diff --git a/.clang-format b/.clang-format index 45c826c3..d83582fc 100644 --- a/.clang-format +++ b/.clang-format @@ -1,39 +1,24 @@ -# Copyright (C) 2016 Olivier Goffart -# -# You may use this file under the terms of the 3-clause BSD license. -# See the file LICENSE from this package for details. +BasedOnStyle: LLVM +Standard: Cpp11 +CommentPragmas: "^!|^:" +PointerBindsToType: false +SpaceAfterTemplateKeyword: false +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +ConstructorInitializerIndentWidth: 2 +NamespaceIndentation: None +AlignAfterOpenBracket: true +AlwaysBreakTemplateDeclarations: true +AllowShortFunctionsOnASingleLine: Inline +SortIncludes: false +IndentCaseLabels: true +IndentPPDirectives: AfterHash +AccessModifierOffset: -2 +IndentWidth: 2 +ColumnLimit: 80 -# This is the clang-format configuration style to be used by Qt, -# based on the rules from https://wiki.qt.io/Qt_Coding_Style and -# https://wiki.qt.io/Coding_Conventions - ---- -# Webkit style was loosely based on the Qt style -BasedOnStyle: WebKit - -Standard: Cpp11 - -# Leave the line breaks up to the user. -# Note that this may be changed at some point in the future. -ColumnLimit: 0 -# How much weight do extra characters after the line length limit have. -# PenaltyExcessCharacter: 4 - -# Disable reflow of qdoc comments: indentation rules are different. -# Translation comments are also excluded. -CommentPragmas: "^!|^:" - -# We want a space between the type and the star for pointer types. -PointerBindsToType: false - -# We use template< without space. -SpaceAfterTemplateKeyword: false - -# We want to break before the operators, but not before a '='. -BreakBeforeBinaryOperators: All - -# Braces are usually attached, but not after functions or class declarations. -BreakBeforeBraces: Custom BraceWrapping: AfterClass: true AfterControlStatement: true @@ -47,48 +32,7 @@ BraceWrapping: BeforeElse: true IndentBraces: false -BreakBeforeTernaryOperators: true - -BreakConstructorInitializers: BeforeComma - -# Indent initializers by 3 spaces -ConstructorInitializerIndentWidth: 4 - -# No indentation for namespaces. -NamespaceIndentation: None - -# Horizontally align arguments after an open bracket. -# The coding style does not specify the following, but this is what gives -# results closest to the existing code. -AlignAfterOpenBracket: true -AlwaysBreakTemplateDeclarations: true - -# Ideally we should also allow less short function in a single line, but -# clang-format does not handle that. -AllowShortFunctionsOnASingleLine: Inline - -# The coding style specifies some include order categories, but also tells to -# separate categories with an empty line. It does not specify the order within -# the categories. Since the SortInclude feature of clang-format does not -# re-order includes separated by empty lines, the feature is not used. -SortIncludes: false - -# macros for which the opening brace stays attached. ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ] - -IndentCaseLabels: true - -IndentPPDirectives: AfterHash - -AlignAfterOpenBracket: Align - -AccessModifierOffset: -4 - -IndentWidth: 4 - #StatementMacros ['Q_OBJECT', 'Q_UNUSED'] -ColumnLimit: 90 - - diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..ac0b7370 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,56 @@ +--- +Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm-*,-llvmlibc-*' +CheckOptions: [{ key: misc-non-private-member-variables-in-classes, value: IgnoreClassesWithAllMemberVariablesBeingPublic }] +WarningsAsErrors: '*' +HeaderFilterRegex: '' +FormatStyle: none + +CheckOptions: + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.ClassMemberCase + value: lower_case + - key: readability-identifier-naming.ConstexprVariableCase + value: CamelCase + - key: readability-identifier-naming.ConstexprVariablePrefix + value: k + - key: readability-identifier-naming.EnumCase + value: CamelCase + - key: readability-identifier-naming.EnumConstantCase + value: CamelCase + - key: readability-identifier-naming.EnumConstantPrefix + value: k + - key: readability-identifier-naming.FunctionCase + value: CamelCase + - key: readability-identifier-naming.GlobalConstantCase + value: CamelCase + - key: readability-identifier-naming.GlobalConstantPrefix + value: k + - key: readability-identifier-naming.StaticConstantCase + value: CamelCase + - key: readability-identifier-naming.StaticConstantPrefix + value: k + - key: readability-identifier-naming.StaticVariableCase + value: lower_case + - key: readability-identifier-naming.MacroDefinitionCase + value: UPPER_CASE + - key: readability-identifier-naming.MacroDefinitionIgnoredRegexp + value: '^[A-Z]+(_[A-Z]+)*_$' + - key: readability-identifier-naming.MemberCase + value: lower_case + - key: readability-identifier-naming.PrivateMemberSuffix + value: _ + - key: readability-identifier-naming.PublicMemberSuffix + value: '' + - key: readability-identifier-naming.NamespaceCase + value: lower_case + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.TypeAliasCase + value: CamelCase + - key: readability-identifier-naming.TypedefCase + value: CamelCase + - key: readability-identifier-naming.VariableCase + value: lower_case + - key: readability-identifier-naming.IgnoreMainLikeFunctions + value: 1 \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 06821538..39d37453 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,6 @@ -#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Workflow configuration -#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- name: Deploy on: @@ -12,9 +12,9 @@ on: paths-ignore: # File-patterns to ignore - '**.md' # Ignore changes to *.md files -#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Define application name & version -#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- env: VERSION: "2.0.0" @@ -26,14 +26,14 @@ env: QML_DIR_WIN: "assets\\qml" PUBLISHER: "Alex Spataru" REPO_DIR: "/home/runner/work/Serial-Studio" - QT_VERSION: 6.6.2 - QT_MODULES: qtserialport qtconnectivity qt5compat qtpositioning qtlocation + QT_VERSION: 6.7.0 + QT_MODULES: qtserialport qtconnectivity qtpositioning qtlocation QMAKE: qmake6 CORES: 16 -#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Workflow jobs (GNU/Linux, macOS & Windows) -#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- jobs: # @@ -60,12 +60,15 @@ jobs: - name: '⚙️ Install dependencies' run: | sudo apt-get update - sudo apt-get install libgl1-mesa-dev libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libzstd-dev libxcb-image0-dev libxcb-util0-dev libxcb-cursor-dev + sudo apt-get install libgl1-mesa-dev libxkbcommon-x11-0 libxcb-icccm4 \ + libxcb-image0 libxcb-keysyms1 libxcb-render-util0 \ + libxcb-xinerama0 libzstd-dev libxcb-image0-dev \ + libxcb-util0-dev libxcb-cursor-dev - name: '🚧 Compile application' run: | - ${{env.QMAKE}} ${{env.QMAKE_PROJECT}} CONFIG+=release PREFIX=/usr - make -j${{env.CORES}} + ${{env.QMAKE}} ${{env.QMAKE_PROJECT}} CONFIG+=release PREFIX=/usr + make -j${{env.CORES}} - name: '⚙️ Install linuxdeploy' run: | @@ -109,24 +112,58 @@ jobs: version: ${{env.QT_VERSION}} modules: ${{env.QT_MODULES}} cache: true + arch: clang_64 install-deps: 'true' + - name: '⚙️ Install Node' + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: '🚧 Compile application' run: | - ${{env.QMAKE}} ${{env.QMAKE_PROJECT}} CONFIG+=release PREFIX=/usr - make -j${{env.CORES}} + ${{env.QMAKE}} ${{env.QMAKE_PROJECT}} CONFIG+=release + make -j${{env.CORES}} - - name: '📦 Package application (macdeployqt and zipfile)' + - name: '📦 Package application' run: | macdeployqt ${{env.EXECUTABLE}}.app -qmldir="${{env.QML_DIR_NIX}}" mv "${{env.EXECUTABLE}}.app" "${{env.APPLICATION}}.app" - ditto -c -k --sequesterRsrc --keepParent "${{env.APPLICATION}}.app" ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.zip - - name: '📤 Upload artifact: ZIP' - uses: actions/upload-artifact@v2 + - name: '🪪 Import Code Signing Certificate' + uses: apple-actions/import-codesign-certs@v2 with: - name: ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.zip - path: ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.zip + p12-file-base64: ${{secrets.CERTIFICATES_P12}} + p12-password: ${{secrets.CERTIFICATES_P12_PASSWORD}} + + - name: '✍🏻 Sign Application' + run: codesign --force --deep --options runtime --sign "${{secrets.DEVELOPER_ID}}" "${{env.APPLICATION}}.app" + + - name: '💽 Create nice DMG' + run: | + npm install --global create-dmg + rm LICENSE.md + create-dmg "${{env.APPLICATION}}.app" --dmg-title="${{env.APPLICATION}}" + mv "${{env.APPLICATION}} ${{env.VERSION}}.dmg" "${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.dmg" + + - name: '📋 Notarize' + uses: alex-spataru/xcode-notarize@v2 + with: + product-path: ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.dmg + appstore-connect-username: ${{secrets.NOTARIZATION_USERNAME}} + appstore-connect-teamid: ${{secrets.NOTARIZATION_TEAMID}} + appstore-connect-password: ${{secrets.NOTARIZATION_PASSWORD}} + + - name: '📌 Staple' + uses: BoundfoxStudios/action-xcode-staple@v1 + with: + product-path: ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.dmg + + - name: '📤 Upload artifact: DMG' + uses: actions/upload-artifact@v4 + with: + name: ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.dmg + path: ${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.dmg # # Windows build @@ -259,7 +296,9 @@ jobs: name: msys2-pkgs path: msys2/*.zst + # # Test Windows MSYS2 packages + # msys2-test: if: ${{false}} needs: msys2-makepkg @@ -324,6 +363,6 @@ jobs: wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage chmod +x pyuploadtool-x86_64.AppImage ./pyuploadtool-x86_64.AppImage **/${{env.EXECUTABLE}}-${{env.VERSION}}-Linux.AppImage - ./pyuploadtool-x86_64.AppImage **/${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.zip + ./pyuploadtool-x86_64.AppImage **/${{env.EXECUTABLE}}-${{env.VERSION}}-macOS.dmg ./pyuploadtool-x86_64.AppImage **/${{env.EXECUTABLE}}-${{env.VERSION}}-Windows.exe ./pyuploadtool-x86_64.AppImage **/${{env.EXECUTABLE}}-${{env.VERSION}}-Windows.zip diff --git a/.gitignore b/.gitignore index 0a5dd035..50f9a661 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,11 @@ .AppleDouble .LSOverride -# SciTools understand -Serial-Studio.und +# Build & IDEs +*.kdev* +build/* +*.vscode +*.layout # Icon must end with two \r Icon @@ -31,3 +34,8 @@ Temporary Items # Qt project file *.pro.user +*.user + +# Clion +.idea/* +cmake-build-* diff --git a/Serial-Studio.pro b/Serial-Studio.pro index 0f987a35..41fd1c42 100644 --- a/Serial-Studio.pro +++ b/Serial-Studio.pro @@ -20,9 +20,9 @@ # THE SOFTWARE. # -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Make options -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- UI_DIR = uic MOC_DIR = moc @@ -33,15 +33,15 @@ isEmpty(PREFIX) { PREFIX = /usr } -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Qt configuration -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- -TEMPLATE = app # Project template -TARGET = serial-studio # Set default target name -CONFIG += qtquickcompiler # Pre-compile QML interface -CONFIG += utf8_source # Source code encoding -QTPLUGIN += qsvg # Fixes issues with windeployqt +TEMPLATE = app +TARGET = serial-studio +CONFIG += qtquickcompiler +CONFIG += utf8_source +QTPLUGIN += qsvg QT += xml QT += svg @@ -56,15 +56,9 @@ QT += printsupport QT += quickcontrols2 -equals(QT_MAJOR_VERSION, 6) { - QT += core5compat -} - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 - -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Compiler options -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- CONFIG += c++11 CONFIG += silent @@ -79,68 +73,64 @@ CONFIG(release, debug|release) { } } -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Serial Studio compile-time settings -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- -DEFINES += SERIAL_STUDIO_INCLUDE_MOC +#DEFINES += DISABLE_QS # If enabled, QSimpleUpdater shall not be used by the app + # This is the default behaviour for MinGW. -#DEFINES += DISABLE_QSU # If enabled, QSimpleUpdater shall not be used by the app. - # This is the default behaviour for MinGW. - -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Libraries -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- include(libs/Libraries.pri) -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Assets -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- include(assets/Assets.pri) -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Deploy options -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- win32* { - TARGET = SerialStudio # Change target name - RC_FILE = deploy/windows/resources/info.rc # Set applicaiton icon - OTHER_FILES += deploy/windows/nsis/setup.nsi # Setup script + TARGET = SerialStudio + RC_FILE = deploy/windows/resources/info.rc + OTHER_FILES += deploy/windows/nsis/setup.nsi } macx* { - TARGET = SerialStudio # Change target name - ICON = deploy/macOS/icon.icns # icon file - RC_FILE = deploy/macOS/icon.icns # icon file - QMAKE_INFO_PLIST = deploy/macOS/info.plist # Add info.plist file - CONFIG += sdk_no_version_check # Avoid warnings with Big Sur + TARGET = SerialStudio + ICON = deploy/macOS/icon.icns + RC_FILE = deploy/macOS/icon.icns + QMAKE_INFO_PLIST = deploy/macOS/info.plist + CONFIG += sdk_no_version_check } linux:!android { - PKGCONFIG += libssl # Add OpenSSL library - target.path = $$PREFIX/bin # Set binary installation path - icon.path = $$PREFIX/share/pixmaps # icon instalation path - desktop.path = $$PREFIX/share/applications # *.desktop instalation path - icon.files += deploy/linux/serial-studio.png # Add application icon - desktop.files += deploy/linux/serial-studio.desktop # Add *.desktop file - copyright.files += deploy/linux/copyright # Libc6 file for linuxdeployqt - copyright.path = $$PREFIX/share/doc/libc6 # libc6 copyright path - INSTALLS += target copyright desktop icon # make install targets + PKGCONFIG += libssl + target.path = $$PREFIX/bin + icon.path = $$PREFIX/share/pixmaps + desktop.path = $$PREFIX/share/applications + icon.files += deploy/linux/serial-studio.png + desktop.files += deploy/linux/serial-studio.desktop + INSTALLS += target copyright desktop icon } mingw { target.path = $$PREFIX/bin - license.path = $$PREFIX/share/licenses/$$TARGET # Set license install path - license.files += LICENSE.md # Add LICENSE.md file - INSTALLS += target license # Install target+licence (MSYS2) - DEFINES += DISABLE_QSU # Disable QSimpleUpdater (MSYS2) + license.path = $$PREFIX/share/licenses/$$TARGET + license.files += LICENSE.md + INSTALLS += target license + DEFINES += DISABLE_QSU } -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Import source code -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- INCLUDEPATH += src @@ -161,7 +151,6 @@ HEADERS += \ src/JSON/Generator.h \ src/JSON/Group.h \ src/MQTT/Client.h \ - src/Misc/MacExtras.h \ src/Misc/ModuleManager.h \ src/Misc/ThemeManager.h \ src/Misc/TimerEvents.h \ @@ -205,7 +194,6 @@ SOURCES += \ src/JSON/Generator.cpp \ src/JSON/Group.cpp \ src/MQTT/Client.cpp \ - src/Misc/MacExtras.cpp \ src/Misc/ModuleManager.cpp \ src/Misc/ThemeManager.cpp \ src/Misc/TimerEvents.cpp \ @@ -236,9 +224,9 @@ SOURCES += \ src/UI/Widgets/Terminal.cpp \ src/main.cpp -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Import QML source code -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- DISTFILES += \ assets/qml/*.qml \ @@ -252,9 +240,9 @@ DISTFILES += \ assets/qml/PlatformDependent/*.qml \ assets/qml/Panes/SetupPanes/Devices/*.qml \ -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # Deploy files -#----------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- OTHER_FILES += \ deploy/linux/* \ diff --git a/assets/Resources.qrc b/assets/Resources.qrc index 6df2b1cc..32927d2a 100644 --- a/assets/Resources.qrc +++ b/assets/Resources.qrc @@ -57,6 +57,7 @@ icons/multiplot.svg icons/new.svg icons/open.svg + icons/paste.svg icons/plot.svg icons/points.svg icons/power.svg @@ -131,6 +132,7 @@ qml/ProjectEditor/JsonDatasetDelegate.qml qml/ProjectEditor/JsonGroupDelegate.qml qml/ProjectEditor/TreeView.qml + qml/Widgets/GpsMap.qml qml/Widgets/Icon.qml qml/Widgets/JSONDropArea.qml qml/Widgets/Shadow.qml @@ -144,15 +146,13 @@ qml/Windows/MQTTConfiguration.qml qml/Windows/ProjectEditor.qml qml/main.qml + scripts/frame-parser.js themes/1_Flat.json themes/2_Dark.json themes/3_Classic.json themes/4_Midnight.json themes/5_Noir.json themes/6_Mathworks.json - touchbar/console.png - touchbar/dashboard.png - touchbar/setup.png translations/de.qm translations/de.ts translations/en.qm @@ -178,8 +178,5 @@ window-border/minimize.svg window-border/restore.svg window-border/unmaximize.svg - icons/paste.svg - scripts/frame-parser.js - qml/Widgets/GpsMap.qml diff --git a/assets/messages/Acknowledgements.txt b/assets/messages/Acknowledgements.txt index e3196c87..75cf7c42 100644 --- a/assets/messages/Acknowledgements.txt +++ b/assets/messages/Acknowledgements.txt @@ -74,26 +74,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -## QMapControl - -Copyright (C) 2007 - 2008 Kai Winter - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with QMapControl. If not, see . - -Contact e-mail: kaiwinter@gmx.de -Program URL : http://qmapcontrol.sourceforge.net/ - ## qtcsv Copyright © 2015 Antony Cherepanov (antony.cherepanov@gmail.com) @@ -731,13 +711,6 @@ Everyone is permitted to copy and distribute copies of this Agreement, but in or This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. -## KDMacTouchBar - -KDMacTouchBar is Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB. - -You may use, distribute and copy KDMacTouchBar under the terms of GNU Lesser General Public License version 3, which is displayed below. - -You may even contact us at info@kdab.com for different licensing options. ### GNU Lesser General Public License diff --git a/assets/messages/Welcome_DE.txt b/assets/messages/Welcome_DE.txt index 6ca4cc70..c565a60e 100644 --- a/assets/messages/Welcome_DE.txt +++ b/assets/messages/Welcome_DE.txt @@ -24,5 +24,5 @@ MCU-Projekten, lesen Sie bitte das Wiki: → https://github.com/Serial-Studio/Serial-Studio/wiki -Tipp: Verwenden Sie den JSON-Editor zum Erstellen und Bearbeiten von +Tipp: Verwenden Sie den Projekt-Editor zum Erstellen und Bearbeiten von Serial Studio-Projektdateien. diff --git a/assets/messages/Welcome_EN.txt b/assets/messages/Welcome_EN.txt index 55bf6c6b..6d2507ba 100644 --- a/assets/messages/Welcome_EN.txt +++ b/assets/messages/Welcome_EN.txt @@ -22,4 +22,4 @@ the wiki: → https://github.com/Serial-Studio/Serial-Studio/wiki -Tip: use the JSON Editor to create and edit Serial Studio project files. +Tip: use the Project Editor to create and edit Serial Studio project files. diff --git a/assets/messages/Welcome_ES.txt b/assets/messages/Welcome_ES.txt index 9e065e17..b9b57989 100644 --- a/assets/messages/Welcome_ES.txt +++ b/assets/messages/Welcome_ES.txt @@ -22,4 +22,4 @@ actuales, por favor lea la wiki: → https://github.com/Serial-Studio/Serial-Studio/wiki -Consejo: utilice el Editor JSON para crear y editar proyectos de Serial Studio. +Consejo: utilice el Editor de Proyectos para crear y editar proyectos de Serial Studio. diff --git a/assets/qml/Dashboard/DashboardTitle.qml b/assets/qml/Dashboard/DashboardTitle.qml index 101e700b..4b4e1ec6 100644 --- a/assets/qml/Dashboard/DashboardTitle.qml +++ b/assets/qml/Dashboard/DashboardTitle.qml @@ -28,69 +28,69 @@ import QtQuick.Controls import "../Widgets" as Widgets Rectangle { - id: root - radius: 5 + id: root + radius: 5 - property alias consoleChecked: consoleBt.checked + property alias consoleChecked: consoleBt.checked - Settings { - property alias consoleVisible: root.consoleChecked + Settings { + property alias consoleVisible: root.consoleChecked + } + + gradient: Gradient { + GradientStop { + position: 0 + color: Cpp_ThemeManager.windowGradient1 } - gradient: Gradient { - GradientStop { - position: 0 - color: Cpp_ThemeManager.windowGradient1 - } + GradientStop { + position: 1 + color: Cpp_ThemeManager.windowGradient2 + } + } - GradientStop { - position: 1 - color: Cpp_ThemeManager.windowGradient2 - } + RowLayout { + spacing: app.spacing + + anchors { + margins: 0 + left: parent.left + right: parent.right + leftMargin: app.spacing + rightMargin: app.spacing + verticalCenter: parent.verticalCenter } - RowLayout { - spacing: app.spacing - - anchors { - margins: 0 - left: parent.left - right: parent.right - leftMargin: app.spacing - rightMargin: app.spacing - verticalCenter: parent.verticalCenter - } - - Widgets.Icon { - Layout.alignment: Qt.AlignVCenter - source: "qrc:/icons/arrow-right.svg" - } - - Label { - font.bold: true - font.pixelSize: 16 - color: palette.brightText - font.family: app.monoFont - text: Cpp_UI_Dashboard.title - Layout.alignment: Qt.AlignVCenter - } - - Item { - Layout.fillWidth: true - } - - Button { - flat: true - id: consoleBt - checkable: true - font.bold: true - text: qsTr("Console") - Layout.alignment: Qt.AlignVCenter - icon.source: "qrc:/icons/code.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.windowGradient1 - palette.window: Cpp_ThemeManager.windowGradient1 - } + Widgets.Icon { + Layout.alignment: Qt.AlignVCenter + source: "qrc:/icons/arrow-right.svg" } + + Label { + font.bold: true + font.pixelSize: 16 + color: palette.brightText + font.family: app.monoFont + text: Cpp_UI_Dashboard.title + Layout.alignment: Qt.AlignVCenter + } + + Item { + Layout.fillWidth: true + } + + Button { + flat: true + id: consoleBt + checkable: true + font.bold: true + text: qsTr("Console") + Layout.alignment: Qt.AlignVCenter + icon.source: "qrc:/icons/code.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.windowGradient1 + palette.window: Cpp_ThemeManager.windowGradient1 + } + } } diff --git a/assets/qml/Dashboard/ViewOptions.qml b/assets/qml/Dashboard/ViewOptions.qml index 7b89925b..07ad017d 100644 --- a/assets/qml/Dashboard/ViewOptions.qml +++ b/assets/qml/Dashboard/ViewOptions.qml @@ -28,307 +28,307 @@ import QtQuick.Controls import "../Widgets" as Widgets Widgets.Window { - id: root + id: root + + // + // Window properties + // + gradient: true + title: qsTr("View") + headerDoubleClickEnabled: false + icon.source: "qrc:/icons/visibility.svg" + backgroundColor: Cpp_ThemeManager.paneWindowBackground + + // + // Signals + // + signal widgetSizeChanged(var maxSize) + + // + // Maps the slider position to points + // https://stackoverflow.com/a/846249 + // + function logslider(position) { + var minp = 0 + var maxp = 100 + var minv = Math.log(10) + var maxv = Math.log(10000) + var scale = (maxv - minv) / (maxp - minp); + return Math.exp(minv + scale * (position - minp)).toFixed(0); + } + + // + // Maps the points value to the slider position + // https://stackoverflow.com/a/846249 + // + function logposition(value) { + var minp = 0 + var maxp = 100 + var minv = Math.log(10) + var maxv = Math.log(10000) + var scale = (maxv - minv) / (maxp - minp) + var result = (Math.log(value) - minv) / scale + minp; + return result.toFixed(0) + } + + // + // Settings + // + Settings { + property alias points: plotPoints.value + property alias widgetSize: widgetSize.value + property alias decimalPlaces: decimalPlaces.value + } + + // + // Put all items inside a scrollview + // + ScrollView { + clip: true + contentWidth: -1 + anchors.fill: parent + anchors.margins: app.spacing + anchors.topMargin: root.borderWidth + anchors.bottomMargin: root.borderWidth // - // Window properties + // Main layout // - gradient: true - title: qsTr("View") - headerDoubleClickEnabled: false - icon.source: "qrc:/icons/visibility.svg" - backgroundColor: Cpp_ThemeManager.paneWindowBackground + ColumnLayout { + id: layout + x: app.spacing + spacing: app.spacing / 2 + width: parent.width - 10 - 2 * app.spacing - // - // Signals - // - signal widgetSizeChanged(var maxSize) + // + // Spacer + // + Item { + height: app.spacing + } - // - // Maps the slider position to points - // https://stackoverflow.com/a/846249 - // - function logslider(position) { - var minp = 0 - var maxp = 100 - var minv = Math.log(10) - var maxv = Math.log(10000) - var scale = (maxv - minv) / (maxp - minp); - return Math.exp(minv + scale * (position - minp)).toFixed(0); - } + // + // View options title + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 - // - // Maps the points value to the slider position - // https://stackoverflow.com/a/846249 - // - function logposition(value) { - var minp = 0 - var maxp = 100 - var minv = Math.log(10) - var maxv = Math.log(10000) - var scale = (maxv - minv) / (maxp - minp) - var result = (Math.log(value) - minv) / scale + minp; - return result.toFixed(0) - } - - // - // Settings - // - Settings { - property alias points: plotPoints.value - property alias widgetSize: widgetSize.value - property alias decimalPlaces: decimalPlaces.value - } - - // - // Put all items inside a scrollview - // - ScrollView { - clip: true - contentWidth: -1 - anchors.fill: parent - anchors.margins: app.spacing - anchors.topMargin: root.borderWidth - anchors.bottomMargin: root.borderWidth - - // - // Main layout - // - ColumnLayout { - id: layout - x: app.spacing - spacing: app.spacing / 2 - width: parent.width - 10 - 2 * app.spacing - - // - // Spacer - // - Item { - height: app.spacing - } - - // - // View options title - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 - - Widgets.Icon { - width: 18 - height: 18 - color: palette.text - source: "qrc:/icons/visibility.svg" - } - - Label { - font.bold: true - text: qsTr("Visualization options") - } - - Item { - Layout.fillWidth: true - } - } - - // - // Spacer - // - Item { - height: app.spacing - } - - // - // Visualization controls - // - GridLayout { - columns: 3 - rowSpacing: app.spacing - columnSpacing: app.spacing - - // - // Number of plot points slider - // - Label { - text: qsTr("Points:") - visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 - } Slider { - id: plotPoints - from: 0 - to: 100 - Layout.fillWidth: true - value: logposition(100) - visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 - onValueChanged: { - var log = logslider(value) - if (Cpp_UI_Dashboard.points !== log) - Cpp_UI_Dashboard.points = log - } - } Label { - text: logslider(plotPoints.value) - visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 - } - - // - // Number of decimal places - // - Label { - text: qsTr("Decimal places:") - } Slider { - id: decimalPlaces - to: 6 - from: 0 - value: 2 - Layout.fillWidth: true - onValueChanged: Cpp_UI_Dashboard.precision = value - } Label { - text: Cpp_UI_Dashboard.precision - } - - - // - // Number of plot points slider - // - Label { - text: qsTr("Widget size:") - } Slider { - id: widgetSize - to: 720 - from: 400 - value: 480 - Layout.fillWidth: true - onValueChanged: widgetSizeChanged(value) - } Item {} - } - - // - // Spacer - // - Item { - height: app.spacing - } - - // - // Groups - // - ViewOptionsDelegate { - title: qsTr("Datasets") - icon: "qrc:/icons/group.svg" - count: Cpp_UI_Dashboard.groupCount - titles: Cpp_UI_Dashboard.groupTitles - onCheckedChanged: Cpp_UI_Dashboard.setGroupVisible(index, checked) - } - - // - // Multiplots - // - ViewOptionsDelegate { - title: qsTr("Multiple data plots") - icon: "qrc:/icons/multiplot.svg" - count: Cpp_UI_Dashboard.multiPlotCount - titles: Cpp_UI_Dashboard.multiPlotTitles - onCheckedChanged: Cpp_UI_Dashboard.setMultiplotVisible(index, checked) - } - - // - // LEDs - // - ViewOptionsDelegate { - title: qsTr("LED Panels") - icon: "qrc:/icons/led.svg" - count: Cpp_UI_Dashboard.ledCount - titles: Cpp_UI_Dashboard.ledTitles - onCheckedChanged: Cpp_UI_Dashboard.setLedVisible(index, checked) - } - - // - // FFT - // - ViewOptionsDelegate { - title: qsTr("FFT plots") - icon: "qrc:/icons/fft.svg" - count: Cpp_UI_Dashboard.fftCount - titles: Cpp_UI_Dashboard.fftTitles - onCheckedChanged: Cpp_UI_Dashboard.setFFTVisible(index, checked) - } - - // - // Plots - // - ViewOptionsDelegate { - title: qsTr("Data plots") - icon: "qrc:/icons/plot.svg" - count: Cpp_UI_Dashboard.plotCount - titles: Cpp_UI_Dashboard.plotTitles - onCheckedChanged: Cpp_UI_Dashboard.setPlotVisible(index, checked) - } - - // - // Bars - // - ViewOptionsDelegate { - title: qsTr("Bars") - icon: "qrc:/icons/bar.svg" - count: Cpp_UI_Dashboard.barCount - titles: Cpp_UI_Dashboard.barTitles - onCheckedChanged: Cpp_UI_Dashboard.setBarVisible(index, checked) - } - - // - // Gauges - // - ViewOptionsDelegate { - title: qsTr("Gauges") - icon: "qrc:/icons/gauge.svg" - count: Cpp_UI_Dashboard.gaugeCount - titles: Cpp_UI_Dashboard.gaugeTitles - onCheckedChanged: Cpp_UI_Dashboard.setGaugeVisible(index, checked) - } - - // - // Compasses - // - ViewOptionsDelegate { - title: qsTr("Compasses") - icon: "qrc:/icons/compass.svg" - count: Cpp_UI_Dashboard.compassCount - titles: Cpp_UI_Dashboard.compassTitles - onCheckedChanged: Cpp_UI_Dashboard.setCompassVisible(index, checked) - } - - // - // Gyroscopes - // - ViewOptionsDelegate { - title: qsTr("Gyroscopes") - icon: "qrc:/icons/gyro.svg" - count: Cpp_UI_Dashboard.gyroscopeCount - titles: Cpp_UI_Dashboard.gyroscopeTitles - onCheckedChanged: Cpp_UI_Dashboard.setGyroscopeVisible(index, checked) - } - - // - // Accelerometers - // - ViewOptionsDelegate { - title: qsTr("Accelerometers") - icon: "qrc:/icons/accelerometer.svg" - count: Cpp_UI_Dashboard.accelerometerCount - titles: Cpp_UI_Dashboard.accelerometerTitles - onCheckedChanged: Cpp_UI_Dashboard.setAccelerometerVisible(index, checked) - } - - // - // Maps - // - ViewOptionsDelegate { - title: qsTr("GPS") - icon: "qrc:/icons/gps.svg" - count: Cpp_UI_Dashboard.gpsCount - titles: Cpp_UI_Dashboard.gpsTitles - onCheckedChanged: Cpp_UI_Dashboard.setGpsVisible(index, checked) - } + Widgets.Icon { + width: 18 + height: 18 + color: palette.text + source: "qrc:/icons/visibility.svg" } + + Label { + font.bold: true + text: qsTr("Visualization options") + } + + Item { + Layout.fillWidth: true + } + } + + // + // Spacer + // + Item { + height: app.spacing + } + + // + // Visualization controls + // + GridLayout { + columns: 3 + rowSpacing: app.spacing + columnSpacing: app.spacing + + // + // Number of plot points slider + // + Label { + text: qsTr("Points:") + visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 + } Slider { + id: plotPoints + from: 0 + to: 100 + Layout.fillWidth: true + value: logposition(100) + visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 + onValueChanged: { + var log = logslider(value) + if (Cpp_UI_Dashboard.points !== log) + Cpp_UI_Dashboard.points = log + } + } Label { + text: logslider(plotPoints.value) + visible: Cpp_UI_Dashboard.plotCount > 0 || Cpp_UI_Dashboard.multiPlotCount > 0 + } + + // + // Number of decimal places + // + Label { + text: qsTr("Decimal places:") + } Slider { + id: decimalPlaces + to: 6 + from: 0 + value: 2 + Layout.fillWidth: true + onValueChanged: Cpp_UI_Dashboard.precision = value + } Label { + text: Cpp_UI_Dashboard.precision + } + + + // + // Number of plot points slider + // + Label { + text: qsTr("Widget size:") + } Slider { + id: widgetSize + to: 720 + from: 400 + value: 480 + Layout.fillWidth: true + onValueChanged: widgetSizeChanged(value) + } Item {} + } + + // + // Spacer + // + Item { + height: app.spacing + } + + // + // Groups + // + ViewOptionsDelegate { + title: qsTr("Datasets") + icon: "qrc:/icons/group.svg" + count: Cpp_UI_Dashboard.groupCount + titles: Cpp_UI_Dashboard.groupTitles + onCheckedChanged: Cpp_UI_Dashboard.setGroupVisible(index, checked) + } + + // + // Multiplots + // + ViewOptionsDelegate { + title: qsTr("Multiple data plots") + icon: "qrc:/icons/multiplot.svg" + count: Cpp_UI_Dashboard.multiPlotCount + titles: Cpp_UI_Dashboard.multiPlotTitles + onCheckedChanged: Cpp_UI_Dashboard.setMultiplotVisible(index, checked) + } + + // + // LEDs + // + ViewOptionsDelegate { + title: qsTr("LED Panels") + icon: "qrc:/icons/led.svg" + count: Cpp_UI_Dashboard.ledCount + titles: Cpp_UI_Dashboard.ledTitles + onCheckedChanged: Cpp_UI_Dashboard.setLedVisible(index, checked) + } + + // + // FFT + // + ViewOptionsDelegate { + title: qsTr("FFT plots") + icon: "qrc:/icons/fft.svg" + count: Cpp_UI_Dashboard.fftCount + titles: Cpp_UI_Dashboard.fftTitles + onCheckedChanged: Cpp_UI_Dashboard.setFFTVisible(index, checked) + } + + // + // Plots + // + ViewOptionsDelegate { + title: qsTr("Data plots") + icon: "qrc:/icons/plot.svg" + count: Cpp_UI_Dashboard.plotCount + titles: Cpp_UI_Dashboard.plotTitles + onCheckedChanged: Cpp_UI_Dashboard.setPlotVisible(index, checked) + } + + // + // Bars + // + ViewOptionsDelegate { + title: qsTr("Bars") + icon: "qrc:/icons/bar.svg" + count: Cpp_UI_Dashboard.barCount + titles: Cpp_UI_Dashboard.barTitles + onCheckedChanged: Cpp_UI_Dashboard.setBarVisible(index, checked) + } + + // + // Gauges + // + ViewOptionsDelegate { + title: qsTr("Gauges") + icon: "qrc:/icons/gauge.svg" + count: Cpp_UI_Dashboard.gaugeCount + titles: Cpp_UI_Dashboard.gaugeTitles + onCheckedChanged: Cpp_UI_Dashboard.setGaugeVisible(index, checked) + } + + // + // Compasses + // + ViewOptionsDelegate { + title: qsTr("Compasses") + icon: "qrc:/icons/compass.svg" + count: Cpp_UI_Dashboard.compassCount + titles: Cpp_UI_Dashboard.compassTitles + onCheckedChanged: Cpp_UI_Dashboard.setCompassVisible(index, checked) + } + + // + // Gyroscopes + // + ViewOptionsDelegate { + title: qsTr("Gyroscopes") + icon: "qrc:/icons/gyro.svg" + count: Cpp_UI_Dashboard.gyroscopeCount + titles: Cpp_UI_Dashboard.gyroscopeTitles + onCheckedChanged: Cpp_UI_Dashboard.setGyroscopeVisible(index, checked) + } + + // + // Accelerometers + // + ViewOptionsDelegate { + title: qsTr("Accelerometers") + icon: "qrc:/icons/accelerometer.svg" + count: Cpp_UI_Dashboard.accelerometerCount + titles: Cpp_UI_Dashboard.accelerometerTitles + onCheckedChanged: Cpp_UI_Dashboard.setAccelerometerVisible(index, checked) + } + + // + // Maps + // + ViewOptionsDelegate { + title: qsTr("GPS") + icon: "qrc:/icons/gps.svg" + count: Cpp_UI_Dashboard.gpsCount + titles: Cpp_UI_Dashboard.gpsTitles + onCheckedChanged: Cpp_UI_Dashboard.setGpsVisible(index, checked) + } } + } } diff --git a/assets/qml/Dashboard/ViewOptionsDelegate.qml b/assets/qml/Dashboard/ViewOptionsDelegate.qml index 631899c5..fe113661 100644 --- a/assets/qml/Dashboard/ViewOptionsDelegate.qml +++ b/assets/qml/Dashboard/ViewOptionsDelegate.qml @@ -5,76 +5,76 @@ import QtQuick.Controls import "../Widgets" as Widgets ColumnLayout { - id: root - visible: count > 0 + id: root + visible: count > 0 + spacing: app.spacing + + property int count: 0 + property var titles:[""] + property string icon: "" + property string title: "" + + signal checkedChanged(var index, var checked) + + Connections { + target: Cpp_UI_Dashboard + + function onDataReset() { + hideAll.checked = false + } + } + + RowLayout { spacing: app.spacing + visible: root.count > 0 - property int count: 0 - property var titles:[""] - property string icon: "" - property string title: "" - - signal checkedChanged(var index, var checked) - - Connections { - target: Cpp_UI_Dashboard - - function onDataReset() { - hideAll.checked = false - } + Widgets.Icon { + width: 18 + height: 18 + source: root.icon + color: palette.text + opacity: hideAll.checked ? 0.5 : 1 } - RowLayout { - spacing: app.spacing - visible: root.count > 0 - - Widgets.Icon { - width: 18 - height: 18 - source: root.icon - color: palette.text - opacity: hideAll.checked ? 0.5 : 1 - } - - Label { - font.bold: true - text: root.title - opacity: hideAll.checked ? 0.5 : 1 - } - - Item { - Layout.fillWidth: true - } - - RoundButton { - id: hideAll - width: 24 - height: 24 - flat: true - checkable: true - icon.color: palette.text - Layout.rightMargin: -app.spacing - icon.source: checked ? "qrc:/icons/show-all.svg" : "qrc:/icons/hide-all.svg" - onCheckedChanged: { - for (var i = 0; i < root.count; ++i) - root.checkedChanged(i, !checked) - } - } - } - - Repeater { - model: hideAll.checked ? 0 : root.count - delegate: Switch { - checked: true - Layout.fillWidth: true - text: root.titles[index] - onCheckedChanged: root.checkedChanged(index, checked) - palette.highlight: Cpp_ThemeManager.alternativeHighlight - } + Label { + font.bold: true + text: root.title + opacity: hideAll.checked ? 0.5 : 1 } Item { - height: app.spacing - visible: !hideAll.checked && count > 0 + Layout.fillWidth: true } + + RoundButton { + id: hideAll + width: 24 + height: 24 + flat: true + checkable: true + icon.color: palette.text + Layout.rightMargin: -app.spacing + icon.source: checked ? "qrc:/icons/show-all.svg" : "qrc:/icons/hide-all.svg" + onCheckedChanged: { + for (var i = 0; i < root.count; ++i) + root.checkedChanged(i, !checked) + } + } + } + + Repeater { + model: hideAll.checked ? 0 : root.count + delegate: Switch { + checked: true + Layout.fillWidth: true + text: root.titles[index] + onCheckedChanged: root.checkedChanged(index, checked) + palette.highlight: Cpp_ThemeManager.alternativeHighlight + } + } + + Item { + height: app.spacing + visible: !hideAll.checked && count > 0 + } } diff --git a/assets/qml/Dashboard/WidgetDelegate.qml b/assets/qml/Dashboard/WidgetDelegate.qml index 5742adf7..787f2079 100644 --- a/assets/qml/Dashboard/WidgetDelegate.qml +++ b/assets/qml/Dashboard/WidgetDelegate.qml @@ -30,125 +30,125 @@ import "../Widgets" as Widgets import "../FramelessWindow" as FramelessWindow Item { - id: root + id: root - property int widgetIndex: -1 - property FramelessWindow.CustomWindow externalWindow: null + property int widgetIndex: -1 + property FramelessWindow.CustomWindow externalWindow: null - Widgets.Window { - id: window + Widgets.Window { + id: window + anchors.fill: parent + title: widget.widgetTitle + icon.source: widget.widgetIcon + headerDoubleClickEnabled: true + borderColor: Cpp_ThemeManager.widgetWindowBorder + onHeaderDoubleClicked: { + if (root.externalWindow !== null) + root.externalWindow.showNormal() + else + externalWindowLoader.active = true + } + + DashboardWidget { + id: widget + widgetIndex: root.widgetIndex + anchors { + fill: parent + leftMargin: window.borderWidth + rightMargin: window.borderWidth + bottomMargin: window.borderWidth + } + + // + // Hack: render a GPS map using QML code instead of QtWidgets + // + Loader { anchors.fill: parent - title: widget.widgetTitle - icon.source: widget.widgetIcon - headerDoubleClickEnabled: true - borderColor: Cpp_ThemeManager.widgetWindowBorder - onHeaderDoubleClicked: { - if (root.externalWindow !== null) - root.externalWindow.showNormal() - else - externalWindowLoader.active = true + asynchronous: true + active: widget.isGpsMap + visible: widget.isGpsMap && status == Loader.Ready + sourceComponent: Widgets.GpsMap { + altitude: widget.gpsAltitude + latitude: widget.gpsLatitude + longitude: widget.gpsLongitude + } + } + } + } + + Loader { + id: externalWindowLoader + + active: false + asynchronous: true + + sourceComponent: FramelessWindow.CustomWindow { + id: _window + minimumWidth: 640 + shadowMargin + minimumHeight: 480 + shadowMargin + title: externalWidget.widgetTitle + titlebarText: Cpp_ThemeManager.text + titlebarColor: Cpp_ThemeManager.widgetWindowBackground + backgroundColor: Cpp_ThemeManager.widgetWindowBackground + borderColor: isMaximized ? backgroundColor : Cpp_ThemeManager.highlight + extraFlags: Qt.WindowStaysOnTopHint | Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + + Timer { + id: timer + interval: 200 + onTriggered: _window.showNormal() + } + + Component.onCompleted: { + root.externalWindow = this + timer.start() + } + + Rectangle { + clip: true + anchors.fill: parent + radius: _window.radius + anchors.margins: _window.shadowMargin + color: Cpp_ThemeManager.widgetWindowBackground + anchors.topMargin: _window.titlebar.height + _window.shadowMargin + + Rectangle { + height: _window.radius + color: Cpp_ThemeManager.widgetWindowBackground + anchors { + top: parent.top + left: parent.left + right: parent.right + } } DashboardWidget { - id: widget - widgetIndex: root.widgetIndex - anchors { - fill: parent - leftMargin: window.borderWidth - rightMargin: window.borderWidth - bottomMargin: window.borderWidth - } + id: externalWidget + anchors.fill: parent + isExternalWindow: true + widgetIndex: root.widgetIndex + widgetVisible: _window.visible + anchors.margins: _window.radius - // - // Hack: render a GPS map using QML code instead of QtWidgets - // - Loader { - anchors.fill: parent - asynchronous: true - active: widget.isGpsMap - visible: widget.isGpsMap && status == Loader.Ready - sourceComponent: Widgets.GpsMap { - altitude: widget.gpsAltitude - latitude: widget.gpsLatitude - longitude: widget.gpsLongitude - } - } - } - } - - Loader { - id: externalWindowLoader - - active: false - asynchronous: true - - sourceComponent: FramelessWindow.CustomWindow { - id: _window - minimumWidth: 640 + shadowMargin - minimumHeight: 480 + shadowMargin - title: externalWidget.widgetTitle - titlebarText: Cpp_ThemeManager.text - titlebarColor: Cpp_ThemeManager.widgetWindowBackground - backgroundColor: Cpp_ThemeManager.widgetWindowBackground - borderColor: isMaximized ? backgroundColor : Cpp_ThemeManager.highlight - extraFlags: Qt.WindowStaysOnTopHint | Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - - Timer { - id: timer - interval: 200 - onTriggered: _window.showNormal() - } - - Component.onCompleted: { - root.externalWindow = this - timer.start() - } - - Rectangle { - clip: true - anchors.fill: parent - radius: _window.radius - anchors.margins: _window.shadowMargin - color: Cpp_ThemeManager.widgetWindowBackground - anchors.topMargin: _window.titlebar.height + _window.shadowMargin - - Rectangle { - height: _window.radius - color: Cpp_ThemeManager.widgetWindowBackground - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - - DashboardWidget { - id: externalWidget - anchors.fill: parent - isExternalWindow: true - widgetIndex: root.widgetIndex - widgetVisible: _window.visible - anchors.margins: _window.radius - - Loader { - anchors.fill: parent - asynchronous: true - active: externalWidget.isGpsMap - visible: externalWidget.isGpsMap && status == Loader.Ready - sourceComponent: Widgets.GpsMap { - altitude: externalWidget.gpsAltitude - latitude: externalWidget.gpsLatitude - longitude: externalWidget.gpsLongitude - } - } - } - } - - FramelessWindow.ResizeHandles { - window: _window - anchors.fill: parent - handleSize: _window.handleSize + Loader { + anchors.fill: parent + asynchronous: true + active: externalWidget.isGpsMap + visible: externalWidget.isGpsMap && status == Loader.Ready + sourceComponent: Widgets.GpsMap { + altitude: externalWidget.gpsAltitude + latitude: externalWidget.gpsLatitude + longitude: externalWidget.gpsLongitude } + } } + } + + FramelessWindow.ResizeHandles { + window: _window + anchors.fill: parent + handleSize: _window.handleSize + } } + } } diff --git a/assets/qml/Dashboard/WidgetGrid.qml b/assets/qml/Dashboard/WidgetGrid.qml index f88a652e..54d28c43 100644 --- a/assets/qml/Dashboard/WidgetGrid.qml +++ b/assets/qml/Dashboard/WidgetGrid.qml @@ -27,101 +27,101 @@ import QtQuick.Controls import "../Widgets" as Widgets Widgets.Window { - id: root + id: root - // - // Window properties - // - gradient: true - title: qsTr("Data") - headerDoubleClickEnabled: false - icon.source: "qrc:/icons/dataset.svg" - backgroundColor: Cpp_ThemeManager.paneWindowBackground + // + // Window properties + // + gradient: true + title: qsTr("Data") + headerDoubleClickEnabled: false + icon.source: "qrc:/icons/dataset.svg" + backgroundColor: Cpp_ThemeManager.paneWindowBackground - // Hacks for calculating cell width - property int maxSize: 480 - readonly property int minSize: maxSize * 356/480 - readonly property int cellHeight: cellWidth * (2/3) - readonly property int columns: Math.floor((grid.width - 2 * scroll.width) / cWidth) - readonly property int cellWidth: cWidth + ((grid.width - 2 * scroll.width) - (cWidth) * columns) / columns - readonly property int cWidth: Math.min(Math.max(minSize, (grid.width - 2 * scroll.width) / model.count), maxSize) + // Hacks for calculating cell width + property int maxSize: 480 + readonly property int minSize: maxSize * 356/480 + readonly property int cellHeight: cellWidth * (2/3) + readonly property int columns: Math.floor((grid.width - 2 * scroll.width) / cWidth) + readonly property int cellWidth: cWidth + ((grid.width - 2 * scroll.width) - (cWidth) * columns) / columns + readonly property int cWidth: Math.min(Math.max(minSize, (grid.width - 2 * scroll.width) / model.count), maxSize) - // - // Put everything into a flickable to enable scrolling - // - Item { - clip: true - anchors.fill: parent + // + // Put everything into a flickable to enable scrolling + // + Item { + clip: true + anchors.fill: parent - Flickable { - contentWidth: width - contentHeight: grid.height + Flickable { + contentWidth: width + contentHeight: grid.height - anchors { - fill: parent - margins: app.spacing * 2 - rightMargin: app.spacing - } + anchors { + fill: parent + margins: app.spacing * 2 + rightMargin: app.spacing + } - ScrollBar.vertical: ScrollBar { - id: scroll - } + ScrollBar.vertical: ScrollBar { + id: scroll + } - Grid { - id: grid - width: parent.width - columns: root.columns - rowSpacing: app.spacing - columnSpacing: app.spacing - height: childrenRect.height + Grid { + id: grid + width: parent.width + columns: root.columns + rowSpacing: app.spacing + columnSpacing: app.spacing + height: childrenRect.height - Timer { - id: timer - interval: 200 - onTriggered: transition.enabled = false - } - - Connections { - target: Cpp_UI_Dashboard - function onWidgetVisibilityChanged() { - transition.enabled = true - timer.start() - } - } - - move: Transition { - id: transition - enabled: false - - NumberAnimation { - duration: 200 - properties: "x,y" - easing.type: Easing.OutSine - } - } - - WidgetModel { - id: model - cellWidth: root.cellWidth - cellHeight: root.cellHeight - model: Cpp_UI_Dashboard.totalWidgetCount - } - } + Timer { + id: timer + interval: 200 + onTriggered: transition.enabled = false } - } - // - // Redraw bottom window border over flickable items - // - Rectangle { - height: root.borderWidth - color: root.gradientColor1 - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - leftMargin: root.radius - rightMargin: root.radius + Connections { + target: Cpp_UI_Dashboard + function onWidgetVisibilityChanged() { + transition.enabled = true + timer.start() + } } + + move: Transition { + id: transition + enabled: false + + NumberAnimation { + duration: 200 + properties: "x,y" + easing.type: Easing.OutSine + } + } + + WidgetModel { + id: model + cellWidth: root.cellWidth + cellHeight: root.cellHeight + model: Cpp_UI_Dashboard.totalWidgetCount + } + } } + } + + // + // Redraw bottom window border over flickable items + // + Rectangle { + height: root.borderWidth + color: root.gradientColor1 + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + leftMargin: root.radius + rightMargin: root.radius + } + } } diff --git a/assets/qml/Dashboard/WidgetModel.qml b/assets/qml/Dashboard/WidgetModel.qml index ec4b37fc..3213fb53 100644 --- a/assets/qml/Dashboard/WidgetModel.qml +++ b/assets/qml/Dashboard/WidgetModel.qml @@ -23,27 +23,27 @@ import QtQuick Repeater { - id: root + id: root - property real cellWidth: 0 - property real cellHeight: 0 + property real cellWidth: 0 + property real cellHeight: 0 - delegate: Loader { - id: loader - asynchronous: true - width: root.cellWidth - height: root.cellHeight + delegate: Loader { + id: loader + asynchronous: true + width: root.cellWidth + height: root.cellHeight - sourceComponent: WidgetDelegate { - widgetIndex: index - } - - Connections { - target: Cpp_UI_Dashboard - - function onWidgetVisibilityChanged() { - loader.visible = Cpp_UI_Dashboard.widgetVisible(index) - } - } + sourceComponent: WidgetDelegate { + widgetIndex: index } + + Connections { + target: Cpp_UI_Dashboard + + function onWidgetVisibilityChanged() { + loader.visible = Cpp_UI_Dashboard.widgetVisible(index) + } + } + } } diff --git a/assets/qml/FramelessWindow/CustomWindow.qml b/assets/qml/FramelessWindow/CustomWindow.qml index 1aeaf0a7..e01246fe 100644 --- a/assets/qml/FramelessWindow/CustomWindow.qml +++ b/assets/qml/FramelessWindow/CustomWindow.qml @@ -26,304 +26,304 @@ import QtQuick.Window as QtWindow import "../Widgets" as Widgets QtWindow.Window { - id: root + id: root + color: "transparent" + flags: (Cpp_ThemeManager.customWindowDecorations ? root.customFlags : Qt.Window) | root.extraFlags + + // + // Custom signals + // + signal closed() + signal minimized() + signal maximized() + signal unmaximized() + + // + // Connections with the theme manager for enabling/disabling frameless window + // + Connections { + target: Cpp_ThemeManager + + function onCustomWindowDecorationsChanged() { + if (Cpp_ThemeManager.customWindowDecorations) + root.flags = root.customFlags | root.extraFlags + else + root.flags = Qt.Window | root.extraFlags + + var prevVisible = root.visible + root.visible = false + root.visible = prevVisible + } + } + + // + // Window radius control + // + property int borderWidth: Cpp_ThemeManager.customWindowDecorations ? 2 : 0 + readonly property int handleSize: radius > 0 ? radius + shadowMargin + 10 : 0 + readonly property int radius: Cpp_ThemeManager.customWindowDecorations ? + (((root.visibility === QtWindow.Window.Maximized && + maximizeEnabled) || isFullscreen) ? 0 : 10) : 0 + + // + // Visibility properties + // + property int extraFlags: 0 + property bool firstChange: true + property bool isMaximized: false + property bool isMinimized: false + property alias showIcon: _title.showIcon + property alias isFullscreen: _title.isFullscreen + readonly property int customFlags: { + // Setup frameless window flags + var flags = Qt.Window | + Qt.CustomizeWindowHint | + Qt.FramelessWindowHint | + Qt.WindowSystemMenuHint | + Qt.WindowMinMaxButtonsHint + + // + // The macOS window manager is able to generate shadows for Qt frameless + // windows. Other operating systems have varied mileage, so we draw the + // shadow ourselves to avoid ugly surprises. + // + // Also, disabling the custom shadow on macOS is a good idea so that users can + // move the window freely over all the desktop without being blocked by the + // menubar or dock due to the custom shadow border. + // + if (!Cpp_IsMac) + flags |= Qt.NoDropShadowWindowHint + + // Return "calculated" window flags + return flags + } + + // + // Toggle fullscreen state + // + function toggleFullscreen() { + root.isFullscreen = !root.isFullscreen + if (root.isFullscreen) + root.showFullScreen() + else + root.showNormal() + } + + // + // Alias to the titlebar + // + property alias titlebar: _title + + // + // Size of the shadow object + // + property int shadowMargin: (Cpp_IsMac | !Cpp_ThemeManager.customWindowDecorations) ? + 0 : (root.radius > 0 ? 20 : 0) + + // + // Titlebar left/right margins for custom controls + // + property alias showMacControls: _title.showMacControls + readonly property real leftTitlebarMargin: Cpp_ThemeManager.customWindowDecorations ? _title.leftMargin : 0 + readonly property real rightTitlebarMargin: Cpp_ThemeManager.customWindowDecorations ? _title.rightMargin : 0 + + // + // Background color of the window & the titlebar + // + property color borderColor: Cpp_ThemeManager.highlight + property color backgroundColor: Cpp_ThemeManager.window + property color titlebarText: Cpp_ThemeManager.menubarText + property color titlebarColor: Cpp_ThemeManager.toolbarGradient2 + + // + // Window controls + // + property alias closeEnabled: _title.closeEnabled + property alias minimizeEnabled: _title.minimizeEnabled + property alias maximizeEnabled: _title.maximizeEnabled + + // + // Ensure that window size & position is valid upon showing + // + Component.onCompleted: { + // Reset window size for whatever reason + if (root.width <= 0 || root.height <= 0) { + root.width = root.minimumWidth + root.height = root.minimumHeight + } + + // Startup verifications to ensure that app is displayed inside the screen + if (root.x < 0 || root.x >= QtWindow.Screen.desktopAvailableWidth) + root.x = 100 + if (root.y < 0 || root.y >= QtWindow.Screen.desktopAvailableHeight) + root.y = 100 + + // Startup verifications to ensure that app fits in current screen + if (root.width > QtWindow.Screen.desktopAvailableWidth) { + root.x = 100 + root.width = QtWindow.Screen.desktopAvailableWidth - root.x + } + + // Startup verifications to ensure that app fits in current screen + if (root.height > QtWindow.Screen.desktopAvailableHeight) { + root.y = 100 + root.height = QtWindow.Screen.desktopAvailableHeight - root.y + } + } + + // + // Custom shadow implementation for non-macOS systems. The shadow shall be disabled + // when the window is maximized. + // + Widgets.Shadow { + border.top: 50 + border.left: 50 + border.right: 50 + border.bottom: 50 + anchors.fill: bg + shadowOpacity: 1.0 + visible: root.shadowMargin > 0 + topMargin: -1 * root.shadowMargin + leftMargin: -1 * root.shadowMargin + rightMargin: -1 * root.shadowMargin + bottomMargin: -1 * root.shadowMargin + source: "qrc:/images/window-shadow.png" + } Rectangle { + id: bg color: "transparent" - flags: (Cpp_ThemeManager.customWindowDecorations ? root.customFlags : Qt.Window) | root.extraFlags + radius: root.radius + anchors.fill: parent + anchors.margins: root.shadowMargin + } - // - // Custom signals - // - signal closed() - signal minimized() - signal maximized() - signal unmaximized() + // + // Window border + // + Rectangle { + opacity: 0.8 + z: titlebar.z + 1 + radius: root.radius + color: "transparent" + anchors.fill: parent + border.color: root.borderColor + border.width: root.borderWidth + anchors.margins: root.shadowMargin + } - // - // Connections with the theme manager for enabling/disabling frameless window - // - Connections { - target: Cpp_ThemeManager + // + // Global mouse area to set cursor shape while resizing + // + MouseArea { + z: titlebar.z - 1 + hoverEnabled: true + anchors.fill: parent + acceptedButtons: Qt.NoButton + enabled: Cpp_ThemeManager.customWindowDecorations + cursorShape: { + const p = Qt.point(mouseX, mouseY) + const b = root.handleSize / 2 - function onCustomWindowDecorationsChanged() { - if (Cpp_ThemeManager.customWindowDecorations) - root.flags = root.customFlags | root.extraFlags - else - root.flags = Qt.Window | root.extraFlags + if (p.x < b && p.y < b) + return Qt.SizeFDiagCursor - var prevVisible = root.visible - root.visible = false - root.visible = prevVisible - } + if (p.x >= width - b && p.y >= height - b) + return Qt.SizeFDiagCursor + + if (p.x >= width - b && p.y < b) + return Qt.SizeBDiagCursor + + if (p.x < b && p.y >= height - b) + return Qt.SizeBDiagCursor + + if (p.x < b || p.x >= width - b) + return Qt.SizeHorCursor + + if (p.y < b || p.y >= height - b) + return Qt.SizeVerCursor } + } - // - // Window radius control - // - property int borderWidth: Cpp_ThemeManager.customWindowDecorations ? 2 : 0 - readonly property int handleSize: radius > 0 ? radius + shadowMargin + 10 : 0 - readonly property int radius: Cpp_ThemeManager.customWindowDecorations ? - (((root.visibility === QtWindow.Window.Maximized && - maximizeEnabled) || isFullscreen) ? 0 : 10) : 0 + // + // Titlebar control + // + Titlebar { + z: 2000 + id: _title + window: root + radius: root.radius + color: root.titlebarColor + textColor: root.titlebarText - // - // Visibility properties - // - property int extraFlags: 0 - property bool firstChange: true - property bool isMaximized: false - property bool isMinimized: false - property alias showIcon: _title.showIcon - property alias isFullscreen: _title.isFullscreen - readonly property int customFlags: { - // Setup frameless window flags - var flags = Qt.Window | - Qt.CustomizeWindowHint | - Qt.FramelessWindowHint | - Qt.WindowSystemMenuHint | - Qt.WindowMinMaxButtonsHint + onClosed: root.closed() + onMinimized: root.minimized() + onMaximized: root.maximized() + onUnmaximized: root.unmaximized() - // - // The macOS window manager is able to generate shadows for Qt frameless - // windows. Other operating systems have varied mileage, so we draw the - // shadow ourselves to avoid ugly surprises. - // - // Also, disabling the custom shadow on macOS is a good idea so that users can - // move the window freely over all the desktop without being blocked by the - // menubar or dock due to the custom shadow border. - // - if (!Cpp_IsMac) - flags |= Qt.NoDropShadowWindowHint - - // Return "calculated" window flags - return flags + anchors { + top: parent.top + left: parent.left + right: parent.right + margins: root.shadowMargin } + } - // - // Toggle fullscreen state - // - function toggleFullscreen() { - root.isFullscreen = !root.isFullscreen - if (root.isFullscreen) - root.showFullScreen() - else - root.showNormal() - } + // + // Maximize window fixes + // + onVisibilityChanged: (visibility) => { + // Ensure that correct window flags are still used + if (Cpp_ThemeManager.customWindowDecorations) { + // Hard-reset window flags on macOS to fix most glitches + if (Cpp_IsMac) + root.flags = Qt.Window - // - // Alias to the titlebar - // - property alias titlebar: _title + // Apply custom flags + root.flags = root.customFlags | root.extraFlags + } - // - // Size of the shadow object - // - property int shadowMargin: (Cpp_IsMac | !Cpp_ThemeManager.customWindowDecorations) ? - 0 : (root.radius > 0 ? 20 : 0) + // Apply basic flags + else + root.flags = Qt.Window | root.extraFlags - // - // Titlebar left/right margins for custom controls - // - property alias showMacControls: _title.showMacControls - readonly property real leftTitlebarMargin: Cpp_ThemeManager.customWindowDecorations ? _title.leftMargin : 0 - readonly property real rightTitlebarMargin: Cpp_ThemeManager.customWindowDecorations ? _title.rightMargin : 0 + // Window has been just maximized, update internal variables + if (visibility === QtWindow.Window.Maximized) { + if (!root.isMaximized) + root.firstChange = false - // - // Background color of the window & the titlebar - // - property color borderColor: Cpp_ThemeManager.highlight - property color backgroundColor: Cpp_ThemeManager.window - property color titlebarText: Cpp_ThemeManager.menubarText - property color titlebarColor: Cpp_ThemeManager.toolbarGradient2 + root.isMaximized = true + root.isFullscreen = false + } - // - // Window controls - // - property alias closeEnabled: _title.closeEnabled - property alias minimizeEnabled: _title.minimizeEnabled - property alias maximizeEnabled: _title.maximizeEnabled + // Window has been just minimized, update internal variables + else if (visibility === QtWindow.Window.Minimized) { + root.isFullscreen = false + root.isMaximized = false + } - // - // Ensure that window size & position is valid upon showing - // - Component.onCompleted: { - // Reset window size for whatever reason - if (root.width <= 0 || root.height <= 0) { - root.width = root.minimumWidth - root.height = root.minimumHeight - } + // Window has been just switched to full-screen, update internal variables + else if (visibility === QtWindow.Window.FullScreen) { + if (!root.isFullscreen) + root.firstChange = false - // Startup verifications to ensure that app is displayed inside the screen - if (root.x < 0 || root.x >= QtWindow.Screen.desktopAvailableWidth) - root.x = 100 - if (root.y < 0 || root.y >= QtWindow.Screen.desktopAvailableHeight) - root.y = 100 + root.isFullscreen = true + root.isMaximized = false + } - // Startup verifications to ensure that app fits in current screen - if (root.width > QtWindow.Screen.desktopAvailableWidth) { - root.x = 100 - root.width = QtWindow.Screen.desktopAvailableWidth - root.x - } + // Window was just restored to "normal" mode, recover previous geometry + else if (visibility !== QtWindow.Window.Hidden) { + if (isMaximized || isFullscreen && firstChange) { + root.width = root.minimumWidth + root.height = root.minimumHeight + root.x = (QtWindow.Screen.desktopAvailableWidth - root.width) / 2 + root.y = (QtWindow.Screen.desktopAvailableHeight - root.height) / 2 + } - // Startup verifications to ensure that app fits in current screen - if (root.height > QtWindow.Screen.desktopAvailableHeight) { - root.y = 100 - root.height = QtWindow.Screen.desktopAvailableHeight - root.y - } - } + root.isMaximized = false + root.isFullscreen = false - // - // Custom shadow implementation for non-macOS systems. The shadow shall be disabled - // when the window is maximized. - // - Widgets.Shadow { - border.top: 50 - border.left: 50 - border.right: 50 - border.bottom: 50 - anchors.fill: bg - shadowOpacity: 1.0 - visible: root.shadowMargin > 0 - topMargin: -1 * root.shadowMargin - leftMargin: -1 * root.shadowMargin - rightMargin: -1 * root.shadowMargin - bottomMargin: -1 * root.shadowMargin - source: "qrc:/images/window-shadow.png" - } Rectangle { - id: bg - color: "transparent" - radius: root.radius - anchors.fill: parent - anchors.margins: root.shadowMargin - } - - // - // Window border - // - Rectangle { - opacity: 0.8 - z: titlebar.z + 1 - radius: root.radius - color: "transparent" - anchors.fill: parent - border.color: root.borderColor - border.width: root.borderWidth - anchors.margins: root.shadowMargin - } - - // - // Global mouse area to set cursor shape while resizing - // - MouseArea { - z: titlebar.z - 1 - hoverEnabled: true - anchors.fill: parent - acceptedButtons: Qt.NoButton - enabled: Cpp_ThemeManager.customWindowDecorations - cursorShape: { - const p = Qt.point(mouseX, mouseY) - const b = root.handleSize / 2 - - if (p.x < b && p.y < b) - return Qt.SizeFDiagCursor - - if (p.x >= width - b && p.y >= height - b) - return Qt.SizeFDiagCursor - - if (p.x >= width - b && p.y < b) - return Qt.SizeBDiagCursor - - if (p.x < b && p.y >= height - b) - return Qt.SizeBDiagCursor - - if (p.x < b || p.x >= width - b) - return Qt.SizeHorCursor - - if (p.y < b || p.y >= height - b) - return Qt.SizeVerCursor - } - } - - // - // Titlebar control - // - Titlebar { - z: 2000 - id: _title - window: root - radius: root.radius - color: root.titlebarColor - textColor: root.titlebarText - - onClosed: root.closed() - onMinimized: root.minimized() - onMaximized: root.maximized() - onUnmaximized: root.unmaximized() - - anchors { - top: parent.top - left: parent.left - right: parent.right - margins: root.shadowMargin - } - } - - // - // Maximize window fixes - // - onVisibilityChanged: (visibility) => { - // Ensure that correct window flags are still used - if (Cpp_ThemeManager.customWindowDecorations) { - // Hard-reset window flags on macOS to fix most glitches - if (Cpp_IsMac) - root.flags = Qt.Window - - // Apply custom flags - root.flags = root.customFlags | root.extraFlags - } - - // Apply basic flags - else - root.flags = Qt.Window | root.extraFlags - - // Window has been just maximized, update internal variables - if (visibility === QtWindow.Window.Maximized) { - if (!root.isMaximized) - root.firstChange = false - - root.isMaximized = true - root.isFullscreen = false - } - - // Window has been just minimized, update internal variables - else if (visibility === QtWindow.Window.Minimized) { - root.isFullscreen = false - root.isMaximized = false - } - - // Window has been just switched to full-screen, update internal variables - else if (visibility === QtWindow.Window.FullScreen) { - if (!root.isFullscreen) - root.firstChange = false - - root.isFullscreen = true - root.isMaximized = false - } - - // Window was just restored to "normal" mode, recover previous geometry - else if (visibility !== QtWindow.Window.Hidden) { - if (isMaximized || isFullscreen && firstChange) { - root.width = root.minimumWidth - root.height = root.minimumHeight - root.x = (QtWindow.Screen.desktopAvailableWidth - root.width) / 2 - root.y = (QtWindow.Screen.desktopAvailableHeight - root.height) / 2 - } - - root.isMaximized = false - root.isFullscreen = false - - // Force active focus - root.requestActivate() - root.requestUpdate() - } - } + // Force active focus + root.requestActivate() + root.requestUpdate() + } + } } diff --git a/assets/qml/FramelessWindow/ResizeHandles.qml b/assets/qml/FramelessWindow/ResizeHandles.qml index 3d0d44a0..66612dbc 100644 --- a/assets/qml/FramelessWindow/ResizeHandles.qml +++ b/assets/qml/FramelessWindow/ResizeHandles.qml @@ -24,216 +24,216 @@ import QtQuick import QtQuick.Window Item { - id: root + id: root - // - // Pointer to window to control - // - property Window window - property int handleSize + // + // Pointer to window to control + // + property Window window + property int handleSize - // - // Disable handles if window size is fixed or window is maximized - // - enabled: ((window.minimumWidth !== window.maximumWidth) || - (window.minimumHeight !== window.maximumHeight)) && - (window.visibility !== Window.Maximized) + // + // Disable handles if window size is fixed or window is maximized + // + enabled: ((window.minimumWidth !== window.maximumWidth) || + (window.minimumHeight !== window.maximumHeight)) && + (window.visibility !== Window.Maximized) - // - // Right resize handle - // - MouseArea { - property bool dragging: false - property point lastMousePos: Qt.point(0, 0) + // + // Right resize handle + // + MouseArea { + property bool dragging: false + property point lastMousePos: Qt.point(0, 0) - anchors { - top: parent.top - bottom: parent.bottom - right: parent.right - topMargin: titlebar.height - } - - width: handleSize - onPressedChanged: dragging = pressed - onPressed: lastMousePos = Qt.point(mouseX, mouseY) - - onMouseXChanged: { - if (dragging) { - var dx = mouseX + lastMousePos.x - var width = window.width + dx - if (width < window.minimumWidth) - width = window.minimumWidth - else if (width > window.maximumWidth) - width = window.maximumWidth - - window.setGeometry(window.x, window.y, width, window.height) - } - } + anchors { + top: parent.top + bottom: parent.bottom + right: parent.right + topMargin: titlebar.height } - // - // Left resize handle - // - MouseArea { - property bool dragging: false - property point lastMousePos: Qt.point(0, 0) + width: handleSize + onPressedChanged: dragging = pressed + onPressed: lastMousePos = Qt.point(mouseX, mouseY) - anchors { - top: parent.top - left: parent.left - bottom: parent.bottom - topMargin: titlebar.height - } + onMouseXChanged: { + if (dragging) { + var dx = mouseX + lastMousePos.x + var width = window.width + dx + if (width < window.minimumWidth) + width = window.minimumWidth + else if (width > window.maximumWidth) + width = window.maximumWidth - width: handleSize - onPressedChanged: dragging = pressed - onPressed: lastMousePos = Qt.point(mouseX, mouseY) + window.setGeometry(window.x, window.y, width, window.height) + } + } + } - onMouseXChanged: { - if (dragging) { - var dx = mouseX - lastMousePos.x - var y = window.y - var x = window.x + dx - var height = window.height - var width = window.width - dx + // + // Left resize handle + // + MouseArea { + property bool dragging: false + property point lastMousePos: Qt.point(0, 0) - if (x > window.x) { - width = window.width - dx / 2 - if (width < window.minimumWidth) { - width = window.minimumWidth - x = window.x - } - - else if (width > window.maximumWidth) { - width = window.maximumWidth - x = window.x - } - } - - window.setGeometry(x, y, width, height) - } - } + anchors { + top: parent.top + left: parent.left + bottom: parent.bottom + topMargin: titlebar.height } - // - // Bottom resize handle - // - MouseArea { - property bool dragging: false - property point lastMousePos: Qt.point(0, 0) + width: handleSize + onPressedChanged: dragging = pressed + onPressed: lastMousePos = Qt.point(mouseX, mouseY) - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom + onMouseXChanged: { + if (dragging) { + var dx = mouseX - lastMousePos.x + var y = window.y + var x = window.x + dx + var height = window.height + var width = window.width - dx + + if (x > window.x) { + width = window.width - dx / 2 + if (width < window.minimumWidth) { + width = window.minimumWidth + x = window.x + } + + else if (width > window.maximumWidth) { + width = window.maximumWidth + x = window.x + } } - height: handleSize - onPressedChanged: dragging = pressed - onPressed: lastMousePos = Qt.point(mouseX, mouseY) - onMouseYChanged: { - if (dragging) { - var dy = mouseY - lastMousePos.y - var height = window.height + dy - if (height < window.minimumHeight) - height = window.minimumHeight - else if (height > window.maximumHeight) - height = window.maximumHeight + window.setGeometry(x, y, width, height) + } + } + } - window.setGeometry(window.x, window.y, window.width, height) - } - } + // + // Bottom resize handle + // + MouseArea { + property bool dragging: false + property point lastMousePos: Qt.point(0, 0) + + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom } - // - // Bottom right corner - // - MouseArea { - property bool dragging: false - property point lastMousePos: Qt.point(0, 0) + height: handleSize + onPressedChanged: dragging = pressed + onPressed: lastMousePos = Qt.point(mouseX, mouseY) + onMouseYChanged: { + if (dragging) { + var dy = mouseY - lastMousePos.y + var height = window.height + dy + if (height < window.minimumHeight) + height = window.minimumHeight + else if (height > window.maximumHeight) + height = window.maximumHeight - function updateWindowPosition() { - if (dragging) { - var dy = mouseY - lastMousePos.y - var dx = mouseX + lastMousePos.x - var width = window.width + dx - var height = window.height + dy + window.setGeometry(window.x, window.y, window.width, height) + } + } + } - if (width < window.minimumWidth) - width = window.minimumWidth - else if (width > window.maximumWidth) - width = window.maximumWidth + // + // Bottom right corner + // + MouseArea { + property bool dragging: false + property point lastMousePos: Qt.point(0, 0) - if (height < window.minimumHeight) - height = window.minimumHeight - else if (height > window.maximumHeight) - height = window.maximumHeight + function updateWindowPosition() { + if (dragging) { + var dy = mouseY - lastMousePos.y + var dx = mouseX + lastMousePos.x + var width = window.width + dx + var height = window.height + dy - window.setGeometry(window.x, window.y, width, height) - } - } + if (width < window.minimumWidth) + width = window.minimumWidth + else if (width > window.maximumWidth) + width = window.maximumWidth - anchors { - right: parent.right - bottom: parent.bottom - } + if (height < window.minimumHeight) + height = window.minimumHeight + else if (height > window.maximumHeight) + height = window.maximumHeight - width: handleSize - height: handleSize - enabled: Cpp_IsMac - onPressedChanged: dragging = pressed - onMouseXChanged: updateWindowPosition() - onPressed: lastMousePos = Qt.point(mouseX, mouseY) + window.setGeometry(window.x, window.y, width, height) + } } - // - // Bottom left corner - // - MouseArea { - property bool dragging: false - property point lastMousePos: Qt.point(0, 0) - - function updateWindowPosition() { - if (dragging) { - var dx = mouseX - lastMousePos.x - var dy = mouseY - lastMousePos.y - - var y = window.y - var x = window.x + dx - var width = window.width - dx - var height = window.height + dy - - if (x > window.x) - width = window.width - dx / 2 - - if (width < window.minimumWidth) { - width = window.minimumWidth - x = window.x - } - - else if (width > window.maximumWidth) { - width = window.maximumWidth - x = window.x - } - - if (height < minimumHeight) - height = minimumHeight - else if (height > maximumHeight) - height = maximumHeight - - window.setGeometry(x, y, width, height) - } - } - - anchors { - left: parent.left - bottom: parent.bottom - } - - width: handleSize - height: handleSize - onPressedChanged: dragging = pressed - onMouseXChanged: updateWindowPosition() - onPressed: lastMousePos = Qt.point(mouseX, mouseY) + anchors { + right: parent.right + bottom: parent.bottom } + + width: handleSize + height: handleSize + enabled: Cpp_IsMac + onPressedChanged: dragging = pressed + onMouseXChanged: updateWindowPosition() + onPressed: lastMousePos = Qt.point(mouseX, mouseY) + } + + // + // Bottom left corner + // + MouseArea { + property bool dragging: false + property point lastMousePos: Qt.point(0, 0) + + function updateWindowPosition() { + if (dragging) { + var dx = mouseX - lastMousePos.x + var dy = mouseY - lastMousePos.y + + var y = window.y + var x = window.x + dx + var width = window.width - dx + var height = window.height + dy + + if (x > window.x) + width = window.width - dx / 2 + + if (width < window.minimumWidth) { + width = window.minimumWidth + x = window.x + } + + else if (width > window.maximumWidth) { + width = window.maximumWidth + x = window.x + } + + if (height < minimumHeight) + height = minimumHeight + else if (height > maximumHeight) + height = maximumHeight + + window.setGeometry(x, y, width, height) + } + } + + anchors { + left: parent.left + bottom: parent.bottom + } + + width: handleSize + height: handleSize + onPressedChanged: dragging = pressed + onMouseXChanged: updateWindowPosition() + onPressed: lastMousePos = Qt.point(mouseX, mouseY) + } } diff --git a/assets/qml/FramelessWindow/Titlebar.qml b/assets/qml/FramelessWindow/Titlebar.qml index 476b03c6..3484daa0 100644 --- a/assets/qml/FramelessWindow/Titlebar.qml +++ b/assets/qml/FramelessWindow/Titlebar.qml @@ -28,312 +28,312 @@ import QtQuick.Controls import "../Widgets" as Widgets Rectangle { - id: root + id: root - // - // Custom signals - // - signal closed() - signal minimized() - signal maximized() - signal unmaximized() + // + // Custom signals + // + signal closed() + signal minimized() + signal maximized() + signal unmaximized() - // - // Window controls - // - property Window window - property bool showIcon: false - property bool closeEnabled: true - property bool isFullscreen: false - property bool minimizeEnabled: true - property bool maximizeEnabled: true - property color textColor: palette.text - property bool showMacControls: Cpp_IsMac + // + // Window controls + // + property Window window + property bool showIcon: false + property bool closeEnabled: true + property bool isFullscreen: false + property bool minimizeEnabled: true + property bool maximizeEnabled: true + property color textColor: palette.text + property bool showMacControls: Cpp_IsMac - // - // Access to left titlebar button widths (e.g. for implementing custom controls over - // the window titlebar, such as the main window menubar) - // - readonly property real leftMargin: { - var margin = 0 + // + // Access to left titlebar button widths (e.g. for implementing custom controls over + // the window titlebar, such as the main window menubar) + // + readonly property real leftMargin: { + var margin = 0 - // Calculations for macOS layout - if (showMacControls) { - // Default spacer - margin = 4 + // Calculations for macOS layout + if (showMacControls) { + // Default spacer + margin = 4 - // Add space for close button - if (closeEnabled) - margin += 20 + // Add space for close button + if (closeEnabled) + margin += 20 - // Add space for minimize button - if (minimizeEnabled && !root.isFullscreen) - margin += 20 + // Add space for minimize button + if (minimizeEnabled && !root.isFullscreen) + margin += 20 - // Add space for maximize button - if (maximizeEnabled && !root.isFullscreen) - margin += 20 + // Add space for maximize button + if (maximizeEnabled && !root.isFullscreen) + margin += 20 - // Add extra spacer if at least one button is visible - if (margin > 4) - margin += 4 - } - - // Calculations for Windows/Linux layout - else { - margin = 8 - - if (root.showIcon) - margin += 24 - - if (margin > 8) - margin += 6 - } - - // Return result - return margin + // Add extra spacer if at least one button is visible + if (margin > 4) + margin += 4 } - // - // Access to right titlebar button widths (e.g. for implementing custom controls over - // the window titlebar, such as the main window menubar) - // - readonly property real rightMargin: { - var margin + // Calculations for Windows/Linux layout + else { + margin = 8 - // Calculations for macOS layout - if (showMacControls) - margin = 8 + if (root.showIcon) + margin += 24 - // Calculations for Windows/Linux layout - else { - // Default spacer - margin = 8 + if (margin > 8) + margin += 6 + } - // Add space for close button - if (closeEnabled) - margin += 24 + // Return result + return margin + } - // Add space for minimize button - if (minimizeEnabled && !root.isFullscreen) - margin += 24 + // + // Access to right titlebar button widths (e.g. for implementing custom controls over + // the window titlebar, such as the main window menubar) + // + readonly property real rightMargin: { + var margin - // Add space for maximize button - if (maximizeEnabled && !root.isFullscreen) - margin += 24 + // Calculations for macOS layout + if (showMacControls) + margin = 8 - // Add extra spacer if at least one button is visible - if (margin > 8) - margin += 8 + // Calculations for Windows/Linux layout + else { + // Default spacer + margin = 8 + + // Add space for close button + if (closeEnabled) + margin += 24 + + // Add space for minimize button + if (minimizeEnabled && !root.isFullscreen) + margin += 24 + + // Add space for maximize button + if (maximizeEnabled && !root.isFullscreen) + margin += 24 + + // Add extra spacer if at least one button is visible + if (margin > 8) + margin += 8 + } + + // Return result + return margin + } + + // + // Toggle maximized + // + function toggleMaximized() { + if (window.visibility === Window.Maximized) { + window.showNormal() + root.unmaximized() + } + + else { + window.showMaximized() + root.maximized() + } + } + + // + // Toggle fullscreen state + // + function toggleFullscreen() { + root.isFullscreen = !root.isFullscreen + if (root.isFullscreen) + window.showFullScreen() + else + window.showNormal() + } + + // + // Height calculation + // + height: Cpp_ThemeManager.customWindowDecorations ? (!showMacControls ? 38 : 32) : 0 + + // + // Radius compensator rectangle + // + Rectangle { + color: parent.color + height: parent.radius + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + } + + // + // Window drag handler & maximize by double click + // + Item { + anchors.fill: parent + enabled: Cpp_ThemeManager.customWindowDecorations + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onDoubleClicked: { + if (root.maximizeEnabled) + root.toggleMaximized() + } + + onPressedChanged: { + if (pressed) + window.startSystemMove() + } + } + } + + // + // macOS layout + // + Item { + anchors.fill: parent + visible: showMacControls && Cpp_ThemeManager.customWindowDecorations + enabled: showMacControls && Cpp_ThemeManager.customWindowDecorations + + RowLayout { + spacing: 0 + anchors.fill: parent + + Item { + width: 4 + } + + WindowButtonMacOS { + name: "close" + enabled: root.closeEnabled + visible: root.closeEnabled + Layout.alignment: Qt.AlignVCenter + onClicked: { + window.close() + root.closed() } - // Return result - return margin - } + } - // - // Toggle maximized - // - function toggleMaximized() { - if (window.visibility === Window.Maximized) { - window.showNormal() - root.unmaximized() + WindowButtonMacOS { + name: "minimize" + Layout.alignment: Qt.AlignVCenter + enabled: root.minimizeEnabled && !root.isFullscreen + visible: root.minimizeEnabled && !root.isFullscreen + onClicked: { + // Workaround for QTBUG-64994 + if (Cpp_IsMac) + window.flags = Qt.Window | Qt.CustomizeWindowHint | Qt.WindowMinMaxButtonsHint + + window.showMinimized() + root.minimized() } + } - else { - window.showMaximized() - root.maximized() + WindowButtonMacOS { + name: "maximize" + onClicked: root.toggleMaximized() + Layout.alignment: Qt.AlignVCenter + enabled: root.maximizeEnabled && !root.isFullscreen + visible: root.maximizeEnabled && !root.isFullscreen + } + + Item { + Layout.fillWidth: true + } + } + } + + // + // Windows & Linux layout + // + Item { + anchors.fill: parent + visible: !showMacControls && Cpp_ThemeManager.customWindowDecorations + enabled: !showMacControls && Cpp_ThemeManager.customWindowDecorations + + RowLayout { + spacing: 0 + anchors.fill: parent + + Item { + width: 8 + } + + WindowButton { + visible: root.showIcon + enabled: root.showIcon + textColor: root.textColor + pressedColor: root.textColor + Layout.alignment: Qt.AlignVCenter + source: "qrc:/images/icon-window.svg" + } + + Item { + Layout.fillWidth: true + } + + WindowButton { + name: "minimize" + textColor: root.textColor + Layout.alignment: Qt.AlignVCenter + enabled: root.minimizeEnabled && !root.isFullscreen + visible: root.minimizeEnabled && !root.isFullscreen + onClicked: { + // Workaround for QTBUG-64994 + if (Cpp_IsMac) + window.flags = Qt.Window | Qt.CustomizeWindowHint | Qt.WindowMinMaxButtonsHint + + window.showMinimized() + root.minimized() } - } + } - // - // Toggle fullscreen state - // - function toggleFullscreen() { - root.isFullscreen = !root.isFullscreen - if (root.isFullscreen) - window.showFullScreen() - else - window.showNormal() - } + WindowButton { + textColor: root.textColor + onClicked: root.toggleMaximized() + Layout.alignment: Qt.AlignVCenter + enabled: root.maximizeEnabled && !root.isFullscreen + visible: root.maximizeEnabled && !root.isFullscreen + name: window.visibility === Window.Maximized ? "unmaximize" : "maximize" + } - // - // Height calculation - // - height: Cpp_ThemeManager.customWindowDecorations ? (!showMacControls ? 38 : 32) : 0 - - // - // Radius compensator rectangle - // - Rectangle { - color: parent.color - height: parent.radius - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom + WindowButton { + name: "close" + pressedColor: "#f00" + textColor: root.textColor + enabled: root.closeEnabled + visible: root.closeEnabled + Layout.alignment: Qt.AlignVCenter + onClicked: { + window.close() + root.closed() } + } + + Item { + width: 8 + } } + } - // - // Window drag handler & maximize by double click - // - Item { - anchors.fill: parent - enabled: Cpp_ThemeManager.customWindowDecorations - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton - - onDoubleClicked: { - if (root.maximizeEnabled) - root.toggleMaximized() - } - - onPressedChanged: { - if (pressed) - window.startSystemMove() - } - } - } - - // - // macOS layout - // - Item { - anchors.fill: parent - visible: showMacControls && Cpp_ThemeManager.customWindowDecorations - enabled: showMacControls && Cpp_ThemeManager.customWindowDecorations - - RowLayout { - spacing: 0 - anchors.fill: parent - - Item { - width: 4 - } - - WindowButtonMacOS { - name: "close" - enabled: root.closeEnabled - visible: root.closeEnabled - Layout.alignment: Qt.AlignVCenter - onClicked: { - window.close() - root.closed() - } - - } - - WindowButtonMacOS { - name: "minimize" - Layout.alignment: Qt.AlignVCenter - enabled: root.minimizeEnabled && !root.isFullscreen - visible: root.minimizeEnabled && !root.isFullscreen - onClicked: { - // Workaround for QTBUG-64994 - if (Cpp_IsMac) - window.flags = Qt.Window | Qt.CustomizeWindowHint | Qt.WindowMinMaxButtonsHint - - window.showMinimized() - root.minimized() - } - } - - WindowButtonMacOS { - name: "maximize" - onClicked: root.toggleMaximized() - Layout.alignment: Qt.AlignVCenter - enabled: root.maximizeEnabled && !root.isFullscreen - visible: root.maximizeEnabled && !root.isFullscreen - } - - Item { - Layout.fillWidth: true - } - } - } - - // - // Windows & Linux layout - // - Item { - anchors.fill: parent - visible: !showMacControls && Cpp_ThemeManager.customWindowDecorations - enabled: !showMacControls && Cpp_ThemeManager.customWindowDecorations - - RowLayout { - spacing: 0 - anchors.fill: parent - - Item { - width: 8 - } - - WindowButton { - visible: root.showIcon - enabled: root.showIcon - textColor: root.textColor - pressedColor: root.textColor - Layout.alignment: Qt.AlignVCenter - source: "qrc:/images/icon-window.svg" - } - - Item { - Layout.fillWidth: true - } - - WindowButton { - name: "minimize" - textColor: root.textColor - Layout.alignment: Qt.AlignVCenter - enabled: root.minimizeEnabled && !root.isFullscreen - visible: root.minimizeEnabled && !root.isFullscreen - onClicked: { - // Workaround for QTBUG-64994 - if (Cpp_IsMac) - window.flags = Qt.Window | Qt.CustomizeWindowHint | Qt.WindowMinMaxButtonsHint - - window.showMinimized() - root.minimized() - } - } - - WindowButton { - textColor: root.textColor - onClicked: root.toggleMaximized() - Layout.alignment: Qt.AlignVCenter - enabled: root.maximizeEnabled && !root.isFullscreen - visible: root.maximizeEnabled && !root.isFullscreen - name: window.visibility === Window.Maximized ? "unmaximize" : "maximize" - } - - WindowButton { - name: "close" - pressedColor: "#f00" - textColor: root.textColor - enabled: root.closeEnabled - visible: root.closeEnabled - Layout.alignment: Qt.AlignVCenter - onClicked: { - window.close() - root.closed() - } - } - - Item { - width: 8 - } - } - } - - Label { - font.bold: true - font.pixelSize: 14 - text: window.title - color: root.textColor - anchors.centerIn: parent - visible: Cpp_ThemeManager.customWindowDecorations - } + Label { + font.bold: true + font.pixelSize: 14 + text: window.title + color: root.textColor + anchors.centerIn: parent + visible: Cpp_ThemeManager.customWindowDecorations + } } diff --git a/assets/qml/FramelessWindow/WindowButton.qml b/assets/qml/FramelessWindow/WindowButton.qml index 783ef40e..b432b56d 100644 --- a/assets/qml/FramelessWindow/WindowButton.qml +++ b/assets/qml/FramelessWindow/WindowButton.qml @@ -24,26 +24,26 @@ import QtQuick import "../Widgets" as Widgets Widgets.Icon { - id: root + id: root - signal clicked() - property string name - property color textColor - property color pressedColor: Cpp_ThemeManager.highlight + signal clicked() + property string name + property color textColor + property color pressedColor: Cpp_ThemeManager.highlight - width: 24 - height: 24 - color: root.textColor - source: "qrc:/window-border/" + name + ".svg" + width: 24 + height: 24 + color: root.textColor + source: "qrc:/window-border/" + name + ".svg" - Behavior on color { ColorAnimation{} } + Behavior on color { ColorAnimation{} } - MouseArea { - hoverEnabled: true - anchors.fill: parent - preventStealing: true - onClicked: root.clicked() - acceptedButtons: Qt.LeftButton - onContainsMouseChanged: root.color = containsMouse ? root.pressedColor : root.textColor - } + MouseArea { + hoverEnabled: true + anchors.fill: parent + preventStealing: true + onClicked: root.clicked() + acceptedButtons: Qt.LeftButton + onContainsMouseChanged: root.color = containsMouse ? root.pressedColor : root.textColor + } } diff --git a/assets/qml/FramelessWindow/WindowButtonMacOS.qml b/assets/qml/FramelessWindow/WindowButtonMacOS.qml index b562a125..c7955595 100644 --- a/assets/qml/FramelessWindow/WindowButtonMacOS.qml +++ b/assets/qml/FramelessWindow/WindowButtonMacOS.qml @@ -23,23 +23,23 @@ import QtQuick Image { - id: root + id: root - signal clicked() - property string name - property string variant: "normal" + signal clicked() + property string name + property string variant: "normal" - width: sourceSize.width - height: sourceSize.height - sourceSize: Qt.size(20, 20) - source: ("qrc:/window-border/macOS/" + name + "-" + variant + ".svg") + width: sourceSize.width + height: sourceSize.height + sourceSize: Qt.size(20, 20) + source: ("qrc:/window-border/macOS/" + name + "-" + variant + ".svg") - MouseArea { - hoverEnabled: true - anchors.fill: parent - onReleased: root.clicked() - acceptedButtons: Qt.LeftButton - onPressedChanged: root.variant = (pressed ? "active" : "normal") - onContainsMouseChanged: root.variant = (containsMouse ? "hover" : "normal") - } + MouseArea { + hoverEnabled: true + anchors.fill: parent + onReleased: root.clicked() + acceptedButtons: Qt.LeftButton + onPressedChanged: root.variant = (pressed ? "active" : "normal") + onContainsMouseChanged: root.variant = (containsMouse ? "hover" : "normal") + } } diff --git a/assets/qml/Panes/Console.qml b/assets/qml/Panes/Console.qml index 6b9ae93a..6da2abba 100644 --- a/assets/qml/Panes/Console.qml +++ b/assets/qml/Panes/Console.qml @@ -27,61 +27,61 @@ import QtQuick.Controls import "../Widgets" as Widgets Item { - id: root + id: root - // - // Custom properties - // - property alias vt100emulation: terminal.vt100emulation + // + // Custom properties + // + property alias vt100emulation: terminal.vt100emulation - // - // Utility functions between terminal widget & main window - // - function sendData() { - terminal.sendData() - } function clear() { - terminal.clear() - } function copy() { - terminal.copy() - } function selectAll() { - terminal.selectAll() + // + // Utility functions between terminal widget & main window + // + function sendData() { + terminal.sendData() + } function clear() { + terminal.clear() + } function copy() { + terminal.copy() + } function selectAll() { + terminal.selectAll() + } + + // + // Load welcome guide + // + function showWelcomeGuide() { + clear() + Cpp_IO_Console.append(Cpp_Misc_Translator.welcomeConsoleText() + "\n") + } + + // + // Re-load welcome text when the language is changed + // + Connections { + target: Cpp_Misc_Translator + function onLanguageChanged() { + root.showWelcomeGuide() } + } - // - // Load welcome guide - // - function showWelcomeGuide() { - clear() - Cpp_IO_Console.append(Cpp_Misc_Translator.welcomeConsoleText() + "\n") - } - - // - // Re-load welcome text when the language is changed - // - Connections { - target: Cpp_Misc_Translator - function onLanguageChanged() { - root.showWelcomeGuide() - } - } - - // - // Console window - // - Widgets.Window { - id: window - gradient: true - anchors.fill: parent - title: qsTr("Console") - headerDoubleClickEnabled: false - icon.source: "qrc:/icons/code.svg" - anchors.margins: (app.spacing * 1.5) - 5 - backgroundColor: Cpp_ThemeManager.paneWindowBackground - - Widgets.Terminal { - id: terminal - widgetEnabled: true - anchors.fill: parent - } + // + // Console window + // + Widgets.Window { + id: window + gradient: true + anchors.fill: parent + title: qsTr("Console") + headerDoubleClickEnabled: false + icon.source: "qrc:/icons/code.svg" + anchors.margins: (app.spacing * 1.5) - 5 + backgroundColor: Cpp_ThemeManager.paneWindowBackground + + Widgets.Terminal { + id: terminal + widgetEnabled: true + anchors.fill: parent } + } } diff --git a/assets/qml/Panes/Dashboard.qml b/assets/qml/Panes/Dashboard.qml index f31080f5..da52d0aa 100644 --- a/assets/qml/Panes/Dashboard.qml +++ b/assets/qml/Panes/Dashboard.qml @@ -28,94 +28,94 @@ import "../Widgets" as Widgets import "../Dashboard" as DashboardItems Item { - id: root + id: root + + // + // Main layout + // + ColumnLayout { + anchors.fill: parent + spacing: app.spacing + anchors.margins: (app.spacing * 1.5) - 5 // - // Main layout + // Widget selector + widgets // - ColumnLayout { - anchors.fill: parent - spacing: app.spacing - anchors.margins: (app.spacing * 1.5) - 5 + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + Layout.fillHeight: true - // - // Widget selector + widgets - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - Layout.fillHeight: true + // + // View options window + // + DashboardItems.ViewOptions { + Layout.fillHeight: true + Layout.minimumWidth: 280 + onWidgetSizeChanged:(maxSize) => widgetGrid.maxSize = maxSize + } - // - // View options window - // - DashboardItems.ViewOptions { - Layout.fillHeight: true - Layout.minimumWidth: 280 - onWidgetSizeChanged:(maxSize) => widgetGrid.maxSize = maxSize - } + // + // Widget grid + console + // + ColumnLayout { + spacing: terminalView.enabled ? app.spacing : 0 - // - // Widget grid + console - // - ColumnLayout { - spacing: terminalView.enabled ? app.spacing : 0 - - DashboardItems.WidgetGrid { - id: widgetGrid - Layout.fillWidth: true - Layout.fillHeight: true - Layout.minimumWidth: 240 - } - - - Item { - enabled: false - id: terminalView - Layout.fillWidth: true - Layout.fillHeight: false - Layout.maximumHeight: 280 - Layout.minimumHeight: 280 - visible: Layout.bottomMargin > -Layout.minimumHeight - Layout.bottomMargin: enabled ? 0 : -Layout.minimumHeight - - Behavior on Layout.bottomMargin { NumberAnimation{} } - - Widgets.Window { - id: terminal - gradient: true - anchors.fill: parent - title: qsTr("Console") - altButtonEnabled: true - headerDoubleClickEnabled: false - icon.source: "qrc:/icons/code.svg" - altButtonIcon.source: "qrc:/icons/scroll-down.svg" - backgroundColor: Cpp_ThemeManager.paneWindowBackground - onAltButtonClicked: { - terminalView.enabled = false - dbTitle.consoleChecked = false - } - - Widgets.Terminal { - anchors.fill: parent - widgetEnabled: terminalView.enabled - } - } - } - } + DashboardItems.WidgetGrid { + id: widgetGrid + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumWidth: 240 } - // - // Dashboard title window - // - DashboardItems.DashboardTitle { - id: dbTitle - height: 32 - Layout.fillWidth: true - onConsoleCheckedChanged: { - if (terminalView.enabled != consoleChecked) - terminalView.enabled = consoleChecked + + Item { + enabled: false + id: terminalView + Layout.fillWidth: true + Layout.fillHeight: false + Layout.maximumHeight: 280 + Layout.minimumHeight: 280 + visible: Layout.bottomMargin > -Layout.minimumHeight + Layout.bottomMargin: enabled ? 0 : -Layout.minimumHeight + + Behavior on Layout.bottomMargin { NumberAnimation{} } + + Widgets.Window { + id: terminal + gradient: true + anchors.fill: parent + title: qsTr("Console") + altButtonEnabled: true + headerDoubleClickEnabled: false + icon.source: "qrc:/icons/code.svg" + altButtonIcon.source: "qrc:/icons/scroll-down.svg" + backgroundColor: Cpp_ThemeManager.paneWindowBackground + onAltButtonClicked: { + terminalView.enabled = false + dbTitle.consoleChecked = false } + + Widgets.Terminal { + anchors.fill: parent + widgetEnabled: terminalView.enabled + } + } } + } } + + // + // Dashboard title window + // + DashboardItems.DashboardTitle { + id: dbTitle + height: 32 + Layout.fillWidth: true + onConsoleCheckedChanged: { + if (terminalView.enabled != consoleChecked) + terminalView.enabled = consoleChecked + } + } + } } diff --git a/assets/qml/Panes/Setup.qml b/assets/qml/Panes/Setup.qml index f91552f5..168b4430 100644 --- a/assets/qml/Panes/Setup.qml +++ b/assets/qml/Panes/Setup.qml @@ -29,259 +29,259 @@ import "../Widgets" as Widgets import "SetupPanes" as SetupPanes Item { - id: root + id: root + + // + // Custom properties + // + property int setupMargin: 0 + property int displayedWidth: 380 + app.spacing * 1.5 + readonly property int maxItemWidth: column.width - 2 * spacing + + // + // Displays the setup panel + // + function show() { + setupMargin = 0 + } + + // + // Hides the setup panel + // + function hide() { + setupMargin = -1 * displayedWidth + } + + // + // Animations + // + visible: setupMargin > -1 * displayedWidth + Behavior on setupMargin {NumberAnimation{}} + + // + // Save settings + // + Settings { + // + // Misc settings + // + property alias auto: commAuto.checked + property alias manual: commManual.checked + property alias tabIndex: tab.currentIndex + property alias csvExport: csvLogging.checked // - // Custom properties + // MQTT settings // - property int setupMargin: 0 - property int displayedWidth: 380 + app.spacing * 1.5 - readonly property int maxItemWidth: column.width - 2 * spacing + property alias mqttHost: mqtt.host + property alias mqttPort: mqtt.port + property alias mqttUser: mqtt.user + property alias mqttMode: mqtt.mode + property alias mqttTopic: mqtt.topic + property alias mqttVersion: mqtt.version + property alias mqttPassword: mqtt.password // - // Displays the setup panel + // App settings // - function show() { - setupMargin = 0 + property alias language: settings.language + property alias tcpPlugins: settings.tcpPlugins + property alias windowShadows: settings.windowShadows + } + + // + // Update manual/auto checkboxes + // + Connections { + target: Cpp_JSON_Generator + function onOperationModeChanged() { + commAuto.checked = (Cpp_JSON_Generator.operationMode === 1) + commManual.checked = (Cpp_JSON_Generator.operationMode === 0) } + } + + // + // Window + // + Widgets.Window { + gradient: true + title: qsTr("Setup") + anchors.fill: parent + anchors.leftMargin: 0 + headerDoubleClickEnabled: false + icon.source: "qrc:/icons/settings.svg" + anchors.margins: (app.spacing * 1.5) - 5 + backgroundColor: Cpp_ThemeManager.paneWindowBackground // - // Hides the setup panel + // Control arrangement // - function hide() { - setupMargin = -1 * displayedWidth - } + ColumnLayout { + id: column + anchors.fill: parent + spacing: app.spacing / 2 + anchors.margins: app.spacing * 1.5 - // - // Animations - // - visible: setupMargin > -1 * displayedWidth - Behavior on setupMargin {NumberAnimation{}} - - // - // Save settings - // - Settings { - // - // Misc settings - // - property alias auto: commAuto.checked - property alias manual: commManual.checked - property alias tabIndex: tab.currentIndex - property alias csvExport: csvLogging.checked - - // - // MQTT settings - // - property alias mqttHost: mqtt.host - property alias mqttPort: mqtt.port - property alias mqttUser: mqtt.user - property alias mqttMode: mqtt.mode - property alias mqttTopic: mqtt.topic - property alias mqttVersion: mqtt.version - property alias mqttPassword: mqtt.password - - // - // App settings - // - property alias language: settings.language - property alias tcpPlugins: settings.tcpPlugins - property alias windowShadows: settings.windowShadows - } - - // - // Update manual/auto checkboxes - // - Connections { - target: Cpp_JSON_Generator - function onOperationModeChanged() { - commAuto.checked = (Cpp_JSON_Generator.operationMode === 1) - commManual.checked = (Cpp_JSON_Generator.operationMode === 0) + // + // Comm mode selector + // + Label { + font.bold: true + text: qsTr("Communication Mode") + ":" + } RadioButton { + id: commAuto + checked: true + Layout.maximumWidth: root.maxItemWidth + text: qsTr("No parsing (device sends JSON data)") + onCheckedChanged: { + if (checked) + Cpp_JSON_Generator.setOperationMode(1) + else + Cpp_JSON_Generator.setOperationMode(0) } - } - - // - // Window - // - Widgets.Window { - gradient: true - title: qsTr("Setup") - anchors.fill: parent - anchors.leftMargin: 0 - headerDoubleClickEnabled: false - icon.source: "qrc:/icons/settings.svg" - anchors.margins: (app.spacing * 1.5) - 5 - backgroundColor: Cpp_ThemeManager.paneWindowBackground - - // - // Control arrangement - // - ColumnLayout { - id: column - anchors.fill: parent - spacing: app.spacing / 2 - anchors.margins: app.spacing * 1.5 - - // - // Comm mode selector - // - Label { - font.bold: true - text: qsTr("Communication Mode") + ":" - } RadioButton { - id: commAuto - checked: true - Layout.maximumWidth: root.maxItemWidth - text: qsTr("No parsing (device sends JSON data)") - onCheckedChanged: { - if (checked) - Cpp_JSON_Generator.setOperationMode(1) - else - Cpp_JSON_Generator.setOperationMode(0) - } - } RadioButton { - id: commManual - checked: false - Layout.maximumWidth: root.maxItemWidth - text: qsTr("Parse via JSON project file") - onCheckedChanged: { - if (checked) - Cpp_JSON_Generator.setOperationMode(0) - else - Cpp_JSON_Generator.setOperationMode(1) - } - } - - // - // Map file selector button - // - Button { - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: commManual.checked - Layout.maximumWidth: root.maxItemWidth - onClicked: Cpp_JSON_Generator.loadJsonMap() - text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change project file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) : - qsTr("Select project file") + "...") - } - - // - // Spacer - // - Item { - height: app.spacing / 2 - } - - // - // Enable/disable CSV logging - // - RowLayout { - Layout.fillWidth: true - - Switch { - id: csvLogging - text: qsTr("Create CSV file") - Layout.alignment: Qt.AlignVCenter - checked: Cpp_CSV_Export.exportEnabled - Layout.maximumWidth: root.maxItemWidth - palette.highlight: Cpp_ThemeManager.csvCheckbox - - onCheckedChanged: { - if (Cpp_CSV_Export.exportEnabled !== checked) - Cpp_CSV_Export.exportEnabled = checked - } - } - - Item { - Layout.fillWidth: true - } - - RoundButton { - icon.width: 24 - icon.height: 24 - icon.color: Cpp_ThemeManager.text - Layout.alignment: Qt.AlignVCenter - icon.source: "qrc:/icons/help.svg" - onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") - } - } - - // - // Spacer - // - Item { - height: app.spacing / 2 - } - - // - // Tab bar - // - TabBar { - height: 24 - id: tab - Layout.fillWidth: true - Layout.maximumWidth: root.maxItemWidth - - TabButton { - text: qsTr("Device") - height: tab.height + 3 - width: implicitWidth + 2 * app.spacing - } - - TabButton { - text: qsTr("MQTT") - height: tab.height + 3 - width: implicitWidth + 2 * app.spacing - } - - TabButton { - text: qsTr("Settings") - height: tab.height + 3 - width: implicitWidth + 2 * app.spacing - } - } - - // - // Tab bar contents - // - StackLayout { - id: stack - clip: true - Layout.fillWidth: true - Layout.fillHeight: true - currentIndex: tab.currentIndex - Layout.topMargin: -parent.spacing - 1 - - SetupPanes.Hardware { - id: hardware - Layout.fillWidth: true - Layout.fillHeight: true - background: TextField { - enabled: false - palette.base: Cpp_ThemeManager.setupPanelBackground - } - } - - SetupPanes.MQTT { - id: mqtt - Layout.fillWidth: true - Layout.fillHeight: true - background: TextField { - enabled: false - palette.base: Cpp_ThemeManager.setupPanelBackground - } - } - - SetupPanes.Settings { - id: settings - Layout.fillWidth: true - Layout.fillHeight: true - background: TextField { - enabled: false - palette.base: Cpp_ThemeManager.setupPanelBackground - } - } - } + } RadioButton { + id: commManual + checked: false + Layout.maximumWidth: root.maxItemWidth + text: qsTr("Parse via JSON project file") + onCheckedChanged: { + if (checked) + Cpp_JSON_Generator.setOperationMode(0) + else + Cpp_JSON_Generator.setOperationMode(1) } + } + + // + // Map file selector button + // + Button { + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: commManual.checked + Layout.maximumWidth: root.maxItemWidth + onClicked: Cpp_JSON_Generator.loadJsonMap() + text: (Cpp_JSON_Generator.jsonMapFilename.length ? qsTr("Change project file (%1)").arg(Cpp_JSON_Generator.jsonMapFilename) : + qsTr("Select project file") + "...") + } + + // + // Spacer + // + Item { + height: app.spacing / 2 + } + + // + // Enable/disable CSV logging + // + RowLayout { + Layout.fillWidth: true + + Switch { + id: csvLogging + text: qsTr("Create CSV file") + Layout.alignment: Qt.AlignVCenter + checked: Cpp_CSV_Export.exportEnabled + Layout.maximumWidth: root.maxItemWidth + palette.highlight: Cpp_ThemeManager.csvCheckbox + + onCheckedChanged: { + if (Cpp_CSV_Export.exportEnabled !== checked) + Cpp_CSV_Export.exportEnabled = checked + } + } + + Item { + Layout.fillWidth: true + } + + RoundButton { + icon.width: 24 + icon.height: 24 + icon.color: Cpp_ThemeManager.text + Layout.alignment: Qt.AlignVCenter + icon.source: "qrc:/icons/help.svg" + onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") + } + } + + // + // Spacer + // + Item { + height: app.spacing / 2 + } + + // + // Tab bar + // + TabBar { + height: 24 + id: tab + Layout.fillWidth: true + Layout.maximumWidth: root.maxItemWidth + + TabButton { + text: qsTr("Device") + height: tab.height + 3 + width: implicitWidth + 2 * app.spacing + } + + TabButton { + text: qsTr("MQTT") + height: tab.height + 3 + width: implicitWidth + 2 * app.spacing + } + + TabButton { + text: qsTr("Settings") + height: tab.height + 3 + width: implicitWidth + 2 * app.spacing + } + } + + // + // Tab bar contents + // + StackLayout { + id: stack + clip: true + Layout.fillWidth: true + Layout.fillHeight: true + currentIndex: tab.currentIndex + Layout.topMargin: -parent.spacing - 1 + + SetupPanes.Hardware { + id: hardware + Layout.fillWidth: true + Layout.fillHeight: true + background: TextField { + enabled: false + palette.base: Cpp_ThemeManager.setupPanelBackground + } + } + + SetupPanes.MQTT { + id: mqtt + Layout.fillWidth: true + Layout.fillHeight: true + background: TextField { + enabled: false + palette.base: Cpp_ThemeManager.setupPanelBackground + } + } + + SetupPanes.Settings { + id: settings + Layout.fillWidth: true + Layout.fillHeight: true + background: TextField { + enabled: false + palette.base: Cpp_ThemeManager.setupPanelBackground + } + } + } } + } } diff --git a/assets/qml/Panes/SetupPanes/Devices/BluetoothLE.qml b/assets/qml/Panes/SetupPanes/Devices/BluetoothLE.qml index 905edd34..0e474aff 100644 --- a/assets/qml/Panes/SetupPanes/Devices/BluetoothLE.qml +++ b/assets/qml/Panes/SetupPanes/Devices/BluetoothLE.qml @@ -25,150 +25,150 @@ import QtQuick.Layouts import QtQuick.Controls Control { - id: root + id: root + + // + // Start BLE scanning 2 seconds after the control is created + // + Component.onCompleted: timer.start() + Timer { + id: timer + interval: 2000 + onTriggered: Cpp_IO_Bluetooth_LE.startDiscovery() + } + + // + // Control layout + // + ColumnLayout { + id: layout + spacing: app.spacing + anchors.fill: parent + anchors.margins: app.spacing // - // Start BLE scanning 2 seconds after the control is created + // Device selector + refresh button // - Component.onCompleted: timer.start() - Timer { - id: timer - interval: 2000 - onTriggered: Cpp_IO_Bluetooth_LE.startDiscovery() + RowLayout { + spacing: app.spacing + visible: opacity > 0 + opacity: Cpp_IO_Bluetooth_LE.operatingSystemSupported && Cpp_IO_Bluetooth_LE.deviceCount > 0 ? 1 : 0 + + Label { + id: devLabel + opacity: enabled ? 1 : 0.5 + text: qsTr("Device") + ":" + enabled: !Cpp_IO_Manager.connected + Layout.minimumWidth: Math.max(devLabel.implicitWidth, servLabel.implicitWidth) + } + + ComboBox { + id: _deviceCombo + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + model: Cpp_IO_Bluetooth_LE.deviceNames + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (currentIndex !== Cpp_IO_Bluetooth_LE.currentDevice) + Cpp_IO_Bluetooth_LE.selectDevice(currentIndex) + } + } + + Button { + width: 24 + height: 24 + icon.width: 16 + icon.height: 16 + opacity: enabled ? 1 : 0.5 + icon.color: Cpp_ThemeManager.text + enabled: !Cpp_IO_Manager.connected + icon.source: "qrc:/icons/refresh.svg" + onClicked: Cpp_IO_Bluetooth_LE.startDiscovery() + palette.base: Cpp_ThemeManager.setupPanelBackground + } } // - // Control layout + // Service selector // - ColumnLayout { - id: layout - spacing: app.spacing - anchors.fill: parent - anchors.margins: app.spacing + RowLayout { + spacing: app.spacing + visible: opacity > 0 + opacity: Cpp_IO_Bluetooth_LE.operatingSystemSupported && serviceNames.count > 1 ? 1 : 0 - // - // Device selector + refresh button - // - RowLayout { - spacing: app.spacing - visible: opacity > 0 - opacity: Cpp_IO_Bluetooth_LE.operatingSystemSupported && Cpp_IO_Bluetooth_LE.deviceCount > 0 ? 1 : 0 + Label { + id: servLabel + text: qsTr("Service") + ":" + Layout.minimumWidth: Math.max(devLabel.implicitWidth, servLabel.implicitWidth) + } - Label { - id: devLabel - opacity: enabled ? 1 : 0.5 - text: qsTr("Device") + ":" - enabled: !Cpp_IO_Manager.connected - Layout.minimumWidth: Math.max(devLabel.implicitWidth, servLabel.implicitWidth) - } - - ComboBox { - id: _deviceCombo - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - model: Cpp_IO_Bluetooth_LE.deviceNames - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (currentIndex !== Cpp_IO_Bluetooth_LE.currentDevice) - Cpp_IO_Bluetooth_LE.selectDevice(currentIndex) - } - } - - Button { - width: 24 - height: 24 - icon.width: 16 - icon.height: 16 - opacity: enabled ? 1 : 0.5 - icon.color: Cpp_ThemeManager.text - enabled: !Cpp_IO_Manager.connected - icon.source: "qrc:/icons/refresh.svg" - onClicked: Cpp_IO_Bluetooth_LE.startDiscovery() - palette.base: Cpp_ThemeManager.setupPanelBackground - } - } - - // - // Service selector - // - RowLayout { - spacing: app.spacing - visible: opacity > 0 - opacity: Cpp_IO_Bluetooth_LE.operatingSystemSupported && serviceNames.count > 1 ? 1 : 0 - - Label { - id: servLabel - text: qsTr("Service") + ":" - Layout.minimumWidth: Math.max(devLabel.implicitWidth, servLabel.implicitWidth) - } - - ComboBox { - id: serviceNames - Layout.fillWidth: true - model: Cpp_IO_Bluetooth_LE.serviceNames - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: Cpp_IO_Bluetooth_LE.selectService(currentIndex) - } - } - - // - // Scanning indicator - // - RowLayout { - spacing: app.spacing - visible: opacity > 0 - opacity: Cpp_IO_Bluetooth_LE.operatingSystemSupported && Cpp_IO_Bluetooth_LE.deviceCount < 1 ? 1 : 0 - - BusyIndicator { - running: parent.visible - Layout.minimumWidth: 16 - Layout.minimumHeight: 16 - Layout.alignment: Qt.AlignVCenter - } - - Label { - Layout.fillWidth: true - text: qsTr("Scanning....") - Layout.alignment: Qt.AlignVCenter - } - } - - // - // OS not supported indicator - // - RowLayout { - spacing: app.spacing - visible: opacity > 0 - opacity: !Cpp_IO_Bluetooth_LE.operatingSystemSupported - - ToolButton { - flat: true - enabled: false - icon.width: 32 - icon.height: 32 - Layout.alignment: Qt.AlignVCenter - icon.source: "qrc:/icons/heart-broken.svg" - icon.color: Cpp_ThemeManager.connectButtonChecked - } - - Label { - Layout.fillWidth: true - wrapMode: Label.WordWrap - Layout.alignment: Qt.AlignVCenter - text: qsTr("Sorry, this version of %1 is not supported yet. " + - "We'll update Serial Studio to work with this operating " + - "system as soon as Qt officially supports it.").arg(Cpp_OSName); - } - } - - // - // Spacer - // - Item { - Layout.fillHeight: true - } + ComboBox { + id: serviceNames + Layout.fillWidth: true + model: Cpp_IO_Bluetooth_LE.serviceNames + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: Cpp_IO_Bluetooth_LE.selectService(currentIndex) + } } + + // + // Scanning indicator + // + RowLayout { + spacing: app.spacing + visible: opacity > 0 + opacity: Cpp_IO_Bluetooth_LE.operatingSystemSupported && Cpp_IO_Bluetooth_LE.deviceCount < 1 ? 1 : 0 + + BusyIndicator { + running: parent.visible + Layout.minimumWidth: 16 + Layout.minimumHeight: 16 + Layout.alignment: Qt.AlignVCenter + } + + Label { + Layout.fillWidth: true + text: qsTr("Scanning....") + Layout.alignment: Qt.AlignVCenter + } + } + + // + // OS not supported indicator + // + RowLayout { + spacing: app.spacing + visible: opacity > 0 + opacity: !Cpp_IO_Bluetooth_LE.operatingSystemSupported + + ToolButton { + flat: true + enabled: false + icon.width: 32 + icon.height: 32 + Layout.alignment: Qt.AlignVCenter + icon.source: "qrc:/icons/heart-broken.svg" + icon.color: Cpp_ThemeManager.connectButtonChecked + } + + Label { + Layout.fillWidth: true + wrapMode: Label.WordWrap + Layout.alignment: Qt.AlignVCenter + text: qsTr("Sorry, this version of %1 is not supported yet. " + + "We'll update Serial Studio to work with this operating " + + "system as soon as Qt officially supports it.").arg(Cpp_OSName); + } + } + + // + // Spacer + // + Item { + Layout.fillHeight: true + } + } } diff --git a/assets/qml/Panes/SetupPanes/Devices/Network.qml b/assets/qml/Panes/SetupPanes/Devices/Network.qml index 38ebfc74..5b2a9a55 100644 --- a/assets/qml/Panes/SetupPanes/Devices/Network.qml +++ b/assets/qml/Panes/SetupPanes/Devices/Network.qml @@ -25,259 +25,259 @@ import QtQuick.Layouts import QtQuick.Controls Control { - id: root + id: root - // - // Access to properties - // - property alias address: _address.text - property alias tcpPort: _tcpPort.text - property alias udpLocalPort: _udpLocalPort.text - property alias udpRemotePort: _udpRemotePort.text - property alias socketType: _typeCombo.currentIndex - property alias udpMulticastEnabled: _udpMulticast.checked - property alias udpProcessDatagramsDirectly: _udpProcessDatagrams.checked - - // - // React to network manager events - // - Connections { - target: Cpp_IO_Network + // + // Access to properties + // + property alias address: _address.text + property alias tcpPort: _tcpPort.text + property alias udpLocalPort: _udpLocalPort.text + property alias udpRemotePort: _udpRemotePort.text + property alias socketType: _typeCombo.currentIndex + property alias udpMulticastEnabled: _udpMulticast.checked + property alias udpProcessDatagramsDirectly: _udpProcessDatagrams.checked - function onAddressChanged() { - if (_address.text.length > 0) - _address.text = Cpp_IO_Network.remoteAddress + // + // React to network manager events + // + Connections { + target: Cpp_IO_Network + + function onAddressChanged() { + if (_address.text.length > 0) + _address.text = Cpp_IO_Network.remoteAddress + } + + function onPortChanged() { + if (_tcpPort.text.length > 0) + _tcpPort.text = Cpp_IO_Network.tcpPort + + if (_udpLocalPort.text.length > 0) + _udpLocalPort.text = Cpp_IO_Network.udpLocalPort + + if (_udpRemotePort.text.length > 0) + _udpRemotePort.text = Cpp_IO_Network.udpRemotePort + } + } + + // + // Layout + // + ColumnLayout { + id: layout + anchors.fill: parent + anchors.margins: app.spacing + + GridLayout { + columns: 2 + Layout.fillWidth: true + rowSpacing: app.spacing + columnSpacing: app.spacing + + // + // Socket type + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("Socket type") + ":" + enabled: !Cpp_IO_Manager.connected + } ComboBox { + id: _typeCombo + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + model: Cpp_IO_Network.socketTypes + enabled: !Cpp_IO_Manager.connected + currentIndex: Cpp_IO_Network.socketTypeIndex + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (currentIndex !== Cpp_IO_Network.socketTypeIndex) + Cpp_IO_Network.socketTypeIndex = currentIndex + } + } + + // + // Address + // + Label { + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + text: qsTr("Remote address") + ":" + } TextField { + id: _address + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + placeholderText: Cpp_IO_Network.defaultAddress + palette.base: Cpp_ThemeManager.setupPanelBackground + Component.onCompleted: text = Cpp_IO_Network.remoteAddress + onTextChanged: { + if (Cpp_IO_Network.remoteAddress !== text && text.length > 0) + Cpp_IO_Network.remoteAddress = text + + if (text.length === 0) + Cpp_IO_Network.remoteAddress = Cpp_IO_Network.defaultAddress + } + } + + // + // TCP port + // + Label { + text: qsTr("Port") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + visible: Cpp_IO_Network.socketTypeIndex === 0 + } TextField { + id: _tcpPort + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + placeholderText: Cpp_IO_Network.defaultTcpPort + palette.base: Cpp_ThemeManager.setupPanelBackground + Component.onCompleted: text = Cpp_IO_Network.tcpPort + onTextChanged: { + if (Cpp_IO_Network.tcpPort !== text && text.length > 0) + Cpp_IO_Network.tcpPort = text + + if (text.length === 0) + Cpp_IO_Network.port = Cpp_IO_Network.defaultTcpPort } - function onPortChanged() { - if (_tcpPort.text.length > 0) - _tcpPort.text = Cpp_IO_Network.tcpPort - - if (_udpLocalPort.text.length > 0) - _udpLocalPort.text = Cpp_IO_Network.udpLocalPort - - if (_udpRemotePort.text.length > 0) - _udpRemotePort.text = Cpp_IO_Network.udpRemotePort + validator: IntValidator { + bottom: 0 + top: 65535 } + + + visible: Cpp_IO_Network.socketTypeIndex === 0 + } + + + // + // TCP port + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("Local port") + ":" + enabled: !Cpp_IO_Manager.connected + visible: Cpp_IO_Network.socketTypeIndex === 1 + } TextField { + id: _udpLocalPort + Layout.fillWidth: true + placeholderText: qsTr("Type 0 for automatic port") + palette.base: Cpp_ThemeManager.setupPanelBackground + Component.onCompleted: text = Cpp_IO_Network.udpLocalPort + onTextChanged: { + if (Cpp_IO_Network.udpLocalPort !== text && text.length > 0) + Cpp_IO_Network.udpLocalPort = text + + if (text.length === 0) + Cpp_IO_Network.udpLocalPort = Cpp_IO_Network.defaultUdpLocalPort + } + + validator: IntValidator { + bottom: 0 + top: 65535 + } + + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + visible: Cpp_IO_Network.socketTypeIndex === 1 + } + + // + // Output port + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("Remote port") + ":" + enabled: !Cpp_IO_Manager.connected + visible: Cpp_IO_Network.socketTypeIndex === 1 && !udpMulticastEnabled + } TextField { + id: _udpRemotePort + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_IO_Manager.connected + palette.base: Cpp_ThemeManager.setupPanelBackground + placeholderText: Cpp_IO_Network.defaultUdpRemotePort + Component.onCompleted: text = Cpp_IO_Network.udpRemotePort + visible: Cpp_IO_Network.socketTypeIndex === 1 && !udpMulticastEnabled + + onTextChanged: { + if (Cpp_IO_Network.udpRemotePort !== text && text.length > 0) + Cpp_IO_Network.udpRemotePort = text + + if (text.length === 0) + Cpp_IO_Network.udpRemotePort = Cpp_IO_Network.defaultUdpRemotePort + } + + validator: IntValidator { + bottom: 0 + top: 65535 + } + } + + // + // UDP multicast checkbox + // + Label { + text: qsTr("Multicast") + ":" + opacity: _udpMulticast.enabled ? 1 : 0.5 + visible: Cpp_IO_Network.socketTypeIndex === 1 + } CheckBox { + id: _udpMulticast + opacity: enabled ? 1 : 0.5 + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: -app.spacing + checked: Cpp_IO_Network.udpMulticast + visible: Cpp_IO_Network.socketTypeIndex === 1 + palette.base: Cpp_ThemeManager.setupPanelBackground + enabled: Cpp_IO_Network.socketTypeIndex === 1 && !Cpp_IO_Manager.connected + + onCheckedChanged: { + if (Cpp_IO_Network.udpMulticast !== checked) + Cpp_IO_Network.udpMulticast = checked + } + } + + // + // UDP multicast checkbox + // + Label { + text: qsTr("Ignore data delimiters") + ":" + opacity: _udpProcessDatagrams.enabled ? 1 : 0.5 + visible: Cpp_IO_Network.socketTypeIndex === 1 + } CheckBox { + id: _udpProcessDatagrams + opacity: enabled ? 1 : 0.5 + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: -app.spacing + visible: Cpp_IO_Network.socketTypeIndex === 1 + checked: Cpp_IO_Network.udpIgnoreFrameSequences + palette.base: Cpp_ThemeManager.setupPanelBackground + enabled: Cpp_IO_Network.socketTypeIndex === 1 && !Cpp_IO_Manager.connected + + onCheckedChanged: { + if (Cpp_IO_Network.udpIgnoreFrameSequences !== checked) + Cpp_IO_Network.udpIgnoreFrameSequences = checked + } + } } // - // Layout + // Spacer // - ColumnLayout { - id: layout - anchors.fill: parent - anchors.margins: app.spacing - - GridLayout { - columns: 2 - Layout.fillWidth: true - rowSpacing: app.spacing - columnSpacing: app.spacing - - // - // Socket type - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("Socket type") + ":" - enabled: !Cpp_IO_Manager.connected - } ComboBox { - id: _typeCombo - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - model: Cpp_IO_Network.socketTypes - enabled: !Cpp_IO_Manager.connected - currentIndex: Cpp_IO_Network.socketTypeIndex - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (currentIndex !== Cpp_IO_Network.socketTypeIndex) - Cpp_IO_Network.socketTypeIndex = currentIndex - } - } - - // - // Address - // - Label { - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - text: qsTr("Remote address") + ":" - } TextField { - id: _address - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - placeholderText: Cpp_IO_Network.defaultAddress - palette.base: Cpp_ThemeManager.setupPanelBackground - Component.onCompleted: text = Cpp_IO_Network.remoteAddress - onTextChanged: { - if (Cpp_IO_Network.remoteAddress !== text && text.length > 0) - Cpp_IO_Network.remoteAddress = text - - if (text.length === 0) - Cpp_IO_Network.remoteAddress = Cpp_IO_Network.defaultAddress - } - } - - // - // TCP port - // - Label { - text: qsTr("Port") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - visible: Cpp_IO_Network.socketTypeIndex === 0 - } TextField { - id: _tcpPort - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - placeholderText: Cpp_IO_Network.defaultTcpPort - palette.base: Cpp_ThemeManager.setupPanelBackground - Component.onCompleted: text = Cpp_IO_Network.tcpPort - onTextChanged: { - if (Cpp_IO_Network.tcpPort !== text && text.length > 0) - Cpp_IO_Network.tcpPort = text - - if (text.length === 0) - Cpp_IO_Network.port = Cpp_IO_Network.defaultTcpPort - } - - validator: IntValidator { - bottom: 0 - top: 65535 - } - - - visible: Cpp_IO_Network.socketTypeIndex === 0 - } - - - // - // TCP port - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("Local port") + ":" - enabled: !Cpp_IO_Manager.connected - visible: Cpp_IO_Network.socketTypeIndex === 1 - } TextField { - id: _udpLocalPort - Layout.fillWidth: true - placeholderText: qsTr("Type 0 for automatic port") - palette.base: Cpp_ThemeManager.setupPanelBackground - Component.onCompleted: text = Cpp_IO_Network.udpLocalPort - onTextChanged: { - if (Cpp_IO_Network.udpLocalPort !== text && text.length > 0) - Cpp_IO_Network.udpLocalPort = text - - if (text.length === 0) - Cpp_IO_Network.udpLocalPort = Cpp_IO_Network.defaultUdpLocalPort - } - - validator: IntValidator { - bottom: 0 - top: 65535 - } - - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - visible: Cpp_IO_Network.socketTypeIndex === 1 - } - - // - // Output port - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("Remote port") + ":" - enabled: !Cpp_IO_Manager.connected - visible: Cpp_IO_Network.socketTypeIndex === 1 && !udpMulticastEnabled - } TextField { - id: _udpRemotePort - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_IO_Manager.connected - palette.base: Cpp_ThemeManager.setupPanelBackground - placeholderText: Cpp_IO_Network.defaultUdpRemotePort - Component.onCompleted: text = Cpp_IO_Network.udpRemotePort - visible: Cpp_IO_Network.socketTypeIndex === 1 && !udpMulticastEnabled - - onTextChanged: { - if (Cpp_IO_Network.udpRemotePort !== text && text.length > 0) - Cpp_IO_Network.udpRemotePort = text - - if (text.length === 0) - Cpp_IO_Network.udpRemotePort = Cpp_IO_Network.defaultUdpRemotePort - } - - validator: IntValidator { - bottom: 0 - top: 65535 - } - } - - // - // UDP multicast checkbox - // - Label { - text: qsTr("Multicast") + ":" - opacity: _udpMulticast.enabled ? 1 : 0.5 - visible: Cpp_IO_Network.socketTypeIndex === 1 - } CheckBox { - id: _udpMulticast - opacity: enabled ? 1 : 0.5 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: -app.spacing - checked: Cpp_IO_Network.udpMulticast - visible: Cpp_IO_Network.socketTypeIndex === 1 - palette.base: Cpp_ThemeManager.setupPanelBackground - enabled: Cpp_IO_Network.socketTypeIndex === 1 && !Cpp_IO_Manager.connected - - onCheckedChanged: { - if (Cpp_IO_Network.udpMulticast !== checked) - Cpp_IO_Network.udpMulticast = checked - } - } - - // - // UDP multicast checkbox - // - Label { - text: qsTr("Ignore data delimiters") + ":" - opacity: _udpProcessDatagrams.enabled ? 1 : 0.5 - visible: Cpp_IO_Network.socketTypeIndex === 1 - } CheckBox { - id: _udpProcessDatagrams - opacity: enabled ? 1 : 0.5 - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: -app.spacing - visible: Cpp_IO_Network.socketTypeIndex === 1 - checked: Cpp_IO_Network.udpIgnoreFrameSequences - palette.base: Cpp_ThemeManager.setupPanelBackground - enabled: Cpp_IO_Network.socketTypeIndex === 1 && !Cpp_IO_Manager.connected - - onCheckedChanged: { - if (Cpp_IO_Network.udpIgnoreFrameSequences !== checked) - Cpp_IO_Network.udpIgnoreFrameSequences = checked - } - } - } - - // - // Spacer - // - Item { - Layout.fillHeight: true - Layout.minimumHeight: app.spacing - } - - // - // Spacer - // - Item { - Layout.fillHeight: true - } + Item { + Layout.fillHeight: true + Layout.minimumHeight: app.spacing } + + // + // Spacer + // + Item { + Layout.fillHeight: true + } + } } diff --git a/assets/qml/Panes/SetupPanes/Devices/Serial.qml b/assets/qml/Panes/SetupPanes/Devices/Serial.qml index 18bf8d96..714dc851 100644 --- a/assets/qml/Panes/SetupPanes/Devices/Serial.qml +++ b/assets/qml/Panes/SetupPanes/Devices/Serial.qml @@ -25,207 +25,207 @@ import QtQuick.Layouts import QtQuick.Controls Control { - id: root + id: root + + // + // Access to properties + // + property alias port: _portCombo.currentIndex + property alias baudRate: _baudCombo.currentIndex + property alias dataBits: _dataCombo.currentIndex + property alias parity: _parityCombo.currentIndex + property alias flowControl: _flowCombo.currentIndex + property alias stopBits: _stopBitsCombo.currentIndex + property alias autoReconnect: _autoreconnect.checked + + // + // Update listbox models when translation is changed + // + Connections { + target: Cpp_Misc_Translator + function onLanguageChanged() { + var oldParityIndex = _parityCombo.currentIndex + var oldFlowControlIndex = _flowCombo.currentIndex + + _parityCombo.model = Cpp_IO_Serial.parityList + _flowCombo.model = Cpp_IO_Serial.flowControlList + + _parityCombo.currentIndex = oldParityIndex + _flowCombo.currentIndex = oldFlowControlIndex + } + } + + // + // Control layout + // + ColumnLayout { + anchors.fill: parent + anchors.margins: app.spacing // - // Access to properties + // Controls // - property alias port: _portCombo.currentIndex - property alias baudRate: _baudCombo.currentIndex - property alias dataBits: _dataCombo.currentIndex - property alias parity: _parityCombo.currentIndex - property alias flowControl: _flowCombo.currentIndex - property alias stopBits: _stopBitsCombo.currentIndex - property alias autoReconnect: _autoreconnect.checked + GridLayout { + id: layout + columns: 2 + Layout.fillWidth: true + rowSpacing: app.spacing + columnSpacing: app.spacing - // - // Update listbox models when translation is changed - // - Connections { - target: Cpp_Misc_Translator - function onLanguageChanged() { - var oldParityIndex = _parityCombo.currentIndex - var oldFlowControlIndex = _flowCombo.currentIndex - - _parityCombo.model = Cpp_IO_Serial.parityList - _flowCombo.model = Cpp_IO_Serial.flowControlList - - _parityCombo.currentIndex = oldParityIndex - _flowCombo.currentIndex = oldFlowControlIndex + // + // COM port selector + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("COM Port") + ":" + enabled: !Cpp_IO_Manager.connected + } ComboBox { + id: _portCombo + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + model: Cpp_IO_Serial.portList + enabled: !Cpp_IO_Manager.connected + currentIndex: Cpp_IO_Serial.portIndex + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (currentIndex !== Cpp_IO_Serial.portIndex) + Cpp_IO_Serial.portIndex = currentIndex } + } + + // + // Baud rate selector + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("Baud Rate") + ":" + } ComboBox { + id: _baudCombo + editable: true + currentIndex: 4 + Layout.fillWidth: true + model: Cpp_IO_Serial.baudRateList + palette.base: Cpp_ThemeManager.setupPanelBackground + + validator: IntValidator { + bottom: 1 + } + + onAccepted: { + if (find(editText) === -1) + Cpp_IO_Serial.appendBaudRate(editText) + } + + onCurrentTextChanged: { + var value = currentText + Cpp_IO_Serial.baudRate = value + } + } + + // + // Auto-reconnect + // + Label { + text: qsTr("Auto-reconnect") + ":" + } CheckBox { + id: _autoreconnect + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: -app.spacing + checked: Cpp_IO_Serial.autoReconnect + palette.base: Cpp_ThemeManager.setupPanelBackground + onCheckedChanged: { + if (Cpp_IO_Serial.autoReconnect !== checked) + Cpp_IO_Serial.autoReconnect = checked + } + } + + // + // Spacer + // + Item { + Layout.minimumHeight: app.spacing / 2 + Layout.maximumHeight: app.spacing / 2 + } Item { + Layout.minimumHeight: app.spacing / 2 + Layout.maximumHeight: app.spacing / 2 + } + + // + // Data bits selector + // + Label { + text: qsTr("Data Bits") + ":" + } ComboBox { + id: _dataCombo + Layout.fillWidth: true + model: Cpp_IO_Serial.dataBitsList + currentIndex: Cpp_IO_Serial.dataBitsIndex + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (Cpp_IO_Serial.dataBitsIndex !== currentIndex) + Cpp_IO_Serial.dataBitsIndex = currentIndex + } + } + + // + // Parity selector + // + Label { + text: qsTr("Parity") + ":" + } ComboBox { + id: _parityCombo + Layout.fillWidth: true + model: Cpp_IO_Serial.parityList + currentIndex: Cpp_IO_Serial.parityIndex + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (Cpp_IO_Serial.parityIndex !== currentIndex) + Cpp_IO_Serial.parityIndex = currentIndex + } + } + + // + // Stop bits selector + // + Label { + text: qsTr("Stop Bits") + ":" + } ComboBox { + id: _stopBitsCombo + Layout.fillWidth: true + model: Cpp_IO_Serial.stopBitsList + currentIndex: Cpp_IO_Serial.stopBitsIndex + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (Cpp_IO_Serial.stopBitsIndex !== currentIndex) + Cpp_IO_Serial.stopBitsIndex = currentIndex + } + } + + // + // Flow control selector + // + Label { + text: qsTr("Flow Control") + ":" + } ComboBox { + id: _flowCombo + Layout.fillWidth: true + model: Cpp_IO_Serial.flowControlList + currentIndex: Cpp_IO_Serial.flowControlIndex + palette.base: Cpp_ThemeManager.setupPanelBackground + onCurrentIndexChanged: { + if (Cpp_IO_Serial.flowControlIndex !== currentIndex) + Cpp_IO_Serial.flowControlIndex = currentIndex + } + } } // - // Control layout + // Vertical spacer // - ColumnLayout { - anchors.fill: parent - anchors.margins: app.spacing - - // - // Controls - // - GridLayout { - id: layout - columns: 2 - Layout.fillWidth: true - rowSpacing: app.spacing - columnSpacing: app.spacing - - // - // COM port selector - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("COM Port") + ":" - enabled: !Cpp_IO_Manager.connected - } ComboBox { - id: _portCombo - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - model: Cpp_IO_Serial.portList - enabled: !Cpp_IO_Manager.connected - currentIndex: Cpp_IO_Serial.portIndex - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (currentIndex !== Cpp_IO_Serial.portIndex) - Cpp_IO_Serial.portIndex = currentIndex - } - } - - // - // Baud rate selector - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("Baud Rate") + ":" - } ComboBox { - id: _baudCombo - editable: true - currentIndex: 4 - Layout.fillWidth: true - model: Cpp_IO_Serial.baudRateList - palette.base: Cpp_ThemeManager.setupPanelBackground - - validator: IntValidator { - bottom: 1 - } - - onAccepted: { - if (find(editText) === -1) - Cpp_IO_Serial.appendBaudRate(editText) - } - - onCurrentTextChanged: { - var value = currentText - Cpp_IO_Serial.baudRate = value - } - } - - // - // Auto-reconnect - // - Label { - text: qsTr("Auto-reconnect") + ":" - } CheckBox { - id: _autoreconnect - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: -app.spacing - checked: Cpp_IO_Serial.autoReconnect - palette.base: Cpp_ThemeManager.setupPanelBackground - onCheckedChanged: { - if (Cpp_IO_Serial.autoReconnect !== checked) - Cpp_IO_Serial.autoReconnect = checked - } - } - - // - // Spacer - // - Item { - Layout.minimumHeight: app.spacing / 2 - Layout.maximumHeight: app.spacing / 2 - } Item { - Layout.minimumHeight: app.spacing / 2 - Layout.maximumHeight: app.spacing / 2 - } - - // - // Data bits selector - // - Label { - text: qsTr("Data Bits") + ":" - } ComboBox { - id: _dataCombo - Layout.fillWidth: true - model: Cpp_IO_Serial.dataBitsList - currentIndex: Cpp_IO_Serial.dataBitsIndex - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (Cpp_IO_Serial.dataBitsIndex !== currentIndex) - Cpp_IO_Serial.dataBitsIndex = currentIndex - } - } - - // - // Parity selector - // - Label { - text: qsTr("Parity") + ":" - } ComboBox { - id: _parityCombo - Layout.fillWidth: true - model: Cpp_IO_Serial.parityList - currentIndex: Cpp_IO_Serial.parityIndex - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (Cpp_IO_Serial.parityIndex !== currentIndex) - Cpp_IO_Serial.parityIndex = currentIndex - } - } - - // - // Stop bits selector - // - Label { - text: qsTr("Stop Bits") + ":" - } ComboBox { - id: _stopBitsCombo - Layout.fillWidth: true - model: Cpp_IO_Serial.stopBitsList - currentIndex: Cpp_IO_Serial.stopBitsIndex - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (Cpp_IO_Serial.stopBitsIndex !== currentIndex) - Cpp_IO_Serial.stopBitsIndex = currentIndex - } - } - - // - // Flow control selector - // - Label { - text: qsTr("Flow Control") + ":" - } ComboBox { - id: _flowCombo - Layout.fillWidth: true - model: Cpp_IO_Serial.flowControlList - currentIndex: Cpp_IO_Serial.flowControlIndex - palette.base: Cpp_ThemeManager.setupPanelBackground - onCurrentIndexChanged: { - if (Cpp_IO_Serial.flowControlIndex !== currentIndex) - Cpp_IO_Serial.flowControlIndex = currentIndex - } - } - } - - // - // Vertical spacer - // - Item { - Layout.fillHeight: true - } + Item { + Layout.fillHeight: true } + } } diff --git a/assets/qml/Panes/SetupPanes/Hardware.qml b/assets/qml/Panes/SetupPanes/Hardware.qml index e48a8d22..592484c8 100644 --- a/assets/qml/Panes/SetupPanes/Hardware.qml +++ b/assets/qml/Panes/SetupPanes/Hardware.qml @@ -29,90 +29,90 @@ import "Devices" as Devices import "../../Windows" as Windows Control { - id: root + id: root + + // + // Save settings + // + QtSettings.Settings { + property alias driver: _driverCombo.currentIndex + property alias parity: serial.parity + property alias baudRate: serial.baudRate + property alias dataBits: serial.dataBits + property alias stopBits: serial.stopBits + property alias flowControl: serial.flowControl + property alias autoReconnect: serial.autoReconnect + property alias address: network.address + property alias tcpPort: network.tcpPort + property alias socketType: network.socketType + property alias udpLocalPort: network.udpLocalPort + property alias udpRemotePort: network.udpRemotePort + property alias udpMulticastEnabled: network.udpMulticastEnabled + property alias udpProcessDatagramsDirectly: network.udpProcessDatagramsDirectly + } + + ColumnLayout { + id: layout + anchors.fill: parent + anchors.margins: app.spacing // - // Save settings + // Device type selector // - QtSettings.Settings { - property alias driver: _driverCombo.currentIndex - property alias parity: serial.parity - property alias baudRate: serial.baudRate - property alias dataBits: serial.dataBits - property alias stopBits: serial.stopBits - property alias flowControl: serial.flowControl - property alias autoReconnect: serial.autoReconnect - property alias address: network.address - property alias tcpPort: network.tcpPort - property alias socketType: network.socketType - property alias udpLocalPort: network.udpLocalPort - property alias udpRemotePort: network.udpRemotePort - property alias udpMulticastEnabled: network.udpMulticastEnabled - property alias udpProcessDatagramsDirectly: network.udpProcessDatagramsDirectly + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Label { + text: qsTr("Data source") + ":" + Layout.alignment: Qt.AlignVCenter + } + + ComboBox { + id: _driverCombo + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter + model: Cpp_IO_Manager.availableDrivers() + onCurrentIndexChanged: Cpp_IO_Manager.selectedDriver = currentIndex + } } - ColumnLayout { - id: layout - anchors.fill: parent - anchors.margins: app.spacing + // + // Device configuration + // + StackLayout { + id: stack + clip: true + Layout.fillWidth: true + Layout.fillHeight: true + currentIndex: Cpp_IO_Manager.selectedDriver - // - // Device type selector - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Label { - text: qsTr("Data source") + ":" - Layout.alignment: Qt.AlignVCenter - } - - ComboBox { - id: _driverCombo - Layout.fillWidth: true - Layout.alignment: Qt.AlignVCenter - model: Cpp_IO_Manager.availableDrivers() - onCurrentIndexChanged: Cpp_IO_Manager.selectedDriver = currentIndex - } + Devices.Serial { + id: serial + Layout.fillWidth: true + Layout.fillHeight: true + background: TextField { + enabled: false } + } - // - // Device configuration - // - StackLayout { - id: stack - clip: true - Layout.fillWidth: true - Layout.fillHeight: true - currentIndex: Cpp_IO_Manager.selectedDriver - - Devices.Serial { - id: serial - Layout.fillWidth: true - Layout.fillHeight: true - background: TextField { - enabled: false - } - } - - Devices.Network { - id: network - Layout.fillWidth: true - Layout.fillHeight: true - background: TextField { - enabled: false - } - } - - Devices.BluetoothLE { - id: bluetoothLE - Layout.fillWidth: true - Layout.fillHeight: true - background: TextField { - enabled: false - } - } + Devices.Network { + id: network + Layout.fillWidth: true + Layout.fillHeight: true + background: TextField { + enabled: false } + } + + Devices.BluetoothLE { + id: bluetoothLE + Layout.fillWidth: true + Layout.fillHeight: true + background: TextField { + enabled: false + } + } } + } } diff --git a/assets/qml/Panes/SetupPanes/MQTT.qml b/assets/qml/Panes/SetupPanes/MQTT.qml index 39662b41..976af345 100644 --- a/assets/qml/Panes/SetupPanes/MQTT.qml +++ b/assets/qml/Panes/SetupPanes/MQTT.qml @@ -27,274 +27,274 @@ import QtQuick.Controls import "../../Windows" as Windows Control { - id: root + id: root - // - // Aliases - // - property alias host: _host.text - property alias port: _port.text - property alias topic: _topic.text - property alias user: _user.text - property alias password: _password.text - property alias version: _version.currentIndex - property alias mode: _mode.currentIndex - - // - // React to events from MQTT module - // - Connections { - target: Cpp_MQTT_Client - - function onHostChanged() { - if (_host.text.length > 0) - _host.text = Cpp_MQTT_Client.host + // + // Aliases + // + property alias host: _host.text + property alias port: _port.text + property alias topic: _topic.text + property alias user: _user.text + property alias password: _password.text + property alias version: _version.currentIndex + property alias mode: _mode.currentIndex + + // + // React to events from MQTT module + // + Connections { + target: Cpp_MQTT_Client + + function onHostChanged() { + if (_host.text.length > 0) + _host.text = Cpp_MQTT_Client.host + } + + function onPortChanged() { + if (_port.text.length > 0) + _port.text = Cpp_MQTT_Client.port + } + } + + // + // Layout + // + ColumnLayout { + id: layout + anchors.fill: parent + anchors.margins: app.spacing + + GridLayout { + columns: 2 + Layout.fillWidth: true + rowSpacing: app.spacing + columnSpacing: app.spacing + + // + // MQTT version + // + Label { + text: qsTr("Version") + ":" + } ComboBox { + id: _version + Layout.fillWidth: true + model: Cpp_MQTT_Client.mqttVersions + currentIndex: Cpp_MQTT_Client.mqttVersion + onCurrentIndexChanged: { + if (Cpp_MQTT_Client.mqttVersion !== currentIndex) + Cpp_MQTT_Client.mqttVersion = currentIndex } - - function onPortChanged() { - if (_port.text.length > 0) - _port.text = Cpp_MQTT_Client.port + } + + // + // Client mode version + // + Label { + text: qsTr("Mode") + ":" + } ComboBox { + id: _mode + Layout.fillWidth: true + model: Cpp_MQTT_Client.clientModes + currentIndex: Cpp_MQTT_Client.clientMode + onCurrentIndexChanged: { + if (Cpp_MQTT_Client.clientMode !== currentIndex) + Cpp_MQTT_Client.clientMode = currentIndex } + } + + // + // Host + // + Label { + text: qsTr("Host") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } TextField { + id: _host + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + placeholderText: Cpp_MQTT_Client.defaultHost + Component.onCompleted: text = Cpp_MQTT_Client.host + + onTextChanged: { + if (Cpp_MQTT_Client.host !== text && text.length > 0) + Cpp_MQTT_Client.host = text + + if (text.length === 0) + Cpp_MQTT_Client.host = Cpp_MQTT_Client.defaultHost + } + } + + // + // Port + // + Label { + text: qsTr("Port") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } TextField { + id: _port + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + placeholderText: Cpp_MQTT_Client.defaultPort + Component.onCompleted: text = Cpp_MQTT_Client.port + onTextChanged: { + if (Cpp_MQTT_Client.port !== text && text.length > 0) + Cpp_MQTT_Client.port = text + + if (text.length === 0) + Cpp_MQTT_Client.port = Cpp_MQTT_Client.defaultPort + } + + validator: IntValidator { + bottom: 0 + top: 65535 + } + } + + // + // Topic + // + Label { + text: qsTr("Topic") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } TextField { + id: _topic + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + text: Cpp_MQTT_Client.topic + placeholderText: qsTr("MQTT topic") + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onTextChanged: { + if (Cpp_MQTT_Client.topic !== text) + Cpp_MQTT_Client.topic = text + } + } + + // + // Username + // + Label { + text: qsTr("User") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } TextField { + id: _user + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + text: Cpp_MQTT_Client.username + placeholderText: qsTr("MQTT username") + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onTextChanged: { + if (Cpp_MQTT_Client.username !== text) + Cpp_MQTT_Client.username = text + } + } + + // + // Password + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("Password") + ":" + enabled: !Cpp_MQTT_Client.isConnectedToHost + } RowLayout { + Layout.fillWidth: true + spacing: app.spacing / 2 + + TextField { + id: _password + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + echoMode: TextField.Password + text: Cpp_MQTT_Client.password + placeholderText: qsTr("MQTT password") + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onTextChanged: { + if (Cpp_MQTT_Client.password !== text) + Cpp_MQTT_Client.password = text + } + } + + Button { + checkable: true + icon.color: palette.text + Layout.maximumWidth: height + Layout.alignment: Qt.AlignVCenter + icon.source: "qrc:/icons/visibility.svg" + onCheckedChanged: _password.echoMode = (checked ? TextField.Normal : + TextField.Password) + } + } } // - // Layout + // Spacer // - ColumnLayout { - id: layout - anchors.fill: parent - anchors.margins: app.spacing - - GridLayout { - columns: 2 - Layout.fillWidth: true - rowSpacing: app.spacing - columnSpacing: app.spacing - - // - // MQTT version - // - Label { - text: qsTr("Version") + ":" - } ComboBox { - id: _version - Layout.fillWidth: true - model: Cpp_MQTT_Client.mqttVersions - currentIndex: Cpp_MQTT_Client.mqttVersion - onCurrentIndexChanged: { - if (Cpp_MQTT_Client.mqttVersion !== currentIndex) - Cpp_MQTT_Client.mqttVersion = currentIndex - } - } - - // - // Client mode version - // - Label { - text: qsTr("Mode") + ":" - } ComboBox { - id: _mode - Layout.fillWidth: true - model: Cpp_MQTT_Client.clientModes - currentIndex: Cpp_MQTT_Client.clientMode - onCurrentIndexChanged: { - if (Cpp_MQTT_Client.clientMode !== currentIndex) - Cpp_MQTT_Client.clientMode = currentIndex - } - } - - // - // Host - // - Label { - text: qsTr("Host") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } TextField { - id: _host - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - placeholderText: Cpp_MQTT_Client.defaultHost - Component.onCompleted: text = Cpp_MQTT_Client.host - - onTextChanged: { - if (Cpp_MQTT_Client.host !== text && text.length > 0) - Cpp_MQTT_Client.host = text - - if (text.length === 0) - Cpp_MQTT_Client.host = Cpp_MQTT_Client.defaultHost - } - } - - // - // Port - // - Label { - text: qsTr("Port") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } TextField { - id: _port - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - placeholderText: Cpp_MQTT_Client.defaultPort - Component.onCompleted: text = Cpp_MQTT_Client.port - onTextChanged: { - if (Cpp_MQTT_Client.port !== text && text.length > 0) - Cpp_MQTT_Client.port = text - - if (text.length === 0) - Cpp_MQTT_Client.port = Cpp_MQTT_Client.defaultPort - } - - validator: IntValidator { - bottom: 0 - top: 65535 - } - } - - // - // Topic - // - Label { - text: qsTr("Topic") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } TextField { - id: _topic - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - text: Cpp_MQTT_Client.topic - placeholderText: qsTr("MQTT topic") - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onTextChanged: { - if (Cpp_MQTT_Client.topic !== text) - Cpp_MQTT_Client.topic = text - } - } - - // - // Username - // - Label { - text: qsTr("User") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } TextField { - id: _user - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - text: Cpp_MQTT_Client.username - placeholderText: qsTr("MQTT username") - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onTextChanged: { - if (Cpp_MQTT_Client.username !== text) - Cpp_MQTT_Client.username = text - } - } - - // - // Password - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("Password") + ":" - enabled: !Cpp_MQTT_Client.isConnectedToHost - } RowLayout { - Layout.fillWidth: true - spacing: app.spacing / 2 - - TextField { - id: _password - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - echoMode: TextField.Password - text: Cpp_MQTT_Client.password - placeholderText: qsTr("MQTT password") - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onTextChanged: { - if (Cpp_MQTT_Client.password !== text) - Cpp_MQTT_Client.password = text - } - } - - Button { - checkable: true - icon.color: palette.text - Layout.maximumWidth: height - Layout.alignment: Qt.AlignVCenter - icon.source: "qrc:/icons/visibility.svg" - onCheckedChanged: _password.echoMode = (checked ? TextField.Normal : - TextField.Password) - } - } - } - - // - // Spacer - // - Item { - Layout.fillHeight: true - Layout.minimumHeight: app.spacing - } - - // - // Spacer - // - Item { - Layout.fillHeight: true - } - - // - // Advanced setup & connect/disconnect button - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Button { - icon.width: 24 - icon.height: 24 - Layout.fillWidth: true - onClicked: mqttSetup.show() - icon.color: palette.buttonText - text: qsTr("Advanced setup") + " " - icon.source: "qrc:/icons/settings.svg" - } - - Button { - icon.width: 24 - icon.height: 24 - font.bold: true - Layout.fillWidth: true - icon.color: Cpp_ThemeManager.mqttButton - checked: Cpp_MQTT_Client.isConnectedToHost - palette.buttonText: Cpp_ThemeManager.mqttButton - onClicked: Cpp_MQTT_Client.toggleConnection() - text: (checked ? qsTr("Disconnect") : - qsTr("Connect to broker")) + " " - icon.source: checked ? "qrc:/icons/disconnect.svg" : - "qrc:/icons/connect.svg" - } - } - - // - // Spacer - // - Item { - Layout.fillHeight: true - } + Item { + Layout.fillHeight: true + Layout.minimumHeight: app.spacing } // - // MQTT setup dialog + // Spacer // - Windows.MQTTConfiguration { - id: mqttSetup + Item { + Layout.fillHeight: true } + + // + // Advanced setup & connect/disconnect button + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Button { + icon.width: 24 + icon.height: 24 + Layout.fillWidth: true + onClicked: mqttSetup.show() + icon.color: palette.buttonText + text: qsTr("Advanced setup") + " " + icon.source: "qrc:/icons/settings.svg" + } + + Button { + icon.width: 24 + icon.height: 24 + font.bold: true + Layout.fillWidth: true + icon.color: Cpp_ThemeManager.mqttButton + checked: Cpp_MQTT_Client.isConnectedToHost + palette.buttonText: Cpp_ThemeManager.mqttButton + onClicked: Cpp_MQTT_Client.toggleConnection() + text: (checked ? qsTr("Disconnect") : + qsTr("Connect to broker")) + " " + icon.source: checked ? "qrc:/icons/disconnect.svg" : + "qrc:/icons/connect.svg" + } + } + + // + // Spacer + // + Item { + Layout.fillHeight: true + } + } + + // + // MQTT setup dialog + // + Windows.MQTTConfiguration { + id: mqttSetup + } } diff --git a/assets/qml/Panes/SetupPanes/Settings.qml b/assets/qml/Panes/SetupPanes/Settings.qml index 7eb7028e..79a2482e 100644 --- a/assets/qml/Panes/SetupPanes/Settings.qml +++ b/assets/qml/Panes/SetupPanes/Settings.qml @@ -25,131 +25,115 @@ import QtQuick.Layouts import QtQuick.Controls Control { - id: root + id: root + + // + // Access to properties + // + property alias tcpPlugins: _tcpPlugins.checked + property alias language: _langCombo.currentIndex + property alias windowShadows: _windowShadows.checked + + // + // Layout + // + ColumnLayout { + id: layout + anchors.fill: parent + anchors.margins: app.spacing // - // Access to properties + // Controls // - property alias tcpPlugins: _tcpPlugins.checked - property alias language: _langCombo.currentIndex - property alias windowShadows: _windowShadows.checked + GridLayout { + columns: 2 + Layout.fillWidth: true + rowSpacing: app.spacing + columnSpacing: app.spacing - // - // Layout - // - ColumnLayout { - id: layout - anchors.fill: parent - anchors.margins: app.spacing - - // - // Controls - // - GridLayout { - columns: 2 - Layout.fillWidth: true - rowSpacing: app.spacing - columnSpacing: app.spacing - - // - // Language selector - // - Label { - text: qsTr("Language") + ":" - } ComboBox { - id: _langCombo - Layout.fillWidth: true - currentIndex: Cpp_Misc_Translator.language - model: Cpp_Misc_Translator.availableLanguages - onCurrentIndexChanged: { - if (currentIndex !== Cpp_Misc_Translator.language) - Cpp_Misc_Translator.setLanguage(currentIndex) - } - } - - // - // Theme selector - // - Label { - text: qsTr("Theme") + ":" - } ComboBox { - id: _themeCombo - Layout.fillWidth: true - model: Cpp_ThemeManager.availableThemes - currentIndex: Cpp_ThemeManager.themeId - onCurrentIndexChanged: { - if (currentIndex !== Cpp_ThemeManager.themeId) - Cpp_ThemeManager.setTheme(currentIndex) - } - } - - // - // Plugins enabled - // - Label { - text: qsTr("Plugin system") + ": " - } Switch { - id: _tcpPlugins - Layout.leftMargin: -app.spacing - Layout.alignment: Qt.AlignLeft - checked: Cpp_Plugins_Bridge.enabled - onCheckedChanged: { - if (checked !== Cpp_Plugins_Bridge.enabled) - Cpp_Plugins_Bridge.enabled = checked - } - } - - // - // Custom window decorations - // - Label { - text: qsTr("Custom window decorations") + ": " - } Switch { - id: _windowShadows - Layout.leftMargin: -app.spacing - Layout.alignment: Qt.AlignLeft - checked: Cpp_ThemeManager.customWindowDecorations - onCheckedChanged: { - if (checked != Cpp_ThemeManager.customWindowDecorations) - Cpp_ThemeManager.customWindowDecorations = checked - } - } - - // - // Software rendering - // - Label { - text: qsTr("Software rendering") + ": " - } Switch { - id: _softwareRendering - Layout.leftMargin: -app.spacing - Layout.alignment: Qt.AlignLeft - checked: Cpp_ModuleManager.softwareRendering - onCheckedChanged: { - if (checked !== Cpp_ModuleManager.softwareRendering) - Cpp_ModuleManager.setSoftwareRenderingEnabled(checked) - } - } + // + // Language selector + // + Label { + text: qsTr("Language") + ":" + } ComboBox { + id: _langCombo + Layout.fillWidth: true + currentIndex: Cpp_Misc_Translator.language + model: Cpp_Misc_Translator.availableLanguages + onCurrentIndexChanged: { + if (currentIndex !== Cpp_Misc_Translator.language) + Cpp_Misc_Translator.setLanguage(currentIndex) } + } - // - // Plugins label - // - Label { - opacity: 0.8 - font.pixelSize: 12 - Layout.fillWidth: true - wrapMode: Label.WrapAtWordBoundaryOrAnywhere - color: Cpp_ThemeManager.highlightedTextAlternative - text: qsTr("Applications/plugins can interact with %1 by " + - "establishing a TCP connection on port 7777.").arg(Cpp_AppName) + // + // Theme selector + // + Label { + text: qsTr("Theme") + ":" + } ComboBox { + id: _themeCombo + Layout.fillWidth: true + model: Cpp_ThemeManager.availableThemes + currentIndex: Cpp_ThemeManager.themeId + onCurrentIndexChanged: { + if (currentIndex !== Cpp_ThemeManager.themeId) + Cpp_ThemeManager.setTheme(currentIndex) } + } - // - // Vertical spacer - // - Item { - Layout.fillHeight: true + // + // Plugins enabled + // + Label { + text: qsTr("Plugin system") + ": " + } Switch { + id: _tcpPlugins + Layout.leftMargin: -app.spacing + Layout.alignment: Qt.AlignLeft + checked: Cpp_Plugins_Bridge.enabled + onCheckedChanged: { + if (checked !== Cpp_Plugins_Bridge.enabled) + Cpp_Plugins_Bridge.enabled = checked } + } + + // + // Custom window decorations + // + Label { + text: qsTr("Custom window decorations") + ": " + } Switch { + id: _windowShadows + Layout.leftMargin: -app.spacing + Layout.alignment: Qt.AlignLeft + checked: Cpp_ThemeManager.customWindowDecorations + onCheckedChanged: { + if (checked != Cpp_ThemeManager.customWindowDecorations) + Cpp_ThemeManager.customWindowDecorations = checked + } + } } + + // + // Plugins label + // + Label { + opacity: 0.8 + font.pixelSize: 12 + Layout.fillWidth: true + wrapMode: Label.WrapAtWordBoundaryOrAnywhere + color: Cpp_ThemeManager.highlightedTextAlternative + text: qsTr("Applications/plugins can interact with %1 by " + + "establishing a TCP connection on port 7777.").arg(Cpp_AppName) + } + + // + // Vertical spacer + // + Item { + Layout.fillHeight: true + } + } } diff --git a/assets/qml/Panes/Toolbar.qml b/assets/qml/Panes/Toolbar.qml index ff075420..7a696e98 100644 --- a/assets/qml/Panes/Toolbar.qml +++ b/assets/qml/Panes/Toolbar.qml @@ -28,322 +28,296 @@ import QtQuick.Controls import "../Widgets" as Widgets Control { - id: root + id: root - // - // Reference to parent window to be able to drag it with the toolbar - // - property Window window + // + // Reference to parent window to be able to drag it with the toolbar + // + property Window window - // - // Dummy string to increase width of buttons - // - readonly property string _btSpacer: " " + // + // Dummy string to increase width of buttons + // + readonly property string _btSpacer: " " - // - // Custom signals - // - signal setupClicked() - signal consoleClicked() - signal dashboardClicked() - signal projectEditorClicked() + // + // Custom signals + // + signal setupClicked() + signal consoleClicked() + signal dashboardClicked() + signal projectEditorClicked() - // - // Aliases to button check status - // - property alias setupChecked: setupBt.checked - property alias consoleChecked: consoleBt.checked - property alias dashboardChecked: dashboardBt.checked + // + // Aliases to button check status + // + property alias setupChecked: setupBt.checked + property alias consoleChecked: consoleBt.checked + property alias dashboardChecked: dashboardBt.checked - // - // Connections with mac touchbar - // - Connections { - target: Cpp_Misc_MacExtras + // + // Toolbar shadow + // + Widgets.Shadow { + anchors.fill: bg + } - function onSetupClicked() { - setupBt.clicked() - Cpp_Misc_MacExtras.setSetupChecked(setupBt.checked) - } + // + // Background gradient + border + // + Rectangle { + id: bg + anchors.fill: parent - function onConsoleClicked() { - consoleBt.clicked() - Cpp_Misc_MacExtras.setConsoleChecked(consoleBt.checked) - } - - function onDashboardClicked() { - dashboardBt.clicked() - Cpp_Misc_MacExtras.setDashboardChecked(dashboardBt.checked) - } + gradient: Gradient { + GradientStop { position: 0; color: Cpp_ThemeManager.toolbarGradient1 } + GradientStop { position: 1; color: Cpp_ThemeManager.toolbarGradient2 } } - // - // Toolbar shadow - // - Widgets.Shadow { - anchors.fill: bg - } - - // - // Background gradient + border - // Rectangle { - id: bg - anchors.fill: parent + border.width: 1 + anchors.fill: parent + color: "transparent" + visible: Cpp_ThemeManager.titlebarSeparator + border.color: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) + } - gradient: Gradient { - GradientStop { position: 0; color: Cpp_ThemeManager.toolbarGradient1 } - GradientStop { position: 1; color: Cpp_ThemeManager.toolbarGradient2 } - } + Rectangle { + height: 1 + visible: Cpp_ThemeManager.titlebarSeparator + color: Qt.darker(Cpp_ThemeManager.toolbarGradient1, 1.5) + + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + } + } + + // + // Toolbar icons + // + RowLayout { + spacing: app.spacing + anchors.fill: parent + anchors.margins: app.spacing + + Button { + id: setupBt + + flat: true + icon.width: 24 + icon.height: 24 + Layout.fillHeight: true + onClicked: root.setupClicked() + text: qsTr("Setup") + _btSpacer + icon.source: "qrc:/icons/settings.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + + background: Rectangle { + radius: 3 + border.width: 1 + color: "transparent" + border.color: "#040600" + opacity: parent.checked ? 0.2 : 0.0 Rectangle { - border.width: 1 - anchors.fill: parent - color: "transparent" - visible: Cpp_ThemeManager.titlebarSeparator - border.color: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) + border.width: 1 + color: "#626262" + anchors.fill: parent + border.color: "#c2c2c2" + radius: parent.radius - 1 + anchors.margins: parent.border.width } + } + } + + Button { + id: consoleBt + + flat: true + icon.width: 24 + icon.height: 24 + Layout.fillHeight: true + enabled: dashboardBt.enabled + onClicked: root.consoleClicked() + icon.source: "qrc:/icons/code.svg" + text: qsTr("Console") + _btSpacer + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + + background: Rectangle { + radius: 3 + border.width: 1 + color: "transparent" + border.color: "#040600" + opacity: parent.checked ? 0.2 : 0.0 Rectangle { - height: 1 - visible: Cpp_ThemeManager.titlebarSeparator - color: Qt.darker(Cpp_ThemeManager.toolbarGradient1, 1.5) - - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } + border.width: 1 + color: "#626262" + anchors.fill: parent + border.color: "#c2c2c2" + radius: parent.radius - 1 + anchors.margins: parent.border.width } + } + } + + Button { + id: dashboardBt + + flat: true + icon.width: 24 + icon.height: 24 + Layout.fillHeight: true + opacity: enabled ? 1 : 0.5 + onClicked: root.dashboardClicked() + enabled: Cpp_UI_Dashboard.available + text: qsTr("Dashboard") + _btSpacer + icon.source: "qrc:/icons/dashboard.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + + background: Rectangle { + radius: 3 + border.width: 1 + color: "transparent" + border.color: "#040600" + opacity: parent.checked ? 0.2 : 0.0 + + Rectangle { + border.width: 1 + color: "#626262" + anchors.fill: parent + border.color: "#c2c2c2" + radius: parent.radius - 1 + anchors.margins: parent.border.width + } + } } // - // Toolbar icons + // Window drag handler // - RowLayout { - spacing: app.spacing + Item { + height: parent.height + Layout.fillWidth: true + + MouseArea { anchors.fill: parent - anchors.margins: app.spacing - - Button { - id: setupBt - - flat: true - icon.width: 24 - icon.height: 24 - Layout.fillHeight: true - onClicked: root.setupClicked() - text: qsTr("Setup") + _btSpacer - icon.source: "qrc:/icons/settings.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - onCheckedChanged: Cpp_Misc_MacExtras.setSetupChecked(checked) - - background: Rectangle { - radius: 3 - border.width: 1 - color: "transparent" - border.color: "#040600" - opacity: parent.checked ? 0.2 : 0.0 - - Rectangle { - border.width: 1 - color: "#626262" - anchors.fill: parent - border.color: "#c2c2c2" - radius: parent.radius - 1 - anchors.margins: parent.border.width - } - } - } - - Button { - id: consoleBt - - flat: true - icon.width: 24 - icon.height: 24 - Layout.fillHeight: true - enabled: dashboardBt.enabled - onClicked: root.consoleClicked() - icon.source: "qrc:/icons/code.svg" - text: qsTr("Console") + _btSpacer - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - onCheckedChanged: Cpp_Misc_MacExtras.setConsoleChecked(checked) - - background: Rectangle { - radius: 3 - border.width: 1 - color: "transparent" - border.color: "#040600" - opacity: parent.checked ? 0.2 : 0.0 - - Rectangle { - border.width: 1 - color: "#626262" - anchors.fill: parent - border.color: "#c2c2c2" - radius: parent.radius - 1 - anchors.margins: parent.border.width - } - } - } - - Button { - id: dashboardBt - - flat: true - icon.width: 24 - icon.height: 24 - Layout.fillHeight: true - opacity: enabled ? 1 : 0.5 - onClicked: root.dashboardClicked() - enabled: Cpp_UI_Dashboard.available - text: qsTr("Dashboard") + _btSpacer - icon.source: "qrc:/icons/dashboard.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - onCheckedChanged: Cpp_Misc_MacExtras.setDashboardChecked(checked) - onEnabledChanged: Cpp_Misc_MacExtras.setDashboardEnabled(enabled) - - background: Rectangle { - radius: 3 - border.width: 1 - color: "transparent" - border.color: "#040600" - opacity: parent.checked ? 0.2 : 0.0 - - Rectangle { - border.width: 1 - color: "#626262" - anchors.fill: parent - border.color: "#c2c2c2" - radius: parent.radius - 1 - anchors.margins: parent.border.width - } - } - } - - // - // Window drag handler - // - Item { - height: parent.height - Layout.fillWidth: true - - MouseArea { - anchors.fill: parent - onPressedChanged: { - if (pressed) - window.startSystemMove() - } - } - } - - Button { - flat: true - icon.width: 24 - icon.height: 24 - Layout.fillHeight: true - icon.source: "qrc:/icons/json.svg" - onClicked: root.projectEditorClicked() - text: qsTr("Project Editor") + _btSpacer - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - - background: Item {} - } - - Button { - flat: true - icon.width: 24 - icon.height: 24 - Layout.fillHeight: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_CSV_Player.isOpen - icon.source: "qrc:/icons/open.svg" - text: qsTr("Open CSV") + _btSpacer - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - - onClicked: { - if (Cpp_CSV_Export.isOpen) - Cpp_CSV_Export.openCurrentCsv() - else - Cpp_CSV_Player.openFile() - } - - background: Item{} - } - - Button { - id: connectBt - - // - // Button properties - // - flat: true - icon.width: 24 - icon.height: 24 - font.bold: true - Layout.fillHeight: true - - // - // Connection-dependent - // - checked: Cpp_IO_Manager.connected - text: (checked ? qsTr("Disconnect") : - qsTr("Connect")) + _btSpacer - icon.source: checked ? "qrc:/icons/disconnect.svg" : - "qrc:/icons/connect.svg" - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - icon.color: checked ? Cpp_ThemeManager.connectButtonChecked : - Cpp_ThemeManager.connectButtonUnchecked - palette.buttonText: checked ? Cpp_ThemeManager.connectButtonChecked : - Cpp_ThemeManager.connectButtonUnchecked - - // - // Only enable button if it can be clicked - // - opacity: enabled ? 1 : 0.5 - enabled: Cpp_IO_Manager.configurationOk - - // - // Connect/disconnect device when button is clicked - // - onClicked: Cpp_IO_Manager.toggleConnection() - - // - // Custom button background - // - background: Rectangle { - radius: 3 - border.width: 1 - color: "transparent" - border.color: "#040600" - opacity: parent.checked ? 0.2 : 0.0 - - Rectangle { - border.width: 1 - color: "#626262" - anchors.fill: parent - border.color: "#c2c2c2" - radius: parent.radius - 1 - anchors.margins: parent.border.width - } - } + onPressedChanged: { + if (pressed) + window.startSystemMove() } + } } + + Button { + flat: true + icon.width: 24 + icon.height: 24 + Layout.fillHeight: true + icon.source: "qrc:/icons/json.svg" + onClicked: root.projectEditorClicked() + text: qsTr("Project Editor") + _btSpacer + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + + background: Item {} + } + + Button { + flat: true + icon.width: 24 + icon.height: 24 + Layout.fillHeight: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_CSV_Player.isOpen + icon.source: "qrc:/icons/open.svg" + text: qsTr("Open CSV") + _btSpacer + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + + onClicked: { + if (Cpp_CSV_Export.isOpen) + Cpp_CSV_Export.openCurrentCsv() + else + Cpp_CSV_Player.openFile() + } + + background: Item{} + } + + Button { + id: connectBt + + // + // Button properties + // + flat: true + icon.width: 24 + icon.height: 24 + font.bold: true + Layout.fillHeight: true + + // + // Connection-dependent + // + checked: Cpp_IO_Manager.connected + text: (checked ? qsTr("Disconnect") : + qsTr("Connect")) + _btSpacer + icon.source: checked ? "qrc:/icons/disconnect.svg" : + "qrc:/icons/connect.svg" + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + icon.color: checked ? Cpp_ThemeManager.connectButtonChecked : + Cpp_ThemeManager.connectButtonUnchecked + palette.buttonText: checked ? Cpp_ThemeManager.connectButtonChecked : + Cpp_ThemeManager.connectButtonUnchecked + + // + // Only enable button if it can be clicked + // + opacity: enabled ? 1 : 0.5 + enabled: Cpp_IO_Manager.configurationOk + + // + // Connect/disconnect device when button is clicked + // + onClicked: Cpp_IO_Manager.toggleConnection() + + // + // Custom button background + // + background: Rectangle { + radius: 3 + border.width: 1 + color: "transparent" + border.color: "#040600" + opacity: parent.checked ? 0.2 : 0.0 + + Rectangle { + border.width: 1 + color: "#626262" + anchors.fill: parent + border.color: "#c2c2c2" + radius: parent.radius - 1 + anchors.margins: parent.border.width + } + } + } + } } diff --git a/assets/qml/PlatformDependent/DecentMenuItem.qml b/assets/qml/PlatformDependent/DecentMenuItem.qml index b8763226..19500ab1 100644 --- a/assets/qml/PlatformDependent/DecentMenuItem.qml +++ b/assets/qml/PlatformDependent/DecentMenuItem.qml @@ -25,45 +25,45 @@ import QtQuick.Layouts import QtQuick.Controls MenuItem { - id: root + id: root - property alias sequence: _shortcut.sequence - property bool indicatorVisible: root.icon.source.length > 0 || root.checkable + property alias sequence: _shortcut.sequence + property bool indicatorVisible: root.icon.source.length > 0 || root.checkable - Shortcut { - id: _shortcut - enabled: root.enabled - onActivated: root.triggered() + Shortcut { + id: _shortcut + enabled: root.enabled + onActivated: root.triggered() + } + + contentItem: RowLayout { + spacing: 0 + width: root.width + opacity: root.enabled ? 1 : 0.5 + + Item { + width: root.indicatorVisible ? 18 : 0 } - contentItem: RowLayout { - spacing: 0 - width: root.width - opacity: root.enabled ? 1 : 0.5 - - Item { - width: root.indicatorVisible ? 18 : 0 - } - - Label { - id: _titleLabel - text: root.text - Layout.fillWidth: true - elide: Label.ElideRight - verticalAlignment: Qt.AlignVCenter - color: root.highlighted ? Cpp_ThemeManager.highlightedText : palette.text - } - - Item { - Layout.fillWidth: true - } - - Label { - id: _shortcutLabel - opacity: 0.8 - text: _shortcut.nativeText - verticalAlignment: Qt.AlignVCenter - color: root.highlighted ? Cpp_ThemeManager.highlightedText : palette.text - } + Label { + id: _titleLabel + text: root.text + Layout.fillWidth: true + elide: Label.ElideRight + verticalAlignment: Qt.AlignVCenter + color: root.highlighted ? Cpp_ThemeManager.highlightedText : palette.text } + + Item { + Layout.fillWidth: true + } + + Label { + id: _shortcutLabel + opacity: 0.8 + text: _shortcut.nativeText + verticalAlignment: Qt.AlignVCenter + color: root.highlighted ? Cpp_ThemeManager.highlightedText : palette.text + } + } } diff --git a/assets/qml/PlatformDependent/Menubar.qml b/assets/qml/PlatformDependent/Menubar.qml index 24d841e5..3fde9373 100644 --- a/assets/qml/PlatformDependent/Menubar.qml +++ b/assets/qml/PlatformDependent/Menubar.qml @@ -24,325 +24,325 @@ import QtQuick import QtQuick.Controls MenuBar { - id: root + id: root - // - // Set background color - // - background: Rectangle { - color: "transparent" + // + // Set background color + // + background: Rectangle { + color: "transparent" + } + + // + // Palette + // + palette.text: Cpp_ThemeManager.menubarText + palette.base: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient2 + palette.highlightedText: Cpp_ThemeManager.highlightedText + + // + // File menu + // + Menu { + title: qsTr("File") + + DecentMenuItem { + sequence: "ctrl+j" + text: qsTr("Select JSON file") + "..." + onTriggered: Cpp_JSON_Generator.loadJsonMap() } - // - // Palette - // - palette.text: Cpp_ThemeManager.menubarText - palette.base: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient2 - palette.highlightedText: Cpp_ThemeManager.highlightedText + MenuSeparator {} - // - // File menu - // Menu { - title: qsTr("File") + title: qsTr("CSV export") - DecentMenuItem { - sequence: "ctrl+j" - text: qsTr("Select JSON file") + "..." - onTriggered: Cpp_JSON_Generator.loadJsonMap() - } + DecentMenuItem { + checkable: true + text: qsTr("Enable CSV export") + checked: Cpp_CSV_Export.exportEnabled + onTriggered: Cpp_CSV_Export.exportEnabled = checked + } - MenuSeparator {} - - Menu { - title: qsTr("CSV export") - - DecentMenuItem { - checkable: true - text: qsTr("Enable CSV export") - checked: Cpp_CSV_Export.exportEnabled - onTriggered: Cpp_CSV_Export.exportEnabled = checked - } - - DecentMenuItem { - sequence: "ctrl+shift+o" - enabled: Cpp_CSV_Export.isOpen - text: qsTr("Show CSV in explorer") - onTriggered: Cpp_CSV_Export.openCurrentCsv() - } - } - - DecentMenuItem { - sequence: "ctrl+o" - text: qsTr("Replay CSV") + "..." - onTriggered: Cpp_CSV_Player.openFile() - enabled: Cpp_JSON_Generator.operationMode === 0 - } - - MenuSeparator {} - - DecentMenuItem { - sequence: "ctrl+p" - text: qsTr("Print") + "..." - enabled: Cpp_IO_Console.saveAvailable - onTriggered: Cpp_IO_Console.print(app.monoFont) - } - - DecentMenuItem { - sequence: "ctrl+s" - onClicked: Cpp_IO_Console.save() - enabled: Cpp_IO_Console.saveAvailable - text: qsTr("Export console output") + "..." - } - - MenuSeparator {} - - DecentMenuItem { - text: qsTr("Quit") - onTriggered: Qt.quit() - sequence: "ctrl+q" - } + DecentMenuItem { + sequence: "ctrl+shift+o" + enabled: Cpp_CSV_Export.isOpen + text: qsTr("Show CSV in explorer") + onTriggered: Cpp_CSV_Export.openCurrentCsv() + } } - // - // Edit menu - // + DecentMenuItem { + sequence: "ctrl+o" + text: qsTr("Replay CSV") + "..." + onTriggered: Cpp_CSV_Player.openFile() + enabled: Cpp_JSON_Generator.operationMode === 0 + } + + MenuSeparator {} + + DecentMenuItem { + sequence: "ctrl+p" + text: qsTr("Print") + "..." + enabled: Cpp_IO_Console.saveAvailable + onTriggered: Cpp_IO_Console.print(app.monoFont) + } + + DecentMenuItem { + sequence: "ctrl+s" + onClicked: Cpp_IO_Console.save() + enabled: Cpp_IO_Console.saveAvailable + text: qsTr("Export console output") + "..." + } + + MenuSeparator {} + + DecentMenuItem { + text: qsTr("Quit") + onTriggered: Qt.quit() + sequence: "ctrl+q" + } + } + + // + // Edit menu + // + Menu { + title: qsTr("Edit") + + DecentMenuItem { + text: qsTr("Copy") + sequence: "ctrl+c" + onTriggered: mainWindow.consoleCopy() + } + + DecentMenuItem { + sequence: "ctrl+a" + text: qsTr("Select all") + "..." + onTriggered: mainWindow.consoleSelectAll() + } + + DecentMenuItem { + sequence: "ctrl+d" + onTriggered: mainWindow.consoleClear() + text: qsTr("Clear console output") + } + + MenuSeparator{} + Menu { - title: qsTr("Edit") + title: qsTr("Communication mode") - DecentMenuItem { - text: qsTr("Copy") - sequence: "ctrl+c" - onTriggered: mainWindow.consoleCopy() - } + DecentMenuItem { + checkable: true + text: qsTr("Device sends JSON") + checked: Cpp_JSON_Generator.operationMode === 1 + onTriggered: Cpp_JSON_Generator.operationMode = checked ? 1 : 0 + } - DecentMenuItem { - sequence: "ctrl+a" - text: qsTr("Select all") + "..." - onTriggered: mainWindow.consoleSelectAll() - } + DecentMenuItem { + checkable: true + text: qsTr("Load JSON from computer") + checked: Cpp_JSON_Generator.operationMode === 0 + onTriggered: Cpp_JSON_Generator.operationMode = checked ? 0 : 1 + } + } + } - DecentMenuItem { - sequence: "ctrl+d" - onTriggered: mainWindow.consoleClear() - text: qsTr("Clear console output") - } + // + // View menu + // + Menu { + title: qsTr("View") - MenuSeparator{} - - Menu { - title: qsTr("Communication mode") - - DecentMenuItem { - checkable: true - text: qsTr("Device sends JSON") - checked: Cpp_JSON_Generator.operationMode === 1 - onTriggered: Cpp_JSON_Generator.operationMode = checked ? 1 : 0 - } - - DecentMenuItem { - checkable: true - text: qsTr("Load JSON from computer") - checked: Cpp_JSON_Generator.operationMode === 0 - onTriggered: Cpp_JSON_Generator.operationMode = checked ? 0 : 1 - } - } + DecentMenuItem { + checkable: true + sequence: "ctrl+t" + text: qsTr("Console") + checked: mainWindow.consoleVisible + onTriggered: mainWindow.showConsole() + onCheckedChanged: { + if (mainWindow.consoleVisible !== checked) + checked = mainWindow.consoleVisible + } } - // - // View menu - // + DecentMenuItem { + checkable: true + sequence: "ctrl+d" + text: qsTr("Dashboard") + checked: mainWindow.dashboardVisible + enabled: Cpp_UI_Dashboard.available + onTriggered: mainWindow.showDashboard() + onCheckedChanged: { + if (mainWindow.dashboardVisible !== checked) + checked = mainWindow.dashboardVisible + } + } + + MenuSeparator {} + + DecentMenuItem { + checkable: true + sequence: "ctrl+," + checked: mainWindow.setupVisible + text: qsTr("Show setup pane") + onTriggered: mainWindow.showSetup() + } + + MenuSeparator {} + + DecentMenuItem { + sequence: "f11" + onTriggered: mainWindow.toggleFullscreen() + text: mainWindow.isFullscreen ? qsTr("Exit full screen") : + qsTr("Enter full screen") + } + } + + // + // Console format + // + Menu { + title: qsTr("Console") + + DecentMenuItem { + checkable: true + text: qsTr("Autoscroll") + checked: Cpp_IO_Console.autoscroll + onTriggered: Cpp_IO_Console.autoscroll = checked + } + + DecentMenuItem { + checkable: true + text: qsTr("Show timestamp") + checked: Cpp_IO_Console.showTimestamp + onTriggered: Cpp_IO_Console.showTimestamp = checked + } + + DecentMenuItem { + checkable: true + checked: mainWindow.vt100emulation + text: qsTr("VT-100 emulation") + onTriggered: mainWindow.vt100emulation = checked + } + + DecentMenuItem { + checkable: true + text: qsTr("Echo user commands") + checked: Cpp_IO_Console.echo + onTriggered: Cpp_IO_Console.echo = checked + } + + MenuSeparator{} + Menu { - title: qsTr("View") + title: qsTr("Display mode") - DecentMenuItem { - checkable: true - sequence: "ctrl+t" - text: qsTr("Console") - checked: mainWindow.consoleVisible - onTriggered: mainWindow.showConsole() - onCheckedChanged: { - if (mainWindow.consoleVisible !== checked) - checked = mainWindow.consoleVisible - } - } + DecentMenuItem { + checkable: true + text: qsTr("Normal (plain text)") + checked: Cpp_IO_Console.displayMode === 0 + onTriggered: Cpp_IO_Console.displayMode = checked ? 0 : 1 + } - DecentMenuItem { - checkable: true - sequence: "ctrl+d" - text: qsTr("Dashboard") - checked: mainWindow.dashboardVisible - enabled: Cpp_UI_Dashboard.available - onTriggered: mainWindow.showDashboard() - onCheckedChanged: { - if (mainWindow.dashboardVisible !== checked) - checked = mainWindow.dashboardVisible - } - } - - MenuSeparator {} - - DecentMenuItem { - checkable: true - sequence: "ctrl+," - checked: mainWindow.setupVisible - text: qsTr("Show setup pane") - onTriggered: mainWindow.showSetup() - } - - MenuSeparator {} - - DecentMenuItem { - sequence: "f11" - onTriggered: mainWindow.toggleFullscreen() - text: mainWindow.isFullscreen ? qsTr("Exit full screen") : - qsTr("Enter full screen") - } + DecentMenuItem { + checkable: true + text: qsTr("Binary (hexadecimal)") + checked: Cpp_IO_Console.displayMode === 1 + onTriggered: Cpp_IO_Console.displayMode = checked ? 1 : 0 + } } - // - // Console format - // Menu { - title: qsTr("Console") + title: qsTr("Line ending character") - DecentMenuItem { - checkable: true - text: qsTr("Autoscroll") - checked: Cpp_IO_Console.autoscroll - onTriggered: Cpp_IO_Console.autoscroll = checked - } + DecentMenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[0] + checked: Cpp_IO_Console.lineEnding === 0 + onTriggered: Cpp_IO_Console.lineEnding = 0 + } - DecentMenuItem { - checkable: true - text: qsTr("Show timestamp") - checked: Cpp_IO_Console.showTimestamp - onTriggered: Cpp_IO_Console.showTimestamp = checked - } + DecentMenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[1] + checked: Cpp_IO_Console.lineEnding === 1 + onTriggered: Cpp_IO_Console.lineEnding = 1 + } - DecentMenuItem { - checkable: true - checked: mainWindow.vt100emulation - text: qsTr("VT-100 emulation") - onTriggered: mainWindow.vt100emulation = checked - } + DecentMenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[2] + checked: Cpp_IO_Console.lineEnding === 2 + onTriggered: Cpp_IO_Console.lineEnding = 2 + } - DecentMenuItem { - checkable: true - text: qsTr("Echo user commands") - checked: Cpp_IO_Console.echo - onTriggered: Cpp_IO_Console.echo = checked - } + DecentMenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[3] + checked: Cpp_IO_Console.lineEnding === 3 + onTriggered: Cpp_IO_Console.lineEnding = 3 + } + } + } - MenuSeparator{} + // + // Help menu + // + Menu { + title: qsTr("Help") - Menu { - title: qsTr("Display mode") - - DecentMenuItem { - checkable: true - text: qsTr("Normal (plain text)") - checked: Cpp_IO_Console.displayMode === 0 - onTriggered: Cpp_IO_Console.displayMode = checked ? 0 : 1 - } - - DecentMenuItem { - checkable: true - text: qsTr("Binary (hexadecimal)") - checked: Cpp_IO_Console.displayMode === 1 - onTriggered: Cpp_IO_Console.displayMode = checked ? 1 : 0 - } - } - - Menu { - title: qsTr("Line ending character") - - DecentMenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[0] - checked: Cpp_IO_Console.lineEnding === 0 - onTriggered: Cpp_IO_Console.lineEnding = 0 - } - - DecentMenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[1] - checked: Cpp_IO_Console.lineEnding === 1 - onTriggered: Cpp_IO_Console.lineEnding = 1 - } - - DecentMenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[2] - checked: Cpp_IO_Console.lineEnding === 2 - onTriggered: Cpp_IO_Console.lineEnding = 2 - } - - DecentMenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[3] - checked: Cpp_IO_Console.lineEnding === 3 - onTriggered: Cpp_IO_Console.lineEnding = 3 - } - } + DecentMenuItem { + onTriggered: app.aboutDialog.show() + text: qsTr("About %1").arg(Cpp_AppName) } - // - // Help menu - // - Menu { - title: qsTr("Help") - - DecentMenuItem { - onTriggered: app.aboutDialog.show() - text: qsTr("About %1").arg(Cpp_AppName) - } - - DecentMenuItem { - text: qsTr("About %1").arg("Qt") - onTriggered: Cpp_Misc_Utilities.aboutQt() - } - - MenuSeparator { - visible: Cpp_UpdaterEnabled - enabled: Cpp_UpdaterEnabled - } - - DecentMenuItem { - checkable: true - visible: Cpp_UpdaterEnabled - enabled: Cpp_UpdaterEnabled - checked: mainWindow.automaticUpdates - onTriggered: mainWindow.automaticUpdates = checked - text: qsTr("Auto-updater") - } - - DecentMenuItem { - visible: Cpp_UpdaterEnabled - enabled: Cpp_UpdaterEnabled - onTriggered: app.checkForUpdates() - text: qsTr("Check for updates") + "..." - } - - MenuSeparator{} - - DecentMenuItem { - text: qsTr("Project website") + "..." - onTriggered: Qt.openUrlExternally("https://www.alex-spataru.com/serial-studio") - } - - DecentMenuItem { - sequence: "f1" - text: qsTr("Documentation/wiki") + "..." - onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") - } - - MenuSeparator{} - - DecentMenuItem { - text: qsTr("Report bug") + "..." - onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues") - } + DecentMenuItem { + text: qsTr("About %1").arg("Qt") + onTriggered: Cpp_Misc_Utilities.aboutQt() } + + MenuSeparator { + visible: Cpp_UpdaterEnabled + enabled: Cpp_UpdaterEnabled + } + + DecentMenuItem { + checkable: true + visible: Cpp_UpdaterEnabled + enabled: Cpp_UpdaterEnabled + checked: mainWindow.automaticUpdates + onTriggered: mainWindow.automaticUpdates = checked + text: qsTr("Auto-updater") + } + + DecentMenuItem { + visible: Cpp_UpdaterEnabled + enabled: Cpp_UpdaterEnabled + onTriggered: app.checkForUpdates() + text: qsTr("Check for updates") + "..." + } + + MenuSeparator{} + + DecentMenuItem { + text: qsTr("Project website") + "..." + onTriggered: Qt.openUrlExternally("https://www.alex-spataru.com/serial-studio") + } + + DecentMenuItem { + sequence: "f1" + text: qsTr("Documentation/wiki") + "..." + onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") + } + + MenuSeparator{} + + DecentMenuItem { + text: qsTr("Report bug") + "..." + onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues") + } + } } diff --git a/assets/qml/PlatformDependent/MenubarMacOS.qml b/assets/qml/PlatformDependent/MenubarMacOS.qml index 18f3f166..1d46736c 100644 --- a/assets/qml/PlatformDependent/MenubarMacOS.qml +++ b/assets/qml/PlatformDependent/MenubarMacOS.qml @@ -24,307 +24,307 @@ import QtQuick import Qt.labs.platform MenuBar { - // - // File menu - // - Menu { - title: qsTr("File") + // + // File menu + // + Menu { + title: qsTr("File") - MenuItem { - shortcut: "ctrl+j" - text: qsTr("Select JSON file") + "..." - onTriggered: Cpp_JSON_Generator.loadJsonMap() - } - - MenuSeparator {} - - Menu { - title: qsTr("CSV export") - - MenuItem { - checkable: true - text: qsTr("Enable CSV export") - checked: Cpp_CSV_Export.exportEnabled - onTriggered: Cpp_CSV_Export.exportEnabled = checked - } - - MenuItem { - shortcut: "ctrl+shift+o" - enabled: Cpp_CSV_Export.isOpen - text: qsTr("Show CSV in explorer") - onTriggered: Cpp_CSV_Export.openCurrentCsv() - } - } - - MenuItem { - shortcut: "ctrl+o" - text: qsTr("Replay CSV") + "..." - onTriggered: Cpp_CSV_Player.openFile() - enabled: Cpp_JSON_Generator.operationMode === 0 - } - - MenuSeparator {} - - MenuItem { - shortcut: StandardKey.Print - text: qsTr("Print") + "..." - enabled: Cpp_IO_Console.saveAvailable - onTriggered: Cpp_IO_Console.print(app.monoFont) - } - - MenuItem { - shortcut: StandardKey.Save - onTriggered: Cpp_IO_Console.save() - enabled: Cpp_IO_Console.saveAvailable - text: qsTr("Export console output") + "..." - } - - MenuSeparator {} - - MenuItem { - text: qsTr("Quit") - onTriggered: Qt.quit() - shortcut: StandardKey.Quit - } + MenuItem { + shortcut: "ctrl+j" + text: qsTr("Select JSON file") + "..." + onTriggered: Cpp_JSON_Generator.loadJsonMap() } - // - // Edit menu - // + MenuSeparator {} + Menu { - title: qsTr("Edit") + title: qsTr("CSV export") - MenuItem { - text: qsTr("Copy") - shortcut: StandardKey.Copy - onTriggered: mainWindow.consoleCopy() - } + MenuItem { + checkable: true + text: qsTr("Enable CSV export") + checked: Cpp_CSV_Export.exportEnabled + onTriggered: Cpp_CSV_Export.exportEnabled = checked + } - MenuItem { - shortcut: StandardKey.SelectAll - text: qsTr("Select all") + "..." - onTriggered: mainWindow.consoleSelectAll() - } - - MenuItem { - shortcut: StandardKey.Delete - onTriggered: mainWindow.consoleClear() - text: qsTr("Clear console output") - } - - MenuSeparator{} - - Menu { - title: qsTr("Communication mode") - - MenuItem { - checkable: true - text: qsTr("Device sends JSON") - checked: Cpp_JSON_Generator.operationMode === 1 - onTriggered: Cpp_JSON_Generator.operationMode = checked ? 1 : 0 - } - - MenuItem { - checkable: true - text: qsTr("Load JSON from computer") - checked: Cpp_JSON_Generator.operationMode === 0 - onTriggered: Cpp_JSON_Generator.operationMode = checked ? 0 : 1 - } - } + MenuItem { + shortcut: "ctrl+shift+o" + enabled: Cpp_CSV_Export.isOpen + text: qsTr("Show CSV in explorer") + onTriggered: Cpp_CSV_Export.openCurrentCsv() + } } - // - // View menu - // - Menu { - title: qsTr("View") - - MenuItem { - checkable: true - shortcut: "ctrl+t" - text: qsTr("Console") - checked: mainWindow.consoleVisible - onTriggered: mainWindow.showConsole() - onCheckedChanged: { - if (mainWindow.consoleVisible !== checked) - checked = mainWindow.consoleVisible - } - } - - MenuItem { - checkable: true - shortcut: "ctrl+d" - text: qsTr("Dashboard") - checked: mainWindow.dashboardVisible - enabled: Cpp_UI_Dashboard.available - onTriggered: mainWindow.showDashboard() - onCheckedChanged: { - if (mainWindow.dashboardVisible !== checked) - checked = mainWindow.dashboardVisible - } - } - - MenuSeparator {} - - MenuItem { - checkable: true - shortcut: "ctrl+," - checked: mainWindow.setupVisible - text: qsTr("Show setup pane") - onTriggered: mainWindow.showSetup() - } - - MenuSeparator {} - - DecentMenuItem { - sequence: StandardKey.FullScreen - onTriggered: mainWindow.toggleFullscreen() - text: mainWindow.fullScreen ? qsTr("Exit full screen") : qsTr("Enter full screen") - } + MenuItem { + shortcut: "ctrl+o" + text: qsTr("Replay CSV") + "..." + onTriggered: Cpp_CSV_Player.openFile() + enabled: Cpp_JSON_Generator.operationMode === 0 } - // - // Console format - // - Menu { - title: qsTr("Console") + MenuSeparator {} - MenuItem { - checkable: true - text: qsTr("Autoscroll") - checked: Cpp_IO_Console.autoscroll - onTriggered: Cpp_IO_Console.autoscroll = checked - } - - MenuItem { - checkable: true - text: qsTr("Show timestamp") - checked: Cpp_IO_Console.showTimestamp - onTriggered: Cpp_IO_Console.showTimestamp = checked - } - - MenuItem { - checkable: true - checked: mainWindow.vt100emulation - text: qsTr("VT-100 emulation") - onTriggered: mainWindow.vt100emulation = checked - } - - MenuItem { - checkable: true - text: qsTr("Echo user commands") - checked: Cpp_IO_Console.echo - onTriggered: Cpp_IO_Console.echo = checked - } - - MenuSeparator{} - - Menu { - title: qsTr("Display mode") - - MenuItem { - checkable: true - text: qsTr("Normal (plain text)") - checked: Cpp_IO_Console.displayMode === 0 - onTriggered: Cpp_IO_Console.displayMode = checked ? 0 : 1 - } - - MenuItem { - checkable: true - text: qsTr("Binary (hexadecimal)") - checked: Cpp_IO_Console.displayMode === 1 - onTriggered: Cpp_IO_Console.displayMode = checked ? 1 : 0 - } - } - - Menu { - title: qsTr("Line ending character") - - MenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[0] - checked: Cpp_IO_Console.lineEnding === 0 - onTriggered: Cpp_IO_Console.lineEnding = 0 - } - - MenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[1] - checked: Cpp_IO_Console.lineEnding === 1 - onTriggered: Cpp_IO_Console.lineEnding = 1 - } - - MenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[2] - checked: Cpp_IO_Console.lineEnding === 2 - onTriggered: Cpp_IO_Console.lineEnding = 2 - } - - MenuItem { - checkable: true - text: Cpp_IO_Console.lineEndings()[3] - checked: Cpp_IO_Console.lineEnding === 3 - onTriggered: Cpp_IO_Console.lineEnding = 3 - } - } + MenuItem { + shortcut: StandardKey.Print + text: qsTr("Print") + "..." + enabled: Cpp_IO_Console.saveAvailable + onTriggered: Cpp_IO_Console.print(app.monoFont) } - // - // Help menu - // - Menu { - title: qsTr("Help") - - MenuItem { - onTriggered: app.aboutDialog.show() - text: qsTr("About %1").arg(Cpp_AppName) - } - - MenuItem { - text: qsTr("About %1").arg("Qt") - onTriggered: Cpp_Misc_Utilities.aboutQt() - } - - MenuSeparator { - visible: Cpp_UpdaterEnabled - enabled: Cpp_UpdaterEnabled - } - - MenuItem { - checkable: true - visible: Cpp_UpdaterEnabled - enabled: Cpp_UpdaterEnabled - checked: mainWindow.automaticUpdates - onTriggered: mainWindow.automaticUpdates = checked - text: qsTr("Auto-updater") - } - - MenuItem { - visible: Cpp_UpdaterEnabled - enabled: Cpp_UpdaterEnabled - onTriggered: app.checkForUpdates() - text: qsTr("Check for updates") + "..." - } - - MenuSeparator{} - - MenuItem { - text: qsTr("Project website") + "..." - onTriggered: Qt.openUrlExternally("https://www.alex-spataru.com/serial-studio") - } - - MenuItem { - shortcut: StandardKey.HelpContents - text: qsTr("Documentation/wiki") + "..." - onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") - } - - MenuSeparator{} - - MenuItem { - text: qsTr("Report bug") + "..." - onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues") - } + MenuItem { + shortcut: StandardKey.Save + onTriggered: Cpp_IO_Console.save() + enabled: Cpp_IO_Console.saveAvailable + text: qsTr("Export console output") + "..." } + + MenuSeparator {} + + MenuItem { + text: qsTr("Quit") + onTriggered: Qt.quit() + shortcut: StandardKey.Quit + } + } + + // + // Edit menu + // + Menu { + title: qsTr("Edit") + + MenuItem { + text: qsTr("Copy") + shortcut: StandardKey.Copy + onTriggered: mainWindow.consoleCopy() + } + + MenuItem { + shortcut: StandardKey.SelectAll + text: qsTr("Select all") + "..." + onTriggered: mainWindow.consoleSelectAll() + } + + MenuItem { + shortcut: StandardKey.Delete + onTriggered: mainWindow.consoleClear() + text: qsTr("Clear console output") + } + + MenuSeparator{} + + Menu { + title: qsTr("Communication mode") + + MenuItem { + checkable: true + text: qsTr("Device sends JSON") + checked: Cpp_JSON_Generator.operationMode === 1 + onTriggered: Cpp_JSON_Generator.operationMode = checked ? 1 : 0 + } + + MenuItem { + checkable: true + text: qsTr("Load JSON from computer") + checked: Cpp_JSON_Generator.operationMode === 0 + onTriggered: Cpp_JSON_Generator.operationMode = checked ? 0 : 1 + } + } + } + + // + // View menu + // + Menu { + title: qsTr("View") + + MenuItem { + checkable: true + shortcut: "ctrl+t" + text: qsTr("Console") + checked: mainWindow.consoleVisible + onTriggered: mainWindow.showConsole() + onCheckedChanged: { + if (mainWindow.consoleVisible !== checked) + checked = mainWindow.consoleVisible + } + } + + MenuItem { + checkable: true + shortcut: "ctrl+d" + text: qsTr("Dashboard") + checked: mainWindow.dashboardVisible + enabled: Cpp_UI_Dashboard.available + onTriggered: mainWindow.showDashboard() + onCheckedChanged: { + if (mainWindow.dashboardVisible !== checked) + checked = mainWindow.dashboardVisible + } + } + + MenuSeparator {} + + MenuItem { + checkable: true + shortcut: "ctrl+," + checked: mainWindow.setupVisible + text: qsTr("Show setup pane") + onTriggered: mainWindow.showSetup() + } + + MenuSeparator {} + + DecentMenuItem { + sequence: StandardKey.FullScreen + onTriggered: mainWindow.toggleFullscreen() + text: mainWindow.fullScreen ? qsTr("Exit full screen") : qsTr("Enter full screen") + } + } + + // + // Console format + // + Menu { + title: qsTr("Console") + + MenuItem { + checkable: true + text: qsTr("Autoscroll") + checked: Cpp_IO_Console.autoscroll + onTriggered: Cpp_IO_Console.autoscroll = checked + } + + MenuItem { + checkable: true + text: qsTr("Show timestamp") + checked: Cpp_IO_Console.showTimestamp + onTriggered: Cpp_IO_Console.showTimestamp = checked + } + + MenuItem { + checkable: true + checked: mainWindow.vt100emulation + text: qsTr("VT-100 emulation") + onTriggered: mainWindow.vt100emulation = checked + } + + MenuItem { + checkable: true + text: qsTr("Echo user commands") + checked: Cpp_IO_Console.echo + onTriggered: Cpp_IO_Console.echo = checked + } + + MenuSeparator{} + + Menu { + title: qsTr("Display mode") + + MenuItem { + checkable: true + text: qsTr("Normal (plain text)") + checked: Cpp_IO_Console.displayMode === 0 + onTriggered: Cpp_IO_Console.displayMode = checked ? 0 : 1 + } + + MenuItem { + checkable: true + text: qsTr("Binary (hexadecimal)") + checked: Cpp_IO_Console.displayMode === 1 + onTriggered: Cpp_IO_Console.displayMode = checked ? 1 : 0 + } + } + + Menu { + title: qsTr("Line ending character") + + MenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[0] + checked: Cpp_IO_Console.lineEnding === 0 + onTriggered: Cpp_IO_Console.lineEnding = 0 + } + + MenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[1] + checked: Cpp_IO_Console.lineEnding === 1 + onTriggered: Cpp_IO_Console.lineEnding = 1 + } + + MenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[2] + checked: Cpp_IO_Console.lineEnding === 2 + onTriggered: Cpp_IO_Console.lineEnding = 2 + } + + MenuItem { + checkable: true + text: Cpp_IO_Console.lineEndings()[3] + checked: Cpp_IO_Console.lineEnding === 3 + onTriggered: Cpp_IO_Console.lineEnding = 3 + } + } + } + + // + // Help menu + // + Menu { + title: qsTr("Help") + + MenuItem { + onTriggered: app.aboutDialog.show() + text: qsTr("About %1").arg(Cpp_AppName) + } + + MenuItem { + text: qsTr("About %1").arg("Qt") + onTriggered: Cpp_Misc_Utilities.aboutQt() + } + + MenuSeparator { + visible: Cpp_UpdaterEnabled + enabled: Cpp_UpdaterEnabled + } + + MenuItem { + checkable: true + visible: Cpp_UpdaterEnabled + enabled: Cpp_UpdaterEnabled + checked: mainWindow.automaticUpdates + onTriggered: mainWindow.automaticUpdates = checked + text: qsTr("Auto-updater") + } + + MenuItem { + visible: Cpp_UpdaterEnabled + enabled: Cpp_UpdaterEnabled + onTriggered: app.checkForUpdates() + text: qsTr("Check for updates") + "..." + } + + MenuSeparator{} + + MenuItem { + text: qsTr("Project website") + "..." + onTriggered: Qt.openUrlExternally("https://www.alex-spataru.com/serial-studio") + } + + MenuItem { + shortcut: StandardKey.HelpContents + text: qsTr("Documentation/wiki") + "..." + onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") + } + + MenuSeparator{} + + MenuItem { + text: qsTr("Report bug") + "..." + onTriggered: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues") + } + } } diff --git a/assets/qml/ProjectEditor/Footer.qml b/assets/qml/ProjectEditor/Footer.qml index 60cfeb9a..5a43df2f 100644 --- a/assets/qml/ProjectEditor/Footer.qml +++ b/assets/qml/ProjectEditor/Footer.qml @@ -27,147 +27,147 @@ import QtQuick.Controls import "../Widgets" as Widgets Rectangle { - id: root - color: Cpp_ThemeManager.toolbarGradient2 - height: footer.implicitHeight + 4 * app.spacing + id: root + color: Cpp_ThemeManager.toolbarGradient2 + height: footer.implicitHeight + 4 * app.spacing - // - // Signals - // - signal closeWindow() - signal scrollToBottom() + // + // Signals + // + signal closeWindow() + signal scrollToBottom() - // - // Radius compensator - // - Rectangle { - color: root.color - height: root.radius - anchors { - top: parent.top - left: parent.left - right: parent.right - } + // + // Radius compensator + // + Rectangle { + color: root.color + height: root.radius + anchors { + top: parent.top + left: parent.left + right: parent.right + } + } + + // + // Top border + // + Rectangle { + height: 1 + color: Cpp_ThemeManager.toolbarGradient1 + anchors { + top: parent.top + left: parent.left + right: parent.right + } + } + + // + // Dialog buttons + // + RowLayout { + id: footer + spacing: app.spacing + + anchors { + left: parent.left + right: parent.right + margins: app.spacing * 2 + verticalCenter: parent.verticalCenter } - // - // Top border - // - Rectangle { - height: 1 - color: Cpp_ThemeManager.toolbarGradient1 - anchors { - top: parent.top - left: parent.left - right: parent.right - } + Button { + icon.width: 24 + icon.height: 24 + onClicked: root.closeWindow() + text: qsTr("Close") + _btSpacer + icon.source: "qrc:/icons/close.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 } - // - // Dialog buttons - // - RowLayout { - id: footer - spacing: app.spacing - - anchors { - left: parent.left - right: parent.right - margins: app.spacing * 2 - verticalCenter: parent.verticalCenter - } - - Button { - icon.width: 24 - icon.height: 24 - onClicked: root.closeWindow() - text: qsTr("Close") + _btSpacer - icon.source: "qrc:/icons/close.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - } - - Item { - Layout.fillWidth: true - } - - Button { - id: addGrp - icon.width: 24 - icon.height: 24 - highlighted: true - Layout.fillWidth: true - text: qsTr("Add group") - icon.source: "qrc:/icons/add.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - onClicked: { - Cpp_Project_Model.addGroup() - root.scrollToBottom() - } - } - - Button { - icon.width: 24 - icon.height: 24 - Layout.fillWidth: true - icon.source: "qrc:/icons/code.svg" - text: qsTr("Customize frame parser") - icon.color: Cpp_ThemeManager.menubarText - onClicked: Cpp_Project_CodeEditor.displayWindow() - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - } - - Item { - Layout.fillWidth: true - } - - Button { - icon.width: 24 - icon.height: 24 - icon.source: "qrc:/icons/open.svg" - icon.color: Cpp_ThemeManager.menubarText - onClicked: Cpp_Project_Model.openJsonFile() - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - text: qsTr("Open existing project...") + _btSpacer - } - - Button { - icon.width: 24 - icon.height: 24 - icon.source: "qrc:/icons/new.svg" - icon.color: Cpp_ThemeManager.menubarText - onClicked: Cpp_Project_Model.newJsonFile() - text: qsTr("Create new project") + _btSpacer - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - } - - Button { - icon.width: 24 - icon.height: 24 - opacity: enabled ? 1: 0.5 - enabled: Cpp_Project_Model.modified - icon.source: "qrc:/icons/apply.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - text: (Cpp_Project_Model.jsonFilePath.length > 0 ? qsTr("Apply") : qsTr("Save")) + _btSpacer - - onClicked: { - if (Cpp_Project_Model.saveJsonFile()) - root.closeWindow() - } - } + Item { + Layout.fillWidth: true } + + Button { + id: addGrp + icon.width: 24 + icon.height: 24 + highlighted: true + Layout.fillWidth: true + text: qsTr("Add group") + icon.source: "qrc:/icons/add.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + onClicked: { + Cpp_Project_Model.addGroup() + root.scrollToBottom() + } + } + + Button { + icon.width: 24 + icon.height: 24 + Layout.fillWidth: true + icon.source: "qrc:/icons/code.svg" + text: qsTr("Customize frame parser") + icon.color: Cpp_ThemeManager.menubarText + onClicked: Cpp_Project_CodeEditor.displayWindow() + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + } + + Item { + Layout.fillWidth: true + } + + Button { + icon.width: 24 + icon.height: 24 + icon.source: "qrc:/icons/open.svg" + icon.color: Cpp_ThemeManager.menubarText + onClicked: Cpp_Project_Model.openJsonFile() + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + text: qsTr("Open existing project...") + _btSpacer + } + + Button { + icon.width: 24 + icon.height: 24 + icon.source: "qrc:/icons/new.svg" + icon.color: Cpp_ThemeManager.menubarText + onClicked: Cpp_Project_Model.newJsonFile() + text: qsTr("Create new project") + _btSpacer + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + } + + Button { + icon.width: 24 + icon.height: 24 + opacity: enabled ? 1: 0.5 + enabled: Cpp_Project_Model.modified + icon.source: "qrc:/icons/apply.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + text: (Cpp_Project_Model.jsonFilePath.length > 0 ? qsTr("Apply") : qsTr("Save")) + _btSpacer + + onClicked: { + if (Cpp_Project_Model.saveJsonFile()) + root.closeWindow() + } + } + } } diff --git a/assets/qml/ProjectEditor/GroupEditor.qml b/assets/qml/ProjectEditor/GroupEditor.qml index 778f1e6e..dbfe052b 100644 --- a/assets/qml/ProjectEditor/GroupEditor.qml +++ b/assets/qml/ProjectEditor/GroupEditor.qml @@ -27,90 +27,90 @@ import QtQuick.Controls import "../Widgets" as Widgets ColumnLayout { - id: root - spacing: 0 + id: root + spacing: 0 - // - // Connections with JSON editor model - // - Connections { - target: Cpp_Project_Model + // + // Connections with JSON editor model + // + Connections { + target: Cpp_Project_Model - function onGroupCountChanged() { - tabRepeater.model = 0 - stackRepeater.model = 0 - tabRepeater.model = Cpp_Project_Model.groupCount - stackRepeater.model = Cpp_Project_Model.groupCount - } - - function onGroupOrderChanged() { - tabRepeater.model = 0 - stackRepeater.model = 0 - tabRepeater.model = Cpp_Project_Model.groupCount - stackRepeater.model = Cpp_Project_Model.groupCount - } + function onGroupCountChanged() { + tabRepeater.model = 0 + stackRepeater.model = 0 + tabRepeater.model = Cpp_Project_Model.groupCount + stackRepeater.model = Cpp_Project_Model.groupCount } - // - // Function to scroll to the last group - // - function selectLastGroup() { - tabBar.currentIndex = tabBar.count - 1 + function onGroupOrderChanged() { + tabRepeater.model = 0 + stackRepeater.model = 0 + tabRepeater.model = Cpp_Project_Model.groupCount + stackRepeater.model = Cpp_Project_Model.groupCount } + } - // - // Spacer - // - Item { - height: app.spacing + // + // Function to scroll to the last group + // + function selectLastGroup() { + tabBar.currentIndex = tabBar.count - 1 + } + + // + // Spacer + // + Item { + height: app.spacing + } + + // + // Tab widget + // + TabBar { + id: tabBar + Layout.fillWidth: true + visible: tabRepeater.model > 0 + + Repeater { + id: tabRepeater + delegate: TabButton { + height: 24 + text: qsTr("Group %1").arg(index + 1) + " " + (Cpp_Project_Model.groupTitle(index)) + "" + } } + } - // - // Tab widget - // - TabBar { - id: tabBar - Layout.fillWidth: true - visible: tabRepeater.model > 0 + // + // StackView + // + StackLayout { + id: swipe + Layout.fillWidth: true + Layout.fillHeight: true + currentIndex: tabBar.currentIndex + Layout.topMargin: -parent.spacing - 1 - Repeater { - id: tabRepeater - delegate: TabButton { - height: 24 - text: qsTr("Group %1").arg(index + 1) + " " + (Cpp_Project_Model.groupTitle(index)) + "" - } - } - } + Repeater { + id: stackRepeater - // - // StackView - // - StackLayout { - id: swipe + delegate: Loader { Layout.fillWidth: true Layout.fillHeight: true - currentIndex: tabBar.currentIndex - Layout.topMargin: -parent.spacing - 1 + active: swipe.currentIndex == index - Repeater { - id: stackRepeater - - delegate: Loader { - Layout.fillWidth: true - Layout.fillHeight: true - active: swipe.currentIndex == index - - sourceComponent: JsonGroupDelegate { - group: index - } - } + sourceComponent: JsonGroupDelegate { + group: index } + } } + } - // - // Spacer - // - Item { - height: app.spacing - } + // + // Spacer + // + Item { + height: app.spacing + } } diff --git a/assets/qml/ProjectEditor/Header.qml b/assets/qml/ProjectEditor/Header.qml index 9a65804c..17bea0ce 100644 --- a/assets/qml/ProjectEditor/Header.qml +++ b/assets/qml/ProjectEditor/Header.qml @@ -27,169 +27,169 @@ import QtQuick.Controls import "../Widgets" as Widgets Rectangle { - id: root - height: header.implicitHeight + 4 * app.spacing + id: root + height: header.implicitHeight + 4 * app.spacing + + // + // Background & border + // + Rectangle { + id: bg + anchors.fill: parent + color: Cpp_ThemeManager.toolbarGradient2 + border.width: Cpp_ThemeManager.titlebarSeparator ? 1 : 0 + border.color: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) - // - // Background & border - // Rectangle { - id: bg - anchors.fill: parent - color: Cpp_ThemeManager.toolbarGradient2 - border.width: Cpp_ThemeManager.titlebarSeparator ? 1 : 0 - border.color: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) + height: 1 + visible: Cpp_ThemeManager.titlebarSeparator + color: Qt.darker(Cpp_ThemeManager.toolbarGradient1, 1.5) - Rectangle { - height: 1 - visible: Cpp_ThemeManager.titlebarSeparator - color: Qt.darker(Cpp_ThemeManager.toolbarGradient1, 1.5) - - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - } - } - - // - // Main layout - // - GridLayout { - id: header - columns: 2 - rowSpacing: app.spacing - columnSpacing: app.spacing * 2 - - anchors { - left: parent.left - right: parent.right - margins: app.spacing * 2 - verticalCenter: parent.verticalCenter - } - - // - // Project title - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Widgets.Icon { - color: Cpp_ThemeManager.menubarText - source: "qrc:/icons/registration.svg" - } - - TextField { - Layout.fillWidth: true - Layout.minimumWidth: 320 - Layout.maximumHeight: 24 - Layout.minimumHeight: 24 - text: Cpp_Project_Model.title - onTextChanged: Cpp_Project_Model.setTitle(text) - placeholderText: qsTr("Project title (required)") - - palette { - base: "#fff" - text: "#000" - //placeholderText: "#444" - } - } - } - - // - // Separator character - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Widgets.Icon { - color: Cpp_ThemeManager.menubarText - source: "qrc:/icons/separator.svg" - } - - TextField { - Layout.fillWidth: true - Layout.minimumWidth: 420 - Layout.maximumHeight: 24 - Layout.minimumHeight: 24 - text: Cpp_Project_Model.separator - onTextChanged: Cpp_Project_Model.setSeparator(text) - placeholderText: qsTr("Data separator (default is ',')") - - palette { - base: "#fff" - text: "#000" - //placeholderText: "#444" - } - } - } - - // - // Start sequence - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Widgets.Icon { - color: Cpp_ThemeManager.menubarText - source: "qrc:/icons/start-sequence.svg" - } - - TextField { - Layout.fillWidth: true - Layout.minimumWidth: 256 - Layout.maximumHeight: 24 - Layout.minimumHeight: 24 - text: Cpp_Project_Model.frameStartSequence - onTextChanged: Cpp_Project_Model.setFrameStartSequence(text) - placeholderText: qsTr("Frame start sequence (default is '/*')") - - palette { - base: "#fff" - text: "#000" - //placeholderText: "#444" - } - } - } - - // - // End sequence - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Widgets.Icon { - color: Cpp_ThemeManager.menubarText - source: "qrc:/icons/end-sequence.svg" - } - - TextField { - Layout.fillWidth: true - Layout.minimumWidth: 256 - Layout.maximumHeight: 24 - Layout.minimumHeight: 24 - text: Cpp_Project_Model.frameEndSequence - onTextChanged: Cpp_Project_Model.setFrameEndSequence(text) - placeholderText: qsTr("Frame end sequence (default is '*/')") - - palette { - base: "#fff" - text: "#000" - //placeholderText: "#444" - } - } - } - } - - anchors { - margins: 0 - top: parent.top + anchors { left: parent.left right: parent.right + bottom: parent.bottom + } } + } + + // + // Main layout + // + GridLayout { + id: header + columns: 2 + rowSpacing: app.spacing + columnSpacing: app.spacing * 2 + + anchors { + left: parent.left + right: parent.right + margins: app.spacing * 2 + verticalCenter: parent.verticalCenter + } + + // + // Project title + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Widgets.Icon { + color: Cpp_ThemeManager.menubarText + source: "qrc:/icons/registration.svg" + } + + TextField { + Layout.fillWidth: true + Layout.minimumWidth: 320 + Layout.maximumHeight: 24 + Layout.minimumHeight: 24 + text: Cpp_Project_Model.title + onTextChanged: Cpp_Project_Model.setTitle(text) + placeholderText: qsTr("Project title (required)") + + palette { + base: "#fff" + text: "#000" + //placeholderText: "#444" + } + } + } + + // + // Separator character + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Widgets.Icon { + color: Cpp_ThemeManager.menubarText + source: "qrc:/icons/separator.svg" + } + + TextField { + Layout.fillWidth: true + Layout.minimumWidth: 420 + Layout.maximumHeight: 24 + Layout.minimumHeight: 24 + text: Cpp_Project_Model.separator + onTextChanged: Cpp_Project_Model.setSeparator(text) + placeholderText: qsTr("Data separator (default is ',')") + + palette { + base: "#fff" + text: "#000" + //placeholderText: "#444" + } + } + } + + // + // Start sequence + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Widgets.Icon { + color: Cpp_ThemeManager.menubarText + source: "qrc:/icons/start-sequence.svg" + } + + TextField { + Layout.fillWidth: true + Layout.minimumWidth: 256 + Layout.maximumHeight: 24 + Layout.minimumHeight: 24 + text: Cpp_Project_Model.frameStartSequence + onTextChanged: Cpp_Project_Model.setFrameStartSequence(text) + placeholderText: qsTr("Frame start sequence (default is '/*')") + + palette { + base: "#fff" + text: "#000" + //placeholderText: "#444" + } + } + } + + // + // End sequence + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Widgets.Icon { + color: Cpp_ThemeManager.menubarText + source: "qrc:/icons/end-sequence.svg" + } + + TextField { + Layout.fillWidth: true + Layout.minimumWidth: 256 + Layout.maximumHeight: 24 + Layout.minimumHeight: 24 + text: Cpp_Project_Model.frameEndSequence + onTextChanged: Cpp_Project_Model.setFrameEndSequence(text) + placeholderText: qsTr("Frame end sequence (default is '*/')") + + palette { + base: "#fff" + text: "#000" + //placeholderText: "#444" + } + } + } + } + + anchors { + margins: 0 + top: parent.top + left: parent.left + right: parent.right + } } diff --git a/assets/qml/ProjectEditor/JsonDatasetDelegate.qml b/assets/qml/ProjectEditor/JsonDatasetDelegate.qml index c791ecce..0ade5867 100644 --- a/assets/qml/ProjectEditor/JsonDatasetDelegate.qml +++ b/assets/qml/ProjectEditor/JsonDatasetDelegate.qml @@ -27,282 +27,282 @@ import QtQuick.Controls import "../Widgets" as Widgets Widgets.Window { - id: root + id: root + + // + // Window properties + // + headerDoubleClickEnabled: false + icon.source: "qrc:/icons/dataset.svg" + borderColor: Cpp_ThemeManager.widgetWindowBorder + palette.window: Cpp_ThemeManager.widgetWindowBackground + title: qsTr("Dataset %1 - %2").arg(dataset + 1).arg(Cpp_Project_Model.datasetTitle(group, dataset)) + + // + // Delete dataset button + // + altButtonEnabled: !showGroupWidget + altButtonIcon.source: "qrc:/icons/close.svg" + onAltButtonClicked: Cpp_Project_Model.deleteDataset(group, dataset) + + // + // Custom properties + // + property int group + property int dataset + property bool multiplotGroup + property bool showGroupWidget + + // + // Convenience variables + // + readonly property bool fftSamplesVisible: fftCheck.checked + readonly property bool alarmVisible: widget.currentIndex === 2 + readonly property bool minMaxVisible: widget.currentIndex === 1 || + widget.currentIndex === 2 || + logPlot.checked || + linearPlot.checked || + root.multiplotGroup + + // + // User interface + // + GridLayout { + x: 0 + columns: 2 + anchors.fill: parent + rowSpacing: app.spacing + columnSpacing: app.spacing + anchors.margins: app.spacing * 2 // - // Window properties + // Dataset title // - headerDoubleClickEnabled: false - icon.source: "qrc:/icons/dataset.svg" - borderColor: Cpp_ThemeManager.widgetWindowBorder - palette.window: Cpp_ThemeManager.widgetWindowBackground - title: qsTr("Dataset %1 - %2").arg(dataset + 1).arg(Cpp_Project_Model.datasetTitle(group, dataset)) - - // - // Delete dataset button - // - altButtonEnabled: !showGroupWidget - altButtonIcon.source: "qrc:/icons/close.svg" - onAltButtonClicked: Cpp_Project_Model.deleteDataset(group, dataset) - - // - // Custom properties - // - property int group - property int dataset - property bool multiplotGroup - property bool showGroupWidget - - // - // Convenience variables - // - readonly property bool fftSamplesVisible: fftCheck.checked - readonly property bool alarmVisible: widget.currentIndex === 2 - readonly property bool minMaxVisible: widget.currentIndex === 1 || - widget.currentIndex === 2 || - logPlot.checked || - linearPlot.checked || - root.multiplotGroup - - // - // User interface - // - GridLayout { - x: 0 - columns: 2 - anchors.fill: parent - rowSpacing: app.spacing - columnSpacing: app.spacing - anchors.margins: app.spacing * 2 - - // - // Dataset title - // - Label { - text: qsTr("Title:") - } TextField { - Layout.fillWidth: true - text: Cpp_Project_Model.datasetTitle(group, dataset) - placeholderText: qsTr("Sensor reading, uptime, etc...") - onTextChanged: { - Cpp_Project_Model.setDatasetTitle(group, dataset, text) - root.title = qsTr("Dataset %1 - %2").arg(dataset + 1).arg(Cpp_Project_Model.datasetTitle(group, dataset)) - } - } - - // - // Dataset units - // - Label { - text: qsTr("Units:") - } TextField { - Layout.fillWidth: true - text: Cpp_Project_Model.datasetUnits(group, dataset) - placeholderText: qsTr("Volts, meters, seconds, etc...") - onTextChanged: Cpp_Project_Model.setDatasetUnits(group, dataset, text) - } - - // - // Frame index - // - Label { - text: qsTr("Frame index:") - } TextField { - Layout.fillWidth: true - text: Cpp_Project_Model.datasetIndex(group, dataset) - onTextChanged: Cpp_Project_Model.setDatasetIndex(group, dataset, text) - validator: IntValidator { - bottom: 1 - top: 100 - } - } - - // - // Dataset LED - // - Label { - text: qsTr("Display LED:") - } Switch { - id: led - Layout.leftMargin: -app.spacing - checked: Cpp_Project_Model.datasetLED(group, dataset) - onCheckedChanged: Cpp_Project_Model.setDatasetLED(group, dataset, checked) - } - - // - // Dataset graph - // - Label { - text: qsTr("Generate plot:") - } Switch { - id: linearPlot - Layout.leftMargin: -app.spacing - checked: Cpp_Project_Model.datasetGraph(group, dataset) - onCheckedChanged: { - if (!checked) - logPlot.checked = false - - Cpp_Project_Model.setDatasetGraph(group, dataset, checked) - } - } - - // - // Log plot - // - Label { - text: qsTr("Logarithmic plot:") - visible: linearPlot.checked - } CheckBox { - id: logPlot - visible: linearPlot.checked - Layout.leftMargin: -app.spacing - checked: Cpp_Project_Model.datasetLogPlot(group, dataset) - onCheckedChanged: Cpp_Project_Model.setDatasetLogPlot(group, dataset, checked) - } - - // - // FFT plot - // - Label { - text: qsTr("FFT plot:") - } Switch { - id: fftCheck - Layout.leftMargin: -app.spacing - checked: Cpp_Project_Model.datasetFftPlot(group, dataset) - onCheckedChanged: Cpp_Project_Model.setDatasetFftPlot(group, dataset, checked) - } - - // - // Dataset widget (user selectable or group-level constant) - // - Label { - text: qsTr("Widget:") - } ComboBox { - id: widget - Layout.fillWidth: true - visible: !showGroupWidget - enabled: !showGroupWidget - model: Cpp_Project_Model.availableDatasetLevelWidgets() - currentIndex: Cpp_Project_Model.datasetWidgetIndex(group, dataset) - onCurrentIndexChanged: { - if (visible && currentIndex !== Cpp_Project_Model.datasetWidgetIndex(group, dataset)) - Cpp_Project_Model.setDatasetWidget(group, dataset, currentIndex) - } - } TextField { - readOnly: true - Layout.fillWidth: true - visible: showGroupWidget - enabled: showGroupWidget - text: Cpp_Project_Model.datasetWidget(group, dataset) - } - - - // - // FFT max frequency - // - Label { - text: qsTr("FFT Samples:") - visible: root.fftSamplesVisible - } TextField { - id: fftSamples - Layout.fillWidth: true - visible: root.fftSamplesVisible - text: Cpp_Project_Model.datasetFFTSamples(group, dataset) - onTextChanged: Cpp_Project_Model.setDatasetFFTSamples(group, dataset, parseInt(text)) - validator: IntValidator { - bottom: 8 - top: 40 * 1000 - } - } - - // - // Widget minimum value - // - Label { - text: qsTr("Min value:") - visible: root.minMaxVisible - } TextField { - id: min - Layout.fillWidth: true - visible: root.minMaxVisible - text: Cpp_Project_Model.datasetWidgetMin(group, dataset) - onTextChanged: Cpp_Project_Model.setDatasetWidgetMin(group, dataset, text) - validator: DoubleValidator { - top: parseFloat(max.text) - } - } - - // - // Widget maximum value - // - Label { - text: qsTr("Max value:") - visible: root.minMaxVisible - } TextField { - id: max - Layout.fillWidth: true - visible: root.minMaxVisible - text: Cpp_Project_Model.datasetWidgetMax(group, dataset) - onTextChanged: Cpp_Project_Model.setDatasetWidgetMax(group, dataset, text) - - validator: DoubleValidator { - bottom: parseFloat(min.text) - } - } - - // - // Bar alarm level - // - Label { - text: qsTr("Alarm level:") - visible: root.alarmVisible - } TextField { - id: alarm - Layout.fillWidth: true - visible: root.alarmVisible - text: Cpp_Project_Model.datasetWidgetAlarm(group, dataset) - onTextChanged: Cpp_Project_Model.setDatasetWidgetAlarm(group, dataset, text) - - validator: DoubleValidator { - top: parseFloat(max.text) - bottom: parseFloat(min.text) - } - } - - // - // Vertical spacer - // - Item { - Layout.fillHeight: true - } Item { - Layout.fillHeight: true - } - - // - // Compass note label - // - Widgets.Icon { - width: 32 - height: 32 - color: palette.text - source: "qrc:/icons/compass.svg" - Layout.alignment: Qt.AlignHCenter - visible: widget.currentIndex === 3 - } Label { - font.pixelSize: 16 - Layout.fillWidth: true - wrapMode: Label.WordWrap - visible: widget.currentIndex === 3 - text: "" + qsTr("Note:") + " " + qsTr("The compass widget expects values from 0° to 360°.") - } - - // - // Vertical spacer - // - Item { - Layout.fillHeight: true - } Item { - Layout.fillHeight: true - } + Label { + text: qsTr("Title:") + } TextField { + Layout.fillWidth: true + text: Cpp_Project_Model.datasetTitle(group, dataset) + placeholderText: qsTr("Sensor reading, uptime, etc...") + onTextChanged: { + Cpp_Project_Model.setDatasetTitle(group, dataset, text) + root.title = qsTr("Dataset %1 - %2").arg(dataset + 1).arg(Cpp_Project_Model.datasetTitle(group, dataset)) + } } + + // + // Dataset units + // + Label { + text: qsTr("Units:") + } TextField { + Layout.fillWidth: true + text: Cpp_Project_Model.datasetUnits(group, dataset) + placeholderText: qsTr("Volts, meters, seconds, etc...") + onTextChanged: Cpp_Project_Model.setDatasetUnits(group, dataset, text) + } + + // + // Frame index + // + Label { + text: qsTr("Frame index:") + } TextField { + Layout.fillWidth: true + text: Cpp_Project_Model.datasetIndex(group, dataset) + onTextChanged: Cpp_Project_Model.setDatasetIndex(group, dataset, text) + validator: IntValidator { + bottom: 1 + top: 100 + } + } + + // + // Dataset LED + // + Label { + text: qsTr("Display LED:") + } Switch { + id: led + Layout.leftMargin: -app.spacing + checked: Cpp_Project_Model.datasetLED(group, dataset) + onCheckedChanged: Cpp_Project_Model.setDatasetLED(group, dataset, checked) + } + + // + // Dataset graph + // + Label { + text: qsTr("Generate plot:") + } Switch { + id: linearPlot + Layout.leftMargin: -app.spacing + checked: Cpp_Project_Model.datasetGraph(group, dataset) + onCheckedChanged: { + if (!checked) + logPlot.checked = false + + Cpp_Project_Model.setDatasetGraph(group, dataset, checked) + } + } + + // + // Log plot + // + Label { + text: qsTr("Logarithmic plot:") + visible: linearPlot.checked + } CheckBox { + id: logPlot + visible: linearPlot.checked + Layout.leftMargin: -app.spacing + checked: Cpp_Project_Model.datasetLogPlot(group, dataset) + onCheckedChanged: Cpp_Project_Model.setDatasetLogPlot(group, dataset, checked) + } + + // + // FFT plot + // + Label { + text: qsTr("FFT plot:") + } Switch { + id: fftCheck + Layout.leftMargin: -app.spacing + checked: Cpp_Project_Model.datasetFftPlot(group, dataset) + onCheckedChanged: Cpp_Project_Model.setDatasetFftPlot(group, dataset, checked) + } + + // + // Dataset widget (user selectable or group-level constant) + // + Label { + text: qsTr("Widget:") + } ComboBox { + id: widget + Layout.fillWidth: true + visible: !showGroupWidget + enabled: !showGroupWidget + model: Cpp_Project_Model.availableDatasetLevelWidgets() + currentIndex: Cpp_Project_Model.datasetWidgetIndex(group, dataset) + onCurrentIndexChanged: { + if (visible && currentIndex !== Cpp_Project_Model.datasetWidgetIndex(group, dataset)) + Cpp_Project_Model.setDatasetWidget(group, dataset, currentIndex) + } + } TextField { + readOnly: true + Layout.fillWidth: true + visible: showGroupWidget + enabled: showGroupWidget + text: Cpp_Project_Model.datasetWidget(group, dataset) + } + + + // + // FFT max frequency + // + Label { + text: qsTr("FFT Samples:") + visible: root.fftSamplesVisible + } TextField { + id: fftSamples + Layout.fillWidth: true + visible: root.fftSamplesVisible + text: Cpp_Project_Model.datasetFFTSamples(group, dataset) + onTextChanged: Cpp_Project_Model.setDatasetFFTSamples(group, dataset, parseInt(text)) + validator: IntValidator { + bottom: 8 + top: 40 * 1000 + } + } + + // + // Widget minimum value + // + Label { + text: qsTr("Min value:") + visible: root.minMaxVisible + } TextField { + id: min + Layout.fillWidth: true + visible: root.minMaxVisible + text: Cpp_Project_Model.datasetWidgetMin(group, dataset) + onTextChanged: Cpp_Project_Model.setDatasetWidgetMin(group, dataset, text) + validator: DoubleValidator { + top: parseFloat(max.text) + } + } + + // + // Widget maximum value + // + Label { + text: qsTr("Max value:") + visible: root.minMaxVisible + } TextField { + id: max + Layout.fillWidth: true + visible: root.minMaxVisible + text: Cpp_Project_Model.datasetWidgetMax(group, dataset) + onTextChanged: Cpp_Project_Model.setDatasetWidgetMax(group, dataset, text) + + validator: DoubleValidator { + bottom: parseFloat(min.text) + } + } + + // + // Bar alarm level + // + Label { + text: qsTr("Alarm level:") + visible: root.alarmVisible + } TextField { + id: alarm + Layout.fillWidth: true + visible: root.alarmVisible + text: Cpp_Project_Model.datasetWidgetAlarm(group, dataset) + onTextChanged: Cpp_Project_Model.setDatasetWidgetAlarm(group, dataset, text) + + validator: DoubleValidator { + top: parseFloat(max.text) + bottom: parseFloat(min.text) + } + } + + // + // Vertical spacer + // + Item { + Layout.fillHeight: true + } Item { + Layout.fillHeight: true + } + + // + // Compass note label + // + Widgets.Icon { + width: 32 + height: 32 + color: palette.text + source: "qrc:/icons/compass.svg" + Layout.alignment: Qt.AlignHCenter + visible: widget.currentIndex === 3 + } Label { + font.pixelSize: 16 + Layout.fillWidth: true + wrapMode: Label.WordWrap + visible: widget.currentIndex === 3 + text: "" + qsTr("Note:") + " " + qsTr("The compass widget expects values from 0° to 360°.") + } + + // + // Vertical spacer + // + Item { + Layout.fillHeight: true + } Item { + Layout.fillHeight: true + } + } } diff --git a/assets/qml/ProjectEditor/JsonGroupDelegate.qml b/assets/qml/ProjectEditor/JsonGroupDelegate.qml index eae1b32a..093817ef 100644 --- a/assets/qml/ProjectEditor/JsonGroupDelegate.qml +++ b/assets/qml/ProjectEditor/JsonGroupDelegate.qml @@ -27,287 +27,287 @@ import QtQuick.Controls import "../Widgets" as Widgets Page { - id: root + id: root - // - // Page background - // - background: TextField { - enabled: false - palette.base: Cpp_ThemeManager.setupPanelBackground + // + // Page background + // + background: TextField { + enabled: false + palette.base: Cpp_ThemeManager.setupPanelBackground + } + + // + // Custom properties + // + property int group + readonly property int minSize: 320 + readonly property int maxSize: 380 + readonly property int cellHeight: 420 + readonly property int columns: Math.floor((grid.width - 2 * scroll.width) / cWidth) + readonly property int cellWidth: cWidth + ((grid.width - 2 * scroll.width) - (cWidth) * columns) / columns + readonly property int cWidth: Math.min(maxSize, Math.max(minSize, (grid.width - 2 * scroll.width) / grid.model)) + + // + // Connections with JSON editor + // + Connections { + target: Cpp_Project_Model + + function onGroupChanged(id) { + if (id === group) { + grid.model = 0 + grid.model = Cpp_Project_Model.datasetCount(group) + grid.positionViewAtIndex(grid.count - 1, GridView.Beginning) + } } + } + + // + // Main layout + // + ColumnLayout { + id: column + spacing: app.spacing + anchors.fill: parent + anchors.margins: app.spacing // - // Custom properties + // Notes rectangle // - property int group - readonly property int minSize: 320 - readonly property int maxSize: 380 - readonly property int cellHeight: 420 - readonly property int columns: Math.floor((grid.width - 2 * scroll.width) / cWidth) - readonly property int cellWidth: cWidth + ((grid.width - 2 * scroll.width) - (cWidth) * columns) / columns - readonly property int cWidth: Math.min(maxSize, Math.max(minSize, (grid.width - 2 * scroll.width) / grid.model)) + Rectangle { + id: notes + radius: 16 + Layout.fillWidth: true + color: Cpp_ThemeManager.highlight + Layout.minimumHeight: 32 + 2 * app.spacing + visible: widget.currentIndex === 1 || widget.currentIndex === 2 - // - // Connections with JSON editor - // - Connections { - target: Cpp_Project_Model - - function onGroupChanged(id) { - if (id === group) { - grid.model = 0 - grid.model = Cpp_Project_Model.datasetCount(group) - grid.positionViewAtIndex(grid.count - 1, GridView.Beginning) - } - } - } - - // - // Main layout - // - ColumnLayout { - id: column + RowLayout { spacing: app.spacing - anchors.fill: parent - anchors.margins: app.spacing + anchors.centerIn: parent + Layout.alignment: Qt.AlignHCenter + visible: widget.currentIndex === 1 - // - // Notes rectangle - // - Rectangle { - id: notes - radius: 16 - Layout.fillWidth: true - color: Cpp_ThemeManager.highlight - Layout.minimumHeight: 32 + 2 * app.spacing - visible: widget.currentIndex === 1 || widget.currentIndex === 2 - - RowLayout { - spacing: app.spacing - anchors.centerIn: parent - Layout.alignment: Qt.AlignHCenter - visible: widget.currentIndex === 1 - - Widgets.Icon { - width: 32 - height: 32 - color: palette.highlightedText - Layout.alignment: Qt.AlignHCenter - source: "qrc:/icons/accelerometer.svg" - } Label { - font.pixelSize: 18 - wrapMode: Label.WordWrap - color: palette.highlightedText - text: "" + qsTr("Note:") + " " + qsTr("The accelerometer widget expects values in m/s².") - } - } - - RowLayout { - spacing: app.spacing - anchors.centerIn: parent - Layout.alignment: Qt.AlignHCenter - visible: widget.currentIndex === 2 - - Widgets.Icon { - width: 32 - height: 32 - source: "qrc:/icons/gyro.svg" - color: palette.highlightedText - Layout.alignment: Qt.AlignHCenter - } Label { - font.pixelSize: 18 - wrapMode: Label.WordWrap - color: palette.highlightedText - text: "" + qsTr("Note:") + " " + qsTr("The gyroscope widget expects values in degrees (0° to 360°).") - } - } + Widgets.Icon { + width: 32 + height: 32 + color: palette.highlightedText + Layout.alignment: Qt.AlignHCenter + source: "qrc:/icons/accelerometer.svg" + } Label { + font.pixelSize: 18 + wrapMode: Label.WordWrap + color: palette.highlightedText + text: "" + qsTr("Note:") + " " + qsTr("The accelerometer widget expects values in m/s².") } + } - // - // Group title - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true + RowLayout { + spacing: app.spacing + anchors.centerIn: parent + Layout.alignment: Qt.AlignHCenter + visible: widget.currentIndex === 2 - Label { - text: qsTr("Title") + ":" - Layout.alignment: Qt.AlignVCenter - } - - TextField { - Layout.minimumWidth: 320 - placeholderText: qsTr("Title") - Layout.alignment: Qt.AlignVCenter - text: Cpp_Project_Model.groupTitle(group) - - onTextChanged: { - Cpp_Project_Model.setGroupTitle(group, text) - root.title = qsTr("Group %1 - %2").arg(group + 1).arg(Cpp_Project_Model.groupTitle(group)) - } - } - - Item { - Layout.fillWidth: true - } - - Label { - text: qsTr("Group widget") + ":" - Layout.alignment: Qt.AlignVCenter - } - - ComboBox { - id: widget - Layout.minimumWidth: 180 - Layout.alignment: Qt.AlignVCenter - model: Cpp_Project_Model.availableGroupLevelWidgets() - currentIndex: Cpp_Project_Model.groupWidgetIndex(group) - onCurrentIndexChanged: { - var prevIndex = Cpp_Project_Model.groupWidgetIndex(group) - if (currentIndex !== prevIndex) { - if (!Cpp_Project_Model.setGroupWidget(group, currentIndex)) - currentIndex = prevIndex - } - } - } - - RoundButton { - icon.width: 18 - icon.height: 18 - enabled: group > 0 - opacity: enabled ? 1 : 0.5 - icon.source: "qrc:/icons/up.svg" - Layout.alignment: Qt.AlignVCenter - icon.color: Cpp_ThemeManager.text - onClicked: Cpp_Project_Model.moveGroupUp(group) - } - - RoundButton { - icon.width: 18 - icon.height: 18 - opacity: enabled ? 1 : 0.5 - Layout.alignment: Qt.AlignVCenter - icon.color: Cpp_ThemeManager.text - icon.source: "qrc:/icons/down.svg" - enabled: group < Cpp_Project_Model.groupCount - 1 - onClicked: Cpp_Project_Model.moveGroupDown(group) - } - - RoundButton { - icon.width: 18 - icon.height: 18 - Layout.alignment: Qt.AlignVCenter - icon.color: Cpp_ThemeManager.text - icon.source: "qrc:/icons/delete-item.svg" - onClicked: Cpp_Project_Model.deleteGroup(group) - } - } - - // - // Datasets - // - Item { - clip: true - Layout.fillWidth: true - Layout.fillHeight: true - - // - // Background - // - TextField { - enabled: false - anchors.fill: parent - } - - // - // Empty group text & icon - // - ColumnLayout { - spacing: app.spacing - anchors.centerIn: parent - visible: grid.model === 0 - - Widgets.Icon { - width: 128 - height: 128 - color: Cpp_ThemeManager.text - source: "qrc:/icons/group.svg" - Layout.alignment: Qt.AlignHCenter - } - - Label { - font.bold: true - font.pixelSize: 24 - text: qsTr("Empty group") - Layout.alignment: Qt.AlignHCenter - } - - Label { - opacity: 0.8 - font.pixelSize: 18 - Layout.alignment: Qt.AlignHCenter - wrapMode: Label.WrapAtWordBoundaryOrAnywhere - Layout.maximumWidth: grid.width - 8 * app.spacing - text: qsTr("Set group title and click on the \"Add dataset\" button to begin") - } - } - - // - // Grid - // - GridView { - id: grid - clip: true - anchors.margins: 1 - anchors.fill: parent - cellWidth: root.cellWidth - cellHeight: root.cellHeight - model: Cpp_Project_Model.datasetCount(group) - - ScrollBar.vertical: ScrollBar { - id: scroll - policy: ScrollBar.AsNeeded - } - - delegate: Item { - width: grid.cellWidth - height: grid.cellHeight - - Loader { - id: loader - anchors.fill: parent - anchors.margins: app.spacing - - sourceComponent: JsonDatasetDelegate { - dataset: index - group: root.group - multiplotGroup: widget.currentIndex === 4 - showGroupWidget: widget.currentIndex > 0 && widget.currentIndex !== 4 - } - } - } - } - } - - // - // Add dataset button - // - Button { - icon.width: 24 - icon.height: 24 - Layout.fillWidth: true - text: qsTr("Add dataset") - icon.source: "qrc:/icons/add.svg" - icon.color: Cpp_ThemeManager.menubarText - palette.buttonText: Cpp_ThemeManager.menubarText - palette.button: Cpp_ThemeManager.toolbarGradient1 - palette.window: Cpp_ThemeManager.toolbarGradient1 - visible: widget.currentIndex === 0 || widget.currentIndex === 4 - onClicked: { - Cpp_Project_Model.addDataset(group) - grid.positionViewAtIndex(grid.count - 1, GridView.Beginning) - } + Widgets.Icon { + width: 32 + height: 32 + source: "qrc:/icons/gyro.svg" + color: palette.highlightedText + Layout.alignment: Qt.AlignHCenter + } Label { + font.pixelSize: 18 + wrapMode: Label.WordWrap + color: palette.highlightedText + text: "" + qsTr("Note:") + " " + qsTr("The gyroscope widget expects values in degrees (0° to 360°).") } + } } + + // + // Group title + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Label { + text: qsTr("Title") + ":" + Layout.alignment: Qt.AlignVCenter + } + + TextField { + Layout.minimumWidth: 320 + placeholderText: qsTr("Title") + Layout.alignment: Qt.AlignVCenter + text: Cpp_Project_Model.groupTitle(group) + + onTextChanged: { + Cpp_Project_Model.setGroupTitle(group, text) + root.title = qsTr("Group %1 - %2").arg(group + 1).arg(Cpp_Project_Model.groupTitle(group)) + } + } + + Item { + Layout.fillWidth: true + } + + Label { + text: qsTr("Group widget") + ":" + Layout.alignment: Qt.AlignVCenter + } + + ComboBox { + id: widget + Layout.minimumWidth: 180 + Layout.alignment: Qt.AlignVCenter + model: Cpp_Project_Model.availableGroupLevelWidgets() + currentIndex: Cpp_Project_Model.groupWidgetIndex(group) + onCurrentIndexChanged: { + var prevIndex = Cpp_Project_Model.groupWidgetIndex(group) + if (currentIndex !== prevIndex) { + if (!Cpp_Project_Model.setGroupWidget(group, currentIndex)) + currentIndex = prevIndex + } + } + } + + RoundButton { + icon.width: 18 + icon.height: 18 + enabled: group > 0 + opacity: enabled ? 1 : 0.5 + icon.source: "qrc:/icons/up.svg" + Layout.alignment: Qt.AlignVCenter + icon.color: Cpp_ThemeManager.text + onClicked: Cpp_Project_Model.moveGroupUp(group) + } + + RoundButton { + icon.width: 18 + icon.height: 18 + opacity: enabled ? 1 : 0.5 + Layout.alignment: Qt.AlignVCenter + icon.color: Cpp_ThemeManager.text + icon.source: "qrc:/icons/down.svg" + enabled: group < Cpp_Project_Model.groupCount - 1 + onClicked: Cpp_Project_Model.moveGroupDown(group) + } + + RoundButton { + icon.width: 18 + icon.height: 18 + Layout.alignment: Qt.AlignVCenter + icon.color: Cpp_ThemeManager.text + icon.source: "qrc:/icons/delete-item.svg" + onClicked: Cpp_Project_Model.deleteGroup(group) + } + } + + // + // Datasets + // + Item { + clip: true + Layout.fillWidth: true + Layout.fillHeight: true + + // + // Background + // + TextField { + enabled: false + anchors.fill: parent + } + + // + // Empty group text & icon + // + ColumnLayout { + spacing: app.spacing + anchors.centerIn: parent + visible: grid.model === 0 + + Widgets.Icon { + width: 128 + height: 128 + color: Cpp_ThemeManager.text + source: "qrc:/icons/group.svg" + Layout.alignment: Qt.AlignHCenter + } + + Label { + font.bold: true + font.pixelSize: 24 + text: qsTr("Empty group") + Layout.alignment: Qt.AlignHCenter + } + + Label { + opacity: 0.8 + font.pixelSize: 18 + Layout.alignment: Qt.AlignHCenter + wrapMode: Label.WrapAtWordBoundaryOrAnywhere + Layout.maximumWidth: grid.width - 8 * app.spacing + text: qsTr("Set group title and click on the \"Add dataset\" button to begin") + } + } + + // + // Grid + // + GridView { + id: grid + clip: true + anchors.margins: 1 + anchors.fill: parent + cellWidth: root.cellWidth + cellHeight: root.cellHeight + model: Cpp_Project_Model.datasetCount(group) + + ScrollBar.vertical: ScrollBar { + id: scroll + policy: ScrollBar.AsNeeded + } + + delegate: Item { + width: grid.cellWidth + height: grid.cellHeight + + Loader { + id: loader + anchors.fill: parent + anchors.margins: app.spacing + + sourceComponent: JsonDatasetDelegate { + dataset: index + group: root.group + multiplotGroup: widget.currentIndex === 4 + showGroupWidget: widget.currentIndex > 0 && widget.currentIndex !== 4 + } + } + } + } + } + + // + // Add dataset button + // + Button { + icon.width: 24 + icon.height: 24 + Layout.fillWidth: true + text: qsTr("Add dataset") + icon.source: "qrc:/icons/add.svg" + icon.color: Cpp_ThemeManager.menubarText + palette.buttonText: Cpp_ThemeManager.menubarText + palette.button: Cpp_ThemeManager.toolbarGradient1 + palette.window: Cpp_ThemeManager.toolbarGradient1 + visible: widget.currentIndex === 0 || widget.currentIndex === 4 + onClicked: { + Cpp_Project_Model.addDataset(group) + grid.positionViewAtIndex(grid.count - 1, GridView.Beginning) + } + } + } } diff --git a/assets/qml/ProjectEditor/TreeView.qml b/assets/qml/ProjectEditor/TreeView.qml index 5d2a84f6..0b647b8a 100644 --- a/assets/qml/ProjectEditor/TreeView.qml +++ b/assets/qml/ProjectEditor/TreeView.qml @@ -27,131 +27,131 @@ import QtQuick.Controls import "../Widgets" as Widgets Widgets.Window { - id: root + id: root - // - // Window properties - // - gradient: true - headerDoubleClickEnabled: false - title: qsTr("JSON Project Tree") - icon.source: "qrc:/icons/json.svg" + // + // Window properties + // + gradient: true + headerDoubleClickEnabled: false + title: qsTr("JSON Project Tree") + icon.source: "qrc:/icons/json.svg" - // - // Connections with JSON editor model - // - Connections { - target: Cpp_Project_Model + // + // Connections with JSON editor model + // + Connections { + target: Cpp_Project_Model - function onGroupCountChanged() { - view.model = 0 - view.model = Cpp_Project_Model.groupCount - } - - function onGroupOrderChanged() { - view.model = 0 - view.model = Cpp_Project_Model.groupCount - } - - function onDatasetChanged() { - view.model = 0 - view.model = Cpp_Project_Model.groupCount - } + function onGroupCountChanged() { + view.model = 0 + view.model = Cpp_Project_Model.groupCount } - // - // List view - // - ListView { - id: view - anchors.fill: parent - spacing: app.spacing * 2 - anchors.margins: app.spacing - model: Cpp_Project_Model.groupCount + function onGroupOrderChanged() { + view.model = 0 + view.model = Cpp_Project_Model.groupCount + } - delegate: Loader { - width: view.width - app.spacing * 2 - height: Cpp_Project_Model.datasetCount(index) * 24 + 24 + function onDatasetChanged() { + view.model = 0 + view.model = Cpp_Project_Model.groupCount + } + } - sourceComponent: ColumnLayout { - id: groupDelegate - spacing: app.spacing + // + // List view + // + ListView { + id: view + anchors.fill: parent + spacing: app.spacing * 2 + anchors.margins: app.spacing + model: Cpp_Project_Model.groupCount - readonly property var groupId: index + delegate: Loader { + width: view.width - app.spacing * 2 + height: Cpp_Project_Model.datasetCount(index) * 24 + 24 - RowLayout { - spacing: app.spacing - Layout.fillWidth: true + sourceComponent: ColumnLayout { + id: groupDelegate + spacing: app.spacing - Widgets.Icon { - width: 18 - height: 18 - color: Cpp_ThemeManager.text - source: "qrc:/icons/group.svg" - Layout.alignment: Qt.AlignVCenter - } + readonly property var groupId: index - Label { - font.bold: true - Layout.fillWidth: true - elide: Label.ElideRight - Layout.alignment: Qt.AlignVCenter - text: Cpp_Project_Model.groupTitle(groupDelegate.groupId) - } + RowLayout { + spacing: app.spacing + Layout.fillWidth: true - Label { - opacity: 0.5 - visible: text !== "[]" - font.family: app.monoFont - Layout.alignment: Qt.AlignVCenter - text: "[" + Cpp_Project_Model.groupWidget(groupDelegate.groupId) + "]" - } + Widgets.Icon { + width: 18 + height: 18 + color: Cpp_ThemeManager.text + source: "qrc:/icons/group.svg" + Layout.alignment: Qt.AlignVCenter + } + + Label { + font.bold: true + Layout.fillWidth: true + elide: Label.ElideRight + Layout.alignment: Qt.AlignVCenter + text: Cpp_Project_Model.groupTitle(groupDelegate.groupId) + } + + Label { + opacity: 0.5 + visible: text !== "[]" + font.family: app.monoFont + Layout.alignment: Qt.AlignVCenter + text: "[" + Cpp_Project_Model.groupWidget(groupDelegate.groupId) + "]" + } + } + + Repeater { + model: Cpp_Project_Model.datasetCount(groupDelegate.groupId) + + delegate: Loader { + Layout.fillWidth: true + sourceComponent: RowLayout { + spacing: app.spacing + + Item { + width: 2 * app.spacing + } + + Widgets.Icon { + width: 18 + height: 18 + color: Cpp_ThemeManager.text + source: "qrc:/icons/dataset.svg" + Layout.alignment: Qt.AlignVCenter + } + + Label { + id: label + Layout.fillWidth: true + elide: Label.ElideRight + Layout.alignment: Qt.AlignVCenter + text: Cpp_Project_Model.datasetTitle(groupDelegate.groupId, index) + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor } + } - Repeater { - model: Cpp_Project_Model.datasetCount(groupDelegate.groupId) - - delegate: Loader { - Layout.fillWidth: true - sourceComponent: RowLayout { - spacing: app.spacing - - Item { - width: 2 * app.spacing - } - - Widgets.Icon { - width: 18 - height: 18 - color: Cpp_ThemeManager.text - source: "qrc:/icons/dataset.svg" - Layout.alignment: Qt.AlignVCenter - } - - Label { - id: label - Layout.fillWidth: true - elide: Label.ElideRight - Layout.alignment: Qt.AlignVCenter - text: Cpp_Project_Model.datasetTitle(groupDelegate.groupId, index) - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - } - } - - Label { - opacity: 0.5 - visible: text !== "[]" - font.family: app.monoFont - Layout.alignment: Qt.AlignVCenter - text: "[" + Cpp_Project_Model.datasetWidget(groupDelegate.groupId, index) + "]" - } - } - } - } + Label { + opacity: 0.5 + visible: text !== "[]" + font.family: app.monoFont + Layout.alignment: Qt.AlignVCenter + text: "[" + Cpp_Project_Model.datasetWidget(groupDelegate.groupId, index) + "]" + } } + } } + } } + } } diff --git a/assets/qml/Widgets/GpsMap.qml b/assets/qml/Widgets/GpsMap.qml index f15a99d2..217fbac7 100644 --- a/assets/qml/Widgets/GpsMap.qml +++ b/assets/qml/Widgets/GpsMap.qml @@ -28,222 +28,222 @@ import QtQuick.Layouts import QtQuick.Controls Item { - id: root + id: root - // - // Custom properties to control the map from other QML files - // - property real latitude: 0 - property real longitude: 0 - property real altitude: 0 // Not used yet :( - onLatitudeChanged: { - if (autoCenter.checked) - centerMap() - } + // + // Custom properties to control the map from other QML files + // + property real latitude: 0 + property real longitude: 0 + property real altitude: 0 // Not used yet :( + onLatitudeChanged: { + if (autoCenter.checked) + centerMap() + } - onLongitudeChanged: { - if (autoCenter.checked) - centerMap() + onLongitudeChanged: { + if (autoCenter.checked) + centerMap() + } + + // + // Centers the map to the current coordinates + // + function centerMap() { + map.center = QtPositioning.coordinate(root.latitude, root.longitude) + } + + // + // Save settings accross runs + // + Settings { + property alias mapTilt: tiltSlider.value + property alias mapZoom: zoomSlider.value + property alias mapCenter: autoCenter.checked + property alias mapVariant: mapType.currentIndex + } + + // + // UI controls + // + ColumnLayout { + spacing: app.spacing + anchors.fill: parent + anchors.margins: app.spacing + + RowLayout { + spacing: app.spacing + + Label { + text: qsTr("Map Type:") + Layout.alignment: Qt.AlignVCenter + } + + ComboBox { + id: mapType + Layout.fillWidth: true + textRole: "description" + model: map.supportedMapTypes + Layout.alignment: Qt.AlignVCenter + onCurrentIndexChanged: map.activeMapType = map.supportedMapTypes[currentIndex] + } } // - // Centers the map to the current coordinates + // Center map + zoom slider // - function centerMap() { - map.center = QtPositioning.coordinate(root.latitude, root.longitude) + RowLayout { + CheckBox { + id: autoCenter + checked: true + checkable: true + Layout.leftMargin: -6 + Layout.alignment: Qt.AlignHCenter + text: qsTr("Center on coordinate") + onCheckedChanged: { + if (checked) + root.centerMap() + } + } + + Slider { + id: zoomSlider + value: map.zoomLevel + Layout.fillWidth: true + to: map.maximumZoomLevel + from: map.minimumZoomLevel + Layout.alignment: Qt.AlignHCenter + onValueChanged: { + if (map.zoomLevel !== value) + map.zoomLevel = value + } + } } // - // Save settings accross runs + // Map // - Settings { - property alias mapTilt: tiltSlider.value - property alias mapZoom: zoomSlider.value - property alias mapCenter: autoCenter.checked - property alias mapVariant: mapType.currentIndex - } + RowLayout { + // + // Tilt slider + // + Slider { + id: tiltSlider + orientation: Qt.Vertical + Layout.fillHeight: true + from: map.minimumTilt + to: map.maximumTilt + value: map.tilt + onValueChanged: { + if (map.tilt != value) + map.tilt = value + } + } - // - // UI controls - // - ColumnLayout { - spacing: app.spacing - anchors.fill: parent - anchors.margins: app.spacing + // + // Map + // + Rectangle { + id: mapRect + clip: true + Layout.fillWidth: true + Layout.fillHeight: true - RowLayout { - spacing: app.spacing - - Label { - text: qsTr("Map Type:") - Layout.alignment: Qt.AlignVCenter - } - - ComboBox { - id: mapType - Layout.fillWidth: true - textRole: "description" - model: map.supportedMapTypes - Layout.alignment: Qt.AlignVCenter - onCurrentIndexChanged: map.activeMapType = map.supportedMapTypes[currentIndex] - } + border { + width: 2 + color: Cpp_ThemeManager.border } - // - // Center map + zoom slider - // - RowLayout { - CheckBox { - id: autoCenter - checked: true - checkable: true - Layout.leftMargin: -6 - Layout.alignment: Qt.AlignHCenter - text: qsTr("Center on coordinate") - onCheckedChanged: { - if (checked) - root.centerMap() - } - } + gradient: Gradient { + GradientStop { + color: "#6ba9d1" + position: Math.max(0.4, + (map.maximumTilt - map.tilt) / + map.maximumTilt) + } - Slider { - id: zoomSlider - value: map.zoomLevel - Layout.fillWidth: true - to: map.maximumZoomLevel - from: map.minimumZoomLevel - Layout.alignment: Qt.AlignHCenter - onValueChanged: { - if (map.zoomLevel !== value) - map.zoomLevel = value - } - } + GradientStop { + position: 0 + color: "#283e51" + } } - // - // Map - // - RowLayout { - // - // Tilt slider - // - Slider { - id: tiltSlider - orientation: Qt.Vertical - Layout.fillHeight: true - from: map.minimumTilt - to: map.maximumTilt - value: map.tilt - onValueChanged: { - if (map.tilt != value) - map.tilt = value - } + Map { + id: map + smooth: true + antialiasing: true + color: "transparent" + anchors.fill: parent + copyrightsVisible: false + anchors.margins: parent.border.width + + tilt: 27 + zoomLevel: 16 + + MapQuickItem { + anchorPoint: Qt.point(sourceItem.width / 2, + sourceItem.height/ 2) + coordinate: QtPositioning.coordinate(root.latitude, + root.longitude) + + sourceItem: Rectangle { + id: dot + width: 20 + height: 20 + opacity: 0.8 + border.width: 2 + radius: width / 2 + color: "#ff0000" + border.color: "#ffffff" } + } - // - // Map - // - Rectangle { - id: mapRect - clip: true - Layout.fillWidth: true - Layout.fillHeight: true + plugin: Plugin { + preferred: "osm" - border { - width: 2 - color: Cpp_ThemeManager.border - } - - gradient: Gradient { - GradientStop { - color: "#6ba9d1" - position: Math.max(0.4, - (map.maximumTilt - map.tilt) / - map.maximumTilt) - } - - GradientStop { - position: 0 - color: "#283e51" - } - } - - Map { - id: map - smooth: true - antialiasing: true - color: "transparent" - anchors.fill: parent - copyrightsVisible: false - anchors.margins: parent.border.width - - tilt: 27 - zoomLevel: 16 - - MapQuickItem { - anchorPoint: Qt.point(sourceItem.width / 2, - sourceItem.height/ 2) - coordinate: QtPositioning.coordinate(root.latitude, - root.longitude) - - sourceItem: Rectangle { - id: dot - width: 20 - height: 20 - opacity: 0.8 - border.width: 2 - radius: width / 2 - color: "#ff0000" - border.color: "#ffffff" - } - } - - plugin: Plugin { - preferred: "osm" - - PluginParameter { - name: "osm.mapping.highdpi_tiles" - value: true - } - } - } - - Rectangle { - id: smog - height: 32 - opacity: 0.5 - - Connections { - target: map - function onTiltChanged() { - var x = map.tilt / map.maximumTilt - smog.y = (1.666 * x - 1.416) * mapRect.height - } - } - - gradient: Gradient { - GradientStop { - position: 0 - color: "transparent" - } - - GradientStop { - position: 0.5 - color: "#dedede" - } - - GradientStop { - position: 1 - color: "transparent" - } - } - - anchors { - left: parent.left - right: parent.right - } - } + PluginParameter { + name: "osm.mapping.highdpi_tiles" + value: true } + } } + + Rectangle { + id: smog + height: 32 + opacity: 0.5 + + Connections { + target: map + function onTiltChanged() { + var x = map.tilt / map.maximumTilt + smog.y = (1.666 * x - 1.416) * mapRect.height + } + } + + gradient: Gradient { + GradientStop { + position: 0 + color: "transparent" + } + + GradientStop { + position: 0.5 + color: "#dedede" + } + + GradientStop { + position: 1 + color: "transparent" + } + } + + anchors { + left: parent.left + right: parent.right + } + } + } } + } } diff --git a/assets/qml/Widgets/Icon.qml b/assets/qml/Widgets/Icon.qml index 8ab99fb9..65bba86b 100644 --- a/assets/qml/Widgets/Icon.qml +++ b/assets/qml/Widgets/Icon.qml @@ -24,28 +24,28 @@ import QtQuick import QtQuick.Controls Item { - id: root + id: root - property string source: "" - property alias icon: button.icon - property color color: Cpp_ThemeManager.menubarText + property string source: "" + property alias icon: button.icon + property color color: Cpp_ThemeManager.menubarText - width: 24 - height: 24 + width: 24 + height: 24 - ToolButton { - id: button - enabled: false - background: Item {} - icon.color: root.color - icon.width: root.width - icon.height: root.width - icon.source: root.source - anchors.centerIn: parent - } + ToolButton { + id: button + enabled: false + background: Item {} + icon.color: root.color + icon.width: root.width + icon.height: root.width + icon.source: root.source + anchors.centerIn: parent + } - MouseArea { - anchors.fill: parent - propagateComposedEvents: true - } + MouseArea { + anchors.fill: parent + propagateComposedEvents: true + } } diff --git a/assets/qml/Widgets/JSONDropArea.qml b/assets/qml/Widgets/JSONDropArea.qml index e72e445f..bf6d185e 100644 --- a/assets/qml/Widgets/JSONDropArea.qml +++ b/assets/qml/Widgets/JSONDropArea.qml @@ -25,110 +25,110 @@ import QtQuick.Layouts import QtQuick.Controls DropArea { - // - // Show rectangle and set color based on file extension on drag enter - // - onEntered: { - // Get file name & set color of rectangle accordingly - if (drag.urls.length > 0) { - var path = drag.urls[0].toString() - if (path.endsWith(".json") || path.endsWith(".csv")) { - drag.accept(Qt.LinkAction) - dropRectangle.color = Qt.darker(palette.highlight, 1.4) - } + // + // Show rectangle and set color based on file extension on drag enter + // + onEntered: { + // Get file name & set color of rectangle accordingly + if (drag.urls.length > 0) { + var path = drag.urls[0].toString() + if (path.endsWith(".json") || path.endsWith(".csv")) { + drag.accept(Qt.LinkAction) + dropRectangle.color = Qt.darker(palette.highlight, 1.4) + } - // Invalid file name, show red rectangle - else - dropRectangle.color = Cpp_ThemeManager.alternativeHighlight + // Invalid file name, show red rectangle + else + dropRectangle.color = Cpp_ThemeManager.alternativeHighlight - // Show drag&drop rectangle - dropRectangle.opacity = 0.8 - } + // Show drag&drop rectangle + dropRectangle.opacity = 0.8 + } + } + + // + // Open *.json & *.csv files on drag drop + // + onDropped: { + // Hide rectangle + dropRectangle.hide() + + // Get dropped file URL and remove prefixed "file://" + var path = drop.urls[0].toString() + if (!Cpp_IsWin) + path = path.replace(/^(file:\/{2})/,""); + else + path = path.replace(/^(file:\/{3})/,""); + + // Unescape html codes like '%23' for '#' + var cleanPath = decodeURIComponent(path); + + // Process JSON files + if (cleanPath.endsWith(".json")) { + Cpp_JSON_Generator.setOperationMode(0) + Cpp_JSON_Generator.loadJsonMap(cleanPath) } - // - // Open *.json & *.csv files on drag drop - // - onDropped: { - // Hide rectangle - dropRectangle.hide() + // Process CSV files + else if (cleanPath.endsWith(".csv")) + Cpp_CSV_Player.openFile(cleanPath) + } - // Get dropped file URL and remove prefixed "file://" - var path = drop.urls[0].toString() - if (!Cpp_IsWin) - path = path.replace(/^(file:\/{2})/,""); - else - path = path.replace(/^(file:\/{3})/,""); + // + // Hide drag & drop rectangle on drag exit + // + onExited: { + dropRectangle.hide() + } - // Unescape html codes like '%23' for '#' - var cleanPath = decodeURIComponent(path); + // + // Drop rectangle + icon + text + // + Rectangle { + id: dropRectangle - // Process JSON files - if (cleanPath.endsWith(".json")) { - Cpp_JSON_Generator.setOperationMode(0) - Cpp_JSON_Generator.loadJsonMap(cleanPath) - } - - // Process CSV files - else if (cleanPath.endsWith(".csv")) - Cpp_CSV_Player.openFile(cleanPath) + function hide() { + rectTimer.start() } - // - // Hide drag & drop rectangle on drag exit - // - onExited: { - dropRectangle.hide() + opacity: 0 + border.width: 1 + anchors.centerIn: parent + color: Cpp_ThemeManager.highlight + border.color: Cpp_ThemeManager.text + width: dropLayout.implicitWidth + 6 * app.spacing + height: dropLayout.implicitHeight + 6 * app.spacing + + ColumnLayout { + id: dropLayout + spacing: app.spacing * 2 + anchors.centerIn: parent + + ToolButton { + flat: true + enabled: false + icon.width: 128 + icon.height: 128 + Layout.alignment: Qt.AlignHCenter + icon.source: "qrc:/icons/drag-drop.svg" + icon.color: Cpp_ThemeManager.highlightedText + } + + Label { + font.bold: true + font.pixelSize: 24 + Layout.alignment: Qt.AlignHCenter + color: Cpp_ThemeManager.highlightedText + text: qsTr("Drop JSON and CSV files here") + } } - // - // Drop rectangle + icon + text - // - Rectangle { - id: dropRectangle - - function hide() { - rectTimer.start() - } - - opacity: 0 - border.width: 1 - anchors.centerIn: parent - color: Cpp_ThemeManager.highlight - border.color: Cpp_ThemeManager.text - width: dropLayout.implicitWidth + 6 * app.spacing - height: dropLayout.implicitHeight + 6 * app.spacing - - ColumnLayout { - id: dropLayout - spacing: app.spacing * 2 - anchors.centerIn: parent - - ToolButton { - flat: true - enabled: false - icon.width: 128 - icon.height: 128 - Layout.alignment: Qt.AlignHCenter - icon.source: "qrc:/icons/drag-drop.svg" - icon.color: Cpp_ThemeManager.highlightedText - } - - Label { - font.bold: true - font.pixelSize: 24 - Layout.alignment: Qt.AlignHCenter - color: Cpp_ThemeManager.highlightedText - text: qsTr("Drop JSON and CSV files here") - } - } - - Timer { - id: rectTimer - interval: 200 - onTriggered: dropRectangle.opacity = 0 - } - - Behavior on opacity {NumberAnimation{}} + Timer { + id: rectTimer + interval: 200 + onTriggered: dropRectangle.opacity = 0 } + + Behavior on opacity {NumberAnimation{}} + } } diff --git a/assets/qml/Widgets/Shadow.qml b/assets/qml/Widgets/Shadow.qml index 864e419d..e49113e6 100644 --- a/assets/qml/Widgets/Shadow.qml +++ b/assets/qml/Widgets/Shadow.qml @@ -23,37 +23,37 @@ import QtQuick Item { - id: root - property real topMargin: -8 - property real leftMargin: -8 - property real rightMargin: -10 - property real bottomMargin: -10 - property alias border: borderImage.border - property alias source: borderImage.source - property alias shadowOpacity: borderImage.opacity + id: root + property real topMargin: -8 + property real leftMargin: -8 + property real rightMargin: -10 + property real bottomMargin: -10 + property alias border: borderImage.border + property alias source: borderImage.source + property alias shadowOpacity: borderImage.opacity - BorderImage { - id: borderImage + BorderImage { + id: borderImage - opacity: 0.5 - smooth: true - anchors.fill: parent - source: "qrc:/images/shadow.png" - verticalTileMode: BorderImage.Round - horizontalTileMode: BorderImage.Round + opacity: 0.5 + smooth: true + anchors.fill: parent + source: "qrc:/images/shadow.png" + verticalTileMode: BorderImage.Round + horizontalTileMode: BorderImage.Round - anchors { - topMargin: root.topMargin - leftMargin: root.leftMargin - rightMargin: root.rightMargin - bottomMargin: root.bottomMargin - } - - border { - left: 10 - top: 10 - right: 10 - bottom: 10 - } + anchors { + topMargin: root.topMargin + leftMargin: root.leftMargin + rightMargin: root.rightMargin + bottomMargin: root.bottomMargin } + + border { + left: 10 + top: 10 + right: 10 + bottom: 10 + } + } } diff --git a/assets/qml/Widgets/Terminal.qml b/assets/qml/Widgets/Terminal.qml index 00cb1373..4ebe8865 100644 --- a/assets/qml/Widgets/Terminal.qml +++ b/assets/qml/Widgets/Terminal.qml @@ -27,297 +27,297 @@ import QtQuick.Controls import SerialStudio as SerialStudio Item { - id: root - property bool isExternalWindow: false - property alias widgetEnabled: textEdit.widgetEnabled - property alias vt100emulation: textEdit.vt100emulation + id: root + property bool isExternalWindow: false + property alias widgetEnabled: textEdit.widgetEnabled + property alias vt100emulation: textEdit.vt100emulation - // - // Save settings - // - Settings { - property alias hex: hexCheckbox.checked - property alias echo: echoCheckbox.checked - property alias timestamp: timestampCheck.checked - property alias autoscroll: autoscrollCheck.checked - property alias vt100Enabled: textEdit.vt100emulation - property alias lineEnding: lineEndingCombo.currentIndex - property alias displayMode: displayModeCombo.currentIndex + // + // Save settings + // + Settings { + property alias hex: hexCheckbox.checked + property alias echo: echoCheckbox.checked + property alias timestamp: timestampCheck.checked + property alias autoscroll: autoscrollCheck.checked + property alias vt100Enabled: textEdit.vt100emulation + property alias lineEnding: lineEndingCombo.currentIndex + property alias displayMode: displayModeCombo.currentIndex + } + + // + // Function to send through serial port data + // + function sendData() { + Cpp_IO_Console.send(send.text) + send.clear() + } + + // + // Clears console output + // + function clear() { + Cpp_IO_Console.clear() + textEdit.clear() + } + + // + // Copy function + // + function copy() { + textEdit.copy() + } + + // + // Select all text + // + function selectAll() { + textEdit.selectAll() + } + + // + // Right-click context menu + // + Menu { + id: contextMenu + + MenuItem { + id: copyMenu + text: qsTr("Copy") + opacity: enabled ? 1 : 0.5 + onClicked: textEdit.copy() + enabled: textEdit.copyAvailable } - // - // Function to send through serial port data - // - function sendData() { - Cpp_IO_Console.send(send.text) - send.clear() + MenuItem { + text: qsTr("Select all") + enabled: !textEdit.empty + opacity: enabled ? 1 : 0.5 + onTriggered: textEdit.selectAll() } - // - // Clears console output - // - function clear() { - Cpp_IO_Console.clear() - textEdit.clear() + MenuItem { + text: qsTr("Clear") + opacity: enabled ? 1 : 0.5 + onTriggered: root.clear() + enabled: Cpp_IO_Console.saveAvailable } - // - // Copy function - // - function copy() { - textEdit.copy() + MenuSeparator {} + + MenuItem { + opacity: enabled ? 1 : 0.5 + text: qsTr("Print") + enabled: Cpp_IO_Console.saveAvailable + onTriggered: Cpp_IO_Console.print(app.monoFont) } - // - // Select all text - // - function selectAll() { - textEdit.selectAll() + MenuItem { + opacity: enabled ? 1 : 0.5 + text: qsTr("Save as") + "..." + onTriggered: Cpp_IO_Console.save() + enabled: Cpp_IO_Console.saveAvailable } + } + + // + // Controls + // + ColumnLayout { + anchors.fill: parent + spacing: app.spacing + anchors.margins: app.spacing * 1.5 // - // Right-click context menu + // Console display // - Menu { - id: contextMenu + SerialStudio.Terminal { + id: textEdit + focus: true + readOnly: true + font.pixelSize: 12 + vt100emulation: true + centerOnScroll: false + undoRedoEnabled: false + Layout.fillWidth: true + Layout.fillHeight: true + maximumBlockCount: 12000 + font.family: app.monoFont + autoscroll: Cpp_IO_Console.autoscroll + renderTarget: PaintedItem.FramebufferObject + wordWrapMode: Text.WrapAtWordBoundaryOrAnywhere + placeholderText: qsTr("No data received so far") + "..." - MenuItem { - id: copyMenu - text: qsTr("Copy") - opacity: enabled ? 1 : 0.5 - onClicked: textEdit.copy() - enabled: textEdit.copyAvailable - } - - MenuItem { - text: qsTr("Select all") - enabled: !textEdit.empty - opacity: enabled ? 1 : 0.5 - onTriggered: textEdit.selectAll() - } - - MenuItem { - text: qsTr("Clear") - opacity: enabled ? 1 : 0.5 - onTriggered: root.clear() - enabled: Cpp_IO_Console.saveAvailable - } - - MenuSeparator {} - - MenuItem { - opacity: enabled ? 1 : 0.5 - text: qsTr("Print") - enabled: Cpp_IO_Console.saveAvailable - onTriggered: Cpp_IO_Console.print(app.monoFont) - } - - MenuItem { - opacity: enabled ? 1 : 0.5 - text: qsTr("Save as") + "..." - onTriggered: Cpp_IO_Console.save() - enabled: Cpp_IO_Console.saveAvailable - } - } - - // - // Controls - // - ColumnLayout { + MouseArea { + id: mouseArea anchors.fill: parent - spacing: app.spacing - anchors.margins: app.spacing * 1.5 + cursorShape: Qt.IBeamCursor + propagateComposedEvents: true + acceptedButtons: Qt.RightButton + anchors.rightMargin: textEdit.scrollbarWidth - // - // Console display - // - SerialStudio.Terminal { - id: textEdit - focus: true - readOnly: true - font.pixelSize: 12 - vt100emulation: true - centerOnScroll: false - undoRedoEnabled: false - Layout.fillWidth: true - Layout.fillHeight: true - maximumBlockCount: 12000 - font.family: app.monoFont - autoscroll: Cpp_IO_Console.autoscroll - renderTarget: PaintedItem.FramebufferObject - wordWrapMode: Text.WrapAtWordBoundaryOrAnywhere - placeholderText: qsTr("No data received so far") + "..." - - MouseArea { - id: mouseArea - anchors.fill: parent - cursorShape: Qt.IBeamCursor - propagateComposedEvents: true - acceptedButtons: Qt.RightButton - anchors.rightMargin: textEdit.scrollbarWidth - - onClicked: (mouse) => { - if (mouse.button === Qt.RightButton) { - contextMenu.popup() - mouse.accepted = true - } - } - } - } - - // - // Data-write controls - // - RowLayout { - Layout.fillWidth: true - - TextField { - id: send - height: 24 - font: textEdit.font - Layout.fillWidth: true - enabled: Cpp_IO_Manager.readWrite - palette.text: Cpp_ThemeManager.consoleText - palette.base: Cpp_ThemeManager.consoleBase - placeholderText: qsTr("Send data to device") + "..." - Component.onCompleted: { - if (Cpp_Qt6) - placeholderTextColor = Cpp_ThemeManager.consolePlaceholderText - } - - // - // Validate hex strings - // - //validator: RegExpValidator { - // regExp: hexCheckbox.checked ? /^(?:([a-f0-9]{2})\s*)+$/i : /[\s\S]*/ - //} - - // - // Send data on - // - Keys.onReturnPressed: root.sendData() - - // - // Add space automatically in hex view - // - onTextChanged: { - if (hexCheckbox.checked) - send.text = Cpp_IO_Console.formatUserHex(send.text) - } - - // - // Navigate command history upwards with - // - Keys.onUpPressed: { - Cpp_IO_Console.historyUp() - send.text = Cpp_IO_Console.currentHistoryString - } - - // - // Navigate command history downwards with - // - Keys.onDownPressed: { - Cpp_IO_Console.historyDown() - send.text = Cpp_IO_Console.currentHistoryString - } - } - - CheckBox { - text: "HEX" - id: hexCheckbox - opacity: enabled ? 1 : 0.5 - enabled: Cpp_IO_Manager.readWrite - checked: Cpp_IO_Console.dataMode === 1 - onCheckedChanged: Cpp_IO_Console.dataMode = checked ? 1 : 0 - } - - CheckBox { - visible: false - text: qsTr("Echo") - id: echoCheckbox - opacity: enabled ? 1 : 0.5 - checked: Cpp_IO_Console.echo - enabled: Cpp_IO_Manager.readWrite - onCheckedChanged: { - if (Cpp_IO_Console.echo !== checked) - Cpp_IO_Console.echo = checked - } - } - } - - // - // Terminal output options - // - RowLayout { - Layout.fillWidth: true - - CheckBox { - id: autoscrollCheck - text: qsTr("Autoscroll") - Layout.alignment: Qt.AlignVCenter - checked: Cpp_IO_Console.autoscroll - onCheckedChanged: { - if (Cpp_IO_Console.autoscroll !== checked) - Cpp_IO_Console.autoscroll = checked - } - } - - CheckBox { - id: timestampCheck - text: qsTr("Show timestamp") - Layout.alignment: Qt.AlignVCenter - checked: Cpp_IO_Console.showTimestamp - onCheckedChanged: { - if (Cpp_IO_Console.showTimestamp !== checked) - Cpp_IO_Console.showTimestamp = checked - } - } - - Item { - Layout.fillWidth: true - } - - ComboBox { - id: lineEndingCombo - Layout.alignment: Qt.AlignVCenter - model: Cpp_IO_Console.lineEndings() - currentIndex: Cpp_IO_Console.lineEnding - onCurrentIndexChanged: { - if (currentIndex !== Cpp_IO_Console.lineEnding) - Cpp_IO_Console.lineEnding = currentIndex - } - } - - ComboBox { - id: displayModeCombo - Layout.alignment: Qt.AlignVCenter - model: Cpp_IO_Console.displayModes() - currentIndex: Cpp_IO_Console.displayMode - onCurrentIndexChanged: { - if (currentIndex !== Cpp_IO_Console.displayMode) - Cpp_IO_Console.displayMode = currentIndex - } - } - - Button { - height: 24 - Layout.maximumWidth: 32 - icon.color: palette.text - opacity: enabled ? 1 : 0.5 - onClicked: Cpp_IO_Console.save() - icon.source: "qrc:/icons/save.svg" - enabled: Cpp_IO_Console.saveAvailable - } - - Button { - height: 24 - Layout.maximumWidth: 32 - icon.color: palette.text - opacity: enabled ? 1 : 0.5 - onClicked: root.clear() - icon.source: "qrc:/icons/delete.svg" - enabled: Cpp_IO_Console.saveAvailable - } - } + onClicked: (mouse) => { + if (mouse.button === Qt.RightButton) { + contextMenu.popup() + mouse.accepted = true + } + } + } } + + // + // Data-write controls + // + RowLayout { + Layout.fillWidth: true + + TextField { + id: send + height: 24 + font: textEdit.font + Layout.fillWidth: true + enabled: Cpp_IO_Manager.readWrite + palette.text: Cpp_ThemeManager.consoleText + palette.base: Cpp_ThemeManager.consoleBase + placeholderText: qsTr("Send data to device") + "..." + Component.onCompleted: { + if (Cpp_Qt6) + placeholderTextColor = Cpp_ThemeManager.consolePlaceholderText + } + + // + // Validate hex strings + // + //validator: RegExpValidator { + // regExp: hexCheckbox.checked ? /^(?:([a-f0-9]{2})\s*)+$/i : /[\s\S]*/ + //} + + // + // Send data on + // + Keys.onReturnPressed: root.sendData() + + // + // Add space automatically in hex view + // + onTextChanged: { + if (hexCheckbox.checked) + send.text = Cpp_IO_Console.formatUserHex(send.text) + } + + // + // Navigate command history upwards with + // + Keys.onUpPressed: { + Cpp_IO_Console.historyUp() + send.text = Cpp_IO_Console.currentHistoryString + } + + // + // Navigate command history downwards with + // + Keys.onDownPressed: { + Cpp_IO_Console.historyDown() + send.text = Cpp_IO_Console.currentHistoryString + } + } + + CheckBox { + text: "HEX" + id: hexCheckbox + opacity: enabled ? 1 : 0.5 + enabled: Cpp_IO_Manager.readWrite + checked: Cpp_IO_Console.dataMode === 1 + onCheckedChanged: Cpp_IO_Console.dataMode = checked ? 1 : 0 + } + + CheckBox { + visible: false + text: qsTr("Echo") + id: echoCheckbox + opacity: enabled ? 1 : 0.5 + checked: Cpp_IO_Console.echo + enabled: Cpp_IO_Manager.readWrite + onCheckedChanged: { + if (Cpp_IO_Console.echo !== checked) + Cpp_IO_Console.echo = checked + } + } + } + + // + // Terminal output options + // + RowLayout { + Layout.fillWidth: true + + CheckBox { + id: autoscrollCheck + text: qsTr("Autoscroll") + Layout.alignment: Qt.AlignVCenter + checked: Cpp_IO_Console.autoscroll + onCheckedChanged: { + if (Cpp_IO_Console.autoscroll !== checked) + Cpp_IO_Console.autoscroll = checked + } + } + + CheckBox { + id: timestampCheck + text: qsTr("Show timestamp") + Layout.alignment: Qt.AlignVCenter + checked: Cpp_IO_Console.showTimestamp + onCheckedChanged: { + if (Cpp_IO_Console.showTimestamp !== checked) + Cpp_IO_Console.showTimestamp = checked + } + } + + Item { + Layout.fillWidth: true + } + + ComboBox { + id: lineEndingCombo + Layout.alignment: Qt.AlignVCenter + model: Cpp_IO_Console.lineEndings() + currentIndex: Cpp_IO_Console.lineEnding + onCurrentIndexChanged: { + if (currentIndex !== Cpp_IO_Console.lineEnding) + Cpp_IO_Console.lineEnding = currentIndex + } + } + + ComboBox { + id: displayModeCombo + Layout.alignment: Qt.AlignVCenter + model: Cpp_IO_Console.displayModes() + currentIndex: Cpp_IO_Console.displayMode + onCurrentIndexChanged: { + if (currentIndex !== Cpp_IO_Console.displayMode) + Cpp_IO_Console.displayMode = currentIndex + } + } + + Button { + height: 24 + Layout.maximumWidth: 32 + icon.color: palette.text + opacity: enabled ? 1 : 0.5 + onClicked: Cpp_IO_Console.save() + icon.source: "qrc:/icons/save.svg" + enabled: Cpp_IO_Console.saveAvailable + } + + Button { + height: 24 + Layout.maximumWidth: 32 + icon.color: palette.text + opacity: enabled ? 1 : 0.5 + onClicked: root.clear() + icon.source: "qrc:/icons/delete.svg" + enabled: Cpp_IO_Console.saveAvailable + } + } + } } diff --git a/assets/qml/Widgets/Window.qml b/assets/qml/Widgets/Window.qml index 475e5d7b..0a51b65f 100644 --- a/assets/qml/Widgets/Window.qml +++ b/assets/qml/Widgets/Window.qml @@ -25,165 +25,165 @@ import QtQuick.Layouts import QtQuick.Controls Page { - id: root - clip: true + id: root + clip: true - // - // Custom properties - // - property int borderWidth: 3 - property alias icon: _bt.icon - property bool gradient: false - property int headerHeight: 32 - property bool headerVisible: true - property alias showIcon: _bt.visible - property int radius: root.borderWidth + 2 - property color titleColor: palette.brightText - property color borderColor: palette.highlight - property bool altButtonEnabled: false - property alias altButtonIcon: altBt.icon - property alias headerDoubleClickEnabled: headerMouseArea.enabled - property color backgroundColor: Cpp_ThemeManager.widgetWindowBackground - property color gradientColor1: root.gradient ? Cpp_ThemeManager.windowGradient1 : - root.borderColor - property color gradientColor2: root.gradient ? Cpp_ThemeManager.windowGradient2 : - root.borderColor + // + // Custom properties + // + property int borderWidth: 3 + property alias icon: _bt.icon + property bool gradient: false + property int headerHeight: 32 + property bool headerVisible: true + property alias showIcon: _bt.visible + property int radius: root.borderWidth + 2 + property color titleColor: palette.brightText + property color borderColor: palette.highlight + property bool altButtonEnabled: false + property alias altButtonIcon: altBt.icon + property alias headerDoubleClickEnabled: headerMouseArea.enabled + property color backgroundColor: Cpp_ThemeManager.widgetWindowBackground + property color gradientColor1: root.gradient ? Cpp_ThemeManager.windowGradient1 : + root.borderColor + property color gradientColor2: root.gradient ? Cpp_ThemeManager.windowGradient2 : + root.borderColor - // - // Signals - // - signal altButtonClicked() - signal headerDoubleClicked() + // + // Signals + // + signal altButtonClicked() + signal headerDoubleClicked() - // - // Layout properties - // - visible: opacity > 0 - Layout.preferredWidth: enabled ? implicitWidth : 0 - Layout.preferredHeight: enabled ? implicitHeight : 0 + // + // Layout properties + // + visible: opacity > 0 + Layout.preferredWidth: enabled ? implicitWidth : 0 + Layout.preferredHeight: enabled ? implicitHeight : 0 - // - // Background widget - // - background: Rectangle { - radius: root.radius - color: root.backgroundColor - border.width: root.borderWidth - border.color: root.gradientColor1 + // + // Background widget + // + background: Rectangle { + radius: root.radius + color: root.backgroundColor + border.width: root.borderWidth + border.color: root.gradientColor1 - Rectangle { - border.width: 1 - color: "transparent" - anchors.fill: parent - anchors.topMargin: header.height - anchors.margins: root.borderWidth - border.color: Cpp_ThemeManager.border - } + Rectangle { + border.width: 1 + color: "transparent" + anchors.fill: parent + anchors.topMargin: header.height + anchors.margins: root.borderWidth + border.color: Cpp_ThemeManager.border + } + } + + // + // Window title & controls + // + header: Rectangle { + radius: root.radius + color: root.borderColor + height: root.headerHeight + visible: root.headerVisible + + gradient: Gradient { + GradientStop { + position: 0 + color: root.gradientColor1 + } + + GradientStop { + position: 1 + color: root.gradientColor2 + } } - // - // Window title & controls - // - header: Rectangle { - radius: root.radius - color: root.borderColor - height: root.headerHeight - visible: root.headerVisible + Rectangle { + z: 5 + color: root.gradientColor1 + height: root.gradient ? 1 : parent.radius - gradient: Gradient { - GradientStop { - position: 0 - color: root.gradientColor1 - } - - GradientStop { - position: 1 - color: root.gradientColor2 - } - } - - Rectangle { - z: 5 - color: root.gradientColor1 - height: root.gradient ? 1 : parent.radius - - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - } - - MouseArea { - z: 2 - id: headerMouseArea - anchors.fill: parent - onDoubleClicked: root.headerDoubleClicked() - - onClicked: (mouse) => { - if (mouse.x >= headerBt.x && mouse.x <= headerBt.x + headerBt.width) - root.headerDoubleClicked() - } - } - - RowLayout { - spacing: 0 - anchors.fill: parent - - Icon { - id: _bt - color: root.titleColor - source: "qrc:/icons/widget.svg" - Layout.alignment: Qt.AlignVCenter - Layout.maximumHeight: parent.height - Layout.minimumHeight: parent.height - Layout.minimumWidth: root.headerHeight - Layout.maximumWidth: root.headerHeight - icon.width: root.headerHeight * 20 / 32 - icon.height: root.headerHeight * 20 / 32 - } - - Label { - font.bold: true - text: root.title - Layout.fillWidth: true - color: root.titleColor - elide: Label.ElideRight - Layout.alignment: Qt.AlignVCenter - font.pixelSize: root.headerHeight * 14 / 32 - horizontalAlignment: root.showIcon ? Label.AlignLeft : Label.AlignHCenter - } - - Icon { - id: headerBt - color: root.titleColor - Layout.alignment: Qt.AlignVCenter - Layout.maximumHeight: parent.height - Layout.minimumHeight: parent.height - icon.source: "qrc:/icons/expand.svg" - Layout.minimumWidth: root.headerHeight - Layout.maximumWidth: root.headerHeight - visible: root.headerDoubleClickEnabled - icon.width: root.headerHeight * 20 / 32 - icon.height: root.headerHeight * 20 / 32 - } - - Button { - id: altBt - flat: true - enabled: visible - icon.color: root.titleColor - visible: root.altButtonEnabled - Layout.alignment: Qt.AlignVCenter - onClicked: root.altButtonClicked() - Layout.maximumHeight: parent.height - Layout.minimumHeight: parent.height - Layout.minimumWidth: root.headerHeight - Layout.maximumWidth: root.headerHeight - icon.width: root.headerHeight * 20 / 32 - icon.height: root.headerHeight * 20 / 32 - background: Item {} - } - } + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } } + + MouseArea { + z: 2 + id: headerMouseArea + anchors.fill: parent + onDoubleClicked: root.headerDoubleClicked() + + onClicked: (mouse) => { + if (mouse.x >= headerBt.x && mouse.x <= headerBt.x + headerBt.width) + root.headerDoubleClicked() + } + } + + RowLayout { + spacing: 0 + anchors.fill: parent + + Icon { + id: _bt + color: root.titleColor + source: "qrc:/icons/widget.svg" + Layout.alignment: Qt.AlignVCenter + Layout.maximumHeight: parent.height + Layout.minimumHeight: parent.height + Layout.minimumWidth: root.headerHeight + Layout.maximumWidth: root.headerHeight + icon.width: root.headerHeight * 20 / 32 + icon.height: root.headerHeight * 20 / 32 + } + + Label { + font.bold: true + text: root.title + Layout.fillWidth: true + color: root.titleColor + elide: Label.ElideRight + Layout.alignment: Qt.AlignVCenter + font.pixelSize: root.headerHeight * 14 / 32 + horizontalAlignment: root.showIcon ? Label.AlignLeft : Label.AlignHCenter + } + + Icon { + id: headerBt + color: root.titleColor + Layout.alignment: Qt.AlignVCenter + Layout.maximumHeight: parent.height + Layout.minimumHeight: parent.height + icon.source: "qrc:/icons/expand.svg" + Layout.minimumWidth: root.headerHeight + Layout.maximumWidth: root.headerHeight + visible: root.headerDoubleClickEnabled + icon.width: root.headerHeight * 20 / 32 + icon.height: root.headerHeight * 20 / 32 + } + + Button { + id: altBt + flat: true + enabled: visible + icon.color: root.titleColor + visible: root.altButtonEnabled + Layout.alignment: Qt.AlignVCenter + onClicked: root.altButtonClicked() + Layout.maximumHeight: parent.height + Layout.minimumHeight: parent.height + Layout.minimumWidth: root.headerHeight + Layout.maximumWidth: root.headerHeight + icon.width: root.headerHeight * 20 / 32 + icon.height: root.headerHeight * 20 / 32 + background: Item {} + } + } + } } diff --git a/assets/qml/Windows/About.qml b/assets/qml/Windows/About.qml index c6d87e7c..f0e250a1 100644 --- a/assets/qml/Windows/About.qml +++ b/assets/qml/Windows/About.qml @@ -28,197 +28,197 @@ import QtQuick.Controls import "../FramelessWindow" as FramelessWindow FramelessWindow.CustomWindow { - id: root + id: root - // - // Custom properties - // - readonly property int year: new Date().getFullYear() + // + // Custom properties + // + readonly property int year: new Date().getFullYear() - // - // Window options - // - title: qsTr("About") - width: minimumWidth - height: minimumHeight - x: (Screen.desktopAvailableWidth - width) / 2 - y: (Screen.desktopAvailableHeight - height) / 2 - extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + // + // Window options + // + title: qsTr("About") + width: minimumWidth + height: minimumHeight + x: (Screen.desktopAvailableWidth - width) / 2 + y: (Screen.desktopAvailableHeight - height) / 2 + extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - // - // Titlebar options - // - minimizeEnabled: false - maximizeEnabled: false - titlebarText: Cpp_ThemeManager.text - titlebarColor: Cpp_ThemeManager.dialogBackground - backgroundColor: Cpp_ThemeManager.dialogBackground + // + // Titlebar options + // + minimizeEnabled: false + maximizeEnabled: false + titlebarText: Cpp_ThemeManager.text + titlebarColor: Cpp_ThemeManager.dialogBackground + backgroundColor: Cpp_ThemeManager.dialogBackground - // - // Use page item to set application palette - // - Page { - anchors { - fill: parent - margins: root.shadowMargin - topMargin: titlebar.height + root.shadowMargin - } - - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText - - background: Rectangle { - radius: root.radius - color: root.backgroundColor - - Rectangle { - height: root.radius - color: root.backgroundColor - - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - } - - // - // Window drag handler - // - Item { - anchors.fill: parent - - MouseArea { - anchors.fill: parent - onPressedChanged: { - if (pressed) - root.startSystemMove() - } - } - } - - // - // Window controls - // - ColumnLayout { - id: column - spacing: app.spacing - anchors.centerIn: parent - - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Image { - width: 128 - height: 128 - Layout.alignment: Qt.AlignVCenter - sourceSize: Qt.size(width, height) - source: { - if (Screen.pixelDensity >= 2) - return "qrc:/images/icon@2x.png" - - return "qrc:/images/icon@1x.png" - } - } - - ColumnLayout { - spacing: app.spacing - Layout.fillWidth: true - Layout.alignment: Qt.AlignVCenter - - Label { - font.bold: true - text: Cpp_AppName - font.pixelSize: 28 - } - - Label { - opacity: 0.5 - font.pixelSize: 16 - text: qsTr("Version %1").arg(Cpp_AppVersion) - } - } - } - - Label { - opacity: 0.8 - Layout.fillWidth: true - Layout.maximumWidth: 320 - wrapMode: Label.WrapAtWordBoundaryOrAnywhere - text: qsTr("Copyright © 2020-%1 %2, released under the MIT License.").arg(root.year).arg(Cpp_AppOrganization) - } - - Label { - opacity: 0.8 - font.pixelSize: 12 - Layout.fillWidth: true - Layout.maximumWidth: 320 - wrapMode: Label.WrapAtWordBoundaryOrAnywhere - color: Cpp_ThemeManager.highlightedTextAlternative - text: qsTr("The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.") - } - - Item { - height: app.spacing - } - - Button { - Layout.fillWidth: true - text: qsTr("Website") - onClicked: Qt.openUrlExternally("https://serial-studio.github.io/") - } - - Button { - Layout.fillWidth: true - text: qsTr("Make a donation") - onClicked: app.donateDialog.show() - } - - Button { - Layout.fillWidth: true - text: qsTr("Report bug") - onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues") - } - - Button { - Layout.fillWidth: true - text: qsTr("Documentation") - onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") - } - - Button { - Layout.fillWidth: true - text: qsTr("Acknowledgements") - onClicked: acknowledgementsDialog.show() - } - - Item { - height: app.spacing - } - - Button { - Layout.fillWidth: true - onClicked: root.close() - text: qsTr("Close") - } - } + // + // Use page item to set application palette + // + Page { + anchors { + fill: parent + margins: root.shadowMargin + topMargin: titlebar.height + root.shadowMargin } + + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText + + background: Rectangle { + radius: root.radius + color: root.backgroundColor + + Rectangle { + height: root.radius + color: root.backgroundColor + + anchors { + top: parent.top + left: parent.left + right: parent.right + } + } + } + + // + // Window drag handler + // + Item { + anchors.fill: parent + + MouseArea { + anchors.fill: parent + onPressedChanged: { + if (pressed) + root.startSystemMove() + } + } + } + + // + // Window controls + // + ColumnLayout { + id: column + spacing: app.spacing + anchors.centerIn: parent + + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Image { + width: 128 + height: 128 + Layout.alignment: Qt.AlignVCenter + sourceSize: Qt.size(width, height) + source: { + if (Screen.pixelDensity >= 2) + return "qrc:/images/icon@2x.png" + + return "qrc:/images/icon@1x.png" + } + } + + ColumnLayout { + spacing: app.spacing + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter + + Label { + font.bold: true + text: Cpp_AppName + font.pixelSize: 28 + } + + Label { + opacity: 0.5 + font.pixelSize: 16 + text: qsTr("Version %1").arg(Cpp_AppVersion) + } + } + } + + Label { + opacity: 0.8 + Layout.fillWidth: true + Layout.maximumWidth: 320 + wrapMode: Label.WrapAtWordBoundaryOrAnywhere + text: qsTr("Copyright © 2020-%1 %2, released under the MIT License.").arg(root.year).arg(Cpp_AppOrganization) + } + + Label { + opacity: 0.8 + font.pixelSize: 12 + Layout.fillWidth: true + Layout.maximumWidth: 320 + wrapMode: Label.WrapAtWordBoundaryOrAnywhere + color: Cpp_ThemeManager.highlightedTextAlternative + text: qsTr("The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.") + } + + Item { + height: app.spacing + } + + Button { + Layout.fillWidth: true + text: qsTr("Website") + onClicked: Qt.openUrlExternally("https://serial-studio.github.io/") + } + + Button { + Layout.fillWidth: true + text: qsTr("Make a donation") + onClicked: app.donateDialog.show() + } + + Button { + Layout.fillWidth: true + text: qsTr("Report bug") + onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/issues") + } + + Button { + Layout.fillWidth: true + text: qsTr("Documentation") + onClicked: Qt.openUrlExternally("https://github.com/Serial-Studio/Serial-Studio/wiki") + } + + Button { + Layout.fillWidth: true + text: qsTr("Acknowledgements") + onClicked: acknowledgementsDialog.show() + } + + Item { + height: app.spacing + } + + Button { + Layout.fillWidth: true + onClicked: root.close() + text: qsTr("Close") + } + } + } } diff --git a/assets/qml/Windows/Acknowledgements.qml b/assets/qml/Windows/Acknowledgements.qml index b76169ff..e0fbe219 100644 --- a/assets/qml/Windows/Acknowledgements.qml +++ b/assets/qml/Windows/Acknowledgements.qml @@ -28,101 +28,101 @@ import QtQuick.Controls import "../FramelessWindow" as FramelessWindow FramelessWindow.CustomWindow { - id: root + id: root - // - // Window options - // - width: minimumWidth - height: minimumHeight - minimizeEnabled: false - maximizeEnabled: false - title: qsTr("Acknowledgements") - titlebarText: Cpp_ThemeManager.text - x: (Screen.desktopAvailableWidth - width) / 2 - y: (Screen.desktopAvailableHeight - height) / 2 - titlebarColor: Cpp_ThemeManager.dialogBackground - backgroundColor: Cpp_ThemeManager.dialogBackground - extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + // + // Window options + // + width: minimumWidth + height: minimumHeight + minimizeEnabled: false + maximizeEnabled: false + title: qsTr("Acknowledgements") + titlebarText: Cpp_ThemeManager.text + x: (Screen.desktopAvailableWidth - width) / 2 + y: (Screen.desktopAvailableHeight - height) / 2 + titlebarColor: Cpp_ThemeManager.dialogBackground + backgroundColor: Cpp_ThemeManager.dialogBackground + extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - // - // Use page item to set application palette - // - Page { - anchors { - fill: parent - margins: root.shadowMargin - topMargin: titlebar.height + root.shadowMargin - } - - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText - - background: Rectangle { - radius: root.radius - color: root.backgroundColor - - Rectangle { - height: root.radius - color: root.backgroundColor - - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - } - - // - // Window controls - // - ColumnLayout { - id: column - spacing: app.spacing - anchors.centerIn: parent - - ScrollView { - Layout.fillWidth: true - Layout.fillHeight: true - Layout.minimumWidth: 640 - Layout.maximumWidth: 640 - Layout.minimumHeight: 480 - Layout.maximumHeight: 480 - - TextArea { - readOnly: true - textFormat: TextArea.MarkdownText - wrapMode: TextArea.WrapAtWordBoundaryOrAnywhere - text: Cpp_Misc_Translator.acknowledgementsText() - - background: TextField { - enabled: false - } - } - } - - Button { - text: qsTr("Close") - onClicked: root.close() - Layout.alignment: Qt.AlignRight - } - } + // + // Use page item to set application palette + // + Page { + anchors { + fill: parent + margins: root.shadowMargin + topMargin: titlebar.height + root.shadowMargin } + + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText + + background: Rectangle { + radius: root.radius + color: root.backgroundColor + + Rectangle { + height: root.radius + color: root.backgroundColor + + anchors { + top: parent.top + left: parent.left + right: parent.right + } + } + } + + // + // Window controls + // + ColumnLayout { + id: column + spacing: app.spacing + anchors.centerIn: parent + + ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumWidth: 640 + Layout.maximumWidth: 640 + Layout.minimumHeight: 480 + Layout.maximumHeight: 480 + + TextArea { + readOnly: true + textFormat: TextArea.MarkdownText + wrapMode: TextArea.WrapAtWordBoundaryOrAnywhere + text: Cpp_Misc_Translator.acknowledgementsText() + + background: TextField { + enabled: false + } + } + } + + Button { + text: qsTr("Close") + onClicked: root.close() + Layout.alignment: Qt.AlignRight + } + } + } } diff --git a/assets/qml/Windows/CsvPlayer.qml b/assets/qml/Windows/CsvPlayer.qml index 8edfbea8..b1d10b25 100644 --- a/assets/qml/Windows/CsvPlayer.qml +++ b/assets/qml/Windows/CsvPlayer.qml @@ -28,155 +28,155 @@ import QtQuick.Controls import "../FramelessWindow" as FramelessWindow FramelessWindow.CustomWindow { - id: root + id: root - // - // Window options - // - width: minimumWidth - height: minimumHeight - minimizeEnabled: false - maximizeEnabled: false - title: qsTr("CSV Player") - titlebarText: Cpp_ThemeManager.text - x: (Screen.desktopAvailableWidth - width) / 2 - y: (Screen.desktopAvailableHeight - height) / 2 - titlebarColor: Cpp_ThemeManager.dialogBackground - backgroundColor: Cpp_ThemeManager.dialogBackground - minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - extraFlags: Qt.WindowStaysOnTopHint | Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + // + // Window options + // + width: minimumWidth + height: minimumHeight + minimizeEnabled: false + maximizeEnabled: false + title: qsTr("CSV Player") + titlebarText: Cpp_ThemeManager.text + x: (Screen.desktopAvailableWidth - width) / 2 + y: (Screen.desktopAvailableHeight - height) / 2 + titlebarColor: Cpp_ThemeManager.dialogBackground + backgroundColor: Cpp_ThemeManager.dialogBackground + minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + extraFlags: Qt.WindowStaysOnTopHint | Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - // - // Close CSV file when window is closed - // - onVisibleChanged: { - if (!visible && Cpp_CSV_Player.isOpen) - Cpp_CSV_Player.closeFile() + // + // Close CSV file when window is closed + // + onVisibleChanged: { + if (!visible && Cpp_CSV_Player.isOpen) + Cpp_CSV_Player.closeFile() + } + + // + // Automatically display the window when the CSV file is opened + // + Connections { + target: Cpp_CSV_Player + function onOpenChanged() { + if (Cpp_CSV_Player.isOpen) + root.visible = true + else + root.visible = false + } + } + + // + // Use page item to set application palette + // + Page { + anchors { + fill: parent + margins: root.shadowMargin + topMargin: titlebar.height + root.shadowMargin } - // - // Automatically display the window when the CSV file is opened - // - Connections { - target: Cpp_CSV_Player - function onOpenChanged() { - if (Cpp_CSV_Player.isOpen) - root.visible = true - else - root.visible = false - } - } + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText + + background: Rectangle { + radius: root.radius + color: root.backgroundColor + + Rectangle { + height: root.radius + color: root.backgroundColor - // - // Use page item to set application palette - // - Page { anchors { - fill: parent - margins: root.shadowMargin - topMargin: titlebar.height + root.shadowMargin - } - - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText - - background: Rectangle { - radius: root.radius - color: root.backgroundColor - - Rectangle { - height: root.radius - color: root.backgroundColor - - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - } - - // - // Window controls - // - ColumnLayout { - id: column - anchors.centerIn: parent - spacing: app.spacing * 2 - - // - // Timestamp display - // - Label { - font.family: app.monoFont - text: Cpp_CSV_Player.timestamp - Layout.alignment: Qt.AlignLeft - } - - // - // Progress display - // - Slider { - Layout.fillWidth: true - value: Cpp_CSV_Player.progress - onValueChanged: { - if (value !== Cpp_CSV_Player.progress) - Cpp_CSV_Player.setProgress(value) - } - } - - // - // Play/pause buttons - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignHCenter - - Button { - opacity: enabled ? 1 : 0.5 - icon.color: Cpp_ThemeManager.text - Layout.alignment: Qt.AlignVCenter - onClicked: Cpp_CSV_Player.previousFrame() - icon.source: "qrc:/icons/media-prev.svg" - enabled: Cpp_CSV_Player.progress > 0 && !Cpp_CSV_Player.isPlaying - } - - Button { - icon.width: 32 - icon.height: 32 - icon.color: Cpp_ThemeManager.text - onClicked: Cpp_CSV_Player.toggle() - Layout.alignment: Qt.AlignVCenter - icon.source: Cpp_CSV_Player.isPlaying ? "qrc:/icons/media-pause.svg" : - "qrc:/icons/media-play.svg" - } - - Button { - opacity: enabled ? 1 : 0.5 - icon.color: Cpp_ThemeManager.text - Layout.alignment: Qt.AlignVCenter - onClicked: Cpp_CSV_Player.nextFrame() - icon.source: "qrc:/icons/media-next.svg" - enabled: Cpp_CSV_Player.progress < 1 && !Cpp_CSV_Player.isPlaying - } - } + top: parent.top + left: parent.left + right: parent.right } + } } + + // + // Window controls + // + ColumnLayout { + id: column + anchors.centerIn: parent + spacing: app.spacing * 2 + + // + // Timestamp display + // + Label { + font.family: app.monoFont + text: Cpp_CSV_Player.timestamp + Layout.alignment: Qt.AlignLeft + } + + // + // Progress display + // + Slider { + Layout.fillWidth: true + value: Cpp_CSV_Player.progress + onValueChanged: { + if (value !== Cpp_CSV_Player.progress) + Cpp_CSV_Player.setProgress(value) + } + } + + // + // Play/pause buttons + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignHCenter + + Button { + opacity: enabled ? 1 : 0.5 + icon.color: Cpp_ThemeManager.text + Layout.alignment: Qt.AlignVCenter + onClicked: Cpp_CSV_Player.previousFrame() + icon.source: "qrc:/icons/media-prev.svg" + enabled: Cpp_CSV_Player.progress > 0 && !Cpp_CSV_Player.isPlaying + } + + Button { + icon.width: 32 + icon.height: 32 + icon.color: Cpp_ThemeManager.text + onClicked: Cpp_CSV_Player.toggle() + Layout.alignment: Qt.AlignVCenter + icon.source: Cpp_CSV_Player.isPlaying ? "qrc:/icons/media-pause.svg" : + "qrc:/icons/media-play.svg" + } + + Button { + opacity: enabled ? 1 : 0.5 + icon.color: Cpp_ThemeManager.text + Layout.alignment: Qt.AlignVCenter + onClicked: Cpp_CSV_Player.nextFrame() + icon.source: "qrc:/icons/media-next.svg" + enabled: Cpp_CSV_Player.progress < 1 && !Cpp_CSV_Player.isPlaying + } + } + } + } } diff --git a/assets/qml/Windows/Donate.qml b/assets/qml/Windows/Donate.qml index 26dbe00e..1f0f8db7 100644 --- a/assets/qml/Windows/Donate.qml +++ b/assets/qml/Windows/Donate.qml @@ -29,222 +29,222 @@ import QtQuick.Controls import "../FramelessWindow" as FramelessWindow FramelessWindow.CustomWindow { - id: root + id: root - // - // Window options - // - title: qsTr("Donate") - width: minimumWidth - height: minimumHeight - minimizeEnabled: false - maximizeEnabled: false - titlebarText: Cpp_ThemeManager.text - x: (Screen.desktopAvailableWidth - width) / 2 - y: (Screen.desktopAvailableHeight - height) / 2 - titlebarColor: Cpp_ThemeManager.dialogBackground - backgroundColor: Cpp_ThemeManager.dialogBackground - extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + // + // Window options + // + title: qsTr("Donate") + width: minimumWidth + height: minimumHeight + minimizeEnabled: false + maximizeEnabled: false + titlebarText: Cpp_ThemeManager.text + x: (Screen.desktopAvailableWidth - width) / 2 + y: (Screen.desktopAvailableHeight - height) / 2 + titlebarColor: Cpp_ThemeManager.dialogBackground + backgroundColor: Cpp_ThemeManager.dialogBackground + extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - // - // Custom properties - // - property alias doNotShowAgain: doNotShowAgainCheck.checked + // + // Custom properties + // + property alias doNotShowAgain: doNotShowAgainCheck.checked - // - // Enables the "do not show again" checkbox and sets - // the text of the close button to "later". - // - // This is used when the window is shown automatically - // every now and then to the user. - // - function showAutomatically() { - doNotShowAgainCheck.visible = true - closeBt.text = qsTr("Later") - showNormal() + // + // Enables the "do not show again" checkbox and sets + // the text of the close button to "later". + // + // This is used when the window is shown automatically + // every now and then to the user. + // + function showAutomatically() { + doNotShowAgainCheck.visible = true + closeBt.text = qsTr("Later") + showNormal() + } + + // + // Disables the "do not show again" checkbox and sets + // the text of the close button to "close". + // + // This is used when the user opens this dialog from + // the "about" window. + // + function show() { + doNotShowAgainCheck.visible = false + closeBt.text = qsTr("Close") + showNormal() + } + + // + // Save settings + // + Settings { + property alias disableDonationsWindow: root.doNotShowAgain + } + + // + // Use page item to set application palette + // + Page { + anchors { + fill: parent + margins: root.shadowMargin + topMargin: titlebar.height + root.shadowMargin } - // - // Disables the "do not show again" checkbox and sets - // the text of the close button to "close". - // - // This is used when the user opens this dialog from - // the "about" window. - // - function show() { - doNotShowAgainCheck.visible = false - closeBt.text = qsTr("Close") - showNormal() - } + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText - // - // Save settings - // - Settings { - property alias disableDonationsWindow: root.doNotShowAgain - } + background: Rectangle { + radius: root.radius + color: root.backgroundColor + + Rectangle { + height: root.radius + color: root.backgroundColor - // - // Use page item to set application palette - // - Page { anchors { - fill: parent - margins: root.shadowMargin - topMargin: titlebar.height + root.shadowMargin - } - - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText - - background: Rectangle { - radius: root.radius - color: root.backgroundColor - - Rectangle { - height: root.radius - color: root.backgroundColor - - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - } - - // - // Window drag handler - // - Item { - anchors.fill: parent - - MouseArea { - anchors.fill: parent - onPressedChanged: { - if (pressed) - root.startSystemMove() - } - } - } - - // - // Window controls - // - ColumnLayout { - id: column - anchors.centerIn: parent - spacing: app.spacing * 2 - - RowLayout { - Layout.fillWidth: true - Layout.fillHeight: true - spacing: app.spacing * 2 - - Image { - sourceSize: Qt.size(120, 120) - Layout.alignment: Qt.AlignVCenter - source: "qrc:/images/donate-qr.svg" - - Rectangle { - border.width: 2 - color: "transparent" - anchors.fill: parent - border.color: "#000" - } - } - - ColumnLayout { - spacing: app.spacing * 2 - Layout.fillWidth: true - Layout.fillHeight: true - - Item { - Layout.fillHeight: true - } - - Label { - id: title - font.bold: true - font.pixelSize: 16 - Layout.fillWidth: true - Layout.minimumHeight: font.pixelSize - text: qsTr("Support the development of %1!").arg(Cpp_AppName) - } - - Label { - Layout.fillWidth: true - Layout.minimumHeight: font.pixelSize * 3 - Layout.maximumWidth: title.implicitWidth - wrapMode: Label.WrapAtWordBoundaryOrAnywhere - text: qsTr("Serial Studio is free & open-source software supported by volunteers. " + - "Consider donating to support development efforts :)") - } - - Label { - opacity: 0.8 - font.pixelSize: 12 - Layout.fillWidth: true - Layout.minimumHeight: font.pixelSize * 2 - Layout.maximumWidth: title.implicitWidth - wrapMode: Label.WrapAtWordBoundaryOrAnywhere - color: Cpp_ThemeManager.highlightedTextAlternative - text: qsTr("You can also support this project by sharing it, reporting bugs and proposing new features!") - } - - Item { - Layout.fillHeight: true - } - } - } - - RowLayout { - Layout.fillWidth: true - spacing: app.spacing - - CheckBox { - id: doNotShowAgainCheck - Layout.leftMargin: -app.spacing - Layout.alignment: Qt.AlignVCenter - text: qsTr("Don't annoy me again!") - } - - Item { - Layout.fillWidth: true - } - - Button { - id: closeBt - onClicked: root.close() - Layout.alignment: Qt.AlignVCenter - } - - Button { - highlighted: true - text: qsTr("Donate") - Keys.onEnterPressed: clicked() - Keys.onReturnPressed: clicked() - Layout.alignment: Qt.AlignVCenter - Component.onCompleted: forceActiveFocus() - onClicked: Qt.openUrlExternally("https://www.paypal.com/donate?hosted_button_id=XN68J47QJKYDE") - } - } + top: parent.top + left: parent.left + right: parent.right } + } } + + // + // Window drag handler + // + Item { + anchors.fill: parent + + MouseArea { + anchors.fill: parent + onPressedChanged: { + if (pressed) + root.startSystemMove() + } + } + } + + // + // Window controls + // + ColumnLayout { + id: column + anchors.centerIn: parent + spacing: app.spacing * 2 + + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + spacing: app.spacing * 2 + + Image { + sourceSize: Qt.size(120, 120) + Layout.alignment: Qt.AlignVCenter + source: "qrc:/images/donate-qr.svg" + + Rectangle { + border.width: 2 + color: "transparent" + anchors.fill: parent + border.color: "#000" + } + } + + ColumnLayout { + spacing: app.spacing * 2 + Layout.fillWidth: true + Layout.fillHeight: true + + Item { + Layout.fillHeight: true + } + + Label { + id: title + font.bold: true + font.pixelSize: 16 + Layout.fillWidth: true + Layout.minimumHeight: font.pixelSize + text: qsTr("Support the development of %1!").arg(Cpp_AppName) + } + + Label { + Layout.fillWidth: true + Layout.minimumHeight: font.pixelSize * 3 + Layout.maximumWidth: title.implicitWidth + wrapMode: Label.WrapAtWordBoundaryOrAnywhere + text: qsTr("Serial Studio is free & open-source software supported by volunteers. " + + "Consider donating to support development efforts :)") + } + + Label { + opacity: 0.8 + font.pixelSize: 12 + Layout.fillWidth: true + Layout.minimumHeight: font.pixelSize * 2 + Layout.maximumWidth: title.implicitWidth + wrapMode: Label.WrapAtWordBoundaryOrAnywhere + color: Cpp_ThemeManager.highlightedTextAlternative + text: qsTr("You can also support this project by sharing it, reporting bugs and proposing new features!") + } + + Item { + Layout.fillHeight: true + } + } + } + + RowLayout { + Layout.fillWidth: true + spacing: app.spacing + + CheckBox { + id: doNotShowAgainCheck + Layout.leftMargin: -app.spacing + Layout.alignment: Qt.AlignVCenter + text: qsTr("Don't annoy me again!") + } + + Item { + Layout.fillWidth: true + } + + Button { + id: closeBt + onClicked: root.close() + Layout.alignment: Qt.AlignVCenter + } + + Button { + highlighted: true + text: qsTr("Donate") + Keys.onEnterPressed: clicked() + Keys.onReturnPressed: clicked() + Layout.alignment: Qt.AlignVCenter + Component.onCompleted: forceActiveFocus() + onClicked: Qt.openUrlExternally("https://www.paypal.com/donate?hosted_button_id=XN68J47QJKYDE") + } + } + } + } } diff --git a/assets/qml/Windows/MQTTConfiguration.qml b/assets/qml/Windows/MQTTConfiguration.qml index 7ee1c261..d19d5e8f 100644 --- a/assets/qml/Windows/MQTTConfiguration.qml +++ b/assets/qml/Windows/MQTTConfiguration.qml @@ -29,591 +29,591 @@ import QtQuick.Controls import "../FramelessWindow" as FramelessWindow FramelessWindow.CustomWindow { - id: root + id: root - // - // Custom properties - // - readonly property int year: new Date().getFullYear() + // + // Custom properties + // + readonly property int year: new Date().getFullYear() - // - // Window options - // - width: minimumWidth - height: minimumHeight - title: qsTr("MQTT Configuration") - x: (Screen.desktopAvailableWidth - width) / 2 - y: (Screen.desktopAvailableHeight - height) / 2 - extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint - minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin - minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + // + // Window options + // + width: minimumWidth + height: minimumHeight + title: qsTr("MQTT Configuration") + x: (Screen.desktopAvailableWidth - width) / 2 + y: (Screen.desktopAvailableHeight - height) / 2 + extraFlags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint + minimumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + maximumWidth: column.implicitWidth + 4 * app.spacing + 2 * root.shadowMargin + minimumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin + maximumHeight: column.implicitHeight + 4 * app.spacing + titlebar.height + 2 * root.shadowMargin - // - // Titlebar options - // - minimizeEnabled: false - maximizeEnabled: false - titlebarText: Cpp_ThemeManager.text - titlebarColor: Cpp_ThemeManager.dialogBackground - backgroundColor: Cpp_ThemeManager.dialogBackground + // + // Titlebar options + // + minimizeEnabled: false + maximizeEnabled: false + titlebarText: Cpp_ThemeManager.text + titlebarColor: Cpp_ThemeManager.dialogBackground + backgroundColor: Cpp_ThemeManager.dialogBackground - // - // Save settings - // - Settings { - property alias version: _version.currentIndex - property alias mode: _mode.currentIndex - property alias host: _host.text - property alias port: _port.text - property alias qos: _qos.currentIndex - property alias keepAlive: _keepAlive.text - property alias topic: _topic.text - property alias retain: _retain.checked - property alias user: _user.text - property alias password: _password.text - property alias ssl: _ssl.checked - property alias certificate: _certificateMode.currentIndex - property alias protocol: _protocols.currentIndex - property alias caFilePath: _caFile.text + // + // Save settings + // + Settings { + property alias version: _version.currentIndex + property alias mode: _mode.currentIndex + property alias host: _host.text + property alias port: _port.text + property alias qos: _qos.currentIndex + property alias keepAlive: _keepAlive.text + property alias topic: _topic.text + property alias retain: _retain.checked + property alias user: _user.text + property alias password: _password.text + property alias ssl: _ssl.checked + property alias certificate: _certificateMode.currentIndex + property alias protocol: _protocols.currentIndex + property alias caFilePath: _caFile.text + } + + // + // Use page item to set application palette + // + Page { + anchors { + fill: parent + margins: root.shadowMargin + topMargin: titlebar.height + root.shadowMargin } - // - // Use page item to set application palette - // - Page { + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText + + background: Rectangle { + radius: root.radius + color: root.backgroundColor + + Rectangle { + height: root.radius + color: root.backgroundColor + anchors { - fill: parent - margins: root.shadowMargin - topMargin: titlebar.height + root.shadowMargin - } - - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText - - background: Rectangle { - radius: root.radius - color: root.backgroundColor - - Rectangle { - height: root.radius - color: root.backgroundColor - - anchors { - top: parent.top - left: parent.left - right: parent.right - } - } - } - - // - // Window controls - // - ColumnLayout { - id: column - spacing: app.spacing - anchors.centerIn: parent - - GridLayout { - columns: 2 - rowSpacing: 0 - Layout.fillWidth: true - columnSpacing: app.spacing - - // - // Version & mode titles - // - Label { - text: qsTr("Version") + ":" - } Label { - text: qsTr("Mode") + ":" - } - - // - // MQTT version - // - ComboBox { - id: _version - Layout.fillWidth: true - Layout.minimumWidth: 256 - model: Cpp_MQTT_Client.mqttVersions - currentIndex: Cpp_MQTT_Client.mqttVersion - onCurrentIndexChanged: { - if (Cpp_MQTT_Client.mqttVersion !== currentIndex) - Cpp_MQTT_Client.mqttVersion = currentIndex - } - } - - // - // Client mode version - // - ComboBox { - id: _mode - Layout.fillWidth: true - Layout.minimumWidth: 256 - model: Cpp_MQTT_Client.clientModes - currentIndex: Cpp_MQTT_Client.clientMode - onCurrentIndexChanged: { - if (Cpp_MQTT_Client.clientMode !== currentIndex) - Cpp_MQTT_Client.clientMode = currentIndex - } - } - - // - // Spacers - // - Item { - height: app.spacing - } Item { - height: app.spacing - } - - // - // QOS Level & Keep Alive - // - Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("QOS level") + ":" - enabled: !Cpp_MQTT_Client.isConnectedToHost - } Label { - opacity: enabled ? 1 : 0.5 - text: qsTr("Keep alive (s)") + ":" - enabled: !Cpp_MQTT_Client.isConnectedToHost - } - - // - // QOS - // - ComboBox { - id: _qos - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - model: Cpp_MQTT_Client.qosLevels - currentIndex: Cpp_MQTT_Client.qos - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onCurrentIndexChanged: { - if (Cpp_MQTT_Client.qos !== currentIndex) - Cpp_MQTT_Client.qos = currentIndex - } - } - - // - // Keep alive - // - TextField { - id: _keepAlive - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - placeholderText: Cpp_MQTT_Client.keepAlive - enabled: !Cpp_MQTT_Client.isConnectedToHost - Component.onCompleted: text = Cpp_MQTT_Client.keepAlive - - onTextChanged: { - if (Cpp_MQTT_Client.keepAlive !== text && text.length > 0) - Cpp_MQTT_Client.keepAlive = text - - if (text.length === 0) - Cpp_MQTT_Client.keepAlive = 1 - } - - validator: IntValidator { - bottom: 1 - top: 65535 - } - } - - // - // Spacers - // - Item { - height: app.spacing - } Item { - height: app.spacing - } - - // - // Host & port titles - // - Label { - text: qsTr("Host") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } Label { - text: qsTr("Port") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } - - // - // Host - // - TextField { - id: _host - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - placeholderText: Cpp_MQTT_Client.defaultHost - Component.onCompleted: text = Cpp_MQTT_Client.host - - onTextChanged: { - if (Cpp_MQTT_Client.host !== text && text.length > 0) - Cpp_MQTT_Client.host = text - - if (text.length === 0) - Cpp_MQTT_Client.host = Cpp_MQTT_Client.defaultHost - } - } - - // - // Port - // - TextField { - id: _port - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - placeholderText: Cpp_MQTT_Client.defaultPort - Component.onCompleted: text = Cpp_MQTT_Client.port - - onTextChanged: { - if (Cpp_MQTT_Client.port !== text && text.length > 0) - Cpp_MQTT_Client.port = text - - if (text.length === 0) - Cpp_MQTT_Client.port = Cpp_MQTT_Client.defaultPort - } - - validator: IntValidator { - bottom: 0 - top: 65535 - } - } - - // - // Spacers - // - Item { - height: app.spacing - } Item { - height: app.spacing - } - - // - // Topic & retain labels - // - Label { - text: qsTr("Topic") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } Label { - text: qsTr("Retain") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } - - // - // Topic - // - TextField { - id: _topic - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - text: Cpp_MQTT_Client.topic - placeholderText: qsTr("MQTT topic") - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onTextChanged: { - if (Cpp_MQTT_Client.topic !== text) - Cpp_MQTT_Client.topic = text - } - } - - // - // Retain checkbox - // - CheckBox { - id: _retain - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - text: qsTr("Add retain flag") - Layout.leftMargin: -app.spacing - checked: Cpp_MQTT_Client.retain - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onCheckedChanged: { - if (Cpp_MQTT_Client.retain != checked) - Cpp_MQTT_Client.retain = checked - } - } - - // - // Spacers - // - Item { - height: app.spacing - } Item { - height: app.spacing - } - - // - // Username & password titles - // - Label { - text: qsTr("User") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } Label { - text: qsTr("Password") + ":" - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } - - // - // Username - // - TextField { - id: _user - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - text: Cpp_MQTT_Client.username - placeholderText: qsTr("MQTT username") - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onTextChanged: { - if (Cpp_MQTT_Client.username !== text) - Cpp_MQTT_Client.username = text - } - } - - // - // Password - // - RowLayout { - Layout.fillWidth: true - spacing: app.spacing - - TextField { - id: _password - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - echoMode: TextField.Password - text: Cpp_MQTT_Client.password - placeholderText: qsTr("MQTT password") - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onTextChanged: { - if (Cpp_MQTT_Client.password !== text) - Cpp_MQTT_Client.password = text - } - } - - Button { - checkable: true - icon.color: palette.text - Layout.maximumWidth: height - Layout.alignment: Qt.AlignVCenter - icon.source: "qrc:/icons/visibility.svg" - onCheckedChanged: _password.echoMode = (checked ? TextField.Normal : - TextField.Password) - } - } - - // Spacers - // - Item { - height: app.spacing - } Item { - height: app.spacing - } - - // - // SSL & certificate titles - // - Label { - text: qsTr("Enable SSL/TLS:") - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost - } Label { - text: qsTr("Certificate:") - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked - } - - // - // SSL/TLS switch - // - Switch { - id: _ssl - opacity: enabled ? 1 : 0.5 - Layout.leftMargin: -app.spacing - checked: Cpp_MQTT_Client.sslEnabled - enabled: !Cpp_MQTT_Client.isConnectedToHost - - onCheckedChanged: { - if (Cpp_MQTT_Client.sslEnabled !== checked) - Cpp_MQTT_Client.sslEnabled = checked - } - } - - // - // Certificate selection - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - ComboBox { - id: _certificateMode - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked - model: [ - qsTr("Use system database"), - qsTr("Custom CA file") - ] - - onCurrentIndexChanged: { - if (currentIndex == 0) - Cpp_MQTT_Client.loadCaFile("") - } - } - - Button { - icon.color: palette.text - opacity: enabled ? 1 : 0.5 - Layout.maximumWidth: height - Layout.alignment: Qt.AlignVCenter - icon.source: "qrc:/icons/open.svg" - onClicked: Cpp_MQTT_Client.loadCaFile() - enabled: _certificateMode.currentIndex == 1 && _ssl.checked - } - } - - // - // Spacers - // - Item { - height: app.spacing - } Item { - height: app.spacing - } - - // - // SSL/TLS protocol selection title - // - Item { - Layout.fillWidth: true - } Label { - text: qsTr("Protocol:") - opacity: enabled ? 1 : 0.5 - enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked - } - - // - // SSL/TLS protocol selection - // - Item { - Layout.fillWidth: true - } ComboBox { - id: _protocols - Layout.fillWidth: true - opacity: enabled ? 1 : 0.5 - model: Cpp_MQTT_Client.sslProtocols - enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked - - onCurrentIndexChanged: { - if (currentIndex !== Cpp_MQTT_Client.sslProtocol) - Cpp_MQTT_Client.sslProtocol = currentIndex - } - } - } - - // - // Spacer - // - Item { - height: app.spacing - visible: Cpp_MQTT_Client.caFilePath.length > 0 - } - - // - // CA file display - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - visible: Cpp_MQTT_Client.caFilePath.length > 0 - - Label { - font.bold: true - text: qsTr("CA file:") - Layout.alignment: Qt.AlignVCenter - } - - Label { - id: _caFile - text: Cpp_MQTT_Client.caFilePath - onTextChanged: { - if (text !== Cpp_MQTT_Client.caFilePath) - Cpp_MQTT_Client.loadCaFile(text) - } - } - } - - // - // Spacer - // - Item { - height: app.spacing * 2 - visible: Cpp_MQTT_Client.caFilePath.length <= 0 - } - - // - // Buttons - // - RowLayout { - spacing: app.spacing - Layout.fillWidth: true - - Button { - icon.width: 24 - icon.height: 24 - font.bold: true - Layout.fillWidth: true - icon.color: Cpp_ThemeManager.mqttButton - checked: Cpp_MQTT_Client.isConnectedToHost - onClicked: Cpp_MQTT_Client.toggleConnection() - palette.buttonText: Cpp_ThemeManager.mqttButton - text: (checked ? qsTr("Disconnect") : qsTr("Connect")) + " " - icon.source: checked ? "qrc:/icons/disconnect.svg" : - "qrc:/icons/connect.svg" - } - - Button { - icon.width: 24 - icon.height: 24 - Layout.fillWidth: true - onClicked: root.close() - text: qsTr("Apply") + " " - icon.color: palette.buttonText - icon.source: "qrc:/icons/apply.svg" - } - } + top: parent.top + left: parent.left + right: parent.right } + } } + + // + // Window controls + // + ColumnLayout { + id: column + spacing: app.spacing + anchors.centerIn: parent + + GridLayout { + columns: 2 + rowSpacing: 0 + Layout.fillWidth: true + columnSpacing: app.spacing + + // + // Version & mode titles + // + Label { + text: qsTr("Version") + ":" + } Label { + text: qsTr("Mode") + ":" + } + + // + // MQTT version + // + ComboBox { + id: _version + Layout.fillWidth: true + Layout.minimumWidth: 256 + model: Cpp_MQTT_Client.mqttVersions + currentIndex: Cpp_MQTT_Client.mqttVersion + onCurrentIndexChanged: { + if (Cpp_MQTT_Client.mqttVersion !== currentIndex) + Cpp_MQTT_Client.mqttVersion = currentIndex + } + } + + // + // Client mode version + // + ComboBox { + id: _mode + Layout.fillWidth: true + Layout.minimumWidth: 256 + model: Cpp_MQTT_Client.clientModes + currentIndex: Cpp_MQTT_Client.clientMode + onCurrentIndexChanged: { + if (Cpp_MQTT_Client.clientMode !== currentIndex) + Cpp_MQTT_Client.clientMode = currentIndex + } + } + + // + // Spacers + // + Item { + height: app.spacing + } Item { + height: app.spacing + } + + // + // QOS Level & Keep Alive + // + Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("QOS level") + ":" + enabled: !Cpp_MQTT_Client.isConnectedToHost + } Label { + opacity: enabled ? 1 : 0.5 + text: qsTr("Keep alive (s)") + ":" + enabled: !Cpp_MQTT_Client.isConnectedToHost + } + + // + // QOS + // + ComboBox { + id: _qos + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + model: Cpp_MQTT_Client.qosLevels + currentIndex: Cpp_MQTT_Client.qos + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onCurrentIndexChanged: { + if (Cpp_MQTT_Client.qos !== currentIndex) + Cpp_MQTT_Client.qos = currentIndex + } + } + + // + // Keep alive + // + TextField { + id: _keepAlive + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + placeholderText: Cpp_MQTT_Client.keepAlive + enabled: !Cpp_MQTT_Client.isConnectedToHost + Component.onCompleted: text = Cpp_MQTT_Client.keepAlive + + onTextChanged: { + if (Cpp_MQTT_Client.keepAlive !== text && text.length > 0) + Cpp_MQTT_Client.keepAlive = text + + if (text.length === 0) + Cpp_MQTT_Client.keepAlive = 1 + } + + validator: IntValidator { + bottom: 1 + top: 65535 + } + } + + // + // Spacers + // + Item { + height: app.spacing + } Item { + height: app.spacing + } + + // + // Host & port titles + // + Label { + text: qsTr("Host") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } Label { + text: qsTr("Port") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } + + // + // Host + // + TextField { + id: _host + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + placeholderText: Cpp_MQTT_Client.defaultHost + Component.onCompleted: text = Cpp_MQTT_Client.host + + onTextChanged: { + if (Cpp_MQTT_Client.host !== text && text.length > 0) + Cpp_MQTT_Client.host = text + + if (text.length === 0) + Cpp_MQTT_Client.host = Cpp_MQTT_Client.defaultHost + } + } + + // + // Port + // + TextField { + id: _port + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + placeholderText: Cpp_MQTT_Client.defaultPort + Component.onCompleted: text = Cpp_MQTT_Client.port + + onTextChanged: { + if (Cpp_MQTT_Client.port !== text && text.length > 0) + Cpp_MQTT_Client.port = text + + if (text.length === 0) + Cpp_MQTT_Client.port = Cpp_MQTT_Client.defaultPort + } + + validator: IntValidator { + bottom: 0 + top: 65535 + } + } + + // + // Spacers + // + Item { + height: app.spacing + } Item { + height: app.spacing + } + + // + // Topic & retain labels + // + Label { + text: qsTr("Topic") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } Label { + text: qsTr("Retain") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } + + // + // Topic + // + TextField { + id: _topic + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + text: Cpp_MQTT_Client.topic + placeholderText: qsTr("MQTT topic") + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onTextChanged: { + if (Cpp_MQTT_Client.topic !== text) + Cpp_MQTT_Client.topic = text + } + } + + // + // Retain checkbox + // + CheckBox { + id: _retain + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + text: qsTr("Add retain flag") + Layout.leftMargin: -app.spacing + checked: Cpp_MQTT_Client.retain + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onCheckedChanged: { + if (Cpp_MQTT_Client.retain != checked) + Cpp_MQTT_Client.retain = checked + } + } + + // + // Spacers + // + Item { + height: app.spacing + } Item { + height: app.spacing + } + + // + // Username & password titles + // + Label { + text: qsTr("User") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } Label { + text: qsTr("Password") + ":" + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } + + // + // Username + // + TextField { + id: _user + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + text: Cpp_MQTT_Client.username + placeholderText: qsTr("MQTT username") + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onTextChanged: { + if (Cpp_MQTT_Client.username !== text) + Cpp_MQTT_Client.username = text + } + } + + // + // Password + // + RowLayout { + Layout.fillWidth: true + spacing: app.spacing + + TextField { + id: _password + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + echoMode: TextField.Password + text: Cpp_MQTT_Client.password + placeholderText: qsTr("MQTT password") + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onTextChanged: { + if (Cpp_MQTT_Client.password !== text) + Cpp_MQTT_Client.password = text + } + } + + Button { + checkable: true + icon.color: palette.text + Layout.maximumWidth: height + Layout.alignment: Qt.AlignVCenter + icon.source: "qrc:/icons/visibility.svg" + onCheckedChanged: _password.echoMode = (checked ? TextField.Normal : + TextField.Password) + } + } + + // Spacers + // + Item { + height: app.spacing + } Item { + height: app.spacing + } + + // + // SSL & certificate titles + // + Label { + text: qsTr("Enable SSL/TLS:") + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost + } Label { + text: qsTr("Certificate:") + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked + } + + // + // SSL/TLS switch + // + Switch { + id: _ssl + opacity: enabled ? 1 : 0.5 + Layout.leftMargin: -app.spacing + checked: Cpp_MQTT_Client.sslEnabled + enabled: !Cpp_MQTT_Client.isConnectedToHost + + onCheckedChanged: { + if (Cpp_MQTT_Client.sslEnabled !== checked) + Cpp_MQTT_Client.sslEnabled = checked + } + } + + // + // Certificate selection + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + ComboBox { + id: _certificateMode + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked + model: [ + qsTr("Use system database"), + qsTr("Custom CA file") + ] + + onCurrentIndexChanged: { + if (currentIndex == 0) + Cpp_MQTT_Client.loadCaFile("") + } + } + + Button { + icon.color: palette.text + opacity: enabled ? 1 : 0.5 + Layout.maximumWidth: height + Layout.alignment: Qt.AlignVCenter + icon.source: "qrc:/icons/open.svg" + onClicked: Cpp_MQTT_Client.loadCaFile() + enabled: _certificateMode.currentIndex == 1 && _ssl.checked + } + } + + // + // Spacers + // + Item { + height: app.spacing + } Item { + height: app.spacing + } + + // + // SSL/TLS protocol selection title + // + Item { + Layout.fillWidth: true + } Label { + text: qsTr("Protocol:") + opacity: enabled ? 1 : 0.5 + enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked + } + + // + // SSL/TLS protocol selection + // + Item { + Layout.fillWidth: true + } ComboBox { + id: _protocols + Layout.fillWidth: true + opacity: enabled ? 1 : 0.5 + model: Cpp_MQTT_Client.sslProtocols + enabled: !Cpp_MQTT_Client.isConnectedToHost && _ssl.checked + + onCurrentIndexChanged: { + if (currentIndex !== Cpp_MQTT_Client.sslProtocol) + Cpp_MQTT_Client.sslProtocol = currentIndex + } + } + } + + // + // Spacer + // + Item { + height: app.spacing + visible: Cpp_MQTT_Client.caFilePath.length > 0 + } + + // + // CA file display + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + visible: Cpp_MQTT_Client.caFilePath.length > 0 + + Label { + font.bold: true + text: qsTr("CA file:") + Layout.alignment: Qt.AlignVCenter + } + + Label { + id: _caFile + text: Cpp_MQTT_Client.caFilePath + onTextChanged: { + if (text !== Cpp_MQTT_Client.caFilePath) + Cpp_MQTT_Client.loadCaFile(text) + } + } + } + + // + // Spacer + // + Item { + height: app.spacing * 2 + visible: Cpp_MQTT_Client.caFilePath.length <= 0 + } + + // + // Buttons + // + RowLayout { + spacing: app.spacing + Layout.fillWidth: true + + Button { + icon.width: 24 + icon.height: 24 + font.bold: true + Layout.fillWidth: true + icon.color: Cpp_ThemeManager.mqttButton + checked: Cpp_MQTT_Client.isConnectedToHost + onClicked: Cpp_MQTT_Client.toggleConnection() + palette.buttonText: Cpp_ThemeManager.mqttButton + text: (checked ? qsTr("Disconnect") : qsTr("Connect")) + " " + icon.source: checked ? "qrc:/icons/disconnect.svg" : + "qrc:/icons/connect.svg" + } + + Button { + icon.width: 24 + icon.height: 24 + Layout.fillWidth: true + onClicked: root.close() + text: qsTr("Apply") + " " + icon.color: palette.buttonText + icon.source: "qrc:/icons/apply.svg" + } + } + } + } } diff --git a/assets/qml/Windows/MainWindow.qml b/assets/qml/Windows/MainWindow.qml index db8522e5..efaacbfb 100644 --- a/assets/qml/Windows/MainWindow.qml +++ b/assets/qml/Windows/MainWindow.qml @@ -34,355 +34,355 @@ import "../FramelessWindow" as FramelessWindow import "../PlatformDependent" as PlatformDependent FramelessWindow.CustomWindow { - id: root + id: root - // - // Quit application when this window is closed - // - onClosed: Qt.quit() + // + // Quit application when this window is closed + // + onClosed: Qt.quit() - // - // Customize window border - // - showIcon: true - borderWidth: 1 - borderColor: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) + // + // Customize window border + // + showIcon: true + borderWidth: 1 + borderColor: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) - // - // Global properties - // - readonly property bool setupVisible: setup.visible - readonly property bool consoleVisible: terminal.visible - readonly property bool dashboardVisible: dashboard.visible + // + // Global properties + // + readonly property bool setupVisible: setup.visible + readonly property bool consoleVisible: terminal.visible + readonly property bool dashboardVisible: dashboard.visible - // - // Custom properties - // - property int appLaunchCount: 0 - property bool firstValidFrame: false - property bool automaticUpdates: false - property alias vt100emulation: terminal.vt100emulation + // + // Custom properties + // + property int appLaunchCount: 0 + property bool firstValidFrame: false + property bool automaticUpdates: false + property alias vt100emulation: terminal.vt100emulation - // - // Toolbar functions aliases - // - function showSetup() { toolbar.setupClicked() } - function showConsole() { toolbar.consoleClicked() } - function showDashboard() { dbTimer.start() } + // + // Toolbar functions aliases + // + function showSetup() { toolbar.setupClicked() } + function showConsole() { toolbar.consoleClicked() } + function showDashboard() { dbTimer.start() } - // - // Wait a little before showing the dashboard to avoid UI glitches and/or overloading - // the rendering engine - // - Timer { - id: dbTimer - interval: 500 - onTriggered: toolbar.dashboardClicked() + // + // Wait a little before showing the dashboard to avoid UI glitches and/or overloading + // the rendering engine + // + Timer { + id: dbTimer + interval: 500 + onTriggered: toolbar.dashboardClicked() + } + + // + // Console-related functions + // + function consoleCopy() { terminal.copy() } + function consoleClear() { terminal.clear() } + function consoleSelectAll() { terminal.selectAll() } + + // + // Window geometry + // + visible: false + title: Cpp_AppName + width: minimumWidth + height: minimumHeight + minimumWidth: 1120 + 2 * root.shadowMargin + backgroundColor: Cpp_ThemeManager.windowBackground + minimumHeight: 650 + 2 * root.shadowMargin + root.titlebar.height + + // + // Startup code + // + Component.onCompleted: { + // Load welcome text + terminal.showWelcomeGuide() + + // Increment app launch count + ++appLaunchCount + + // Show app window + if (root.isFullscreen) + root.showFullScreen() + else if (root.isMaximized) + root.showMaximized() + else { + // Fix maximize not working on first try on macOS & Windows + root.opacity = 0 + var x = root.x + var y = root.y + var w = root.width + var h = root.height + root.showMaximized() + root.showNormal() + root.setGeometry(x, y, w,h) + root.opacity = 1 + } + + // Force active focus + root.requestActivate() + root.requestUpdate() + + // Show donations dialog every 15 launches + if (root.appLaunchCount % 15 == 0 && !app.donateDialog.doNotShowAgain) + app.donateDialog.showAutomatically() + + // Ask user if he/she wants to enable automatic updates + if (root.appLaunchCount == 2 && Cpp_UpdaterEnabled) { + if (Cpp_Misc_Utilities.askAutomaticUpdates()) { + root.automaticUpdates = true + Cpp_Updater.checkForUpdates(Cpp_AppUpdaterUrl) + } + + else + root.automaticUpdates = false + } + + // Check for updates (if we are allowed) + if (root.automaticUpdates && Cpp_UpdaterEnabled) + Cpp_Updater.checkForUpdates(Cpp_AppUpdaterUrl) + } + + // + // Hide console & device manager when we receive first valid frame + // + Connections { + target: Cpp_UI_Dashboard + + function onUpdated() { + if (root.firstValidFrame) + return + + if ((Cpp_IO_Manager.connected || Cpp_CSV_Player.isOpen) && Cpp_UI_Dashboard.frameValid()) { + setup.hide() + root.showDashboard() + root.firstValidFrame = true + } + + else { + setup.show() + root.showConsole() + root.firstValidFrame = false + } + } + } + + // + // Show console tab on serial disconnect + // + Connections { + target: Cpp_UI_Dashboard + function onDataReset() { + setup.show() + root.showConsole() + root.firstValidFrame = false + } + } + + // + // Save window size & position + // + Settings { + property alias wx: root.x + property alias wy: root.y + property alias ww: root.width + property alias wh: root.height + property alias wm: root.isMaximized + property alias wf: root.isFullscreen + property alias appStatus: root.appLaunchCount + property alias autoUpdater: root.automaticUpdates + } + + // + // macOS menubar loader + // + Loader { + active: Cpp_IsMac + asynchronous: false + sourceComponent: PlatformDependent.MenubarMacOS {} + } + + // + // Rectangle for the menubar (only used if custom window flags are disabled) + // + Rectangle { + color: root.titlebarColor + anchors.fill: menubarLayout + visible: !Cpp_ThemeManager.customWindowDecorations + } + + // + // Menubar, shown by default on Windows & Linux and when the app is fullscreen + // + RowLayout { + id: menubarLayout + z: titlebar.z + 1 + spacing: app.spacing + height: !showMenubar ? titlebar.height : 38 + + readonly property bool showMenubar: !root.showMacControls || isFullscreen + + anchors { + top: parent.top + left: parent.left + right: parent.right + leftMargin: root.leftTitlebarMargin + root.shadowMargin + rightMargin: root.rightTitlebarMargin + root.shadowMargin + topMargin: root.shadowMargin + (!root.showMacControls ? 1 : 0) } // - // Console-related functions - // - function consoleCopy() { terminal.copy() } - function consoleClear() { terminal.clear() } - function consoleSelectAll() { terminal.selectAll() } - - // - // Window geometry - // - visible: false - title: Cpp_AppName - width: minimumWidth - height: minimumHeight - minimumWidth: 1120 + 2 * root.shadowMargin - backgroundColor: Cpp_ThemeManager.windowBackground - minimumHeight: 650 + 2 * root.shadowMargin + root.titlebar.height - - // - // Startup code - // - Component.onCompleted: { - // Load welcome text - terminal.showWelcomeGuide() - - // Increment app launch count - ++appLaunchCount - - // Show app window - if (root.isFullscreen) - root.showFullScreen() - else if (root.isMaximized) - root.showMaximized() - else { - // Fix maximize not working on first try on macOS & Windows - root.opacity = 0 - var x = root.x - var y = root.y - var w = root.width - var h = root.height - root.showMaximized() - root.showNormal() - root.setGeometry(x, y, w,h) - root.opacity = 1 - } - - // Force active focus - root.requestActivate() - root.requestUpdate() - - // Show donations dialog every 15 launches - if (root.appLaunchCount % 15 == 0 && !app.donateDialog.doNotShowAgain) - app.donateDialog.showAutomatically() - - // Ask user if he/she wants to enable automatic updates - if (root.appLaunchCount == 2 && Cpp_UpdaterEnabled) { - if (Cpp_Misc_Utilities.askAutomaticUpdates()) { - root.automaticUpdates = true - Cpp_Updater.checkForUpdates(Cpp_AppUpdaterUrl) - } - - else - root.automaticUpdates = false - } - - // Check for updates (if we are allowed) - if (root.automaticUpdates && Cpp_UpdaterEnabled) - Cpp_Updater.checkForUpdates(Cpp_AppUpdaterUrl) - } - - // - // Hide console & device manager when we receive first valid frame - // - Connections { - target: Cpp_UI_Dashboard - - function onUpdated() { - if (root.firstValidFrame) - return - - if ((Cpp_IO_Manager.connected || Cpp_CSV_Player.isOpen) && Cpp_UI_Dashboard.frameValid()) { - setup.hide() - root.showDashboard() - root.firstValidFrame = true - } - - else { - setup.show() - root.showConsole() - root.firstValidFrame = false - } - } - } - - // - // Show console tab on serial disconnect - // - Connections { - target: Cpp_UI_Dashboard - function onDataReset() { - setup.show() - root.showConsole() - root.firstValidFrame = false - } - } - - // - // Save window size & position - // - Settings { - property alias wx: root.x - property alias wy: root.y - property alias ww: root.width - property alias wh: root.height - property alias wm: root.isMaximized - property alias wf: root.isFullscreen - property alias appStatus: root.appLaunchCount - property alias autoUpdater: root.automaticUpdates - } - - // - // macOS menubar loader + // Menubar // Loader { - active: Cpp_IsMac - asynchronous: false - sourceComponent: PlatformDependent.MenubarMacOS {} + opacity: 0.8 + asynchronous: false + Layout.alignment: Qt.AlignVCenter + sourceComponent: PlatformDependent.Menubar { + enabled: !root.showMacControls || isFullscreen + visible: !root.showMacControls || isFullscreen + } } // - // Rectangle for the menubar (only used if custom window flags are disabled) + // Spacer // - Rectangle { - color: root.titlebarColor - anchors.fill: menubarLayout - visible: !Cpp_ThemeManager.customWindowDecorations + Item { + Layout.fillWidth: true + } + } + + // + // Main layout + // + Page { + clip: true + anchors.fill: parent + anchors.margins: root.shadowMargin + anchors.topMargin: menubarLayout.height + root.shadowMargin + + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText + + background: Rectangle { + radius: root.radius + color: Cpp_ThemeManager.windowBackground } - // - // Menubar, shown by default on Windows & Linux and when the app is fullscreen - // - RowLayout { - id: menubarLayout - z: titlebar.z + 1 - spacing: app.spacing - height: !showMenubar ? titlebar.height : 38 + ColumnLayout { + spacing: 0 + anchors.fill: parent - readonly property bool showMenubar: !root.showMacControls || isFullscreen - - anchors { - top: parent.top - left: parent.left - right: parent.right - leftMargin: root.leftTitlebarMargin + root.shadowMargin - rightMargin: root.rightTitlebarMargin + root.shadowMargin - topMargin: root.shadowMargin + (!root.showMacControls ? 1 : 0) - } - - // - // Menubar - // - Loader { - opacity: 0.8 - asynchronous: false - Layout.alignment: Qt.AlignVCenter - sourceComponent: PlatformDependent.Menubar { - enabled: !root.showMacControls || isFullscreen - visible: !root.showMacControls || isFullscreen - } - } - - // - // Spacer - // - Item { - Layout.fillWidth: true - } - } - - // - // Main layout - // - Page { - clip: true - anchors.fill: parent - anchors.margins: root.shadowMargin - anchors.topMargin: menubarLayout.height + root.shadowMargin - - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText - - background: Rectangle { - radius: root.radius - color: Cpp_ThemeManager.windowBackground - } - - ColumnLayout { - spacing: 0 - anchors.fill: parent - - // - // Application toolbar - // - Toolbar { - id: toolbar - window: root - z: titlebar.z - Layout.fillWidth: true - Layout.minimumHeight: 48 - Layout.maximumHeight: 48 - setupChecked: root.setupVisible - consoleChecked: root.consoleVisible - dashboardChecked: root.dashboardVisible - onProjectEditorClicked: app.projectEditorWindow.show() - onSetupClicked: setup.visible ? setup.hide() : setup.show() - - onDashboardClicked: { - if (Cpp_UI_Dashboard.available) { - consoleChecked = 0 - dashboardChecked = 1 - if (stack.currentItem != dashboard) - stack.push(dashboard) - } - - else - root.showConsole() - } - - onConsoleClicked: { - consoleChecked = 1 - dashboardChecked = 0 - stack.pop() - } - } - - // - // Console, dashboard & setup panel - // - RowLayout { - spacing: 0 - Layout.fillWidth: true - Layout.fillHeight: true - - StackView { - id: stack - clip: true - initialItem: terminal - Layout.fillWidth: true - Layout.fillHeight: true - data: [ - Console { - id: terminal - visible: false - width: parent.width - height: parent.height - }, - - Dashboard { - id: dashboard - visible: false - width: parent.width - height: parent.height - } - ] - } - - Setup { - id: setup - Layout.fillHeight: true - Layout.rightMargin: setupMargin - Layout.minimumWidth: displayedWidth - Layout.maximumWidth: displayedWidth - } - } - } - } - - // - // JSON project drop area - // - JSONDropArea { - anchors.fill: parent - enabled: !Cpp_IO_Manager.connected - } - - // - // Resize handler - // - FramelessWindow.ResizeHandles { + // + // Application toolbar + // + Toolbar { + id: toolbar window: root - anchors.fill: parent - handleSize: root.handleSize + z: titlebar.z + Layout.fillWidth: true + Layout.minimumHeight: 48 + Layout.maximumHeight: 48 + setupChecked: root.setupVisible + consoleChecked: root.consoleVisible + dashboardChecked: root.dashboardVisible + onProjectEditorClicked: app.projectEditorWindow.show() + onSetupClicked: setup.visible ? setup.hide() : setup.show() + + onDashboardClicked: { + if (Cpp_UI_Dashboard.available) { + consoleChecked = 0 + dashboardChecked = 1 + if (stack.currentItem != dashboard) + stack.push(dashboard) + } + + else + root.showConsole() + } + + onConsoleClicked: { + consoleChecked = 1 + dashboardChecked = 0 + stack.pop() + } + } + + // + // Console, dashboard & setup panel + // + RowLayout { + spacing: 0 + Layout.fillWidth: true + Layout.fillHeight: true + + StackView { + id: stack + clip: true + initialItem: terminal + Layout.fillWidth: true + Layout.fillHeight: true + data: [ + Console { + id: terminal + visible: false + width: parent.width + height: parent.height + }, + + Dashboard { + id: dashboard + visible: false + width: parent.width + height: parent.height + } + ] + } + + Setup { + id: setup + Layout.fillHeight: true + Layout.rightMargin: setupMargin + Layout.minimumWidth: displayedWidth + Layout.maximumWidth: displayedWidth + } + } } + } + + // + // JSON project drop area + // + JSONDropArea { + anchors.fill: parent + enabled: !Cpp_IO_Manager.connected + } + + // + // Resize handler + // + FramelessWindow.ResizeHandles { + window: root + anchors.fill: parent + handleSize: root.handleSize + } } diff --git a/assets/qml/Windows/ProjectEditor.qml b/assets/qml/Windows/ProjectEditor.qml index 206437b1..3cfcb4dc 100644 --- a/assets/qml/Windows/ProjectEditor.qml +++ b/assets/qml/Windows/ProjectEditor.qml @@ -31,139 +31,139 @@ import "../Widgets" as Widgets import "../FramelessWindow" as FramelessWindow FramelessWindow.CustomWindow { - id: root + id: root - // - // Window options - // - minimumWidth: 910 - minimumHeight: 720 - title: qsTr("Project Editor - %1").arg(Cpp_Project_Model.jsonFileName) + // + // Window options + // + minimumWidth: 910 + minimumHeight: 720 + title: qsTr("Project Editor - %1").arg(Cpp_Project_Model.jsonFileName) - // - // Customize window border - // - borderWidth: 1 - borderColor: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) + // + // Customize window border + // + borderWidth: 1 + borderColor: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5) - // - // Ensure that current JSON file is shown - // - Component.onCompleted: Cpp_Project_Model.openJsonFile(Cpp_JSON_Generator.jsonMapFilepath) + // + // Ensure that current JSON file is shown + // + Component.onCompleted: Cpp_Project_Model.openJsonFile(Cpp_JSON_Generator.jsonMapFilepath) - // - // Ask user to save changes before closing the window - // - onClosing: (close) => close.accepted = Cpp_Project_Model.askSave() + // + // Ask user to save changes before closing the window + // + onClosing: (close) => close.accepted = Cpp_Project_Model.askSave() - // - // Dummy string to increase width of buttons - // - readonly property string _btSpacer: " " + // + // Dummy string to increase width of buttons + // + readonly property string _btSpacer: " " - // - // Save window size - // - Settings { - category: "ProjectEditor" - property alias windowX: root.x - property alias windowY: root.y - property alias windowWidth: root.width - property alias windowHeight: root.height + // + // Save window size + // + Settings { + category: "ProjectEditor" + property alias windowX: root.x + property alias windowY: root.y + property alias windowWidth: root.width + property alias windowHeight: root.height + } + + // + // Use page item to set application palette + // + Page { + clip: true + anchors.fill: parent + anchors.margins: root.shadowMargin + anchors.topMargin: titlebar.height + root.shadowMargin + + palette.alternateBase: Cpp_ThemeManager.base + palette.base: Cpp_ThemeManager.base + palette.brightText: Cpp_ThemeManager.brightText + palette.button: Cpp_ThemeManager.button + palette.buttonText: Cpp_ThemeManager.buttonText + palette.highlight: Cpp_ThemeManager.highlight + palette.highlightedText: Cpp_ThemeManager.highlightedText + palette.link: Cpp_ThemeManager.link + palette.placeholderText: Cpp_ThemeManager.placeholderText + palette.text: Cpp_ThemeManager.text + palette.toolTipBase: Cpp_ThemeManager.tooltipBase + palette.toolTipText: Cpp_ThemeManager.tooltipText + palette.window: Cpp_ThemeManager.window + palette.windowText: Cpp_ThemeManager.windowText + + background: Rectangle { + radius: root.radius + color: Cpp_ThemeManager.windowBackground } // - // Use page item to set application palette + // Shadows // - Page { - clip: true - anchors.fill: parent - anchors.margins: root.shadowMargin - anchors.topMargin: titlebar.height + root.shadowMargin + Widgets.Shadow { + anchors.fill: header + } Widgets.Shadow { + anchors.fill: footer + anchors.bottomMargin: footer.height / 2 + } - palette.alternateBase: Cpp_ThemeManager.base - palette.base: Cpp_ThemeManager.base - palette.brightText: Cpp_ThemeManager.brightText - palette.button: Cpp_ThemeManager.button - palette.buttonText: Cpp_ThemeManager.buttonText - palette.highlight: Cpp_ThemeManager.highlight - palette.highlightedText: Cpp_ThemeManager.highlightedText - palette.link: Cpp_ThemeManager.link - palette.placeholderText: Cpp_ThemeManager.placeholderText - palette.text: Cpp_ThemeManager.text - palette.toolTipBase: Cpp_ThemeManager.tooltipBase - palette.toolTipText: Cpp_ThemeManager.tooltipText - palette.window: Cpp_ThemeManager.window - palette.windowText: Cpp_ThemeManager.windowText + // + // Header (project properties) + // + Header { + id: header + anchors { + margins: 0 + top: parent.top + left: parent.left + right: parent.right + } + } - background: Rectangle { - radius: root.radius - color: Cpp_ThemeManager.windowBackground - } + // + // Footer background + // + Footer { + id: footer + radius: root.radius + onCloseWindow: root.close() + onScrollToBottom: groupEditor.selectLastGroup() - // - // Shadows - // - Widgets.Shadow { - anchors.fill: header - } Widgets.Shadow { - anchors.fill: footer - anchors.bottomMargin: footer.height / 2 - } + anchors { + margins: 0 + left: parent.left + right: parent.right + bottom: parent.bottom + } + } - // - // Header (project properties) - // - Header { - id: header - anchors { - margins: 0 - top: parent.top - left: parent.left - right: parent.right - } - } + // + // Window controls + // + RowLayout { + clip: true + anchors.fill: parent + spacing: app.spacing + anchors.topMargin: header.height + anchors.bottomMargin: footer.height - // - // Footer background - // - Footer { - id: footer - radius: root.radius - onCloseWindow: root.close() - onScrollToBottom: groupEditor.selectLastGroup() + // + // Horizontal spacer + // + Item { + Layout.fillHeight: true + Layout.minimumWidth: app.spacing + Layout.maximumWidth: app.spacing + } - anchors { - margins: 0 - left: parent.left - right: parent.right - bottom: parent.bottom - } - } - - // - // Window controls - // - RowLayout { - clip: true - anchors.fill: parent - spacing: app.spacing - anchors.topMargin: header.height - anchors.bottomMargin: footer.height - - // - // Horizontal spacer - // - Item { - Layout.fillHeight: true - Layout.minimumWidth: app.spacing - Layout.maximumWidth: app.spacing - } - - // - // JSON structure tree - // - /*TreeView { + // + // JSON structure tree + // + /*TreeView { id: jsonTree Layout.fillHeight: true Layout.minimumWidth: 240 @@ -173,69 +173,69 @@ FramelessWindow.CustomWindow { visible: Cpp_Project_Model.groupCount !== 0 }*/ - // - // Group editor - // - GroupEditor { - id: groupEditor - Layout.fillWidth: true - Layout.fillHeight: true - visible: Cpp_Project_Model.groupCount !== 0 - } + // + // Group editor + // + GroupEditor { + id: groupEditor + Layout.fillWidth: true + Layout.fillHeight: true + visible: Cpp_Project_Model.groupCount !== 0 + } - // - // Empty project text & icon - // - Item { - Layout.fillWidth: true - Layout.fillHeight: true - visible: Cpp_Project_Model.groupCount === 0 + // + // Empty project text & icon + // + Item { + Layout.fillWidth: true + Layout.fillHeight: true + visible: Cpp_Project_Model.groupCount === 0 - ColumnLayout { - spacing: app.spacing - anchors.centerIn: parent + ColumnLayout { + spacing: app.spacing + anchors.centerIn: parent - Widgets.Icon { - width: 128 - height: 128 - color: Cpp_ThemeManager.text - Layout.alignment: Qt.AlignHCenter - source: "qrc:/icons/developer-board.svg" - } + Widgets.Icon { + width: 128 + height: 128 + color: Cpp_ThemeManager.text + Layout.alignment: Qt.AlignHCenter + source: "qrc:/icons/developer-board.svg" + } - Label { - font.bold: true - font.pixelSize: 24 - Layout.alignment: Qt.AlignHCenter - text: qsTr("Start something awesome") - } + Label { + font.bold: true + font.pixelSize: 24 + Layout.alignment: Qt.AlignHCenter + text: qsTr("Start something awesome") + } - Label { - opacity: 0.8 - font.pixelSize: 18 - Layout.alignment: Qt.AlignHCenter - text: qsTr("Click on the \"Add group\" button to begin") - } - } - } - - // - // Horizontal spacer - // - Item { - Layout.fillHeight: true - Layout.minimumWidth: app.spacing - Layout.maximumWidth: app.spacing - } + Label { + opacity: 0.8 + font.pixelSize: 18 + Layout.alignment: Qt.AlignHCenter + text: qsTr("Click on the \"Add group\" button to begin") + } } - } + } - // - // Resize handler - // - FramelessWindow.ResizeHandles { - window: root - anchors.fill: parent - handleSize: root.handleSize + // + // Horizontal spacer + // + Item { + Layout.fillHeight: true + Layout.minimumWidth: app.spacing + Layout.maximumWidth: app.spacing + } } + } + + // + // Resize handler + // + FramelessWindow.ResizeHandles { + window: root + anchors.fill: parent + handleSize: root.handleSize + } } diff --git a/assets/qml/main.qml b/assets/qml/main.qml index 2e492b18..f5610c84 100644 --- a/assets/qml/main.qml +++ b/assets/qml/main.qml @@ -27,92 +27,92 @@ import QtQuick.Controls import "Windows" as Windows Item { - id: app + id: app - // - // Global propeties - // - readonly property int spacing: 8 - readonly property string monoFont: "Roboto Mono" + // + // Global propeties + // + readonly property int spacing: 8 + readonly property string monoFont: "Roboto Mono" - // - // Access to dialogs & windows - // - property Windows.About aboutDialog: null - property Windows.Donate donateDialog: null - property Windows.MainWindow mainWindow: null - property Windows.CsvPlayer csvPlayerDialog: null - property Windows.ProjectEditor projectEditorWindow: null - property Windows.Acknowledgements acknowledgementsDialog: null + // + // Access to dialogs & windows + // + property Window aboutDialog: null + property Window donateDialog: null + property Window mainWindow: null + property Window csvPlayerDialog: null + property Window projectEditorWindow: null + property Window acknowledgementsDialog: null - // - // Check for updates (non-silent mode) - // - function checkForUpdates() { - Cpp_Updater.setNotifyOnFinish(Cpp_AppUpdaterUrl, true) - Cpp_Updater.checkForUpdates(Cpp_AppUpdaterUrl) + // + // Check for updates (non-silent mode) + // + function checkForUpdates() { + Cpp_Updater.setNotifyOnFinish(Cpp_AppUpdaterUrl, true) + Cpp_Updater.checkForUpdates(Cpp_AppUpdaterUrl) + } + + // + // MainWindow + // + Loader { + asynchronous: true + sourceComponent: Windows.MainWindow { + Component.onCompleted: { + app.forceActiveFocus() + app.mainWindow = this + } } + } - // - // MainWindow - // - Loader { - asynchronous: true - sourceComponent: Windows.MainWindow { - Component.onCompleted: { - app.forceActiveFocus() - app.mainWindow = this - } - } + // + // About window + // + Loader { + asynchronous: true + sourceComponent: Windows.About { + Component.onCompleted: app.aboutDialog = this } + } - // - // About window - // - Loader { - asynchronous: true - sourceComponent: Windows.About { - Component.onCompleted: app.aboutDialog = this - } + // + // CSV player window + // + Loader { + asynchronous: true + sourceComponent: Windows.CsvPlayer { + Component.onCompleted: app.csvPlayerDialog = this } + } - // - // CSV player window - // - Loader { - asynchronous: true - sourceComponent: Windows.CsvPlayer { - Component.onCompleted: app.csvPlayerDialog = this - } + // + // Project editor dialog + // + Loader { + asynchronous: true + sourceComponent: Windows.ProjectEditor { + Component.onCompleted: app.projectEditorWindow = this } + } - // - // Project editor dialog - // - Loader { - asynchronous: true - sourceComponent: Windows.ProjectEditor { - Component.onCompleted: app.projectEditorWindow = this - } + // + // Donations dialog + // + Loader { + asynchronous: false + sourceComponent: Windows.Donate { + Component.onCompleted: app.donateDialog = this } + } - // - // Donations dialog - // - Loader { - asynchronous: false - sourceComponent: Windows.Donate { - Component.onCompleted: app.donateDialog = this - } - } - - // - // Acknowledgements dialog - // - Loader { - asynchronous: true - sourceComponent: Windows.Acknowledgements { - Component.onCompleted: app.acknowledgementsDialog = this - } + // + // Acknowledgements dialog + // + Loader { + asynchronous: true + sourceComponent: Windows.Acknowledgements { + Component.onCompleted: app.acknowledgementsDialog = this } + } } diff --git a/assets/touchbar/console.png b/assets/touchbar/console.png deleted file mode 100644 index c5d45dcf..00000000 Binary files a/assets/touchbar/console.png and /dev/null differ diff --git a/assets/touchbar/dashboard.png b/assets/touchbar/dashboard.png deleted file mode 100644 index d29f869b..00000000 Binary files a/assets/touchbar/dashboard.png and /dev/null differ diff --git a/assets/touchbar/setup.png b/assets/touchbar/setup.png deleted file mode 100644 index f26e8c91..00000000 Binary files a/assets/touchbar/setup.png and /dev/null differ diff --git a/deploy/linux/serial-studio.desktop b/deploy/linux/serial-studio.desktop index 427b812c..a7619fc4 100644 --- a/deploy/linux/serial-studio.desktop +++ b/deploy/linux/serial-studio.desktop @@ -8,5 +8,5 @@ StartupNotify=true Categories=Electronics;Engineering;Science; Icon=serial-studio X-AppImage-Name=Serial Studio -X-AppImage-Version=2.0.0 +X-AppImage-Version=2.1.0 X-AppImage-Arch=x86_64 diff --git a/deploy/windows/nsis/setup.nsi b/deploy/windows/nsis/setup.nsi index 0944bd3f..d5b6f0a3 100644 --- a/deploy/windows/nsis/setup.nsi +++ b/deploy/windows/nsis/setup.nsi @@ -31,7 +31,7 @@ Unicode True !define COMPANYNAME "Alex Spataru" !define DESCRIPTION "Multi-purpose data visualization & processing program" !define VERSIONMAJOR 2 -!define VERSIONMINOR 0 +!define VERSIONMINOR 1 !define VERSIONBUILD 0 !define MUI_ABORTWARNING !define INSTALL_DIR "$PROGRAMFILES64\${APPNAME}" diff --git a/libs/KDMacTouchBar/.gitignore b/libs/KDMacTouchBar/.gitignore deleted file mode 100644 index 474c123a..00000000 --- a/libs/KDMacTouchBar/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -*.moc -*.o -lib -.qmake.cache -.qmake.stash -.DS_Store diff --git a/libs/KDMacTouchBar/.krazy b/libs/KDMacTouchBar/.krazy deleted file mode 100644 index 18d712b6..00000000 --- a/libs/KDMacTouchBar/.krazy +++ /dev/null @@ -1,16 +0,0 @@ -CHECKSETS qt5,c++,foss - -#KDAB-specific checks -EXTRA kdabcopyright,kdabcontactus - -#additional checks -#EXTRA defines,null - -#exclude checks now being done by clazy or clang-tools -EXCLUDE strings,explicit,normalize,passbyvalue,operators,nullstrcompare,nullstrassign,doublequote_chars,qobject,sigsandslots,staticobjects -#exclude more checks -EXCLUDE style - -#skip the borrowed code in the cmake subdir -SKIP /cmake/Qt5Portability.cmake - diff --git a/libs/KDMacTouchBar/CMakeLists.txt b/libs/KDMacTouchBar/CMakeLists.txt deleted file mode 100644 index 0c9d9a78..00000000 --- a/libs/KDMacTouchBar/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) - -if("${CMAKE_INSTALL_PREFIX}" STREQUAL "") - set(USE_DEFAULT_INSTALL_LOCATION True) -else() - set(USE_DEFAULT_INSTALL_LOCATION False) -endif() - -project(KDMacTouchBar CXX) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) -endif() - -set(${PROJECT_NAME}_VERSION_MAJOR 1) -set(${PROJECT_NAME}_VERSION_MINOR 0) -set(${PROJECT_NAME}_VERSION_PATCH 0) -set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}) - -if(CMAKE_VERSION VERSION_LESS "3.1") - if(CMAKE_COMPILER_IS_GNUCXX) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif () -else() - set(CMAKE_CXX_STANDARD 11) -endif() - -if(USE_DEFAULT_INSTALL_LOCATION) - set(CMAKE_INSTALL_PREFIX "/usr/local/KDAB/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}" CACHE STRING "" FORCE) -endif() - -message(STATUS "Building ${PROJECT_NAME} ${${PROJECT_NAME}_VERSION} in ${CMAKE_BUILD_TYPE} mode. Installing to ${CMAKE_INSTALL_PREFIX}") - -find_package(Qt5Core REQUIRED) -find_package(Qt5Widgets REQUIRED) - -set(CMAKE_AUTOMOC TRUE) -set(QT_LIBRARIES Qt5::Widgets) -set(QT_USE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Qt5Portability.cmake") - -install(FILES - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/KDMacTouchBarConfig.cmake" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake") - -add_subdirectory(src) -add_subdirectory(examples) diff --git a/libs/KDMacTouchBar/LICENSE.LGPL.txt b/libs/KDMacTouchBar/LICENSE.LGPL.txt deleted file mode 100644 index a106daab..00000000 --- a/libs/KDMacTouchBar/LICENSE.LGPL.txt +++ /dev/null @@ -1,175 +0,0 @@ - - KDMacTouchBar is Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB. - - You may use, distribute and copy KDMacTouchBar under the terms of - GNU Lesser General Public License version 3, which is displayed below. - - You may even contact us at info@kdab.com for different licensing options. - -------------------------------------------------------------------------- - - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/libs/KDMacTouchBar/README.md b/libs/KDMacTouchBar/README.md deleted file mode 100644 index f86207b5..00000000 --- a/libs/KDMacTouchBar/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# KDMacTouchBar -KDAB's Qt Widget for the Mac Touch Bar - -## Introduction -The KDMacTouchBar class wraps the native NSTouchBar class. - -KDMacTouchBar provides a Qt-based API for NSTouchBar. The touchbar displays -a number of QActions. Each QAction can have a text and an icon. Alternatively, -the QActions might be separators (with or without text) or QWidgetActions. - -Add actions by calling addAction(). Alternatively, you can use one of the -convenience methods like addDialogButtonBox() or addTabBar() which provide -common use cases. - -If an action with a associated menu is added, its menu items are added as -sub-touchbar. Showing sub-menus of this menu is not supported, due to macOS -system restrictions. - -## Usage: -``` -QMainWindow *mw = ...; -KDMacTouchBar *touchBar = new KDMacTouchBar(mw); -touchBar->addAction(actionNewFile); -touchBar->addSeparator(); -touchBar->addAction(actionSaveFile); -``` - -## Licensing: -KD MacTouchBar is (C) 2019-2021, Klarälvdalens Datakonsult AB, -and is available under the terms of: - -* the LGPL (see LICENSE.LGPL.txt for details) -* the KDAB commercial license, provided that you buy a license. - please contact info@kdab.com if you are interested in buying commercial licenses. - -## Get Involved: -KDAB will happily accept external contributions; however, **all** -contributions will require a signed Contributor License Agreement -(see docs/KDMacTouchBar-CopyrightAssignmentForm.pdf). - -Contact info@kdab.com for more information. - -Please submit your contributions or issue reports from our GitHub space at -https://github.com/KDAB/KDMacTouchBar - -## About KDAB -KD MacTouchBar is supported and maintained by Klarälvdalens Datakonsult AB (KDAB). - -The KDAB Group is the global No.1 software consultancy for Qt, C++ and -OpenGL applications across desktop, embedded and mobile platforms. - -The KDAB Group provides consulting and mentoring for developing Qt applications -from scratch and in porting from all popular and legacy frameworks to Qt. -We continue to help develop parts of Qt and are one of the major contributors -to the Qt Project. We can give advanced or standard trainings anywhere -around the globe on Qt as well as C++, OpenGL, 3D and more. - -Please visit https://www.kdab.com to meet the people who write code like this. - -Stay up-to-date with KDAB product announcements: - -* [KDAB Newsletter](https://news.kdab.com) -* [KDAB Blogs](https://www.kdab.com/category/blogs) -* [KDAB on Twitter](https://twitter.com/KDABQt) diff --git a/libs/KDMacTouchBar/cmake/KDMacTouchBarConfig.cmake b/libs/KDMacTouchBar/cmake/KDMacTouchBarConfig.cmake deleted file mode 100644 index 16e70b62..00000000 --- a/libs/KDMacTouchBar/cmake/KDMacTouchBarConfig.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(KDMacTouchBar_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../KDMacTouchBar.framework/Headers) -set(KDMacTouchBar_LIBRARIES ${CMAKE_CURRENT_LIST_DIR}/../KDMacTouchBar.framework/Versions/Current/KDMacTouchBar) diff --git a/libs/KDMacTouchBar/cmake/Qt5Portability.cmake b/libs/KDMacTouchBar/cmake/Qt5Portability.cmake deleted file mode 100644 index 313b845a..00000000 --- a/libs/KDMacTouchBar/cmake/Qt5Portability.cmake +++ /dev/null @@ -1,32 +0,0 @@ - -include_directories(${Qt5Widgets_INCLUDE_DIRS}) - -if(QT_USE_QTNETWORK) - find_package(Qt5Network REQUIRED) - list(APPEND QT_LIBRARIES Qt5::Network) - include_directories(${Qt5Network_INCLUDE_DIRS}) -endif() - -if(QT_USE_QTXML) - find_package(Qt5Xml REQUIRED) - list(APPEND QT_LIBRARIES Qt5::Xml) - include_directories(${Qt5Xml_INCLUDE_DIRS}) -endif() - -if(QT_USE_QTTEST) - find_package(Qt5Test REQUIRED) - list(APPEND QT_LIBRARIES Qt5::Test) - include_directories(${Qt5Test_INCLUDE_DIRS}) -endif() - -macro(qt4_wrap_ui) - qt5_wrap_ui(${ARGN}) -endmacro() - -macro(qt4_wrap_cpp) - qt5_wrap_cpp(${ARGN}) -endmacro() - -macro(qt4_add_resources) - qt5_add_resources(${ARGN}) -endmacro() diff --git a/libs/KDMacTouchBar/docs/KDMacTouchBar-CopyrightAssignmentForm.pdf b/libs/KDMacTouchBar/docs/KDMacTouchBar-CopyrightAssignmentForm.pdf deleted file mode 100644 index 6f3be3df..00000000 Binary files a/libs/KDMacTouchBar/docs/KDMacTouchBar-CopyrightAssignmentForm.pdf and /dev/null differ diff --git a/libs/KDMacTouchBar/examples/CMakeLists.txt b/libs/KDMacTouchBar/examples/CMakeLists.txt deleted file mode 100644 index 0dfdd522..00000000 --- a/libs/KDMacTouchBar/examples/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(mactouchbar) diff --git a/libs/KDMacTouchBar/examples/examples.pro b/libs/KDMacTouchBar/examples/examples.pro deleted file mode 100644 index 6a784978..00000000 --- a/libs/KDMacTouchBar/examples/examples.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE=subdirs - -SUBDIRS=mactouchbar diff --git a/libs/KDMacTouchBar/examples/mactouchbar/CMakeLists.txt b/libs/KDMacTouchBar/examples/mactouchbar/CMakeLists.txt deleted file mode 100644 index 9ce3b5a1..00000000 --- a/libs/KDMacTouchBar/examples/mactouchbar/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include(${QT_USE_FILE}) - -set(CMAKE_AUTORCC ON) -set(CMAKE_MACOSX_RPATH 1) -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - -add_executable(mactouchbar MACOSX_BUNDLE - main.cpp - mainwindow.cpp - mainwindow.h - mactouchbar.qrc) - -include_directories(../../src) - -install(TARGETS mactouchbar - DESTINATION "${CMAKE_INSTALL_PREFIX}/examples/mactouchbar") - -target_link_libraries(mactouchbar KDMacTouchBar) diff --git a/libs/KDMacTouchBar/examples/mactouchbar/mactouchbar.pro b/libs/KDMacTouchBar/examples/mactouchbar/mactouchbar.pro deleted file mode 100644 index b1e80ac6..00000000 --- a/libs/KDMacTouchBar/examples/mactouchbar/mactouchbar.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets - -HEADERS += mainwindow.h -SOURCES += mainwindow.cpp main.cpp -RESOURCES += mactouchbar.qrc - -INCLUDEPATH = ../../src -LIBS += -F../../lib -framework KDMacTouchBar -QMAKE_LFLAGS = '-Wl,-rpath,\'$$OUT_PWD/../../lib\',-rpath,\'$$INSTALL_PREFIX/lib\'' - -target.path = "$${INSTALL_PREFIX}/examples/mactouchbar" -INSTALLS += target diff --git a/libs/KDMacTouchBar/examples/mactouchbar/mactouchbar.qrc b/libs/KDMacTouchBar/examples/mactouchbar/mactouchbar.qrc deleted file mode 100644 index 04a94195..00000000 --- a/libs/KDMacTouchBar/examples/mactouchbar/mactouchbar.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - qtlogo.png - - diff --git a/libs/KDMacTouchBar/examples/mactouchbar/main.cpp b/libs/KDMacTouchBar/examples/mactouchbar/main.cpp deleted file mode 100644 index e398b653..00000000 --- a/libs/KDMacTouchBar/examples/mactouchbar/main.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. -** All rights reserved. -** -** This file is part of the KD MacTouchBar library. -** -** This file may be distributed and/or modified under the terms of the -** GNU Lesser General Public License version 3 as published by the -** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included. -** -** You may even contact us at info@kdab.com for different licensing options. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** Contact info@kdab.com if any conditions of this licensing are not -** clear to you. -** -**********************************************************************/ - -#include - -#include "kdmactouchbar.h" - -#include "mainwindow.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - // enable automatic message box on touchbar - KDMacTouchBar::setAutomaticallyCreateMessageBoxTouchBar(true); - - MainWindow mw; - mw.show(); - - return app.exec(); -} diff --git a/libs/KDMacTouchBar/examples/mactouchbar/mainwindow.cpp b/libs/KDMacTouchBar/examples/mactouchbar/mainwindow.cpp deleted file mode 100644 index de7fc9dd..00000000 --- a/libs/KDMacTouchBar/examples/mactouchbar/mainwindow.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. -** All rights reserved. -** -** This file is part of the KD MacTouchBar library. -** -** This file may be distributed and/or modified under the terms of the -** GNU Lesser General Public License version 3 as published by the -** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included. -** -** You may even contact us at info@kdab.com for different licensing options. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** Contact info@kdab.com if any conditions of this licensing are not -** clear to you. -** -**********************************************************************/ - -#include "mainwindow.h" - -#include - -#include -#include -#include - -#include "kdmactouchbar.h" - -MainWindow::MainWindow() -{ - setWindowTitle("KDMacTouchBar Example"); - resize(400, 200); - - // attach a touchbar to this window - KDMacTouchBar *touchBar = new KDMacTouchBar(this); - - QIcon qtIcon(QStringLiteral(":qtlogo.png")); - - // add item - QAction *action = new QAction(qtIcon, tr("Qt with touchbar")); - touchBar->addAction(action); - connect(action, &QAction::triggered, this, &MainWindow::activated); - - // separator - touchBar->addSeparator(); - touchBar->addSeparator()->setText(tr("More items:")); - - // and more items - QAction *action1 = new QAction(tr("Item 1")); - touchBar->addAction(action1); - connect(action1, &QAction::triggered, this, &MainWindow::activated); - - QAction *action2 = new QAction(tr("Item 2")); - touchBar->addAction(action2); - connect(action2, &QAction::triggered, this, &MainWindow::activated); - - // make special escape button - QAction *quit = new QAction(tr("Quit")); - touchBar->setEscapeAction(quit); - connect(quit, &QAction::triggered, this, &QWidget::close); -} - -void MainWindow::activated() -{ - QMessageBox::information(this, tr("Activated"), tr("You activated the touchbar action!")); -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - event->setAccepted(QMessageBox::question(this, tr("Quit"), tr("Do yo really want to quit?")) == QMessageBox::Yes); -} diff --git a/libs/KDMacTouchBar/examples/mactouchbar/mainwindow.h b/libs/KDMacTouchBar/examples/mactouchbar/mainwindow.h deleted file mode 100644 index c980a2a4..00000000 --- a/libs/KDMacTouchBar/examples/mactouchbar/mainwindow.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. -** All rights reserved. -** -** This file is part of the KD MacTouchBar library. -** -** This file may be distributed and/or modified under the terms of the -** GNU Lesser General Public License version 3 as published by the -** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included. -** -** You may even contact us at info@kdab.com for different licensing options. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** Contact info@kdab.com if any conditions of this licensing are not -** clear to you. -** -**********************************************************************/ - -#ifndef EX_MAINWINDOW_H -#define EX_MAINWINDOW_H - -#include - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(); - -public Q_SLOTS: - void activated(); - -protected: - void closeEvent(QCloseEvent *event) override; -}; - -#endif diff --git a/libs/KDMacTouchBar/examples/mactouchbar/qtlogo.png b/libs/KDMacTouchBar/examples/mactouchbar/qtlogo.png deleted file mode 100644 index d75936b0..00000000 Binary files a/libs/KDMacTouchBar/examples/mactouchbar/qtlogo.png and /dev/null differ diff --git a/libs/KDMacTouchBar/features/features.pro b/libs/KDMacTouchBar/features/features.pro deleted file mode 100644 index 5cdf80c1..00000000 --- a/libs/KDMacTouchBar/features/features.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -features.path = $$INSTALL_PREFIX/share/mkspecs/features -features.files = *.prf - -INSTALLS += features - -OTHER_FILES = *.prf diff --git a/libs/KDMacTouchBar/features/kdmactouchbar.prf b/libs/KDMacTouchBar/features/kdmactouchbar.prf deleted file mode 100644 index 4bf73e6f..00000000 --- a/libs/KDMacTouchBar/features/kdmactouchbar.prf +++ /dev/null @@ -1,4 +0,0 @@ -LIBPATH=$$clean_path($$PWD/../../../lib) -LIBS += -F$$LIBPATH -framework KDMacTouchBar -QMAKE_LFLAGS += '-Wl,-rpath,\'$$LIBPATH\'' -INCLUDEPATH += $$LIBPATH/KDMacTouchBar.framework/Headers diff --git a/libs/KDMacTouchBar/kdmactouchbar.pri b/libs/KDMacTouchBar/kdmactouchbar.pri deleted file mode 100644 index 341988ca..00000000 --- a/libs/KDMacTouchBar/kdmactouchbar.pri +++ /dev/null @@ -1 +0,0 @@ -VERSION = 1.0 diff --git a/libs/KDMacTouchBar/kdmactouchbar.pro b/libs/KDMacTouchBar/kdmactouchbar.pro deleted file mode 100644 index 7b102e8f..00000000 --- a/libs/KDMacTouchBar/kdmactouchbar.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = subdirs - -include(kdmactouchbar.pri) - -DEFAULT_INSTALL_PREFIX = /usr/local/KDAB/KDMacTouchBar-$$VERSION - -isEmpty( KDMACTOUCHBAR_INSTALL_PREFIX ): KDMACTOUCHBAR_INSTALL_PREFIX=$$PREFIX - -isEmpty( KDMACTOUCHBAR_INSTALL_PREFIX ): KDMACTOUCHBAR_INSTALL_PREFIX=$$DEFAULT_INSTALL_PREFIX - -# if the default was either set by configure or set by the line above: -equals( KDMACTOUCHBAR_INSTALL_PREFIX, $$DEFAULT_INSTALL_PREFIX ){ - INSTALL_PREFIX=$$DEFAULT_INSTALL_PREFIX - message( "No install prefix given, using default of" $$DEFAULT_INSTALL_PREFIX (use configure.sh -prefix DIR to specify)) -} else { - INSTALL_PREFIX=$$KDMACTOUCHBAR_INSTALL_PREFIX -} - -# This file is in the build directory (because "somecommand >> somefile" puts it there) -QMAKE_CACHE = "$${OUT_PWD}/.qmake.cache" - -MESSAGE = '\\'$$LITERAL_HASH\\' KDAB qmake cache file: following lines autogenerated during qmake run' -system('echo $${MESSAGE} > $${QMAKE_CACHE}') - -TMP_SOURCE_DIR = $${PWD} -TMP_BUILD_DIR = $${OUT_PWD} -system('echo TOP_SOURCE_DIR=$${TMP_SOURCE_DIR} >> $${QMAKE_CACHE}') -system('echo TOP_BUILD_DIR=$${TMP_BUILD_DIR} >> $${QMAKE_CACHE}') -system('echo INSTALL_PREFIX=$$INSTALL_PREFIX >> $${QMAKE_CACHE}') - -SUBDIRS += src examples features - -examples.depends = src diff --git a/libs/KDMacTouchBar/src/CMakeLists.txt b/libs/KDMacTouchBar/src/CMakeLists.txt deleted file mode 100644 index 05a19c5e..00000000 --- a/libs/KDMacTouchBar/src/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -include(${QT_USE_FILE}) - -set(HEADERS kdmactouchbar.h - kdmactouchbar_global.h) - -add_definitions(-DKDMACTOUCHBAR_BUILD_KDMACTOUCHBAR_LIB -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNING) - -add_library(KDMacTouchBar SHARED - kdmactouchbar.mm - ${HEADERS}) - -install(TARGETS KDMacTouchBar - LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") - -target_link_libraries(KDMacTouchBar ${QT_LIBRARIES} "-framework Cocoa") - -set_target_properties(KDMacTouchBar PROPERTIES - FRAMEWORK TRUE - FRAMEWORK_VERSION 1 - MACOSX_FRAMEWORK_IDENTIFIER com.kdab.KDMacTouchBar - PUBLIC_HEADER "${HEADERS}" - LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" - MACOSX_RPATH TRUE -) diff --git a/libs/KDMacTouchBar/src/kdmactouchbar.h b/libs/KDMacTouchBar/src/kdmactouchbar.h deleted file mode 100644 index aa286cf7..00000000 --- a/libs/KDMacTouchBar/src/kdmactouchbar.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. -** All rights reserved. -** -** This file is part of the KD MacTouchBar library. -** -** This file may be distributed and/or modified under the terms of the -** GNU Lesser General Public License version 3 as published by the -** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included. -** -** You may even contact us at info@kdab.com for different licensing options. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** Contact info@kdab.com if any conditions of this licensing are not -** clear to you. -** -**********************************************************************/ - -#ifndef KDMACTOUCHBAR_H -#define KDMACTOUCHBAR_H - -#include "kdmactouchbar_global.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDialogButtonBox; -class QMessageBox; -class QTabBar; - - -class KDMACTOUCHBAR_EXPORT KDMacTouchBar : public QWidget -{ - Q_OBJECT - Q_PROPERTY(QAction *principialAction READ principialAction WRITE setPrincipialAction) - Q_PROPERTY(QAction *escapeAction READ escapeAction WRITE setEscapeAction) - Q_PROPERTY(TouchButtonStyle touchButtonStyle READ touchButtonStyle WRITE setTouchButtonStyle) -public: - explicit KDMacTouchBar(QWidget *parent = nullptr); - explicit KDMacTouchBar(QMessageBox *messageBox); - ~KDMacTouchBar(); - - enum TouchButtonStyle - { - IconOnly, - TextOnly, - TextBesideIcon - }; - - static void setAutomaticallyCreateMessageBoxTouchBar(bool automatic); - static bool isAutomacicallyCreatingMessageBoxTouchBar(); - - QAction *addSeparator(); - QAction *addTabBar(QTabBar *tabBar); - void removeTabBar(QTabBar *tabBar); - - QAction *addMessageBox(QMessageBox *messageBox); - void removeMessageBox(QMessageBox *messageBox); - - QAction *addDialogButtonBox(QDialogButtonBox *buttonBox); - void removeDialogButtonBox(QDialogButtonBox *buttonBox); - - void setPrincipialAction(QAction *action); - QAction *principialAction() const; - - void setEscapeAction(QAction *action); - QAction *escapeAction() const; - - void setTouchButtonStyle(TouchButtonStyle touchButtonStyle); - TouchButtonStyle touchButtonStyle() const; - - void clear(); - -protected: - bool event(QEvent *event); - -private: - class Private; - Private *const d; -}; - -QT_END_NAMESPACE - -#endif diff --git a/libs/KDMacTouchBar/src/kdmactouchbar.mm b/libs/KDMacTouchBar/src/kdmactouchbar.mm deleted file mode 100644 index 56447ae2..00000000 --- a/libs/KDMacTouchBar/src/kdmactouchbar.mm +++ /dev/null @@ -1,980 +0,0 @@ -/**************************************************************************** -** Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. -** All rights reserved. -** -** This file is part of the KD MacTouchBar library. -** -** This file may be distributed and/or modified under the terms of the -** GNU Lesser General Public License version 3 as published by the -** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included. -** -** You may even contact us at info@kdab.com for different licensing options. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** Contact info@kdab.com if any conditions of this licensing are not -** clear to you. -** -**********************************************************************/ -#include "kdmactouchbar.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#import - -QT_BEGIN_NAMESPACE - -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) -NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize = 0); -#else -// defined in gui/painting/qcoregraphics.mm -@interface NSImage (QtExtras) -+ (instancetype)imageFromQIcon:(const QIcon &)icon; -@end -static NSImage *qt_mac_create_nsimage(const QIcon &icon) -{ - return [NSImage imageFromQIcon:icon]; -} -#endif - -static QString identifierForAction(QObject *action) -{ - return QStringLiteral("0x%1 %2") - .arg((quintptr)action, QT_POINTER_SIZE * 2, 16, QLatin1Char('0')) - .arg(action->objectName()); -} - - -static QString removeMnemonics(const QString &original) -{ - QString returnText(original.size(), QChar('\0')); - int finalDest = 0; - int currPos = 0; - int l = original.length(); - while (l) { - if (original.at(currPos) == QLatin1Char('&')) { - ++currPos; - --l; - if (l == 0) - break; - } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && - original.at(currPos + 1) == QLatin1Char('&') && - original.at(currPos + 2) != QLatin1Char('&') && - original.at(currPos + 3) == QLatin1Char(')')) { - /* remove mnemonics its format is "\s*(&X)" */ - int n = 0; - while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) - ++n; - finalDest -= n; - currPos += 4; - l -= 4; - continue; - } - returnText[finalDest] = original.at(currPos); - ++currPos; - ++finalDest; - --l; - } - returnText.truncate(finalDest); - return returnText; -} - -class TabBarAction : public QAction -{ -public: - TabBarAction(QTabBar *tabBar, QObject *parent) - : QAction(parent) - { - setData(QVariant::fromValue(tabBar)); - connect(tabBar, &QTabBar::currentChanged, this, &TabBarAction::sendDataChanged); - connect(tabBar, &QObject::destroyed, this, &QObject::deleteLater); - } - - void sendDataChanged() - { - QActionEvent e(QEvent::ActionChanged, this); - for (auto w : associatedWidgets()) - QApplication::sendEvent(w, &e); - } -}; - -class ButtonBoxAction : public QAction -{ -public: - ButtonBoxAction(QDialogButtonBox *buttonBox, QObject *parent) - : QAction(parent) - , mButtonBox(buttonBox) - { - setData(QVariant::fromValue(buttonBox)); - - checkStandardButtonAndTexts(); - - auto timer = new QTimer(buttonBox); - timer->start(200); - connect(timer, &QTimer::timeout, this, &ButtonBoxAction::checkStandardButtonAndTexts); - connect(buttonBox, &QObject::destroyed, this, &QObject::deleteLater); - } - - void checkStandardButtonAndTexts() - { - QStringList buttonTexts; - QPushButton *defaultButton = nullptr; - for (auto b : mButtonBox->buttons()) { - buttonTexts.append(b->text()); - if (auto pb = qobject_cast(b)) - if (pb->isDefault()) - defaultButton = pb; - } - - if (buttonTexts != mButtonTexts || defaultButton != mDefaultButton) { - sendDataChanged(); - mButtonTexts = buttonTexts; - mDefaultButton = defaultButton; - } - } - - void sendDataChanged() - { - QActionEvent e(QEvent::ActionChanged, this); - for (auto w : associatedWidgets()) - QApplication::sendEvent(w, &e); - } - - QDialogButtonBox *mButtonBox; - QList mButtons; - QPushButton *mDefaultButton = nullptr; - QStringList mButtonTexts; -}; - -@interface QObjectPointer : NSObject { -} -@property (readonly) QObject *qobject; -@end - -@implementation QObjectPointer -QObject *_qobject; -@synthesize qobject = _qobject; - -- (id)initWithQObject:(QObject *)aQObject -{ - self = [super init]; - _qobject = aQObject; - return self; -} - -@end - -class WidgetActionContainerWidget : public QWidget -{ -public: - WidgetActionContainerWidget(QWidget *widget, NSView *view) - : w(widget) - , v(view) - { - widget->setParent(this); - widget->move(0, 0); - if (!widget->testAttribute(Qt::WA_Resized)) - widget->resize(widget->sizeHint() - .boundedTo(QSize(widget->maximumWidth(), 30)) - .expandedTo(widget->minimumSize())); - setAttribute(Qt::WA_DontShowOnScreen); - setAttribute(Qt::WA_QuitOnClose, false); - ensurePolished(); - setVisible(true); - QPixmap pm(1, 1); - render(&pm, QPoint(), QRegion(), - widget->autoFillBackground() - ? (QWidget::DrawWindowBackground | QWidget::DrawChildren) - : QWidget::DrawChildren); - } - - QSize sizeHint() const { return w->size(); } - - void resizeEvent(QResizeEvent *event) { w->resize(event->size()); } - - bool event(QEvent *event) - { - if (event->type() == QEvent::UpdateRequest) - [v setNeedsDisplay:YES]; - return QWidget::event(event); - } - - QWidget *w; - NSView *v; -}; - -@interface WidgetActionView : NSView -@property WidgetActionContainerWidget *widget; -@property QWidget *touchTarget; -@property QWidgetAction *action; -@property (readonly) NSSize intrinsicContentSize; -@end - -@implementation WidgetActionView -@synthesize action; -@synthesize widget; -@synthesize touchTarget; - -- (NSSize)intrinsicContentSize -{ - return NSMakeSize(widget->width(), widget->height()); -} - -- (id)initWithWidgetAction:(QWidgetAction *)wa -{ - self = [super init]; - action = wa; - widget = new WidgetActionContainerWidget(action->requestWidget(nullptr), self); - if (!widget->testAttribute(Qt::WA_Resized)) - widget->resize(widget->sizeHint() - .boundedTo(QSize(widget->maximumWidth(), 30)) - .expandedTo(widget->minimumSize())); - [self setNeedsDisplay:YES]; - return self; -} - -- (void)dealloc -{ - widget->w->setParent(0); - [super dealloc]; -} - -- (void)drawRect:(NSRect)frame -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - widget->w->resize(frame.size.width, frame.size.height); - QPixmap pm(widget->w->size() * 2); - pm.setDevicePixelRatio(2); - pm.fill(Qt::transparent); - widget->w->render(&pm, QPoint(), QRegion(), - widget->w->autoFillBackground() - ? (QWidget::DrawWindowBackground | QWidget::DrawChildren) - : QWidget::DrawChildren); - CGImageRef cgImage = pm.toImage().toCGImage(); - NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; - [image drawInRect:frame]; - [pool release]; -} - -- (void)touchesBeganWithEvent:(NSEvent *)event -{ - NSTouch *touch = [[event touchesMatchingPhase:NSTouchPhaseBegan inView:self] anyObject]; - const QPoint point = QPointF::fromCGPoint([touch locationInView:self]).toPoint(); - touchTarget = widget->childAt(point); - if (touchTarget == nullptr) - touchTarget = widget; - QMouseEvent e(QEvent::MouseButtonPress, touchTarget->mapFrom(widget, point), Qt::LeftButton, - Qt::LeftButton, Qt::NoModifier); - qApp->sendEvent(touchTarget, &e); -} -- (void)touchesMovedWithEvent:(NSEvent *)event -{ - NSTouch *touch = [[event touchesMatchingPhase:NSTouchPhaseMoved inView:self] anyObject]; - const QPoint point = QPointF::fromCGPoint([touch locationInView:self]).toPoint(); - QMouseEvent e(QEvent::MouseButtonPress, touchTarget->mapFrom(widget, point), Qt::LeftButton, - Qt::LeftButton, Qt::NoModifier); - qApp->sendEvent(touchTarget, &e); -} -- (void)touchesEndedWithEvent:(NSEvent *)event -{ - NSTouch *touch = [[event touchesMatchingPhase:NSTouchPhaseEnded inView:self] anyObject]; - const QPoint point = QPointF::fromCGPoint([touch locationInView:self]).toPoint(); - QMouseEvent e(QEvent::MouseButtonRelease, touchTarget->mapFrom(widget, point), Qt::LeftButton, - Qt::LeftButton, Qt::NoModifier); - qApp->sendEvent(touchTarget, &e); -} - -@end - -@interface DynamicTouchBarProviderDelegate : NSResponder -@property (strong) NSMutableDictionary *items; -@end - -@implementation DynamicTouchBarProviderDelegate -@synthesize items; - -- (id)initWithItems:(NSMutableDictionary *)i -{ - self = [super init]; - self.items = i; - return self; -} - -- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar - makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier -{ - Q_UNUSED(touchBar); - - if ([self.items objectForKey:identifier] != nil) - return [self.items objectForKey:identifier]; - - return nil; -} -@end - -@interface DynamicTouchBarProvider - : NSResponder -@property (strong) NSMutableDictionary *items; -@property (strong) NSMutableDictionary *commands; -@property (strong) NSObject *qtDelegate; -@property (strong, readonly) NSTouchBar *touchBar; -@property (strong) DynamicTouchBarProviderDelegate *delegate; -@property KDMacTouchBar *qMacTouchBar; -@property QStack openedPopOvers; -@end - -@implementation DynamicTouchBarProvider -@synthesize items; -@synthesize commands; -@synthesize touchBar; -@synthesize delegate; -@synthesize qMacTouchBar; -@synthesize openedPopOvers; - -- (id)initWithKDMacTouchBar:(KDMacTouchBar *)bar -{ - self = [super init]; - items = [[NSMutableDictionary alloc] init]; - commands = [[NSMutableDictionary alloc] init]; - qMacTouchBar = bar; - delegate = [[DynamicTouchBarProviderDelegate alloc] initWithItems:items]; - return self; -} - -- (void)addItem:(QAction *)action -{ - // Create custom button item - NSString *identifier = identifierForAction(action).toNSString(); - NSTouchBarItem *item = nil; - NSView *view = nil; - - if (auto wa = qobject_cast(action)) { - NSPopoverTouchBarItem *i = - [[[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier] autorelease]; - item = i; - view = [[WidgetActionView alloc] initWithWidgetAction:wa]; - i.collapsedRepresentation = view; - } else if (auto tb = qobject_cast(action->data().value())) { - NSCustomTouchBarItem *i = - [[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier] autorelease]; - item = i; - NSMutableArray *labels = [[NSMutableArray alloc] init]; - view = - [[NSSegmentedControl segmentedControlWithLabels:labels - trackingMode:NSSegmentSwitchTrackingSelectOne - target:self - action:@selector(tabBarAction:)] autorelease]; - i.view = view; - } else if (auto bb = qobject_cast(action->data().value())) { - NSMutableArray *buttonItems = [[NSMutableArray alloc] init]; - - for (int i = 0; i < bb->layout()->count(); ++i) { - auto layoutItem = bb->layout()->itemAt(i); - if (auto b = qobject_cast(layoutItem->widget())) { - auto buttonIdentifier = identifierForAction(b).toNSString(); - NSCustomTouchBarItem *buttonItem = nil; - NSButton *button = nil; - if ([[items allKeys] containsObject:buttonIdentifier]) { - buttonItem = [items objectForKey:buttonIdentifier]; - button = buttonItem.view; - } else { - buttonItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:buttonIdentifier]; - button = [NSButton buttonWithTitle:removeMnemonics(b->text()).toNSString() - target:self - action:@selector(buttonAction:)]; - } - if (b->isDefault()) - [button setKeyEquivalent:@"\r"]; - button.title = removeMnemonics(b->text()).toNSString(); - buttonItem.view = button; - [buttonItems addObject:buttonItem]; - [commands setObject:[[QObjectPointer alloc] initWithQObject:b] - forKey:[NSValue valueWithPointer:button]]; - [items setObject:buttonItem forKey:buttonIdentifier]; - } - } - - item = [[NSGroupTouchBarItem groupItemWithIdentifier:identifier items:buttonItems] - autorelease]; - } else if (action->isSeparator()) { - NSPopoverTouchBarItem *i = - [[[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier] autorelease]; - item = i; - view = [NSTextField labelWithString:action->text().toNSString()]; - i.collapsedRepresentation = view; - } else { - NSPopoverTouchBarItem *i = - [[[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier] autorelease]; - item = i; - view = [[NSButton buttonWithTitle:removeMnemonics(action->text()).toNSString() - target:self - action:@selector(itemAction:)] autorelease]; - i.collapsedRepresentation = view; - } - - if (view) - [view retain]; - [item retain]; - - [items setObject:item forKey:identifier]; - [commands setObject:[[QObjectPointer alloc] initWithQObject:action] - forKey:[NSValue valueWithPointer:view]]; - - if (!qobject_cast(action->data().value())) - [self changeItem:action]; - else - [self makeTouchBar]; -} - -- (void)changeItem:(QAction *)action -{ - NSString *identifier = identifierForAction(action).toNSString(); - - if (auto wa = qobject_cast(action)) { - - } else if (auto tb = qobject_cast(action->data().value())) { - NSCustomTouchBarItem *item = [items objectForKey:identifier]; - NSSegmentedControl *control = item.view; - control.segmentCount = tb->count(); - for (int i = 0; i < tb->count(); ++i) { - [control setLabel:tb->tabText(i).toNSString() forSegment:i]; - } - control.selectedSegment = tb->currentIndex(); - } else if (auto bb = qobject_cast(action->data().value())) { - // unfortunately we cannot modify a NSGroupTouchBarItem, so we - // have to recreate it from scratch :-( - int index = qMacTouchBar->actions().indexOf(action); - if (index == qMacTouchBar->actions().count() - 1) { - qMacTouchBar->removeAction(action); - qMacTouchBar->addAction(action); - } else { - QAction *before = qMacTouchBar->actions().at(index + 1); - qMacTouchBar->removeAction(action); - qMacTouchBar->insertAction(before, action); - } - } else if (action->isSeparator()) { - NSPopoverTouchBarItem *item = [items objectForKey:identifier]; - NSTextField *field = item.collapsedRepresentation; - field.stringValue = action->text().toNSString(); - } else { - NSPopoverTouchBarItem *item = [items objectForKey:identifier]; - NSButton *button = item.collapsedRepresentation; - button.imagePosition = NSImageLeft; - button.enabled = action->isEnabled(); - button.buttonType = - action->isCheckable() ? NSButtonTypePushOnPushOff : NSButtonTypeAccelerator; - button.bordered = action->isSeparator() && !action->text().isEmpty() ? NO : YES; - button.highlighted = !button.bordered; - button.state = action->isChecked(); - button.hidden = !action->isVisible(); - button.image = qt_mac_create_nsimage(action->icon()); - button.title = removeMnemonics(action->text()).toNSString(); - switch (qMacTouchBar->touchButtonStyle()) - { - case KDMacTouchBar::IconOnly: - button.imagePosition = NSImageOnly; - break; - case KDMacTouchBar::TextOnly: - button.imagePosition = NSNoImage; - break; - case KDMacTouchBar::TextBesideIcon: - button.imagePosition = NSImageLeft; - break; - } - item.showsCloseButton = action->menu() != nullptr; - if (action->menu()) { - item.popoverTouchBar = [[NSTouchBar alloc] init]; - item.popoverTouchBar.delegate = delegate; - // Add ordered items array - NSMutableArray *array = [[NSMutableArray alloc] init]; - for (auto action : action->menu()->actions()) { - if (action->isVisible()) { - [self addItem:action]; - if (action->isSeparator() && action->text().isEmpty()) - [array addObject:NSTouchBarItemIdentifierFixedSpaceLarge]; - else - [array addObject:identifierForAction(action).toNSString()]; - } - } - item.popoverTouchBar.defaultItemIdentifiers = array; - } - } - - [self makeTouchBar]; -} - -- (void)removeItem:(QAction *)action -{ - NSString *identifier = identifierForAction(action).toNSString(); - NSPopoverTouchBarItem *item = [items objectForKey:identifier]; - if (item == nil) - return; - QObjectPointer *command = [commands objectForKey:[NSValue valueWithPointer:item.view]]; - [commands removeObjectForKey:[NSValue valueWithPointer:item.view]]; - [items removeObjectForKey:identifier]; - [command release]; - - [self makeTouchBar]; -} - -- (void)buttonAction:(id)sender -{ - QObjectPointer *qobjectPointer = - (QObjectPointer *)[commands objectForKey:[NSValue valueWithPointer:sender]]; - // Missing entry in commands dict. Should not really happen, but does - if (!qobjectPointer) - return; - - QPushButton *button = qobject_cast(qobjectPointer.qobject); - if (!button) - return; - - button->click(); -} - -- (void)tabBarAction:(id)sender -{ - QObjectPointer *qobjectPointer = - (QObjectPointer *)[commands objectForKey:[NSValue valueWithPointer:sender]]; - // Missing entry in commands dict. Should not really happen, but does - if (!qobjectPointer) - return; - - // Check for deleted QObject - if (!qobjectPointer.qobject) - return; - - QAction *action = static_cast(qobjectPointer.qobject); - if (!action) - return; - QTabBar *tabBar = qobject_cast(action->data().value()); - if (!tabBar) - return; - - NSString *identifier = identifierForAction(action).toNSString(); - NSCustomTouchBarItem *item = [items objectForKey:identifier]; - NSSegmentedControl *control = item.view; - - tabBar->setCurrentIndex(control.selectedSegment); -} - -- (void)itemAction:(id)sender -{ - QObjectPointer *qobjectPointer = - (QObjectPointer *)[commands objectForKey:[NSValue valueWithPointer:sender]]; - // Missing entry in commands dict. Should not really happen, but does - if (!qobjectPointer) - return; - - // Check for deleted QObject - if (!qobjectPointer.qobject) - return; - - QAction *action = static_cast(qobjectPointer.qobject); - if (!action || action->isSeparator()) - return; - if (!action->isEnabled()) - return; - action->activate(QAction::Trigger); - - if (action->menu()) { - NSString *identifier = identifierForAction(action).toNSString(); - NSPopoverTouchBarItem *item = [items objectForKey:identifier]; - [item showPopover:item]; - openedPopOvers.push(item); - } else { - while (!openedPopOvers.isEmpty()) { - auto poppedItem = openedPopOvers.pop(); - [poppedItem dismissPopover:poppedItem]; - } - } -} - -- (void)clearItems -{ - [items removeAllObjects]; - [commands removeAllObjects]; -} - -- (NSTouchBar *)makeTouchBar -{ - // Create the touch bar with this instance as its delegate - if (touchBar == nil) { - touchBar = [[NSTouchBar alloc] init]; - touchBar.delegate = delegate; - } - - // Add ordered items array - NSMutableArray *array = [[NSMutableArray alloc] init]; - for (auto action : qMacTouchBar->actions()) { - if (action->isVisible()) { - if (action->isSeparator() && action->text().isEmpty()) - [array addObject:NSTouchBarItemIdentifierFixedSpaceLarge]; - else - [array addObject:identifierForAction(action).toNSString()]; - } - } - touchBar.defaultItemIdentifiers = array; - - return touchBar; -} - -- (void)installAsDelegateForWindow:(NSWindow *)window -{ - _qtDelegate = window.delegate; // Save current delegate for forwarding - window.delegate = self; -} - -- (void)installAsDelegateForApplication:(NSApplication *)application -{ - _qtDelegate = application.delegate; // Save current delegate for forwarding - application.delegate = self; -} - -- (BOOL)respondsToSelector:(SEL)aSelector -{ - // We want to forward to the qt delegate. Respond to selectors it - // responds to in addition to selectors this instance resonds to. - return [_qtDelegate respondsToSelector:aSelector] || [super respondsToSelector:aSelector]; -} - -- (void)forwardInvocation:(NSInvocation *)anInvocation -{ - // Forward to the existing delegate. This function is only called for selectors - // this instance does not responds to, which means that the qt delegate - // must respond to it (due to the respondsToSelector implementation above). - [anInvocation invokeWithTarget:_qtDelegate]; -} - -@end - -class KDMacTouchBar::Private -{ -public: - DynamicTouchBarProvider *touchBarProvider = nil; - QAction *principialAction = nullptr; - QAction *escapeAction = nullptr; - KDMacTouchBar::TouchButtonStyle touchButtonStyle = TextBesideIcon; - - static bool automaticallyCreateMessageBoxTouchBar; -}; - -bool KDMacTouchBar::Private::automaticallyCreateMessageBoxTouchBar = false; - -class AutomaticMessageBoxTouchBarStyle : public QProxyStyle -{ -public: - using QProxyStyle::QProxyStyle; - - void polish(QWidget *w) override - { - if (auto mb = qobject_cast(w)) { - if (KDMacTouchBar::isAutomacicallyCreatingMessageBoxTouchBar()) - new KDMacTouchBar(mb); - } - QProxyStyle::polish(w); - } -}; - -/*! - \class KDMacTouchBar - \brief The KDMacTouchBar class wraps the native NSTouchBar class. - - KDMacTouchBar provides a Qt-based API for NSTouchBar. The touchbar displays - a number of QActions. Each QAction can have a text and an icon. Alternatively, - the QActions might be separators (with or without text) or QWidgetActions. - - Add actions by calling addAction(). Alternatively, you can use one of the - convenience methods like addDialogButtonBox() or addTabBar() which provide - common use cases. - - If an action with a associated menu is added, its menu items are added as - sub-touchbar. Showing sub-menus of this menu is not supported, due to macOS - system restrictions. - - Usage: (QtWidgets) - \code - QMainWindow *mw = ...; - KDMacTouchBar *touchBar = new KDMacTouchBar(mw); - touchBar->addAction(actionNewFile); - touchBar->addSeparator(); - touchBar->addAction(actionSaveFile); - \endcode -*/ - -/*! -\enum KDMacTouchBar::TouchButtonStyle -\value IconOnly Only display the icon. -\value TextOnly Only display the text. -\value TextBesideIcon The text appears beside the icon. -*/ - -/*! - Constructs a KDMacTouchBar for the window of \a parent. If \a parent is - nullptr, the KDMacTouchBar is shown as soon as this QApplication has focus, - if no other window with an own KDMacTouchBar has focus. -*/ -KDMacTouchBar::KDMacTouchBar(QWidget *parent) - : QWidget(parent) - , d(new Private) -{ - d->touchBarProvider = [[DynamicTouchBarProvider alloc] initWithKDMacTouchBar:this]; - if (parent) { - NSView *view = reinterpret_cast(parent->window()->winId()); - [d->touchBarProvider installAsDelegateForWindow:[view window]]; - } else { - [d->touchBarProvider installAsDelegateForApplication:[NSApplication sharedApplication]]; - } -} - -/*! - Constructs a KDMacTouchBar containing the QDialogButtonBox from inside of - \a messageBox. -*/ -KDMacTouchBar::KDMacTouchBar(QMessageBox *messageBox) - : QWidget( messageBox) - , d(new Private) -{ - d->touchBarProvider = [[DynamicTouchBarProvider alloc] initWithKDMacTouchBar:this]; - NSView *view = reinterpret_cast(messageBox->window()->winId()); - [d->touchBarProvider installAsDelegateForWindow:[view window]]; - setPrincipialAction(addMessageBox(messageBox)); -} - -/*! - Destroys the touch bar. -*/ -KDMacTouchBar::~KDMacTouchBar() -{ - [d->touchBarProvider release]; - delete d; -} - -/*! - This static convenience method controls, whether KDMacTouchBar will - automatically create a touchbar for QMessageBox instances. The - created touchbar contains the buttons of the message box. - This enables to use the static QMessageBox method and still having - a touchbar for them. - - \note When you enable this setting for the first time, KDMacTouchBar will - install a QProxyStyle into the QApplication object to be able to create - the KDMacTouchBar in its polish method. The installed QProxyStyle will - use the existing application style as base style. -*/ -void KDMacTouchBar::setAutomaticallyCreateMessageBoxTouchBar(bool automatic) -{ - static AutomaticMessageBoxTouchBarStyle *touchStyle = nullptr; - if (automatic && !touchStyle) { - qApp->setStyle(touchStyle = new AutomaticMessageBoxTouchBarStyle(qApp->style())); - } - Private::automaticallyCreateMessageBoxTouchBar = automatic; -} - -/*! - Returns whether KDMacTouchBar automatically creates a touchbar for - QMessageBox instances. -*/ -bool KDMacTouchBar::isAutomacicallyCreatingMessageBoxTouchBar() -{ - return Private::automaticallyCreateMessageBoxTouchBar; -} - -/*! - Adds a separator item to the end of the touch bar. -*/ -QAction *KDMacTouchBar::addSeparator() -{ - auto action = new QAction(this); - action->setSeparator(true); - addAction(action); - return action; -} - -/*! \reimp */ -bool KDMacTouchBar::event(QEvent *event) -{ - switch (event->type()) { - case QEvent::ActionAdded: - [d->touchBarProvider addItem:static_cast(event)->action()]; - break; - case QEvent::ActionChanged: - [d->touchBarProvider changeItem:static_cast(event)->action()]; - break; - case QEvent::ActionRemoved: - [d->touchBarProvider removeItem:static_cast(event)->action()]; - break; - default: - break; - } - - return QWidget::event(event); -} - -/*! - Adds a button group controlling a \a tabBar item to the end of the touch bar. -*/ -QAction *KDMacTouchBar::addTabBar(QTabBar *tabBar) -{ - auto a = new TabBarAction(tabBar, this); - addAction(a); - return a; -} - -/*! - Removes \a tabBar from the touch bar. -*/ -void KDMacTouchBar::removeTabBar(QTabBar *tabBar) -{ - for (auto a : actions()) { - if (a->data().value() == tabBar) { - removeAction(a); - return; - } - } -} - -/*! - Adds the QDialogButtonBox of \a messageBox to the end of the touch bar. -*/ -QAction *KDMacTouchBar::addMessageBox(QMessageBox *messageBox) -{ - return addDialogButtonBox(messageBox->findChild(QStringLiteral("qt_msgbox_buttonbox"))); -} - -/*! - Removes the QDialogButtonBox of \a messageBox from the touch bar. -*/ -void KDMacTouchBar::removeMessageBox(QMessageBox *messageBox) -{ - return removeDialogButtonBox(messageBox->findChild(QStringLiteral("qt_msgbox_buttonbox"))); -} - -/*! - Adds a button group controlling \a buttonBox to the end of the touch bar. -*/ -QAction *KDMacTouchBar::addDialogButtonBox(QDialogButtonBox *buttonBox) -{ - auto a = new ButtonBoxAction(buttonBox, this); - addAction(a); - return a; -} - -/*! - Removes the \a buttonBox from the touch bar. -*/ -void KDMacTouchBar::removeDialogButtonBox(QDialogButtonBox *buttonBox) -{ - for (auto a : actions()) { - if (a->data().value() == buttonBox) { - removeAction(a); - return; - } - } -} - -/*! - \property KDMacTouchBar::principialAction - \brief the principial action of the touch bar - - The principial action of the touch bar is the QAction you want the system - to center in the touch bar. - - You need to add the action to the touch bar before you can set it as principial - action. -*/ -void KDMacTouchBar::setPrincipialAction(QAction *action) -{ - d->principialAction = action; - d->touchBarProvider.touchBar.principalItemIdentifier = action ? identifierForAction(action).toNSString() : nil; -} - -QAction *KDMacTouchBar::principialAction() const -{ - return d->principialAction; -} - -/*! - \property KDMacTouchBar::escapeAction - \brief the action used as system escape key action - - By setting a QAction as escapeAction, it is possible to replace the system - escape key with a random action. - - You don't need to add the action to the touch bar before you can set it as - escape action. -*/ -void KDMacTouchBar::setEscapeAction(QAction *action) -{ - if (d->escapeAction == action) - return; - if (d->escapeAction) - [d->touchBarProvider removeItem:d->escapeAction]; - d->escapeAction = action; - if (d->escapeAction) { - [d->touchBarProvider addItem:d->escapeAction]; - d->touchBarProvider.touchBar.escapeKeyReplacementItemIdentifier = - identifierForAction(action).toNSString(); - } else - d->touchBarProvider.touchBar.escapeKeyReplacementItemIdentifier = nil; -} - -QAction *KDMacTouchBar::escapeAction() const -{ - return d->escapeAction; -} - -/*! - \property KDMacTouchBar::touchButtonStyle - This property holds the style of touch bar buttons. - - This property defines the style of all touch buttons that are added as QActions. - Added tab widgets, dialog button boxes, message boxes or QWidgetActions won't - follow this style. - - The default is KDMacTouchBar::TextBesideIcon - */ -void KDMacTouchBar::setTouchButtonStyle(TouchButtonStyle touchButtonStyle) -{ - if (d->touchButtonStyle == touchButtonStyle) - return; - - d->touchButtonStyle = touchButtonStyle; - - for (auto* action : actions()) - [d->touchBarProvider changeItem:action]; - if (d->escapeAction) - [d->touchBarProvider changeItem:d->escapeAction]; -} - -KDMacTouchBar::TouchButtonStyle KDMacTouchBar::touchButtonStyle() const -{ - return d->touchButtonStyle; -} - -/*! - Removes all actions from the touch bar. Removes even the escapeAction. - The principialAction is cleared. -*/ -void KDMacTouchBar::clear() -{ - setEscapeAction(nullptr); - setPrincipialAction(nullptr); - for (auto* action : actions()) - removeAction(action); -} - -QT_END_NAMESPACE diff --git a/libs/KDMacTouchBar/src/kdmactouchbar_global.h b/libs/KDMacTouchBar/src/kdmactouchbar_global.h deleted file mode 100644 index 3af01631..00000000 --- a/libs/KDMacTouchBar/src/kdmactouchbar_global.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** Copyright (C) 2019-2021 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com. -** All rights reserved. -** -** This file is part of the KD MacTouchBar library. -** -** This file may be distributed and/or modified under the terms of the -** GNU Lesser General Public License version 3 as published by the -** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included. -** -** You may even contact us at info@kdab.com for different licensing options. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** Contact info@kdab.com if any conditions of this licensing are not -** clear to you. -** -**********************************************************************/ -#ifndef KDMACTOUCHBAR_GLOBAL_H -#define KDMACTOUCHBAR_GLOBAL_H - -#include - -#ifdef KDMACTOUCHBAR_BUILD_KDMACTOUCHBAR_LIB -# define KDMACTOUCHBAR_EXPORT Q_DECL_EXPORT -#elif defined(KDMACTOUCHBAR_BUILD_KDMACTOUCHBAR_SRC) -# define KDMACTOUCHBAR_EXPORT -#else -# define KDMACTOUCHBAR_EXPORT Q_DECL_IMPORT -#endif - -#endif /* KDMACTOUCHBAR_GLOBAL_H */ diff --git a/libs/KDMacTouchBar/src/src.pro b/libs/KDMacTouchBar/src/src.pro deleted file mode 100644 index 50fce58b..00000000 --- a/libs/KDMacTouchBar/src/src.pro +++ /dev/null @@ -1,28 +0,0 @@ -TEMPLATE = lib -TARGET = KDMacTouchBar -QT += widgets - -include($${TOP_SOURCE_DIR}/kdmactouchbar.pri) - -CONFIG += lib_bundle - -DESTDIR = ../lib - -SOURCES = kdmactouchbar.mm - -HEADERS = kdmactouchbar.h kdmactouchbar_global.h - -LIBS += -framework Cocoa -QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ - -DEFINES += KDMACTOUCHBAR_BUILD_KDMACTOUCHBAR_LIB QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNING - -target.path = "$${INSTALL_PREFIX}/lib" - -INSTALLS += target - -FRAMEWORK_HEADERS.version = Versions -FRAMEWORK_HEADERS.files = $$HEADERS -FRAMEWORK_HEADERS.path = Headers -QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS -QMAKE_TARGET_BUNDLE_PREFIX = "com.kdab" diff --git a/libs/Libraries.pri b/libs/Libraries.pri index d2706755..29af645a 100644 --- a/libs/Libraries.pri +++ b/libs/Libraries.pri @@ -49,14 +49,3 @@ include($$PWD/OpenSSL/OpenSSL.pri) include($$PWD/QRealFourier/QRealFourier.pri) include($$PWD/QSimpleUpdater/QSimpleUpdater.pri) include($$PWD/QSourceHighlite/QSourceHighlite.pri) - -macx* { - DEFINES += KDMACTOUCHBAR_BUILD_KDMACTOUCHBAR_SRC - LIBS += -framework Cocoa - INCLUDEPATH += $$PWD/KDMacTouchBar/src - SOURCES += \ - $$PWD/KDMacTouchBar/src/kdmactouchbar.mm - HEADERS += \ - $$PWD/KDMacTouchBar/src/kdmactouchbar.h \ - $$PWD/KDMacTouchBar/src/kdmactouchbar_global.h -} diff --git a/libs/OpenSSL/dll/macOS/libcrypto.a b/libs/OpenSSL/dll/macOS/libcrypto.a index 7cd9a9ee..c728ea0c 100644 Binary files a/libs/OpenSSL/dll/macOS/libcrypto.a and b/libs/OpenSSL/dll/macOS/libcrypto.a differ diff --git a/libs/OpenSSL/dll/macOS/libssl.a b/libs/OpenSSL/dll/macOS/libssl.a index 87b214d3..bfc7b96f 100644 Binary files a/libs/OpenSSL/dll/macOS/libssl.a and b/libs/OpenSSL/dll/macOS/libssl.a differ diff --git a/libs/OpenSSL/include/crypto/aes_platform.h b/libs/OpenSSL/include/crypto/aes_platform.h index bae264bc..1b84d482 100644 --- a/libs/OpenSSL/include/crypto/aes_platform.h +++ b/libs/OpenSSL/include/crypto/aes_platform.h @@ -16,239 +16,291 @@ #ifdef VPAES_ASM int vpaes_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); int vpaes_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); -void vpaes_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void vpaes_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void vpaes_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, int enc); +void vpaes_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void vpaes_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void vpaes_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + int enc); #endif /* VPAES_ASM */ #ifdef BSAES_ASM -void ossl_bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char ivec[16], int enc); -void ossl_bsaes_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, const unsigned char ivec[16]); -void ossl_bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); -void ossl_bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); +void ossl_bsaes_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, + unsigned char ivec[16], int enc); +void ossl_bsaes_ctr32_encrypt_blocks(const unsigned char *in, + unsigned char *out, size_t len, + const AES_KEY *key, + const unsigned char ivec[16]); +void ossl_bsaes_xts_encrypt(const unsigned char *inp, unsigned char *out, + size_t len, const AES_KEY *key1, + const AES_KEY *key2, const unsigned char iv[16]); +void ossl_bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out, + size_t len, const AES_KEY *key1, + const AES_KEY *key2, const unsigned char iv[16]); #endif /* BSAES_ASM */ #ifdef AES_CTR_ASM -void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key, const unsigned char ivec[AES_BLOCK_SIZE]); +void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key, + const unsigned char ivec[AES_BLOCK_SIZE]); #endif /* AES_CTR_ASM */ #ifdef AES_XTS_ASM -void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, - const AES_KEY *key2, const unsigned char iv[16]); -void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, - const AES_KEY *key2, const unsigned char iv[16]); +void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len, + const AES_KEY *key1, const AES_KEY *key2, + const unsigned char iv[16]); +void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, + const AES_KEY *key1, const AES_KEY *key2, + const unsigned char iv[16]); #endif /* AES_XTS_ASM */ #if defined(OPENSSL_CPUID_OBJ) -# if (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC)) -# include "crypto/ppc_arch.h" -# ifdef VPAES_ASM -# define VPAES_CAPABLE (OPENSSL_ppccap_P & PPC_ALTIVEC) -# endif -# define HWAES_CAPABLE (OPENSSL_ppccap_P & PPC_CRYPTO207) -# define HWAES_set_encrypt_key aes_p8_set_encrypt_key -# define HWAES_set_decrypt_key aes_p8_set_decrypt_key -# define HWAES_encrypt aes_p8_encrypt -# define HWAES_decrypt aes_p8_decrypt -# define HWAES_cbc_encrypt aes_p8_cbc_encrypt -# define HWAES_ctr32_encrypt_blocks aes_p8_ctr32_encrypt_blocks -# define HWAES_xts_encrypt aes_p8_xts_encrypt -# define HWAES_xts_decrypt aes_p8_xts_decrypt -# ifndef OPENSSL_SYS_AIX -# define PPC_AES_GCM_CAPABLE (OPENSSL_ppccap_P & PPC_MADD300) -# define AES_GCM_ENC_BYTES 128 -# define AES_GCM_DEC_BYTES 128 -size_t ppc_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], u64 *Xi); -size_t ppc_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], u64 *Xi); -# define AES_GCM_ASM_PPC(gctx) \ - ((gctx)->ctr == aes_p8_ctr32_encrypt_blocks \ - && (gctx)->gcm.funcs.ghash == gcm_ghash_p8) -void gcm_ghash_p8(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len); -# endif /* OPENSSL_SYS_AIX */ -# endif /* PPC */ - -# if (defined(__arm__) || defined(__arm) || defined(__aarch64__)) -# include "arm_arch.h" -# if __ARM_MAX_ARCH__ >= 7 -# if defined(BSAES_ASM) -# define BSAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON) -# endif -# if defined(VPAES_ASM) -# define VPAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON) -# endif -# define HWAES_CAPABLE (OPENSSL_armcap_P & ARMV8_AES) -# define HWAES_set_encrypt_key aes_v8_set_encrypt_key -# define HWAES_set_decrypt_key aes_v8_set_decrypt_key -# define HWAES_encrypt aes_v8_encrypt -# define HWAES_decrypt aes_v8_decrypt -# define HWAES_cbc_encrypt aes_v8_cbc_encrypt -# define HWAES_ecb_encrypt aes_v8_ecb_encrypt -# if __ARM_MAX_ARCH__ >= 8 && defined(__aarch64__) -# define HWAES_xts_encrypt aes_v8_xts_encrypt -# define HWAES_xts_decrypt aes_v8_xts_decrypt -# endif -# define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks -# define AES_PMULL_CAPABLE \ - ((OPENSSL_armcap_P & ARMV8_PMULL) && (OPENSSL_armcap_P & ARMV8_AES)) -# define AES_GCM_ENC_BYTES 512 -# define AES_GCM_DEC_BYTES 512 -# if __ARM_MAX_ARCH__ >= 8 && defined(__aarch64__) -# define AES_gcm_encrypt armv8_aes_gcm_encrypt -# define AES_gcm_decrypt armv8_aes_gcm_decrypt -# define AES_GCM_ASM(gctx) \ - ((gctx)->ctr == aes_v8_ctr32_encrypt_blocks \ - && (gctx)->gcm.funcs.ghash == gcm_ghash_v8) -size_t aes_gcm_enc_128_kernel(const uint8_t *plaintext, uint64_t plaintext_length, - uint8_t *ciphertext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t aes_gcm_enc_192_kernel(const uint8_t *plaintext, uint64_t plaintext_length, - uint8_t *ciphertext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t aes_gcm_enc_256_kernel(const uint8_t *plaintext, uint64_t plaintext_length, - uint8_t *ciphertext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t aes_gcm_dec_128_kernel(const uint8_t *ciphertext, uint64_t plaintext_length, - uint8_t *plaintext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t aes_gcm_dec_192_kernel(const uint8_t *ciphertext, uint64_t plaintext_length, - uint8_t *plaintext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t aes_gcm_dec_256_kernel(const uint8_t *ciphertext, uint64_t plaintext_length, - uint8_t *plaintext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t unroll8_eor3_aes_gcm_enc_128_kernel(const uint8_t *plaintext, uint64_t plaintext_length, - uint8_t *ciphertext, uint64_t *Xi, - unsigned char ivec[16], const void *key); -size_t unroll8_eor3_aes_gcm_enc_192_kernel(const uint8_t *plaintext, uint64_t plaintext_length, - uint8_t *ciphertext, uint64_t *Xi, - unsigned char ivec[16], const void *key); -size_t unroll8_eor3_aes_gcm_enc_256_kernel(const uint8_t *plaintext, uint64_t plaintext_length, - uint8_t *ciphertext, uint64_t *Xi, - unsigned char ivec[16], const void *key); -size_t unroll8_eor3_aes_gcm_dec_128_kernel(const uint8_t *ciphertext, uint64_t plaintext_length, - uint8_t *plaintext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t unroll8_eor3_aes_gcm_dec_192_kernel(const uint8_t *ciphertext, uint64_t plaintext_length, - uint8_t *plaintext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t unroll8_eor3_aes_gcm_dec_256_kernel(const uint8_t *ciphertext, uint64_t plaintext_length, - uint8_t *plaintext, uint64_t *Xi, unsigned char ivec[16], - const void *key); -size_t armv8_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], u64 *Xi); -size_t armv8_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], u64 *Xi); -void gcm_ghash_v8(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len); -# endif -# endif +# if (defined(__powerpc__) || defined(__ppc__) || defined(_ARCH_PPC)) +# include "crypto/ppc_arch.h" +# ifdef VPAES_ASM +# define VPAES_CAPABLE (OPENSSL_ppccap_P & PPC_ALTIVEC) # endif +# define HWAES_CAPABLE (OPENSSL_ppccap_P & PPC_CRYPTO207) +# define HWAES_set_encrypt_key aes_p8_set_encrypt_key +# define HWAES_set_decrypt_key aes_p8_set_decrypt_key +# define HWAES_encrypt aes_p8_encrypt +# define HWAES_decrypt aes_p8_decrypt +# define HWAES_cbc_encrypt aes_p8_cbc_encrypt +# define HWAES_ctr32_encrypt_blocks aes_p8_ctr32_encrypt_blocks +# define HWAES_xts_encrypt aes_p8_xts_encrypt +# define HWAES_xts_decrypt aes_p8_xts_decrypt +# ifndef OPENSSL_SYS_AIX +# define PPC_AES_GCM_CAPABLE (OPENSSL_ppccap_P & PPC_MADD300) +# define AES_GCM_ENC_BYTES 128 +# define AES_GCM_DEC_BYTES 128 +size_t ppc_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + u64 *Xi); +size_t ppc_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + u64 *Xi); +# define AES_GCM_ASM_PPC(gctx) \ + ((gctx)->ctr == aes_p8_ctr32_encrypt_blocks \ + && (gctx)->gcm.funcs.ghash == gcm_ghash_p8) +void gcm_ghash_p8(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len); +# endif /* OPENSSL_SYS_AIX */ +# endif /* PPC */ + +# if (defined(__arm__) || defined(__arm) || defined(__aarch64__)) +# include "arm_arch.h" +# if __ARM_MAX_ARCH__ >= 7 +# if defined(BSAES_ASM) +# define BSAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON) +# endif +# if defined(VPAES_ASM) +# define VPAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON) +# endif +# define HWAES_CAPABLE (OPENSSL_armcap_P & ARMV8_AES) +# define HWAES_set_encrypt_key aes_v8_set_encrypt_key +# define HWAES_set_decrypt_key aes_v8_set_decrypt_key +# define HWAES_encrypt aes_v8_encrypt +# define HWAES_decrypt aes_v8_decrypt +# define HWAES_cbc_encrypt aes_v8_cbc_encrypt +# define HWAES_ecb_encrypt aes_v8_ecb_encrypt +# if __ARM_MAX_ARCH__ >= 8 && defined(__aarch64__) +# define HWAES_xts_encrypt aes_v8_xts_encrypt +# define HWAES_xts_decrypt aes_v8_xts_decrypt +# endif +# define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks +# define AES_PMULL_CAPABLE \ + ((OPENSSL_armcap_P & ARMV8_PMULL) && (OPENSSL_armcap_P & ARMV8_AES)) +# define AES_GCM_ENC_BYTES 512 +# define AES_GCM_DEC_BYTES 512 +# if __ARM_MAX_ARCH__ >= 8 && defined(__aarch64__) +# define AES_gcm_encrypt armv8_aes_gcm_encrypt +# define AES_gcm_decrypt armv8_aes_gcm_decrypt +# define AES_GCM_ASM(gctx) \ + ((gctx)->ctr == aes_v8_ctr32_encrypt_blocks \ + && (gctx)->gcm.funcs.ghash == gcm_ghash_v8) +size_t aes_gcm_enc_128_kernel(const uint8_t *plaintext, + uint64_t plaintext_length, uint8_t *ciphertext, + uint64_t *Xi, unsigned char ivec[16], + const void *key); +size_t aes_gcm_enc_192_kernel(const uint8_t *plaintext, + uint64_t plaintext_length, uint8_t *ciphertext, + uint64_t *Xi, unsigned char ivec[16], + const void *key); +size_t aes_gcm_enc_256_kernel(const uint8_t *plaintext, + uint64_t plaintext_length, uint8_t *ciphertext, + uint64_t *Xi, unsigned char ivec[16], + const void *key); +size_t aes_gcm_dec_128_kernel(const uint8_t *ciphertext, + uint64_t plaintext_length, uint8_t *plaintext, + uint64_t *Xi, unsigned char ivec[16], + const void *key); +size_t aes_gcm_dec_192_kernel(const uint8_t *ciphertext, + uint64_t plaintext_length, uint8_t *plaintext, + uint64_t *Xi, unsigned char ivec[16], + const void *key); +size_t aes_gcm_dec_256_kernel(const uint8_t *ciphertext, + uint64_t plaintext_length, uint8_t *plaintext, + uint64_t *Xi, unsigned char ivec[16], + const void *key); +size_t unroll8_eor3_aes_gcm_enc_128_kernel(const uint8_t *plaintext, + uint64_t plaintext_length, + uint8_t *ciphertext, uint64_t *Xi, + unsigned char ivec[16], + const void *key); +size_t unroll8_eor3_aes_gcm_enc_192_kernel(const uint8_t *plaintext, + uint64_t plaintext_length, + uint8_t *ciphertext, uint64_t *Xi, + unsigned char ivec[16], + const void *key); +size_t unroll8_eor3_aes_gcm_enc_256_kernel(const uint8_t *plaintext, + uint64_t plaintext_length, + uint8_t *ciphertext, uint64_t *Xi, + unsigned char ivec[16], + const void *key); +size_t unroll8_eor3_aes_gcm_dec_128_kernel(const uint8_t *ciphertext, + uint64_t plaintext_length, + uint8_t *plaintext, uint64_t *Xi, + unsigned char ivec[16], + const void *key); +size_t unroll8_eor3_aes_gcm_dec_192_kernel(const uint8_t *ciphertext, + uint64_t plaintext_length, + uint8_t *plaintext, uint64_t *Xi, + unsigned char ivec[16], + const void *key); +size_t unroll8_eor3_aes_gcm_dec_256_kernel(const uint8_t *ciphertext, + uint64_t plaintext_length, + uint8_t *plaintext, uint64_t *Xi, + unsigned char ivec[16], + const void *key); +size_t armv8_aes_gcm_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], u64 *Xi); +size_t armv8_aes_gcm_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], u64 *Xi); +void gcm_ghash_v8(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len); +# endif +# endif +# endif #endif /* OPENSSL_CPUID_OBJ */ -#if defined(AES_ASM) \ - && (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)) -# define AES_CBC_HMAC_SHA_CAPABLE 1 -# define AESNI_CBC_HMAC_SHA_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (57 - 32))) +#if defined(AES_ASM) \ + && (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) \ + || defined(_M_X64)) +# define AES_CBC_HMAC_SHA_CAPABLE 1 +# define AESNI_CBC_HMAC_SHA_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (57 - 32))) #endif #if defined(__loongarch__) || defined(__loongarch64) -# include "loongarch_arch.h" -# if defined(VPAES_ASM) -# define VPAES_CAPABLE (OPENSSL_loongarchcap_P & LOONGARCH_CFG2_LSX) -# endif +# include "loongarch_arch.h" +# if defined(VPAES_ASM) +# define VPAES_CAPABLE (OPENSSL_loongarchcap_P & LOONGARCH_CFG2_LSX) +# endif #endif -#if defined(AES_ASM) && !defined(I386_ONLY) \ - && (((defined(__i386) || defined(__i386__) || defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2)) \ - || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)) +#if defined(AES_ASM) && !defined(I386_ONLY) \ + && (((defined(__i386) || defined(__i386__) || defined(_M_IX86)) \ + && defined(OPENSSL_IA32_SSE2)) \ + || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) \ + || defined(_M_X64)) /* AES-NI section */ -# define AESNI_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (57 - 32))) -# ifdef VPAES_ASM -# define VPAES_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (41 - 32))) -# endif -# ifdef BSAES_ASM -# define BSAES_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (41 - 32))) -# endif +# define AESNI_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (57 - 32))) +# ifdef VPAES_ASM +# define VPAES_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (41 - 32))) +# endif +# ifdef BSAES_ASM +# define BSAES_CAPABLE (OPENSSL_ia32cap_P[1] & (1 << (41 - 32))) +# endif -# define AES_GCM_ENC_BYTES 32 -# define AES_GCM_DEC_BYTES 16 +# define AES_GCM_ENC_BYTES 32 +# define AES_GCM_DEC_BYTES 16 int aesni_set_encrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); int aesni_set_decrypt_key(const unsigned char *userKey, int bits, AES_KEY *key); -void aesni_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void aesni_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); +void aesni_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void aesni_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); -void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, int enc); -void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, int enc); -# ifndef OPENSSL_NO_OCB -void aesni_ocb_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, const void *key, - size_t start_block_num, unsigned char offset_i[16], - const unsigned char L_[][16], unsigned char checksum[16]); -void aesni_ocb_decrypt(const unsigned char *in, unsigned char *out, size_t blocks, const void *key, - size_t start_block_num, unsigned char offset_i[16], - const unsigned char L_[][16], unsigned char checksum[16]); -# endif /* OPENSSL_NO_OCB */ +void aesni_ecb_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, int enc); +void aesni_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + int enc); +# ifndef OPENSSL_NO_OCB +void aesni_ocb_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, size_t start_block_num, + unsigned char offset_i[16], const unsigned char L_[][16], + unsigned char checksum[16]); +void aesni_ocb_decrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, size_t start_block_num, + unsigned char offset_i[16], const unsigned char L_[][16], + unsigned char checksum[16]); +# endif /* OPENSSL_NO_OCB */ -void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t blocks, - const void *key, const unsigned char *ivec); +void aesni_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char *ivec); -void aesni_xts_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); +void aesni_xts_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key1, const AES_KEY *key2, + const unsigned char iv[16]); -void aesni_xts_decrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); +void aesni_xts_decrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key1, const AES_KEY *key2, + const unsigned char iv[16]); -void aesni_ccm64_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t blocks, - const void *key, const unsigned char ivec[16], +void aesni_ccm64_encrypt_blocks(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char ivec[16], unsigned char cmac[16]); -void aesni_ccm64_decrypt_blocks(const unsigned char *in, unsigned char *out, size_t blocks, - const void *key, const unsigned char ivec[16], +void aesni_ccm64_decrypt_blocks(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char ivec[16], unsigned char cmac[16]); -# if defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) -size_t aesni_gcm_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], u64 *Xi); -size_t aesni_gcm_decrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], u64 *Xi); +# if defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) \ + || defined(_M_X64) +size_t aesni_gcm_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + u64 *Xi); +size_t aesni_gcm_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + u64 *Xi); void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *in, size_t len); -# define AES_gcm_encrypt aesni_gcm_encrypt -# define AES_gcm_decrypt aesni_gcm_decrypt -# define AES_GCM_ASM(ctx) \ - (ctx->ctr == aesni_ctr32_encrypt_blocks && ctx->gcm.funcs.ghash == gcm_ghash_avx) -# endif +# define AES_gcm_encrypt aesni_gcm_encrypt +# define AES_gcm_decrypt aesni_gcm_decrypt +# define AES_GCM_ASM(ctx) \ + (ctx->ctr == aesni_ctr32_encrypt_blocks \ + && ctx->gcm.funcs.ghash == gcm_ghash_avx) +# endif #elif defined(AES_ASM) && (defined(__sparc) || defined(__sparc__)) /* Fujitsu SPARC64 X support */ -# include "crypto/sparc_arch.h" +# include "crypto/sparc_arch.h" -# define SPARC_AES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_AES) -# define HWAES_CAPABLE (OPENSSL_sparcv9cap_P[0] & SPARCV9_FJAESX) -# define HWAES_set_encrypt_key aes_fx_set_encrypt_key -# define HWAES_set_decrypt_key aes_fx_set_decrypt_key -# define HWAES_encrypt aes_fx_encrypt -# define HWAES_decrypt aes_fx_decrypt -# define HWAES_cbc_encrypt aes_fx_cbc_encrypt -# define HWAES_ctr32_encrypt_blocks aes_fx_ctr32_encrypt_blocks +# define SPARC_AES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_AES) +# define HWAES_CAPABLE (OPENSSL_sparcv9cap_P[0] & SPARCV9_FJAESX) +# define HWAES_set_encrypt_key aes_fx_set_encrypt_key +# define HWAES_set_decrypt_key aes_fx_set_decrypt_key +# define HWAES_encrypt aes_fx_encrypt +# define HWAES_decrypt aes_fx_decrypt +# define HWAES_cbc_encrypt aes_fx_cbc_encrypt +# define HWAES_ctr32_encrypt_blocks aes_fx_ctr32_encrypt_blocks void aes_t4_set_encrypt_key(const unsigned char *key, int bits, AES_KEY *ks); void aes_t4_set_decrypt_key(const unsigned char *key, int bits, AES_KEY *ks); -void aes_t4_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void aes_t4_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); +void aes_t4_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void aes_t4_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); /* * Key-length specific subroutines were chosen for following reason. * Each SPARC T4 core can execute up to 8 threads which share core's @@ -260,165 +312,216 @@ void aes_t4_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY * * acceptable, while latter means code size increase to size occupied * by multiple key-length specific subroutines, so why fight? */ -void aes128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, unsigned char *ivec, int /*unused*/); -void aes128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, unsigned char *ivec, int /*unused*/); -void aes192_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, unsigned char *ivec, int /*unused*/); -void aes192_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, unsigned char *ivec, int /*unused*/); -void aes256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, unsigned char *ivec, int /*unused*/); -void aes256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const AES_KEY *key, unsigned char *ivec, int /*unused*/); -void aes128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key, unsigned char *ivec); -void aes192_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key, unsigned char *ivec); -void aes256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key, unsigned char *ivec); -void aes128_t4_xts_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char *ivec); -void aes128_t4_xts_decrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char *ivec); -void aes256_t4_xts_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char *ivec); -void aes256_t4_xts_decrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char *ivec); +void aes128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, + int /*unused*/); +void aes128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, + int /*unused*/); +void aes192_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, + int /*unused*/); +void aes192_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, + int /*unused*/); +void aes256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, + int /*unused*/); +void aes256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, + int /*unused*/); +void aes128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key, + unsigned char *ivec); +void aes192_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key, + unsigned char *ivec); +void aes256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key, + unsigned char *ivec); +void aes128_t4_xts_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key1, + const AES_KEY *key2, const unsigned char *ivec); +void aes128_t4_xts_decrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key1, + const AES_KEY *key2, const unsigned char *ivec); +void aes256_t4_xts_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key1, + const AES_KEY *key2, const unsigned char *ivec); +void aes256_t4_xts_decrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key1, + const AES_KEY *key2, const unsigned char *ivec); #elif defined(OPENSSL_CPUID_OBJ) && defined(__s390__) /* IBM S390X support */ -# include "s390x_arch.h" +# include "s390x_arch.h" /* Convert key size to function code: [16,24,32] -> [18,19,20]. */ -# define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6)) +# define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6)) /* Most modes of operation need km for partial block processing. */ -# define S390X_aes_128_CAPABLE (OPENSSL_s390xcap_P.km[0] & S390X_CAPBIT(S390X_AES_128)) -# define S390X_aes_192_CAPABLE (OPENSSL_s390xcap_P.km[0] & S390X_CAPBIT(S390X_AES_192)) -# define S390X_aes_256_CAPABLE (OPENSSL_s390xcap_P.km[0] & S390X_CAPBIT(S390X_AES_256)) +# define S390X_aes_128_CAPABLE \ + (OPENSSL_s390xcap_P.km[0] & S390X_CAPBIT(S390X_AES_128)) +# define S390X_aes_192_CAPABLE \ + (OPENSSL_s390xcap_P.km[0] & S390X_CAPBIT(S390X_AES_192)) +# define S390X_aes_256_CAPABLE \ + (OPENSSL_s390xcap_P.km[0] & S390X_CAPBIT(S390X_AES_256)) -# define S390X_aes_128_cbc_CAPABLE 1 /* checked by callee */ -# define S390X_aes_192_cbc_CAPABLE 1 -# define S390X_aes_256_cbc_CAPABLE 1 +# define S390X_aes_128_cbc_CAPABLE 1 /* checked by callee */ +# define S390X_aes_192_cbc_CAPABLE 1 +# define S390X_aes_256_cbc_CAPABLE 1 -# define S390X_aes_128_ecb_CAPABLE S390X_aes_128_CAPABLE -# define S390X_aes_192_ecb_CAPABLE S390X_aes_192_CAPABLE -# define S390X_aes_256_ecb_CAPABLE S390X_aes_256_CAPABLE +# define S390X_aes_128_ecb_CAPABLE S390X_aes_128_CAPABLE +# define S390X_aes_192_ecb_CAPABLE S390X_aes_192_CAPABLE +# define S390X_aes_256_ecb_CAPABLE S390X_aes_256_CAPABLE -# define S390X_aes_128_ofb_CAPABLE \ - (S390X_aes_128_CAPABLE && (OPENSSL_s390xcap_P.kmo[0] & S390X_CAPBIT(S390X_AES_128))) -# define S390X_aes_192_ofb_CAPABLE \ - (S390X_aes_192_CAPABLE && (OPENSSL_s390xcap_P.kmo[0] & S390X_CAPBIT(S390X_AES_192))) -# define S390X_aes_256_ofb_CAPABLE \ - (S390X_aes_256_CAPABLE && (OPENSSL_s390xcap_P.kmo[0] & S390X_CAPBIT(S390X_AES_256))) +# define S390X_aes_128_ofb_CAPABLE \ + (S390X_aes_128_CAPABLE \ + && (OPENSSL_s390xcap_P.kmo[0] & S390X_CAPBIT(S390X_AES_128))) +# define S390X_aes_192_ofb_CAPABLE \ + (S390X_aes_192_CAPABLE \ + && (OPENSSL_s390xcap_P.kmo[0] & S390X_CAPBIT(S390X_AES_192))) +# define S390X_aes_256_ofb_CAPABLE \ + (S390X_aes_256_CAPABLE \ + && (OPENSSL_s390xcap_P.kmo[0] & S390X_CAPBIT(S390X_AES_256))) -# define S390X_aes_128_cfb_CAPABLE \ - (S390X_aes_128_CAPABLE && (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_128))) -# define S390X_aes_192_cfb_CAPABLE \ - (S390X_aes_192_CAPABLE && (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_192))) -# define S390X_aes_256_cfb_CAPABLE \ - (S390X_aes_256_CAPABLE && (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_256))) -# define S390X_aes_128_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_128)) -# define S390X_aes_192_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_192)) -# define S390X_aes_256_cfb8_CAPABLE (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_256)) -# define S390X_aes_128_cfb1_CAPABLE 0 -# define S390X_aes_192_cfb1_CAPABLE 0 -# define S390X_aes_256_cfb1_CAPABLE 0 +# define S390X_aes_128_cfb_CAPABLE \ + (S390X_aes_128_CAPABLE \ + && (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_128))) +# define S390X_aes_192_cfb_CAPABLE \ + (S390X_aes_192_CAPABLE \ + && (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_192))) +# define S390X_aes_256_cfb_CAPABLE \ + (S390X_aes_256_CAPABLE \ + && (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_256))) +# define S390X_aes_128_cfb8_CAPABLE \ + (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_128)) +# define S390X_aes_192_cfb8_CAPABLE \ + (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_192)) +# define S390X_aes_256_cfb8_CAPABLE \ + (OPENSSL_s390xcap_P.kmf[0] & S390X_CAPBIT(S390X_AES_256)) +# define S390X_aes_128_cfb1_CAPABLE 0 +# define S390X_aes_192_cfb1_CAPABLE 0 +# define S390X_aes_256_cfb1_CAPABLE 0 -# define S390X_aes_128_ctr_CAPABLE 1 /* checked by callee */ -# define S390X_aes_192_ctr_CAPABLE 1 -# define S390X_aes_256_ctr_CAPABLE 1 +# define S390X_aes_128_ctr_CAPABLE 1 /* checked by callee */ +# define S390X_aes_192_ctr_CAPABLE 1 +# define S390X_aes_256_ctr_CAPABLE 1 -# define S390X_aes_128_xts_CAPABLE 1 /* checked by callee */ -# define S390X_aes_256_xts_CAPABLE 1 +# define S390X_aes_128_xts_CAPABLE 1 /* checked by callee */ +# define S390X_aes_256_xts_CAPABLE 1 -# define S390X_aes_128_gcm_CAPABLE \ - (S390X_aes_128_CAPABLE && (OPENSSL_s390xcap_P.kma[0] & S390X_CAPBIT(S390X_AES_128))) -# define S390X_aes_192_gcm_CAPABLE \ - (S390X_aes_192_CAPABLE && (OPENSSL_s390xcap_P.kma[0] & S390X_CAPBIT(S390X_AES_192))) -# define S390X_aes_256_gcm_CAPABLE \ - (S390X_aes_256_CAPABLE && (OPENSSL_s390xcap_P.kma[0] & S390X_CAPBIT(S390X_AES_256))) +# define S390X_aes_128_gcm_CAPABLE \ + (S390X_aes_128_CAPABLE \ + && (OPENSSL_s390xcap_P.kma[0] & S390X_CAPBIT(S390X_AES_128))) +# define S390X_aes_192_gcm_CAPABLE \ + (S390X_aes_192_CAPABLE \ + && (OPENSSL_s390xcap_P.kma[0] & S390X_CAPBIT(S390X_AES_192))) +# define S390X_aes_256_gcm_CAPABLE \ + (S390X_aes_256_CAPABLE \ + && (OPENSSL_s390xcap_P.kma[0] & S390X_CAPBIT(S390X_AES_256))) -# define S390X_aes_128_ccm_CAPABLE \ - (S390X_aes_128_CAPABLE && (OPENSSL_s390xcap_P.kmac[0] & S390X_CAPBIT(S390X_AES_128))) -# define S390X_aes_192_ccm_CAPABLE \ - (S390X_aes_192_CAPABLE && (OPENSSL_s390xcap_P.kmac[0] & S390X_CAPBIT(S390X_AES_192))) -# define S390X_aes_256_ccm_CAPABLE \ - (S390X_aes_256_CAPABLE && (OPENSSL_s390xcap_P.kmac[0] & S390X_CAPBIT(S390X_AES_256))) -# define S390X_CCM_AAD_FLAG 0x40 +# define S390X_aes_128_ccm_CAPABLE \ + (S390X_aes_128_CAPABLE \ + && (OPENSSL_s390xcap_P.kmac[0] & S390X_CAPBIT(S390X_AES_128))) +# define S390X_aes_192_ccm_CAPABLE \ + (S390X_aes_192_CAPABLE \ + && (OPENSSL_s390xcap_P.kmac[0] & S390X_CAPBIT(S390X_AES_192))) +# define S390X_aes_256_ccm_CAPABLE \ + (S390X_aes_256_CAPABLE \ + && (OPENSSL_s390xcap_P.kmac[0] & S390X_CAPBIT(S390X_AES_256))) +# define S390X_CCM_AAD_FLAG 0x40 -# ifndef OPENSSL_NO_OCB -# define S390X_aes_128_ocb_CAPABLE 0 -# define S390X_aes_192_ocb_CAPABLE 0 -# define S390X_aes_256_ocb_CAPABLE 0 -# endif /* OPENSSL_NO_OCB */ +# ifndef OPENSSL_NO_OCB +# define S390X_aes_128_ocb_CAPABLE 0 +# define S390X_aes_192_ocb_CAPABLE 0 +# define S390X_aes_256_ocb_CAPABLE 0 +# endif /* OPENSSL_NO_OCB */ -# ifndef OPENSSL_NO_SIV -# define S390X_aes_128_siv_CAPABLE 0 -# define S390X_aes_192_siv_CAPABLE 0 -# define S390X_aes_256_siv_CAPABLE 0 -# endif /* OPENSSL_NO_SIV */ +# ifndef OPENSSL_NO_SIV +# define S390X_aes_128_siv_CAPABLE 0 +# define S390X_aes_192_siv_CAPABLE 0 +# define S390X_aes_256_siv_CAPABLE 0 +# endif /* OPENSSL_NO_SIV */ /* Convert key size to function code: [16,24,32] -> [18,19,20]. */ -# define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6)) +# define S390X_AES_FC(keylen) (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6)) #elif defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 64 /* RISC-V 64 support */ -# include "riscv_arch.h" -# define RV64I_ZKND_ZKNE_CAPABLE (RISCV_HAS_ZKND() && RISCV_HAS_ZKNE()) +# include "riscv_arch.h" +# define RV64I_ZKND_ZKNE_CAPABLE (RISCV_HAS_ZKND() && RISCV_HAS_ZKNE()) -int rv64i_zkne_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -int rv64i_zknd_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -void rv64i_zkne_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void rv64i_zknd_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); +int rv64i_zkne_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +int rv64i_zknd_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +void rv64i_zkne_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void rv64i_zknd_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); #elif defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 32 /* RISC-V 32 support */ -# include "riscv_arch.h" -# define RV32I_ZKND_ZKNE_CAPABLE (RISCV_HAS_ZKND() && RISCV_HAS_ZKNE()) -# define RV32I_ZBKB_ZKND_ZKNE_CAPABLE (RV32I_ZKND_ZKNE_CAPABLE && RISCV_HAS_ZBKB()) +# include "riscv_arch.h" +# define RV32I_ZKND_ZKNE_CAPABLE (RISCV_HAS_ZKND() && RISCV_HAS_ZKNE()) +# define RV32I_ZBKB_ZKND_ZKNE_CAPABLE \ + (RV32I_ZKND_ZKNE_CAPABLE && RISCV_HAS_ZBKB()) -int rv32i_zkne_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); +int rv32i_zkne_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); /* set_decrypt_key needs both zknd and zkne */ -int rv32i_zknd_zkne_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -int rv32i_zbkb_zkne_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -int rv32i_zbkb_zknd_zkne_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); -void rv32i_zkne_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void rv32i_zknd_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); +int rv32i_zknd_zkne_set_decrypt_key(const unsigned char *userKey, + const int bits, AES_KEY *key); +int rv32i_zbkb_zkne_set_encrypt_key(const unsigned char *userKey, + const int bits, AES_KEY *key); +int rv32i_zbkb_zknd_zkne_set_decrypt_key(const unsigned char *userKey, + const int bits, AES_KEY *key); +void rv32i_zkne_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void rv32i_zknd_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); #endif #if defined(HWAES_CAPABLE) -int HWAES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -int HWAES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -void HWAES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void HWAES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); -void HWAES_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, const int enc); -void HWAES_ecb_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, const int enc); -void HWAES_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t len, - const void *key, const unsigned char ivec[16]); +int HWAES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +int HWAES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); +void HWAES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void HWAES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); +void HWAES_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + const int enc); +void HWAES_ecb_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, const int enc); +void HWAES_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + const unsigned char ivec[16]); void HWAES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); + const AES_KEY *key1, const AES_KEY *key2, + const unsigned char iv[16]); void HWAES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, - const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); -# ifndef OPENSSL_NO_OCB -# ifdef HWAES_ocb_encrypt -void HWAES_ocb_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, const void *key, - size_t start_block_num, unsigned char offset_i[16], - const unsigned char L_[][16], unsigned char checksum[16]); -# else -# define HWAES_ocb_encrypt ((ocb128_f)NULL) -# endif -# ifdef HWAES_ocb_decrypt -void HWAES_ocb_decrypt(const unsigned char *in, unsigned char *out, size_t blocks, const void *key, - size_t start_block_num, unsigned char offset_i[16], - const unsigned char L_[][16], unsigned char checksum[16]); -# else -# define HWAES_ocb_decrypt ((ocb128_f)NULL) -# endif -# endif /* OPENSSL_NO_OCB */ + const AES_KEY *key1, const AES_KEY *key2, + const unsigned char iv[16]); +# ifndef OPENSSL_NO_OCB +# ifdef HWAES_ocb_encrypt +void HWAES_ocb_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, size_t start_block_num, + unsigned char offset_i[16], const unsigned char L_[][16], + unsigned char checksum[16]); +# else +# define HWAES_ocb_encrypt ((ocb128_f)NULL) +# endif +# ifdef HWAES_ocb_decrypt +void HWAES_ocb_decrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, size_t start_block_num, + unsigned char offset_i[16], const unsigned char L_[][16], + unsigned char checksum[16]); +# else +# define HWAES_ocb_decrypt ((ocb128_f)NULL) +# endif +# endif /* OPENSSL_NO_OCB */ #endif /* HWAES_CAPABLE */ diff --git a/libs/OpenSSL/include/crypto/aria.h b/libs/OpenSSL/include/crypto/aria.h index f3c29494..7b31658d 100644 --- a/libs/OpenSSL/include/crypto/aria.h +++ b/libs/OpenSSL/include/crypto/aria.h @@ -8,7 +8,8 @@ * https://www.openssl.org/source/license.html */ -/* Copyright (c) 2017 National Security Research Institute. All rights reserved. */ +/* Copyright (c) 2017 National Security Research Institute. All rights + * reserved. */ #ifndef OSSL_CRYPTO_ARIA_H #define OSSL_CRYPTO_ARIA_H @@ -17,33 +18,36 @@ #include #ifdef OPENSSL_NO_ARIA -# error ARIA is disabled. +# error ARIA is disabled. #endif #define ARIA_ENCRYPT 1 #define ARIA_DECRYPT 0 #define ARIA_BLOCK_SIZE 16 /* Size of each encryption/decryption block */ -#define ARIA_MAX_KEYS 17 /* Number of keys needed in the worst case */ +#define ARIA_MAX_KEYS 17 /* Number of keys needed in the worst case */ typedef union { - unsigned char c[ARIA_BLOCK_SIZE]; - unsigned int u[ARIA_BLOCK_SIZE / sizeof(unsigned int)]; + unsigned char c[ARIA_BLOCK_SIZE]; + unsigned int u[ARIA_BLOCK_SIZE / sizeof(unsigned int)]; } ARIA_u128; typedef unsigned char ARIA_c128[ARIA_BLOCK_SIZE]; struct aria_key_st { - ARIA_u128 rd_key[ARIA_MAX_KEYS]; - unsigned int rounds; + ARIA_u128 rd_key[ARIA_MAX_KEYS]; + unsigned int rounds; }; typedef struct aria_key_st ARIA_KEY; -int ossl_aria_set_encrypt_key(const unsigned char *userKey, const int bits, ARIA_KEY *key); -int ossl_aria_set_decrypt_key(const unsigned char *userKey, const int bits, ARIA_KEY *key); +int ossl_aria_set_encrypt_key(const unsigned char *userKey, const int bits, + ARIA_KEY *key); +int ossl_aria_set_decrypt_key(const unsigned char *userKey, const int bits, + ARIA_KEY *key); -void ossl_aria_encrypt(const unsigned char *in, unsigned char *out, const ARIA_KEY *key); +void ossl_aria_encrypt(const unsigned char *in, unsigned char *out, + const ARIA_KEY *key); #endif diff --git a/libs/OpenSSL/include/crypto/asn1.h b/libs/OpenSSL/include/crypto/asn1.h index 2386d045..94a6684e 100644 --- a/libs/OpenSSL/include/crypto/asn1.h +++ b/libs/OpenSSL/include/crypto/asn1.h @@ -22,59 +22,65 @@ struct evp_pkey_asn1_method_st { - int pkey_id; - int pkey_base_id; - unsigned long pkey_flags; - char *pem_str; - char *info; - int (*pub_decode)(EVP_PKEY *pk, const X509_PUBKEY *pub); - int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk); - int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b); - int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); - int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf); - int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); - int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); - int (*pkey_size)(const EVP_PKEY *pk); - int (*pkey_bits)(const EVP_PKEY *pk); - int (*pkey_security_bits)(const EVP_PKEY *pk); - int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen); - int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder); - int (*param_missing)(const EVP_PKEY *pk); - int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from); - int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b); - int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); - int (*sig_print)(BIO *out, const X509_ALGOR *sigalg, const ASN1_STRING *sig, int indent, + int pkey_id; + int pkey_base_id; + unsigned long pkey_flags; + char *pem_str; + char *info; + int (*pub_decode)(EVP_PKEY *pk, const X509_PUBKEY *pub); + int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk); + int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b); + int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); + int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf); + int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); + int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); + int (*pkey_size)(const EVP_PKEY *pk); + int (*pkey_bits)(const EVP_PKEY *pk); + int (*pkey_security_bits)(const EVP_PKEY *pk); + int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen); + int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder); + int (*param_missing)(const EVP_PKEY *pk); + int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from); + int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b); + int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); - void (*pkey_free)(EVP_PKEY *pkey); - int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2); - /* Legacy functions for old PEM */ - int (*old_priv_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen); - int (*old_priv_encode)(const EVP_PKEY *pkey, unsigned char **pder); - /* Custom ASN1 signature verification */ - int (*item_verify)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, const X509_ALGOR *a, - const ASN1_BIT_STRING *sig, EVP_PKEY *pkey); - int (*item_sign)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, X509_ALGOR *alg1, - X509_ALGOR *alg2, ASN1_BIT_STRING *sig); - int (*siginf_set)(X509_SIG_INFO *siginf, const X509_ALGOR *alg, const ASN1_STRING *sig); - /* Check */ - int (*pkey_check)(const EVP_PKEY *pk); - int (*pkey_public_check)(const EVP_PKEY *pk); - int (*pkey_param_check)(const EVP_PKEY *pk); - /* Get/set raw private/public key data */ - int (*set_priv_key)(EVP_PKEY *pk, const unsigned char *priv, size_t len); - int (*set_pub_key)(EVP_PKEY *pk, const unsigned char *pub, size_t len); - int (*get_priv_key)(const EVP_PKEY *pk, unsigned char *priv, size_t *len); - int (*get_pub_key)(const EVP_PKEY *pk, unsigned char *pub, size_t *len); + int (*sig_print)(BIO *out, const X509_ALGOR *sigalg, const ASN1_STRING *sig, + int indent, ASN1_PCTX *pctx); + void (*pkey_free)(EVP_PKEY *pkey); + int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2); + /* Legacy functions for old PEM */ + int (*old_priv_decode)(EVP_PKEY *pkey, const unsigned char **pder, + int derlen); + int (*old_priv_encode)(const EVP_PKEY *pkey, unsigned char **pder); + /* Custom ASN1 signature verification */ + int (*item_verify)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, + const X509_ALGOR *a, const ASN1_BIT_STRING *sig, + EVP_PKEY *pkey); + int (*item_sign)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, + X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig); + int (*siginf_set)(X509_SIG_INFO *siginf, const X509_ALGOR *alg, + const ASN1_STRING *sig); + /* Check */ + int (*pkey_check)(const EVP_PKEY *pk); + int (*pkey_public_check)(const EVP_PKEY *pk); + int (*pkey_param_check)(const EVP_PKEY *pk); + /* Get/set raw private/public key data */ + int (*set_priv_key)(EVP_PKEY *pk, const unsigned char *priv, size_t len); + int (*set_pub_key)(EVP_PKEY *pk, const unsigned char *pub, size_t len); + int (*get_priv_key)(const EVP_PKEY *pk, unsigned char *priv, size_t *len); + int (*get_pub_key)(const EVP_PKEY *pk, unsigned char *pub, size_t *len); - /* Exports and imports to / from providers */ - size_t (*dirty_cnt)(const EVP_PKEY *pk); - int (*export_to)(const EVP_PKEY *pk, void *to_keydata, OSSL_FUNC_keymgmt_import_fn *importer, - OSSL_LIB_CTX *libctx, const char *propq); - OSSL_CALLBACK *import_from; - int (*copy)(EVP_PKEY *to, EVP_PKEY *from); + /* Exports and imports to / from providers */ + size_t (*dirty_cnt)(const EVP_PKEY *pk); + int (*export_to)(const EVP_PKEY *pk, void *to_keydata, + OSSL_FUNC_keymgmt_import_fn *importer, OSSL_LIB_CTX *libctx, + const char *propq); + OSSL_CALLBACK *import_from; + int (*copy)(EVP_PKEY *to, EVP_PKEY *from); - int (*priv_decode_ex)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); + int (*priv_decode_ex)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); } /* EVP_PKEY_ASN1_METHOD */; DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD) @@ -96,35 +102,36 @@ extern const EVP_PKEY_ASN1_METHOD ossl_rsa_pss_asn1_meth; * These are used internally in the ASN1_OBJECT to keep track of whether the * names and data need to be free()ed */ -#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ -#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ +#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ +#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ #define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ -#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ +#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ struct asn1_object_st { - const char *sn, *ln; - int nid; - int length; - const unsigned char *data; /* data remains const after init */ - int flags; /* Should we free this one */ + const char *sn, *ln; + int nid; + int length; + const unsigned char *data; /* data remains const after init */ + int flags; /* Should we free this one */ }; /* ASN1 print context structure */ struct asn1_pctx_st { - unsigned long flags; - unsigned long nm_flags; - unsigned long cert_flags; - unsigned long oid_flags; - unsigned long str_flags; + unsigned long flags; + unsigned long nm_flags; + unsigned long cert_flags; + unsigned long oid_flags; + unsigned long str_flags; } /* ASN1_PCTX */; /* ASN1 type functions */ -int ossl_asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, unsigned char *data, int len); -int ossl_asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num, unsigned char *data, - int max_len); +int ossl_asn1_type_set_octetstring_int(ASN1_TYPE *a, long num, + unsigned char *data, int len); +int ossl_asn1_type_get_octetstring_int(const ASN1_TYPE *a, long *num, + unsigned char *data, int max_len); int ossl_x509_algor_new_from_md(X509_ALGOR **palg, const EVP_MD *md); const EVP_MD *ossl_x509_algor_get_md(X509_ALGOR *alg); @@ -132,8 +139,9 @@ X509_ALGOR *ossl_x509_algor_mgf1_decode(X509_ALGOR *alg); int ossl_x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md); int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags); -EVP_PKEY *ossl_d2i_PrivateKey_legacy(int keytype, EVP_PKEY **a, const unsigned char **pp, - long length, OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *ossl_d2i_PrivateKey_legacy(int keytype, EVP_PKEY **a, + const unsigned char **pp, long length, + OSSL_LIB_CTX *libctx, const char *propq); X509_ALGOR *ossl_X509_ALGOR_from_nid(int nid, int ptype, void *pval); time_t ossl_asn1_string_to_time_t(const char *asn1_string); diff --git a/libs/OpenSSL/include/crypto/asn1_dsa.h b/libs/OpenSSL/include/crypto/asn1_dsa.h index ab9f5c08..6967d7f0 100644 --- a/libs/OpenSSL/include/crypto/asn1_dsa.h +++ b/libs/OpenSSL/include/crypto/asn1_dsa.h @@ -18,6 +18,7 @@ int ossl_encode_der_integer(WPACKET *pkt, const BIGNUM *n); int ossl_encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s); int ossl_decode_der_length(PACKET *pkt, PACKET *subpkt); int ossl_decode_der_integer(PACKET *pkt, BIGNUM *n); -size_t ossl_decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin, size_t len); +size_t ossl_decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin, + size_t len); #endif diff --git a/libs/OpenSSL/include/crypto/bn.h b/libs/OpenSSL/include/crypto/bn.h index 045c8764..28bbf509 100644 --- a/libs/OpenSSL/include/crypto/bn.h +++ b/libs/OpenSSL/include/crypto/bn.h @@ -71,35 +71,44 @@ int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words); * is constant-time by itself. They all have pre-conditions, consult source * code... */ -int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_MONT_CTX *mont, - BN_CTX *ctx); -int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); -int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); -int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); -int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); +int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); int bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); -int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); #define BN_PRIMETEST_COMPOSITE 0 #define BN_PRIMETEST_COMPOSITE_WITH_FACTOR 1 #define BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME 2 #define BN_PRIMETEST_PROBABLY_PRIME 3 -int ossl_bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx, BN_GENCB *cb, - int enhanced, int *status); -int ossl_bn_check_generated_prime(const BIGNUM *w, int checks, BN_CTX *ctx, BN_GENCB *cb); +int ossl_bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx, + BN_GENCB *cb, int enhanced, int *status); +int ossl_bn_check_generated_prime(const BIGNUM *w, int checks, BN_CTX *ctx, + BN_GENCB *cb); const BIGNUM *ossl_bn_get0_small_factors(void); -int ossl_bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout, BIGNUM *p1, BIGNUM *p2, - const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2, - int nlen, const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); +int ossl_bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout, BIGNUM *p1, + BIGNUM *p2, const BIGNUM *Xp, + const BIGNUM *Xp1, const BIGNUM *Xp2, + int nlen, const BIGNUM *e, + BN_CTX *ctx, BN_GENCB *cb); -int ossl_bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin, const BIGNUM *r1, - const BIGNUM *r2, int nlen, const BIGNUM *e, BN_CTX *ctx, +int ossl_bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin, + const BIGNUM *r1, const BIGNUM *r2, + int nlen, const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); OSSL_LIB_CTX *ossl_bn_get_libctx(BN_CTX *ctx); diff --git a/libs/OpenSSL/include/crypto/bn_dh.h b/libs/OpenSSL/include/crypto/bn_dh.h index cd807b93..fa6b959f 100644 --- a/libs/OpenSSL/include/crypto/bn_dh.h +++ b/libs/OpenSSL/include/crypto/bn_dh.h @@ -7,10 +7,10 @@ * https://www.openssl.org/source/license.html */ -#define declare_dh_bn(x) \ - extern const BIGNUM ossl_bignum_dh##x##_p; \ - extern const BIGNUM ossl_bignum_dh##x##_q; \ - extern const BIGNUM ossl_bignum_dh##x##_g; +#define declare_dh_bn(x) \ + extern const BIGNUM ossl_bignum_dh##x##_p; \ + extern const BIGNUM ossl_bignum_dh##x##_q; \ + extern const BIGNUM ossl_bignum_dh##x##_g; declare_dh_bn(1024_160) declare_dh_bn(2048_224) declare_dh_bn(2048_256) diff --git a/libs/OpenSSL/include/crypto/chacha.h b/libs/OpenSSL/include/crypto/chacha.h index 134bc4f4..efe086d8 100644 --- a/libs/OpenSSL/include/crypto/chacha.h +++ b/libs/OpenSSL/include/crypto/chacha.h @@ -31,9 +31,9 @@ void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp, size_t len, * as trivial as collecting bytes into 32-bit elements, it's reckoned * that below macro is sufficient. */ -#define CHACHA_U8TOU32(p) \ - (((unsigned int)(p)[0]) | ((unsigned int)(p)[1] << 8) | ((unsigned int)(p)[2] << 16) \ - | ((unsigned int)(p)[3] << 24)) +#define CHACHA_U8TOU32(p) \ + (((unsigned int)(p)[0]) | ((unsigned int)(p)[1] << 8) \ + | ((unsigned int)(p)[2] << 16) | ((unsigned int)(p)[3] << 24)) #define CHACHA_KEY_SIZE 32 #define CHACHA_CTR_SIZE 16 diff --git a/libs/OpenSSL/include/crypto/cmll_platform.h b/libs/OpenSSL/include/crypto/cmll_platform.h index f490dee0..bf472b79 100644 --- a/libs/OpenSSL/include/crypto/cmll_platform.h +++ b/libs/OpenSSL/include/crypto/cmll_platform.h @@ -14,29 +14,37 @@ #if defined(CMLL_ASM) && (defined(__sparc) || defined(__sparc__)) /* Fujitsu SPARC64 X support */ -# include "crypto/sparc_arch.h" +# include "crypto/sparc_arch.h" -# ifndef OPENSSL_NO_CAMELLIA -# define SPARC_CMLL_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_CAMELLIA) -# include +# ifndef OPENSSL_NO_CAMELLIA +# define SPARC_CMLL_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_CAMELLIA) +# include void cmll_t4_set_key(const unsigned char *key, int bits, CAMELLIA_KEY *ks); -void cmll_t4_encrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key); -void cmll_t4_decrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key); +void cmll_t4_encrypt(const unsigned char *in, unsigned char *out, + const CAMELLIA_KEY *key); +void cmll_t4_decrypt(const unsigned char *in, unsigned char *out, + const CAMELLIA_KEY *key); -void cmll128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const CAMELLIA_KEY *key, unsigned char *ivec, int /*unused*/); -void cmll128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const CAMELLIA_KEY *key, unsigned char *ivec, int /*unused*/); -void cmll256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const CAMELLIA_KEY *key, unsigned char *ivec, int /*unused*/); -void cmll256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const CAMELLIA_KEY *key, unsigned char *ivec, int /*unused*/); -void cmll128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const CAMELLIA_KEY *key, unsigned char *ivec); -void cmll256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, - const CAMELLIA_KEY *key, unsigned char *ivec); -# endif /* OPENSSL_NO_CAMELLIA */ +void cmll128_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const CAMELLIA_KEY *key, + unsigned char *ivec, int /*unused*/); +void cmll128_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const CAMELLIA_KEY *key, + unsigned char *ivec, int /*unused*/); +void cmll256_t4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const CAMELLIA_KEY *key, + unsigned char *ivec, int /*unused*/); +void cmll256_t4_cbc_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const CAMELLIA_KEY *key, + unsigned char *ivec, int /*unused*/); +void cmll128_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const CAMELLIA_KEY *key, + unsigned char *ivec); +void cmll256_t4_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const CAMELLIA_KEY *key, + unsigned char *ivec); +# endif /* OPENSSL_NO_CAMELLIA */ #endif /* CMLL_ASM && sparc */ diff --git a/libs/OpenSSL/include/crypto/cryptlib.h b/libs/OpenSSL/include/crypto/cryptlib.h index 50673671..cba5f1c5 100644 --- a/libs/OpenSSL/include/crypto/cryptlib.h +++ b/libs/OpenSSL/include/crypto/cryptlib.h @@ -16,7 +16,8 @@ /* This file is not scanned by mkdef.pl, whereas cryptlib.h is */ -int ossl_init_thread_start(const void *index, void *arg, OSSL_thread_stop_handler_fn handfn); +int ossl_init_thread_start(const void *index, void *arg, + OSSL_thread_stop_handler_fn handfn); int ossl_init_thread_deregister(void *index); int ossl_init_thread(void); void ossl_cleanup_thread(void); @@ -32,6 +33,7 @@ void ossl_ctx_thread_stop(OSSL_LIB_CTX *ctx); void ossl_trace_cleanup(void); void ossl_malloc_setup_failures(void); -int ossl_crypto_alloc_ex_data_intern(int class_index, void *obj, CRYPTO_EX_DATA *ad, int idx); +int ossl_crypto_alloc_ex_data_intern(int class_index, void *obj, + CRYPTO_EX_DATA *ad, int idx); #endif /* OSSL_CRYPTO_CRYPTLIB_H */ diff --git a/libs/OpenSSL/include/crypto/ctype.h b/libs/OpenSSL/include/crypto/ctype.h index c066aa5f..64c9ac97 100644 --- a/libs/OpenSSL/include/crypto/ctype.h +++ b/libs/OpenSSL/include/crypto/ctype.h @@ -53,8 +53,8 @@ int ossl_toascii(int c); int ossl_fromascii(int c); #else -# define ossl_toascii(c) (c) -# define ossl_fromascii(c) (c) +# define ossl_toascii(c) (c) +# define ossl_fromascii(c) (c) #endif int ossl_ctype_check(int c, unsigned int mask); @@ -70,9 +70,9 @@ int ossl_ascii_isdigit(int c); #define ossl_isalnum(c) (ossl_ctype_check((c), CTYPE_MASK_alnum)) #define ossl_isalpha(c) (ossl_ctype_check((c), CTYPE_MASK_alpha)) #ifdef CHARSET_EBCDIC -# define ossl_isascii(c) (ossl_ctype_check((c), CTYPE_MASK_ascii)) +# define ossl_isascii(c) (ossl_ctype_check((c), CTYPE_MASK_ascii)) #else -# define ossl_isascii(c) (((c) & ~127) == 0) +# define ossl_isascii(c) (((c) & ~127) == 0) #endif #define ossl_isblank(c) (ossl_ctype_check((c), CTYPE_MASK_blank)) #define ossl_iscntrl(c) (ossl_ctype_check((c), CTYPE_MASK_cntrl)) diff --git a/libs/OpenSSL/include/crypto/decoder.h b/libs/OpenSSL/include/crypto/decoder.h index dd500728..9e727bbc 100644 --- a/libs/OpenSSL/include/crypto/decoder.h +++ b/libs/OpenSSL/include/crypto/decoder.h @@ -19,14 +19,18 @@ * except read a DER blob and pass it on as a provider object abstraction * (provider-object(7)). */ -void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov); +void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef, + OSSL_PROVIDER *prov); -OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder, void *decoderctx); +OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder, + void *decoderctx); void ossl_decoder_instance_free(OSSL_DECODER_INSTANCE *decoder_inst); -int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx, OSSL_DECODER_INSTANCE *di); +int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx, + OSSL_DECODER_INSTANCE *di); -int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx, EVP_PKEY **pkey, const char *keytype, - OSSL_LIB_CTX *libctx, const char *propquery); +int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx, EVP_PKEY **pkey, + const char *keytype, OSSL_LIB_CTX *libctx, + const char *propquery); int ossl_decoder_get_number(const OSSL_DECODER *encoder); int ossl_decoder_store_cache_flush(OSSL_LIB_CTX *libctx); diff --git a/libs/OpenSSL/include/crypto/des_platform.h b/libs/OpenSSL/include/crypto/des_platform.h index 675d149f..d3f3cb32 100644 --- a/libs/OpenSSL/include/crypto/des_platform.h +++ b/libs/OpenSSL/include/crypto/des_platform.h @@ -14,21 +14,21 @@ #if defined(DES_ASM) && (defined(__sparc) || defined(__sparc__)) /* Fujitsu SPARC64 X support */ -# include "crypto/sparc_arch.h" +# include "crypto/sparc_arch.h" -# ifndef OPENSSL_NO_DES -# define SPARC_DES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_DES) -# include +# ifndef OPENSSL_NO_DES +# define SPARC_DES_CAPABLE (OPENSSL_sparcv9cap_P[1] & CFR_DES) +# include void des_t4_key_expand(const void *key, DES_key_schedule *ks); -void des_t4_ede3_cbc_encrypt(const void *inp, void *out, size_t len, const DES_key_schedule ks[3], - unsigned char iv[8]); -void des_t4_ede3_cbc_decrypt(const void *inp, void *out, size_t len, const DES_key_schedule ks[3], - unsigned char iv[8]); -void des_t4_cbc_encrypt(const void *inp, void *out, size_t len, const DES_key_schedule *ks, - unsigned char iv[8]); -void des_t4_cbc_decrypt(const void *inp, void *out, size_t len, const DES_key_schedule *ks, - unsigned char iv[8]); -# endif /* OPENSSL_NO_DES */ +void des_t4_ede3_cbc_encrypt(const void *inp, void *out, size_t len, + const DES_key_schedule ks[3], unsigned char iv[8]); +void des_t4_ede3_cbc_decrypt(const void *inp, void *out, size_t len, + const DES_key_schedule ks[3], unsigned char iv[8]); +void des_t4_cbc_encrypt(const void *inp, void *out, size_t len, + const DES_key_schedule *ks, unsigned char iv[8]); +void des_t4_cbc_decrypt(const void *inp, void *out, size_t len, + const DES_key_schedule *ks, unsigned char iv[8]); +# endif /* OPENSSL_NO_DES */ #endif /* DES_ASM && sparc */ diff --git a/libs/OpenSSL/include/crypto/dh.h b/libs/OpenSSL/include/crypto/dh.h index 62d2e2f8..7c905025 100644 --- a/libs/OpenSSL/include/crypto/dh.h +++ b/libs/OpenSSL/include/crypto/dh.h @@ -19,8 +19,10 @@ DH *ossl_dh_new_by_nid_ex(OSSL_LIB_CTX *libctx, int nid); DH *ossl_dh_new_ex(OSSL_LIB_CTX *libctx); void ossl_dh_set0_libctx(DH *d, OSSL_LIB_CTX *libctx); -int ossl_dh_generate_ffc_parameters(DH *dh, int type, int pbits, int qbits, BN_GENCB *cb); -int ossl_dh_generate_public_key(BN_CTX *ctx, const DH *dh, const BIGNUM *priv_key, BIGNUM *pub_key); +int ossl_dh_generate_ffc_parameters(DH *dh, int type, int pbits, int qbits, + BN_GENCB *cb); +int ossl_dh_generate_public_key(BN_CTX *ctx, const DH *dh, + const BIGNUM *priv_key, BIGNUM *pub_key); int ossl_dh_get_named_group_uid_from_size(int pbits); const char *ossl_dh_gen_type_id2name(int id); int ossl_dh_gen_type_name2id(const char *name, int type); @@ -30,25 +32,31 @@ int ossl_dh_is_named_safe_prime_group(const DH *dh); FFC_PARAMS *ossl_dh_get0_params(DH *dh); int ossl_dh_get0_nid(const DH *dh); int ossl_dh_params_fromdata(DH *dh, const OSSL_PARAM params[]); -int ossl_dh_key_fromdata(DH *dh, const OSSL_PARAM params[], int include_private); +int ossl_dh_key_fromdata(DH *dh, const OSSL_PARAM params[], + int include_private); int ossl_dh_params_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM params[]); -int ossl_dh_key_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM params[], int include_private); -DH *ossl_dh_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); +int ossl_dh_key_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM params[], + int include_private); +DH *ossl_dh_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); -int ossl_dh_check_pub_key_partial(const DH *dh, const BIGNUM *pub_key, int *ret); +int ossl_dh_check_pub_key_partial(const DH *dh, const BIGNUM *pub_key, + int *ret); int ossl_dh_check_priv_key(const DH *dh, const BIGNUM *priv_key, int *ret); int ossl_dh_check_pairwise(const DH *dh); const DH_METHOD *ossl_dh_get_method(const DH *dh); int ossl_dh_buf2key(DH *key, const unsigned char *buf, size_t len); -size_t ossl_dh_key2buf(const DH *dh, unsigned char **pbuf, size_t size, int alloc); +size_t ossl_dh_key2buf(const DH *dh, unsigned char **pbuf, size_t size, + int alloc); -int ossl_dh_kdf_X9_42_asn1(unsigned char *out, size_t outlen, const unsigned char *Z, size_t Zlen, - const char *cek_alg, const unsigned char *ukm, size_t ukmlen, - const EVP_MD *md, OSSL_LIB_CTX *libctx, const char *propq); +int ossl_dh_kdf_X9_42_asn1(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + const char *cek_alg, const unsigned char *ukm, + size_t ukmlen, const EVP_MD *md, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_dh_is_foreign(const DH *dh); DH *ossl_dh_dup(const DH *dh, int selection); diff --git a/libs/OpenSSL/include/crypto/dsa.h b/libs/OpenSSL/include/crypto/dsa.h index f73d5c02..db5af69c 100644 --- a/libs/OpenSSL/include/crypto/dsa.h +++ b/libs/OpenSSL/include/crypto/dsa.h @@ -22,23 +22,27 @@ DSA *ossl_dsa_new(OSSL_LIB_CTX *libctx); void ossl_dsa_set0_libctx(DSA *d, OSSL_LIB_CTX *libctx); -int ossl_dsa_generate_ffc_parameters(DSA *dsa, int type, int pbits, int qbits, BN_GENCB *cb); +int ossl_dsa_generate_ffc_parameters(DSA *dsa, int type, int pbits, int qbits, + BN_GENCB *cb); -int ossl_dsa_sign_int(int type, const unsigned char *dgst, int dlen, unsigned char *sig, - unsigned int *siglen, DSA *dsa, unsigned int nonce_type, - const char *digestname, OSSL_LIB_CTX *libctx, const char *propq); +int ossl_dsa_sign_int(int type, const unsigned char *dgst, int dlen, + unsigned char *sig, unsigned int *siglen, DSA *dsa, + unsigned int nonce_type, const char *digestname, + OSSL_LIB_CTX *libctx, const char *propq); FFC_PARAMS *ossl_dsa_get0_params(DSA *dsa); int ossl_dsa_ffc_params_fromdata(DSA *dsa, const OSSL_PARAM params[]); -int ossl_dsa_key_fromdata(DSA *dsa, const OSSL_PARAM params[], int include_private); -DSA *ossl_dsa_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); +int ossl_dsa_key_fromdata(DSA *dsa, const OSSL_PARAM params[], + int include_private); +DSA *ossl_dsa_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); -int ossl_dsa_generate_public_key(BN_CTX *ctx, const DSA *dsa, const BIGNUM *priv_key, - BIGNUM *pub_key); +int ossl_dsa_generate_public_key(BN_CTX *ctx, const DSA *dsa, + const BIGNUM *priv_key, BIGNUM *pub_key); int ossl_dsa_check_params(const DSA *dsa, int checktype, int *ret); int ossl_dsa_check_pub_key(const DSA *dsa, const BIGNUM *pub_key, int *ret); -int ossl_dsa_check_pub_key_partial(const DSA *dsa, const BIGNUM *pub_key, int *ret); +int ossl_dsa_check_pub_key_partial(const DSA *dsa, const BIGNUM *pub_key, + int *ret); int ossl_dsa_check_priv_key(const DSA *dsa, const BIGNUM *priv_key, int *ret); int ossl_dsa_check_pairwise(const DSA *dsa); int ossl_dsa_is_foreign(const DSA *dsa); diff --git a/libs/OpenSSL/include/crypto/ec.h b/libs/OpenSSL/include/crypto/ec.h index 1f466495..a0af4691 100644 --- a/libs/OpenSSL/include/crypto/ec.h +++ b/libs/OpenSSL/include/crypto/ec.h @@ -22,9 +22,9 @@ int ossl_ec_curve_nist2nid_int(const char *name); int evp_pkey_ctx_set_ec_param_enc_prov(EVP_PKEY_CTX *ctx, int param_enc); #ifndef OPENSSL_NO_EC -# include -# include -# include "crypto/types.h" +# include +# include +# include "crypto/types.h" /*- * Computes the multiplicative inverse of x in the range @@ -47,15 +47,17 @@ int evp_pkey_ctx_set_ec_param_enc_prov(EVP_PKEY_CTX *ctx, int param_enc); * reduction round on the input can be omitted by the underlying * implementations for better SCA properties on regular input values). */ -__owur int ossl_ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res, const BIGNUM *x, - BN_CTX *ctx); +__owur int ossl_ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res, + const BIGNUM *x, BN_CTX *ctx); /*- * ECDH Key Derivation Function as defined in ANSI X9.63 */ -int ossl_ecdh_kdf_X9_63(unsigned char *out, size_t outlen, const unsigned char *Z, size_t Zlen, - const unsigned char *sinfo, size_t sinfolen, const EVP_MD *md, - OSSL_LIB_CTX *libctx, const char *propq); +int ossl_ecdh_kdf_X9_63(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + const unsigned char *sinfo, size_t sinfolen, + const EVP_MD *md, OSSL_LIB_CTX *libctx, + const char *propq); int ossl_ec_key_public_check(const EC_KEY *eckey, BN_CTX *ctx); int ossl_ec_key_public_check_quick(const EC_KEY *eckey, BN_CTX *ctx); @@ -66,20 +68,23 @@ const char *ossl_ec_key_get0_propq(const EC_KEY *eckey); void ossl_ec_key_set0_libctx(EC_KEY *key, OSSL_LIB_CTX *libctx); /* Backend support */ -int ossl_ec_group_todata(const EC_GROUP *group, OSSL_PARAM_BLD *tmpl, OSSL_PARAM params[], - OSSL_LIB_CTX *libctx, const char *propq, BN_CTX *bnctx, +int ossl_ec_group_todata(const EC_GROUP *group, OSSL_PARAM_BLD *tmpl, + OSSL_PARAM params[], OSSL_LIB_CTX *libctx, + const char *propq, BN_CTX *bnctx, unsigned char **genbuf); int ossl_ec_group_fromdata(EC_KEY *ec, const OSSL_PARAM params[]); int ossl_ec_group_set_params(EC_GROUP *group, const OSSL_PARAM params[]); -int ossl_ec_key_fromdata(EC_KEY *ecx, const OSSL_PARAM params[], int include_private); +int ossl_ec_key_fromdata(EC_KEY *ecx, const OSSL_PARAM params[], + int include_private); int ossl_ec_key_otherparams_fromdata(EC_KEY *ec, const OSSL_PARAM params[]); int ossl_ec_key_is_foreign(const EC_KEY *ec); EC_KEY *ossl_ec_key_dup(const EC_KEY *key, int selection); int ossl_x509_algor_is_sm2(const X509_ALGOR *palg); -EC_KEY *ossl_ec_key_param_from_x509_algor(const X509_ALGOR *palg, OSSL_LIB_CTX *libctx, +EC_KEY *ossl_ec_key_param_from_x509_algor(const X509_ALGOR *palg, + OSSL_LIB_CTX *libctx, const char *propq); -EC_KEY *ossl_ec_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); +EC_KEY *ossl_ec_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_ec_set_ecdh_cofactor_mode(EC_KEY *ec, int mode); int ossl_ec_encoding_name2id(const char *name); @@ -90,9 +95,12 @@ char *ossl_ec_pt_format_id2name(int id); char *ossl_ec_check_group_type_id2name(int flags); int ossl_ec_set_check_group_type_from_name(EC_KEY *ec, const char *name); -int ossl_ec_generate_key_dhkem(EC_KEY *eckey, const unsigned char *ikm, size_t ikmlen); -int ossl_ecdsa_deterministic_sign(const unsigned char *dgst, int dlen, unsigned char *sig, - unsigned int *siglen, EC_KEY *eckey, unsigned int nonce_type, - const char *digestname, OSSL_LIB_CTX *libctx, const char *propq); +int ossl_ec_generate_key_dhkem(EC_KEY *eckey, const unsigned char *ikm, + size_t ikmlen); +int ossl_ecdsa_deterministic_sign(const unsigned char *dgst, int dlen, + unsigned char *sig, unsigned int *siglen, + EC_KEY *eckey, unsigned int nonce_type, + const char *digestname, OSSL_LIB_CTX *libctx, + const char *propq); #endif /* OPENSSL_NO_EC */ #endif diff --git a/libs/OpenSSL/include/crypto/ecx.h b/libs/OpenSSL/include/crypto/ecx.h index 43a5bb5a..3f012d51 100644 --- a/libs/OpenSSL/include/crypto/ecx.h +++ b/libs/OpenSSL/include/crypto/ecx.h @@ -17,115 +17,130 @@ #ifndef OPENSSL_NO_EC -# include -# include -# include -# include "internal/refcount.h" -# include "crypto/types.h" +# include +# include +# include +# include "internal/refcount.h" +# include "crypto/types.h" -# define X25519_KEYLEN 32 -# define X448_KEYLEN 56 -# define ED25519_KEYLEN 32 -# define ED448_KEYLEN 57 +# define X25519_KEYLEN 32 +# define X448_KEYLEN 56 +# define ED25519_KEYLEN 32 +# define ED448_KEYLEN 57 -# define MAX_KEYLEN ED448_KEYLEN +# define MAX_KEYLEN ED448_KEYLEN -# define X25519_BITS 253 -# define X25519_SECURITY_BITS 128 +# define X25519_BITS 253 +# define X25519_SECURITY_BITS 128 -# define X448_BITS 448 -# define X448_SECURITY_BITS 224 +# define X448_BITS 448 +# define X448_SECURITY_BITS 224 -# define ED25519_BITS 256 +# define ED25519_BITS 256 /* RFC8032 Section 8.5 */ -# define ED25519_SECURITY_BITS 128 -# define ED25519_SIGSIZE 64 +# define ED25519_SECURITY_BITS 128 +# define ED25519_SIGSIZE 64 -# define ED448_BITS 456 +# define ED448_BITS 456 /* RFC8032 Section 8.5 */ -# define ED448_SECURITY_BITS 224 -# define ED448_SIGSIZE 114 +# define ED448_SECURITY_BITS 224 +# define ED448_SIGSIZE 114 typedef enum { - ECX_KEY_TYPE_X25519, - ECX_KEY_TYPE_X448, - ECX_KEY_TYPE_ED25519, - ECX_KEY_TYPE_ED448 + ECX_KEY_TYPE_X25519, + ECX_KEY_TYPE_X448, + ECX_KEY_TYPE_ED25519, + ECX_KEY_TYPE_ED448 } ECX_KEY_TYPE; -# define KEYTYPE2NID(type) \ - ((type) == ECX_KEY_TYPE_X25519 \ - ? EVP_PKEY_X25519 \ - : ((type) == ECX_KEY_TYPE_X448 \ - ? EVP_PKEY_X448 \ - : ((type) == ECX_KEY_TYPE_ED25519 ? EVP_PKEY_ED25519 : EVP_PKEY_ED448))) +# define KEYTYPE2NID(type) \ + ((type) == ECX_KEY_TYPE_X25519 \ + ? EVP_PKEY_X25519 \ + : ((type) == ECX_KEY_TYPE_X448 \ + ? EVP_PKEY_X448 \ + : ((type) == ECX_KEY_TYPE_ED25519 ? EVP_PKEY_ED25519 \ + : EVP_PKEY_ED448))) struct ecx_key_st { - OSSL_LIB_CTX *libctx; - char *propq; - unsigned int haspubkey : 1; - unsigned char pubkey[MAX_KEYLEN]; - unsigned char *privkey; - size_t keylen; - ECX_KEY_TYPE type; - CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; + OSSL_LIB_CTX *libctx; + char *propq; + unsigned int haspubkey : 1; + unsigned char pubkey[MAX_KEYLEN]; + unsigned char *privkey; + size_t keylen; + ECX_KEY_TYPE type; + CRYPTO_REF_COUNT references; + CRYPTO_RWLOCK *lock; }; size_t ossl_ecx_key_length(ECX_KEY_TYPE type); -ECX_KEY *ossl_ecx_key_new(OSSL_LIB_CTX *libctx, ECX_KEY_TYPE type, int haspubkey, - const char *propq); +ECX_KEY *ossl_ecx_key_new(OSSL_LIB_CTX *libctx, ECX_KEY_TYPE type, + int haspubkey, const char *propq); void ossl_ecx_key_set0_libctx(ECX_KEY *key, OSSL_LIB_CTX *libctx); unsigned char *ossl_ecx_key_allocate_privkey(ECX_KEY *key); void ossl_ecx_key_free(ECX_KEY *key); int ossl_ecx_key_up_ref(ECX_KEY *key); ECX_KEY *ossl_ecx_key_dup(const ECX_KEY *key, int selection); -int ossl_ecx_compute_key(ECX_KEY *peer, ECX_KEY *priv, size_t keylen, unsigned char *secret, - size_t *secretlen, size_t outlen); +int ossl_ecx_compute_key(ECX_KEY *peer, ECX_KEY *priv, size_t keylen, + unsigned char *secret, size_t *secretlen, + size_t outlen); int ossl_x25519(uint8_t out_shared_key[32], const uint8_t private_key[32], const uint8_t peer_public_value[32]); -void ossl_x25519_public_from_private(uint8_t out_public_value[32], const uint8_t private_key[32]); +void ossl_x25519_public_from_private(uint8_t out_public_value[32], + const uint8_t private_key[32]); -int ossl_ed25519_public_from_private(OSSL_LIB_CTX *ctx, uint8_t out_public_key[32], - const uint8_t private_key[32], const char *propq); -int ossl_ed25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, - const uint8_t public_key[32], const uint8_t private_key[32], - OSSL_LIB_CTX *libctx, const char *propq); -int ossl_ed25519_verify(const uint8_t *message, size_t message_len, const uint8_t signature[64], - const uint8_t public_key[32], OSSL_LIB_CTX *libctx, const char *propq); +int ossl_ed25519_public_from_private(OSSL_LIB_CTX *ctx, + uint8_t out_public_key[32], + const uint8_t private_key[32], + const char *propq); +int ossl_ed25519_sign(uint8_t *out_sig, const uint8_t *message, + size_t message_len, const uint8_t public_key[32], + const uint8_t private_key[32], OSSL_LIB_CTX *libctx, + const char *propq); +int ossl_ed25519_verify(const uint8_t *message, size_t message_len, + const uint8_t signature[64], + const uint8_t public_key[32], OSSL_LIB_CTX *libctx, + const char *propq); -int ossl_ed448_public_from_private(OSSL_LIB_CTX *ctx, uint8_t out_public_key[57], - const uint8_t private_key[57], const char *propq); -int ossl_ed448_sign(OSSL_LIB_CTX *ctx, uint8_t *out_sig, const uint8_t *message, size_t message_len, - const uint8_t public_key[57], const uint8_t private_key[57], - const uint8_t *context, size_t context_len, const char *propq); +int ossl_ed448_public_from_private(OSSL_LIB_CTX *ctx, + uint8_t out_public_key[57], + const uint8_t private_key[57], + const char *propq); +int ossl_ed448_sign(OSSL_LIB_CTX *ctx, uint8_t *out_sig, const uint8_t *message, + size_t message_len, const uint8_t public_key[57], + const uint8_t private_key[57], const uint8_t *context, + size_t context_len, const char *propq); -int ossl_ed448_verify(OSSL_LIB_CTX *ctx, const uint8_t *message, size_t message_len, - const uint8_t signature[114], const uint8_t public_key[57], - const uint8_t *context, size_t context_len, const char *propq); +int ossl_ed448_verify(OSSL_LIB_CTX *ctx, const uint8_t *message, + size_t message_len, const uint8_t signature[114], + const uint8_t public_key[57], const uint8_t *context, + size_t context_len, const char *propq); int ossl_x448(uint8_t out_shared_key[56], const uint8_t private_key[56], const uint8_t peer_public_value[56]); -void ossl_x448_public_from_private(uint8_t out_public_value[56], const uint8_t private_key[56]); +void ossl_x448_public_from_private(uint8_t out_public_value[56], + const uint8_t private_key[56]); /* Backend support */ typedef enum { - KEY_OP_PUBLIC, - KEY_OP_PRIVATE, - KEY_OP_KEYGEN + KEY_OP_PUBLIC, + KEY_OP_PRIVATE, + KEY_OP_KEYGEN } ecx_key_op_t; -ECX_KEY *ossl_ecx_key_op(const X509_ALGOR *palg, const unsigned char *p, int plen, int pkey_id, - ecx_key_op_t op, OSSL_LIB_CTX *libctx, const char *propq); +ECX_KEY *ossl_ecx_key_op(const X509_ALGOR *palg, const unsigned char *p, + int plen, int pkey_id, ecx_key_op_t op, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_ecx_public_from_private(ECX_KEY *key); -int ossl_ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[], int include_private); -ECX_KEY *ossl_ecx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); +int ossl_ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[], + int include_private); +ECX_KEY *ossl_ecx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); ECX_KEY *ossl_evp_pkey_get1_X25519(EVP_PKEY *pkey); ECX_KEY *ossl_evp_pkey_get1_X448(EVP_PKEY *pkey); diff --git a/libs/OpenSSL/include/crypto/ess.h b/libs/OpenSSL/include/crypto/ess.h index ed9c4788..746a9929 100644 --- a/libs/OpenSSL/include/crypto/ess.h +++ b/libs/OpenSSL/include/crypto/ess.h @@ -20,8 +20,8 @@ struct ESS_issuer_serial { - STACK_OF(GENERAL_NAME) * issuer; - ASN1_INTEGER *serial; + STACK_OF(GENERAL_NAME) * issuer; + ASN1_INTEGER *serial; }; /*- @@ -33,8 +33,8 @@ struct ESS_issuer_serial struct ESS_cert_id { - ASN1_OCTET_STRING *hash; /* Always SHA-1 digest. */ - ESS_ISSUER_SERIAL *issuer_serial; + ASN1_OCTET_STRING *hash; /* Always SHA-1 digest. */ + ESS_ISSUER_SERIAL *issuer_serial; }; /*- @@ -46,8 +46,8 @@ struct ESS_cert_id struct ESS_signing_cert { - STACK_OF(ESS_CERT_ID) * cert_ids; - STACK_OF(POLICYINFO) * policy_info; + STACK_OF(ESS_CERT_ID) * cert_ids; + STACK_OF(POLICYINFO) * policy_info; }; /*- @@ -60,9 +60,9 @@ struct ESS_signing_cert struct ESS_cert_id_v2_st { - X509_ALGOR *hash_alg; /* Default: SHA-256 */ - ASN1_OCTET_STRING *hash; - ESS_ISSUER_SERIAL *issuer_serial; + X509_ALGOR *hash_alg; /* Default: SHA-256 */ + ASN1_OCTET_STRING *hash; + ESS_ISSUER_SERIAL *issuer_serial; }; /*- @@ -74,8 +74,8 @@ struct ESS_cert_id_v2_st struct ESS_signing_cert_v2_st { - STACK_OF(ESS_CERT_ID_V2) * cert_ids; - STACK_OF(POLICYINFO) * policy_info; + STACK_OF(ESS_CERT_ID_V2) * cert_ids; + STACK_OF(POLICYINFO) * policy_info; }; #endif /* OSSL_CRYPTO_ESS_H */ diff --git a/libs/OpenSSL/include/crypto/evp.h b/libs/OpenSSL/include/crypto/evp.h index 3d1af03b..b40acaeb 100644 --- a/libs/OpenSSL/include/crypto/evp.h +++ b/libs/OpenSSL/include/crypto/evp.h @@ -27,160 +27,162 @@ struct evp_pkey_ctx_st { - /* Actual operation */ - int operation; + /* Actual operation */ + int operation; - /* - * Library context, property query, keytype and keymgmt associated with - * this context - */ - OSSL_LIB_CTX *libctx; - char *propquery; - const char *keytype; - /* If |pkey| below is set, this field is always a reference to its keymgmt */ - EVP_KEYMGMT *keymgmt; + /* + * Library context, property query, keytype and keymgmt associated with + * this context + */ + OSSL_LIB_CTX *libctx; + char *propquery; + const char *keytype; + /* If |pkey| below is set, this field is always a reference to its keymgmt */ + EVP_KEYMGMT *keymgmt; - union - { - struct - { - void *genctx; - } keymgmt; - - struct - { - EVP_KEYEXCH *exchange; - /* - * Opaque ctx returned from a providers exchange algorithm - * implementation OSSL_FUNC_keyexch_newctx() - */ - void *algctx; - } kex; - - struct - { - EVP_SIGNATURE *signature; - /* - * Opaque ctx returned from a providers signature algorithm - * implementation OSSL_FUNC_signature_newctx() - */ - void *algctx; - } sig; - - struct - { - EVP_ASYM_CIPHER *cipher; - /* - * Opaque ctx returned from a providers asymmetric cipher algorithm - * implementation OSSL_FUNC_asym_cipher_newctx() - */ - void *algctx; - } ciph; - struct - { - EVP_KEM *kem; - /* - * Opaque ctx returned from a providers KEM algorithm - * implementation OSSL_FUNC_kem_newctx() - */ - void *algctx; - } encap; - } op; - - /* - * Cached parameters. Inits of operations that depend on these should - * call evp_pkey_ctx_use_delayed_data() when the operation has been set - * up properly. - */ + union + { struct { - /* Distinguishing Identifier, ISO/IEC 15946-3, FIPS 196 */ - char *dist_id_name; /* The name used with EVP_PKEY_CTX_ctrl_str() */ - void *dist_id; /* The distinguishing ID itself */ - size_t dist_id_len; /* The length of the distinguishing ID */ + void *genctx; + } keymgmt; - /* Indicators of what has been set. Keep them together! */ - unsigned int dist_id_set : 1; - } cached_parameters; + struct + { + EVP_KEYEXCH *exchange; + /* + * Opaque ctx returned from a providers exchange algorithm + * implementation OSSL_FUNC_keyexch_newctx() + */ + void *algctx; + } kex; - /* Application specific data, usually used by the callback */ - void *app_data; - /* Keygen callback */ - EVP_PKEY_gen_cb *pkey_gencb; - /* implementation specific keygen data */ - int *keygen_info; - int keygen_info_count; + struct + { + EVP_SIGNATURE *signature; + /* + * Opaque ctx returned from a providers signature algorithm + * implementation OSSL_FUNC_signature_newctx() + */ + void *algctx; + } sig; - /* Legacy fields below */ + struct + { + EVP_ASYM_CIPHER *cipher; + /* + * Opaque ctx returned from a providers asymmetric cipher algorithm + * implementation OSSL_FUNC_asym_cipher_newctx() + */ + void *algctx; + } ciph; + struct + { + EVP_KEM *kem; + /* + * Opaque ctx returned from a providers KEM algorithm + * implementation OSSL_FUNC_kem_newctx() + */ + void *algctx; + } encap; + } op; - /* EVP_PKEY identity */ - int legacy_keytype; - /* Method associated with this operation */ - const EVP_PKEY_METHOD *pmeth; - /* Engine that implements this method or NULL if builtin */ - ENGINE *engine; - /* Key: may be NULL */ - EVP_PKEY *pkey; - /* Peer key for key agreement, may be NULL */ - EVP_PKEY *peerkey; - /* Algorithm specific data */ - void *data; - /* Indicator if digest_custom needs to be called */ - unsigned int flag_call_digest_custom : 1; - /* - * Used to support taking custody of memory in the case of a provider being - * used with the deprecated EVP_PKEY_CTX_set_rsa_keygen_pubexp() API. This - * member should NOT be used for any other purpose and should be removed - * when said deprecated API is excised completely. - */ - BIGNUM *rsa_pubexp; + /* + * Cached parameters. Inits of operations that depend on these should + * call evp_pkey_ctx_use_delayed_data() when the operation has been set + * up properly. + */ + struct + { + /* Distinguishing Identifier, ISO/IEC 15946-3, FIPS 196 */ + char *dist_id_name; /* The name used with EVP_PKEY_CTX_ctrl_str() */ + void *dist_id; /* The distinguishing ID itself */ + size_t dist_id_len; /* The length of the distinguishing ID */ + + /* Indicators of what has been set. Keep them together! */ + unsigned int dist_id_set : 1; + } cached_parameters; + + /* Application specific data, usually used by the callback */ + void *app_data; + /* Keygen callback */ + EVP_PKEY_gen_cb *pkey_gencb; + /* implementation specific keygen data */ + int *keygen_info; + int keygen_info_count; + + /* Legacy fields below */ + + /* EVP_PKEY identity */ + int legacy_keytype; + /* Method associated with this operation */ + const EVP_PKEY_METHOD *pmeth; + /* Engine that implements this method or NULL if builtin */ + ENGINE *engine; + /* Key: may be NULL */ + EVP_PKEY *pkey; + /* Peer key for key agreement, may be NULL */ + EVP_PKEY *peerkey; + /* Algorithm specific data */ + void *data; + /* Indicator if digest_custom needs to be called */ + unsigned int flag_call_digest_custom : 1; + /* + * Used to support taking custody of memory in the case of a provider being + * used with the deprecated EVP_PKEY_CTX_set_rsa_keygen_pubexp() API. This + * member should NOT be used for any other purpose and should be removed + * when said deprecated API is excised completely. + */ + BIGNUM *rsa_pubexp; } /* EVP_PKEY_CTX */; #define EVP_PKEY_FLAG_DYNAMIC 1 struct evp_pkey_method_st { - int pkey_id; - int flags; - int (*init)(EVP_PKEY_CTX *ctx); - int (*copy)(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src); - void (*cleanup)(EVP_PKEY_CTX *ctx); - int (*paramgen_init)(EVP_PKEY_CTX *ctx); - int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); - int (*keygen_init)(EVP_PKEY_CTX *ctx); - int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); - int (*sign_init)(EVP_PKEY_CTX *ctx); - int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, - size_t tbslen); - int (*verify_init)(EVP_PKEY_CTX *ctx); - int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen); - int (*verify_recover_init)(EVP_PKEY_CTX *ctx); - int (*verify_recover)(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, - const unsigned char *sig, size_t siglen); - int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); - int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx); - int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); - int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, EVP_MD_CTX *mctx); - int (*encrypt_init)(EVP_PKEY_CTX *ctx); - int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, - size_t inlen); - int (*decrypt_init)(EVP_PKEY_CTX *ctx); - int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, - size_t inlen); - int (*derive_init)(EVP_PKEY_CTX *ctx); - int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); - int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2); - int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value); - int (*digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, - size_t tbslen); - int (*digestverify)(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen); - int (*check)(EVP_PKEY *pkey); - int (*public_check)(EVP_PKEY *pkey); - int (*param_check)(EVP_PKEY *pkey); + int pkey_id; + int flags; + int (*init)(EVP_PKEY_CTX *ctx); + int (*copy)(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src); + void (*cleanup)(EVP_PKEY_CTX *ctx); + int (*paramgen_init)(EVP_PKEY_CTX *ctx); + int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); + int (*keygen_init)(EVP_PKEY_CTX *ctx); + int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); + int (*sign_init)(EVP_PKEY_CTX *ctx); + int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); + int (*verify_init)(EVP_PKEY_CTX *ctx); + int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen); + int (*verify_recover_init)(EVP_PKEY_CTX *ctx); + int (*verify_recover)(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, + const unsigned char *sig, size_t siglen); + int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx); + int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, + EVP_MD_CTX *mctx); + int (*encrypt_init)(EVP_PKEY_CTX *ctx); + int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + int (*decrypt_init)(EVP_PKEY_CTX *ctx); + int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + int (*derive_init)(EVP_PKEY_CTX *ctx); + int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); + int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2); + int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value); + int (*digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); + int (*digestverify)(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen); + int (*check)(EVP_PKEY *pkey); + int (*public_check)(EVP_PKEY *pkey); + int (*param_check)(EVP_PKEY *pkey); - int (*digest_custom)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*digest_custom)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); } /* EVP_PKEY_METHOD */; DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD) @@ -200,48 +202,48 @@ const EVP_PKEY_METHOD *ossl_rsa_pss_pkey_method(void); struct evp_mac_st { - OSSL_PROVIDER *prov; - int name_id; - char *type_name; - const char *description; + OSSL_PROVIDER *prov; + int name_id; + char *type_name; + const char *description; - CRYPTO_REF_COUNT refcnt; - CRYPTO_RWLOCK *lock; + CRYPTO_REF_COUNT refcnt; + CRYPTO_RWLOCK *lock; - OSSL_FUNC_mac_newctx_fn *newctx; - OSSL_FUNC_mac_dupctx_fn *dupctx; - OSSL_FUNC_mac_freectx_fn *freectx; - OSSL_FUNC_mac_init_fn *init; - OSSL_FUNC_mac_update_fn *update; - OSSL_FUNC_mac_final_fn *final; - OSSL_FUNC_mac_gettable_params_fn *gettable_params; - OSSL_FUNC_mac_gettable_ctx_params_fn *gettable_ctx_params; - OSSL_FUNC_mac_settable_ctx_params_fn *settable_ctx_params; - OSSL_FUNC_mac_get_params_fn *get_params; - OSSL_FUNC_mac_get_ctx_params_fn *get_ctx_params; - OSSL_FUNC_mac_set_ctx_params_fn *set_ctx_params; + OSSL_FUNC_mac_newctx_fn *newctx; + OSSL_FUNC_mac_dupctx_fn *dupctx; + OSSL_FUNC_mac_freectx_fn *freectx; + OSSL_FUNC_mac_init_fn *init; + OSSL_FUNC_mac_update_fn *update; + OSSL_FUNC_mac_final_fn *final; + OSSL_FUNC_mac_gettable_params_fn *gettable_params; + OSSL_FUNC_mac_gettable_ctx_params_fn *gettable_ctx_params; + OSSL_FUNC_mac_settable_ctx_params_fn *settable_ctx_params; + OSSL_FUNC_mac_get_params_fn *get_params; + OSSL_FUNC_mac_get_ctx_params_fn *get_ctx_params; + OSSL_FUNC_mac_set_ctx_params_fn *set_ctx_params; }; struct evp_kdf_st { - OSSL_PROVIDER *prov; - int name_id; - char *type_name; - const char *description; - CRYPTO_REF_COUNT refcnt; - CRYPTO_RWLOCK *lock; + OSSL_PROVIDER *prov; + int name_id; + char *type_name; + const char *description; + CRYPTO_REF_COUNT refcnt; + CRYPTO_RWLOCK *lock; - OSSL_FUNC_kdf_newctx_fn *newctx; - OSSL_FUNC_kdf_dupctx_fn *dupctx; - OSSL_FUNC_kdf_freectx_fn *freectx; - OSSL_FUNC_kdf_reset_fn *reset; - OSSL_FUNC_kdf_derive_fn *derive; - OSSL_FUNC_kdf_gettable_params_fn *gettable_params; - OSSL_FUNC_kdf_gettable_ctx_params_fn *gettable_ctx_params; - OSSL_FUNC_kdf_settable_ctx_params_fn *settable_ctx_params; - OSSL_FUNC_kdf_get_params_fn *get_params; - OSSL_FUNC_kdf_get_ctx_params_fn *get_ctx_params; - OSSL_FUNC_kdf_set_ctx_params_fn *set_ctx_params; + OSSL_FUNC_kdf_newctx_fn *newctx; + OSSL_FUNC_kdf_dupctx_fn *dupctx; + OSSL_FUNC_kdf_freectx_fn *freectx; + OSSL_FUNC_kdf_reset_fn *reset; + OSSL_FUNC_kdf_derive_fn *derive; + OSSL_FUNC_kdf_gettable_params_fn *gettable_params; + OSSL_FUNC_kdf_gettable_ctx_params_fn *gettable_ctx_params; + OSSL_FUNC_kdf_settable_ctx_params_fn *settable_ctx_params; + OSSL_FUNC_kdf_get_params_fn *get_params; + OSSL_FUNC_kdf_get_ctx_params_fn *get_ctx_params; + OSSL_FUNC_kdf_set_ctx_params_fn *set_ctx_params; }; #define EVP_ORIG_DYNAMIC 0 @@ -250,257 +252,277 @@ struct evp_kdf_st struct evp_md_st { - /* nid */ - int type; + /* nid */ + int type; - /* Legacy structure members */ - int pkey_type; - int md_size; - unsigned long flags; - int origin; - int (*init)(EVP_MD_CTX *ctx); - int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count); - int (*final)(EVP_MD_CTX *ctx, unsigned char *md); - int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from); - int (*cleanup)(EVP_MD_CTX *ctx); - int block_size; - int ctx_size; /* how big does the ctx->md_data need to be */ - /* control function */ - int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); + /* Legacy structure members */ + int pkey_type; + int md_size; + unsigned long flags; + int origin; + int (*init)(EVP_MD_CTX *ctx); + int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count); + int (*final)(EVP_MD_CTX *ctx, unsigned char *md); + int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from); + int (*cleanup)(EVP_MD_CTX *ctx); + int block_size; + int ctx_size; /* how big does the ctx->md_data need to be */ + /* control function */ + int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); - /* New structure members */ - /* Above comment to be removed when legacy has gone */ - int name_id; - char *type_name; - const char *description; - OSSL_PROVIDER *prov; - CRYPTO_REF_COUNT refcnt; - CRYPTO_RWLOCK *lock; - OSSL_FUNC_digest_newctx_fn *newctx; - OSSL_FUNC_digest_init_fn *dinit; - OSSL_FUNC_digest_update_fn *dupdate; - OSSL_FUNC_digest_final_fn *dfinal; - OSSL_FUNC_digest_digest_fn *digest; - OSSL_FUNC_digest_freectx_fn *freectx; - OSSL_FUNC_digest_dupctx_fn *dupctx; - OSSL_FUNC_digest_get_params_fn *get_params; - OSSL_FUNC_digest_set_ctx_params_fn *set_ctx_params; - OSSL_FUNC_digest_get_ctx_params_fn *get_ctx_params; - OSSL_FUNC_digest_gettable_params_fn *gettable_params; - OSSL_FUNC_digest_settable_ctx_params_fn *settable_ctx_params; - OSSL_FUNC_digest_gettable_ctx_params_fn *gettable_ctx_params; + /* New structure members */ + /* Above comment to be removed when legacy has gone */ + int name_id; + char *type_name; + const char *description; + OSSL_PROVIDER *prov; + CRYPTO_REF_COUNT refcnt; + CRYPTO_RWLOCK *lock; + OSSL_FUNC_digest_newctx_fn *newctx; + OSSL_FUNC_digest_init_fn *dinit; + OSSL_FUNC_digest_update_fn *dupdate; + OSSL_FUNC_digest_final_fn *dfinal; + OSSL_FUNC_digest_digest_fn *digest; + OSSL_FUNC_digest_freectx_fn *freectx; + OSSL_FUNC_digest_dupctx_fn *dupctx; + OSSL_FUNC_digest_get_params_fn *get_params; + OSSL_FUNC_digest_set_ctx_params_fn *set_ctx_params; + OSSL_FUNC_digest_get_ctx_params_fn *get_ctx_params; + OSSL_FUNC_digest_gettable_params_fn *gettable_params; + OSSL_FUNC_digest_settable_ctx_params_fn *settable_ctx_params; + OSSL_FUNC_digest_gettable_ctx_params_fn *gettable_ctx_params; } /* EVP_MD */; struct evp_cipher_st { - int nid; + int nid; - int block_size; - /* Default value for variable length ciphers */ - int key_len; - int iv_len; + int block_size; + /* Default value for variable length ciphers */ + int key_len; + int iv_len; - /* Legacy structure members */ - /* Various flags */ - unsigned long flags; - /* How the EVP_CIPHER was created. */ - int origin; - /* init key */ - int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); - /* encrypt/decrypt data */ - int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl); - /* cleanup ctx */ - int (*cleanup)(EVP_CIPHER_CTX *); - /* how big ctx->cipher_data needs to be */ - int ctx_size; - /* Populate a ASN1_TYPE with parameters */ - int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); - /* Get parameters from a ASN1_TYPE */ - int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); - /* Miscellaneous operations */ - int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); - /* Application data */ - void *app_data; + /* Legacy structure members */ + /* Various flags */ + unsigned long flags; + /* How the EVP_CIPHER was created. */ + int origin; + /* init key */ + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc); + /* encrypt/decrypt data */ + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, size_t inl); + /* cleanup ctx */ + int (*cleanup)(EVP_CIPHER_CTX *); + /* how big ctx->cipher_data needs to be */ + int ctx_size; + /* Populate a ASN1_TYPE with parameters */ + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); + /* Get parameters from a ASN1_TYPE */ + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); + /* Miscellaneous operations */ + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); + /* Application data */ + void *app_data; - /* New structure members */ - /* Above comment to be removed when legacy has gone */ - int name_id; - char *type_name; - const char *description; - OSSL_PROVIDER *prov; - CRYPTO_REF_COUNT refcnt; - CRYPTO_RWLOCK *lock; - OSSL_FUNC_cipher_newctx_fn *newctx; - OSSL_FUNC_cipher_encrypt_init_fn *einit; - OSSL_FUNC_cipher_decrypt_init_fn *dinit; - OSSL_FUNC_cipher_update_fn *cupdate; - OSSL_FUNC_cipher_final_fn *cfinal; - OSSL_FUNC_cipher_cipher_fn *ccipher; - OSSL_FUNC_cipher_freectx_fn *freectx; - OSSL_FUNC_cipher_dupctx_fn *dupctx; - OSSL_FUNC_cipher_get_params_fn *get_params; - OSSL_FUNC_cipher_get_ctx_params_fn *get_ctx_params; - OSSL_FUNC_cipher_set_ctx_params_fn *set_ctx_params; - OSSL_FUNC_cipher_gettable_params_fn *gettable_params; - OSSL_FUNC_cipher_gettable_ctx_params_fn *gettable_ctx_params; - OSSL_FUNC_cipher_settable_ctx_params_fn *settable_ctx_params; + /* New structure members */ + /* Above comment to be removed when legacy has gone */ + int name_id; + char *type_name; + const char *description; + OSSL_PROVIDER *prov; + CRYPTO_REF_COUNT refcnt; + CRYPTO_RWLOCK *lock; + OSSL_FUNC_cipher_newctx_fn *newctx; + OSSL_FUNC_cipher_encrypt_init_fn *einit; + OSSL_FUNC_cipher_decrypt_init_fn *dinit; + OSSL_FUNC_cipher_update_fn *cupdate; + OSSL_FUNC_cipher_final_fn *cfinal; + OSSL_FUNC_cipher_cipher_fn *ccipher; + OSSL_FUNC_cipher_freectx_fn *freectx; + OSSL_FUNC_cipher_dupctx_fn *dupctx; + OSSL_FUNC_cipher_get_params_fn *get_params; + OSSL_FUNC_cipher_get_ctx_params_fn *get_ctx_params; + OSSL_FUNC_cipher_set_ctx_params_fn *set_ctx_params; + OSSL_FUNC_cipher_gettable_params_fn *gettable_params; + OSSL_FUNC_cipher_gettable_ctx_params_fn *gettable_ctx_params; + OSSL_FUNC_cipher_settable_ctx_params_fn *settable_ctx_params; } /* EVP_CIPHER */; /* Macros to code block cipher wrappers */ /* Wrapper functions for each cipher mode */ -#define EVP_C_DATA(kstruct, ctx) ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx)) +#define EVP_C_DATA(kstruct, ctx) \ + ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx)) -#define BLOCK_CIPHER_ecb_loop() \ - size_t i, bl; \ - bl = EVP_CIPHER_CTX_get0_cipher(ctx)->block_size; \ - if (inl < bl) \ - return 1; \ - inl -= bl; \ - for (i = 0; i <= inl; i += bl) +#define BLOCK_CIPHER_ecb_loop() \ + size_t i, bl; \ + bl = EVP_CIPHER_CTX_get0_cipher(ctx)->block_size; \ + if (inl < bl) \ + return 1; \ + inl -= bl; \ + for (i = 0; i <= inl; i += bl) -#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ - static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ - const unsigned char *in, size_t inl) \ - { \ - BLOCK_CIPHER_ecb_loop() \ - cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct, ctx)->ksched, \ - EVP_CIPHER_CTX_is_encrypting(ctx)); \ - return 1; \ - } +#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ + static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ + const unsigned char *in, size_t inl) \ + { \ + BLOCK_CIPHER_ecb_loop() cprefix##_ecb_encrypt( \ + in + i, out + i, &EVP_C_DATA(kstruct, ctx)->ksched, \ + EVP_CIPHER_CTX_is_encrypting(ctx)); \ + return 1; \ + } #define EVP_MAXCHUNK ((size_t)1 << 30) -#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ - static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ - const unsigned char *in, size_t inl) \ - { \ - while (inl >= EVP_MAXCHUNK) \ - { \ - int num = EVP_CIPHER_CTX_get_num(ctx); \ - cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, \ - &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv, &num); \ - EVP_CIPHER_CTX_set_num(ctx, num); \ - inl -= EVP_MAXCHUNK; \ - in += EVP_MAXCHUNK; \ - out += EVP_MAXCHUNK; \ - } \ - if (inl) \ - { \ - int num = EVP_CIPHER_CTX_get_num(ctx); \ - cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct, ctx)->ksched, \ - ctx->iv, &num); \ - EVP_CIPHER_CTX_set_num(ctx, num); \ - } \ - return 1; \ - } +#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ + static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ + const unsigned char *in, size_t inl) \ + { \ + while (inl >= EVP_MAXCHUNK) \ + { \ + int num = EVP_CIPHER_CTX_get_num(ctx); \ + cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, \ + &EVP_C_DATA(kstruct, ctx)->ksched, \ + ctx->iv, &num); \ + EVP_CIPHER_CTX_set_num(ctx, num); \ + inl -= EVP_MAXCHUNK; \ + in += EVP_MAXCHUNK; \ + out += EVP_MAXCHUNK; \ + } \ + if (inl) \ + { \ + int num = EVP_CIPHER_CTX_get_num(ctx); \ + cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, \ + &EVP_C_DATA(kstruct, ctx)->ksched, \ + ctx->iv, &num); \ + EVP_CIPHER_CTX_set_num(ctx, num); \ + } \ + return 1; \ + } -#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ - static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ - const unsigned char *in, size_t inl) \ - { \ - while (inl >= EVP_MAXCHUNK) \ - { \ - cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct, ctx)->ksched, \ - ctx->iv, EVP_CIPHER_CTX_is_encrypting(ctx)); \ - inl -= EVP_MAXCHUNK; \ - in += EVP_MAXCHUNK; \ - out += EVP_MAXCHUNK; \ - } \ - if (inl) \ - cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv, \ - EVP_CIPHER_CTX_is_encrypting(ctx)); \ - return 1; \ - } +#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ + static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ + const unsigned char *in, size_t inl) \ + { \ + while (inl >= EVP_MAXCHUNK) \ + { \ + cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, \ + &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv, \ + EVP_CIPHER_CTX_is_encrypting(ctx)); \ + inl -= EVP_MAXCHUNK; \ + in += EVP_MAXCHUNK; \ + out += EVP_MAXCHUNK; \ + } \ + if (inl) \ + cprefix##_cbc_encrypt(in, out, (long)inl, \ + &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv, \ + EVP_CIPHER_CTX_is_encrypting(ctx)); \ + return 1; \ + } -#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ - static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, \ - const unsigned char *in, size_t inl) \ - { \ - size_t chunk = EVP_MAXCHUNK; \ - if (cbits == 1) \ - chunk >>= 3; \ - if (inl < chunk) \ - chunk = inl; \ - while (inl && inl >= chunk) \ - { \ - int num = EVP_CIPHER_CTX_get_num(ctx); \ - cprefix##_cfb##cbits##_encrypt( \ - in, out, \ - (long)((cbits == 1) && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \ - ? chunk * 8 \ - : chunk), \ - &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv, &num, \ - EVP_CIPHER_CTX_is_encrypting(ctx)); \ - EVP_CIPHER_CTX_set_num(ctx, num); \ - inl -= chunk; \ - in += chunk; \ - out += chunk; \ - if (inl < chunk) \ - chunk = inl; \ - } \ - return 1; \ - } +#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ + static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, \ + unsigned char *out, \ + const unsigned char *in, size_t inl) \ + { \ + size_t chunk = EVP_MAXCHUNK; \ + if (cbits == 1) \ + chunk >>= 3; \ + if (inl < chunk) \ + chunk = inl; \ + while (inl && inl >= chunk) \ + { \ + int num = EVP_CIPHER_CTX_get_num(ctx); \ + cprefix##_cfb##cbits##_encrypt( \ + in, out, \ + (long)((cbits == 1) \ + && !EVP_CIPHER_CTX_test_flags( \ + ctx, EVP_CIPH_FLAG_LENGTH_BITS) \ + ? chunk * 8 \ + : chunk), \ + &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv, &num, \ + EVP_CIPHER_CTX_is_encrypting(ctx)); \ + EVP_CIPHER_CTX_set_num(ctx, num); \ + inl -= chunk; \ + in += chunk; \ + out += chunk; \ + if (inl < chunk) \ + chunk = inl; \ + } \ + return 1; \ + } -#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ - BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ - BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) +#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) -#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, key_len, iv_len, \ - flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ - static const EVP_CIPHER cname##_##mode = { nid##_##nmode, \ - block_size, \ - key_len, \ - iv_len, \ - flags | EVP_CIPH_##MODE##_MODE, \ - EVP_ORIG_GLOBAL, \ - init_key, \ - cname##_##mode##_cipher, \ - cleanup, \ - sizeof(kstruct), \ - set_asn1, \ - get_asn1, \ - ctrl, \ - NULL }; \ - const EVP_CIPHER *EVP_##cname##_##mode(void) \ - { \ - return &cname##_##mode; \ - } +#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ + key_len, iv_len, flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) \ + static const EVP_CIPHER cname##_##mode = {nid##_##nmode, \ + block_size, \ + key_len, \ + iv_len, \ + flags | EVP_CIPH_##MODE##_MODE, \ + EVP_ORIG_GLOBAL, \ + init_key, \ + cname##_##mode##_cipher, \ + cleanup, \ + sizeof(kstruct), \ + set_asn1, \ + get_asn1, \ + ctrl, \ + NULL}; \ + const EVP_CIPHER *EVP_##cname##_##mode(void) \ + { \ + return &cname##_##mode; \ + } -#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, iv_len, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) +#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, \ + flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) \ + BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ + iv_len, flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) -#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, key_len, iv_len, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) +#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \ + flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) \ + BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ + key_len, iv_len, flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) -#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, key_len, iv_len, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) +#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ + flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) \ + BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, key_len, \ + iv_len, flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) -#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, init_key, cleanup, \ - set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, 0, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) +#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \ + init_key, cleanup, set_asn1, get_asn1, ctrl) \ + BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ + 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) -#define BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, cbits, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) +#define BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ + cbits, flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) \ + BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, \ + flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ + BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, flags, \ + init_key, cleanup, set_asn1, get_asn1, ctrl) \ + BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ + flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) \ + BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ + flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) /*- #define BLOCK_CIPHER_defs(cname, kstruct, \ @@ -564,23 +586,27 @@ static const EVP_CIPHER cname##_ecb = {\ const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } */ -#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, block_size, key_len, iv_len, \ - cbits, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, cbits, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) +#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ + block_size, key_len, iv_len, cbits, flags, \ + init_key, cleanup, set_asn1, get_asn1, ctrl) \ + BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ + cbits, flags, init_key, cleanup, set_asn1, get_asn1, \ + ctrl) -#define IMPLEMENT_CFBR(cipher, cprefix, kstruct, ksched, keysize, cbits, iv_len, fl) \ - BLOCK_CIPHER_func_cfb(cipher##_##keysize, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_def_cfb(cipher##_##keysize, kstruct, NID_##cipher##_##keysize, keysize / 8, \ - iv_len, cbits, (fl) | EVP_CIPH_FLAG_DEFAULT_ASN1, cipher##_init_key, \ - NULL, NULL, NULL, NULL) +#define IMPLEMENT_CFBR(cipher, cprefix, kstruct, ksched, keysize, cbits, \ + iv_len, fl) \ + BLOCK_CIPHER_func_cfb(cipher##_##keysize, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_def_cfb(cipher##_##keysize, kstruct, \ + NID_##cipher##_##keysize, keysize / 8, iv_len, \ + cbits, (fl) | EVP_CIPH_FLAG_DEFAULT_ASN1, \ + cipher##_init_key, NULL, NULL, NULL, NULL) typedef struct { - unsigned char iv[EVP_MAX_IV_LENGTH]; - unsigned int iv_len; - unsigned int tag_len; + unsigned char iv[EVP_MAX_IV_LENGTH]; + unsigned int iv_len; + unsigned int tag_len; } evp_cipher_aead_asn1_params; int evp_cipher_param_to_asn1_ex(EVP_CIPHER_CTX *c, ASN1_TYPE *type, @@ -601,9 +627,9 @@ int evp_cipher_asn1_to_param_ex(EVP_CIPHER_CTX *c, ASN1_TYPE *type, */ typedef struct { - EVP_KEYMGMT *keymgmt; - void *keydata; - int selection; + EVP_KEYMGMT *keymgmt; + void *keydata; + int selection; } OP_CACHE_ELEM; DEFINE_STACK_OF(OP_CACHE_ELEM) @@ -617,12 +643,14 @@ DEFINE_STACK_OF(OP_CACHE_ELEM) * * typed & empty: * - * (type != EVP_PKEY_NONE && pkey.ptr == NULL) ## legacy (libcrypto only) + * (type != EVP_PKEY_NONE && pkey.ptr == NULL) ## legacy (libcrypto + * only) * || (keymgmt != NULL && keydata == NULL) ## provider side * * fully assigned: * - * (type != EVP_PKEY_NONE && pkey.ptr != NULL) ## legacy (libcrypto only) + * (type != EVP_PKEY_NONE && pkey.ptr != NULL) ## legacy (libcrypto + * only) * || (keymgmt != NULL && keydata != NULL) ## provider side * * The easiest way to detect a legacy key is: @@ -633,133 +661,144 @@ DEFINE_STACK_OF(OP_CACHE_ELEM) * * keymgmt != NULL */ -#define evp_pkey_is_blank(pk) ((pk)->type == EVP_PKEY_NONE && (pk)->keymgmt == NULL) -#define evp_pkey_is_typed(pk) ((pk)->type != EVP_PKEY_NONE || (pk)->keymgmt != NULL) +#define evp_pkey_is_blank(pk) \ + ((pk)->type == EVP_PKEY_NONE && (pk)->keymgmt == NULL) +#define evp_pkey_is_typed(pk) \ + ((pk)->type != EVP_PKEY_NONE || (pk)->keymgmt != NULL) #ifndef FIPS_MODULE -# define evp_pkey_is_assigned(pk) ((pk)->pkey.ptr != NULL || (pk)->keydata != NULL) +# define evp_pkey_is_assigned(pk) \ + ((pk)->pkey.ptr != NULL || (pk)->keydata != NULL) #else -# define evp_pkey_is_assigned(pk) ((pk)->keydata != NULL) +# define evp_pkey_is_assigned(pk) ((pk)->keydata != NULL) #endif -#define evp_pkey_is_legacy(pk) ((pk)->type != EVP_PKEY_NONE && (pk)->keymgmt == NULL) +#define evp_pkey_is_legacy(pk) \ + ((pk)->type != EVP_PKEY_NONE && (pk)->keymgmt == NULL) #define evp_pkey_is_provided(pk) ((pk)->keymgmt != NULL) union legacy_pkey_st { - void *ptr; - struct rsa_st *rsa; /* RSA */ + void *ptr; + struct rsa_st *rsa; /* RSA */ #ifndef OPENSSL_NO_DSA - struct dsa_st *dsa; /* DSA */ + struct dsa_st *dsa; /* DSA */ #endif #ifndef OPENSSL_NO_DH - struct dh_st *dh; /* DH */ + struct dh_st *dh; /* DH */ #endif #ifndef OPENSSL_NO_EC - struct ec_key_st *ec; /* ECC */ - ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */ + struct ec_key_st *ec; /* ECC */ + ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */ #endif }; struct evp_pkey_st { - /* == Legacy attributes == */ - int type; - int save_type; + /* == Legacy attributes == */ + int type; + int save_type; #ifndef FIPS_MODULE - /* - * Legacy key "origin" is composed of a pointer to an EVP_PKEY_ASN1_METHOD, - * a pointer to a low level key and possibly a pointer to an engine. - */ - const EVP_PKEY_ASN1_METHOD *ameth; - ENGINE *engine; - ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */ + /* + * Legacy key "origin" is composed of a pointer to an EVP_PKEY_ASN1_METHOD, + * a pointer to a low level key and possibly a pointer to an engine. + */ + const EVP_PKEY_ASN1_METHOD *ameth; + ENGINE *engine; + ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */ - /* Union to store the reference to an origin legacy key */ - union legacy_pkey_st pkey; + /* Union to store the reference to an origin legacy key */ + union legacy_pkey_st pkey; - /* Union to store the reference to a non-origin legacy key */ - union legacy_pkey_st legacy_cache_pkey; + /* Union to store the reference to a non-origin legacy key */ + union legacy_pkey_st legacy_cache_pkey; #endif - /* == Common attributes == */ - CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; + /* == Common attributes == */ + CRYPTO_REF_COUNT references; + CRYPTO_RWLOCK *lock; #ifndef FIPS_MODULE - STACK_OF(X509_ATTRIBUTE) * attributes; /* [ 0 ] */ - int save_parameters; - unsigned int foreign : 1; /* the low-level key is using an engine or an app-method */ - CRYPTO_EX_DATA ex_data; + STACK_OF(X509_ATTRIBUTE) * attributes; /* [ 0 ] */ + int save_parameters; + unsigned int + foreign : 1; /* the low-level key is using an engine or an app-method */ + CRYPTO_EX_DATA ex_data; #endif - /* == Provider attributes == */ + /* == Provider attributes == */ - /* - * Provider keydata "origin" is composed of a pointer to an EVP_KEYMGMT - * and a pointer to the provider side key data. This is never used at - * the same time as the legacy key data above. - */ - EVP_KEYMGMT *keymgmt; - void *keydata; - /* - * If any libcrypto code does anything that may modify the keydata - * contents, this dirty counter must be incremented. - */ - size_t dirty_cnt; + /* + * Provider keydata "origin" is composed of a pointer to an EVP_KEYMGMT + * and a pointer to the provider side key data. This is never used at + * the same time as the legacy key data above. + */ + EVP_KEYMGMT *keymgmt; + void *keydata; + /* + * If any libcrypto code does anything that may modify the keydata + * contents, this dirty counter must be incremented. + */ + size_t dirty_cnt; - /* - * To support transparent execution of operation in backends other - * than the "origin" key, we support transparent export/import to - * those providers, and maintain a cache of the imported keydata, - * so we don't need to redo the export/import every time we perform - * the same operation in that same provider. - */ - STACK_OF(OP_CACHE_ELEM) * operation_cache; + /* + * To support transparent execution of operation in backends other + * than the "origin" key, we support transparent export/import to + * those providers, and maintain a cache of the imported keydata, + * so we don't need to redo the export/import every time we perform + * the same operation in that same provider. + */ + STACK_OF(OP_CACHE_ELEM) * operation_cache; - /* - * We keep a copy of that "origin"'s dirty count, so we know if the - * operation cache needs flushing. - */ - size_t dirty_cnt_copy; + /* + * We keep a copy of that "origin"'s dirty count, so we know if the + * operation cache needs flushing. + */ + size_t dirty_cnt_copy; - /* Cache of key object information */ - struct - { - int bits; - int security_bits; - int size; - } cache; + /* Cache of key object information */ + struct + { + int bits; + int security_bits; + int size; + } cache; } /* EVP_PKEY */; -#define EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx) \ - ((ctx)->operation == EVP_PKEY_OP_SIGN || (ctx)->operation == EVP_PKEY_OP_SIGNCTX \ - || (ctx)->operation == EVP_PKEY_OP_VERIFY || (ctx)->operation == EVP_PKEY_OP_VERIFYCTX \ - || (ctx)->operation == EVP_PKEY_OP_VERIFYRECOVER) +#define EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_SIGN \ + || (ctx)->operation == EVP_PKEY_OP_SIGNCTX \ + || (ctx)->operation == EVP_PKEY_OP_VERIFY \ + || (ctx)->operation == EVP_PKEY_OP_VERIFYCTX \ + || (ctx)->operation == EVP_PKEY_OP_VERIFYRECOVER) #define EVP_PKEY_CTX_IS_DERIVE_OP(ctx) ((ctx)->operation == EVP_PKEY_OP_DERIVE) -#define EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx) \ - ((ctx)->operation == EVP_PKEY_OP_ENCRYPT || (ctx)->operation == EVP_PKEY_OP_DECRYPT) +#define EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_ENCRYPT \ + || (ctx)->operation == EVP_PKEY_OP_DECRYPT) -#define EVP_PKEY_CTX_IS_GEN_OP(ctx) \ - ((ctx)->operation == EVP_PKEY_OP_PARAMGEN || (ctx)->operation == EVP_PKEY_OP_KEYGEN) +#define EVP_PKEY_CTX_IS_GEN_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_PARAMGEN \ + || (ctx)->operation == EVP_PKEY_OP_KEYGEN) -#define EVP_PKEY_CTX_IS_FROMDATA_OP(ctx) ((ctx)->operation == EVP_PKEY_OP_FROMDATA) +#define EVP_PKEY_CTX_IS_FROMDATA_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_FROMDATA) -#define EVP_PKEY_CTX_IS_KEM_OP(ctx) \ - ((ctx)->operation == EVP_PKEY_OP_ENCAPSULATE || (ctx)->operation == EVP_PKEY_OP_DECAPSULATE) +#define EVP_PKEY_CTX_IS_KEM_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_ENCAPSULATE \ + || (ctx)->operation == EVP_PKEY_OP_DECAPSULATE) void openssl_add_all_ciphers_int(void); void openssl_add_all_digests_int(void); void evp_cleanup_int(void); void evp_app_cleanup_int(void); -void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx, EVP_KEYMGMT **keymgmt, - const char *propquery); +void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx, + EVP_KEYMGMT **keymgmt, const char *propquery); #ifndef FIPS_MODULE int evp_pkey_copy_downgraded(EVP_PKEY **dest, const EVP_PKEY *src); void *evp_pkey_get_legacy(EVP_PKEY *pk); void evp_pkey_free_legacy(EVP_PKEY *x); -EVP_PKEY *evp_pkcs82pkey_legacy(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); +EVP_PKEY *evp_pkcs82pkey_legacy(const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); #endif /* @@ -771,63 +810,78 @@ EVP_PKEY *evp_pkcs82pkey_legacy(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX * */ struct evp_keymgmt_util_try_import_data_st { - EVP_KEYMGMT *keymgmt; - void *keydata; + EVP_KEYMGMT *keymgmt; + void *keydata; - int selection; + int selection; }; int evp_keymgmt_util_try_import(const OSSL_PARAM params[], void *arg); -int evp_keymgmt_util_assign_pkey(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt, void *keydata); +int evp_keymgmt_util_assign_pkey(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt, + void *keydata); EVP_PKEY *evp_keymgmt_util_make_pkey(EVP_KEYMGMT *keymgmt, void *keydata); -int evp_keymgmt_util_export(const EVP_PKEY *pk, int selection, OSSL_CALLBACK *export_cb, - void *export_cbarg); -void *evp_keymgmt_util_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, int selection); -OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, +int evp_keymgmt_util_export(const EVP_PKEY *pk, int selection, + OSSL_CALLBACK *export_cb, void *export_cbarg); +void *evp_keymgmt_util_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, + int selection); +OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk, + EVP_KEYMGMT *keymgmt, int selection); int evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk, int locking); -int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, void *keydata, - int selection); +int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt, + void *keydata, int selection); void evp_keymgmt_util_cache_keyinfo(EVP_PKEY *pk); -void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt, int selection, - const OSSL_PARAM params[]); +void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt, + int selection, const OSSL_PARAM params[]); int evp_keymgmt_util_has(EVP_PKEY *pk, int selection); int evp_keymgmt_util_match(EVP_PKEY *pk1, EVP_PKEY *pk2, int selection); int evp_keymgmt_util_copy(EVP_PKEY *to, EVP_PKEY *from, int selection); -void *evp_keymgmt_util_gen(EVP_PKEY *target, EVP_KEYMGMT *keymgmt, void *genctx, OSSL_CALLBACK *cb, - void *cbarg); -int evp_keymgmt_util_get_deflt_digest_name(EVP_KEYMGMT *keymgmt, void *keydata, char *mdname, - size_t mdname_sz); -const char *evp_keymgmt_util_query_operation_name(EVP_KEYMGMT *keymgmt, int op_id); +void *evp_keymgmt_util_gen(EVP_PKEY *target, EVP_KEYMGMT *keymgmt, void *genctx, + OSSL_CALLBACK *cb, void *cbarg); +int evp_keymgmt_util_get_deflt_digest_name(EVP_KEYMGMT *keymgmt, void *keydata, + char *mdname, size_t mdname_sz); +const char *evp_keymgmt_util_query_operation_name(EVP_KEYMGMT *keymgmt, + int op_id); /* * KEYMGMT provider interface functions */ void *evp_keymgmt_newdata(const EVP_KEYMGMT *keymgmt); void evp_keymgmt_freedata(const EVP_KEYMGMT *keymgmt, void *keyddata); -int evp_keymgmt_get_params(const EVP_KEYMGMT *keymgmt, void *keydata, OSSL_PARAM params[]); -int evp_keymgmt_set_params(const EVP_KEYMGMT *keymgmt, void *keydata, const OSSL_PARAM params[]); -void *evp_keymgmt_gen_init(const EVP_KEYMGMT *keymgmt, int selection, const OSSL_PARAM params[]); -int evp_keymgmt_gen_set_template(const EVP_KEYMGMT *keymgmt, void *genctx, void *template); -int evp_keymgmt_gen_set_params(const EVP_KEYMGMT *keymgmt, void *genctx, const OSSL_PARAM params[]); -void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx, OSSL_CALLBACK *cb, void *cbarg); +int evp_keymgmt_get_params(const EVP_KEYMGMT *keymgmt, void *keydata, + OSSL_PARAM params[]); +int evp_keymgmt_set_params(const EVP_KEYMGMT *keymgmt, void *keydata, + const OSSL_PARAM params[]); +void *evp_keymgmt_gen_init(const EVP_KEYMGMT *keymgmt, int selection, + const OSSL_PARAM params[]); +int evp_keymgmt_gen_set_template(const EVP_KEYMGMT *keymgmt, void *genctx, + void *template); +int evp_keymgmt_gen_set_params(const EVP_KEYMGMT *keymgmt, void *genctx, + const OSSL_PARAM params[]); +void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx, + OSSL_CALLBACK *cb, void *cbarg); void evp_keymgmt_gen_cleanup(const EVP_KEYMGMT *keymgmt, void *genctx); int evp_keymgmt_has_load(const EVP_KEYMGMT *keymgmt); -void *evp_keymgmt_load(const EVP_KEYMGMT *keymgmt, const void *objref, size_t objref_sz); +void *evp_keymgmt_load(const EVP_KEYMGMT *keymgmt, const void *objref, + size_t objref_sz); int evp_keymgmt_has(const EVP_KEYMGMT *keymgmt, void *keyddata, int selection); -int evp_keymgmt_validate(const EVP_KEYMGMT *keymgmt, void *keydata, int selection, int checktype); -int evp_keymgmt_match(const EVP_KEYMGMT *keymgmt, const void *keydata1, const void *keydata2, - int selection); +int evp_keymgmt_validate(const EVP_KEYMGMT *keymgmt, void *keydata, + int selection, int checktype); +int evp_keymgmt_match(const EVP_KEYMGMT *keymgmt, const void *keydata1, + const void *keydata2, int selection); int evp_keymgmt_import(const EVP_KEYMGMT *keymgmt, void *keydata, int selection, const OSSL_PARAM params[]); -const OSSL_PARAM *evp_keymgmt_import_types(const EVP_KEYMGMT *keymgmt, int selection); +const OSSL_PARAM *evp_keymgmt_import_types(const EVP_KEYMGMT *keymgmt, + int selection); int evp_keymgmt_export(const EVP_KEYMGMT *keymgmt, void *keydata, int selection, OSSL_CALLBACK *param_cb, void *cbarg); -const OSSL_PARAM *evp_keymgmt_export_types(const EVP_KEYMGMT *keymgmt, int selection); -void *evp_keymgmt_dup(const EVP_KEYMGMT *keymgmt, const void *keydata_from, int selection); +const OSSL_PARAM *evp_keymgmt_export_types(const EVP_KEYMGMT *keymgmt, + int selection); +void *evp_keymgmt_dup(const EVP_KEYMGMT *keymgmt, const void *keydata_from, + int selection); EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov, const char *name, const char *properties); @@ -835,7 +889,7 @@ EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov, const char *name, #define EVP_RC4_KEY_SIZE 16 #ifndef TLS1_1_VERSION -# define TLS1_1_VERSION 0x0302 +# define TLS1_1_VERSION 0x0302 #endif void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags); @@ -846,12 +900,15 @@ void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags); /* Use the SRP base64 alphabet instead of the standard one */ #define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2 -const EVP_CIPHER *evp_get_cipherbyname_ex(OSSL_LIB_CTX *libctx, const char *name); +const EVP_CIPHER *evp_get_cipherbyname_ex(OSSL_LIB_CTX *libctx, + const char *name); const EVP_MD *evp_get_digestbyname_ex(OSSL_LIB_CTX *libctx, const char *name); -int ossl_pkcs5_pbkdf2_hmac_ex(const char *pass, int passlen, const unsigned char *salt, int saltlen, - int iter, const EVP_MD *digest, int keylen, unsigned char *out, - OSSL_LIB_CTX *libctx, const char *propq); +int ossl_pkcs5_pbkdf2_hmac_ex(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + const EVP_MD *digest, int keylen, + unsigned char *out, OSSL_LIB_CTX *libctx, + const char *propq); #ifndef FIPS_MODULE /* @@ -869,8 +926,8 @@ int ossl_pkcs5_pbkdf2_hmac_ex(const char *pass, int passlen, const unsigned char int evp_pkey_ctx_set_params_strict(EVP_PKEY_CTX *ctx, OSSL_PARAM *params); int evp_pkey_ctx_get_params_strict(EVP_PKEY_CTX *ctx, OSSL_PARAM *params); -EVP_MD_CTX *evp_md_ctx_new_ex(EVP_PKEY *pkey, const ASN1_OCTET_STRING *id, OSSL_LIB_CTX *libctx, - const char *propq); +EVP_MD_CTX *evp_md_ctx_new_ex(EVP_PKEY *pkey, const ASN1_OCTET_STRING *id, + OSSL_LIB_CTX *libctx, const char *propq); int evp_pkey_name2type(const char *name); const char *evp_pkey_type2name(int type); @@ -884,9 +941,10 @@ int evp_pkey_ctx_use_cached_data(EVP_PKEY_CTX *ctx); int evp_method_store_cache_flush(OSSL_LIB_CTX *libctx); int evp_method_store_remove_all_provided(const OSSL_PROVIDER *prov); -int evp_default_properties_enable_fips_int(OSSL_LIB_CTX *libctx, int enable, int loadconfig); -int evp_set_default_properties_int(OSSL_LIB_CTX *libctx, const char *propq, int loadconfig, - int mirrored); +int evp_default_properties_enable_fips_int(OSSL_LIB_CTX *libctx, int enable, + int loadconfig); +int evp_set_default_properties_int(OSSL_LIB_CTX *libctx, const char *propq, + int loadconfig, int mirrored); char *evp_get_global_properties_str(OSSL_LIB_CTX *libctx, int loadconfig); void evp_md_ctx_clear_digest(EVP_MD_CTX *ctx, int force, int keep_digest); @@ -900,12 +958,14 @@ int evp_md_ctx_free_algctx(EVP_MD_CTX *ctx); int evp_pkey_ctx_state(const EVP_PKEY_CTX *ctx); /* These two must ONLY be called for provider side operations */ -int evp_pkey_ctx_ctrl_to_param(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, - void *p2); -int evp_pkey_ctx_ctrl_str_to_param(EVP_PKEY_CTX *ctx, const char *name, const char *value); +int evp_pkey_ctx_ctrl_to_param(EVP_PKEY_CTX *ctx, int keytype, int optype, + int cmd, int p1, void *p2); +int evp_pkey_ctx_ctrl_str_to_param(EVP_PKEY_CTX *ctx, const char *name, + const char *value); /* These two must ONLY be called for legacy operations */ -int evp_pkey_ctx_set_params_to_ctrl(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params); +int evp_pkey_ctx_set_params_to_ctrl(EVP_PKEY_CTX *ctx, + const OSSL_PARAM *params); int evp_pkey_ctx_get_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params); /* This must ONLY be called for legacy EVP_PKEYs */ diff --git a/libs/OpenSSL/include/crypto/md32_common.h b/libs/OpenSSL/include/crypto/md32_common.h index 0f290053..03ffc439 100644 --- a/libs/OpenSSL/include/crypto/md32_common.h +++ b/libs/OpenSSL/include/crypto/md32_common.h @@ -70,81 +70,86 @@ #include #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN) -# error "DATA_ORDER must be defined!" +# error "DATA_ORDER must be defined!" #endif #ifndef HASH_CBLOCK -# error "HASH_CBLOCK must be defined!" +# error "HASH_CBLOCK must be defined!" #endif #ifndef HASH_LONG -# error "HASH_LONG must be defined!" +# error "HASH_LONG must be defined!" #endif #ifndef HASH_CTX -# error "HASH_CTX must be defined!" +# error "HASH_CTX must be defined!" #endif #ifndef HASH_UPDATE -# error "HASH_UPDATE must be defined!" +# error "HASH_UPDATE must be defined!" #endif #ifndef HASH_TRANSFORM -# error "HASH_TRANSFORM must be defined!" +# error "HASH_TRANSFORM must be defined!" #endif #ifndef HASH_FINAL -# error "HASH_FINAL must be defined!" +# error "HASH_FINAL must be defined!" #endif #ifndef HASH_BLOCK_DATA_ORDER -# error "HASH_BLOCK_DATA_ORDER must be defined!" +# error "HASH_BLOCK_DATA_ORDER must be defined!" #endif -#define ROTATE(a, n) (((a) << (n)) | (((a)&0xffffffff) >> (32 - (n)))) +#define ROTATE(a, n) (((a) << (n)) | (((a) & 0xffffffff) >> (32 - (n)))) #ifndef PEDANTIC -# if defined(__GNUC__) && __GNUC__ >= 2 && !defined(OPENSSL_NO_ASM) \ - && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(__riscv_zbb) || defined(__riscv_zbkb) -# if __riscv_xlen == 64 -# undef ROTATE -# define ROTATE(x, n) \ - ({ \ - MD32_REG_T ret; \ - asm("roriw %0, %1, %2" : "=r"(ret) : "r"(x), "i"(32 - (n))); \ - ret; \ - }) -# endif -# if __riscv_xlen == 32 -# undef ROTATE -# define ROTATE(x, n) \ - ({ \ - MD32_REG_T ret; \ - asm("rori %0, %1, %2" : "=r"(ret) : "r"(x), "i"(32 - (n))); \ - ret; \ - }) -# endif -# endif +# if defined(__GNUC__) && __GNUC__ >= 2 && !defined(OPENSSL_NO_ASM) \ + && !defined(OPENSSL_NO_INLINE_ASM) +# if defined(__riscv_zbb) || defined(__riscv_zbkb) +# if __riscv_xlen == 64 +# undef ROTATE +# define ROTATE(x, n) \ + ({ \ + MD32_REG_T ret; \ + asm("roriw %0, %1, %2" : "=r"(ret) : "r"(x), "i"(32 - (n))); \ + ret; \ + }) +# endif +# if __riscv_xlen == 32 +# undef ROTATE +# define ROTATE(x, n) \ + ({ \ + MD32_REG_T ret; \ + asm("rori %0, %1, %2" : "=r"(ret) : "r"(x), "i"(32 - (n))); \ + ret; \ + }) +# endif # endif +# endif #endif #if defined(DATA_ORDER_IS_BIG_ENDIAN) -# define HOST_c2l(c, l) \ - (l = (((unsigned long)(*((c)++))) << 24), l |= (((unsigned long)(*((c)++))) << 16), \ - l |= (((unsigned long)(*((c)++))) << 8), l |= (((unsigned long)(*((c)++))))) -# define HOST_l2c(l, c) \ - (*((c)++) = (unsigned char)(((l) >> 24) & 0xff), \ - *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ - *((c)++) = (unsigned char)(((l) >> 8) & 0xff), *((c)++) = (unsigned char)(((l)) & 0xff), \ - l) +# define HOST_c2l(c, l) \ + (l = (((unsigned long)(*((c)++))) << 24), \ + l |= (((unsigned long)(*((c)++))) << 16), \ + l |= (((unsigned long)(*((c)++))) << 8), \ + l |= (((unsigned long)(*((c)++))))) +# define HOST_l2c(l, c) \ + (*((c)++) = (unsigned char)(((l) >> 24) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l)) & 0xff), l) #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) -# define HOST_c2l(c, l) \ - (l = (((unsigned long)(*((c)++)))), l |= (((unsigned long)(*((c)++))) << 8), \ - l |= (((unsigned long)(*((c)++))) << 16), l |= (((unsigned long)(*((c)++))) << 24)) -# define HOST_l2c(l, c) \ - (*((c)++) = (unsigned char)(((l)) & 0xff), *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ - *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ - *((c)++) = (unsigned char)(((l) >> 24) & 0xff), l) +# define HOST_c2l(c, l) \ + (l = (((unsigned long)(*((c)++)))), \ + l |= (((unsigned long)(*((c)++))) << 8), \ + l |= (((unsigned long)(*((c)++))) << 16), \ + l |= (((unsigned long)(*((c)++))) << 24)) +# define HOST_l2c(l, c) \ + (*((c)++) = (unsigned char)(((l)) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 24) & 0xff), l) #endif @@ -154,114 +159,114 @@ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len) { - const unsigned char *data = data_; - unsigned char *p; - HASH_LONG l; - size_t n; + const unsigned char *data = data_; + unsigned char *p; + HASH_LONG l; + size_t n; - if (len == 0) - return 1; - - l = (c->Nl + (((HASH_LONG)len) << 3)) & 0xffffffffUL; - if (l < c->Nl) /* overflow */ - c->Nh++; - c->Nh += (HASH_LONG)(len >> 29); /* might cause compiler warning on - * 16-bit */ - c->Nl = l; - - n = c->num; - if (n != 0) - { - p = (unsigned char *)c->data; - - if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) - { - memcpy(p + n, data, HASH_CBLOCK - n); - HASH_BLOCK_DATA_ORDER(c, p, 1); - n = HASH_CBLOCK - n; - data += n; - len -= n; - c->num = 0; - /* - * We use memset rather than OPENSSL_cleanse() here deliberately. - * Using OPENSSL_cleanse() here could be a performance issue. It - * will get properly cleansed on finalisation so this isn't a - * security problem. - */ - memset(p, 0, HASH_CBLOCK); /* keep it zeroed */ - } - else - { - memcpy(p + n, data, len); - c->num += (unsigned int)len; - return 1; - } - } - - n = len / HASH_CBLOCK; - if (n > 0) - { - HASH_BLOCK_DATA_ORDER(c, data, n); - n *= HASH_CBLOCK; - data += n; - len -= n; - } - - if (len != 0) - { - p = (unsigned char *)c->data; - c->num = (unsigned int)len; - memcpy(p, data, len); - } + if (len == 0) return 1; + + l = (c->Nl + (((HASH_LONG)len) << 3)) & 0xffffffffUL; + if (l < c->Nl) /* overflow */ + c->Nh++; + c->Nh += (HASH_LONG)(len >> 29); /* might cause compiler warning on + * 16-bit */ + c->Nl = l; + + n = c->num; + if (n != 0) + { + p = (unsigned char *)c->data; + + if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) + { + memcpy(p + n, data, HASH_CBLOCK - n); + HASH_BLOCK_DATA_ORDER(c, p, 1); + n = HASH_CBLOCK - n; + data += n; + len -= n; + c->num = 0; + /* + * We use memset rather than OPENSSL_cleanse() here deliberately. + * Using OPENSSL_cleanse() here could be a performance issue. It + * will get properly cleansed on finalisation so this isn't a + * security problem. + */ + memset(p, 0, HASH_CBLOCK); /* keep it zeroed */ + } + else + { + memcpy(p + n, data, len); + c->num += (unsigned int)len; + return 1; + } + } + + n = len / HASH_CBLOCK; + if (n > 0) + { + HASH_BLOCK_DATA_ORDER(c, data, n); + n *= HASH_CBLOCK; + data += n; + len -= n; + } + + if (len != 0) + { + p = (unsigned char *)c->data; + c->num = (unsigned int)len; + memcpy(p, data, len); + } + return 1; } void HASH_TRANSFORM(HASH_CTX *c, const unsigned char *data) { - HASH_BLOCK_DATA_ORDER(c, data, 1); + HASH_BLOCK_DATA_ORDER(c, data, 1); } int HASH_FINAL(unsigned char *md, HASH_CTX *c) { - unsigned char *p = (unsigned char *)c->data; - size_t n = c->num; + unsigned char *p = (unsigned char *)c->data; + size_t n = c->num; - p[n] = 0x80; /* there is always room for one */ - n++; + p[n] = 0x80; /* there is always room for one */ + n++; - if (n > (HASH_CBLOCK - 8)) - { - memset(p + n, 0, HASH_CBLOCK - n); - n = 0; - HASH_BLOCK_DATA_ORDER(c, p, 1); - } - memset(p + n, 0, HASH_CBLOCK - 8 - n); - - p += HASH_CBLOCK - 8; -#if defined(DATA_ORDER_IS_BIG_ENDIAN) - (void)HOST_l2c(c->Nh, p); - (void)HOST_l2c(c->Nl, p); -#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) - (void)HOST_l2c(c->Nl, p); - (void)HOST_l2c(c->Nh, p); -#endif - p -= HASH_CBLOCK; + if (n > (HASH_CBLOCK - 8)) + { + memset(p + n, 0, HASH_CBLOCK - n); + n = 0; HASH_BLOCK_DATA_ORDER(c, p, 1); - c->num = 0; - OPENSSL_cleanse(p, HASH_CBLOCK); + } + memset(p + n, 0, HASH_CBLOCK - 8 - n); + + p += HASH_CBLOCK - 8; +#if defined(DATA_ORDER_IS_BIG_ENDIAN) + (void)HOST_l2c(c->Nh, p); + (void)HOST_l2c(c->Nl, p); +#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) + (void)HOST_l2c(c->Nl, p); + (void)HOST_l2c(c->Nh, p); +#endif + p -= HASH_CBLOCK; + HASH_BLOCK_DATA_ORDER(c, p, 1); + c->num = 0; + OPENSSL_cleanse(p, HASH_CBLOCK); #ifndef HASH_MAKE_STRING -# error "HASH_MAKE_STRING must be defined!" +# error "HASH_MAKE_STRING must be defined!" #else - HASH_MAKE_STRING(c, md); + HASH_MAKE_STRING(c, md); #endif - return 1; + return 1; } #ifndef MD32_REG_T -# if defined(__alpha) || defined(__sparcv9) || defined(__mips) -# define MD32_REG_T long +# if defined(__alpha) || defined(__sparcv9) || defined(__mips) +# define MD32_REG_T long /* * This comment was originally written for MD5, which is why it * discusses A-D. But it basically applies to all 32-bit digests, @@ -278,15 +283,15 @@ int HASH_FINAL(unsigned char *md, HASH_CTX *c) * Well, to be honest it should say that this *prevents* * performance degradation. */ -# else +# else /* * Above is not absolute and there are LP64 compilers that * generate better code if MD32_REG_T is defined int. The above * pre-processor condition reflects the circumstances under which * the conclusion was made and is subject to further extension. */ -# define MD32_REG_T int -# endif +# define MD32_REG_T int +# endif #endif #endif diff --git a/libs/OpenSSL/include/crypto/modes.h b/libs/OpenSSL/include/crypto/modes.h index 9b29e6c0..78e83047 100644 --- a/libs/OpenSSL/include/crypto/modes.h +++ b/libs/OpenSSL/include/crypto/modes.h @@ -13,15 +13,15 @@ #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) typedef __int64 i64; typedef unsigned __int64 u64; -# define U64(C) C##UI64 +# define U64(C) C##UI64 #elif defined(__arch64__) typedef long i64; typedef unsigned long u64; -# define U64(C) C##UL +# define U64(C) C##UL #else typedef long long i64; typedef unsigned long long u64; -# define U64(C) C##ULL +# define U64(C) C##ULL #endif typedef unsigned int u32; @@ -29,150 +29,152 @@ typedef unsigned char u8; #define STRICT_ALIGNMENT 1 #ifndef PEDANTIC -# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) \ - || defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || defined(__aarch64__) \ - || defined(__s390__) || defined(__s390x__) -# undef STRICT_ALIGNMENT -# endif +# if defined(__i386) || defined(__i386__) || defined(__x86_64) \ + || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64) \ + || defined(_M_X64) || defined(__aarch64__) || defined(__s390__) \ + || defined(__s390x__) +# undef STRICT_ALIGNMENT +# endif #endif -#if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(__GNUC__) && __GNUC__ >= 2 -# if defined(__x86_64) || defined(__x86_64__) -# define BSWAP8(x) \ - ({ \ - u64 ret_ = (x); \ - asm("bswapq %0" : "+r"(ret_)); \ - ret_; \ - }) -# define BSWAP4(x) \ - ({ \ - u32 ret_ = (x); \ - asm("bswapl %0" : "+r"(ret_)); \ - ret_; \ - }) -# elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) -# define BSWAP8(x) \ - ({ \ - u32 lo_ = (u64)(x) >> 32, hi_ = (x); \ - asm("bswapl %0; bswapl %1" : "+r"(hi_), "+r"(lo_)); \ - (u64) hi_ << 32 | lo_; \ - }) -# define BSWAP4(x) \ - ({ \ - u32 ret_ = (x); \ - asm("bswapl %0" : "+r"(ret_)); \ - ret_; \ - }) -# elif defined(__aarch64__) -# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) \ - && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define BSWAP8(x) \ - ({ \ - u64 ret_; \ - asm("rev %0,%1" : "=r"(ret_) : "r"(x)); \ - ret_; \ - }) -# define BSWAP4(x) \ - ({ \ - u32 ret_; \ - asm("rev %w0,%w1" : "=r"(ret_) : "r"(x)); \ - ret_; \ - }) -# endif -# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT) -# define BSWAP8(x) \ - ({ \ - u32 lo_ = (u64)(x) >> 32, hi_ = (x); \ - asm("rev %0,%0; rev %1,%1" : "+r"(hi_), "+r"(lo_)); \ - (u64) hi_ << 32 | lo_; \ - }) -# define BSWAP4(x) \ - ({ \ - u32 ret_; \ - asm("rev %0,%1" : "=r"(ret_) : "r"((u32)(x))); \ - ret_; \ - }) -# elif (defined(__riscv_zbb) || defined(__riscv_zbkb)) && __riscv_xlen == 64 -# define BSWAP8(x) \ - ({ \ - u64 ret_ = (x); \ - asm("rev8 %0,%0" : "+r"(ret_)); \ - ret_; \ - }) -# define BSWAP4(x) \ - ({ \ - u32 ret_ = (x); \ - asm("rev8 %0,%0; srli %0,%0,32" : "+&r"(ret_)); \ - ret_; \ - }) -# endif -# elif defined(_MSC_VER) -# if _MSC_VER >= 1300 -# include -# pragma intrinsic(_byteswap_uint64, _byteswap_ulong) -# define BSWAP8(x) _byteswap_uint64((u64)(x)) -# define BSWAP4(x) _byteswap_ulong((u32)(x)) -# elif defined(_M_IX86) -__inline u32 _bswap4(u32 val) -{ - _asm mov eax, val _asm bswap eax -} -# define BSWAP4(x) _bswap4(x) -# endif +#if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) \ + && !defined(OPENSSL_NO_INLINE_ASM) +# if defined(__GNUC__) && __GNUC__ >= 2 +# if defined(__x86_64) || defined(__x86_64__) +# define BSWAP8(x) \ + ({ \ + u64 ret_ = (x); \ + asm("bswapq %0" : "+r"(ret_)); \ + ret_; \ + }) +# define BSWAP4(x) \ + ({ \ + u32 ret_ = (x); \ + asm("bswapl %0" : "+r"(ret_)); \ + ret_; \ + }) +# elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) +# define BSWAP8(x) \ + ({ \ + u32 lo_ = (u64)(x) >> 32, hi_ = (x); \ + asm("bswapl %0; bswapl %1" : "+r"(hi_), "+r"(lo_)); \ + (u64) hi_ << 32 | lo_; \ + }) +# define BSWAP4(x) \ + ({ \ + u32 ret_ = (x); \ + asm("bswapl %0" : "+r"(ret_)); \ + ret_; \ + }) +# elif defined(__aarch64__) +# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) \ + && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define BSWAP8(x) \ + ({ \ + u64 ret_; \ + asm("rev %0,%1" : "=r"(ret_) : "r"(x)); \ + ret_; \ + }) +# define BSWAP4(x) \ + ({ \ + u32 ret_; \ + asm("rev %w0,%w1" : "=r"(ret_) : "r"(x)); \ + ret_; \ + }) +# endif +# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT) +# define BSWAP8(x) \ + ({ \ + u32 lo_ = (u64)(x) >> 32, hi_ = (x); \ + asm("rev %0,%0; rev %1,%1" : "+r"(hi_), "+r"(lo_)); \ + (u64) hi_ << 32 | lo_; \ + }) +# define BSWAP4(x) \ + ({ \ + u32 ret_; \ + asm("rev %0,%1" : "=r"(ret_) : "r"((u32)(x))); \ + ret_; \ + }) +# elif (defined(__riscv_zbb) || defined(__riscv_zbkb)) && __riscv_xlen == 64 +# define BSWAP8(x) \ + ({ \ + u64 ret_ = (x); \ + asm("rev8 %0,%0" : "+r"(ret_)); \ + ret_; \ + }) +# define BSWAP4(x) \ + ({ \ + u32 ret_ = (x); \ + asm("rev8 %0,%0; srli %0,%0,32" : "+&r"(ret_)); \ + ret_; \ + }) # endif +# elif defined(_MSC_VER) +# if _MSC_VER >= 1300 +# include +# pragma intrinsic(_byteswap_uint64, _byteswap_ulong) +# define BSWAP8(x) _byteswap_uint64((u64)(x)) +# define BSWAP4(x) _byteswap_ulong((u32)(x)) +# elif defined(_M_IX86) +__inline u32 _bswap4(u32 val){_asm mov eax, val _asm bswap eax} +# define BSWAP4(x) _bswap4(x) +# endif +# endif #endif #if defined(BSWAP4) && !defined(STRICT_ALIGNMENT) -# define GETU32(p) BSWAP4(*(const u32 *)(p)) -# define PUTU32(p, v) *(u32 *)(p) = BSWAP4(v) +# define GETU32(p) BSWAP4(*(const u32 *)(p)) +# define PUTU32(p, v) *(u32 *)(p) = BSWAP4(v) #else -# define GETU32(p) ((u32)(p)[0] << 24 | (u32)(p)[1] << 16 | (u32)(p)[2] << 8 | (u32)(p)[3]) -# define PUTU32(p, v) \ - ((p)[0] = (u8)((v) >> 24), (p)[1] = (u8)((v) >> 16), (p)[2] = (u8)((v) >> 8), \ - (p)[3] = (u8)(v)) +# define GETU32(p) \ + ((u32)(p)[0] << 24 | (u32)(p)[1] << 16 | (u32)(p)[2] << 8 | (u32)(p)[3]) +# define PUTU32(p, v) \ + ((p)[0] = (u8)((v) >> 24), (p)[1] = (u8)((v) >> 16), \ + (p)[2] = (u8)((v) >> 8), (p)[3] = (u8)(v)) #endif /*- GCM definitions */ typedef struct { - u64 hi, lo; + u64 hi, lo; } u128; typedef void (*gcm_init_fn)(u128 Htable[16], const u64 H[2]); -typedef void (*gcm_ghash_fn)(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len); +typedef void (*gcm_ghash_fn)(u64 Xi[2], const u128 Htable[16], const u8 *inp, + size_t len); typedef void (*gcm_gmult_fn)(u64 Xi[2], const u128 Htable[16]); struct gcm_funcs_st { - gcm_init_fn ginit; - gcm_ghash_fn ghash; - gcm_gmult_fn gmult; + gcm_init_fn ginit; + gcm_ghash_fn ghash; + gcm_gmult_fn gmult; }; struct gcm128_context { - /* Following 6 names follow names in GCM specification */ - union - { - u64 u[2]; - u32 d[4]; - u8 c[16]; - size_t t[16 / sizeof(size_t)]; - } Yi, EKi, EK0, len, Xi, H; - /* - * Relative position of Yi, EKi, EK0, len, Xi, H and pre-computed Htable is - * used in some assembler modules, i.e. don't change the order! - */ - u128 Htable[16]; - struct gcm_funcs_st funcs; - unsigned int mres, ares; - block128_f block; - void *key; + /* Following 6 names follow names in GCM specification */ + union + { + u64 u[2]; + u32 d[4]; + u8 c[16]; + size_t t[16 / sizeof(size_t)]; + } Yi, EKi, EK0, len, Xi, H; + /* + * Relative position of Yi, EKi, EK0, len, Xi, H and pre-computed Htable is + * used in some assembler modules, i.e. don't change the order! + */ + u128 Htable[16]; + struct gcm_funcs_st funcs; + unsigned int mres, ares; + block128_f block; + void *key; #if !defined(OPENSSL_SMALL_FOOTPRINT) - unsigned char Xn[48]; + unsigned char Xn[48]; #endif }; /* GHASH functions */ void ossl_gcm_init_4bit(u128 Htable[16], const u64 H[2]); -void ossl_gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], const u8 *inp, size_t len); +void ossl_gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], const u8 *inp, + size_t len); void ossl_gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16]); /* @@ -183,90 +185,93 @@ void ossl_gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16]); struct xts128_context { - void *key1, *key2; - block128_f block1, block2; + void *key1, *key2; + block128_f block1, block2; }; /* XTS mode for SM4 algorithm specified by GB/T 17964-2021 */ -int ossl_crypto_xts128gb_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16], - const unsigned char *inp, unsigned char *out, size_t len, int enc); +int ossl_crypto_xts128gb_encrypt(const XTS128_CONTEXT *ctx, + const unsigned char iv[16], + const unsigned char *inp, unsigned char *out, + size_t len, int enc); struct ccm128_context { - union - { - u64 u[2]; - u8 c[16]; - } nonce, cmac; - u64 blocks; - block128_f block; - void *key; + union + { + u64 u[2]; + u8 c[16]; + } nonce, cmac; + u64 blocks; + block128_f block; + void *key; }; #ifndef OPENSSL_NO_OCB typedef union { - u64 a[2]; - unsigned char c[16]; + u64 a[2]; + unsigned char c[16]; } OCB_BLOCK; -# define ocb_block16_xor(in1, in2, out) \ - ((out)->a[0] = (in1)->a[0] ^ (in2)->a[0], (out)->a[1] = (in1)->a[1] ^ (in2)->a[1]) -# if STRICT_ALIGNMENT -# define ocb_block16_xor_misaligned(in1, in2, out) \ - ocb_block_xor((in1)->c, (in2)->c, 16, (out)->c) -# else -# define ocb_block16_xor_misaligned ocb_block16_xor -# endif +# define ocb_block16_xor(in1, in2, out) \ + ((out)->a[0] = (in1)->a[0] ^ (in2)->a[0], \ + (out)->a[1] = (in1)->a[1] ^ (in2)->a[1]) +# if STRICT_ALIGNMENT +# define ocb_block16_xor_misaligned(in1, in2, out) \ + ocb_block_xor((in1)->c, (in2)->c, 16, (out)->c) +# else +# define ocb_block16_xor_misaligned ocb_block16_xor +# endif struct ocb128_context { - /* Need both encrypt and decrypt key schedules for decryption */ - block128_f encrypt; - block128_f decrypt; - void *keyenc; - void *keydec; - ocb128_f stream; /* direction dependent */ - /* Key dependent variables. Can be reused if key remains the same */ - size_t l_index; - size_t max_l_index; - OCB_BLOCK l_star; - OCB_BLOCK l_dollar; - OCB_BLOCK *l; - /* Must be reset for each session */ - struct - { - u64 blocks_hashed; - u64 blocks_processed; - OCB_BLOCK offset_aad; - OCB_BLOCK sum; - OCB_BLOCK offset; - OCB_BLOCK checksum; - } sess; + /* Need both encrypt and decrypt key schedules for decryption */ + block128_f encrypt; + block128_f decrypt; + void *keyenc; + void *keydec; + ocb128_f stream; /* direction dependent */ + /* Key dependent variables. Can be reused if key remains the same */ + size_t l_index; + size_t max_l_index; + OCB_BLOCK l_star; + OCB_BLOCK l_dollar; + OCB_BLOCK *l; + /* Must be reset for each session */ + struct + { + u64 blocks_hashed; + u64 blocks_processed; + OCB_BLOCK offset_aad; + OCB_BLOCK sum; + OCB_BLOCK offset; + OCB_BLOCK checksum; + } sess; }; #endif /* OPENSSL_NO_OCB */ #ifndef OPENSSL_NO_SIV -# define SIV_LEN 16 +# define SIV_LEN 16 typedef union siv_block_u { - uint64_t word[SIV_LEN / sizeof(uint64_t)]; - unsigned char byte[SIV_LEN]; + uint64_t word[SIV_LEN / sizeof(uint64_t)]; + unsigned char byte[SIV_LEN]; } SIV_BLOCK; struct siv128_context { - /* d stores intermediate results of S2V; it corresponds to D from the - pseudocode in section 2.4 of RFC 5297. */ - SIV_BLOCK d; - SIV_BLOCK tag; - EVP_CIPHER_CTX *cipher_ctx; - EVP_MAC *mac; - EVP_MAC_CTX *mac_ctx_init; - int final_ret; - int crypto_ok; + /* d stores intermediate results of S2V; it corresponds to D from the + pseudocode in section 2.4 of RFC 5297. */ + SIV_BLOCK d; + SIV_BLOCK tag; + EVP_CIPHER_CTX *cipher_ctx; + EVP_MAC *mac; + EVP_MAC_CTX *mac_ctx_init; + int final_ret; + int crypto_ok; }; #endif /* OPENSSL_NO_SIV */ diff --git a/libs/OpenSSL/include/crypto/pem.h b/libs/OpenSSL/include/crypto/pem.h index 361d1f06..99cc383f 100644 --- a/libs/OpenSSL/include/crypto/pem.h +++ b/libs/OpenSSL/include/crypto/pem.h @@ -19,29 +19,33 @@ /* Maximum length of a blob after header */ #define BLOB_MAX_LENGTH 102400 -int ossl_do_blob_header(const unsigned char **in, unsigned int length, unsigned int *pmagic, - unsigned int *pbitlen, int *pisdss, int *pispub); +int ossl_do_blob_header(const unsigned char **in, unsigned int length, + unsigned int *pmagic, unsigned int *pbitlen, + int *pisdss, int *pispub); unsigned int ossl_blob_length(unsigned bitlen, int isdss, int ispub); -int ossl_do_PVK_header(const unsigned char **in, unsigned int length, int skip_magic, - unsigned int *psaltlen, unsigned int *pkeylen); +int ossl_do_PVK_header(const unsigned char **in, unsigned int length, + int skip_magic, unsigned int *psaltlen, + unsigned int *pkeylen); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_DSA -DSA *ossl_b2i_DSA_after_header(const unsigned char **in, unsigned int bitlen, int ispub); -# endif -RSA *ossl_b2i_RSA_after_header(const unsigned char **in, unsigned int bitlen, int ispub); +# ifndef OPENSSL_NO_DSA +DSA *ossl_b2i_DSA_after_header(const unsigned char **in, unsigned int bitlen, + int ispub); +# endif +RSA *ossl_b2i_RSA_after_header(const unsigned char **in, unsigned int bitlen, + int ispub); #endif EVP_PKEY *ossl_b2i(const unsigned char **in, unsigned int length, int *ispub); EVP_PKEY *ossl_b2i_bio(BIO *in, int *ispub); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_DSA +# ifndef OPENSSL_NO_DSA DSA *b2i_DSA_PVK_bio(BIO *in, pem_password_cb *cb, void *u); -DSA *b2i_DSA_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx, - const char *propq); -# endif +DSA *b2i_DSA_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, + OSSL_LIB_CTX *libctx, const char *propq); +# endif RSA *b2i_RSA_PVK_bio(BIO *in, pem_password_cb *cb, void *u); -RSA *b2i_RSA_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx, - const char *propq); +RSA *b2i_RSA_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, + OSSL_LIB_CTX *libctx, const char *propq); #endif #endif diff --git a/libs/OpenSSL/include/crypto/poly1305.h b/libs/OpenSSL/include/crypto/poly1305.h index 152cac0b..ed37c2f4 100644 --- a/libs/OpenSSL/include/crypto/poly1305.h +++ b/libs/OpenSSL/include/crypto/poly1305.h @@ -19,24 +19,25 @@ typedef struct poly1305_context POLY1305; -typedef void (*poly1305_blocks_f)(void *ctx, const unsigned char *inp, size_t len, - unsigned int padbit); -typedef void (*poly1305_emit_f)(void *ctx, unsigned char mac[16], const unsigned int nonce[4]); +typedef void (*poly1305_blocks_f)(void *ctx, const unsigned char *inp, + size_t len, unsigned int padbit); +typedef void (*poly1305_emit_f)(void *ctx, unsigned char mac[16], + const unsigned int nonce[4]); struct poly1305_context { - double opaque[24]; /* large enough to hold internal state, declared - * 'double' to ensure at least 64-bit invariant - * alignment across all platforms and - * configurations */ - unsigned int nonce[4]; - unsigned char data[POLY1305_BLOCK_SIZE]; - size_t num; - struct - { - poly1305_blocks_f blocks; - poly1305_emit_f emit; - } func; + double opaque[24]; /* large enough to hold internal state, declared + * 'double' to ensure at least 64-bit invariant + * alignment across all platforms and + * configurations */ + unsigned int nonce[4]; + unsigned char data[POLY1305_BLOCK_SIZE]; + size_t num; + struct + { + poly1305_blocks_f blocks; + poly1305_emit_f emit; + } func; }; size_t Poly1305_ctx_size(void); diff --git a/libs/OpenSSL/include/crypto/punycode.h b/libs/OpenSSL/include/crypto/punycode.h index 3df1a513..7efce84d 100644 --- a/libs/OpenSSL/include/crypto/punycode.h +++ b/libs/OpenSSL/include/crypto/punycode.h @@ -13,8 +13,8 @@ #include /* for size_t */ -int ossl_punycode_decode(const char *pEncoded, const size_t enc_len, unsigned int *pDecoded, - unsigned int *pout_length); +int ossl_punycode_decode(const char *pEncoded, const size_t enc_len, + unsigned int *pDecoded, unsigned int *pout_length); int ossl_a2ulabel(const char *in, char *out, size_t outlen); diff --git a/libs/OpenSSL/include/crypto/rand.h b/libs/OpenSSL/include/crypto/rand.h index 3fa3226d..32fda0ad 100644 --- a/libs/OpenSSL/include/crypto/rand.h +++ b/libs/OpenSSL/include/crypto/rand.h @@ -23,14 +23,15 @@ #include "crypto/rand_pool.h" #if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM) -# include -# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) \ - || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) \ - && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) -# define OPENSSL_APPLE_CRYPTO_RANDOM 1 -# include -# include -# endif +# include +# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \ + && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) \ + || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) \ + && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) +# define OPENSSL_APPLE_CRYPTO_RANDOM 1 +# include +# include +# endif #endif /* @@ -41,36 +42,36 @@ * set this to a comma-separated list of 'random' device files to try out. By * default, we will try to read at least one of these files */ -# define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom" -# if defined(__linux) && !defined(__ANDROID__) -# ifndef DEVRANDOM_WAIT -# define DEVRANDOM_WAIT "/dev/random" -# endif +# define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom" +# if defined(__linux) && !defined(__ANDROID__) +# ifndef DEVRANDOM_WAIT +# define DEVRANDOM_WAIT "/dev/random" +# endif /* * Linux kernels 4.8 and later changes how their random device works and there * is no reliable way to tell that /dev/urandom has been seeded -- getentropy(2) * should be used instead. */ -# ifndef DEVRANDOM_SAFE_KERNEL -# define DEVRANDOM_SAFE_KERNEL 4, 8 -# endif +# ifndef DEVRANDOM_SAFE_KERNEL +# define DEVRANDOM_SAFE_KERNEL 4, 8 +# endif /* * Some operating systems do not permit select(2) on their random devices, * defining this to zero will force the use of read(2) to extract one byte * from /dev/random. */ -# ifndef DEVRANDM_WAIT_USE_SELECT -# define DEVRANDM_WAIT_USE_SELECT 1 -# endif +# ifndef DEVRANDM_WAIT_USE_SELECT +# define DEVRANDM_WAIT_USE_SELECT 1 +# endif /* * Define the shared memory identifier used to indicate if the operating * system has properly seeded the DEVRANDOM source. */ -# ifndef OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID -# define OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID 114 -# endif - +# ifndef OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID +# define OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID 114 # endif + +# endif #endif #if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD) @@ -79,7 +80,8 @@ * sockets will be tried in the order listed in case accessing the device * files listed in DEVRANDOM did not return enough randomness. */ -# define DEVRANDOM_EGD "/var/run/egd-pool", "/dev/egd-pool", "/etc/egd-pool", "/etc/entropy" +# define DEVRANDOM_EGD \ + "/var/run/egd-pool", "/dev/egd-pool", "/etc/egd-pool", "/etc/entropy" #endif void ossl_rand_cleanup_int(void); @@ -109,14 +111,16 @@ void ossl_random_add_conf_module(void); /* * Get and cleanup random seed material. */ -size_t ossl_rand_get_entropy(ossl_unused const OSSL_CORE_HANDLE *handle, unsigned char **pout, - int entropy, size_t min_len, size_t max_len); -void ossl_rand_cleanup_entropy(ossl_unused const OSSL_CORE_HANDLE *handle, unsigned char *buf, - size_t len); -size_t ossl_rand_get_nonce(ossl_unused const OSSL_CORE_HANDLE *handle, unsigned char **pout, - size_t min_len, size_t max_len, const void *salt, size_t salt_len); -void ossl_rand_cleanup_nonce(ossl_unused const OSSL_CORE_HANDLE *handle, unsigned char *buf, - size_t len); +size_t ossl_rand_get_entropy(ossl_unused const OSSL_CORE_HANDLE *handle, + unsigned char **pout, int entropy, size_t min_len, + size_t max_len); +void ossl_rand_cleanup_entropy(ossl_unused const OSSL_CORE_HANDLE *handle, + unsigned char *buf, size_t len); +size_t ossl_rand_get_nonce(ossl_unused const OSSL_CORE_HANDLE *handle, + unsigned char **pout, size_t min_len, size_t max_len, + const void *salt, size_t salt_len); +void ossl_rand_cleanup_nonce(ossl_unused const OSSL_CORE_HANDLE *handle, + unsigned char *buf, size_t len); /* * Get seeding material from the operating system sources. diff --git a/libs/OpenSSL/include/crypto/rand_pool.h b/libs/OpenSSL/include/crypto/rand_pool.h index 3e8ff864..e74f5c11 100644 --- a/libs/OpenSSL/include/crypto/rand_pool.h +++ b/libs/OpenSSL/include/crypto/rand_pool.h @@ -19,9 +19,9 @@ * * The max_len value for the buffer provided to the rand_drbg_get_entropy() * callback is currently 2^31 bytes (2 gigabytes), if a derivation function - * is used. Since this is much too large to be allocated, the ossl_rand_pool_new() - * function chooses more modest values as default pool length, bounded - * by RAND_POOL_MIN_LENGTH and RAND_POOL_MAX_LENGTH + * is used. Since this is much too large to be allocated, the + * ossl_rand_pool_new() function chooses more modest values as default pool + * length, bounded by RAND_POOL_MIN_LENGTH and RAND_POOL_MAX_LENGTH * * The choice of the RAND_POOL_FACTOR is large enough such that the * RAND_POOL can store a random input which has a lousy entropy rate of @@ -69,21 +69,23 @@ */ typedef struct rand_pool_st { - unsigned char *buffer; /* points to the beginning of the random pool */ - size_t len; /* current number of random bytes contained in the pool */ + unsigned char *buffer; /* points to the beginning of the random pool */ + size_t len; /* current number of random bytes contained in the pool */ - int attached; /* true pool was attached to existing buffer */ - int secure; /* 1: allocated on the secure heap, 0: otherwise */ + int attached; /* true pool was attached to existing buffer */ + int secure; /* 1: allocated on the secure heap, 0: otherwise */ - size_t min_len; /* minimum number of random bytes requested */ - size_t max_len; /* maximum number of random bytes (allocated buffer size) */ - size_t alloc_len; /* current number of bytes allocated */ - size_t entropy; /* current entropy count in bits */ - size_t entropy_requested; /* requested entropy count in bits */ + size_t min_len; /* minimum number of random bytes requested */ + size_t max_len; /* maximum number of random bytes (allocated buffer size) */ + size_t alloc_len; /* current number of bytes allocated */ + size_t entropy; /* current entropy count in bits */ + size_t entropy_requested; /* requested entropy count in bits */ } RAND_POOL; -RAND_POOL *ossl_rand_pool_new(int entropy_requested, int secure, size_t min_len, size_t max_len); -RAND_POOL *ossl_rand_pool_attach(const unsigned char *buffer, size_t len, size_t entropy); +RAND_POOL *ossl_rand_pool_new(int entropy_requested, int secure, size_t min_len, + size_t max_len); +RAND_POOL *ossl_rand_pool_attach(const unsigned char *buffer, size_t len, + size_t entropy); void ossl_rand_pool_free(RAND_POOL *pool); const unsigned char *ossl_rand_pool_buffer(RAND_POOL *pool); @@ -96,10 +98,12 @@ size_t ossl_rand_pool_length(RAND_POOL *pool); size_t ossl_rand_pool_entropy_available(RAND_POOL *pool); size_t ossl_rand_pool_entropy_needed(RAND_POOL *pool); /* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */ -size_t ossl_rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor); +size_t ossl_rand_pool_bytes_needed(RAND_POOL *pool, + unsigned int entropy_factor); size_t ossl_rand_pool_bytes_remaining(RAND_POOL *pool); -int ossl_rand_pool_add(RAND_POOL *pool, const unsigned char *buffer, size_t len, size_t entropy); +int ossl_rand_pool_add(RAND_POOL *pool, const unsigned char *buffer, size_t len, + size_t entropy); unsigned char *ossl_rand_pool_add_begin(RAND_POOL *pool, size_t len); int ossl_rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy); diff --git a/libs/OpenSSL/include/crypto/riscv_arch.h b/libs/OpenSSL/include/crypto/riscv_arch.h index 57917ed2..8f48428e 100644 --- a/libs/OpenSSL/include/crypto/riscv_arch.h +++ b/libs/OpenSSL/include/crypto/riscv_arch.h @@ -21,26 +21,26 @@ extern uint32_t OPENSSL_riscvcap_P[(( / sizeof(uint32_t)]; #ifdef OPENSSL_RISCVCAP_IMPL -# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1 +# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1 uint32_t OPENSSL_riscvcap_P[(( -# include "riscv_arch.def" +# include "riscv_arch.def" ) + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; #endif -#define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) \ - static inline int RISCV_HAS_##NAME(void) \ - { \ - return (OPENSSL_riscvcap_P[INDEX] & (1 << BIT_INDEX)) != 0; \ - } +#define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) \ + static inline int RISCV_HAS_##NAME(void) \ + { \ + return (OPENSSL_riscvcap_P[INDEX] & (1 << BIT_INDEX)) != 0; \ + } #include "riscv_arch.def" struct RISCV_capability_s { - const char *name; - size_t index; - size_t bit_offset; + const char *name; + size_t index; + size_t bit_offset; }; #define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) +1 @@ -49,9 +49,9 @@ extern const struct RISCV_capability_s RISCV_capabilities[ ]; #ifdef OPENSSL_RISCVCAP_IMPL -# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) { # NAME, INDEX, BIT_INDEX }, +# define RISCV_DEFINE_CAP(NAME, INDEX, BIT_INDEX) {#NAME, INDEX, BIT_INDEX}, const struct RISCV_capability_s RISCV_capabilities[] = { -# include "riscv_arch.def" +# include "riscv_arch.def" }; #endif diff --git a/libs/OpenSSL/include/crypto/rsa.h b/libs/OpenSSL/include/crypto/rsa.h index 33f7b507..a8a8d298 100644 --- a/libs/OpenSSL/include/crypto/rsa.h +++ b/libs/OpenSSL/include/crypto/rsa.h @@ -19,31 +19,39 @@ typedef struct rsa_pss_params_30_st { + int hash_algorithm_nid; + struct + { + int algorithm_nid; /* Currently always NID_mgf1 */ int hash_algorithm_nid; - struct - { - int algorithm_nid; /* Currently always NID_mgf1 */ - int hash_algorithm_nid; - } mask_gen; - int salt_len; - int trailer_field; + } mask_gen; + int salt_len; + int trailer_field; } RSA_PSS_PARAMS_30; RSA_PSS_PARAMS_30 *ossl_rsa_get0_pss_params_30(RSA *r); int ossl_rsa_pss_params_30_set_defaults(RSA_PSS_PARAMS_30 *rsa_pss_params); -int ossl_rsa_pss_params_30_copy(RSA_PSS_PARAMS_30 *to, const RSA_PSS_PARAMS_30 *from); -int ossl_rsa_pss_params_30_is_unrestricted(const RSA_PSS_PARAMS_30 *rsa_pss_params); -int ossl_rsa_pss_params_30_set_hashalg(RSA_PSS_PARAMS_30 *rsa_pss_params, int hashalg_nid); -int ossl_rsa_pss_params_30_set_maskgenalg(RSA_PSS_PARAMS_30 *rsa_pss_params, int maskgenalg_nid); +int ossl_rsa_pss_params_30_copy(RSA_PSS_PARAMS_30 *to, + const RSA_PSS_PARAMS_30 *from); +int ossl_rsa_pss_params_30_is_unrestricted( + const RSA_PSS_PARAMS_30 *rsa_pss_params); +int ossl_rsa_pss_params_30_set_hashalg(RSA_PSS_PARAMS_30 *rsa_pss_params, + int hashalg_nid); +int ossl_rsa_pss_params_30_set_maskgenalg(RSA_PSS_PARAMS_30 *rsa_pss_params, + int maskgenalg_nid); int ossl_rsa_pss_params_30_set_maskgenhashalg(RSA_PSS_PARAMS_30 *rsa_pss_params, int maskgenhashalg_nid); -int ossl_rsa_pss_params_30_set_saltlen(RSA_PSS_PARAMS_30 *rsa_pss_params, int saltlen); -int ossl_rsa_pss_params_30_set_trailerfield(RSA_PSS_PARAMS_30 *rsa_pss_params, int trailerfield); +int ossl_rsa_pss_params_30_set_saltlen(RSA_PSS_PARAMS_30 *rsa_pss_params, + int saltlen); +int ossl_rsa_pss_params_30_set_trailerfield(RSA_PSS_PARAMS_30 *rsa_pss_params, + int trailerfield); int ossl_rsa_pss_params_30_hashalg(const RSA_PSS_PARAMS_30 *rsa_pss_params); int ossl_rsa_pss_params_30_maskgenalg(const RSA_PSS_PARAMS_30 *rsa_pss_params); -int ossl_rsa_pss_params_30_maskgenhashalg(const RSA_PSS_PARAMS_30 *rsa_pss_params); +int ossl_rsa_pss_params_30_maskgenhashalg( + const RSA_PSS_PARAMS_30 *rsa_pss_params); int ossl_rsa_pss_params_30_saltlen(const RSA_PSS_PARAMS_30 *rsa_pss_params); -int ossl_rsa_pss_params_30_trailerfield(const RSA_PSS_PARAMS_30 *rsa_pss_params); +int ossl_rsa_pss_params_30_trailerfield( + const RSA_PSS_PARAMS_30 *rsa_pss_params); const char *ossl_rsa_mgf_nid2name(int mgf); int ossl_rsa_oaeppss_md2nid(const EVP_MD *md); @@ -53,44 +61,56 @@ RSA *ossl_rsa_new_with_ctx(OSSL_LIB_CTX *libctx); OSSL_LIB_CTX *ossl_rsa_get0_libctx(RSA *r); void ossl_rsa_set0_libctx(RSA *r, OSSL_LIB_CTX *libctx); -int ossl_rsa_set0_all_params(RSA *r, const STACK_OF(BIGNUM) * primes, const STACK_OF(BIGNUM) * exps, +int ossl_rsa_set0_all_params(RSA *r, const STACK_OF(BIGNUM) * primes, + const STACK_OF(BIGNUM) * exps, const STACK_OF(BIGNUM) * coeffs); -int ossl_rsa_get0_all_params(RSA *r, STACK_OF(BIGNUM_const) * primes, STACK_OF(BIGNUM_const) * exps, +int ossl_rsa_get0_all_params(RSA *r, STACK_OF(BIGNUM_const) * primes, + STACK_OF(BIGNUM_const) * exps, STACK_OF(BIGNUM_const) * coeffs); int ossl_rsa_is_foreign(const RSA *rsa); RSA *ossl_rsa_dup(const RSA *rsa, int selection); -int ossl_rsa_todata(RSA *rsa, OSSL_PARAM_BLD *bld, OSSL_PARAM params[], int include_private); +int ossl_rsa_todata(RSA *rsa, OSSL_PARAM_BLD *bld, OSSL_PARAM params[], + int include_private); int ossl_rsa_fromdata(RSA *rsa, const OSSL_PARAM params[], int include_private); -int ossl_rsa_pss_params_30_todata(const RSA_PSS_PARAMS_30 *pss, OSSL_PARAM_BLD *bld, - OSSL_PARAM params[]); -int ossl_rsa_pss_params_30_fromdata(RSA_PSS_PARAMS_30 *pss_params, int *defaults_set, - const OSSL_PARAM params[], OSSL_LIB_CTX *libctx); +int ossl_rsa_pss_params_30_todata(const RSA_PSS_PARAMS_30 *pss, + OSSL_PARAM_BLD *bld, OSSL_PARAM params[]); +int ossl_rsa_pss_params_30_fromdata(RSA_PSS_PARAMS_30 *pss_params, + int *defaults_set, + const OSSL_PARAM params[], + OSSL_LIB_CTX *libctx); int ossl_rsa_set0_pss_params(RSA *r, RSA_PSS_PARAMS *pss); -int ossl_rsa_pss_get_param_unverified(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd, - const EVP_MD **pmgf1md, int *psaltlen, int *ptrailerField); +int ossl_rsa_pss_get_param_unverified(const RSA_PSS_PARAMS *pss, + const EVP_MD **pmd, + const EVP_MD **pmgf1md, int *psaltlen, + int *ptrailerField); RSA_PSS_PARAMS *ossl_rsa_pss_decode(const X509_ALGOR *alg); int ossl_rsa_param_decode(RSA *rsa, const X509_ALGOR *alg); -RSA *ossl_rsa_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, - const char *propq); +RSA *ossl_rsa_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *libctx, const char *propq); -int ossl_rsa_padding_check_PKCS1_type_2(OSSL_LIB_CTX *ctx, unsigned char *to, int tlen, - const unsigned char *from, int flen, int num, - unsigned char *kdk); -int ossl_rsa_padding_check_PKCS1_type_2_TLS(OSSL_LIB_CTX *ctx, unsigned char *to, size_t tlen, - const unsigned char *from, size_t flen, - int client_version, int alt_version); -int ossl_rsa_padding_add_PKCS1_OAEP_mgf1_ex(OSSL_LIB_CTX *libctx, unsigned char *to, int tlen, +int ossl_rsa_padding_check_PKCS1_type_2(OSSL_LIB_CTX *ctx, unsigned char *to, + int tlen, const unsigned char *from, + int flen, int num, unsigned char *kdk); +int ossl_rsa_padding_check_PKCS1_type_2_TLS(OSSL_LIB_CTX *ctx, + unsigned char *to, size_t tlen, + const unsigned char *from, + size_t flen, int client_version, + int alt_version); +int ossl_rsa_padding_add_PKCS1_OAEP_mgf1_ex(OSSL_LIB_CTX *libctx, + unsigned char *to, int tlen, const unsigned char *from, int flen, - const unsigned char *param, int plen, const EVP_MD *md, + const unsigned char *param, + int plen, const EVP_MD *md, const EVP_MD *mgf1md); int ossl_rsa_validate_public(const RSA *key); int ossl_rsa_validate_private(const RSA *key); int ossl_rsa_validate_pairwise(const RSA *key); -int ossl_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, unsigned char *rm, - size_t *prm_len, const unsigned char *sigbuf, size_t siglen, RSA *rsa); +int ossl_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, + unsigned char *rm, size_t *prm_len, + const unsigned char *sigbuf, size_t siglen, RSA *rsa); const unsigned char *ossl_rsa_digestinfo_encoding(int md_nid, size_t *len); @@ -99,8 +119,8 @@ extern const char *ossl_rsa_mp_exp_names[]; extern const char *ossl_rsa_mp_coeff_names[]; ASN1_STRING *ossl_rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkctx); -int ossl_rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx, const X509_ALGOR *sigalg, - EVP_PKEY *pkey); +int ossl_rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx, + const X509_ALGOR *sigalg, EVP_PKEY *pkey); #if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS) int ossl_rsa_acvp_test_gen_params_new(OSSL_PARAM **dst, const OSSL_PARAM src[]); @@ -111,7 +131,7 @@ int ossl_rsa_acvp_test_get_params(RSA *r, OSSL_PARAM params[]); typedef struct rsa_acvp_test_st RSA_ACVP_TEST; void ossl_rsa_acvp_test_free(RSA_ACVP_TEST *t); #else -# define RSA_ACVP_TEST void +# define RSA_ACVP_TEST void #endif RSA *evp_pkey_get1_RSA_PSS(EVP_PKEY *pkey); diff --git a/libs/OpenSSL/include/crypto/siphash.h b/libs/OpenSSL/include/crypto/siphash.h index 822f1a23..a5ab993e 100644 --- a/libs/OpenSSL/include/crypto/siphash.h +++ b/libs/OpenSSL/include/crypto/siphash.h @@ -23,7 +23,8 @@ typedef struct siphash_st SIPHASH; size_t SipHash_ctx_size(void); size_t SipHash_hash_size(SIPHASH *ctx); int SipHash_set_hash_size(SIPHASH *ctx, size_t hash_size); -int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int crounds, int drounds); +int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int crounds, + int drounds); void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen); int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen); @@ -31,16 +32,16 @@ int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen); struct siphash_st { - uint64_t total_inlen; - uint64_t v0; - uint64_t v1; - uint64_t v2; - uint64_t v3; - unsigned int len; - unsigned int hash_size; - unsigned int crounds; - unsigned int drounds; - unsigned char leavings[SIPHASH_BLOCK_SIZE]; + uint64_t total_inlen; + uint64_t v0; + uint64_t v1; + uint64_t v2; + uint64_t v3; + unsigned int len; + unsigned int hash_size; + unsigned int crounds; + unsigned int drounds; + unsigned char leavings[SIPHASH_BLOCK_SIZE]; }; /* default: SipHash-2-4 */ diff --git a/libs/OpenSSL/include/crypto/siv.h b/libs/OpenSSL/include/crypto/siv.h index ec2188be..575eb388 100644 --- a/libs/OpenSSL/include/crypto/siv.h +++ b/libs/OpenSSL/include/crypto/siv.h @@ -11,18 +11,21 @@ typedef struct siv128_context SIV128_CONTEXT; -SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen, EVP_CIPHER *cbc, - EVP_CIPHER *ctr, OSSL_LIB_CTX *libctx, const char *propq); -int ossl_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, const EVP_CIPHER *cbc, - const EVP_CIPHER *ctr, OSSL_LIB_CTX *libctx, const char *propq); +SIV128_CONTEXT *ossl_siv128_new(const unsigned char *key, int klen, + EVP_CIPHER *cbc, EVP_CIPHER *ctr, + OSSL_LIB_CTX *libctx, const char *propq); +int ossl_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, + const EVP_CIPHER *cbc, const EVP_CIPHER *ctr, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src); int ossl_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad, size_t len); -int ossl_siv128_encrypt(SIV128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len); -int ossl_siv128_decrypt(SIV128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len); +int ossl_siv128_encrypt(SIV128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int ossl_siv128_decrypt(SIV128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); int ossl_siv128_finish(SIV128_CONTEXT *ctx); -int ossl_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag, size_t len); +int ossl_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag, + size_t len); int ossl_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len); int ossl_siv128_cleanup(SIV128_CONTEXT *ctx); int ossl_siv128_speed(SIV128_CONTEXT *ctx, int arg); diff --git a/libs/OpenSSL/include/crypto/sm2.h b/libs/OpenSSL/include/crypto/sm2.h index 5b363157..abbe87ef 100644 --- a/libs/OpenSSL/include/crypto/sm2.h +++ b/libs/OpenSSL/include/crypto/sm2.h @@ -17,52 +17,61 @@ #if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODULE) -# include -# include "crypto/types.h" +# include +# include "crypto/types.h" int ossl_sm2_key_private_check(const EC_KEY *eckey); /* The default user id as specified in GM/T 0009-2012 */ -# define SM2_DEFAULT_USERID "1234567812345678" +# define SM2_DEFAULT_USERID "1234567812345678" -int ossl_sm2_compute_z_digest(uint8_t *out, const EVP_MD *digest, const uint8_t *id, - const size_t id_len, const EC_KEY *key); +int ossl_sm2_compute_z_digest(uint8_t *out, const EVP_MD *digest, + const uint8_t *id, const size_t id_len, + const EC_KEY *key); /* * SM2 signature operation. Computes Z and then signs H(Z || msg) using SM2 */ -ECDSA_SIG *ossl_sm2_do_sign(const EC_KEY *key, const EVP_MD *digest, const uint8_t *id, - const size_t id_len, const uint8_t *msg, size_t msg_len); +ECDSA_SIG *ossl_sm2_do_sign(const EC_KEY *key, const EVP_MD *digest, + const uint8_t *id, const size_t id_len, + const uint8_t *msg, size_t msg_len); -int ossl_sm2_do_verify(const EC_KEY *key, const EVP_MD *digest, const ECDSA_SIG *signature, - const uint8_t *id, const size_t id_len, const uint8_t *msg, size_t msg_len); +int ossl_sm2_do_verify(const EC_KEY *key, const EVP_MD *digest, + const ECDSA_SIG *signature, const uint8_t *id, + const size_t id_len, const uint8_t *msg, size_t msg_len); /* * SM2 signature generation. */ -int ossl_sm2_internal_sign(const unsigned char *dgst, int dgstlen, unsigned char *sig, - unsigned int *siglen, EC_KEY *eckey); +int ossl_sm2_internal_sign(const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, + EC_KEY *eckey); /* * SM2 signature verification. */ -int ossl_sm2_internal_verify(const unsigned char *dgst, int dgstlen, const unsigned char *sig, - int siglen, EC_KEY *eckey); +int ossl_sm2_internal_verify(const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int siglen, + EC_KEY *eckey); /* * SM2 encryption */ -int ossl_sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *ct_size); +int ossl_sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, + size_t msg_len, size_t *ct_size); -int ossl_sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size); +int ossl_sm2_plaintext_size(const unsigned char *ct, size_t ct_size, + size_t *pt_size); -int ossl_sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, const uint8_t *msg, size_t msg_len, +int ossl_sm2_encrypt(const EC_KEY *key, const EVP_MD *digest, + const uint8_t *msg, size_t msg_len, uint8_t *ciphertext_buf, size_t *ciphertext_len); -int ossl_sm2_decrypt(const EC_KEY *key, const EVP_MD *digest, const uint8_t *ciphertext, - size_t ciphertext_len, uint8_t *ptext_buf, size_t *ptext_len); +int ossl_sm2_decrypt(const EC_KEY *key, const EVP_MD *digest, + const uint8_t *ciphertext, size_t ciphertext_len, + uint8_t *ptext_buf, size_t *ptext_len); -const unsigned char *ossl_sm2_algorithmidentifier_encoding(int md_nid, size_t *len); +const unsigned char *ossl_sm2_algorithmidentifier_encoding(int md_nid, + size_t *len); #endif /* OPENSSL_NO_SM2 */ #endif diff --git a/libs/OpenSSL/include/crypto/sm2err.h b/libs/OpenSSL/include/crypto/sm2err.h index 4a8ceb99..8644a344 100644 --- a/libs/OpenSSL/include/crypto/sm2err.h +++ b/libs/OpenSSL/include/crypto/sm2err.h @@ -26,20 +26,20 @@ int ossl_err_load_SM2_strings(void); /* * SM2 reason codes. */ -# define SM2_R_ASN1_ERROR 100 -# define SM2_R_BAD_SIGNATURE 101 -# define SM2_R_BUFFER_TOO_SMALL 107 -# define SM2_R_DIST_ID_TOO_LARGE 110 -# define SM2_R_ID_NOT_SET 112 -# define SM2_R_ID_TOO_LARGE 111 -# define SM2_R_INVALID_CURVE 108 -# define SM2_R_INVALID_DIGEST 102 -# define SM2_R_INVALID_DIGEST_TYPE 103 -# define SM2_R_INVALID_ENCODING 104 -# define SM2_R_INVALID_FIELD 105 -# define SM2_R_INVALID_PRIVATE_KEY 113 -# define SM2_R_NO_PARAMETERS_SET 109 -# define SM2_R_USER_ID_TOO_LARGE 106 +# define SM2_R_ASN1_ERROR 100 +# define SM2_R_BAD_SIGNATURE 101 +# define SM2_R_BUFFER_TOO_SMALL 107 +# define SM2_R_DIST_ID_TOO_LARGE 110 +# define SM2_R_ID_NOT_SET 112 +# define SM2_R_ID_TOO_LARGE 111 +# define SM2_R_INVALID_CURVE 108 +# define SM2_R_INVALID_DIGEST 102 +# define SM2_R_INVALID_DIGEST_TYPE 103 +# define SM2_R_INVALID_ENCODING 104 +# define SM2_R_INVALID_FIELD 105 +# define SM2_R_INVALID_PRIVATE_KEY 113 +# define SM2_R_NO_PARAMETERS_SET 109 +# define SM2_R_USER_ID_TOO_LARGE 106 #endif diff --git a/libs/OpenSSL/include/crypto/sm4.h b/libs/OpenSSL/include/crypto/sm4.h index 971e0a30..ab3f3667 100644 --- a/libs/OpenSSL/include/crypto/sm4.h +++ b/libs/OpenSSL/include/crypto/sm4.h @@ -16,7 +16,7 @@ #include #ifdef OPENSSL_NO_SM4 -# error SM4 is disabled. +# error SM4 is disabled. #endif #define SM4_ENCRYPT 1 @@ -27,7 +27,7 @@ typedef struct SM4_KEY_st { - uint32_t rk[SM4_KEY_SCHEDULE]; + uint32_t rk[SM4_KEY_SCHEDULE]; } SM4_KEY; int ossl_sm4_set_key(const uint8_t *key, SM4_KEY *ks); diff --git a/libs/OpenSSL/include/crypto/sm4_platform.h b/libs/OpenSSL/include/crypto/sm4_platform.h index 27d43d36..a19ae612 100644 --- a/libs/OpenSSL/include/crypto/sm4_platform.h +++ b/libs/OpenSSL/include/crypto/sm4_platform.h @@ -12,56 +12,67 @@ #pragma once #if defined(OPENSSL_CPUID_OBJ) -# if (defined(__arm__) || defined(__arm) || defined(__aarch64__)) -# include "arm_arch.h" -# if __ARM_MAX_ARCH__ >= 8 +# if (defined(__arm__) || defined(__arm) || defined(__aarch64__)) +# include "arm_arch.h" +# if __ARM_MAX_ARCH__ >= 8 extern unsigned int OPENSSL_arm_midr; static inline int vpsm4_capable(void) { - return (OPENSSL_armcap_P & ARMV8_CPUID) - && (MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_V1) - || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, ARM_CPU_PART_N1) - || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, HISI_CPU_IMP, HISI_CPU_PART_KP920)); + return (OPENSSL_armcap_P & ARMV8_CPUID) + && (MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, + ARM_CPU_PART_V1) + || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, ARM_CPU_IMP_ARM, + ARM_CPU_PART_N1) + || MIDR_IS_CPU_MODEL(OPENSSL_arm_midr, HISI_CPU_IMP, + HISI_CPU_PART_KP920)); } -# if defined(VPSM4_ASM) -# define VPSM4_CAPABLE vpsm4_capable() -# endif -# define HWSM4_CAPABLE (OPENSSL_armcap_P & ARMV8_SM4) -# define HWSM4_set_encrypt_key sm4_v8_set_encrypt_key -# define HWSM4_set_decrypt_key sm4_v8_set_decrypt_key -# define HWSM4_encrypt sm4_v8_encrypt -# define HWSM4_decrypt sm4_v8_decrypt -# define HWSM4_cbc_encrypt sm4_v8_cbc_encrypt -# define HWSM4_ecb_encrypt sm4_v8_ecb_encrypt -# define HWSM4_ctr32_encrypt_blocks sm4_v8_ctr32_encrypt_blocks -# endif +# if defined(VPSM4_ASM) +# define VPSM4_CAPABLE vpsm4_capable() +# endif +# define HWSM4_CAPABLE (OPENSSL_armcap_P & ARMV8_SM4) +# define HWSM4_set_encrypt_key sm4_v8_set_encrypt_key +# define HWSM4_set_decrypt_key sm4_v8_set_decrypt_key +# define HWSM4_encrypt sm4_v8_encrypt +# define HWSM4_decrypt sm4_v8_decrypt +# define HWSM4_cbc_encrypt sm4_v8_cbc_encrypt +# define HWSM4_ecb_encrypt sm4_v8_ecb_encrypt +# define HWSM4_ctr32_encrypt_blocks sm4_v8_ctr32_encrypt_blocks # endif +# endif #endif /* OPENSSL_CPUID_OBJ */ #if defined(HWSM4_CAPABLE) int HWSM4_set_encrypt_key(const unsigned char *userKey, SM4_KEY *key); int HWSM4_set_decrypt_key(const unsigned char *userKey, SM4_KEY *key); -void HWSM4_encrypt(const unsigned char *in, unsigned char *out, const SM4_KEY *key); -void HWSM4_decrypt(const unsigned char *in, unsigned char *out, const SM4_KEY *key); -void HWSM4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const SM4_KEY *key, unsigned char *ivec, const int enc); -void HWSM4_ecb_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const SM4_KEY *key, const int enc); -void HWSM4_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t len, - const void *key, const unsigned char ivec[16]); +void HWSM4_encrypt(const unsigned char *in, unsigned char *out, + const SM4_KEY *key); +void HWSM4_decrypt(const unsigned char *in, unsigned char *out, + const SM4_KEY *key); +void HWSM4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const SM4_KEY *key, unsigned char *ivec, + const int enc); +void HWSM4_ecb_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const SM4_KEY *key, const int enc); +void HWSM4_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + const unsigned char ivec[16]); #endif /* HWSM4_CAPABLE */ #ifdef VPSM4_CAPABLE int vpsm4_set_encrypt_key(const unsigned char *userKey, SM4_KEY *key); int vpsm4_set_decrypt_key(const unsigned char *userKey, SM4_KEY *key); -void vpsm4_encrypt(const unsigned char *in, unsigned char *out, const SM4_KEY *key); -void vpsm4_decrypt(const unsigned char *in, unsigned char *out, const SM4_KEY *key); -void vpsm4_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const SM4_KEY *key, unsigned char *ivec, const int enc); -void vpsm4_ecb_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const SM4_KEY *key, const int enc); -void vpsm4_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, size_t len, - const void *key, const unsigned char ivec[16]); +void vpsm4_encrypt(const unsigned char *in, unsigned char *out, + const SM4_KEY *key); +void vpsm4_decrypt(const unsigned char *in, unsigned char *out, + const SM4_KEY *key); +void vpsm4_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const SM4_KEY *key, unsigned char *ivec, + const int enc); +void vpsm4_ecb_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const SM4_KEY *key, const int enc); +void vpsm4_ctr32_encrypt_blocks(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + const unsigned char ivec[16]); #endif /* VPSM4_CAPABLE */ #endif /* OSSL_SM4_PLATFORM_H */ diff --git a/libs/OpenSSL/include/crypto/sparc_arch.h b/libs/OpenSSL/include/crypto/sparc_arch.h index b1119972..be9b9df3 100644 --- a/libs/OpenSSL/include/crypto/sparc_arch.h +++ b/libs/OpenSSL/include/crypto/sparc_arch.h @@ -19,97 +19,97 @@ #define SPARCV9_VIS3 (1 << 6) #define SPARCV9_RANDOM (1 << 7) #define SPARCV9_64BIT_STACK (1 << 8) -#define SPARCV9_FJAESX (1 << 9) /* Fujitsu SPARC64 X AES */ -#define SPARCV9_FJDESX (1 << 10) /* Fujitsu SPARC64 X DES, reserved */ +#define SPARCV9_FJAESX (1 << 9) /* Fujitsu SPARC64 X AES */ +#define SPARCV9_FJDESX (1 << 10) /* Fujitsu SPARC64 X DES, reserved */ #define SPARCV9_FJHPCACE (1 << 11) /* Fujitsu HPC-ACE, reserved */ -#define SPARCV9_IMA (1 << 13) /* reserved */ -#define SPARCV9_VIS4 (1 << 14) /* reserved */ +#define SPARCV9_IMA (1 << 13) /* reserved */ +#define SPARCV9_VIS4 (1 << 14) /* reserved */ /* * OPENSSL_sparcv9cap_P[1] is copy of Compatibility Feature Register, * %asr26, SPARC-T4 and later. There is no SPARCV9_CFR bit in * OPENSSL_sparcv9cap_P[0], as %cfr copy is sufficient... */ -#define CFR_AES 0x00000001 /* Supports AES opcodes */ -#define CFR_DES 0x00000002 /* Supports DES opcodes */ -#define CFR_KASUMI 0x00000004 /* Supports KASUMI opcodes */ +#define CFR_AES 0x00000001 /* Supports AES opcodes */ +#define CFR_DES 0x00000002 /* Supports DES opcodes */ +#define CFR_KASUMI 0x00000004 /* Supports KASUMI opcodes */ #define CFR_CAMELLIA 0x00000008 /* Supports CAMELLIA opcodes */ -#define CFR_MD5 0x00000010 /* Supports MD5 opcodes */ -#define CFR_SHA1 0x00000020 /* Supports SHA1 opcodes */ -#define CFR_SHA256 0x00000040 /* Supports SHA256 opcodes */ -#define CFR_SHA512 0x00000080 /* Supports SHA512 opcodes */ -#define CFR_MPMUL 0x00000100 /* Supports MPMUL opcodes */ -#define CFR_MONTMUL 0x00000200 /* Supports MONTMUL opcodes */ -#define CFR_MONTSQR 0x00000400 /* Supports MONTSQR opcodes */ -#define CFR_CRC32C 0x00000800 /* Supports CRC32C opcodes */ -#define CFR_XMPMUL 0x00001000 /* Supports XMPMUL opcodes */ +#define CFR_MD5 0x00000010 /* Supports MD5 opcodes */ +#define CFR_SHA1 0x00000020 /* Supports SHA1 opcodes */ +#define CFR_SHA256 0x00000040 /* Supports SHA256 opcodes */ +#define CFR_SHA512 0x00000080 /* Supports SHA512 opcodes */ +#define CFR_MPMUL 0x00000100 /* Supports MPMUL opcodes */ +#define CFR_MONTMUL 0x00000200 /* Supports MONTMUL opcodes */ +#define CFR_MONTSQR 0x00000400 /* Supports MONTSQR opcodes */ +#define CFR_CRC32C 0x00000800 /* Supports CRC32C opcodes */ +#define CFR_XMPMUL 0x00001000 /* Supports XMPMUL opcodes */ #define CFR_XMONTMUL 0x00002000 /* Supports XMONTMUL opcodes */ #define CFR_XMONTSQR 0x00004000 /* Supports XMONTSQR opcodes */ #if defined(OPENSSL_PIC) && !defined(__PIC__) -# define __PIC__ +# define __PIC__ #endif #if defined(__SUNPRO_C) && defined(__sparcv9) && !defined(__arch64__) -# define __arch64__ +# define __arch64__ #endif -#define SPARC_PIC_THUNK(reg) \ - .align 32; \ - .Lpic_thunk : jmp % o7 + 8; \ - add % o7, reg, reg; +#define SPARC_PIC_THUNK(reg) \ + .align 32; \ + .Lpic_thunk : jmp % o7 + 8; \ + add % o7, reg, reg; -#define SPARC_PIC_THUNK_CALL(reg) \ - sethi % hi(_GLOBAL_OFFSET_TABLE_ - 4), reg; \ - call.Lpic_thunk; \ - or reg, % lo(_GLOBAL_OFFSET_TABLE_ + 4), reg; +#define SPARC_PIC_THUNK_CALL(reg) \ + sethi % hi(_GLOBAL_OFFSET_TABLE_ - 4), reg; \ + call.Lpic_thunk; \ + or reg, % lo(_GLOBAL_OFFSET_TABLE_ + 4), reg; #if 1 -# define SPARC_SETUP_GOT_REG(reg) SPARC_PIC_THUNK_CALL(reg) +# define SPARC_SETUP_GOT_REG(reg) SPARC_PIC_THUNK_CALL(reg) #else -# define SPARC_SETUP_GOT_REG(reg) \ - sethi % hi(_GLOBAL_OFFSET_TABLE_ - 4), reg; \ - call.+ 8; \ - or reg, % lo(_GLOBAL_OFFSET_TABLE_ + 4), reg; \ - add % o7, reg, reg +# define SPARC_SETUP_GOT_REG(reg) \ + sethi % hi(_GLOBAL_OFFSET_TABLE_ - 4), reg; \ + call.+ 8; \ + or reg, % lo(_GLOBAL_OFFSET_TABLE_ + 4), reg; \ + add % o7, reg, reg #endif #if defined(__arch64__) -# define SPARC_LOAD_ADDRESS(SYM, reg) setx SYM, % o7, reg; -# define LDPTR ldx -# define SIZE_T_CC % xcc -# define STACK_FRAME 192 -# define STACK_BIAS 2047 -# define STACK_7thARG (STACK_BIAS + 176) +# define SPARC_LOAD_ADDRESS(SYM, reg) setx SYM, % o7, reg; +# define LDPTR ldx +# define SIZE_T_CC % xcc +# define STACK_FRAME 192 +# define STACK_BIAS 2047 +# define STACK_7thARG (STACK_BIAS + 176) #else -# define SPARC_LOAD_ADDRESS(SYM, reg) set SYM, reg; -# define LDPTR ld -# define SIZE_T_CC % icc -# define STACK_FRAME 112 -# define STACK_BIAS 0 -# define STACK_7thARG 92 -# define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) SPARC_LOAD_ADDRESS(SYM, reg) +# define SPARC_LOAD_ADDRESS(SYM, reg) set SYM, reg; +# define LDPTR ld +# define SIZE_T_CC % icc +# define STACK_FRAME 112 +# define STACK_BIAS 0 +# define STACK_7thARG 92 +# define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) SPARC_LOAD_ADDRESS(SYM, reg) #endif #ifdef __PIC__ -# undef SPARC_LOAD_ADDRESS -# undef SPARC_LOAD_ADDRESS_LEAF -# define SPARC_LOAD_ADDRESS(SYM, reg) \ - SPARC_SETUP_GOT_REG(reg); \ - sethi % hi(SYM), % o7; \ - or % o7, % lo(SYM), % o7; \ - LDPTR[reg + % o7], reg; +# undef SPARC_LOAD_ADDRESS +# undef SPARC_LOAD_ADDRESS_LEAF +# define SPARC_LOAD_ADDRESS(SYM, reg) \ + SPARC_SETUP_GOT_REG(reg); \ + sethi % hi(SYM), % o7; \ + or % o7, % lo(SYM), % o7; \ + LDPTR[reg + % o7], reg; #endif #ifndef SPARC_LOAD_ADDRESS_LEAF -# define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) \ - mov % o7, tmp; \ - SPARC_LOAD_ADDRESS(SYM, reg) \ - mov tmp, % o7; +# define SPARC_LOAD_ADDRESS_LEAF(SYM, reg, tmp) \ + mov % o7, tmp; \ + SPARC_LOAD_ADDRESS(SYM, reg) \ + mov tmp, % o7; #endif #ifndef __ASSEMBLER__ diff --git a/libs/OpenSSL/include/crypto/sparse_array.h b/libs/OpenSSL/include/crypto/sparse_array.h index 5fe61127..3b263c0c 100644 --- a/libs/OpenSSL/include/crypto/sparse_array.h +++ b/libs/OpenSSL/include/crypto/sparse_array.h @@ -20,48 +20,55 @@ extern "C" { #define SPARSE_ARRAY_OF(type) struct sparse_array_st_##type -#define DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, ctype) \ - SPARSE_ARRAY_OF(type); \ - static ossl_unused ossl_inline SPARSE_ARRAY_OF(type) * ossl_sa_##type##_new(void) \ - { \ - return (SPARSE_ARRAY_OF(type) *)ossl_sa_new(); \ - } \ - static ossl_unused ossl_inline void ossl_sa_##type##_free(SPARSE_ARRAY_OF(type) * sa) \ - { \ - ossl_sa_free((OPENSSL_SA *)sa); \ - } \ - static ossl_unused ossl_inline void ossl_sa_##type##_free_leaves(SPARSE_ARRAY_OF(type) * sa) \ - { \ - ossl_sa_free_leaves((OPENSSL_SA *)sa); \ - } \ - static ossl_unused ossl_inline size_t ossl_sa_##type##_num(const SPARSE_ARRAY_OF(type) * sa) \ - { \ - return ossl_sa_num((OPENSSL_SA *)sa); \ - } \ - static ossl_unused ossl_inline void ossl_sa_##type##_doall( \ - const SPARSE_ARRAY_OF(type) * sa, void (*leaf)(ossl_uintmax_t, type *)) \ - { \ - ossl_sa_doall((OPENSSL_SA *)sa, (void (*)(ossl_uintmax_t, void *))leaf); \ - } \ - static ossl_unused ossl_inline void ossl_sa_##type##_doall_arg( \ - const SPARSE_ARRAY_OF(type) * sa, void (*leaf)(ossl_uintmax_t, type *, void *), void *arg) \ - { \ - ossl_sa_doall_arg((OPENSSL_SA *)sa, (void (*)(ossl_uintmax_t, void *, void *))leaf, arg); \ - } \ - static ossl_unused ossl_inline ctype *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) * sa, \ - ossl_uintmax_t n) \ - { \ - return (type *)ossl_sa_get((OPENSSL_SA *)sa, n); \ - } \ - static ossl_unused ossl_inline int ossl_sa_##type##_set(SPARSE_ARRAY_OF(type) * sa, \ - ossl_uintmax_t n, ctype * val) \ - { \ - return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val); \ - } \ - SPARSE_ARRAY_OF(type) +#define DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, ctype) \ + SPARSE_ARRAY_OF(type); \ + static ossl_unused ossl_inline SPARSE_ARRAY_OF(type) \ + * ossl_sa_##type##_new(void) \ + { \ + return (SPARSE_ARRAY_OF(type) *)ossl_sa_new(); \ + } \ + static ossl_unused ossl_inline void ossl_sa_##type##_free( \ + SPARSE_ARRAY_OF(type) * sa) \ + { \ + ossl_sa_free((OPENSSL_SA *)sa); \ + } \ + static ossl_unused ossl_inline void ossl_sa_##type##_free_leaves( \ + SPARSE_ARRAY_OF(type) * sa) \ + { \ + ossl_sa_free_leaves((OPENSSL_SA *)sa); \ + } \ + static ossl_unused ossl_inline size_t ossl_sa_##type##_num( \ + const SPARSE_ARRAY_OF(type) * sa) \ + { \ + return ossl_sa_num((OPENSSL_SA *)sa); \ + } \ + static ossl_unused ossl_inline void ossl_sa_##type##_doall( \ + const SPARSE_ARRAY_OF(type) * sa, void (*leaf)(ossl_uintmax_t, type *)) \ + { \ + ossl_sa_doall((OPENSSL_SA *)sa, (void (*)(ossl_uintmax_t, void *))leaf); \ + } \ + static ossl_unused ossl_inline void ossl_sa_##type##_doall_arg( \ + const SPARSE_ARRAY_OF(type) * sa, \ + void (*leaf)(ossl_uintmax_t, type *, void *), void *arg) \ + { \ + ossl_sa_doall_arg((OPENSSL_SA *)sa, \ + (void (*)(ossl_uintmax_t, void *, void *))leaf, arg); \ + } \ + static ossl_unused ossl_inline ctype *ossl_sa_##type##_get( \ + const SPARSE_ARRAY_OF(type) * sa, ossl_uintmax_t n) \ + { \ + return (type *)ossl_sa_get((OPENSSL_SA *)sa, n); \ + } \ + static ossl_unused ossl_inline int ossl_sa_##type##_set( \ + SPARSE_ARRAY_OF(type) * sa, ossl_uintmax_t n, ctype * val) \ + { \ + return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val); \ + } \ + SPARSE_ARRAY_OF(type) #define DEFINE_SPARSE_ARRAY_OF(type) DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, type) -#define DEFINE_SPARSE_ARRAY_OF_CONST(type) DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, const type) +#define DEFINE_SPARSE_ARRAY_OF_CONST(type) \ + DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, const type) typedef struct sparse_array_st OPENSSL_SA; OPENSSL_SA *ossl_sa_new(void); @@ -69,7 +76,8 @@ void ossl_sa_free(OPENSSL_SA *sa); void ossl_sa_free_leaves(OPENSSL_SA *sa); size_t ossl_sa_num(const OPENSSL_SA *sa); void ossl_sa_doall(const OPENSSL_SA *sa, void (*leaf)(ossl_uintmax_t, void *)); -void ossl_sa_doall_arg(const OPENSSL_SA *sa, void (*leaf)(ossl_uintmax_t, void *, void *), void *); +void ossl_sa_doall_arg(const OPENSSL_SA *sa, + void (*leaf)(ossl_uintmax_t, void *, void *), void *); void *ossl_sa_get(const OPENSSL_SA *sa, ossl_uintmax_t n); int ossl_sa_set(OPENSSL_SA *sa, ossl_uintmax_t n, void *val); diff --git a/libs/OpenSSL/include/crypto/types.h b/libs/OpenSSL/include/crypto/types.h index bc1cebad..17b5cb4b 100644 --- a/libs/OpenSSL/include/crypto/types.h +++ b/libs/OpenSSL/include/crypto/types.h @@ -16,10 +16,10 @@ #ifdef OPENSSL_NO_DEPRECATED_3_0 typedef struct rsa_st RSA; typedef struct rsa_meth_st RSA_METHOD; -# ifndef OPENSSL_NO_EC +# ifndef OPENSSL_NO_EC typedef struct ec_key_st EC_KEY; typedef struct ec_key_method_st EC_KEY_METHOD; -# endif +# endif #endif #ifndef OPENSSL_NO_EC diff --git a/libs/OpenSSL/include/crypto/x509.h b/libs/OpenSSL/include/crypto/x509.h index 17c30760..63fce033 100644 --- a/libs/OpenSSL/include/crypto/x509.h +++ b/libs/OpenSSL/include/crypto/x509.h @@ -30,124 +30,124 @@ */ struct X509_name_entry_st { - ASN1_OBJECT *object; /* AttributeType */ - ASN1_STRING *value; /* AttributeValue */ - int set; /* index of RDNSequence for this entry */ - int size; /* temp variable */ + ASN1_OBJECT *object; /* AttributeType */ + ASN1_STRING *value; /* AttributeValue */ + int set; /* index of RDNSequence for this entry */ + int size; /* temp variable */ }; /* Name from RFC 5280. */ struct X509_name_st { - STACK_OF(X509_NAME_ENTRY) * entries; /* DN components */ - int modified; /* true if 'bytes' needs to be built */ - BUF_MEM *bytes; /* cached encoding: cannot be NULL */ - /* canonical encoding used for rapid Name comparison */ - unsigned char *canon_enc; - int canon_enclen; + STACK_OF(X509_NAME_ENTRY) * entries; /* DN components */ + int modified; /* true if 'bytes' needs to be built */ + BUF_MEM *bytes; /* cached encoding: cannot be NULL */ + /* canonical encoding used for rapid Name comparison */ + unsigned char *canon_enc; + int canon_enclen; } /* X509_NAME */; /* Signature info structure */ struct x509_sig_info_st { - /* NID of message digest */ - int mdnid; - /* NID of public key algorithm */ - int pknid; - /* Security bits */ - int secbits; - /* Various flags */ - uint32_t flags; + /* NID of message digest */ + int mdnid; + /* NID of public key algorithm */ + int pknid; + /* Security bits */ + int secbits; + /* Various flags */ + uint32_t flags; }; /* PKCS#10 certificate request */ struct X509_req_info_st { - ASN1_ENCODING enc; /* cached encoding of signed part */ - ASN1_INTEGER *version; /* version, defaults to v1(0) so can be NULL */ - X509_NAME *subject; /* certificate request DN */ - X509_PUBKEY *pubkey; /* public key of request */ - /* - * Zero or more attributes. - * NB: although attributes is a mandatory field some broken - * encodings omit it so this may be NULL in that case. - */ - STACK_OF(X509_ATTRIBUTE) * attributes; + ASN1_ENCODING enc; /* cached encoding of signed part */ + ASN1_INTEGER *version; /* version, defaults to v1(0) so can be NULL */ + X509_NAME *subject; /* certificate request DN */ + X509_PUBKEY *pubkey; /* public key of request */ + /* + * Zero or more attributes. + * NB: although attributes is a mandatory field some broken + * encodings omit it so this may be NULL in that case. + */ + STACK_OF(X509_ATTRIBUTE) * attributes; }; struct X509_req_st { - X509_REQ_INFO req_info; /* signed certificate request data */ - X509_ALGOR sig_alg; /* signature algorithm */ - ASN1_BIT_STRING *signature; /* signature */ - CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; + X509_REQ_INFO req_info; /* signed certificate request data */ + X509_ALGOR sig_alg; /* signature algorithm */ + ASN1_BIT_STRING *signature; /* signature */ + CRYPTO_REF_COUNT references; + CRYPTO_RWLOCK *lock; - /* Set on live certificates for authentication purposes */ - ASN1_OCTET_STRING *distinguishing_id; - OSSL_LIB_CTX *libctx; - char *propq; + /* Set on live certificates for authentication purposes */ + ASN1_OCTET_STRING *distinguishing_id; + OSSL_LIB_CTX *libctx; + char *propq; }; struct X509_crl_info_st { - ASN1_INTEGER *version; /* version: defaults to v1(0) so may be NULL */ - X509_ALGOR sig_alg; /* signature algorithm */ - X509_NAME *issuer; /* CRL issuer name */ - ASN1_TIME *lastUpdate; /* lastUpdate field */ - ASN1_TIME *nextUpdate; /* nextUpdate field: optional */ - STACK_OF(X509_REVOKED) * revoked; /* revoked entries: optional */ - STACK_OF(X509_EXTENSION) * extensions; /* extensions: optional */ - ASN1_ENCODING enc; /* encoding of signed portion of CRL */ + ASN1_INTEGER *version; /* version: defaults to v1(0) so may be NULL */ + X509_ALGOR sig_alg; /* signature algorithm */ + X509_NAME *issuer; /* CRL issuer name */ + ASN1_TIME *lastUpdate; /* lastUpdate field */ + ASN1_TIME *nextUpdate; /* nextUpdate field: optional */ + STACK_OF(X509_REVOKED) * revoked; /* revoked entries: optional */ + STACK_OF(X509_EXTENSION) * extensions; /* extensions: optional */ + ASN1_ENCODING enc; /* encoding of signed portion of CRL */ }; struct X509_crl_st { - X509_CRL_INFO crl; /* signed CRL data */ - X509_ALGOR sig_alg; /* CRL signature algorithm */ - ASN1_BIT_STRING signature; /* CRL signature */ - CRYPTO_REF_COUNT references; - int flags; - /* - * Cached copies of decoded extension values, since extensions - * are optional any of these can be NULL. - */ - AUTHORITY_KEYID *akid; - ISSUING_DIST_POINT *idp; - /* Convenient breakdown of IDP */ - int idp_flags; - int idp_reasons; - /* CRL and base CRL numbers for delta processing */ - ASN1_INTEGER *crl_number; - ASN1_INTEGER *base_crl_number; - STACK_OF(GENERAL_NAMES) * issuers; - /* hash of CRL */ - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; - /* alternative method to handle this CRL */ - const X509_CRL_METHOD *meth; - void *meth_data; - CRYPTO_RWLOCK *lock; + X509_CRL_INFO crl; /* signed CRL data */ + X509_ALGOR sig_alg; /* CRL signature algorithm */ + ASN1_BIT_STRING signature; /* CRL signature */ + CRYPTO_REF_COUNT references; + int flags; + /* + * Cached copies of decoded extension values, since extensions + * are optional any of these can be NULL. + */ + AUTHORITY_KEYID *akid; + ISSUING_DIST_POINT *idp; + /* Convenient breakdown of IDP */ + int idp_flags; + int idp_reasons; + /* CRL and base CRL numbers for delta processing */ + ASN1_INTEGER *crl_number; + ASN1_INTEGER *base_crl_number; + STACK_OF(GENERAL_NAMES) * issuers; + /* hash of CRL */ + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; + /* alternative method to handle this CRL */ + const X509_CRL_METHOD *meth; + void *meth_data; + CRYPTO_RWLOCK *lock; - OSSL_LIB_CTX *libctx; - char *propq; + OSSL_LIB_CTX *libctx; + char *propq; }; struct x509_revoked_st { - ASN1_INTEGER serialNumber; /* revoked entry serial number */ - ASN1_TIME *revocationDate; /* revocation date */ - STACK_OF(X509_EXTENSION) * extensions; /* CRL entry extensions: optional */ - /* decoded value of CRLissuer extension: set if indirect CRL */ - STACK_OF(GENERAL_NAME) * issuer; - /* revocation reason: set to CRL_REASON_NONE if reason extension absent */ - int reason; - /* - * CRL entries are reordered for faster lookup of serial numbers. This - * field contains the original load sequence for this entry. - */ - int sequence; + ASN1_INTEGER serialNumber; /* revoked entry serial number */ + ASN1_TIME *revocationDate; /* revocation date */ + STACK_OF(X509_EXTENSION) * extensions; /* CRL entry extensions: optional */ + /* decoded value of CRLissuer extension: set if indirect CRL */ + STACK_OF(GENERAL_NAME) * issuer; + /* revocation reason: set to CRL_REASON_NONE if reason extension absent */ + int reason; + /* + * CRL entries are reordered for faster lookup of serial numbers. This + * field contains the original load sequence for this entry. + */ + int sequence; }; /* @@ -159,63 +159,63 @@ struct x509_revoked_st struct x509_cert_aux_st { - STACK_OF(ASN1_OBJECT) * trust; /* trusted uses */ - STACK_OF(ASN1_OBJECT) * reject; /* rejected uses */ - ASN1_UTF8STRING *alias; /* "friendly name" */ - ASN1_OCTET_STRING *keyid; /* key id of private key */ - STACK_OF(X509_ALGOR) * other; /* other unspecified info */ + STACK_OF(ASN1_OBJECT) * trust; /* trusted uses */ + STACK_OF(ASN1_OBJECT) * reject; /* rejected uses */ + ASN1_UTF8STRING *alias; /* "friendly name" */ + ASN1_OCTET_STRING *keyid; /* key id of private key */ + STACK_OF(X509_ALGOR) * other; /* other unspecified info */ }; struct x509_cinf_st { - ASN1_INTEGER *version; /* [ 0 ] default of v1 */ - ASN1_INTEGER serialNumber; - X509_ALGOR signature; - X509_NAME *issuer; - X509_VAL validity; - X509_NAME *subject; - X509_PUBKEY *key; - ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ - ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ - STACK_OF(X509_EXTENSION) * extensions; /* [ 3 ] optional in v3 */ - ASN1_ENCODING enc; + ASN1_INTEGER *version; /* [ 0 ] default of v1 */ + ASN1_INTEGER serialNumber; + X509_ALGOR signature; + X509_NAME *issuer; + X509_VAL validity; + X509_NAME *subject; + X509_PUBKEY *key; + ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ + ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ + STACK_OF(X509_EXTENSION) * extensions; /* [ 3 ] optional in v3 */ + ASN1_ENCODING enc; }; struct x509_st { - X509_CINF cert_info; - X509_ALGOR sig_alg; - ASN1_BIT_STRING signature; - X509_SIG_INFO siginf; - CRYPTO_REF_COUNT references; - CRYPTO_EX_DATA ex_data; - /* These contain copies of various extension values */ - long ex_pathlen; - long ex_pcpathlen; - uint32_t ex_flags; - uint32_t ex_kusage; - uint32_t ex_xkusage; - uint32_t ex_nscert; - ASN1_OCTET_STRING *skid; - AUTHORITY_KEYID *akid; - X509_POLICY_CACHE *policy_cache; - STACK_OF(DIST_POINT) * crldp; - STACK_OF(GENERAL_NAME) * altname; - NAME_CONSTRAINTS *nc; + X509_CINF cert_info; + X509_ALGOR sig_alg; + ASN1_BIT_STRING signature; + X509_SIG_INFO siginf; + CRYPTO_REF_COUNT references; + CRYPTO_EX_DATA ex_data; + /* These contain copies of various extension values */ + long ex_pathlen; + long ex_pcpathlen; + uint32_t ex_flags; + uint32_t ex_kusage; + uint32_t ex_xkusage; + uint32_t ex_nscert; + ASN1_OCTET_STRING *skid; + AUTHORITY_KEYID *akid; + X509_POLICY_CACHE *policy_cache; + STACK_OF(DIST_POINT) * crldp; + STACK_OF(GENERAL_NAME) * altname; + NAME_CONSTRAINTS *nc; #ifndef OPENSSL_NO_RFC3779 - STACK_OF(IPAddressFamily) * rfc3779_addr; - struct ASIdentifiers_st *rfc3779_asid; + STACK_OF(IPAddressFamily) * rfc3779_addr; + struct ASIdentifiers_st *rfc3779_asid; #endif - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; - X509_CERT_AUX *aux; - CRYPTO_RWLOCK *lock; - volatile int ex_cached; + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; + X509_CERT_AUX *aux; + CRYPTO_RWLOCK *lock; + volatile int ex_cached; - /* Set on live certificates for authentication purposes */ - ASN1_OCTET_STRING *distinguishing_id; + /* Set on live certificates for authentication purposes */ + ASN1_OCTET_STRING *distinguishing_id; - OSSL_LIB_CTX *libctx; - char *propq; + OSSL_LIB_CTX *libctx; + char *propq; } /* X509 */; /* @@ -225,101 +225,102 @@ struct x509_st */ struct x509_store_ctx_st { /* X509_STORE_CTX */ - X509_STORE *store; - /* The following are set by the caller */ - /* The cert to check */ - X509 *cert; - /* chain of X509s - untrusted - passed in */ - STACK_OF(X509) * untrusted; - /* set of CRLs passed in */ - STACK_OF(X509_CRL) * crls; - X509_VERIFY_PARAM *param; - /* Other info for use with get_issuer() */ - void *other_ctx; - /* Callbacks for various operations */ - /* called to verify a certificate */ - int (*verify)(X509_STORE_CTX *ctx); - /* error callback */ - int (*verify_cb)(int ok, X509_STORE_CTX *ctx); - /* get issuers cert from ctx */ - int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - /* check issued */ - int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); - /* Check revocation status of chain */ - int (*check_revocation)(X509_STORE_CTX *ctx); - /* retrieve CRL */ - int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); - /* Check CRL validity */ - int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); - /* Check certificate against CRL */ - int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); - /* Check policy status of the chain */ - int (*check_policy)(X509_STORE_CTX *ctx); - STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, const X509_NAME *nm); - /* cannot constify 'ctx' param due to lookup_certs_sk() in x509_vfy.c */ - STACK_OF(X509_CRL) * (*lookup_crls)(const X509_STORE_CTX *ctx, const X509_NAME *nm); - int (*cleanup)(X509_STORE_CTX *ctx); - /* The following is built up */ - /* if 0, rebuild chain */ - int valid; - /* number of untrusted certs */ - int num_untrusted; - /* chain of X509s - built up and trusted */ - STACK_OF(X509) * chain; - /* Valid policy tree */ - X509_POLICY_TREE *tree; - /* Require explicit policy value */ - int explicit_policy; - /* When something goes wrong, this is why */ - int error_depth; - int error; - X509 *current_cert; - /* cert currently being tested as valid issuer */ - X509 *current_issuer; - /* current CRL */ - X509_CRL *current_crl; - /* score of current CRL */ - int current_crl_score; - /* Reason mask */ - unsigned int current_reasons; - /* For CRL path validation: parent context */ - X509_STORE_CTX *parent; - CRYPTO_EX_DATA ex_data; - SSL_DANE *dane; - /* signed via bare TA public key, rather than CA certificate */ - int bare_ta_signed; + X509_STORE *store; + /* The following are set by the caller */ + /* The cert to check */ + X509 *cert; + /* chain of X509s - untrusted - passed in */ + STACK_OF(X509) * untrusted; + /* set of CRLs passed in */ + STACK_OF(X509_CRL) * crls; + X509_VERIFY_PARAM *param; + /* Other info for use with get_issuer() */ + void *other_ctx; + /* Callbacks for various operations */ + /* called to verify a certificate */ + int (*verify)(X509_STORE_CTX *ctx); + /* error callback */ + int (*verify_cb)(int ok, X509_STORE_CTX *ctx); + /* get issuers cert from ctx */ + int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + /* check issued */ + int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); + /* Check revocation status of chain */ + int (*check_revocation)(X509_STORE_CTX *ctx); + /* retrieve CRL */ + int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); + /* Check CRL validity */ + int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); + /* Check certificate against CRL */ + int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); + /* Check policy status of the chain */ + int (*check_policy)(X509_STORE_CTX *ctx); + STACK_OF(X509) * (*lookup_certs)(X509_STORE_CTX *ctx, const X509_NAME *nm); + /* cannot constify 'ctx' param due to lookup_certs_sk() in x509_vfy.c */ + STACK_OF(X509_CRL) + * (*lookup_crls)(const X509_STORE_CTX *ctx, const X509_NAME *nm); + int (*cleanup)(X509_STORE_CTX *ctx); + /* The following is built up */ + /* if 0, rebuild chain */ + int valid; + /* number of untrusted certs */ + int num_untrusted; + /* chain of X509s - built up and trusted */ + STACK_OF(X509) * chain; + /* Valid policy tree */ + X509_POLICY_TREE *tree; + /* Require explicit policy value */ + int explicit_policy; + /* When something goes wrong, this is why */ + int error_depth; + int error; + X509 *current_cert; + /* cert currently being tested as valid issuer */ + X509 *current_issuer; + /* current CRL */ + X509_CRL *current_crl; + /* score of current CRL */ + int current_crl_score; + /* Reason mask */ + unsigned int current_reasons; + /* For CRL path validation: parent context */ + X509_STORE_CTX *parent; + CRYPTO_EX_DATA ex_data; + SSL_DANE *dane; + /* signed via bare TA public key, rather than CA certificate */ + int bare_ta_signed; - OSSL_LIB_CTX *libctx; - char *propq; + OSSL_LIB_CTX *libctx; + char *propq; }; /* PKCS#8 private key info structure */ struct pkcs8_priv_key_info_st { - ASN1_INTEGER *version; - X509_ALGOR *pkeyalg; - ASN1_OCTET_STRING *pkey; - STACK_OF(X509_ATTRIBUTE) * attributes; + ASN1_INTEGER *version; + X509_ALGOR *pkeyalg; + ASN1_OCTET_STRING *pkey; + STACK_OF(X509_ATTRIBUTE) * attributes; }; struct X509_sig_st { - X509_ALGOR *algor; - ASN1_OCTET_STRING *digest; + X509_ALGOR *algor; + ASN1_OCTET_STRING *digest; }; struct x509_object_st { - /* one of the above types */ - X509_LOOKUP_TYPE type; - union - { - char *ptr; - X509 *x509; - X509_CRL *crl; - EVP_PKEY *pkey; - } data; + /* one of the above types */ + X509_LOOKUP_TYPE type; + union + { + char *ptr; + X509 *x509; + X509_CRL *crl; + EVP_PKEY *pkey; + } data; }; int ossl_a2i_ipadd(unsigned char *ipout, const char *ipasc); @@ -329,12 +330,16 @@ int ossl_x509v3_cache_extensions(X509 *x); int ossl_x509_init_sig_info(X509 *x); int ossl_x509_set0_libctx(X509 *x, OSSL_LIB_CTX *libctx, const char *propq); -int ossl_x509_crl_set0_libctx(X509_CRL *x, OSSL_LIB_CTX *libctx, const char *propq); -int ossl_x509_req_set0_libctx(X509_REQ *x, OSSL_LIB_CTX *libctx, const char *propq); -int ossl_asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *type, void *data, unsigned char *md, - unsigned int *len, OSSL_LIB_CTX *libctx, const char *propq); +int ossl_x509_crl_set0_libctx(X509_CRL *x, OSSL_LIB_CTX *libctx, + const char *propq); +int ossl_x509_req_set0_libctx(X509_REQ *x, OSSL_LIB_CTX *libctx, + const char *propq); +int ossl_asn1_item_digest_ex(const ASN1_ITEM *it, const EVP_MD *type, + void *data, unsigned char *md, unsigned int *len, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_x509_add_cert_new(STACK_OF(X509) * *sk, X509 *cert, int flags); -int ossl_x509_add_certs_new(STACK_OF(X509) * *p_sk, STACK_OF(X509) * certs, int flags); +int ossl_x509_add_certs_new(STACK_OF(X509) * *p_sk, STACK_OF(X509) * certs, + int flags); STACK_OF(X509_ATTRIBUTE) * ossl_x509at_dup(const STACK_OF(X509_ATTRIBUTE) * x); @@ -356,18 +361,23 @@ DH *ossl_d2i_DHx_PUBKEY(DH **a, const unsigned char **pp, long length); int ossl_i2d_DHx_PUBKEY(const DH *a, unsigned char **pp); #endif /* OPENSSL_NO_DH */ #ifndef OPENSSL_NO_EC -ECX_KEY *ossl_d2i_ED25519_PUBKEY(ECX_KEY **a, const unsigned char **pp, long length); +ECX_KEY *ossl_d2i_ED25519_PUBKEY(ECX_KEY **a, const unsigned char **pp, + long length); int ossl_i2d_ED25519_PUBKEY(const ECX_KEY *a, unsigned char **pp); -ECX_KEY *ossl_d2i_ED448_PUBKEY(ECX_KEY **a, const unsigned char **pp, long length); +ECX_KEY *ossl_d2i_ED448_PUBKEY(ECX_KEY **a, const unsigned char **pp, + long length); int ossl_i2d_ED448_PUBKEY(const ECX_KEY *a, unsigned char **pp); -ECX_KEY *ossl_d2i_X25519_PUBKEY(ECX_KEY **a, const unsigned char **pp, long length); +ECX_KEY *ossl_d2i_X25519_PUBKEY(ECX_KEY **a, const unsigned char **pp, + long length); int ossl_i2d_X25519_PUBKEY(const ECX_KEY *a, unsigned char **pp); -ECX_KEY *ossl_d2i_X448_PUBKEY(ECX_KEY **a, const unsigned char **pp, long length); +ECX_KEY *ossl_d2i_X448_PUBKEY(ECX_KEY **a, const unsigned char **pp, + long length); int ossl_i2d_X448_PUBKEY(const ECX_KEY *a, unsigned char **pp); #endif /* OPENSSL_NO_EC */ -EVP_PKEY *ossl_d2i_PUBKEY_legacy(EVP_PKEY **a, const unsigned char **pp, long length); +EVP_PKEY *ossl_d2i_PUBKEY_legacy(EVP_PKEY **a, const unsigned char **pp, + long length); int ossl_x509_check_private_key(const EVP_PKEY *k, const EVP_PKEY *pkey); -int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, size_t vallen, - STACK_OF(CONF_VALUE) * *extlist); +int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, + size_t vallen, STACK_OF(CONF_VALUE) * *extlist); #endif /* OSSL_CRYPTO_X509_H */ diff --git a/libs/OpenSSL/include/internal/bio.h b/libs/OpenSSL/include/internal/bio.h index c929b88e..e5e17119 100644 --- a/libs/OpenSSL/include/internal/bio.h +++ b/libs/OpenSSL/include/internal/bio.h @@ -16,20 +16,20 @@ struct bio_method_st { - int type; - char *name; - int (*bwrite)(BIO *, const char *, size_t, size_t *); - int (*bwrite_old)(BIO *, const char *, int); - int (*bread)(BIO *, char *, size_t, size_t *); - int (*bread_old)(BIO *, char *, int); - int (*bputs)(BIO *, const char *); - int (*bgets)(BIO *, char *, int); - long (*ctrl)(BIO *, int, long, void *); - int (*create)(BIO *); - int (*destroy)(BIO *); - long (*callback_ctrl)(BIO *, int, BIO_info_cb *); - int (*bsendmmsg)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); - int (*brecvmmsg)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); + int type; + char *name; + int (*bwrite)(BIO *, const char *, size_t, size_t *); + int (*bwrite_old)(BIO *, const char *, int); + int (*bread)(BIO *, char *, size_t, size_t *); + int (*bread_old)(BIO *, char *, int); + int (*bputs)(BIO *, const char *); + int (*bgets)(BIO *, char *, int); + long (*ctrl)(BIO *, int, long, void *); + int (*create)(BIO *); + int (*destroy)(BIO *); + long (*callback_ctrl)(BIO *, int, BIO_info_cb *); + int (*bsendmmsg)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); + int (*brecvmmsg)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); }; void bio_free_ex_data(BIO *bio); @@ -59,28 +59,36 @@ int bread_conv(BIO *bio, char *data, size_t datal, size_t *read); #define BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE 0x8000 /* KTLS related controls and flags */ -#define BIO_set_ktls_flag(b, is_tx) \ - BIO_set_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX) -#define BIO_should_ktls_flag(b, is_tx) \ - BIO_test_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX) -#define BIO_set_ktls_ctrl_msg_flag(b) BIO_set_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) -#define BIO_should_ktls_ctrl_msg_flag(b) BIO_test_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) -#define BIO_clear_ktls_ctrl_msg_flag(b) BIO_clear_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) -#define BIO_set_ktls_zerocopy_sendfile_flag(b) BIO_set_flags(b, BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE) +#define BIO_set_ktls_flag(b, is_tx) \ + BIO_set_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX) +#define BIO_should_ktls_flag(b, is_tx) \ + BIO_test_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX) +#define BIO_set_ktls_ctrl_msg_flag(b) \ + BIO_set_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) +#define BIO_should_ktls_ctrl_msg_flag(b) \ + BIO_test_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) +#define BIO_clear_ktls_ctrl_msg_flag(b) \ + BIO_clear_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) +#define BIO_set_ktls_zerocopy_sendfile_flag(b) \ + BIO_set_flags(b, BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE) -#define BIO_set_ktls(b, keyblob, is_tx) BIO_ctrl(b, BIO_CTRL_SET_KTLS, is_tx, keyblob) -#define BIO_set_ktls_ctrl_msg(b, record_type) \ - BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG, record_type, NULL) -#define BIO_clear_ktls_ctrl_msg(b) BIO_ctrl(b, BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG, 0, NULL) -#define BIO_set_ktls_tx_zerocopy_sendfile(b) \ - BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE, 0, NULL) +#define BIO_set_ktls(b, keyblob, is_tx) \ + BIO_ctrl(b, BIO_CTRL_SET_KTLS, is_tx, keyblob) +#define BIO_set_ktls_ctrl_msg(b, record_type) \ + BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG, record_type, NULL) +#define BIO_clear_ktls_ctrl_msg(b) \ + BIO_ctrl(b, BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG, 0, NULL) +#define BIO_set_ktls_tx_zerocopy_sendfile(b) \ + BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE, 0, NULL) /* Functions to allow the core to offer the CORE_BIO type to providers */ OSSL_CORE_BIO *ossl_core_bio_new_from_bio(BIO *bio); OSSL_CORE_BIO *ossl_core_bio_new_file(const char *filename, const char *mode); OSSL_CORE_BIO *ossl_core_bio_new_mem_buf(const void *buf, int len); -int ossl_core_bio_read_ex(OSSL_CORE_BIO *cb, void *data, size_t dlen, size_t *readbytes); -int ossl_core_bio_write_ex(OSSL_CORE_BIO *cb, const void *data, size_t dlen, size_t *written); +int ossl_core_bio_read_ex(OSSL_CORE_BIO *cb, void *data, size_t dlen, + size_t *readbytes); +int ossl_core_bio_write_ex(OSSL_CORE_BIO *cb, const void *data, size_t dlen, + size_t *written); int ossl_core_bio_gets(OSSL_CORE_BIO *cb, char *buf, int size); int ossl_core_bio_puts(OSSL_CORE_BIO *cb, const char *buf); long ossl_core_bio_ctrl(OSSL_CORE_BIO *cb, int cmd, long larg, void *parg); diff --git a/libs/OpenSSL/include/internal/bio_addr.h b/libs/OpenSSL/include/internal/bio_addr.h index 380c3a89..f6a3bebd 100644 --- a/libs/OpenSSL/include/internal/bio_addr.h +++ b/libs/OpenSSL/include/internal/bio_addr.h @@ -16,14 +16,14 @@ #ifndef OPENSSL_NO_SOCK union bio_addr_st { - struct sockaddr sa; -# if OPENSSL_USE_IPV6 - struct sockaddr_in6 s_in6; -# endif - struct sockaddr_in s_in; -# ifndef OPENSSL_NO_UNIX_SOCK - struct sockaddr_un s_un; -# endif + struct sockaddr sa; +# if OPENSSL_USE_IPV6 + struct sockaddr_in6 s_in6; +# endif + struct sockaddr_in s_in; +# ifndef OPENSSL_NO_UNIX_SOCK + struct sockaddr_un s_un; +# endif }; #endif diff --git a/libs/OpenSSL/include/internal/bio_tfo.h b/libs/OpenSSL/include/internal/bio_tfo.h index 247bb6e5..714306be 100644 --- a/libs/OpenSSL/include/internal/bio_tfo.h +++ b/libs/OpenSSL/include/internal/bio_tfo.h @@ -15,9 +15,9 @@ /* If a supported OS is added here, update test/bio_tfo_test.c */ #if defined(TCP_FASTOPEN) && !defined(OPENSSL_NO_TFO) -# if defined(OPENSSL_SYS_MACOSX) || defined(__FreeBSD__) -# include -# endif +# if defined(OPENSSL_SYS_MACOSX) || defined(__FreeBSD__) +# include +# endif /* * OSSL_TFO_SYSCTL is used to determine if TFO is supported by @@ -82,7 +82,7 @@ * client socket (macOS, FreeBSD, Linux pre-4.14) */ -# if defined(OPENSSL_SYS_WINDOWS) +# if defined(OPENSSL_SYS_WINDOWS) /* * NO WINDOWS SUPPORT * @@ -93,59 +93,59 @@ * * Still have to figure out client support */ -# undef TCP_FASTOPEN -# endif +# undef TCP_FASTOPEN +# endif /* NO VMS SUPPORT */ -# if defined(OPENSSL_SYS_VMS) -# undef TCP_FASTOPEN -# endif +# if defined(OPENSSL_SYS_VMS) +# undef TCP_FASTOPEN +# endif -# if defined(OPENSSL_SYS_MACOSX) -# define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE 1 -# define OSSL_TFO_CONNECTX 1 -# define OSSL_TFO_DO_NOT_CONNECT 1 -# define OSSL_TFO_CLIENT_FLAG 1 -# define OSSL_TFO_SERVER_FLAG 2 -# endif +# if defined(OPENSSL_SYS_MACOSX) +# define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen" +# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +# define OSSL_TFO_SERVER_SOCKOPT_VALUE 1 +# define OSSL_TFO_CONNECTX 1 +# define OSSL_TFO_DO_NOT_CONNECT 1 +# define OSSL_TFO_CLIENT_FLAG 1 +# define OSSL_TFO_SERVER_FLAG 2 +# endif -# if defined(__FreeBSD__) -# if defined(TCP_FASTOPEN_PSK_LEN) +# if defined(__FreeBSD__) +# if defined(TCP_FASTOPEN_PSK_LEN) /* As of 12.0 these are the SYSCTLs */ -# define OSSL_TFO_SYSCTL_SERVER "net.inet.tcp.fastopen.server_enable" -# define OSSL_TFO_SYSCTL_CLIENT "net.inet.tcp.fastopen.client_enable" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN -# define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_DO_NOT_CONNECT 1 -# define OSSL_TFO_SENDTO 0 +# define OSSL_TFO_SYSCTL_SERVER "net.inet.tcp.fastopen.server_enable" +# define OSSL_TFO_SYSCTL_CLIENT "net.inet.tcp.fastopen.client_enable" +# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN +# define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN +# define OSSL_TFO_DO_NOT_CONNECT 1 +# define OSSL_TFO_SENDTO 0 /* These are the same because the sysctl are client/server-specific */ -# define OSSL_TFO_CLIENT_FLAG 1 -# define OSSL_TFO_SERVER_FLAG 1 -# else +# define OSSL_TFO_CLIENT_FLAG 1 +# define OSSL_TFO_SERVER_FLAG 1 +# else /* 10.3 through 11.4 SYSCTL - ONLY SERVER SUPPORT */ -# define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen.enabled" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN -# define OSSL_TFO_SERVER_FLAG 1 -# endif +# define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen.enabled" +# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN +# define OSSL_TFO_SERVER_FLAG 1 # endif +# endif -# if defined(OPENSSL_SYS_LINUX) +# if defined(OPENSSL_SYS_LINUX) /* OSSL_TFO_PROC not used, but of interest */ -# define OSSL_TFO_PROC "/proc/sys/net/ipv4/tcp_fastopen" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN -# if defined(TCP_FASTOPEN_CONNECT) -# define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT -# else -# define OSSL_TFO_SENDTO MSG_FASTOPEN -# define OSSL_TFO_DO_NOT_CONNECT 1 -# endif -# define OSSL_TFO_CLIENT_FLAG 1 -# define OSSL_TFO_SERVER_FLAG 2 +# define OSSL_TFO_PROC "/proc/sys/net/ipv4/tcp_fastopen" +# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN +# if defined(TCP_FASTOPEN_CONNECT) +# define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT +# else +# define OSSL_TFO_SENDTO MSG_FASTOPEN +# define OSSL_TFO_DO_NOT_CONNECT 1 # endif +# define OSSL_TFO_CLIENT_FLAG 1 +# define OSSL_TFO_SERVER_FLAG 2 +# endif #endif diff --git a/libs/OpenSSL/include/internal/common.h b/libs/OpenSSL/include/internal/common.h index 4cd35390..1fa0b0a1 100644 --- a/libs/OpenSSL/include/internal/common.h +++ b/libs/OpenSSL/include/internal/common.h @@ -19,66 +19,69 @@ #include "internal/nelem.h" #ifdef NDEBUG -# define ossl_assert(x) ((x) != 0) +# define ossl_assert(x) ((x) != 0) #else -__owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr, const char *file, - int line) +__owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr, + const char *file, int line) { - if (!expr) - OPENSSL_die(exprstr, file, line); + if (!expr) + OPENSSL_die(exprstr, file, line); - return expr; + return expr; } -# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: " # x, __FILE__, __LINE__) +# define ossl_assert(x) \ + ossl_assert_int((x) != 0, "Assertion failed: " #x, __FILE__, __LINE__) #endif /* Check if |pre|, which must be a string literal, is a prefix of |str| */ #define HAS_PREFIX(str, pre) (strncmp(str, pre "", sizeof(pre) - 1) == 0) /* As before, and if check succeeds, advance |str| past the prefix |pre| */ -#define CHECK_AND_SKIP_PREFIX(str, pre) (HAS_PREFIX(str, pre) ? ((str) += sizeof(pre) - 1, 1) : 0) +#define CHECK_AND_SKIP_PREFIX(str, pre) \ + (HAS_PREFIX(str, pre) ? ((str) += sizeof(pre) - 1, 1) : 0) /* Check if the string literal |p| is a case-insensitive prefix of |s| */ #define HAS_CASE_PREFIX(s, p) (OPENSSL_strncasecmp(s, p "", sizeof(p) - 1) == 0) /* As before, and if check succeeds, advance |str| past the prefix |pre| */ -#define CHECK_AND_SKIP_CASE_PREFIX(str, pre) \ - (HAS_CASE_PREFIX(str, pre) ? ((str) += sizeof(pre) - 1, 1) : 0) +#define CHECK_AND_SKIP_CASE_PREFIX(str, pre) \ + (HAS_CASE_PREFIX(str, pre) ? ((str) += sizeof(pre) - 1, 1) : 0) /* Check if the string literal |suffix| is a case-insensitive suffix of |str| */ -#define HAS_CASE_SUFFIX(str, suffix) \ - (strlen(str) < sizeof(suffix) - 1 \ - ? 0 \ - : OPENSSL_strcasecmp(str + strlen(str) - sizeof(suffix) + 1, suffix "") == 0) +#define HAS_CASE_SUFFIX(str, suffix) \ + (strlen(str) < sizeof(suffix) - 1 \ + ? 0 \ + : OPENSSL_strcasecmp(str + strlen(str) - sizeof(suffix) + 1, suffix "") \ + == 0) /* * Use this inside a union with the field that needs to be aligned to a * reasonable boundary for the platform. The most pessimistic alignment * of the listed types will be used by the compiler. */ -#define OSSL_UNION_ALIGN \ - double align; \ - ossl_uintmax_t align_int; \ - void *align_ptr +#define OSSL_UNION_ALIGN \ + double align; \ + ossl_uintmax_t align_int; \ + void *align_ptr #define OPENSSL_CONF "openssl.cnf" #ifndef OPENSSL_SYS_VMS -# define X509_CERT_AREA OPENSSLDIR -# define X509_CERT_DIR OPENSSLDIR "/certs" -# define X509_CERT_FILE OPENSSLDIR "/cert.pem" -# define X509_PRIVATE_DIR OPENSSLDIR "/private" -# define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf" +# define X509_CERT_AREA OPENSSLDIR +# define X509_CERT_DIR OPENSSLDIR "/certs" +# define X509_CERT_FILE OPENSSLDIR "/cert.pem" +# define X509_PRIVATE_DIR OPENSSLDIR "/private" +# define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf" #else -# define X509_CERT_AREA "OSSL$DATAROOT:[000000]" -# define X509_CERT_DIR "OSSL$DATAROOT:[CERTS]" -# define X509_CERT_FILE "OSSL$DATAROOT:[000000]cert.pem" -# define X509_PRIVATE_DIR "OSSL$DATAROOT:[PRIVATE]" -# define CTLOG_FILE "OSSL$DATAROOT:[000000]ct_log_list.cnf" +# define X509_CERT_AREA "OSSL$DATAROOT:[000000]" +# define X509_CERT_DIR "OSSL$DATAROOT:[CERTS]" +# define X509_CERT_FILE "OSSL$DATAROOT:[000000]cert.pem" +# define X509_PRIVATE_DIR "OSSL$DATAROOT:[PRIVATE]" +# define CTLOG_FILE "OSSL$DATAROOT:[000000]ct_log_list.cnf" #endif #ifndef OPENSSL_NO_WINSTORE -# define X509_CERT_URI "org.openssl.winstore://" +# define X509_CERT_URI "org.openssl.winstore://" #else -# define X509_CERT_URI "" +# define X509_CERT_URI "" #endif #define X509_CERT_URI_EVP "SSL_CERT_URI" @@ -93,30 +96,30 @@ __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr, con static ossl_inline int ossl_ends_with_dirsep(const char *path) { - if (*path != '\0') - path += strlen(path) - 1; + if (*path != '\0') + path += strlen(path) - 1; #if defined __VMS - if (*path == ']' || *path == '>' || *path == ':') - return 1; + if (*path == ']' || *path == '>' || *path == ':') + return 1; #elif defined _WIN32 - if (*path == '\\') - return 1; + if (*path == '\\') + return 1; #endif - return *path == '/'; + return *path == '/'; } static ossl_inline int ossl_is_absolute_path(const char *path) { #if defined __VMS - if (strchr(path, ':') != NULL - || ((path[0] == '[' || path[0] == '<') && path[1] != '.' && path[1] != '-' && path[1] != ']' - && path[1] != '>')) - return 1; + if (strchr(path, ':') != NULL + || ((path[0] == '[' || path[0] == '<') && path[1] != '.' && path[1] != '-' + && path[1] != ']' && path[1] != '>')) + return 1; #elif defined _WIN32 - if (path[0] == '\\' || (path[0] != '\0' && path[1] == ':')) - return 1; + if (path[0] == '\\' || (path[0] != '\0' && path[1] == ':')) + return 1; #endif - return path[0] == '/'; + return path[0] == '/'; } #endif diff --git a/libs/OpenSSL/include/internal/conf.h b/libs/OpenSSL/include/internal/conf.h index bcbc0e35..8eac0075 100644 --- a/libs/OpenSSL/include/internal/conf.h +++ b/libs/OpenSSL/include/internal/conf.h @@ -13,15 +13,15 @@ #include -#define DEFAULT_CONF_MFLAGS \ - (CONF_MFLAGS_DEFAULT_SECTION | CONF_MFLAGS_IGNORE_MISSING_FILE \ - | CONF_MFLAGS_IGNORE_RETURN_CODES) +#define DEFAULT_CONF_MFLAGS \ + (CONF_MFLAGS_DEFAULT_SECTION | CONF_MFLAGS_IGNORE_MISSING_FILE \ + | CONF_MFLAGS_IGNORE_RETURN_CODES) struct ossl_init_settings_st { - char *filename; - char *appname; - unsigned long flags; + char *filename; + char *appname; + unsigned long flags; }; int ossl_config_int(const OPENSSL_INIT_SETTINGS *); diff --git a/libs/OpenSSL/include/internal/constant_time.h b/libs/OpenSSL/include/internal/constant_time.h index f5c4e045..c3f34472 100644 --- a/libs/OpenSSL/include/internal/constant_time.h +++ b/libs/OpenSSL/include/internal/constant_time.h @@ -37,16 +37,20 @@ static ossl_inline uint32_t constant_time_msb_32(uint32_t a); static ossl_inline uint64_t constant_time_msb_64(uint64_t a); /* Returns 0xff..f if a < b and 0 otherwise. */ -static ossl_inline unsigned int constant_time_lt(unsigned int a, unsigned int b); +static ossl_inline unsigned int constant_time_lt(unsigned int a, + unsigned int b); /* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b); +static ossl_inline unsigned char constant_time_lt_8(unsigned int a, + unsigned int b); /* Convenience method for uint64_t. */ static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b); /* Returns 0xff..f if a >= b and 0 otherwise. */ -static ossl_inline unsigned int constant_time_ge(unsigned int a, unsigned int b); +static ossl_inline unsigned int constant_time_ge(unsigned int a, + unsigned int b); /* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b); +static ossl_inline unsigned char constant_time_ge_8(unsigned int a, + unsigned int b); /* Returns 0xff..f if a == 0 and 0 otherwise. */ static ossl_inline unsigned int constant_time_is_zero(unsigned int a); @@ -56,9 +60,11 @@ static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a); static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a); /* Returns 0xff..f if a == b and 0 otherwise. */ -static ossl_inline unsigned int constant_time_eq(unsigned int a, unsigned int b); +static ossl_inline unsigned int constant_time_eq(unsigned int a, + unsigned int b); /* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_eq_8(unsigned int a, unsigned int b); +static ossl_inline unsigned char constant_time_eq_8(unsigned int a, + unsigned int b); /* Signed integers. */ static ossl_inline unsigned int constant_time_eq_int(int a, int b); /* Convenience method for getting an 8-bit mask. */ @@ -71,133 +77,139 @@ static ossl_inline unsigned char constant_time_eq_int_8(int a, int b); * the select methods return either |a| (if |mask| is nonzero) or |b| * (if |mask| is zero). */ -static ossl_inline unsigned int constant_time_select(unsigned int mask, unsigned int a, - unsigned int b); +static ossl_inline unsigned int +constant_time_select(unsigned int mask, unsigned int a, unsigned int b); /* Convenience method for unsigned chars. */ -static ossl_inline unsigned char constant_time_select_8(unsigned char mask, unsigned char a, - unsigned char b); +static ossl_inline unsigned char +constant_time_select_8(unsigned char mask, unsigned char a, unsigned char b); /* Convenience method for uint32_t. */ -static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, uint32_t b); +static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, + uint32_t b); /* Convenience method for uint64_t. */ -static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, uint64_t b); +static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, + uint64_t b); /* Convenience method for signed integers. */ -static ossl_inline int constant_time_select_int(unsigned int mask, int a, int b); +static ossl_inline int constant_time_select_int(unsigned int mask, int a, + int b); static ossl_inline unsigned int constant_time_msb(unsigned int a) { - return 0 - (a >> (sizeof(a) * 8 - 1)); + return 0 - (a >> (sizeof(a) * 8 - 1)); } static ossl_inline uint32_t constant_time_msb_32(uint32_t a) { - return 0 - (a >> 31); + return 0 - (a >> 31); } static ossl_inline uint64_t constant_time_msb_64(uint64_t a) { - return 0 - (a >> 63); + return 0 - (a >> 63); } static ossl_inline size_t constant_time_msb_s(size_t a) { - return 0 - (a >> (sizeof(a) * 8 - 1)); + return 0 - (a >> (sizeof(a) * 8 - 1)); } static ossl_inline unsigned int constant_time_lt(unsigned int a, unsigned int b) { - return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b))); + return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b))); } static ossl_inline size_t constant_time_lt_s(size_t a, size_t b) { - return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b))); + return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b))); } -static ossl_inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b) +static ossl_inline unsigned char constant_time_lt_8(unsigned int a, + unsigned int b) { - return (unsigned char)constant_time_lt(a, b); + return (unsigned char)constant_time_lt(a, b); } static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b) { - return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b))); + return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b))); } static ossl_inline unsigned int constant_time_ge(unsigned int a, unsigned int b) { - return ~constant_time_lt(a, b); + return ~constant_time_lt(a, b); } static ossl_inline size_t constant_time_ge_s(size_t a, size_t b) { - return ~constant_time_lt_s(a, b); + return ~constant_time_lt_s(a, b); } -static ossl_inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b) +static ossl_inline unsigned char constant_time_ge_8(unsigned int a, + unsigned int b) { - return (unsigned char)constant_time_ge(a, b); + return (unsigned char)constant_time_ge(a, b); } static ossl_inline unsigned char constant_time_ge_8_s(size_t a, size_t b) { - return (unsigned char)constant_time_ge_s(a, b); + return (unsigned char)constant_time_ge_s(a, b); } static ossl_inline unsigned int constant_time_is_zero(unsigned int a) { - return constant_time_msb(~a & (a - 1)); + return constant_time_msb(~a & (a - 1)); } static ossl_inline size_t constant_time_is_zero_s(size_t a) { - return constant_time_msb_s(~a & (a - 1)); + return constant_time_msb_s(~a & (a - 1)); } static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a) { - return (unsigned char)constant_time_is_zero(a); + return (unsigned char)constant_time_is_zero(a); } static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a) { - return constant_time_msb_32(~a & (a - 1)); + return constant_time_msb_32(~a & (a - 1)); } static ossl_inline uint64_t constant_time_is_zero_64(uint64_t a) { - return constant_time_msb_64(~a & (a - 1)); + return constant_time_msb_64(~a & (a - 1)); } static ossl_inline unsigned int constant_time_eq(unsigned int a, unsigned int b) { - return constant_time_is_zero(a ^ b); + return constant_time_is_zero(a ^ b); } static ossl_inline size_t constant_time_eq_s(size_t a, size_t b) { - return constant_time_is_zero_s(a ^ b); + return constant_time_is_zero_s(a ^ b); } -static ossl_inline unsigned char constant_time_eq_8(unsigned int a, unsigned int b) +static ossl_inline unsigned char constant_time_eq_8(unsigned int a, + unsigned int b) { - return (unsigned char)constant_time_eq(a, b); + return (unsigned char)constant_time_eq(a, b); } static ossl_inline unsigned char constant_time_eq_8_s(size_t a, size_t b) { - return (unsigned char)constant_time_eq_s(a, b); + return (unsigned char)constant_time_eq_s(a, b); } static ossl_inline unsigned int constant_time_eq_int(int a, int b) { - return constant_time_eq((unsigned)(a), (unsigned)(b)); + return constant_time_eq((unsigned)(a), (unsigned)(b)); } static ossl_inline unsigned char constant_time_eq_int_8(int a, int b) { - return constant_time_eq_8((unsigned)(a), (unsigned)(b)); + return constant_time_eq_8((unsigned)(a), (unsigned)(b)); } /* @@ -210,85 +222,89 @@ static ossl_inline unsigned char constant_time_eq_int_8(int a, int b) static ossl_inline unsigned int value_barrier(unsigned int a) { #if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - unsigned int r; - __asm__("" : "=r"(r) : "0"(a)); + unsigned int r; + __asm__("" : "=r"(r) : "0"(a)); #else - volatile unsigned int r = a; + volatile unsigned int r = a; #endif - return r; + return r; } /* Convenience method for uint32_t. */ static ossl_inline uint32_t value_barrier_32(uint32_t a) { #if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - uint32_t r; - __asm__("" : "=r"(r) : "0"(a)); + uint32_t r; + __asm__("" : "=r"(r) : "0"(a)); #else - volatile uint32_t r = a; + volatile uint32_t r = a; #endif - return r; + return r; } /* Convenience method for uint64_t. */ static ossl_inline uint64_t value_barrier_64(uint64_t a) { #if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - uint64_t r; - __asm__("" : "=r"(r) : "0"(a)); + uint64_t r; + __asm__("" : "=r"(r) : "0"(a)); #else - volatile uint64_t r = a; + volatile uint64_t r = a; #endif - return r; + return r; } /* Convenience method for size_t. */ static ossl_inline size_t value_barrier_s(size_t a) { #if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - size_t r; - __asm__("" : "=r"(r) : "0"(a)); + size_t r; + __asm__("" : "=r"(r) : "0"(a)); #else - volatile size_t r = a; + volatile size_t r = a; #endif - return r; + return r; } -static ossl_inline unsigned int constant_time_select(unsigned int mask, unsigned int a, - unsigned int b) +static ossl_inline unsigned int +constant_time_select(unsigned int mask, unsigned int a, unsigned int b) { - return (value_barrier(mask) & a) | (value_barrier(~mask) & b); + return (value_barrier(mask) & a) | (value_barrier(~mask) & b); } -static ossl_inline size_t constant_time_select_s(size_t mask, size_t a, size_t b) +static ossl_inline size_t constant_time_select_s(size_t mask, size_t a, + size_t b) { - return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b); + return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b); } -static ossl_inline unsigned char constant_time_select_8(unsigned char mask, unsigned char a, - unsigned char b) +static ossl_inline unsigned char +constant_time_select_8(unsigned char mask, unsigned char a, unsigned char b) { - return (unsigned char)constant_time_select(mask, a, b); + return (unsigned char)constant_time_select(mask, a, b); } static ossl_inline int constant_time_select_int(unsigned int mask, int a, int b) { - return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b)); + return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b)); } static ossl_inline int constant_time_select_int_s(size_t mask, int a, int b) { - return (int)constant_time_select((unsigned)mask, (unsigned)(a), (unsigned)(b)); + return (int)constant_time_select((unsigned)mask, (unsigned)(a), + (unsigned)(b)); } -static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, uint32_t b) +static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, + uint32_t b) { - return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b); + return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b); } -static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, uint64_t b) +static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, + uint64_t b) { - return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b); + return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b); } /* @@ -301,13 +317,14 @@ static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, u * *b = tmp; * } */ -static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, uint32_t *b) +static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, + uint32_t *b) { - uint32_t xor = *a ^ *b; + uint32_t xor = *a ^ *b; - xor &= mask; - *a ^= xor; - *b ^= xor; + xor &= mask; + *a ^= xor; + *b ^= xor; } /* @@ -320,13 +337,14 @@ static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, u * *b = tmp; * } */ -static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, uint64_t *b) +static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, + uint64_t *b) { - uint64_t xor = *a ^ *b; + uint64_t xor = *a ^ *b; - xor &= mask; - *a ^= xor; - *b ^= xor; + xor &= mask; + *a ^= xor; + *b ^= xor; } /* @@ -341,19 +359,21 @@ static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, u * memcpy(b, tmp); * } */ -static ossl_inline void constant_time_cond_swap_buff(unsigned char mask, unsigned char *a, - unsigned char *b, size_t len) +static ossl_inline void constant_time_cond_swap_buff(unsigned char mask, + unsigned char *a, + unsigned char *b, + size_t len) { - size_t i; - unsigned char tmp; + size_t i; + unsigned char tmp; - for (i = 0; i < len; i++) - { - tmp = a[i] ^ b[i]; - tmp &= mask; - a[i] ^= tmp; - b[i] ^= tmp; - } + for (i = 0; i < len; i++) + { + tmp = a[i] ^ b[i]; + tmp &= mask; + a[i] ^= tmp; + b[i] ^= tmp; + } } /* @@ -361,23 +381,24 @@ static ossl_inline void constant_time_cond_swap_buff(unsigned char mask, unsigne * Copies row number idx into out. rowsize and numrows are not considered * private. */ -static ossl_inline void constant_time_lookup(void *out, const void *table, size_t rowsize, - size_t numrows, size_t idx) +static ossl_inline void constant_time_lookup(void *out, const void *table, + size_t rowsize, size_t numrows, + size_t idx) { - size_t i, j; - const unsigned char *tablec = (const unsigned char *)table; - unsigned char *outc = (unsigned char *)out; - unsigned char mask; + size_t i, j; + const unsigned char *tablec = (const unsigned char *)table; + unsigned char *outc = (unsigned char *)out; + unsigned char mask; - memset(out, 0, rowsize); + memset(out, 0, rowsize); - /* Note idx may underflow - but that is well defined */ - for (i = 0; i < numrows; i++, idx--) - { - mask = (unsigned char)constant_time_is_zero_s(idx); - for (j = 0; j < rowsize; j++) - *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0); - } + /* Note idx may underflow - but that is well defined */ + for (i = 0; i < numrows; i++, idx--) + { + mask = (unsigned char)constant_time_is_zero_s(idx); + for (j = 0; j < rowsize; j++) + *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0); + } } /* diff --git a/libs/OpenSSL/include/internal/core.h b/libs/OpenSSL/include/internal/core.h index e23b2bc5..cf7152ec 100644 --- a/libs/OpenSSL/include/internal/core.h +++ b/libs/OpenSSL/include/internal/core.h @@ -29,34 +29,40 @@ */ typedef struct ossl_method_construct_method_st { - /* Get a temporary store */ - void *(*get_tmp_store)(void *data); - /* Reserve the appropriate method store */ - int (*lock_store)(void *store, void *data); - /* Unreserve the appropriate method store */ - int (*unlock_store)(void *store, void *data); - /* Get an already existing method from a store */ - void *(*get)(void *store, const OSSL_PROVIDER **prov, void *data); - /* Store a method in a store */ - int (*put)(void *store, void *method, const OSSL_PROVIDER *prov, const char *name, - const char *propdef, void *data); - /* Construct a new method */ - void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov, void *data); - /* Destruct a method */ - void (*destruct)(void *method, void *data); + /* Get a temporary store */ + void *(*get_tmp_store)(void *data); + /* Reserve the appropriate method store */ + int (*lock_store)(void *store, void *data); + /* Unreserve the appropriate method store */ + int (*unlock_store)(void *store, void *data); + /* Get an already existing method from a store */ + void *(*get)(void *store, const OSSL_PROVIDER **prov, void *data); + /* Store a method in a store */ + int (*put)(void *store, void *method, const OSSL_PROVIDER *prov, + const char *name, const char *propdef, void *data); + /* Construct a new method */ + void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov, + void *data); + /* Destruct a method */ + void (*destruct)(void *method, void *data); } OSSL_METHOD_CONSTRUCT_METHOD; -void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id, OSSL_PROVIDER **provider_rw, - int force_cache, OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); +void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id, + OSSL_PROVIDER **provider_rw, int force_cache, + OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); -void ossl_algorithm_do_all( - OSSL_LIB_CTX *libctx, int operation_id, OSSL_PROVIDER *provider, - int (*pre)(OSSL_PROVIDER *, int operation_id, int no_store, void *data, int *result), - int (*reserve_store)(int no_store, void *data), - void (*fn)(OSSL_PROVIDER *provider, const OSSL_ALGORITHM *algo, int no_store, void *data), - int (*unreserve_store)(void *data), - int (*post)(OSSL_PROVIDER *, int operation_id, int no_store, void *data, int *result), - void *data); +void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id, + OSSL_PROVIDER *provider, + int (*pre)(OSSL_PROVIDER *, int operation_id, + int no_store, void *data, int *result), + int (*reserve_store)(int no_store, void *data), + void (*fn)(OSSL_PROVIDER *provider, + const OSSL_ALGORITHM *algo, int no_store, + void *data), + int (*unreserve_store)(void *data), + int (*post)(OSSL_PROVIDER *, int operation_id, + int no_store, void *data, int *result), + void *data); char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo); __owur int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx); diff --git a/libs/OpenSSL/include/internal/cryptlib.h b/libs/OpenSSL/include/internal/cryptlib.h index 87402185..e4a3dc79 100644 --- a/libs/OpenSSL/include/internal/cryptlib.h +++ b/libs/OpenSSL/include/internal/cryptlib.h @@ -12,10 +12,10 @@ #pragma once #ifdef OPENSSL_USE_APPLINK -# define BIO_FLAGS_UPLINK_INTERNAL 0x8000 -# include "ms/uplink.h" +# define BIO_FLAGS_UPLINK_INTERNAL 0x8000 +# include "ms/uplink.h" #else -# define BIO_FLAGS_UPLINK_INTERNAL 0 +# define BIO_FLAGS_UPLINK_INTERNAL 0 #endif #include "internal/common.h" @@ -34,8 +34,9 @@ typedef struct mem_st MEM; DEFINE_LHASH_OF_EX(MEM); void OPENSSL_cpuid_setup(void); -#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86_64) \ - || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) \ + || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) \ + || defined(_M_X64) extern unsigned int OPENSSL_ia32cap_P[]; #endif void OPENSSL_showfatal(const char *fmta, ...); @@ -66,12 +67,12 @@ size_t OPENSSL_instrument_bus2(unsigned int *, size_t, size_t); */ struct ex_callback_st { - long argl; /* Arbitrary long */ - void *argp; /* Arbitrary void * */ - int priority; /* Priority ordering for freeing */ - CRYPTO_EX_new *new_func; - CRYPTO_EX_free *free_func; - CRYPTO_EX_dup *dup_func; + long argl; /* Arbitrary long */ + void *argp; /* Arbitrary void * */ + int priority; /* Priority ordering for freeing */ + CRYPTO_EX_new *new_func; + CRYPTO_EX_free *free_func; + CRYPTO_EX_dup *dup_func; }; /* @@ -80,13 +81,13 @@ struct ex_callback_st */ typedef struct ex_callbacks_st { - STACK_OF(EX_CALLBACK) * meth; + STACK_OF(EX_CALLBACK) * meth; } EX_CALLBACKS; typedef struct ossl_ex_data_global_st { - CRYPTO_RWLOCK *ex_data_lock; - EX_CALLBACKS ex_data[CRYPTO_EX_INDEX__COUNT]; + CRYPTO_RWLOCK *ex_data_lock; + EX_CALLBACKS ex_data[CRYPTO_EX_INDEX__COUNT]; } OSSL_EX_DATA_GLOBAL; /* OSSL_LIB_CTX */ @@ -105,7 +106,7 @@ typedef struct ossl_ex_data_global_st #define OSSL_LIB_CTX_DRBG_NONCE_INDEX 6 #define OSSL_LIB_CTX_RAND_CRNGT_INDEX 7 #ifdef FIPS_MODULE -# define OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX 8 +# define OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX 8 #endif #define OSSL_LIB_CTX_FIPS_PROV_INDEX 9 #define OSSL_LIB_CTX_ENCODER_STORE_INDEX 10 @@ -133,9 +134,12 @@ OSSL_EX_DATA_GLOBAL *ossl_lib_ctx_get_ex_data_global(OSSL_LIB_CTX *ctx); const char *ossl_lib_ctx_get_descriptor(OSSL_LIB_CTX *libctx); OSSL_LIB_CTX *ossl_crypto_ex_data_get_ossl_lib_ctx(const CRYPTO_EX_DATA *ad); -int ossl_crypto_new_ex_data_ex(OSSL_LIB_CTX *ctx, int class_index, void *obj, CRYPTO_EX_DATA *ad); -int ossl_crypto_get_ex_new_index_ex(OSSL_LIB_CTX *ctx, int class_index, long argl, void *argp, - CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, +int ossl_crypto_new_ex_data_ex(OSSL_LIB_CTX *ctx, int class_index, void *obj, + CRYPTO_EX_DATA *ad); +int ossl_crypto_get_ex_new_index_ex(OSSL_LIB_CTX *ctx, int class_index, + long argl, void *argp, + CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func, int priority); int ossl_crypto_free_ex_index_ex(OSSL_LIB_CTX *ctx, int class_index, int idx); @@ -148,10 +152,11 @@ int ossl_crypto_free_ex_index_ex(OSSL_LIB_CTX *ctx, int class_index, int idx); const void *ossl_bsearch(const void *key, const void *base, int num, int size, int (*cmp)(const void *, const void *), int flags); -char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) * text, const char *sep, - size_t max_len); +char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) * text, + const char *sep, size_t max_len); char *ossl_ipaddr_to_asc(unsigned char *p, int len); char *ossl_buf2hexstr_sep(const unsigned char *buf, long buflen, char sep); -unsigned char *ossl_hexstr2buf_sep(const char *str, long *buflen, const char sep); +unsigned char *ossl_hexstr2buf_sep(const char *str, long *buflen, + const char sep); #endif diff --git a/libs/OpenSSL/include/internal/dane.h b/libs/OpenSSL/include/internal/dane.h index bc188f58..649c3c14 100644 --- a/libs/OpenSSL/include/internal/dane.h +++ b/libs/OpenSSL/include/internal/dane.h @@ -42,12 +42,12 @@ typedef struct danetls_record_st { - uint8_t usage; - uint8_t selector; - uint8_t mtype; - unsigned char *data; - size_t dlen; - EVP_PKEY *spki; + uint8_t usage; + uint8_t selector; + uint8_t mtype; + unsigned char *data; + size_t dlen; + EVP_PKEY *spki; } danetls_record; DEFINE_STACK_OF(danetls_record) @@ -57,10 +57,10 @@ DEFINE_STACK_OF(danetls_record) */ struct dane_ctx_st { - const EVP_MD **mdevp; /* mtype -> digest */ - uint8_t *mdord; /* mtype -> preference */ - uint8_t mdmax; /* highest supported mtype */ - unsigned long flags; /* feature bitmask */ + const EVP_MD **mdevp; /* mtype -> digest */ + uint8_t *mdord; /* mtype -> preference */ + uint8_t mdmax; /* highest supported mtype */ + unsigned long flags; /* feature bitmask */ }; /* @@ -68,18 +68,19 @@ struct dane_ctx_st */ struct ssl_dane_st { - struct dane_ctx_st *dctx; - STACK_OF(danetls_record) * trecs; - STACK_OF(X509) * certs; /* DANE-TA(2) Cert(0) Full(0) certs */ - danetls_record *mtlsa; /* Matching TLSA record */ - X509 *mcert; /* DANE matched cert */ - uint32_t umask; /* Usages present */ - int mdpth; /* Depth of matched cert */ - int pdpth; /* Depth of PKIX trust */ - unsigned long flags; /* feature bitmask */ + struct dane_ctx_st *dctx; + STACK_OF(danetls_record) * trecs; + STACK_OF(X509) * certs; /* DANE-TA(2) Cert(0) Full(0) certs */ + danetls_record *mtlsa; /* Matching TLSA record */ + X509 *mcert; /* DANE matched cert */ + uint32_t umask; /* Usages present */ + int mdpth; /* Depth of matched cert */ + int pdpth; /* Depth of PKIX trust */ + unsigned long flags; /* feature bitmask */ }; -#define DANETLS_ENABLED(dane) ((dane) != NULL && sk_danetls_record_num((dane)->trecs) > 0) +#define DANETLS_ENABLED(dane) \ + ((dane) != NULL && sk_danetls_record_num((dane)->trecs) > 0) #define DANETLS_USAGE_BIT(u) (((uint32_t)1) << u) @@ -98,9 +99,13 @@ struct ssl_dane_st #define DANETLS_HAS_TA(dane) ((dane) && ((dane)->umask & DANETLS_TA_MASK)) #define DANETLS_HAS_EE(dane) ((dane) && ((dane)->umask & DANETLS_EE_MASK)) -#define DANETLS_HAS_PKIX_TA(dane) ((dane) && ((dane)->umask & DANETLS_PKIX_TA_MASK)) -#define DANETLS_HAS_PKIX_EE(dane) ((dane) && ((dane)->umask & DANETLS_PKIX_EE_MASK)) -#define DANETLS_HAS_DANE_TA(dane) ((dane) && ((dane)->umask & DANETLS_DANE_TA_MASK)) -#define DANETLS_HAS_DANE_EE(dane) ((dane) && ((dane)->umask & DANETLS_DANE_EE_MASK)) +#define DANETLS_HAS_PKIX_TA(dane) \ + ((dane) && ((dane)->umask & DANETLS_PKIX_TA_MASK)) +#define DANETLS_HAS_PKIX_EE(dane) \ + ((dane) && ((dane)->umask & DANETLS_PKIX_EE_MASK)) +#define DANETLS_HAS_DANE_TA(dane) \ + ((dane) && ((dane)->umask & DANETLS_DANE_TA_MASK)) +#define DANETLS_HAS_DANE_EE(dane) \ + ((dane) && ((dane)->umask & DANETLS_DANE_EE_MASK)) #endif /* OSSL_INTERNAL_DANE_H */ diff --git a/libs/OpenSSL/include/internal/der.h b/libs/OpenSSL/include/internal/der.h index 86ae981e..bec79d98 100644 --- a/libs/OpenSSL/include/internal/der.h +++ b/libs/OpenSSL/include/internal/der.h @@ -73,14 +73,16 @@ /* This can be used for all items that don't have a context */ #define DER_NO_CONTEXT -1 -int ossl_DER_w_precompiled(WPACKET *pkt, int tag, const unsigned char *precompiled, +int ossl_DER_w_precompiled(WPACKET *pkt, int tag, + const unsigned char *precompiled, size_t precompiled_n); int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b); int ossl_DER_w_uint32(WPACKET *pkt, int tag, uint32_t v); int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v); int ossl_DER_w_null(WPACKET *pkt, int tag); -int ossl_DER_w_octet_string(WPACKET *pkt, int tag, const unsigned char *data, size_t data_n); +int ossl_DER_w_octet_string(WPACKET *pkt, int tag, const unsigned char *data, + size_t data_n); int ossl_DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value); /* diff --git a/libs/OpenSSL/include/internal/deterministic_nonce.h b/libs/OpenSSL/include/internal/deterministic_nonce.h index 0e72d544..59c207c1 100644 --- a/libs/OpenSSL/include/internal/deterministic_nonce.h +++ b/libs/OpenSSL/include/internal/deterministic_nonce.h @@ -13,9 +13,9 @@ #include -int ossl_gen_deterministic_nonce_rfc6979(BIGNUM *out, const BIGNUM *q, const BIGNUM *priv, - const unsigned char *message, size_t message_len, - const char *digestname, OSSL_LIB_CTX *libctx, - const char *propq); +int ossl_gen_deterministic_nonce_rfc6979( + BIGNUM *out, const BIGNUM *q, const BIGNUM *priv, + const unsigned char *message, size_t message_len, const char *digestname, + OSSL_LIB_CTX *libctx, const char *propq); #endif /*OSSL_INTERNAL_DETERMINISTIC_NONCE_H */ diff --git a/libs/OpenSSL/include/internal/e_os.h b/libs/OpenSSL/include/internal/e_os.h index e7b21de9..3c15f0cb 100644 --- a/libs/OpenSSL/include/internal/e_os.h +++ b/libs/OpenSSL/include/internal/e_os.h @@ -23,8 +23,8 @@ */ #if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) -# define NO_CHMOD -# define NO_SYSLOG +# define NO_CHMOD +# define NO_SYSLOG #endif #define get_last_sys_error() errno @@ -35,55 +35,56 @@ The Microsoft section ********************************************************************/ #if defined(OPENSSL_SYS_WIN32) && !defined(WIN32) -# define WIN32 +# define WIN32 #endif #if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS) -# define WINDOWS +# define WINDOWS #endif #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS) -# define MSDOS +# define MSDOS #endif #ifdef WIN32 -# undef get_last_sys_error -# undef clear_sys_error -# undef set_sys_error -# define get_last_sys_error() GetLastError() -# define clear_sys_error() SetLastError(0) -# define set_sys_error(e) SetLastError(e) -# if !defined(WINNT) -# define WIN_CONSOLE_BUG -# endif +# undef get_last_sys_error +# undef clear_sys_error +# undef set_sys_error +# define get_last_sys_error() GetLastError() +# define clear_sys_error() SetLastError(0) +# define set_sys_error(e) SetLastError(e) +# if !defined(WINNT) +# define WIN_CONSOLE_BUG +# endif #else #endif #if (defined(WINDOWS) || defined(MSDOS)) -# ifdef __DJGPP__ -# include -# include -# define _setmode setmode -# define _O_TEXT O_TEXT -# define _O_BINARY O_BINARY -# undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. */ -# undef DEVRANDOM -# define DEVRANDOM "/dev/urandom\x24" -# endif /* __DJGPP__ */ +# ifdef __DJGPP__ +# include +# include +# define _setmode setmode +# define _O_TEXT O_TEXT +# define _O_BINARY O_BINARY +# undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. \ + */ +# undef DEVRANDOM +# define DEVRANDOM "/dev/urandom\x24" +# endif /* __DJGPP__ */ -# ifndef S_IFDIR -# define S_IFDIR _S_IFDIR -# endif +# ifndef S_IFDIR +# define S_IFDIR _S_IFDIR +# endif -# ifndef S_IFMT -# define S_IFMT _S_IFMT -# endif +# ifndef S_IFMT +# define S_IFMT _S_IFMT +# endif -# if !defined(WINNT) && !defined(__DJGPP__) -# define NO_SYSLOG -# endif +# if !defined(WINNT) && !defined(__DJGPP__) +# define NO_SYSLOG +# endif -# ifdef WINDOWS -# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) +# ifdef WINDOWS +# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) /* * Defining _WIN32_WINNT here in e_os.h implies certain "discipline." * Most notably we ought to check for availability of each specific @@ -96,9 +97,9 @@ * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs * and check for current OS version instead. */ -# define _WIN32_WINNT 0x0501 -# endif -# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) +# define _WIN32_WINNT 0x0501 +# endif +# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) /* * Just like defining _WIN32_WINNT including winsock2.h implies * certain "discipline" for maintaining [broad] binary compatibility. @@ -106,103 +107,104 @@ * it's sufficient to check for specific Winsock2 API availability * at run-time [DSO_global_lookup is recommended]... */ -# include -# include +# include +# include /* * Clang-based C++Builder 10.3.3 toolchains cannot find C inline * definitions at link-time. This header defines WspiapiLoad() as an * __inline function. https://quality.embarcadero.com/browse/RSP-33806 */ -# if !defined(__BORLANDC__) || !defined(__clang__) -# include -# endif +# if !defined(__BORLANDC__) || !defined(__clang__) +# include +# endif /* yes, they have to be #included prior to */ -# endif -# include -# include -# include -# include -# if defined(_WIN32_WCE) && !defined(EACCES) -# define EACCES 13 -# endif -# include -# ifdef _WIN64 -# define strlen(s) _strlen31(s) +# endif +# include +# include +# include +# include +# if defined(_WIN32_WCE) && !defined(EACCES) +# define EACCES 13 +# endif +# include +# ifdef _WIN64 +# define strlen(s) _strlen31(s) /* cut strings to 2GB */ static __inline unsigned int _strlen31(const char *str) { - unsigned int len = 0; - while (*str && len < 0x80000000U) - str++, len++; - return len & 0x7FFFFFFF; + unsigned int len = 0; + while (*str && len < 0x80000000U) + str++, len++; + return len & 0x7FFFFFFF; } -# endif -# include -# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin) -# if _MSC_VER >= 1300 && _MSC_VER < 1600 -# undef stdin -# undef stdout -# undef stderr +# endif +# include +# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) \ + && defined(stdin) +# if _MSC_VER >= 1300 && _MSC_VER < 1600 +# undef stdin +# undef stdout +# undef stderr FILE *__iob_func(); -# define stdin (&__iob_func()[0]) -# define stdout (&__iob_func()[1]) -# define stderr (&__iob_func()[2]) -# endif -# endif +# define stdin (&__iob_func()[0]) +# define stdout (&__iob_func()[1]) +# define stderr (&__iob_func()[2]) +# endif # endif -# include -# include +# endif +# include +# include -# ifdef OPENSSL_SYS_WINCE -# define OPENSSL_NO_POSIX_IO -# endif +# ifdef OPENSSL_SYS_WINCE +# define OPENSSL_NO_POSIX_IO +# endif -# define EXIT(n) exit(n) -# define LIST_SEPARATOR_CHAR ';' -# ifndef W_OK -# define W_OK 2 -# endif -# ifndef R_OK -# define R_OK 4 -# endif -# ifdef OPENSSL_SYS_WINCE -# define DEFAULT_HOME "" -# else -# define DEFAULT_HOME "C:" -# endif +# define EXIT(n) exit(n) +# define LIST_SEPARATOR_CHAR ';' +# ifndef W_OK +# define W_OK 2 +# endif +# ifndef R_OK +# define R_OK 4 +# endif +# ifdef OPENSSL_SYS_WINCE +# define DEFAULT_HOME "" +# else +# define DEFAULT_HOME "C:" +# endif /* Avoid Visual Studio 13 GetVersion deprecated problems */ -# if defined(_MSC_VER) && _MSC_VER >= 1800 -# define check_winnt() (1) -# define check_win_minplat(x) (1) -# else -# define check_winnt() (GetVersion() < 0x80000000) -# define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x)) -# endif +# if defined(_MSC_VER) && _MSC_VER >= 1800 +# define check_winnt() (1) +# define check_win_minplat(x) (1) +# else +# define check_winnt() (GetVersion() < 0x80000000) +# define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x)) +# endif #else /* The non-microsoft world */ -# if defined(OPENSSL_SYS_VXWORKS) -# include -# else -# include -# endif +# if defined(OPENSSL_SYS_VXWORKS) +# include +# else +# include +# endif -# ifdef OPENSSL_SYS_VMS -# define VMS 1 +# ifdef OPENSSL_SYS_VMS +# define VMS 1 /* * some programs don't include stdlib, so exit() and others give implicit * function warnings */ -# include -# if defined(__DECC) -# include -# else -# include -# endif -# define LIST_SEPARATOR_CHAR ',' +# include +# if defined(__DECC) +# include +# else +# include +# endif +# define LIST_SEPARATOR_CHAR ',' /* We don't have any well-defined random devices on VMS, yet... */ -# undef DEVRANDOM +# undef DEVRANDOM /*- We need to do this since VMS has the following coding on status codes: @@ -227,53 +229,53 @@ FILE *__iob_func(); status type doesn't seem to bother Perl. -- Richard Levitte */ -# define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1) +# define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1) -# define DEFAULT_HOME "SYS$LOGIN:" +# define DEFAULT_HOME "SYS$LOGIN:" -# else +# else /* !defined VMS */ -# include -# include -# ifdef OPENSSL_SYS_WIN32_CYGWIN -# include -# include -# endif - -# define LIST_SEPARATOR_CHAR ':' -# define EXIT(n) exit(n) +# include +# include +# ifdef OPENSSL_SYS_WIN32_CYGWIN +# include +# include # endif +# define LIST_SEPARATOR_CHAR ':' +# define EXIT(n) exit(n) +# endif + #endif /***********************************************/ #if defined(OPENSSL_SYS_WINDOWS) -# if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(_WIN32_WCE) -# define open _open -# define fdopen _fdopen -# define close _close -# ifndef strdup -# define strdup _strdup -# endif -# define unlink _unlink -# define fileno _fileno +# if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(_WIN32_WCE) +# define open _open +# define fdopen _fdopen +# define close _close +# ifndef strdup +# define strdup _strdup # endif +# define unlink _unlink +# define fileno _fileno +# endif #else -# include +# include #endif /* vxworks */ #if defined(OPENSSL_SYS_VXWORKS) -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include -# define TTY_STRUCT int -# define sleep(a) taskDelay((a)*sysClkRateGet()) +# define TTY_STRUCT int +# define sleep(a) taskDelay((a) * sysClkRateGet()) /* * NOTE: these are implemented by helpers in database app! if the database is @@ -289,50 +291,50 @@ struct servent *getservbyname(const char *name, const char *proto); /* ----------------------------- HP NonStop -------------------------------- */ /* Required to support platform variant without getpid() and pid_t. */ #if defined(__TANDEM) && defined(_GUARDIAN_TARGET) -# include -# include -# define getservbyname(name, proto) getservbyname((char *)name, proto) -# define gethostbyname(name) gethostbyname((char *)name) -# define ioctlsocket(a, b, c) ioctl(a, b, c) -# ifdef NO_GETPID +# include +# include +# define getservbyname(name, proto) getservbyname((char *)name, proto) +# define gethostbyname(name) gethostbyname((char *)name) +# define ioctlsocket(a, b, c) ioctl(a, b, c) +# ifdef NO_GETPID inline int nssgetpid(); -# ifndef NSSGETPID_MACRO -# define NSSGETPID_MACRO -# include -# include +# ifndef NSSGETPID_MACRO +# define NSSGETPID_MACRO +# include +# include inline int nssgetpid() { - short phandle[10] = { 0 }; - union pseudo_pid + short phandle[10] = {0}; + union pseudo_pid + { + struct { - struct - { - short cpu; - short pin; - } cpu_pin; - int ppid; - } ppid = { 0 }; - PROCESSHANDLE_GETMINE_(phandle); - PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin); - return ppid.ppid; + short cpu; + short pin; + } cpu_pin; + int ppid; + } ppid = {0}; + PROCESSHANDLE_GETMINE_(phandle); + PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin); + return ppid.ppid; } -# define getpid(a) nssgetpid(a) -# endif /* NSSGETPID_MACRO */ -# endif /* NO_GETPID */ +# define getpid(a) nssgetpid(a) +# endif /* NSSGETPID_MACRO */ +# endif /* NO_GETPID */ /*# define setsockopt(a,b,c,d,f) setsockopt(a,b,c,(char*)d,f)*/ /*# define getsockopt(a,b,c,d,f) getsockopt(a,b,c,(char*)d,f)*/ /*# define connect(a,b,c) connect(a,(struct sockaddr *)b,c)*/ /*# define bind(a,b,c) bind(a,(struct sockaddr *)b,c)*/ /*# define sendto(a,b,c,d,e,f) sendto(a,(char*)b,c,d,(struct sockaddr *)e,f)*/ -# if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_) +# if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_) /* * HPNS SPT threads */ -# define SPT_THREAD_SIGNAL 1 -# define SPT_THREAD_AWARE 1 -# include -# undef close -# define close spt_close +# define SPT_THREAD_SIGNAL 1 +# define SPT_THREAD_AWARE 1 +# include +# undef close +# define close spt_close /* # define get_last_socket_error() errno # define clear_socket_error() errno=0 @@ -341,25 +343,26 @@ inline int nssgetpid() # define readsocket(s,b,n) read((s),(char*)(b),(n)) # define writesocket(s,b,n) write((s),(char*)(b),(n) */ -# define accept(a, b, c) accept(a, (struct sockaddr *)b, c) -# define recvfrom(a, b, c, d, e, f) recvfrom(a, b, (socklen_t)c, d, e, f) -# endif +# define accept(a, b, c) accept(a, (struct sockaddr *)b, c) +# define recvfrom(a, b, c, d, e, f) recvfrom(a, b, (socklen_t)c, d, e, f) +# endif #endif #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -# define CRYPTO_memcmp memcmp +# define CRYPTO_memcmp memcmp #endif #ifndef OPENSSL_NO_SECURE_MEMORY /* unistd.h defines _POSIX_VERSION */ -# if (defined(OPENSSL_SYS_UNIX) \ - && ((defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__sun) \ - || defined(__hpux) || defined(__sgi) || defined(__osf__))) \ - || defined(_WIN32) +# if (defined(OPENSSL_SYS_UNIX) \ + && ((defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ + || defined(__sun) || defined(__hpux) || defined(__sgi) \ + || defined(__osf__))) \ + || defined(_WIN32) /* secure memory is implemented */ -# else -# define OPENSSL_NO_SECURE_MEMORY -# endif +# else +# define OPENSSL_NO_SECURE_MEMORY +# endif #endif /* @@ -369,16 +372,17 @@ inline int nssgetpid() * There is no locale_t on NONSTOP. */ #if defined(OPENSSL_SYS_WINDOWS) -# define locale_t _locale_t -# define freelocale _free_locale -# define strcasecmp_l _stricmp_l -# define strncasecmp_l _strnicmp_l -# define strcasecmp _stricmp -# define strncasecmp _strnicmp -#elif !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L || defined(OPENSSL_SYS_TANDEM) -# ifndef OPENSSL_NO_LOCALE -# define OPENSSL_NO_LOCALE -# endif +# define locale_t _locale_t +# define freelocale _free_locale +# define strcasecmp_l _stricmp_l +# define strncasecmp_l _strnicmp_l +# define strcasecmp _stricmp +# define strncasecmp _strnicmp +#elif !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L \ + || defined(OPENSSL_SYS_TANDEM) +# ifndef OPENSSL_NO_LOCALE +# define OPENSSL_NO_LOCALE +# endif #endif #endif diff --git a/libs/OpenSSL/include/internal/endian.h b/libs/OpenSSL/include/internal/endian.h index 5fabcc11..19358b63 100644 --- a/libs/OpenSSL/include/internal/endian.h +++ b/libs/OpenSSL/include/internal/endian.h @@ -22,32 +22,32 @@ */ #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) -# define DECLARE_IS_ENDIAN \ - const int ossl_is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define IS_LITTLE_ENDIAN (ossl_is_little_endian) -# define IS_BIG_ENDIAN (!ossl_is_little_endian) -# if defined(L_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) -# error "L_ENDIAN defined on a big endian machine" -# endif -# if defined(B_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -# error "B_ENDIAN defined on a little endian machine" -# endif -# if !defined(L_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -# define L_ENDIAN -# endif -# if !defined(B_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) -# define B_ENDIAN -# endif +# define DECLARE_IS_ENDIAN \ + const int ossl_is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define IS_LITTLE_ENDIAN (ossl_is_little_endian) +# define IS_BIG_ENDIAN (!ossl_is_little_endian) +# if defined(L_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) +# error "L_ENDIAN defined on a big endian machine" +# endif +# if defined(B_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +# error "B_ENDIAN defined on a little endian machine" +# endif +# if !defined(L_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +# define L_ENDIAN +# endif +# if !defined(B_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) +# define B_ENDIAN +# endif #else -# define DECLARE_IS_ENDIAN \ - const union \ - { \ - long one; \ - char little; \ - } ossl_is_endian = { 1 } +# define DECLARE_IS_ENDIAN \ + const union \ + { \ + long one; \ + char little; \ + } ossl_is_endian = {1} -# define IS_LITTLE_ENDIAN (ossl_is_endian.little != 0) -# define IS_BIG_ENDIAN (ossl_is_endian.little == 0) +# define IS_LITTLE_ENDIAN (ossl_is_endian.little != 0) +# define IS_BIG_ENDIAN (ossl_is_endian.little == 0) #endif #endif diff --git a/libs/OpenSSL/include/internal/event_queue.h b/libs/OpenSSL/include/internal/event_queue.h index 45149ada..c7eb08e8 100644 --- a/libs/OpenSSL/include/internal/event_queue.h +++ b/libs/OpenSSL/include/internal/event_queue.h @@ -34,55 +34,59 @@ typedef struct ossl_event_queue_st OSSL_EVENT_QUEUE; */ struct ossl_event_st { - uint32_t type; /* What type of event this is */ - uint32_t priority; /* What priority this event has */ - OSSL_TIME when; /* When the event is scheduled to happen */ - void *ctx; /* User argument passed to call backs */ - void *payload; /* Event specific data of unknown kind */ - size_t payload_size; /* Length (in bytes) of event specific data */ + uint32_t type; /* What type of event this is */ + uint32_t priority; /* What priority this event has */ + OSSL_TIME when; /* When the event is scheduled to happen */ + void *ctx; /* User argument passed to call backs */ + void *payload; /* Event specific data of unknown kind */ + size_t payload_size; /* Length (in bytes) of event specific data */ - /* These fields are for internal use only */ - PRIORITY_QUEUE_OF(OSSL_EVENT) * queue; /* Queue containing this event */ - size_t ref; /* ID for this event */ - unsigned int flag_dynamic : 1; /* Malloced or not? */ + /* These fields are for internal use only */ + PRIORITY_QUEUE_OF(OSSL_EVENT) * queue; /* Queue containing this event */ + size_t ref; /* ID for this event */ + unsigned int flag_dynamic : 1; /* Malloced or not? */ }; /* * Utility function to populate an event structure and add it to the queue */ -int ossl_event_queue_add(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event, uint32_t type, - uint32_t priority, OSSL_TIME when, void *ctx, void *payload, - size_t payload_size); +int ossl_event_queue_add(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event, + uint32_t type, uint32_t priority, OSSL_TIME when, + void *ctx, void *payload, size_t payload_size); /* * Utility functions to extract event fields */ -static ossl_unused ossl_inline uint32_t ossl_event_get_type(const OSSL_EVENT *event) +static ossl_unused ossl_inline uint32_t +ossl_event_get_type(const OSSL_EVENT *event) { - return event->type; + return event->type; } -static ossl_unused ossl_inline uint32_t ossl_event_get_priority(const OSSL_EVENT *event) +static ossl_unused ossl_inline uint32_t +ossl_event_get_priority(const OSSL_EVENT *event) { - return event->priority; + return event->priority; } -static ossl_unused ossl_inline OSSL_TIME ossl_event_get_when(const OSSL_EVENT *event) +static ossl_unused ossl_inline OSSL_TIME +ossl_event_get_when(const OSSL_EVENT *event) { - return event->when; + return event->when; } -static ossl_unused ossl_inline void *ossl_event_get0_ctx(const OSSL_EVENT *event) +static ossl_unused ossl_inline void * +ossl_event_get0_ctx(const OSSL_EVENT *event) { - return event->ctx; + return event->ctx; } -static ossl_unused ossl_inline void *ossl_event_get0_payload(const OSSL_EVENT *event, - size_t *length) +static ossl_unused ossl_inline void * +ossl_event_get0_payload(const OSSL_EVENT *event, size_t *length) { - if (length != NULL) - *length = event->payload_size; - return event->payload; + if (length != NULL) + *length = event->payload_size; + return event->payload; } /* @@ -98,8 +102,10 @@ void ossl_event_queue_free(OSSL_EVENT_QUEUE *queue); * * The function reutrns NULL on failure and the added event on success. */ -OSSL_EVENT *ossl_event_queue_add_new(OSSL_EVENT_QUEUE *queue, uint32_t type, uint32_t priority, - OSSL_TIME when, void *ctx, void *payload, size_t payload_size); +OSSL_EVENT *ossl_event_queue_add_new(OSSL_EVENT_QUEUE *queue, uint32_t type, + uint32_t priority, OSSL_TIME when, + void *ctx, void *payload, + size_t payload_size); /* * Schedule an event into an event queue. @@ -108,9 +114,9 @@ OSSL_EVENT *ossl_event_queue_add_new(OSSL_EVENT_QUEUE *queue, uint32_t type, uin * * The function reutrns 0 on failure and 1 on success. */ -int ossl_event_queue_add(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event, uint32_t type, - uint32_t priority, OSSL_TIME when, void *ctx, void *payload, - size_t payload_size); +int ossl_event_queue_add(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event, + uint32_t type, uint32_t priority, OSSL_TIME when, + void *ctx, void *payload, size_t payload_size); /* * Delete an event from the queue. @@ -142,11 +148,13 @@ OSSL_TIME ossl_event_queue_time_until_next(const OSSL_EVENT_QUEUE *queue); * Postpone an event to trigger at the specified time. * If the event has triggered, this function's behaviour is undefined. */ -int ossl_event_queue_postpone_until(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event, OSSL_TIME when); +int ossl_event_queue_postpone_until(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event, + OSSL_TIME when); /* * Return the next event to process. */ -int ossl_event_queue_get1_next_event(OSSL_EVENT_QUEUE *queue, OSSL_EVENT **event); +int ossl_event_queue_get1_next_event(OSSL_EVENT_QUEUE *queue, + OSSL_EVENT **event); #endif diff --git a/libs/OpenSSL/include/internal/ffc.h b/libs/OpenSSL/include/internal/ffc.h index de704581..2e6e4f8e 100644 --- a/libs/OpenSSL/include/internal/ffc.h +++ b/libs/OpenSSL/include/internal/ffc.h @@ -42,7 +42,8 @@ /* Validation flags */ #define FFC_PARAM_FLAG_VALIDATE_PQ 0x01 #define FFC_PARAM_FLAG_VALIDATE_G 0x02 -#define FFC_PARAM_FLAG_VALIDATE_PQG (FFC_PARAM_FLAG_VALIDATE_PQ | FFC_PARAM_FLAG_VALIDATE_G) +#define FFC_PARAM_FLAG_VALIDATE_PQG \ + (FFC_PARAM_FLAG_VALIDATE_PQ | FFC_PARAM_FLAG_VALIDATE_G) #define FFC_PARAM_FLAG_VALIDATE_LEGACY 0x04 /* @@ -82,58 +83,63 @@ */ typedef struct ffc_params_st { - /* Primes */ - BIGNUM *p; - BIGNUM *q; - /* Generator */ - BIGNUM *g; - /* DH X9.42 Optional Subgroup factor j >= 2 where p = j * q + 1 */ - BIGNUM *j; + /* Primes */ + BIGNUM *p; + BIGNUM *q; + /* Generator */ + BIGNUM *g; + /* DH X9.42 Optional Subgroup factor j >= 2 where p = j * q + 1 */ + BIGNUM *j; - /* Required for FIPS186_4 validation of p, q and optionally canonical g */ - unsigned char *seed; - /* If this value is zero the hash size is used as the seed length */ - size_t seedlen; - /* Required for FIPS186_4 validation of p and q */ - int pcounter; - int nid; /* The identity of a named group */ + /* Required for FIPS186_4 validation of p, q and optionally canonical g */ + unsigned char *seed; + /* If this value is zero the hash size is used as the seed length */ + size_t seedlen; + /* Required for FIPS186_4 validation of p and q */ + int pcounter; + int nid; /* The identity of a named group */ - /* - * Required for FIPS186_4 generation & validation of canonical g. - * It uses unverifiable g if this value is -1. - */ - int gindex; - int h; /* loop counter for unverifiable g */ + /* + * Required for FIPS186_4 generation & validation of canonical g. + * It uses unverifiable g if this value is -1. + */ + int gindex; + int h; /* loop counter for unverifiable g */ - unsigned int flags; - /* - * The digest to use for generation or validation. If this value is NULL, - * then the digest is chosen using the value of N. - */ - const char *mdname; - const char *mdprops; - /* Default key length for known named groups according to RFC7919 */ - int keylength; + unsigned int flags; + /* + * The digest to use for generation or validation. If this value is NULL, + * then the digest is chosen using the value of N. + */ + const char *mdname; + const char *mdprops; + /* Default key length for known named groups according to RFC7919 */ + int keylength; } FFC_PARAMS; void ossl_ffc_params_init(FFC_PARAMS *params); void ossl_ffc_params_cleanup(FFC_PARAMS *params); -void ossl_ffc_params_set0_pqg(FFC_PARAMS *params, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void ossl_ffc_params_get0_pqg(const FFC_PARAMS *params, const BIGNUM **p, const BIGNUM **q, - const BIGNUM **g); +void ossl_ffc_params_set0_pqg(FFC_PARAMS *params, BIGNUM *p, BIGNUM *q, + BIGNUM *g); +void ossl_ffc_params_get0_pqg(const FFC_PARAMS *params, const BIGNUM **p, + const BIGNUM **q, const BIGNUM **g); void ossl_ffc_params_set0_j(FFC_PARAMS *d, BIGNUM *j); -int ossl_ffc_params_set_seed(FFC_PARAMS *params, const unsigned char *seed, size_t seedlen); +int ossl_ffc_params_set_seed(FFC_PARAMS *params, const unsigned char *seed, + size_t seedlen); void ossl_ffc_params_set_gindex(FFC_PARAMS *params, int index); void ossl_ffc_params_set_pcounter(FFC_PARAMS *params, int index); void ossl_ffc_params_set_h(FFC_PARAMS *params, int index); void ossl_ffc_params_set_flags(FFC_PARAMS *params, unsigned int flags); -void ossl_ffc_params_enable_flags(FFC_PARAMS *params, unsigned int flags, int enable); +void ossl_ffc_params_enable_flags(FFC_PARAMS *params, unsigned int flags, + int enable); int ossl_ffc_set_digest(FFC_PARAMS *params, const char *alg, const char *props); -int ossl_ffc_params_set_validate_params(FFC_PARAMS *params, const unsigned char *seed, +int ossl_ffc_params_set_validate_params(FFC_PARAMS *params, + const unsigned char *seed, size_t seedlen, int counter); -void ossl_ffc_params_get_validate_params(const FFC_PARAMS *params, unsigned char **seed, - size_t *seedlen, int *pcounter); +void ossl_ffc_params_get_validate_params(const FFC_PARAMS *params, + unsigned char **seed, size_t *seedlen, + int *pcounter); int ossl_ffc_params_copy(FFC_PARAMS *dst, const FFC_PARAMS *src); int ossl_ffc_params_cmp(const FFC_PARAMS *a, const FFC_PARAMS *b, int ignore_q); @@ -142,44 +148,60 @@ int ossl_ffc_params_cmp(const FFC_PARAMS *a, const FFC_PARAMS *b, int ignore_q); int ossl_ffc_params_print(BIO *bp, const FFC_PARAMS *ffc, int indent); #endif /* FIPS_MODULE */ -int ossl_ffc_params_FIPS186_4_generate(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, int type, size_t L, - size_t N, int *res, BN_GENCB *cb); -int ossl_ffc_params_FIPS186_2_generate(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, int type, size_t L, - size_t N, int *res, BN_GENCB *cb); +int ossl_ffc_params_FIPS186_4_generate(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, + int type, size_t L, size_t N, int *res, + BN_GENCB *cb); +int ossl_ffc_params_FIPS186_2_generate(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, + int type, size_t L, size_t N, int *res, + BN_GENCB *cb); -int ossl_ffc_params_FIPS186_4_gen_verify(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, int mode, - int type, size_t L, size_t N, int *res, BN_GENCB *cb); -int ossl_ffc_params_FIPS186_2_gen_verify(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, int mode, - int type, size_t L, size_t N, int *res, BN_GENCB *cb); +int ossl_ffc_params_FIPS186_4_gen_verify(OSSL_LIB_CTX *libctx, + FFC_PARAMS *params, int mode, int type, + size_t L, size_t N, int *res, + BN_GENCB *cb); +int ossl_ffc_params_FIPS186_2_gen_verify(OSSL_LIB_CTX *libctx, + FFC_PARAMS *params, int mode, int type, + size_t L, size_t N, int *res, + BN_GENCB *cb); -int ossl_ffc_params_simple_validate(OSSL_LIB_CTX *libctx, const FFC_PARAMS *params, int paramstype, +int ossl_ffc_params_simple_validate(OSSL_LIB_CTX *libctx, + const FFC_PARAMS *params, int paramstype, int *res); -int ossl_ffc_params_full_validate(OSSL_LIB_CTX *libctx, const FFC_PARAMS *params, int paramstype, +int ossl_ffc_params_full_validate(OSSL_LIB_CTX *libctx, + const FFC_PARAMS *params, int paramstype, int *res); -int ossl_ffc_params_FIPS186_4_validate(OSSL_LIB_CTX *libctx, const FFC_PARAMS *params, int type, +int ossl_ffc_params_FIPS186_4_validate(OSSL_LIB_CTX *libctx, + const FFC_PARAMS *params, int type, int *res, BN_GENCB *cb); -int ossl_ffc_params_FIPS186_2_validate(OSSL_LIB_CTX *libctx, const FFC_PARAMS *params, int type, +int ossl_ffc_params_FIPS186_2_validate(OSSL_LIB_CTX *libctx, + const FFC_PARAMS *params, int type, int *res, BN_GENCB *cb); -int ossl_ffc_generate_private_key(BN_CTX *ctx, const FFC_PARAMS *params, int N, int s, - BIGNUM *priv); +int ossl_ffc_generate_private_key(BN_CTX *ctx, const FFC_PARAMS *params, int N, + int s, BIGNUM *priv); -int ossl_ffc_params_validate_unverifiable_g(BN_CTX *ctx, BN_MONT_CTX *mont, const BIGNUM *p, - const BIGNUM *q, const BIGNUM *g, BIGNUM *tmp, +int ossl_ffc_params_validate_unverifiable_g(BN_CTX *ctx, BN_MONT_CTX *mont, + const BIGNUM *p, const BIGNUM *q, + const BIGNUM *g, BIGNUM *tmp, int *ret); -int ossl_ffc_validate_public_key(const FFC_PARAMS *params, const BIGNUM *pub_key, int *ret); -int ossl_ffc_validate_public_key_partial(const FFC_PARAMS *params, const BIGNUM *pub_key, int *ret); -int ossl_ffc_validate_private_key(const BIGNUM *upper, const BIGNUM *priv_key, int *ret); +int ossl_ffc_validate_public_key(const FFC_PARAMS *params, + const BIGNUM *pub_key, int *ret); +int ossl_ffc_validate_public_key_partial(const FFC_PARAMS *params, + const BIGNUM *pub_key, int *ret); +int ossl_ffc_validate_private_key(const BIGNUM *upper, const BIGNUM *priv_key, + int *ret); -int ossl_ffc_params_todata(const FFC_PARAMS *ffc, OSSL_PARAM_BLD *tmpl, OSSL_PARAM params[]); +int ossl_ffc_params_todata(const FFC_PARAMS *ffc, OSSL_PARAM_BLD *tmpl, + OSSL_PARAM params[]); int ossl_ffc_params_fromdata(FFC_PARAMS *ffc, const OSSL_PARAM params[]); typedef struct dh_named_group_st DH_NAMED_GROUP; const DH_NAMED_GROUP *ossl_ffc_name_to_dh_named_group(const char *name); const DH_NAMED_GROUP *ossl_ffc_uid_to_dh_named_group(int uid); #ifndef OPENSSL_NO_DH -const DH_NAMED_GROUP *ossl_ffc_numbers_to_dh_named_group(const BIGNUM *p, const BIGNUM *q, +const DH_NAMED_GROUP *ossl_ffc_numbers_to_dh_named_group(const BIGNUM *p, + const BIGNUM *q, const BIGNUM *g); #endif int ossl_ffc_named_group_get_uid(const DH_NAMED_GROUP *group); diff --git a/libs/OpenSSL/include/internal/hpke_util.h b/libs/OpenSSL/include/internal/hpke_util.h index 4e2a65cb..112eb2a1 100644 --- a/libs/OpenSSL/include/internal/hpke_util.h +++ b/libs/OpenSSL/include/internal/hpke_util.h @@ -30,15 +30,15 @@ */ typedef struct { - uint16_t kem_id; /* code point for key encipherment method */ - const char *keytype; /* string form of algtype "EC"/"X25519"/"X448" */ - const char *groupname; /* string form of EC group for NIST curves */ - const char *mdname; /* hash alg name for the HKDF */ - size_t Nsecret; /* size of secrets */ - size_t Nenc; /* length of encapsulated key */ - size_t Npk; /* length of public key */ - size_t Nsk; /* length of raw private key */ - uint8_t bitmask; + uint16_t kem_id; /* code point for key encipherment method */ + const char *keytype; /* string form of algtype "EC"/"X25519"/"X448" */ + const char *groupname; /* string form of EC group for NIST curves */ + const char *mdname; /* hash alg name for the HKDF */ + size_t Nsecret; /* size of secrets */ + size_t Nenc; /* length of encapsulated key */ + size_t Npk; /* length of public key */ + size_t Nsk; /* length of raw private key */ + uint8_t bitmask; } OSSL_HPKE_KEM_INFO; /* @@ -46,9 +46,9 @@ typedef struct */ typedef struct { - uint16_t kdf_id; /* code point for KDF */ - const char *mdname; /* hash alg name for the HKDF */ - size_t Nh; /* length of hash/extract output */ + uint16_t kdf_id; /* code point for KDF */ + const char *mdname; /* hash alg name for the HKDF */ + size_t Nh; /* length of hash/extract output */ } OSSL_HPKE_KDF_INFO; /* @@ -56,11 +56,11 @@ typedef struct */ typedef struct { - uint16_t aead_id; /* code point for aead alg */ - const char *name; /* alg name */ - size_t taglen; /* aead tag len */ - size_t Nk; /* size of a key for this aead */ - size_t Nn; /* length of a nonce for this aead */ + uint16_t aead_id; /* code point for aead alg */ + const char *name; /* alg name */ + size_t taglen; /* aead tag len */ + size_t Nk; /* size of a key for this aead */ + size_t Nn; /* length of a nonce for this aead */ } OSSL_HPKE_AEAD_INFO; const OSSL_HPKE_KEM_INFO *ossl_HPKE_KEM_INFO_find_curve(const char *curve); @@ -72,24 +72,28 @@ const OSSL_HPKE_AEAD_INFO *ossl_HPKE_AEAD_INFO_find_id(uint16_t aeadid); const OSSL_HPKE_AEAD_INFO *ossl_HPKE_AEAD_INFO_find_random(OSSL_LIB_CTX *ctx); int ossl_hpke_kdf_extract(EVP_KDF_CTX *kctx, unsigned char *prk, size_t prklen, - const unsigned char *salt, size_t saltlen, const unsigned char *ikm, - size_t ikmlen); + const unsigned char *salt, size_t saltlen, + const unsigned char *ikm, size_t ikmlen); int ossl_hpke_kdf_expand(EVP_KDF_CTX *kctx, unsigned char *okm, size_t okmlen, - const unsigned char *prk, size_t prklen, const unsigned char *info, - size_t infolen); + const unsigned char *prk, size_t prklen, + const unsigned char *info, size_t infolen); -int ossl_hpke_labeled_extract(EVP_KDF_CTX *kctx, unsigned char *prk, size_t prklen, - const unsigned char *salt, size_t saltlen, const char *protocol_label, - const unsigned char *suiteid, size_t suiteidlen, const char *label, - const unsigned char *ikm, size_t ikmlen); -int ossl_hpke_labeled_expand(EVP_KDF_CTX *kctx, unsigned char *okm, size_t okmlen, - const unsigned char *prk, size_t prklen, const char *protocol_label, - const unsigned char *suiteid, size_t suiteidlen, const char *label, - const unsigned char *info, size_t infolen); +int ossl_hpke_labeled_extract(EVP_KDF_CTX *kctx, unsigned char *prk, + size_t prklen, const unsigned char *salt, + size_t saltlen, const char *protocol_label, + const unsigned char *suiteid, size_t suiteidlen, + const char *label, const unsigned char *ikm, + size_t ikmlen); +int ossl_hpke_labeled_expand(EVP_KDF_CTX *kctx, unsigned char *okm, + size_t okmlen, const unsigned char *prk, + size_t prklen, const char *protocol_label, + const unsigned char *suiteid, size_t suiteidlen, + const char *label, const unsigned char *info, + size_t infolen); -EVP_KDF_CTX *ossl_kdf_ctx_create(const char *kdfname, const char *mdname, OSSL_LIB_CTX *libctx, - const char *propq); +EVP_KDF_CTX *ossl_kdf_ctx_create(const char *kdfname, const char *mdname, + OSSL_LIB_CTX *libctx, const char *propq); int ossl_hpke_str2suite(const char *suitestr, OSSL_HPKE_SUITE *suite); #endif diff --git a/libs/OpenSSL/include/internal/ktls.h b/libs/OpenSSL/include/internal/ktls.h index ade54346..054b525e 100644 --- a/libs/OpenSSL/include/internal/ktls.h +++ b/libs/OpenSSL/include/internal/ktls.h @@ -8,43 +8,43 @@ */ #if defined(OPENSSL_SYS_LINUX) -# ifndef OPENSSL_NO_KTLS -# include -# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) -# define OPENSSL_NO_KTLS -# ifndef PEDANTIC -# warning "KTLS requires Kernel Headers >= 4.13.0" -# warning "Skipping Compilation of KTLS" -# endif -# endif +# ifndef OPENSSL_NO_KTLS +# include +# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) +# define OPENSSL_NO_KTLS +# ifndef PEDANTIC +# warning "KTLS requires Kernel Headers >= 4.13.0" +# warning "Skipping Compilation of KTLS" +# endif # endif +# endif #endif #ifndef HEADER_INTERNAL_KTLS -# define HEADER_INTERNAL_KTLS -# pragma once +# define HEADER_INTERNAL_KTLS +# pragma once -# ifndef OPENSSL_NO_KTLS +# ifndef OPENSSL_NO_KTLS -# if defined(__FreeBSD__) -# include -# include -# include -# include -# include -# include +# if defined(__FreeBSD__) +# include +# include +# include +# include +# include +# include -# ifndef TCP_RXTLS_ENABLE -# define OPENSSL_NO_KTLS_RX -# endif -# define OPENSSL_KTLS_AES_GCM_128 -# define OPENSSL_KTLS_AES_GCM_256 -# define OPENSSL_KTLS_TLS13 -# ifdef TLS_CHACHA20_IV_LEN -# ifndef OPENSSL_NO_CHACHA -# define OPENSSL_KTLS_CHACHA20_POLY1305 -# endif -# endif +# ifndef TCP_RXTLS_ENABLE +# define OPENSSL_NO_KTLS_RX +# endif +# define OPENSSL_KTLS_AES_GCM_128 +# define OPENSSL_KTLS_AES_GCM_256 +# define OPENSSL_KTLS_TLS13 +# ifdef TLS_CHACHA20_IV_LEN +# ifndef OPENSSL_NO_CHACHA +# define OPENSSL_KTLS_CHACHA20_POLY1305 +# endif +# endif typedef struct tls_enable ktls_crypto_info_t; @@ -54,7 +54,7 @@ typedef struct tls_enable ktls_crypto_info_t; */ static ossl_inline int ktls_enable(int fd) { - return 1; + return 1; } /* @@ -69,13 +69,18 @@ static ossl_inline int ktls_enable(int fd) */ static ossl_inline int ktls_start(int fd, ktls_crypto_info_t *tls_en, int is_tx) { - if (is_tx) - return setsockopt(fd, IPPROTO_TCP, TCP_TXTLS_ENABLE, tls_en, sizeof(*tls_en)) ? 0 : 1; -# ifndef OPENSSL_NO_KTLS_RX - return setsockopt(fd, IPPROTO_TCP, TCP_RXTLS_ENABLE, tls_en, sizeof(*tls_en)) ? 0 : 1; -# else - return 0; -# endif + if (is_tx) + return setsockopt(fd, IPPROTO_TCP, TCP_TXTLS_ENABLE, tls_en, + sizeof(*tls_en)) + ? 0 + : 1; +# ifndef OPENSSL_NO_KTLS_RX + return setsockopt(fd, IPPROTO_TCP, TCP_RXTLS_ENABLE, tls_en, sizeof(*tls_en)) + ? 0 + : 1; +# else + return 0; +# endif } /* @@ -85,40 +90,40 @@ static ossl_inline int ktls_start(int fd, ktls_crypto_info_t *tls_en, int is_tx) * the entire record is pushed to TCP. It is impossible to send a partial * record using this control message. */ -static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, const void *data, - size_t length) +static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, + const void *data, size_t length) { - struct msghdr msg = { 0 }; - int cmsg_len = sizeof(record_type); - struct cmsghdr *cmsg; - char buf[CMSG_SPACE(cmsg_len)]; - struct iovec msg_iov; /* Vector of data to send/receive into */ + struct msghdr msg = {0}; + int cmsg_len = sizeof(record_type); + struct cmsghdr *cmsg; + char buf[CMSG_SPACE(cmsg_len)]; + struct iovec msg_iov; /* Vector of data to send/receive into */ - msg.msg_control = buf; - msg.msg_controllen = sizeof(buf); - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = IPPROTO_TCP; - cmsg->cmsg_type = TLS_SET_RECORD_TYPE; - cmsg->cmsg_len = CMSG_LEN(cmsg_len); - *((unsigned char *)CMSG_DATA(cmsg)) = record_type; - msg.msg_controllen = cmsg->cmsg_len; + msg.msg_control = buf; + msg.msg_controllen = sizeof(buf); + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_level = IPPROTO_TCP; + cmsg->cmsg_type = TLS_SET_RECORD_TYPE; + cmsg->cmsg_len = CMSG_LEN(cmsg_len); + *((unsigned char *)CMSG_DATA(cmsg)) = record_type; + msg.msg_controllen = cmsg->cmsg_len; - msg_iov.iov_base = (void *)data; - msg_iov.iov_len = length; - msg.msg_iov = &msg_iov; - msg.msg_iovlen = 1; + msg_iov.iov_base = (void *)data; + msg_iov.iov_len = length; + msg.msg_iov = &msg_iov; + msg.msg_iovlen = 1; - return sendmsg(fd, &msg, 0); + return sendmsg(fd, &msg, 0); } -# ifdef OPENSSL_NO_KTLS_RX +# ifdef OPENSSL_NO_KTLS_RX static ossl_inline int ktls_read_record(int fd, void *data, size_t length) { - return -1; + return -1; } -# else /* !defined(OPENSSL_NO_KTLS_RX) */ +# else /* !defined(OPENSSL_NO_KTLS_RX) */ /* * Receive a TLS record using the tls_en provided in ktls_start. The @@ -129,150 +134,152 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) */ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) { - struct msghdr msg = { 0 }; - int cmsg_len = sizeof(struct tls_get_record); - struct tls_get_record *tgr; - struct cmsghdr *cmsg; - char buf[CMSG_SPACE(cmsg_len)]; - struct iovec msg_iov; /* Vector of data to send/receive into */ - int ret; - unsigned char *p = data; - const size_t prepend_length = SSL3_RT_HEADER_LENGTH; + struct msghdr msg = {0}; + int cmsg_len = sizeof(struct tls_get_record); + struct tls_get_record *tgr; + struct cmsghdr *cmsg; + char buf[CMSG_SPACE(cmsg_len)]; + struct iovec msg_iov; /* Vector of data to send/receive into */ + int ret; + unsigned char *p = data; + const size_t prepend_length = SSL3_RT_HEADER_LENGTH; - if (length <= prepend_length) - { - errno = EINVAL; - return -1; - } + if (length <= prepend_length) + { + errno = EINVAL; + return -1; + } - msg.msg_control = buf; - msg.msg_controllen = sizeof(buf); + msg.msg_control = buf; + msg.msg_controllen = sizeof(buf); - msg_iov.iov_base = p + prepend_length; - msg_iov.iov_len = length - prepend_length; - msg.msg_iov = &msg_iov; - msg.msg_iovlen = 1; + msg_iov.iov_base = p + prepend_length; + msg_iov.iov_len = length - prepend_length; + msg.msg_iov = &msg_iov; + msg.msg_iovlen = 1; - ret = recvmsg(fd, &msg, 0); - if (ret <= 0) - return ret; + ret = recvmsg(fd, &msg, 0); + if (ret <= 0) + return ret; - if ((msg.msg_flags & (MSG_EOR | MSG_CTRUNC)) != MSG_EOR) - { - errno = EMSGSIZE; - return -1; - } + if ((msg.msg_flags & (MSG_EOR | MSG_CTRUNC)) != MSG_EOR) + { + errno = EMSGSIZE; + return -1; + } - if (msg.msg_controllen == 0) - { - errno = EBADMSG; - return -1; - } + if (msg.msg_controllen == 0) + { + errno = EBADMSG; + return -1; + } - cmsg = CMSG_FIRSTHDR(&msg); - if (cmsg->cmsg_level != IPPROTO_TCP || cmsg->cmsg_type != TLS_GET_RECORD - || cmsg->cmsg_len != CMSG_LEN(cmsg_len)) - { - errno = EBADMSG; - return -1; - } + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_level != IPPROTO_TCP || cmsg->cmsg_type != TLS_GET_RECORD + || cmsg->cmsg_len != CMSG_LEN(cmsg_len)) + { + errno = EBADMSG; + return -1; + } - tgr = (struct tls_get_record *)CMSG_DATA(cmsg); - p[0] = tgr->tls_type; - p[1] = tgr->tls_vmajor; - p[2] = tgr->tls_vminor; - *(uint16_t *)(p + 3) = htons(ret); + tgr = (struct tls_get_record *)CMSG_DATA(cmsg); + p[0] = tgr->tls_type; + p[1] = tgr->tls_vmajor; + p[2] = tgr->tls_vminor; + *(uint16_t *)(p + 3) = htons(ret); - return ret + prepend_length; + return ret + prepend_length; } -# endif /* OPENSSL_NO_KTLS_RX */ +# endif /* OPENSSL_NO_KTLS_RX */ /* * KTLS enables the sendfile system call to send data from a file over * TLS. */ -static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags) +static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, + size_t size, int flags) { - off_t sbytes = 0; - int ret; + off_t sbytes = 0; + int ret; - ret = sendfile(fd, s, off, size, NULL, &sbytes, flags); - if (ret == -1 && sbytes == 0) - return -1; - return sbytes; + ret = sendfile(fd, s, off, size, NULL, &sbytes, flags); + if (ret == -1 && sbytes == 0) + return -1; + return sbytes; } -# endif /* __FreeBSD__ */ +# endif /* __FreeBSD__ */ -# if defined(OPENSSL_SYS_LINUX) +# if defined(OPENSSL_SYS_LINUX) -# include -# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) -# define OPENSSL_NO_KTLS_RX -# ifndef PEDANTIC -# warning "KTLS requires Kernel Headers >= 4.17.0 for receiving" -# warning "Skipping Compilation of KTLS receive data path" -# endif -# endif -# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) -# define OPENSSL_NO_KTLS_ZC_TX -# ifndef PEDANTIC -# warning "KTLS requires Kernel Headers >= 5.19.0 for zerocopy sendfile" -# warning "Skipping Compilation of KTLS zerocopy sendfile" -# endif -# endif -# define OPENSSL_KTLS_AES_GCM_128 -# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) -# define OPENSSL_KTLS_AES_GCM_256 -# define OPENSSL_KTLS_TLS13 -# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) -# define OPENSSL_KTLS_AES_CCM_128 -# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) -# ifndef OPENSSL_NO_CHACHA -# define OPENSSL_KTLS_CHACHA20_POLY1305 -# endif -# endif -# endif +# include +# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) +# define OPENSSL_NO_KTLS_RX +# ifndef PEDANTIC +# warning "KTLS requires Kernel Headers >= 4.17.0 for receiving" +# warning "Skipping Compilation of KTLS receive data path" +# endif +# endif +# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) +# define OPENSSL_NO_KTLS_ZC_TX +# ifndef PEDANTIC +# warning \ + "KTLS requires Kernel Headers >= 5.19.0 for zerocopy sendfile" +# warning "Skipping Compilation of KTLS zerocopy sendfile" +# endif +# endif +# define OPENSSL_KTLS_AES_GCM_128 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) +# define OPENSSL_KTLS_AES_GCM_256 +# define OPENSSL_KTLS_TLS13 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) +# define OPENSSL_KTLS_AES_CCM_128 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) +# ifndef OPENSSL_NO_CHACHA +# define OPENSSL_KTLS_CHACHA20_POLY1305 # endif +# endif +# endif +# endif -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include -# ifndef SOL_TLS -# define SOL_TLS 282 -# endif +# ifndef SOL_TLS +# define SOL_TLS 282 +# endif -# ifndef TCP_ULP -# define TCP_ULP 31 -# endif +# ifndef TCP_ULP +# define TCP_ULP 31 +# endif -# ifndef TLS_RX -# define TLS_RX 2 -# endif +# ifndef TLS_RX +# define TLS_RX 2 +# endif struct tls_crypto_info_all { - union - { -# ifdef OPENSSL_KTLS_AES_GCM_128 - struct tls12_crypto_info_aes_gcm_128 gcm128; -# endif -# ifdef OPENSSL_KTLS_AES_GCM_256 - struct tls12_crypto_info_aes_gcm_256 gcm256; -# endif -# ifdef OPENSSL_KTLS_AES_CCM_128 - struct tls12_crypto_info_aes_ccm_128 ccm128; -# endif -# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 - struct tls12_crypto_info_chacha20_poly1305 chacha20poly1305; -# endif - }; - size_t tls_crypto_info_len; + union + { +# ifdef OPENSSL_KTLS_AES_GCM_128 + struct tls12_crypto_info_aes_gcm_128 gcm128; +# endif +# ifdef OPENSSL_KTLS_AES_GCM_256 + struct tls12_crypto_info_aes_gcm_256 gcm256; +# endif +# ifdef OPENSSL_KTLS_AES_CCM_128 + struct tls12_crypto_info_aes_ccm_128 ccm128; +# endif +# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 + struct tls12_crypto_info_chacha20_poly1305 chacha20poly1305; +# endif + }; + size_t tls_crypto_info_len; }; typedef struct tls_crypto_info_all ktls_crypto_info_t; @@ -285,7 +292,7 @@ typedef struct tls_crypto_info_all ktls_crypto_info_t; */ static ossl_inline int ktls_enable(int fd) { - return setsockopt(fd, SOL_TCP, TCP_ULP, "tls", sizeof("tls")) ? 0 : 1; + return setsockopt(fd, SOL_TCP, TCP_ULP, "tls", sizeof("tls")) ? 0 : 1; } /* @@ -296,23 +303,26 @@ static ossl_inline int ktls_enable(int fd) * If successful, then data received using this socket will be decrypted, * authenticated and decapsulated using the crypto_info provided here. */ -static ossl_inline int ktls_start(int fd, ktls_crypto_info_t *crypto_info, int is_tx) +static ossl_inline int ktls_start(int fd, ktls_crypto_info_t *crypto_info, + int is_tx) { - return setsockopt(fd, SOL_TLS, is_tx ? TLS_TX : TLS_RX, crypto_info, - crypto_info->tls_crypto_info_len) - ? 0 - : 1; + return setsockopt(fd, SOL_TLS, is_tx ? TLS_TX : TLS_RX, crypto_info, + crypto_info->tls_crypto_info_len) + ? 0 + : 1; } static ossl_inline int ktls_enable_tx_zerocopy_sendfile(int fd) { -# ifndef OPENSSL_NO_KTLS_ZC_TX - int enable = 1; +# ifndef OPENSSL_NO_KTLS_ZC_TX + int enable = 1; - return setsockopt(fd, SOL_TLS, TLS_TX_ZEROCOPY_RO, &enable, sizeof(enable)) ? 0 : 1; -# else - return 0; -# endif + return setsockopt(fd, SOL_TLS, TLS_TX_ZEROCOPY_RO, &enable, sizeof(enable)) + ? 0 + : 1; +# else + return 0; +# endif } /* @@ -322,54 +332,55 @@ static ossl_inline int ktls_enable_tx_zerocopy_sendfile(int fd) * the entire record is pushed to TCP. It is impossible to send a partial * record using this control message. */ -static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, const void *data, - size_t length) +static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, + const void *data, size_t length) { - struct msghdr msg; - int cmsg_len = sizeof(record_type); - struct cmsghdr *cmsg; - union - { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(unsigned char))]; - } cmsgbuf; - struct iovec msg_iov; /* Vector of data to send/receive into */ + struct msghdr msg; + int cmsg_len = sizeof(record_type); + struct cmsghdr *cmsg; + union + { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(unsigned char))]; + } cmsgbuf; + struct iovec msg_iov; /* Vector of data to send/receive into */ - memset(&msg, 0, sizeof(msg)); - msg.msg_control = cmsgbuf.buf; - msg.msg_controllen = sizeof(cmsgbuf.buf); - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level = SOL_TLS; - cmsg->cmsg_type = TLS_SET_RECORD_TYPE; - cmsg->cmsg_len = CMSG_LEN(cmsg_len); - *((unsigned char *)CMSG_DATA(cmsg)) = record_type; - msg.msg_controllen = cmsg->cmsg_len; + memset(&msg, 0, sizeof(msg)); + msg.msg_control = cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_level = SOL_TLS; + cmsg->cmsg_type = TLS_SET_RECORD_TYPE; + cmsg->cmsg_len = CMSG_LEN(cmsg_len); + *((unsigned char *)CMSG_DATA(cmsg)) = record_type; + msg.msg_controllen = cmsg->cmsg_len; - msg_iov.iov_base = (void *)data; - msg_iov.iov_len = length; - msg.msg_iov = &msg_iov; - msg.msg_iovlen = 1; + msg_iov.iov_base = (void *)data; + msg_iov.iov_len = length; + msg.msg_iov = &msg_iov; + msg.msg_iovlen = 1; - return sendmsg(fd, &msg, 0); + return sendmsg(fd, &msg, 0); } /* * KTLS enables the sendfile system call to send data from a file over TLS. * @flags are ignored on Linux. (placeholder for FreeBSD sendfile) * */ -static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags) +static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, + size_t size, int flags) { - return sendfile(s, fd, &off, size); + return sendfile(s, fd, &off, size); } -# ifdef OPENSSL_NO_KTLS_RX +# ifdef OPENSSL_NO_KTLS_RX static ossl_inline int ktls_read_record(int fd, void *data, size_t length) { - return -1; + return -1; } -# else /* !defined(OPENSSL_NO_KTLS_RX) */ +# else /* !defined(OPENSSL_NO_KTLS_RX) */ /* * Receive a TLS record using the crypto_info provided in ktls_start. @@ -379,57 +390,57 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) */ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) { - struct msghdr msg; - struct cmsghdr *cmsg; - union - { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(unsigned char))]; - } cmsgbuf; - struct iovec msg_iov; - int ret; - unsigned char *p = data; - const size_t prepend_length = SSL3_RT_HEADER_LENGTH; + struct msghdr msg; + struct cmsghdr *cmsg; + union + { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(unsigned char))]; + } cmsgbuf; + struct iovec msg_iov; + int ret; + unsigned char *p = data; + const size_t prepend_length = SSL3_RT_HEADER_LENGTH; - if (length < prepend_length + EVP_GCM_TLS_TAG_LEN) - { - errno = EINVAL; - return -1; - } + if (length < prepend_length + EVP_GCM_TLS_TAG_LEN) + { + errno = EINVAL; + return -1; + } - memset(&msg, 0, sizeof(msg)); - msg.msg_control = cmsgbuf.buf; - msg.msg_controllen = sizeof(cmsgbuf.buf); + memset(&msg, 0, sizeof(msg)); + msg.msg_control = cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); - msg_iov.iov_base = p + prepend_length; - msg_iov.iov_len = length - prepend_length - EVP_GCM_TLS_TAG_LEN; - msg.msg_iov = &msg_iov; - msg.msg_iovlen = 1; - - ret = recvmsg(fd, &msg, 0); - if (ret < 0) - return ret; - - if (msg.msg_controllen > 0) - { - cmsg = CMSG_FIRSTHDR(&msg); - if (cmsg->cmsg_type == TLS_GET_RECORD_TYPE) - { - p[0] = *((unsigned char *)CMSG_DATA(cmsg)); - p[1] = TLS1_2_VERSION_MAJOR; - p[2] = TLS1_2_VERSION_MINOR; - /* returned length is limited to msg_iov.iov_len above */ - p[3] = (ret >> 8) & 0xff; - p[4] = ret & 0xff; - ret += prepend_length; - } - } + msg_iov.iov_base = p + prepend_length; + msg_iov.iov_len = length - prepend_length - EVP_GCM_TLS_TAG_LEN; + msg.msg_iov = &msg_iov; + msg.msg_iovlen = 1; + ret = recvmsg(fd, &msg, 0); + if (ret < 0) return ret; + + if (msg.msg_controllen > 0) + { + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_type == TLS_GET_RECORD_TYPE) + { + p[0] = *((unsigned char *)CMSG_DATA(cmsg)); + p[1] = TLS1_2_VERSION_MAJOR; + p[2] = TLS1_2_VERSION_MINOR; + /* returned length is limited to msg_iov.iov_len above */ + p[3] = (ret >> 8) & 0xff; + p[4] = ret & 0xff; + ret += prepend_length; + } + } + + return ret; } -# endif /* OPENSSL_NO_KTLS_RX */ +# endif /* OPENSSL_NO_KTLS_RX */ -# endif /* OPENSSL_SYS_LINUX */ -# endif /* OPENSSL_NO_KTLS */ -#endif /* HEADER_INTERNAL_KTLS */ +# endif /* OPENSSL_SYS_LINUX */ +# endif /* OPENSSL_NO_KTLS */ +#endif /* HEADER_INTERNAL_KTLS */ diff --git a/libs/OpenSSL/include/internal/list.h b/libs/OpenSSL/include/internal/list.h index 5acfd98d..940808b9 100644 --- a/libs/OpenSSL/include/internal/list.h +++ b/libs/OpenSSL/include/internal/list.h @@ -15,139 +15,148 @@ #include #ifdef NDEBUG -# define OSSL_LIST_DBG(x) +# define OSSL_LIST_DBG(x) #else -# define OSSL_LIST_DBG(x) x; +# define OSSL_LIST_DBG(x) x; #endif /* Define a list structure */ #define OSSL_LIST(name) OSSL_LIST_##name /* Define fields to include an element of a list */ -#define OSSL_LIST_MEMBER(name, type) \ - struct \ - { \ - type *next, *prev; \ - OSSL_LIST_DBG(struct ossl_list_st_##name *list) \ - } ossl_list_##name +#define OSSL_LIST_MEMBER(name, type) \ + struct \ + { \ + type *next, *prev; \ + OSSL_LIST_DBG(struct ossl_list_st_##name *list) \ + } ossl_list_##name -#define DEFINE_LIST_OF(name, type) \ - typedef struct ossl_list_st_##name OSSL_LIST(name); \ - struct ossl_list_st_##name \ - { \ - type *alpha, *omega; \ - size_t num_elems; \ - }; \ - static ossl_unused ossl_inline void ossl_list_##name##_init(OSSL_LIST(name) * list) \ - { \ - memset(list, 0, sizeof(*list)); \ - } \ - static ossl_unused ossl_inline void ossl_list_##name##_init_elem(type *elem) \ - { \ - memset(&elem->ossl_list_##name, 0, sizeof(elem->ossl_list_##name)); \ - } \ - static ossl_unused ossl_inline int ossl_list_##name##_is_empty(const OSSL_LIST(name) * list) \ - { \ - return list->num_elems == 0; \ - } \ - static ossl_unused ossl_inline size_t ossl_list_##name##_num(const OSSL_LIST(name) * list) \ - { \ - return list->num_elems; \ - } \ - static ossl_unused ossl_inline type *ossl_list_##name##_head(const OSSL_LIST(name) * list) \ - { \ - assert(list->alpha == NULL || list->alpha->ossl_list_##name.list == list); \ - return list->alpha; \ - } \ - static ossl_unused ossl_inline type *ossl_list_##name##_tail(const OSSL_LIST(name) * list) \ - { \ - assert(list->omega == NULL || list->omega->ossl_list_##name.list == list); \ - return list->omega; \ - } \ - static ossl_unused ossl_inline type *ossl_list_##name##_next(const type *elem) \ - { \ - assert(elem->ossl_list_##name.next == NULL \ - || elem->ossl_list_##name.next->ossl_list_##name.prev == elem); \ - return elem->ossl_list_##name.next; \ - } \ - static ossl_unused ossl_inline type *ossl_list_##name##_prev(const type *elem) \ - { \ - assert(elem->ossl_list_##name.prev == NULL \ - || elem->ossl_list_##name.prev->ossl_list_##name.next == elem); \ - return elem->ossl_list_##name.prev; \ - } \ - static ossl_unused ossl_inline void ossl_list_##name##_remove(OSSL_LIST(name) * list, \ - type * elem) \ - { \ - assert(elem->ossl_list_##name.list == list); \ - OSSL_LIST_DBG(elem->ossl_list_##name.list = NULL) \ - if (list->alpha == elem) \ - list->alpha = elem->ossl_list_##name.next; \ - if (list->omega == elem) \ - list->omega = elem->ossl_list_##name.prev; \ - if (elem->ossl_list_##name.prev != NULL) \ - elem->ossl_list_##name.prev->ossl_list_##name.next = elem->ossl_list_##name.next; \ - if (elem->ossl_list_##name.next != NULL) \ - elem->ossl_list_##name.next->ossl_list_##name.prev = elem->ossl_list_##name.prev; \ - list->num_elems--; \ - memset(&elem->ossl_list_##name, 0, sizeof(elem->ossl_list_##name)); \ - } \ - static ossl_unused ossl_inline void ossl_list_##name##_insert_head(OSSL_LIST(name) * list, \ - type * elem) \ - { \ - assert(elem->ossl_list_##name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ - if (list->alpha != NULL) \ - list->alpha->ossl_list_##name.prev = elem; \ - elem->ossl_list_##name.next = list->alpha; \ - elem->ossl_list_##name.prev = NULL; \ - list->alpha = elem; \ - if (list->omega == NULL) \ - list->omega = elem; \ - list->num_elems++; \ - } \ - static ossl_unused ossl_inline void ossl_list_##name##_insert_tail(OSSL_LIST(name) * list, \ - type * elem) \ - { \ - assert(elem->ossl_list_##name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ - if (list->omega != NULL) \ - list->omega->ossl_list_##name.next = elem; \ - elem->ossl_list_##name.prev = list->omega; \ - elem->ossl_list_##name.next = NULL; \ - list->omega = elem; \ - if (list->alpha == NULL) \ - list->alpha = elem; \ - list->num_elems++; \ - } \ - static ossl_unused ossl_inline void ossl_list_##name##_insert_before(OSSL_LIST(name) * list, \ - type * e, type * elem) \ - { \ - assert(elem->ossl_list_##name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ - elem->ossl_list_##name.next = e; \ - elem->ossl_list_##name.prev = e->ossl_list_##name.prev; \ - if (e->ossl_list_##name.prev != NULL) \ - e->ossl_list_##name.prev->ossl_list_##name.next = elem; \ - e->ossl_list_##name.prev = elem; \ - if (list->alpha == e) \ - list->alpha = elem; \ - list->num_elems++; \ - } \ - static ossl_unused ossl_inline void ossl_list_##name##_insert_after(OSSL_LIST(name) * list, \ - type * e, type * elem) \ - { \ - assert(elem->ossl_list_##name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ - elem->ossl_list_##name.prev = e; \ - elem->ossl_list_##name.next = e->ossl_list_##name.next; \ - if (e->ossl_list_##name.next != NULL) \ - e->ossl_list_##name.next->ossl_list_##name.prev = elem; \ - e->ossl_list_##name.next = elem; \ - if (list->omega == e) \ - list->omega = elem; \ - list->num_elems++; \ - } \ - struct ossl_list_st_##name +#define DEFINE_LIST_OF(name, type) \ + typedef struct ossl_list_st_##name OSSL_LIST(name); \ + struct ossl_list_st_##name \ + { \ + type *alpha, *omega; \ + size_t num_elems; \ + }; \ + static ossl_unused ossl_inline void ossl_list_##name##_init(OSSL_LIST(name) \ + * list) \ + { \ + memset(list, 0, sizeof(*list)); \ + } \ + static ossl_unused ossl_inline void ossl_list_##name##_init_elem(type *elem) \ + { \ + memset(&elem->ossl_list_##name, 0, sizeof(elem->ossl_list_##name)); \ + } \ + static ossl_unused ossl_inline int ossl_list_##name##_is_empty( \ + const OSSL_LIST(name) * list) \ + { \ + return list->num_elems == 0; \ + } \ + static ossl_unused ossl_inline size_t ossl_list_##name##_num( \ + const OSSL_LIST(name) * list) \ + { \ + return list->num_elems; \ + } \ + static ossl_unused ossl_inline type *ossl_list_##name##_head( \ + const OSSL_LIST(name) * list) \ + { \ + assert(list->alpha == NULL || list->alpha->ossl_list_##name.list == list); \ + return list->alpha; \ + } \ + static ossl_unused ossl_inline type *ossl_list_##name##_tail( \ + const OSSL_LIST(name) * list) \ + { \ + assert(list->omega == NULL || list->omega->ossl_list_##name.list == list); \ + return list->omega; \ + } \ + static ossl_unused ossl_inline type *ossl_list_##name##_next( \ + const type *elem) \ + { \ + assert(elem->ossl_list_##name.next == NULL \ + || elem->ossl_list_##name.next->ossl_list_##name.prev == elem); \ + return elem->ossl_list_##name.next; \ + } \ + static ossl_unused ossl_inline type *ossl_list_##name##_prev( \ + const type *elem) \ + { \ + assert(elem->ossl_list_##name.prev == NULL \ + || elem->ossl_list_##name.prev->ossl_list_##name.next == elem); \ + return elem->ossl_list_##name.prev; \ + } \ + static ossl_unused ossl_inline void ossl_list_##name##_remove( \ + OSSL_LIST(name) * list, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == list); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = NULL) \ + if (list->alpha == elem) \ + list->alpha = elem->ossl_list_##name.next; \ + if (list->omega == elem) \ + list->omega = elem->ossl_list_##name.prev; \ + if (elem->ossl_list_##name.prev != NULL) \ + elem->ossl_list_##name.prev->ossl_list_##name.next \ + = elem->ossl_list_##name.next; \ + if (elem->ossl_list_##name.next != NULL) \ + elem->ossl_list_##name.next->ossl_list_##name.prev \ + = elem->ossl_list_##name.prev; \ + list->num_elems--; \ + memset(&elem->ossl_list_##name, 0, sizeof(elem->ossl_list_##name)); \ + } \ + static ossl_unused ossl_inline void ossl_list_##name##_insert_head( \ + OSSL_LIST(name) * list, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + if (list->alpha != NULL) \ + list->alpha->ossl_list_##name.prev = elem; \ + elem->ossl_list_##name.next = list->alpha; \ + elem->ossl_list_##name.prev = NULL; \ + list->alpha = elem; \ + if (list->omega == NULL) \ + list->omega = elem; \ + list->num_elems++; \ + } \ + static ossl_unused ossl_inline void ossl_list_##name##_insert_tail( \ + OSSL_LIST(name) * list, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + if (list->omega != NULL) \ + list->omega->ossl_list_##name.next = elem; \ + elem->ossl_list_##name.prev = list->omega; \ + elem->ossl_list_##name.next = NULL; \ + list->omega = elem; \ + if (list->alpha == NULL) \ + list->alpha = elem; \ + list->num_elems++; \ + } \ + static ossl_unused ossl_inline void ossl_list_##name##_insert_before( \ + OSSL_LIST(name) * list, type * e, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + elem->ossl_list_##name.next = e; \ + elem->ossl_list_##name.prev = e->ossl_list_##name.prev; \ + if (e->ossl_list_##name.prev != NULL) \ + e->ossl_list_##name.prev->ossl_list_##name.next = elem; \ + e->ossl_list_##name.prev = elem; \ + if (list->alpha == e) \ + list->alpha = elem; \ + list->num_elems++; \ + } \ + static ossl_unused ossl_inline void ossl_list_##name##_insert_after( \ + OSSL_LIST(name) * list, type * e, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + elem->ossl_list_##name.prev = e; \ + elem->ossl_list_##name.next = e->ossl_list_##name.next; \ + if (e->ossl_list_##name.next != NULL) \ + e->ossl_list_##name.next->ossl_list_##name.prev = elem; \ + e->ossl_list_##name.next = elem; \ + if (list->omega == e) \ + list->omega = elem; \ + list->num_elems++; \ + } \ + struct ossl_list_st_##name #endif diff --git a/libs/OpenSSL/include/internal/namemap.h b/libs/OpenSSL/include/internal/namemap.h index 7c6f46b7..a62c02a3 100644 --- a/libs/OpenSSL/include/internal/namemap.h +++ b/libs/OpenSSL/include/internal/namemap.h @@ -25,10 +25,13 @@ int ossl_namemap_add_name(OSSL_NAMEMAP *namemap, int number, const char *name); * number->name mapping is an iterator. */ int ossl_namemap_name2num(const OSSL_NAMEMAP *namemap, const char *name); -int ossl_namemap_name2num_n(const OSSL_NAMEMAP *namemap, const char *name, size_t name_len); -const char *ossl_namemap_num2name(const OSSL_NAMEMAP *namemap, int number, size_t idx); +int ossl_namemap_name2num_n(const OSSL_NAMEMAP *namemap, const char *name, + size_t name_len); +const char *ossl_namemap_num2name(const OSSL_NAMEMAP *namemap, int number, + size_t idx); int ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number, - void (*fn)(const char *name, void *data), void *data); + void (*fn)(const char *name, void *data), + void *data); /* * A utility that handles several names in a string, divided by a given diff --git a/libs/OpenSSL/include/internal/numbers.h b/libs/OpenSSL/include/internal/numbers.h index 991ca1ff..602f28c6 100644 --- a/libs/OpenSSL/include/internal/numbers.h +++ b/libs/OpenSSL/include/internal/numbers.h @@ -15,72 +15,75 @@ #if (-1 & 3) == 0x03 /* Two's complement */ -# define __MAXUINT__(T) ((T)-1) -# define __MAXINT__(T) ((T)((((T)1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) -# define __MININT__(T) (-__MAXINT__(T) - 1) +# define __MAXUINT__(T) ((T) - 1) +# define __MAXINT__(T) \ + ((T)((((T)1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) +# define __MININT__(T) (-__MAXINT__(T) - 1) #elif (-1 & 3) == 0x02 /* One's complement */ -# define __MAXUINT__(T) (((T)-1) + 1) -# define __MAXINT__(T) ((T)((((T)1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) -# define __MININT__(T) (-__MAXINT__(T)) +# define __MAXUINT__(T) (((T) - 1) + 1) +# define __MAXINT__(T) \ + ((T)((((T)1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) +# define __MININT__(T) (-__MAXINT__(T)) #elif (-1 & 3) == 0x01 /* Sign/magnitude */ -# define __MAXINT__(T) \ - ((T)(((((T)1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) \ - | (((T)1) << ((sizeof(T) * CHAR_BIT) - 2)))) -# define __MAXUINT__(T) ((T)(__MAXINT__(T) | (((T)1) << ((sizeof(T) * CHAR_BIT) - 1)))) -# define __MININT__(T) (-__MAXINT__(T)) +# define __MAXINT__(T) \ + ((T)(((((T)1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) \ + | (((T)1) << ((sizeof(T) * CHAR_BIT) - 2)))) +# define __MAXUINT__(T) \ + ((T)(__MAXINT__(T) | (((T)1) << ((sizeof(T) * CHAR_BIT) - 1)))) +# define __MININT__(T) (-__MAXINT__(T)) #else -# error "do not know the integer encoding on this architecture" +# error "do not know the integer encoding on this architecture" #endif #ifndef INT8_MAX -# define INT8_MIN __MININT__(int8_t) -# define INT8_MAX __MAXINT__(int8_t) -# define UINT8_MAX __MAXUINT__(uint8_t) +# define INT8_MIN __MININT__(int8_t) +# define INT8_MAX __MAXINT__(int8_t) +# define UINT8_MAX __MAXUINT__(uint8_t) #endif #ifndef INT16_MAX -# define INT16_MIN __MININT__(int16_t) -# define INT16_MAX __MAXINT__(int16_t) -# define UINT16_MAX __MAXUINT__(uint16_t) +# define INT16_MIN __MININT__(int16_t) +# define INT16_MAX __MAXINT__(int16_t) +# define UINT16_MAX __MAXUINT__(uint16_t) #endif #ifndef INT32_MAX -# define INT32_MIN __MININT__(int32_t) -# define INT32_MAX __MAXINT__(int32_t) -# define UINT32_MAX __MAXUINT__(uint32_t) +# define INT32_MIN __MININT__(int32_t) +# define INT32_MAX __MAXINT__(int32_t) +# define UINT32_MAX __MAXUINT__(uint32_t) #endif #ifndef INT64_MAX -# define INT64_MIN __MININT__(int64_t) -# define INT64_MAX __MAXINT__(int64_t) -# define UINT64_MAX __MAXUINT__(uint64_t) +# define INT64_MIN __MININT__(int64_t) +# define INT64_MAX __MAXINT__(int64_t) +# define UINT64_MAX __MAXUINT__(uint64_t) #endif #ifndef INT128_MAX -# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16 +# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16 typedef __int128_t int128_t; typedef __uint128_t uint128_t; -# define INT128_MIN __MININT__(int128_t) -# define INT128_MAX __MAXINT__(int128_t) -# define UINT128_MAX __MAXUINT__(uint128_t) -# endif +# define INT128_MIN __MININT__(int128_t) +# define INT128_MAX __MAXINT__(int128_t) +# define UINT128_MAX __MAXUINT__(uint128_t) +# endif #endif #ifndef SIZE_MAX -# define SIZE_MAX __MAXUINT__(size_t) +# define SIZE_MAX __MAXUINT__(size_t) #endif #ifndef OSSL_INTMAX_MAX -# define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t) -# define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t) -# define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t) +# define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t) +# define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t) +# define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t) #endif #endif diff --git a/libs/OpenSSL/include/internal/packet.h b/libs/OpenSSL/include/internal/packet.h index 0d84e092..200f4b6a 100644 --- a/libs/OpenSSL/include/internal/packet.h +++ b/libs/OpenSSL/include/internal/packet.h @@ -22,17 +22,17 @@ typedef struct { - /* Pointer to where we are currently reading from */ - const unsigned char *curr; - /* Number of bytes remaining */ - size_t remaining; + /* Pointer to where we are currently reading from */ + const unsigned char *curr; + /* Number of bytes remaining */ + size_t remaining; } PACKET; /* Internal unchecked shorthand; don't use outside this file. */ static ossl_inline void packet_forward(PACKET *pkt, size_t len) { - pkt->curr += len; - pkt->remaining -= len; + pkt->curr += len; + pkt->remaining -= len; } /* @@ -40,7 +40,7 @@ static ossl_inline void packet_forward(PACKET *pkt, size_t len) */ static ossl_inline size_t PACKET_remaining(const PACKET *pkt) { - return pkt->remaining; + return pkt->remaining; } /* @@ -51,7 +51,7 @@ static ossl_inline size_t PACKET_remaining(const PACKET *pkt) */ static ossl_inline const unsigned char *PACKET_end(const PACKET *pkt) { - return pkt->curr + pkt->remaining; + return pkt->curr + pkt->remaining; } /* @@ -60,7 +60,7 @@ static ossl_inline const unsigned char *PACKET_end(const PACKET *pkt) */ static ossl_inline const unsigned char *PACKET_data(const PACKET *pkt) { - return pkt->curr; + return pkt->curr; } /* @@ -68,22 +68,23 @@ static ossl_inline const unsigned char *PACKET_data(const PACKET *pkt) * copy of the data so |buf| must be present for the whole time that the PACKET * is being used. */ -__owur static ossl_inline int PACKET_buf_init(PACKET *pkt, const unsigned char *buf, size_t len) +__owur static ossl_inline int +PACKET_buf_init(PACKET *pkt, const unsigned char *buf, size_t len) { - /* Sanity check for negative values. */ - if (len > (size_t)(SIZE_MAX / 2)) - return 0; + /* Sanity check for negative values. */ + if (len > (size_t)(SIZE_MAX / 2)) + return 0; - pkt->curr = buf; - pkt->remaining = len; - return 1; + pkt->curr = buf; + pkt->remaining = len; + return 1; } /* Initialize a PACKET to hold zero bytes. */ static ossl_inline void PACKET_null_init(PACKET *pkt) { - pkt->curr = NULL; - pkt->remaining = 0; + pkt->curr = NULL; + pkt->remaining = 0; } /* @@ -91,11 +92,12 @@ static ossl_inline void PACKET_null_init(PACKET *pkt) * bytes read from |ptr|. Returns 0 otherwise (lengths or contents not equal). * If lengths are equal, performs the comparison in constant time. */ -__owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, size_t num) +__owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, + size_t num) { - if (PACKET_remaining(pkt) != num) - return 0; - return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; + if (PACKET_remaining(pkt) != num) + return 0; + return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; } /* @@ -103,12 +105,13 @@ __owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, s * Data is not copied: the |subpkt| packet will share its underlying buffer with * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. */ -__owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, PACKET *subpkt, size_t len) +__owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, + PACKET *subpkt, size_t len) { - if (PACKET_remaining(pkt) < len) - return 0; + if (PACKET_remaining(pkt) < len) + return 0; - return PACKET_buf_init(subpkt, pkt->curr, len); + return PACKET_buf_init(subpkt, pkt->curr, len); } /* @@ -116,131 +119,136 @@ __owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, PACKET * * copied: the |subpkt| packet will share its underlying buffer with the * original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. */ -__owur static ossl_inline int PACKET_get_sub_packet(PACKET *pkt, PACKET *subpkt, size_t len) +__owur static ossl_inline int PACKET_get_sub_packet(PACKET *pkt, PACKET *subpkt, + size_t len) { - if (!PACKET_peek_sub_packet(pkt, subpkt, len)) - return 0; + if (!PACKET_peek_sub_packet(pkt, subpkt, len)) + return 0; - packet_forward(pkt, len); + packet_forward(pkt, len); - return 1; + return 1; } /* * Peek ahead at 2 bytes in network order from |pkt| and store the value in * |*data| */ -__owur static ossl_inline int PACKET_peek_net_2(const PACKET *pkt, unsigned int *data) +__owur static ossl_inline int PACKET_peek_net_2(const PACKET *pkt, + unsigned int *data) { - if (PACKET_remaining(pkt) < 2) - return 0; + if (PACKET_remaining(pkt) < 2) + return 0; - *data = ((unsigned int)(*pkt->curr)) << 8; - *data |= *(pkt->curr + 1); + *data = ((unsigned int)(*pkt->curr)) << 8; + *data |= *(pkt->curr + 1); - return 1; + return 1; } /* Equivalent of n2s */ /* Get 2 bytes in network order from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_get_net_2(PACKET *pkt, unsigned int *data) { - if (!PACKET_peek_net_2(pkt, data)) - return 0; + if (!PACKET_peek_net_2(pkt, data)) + return 0; - packet_forward(pkt, 2); + packet_forward(pkt, 2); - return 1; + return 1; } /* Same as PACKET_get_net_2() but for a size_t */ __owur static ossl_inline int PACKET_get_net_2_len(PACKET *pkt, size_t *data) { - unsigned int i; - int ret = PACKET_get_net_2(pkt, &i); + unsigned int i; + int ret = PACKET_get_net_2(pkt, &i); - if (ret) - *data = (size_t)i; + if (ret) + *data = (size_t)i; - return ret; + return ret; } /* * Peek ahead at 3 bytes in network order from |pkt| and store the value in * |*data| */ -__owur static ossl_inline int PACKET_peek_net_3(const PACKET *pkt, unsigned long *data) +__owur static ossl_inline int PACKET_peek_net_3(const PACKET *pkt, + unsigned long *data) { - if (PACKET_remaining(pkt) < 3) - return 0; + if (PACKET_remaining(pkt) < 3) + return 0; - *data = ((unsigned long)(*pkt->curr)) << 16; - *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; - *data |= *(pkt->curr + 2); + *data = ((unsigned long)(*pkt->curr)) << 16; + *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; + *data |= *(pkt->curr + 2); - return 1; + return 1; } /* Equivalent of n2l3 */ /* Get 3 bytes in network order from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_get_net_3(PACKET *pkt, unsigned long *data) { - if (!PACKET_peek_net_3(pkt, data)) - return 0; + if (!PACKET_peek_net_3(pkt, data)) + return 0; - packet_forward(pkt, 3); + packet_forward(pkt, 3); - return 1; + return 1; } /* Same as PACKET_get_net_3() but for a size_t */ __owur static ossl_inline int PACKET_get_net_3_len(PACKET *pkt, size_t *data) { - unsigned long i; - int ret = PACKET_get_net_3(pkt, &i); + unsigned long i; + int ret = PACKET_get_net_3(pkt, &i); - if (ret) - *data = (size_t)i; + if (ret) + *data = (size_t)i; - return ret; + return ret; } /* * Peek ahead at 4 bytes in network order from |pkt| and store the value in * |*data| */ -__owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt, unsigned long *data) +__owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt, + unsigned long *data) { - if (PACKET_remaining(pkt) < 4) - return 0; + if (PACKET_remaining(pkt) < 4) + return 0; - *data = ((unsigned long)(*pkt->curr)) << 24; - *data |= ((unsigned long)(*(pkt->curr + 1))) << 16; - *data |= ((unsigned long)(*(pkt->curr + 2))) << 8; - *data |= *(pkt->curr + 3); + *data = ((unsigned long)(*pkt->curr)) << 24; + *data |= ((unsigned long)(*(pkt->curr + 1))) << 16; + *data |= ((unsigned long)(*(pkt->curr + 2))) << 8; + *data |= *(pkt->curr + 3); - return 1; + return 1; } /* * Peek ahead at 8 bytes in network order from |pkt| and store the value in * |*data| */ -__owur static ossl_inline int PACKET_peek_net_8(const PACKET *pkt, uint64_t *data) +__owur static ossl_inline int PACKET_peek_net_8(const PACKET *pkt, + uint64_t *data) { - if (PACKET_remaining(pkt) < 8) - return 0; + if (PACKET_remaining(pkt) < 8) + return 0; - *data = ((uint64_t)(*pkt->curr)) << 56; - *data |= ((uint64_t)(*(pkt->curr + 1))) << 48; - *data |= ((uint64_t)(*(pkt->curr + 2))) << 40; - *data |= ((uint64_t)(*(pkt->curr + 3))) << 32; - *data |= ((uint64_t)(*(pkt->curr + 4))) << 24; - *data |= ((uint64_t)(*(pkt->curr + 5))) << 16; - *data |= ((uint64_t)(*(pkt->curr + 6))) << 8; - *data |= *(pkt->curr + 7); + *data = ((uint64_t)(*pkt->curr)) << 56; + *data |= ((uint64_t)(*(pkt->curr + 1))) << 48; + *data |= ((uint64_t)(*(pkt->curr + 2))) << 40; + *data |= ((uint64_t)(*(pkt->curr + 3))) << 32; + *data |= ((uint64_t)(*(pkt->curr + 4))) << 24; + *data |= ((uint64_t)(*(pkt->curr + 5))) << 16; + *data |= ((uint64_t)(*(pkt->curr + 6))) << 8; + *data |= *(pkt->curr + 7); - return 1; + return 1; } /* @@ -249,19 +257,19 @@ __owur static ossl_inline int PACKET_peek_net_8(const PACKET *pkt, uint64_t *dat */ __owur static ossl_inline int PACKET_get_quic_vlint(PACKET *pkt, uint64_t *data) { - size_t enclen; + size_t enclen; - if (PACKET_remaining(pkt) < 1) - return 0; + if (PACKET_remaining(pkt) < 1) + return 0; - enclen = ossl_quic_vlint_decode_len(*pkt->curr); + enclen = ossl_quic_vlint_decode_len(*pkt->curr); - if (PACKET_remaining(pkt) < enclen) - return 0; + if (PACKET_remaining(pkt) < enclen) + return 0; - *data = ossl_quic_vlint_decode_unchecked(pkt->curr); - packet_forward(pkt, enclen); - return 1; + *data = ossl_quic_vlint_decode_unchecked(pkt->curr); + packet_forward(pkt, enclen); + return 1; } /* @@ -269,20 +277,21 @@ __owur static ossl_inline int PACKET_get_quic_vlint(PACKET *pkt, uint64_t *data) * |data|. Unlike PACKET_get_quic_vlint, this does not advance the current * position. */ -__owur static ossl_inline int PACKET_peek_quic_vlint(PACKET *pkt, uint64_t *data) +__owur static ossl_inline int PACKET_peek_quic_vlint(PACKET *pkt, + uint64_t *data) { - size_t enclen; + size_t enclen; - if (PACKET_remaining(pkt) < 1) - return 0; + if (PACKET_remaining(pkt) < 1) + return 0; - enclen = ossl_quic_vlint_decode_len(*pkt->curr); + enclen = ossl_quic_vlint_decode_len(*pkt->curr); - if (PACKET_remaining(pkt) < enclen) - return 0; + if (PACKET_remaining(pkt) < enclen) + return 0; - *data = ossl_quic_vlint_decode_unchecked(pkt->curr); - return 1; + *data = ossl_quic_vlint_decode_unchecked(pkt->curr); + return 1; } /* @@ -290,104 +299,106 @@ __owur static ossl_inline int PACKET_peek_quic_vlint(PACKET *pkt, uint64_t *data */ __owur static ossl_inline int PACKET_skip_quic_vlint(PACKET *pkt) { - size_t enclen; + size_t enclen; - if (PACKET_remaining(pkt) < 1) - return 0; + if (PACKET_remaining(pkt) < 1) + return 0; - enclen = ossl_quic_vlint_decode_len(*pkt->curr); + enclen = ossl_quic_vlint_decode_len(*pkt->curr); - if (PACKET_remaining(pkt) < enclen) - return 0; + if (PACKET_remaining(pkt) < enclen) + return 0; - packet_forward(pkt, enclen); - return 1; + packet_forward(pkt, enclen); + return 1; } /* Equivalent of n2l */ /* Get 4 bytes in network order from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_get_net_4(PACKET *pkt, unsigned long *data) { - if (!PACKET_peek_net_4(pkt, data)) - return 0; + if (!PACKET_peek_net_4(pkt, data)) + return 0; - packet_forward(pkt, 4); + packet_forward(pkt, 4); - return 1; + return 1; } /* Same as PACKET_get_net_4() but for a size_t */ __owur static ossl_inline int PACKET_get_net_4_len(PACKET *pkt, size_t *data) { - unsigned long i; - int ret = PACKET_get_net_4(pkt, &i); + unsigned long i; + int ret = PACKET_get_net_4(pkt, &i); - if (ret) - *data = (size_t)i; + if (ret) + *data = (size_t)i; - return ret; + return ret; } /* Get 8 bytes in network order from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_get_net_8(PACKET *pkt, uint64_t *data) { - if (!PACKET_peek_net_8(pkt, data)) - return 0; + if (!PACKET_peek_net_8(pkt, data)) + return 0; - packet_forward(pkt, 8); + packet_forward(pkt, 8); - return 1; + return 1; } /* Peek ahead at 1 byte from |pkt| and store the value in |*data| */ -__owur static ossl_inline int PACKET_peek_1(const PACKET *pkt, unsigned int *data) +__owur static ossl_inline int PACKET_peek_1(const PACKET *pkt, + unsigned int *data) { - if (!PACKET_remaining(pkt)) - return 0; + if (!PACKET_remaining(pkt)) + return 0; - *data = *pkt->curr; + *data = *pkt->curr; - return 1; + return 1; } /* Get 1 byte from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_get_1(PACKET *pkt, unsigned int *data) { - if (!PACKET_peek_1(pkt, data)) - return 0; + if (!PACKET_peek_1(pkt, data)) + return 0; - packet_forward(pkt, 1); + packet_forward(pkt, 1); - return 1; + return 1; } /* Same as PACKET_get_1() but for a size_t */ __owur static ossl_inline int PACKET_get_1_len(PACKET *pkt, size_t *data) { - unsigned int i; - int ret = PACKET_get_1(pkt, &i); + unsigned int i; + int ret = PACKET_get_1(pkt, &i); - if (ret) - *data = (size_t)i; + if (ret) + *data = (size_t)i; - return ret; + return ret; } /* * Peek ahead at 4 bytes in reverse network order from |pkt| and store the value * in |*data| */ -__owur static ossl_inline int PACKET_peek_4(const PACKET *pkt, unsigned long *data) +__owur static ossl_inline int PACKET_peek_4(const PACKET *pkt, + unsigned long *data) { - if (PACKET_remaining(pkt) < 4) - return 0; + if (PACKET_remaining(pkt) < 4) + return 0; - *data = *pkt->curr; - *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; - *data |= ((unsigned long)(*(pkt->curr + 2))) << 16; - *data |= ((unsigned long)(*(pkt->curr + 3))) << 24; + *data = *pkt->curr; + *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; + *data |= ((unsigned long)(*(pkt->curr + 2))) << 16; + *data |= ((unsigned long)(*(pkt->curr + 3))) << 24; - return 1; + return 1; } /* Equivalent of c2l */ @@ -397,12 +408,12 @@ __owur static ossl_inline int PACKET_peek_4(const PACKET *pkt, unsigned long *da */ __owur static ossl_inline int PACKET_get_4(PACKET *pkt, unsigned long *data) { - if (!PACKET_peek_4(pkt, data)) - return 0; + if (!PACKET_peek_4(pkt, data)) + return 0; - packet_forward(pkt, 4); + packet_forward(pkt, 4); - return 1; + return 1; } /* @@ -411,15 +422,15 @@ __owur static ossl_inline int PACKET_get_4(PACKET *pkt, unsigned long *data) * caller should not free this data directly (it will be freed when the * underlying buffer gets freed */ -__owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt, const unsigned char **data, - size_t len) +__owur static ossl_inline int +PACKET_peek_bytes(const PACKET *pkt, const unsigned char **data, size_t len) { - if (PACKET_remaining(pkt) < len) - return 0; + if (PACKET_remaining(pkt) < len) + return 0; - *data = pkt->curr; + *data = pkt->curr; - return 1; + return 1; } /* @@ -428,40 +439,42 @@ __owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt, const unsigne * not free this data directly (it will be freed when the underlying buffer gets * freed */ -__owur static ossl_inline int PACKET_get_bytes(PACKET *pkt, const unsigned char **data, size_t len) +__owur static ossl_inline int +PACKET_get_bytes(PACKET *pkt, const unsigned char **data, size_t len) { - if (!PACKET_peek_bytes(pkt, data, len)) - return 0; + if (!PACKET_peek_bytes(pkt, data, len)) + return 0; - packet_forward(pkt, len); + packet_forward(pkt, len); - return 1; + return 1; } /* Peek ahead at |len| bytes from |pkt| and copy them to |data| */ -__owur static ossl_inline int PACKET_peek_copy_bytes(const PACKET *pkt, unsigned char *data, - size_t len) +__owur static ossl_inline int +PACKET_peek_copy_bytes(const PACKET *pkt, unsigned char *data, size_t len) { - if (PACKET_remaining(pkt) < len) - return 0; + if (PACKET_remaining(pkt) < len) + return 0; - memcpy(data, pkt->curr, len); + memcpy(data, pkt->curr, len); - return 1; + return 1; } /* * Read |len| bytes from |pkt| and copy them to |data|. * The caller is responsible for ensuring that |data| can hold |len| bytes. */ -__owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, unsigned char *data, size_t len) +__owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, + unsigned char *data, size_t len) { - if (!PACKET_peek_copy_bytes(pkt, data, len)) - return 0; + if (!PACKET_peek_copy_bytes(pkt, data, len)) + return 0; - packet_forward(pkt, len); + packet_forward(pkt, len); - return 1; + return 1; } /* @@ -471,17 +484,18 @@ __owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, unsigned char *data * Does not forward PACKET position (because it is typically the last thing * done with a given PACKET). */ -__owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, unsigned char *dest, +__owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, + unsigned char *dest, size_t dest_len, size_t *len) { - if (PACKET_remaining(pkt) > dest_len) - { - *len = 0; - return 0; - } - *len = pkt->remaining; - memcpy(dest, pkt->curr, pkt->remaining); - return 1; + if (PACKET_remaining(pkt) > dest_len) + { + *len = 0; + return 0; + } + *len = pkt->remaining; + memcpy(dest, pkt->curr, pkt->remaining); + return 1; } /* @@ -493,25 +507,26 @@ __owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, unsigned char * * Does not forward PACKET position (because it is typically the last thing * done with a given PACKET). */ -__owur static ossl_inline int PACKET_memdup(const PACKET *pkt, unsigned char **data, size_t *len) +__owur static ossl_inline int PACKET_memdup(const PACKET *pkt, + unsigned char **data, size_t *len) { - size_t length; + size_t length; - OPENSSL_free(*data); - *data = NULL; - *len = 0; + OPENSSL_free(*data); + *data = NULL; + *len = 0; - length = PACKET_remaining(pkt); + length = PACKET_remaining(pkt); - if (length == 0) - return 1; - - *data = OPENSSL_memdup(pkt->curr, length); - if (*data == NULL) - return 0; - - *len = length; + if (length == 0) return 1; + + *data = OPENSSL_memdup(pkt->curr, length); + if (*data == NULL) + return 0; + + *len = length; + return 1; } /* @@ -526,28 +541,28 @@ __owur static ossl_inline int PACKET_memdup(const PACKET *pkt, unsigned char **d */ __owur static ossl_inline int PACKET_strndup(const PACKET *pkt, char **data) { - OPENSSL_free(*data); + OPENSSL_free(*data); - /* This will succeed on an empty packet, unless pkt->curr == NULL. */ - *data = OPENSSL_strndup((const char *)pkt->curr, PACKET_remaining(pkt)); - return (*data != NULL); + /* This will succeed on an empty packet, unless pkt->curr == NULL. */ + *data = OPENSSL_strndup((const char *)pkt->curr, PACKET_remaining(pkt)); + return (*data != NULL); } /* Returns 1 if |pkt| contains at least one 0-byte, 0 otherwise. */ static ossl_inline int PACKET_contains_zero_byte(const PACKET *pkt) { - return memchr(pkt->curr, 0, pkt->remaining) != NULL; + return memchr(pkt->curr, 0, pkt->remaining) != NULL; } /* Move the current reading position forward |len| bytes */ __owur static ossl_inline int PACKET_forward(PACKET *pkt, size_t len) { - if (PACKET_remaining(pkt) < len) - return 0; + if (PACKET_remaining(pkt) < len) + return 0; - packet_forward(pkt, len); + packet_forward(pkt, len); - return 1; + return 1; } /* @@ -557,43 +572,47 @@ __owur static ossl_inline int PACKET_forward(PACKET *pkt, size_t len) * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. * Upon failure, the original |pkt| and |subpkt| are not modified. */ -__owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt, PACKET *subpkt) +__owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt, + PACKET *subpkt) { - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; - if (!PACKET_get_1(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length)) - { - return 0; - } + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; + if (!PACKET_get_1(&tmp, &length) + || !PACKET_get_bytes(&tmp, &data, (size_t)length)) + { + return 0; + } - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; - return 1; + return 1; } /* * Like PACKET_get_length_prefixed_1, but additionally, fails when there are * leftover bytes in |pkt|. */ -__owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, PACKET *subpkt) +__owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, + PACKET *subpkt) { - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; - if (!PACKET_get_1(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length) - || PACKET_remaining(&tmp) != 0) - { - return 0; - } + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; + if (!PACKET_get_1(&tmp, &length) + || !PACKET_get_bytes(&tmp, &data, (size_t)length) + || PACKET_remaining(&tmp) != 0) + { + return 0; + } - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; - return 1; + return 1; } /* @@ -603,45 +622,49 @@ __owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, PACKET *s * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. * Upon failure, the original |pkt| and |subpkt| are not modified. */ -__owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt, PACKET *subpkt) +__owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt, + PACKET *subpkt) { - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; - if (!PACKET_get_net_2(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length)) - { - return 0; - } + if (!PACKET_get_net_2(&tmp, &length) + || !PACKET_get_bytes(&tmp, &data, (size_t)length)) + { + return 0; + } - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; - return 1; + return 1; } /* * Like PACKET_get_length_prefixed_2, but additionally, fails when there are * leftover bytes in |pkt|. */ -__owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, PACKET *subpkt) +__owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, + PACKET *subpkt) { - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; - if (!PACKET_get_net_2(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length) - || PACKET_remaining(&tmp) != 0) - { - return 0; - } + if (!PACKET_get_net_2(&tmp, &length) + || !PACKET_get_bytes(&tmp, &data, (size_t)length) + || PACKET_remaining(&tmp) != 0) + { + return 0; + } - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; - return 1; + return 1; } /* @@ -651,21 +674,23 @@ __owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, PACKET *s * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. * Upon failure, the original |pkt| and |subpkt| are not modified. */ -__owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt, PACKET *subpkt) +__owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt, + PACKET *subpkt) { - unsigned long length; - const unsigned char *data; - PACKET tmp = *pkt; - if (!PACKET_get_net_3(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length)) - { - return 0; - } + unsigned long length; + const unsigned char *data; + PACKET tmp = *pkt; + if (!PACKET_get_net_3(&tmp, &length) + || !PACKET_get_bytes(&tmp, &data, (size_t)length)) + { + return 0; + } - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; - return 1; + return 1; } /* @@ -675,23 +700,24 @@ __owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt, PACKET * * buffer with the original |pkt|, so data wrapped by |pkt| must outlive the * |subpkt|. Upon failure, the original |pkt| and |subpkt| are not modified. */ -__owur static ossl_inline int PACKET_get_quic_length_prefixed(PACKET *pkt, PACKET *subpkt) +__owur static ossl_inline int PACKET_get_quic_length_prefixed(PACKET *pkt, + PACKET *subpkt) { - uint64_t length; - const unsigned char *data; - PACKET tmp = *pkt; + uint64_t length; + const unsigned char *data; + PACKET tmp = *pkt; - if (!PACKET_get_quic_vlint(&tmp, &length) || length > SIZE_MAX - || !PACKET_get_bytes(&tmp, &data, (size_t)length)) - { - return 0; - } + if (!PACKET_get_quic_vlint(&tmp, &length) || length > SIZE_MAX + || !PACKET_get_bytes(&tmp, &data, (size_t)length)) + { + return 0; + } - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = (size_t)length; + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = (size_t)length; - return 1; + return 1; } /* Writeable packets */ @@ -699,51 +725,51 @@ __owur static ossl_inline int PACKET_get_quic_length_prefixed(PACKET *pkt, PACKE typedef struct wpacket_sub WPACKET_SUB; struct wpacket_sub { - /* The parent WPACKET_SUB if we have one or NULL otherwise */ - WPACKET_SUB *parent; + /* The parent WPACKET_SUB if we have one or NULL otherwise */ + WPACKET_SUB *parent; - /* - * Offset into the buffer where the length of this WPACKET goes. We use an - * offset in case the buffer grows and gets reallocated. - */ - size_t packet_len; + /* + * Offset into the buffer where the length of this WPACKET goes. We use an + * offset in case the buffer grows and gets reallocated. + */ + size_t packet_len; - /* Number of bytes in the packet_len or 0 if we don't write the length */ - size_t lenbytes; + /* Number of bytes in the packet_len or 0 if we don't write the length */ + size_t lenbytes; - /* Number of bytes written to the buf prior to this packet starting */ - size_t pwritten; + /* Number of bytes written to the buf prior to this packet starting */ + size_t pwritten; - /* Flags for this sub-packet */ - unsigned int flags; + /* Flags for this sub-packet */ + unsigned int flags; }; typedef struct wpacket_st WPACKET; struct wpacket_st { - /* The buffer where we store the output data */ - BUF_MEM *buf; + /* The buffer where we store the output data */ + BUF_MEM *buf; - /* Fixed sized buffer which can be used as an alternative to buf */ - unsigned char *staticbuf; + /* Fixed sized buffer which can be used as an alternative to buf */ + unsigned char *staticbuf; - /* - * Offset into the buffer where we are currently writing. We use an offset - * in case the buffer grows and gets reallocated. - */ - size_t curr; + /* + * Offset into the buffer where we are currently writing. We use an offset + * in case the buffer grows and gets reallocated. + */ + size_t curr; - /* Number of bytes written so far */ - size_t written; + /* Number of bytes written so far */ + size_t written; - /* Maximum number of bytes we will allow to be written to this WPACKET */ - size_t maxsize; + /* Maximum number of bytes we will allow to be written to this WPACKET */ + size_t maxsize; - /* Our sub-packets (always at least one if not finished) */ - WPACKET_SUB *subs; + /* Our sub-packets (always at least one if not finished) */ + WPACKET_SUB *subs; - /* Writing from the end first? */ - unsigned int endfirst : 1; + /* Writing from the end first? */ + unsigned int endfirst : 1; }; /* Flags */ @@ -795,7 +821,8 @@ int WPACKET_init_null_der(WPACKET *pkt); * A fixed buffer of memory |buf| of size |len| is used instead. A failure will * occur if you attempt to write beyond the end of the buffer */ -int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len, size_t lenbytes); +int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len, + size_t lenbytes); /* * Same as WPACKET_init_static_len except lenbytes is always 0, and we set the @@ -843,10 +870,14 @@ int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes); * Convenience macros for calling WPACKET_start_sub_packet_len with different * lengths */ -#define WPACKET_start_sub_packet_u8(pkt) WPACKET_start_sub_packet_len__((pkt), 1) -#define WPACKET_start_sub_packet_u16(pkt) WPACKET_start_sub_packet_len__((pkt), 2) -#define WPACKET_start_sub_packet_u24(pkt) WPACKET_start_sub_packet_len__((pkt), 3) -#define WPACKET_start_sub_packet_u32(pkt) WPACKET_start_sub_packet_len__((pkt), 4) +#define WPACKET_start_sub_packet_u8(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 1) +#define WPACKET_start_sub_packet_u16(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 2) +#define WPACKET_start_sub_packet_u24(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 3) +#define WPACKET_start_sub_packet_u32(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 4) /* * Same as WPACKET_start_sub_packet_len__() except no bytes are pre-allocated @@ -862,7 +893,8 @@ int WPACKET_start_sub_packet(WPACKET *pkt); * WPACKET_* calls. If not then the underlying buffer may be realloc'd and * change its location. */ -int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes); +int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, + unsigned char **allocbytes); /* * The same as WPACKET_allocate_bytes() except additionally a new sub-packet is @@ -870,21 +902,21 @@ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes) * number of length bytes for the sub-packet is in |lenbytes|. Don't call this * directly. Use the convenience macros below instead. */ -int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, unsigned char **allocbytes, - size_t lenbytes); +int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, + unsigned char **allocbytes, size_t lenbytes); /* * Convenience macros for calling WPACKET_sub_allocate_bytes with different * lengths */ -#define WPACKET_sub_allocate_bytes_u8(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 1) -#define WPACKET_sub_allocate_bytes_u16(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 2) -#define WPACKET_sub_allocate_bytes_u24(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 3) -#define WPACKET_sub_allocate_bytes_u32(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 4) +#define WPACKET_sub_allocate_bytes_u8(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 1) +#define WPACKET_sub_allocate_bytes_u16(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 2) +#define WPACKET_sub_allocate_bytes_u24(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 3) +#define WPACKET_sub_allocate_bytes_u32(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 4) /* * The same as WPACKET_allocate_bytes() except the reserved bytes are not @@ -898,7 +930,8 @@ int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, unsigned char **alloc * signature may not be known in advance. We can use WPACKET_reserve_bytes() to * handle this: * - * if (!WPACKET_sub_reserve_bytes_u16(&pkt, EVP_PKEY_get_size(pkey), &sigbytes1) + * if (!WPACKET_sub_reserve_bytes_u16(&pkt, EVP_PKEY_get_size(pkey), + * &sigbytes1) * || EVP_SignFinal(md_ctx, sigbytes1, &siglen, pkey) <= 0 * || !WPACKET_sub_allocate_bytes_u16(&pkt, siglen, &sigbytes2) * || sigbytes1 != sigbytes2) @@ -909,20 +942,20 @@ int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes); /* * The "reserve_bytes" equivalent of WPACKET_sub_allocate_bytes__() */ -int WPACKET_sub_reserve_bytes__(WPACKET *pkt, size_t len, unsigned char **allocbytes, - size_t lenbytes); +int WPACKET_sub_reserve_bytes__(WPACKET *pkt, size_t len, + unsigned char **allocbytes, size_t lenbytes); /* * Convenience macros for WPACKET_sub_reserve_bytes with different lengths */ -#define WPACKET_sub_reserve_bytes_u8(pkt, len, bytes) \ - WPACKET_reserve_bytes__((pkt), (len), (bytes), 1) -#define WPACKET_sub_reserve_bytes_u16(pkt, len, bytes) \ - WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 2) -#define WPACKET_sub_reserve_bytes_u24(pkt, len, bytes) \ - WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 3) -#define WPACKET_sub_reserve_bytes_u32(pkt, len, bytes) \ - WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 4) +#define WPACKET_sub_reserve_bytes_u8(pkt, len, bytes) \ + WPACKET_reserve_bytes__((pkt), (len), (bytes), 1) +#define WPACKET_sub_reserve_bytes_u16(pkt, len, bytes) \ + WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 2) +#define WPACKET_sub_reserve_bytes_u24(pkt, len, bytes) \ + WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 3) +#define WPACKET_sub_reserve_bytes_u32(pkt, len, bytes) \ + WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 4) /* * Write the value stored in |val| into the WPACKET. The value will consume @@ -957,13 +990,18 @@ int WPACKET_memset(WPACKET *pkt, int ch, size_t len); * length (consuming |lenbytes| of data for the length). Don't call this * directly. Use the convenience macros below instead. */ -int WPACKET_sub_memcpy__(WPACKET *pkt, const void *src, size_t len, size_t lenbytes); +int WPACKET_sub_memcpy__(WPACKET *pkt, const void *src, size_t len, + size_t lenbytes); /* Convenience macros for calling WPACKET_sub_memcpy with different lengths */ -#define WPACKET_sub_memcpy_u8(pkt, src, len) WPACKET_sub_memcpy__((pkt), (src), (len), 1) -#define WPACKET_sub_memcpy_u16(pkt, src, len) WPACKET_sub_memcpy__((pkt), (src), (len), 2) -#define WPACKET_sub_memcpy_u24(pkt, src, len) WPACKET_sub_memcpy__((pkt), (src), (len), 3) -#define WPACKET_sub_memcpy_u32(pkt, src, len) WPACKET_sub_memcpy__((pkt), (src), (len), 4) +#define WPACKET_sub_memcpy_u8(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 1) +#define WPACKET_sub_memcpy_u16(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 2) +#define WPACKET_sub_memcpy_u24(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 3) +#define WPACKET_sub_memcpy_u32(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 4) /* * Return the total number of bytes written so far to the underlying buffer @@ -1010,7 +1048,8 @@ __owur int WPACKET_start_quic_sub_packet_bound(WPACKET *pkt, size_t max_len); * must be filled by the caller. This function assures optimal selection of * variable-length integer encoding length. */ -__owur int WPACKET_quic_sub_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **bytes); +__owur int WPACKET_quic_sub_allocate_bytes(WPACKET *pkt, size_t len, + unsigned char **bytes); /* * Write a QUIC variable-length integer to the packet. diff --git a/libs/OpenSSL/include/internal/param_build_set.h b/libs/OpenSSL/include/internal/param_build_set.h index 2abbef22..217834df 100644 --- a/libs/OpenSSL/include/internal/param_build_set.h +++ b/libs/OpenSSL/include/internal/param_build_set.h @@ -17,28 +17,36 @@ typedef union { - OSSL_UNION_ALIGN; + OSSL_UNION_ALIGN; } OSSL_PARAM_ALIGNED_BLOCK; #define OSSL_PARAM_ALIGN_SIZE sizeof(OSSL_PARAM_ALIGNED_BLOCK) size_t ossl_param_bytes_to_blocks(size_t bytes); -void ossl_param_set_secure_block(OSSL_PARAM *last, void *secure_buffer, size_t secure_buffer_sz); +void ossl_param_set_secure_block(OSSL_PARAM *last, void *secure_buffer, + size_t secure_buffer_sz); -int ossl_param_build_set_int(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, int num); -int ossl_param_build_set_long(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, long num); -int ossl_param_build_set_utf8_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, - const char *buf); -int ossl_param_build_set_octet_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, - const unsigned char *data, size_t data_len); -int ossl_param_build_set_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, const BIGNUM *bn); -int ossl_param_build_set_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, - const BIGNUM *bn, size_t sz); -int ossl_param_build_set_signed_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, - const BIGNUM *bn); -int ossl_param_build_set_signed_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, - const BIGNUM *bn, size_t sz); -int ossl_param_build_set_multi_key_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *names[], +int ossl_param_build_set_int(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, int num); +int ossl_param_build_set_long(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, long num); +int ossl_param_build_set_utf8_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, const char *buf); +int ossl_param_build_set_octet_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, + const unsigned char *data, + size_t data_len); +int ossl_param_build_set_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, + const BIGNUM *bn); +int ossl_param_build_set_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, const BIGNUM *bn, size_t sz); +int ossl_param_build_set_signed_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, const BIGNUM *bn); +int ossl_param_build_set_signed_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *key, const BIGNUM *bn, + size_t sz); +int ossl_param_build_set_multi_key_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, + const char *names[], STACK_OF(BIGNUM_const) * stk); #endif /* OSSL_INTERNAL_PARAM_BUILD_SET_H */ diff --git a/libs/OpenSSL/include/internal/passphrase.h b/libs/OpenSSL/include/internal/passphrase.h index eb0435e5..2335739b 100644 --- a/libs/OpenSSL/include/internal/passphrase.h +++ b/libs/OpenSSL/include/internal/passphrase.h @@ -40,53 +40,53 @@ */ struct ossl_passphrase_data_st { - enum + enum + { + is_expl_passphrase = 1, /* Explicit passphrase given by user */ + is_pem_password, /* pem_password_cb given by user */ + is_ossl_passphrase, /* OSSL_PASSPHRASE_CALLBACK given by user */ + is_ui_method /* UI_METHOD given by user */ + } type; + union + { + struct { - is_expl_passphrase = 1, /* Explicit passphrase given by user */ - is_pem_password, /* pem_password_cb given by user */ - is_ossl_passphrase, /* OSSL_PASSPHRASE_CALLBACK given by user */ - is_ui_method /* UI_METHOD given by user */ - } type; - union + char *passphrase_copy; + size_t passphrase_len; + } expl_passphrase; + + struct { - struct - { - char *passphrase_copy; - size_t passphrase_len; - } expl_passphrase; + pem_password_cb *password_cb; + void *password_cbarg; + } pem_password; - struct - { - pem_password_cb *password_cb; - void *password_cbarg; - } pem_password; + struct + { + OSSL_PASSPHRASE_CALLBACK *passphrase_cb; + void *passphrase_cbarg; + } ossl_passphrase; - struct - { - OSSL_PASSPHRASE_CALLBACK *passphrase_cb; - void *passphrase_cbarg; - } ossl_passphrase; + struct + { + const UI_METHOD *ui_method; + void *ui_method_data; + } ui_method; + } _; - struct - { - const UI_METHOD *ui_method; - void *ui_method_data; - } ui_method; - } _; + /*- + * Flags section + */ - /*- - * Flags section - */ + /* Set to indicate that caching should be done */ + unsigned int flag_cache_passphrase : 1; - /* Set to indicate that caching should be done */ - unsigned int flag_cache_passphrase : 1; + /*- + * Misc section: caches and other + */ - /*- - * Misc section: caches and other - */ - - char *cached_passphrase; - size_t cached_passphrase_len; + char *cached_passphrase; + size_t cached_passphrase_len; }; /* Structure manipulation */ @@ -94,14 +94,15 @@ struct ossl_passphrase_data_st void ossl_pw_clear_passphrase_data(struct ossl_passphrase_data_st *data); void ossl_pw_clear_passphrase_cache(struct ossl_passphrase_data_st *data); -int ossl_pw_set_passphrase(struct ossl_passphrase_data_st *data, const unsigned char *passphrase, +int ossl_pw_set_passphrase(struct ossl_passphrase_data_st *data, + const unsigned char *passphrase, size_t passphrase_len); -int ossl_pw_set_pem_password_cb(struct ossl_passphrase_data_st *data, pem_password_cb *cb, - void *cbarg); +int ossl_pw_set_pem_password_cb(struct ossl_passphrase_data_st *data, + pem_password_cb *cb, void *cbarg); int ossl_pw_set_ossl_passphrase_cb(struct ossl_passphrase_data_st *data, OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); -int ossl_pw_set_ui_method(struct ossl_passphrase_data_st *data, const UI_METHOD *ui_method, - void *ui_data); +int ossl_pw_set_ui_method(struct ossl_passphrase_data_st *data, + const UI_METHOD *ui_method, void *ui_data); int ossl_pw_enable_passphrase_caching(struct ossl_passphrase_data_st *data); int ossl_pw_disable_passphrase_caching(struct ossl_passphrase_data_st *data); diff --git a/libs/OpenSSL/include/internal/priority_queue.h b/libs/OpenSSL/include/internal/priority_queue.h index a7f34cff..d26de538 100644 --- a/libs/OpenSSL/include/internal/priority_queue.h +++ b/libs/OpenSSL/include/internal/priority_queue.h @@ -16,55 +16,58 @@ #define PRIORITY_QUEUE_OF(type) OSSL_PRIORITY_QUEUE_##type -#define DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, ctype) \ - typedef struct ossl_priority_queue_st_##type PRIORITY_QUEUE_OF(type); \ - static ossl_unused ossl_inline PRIORITY_QUEUE_OF(type) \ - * ossl_pqueue_##type##_new(int (*compare)(const ctype *, const ctype *)) \ - { \ - return (PRIORITY_QUEUE_OF(type) *)ossl_pqueue_new( \ - (int (*)(const void *, const void *))compare); \ - } \ - static ossl_unused ossl_inline void ossl_pqueue_##type##_free(PRIORITY_QUEUE_OF(type) * pq) \ - { \ - ossl_pqueue_free((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline void ossl_pqueue_##type##_pop_free( \ - PRIORITY_QUEUE_OF(type) * pq, void (*freefunc)(ctype *)) \ - { \ - ossl_pqueue_pop_free((OSSL_PQUEUE *)pq, (void (*)(void *))freefunc); \ - } \ - static ossl_unused ossl_inline int ossl_pqueue_##type##_reserve(PRIORITY_QUEUE_OF(type) * pq, \ - size_t n) \ - { \ - return ossl_pqueue_reserve((OSSL_PQUEUE *)pq, n); \ - } \ - static ossl_unused ossl_inline size_t ossl_pqueue_##type##_num(const PRIORITY_QUEUE_OF(type) \ - * pq) \ - { \ - return ossl_pqueue_num((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline int ossl_pqueue_##type##_push(PRIORITY_QUEUE_OF(type) * pq, \ - ctype * data, size_t * elem) \ - { \ - return ossl_pqueue_push((OSSL_PQUEUE *)pq, (void *)data, elem); \ - } \ - static ossl_unused ossl_inline ctype *ossl_pqueue_##type##_peek(const PRIORITY_QUEUE_OF(type) \ - * pq) \ - { \ - return (type *)ossl_pqueue_peek((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline ctype *ossl_pqueue_##type##_pop(PRIORITY_QUEUE_OF(type) * pq) \ - { \ - return (type *)ossl_pqueue_pop((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline ctype *ossl_pqueue_##type##_remove( \ - PRIORITY_QUEUE_OF(type) * pq, size_t elem) \ - { \ - return (type *)ossl_pqueue_remove((OSSL_PQUEUE *)pq, elem); \ - } \ - struct ossl_priority_queue_st_##type +#define DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, ctype) \ + typedef struct ossl_priority_queue_st_##type PRIORITY_QUEUE_OF(type); \ + static ossl_unused ossl_inline PRIORITY_QUEUE_OF(type) \ + * ossl_pqueue_##type##_new(int (*compare)(const ctype *, const ctype *)) \ + { \ + return (PRIORITY_QUEUE_OF(type) *)ossl_pqueue_new( \ + (int (*)(const void *, const void *))compare); \ + } \ + static ossl_unused ossl_inline void ossl_pqueue_##type##_free( \ + PRIORITY_QUEUE_OF(type) * pq) \ + { \ + ossl_pqueue_free((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline void ossl_pqueue_##type##_pop_free( \ + PRIORITY_QUEUE_OF(type) * pq, void (*freefunc)(ctype *)) \ + { \ + ossl_pqueue_pop_free((OSSL_PQUEUE *)pq, (void (*)(void *))freefunc); \ + } \ + static ossl_unused ossl_inline int ossl_pqueue_##type##_reserve( \ + PRIORITY_QUEUE_OF(type) * pq, size_t n) \ + { \ + return ossl_pqueue_reserve((OSSL_PQUEUE *)pq, n); \ + } \ + static ossl_unused ossl_inline size_t ossl_pqueue_##type##_num( \ + const PRIORITY_QUEUE_OF(type) * pq) \ + { \ + return ossl_pqueue_num((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline int ossl_pqueue_##type##_push( \ + PRIORITY_QUEUE_OF(type) * pq, ctype * data, size_t * elem) \ + { \ + return ossl_pqueue_push((OSSL_PQUEUE *)pq, (void *)data, elem); \ + } \ + static ossl_unused ossl_inline ctype *ossl_pqueue_##type##_peek( \ + const PRIORITY_QUEUE_OF(type) * pq) \ + { \ + return (type *)ossl_pqueue_peek((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline ctype *ossl_pqueue_##type##_pop( \ + PRIORITY_QUEUE_OF(type) * pq) \ + { \ + return (type *)ossl_pqueue_pop((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline ctype *ossl_pqueue_##type##_remove( \ + PRIORITY_QUEUE_OF(type) * pq, size_t elem) \ + { \ + return (type *)ossl_pqueue_remove((OSSL_PQUEUE *)pq, elem); \ + } \ + struct ossl_priority_queue_st_##type -#define DEFINE_PRIORITY_QUEUE_OF(type) DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, type) +#define DEFINE_PRIORITY_QUEUE_OF(type) \ + DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, type) typedef struct ossl_pqueue_st OSSL_PQUEUE; diff --git a/libs/OpenSSL/include/internal/property.h b/libs/OpenSSL/include/internal/property.h index 9265cd65..892a665d 100644 --- a/libs/OpenSSL/include/internal/property.h +++ b/libs/OpenSSL/include/internal/property.h @@ -19,9 +19,9 @@ typedef struct ossl_property_list_st OSSL_PROPERTY_LIST; typedef enum { - OSSL_PROPERTY_TYPE_STRING, - OSSL_PROPERTY_TYPE_NUMBER, - OSSL_PROPERTY_TYPE_VALUE_UNDEFINED + OSSL_PROPERTY_TYPE_STRING, + OSSL_PROPERTY_TYPE_NUMBER, + OSSL_PROPERTY_TYPE_VALUE_UNDEFINED } OSSL_PROPERTY_TYPE; typedef struct ossl_property_definition_st OSSL_PROPERTY_DEFINITION; @@ -31,20 +31,24 @@ int ossl_property_parse_init(OSSL_LIB_CTX *ctx); /* Property definition parser */ OSSL_PROPERTY_LIST *ossl_parse_property(OSSL_LIB_CTX *ctx, const char *defn); /* Property query parser */ -OSSL_PROPERTY_LIST *ossl_parse_query(OSSL_LIB_CTX *ctx, const char *s, int create_values); +OSSL_PROPERTY_LIST *ossl_parse_query(OSSL_LIB_CTX *ctx, const char *s, + int create_values); /* Property checker of query vs definition */ -int ossl_property_match_count(const OSSL_PROPERTY_LIST *query, const OSSL_PROPERTY_LIST *defn); +int ossl_property_match_count(const OSSL_PROPERTY_LIST *query, + const OSSL_PROPERTY_LIST *defn); int ossl_property_is_enabled(OSSL_LIB_CTX *ctx, const char *property_name, const OSSL_PROPERTY_LIST *prop_list); /* Free a parsed property list */ void ossl_property_free(OSSL_PROPERTY_LIST *p); /* Get a property from a property list */ -const OSSL_PROPERTY_DEFINITION *ossl_property_find_property(const OSSL_PROPERTY_LIST *list, - OSSL_LIB_CTX *libctx, const char *name); +const OSSL_PROPERTY_DEFINITION * +ossl_property_find_property(const OSSL_PROPERTY_LIST *list, + OSSL_LIB_CTX *libctx, const char *name); OSSL_PROPERTY_TYPE ossl_property_get_type(const OSSL_PROPERTY_DEFINITION *prop); -const char *ossl_property_get_string_value(OSSL_LIB_CTX *libctx, - const OSSL_PROPERTY_DEFINITION *prop); +const char * +ossl_property_get_string_value(OSSL_LIB_CTX *libctx, + const OSSL_PROPERTY_DEFINITION *prop); int64_t ossl_property_get_number_value(const OSSL_PROPERTY_DEFINITION *prop); /* Implementation store functions */ @@ -54,32 +58,41 @@ void ossl_method_store_free(OSSL_METHOD_STORE *store); int ossl_method_lock_store(OSSL_METHOD_STORE *store); int ossl_method_unlock_store(OSSL_METHOD_STORE *store); -int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov, int nid, - const char *properties, void *method, int (*method_up_ref)(void *), +int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov, + int nid, const char *properties, void *method, + int (*method_up_ref)(void *), void (*method_destruct)(void *)); -int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid, const void *method); +int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid, + const void *method); void ossl_method_store_do_all(OSSL_METHOD_STORE *store, - void (*fn)(int id, void *method, void *fnarg), void *fnarg); -int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid, const char *prop_query, - const OSSL_PROVIDER **prov, void **method); -int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov); + void (*fn)(int id, void *method, void *fnarg), + void *fnarg); +int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid, + const char *prop_query, const OSSL_PROVIDER **prov, + void **method); +int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store, + const OSSL_PROVIDER *prov); /* Get the global properties associate with the specified library context */ -OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx, int loadconfig); +OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx, + int loadconfig); /* property query cache functions */ -int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov, int nid, - const char *prop_query, void **result); -int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov, int nid, - const char *prop_query, void *result, int (*method_up_ref)(void *), +int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov, + int nid, const char *prop_query, void **result); +int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov, + int nid, const char *prop_query, void *result, + int (*method_up_ref)(void *), void (*method_destruct)(void *)); __owur int ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store); /* Merge two property queries together */ -OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a, const OSSL_PROPERTY_LIST *b); +OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a, + const OSSL_PROPERTY_LIST *b); -size_t ossl_property_list_to_string(OSSL_LIB_CTX *ctx, const OSSL_PROPERTY_LIST *list, char *buf, +size_t ossl_property_list_to_string(OSSL_LIB_CTX *ctx, + const OSSL_PROPERTY_LIST *list, char *buf, size_t bufsize); int ossl_global_properties_no_mirrored(OSSL_LIB_CTX *libctx); diff --git a/libs/OpenSSL/include/internal/provider.h b/libs/OpenSSL/include/internal/provider.h index 46a20031..fe6ecf13 100644 --- a/libs/OpenSSL/include/internal/provider.h +++ b/libs/OpenSSL/include/internal/provider.h @@ -28,18 +28,22 @@ extern "C" { */ /* Provider Object finder, constructor and destructor */ -OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name, int noconfig); +OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name, + int noconfig); OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name, - OSSL_provider_init_fn *init_function, int noconfig); + OSSL_provider_init_fn *init_function, + int noconfig); int ossl_provider_up_ref(OSSL_PROVIDER *prov); void ossl_provider_free(OSSL_PROVIDER *prov); /* Setters */ int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *module_path); -int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name, const char *value); +int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name, + const char *value); int ossl_provider_is_child(const OSSL_PROVIDER *prov); -int ossl_provider_set_child(OSSL_PROVIDER *prov, const OSSL_CORE_HANDLE *handle); +int ossl_provider_set_child(OSSL_PROVIDER *prov, + const OSSL_CORE_HANDLE *handle); const OSSL_CORE_HANDLE *ossl_provider_get_parent(OSSL_PROVIDER *prov); int ossl_provider_up_ref_parent(OSSL_PROVIDER *prov, int activate); int ossl_provider_free_parent(OSSL_PROVIDER *prov, int deactivate); @@ -61,7 +65,9 @@ int ossl_provider_add_to_store(OSSL_PROVIDER *prov, OSSL_PROVIDER **actualprov, void *ossl_provider_ctx(const OSSL_PROVIDER *prov); /* Iterate over all loaded providers */ -int ossl_provider_doall_activated(OSSL_LIB_CTX *, int (*cb)(OSSL_PROVIDER *provider, void *cbdata), +int ossl_provider_doall_activated(OSSL_LIB_CTX *, + int (*cb)(OSSL_PROVIDER *provider, + void *cbdata), void *cbdata); /* Getters for other library functions */ @@ -77,12 +83,15 @@ OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov); void ossl_provider_teardown(const OSSL_PROVIDER *prov); const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov); int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); -int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov, const char *capability, - OSSL_CALLBACK *cb, void *arg); +int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov, + const char *capability, OSSL_CALLBACK *cb, + void *arg); int ossl_provider_self_test(const OSSL_PROVIDER *prov); -const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, int operation_id, +const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, + int operation_id, int *no_cache); -void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov, int operation_id, +void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov, + int operation_id, const OSSL_ALGORITHM *algs); /* @@ -91,13 +100,15 @@ void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov, int operation_id * They should never be called for temporary method stores! */ int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum); -int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum, int *result); +int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum, + int *result); /* Configuration */ void ossl_provider_add_conf_module(void); /* Child providers */ -int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx, const OSSL_CORE_HANDLE *handle, +int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx, + const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH *in); void ossl_provider_deinit_child(OSSL_LIB_CTX *ctx); diff --git a/libs/OpenSSL/include/internal/quic_ackm.h b/libs/OpenSSL/include/internal/quic_ackm.h index d2df083b..4001338c 100644 --- a/libs/OpenSSL/include/internal/quic_ackm.h +++ b/libs/OpenSSL/include/internal/quic_ackm.h @@ -18,82 +18,83 @@ typedef struct ossl_ackm_st OSSL_ACKM; -OSSL_ACKM *ossl_ackm_new(OSSL_TIME (*now)(void *arg), void *now_arg, OSSL_STATM *statm, - const OSSL_CC_METHOD *cc_method, OSSL_CC_DATA *cc_data); +OSSL_ACKM *ossl_ackm_new(OSSL_TIME (*now)(void *arg), void *now_arg, + OSSL_STATM *statm, const OSSL_CC_METHOD *cc_method, + OSSL_CC_DATA *cc_data); void ossl_ackm_free(OSSL_ACKM *ackm); -void ossl_ackm_set_loss_detection_deadline_callback(OSSL_ACKM *ackm, - void (*fn)(OSSL_TIME deadline, void *arg), - void *arg); +void ossl_ackm_set_loss_detection_deadline_callback( + OSSL_ACKM *ackm, void (*fn)(OSSL_TIME deadline, void *arg), void *arg); void ossl_ackm_set_ack_deadline_callback(OSSL_ACKM *ackm, - void (*fn)(OSSL_TIME deadline, int pkt_space, void *arg), + void (*fn)(OSSL_TIME deadline, + int pkt_space, void *arg), void *arg); typedef struct ossl_ackm_tx_pkt_st OSSL_ACKM_TX_PKT; struct ossl_ackm_tx_pkt_st { - /* The packet number of the transmitted packet. */ - QUIC_PN pkt_num; + /* The packet number of the transmitted packet. */ + QUIC_PN pkt_num; - /* The number of bytes in the packet which was sent. */ - size_t num_bytes; + /* The number of bytes in the packet which was sent. */ + size_t num_bytes; - /* The time at which the packet was sent. */ - OSSL_TIME time; + /* The time at which the packet was sent. */ + OSSL_TIME time; - /* - * If the packet being described by this structure contains an ACK frame, - * this must be set to the largest PN ACK'd by that frame. - * - * Otherwise, it should be set to QUIC_PN_INVALID. - * - * This is necessary to bound the number of PNs we have to keep track of on - * the RX side (RFC 9000 s. 13.2.4). It allows older PN tracking information - * on the RX side to be discarded. - */ - QUIC_PN largest_acked; + /* + * If the packet being described by this structure contains an ACK frame, + * this must be set to the largest PN ACK'd by that frame. + * + * Otherwise, it should be set to QUIC_PN_INVALID. + * + * This is necessary to bound the number of PNs we have to keep track of on + * the RX side (RFC 9000 s. 13.2.4). It allows older PN tracking information + * on the RX side to be discarded. + */ + QUIC_PN largest_acked; - /* - * One of the QUIC_PN_SPACE_* values. This qualifies the pkt_num field - * into a packet number space. - */ - unsigned int pkt_space : 2; + /* + * One of the QUIC_PN_SPACE_* values. This qualifies the pkt_num field + * into a packet number space. + */ + unsigned int pkt_space : 2; - /* 1 if the packet is in flight. */ - unsigned int is_inflight : 1; + /* 1 if the packet is in flight. */ + unsigned int is_inflight : 1; - /* 1 if the packet has one or more ACK-eliciting frames. */ - unsigned int is_ack_eliciting : 1; + /* 1 if the packet has one or more ACK-eliciting frames. */ + unsigned int is_ack_eliciting : 1; - /* 1 if the packet is a PTO probe. */ - unsigned int is_pto_probe : 1; + /* 1 if the packet is a PTO probe. */ + unsigned int is_pto_probe : 1; - /* 1 if the packet is an MTU probe. */ - unsigned int is_mtu_probe : 1; + /* 1 if the packet is an MTU probe. */ + unsigned int is_mtu_probe : 1; - /* Callback called if frames in this packet are lost. arg is cb_arg. */ - void (*on_lost)(void *arg); - /* Callback called if frames in this packet are acked. arg is cb_arg. */ - void (*on_acked)(void *arg); - /* - * Callback called if frames in this packet are neither acked nor lost. arg - * is cb_arg. - */ - void (*on_discarded)(void *arg); - void *cb_arg; + /* Callback called if frames in this packet are lost. arg is cb_arg. */ + void (*on_lost)(void *arg); + /* Callback called if frames in this packet are acked. arg is cb_arg. */ + void (*on_acked)(void *arg); + /* + * Callback called if frames in this packet are neither acked nor lost. arg + * is cb_arg. + */ + void (*on_discarded)(void *arg); + void *cb_arg; - /* - * (Internal use fields; must be zero-initialized.) - * - * Keep a TX history list, anext is used to manifest - * a singly-linked list of newly-acknowledged packets, and lnext is used to - * manifest a singly-linked list of newly lost packets. - */ - OSSL_LIST_MEMBER(tx_history, OSSL_ACKM_TX_PKT); + /* + * (Internal use fields; must be zero-initialized.) + * + * Keep a TX history list, anext is used to manifest + * a singly-linked list of newly-acknowledged packets, and lnext is used to + * manifest a singly-linked list of newly lost packets. + */ + OSSL_LIST_MEMBER(tx_history, OSSL_ACKM_TX_PKT); - struct ossl_ackm_tx_pkt_st *anext; - struct ossl_ackm_tx_pkt_st *lnext; + struct ossl_ackm_tx_pkt_st *anext; + struct ossl_ackm_tx_pkt_st *lnext; }; int ossl_ackm_on_tx_packet(OSSL_ACKM *ackm, OSSL_ACKM_TX_PKT *pkt); @@ -106,32 +107,32 @@ int ossl_ackm_on_rx_datagram(OSSL_ACKM *ackm, size_t num_bytes); typedef struct ossl_ackm_rx_pkt_st { - /* The packet number of the received packet. */ - QUIC_PN pkt_num; + /* The packet number of the received packet. */ + QUIC_PN pkt_num; - /* The time at which the packet was received. */ - OSSL_TIME time; + /* The time at which the packet was received. */ + OSSL_TIME time; - /* - * One of the QUIC_PN_SPACE_* values. This qualifies the pkt_num field - * into a packet number space. - */ - unsigned int pkt_space : 2; + /* + * One of the QUIC_PN_SPACE_* values. This qualifies the pkt_num field + * into a packet number space. + */ + unsigned int pkt_space : 2; - /* 1 if the packet has one or more ACK-eliciting frames. */ - unsigned int is_ack_eliciting : 1; + /* 1 if the packet has one or more ACK-eliciting frames. */ + unsigned int is_ack_eliciting : 1; - /* - * One of the OSSL_ACKM_ECN_* values. This is the ECN labelling applied to - * the received packet. If unknown, use OSSL_ACKM_ECN_NONE. - */ - unsigned int ecn : 2; + /* + * One of the OSSL_ACKM_ECN_* values. This is the ECN labelling applied to + * the received packet. If unknown, use OSSL_ACKM_ECN_NONE. + */ + unsigned int ecn : 2; } OSSL_ACKM_RX_PKT; int ossl_ackm_on_rx_packet(OSSL_ACKM *ackm, const OSSL_ACKM_RX_PKT *pkt); -int ossl_ackm_on_rx_ack_frame(OSSL_ACKM *ackm, const OSSL_QUIC_FRAME_ACK *ack, int pkt_space, - OSSL_TIME rx_time); +int ossl_ackm_on_rx_ack_frame(OSSL_ACKM *ackm, const OSSL_QUIC_FRAME_ACK *ack, + int pkt_space, OSSL_TIME rx_time); /* * Discards a PN space. This must be called for a PN space before freeing the @@ -154,7 +155,8 @@ OSSL_TIME ossl_ackm_get_loss_detection_deadline(OSSL_ACKM *ackm); * This clears the flag returned by ossl_ackm_is_ack_desired and the deadline * returned by ossl_ackm_get_ack_deadline. */ -const OSSL_QUIC_FRAME_ACK *ossl_ackm_get_ack_frame(OSSL_ACKM *ackm, int pkt_space); +const OSSL_QUIC_FRAME_ACK *ossl_ackm_get_ack_frame(OSSL_ACKM *ackm, + int pkt_space); /* * Returns the deadline after which an ACK frame should be generated by calling @@ -199,12 +201,13 @@ int ossl_ackm_is_rx_pn_processable(OSSL_ACKM *ackm, QUIC_PN pn, int pkt_space); typedef struct ossl_ackm_probe_info_st { - uint32_t handshake; - uint32_t padded_initial; - uint32_t pto[QUIC_PN_SPACE_NUM]; + uint32_t handshake; + uint32_t padded_initial; + uint32_t pto[QUIC_PN_SPACE_NUM]; } OSSL_ACKM_PROBE_INFO; -int ossl_ackm_get_probe_request(OSSL_ACKM *ackm, int clear, OSSL_ACKM_PROBE_INFO *info); +int ossl_ackm_get_probe_request(OSSL_ACKM *ackm, int clear, + OSSL_ACKM_PROBE_INFO *info); int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn); diff --git a/libs/OpenSSL/include/internal/quic_cc.h b/libs/OpenSSL/include/internal/quic_cc.h index b5e43a83..9f767526 100644 --- a/libs/OpenSSL/include/internal/quic_cc.h +++ b/libs/OpenSSL/include/internal/quic_cc.h @@ -16,125 +16,131 @@ typedef struct ossl_cc_data_st *OSSL_CC_DATA; typedef struct ossl_cc_method_st { - void *dummy; + void *dummy; - /* - * Create a new OSSL_CC_DATA object to handle the congestion control - * calculations. - * - * |settings| are mandatory settings that will cause the - * new() call to fail if they are not understood). - * |options| are optional settings that will not - * cause the new() call to fail if they are not understood. - * |changeables| contain additional parameters that the congestion - * control algorithms need that can be updated during the - * connection lifetime - for example size of the datagram payload. - * To avoid calling a function with OSSL_PARAM array every time - * these parameters are changed the addresses of these param - * values are considered permanent and the values can be updated - * any time. - */ - OSSL_CC_DATA *(*new)(OSSL_PARAM *settings, OSSL_PARAM *options, OSSL_PARAM *changeables); + /* + * Create a new OSSL_CC_DATA object to handle the congestion control + * calculations. + * + * |settings| are mandatory settings that will cause the + * new() call to fail if they are not understood). + * |options| are optional settings that will not + * cause the new() call to fail if they are not understood. + * |changeables| contain additional parameters that the congestion + * control algorithms need that can be updated during the + * connection lifetime - for example size of the datagram payload. + * To avoid calling a function with OSSL_PARAM array every time + * these parameters are changed the addresses of these param + * values are considered permanent and the values can be updated + * any time. + */ + OSSL_CC_DATA *(*new)(OSSL_PARAM *settings, OSSL_PARAM *options, + OSSL_PARAM *changeables); - /* - * Release the OSSL_CC_DATA. - */ - void (*free)(OSSL_CC_DATA *ccdata); + /* + * Release the OSSL_CC_DATA. + */ + void (*free)(OSSL_CC_DATA *ccdata); - /* - * Reset the congestion control state. - * |flags| to support different level of reset (partial/full). - */ - void (*reset)(OSSL_CC_DATA *ccdata, int flags); + /* + * Reset the congestion control state. + * |flags| to support different level of reset (partial/full). + */ + void (*reset)(OSSL_CC_DATA *ccdata, int flags); - /* - * Set number of packets exempted from CC - used for probing - * |numpackets| is a small value (2). - * Returns 0 on error, 1 otherwise. - */ - int (*set_exemption)(OSSL_CC_DATA *ccdata, int numpackets); + /* + * Set number of packets exempted from CC - used for probing + * |numpackets| is a small value (2). + * Returns 0 on error, 1 otherwise. + */ + int (*set_exemption)(OSSL_CC_DATA *ccdata, int numpackets); - /* - * Get current number of packets exempted from CC. - * Returns negative value on error, the number otherwise. - */ - int (*get_exemption)(OSSL_CC_DATA *ccdata); + /* + * Get current number of packets exempted from CC. + * Returns negative value on error, the number otherwise. + */ + int (*get_exemption)(OSSL_CC_DATA *ccdata); - /* - * Returns 1 if sending is allowed, 0 otherwise. - */ - int (*can_send)(OSSL_CC_DATA *ccdata); + /* + * Returns 1 if sending is allowed, 0 otherwise. + */ + int (*can_send)(OSSL_CC_DATA *ccdata); - /* - * Returns number of bytes allowed to be sent. - * |time_since_last_send| is time since last send operation - * in microseconds. - * |time_valid| is 1 if the |time_since_last_send| holds - * a meaningful value, 0 otherwise. - */ - uint64_t (*get_send_allowance)(OSSL_CC_DATA *ccdata, OSSL_TIME time_since_last_send, - int time_valid); + /* + * Returns number of bytes allowed to be sent. + * |time_since_last_send| is time since last send operation + * in microseconds. + * |time_valid| is 1 if the |time_since_last_send| holds + * a meaningful value, 0 otherwise. + */ + uint64_t (*get_send_allowance)(OSSL_CC_DATA *ccdata, + OSSL_TIME time_since_last_send, + int time_valid); - /* - * Returns the maximum number of bytes allowed to be in flight. - */ - uint64_t (*get_bytes_in_flight_max)(OSSL_CC_DATA *ccdata); + /* + * Returns the maximum number of bytes allowed to be in flight. + */ + uint64_t (*get_bytes_in_flight_max)(OSSL_CC_DATA *ccdata); - /* - * To be called when a packet with retransmittable data was sent. - * |num_retransmittable_bytes| is the number of bytes sent - * in the packet that are retransmittable. - * Returns 1 on success, 0 otherwise. - */ - int (*on_data_sent)(OSSL_CC_DATA *ccdata, uint64_t num_retransmittable_bytes); + /* + * To be called when a packet with retransmittable data was sent. + * |num_retransmittable_bytes| is the number of bytes sent + * in the packet that are retransmittable. + * Returns 1 on success, 0 otherwise. + */ + int (*on_data_sent)(OSSL_CC_DATA *ccdata, uint64_t num_retransmittable_bytes); - /* - * To be called when retransmittable data was invalidated. - * I.E. they are not considered in-flight anymore but - * are neither acknowledged nor lost. In particular used when - * 0RTT data was rejected. - * |num_retransmittable_bytes| is the number of bytes - * of the invalidated data. - * Returns 1 if sending is unblocked (can_send returns 1), 0 - * otherwise. - */ - int (*on_data_invalidated)(OSSL_CC_DATA *ccdata, uint64_t num_retransmittable_bytes); + /* + * To be called when retransmittable data was invalidated. + * I.E. they are not considered in-flight anymore but + * are neither acknowledged nor lost. In particular used when + * 0RTT data was rejected. + * |num_retransmittable_bytes| is the number of bytes + * of the invalidated data. + * Returns 1 if sending is unblocked (can_send returns 1), 0 + * otherwise. + */ + int (*on_data_invalidated)(OSSL_CC_DATA *ccdata, + uint64_t num_retransmittable_bytes); - /* - * To be called when sent data was acked. - * |time_now| is current time in microseconds. - * |largest_pn_acked| is the largest packet number of the acked - * packets. - * |num_retransmittable_bytes| is the number of retransmittable - * packet bytes that were newly acked. - * Returns 1 if sending is unblocked (can_send returns 1), 0 - * otherwise. - */ - int (*on_data_acked)(OSSL_CC_DATA *ccdata, OSSL_TIME time_now, uint64_t last_pn_acked, - uint64_t num_retransmittable_bytes); + /* + * To be called when sent data was acked. + * |time_now| is current time in microseconds. + * |largest_pn_acked| is the largest packet number of the acked + * packets. + * |num_retransmittable_bytes| is the number of retransmittable + * packet bytes that were newly acked. + * Returns 1 if sending is unblocked (can_send returns 1), 0 + * otherwise. + */ + int (*on_data_acked)(OSSL_CC_DATA *ccdata, OSSL_TIME time_now, + uint64_t last_pn_acked, + uint64_t num_retransmittable_bytes); - /* - * To be called when sent data is considered lost. - * |largest_pn_lost| is the largest packet number of the lost - * packets. - * |largest_pn_sent| is the largest packet number sent on this - * connection. - * |num_retransmittable_bytes| is the number of retransmittable - * packet bytes that are newly considered lost. - * |persistent_congestion| is 1 if the congestion is considered - * persistent (see RFC 9002 Section 7.6), 0 otherwise. - */ - void (*on_data_lost)(OSSL_CC_DATA *ccdata, uint64_t largest_pn_lost, uint64_t largest_pn_sent, - uint64_t num_retransmittable_bytes, int persistent_congestion); + /* + * To be called when sent data is considered lost. + * |largest_pn_lost| is the largest packet number of the lost + * packets. + * |largest_pn_sent| is the largest packet number sent on this + * connection. + * |num_retransmittable_bytes| is the number of retransmittable + * packet bytes that are newly considered lost. + * |persistent_congestion| is 1 if the congestion is considered + * persistent (see RFC 9002 Section 7.6), 0 otherwise. + */ + void (*on_data_lost)(OSSL_CC_DATA *ccdata, uint64_t largest_pn_lost, + uint64_t largest_pn_sent, + uint64_t num_retransmittable_bytes, + int persistent_congestion); - /* - * To be called when all lost data from the previous call to - * on_data_lost() was actually acknowledged. - * This reverts the size of the congestion window to the state - * before the on_data_lost() call. - * Returns 1 if sending is unblocked, 0 otherwise. - */ - int (*on_spurious_congestion_event)(OSSL_CC_DATA *ccdata); + /* + * To be called when all lost data from the previous call to + * on_data_lost() was actually acknowledged. + * This reverts the size of the congestion window to the state + * before the on_data_lost() call. + * Returns 1 if sending is unblocked, 0 otherwise. + */ + int (*on_spurious_congestion_event)(OSSL_CC_DATA *ccdata); } OSSL_CC_METHOD; extern const OSSL_CC_METHOD ossl_cc_dummy_method; diff --git a/libs/OpenSSL/include/internal/quic_cfq.h b/libs/OpenSSL/include/internal/quic_cfq.h index 235bfccf..a0e20d32 100644 --- a/libs/OpenSSL/include/internal/quic_cfq.h +++ b/libs/OpenSSL/include/internal/quic_cfq.h @@ -24,14 +24,14 @@ typedef struct quic_cfq_item_st QUIC_CFQ_ITEM; struct quic_cfq_item_st { - /* - * These fields are not used by the CFQ, but are a convenience to assist the - * TXPIM in keeping a list of GCR control frames which were sent in a - * packet. They may be used for any purpose. - */ - QUIC_CFQ_ITEM *pkt_prev, *pkt_next; + /* + * These fields are not used by the CFQ, but are a convenience to assist the + * TXPIM in keeping a list of GCR control frames which were sent in a + * packet. They may be used for any purpose. + */ + QUIC_CFQ_ITEM *pkt_prev, *pkt_next; - /* All other fields are private; use ossl_quic_cfq_item_* accessors. */ + /* All other fields are private; use ossl_quic_cfq_item_* accessors. */ }; #define QUIC_CFQ_STATE_NEW 0 @@ -90,9 +90,11 @@ void ossl_quic_cfq_free(QUIC_CFQ *cfq); */ typedef void(cfq_free_cb)(unsigned char *buf, size_t buf_len, void *arg); -QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq, uint32_t priority, uint32_t pn_space, - uint64_t frame_type, const unsigned char *encoded, - size_t encoded_len, cfq_free_cb *free_cb, void *free_cb_arg); +QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq, uint32_t priority, + uint32_t pn_space, uint64_t frame_type, + const unsigned char *encoded, + size_t encoded_len, cfq_free_cb *free_cb, + void *free_cb_arg); /* * Effects an immediate transition of the given CFQ item to the TX state. @@ -104,7 +106,8 @@ void ossl_quic_cfq_mark_tx(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item); * allowing the frame to be retransmitted. If priority is not UINT32_MAX, * the priority is changed to the given value. */ -void ossl_quic_cfq_mark_lost(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item, uint32_t priority); +void ossl_quic_cfq_mark_lost(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item, + uint32_t priority); /* * Releases a CFQ item. The item may be in either state (NEW or TX) prior to the @@ -121,7 +124,8 @@ void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item); * Gets the highest priority CFQ item in the given PN space awaiting * transmission. If there are none, returns NULL. */ -QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq, uint32_t pn_space); +QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq, + uint32_t pn_space); /* * Given a CFQ item, gets the next CFQ item awaiting transmission in priority @@ -129,6 +133,7 @@ QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq, uint32_t pn_ * ossl_quic_cfq_get_priority_head(), returns the next-lower priority item. * Returns NULL if the given item is the last item in priority order. */ -QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(const QUIC_CFQ_ITEM *item, uint32_t pn_space); +QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(const QUIC_CFQ_ITEM *item, + uint32_t pn_space); #endif diff --git a/libs/OpenSSL/include/internal/quic_demux.h b/libs/OpenSSL/include/internal/quic_demux.h index eb1f7b89..4f4c6238 100644 --- a/libs/OpenSSL/include/internal/quic_demux.h +++ b/libs/OpenSSL/include/internal/quic_demux.h @@ -88,54 +88,56 @@ typedef struct quic_urxe_st QUIC_URXE; struct quic_urxe_st { - OSSL_LIST_MEMBER(urxe, QUIC_URXE); + OSSL_LIST_MEMBER(urxe, QUIC_URXE); - /* - * The URXE data starts after this structure so we don't need a pointer. - * data_len stores the current length (i.e., the length of the received - * datagram) and alloc_len stores the allocation length. The URXE will be - * reallocated if we need a larger allocation than is available, though this - * should not be common as we will have a good idea of worst-case MTUs up - * front. - */ - size_t data_len, alloc_len; + /* + * The URXE data starts after this structure so we don't need a pointer. + * data_len stores the current length (i.e., the length of the received + * datagram) and alloc_len stores the allocation length. The URXE will be + * reallocated if we need a larger allocation than is available, though this + * should not be common as we will have a good idea of worst-case MTUs up + * front. + */ + size_t data_len, alloc_len; - /* - * Bitfields per packet. processed indicates the packet has been processed - * and must not be processed again, hpr_removed indicates header protection - * has already been removed. Used by QRX only; not used by the demuxer. - */ - uint64_t processed, hpr_removed; + /* + * Bitfields per packet. processed indicates the packet has been processed + * and must not be processed again, hpr_removed indicates header protection + * has already been removed. Used by QRX only; not used by the demuxer. + */ + uint64_t processed, hpr_removed; - /* - * Address of peer we received the datagram from, and the local interface - * address we received it on. If local address support is not enabled, local - * is zeroed. - */ - BIO_ADDR peer, local; + /* + * Address of peer we received the datagram from, and the local interface + * address we received it on. If local address support is not enabled, local + * is zeroed. + */ + BIO_ADDR peer, local; - /* - * Time at which datagram was received (or ossl_time_zero()) if a now - * function was not provided). - */ - OSSL_TIME time; + /* + * Time at which datagram was received (or ossl_time_zero()) if a now + * function was not provided). + */ + OSSL_TIME time; - /* - * Used by the QRX to mark whether a datagram has been deferred. Used by the - * QRX only; not used by the demuxer. - */ - char deferred; + /* + * Used by the QRX to mark whether a datagram has been deferred. Used by the + * QRX only; not used by the demuxer. + */ + char deferred; }; /* Accessors for URXE buffer. */ -static ossl_unused ossl_inline unsigned char *ossl_quic_urxe_data(const QUIC_URXE *e) +static ossl_unused ossl_inline unsigned char * +ossl_quic_urxe_data(const QUIC_URXE *e) { - return (unsigned char *)&e[1]; + return (unsigned char *)&e[1]; } -static ossl_unused ossl_inline unsigned char *ossl_quic_urxe_data_end(const QUIC_URXE *e) +static ossl_unused ossl_inline unsigned char * +ossl_quic_urxe_data_end(const QUIC_URXE *e) { - return ossl_quic_urxe_data(e) + e->data_len; + return ossl_quic_urxe_data(e) + e->data_len; } /* List structure tracking a queue of URXEs. */ @@ -160,8 +162,9 @@ typedef struct quic_demux_st QUIC_DEMUX; * to mutate this buffer; once the demuxer calls this callback, it will never * read the buffer again. * - * The callee must arrange for ossl_quic_demux_release_urxe to be called on the URXE - * at some point in the future (this need not be before the callback returns). + * The callee must arrange for ossl_quic_demux_release_urxe to be called on the + * URXE at some point in the future (this need not be before the callback + * returns). * * At the time the callback is made, the URXE will not be in any queue, * therefore the callee can use the prev and next fields as it wishes. @@ -181,8 +184,8 @@ typedef void(ossl_quic_demux_cb_fn)(QUIC_URXE *e, void *arg); * NULL, ossl_time_zero() is used as the datagram reception time. */ QUIC_DEMUX *ossl_quic_demux_new(BIO *net_bio, size_t short_conn_id_len, - size_t default_urxe_alloc_len, OSSL_TIME (*now)(void *arg), - void *now_arg); + size_t default_urxe_alloc_len, + OSSL_TIME (*now)(void *arg), void *now_arg); /* * Destroy a demuxer. All URXEs must have been released back to the demuxer @@ -193,8 +196,9 @@ void ossl_quic_demux_free(QUIC_DEMUX *demux); /* * Register a datagram handler callback for a connection ID. * - * ossl_quic_demux_pump will call the specified function if it receives a datagram - * the first packet of which has the specified destination connection ID. + * ossl_quic_demux_pump will call the specified function if it receives a + * datagram the first packet of which has the specified destination connection + * ID. * * It is assumed all packets in a datagram have the same destination connection * ID (as QUIC mandates this), but it is the user's responsibility to check for @@ -220,14 +224,16 @@ int ossl_quic_demux_register(QUIC_DEMUX *demux, const QUIC_CONN_ID *dst_conn_id, * * Returns 1 on success or 0 on failure. */ -int ossl_quic_demux_unregister(QUIC_DEMUX *demux, const QUIC_CONN_ID *dst_conn_id); +int ossl_quic_demux_unregister(QUIC_DEMUX *demux, + const QUIC_CONN_ID *dst_conn_id); /* * Unregisters any datagram handler callback from all connection IDs it is used * for. cb and cb_arg must both match the values passed to * ossl_quic_demux_register. */ -void ossl_quic_demux_unregister_by_cb(QUIC_DEMUX *demux, ossl_quic_demux_cb_fn *cb, void *cb_arg); +void ossl_quic_demux_unregister_by_cb(QUIC_DEMUX *demux, + ossl_quic_demux_cb_fn *cb, void *cb_arg); /* * Releases a URXE back to the demuxer. No reference must be made to the URXE or @@ -253,7 +259,8 @@ int ossl_quic_demux_pump(QUIC_DEMUX *demux); * * Returns 1 on success or 0 on failure. */ -int ossl_quic_demux_inject(QUIC_DEMUX *demux, const unsigned char *buf, size_t buf_len, - const BIO_ADDR *peer, const BIO_ADDR *local); +int ossl_quic_demux_inject(QUIC_DEMUX *demux, const unsigned char *buf, + size_t buf_len, const BIO_ADDR *peer, + const BIO_ADDR *local); #endif diff --git a/libs/OpenSSL/include/internal/quic_fc.h b/libs/OpenSSL/include/internal/quic_fc.h index 2df2ef53..3cec625f 100644 --- a/libs/OpenSSL/include/internal/quic_fc.h +++ b/libs/OpenSSL/include/internal/quic_fc.h @@ -23,9 +23,9 @@ typedef struct quic_txfc_st QUIC_TXFC; struct quic_txfc_st { - QUIC_TXFC *parent; /* stream-level iff non-NULL */ - uint64_t swm, cwm; - char has_become_blocked; + QUIC_TXFC *parent; /* stream-level iff non-NULL */ + uint64_t swm, cwm; + char has_become_blocked; }; /* @@ -124,20 +124,20 @@ typedef struct quic_rxfc_st QUIC_RXFC; struct quic_rxfc_st { - /* - * swm is the sent/received watermark, which tracks how much we have - * received from the peer. rwm is the retired watermark, which tracks how - * much has been passed to the application. esrwm is the rwm value at which - * the current auto-tuning epoch started. hwm is the highest stream length - * (STREAM frame offset + payload length) we have seen from a STREAM frame - * yet. - */ - uint64_t cwm, swm, rwm, esrwm, hwm, cur_window_size, max_window_size; - OSSL_TIME epoch_start; - OSSL_TIME (*now)(void *arg); - void *now_arg; - QUIC_RXFC *parent; - unsigned char error_code, has_cwm_changed, is_fin; + /* + * swm is the sent/received watermark, which tracks how much we have + * received from the peer. rwm is the retired watermark, which tracks how + * much has been passed to the application. esrwm is the rwm value at which + * the current auto-tuning epoch started. hwm is the highest stream length + * (STREAM frame offset + payload length) we have seen from a STREAM frame + * yet. + */ + uint64_t cwm, swm, rwm, esrwm, hwm, cur_window_size, max_window_size; + OSSL_TIME epoch_start; + OSSL_TIME (*now)(void *arg); + void *now_arg; + QUIC_RXFC *parent; + unsigned char error_code, has_cwm_changed, is_fin; }; /* @@ -148,8 +148,9 @@ struct quic_rxfc_st * expressed in bytes and determine how much credit the RXFC extends to the peer * to transmit more data at a time. */ -int ossl_quic_rxfc_init(QUIC_RXFC *rxfc, QUIC_RXFC *conn_rxfc, uint64_t initial_window_size, - uint64_t max_window_size, OSSL_TIME (*now)(void *arg), void *now_arg); +int ossl_quic_rxfc_init(QUIC_RXFC *rxfc, QUIC_RXFC *conn_rxfc, + uint64_t initial_window_size, uint64_t max_window_size, + OSSL_TIME (*now)(void *arg), void *now_arg); /* * Gets the parent (i.e., connection-level) RXFC. Returns NULL if called on a @@ -160,7 +161,8 @@ QUIC_RXFC *ossl_quic_rxfc_get_parent(QUIC_RXFC *rxfc); /* * Changes the current maximum window size value. */ -void ossl_quic_rxfc_set_max_window_size(QUIC_RXFC *rxfc, size_t max_window_size); +void ossl_quic_rxfc_set_max_window_size(QUIC_RXFC *rxfc, + size_t max_window_size); /* * To be called whenever a STREAM frame is received. @@ -180,7 +182,8 @@ void ossl_quic_rxfc_set_max_window_size(QUIC_RXFC *rxfc, size_t max_window_size) * * Returns 1 on success or 0 on failure. */ -int ossl_quic_rxfc_on_rx_stream_frame(QUIC_RXFC *rxfc, uint64_t end, int is_fin); +int ossl_quic_rxfc_on_rx_stream_frame(QUIC_RXFC *rxfc, uint64_t end, + int is_fin); /* * To be called whenever controlled bytes are retired, i.e. when bytes are @@ -199,7 +202,8 @@ int ossl_quic_rxfc_on_rx_stream_frame(QUIC_RXFC *rxfc, uint64_t end, int is_fin) * * Returns 1 on success and 0 on failure. */ -int ossl_quic_rxfc_on_retire(QUIC_RXFC *rxfc, uint64_t num_bytes, OSSL_TIME rtt); +int ossl_quic_rxfc_on_retire(QUIC_RXFC *rxfc, uint64_t num_bytes, + OSSL_TIME rtt); /* * Returns the current CWM which the RXFC thinks the peer should have. diff --git a/libs/OpenSSL/include/internal/quic_fifd.h b/libs/OpenSSL/include/internal/quic_fifd.h index 8a9717b7..f8038225 100644 --- a/libs/OpenSSL/include/internal/quic_fifd.h +++ b/libs/OpenSSL/include/internal/quic_fifd.h @@ -23,25 +23,28 @@ */ struct quic_fifd_st { - /* Internal data; use the ossl_quic_fifd functions. */ - QUIC_CFQ *cfq; - OSSL_ACKM *ackm; - QUIC_TXPIM *txpim; - QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, uint32_t pn_space, void *arg); - void *get_sstream_by_id_arg; - void (*regen_frame)(uint64_t frame_type, uint64_t stream_id, QUIC_TXPIM_PKT *pkt, void *arg); - void *regen_frame_arg; + /* Internal data; use the ossl_quic_fifd functions. */ + QUIC_CFQ *cfq; + OSSL_ACKM *ackm; + QUIC_TXPIM *txpim; + QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, uint32_t pn_space, + void *arg); + void *get_sstream_by_id_arg; + void (*regen_frame)(uint64_t frame_type, uint64_t stream_id, + QUIC_TXPIM_PKT *pkt, void *arg); + void *regen_frame_arg; }; -int ossl_quic_fifd_init(QUIC_FIFD *fifd, QUIC_CFQ *cfq, OSSL_ACKM *ackm, QUIC_TXPIM *txpim, - /* stream_id is UINT64_MAX for the crypto stream */ - QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, uint32_t pn_space, - void *arg), - void *get_sstream_by_id_arg, - /* stream_id is UINT64_MAX if not applicable */ - void (*regen_frame)(uint64_t frame_type, uint64_t stream_id, - QUIC_TXPIM_PKT *pkt, void *arg), - void *regen_frame_arg); +int ossl_quic_fifd_init( + QUIC_FIFD *fifd, QUIC_CFQ *cfq, OSSL_ACKM *ackm, QUIC_TXPIM *txpim, + /* stream_id is UINT64_MAX for the crypto stream */ + QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, uint32_t pn_space, + void *arg), + void *get_sstream_by_id_arg, + /* stream_id is UINT64_MAX if not applicable */ + void (*regen_frame)(uint64_t frame_type, uint64_t stream_id, + QUIC_TXPIM_PKT *pkt, void *arg), + void *regen_frame_arg); void ossl_quic_fifd_cleanup(QUIC_FIFD *fifd); /* (no-op) */ diff --git a/libs/OpenSSL/include/internal/quic_record_rx.h b/libs/OpenSSL/include/internal/quic_record_rx.h index 969eb051..fece6400 100644 --- a/libs/OpenSSL/include/internal/quic_record_rx.h +++ b/libs/OpenSSL/include/internal/quic_record_rx.h @@ -24,26 +24,26 @@ typedef struct ossl_qrx_st OSSL_QRX; typedef struct ossl_qrx_args_st { - OSSL_LIB_CTX *libctx; - const char *propq; + OSSL_LIB_CTX *libctx; + const char *propq; - /* Demux to receive datagrams from. */ - QUIC_DEMUX *demux; + /* Demux to receive datagrams from. */ + QUIC_DEMUX *demux; - /* Length of connection IDs used in short-header packets in bytes. */ - size_t short_conn_id_len; + /* Length of connection IDs used in short-header packets in bytes. */ + size_t short_conn_id_len; - /* - * Maximum number of deferred datagrams buffered at any one time. - * Suggested value: 32. - */ - size_t max_deferred; + /* + * Maximum number of deferred datagrams buffered at any one time. + * Suggested value: 32. + */ + size_t max_deferred; - /* Initial reference PN used for RX. */ - QUIC_PN init_largest_pn[QUIC_PN_SPACE_NUM]; + /* Initial reference PN used for RX. */ + QUIC_PN init_largest_pn[QUIC_PN_SPACE_NUM]; - /* Initial key phase. For debugging use only; always 0 in real use. */ - unsigned char init_key_phase_bit; + /* Initial key phase. For debugging use only; always 0 in real use. */ + unsigned char init_key_phase_bit; } OSSL_QRX_ARGS; /* Instantiates a new QRX. */ @@ -172,7 +172,8 @@ int ossl_qrx_remove_dst_conn_id(OSSL_QRX *qrx, const QUIC_CONN_ID *dst_conn_id); * * Returns 1 on success or 0 on failure. */ -int ossl_qrx_provide_secret(OSSL_QRX *qrx, uint32_t enc_level, uint32_t suite_id, EVP_MD *md, +int ossl_qrx_provide_secret(OSSL_QRX *qrx, uint32_t enc_level, + uint32_t suite_id, EVP_MD *md, const unsigned char *secret, size_t secret_len); /* @@ -193,45 +194,45 @@ int ossl_qrx_discard_enc_level(OSSL_QRX *qrx, uint32_t enc_level); /* Information about a received packet. */ typedef struct ossl_qrx_pkt_st { - /* Opaque handle to be passed to ossl_qrx_release_pkt. */ - void *handle; + /* Opaque handle to be passed to ossl_qrx_release_pkt. */ + void *handle; - /* - * Points to a logical representation of the decoded QUIC packet header. The - * data and len fields point to the decrypted QUIC payload (i.e., to a - * sequence of zero or more (potentially malformed) frames to be decoded). - */ - QUIC_PKT_HDR *hdr; + /* + * Points to a logical representation of the decoded QUIC packet header. The + * data and len fields point to the decrypted QUIC payload (i.e., to a + * sequence of zero or more (potentially malformed) frames to be decoded). + */ + QUIC_PKT_HDR *hdr; - /* - * Address the packet was received from. If this is not available for this - * packet, this field is NULL (but this can only occur for manually injected - * packets). - */ - const BIO_ADDR *peer; + /* + * Address the packet was received from. If this is not available for this + * packet, this field is NULL (but this can only occur for manually injected + * packets). + */ + const BIO_ADDR *peer; - /* - * Local address the packet was sent to. If this is not available for this - * packet, this field is NULL. - */ - const BIO_ADDR *local; + /* + * Local address the packet was sent to. If this is not available for this + * packet, this field is NULL. + */ + const BIO_ADDR *local; - /* - * This is the length of the datagram which contained this packet. Note that - * the datagram may have contained other packets than this. The intended use - * for this is so that the user can enforce minimum datagram sizes (e.g. for - * datagrams containing INITIAL packets), as required by RFC 9000. - */ - size_t datagram_len; + /* + * This is the length of the datagram which contained this packet. Note that + * the datagram may have contained other packets than this. The intended use + * for this is so that the user can enforce minimum datagram sizes (e.g. for + * datagrams containing INITIAL packets), as required by RFC 9000. + */ + size_t datagram_len; - /* The PN which was decoded for the packet, if the packet has a PN field. */ - QUIC_PN pn; + /* The PN which was decoded for the packet, if the packet has a PN field. */ + QUIC_PN pn; - /* - * Time the packet was received, or ossl_time_zero() if the demuxer is not - * using a now() function. - */ - OSSL_TIME time; + /* + * Time the packet was received, or ossl_time_zero() if the demuxer is not + * using a now() function. + */ + OSSL_TIME time; } OSSL_QRX_PKT; /* @@ -302,7 +303,9 @@ uint64_t ossl_qrx_get_bytes_received(OSSL_QRX *qrx, int clear); */ typedef int(ossl_qrx_early_validation_cb)(QUIC_PN pn, int pn_space, void *arg); -int ossl_qrx_set_early_validation_cb(OSSL_QRX *qrx, ossl_qrx_early_validation_cb *cb, void *cb_arg); +int ossl_qrx_set_early_validation_cb(OSSL_QRX *qrx, + ossl_qrx_early_validation_cb *cb, + void *cb_arg); /* * Key Update (RX) @@ -467,7 +470,8 @@ uint64_t ossl_qrx_get_key_epoch(OSSL_QRX *qrx); */ typedef void(ossl_qrx_key_update_cb)(void *arg); -int ossl_qrx_set_key_update_cb(OSSL_QRX *qrx, ossl_qrx_key_update_cb *cb, void *cb_arg); +int ossl_qrx_set_key_update_cb(OSSL_QRX *qrx, ossl_qrx_key_update_cb *cb, + void *cb_arg); /* * Relates to the 1-RTT encryption level. The caller should call this after the diff --git a/libs/OpenSSL/include/internal/quic_record_rx_wrap.h b/libs/OpenSSL/include/internal/quic_record_rx_wrap.h index c9519c16..866c3ad7 100644 --- a/libs/OpenSSL/include/internal/quic_record_rx_wrap.h +++ b/libs/OpenSSL/include/internal/quic_record_rx_wrap.h @@ -31,10 +31,10 @@ typedef struct ossl_qrx_pkt_wrap_st { - void *handle; /* This is a copy of |pkt->handle| */ - OSSL_QRX_PKT *pkt; - CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; /* For reference counting without atomic */ + void *handle; /* This is a copy of |pkt->handle| */ + OSSL_QRX_PKT *pkt; + CRYPTO_REF_COUNT references; + CRYPTO_RWLOCK *lock; /* For reference counting without atomic */ } OSSL_QRX_PKT_WRAP; OSSL_QRX_PKT_WRAP *ossl_qrx_pkt_wrap_new(OSSL_QRX_PKT *pkt); diff --git a/libs/OpenSSL/include/internal/quic_record_tx.h b/libs/OpenSSL/include/internal/quic_record_tx.h index 9811b545..28ab5e39 100644 --- a/libs/OpenSSL/include/internal/quic_record_tx.h +++ b/libs/OpenSSL/include/internal/quic_record_tx.h @@ -23,14 +23,14 @@ typedef struct ossl_qtx_st OSSL_QTX; typedef struct ossl_qtx_args_st { - OSSL_LIB_CTX *libctx; - const char *propq; + OSSL_LIB_CTX *libctx; + const char *propq; - /* BIO to transmit to. */ - BIO *bio; + /* BIO to transmit to. */ + BIO *bio; - /* Maximum datagram payload length (MDPL) for TX purposes. */ - size_t mdpl; + /* Maximum datagram payload length (MDPL) for TX purposes. */ + size_t mdpl; } OSSL_QTX_ARGS; /* Instantiates a new QTX. */ @@ -75,7 +75,8 @@ void ossl_qtx_free(OSSL_QTX *qtx); * * Returns 1 on success or 0 on failure. */ -int ossl_qtx_provide_secret(OSSL_QTX *qtx, uint32_t enc_level, uint32_t suite_id, EVP_MD *md, +int ossl_qtx_provide_secret(OSSL_QTX *qtx, uint32_t enc_level, + uint32_t suite_id, EVP_MD *md, const unsigned char *secret, size_t secret_len); /* @@ -97,7 +98,8 @@ int ossl_qtx_is_enc_level_provisioned(OSSL_QTX *qtx, uint32_t enc_level); * small. The result is written to *plaintext_len. */ int ossl_qtx_calculate_plaintext_payload_len(OSSL_QTX *qtx, uint32_t enc_level, - size_t ciphertext_len, size_t *plaintext_len); + size_t ciphertext_len, + size_t *plaintext_len); uint32_t ossl_qrl_get_suite_cipher_tag_len(uint32_t suite_id); @@ -107,39 +109,39 @@ uint32_t ossl_qrl_get_suite_cipher_tag_len(uint32_t suite_id); */ typedef struct ossl_qtx_iovec_st { - const unsigned char *buf; - size_t buf_len; + const unsigned char *buf; + size_t buf_len; } OSSL_QTX_IOVEC; typedef struct ossl_qtx_pkt_st { - /* Logical packet header to be serialized. */ - QUIC_PKT_HDR *hdr; + /* Logical packet header to be serialized. */ + QUIC_PKT_HDR *hdr; - /* - * iovecs expressing the logical packet payload buffer. Zero-length entries - * are permitted. - */ - const OSSL_QTX_IOVEC *iovec; - size_t num_iovec; + /* + * iovecs expressing the logical packet payload buffer. Zero-length entries + * are permitted. + */ + const OSSL_QTX_IOVEC *iovec; + size_t num_iovec; - /* Destination address. Will be passed through to the BIO if non-NULL. */ - const BIO_ADDR *peer; + /* Destination address. Will be passed through to the BIO if non-NULL. */ + const BIO_ADDR *peer; - /* - * Local address (optional). Specify as non-NULL only if TX BIO - * has local address support enabled. - */ - const BIO_ADDR *local; + /* + * Local address (optional). Specify as non-NULL only if TX BIO + * has local address support enabled. + */ + const BIO_ADDR *local; - /* - * Logical PN. Used for encryption. This will automatically be encoded to - * hdr->pn, which need not be initialized. - */ - QUIC_PN pn; + /* + * Logical PN. Used for encryption. This will automatically be encoded to + * hdr->pn, which need not be initialized. + */ + QUIC_PN pn; - /* Packet flags. Zero or more OSSL_QTX_PKT_FLAG_* values. */ - uint32_t flags; + /* Packet flags. Zero or more OSSL_QTX_PKT_FLAG_* values. */ + uint32_t flags; } OSSL_QTX_PKT; /* diff --git a/libs/OpenSSL/include/internal/quic_record_util.h b/libs/OpenSSL/include/internal/quic_record_util.h index a08d88d7..d25b34b7 100644 --- a/libs/OpenSSL/include/internal/quic_record_util.h +++ b/libs/OpenSSL/include/internal/quic_record_util.h @@ -22,8 +22,9 @@ struct ossl_qtx_st; */ /* HKDF-Extract(salt, IKM) (RFC 5869) */ -int ossl_quic_hkdf_extract(OSSL_LIB_CTX *libctx, const char *propq, const EVP_MD *md, - const unsigned char *salt, size_t salt_len, const unsigned char *ikm, +int ossl_quic_hkdf_extract(OSSL_LIB_CTX *libctx, const char *propq, + const EVP_MD *md, const unsigned char *salt, + size_t salt_len, const unsigned char *ikm, size_t ikm_len, unsigned char *out, size_t out_len); /* @@ -54,8 +55,9 @@ int ossl_quic_hkdf_extract(OSSL_LIB_CTX *libctx, const char *propq, const EVP_MD * Returns 1 on success or 0 on error. */ int ossl_quic_provide_initial_secret(OSSL_LIB_CTX *libctx, const char *propq, - const QUIC_CONN_ID *dst_conn_id, int is_server, - struct ossl_qrx_st *qrx, struct ossl_qtx_st *qtx); + const QUIC_CONN_ID *dst_conn_id, + int is_server, struct ossl_qrx_st *qrx, + struct ossl_qtx_st *qtx); /* * QUIC Record Layer Ciphersuite Info @@ -63,8 +65,8 @@ int ossl_quic_provide_initial_secret(OSSL_LIB_CTX *libctx, const char *propq, */ /* Available QUIC Record Layer (QRL) ciphersuites. */ -#define QRL_SUITE_AES128GCM 1 /* SHA256 */ -#define QRL_SUITE_AES256GCM 2 /* SHA384 */ +#define QRL_SUITE_AES128GCM 1 /* SHA256 */ +#define QRL_SUITE_AES256GCM 2 /* SHA384 */ #define QRL_SUITE_CHACHA20POLY1305 3 /* SHA256 */ /* Returns cipher name in bytes or NULL if suite ID is invalid. */ diff --git a/libs/OpenSSL/include/internal/quic_sf_list.h b/libs/OpenSSL/include/internal/quic_sf_list.h index 641298e1..7c11548a 100644 --- a/libs/OpenSSL/include/internal/quic_sf_list.h +++ b/libs/OpenSSL/include/internal/quic_sf_list.h @@ -39,20 +39,21 @@ typedef struct stream_frame_st STREAM_FRAME; typedef struct sframe_list_st { - OSSL_QRX *qrx; - STREAM_FRAME *head, *tail; - /* Is the tail frame final. */ - unsigned int fin; - /* Number of stream frames in the list. */ - size_t num_frames; - /* Offset of data not yet dropped */ - uint64_t offset; + OSSL_QRX *qrx; + STREAM_FRAME *head, *tail; + /* Is the tail frame final. */ + unsigned int fin; + /* Number of stream frames in the list. */ + size_t num_frames; + /* Offset of data not yet dropped */ + uint64_t offset; } SFRAME_LIST; void ossl_sframe_list_init(SFRAME_LIST *fl, OSSL_QRX *qrx); void ossl_sframe_list_destroy(SFRAME_LIST *fl); -int ossl_sframe_list_insert(SFRAME_LIST *fl, UINT_RANGE *range, OSSL_QRX_PKT_WRAP *pkt, - const unsigned char *data, int fin); +int ossl_sframe_list_insert(SFRAME_LIST *fl, UINT_RANGE *range, + OSSL_QRX_PKT_WRAP *pkt, const unsigned char *data, + int fin); int ossl_sframe_list_peek(const SFRAME_LIST *fl, void **iter, UINT_RANGE *range, const unsigned char **data, int *fin); int ossl_sframe_list_drop_frames(SFRAME_LIST *fl, uint64_t limit); diff --git a/libs/OpenSSL/include/internal/quic_ssl.h b/libs/OpenSSL/include/internal/quic_ssl.h index e852ed48..f19fa0bd 100644 --- a/libs/OpenSSL/include/internal/quic_ssl.h +++ b/libs/OpenSSL/include/internal/quic_ssl.h @@ -12,7 +12,7 @@ #include #include "internal/quic_record_rx.h" /* OSSL_QRX */ -#include "internal/quic_ackm.h" /* OSSL_ACKM */ +#include "internal/quic_ackm.h" /* OSSL_ACKM */ __owur SSL *ossl_quic_new(SSL_CTX *ctx); __owur int ossl_quic_init(SSL *s); @@ -24,12 +24,14 @@ __owur int ossl_quic_accept(SSL *s); __owur int ossl_quic_connect(SSL *s); __owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes); __owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes); -__owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written); +__owur int ossl_quic_write(SSL *s, const void *buf, size_t len, + size_t *written); __owur int ossl_quic_shutdown(SSL *s); __owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg); __owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); __owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp)(void)); -__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)); +__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, + void (*fp)(void)); __owur size_t ossl_quic_pending(const SSL *s); __owur OSSL_TIME ossl_quic_default_timeout(void); __owur int ossl_quic_num_ciphers(void); diff --git a/libs/OpenSSL/include/internal/quic_statm.h b/libs/OpenSSL/include/internal/quic_statm.h index 4cbf0e91..27a6cfa2 100644 --- a/libs/OpenSSL/include/internal/quic_statm.h +++ b/libs/OpenSSL/include/internal/quic_statm.h @@ -15,14 +15,14 @@ typedef struct ossl_statm_st { - OSSL_TIME smoothed_rtt, latest_rtt, min_rtt, rtt_variance, max_ack_delay; - char have_first_sample; + OSSL_TIME smoothed_rtt, latest_rtt, min_rtt, rtt_variance, max_ack_delay; + char have_first_sample; } OSSL_STATM; typedef struct ossl_rtt_info_st { - /* As defined in RFC 9002. */ - OSSL_TIME smoothed_rtt, latest_rtt, rtt_variance, min_rtt, max_ack_delay; + /* As defined in RFC 9002. */ + OSSL_TIME smoothed_rtt, latest_rtt, rtt_variance, min_rtt, max_ack_delay; } OSSL_RTT_INFO; int ossl_statm_init(OSSL_STATM *statm); @@ -31,7 +31,8 @@ void ossl_statm_destroy(OSSL_STATM *statm); void ossl_statm_get_rtt_info(OSSL_STATM *statm, OSSL_RTT_INFO *rtt_info); -void ossl_statm_update_rtt(OSSL_STATM *statm, OSSL_TIME ack_delay, OSSL_TIME override_latest_rtt); +void ossl_statm_update_rtt(OSSL_STATM *statm, OSSL_TIME ack_delay, + OSSL_TIME override_latest_rtt); void ossl_statm_set_max_ack_delay(OSSL_STATM *statm, OSSL_TIME max_ack_delay); diff --git a/libs/OpenSSL/include/internal/quic_stream.h b/libs/OpenSSL/include/internal/quic_stream.h index c566a826..75ea8cb4 100644 --- a/libs/OpenSSL/include/internal/quic_stream.h +++ b/libs/OpenSSL/include/internal/quic_stream.h @@ -61,8 +61,8 @@ QUIC_SSTREAM *ossl_quic_sstream_new(size_t init_buf_size); /* * Frees a QUIC_SSTREAM and associated stream data storage. * - * Any iovecs returned by ossl_quic_sstream_get_stream_frame cease to be valid after - * calling this function. + * Any iovecs returned by ossl_quic_sstream_get_stream_frame cease to be valid + * after calling this function. */ void ossl_quic_sstream_free(QUIC_SSTREAM *qss); @@ -95,12 +95,13 @@ void ossl_quic_sstream_free(QUIC_SSTREAM *qss); * done by updating hdr->len and then calling the utility function * ossl_quic_sstream_adjust_iov(). * - * After committing one or more bytes returned by ossl_quic_sstream_get_stream_frame to a - * packet, call ossl_quic_sstream_mark_transmitted with the inclusive range of logical - * byte numbers of the transmitted bytes (i.e., hdr->offset, hdr->offset + - * hdr->len - 1). If you do not call ossl_quic_sstream_mark_transmitted, the next call to - * ossl_quic_sstream_get_stream_frame will return the same data (or potentially the same - * and more, if more data has been appended by the application). + * After committing one or more bytes returned by + * ossl_quic_sstream_get_stream_frame to a packet, call + * ossl_quic_sstream_mark_transmitted with the inclusive range of logical byte + * numbers of the transmitted bytes (i.e., hdr->offset, hdr->offset + hdr->len - + * 1). If you do not call ossl_quic_sstream_mark_transmitted, the next call to + * ossl_quic_sstream_get_stream_frame will return the same data (or potentially + * the same and more, if more data has been appended by the application). * * It is the caller's responsibility to clamp the length of data which this * function indicates is available according to other concerns, such as @@ -109,10 +110,10 @@ void ossl_quic_sstream_free(QUIC_SSTREAM *qss); * * The skip argument can usually be given as zero. If it is non-zero, this * function outputs a range which would be output if it were called again after - * calling ossl_quic_sstream_mark_transmitted() with the returned range, repeated 'skip' - * times, and so on. This may be useful for callers which wish to enumerate - * available stream frames and batch their calls to ossl_quic_sstream_mark_transmitted at - * a later time. + * calling ossl_quic_sstream_mark_transmitted() with the returned range, + * repeated 'skip' times, and so on. This may be useful for callers which wish + * to enumerate available stream frames and batch their calls to + * ossl_quic_sstream_mark_transmitted at a later time. * * On success, this function will never write *num_iov with a value other than * 0, 1 or 2. A *num_iov value of 0 can only occurs when hdr->is_fin is set (for @@ -124,7 +125,8 @@ void ossl_quic_sstream_free(QUIC_SSTREAM *qss); * transmission, or on other error (such as if the caller provides fewer * than two IOVs.) */ -int ossl_quic_sstream_get_stream_frame(QUIC_SSTREAM *qss, size_t skip, OSSL_QUIC_FRAME_STREAM *hdr, +int ossl_quic_sstream_get_stream_frame(QUIC_SSTREAM *qss, size_t skip, + OSSL_QUIC_FRAME_STREAM *hdr, OSSL_QTX_IOVEC *iov, size_t *num_iov); /* @@ -146,35 +148,39 @@ uint64_t ossl_quic_sstream_get_cur_size(QUIC_SSTREAM *qss); * ossl_quic_sstream_mark_transmitted_fin() after calling this function. * * If you sent a zero-length STREAM frame with the FIN bit set, you need only - * call ossl_quic_sstream_mark_transmitted_fin() and must not call this function. + * call ossl_quic_sstream_mark_transmitted_fin() and must not call this + * function. * * Returns 1 on success and 0 on error (e.g. if end < start). */ -int ossl_quic_sstream_mark_transmitted(QUIC_SSTREAM *qss, uint64_t start, uint64_t end); +int ossl_quic_sstream_mark_transmitted(QUIC_SSTREAM *qss, uint64_t start, + uint64_t end); /* * (For TX packetizer use.) Marks a STREAM frame with the FIN bit set as having * been transmitted. final_size is the final size of the stream (i.e., the value * offset + len of the transmitted STREAM frame). * - * This function fails returning 0 if ossl_quic_sstream_fin() has not been called or if - * final_size is not correct. The final_size argument is not strictly needed by - * the QUIC_SSTREAM but is required as a sanity check. + * This function fails returning 0 if ossl_quic_sstream_fin() has not been + * called or if final_size is not correct. The final_size argument is not + * strictly needed by the QUIC_SSTREAM but is required as a sanity check. */ -int ossl_quic_sstream_mark_transmitted_fin(QUIC_SSTREAM *qss, uint64_t final_size); +int ossl_quic_sstream_mark_transmitted_fin(QUIC_SSTREAM *qss, + uint64_t final_size); /* * (RX/ACKM use.) Marks a logical range of the send stream as having been lost. * The send stream will return the lost data for retransmission on a future call - * to ossl_quic_sstream_get_stream_frame. The start and end values denote logical byte - * numbers and are inclusive. + * to ossl_quic_sstream_get_stream_frame. The start and end values denote + * logical byte numbers and are inclusive. * * If the lost frame had the FIN bit set, you must also call * ossl_quic_sstream_mark_lost_fin() after calling this function. * * Returns 1 on success and 0 on error (e.g. if end < start). */ -int ossl_quic_sstream_mark_lost(QUIC_SSTREAM *qss, uint64_t start, uint64_t end); +int ossl_quic_sstream_mark_lost(QUIC_SSTREAM *qss, uint64_t start, + uint64_t end); /* * (RX/ACKM use.) Informs the QUIC_SSTREAM that a STREAM frame with the FIN bit @@ -196,7 +202,8 @@ int ossl_quic_sstream_mark_lost_fin(QUIC_SSTREAM *qss); * * Returns 1 on success and 0 on error (e.g. if end < start). */ -int ossl_quic_sstream_mark_acked(QUIC_SSTREAM *qss, uint64_t start, uint64_t end); +int ossl_quic_sstream_mark_acked(QUIC_SSTREAM *qss, uint64_t start, + uint64_t end); /* * (RX/ACKM use.) Informs the QUIC_SSTREAM that a STREAM frame with the FIN bit @@ -210,8 +217,9 @@ int ossl_quic_sstream_mark_acked_fin(QUIC_SSTREAM *qss); * (Front end use.) Appends user data to the stream. The data is copied into the * stream. The amount of data consumed from buf is written to *consumed on * success (short writes are possible). The amount of data which can be written - * can be determined in advance by calling the ossl_quic_sstream_get_buffer_avail() - * function; data is copied into an internal ring buffer of finite size. + * can be determined in advance by calling the + * ossl_quic_sstream_get_buffer_avail() function; data is copied into an + * internal ring buffer of finite size. * * If the buffer is full, this should be materialised as a backpressure * condition by the front end. This is not considered a failure condition; @@ -219,12 +227,12 @@ int ossl_quic_sstream_mark_acked_fin(QUIC_SSTREAM *qss); * * Returns 1 on success or 0 on failure. */ -int ossl_quic_sstream_append(QUIC_SSTREAM *qss, const unsigned char *buf, size_t buf_len, - size_t *consumed); +int ossl_quic_sstream_append(QUIC_SSTREAM *qss, const unsigned char *buf, + size_t buf_len, size_t *consumed); /* - * Marks a stream as finished. ossl_quic_sstream_append() may not be called anymore - * after calling this. + * Marks a stream as finished. ossl_quic_sstream_append() may not be called + * anymore after calling this. */ void ossl_quic_sstream_fin(QUIC_SSTREAM *qss); @@ -236,7 +244,8 @@ void ossl_quic_sstream_fin(QUIC_SSTREAM *qss); * Returns 1 on success and 0 on failure. * * IMPORTANT: Any buffers referenced by iovecs output by - * ossl_quic_sstream_get_stream_frame() cease to be valid after calling this function. + * ossl_quic_sstream_get_stream_frame() cease to be valid after calling this + * function. */ int ossl_quic_sstream_set_buffer_size(QUIC_SSTREAM *qss, size_t num_bytes); @@ -260,7 +269,8 @@ size_t ossl_quic_sstream_get_buffer_avail(QUIC_SSTREAM *qss); * length given as len. Trailing iovecs have their length values reduced or set * to 0 as necessary. */ -void ossl_quic_sstream_adjust_iov(size_t len, OSSL_QTX_IOVEC *iov, size_t num_iov); +void ossl_quic_sstream_adjust_iov(size_t len, OSSL_QTX_IOVEC *iov, + size_t num_iov); /* * QUIC Receive Stream Manager @@ -282,7 +292,8 @@ typedef struct quic_rstream_st QUIC_RSTREAM; * If they are non-NULL, the `rxfc` is called when receive stream data * is read by application. `statm` is queried for current rtt. */ -QUIC_RSTREAM *ossl_quic_rstream_new(OSSL_QRX *qrx, QUIC_RXFC *rxfc, OSSL_STATM *statm); +QUIC_RSTREAM *ossl_quic_rstream_new(OSSL_QRX *qrx, QUIC_RXFC *rxfc, + OSSL_STATM *statm); /* * Frees a QUIC_RSTREAM and any associated storage. @@ -299,8 +310,9 @@ void ossl_quic_rstream_free(QUIC_RSTREAM *qrs); * Or to indicate `fin` without any further data added to the stream. */ -int ossl_quic_rstream_queue_data(QUIC_RSTREAM *qrs, OSSL_QRX_PKT_WRAP *pkt_wrap, uint64_t offset, - const unsigned char *data, uint64_t data_len, int fin); +int ossl_quic_rstream_queue_data(QUIC_RSTREAM *qrs, OSSL_QRX_PKT_WRAP *pkt_wrap, + uint64_t offset, const unsigned char *data, + uint64_t data_len, int fin); /* * Copies the data from the stream storage to buffer `buf` of size `size`. @@ -308,8 +320,8 @@ int ossl_quic_rstream_queue_data(QUIC_RSTREAM *qrs, OSSL_QRX_PKT_WRAP *pkt_wrap, * `fin` is set to 1 if all the data from the stream were read so the * stream is finished. It is set to 0 otherwise. */ -int ossl_quic_rstream_read(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, size_t *readbytes, - int *fin); +int ossl_quic_rstream_read(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, + size_t *readbytes, int *fin); /* * Peeks at the data in the stream storage. It copies them to buffer `buf` @@ -317,8 +329,8 @@ int ossl_quic_rstream_read(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, s * `fin` is set to 1 if the copied data reach end of the stream. * It is set to 0 otherwise. */ -int ossl_quic_rstream_peek(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, size_t *readbytes, - int *fin); +int ossl_quic_rstream_peek(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, + size_t *readbytes, int *fin); /* * Returns the size of the data available for reading. `fin` is set to 1 if diff --git a/libs/OpenSSL/include/internal/quic_stream_map.h b/libs/OpenSSL/include/internal/quic_stream_map.h index fe430a8f..e2dd613e 100644 --- a/libs/OpenSSL/include/internal/quic_stream_map.h +++ b/libs/OpenSSL/include/internal/quic_stream_map.h @@ -30,69 +30,69 @@ typedef struct quic_stream_list_node_st QUIC_STREAM_LIST_NODE; struct quic_stream_list_node_st { - QUIC_STREAM_LIST_NODE *prev, *next; + QUIC_STREAM_LIST_NODE *prev, *next; }; struct quic_stream_st { - QUIC_STREAM_LIST_NODE active_node; /* for use by QUIC_STREAM_MAP */ + QUIC_STREAM_LIST_NODE active_node; /* for use by QUIC_STREAM_MAP */ - /* Temporary link used by TXP. */ - QUIC_STREAM *txp_next; + /* Temporary link used by TXP. */ + QUIC_STREAM *txp_next; - /* - * QUIC Stream ID. Do not assume that this encodes a type as this is a - * version-specific property and may change between QUIC versions; instead, - * use the type field. - */ - uint64_t id; + /* + * QUIC Stream ID. Do not assume that this encodes a type as this is a + * version-specific property and may change between QUIC versions; instead, + * use the type field. + */ + uint64_t id; - /* - * Application Error Code (AEC) used for STOP_SENDING frame. - * This is only valid if stop_sending is 1. - */ - uint64_t stop_sending_aec; + /* + * Application Error Code (AEC) used for STOP_SENDING frame. + * This is only valid if stop_sending is 1. + */ + uint64_t stop_sending_aec; - /* - * Application Error Code (AEC) used for RESET_STREAM frame. - * This is only valid if reset_stream is 1. - */ - uint64_t reset_stream_aec; + /* + * Application Error Code (AEC) used for RESET_STREAM frame. + * This is only valid if reset_stream is 1. + */ + uint64_t reset_stream_aec; - /* Temporary value used by TXP. */ - uint64_t txp_txfc_new_credit_consumed; + /* Temporary value used by TXP. */ + uint64_t txp_txfc_new_credit_consumed; - QUIC_SSTREAM *sstream; /* NULL if RX-only */ - void *rstream; /* NULL if TX only (placeholder) */ - QUIC_TXFC txfc; /* NULL if RX-only */ - QUIC_RXFC rxfc; /* NULL if TX-only */ - unsigned int type : 8; /* QUIC_STREAM_INITIATOR_*, QUIC_STREAM_DIR_* */ - unsigned int active : 1; + QUIC_SSTREAM *sstream; /* NULL if RX-only */ + void *rstream; /* NULL if TX only (placeholder) */ + QUIC_TXFC txfc; /* NULL if RX-only */ + QUIC_RXFC rxfc; /* NULL if TX-only */ + unsigned int type : 8; /* QUIC_STREAM_INITIATOR_*, QUIC_STREAM_DIR_* */ + unsigned int active : 1; - /* - * Has STOP_SENDING been requested? Note that this is not the same as - * want_stop_sending below, as a STOP_SENDING frame may already have been - * sent and fully acknowledged. - */ - unsigned int stop_sending : 1; + /* + * Has STOP_SENDING been requested? Note that this is not the same as + * want_stop_sending below, as a STOP_SENDING frame may already have been + * sent and fully acknowledged. + */ + unsigned int stop_sending : 1; - /* - * Has RESET_STREAM been requested? Works identically to STOP_SENDING for - * transmission purposes. - */ - unsigned int reset_stream : 1; + /* + * Has RESET_STREAM been requested? Works identically to STOP_SENDING for + * transmission purposes. + */ + unsigned int reset_stream : 1; - /* Temporary flags used by TXP. */ - unsigned int txp_sent_fc : 1; - unsigned int txp_sent_stop_sending : 1; - unsigned int txp_sent_reset_stream : 1; - unsigned int txp_drained : 1; - unsigned int txp_blocked : 1; + /* Temporary flags used by TXP. */ + unsigned int txp_sent_fc : 1; + unsigned int txp_sent_stop_sending : 1; + unsigned int txp_sent_reset_stream : 1; + unsigned int txp_drained : 1; + unsigned int txp_blocked : 1; - /* Frame regeneration flags. */ - unsigned int want_max_stream_data : 1; /* used for regen only */ - unsigned int want_stop_sending : 1; /* used for gen or regen */ - unsigned int want_reset_stream : 1; /* used for gen or regen */ + /* Frame regeneration flags. */ + unsigned int want_max_stream_data : 1; /* used for regen only */ + unsigned int want_stop_sending : 1; /* used for gen or regen */ + unsigned int want_reset_stream : 1; /* used for gen or regen */ }; /* @@ -120,10 +120,10 @@ int ossl_quic_stream_reset(QUIC_STREAM *s, uint64_t aec); */ typedef struct quic_stream_map_st { - LHASH_OF(QUIC_STREAM) * map; - QUIC_STREAM_LIST_NODE active_list; - size_t rr_stepping, rr_counter; - QUIC_STREAM *rr_cur; + LHASH_OF(QUIC_STREAM) * map; + QUIC_STREAM_LIST_NODE active_list; + size_t rr_stepping, rr_counter; + QUIC_STREAM *rr_cur; } QUIC_STREAM_MAP; int ossl_quic_stream_map_init(QUIC_STREAM_MAP *qsm); @@ -151,7 +151,8 @@ void ossl_quic_stream_map_cleanup(QUIC_STREAM_MAP *qsm); * stream_id must be a valid value. Returns NULL if a stream already exists * with the given ID. */ -QUIC_STREAM *ossl_quic_stream_map_alloc(QUIC_STREAM_MAP *qsm, uint64_t stream_id, int type); +QUIC_STREAM *ossl_quic_stream_map_alloc(QUIC_STREAM_MAP *qsm, + uint64_t stream_id, int type); /* * Releases a stream object. Note that this must only be done once the teardown @@ -164,13 +165,15 @@ void ossl_quic_stream_map_release(QUIC_STREAM_MAP *qsm, QUIC_STREAM *stream); * argument which is passed through. */ void ossl_quic_stream_map_visit(QUIC_STREAM_MAP *qsm, - void (*visit_cb)(QUIC_STREAM *stream, void *arg), + void (*visit_cb)(QUIC_STREAM *stream, + void *arg), void *visit_cb_arg); /* * Retrieves a stream by stream ID. Returns NULL if it does not exist. */ -QUIC_STREAM *ossl_quic_stream_map_get_by_id(QUIC_STREAM_MAP *qsm, uint64_t stream_id); +QUIC_STREAM *ossl_quic_stream_map_get_by_id(QUIC_STREAM_MAP *qsm, + uint64_t stream_id); /* * Marks the given stream as active or inactive based on its state. Idempotent. @@ -189,7 +192,8 @@ void ossl_quic_stream_map_update_state(QUIC_STREAM_MAP *qsm, QUIC_STREAM *s); * Sets the RR stepping value, n. The RR rotation will be advanced every n * packets. The default value is 1. */ -void ossl_quic_stream_map_set_rr_stepping(QUIC_STREAM_MAP *qsm, size_t stepping); +void ossl_quic_stream_map_set_rr_stepping(QUIC_STREAM_MAP *qsm, + size_t stepping); /* * QUIC Stream Iterator @@ -211,8 +215,8 @@ void ossl_quic_stream_map_set_rr_stepping(QUIC_STREAM_MAP *qsm, size_t stepping) */ typedef struct quic_stream_iter_st { - QUIC_STREAM_MAP *qsm; - QUIC_STREAM *first_stream, *stream; + QUIC_STREAM_MAP *qsm; + QUIC_STREAM *first_stream, *stream; } QUIC_STREAM_ITER; /* @@ -220,7 +224,8 @@ typedef struct quic_stream_iter_st * advance_rr is 1). After calling this, it->stream will be the first stream in * the iteration sequence, or NULL if there are no active streams. */ -void ossl_quic_stream_iter_init(QUIC_STREAM_ITER *it, QUIC_STREAM_MAP *qsm, int advance_rr); +void ossl_quic_stream_iter_init(QUIC_STREAM_ITER *it, QUIC_STREAM_MAP *qsm, + int advance_rr); /* * Advances to next stream in iteration sequence. You do not need to call this diff --git a/libs/OpenSSL/include/internal/quic_txp.h b/libs/OpenSSL/include/internal/quic_txp.h index 48b5ddfd..977bb3d9 100644 --- a/libs/OpenSSL/include/internal/quic_txp.h +++ b/libs/OpenSSL/include/internal/quic_txp.h @@ -27,39 +27,41 @@ */ typedef struct ossl_quic_tx_packetiser_args_st { - /* Configuration Settings */ - QUIC_CONN_ID cur_scid; /* Current Source Connection ID we use. */ - QUIC_CONN_ID cur_dcid; /* Current Destination Connection ID we use. */ - BIO_ADDR peer; /* Current destination L4 address we use. */ - uint32_t ack_delay_exponent; /* ACK delay exponent used when encoding. */ + /* Configuration Settings */ + QUIC_CONN_ID cur_scid; /* Current Source Connection ID we use. */ + QUIC_CONN_ID cur_dcid; /* Current Destination Connection ID we use. */ + BIO_ADDR peer; /* Current destination L4 address we use. */ + uint32_t ack_delay_exponent; /* ACK delay exponent used when encoding. */ - /* Injected Dependencies */ - OSSL_QTX *qtx; /* QUIC Record Layer TX we are using */ - QUIC_TXPIM *txpim; /* QUIC TX'd Packet Information Manager */ - QUIC_CFQ *cfq; /* QUIC Control Frame Queue */ - OSSL_ACKM *ackm; /* QUIC Acknowledgement Manager */ - QUIC_STREAM_MAP *qsm; /* QUIC Streams Map */ - QUIC_TXFC *conn_txfc; /* QUIC Connection-Level TX Flow Controller */ - QUIC_RXFC *conn_rxfc; /* QUIC Connection-Level RX Flow Controller */ - const OSSL_CC_METHOD *cc_method; /* QUIC Congestion Controller */ - OSSL_CC_DATA *cc_data; /* QUIC Congestion Controller Instance */ - OSSL_TIME (*now)(void *arg); /* Callback to get current time. */ - void *now_arg; + /* Injected Dependencies */ + OSSL_QTX *qtx; /* QUIC Record Layer TX we are using */ + QUIC_TXPIM *txpim; /* QUIC TX'd Packet Information Manager */ + QUIC_CFQ *cfq; /* QUIC Control Frame Queue */ + OSSL_ACKM *ackm; /* QUIC Acknowledgement Manager */ + QUIC_STREAM_MAP *qsm; /* QUIC Streams Map */ + QUIC_TXFC *conn_txfc; /* QUIC Connection-Level TX Flow Controller */ + QUIC_RXFC *conn_rxfc; /* QUIC Connection-Level RX Flow Controller */ + const OSSL_CC_METHOD *cc_method; /* QUIC Congestion Controller */ + OSSL_CC_DATA *cc_data; /* QUIC Congestion Controller Instance */ + OSSL_TIME (*now)(void *arg); /* Callback to get current time. */ + void *now_arg; - /* - * Injected dependencies - crypto streams. - * - * Note: There is no crypto stream for the 0-RTT EL. - * crypto[QUIC_PN_SPACE_APP] is the 1-RTT crypto stream. - */ - QUIC_SSTREAM *crypto[QUIC_PN_SPACE_NUM]; + /* + * Injected dependencies - crypto streams. + * + * Note: There is no crypto stream for the 0-RTT EL. + * crypto[QUIC_PN_SPACE_APP] is the 1-RTT crypto stream. + */ + QUIC_SSTREAM *crypto[QUIC_PN_SPACE_NUM]; } OSSL_QUIC_TX_PACKETISER_ARGS; typedef struct ossl_quic_tx_packetiser_st OSSL_QUIC_TX_PACKETISER; -OSSL_QUIC_TX_PACKETISER *ossl_quic_tx_packetiser_new(const OSSL_QUIC_TX_PACKETISER_ARGS *args); +OSSL_QUIC_TX_PACKETISER * +ossl_quic_tx_packetiser_new(const OSSL_QUIC_TX_PACKETISER_ARGS *args); -typedef void(ossl_quic_initial_token_free_fn)(const unsigned char *buf, size_t buf_len, void *arg); +typedef void(ossl_quic_initial_token_free_fn)(const unsigned char *buf, + size_t buf_len, void *arg); void ossl_quic_tx_packetiser_free(OSSL_QUIC_TX_PACKETISER *txp); @@ -83,26 +85,29 @@ void ossl_quic_tx_packetiser_free(OSSL_QUIC_TX_PACKETISER *txp); #define TX_PACKETISER_RES_FAILURE 0 #define TX_PACKETISER_RES_NO_PKT 1 #define TX_PACKETISER_RES_SENT_PKT 2 -int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp, uint32_t archetype); +int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp, + uint32_t archetype); /* * Set the token used in Initial packets. The callback is called when the buffer * is no longer needed; for example, when the TXP is freed or when this function * is called again with a new buffer. */ -void ossl_quic_tx_packetiser_set_initial_token(OSSL_QUIC_TX_PACKETISER *txp, - const unsigned char *token, size_t token_len, - ossl_quic_initial_token_free_fn *free_cb, - void *free_cb_arg); +void ossl_quic_tx_packetiser_set_initial_token( + OSSL_QUIC_TX_PACKETISER *txp, const unsigned char *token, size_t token_len, + ossl_quic_initial_token_free_fn *free_cb, void *free_cb_arg); /* Change the DCID the TXP uses to send outgoing packets. */ -int ossl_quic_tx_packetiser_set_cur_dcid(OSSL_QUIC_TX_PACKETISER *txp, const QUIC_CONN_ID *dcid); +int ossl_quic_tx_packetiser_set_cur_dcid(OSSL_QUIC_TX_PACKETISER *txp, + const QUIC_CONN_ID *dcid); /* Change the SCID the TXP uses to send outgoing (long) packets. */ -int ossl_quic_tx_packetiser_set_cur_scid(OSSL_QUIC_TX_PACKETISER *txp, const QUIC_CONN_ID *scid); +int ossl_quic_tx_packetiser_set_cur_scid(OSSL_QUIC_TX_PACKETISER *txp, + const QUIC_CONN_ID *scid); /* Change the destination L4 address the TXP uses to send datagrams. */ -int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp, const BIO_ADDR *peer); +int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp, + const BIO_ADDR *peer); /* * Inform the TX packetiser that an EL has been discarded. Idempotent. @@ -113,14 +118,17 @@ int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp, const BIO_ADD * provided in the TXP arguments. However, it is the callers responsibility to * free that QUIC_SSTREAM if desired. */ -int ossl_quic_tx_packetiser_discard_enc_level(OSSL_QUIC_TX_PACKETISER *txp, uint32_t enc_level); +int ossl_quic_tx_packetiser_discard_enc_level(OSSL_QUIC_TX_PACKETISER *txp, + uint32_t enc_level); /* Asks the TXP to generate a HANDSHAKE_DONE frame in the next 1-RTT packet. */ -void ossl_quic_tx_packetiser_schedule_handshake_done(OSSL_QUIC_TX_PACKETISER *txp); +void ossl_quic_tx_packetiser_schedule_handshake_done( + OSSL_QUIC_TX_PACKETISER *txp); -/* Asks the TXP to ensure the next packet in the given PN space is ACK-eliciting. */ -void ossl_quic_tx_packetiser_schedule_ack_eliciting(OSSL_QUIC_TX_PACKETISER *txp, - uint32_t pn_space); +/* Asks the TXP to ensure the next packet in the given PN space is + * ACK-eliciting. */ +void ossl_quic_tx_packetiser_schedule_ack_eliciting( + OSSL_QUIC_TX_PACKETISER *txp, uint32_t pn_space); /* * Schedules a connection close. *f and f->reason are copied. This operation is @@ -129,7 +137,7 @@ void ossl_quic_tx_packetiser_schedule_ack_eliciting(OSSL_QUIC_TX_PACKETISER *txp * successfully; the information in *f cannot be changed after the first * successful call to this function. */ -int ossl_quic_tx_packetiser_schedule_conn_close(OSSL_QUIC_TX_PACKETISER *txp, - const OSSL_QUIC_FRAME_CONN_CLOSE *f); +int ossl_quic_tx_packetiser_schedule_conn_close( + OSSL_QUIC_TX_PACKETISER *txp, const OSSL_QUIC_FRAME_CONN_CLOSE *f); #endif diff --git a/libs/OpenSSL/include/internal/quic_txpim.h b/libs/OpenSSL/include/internal/quic_txpim.h index 9256aced..d0dbff6f 100644 --- a/libs/OpenSSL/include/internal/quic_txpim.h +++ b/libs/OpenSSL/include/internal/quic_txpim.h @@ -24,52 +24,52 @@ typedef struct quic_fifd_st QUIC_FIFD; typedef struct quic_txpim_pkt_st { - /* ACKM-specific data. Caller should fill this. */ - OSSL_ACKM_TX_PKT ackm_pkt; + /* ACKM-specific data. Caller should fill this. */ + OSSL_ACKM_TX_PKT ackm_pkt; - /* Linked list of CFQ items in this packet. */ - QUIC_CFQ_ITEM *retx_head; + /* Linked list of CFQ items in this packet. */ + QUIC_CFQ_ITEM *retx_head; - /* Reserved for FIFD use. */ - QUIC_FIFD *fifd; + /* Reserved for FIFD use. */ + QUIC_FIFD *fifd; - /* Regenerate-strategy frames. */ - unsigned int had_handshake_done_frame : 1; - unsigned int had_max_data_frame : 1; - unsigned int had_max_streams_bidi_frame : 1; - unsigned int had_max_streams_uni_frame : 1; - unsigned int had_ack_frame : 1; + /* Regenerate-strategy frames. */ + unsigned int had_handshake_done_frame : 1; + unsigned int had_max_data_frame : 1; + unsigned int had_max_streams_bidi_frame : 1; + unsigned int had_max_streams_uni_frame : 1; + unsigned int had_ack_frame : 1; - /* Private data follows. */ + /* Private data follows. */ } QUIC_TXPIM_PKT; /* Represents a range of bytes in an application or CRYPTO stream. */ typedef struct quic_txpim_chunk_st { - /* The stream ID, or UINT64_MAX for the CRYPTO stream. */ - uint64_t stream_id; - /* - * The inclusive range of bytes in the stream. Exceptionally, if end < - * start, designates a frame of zero length (used for FIN-only frames). In - * this case end is the number of the final byte (i.e., one less than the - * final size of the stream). - */ - uint64_t start, end; - /* - * Whether a FIN was sent for this stream in the packet. Not valid for - * CRYPTO stream. - */ - unsigned int has_fin : 1; - /* - * If set, a STOP_SENDING frame was sent for this stream ID. (If no data was - * sent for the stream, set end < start.) - */ - unsigned int has_stop_sending : 1; - /* - * If set, a RESET_STREAM frame was sent for this stream ID. (If no data was - * sent for the stream, set end < start.) - */ - unsigned int has_reset_stream : 1; + /* The stream ID, or UINT64_MAX for the CRYPTO stream. */ + uint64_t stream_id; + /* + * The inclusive range of bytes in the stream. Exceptionally, if end < + * start, designates a frame of zero length (used for FIN-only frames). In + * this case end is the number of the final byte (i.e., one less than the + * final size of the stream). + */ + uint64_t start, end; + /* + * Whether a FIN was sent for this stream in the packet. Not valid for + * CRYPTO stream. + */ + unsigned int has_fin : 1; + /* + * If set, a STOP_SENDING frame was sent for this stream ID. (If no data was + * sent for the stream, set end < start.) + */ + unsigned int has_stop_sending : 1; + /* + * If set, a RESET_STREAM frame was sent for this stream ID. (If no data was + * sent for the stream, set end < start.) + */ + unsigned int has_reset_stream : 1; } QUIC_TXPIM_CHUNK; QUIC_TXPIM *ossl_quic_txpim_new(void); @@ -97,10 +97,12 @@ void ossl_quic_txpim_pkt_release(QUIC_TXPIM *txpim, QUIC_TXPIM_PKT *fpkt); void ossl_quic_txpim_pkt_clear_chunks(QUIC_TXPIM_PKT *fpkt); /* Appends a chunk to the packet. The structure is copied. */ -int ossl_quic_txpim_pkt_append_chunk(QUIC_TXPIM_PKT *fpkt, const QUIC_TXPIM_CHUNK *chunk); +int ossl_quic_txpim_pkt_append_chunk(QUIC_TXPIM_PKT *fpkt, + const QUIC_TXPIM_CHUNK *chunk); /* Adds a CFQ item to the packet by prepending it to the retx_head list. */ -void ossl_quic_txpim_pkt_add_cfq_item(QUIC_TXPIM_PKT *fpkt, QUIC_CFQ_ITEM *item); +void ossl_quic_txpim_pkt_add_cfq_item(QUIC_TXPIM_PKT *fpkt, + QUIC_CFQ_ITEM *item); /* * Returns a pointer to an array of stream chunk information structures for the @@ -111,7 +113,8 @@ void ossl_quic_txpim_pkt_add_cfq_item(QUIC_TXPIM_PKT *fpkt, QUIC_CFQ_ITEM *item) * * The chunks are sorted by (stream_id, start) in ascending order. */ -const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(const QUIC_TXPIM_PKT *fpkt); +const QUIC_TXPIM_CHUNK * +ossl_quic_txpim_pkt_get_chunks(const QUIC_TXPIM_PKT *fpkt); /* * Returns the number of entries in the array returned by diff --git a/libs/OpenSSL/include/internal/quic_types.h b/libs/OpenSSL/include/internal/quic_types.h index b20188f3..4691b03f 100644 --- a/libs/OpenSSL/include/internal/quic_types.h +++ b/libs/OpenSSL/include/internal/quic_types.h @@ -27,21 +27,22 @@ #define QUIC_PN_SPACE_APP 2 #define QUIC_PN_SPACE_NUM 3 -static ossl_unused ossl_inline uint32_t ossl_quic_enc_level_to_pn_space(uint32_t enc_level) +static ossl_unused ossl_inline uint32_t +ossl_quic_enc_level_to_pn_space(uint32_t enc_level) { - switch (enc_level) - { - case QUIC_ENC_LEVEL_INITIAL: - return QUIC_PN_SPACE_INITIAL; - case QUIC_ENC_LEVEL_HANDSHAKE: - return QUIC_PN_SPACE_HANDSHAKE; - case QUIC_ENC_LEVEL_0RTT: - case QUIC_ENC_LEVEL_1RTT: - return QUIC_PN_SPACE_APP; - default: - assert(0); - return QUIC_PN_SPACE_APP; - } + switch (enc_level) + { + case QUIC_ENC_LEVEL_INITIAL: + return QUIC_PN_SPACE_INITIAL; + case QUIC_ENC_LEVEL_HANDSHAKE: + return QUIC_PN_SPACE_HANDSHAKE; + case QUIC_ENC_LEVEL_0RTT: + case QUIC_ENC_LEVEL_1RTT: + return QUIC_PN_SPACE_APP; + default: + assert(0); + return QUIC_PN_SPACE_APP; + } } /* QUIC packet number spaces. */ @@ -56,12 +57,12 @@ typedef uint64_t QUIC_PN; static ossl_unused ossl_inline QUIC_PN ossl_quic_pn_max(QUIC_PN a, QUIC_PN b) { - return a > b ? a : b; + return a > b ? a : b; } static ossl_unused ossl_inline QUIC_PN ossl_quic_pn_min(QUIC_PN a, QUIC_PN b) { - return a < b ? a : b; + return a < b ? a : b; } /* QUIC connection ID representation. */ @@ -69,15 +70,15 @@ static ossl_unused ossl_inline QUIC_PN ossl_quic_pn_min(QUIC_PN a, QUIC_PN b) typedef struct quic_conn_id_st { - unsigned char id_len, id[QUIC_MAX_CONN_ID_LEN]; + unsigned char id_len, id[QUIC_MAX_CONN_ID_LEN]; } QUIC_CONN_ID; static ossl_unused ossl_inline int ossl_quic_conn_id_eq(const QUIC_CONN_ID *a, const QUIC_CONN_ID *b) { - if (a->id_len != b->id_len || a->id_len > QUIC_MAX_CONN_ID_LEN) - return 0; - return memcmp(a->id, b->id, a->id_len) == 0; + if (a->id_len != b->id_len || a->id_len > QUIC_MAX_CONN_ID_LEN) + return 0; + return memcmp(a->id, b->id, a->id_len) == 0; } #define QUIC_MIN_INITIAL_DGRAM_LEN 1200 diff --git a/libs/OpenSSL/include/internal/quic_vlint.h b/libs/OpenSSL/include/internal/quic_vlint.h index 45e700ff..3eb986bd 100644 --- a/libs/OpenSSL/include/internal/quic_vlint.h +++ b/libs/OpenSSL/include/internal/quic_vlint.h @@ -36,19 +36,19 @@ */ static ossl_unused ossl_inline size_t ossl_quic_vlint_encode_len(uint64_t v) { - if (v < OSSL_QUIC_VLINT_2B_MIN) - return 1; + if (v < OSSL_QUIC_VLINT_2B_MIN) + return 1; - if (v < OSSL_QUIC_VLINT_4B_MIN) - return 2; + if (v < OSSL_QUIC_VLINT_4B_MIN) + return 2; - if (v < OSSL_QUIC_VLINT_8B_MIN) - return 4; + if (v < OSSL_QUIC_VLINT_8B_MIN) + return 4; - if (v <= OSSL_QUIC_VLINT_MAX) - return 8; + if (v <= OSSL_QUIC_VLINT_MAX) + return 8; - return 0; + return 0; } /* @@ -92,19 +92,20 @@ void ossl_quic_vlint_encode_n(unsigned char *buf, uint64_t v, int n); * the number of bytes comprising the encoded integer, including the first * byte. */ -static ossl_unused ossl_inline size_t ossl_quic_vlint_decode_len(uint8_t first_byte) +static ossl_unused ossl_inline size_t +ossl_quic_vlint_decode_len(uint8_t first_byte) { - return 1U << ((first_byte & 0xC0) >> 6); + return 1U << ((first_byte & 0xC0) >> 6); } /* * Given a buffer containing an encoded QUIC variable-length integer, returns * the decoded value. The buffer must be of at least - * ossl_quic_vlint_decode_len(buf[0]) bytes in size, and the caller is responsible - * for checking this. + * ossl_quic_vlint_decode_len(buf[0]) bytes in size, and the caller is + * responsible for checking this. * - * Precondition: buf is at least ossl_quic_vlint_decode_len(buf[0]) bytes in size - * (unchecked) + * Precondition: buf is at least ossl_quic_vlint_decode_len(buf[0]) bytes in + * size (unchecked) */ uint64_t ossl_quic_vlint_decode_unchecked(const unsigned char *buf); @@ -118,6 +119,7 @@ uint64_t ossl_quic_vlint_decode_unchecked(const unsigned char *buf); * Precondition: buf is at least buf_len bytes in size * Precondition: v (unchecked) */ -int ossl_quic_vlint_decode(const unsigned char *buf, size_t buf_len, uint64_t *v); +int ossl_quic_vlint_decode(const unsigned char *buf, size_t buf_len, + uint64_t *v); #endif diff --git a/libs/OpenSSL/include/internal/quic_wire.h b/libs/OpenSSL/include/internal/quic_wire.h index 69d7e718..093683f3 100644 --- a/libs/OpenSSL/include/internal/quic_wire.h +++ b/libs/OpenSSL/include/internal/quic_wire.h @@ -47,49 +47,50 @@ /* Low 3 bits of the type contain flags */ #define OSSL_QUIC_FRAME_TYPE_STREAM 0x08 /* base ID */ -#define OSSL_QUIC_FRAME_TYPE_STREAM_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -#define OSSL_QUIC_FRAME_TYPE_STREAM_LEN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_LEN) -#define OSSL_QUIC_FRAME_TYPE_STREAM_LEN_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_LEN \ - | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF) -#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF \ - | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF \ - | OSSL_QUIC_FRAME_FLAG_STREAM_LEN) -#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF \ - | OSSL_QUIC_FRAME_FLAG_STREAM_LEN | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_LEN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_LEN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_LEN_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_LEN \ + | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF \ + | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF \ + | OSSL_QUIC_FRAME_FLAG_STREAM_LEN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF \ + | OSSL_QUIC_FRAME_FLAG_STREAM_LEN | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -#define OSSL_QUIC_FRAME_TYPE_IS_STREAM(x) \ - (((x) & ~OSSL_QUIC_FRAME_FLAG_STREAM_MASK) == OSSL_QUIC_FRAME_TYPE_STREAM) -#define OSSL_QUIC_FRAME_TYPE_IS_ACK(x) \ - (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN) -#define OSSL_QUIC_FRAME_TYPE_IS_MAX_STREAMS(x) \ - (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI) -#define OSSL_QUIC_FRAME_TYPE_IS_STREAMS_BLOCKED(x) \ - (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI) -#define OSSL_QUIC_FRAME_TYPE_IS_CONN_CLOSE(x) \ - (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT) +#define OSSL_QUIC_FRAME_TYPE_IS_STREAM(x) \ + (((x) & ~OSSL_QUIC_FRAME_FLAG_STREAM_MASK) == OSSL_QUIC_FRAME_TYPE_STREAM) +#define OSSL_QUIC_FRAME_TYPE_IS_ACK(x) \ + (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN) +#define OSSL_QUIC_FRAME_TYPE_IS_MAX_STREAMS(x) \ + (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI) +#define OSSL_QUIC_FRAME_TYPE_IS_STREAMS_BLOCKED(x) \ + (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI) +#define OSSL_QUIC_FRAME_TYPE_IS_CONN_CLOSE(x) \ + (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT) -static ossl_unused ossl_inline int ossl_quic_frame_type_is_ack_eliciting(uint64_t frame_type) +static ossl_unused ossl_inline int +ossl_quic_frame_type_is_ack_eliciting(uint64_t frame_type) { - switch (frame_type) - { - case OSSL_QUIC_FRAME_TYPE_PADDING: - case OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN: - case OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN: - case OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT: - case OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP: - return 0; - default: - return 1; - } + switch (frame_type) + { + case OSSL_QUIC_FRAME_TYPE_PADDING: + case OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN: + case OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN: + case OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT: + case OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP: + return 0; + default: + return 1; + } } /* @@ -100,101 +101,101 @@ static ossl_unused ossl_inline int ossl_quic_frame_type_is_ack_eliciting(uint64_ /* QUIC Frame: ACK */ typedef struct ossl_quic_ack_range_st { - /* - * Represents an inclusive range of packet numbers [start, end]. - * start must be <= end. - */ - QUIC_PN start, end; + /* + * Represents an inclusive range of packet numbers [start, end]. + * start must be <= end. + */ + QUIC_PN start, end; } OSSL_QUIC_ACK_RANGE; typedef struct ossl_quic_frame_ack_st { - /* - * A sequence of packet number ranges [[start, end]...]. - * - * The ranges must be sorted in descending order, for example: - * [ 95, 100] - * [ 90, 92] - * etc. - * - * As such, ack_ranges[0].end is always the highest packet number - * being acknowledged and ack_ranges[num_ack_ranges-1].start is - * always the lowest packet number being acknowledged. - * - * num_ack_ranges must be greater than zero, as an ACK frame must - * acknowledge at least one packet number. - */ - OSSL_QUIC_ACK_RANGE *ack_ranges; - size_t num_ack_ranges; + /* + * A sequence of packet number ranges [[start, end]...]. + * + * The ranges must be sorted in descending order, for example: + * [ 95, 100] + * [ 90, 92] + * etc. + * + * As such, ack_ranges[0].end is always the highest packet number + * being acknowledged and ack_ranges[num_ack_ranges-1].start is + * always the lowest packet number being acknowledged. + * + * num_ack_ranges must be greater than zero, as an ACK frame must + * acknowledge at least one packet number. + */ + OSSL_QUIC_ACK_RANGE *ack_ranges; + size_t num_ack_ranges; - OSSL_TIME delay_time; - uint64_t ect0, ect1, ecnce; - unsigned int ecn_present : 1; + OSSL_TIME delay_time; + uint64_t ect0, ect1, ecnce; + unsigned int ecn_present : 1; } OSSL_QUIC_FRAME_ACK; /* QUIC Frame: STREAM */ typedef struct ossl_quic_frame_stream_st { - uint64_t stream_id; /* Stream ID */ - uint64_t offset; /* Logical offset in stream */ - uint64_t len; /* Length of data in bytes */ - const unsigned char *data; + uint64_t stream_id; /* Stream ID */ + uint64_t offset; /* Logical offset in stream */ + uint64_t len; /* Length of data in bytes */ + const unsigned char *data; - /* - * On encode, this determines whether the len field should be encoded or - * not. If zero, the len field is not encoded and it is assumed the frame - * runs to the end of the packet. - * - * On decode, this determines whether the frame had an explicitly encoded - * length. If not set, the frame runs to the end of the packet and len has - * been set accordingly. - */ - unsigned int has_explicit_len : 1; + /* + * On encode, this determines whether the len field should be encoded or + * not. If zero, the len field is not encoded and it is assumed the frame + * runs to the end of the packet. + * + * On decode, this determines whether the frame had an explicitly encoded + * length. If not set, the frame runs to the end of the packet and len has + * been set accordingly. + */ + unsigned int has_explicit_len : 1; - /* 1 if this is the end of the stream */ - unsigned int is_fin : 1; + /* 1 if this is the end of the stream */ + unsigned int is_fin : 1; } OSSL_QUIC_FRAME_STREAM; /* QUIC Frame: CRYPTO */ typedef struct ossl_quic_frame_crypto_st { - uint64_t offset; /* Logical offset in stream */ - uint64_t len; /* Length of the data in bytes */ - const unsigned char *data; + uint64_t offset; /* Logical offset in stream */ + uint64_t len; /* Length of the data in bytes */ + const unsigned char *data; } OSSL_QUIC_FRAME_CRYPTO; /* QUIC Frame: RESET_STREAM */ typedef struct ossl_quic_frame_reset_stream_st { - uint64_t stream_id; - uint64_t app_error_code; - uint64_t final_size; + uint64_t stream_id; + uint64_t app_error_code; + uint64_t final_size; } OSSL_QUIC_FRAME_RESET_STREAM; /* QUIC Frame: STOP_SENDING */ typedef struct ossl_quic_frame_stop_sending_st { - uint64_t stream_id; - uint64_t app_error_code; + uint64_t stream_id; + uint64_t app_error_code; } OSSL_QUIC_FRAME_STOP_SENDING; /* QUIC Frame: NEW_CONNECTION_ID */ typedef struct ossl_quic_frame_new_conn_id_st { - uint64_t seq_num; - uint64_t retire_prior_to; - QUIC_CONN_ID conn_id; - unsigned char stateless_reset_token[16]; + uint64_t seq_num; + uint64_t retire_prior_to; + QUIC_CONN_ID conn_id; + unsigned char stateless_reset_token[16]; } OSSL_QUIC_FRAME_NEW_CONN_ID; /* QUIC Frame: CONNECTION_CLOSE */ typedef struct ossl_quic_frame_conn_close_st { - unsigned int is_app : 1; /* 0: transport error, 1: app error */ - uint64_t error_code; /* 62-bit transport or app error code */ - uint64_t frame_type; /* transport errors only */ - char *reason; /* UTF-8 string, not necessarily zero-terminated */ - size_t reason_len; /* Length of reason in bytes */ + unsigned int is_app : 1; /* 0: transport error, 1: app error */ + uint64_t error_code; /* 62-bit transport or app error code */ + uint64_t frame_type; /* transport errors only */ + char *reason; /* UTF-8 string, not necessarily zero-terminated */ + size_t reason_len; /* Length of reason in bytes */ } OSSL_QUIC_FRAME_CONN_CLOSE; /* @@ -238,13 +239,15 @@ int ossl_quic_wire_encode_frame_ack(WPACKET *pkt, uint32_t ack_delay_exponent, * Encodes a QUIC RESET_STREAM frame to the packet writer, given a logical * representation of the RESET_STREAM frame. */ -int ossl_quic_wire_encode_frame_reset_stream(WPACKET *pkt, const OSSL_QUIC_FRAME_RESET_STREAM *f); +int ossl_quic_wire_encode_frame_reset_stream( + WPACKET *pkt, const OSSL_QUIC_FRAME_RESET_STREAM *f); /* * Encodes a QUIC STOP_SENDING frame to the packet writer, given a logical * representation of the STOP_SENDING frame. */ -int ossl_quic_wire_encode_frame_stop_sending(WPACKET *pkt, const OSSL_QUIC_FRAME_STOP_SENDING *f); +int ossl_quic_wire_encode_frame_stop_sending( + WPACKET *pkt, const OSSL_QUIC_FRAME_STOP_SENDING *f); /* * Encodes a QUIC CRYPTO frame header to the packet writer. @@ -252,14 +255,16 @@ int ossl_quic_wire_encode_frame_stop_sending(WPACKET *pkt, const OSSL_QUIC_FRAME * To create a well-formed frame, the data written using this function must be * immediately followed by f->len bytes of data. */ -int ossl_quic_wire_encode_frame_crypto_hdr(WPACKET *hdr, const OSSL_QUIC_FRAME_CRYPTO *f); +int ossl_quic_wire_encode_frame_crypto_hdr(WPACKET *hdr, + const OSSL_QUIC_FRAME_CRYPTO *f); /* * Returns the number of bytes which will be required to encode the given * CRYPTO frame header. Does not include the payload bytes in the count. * Returns 0 if input is invalid. */ -size_t ossl_quic_wire_get_encoded_frame_len_crypto_hdr(const OSSL_QUIC_FRAME_CRYPTO *f); +size_t ossl_quic_wire_get_encoded_frame_len_crypto_hdr( + const OSSL_QUIC_FRAME_CRYPTO *f); /* * Encodes a QUIC CRYPTO frame to the packet writer. @@ -269,12 +274,14 @@ size_t ossl_quic_wire_get_encoded_frame_len_crypto_hdr(const OSSL_QUIC_FRAME_CRY * copied to the target buffer, otherwise the caller must fill the returned * buffer. Returns NULL on failure. */ -void *ossl_quic_wire_encode_frame_crypto(WPACKET *pkt, const OSSL_QUIC_FRAME_CRYPTO *f); +void *ossl_quic_wire_encode_frame_crypto(WPACKET *pkt, + const OSSL_QUIC_FRAME_CRYPTO *f); /* * Encodes a QUIC NEW_TOKEN frame to the packet writer. */ -int ossl_quic_wire_encode_frame_new_token(WPACKET *pkt, const unsigned char *token, +int ossl_quic_wire_encode_frame_new_token(WPACKET *pkt, + const unsigned char *token, size_t token_len); /* @@ -292,14 +299,16 @@ int ossl_quic_wire_encode_frame_new_token(WPACKET *pkt, const unsigned char *tok * To create a well-formed frame, the data written using this function must be * immediately followed by f->len bytes of stream data. */ -int ossl_quic_wire_encode_frame_stream_hdr(WPACKET *pkt, const OSSL_QUIC_FRAME_STREAM *f); +int ossl_quic_wire_encode_frame_stream_hdr(WPACKET *pkt, + const OSSL_QUIC_FRAME_STREAM *f); /* * Returns the number of bytes which will be required to encode the given * STREAM frame header. Does not include the payload bytes in the count. * Returns 0 if input is invalid. */ -size_t ossl_quic_wire_get_encoded_frame_len_stream_hdr(const OSSL_QUIC_FRAME_STREAM *f); +size_t ossl_quic_wire_get_encoded_frame_len_stream_hdr( + const OSSL_QUIC_FRAME_STREAM *f); /* * Functions similarly to ossl_quic_wire_encode_frame_stream_hdr, but it also @@ -311,7 +320,8 @@ size_t ossl_quic_wire_get_encoded_frame_len_stream_hdr(const OSSL_QUIC_FRAME_STR * it is automatically copied to the target buffer, otherwise the caller * must fill the returned buffer. Returns NULL on failure. */ -void *ossl_quic_wire_encode_frame_stream(WPACKET *pkt, const OSSL_QUIC_FRAME_STREAM *f); +void *ossl_quic_wire_encode_frame_stream(WPACKET *pkt, + const OSSL_QUIC_FRAME_STREAM *f); /* * Encodes a QUIC MAX_DATA frame to the packet writer. @@ -321,7 +331,8 @@ int ossl_quic_wire_encode_frame_max_data(WPACKET *pkt, uint64_t max_data); /* * Encodes a QUIC MAX_STREAM_DATA frame to the packet writer. */ -int ossl_quic_wire_encode_frame_max_stream_data(WPACKET *pkt, uint64_t stream_id, +int ossl_quic_wire_encode_frame_max_stream_data(WPACKET *pkt, + uint64_t stream_id, uint64_t max_data); /* @@ -331,7 +342,8 @@ int ossl_quic_wire_encode_frame_max_stream_data(WPACKET *pkt, uint64_t stream_id * bidirectional streams; else it specifies the maximum number of unidirectional * streams. */ -int ossl_quic_wire_encode_frame_max_streams(WPACKET *pkt, char is_uni, uint64_t max_streams); +int ossl_quic_wire_encode_frame_max_streams(WPACKET *pkt, char is_uni, + uint64_t max_streams); /* * Encodes a QUIC DATA_BLOCKED frame to the packet writer. @@ -341,7 +353,8 @@ int ossl_quic_wire_encode_frame_data_blocked(WPACKET *pkt, uint64_t max_data); /* * Encodes a QUIC STREAM_DATA_BLOCKED frame to the packet writer. */ -int ossl_quic_wire_encode_frame_stream_data_blocked(WPACKET *pkt, uint64_t stream_id, +int ossl_quic_wire_encode_frame_stream_data_blocked(WPACKET *pkt, + uint64_t stream_id, uint64_t max_stream_data); /* * Encodes a QUIC STREAMS_BLOCKED frame to the packet writer. @@ -350,7 +363,8 @@ int ossl_quic_wire_encode_frame_stream_data_blocked(WPACKET *pkt, uint64_t strea * bidirectional streams; else it specifies the maximum number of unidirectional * streams. */ -int ossl_quic_wire_encode_frame_streams_blocked(WPACKET *pkt, char is_uni, uint64_t max_streams); +int ossl_quic_wire_encode_frame_streams_blocked(WPACKET *pkt, char is_uni, + uint64_t max_streams); /* * Encodes a QUIC NEW_CONNECTION_ID frame to the packet writer, given a logical @@ -359,7 +373,8 @@ int ossl_quic_wire_encode_frame_streams_blocked(WPACKET *pkt, char is_uni, uint6 * The buffer pointed to by the conn_id field must be valid for the duration of * the call. */ -int ossl_quic_wire_encode_frame_new_conn_id(WPACKET *pkt, const OSSL_QUIC_FRAME_NEW_CONN_ID *f); +int ossl_quic_wire_encode_frame_new_conn_id( + WPACKET *pkt, const OSSL_QUIC_FRAME_NEW_CONN_ID *f); /* * Encodes a QUIC RETIRE_CONNECTION_ID frame to the packet writer. @@ -385,7 +400,8 @@ int ossl_quic_wire_encode_frame_path_response(WPACKET *pkt, uint64_t data); * reason_len must be set to the length of the reason string in bytes. The * reason string need not be zero terminated. */ -int ossl_quic_wire_encode_frame_conn_close(WPACKET *pkt, const OSSL_QUIC_FRAME_CONN_CLOSE *f); +int ossl_quic_wire_encode_frame_conn_close(WPACKET *pkt, + const OSSL_QUIC_FRAME_CONN_CLOSE *f); /* * Encodes a QUIC HANDSHAKE_DONE frame to the packet writer. This frame type @@ -403,15 +419,15 @@ int ossl_quic_wire_encode_frame_handshake_done(WPACKET *pkt); * * Returns a pointer to the start of the payload on success, or NULL on failure. */ -unsigned char *ossl_quic_wire_encode_transport_param_bytes(WPACKET *pkt, uint64_t id, - const unsigned char *value, - size_t value_len); +unsigned char *ossl_quic_wire_encode_transport_param_bytes( + WPACKET *pkt, uint64_t id, const unsigned char *value, size_t value_len); /* * Encodes a QUIC transport parameter TLV with the given ID into the WPACKET. * The payload is a QUIC variable-length integer with the given value. */ -int ossl_quic_wire_encode_transport_param_int(WPACKET *pkt, uint64_t id, uint64_t value); +int ossl_quic_wire_encode_transport_param_int(WPACKET *pkt, uint64_t id, + uint64_t value); /* * QUIC Wire Format Decoding @@ -453,7 +469,8 @@ int ossl_quic_wire_skip_frame_header(PACKET *pkt, uint64_t *type); * * The PACKET is not advanced. */ -int ossl_quic_wire_peek_frame_ack_num_ranges(const PACKET *pkt, uint64_t *total_ranges); +int ossl_quic_wire_peek_frame_ack_num_ranges(const PACKET *pkt, + uint64_t *total_ranges); /* * Decodes a QUIC ACK frame. The ack_ranges field of the passed structure should @@ -483,17 +500,20 @@ int ossl_quic_wire_peek_frame_ack_num_ranges(const PACKET *pkt, uint64_t *total_ * to encode the frame. */ int ossl_quic_wire_decode_frame_ack(PACKET *pkt, uint32_t ack_delay_exponent, - OSSL_QUIC_FRAME_ACK *ack, uint64_t *total_ranges); + OSSL_QUIC_FRAME_ACK *ack, + uint64_t *total_ranges); /* * Decodes a QUIC RESET_STREAM frame. */ -int ossl_quic_wire_decode_frame_reset_stream(PACKET *pkt, OSSL_QUIC_FRAME_RESET_STREAM *f); +int ossl_quic_wire_decode_frame_reset_stream(PACKET *pkt, + OSSL_QUIC_FRAME_RESET_STREAM *f); /* * Decodes a QUIC STOP_SENDING frame. */ -int ossl_quic_wire_decode_frame_stop_sending(PACKET *pkt, OSSL_QUIC_FRAME_STOP_SENDING *f); +int ossl_quic_wire_decode_frame_stop_sending(PACKET *pkt, + OSSL_QUIC_FRAME_STOP_SENDING *f); /* * Decodes a QUIC CRYPTO frame. @@ -507,7 +527,8 @@ int ossl_quic_wire_decode_frame_crypto(PACKET *pkt, OSSL_QUIC_FRAME_CRYPTO *f); * Decodes a QUIC NEW_TOKEN frame. *token is written with a pointer to the token * bytes and *token_len is written with the length of the token in bytes. */ -int ossl_quic_wire_decode_frame_new_token(PACKET *pkt, const unsigned char **token, +int ossl_quic_wire_decode_frame_new_token(PACKET *pkt, + const unsigned char **token, size_t *token_len); /* @@ -547,7 +568,8 @@ int ossl_quic_wire_decode_frame_max_data(PACKET *pkt, uint64_t *max_data); * Decodes a QUIC MAX_STREAM_DATA frame. The Stream ID is written to *stream_id * and Maximum Stream Data field is written to *max_stream_data. */ -int ossl_quic_wire_decode_frame_max_stream_data(PACKET *pkt, uint64_t *stream_id, +int ossl_quic_wire_decode_frame_max_stream_data(PACKET *pkt, + uint64_t *stream_id, uint64_t *max_stream_data); /* * Decodes a QUIC MAX_STREAMS frame. The Maximum Streams field is written to @@ -569,7 +591,8 @@ int ossl_quic_wire_decode_frame_data_blocked(PACKET *pkt, uint64_t *max_data); * Decodes a QUIC STREAM_DATA_BLOCKED frame. The Stream ID and Maximum Stream * Data fields are written to *stream_id and *max_stream_data respectively. */ -int ossl_quic_wire_decode_frame_stream_data_blocked(PACKET *pkt, uint64_t *stream_id, +int ossl_quic_wire_decode_frame_stream_data_blocked(PACKET *pkt, + uint64_t *stream_id, uint64_t *max_stream_data); /* @@ -580,7 +603,8 @@ int ossl_quic_wire_decode_frame_stream_data_blocked(PACKET *pkt, uint64_t *strea * denoted by the frame type; the caller should examine the frame type to * determine this. */ -int ossl_quic_wire_decode_frame_streams_blocked(PACKET *pkt, uint64_t *max_streams); +int ossl_quic_wire_decode_frame_streams_blocked(PACKET *pkt, + uint64_t *max_streams); /* * Decodes a QUIC NEW_CONNECTION_ID frame. The logical representation of the @@ -591,7 +615,8 @@ int ossl_quic_wire_decode_frame_streams_blocked(PACKET *pkt, uint64_t *max_strea * valid. The conn_id_len field is set to the length of the connection ID string * in bytes. */ -int ossl_quic_wire_decode_frame_new_conn_id(PACKET *pkt, OSSL_QUIC_FRAME_NEW_CONN_ID *f); +int ossl_quic_wire_decode_frame_new_conn_id(PACKET *pkt, + OSSL_QUIC_FRAME_NEW_CONN_ID *f); /* * Decodes a QUIC RETIRE_CONNECTION_ID frame. The Sequence Number field @@ -622,7 +647,8 @@ int ossl_quic_wire_decode_frame_path_response(PACKET *pkt, uint64_t *data); * * Returns 1 on success or 0 on failure. */ -int ossl_quic_wire_decode_frame_conn_close(PACKET *pkt, OSSL_QUIC_FRAME_CONN_CLOSE *f); +int ossl_quic_wire_decode_frame_conn_close(PACKET *pkt, + OSSL_QUIC_FRAME_CONN_CLOSE *f); /* * Decodes one or more PADDING frames. PADDING frames have no arguments. @@ -657,7 +683,8 @@ int ossl_quic_wire_peek_transport_param(PACKET *pkt, uint64_t *id); * * Returns NULL on failure. */ -const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt, uint64_t *id, +const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt, + uint64_t *id, size_t *len); /* @@ -666,6 +693,7 @@ const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt, ui * The transport parameter ID is written to *id and the value is written to * *value. */ -int ossl_quic_wire_decode_transport_param_int(PACKET *pkt, uint64_t *id, uint64_t *value); +int ossl_quic_wire_decode_transport_param_int(PACKET *pkt, uint64_t *id, + uint64_t *value); #endif diff --git a/libs/OpenSSL/include/internal/quic_wire_pkt.h b/libs/OpenSSL/include/internal/quic_wire_pkt.h index 24b54f06..796aebda 100644 --- a/libs/OpenSSL/include/internal/quic_wire_pkt.h +++ b/libs/OpenSSL/include/internal/quic_wire_pkt.h @@ -15,7 +15,7 @@ #include "internal/quic_types.h" #define QUIC_VERSION_NONE ((uint32_t)0) /* Used for version negotiation */ -#define QUIC_VERSION_1 ((uint32_t)1) /* QUIC v1 */ +#define QUIC_VERSION_1 ((uint32_t)1) /* QUIC v1 */ /* QUIC logical packet type. These do not match wire values. */ #define QUIC_PKT_TYPE_INITIAL 1 @@ -29,87 +29,93 @@ * Determine encryption level from packet type. Returns QUIC_ENC_LEVEL_NUM if * the packet is not of a type which is encrypted. */ -static ossl_inline ossl_unused uint32_t ossl_quic_pkt_type_to_enc_level(uint32_t pkt_type) +static ossl_inline ossl_unused uint32_t +ossl_quic_pkt_type_to_enc_level(uint32_t pkt_type) { - switch (pkt_type) - { - case QUIC_PKT_TYPE_INITIAL: - return QUIC_ENC_LEVEL_INITIAL; - case QUIC_PKT_TYPE_HANDSHAKE: - return QUIC_ENC_LEVEL_HANDSHAKE; - case QUIC_PKT_TYPE_0RTT: - return QUIC_ENC_LEVEL_0RTT; - case QUIC_PKT_TYPE_1RTT: - return QUIC_ENC_LEVEL_1RTT; - default: - return QUIC_ENC_LEVEL_NUM; - } + switch (pkt_type) + { + case QUIC_PKT_TYPE_INITIAL: + return QUIC_ENC_LEVEL_INITIAL; + case QUIC_PKT_TYPE_HANDSHAKE: + return QUIC_ENC_LEVEL_HANDSHAKE; + case QUIC_PKT_TYPE_0RTT: + return QUIC_ENC_LEVEL_0RTT; + case QUIC_PKT_TYPE_1RTT: + return QUIC_ENC_LEVEL_1RTT; + default: + return QUIC_ENC_LEVEL_NUM; + } } -static ossl_inline ossl_unused uint32_t ossl_quic_enc_level_to_pkt_type(uint32_t enc_level) +static ossl_inline ossl_unused uint32_t +ossl_quic_enc_level_to_pkt_type(uint32_t enc_level) { - switch (enc_level) - { - case QUIC_ENC_LEVEL_INITIAL: - return QUIC_PKT_TYPE_INITIAL; - case QUIC_ENC_LEVEL_HANDSHAKE: - return QUIC_PKT_TYPE_HANDSHAKE; - case QUIC_ENC_LEVEL_0RTT: - return QUIC_PKT_TYPE_0RTT; - case QUIC_ENC_LEVEL_1RTT: - return QUIC_PKT_TYPE_1RTT; - default: - return UINT32_MAX; - } + switch (enc_level) + { + case QUIC_ENC_LEVEL_INITIAL: + return QUIC_PKT_TYPE_INITIAL; + case QUIC_ENC_LEVEL_HANDSHAKE: + return QUIC_PKT_TYPE_HANDSHAKE; + case QUIC_ENC_LEVEL_0RTT: + return QUIC_PKT_TYPE_0RTT; + case QUIC_ENC_LEVEL_1RTT: + return QUIC_PKT_TYPE_1RTT; + default: + return UINT32_MAX; + } } /* Determine if a packet type contains an encrypted payload. */ -static ossl_inline ossl_unused int ossl_quic_pkt_type_is_encrypted(uint32_t pkt_type) +static ossl_inline ossl_unused int +ossl_quic_pkt_type_is_encrypted(uint32_t pkt_type) { - switch (pkt_type) - { - case QUIC_PKT_TYPE_RETRY: - case QUIC_PKT_TYPE_VERSION_NEG: - return 0; - default: - return 1; - } + switch (pkt_type) + { + case QUIC_PKT_TYPE_RETRY: + case QUIC_PKT_TYPE_VERSION_NEG: + return 0; + default: + return 1; + } } /* Determine if a packet type contains a PN field. */ static ossl_inline ossl_unused int ossl_quic_pkt_type_has_pn(uint32_t pkt_type) { - /* - * Currently a packet has a PN iff it is encrypted. This could change - * someday. - */ - return ossl_quic_pkt_type_is_encrypted(pkt_type); + /* + * Currently a packet has a PN iff it is encrypted. This could change + * someday. + */ + return ossl_quic_pkt_type_is_encrypted(pkt_type); } /* * Determine if a packet type can appear with other packets in a datagram. Some * packet types must be the sole packet in a datagram. */ -static ossl_inline ossl_unused int ossl_quic_pkt_type_can_share_dgram(uint32_t pkt_type) +static ossl_inline ossl_unused int +ossl_quic_pkt_type_can_share_dgram(uint32_t pkt_type) { - /* - * Currently only the encrypted packet types can share a datagram. This - * could change someday. - */ - return ossl_quic_pkt_type_is_encrypted(pkt_type); + /* + * Currently only the encrypted packet types can share a datagram. This + * could change someday. + */ + return ossl_quic_pkt_type_is_encrypted(pkt_type); } /* * Determine if the packet type must come at the end of the datagram (due to the * lack of a length field). */ -static ossl_inline ossl_unused int ossl_quic_pkt_type_must_be_last(uint32_t pkt_type) +static ossl_inline ossl_unused int +ossl_quic_pkt_type_must_be_last(uint32_t pkt_type) { - /* - * Any packet type which cannot share a datagram obviously must come last. - * 1-RTT also must come last as it lacks a length field. - */ - return !ossl_quic_pkt_type_can_share_dgram(pkt_type) || pkt_type == QUIC_PKT_TYPE_1RTT; + /* + * Any packet type which cannot share a datagram obviously must come last. + * 1-RTT also must come last as it lacks a length field. + */ + return !ossl_quic_pkt_type_can_share_dgram(pkt_type) + || pkt_type == QUIC_PKT_TYPE_1RTT; } /* @@ -132,11 +138,11 @@ typedef struct quic_pkt_hdr_ptrs_st QUIC_PKT_HDR_PTRS; */ typedef struct quic_hdr_protector_st { - OSSL_LIB_CTX *libctx; - const char *propq; - EVP_CIPHER_CTX *cipher_ctx; - EVP_CIPHER *cipher; - uint32_t cipher_id; + OSSL_LIB_CTX *libctx; + const char *propq; + EVP_CIPHER_CTX *cipher_ctx; + EVP_CIPHER *cipher; + uint32_t cipher_id; } QUIC_HDR_PROTECTOR; #define QUIC_HDR_PROT_CIPHER_AES_128 1 @@ -162,8 +168,9 @@ typedef struct quic_hdr_protector_st * * Returns 1 on success and 0 on failure. */ -int ossl_quic_hdr_protector_init(QUIC_HDR_PROTECTOR *hpr, OSSL_LIB_CTX *libctx, const char *propq, - uint32_t cipher_id, const unsigned char *quic_hp_key, +int ossl_quic_hdr_protector_init(QUIC_HDR_PROTECTOR *hpr, OSSL_LIB_CTX *libctx, + const char *propq, uint32_t cipher_id, + const unsigned char *quic_hp_key, size_t quic_hp_key_len); /* @@ -185,7 +192,8 @@ void ossl_quic_hdr_protector_cleanup(QUIC_HDR_PROTECTOR *hpr); * * Returns 1 on success and 0 on failure. */ -int ossl_quic_hdr_protector_decrypt(QUIC_HDR_PROTECTOR *hpr, QUIC_PKT_HDR_PTRS *ptrs); +int ossl_quic_hdr_protector_decrypt(QUIC_HDR_PROTECTOR *hpr, + QUIC_PKT_HDR_PTRS *ptrs); /* * Applies header protection to a packet. The packet payload must already have @@ -197,7 +205,8 @@ int ossl_quic_hdr_protector_decrypt(QUIC_HDR_PROTECTOR *hpr, QUIC_PKT_HDR_PTRS * * * Returns 1 on success and 0 on failure. */ -int ossl_quic_hdr_protector_encrypt(QUIC_HDR_PROTECTOR *hpr, QUIC_PKT_HDR_PTRS *ptrs); +int ossl_quic_hdr_protector_encrypt(QUIC_HDR_PROTECTOR *hpr, + QUIC_PKT_HDR_PTRS *ptrs); /* * Removes header protection from a packet. The packet payload must currently @@ -219,16 +228,20 @@ int ossl_quic_hdr_protector_encrypt(QUIC_HDR_PROTECTOR *hpr, QUIC_PKT_HDR_PTRS * * * Returns 1 on success and 0 on failure. */ -int ossl_quic_hdr_protector_decrypt_fields(QUIC_HDR_PROTECTOR *hpr, const unsigned char *sample, - size_t sample_len, unsigned char *first_byte, +int ossl_quic_hdr_protector_decrypt_fields(QUIC_HDR_PROTECTOR *hpr, + const unsigned char *sample, + size_t sample_len, + unsigned char *first_byte, unsigned char *pn_bytes); /* * Works analogously to ossl_hdr_protector_decrypt_fields, but applies header * protection instead of removing it. */ -int ossl_quic_hdr_protector_encrypt_fields(QUIC_HDR_PROTECTOR *hpr, const unsigned char *sample, - size_t sample_len, unsigned char *first_byte, +int ossl_quic_hdr_protector_encrypt_fields(QUIC_HDR_PROTECTOR *hpr, + const unsigned char *sample, + size_t sample_len, + unsigned char *first_byte, unsigned char *pn_bytes); /* @@ -278,106 +291,106 @@ int ossl_quic_hdr_protector_encrypt_fields(QUIC_HDR_PROTECTOR *hpr, const unsign */ typedef struct quic_pkt_hdr_st { - /* [ALL] A QUIC_PKT_TYPE_* value. Always valid. */ - unsigned int type : 8; + /* [ALL] A QUIC_PKT_TYPE_* value. Always valid. */ + unsigned int type : 8; - /* [S] Value of the spin bit. Valid if (type == 1RTT). */ - unsigned int spin_bit : 1; + /* [S] Value of the spin bit. Valid if (type == 1RTT). */ + unsigned int spin_bit : 1; - /* - * [S] Value of the Key Phase bit in the short packet. - * Valid if (type == 1RTT && !partial). - */ - unsigned int key_phase : 1; + /* + * [S] Value of the Key Phase bit in the short packet. + * Valid if (type == 1RTT && !partial). + */ + unsigned int key_phase : 1; - /* - * [1i0h] Length of packet number in bytes. This is the decoded value. - * Valid if ((type == 1RTT || (version && type != RETRY)) && !partial). - */ - unsigned int pn_len : 4; + /* + * [1i0h] Length of packet number in bytes. This is the decoded value. + * Valid if ((type == 1RTT || (version && type != RETRY)) && !partial). + */ + unsigned int pn_len : 4; - /* - * [ALL] Set to 1 if this is a partial decode because the packet header - * has not yet been deprotected. pn_len, pn and key_phase are not valid if - * this is set. - */ - unsigned int partial : 1; + /* + * [ALL] Set to 1 if this is a partial decode because the packet header + * has not yet been deprotected. pn_len, pn and key_phase are not valid if + * this is set. + */ + unsigned int partial : 1; - /* - * [ALL] Whether the fixed bit was set. Note that only Version Negotiation - * packets are allowed to have this unset, so this will always be 1 for all - * other packet types (decode will fail if it is not set). Ignored when - * encoding unless encoding a Version Negotiation packet. - */ - unsigned int fixed : 1; + /* + * [ALL] Whether the fixed bit was set. Note that only Version Negotiation + * packets are allowed to have this unset, so this will always be 1 for all + * other packet types (decode will fail if it is not set). Ignored when + * encoding unless encoding a Version Negotiation packet. + */ + unsigned int fixed : 1; - /* [L] Version field. Valid if (type != 1RTT). */ - uint32_t version; + /* [L] Version field. Valid if (type != 1RTT). */ + uint32_t version; - /* [ALL] The destination connection ID. Always valid. */ - QUIC_CONN_ID dst_conn_id; + /* [ALL] The destination connection ID. Always valid. */ + QUIC_CONN_ID dst_conn_id; - /* - * [L] The source connection ID. - * Valid if (type != 1RTT). - */ - QUIC_CONN_ID src_conn_id; + /* + * [L] The source connection ID. + * Valid if (type != 1RTT). + */ + QUIC_CONN_ID src_conn_id; - /* - * [1i0h] Relatively-encoded packet number in raw, encoded form. The correct - * decoding of this value is context-dependent. The number of bytes valid in - * this buffer is determined by pn_len above. If the decode was partial, - * this field is not valid. - * - * Valid if ((type == 1RTT || (version && type != RETRY)) && !partial). - */ - unsigned char pn[4]; + /* + * [1i0h] Relatively-encoded packet number in raw, encoded form. The correct + * decoding of this value is context-dependent. The number of bytes valid in + * this buffer is determined by pn_len above. If the decode was partial, + * this field is not valid. + * + * Valid if ((type == 1RTT || (version && type != RETRY)) && !partial). + */ + unsigned char pn[4]; - /* - * [i] Token field in Initial packet. Points to memory inside the decoded - * PACKET, and therefore is valid for as long as the PACKET's buffer is - * valid. token_len is the length of the token in bytes. - * - * Valid if (type == INITIAL). - */ - const unsigned char *token; - size_t token_len; + /* + * [i] Token field in Initial packet. Points to memory inside the decoded + * PACKET, and therefore is valid for as long as the PACKET's buffer is + * valid. token_len is the length of the token in bytes. + * + * Valid if (type == INITIAL). + */ + const unsigned char *token; + size_t token_len; - /* - * [ALL] Payload length in bytes. - * - * Though 1-RTT, Retry and Version Negotiation packets do not contain an - * explicit length field, this field is always valid and is used by the - * packet header encoding and decoding routines to describe the payload - * length, regardless of whether the packet type encoded or decoded uses an - * explicit length indication. - */ - size_t len; + /* + * [ALL] Payload length in bytes. + * + * Though 1-RTT, Retry and Version Negotiation packets do not contain an + * explicit length field, this field is always valid and is used by the + * packet header encoding and decoding routines to describe the payload + * length, regardless of whether the packet type encoded or decoded uses an + * explicit length indication. + */ + size_t len; - /* - * Pointer to start of payload data in the packet. Points to memory inside - * the decoded PACKET, and therefore is valid for as long as the PACKET'S - * buffer is valid. The length of the buffer in bytes is in len above. - * - * For Version Negotiation packets, points to the array of supported - * versions. - * - * For Retry packets, points to the Retry packet payload, which comprises - * the Retry Token followed by a 16-byte Retry Integrity Tag. - * - * Regardless of whether a packet is a Version Negotiation packet (where the - * payload contains a list of supported versions), a Retry packet (where the - * payload contains a Retry Token and Retry Integrity Tag), or any other - * packet type (where the payload contains frames), the payload is not - * validated and the user must parse the payload bearing this in mind. - * - * If the decode was partial (partial is set), this points to the start of - * the packet number field, rather than the protected payload, as the length - * of the packet number field is unknown. The len field reflects this in - * this case (i.e., the len field is the number of payload bytes plus the - * number of bytes comprising the PN). - */ - const unsigned char *data; + /* + * Pointer to start of payload data in the packet. Points to memory inside + * the decoded PACKET, and therefore is valid for as long as the PACKET'S + * buffer is valid. The length of the buffer in bytes is in len above. + * + * For Version Negotiation packets, points to the array of supported + * versions. + * + * For Retry packets, points to the Retry packet payload, which comprises + * the Retry Token followed by a 16-byte Retry Integrity Tag. + * + * Regardless of whether a packet is a Version Negotiation packet (where the + * payload contains a list of supported versions), a Retry packet (where the + * payload contains a Retry Token and Retry Integrity Tag), or any other + * packet type (where the payload contains frames), the payload is not + * validated and the user must parse the payload bearing this in mind. + * + * If the decode was partial (partial is set), this points to the start of + * the packet number field, rather than the protected payload, as the length + * of the packet number field is unknown. The len field reflects this in + * this case (i.e., the len field is the number of payload bytes plus the + * number of bytes comprising the PN). + */ + const unsigned char *data; } QUIC_PKT_HDR; /* @@ -387,15 +400,15 @@ typedef struct quic_pkt_hdr_st */ struct quic_pkt_hdr_ptrs_st { - unsigned char *raw_start; /* start of packet */ - unsigned char *raw_sample; /* start of sampling range */ - size_t raw_sample_len; /* maximum length of sampling range */ + unsigned char *raw_start; /* start of packet */ + unsigned char *raw_sample; /* start of sampling range */ + size_t raw_sample_len; /* maximum length of sampling range */ - /* - * Start of PN field. Guaranteed to be NULL unless at least four bytes are - * available via this pointer. - */ - unsigned char *raw_pn; + /* + * Start of PN field. Guaranteed to be NULL unless at least four bytes are + * available via this pointer. + */ + unsigned char *raw_pn; }; /* @@ -418,8 +431,9 @@ struct quic_pkt_hdr_ptrs_st * * Returns 1 on success and 0 on failure. */ -int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt, size_t short_conn_id_len, int partial, - QUIC_PKT_HDR *hdr, QUIC_PKT_HDR_PTRS *ptrs); +int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt, size_t short_conn_id_len, + int partial, QUIC_PKT_HDR *hdr, + QUIC_PKT_HDR_PTRS *ptrs); /* * Encodes a packet header. The packet is written to pkt. @@ -456,7 +470,8 @@ int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt, size_t short_conn_id_len, int par * * Returns 1 on success and 0 on failure. */ -int ossl_quic_wire_encode_pkt_hdr(WPACKET *pkt, size_t short_conn_id_len, const QUIC_PKT_HDR *hdr, +int ossl_quic_wire_encode_pkt_hdr(WPACKET *pkt, size_t short_conn_id_len, + const QUIC_PKT_HDR *hdr, QUIC_PKT_HDR_PTRS *ptrs); /* @@ -469,8 +484,10 @@ int ossl_quic_wire_encode_pkt_hdr(WPACKET *pkt, size_t short_conn_id_len, const * * Returns 1 on success and 0 on failure. */ -int ossl_quic_wire_get_pkt_hdr_dst_conn_id(const unsigned char *buf, size_t buf_len, - size_t short_conn_id_len, QUIC_CONN_ID *dst_conn_id); +int ossl_quic_wire_get_pkt_hdr_dst_conn_id(const unsigned char *buf, + size_t buf_len, + size_t short_conn_id_len, + QUIC_CONN_ID *dst_conn_id); /* * Precisely predicts the encoded length of a packet header structure. @@ -479,7 +496,8 @@ int ossl_quic_wire_get_pkt_hdr_dst_conn_id(const unsigned char *buf, size_t buf_ * function returns non-zero does not guarantee that * ossl_quic_wire_encode_pkt_hdr() will succeed. */ -int ossl_quic_wire_get_encoded_pkt_hdr_len(size_t short_conn_id_len, const QUIC_PKT_HDR *hdr); +int ossl_quic_wire_get_encoded_pkt_hdr_len(size_t short_conn_id_len, + const QUIC_PKT_HDR *hdr); /* * Packet Number Encoding @@ -497,8 +515,9 @@ int ossl_quic_wire_get_encoded_pkt_hdr_len(size_t short_conn_id_len, const QUIC_ * * Returns 1 on success or 0 on failure. */ -int ossl_quic_wire_decode_pkt_hdr_pn(const unsigned char *enc_pn, size_t enc_pn_len, - QUIC_PN largest_pn, QUIC_PN *res_pn); +int ossl_quic_wire_decode_pkt_hdr_pn(const unsigned char *enc_pn, + size_t enc_pn_len, QUIC_PN largest_pn, + QUIC_PN *res_pn); /* * Determine how many bytes should be used to encode a PN. Returns the number of @@ -514,5 +533,6 @@ int ossl_quic_wire_determine_pn_len(QUIC_PN pn, QUIC_PN largest_acked); * * Returns 1 on success and 0 on failure. */ -int ossl_quic_wire_encode_pkt_hdr_pn(QUIC_PN pn, unsigned char *enc_pn, size_t enc_pn_len); +int ossl_quic_wire_encode_pkt_hdr_pn(QUIC_PN pn, unsigned char *enc_pn, + size_t enc_pn_len); #endif diff --git a/libs/OpenSSL/include/internal/refcount.h b/libs/OpenSSL/include/internal/refcount.h index 579e64a3..0cf9c203 100644 --- a/libs/OpenSSL/include/internal/refcount.h +++ b/libs/OpenSSL/include/internal/refcount.h @@ -14,21 +14,24 @@ #include #if defined(OPENSSL_THREADS) && !defined(OPENSSL_DEV_NO_ATOMICS) -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) -# include -# define HAVE_C11_ATOMICS -# endif +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ + && !defined(__STDC_NO_ATOMICS__) +# include +# define HAVE_C11_ATOMICS +# endif -# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) && ATOMIC_INT_LOCK_FREE > 0 +# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \ + && ATOMIC_INT_LOCK_FREE > 0 -# define HAVE_ATOMICS 1 +# define HAVE_ATOMICS 1 typedef _Atomic int CRYPTO_REF_COUNT; -static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, ossl_unused void *lock) +static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, + ossl_unused void *lock) { - *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1; - return 1; + *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1; + return 1; } /* @@ -41,101 +44,111 @@ static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, ossl_unused void *lo * to mutable members doesn't have to be serialized anymore, which would * otherwise imply an acquire fence. Hence conditional acquire fence... */ -static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, ossl_unused void *lock) +static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, + ossl_unused void *lock) { - *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; - if (*ret == 0) - atomic_thread_fence(memory_order_acquire); - return 1; + *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; + if (*ret == 0) + atomic_thread_fence(memory_order_acquire); + return 1; } -# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 +# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) \ + && __GCC_ATOMIC_INT_LOCK_FREE > 0 -# define HAVE_ATOMICS 1 +# define HAVE_ATOMICS 1 typedef int CRYPTO_REF_COUNT; static __inline__ int CRYPTO_UP_REF(int *val, int *ret, ossl_unused void *lock) { - *ret = __atomic_fetch_add(val, 1, __ATOMIC_RELAXED) + 1; - return 1; + *ret = __atomic_fetch_add(val, 1, __ATOMIC_RELAXED) + 1; + return 1; } -static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, ossl_unused void *lock) +static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, + ossl_unused void *lock) { - *ret = __atomic_fetch_sub(val, 1, __ATOMIC_RELAXED) - 1; - if (*ret == 0) - __atomic_thread_fence(__ATOMIC_ACQUIRE); - return 1; + *ret = __atomic_fetch_sub(val, 1, __ATOMIC_RELAXED) - 1; + if (*ret == 0) + __atomic_thread_fence(__ATOMIC_ACQUIRE); + return 1; } -# elif defined(__ICL) && defined(_WIN32) -# define HAVE_ATOMICS 1 +# elif defined(__ICL) && defined(_WIN32) +# define HAVE_ATOMICS 1 typedef volatile int CRYPTO_REF_COUNT; -static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, ossl_unused void *lock) +static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, + ossl_unused void *lock) { - *ret = _InterlockedExchangeAdd((void *)val, 1) + 1; - return 1; + *ret = _InterlockedExchangeAdd((void *)val, 1) + 1; + return 1; } -static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, ossl_unused void *lock) +static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, + ossl_unused void *lock) { - *ret = _InterlockedExchangeAdd((void *)val, -1) - 1; - return 1; + *ret = _InterlockedExchangeAdd((void *)val, -1) - 1; + return 1; } -# elif defined(_MSC_VER) && _MSC_VER >= 1200 +# elif defined(_MSC_VER) && _MSC_VER >= 1200 -# define HAVE_ATOMICS 1 +# define HAVE_ATOMICS 1 typedef volatile int CRYPTO_REF_COUNT; -# if (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE)) || defined(_M_ARM64) -# include -# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) -# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH -# endif +# if (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE)) \ + || defined(_M_ARM64) +# include +# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) +# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH +# endif -static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, ossl_unused void *lock) +static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, + ossl_unused void *lock) { - *ret = _InterlockedExchangeAdd_nf(val, 1) + 1; - return 1; + *ret = _InterlockedExchangeAdd_nf(val, 1) + 1; + return 1; } -static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, ossl_unused void *lock) +static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, + ossl_unused void *lock) { - *ret = _InterlockedExchangeAdd_nf(val, -1) - 1; - if (*ret == 0) - __dmb(_ARM_BARRIER_ISH); - return 1; + *ret = _InterlockedExchangeAdd_nf(val, -1) - 1; + if (*ret == 0) + __dmb(_ARM_BARRIER_ISH); + return 1; } -# else -# if !defined(_WIN32_WCE) -# pragma intrinsic(_InterlockedExchangeAdd) -# else -# if _WIN32_WCE >= 0x600 +# else +# if !defined(_WIN32_WCE) +# pragma intrinsic(_InterlockedExchangeAdd) +# else +# if _WIN32_WCE >= 0x600 extern long __cdecl _InterlockedExchangeAdd(long volatile *, long); -# else +# else /* under Windows CE we still have old-style Interlocked* functions */ extern long __cdecl InterlockedExchangeAdd(long volatile *, long); -# define _InterlockedExchangeAdd InterlockedExchangeAdd -# endif -# endif - -static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, ossl_unused void *lock) -{ - *ret = _InterlockedExchangeAdd(val, 1) + 1; - return 1; -} - -static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, ossl_unused void *lock) -{ - *ret = _InterlockedExchangeAdd(val, -1) - 1; - return 1; -} +# define _InterlockedExchangeAdd InterlockedExchangeAdd # endif +# endif +static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, + ossl_unused void *lock) +{ + *ret = _InterlockedExchangeAdd(val, 1) + 1; + return 1; +} + +static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, + ossl_unused void *lock) +{ + *ret = _InterlockedExchangeAdd(val, -1) - 1; + return 1; +} # endif + +# endif #endif /* !OPENSSL_DEV_NO_ATOMICS */ /* @@ -147,20 +160,21 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, ossl_unused voi typedef int CRYPTO_REF_COUNT; -# define CRYPTO_UP_REF(val, ret, lock) CRYPTO_atomic_add(val, 1, ret, lock) -# define CRYPTO_DOWN_REF(val, ret, lock) CRYPTO_atomic_add(val, -1, ret, lock) +# define CRYPTO_UP_REF(val, ret, lock) CRYPTO_atomic_add(val, 1, ret, lock) +# define CRYPTO_DOWN_REF(val, ret, lock) CRYPTO_atomic_add(val, -1, ret, lock) #endif #if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO) -# define REF_ASSERT_ISNT(test) \ - (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0) +# define REF_ASSERT_ISNT(test) \ + (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0) #else -# define REF_ASSERT_ISNT(i) +# define REF_ASSERT_ISNT(i) #endif -#define REF_PRINT_EX(text, count, object) \ - OSSL_TRACE3(REF_COUNT, "%p:%4d:%s\n", (object), (count), (text)); -#define REF_PRINT_COUNT(text, object) REF_PRINT_EX(text, object->references, (void *)object) +#define REF_PRINT_EX(text, count, object) \ + OSSL_TRACE3(REF_COUNT, "%p:%4d:%s\n", (object), (count), (text)); +#define REF_PRINT_COUNT(text, object) \ + REF_PRINT_EX(text, object->references, (void *)object) #endif diff --git a/libs/OpenSSL/include/internal/safe_math.h b/libs/OpenSSL/include/internal/safe_math.h index ed334465..e158a37c 100644 --- a/libs/OpenSSL/include/internal/safe_math.h +++ b/libs/OpenSSL/include/internal/safe_math.h @@ -14,249 +14,265 @@ #include /* For 'ossl_inline' */ #ifndef OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING -# ifdef __has_builtin -# define has(func) __has_builtin(func) -# elif __GNUC__ > 5 -# define has(func) 1 -# endif +# ifdef __has_builtin +# define has(func) __has_builtin(func) +# elif __GNUC__ > 5 +# define has(func) 1 +# endif #endif /* OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING */ #ifndef has -# define has(func) 0 +# define has(func) 0 #endif /* * Safe addition helpers */ #if has(__builtin_add_overflow) -# define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, int *err) \ - { \ - type r; \ - \ - if (!__builtin_add_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a < 0 ? min : max; \ - } +# define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_add_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a < 0 ? min : max; \ + } -# define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, int *err) \ - { \ - type r; \ - \ - if (!__builtin_add_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a + b; \ - } +# define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_add_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a + b; \ + } #else /* has(__builtin_add_overflow) */ -# define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, int *err) \ - { \ - if ((a < 0) ^ (b < 0) || (a > 0 && b <= max - a) || (a < 0 && b >= min - a) || a == 0) \ - return a + b; \ - *err |= 1; \ - return a < 0 ? min : max; \ - } +# define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, \ + int *err) \ + { \ + if ((a < 0) ^ (b < 0) || (a > 0 && b <= max - a) \ + || (a < 0 && b >= min - a) || a == 0) \ + return a + b; \ + *err |= 1; \ + return a < 0 ? min : max; \ + } -# define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, int *err) \ - { \ - if (b > max - a) \ - *err |= 1; \ - return a + b; \ - } +# define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, type b, \ + int *err) \ + { \ + if (b > max - a) \ + *err |= 1; \ + return a + b; \ + } #endif /* has(__builtin_add_overflow) */ /* * Safe subtraction helpers */ #if has(__builtin_sub_overflow) -# define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_sub_##type_name(type a, type b, int *err) \ - { \ - type r; \ - \ - if (!__builtin_sub_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a < 0 ? min : max; \ - } +# define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_sub_##type_name(type a, type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_sub_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a < 0 ? min : max; \ + } #else /* has(__builtin_sub_overflow) */ -# define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_sub_##type_name(type a, type b, int *err) \ - { \ - if (!((a < 0) ^ (b < 0)) || (b > 0 && a >= min + b) || (b < 0 && a <= max + b) \ - || b == 0) \ - return a - b; \ - *err |= 1; \ - return a < 0 ? min : max; \ - } +# define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_sub_##type_name(type a, type b, \ + int *err) \ + { \ + if (!((a < 0) ^ (b < 0)) || (b > 0 && a >= min + b) \ + || (b < 0 && a <= max + b) || b == 0) \ + return a - b; \ + *err |= 1; \ + return a < 0 ? min : max; \ + } #endif /* has(__builtin_sub_overflow) */ -#define OSSL_SAFE_MATH_SUBU(type_name, type) \ - static ossl_inline ossl_unused type safe_sub_##type_name(type a, type b, int *err) \ - { \ - if (b > a) \ - *err |= 1; \ - return a - b; \ - } +#define OSSL_SAFE_MATH_SUBU(type_name, type) \ + static ossl_inline ossl_unused type safe_sub_##type_name(type a, type b, \ + int *err) \ + { \ + if (b > a) \ + *err |= 1; \ + return a - b; \ + } /* * Safe multiplication helpers */ #if has(__builtin_mul_overflow) -# define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, int *err) \ - { \ - type r; \ - \ - if (!__builtin_mul_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return (a < 0) ^ (b < 0) ? min : max; \ - } +# define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_mul_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return (a < 0) ^ (b < 0) ? min : max; \ + } -# define OSSL_SAFE_MATH_MULU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, int *err) \ - { \ - type r; \ - \ - if (!__builtin_mul_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a * b; \ - } +# define OSSL_SAFE_MATH_MULU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_mul_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a * b; \ + } #else /* has(__builtin_mul_overflow) */ -# define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, int *err) \ - { \ - if (a == 0 || b == 0) \ - return 0; \ - if (a == 1) \ - return b; \ - if (b == 1) \ - return a; \ - if (a != min && b != min) \ - { \ - const type x = a < 0 ? -a : a; \ - const type y = b < 0 ? -b : b; \ - \ - if (x <= max / y) \ - return a * b; \ - } \ - *err |= 1; \ - return (a < 0) ^ (b < 0) ? min : max; \ - } +# define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, \ + int *err) \ + { \ + if (a == 0 || b == 0) \ + return 0; \ + if (a == 1) \ + return b; \ + if (b == 1) \ + return a; \ + if (a != min && b != min) \ + { \ + const type x = a < 0 ? -a : a; \ + const type y = b < 0 ? -b : b; \ + \ + if (x <= max / y) \ + return a * b; \ + } \ + *err |= 1; \ + return (a < 0) ^ (b < 0) ? min : max; \ + } -# define OSSL_SAFE_MATH_MULU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, int *err) \ - { \ - if (b != 0 && a > max / b) \ - *err |= 1; \ - return a * b; \ - } +# define OSSL_SAFE_MATH_MULU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, type b, \ + int *err) \ + { \ + if (b != 0 && a > max / b) \ + *err |= 1; \ + return a * b; \ + } #endif /* has(__builtin_mul_overflow) */ /* * Safe division helpers */ -#define OSSL_SAFE_MATH_DIVS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_div_##type_name(type a, type b, int *err) \ - { \ - if (b == 0) \ - { \ - *err |= 1; \ - return a < 0 ? min : max; \ - } \ - if (b == -1 && a == min) \ - { \ - *err |= 1; \ - return max; \ - } \ - return a / b; \ - } +#define OSSL_SAFE_MATH_DIVS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_div_##type_name(type a, type b, \ + int *err) \ + { \ + if (b == 0) \ + { \ + *err |= 1; \ + return a < 0 ? min : max; \ + } \ + if (b == -1 && a == min) \ + { \ + *err |= 1; \ + return max; \ + } \ + return a / b; \ + } -#define OSSL_SAFE_MATH_DIVU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_div_##type_name(type a, type b, int *err) \ - { \ - if (b != 0) \ - return a / b; \ - *err |= 1; \ - return max; \ - } +#define OSSL_SAFE_MATH_DIVU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_div_##type_name(type a, type b, \ + int *err) \ + { \ + if (b != 0) \ + return a / b; \ + *err |= 1; \ + return max; \ + } /* * Safe modulus helpers */ -#define OSSL_SAFE_MATH_MODS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_mod_##type_name(type a, type b, int *err) \ - { \ - if (b == 0) \ - { \ - *err |= 1; \ - return 0; \ - } \ - if (b == -1 && a == min) \ - { \ - *err |= 1; \ - return max; \ - } \ - return a % b; \ - } +#define OSSL_SAFE_MATH_MODS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_mod_##type_name(type a, type b, \ + int *err) \ + { \ + if (b == 0) \ + { \ + *err |= 1; \ + return 0; \ + } \ + if (b == -1 && a == min) \ + { \ + *err |= 1; \ + return max; \ + } \ + return a % b; \ + } -#define OSSL_SAFE_MATH_MODU(type_name, type) \ - static ossl_inline ossl_unused type safe_mod_##type_name(type a, type b, int *err) \ - { \ - if (b != 0) \ - return a % b; \ - *err |= 1; \ - return 0; \ - } +#define OSSL_SAFE_MATH_MODU(type_name, type) \ + static ossl_inline ossl_unused type safe_mod_##type_name(type a, type b, \ + int *err) \ + { \ + if (b != 0) \ + return a % b; \ + *err |= 1; \ + return 0; \ + } /* * Safe negation helpers */ -#define OSSL_SAFE_MATH_NEGS(type_name, type, min) \ - static ossl_inline ossl_unused type safe_neg_##type_name(type a, int *err) \ - { \ - if (a != min) \ - return -a; \ - *err |= 1; \ - return min; \ - } +#define OSSL_SAFE_MATH_NEGS(type_name, type, min) \ + static ossl_inline ossl_unused type safe_neg_##type_name(type a, int *err) \ + { \ + if (a != min) \ + return -a; \ + *err |= 1; \ + return min; \ + } -#define OSSL_SAFE_MATH_NEGU(type_name, type) \ - static ossl_inline ossl_unused type safe_neg_##type_name(type a, int *err) \ - { \ - if (a == 0) \ - return a; \ - *err |= 1; \ - return 1 + ~a; \ - } +#define OSSL_SAFE_MATH_NEGU(type_name, type) \ + static ossl_inline ossl_unused type safe_neg_##type_name(type a, int *err) \ + { \ + if (a == 0) \ + return a; \ + *err |= 1; \ + return 1 + ~a; \ + } /* * Safe absolute value helpers */ -#define OSSL_SAFE_MATH_ABSS(type_name, type, min) \ - static ossl_inline ossl_unused type safe_abs_##type_name(type a, int *err) \ - { \ - if (a != min) \ - return a < 0 ? -a : a; \ - *err |= 1; \ - return min; \ - } +#define OSSL_SAFE_MATH_ABSS(type_name, type, min) \ + static ossl_inline ossl_unused type safe_abs_##type_name(type a, int *err) \ + { \ + if (a != min) \ + return a < 0 ? -a : a; \ + *err |= 1; \ + return min; \ + } -#define OSSL_SAFE_MATH_ABSU(type_name, type) \ - static ossl_inline ossl_unused type safe_abs_##type_name(type a, int *err) \ - { \ - return a; \ - } +#define OSSL_SAFE_MATH_ABSU(type_name, type) \ + static ossl_inline ossl_unused type safe_abs_##type_name(type a, int *err) \ + { \ + return a; \ + } /* * Safe fused multiply divide helpers @@ -280,58 +296,60 @@ * * The algorithm used is not perfect but it should be "good enough". */ -#define OSSL_SAFE_MATH_MULDIVS(type_name, type, max) \ - static ossl_inline ossl_unused type safe_muldiv_##type_name(type a, type b, type c, int *err) \ - { \ - int e2 = 0; \ - type q, r, x, y; \ - \ - if (c == 0) \ - { \ - *err |= 1; \ - return a == 0 || b == 0 ? 0 : max; \ - } \ - x = safe_mul_##type_name(a, b, &e2); \ - if (!e2) \ - return safe_div_##type_name(x, c, err); \ - if (b > a) \ - { \ - x = b; \ - b = a; \ - a = x; \ - } \ - q = safe_div_##type_name(a, c, err); \ - r = safe_mod_##type_name(a, c, err); \ - x = safe_mul_##type_name(r, b, err); \ - y = safe_mul_##type_name(q, b, err); \ - q = safe_div_##type_name(x, c, err); \ - return safe_add_##type_name(y, q, err); \ - } +#define OSSL_SAFE_MATH_MULDIVS(type_name, type, max) \ + static ossl_inline ossl_unused type safe_muldiv_##type_name( \ + type a, type b, type c, int *err) \ + { \ + int e2 = 0; \ + type q, r, x, y; \ + \ + if (c == 0) \ + { \ + *err |= 1; \ + return a == 0 || b == 0 ? 0 : max; \ + } \ + x = safe_mul_##type_name(a, b, &e2); \ + if (!e2) \ + return safe_div_##type_name(x, c, err); \ + if (b > a) \ + { \ + x = b; \ + b = a; \ + a = x; \ + } \ + q = safe_div_##type_name(a, c, err); \ + r = safe_mod_##type_name(a, c, err); \ + x = safe_mul_##type_name(r, b, err); \ + y = safe_mul_##type_name(q, b, err); \ + q = safe_div_##type_name(x, c, err); \ + return safe_add_##type_name(y, q, err); \ + } -#define OSSL_SAFE_MATH_MULDIVU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_muldiv_##type_name(type a, type b, type c, int *err) \ - { \ - int e2 = 0; \ - type x, y; \ - \ - if (c == 0) \ - { \ - *err |= 1; \ - return a == 0 || b == 0 ? 0 : max; \ - } \ - x = safe_mul_##type_name(a, b, &e2); \ - if (!e2) \ - return x / c; \ - if (b > a) \ - { \ - x = b; \ - b = a; \ - a = x; \ - } \ - x = safe_mul_##type_name(a % c, b, err); \ - y = safe_mul_##type_name(a / c, b, err); \ - return safe_add_##type_name(y, x / c, err); \ - } +#define OSSL_SAFE_MATH_MULDIVU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_muldiv_##type_name( \ + type a, type b, type c, int *err) \ + { \ + int e2 = 0; \ + type x, y; \ + \ + if (c == 0) \ + { \ + *err |= 1; \ + return a == 0 || b == 0 ? 0 : max; \ + } \ + x = safe_mul_##type_name(a, b, &e2); \ + if (!e2) \ + return x / c; \ + if (b > a) \ + { \ + x = b; \ + b = a; \ + a = x; \ + } \ + x = safe_mul_##type_name(a % c, b, err); \ + y = safe_mul_##type_name(a / c, b, err); \ + return safe_add_##type_name(y, x / c, err); \ + } /* * Calculate a / b rounding up: @@ -339,33 +357,34 @@ * Which is usually (less safely) converted to (a + b - 1) / b * If you *know* that b != 0, then it's safe to ignore err. */ -#define OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, max) \ - static ossl_inline ossl_unused type safe_div_round_up_##type_name(type a, type b, int *errp) \ - { \ - type x; \ - int *err, err_local = 0; \ - \ - /* Allow errors to be ignored by callers */ \ - err = errp != NULL ? errp : &err_local; \ - /* Fast path, both positive */ \ - if (b > 0 && a > 0) \ - { \ - /* Faster path: no overflow concerns */ \ - if (a < max - b) \ - return (a + b - 1) / b; \ - return a / b + (a % b != 0); \ - } \ - if (b == 0) \ - { \ - *err |= 1; \ - return a == 0 ? 0 : max; \ - } \ - if (a == 0) \ - return 0; \ - /* Rather slow path because there are negatives involved */ \ - x = safe_mod_##type_name(a, b, err); \ - return safe_add_##type_name(safe_div_##type_name(a, b, err), x != 0, err); \ - } +#define OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, max) \ + static ossl_inline ossl_unused type safe_div_round_up_##type_name( \ + type a, type b, int *errp) \ + { \ + type x; \ + int *err, err_local = 0; \ + \ + /* Allow errors to be ignored by callers */ \ + err = errp != NULL ? errp : &err_local; \ + /* Fast path, both positive */ \ + if (b > 0 && a > 0) \ + { \ + /* Faster path: no overflow concerns */ \ + if (a < max - b) \ + return (a + b - 1) / b; \ + return a / b + (a % b != 0); \ + } \ + if (b == 0) \ + { \ + *err |= 1; \ + return a == 0 ? 0 : max; \ + } \ + if (a == 0) \ + return 0; \ + /* Rather slow path because there are negatives involved */ \ + x = safe_mod_##type_name(a, b, err); \ + return safe_add_##type_name(safe_div_##type_name(a, b, err), x != 0, err); \ + } /* Calculate ranges of types */ #define OSSL_SAFE_MATH_MINS(type) ((type)1 << (sizeof(type) * 8 - 1)) @@ -375,26 +394,31 @@ /* * Wrapper macros to create all the functions of a given type */ -#define OSSL_SAFE_MATH_SIGNED(type_name, type) \ - OSSL_SAFE_MATH_ADDS(type_name, type, OSSL_SAFE_MATH_MINS(type), OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_SUBS(type_name, type, OSSL_SAFE_MATH_MINS(type), OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_MULS(type_name, type, OSSL_SAFE_MATH_MINS(type), OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_DIVS(type_name, type, OSSL_SAFE_MATH_MINS(type), OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_MODS(type_name, type, OSSL_SAFE_MATH_MINS(type), OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_MULDIVS(type_name, type, OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_NEGS(type_name, type, OSSL_SAFE_MATH_MINS(type)) \ - OSSL_SAFE_MATH_ABSS(type_name, type, OSSL_SAFE_MATH_MINS(type)) +#define OSSL_SAFE_MATH_SIGNED(type_name, type) \ + OSSL_SAFE_MATH_ADDS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_SUBS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_MULS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_DIVS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_MODS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_MULDIVS(type_name, type, OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_NEGS(type_name, type, OSSL_SAFE_MATH_MINS(type)) \ + OSSL_SAFE_MATH_ABSS(type_name, type, OSSL_SAFE_MATH_MINS(type)) -#define OSSL_SAFE_MATH_UNSIGNED(type_name, type) \ - OSSL_SAFE_MATH_ADDU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_SUBU(type_name, type) \ - OSSL_SAFE_MATH_MULU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_DIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_MODU(type_name, type) \ - OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_MULDIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_NEGU(type_name, type) \ - OSSL_SAFE_MATH_ABSU(type_name, type) +#define OSSL_SAFE_MATH_UNSIGNED(type_name, type) \ + OSSL_SAFE_MATH_ADDU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_SUBU(type_name, type) \ + OSSL_SAFE_MATH_MULU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_DIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_MODU(type_name, type) \ + OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_MULDIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_NEGU(type_name, type) \ + OSSL_SAFE_MATH_ABSU(type_name, type) #endif /* OSSL_INTERNAL_SAFE_MATH_H */ diff --git a/libs/OpenSSL/include/internal/sha3.h b/libs/OpenSSL/include/internal/sha3.h index b4c664d0..3ccd6d23 100644 --- a/libs/OpenSSL/include/internal/sha3.h +++ b/libs/OpenSSL/include/internal/sha3.h @@ -27,27 +27,29 @@ typedef int(sha3_final_fn)(unsigned char *md, void *vctx); typedef struct prov_sha3_meth_st { - sha3_absorb_fn *absorb; - sha3_final_fn *final; + sha3_absorb_fn *absorb; + sha3_final_fn *final; } PROV_SHA3_METHOD; struct keccak_st { - uint64_t A[5][5]; - size_t block_size; /* cached ctx->digest->block_size */ - size_t md_size; /* output length, variable in XOF */ - size_t bufsz; /* used bytes in below buffer */ - unsigned char buf[KECCAK1600_WIDTH / 8 - 32]; - unsigned char pad; - PROV_SHA3_METHOD meth; + uint64_t A[5][5]; + size_t block_size; /* cached ctx->digest->block_size */ + size_t md_size; /* output length, variable in XOF */ + size_t bufsz; /* used bytes in below buffer */ + unsigned char buf[KECCAK1600_WIDTH / 8 - 32]; + unsigned char pad; + PROV_SHA3_METHOD meth; }; void ossl_sha3_reset(KECCAK1600_CTX *ctx); int ossl_sha3_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen); -int ossl_keccak_kmac_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen); +int ossl_keccak_kmac_init(KECCAK1600_CTX *ctx, unsigned char pad, + size_t bitlen); int ossl_sha3_update(KECCAK1600_CTX *ctx, const void *_inp, size_t len); int ossl_sha3_final(unsigned char *md, KECCAK1600_CTX *ctx); -size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, size_t r); +size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, + size_t r); #endif /* OSSL_INTERNAL_SHA3_H */ diff --git a/libs/OpenSSL/include/internal/sizes.h b/libs/OpenSSL/include/internal/sizes.h index d6f655ee..4a72ed9e 100644 --- a/libs/OpenSSL/include/internal/sizes.h +++ b/libs/OpenSSL/include/internal/sizes.h @@ -15,8 +15,8 @@ * Max sizes used to allocate buffers with a fixed sizes, for example for * stack allocations, structure fields, ... */ -#define OSSL_MAX_NAME_SIZE 50 /* Algorithm name */ -#define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */ +#define OSSL_MAX_NAME_SIZE 50 /* Algorithm name */ +#define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */ #define OSSL_MAX_ALGORITHM_ID_SIZE 256 /* AlgorithmIdentifier DER */ #endif diff --git a/libs/OpenSSL/include/internal/sm3.h b/libs/OpenSSL/include/internal/sm3.h index 37f33294..5c7252f9 100644 --- a/libs/OpenSSL/include/internal/sm3.h +++ b/libs/OpenSSL/include/internal/sm3.h @@ -16,7 +16,7 @@ #include #ifdef OPENSSL_NO_SM3 -# error SM3 is disabled. +# error SM3 is disabled. #endif #define SM3_DIGEST_LENGTH 32 @@ -27,10 +27,10 @@ typedef struct SM3state_st { - SM3_WORD A, B, C, D, E, F, G, H; - SM3_WORD Nl, Nh; - SM3_WORD data[SM3_LBLOCK]; - unsigned int num; + SM3_WORD A, B, C, D, E, F, G, H; + SM3_WORD Nl, Nh; + SM3_WORD data[SM3_LBLOCK]; + unsigned int num; } SM3_CTX; int ossl_sm3_init(SM3_CTX *c); diff --git a/libs/OpenSSL/include/internal/sockets.h b/libs/OpenSSL/include/internal/sockets.h index 53aec6aa..c40a2b16 100644 --- a/libs/OpenSSL/include/internal/sockets.h +++ b/libs/OpenSSL/include/internal/sockets.h @@ -14,42 +14,42 @@ #include #if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) -# define NO_SYS_PARAM_H +# define NO_SYS_PARAM_H #endif #ifdef WIN32 -# define NO_SYS_UN_H +# define NO_SYS_UN_H #endif #ifdef OPENSSL_SYS_VMS -# define NO_SYS_PARAM_H -# define NO_SYS_UN_H +# define NO_SYS_PARAM_H +# define NO_SYS_UN_H #endif #ifdef OPENSSL_NO_SOCK #elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) -# if defined(__DJGPP__) -# define WATT32 -# define WATT32_NO_OLDIES -# include -# include -# include -# include -# include -# include -# elif defined(_WIN32_WCE) && _WIN32_WCE < 410 -# define getservbyname _masked_declaration_getservbyname -# endif -# if !defined(IPPROTO_IP) +# if defined(__DJGPP__) +# define WATT32 +# define WATT32_NO_OLDIES +# include +# include +# include +# include +# include +# include +# elif defined(_WIN32_WCE) && _WIN32_WCE < 410 +# define getservbyname _masked_declaration_getservbyname +# endif +# if !defined(IPPROTO_IP) /* winsock[2].h was included already? */ -# include -# endif -# ifdef getservbyname +# include +# endif +# ifdef getservbyname /* this is used to be wcecompat/include/winsock_extras.h */ -# undef getservbyname +# undef getservbyname struct servent *PASCAL getservbyname(const char *, const char *); -# endif +# endif -# ifdef _WIN64 +# ifdef _WIN64 /* * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because * the value constitutes an index in per-process table of limited size @@ -57,78 +57,80 @@ struct servent *PASCAL getservbyname(const char *, const char *); * Windows run on happen to be two's-complement, which allows to * interchange INVALID_SOCKET and -1. */ -# define socket(d, t, p) ((int)socket(d, t, p)) -# define accept(s, f, l) ((int)accept(s, f, l)) -# endif +# define socket(d, t, p) ((int)socket(d, t, p)) +# define accept(s, f, l) ((int)accept(s, f, l)) +# endif /* Windows have other names for shutdown() reasons */ -# ifndef SHUT_RD -# define SHUT_RD SD_RECEIVE -# endif -# ifndef SHUT_WR -# define SHUT_WR SD_SEND -# endif -# ifndef SHUT_RDWR -# define SHUT_RDWR SD_BOTH -# endif +# ifndef SHUT_RD +# define SHUT_RD SD_RECEIVE +# endif +# ifndef SHUT_WR +# define SHUT_WR SD_SEND +# endif +# ifndef SHUT_RDWR +# define SHUT_RDWR SD_BOTH +# endif #else -# if defined(__APPLE__) +# if defined(__APPLE__) /* * This must be defined before including to get * IPV6_RECVPKTINFO */ -# define __APPLE_USE_RFC_3542 -# endif +# define __APPLE_USE_RFC_3542 +# endif -# ifndef NO_SYS_PARAM_H -# include -# endif -# ifdef OPENSSL_SYS_VXWORKS -# include -# endif +# ifndef NO_SYS_PARAM_H +# include +# endif +# ifdef OPENSSL_SYS_VXWORKS +# include +# endif -# include -# if defined(OPENSSL_SYS_VMS_NODECC) -# include -# include -# include -# else -# include -# if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK) -# include -# ifndef UNIX_PATH_MAX -# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path) -# endif -# endif -# ifdef FILIO_H -# include /* FIONBIO in some SVR4, e.g. unixware, solaris */ -# endif -# include -# include -# include +# include +# if defined(OPENSSL_SYS_VMS_NODECC) +# include +# include +# include +# else +# include +# if !defined(NO_SYS_UN_H) && defined(AF_UNIX) \ + && !defined(OPENSSL_NO_UNIX_SOCK) +# include +# ifndef UNIX_PATH_MAX +# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path) +# endif # endif - -# ifdef OPENSSL_SYS_AIX -# include +# ifdef FILIO_H +# include /* FIONBIO in some SVR4, e.g. unixware, solaris */ # endif +# include +# include +# include +# endif -# ifndef VMS -# include -# else -# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000) +# ifdef OPENSSL_SYS_AIX +# include +# endif + +# ifndef VMS +# include +# else +# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) \ + && (__VMS_VER > 70000000) /* ioctl is only in VMS > 7.0 and when socketshr is not used */ -# include -# endif -# include -# if defined(TCPIP_TYPE_SOCKETSHR) -# include -# endif +# include # endif +# include +# if defined(TCPIP_TYPE_SOCKETSHR) +# include +# endif +# endif -# ifndef INVALID_SOCKET -# define INVALID_SOCKET (-1) -# endif +# ifndef INVALID_SOCKET +# define INVALID_SOCKET (-1) +# endif #endif /* @@ -136,69 +138,69 @@ struct servent *PASCAL getservbyname(const char *, const char *); * bad versions. */ #if !defined(OPENSSL_USE_IPV6) -# if defined(AF_INET6) -# define OPENSSL_USE_IPV6 1 -# else -# define OPENSSL_USE_IPV6 0 -# endif +# if defined(AF_INET6) +# define OPENSSL_USE_IPV6 1 +# else +# define OPENSSL_USE_IPV6 0 +# endif #endif /* * Some platforms define AF_UNIX, but don't support it */ #if !defined(OPENSSL_NO_UNIX_SOCK) -# if !defined(AF_UNIX) || defined(NO_SYS_UN_H) -# define OPENSSL_NO_UNIX_SOCK -# endif +# if !defined(AF_UNIX) || defined(NO_SYS_UN_H) +# define OPENSSL_NO_UNIX_SOCK +# endif #endif #define get_last_socket_error() errno #define clear_socket_error() errno = 0 #if defined(OPENSSL_SYS_WINDOWS) -# undef get_last_socket_error -# undef clear_socket_error -# define get_last_socket_error() WSAGetLastError() -# define clear_socket_error() WSASetLastError(0) -# define readsocket(s, b, n) recv((s), (b), (n), 0) -# define writesocket(s, b, n) send((s), (b), (n), 0) +# undef get_last_socket_error +# undef clear_socket_error +# define get_last_socket_error() WSAGetLastError() +# define clear_socket_error() WSASetLastError(0) +# define readsocket(s, b, n) recv((s), (b), (n), 0) +# define writesocket(s, b, n) send((s), (b), (n), 0) #elif defined(__DJGPP__) -# define closesocket(s) close_s(s) -# define readsocket(s, b, n) read_s(s, b, n) -# define writesocket(s, b, n) send(s, b, n, 0) +# define closesocket(s) close_s(s) +# define readsocket(s, b, n) read_s(s, b, n) +# define writesocket(s, b, n) send(s, b, n, 0) #elif defined(OPENSSL_SYS_VMS) -# define ioctlsocket(a, b, c) ioctl(a, b, c) -# define closesocket(s) close(s) -# define readsocket(s, b, n) recv((s), (b), (n), 0) -# define writesocket(s, b, n) send((s), (b), (n), 0) +# define ioctlsocket(a, b, c) ioctl(a, b, c) +# define closesocket(s) close(s) +# define readsocket(s, b, n) recv((s), (b), (n), 0) +# define writesocket(s, b, n) send((s), (b), (n), 0) #elif defined(OPENSSL_SYS_VXWORKS) -# define ioctlsocket(a, b, c) ioctl((a), (b), (int)(c)) -# define closesocket(s) close(s) -# define readsocket(s, b, n) read((s), (b), (n)) -# define writesocket(s, b, n) write((s), (char *)(b), (n)) +# define ioctlsocket(a, b, c) ioctl((a), (b), (int)(c)) +# define closesocket(s) close(s) +# define readsocket(s, b, n) read((s), (b), (n)) +# define writesocket(s, b, n) write((s), (char *)(b), (n)) #elif defined(OPENSSL_SYS_TANDEM) -# if defined(OPENSSL_TANDEM_FLOSS) -# include -# define readsocket(s, b, n) floss_read((s), (b), (n)) -# define writesocket(s, b, n) floss_write((s), (b), (n)) -# else -# define readsocket(s, b, n) read((s), (b), (n)) -# define writesocket(s, b, n) write((s), (b), (n)) -# endif -# define ioctlsocket(a, b, c) ioctl(a, b, c) -# define closesocket(s) close(s) -#else -# define ioctlsocket(a, b, c) ioctl(a, b, c) -# define closesocket(s) close(s) +# if defined(OPENSSL_TANDEM_FLOSS) +# include +# define readsocket(s, b, n) floss_read((s), (b), (n)) +# define writesocket(s, b, n) floss_write((s), (b), (n)) +# else # define readsocket(s, b, n) read((s), (b), (n)) # define writesocket(s, b, n) write((s), (b), (n)) +# endif +# define ioctlsocket(a, b, c) ioctl(a, b, c) +# define closesocket(s) close(s) +#else +# define ioctlsocket(a, b, c) ioctl(a, b, c) +# define closesocket(s) close(s) +# define readsocket(s, b, n) read((s), (b), (n)) +# define writesocket(s, b, n) write((s), (b), (n)) #endif /* also in apps/include/apps.h */ #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE) -# define openssl_fdset(a, b) FD_SET((unsigned int)(a), b) +# define openssl_fdset(a, b) FD_SET((unsigned int)(a), b) #else -# define openssl_fdset(a, b) FD_SET(a, b) +# define openssl_fdset(a, b) FD_SET(a, b) #endif #endif diff --git a/libs/OpenSSL/include/internal/sslconf.h b/libs/OpenSSL/include/internal/sslconf.h index e47d9ffa..699fb5c0 100644 --- a/libs/OpenSSL/include/internal/sslconf.h +++ b/libs/OpenSSL/include/internal/sslconf.h @@ -15,6 +15,7 @@ typedef struct ssl_conf_cmd_st SSL_CONF_CMD; const SSL_CONF_CMD *conf_ssl_get(size_t idx, const char **name, size_t *cnt); int conf_ssl_name_find(const char *name, size_t *idx); -void conf_ssl_get_cmd(const SSL_CONF_CMD *cmd, size_t idx, char **cmdstr, char **arg); +void conf_ssl_get_cmd(const SSL_CONF_CMD *cmd, size_t idx, char **cmdstr, + char **arg); #endif diff --git a/libs/OpenSSL/include/internal/symhacks.h b/libs/OpenSSL/include/internal/symhacks.h index 33a17d8b..c32297bf 100644 --- a/libs/OpenSSL/include/internal/symhacks.h +++ b/libs/OpenSSL/include/internal/symhacks.h @@ -16,11 +16,11 @@ #if defined(OPENSSL_SYS_VMS) /* ossl_provider_gettable_params vs OSSL_PROVIDER_gettable_params */ -# undef ossl_provider_gettable_params -# define ossl_provider_gettable_params ossl_int_prov_gettable_params +# undef ossl_provider_gettable_params +# define ossl_provider_gettable_params ossl_int_prov_gettable_params /* ossl_provider_get_params vs OSSL_PROVIDER_get_params */ -# undef ossl_provider_get_params -# define ossl_provider_get_params ossl_int_prov_get_params +# undef ossl_provider_get_params +# define ossl_provider_get_params ossl_int_prov_get_params #endif diff --git a/libs/OpenSSL/include/internal/thread.h b/libs/OpenSSL/include/internal/thread.h index 3385ba18..539a1621 100644 --- a/libs/OpenSSL/include/internal/thread.h +++ b/libs/OpenSSL/include/internal/thread.h @@ -16,21 +16,23 @@ #include #include "crypto/context.h" -void *ossl_crypto_thread_start(OSSL_LIB_CTX *ctx, CRYPTO_THREAD_ROUTINE start, void *data); +void *ossl_crypto_thread_start(OSSL_LIB_CTX *ctx, CRYPTO_THREAD_ROUTINE start, + void *data); int ossl_crypto_thread_join(void *task, CRYPTO_THREAD_RETVAL *retval); int ossl_crypto_thread_clean(void *vhandle); uint64_t ossl_get_avail_threads(OSSL_LIB_CTX *ctx); #if defined(OPENSSL_THREADS) -# define OSSL_LIB_CTX_GET_THREADS(CTX) ossl_lib_ctx_get_data(CTX, OSSL_LIB_CTX_THREAD_INDEX); +# define OSSL_LIB_CTX_GET_THREADS(CTX) \ + ossl_lib_ctx_get_data(CTX, OSSL_LIB_CTX_THREAD_INDEX); typedef struct openssl_threads_st { - uint64_t max_threads; - uint64_t active_threads; - CRYPTO_MUTEX *lock; - CRYPTO_CONDVAR *cond_finished; + uint64_t max_threads; + uint64_t active_threads; + CRYPTO_MUTEX *lock; + CRYPTO_CONDVAR *cond_finished; } OSSL_LIB_CTX_THREADS; #endif /* defined(OPENSSL_THREADS) */ diff --git a/libs/OpenSSL/include/internal/thread_arch.h b/libs/OpenSSL/include/internal/thread_arch.h index 0a54a274..6cad4847 100644 --- a/libs/OpenSSL/include/internal/thread_arch.h +++ b/libs/OpenSSL/include/internal/thread_arch.h @@ -13,19 +13,20 @@ #include #if defined(_WIN32) -# include +# include #endif #if defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_UNIX) -# define OPENSSL_THREADS_POSIX -#elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_WINDOWS) && defined(_WIN32_WINNT) -# if _WIN32_WINNT >= 0x0600 -# define OPENSSL_THREADS_WINNT -# else -# define OPENSSL_THREADS_NONE -# endif -#else +# define OPENSSL_THREADS_POSIX +#elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_WINDOWS) \ + && defined(_WIN32_WINNT) +# if _WIN32_WINNT >= 0x0600 +# define OPENSSL_THREADS_WINNT +# else # define OPENSSL_THREADS_NONE +# endif +#else +# define OPENSSL_THREADS_NONE #endif #include @@ -46,7 +47,9 @@ void ossl_crypto_condvar_free(CRYPTO_CONDVAR **cv); typedef uint32_t CRYPTO_THREAD_RETVAL; typedef CRYPTO_THREAD_RETVAL (*CRYPTO_THREAD_ROUTINE)(void *); -typedef CRYPTO_THREAD_RETVAL (*CRYPTO_THREAD_ROUTINE_CB)(void *, void (**)(void *), void **); +typedef CRYPTO_THREAD_RETVAL (*CRYPTO_THREAD_ROUTINE_CB)(void *, + void (**)(void *), + void **); #define CRYPTO_THREAD_NO_STATE 0UL #define CRYPTO_THREAD_FINISHED (1UL << 0) @@ -58,59 +61,61 @@ typedef CRYPTO_THREAD_RETVAL (*CRYPTO_THREAD_ROUTINE_CB)(void *, void (**)(void typedef struct crypto_thread_st { - uint32_t state; - void *data; - CRYPTO_THREAD_ROUTINE routine; - CRYPTO_THREAD_RETVAL retval; - void *handle; - CRYPTO_MUTEX *lock; - CRYPTO_MUTEX *statelock; - CRYPTO_CONDVAR *condvar; - unsigned long thread_id; - int joinable; - OSSL_LIB_CTX *ctx; + uint32_t state; + void *data; + CRYPTO_THREAD_ROUTINE routine; + CRYPTO_THREAD_RETVAL retval; + void *handle; + CRYPTO_MUTEX *lock; + CRYPTO_MUTEX *statelock; + CRYPTO_CONDVAR *condvar; + unsigned long thread_id; + int joinable; + OSSL_LIB_CTX *ctx; } CRYPTO_THREAD; #if defined(OPENSSL_THREADS) -# define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) \ - do \ - { \ - (THREAD)->state &= ~(FLAG); \ - } while ((void)0, 0) +# define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) \ + do \ + { \ + (THREAD)->state &= ~(FLAG); \ + } while ((void)0, 0) -# define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) \ - do \ - { \ - (THREAD)->state |= (FLAG); \ - } while ((void)0, 0) +# define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) \ + do \ + { \ + (THREAD)->state |= (FLAG); \ + } while ((void)0, 0) -# define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) \ - do \ - { \ - (THREAD)->state |= ((FLAG) << 16); \ - } while ((void)0, 0) +# define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) \ + do \ + { \ + (THREAD)->state |= ((FLAG) << 16); \ + } while ((void)0, 0) -# define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) \ - do \ - { \ - (THREAD)->state &= ~((FLAG) << 16); \ - } while ((void)0, 0) +# define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) \ + do \ + { \ + (THREAD)->state &= ~((FLAG) << 16); \ + } while ((void)0, 0) #else -# define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) -# define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) -# define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) -# define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) +# define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) +# define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) +# define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) +# define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) #endif /* defined(OPENSSL_THREADS) */ -CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine, void *data, - int joinable); +CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine, + void *data, int joinable); int ossl_crypto_thread_native_spawn(CRYPTO_THREAD *thread); -int ossl_crypto_thread_native_join(CRYPTO_THREAD *thread, CRYPTO_THREAD_RETVAL *retval); -int ossl_crypto_thread_native_perform_join(CRYPTO_THREAD *thread, CRYPTO_THREAD_RETVAL *retval); +int ossl_crypto_thread_native_join(CRYPTO_THREAD *thread, + CRYPTO_THREAD_RETVAL *retval); +int ossl_crypto_thread_native_perform_join(CRYPTO_THREAD *thread, + CRYPTO_THREAD_RETVAL *retval); int ossl_crypto_thread_native_exit(void); int ossl_crypto_thread_native_is_self(CRYPTO_THREAD *thread); int ossl_crypto_thread_native_clean(CRYPTO_THREAD *thread); diff --git a/libs/OpenSSL/include/internal/thread_once.h b/libs/OpenSSL/include/internal/thread_once.h index b43fee27..6df8d3f1 100644 --- a/libs/OpenSSL/include/internal/thread_once.h +++ b/libs/OpenSSL/include/internal/thread_once.h @@ -34,22 +34,22 @@ * return 0; * } */ -# define DEFINE_RUN_ONCE(init) \ - static int init(void); \ - int init##_ossl_ret_ = 0; \ - void init##_ossl_(void) \ - { \ - init##_ossl_ret_ = init(); \ - } \ - static int init(void) +# define DEFINE_RUN_ONCE(init) \ + static int init(void); \ + int init##_ossl_ret_ = 0; \ + void init##_ossl_(void) \ + { \ + init##_ossl_ret_ = init(); \ + } \ + static int init(void) /* * DECLARE_RUN_ONCE: Declare an initialiser function that should be run exactly * once that has been defined in another file via DEFINE_RUN_ONCE(). */ -# define DECLARE_RUN_ONCE(init) \ - extern int init##_ossl_ret_; \ - void init##_ossl_(void); +# define DECLARE_RUN_ONCE(init) \ + extern int init##_ossl_ret_; \ + void init##_ossl_(void); /* * DEFINE_RUN_ONCE_STATIC: Define an initialiser function that should be run @@ -66,14 +66,14 @@ * return 0; * } */ -# define DEFINE_RUN_ONCE_STATIC(init) \ - static int init(void); \ - static int init##_ossl_ret_ = 0; \ - static void init##_ossl_(void) \ - { \ - init##_ossl_ret_ = init(); \ - } \ - static int init(void) +# define DEFINE_RUN_ONCE_STATIC(init) \ + static int init(void); \ + static int init##_ossl_ret_ = 0; \ + static void init##_ossl_(void) \ + { \ + init##_ossl_ret_ = init(); \ + } \ + static int init(void) /* * DEFINE_RUN_ONCE_STATIC_ALT: Define an alternative initialiser function. This @@ -107,13 +107,13 @@ * return 0; * } */ -# define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ - static int initalt(void); \ - static void initalt##_ossl_(void) \ - { \ - init##_ossl_ret_ = initalt(); \ - } \ - static int initalt(void) +# define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ + static int initalt(void); \ + static void initalt##_ossl_(void) \ + { \ + init##_ossl_ret_ = initalt(); \ + } \ + static int initalt(void) /* * RUN_ONCE - use CRYPTO_THREAD_run_once, and check if the init succeeded @@ -126,7 +126,8 @@ * * (*) by convention, since the init function must return 1 on success. */ -# define RUN_ONCE(once, init) (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0) +# define RUN_ONCE(once, init) \ + (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0) /* * RUN_ONCE_ALT - use CRYPTO_THREAD_run_once, to run an alternative initialiser @@ -143,8 +144,8 @@ * * (*) by convention, since the init function must return 1 on success. */ -# define RUN_ONCE_ALT(once, initalt, init) \ - (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0) +# define RUN_ONCE_ALT(once, initalt, init) \ + (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0) #endif /* FIPS_MODULE */ #endif /* OSSL_INTERNAL_THREAD_ONCE_H */ diff --git a/libs/OpenSSL/include/internal/time.h b/libs/OpenSSL/include/internal/time.h index 6b704e04..f853b60a 100644 --- a/libs/OpenSSL/include/internal/time.h +++ b/libs/OpenSSL/include/internal/time.h @@ -24,7 +24,7 @@ */ typedef struct { - uint64_t t; /* Ticks since the epoch */ + uint64_t t; /* Ticks since the epoch */ } OSSL_TIME; /* The precision of times allows this many values per second */ @@ -36,26 +36,26 @@ typedef struct /* One microsecond. */ #define OSSL_TIME_US (OSSL_TIME_MS / 1000) -#define ossl_seconds2time(s) ossl_ticks2time((s)*OSSL_TIME_SECOND) +#define ossl_seconds2time(s) ossl_ticks2time((s) * OSSL_TIME_SECOND) #define ossl_time2seconds(t) (ossl_time2ticks(t) / OSSL_TIME_SECOND) -#define ossl_ms2time(ms) ossl_ticks2time((ms)*OSSL_TIME_MS) +#define ossl_ms2time(ms) ossl_ticks2time((ms) * OSSL_TIME_MS) #define ossl_time2ms(t) (ossl_time2ticks(t) / OSSL_TIME_MS) -#define ossl_us2time(us) ossl_ticks2time((us)*OSSL_TIME_US) +#define ossl_us2time(us) ossl_ticks2time((us) * OSSL_TIME_US) #define ossl_time2us(t) (ossl_time2ticks(t) / OSSL_TIME_US) /* Convert a tick count into a time */ static ossl_unused ossl_inline OSSL_TIME ossl_ticks2time(uint64_t ticks) { - OSSL_TIME r; + OSSL_TIME r; - r.t = ticks; - return r; + r.t = ticks; + return r; } /* Convert a time to a tick count */ static ossl_unused ossl_inline uint64_t ossl_time2ticks(OSSL_TIME t) { - return t.t; + return t.t; } /* Get current time */ @@ -64,77 +64,78 @@ OSSL_TIME ossl_time_now(void); /* The beginning and end of the time range */ static ossl_unused ossl_inline OSSL_TIME ossl_time_zero(void) { - return ossl_ticks2time(0); + return ossl_ticks2time(0); } static ossl_unused ossl_inline OSSL_TIME ossl_time_infinite(void) { - return ossl_ticks2time(~(uint64_t)0); + return ossl_ticks2time(~(uint64_t)0); } /* Convert time to timeval */ static ossl_unused ossl_inline struct timeval ossl_time_to_timeval(OSSL_TIME t) { - struct timeval tv; + struct timeval tv; #ifdef _WIN32 - tv.tv_sec = (long int)(t.t / OSSL_TIME_SECOND); + tv.tv_sec = (long int)(t.t / OSSL_TIME_SECOND); #else - tv.tv_sec = (time_t)(t.t / OSSL_TIME_SECOND); + tv.tv_sec = (time_t)(t.t / OSSL_TIME_SECOND); #endif - tv.tv_usec = (t.t % OSSL_TIME_SECOND) / OSSL_TIME_US; - return tv; + tv.tv_usec = (t.t % OSSL_TIME_SECOND) / OSSL_TIME_US; + return tv; } /* Convert timeval to time */ -static ossl_unused ossl_inline OSSL_TIME ossl_time_from_timeval(struct timeval tv) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_from_timeval(struct timeval tv) { - OSSL_TIME t; + OSSL_TIME t; #ifndef __DJGPP__ /* tv_sec is unsigned on djgpp. */ - if (tv.tv_sec < 0) - return ossl_time_zero(); + if (tv.tv_sec < 0) + return ossl_time_zero(); #endif - t.t = tv.tv_sec * OSSL_TIME_SECOND + tv.tv_usec * OSSL_TIME_US; - return t; + t.t = tv.tv_sec * OSSL_TIME_SECOND + tv.tv_usec * OSSL_TIME_US; + return t; } /* Convert OSSL_TIME to time_t */ static ossl_unused ossl_inline time_t ossl_time_to_time_t(OSSL_TIME t) { - return (time_t)(t.t / OSSL_TIME_SECOND); + return (time_t)(t.t / OSSL_TIME_SECOND); } /* Convert time_t to OSSL_TIME */ static ossl_unused ossl_inline OSSL_TIME ossl_time_from_time_t(time_t t) { - OSSL_TIME ot; + OSSL_TIME ot; - ot.t = t; - ot.t *= OSSL_TIME_SECOND; - return ot; + ot.t = t; + ot.t *= OSSL_TIME_SECOND; + return ot; } /* Compare two time values, return -1 if less, 1 if greater and 0 if equal */ static ossl_unused ossl_inline int ossl_time_compare(OSSL_TIME a, OSSL_TIME b) { - if (a.t > b.t) - return 1; - if (a.t < b.t) - return -1; - return 0; + if (a.t > b.t) + return 1; + if (a.t < b.t) + return -1; + return 0; } /* Returns true if an OSSL_TIME is ossl_time_zero(). */ static ossl_unused ossl_inline int ossl_time_is_zero(OSSL_TIME t) { - return ossl_time_compare(t, ossl_time_zero()) == 0; + return ossl_time_compare(t, ossl_time_zero()) == 0; } /* Returns true if an OSSL_TIME is ossl_time_infinite(). */ static ossl_unused ossl_inline int ossl_time_is_infinite(OSSL_TIME t) { - return ossl_time_compare(t, ossl_time_infinite()) == 0; + return ossl_time_compare(t, ossl_time_infinite()) == 0; } /* @@ -146,65 +147,71 @@ OSSL_SAFE_MATH_UNSIGNED(time, uint64_t) static ossl_unused ossl_inline OSSL_TIME ossl_time_add(OSSL_TIME a, OSSL_TIME b) { - OSSL_TIME r; - int err = 0; + OSSL_TIME r; + int err = 0; - r.t = safe_add_time(a.t, b.t, &err); - return err ? ossl_time_infinite() : r; + r.t = safe_add_time(a.t, b.t, &err); + return err ? ossl_time_infinite() : r; } -static ossl_unused ossl_inline OSSL_TIME ossl_time_subtract(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME ossl_time_subtract(OSSL_TIME a, + OSSL_TIME b) { - OSSL_TIME r; - int err = 0; + OSSL_TIME r; + int err = 0; - r.t = safe_sub_time(a.t, b.t, &err); - return err ? ossl_time_zero() : r; + r.t = safe_sub_time(a.t, b.t, &err); + return err ? ossl_time_zero() : r; } /* Returns |a - b|. */ -static ossl_unused ossl_inline OSSL_TIME ossl_time_abs_difference(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME ossl_time_abs_difference(OSSL_TIME a, + OSSL_TIME b) { - return a.t > b.t ? ossl_time_subtract(a, b) : ossl_time_subtract(b, a); + return a.t > b.t ? ossl_time_subtract(a, b) : ossl_time_subtract(b, a); } -static ossl_unused ossl_inline OSSL_TIME ossl_time_multiply(OSSL_TIME a, uint64_t b) +static ossl_unused ossl_inline OSSL_TIME ossl_time_multiply(OSSL_TIME a, + uint64_t b) { - OSSL_TIME r; - int err = 0; + OSSL_TIME r; + int err = 0; - r.t = safe_mul_time(a.t, b, &err); - return err ? ossl_time_infinite() : r; + r.t = safe_mul_time(a.t, b, &err); + return err ? ossl_time_infinite() : r; } -static ossl_unused ossl_inline OSSL_TIME ossl_time_divide(OSSL_TIME a, uint64_t b) +static ossl_unused ossl_inline OSSL_TIME ossl_time_divide(OSSL_TIME a, + uint64_t b) { - OSSL_TIME r; - int err = 0; + OSSL_TIME r; + int err = 0; - r.t = safe_div_time(a.t, b, &err); - return err ? ossl_time_zero() : r; + r.t = safe_div_time(a.t, b, &err); + return err ? ossl_time_zero() : r; } -static ossl_unused ossl_inline OSSL_TIME ossl_time_muldiv(OSSL_TIME a, uint64_t b, uint64_t c) +static ossl_unused ossl_inline OSSL_TIME ossl_time_muldiv(OSSL_TIME a, + uint64_t b, + uint64_t c) { - OSSL_TIME r; - int err = 0; + OSSL_TIME r; + int err = 0; - r.t = safe_muldiv_time(a.t, b, c, &err); - return err ? ossl_time_zero() : r; + r.t = safe_muldiv_time(a.t, b, c, &err); + return err ? ossl_time_zero() : r; } /* Return higher of the two given time values. */ static ossl_unused ossl_inline OSSL_TIME ossl_time_max(OSSL_TIME a, OSSL_TIME b) { - return a.t > b.t ? a : b; + return a.t > b.t ? a : b; } /* Return the lower of the two given time values. */ static ossl_unused ossl_inline OSSL_TIME ossl_time_min(OSSL_TIME a, OSSL_TIME b) { - return a.t < b.t ? a : b; + return a.t < b.t ? a : b; } #endif diff --git a/libs/OpenSSL/include/internal/tsan_assist.h b/libs/OpenSSL/include/internal/tsan_assist.h index 86f3d373..c8310494 100644 --- a/libs/OpenSSL/include/internal/tsan_assist.h +++ b/libs/OpenSSL/include/internal/tsan_assist.h @@ -51,31 +51,39 @@ #define OSSL_INTERNAL_TSAN_ASSIST_H #pragma once -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) -# include +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ + && !defined(__STDC_NO_ATOMICS__) +# include -# if defined(ATOMIC_POINTER_LOCK_FREE) && ATOMIC_POINTER_LOCK_FREE >= 2 -# define TSAN_QUALIFIER _Atomic -# define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed) -# define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed) -# define tsan_add(ptr, n) atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed) -# define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire) -# define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release) -# endif +# if defined(ATOMIC_POINTER_LOCK_FREE) && ATOMIC_POINTER_LOCK_FREE >= 2 +# define TSAN_QUALIFIER _Atomic +# define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed) +# define tsan_store(ptr, val) \ + atomic_store_explicit((ptr), (val), memory_order_relaxed) +# define tsan_add(ptr, n) \ + atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed) +# define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire) +# define tsan_st_rel(ptr, val) \ + atomic_store_explicit((ptr), (val), memory_order_release) +# endif #elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) -# if defined(__GCC_ATOMIC_POINTER_LOCK_FREE) && __GCC_ATOMIC_POINTER_LOCK_FREE >= 2 -# define TSAN_QUALIFIER volatile -# define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED) -# define tsan_store(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELAXED) -# define tsan_add(ptr, n) __atomic_fetch_add((ptr), (n), __ATOMIC_RELAXED) -# define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE) -# define tsan_st_rel(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELEASE) -# endif +# if defined(__GCC_ATOMIC_POINTER_LOCK_FREE) \ + && __GCC_ATOMIC_POINTER_LOCK_FREE >= 2 +# define TSAN_QUALIFIER volatile +# define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED) +# define tsan_store(ptr, val) \ + __atomic_store_n((ptr), (val), __ATOMIC_RELAXED) +# define tsan_add(ptr, n) __atomic_fetch_add((ptr), (n), __ATOMIC_RELAXED) +# define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE) +# define tsan_st_rel(ptr, val) \ + __atomic_store_n((ptr), (val), __ATOMIC_RELEASE) +# endif -#elif defined(_MSC_VER) && _MSC_VER >= 1200 \ - && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_ARM64) \ +#elif defined(_MSC_VER) && _MSC_VER >= 1200 \ + && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) \ + || defined(_M_ARM64) \ || (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE))) /* * There is subtle dependency on /volatile: command-line option. @@ -88,56 +96,57 @@ * with additional instructions and penalties, it kind of makes sense to * default to "iso"... */ -# define TSAN_QUALIFIER volatile -# if defined(_M_ARM) || defined(_M_ARM64) -# define _InterlockedExchangeAdd _InterlockedExchangeAdd_nf -# pragma intrinsic(_InterlockedExchangeAdd_nf) -# pragma intrinsic(__iso_volatile_load32, __iso_volatile_store32) -# ifdef _WIN64 -# define _InterlockedExchangeAdd64 _InterlockedExchangeAdd64_nf -# pragma intrinsic(_InterlockedExchangeAdd64_nf) -# pragma intrinsic(__iso_volatile_load64, __iso_volatile_store64) -# define tsan_load(ptr) \ - (sizeof(*(ptr)) == 8 ? __iso_volatile_load64(ptr) : __iso_volatile_load32(ptr)) -# define tsan_store(ptr, val) \ - (sizeof(*(ptr)) == 8 ? __iso_volatile_store64((ptr), (val)) \ - : __iso_volatile_store32((ptr), (val))) -# else -# define tsan_load(ptr) __iso_volatile_load32(ptr) -# define tsan_store(ptr, val) __iso_volatile_store32((ptr), (val)) -# endif -# else -# define tsan_load(ptr) (*(ptr)) -# define tsan_store(ptr, val) (*(ptr) = (val)) -# endif -# pragma intrinsic(_InterlockedExchangeAdd) +# define TSAN_QUALIFIER volatile +# if defined(_M_ARM) || defined(_M_ARM64) +# define _InterlockedExchangeAdd _InterlockedExchangeAdd_nf +# pragma intrinsic(_InterlockedExchangeAdd_nf) +# pragma intrinsic(__iso_volatile_load32, __iso_volatile_store32) # ifdef _WIN64 -# pragma intrinsic(_InterlockedExchangeAdd64) -# define tsan_add(ptr, n) \ - (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), (n)) \ - : _InterlockedExchangeAdd((ptr), (n))) +# define _InterlockedExchangeAdd64 _InterlockedExchangeAdd64_nf +# pragma intrinsic(_InterlockedExchangeAdd64_nf) +# pragma intrinsic(__iso_volatile_load64, __iso_volatile_store64) +# define tsan_load(ptr) \ + (sizeof(*(ptr)) == 8 ? __iso_volatile_load64(ptr) \ + : __iso_volatile_load32(ptr)) +# define tsan_store(ptr, val) \ + (sizeof(*(ptr)) == 8 ? __iso_volatile_store64((ptr), (val)) \ + : __iso_volatile_store32((ptr), (val))) # else -# define tsan_add(ptr, n) _InterlockedExchangeAdd((ptr), (n)) -# endif -# if !defined(_ISO_VOLATILE) -# define tsan_ld_acq(ptr) (*(ptr)) -# define tsan_st_rel(ptr, val) (*(ptr) = (val)) +# define tsan_load(ptr) __iso_volatile_load32(ptr) +# define tsan_store(ptr, val) __iso_volatile_store32((ptr), (val)) # endif +# else +# define tsan_load(ptr) (*(ptr)) +# define tsan_store(ptr, val) (*(ptr) = (val)) +# endif +# pragma intrinsic(_InterlockedExchangeAdd) +# ifdef _WIN64 +# pragma intrinsic(_InterlockedExchangeAdd64) +# define tsan_add(ptr, n) \ + (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), (n)) \ + : _InterlockedExchangeAdd((ptr), (n))) +# else +# define tsan_add(ptr, n) _InterlockedExchangeAdd((ptr), (n)) +# endif +# if !defined(_ISO_VOLATILE) +# define tsan_ld_acq(ptr) (*(ptr)) +# define tsan_st_rel(ptr, val) (*(ptr) = (val)) +# endif #endif #ifndef TSAN_QUALIFIER -# ifdef OPENSSL_THREADS -# define TSAN_QUALIFIER volatile -# define TSAN_REQUIRES_LOCKING -# else /* OPENSSL_THREADS */ -# define TSAN_QUALIFIER -# endif /* OPENSSL_THREADS */ +# ifdef OPENSSL_THREADS +# define TSAN_QUALIFIER volatile +# define TSAN_REQUIRES_LOCKING +# else /* OPENSSL_THREADS */ +# define TSAN_QUALIFIER +# endif /* OPENSSL_THREADS */ -# define tsan_load(ptr) (*(ptr)) -# define tsan_store(ptr, val) (*(ptr) = (val)) -# define tsan_add(ptr, n) (*(ptr) += (n)) +# define tsan_load(ptr) (*(ptr)) +# define tsan_store(ptr, val) (*(ptr) = (val)) +# define tsan_add(ptr, n) (*(ptr) += (n)) /* * Lack of tsan_ld_acq and tsan_ld_rel means that compiler support is not * sophisticated enough to support them. Code that relies on them should be diff --git a/libs/OpenSSL/include/internal/uint_set.h b/libs/OpenSSL/include/internal/uint_set.h index 15ab04cd..77f52c27 100644 --- a/libs/OpenSSL/include/internal/uint_set.h +++ b/libs/OpenSSL/include/internal/uint_set.h @@ -26,14 +26,14 @@ */ typedef struct uint_range_st { - uint64_t start, end; + uint64_t start, end; } UINT_RANGE; typedef struct uint_set_item_st UINT_SET_ITEM; struct uint_set_item_st { - OSSL_LIST_MEMBER(uint_set, UINT_SET_ITEM); - UINT_RANGE range; + OSSL_LIST_MEMBER(uint_set, UINT_SET_ITEM); + UINT_RANGE range; }; DEFINE_LIST_OF(uint_set, UINT_SET_ITEM); diff --git a/libs/OpenSSL/include/internal/unicode.h b/libs/OpenSSL/include/internal/unicode.h index 4f50bcb8..fe8e5f0c 100644 --- a/libs/OpenSSL/include/internal/unicode.h +++ b/libs/OpenSSL/include/internal/unicode.h @@ -13,20 +13,20 @@ typedef enum { - SURROGATE_MIN = 0xd800UL, - SURROGATE_MAX = 0xdfffUL, - UNICODE_MAX = 0x10ffffUL, - UNICODE_LIMIT + SURROGATE_MIN = 0xd800UL, + SURROGATE_MAX = 0xdfffUL, + UNICODE_MAX = 0x10ffffUL, + UNICODE_LIMIT } UNICODE_CONSTANTS; static ossl_unused ossl_inline int is_unicode_surrogate(unsigned long value) { - return value >= SURROGATE_MIN && value <= SURROGATE_MAX; + return value >= SURROGATE_MIN && value <= SURROGATE_MAX; } static ossl_unused ossl_inline int is_unicode_valid(unsigned long value) { - return value <= UNICODE_MAX && !is_unicode_surrogate(value); + return value <= UNICODE_MAX && !is_unicode_surrogate(value); } #endif diff --git a/libs/OpenSSL/include/openssl/aes.h b/libs/OpenSSL/include/openssl/aes.h index 829ad49a..832e01a2 100644 --- a/libs/OpenSSL/include/openssl/aes.h +++ b/libs/OpenSSL/include/openssl/aes.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_AES_H +# define HEADER_AES_H #endif #include @@ -27,20 +27,20 @@ extern "C" { #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define AES_ENCRYPT 1 -# define AES_DECRYPT 0 +# define AES_ENCRYPT 1 +# define AES_DECRYPT 0 -# define AES_MAXNR 14 +# define AES_MAXNR 14 /* This should be a hidden type, but EVP requires that the size be known */ struct aes_key_st { -# ifdef AES_LONG - unsigned long rd_key[4 * (AES_MAXNR + 1)]; -# else - unsigned int rd_key[4 * (AES_MAXNR + 1)]; -# endif - int rounds; +# ifdef AES_LONG + unsigned long rd_key[4 * (AES_MAXNR + 1)]; +# else + unsigned int rd_key[4 * (AES_MAXNR + 1)]; +# endif + int rounds; }; typedef struct aes_key_st AES_KEY; @@ -48,44 +48,52 @@ typedef struct aes_key_st AES_KEY; #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 const char *AES_options(void); OSSL_DEPRECATEDIN_3_0 -int AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); OSSL_DEPRECATEDIN_3_0 -int AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key); OSSL_DEPRECATEDIN_3_0 -void AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); OSSL_DEPRECATEDIN_3_0 -void AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key); +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key); OSSL_DEPRECATEDIN_3_0 -void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key, - const int enc); +void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key, const int enc); OSSL_DEPRECATEDIN_3_0 -void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, - unsigned char *ivec, const int enc); +void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, + const AES_KEY *key, unsigned char *ivec, const int enc); OSSL_DEPRECATEDIN_3_0 -void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, int *num, const int enc); +void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + int *num, const int enc); OSSL_DEPRECATEDIN_3_0 -void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, int *num, const int enc); +void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + int *num, const int enc); OSSL_DEPRECATEDIN_3_0 -void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, int *num, const int enc); +void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + int *num, const int enc); OSSL_DEPRECATEDIN_3_0 -void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, unsigned char *ivec, int *num); +void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, unsigned char *ivec, + int *num); /* NB: the IV is _two_ blocks long */ OSSL_DEPRECATEDIN_3_0 -void AES_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, - unsigned char *ivec, const int enc); +void AES_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length, + const AES_KEY *key, unsigned char *ivec, const int enc); /* NB: the IV is _four_ blocks long */ OSSL_DEPRECATEDIN_3_0 -void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const AES_KEY *key, const AES_KEY *key2, const unsigned char *ivec, - const int enc); +void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const AES_KEY *key, const AES_KEY *key2, + const unsigned char *ivec, const int enc); OSSL_DEPRECATEDIN_3_0 -int AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, const unsigned char *in, - unsigned int inlen); +int AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, + const unsigned char *in, unsigned int inlen); OSSL_DEPRECATEDIN_3_0 int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, const unsigned char *in, unsigned int inlen); diff --git a/libs/OpenSSL/include/openssl/asn1.h b/libs/OpenSSL/include/openssl/asn1.h index 106a3361..6b6bbfe6 100644 --- a/libs/OpenSSL/include/openssl/asn1.h +++ b/libs/OpenSSL/include/openssl/asn1.h @@ -16,11 +16,11 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_ASN1_H +# define HEADER_ASN1_H #endif #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include #include @@ -34,8 +34,8 @@ #include #ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT #endif #ifdef __cplusplus @@ -52,8 +52,8 @@ extern "C" { #define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG #define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ -#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ -#define V_ASN1_ANY -4 /* used in ASN1 template code */ +#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +#define V_ASN1_ANY -4 /* used in ASN1 template code */ #define V_ASN1_UNDEF -1 /* ASN.1 tag values */ @@ -74,15 +74,15 @@ extern "C" { #define V_ASN1_NUMERICSTRING 18 /**/ #define V_ASN1_PRINTABLESTRING 19 #define V_ASN1_T61STRING 20 -#define V_ASN1_TELETEXSTRING 20 /* alias */ +#define V_ASN1_TELETEXSTRING 20 /* alias */ #define V_ASN1_VIDEOTEXSTRING 21 /**/ #define V_ASN1_IA5STRING 22 #define V_ASN1_UTCTIME 23 #define V_ASN1_GENERALIZEDTIME 24 /**/ -#define V_ASN1_GRAPHICSTRING 25 /**/ -#define V_ASN1_ISO64STRING 26 /**/ -#define V_ASN1_VISIBLESTRING 26 /* alias */ -#define V_ASN1_GENERALSTRING 27 /**/ +#define V_ASN1_GRAPHICSTRING 25 /**/ +#define V_ASN1_ISO64STRING 26 /**/ +#define V_ASN1_VISIBLESTRING 26 /* alias */ +#define V_ASN1_GENERALSTRING 27 /**/ #define V_ASN1_UNIVERSALSTRING 28 /**/ #define V_ASN1_BMPSTRING 30 @@ -128,53 +128,73 @@ extern "C" { /* Stacks for types not otherwise defined in this header */ SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR) -#define sk_X509_ALGOR_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_type(sk)) -#define sk_X509_ALGOR_value(sk, idx) \ - ((X509_ALGOR *)OPENSSL_sk_value(ossl_check_const_X509_ALGOR_sk_type(sk), (idx))) -#define sk_X509_ALGOR_new(cmp) \ - ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new(ossl_check_X509_ALGOR_compfunc_type(cmp))) +#define sk_X509_ALGOR_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_value(sk, idx) \ + ((X509_ALGOR *)OPENSSL_sk_value(ossl_check_const_X509_ALGOR_sk_type(sk), \ + (idx))) +#define sk_X509_ALGOR_new(cmp) \ + ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new( \ + ossl_check_X509_ALGOR_compfunc_type(cmp))) #define sk_X509_ALGOR_new_null() ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_null()) -#define sk_X509_ALGOR_new_reserve(cmp, n) \ - ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_reserve(ossl_check_X509_ALGOR_compfunc_type(cmp), (n))) -#define sk_X509_ALGOR_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ALGOR_sk_type(sk), (n)) -#define sk_X509_ALGOR_free(sk) OPENSSL_sk_free(ossl_check_X509_ALGOR_sk_type(sk)) -#define sk_X509_ALGOR_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ALGOR_sk_type(sk)) -#define sk_X509_ALGOR_delete(sk, i) \ - ((X509_ALGOR *)OPENSSL_sk_delete(ossl_check_X509_ALGOR_sk_type(sk), (i))) -#define sk_X509_ALGOR_delete_ptr(sk, ptr) \ - ((X509_ALGOR *)OPENSSL_sk_delete_ptr(ossl_check_X509_ALGOR_sk_type(sk), \ - ossl_check_X509_ALGOR_type(ptr))) -#define sk_X509_ALGOR_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) -#define sk_X509_ALGOR_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) -#define sk_X509_ALGOR_pop(sk) ((X509_ALGOR *)OPENSSL_sk_pop(ossl_check_X509_ALGOR_sk_type(sk))) -#define sk_X509_ALGOR_shift(sk) ((X509_ALGOR *)OPENSSL_sk_shift(ossl_check_X509_ALGOR_sk_type(sk))) -#define sk_X509_ALGOR_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_ALGOR_sk_type(sk), \ - ossl_check_X509_ALGOR_freefunc_type(freefunc)) -#define sk_X509_ALGOR_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr), (idx)) -#define sk_X509_ALGOR_set(sk, idx, ptr) \ - ((X509_ALGOR *)OPENSSL_sk_set(ossl_check_X509_ALGOR_sk_type(sk), (idx), \ - ossl_check_X509_ALGOR_type(ptr))) -#define sk_X509_ALGOR_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) -#define sk_X509_ALGOR_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) -#define sk_X509_ALGOR_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr), pnum) -#define sk_X509_ALGOR_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ALGOR_sk_type(sk)) -#define sk_X509_ALGOR_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ALGOR_sk_type(sk)) -#define sk_X509_ALGOR_dup(sk) \ - ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_dup(ossl_check_const_X509_ALGOR_sk_type(sk))) -#define sk_X509_ALGOR_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_ALGOR_sk_type(sk), \ - ossl_check_X509_ALGOR_copyfunc_type(copyfunc), \ - ossl_check_X509_ALGOR_freefunc_type(freefunc))) -#define sk_X509_ALGOR_set_cmp_func(sk, cmp) \ - ((sk_X509_ALGOR_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_ALGOR_sk_type(sk), \ - ossl_check_X509_ALGOR_compfunc_type(cmp))) +#define sk_X509_ALGOR_new_reserve(cmp, n) \ + ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_ALGOR_compfunc_type(cmp), (n))) +#define sk_X509_ALGOR_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_ALGOR_sk_type(sk), (n)) +#define sk_X509_ALGOR_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_delete(sk, i) \ + ((X509_ALGOR *)OPENSSL_sk_delete(ossl_check_X509_ALGOR_sk_type(sk), (i))) +#define sk_X509_ALGOR_delete_ptr(sk, ptr) \ + ((X509_ALGOR *)OPENSSL_sk_delete_ptr(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr))) +#define sk_X509_ALGOR_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_pop(sk) \ + ((X509_ALGOR *)OPENSSL_sk_pop(ossl_check_X509_ALGOR_sk_type(sk))) +#define sk_X509_ALGOR_shift(sk) \ + ((X509_ALGOR *)OPENSSL_sk_shift(ossl_check_X509_ALGOR_sk_type(sk))) +#define sk_X509_ALGOR_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_freefunc_type(freefunc)) +#define sk_X509_ALGOR_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr), (idx)) +#define sk_X509_ALGOR_set(sk, idx, ptr) \ + ((X509_ALGOR *)OPENSSL_sk_set(ossl_check_X509_ALGOR_sk_type(sk), (idx), \ + ossl_check_X509_ALGOR_type(ptr))) +#define sk_X509_ALGOR_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr)) +#define sk_X509_ALGOR_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_type(ptr), pnum) +#define sk_X509_ALGOR_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_ALGOR_sk_type(sk)) +#define sk_X509_ALGOR_dup(sk) \ + ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_ALGOR_sk_type(sk))) +#define sk_X509_ALGOR_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_copyfunc_type(copyfunc), \ + ossl_check_X509_ALGOR_freefunc_type(freefunc))) +#define sk_X509_ALGOR_set_cmp_func(sk, cmp) \ + ((sk_X509_ALGOR_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_ALGOR_sk_type(sk), \ + ossl_check_X509_ALGOR_compfunc_type(cmp))) #define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ /* @@ -203,15 +223,15 @@ SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR) /* This is the base type that holds just about everything :-) */ struct asn1_string_st { - int length; - int type; - unsigned char *data; - /* - * The value of the following field depends on the type being held. It - * is mostly being used for BIT_STRING so if the input data has a - * non-zero 'unused bits' value, it will be handled correctly - */ - long flags; + int length; + int type; + unsigned char *data; + /* + * The value of the following field depends on the type being held. It + * is mostly being used for BIT_STRING so if the input data has a + * non-zero 'unused bits' value, it will be handled correctly + */ + long flags; }; /* @@ -222,9 +242,9 @@ struct asn1_string_st typedef struct ASN1_ENCODING_st { - unsigned char *enc; /* DER encoding */ - long len; /* Length of encoding */ - int modified; /* set to 1 if 'enc' is invalid */ + unsigned char *enc; /* DER encoding */ + long len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ } ASN1_ENCODING; /* Used with ASN1 LONG type: if a long is set to this it is omitted */ @@ -239,80 +259,95 @@ typedef struct ASN1_ENCODING_st */ #define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC #define STABLE_NO_MASK 0x02 -#define DIRSTRING_TYPE \ - (B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING) +#define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_BMPSTRING \ + | B_ASN1_UTF8STRING) #define PKCS9STRING_TYPE (DIRSTRING_TYPE | B_ASN1_IA5STRING) struct asn1_string_table_st { - int nid; - long minsize; - long maxsize; - unsigned long mask; - unsigned long flags; + int nid; + long minsize; + long maxsize; + unsigned long mask; + unsigned long flags; }; -SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING_TABLE, ASN1_STRING_TABLE, ASN1_STRING_TABLE) -#define sk_ASN1_STRING_TABLE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) -#define sk_ASN1_STRING_TABLE_value(sk, idx) \ - ((ASN1_STRING_TABLE *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), (idx))) -#define sk_ASN1_STRING_TABLE_new(cmp) \ - ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp))) -#define sk_ASN1_STRING_TABLE_new_null() ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_null()) -#define sk_ASN1_STRING_TABLE_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_reserve( \ - ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp), (n))) -#define sk_ASN1_STRING_TABLE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (n)) -#define sk_ASN1_STRING_TABLE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) -#define sk_ASN1_STRING_TABLE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) -#define sk_ASN1_STRING_TABLE_delete(sk, i) \ - ((ASN1_STRING_TABLE *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (i))) -#define sk_ASN1_STRING_TABLE_delete_ptr(sk, ptr) \ - ((ASN1_STRING_TABLE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr))) -#define sk_ASN1_STRING_TABLE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr)) -#define sk_ASN1_STRING_TABLE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr)) -#define sk_ASN1_STRING_TABLE_pop(sk) \ - ((ASN1_STRING_TABLE *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_TABLE_sk_type(sk))) -#define sk_ASN1_STRING_TABLE_shift(sk) \ - ((ASN1_STRING_TABLE *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_TABLE_sk_type(sk))) -#define sk_ASN1_STRING_TABLE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc)) -#define sk_ASN1_STRING_TABLE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr), (idx)) -#define sk_ASN1_STRING_TABLE_set(sk, idx, ptr) \ - ((ASN1_STRING_TABLE *)OPENSSL_sk_set(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (idx), \ - ossl_check_ASN1_STRING_TABLE_type(ptr))) -#define sk_ASN1_STRING_TABLE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr)) -#define sk_ASN1_STRING_TABLE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr)) -#define sk_ASN1_STRING_TABLE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_type(ptr), pnum) -#define sk_ASN1_STRING_TABLE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) -#define sk_ASN1_STRING_TABLE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) -#define sk_ASN1_STRING_TABLE_dup(sk) \ - ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))) -#define sk_ASN1_STRING_TABLE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_copyfunc_type(copyfunc), \ - ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc))) -#define sk_ASN1_STRING_TABLE_set_cmp_func(sk, cmp) \ - ((sk_ASN1_STRING_TABLE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ - ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING_TABLE, ASN1_STRING_TABLE, + ASN1_STRING_TABLE) +#define sk_ASN1_STRING_TABLE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_value(sk, idx) \ + ((ASN1_STRING_TABLE *)OPENSSL_sk_value( \ + ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), (idx))) +#define sk_ASN1_STRING_TABLE_new(cmp) \ + ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new( \ + ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp))) +#define sk_ASN1_STRING_TABLE_new_null() \ + ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_null()) +#define sk_ASN1_STRING_TABLE_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp), (n))) +#define sk_ASN1_STRING_TABLE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (n)) +#define sk_ASN1_STRING_TABLE_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_delete(sk, i) \ + ((ASN1_STRING_TABLE *)OPENSSL_sk_delete( \ + ossl_check_ASN1_STRING_TABLE_sk_type(sk), (i))) +#define sk_ASN1_STRING_TABLE_delete_ptr(sk, ptr) \ + ((ASN1_STRING_TABLE *)OPENSSL_sk_delete_ptr( \ + ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr))) +#define sk_ASN1_STRING_TABLE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_pop(sk) \ + ((ASN1_STRING_TABLE *)OPENSSL_sk_pop( \ + ossl_check_ASN1_STRING_TABLE_sk_type(sk))) +#define sk_ASN1_STRING_TABLE_shift(sk) \ + ((ASN1_STRING_TABLE *)OPENSSL_sk_shift( \ + ossl_check_ASN1_STRING_TABLE_sk_type(sk))) +#define sk_ASN1_STRING_TABLE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc)) +#define sk_ASN1_STRING_TABLE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr), (idx)) +#define sk_ASN1_STRING_TABLE_set(sk, idx, ptr) \ + ((ASN1_STRING_TABLE *)OPENSSL_sk_set( \ + ossl_check_ASN1_STRING_TABLE_sk_type(sk), (idx), \ + ossl_check_ASN1_STRING_TABLE_type(ptr))) +#define sk_ASN1_STRING_TABLE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr)) +#define sk_ASN1_STRING_TABLE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_type(ptr), pnum) +#define sk_ASN1_STRING_TABLE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) +#define sk_ASN1_STRING_TABLE_dup(sk) \ + ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))) +#define sk_ASN1_STRING_TABLE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_copyfunc_type(copyfunc), \ + ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc))) +#define sk_ASN1_STRING_TABLE_set_cmp_func(sk, cmp) \ + ((sk_ASN1_STRING_TABLE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_STRING_TABLE_sk_type(sk), \ + ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp))) /* size limits: this stuff is taken straight from RFC2459 */ @@ -341,75 +376,87 @@ typedef struct ASN1_VALUE_st ASN1_VALUE; * arguments in macro calls. */ -#define DECLARE_ASN1_FUNCTIONS_attr(attr, type) DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, type) +#define DECLARE_ASN1_FUNCTIONS_attr(attr, type) \ + DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, type) #define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_attr(extern, type) -#define DECLARE_ASN1_ALLOC_FUNCTIONS_attr(attr, type) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, type) -#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) DECLARE_ASN1_ALLOC_FUNCTIONS_attr(extern, type) +#define DECLARE_ASN1_ALLOC_FUNCTIONS_attr(attr, type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, type) +#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_attr(extern, type) -#define DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) -#define DECLARE_ASN1_FUNCTIONS_name(type, name) DECLARE_ASN1_FUNCTIONS_name_attr(extern, type, name) +#define DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) +#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_FUNCTIONS_name_attr(extern, type, name) -#define DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, itname, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) DECLARE_ASN1_ITEM_attr(attr, itname) -#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_attr(extern, type, itname, name) +#define DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, itname, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ + DECLARE_ASN1_ITEM_attr(attr, itname) +#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_attr(extern, type, itname, name) -#define DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, name, name) -#define DECLARE_ASN1_ENCODE_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, type, name) +#define DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, name, name) +#define DECLARE_ASN1_ENCODE_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, type, name) -#define DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ - attr type *d2i_##name(type **a, const unsigned char **in, long len); \ - attr int i2d_##name(const type *a, unsigned char **out); -#define DECLARE_ASN1_ENCODE_FUNCTIONS_only(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(extern, type, name) +#define DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ + attr type *d2i_##name(type **a, const unsigned char **in, long len); \ + attr int i2d_##name(const type *a, unsigned char **out); +#define DECLARE_ASN1_ENCODE_FUNCTIONS_only(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(extern, type, name) -#define DECLARE_ASN1_NDEF_FUNCTION_attr(attr, name) \ - attr int i2d_##name##_NDEF(const name *a, unsigned char **out); -#define DECLARE_ASN1_NDEF_FUNCTION(name) DECLARE_ASN1_NDEF_FUNCTION_attr(extern, name) +#define DECLARE_ASN1_NDEF_FUNCTION_attr(attr, name) \ + attr int i2d_##name##_NDEF(const name *a, unsigned char **out); +#define DECLARE_ASN1_NDEF_FUNCTION(name) \ + DECLARE_ASN1_NDEF_FUNCTION_attr(extern, name) -#define DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ - attr type *name##_new(void); \ - attr void name##_free(type *a); -#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(extern, type, name) +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ + attr type *name##_new(void); \ + attr void name##_free(type *a); +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(extern, type, name) -#define DECLARE_ASN1_DUP_FUNCTION_attr(attr, type) \ - DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, type) -#define DECLARE_ASN1_DUP_FUNCTION(type) DECLARE_ASN1_DUP_FUNCTION_attr(extern, type) +#define DECLARE_ASN1_DUP_FUNCTION_attr(attr, type) \ + DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, type) +#define DECLARE_ASN1_DUP_FUNCTION(type) \ + DECLARE_ASN1_DUP_FUNCTION_attr(extern, type) -#define DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, name) attr type *name##_dup(const type *a); -#define DECLARE_ASN1_DUP_FUNCTION_name(type, name) \ - DECLARE_ASN1_DUP_FUNCTION_name_attr(extern, type, name) +#define DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, name) \ + attr type *name##_dup(const type *a); +#define DECLARE_ASN1_DUP_FUNCTION_name(type, name) \ + DECLARE_ASN1_DUP_FUNCTION_name_attr(extern, type, name) -#define DECLARE_ASN1_PRINT_FUNCTION_attr(attr, stname) \ - DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, stname) -#define DECLARE_ASN1_PRINT_FUNCTION(stname) DECLARE_ASN1_PRINT_FUNCTION_attr(extern, stname) +#define DECLARE_ASN1_PRINT_FUNCTION_attr(attr, stname) \ + DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, stname) +#define DECLARE_ASN1_PRINT_FUNCTION(stname) \ + DECLARE_ASN1_PRINT_FUNCTION_attr(extern, stname) -#define DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, fname) \ - attr int fname##_print_ctx(BIO *out, const stname *x, int indent, const ASN1_PCTX *pctx); -#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ - DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname) +#define DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, fname) \ + attr int fname##_print_ctx(BIO *out, const stname *x, int indent, \ + const ASN1_PCTX *pctx); +#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ + DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname) #define D2I_OF(type) type *(*)(type **, const unsigned char **, long) #define I2D_OF(type) int (*)(const type *, unsigned char **) #define CHECKED_D2I_OF(type, d2i) ((d2i_of_void *)(1 ? d2i : ((D2I_OF(type))0))) #define CHECKED_I2D_OF(type, i2d) ((i2d_of_void *)(1 ? i2d : ((I2D_OF(type))0))) -#define CHECKED_NEW_OF(type, xnew) ((void *(*)(void))(1 ? xnew : ((type * (*)(void))0))) +#define CHECKED_NEW_OF(type, xnew) \ + ((void *(*)(void))(1 ? xnew : ((type * (*)(void))0))) #define CHECKED_PTR_OF(type, p) ((void *)(1 ? p : (type *)0)) #define CHECKED_PPTR_OF(type, p) ((void **)(1 ? p : (type **)0)) -#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **, const unsigned char **, long) -#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *, unsigned char **) -#define TYPEDEF_D2I2D_OF(type) \ - TYPEDEF_D2I_OF(type); \ - TYPEDEF_I2D_OF(type) +#define TYPEDEF_D2I_OF(type) \ + typedef type *d2i_of_##type(type **, const unsigned char **, long) +#define TYPEDEF_I2D_OF(type) \ + typedef int i2d_of_##type(const type *, unsigned char **) +#define TYPEDEF_D2I2D_OF(type) \ + TYPEDEF_D2I_OF(type); \ + TYPEDEF_I2D_OF(type) typedef void *d2i_of_void(void **, const unsigned char **, long); typedef int i2d_of_void(const void *, unsigned char **); @@ -466,7 +513,8 @@ typedef const ASN1_ITEM *ASN1_ITEM_EXP(void); #define ASN1_ITEM_rptr(ref) (ref##_it()) -#define DECLARE_ASN1_ITEM_attr(attr, name) attr const ASN1_ITEM *name##_it(void); +#define DECLARE_ASN1_ITEM_attr(attr, name) \ + attr const ASN1_ITEM *name##_it(void); #define DECLARE_ASN1_ITEM(name) DECLARE_ASN1_ITEM_attr(extern, name) /* Parameters used by ASN1_STRING_print_ex() */ @@ -551,91 +599,108 @@ typedef const ASN1_ITEM *ASN1_ITEM_EXP(void); * isn't essential in RFC2253 but it is advisable anyway. */ -#define ASN1_STRFLGS_RFC2253 \ - (ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB \ - | ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN | ASN1_STRFLGS_DUMP_DER) +#define ASN1_STRFLGS_RFC2253 \ + (ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB \ + | ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN \ + | ASN1_STRFLGS_DUMP_DER) struct asn1_type_st { - int type; - union - { - char *ptr; - ASN1_BOOLEAN boolean; - ASN1_STRING *asn1_string; - ASN1_OBJECT *object; - ASN1_INTEGER *integer; - ASN1_ENUMERATED *enumerated; - ASN1_BIT_STRING *bit_string; - ASN1_OCTET_STRING *octet_string; - ASN1_PRINTABLESTRING *printablestring; - ASN1_T61STRING *t61string; - ASN1_IA5STRING *ia5string; - ASN1_GENERALSTRING *generalstring; - ASN1_BMPSTRING *bmpstring; - ASN1_UNIVERSALSTRING *universalstring; - ASN1_UTCTIME *utctime; - ASN1_GENERALIZEDTIME *generalizedtime; - ASN1_VISIBLESTRING *visiblestring; - ASN1_UTF8STRING *utf8string; - /* - * set and sequence are left complete and still contain the set or - * sequence bytes - */ - ASN1_STRING *set; - ASN1_STRING *sequence; - ASN1_VALUE *asn1_value; - } value; + int type; + union + { + char *ptr; + ASN1_BOOLEAN boolean; + ASN1_STRING *asn1_string; + ASN1_OBJECT *object; + ASN1_INTEGER *integer; + ASN1_ENUMERATED *enumerated; + ASN1_BIT_STRING *bit_string; + ASN1_OCTET_STRING *octet_string; + ASN1_PRINTABLESTRING *printablestring; + ASN1_T61STRING *t61string; + ASN1_IA5STRING *ia5string; + ASN1_GENERALSTRING *generalstring; + ASN1_BMPSTRING *bmpstring; + ASN1_UNIVERSALSTRING *universalstring; + ASN1_UTCTIME *utctime; + ASN1_GENERALIZEDTIME *generalizedtime; + ASN1_VISIBLESTRING *visiblestring; + ASN1_UTF8STRING *utf8string; + /* + * set and sequence are left complete and still contain the set or + * sequence bytes + */ + ASN1_STRING *set; + ASN1_STRING *sequence; + ASN1_VALUE *asn1_value; + } value; }; SKM_DEFINE_STACK_OF_INTERNAL(ASN1_TYPE, ASN1_TYPE, ASN1_TYPE) -#define sk_ASN1_TYPE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_TYPE_sk_type(sk)) -#define sk_ASN1_TYPE_value(sk, idx) \ - ((ASN1_TYPE *)OPENSSL_sk_value(ossl_check_const_ASN1_TYPE_sk_type(sk), (idx))) -#define sk_ASN1_TYPE_new(cmp) \ - ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new(ossl_check_ASN1_TYPE_compfunc_type(cmp))) +#define sk_ASN1_TYPE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_value(sk, idx) \ + ((ASN1_TYPE *)OPENSSL_sk_value(ossl_check_const_ASN1_TYPE_sk_type(sk), (idx))) +#define sk_ASN1_TYPE_new(cmp) \ + ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new( \ + ossl_check_ASN1_TYPE_compfunc_type(cmp))) #define sk_ASN1_TYPE_new_null() ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_null()) -#define sk_ASN1_TYPE_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_TYPE_compfunc_type(cmp), (n))) -#define sk_ASN1_TYPE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_TYPE_sk_type(sk), (n)) +#define sk_ASN1_TYPE_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_TYPE_compfunc_type(cmp), (n))) +#define sk_ASN1_TYPE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_TYPE_sk_type(sk), (n)) #define sk_ASN1_TYPE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_TYPE_sk_type(sk)) #define sk_ASN1_TYPE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_TYPE_sk_type(sk)) -#define sk_ASN1_TYPE_delete(sk, i) \ - ((ASN1_TYPE *)OPENSSL_sk_delete(ossl_check_ASN1_TYPE_sk_type(sk), (i))) -#define sk_ASN1_TYPE_delete_ptr(sk, ptr) \ - ((ASN1_TYPE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_TYPE_sk_type(sk), \ - ossl_check_ASN1_TYPE_type(ptr))) -#define sk_ASN1_TYPE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) -#define sk_ASN1_TYPE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) -#define sk_ASN1_TYPE_pop(sk) ((ASN1_TYPE *)OPENSSL_sk_pop(ossl_check_ASN1_TYPE_sk_type(sk))) -#define sk_ASN1_TYPE_shift(sk) ((ASN1_TYPE *)OPENSSL_sk_shift(ossl_check_ASN1_TYPE_sk_type(sk))) -#define sk_ASN1_TYPE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_TYPE_sk_type(sk), \ - ossl_check_ASN1_TYPE_freefunc_type(freefunc)) -#define sk_ASN1_TYPE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr), (idx)) -#define sk_ASN1_TYPE_set(sk, idx, ptr) \ - ((ASN1_TYPE *)OPENSSL_sk_set(ossl_check_ASN1_TYPE_sk_type(sk), (idx), \ - ossl_check_ASN1_TYPE_type(ptr))) -#define sk_ASN1_TYPE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) -#define sk_ASN1_TYPE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) -#define sk_ASN1_TYPE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr), pnum) +#define sk_ASN1_TYPE_delete(sk, i) \ + ((ASN1_TYPE *)OPENSSL_sk_delete(ossl_check_ASN1_TYPE_sk_type(sk), (i))) +#define sk_ASN1_TYPE_delete_ptr(sk, ptr) \ + ((ASN1_TYPE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr))) +#define sk_ASN1_TYPE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_pop(sk) \ + ((ASN1_TYPE *)OPENSSL_sk_pop(ossl_check_ASN1_TYPE_sk_type(sk))) +#define sk_ASN1_TYPE_shift(sk) \ + ((ASN1_TYPE *)OPENSSL_sk_shift(ossl_check_ASN1_TYPE_sk_type(sk))) +#define sk_ASN1_TYPE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_freefunc_type(freefunc)) +#define sk_ASN1_TYPE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr), (idx)) +#define sk_ASN1_TYPE_set(sk, idx, ptr) \ + ((ASN1_TYPE *)OPENSSL_sk_set(ossl_check_ASN1_TYPE_sk_type(sk), (idx), \ + ossl_check_ASN1_TYPE_type(ptr))) +#define sk_ASN1_TYPE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr)) +#define sk_ASN1_TYPE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_type(ptr), pnum) #define sk_ASN1_TYPE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_TYPE_sk_type(sk)) -#define sk_ASN1_TYPE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_TYPE_sk_type(sk)) -#define sk_ASN1_TYPE_dup(sk) \ - ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_TYPE_sk_type(sk))) -#define sk_ASN1_TYPE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_TYPE_sk_type(sk), \ - ossl_check_ASN1_TYPE_copyfunc_type(copyfunc), \ - ossl_check_ASN1_TYPE_freefunc_type(freefunc))) -#define sk_ASN1_TYPE_set_cmp_func(sk, cmp) \ - ((sk_ASN1_TYPE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_TYPE_sk_type(sk), \ - ossl_check_ASN1_TYPE_compfunc_type(cmp))) +#define sk_ASN1_TYPE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_TYPE_sk_type(sk)) +#define sk_ASN1_TYPE_dup(sk) \ + ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_TYPE_sk_type(sk))) +#define sk_ASN1_TYPE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_copyfunc_type(copyfunc), \ + ossl_check_ASN1_TYPE_freefunc_type(freefunc))) +#define sk_ASN1_TYPE_set_cmp_func(sk, cmp) \ + ((sk_ASN1_TYPE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_TYPE_sk_type(sk), \ + ossl_check_ASN1_TYPE_compfunc_type(cmp))) typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; @@ -645,24 +710,25 @@ DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) /* This is used to contain a list of bit names */ typedef struct BIT_STRING_BITNAME_st { - int bitnum; - const char *lname; - const char *sname; + int bitnum; + const char *lname; + const char *sname; } BIT_STRING_BITNAME; #define B_ASN1_TIME B_ASN1_UTCTIME | B_ASN1_GENERALIZEDTIME -#define B_ASN1_PRINTABLE \ - B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING \ - | B_ASN1_BIT_STRING | B_ASN1_UNIVERSALSTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING \ - | B_ASN1_SEQUENCE | B_ASN1_UNKNOWN +#define B_ASN1_PRINTABLE \ + B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING \ + | B_ASN1_IA5STRING | B_ASN1_BIT_STRING | B_ASN1_UNIVERSALSTRING \ + | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING | B_ASN1_SEQUENCE \ + | B_ASN1_UNKNOWN -#define B_ASN1_DIRECTORYSTRING \ - B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING | B_ASN1_BMPSTRING | B_ASN1_UNIVERSALSTRING \ - | B_ASN1_UTF8STRING +#define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING | B_ASN1_BMPSTRING \ + | B_ASN1_UNIVERSALSTRING | B_ASN1_UTF8STRING -#define B_ASN1_DISPLAYTEXT \ - B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING +#define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING DECLARE_ASN1_ALLOC_FUNCTIONS_name(ASN1_TYPE, ASN1_TYPE) DECLARE_ASN1_ENCODE_FUNCTIONS(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) @@ -676,55 +742,74 @@ ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); SKM_DEFINE_STACK_OF_INTERNAL(ASN1_OBJECT, ASN1_OBJECT, ASN1_OBJECT) -#define sk_ASN1_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_OBJECT_sk_type(sk)) -#define sk_ASN1_OBJECT_value(sk, idx) \ - ((ASN1_OBJECT *)OPENSSL_sk_value(ossl_check_const_ASN1_OBJECT_sk_type(sk), (idx))) -#define sk_ASN1_OBJECT_new(cmp) \ - ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new(ossl_check_ASN1_OBJECT_compfunc_type(cmp))) -#define sk_ASN1_OBJECT_new_null() ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_null()) -#define sk_ASN1_OBJECT_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_OBJECT_compfunc_type(cmp), \ - (n))) -#define sk_ASN1_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_OBJECT_sk_type(sk), (n)) -#define sk_ASN1_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_ASN1_OBJECT_sk_type(sk)) -#define sk_ASN1_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_OBJECT_sk_type(sk)) -#define sk_ASN1_OBJECT_delete(sk, i) \ - ((ASN1_OBJECT *)OPENSSL_sk_delete(ossl_check_ASN1_OBJECT_sk_type(sk), (i))) -#define sk_ASN1_OBJECT_delete_ptr(sk, ptr) \ - ((ASN1_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_OBJECT_sk_type(sk), \ - ossl_check_ASN1_OBJECT_type(ptr))) -#define sk_ASN1_OBJECT_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) -#define sk_ASN1_OBJECT_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) -#define sk_ASN1_OBJECT_pop(sk) ((ASN1_OBJECT *)OPENSSL_sk_pop(ossl_check_ASN1_OBJECT_sk_type(sk))) -#define sk_ASN1_OBJECT_shift(sk) \ - ((ASN1_OBJECT *)OPENSSL_sk_shift(ossl_check_ASN1_OBJECT_sk_type(sk))) -#define sk_ASN1_OBJECT_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_OBJECT_sk_type(sk), \ - ossl_check_ASN1_OBJECT_freefunc_type(freefunc)) -#define sk_ASN1_OBJECT_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr), (idx)) -#define sk_ASN1_OBJECT_set(sk, idx, ptr) \ - ((ASN1_OBJECT *)OPENSSL_sk_set(ossl_check_ASN1_OBJECT_sk_type(sk), (idx), \ - ossl_check_ASN1_OBJECT_type(ptr))) -#define sk_ASN1_OBJECT_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) -#define sk_ASN1_OBJECT_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) -#define sk_ASN1_OBJECT_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr), pnum) -#define sk_ASN1_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_OBJECT_sk_type(sk)) -#define sk_ASN1_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_OBJECT_sk_type(sk)) -#define sk_ASN1_OBJECT_dup(sk) \ - ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_ASN1_OBJECT_sk_type(sk))) -#define sk_ASN1_OBJECT_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_copyfunc_type(copyfunc), \ - ossl_check_ASN1_OBJECT_freefunc_type(freefunc))) -#define sk_ASN1_OBJECT_set_cmp_func(sk, cmp) \ - ((sk_ASN1_OBJECT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_OBJECT_sk_type(sk), \ - ossl_check_ASN1_OBJECT_compfunc_type(cmp))) +#define sk_ASN1_OBJECT_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_value(sk, idx) \ + ((ASN1_OBJECT *)OPENSSL_sk_value(ossl_check_const_ASN1_OBJECT_sk_type(sk), \ + (idx))) +#define sk_ASN1_OBJECT_new(cmp) \ + ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new( \ + ossl_check_ASN1_OBJECT_compfunc_type(cmp))) +#define sk_ASN1_OBJECT_new_null() \ + ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_null()) +#define sk_ASN1_OBJECT_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_OBJECT_compfunc_type(cmp), (n))) +#define sk_ASN1_OBJECT_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_OBJECT_sk_type(sk), (n)) +#define sk_ASN1_OBJECT_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_delete(sk, i) \ + ((ASN1_OBJECT *)OPENSSL_sk_delete(ossl_check_ASN1_OBJECT_sk_type(sk), (i))) +#define sk_ASN1_OBJECT_delete_ptr(sk, ptr) \ + ((ASN1_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr))) +#define sk_ASN1_OBJECT_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_pop(sk) \ + ((ASN1_OBJECT *)OPENSSL_sk_pop(ossl_check_ASN1_OBJECT_sk_type(sk))) +#define sk_ASN1_OBJECT_shift(sk) \ + ((ASN1_OBJECT *)OPENSSL_sk_shift(ossl_check_ASN1_OBJECT_sk_type(sk))) +#define sk_ASN1_OBJECT_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_freefunc_type(freefunc)) +#define sk_ASN1_OBJECT_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr), (idx)) +#define sk_ASN1_OBJECT_set(sk, idx, ptr) \ + ((ASN1_OBJECT *)OPENSSL_sk_set(ossl_check_ASN1_OBJECT_sk_type(sk), (idx), \ + ossl_check_ASN1_OBJECT_type(ptr))) +#define sk_ASN1_OBJECT_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr)) +#define sk_ASN1_OBJECT_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_type(ptr), pnum) +#define sk_ASN1_OBJECT_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_OBJECT_sk_type(sk)) +#define sk_ASN1_OBJECT_dup(sk) \ + ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_OBJECT_sk_type(sk))) +#define sk_ASN1_OBJECT_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_copyfunc_type(copyfunc), \ + ossl_check_ASN1_OBJECT_freefunc_type(freefunc))) +#define sk_ASN1_OBJECT_set_cmp_func(sk, cmp) \ + ((sk_ASN1_OBJECT_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_OBJECT_sk_type(sk), \ + ossl_check_ASN1_OBJECT_compfunc_type(cmp))) DECLARE_ASN1_FUNCTIONS(ASN1_OBJECT) @@ -755,70 +840,88 @@ DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); -int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags, int flags_len); +int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags, + int flags_len); -int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, BIT_STRING_BITNAME *tbl, int indent); +int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, + BIT_STRING_BITNAME *tbl, int indent); int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, BIT_STRING_BITNAME *tbl); SKM_DEFINE_STACK_OF_INTERNAL(ASN1_INTEGER, ASN1_INTEGER, ASN1_INTEGER) -#define sk_ASN1_INTEGER_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk)) -#define sk_ASN1_INTEGER_value(sk, idx) \ - ((ASN1_INTEGER *)OPENSSL_sk_value(ossl_check_const_ASN1_INTEGER_sk_type(sk), (idx))) -#define sk_ASN1_INTEGER_new(cmp) \ - ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new(ossl_check_ASN1_INTEGER_compfunc_type(cmp))) -#define sk_ASN1_INTEGER_new_null() ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_null()) -#define sk_ASN1_INTEGER_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_INTEGER_compfunc_type(cmp), \ - (n))) -#define sk_ASN1_INTEGER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_INTEGER_sk_type(sk), (n)) -#define sk_ASN1_INTEGER_free(sk) OPENSSL_sk_free(ossl_check_ASN1_INTEGER_sk_type(sk)) -#define sk_ASN1_INTEGER_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_INTEGER_sk_type(sk)) -#define sk_ASN1_INTEGER_delete(sk, i) \ - ((ASN1_INTEGER *)OPENSSL_sk_delete(ossl_check_ASN1_INTEGER_sk_type(sk), (i))) -#define sk_ASN1_INTEGER_delete_ptr(sk, ptr) \ - ((ASN1_INTEGER *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_INTEGER_sk_type(sk), \ - ossl_check_ASN1_INTEGER_type(ptr))) -#define sk_ASN1_INTEGER_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) -#define sk_ASN1_INTEGER_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) -#define sk_ASN1_INTEGER_pop(sk) \ - ((ASN1_INTEGER *)OPENSSL_sk_pop(ossl_check_ASN1_INTEGER_sk_type(sk))) -#define sk_ASN1_INTEGER_shift(sk) \ - ((ASN1_INTEGER *)OPENSSL_sk_shift(ossl_check_ASN1_INTEGER_sk_type(sk))) -#define sk_ASN1_INTEGER_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_INTEGER_sk_type(sk), \ - ossl_check_ASN1_INTEGER_freefunc_type(freefunc)) -#define sk_ASN1_INTEGER_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr), (idx)) -#define sk_ASN1_INTEGER_set(sk, idx, ptr) \ - ((ASN1_INTEGER *)OPENSSL_sk_set(ossl_check_ASN1_INTEGER_sk_type(sk), (idx), \ - ossl_check_ASN1_INTEGER_type(ptr))) -#define sk_ASN1_INTEGER_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) -#define sk_ASN1_INTEGER_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) -#define sk_ASN1_INTEGER_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr), \ - pnum) -#define sk_ASN1_INTEGER_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_INTEGER_sk_type(sk)) -#define sk_ASN1_INTEGER_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ASN1_INTEGER_sk_type(sk)) -#define sk_ASN1_INTEGER_dup(sk) \ - ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_dup(ossl_check_const_ASN1_INTEGER_sk_type(sk))) -#define sk_ASN1_INTEGER_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASN1_INTEGER_sk_type(sk), \ - ossl_check_ASN1_INTEGER_copyfunc_type(copyfunc), \ - ossl_check_ASN1_INTEGER_freefunc_type(freefunc))) -#define sk_ASN1_INTEGER_set_cmp_func(sk, cmp) \ - ((sk_ASN1_INTEGER_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_compfunc_type(cmp))) +#define sk_ASN1_INTEGER_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_value(sk, idx) \ + ((ASN1_INTEGER *)OPENSSL_sk_value(ossl_check_const_ASN1_INTEGER_sk_type(sk), \ + (idx))) +#define sk_ASN1_INTEGER_new(cmp) \ + ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new( \ + ossl_check_ASN1_INTEGER_compfunc_type(cmp))) +#define sk_ASN1_INTEGER_new_null() \ + ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_null()) +#define sk_ASN1_INTEGER_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_INTEGER_compfunc_type(cmp), (n))) +#define sk_ASN1_INTEGER_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_INTEGER_sk_type(sk), (n)) +#define sk_ASN1_INTEGER_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_delete(sk, i) \ + ((ASN1_INTEGER *)OPENSSL_sk_delete(ossl_check_ASN1_INTEGER_sk_type(sk), (i))) +#define sk_ASN1_INTEGER_delete_ptr(sk, ptr) \ + ((ASN1_INTEGER *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr))) +#define sk_ASN1_INTEGER_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_pop(sk) \ + ((ASN1_INTEGER *)OPENSSL_sk_pop(ossl_check_ASN1_INTEGER_sk_type(sk))) +#define sk_ASN1_INTEGER_shift(sk) \ + ((ASN1_INTEGER *)OPENSSL_sk_shift(ossl_check_ASN1_INTEGER_sk_type(sk))) +#define sk_ASN1_INTEGER_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_freefunc_type(freefunc)) +#define sk_ASN1_INTEGER_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr), (idx)) +#define sk_ASN1_INTEGER_set(sk, idx, ptr) \ + ((ASN1_INTEGER *)OPENSSL_sk_set(ossl_check_ASN1_INTEGER_sk_type(sk), (idx), \ + ossl_check_ASN1_INTEGER_type(ptr))) +#define sk_ASN1_INTEGER_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr)) +#define sk_ASN1_INTEGER_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_type(ptr), pnum) +#define sk_ASN1_INTEGER_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_INTEGER_sk_type(sk)) +#define sk_ASN1_INTEGER_dup(sk) \ + ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_INTEGER_sk_type(sk))) +#define sk_ASN1_INTEGER_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_copyfunc_type(copyfunc), \ + ossl_check_ASN1_INTEGER_freefunc_type(freefunc))) +#define sk_ASN1_INTEGER_set_cmp_func(sk, cmp) \ + ((sk_ASN1_INTEGER_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_INTEGER_sk_type(sk), \ + ossl_check_ASN1_INTEGER_compfunc_type(cmp))) DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) -ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length); +ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, + long length); DECLARE_ASN1_DUP_FUNCTION(ASN1_INTEGER) int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); @@ -826,79 +929,101 @@ DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); -ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec); +ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, + long offset_sec); int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, + time_t t); +ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, + time_t t, int offset_day, long offset_sec); int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); -int ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, const ASN1_TIME *to); +int ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, + const ASN1_TIME *to); DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) DECLARE_ASN1_DUP_FUNCTION(ASN1_OCTET_STRING) -int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, const ASN1_OCTET_STRING *b); -int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, int len); +int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, + const ASN1_OCTET_STRING *b); +int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, + int len); SKM_DEFINE_STACK_OF_INTERNAL(ASN1_UTF8STRING, ASN1_UTF8STRING, ASN1_UTF8STRING) -#define sk_ASN1_UTF8STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) -#define sk_ASN1_UTF8STRING_value(sk, idx) \ - ((ASN1_UTF8STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), (idx))) -#define sk_ASN1_UTF8STRING_new(cmp) \ - ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp))) -#define sk_ASN1_UTF8STRING_new_null() ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_null()) -#define sk_ASN1_UTF8STRING_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_reserve( \ - ossl_check_ASN1_UTF8STRING_compfunc_type(cmp), (n))) -#define sk_ASN1_UTF8STRING_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_ASN1_UTF8STRING_sk_type(sk), (n)) -#define sk_ASN1_UTF8STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_UTF8STRING_sk_type(sk)) -#define sk_ASN1_UTF8STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_UTF8STRING_sk_type(sk)) -#define sk_ASN1_UTF8STRING_delete(sk, i) \ - ((ASN1_UTF8STRING *)OPENSSL_sk_delete(ossl_check_ASN1_UTF8STRING_sk_type(sk), (i))) -#define sk_ASN1_UTF8STRING_delete_ptr(sk, ptr) \ - ((ASN1_UTF8STRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ - ossl_check_ASN1_UTF8STRING_type(ptr))) -#define sk_ASN1_UTF8STRING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) -#define sk_ASN1_UTF8STRING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) -#define sk_ASN1_UTF8STRING_pop(sk) \ - ((ASN1_UTF8STRING *)OPENSSL_sk_pop(ossl_check_ASN1_UTF8STRING_sk_type(sk))) -#define sk_ASN1_UTF8STRING_shift(sk) \ - ((ASN1_UTF8STRING *)OPENSSL_sk_shift(ossl_check_ASN1_UTF8STRING_sk_type(sk))) -#define sk_ASN1_UTF8STRING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ - ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc)) -#define sk_ASN1_UTF8STRING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ - ossl_check_ASN1_UTF8STRING_type(ptr), (idx)) -#define sk_ASN1_UTF8STRING_set(sk, idx, ptr) \ - ((ASN1_UTF8STRING *)OPENSSL_sk_set(ossl_check_ASN1_UTF8STRING_sk_type(sk), (idx), \ - ossl_check_ASN1_UTF8STRING_type(ptr))) -#define sk_ASN1_UTF8STRING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) -#define sk_ASN1_UTF8STRING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) -#define sk_ASN1_UTF8STRING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ - ossl_check_ASN1_UTF8STRING_type(ptr), pnum) -#define sk_ASN1_UTF8STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_UTF8STRING_sk_type(sk)) -#define sk_ASN1_UTF8STRING_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) -#define sk_ASN1_UTF8STRING_dup(sk) \ - ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_UTF8STRING_sk_type(sk))) -#define sk_ASN1_UTF8STRING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASN1_UTF8STRING_sk_type(sk), \ - ossl_check_ASN1_UTF8STRING_copyfunc_type(copyfunc), \ - ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc))) -#define sk_ASN1_UTF8STRING_set_cmp_func(sk, cmp) \ - ((sk_ASN1_UTF8STRING_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_compfunc_type(cmp))) +#define sk_ASN1_UTF8STRING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_value(sk, idx) \ + ((ASN1_UTF8STRING *)OPENSSL_sk_value( \ + ossl_check_const_ASN1_UTF8STRING_sk_type(sk), (idx))) +#define sk_ASN1_UTF8STRING_new(cmp) \ + ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new( \ + ossl_check_ASN1_UTF8STRING_compfunc_type(cmp))) +#define sk_ASN1_UTF8STRING_new_null() \ + ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_null()) +#define sk_ASN1_UTF8STRING_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_UTF8STRING_compfunc_type(cmp), (n))) +#define sk_ASN1_UTF8STRING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_UTF8STRING_sk_type(sk), (n)) +#define sk_ASN1_UTF8STRING_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_delete(sk, i) \ + ((ASN1_UTF8STRING *)OPENSSL_sk_delete( \ + ossl_check_ASN1_UTF8STRING_sk_type(sk), (i))) +#define sk_ASN1_UTF8STRING_delete_ptr(sk, ptr) \ + ((ASN1_UTF8STRING *)OPENSSL_sk_delete_ptr( \ + ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr))) +#define sk_ASN1_UTF8STRING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_pop(sk) \ + ((ASN1_UTF8STRING *)OPENSSL_sk_pop(ossl_check_ASN1_UTF8STRING_sk_type(sk))) +#define sk_ASN1_UTF8STRING_shift(sk) \ + ((ASN1_UTF8STRING *)OPENSSL_sk_shift(ossl_check_ASN1_UTF8STRING_sk_type(sk))) +#define sk_ASN1_UTF8STRING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc)) +#define sk_ASN1_UTF8STRING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr), (idx)) +#define sk_ASN1_UTF8STRING_set(sk, idx, ptr) \ + ((ASN1_UTF8STRING *)OPENSSL_sk_set(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + (idx), \ + ossl_check_ASN1_UTF8STRING_type(ptr))) +#define sk_ASN1_UTF8STRING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr)) +#define sk_ASN1_UTF8STRING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_type(ptr), pnum) +#define sk_ASN1_UTF8STRING_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) +#define sk_ASN1_UTF8STRING_dup(sk) \ + ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_UTF8STRING_sk_type(sk))) +#define sk_ASN1_UTF8STRING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_copyfunc_type(copyfunc), \ + ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc))) +#define sk_ASN1_UTF8STRING_set_cmp_func(sk, cmp) \ + ((sk_ASN1_UTF8STRING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_UTF8STRING_sk_type(sk), \ + ossl_check_ASN1_UTF8STRING_compfunc_type(cmp))) DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) @@ -909,89 +1034,105 @@ DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) int UTF8_getc(const unsigned char *str, int len, unsigned long *val); int UTF8_putc(unsigned char *str, int len, unsigned long value); -SKM_DEFINE_STACK_OF_INTERNAL(ASN1_GENERALSTRING, ASN1_GENERALSTRING, ASN1_GENERALSTRING) -#define sk_ASN1_GENERALSTRING_num(sk) \ - OPENSSL_sk_num(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) -#define sk_ASN1_GENERALSTRING_value(sk, idx) \ - ((ASN1_GENERALSTRING *)OPENSSL_sk_value(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), (idx))) -#define sk_ASN1_GENERALSTRING_new(cmp) \ - ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new( \ - ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp))) -#define sk_ASN1_GENERALSTRING_new_null() ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_null()) -#define sk_ASN1_GENERALSTRING_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_reserve( \ - ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp), (n))) -#define sk_ASN1_GENERALSTRING_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (n)) -#define sk_ASN1_GENERALSTRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) -#define sk_ASN1_GENERALSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) -#define sk_ASN1_GENERALSTRING_delete(sk, i) \ - ((ASN1_GENERALSTRING *)OPENSSL_sk_delete(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (i))) -#define sk_ASN1_GENERALSTRING_delete_ptr(sk, ptr) \ - ((ASN1_GENERALSTRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr))) -#define sk_ASN1_GENERALSTRING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr)) -#define sk_ASN1_GENERALSTRING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr)) -#define sk_ASN1_GENERALSTRING_pop(sk) \ - ((ASN1_GENERALSTRING *)OPENSSL_sk_pop(ossl_check_ASN1_GENERALSTRING_sk_type(sk))) -#define sk_ASN1_GENERALSTRING_shift(sk) \ - ((ASN1_GENERALSTRING *)OPENSSL_sk_shift(ossl_check_ASN1_GENERALSTRING_sk_type(sk))) -#define sk_ASN1_GENERALSTRING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc)) -#define sk_ASN1_GENERALSTRING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr), (idx)) -#define sk_ASN1_GENERALSTRING_set(sk, idx, ptr) \ - ((ASN1_GENERALSTRING *)OPENSSL_sk_set(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (idx), \ - ossl_check_ASN1_GENERALSTRING_type(ptr))) -#define sk_ASN1_GENERALSTRING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr)) -#define sk_ASN1_GENERALSTRING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr)) -#define sk_ASN1_GENERALSTRING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_type(ptr), pnum) -#define sk_ASN1_GENERALSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) -#define sk_ASN1_GENERALSTRING_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) -#define sk_ASN1_GENERALSTRING_dup(sk) \ - ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_dup( \ - ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))) -#define sk_ASN1_GENERALSTRING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_copyfunc_type(copyfunc), \ - ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc))) -#define sk_ASN1_GENERALSTRING_set_cmp_func(sk, cmp) \ - ((sk_ASN1_GENERALSTRING_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ - ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(ASN1_GENERALSTRING, ASN1_GENERALSTRING, + ASN1_GENERALSTRING) +#define sk_ASN1_GENERALSTRING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_value(sk, idx) \ + ((ASN1_GENERALSTRING *)OPENSSL_sk_value( \ + ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), (idx))) +#define sk_ASN1_GENERALSTRING_new(cmp) \ + ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new( \ + ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp))) +#define sk_ASN1_GENERALSTRING_new_null() \ + ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_null()) +#define sk_ASN1_GENERALSTRING_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp), (n))) +#define sk_ASN1_GENERALSTRING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (n)) +#define sk_ASN1_GENERALSTRING_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_delete(sk, i) \ + ((ASN1_GENERALSTRING *)OPENSSL_sk_delete( \ + ossl_check_ASN1_GENERALSTRING_sk_type(sk), (i))) +#define sk_ASN1_GENERALSTRING_delete_ptr(sk, ptr) \ + ((ASN1_GENERALSTRING *)OPENSSL_sk_delete_ptr( \ + ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr))) +#define sk_ASN1_GENERALSTRING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_pop(sk) \ + ((ASN1_GENERALSTRING *)OPENSSL_sk_pop( \ + ossl_check_ASN1_GENERALSTRING_sk_type(sk))) +#define sk_ASN1_GENERALSTRING_shift(sk) \ + ((ASN1_GENERALSTRING *)OPENSSL_sk_shift( \ + ossl_check_ASN1_GENERALSTRING_sk_type(sk))) +#define sk_ASN1_GENERALSTRING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc)) +#define sk_ASN1_GENERALSTRING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr), (idx)) +#define sk_ASN1_GENERALSTRING_set(sk, idx, ptr) \ + ((ASN1_GENERALSTRING *)OPENSSL_sk_set( \ + ossl_check_ASN1_GENERALSTRING_sk_type(sk), (idx), \ + ossl_check_ASN1_GENERALSTRING_type(ptr))) +#define sk_ASN1_GENERALSTRING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr)) +#define sk_ASN1_GENERALSTRING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_type(ptr), pnum) +#define sk_ASN1_GENERALSTRING_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) +#define sk_ASN1_GENERALSTRING_dup(sk) \ + ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))) +#define sk_ASN1_GENERALSTRING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_copyfunc_type(copyfunc), \ + ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc))) +#define sk_ASN1_GENERALSTRING_set_cmp_func(sk, cmp) \ + ((sk_ASN1_GENERALSTRING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_GENERALSTRING_sk_type(sk), \ + ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp))) DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) - DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, - DISPLAYTEXT) DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) - DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) - DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) - DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) DECLARE_ASN1_FUNCTIONS(ASN1_TIME) + DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) + DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) DECLARE_ASN1_FUNCTIONS( + ASN1_T61STRING) DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) + DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) + DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) DECLARE_ASN1_FUNCTIONS( + ASN1_GENERALIZEDTIME) DECLARE_ASN1_FUNCTIONS(ASN1_TIME) - DECLARE_ASN1_DUP_FUNCTION(ASN1_TIME) DECLARE_ASN1_DUP_FUNCTION(ASN1_UTCTIME) - DECLARE_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME) + DECLARE_ASN1_DUP_FUNCTION(ASN1_TIME) + DECLARE_ASN1_DUP_FUNCTION(ASN1_UTCTIME) + DECLARE_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME) - DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) + DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) - ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); -ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec); + ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, + time_t t); +ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, + long offset_sec); int ASN1_TIME_check(const ASN1_TIME *t); -ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); +ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, + ASN1_GENERALIZEDTIME **out); int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str); int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm); @@ -1009,8 +1150,8 @@ int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type); int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a); int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); -ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, const char *sn, - const char *ln); +ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, + const char *sn, const char *ln); int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a); int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r); @@ -1037,68 +1178,75 @@ int ASN1_PRINTABLE_type(const unsigned char *s, int max); unsigned long ASN1_tag2bit(int tag); /* SPECIALS */ -int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, int *pclass, long omax); +int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax); int ASN1_check_infinite_end(unsigned char **p, long len); int ASN1_const_check_infinite_end(const unsigned char **p, long len); -void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, int xclass); +void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, + int xclass); int ASN1_put_eoc(unsigned char **pp); int ASN1_object_size(int constructed, int length, int tag); /* Used to implement other functions */ void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x); -#define ASN1_dup_of(type, i2d, d2i, x) \ - ((type *)ASN1_dup(CHECKED_I2D_OF(type, i2d), CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(const type, x))) +#define ASN1_dup_of(type, i2d, d2i, x) \ + ((type *)ASN1_dup(CHECKED_I2D_OF(type, i2d), CHECKED_D2I_OF(type, d2i), \ + CHECKED_PTR_OF(const type, x))) void *ASN1_item_dup(const ASN1_ITEM *it, const void *x); -int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, const void *data, const ASN1_OCTET_STRING *id, - EVP_PKEY *pkey, const EVP_MD *md, OSSL_LIB_CTX *libctx, const char *propq); +int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + const void *data, const ASN1_OCTET_STRING *id, + EVP_PKEY *pkey, const EVP_MD *md, OSSL_LIB_CTX *libctx, + const char *propq); int ASN1_item_verify_ex(const ASN1_ITEM *it, const X509_ALGOR *alg, const ASN1_BIT_STRING *signature, const void *data, - const ASN1_OCTET_STRING *id, EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, - const char *propq); + const ASN1_OCTET_STRING *id, EVP_PKEY *pkey, + OSSL_LIB_CTX *libctx, const char *propq); /* ASN1 alloc/free macros for when a type is only used internally */ #define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) -#define M_ASN1_free_of(x, type) ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) +#define M_ASN1_free_of(x, type) \ + ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) #ifndef OPENSSL_NO_STDIO void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); -# define ASN1_d2i_fp_of(type, xnew, d2i, in, x) \ - ((type *)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), CHECKED_D2I_OF(type, d2i), in, \ - CHECKED_PPTR_OF(type, x))) +# define ASN1_d2i_fp_of(type, xnew, d2i, in, x) \ + ((type *)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ + CHECKED_D2I_OF(type, d2i), in, \ + CHECKED_PPTR_OF(type, x))) -void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x, OSSL_LIB_CTX *libctx, - const char *propq); +void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x, + OSSL_LIB_CTX *libctx, const char *propq); void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x); -# define ASN1_i2d_fp_of(type, i2d, out, x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), out, CHECKED_PTR_OF(const type, x))) +# define ASN1_i2d_fp_of(type, i2d, out, x) \ + (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), out, CHECKED_PTR_OF(const type, x))) int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x); -int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags); +int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, + unsigned long flags); #endif int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); -#define ASN1_d2i_bio_of(type, xnew, d2i, in, x) \ - ((type *)ASN1_d2i_bio(CHECKED_NEW_OF(type, xnew), CHECKED_D2I_OF(type, d2i), in, \ - CHECKED_PPTR_OF(type, x))) +#define ASN1_d2i_bio_of(type, xnew, d2i, in, x) \ + ((type *)ASN1_d2i_bio(CHECKED_NEW_OF(type, xnew), CHECKED_D2I_OF(type, d2i), \ + in, CHECKED_PPTR_OF(type, x))) -void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *pval, OSSL_LIB_CTX *libctx, - const char *propq); +void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *pval, + OSSL_LIB_CTX *libctx, const char *propq); void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *pval); int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x); -#define ASN1_i2d_bio_of(type, i2d, out, x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), out, CHECKED_PTR_OF(const type, x))) +#define ASN1_i2d_bio_of(type, i2d, out, x) \ + (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), out, CHECKED_PTR_OF(const type, x))) int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x); BIO *ASN1_item_i2d_mem_bio(const ASN1_ITEM *it, const ASN1_VALUE *val); @@ -1109,9 +1257,11 @@ int ASN1_TIME_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags); int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off); -int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *buf, int off); +int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, + unsigned char *buf, int off); int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); -int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump); +int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, + int dump); const char *ASN1_tag2str(int tag); /* Used to load and write Netscape format cert */ @@ -1119,24 +1269,29 @@ const char *ASN1_tag2str(int tag); int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); -int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len); -int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, int len); -int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, unsigned char *data, int max_len); +int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, + int max_len); +int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, unsigned char *data, + int len); +int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, + unsigned char *data, int max_len); void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it); -ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); +ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, + ASN1_OCTET_STRING **oct); void ASN1_STRING_set_default_mask(unsigned long mask); int ASN1_STRING_set_default_mask_asc(const char *p); unsigned long ASN1_STRING_get_default_mask(void); -int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, int inform, - unsigned long mask); -int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, int inform, - unsigned long mask, long minsize, long maxsize); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask); +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, + int inform, unsigned long mask, long minsize, + long maxsize); -ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int inlen, - int inform, int nid); +ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, + int inlen, int inform, int nid); ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); void ASN1_STRING_TABLE_cleanup(void); @@ -1145,14 +1300,18 @@ void ASN1_STRING_TABLE_cleanup(void); /* Old API compatible functions */ ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); -ASN1_VALUE *ASN1_item_new_ex(const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, const char *propq); +ASN1_VALUE *ASN1_item_new_ex(const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, + const char *propq); void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); -ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **val, const unsigned char **in, long len, - const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, const char *propq); +ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **val, const unsigned char **in, + long len, const ASN1_ITEM *it, + OSSL_LIB_CTX *libctx, const char *propq); ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); -int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); +int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, + const ASN1_ITEM *it); +int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out, + const ASN1_ITEM *it); void ASN1_add_oid_module(void); void ASN1_add_stable_module(void); @@ -1182,8 +1341,8 @@ int ASN1_str2mask(const char *str, unsigned long *pmask); /* Don't show structure name even at top level */ #define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 -int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent, const ASN1_ITEM *it, - const ASN1_PCTX *pctx); +int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent, + const ASN1_ITEM *it, const ASN1_PCTX *pctx); ASN1_PCTX *ASN1_PCTX_new(void); void ASN1_PCTX_free(ASN1_PCTX *p); unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p); @@ -1210,18 +1369,22 @@ const BIO_METHOD *BIO_f_asn1(void); /* cannot constify val because of CMS_stream() */ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); -int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const ASN1_ITEM *it); -int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, const char *hdr, - const ASN1_ITEM *it); +int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, + const ASN1_ITEM *it); +int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, + const char *hdr, const ASN1_ITEM *it); /* cannot constify val because of CMS_dataFinal() */ -int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, int ctype_nid, int econt_nid, +int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, + int ctype_nid, int econt_nid, STACK_OF(X509_ALGOR) * mdalgs, const ASN1_ITEM *it); -int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, int ctype_nid, - int econt_nid, STACK_OF(X509_ALGOR) * mdalgs, const ASN1_ITEM *it, +int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, + int ctype_nid, int econt_nid, + STACK_OF(X509_ALGOR) * mdalgs, const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, const char *propq); ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); -ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, int flags, BIO **bcont, const ASN1_ITEM *it, - ASN1_VALUE **x, OSSL_LIB_CTX *libctx, const char *propq); +ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, int flags, BIO **bcont, + const ASN1_ITEM *it, ASN1_VALUE **x, + OSSL_LIB_CTX *libctx, const char *propq); int SMIME_crlf_copy(BIO *in, BIO *out, int flags); int SMIME_text(BIO *in, BIO *out); @@ -1229,14 +1392,18 @@ const ASN1_ITEM *ASN1_ITEM_lookup(const char *name); const ASN1_ITEM *ASN1_ITEM_get(size_t i); /* Legacy compatibility */ -#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) +#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) #define DECLARE_ASN1_FUNCTIONS_const(type) DECLARE_ASN1_FUNCTIONS(type) -#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) DECLARE_ASN1_ENCODE_FUNCTIONS(type, name) +#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name) #define I2D_OF_const(type) I2D_OF(type) #define ASN1_dup_of_const(type, i2d, d2i, x) ASN1_dup_of(type, i2d, d2i, x) -#define ASN1_i2d_fp_of_const(type, i2d, out, x) ASN1_i2d_fp_of(type, i2d, out, x) -#define ASN1_i2d_bio_of_const(type, i2d, out, x) ASN1_i2d_bio_of(type, i2d, out, x) +#define ASN1_i2d_fp_of_const(type, i2d, out, x) \ + ASN1_i2d_fp_of(type, i2d, out, x) +#define ASN1_i2d_bio_of_const(type, i2d, out, x) \ + ASN1_i2d_bio_of(type, i2d, out, x) #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/asn1t.h b/libs/OpenSSL/include/openssl/asn1t.h index 5cd07568..49343c07 100644 --- a/libs/OpenSSL/include/openssl/asn1t.h +++ b/libs/OpenSSL/include/openssl/asn1t.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_ASN1T_H +# define HEADER_ASN1T_H #endif #include @@ -24,8 +24,8 @@ #include #ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT #endif /* ASN1 template defines, structures and functions */ @@ -88,31 +88,31 @@ extern "C" { /* Macros for start and end of ASN1_ITEM definition */ -#define ASN1_ITEM_start(itname) \ - const ASN1_ITEM *itname##_it(void) \ - { \ - static const ASN1_ITEM local_it = { +#define ASN1_ITEM_start(itname) \ + const ASN1_ITEM *itname##_it(void) \ + { \ + static const ASN1_ITEM local_it = { #define static_ASN1_ITEM_start(itname) static ASN1_ITEM_start(itname) -#define ASN1_ITEM_end(itname) \ - } \ - ; \ - return &local_it; \ - } +#define ASN1_ITEM_end(itname) \ + } \ + ; \ + return &local_it; \ + } /* Macros to aid ASN1 template writing */ #define ASN1_ITEM_TEMPLATE(tname) static const ASN1_TEMPLATE tname##_item_tt -#define ASN1_ITEM_TEMPLATE_END(tname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_PRIMITIVE, -1, &tname##_item_tt, 0, NULL, 0, \ - #tname ASN1_ITEM_end(tname) -#define static_ASN1_ITEM_TEMPLATE_END(tname) \ - ; \ - static_ASN1_ITEM_start(tname) ASN1_ITYPE_PRIMITIVE, -1, &tname##_item_tt, 0, NULL, 0, \ - #tname ASN1_ITEM_end(tname) +#define ASN1_ITEM_TEMPLATE_END(tname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_PRIMITIVE, -1, &tname##_item_tt, 0, NULL, \ + 0, #tname ASN1_ITEM_end(tname) +#define static_ASN1_ITEM_TEMPLATE_END(tname) \ + ; \ + static_ASN1_ITEM_start(tname) ASN1_ITYPE_PRIMITIVE, -1, &tname##_item_tt, 0, \ + NULL, 0, #tname ASN1_ITEM_end(tname) /* This is a ASN1 type which just embeds a template */ @@ -141,79 +141,88 @@ extern "C" { #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) -#define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname) +#define static_ASN1_SEQUENCE_END(stname) \ + static_ASN1_SEQUENCE_END_name(stname, stname) -#define ASN1_SEQUENCE_END_name(stname, tname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(stname), \ - #tname ASN1_ITEM_end(tname) +#define ASN1_SEQUENCE_END_name(stname, tname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(stname), \ + #tname ASN1_ITEM_end(tname) -#define static_ASN1_SEQUENCE_END_name(stname, tname) \ - ; \ - static_ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(stname), \ - #stname ASN1_ITEM_end(tname) +#define static_ASN1_SEQUENCE_END_name(stname, tname) \ + ; \ + static_ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, \ + tname##_seq_tt, sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, \ + sizeof(stname), #stname ASN1_ITEM_end(tname) #define ASN1_NDEF_SEQUENCE(tname) ASN1_SEQUENCE(tname) #define ASN1_NDEF_SEQUENCE_cb(tname, cb) ASN1_SEQUENCE_cb(tname, cb) -#define ASN1_SEQUENCE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = { NULL, 0, 0, 0, cb, 0, NULL }; \ - ASN1_SEQUENCE(tname) +#define ASN1_SEQUENCE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \ + ASN1_SEQUENCE(tname) -#define ASN1_SEQUENCE_const_cb(tname, const_cb) \ - static const ASN1_AUX tname##_aux = { NULL, ASN1_AFLG_CONST_CB, 0, 0, NULL, 0, const_cb }; \ - ASN1_SEQUENCE(tname) +#define ASN1_SEQUENCE_const_cb(tname, const_cb) \ + static const ASN1_AUX tname##_aux \ + = {NULL, ASN1_AFLG_CONST_CB, 0, 0, NULL, 0, const_cb}; \ + ASN1_SEQUENCE(tname) -#define ASN1_SEQUENCE_cb_const_cb(tname, cb, const_cb) \ - static const ASN1_AUX tname##_aux = { NULL, ASN1_AFLG_CONST_CB, 0, 0, cb, 0, const_cb }; \ - ASN1_SEQUENCE(tname) +#define ASN1_SEQUENCE_cb_const_cb(tname, cb, const_cb) \ + static const ASN1_AUX tname##_aux \ + = {NULL, ASN1_AFLG_CONST_CB, 0, 0, cb, 0, const_cb}; \ + ASN1_SEQUENCE(tname) -#define ASN1_SEQUENCE_ref(tname, cb) \ - static const ASN1_AUX tname##_aux \ - = { NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0, \ - NULL }; \ - ASN1_SEQUENCE(tname) +#define ASN1_SEQUENCE_ref(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, \ + ASN1_AFLG_REFCOUNT, \ + offsetof(tname, references), \ + offsetof(tname, lock), \ + cb, \ + 0, \ + NULL}; \ + ASN1_SEQUENCE(tname) -#define ASN1_SEQUENCE_enc(tname, enc, cb) \ - static const ASN1_AUX tname##_aux \ - = { NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc), NULL }; \ - ASN1_SEQUENCE(tname) +#define ASN1_SEQUENCE_enc(tname, enc, cb) \ + static const ASN1_AUX tname##_aux \ + = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc), NULL}; \ + ASN1_SEQUENCE(tname) -#define ASN1_NDEF_SEQUENCE_END(tname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_NDEF_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(tname), \ - #tname ASN1_ITEM_end(tname) -#define static_ASN1_NDEF_SEQUENCE_END(tname) \ - ; \ - static_ASN1_ITEM_start(tname) ASN1_ITYPE_NDEF_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(tname), \ - #tname ASN1_ITEM_end(tname) +#define ASN1_NDEF_SEQUENCE_END(tname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_NDEF_SEQUENCE, V_ASN1_SEQUENCE, \ + tname##_seq_tt, sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, \ + sizeof(tname), #tname ASN1_ITEM_end(tname) +#define static_ASN1_NDEF_SEQUENCE_END(tname) \ + ; \ + static_ASN1_ITEM_start(tname) ASN1_ITYPE_NDEF_SEQUENCE, V_ASN1_SEQUENCE, \ + tname##_seq_tt, sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), NULL, \ + sizeof(tname), #tname ASN1_ITEM_end(tname) -#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) +#define ASN1_SEQUENCE_END_enc(stname, tname) \ + ASN1_SEQUENCE_END_ref(stname, tname) #define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) -#define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) +#define static_ASN1_SEQUENCE_END_cb(stname, tname) \ + static_ASN1_SEQUENCE_END_ref(stname, tname) -#define ASN1_SEQUENCE_END_ref(stname, tname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), &tname##_aux, sizeof(stname), \ - #tname ASN1_ITEM_end(tname) -#define static_ASN1_SEQUENCE_END_ref(stname, tname) \ - ; \ - static_ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), &tname##_aux, sizeof(stname), \ - #stname ASN1_ITEM_end(tname) +#define ASN1_SEQUENCE_END_ref(stname, tname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ + sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), &tname##_aux, \ + sizeof(stname), #tname ASN1_ITEM_end(tname) +#define static_ASN1_SEQUENCE_END_ref(stname, tname) \ + ; \ + static_ASN1_ITEM_start(tname) ASN1_ITYPE_SEQUENCE, V_ASN1_SEQUENCE, \ + tname##_seq_tt, sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \ + &tname##_aux, sizeof(stname), #stname ASN1_ITEM_end(tname) -#define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_NDEF_SEQUENCE, V_ASN1_SEQUENCE, tname##_seq_tt, \ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), &tname##_aux, sizeof(stname), \ - #stname ASN1_ITEM_end(tname) +#define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_NDEF_SEQUENCE, V_ASN1_SEQUENCE, \ + tname##_seq_tt, sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \ + &tname##_aux, sizeof(stname), #stname ASN1_ITEM_end(tname) /*- * This pair helps declare a CHOICE type. We can do: @@ -240,175 +249,186 @@ extern "C" { #define ASN1_CHOICE(tname) static const ASN1_TEMPLATE tname##_ch_tt[] -#define ASN1_CHOICE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = { NULL, 0, 0, 0, cb, 0, NULL }; \ - ASN1_CHOICE(tname) +#define ASN1_CHOICE_cb(tname, cb) \ + static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \ + ASN1_CHOICE(tname) #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) -#define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname) +#define static_ASN1_CHOICE_END(stname) \ + static_ASN1_CHOICE_END_name(stname, stname) -#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) +#define ASN1_CHOICE_END_name(stname, tname) \ + ASN1_CHOICE_END_selector(stname, tname, type) -#define static_ASN1_CHOICE_END_name(stname, tname) \ - static_ASN1_CHOICE_END_selector(stname, tname, type) +#define static_ASN1_CHOICE_END_name(stname, tname) \ + static_ASN1_CHOICE_END_selector(stname, tname, type) -#define ASN1_CHOICE_END_selector(stname, tname, selname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_CHOICE, offsetof(stname, selname), tname##_ch_tt, \ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(stname), \ - #stname ASN1_ITEM_end(tname) +#define ASN1_CHOICE_END_selector(stname, tname, selname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_CHOICE, offsetof(stname, selname), \ + tname##_ch_tt, sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), NULL, \ + sizeof(stname), #stname ASN1_ITEM_end(tname) -#define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ - ; \ - static_ASN1_ITEM_start(tname) ASN1_ITYPE_CHOICE, offsetof(stname, selname), tname##_ch_tt, \ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), NULL, sizeof(stname), \ - #stname ASN1_ITEM_end(tname) +#define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ + ; \ + static_ASN1_ITEM_start(tname) ASN1_ITYPE_CHOICE, offsetof(stname, selname), \ + tname##_ch_tt, sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), NULL, \ + sizeof(stname), #stname ASN1_ITEM_end(tname) -#define ASN1_CHOICE_END_cb(stname, tname, selname) \ - ; \ - ASN1_ITEM_start(tname) ASN1_ITYPE_CHOICE, offsetof(stname, selname), tname##_ch_tt, \ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), &tname##_aux, sizeof(stname), \ - #stname ASN1_ITEM_end(tname) +#define ASN1_CHOICE_END_cb(stname, tname, selname) \ + ; \ + ASN1_ITEM_start(tname) ASN1_ITYPE_CHOICE, offsetof(stname, selname), \ + tname##_ch_tt, sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), \ + &tname##_aux, sizeof(stname), #stname ASN1_ITEM_end(tname) /* This helps with the template wrapper form of ASN1_ITEM */ -#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) \ - { \ - (flags), (tag), 0, #name, ASN1_ITEM_ref(type) \ - } +#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) \ + { \ + (flags), (tag), 0, #name, ASN1_ITEM_ref(type) \ + } /* These help with SEQUENCE or CHOICE components */ /* used to declare other types */ -#define ASN1_EX_TYPE(flags, tag, stname, field, type) \ - { \ - (flags), (tag), offsetof(stname, field), #field, ASN1_ITEM_ref(type) \ - } +#define ASN1_EX_TYPE(flags, tag, stname, field, type) \ + { \ + (flags), (tag), offsetof(stname, field), #field, ASN1_ITEM_ref(type) \ + } /* implicit and explicit helper macros */ -#define ASN1_IMP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type) +#define ASN1_IMP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type) -#define ASN1_EXP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type) +#define ASN1_EXP_EX(stname, field, type, tag, ex) \ + ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type) /* Any defined by macros: the field used is in the table itself */ -#define ASN1_ADB_OBJECT(tblname) \ - { \ - ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb \ - } -#define ASN1_ADB_INTEGER(tblname) \ - { \ - ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb \ - } +#define ASN1_ADB_OBJECT(tblname) \ + { \ + ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb \ + } +#define ASN1_ADB_INTEGER(tblname) \ + { \ + ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb \ + } /* Plain simple type */ #define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0, 0, stname, field, type) /* Embedded simple type */ -#define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED, 0, stname, field, type) +#define ASN1_EMBED(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_EMBED, 0, stname, field, type) /* OPTIONAL simple type */ -#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) -#define ASN1_OPT_EMBED(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED, 0, stname, field, type) +#define ASN1_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) +#define ASN1_OPT_EMBED(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED, 0, stname, field, type) /* IMPLICIT tagged simple type */ -#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) -#define ASN1_IMP_EMBED(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) +#define ASN1_IMP(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, 0) +#define ASN1_IMP_EMBED(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) /* IMPLICIT tagged OPTIONAL simple type */ -#define ASN1_IMP_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) -#define ASN1_IMP_OPT_EMBED(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED) +#define ASN1_IMP_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) +#define ASN1_IMP_OPT_EMBED(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED) /* Same as above but EXPLICIT */ -#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) -#define ASN1_EXP_EMBED(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) -#define ASN1_EXP_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) -#define ASN1_EXP_OPT_EMBED(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED) +#define ASN1_EXP(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, 0) +#define ASN1_EXP_EMBED(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) +#define ASN1_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) +#define ASN1_EXP_OPT_EMBED(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED) /* SEQUENCE OF type */ -#define ASN1_SEQUENCE_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) +#define ASN1_SEQUENCE_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) /* OPTIONAL SEQUENCE OF */ -#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, 0, stname, field, type) +#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, 0, stname, field, \ + type) /* Same as above but for SET OF */ -#define ASN1_SET_OF(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) +#define ASN1_SET_OF(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) -#define ASN1_SET_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, 0, stname, field, type) +#define ASN1_SET_OF_OPT(stname, field, type) \ + ASN1_EX_TYPE(ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, 0, stname, field, type) /* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ -#define ASN1_IMP_SET_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) +#define ASN1_IMP_SET_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) -#define ASN1_EXP_SET_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) +#define ASN1_EXP_SET_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) -#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL) +#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL) -#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL) +#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL) -#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) +#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) -#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL) +#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_IMP_EX(stname, field, type, tag, \ + ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL) -#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) +#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) -#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL) +#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, \ + ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL) /* EXPLICIT using indefinite length constructed form */ -#define ASN1_NDEF_EXP(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) +#define ASN1_NDEF_EXP(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) /* EXPLICIT OPTIONAL using indefinite length constructed form */ -#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_NDEF) +#define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ + ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_NDEF) /* Macros for the ASN1_ADB structure */ #define ASN1_ADB(name) static const ASN1_ADB_TABLE name##_adbtbl[] -#define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ - ; \ - static const ASN1_ITEM *name##_adb(void) \ - { \ - static const ASN1_ADB internal_adb = { flags, \ - offsetof(name, field), \ - adb_cb, \ - name##_adbtbl, \ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE), \ - def, \ - none }; \ - return (const ASN1_ITEM *)&internal_adb; \ - } \ - void dummy_function(void) +#define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ + ; \ + static const ASN1_ITEM *name##_adb(void) \ + { \ + static const ASN1_ADB internal_adb \ + = {flags, \ + offsetof(name, field), \ + adb_cb, \ + name##_adbtbl, \ + sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE), \ + def, \ + none}; \ + return (const ASN1_ITEM *)&internal_adb; \ + } \ + void dummy_function(void) -#define ADB_ENTRY(val, template) \ - { \ - val, template \ - } +#define ADB_ENTRY(val, template) \ + { \ + val, template \ + } #define ASN1_ADB_TEMPLATE(name) static const ASN1_TEMPLATE name##_tt @@ -420,11 +440,11 @@ extern "C" { struct ASN1_TEMPLATE_st { - unsigned long flags; /* Various flags */ - long tag; /* tag, not used if no tagging */ - unsigned long offset; /* Offset of this field in structure */ - const char *field_name; /* Field name */ - ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ + unsigned long flags; /* Various flags */ + long tag; /* tag, not used if no tagging */ + unsigned long offset; /* Offset of this field in structure */ + const char *field_name; /* Field name */ + ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ }; /* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ @@ -437,19 +457,19 @@ typedef struct ASN1_ADB_st ASN1_ADB; struct ASN1_ADB_st { - unsigned long flags; /* Various flags */ - unsigned long offset; /* Offset of selector field */ - int (*adb_cb)(long *psel); /* Application callback */ - const ASN1_ADB_TABLE *tbl; /* Table of possible types */ - long tblcount; /* Number of entries in tbl */ - const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ - const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ + unsigned long flags; /* Various flags */ + unsigned long offset; /* Offset of selector field */ + int (*adb_cb)(long *psel); /* Application callback */ + const ASN1_ADB_TABLE *tbl; /* Table of possible types */ + long tblcount; /* Number of entries in tbl */ + const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ + const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ }; struct ASN1_ADB_TABLE_st { - long value; /* NID for an object or value for an int */ - const ASN1_TEMPLATE tt; /* item for this value */ + long value; /* NID for an object or value for an int */ + const ASN1_TEMPLATE tt; /* item for this value */ }; /* template flags */ @@ -535,16 +555,16 @@ struct ASN1_ADB_TABLE_st struct ASN1_ITEM_st { - char itype; /* The item type, primitive, SEQUENCE, CHOICE - * or extern */ - long utype; /* underlying type */ - const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains - * the contents */ - long tcount; /* Number of templates if SEQUENCE or CHOICE */ - const void *funcs; /* further data and type-specific functions */ - /* funcs can be ASN1_PRIMITIVE_FUNCS*, ASN1_EXTERN_FUNCS*, or ASN1_AUX* */ - long size; /* Structure size (usually) */ - const char *sname; /* Structure name */ + char itype; /* The item type, primitive, SEQUENCE, CHOICE + * or extern */ + long utype; /* underlying type */ + const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains + * the contents */ + long tcount; /* Number of templates if SEQUENCE or CHOICE */ + const void *funcs; /* further data and type-specific functions */ + /* funcs can be ASN1_PRIMITIVE_FUNCS*, ASN1_EXTERN_FUNCS*, or ASN1_AUX* */ + long size; /* Structure size (usually) */ + const char *sname; /* Structure name */ }; /* @@ -554,61 +574,65 @@ struct ASN1_ITEM_st struct ASN1_TLC_st { - char valid; /* Values below are valid */ - int ret; /* return value */ - long plen; /* length */ - int ptag; /* class value */ - int pclass; /* class value */ - int hdrlen; /* header length */ + char valid; /* Values below are valid */ + int ret; /* return value */ + long plen; /* length */ + int ptag; /* class value */ + int pclass; /* class value */ + int hdrlen; /* header length */ }; /* Typedefs for ASN1 function pointers */ -typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx); +typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, + ASN1_TLC *ctx); -typedef int ASN1_ex_d2i_ex(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx, - OSSL_LIB_CTX *libctx, const char *propq); -typedef int ASN1_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, - int aclass); +typedef int ASN1_ex_d2i_ex(ASN1_VALUE **pval, const unsigned char **in, + long len, const ASN1_ITEM *it, int tag, int aclass, + char opt, ASN1_TLC *ctx, OSSL_LIB_CTX *libctx, + const char *propq); +typedef int ASN1_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, + const ASN1_ITEM *it, int tag, int aclass); typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); -typedef int ASN1_ex_new_ex_func(ASN1_VALUE **pval, const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, - const char *propq); +typedef int ASN1_ex_new_ex_func(ASN1_VALUE **pval, const ASN1_ITEM *it, + OSSL_LIB_CTX *libctx, const char *propq); typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); -typedef int ASN1_ex_print_func(BIO *out, const ASN1_VALUE **pval, int indent, const char *fname, - const ASN1_PCTX *pctx); +typedef int ASN1_ex_print_func(BIO *out, const ASN1_VALUE **pval, int indent, + const char *fname, const ASN1_PCTX *pctx); -typedef int ASN1_primitive_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype, +typedef int ASN1_primitive_i2c(const ASN1_VALUE **pval, unsigned char *cont, + int *putype, const ASN1_ITEM *it); +typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, + int len, int utype, char *free_cont, const ASN1_ITEM *it); -typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, - char *free_cont, const ASN1_ITEM *it); -typedef int ASN1_primitive_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, +typedef int ASN1_primitive_print(BIO *out, const ASN1_VALUE **pval, + const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); typedef struct ASN1_EXTERN_FUNCS_st { - void *app_data; - ASN1_ex_new_func *asn1_ex_new; - ASN1_ex_free_func *asn1_ex_free; - ASN1_ex_free_func *asn1_ex_clear; - ASN1_ex_d2i *asn1_ex_d2i; - ASN1_ex_i2d *asn1_ex_i2d; - ASN1_ex_print_func *asn1_ex_print; - ASN1_ex_new_ex_func *asn1_ex_new_ex; - ASN1_ex_d2i_ex *asn1_ex_d2i_ex; + void *app_data; + ASN1_ex_new_func *asn1_ex_new; + ASN1_ex_free_func *asn1_ex_free; + ASN1_ex_free_func *asn1_ex_clear; + ASN1_ex_d2i *asn1_ex_d2i; + ASN1_ex_i2d *asn1_ex_i2d; + ASN1_ex_print_func *asn1_ex_print; + ASN1_ex_new_ex_func *asn1_ex_new_ex; + ASN1_ex_d2i_ex *asn1_ex_d2i_ex; } ASN1_EXTERN_FUNCS; typedef struct ASN1_PRIMITIVE_FUNCS_st { - void *app_data; - unsigned long flags; - ASN1_ex_new_func *prim_new; - ASN1_ex_free_func *prim_free; - ASN1_ex_free_func *prim_clear; - ASN1_primitive_c2i *prim_c2i; - ASN1_primitive_i2c *prim_i2c; - ASN1_primitive_print *prim_print; + void *app_data; + unsigned long flags; + ASN1_ex_new_func *prim_new; + ASN1_ex_free_func *prim_free; + ASN1_ex_free_func *prim_clear; + ASN1_primitive_c2i *prim_c2i; + ASN1_primitive_i2c *prim_i2c; + ASN1_primitive_print *prim_print; } ASN1_PRIMITIVE_FUNCS; /* @@ -628,38 +652,39 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st * and only if this variant is in use the flag ASN1_AFLG_CONST_CB must be set. */ -typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, void *exarg); -typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in, const ASN1_ITEM *it, - void *exarg); +typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, + void *exarg); +typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in, + const ASN1_ITEM *it, void *exarg); typedef struct ASN1_AUX_st { - void *app_data; - int flags; - int ref_offset; /* Offset of reference value */ - int ref_lock; /* Offset of lock value */ - ASN1_aux_cb *asn1_cb; - int enc_offset; /* Offset of ASN1_ENCODING structure */ - ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */ + void *app_data; + int flags; + int ref_offset; /* Offset of reference value */ + int ref_lock; /* Offset of lock value */ + ASN1_aux_cb *asn1_cb; + int enc_offset; /* Offset of ASN1_ENCODING structure */ + ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */ } ASN1_AUX; /* For print related callbacks exarg points to this structure */ typedef struct ASN1_PRINT_ARG_st { - BIO *out; - int indent; - const ASN1_PCTX *pctx; + BIO *out; + int indent; + const ASN1_PCTX *pctx; } ASN1_PRINT_ARG; /* For streaming related callbacks exarg points to this structure */ typedef struct ASN1_STREAM_ARG_st { - /* BIO to stream through */ - BIO *out; - /* BIO with filters appended */ - BIO *ndef_bio; - /* Streaming I/O boundary */ - unsigned char **boundary; + /* BIO to stream through */ + BIO *out; + /* BIO with filters appended */ + BIO *ndef_bio; + /* Streaming I/O boundary */ + unsigned char **boundary; } ASN1_STREAM_ARG; /* Flags in ASN1_AUX */ @@ -696,98 +721,105 @@ typedef struct ASN1_STREAM_ARG_st /* Macro to implement a primitive type */ #define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) -#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ - ASN1_ITEM_start(itname) ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, \ - #itname ASN1_ITEM_end(itname) +#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ + ASN1_ITEM_start(itname) ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, \ + #itname ASN1_ITEM_end(itname) /* Macro to implement a multi string type */ -#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ - ASN1_ITEM_start(itname) ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), \ - #itname ASN1_ITEM_end(itname) +#define IMPLEMENT_ASN1_MSTRING(itname, mask) \ + ASN1_ITEM_start(itname) ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, \ + sizeof(ASN1_STRING), #itname ASN1_ITEM_end(itname) -#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ - ASN1_ITEM_start(sname) ASN1_ITYPE_EXTERN, tag, NULL, 0, &fptrs, 0, #sname ASN1_ITEM_end(sname) +#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ + ASN1_ITEM_start(sname) ASN1_ITYPE_EXTERN, tag, NULL, 0, &fptrs, 0, \ + #sname ASN1_ITEM_end(sname) /* Macro to implement standard functions in terms of ASN1_ITEM structures */ -#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) +#define IMPLEMENT_ASN1_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) -#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) \ - IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) +#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) -#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ - IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) +#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ + IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) -#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) +#define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ - pre stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - pre void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ + pre stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + pre void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } -#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ - stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } +#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ + stname *fname##_new(void) \ + { \ + return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ + } \ + void fname##_free(stname *a) \ + { \ + ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ + } -#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) +#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) -#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname)); \ - } \ - int i2d_##fname(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname)); \ - } +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ + stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \ + ASN1_ITEM_rptr(itname)); \ + } \ + int i2d_##fname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname)); \ + } -#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ - int i2d_##stname##_NDEF(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_ndef_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname)); \ - } +#define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ + int i2d_##stname##_NDEF(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_ndef_i2d((const ASN1_VALUE *)a, out, \ + ASN1_ITEM_rptr(stname)); \ + } -#define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \ - static stname *d2i_##stname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(stname)); \ - } \ - static int i2d_##stname(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname)); \ - } +#define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \ + static stname *d2i_##stname(stname **a, const unsigned char **in, long len) \ + { \ + return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \ + ASN1_ITEM_rptr(stname)); \ + } \ + static int i2d_##stname(const stname *a, unsigned char **out) \ + { \ + return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname)); \ + } -#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ - stname *stname##_dup(const stname *x) \ - { \ - return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ - } +#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ + stname *stname##_dup(const stname *x) \ + { \ + return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ + } -#define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ - IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) +#define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ + IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) -#define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ - int fname##_print_ctx(BIO *out, const stname *x, int indent, const ASN1_PCTX *pctx) \ - { \ - return ASN1_item_print(out, (const ASN1_VALUE *)x, indent, ASN1_ITEM_rptr(itname), pctx); \ - } +#define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ + int fname##_print_ctx(BIO *out, const stname *x, int indent, \ + const ASN1_PCTX *pctx) \ + { \ + return ASN1_item_print(out, (const ASN1_VALUE *)x, indent, \ + ASN1_ITEM_rptr(itname), pctx); \ + } /* external definitions for primitive types */ @@ -817,69 +849,90 @@ DECLARE_ASN1_ITEM(ZLONG) #endif SKM_DEFINE_STACK_OF_INTERNAL(ASN1_VALUE, ASN1_VALUE, ASN1_VALUE) -#define sk_ASN1_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_VALUE_sk_type(sk)) -#define sk_ASN1_VALUE_value(sk, idx) \ - ((ASN1_VALUE *)OPENSSL_sk_value(ossl_check_const_ASN1_VALUE_sk_type(sk), (idx))) -#define sk_ASN1_VALUE_new(cmp) \ - ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new(ossl_check_ASN1_VALUE_compfunc_type(cmp))) +#define sk_ASN1_VALUE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_value(sk, idx) \ + ((ASN1_VALUE *)OPENSSL_sk_value(ossl_check_const_ASN1_VALUE_sk_type(sk), \ + (idx))) +#define sk_ASN1_VALUE_new(cmp) \ + ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new( \ + ossl_check_ASN1_VALUE_compfunc_type(cmp))) #define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_null()) -#define sk_ASN1_VALUE_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_VALUE_compfunc_type(cmp), (n))) -#define sk_ASN1_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_VALUE_sk_type(sk), (n)) -#define sk_ASN1_VALUE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_VALUE_sk_type(sk)) -#define sk_ASN1_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_VALUE_sk_type(sk)) -#define sk_ASN1_VALUE_delete(sk, i) \ - ((ASN1_VALUE *)OPENSSL_sk_delete(ossl_check_ASN1_VALUE_sk_type(sk), (i))) -#define sk_ASN1_VALUE_delete_ptr(sk, ptr) \ - ((ASN1_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_VALUE_sk_type(sk), \ - ossl_check_ASN1_VALUE_type(ptr))) -#define sk_ASN1_VALUE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) -#define sk_ASN1_VALUE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) -#define sk_ASN1_VALUE_pop(sk) ((ASN1_VALUE *)OPENSSL_sk_pop(ossl_check_ASN1_VALUE_sk_type(sk))) -#define sk_ASN1_VALUE_shift(sk) ((ASN1_VALUE *)OPENSSL_sk_shift(ossl_check_ASN1_VALUE_sk_type(sk))) -#define sk_ASN1_VALUE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_VALUE_sk_type(sk), \ - ossl_check_ASN1_VALUE_freefunc_type(freefunc)) -#define sk_ASN1_VALUE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), (idx)) -#define sk_ASN1_VALUE_set(sk, idx, ptr) \ - ((ASN1_VALUE *)OPENSSL_sk_set(ossl_check_ASN1_VALUE_sk_type(sk), (idx), \ - ossl_check_ASN1_VALUE_type(ptr))) -#define sk_ASN1_VALUE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) -#define sk_ASN1_VALUE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)) -#define sk_ASN1_VALUE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), pnum) -#define sk_ASN1_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_VALUE_sk_type(sk)) -#define sk_ASN1_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_VALUE_sk_type(sk)) -#define sk_ASN1_VALUE_dup(sk) \ - ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_VALUE_sk_type(sk))) -#define sk_ASN1_VALUE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_VALUE_sk_type(sk), \ - ossl_check_ASN1_VALUE_copyfunc_type(copyfunc), \ - ossl_check_ASN1_VALUE_freefunc_type(freefunc))) -#define sk_ASN1_VALUE_set_cmp_func(sk, cmp) \ - ((sk_ASN1_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_VALUE_sk_type(sk), \ - ossl_check_ASN1_VALUE_compfunc_type(cmp))) +#define sk_ASN1_VALUE_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_VALUE_compfunc_type(cmp), (n))) +#define sk_ASN1_VALUE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_VALUE_sk_type(sk), (n)) +#define sk_ASN1_VALUE_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_delete(sk, i) \ + ((ASN1_VALUE *)OPENSSL_sk_delete(ossl_check_ASN1_VALUE_sk_type(sk), (i))) +#define sk_ASN1_VALUE_delete_ptr(sk, ptr) \ + ((ASN1_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr))) +#define sk_ASN1_VALUE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_pop(sk) \ + ((ASN1_VALUE *)OPENSSL_sk_pop(ossl_check_ASN1_VALUE_sk_type(sk))) +#define sk_ASN1_VALUE_shift(sk) \ + ((ASN1_VALUE *)OPENSSL_sk_shift(ossl_check_ASN1_VALUE_sk_type(sk))) +#define sk_ASN1_VALUE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_freefunc_type(freefunc)) +#define sk_ASN1_VALUE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr), (idx)) +#define sk_ASN1_VALUE_set(sk, idx, ptr) \ + ((ASN1_VALUE *)OPENSSL_sk_set(ossl_check_ASN1_VALUE_sk_type(sk), (idx), \ + ossl_check_ASN1_VALUE_type(ptr))) +#define sk_ASN1_VALUE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr)) +#define sk_ASN1_VALUE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_type(ptr), pnum) +#define sk_ASN1_VALUE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_VALUE_sk_type(sk)) +#define sk_ASN1_VALUE_dup(sk) \ + ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_VALUE_sk_type(sk))) +#define sk_ASN1_VALUE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_copyfunc_type(copyfunc), \ + ossl_check_ASN1_VALUE_freefunc_type(freefunc))) +#define sk_ASN1_VALUE_set_cmp_func(sk, cmp) \ + ((sk_ASN1_VALUE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_VALUE_sk_type(sk), \ + ossl_check_ASN1_VALUE_compfunc_type(cmp))) /* Functions used internally by the ASN1 code */ int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx); +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, + ASN1_TLC *ctx); -int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, - int aclass); +int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out, + const ASN1_ITEM *it, int tag, int aclass); /* Legacy compatibility */ #define IMPLEMENT_ASN1_FUNCTIONS_const(name) IMPLEMENT_ASN1_FUNCTIONS(name) -#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) +#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ + IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/async.h b/libs/OpenSSL/include/openssl/async.h index b15e67d7..738c9d90 100644 --- a/libs/OpenSSL/include/openssl/async.h +++ b/libs/OpenSSL/include/openssl/async.h @@ -10,78 +10,83 @@ #include #ifndef OPENSSL_ASYNC_H -# define OPENSSL_ASYNC_H -# pragma once +# define OPENSSL_ASYNC_H +# pragma once -# include -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_ASYNC_H -# endif +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define HEADER_ASYNC_H +# endif -# if defined(_WIN32) -# if defined(BASETYPES) || defined(_WINDEF_H) +# if defined(_WIN32) +# if defined(BASETYPES) || defined(_WINDEF_H) /* application has to include to use this */ -# define OSSL_ASYNC_FD HANDLE -# define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE -# endif -# else -# define OSSL_ASYNC_FD int -# define OSSL_BAD_ASYNC_FD -1 +# define OSSL_ASYNC_FD HANDLE +# define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE # endif -# include +# else +# define OSSL_ASYNC_FD int +# define OSSL_BAD_ASYNC_FD -1 +# endif +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif typedef struct async_job_st ASYNC_JOB; typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; typedef int (*ASYNC_callback_fn)(void *arg); -# define ASYNC_ERR 0 -# define ASYNC_NO_JOBS 1 -# define ASYNC_PAUSE 2 -# define ASYNC_FINISH 3 +# define ASYNC_ERR 0 +# define ASYNC_NO_JOBS 1 +# define ASYNC_PAUSE 2 +# define ASYNC_FINISH 3 -# define ASYNC_STATUS_UNSUPPORTED 0 -# define ASYNC_STATUS_ERR 1 -# define ASYNC_STATUS_OK 2 -# define ASYNC_STATUS_EAGAIN 3 +# define ASYNC_STATUS_UNSUPPORTED 0 +# define ASYNC_STATUS_ERR 1 +# define ASYNC_STATUS_OK 2 +# define ASYNC_STATUS_EAGAIN 3 int ASYNC_init_thread(size_t max_size, size_t init_size); void ASYNC_cleanup_thread(void); -# ifdef OSSL_ASYNC_FD +# ifdef OSSL_ASYNC_FD ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); -int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, OSSL_ASYNC_FD fd, - void *custom_data, - void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, - void *)); -int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, OSSL_ASYNC_FD *fd, - void **custom_data); -int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, size_t *numfds); -int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx, ASYNC_callback_fn *callback, +int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, + OSSL_ASYNC_FD fd, void *custom_data, + void (*cleanup)(ASYNC_WAIT_CTX *, const void *, + OSSL_ASYNC_FD, void *)); +int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, + OSSL_ASYNC_FD *fd, void **custom_data); +int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, + size_t *numfds); +int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx, + ASYNC_callback_fn *callback, void **callback_arg); int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx, ASYNC_callback_fn callback, void *callback_arg); int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status); int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx); -int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, size_t *numaddfds, - OSSL_ASYNC_FD *delfd, size_t *numdelfds); +int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, + size_t *numaddfds, OSSL_ASYNC_FD *delfd, + size_t *numdelfds); int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); -# endif +# endif int ASYNC_is_capable(void); typedef void *(*ASYNC_stack_alloc_fn)(size_t *num); typedef void (*ASYNC_stack_free_fn)(void *addr); -int ASYNC_set_mem_functions(ASYNC_stack_alloc_fn alloc_fn, ASYNC_stack_free_fn free_fn); -void ASYNC_get_mem_functions(ASYNC_stack_alloc_fn *alloc_fn, ASYNC_stack_free_fn *free_fn); +int ASYNC_set_mem_functions(ASYNC_stack_alloc_fn alloc_fn, + ASYNC_stack_free_fn free_fn); +void ASYNC_get_mem_functions(ASYNC_stack_alloc_fn *alloc_fn, + ASYNC_stack_free_fn *free_fn); -int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, int (*func)(void *), void *args, - size_t size); +int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, + int (*func)(void *), void *args, size_t size); int ASYNC_pause_job(void); ASYNC_JOB *ASYNC_get_current_job(void); @@ -89,7 +94,7 @@ ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); void ASYNC_block_pause(void); void ASYNC_unblock_pause(void); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif diff --git a/libs/OpenSSL/include/openssl/bio.h b/libs/OpenSSL/include/openssl/bio.h index 0f4bc703..cf01a592 100644 --- a/libs/OpenSSL/include/openssl/bio.h +++ b/libs/OpenSSL/include/openssl/bio.h @@ -16,13 +16,13 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_BIO_H +# define HEADER_BIO_H #endif #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include @@ -63,7 +63,7 @@ extern "C" { #define BIO_TYPE_ASN1 (22 | BIO_TYPE_FILTER) #define BIO_TYPE_COMP (23 | BIO_TYPE_FILTER) #ifndef OPENSSL_NO_SCTP -# define BIO_TYPE_DGRAM_SCTP (24 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) +# define BIO_TYPE_DGRAM_SCTP (24 | BIO_TYPE_SOURCE_SINK | BIO_TYPE_DESCRIPTOR) #endif #define BIO_TYPE_CORE_TO_PROV (25 | BIO_TYPE_SOURCE_SINK) #define BIO_TYPE_DGRAM_PAIR (26 | BIO_TYPE_SOURCE_SINK) @@ -80,30 +80,30 @@ extern "C" { /* * These are used in the following macros and are passed to BIO_ctrl() */ -#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ -#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ -#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ -#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ -#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ -#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ -#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ -#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ -#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ -#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ -#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ -#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ -#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ +#define BIO_CTRL_RESET 1 /* opt - rewind/zero etc */ +#define BIO_CTRL_EOF 2 /* opt - are we at the eof */ +#define BIO_CTRL_INFO 3 /* opt - extra tit-bits */ +#define BIO_CTRL_SET 4 /* man - set the 'IO' type */ +#define BIO_CTRL_GET 5 /* man - get the 'IO' type */ +#define BIO_CTRL_PUSH 6 /* opt - internal, used to signify change */ +#define BIO_CTRL_POP 7 /* opt - internal, used to signify change */ +#define BIO_CTRL_GET_CLOSE 8 /* man - set the 'close' on free */ +#define BIO_CTRL_SET_CLOSE 9 /* man - set the 'close' on free */ +#define BIO_CTRL_PENDING 10 /* opt - is their more data buffered */ +#define BIO_CTRL_FLUSH 11 /* opt - 'flush' buffered output */ +#define BIO_CTRL_DUP 12 /* man - extra stuff for 'duped' BIO */ +#define BIO_CTRL_WPENDING 13 /* opt - number of bytes still to write */ #define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback function */ #define BIO_CTRL_GET_CALLBACK 15 /* opt - set callback function */ -#define BIO_CTRL_PEEK 29 /* BIO_f_buffer special */ +#define BIO_CTRL_PEEK 29 /* BIO_f_buffer special */ #define BIO_CTRL_SET_FILENAME 30 /* BIO_s_file special */ /* dgram BIO stuff */ #define BIO_CTRL_DGRAM_CONNECT 31 /* BIO dgram special */ -#define BIO_CTRL_DGRAM_SET_CONNECTED \ - 32 /* allow for an externally connected \ - * socket to be passed in */ +#define BIO_CTRL_DGRAM_SET_CONNECTED \ + 32 /* allow for an externally connected \ + * socket to be passed in */ #define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */ #define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */ #define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */ @@ -119,22 +119,22 @@ extern "C" { #define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */ #define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 #define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */ -#define BIO_CTRL_DGRAM_SET_MTU \ - 42 /* set cached value for MTU. \ - * want to use this if asking \ - * the kernel fails */ +#define BIO_CTRL_DGRAM_SET_MTU \ + 42 /* set cached value for MTU. \ + * want to use this if asking \ + * the kernel fails */ -#define BIO_CTRL_DGRAM_MTU_EXCEEDED \ - 43 /* check whether the MTU was \ - * exceed in the previous write \ - * operation */ +#define BIO_CTRL_DGRAM_MTU_EXCEEDED \ + 43 /* check whether the MTU was \ + * exceed in the previous write \ + * operation */ #define BIO_CTRL_DGRAM_GET_PEER 46 #define BIO_CTRL_DGRAM_SET_PEER 44 /* Destination for the data */ -#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT \ - 45 /* Next DTLS handshake timeout \ - * to adjust socket timeouts */ +#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT \ + 45 /* Next DTLS handshake timeout \ + * to adjust socket timeouts */ #define BIO_CTRL_DGRAM_SET_DONT_FRAG 48 #define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 @@ -143,16 +143,16 @@ extern "C" { #define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 #ifndef OPENSSL_NO_SCTP /* SCTP stuff */ -# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 -# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 -# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 -# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 -# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 -# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 -# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 -# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 -# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 -# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 +# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 +# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 +# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 +# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 +# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 +# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 +# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 +# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 +# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 +# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 #endif #define BIO_CTRL_DGRAM_SET_PEEK_MODE 71 @@ -196,11 +196,13 @@ extern "C" { #define BIO_DGRAM_CAP_PROVIDES_DST_ADDR (1U << 3) #ifndef OPENSSL_NO_KTLS -# define BIO_get_ktls_send(b) (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0) -# define BIO_get_ktls_recv(b) (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0) +# define BIO_get_ktls_send(b) \ + (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0) +# define BIO_get_ktls_recv(b) \ + (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0) #else -# define BIO_get_ktls_send(b) (0) -# define BIO_get_ktls_recv(b) (0) +# define BIO_get_ktls_send(b) (0) +# define BIO_get_ktls_recv(b) (0) #endif /* modifiers */ @@ -216,15 +218,15 @@ extern "C" { #define BIO_FLAGS_SHOULD_RETRY 0x08 #ifndef OPENSSL_NO_DEPRECATED_3_0 /* This #define was replaced by an internal constant and should not be used. */ -# define BIO_FLAGS_UPLINK 0 +# define BIO_FLAGS_UPLINK 0 #endif #define BIO_FLAGS_BASE64_NO_NL 0x100 /* * This is used with memory BIOs: - * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way; - * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset. + * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any + * way; BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset. */ #define BIO_FLAGS_MEM_RDONLY 0x200 #define BIO_FLAGS_NONCLEAR_RST 0x400 @@ -241,13 +243,18 @@ int BIO_test_flags(const BIO *b, int flags); void BIO_clear_flags(BIO *b, int flags); #define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) -#define BIO_set_retry_special(b) BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY)) -#define BIO_set_retry_read(b) BIO_set_flags(b, (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY)) -#define BIO_set_retry_write(b) BIO_set_flags(b, (BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_special(b) \ + BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_read(b) \ + BIO_set_flags(b, (BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY)) +#define BIO_set_retry_write(b) \ + BIO_set_flags(b, (BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY)) /* These are normally used internally in BIOs */ -#define BIO_clear_retry_flags(b) BIO_clear_flags(b, (BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY)) -#define BIO_get_retry_flags(b) BIO_test_flags(b, (BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY)) +#define BIO_clear_retry_flags(b) \ + BIO_clear_flags(b, (BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY)) +#define BIO_get_retry_flags(b) \ + BIO_test_flags(b, (BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY)) /* These should be used by the application to tell why we should retry */ #define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) @@ -288,23 +295,26 @@ void BIO_clear_flags(BIO *b, int flags); */ #define BIO_CB_RETURN 0x80 #define BIO_CB_return(a) ((a) | BIO_CB_RETURN) -#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) -#define BIO_cb_post(a) ((a)&BIO_CB_RETURN) +#define BIO_cb_pre(a) (!((a) & BIO_CB_RETURN)) +#define BIO_cb_post(a) ((a) & BIO_CB_RETURN) #ifndef OPENSSL_NO_DEPRECATED_3_0 -typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi, long argl, long ret); +typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi, + long argl, long ret); OSSL_DEPRECATEDIN_3_0 BIO_callback_fn BIO_get_callback(const BIO *b); OSSL_DEPRECATEDIN_3_0 void BIO_set_callback(BIO *b, BIO_callback_fn callback); -OSSL_DEPRECATEDIN_3_0 long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, +OSSL_DEPRECATEDIN_3_0 long BIO_debug_callback(BIO *bio, int cmd, + const char *argp, int argi, long argl, long ret); #endif -typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp, size_t len, int argi, - long argl, int ret, size_t *processed); +typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp, + size_t len, int argi, long argl, int ret, + size_t *processed); BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b); void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback); -long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len, int argi, long argl, - int ret, size_t *processed); +long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len, + int argi, long argl, int ret, size_t *processed); char *BIO_get_callback_arg(const BIO *b); void BIO_set_callback_arg(BIO *b, char *arg); @@ -319,91 +329,106 @@ typedef BIO_info_cb bio_info_cb; /* backward compatibility */ SKM_DEFINE_STACK_OF_INTERNAL(BIO, BIO, BIO) #define sk_BIO_num(sk) OPENSSL_sk_num(ossl_check_const_BIO_sk_type(sk)) -#define sk_BIO_value(sk, idx) ((BIO *)OPENSSL_sk_value(ossl_check_const_BIO_sk_type(sk), (idx))) -#define sk_BIO_new(cmp) ((STACK_OF(BIO) *)OPENSSL_sk_new(ossl_check_BIO_compfunc_type(cmp))) +#define sk_BIO_value(sk, idx) \ + ((BIO *)OPENSSL_sk_value(ossl_check_const_BIO_sk_type(sk), (idx))) +#define sk_BIO_new(cmp) \ + ((STACK_OF(BIO) *)OPENSSL_sk_new(ossl_check_BIO_compfunc_type(cmp))) #define sk_BIO_new_null() ((STACK_OF(BIO) *)OPENSSL_sk_new_null()) -#define sk_BIO_new_reserve(cmp, n) \ - ((STACK_OF(BIO) *)OPENSSL_sk_new_reserve(ossl_check_BIO_compfunc_type(cmp), (n))) -#define sk_BIO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_BIO_sk_type(sk), (n)) +#define sk_BIO_new_reserve(cmp, n) \ + ((STACK_OF(BIO) *)OPENSSL_sk_new_reserve(ossl_check_BIO_compfunc_type(cmp), \ + (n))) +#define sk_BIO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_BIO_sk_type(sk), (n)) #define sk_BIO_free(sk) OPENSSL_sk_free(ossl_check_BIO_sk_type(sk)) #define sk_BIO_zero(sk) OPENSSL_sk_zero(ossl_check_BIO_sk_type(sk)) -#define sk_BIO_delete(sk, i) ((BIO *)OPENSSL_sk_delete(ossl_check_BIO_sk_type(sk), (i))) -#define sk_BIO_delete_ptr(sk, ptr) \ - ((BIO *)OPENSSL_sk_delete_ptr(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))) -#define sk_BIO_push(sk, ptr) OPENSSL_sk_push(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) -#define sk_BIO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_delete(sk, i) \ + ((BIO *)OPENSSL_sk_delete(ossl_check_BIO_sk_type(sk), (i))) +#define sk_BIO_delete_ptr(sk, ptr) \ + ((BIO *)OPENSSL_sk_delete_ptr(ossl_check_BIO_sk_type(sk), \ + ossl_check_BIO_type(ptr))) +#define sk_BIO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) #define sk_BIO_pop(sk) ((BIO *)OPENSSL_sk_pop(ossl_check_BIO_sk_type(sk))) #define sk_BIO_shift(sk) ((BIO *)OPENSSL_sk_shift(ossl_check_BIO_sk_type(sk))) -#define sk_BIO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_BIO_sk_type(sk), ossl_check_BIO_freefunc_type(freefunc)) -#define sk_BIO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), (idx)) -#define sk_BIO_set(sk, idx, ptr) \ - ((BIO *)OPENSSL_sk_set(ossl_check_BIO_sk_type(sk), (idx), ossl_check_BIO_type(ptr))) -#define sk_BIO_find(sk, ptr) OPENSSL_sk_find(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) -#define sk_BIO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) -#define sk_BIO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), pnum) +#define sk_BIO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_BIO_sk_type(sk), \ + ossl_check_BIO_freefunc_type(freefunc)) +#define sk_BIO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), (idx)) +#define sk_BIO_set(sk, idx, ptr) \ + ((BIO *)OPENSSL_sk_set(ossl_check_BIO_sk_type(sk), (idx), \ + ossl_check_BIO_type(ptr))) +#define sk_BIO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)) +#define sk_BIO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), \ + pnum) #define sk_BIO_sort(sk) OPENSSL_sk_sort(ossl_check_BIO_sk_type(sk)) -#define sk_BIO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_BIO_sk_type(sk)) -#define sk_BIO_dup(sk) ((STACK_OF(BIO) *)OPENSSL_sk_dup(ossl_check_const_BIO_sk_type(sk))) -#define sk_BIO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(BIO) *)OPENSSL_sk_deep_copy(ossl_check_const_BIO_sk_type(sk), \ - ossl_check_BIO_copyfunc_type(copyfunc), \ - ossl_check_BIO_freefunc_type(freefunc))) -#define sk_BIO_set_cmp_func(sk, cmp) \ - ((sk_BIO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_BIO_sk_type(sk), \ - ossl_check_BIO_compfunc_type(cmp))) +#define sk_BIO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_BIO_sk_type(sk)) +#define sk_BIO_dup(sk) \ + ((STACK_OF(BIO) *)OPENSSL_sk_dup(ossl_check_const_BIO_sk_type(sk))) +#define sk_BIO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(BIO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_BIO_sk_type(sk), \ + ossl_check_BIO_copyfunc_type(copyfunc), \ + ossl_check_BIO_freefunc_type(freefunc))) +#define sk_BIO_set_cmp_func(sk, cmp) \ + ((sk_BIO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_BIO_sk_type(sk), ossl_check_BIO_compfunc_type(cmp))) /* Prefix and suffix callback in ASN1 BIO */ typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg); -typedef void (*BIO_dgram_sctp_notification_handler_fn)(BIO *b, void *context, void *buf); +typedef void (*BIO_dgram_sctp_notification_handler_fn)(BIO *b, void *context, + void *buf); #ifndef OPENSSL_NO_SCTP /* SCTP parameter structs */ struct bio_dgram_sctp_sndinfo { - uint16_t snd_sid; - uint16_t snd_flags; - uint32_t snd_ppid; - uint32_t snd_context; + uint16_t snd_sid; + uint16_t snd_flags; + uint32_t snd_ppid; + uint32_t snd_context; }; struct bio_dgram_sctp_rcvinfo { - uint16_t rcv_sid; - uint16_t rcv_ssn; - uint16_t rcv_flags; - uint32_t rcv_ppid; - uint32_t rcv_tsn; - uint32_t rcv_cumtsn; - uint32_t rcv_context; + uint16_t rcv_sid; + uint16_t rcv_ssn; + uint16_t rcv_flags; + uint32_t rcv_ppid; + uint32_t rcv_tsn; + uint32_t rcv_cumtsn; + uint32_t rcv_context; }; struct bio_dgram_sctp_prinfo { - uint16_t pr_policy; - uint32_t pr_value; + uint16_t pr_policy; + uint32_t pr_value; }; #endif /* BIO_sendmmsg/BIO_recvmmsg-related definitions */ typedef struct bio_msg_st { - void *data; - size_t data_len; - BIO_ADDR *peer, *local; - uint64_t flags; + void *data; + size_t data_len; + BIO_ADDR *peer, *local; + uint64_t flags; } BIO_MSG; typedef struct bio_mmsg_cb_args_st { - BIO_MSG *msg; - size_t stride, num_msg; - uint64_t flags; - size_t *msgs_processed; + BIO_MSG *msg; + size_t stride, num_msg; + uint64_t flags; + size_t *msgs_processed; } BIO_MMSG_CB_ARGS; /* @@ -440,9 +465,9 @@ typedef struct bio_mmsg_cb_args_st #define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 #define BIO_C_FILE_SEEK 128 #define BIO_C_GET_CIPHER_CTX 129 -#define BIO_C_SET_BUF_MEM_EOF_RETURN \ - 130 /* return end of input \ - * value */ +#define BIO_C_SET_BUF_MEM_EOF_RETURN \ + 130 /* return end of input \ + * value */ #define BIO_C_SET_BIND_MODE 131 #define BIO_C_GET_BIND_MODE 132 #define BIO_C_FILE_TELL 133 @@ -484,42 +509,58 @@ typedef struct bio_mmsg_cb_args_st #ifndef OPENSSL_NO_SOCK /* IP families we support, for BIO_s_connect() and BIO_s_accept() */ /* Note: the underlying operating system may not support some of them */ -# define BIO_FAMILY_IPV4 4 -# define BIO_FAMILY_IPV6 6 -# define BIO_FAMILY_IPANY 256 +# define BIO_FAMILY_IPV4 4 +# define BIO_FAMILY_IPV6 6 +# define BIO_FAMILY_IPANY 256 /* BIO_s_connect() */ -# define BIO_set_conn_hostname(b, name) BIO_ctrl(b, BIO_C_SET_CONNECT, 0, (char *)(name)) -# define BIO_set_conn_port(b, port) BIO_ctrl(b, BIO_C_SET_CONNECT, 1, (char *)(port)) -# define BIO_set_conn_address(b, addr) BIO_ctrl(b, BIO_C_SET_CONNECT, 2, (char *)(addr)) -# define BIO_set_conn_ip_family(b, f) BIO_int_ctrl(b, BIO_C_SET_CONNECT, 3, f) -# define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_CONNECT, 0)) -# define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_CONNECT, 1)) -# define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b, BIO_C_GET_CONNECT, 2)) -# define BIO_get_conn_ip_family(b) BIO_ctrl(b, BIO_C_GET_CONNECT, 3, NULL) -# define BIO_get_conn_mode(b) BIO_ctrl(b, BIO_C_GET_CONNECT, 4, NULL) -# define BIO_set_conn_mode(b, n) BIO_ctrl(b, BIO_C_SET_CONNECT_MODE, (n), NULL) +# define BIO_set_conn_hostname(b, name) \ + BIO_ctrl(b, BIO_C_SET_CONNECT, 0, (char *)(name)) +# define BIO_set_conn_port(b, port) \ + BIO_ctrl(b, BIO_C_SET_CONNECT, 1, (char *)(port)) +# define BIO_set_conn_address(b, addr) \ + BIO_ctrl(b, BIO_C_SET_CONNECT, 2, (char *)(addr)) +# define BIO_set_conn_ip_family(b, f) BIO_int_ctrl(b, BIO_C_SET_CONNECT, 3, f) +# define BIO_get_conn_hostname(b) \ + ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_CONNECT, 0)) +# define BIO_get_conn_port(b) \ + ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_CONNECT, 1)) +# define BIO_get_conn_address(b) \ + ((const BIO_ADDR *)BIO_ptr_ctrl(b, BIO_C_GET_CONNECT, 2)) +# define BIO_get_conn_ip_family(b) BIO_ctrl(b, BIO_C_GET_CONNECT, 3, NULL) +# define BIO_get_conn_mode(b) BIO_ctrl(b, BIO_C_GET_CONNECT, 4, NULL) +# define BIO_set_conn_mode(b, n) BIO_ctrl(b, BIO_C_SET_CONNECT_MODE, (n), NULL) /* BIO_s_accept() */ -# define BIO_set_accept_name(b, name) BIO_ctrl(b, BIO_C_SET_ACCEPT, 0, (char *)(name)) -# define BIO_set_accept_port(b, port) BIO_ctrl(b, BIO_C_SET_ACCEPT, 1, (char *)(port)) -# define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 0)) -# define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 1)) -# define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 2)) -# define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 3)) +# define BIO_set_accept_name(b, name) \ + BIO_ctrl(b, BIO_C_SET_ACCEPT, 0, (char *)(name)) +# define BIO_set_accept_port(b, port) \ + BIO_ctrl(b, BIO_C_SET_ACCEPT, 1, (char *)(port)) +# define BIO_get_accept_name(b) \ + ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 0)) +# define BIO_get_accept_port(b) \ + ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 1)) +# define BIO_get_peer_name(b) \ + ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 2)) +# define BIO_get_peer_port(b) \ + ((const char *)BIO_ptr_ctrl(b, BIO_C_GET_ACCEPT, 3)) /* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ -# define BIO_set_nbio_accept(b, n) BIO_ctrl(b, BIO_C_SET_ACCEPT, 2, (n) ? (void *)"a" : NULL) -# define BIO_set_accept_bios(b, bio) BIO_ctrl(b, BIO_C_SET_ACCEPT, 3, (char *)(bio)) -# define BIO_set_accept_ip_family(b, f) BIO_int_ctrl(b, BIO_C_SET_ACCEPT, 4, f) -# define BIO_get_accept_ip_family(b) BIO_ctrl(b, BIO_C_GET_ACCEPT, 4, NULL) -# define BIO_set_tfo_accept(b, n) BIO_ctrl(b, BIO_C_SET_ACCEPT, 5, (n) ? (void *)"a" : NULL) +# define BIO_set_nbio_accept(b, n) \ + BIO_ctrl(b, BIO_C_SET_ACCEPT, 2, (n) ? (void *)"a" : NULL) +# define BIO_set_accept_bios(b, bio) \ + BIO_ctrl(b, BIO_C_SET_ACCEPT, 3, (char *)(bio)) +# define BIO_set_accept_ip_family(b, f) BIO_int_ctrl(b, BIO_C_SET_ACCEPT, 4, f) +# define BIO_get_accept_ip_family(b) BIO_ctrl(b, BIO_C_GET_ACCEPT, 4, NULL) +# define BIO_set_tfo_accept(b, n) \ + BIO_ctrl(b, BIO_C_SET_ACCEPT, 5, (n) ? (void *)"a" : NULL) /* Aliases kept for backward compatibility */ -# define BIO_BIND_NORMAL 0 -# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR -# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR -# define BIO_set_bind_mode(b, mode) BIO_ctrl(b, BIO_C_SET_BIND_MODE, mode, NULL) -# define BIO_get_bind_mode(b) BIO_ctrl(b, BIO_C_GET_BIND_MODE, 0, NULL) +# define BIO_BIND_NORMAL 0 +# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR +# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR +# define BIO_set_bind_mode(b, mode) \ + BIO_ctrl(b, BIO_C_SET_BIND_MODE, mode, NULL) +# define BIO_get_bind_mode(b) BIO_ctrl(b, BIO_C_GET_BIND_MODE, 0, NULL) #endif /* OPENSSL_NO_SOCK */ #define BIO_do_connect(b) BIO_do_handshake(b) @@ -527,7 +568,8 @@ typedef struct bio_mmsg_cb_args_st #define BIO_do_handshake(b) BIO_ctrl(b, BIO_C_DO_STATE_MACHINE, 0, NULL) -/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */ +/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and + * BIO_s_connect() */ #define BIO_set_fd(b, fd, c) BIO_int_ctrl(b, BIO_C_SET_FD, c, fd) #define BIO_get_fd(b, c) BIO_ctrl(b, BIO_C_GET_FD, 0, (char *)(c)) @@ -550,15 +592,17 @@ typedef struct bio_mmsg_cb_args_st */ int BIO_read_filename(BIO *b, const char *name); #else -# define BIO_read_filename(b, name) \ - (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_READ, (char *)(name)) +# define BIO_read_filename(b, name) \ + (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_READ, \ + (char *)(name)) #endif -#define BIO_write_filename(b, name) \ - (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_WRITE, name) -#define BIO_append_filename(b, name) \ - (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_APPEND, name) -#define BIO_rw_filename(b, name) \ - (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_READ | BIO_FP_WRITE, name) +#define BIO_write_filename(b, name) \ + (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_WRITE, name) +#define BIO_append_filename(b, name) \ + (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_APPEND, name) +#define BIO_rw_filename(b, name) \ + (int)BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE | BIO_FP_READ | BIO_FP_WRITE, \ + name) /* * WARNING WARNING, this ups the reference count on the read bio of the SSL @@ -569,26 +613,35 @@ int BIO_read_filename(BIO *b, const char *name); #define BIO_set_ssl(b, ssl, c) BIO_ctrl(b, BIO_C_SET_SSL, c, (char *)(ssl)) #define BIO_get_ssl(b, sslp) BIO_ctrl(b, BIO_C_GET_SSL, 0, (char *)(sslp)) #define BIO_set_ssl_mode(b, client) BIO_ctrl(b, BIO_C_SSL_MODE, client, NULL) -#define BIO_set_ssl_renegotiate_bytes(b, num) \ - BIO_ctrl(b, BIO_C_SET_SSL_RENEGOTIATE_BYTES, num, NULL) -#define BIO_get_num_renegotiates(b) BIO_ctrl(b, BIO_C_GET_SSL_NUM_RENEGOTIATES, 0, NULL) -#define BIO_set_ssl_renegotiate_timeout(b, seconds) \ - BIO_ctrl(b, BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT, seconds, NULL) +#define BIO_set_ssl_renegotiate_bytes(b, num) \ + BIO_ctrl(b, BIO_C_SET_SSL_RENEGOTIATE_BYTES, num, NULL) +#define BIO_get_num_renegotiates(b) \ + BIO_ctrl(b, BIO_C_GET_SSL_NUM_RENEGOTIATES, 0, NULL) +#define BIO_set_ssl_renegotiate_timeout(b, seconds) \ + BIO_ctrl(b, BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT, seconds, NULL) /* defined in evp.h */ /* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */ #define BIO_get_mem_data(b, pp) BIO_ctrl(b, BIO_CTRL_INFO, 0, (char *)(pp)) -#define BIO_set_mem_buf(b, bm, c) BIO_ctrl(b, BIO_C_SET_BUF_MEM, c, (char *)(bm)) -#define BIO_get_mem_ptr(b, pp) BIO_ctrl(b, BIO_C_GET_BUF_MEM_PTR, 0, (char *)(pp)) -#define BIO_set_mem_eof_return(b, v) BIO_ctrl(b, BIO_C_SET_BUF_MEM_EOF_RETURN, v, NULL) +#define BIO_set_mem_buf(b, bm, c) \ + BIO_ctrl(b, BIO_C_SET_BUF_MEM, c, (char *)(bm)) +#define BIO_get_mem_ptr(b, pp) \ + BIO_ctrl(b, BIO_C_GET_BUF_MEM_PTR, 0, (char *)(pp)) +#define BIO_set_mem_eof_return(b, v) \ + BIO_ctrl(b, BIO_C_SET_BUF_MEM_EOF_RETURN, v, NULL) /* For the BIO_f_buffer() type */ -#define BIO_get_buffer_num_lines(b) BIO_ctrl(b, BIO_C_GET_BUFF_NUM_LINES, 0, NULL) -#define BIO_set_buffer_size(b, size) BIO_ctrl(b, BIO_C_SET_BUFF_SIZE, size, NULL) -#define BIO_set_read_buffer_size(b, size) BIO_int_ctrl(b, BIO_C_SET_BUFF_SIZE, size, 0) -#define BIO_set_write_buffer_size(b, size) BIO_int_ctrl(b, BIO_C_SET_BUFF_SIZE, size, 1) -#define BIO_set_buffer_read_data(b, buf, num) BIO_ctrl(b, BIO_C_SET_BUFF_READ_DATA, num, buf) +#define BIO_get_buffer_num_lines(b) \ + BIO_ctrl(b, BIO_C_GET_BUFF_NUM_LINES, 0, NULL) +#define BIO_set_buffer_size(b, size) \ + BIO_ctrl(b, BIO_C_SET_BUFF_SIZE, size, NULL) +#define BIO_set_read_buffer_size(b, size) \ + BIO_int_ctrl(b, BIO_C_SET_BUFF_SIZE, size, 0) +#define BIO_set_write_buffer_size(b, size) \ + BIO_int_ctrl(b, BIO_C_SET_BUFF_SIZE, size, 1) +#define BIO_set_buffer_read_data(b, buf, num) \ + BIO_ctrl(b, BIO_C_SET_BUFF_READ_DATA, num, buf) /* Don't use the next one unless you know what you are doing :-) */ #define BIO_dup_state(b, ret) BIO_ctrl(b, BIO_CTRL_DUP, 0, (char *)(ret)) @@ -603,69 +656,90 @@ int BIO_read_filename(BIO *b, const char *name); size_t BIO_ctrl_pending(BIO *b); size_t BIO_ctrl_wpending(BIO *b); #define BIO_flush(b) (int)BIO_ctrl(b, BIO_CTRL_FLUSH, 0, NULL) -#define BIO_get_info_callback(b, cbp) (int)BIO_ctrl(b, BIO_CTRL_GET_CALLBACK, 0, cbp) -#define BIO_set_info_callback(b, cb) (int)BIO_callback_ctrl(b, BIO_CTRL_SET_CALLBACK, cb) +#define BIO_get_info_callback(b, cbp) \ + (int)BIO_ctrl(b, BIO_CTRL_GET_CALLBACK, 0, cbp) +#define BIO_set_info_callback(b, cb) \ + (int)BIO_callback_ctrl(b, BIO_CTRL_SET_CALLBACK, cb) /* For the BIO_f_buffer() type */ #define BIO_buffer_get_num_lines(b) BIO_ctrl(b, BIO_CTRL_GET, 0, NULL) #define BIO_buffer_peek(b, s, l) BIO_ctrl(b, BIO_CTRL_PEEK, (l), (s)) /* For BIO_s_bio() */ -#define BIO_set_write_buf_size(b, size) (int)BIO_ctrl(b, BIO_C_SET_WRITE_BUF_SIZE, size, NULL) -#define BIO_get_write_buf_size(b, size) (size_t) BIO_ctrl(b, BIO_C_GET_WRITE_BUF_SIZE, size, NULL) +#define BIO_set_write_buf_size(b, size) \ + (int)BIO_ctrl(b, BIO_C_SET_WRITE_BUF_SIZE, size, NULL) +#define BIO_get_write_buf_size(b, size) \ + (size_t) BIO_ctrl(b, BIO_C_GET_WRITE_BUF_SIZE, size, NULL) #define BIO_make_bio_pair(b1, b2) (int)BIO_ctrl(b1, BIO_C_MAKE_BIO_PAIR, 0, b2) -#define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b, BIO_C_DESTROY_BIO_PAIR, 0, NULL) +#define BIO_destroy_bio_pair(b) \ + (int)BIO_ctrl(b, BIO_C_DESTROY_BIO_PAIR, 0, NULL) #define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) /* macros with inappropriate type -- but ...pending macros use int too: */ -#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b, BIO_C_GET_WRITE_GUARANTEE, 0, NULL) -#define BIO_get_read_request(b) (int)BIO_ctrl(b, BIO_C_GET_READ_REQUEST, 0, NULL) +#define BIO_get_write_guarantee(b) \ + (int)BIO_ctrl(b, BIO_C_GET_WRITE_GUARANTEE, 0, NULL) +#define BIO_get_read_request(b) \ + (int)BIO_ctrl(b, BIO_C_GET_READ_REQUEST, 0, NULL) size_t BIO_ctrl_get_write_guarantee(BIO *b); size_t BIO_ctrl_get_read_request(BIO *b); int BIO_ctrl_reset_read_request(BIO *b); /* ctrl macros for dgram */ -#define BIO_ctrl_dgram_connect(b, peer) (int)BIO_ctrl(b, BIO_CTRL_DGRAM_CONNECT, 0, (char *)(peer)) -#define BIO_ctrl_set_connected(b, peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer)) -#define BIO_dgram_recv_timedout(b) (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) -#define BIO_dgram_send_timedout(b) (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) -#define BIO_dgram_get_peer(b, peer) (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer)) -#define BIO_dgram_set_peer(b, peer) (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer)) -#define BIO_dgram_get_mtu_overhead(b) \ - (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) -#define BIO_dgram_get_local_addr_cap(b) \ - (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, NULL) -#define BIO_dgram_get_local_addr_enable(b, penable) \ - (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, (char *)(penable)) -#define BIO_dgram_set_local_addr_enable(b, enable) \ - (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, (enable), NULL) -#define BIO_dgram_get_effective_caps(b) \ - (uint32_t) BIO_ctrl((b), BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS, 0, NULL) -#define BIO_dgram_get_caps(b) (uint32_t) BIO_ctrl((b), BIO_CTRL_DGRAM_GET_CAPS, 0, NULL) -#define BIO_dgram_set_caps(b, caps) (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_CAPS, (long)(caps), NULL) -#define BIO_dgram_get_no_trunc(b) (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, NULL) -#define BIO_dgram_set_no_trunc(b, enable) \ - (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_NO_TRUNC, (enable), NULL) -#define BIO_dgram_get_mtu(b) (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU, 0, NULL) -#define BIO_dgram_set_mtu(b, mtu) (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_MTU, (mtu), NULL) +#define BIO_ctrl_dgram_connect(b, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_CONNECT, 0, (char *)(peer)) +#define BIO_ctrl_set_connected(b, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer)) +#define BIO_dgram_recv_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) +#define BIO_dgram_send_timedout(b) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) +#define BIO_dgram_get_peer(b, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer)) +#define BIO_dgram_set_peer(b, peer) \ + (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer)) +#define BIO_dgram_get_mtu_overhead(b) \ + (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) +#define BIO_dgram_get_local_addr_cap(b) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, NULL) +#define BIO_dgram_get_local_addr_enable(b, penable) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, (char *)(penable)) +#define BIO_dgram_set_local_addr_enable(b, enable) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, (enable), NULL) +#define BIO_dgram_get_effective_caps(b) \ + (uint32_t) BIO_ctrl((b), BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS, 0, NULL) +#define BIO_dgram_get_caps(b) \ + (uint32_t) BIO_ctrl((b), BIO_CTRL_DGRAM_GET_CAPS, 0, NULL) +#define BIO_dgram_set_caps(b, caps) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_CAPS, (long)(caps), NULL) +#define BIO_dgram_get_no_trunc(b) \ + (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, NULL) +#define BIO_dgram_set_no_trunc(b, enable) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_NO_TRUNC, (enable), NULL) +#define BIO_dgram_get_mtu(b) \ + (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU, 0, NULL) +#define BIO_dgram_set_mtu(b, mtu) \ + (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_MTU, (mtu), NULL) /* ctrl macros for BIO_f_prefix */ #define BIO_set_prefix(b, p) BIO_ctrl((b), BIO_CTRL_SET_PREFIX, 0, (void *)(p)) #define BIO_set_indent(b, i) BIO_ctrl((b), BIO_CTRL_SET_INDENT, (i), NULL) #define BIO_get_indent(b) BIO_ctrl((b), BIO_CTRL_GET_INDENT, 0, NULL) -#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef) +#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef) int BIO_set_ex_data(BIO *bio, int idx, void *data); void *BIO_get_ex_data(const BIO *bio, int idx); uint64_t BIO_number_read(BIO *bio); uint64_t BIO_number_written(BIO *bio); /* For BIO_f_asn1() */ -int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, asn1_ps_func *prefix_free); -int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, asn1_ps_func **pprefix_free); -int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, asn1_ps_func *suffix_free); -int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, asn1_ps_func **psuffix_free); +int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, + asn1_ps_func *prefix_free); +int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, + asn1_ps_func **pprefix_free); +int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, + asn1_ps_func *suffix_free); +int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, + asn1_ps_func **psuffix_free); const BIO_METHOD *BIO_s_file(void); BIO *BIO_new_file(const char *filename, const char *mode); @@ -686,14 +760,14 @@ void BIO_vfree(BIO *a); int BIO_up_ref(BIO *a); int BIO_read(BIO *b, void *data, int dlen); int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes); -__owur int BIO_recvmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, - size_t *msgs_processed); +__owur int BIO_recvmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, + uint64_t flags, size_t *msgs_processed); int BIO_gets(BIO *bp, char *buf, int size); int BIO_get_line(BIO *bio, char *buf, int size); int BIO_write(BIO *b, const void *data, int dlen); int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written); -__owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, - size_t *msgs_processed); +__owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, + uint64_t flags, size_t *msgs_processed); int BIO_puts(BIO *bp, const char *buf); int BIO_indent(BIO *b, int indent, int max); long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); @@ -741,16 +815,16 @@ const BIO_METHOD *BIO_s_dgram_pair(void); const BIO_METHOD *BIO_s_datagram(void); int BIO_dgram_non_fatal_error(int error); BIO *BIO_new_dgram(int fd, int close_flag); -# ifndef OPENSSL_NO_SCTP +# ifndef OPENSSL_NO_SCTP const BIO_METHOD *BIO_s_datagram_sctp(void); BIO *BIO_new_dgram_sctp(int fd, int close_flag); int BIO_dgram_is_sctp(BIO *bio); -int BIO_dgram_sctp_notification_cb(BIO *b, - BIO_dgram_sctp_notification_handler_fn handle_notifications, - void *context); +int BIO_dgram_sctp_notification_cb( + BIO *b, BIO_dgram_sctp_notification_handler_fn handle_notifications, + void *context); int BIO_dgram_sctp_wait_for_dry(BIO *b); int BIO_dgram_sctp_msg_waiting(BIO *b); -# endif +# endif #endif #ifndef OPENSSL_NO_SOCK @@ -764,22 +838,24 @@ int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds); int BIO_fd_should_retry(int i); int BIO_fd_non_fatal_error(int error); -int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), void *u, const void *s, int len); -int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), void *u, const void *s, - int len, int indent); +int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u), void *u, + const void *s, int len); +int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), + void *u, const void *s, int len, int indent); int BIO_dump(BIO *b, const void *bytes, int len); int BIO_dump_indent(BIO *b, const void *bytes, int len, int indent); #ifndef OPENSSL_NO_STDIO int BIO_dump_fp(FILE *fp, const void *s, int len); int BIO_dump_indent_fp(FILE *fp, const void *s, int len, int indent); #endif -int BIO_hex_string(BIO *out, int indent, int width, const void *data, int datalen); +int BIO_hex_string(BIO *out, int indent, int width, const void *data, + int datalen); #ifndef OPENSSL_NO_SOCK BIO_ADDR *BIO_ADDR_new(void); BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap); -int BIO_ADDR_rawmake(BIO_ADDR *ap, int family, const void *where, size_t wherelen, - unsigned short port); +int BIO_ADDR_rawmake(BIO_ADDR *ap, int family, const void *where, + size_t wherelen, unsigned short port); void BIO_ADDR_free(BIO_ADDR *); void BIO_ADDR_clear(BIO_ADDR *ap); int BIO_ADDR_family(const BIO_ADDR *ap); @@ -798,54 +874,57 @@ void BIO_ADDRINFO_free(BIO_ADDRINFO *bai); enum BIO_hostserv_priorities { - BIO_PARSE_PRIO_HOST, - BIO_PARSE_PRIO_SERV + BIO_PARSE_PRIO_HOST, + BIO_PARSE_PRIO_SERV }; int BIO_parse_hostserv(const char *hostserv, char **host, char **service, enum BIO_hostserv_priorities hostserv_prio); enum BIO_lookup_type { - BIO_LOOKUP_CLIENT, - BIO_LOOKUP_SERVER + BIO_LOOKUP_CLIENT, + BIO_LOOKUP_SERVER }; -int BIO_lookup(const char *host, const char *service, enum BIO_lookup_type lookup_type, int family, - int socktype, BIO_ADDRINFO **res); -int BIO_lookup_ex(const char *host, const char *service, int lookup_type, int family, int socktype, - int protocol, BIO_ADDRINFO **res); +int BIO_lookup(const char *host, const char *service, + enum BIO_lookup_type lookup_type, int family, int socktype, + BIO_ADDRINFO **res); +int BIO_lookup_ex(const char *host, const char *service, int lookup_type, + int family, int socktype, int protocol, BIO_ADDRINFO **res); int BIO_sock_error(int sock); int BIO_socket_ioctl(int fd, long type, void *arg); int BIO_socket_nbio(int fd, int mode); int BIO_sock_init(void); -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define BIO_sock_cleanup() \ - while (0) \ - continue -# endif +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define BIO_sock_cleanup() \ + while (0) \ + continue +# endif int BIO_set_tcp_ndelay(int sock, int turn_on); -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 struct hostent *BIO_gethostbyname(const char *name); -OSSL_DEPRECATEDIN_1_1_0 int BIO_get_port(const char *str, unsigned short *port_ptr); +OSSL_DEPRECATEDIN_1_1_0 int BIO_get_port(const char *str, + unsigned short *port_ptr); OSSL_DEPRECATEDIN_1_1_0 int BIO_get_host_ip(const char *str, unsigned char *ip); OSSL_DEPRECATEDIN_1_1_0 int BIO_get_accept_socket(char *host_port, int mode); OSSL_DEPRECATEDIN_1_1_0 int BIO_accept(int sock, char **ip_port); -# endif +# endif union BIO_sock_info_u { - BIO_ADDR *addr; + BIO_ADDR *addr; }; enum BIO_sock_info_type { - BIO_SOCK_INFO_ADDRESS + BIO_SOCK_INFO_ADDRESS }; -int BIO_sock_info(int sock, enum BIO_sock_info_type type, union BIO_sock_info_u *info); +int BIO_sock_info(int sock, enum BIO_sock_info_type type, + union BIO_sock_info_u *info); -# define BIO_SOCK_REUSEADDR 0x01 -# define BIO_SOCK_V6_ONLY 0x02 -# define BIO_SOCK_KEEPALIVE 0x04 -# define BIO_SOCK_NONBLOCK 0x08 -# define BIO_SOCK_NODELAY 0x10 -# define BIO_SOCK_TFO 0x20 +# define BIO_SOCK_REUSEADDR 0x01 +# define BIO_SOCK_V6_ONLY 0x02 +# define BIO_SOCK_KEEPALIVE 0x04 +# define BIO_SOCK_NONBLOCK 0x08 +# define BIO_SOCK_NODELAY 0x10 +# define BIO_SOCK_TFO 0x20 int BIO_socket(int domain, int socktype, int protocol, int options); int BIO_connect(int sock, const BIO_ADDR *addr, int options); @@ -861,9 +940,11 @@ BIO *BIO_new_accept(const char *host_port); BIO *BIO_new_fd(int fd, int close_flag); -int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2); +int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, BIO **bio2, + size_t writebuf2); #ifndef OPENSSL_NO_DGRAM -int BIO_new_bio_dgram_pair(BIO **bio1, size_t writebuf1, BIO **bio2, size_t writebuf2); +int BIO_new_bio_dgram_pair(BIO **bio1, size_t writebuf1, BIO **bio2, + size_t writebuf2); #endif /* @@ -879,21 +960,21 @@ void BIO_copy_next_retry(BIO *b); */ #define ossl_bio__attr__(x) -#if defined(__GNUC__) && defined(__STDC_VERSION__) && !defined(__MINGW32__) \ +#if defined(__GNUC__) && defined(__STDC_VERSION__) && !defined(__MINGW32__) \ && !defined(__MINGW64__) && !defined(__APPLE__) /* * Because we support the 'z' modifier, which made its appearance in C99, * we can't use __attribute__ with pre C99 dialects. */ -# if __STDC_VERSION__ >= 199901L -# undef ossl_bio__attr__ -# define ossl_bio__attr__ __attribute__ -# if __GNUC__ * 10 + __GNUC_MINOR__ >= 44 -# define ossl_bio__printf__ __gnu_printf__ -# else -# define ossl_bio__printf__ __printf__ -# endif +# if __STDC_VERSION__ >= 199901L +# undef ossl_bio__attr__ +# define ossl_bio__attr__ __attribute__ +# if __GNUC__ * 10 + __GNUC_MINOR__ >= 44 +# define ossl_bio__printf__ __gnu_printf__ +# else +# define ossl_bio__printf__ __printf__ # endif +# endif #endif int BIO_printf(BIO *bio, const char *format, ...) ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3))); @@ -909,20 +990,29 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) BIO_METHOD *BIO_meth_new(int type, const char *name); void BIO_meth_free(BIO_METHOD *biom); int (*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int); -int (*BIO_meth_get_write_ex(const BIO_METHOD *biom))(BIO *, const char *, size_t, size_t *); -int BIO_meth_set_write(BIO_METHOD *biom, int (*write)(BIO *, const char *, int)); -int BIO_meth_set_write_ex(BIO_METHOD *biom, int (*bwrite)(BIO *, const char *, size_t, size_t *)); +int (*BIO_meth_get_write_ex(const BIO_METHOD *biom))(BIO *, const char *, + size_t, size_t *); +int BIO_meth_set_write(BIO_METHOD *biom, + int (*write)(BIO *, const char *, int)); +int BIO_meth_set_write_ex(BIO_METHOD *biom, + int (*bwrite)(BIO *, const char *, size_t, size_t *)); int BIO_meth_set_sendmmsg(BIO_METHOD *biom, - int (*f)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *)); -int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, size_t, size_t, uint64_t, + int (*f)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, + size_t *)); +int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, size_t, + size_t, uint64_t, size_t *); int (*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int); -int (*BIO_meth_get_read_ex(const BIO_METHOD *biom))(BIO *, char *, size_t, size_t *); +int (*BIO_meth_get_read_ex(const BIO_METHOD *biom))(BIO *, char *, size_t, + size_t *); int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)); -int BIO_meth_set_read_ex(BIO_METHOD *biom, int (*bread)(BIO *, char *, size_t, size_t *)); +int BIO_meth_set_read_ex(BIO_METHOD *biom, + int (*bread)(BIO *, char *, size_t, size_t *)); int BIO_meth_set_recvmmsg(BIO_METHOD *biom, - int (*f)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *)); -int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, size_t, size_t, uint64_t, + int (*f)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, + size_t *)); +int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *, size_t, + size_t, uint64_t, size_t *); int (*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *); int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)); @@ -934,8 +1024,11 @@ int (*BIO_meth_get_create(const BIO_METHOD *bion))(BIO *); int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)); int (*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *); int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)); -long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *); -int BIO_meth_set_callback_ctrl(BIO_METHOD *biom, long (*callback_ctrl)(BIO *, int, BIO_info_cb *)); +long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, + BIO_info_cb *); +int BIO_meth_set_callback_ctrl(BIO_METHOD *biom, + long (*callback_ctrl)(BIO *, int, + BIO_info_cb *)); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/blowfish.h b/libs/OpenSSL/include/openssl/blowfish.h index 94c3438f..752aa8f9 100644 --- a/libs/OpenSSL/include/openssl/blowfish.h +++ b/libs/OpenSSL/include/openssl/blowfish.h @@ -13,60 +13,67 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_BLOWFISH_H +# define HEADER_BLOWFISH_H #endif #include #ifndef OPENSSL_NO_BF -# include -# ifdef __cplusplus +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define BF_BLOCK 8 +# define BF_BLOCK 8 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define BF_ENCRYPT 1 -# define BF_DECRYPT 0 +# define BF_ENCRYPT 1 +# define BF_DECRYPT 0 /*- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * ! BF_LONG has to be at least 32 bits wide. ! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -# define BF_LONG unsigned int +# define BF_LONG unsigned int -# define BF_ROUNDS 16 +# define BF_ROUNDS 16 typedef struct bf_key_st { - BF_LONG P[BF_ROUNDS + 2]; - BF_LONG S[4 * 256]; + BF_LONG P[BF_ROUNDS + 2]; + BF_LONG S[4 * 256]; } BF_KEY; -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 void BF_set_key(BF_KEY *key, int len, const unsigned char *data); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void BF_set_key(BF_KEY *key, int len, + const unsigned char *data); OSSL_DEPRECATEDIN_3_0 void BF_encrypt(BF_LONG *data, const BF_KEY *key); OSSL_DEPRECATEDIN_3_0 void BF_decrypt(BF_LONG *data, const BF_KEY *key); -OSSL_DEPRECATEDIN_3_0 void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, - const BF_KEY *key, int enc); -OSSL_DEPRECATEDIN_3_0 void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int enc); -OSSL_DEPRECATEDIN_3_0 void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const BF_KEY *schedule, - unsigned char *ivec, int *num, int enc); -OSSL_DEPRECATEDIN_3_0 void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const BF_KEY *schedule, +OSSL_DEPRECATEDIN_3_0 void BF_ecb_encrypt(const unsigned char *in, + unsigned char *out, const BF_KEY *key, + int enc); +OSSL_DEPRECATEDIN_3_0 void BF_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + const BF_KEY *schedule, + unsigned char *ivec, int enc); +OSSL_DEPRECATEDIN_3_0 void BF_cfb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + const BF_KEY *schedule, + unsigned char *ivec, int *num, + int enc); +OSSL_DEPRECATEDIN_3_0 void BF_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num); OSSL_DEPRECATEDIN_3_0 const char *BF_options(void); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/bn.h b/libs/OpenSSL/include/openssl/bn.h index 6dfbf56b..392dc944 100644 --- a/libs/OpenSSL/include/openssl/bn.h +++ b/libs/OpenSSL/include/openssl/bn.h @@ -14,12 +14,12 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_BN_H +# define HEADER_BN_H #endif #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include #include @@ -34,21 +34,21 @@ extern "C" { * 64-bit processor with LP64 ABI */ #ifdef SIXTY_FOUR_BIT_LONG -# define BN_ULONG unsigned long -# define BN_BYTES 8 +# define BN_ULONG unsigned long +# define BN_BYTES 8 #endif /* * 64-bit processor other than LP64 ABI */ #ifdef SIXTY_FOUR_BIT -# define BN_ULONG unsigned long long -# define BN_BYTES 8 +# define BN_ULONG unsigned long long +# define BN_BYTES 8 #endif #ifdef THIRTY_TWO_BIT -# define BN_ULONG unsigned int -# define BN_BYTES 4 +# define BN_ULONG unsigned int +# define BN_BYTES 4 #endif #define BN_BITS2 (BN_BYTES * 8) @@ -69,8 +69,8 @@ extern "C" { #ifndef OPENSSL_NO_DEPRECATED_0_9_8 /* deprecated name for the flag */ -# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME -# define BN_FLG_FREE 0x8000 /* used for debugging */ +# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME +# define BN_FLG_FREE 0x8000 /* used for debugging */ #endif void BN_set_flags(BIGNUM *b, int n); @@ -100,25 +100,27 @@ BN_GENCB *BN_GENCB_new(void); void BN_GENCB_free(BN_GENCB *cb); /* Populate a BN_GENCB structure with an "old"-style callback */ -void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback)(int, int, void *), void *cb_arg); +void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback)(int, int, void *), + void *cb_arg); /* Populate a BN_GENCB structure with a "new"-style callback */ -void BN_GENCB_set(BN_GENCB *gencb, int (*callback)(int, int, BN_GENCB *), void *cb_arg); +void BN_GENCB_set(BN_GENCB *gencb, int (*callback)(int, int, BN_GENCB *), + void *cb_arg); void *BN_GENCB_get_arg(BN_GENCB *cb); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define BN_prime_checks \ - 0 /* default: select number of iterations based \ - * on the size of the number */ +# define BN_prime_checks \ + 0 /* default: select number of iterations based \ + * on the size of the number */ /* * BN_prime_checks_for_size() returns the number of Miller-Rabin iterations * that will be done for checking that a random number is probably prime. The * error rate for accepting a composite number as prime depends on the size of - * the prime |b|. The error rates used are for calculating an RSA key with 2 primes, - * and so the level is what you would expect for a key of double the size of the - * prime. + * the prime |b|. The error rates used are for calculating an RSA key with 2 + * primes, and so the level is what you would expect for a key of double the + * size of the prime. * * This table is generated using the algorithm of FIPS PUB 186-4 * Digital Signature Standard (DSS), section F.1, page 117. @@ -175,15 +177,15 @@ void *BN_GENCB_get_arg(BN_GENCB *cb); * (b) >= 6 | >= 12 | 34 | 64 bit */ -# define BN_prime_checks_for_size(b) \ - ((b) >= 3747 ? 3 \ - : (b) >= 1345 ? 4 \ - : (b) >= 476 ? 5 \ - : (b) >= 400 ? 6 \ - : (b) >= 347 ? 7 \ - : (b) >= 308 ? 8 \ - : (b) >= 55 ? 27 \ - : /* b >= 6 */ 34) +# define BN_prime_checks_for_size(b) \ + ((b) >= 3747 ? 3 \ + : (b) >= 1345 ? 4 \ + : (b) >= 476 ? 5 \ + : (b) >= 400 ? 6 \ + : (b) >= 347 ? 7 \ + : (b) >= 308 ? 8 \ + : (b) >= 55 ? 27 \ + : /* b >= 6 */ 34) #endif #define BN_num_bytes(a) ((BN_num_bits(a) + 7) / 8) @@ -199,9 +201,9 @@ int BN_is_odd(const BIGNUM *a); void BN_zero_ex(BIGNUM *a); #if OPENSSL_API_LEVEL > 908 -# define BN_zero(a) BN_zero_ex(a) +# define BN_zero(a) BN_zero_ex(a) #else -# define BN_zero(a) (BN_set_word((a), 0)) +# define BN_zero(a) (BN_set_word((a), 0)) #endif const BIGNUM *BN_value_one(void); @@ -214,13 +216,17 @@ void BN_CTX_free(BN_CTX *c); void BN_CTX_start(BN_CTX *ctx); BIGNUM *BN_CTX_get(BN_CTX *ctx); void BN_CTX_end(BN_CTX *ctx); -int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, unsigned int strength, BN_CTX *ctx); +int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, + unsigned int strength, BN_CTX *ctx); int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, unsigned int strength, BN_CTX *ctx); +int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, + unsigned int strength, BN_CTX *ctx); int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, unsigned int strength, BN_CTX *ctx); +int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, unsigned int strength, + BN_CTX *ctx); int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); -int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, unsigned int strength, BN_CTX *ctx); +int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, unsigned int strength, + BN_CTX *ctx); int BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 @@ -268,18 +274,25 @@ void BN_set_negative(BIGNUM *b, int n); */ int BN_is_negative(const BIGNUM *b); -int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, + BN_CTX *ctx); #define BN_mod(rem, m, d, ctx) BN_div(NULL, (rem), (m), (d), (ctx)) int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); -int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); -int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); -int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); -int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, + BN_CTX *ctx); int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); @@ -297,19 +310,25 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); int BN_lshift1(BIGNUM *r, const BIGNUM *a); int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont); -int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, const BIGNUM *a2, - const BIGNUM *p2, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_mont_consttime_x2(BIGNUM *rr1, const BIGNUM *a1, const BIGNUM *p1, const BIGNUM *m1, - BN_MONT_CTX *in_mont1, BIGNUM *rr2, const BIGNUM *a2, - const BIGNUM *p2, const BIGNUM *m2, BN_MONT_CTX *in_mont2, +int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx); +int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); +int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *m_ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_mod_exp_mont_consttime_x2(BIGNUM *rr1, const BIGNUM *a1, + const BIGNUM *p1, const BIGNUM *m1, + BN_MONT_CTX *in_mont1, BIGNUM *rr2, + const BIGNUM *a2, const BIGNUM *p2, + const BIGNUM *m2, BN_MONT_CTX *in_mont2, BN_CTX *ctx); int BN_mask_bits(BIGNUM *a, int n); @@ -335,7 +354,8 @@ int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns * -2 for * error */ int BN_are_coprime(BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -BIGNUM *BN_mod_inverse(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); +BIGNUM *BN_mod_inverse(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, + BN_CTX *ctx); BIGNUM *BN_mod_sqrt(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); @@ -343,27 +363,29 @@ void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); /* Deprecated versions */ #ifndef OPENSSL_NO_DEPRECATED_0_9_8 OSSL_DEPRECATEDIN_0_9_8 -BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, - void (*callback)(int, int, void *), void *cb_arg); +BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, + const BIGNUM *rem, void (*callback)(int, int, void *), + void *cb_arg); OSSL_DEPRECATEDIN_0_9_8 -int BN_is_prime(const BIGNUM *p, int nchecks, void (*callback)(int, int, void *), BN_CTX *ctx, - void *cb_arg); +int BN_is_prime(const BIGNUM *p, int nchecks, + void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg); OSSL_DEPRECATEDIN_0_9_8 -int BN_is_prime_fasttest(const BIGNUM *p, int nchecks, void (*callback)(int, int, void *), - BN_CTX *ctx, void *cb_arg, int do_trial_division); +int BN_is_prime_fasttest(const BIGNUM *p, int nchecks, + void (*callback)(int, int, void *), BN_CTX *ctx, + void *cb_arg, int do_trial_division); #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 -int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, int do_trial_division, - BN_GENCB *cb); +int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, + int do_trial_division, BN_GENCB *cb); #endif /* Newer versions */ -int BN_generate_prime_ex2(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, - BN_GENCB *cb, BN_CTX *ctx); -int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, - BN_GENCB *cb); +int BN_generate_prime_ex2(BIGNUM *ret, int bits, int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb, BN_CTX *ctx); +int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); int BN_check_prime(const BIGNUM *p, BN_CTX *ctx, BN_GENCB *cb); #ifndef OPENSSL_NO_DEPRECATED_3_0 @@ -371,23 +393,27 @@ OSSL_DEPRECATEDIN_3_0 int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx); OSSL_DEPRECATEDIN_3_0 -int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, const BIGNUM *Xp1, - const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); +int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, + const BIGNUM *Xp1, const BIGNUM *Xp2, + const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 -int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1, BIGNUM *Xp2, - const BIGNUM *Xp, const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); +int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1, + BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e, + BN_CTX *ctx, BN_GENCB *cb); #endif BN_MONT_CTX *BN_MONT_CTX_new(void); -int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_MONT_CTX *mont, - BN_CTX *ctx); -int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); -int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); +int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); void BN_MONT_CTX_free(BN_MONT_CTX *mont); int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx); BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from); -BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock, const BIGNUM *mod, - BN_CTX *ctx); +BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock, + const BIGNUM *mod, BN_CTX *ctx); /* BN_BLINDING flags */ #define BN_BLINDING_NO_UPDATE 0x00000001 @@ -408,11 +434,11 @@ int BN_BLINDING_unlock(BN_BLINDING *b); unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); -BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, - int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx), - BN_MONT_CTX *m_ctx); +BN_BLINDING *BN_BLINDING_create_param( + BN_BLINDING *b, const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); #ifndef OPENSSL_NO_DEPRECATED_0_9_8 OSSL_DEPRECATEDIN_0_9_8 void BN_set_params(int mul, int high, int low, int mont); @@ -423,10 +449,12 @@ int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ BN_RECP_CTX *BN_RECP_CTX_new(void); void BN_RECP_CTX_free(BN_RECP_CTX *recp); int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx); -int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, BN_RECP_CTX *recp, - BN_CTX *ctx); -int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx); -int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, BN_CTX *ctx); +int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, + BN_RECP_CTX *recp, BN_CTX *ctx); +int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, + BN_CTX *ctx); #ifndef OPENSSL_NO_EC2M @@ -441,26 +469,30 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, BN_ * r = a + b */ int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) +# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) /* * r=a mod p */ int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /* r = (a * b) mod p */ -int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); +int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a * a) mod p */ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); /* r = (1 / b) mod p */ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */ -int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); +int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */ -int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); +int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *p, BN_CTX *ctx); /* r = sqrt(a) mod p */ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); /* r^2 + r = a mod p */ -int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) +int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + BN_CTX *ctx); +# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) /*- * Some functions allow for representation of the irreducible polynomials * as an unsigned int[], say p. The irreducible f(t) is then of the form: @@ -470,19 +502,24 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX * /* r = a mod p */ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); /* r = (a * b) mod p */ -int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx); +int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const int p[], BN_CTX *ctx); /* r = (a * a) mod p */ int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx); /* r = (1 / b) mod p */ int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], BN_CTX *ctx); /* r = (a / b) mod p */ -int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx); +int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ -int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BN_CTX *ctx); +int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ -int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx); +int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[], + BN_CTX *ctx); /* r^2 + r = a mod p */ -int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx); +int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, const int p[], + BN_CTX *ctx); int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max); int BN_GF2m_arr2poly(const int p[], BIGNUM *a); @@ -503,11 +540,12 @@ const BIGNUM *BN_get0_nist_prime_256(void); const BIGNUM *BN_get0_nist_prime_384(void); const BIGNUM *BN_get0_nist_prime_521(void); -int (*BN_nist_mod_func(const BIGNUM *p))(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, - BN_CTX *ctx); +int (*BN_nist_mod_func(const BIGNUM *p))(BIGNUM *r, const BIGNUM *a, + const BIGNUM *field, BN_CTX *ctx); int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, const BIGNUM *priv, - const unsigned char *message, size_t message_len, BN_CTX *ctx); + const unsigned char *message, size_t message_len, + BN_CTX *ctx); /* Primes from RFC 2409 */ BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn); @@ -522,14 +560,14 @@ BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn); BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768 -# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024 -# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536 -# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048 -# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072 -# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096 -# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144 -# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192 +# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768 +# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024 +# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536 +# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048 +# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072 +# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096 +# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144 +# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192 #endif int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom); diff --git a/libs/OpenSSL/include/openssl/buffer.h b/libs/OpenSSL/include/openssl/buffer.h index 30745797..44be93bc 100644 --- a/libs/OpenSSL/include/openssl/buffer.h +++ b/libs/OpenSSL/include/openssl/buffer.h @@ -13,12 +13,12 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_BUFFER_H +# define HEADER_BUFFER_H #endif #include #ifndef OPENSSL_CRYPTO_H -# include +# include #endif #include @@ -30,20 +30,20 @@ extern "C" { #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define BUF_strdup(s) OPENSSL_strdup(s) -# define BUF_strndup(s, size) OPENSSL_strndup(s, size) -# define BUF_memdup(data, size) OPENSSL_memdup(data, size) -# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) -# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) -# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) +# define BUF_strdup(s) OPENSSL_strdup(s) +# define BUF_strndup(s, size) OPENSSL_strndup(s, size) +# define BUF_memdup(data, size) OPENSSL_memdup(data, size) +# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) +# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) +# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) #endif struct buf_mem_st { - size_t length; /* current number of bytes */ - char *data; - size_t max; /* size of buffer */ - unsigned long flags; + size_t length; /* current number of bytes */ + char *data; + size_t max; /* size of buffer */ + unsigned long flags; }; #define BUF_MEM_FLAG_SECURE 0x01 diff --git a/libs/OpenSSL/include/openssl/camellia.h b/libs/OpenSSL/include/openssl/camellia.h index cf6898ff..790fbbf5 100644 --- a/libs/OpenSSL/include/openssl/camellia.h +++ b/libs/OpenSSL/include/openssl/camellia.h @@ -13,23 +13,23 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CAMELLIA_H +# define HEADER_CAMELLIA_H #endif #include #ifndef OPENSSL_NO_CAMELLIA -# include -# ifdef __cplusplus +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define CAMELLIA_BLOCK_SIZE 16 +# define CAMELLIA_BLOCK_SIZE 16 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define CAMELLIA_ENCRYPT 1 -# define CAMELLIA_DECRYPT 0 +# define CAMELLIA_ENCRYPT 1 +# define CAMELLIA_DECRYPT 0 /* * Because array size can't be a const in C, the following two are macros. @@ -38,57 +38,68 @@ extern "C" { /* This should be a hidden type, but EVP requires that the size be known */ -# define CAMELLIA_TABLE_BYTE_LEN 272 -# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) +# define CAMELLIA_TABLE_BYTE_LEN 272 +# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match * with WORD */ struct camellia_key_st { - union - { - double d; /* ensures 64-bit align */ - KEY_TABLE_TYPE rd_key; - } u; - int grand_rounds; + union + { + double d; /* ensures 64-bit align */ + KEY_TABLE_TYPE rd_key; + } u; + int grand_rounds; }; typedef struct camellia_key_st CAMELLIA_KEY; -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int Camellia_set_key(const unsigned char *userKey, const int bits, - CAMELLIA_KEY *key); -OSSL_DEPRECATEDIN_3_0 void Camellia_encrypt(const unsigned char *in, unsigned char *out, +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int Camellia_set_key(const unsigned char *userKey, + const int bits, CAMELLIA_KEY *key); +OSSL_DEPRECATEDIN_3_0 void Camellia_encrypt(const unsigned char *in, + unsigned char *out, const CAMELLIA_KEY *key); -OSSL_DEPRECATEDIN_3_0 void Camellia_decrypt(const unsigned char *in, unsigned char *out, +OSSL_DEPRECATEDIN_3_0 void Camellia_decrypt(const unsigned char *in, + unsigned char *out, const CAMELLIA_KEY *key); -OSSL_DEPRECATEDIN_3_0 void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key, const int enc); -OSSL_DEPRECATEDIN_3_0 void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, const int enc); -OSSL_DEPRECATEDIN_3_0 void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -OSSL_DEPRECATEDIN_3_0 void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -OSSL_DEPRECATEDIN_3_0 void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -OSSL_DEPRECATEDIN_3_0 void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num); +OSSL_DEPRECATEDIN_3_0 void Camellia_ecb_encrypt(const unsigned char *in, + unsigned char *out, + const CAMELLIA_KEY *key, + const int enc); +OSSL_DEPRECATEDIN_3_0 void +Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t length, + const CAMELLIA_KEY *key, unsigned char *ivec, + const int enc); +OSSL_DEPRECATEDIN_3_0 void +Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const CAMELLIA_KEY *key, + unsigned char *ivec, int *num, const int enc); +OSSL_DEPRECATEDIN_3_0 void +Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const CAMELLIA_KEY *key, + unsigned char *ivec, int *num, const int enc); +OSSL_DEPRECATEDIN_3_0 void +Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const CAMELLIA_KEY *key, + unsigned char *ivec, int *num, const int enc); +OSSL_DEPRECATEDIN_3_0 void +Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const CAMELLIA_KEY *key, + unsigned char *ivec, int *num); OSSL_DEPRECATEDIN_3_0 -void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const CAMELLIA_KEY *key, unsigned char ivec[CAMELLIA_BLOCK_SIZE], - unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], unsigned int *num); -# endif +void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const CAMELLIA_KEY *key, + unsigned char ivec[CAMELLIA_BLOCK_SIZE], + unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], + unsigned int *num); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/cast.h b/libs/OpenSSL/include/openssl/cast.h index 1a97d48c..e7a67e40 100644 --- a/libs/OpenSSL/include/openssl/cast.h +++ b/libs/OpenSSL/include/openssl/cast.h @@ -13,56 +13,59 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CAST_H +# define HEADER_CAST_H #endif #include #ifndef OPENSSL_NO_CAST -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define CAST_BLOCK 8 -# define CAST_KEY_LENGTH 16 +# define CAST_BLOCK 8 +# define CAST_KEY_LENGTH 16 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define CAST_ENCRYPT 1 -# define CAST_DECRYPT 0 +# define CAST_ENCRYPT 1 +# define CAST_DECRYPT 0 -# define CAST_LONG unsigned int +# define CAST_LONG unsigned int typedef struct cast_key_st { - CAST_LONG data[32]; - int short_key; /* Use reduced rounds for short key */ + CAST_LONG data[32]; + int short_key; /* Use reduced rounds for short key */ } CAST_KEY; -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); OSSL_DEPRECATEDIN_3_0 -void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, const CAST_KEY *key, int enc); +void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, + const CAST_KEY *key, int enc); OSSL_DEPRECATEDIN_3_0 void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); OSSL_DEPRECATEDIN_3_0 void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); OSSL_DEPRECATEDIN_3_0 -void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, const CAST_KEY *ks, - unsigned char *iv, int enc); +void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const CAST_KEY *ks, unsigned char *iv, int enc); OSSL_DEPRECATEDIN_3_0 -void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const CAST_KEY *schedule, unsigned char *ivec, int *num, int enc); +void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, const CAST_KEY *schedule, + unsigned char *ivec, int *num, int enc); OSSL_DEPRECATEDIN_3_0 -void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const CAST_KEY *schedule, unsigned char *ivec, int *num); -# endif +void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, const CAST_KEY *schedule, + unsigned char *ivec, int *num); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/cmac.h b/libs/OpenSSL/include/openssl/cmac.h index 2659c2ef..f9d1e14c 100644 --- a/libs/OpenSSL/include/openssl/cmac.h +++ b/libs/OpenSSL/include/openssl/cmac.h @@ -13,37 +13,40 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CMAC_H +# define HEADER_CMAC_H #endif #ifndef OPENSSL_NO_CMAC -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# include +# include -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /* Opaque */ typedef struct CMAC_CTX_st CMAC_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 CMAC_CTX *CMAC_CTX_new(void); OSSL_DEPRECATEDIN_3_0 void CMAC_CTX_cleanup(CMAC_CTX *ctx); OSSL_DEPRECATEDIN_3_0 void CMAC_CTX_free(CMAC_CTX *ctx); OSSL_DEPRECATEDIN_3_0 EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); OSSL_DEPRECATEDIN_3_0 int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); -OSSL_DEPRECATEDIN_3_0 int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, - const EVP_CIPHER *cipher, ENGINE *impl); -OSSL_DEPRECATEDIN_3_0 int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); -OSSL_DEPRECATEDIN_3_0 int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); +OSSL_DEPRECATEDIN_3_0 int CMAC_Init(CMAC_CTX *ctx, const void *key, + size_t keylen, const EVP_CIPHER *cipher, + ENGINE *impl); +OSSL_DEPRECATEDIN_3_0 int CMAC_Update(CMAC_CTX *ctx, const void *data, + size_t dlen); +OSSL_DEPRECATEDIN_3_0 int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, + size_t *poutlen); OSSL_DEPRECATEDIN_3_0 int CMAC_resume(CMAC_CTX *ctx); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/cmp.h b/libs/OpenSSL/include/openssl/cmp.h index 67a2f52a..39e120e0 100644 --- a/libs/OpenSSL/include/openssl/cmp.h +++ b/libs/OpenSSL/include/openssl/cmp.h @@ -18,24 +18,24 @@ #include #ifndef OPENSSL_NO_CMP -# include -# include -# include -# include +# include +# include +# include +# include /* explicit #includes not strictly needed since implied by the above: */ -# include -# include -# include -# include +# include +# include +# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define OSSL_CMP_PVNO_2 2 -# define OSSL_CMP_PVNO_3 3 -# define OSSL_CMP_PVNO OSSL_CMP_PVNO_2 /* v2 is the default */ +# define OSSL_CMP_PVNO_2 2 +# define OSSL_CMP_PVNO_3 3 +# define OSSL_CMP_PVNO OSSL_CMP_PVNO_2 /* v2 is the default */ /*- * PKIFailureInfo ::= BIT STRING { @@ -104,68 +104,69 @@ extern "C" { * -- certificate already exists * } */ -# define OSSL_CMP_PKIFAILUREINFO_badAlg 0 -# define OSSL_CMP_PKIFAILUREINFO_badMessageCheck 1 -# define OSSL_CMP_PKIFAILUREINFO_badRequest 2 -# define OSSL_CMP_PKIFAILUREINFO_badTime 3 -# define OSSL_CMP_PKIFAILUREINFO_badCertId 4 -# define OSSL_CMP_PKIFAILUREINFO_badDataFormat 5 -# define OSSL_CMP_PKIFAILUREINFO_wrongAuthority 6 -# define OSSL_CMP_PKIFAILUREINFO_incorrectData 7 -# define OSSL_CMP_PKIFAILUREINFO_missingTimeStamp 8 -# define OSSL_CMP_PKIFAILUREINFO_badPOP 9 -# define OSSL_CMP_PKIFAILUREINFO_certRevoked 10 -# define OSSL_CMP_PKIFAILUREINFO_certConfirmed 11 -# define OSSL_CMP_PKIFAILUREINFO_wrongIntegrity 12 -# define OSSL_CMP_PKIFAILUREINFO_badRecipientNonce 13 -# define OSSL_CMP_PKIFAILUREINFO_timeNotAvailable 14 -# define OSSL_CMP_PKIFAILUREINFO_unacceptedPolicy 15 -# define OSSL_CMP_PKIFAILUREINFO_unacceptedExtension 16 -# define OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable 17 -# define OSSL_CMP_PKIFAILUREINFO_badSenderNonce 18 -# define OSSL_CMP_PKIFAILUREINFO_badCertTemplate 19 -# define OSSL_CMP_PKIFAILUREINFO_signerNotTrusted 20 -# define OSSL_CMP_PKIFAILUREINFO_transactionIdInUse 21 -# define OSSL_CMP_PKIFAILUREINFO_unsupportedVersion 22 -# define OSSL_CMP_PKIFAILUREINFO_notAuthorized 23 -# define OSSL_CMP_PKIFAILUREINFO_systemUnavail 24 -# define OSSL_CMP_PKIFAILUREINFO_systemFailure 25 -# define OSSL_CMP_PKIFAILUREINFO_duplicateCertReq 26 -# define OSSL_CMP_PKIFAILUREINFO_MAX 26 -# define OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN ((1 << (OSSL_CMP_PKIFAILUREINFO_MAX + 1)) - 1) -# if OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN > INT_MAX -# error CMP_PKIFAILUREINFO_MAX bit pattern does not fit in type int -# endif +# define OSSL_CMP_PKIFAILUREINFO_badAlg 0 +# define OSSL_CMP_PKIFAILUREINFO_badMessageCheck 1 +# define OSSL_CMP_PKIFAILUREINFO_badRequest 2 +# define OSSL_CMP_PKIFAILUREINFO_badTime 3 +# define OSSL_CMP_PKIFAILUREINFO_badCertId 4 +# define OSSL_CMP_PKIFAILUREINFO_badDataFormat 5 +# define OSSL_CMP_PKIFAILUREINFO_wrongAuthority 6 +# define OSSL_CMP_PKIFAILUREINFO_incorrectData 7 +# define OSSL_CMP_PKIFAILUREINFO_missingTimeStamp 8 +# define OSSL_CMP_PKIFAILUREINFO_badPOP 9 +# define OSSL_CMP_PKIFAILUREINFO_certRevoked 10 +# define OSSL_CMP_PKIFAILUREINFO_certConfirmed 11 +# define OSSL_CMP_PKIFAILUREINFO_wrongIntegrity 12 +# define OSSL_CMP_PKIFAILUREINFO_badRecipientNonce 13 +# define OSSL_CMP_PKIFAILUREINFO_timeNotAvailable 14 +# define OSSL_CMP_PKIFAILUREINFO_unacceptedPolicy 15 +# define OSSL_CMP_PKIFAILUREINFO_unacceptedExtension 16 +# define OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable 17 +# define OSSL_CMP_PKIFAILUREINFO_badSenderNonce 18 +# define OSSL_CMP_PKIFAILUREINFO_badCertTemplate 19 +# define OSSL_CMP_PKIFAILUREINFO_signerNotTrusted 20 +# define OSSL_CMP_PKIFAILUREINFO_transactionIdInUse 21 +# define OSSL_CMP_PKIFAILUREINFO_unsupportedVersion 22 +# define OSSL_CMP_PKIFAILUREINFO_notAuthorized 23 +# define OSSL_CMP_PKIFAILUREINFO_systemUnavail 24 +# define OSSL_CMP_PKIFAILUREINFO_systemFailure 25 +# define OSSL_CMP_PKIFAILUREINFO_duplicateCertReq 26 +# define OSSL_CMP_PKIFAILUREINFO_MAX 26 +# define OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN \ + ((1 << (OSSL_CMP_PKIFAILUREINFO_MAX + 1)) - 1) +# if OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN > INT_MAX +# error CMP_PKIFAILUREINFO_MAX bit pattern does not fit in type int +# endif typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO; -# define OSSL_CMP_CTX_FAILINFO_badAlg (1 << 0) -# define OSSL_CMP_CTX_FAILINFO_badMessageCheck (1 << 1) -# define OSSL_CMP_CTX_FAILINFO_badRequest (1 << 2) -# define OSSL_CMP_CTX_FAILINFO_badTime (1 << 3) -# define OSSL_CMP_CTX_FAILINFO_badCertId (1 << 4) -# define OSSL_CMP_CTX_FAILINFO_badDataFormat (1 << 5) -# define OSSL_CMP_CTX_FAILINFO_wrongAuthority (1 << 6) -# define OSSL_CMP_CTX_FAILINFO_incorrectData (1 << 7) -# define OSSL_CMP_CTX_FAILINFO_missingTimeStamp (1 << 8) -# define OSSL_CMP_CTX_FAILINFO_badPOP (1 << 9) -# define OSSL_CMP_CTX_FAILINFO_certRevoked (1 << 10) -# define OSSL_CMP_CTX_FAILINFO_certConfirmed (1 << 11) -# define OSSL_CMP_CTX_FAILINFO_wrongIntegrity (1 << 12) -# define OSSL_CMP_CTX_FAILINFO_badRecipientNonce (1 << 13) -# define OSSL_CMP_CTX_FAILINFO_timeNotAvailable (1 << 14) -# define OSSL_CMP_CTX_FAILINFO_unacceptedPolicy (1 << 15) -# define OSSL_CMP_CTX_FAILINFO_unacceptedExtension (1 << 16) -# define OSSL_CMP_CTX_FAILINFO_addInfoNotAvailable (1 << 17) -# define OSSL_CMP_CTX_FAILINFO_badSenderNonce (1 << 18) -# define OSSL_CMP_CTX_FAILINFO_badCertTemplate (1 << 19) -# define OSSL_CMP_CTX_FAILINFO_signerNotTrusted (1 << 20) -# define OSSL_CMP_CTX_FAILINFO_transactionIdInUse (1 << 21) -# define OSSL_CMP_CTX_FAILINFO_unsupportedVersion (1 << 22) -# define OSSL_CMP_CTX_FAILINFO_notAuthorized (1 << 23) -# define OSSL_CMP_CTX_FAILINFO_systemUnavail (1 << 24) -# define OSSL_CMP_CTX_FAILINFO_systemFailure (1 << 25) -# define OSSL_CMP_CTX_FAILINFO_duplicateCertReq (1 << 26) +# define OSSL_CMP_CTX_FAILINFO_badAlg (1 << 0) +# define OSSL_CMP_CTX_FAILINFO_badMessageCheck (1 << 1) +# define OSSL_CMP_CTX_FAILINFO_badRequest (1 << 2) +# define OSSL_CMP_CTX_FAILINFO_badTime (1 << 3) +# define OSSL_CMP_CTX_FAILINFO_badCertId (1 << 4) +# define OSSL_CMP_CTX_FAILINFO_badDataFormat (1 << 5) +# define OSSL_CMP_CTX_FAILINFO_wrongAuthority (1 << 6) +# define OSSL_CMP_CTX_FAILINFO_incorrectData (1 << 7) +# define OSSL_CMP_CTX_FAILINFO_missingTimeStamp (1 << 8) +# define OSSL_CMP_CTX_FAILINFO_badPOP (1 << 9) +# define OSSL_CMP_CTX_FAILINFO_certRevoked (1 << 10) +# define OSSL_CMP_CTX_FAILINFO_certConfirmed (1 << 11) +# define OSSL_CMP_CTX_FAILINFO_wrongIntegrity (1 << 12) +# define OSSL_CMP_CTX_FAILINFO_badRecipientNonce (1 << 13) +# define OSSL_CMP_CTX_FAILINFO_timeNotAvailable (1 << 14) +# define OSSL_CMP_CTX_FAILINFO_unacceptedPolicy (1 << 15) +# define OSSL_CMP_CTX_FAILINFO_unacceptedExtension (1 << 16) +# define OSSL_CMP_CTX_FAILINFO_addInfoNotAvailable (1 << 17) +# define OSSL_CMP_CTX_FAILINFO_badSenderNonce (1 << 18) +# define OSSL_CMP_CTX_FAILINFO_badCertTemplate (1 << 19) +# define OSSL_CMP_CTX_FAILINFO_signerNotTrusted (1 << 20) +# define OSSL_CMP_CTX_FAILINFO_transactionIdInUse (1 << 21) +# define OSSL_CMP_CTX_FAILINFO_unsupportedVersion (1 << 22) +# define OSSL_CMP_CTX_FAILINFO_notAuthorized (1 << 23) +# define OSSL_CMP_CTX_FAILINFO_systemUnavail (1 << 24) +# define OSSL_CMP_CTX_FAILINFO_systemFailure (1 << 25) +# define OSSL_CMP_CTX_FAILINFO_duplicateCertReq (1 << 26) /*- * PKIStatus ::= INTEGER { @@ -192,22 +193,22 @@ typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO; * -- CertReqMsg * } */ -# define OSSL_CMP_PKISTATUS_request -3 -# define OSSL_CMP_PKISTATUS_trans -2 -# define OSSL_CMP_PKISTATUS_unspecified -1 -# define OSSL_CMP_PKISTATUS_accepted 0 -# define OSSL_CMP_PKISTATUS_grantedWithMods 1 -# define OSSL_CMP_PKISTATUS_rejection 2 -# define OSSL_CMP_PKISTATUS_waiting 3 -# define OSSL_CMP_PKISTATUS_revocationWarning 4 -# define OSSL_CMP_PKISTATUS_revocationNotification 5 -# define OSSL_CMP_PKISTATUS_keyUpdateWarning 6 +# define OSSL_CMP_PKISTATUS_request -3 +# define OSSL_CMP_PKISTATUS_trans -2 +# define OSSL_CMP_PKISTATUS_unspecified -1 +# define OSSL_CMP_PKISTATUS_accepted 0 +# define OSSL_CMP_PKISTATUS_grantedWithMods 1 +# define OSSL_CMP_PKISTATUS_rejection 2 +# define OSSL_CMP_PKISTATUS_waiting 3 +# define OSSL_CMP_PKISTATUS_revocationWarning 4 +# define OSSL_CMP_PKISTATUS_revocationNotification 5 +# define OSSL_CMP_PKISTATUS_keyUpdateWarning 6 typedef ASN1_INTEGER OSSL_CMP_PKISTATUS; DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS) -# define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0 -# define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1 +# define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0 +# define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1 /* data type declarations */ typedef struct ossl_cmp_ctx_st OSSL_CMP_CTX; @@ -217,349 +218,392 @@ typedef struct ossl_cmp_msg_st OSSL_CMP_MSG; DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG) DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG) typedef struct ossl_cmp_certstatus_st OSSL_CMP_CERTSTATUS; -SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS) -# define sk_OSSL_CMP_CERTSTATUS_num(sk) \ - OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk)) -# define sk_OSSL_CMP_CERTSTATUS_value(sk, idx) \ - ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - (idx))) -# define sk_OSSL_CMP_CERTSTATUS_new(cmp) \ - ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new( \ - ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp))) -# define sk_OSSL_CMP_CERTSTATUS_new_null() \ - ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CMP_CERTSTATUS_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp), (n))) -# define sk_OSSL_CMP_CERTSTATUS_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (n)) -# define sk_OSSL_CMP_CERTSTATUS_free(sk) \ - OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) -# define sk_OSSL_CMP_CERTSTATUS_zero(sk) \ - OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) -# define sk_OSSL_CMP_CERTSTATUS_delete(sk, i) \ - ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (i))) -# define sk_OSSL_CMP_CERTSTATUS_delete_ptr(sk, ptr) \ - ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr))) -# define sk_OSSL_CMP_CERTSTATUS_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) -# define sk_OSSL_CMP_CERTSTATUS_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) -# define sk_OSSL_CMP_CERTSTATUS_pop(sk) \ - ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk))) -# define sk_OSSL_CMP_CERTSTATUS_shift(sk) \ - ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk))) -# define sk_OSSL_CMP_CERTSTATUS_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_freefunc_type(freefunc)) -# define sk_OSSL_CMP_CERTSTATUS_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr), (idx)) -# define sk_OSSL_CMP_CERTSTATUS_set(sk, idx, ptr) \ - ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (idx), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr))) -# define sk_OSSL_CMP_CERTSTATUS_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) -# define sk_OSSL_CMP_CERTSTATUS_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) -# define sk_OSSL_CMP_CERTSTATUS_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_type(ptr), pnum) -# define sk_OSSL_CMP_CERTSTATUS_sort(sk) \ - OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) -# define sk_OSSL_CMP_CERTSTATUS_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk)) -# define sk_OSSL_CMP_CERTSTATUS_dup(sk) \ - ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_dup( \ - ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk))) -# define sk_OSSL_CMP_CERTSTATUS_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CMP_CERTSTATUS_freefunc_type(freefunc))) -# define sk_OSSL_CMP_CERTSTATUS_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CMP_CERTSTATUS_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTSTATUS, OSSL_CMP_CERTSTATUS, + OSSL_CMP_CERTSTATUS) +# define sk_OSSL_CMP_CERTSTATUS_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk)) +# define sk_OSSL_CMP_CERTSTATUS_value(sk, idx) \ + ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk), (idx))) +# define sk_OSSL_CMP_CERTSTATUS_new(cmp) \ + ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp))) +# define sk_OSSL_CMP_CERTSTATUS_new_null() \ + ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CMP_CERTSTATUS_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp), (n))) +# define sk_OSSL_CMP_CERTSTATUS_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (n)) +# define sk_OSSL_CMP_CERTSTATUS_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) +# define sk_OSSL_CMP_CERTSTATUS_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) +# define sk_OSSL_CMP_CERTSTATUS_delete(sk, i) \ + ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_delete( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (i))) +# define sk_OSSL_CMP_CERTSTATUS_delete_ptr(sk, ptr) \ + ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr))) +# define sk_OSSL_CMP_CERTSTATUS_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +# define sk_OSSL_CMP_CERTSTATUS_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +# define sk_OSSL_CMP_CERTSTATUS_pop(sk) \ + ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_pop( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk))) +# define sk_OSSL_CMP_CERTSTATUS_shift(sk) \ + ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_shift( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk))) +# define sk_OSSL_CMP_CERTSTATUS_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_freefunc_type(freefunc)) +# define sk_OSSL_CMP_CERTSTATUS_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr), (idx)) +# define sk_OSSL_CMP_CERTSTATUS_set(sk, idx, ptr) \ + ((OSSL_CMP_CERTSTATUS *)OPENSSL_sk_set( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), (idx), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr))) +# define sk_OSSL_CMP_CERTSTATUS_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +# define sk_OSSL_CMP_CERTSTATUS_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr)) +# define sk_OSSL_CMP_CERTSTATUS_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_type(ptr), pnum) +# define sk_OSSL_CMP_CERTSTATUS_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk)) +# define sk_OSSL_CMP_CERTSTATUS_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk)) +# define sk_OSSL_CMP_CERTSTATUS_dup(sk) \ + ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk))) +# define sk_OSSL_CMP_CERTSTATUS_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CMP_CERTSTATUS) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CMP_CERTSTATUS_freefunc_type(freefunc))) +# define sk_OSSL_CMP_CERTSTATUS_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CMP_CERTSTATUS_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CMP_CERTSTATUS_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTSTATUS_compfunc_type(cmp))) typedef struct ossl_cmp_itav_st OSSL_CMP_ITAV; DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV) SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_ITAV, OSSL_CMP_ITAV, OSSL_CMP_ITAV) -# define sk_OSSL_CMP_ITAV_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk)) -# define sk_OSSL_CMP_ITAV_value(sk, idx) \ - ((OSSL_CMP_ITAV *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk), (idx))) -# define sk_OSSL_CMP_ITAV_new(cmp) \ - ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp))) -# define sk_OSSL_CMP_ITAV_new_null() ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CMP_ITAV_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp), (n))) -# define sk_OSSL_CMP_ITAV_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (n)) -# define sk_OSSL_CMP_ITAV_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) -# define sk_OSSL_CMP_ITAV_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) -# define sk_OSSL_CMP_ITAV_delete(sk, i) \ - ((OSSL_CMP_ITAV *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (i))) -# define sk_OSSL_CMP_ITAV_delete_ptr(sk, ptr) \ - ((OSSL_CMP_ITAV *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ - ossl_check_OSSL_CMP_ITAV_type(ptr))) -# define sk_OSSL_CMP_ITAV_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) -# define sk_OSSL_CMP_ITAV_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) -# define sk_OSSL_CMP_ITAV_pop(sk) \ - ((OSSL_CMP_ITAV *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_ITAV_sk_type(sk))) -# define sk_OSSL_CMP_ITAV_shift(sk) \ - ((OSSL_CMP_ITAV *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_ITAV_sk_type(sk))) -# define sk_OSSL_CMP_ITAV_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ - ossl_check_OSSL_CMP_ITAV_freefunc_type(freefunc)) -# define sk_OSSL_CMP_ITAV_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ - ossl_check_OSSL_CMP_ITAV_type(ptr), (idx)) -# define sk_OSSL_CMP_ITAV_set(sk, idx, ptr) \ - ((OSSL_CMP_ITAV *)OPENSSL_sk_set(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (idx), \ - ossl_check_OSSL_CMP_ITAV_type(ptr))) -# define sk_OSSL_CMP_ITAV_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) -# define sk_OSSL_CMP_ITAV_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_type(ptr)) -# define sk_OSSL_CMP_ITAV_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ - ossl_check_OSSL_CMP_ITAV_type(ptr), pnum) -# define sk_OSSL_CMP_ITAV_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) -# define sk_OSSL_CMP_ITAV_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk)) -# define sk_OSSL_CMP_ITAV_dup(sk) \ - ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk))) -# define sk_OSSL_CMP_ITAV_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CMP_ITAV_sk_type(sk), \ - ossl_check_OSSL_CMP_ITAV_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CMP_ITAV_freefunc_type(freefunc))) -# define sk_OSSL_CMP_ITAV_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CMP_ITAV_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CMP_ITAV_sk_type(sk), ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp))) +# define sk_OSSL_CMP_ITAV_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk)) +# define sk_OSSL_CMP_ITAV_value(sk, idx) \ + ((OSSL_CMP_ITAV *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CMP_ITAV_sk_type(sk), (idx))) +# define sk_OSSL_CMP_ITAV_new(cmp) \ + ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp))) +# define sk_OSSL_CMP_ITAV_new_null() \ + ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CMP_ITAV_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp), (n))) +# define sk_OSSL_CMP_ITAV_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CMP_ITAV_sk_type(sk), (n)) +# define sk_OSSL_CMP_ITAV_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) +# define sk_OSSL_CMP_ITAV_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) +# define sk_OSSL_CMP_ITAV_delete(sk, i) \ + ((OSSL_CMP_ITAV *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + (i))) +# define sk_OSSL_CMP_ITAV_delete_ptr(sk, ptr) \ + ((OSSL_CMP_ITAV *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr))) +# define sk_OSSL_CMP_ITAV_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr)) +# define sk_OSSL_CMP_ITAV_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr)) +# define sk_OSSL_CMP_ITAV_pop(sk) \ + ((OSSL_CMP_ITAV *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_ITAV_sk_type(sk))) +# define sk_OSSL_CMP_ITAV_shift(sk) \ + ((OSSL_CMP_ITAV *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_ITAV_sk_type(sk))) +# define sk_OSSL_CMP_ITAV_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_freefunc_type(freefunc)) +# define sk_OSSL_CMP_ITAV_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr), (idx)) +# define sk_OSSL_CMP_ITAV_set(sk, idx, ptr) \ + ((OSSL_CMP_ITAV *)OPENSSL_sk_set(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + (idx), \ + ossl_check_OSSL_CMP_ITAV_type(ptr))) +# define sk_OSSL_CMP_ITAV_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr)) +# define sk_OSSL_CMP_ITAV_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr)) +# define sk_OSSL_CMP_ITAV_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_type(ptr), pnum) +# define sk_OSSL_CMP_ITAV_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CMP_ITAV_sk_type(sk)) +# define sk_OSSL_CMP_ITAV_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_ITAV_sk_type(sk)) +# define sk_OSSL_CMP_ITAV_dup(sk) \ + ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CMP_ITAV_sk_type(sk))) +# define sk_OSSL_CMP_ITAV_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CMP_ITAV) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CMP_ITAV_freefunc_type(freefunc))) +# define sk_OSSL_CMP_ITAV_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CMP_ITAV_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CMP_ITAV_sk_type(sk), \ + ossl_check_OSSL_CMP_ITAV_compfunc_type(cmp))) typedef struct ossl_cmp_revrepcontent_st OSSL_CMP_REVREPCONTENT; typedef struct ossl_cmp_pkisi_st OSSL_CMP_PKISI; DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI) DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI) SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_PKISI, OSSL_CMP_PKISI, OSSL_CMP_PKISI) -# define sk_OSSL_CMP_PKISI_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk)) -# define sk_OSSL_CMP_PKISI_value(sk, idx) \ - ((OSSL_CMP_PKISI *)OPENSSL_sk_value(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk), (idx))) -# define sk_OSSL_CMP_PKISI_new(cmp) \ - ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new(ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp))) -# define sk_OSSL_CMP_PKISI_new_null() ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CMP_PKISI_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp), (n))) -# define sk_OSSL_CMP_PKISI_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (n)) -# define sk_OSSL_CMP_PKISI_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) -# define sk_OSSL_CMP_PKISI_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) -# define sk_OSSL_CMP_PKISI_delete(sk, i) \ - ((OSSL_CMP_PKISI *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (i))) -# define sk_OSSL_CMP_PKISI_delete_ptr(sk, ptr) \ - ((OSSL_CMP_PKISI *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_type(ptr))) -# define sk_OSSL_CMP_PKISI_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr)) -# define sk_OSSL_CMP_PKISI_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_type(ptr)) -# define sk_OSSL_CMP_PKISI_pop(sk) \ - ((OSSL_CMP_PKISI *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_PKISI_sk_type(sk))) -# define sk_OSSL_CMP_PKISI_shift(sk) \ - ((OSSL_CMP_PKISI *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_PKISI_sk_type(sk))) -# define sk_OSSL_CMP_PKISI_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_freefunc_type(freefunc)) -# define sk_OSSL_CMP_PKISI_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_type(ptr), (idx)) -# define sk_OSSL_CMP_PKISI_set(sk, idx, ptr) \ - ((OSSL_CMP_PKISI *)OPENSSL_sk_set(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (idx), \ - ossl_check_OSSL_CMP_PKISI_type(ptr))) -# define sk_OSSL_CMP_PKISI_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_type(ptr)) -# define sk_OSSL_CMP_PKISI_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_type(ptr)) -# define sk_OSSL_CMP_PKISI_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_type(ptr), pnum) -# define sk_OSSL_CMP_PKISI_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) -# define sk_OSSL_CMP_PKISI_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk)) -# define sk_OSSL_CMP_PKISI_dup(sk) \ - ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk))) -# define sk_OSSL_CMP_PKISI_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CMP_PKISI_sk_type(sk), \ - ossl_check_OSSL_CMP_PKISI_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CMP_PKISI_freefunc_type(freefunc))) -# define sk_OSSL_CMP_PKISI_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CMP_PKISI_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CMP_PKISI_sk_type(sk), ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp))) +# define sk_OSSL_CMP_PKISI_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk)) +# define sk_OSSL_CMP_PKISI_value(sk, idx) \ + ((OSSL_CMP_PKISI *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CMP_PKISI_sk_type(sk), (idx))) +# define sk_OSSL_CMP_PKISI_new(cmp) \ + ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp))) +# define sk_OSSL_CMP_PKISI_new_null() \ + ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CMP_PKISI_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp), (n))) +# define sk_OSSL_CMP_PKISI_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CMP_PKISI_sk_type(sk), (n)) +# define sk_OSSL_CMP_PKISI_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) +# define sk_OSSL_CMP_PKISI_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) +# define sk_OSSL_CMP_PKISI_delete(sk, i) \ + ((OSSL_CMP_PKISI *)OPENSSL_sk_delete( \ + ossl_check_OSSL_CMP_PKISI_sk_type(sk), (i))) +# define sk_OSSL_CMP_PKISI_delete_ptr(sk, ptr) \ + ((OSSL_CMP_PKISI *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr))) +# define sk_OSSL_CMP_PKISI_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr)) +# define sk_OSSL_CMP_PKISI_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr)) +# define sk_OSSL_CMP_PKISI_pop(sk) \ + ((OSSL_CMP_PKISI *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_PKISI_sk_type(sk))) +# define sk_OSSL_CMP_PKISI_shift(sk) \ + ((OSSL_CMP_PKISI *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_PKISI_sk_type(sk))) +# define sk_OSSL_CMP_PKISI_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_freefunc_type(freefunc)) +# define sk_OSSL_CMP_PKISI_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr), (idx)) +# define sk_OSSL_CMP_PKISI_set(sk, idx, ptr) \ + ((OSSL_CMP_PKISI *)OPENSSL_sk_set(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + (idx), \ + ossl_check_OSSL_CMP_PKISI_type(ptr))) +# define sk_OSSL_CMP_PKISI_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr)) +# define sk_OSSL_CMP_PKISI_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr)) +# define sk_OSSL_CMP_PKISI_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_type(ptr), pnum) +# define sk_OSSL_CMP_PKISI_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CMP_PKISI_sk_type(sk)) +# define sk_OSSL_CMP_PKISI_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_PKISI_sk_type(sk)) +# define sk_OSSL_CMP_PKISI_dup(sk) \ + ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CMP_PKISI_sk_type(sk))) +# define sk_OSSL_CMP_PKISI_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CMP_PKISI) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CMP_PKISI_freefunc_type(freefunc))) +# define sk_OSSL_CMP_PKISI_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CMP_PKISI_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CMP_PKISI_sk_type(sk), \ + ossl_check_OSSL_CMP_PKISI_compfunc_type(cmp))) typedef struct ossl_cmp_certrepmessage_st OSSL_CMP_CERTREPMESSAGE; SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTREPMESSAGE, OSSL_CMP_CERTREPMESSAGE, OSSL_CMP_CERTREPMESSAGE) -# define sk_OSSL_CMP_CERTREPMESSAGE_num(sk) \ - OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) -# define sk_OSSL_CMP_CERTREPMESSAGE_value(sk, idx) \ - ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_value( \ - ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (idx))) -# define sk_OSSL_CMP_CERTREPMESSAGE_new(cmp) \ - ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new( \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp))) -# define sk_OSSL_CMP_CERTREPMESSAGE_new_null() \ - ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CMP_CERTREPMESSAGE_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp), (n))) -# define sk_OSSL_CMP_CERTREPMESSAGE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (n)) -# define sk_OSSL_CMP_CERTREPMESSAGE_free(sk) \ - OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) -# define sk_OSSL_CMP_CERTREPMESSAGE_zero(sk) \ - OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) -# define sk_OSSL_CMP_CERTREPMESSAGE_delete(sk, i) \ - ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_delete( \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (i))) -# define sk_OSSL_CMP_CERTREPMESSAGE_delete_ptr(sk, ptr) \ - ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_delete_ptr( \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr))) -# define sk_OSSL_CMP_CERTREPMESSAGE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) -# define sk_OSSL_CMP_CERTREPMESSAGE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) -# define sk_OSSL_CMP_CERTREPMESSAGE_pop(sk) \ - ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) -# define sk_OSSL_CMP_CERTREPMESSAGE_shift(sk) \ - ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_shift( \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) -# define sk_OSSL_CMP_CERTREPMESSAGE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_freefunc_type(freefunc)) -# define sk_OSSL_CMP_CERTREPMESSAGE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr), (idx)) -# define sk_OSSL_CMP_CERTREPMESSAGE_set(sk, idx, ptr) \ - ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - (idx), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr))) -# define sk_OSSL_CMP_CERTREPMESSAGE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) -# define sk_OSSL_CMP_CERTREPMESSAGE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) -# define sk_OSSL_CMP_CERTREPMESSAGE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr), pnum) -# define sk_OSSL_CMP_CERTREPMESSAGE_sort(sk) \ - OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) -# define sk_OSSL_CMP_CERTREPMESSAGE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) -# define sk_OSSL_CMP_CERTREPMESSAGE_dup(sk) \ - ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_dup( \ - ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) -# define sk_OSSL_CMP_CERTREPMESSAGE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_freefunc_type(freefunc))) -# define sk_OSSL_CMP_CERTREPMESSAGE_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CMP_CERTREPMESSAGE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp))) +# define sk_OSSL_CMP_CERTREPMESSAGE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +# define sk_OSSL_CMP_CERTREPMESSAGE_value(sk, idx) \ + ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (idx))) +# define sk_OSSL_CMP_CERTREPMESSAGE_new(cmp) \ + ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp))) +# define sk_OSSL_CMP_CERTREPMESSAGE_new_null() \ + ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CMP_CERTREPMESSAGE_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp), (n))) +# define sk_OSSL_CMP_CERTREPMESSAGE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (n)) +# define sk_OSSL_CMP_CERTREPMESSAGE_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +# define sk_OSSL_CMP_CERTREPMESSAGE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +# define sk_OSSL_CMP_CERTREPMESSAGE_delete(sk, i) \ + ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_delete( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (i))) +# define sk_OSSL_CMP_CERTREPMESSAGE_delete_ptr(sk, ptr) \ + ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr))) +# define sk_OSSL_CMP_CERTREPMESSAGE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +# define sk_OSSL_CMP_CERTREPMESSAGE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +# define sk_OSSL_CMP_CERTREPMESSAGE_pop(sk) \ + ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_pop( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) +# define sk_OSSL_CMP_CERTREPMESSAGE_shift(sk) \ + ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_shift( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) +# define sk_OSSL_CMP_CERTREPMESSAGE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_freefunc_type(freefunc)) +# define sk_OSSL_CMP_CERTREPMESSAGE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr), (idx)) +# define sk_OSSL_CMP_CERTREPMESSAGE_set(sk, idx, ptr) \ + ((OSSL_CMP_CERTREPMESSAGE *)OPENSSL_sk_set( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), (idx), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr))) +# define sk_OSSL_CMP_CERTREPMESSAGE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +# define sk_OSSL_CMP_CERTREPMESSAGE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr)) +# define sk_OSSL_CMP_CERTREPMESSAGE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_type(ptr), pnum) +# define sk_OSSL_CMP_CERTREPMESSAGE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +# define sk_OSSL_CMP_CERTREPMESSAGE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk)) +# define sk_OSSL_CMP_CERTREPMESSAGE_dup(sk) \ + ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk))) +# define sk_OSSL_CMP_CERTREPMESSAGE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CMP_CERTREPMESSAGE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_freefunc_type(freefunc))) +# define sk_OSSL_CMP_CERTREPMESSAGE_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CMP_CERTREPMESSAGE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTREPMESSAGE_compfunc_type(cmp))) typedef struct ossl_cmp_pollrep_st OSSL_CMP_POLLREP; typedef STACK_OF(OSSL_CMP_POLLREP) OSSL_CMP_POLLREPCONTENT; typedef struct ossl_cmp_certresponse_st OSSL_CMP_CERTRESPONSE; -SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTRESPONSE, OSSL_CMP_CERTRESPONSE, OSSL_CMP_CERTRESPONSE) -# define sk_OSSL_CMP_CERTRESPONSE_num(sk) \ - OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk)) -# define sk_OSSL_CMP_CERTRESPONSE_value(sk, idx) \ - ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_value( \ - ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk), (idx))) -# define sk_OSSL_CMP_CERTRESPONSE_new(cmp) \ - ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new( \ - ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp))) -# define sk_OSSL_CMP_CERTRESPONSE_new_null() \ - ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CMP_CERTRESPONSE_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp), (n))) -# define sk_OSSL_CMP_CERTRESPONSE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (n)) -# define sk_OSSL_CMP_CERTRESPONSE_free(sk) \ - OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) -# define sk_OSSL_CMP_CERTRESPONSE_zero(sk) \ - OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) -# define sk_OSSL_CMP_CERTRESPONSE_delete(sk, i) \ - ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_delete(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - (i))) -# define sk_OSSL_CMP_CERTRESPONSE_delete_ptr(sk, ptr) \ - ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_delete_ptr( \ - ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr))) -# define sk_OSSL_CMP_CERTRESPONSE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) -# define sk_OSSL_CMP_CERTRESPONSE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) -# define sk_OSSL_CMP_CERTRESPONSE_pop(sk) \ - ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_pop(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk))) -# define sk_OSSL_CMP_CERTRESPONSE_shift(sk) \ - ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_shift(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk))) -# define sk_OSSL_CMP_CERTRESPONSE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_freefunc_type(freefunc)) -# define sk_OSSL_CMP_CERTRESPONSE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr), (idx)) -# define sk_OSSL_CMP_CERTRESPONSE_set(sk, idx, ptr) \ - ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_set(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - (idx), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr))) -# define sk_OSSL_CMP_CERTRESPONSE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) -# define sk_OSSL_CMP_CERTRESPONSE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) -# define sk_OSSL_CMP_CERTRESPONSE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr), pnum) -# define sk_OSSL_CMP_CERTRESPONSE_sort(sk) \ - OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) -# define sk_OSSL_CMP_CERTRESPONSE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk)) -# define sk_OSSL_CMP_CERTRESPONSE_dup(sk) \ - ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_dup( \ - ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk))) -# define sk_OSSL_CMP_CERTRESPONSE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CMP_CERTRESPONSE_freefunc_type(freefunc))) -# define sk_OSSL_CMP_CERTRESPONSE_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CMP_CERTRESPONSE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ - ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CMP_CERTRESPONSE, OSSL_CMP_CERTRESPONSE, + OSSL_CMP_CERTRESPONSE) +# define sk_OSSL_CMP_CERTRESPONSE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +# define sk_OSSL_CMP_CERTRESPONSE_value(sk, idx) \ + ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk), (idx))) +# define sk_OSSL_CMP_CERTRESPONSE_new(cmp) \ + ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp))) +# define sk_OSSL_CMP_CERTRESPONSE_new_null() \ + ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CMP_CERTRESPONSE_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp), (n))) +# define sk_OSSL_CMP_CERTRESPONSE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (n)) +# define sk_OSSL_CMP_CERTRESPONSE_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +# define sk_OSSL_CMP_CERTRESPONSE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +# define sk_OSSL_CMP_CERTRESPONSE_delete(sk, i) \ + ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_delete( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (i))) +# define sk_OSSL_CMP_CERTRESPONSE_delete_ptr(sk, ptr) \ + ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr))) +# define sk_OSSL_CMP_CERTRESPONSE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +# define sk_OSSL_CMP_CERTRESPONSE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +# define sk_OSSL_CMP_CERTRESPONSE_pop(sk) \ + ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_pop( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk))) +# define sk_OSSL_CMP_CERTRESPONSE_shift(sk) \ + ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_shift( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk))) +# define sk_OSSL_CMP_CERTRESPONSE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_freefunc_type(freefunc)) +# define sk_OSSL_CMP_CERTRESPONSE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr), (idx)) +# define sk_OSSL_CMP_CERTRESPONSE_set(sk, idx, ptr) \ + ((OSSL_CMP_CERTRESPONSE *)OPENSSL_sk_set( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), (idx), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr))) +# define sk_OSSL_CMP_CERTRESPONSE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +# define sk_OSSL_CMP_CERTRESPONSE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr)) +# define sk_OSSL_CMP_CERTRESPONSE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_type(ptr), pnum) +# define sk_OSSL_CMP_CERTRESPONSE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +# define sk_OSSL_CMP_CERTRESPONSE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk)) +# define sk_OSSL_CMP_CERTRESPONSE_dup(sk) \ + ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk))) +# define sk_OSSL_CMP_CERTRESPONSE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CMP_CERTRESPONSE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CMP_CERTRESPONSE_freefunc_type(freefunc))) +# define sk_OSSL_CMP_CERTRESPONSE_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CMP_CERTRESPONSE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CMP_CERTRESPONSE_sk_type(sk), \ + ossl_check_OSSL_CMP_CERTRESPONSE_compfunc_type(cmp))) typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT; @@ -569,10 +613,12 @@ typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT; /* from cmp_asn.c */ OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); -void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, ASN1_TYPE *value); +void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, + ASN1_TYPE *value); ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav); ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav); -int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) * *itav_sk_p, OSSL_CMP_ITAV *itav); +int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) * *itav_sk_p, + OSSL_CMP_ITAV *itav); void OSSL_CMP_ITAV_free(OSSL_CMP_ITAV *itav); void OSSL_CMP_MSG_free(OSSL_CMP_MSG *msg); @@ -583,34 +629,34 @@ int OSSL_CMP_CTX_reinit(OSSL_CMP_CTX *ctx); OSSL_LIB_CTX *OSSL_CMP_CTX_get0_libctx(const OSSL_CMP_CTX *ctx); const char *OSSL_CMP_CTX_get0_propq(const OSSL_CMP_CTX *ctx); /* CMP general options: */ -# define OSSL_CMP_OPT_LOG_VERBOSITY 0 +# define OSSL_CMP_OPT_LOG_VERBOSITY 0 /* CMP transfer options: */ -# define OSSL_CMP_OPT_KEEP_ALIVE 10 -# define OSSL_CMP_OPT_MSG_TIMEOUT 11 -# define OSSL_CMP_OPT_TOTAL_TIMEOUT 12 +# define OSSL_CMP_OPT_KEEP_ALIVE 10 +# define OSSL_CMP_OPT_MSG_TIMEOUT 11 +# define OSSL_CMP_OPT_TOTAL_TIMEOUT 12 /* CMP request options: */ -# define OSSL_CMP_OPT_VALIDITY_DAYS 20 -# define OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT 21 -# define OSSL_CMP_OPT_SUBJECTALTNAME_CRITICAL 22 -# define OSSL_CMP_OPT_POLICIES_CRITICAL 23 -# define OSSL_CMP_OPT_POPO_METHOD 24 -# define OSSL_CMP_OPT_IMPLICIT_CONFIRM 25 -# define OSSL_CMP_OPT_DISABLE_CONFIRM 26 -# define OSSL_CMP_OPT_REVOCATION_REASON 27 +# define OSSL_CMP_OPT_VALIDITY_DAYS 20 +# define OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT 21 +# define OSSL_CMP_OPT_SUBJECTALTNAME_CRITICAL 22 +# define OSSL_CMP_OPT_POLICIES_CRITICAL 23 +# define OSSL_CMP_OPT_POPO_METHOD 24 +# define OSSL_CMP_OPT_IMPLICIT_CONFIRM 25 +# define OSSL_CMP_OPT_DISABLE_CONFIRM 26 +# define OSSL_CMP_OPT_REVOCATION_REASON 27 /* CMP protection options: */ -# define OSSL_CMP_OPT_UNPROTECTED_SEND 30 -# define OSSL_CMP_OPT_UNPROTECTED_ERRORS 31 -# define OSSL_CMP_OPT_OWF_ALGNID 32 -# define OSSL_CMP_OPT_MAC_ALGNID 33 -# define OSSL_CMP_OPT_DIGEST_ALGNID 34 -# define OSSL_CMP_OPT_IGNORE_KEYUSAGE 35 -# define OSSL_CMP_OPT_PERMIT_TA_IN_EXTRACERTS_FOR_IR 36 +# define OSSL_CMP_OPT_UNPROTECTED_SEND 30 +# define OSSL_CMP_OPT_UNPROTECTED_ERRORS 31 +# define OSSL_CMP_OPT_OWF_ALGNID 32 +# define OSSL_CMP_OPT_MAC_ALGNID 33 +# define OSSL_CMP_OPT_DIGEST_ALGNID 34 +# define OSSL_CMP_OPT_IGNORE_KEYUSAGE 35 +# define OSSL_CMP_OPT_PERMIT_TA_IN_EXTRACERTS_FOR_IR 36 int OSSL_CMP_CTX_set_option(OSSL_CMP_CTX *ctx, int opt, int val); int OSSL_CMP_CTX_get_option(const OSSL_CMP_CTX *ctx, int opt); /* CMP-specific callback for logging and outputting the error queue: */ int OSSL_CMP_CTX_set_log_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_log_cb_t cb); -# define OSSL_CMP_CTX_set_log_verbosity(ctx, level) \ - OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_LOG_VERBOSITY, level) +# define OSSL_CMP_CTX_set_log_verbosity(ctx, level) \ + OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_LOG_VERBOSITY, level) void OSSL_CMP_CTX_print_errors(const OSSL_CMP_CTX *ctx); /* message transfer: */ int OSSL_CMP_CTX_set1_serverPath(OSSL_CMP_CTX *ctx, const char *path); @@ -621,7 +667,8 @@ int OSSL_CMP_CTX_set1_no_proxy(OSSL_CMP_CTX *ctx, const char *names); int OSSL_CMP_CTX_set_http_cb(OSSL_CMP_CTX *ctx, OSSL_HTTP_bio_cb_t cb); int OSSL_CMP_CTX_set_http_cb_arg(OSSL_CMP_CTX *ctx, void *arg); void *OSSL_CMP_CTX_get_http_cb_arg(const OSSL_CMP_CTX *ctx); -typedef OSSL_CMP_MSG *(*OSSL_CMP_transfer_cb_t)(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req); +typedef OSSL_CMP_MSG *(*OSSL_CMP_transfer_cb_t)(OSSL_CMP_CTX *ctx, + const OSSL_CMP_MSG *req); int OSSL_CMP_CTX_set_transfer_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_transfer_cb_t cb); int OSSL_CMP_CTX_set_transfer_cb_arg(OSSL_CMP_CTX *ctx, void *arg); void *OSSL_CMP_CTX_get_transfer_cb_arg(const OSSL_CMP_CTX *ctx); @@ -629,9 +676,9 @@ void *OSSL_CMP_CTX_get_transfer_cb_arg(const OSSL_CMP_CTX *ctx); int OSSL_CMP_CTX_set1_srvCert(OSSL_CMP_CTX *ctx, X509 *cert); int OSSL_CMP_CTX_set1_expected_sender(OSSL_CMP_CTX *ctx, const X509_NAME *name); int OSSL_CMP_CTX_set0_trustedStore(OSSL_CMP_CTX *ctx, X509_STORE *store); -# define OSSL_CMP_CTX_set0_trusted OSSL_CMP_CTX_set0_trustedStore +# define OSSL_CMP_CTX_set0_trusted OSSL_CMP_CTX_set0_trustedStore X509_STORE *OSSL_CMP_CTX_get0_trustedStore(const OSSL_CMP_CTX *ctx); -# define OSSL_CMP_CTX_get0_trusted OSSL_CMP_CTX_get0_trustedStore +# define OSSL_CMP_CTX_get0_trusted OSSL_CMP_CTX_get0_trustedStore int OSSL_CMP_CTX_set1_untrusted(OSSL_CMP_CTX *ctx, STACK_OF(X509) * certs); STACK_OF(X509) * OSSL_CMP_CTX_get0_untrusted(const OSSL_CMP_CTX *ctx); /* client authentication: */ @@ -639,19 +686,23 @@ int OSSL_CMP_CTX_set1_cert(OSSL_CMP_CTX *ctx, X509 *cert); int OSSL_CMP_CTX_build_cert_chain(OSSL_CMP_CTX *ctx, X509_STORE *own_trusted, STACK_OF(X509) * candidates); int OSSL_CMP_CTX_set1_pkey(OSSL_CMP_CTX *ctx, EVP_PKEY *pkey); -int OSSL_CMP_CTX_set1_referenceValue(OSSL_CMP_CTX *ctx, const unsigned char *ref, int len); -int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx, const unsigned char *sec, const int len); +int OSSL_CMP_CTX_set1_referenceValue(OSSL_CMP_CTX *ctx, + const unsigned char *ref, int len); +int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx, const unsigned char *sec, + const int len); /* CMP message header and extra certificates: */ int OSSL_CMP_CTX_set1_recipient(OSSL_CMP_CTX *ctx, const X509_NAME *name); int OSSL_CMP_CTX_push0_geninfo_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav); int OSSL_CMP_CTX_reset_geninfo_ITAVs(OSSL_CMP_CTX *ctx); -int OSSL_CMP_CTX_set1_extraCertsOut(OSSL_CMP_CTX *ctx, STACK_OF(X509) * extraCertsOut); +int OSSL_CMP_CTX_set1_extraCertsOut(OSSL_CMP_CTX *ctx, + STACK_OF(X509) * extraCertsOut); /* certificate template: */ int OSSL_CMP_CTX_set0_newPkey(OSSL_CMP_CTX *ctx, int priv, EVP_PKEY *pkey); EVP_PKEY *OSSL_CMP_CTX_get0_newPkey(const OSSL_CMP_CTX *ctx, int priv); int OSSL_CMP_CTX_set1_issuer(OSSL_CMP_CTX *ctx, const X509_NAME *name); int OSSL_CMP_CTX_set1_subjectName(OSSL_CMP_CTX *ctx, const X509_NAME *name); -int OSSL_CMP_CTX_push1_subjectAltName(OSSL_CMP_CTX *ctx, const GENERAL_NAME *name); +int OSSL_CMP_CTX_push1_subjectAltName(OSSL_CMP_CTX *ctx, + const GENERAL_NAME *name); int OSSL_CMP_CTX_set0_reqExtensions(OSSL_CMP_CTX *ctx, X509_EXTENSIONS *exts); int OSSL_CMP_CTX_reqExtensions_have_SAN(OSSL_CMP_CTX *ctx); int OSSL_CMP_CTX_push0_policy(OSSL_CMP_CTX *ctx, POLICYINFO *pinfo); @@ -660,9 +711,10 @@ int OSSL_CMP_CTX_set1_p10CSR(OSSL_CMP_CTX *ctx, const X509_REQ *csr); /* misc body contents: */ int OSSL_CMP_CTX_push0_genm_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav); /* certificate confirmation: */ -typedef int (*OSSL_CMP_certConf_cb_t)(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info, - const char **txt); -int OSSL_CMP_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info, const char **text); +typedef int (*OSSL_CMP_certConf_cb_t)(OSSL_CMP_CTX *ctx, X509 *cert, + int fail_info, const char **txt); +int OSSL_CMP_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info, + const char **text); int OSSL_CMP_CTX_set_certConf_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_certConf_cb_t cb); int OSSL_CMP_CTX_set_certConf_cb_arg(OSSL_CMP_CTX *ctx, void *arg); void *OSSL_CMP_CTX_get_certConf_cb_arg(const OSSL_CMP_CTX *ctx); @@ -670,22 +722,28 @@ void *OSSL_CMP_CTX_get_certConf_cb_arg(const OSSL_CMP_CTX *ctx); int OSSL_CMP_CTX_get_status(const OSSL_CMP_CTX *ctx); OSSL_CMP_PKIFREETEXT *OSSL_CMP_CTX_get0_statusString(const OSSL_CMP_CTX *ctx); int OSSL_CMP_CTX_get_failInfoCode(const OSSL_CMP_CTX *ctx); -# define OSSL_CMP_PKISI_BUFLEN 1024 +# define OSSL_CMP_PKISI_BUFLEN 1024 X509 *OSSL_CMP_CTX_get0_validatedSrvCert(const OSSL_CMP_CTX *ctx); X509 *OSSL_CMP_CTX_get0_newCert(const OSSL_CMP_CTX *ctx); STACK_OF(X509) * OSSL_CMP_CTX_get1_newChain(const OSSL_CMP_CTX *ctx); STACK_OF(X509) * OSSL_CMP_CTX_get1_caPubs(const OSSL_CMP_CTX *ctx); STACK_OF(X509) * OSSL_CMP_CTX_get1_extraCertsIn(const OSSL_CMP_CTX *ctx); -int OSSL_CMP_CTX_set1_transactionID(OSSL_CMP_CTX *ctx, const ASN1_OCTET_STRING *id); -int OSSL_CMP_CTX_set1_senderNonce(OSSL_CMP_CTX *ctx, const ASN1_OCTET_STRING *nonce); +int OSSL_CMP_CTX_set1_transactionID(OSSL_CMP_CTX *ctx, + const ASN1_OCTET_STRING *id); +int OSSL_CMP_CTX_set1_senderNonce(OSSL_CMP_CTX *ctx, + const ASN1_OCTET_STRING *nonce); /* from cmp_status.c */ -char *OSSL_CMP_CTX_snprint_PKIStatus(const OSSL_CMP_CTX *ctx, char *buf, size_t bufsize); -char *OSSL_CMP_snprint_PKIStatusInfo(const OSSL_CMP_PKISI *statusInfo, char *buf, size_t bufsize); -OSSL_CMP_PKISI *OSSL_CMP_STATUSINFO_new(int status, int fail_info, const char *text); +char *OSSL_CMP_CTX_snprint_PKIStatus(const OSSL_CMP_CTX *ctx, char *buf, + size_t bufsize); +char *OSSL_CMP_snprint_PKIStatusInfo(const OSSL_CMP_PKISI *statusInfo, + char *buf, size_t bufsize); +OSSL_CMP_PKISI *OSSL_CMP_STATUSINFO_new(int status, int fail_info, + const char *text); /* from cmp_hdr.c */ -ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_transactionID(const OSSL_CMP_PKIHEADER *hdr); +ASN1_OCTET_STRING * +OSSL_CMP_HDR_get0_transactionID(const OSSL_CMP_PKIHEADER *hdr); ASN1_OCTET_STRING *OSSL_CMP_HDR_get0_recipNonce(const OSSL_CMP_PKIHEADER *hdr); /* from cmp_msg.c */ @@ -693,73 +751,93 @@ OSSL_CMP_PKIHEADER *OSSL_CMP_MSG_get0_header(const OSSL_CMP_MSG *msg); int OSSL_CMP_MSG_get_bodytype(const OSSL_CMP_MSG *msg); int OSSL_CMP_MSG_update_transactionID(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg); OSSL_CRMF_MSG *OSSL_CMP_CTX_setup_CRM(OSSL_CMP_CTX *ctx, int for_KUR, int rid); -OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx, const char *propq); +OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx, + const char *propq); int OSSL_CMP_MSG_write(const char *file, const OSSL_CMP_MSG *msg); OSSL_CMP_MSG *d2i_OSSL_CMP_MSG_bio(BIO *bio, OSSL_CMP_MSG **msg); int i2d_OSSL_CMP_MSG_bio(BIO *bio, const OSSL_CMP_MSG *msg); /* from cmp_vfy.c */ int OSSL_CMP_validate_msg(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg); -int OSSL_CMP_validate_cert_path(const OSSL_CMP_CTX *ctx, X509_STORE *trusted_store, X509 *cert); +int OSSL_CMP_validate_cert_path(const OSSL_CMP_CTX *ctx, + X509_STORE *trusted_store, X509 *cert); /* from cmp_http.c */ -OSSL_CMP_MSG *OSSL_CMP_MSG_http_perform(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req); +OSSL_CMP_MSG *OSSL_CMP_MSG_http_perform(OSSL_CMP_CTX *ctx, + const OSSL_CMP_MSG *req); /* from cmp_server.c */ typedef struct ossl_cmp_srv_ctx_st OSSL_CMP_SRV_CTX; -OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req); -OSSL_CMP_MSG *OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx, const OSSL_CMP_MSG *req); +OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req); +OSSL_CMP_MSG *OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx, + const OSSL_CMP_MSG *req); OSSL_CMP_SRV_CTX *OSSL_CMP_SRV_CTX_new(OSSL_LIB_CTX *libctx, const char *propq); void OSSL_CMP_SRV_CTX_free(OSSL_CMP_SRV_CTX *srv_ctx); typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_cert_request_cb_t)( - OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, int certReqId, const OSSL_CRMF_MSG *crm, - const X509_REQ *p10cr, X509 **certOut, STACK_OF(X509) * *chainOut, STACK_OF(X509) * *caPubs); -typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_rr_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, + OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, int certReqId, + const OSSL_CRMF_MSG *crm, const X509_REQ *p10cr, X509 **certOut, + STACK_OF(X509) * *chainOut, STACK_OF(X509) * *caPubs); +typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_rr_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, const X509_NAME *issuer, const ASN1_INTEGER *serial); -typedef int (*OSSL_CMP_SRV_genm_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, +typedef int (*OSSL_CMP_SRV_genm_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, const STACK_OF(OSSL_CMP_ITAV) * in, STACK_OF(OSSL_CMP_ITAV) * *out); -typedef void (*OSSL_CMP_SRV_error_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, +typedef void (*OSSL_CMP_SRV_error_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, const OSSL_CMP_PKISI *statusInfo, const ASN1_INTEGER *errorCode, const OSSL_CMP_PKIFREETEXT *errDetails); -typedef int (*OSSL_CMP_SRV_certConf_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, - int certReqId, const ASN1_OCTET_STRING *certHash, +typedef int (*OSSL_CMP_SRV_certConf_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, + int certReqId, + const ASN1_OCTET_STRING *certHash, const OSSL_CMP_PKISI *si); -typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, const OSSL_CMP_MSG *req, - int certReqId, OSSL_CMP_MSG **certReq, +typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx, + const OSSL_CMP_MSG *req, int certReqId, + OSSL_CMP_MSG **certReq, int64_t *check_after); int OSSL_CMP_SRV_CTX_init(OSSL_CMP_SRV_CTX *srv_ctx, void *custom_ctx, OSSL_CMP_SRV_cert_request_cb_t process_cert_request, - OSSL_CMP_SRV_rr_cb_t process_rr, OSSL_CMP_SRV_genm_cb_t process_genm, + OSSL_CMP_SRV_rr_cb_t process_rr, + OSSL_CMP_SRV_genm_cb_t process_genm, OSSL_CMP_SRV_error_cb_t process_error, OSSL_CMP_SRV_certConf_cb_t process_certConf, OSSL_CMP_SRV_pollReq_cb_t process_pollReq); OSSL_CMP_CTX *OSSL_CMP_SRV_CTX_get0_cmp_ctx(const OSSL_CMP_SRV_CTX *srv_ctx); void *OSSL_CMP_SRV_CTX_get0_custom_ctx(const OSSL_CMP_SRV_CTX *srv_ctx); -int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx, int val); +int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx, + int val); int OSSL_CMP_SRV_CTX_set_accept_unprotected(OSSL_CMP_SRV_CTX *srv_ctx, int val); int OSSL_CMP_SRV_CTX_set_accept_raverified(OSSL_CMP_SRV_CTX *srv_ctx, int val); -int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx, int val); +int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx, + int val); /* from cmp_client.c */ -X509 *OSSL_CMP_exec_certreq(OSSL_CMP_CTX *ctx, int req_type, const OSSL_CRMF_MSG *crm); -# define OSSL_CMP_IR 0 -# define OSSL_CMP_CR 2 -# define OSSL_CMP_P10CR 4 -# define OSSL_CMP_KUR 7 -# define OSSL_CMP_exec_IR_ses(ctx) OSSL_CMP_exec_certreq(ctx, OSSL_CMP_IR, NULL) -# define OSSL_CMP_exec_CR_ses(ctx) OSSL_CMP_exec_certreq(ctx, OSSL_CMP_CR, NULL) -# define OSSL_CMP_exec_P10CR_ses(ctx) OSSL_CMP_exec_certreq(ctx, OSSL_CMP_P10CR, NULL) -# define OSSL_CMP_exec_KUR_ses(ctx) OSSL_CMP_exec_certreq(ctx, OSSL_CMP_KUR, NULL) -int OSSL_CMP_try_certreq(OSSL_CMP_CTX *ctx, int req_type, const OSSL_CRMF_MSG *crm, - int *checkAfter); +X509 *OSSL_CMP_exec_certreq(OSSL_CMP_CTX *ctx, int req_type, + const OSSL_CRMF_MSG *crm); +# define OSSL_CMP_IR 0 +# define OSSL_CMP_CR 2 +# define OSSL_CMP_P10CR 4 +# define OSSL_CMP_KUR 7 +# define OSSL_CMP_exec_IR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_IR, NULL) +# define OSSL_CMP_exec_CR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_CR, NULL) +# define OSSL_CMP_exec_P10CR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_P10CR, NULL) +# define OSSL_CMP_exec_KUR_ses(ctx) \ + OSSL_CMP_exec_certreq(ctx, OSSL_CMP_KUR, NULL) +int OSSL_CMP_try_certreq(OSSL_CMP_CTX *ctx, int req_type, + const OSSL_CRMF_MSG *crm, int *checkAfter); int OSSL_CMP_exec_RR_ses(OSSL_CMP_CTX *ctx); STACK_OF(OSSL_CMP_ITAV) * OSSL_CMP_exec_GENM_ses(OSSL_CMP_CTX *ctx); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* !defined(OPENSSL_NO_CMP) */ #endif /* !defined(OPENSSL_CMP_H) */ diff --git a/libs/OpenSSL/include/openssl/cmp_util.h b/libs/OpenSSL/include/openssl/cmp_util.h index 0d35432e..67d9f9d1 100644 --- a/libs/OpenSSL/include/openssl/cmp_util.h +++ b/libs/OpenSSL/include/openssl/cmp_util.h @@ -16,41 +16,41 @@ #include #ifndef OPENSSL_NO_CMP -# include -# include +# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif int OSSL_CMP_log_open(void); void OSSL_CMP_log_close(void); -# define OSSL_CMP_LOG_PREFIX "CMP " +# define OSSL_CMP_LOG_PREFIX "CMP " /* * generalized logging/error callback mirroring the severity levels of syslog.h */ typedef int OSSL_CMP_severity; -# define OSSL_CMP_LOG_EMERG 0 -# define OSSL_CMP_LOG_ALERT 1 -# define OSSL_CMP_LOG_CRIT 2 -# define OSSL_CMP_LOG_ERR 3 -# define OSSL_CMP_LOG_WARNING 4 -# define OSSL_CMP_LOG_NOTICE 5 -# define OSSL_CMP_LOG_INFO 6 -# define OSSL_CMP_LOG_DEBUG 7 -# define OSSL_CMP_LOG_TRACE 8 -# define OSSL_CMP_LOG_MAX OSSL_CMP_LOG_TRACE +# define OSSL_CMP_LOG_EMERG 0 +# define OSSL_CMP_LOG_ALERT 1 +# define OSSL_CMP_LOG_CRIT 2 +# define OSSL_CMP_LOG_ERR 3 +# define OSSL_CMP_LOG_WARNING 4 +# define OSSL_CMP_LOG_NOTICE 5 +# define OSSL_CMP_LOG_INFO 6 +# define OSSL_CMP_LOG_DEBUG 7 +# define OSSL_CMP_LOG_TRACE 8 +# define OSSL_CMP_LOG_MAX OSSL_CMP_LOG_TRACE typedef int (*OSSL_CMP_log_cb_t)(const char *func, const char *file, int line, OSSL_CMP_severity level, const char *msg); -int OSSL_CMP_print_to_bio(BIO *bio, const char *component, const char *file, int line, - OSSL_CMP_severity level, const char *msg); +int OSSL_CMP_print_to_bio(BIO *bio, const char *component, const char *file, + int line, OSSL_CMP_severity level, const char *msg); /* use of the logging callback for outputting error queue */ void OSSL_CMP_print_errors_cb(OSSL_CMP_log_cb_t log_fn); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* !defined(OPENSSL_NO_CMP) */ #endif /* !defined(OPENSSL_CMP_UTIL_H) */ diff --git a/libs/OpenSSL/include/openssl/cmperr.h b/libs/OpenSSL/include/openssl/cmperr.h index eaea6071..378ed683 100644 --- a/libs/OpenSSL/include/openssl/cmperr.h +++ b/libs/OpenSSL/include/openssl/cmperr.h @@ -21,92 +21,92 @@ /* * CMP reason codes. */ -# define CMP_R_ALGORITHM_NOT_SUPPORTED 139 -# define CMP_R_BAD_CHECKAFTER_IN_POLLREP 167 -# define CMP_R_BAD_REQUEST_ID 108 -# define CMP_R_CERTHASH_UNMATCHED 156 -# define CMP_R_CERTID_NOT_FOUND 109 -# define CMP_R_CERTIFICATE_NOT_ACCEPTED 169 -# define CMP_R_CERTIFICATE_NOT_FOUND 112 -# define CMP_R_CERTREQMSG_NOT_FOUND 157 -# define CMP_R_CERTRESPONSE_NOT_FOUND 113 -# define CMP_R_CERT_AND_KEY_DO_NOT_MATCH 114 -# define CMP_R_CHECKAFTER_OUT_OF_RANGE 181 -# define CMP_R_ENCOUNTERED_KEYUPDATEWARNING 176 -# define CMP_R_ENCOUNTERED_WAITING 162 -# define CMP_R_ERROR_CALCULATING_PROTECTION 115 -# define CMP_R_ERROR_CREATING_CERTCONF 116 -# define CMP_R_ERROR_CREATING_CERTREP 117 -# define CMP_R_ERROR_CREATING_CERTREQ 163 -# define CMP_R_ERROR_CREATING_ERROR 118 -# define CMP_R_ERROR_CREATING_GENM 119 -# define CMP_R_ERROR_CREATING_GENP 120 -# define CMP_R_ERROR_CREATING_PKICONF 122 -# define CMP_R_ERROR_CREATING_POLLREP 123 -# define CMP_R_ERROR_CREATING_POLLREQ 124 -# define CMP_R_ERROR_CREATING_RP 125 -# define CMP_R_ERROR_CREATING_RR 126 -# define CMP_R_ERROR_PARSING_PKISTATUS 107 -# define CMP_R_ERROR_PROCESSING_MESSAGE 158 -# define CMP_R_ERROR_PROTECTING_MESSAGE 127 -# define CMP_R_ERROR_SETTING_CERTHASH 128 -# define CMP_R_ERROR_UNEXPECTED_CERTCONF 160 -# define CMP_R_ERROR_VALIDATING_PROTECTION 140 -# define CMP_R_ERROR_VALIDATING_SIGNATURE 171 -# define CMP_R_FAILED_BUILDING_OWN_CHAIN 164 -# define CMP_R_FAILED_EXTRACTING_PUBKEY 141 -# define CMP_R_FAILURE_OBTAINING_RANDOM 110 -# define CMP_R_FAIL_INFO_OUT_OF_RANGE 129 -# define CMP_R_INVALID_ARGS 100 -# define CMP_R_INVALID_OPTION 174 -# define CMP_R_MISSING_CERTID 165 -# define CMP_R_MISSING_KEY_INPUT_FOR_CREATING_PROTECTION 130 -# define CMP_R_MISSING_KEY_USAGE_DIGITALSIGNATURE 142 -# define CMP_R_MISSING_P10CSR 121 -# define CMP_R_MISSING_PBM_SECRET 166 -# define CMP_R_MISSING_PRIVATE_KEY 131 -# define CMP_R_MISSING_PROTECTION 143 -# define CMP_R_MISSING_REFERENCE_CERT 168 -# define CMP_R_MISSING_SECRET 178 -# define CMP_R_MISSING_SENDER_IDENTIFICATION 111 -# define CMP_R_MISSING_TRUST_ANCHOR 179 -# define CMP_R_MISSING_TRUST_STORE 144 -# define CMP_R_MULTIPLE_REQUESTS_NOT_SUPPORTED 161 -# define CMP_R_MULTIPLE_RESPONSES_NOT_SUPPORTED 170 -# define CMP_R_MULTIPLE_SAN_SOURCES 102 -# define CMP_R_NO_STDIO 194 -# define CMP_R_NO_SUITABLE_SENDER_CERT 145 -# define CMP_R_NULL_ARGUMENT 103 -# define CMP_R_PKIBODY_ERROR 146 -# define CMP_R_PKISTATUSINFO_NOT_FOUND 132 -# define CMP_R_POLLING_FAILED 172 -# define CMP_R_POTENTIALLY_INVALID_CERTIFICATE 147 -# define CMP_R_RECEIVED_ERROR 180 -# define CMP_R_RECIPNONCE_UNMATCHED 148 -# define CMP_R_REQUEST_NOT_ACCEPTED 149 -# define CMP_R_REQUEST_REJECTED_BY_SERVER 182 -# define CMP_R_SENDER_GENERALNAME_TYPE_NOT_SUPPORTED 150 -# define CMP_R_SRVCERT_DOES_NOT_VALIDATE_MSG 151 -# define CMP_R_TOTAL_TIMEOUT 184 -# define CMP_R_TRANSACTIONID_UNMATCHED 152 -# define CMP_R_TRANSFER_ERROR 159 -# define CMP_R_UNEXPECTED_PKIBODY 133 -# define CMP_R_UNEXPECTED_PKISTATUS 185 -# define CMP_R_UNEXPECTED_PVNO 153 -# define CMP_R_UNKNOWN_ALGORITHM_ID 134 -# define CMP_R_UNKNOWN_CERT_TYPE 135 -# define CMP_R_UNKNOWN_PKISTATUS 186 -# define CMP_R_UNSUPPORTED_ALGORITHM 136 -# define CMP_R_UNSUPPORTED_KEY_TYPE 137 -# define CMP_R_UNSUPPORTED_PROTECTION_ALG_DHBASEDMAC 154 -# define CMP_R_VALUE_TOO_LARGE 175 -# define CMP_R_VALUE_TOO_SMALL 177 -# define CMP_R_WRONG_ALGORITHM_OID 138 -# define CMP_R_WRONG_CERTID 189 -# define CMP_R_WRONG_CERTID_IN_RP 187 -# define CMP_R_WRONG_PBM_VALUE 155 -# define CMP_R_WRONG_RP_COMPONENT_COUNT 188 -# define CMP_R_WRONG_SERIAL_IN_RP 173 +# define CMP_R_ALGORITHM_NOT_SUPPORTED 139 +# define CMP_R_BAD_CHECKAFTER_IN_POLLREP 167 +# define CMP_R_BAD_REQUEST_ID 108 +# define CMP_R_CERTHASH_UNMATCHED 156 +# define CMP_R_CERTID_NOT_FOUND 109 +# define CMP_R_CERTIFICATE_NOT_ACCEPTED 169 +# define CMP_R_CERTIFICATE_NOT_FOUND 112 +# define CMP_R_CERTREQMSG_NOT_FOUND 157 +# define CMP_R_CERTRESPONSE_NOT_FOUND 113 +# define CMP_R_CERT_AND_KEY_DO_NOT_MATCH 114 +# define CMP_R_CHECKAFTER_OUT_OF_RANGE 181 +# define CMP_R_ENCOUNTERED_KEYUPDATEWARNING 176 +# define CMP_R_ENCOUNTERED_WAITING 162 +# define CMP_R_ERROR_CALCULATING_PROTECTION 115 +# define CMP_R_ERROR_CREATING_CERTCONF 116 +# define CMP_R_ERROR_CREATING_CERTREP 117 +# define CMP_R_ERROR_CREATING_CERTREQ 163 +# define CMP_R_ERROR_CREATING_ERROR 118 +# define CMP_R_ERROR_CREATING_GENM 119 +# define CMP_R_ERROR_CREATING_GENP 120 +# define CMP_R_ERROR_CREATING_PKICONF 122 +# define CMP_R_ERROR_CREATING_POLLREP 123 +# define CMP_R_ERROR_CREATING_POLLREQ 124 +# define CMP_R_ERROR_CREATING_RP 125 +# define CMP_R_ERROR_CREATING_RR 126 +# define CMP_R_ERROR_PARSING_PKISTATUS 107 +# define CMP_R_ERROR_PROCESSING_MESSAGE 158 +# define CMP_R_ERROR_PROTECTING_MESSAGE 127 +# define CMP_R_ERROR_SETTING_CERTHASH 128 +# define CMP_R_ERROR_UNEXPECTED_CERTCONF 160 +# define CMP_R_ERROR_VALIDATING_PROTECTION 140 +# define CMP_R_ERROR_VALIDATING_SIGNATURE 171 +# define CMP_R_FAILED_BUILDING_OWN_CHAIN 164 +# define CMP_R_FAILED_EXTRACTING_PUBKEY 141 +# define CMP_R_FAILURE_OBTAINING_RANDOM 110 +# define CMP_R_FAIL_INFO_OUT_OF_RANGE 129 +# define CMP_R_INVALID_ARGS 100 +# define CMP_R_INVALID_OPTION 174 +# define CMP_R_MISSING_CERTID 165 +# define CMP_R_MISSING_KEY_INPUT_FOR_CREATING_PROTECTION 130 +# define CMP_R_MISSING_KEY_USAGE_DIGITALSIGNATURE 142 +# define CMP_R_MISSING_P10CSR 121 +# define CMP_R_MISSING_PBM_SECRET 166 +# define CMP_R_MISSING_PRIVATE_KEY 131 +# define CMP_R_MISSING_PROTECTION 143 +# define CMP_R_MISSING_REFERENCE_CERT 168 +# define CMP_R_MISSING_SECRET 178 +# define CMP_R_MISSING_SENDER_IDENTIFICATION 111 +# define CMP_R_MISSING_TRUST_ANCHOR 179 +# define CMP_R_MISSING_TRUST_STORE 144 +# define CMP_R_MULTIPLE_REQUESTS_NOT_SUPPORTED 161 +# define CMP_R_MULTIPLE_RESPONSES_NOT_SUPPORTED 170 +# define CMP_R_MULTIPLE_SAN_SOURCES 102 +# define CMP_R_NO_STDIO 194 +# define CMP_R_NO_SUITABLE_SENDER_CERT 145 +# define CMP_R_NULL_ARGUMENT 103 +# define CMP_R_PKIBODY_ERROR 146 +# define CMP_R_PKISTATUSINFO_NOT_FOUND 132 +# define CMP_R_POLLING_FAILED 172 +# define CMP_R_POTENTIALLY_INVALID_CERTIFICATE 147 +# define CMP_R_RECEIVED_ERROR 180 +# define CMP_R_RECIPNONCE_UNMATCHED 148 +# define CMP_R_REQUEST_NOT_ACCEPTED 149 +# define CMP_R_REQUEST_REJECTED_BY_SERVER 182 +# define CMP_R_SENDER_GENERALNAME_TYPE_NOT_SUPPORTED 150 +# define CMP_R_SRVCERT_DOES_NOT_VALIDATE_MSG 151 +# define CMP_R_TOTAL_TIMEOUT 184 +# define CMP_R_TRANSACTIONID_UNMATCHED 152 +# define CMP_R_TRANSFER_ERROR 159 +# define CMP_R_UNEXPECTED_PKIBODY 133 +# define CMP_R_UNEXPECTED_PKISTATUS 185 +# define CMP_R_UNEXPECTED_PVNO 153 +# define CMP_R_UNKNOWN_ALGORITHM_ID 134 +# define CMP_R_UNKNOWN_CERT_TYPE 135 +# define CMP_R_UNKNOWN_PKISTATUS 186 +# define CMP_R_UNSUPPORTED_ALGORITHM 136 +# define CMP_R_UNSUPPORTED_KEY_TYPE 137 +# define CMP_R_UNSUPPORTED_PROTECTION_ALG_DHBASEDMAC 154 +# define CMP_R_VALUE_TOO_LARGE 175 +# define CMP_R_VALUE_TOO_SMALL 177 +# define CMP_R_WRONG_ALGORITHM_OID 138 +# define CMP_R_WRONG_CERTID 189 +# define CMP_R_WRONG_CERTID_IN_RP 187 +# define CMP_R_WRONG_PBM_VALUE 155 +# define CMP_R_WRONG_RP_COMPONENT_COUNT 188 +# define CMP_R_WRONG_SERIAL_IN_RP 173 #endif #endif diff --git a/libs/OpenSSL/include/openssl/cms.h b/libs/OpenSSL/include/openssl/cms.h index 51ad4104..6aab0382 100644 --- a/libs/OpenSSL/include/openssl/cms.h +++ b/libs/OpenSSL/include/openssl/cms.h @@ -16,18 +16,18 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CMS_H +# define HEADER_CMS_H #endif #include #ifndef OPENSSL_NO_CMS -# include -# include -# include -# ifdef __cplusplus +# include +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif typedef struct CMS_EnvelopedData_st CMS_EnvelopedData; typedef struct CMS_ContentInfo_st CMS_ContentInfo; @@ -42,278 +42,305 @@ typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey; typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute; SKM_DEFINE_STACK_OF_INTERNAL(CMS_SignerInfo, CMS_SignerInfo, CMS_SignerInfo) -# define sk_CMS_SignerInfo_num(sk) OPENSSL_sk_num(ossl_check_const_CMS_SignerInfo_sk_type(sk)) -# define sk_CMS_SignerInfo_value(sk, idx) \ - ((CMS_SignerInfo *)OPENSSL_sk_value(ossl_check_const_CMS_SignerInfo_sk_type(sk), (idx))) -# define sk_CMS_SignerInfo_new(cmp) \ - ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new(ossl_check_CMS_SignerInfo_compfunc_type(cmp))) -# define sk_CMS_SignerInfo_new_null() ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new_null()) -# define sk_CMS_SignerInfo_new_reserve(cmp, n) \ - ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new_reserve( \ - ossl_check_CMS_SignerInfo_compfunc_type(cmp), (n))) -# define sk_CMS_SignerInfo_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_CMS_SignerInfo_sk_type(sk), (n)) -# define sk_CMS_SignerInfo_free(sk) OPENSSL_sk_free(ossl_check_CMS_SignerInfo_sk_type(sk)) -# define sk_CMS_SignerInfo_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_SignerInfo_sk_type(sk)) -# define sk_CMS_SignerInfo_delete(sk, i) \ - ((CMS_SignerInfo *)OPENSSL_sk_delete(ossl_check_CMS_SignerInfo_sk_type(sk), (i))) -# define sk_CMS_SignerInfo_delete_ptr(sk, ptr) \ - ((CMS_SignerInfo *)OPENSSL_sk_delete_ptr(ossl_check_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_type(ptr))) -# define sk_CMS_SignerInfo_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr)) -# define sk_CMS_SignerInfo_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_type(ptr)) -# define sk_CMS_SignerInfo_pop(sk) \ - ((CMS_SignerInfo *)OPENSSL_sk_pop(ossl_check_CMS_SignerInfo_sk_type(sk))) -# define sk_CMS_SignerInfo_shift(sk) \ - ((CMS_SignerInfo *)OPENSSL_sk_shift(ossl_check_CMS_SignerInfo_sk_type(sk))) -# define sk_CMS_SignerInfo_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_freefunc_type(freefunc)) -# define sk_CMS_SignerInfo_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_type(ptr), (idx)) -# define sk_CMS_SignerInfo_set(sk, idx, ptr) \ - ((CMS_SignerInfo *)OPENSSL_sk_set(ossl_check_CMS_SignerInfo_sk_type(sk), (idx), \ - ossl_check_CMS_SignerInfo_type(ptr))) -# define sk_CMS_SignerInfo_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_type(ptr)) -# define sk_CMS_SignerInfo_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_type(ptr)) -# define sk_CMS_SignerInfo_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_type(ptr), pnum) -# define sk_CMS_SignerInfo_sort(sk) OPENSSL_sk_sort(ossl_check_CMS_SignerInfo_sk_type(sk)) -# define sk_CMS_SignerInfo_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_CMS_SignerInfo_sk_type(sk)) -# define sk_CMS_SignerInfo_dup(sk) \ - ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_dup(ossl_check_const_CMS_SignerInfo_sk_type(sk))) -# define sk_CMS_SignerInfo_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_CMS_SignerInfo_sk_type(sk), \ - ossl_check_CMS_SignerInfo_copyfunc_type(copyfunc), \ - ossl_check_CMS_SignerInfo_freefunc_type(freefunc))) -# define sk_CMS_SignerInfo_set_cmp_func(sk, cmp) \ - ((sk_CMS_SignerInfo_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_CMS_SignerInfo_sk_type(sk), ossl_check_CMS_SignerInfo_compfunc_type(cmp))) -SKM_DEFINE_STACK_OF_INTERNAL(CMS_RecipientEncryptedKey, CMS_RecipientEncryptedKey, +# define sk_CMS_SignerInfo_num(sk) \ + OPENSSL_sk_num(ossl_check_const_CMS_SignerInfo_sk_type(sk)) +# define sk_CMS_SignerInfo_value(sk, idx) \ + ((CMS_SignerInfo *)OPENSSL_sk_value( \ + ossl_check_const_CMS_SignerInfo_sk_type(sk), (idx))) +# define sk_CMS_SignerInfo_new(cmp) \ + ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new( \ + ossl_check_CMS_SignerInfo_compfunc_type(cmp))) +# define sk_CMS_SignerInfo_new_null() \ + ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new_null()) +# define sk_CMS_SignerInfo_new_reserve(cmp, n) \ + ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_new_reserve( \ + ossl_check_CMS_SignerInfo_compfunc_type(cmp), (n))) +# define sk_CMS_SignerInfo_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_CMS_SignerInfo_sk_type(sk), (n)) +# define sk_CMS_SignerInfo_free(sk) \ + OPENSSL_sk_free(ossl_check_CMS_SignerInfo_sk_type(sk)) +# define sk_CMS_SignerInfo_zero(sk) \ + OPENSSL_sk_zero(ossl_check_CMS_SignerInfo_sk_type(sk)) +# define sk_CMS_SignerInfo_delete(sk, i) \ + ((CMS_SignerInfo *)OPENSSL_sk_delete( \ + ossl_check_CMS_SignerInfo_sk_type(sk), (i))) +# define sk_CMS_SignerInfo_delete_ptr(sk, ptr) \ + ((CMS_SignerInfo *)OPENSSL_sk_delete_ptr( \ + ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr))) +# define sk_CMS_SignerInfo_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr)) +# define sk_CMS_SignerInfo_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr)) +# define sk_CMS_SignerInfo_pop(sk) \ + ((CMS_SignerInfo *)OPENSSL_sk_pop(ossl_check_CMS_SignerInfo_sk_type(sk))) +# define sk_CMS_SignerInfo_shift(sk) \ + ((CMS_SignerInfo *)OPENSSL_sk_shift(ossl_check_CMS_SignerInfo_sk_type(sk))) +# define sk_CMS_SignerInfo_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_freefunc_type(freefunc)) +# define sk_CMS_SignerInfo_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr), (idx)) +# define sk_CMS_SignerInfo_set(sk, idx, ptr) \ + ((CMS_SignerInfo *)OPENSSL_sk_set(ossl_check_CMS_SignerInfo_sk_type(sk), \ + (idx), \ + ossl_check_CMS_SignerInfo_type(ptr))) +# define sk_CMS_SignerInfo_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr)) +# define sk_CMS_SignerInfo_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr)) +# define sk_CMS_SignerInfo_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_type(ptr), pnum) +# define sk_CMS_SignerInfo_sort(sk) \ + OPENSSL_sk_sort(ossl_check_CMS_SignerInfo_sk_type(sk)) +# define sk_CMS_SignerInfo_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_CMS_SignerInfo_sk_type(sk)) +# define sk_CMS_SignerInfo_dup(sk) \ + ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_dup( \ + ossl_check_const_CMS_SignerInfo_sk_type(sk))) +# define sk_CMS_SignerInfo_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(CMS_SignerInfo) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_copyfunc_type(copyfunc), \ + ossl_check_CMS_SignerInfo_freefunc_type(freefunc))) +# define sk_CMS_SignerInfo_set_cmp_func(sk, cmp) \ + ((sk_CMS_SignerInfo_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_CMS_SignerInfo_sk_type(sk), \ + ossl_check_CMS_SignerInfo_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(CMS_RecipientEncryptedKey, + CMS_RecipientEncryptedKey, CMS_RecipientEncryptedKey) -# define sk_CMS_RecipientEncryptedKey_num(sk) \ - OPENSSL_sk_num(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk)) -# define sk_CMS_RecipientEncryptedKey_value(sk, idx) \ - ((CMS_RecipientEncryptedKey *)OPENSSL_sk_value( \ - ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk), (idx))) -# define sk_CMS_RecipientEncryptedKey_new(cmp) \ - ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new( \ - ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp))) -# define sk_CMS_RecipientEncryptedKey_new_null() \ - ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new_null()) -# define sk_CMS_RecipientEncryptedKey_new_reserve(cmp, n) \ - ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new_reserve( \ - ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp), (n))) -# define sk_CMS_RecipientEncryptedKey_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (n)) -# define sk_CMS_RecipientEncryptedKey_free(sk) \ - OPENSSL_sk_free(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) -# define sk_CMS_RecipientEncryptedKey_zero(sk) \ - OPENSSL_sk_zero(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) -# define sk_CMS_RecipientEncryptedKey_delete(sk, i) \ - ((CMS_RecipientEncryptedKey *)OPENSSL_sk_delete( \ - ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (i))) -# define sk_CMS_RecipientEncryptedKey_delete_ptr(sk, ptr) \ - ((CMS_RecipientEncryptedKey *)OPENSSL_sk_delete_ptr( \ - ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr))) -# define sk_CMS_RecipientEncryptedKey_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr)) -# define sk_CMS_RecipientEncryptedKey_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr)) -# define sk_CMS_RecipientEncryptedKey_pop(sk) \ - ((CMS_RecipientEncryptedKey *)OPENSSL_sk_pop( \ - ossl_check_CMS_RecipientEncryptedKey_sk_type(sk))) -# define sk_CMS_RecipientEncryptedKey_shift(sk) \ - ((CMS_RecipientEncryptedKey *)OPENSSL_sk_shift( \ - ossl_check_CMS_RecipientEncryptedKey_sk_type(sk))) -# define sk_CMS_RecipientEncryptedKey_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_freefunc_type(freefunc)) -# define sk_CMS_RecipientEncryptedKey_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr), (idx)) -# define sk_CMS_RecipientEncryptedKey_set(sk, idx, ptr) \ - ((CMS_RecipientEncryptedKey *)OPENSSL_sk_set( \ - ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (idx), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr))) -# define sk_CMS_RecipientEncryptedKey_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr)) -# define sk_CMS_RecipientEncryptedKey_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr)) -# define sk_CMS_RecipientEncryptedKey_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_type(ptr), pnum) -# define sk_CMS_RecipientEncryptedKey_sort(sk) \ - OPENSSL_sk_sort(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) -# define sk_CMS_RecipientEncryptedKey_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk)) -# define sk_CMS_RecipientEncryptedKey_dup(sk) \ - ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_dup( \ - ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk))) -# define sk_CMS_RecipientEncryptedKey_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_copyfunc_type(copyfunc), \ - ossl_check_CMS_RecipientEncryptedKey_freefunc_type(freefunc))) -# define sk_CMS_RecipientEncryptedKey_set_cmp_func(sk, cmp) \ - ((sk_CMS_RecipientEncryptedKey_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ - ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp))) -SKM_DEFINE_STACK_OF_INTERNAL(CMS_RecipientInfo, CMS_RecipientInfo, CMS_RecipientInfo) -# define sk_CMS_RecipientInfo_num(sk) \ - OPENSSL_sk_num(ossl_check_const_CMS_RecipientInfo_sk_type(sk)) -# define sk_CMS_RecipientInfo_value(sk, idx) \ - ((CMS_RecipientInfo *)OPENSSL_sk_value(ossl_check_const_CMS_RecipientInfo_sk_type(sk), \ - (idx))) -# define sk_CMS_RecipientInfo_new(cmp) \ - ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new( \ - ossl_check_CMS_RecipientInfo_compfunc_type(cmp))) -# define sk_CMS_RecipientInfo_new_null() ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new_null()) -# define sk_CMS_RecipientInfo_new_reserve(cmp, n) \ - ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new_reserve( \ - ossl_check_CMS_RecipientInfo_compfunc_type(cmp), (n))) -# define sk_CMS_RecipientInfo_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_CMS_RecipientInfo_sk_type(sk), (n)) -# define sk_CMS_RecipientInfo_free(sk) OPENSSL_sk_free(ossl_check_CMS_RecipientInfo_sk_type(sk)) -# define sk_CMS_RecipientInfo_zero(sk) OPENSSL_sk_zero(ossl_check_CMS_RecipientInfo_sk_type(sk)) -# define sk_CMS_RecipientInfo_delete(sk, i) \ - ((CMS_RecipientInfo *)OPENSSL_sk_delete(ossl_check_CMS_RecipientInfo_sk_type(sk), (i))) -# define sk_CMS_RecipientInfo_delete_ptr(sk, ptr) \ - ((CMS_RecipientInfo *)OPENSSL_sk_delete_ptr(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr))) -# define sk_CMS_RecipientInfo_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr)) -# define sk_CMS_RecipientInfo_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr)) -# define sk_CMS_RecipientInfo_pop(sk) \ - ((CMS_RecipientInfo *)OPENSSL_sk_pop(ossl_check_CMS_RecipientInfo_sk_type(sk))) -# define sk_CMS_RecipientInfo_shift(sk) \ - ((CMS_RecipientInfo *)OPENSSL_sk_shift(ossl_check_CMS_RecipientInfo_sk_type(sk))) -# define sk_CMS_RecipientInfo_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_freefunc_type(freefunc)) -# define sk_CMS_RecipientInfo_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr), (idx)) -# define sk_CMS_RecipientInfo_set(sk, idx, ptr) \ - ((CMS_RecipientInfo *)OPENSSL_sk_set(ossl_check_CMS_RecipientInfo_sk_type(sk), (idx), \ - ossl_check_CMS_RecipientInfo_type(ptr))) -# define sk_CMS_RecipientInfo_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr)) -# define sk_CMS_RecipientInfo_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr)) -# define sk_CMS_RecipientInfo_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_type(ptr), pnum) -# define sk_CMS_RecipientInfo_sort(sk) OPENSSL_sk_sort(ossl_check_CMS_RecipientInfo_sk_type(sk)) -# define sk_CMS_RecipientInfo_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_CMS_RecipientInfo_sk_type(sk)) -# define sk_CMS_RecipientInfo_dup(sk) \ - ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_dup( \ - ossl_check_const_CMS_RecipientInfo_sk_type(sk))) -# define sk_CMS_RecipientInfo_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_copyfunc_type(copyfunc), \ - ossl_check_CMS_RecipientInfo_freefunc_type(freefunc))) -# define sk_CMS_RecipientInfo_set_cmp_func(sk, cmp) \ - ((sk_CMS_RecipientInfo_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_CMS_RecipientInfo_sk_type(sk), \ - ossl_check_CMS_RecipientInfo_compfunc_type(cmp))) +# define sk_CMS_RecipientEncryptedKey_num(sk) \ + OPENSSL_sk_num(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk)) +# define sk_CMS_RecipientEncryptedKey_value(sk, idx) \ + ((CMS_RecipientEncryptedKey *)OPENSSL_sk_value( \ + ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk), (idx))) +# define sk_CMS_RecipientEncryptedKey_new(cmp) \ + ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new( \ + ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp))) +# define sk_CMS_RecipientEncryptedKey_new_null() \ + ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new_null()) +# define sk_CMS_RecipientEncryptedKey_new_reserve(cmp, n) \ + ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_new_reserve( \ + ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp), (n))) +# define sk_CMS_RecipientEncryptedKey_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (n)) +# define sk_CMS_RecipientEncryptedKey_free(sk) \ + OPENSSL_sk_free(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) +# define sk_CMS_RecipientEncryptedKey_zero(sk) \ + OPENSSL_sk_zero(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) +# define sk_CMS_RecipientEncryptedKey_delete(sk, i) \ + ((CMS_RecipientEncryptedKey *)OPENSSL_sk_delete( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (i))) +# define sk_CMS_RecipientEncryptedKey_delete_ptr(sk, ptr) \ + ((CMS_RecipientEncryptedKey *)OPENSSL_sk_delete_ptr( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr))) +# define sk_CMS_RecipientEncryptedKey_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +# define sk_CMS_RecipientEncryptedKey_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +# define sk_CMS_RecipientEncryptedKey_pop(sk) \ + ((CMS_RecipientEncryptedKey *)OPENSSL_sk_pop( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk))) +# define sk_CMS_RecipientEncryptedKey_shift(sk) \ + ((CMS_RecipientEncryptedKey *)OPENSSL_sk_shift( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk))) +# define sk_CMS_RecipientEncryptedKey_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_freefunc_type(freefunc)) +# define sk_CMS_RecipientEncryptedKey_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr), (idx)) +# define sk_CMS_RecipientEncryptedKey_set(sk, idx, ptr) \ + ((CMS_RecipientEncryptedKey *)OPENSSL_sk_set( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), (idx), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr))) +# define sk_CMS_RecipientEncryptedKey_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +# define sk_CMS_RecipientEncryptedKey_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr)) +# define sk_CMS_RecipientEncryptedKey_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_type(ptr), pnum) +# define sk_CMS_RecipientEncryptedKey_sort(sk) \ + OPENSSL_sk_sort(ossl_check_CMS_RecipientEncryptedKey_sk_type(sk)) +# define sk_CMS_RecipientEncryptedKey_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk)) +# define sk_CMS_RecipientEncryptedKey_dup(sk) \ + ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_dup( \ + ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk))) +# define sk_CMS_RecipientEncryptedKey_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(CMS_RecipientEncryptedKey) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_copyfunc_type(copyfunc), \ + ossl_check_CMS_RecipientEncryptedKey_freefunc_type(freefunc))) +# define sk_CMS_RecipientEncryptedKey_set_cmp_func(sk, cmp) \ + ((sk_CMS_RecipientEncryptedKey_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_CMS_RecipientEncryptedKey_sk_type(sk), \ + ossl_check_CMS_RecipientEncryptedKey_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(CMS_RecipientInfo, CMS_RecipientInfo, + CMS_RecipientInfo) +# define sk_CMS_RecipientInfo_num(sk) \ + OPENSSL_sk_num(ossl_check_const_CMS_RecipientInfo_sk_type(sk)) +# define sk_CMS_RecipientInfo_value(sk, idx) \ + ((CMS_RecipientInfo *)OPENSSL_sk_value( \ + ossl_check_const_CMS_RecipientInfo_sk_type(sk), (idx))) +# define sk_CMS_RecipientInfo_new(cmp) \ + ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new( \ + ossl_check_CMS_RecipientInfo_compfunc_type(cmp))) +# define sk_CMS_RecipientInfo_new_null() \ + ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new_null()) +# define sk_CMS_RecipientInfo_new_reserve(cmp, n) \ + ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_new_reserve( \ + ossl_check_CMS_RecipientInfo_compfunc_type(cmp), (n))) +# define sk_CMS_RecipientInfo_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_CMS_RecipientInfo_sk_type(sk), (n)) +# define sk_CMS_RecipientInfo_free(sk) \ + OPENSSL_sk_free(ossl_check_CMS_RecipientInfo_sk_type(sk)) +# define sk_CMS_RecipientInfo_zero(sk) \ + OPENSSL_sk_zero(ossl_check_CMS_RecipientInfo_sk_type(sk)) +# define sk_CMS_RecipientInfo_delete(sk, i) \ + ((CMS_RecipientInfo *)OPENSSL_sk_delete( \ + ossl_check_CMS_RecipientInfo_sk_type(sk), (i))) +# define sk_CMS_RecipientInfo_delete_ptr(sk, ptr) \ + ((CMS_RecipientInfo *)OPENSSL_sk_delete_ptr( \ + ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr))) +# define sk_CMS_RecipientInfo_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr)) +# define sk_CMS_RecipientInfo_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr)) +# define sk_CMS_RecipientInfo_pop(sk) \ + ((CMS_RecipientInfo *)OPENSSL_sk_pop( \ + ossl_check_CMS_RecipientInfo_sk_type(sk))) +# define sk_CMS_RecipientInfo_shift(sk) \ + ((CMS_RecipientInfo *)OPENSSL_sk_shift( \ + ossl_check_CMS_RecipientInfo_sk_type(sk))) +# define sk_CMS_RecipientInfo_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_freefunc_type(freefunc)) +# define sk_CMS_RecipientInfo_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr), (idx)) +# define sk_CMS_RecipientInfo_set(sk, idx, ptr) \ + ((CMS_RecipientInfo *)OPENSSL_sk_set( \ + ossl_check_CMS_RecipientInfo_sk_type(sk), (idx), \ + ossl_check_CMS_RecipientInfo_type(ptr))) +# define sk_CMS_RecipientInfo_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr)) +# define sk_CMS_RecipientInfo_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr)) +# define sk_CMS_RecipientInfo_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_type(ptr), pnum) +# define sk_CMS_RecipientInfo_sort(sk) \ + OPENSSL_sk_sort(ossl_check_CMS_RecipientInfo_sk_type(sk)) +# define sk_CMS_RecipientInfo_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_CMS_RecipientInfo_sk_type(sk)) +# define sk_CMS_RecipientInfo_dup(sk) \ + ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_dup( \ + ossl_check_const_CMS_RecipientInfo_sk_type(sk))) +# define sk_CMS_RecipientInfo_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(CMS_RecipientInfo) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_copyfunc_type(copyfunc), \ + ossl_check_CMS_RecipientInfo_freefunc_type(freefunc))) +# define sk_CMS_RecipientInfo_set_cmp_func(sk, cmp) \ + ((sk_CMS_RecipientInfo_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_CMS_RecipientInfo_sk_type(sk), \ + ossl_check_CMS_RecipientInfo_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(CMS_RevocationInfoChoice, CMS_RevocationInfoChoice, CMS_RevocationInfoChoice) -# define sk_CMS_RevocationInfoChoice_num(sk) \ - OPENSSL_sk_num(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk)) -# define sk_CMS_RevocationInfoChoice_value(sk, idx) \ - ((CMS_RevocationInfoChoice *)OPENSSL_sk_value( \ - ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk), (idx))) -# define sk_CMS_RevocationInfoChoice_new(cmp) \ - ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new( \ - ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp))) -# define sk_CMS_RevocationInfoChoice_new_null() \ - ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new_null()) -# define sk_CMS_RevocationInfoChoice_new_reserve(cmp, n) \ - ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new_reserve( \ - ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp), (n))) -# define sk_CMS_RevocationInfoChoice_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (n)) -# define sk_CMS_RevocationInfoChoice_free(sk) \ - OPENSSL_sk_free(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) -# define sk_CMS_RevocationInfoChoice_zero(sk) \ - OPENSSL_sk_zero(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) -# define sk_CMS_RevocationInfoChoice_delete(sk, i) \ - ((CMS_RevocationInfoChoice *)OPENSSL_sk_delete( \ - ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (i))) -# define sk_CMS_RevocationInfoChoice_delete_ptr(sk, ptr) \ - ((CMS_RevocationInfoChoice *)OPENSSL_sk_delete_ptr( \ - ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr))) -# define sk_CMS_RevocationInfoChoice_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr)) -# define sk_CMS_RevocationInfoChoice_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr)) -# define sk_CMS_RevocationInfoChoice_pop(sk) \ - ((CMS_RevocationInfoChoice *)OPENSSL_sk_pop( \ - ossl_check_CMS_RevocationInfoChoice_sk_type(sk))) -# define sk_CMS_RevocationInfoChoice_shift(sk) \ - ((CMS_RevocationInfoChoice *)OPENSSL_sk_shift( \ - ossl_check_CMS_RevocationInfoChoice_sk_type(sk))) -# define sk_CMS_RevocationInfoChoice_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_freefunc_type(freefunc)) -# define sk_CMS_RevocationInfoChoice_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr), (idx)) -# define sk_CMS_RevocationInfoChoice_set(sk, idx, ptr) \ - ((CMS_RevocationInfoChoice *)OPENSSL_sk_set( \ - ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (idx), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr))) -# define sk_CMS_RevocationInfoChoice_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr)) -# define sk_CMS_RevocationInfoChoice_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr)) -# define sk_CMS_RevocationInfoChoice_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_type(ptr), pnum) -# define sk_CMS_RevocationInfoChoice_sort(sk) \ - OPENSSL_sk_sort(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) -# define sk_CMS_RevocationInfoChoice_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk)) -# define sk_CMS_RevocationInfoChoice_dup(sk) \ - ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_dup( \ - ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk))) -# define sk_CMS_RevocationInfoChoice_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_copyfunc_type(copyfunc), \ - ossl_check_CMS_RevocationInfoChoice_freefunc_type(freefunc))) -# define sk_CMS_RevocationInfoChoice_set_cmp_func(sk, cmp) \ - ((sk_CMS_RevocationInfoChoice_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ - ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp))) +# define sk_CMS_RevocationInfoChoice_num(sk) \ + OPENSSL_sk_num(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk)) +# define sk_CMS_RevocationInfoChoice_value(sk, idx) \ + ((CMS_RevocationInfoChoice *)OPENSSL_sk_value( \ + ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk), (idx))) +# define sk_CMS_RevocationInfoChoice_new(cmp) \ + ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new( \ + ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp))) +# define sk_CMS_RevocationInfoChoice_new_null() \ + ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new_null()) +# define sk_CMS_RevocationInfoChoice_new_reserve(cmp, n) \ + ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_new_reserve( \ + ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp), (n))) +# define sk_CMS_RevocationInfoChoice_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (n)) +# define sk_CMS_RevocationInfoChoice_free(sk) \ + OPENSSL_sk_free(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) +# define sk_CMS_RevocationInfoChoice_zero(sk) \ + OPENSSL_sk_zero(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) +# define sk_CMS_RevocationInfoChoice_delete(sk, i) \ + ((CMS_RevocationInfoChoice *)OPENSSL_sk_delete( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (i))) +# define sk_CMS_RevocationInfoChoice_delete_ptr(sk, ptr) \ + ((CMS_RevocationInfoChoice *)OPENSSL_sk_delete_ptr( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr))) +# define sk_CMS_RevocationInfoChoice_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr)) +# define sk_CMS_RevocationInfoChoice_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr)) +# define sk_CMS_RevocationInfoChoice_pop(sk) \ + ((CMS_RevocationInfoChoice *)OPENSSL_sk_pop( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk))) +# define sk_CMS_RevocationInfoChoice_shift(sk) \ + ((CMS_RevocationInfoChoice *)OPENSSL_sk_shift( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk))) +# define sk_CMS_RevocationInfoChoice_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_freefunc_type(freefunc)) +# define sk_CMS_RevocationInfoChoice_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr), (idx)) +# define sk_CMS_RevocationInfoChoice_set(sk, idx, ptr) \ + ((CMS_RevocationInfoChoice *)OPENSSL_sk_set( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk), (idx), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr))) +# define sk_CMS_RevocationInfoChoice_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr)) +# define sk_CMS_RevocationInfoChoice_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr)) +# define sk_CMS_RevocationInfoChoice_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_type(ptr), pnum) +# define sk_CMS_RevocationInfoChoice_sort(sk) \ + OPENSSL_sk_sort(ossl_check_CMS_RevocationInfoChoice_sk_type(sk)) +# define sk_CMS_RevocationInfoChoice_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk)) +# define sk_CMS_RevocationInfoChoice_dup(sk) \ + ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_dup( \ + ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk))) +# define sk_CMS_RevocationInfoChoice_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(CMS_RevocationInfoChoice) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_copyfunc_type(copyfunc), \ + ossl_check_CMS_RevocationInfoChoice_freefunc_type(freefunc))) +# define sk_CMS_RevocationInfoChoice_set_cmp_func(sk, cmp) \ + ((sk_CMS_RevocationInfoChoice_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_CMS_RevocationInfoChoice_sk_type(sk), \ + ossl_check_CMS_RevocationInfoChoice_compfunc_type(cmp))) DECLARE_ASN1_ITEM(CMS_EnvelopedData) DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_SignedData) @@ -321,44 +348,45 @@ DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest) DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo) -CMS_ContentInfo *CMS_ContentInfo_new_ex(OSSL_LIB_CTX *libctx, const char *propq); +CMS_ContentInfo *CMS_ContentInfo_new_ex(OSSL_LIB_CTX *libctx, + const char *propq); -# define CMS_SIGNERINFO_ISSUER_SERIAL 0 -# define CMS_SIGNERINFO_KEYIDENTIFIER 1 +# define CMS_SIGNERINFO_ISSUER_SERIAL 0 +# define CMS_SIGNERINFO_KEYIDENTIFIER 1 -# define CMS_RECIPINFO_NONE -1 -# define CMS_RECIPINFO_TRANS 0 -# define CMS_RECIPINFO_AGREE 1 -# define CMS_RECIPINFO_KEK 2 -# define CMS_RECIPINFO_PASS 3 -# define CMS_RECIPINFO_OTHER 4 +# define CMS_RECIPINFO_NONE -1 +# define CMS_RECIPINFO_TRANS 0 +# define CMS_RECIPINFO_AGREE 1 +# define CMS_RECIPINFO_KEK 2 +# define CMS_RECIPINFO_PASS 3 +# define CMS_RECIPINFO_OTHER 4 /* S/MIME related flags */ -# define CMS_TEXT 0x1 -# define CMS_NOCERTS 0x2 -# define CMS_NO_CONTENT_VERIFY 0x4 -# define CMS_NO_ATTR_VERIFY 0x8 -# define CMS_NOSIGS (CMS_NO_CONTENT_VERIFY | CMS_NO_ATTR_VERIFY) -# define CMS_NOINTERN 0x10 -# define CMS_NO_SIGNER_CERT_VERIFY 0x20 -# define CMS_NOVERIFY 0x20 -# define CMS_DETACHED 0x40 -# define CMS_BINARY 0x80 -# define CMS_NOATTR 0x100 -# define CMS_NOSMIMECAP 0x200 -# define CMS_NOOLDMIMETYPE 0x400 -# define CMS_CRLFEOL 0x800 -# define CMS_STREAM 0x1000 -# define CMS_NOCRL 0x2000 -# define CMS_PARTIAL 0x4000 -# define CMS_REUSE_DIGEST 0x8000 -# define CMS_USE_KEYID 0x10000 -# define CMS_DEBUG_DECRYPT 0x20000 -# define CMS_KEY_PARAM 0x40000 -# define CMS_ASCIICRLF 0x80000 -# define CMS_CADES 0x100000 -# define CMS_USE_ORIGINATOR_KEYID 0x200000 +# define CMS_TEXT 0x1 +# define CMS_NOCERTS 0x2 +# define CMS_NO_CONTENT_VERIFY 0x4 +# define CMS_NO_ATTR_VERIFY 0x8 +# define CMS_NOSIGS (CMS_NO_CONTENT_VERIFY | CMS_NO_ATTR_VERIFY) +# define CMS_NOINTERN 0x10 +# define CMS_NO_SIGNER_CERT_VERIFY 0x20 +# define CMS_NOVERIFY 0x20 +# define CMS_DETACHED 0x40 +# define CMS_BINARY 0x80 +# define CMS_NOATTR 0x100 +# define CMS_NOSMIMECAP 0x200 +# define CMS_NOOLDMIMETYPE 0x400 +# define CMS_CRLFEOL 0x800 +# define CMS_STREAM 0x1000 +# define CMS_NOCRL 0x2000 +# define CMS_PARTIAL 0x4000 +# define CMS_REUSE_DIGEST 0x8000 +# define CMS_USE_KEYID 0x10000 +# define CMS_DEBUG_DECRYPT 0x20000 +# define CMS_KEY_PARAM 0x40000 +# define CMS_ASCIICRLF 0x80000 +# define CMS_CADES 0x100000 +# define CMS_USE_ORIGINATOR_KEYID 0x200000 const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms); @@ -369,125 +397,156 @@ ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms); int CMS_is_detached(CMS_ContentInfo *cms); int CMS_set_detached(CMS_ContentInfo *cms, int detached); -# ifdef OPENSSL_PEM_H +# ifdef OPENSSL_PEM_H DECLARE_PEM_rw(CMS, CMS_ContentInfo) -# endif +# endif int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms); CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms); int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms); BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms); int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags); -int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags); +int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, + int flags); CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont); -CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont, CMS_ContentInfo **ci); +CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont, + CMS_ContentInfo **ci); int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags); int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags); -int CMS_final_digest(CMS_ContentInfo *cms, const unsigned char *md, unsigned int mdlen, BIO *dcont, - unsigned int flags); +int CMS_final_digest(CMS_ContentInfo *cms, const unsigned char *md, + unsigned int mdlen, BIO *dcont, unsigned int flags); -CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) * certs, BIO *data, +CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, + STACK_OF(X509) * certs, BIO *data, unsigned int flags); -CMS_ContentInfo *CMS_sign_ex(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) * certs, BIO *data, - unsigned int flags, OSSL_LIB_CTX *libctx, const char *propq); +CMS_ContentInfo *CMS_sign_ex(X509 *signcert, EVP_PKEY *pkey, + STACK_OF(X509) * certs, BIO *data, + unsigned int flags, OSSL_LIB_CTX *libctx, + const char *propq); -CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, X509 *signcert, EVP_PKEY *pkey, - STACK_OF(X509) * certs, unsigned int flags); +CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, X509 *signcert, + EVP_PKEY *pkey, STACK_OF(X509) * certs, + unsigned int flags); int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags); CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags); -CMS_ContentInfo *CMS_data_create_ex(BIO *in, unsigned int flags, OSSL_LIB_CTX *libctx, - const char *propq); +CMS_ContentInfo *CMS_data_create_ex(BIO *in, unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); -int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags); -CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md, unsigned int flags); -CMS_ContentInfo *CMS_digest_create_ex(BIO *in, const EVP_MD *md, unsigned int flags, - OSSL_LIB_CTX *libctx, const char *propq); +int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, + unsigned int flags); +CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md, + unsigned int flags); +CMS_ContentInfo *CMS_digest_create_ex(BIO *in, const EVP_MD *md, + unsigned int flags, OSSL_LIB_CTX *libctx, + const char *propq); -int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, const unsigned char *key, size_t keylen, - BIO *dcont, BIO *out, unsigned int flags); +int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, const unsigned char *key, + size_t keylen, BIO *dcont, BIO *out, + unsigned int flags); CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, - const unsigned char *key, size_t keylen, - unsigned int flags); + const unsigned char *key, + size_t keylen, unsigned int flags); CMS_ContentInfo *CMS_EncryptedData_encrypt_ex(BIO *in, const EVP_CIPHER *cipher, - const unsigned char *key, size_t keylen, - unsigned int flags, OSSL_LIB_CTX *libctx, + const unsigned char *key, + size_t keylen, unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph, const unsigned char *key, size_t keylen); -int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) * certs, X509_STORE *store, BIO *dcont, - BIO *out, unsigned int flags); +int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) * certs, X509_STORE *store, + BIO *dcont, BIO *out, unsigned int flags); -int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms, STACK_OF(X509) * certs, - X509_STORE *store, unsigned int flags); +int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms, + STACK_OF(X509) * certs, X509_STORE *store, + unsigned int flags); STACK_OF(X509) * CMS_get0_signers(CMS_ContentInfo *cms); -CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) * certs, BIO *in, const EVP_CIPHER *cipher, - unsigned int flags); -CMS_ContentInfo *CMS_encrypt_ex(STACK_OF(X509) * certs, BIO *in, const EVP_CIPHER *cipher, - unsigned int flags, OSSL_LIB_CTX *libctx, const char *propq); +CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) * certs, BIO *in, + const EVP_CIPHER *cipher, unsigned int flags); +CMS_ContentInfo *CMS_encrypt_ex(STACK_OF(X509) * certs, BIO *in, + const EVP_CIPHER *cipher, unsigned int flags, + OSSL_LIB_CTX *libctx, const char *propq); -int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, BIO *dcont, BIO *out, - unsigned int flags); +int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, BIO *dcont, + BIO *out, unsigned int flags); int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert); -int CMS_decrypt_set1_pkey_and_peer(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert, X509 *peer); -int CMS_decrypt_set1_key(CMS_ContentInfo *cms, unsigned char *key, size_t keylen, - const unsigned char *id, size_t idlen); -int CMS_decrypt_set1_password(CMS_ContentInfo *cms, unsigned char *pass, ossl_ssize_t passlen); +int CMS_decrypt_set1_pkey_and_peer(CMS_ContentInfo *cms, EVP_PKEY *pk, + X509 *cert, X509 *peer); +int CMS_decrypt_set1_key(CMS_ContentInfo *cms, unsigned char *key, + size_t keylen, const unsigned char *id, size_t idlen); +int CMS_decrypt_set1_password(CMS_ContentInfo *cms, unsigned char *pass, + ossl_ssize_t passlen); STACK_OF(CMS_RecipientInfo) * CMS_get0_RecipientInfos(CMS_ContentInfo *cms); int CMS_RecipientInfo_type(CMS_RecipientInfo *ri); EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri); CMS_ContentInfo *CMS_AuthEnvelopedData_create(const EVP_CIPHER *cipher); -CMS_ContentInfo *CMS_AuthEnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx, +CMS_ContentInfo *CMS_AuthEnvelopedData_create_ex(const EVP_CIPHER *cipher, + OSSL_LIB_CTX *libctx, const char *propq); CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher); -CMS_ContentInfo *CMS_EnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx, +CMS_ContentInfo *CMS_EnvelopedData_create_ex(const EVP_CIPHER *cipher, + OSSL_LIB_CTX *libctx, const char *propq); -BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data, EVP_PKEY *pkey, - X509 *cert, ASN1_OCTET_STRING *secret, unsigned int flags, +BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data, + EVP_PKEY *pkey, X509 *cert, + ASN1_OCTET_STRING *secret, unsigned int flags, OSSL_LIB_CTX *libctx, const char *propq); -CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, unsigned int flags); +CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, X509 *recip, + unsigned int flags); CMS_RecipientInfo *CMS_add1_recipient(CMS_ContentInfo *cms, X509 *recip, - EVP_PKEY *originatorPrivKey, X509 *originator, - unsigned int flags); + EVP_PKEY *originatorPrivKey, + X509 *originator, unsigned int flags); int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey); int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert); -int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, EVP_PKEY **pk, X509 **recip, - X509_ALGOR **palg); -int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, ASN1_INTEGER **sno); +int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, EVP_PKEY **pk, + X509 **recip, X509_ALGOR **palg); +int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, + ASN1_OCTET_STRING **keyid, + X509_NAME **issuer, + ASN1_INTEGER **sno); -CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, unsigned char *key, - size_t keylen, unsigned char *id, size_t idlen, - ASN1_GENERALIZEDTIME *date, ASN1_OBJECT *otherTypeId, +CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, + unsigned char *key, size_t keylen, + unsigned char *id, size_t idlen, + ASN1_GENERALIZEDTIME *date, + ASN1_OBJECT *otherTypeId, ASN1_TYPE *otherType); int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, X509_ALGOR **palg, - ASN1_OCTET_STRING **pid, ASN1_GENERALIZEDTIME **pdate, - ASN1_OBJECT **potherid, ASN1_TYPE **pothertype); + ASN1_OCTET_STRING **pid, + ASN1_GENERALIZEDTIME **pdate, + ASN1_OBJECT **potherid, + ASN1_TYPE **pothertype); -int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, unsigned char *key, size_t keylen); +int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, unsigned char *key, + size_t keylen); -int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, const unsigned char *id, size_t idlen); +int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, + const unsigned char *id, size_t idlen); int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass, ossl_ssize_t passlen); -CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, int wrap_nid, - int pbe_nid, unsigned char *pass, - ossl_ssize_t passlen, const EVP_CIPHER *kekciph); +CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, int iter, + int wrap_nid, int pbe_nid, + unsigned char *pass, + ossl_ssize_t passlen, + const EVP_CIPHER *kekciph); int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); -int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri); +int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, + CMS_RecipientInfo *ri); -int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags); +int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, + unsigned int flags); CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid); @@ -504,70 +563,84 @@ int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl); STACK_OF(X509_CRL) * CMS_get1_crls(CMS_ContentInfo *cms); int CMS_SignedData_init(CMS_ContentInfo *cms); -CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, EVP_PKEY *pk, const EVP_MD *md, +CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, X509 *signer, + EVP_PKEY *pk, const EVP_MD *md, unsigned int flags); EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si); EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si); STACK_OF(CMS_SignerInfo) * CMS_get0_SignerInfos(CMS_ContentInfo *cms); void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer); -int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, ASN1_OCTET_STRING **keyid, X509_NAME **issuer, - ASN1_INTEGER **sno); +int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, ASN1_OCTET_STRING **keyid, + X509_NAME **issuer, ASN1_INTEGER **sno); int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert); -int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) * certs, unsigned int flags); -void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk, X509 **signer, X509_ALGOR **pdig, - X509_ALGOR **psig); +int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) * certs, + unsigned int flags); +void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk, X509 **signer, + X509_ALGOR **pdig, X509_ALGOR **psig); ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si); int CMS_SignerInfo_sign(CMS_SignerInfo *si); int CMS_SignerInfo_verify(CMS_SignerInfo *si); int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain); -BIO *CMS_SignedData_verify(CMS_SignedData *sd, BIO *detached_data, STACK_OF(X509) * scerts, - X509_STORE *store, STACK_OF(X509) * extra, STACK_OF(X509_CRL) * crls, - unsigned int flags, OSSL_LIB_CTX *libctx, const char *propq); +BIO *CMS_SignedData_verify(CMS_SignedData *sd, BIO *detached_data, + STACK_OF(X509) * scerts, X509_STORE *store, + STACK_OF(X509) * extra, STACK_OF(X509_CRL) * crls, + unsigned int flags, OSSL_LIB_CTX *libctx, + const char *propq); int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) * algs); -int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) * *algs, int algnid, int keysize); +int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) * *algs, int algnid, + int keysize); int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) * *smcap); int CMS_signed_get_attr_count(const CMS_SignerInfo *si); int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos); -int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, int lastpos); +int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, + int lastpos); X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc); X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc); int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); -int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj, int type, +int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj, + int type, const void *bytes, int len); +int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type, const void *bytes, int len); -int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type, const void *bytes, int len); -int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname, int type, - const void *bytes, int len); -void *CMS_signed_get0_data_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *oid, int lastpos, +int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname, + int type, const void *bytes, int len); +void *CMS_signed_get0_data_by_OBJ(const CMS_SignerInfo *si, + const ASN1_OBJECT *oid, int lastpos, int type); int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si); -int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, int lastpos); -int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, int lastpos); +int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, + int lastpos); +int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, + const ASN1_OBJECT *obj, int lastpos); X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc); X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc); int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); -int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj, int type, +int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *obj, + int type, const void *bytes, int len); +int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type, const void *bytes, int len); -int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, int nid, int type, const void *bytes, - int len); -int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname, int type, - const void *bytes, int len); -void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, int lastpos, int type); +int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, const char *attrname, + int type, const void *bytes, int len); +void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, + int lastpos, int type); int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr); -CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst, - STACK_OF(GENERAL_NAMES) * receiptList, - STACK_OF(GENERAL_NAMES) * receiptsTo); -CMS_ReceiptRequest *CMS_ReceiptRequest_create0_ex(unsigned char *id, int idlen, int allorfirst, - STACK_OF(GENERAL_NAMES) * receiptList, - STACK_OF(GENERAL_NAMES) * receiptsTo, - OSSL_LIB_CTX *libctx); +CMS_ReceiptRequest * +CMS_ReceiptRequest_create0(unsigned char *id, int idlen, int allorfirst, + STACK_OF(GENERAL_NAMES) * receiptList, + STACK_OF(GENERAL_NAMES) * receiptsTo); +CMS_ReceiptRequest * +CMS_ReceiptRequest_create0_ex(unsigned char *id, int idlen, int allorfirst, + STACK_OF(GENERAL_NAMES) * receiptList, + STACK_OF(GENERAL_NAMES) * receiptsTo, + OSSL_LIB_CTX *libctx); int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr); -void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid, int *pallorfirst, +void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, ASN1_STRING **pcid, + int *pallorfirst, STACK_OF(GENERAL_NAMES) * *plist, STACK_OF(GENERAL_NAMES) * *prto); int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, X509_ALGOR **palg, @@ -575,31 +648,38 @@ int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, X509_ALGOR **palg, STACK_OF(CMS_RecipientEncryptedKey) *CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri); -int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri, X509_ALGOR **pubalg, - ASN1_BIT_STRING **pubkey, ASN1_OCTET_STRING **keyid, +int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri, + X509_ALGOR **pubalg, + ASN1_BIT_STRING **pubkey, + ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno); int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert); -int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek, ASN1_OCTET_STRING **keyid, - ASN1_GENERALIZEDTIME **tm, CMS_OtherKeyAttribute **other, +int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek, + ASN1_OCTET_STRING **keyid, + ASN1_GENERALIZEDTIME **tm, + CMS_OtherKeyAttribute **other, X509_NAME **issuer, ASN1_INTEGER **sno); -int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek, X509 *cert); +int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek, + X509 *cert); int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk); -int CMS_RecipientInfo_kari_set0_pkey_and_peer(CMS_RecipientInfo *ri, EVP_PKEY *pk, X509 *peer); +int CMS_RecipientInfo_kari_set0_pkey_and_peer(CMS_RecipientInfo *ri, + EVP_PKEY *pk, X509 *peer); EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri); int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, CMS_RecipientEncryptedKey *rek); -int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, ASN1_OCTET_STRING *ukm, - int keylen); +int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, + ASN1_OCTET_STRING *ukm, int keylen); /* Backward compatibility for spelling errors. */ -# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM -# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE +# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM +# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \ + CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/cmserr.h b/libs/OpenSSL/include/openssl/cmserr.h index b502920d..2119ab28 100644 --- a/libs/OpenSSL/include/openssl/cmserr.h +++ b/libs/OpenSSL/include/openssl/cmserr.h @@ -21,102 +21,102 @@ /* * CMS reason codes. */ -# define CMS_R_ADD_SIGNER_ERROR 99 -# define CMS_R_ATTRIBUTE_ERROR 161 -# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175 -# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160 -# define CMS_R_CERTIFICATE_VERIFY_ERROR 100 -# define CMS_R_CIPHER_AEAD_SET_TAG_ERROR 184 -# define CMS_R_CIPHER_GET_TAG 185 -# define CMS_R_CIPHER_INITIALISATION_ERROR 101 -# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102 -# define CMS_R_CMS_DATAFINAL_ERROR 103 -# define CMS_R_CMS_LIB 104 -# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170 -# define CMS_R_CONTENT_NOT_FOUND 105 -# define CMS_R_CONTENT_TYPE_MISMATCH 171 -# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106 -# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107 -# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108 -# define CMS_R_CONTENT_VERIFY_ERROR 109 -# define CMS_R_CTRL_ERROR 110 -# define CMS_R_CTRL_FAILURE 111 -# define CMS_R_DECODE_ERROR 187 -# define CMS_R_DECRYPT_ERROR 112 -# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113 -# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114 -# define CMS_R_ERROR_SETTING_KEY 115 -# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116 -# define CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR 183 -# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117 -# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176 -# define CMS_R_INVALID_KEY_LENGTH 118 -# define CMS_R_INVALID_LABEL 190 -# define CMS_R_INVALID_OAEP_PARAMETERS 191 -# define CMS_R_KDF_PARAMETER_ERROR 186 -# define CMS_R_MD_BIO_INIT_ERROR 119 -# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120 -# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121 -# define CMS_R_MSGSIGDIGEST_ERROR 172 -# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162 -# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163 -# define CMS_R_NEED_ONE_SIGNER 164 -# define CMS_R_NOT_A_SIGNED_RECEIPT 165 -# define CMS_R_NOT_ENCRYPTED_DATA 122 -# define CMS_R_NOT_KEK 123 -# define CMS_R_NOT_KEY_AGREEMENT 181 -# define CMS_R_NOT_KEY_TRANSPORT 124 -# define CMS_R_NOT_PWRI 177 -# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125 -# define CMS_R_NO_CIPHER 126 -# define CMS_R_NO_CONTENT 127 -# define CMS_R_NO_CONTENT_TYPE 173 -# define CMS_R_NO_DEFAULT_DIGEST 128 -# define CMS_R_NO_DIGEST_SET 129 -# define CMS_R_NO_KEY 130 -# define CMS_R_NO_KEY_OR_CERT 174 -# define CMS_R_NO_MATCHING_DIGEST 131 -# define CMS_R_NO_MATCHING_RECIPIENT 132 -# define CMS_R_NO_MATCHING_SIGNATURE 166 -# define CMS_R_NO_MSGSIGDIGEST 167 -# define CMS_R_NO_PASSWORD 178 -# define CMS_R_NO_PRIVATE_KEY 133 -# define CMS_R_NO_PUBLIC_KEY 134 -# define CMS_R_NO_RECEIPT_REQUEST 168 -# define CMS_R_NO_SIGNERS 135 -# define CMS_R_OPERATION_UNSUPPORTED 182 -# define CMS_R_PEER_KEY_ERROR 188 -# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136 -# define CMS_R_RECEIPT_DECODE_ERROR 169 -# define CMS_R_RECIPIENT_ERROR 137 -# define CMS_R_SHARED_INFO_ERROR 189 -# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138 -# define CMS_R_SIGNFINAL_ERROR 139 -# define CMS_R_SMIME_TEXT_ERROR 140 -# define CMS_R_STORE_INIT_ERROR 141 -# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142 -# define CMS_R_TYPE_NOT_DATA 143 -# define CMS_R_TYPE_NOT_DIGESTED_DATA 144 -# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145 -# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146 -# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147 -# define CMS_R_UNKNOWN_CIPHER 148 -# define CMS_R_UNKNOWN_DIGEST_ALGORITHM 149 -# define CMS_R_UNKNOWN_ID 150 -# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151 -# define CMS_R_UNSUPPORTED_CONTENT_ENCRYPTION_ALGORITHM 194 -# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152 -# define CMS_R_UNSUPPORTED_ENCRYPTION_TYPE 192 -# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153 -# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179 -# define CMS_R_UNSUPPORTED_LABEL_SOURCE 193 -# define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE 155 -# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154 -# define CMS_R_UNSUPPORTED_TYPE 156 -# define CMS_R_UNWRAP_ERROR 157 -# define CMS_R_UNWRAP_FAILURE 180 -# define CMS_R_VERIFICATION_FAILURE 158 -# define CMS_R_WRAP_ERROR 159 +# define CMS_R_ADD_SIGNER_ERROR 99 +# define CMS_R_ATTRIBUTE_ERROR 161 +# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175 +# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160 +# define CMS_R_CERTIFICATE_VERIFY_ERROR 100 +# define CMS_R_CIPHER_AEAD_SET_TAG_ERROR 184 +# define CMS_R_CIPHER_GET_TAG 185 +# define CMS_R_CIPHER_INITIALISATION_ERROR 101 +# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102 +# define CMS_R_CMS_DATAFINAL_ERROR 103 +# define CMS_R_CMS_LIB 104 +# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170 +# define CMS_R_CONTENT_NOT_FOUND 105 +# define CMS_R_CONTENT_TYPE_MISMATCH 171 +# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106 +# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107 +# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108 +# define CMS_R_CONTENT_VERIFY_ERROR 109 +# define CMS_R_CTRL_ERROR 110 +# define CMS_R_CTRL_FAILURE 111 +# define CMS_R_DECODE_ERROR 187 +# define CMS_R_DECRYPT_ERROR 112 +# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113 +# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114 +# define CMS_R_ERROR_SETTING_KEY 115 +# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116 +# define CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR 183 +# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117 +# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176 +# define CMS_R_INVALID_KEY_LENGTH 118 +# define CMS_R_INVALID_LABEL 190 +# define CMS_R_INVALID_OAEP_PARAMETERS 191 +# define CMS_R_KDF_PARAMETER_ERROR 186 +# define CMS_R_MD_BIO_INIT_ERROR 119 +# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120 +# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121 +# define CMS_R_MSGSIGDIGEST_ERROR 172 +# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162 +# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163 +# define CMS_R_NEED_ONE_SIGNER 164 +# define CMS_R_NOT_A_SIGNED_RECEIPT 165 +# define CMS_R_NOT_ENCRYPTED_DATA 122 +# define CMS_R_NOT_KEK 123 +# define CMS_R_NOT_KEY_AGREEMENT 181 +# define CMS_R_NOT_KEY_TRANSPORT 124 +# define CMS_R_NOT_PWRI 177 +# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125 +# define CMS_R_NO_CIPHER 126 +# define CMS_R_NO_CONTENT 127 +# define CMS_R_NO_CONTENT_TYPE 173 +# define CMS_R_NO_DEFAULT_DIGEST 128 +# define CMS_R_NO_DIGEST_SET 129 +# define CMS_R_NO_KEY 130 +# define CMS_R_NO_KEY_OR_CERT 174 +# define CMS_R_NO_MATCHING_DIGEST 131 +# define CMS_R_NO_MATCHING_RECIPIENT 132 +# define CMS_R_NO_MATCHING_SIGNATURE 166 +# define CMS_R_NO_MSGSIGDIGEST 167 +# define CMS_R_NO_PASSWORD 178 +# define CMS_R_NO_PRIVATE_KEY 133 +# define CMS_R_NO_PUBLIC_KEY 134 +# define CMS_R_NO_RECEIPT_REQUEST 168 +# define CMS_R_NO_SIGNERS 135 +# define CMS_R_OPERATION_UNSUPPORTED 182 +# define CMS_R_PEER_KEY_ERROR 188 +# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136 +# define CMS_R_RECEIPT_DECODE_ERROR 169 +# define CMS_R_RECIPIENT_ERROR 137 +# define CMS_R_SHARED_INFO_ERROR 189 +# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138 +# define CMS_R_SIGNFINAL_ERROR 139 +# define CMS_R_SMIME_TEXT_ERROR 140 +# define CMS_R_STORE_INIT_ERROR 141 +# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142 +# define CMS_R_TYPE_NOT_DATA 143 +# define CMS_R_TYPE_NOT_DIGESTED_DATA 144 +# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145 +# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146 +# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147 +# define CMS_R_UNKNOWN_CIPHER 148 +# define CMS_R_UNKNOWN_DIGEST_ALGORITHM 149 +# define CMS_R_UNKNOWN_ID 150 +# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151 +# define CMS_R_UNSUPPORTED_CONTENT_ENCRYPTION_ALGORITHM 194 +# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152 +# define CMS_R_UNSUPPORTED_ENCRYPTION_TYPE 192 +# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153 +# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179 +# define CMS_R_UNSUPPORTED_LABEL_SOURCE 193 +# define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE 155 +# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154 +# define CMS_R_UNSUPPORTED_TYPE 156 +# define CMS_R_UNWRAP_ERROR 157 +# define CMS_R_UNWRAP_FAILURE 180 +# define CMS_R_VERIFICATION_FAILURE 158 +# define CMS_R_WRAP_ERROR 159 #endif #endif diff --git a/libs/OpenSSL/include/openssl/comp.h b/libs/OpenSSL/include/openssl/comp.h index 9c44171b..bbfd6463 100644 --- a/libs/OpenSSL/include/openssl/comp.h +++ b/libs/OpenSSL/include/openssl/comp.h @@ -13,17 +13,17 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_COMP_H +# define HEADER_COMP_H #endif #include #ifndef OPENSSL_NO_COMP -# include -# include -# ifdef __cplusplus +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); @@ -32,8 +32,10 @@ int COMP_get_type(const COMP_METHOD *meth); const char *COMP_get_name(const COMP_METHOD *meth); void COMP_CTX_free(COMP_CTX *ctx); -int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, unsigned char *in, int ilen); -int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, unsigned char *in, int ilen); +int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); +int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, + unsigned char *in, int ilen); COMP_METHOD *COMP_zlib(void); COMP_METHOD *COMP_zlib_oneshot(void); @@ -42,20 +44,20 @@ COMP_METHOD *COMP_brotli_oneshot(void); COMP_METHOD *COMP_zstd(void); COMP_METHOD *COMP_zstd_oneshot(void); -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define COMP_zlib_cleanup() \ - while (0) \ - continue -# endif +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define COMP_zlib_cleanup() \ + while (0) \ + continue +# endif -# ifdef OPENSSL_BIO_H +# ifdef OPENSSL_BIO_H const BIO_METHOD *BIO_f_zlib(void); const BIO_METHOD *BIO_f_brotli(void); const BIO_METHOD *BIO_f_zstd(void); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/comperr.h b/libs/OpenSSL/include/openssl/comperr.h index 72fae2ab..66329850 100644 --- a/libs/OpenSSL/include/openssl/comperr.h +++ b/libs/OpenSSL/include/openssl/comperr.h @@ -21,16 +21,16 @@ /* * COMP reason codes. */ -# define COMP_R_BROTLI_DECODE_ERROR 102 -# define COMP_R_BROTLI_ENCODE_ERROR 103 -# define COMP_R_BROTLI_NOT_SUPPORTED 104 -# define COMP_R_ZLIB_DEFLATE_ERROR 99 -# define COMP_R_ZLIB_INFLATE_ERROR 100 -# define COMP_R_ZLIB_NOT_SUPPORTED 101 -# define COMP_R_ZSTD_COMPRESS_ERROR 105 -# define COMP_R_ZSTD_DECODE_ERROR 106 -# define COMP_R_ZSTD_DECOMPRESS_ERROR 107 -# define COMP_R_ZSTD_NOT_SUPPORTED 108 +# define COMP_R_BROTLI_DECODE_ERROR 102 +# define COMP_R_BROTLI_ENCODE_ERROR 103 +# define COMP_R_BROTLI_NOT_SUPPORTED 104 +# define COMP_R_ZLIB_DEFLATE_ERROR 99 +# define COMP_R_ZLIB_INFLATE_ERROR 100 +# define COMP_R_ZLIB_NOT_SUPPORTED 101 +# define COMP_R_ZSTD_COMPRESS_ERROR 105 +# define COMP_R_ZSTD_DECODE_ERROR 106 +# define COMP_R_ZSTD_DECOMPRESS_ERROR 107 +# define COMP_R_ZSTD_NOT_SUPPORTED 108 #endif #endif diff --git a/libs/OpenSSL/include/openssl/conf.h b/libs/OpenSSL/include/openssl/conf.h index 1ca12040..49020072 100644 --- a/libs/OpenSSL/include/openssl/conf.h +++ b/libs/OpenSSL/include/openssl/conf.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CONF_H +# define HEADER_CONF_H #endif #include @@ -26,7 +26,7 @@ #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -35,95 +35,123 @@ extern "C" { typedef struct { - char *section; - char *name; - char *value; + char *section; + char *name; + char *value; } CONF_VALUE; SKM_DEFINE_STACK_OF_INTERNAL(CONF_VALUE, CONF_VALUE, CONF_VALUE) -#define sk_CONF_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_CONF_VALUE_sk_type(sk)) -#define sk_CONF_VALUE_value(sk, idx) \ - ((CONF_VALUE *)OPENSSL_sk_value(ossl_check_const_CONF_VALUE_sk_type(sk), (idx))) -#define sk_CONF_VALUE_new(cmp) \ - ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new(ossl_check_CONF_VALUE_compfunc_type(cmp))) +#define sk_CONF_VALUE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_value(sk, idx) \ + ((CONF_VALUE *)OPENSSL_sk_value(ossl_check_const_CONF_VALUE_sk_type(sk), \ + (idx))) +#define sk_CONF_VALUE_new(cmp) \ + ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new( \ + ossl_check_CONF_VALUE_compfunc_type(cmp))) #define sk_CONF_VALUE_new_null() ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new_null()) -#define sk_CONF_VALUE_new_reserve(cmp, n) \ - ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_CONF_VALUE_compfunc_type(cmp), (n))) -#define sk_CONF_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CONF_VALUE_sk_type(sk), (n)) -#define sk_CONF_VALUE_free(sk) OPENSSL_sk_free(ossl_check_CONF_VALUE_sk_type(sk)) -#define sk_CONF_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_CONF_VALUE_sk_type(sk)) -#define sk_CONF_VALUE_delete(sk, i) \ - ((CONF_VALUE *)OPENSSL_sk_delete(ossl_check_CONF_VALUE_sk_type(sk), (i))) -#define sk_CONF_VALUE_delete_ptr(sk, ptr) \ - ((CONF_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_CONF_VALUE_sk_type(sk), \ - ossl_check_CONF_VALUE_type(ptr))) -#define sk_CONF_VALUE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) -#define sk_CONF_VALUE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) -#define sk_CONF_VALUE_pop(sk) ((CONF_VALUE *)OPENSSL_sk_pop(ossl_check_CONF_VALUE_sk_type(sk))) -#define sk_CONF_VALUE_shift(sk) ((CONF_VALUE *)OPENSSL_sk_shift(ossl_check_CONF_VALUE_sk_type(sk))) -#define sk_CONF_VALUE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_CONF_VALUE_sk_type(sk), \ - ossl_check_CONF_VALUE_freefunc_type(freefunc)) -#define sk_CONF_VALUE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr), (idx)) -#define sk_CONF_VALUE_set(sk, idx, ptr) \ - ((CONF_VALUE *)OPENSSL_sk_set(ossl_check_CONF_VALUE_sk_type(sk), (idx), \ - ossl_check_CONF_VALUE_type(ptr))) -#define sk_CONF_VALUE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) -#define sk_CONF_VALUE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr)) -#define sk_CONF_VALUE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_CONF_VALUE_sk_type(sk), ossl_check_CONF_VALUE_type(ptr), pnum) -#define sk_CONF_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_CONF_VALUE_sk_type(sk)) -#define sk_CONF_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CONF_VALUE_sk_type(sk)) -#define sk_CONF_VALUE_dup(sk) \ - ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_dup(ossl_check_const_CONF_VALUE_sk_type(sk))) -#define sk_CONF_VALUE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_CONF_VALUE_sk_type(sk), \ - ossl_check_CONF_VALUE_copyfunc_type(copyfunc), \ - ossl_check_CONF_VALUE_freefunc_type(freefunc))) -#define sk_CONF_VALUE_set_cmp_func(sk, cmp) \ - ((sk_CONF_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CONF_VALUE_sk_type(sk), \ - ossl_check_CONF_VALUE_compfunc_type(cmp))) +#define sk_CONF_VALUE_new_reserve(cmp, n) \ + ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_new_reserve( \ + ossl_check_CONF_VALUE_compfunc_type(cmp), (n))) +#define sk_CONF_VALUE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_CONF_VALUE_sk_type(sk), (n)) +#define sk_CONF_VALUE_free(sk) \ + OPENSSL_sk_free(ossl_check_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_delete(sk, i) \ + ((CONF_VALUE *)OPENSSL_sk_delete(ossl_check_CONF_VALUE_sk_type(sk), (i))) +#define sk_CONF_VALUE_delete_ptr(sk, ptr) \ + ((CONF_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr))) +#define sk_CONF_VALUE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_pop(sk) \ + ((CONF_VALUE *)OPENSSL_sk_pop(ossl_check_CONF_VALUE_sk_type(sk))) +#define sk_CONF_VALUE_shift(sk) \ + ((CONF_VALUE *)OPENSSL_sk_shift(ossl_check_CONF_VALUE_sk_type(sk))) +#define sk_CONF_VALUE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_freefunc_type(freefunc)) +#define sk_CONF_VALUE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr), (idx)) +#define sk_CONF_VALUE_set(sk, idx, ptr) \ + ((CONF_VALUE *)OPENSSL_sk_set(ossl_check_CONF_VALUE_sk_type(sk), (idx), \ + ossl_check_CONF_VALUE_type(ptr))) +#define sk_CONF_VALUE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr)) +#define sk_CONF_VALUE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_type(ptr), pnum) +#define sk_CONF_VALUE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_CONF_VALUE_sk_type(sk)) +#define sk_CONF_VALUE_dup(sk) \ + ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_dup( \ + ossl_check_const_CONF_VALUE_sk_type(sk))) +#define sk_CONF_VALUE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(CONF_VALUE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_copyfunc_type(copyfunc), \ + ossl_check_CONF_VALUE_freefunc_type(freefunc))) +#define sk_CONF_VALUE_set_cmp_func(sk, cmp) \ + ((sk_CONF_VALUE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_CONF_VALUE_sk_type(sk), \ + ossl_check_CONF_VALUE_compfunc_type(cmp))) DEFINE_LHASH_OF_INTERNAL(CONF_VALUE); -#define lh_CONF_VALUE_new(hfn, cmp) \ - ((LHASH_OF(CONF_VALUE) *)OPENSSL_LH_new(ossl_check_CONF_VALUE_lh_hashfunc_type(hfn), \ - ossl_check_CONF_VALUE_lh_compfunc_type(cmp))) -#define lh_CONF_VALUE_free(lh) OPENSSL_LH_free(ossl_check_CONF_VALUE_lh_type(lh)) -#define lh_CONF_VALUE_flush(lh) OPENSSL_LH_flush(ossl_check_CONF_VALUE_lh_type(lh)) -#define lh_CONF_VALUE_insert(lh, ptr) \ - ((CONF_VALUE *)OPENSSL_LH_insert(ossl_check_CONF_VALUE_lh_type(lh), \ - ossl_check_CONF_VALUE_lh_plain_type(ptr))) -#define lh_CONF_VALUE_delete(lh, ptr) \ - ((CONF_VALUE *)OPENSSL_LH_delete(ossl_check_CONF_VALUE_lh_type(lh), \ - ossl_check_const_CONF_VALUE_lh_plain_type(ptr))) -#define lh_CONF_VALUE_retrieve(lh, ptr) \ - ((CONF_VALUE *)OPENSSL_LH_retrieve(ossl_check_CONF_VALUE_lh_type(lh), \ - ossl_check_const_CONF_VALUE_lh_plain_type(ptr))) -#define lh_CONF_VALUE_error(lh) OPENSSL_LH_error(ossl_check_CONF_VALUE_lh_type(lh)) -#define lh_CONF_VALUE_num_items(lh) OPENSSL_LH_num_items(ossl_check_CONF_VALUE_lh_type(lh)) -#define lh_CONF_VALUE_node_stats_bio(lh, out) \ - OPENSSL_LH_node_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) -#define lh_CONF_VALUE_node_usage_stats_bio(lh, out) \ - OPENSSL_LH_node_usage_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) -#define lh_CONF_VALUE_stats_bio(lh, out) \ - OPENSSL_LH_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) -#define lh_CONF_VALUE_get_down_load(lh) OPENSSL_LH_get_down_load(ossl_check_CONF_VALUE_lh_type(lh)) -#define lh_CONF_VALUE_set_down_load(lh, dl) \ - OPENSSL_LH_set_down_load(ossl_check_CONF_VALUE_lh_type(lh), dl) -#define lh_CONF_VALUE_doall(lh, dfn) \ - OPENSSL_LH_doall(ossl_check_CONF_VALUE_lh_type(lh), \ - ossl_check_CONF_VALUE_lh_doallfunc_type(dfn)) +#define lh_CONF_VALUE_new(hfn, cmp) \ + ((LHASH_OF(CONF_VALUE) *)OPENSSL_LH_new( \ + ossl_check_CONF_VALUE_lh_hashfunc_type(hfn), \ + ossl_check_CONF_VALUE_lh_compfunc_type(cmp))) +#define lh_CONF_VALUE_free(lh) \ + OPENSSL_LH_free(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_flush(lh) \ + OPENSSL_LH_flush(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_insert(lh, ptr) \ + ((CONF_VALUE *)OPENSSL_LH_insert(ossl_check_CONF_VALUE_lh_type(lh), \ + ossl_check_CONF_VALUE_lh_plain_type(ptr))) +#define lh_CONF_VALUE_delete(lh, ptr) \ + ((CONF_VALUE *)OPENSSL_LH_delete( \ + ossl_check_CONF_VALUE_lh_type(lh), \ + ossl_check_const_CONF_VALUE_lh_plain_type(ptr))) +#define lh_CONF_VALUE_retrieve(lh, ptr) \ + ((CONF_VALUE *)OPENSSL_LH_retrieve( \ + ossl_check_CONF_VALUE_lh_type(lh), \ + ossl_check_const_CONF_VALUE_lh_plain_type(ptr))) +#define lh_CONF_VALUE_error(lh) \ + OPENSSL_LH_error(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_num_items(lh) \ + OPENSSL_LH_num_items(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_node_stats_bio(lh, out) \ + OPENSSL_LH_node_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) +#define lh_CONF_VALUE_node_usage_stats_bio(lh, out) \ + OPENSSL_LH_node_usage_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) +#define lh_CONF_VALUE_stats_bio(lh, out) \ + OPENSSL_LH_stats_bio(ossl_check_const_CONF_VALUE_lh_type(lh), out) +#define lh_CONF_VALUE_get_down_load(lh) \ + OPENSSL_LH_get_down_load(ossl_check_CONF_VALUE_lh_type(lh)) +#define lh_CONF_VALUE_set_down_load(lh, dl) \ + OPENSSL_LH_set_down_load(ossl_check_CONF_VALUE_lh_type(lh), dl) +#define lh_CONF_VALUE_doall(lh, dfn) \ + OPENSSL_LH_doall(ossl_check_CONF_VALUE_lh_type(lh), \ + ossl_check_CONF_VALUE_lh_doallfunc_type(dfn)) struct conf_st; struct conf_method_st; typedef struct conf_method_st CONF_METHOD; #ifndef OPENSSL_NO_DEPRECATED_3_0 -# include +# include #endif /* Module definitions */ @@ -146,14 +174,20 @@ typedef void conf_finish_func(CONF_IMODULE *md); int CONF_set_default_method(CONF_METHOD *meth); void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) * hash); -LHASH_OF(CONF_VALUE) * CONF_load(LHASH_OF(CONF_VALUE) * conf, const char *file, long *eline); +LHASH_OF(CONF_VALUE) + * CONF_load(LHASH_OF(CONF_VALUE) * conf, const char *file, long *eline); #ifndef OPENSSL_NO_STDIO -LHASH_OF(CONF_VALUE) * CONF_load_fp(LHASH_OF(CONF_VALUE) * conf, FILE *fp, long *eline); +LHASH_OF(CONF_VALUE) + * CONF_load_fp(LHASH_OF(CONF_VALUE) * conf, FILE *fp, long *eline); #endif -LHASH_OF(CONF_VALUE) * CONF_load_bio(LHASH_OF(CONF_VALUE) * conf, BIO *bp, long *eline); -STACK_OF(CONF_VALUE) * CONF_get_section(LHASH_OF(CONF_VALUE) * conf, const char *section); -char *CONF_get_string(LHASH_OF(CONF_VALUE) * conf, const char *group, const char *name); -long CONF_get_number(LHASH_OF(CONF_VALUE) * conf, const char *group, const char *name); +LHASH_OF(CONF_VALUE) + * CONF_load_bio(LHASH_OF(CONF_VALUE) * conf, BIO *bp, long *eline); +STACK_OF(CONF_VALUE) + * CONF_get_section(LHASH_OF(CONF_VALUE) * conf, const char *section); +char *CONF_get_string(LHASH_OF(CONF_VALUE) * conf, const char *group, + const char *name); +long CONF_get_number(LHASH_OF(CONF_VALUE) * conf, const char *group, + const char *name); void CONF_free(LHASH_OF(CONF_VALUE) * conf); #ifndef OPENSSL_NO_STDIO int CONF_dump_fp(LHASH_OF(CONF_VALUE) * conf, FILE *out); @@ -164,7 +198,8 @@ OSSL_DEPRECATEDIN_1_1_0 void OPENSSL_config(const char *config_name); #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define OPENSSL_no_config() OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) +# define OPENSSL_no_config() \ + OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) #endif /* @@ -190,7 +225,8 @@ int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); STACK_OF(OPENSSL_CSTRING) * NCONF_get_section_names(const CONF *conf); STACK_OF(CONF_VALUE) * NCONF_get_section(const CONF *conf, const char *section); char *NCONF_get_string(const CONF *conf, const char *group, const char *name); -int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, long *result); +int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, + long *result); #ifndef OPENSSL_NO_STDIO int NCONF_dump_fp(const CONF *conf, FILE *out); #endif @@ -200,18 +236,21 @@ int NCONF_dump_bio(const CONF *conf, BIO *out); /* Module functions */ -int CONF_modules_load(const CONF *cnf, const char *appname, unsigned long flags); -int CONF_modules_load_file_ex(OSSL_LIB_CTX *libctx, const char *filename, const char *appname, - unsigned long flags); -int CONF_modules_load_file(const char *filename, const char *appname, unsigned long flags); +int CONF_modules_load(const CONF *cnf, const char *appname, + unsigned long flags); +int CONF_modules_load_file_ex(OSSL_LIB_CTX *libctx, const char *filename, + const char *appname, unsigned long flags); +int CONF_modules_load_file(const char *filename, const char *appname, + unsigned long flags); void CONF_modules_unload(int all); void CONF_modules_finish(void); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define CONF_modules_free() \ - while (0) \ - continue +# define CONF_modules_free() \ + while (0) \ + continue #endif -int CONF_module_add(const char *name, conf_init_func *ifunc, conf_finish_func *ffunc); +int CONF_module_add(const char *name, conf_init_func *ifunc, + conf_finish_func *ffunc); const char *CONF_imodule_get_name(const CONF_IMODULE *md); const char *CONF_imodule_get_value(const CONF_IMODULE *md); @@ -226,7 +265,8 @@ void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); char *CONF_get1_default_config_file(void); int CONF_parse_list(const char *list, int sep, int nospc, - int (*list_cb)(const char *elem, int len, void *usr), void *arg); + int (*list_cb)(const char *elem, int len, void *usr), + void *arg); void OPENSSL_load_builtin_modules(void); diff --git a/libs/OpenSSL/include/openssl/conf_api.h b/libs/OpenSSL/include/openssl/conf_api.h index 9e955de3..25b744d2 100644 --- a/libs/OpenSSL/include/openssl/conf_api.h +++ b/libs/OpenSSL/include/openssl/conf_api.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CONF_API_H +# define HEADER_CONF_API_H #endif #include @@ -28,7 +28,8 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); /* Up until OpenSSL 0.9.5a, this was get_section */ CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ -STACK_OF(CONF_VALUE) * _CONF_get_section_values(const CONF *conf, const char *section); +STACK_OF(CONF_VALUE) + * _CONF_get_section_values(const CONF *conf, const char *section); int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); char *_CONF_get_string(const CONF *conf, const char *section, const char *name); diff --git a/libs/OpenSSL/include/openssl/configuration.h b/libs/OpenSSL/include/openssl/configuration.h index 84f0924f..b2aa41a2 100644 --- a/libs/OpenSSL/include/openssl/configuration.h +++ b/libs/OpenSSL/include/openssl/configuration.h @@ -1,7 +1,7 @@ /* * WARNING: do not edit! - * Generated by configdata.pm from Configurations/common0.tmpl, Configurations/unix-Makefile.tmpl - * via Makefile.in + * Generated by configdata.pm from Configurations/common0.tmpl, + * Configurations/unix-Makefile.tmpl via Makefile.in * * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. * @@ -20,7 +20,7 @@ extern "C" { #endif #ifdef OPENSSL_ALGORITHM_DEFINES -# error OPENSSL_ALGORITHM_DEFINES no longer supported +# error OPENSSL_ALGORITHM_DEFINES no longer supported #endif /* @@ -28,116 +28,116 @@ extern "C" { */ #ifndef OPENSSL_SYS_MACOSX -# define OPENSSL_SYS_MACOSX 1 +# define OPENSSL_SYS_MACOSX 1 #endif #define OPENSSL_CONFIGURED_API 30200 #ifndef OPENSSL_RAND_SEED_OS -# define OPENSSL_RAND_SEED_OS +# define OPENSSL_RAND_SEED_OS #endif #ifndef OPENSSL_THREADS -# define OPENSSL_THREADS +# define OPENSSL_THREADS #endif #ifndef OPENSSL_NO_ACVP_TESTS -# define OPENSSL_NO_ACVP_TESTS +# define OPENSSL_NO_ACVP_TESTS #endif #ifndef OPENSSL_NO_AFALGENG -# define OPENSSL_NO_AFALGENG +# define OPENSSL_NO_AFALGENG #endif #ifndef OPENSSL_NO_ASAN -# define OPENSSL_NO_ASAN +# define OPENSSL_NO_ASAN #endif #ifndef OPENSSL_NO_BROTLI -# define OPENSSL_NO_BROTLI +# define OPENSSL_NO_BROTLI #endif #ifndef OPENSSL_NO_BROTLI_DYNAMIC -# define OPENSSL_NO_BROTLI_DYNAMIC +# define OPENSSL_NO_BROTLI_DYNAMIC #endif #ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_NO_CRYPTO_MDEBUG +# define OPENSSL_NO_CRYPTO_MDEBUG #endif #ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE +# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE #endif #ifndef OPENSSL_NO_DEVCRYPTOENG -# define OPENSSL_NO_DEVCRYPTOENG +# define OPENSSL_NO_DEVCRYPTOENG #endif #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -# define OPENSSL_NO_EC_NISTP_64_GCC_128 +# define OPENSSL_NO_EC_NISTP_64_GCC_128 #endif #ifndef OPENSSL_NO_EGD -# define OPENSSL_NO_EGD +# define OPENSSL_NO_EGD #endif #ifndef OPENSSL_NO_EXTERNAL_TESTS -# define OPENSSL_NO_EXTERNAL_TESTS +# define OPENSSL_NO_EXTERNAL_TESTS #endif #ifndef OPENSSL_NO_FIPS_SECURITYCHECKS -# define OPENSSL_NO_FIPS_SECURITYCHECKS +# define OPENSSL_NO_FIPS_SECURITYCHECKS #endif #ifndef OPENSSL_NO_FUZZ_AFL -# define OPENSSL_NO_FUZZ_AFL +# define OPENSSL_NO_FUZZ_AFL #endif #ifndef OPENSSL_NO_FUZZ_LIBFUZZER -# define OPENSSL_NO_FUZZ_LIBFUZZER +# define OPENSSL_NO_FUZZ_LIBFUZZER #endif #ifndef OPENSSL_NO_KTLS -# define OPENSSL_NO_KTLS +# define OPENSSL_NO_KTLS #endif #ifndef OPENSSL_NO_MD2 -# define OPENSSL_NO_MD2 +# define OPENSSL_NO_MD2 #endif #ifndef OPENSSL_NO_MSAN -# define OPENSSL_NO_MSAN +# define OPENSSL_NO_MSAN #endif #ifndef OPENSSL_NO_QUIC -# define OPENSSL_NO_QUIC +# define OPENSSL_NO_QUIC #endif #ifndef OPENSSL_NO_RC5 -# define OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 #endif #ifndef OPENSSL_NO_SCTP -# define OPENSSL_NO_SCTP +# define OPENSSL_NO_SCTP #endif #ifndef OPENSSL_NO_SSL3 -# define OPENSSL_NO_SSL3 +# define OPENSSL_NO_SSL3 #endif #ifndef OPENSSL_NO_SSL3_METHOD -# define OPENSSL_NO_SSL3_METHOD +# define OPENSSL_NO_SSL3_METHOD #endif #ifndef OPENSSL_NO_TFO -# define OPENSSL_NO_TFO +# define OPENSSL_NO_TFO #endif #ifndef OPENSSL_NO_TRACE -# define OPENSSL_NO_TRACE +# define OPENSSL_NO_TRACE #endif #ifndef OPENSSL_NO_UBSAN -# define OPENSSL_NO_UBSAN +# define OPENSSL_NO_UBSAN #endif #ifndef OPENSSL_NO_UNIT_TEST -# define OPENSSL_NO_UNIT_TEST +# define OPENSSL_NO_UNIT_TEST #endif #ifndef OPENSSL_NO_UPLINK -# define OPENSSL_NO_UPLINK +# define OPENSSL_NO_UPLINK #endif #ifndef OPENSSL_NO_WEAK_SSL_CIPHERS -# define OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS #endif #ifndef OPENSSL_NO_WINSTORE -# define OPENSSL_NO_WINSTORE +# define OPENSSL_NO_WINSTORE #endif #ifndef OPENSSL_NO_ZLIB -# define OPENSSL_NO_ZLIB +# define OPENSSL_NO_ZLIB #endif #ifndef OPENSSL_NO_ZLIB_DYNAMIC -# define OPENSSL_NO_ZLIB_DYNAMIC +# define OPENSSL_NO_ZLIB_DYNAMIC #endif #ifndef OPENSSL_NO_ZSTD -# define OPENSSL_NO_ZSTD +# define OPENSSL_NO_ZSTD #endif #ifndef OPENSSL_NO_ZSTD_DYNAMIC -# define OPENSSL_NO_ZSTD_DYNAMIC +# define OPENSSL_NO_ZSTD_DYNAMIC #endif #ifndef OPENSSL_NO_STATIC_ENGINE -# define OPENSSL_NO_STATIC_ENGINE +# define OPENSSL_NO_STATIC_ENGINE #endif /* Generate 80386 code? */ @@ -147,20 +147,21 @@ extern "C" { * The following are cipher-specific, but are part of the public API. */ #if !defined(OPENSSL_SYS_UEFI) -# undef BN_LLONG +# undef BN_LLONG /* Only one for the following should be defined */ -# define SIXTY_FOUR_BIT_LONG -# undef SIXTY_FOUR_BIT -# undef THIRTY_TWO_BIT +# define SIXTY_FOUR_BIT_LONG +# undef SIXTY_FOUR_BIT +# undef THIRTY_TWO_BIT #endif #define RC4_INT unsigned int -#if defined(OPENSSL_NO_COMP) \ - || (defined(OPENSSL_NO_BROTLI) && defined(OPENSSL_NO_ZSTD) && defined(OPENSSL_NO_ZLIB)) -# define OPENSSL_NO_COMP_ALG +#if defined(OPENSSL_NO_COMP) \ + || (defined(OPENSSL_NO_BROTLI) && defined(OPENSSL_NO_ZSTD) \ + && defined(OPENSSL_NO_ZLIB)) +# define OPENSSL_NO_COMP_ALG #else -# undef OPENSSL_NO_COMP_ALG +# undef OPENSSL_NO_COMP_ALG #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/conftypes.h b/libs/OpenSSL/include/openssl/conftypes.h index bf2a03be..5abbe37c 100644 --- a/libs/OpenSSL/include/openssl/conftypes.h +++ b/libs/OpenSSL/include/openssl/conftypes.h @@ -12,7 +12,7 @@ #pragma once #ifndef OPENSSL_CONF_H -# include +# include #endif /* @@ -20,27 +20,27 @@ */ struct conf_method_st { - const char *name; - CONF *(*create)(CONF_METHOD *meth); - int (*init)(CONF *conf); - int (*destroy)(CONF *conf); - int (*destroy_data)(CONF *conf); - int (*load_bio)(CONF *conf, BIO *bp, long *eline); - int (*dump)(const CONF *conf, BIO *bp); - int (*is_number)(const CONF *conf, char c); - int (*to_int)(const CONF *conf, char c); - int (*load)(CONF *conf, const char *name, long *eline); + const char *name; + CONF *(*create)(CONF_METHOD *meth); + int (*init)(CONF *conf); + int (*destroy)(CONF *conf); + int (*destroy_data)(CONF *conf); + int (*load_bio)(CONF *conf, BIO *bp, long *eline); + int (*dump)(const CONF *conf, BIO *bp); + int (*is_number)(const CONF *conf, char c); + int (*to_int)(const CONF *conf, char c); + int (*load)(CONF *conf, const char *name, long *eline); }; struct conf_st { - CONF_METHOD *meth; - void *meth_data; - LHASH_OF(CONF_VALUE) * data; - int flag_dollarid; - int flag_abspath; - char *includedir; - OSSL_LIB_CTX *libctx; + CONF_METHOD *meth; + void *meth_data; + LHASH_OF(CONF_VALUE) * data; + int flag_dollarid; + int flag_abspath; + char *includedir; + OSSL_LIB_CTX *libctx; }; #endif diff --git a/libs/OpenSSL/include/openssl/core.h b/libs/OpenSSL/include/openssl/core.h index 9a49e8cf..43587c45 100644 --- a/libs/OpenSSL/include/openssl/core.h +++ b/libs/OpenSSL/include/openssl/core.h @@ -39,8 +39,8 @@ typedef struct ossl_core_bio_st OSSL_CORE_BIO; */ struct ossl_dispatch_st { - int function_id; - void (*function)(void); + int function_id; + void (*function)(void); }; /* @@ -58,8 +58,8 @@ struct ossl_dispatch_st */ struct ossl_item_st { - unsigned int id; - void *ptr; + unsigned int id; + void *ptr; }; /* @@ -70,10 +70,10 @@ struct ossl_item_st */ struct ossl_algorithm_st { - const char *algorithm_names; /* key */ - const char *property_definition; /* key */ - const OSSL_DISPATCH *implementation; - const char *algorithm_description; + const char *algorithm_names; /* key */ + const char *property_definition; /* key */ + const OSSL_DISPATCH *implementation; + const char *algorithm_description; }; /* @@ -84,11 +84,11 @@ struct ossl_algorithm_st */ struct ossl_param_st { - const char *key; /* the name of the parameter */ - unsigned int data_type; /* declare what kind of content is in buffer */ - void *data; /* value being passed in or out */ - size_t data_size; /* data size */ - size_t return_size; /* returned content size */ + const char *key; /* the name of the parameter */ + unsigned int data_type; /* declare what kind of content is in buffer */ + void *data; /* value being passed in or out */ + size_t data_size; /* data size */ + size_t return_size; /* returned content size */ }; /* Currently supported OSSL_PARAM data types */ @@ -190,15 +190,16 @@ typedef void (*OSSL_thread_stop_handler_fn)(void *arg); * provider needs it. This value is passed to other provider * functions, notably other context constructors. */ -typedef int(OSSL_provider_init_fn)(const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH *in, +typedef int(OSSL_provider_init_fn)(const OSSL_CORE_HANDLE *handle, + const OSSL_DISPATCH *in, const OSSL_DISPATCH **out, void **provctx); #ifdef __VMS -# pragma names save -# pragma names uppercase, truncated +# pragma names save +# pragma names uppercase, truncated #endif OPENSSL_EXPORT OSSL_provider_init_fn OSSL_provider_init; #ifdef __VMS -# pragma names restore +# pragma names restore #endif /* @@ -215,14 +216,16 @@ OPENSSL_EXPORT OSSL_provider_init_fn OSSL_provider_init; * application callback it knows about. */ typedef int(OSSL_CALLBACK)(const OSSL_PARAM params[], void *arg); -typedef int(OSSL_INOUT_CALLBACK)(const OSSL_PARAM in_params[], OSSL_PARAM out_params[], void *arg); +typedef int(OSSL_INOUT_CALLBACK)(const OSSL_PARAM in_params[], + OSSL_PARAM out_params[], void *arg); /* * Passphrase callback function signature * * This is similar to the generic callback function above, but adds a * result parameter. */ -typedef int(OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size, size_t *pass_len, +typedef int(OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size, + size_t *pass_len, const OSSL_PARAM params[], void *arg); #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/core_dispatch.h b/libs/OpenSSL/include/openssl/core_dispatch.h index 9a316db6..d497f4db 100644 --- a/libs/OpenSSL/include/openssl/core_dispatch.h +++ b/libs/OpenSSL/include/openssl/core_dispatch.h @@ -44,13 +44,13 @@ extern "C" { * Note: This is considered a "reserved" internal macro. Applications should * not use this or assume its existence. */ -#define OSSL_CORE_MAKE_FUNC(type, name, args) \ - typedef type(OSSL_FUNC_##name##_fn) args; \ - static ossl_unused ossl_inline OSSL_FUNC_##name##_fn *OSSL_FUNC_##name( \ - const OSSL_DISPATCH *opf) \ - { \ - return (OSSL_FUNC_##name##_fn *)opf->function; \ - } +#define OSSL_CORE_MAKE_FUNC(type, name, args) \ + typedef type(OSSL_FUNC_##name##_fn) args; \ + static ossl_unused ossl_inline OSSL_FUNC_##name##_fn *OSSL_FUNC_##name( \ + const OSSL_DISPATCH *opf) \ + { \ + return (OSSL_FUNC_##name##_fn *)opf->function; \ + } /* * Core function identities, for the two OSSL_DISPATCH tables being passed @@ -61,26 +61,33 @@ extern "C" { */ /* Functions provided by the Core to the provider, reserved numbers 1-1023 */ #define OSSL_FUNC_CORE_GETTABLE_PARAMS 1 -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, core_gettable_params, (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, core_gettable_params, + (const OSSL_CORE_HANDLE *prov)) #define OSSL_FUNC_CORE_GET_PARAMS 2 -OSSL_CORE_MAKE_FUNC(int, core_get_params, (const OSSL_CORE_HANDLE *prov, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, core_get_params, + (const OSSL_CORE_HANDLE *prov, OSSL_PARAM params[])) #define OSSL_FUNC_CORE_THREAD_START 3 OSSL_CORE_MAKE_FUNC(int, core_thread_start, - (const OSSL_CORE_HANDLE *prov, OSSL_thread_stop_handler_fn handfn, void *arg)) + (const OSSL_CORE_HANDLE *prov, + OSSL_thread_stop_handler_fn handfn, void *arg)) #define OSSL_FUNC_CORE_GET_LIBCTX 4 -OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *, core_get_libctx, (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *, core_get_libctx, + (const OSSL_CORE_HANDLE *prov)) #define OSSL_FUNC_CORE_NEW_ERROR 5 OSSL_CORE_MAKE_FUNC(void, core_new_error, (const OSSL_CORE_HANDLE *prov)) #define OSSL_FUNC_CORE_SET_ERROR_DEBUG 6 OSSL_CORE_MAKE_FUNC(void, core_set_error_debug, - (const OSSL_CORE_HANDLE *prov, const char *file, int line, const char *func)) + (const OSSL_CORE_HANDLE *prov, const char *file, int line, + const char *func)) #define OSSL_FUNC_CORE_VSET_ERROR 7 OSSL_CORE_MAKE_FUNC(void, core_vset_error, - (const OSSL_CORE_HANDLE *prov, uint32_t reason, const char *fmt, va_list args)) + (const OSSL_CORE_HANDLE *prov, uint32_t reason, + const char *fmt, va_list args)) #define OSSL_FUNC_CORE_SET_ERROR_MARK 8 OSSL_CORE_MAKE_FUNC(int, core_set_error_mark, (const OSSL_CORE_HANDLE *prov)) #define OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK 9 -OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark, (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark, + (const OSSL_CORE_HANDLE *prov)) #define OSSL_FUNC_CORE_POP_ERROR_TO_MARK 10 OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov)) @@ -90,31 +97,40 @@ OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov)) #define OSSL_FUNC_CORE_OBJ_CREATE 12 OSSL_CORE_MAKE_FUNC(int, core_obj_add_sigid, - (const OSSL_CORE_HANDLE *prov, const char *sign_name, const char *digest_name, - const char *pkey_name)) + (const OSSL_CORE_HANDLE *prov, const char *sign_name, + const char *digest_name, const char *pkey_name)) OSSL_CORE_MAKE_FUNC(int, core_obj_create, - (const OSSL_CORE_HANDLE *prov, const char *oid, const char *sn, const char *ln)) + (const OSSL_CORE_HANDLE *prov, const char *oid, + const char *sn, const char *ln)) /* Memory allocation, freeing, clearing. */ #define OSSL_FUNC_CRYPTO_MALLOC 20 -OSSL_CORE_MAKE_FUNC(void *, CRYPTO_malloc, (size_t num, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void *, CRYPTO_malloc, + (size_t num, const char *file, int line)) #define OSSL_FUNC_CRYPTO_ZALLOC 21 -OSSL_CORE_MAKE_FUNC(void *, CRYPTO_zalloc, (size_t num, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void *, CRYPTO_zalloc, + (size_t num, const char *file, int line)) #define OSSL_FUNC_CRYPTO_FREE 22 OSSL_CORE_MAKE_FUNC(void, CRYPTO_free, (void *ptr, const char *file, int line)) #define OSSL_FUNC_CRYPTO_CLEAR_FREE 23 -OSSL_CORE_MAKE_FUNC(void, CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void, CRYPTO_clear_free, + (void *ptr, size_t num, const char *file, int line)) #define OSSL_FUNC_CRYPTO_REALLOC 24 -OSSL_CORE_MAKE_FUNC(void *, CRYPTO_realloc, (void *addr, size_t num, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void *, CRYPTO_realloc, + (void *addr, size_t num, const char *file, int line)) #define OSSL_FUNC_CRYPTO_CLEAR_REALLOC 25 OSSL_CORE_MAKE_FUNC(void *, CRYPTO_clear_realloc, - (void *addr, size_t old_num, size_t num, const char *file, int line)) + (void *addr, size_t old_num, size_t num, const char *file, + int line)) #define OSSL_FUNC_CRYPTO_SECURE_MALLOC 26 -OSSL_CORE_MAKE_FUNC(void *, CRYPTO_secure_malloc, (size_t num, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void *, CRYPTO_secure_malloc, + (size_t num, const char *file, int line)) #define OSSL_FUNC_CRYPTO_SECURE_ZALLOC 27 -OSSL_CORE_MAKE_FUNC(void *, CRYPTO_secure_zalloc, (size_t num, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void *, CRYPTO_secure_zalloc, + (size_t num, const char *file, int line)) #define OSSL_FUNC_CRYPTO_SECURE_FREE 28 -OSSL_CORE_MAKE_FUNC(void, CRYPTO_secure_free, (void *ptr, const char *file, int line)) +OSSL_CORE_MAKE_FUNC(void, CRYPTO_secure_free, + (void *ptr, const char *file, int line)) #define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE 29 OSSL_CORE_MAKE_FUNC(void, CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file, int line)) @@ -136,22 +152,29 @@ OSSL_CORE_MAKE_FUNC(void, OPENSSL_cleanse, (void *ptr, size_t len)) #define OSSL_FUNC_BIO_GETS 49 #define OSSL_FUNC_BIO_CTRL 50 -OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename, const char *mode)) +OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, + (const char *filename, const char *mode)) OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_membuf, (const void *buf, int len)) OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, - (OSSL_CORE_BIO * bio, void *data, size_t data_len, size_t *bytes_read)) + (OSSL_CORE_BIO * bio, void *data, size_t data_len, + size_t *bytes_read)) OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, - (OSSL_CORE_BIO * bio, const void *data, size_t data_len, size_t *written)) + (OSSL_CORE_BIO * bio, const void *data, size_t data_len, + size_t *written)) OSSL_CORE_MAKE_FUNC(int, BIO_gets, (OSSL_CORE_BIO * bio, char *buf, int size)) OSSL_CORE_MAKE_FUNC(int, BIO_puts, (OSSL_CORE_BIO * bio, const char *str)) OSSL_CORE_MAKE_FUNC(int, BIO_up_ref, (OSSL_CORE_BIO * bio)) OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO * bio)) -OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO * bio, const char *format, va_list args)) -OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf, (char *buf, size_t n, const char *fmt, va_list args)) -OSSL_CORE_MAKE_FUNC(int, BIO_ctrl, (OSSL_CORE_BIO * bio, int cmd, long num, void *ptr)) +OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, + (OSSL_CORE_BIO * bio, const char *format, va_list args)) +OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf, + (char *buf, size_t n, const char *fmt, va_list args)) +OSSL_CORE_MAKE_FUNC(int, BIO_ctrl, + (OSSL_CORE_BIO * bio, int cmd, long num, void *ptr)) #define OSSL_FUNC_SELF_TEST_CB 100 -OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX * ctx, OSSL_CALLBACK **cb, void **cbarg)) +OSSL_CORE_MAKE_FUNC(void, self_test_cb, + (OPENSSL_CORE_CTX * ctx, OSSL_CALLBACK **cb, void **cbarg)) /* Functions to get seed material from the operating system */ #define OSSL_FUNC_GET_ENTROPY 101 @@ -159,15 +182,18 @@ OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX * ctx, OSSL_CALLBACK * #define OSSL_FUNC_GET_NONCE 103 #define OSSL_FUNC_CLEANUP_NONCE 104 OSSL_CORE_MAKE_FUNC(size_t, get_entropy, - (const OSSL_CORE_HANDLE *handle, unsigned char **pout, int entropy, - size_t min_len, size_t max_len)) + (const OSSL_CORE_HANDLE *handle, unsigned char **pout, + int entropy, size_t min_len, size_t max_len)) OSSL_CORE_MAKE_FUNC(void, cleanup_entropy, - (const OSSL_CORE_HANDLE *handle, unsigned char *buf, size_t len)) + (const OSSL_CORE_HANDLE *handle, unsigned char *buf, + size_t len)) OSSL_CORE_MAKE_FUNC(size_t, get_nonce, - (const OSSL_CORE_HANDLE *handle, unsigned char **pout, size_t min_len, - size_t max_len, const void *salt, size_t salt_len)) + (const OSSL_CORE_HANDLE *handle, unsigned char **pout, + size_t min_len, size_t max_len, const void *salt, + size_t salt_len)) OSSL_CORE_MAKE_FUNC(void, cleanup_nonce, - (const OSSL_CORE_HANDLE *handle, unsigned char *buf, size_t len)) + (const OSSL_CORE_HANDLE *handle, unsigned char *buf, + size_t len)) /* Functions to access the core's providers */ #define OSSL_FUNC_PROVIDER_REGISTER_CHILD_CB 105 @@ -178,25 +204,33 @@ OSSL_CORE_MAKE_FUNC(void, cleanup_nonce, #define OSSL_FUNC_PROVIDER_UP_REF 110 #define OSSL_FUNC_PROVIDER_FREE 111 -OSSL_CORE_MAKE_FUNC(int, provider_register_child_cb, - (const OSSL_CORE_HANDLE *handle, - int (*create_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), - int (*remove_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), - int (*global_props_cb)(const char *props, void *cbdata), void *cbdata)) -OSSL_CORE_MAKE_FUNC(void, provider_deregister_child_cb, (const OSSL_CORE_HANDLE *handle)) +OSSL_CORE_MAKE_FUNC( + int, provider_register_child_cb, + (const OSSL_CORE_HANDLE *handle, + int (*create_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), + int (*remove_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), + int (*global_props_cb)(const char *props, void *cbdata), void *cbdata)) +OSSL_CORE_MAKE_FUNC(void, provider_deregister_child_cb, + (const OSSL_CORE_HANDLE *handle)) OSSL_CORE_MAKE_FUNC(const char *, provider_name, (const OSSL_CORE_HANDLE *prov)) -OSSL_CORE_MAKE_FUNC(void *, provider_get0_provider_ctx, (const OSSL_CORE_HANDLE *prov)) -OSSL_CORE_MAKE_FUNC(const OSSL_DISPATCH *, provider_get0_dispatch, (const OSSL_CORE_HANDLE *prov)) -OSSL_CORE_MAKE_FUNC(int, provider_up_ref, (const OSSL_CORE_HANDLE *prov, int activate)) -OSSL_CORE_MAKE_FUNC(int, provider_free, (const OSSL_CORE_HANDLE *prov, int deactivate)) +OSSL_CORE_MAKE_FUNC(void *, provider_get0_provider_ctx, + (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(const OSSL_DISPATCH *, provider_get0_dispatch, + (const OSSL_CORE_HANDLE *prov)) +OSSL_CORE_MAKE_FUNC(int, provider_up_ref, + (const OSSL_CORE_HANDLE *prov, int activate)) +OSSL_CORE_MAKE_FUNC(int, provider_free, + (const OSSL_CORE_HANDLE *prov, int deactivate)) /* Functions provided by the provider to the Core, reserved numbers 1024-1535 */ #define OSSL_FUNC_PROVIDER_TEARDOWN 1024 OSSL_CORE_MAKE_FUNC(void, provider_teardown, (void *provctx)) #define OSSL_FUNC_PROVIDER_GETTABLE_PARAMS 1025 -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, provider_gettable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, provider_gettable_params, + (void *provctx)) #define OSSL_FUNC_PROVIDER_GET_PARAMS 1026 -OSSL_CORE_MAKE_FUNC(int, provider_get_params, (void *provctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, provider_get_params, + (void *provctx, OSSL_PARAM params[])) #define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027 OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *, provider_query_operation, (void *provctx, int operation_id, int *no_store)) @@ -204,10 +238,12 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *, provider_query_operation, OSSL_CORE_MAKE_FUNC(void, provider_unquery_operation, (void *provctx, int operation_id, const OSSL_ALGORITHM *)) #define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1029 -OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, provider_get_reason_strings, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, provider_get_reason_strings, + (void *provctx)) #define OSSL_FUNC_PROVIDER_GET_CAPABILITIES 1030 OSSL_CORE_MAKE_FUNC(int, provider_get_capabilities, - (void *provctx, const char *capability, OSSL_CALLBACK *cb, void *arg)) + (void *provctx, const char *capability, OSSL_CALLBACK *cb, + void *arg)) #define OSSL_FUNC_PROVIDER_SELF_TEST 1031 OSSL_CORE_MAKE_FUNC(int, provider_self_test, (void *provctx)) @@ -248,21 +284,28 @@ OSSL_CORE_MAKE_FUNC(int, provider_self_test, (void *provctx)) OSSL_CORE_MAKE_FUNC(void *, digest_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(int, digest_init, (void *dctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, digest_update, (void *dctx, const unsigned char *in, size_t inl)) -OSSL_CORE_MAKE_FUNC(int, digest_final, (void *dctx, unsigned char *out, size_t *outl, size_t outsz)) +OSSL_CORE_MAKE_FUNC(int, digest_update, + (void *dctx, const unsigned char *in, size_t inl)) +OSSL_CORE_MAKE_FUNC(int, digest_final, + (void *dctx, unsigned char *out, size_t *outl, + size_t outsz)) OSSL_CORE_MAKE_FUNC(int, digest_digest, - (void *provctx, const unsigned char *in, size_t inl, unsigned char *out, - size_t *outl, size_t outsz)) + (void *provctx, const unsigned char *in, size_t inl, + unsigned char *out, size_t *outl, size_t outsz)) OSSL_CORE_MAKE_FUNC(void, digest_freectx, (void *dctx)) OSSL_CORE_MAKE_FUNC(void *, digest_dupctx, (void *dctx)) OSSL_CORE_MAKE_FUNC(int, digest_get_params, (OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, digest_set_ctx_params, (void *vctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, digest_get_ctx_params, (void *vctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, digest_set_ctx_params, + (void *vctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, digest_get_ctx_params, + (void *vctx, OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_settable_ctx_params, (void *dctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_ctx_params, (void *dctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_settable_ctx_params, + (void *dctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_ctx_params, + (void *dctx, void *provctx)) /* Symmetric Ciphers */ @@ -283,27 +326,34 @@ OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_ctx_params, (void *dctx, OSSL_CORE_MAKE_FUNC(void *, cipher_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(int, cipher_encrypt_init, - (void *cctx, const unsigned char *key, size_t keylen, const unsigned char *iv, - size_t ivlen, const OSSL_PARAM params[])) + (void *cctx, const unsigned char *key, size_t keylen, + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, cipher_decrypt_init, - (void *cctx, const unsigned char *key, size_t keylen, const unsigned char *iv, - size_t ivlen, const OSSL_PARAM params[])) + (void *cctx, const unsigned char *key, size_t keylen, + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, cipher_update, - (void *cctx, unsigned char *out, size_t *outl, size_t outsize, - const unsigned char *in, size_t inl)) + (void *cctx, unsigned char *out, size_t *outl, + size_t outsize, const unsigned char *in, size_t inl)) OSSL_CORE_MAKE_FUNC(int, cipher_final, - (void *cctx, unsigned char *out, size_t *outl, size_t outsize)) + (void *cctx, unsigned char *out, size_t *outl, + size_t outsize)) OSSL_CORE_MAKE_FUNC(int, cipher_cipher, - (void *cctx, unsigned char *out, size_t *outl, size_t outsize, - const unsigned char *in, size_t inl)) + (void *cctx, unsigned char *out, size_t *outl, + size_t outsize, const unsigned char *in, size_t inl)) OSSL_CORE_MAKE_FUNC(void, cipher_freectx, (void *cctx)) OSSL_CORE_MAKE_FUNC(void *, cipher_dupctx, (void *cctx)) OSSL_CORE_MAKE_FUNC(int, cipher_get_params, (OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, cipher_get_ctx_params, (void *cctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, cipher_set_ctx_params, (void *cctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_get_ctx_params, + (void *cctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, cipher_set_ctx_params, + (void *cctx, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_settable_ctx_params, (void *cctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_ctx_params, (void *cctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_settable_ctx_params, + (void *cctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_ctx_params, + (void *cctx, void *provctx)) /* MACs */ @@ -326,14 +376,20 @@ OSSL_CORE_MAKE_FUNC(void, mac_freectx, (void *mctx)) OSSL_CORE_MAKE_FUNC(int, mac_init, (void *mctx, const unsigned char *key, size_t keylen, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, mac_update, (void *mctx, const unsigned char *in, size_t inl)) -OSSL_CORE_MAKE_FUNC(int, mac_final, (void *mctx, unsigned char *out, size_t *outl, size_t outsize)) +OSSL_CORE_MAKE_FUNC(int, mac_update, + (void *mctx, const unsigned char *in, size_t inl)) +OSSL_CORE_MAKE_FUNC(int, mac_final, + (void *mctx, unsigned char *out, size_t *outl, + size_t outsize)) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_ctx_params, (void *mctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_settable_ctx_params, (void *mctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_ctx_params, + (void *mctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_settable_ctx_params, + (void *mctx, void *provctx)) OSSL_CORE_MAKE_FUNC(int, mac_get_params, (OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, mac_get_ctx_params, (void *mctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, mac_set_ctx_params, (void *mctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, mac_set_ctx_params, + (void *mctx, const OSSL_PARAM params[])) /* KDFs and PRFs */ @@ -354,13 +410,17 @@ OSSL_CORE_MAKE_FUNC(void *, kdf_dupctx, (void *src)) OSSL_CORE_MAKE_FUNC(void, kdf_freectx, (void *kctx)) OSSL_CORE_MAKE_FUNC(void, kdf_reset, (void *kctx)) OSSL_CORE_MAKE_FUNC(int, kdf_derive, - (void *kctx, unsigned char *key, size_t keylen, const OSSL_PARAM params[])) + (void *kctx, unsigned char *key, size_t keylen, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_ctx_params, (void *kctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_settable_ctx_params, (void *kctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_ctx_params, + (void *kctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_settable_ctx_params, + (void *kctx, void *provctx)) OSSL_CORE_MAKE_FUNC(int, kdf_get_params, (OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, kdf_get_ctx_params, (void *kctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, kdf_set_ctx_params, (void *kctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, kdf_set_ctx_params, + (void *kctx, const OSSL_PARAM params[])) /* RAND */ @@ -385,39 +445,49 @@ OSSL_CORE_MAKE_FUNC(int, kdf_set_ctx_params, (void *kctx, const OSSL_PARAM param #define OSSL_FUNC_RAND_CLEAR_SEED 19 OSSL_CORE_MAKE_FUNC(void *, rand_newctx, - (void *provctx, void *parent, const OSSL_DISPATCH *parent_calls)) + (void *provctx, void *parent, + const OSSL_DISPATCH *parent_calls)) OSSL_CORE_MAKE_FUNC(void, rand_freectx, (void *vctx)) OSSL_CORE_MAKE_FUNC(int, rand_instantiate, - (void *vdrbg, unsigned int strength, int prediction_resistance, - const unsigned char *pstr, size_t pstr_len, const OSSL_PARAM params[])) + (void *vdrbg, unsigned int strength, + int prediction_resistance, const unsigned char *pstr, + size_t pstr_len, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, rand_uninstantiate, (void *vdrbg)) OSSL_CORE_MAKE_FUNC(int, rand_generate, - (void *vctx, unsigned char *out, size_t outlen, unsigned int strength, - int prediction_resistance, const unsigned char *addin, size_t addin_len)) + (void *vctx, unsigned char *out, size_t outlen, + unsigned int strength, int prediction_resistance, + const unsigned char *addin, size_t addin_len)) OSSL_CORE_MAKE_FUNC(int, rand_reseed, - (void *vctx, int prediction_resistance, const unsigned char *ent, - size_t ent_len, const unsigned char *addin, size_t addin_len)) + (void *vctx, int prediction_resistance, + const unsigned char *ent, size_t ent_len, + const unsigned char *addin, size_t addin_len)) OSSL_CORE_MAKE_FUNC(size_t, rand_nonce, - (void *vctx, unsigned char *out, unsigned int strength, size_t min_noncelen, - size_t max_noncelen)) + (void *vctx, unsigned char *out, unsigned int strength, + size_t min_noncelen, size_t max_noncelen)) OSSL_CORE_MAKE_FUNC(int, rand_enable_locking, (void *vctx)) OSSL_CORE_MAKE_FUNC(int, rand_lock, (void *vctx)) OSSL_CORE_MAKE_FUNC(void, rand_unlock, (void *vctx)) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, rand_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, rand_gettable_ctx_params, (void *vctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, rand_settable_ctx_params, (void *vctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, rand_gettable_ctx_params, + (void *vctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, rand_settable_ctx_params, + (void *vctx, void *provctx)) OSSL_CORE_MAKE_FUNC(int, rand_get_params, (OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, rand_get_ctx_params, (void *vctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(int, rand_set_ctx_params, (void *vctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, rand_set_ctx_params, + (void *vctx, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(void, rand_set_callbacks, - (void *vctx, OSSL_INOUT_CALLBACK *get_entropy, OSSL_CALLBACK *cleanup_entropy, - OSSL_INOUT_CALLBACK *get_nonce, OSSL_CALLBACK *cleanup_nonce, void *arg)) + (void *vctx, OSSL_INOUT_CALLBACK *get_entropy, + OSSL_CALLBACK *cleanup_entropy, + OSSL_INOUT_CALLBACK *get_nonce, + OSSL_CALLBACK *cleanup_nonce, void *arg)) OSSL_CORE_MAKE_FUNC(int, rand_verify_zeroization, (void *vctx)) OSSL_CORE_MAKE_FUNC(size_t, rand_get_seed, - (void *vctx, unsigned char **buffer, int entropy, size_t min_len, - size_t max_len, int prediction_resistance, const unsigned char *adin, - size_t adin_len)) -OSSL_CORE_MAKE_FUNC(void, rand_clear_seed, (void *vctx, unsigned char *buffer, size_t b_len)) + (void *vctx, unsigned char **buffer, int entropy, + size_t min_len, size_t max_len, int prediction_resistance, + const unsigned char *adin, size_t adin_len)) +OSSL_CORE_MAKE_FUNC(void, rand_clear_seed, + (void *vctx, unsigned char *buffer, size_t b_len)) /*- * Key management @@ -461,11 +531,12 @@ OSSL_CORE_MAKE_FUNC(void, rand_clear_seed, (void *vctx, unsigned char *buffer, s #define OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS 0x80 /* Key data subset selection - combinations */ -#define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS \ - (OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) -#define OSSL_KEYMGMT_SELECT_KEYPAIR \ - (OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY) -#define OSSL_KEYMGMT_SELECT_ALL (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) +#define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS \ + (OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) +#define OSSL_KEYMGMT_SELECT_KEYPAIR \ + (OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY) +#define OSSL_KEYMGMT_SELECT_ALL \ + (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) #define OSSL_KEYMGMT_VALIDATE_FULL_CHECK 0 #define OSSL_KEYMGMT_VALIDATE_QUICK_CHECK 1 @@ -484,14 +555,18 @@ OSSL_CORE_MAKE_FUNC(void *, keymgmt_new, (void *provctx)) OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen_init, (void *provctx, int selection, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_template, (void *genctx, void *templ)) -OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_params, (void *genctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gen_settable_params, (void *genctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen, (void *genctx, OSSL_CALLBACK *cb, void *cbarg)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_params, + (void *genctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gen_settable_params, + (void *genctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen, + (void *genctx, OSSL_CALLBACK *cb, void *cbarg)) OSSL_CORE_MAKE_FUNC(void, keymgmt_gen_cleanup, (void *genctx)) /* Key loading by object reference */ #define OSSL_FUNC_KEYMGMT_LOAD 8 -OSSL_CORE_MAKE_FUNC(void *, keymgmt_load, (const void *reference, size_t reference_sz)) +OSSL_CORE_MAKE_FUNC(void *, keymgmt_load, + (const void *reference, size_t reference_sz)) /* Basic key object destruction */ #define OSSL_FUNC_KEYMGMT_FREE 10 @@ -500,17 +575,22 @@ OSSL_CORE_MAKE_FUNC(void, keymgmt_free, (void *keydata)) /* Key object information, with discovery */ #define OSSL_FUNC_KEYMGMT_GET_PARAMS 11 #define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS 12 -OSSL_CORE_MAKE_FUNC(int, keymgmt_get_params, (void *keydata, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gettable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_get_params, + (void *keydata, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gettable_params, + (void *provctx)) #define OSSL_FUNC_KEYMGMT_SET_PARAMS 13 #define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS 14 -OSSL_CORE_MAKE_FUNC(int, keymgmt_set_params, (void *keydata, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_settable_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_set_params, + (void *keydata, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_settable_params, + (void *provctx)) /* Key checks - discovery of supported operations */ #define OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME 20 -OSSL_CORE_MAKE_FUNC(const char *, keymgmt_query_operation_name, (int operation_id)) +OSSL_CORE_MAKE_FUNC(const char *, keymgmt_query_operation_name, + (int operation_id)) /* Key checks - key data content checks */ #define OSSL_FUNC_KEYMGMT_HAS 21 @@ -518,26 +598,31 @@ OSSL_CORE_MAKE_FUNC(int, keymgmt_has, (const void *keydata, int selection)) /* Key checks - validation */ #define OSSL_FUNC_KEYMGMT_VALIDATE 22 -OSSL_CORE_MAKE_FUNC(int, keymgmt_validate, (const void *keydata, int selection, int checktype)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_validate, + (const void *keydata, int selection, int checktype)) /* Key checks - matching */ #define OSSL_FUNC_KEYMGMT_MATCH 23 -OSSL_CORE_MAKE_FUNC(int, keymgmt_match, (const void *keydata1, const void *keydata2, int selection)) +OSSL_CORE_MAKE_FUNC(int, keymgmt_match, + (const void *keydata1, const void *keydata2, int selection)) /* Import and export functions, with discovery */ #define OSSL_FUNC_KEYMGMT_IMPORT 40 #define OSSL_FUNC_KEYMGMT_IMPORT_TYPES 41 #define OSSL_FUNC_KEYMGMT_EXPORT 42 #define OSSL_FUNC_KEYMGMT_EXPORT_TYPES 43 -OSSL_CORE_MAKE_FUNC(int, keymgmt_import, (void *keydata, int selection, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, keymgmt_import, + (void *keydata, int selection, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types, (int selection)) OSSL_CORE_MAKE_FUNC(int, keymgmt_export, - (void *keydata, int selection, OSSL_CALLBACK *param_cb, void *cbarg)) + (void *keydata, int selection, OSSL_CALLBACK *param_cb, + void *cbarg)) OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types, (int selection)) /* Dup function, constructor */ #define OSSL_FUNC_KEYMGMT_DUP 44 -OSSL_CORE_MAKE_FUNC(void *, keymgmt_dup, (const void *keydata_from, int selection)) +OSSL_CORE_MAKE_FUNC(void *, keymgmt_dup, + (const void *keydata_from, int selection)) /* Key Exchange */ @@ -553,16 +638,22 @@ OSSL_CORE_MAKE_FUNC(void *, keymgmt_dup, (const void *keydata_from, int selectio #define OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS 10 OSSL_CORE_MAKE_FUNC(void *, keyexch_newctx, (void *provctx)) -OSSL_CORE_MAKE_FUNC(int, keyexch_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, keyexch_init, + (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, keyexch_derive, - (void *ctx, unsigned char *secret, size_t *secretlen, size_t outlen)) + (void *ctx, unsigned char *secret, size_t *secretlen, + size_t outlen)) OSSL_CORE_MAKE_FUNC(int, keyexch_set_peer, (void *ctx, void *provkey)) OSSL_CORE_MAKE_FUNC(void, keyexch_freectx, (void *ctx)) OSSL_CORE_MAKE_FUNC(void *, keyexch_dupctx, (void *ctx)) -OSSL_CORE_MAKE_FUNC(int, keyexch_set_ctx_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_settable_ctx_params, (void *ctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(int, keyexch_get_ctx_params, (void *ctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_gettable_ctx_params, (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keyexch_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_settable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, keyexch_get_ctx_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_gettable_ctx_params, + (void *ctx, void *provctx)) /* Signature */ @@ -592,49 +683,62 @@ OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_gettable_ctx_params, (void *ctx, #define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 24 #define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25 -OSSL_CORE_MAKE_FUNC(void *, signature_newctx, (void *provctx, const char *propq)) -OSSL_CORE_MAKE_FUNC(int, signature_sign_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(void *, signature_newctx, + (void *provctx, const char *propq)) +OSSL_CORE_MAKE_FUNC(int, signature_sign_init, + (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, signature_sign, - (void *ctx, unsigned char *sig, size_t *siglen, size_t sigsize, - const unsigned char *tbs, size_t tbslen)) + (void *ctx, unsigned char *sig, size_t *siglen, + size_t sigsize, const unsigned char *tbs, size_t tbslen)) OSSL_CORE_MAKE_FUNC(int, signature_verify_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, signature_verify, - (void *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, - size_t tbslen)) + (void *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen)) OSSL_CORE_MAKE_FUNC(int, signature_verify_recover_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, signature_verify_recover, - (void *ctx, unsigned char *rout, size_t *routlen, size_t routsize, - const unsigned char *sig, size_t siglen)) + (void *ctx, unsigned char *rout, size_t *routlen, + size_t routsize, const unsigned char *sig, size_t siglen)) OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_init, - (void *ctx, const char *mdname, void *provkey, const OSSL_PARAM params[])) + (void *ctx, const char *mdname, void *provkey, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_update, (void *ctx, const unsigned char *data, size_t datalen)) OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_final, - (void *ctx, unsigned char *sig, size_t *siglen, size_t sigsize)) + (void *ctx, unsigned char *sig, size_t *siglen, + size_t sigsize)) OSSL_CORE_MAKE_FUNC(int, signature_digest_sign, - (void *ctx, unsigned char *sigret, size_t *siglen, size_t sigsize, - const unsigned char *tbs, size_t tbslen)) + (void *ctx, unsigned char *sigret, size_t *siglen, + size_t sigsize, const unsigned char *tbs, size_t tbslen)) OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_init, - (void *ctx, const char *mdname, void *provkey, const OSSL_PARAM params[])) + (void *ctx, const char *mdname, void *provkey, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_update, (void *ctx, const unsigned char *data, size_t datalen)) OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_final, (void *ctx, const unsigned char *sig, size_t siglen)) OSSL_CORE_MAKE_FUNC(int, signature_digest_verify, - (void *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, - size_t tbslen)) + (void *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen)) OSSL_CORE_MAKE_FUNC(void, signature_freectx, (void *ctx)) OSSL_CORE_MAKE_FUNC(void *, signature_dupctx, (void *ctx)) -OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_params, (void *ctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_params, (void *ctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_params, (void *ctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_md_params, (void *ctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_md_params, (void *ctx)) -OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_md_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_md_params, (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_md_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_md_params, + (void *ctx)) +OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_md_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_md_params, + (void *ctx)) /* Asymmetric Ciphers */ @@ -654,19 +758,23 @@ OSSL_CORE_MAKE_FUNC(void *, asym_cipher_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt, - (void *ctx, unsigned char *out, size_t *outlen, size_t outsize, - const unsigned char *in, size_t inlen)) + (void *ctx, unsigned char *out, size_t *outlen, + size_t outsize, const unsigned char *in, size_t inlen)) OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt, - (void *ctx, unsigned char *out, size_t *outlen, size_t outsize, - const unsigned char *in, size_t inlen)) + (void *ctx, unsigned char *out, size_t *outlen, + size_t outsize, const unsigned char *in, size_t inlen)) OSSL_CORE_MAKE_FUNC(void, asym_cipher_freectx, (void *ctx)) OSSL_CORE_MAKE_FUNC(void *, asym_cipher_dupctx, (void *ctx)) -OSSL_CORE_MAKE_FUNC(int, asym_cipher_get_ctx_params, (void *ctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_gettable_ctx_params, (void *ctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(int, asym_cipher_set_ctx_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_settable_ctx_params, (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_get_ctx_params, + (void *ctx, OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_gettable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, asym_cipher_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_settable_ctx_params, + (void *ctx, void *provctx)) /* Asymmetric Key encapsulation */ #define OSSL_FUNC_KEM_NEWCTX 1 @@ -687,23 +795,28 @@ OSSL_CORE_MAKE_FUNC(void *, kem_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(int, kem_encapsulate_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, kem_auth_encapsulate_init, - (void *ctx, void *provkey, void *authprivkey, const OSSL_PARAM params[])) + (void *ctx, void *provkey, void *authprivkey, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, kem_encapsulate, - (void *ctx, unsigned char *out, size_t *outlen, unsigned char *secret, - size_t *secretlen)) + (void *ctx, unsigned char *out, size_t *outlen, + unsigned char *secret, size_t *secretlen)) OSSL_CORE_MAKE_FUNC(int, kem_decapsulate_init, (void *ctx, void *provkey, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, kem_auth_decapsulate_init, - (void *ctx, void *provkey, void *authpubkey, const OSSL_PARAM params[])) + (void *ctx, void *provkey, void *authpubkey, + const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, kem_decapsulate, - (void *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, - size_t inlen)) + (void *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)) OSSL_CORE_MAKE_FUNC(void, kem_freectx, (void *ctx)) OSSL_CORE_MAKE_FUNC(void *, kem_dupctx, (void *ctx)) OSSL_CORE_MAKE_FUNC(int, kem_get_ctx_params, (void *ctx, OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_gettable_ctx_params, (void *ctx, void *provctx)) -OSSL_CORE_MAKE_FUNC(int, kem_set_ctx_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_settable_ctx_params, (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_gettable_ctx_params, + (void *ctx, void *provctx)) +OSSL_CORE_MAKE_FUNC(int, kem_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_settable_ctx_params, + (void *ctx, void *provctx)) /* Encoders and decoders */ #define OSSL_FUNC_ENCODER_NEWCTX 1 @@ -719,15 +832,18 @@ OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_settable_ctx_params, (void *ctx, voi OSSL_CORE_MAKE_FUNC(void *, encoder_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(void, encoder_freectx, (void *ctx)) OSSL_CORE_MAKE_FUNC(int, encoder_get_params, (OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(int, encoder_set_ctx_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_settable_ctx_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_gettable_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, encoder_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_settable_ctx_params, + (void *provctx)) OSSL_CORE_MAKE_FUNC(int, encoder_does_selection, (void *provctx, int selection)) OSSL_CORE_MAKE_FUNC(int, encoder_encode, (void *ctx, OSSL_CORE_BIO *out, const void *obj_raw, - const OSSL_PARAM obj_abstract[], int selection, OSSL_PASSPHRASE_CALLBACK *cb, - void *cbarg)) + const OSSL_PARAM obj_abstract[], int selection, + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)) OSSL_CORE_MAKE_FUNC(void *, encoder_import_object, (void *ctx, int selection, const OSSL_PARAM params[])) @@ -745,17 +861,21 @@ OSSL_CORE_MAKE_FUNC(void, encoder_free_object, (void *obj)) OSSL_CORE_MAKE_FUNC(void *, decoder_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(void, decoder_freectx, (void *ctx)) OSSL_CORE_MAKE_FUNC(int, decoder_get_params, (OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_gettable_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(int, decoder_set_ctx_params, (void *ctx, const OSSL_PARAM params[])) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_settable_ctx_params, (void *provctx)) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_gettable_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, decoder_set_ctx_params, + (void *ctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_settable_ctx_params, + (void *provctx)) OSSL_CORE_MAKE_FUNC(int, decoder_does_selection, (void *provctx, int selection)) OSSL_CORE_MAKE_FUNC(int, decoder_decode, - (void *ctx, OSSL_CORE_BIO *in, int selection, OSSL_CALLBACK *data_cb, - void *data_cbarg, OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) + (void *ctx, OSSL_CORE_BIO *in, int selection, + OSSL_CALLBACK *data_cb, void *data_cbarg, + OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) OSSL_CORE_MAKE_FUNC(int, decoder_export_object, - (void *ctx, const void *objref, size_t objref_sz, OSSL_CALLBACK *export_cb, - void *export_cbarg)) + (void *ctx, const void *objref, size_t objref_sz, + OSSL_CALLBACK *export_cb, void *export_cbarg)) /*- * Store @@ -779,11 +899,14 @@ OSSL_CORE_MAKE_FUNC(int, decoder_export_object, #define OSSL_FUNC_STORE_EXPORT_OBJECT 8 OSSL_CORE_MAKE_FUNC(void *, store_open, (void *provctx, const char *uri)) OSSL_CORE_MAKE_FUNC(void *, store_attach, (void *provctx, OSSL_CORE_BIO *in)) -OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, store_settable_ctx_params, (void *provctx)) -OSSL_CORE_MAKE_FUNC(int, store_set_ctx_params, (void *loaderctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, store_settable_ctx_params, + (void *provctx)) +OSSL_CORE_MAKE_FUNC(int, store_set_ctx_params, + (void *loaderctx, const OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, store_load, - (void *loaderctx, OSSL_CALLBACK *object_cb, void *object_cbarg, - OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) + (void *loaderctx, OSSL_CALLBACK *object_cb, + void *object_cbarg, OSSL_PASSPHRASE_CALLBACK *pw_cb, + void *pw_cbarg)) OSSL_CORE_MAKE_FUNC(int, store_eof, (void *loaderctx)) OSSL_CORE_MAKE_FUNC(int, store_close, (void *loaderctx)) OSSL_CORE_MAKE_FUNC(int, store_export_object, diff --git a/libs/OpenSSL/include/openssl/core_names.h b/libs/OpenSSL/include/openssl/core_names.h index f849de2d..27bddcf1 100644 --- a/libs/OpenSSL/include/openssl/core_names.h +++ b/libs/OpenSSL/include/openssl/core_names.h @@ -16,21 +16,21 @@ extern "C" { #endif /* Well known parameter names that core passes to providers */ -#define OSSL_PROV_PARAM_CORE_VERSION "openssl-version" /* utf8_ptr */ -#define OSSL_PROV_PARAM_CORE_PROV_NAME "provider-name" /* utf8_ptr */ +#define OSSL_PROV_PARAM_CORE_VERSION "openssl-version" /* utf8_ptr */ +#define OSSL_PROV_PARAM_CORE_PROV_NAME "provider-name" /* utf8_ptr */ #define OSSL_PROV_PARAM_CORE_MODULE_FILENAME "module-filename" /* utf8_ptr */ /* Well known parameter names that Providers can define */ -#define OSSL_PROV_PARAM_NAME "name" /* utf8_ptr */ -#define OSSL_PROV_PARAM_VERSION "version" /* utf8_ptr */ -#define OSSL_PROV_PARAM_BUILDINFO "buildinfo" /* utf8_ptr */ -#define OSSL_PROV_PARAM_STATUS "status" /* uint */ +#define OSSL_PROV_PARAM_NAME "name" /* utf8_ptr */ +#define OSSL_PROV_PARAM_VERSION "version" /* utf8_ptr */ +#define OSSL_PROV_PARAM_BUILDINFO "buildinfo" /* utf8_ptr */ +#define OSSL_PROV_PARAM_STATUS "status" /* uint */ #define OSSL_PROV_PARAM_SECURITY_CHECKS "security-checks" /* uint */ /* Self test callback parameters */ #define OSSL_PROV_PARAM_SELF_TEST_PHASE "st-phase" /* utf8_string */ -#define OSSL_PROV_PARAM_SELF_TEST_TYPE "st-type" /* utf8_string */ -#define OSSL_PROV_PARAM_SELF_TEST_DESC "st-desc" /* utf8_string */ +#define OSSL_PROV_PARAM_SELF_TEST_TYPE "st-type" /* utf8_string */ +#define OSSL_PROV_PARAM_SELF_TEST_DESC "st-desc" /* utf8_string */ /*- * Provider-native object abstractions @@ -43,10 +43,10 @@ extern "C" { * This set of parameter names is explained in detail in provider-object(7) * (doc/man7/provider-object.pod) */ -#define OSSL_OBJECT_PARAM_TYPE "type" /* INTEGER */ -#define OSSL_OBJECT_PARAM_DATA_TYPE "data-type" /* UTF8_STRING */ +#define OSSL_OBJECT_PARAM_TYPE "type" /* INTEGER */ +#define OSSL_OBJECT_PARAM_DATA_TYPE "data-type" /* UTF8_STRING */ #define OSSL_OBJECT_PARAM_DATA_STRUCTURE "data-structure" /* UTF8_STRING */ -#define OSSL_OBJECT_PARAM_REFERENCE "reference" /* OCTET_STRING */ +#define OSSL_OBJECT_PARAM_REFERENCE "reference" /* OCTET_STRING */ #define OSSL_OBJECT_PARAM_DATA "data" /* OCTET_STRING or UTF8_STRING */ #define OSSL_OBJECT_PARAM_DESC "desc" /* UTF8_STRING */ @@ -57,56 +57,66 @@ extern "C" { * Note these are common names that are shared by many types (such as kdf, mac, * and pkey) e.g: see OSSL_MAC_PARAM_DIGEST below. */ -#define OSSL_ALG_PARAM_DIGEST "digest" /* utf8_string */ -#define OSSL_ALG_PARAM_CIPHER "cipher" /* utf8_string */ -#define OSSL_ALG_PARAM_ENGINE "engine" /* utf8_string */ -#define OSSL_ALG_PARAM_MAC "mac" /* utf8_string */ +#define OSSL_ALG_PARAM_DIGEST "digest" /* utf8_string */ +#define OSSL_ALG_PARAM_CIPHER "cipher" /* utf8_string */ +#define OSSL_ALG_PARAM_ENGINE "engine" /* utf8_string */ +#define OSSL_ALG_PARAM_MAC "mac" /* utf8_string */ #define OSSL_ALG_PARAM_PROPERTIES "properties" /* utf8_string */ /* cipher parameters */ -#define OSSL_CIPHER_PARAM_PADDING "padding" /* uint */ -#define OSSL_CIPHER_PARAM_USE_BITS "use-bits" /* uint */ -#define OSSL_CIPHER_PARAM_TLS_VERSION "tls-version" /* uint */ -#define OSSL_CIPHER_PARAM_TLS_MAC "tls-mac" /* octet_ptr */ +#define OSSL_CIPHER_PARAM_PADDING "padding" /* uint */ +#define OSSL_CIPHER_PARAM_USE_BITS "use-bits" /* uint */ +#define OSSL_CIPHER_PARAM_TLS_VERSION "tls-version" /* uint */ +#define OSSL_CIPHER_PARAM_TLS_MAC "tls-mac" /* octet_ptr */ #define OSSL_CIPHER_PARAM_TLS_MAC_SIZE "tls-mac-size" /* size_t */ -#define OSSL_CIPHER_PARAM_MODE "mode" /* uint */ -#define OSSL_CIPHER_PARAM_BLOCK_SIZE "blocksize" /* size_t */ -#define OSSL_CIPHER_PARAM_AEAD "aead" /* int, 0 or 1 */ -#define OSSL_CIPHER_PARAM_CUSTOM_IV "custom-iv" /* int, 0 or 1 */ -#define OSSL_CIPHER_PARAM_CTS "cts" /* int, 0 or 1 */ +#define OSSL_CIPHER_PARAM_MODE "mode" /* uint */ +#define OSSL_CIPHER_PARAM_BLOCK_SIZE "blocksize" /* size_t */ +#define OSSL_CIPHER_PARAM_AEAD "aead" /* int, 0 or 1 */ +#define OSSL_CIPHER_PARAM_CUSTOM_IV "custom-iv" /* int, 0 or 1 */ +#define OSSL_CIPHER_PARAM_CTS "cts" /* int, 0 or 1 */ #define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK "tls-multi" /* int, 0 or 1 */ -#define OSSL_CIPHER_PARAM_HAS_RAND_KEY "has-randkey" /* int, 0 or 1 */ -#define OSSL_CIPHER_PARAM_KEYLEN "keylen" /* size_t */ -#define OSSL_CIPHER_PARAM_IVLEN "ivlen" /* size_t */ +#define OSSL_CIPHER_PARAM_HAS_RAND_KEY "has-randkey" /* int, 0 or 1 */ +#define OSSL_CIPHER_PARAM_KEYLEN "keylen" /* size_t */ +#define OSSL_CIPHER_PARAM_IVLEN "ivlen" /* size_t */ #define OSSL_CIPHER_PARAM_IV "iv" /* octet_string OR octet_ptr */ -#define OSSL_CIPHER_PARAM_UPDATED_IV "updated-iv" /* octet_string OR octet_ptr */ -#define OSSL_CIPHER_PARAM_NUM "num" /* uint */ -#define OSSL_CIPHER_PARAM_ROUNDS "rounds" /* uint */ -#define OSSL_CIPHER_PARAM_AEAD_TAG "tag" /* octet_string */ +#define OSSL_CIPHER_PARAM_UPDATED_IV \ + "updated-iv" /* octet_string OR octet_ptr */ +#define OSSL_CIPHER_PARAM_NUM "num" /* uint */ +#define OSSL_CIPHER_PARAM_ROUNDS "rounds" /* uint */ +#define OSSL_CIPHER_PARAM_AEAD_TAG "tag" /* octet_string */ #define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD "tlsaad" /* octet_string */ -#define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD "tlsaadpad" /* size_t */ +#define OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD "tlsaadpad" /* size_t */ #define OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED "tlsivfixed" /* octet_string */ #define OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN "tlsivgen" /* octet_string */ #define OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV "tlsivinv" /* octet_string */ #define OSSL_CIPHER_PARAM_AEAD_IVLEN OSSL_CIPHER_PARAM_IVLEN -#define OSSL_CIPHER_PARAM_AEAD_TAGLEN "taglen" /* size_t */ +#define OSSL_CIPHER_PARAM_AEAD_TAGLEN "taglen" /* size_t */ #define OSSL_CIPHER_PARAM_AEAD_MAC_KEY "mackey" /* octet_string */ -#define OSSL_CIPHER_PARAM_RANDOM_KEY "randkey" /* octet_string */ +#define OSSL_CIPHER_PARAM_RANDOM_KEY "randkey" /* octet_string */ #define OSSL_CIPHER_PARAM_RC2_KEYBITS "keybits" /* size_t */ -#define OSSL_CIPHER_PARAM_SPEED "speed" /* uint */ -#define OSSL_CIPHER_PARAM_CTS_MODE "cts_mode" /* utf8_string */ +#define OSSL_CIPHER_PARAM_SPEED "speed" /* uint */ +#define OSSL_CIPHER_PARAM_CTS_MODE "cts_mode" /* utf8_string */ /* For passing the AlgorithmIdentifier parameter in DER form */ -#define OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS "alg_id_param" /* octet_string */ -#define OSSL_CIPHER_PARAM_XTS_STANDARD "xts_standard" /* utf8_string */ +#define OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS "alg_id_param" /* octet_string \ + */ +#define OSSL_CIPHER_PARAM_XTS_STANDARD "xts_standard" /* utf8_string */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT "tls1multi_maxsndfrag" /* uint */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE "tls1multi_maxbufsz" /* size_t */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE "tls1multi_interleave" /* uint */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD "tls1multi_aad" /* octet_string */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN "tls1multi_aadpacklen" /* uint */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC "tls1multi_enc" /* octet_string */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN "tls1multi_encin" /* octet_string */ -#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN "tls1multi_enclen" /* size_t */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT \ + "tls1multi_maxsndfrag" /* uint */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE \ + "tls1multi_maxbufsz" /* size_t */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE \ + "tls1multi_interleave" /* uint */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD "tls1multi_aad" /* octet_string \ + */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN \ + "tls1multi_aadpacklen" /* uint */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC "tls1multi_enc" /* octet_string \ + */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN \ + "tls1multi_encin" /* octet_string */ +#define OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN \ + "tls1multi_enclen" /* size_t */ /* OSSL_CIPHER_PARAM_CTS_MODE Values */ #define OSSL_CIPHER_CTS_MODE_CS1 "CS1" @@ -119,13 +129,13 @@ extern "C" { #define OSSL_CIPHER_NAME_AES_256_GCM_SIV "AES-256-GCM-SIV" /* digest parameters */ -#define OSSL_DIGEST_PARAM_XOFLEN "xoflen" /* size_t */ -#define OSSL_DIGEST_PARAM_SSL3_MS "ssl3-ms" /* octet string */ -#define OSSL_DIGEST_PARAM_PAD_TYPE "pad-type" /* uint */ -#define OSSL_DIGEST_PARAM_MICALG "micalg" /* utf8 string */ -#define OSSL_DIGEST_PARAM_BLOCK_SIZE "blocksize" /* size_t */ -#define OSSL_DIGEST_PARAM_SIZE "size" /* size_t */ -#define OSSL_DIGEST_PARAM_XOF "xof" /* int, 0 or 1 */ +#define OSSL_DIGEST_PARAM_XOFLEN "xoflen" /* size_t */ +#define OSSL_DIGEST_PARAM_SSL3_MS "ssl3-ms" /* octet string */ +#define OSSL_DIGEST_PARAM_PAD_TYPE "pad-type" /* uint */ +#define OSSL_DIGEST_PARAM_MICALG "micalg" /* utf8 string */ +#define OSSL_DIGEST_PARAM_BLOCK_SIZE "blocksize" /* size_t */ +#define OSSL_DIGEST_PARAM_SIZE "size" /* size_t */ +#define OSSL_DIGEST_PARAM_XOF "xof" /* int, 0 or 1 */ #define OSSL_DIGEST_PARAM_ALGID_ABSENT "algid-absent" /* int, 0 or 1 */ /* Known DIGEST names (not a complete list) */ @@ -151,26 +161,26 @@ extern "C" { #define OSSL_DIGEST_NAME_SM3 "SM3" /* MAC parameters */ -#define OSSL_MAC_PARAM_KEY "key" /* octet string */ -#define OSSL_MAC_PARAM_IV "iv" /* octet string */ -#define OSSL_MAC_PARAM_CUSTOM "custom" /* utf8 string */ -#define OSSL_MAC_PARAM_SALT "salt" /* octet string */ -#define OSSL_MAC_PARAM_XOF "xof" /* int, 0 or 1 */ -#define OSSL_MAC_PARAM_DIGEST_NOINIT "digest-noinit" /* int, 0 or 1 */ +#define OSSL_MAC_PARAM_KEY "key" /* octet string */ +#define OSSL_MAC_PARAM_IV "iv" /* octet string */ +#define OSSL_MAC_PARAM_CUSTOM "custom" /* utf8 string */ +#define OSSL_MAC_PARAM_SALT "salt" /* octet string */ +#define OSSL_MAC_PARAM_XOF "xof" /* int, 0 or 1 */ +#define OSSL_MAC_PARAM_DIGEST_NOINIT "digest-noinit" /* int, 0 or 1 */ #define OSSL_MAC_PARAM_DIGEST_ONESHOT "digest-oneshot" /* int, 0 or 1 */ -#define OSSL_MAC_PARAM_C_ROUNDS "c-rounds" /* unsigned int */ -#define OSSL_MAC_PARAM_D_ROUNDS "d-rounds" /* unsigned int */ +#define OSSL_MAC_PARAM_C_ROUNDS "c-rounds" /* unsigned int */ +#define OSSL_MAC_PARAM_D_ROUNDS "d-rounds" /* unsigned int */ /* * If "engine" or "properties" are specified, they should always be paired * with "cipher" or "digest". */ -#define OSSL_MAC_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */ -#define OSSL_MAC_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST /* utf8 string */ +#define OSSL_MAC_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */ +#define OSSL_MAC_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST /* utf8 string */ #define OSSL_MAC_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES /* utf8 string */ -#define OSSL_MAC_PARAM_SIZE "size" /* size_t */ -#define OSSL_MAC_PARAM_BLOCK_SIZE "block-size" /* size_t */ -#define OSSL_MAC_PARAM_TLS_DATA_SIZE "tls-data-size" /* size_t */ +#define OSSL_MAC_PARAM_SIZE "size" /* size_t */ +#define OSSL_MAC_PARAM_BLOCK_SIZE "block-size" /* size_t */ +#define OSSL_MAC_PARAM_TLS_DATA_SIZE "tls-data-size" /* size_t */ /* Known MAC names */ #define OSSL_MAC_NAME_BLAKE2BMAC "BLAKE2BMAC" @@ -184,38 +194,38 @@ extern "C" { #define OSSL_MAC_NAME_SIPHASH "SIPHASH" /* KDF / PRF parameters */ -#define OSSL_KDF_PARAM_SECRET "secret" /* octet string */ -#define OSSL_KDF_PARAM_KEY "key" /* octet string */ -#define OSSL_KDF_PARAM_SALT "salt" /* octet string */ -#define OSSL_KDF_PARAM_PASSWORD "pass" /* octet string */ -#define OSSL_KDF_PARAM_PREFIX "prefix" /* octet string */ -#define OSSL_KDF_PARAM_LABEL "label" /* octet string */ -#define OSSL_KDF_PARAM_DATA "data" /* octet string */ -#define OSSL_KDF_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST /* utf8 string */ -#define OSSL_KDF_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */ -#define OSSL_KDF_PARAM_MAC OSSL_ALG_PARAM_MAC /* utf8 string */ -#define OSSL_KDF_PARAM_MAC_SIZE "maclen" /* size_t */ +#define OSSL_KDF_PARAM_SECRET "secret" /* octet string */ +#define OSSL_KDF_PARAM_KEY "key" /* octet string */ +#define OSSL_KDF_PARAM_SALT "salt" /* octet string */ +#define OSSL_KDF_PARAM_PASSWORD "pass" /* octet string */ +#define OSSL_KDF_PARAM_PREFIX "prefix" /* octet string */ +#define OSSL_KDF_PARAM_LABEL "label" /* octet string */ +#define OSSL_KDF_PARAM_DATA "data" /* octet string */ +#define OSSL_KDF_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST /* utf8 string */ +#define OSSL_KDF_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */ +#define OSSL_KDF_PARAM_MAC OSSL_ALG_PARAM_MAC /* utf8 string */ +#define OSSL_KDF_PARAM_MAC_SIZE "maclen" /* size_t */ #define OSSL_KDF_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES /* utf8 string */ -#define OSSL_KDF_PARAM_ITER "iter" /* unsigned int */ -#define OSSL_KDF_PARAM_MODE "mode" /* utf8 string or int */ -#define OSSL_KDF_PARAM_PKCS5 "pkcs5" /* int */ -#define OSSL_KDF_PARAM_UKM "ukm" /* octet string */ -#define OSSL_KDF_PARAM_CEK_ALG "cekalg" /* utf8 string */ -#define OSSL_KDF_PARAM_SCRYPT_N "n" /* uint64_t */ -#define OSSL_KDF_PARAM_SCRYPT_R "r" /* uint32_t */ -#define OSSL_KDF_PARAM_SCRYPT_P "p" /* uint32_t */ -#define OSSL_KDF_PARAM_SCRYPT_MAXMEM "maxmem_bytes" /* uint64_t */ -#define OSSL_KDF_PARAM_INFO "info" /* octet string */ -#define OSSL_KDF_PARAM_SEED "seed" /* octet string */ -#define OSSL_KDF_PARAM_SSHKDF_XCGHASH "xcghash" /* octet string */ +#define OSSL_KDF_PARAM_ITER "iter" /* unsigned int */ +#define OSSL_KDF_PARAM_MODE "mode" /* utf8 string or int */ +#define OSSL_KDF_PARAM_PKCS5 "pkcs5" /* int */ +#define OSSL_KDF_PARAM_UKM "ukm" /* octet string */ +#define OSSL_KDF_PARAM_CEK_ALG "cekalg" /* utf8 string */ +#define OSSL_KDF_PARAM_SCRYPT_N "n" /* uint64_t */ +#define OSSL_KDF_PARAM_SCRYPT_R "r" /* uint32_t */ +#define OSSL_KDF_PARAM_SCRYPT_P "p" /* uint32_t */ +#define OSSL_KDF_PARAM_SCRYPT_MAXMEM "maxmem_bytes" /* uint64_t */ +#define OSSL_KDF_PARAM_INFO "info" /* octet string */ +#define OSSL_KDF_PARAM_SEED "seed" /* octet string */ +#define OSSL_KDF_PARAM_SSHKDF_XCGHASH "xcghash" /* octet string */ #define OSSL_KDF_PARAM_SSHKDF_SESSION_ID "session_id" /* octet string */ -#define OSSL_KDF_PARAM_SSHKDF_TYPE "type" /* int */ -#define OSSL_KDF_PARAM_SIZE "size" /* size_t */ -#define OSSL_KDF_PARAM_CONSTANT "constant" /* octet string */ -#define OSSL_KDF_PARAM_PKCS12_ID "id" /* int */ -#define OSSL_KDF_PARAM_KBKDF_USE_L "use-l" /* int */ +#define OSSL_KDF_PARAM_SSHKDF_TYPE "type" /* int */ +#define OSSL_KDF_PARAM_SIZE "size" /* size_t */ +#define OSSL_KDF_PARAM_CONSTANT "constant" /* octet string */ +#define OSSL_KDF_PARAM_PKCS12_ID "id" /* int */ +#define OSSL_KDF_PARAM_KBKDF_USE_L "use-l" /* int */ #define OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR "use-separator" /* int */ -#define OSSL_KDF_PARAM_KBKDF_R "r" /* int */ +#define OSSL_KDF_PARAM_KBKDF_R "r" /* int */ #define OSSL_KDF_PARAM_X942_ACVPINFO "acvp-info" #define OSSL_KDF_PARAM_X942_PARTYUINFO "partyu-info" #define OSSL_KDF_PARAM_X942_PARTYVINFO "partyv-info" @@ -275,14 +285,14 @@ extern "C" { /* PKEY parameters */ /* Common PKEY parameters */ -#define OSSL_PKEY_PARAM_BITS "bits" /* integer */ -#define OSSL_PKEY_PARAM_MAX_SIZE "max-size" /* integer */ +#define OSSL_PKEY_PARAM_BITS "bits" /* integer */ +#define OSSL_PKEY_PARAM_MAX_SIZE "max-size" /* integer */ #define OSSL_PKEY_PARAM_SECURITY_BITS "security-bits" /* integer */ #define OSSL_PKEY_PARAM_DIGEST OSSL_ALG_PARAM_DIGEST #define OSSL_PKEY_PARAM_CIPHER OSSL_ALG_PARAM_CIPHER /* utf8 string */ #define OSSL_PKEY_PARAM_ENGINE OSSL_ALG_PARAM_ENGINE /* utf8 string */ #define OSSL_PKEY_PARAM_PROPERTIES OSSL_ALG_PARAM_PROPERTIES -#define OSSL_PKEY_PARAM_DEFAULT_DIGEST "default-digest" /* utf8 string */ +#define OSSL_PKEY_PARAM_DEFAULT_DIGEST "default-digest" /* utf8 string */ #define OSSL_PKEY_PARAM_MANDATORY_DIGEST "mandatory-digest" /* utf8 string */ #define OSSL_PKEY_PARAM_PAD_MODE "pad-mode" #define OSSL_PKEY_PARAM_DIGEST_SIZE "digest-size" @@ -439,10 +449,12 @@ extern "C" { /* Key Exchange parameters */ #define OSSL_EXCHANGE_PARAM_PAD "pad" /* uint */ -#define OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE "ecdh-cofactor-mode" /* int */ -#define OSSL_EXCHANGE_PARAM_KDF_TYPE "kdf-type" /* utf8_string */ +#define OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE "ecdh-cofactor-mode" /* int \ + */ +#define OSSL_EXCHANGE_PARAM_KDF_TYPE "kdf-type" /* utf8_string */ #define OSSL_EXCHANGE_PARAM_KDF_DIGEST "kdf-digest" /* utf8_string */ -#define OSSL_EXCHANGE_PARAM_KDF_DIGEST_PROPS "kdf-digest-props" /* utf8_string */ +#define OSSL_EXCHANGE_PARAM_KDF_DIGEST_PROPS \ + "kdf-digest-props" /* utf8_string */ #define OSSL_EXCHANGE_PARAM_KDF_OUTLEN "kdf-outlen" /* size_t */ /* The following parameter is an octet_string on set and an octet_ptr on get */ #define OSSL_EXCHANGE_PARAM_KDF_UKM "kdf-ukm" @@ -543,13 +555,13 @@ extern "C" { * are used as search criteria. * (OSSL_STORE_PARAM_DIGEST is used with OSSL_STORE_PARAM_FINGERPRINT) */ -#define OSSL_STORE_PARAM_EXPECT "expect" /* INTEGER */ +#define OSSL_STORE_PARAM_EXPECT "expect" /* INTEGER */ #define OSSL_STORE_PARAM_SUBJECT "subject" /* DER blob => OCTET_STRING */ -#define OSSL_STORE_PARAM_ISSUER "name" /* DER blob => OCTET_STRING */ -#define OSSL_STORE_PARAM_SERIAL "serial" /* INTEGER */ -#define OSSL_STORE_PARAM_DIGEST "digest" /* UTF8_STRING */ +#define OSSL_STORE_PARAM_ISSUER "name" /* DER blob => OCTET_STRING */ +#define OSSL_STORE_PARAM_SERIAL "serial" /* INTEGER */ +#define OSSL_STORE_PARAM_DIGEST "digest" /* UTF8_STRING */ #define OSSL_STORE_PARAM_FINGERPRINT "fingerprint" /* OCTET_STRING */ -#define OSSL_STORE_PARAM_ALIAS "alias" /* UTF8_STRING */ +#define OSSL_STORE_PARAM_ALIAS "alias" /* UTF8_STRING */ /* You may want to pass properties for the provider implementation to use */ #define OSSL_STORE_PARAM_PROPERTIES "properties" /* utf8_string */ diff --git a/libs/OpenSSL/include/openssl/core_object.h b/libs/OpenSSL/include/openssl/core_object.h index df0c7943..7732e5b8 100644 --- a/libs/OpenSSL/include/openssl/core_object.h +++ b/libs/OpenSSL/include/openssl/core_object.h @@ -28,7 +28,7 @@ extern "C" { #define OSSL_OBJECT_NAME 1 /* char * */ #define OSSL_OBJECT_PKEY 2 /* EVP_PKEY * */ #define OSSL_OBJECT_CERT 3 /* X509 * */ -#define OSSL_OBJECT_CRL 4 /* X509_CRL * */ +#define OSSL_OBJECT_CRL 4 /* X509_CRL * */ /* * The rest of the associated OSSL_PARAM elements is described in core_names.h diff --git a/libs/OpenSSL/include/openssl/crmf.h b/libs/OpenSSL/include/openssl/crmf.h index e13cb61c..328ab74e 100644 --- a/libs/OpenSSL/include/openssl/crmf.h +++ b/libs/OpenSSL/include/openssl/crmf.h @@ -20,27 +20,27 @@ #include #ifndef OPENSSL_NO_CRMF -# include -# include -# include -# include /* for GENERAL_NAME etc. */ +# include +# include +# include +# include /* for GENERAL_NAME etc. */ /* explicit #includes not strictly needed since implied by the above: */ -# include -# include +# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define OSSL_CRMF_POPOPRIVKEY_THISMESSAGE 0 -# define OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE 1 -# define OSSL_CRMF_POPOPRIVKEY_DHMAC 2 -# define OSSL_CRMF_POPOPRIVKEY_AGREEMAC 3 -# define OSSL_CRMF_POPOPRIVKEY_ENCRYPTEDKEY 4 +# define OSSL_CRMF_POPOPRIVKEY_THISMESSAGE 0 +# define OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE 1 +# define OSSL_CRMF_POPOPRIVKEY_DHMAC 2 +# define OSSL_CRMF_POPOPRIVKEY_AGREEMAC 3 +# define OSSL_CRMF_POPOPRIVKEY_ENCRYPTEDKEY 4 -# define OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT 0 -# define OSSL_CRMF_SUBSEQUENTMESSAGE_CHALLENGERESP 1 +# define OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT 0 +# define OSSL_CRMF_SUBSEQUENTMESSAGE_CHALLENGERESP 1 typedef struct ossl_crmf_encryptedvalue_st OSSL_CRMF_ENCRYPTEDVALUE; DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE) @@ -48,63 +48,80 @@ typedef struct ossl_crmf_msg_st OSSL_CRMF_MSG; DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSG) DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_MSG) SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_MSG, OSSL_CRMF_MSG, OSSL_CRMF_MSG) -# define sk_OSSL_CRMF_MSG_num(sk) OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk)) -# define sk_OSSL_CRMF_MSG_value(sk, idx) \ - ((OSSL_CRMF_MSG *)OPENSSL_sk_value(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk), (idx))) -# define sk_OSSL_CRMF_MSG_new(cmp) \ - ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new(ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp))) -# define sk_OSSL_CRMF_MSG_new_null() ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CRMF_MSG_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp), (n))) -# define sk_OSSL_CRMF_MSG_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (n)) -# define sk_OSSL_CRMF_MSG_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) -# define sk_OSSL_CRMF_MSG_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) -# define sk_OSSL_CRMF_MSG_delete(sk, i) \ - ((OSSL_CRMF_MSG *)OPENSSL_sk_delete(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (i))) -# define sk_OSSL_CRMF_MSG_delete_ptr(sk, ptr) \ - ((OSSL_CRMF_MSG *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ - ossl_check_OSSL_CRMF_MSG_type(ptr))) -# define sk_OSSL_CRMF_MSG_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) -# define sk_OSSL_CRMF_MSG_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) -# define sk_OSSL_CRMF_MSG_pop(sk) \ - ((OSSL_CRMF_MSG *)OPENSSL_sk_pop(ossl_check_OSSL_CRMF_MSG_sk_type(sk))) -# define sk_OSSL_CRMF_MSG_shift(sk) \ - ((OSSL_CRMF_MSG *)OPENSSL_sk_shift(ossl_check_OSSL_CRMF_MSG_sk_type(sk))) -# define sk_OSSL_CRMF_MSG_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ - ossl_check_OSSL_CRMF_MSG_freefunc_type(freefunc)) -# define sk_OSSL_CRMF_MSG_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ - ossl_check_OSSL_CRMF_MSG_type(ptr), (idx)) -# define sk_OSSL_CRMF_MSG_set(sk, idx, ptr) \ - ((OSSL_CRMF_MSG *)OPENSSL_sk_set(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (idx), \ - ossl_check_OSSL_CRMF_MSG_type(ptr))) -# define sk_OSSL_CRMF_MSG_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) -# define sk_OSSL_CRMF_MSG_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_type(ptr)) -# define sk_OSSL_CRMF_MSG_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ - ossl_check_OSSL_CRMF_MSG_type(ptr), pnum) -# define sk_OSSL_CRMF_MSG_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) -# define sk_OSSL_CRMF_MSG_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk)) -# define sk_OSSL_CRMF_MSG_dup(sk) \ - ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_dup(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk))) -# define sk_OSSL_CRMF_MSG_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CRMF_MSG_sk_type(sk), \ - ossl_check_OSSL_CRMF_MSG_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CRMF_MSG_freefunc_type(freefunc))) -# define sk_OSSL_CRMF_MSG_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CRMF_MSG_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CRMF_MSG_sk_type(sk), ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp))) +# define sk_OSSL_CRMF_MSG_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk)) +# define sk_OSSL_CRMF_MSG_value(sk, idx) \ + ((OSSL_CRMF_MSG *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CRMF_MSG_sk_type(sk), (idx))) +# define sk_OSSL_CRMF_MSG_new(cmp) \ + ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp))) +# define sk_OSSL_CRMF_MSG_new_null() \ + ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CRMF_MSG_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp), (n))) +# define sk_OSSL_CRMF_MSG_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_MSG_sk_type(sk), (n)) +# define sk_OSSL_CRMF_MSG_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) +# define sk_OSSL_CRMF_MSG_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) +# define sk_OSSL_CRMF_MSG_delete(sk, i) \ + ((OSSL_CRMF_MSG *)OPENSSL_sk_delete(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + (i))) +# define sk_OSSL_CRMF_MSG_delete_ptr(sk, ptr) \ + ((OSSL_CRMF_MSG *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr))) +# define sk_OSSL_CRMF_MSG_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr)) +# define sk_OSSL_CRMF_MSG_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr)) +# define sk_OSSL_CRMF_MSG_pop(sk) \ + ((OSSL_CRMF_MSG *)OPENSSL_sk_pop(ossl_check_OSSL_CRMF_MSG_sk_type(sk))) +# define sk_OSSL_CRMF_MSG_shift(sk) \ + ((OSSL_CRMF_MSG *)OPENSSL_sk_shift(ossl_check_OSSL_CRMF_MSG_sk_type(sk))) +# define sk_OSSL_CRMF_MSG_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_freefunc_type(freefunc)) +# define sk_OSSL_CRMF_MSG_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr), (idx)) +# define sk_OSSL_CRMF_MSG_set(sk, idx, ptr) \ + ((OSSL_CRMF_MSG *)OPENSSL_sk_set(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + (idx), \ + ossl_check_OSSL_CRMF_MSG_type(ptr))) +# define sk_OSSL_CRMF_MSG_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr)) +# define sk_OSSL_CRMF_MSG_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr)) +# define sk_OSSL_CRMF_MSG_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_type(ptr), pnum) +# define sk_OSSL_CRMF_MSG_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CRMF_MSG_sk_type(sk)) +# define sk_OSSL_CRMF_MSG_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_MSG_sk_type(sk)) +# define sk_OSSL_CRMF_MSG_dup(sk) \ + ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CRMF_MSG_sk_type(sk))) +# define sk_OSSL_CRMF_MSG_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CRMF_MSG) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CRMF_MSG_freefunc_type(freefunc))) +# define sk_OSSL_CRMF_MSG_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CRMF_MSG_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CRMF_MSG_sk_type(sk), \ + ossl_check_OSSL_CRMF_MSG_compfunc_type(cmp))) -typedef struct ossl_crmf_attributetypeandvalue_st OSSL_CRMF_ATTRIBUTETYPEANDVALUE; +typedef struct ossl_crmf_attributetypeandvalue_st + OSSL_CRMF_ATTRIBUTETYPEANDVALUE; typedef struct ossl_crmf_pbmparameter_st OSSL_CRMF_PBMPARAMETER; DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER) typedef struct ossl_crmf_poposigningkey_st OSSL_CRMF_POPOSIGNINGKEY; @@ -112,70 +129,81 @@ typedef struct ossl_crmf_certrequest_st OSSL_CRMF_CERTREQUEST; typedef struct ossl_crmf_certid_st OSSL_CRMF_CERTID; DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTID) DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID) -SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_CERTID, OSSL_CRMF_CERTID, OSSL_CRMF_CERTID) -# define sk_OSSL_CRMF_CERTID_num(sk) \ - OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk)) -# define sk_OSSL_CRMF_CERTID_value(sk, idx) \ - ((OSSL_CRMF_CERTID *)OPENSSL_sk_value(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), (idx))) -# define sk_OSSL_CRMF_CERTID_new(cmp) \ - ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new( \ - ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp))) -# define sk_OSSL_CRMF_CERTID_new_null() ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new_null()) -# define sk_OSSL_CRMF_CERTID_new_reserve(cmp, n) \ - ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new_reserve( \ - ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp), (n))) -# define sk_OSSL_CRMF_CERTID_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (n)) -# define sk_OSSL_CRMF_CERTID_free(sk) OPENSSL_sk_free(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) -# define sk_OSSL_CRMF_CERTID_zero(sk) OPENSSL_sk_zero(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) -# define sk_OSSL_CRMF_CERTID_delete(sk, i) \ - ((OSSL_CRMF_CERTID *)OPENSSL_sk_delete(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (i))) -# define sk_OSSL_CRMF_CERTID_delete_ptr(sk, ptr) \ - ((OSSL_CRMF_CERTID *)OPENSSL_sk_delete_ptr(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr))) -# define sk_OSSL_CRMF_CERTID_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr)) -# define sk_OSSL_CRMF_CERTID_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr)) -# define sk_OSSL_CRMF_CERTID_pop(sk) \ - ((OSSL_CRMF_CERTID *)OPENSSL_sk_pop(ossl_check_OSSL_CRMF_CERTID_sk_type(sk))) -# define sk_OSSL_CRMF_CERTID_shift(sk) \ - ((OSSL_CRMF_CERTID *)OPENSSL_sk_shift(ossl_check_OSSL_CRMF_CERTID_sk_type(sk))) -# define sk_OSSL_CRMF_CERTID_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_freefunc_type(freefunc)) -# define sk_OSSL_CRMF_CERTID_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr), (idx)) -# define sk_OSSL_CRMF_CERTID_set(sk, idx, ptr) \ - ((OSSL_CRMF_CERTID *)OPENSSL_sk_set(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (idx), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr))) -# define sk_OSSL_CRMF_CERTID_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr)) -# define sk_OSSL_CRMF_CERTID_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr)) -# define sk_OSSL_CRMF_CERTID_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_type(ptr), pnum) -# define sk_OSSL_CRMF_CERTID_sort(sk) OPENSSL_sk_sort(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) -# define sk_OSSL_CRMF_CERTID_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk)) -# define sk_OSSL_CRMF_CERTID_dup(sk) \ - ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_dup( \ - ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk))) -# define sk_OSSL_CRMF_CERTID_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_copyfunc_type(copyfunc), \ - ossl_check_OSSL_CRMF_CERTID_freefunc_type(freefunc))) -# define sk_OSSL_CRMF_CERTID_set_cmp_func(sk, cmp) \ - ((sk_OSSL_CRMF_CERTID_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ - ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(OSSL_CRMF_CERTID, OSSL_CRMF_CERTID, + OSSL_CRMF_CERTID) +# define sk_OSSL_CRMF_CERTID_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk)) +# define sk_OSSL_CRMF_CERTID_value(sk, idx) \ + ((OSSL_CRMF_CERTID *)OPENSSL_sk_value( \ + ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), (idx))) +# define sk_OSSL_CRMF_CERTID_new(cmp) \ + ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new( \ + ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp))) +# define sk_OSSL_CRMF_CERTID_new_null() \ + ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new_null()) +# define sk_OSSL_CRMF_CERTID_new_reserve(cmp, n) \ + ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_new_reserve( \ + ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp), (n))) +# define sk_OSSL_CRMF_CERTID_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (n)) +# define sk_OSSL_CRMF_CERTID_free(sk) \ + OPENSSL_sk_free(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) +# define sk_OSSL_CRMF_CERTID_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) +# define sk_OSSL_CRMF_CERTID_delete(sk, i) \ + ((OSSL_CRMF_CERTID *)OPENSSL_sk_delete( \ + ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (i))) +# define sk_OSSL_CRMF_CERTID_delete_ptr(sk, ptr) \ + ((OSSL_CRMF_CERTID *)OPENSSL_sk_delete_ptr( \ + ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr))) +# define sk_OSSL_CRMF_CERTID_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr)) +# define sk_OSSL_CRMF_CERTID_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr)) +# define sk_OSSL_CRMF_CERTID_pop(sk) \ + ((OSSL_CRMF_CERTID *)OPENSSL_sk_pop( \ + ossl_check_OSSL_CRMF_CERTID_sk_type(sk))) +# define sk_OSSL_CRMF_CERTID_shift(sk) \ + ((OSSL_CRMF_CERTID *)OPENSSL_sk_shift( \ + ossl_check_OSSL_CRMF_CERTID_sk_type(sk))) +# define sk_OSSL_CRMF_CERTID_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_freefunc_type(freefunc)) +# define sk_OSSL_CRMF_CERTID_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr), (idx)) +# define sk_OSSL_CRMF_CERTID_set(sk, idx, ptr) \ + ((OSSL_CRMF_CERTID *)OPENSSL_sk_set( \ + ossl_check_OSSL_CRMF_CERTID_sk_type(sk), (idx), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr))) +# define sk_OSSL_CRMF_CERTID_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr)) +# define sk_OSSL_CRMF_CERTID_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr)) +# define sk_OSSL_CRMF_CERTID_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_type(ptr), pnum) +# define sk_OSSL_CRMF_CERTID_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OSSL_CRMF_CERTID_sk_type(sk)) +# define sk_OSSL_CRMF_CERTID_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk)) +# define sk_OSSL_CRMF_CERTID_dup(sk) \ + ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_dup( \ + ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk))) +# define sk_OSSL_CRMF_CERTID_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OSSL_CRMF_CERTID) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_copyfunc_type(copyfunc), \ + ossl_check_OSSL_CRMF_CERTID_freefunc_type(freefunc))) +# define sk_OSSL_CRMF_CERTID_set_cmp_func(sk, cmp) \ + ((sk_OSSL_CRMF_CERTID_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OSSL_CRMF_CERTID_sk_type(sk), \ + ossl_check_OSSL_CRMF_CERTID_compfunc_type(cmp))) typedef struct ossl_crmf_pkipublicationinfo_st OSSL_CRMF_PKIPUBLICATIONINFO; DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKIPUBLICATIONINFO) @@ -189,81 +217,103 @@ DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSGS) typedef struct ossl_crmf_optionalvalidity_st OSSL_CRMF_OPTIONALVALIDITY; /* crmf_pbm.c */ -OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(OSSL_LIB_CTX *libctx, size_t slen, int owfnid, - size_t itercnt, int macnid); -int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq, const OSSL_CRMF_PBMPARAMETER *pbmp, - const unsigned char *msg, size_t msglen, const unsigned char *sec, - size_t seclen, unsigned char **mac, size_t *maclen); +OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(OSSL_LIB_CTX *libctx, size_t slen, + int owfnid, size_t itercnt, + int macnid); +int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq, + const OSSL_CRMF_PBMPARAMETER *pbmp, + const unsigned char *msg, size_t msglen, + const unsigned char *sec, size_t seclen, + unsigned char **mac, size_t *maclen); /* crmf_lib.c */ -int OSSL_CRMF_MSG_set1_regCtrl_regToken(OSSL_CRMF_MSG *msg, const ASN1_UTF8STRING *tok); +int OSSL_CRMF_MSG_set1_regCtrl_regToken(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *tok); ASN1_UTF8STRING *OSSL_CRMF_MSG_get0_regCtrl_regToken(const OSSL_CRMF_MSG *msg); -int OSSL_CRMF_MSG_set1_regCtrl_authenticator(OSSL_CRMF_MSG *msg, const ASN1_UTF8STRING *auth); +int OSSL_CRMF_MSG_set1_regCtrl_authenticator(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *auth); ASN1_UTF8STRING *OSSL_CRMF_MSG_get0_regCtrl_authenticator(const OSSL_CRMF_MSG *msg); -int OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo(OSSL_CRMF_PKIPUBLICATIONINFO *pi, - OSSL_CRMF_SINGLEPUBINFO *spi); -# define OSSL_CRMF_PUB_METHOD_DONTCARE 0 -# define OSSL_CRMF_PUB_METHOD_X500 1 -# define OSSL_CRMF_PUB_METHOD_WEB 2 -# define OSSL_CRMF_PUB_METHOD_LDAP 3 -int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi, int method, GENERAL_NAME *nm); -# define OSSL_CRMF_PUB_ACTION_DONTPUBLISH 0 -# define OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH 1 -int OSSL_CRMF_MSG_set_PKIPublicationInfo_action(OSSL_CRMF_PKIPUBLICATIONINFO *pi, int action); -int OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo(OSSL_CRMF_MSG *msg, - const OSSL_CRMF_PKIPUBLICATIONINFO *pi); +int OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, OSSL_CRMF_SINGLEPUBINFO *spi); +# define OSSL_CRMF_PUB_METHOD_DONTCARE 0 +# define OSSL_CRMF_PUB_METHOD_X500 1 +# define OSSL_CRMF_PUB_METHOD_WEB 2 +# define OSSL_CRMF_PUB_METHOD_LDAP 3 +int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi, int method, + GENERAL_NAME *nm); +# define OSSL_CRMF_PUB_ACTION_DONTPUBLISH 0 +# define OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH 1 +int OSSL_CRMF_MSG_set_PKIPublicationInfo_action( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, int action); +int OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo( + OSSL_CRMF_MSG *msg, const OSSL_CRMF_PKIPUBLICATIONINFO *pi); OSSL_CRMF_PKIPUBLICATIONINFO *OSSL_CRMF_MSG_get0_regCtrl_pkiPublicationInfo(const OSSL_CRMF_MSG *msg); -int OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey(OSSL_CRMF_MSG *msg, const X509_PUBKEY *pubkey); +int OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey(OSSL_CRMF_MSG *msg, + const X509_PUBKEY *pubkey); X509_PUBKEY *OSSL_CRMF_MSG_get0_regCtrl_protocolEncrKey(const OSSL_CRMF_MSG *msg); -int OSSL_CRMF_MSG_set1_regCtrl_oldCertID(OSSL_CRMF_MSG *msg, const OSSL_CRMF_CERTID *cid); +int OSSL_CRMF_MSG_set1_regCtrl_oldCertID(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTID *cid); OSSL_CRMF_CERTID *OSSL_CRMF_MSG_get0_regCtrl_oldCertID(const OSSL_CRMF_MSG *msg); -OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer, const ASN1_INTEGER *serial); +OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer, + const ASN1_INTEGER *serial); -int OSSL_CRMF_MSG_set1_regInfo_utf8Pairs(OSSL_CRMF_MSG *msg, const ASN1_UTF8STRING *utf8pairs); +int OSSL_CRMF_MSG_set1_regInfo_utf8Pairs(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *utf8pairs); ASN1_UTF8STRING *OSSL_CRMF_MSG_get0_regInfo_utf8Pairs(const OSSL_CRMF_MSG *msg); -int OSSL_CRMF_MSG_set1_regInfo_certReq(OSSL_CRMF_MSG *msg, const OSSL_CRMF_CERTREQUEST *cr); +int OSSL_CRMF_MSG_set1_regInfo_certReq(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTREQUEST *cr); OSSL_CRMF_CERTREQUEST *OSSL_CRMF_MSG_get0_regInfo_certReq(const OSSL_CRMF_MSG *msg); -int OSSL_CRMF_MSG_set0_validity(OSSL_CRMF_MSG *crm, ASN1_TIME *notBefore, ASN1_TIME *notAfter); +int OSSL_CRMF_MSG_set0_validity(OSSL_CRMF_MSG *crm, ASN1_TIME *notBefore, + ASN1_TIME *notAfter); int OSSL_CRMF_MSG_set_certReqId(OSSL_CRMF_MSG *crm, int rid); int OSSL_CRMF_MSG_get_certReqId(const OSSL_CRMF_MSG *crm); int OSSL_CRMF_MSG_set0_extensions(OSSL_CRMF_MSG *crm, X509_EXTENSIONS *exts); int OSSL_CRMF_MSG_push0_extension(OSSL_CRMF_MSG *crm, X509_EXTENSION *ext); -# define OSSL_CRMF_POPO_NONE -1 -# define OSSL_CRMF_POPO_RAVERIFIED 0 -# define OSSL_CRMF_POPO_SIGNATURE 1 -# define OSSL_CRMF_POPO_KEYENC 2 -# define OSSL_CRMF_POPO_KEYAGREE 3 -int OSSL_CRMF_MSG_create_popo(int meth, OSSL_CRMF_MSG *crm, EVP_PKEY *pkey, const EVP_MD *digest, - OSSL_LIB_CTX *libctx, const char *propq); -int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs, int rid, int acceptRAVerified, - OSSL_LIB_CTX *libctx, const char *propq); +# define OSSL_CRMF_POPO_NONE -1 +# define OSSL_CRMF_POPO_RAVERIFIED 0 +# define OSSL_CRMF_POPO_SIGNATURE 1 +# define OSSL_CRMF_POPO_KEYENC 2 +# define OSSL_CRMF_POPO_KEYAGREE 3 +int OSSL_CRMF_MSG_create_popo(int meth, OSSL_CRMF_MSG *crm, EVP_PKEY *pkey, + const EVP_MD *digest, OSSL_LIB_CTX *libctx, + const char *propq); +int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs, int rid, + int acceptRAVerified, OSSL_LIB_CTX *libctx, + const char *propq); OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm); -const X509_PUBKEY *OSSL_CRMF_CERTTEMPLATE_get0_publicKey(const OSSL_CRMF_CERTTEMPLATE *tmpl); -const X509_NAME *OSSL_CRMF_CERTTEMPLATE_get0_subject(const OSSL_CRMF_CERTTEMPLATE *tmpl); -const X509_NAME *OSSL_CRMF_CERTTEMPLATE_get0_issuer(const OSSL_CRMF_CERTTEMPLATE *tmpl); -const ASN1_INTEGER *OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const X509_PUBKEY * +OSSL_CRMF_CERTTEMPLATE_get0_publicKey(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const X509_NAME * +OSSL_CRMF_CERTTEMPLATE_get0_subject(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const X509_NAME * +OSSL_CRMF_CERTTEMPLATE_get0_issuer(const OSSL_CRMF_CERTTEMPLATE *tmpl); +const ASN1_INTEGER * +OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(const OSSL_CRMF_CERTTEMPLATE *tmpl); X509_EXTENSIONS *OSSL_CRMF_CERTTEMPLATE_get0_extensions(const OSSL_CRMF_CERTTEMPLATE *tmpl); const X509_NAME *OSSL_CRMF_CERTID_get0_issuer(const OSSL_CRMF_CERTID *cid); -const ASN1_INTEGER *OSSL_CRMF_CERTID_get0_serialNumber(const OSSL_CRMF_CERTID *cid); +const ASN1_INTEGER * +OSSL_CRMF_CERTID_get0_serialNumber(const OSSL_CRMF_CERTID *cid); int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl, EVP_PKEY *pubkey, - const X509_NAME *subject, const X509_NAME *issuer, + const X509_NAME *subject, + const X509_NAME *issuer, const ASN1_INTEGER *serial); -X509 *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(const OSSL_CRMF_ENCRYPTEDVALUE *ecert, - OSSL_LIB_CTX *libctx, const char *propq, - EVP_PKEY *pkey); +X509 * +OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(const OSSL_CRMF_ENCRYPTEDVALUE *ecert, + OSSL_LIB_CTX *libctx, const char *propq, + EVP_PKEY *pkey); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* !defined(OPENSSL_NO_CRMF) */ #endif /* !defined(OPENSSL_CRMF_H) */ diff --git a/libs/OpenSSL/include/openssl/crmferr.h b/libs/OpenSSL/include/openssl/crmferr.h index 73890b64..f6ec0cae 100644 --- a/libs/OpenSSL/include/openssl/crmferr.h +++ b/libs/OpenSSL/include/openssl/crmferr.h @@ -21,28 +21,28 @@ /* * CRMF reason codes. */ -# define CRMF_R_BAD_PBM_ITERATIONCOUNT 100 -# define CRMF_R_CRMFERROR 102 -# define CRMF_R_ERROR 103 -# define CRMF_R_ERROR_DECODING_CERTIFICATE 104 -# define CRMF_R_ERROR_DECRYPTING_CERTIFICATE 105 -# define CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY 106 -# define CRMF_R_FAILURE_OBTAINING_RANDOM 107 -# define CRMF_R_ITERATIONCOUNT_BELOW_100 108 -# define CRMF_R_MALFORMED_IV 101 -# define CRMF_R_NULL_ARGUMENT 109 -# define CRMF_R_POPOSKINPUT_NOT_SUPPORTED 113 -# define CRMF_R_POPO_INCONSISTENT_PUBLIC_KEY 117 -# define CRMF_R_POPO_MISSING 121 -# define CRMF_R_POPO_MISSING_PUBLIC_KEY 118 -# define CRMF_R_POPO_MISSING_SUBJECT 119 -# define CRMF_R_POPO_RAVERIFIED_NOT_ACCEPTED 120 -# define CRMF_R_SETTING_MAC_ALGOR_FAILURE 110 -# define CRMF_R_SETTING_OWF_ALGOR_FAILURE 111 -# define CRMF_R_UNSUPPORTED_ALGORITHM 112 -# define CRMF_R_UNSUPPORTED_CIPHER 114 -# define CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO 115 -# define CRMF_R_UNSUPPORTED_POPO_METHOD 116 +# define CRMF_R_BAD_PBM_ITERATIONCOUNT 100 +# define CRMF_R_CRMFERROR 102 +# define CRMF_R_ERROR 103 +# define CRMF_R_ERROR_DECODING_CERTIFICATE 104 +# define CRMF_R_ERROR_DECRYPTING_CERTIFICATE 105 +# define CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY 106 +# define CRMF_R_FAILURE_OBTAINING_RANDOM 107 +# define CRMF_R_ITERATIONCOUNT_BELOW_100 108 +# define CRMF_R_MALFORMED_IV 101 +# define CRMF_R_NULL_ARGUMENT 109 +# define CRMF_R_POPOSKINPUT_NOT_SUPPORTED 113 +# define CRMF_R_POPO_INCONSISTENT_PUBLIC_KEY 117 +# define CRMF_R_POPO_MISSING 121 +# define CRMF_R_POPO_MISSING_PUBLIC_KEY 118 +# define CRMF_R_POPO_MISSING_SUBJECT 119 +# define CRMF_R_POPO_RAVERIFIED_NOT_ACCEPTED 120 +# define CRMF_R_SETTING_MAC_ALGOR_FAILURE 110 +# define CRMF_R_SETTING_OWF_ALGOR_FAILURE 111 +# define CRMF_R_UNSUPPORTED_ALGORITHM 112 +# define CRMF_R_UNSUPPORTED_CIPHER 114 +# define CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO 115 +# define CRMF_R_UNSUPPORTED_POPO_METHOD 116 #endif #endif diff --git a/libs/OpenSSL/include/openssl/crypto.h b/libs/OpenSSL/include/openssl/crypto.h index f28bf6a7..2f463848 100644 --- a/libs/OpenSSL/include/openssl/crypto.h +++ b/libs/OpenSSL/include/openssl/crypto.h @@ -17,7 +17,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CRYPTO_H +# define HEADER_CRYPTO_H #endif #include @@ -26,7 +26,7 @@ #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include @@ -37,7 +37,7 @@ #include #ifdef CHARSET_EBCDIC -# include +# include #endif /* @@ -47,7 +47,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include +# include #endif #ifdef __cplusplus @@ -55,14 +55,14 @@ extern "C" { #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define SSLeay OpenSSL_version_num -# define SSLeay_version OpenSSL_version -# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER -# define SSLEAY_VERSION OPENSSL_VERSION -# define SSLEAY_CFLAGS OPENSSL_CFLAGS -# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON -# define SSLEAY_PLATFORM OPENSSL_PLATFORM -# define SSLEAY_DIR OPENSSL_DIR +# define SSLeay OpenSSL_version_num +# define SSLeay_version OpenSSL_version +# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER +# define SSLEAY_VERSION OPENSSL_VERSION +# define SSLEAY_CFLAGS OPENSSL_CFLAGS +# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON +# define SSLEAY_PLATFORM OPENSSL_PLATFORM +# define SSLEAY_DIR OPENSSL_DIR /* * Old type for allocating dynamic locks. No longer used. Use the new thread @@ -70,7 +70,7 @@ extern "C" { */ typedef struct { - int dummy; + int dummy; } CRYPTO_dynlock; #endif /* OPENSSL_NO_DEPRECATED_1_1_0 */ @@ -84,45 +84,55 @@ int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock); void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock); int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock); -int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret, CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret, + CRYPTO_RWLOCK *lock); int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock); /* No longer needed, so this is a no-op */ -#define OPENSSL_malloc_init() \ - while (0) \ - continue +#define OPENSSL_malloc_init() \ + while (0) \ + continue #define OPENSSL_malloc(num) CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE) #define OPENSSL_zalloc(num) CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_realloc(addr, num) CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_clear_realloc(addr, old_num, num) \ - CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_clear_free(addr, num) CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_realloc(addr, num) \ + CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_clear_realloc(addr, old_num, num) \ + CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_clear_free(addr, num) \ + CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) #define OPENSSL_free(addr) CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_memdup(str, s) CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_memdup(str, s) \ + CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE) #define OPENSSL_strdup(str) CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_strndup(str, n) CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_secure_malloc(num) CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_secure_zalloc(num) CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_secure_free(addr) CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE) -#define OPENSSL_secure_clear_free(addr, num) \ - CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_strndup(str, n) \ + CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_secure_malloc(num) \ + CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_secure_zalloc(num) \ + CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_secure_free(addr) \ + CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE) +#define OPENSSL_secure_clear_free(addr, num) \ + CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) #define OPENSSL_secure_actual_size(ptr) CRYPTO_secure_actual_size(ptr) size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz); size_t OPENSSL_strnlen(const char *str, size_t maxlen); -int OPENSSL_buf2hexstr_ex(char *str, size_t str_n, size_t *strlength, const unsigned char *buf, - size_t buflen, const char sep); -char *OPENSSL_buf2hexstr(const unsigned char *buf, long buflen); -int OPENSSL_hexstr2buf_ex(unsigned char *buf, size_t buf_n, size_t *buflen, const char *str, +int OPENSSL_buf2hexstr_ex(char *str, size_t str_n, size_t *strlength, + const unsigned char *buf, size_t buflen, const char sep); +char *OPENSSL_buf2hexstr(const unsigned char *buf, long buflen); +int OPENSSL_hexstr2buf_ex(unsigned char *buf, size_t buf_n, size_t *buflen, + const char *str, const char sep); unsigned char *OPENSSL_hexstr2buf(const char *str, long *buflen); int OPENSSL_hexchar2int(unsigned char c); int OPENSSL_strcasecmp(const char *s1, const char *s2); int OPENSSL_strncasecmp(const char *s1, const char *s2, size_t n); -#define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U << (sizeof(int) * 8 - 1)) - 1) / sizeof(type)) +#define OPENSSL_MALLOC_MAX_NELEMS(type) \ + (((1U << (sizeof(int) * 8 - 1)) - 1) / sizeof(type)) /* * These functions return the values of OPENSSL_VERSION_MAJOR, @@ -166,51 +176,65 @@ int OPENSSL_issetugid(void); struct crypto_ex_data_st { - OSSL_LIB_CTX *ctx; - STACK_OF(void) * sk; + OSSL_LIB_CTX *ctx; + STACK_OF(void) * sk; }; SKM_DEFINE_STACK_OF_INTERNAL(void, void, void) #define sk_void_num(sk) OPENSSL_sk_num(ossl_check_const_void_sk_type(sk)) -#define sk_void_value(sk, idx) ((void *)OPENSSL_sk_value(ossl_check_const_void_sk_type(sk), (idx))) -#define sk_void_new(cmp) ((STACK_OF(void) *)OPENSSL_sk_new(ossl_check_void_compfunc_type(cmp))) +#define sk_void_value(sk, idx) \ + ((void *)OPENSSL_sk_value(ossl_check_const_void_sk_type(sk), (idx))) +#define sk_void_new(cmp) \ + ((STACK_OF(void) *)OPENSSL_sk_new(ossl_check_void_compfunc_type(cmp))) #define sk_void_new_null() ((STACK_OF(void) *)OPENSSL_sk_new_null()) -#define sk_void_new_reserve(cmp, n) \ - ((STACK_OF(void) *)OPENSSL_sk_new_reserve(ossl_check_void_compfunc_type(cmp), (n))) -#define sk_void_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_void_sk_type(sk), (n)) +#define sk_void_new_reserve(cmp, n) \ + ((STACK_OF(void) *)OPENSSL_sk_new_reserve( \ + ossl_check_void_compfunc_type(cmp), (n))) +#define sk_void_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_void_sk_type(sk), (n)) #define sk_void_free(sk) OPENSSL_sk_free(ossl_check_void_sk_type(sk)) #define sk_void_zero(sk) OPENSSL_sk_zero(ossl_check_void_sk_type(sk)) -#define sk_void_delete(sk, i) ((void *)OPENSSL_sk_delete(ossl_check_void_sk_type(sk), (i))) -#define sk_void_delete_ptr(sk, ptr) \ - ((void *)OPENSSL_sk_delete_ptr(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr))) -#define sk_void_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) -#define sk_void_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_delete(sk, i) \ + ((void *)OPENSSL_sk_delete(ossl_check_void_sk_type(sk), (i))) +#define sk_void_delete_ptr(sk, ptr) \ + ((void *)OPENSSL_sk_delete_ptr(ossl_check_void_sk_type(sk), \ + ossl_check_void_type(ptr))) +#define sk_void_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) #define sk_void_pop(sk) ((void *)OPENSSL_sk_pop(ossl_check_void_sk_type(sk))) -#define sk_void_shift(sk) ((void *)OPENSSL_sk_shift(ossl_check_void_sk_type(sk))) -#define sk_void_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_void_sk_type(sk), ossl_check_void_freefunc_type(freefunc)) -#define sk_void_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), (idx)) -#define sk_void_set(sk, idx, ptr) \ - ((void *)OPENSSL_sk_set(ossl_check_void_sk_type(sk), (idx), ossl_check_void_type(ptr))) -#define sk_void_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) -#define sk_void_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) -#define sk_void_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), pnum) +#define sk_void_shift(sk) \ + ((void *)OPENSSL_sk_shift(ossl_check_void_sk_type(sk))) +#define sk_void_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_void_sk_type(sk), \ + ossl_check_void_freefunc_type(freefunc)) +#define sk_void_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), \ + (idx)) +#define sk_void_set(sk, idx, ptr) \ + ((void *)OPENSSL_sk_set(ossl_check_void_sk_type(sk), (idx), \ + ossl_check_void_type(ptr))) +#define sk_void_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) +#define sk_void_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), \ + pnum) #define sk_void_sort(sk) OPENSSL_sk_sort(ossl_check_void_sk_type(sk)) -#define sk_void_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_void_sk_type(sk)) -#define sk_void_dup(sk) ((STACK_OF(void) *)OPENSSL_sk_dup(ossl_check_const_void_sk_type(sk))) -#define sk_void_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(void) *)OPENSSL_sk_deep_copy(ossl_check_const_void_sk_type(sk), \ - ossl_check_void_copyfunc_type(copyfunc), \ - ossl_check_void_freefunc_type(freefunc))) -#define sk_void_set_cmp_func(sk, cmp) \ - ((sk_void_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_void_sk_type(sk), \ - ossl_check_void_compfunc_type(cmp))) +#define sk_void_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_void_sk_type(sk)) +#define sk_void_dup(sk) \ + ((STACK_OF(void) *)OPENSSL_sk_dup(ossl_check_const_void_sk_type(sk))) +#define sk_void_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(void) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_void_sk_type(sk), \ + ossl_check_void_copyfunc_type(copyfunc), \ + ossl_check_void_freefunc_type(freefunc))) +#define sk_void_set_cmp_func(sk, cmp) \ + ((sk_void_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_void_sk_type(sk), ossl_check_void_compfunc_type(cmp))) /* * Per class, we have a STACK of function pointers. @@ -236,14 +260,16 @@ SKM_DEFINE_STACK_OF_INTERNAL(void, void, void) #define CRYPTO_EX_INDEX_EVP_PKEY 17 #define CRYPTO_EX_INDEX__COUNT 18 -typedef void CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int idx, long argl, - void *argp); -typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int idx, long argl, - void *argp); -typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, void **from_d, int idx, - long argl, void *argp); -__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +typedef void CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int idx, + long argl, void *argp); +typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); +typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, + void **from_d, int idx, long argl, void *argp); +__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, + CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func); /* No longer use an index. */ int CRYPTO_free_ex_index(int class_index, int idx); @@ -252,12 +278,14 @@ int CRYPTO_free_ex_index(int class_index, int idx); * given class (invokes whatever per-class callbacks are applicable) */ int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); -int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from); +int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, + const CRYPTO_EX_DATA *from); void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); /* Allocate a single item in the CRYPTO_EX_DATA variable */ -int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad, int idx); +int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad, + int idx); /* * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular @@ -271,9 +299,9 @@ void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); * This function cleans up all "ex_data" state. It mustn't be called under * potential race-conditions. */ -# define CRYPTO_cleanup_all_ex_data() \ - while (0) \ - continue +# define CRYPTO_cleanup_all_ex_data() \ + while (0) \ + continue /* * The old locking functions have been removed completely without compatibility @@ -285,75 +313,85 @@ void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); * On the other hand, the locking callbacks are no longer used. Consequently, * the callback management functions can be safely replaced with no-op macros. */ -# define CRYPTO_num_locks() (1) -# define CRYPTO_set_locking_callback(func) -# define CRYPTO_get_locking_callback() (NULL) -# define CRYPTO_set_add_lock_callback(func) -# define CRYPTO_get_add_lock_callback() (NULL) +# define CRYPTO_num_locks() (1) +# define CRYPTO_set_locking_callback(func) +# define CRYPTO_get_locking_callback() (NULL) +# define CRYPTO_set_add_lock_callback(func) +# define CRYPTO_get_add_lock_callback() (NULL) /* * These defines where used in combination with the old locking callbacks, * they are not called anymore, but old code that's not called might still * use them. */ -# define CRYPTO_LOCK 1 -# define CRYPTO_UNLOCK 2 -# define CRYPTO_READ 4 -# define CRYPTO_WRITE 8 +# define CRYPTO_LOCK 1 +# define CRYPTO_UNLOCK 2 +# define CRYPTO_READ 4 +# define CRYPTO_WRITE 8 /* This structure is no longer used */ typedef struct crypto_threadid_st { - int dummy; + int dummy; } CRYPTO_THREADID; /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ -# define CRYPTO_THREADID_set_numeric(id, val) -# define CRYPTO_THREADID_set_pointer(id, ptr) -# define CRYPTO_THREADID_set_callback(threadid_func) (0) -# define CRYPTO_THREADID_get_callback() (NULL) -# define CRYPTO_THREADID_current(id) -# define CRYPTO_THREADID_cmp(a, b) (-1) -# define CRYPTO_THREADID_cpy(dest, src) -# define CRYPTO_THREADID_hash(id) (0UL) +# define CRYPTO_THREADID_set_numeric(id, val) +# define CRYPTO_THREADID_set_pointer(id, ptr) +# define CRYPTO_THREADID_set_callback(threadid_func) (0) +# define CRYPTO_THREADID_get_callback() (NULL) +# define CRYPTO_THREADID_current(id) +# define CRYPTO_THREADID_cmp(a, b) (-1) +# define CRYPTO_THREADID_cpy(dest, src) +# define CRYPTO_THREADID_hash(id) (0UL) -# ifndef OPENSSL_NO_DEPRECATED_1_0_0 -# define CRYPTO_set_id_callback(func) -# define CRYPTO_get_id_callback() (NULL) -# define CRYPTO_thread_id() (0UL) -# endif /* OPENSSL_NO_DEPRECATED_1_0_0 */ +# ifndef OPENSSL_NO_DEPRECATED_1_0_0 +# define CRYPTO_set_id_callback(func) +# define CRYPTO_get_id_callback() (NULL) +# define CRYPTO_thread_id() (0UL) +# endif /* OPENSSL_NO_DEPRECATED_1_0_0 */ -# define CRYPTO_set_dynlock_create_callback(dyn_create_function) -# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function) -# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function) -# define CRYPTO_get_dynlock_create_callback() (NULL) -# define CRYPTO_get_dynlock_lock_callback() (NULL) -# define CRYPTO_get_dynlock_destroy_callback() (NULL) +# define CRYPTO_set_dynlock_create_callback(dyn_create_function) +# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function) +# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function) +# define CRYPTO_get_dynlock_create_callback() (NULL) +# define CRYPTO_get_dynlock_lock_callback() (NULL) +# define CRYPTO_get_dynlock_destroy_callback() (NULL) #endif /* OPENSSL_NO_DEPRECATED_1_1_0 */ typedef void *(*CRYPTO_malloc_fn)(size_t num, const char *file, int line); -typedef void *(*CRYPTO_realloc_fn)(void *addr, size_t num, const char *file, int line); +typedef void *(*CRYPTO_realloc_fn)(void *addr, size_t num, const char *file, + int line); typedef void (*CRYPTO_free_fn)(void *addr, const char *file, int line); -int CRYPTO_set_mem_functions(CRYPTO_malloc_fn malloc_fn, CRYPTO_realloc_fn realloc_fn, +int CRYPTO_set_mem_functions(CRYPTO_malloc_fn malloc_fn, + CRYPTO_realloc_fn realloc_fn, CRYPTO_free_fn free_fn); -void CRYPTO_get_mem_functions(CRYPTO_malloc_fn *malloc_fn, CRYPTO_realloc_fn *realloc_fn, +void CRYPTO_get_mem_functions(CRYPTO_malloc_fn *malloc_fn, + CRYPTO_realloc_fn *realloc_fn, CRYPTO_free_fn *free_fn); OSSL_CRYPTO_ALLOC void *CRYPTO_malloc(size_t num, const char *file, int line); OSSL_CRYPTO_ALLOC void *CRYPTO_zalloc(size_t num, const char *file, int line); -OSSL_CRYPTO_ALLOC void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line); -OSSL_CRYPTO_ALLOC char *CRYPTO_strdup(const char *str, const char *file, int line); -OSSL_CRYPTO_ALLOC char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line); +OSSL_CRYPTO_ALLOC void *CRYPTO_memdup(const void *str, size_t siz, + const char *file, int line); +OSSL_CRYPTO_ALLOC char *CRYPTO_strdup(const char *str, const char *file, + int line); +OSSL_CRYPTO_ALLOC char *CRYPTO_strndup(const char *str, size_t s, + const char *file, int line); void CRYPTO_free(void *ptr, const char *file, int line); void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line); void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line); -void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, const char *file, int line); +void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, + const char *file, int line); int CRYPTO_secure_malloc_init(size_t sz, size_t minsize); int CRYPTO_secure_malloc_done(void); -OSSL_CRYPTO_ALLOC void *CRYPTO_secure_malloc(size_t num, const char *file, int line); -OSSL_CRYPTO_ALLOC void *CRYPTO_secure_zalloc(size_t num, const char *file, int line); +OSSL_CRYPTO_ALLOC void *CRYPTO_secure_malloc(size_t num, const char *file, + int line); +OSSL_CRYPTO_ALLOC void *CRYPTO_secure_zalloc(size_t num, const char *file, + int line); void CRYPTO_secure_free(void *ptr, const char *file, int line); -void CRYPTO_secure_clear_free(void *ptr, size_t num, const char *file, int line); +void CRYPTO_secure_clear_free(void *ptr, size_t num, const char *file, + int line); int CRYPTO_secure_allocated(const void *ptr); int CRYPTO_secure_malloc_initialized(void); size_t CRYPTO_secure_actual_size(void *ptr); @@ -366,61 +404,72 @@ void OPENSSL_cleanse(void *ptr, size_t len); * The following can be used to detect memory leaks in the library. If * used, it turns on malloc checking */ -# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */ -# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */ -# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */ -# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */ +# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */ +# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */ +# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */ +# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */ void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount); -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define OPENSSL_mem_debug_push(info) CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_mem_debug_pop() CRYPTO_mem_debug_pop() -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define OPENSSL_mem_debug_push(info) \ + CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE) +# define OPENSSL_mem_debug_pop() CRYPTO_mem_debug_pop() +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int CRYPTO_set_mem_debug(int flag); OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_ctrl(int mode); -OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_push(const char *info, const char *file, int line); +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_push(const char *info, + const char *file, int line); OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_pop(void); -OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag, - const char *file, int line); -OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag, +OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_malloc(void *addr, size_t num, + int flag, const char *file, + int line); +OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, + size_t num, int flag, const char *file, int line); -OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_free(void *addr, int flag, const char *file, int line); +OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_free(void *addr, int flag, + const char *file, int line); OSSL_DEPRECATEDIN_3_0 -int CRYPTO_mem_leaks_cb(int (*cb)(const char *str, size_t len, void *u), void *u); -# endif -# ifndef OPENSSL_NO_STDIO -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks_fp(FILE *); -# endif -# endif +int CRYPTO_mem_leaks_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); +# endif +# ifndef OPENSSL_NO_STDIO # ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks(BIO *bio); +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks_fp(FILE *); # endif +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks(BIO *bio); +# endif #endif /* OPENSSL_NO_CRYPTO_MDEBUG */ /* die if we have to */ -ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line); +ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, + int line); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define OpenSSLDie(f, l, a) OPENSSL_die((a), (f), (l)) +# define OpenSSLDie(f, l, a) OPENSSL_die((a), (f), (l)) #endif -#define OPENSSL_assert(e) \ - (void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1)) +#define OPENSSL_assert(e) \ + (void)((e) ? 0 \ + : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, \ + OPENSSL_LINE), \ + 1)) int OPENSSL_isservice(void); void OPENSSL_init(void); #ifdef OPENSSL_SYS_UNIX -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_prepare(void); OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_parent(void); OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_child(void); -# endif +# endif #endif struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); -int OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from, const struct tm *to); +int OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from, + const struct tm *to); /* * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. @@ -462,9 +511,10 @@ int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len); /* Max OPENSSL_INIT flag value is 0x80000000 */ /* openssl and dasync not counted as builtin */ -#define OPENSSL_INIT_ENGINE_ALL_BUILTIN \ - (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC | OPENSSL_INIT_ENGINE_CRYPTODEV \ - | OPENSSL_INIT_ENGINE_CAPI | OPENSSL_INIT_ENGINE_PADLOCK) +#define OPENSSL_INIT_ENGINE_ALL_BUILTIN \ + (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \ + | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI \ + | OPENSSL_INIT_ENGINE_PADLOCK) /* Library initialisation functions */ void OPENSSL_cleanup(void); @@ -476,43 +526,46 @@ void OPENSSL_thread_stop_ex(OSSL_LIB_CTX *ctx); /* Low-level control of initialization */ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); #ifndef OPENSSL_NO_STDIO -int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, const char *config_filename); -void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings, unsigned long flags); -int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, const char *config_appname); +int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, + const char *config_filename); +void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings, + unsigned long flags); +int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, + const char *config_appname); #endif void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings); #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) -# if defined(_WIN32) -# if defined(BASETYPES) || defined(_WINDEF_H) +# if defined(_WIN32) +# if defined(BASETYPES) || defined(_WINDEF_H) /* application has to include in order to use this */ typedef DWORD CRYPTO_THREAD_LOCAL; typedef DWORD CRYPTO_THREAD_ID; typedef LONG CRYPTO_ONCE; -# define CRYPTO_ONCE_STATIC_INIT 0 -# endif +# define CRYPTO_ONCE_STATIC_INIT 0 +# endif +# else +# if defined(__TANDEM) && defined(_SPT_MODEL_) +# define SPT_THREAD_SIGNAL 1 +# define SPT_THREAD_AWARE 1 +# include # else -# if defined(__TANDEM) && defined(_SPT_MODEL_) -# define SPT_THREAD_SIGNAL 1 -# define SPT_THREAD_AWARE 1 -# include -# else -# include -# endif +# include +# endif typedef pthread_once_t CRYPTO_ONCE; typedef pthread_key_t CRYPTO_THREAD_LOCAL; typedef pthread_t CRYPTO_THREAD_ID; -# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT -# endif +# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT +# endif #endif #if !defined(CRYPTO_ONCE_STATIC_INIT) typedef unsigned int CRYPTO_ONCE; typedef unsigned int CRYPTO_THREAD_LOCAL; typedef unsigned int CRYPTO_THREAD_ID; -# define CRYPTO_ONCE_STATIC_INIT 0 +# define CRYPTO_ONCE_STATIC_INIT 0 #endif int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)); @@ -528,7 +581,8 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b); OSSL_LIB_CTX *OSSL_LIB_CTX_new(void); OSSL_LIB_CTX *OSSL_LIB_CTX_new_from_dispatch(const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH *in); -OSSL_LIB_CTX *OSSL_LIB_CTX_new_child(const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH *in); +OSSL_LIB_CTX *OSSL_LIB_CTX_new_child(const OSSL_CORE_HANDLE *handle, + const OSSL_DISPATCH *in); int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file); void OSSL_LIB_CTX_free(OSSL_LIB_CTX *); OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void); diff --git a/libs/OpenSSL/include/openssl/cryptoerr_legacy.h b/libs/OpenSSL/include/openssl/cryptoerr_legacy.h index 656f75c5..f6df96a7 100644 --- a/libs/OpenSSL/include/openssl/cryptoerr_legacy.h +++ b/libs/OpenSSL/include/openssl/cryptoerr_legacy.h @@ -31,45 +31,45 @@ OSSL_DEPRECATEDIN_3_0 int ERR_load_ASYNC_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_BIO_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_BN_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_BUF_strings(void); -# ifndef OPENSSL_NO_CMS +# ifndef OPENSSL_NO_CMS OSSL_DEPRECATEDIN_3_0 int ERR_load_CMS_strings(void); -# endif -# ifndef OPENSSL_NO_COMP +# endif +# ifndef OPENSSL_NO_COMP OSSL_DEPRECATEDIN_3_0 int ERR_load_COMP_strings(void); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int ERR_load_CONF_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_CRYPTO_strings(void); -# ifndef OPENSSL_NO_CT +# ifndef OPENSSL_NO_CT OSSL_DEPRECATEDIN_3_0 int ERR_load_CT_strings(void); -# endif -# ifndef OPENSSL_NO_DH +# endif +# ifndef OPENSSL_NO_DH OSSL_DEPRECATEDIN_3_0 int ERR_load_DH_strings(void); -# endif -# ifndef OPENSSL_NO_DSA +# endif +# ifndef OPENSSL_NO_DSA OSSL_DEPRECATEDIN_3_0 int ERR_load_DSA_strings(void); -# endif -# ifndef OPENSSL_NO_EC +# endif +# ifndef OPENSSL_NO_EC OSSL_DEPRECATEDIN_3_0 int ERR_load_EC_strings(void); -# endif -# ifndef OPENSSL_NO_ENGINE +# endif +# ifndef OPENSSL_NO_ENGINE OSSL_DEPRECATEDIN_3_0 int ERR_load_ENGINE_strings(void); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int ERR_load_ERR_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_EVP_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_KDF_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_OBJ_strings(void); -# ifndef OPENSSL_NO_OCSP +# ifndef OPENSSL_NO_OCSP OSSL_DEPRECATEDIN_3_0 int ERR_load_OCSP_strings(void); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int ERR_load_PEM_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_PKCS12_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_PKCS7_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_RAND_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_RSA_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_OSSL_STORE_strings(void); -# ifndef OPENSSL_NO_TS +# ifndef OPENSSL_NO_TS OSSL_DEPRECATEDIN_3_0 int ERR_load_TS_strings(void); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int ERR_load_UI_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_X509_strings(void); OSSL_DEPRECATEDIN_3_0 int ERR_load_X509V3_strings(void); @@ -79,1384 +79,1384 @@ OSSL_DEPRECATEDIN_3_0 int ERR_load_X509V3_strings(void); /* * ASN1 function codes. */ -# define ASN1_F_A2D_ASN1_OBJECT 0 -# define ASN1_F_A2I_ASN1_INTEGER 0 -# define ASN1_F_A2I_ASN1_STRING 0 -# define ASN1_F_APPEND_EXP 0 -# define ASN1_F_ASN1_BIO_INIT 0 -# define ASN1_F_ASN1_BIT_STRING_SET_BIT 0 -# define ASN1_F_ASN1_CB 0 -# define ASN1_F_ASN1_CHECK_TLEN 0 -# define ASN1_F_ASN1_COLLECT 0 -# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 0 -# define ASN1_F_ASN1_D2I_FP 0 -# define ASN1_F_ASN1_D2I_READ_BIO 0 -# define ASN1_F_ASN1_DIGEST 0 -# define ASN1_F_ASN1_DO_ADB 0 -# define ASN1_F_ASN1_DO_LOCK 0 -# define ASN1_F_ASN1_DUP 0 -# define ASN1_F_ASN1_ENC_SAVE 0 -# define ASN1_F_ASN1_EX_C2I 0 -# define ASN1_F_ASN1_FIND_END 0 -# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 0 -# define ASN1_F_ASN1_GENERATE_V3 0 -# define ASN1_F_ASN1_GET_INT64 0 -# define ASN1_F_ASN1_GET_OBJECT 0 -# define ASN1_F_ASN1_GET_UINT64 0 -# define ASN1_F_ASN1_I2D_BIO 0 -# define ASN1_F_ASN1_I2D_FP 0 -# define ASN1_F_ASN1_ITEM_D2I_FP 0 -# define ASN1_F_ASN1_ITEM_DUP 0 -# define ASN1_F_ASN1_ITEM_EMBED_D2I 0 -# define ASN1_F_ASN1_ITEM_EMBED_NEW 0 -# define ASN1_F_ASN1_ITEM_FLAGS_I2D 0 -# define ASN1_F_ASN1_ITEM_I2D_BIO 0 -# define ASN1_F_ASN1_ITEM_I2D_FP 0 -# define ASN1_F_ASN1_ITEM_PACK 0 -# define ASN1_F_ASN1_ITEM_SIGN 0 -# define ASN1_F_ASN1_ITEM_SIGN_CTX 0 -# define ASN1_F_ASN1_ITEM_UNPACK 0 -# define ASN1_F_ASN1_ITEM_VERIFY 0 -# define ASN1_F_ASN1_MBSTRING_NCOPY 0 -# define ASN1_F_ASN1_OBJECT_NEW 0 -# define ASN1_F_ASN1_OUTPUT_DATA 0 -# define ASN1_F_ASN1_PCTX_NEW 0 -# define ASN1_F_ASN1_PRIMITIVE_NEW 0 -# define ASN1_F_ASN1_SCTX_NEW 0 -# define ASN1_F_ASN1_SIGN 0 -# define ASN1_F_ASN1_STR2TYPE 0 -# define ASN1_F_ASN1_STRING_GET_INT64 0 -# define ASN1_F_ASN1_STRING_GET_UINT64 0 -# define ASN1_F_ASN1_STRING_SET 0 -# define ASN1_F_ASN1_STRING_TABLE_ADD 0 -# define ASN1_F_ASN1_STRING_TO_BN 0 -# define ASN1_F_ASN1_STRING_TYPE_NEW 0 -# define ASN1_F_ASN1_TEMPLATE_EX_D2I 0 -# define ASN1_F_ASN1_TEMPLATE_NEW 0 -# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 0 -# define ASN1_F_ASN1_TIME_ADJ 0 -# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 0 -# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 0 -# define ASN1_F_ASN1_UTCTIME_ADJ 0 -# define ASN1_F_ASN1_VERIFY 0 -# define ASN1_F_B64_READ_ASN1 0 -# define ASN1_F_B64_WRITE_ASN1 0 -# define ASN1_F_BIO_NEW_NDEF 0 -# define ASN1_F_BITSTR_CB 0 -# define ASN1_F_BN_TO_ASN1_STRING 0 -# define ASN1_F_C2I_ASN1_BIT_STRING 0 -# define ASN1_F_C2I_ASN1_INTEGER 0 -# define ASN1_F_C2I_ASN1_OBJECT 0 -# define ASN1_F_C2I_IBUF 0 -# define ASN1_F_C2I_UINT64_INT 0 -# define ASN1_F_COLLECT_DATA 0 -# define ASN1_F_D2I_ASN1_OBJECT 0 -# define ASN1_F_D2I_ASN1_UINTEGER 0 -# define ASN1_F_D2I_AUTOPRIVATEKEY 0 -# define ASN1_F_D2I_PRIVATEKEY 0 -# define ASN1_F_D2I_PUBLICKEY 0 -# define ASN1_F_DO_BUF 0 -# define ASN1_F_DO_CREATE 0 -# define ASN1_F_DO_DUMP 0 -# define ASN1_F_DO_TCREATE 0 -# define ASN1_F_I2A_ASN1_OBJECT 0 -# define ASN1_F_I2D_ASN1_BIO_STREAM 0 -# define ASN1_F_I2D_ASN1_OBJECT 0 -# define ASN1_F_I2D_DSA_PUBKEY 0 -# define ASN1_F_I2D_EC_PUBKEY 0 -# define ASN1_F_I2D_PRIVATEKEY 0 -# define ASN1_F_I2D_PUBLICKEY 0 -# define ASN1_F_I2D_RSA_PUBKEY 0 -# define ASN1_F_LONG_C2I 0 -# define ASN1_F_NDEF_PREFIX 0 -# define ASN1_F_NDEF_SUFFIX 0 -# define ASN1_F_OID_MODULE_INIT 0 -# define ASN1_F_PARSE_TAGGING 0 -# define ASN1_F_PKCS5_PBE2_SET_IV 0 -# define ASN1_F_PKCS5_PBE2_SET_SCRYPT 0 -# define ASN1_F_PKCS5_PBE_SET 0 -# define ASN1_F_PKCS5_PBE_SET0_ALGOR 0 -# define ASN1_F_PKCS5_PBKDF2_SET 0 -# define ASN1_F_PKCS5_SCRYPT_SET 0 -# define ASN1_F_SMIME_READ_ASN1 0 -# define ASN1_F_SMIME_TEXT 0 -# define ASN1_F_STABLE_GET 0 -# define ASN1_F_STBL_MODULE_INIT 0 -# define ASN1_F_UINT32_C2I 0 -# define ASN1_F_UINT32_NEW 0 -# define ASN1_F_UINT64_C2I 0 -# define ASN1_F_UINT64_NEW 0 -# define ASN1_F_X509_CRL_ADD0_REVOKED 0 -# define ASN1_F_X509_INFO_NEW 0 -# define ASN1_F_X509_NAME_ENCODE 0 -# define ASN1_F_X509_NAME_EX_D2I 0 -# define ASN1_F_X509_NAME_EX_NEW 0 -# define ASN1_F_X509_PKEY_NEW 0 +# define ASN1_F_A2D_ASN1_OBJECT 0 +# define ASN1_F_A2I_ASN1_INTEGER 0 +# define ASN1_F_A2I_ASN1_STRING 0 +# define ASN1_F_APPEND_EXP 0 +# define ASN1_F_ASN1_BIO_INIT 0 +# define ASN1_F_ASN1_BIT_STRING_SET_BIT 0 +# define ASN1_F_ASN1_CB 0 +# define ASN1_F_ASN1_CHECK_TLEN 0 +# define ASN1_F_ASN1_COLLECT 0 +# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 0 +# define ASN1_F_ASN1_D2I_FP 0 +# define ASN1_F_ASN1_D2I_READ_BIO 0 +# define ASN1_F_ASN1_DIGEST 0 +# define ASN1_F_ASN1_DO_ADB 0 +# define ASN1_F_ASN1_DO_LOCK 0 +# define ASN1_F_ASN1_DUP 0 +# define ASN1_F_ASN1_ENC_SAVE 0 +# define ASN1_F_ASN1_EX_C2I 0 +# define ASN1_F_ASN1_FIND_END 0 +# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 0 +# define ASN1_F_ASN1_GENERATE_V3 0 +# define ASN1_F_ASN1_GET_INT64 0 +# define ASN1_F_ASN1_GET_OBJECT 0 +# define ASN1_F_ASN1_GET_UINT64 0 +# define ASN1_F_ASN1_I2D_BIO 0 +# define ASN1_F_ASN1_I2D_FP 0 +# define ASN1_F_ASN1_ITEM_D2I_FP 0 +# define ASN1_F_ASN1_ITEM_DUP 0 +# define ASN1_F_ASN1_ITEM_EMBED_D2I 0 +# define ASN1_F_ASN1_ITEM_EMBED_NEW 0 +# define ASN1_F_ASN1_ITEM_FLAGS_I2D 0 +# define ASN1_F_ASN1_ITEM_I2D_BIO 0 +# define ASN1_F_ASN1_ITEM_I2D_FP 0 +# define ASN1_F_ASN1_ITEM_PACK 0 +# define ASN1_F_ASN1_ITEM_SIGN 0 +# define ASN1_F_ASN1_ITEM_SIGN_CTX 0 +# define ASN1_F_ASN1_ITEM_UNPACK 0 +# define ASN1_F_ASN1_ITEM_VERIFY 0 +# define ASN1_F_ASN1_MBSTRING_NCOPY 0 +# define ASN1_F_ASN1_OBJECT_NEW 0 +# define ASN1_F_ASN1_OUTPUT_DATA 0 +# define ASN1_F_ASN1_PCTX_NEW 0 +# define ASN1_F_ASN1_PRIMITIVE_NEW 0 +# define ASN1_F_ASN1_SCTX_NEW 0 +# define ASN1_F_ASN1_SIGN 0 +# define ASN1_F_ASN1_STR2TYPE 0 +# define ASN1_F_ASN1_STRING_GET_INT64 0 +# define ASN1_F_ASN1_STRING_GET_UINT64 0 +# define ASN1_F_ASN1_STRING_SET 0 +# define ASN1_F_ASN1_STRING_TABLE_ADD 0 +# define ASN1_F_ASN1_STRING_TO_BN 0 +# define ASN1_F_ASN1_STRING_TYPE_NEW 0 +# define ASN1_F_ASN1_TEMPLATE_EX_D2I 0 +# define ASN1_F_ASN1_TEMPLATE_NEW 0 +# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 0 +# define ASN1_F_ASN1_TIME_ADJ 0 +# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 0 +# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 0 +# define ASN1_F_ASN1_UTCTIME_ADJ 0 +# define ASN1_F_ASN1_VERIFY 0 +# define ASN1_F_B64_READ_ASN1 0 +# define ASN1_F_B64_WRITE_ASN1 0 +# define ASN1_F_BIO_NEW_NDEF 0 +# define ASN1_F_BITSTR_CB 0 +# define ASN1_F_BN_TO_ASN1_STRING 0 +# define ASN1_F_C2I_ASN1_BIT_STRING 0 +# define ASN1_F_C2I_ASN1_INTEGER 0 +# define ASN1_F_C2I_ASN1_OBJECT 0 +# define ASN1_F_C2I_IBUF 0 +# define ASN1_F_C2I_UINT64_INT 0 +# define ASN1_F_COLLECT_DATA 0 +# define ASN1_F_D2I_ASN1_OBJECT 0 +# define ASN1_F_D2I_ASN1_UINTEGER 0 +# define ASN1_F_D2I_AUTOPRIVATEKEY 0 +# define ASN1_F_D2I_PRIVATEKEY 0 +# define ASN1_F_D2I_PUBLICKEY 0 +# define ASN1_F_DO_BUF 0 +# define ASN1_F_DO_CREATE 0 +# define ASN1_F_DO_DUMP 0 +# define ASN1_F_DO_TCREATE 0 +# define ASN1_F_I2A_ASN1_OBJECT 0 +# define ASN1_F_I2D_ASN1_BIO_STREAM 0 +# define ASN1_F_I2D_ASN1_OBJECT 0 +# define ASN1_F_I2D_DSA_PUBKEY 0 +# define ASN1_F_I2D_EC_PUBKEY 0 +# define ASN1_F_I2D_PRIVATEKEY 0 +# define ASN1_F_I2D_PUBLICKEY 0 +# define ASN1_F_I2D_RSA_PUBKEY 0 +# define ASN1_F_LONG_C2I 0 +# define ASN1_F_NDEF_PREFIX 0 +# define ASN1_F_NDEF_SUFFIX 0 +# define ASN1_F_OID_MODULE_INIT 0 +# define ASN1_F_PARSE_TAGGING 0 +# define ASN1_F_PKCS5_PBE2_SET_IV 0 +# define ASN1_F_PKCS5_PBE2_SET_SCRYPT 0 +# define ASN1_F_PKCS5_PBE_SET 0 +# define ASN1_F_PKCS5_PBE_SET0_ALGOR 0 +# define ASN1_F_PKCS5_PBKDF2_SET 0 +# define ASN1_F_PKCS5_SCRYPT_SET 0 +# define ASN1_F_SMIME_READ_ASN1 0 +# define ASN1_F_SMIME_TEXT 0 +# define ASN1_F_STABLE_GET 0 +# define ASN1_F_STBL_MODULE_INIT 0 +# define ASN1_F_UINT32_C2I 0 +# define ASN1_F_UINT32_NEW 0 +# define ASN1_F_UINT64_C2I 0 +# define ASN1_F_UINT64_NEW 0 +# define ASN1_F_X509_CRL_ADD0_REVOKED 0 +# define ASN1_F_X509_INFO_NEW 0 +# define ASN1_F_X509_NAME_ENCODE 0 +# define ASN1_F_X509_NAME_EX_D2I 0 +# define ASN1_F_X509_NAME_EX_NEW 0 +# define ASN1_F_X509_PKEY_NEW 0 /* * ASYNC function codes. */ -# define ASYNC_F_ASYNC_CTX_NEW 0 -# define ASYNC_F_ASYNC_INIT_THREAD 0 -# define ASYNC_F_ASYNC_JOB_NEW 0 -# define ASYNC_F_ASYNC_PAUSE_JOB 0 -# define ASYNC_F_ASYNC_START_FUNC 0 -# define ASYNC_F_ASYNC_START_JOB 0 -# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 0 +# define ASYNC_F_ASYNC_CTX_NEW 0 +# define ASYNC_F_ASYNC_INIT_THREAD 0 +# define ASYNC_F_ASYNC_JOB_NEW 0 +# define ASYNC_F_ASYNC_PAUSE_JOB 0 +# define ASYNC_F_ASYNC_START_FUNC 0 +# define ASYNC_F_ASYNC_START_JOB 0 +# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 0 /* * BIO function codes. */ -# define BIO_F_ACPT_STATE 0 -# define BIO_F_ADDRINFO_WRAP 0 -# define BIO_F_ADDR_STRINGS 0 -# define BIO_F_BIO_ACCEPT 0 -# define BIO_F_BIO_ACCEPT_EX 0 -# define BIO_F_BIO_ACCEPT_NEW 0 -# define BIO_F_BIO_ADDR_NEW 0 -# define BIO_F_BIO_BIND 0 -# define BIO_F_BIO_CALLBACK_CTRL 0 -# define BIO_F_BIO_CONNECT 0 -# define BIO_F_BIO_CONNECT_NEW 0 -# define BIO_F_BIO_CTRL 0 -# define BIO_F_BIO_GETS 0 -# define BIO_F_BIO_GET_HOST_IP 0 -# define BIO_F_BIO_GET_NEW_INDEX 0 -# define BIO_F_BIO_GET_PORT 0 -# define BIO_F_BIO_LISTEN 0 -# define BIO_F_BIO_LOOKUP 0 -# define BIO_F_BIO_LOOKUP_EX 0 -# define BIO_F_BIO_MAKE_PAIR 0 -# define BIO_F_BIO_METH_NEW 0 -# define BIO_F_BIO_NEW 0 -# define BIO_F_BIO_NEW_DGRAM_SCTP 0 -# define BIO_F_BIO_NEW_FILE 0 -# define BIO_F_BIO_NEW_MEM_BUF 0 -# define BIO_F_BIO_NREAD 0 -# define BIO_F_BIO_NREAD0 0 -# define BIO_F_BIO_NWRITE 0 -# define BIO_F_BIO_NWRITE0 0 -# define BIO_F_BIO_PARSE_HOSTSERV 0 -# define BIO_F_BIO_PUTS 0 -# define BIO_F_BIO_READ 0 -# define BIO_F_BIO_READ_EX 0 -# define BIO_F_BIO_READ_INTERN 0 -# define BIO_F_BIO_SOCKET 0 -# define BIO_F_BIO_SOCKET_NBIO 0 -# define BIO_F_BIO_SOCK_INFO 0 -# define BIO_F_BIO_SOCK_INIT 0 -# define BIO_F_BIO_WRITE 0 -# define BIO_F_BIO_WRITE_EX 0 -# define BIO_F_BIO_WRITE_INTERN 0 -# define BIO_F_BUFFER_CTRL 0 -# define BIO_F_CONN_CTRL 0 -# define BIO_F_CONN_STATE 0 -# define BIO_F_DGRAM_SCTP_NEW 0 -# define BIO_F_DGRAM_SCTP_READ 0 -# define BIO_F_DGRAM_SCTP_WRITE 0 -# define BIO_F_DOAPR_OUTCH 0 -# define BIO_F_FILE_CTRL 0 -# define BIO_F_FILE_READ 0 -# define BIO_F_LINEBUFFER_CTRL 0 -# define BIO_F_LINEBUFFER_NEW 0 -# define BIO_F_MEM_WRITE 0 -# define BIO_F_NBIOF_NEW 0 -# define BIO_F_SLG_WRITE 0 -# define BIO_F_SSL_NEW 0 +# define BIO_F_ACPT_STATE 0 +# define BIO_F_ADDRINFO_WRAP 0 +# define BIO_F_ADDR_STRINGS 0 +# define BIO_F_BIO_ACCEPT 0 +# define BIO_F_BIO_ACCEPT_EX 0 +# define BIO_F_BIO_ACCEPT_NEW 0 +# define BIO_F_BIO_ADDR_NEW 0 +# define BIO_F_BIO_BIND 0 +# define BIO_F_BIO_CALLBACK_CTRL 0 +# define BIO_F_BIO_CONNECT 0 +# define BIO_F_BIO_CONNECT_NEW 0 +# define BIO_F_BIO_CTRL 0 +# define BIO_F_BIO_GETS 0 +# define BIO_F_BIO_GET_HOST_IP 0 +# define BIO_F_BIO_GET_NEW_INDEX 0 +# define BIO_F_BIO_GET_PORT 0 +# define BIO_F_BIO_LISTEN 0 +# define BIO_F_BIO_LOOKUP 0 +# define BIO_F_BIO_LOOKUP_EX 0 +# define BIO_F_BIO_MAKE_PAIR 0 +# define BIO_F_BIO_METH_NEW 0 +# define BIO_F_BIO_NEW 0 +# define BIO_F_BIO_NEW_DGRAM_SCTP 0 +# define BIO_F_BIO_NEW_FILE 0 +# define BIO_F_BIO_NEW_MEM_BUF 0 +# define BIO_F_BIO_NREAD 0 +# define BIO_F_BIO_NREAD0 0 +# define BIO_F_BIO_NWRITE 0 +# define BIO_F_BIO_NWRITE0 0 +# define BIO_F_BIO_PARSE_HOSTSERV 0 +# define BIO_F_BIO_PUTS 0 +# define BIO_F_BIO_READ 0 +# define BIO_F_BIO_READ_EX 0 +# define BIO_F_BIO_READ_INTERN 0 +# define BIO_F_BIO_SOCKET 0 +# define BIO_F_BIO_SOCKET_NBIO 0 +# define BIO_F_BIO_SOCK_INFO 0 +# define BIO_F_BIO_SOCK_INIT 0 +# define BIO_F_BIO_WRITE 0 +# define BIO_F_BIO_WRITE_EX 0 +# define BIO_F_BIO_WRITE_INTERN 0 +# define BIO_F_BUFFER_CTRL 0 +# define BIO_F_CONN_CTRL 0 +# define BIO_F_CONN_STATE 0 +# define BIO_F_DGRAM_SCTP_NEW 0 +# define BIO_F_DGRAM_SCTP_READ 0 +# define BIO_F_DGRAM_SCTP_WRITE 0 +# define BIO_F_DOAPR_OUTCH 0 +# define BIO_F_FILE_CTRL 0 +# define BIO_F_FILE_READ 0 +# define BIO_F_LINEBUFFER_CTRL 0 +# define BIO_F_LINEBUFFER_NEW 0 +# define BIO_F_MEM_WRITE 0 +# define BIO_F_NBIOF_NEW 0 +# define BIO_F_SLG_WRITE 0 +# define BIO_F_SSL_NEW 0 /* * BN function codes. */ -# define BN_F_BNRAND 0 -# define BN_F_BNRAND_RANGE 0 -# define BN_F_BN_BLINDING_CONVERT_EX 0 -# define BN_F_BN_BLINDING_CREATE_PARAM 0 -# define BN_F_BN_BLINDING_INVERT_EX 0 -# define BN_F_BN_BLINDING_NEW 0 -# define BN_F_BN_BLINDING_UPDATE 0 -# define BN_F_BN_BN2DEC 0 -# define BN_F_BN_BN2HEX 0 -# define BN_F_BN_COMPUTE_WNAF 0 -# define BN_F_BN_CTX_GET 0 -# define BN_F_BN_CTX_NEW 0 -# define BN_F_BN_CTX_START 0 -# define BN_F_BN_DIV 0 -# define BN_F_BN_DIV_RECP 0 -# define BN_F_BN_EXP 0 -# define BN_F_BN_EXPAND_INTERNAL 0 -# define BN_F_BN_GENCB_NEW 0 -# define BN_F_BN_GENERATE_DSA_NONCE 0 -# define BN_F_BN_GENERATE_PRIME_EX 0 -# define BN_F_BN_GF2M_MOD 0 -# define BN_F_BN_GF2M_MOD_EXP 0 -# define BN_F_BN_GF2M_MOD_MUL 0 -# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 0 -# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 0 -# define BN_F_BN_GF2M_MOD_SQR 0 -# define BN_F_BN_GF2M_MOD_SQRT 0 -# define BN_F_BN_LSHIFT 0 -# define BN_F_BN_MOD_EXP2_MONT 0 -# define BN_F_BN_MOD_EXP_MONT 0 -# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 0 -# define BN_F_BN_MOD_EXP_MONT_WORD 0 -# define BN_F_BN_MOD_EXP_RECP 0 -# define BN_F_BN_MOD_EXP_SIMPLE 0 -# define BN_F_BN_MOD_INVERSE 0 -# define BN_F_BN_MOD_INVERSE_NO_BRANCH 0 -# define BN_F_BN_MOD_LSHIFT_QUICK 0 -# define BN_F_BN_MOD_SQRT 0 -# define BN_F_BN_MONT_CTX_NEW 0 -# define BN_F_BN_MPI2BN 0 -# define BN_F_BN_NEW 0 -# define BN_F_BN_POOL_GET 0 -# define BN_F_BN_RAND 0 -# define BN_F_BN_RAND_RANGE 0 -# define BN_F_BN_RECP_CTX_NEW 0 -# define BN_F_BN_RSHIFT 0 -# define BN_F_BN_SET_WORDS 0 -# define BN_F_BN_STACK_PUSH 0 -# define BN_F_BN_USUB 0 +# define BN_F_BNRAND 0 +# define BN_F_BNRAND_RANGE 0 +# define BN_F_BN_BLINDING_CONVERT_EX 0 +# define BN_F_BN_BLINDING_CREATE_PARAM 0 +# define BN_F_BN_BLINDING_INVERT_EX 0 +# define BN_F_BN_BLINDING_NEW 0 +# define BN_F_BN_BLINDING_UPDATE 0 +# define BN_F_BN_BN2DEC 0 +# define BN_F_BN_BN2HEX 0 +# define BN_F_BN_COMPUTE_WNAF 0 +# define BN_F_BN_CTX_GET 0 +# define BN_F_BN_CTX_NEW 0 +# define BN_F_BN_CTX_START 0 +# define BN_F_BN_DIV 0 +# define BN_F_BN_DIV_RECP 0 +# define BN_F_BN_EXP 0 +# define BN_F_BN_EXPAND_INTERNAL 0 +# define BN_F_BN_GENCB_NEW 0 +# define BN_F_BN_GENERATE_DSA_NONCE 0 +# define BN_F_BN_GENERATE_PRIME_EX 0 +# define BN_F_BN_GF2M_MOD 0 +# define BN_F_BN_GF2M_MOD_EXP 0 +# define BN_F_BN_GF2M_MOD_MUL 0 +# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 0 +# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 0 +# define BN_F_BN_GF2M_MOD_SQR 0 +# define BN_F_BN_GF2M_MOD_SQRT 0 +# define BN_F_BN_LSHIFT 0 +# define BN_F_BN_MOD_EXP2_MONT 0 +# define BN_F_BN_MOD_EXP_MONT 0 +# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 0 +# define BN_F_BN_MOD_EXP_MONT_WORD 0 +# define BN_F_BN_MOD_EXP_RECP 0 +# define BN_F_BN_MOD_EXP_SIMPLE 0 +# define BN_F_BN_MOD_INVERSE 0 +# define BN_F_BN_MOD_INVERSE_NO_BRANCH 0 +# define BN_F_BN_MOD_LSHIFT_QUICK 0 +# define BN_F_BN_MOD_SQRT 0 +# define BN_F_BN_MONT_CTX_NEW 0 +# define BN_F_BN_MPI2BN 0 +# define BN_F_BN_NEW 0 +# define BN_F_BN_POOL_GET 0 +# define BN_F_BN_RAND 0 +# define BN_F_BN_RAND_RANGE 0 +# define BN_F_BN_RECP_CTX_NEW 0 +# define BN_F_BN_RSHIFT 0 +# define BN_F_BN_SET_WORDS 0 +# define BN_F_BN_STACK_PUSH 0 +# define BN_F_BN_USUB 0 /* * BUF function codes. */ -# define BUF_F_BUF_MEM_GROW 0 -# define BUF_F_BUF_MEM_GROW_CLEAN 0 -# define BUF_F_BUF_MEM_NEW 0 +# define BUF_F_BUF_MEM_GROW 0 +# define BUF_F_BUF_MEM_GROW_CLEAN 0 +# define BUF_F_BUF_MEM_NEW 0 -# ifndef OPENSSL_NO_CMS +# ifndef OPENSSL_NO_CMS /* * CMS function codes. */ -# define CMS_F_CHECK_CONTENT 0 -# define CMS_F_CMS_ADD0_CERT 0 -# define CMS_F_CMS_ADD0_RECIPIENT_KEY 0 -# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 0 -# define CMS_F_CMS_ADD1_RECEIPTREQUEST 0 -# define CMS_F_CMS_ADD1_RECIPIENT_CERT 0 -# define CMS_F_CMS_ADD1_SIGNER 0 -# define CMS_F_CMS_ADD1_SIGNINGTIME 0 -# define CMS_F_CMS_COMPRESS 0 -# define CMS_F_CMS_COMPRESSEDDATA_CREATE 0 -# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 0 -# define CMS_F_CMS_COPY_CONTENT 0 -# define CMS_F_CMS_COPY_MESSAGEDIGEST 0 -# define CMS_F_CMS_DATA 0 -# define CMS_F_CMS_DATAFINAL 0 -# define CMS_F_CMS_DATAINIT 0 -# define CMS_F_CMS_DECRYPT 0 -# define CMS_F_CMS_DECRYPT_SET1_KEY 0 -# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 0 -# define CMS_F_CMS_DECRYPT_SET1_PKEY 0 -# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 0 -# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 0 -# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 0 -# define CMS_F_CMS_DIGEST_VERIFY 0 -# define CMS_F_CMS_ENCODE_RECEIPT 0 -# define CMS_F_CMS_ENCRYPT 0 -# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT 0 -# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 0 -# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 0 -# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 0 -# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 0 -# define CMS_F_CMS_ENVELOPEDDATA_CREATE 0 -# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 0 -# define CMS_F_CMS_ENVELOPED_DATA_INIT 0 -# define CMS_F_CMS_ENV_ASN1_CTRL 0 -# define CMS_F_CMS_FINAL 0 -# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 0 -# define CMS_F_CMS_GET0_CONTENT 0 -# define CMS_F_CMS_GET0_ECONTENT_TYPE 0 -# define CMS_F_CMS_GET0_ENVELOPED 0 -# define CMS_F_CMS_GET0_REVOCATION_CHOICES 0 -# define CMS_F_CMS_GET0_SIGNED 0 -# define CMS_F_CMS_MSGSIGDIGEST_ADD1 0 -# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 0 -# define CMS_F_CMS_RECEIPT_VERIFY 0 -# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 0 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 0 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 0 -# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 0 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 0 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 0 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 0 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 0 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 0 -# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 0 -# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 0 -# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 0 -# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 0 -# define CMS_F_CMS_SD_ASN1_CTRL 0 -# define CMS_F_CMS_SET1_IAS 0 -# define CMS_F_CMS_SET1_KEYID 0 -# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 0 -# define CMS_F_CMS_SET_DETACHED 0 -# define CMS_F_CMS_SIGN 0 -# define CMS_F_CMS_SIGNED_DATA_INIT 0 -# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 0 -# define CMS_F_CMS_SIGNERINFO_SIGN 0 -# define CMS_F_CMS_SIGNERINFO_VERIFY 0 -# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 0 -# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 0 -# define CMS_F_CMS_SIGN_RECEIPT 0 -# define CMS_F_CMS_SI_CHECK_ATTRIBUTES 0 -# define CMS_F_CMS_STREAM 0 -# define CMS_F_CMS_UNCOMPRESS 0 -# define CMS_F_CMS_VERIFY 0 -# define CMS_F_KEK_UNWRAP_KEY 0 -# endif +# define CMS_F_CHECK_CONTENT 0 +# define CMS_F_CMS_ADD0_CERT 0 +# define CMS_F_CMS_ADD0_RECIPIENT_KEY 0 +# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 0 +# define CMS_F_CMS_ADD1_RECEIPTREQUEST 0 +# define CMS_F_CMS_ADD1_RECIPIENT_CERT 0 +# define CMS_F_CMS_ADD1_SIGNER 0 +# define CMS_F_CMS_ADD1_SIGNINGTIME 0 +# define CMS_F_CMS_COMPRESS 0 +# define CMS_F_CMS_COMPRESSEDDATA_CREATE 0 +# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 0 +# define CMS_F_CMS_COPY_CONTENT 0 +# define CMS_F_CMS_COPY_MESSAGEDIGEST 0 +# define CMS_F_CMS_DATA 0 +# define CMS_F_CMS_DATAFINAL 0 +# define CMS_F_CMS_DATAINIT 0 +# define CMS_F_CMS_DECRYPT 0 +# define CMS_F_CMS_DECRYPT_SET1_KEY 0 +# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 0 +# define CMS_F_CMS_DECRYPT_SET1_PKEY 0 +# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 0 +# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 0 +# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 0 +# define CMS_F_CMS_DIGEST_VERIFY 0 +# define CMS_F_CMS_ENCODE_RECEIPT 0 +# define CMS_F_CMS_ENCRYPT 0 +# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT 0 +# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 0 +# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 0 +# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 0 +# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 0 +# define CMS_F_CMS_ENVELOPEDDATA_CREATE 0 +# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 0 +# define CMS_F_CMS_ENVELOPED_DATA_INIT 0 +# define CMS_F_CMS_ENV_ASN1_CTRL 0 +# define CMS_F_CMS_FINAL 0 +# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 0 +# define CMS_F_CMS_GET0_CONTENT 0 +# define CMS_F_CMS_GET0_ECONTENT_TYPE 0 +# define CMS_F_CMS_GET0_ENVELOPED 0 +# define CMS_F_CMS_GET0_REVOCATION_CHOICES 0 +# define CMS_F_CMS_GET0_SIGNED 0 +# define CMS_F_CMS_MSGSIGDIGEST_ADD1 0 +# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 0 +# define CMS_F_CMS_RECEIPT_VERIFY 0 +# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 0 +# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 0 +# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 0 +# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 0 +# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 0 +# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 0 +# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 0 +# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 0 +# define CMS_F_CMS_SD_ASN1_CTRL 0 +# define CMS_F_CMS_SET1_IAS 0 +# define CMS_F_CMS_SET1_KEYID 0 +# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 0 +# define CMS_F_CMS_SET_DETACHED 0 +# define CMS_F_CMS_SIGN 0 +# define CMS_F_CMS_SIGNED_DATA_INIT 0 +# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 0 +# define CMS_F_CMS_SIGNERINFO_SIGN 0 +# define CMS_F_CMS_SIGNERINFO_VERIFY 0 +# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 0 +# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 0 +# define CMS_F_CMS_SIGN_RECEIPT 0 +# define CMS_F_CMS_SI_CHECK_ATTRIBUTES 0 +# define CMS_F_CMS_STREAM 0 +# define CMS_F_CMS_UNCOMPRESS 0 +# define CMS_F_CMS_VERIFY 0 +# define CMS_F_KEK_UNWRAP_KEY 0 +# endif -# ifndef OPENSSL_NO_COMP +# ifndef OPENSSL_NO_COMP /* * COMP function codes. */ -# define COMP_F_BIO_ZLIB_FLUSH 0 -# define COMP_F_BIO_ZLIB_NEW 0 -# define COMP_F_BIO_ZLIB_READ 0 -# define COMP_F_BIO_ZLIB_WRITE 0 -# define COMP_F_COMP_CTX_NEW 0 -# endif +# define COMP_F_BIO_ZLIB_FLUSH 0 +# define COMP_F_BIO_ZLIB_NEW 0 +# define COMP_F_BIO_ZLIB_READ 0 +# define COMP_F_BIO_ZLIB_WRITE 0 +# define COMP_F_COMP_CTX_NEW 0 +# endif /* * CONF function codes. */ -# define CONF_F_CONF_DUMP_FP 0 -# define CONF_F_CONF_LOAD 0 -# define CONF_F_CONF_LOAD_FP 0 -# define CONF_F_CONF_PARSE_LIST 0 -# define CONF_F_DEF_LOAD 0 -# define CONF_F_DEF_LOAD_BIO 0 -# define CONF_F_GET_NEXT_FILE 0 -# define CONF_F_MODULE_ADD 0 -# define CONF_F_MODULE_INIT 0 -# define CONF_F_MODULE_LOAD_DSO 0 -# define CONF_F_MODULE_RUN 0 -# define CONF_F_NCONF_DUMP_BIO 0 -# define CONF_F_NCONF_DUMP_FP 0 -# define CONF_F_NCONF_GET_NUMBER_E 0 -# define CONF_F_NCONF_GET_SECTION 0 -# define CONF_F_NCONF_GET_STRING 0 -# define CONF_F_NCONF_LOAD 0 -# define CONF_F_NCONF_LOAD_BIO 0 -# define CONF_F_NCONF_LOAD_FP 0 -# define CONF_F_NCONF_NEW 0 -# define CONF_F_PROCESS_INCLUDE 0 -# define CONF_F_SSL_MODULE_INIT 0 -# define CONF_F_STR_COPY 0 +# define CONF_F_CONF_DUMP_FP 0 +# define CONF_F_CONF_LOAD 0 +# define CONF_F_CONF_LOAD_FP 0 +# define CONF_F_CONF_PARSE_LIST 0 +# define CONF_F_DEF_LOAD 0 +# define CONF_F_DEF_LOAD_BIO 0 +# define CONF_F_GET_NEXT_FILE 0 +# define CONF_F_MODULE_ADD 0 +# define CONF_F_MODULE_INIT 0 +# define CONF_F_MODULE_LOAD_DSO 0 +# define CONF_F_MODULE_RUN 0 +# define CONF_F_NCONF_DUMP_BIO 0 +# define CONF_F_NCONF_DUMP_FP 0 +# define CONF_F_NCONF_GET_NUMBER_E 0 +# define CONF_F_NCONF_GET_SECTION 0 +# define CONF_F_NCONF_GET_STRING 0 +# define CONF_F_NCONF_LOAD 0 +# define CONF_F_NCONF_LOAD_BIO 0 +# define CONF_F_NCONF_LOAD_FP 0 +# define CONF_F_NCONF_NEW 0 +# define CONF_F_PROCESS_INCLUDE 0 +# define CONF_F_SSL_MODULE_INIT 0 +# define CONF_F_STR_COPY 0 /* * CRYPTO function codes. */ -# define CRYPTO_F_CMAC_CTX_NEW 0 -# define CRYPTO_F_CRYPTO_DUP_EX_DATA 0 -# define CRYPTO_F_CRYPTO_FREE_EX_DATA 0 -# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 0 -# define CRYPTO_F_CRYPTO_MEMDUP 0 -# define CRYPTO_F_CRYPTO_NEW_EX_DATA 0 -# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 0 -# define CRYPTO_F_CRYPTO_OCB128_INIT 0 -# define CRYPTO_F_CRYPTO_SET_EX_DATA 0 -# define CRYPTO_F_GET_AND_LOCK 0 -# define CRYPTO_F_OPENSSL_ATEXIT 0 -# define CRYPTO_F_OPENSSL_BUF2HEXSTR 0 -# define CRYPTO_F_OPENSSL_FOPEN 0 -# define CRYPTO_F_OPENSSL_HEXSTR2BUF 0 -# define CRYPTO_F_OPENSSL_INIT_CRYPTO 0 -# define CRYPTO_F_OPENSSL_LH_NEW 0 -# define CRYPTO_F_OPENSSL_SK_DEEP_COPY 0 -# define CRYPTO_F_OPENSSL_SK_DUP 0 -# define CRYPTO_F_PKEY_HMAC_INIT 0 -# define CRYPTO_F_PKEY_POLY1305_INIT 0 -# define CRYPTO_F_PKEY_SIPHASH_INIT 0 -# define CRYPTO_F_SK_RESERVE 0 +# define CRYPTO_F_CMAC_CTX_NEW 0 +# define CRYPTO_F_CRYPTO_DUP_EX_DATA 0 +# define CRYPTO_F_CRYPTO_FREE_EX_DATA 0 +# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 0 +# define CRYPTO_F_CRYPTO_MEMDUP 0 +# define CRYPTO_F_CRYPTO_NEW_EX_DATA 0 +# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 0 +# define CRYPTO_F_CRYPTO_OCB128_INIT 0 +# define CRYPTO_F_CRYPTO_SET_EX_DATA 0 +# define CRYPTO_F_GET_AND_LOCK 0 +# define CRYPTO_F_OPENSSL_ATEXIT 0 +# define CRYPTO_F_OPENSSL_BUF2HEXSTR 0 +# define CRYPTO_F_OPENSSL_FOPEN 0 +# define CRYPTO_F_OPENSSL_HEXSTR2BUF 0 +# define CRYPTO_F_OPENSSL_INIT_CRYPTO 0 +# define CRYPTO_F_OPENSSL_LH_NEW 0 +# define CRYPTO_F_OPENSSL_SK_DEEP_COPY 0 +# define CRYPTO_F_OPENSSL_SK_DUP 0 +# define CRYPTO_F_PKEY_HMAC_INIT 0 +# define CRYPTO_F_PKEY_POLY1305_INIT 0 +# define CRYPTO_F_PKEY_SIPHASH_INIT 0 +# define CRYPTO_F_SK_RESERVE 0 -# ifndef OPENSSL_NO_CT +# ifndef OPENSSL_NO_CT /* * CT function codes. */ -# define CT_F_CTLOG_NEW 0 -# define CT_F_CTLOG_NEW_FROM_BASE64 0 -# define CT_F_CTLOG_NEW_FROM_CONF 0 -# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 0 -# define CT_F_CTLOG_STORE_LOAD_FILE 0 -# define CT_F_CTLOG_STORE_LOAD_LOG 0 -# define CT_F_CTLOG_STORE_NEW 0 -# define CT_F_CT_BASE64_DECODE 0 -# define CT_F_CT_POLICY_EVAL_CTX_NEW 0 -# define CT_F_CT_V1_LOG_ID_FROM_PKEY 0 -# define CT_F_I2O_SCT 0 -# define CT_F_I2O_SCT_LIST 0 -# define CT_F_I2O_SCT_SIGNATURE 0 -# define CT_F_O2I_SCT 0 -# define CT_F_O2I_SCT_LIST 0 -# define CT_F_O2I_SCT_SIGNATURE 0 -# define CT_F_SCT_CTX_NEW 0 -# define CT_F_SCT_CTX_VERIFY 0 -# define CT_F_SCT_NEW 0 -# define CT_F_SCT_NEW_FROM_BASE64 0 -# define CT_F_SCT_SET0_LOG_ID 0 -# define CT_F_SCT_SET1_EXTENSIONS 0 -# define CT_F_SCT_SET1_LOG_ID 0 -# define CT_F_SCT_SET1_SIGNATURE 0 -# define CT_F_SCT_SET_LOG_ENTRY_TYPE 0 -# define CT_F_SCT_SET_SIGNATURE_NID 0 -# define CT_F_SCT_SET_VERSION 0 -# endif +# define CT_F_CTLOG_NEW 0 +# define CT_F_CTLOG_NEW_FROM_BASE64 0 +# define CT_F_CTLOG_NEW_FROM_CONF 0 +# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 0 +# define CT_F_CTLOG_STORE_LOAD_FILE 0 +# define CT_F_CTLOG_STORE_LOAD_LOG 0 +# define CT_F_CTLOG_STORE_NEW 0 +# define CT_F_CT_BASE64_DECODE 0 +# define CT_F_CT_POLICY_EVAL_CTX_NEW 0 +# define CT_F_CT_V1_LOG_ID_FROM_PKEY 0 +# define CT_F_I2O_SCT 0 +# define CT_F_I2O_SCT_LIST 0 +# define CT_F_I2O_SCT_SIGNATURE 0 +# define CT_F_O2I_SCT 0 +# define CT_F_O2I_SCT_LIST 0 +# define CT_F_O2I_SCT_SIGNATURE 0 +# define CT_F_SCT_CTX_NEW 0 +# define CT_F_SCT_CTX_VERIFY 0 +# define CT_F_SCT_NEW 0 +# define CT_F_SCT_NEW_FROM_BASE64 0 +# define CT_F_SCT_SET0_LOG_ID 0 +# define CT_F_SCT_SET1_EXTENSIONS 0 +# define CT_F_SCT_SET1_LOG_ID 0 +# define CT_F_SCT_SET1_SIGNATURE 0 +# define CT_F_SCT_SET_LOG_ENTRY_TYPE 0 +# define CT_F_SCT_SET_SIGNATURE_NID 0 +# define CT_F_SCT_SET_VERSION 0 +# endif -# ifndef OPENSSL_NO_DH +# ifndef OPENSSL_NO_DH /* * DH function codes. */ -# define DH_F_COMPUTE_KEY 0 -# define DH_F_DHPARAMS_PRINT_FP 0 -# define DH_F_DH_BUILTIN_GENPARAMS 0 -# define DH_F_DH_CHECK_EX 0 -# define DH_F_DH_CHECK_PARAMS_EX 0 -# define DH_F_DH_CHECK_PUB_KEY_EX 0 -# define DH_F_DH_CMS_DECRYPT 0 -# define DH_F_DH_CMS_SET_PEERKEY 0 -# define DH_F_DH_CMS_SET_SHARED_INFO 0 -# define DH_F_DH_METH_DUP 0 -# define DH_F_DH_METH_NEW 0 -# define DH_F_DH_METH_SET1_NAME 0 -# define DH_F_DH_NEW_BY_NID 0 -# define DH_F_DH_NEW_METHOD 0 -# define DH_F_DH_PARAM_DECODE 0 -# define DH_F_DH_PKEY_PUBLIC_CHECK 0 -# define DH_F_DH_PRIV_DECODE 0 -# define DH_F_DH_PRIV_ENCODE 0 -# define DH_F_DH_PUB_DECODE 0 -# define DH_F_DH_PUB_ENCODE 0 -# define DH_F_DO_DH_PRINT 0 -# define DH_F_GENERATE_KEY 0 -# define DH_F_PKEY_DH_CTRL_STR 0 -# define DH_F_PKEY_DH_DERIVE 0 -# define DH_F_PKEY_DH_INIT 0 -# define DH_F_PKEY_DH_KEYGEN 0 -# endif +# define DH_F_COMPUTE_KEY 0 +# define DH_F_DHPARAMS_PRINT_FP 0 +# define DH_F_DH_BUILTIN_GENPARAMS 0 +# define DH_F_DH_CHECK_EX 0 +# define DH_F_DH_CHECK_PARAMS_EX 0 +# define DH_F_DH_CHECK_PUB_KEY_EX 0 +# define DH_F_DH_CMS_DECRYPT 0 +# define DH_F_DH_CMS_SET_PEERKEY 0 +# define DH_F_DH_CMS_SET_SHARED_INFO 0 +# define DH_F_DH_METH_DUP 0 +# define DH_F_DH_METH_NEW 0 +# define DH_F_DH_METH_SET1_NAME 0 +# define DH_F_DH_NEW_BY_NID 0 +# define DH_F_DH_NEW_METHOD 0 +# define DH_F_DH_PARAM_DECODE 0 +# define DH_F_DH_PKEY_PUBLIC_CHECK 0 +# define DH_F_DH_PRIV_DECODE 0 +# define DH_F_DH_PRIV_ENCODE 0 +# define DH_F_DH_PUB_DECODE 0 +# define DH_F_DH_PUB_ENCODE 0 +# define DH_F_DO_DH_PRINT 0 +# define DH_F_GENERATE_KEY 0 +# define DH_F_PKEY_DH_CTRL_STR 0 +# define DH_F_PKEY_DH_DERIVE 0 +# define DH_F_PKEY_DH_INIT 0 +# define DH_F_PKEY_DH_KEYGEN 0 +# endif -# ifndef OPENSSL_NO_DSA +# ifndef OPENSSL_NO_DSA /* * DSA function codes. */ -# define DSA_F_DSAPARAMS_PRINT 0 -# define DSA_F_DSAPARAMS_PRINT_FP 0 -# define DSA_F_DSA_BUILTIN_PARAMGEN 0 -# define DSA_F_DSA_BUILTIN_PARAMGEN2 0 -# define DSA_F_DSA_DO_SIGN 0 -# define DSA_F_DSA_DO_VERIFY 0 -# define DSA_F_DSA_METH_DUP 0 -# define DSA_F_DSA_METH_NEW 0 -# define DSA_F_DSA_METH_SET1_NAME 0 -# define DSA_F_DSA_NEW_METHOD 0 -# define DSA_F_DSA_PARAM_DECODE 0 -# define DSA_F_DSA_PRINT_FP 0 -# define DSA_F_DSA_PRIV_DECODE 0 -# define DSA_F_DSA_PRIV_ENCODE 0 -# define DSA_F_DSA_PUB_DECODE 0 -# define DSA_F_DSA_PUB_ENCODE 0 -# define DSA_F_DSA_SIGN 0 -# define DSA_F_DSA_SIGN_SETUP 0 -# define DSA_F_DSA_SIG_NEW 0 -# define DSA_F_OLD_DSA_PRIV_DECODE 0 -# define DSA_F_PKEY_DSA_CTRL 0 -# define DSA_F_PKEY_DSA_CTRL_STR 0 -# define DSA_F_PKEY_DSA_KEYGEN 0 -# endif +# define DSA_F_DSAPARAMS_PRINT 0 +# define DSA_F_DSAPARAMS_PRINT_FP 0 +# define DSA_F_DSA_BUILTIN_PARAMGEN 0 +# define DSA_F_DSA_BUILTIN_PARAMGEN2 0 +# define DSA_F_DSA_DO_SIGN 0 +# define DSA_F_DSA_DO_VERIFY 0 +# define DSA_F_DSA_METH_DUP 0 +# define DSA_F_DSA_METH_NEW 0 +# define DSA_F_DSA_METH_SET1_NAME 0 +# define DSA_F_DSA_NEW_METHOD 0 +# define DSA_F_DSA_PARAM_DECODE 0 +# define DSA_F_DSA_PRINT_FP 0 +# define DSA_F_DSA_PRIV_DECODE 0 +# define DSA_F_DSA_PRIV_ENCODE 0 +# define DSA_F_DSA_PUB_DECODE 0 +# define DSA_F_DSA_PUB_ENCODE 0 +# define DSA_F_DSA_SIGN 0 +# define DSA_F_DSA_SIGN_SETUP 0 +# define DSA_F_DSA_SIG_NEW 0 +# define DSA_F_OLD_DSA_PRIV_DECODE 0 +# define DSA_F_PKEY_DSA_CTRL 0 +# define DSA_F_PKEY_DSA_CTRL_STR 0 +# define DSA_F_PKEY_DSA_KEYGEN 0 +# endif -# ifndef OPENSSL_NO_EC +# ifndef OPENSSL_NO_EC /* * EC function codes. */ -# define EC_F_BN_TO_FELEM 0 -# define EC_F_D2I_ECPARAMETERS 0 -# define EC_F_D2I_ECPKPARAMETERS 0 -# define EC_F_D2I_ECPRIVATEKEY 0 -# define EC_F_DO_EC_KEY_PRINT 0 -# define EC_F_ECDH_CMS_DECRYPT 0 -# define EC_F_ECDH_CMS_SET_SHARED_INFO 0 -# define EC_F_ECDH_COMPUTE_KEY 0 -# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 0 -# define EC_F_ECDSA_DO_SIGN_EX 0 -# define EC_F_ECDSA_DO_VERIFY 0 -# define EC_F_ECDSA_SIGN_EX 0 -# define EC_F_ECDSA_SIGN_SETUP 0 -# define EC_F_ECDSA_SIG_NEW 0 -# define EC_F_ECDSA_VERIFY 0 -# define EC_F_ECD_ITEM_VERIFY 0 -# define EC_F_ECKEY_PARAM2TYPE 0 -# define EC_F_ECKEY_PARAM_DECODE 0 -# define EC_F_ECKEY_PRIV_DECODE 0 -# define EC_F_ECKEY_PRIV_ENCODE 0 -# define EC_F_ECKEY_PUB_DECODE 0 -# define EC_F_ECKEY_PUB_ENCODE 0 -# define EC_F_ECKEY_TYPE2PARAM 0 -# define EC_F_ECPARAMETERS_PRINT 0 -# define EC_F_ECPARAMETERS_PRINT_FP 0 -# define EC_F_ECPKPARAMETERS_PRINT 0 -# define EC_F_ECPKPARAMETERS_PRINT_FP 0 -# define EC_F_ECP_NISTZ256_GET_AFFINE 0 -# define EC_F_ECP_NISTZ256_INV_MOD_ORD 0 -# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 0 -# define EC_F_ECP_NISTZ256_POINTS_MUL 0 -# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 0 -# define EC_F_ECP_NISTZ256_WINDOWED_MUL 0 -# define EC_F_ECX_KEY_OP 0 -# define EC_F_ECX_PRIV_ENCODE 0 -# define EC_F_ECX_PUB_ENCODE 0 -# define EC_F_EC_ASN1_GROUP2CURVE 0 -# define EC_F_EC_ASN1_GROUP2FIELDID 0 -# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 0 -# define EC_F_EC_GF2M_SIMPLE_FIELD_INV 0 -# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 0 -# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 0 -# define EC_F_EC_GF2M_SIMPLE_LADDER_POST 0 -# define EC_F_EC_GF2M_SIMPLE_LADDER_PRE 0 -# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 0 -# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 0 -# define EC_F_EC_GF2M_SIMPLE_POINTS_MUL 0 -# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 0 -# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 0 -# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 0 -# define EC_F_EC_GFP_MONT_FIELD_DECODE 0 -# define EC_F_EC_GFP_MONT_FIELD_ENCODE 0 -# define EC_F_EC_GFP_MONT_FIELD_INV 0 -# define EC_F_EC_GFP_MONT_FIELD_MUL 0 -# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 0 -# define EC_F_EC_GFP_MONT_FIELD_SQR 0 -# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 0 -# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 0 -# define EC_F_EC_GFP_NISTP224_POINTS_MUL 0 -# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 0 -# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 0 -# define EC_F_EC_GFP_NISTP256_POINTS_MUL 0 -# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 0 -# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 0 -# define EC_F_EC_GFP_NISTP521_POINTS_MUL 0 -# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 0 -# define EC_F_EC_GFP_NIST_FIELD_MUL 0 -# define EC_F_EC_GFP_NIST_FIELD_SQR 0 -# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 0 -# define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES 0 -# define EC_F_EC_GFP_SIMPLE_FIELD_INV 0 -# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 0 -# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 0 -# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 0 -# define EC_F_EC_GFP_SIMPLE_OCT2POINT 0 -# define EC_F_EC_GFP_SIMPLE_POINT2OCT 0 -# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 0 -# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 0 -# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 0 -# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 0 -# define EC_F_EC_GROUP_CHECK 0 -# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 0 -# define EC_F_EC_GROUP_COPY 0 -# define EC_F_EC_GROUP_GET_CURVE 0 -# define EC_F_EC_GROUP_GET_CURVE_GF2M 0 -# define EC_F_EC_GROUP_GET_CURVE_GFP 0 -# define EC_F_EC_GROUP_GET_DEGREE 0 -# define EC_F_EC_GROUP_GET_ECPARAMETERS 0 -# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 0 -# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 0 -# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 0 -# define EC_F_EC_GROUP_NEW 0 -# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 0 -# define EC_F_EC_GROUP_NEW_FROM_DATA 0 -# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 0 -# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 0 -# define EC_F_EC_GROUP_SET_CURVE 0 -# define EC_F_EC_GROUP_SET_CURVE_GF2M 0 -# define EC_F_EC_GROUP_SET_CURVE_GFP 0 -# define EC_F_EC_GROUP_SET_GENERATOR 0 -# define EC_F_EC_GROUP_SET_SEED 0 -# define EC_F_EC_KEY_CHECK_KEY 0 -# define EC_F_EC_KEY_COPY 0 -# define EC_F_EC_KEY_GENERATE_KEY 0 -# define EC_F_EC_KEY_NEW 0 -# define EC_F_EC_KEY_NEW_METHOD 0 -# define EC_F_EC_KEY_OCT2PRIV 0 -# define EC_F_EC_KEY_PRINT 0 -# define EC_F_EC_KEY_PRINT_FP 0 -# define EC_F_EC_KEY_PRIV2BUF 0 -# define EC_F_EC_KEY_PRIV2OCT 0 -# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 0 -# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 0 -# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 0 -# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 0 -# define EC_F_EC_PKEY_CHECK 0 -# define EC_F_EC_PKEY_PARAM_CHECK 0 -# define EC_F_EC_POINTS_MAKE_AFFINE 0 -# define EC_F_EC_POINTS_MUL 0 -# define EC_F_EC_POINT_ADD 0 -# define EC_F_EC_POINT_BN2POINT 0 -# define EC_F_EC_POINT_CMP 0 -# define EC_F_EC_POINT_COPY 0 -# define EC_F_EC_POINT_DBL 0 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES 0 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 0 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 0 -# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 0 -# define EC_F_EC_POINT_INVERT 0 -# define EC_F_EC_POINT_IS_AT_INFINITY 0 -# define EC_F_EC_POINT_IS_ON_CURVE 0 -# define EC_F_EC_POINT_MAKE_AFFINE 0 -# define EC_F_EC_POINT_NEW 0 -# define EC_F_EC_POINT_OCT2POINT 0 -# define EC_F_EC_POINT_POINT2BUF 0 -# define EC_F_EC_POINT_POINT2OCT 0 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES 0 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 0 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 0 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES 0 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 0 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 0 -# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 0 -# define EC_F_EC_POINT_SET_TO_INFINITY 0 -# define EC_F_EC_PRE_COMP_NEW 0 -# define EC_F_EC_SCALAR_MUL_LADDER 0 -# define EC_F_EC_WNAF_MUL 0 -# define EC_F_EC_WNAF_PRECOMPUTE_MULT 0 -# define EC_F_I2D_ECPARAMETERS 0 -# define EC_F_I2D_ECPKPARAMETERS 0 -# define EC_F_I2D_ECPRIVATEKEY 0 -# define EC_F_I2O_ECPUBLICKEY 0 -# define EC_F_NISTP224_PRE_COMP_NEW 0 -# define EC_F_NISTP256_PRE_COMP_NEW 0 -# define EC_F_NISTP521_PRE_COMP_NEW 0 -# define EC_F_O2I_ECPUBLICKEY 0 -# define EC_F_OLD_EC_PRIV_DECODE 0 -# define EC_F_OSSL_ECDH_COMPUTE_KEY 0 -# define EC_F_OSSL_ECDSA_SIGN_SIG 0 -# define EC_F_OSSL_ECDSA_VERIFY_SIG 0 -# define EC_F_PKEY_ECD_CTRL 0 -# define EC_F_PKEY_ECD_DIGESTSIGN 0 -# define EC_F_PKEY_ECD_DIGESTSIGN25519 0 -# define EC_F_PKEY_ECD_DIGESTSIGN448 0 -# define EC_F_PKEY_ECX_DERIVE 0 -# define EC_F_PKEY_EC_CTRL 0 -# define EC_F_PKEY_EC_CTRL_STR 0 -# define EC_F_PKEY_EC_DERIVE 0 -# define EC_F_PKEY_EC_INIT 0 -# define EC_F_PKEY_EC_KDF_DERIVE 0 -# define EC_F_PKEY_EC_KEYGEN 0 -# define EC_F_PKEY_EC_PARAMGEN 0 -# define EC_F_PKEY_EC_SIGN 0 -# define EC_F_VALIDATE_ECX_DERIVE 0 -# endif +# define EC_F_BN_TO_FELEM 0 +# define EC_F_D2I_ECPARAMETERS 0 +# define EC_F_D2I_ECPKPARAMETERS 0 +# define EC_F_D2I_ECPRIVATEKEY 0 +# define EC_F_DO_EC_KEY_PRINT 0 +# define EC_F_ECDH_CMS_DECRYPT 0 +# define EC_F_ECDH_CMS_SET_SHARED_INFO 0 +# define EC_F_ECDH_COMPUTE_KEY 0 +# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 0 +# define EC_F_ECDSA_DO_SIGN_EX 0 +# define EC_F_ECDSA_DO_VERIFY 0 +# define EC_F_ECDSA_SIGN_EX 0 +# define EC_F_ECDSA_SIGN_SETUP 0 +# define EC_F_ECDSA_SIG_NEW 0 +# define EC_F_ECDSA_VERIFY 0 +# define EC_F_ECD_ITEM_VERIFY 0 +# define EC_F_ECKEY_PARAM2TYPE 0 +# define EC_F_ECKEY_PARAM_DECODE 0 +# define EC_F_ECKEY_PRIV_DECODE 0 +# define EC_F_ECKEY_PRIV_ENCODE 0 +# define EC_F_ECKEY_PUB_DECODE 0 +# define EC_F_ECKEY_PUB_ENCODE 0 +# define EC_F_ECKEY_TYPE2PARAM 0 +# define EC_F_ECPARAMETERS_PRINT 0 +# define EC_F_ECPARAMETERS_PRINT_FP 0 +# define EC_F_ECPKPARAMETERS_PRINT 0 +# define EC_F_ECPKPARAMETERS_PRINT_FP 0 +# define EC_F_ECP_NISTZ256_GET_AFFINE 0 +# define EC_F_ECP_NISTZ256_INV_MOD_ORD 0 +# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 0 +# define EC_F_ECP_NISTZ256_POINTS_MUL 0 +# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 0 +# define EC_F_ECP_NISTZ256_WINDOWED_MUL 0 +# define EC_F_ECX_KEY_OP 0 +# define EC_F_ECX_PRIV_ENCODE 0 +# define EC_F_ECX_PUB_ENCODE 0 +# define EC_F_EC_ASN1_GROUP2CURVE 0 +# define EC_F_EC_ASN1_GROUP2FIELDID 0 +# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 0 +# define EC_F_EC_GF2M_SIMPLE_FIELD_INV 0 +# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 0 +# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 0 +# define EC_F_EC_GF2M_SIMPLE_LADDER_POST 0 +# define EC_F_EC_GF2M_SIMPLE_LADDER_PRE 0 +# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 0 +# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 0 +# define EC_F_EC_GF2M_SIMPLE_POINTS_MUL 0 +# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 0 +# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 0 +# define EC_F_EC_GFP_MONT_FIELD_DECODE 0 +# define EC_F_EC_GFP_MONT_FIELD_ENCODE 0 +# define EC_F_EC_GFP_MONT_FIELD_INV 0 +# define EC_F_EC_GFP_MONT_FIELD_MUL 0 +# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 0 +# define EC_F_EC_GFP_MONT_FIELD_SQR 0 +# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP224_POINTS_MUL 0 +# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP256_POINTS_MUL 0 +# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_NISTP521_POINTS_MUL 0 +# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_NIST_FIELD_MUL 0 +# define EC_F_EC_GFP_NIST_FIELD_SQR 0 +# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES 0 +# define EC_F_EC_GFP_SIMPLE_FIELD_INV 0 +# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 0 +# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 0 +# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 0 +# define EC_F_EC_GFP_SIMPLE_OCT2POINT 0 +# define EC_F_EC_GFP_SIMPLE_POINT2OCT 0 +# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 0 +# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 0 +# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 0 +# define EC_F_EC_GROUP_CHECK 0 +# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 0 +# define EC_F_EC_GROUP_COPY 0 +# define EC_F_EC_GROUP_GET_CURVE 0 +# define EC_F_EC_GROUP_GET_CURVE_GF2M 0 +# define EC_F_EC_GROUP_GET_CURVE_GFP 0 +# define EC_F_EC_GROUP_GET_DEGREE 0 +# define EC_F_EC_GROUP_GET_ECPARAMETERS 0 +# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 0 +# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 0 +# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 0 +# define EC_F_EC_GROUP_NEW 0 +# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 0 +# define EC_F_EC_GROUP_NEW_FROM_DATA 0 +# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 0 +# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 0 +# define EC_F_EC_GROUP_SET_CURVE 0 +# define EC_F_EC_GROUP_SET_CURVE_GF2M 0 +# define EC_F_EC_GROUP_SET_CURVE_GFP 0 +# define EC_F_EC_GROUP_SET_GENERATOR 0 +# define EC_F_EC_GROUP_SET_SEED 0 +# define EC_F_EC_KEY_CHECK_KEY 0 +# define EC_F_EC_KEY_COPY 0 +# define EC_F_EC_KEY_GENERATE_KEY 0 +# define EC_F_EC_KEY_NEW 0 +# define EC_F_EC_KEY_NEW_METHOD 0 +# define EC_F_EC_KEY_OCT2PRIV 0 +# define EC_F_EC_KEY_PRINT 0 +# define EC_F_EC_KEY_PRINT_FP 0 +# define EC_F_EC_KEY_PRIV2BUF 0 +# define EC_F_EC_KEY_PRIV2OCT 0 +# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 0 +# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 0 +# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 0 +# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 0 +# define EC_F_EC_PKEY_CHECK 0 +# define EC_F_EC_PKEY_PARAM_CHECK 0 +# define EC_F_EC_POINTS_MAKE_AFFINE 0 +# define EC_F_EC_POINTS_MUL 0 +# define EC_F_EC_POINT_ADD 0 +# define EC_F_EC_POINT_BN2POINT 0 +# define EC_F_EC_POINT_CMP 0 +# define EC_F_EC_POINT_COPY 0 +# define EC_F_EC_POINT_DBL 0 +# define EC_F_EC_POINT_GET_AFFINE_COORDINATES 0 +# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 0 +# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_INVERT 0 +# define EC_F_EC_POINT_IS_AT_INFINITY 0 +# define EC_F_EC_POINT_IS_ON_CURVE 0 +# define EC_F_EC_POINT_MAKE_AFFINE 0 +# define EC_F_EC_POINT_NEW 0 +# define EC_F_EC_POINT_OCT2POINT 0 +# define EC_F_EC_POINT_POINT2BUF 0 +# define EC_F_EC_POINT_POINT2OCT 0 +# define EC_F_EC_POINT_SET_AFFINE_COORDINATES 0 +# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 0 +# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES 0 +# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 0 +# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 0 +# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 0 +# define EC_F_EC_POINT_SET_TO_INFINITY 0 +# define EC_F_EC_PRE_COMP_NEW 0 +# define EC_F_EC_SCALAR_MUL_LADDER 0 +# define EC_F_EC_WNAF_MUL 0 +# define EC_F_EC_WNAF_PRECOMPUTE_MULT 0 +# define EC_F_I2D_ECPARAMETERS 0 +# define EC_F_I2D_ECPKPARAMETERS 0 +# define EC_F_I2D_ECPRIVATEKEY 0 +# define EC_F_I2O_ECPUBLICKEY 0 +# define EC_F_NISTP224_PRE_COMP_NEW 0 +# define EC_F_NISTP256_PRE_COMP_NEW 0 +# define EC_F_NISTP521_PRE_COMP_NEW 0 +# define EC_F_O2I_ECPUBLICKEY 0 +# define EC_F_OLD_EC_PRIV_DECODE 0 +# define EC_F_OSSL_ECDH_COMPUTE_KEY 0 +# define EC_F_OSSL_ECDSA_SIGN_SIG 0 +# define EC_F_OSSL_ECDSA_VERIFY_SIG 0 +# define EC_F_PKEY_ECD_CTRL 0 +# define EC_F_PKEY_ECD_DIGESTSIGN 0 +# define EC_F_PKEY_ECD_DIGESTSIGN25519 0 +# define EC_F_PKEY_ECD_DIGESTSIGN448 0 +# define EC_F_PKEY_ECX_DERIVE 0 +# define EC_F_PKEY_EC_CTRL 0 +# define EC_F_PKEY_EC_CTRL_STR 0 +# define EC_F_PKEY_EC_DERIVE 0 +# define EC_F_PKEY_EC_INIT 0 +# define EC_F_PKEY_EC_KDF_DERIVE 0 +# define EC_F_PKEY_EC_KEYGEN 0 +# define EC_F_PKEY_EC_PARAMGEN 0 +# define EC_F_PKEY_EC_SIGN 0 +# define EC_F_VALIDATE_ECX_DERIVE 0 +# endif -# ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE /* * ENGINE function codes. */ -# define ENGINE_F_DIGEST_UPDATE 0 -# define ENGINE_F_DYNAMIC_CTRL 0 -# define ENGINE_F_DYNAMIC_GET_DATA_CTX 0 -# define ENGINE_F_DYNAMIC_LOAD 0 -# define ENGINE_F_DYNAMIC_SET_DATA_CTX 0 -# define ENGINE_F_ENGINE_ADD 0 -# define ENGINE_F_ENGINE_BY_ID 0 -# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 0 -# define ENGINE_F_ENGINE_CTRL 0 -# define ENGINE_F_ENGINE_CTRL_CMD 0 -# define ENGINE_F_ENGINE_CTRL_CMD_STRING 0 -# define ENGINE_F_ENGINE_FINISH 0 -# define ENGINE_F_ENGINE_GET_CIPHER 0 -# define ENGINE_F_ENGINE_GET_DIGEST 0 -# define ENGINE_F_ENGINE_GET_FIRST 0 -# define ENGINE_F_ENGINE_GET_LAST 0 -# define ENGINE_F_ENGINE_GET_NEXT 0 -# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 0 -# define ENGINE_F_ENGINE_GET_PKEY_METH 0 -# define ENGINE_F_ENGINE_GET_PREV 0 -# define ENGINE_F_ENGINE_INIT 0 -# define ENGINE_F_ENGINE_LIST_ADD 0 -# define ENGINE_F_ENGINE_LIST_REMOVE 0 -# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 0 -# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 0 -# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 0 -# define ENGINE_F_ENGINE_NEW 0 -# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR 0 -# define ENGINE_F_ENGINE_REMOVE 0 -# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 0 -# define ENGINE_F_ENGINE_SET_ID 0 -# define ENGINE_F_ENGINE_SET_NAME 0 -# define ENGINE_F_ENGINE_TABLE_REGISTER 0 -# define ENGINE_F_ENGINE_UNLOCKED_FINISH 0 -# define ENGINE_F_ENGINE_UP_REF 0 -# define ENGINE_F_INT_CLEANUP_ITEM 0 -# define ENGINE_F_INT_CTRL_HELPER 0 -# define ENGINE_F_INT_ENGINE_CONFIGURE 0 -# define ENGINE_F_INT_ENGINE_MODULE_INIT 0 -# define ENGINE_F_OSSL_HMAC_INIT 0 -# endif +# define ENGINE_F_DIGEST_UPDATE 0 +# define ENGINE_F_DYNAMIC_CTRL 0 +# define ENGINE_F_DYNAMIC_GET_DATA_CTX 0 +# define ENGINE_F_DYNAMIC_LOAD 0 +# define ENGINE_F_DYNAMIC_SET_DATA_CTX 0 +# define ENGINE_F_ENGINE_ADD 0 +# define ENGINE_F_ENGINE_BY_ID 0 +# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 0 +# define ENGINE_F_ENGINE_CTRL 0 +# define ENGINE_F_ENGINE_CTRL_CMD 0 +# define ENGINE_F_ENGINE_CTRL_CMD_STRING 0 +# define ENGINE_F_ENGINE_FINISH 0 +# define ENGINE_F_ENGINE_GET_CIPHER 0 +# define ENGINE_F_ENGINE_GET_DIGEST 0 +# define ENGINE_F_ENGINE_GET_FIRST 0 +# define ENGINE_F_ENGINE_GET_LAST 0 +# define ENGINE_F_ENGINE_GET_NEXT 0 +# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 0 +# define ENGINE_F_ENGINE_GET_PKEY_METH 0 +# define ENGINE_F_ENGINE_GET_PREV 0 +# define ENGINE_F_ENGINE_INIT 0 +# define ENGINE_F_ENGINE_LIST_ADD 0 +# define ENGINE_F_ENGINE_LIST_REMOVE 0 +# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 0 +# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 0 +# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 0 +# define ENGINE_F_ENGINE_NEW 0 +# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR 0 +# define ENGINE_F_ENGINE_REMOVE 0 +# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 0 +# define ENGINE_F_ENGINE_SET_ID 0 +# define ENGINE_F_ENGINE_SET_NAME 0 +# define ENGINE_F_ENGINE_TABLE_REGISTER 0 +# define ENGINE_F_ENGINE_UNLOCKED_FINISH 0 +# define ENGINE_F_ENGINE_UP_REF 0 +# define ENGINE_F_INT_CLEANUP_ITEM 0 +# define ENGINE_F_INT_CTRL_HELPER 0 +# define ENGINE_F_INT_ENGINE_CONFIGURE 0 +# define ENGINE_F_INT_ENGINE_MODULE_INIT 0 +# define ENGINE_F_OSSL_HMAC_INIT 0 +# endif /* * EVP function codes. */ -# define EVP_F_AESNI_INIT_KEY 0 -# define EVP_F_AESNI_XTS_INIT_KEY 0 -# define EVP_F_AES_GCM_CTRL 0 -# define EVP_F_AES_INIT_KEY 0 -# define EVP_F_AES_OCB_CIPHER 0 -# define EVP_F_AES_T4_INIT_KEY 0 -# define EVP_F_AES_T4_XTS_INIT_KEY 0 -# define EVP_F_AES_WRAP_CIPHER 0 -# define EVP_F_AES_XTS_INIT_KEY 0 -# define EVP_F_ALG_MODULE_INIT 0 -# define EVP_F_ARIA_CCM_INIT_KEY 0 -# define EVP_F_ARIA_GCM_CTRL 0 -# define EVP_F_ARIA_GCM_INIT_KEY 0 -# define EVP_F_ARIA_INIT_KEY 0 -# define EVP_F_B64_NEW 0 -# define EVP_F_CAMELLIA_INIT_KEY 0 -# define EVP_F_CHACHA20_POLY1305_CTRL 0 -# define EVP_F_CMLL_T4_INIT_KEY 0 -# define EVP_F_DES_EDE3_WRAP_CIPHER 0 -# define EVP_F_DO_SIGVER_INIT 0 -# define EVP_F_ENC_NEW 0 -# define EVP_F_EVP_CIPHERINIT_EX 0 -# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM 0 -# define EVP_F_EVP_CIPHER_CTX_COPY 0 -# define EVP_F_EVP_CIPHER_CTX_CTRL 0 -# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 0 -# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1 0 -# define EVP_F_EVP_DECRYPTFINAL_EX 0 -# define EVP_F_EVP_DECRYPTUPDATE 0 -# define EVP_F_EVP_DIGESTFINALXOF 0 -# define EVP_F_EVP_DIGESTINIT_EX 0 -# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE 0 -# define EVP_F_EVP_ENCRYPTFINAL_EX 0 -# define EVP_F_EVP_ENCRYPTUPDATE 0 -# define EVP_F_EVP_MD_CTX_COPY_EX 0 -# define EVP_F_EVP_MD_SIZE 0 -# define EVP_F_EVP_OPENINIT 0 -# define EVP_F_EVP_PBE_ALG_ADD 0 -# define EVP_F_EVP_PBE_ALG_ADD_TYPE 0 -# define EVP_F_EVP_PBE_CIPHERINIT 0 -# define EVP_F_EVP_PBE_SCRYPT 0 -# define EVP_F_EVP_PKCS82PKEY 0 -# define EVP_F_EVP_PKEY2PKCS8 0 -# define EVP_F_EVP_PKEY_ASN1_ADD0 0 -# define EVP_F_EVP_PKEY_CHECK 0 -# define EVP_F_EVP_PKEY_COPY_PARAMETERS 0 -# define EVP_F_EVP_PKEY_CTX_CTRL 0 -# define EVP_F_EVP_PKEY_CTX_CTRL_STR 0 -# define EVP_F_EVP_PKEY_CTX_DUP 0 -# define EVP_F_EVP_PKEY_CTX_MD 0 -# define EVP_F_EVP_PKEY_DECRYPT 0 -# define EVP_F_EVP_PKEY_DECRYPT_INIT 0 -# define EVP_F_EVP_PKEY_DECRYPT_OLD 0 -# define EVP_F_EVP_PKEY_DERIVE 0 -# define EVP_F_EVP_PKEY_DERIVE_INIT 0 -# define EVP_F_EVP_PKEY_DERIVE_SET_PEER 0 -# define EVP_F_EVP_PKEY_ENCRYPT 0 -# define EVP_F_EVP_PKEY_ENCRYPT_INIT 0 -# define EVP_F_EVP_PKEY_ENCRYPT_OLD 0 -# define EVP_F_EVP_PKEY_GET0_DH 0 -# define EVP_F_EVP_PKEY_GET0_DSA 0 -# define EVP_F_EVP_PKEY_GET0_EC_KEY 0 -# define EVP_F_EVP_PKEY_GET0_HMAC 0 -# define EVP_F_EVP_PKEY_GET0_POLY1305 0 -# define EVP_F_EVP_PKEY_GET0_RSA 0 -# define EVP_F_EVP_PKEY_GET0_SIPHASH 0 -# define EVP_F_EVP_PKEY_GET_RAW_PRIVATE_KEY 0 -# define EVP_F_EVP_PKEY_GET_RAW_PUBLIC_KEY 0 -# define EVP_F_EVP_PKEY_KEYGEN 0 -# define EVP_F_EVP_PKEY_KEYGEN_INIT 0 -# define EVP_F_EVP_PKEY_METH_ADD0 0 -# define EVP_F_EVP_PKEY_METH_NEW 0 -# define EVP_F_EVP_PKEY_NEW 0 -# define EVP_F_EVP_PKEY_NEW_CMAC_KEY 0 -# define EVP_F_EVP_PKEY_NEW_RAW_PRIVATE_KEY 0 -# define EVP_F_EVP_PKEY_NEW_RAW_PUBLIC_KEY 0 -# define EVP_F_EVP_PKEY_PARAMGEN 0 -# define EVP_F_EVP_PKEY_PARAMGEN_INIT 0 -# define EVP_F_EVP_PKEY_PARAM_CHECK 0 -# define EVP_F_EVP_PKEY_PUBLIC_CHECK 0 -# define EVP_F_EVP_PKEY_SET1_ENGINE 0 -# define EVP_F_EVP_PKEY_SET_ALIAS_TYPE 0 -# define EVP_F_EVP_PKEY_SIGN 0 -# define EVP_F_EVP_PKEY_SIGN_INIT 0 -# define EVP_F_EVP_PKEY_VERIFY 0 -# define EVP_F_EVP_PKEY_VERIFY_INIT 0 -# define EVP_F_EVP_PKEY_VERIFY_RECOVER 0 -# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 0 -# define EVP_F_EVP_SIGNFINAL 0 -# define EVP_F_EVP_VERIFYFINAL 0 -# define EVP_F_INT_CTX_NEW 0 -# define EVP_F_OK_NEW 0 -# define EVP_F_PKCS5_PBE_KEYIVGEN 0 -# define EVP_F_PKCS5_V2_PBE_KEYIVGEN 0 -# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 0 -# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 0 -# define EVP_F_PKEY_SET_TYPE 0 -# define EVP_F_RC2_MAGIC_TO_METH 0 -# define EVP_F_RC5_CTRL 0 -# define EVP_F_R_32_12_16_INIT_KEY 0 -# define EVP_F_S390X_AES_GCM_CTRL 0 -# define EVP_F_UPDATE 0 +# define EVP_F_AESNI_INIT_KEY 0 +# define EVP_F_AESNI_XTS_INIT_KEY 0 +# define EVP_F_AES_GCM_CTRL 0 +# define EVP_F_AES_INIT_KEY 0 +# define EVP_F_AES_OCB_CIPHER 0 +# define EVP_F_AES_T4_INIT_KEY 0 +# define EVP_F_AES_T4_XTS_INIT_KEY 0 +# define EVP_F_AES_WRAP_CIPHER 0 +# define EVP_F_AES_XTS_INIT_KEY 0 +# define EVP_F_ALG_MODULE_INIT 0 +# define EVP_F_ARIA_CCM_INIT_KEY 0 +# define EVP_F_ARIA_GCM_CTRL 0 +# define EVP_F_ARIA_GCM_INIT_KEY 0 +# define EVP_F_ARIA_INIT_KEY 0 +# define EVP_F_B64_NEW 0 +# define EVP_F_CAMELLIA_INIT_KEY 0 +# define EVP_F_CHACHA20_POLY1305_CTRL 0 +# define EVP_F_CMLL_T4_INIT_KEY 0 +# define EVP_F_DES_EDE3_WRAP_CIPHER 0 +# define EVP_F_DO_SIGVER_INIT 0 +# define EVP_F_ENC_NEW 0 +# define EVP_F_EVP_CIPHERINIT_EX 0 +# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM 0 +# define EVP_F_EVP_CIPHER_CTX_COPY 0 +# define EVP_F_EVP_CIPHER_CTX_CTRL 0 +# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 0 +# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1 0 +# define EVP_F_EVP_DECRYPTFINAL_EX 0 +# define EVP_F_EVP_DECRYPTUPDATE 0 +# define EVP_F_EVP_DIGESTFINALXOF 0 +# define EVP_F_EVP_DIGESTINIT_EX 0 +# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE 0 +# define EVP_F_EVP_ENCRYPTFINAL_EX 0 +# define EVP_F_EVP_ENCRYPTUPDATE 0 +# define EVP_F_EVP_MD_CTX_COPY_EX 0 +# define EVP_F_EVP_MD_SIZE 0 +# define EVP_F_EVP_OPENINIT 0 +# define EVP_F_EVP_PBE_ALG_ADD 0 +# define EVP_F_EVP_PBE_ALG_ADD_TYPE 0 +# define EVP_F_EVP_PBE_CIPHERINIT 0 +# define EVP_F_EVP_PBE_SCRYPT 0 +# define EVP_F_EVP_PKCS82PKEY 0 +# define EVP_F_EVP_PKEY2PKCS8 0 +# define EVP_F_EVP_PKEY_ASN1_ADD0 0 +# define EVP_F_EVP_PKEY_CHECK 0 +# define EVP_F_EVP_PKEY_COPY_PARAMETERS 0 +# define EVP_F_EVP_PKEY_CTX_CTRL 0 +# define EVP_F_EVP_PKEY_CTX_CTRL_STR 0 +# define EVP_F_EVP_PKEY_CTX_DUP 0 +# define EVP_F_EVP_PKEY_CTX_MD 0 +# define EVP_F_EVP_PKEY_DECRYPT 0 +# define EVP_F_EVP_PKEY_DECRYPT_INIT 0 +# define EVP_F_EVP_PKEY_DECRYPT_OLD 0 +# define EVP_F_EVP_PKEY_DERIVE 0 +# define EVP_F_EVP_PKEY_DERIVE_INIT 0 +# define EVP_F_EVP_PKEY_DERIVE_SET_PEER 0 +# define EVP_F_EVP_PKEY_ENCRYPT 0 +# define EVP_F_EVP_PKEY_ENCRYPT_INIT 0 +# define EVP_F_EVP_PKEY_ENCRYPT_OLD 0 +# define EVP_F_EVP_PKEY_GET0_DH 0 +# define EVP_F_EVP_PKEY_GET0_DSA 0 +# define EVP_F_EVP_PKEY_GET0_EC_KEY 0 +# define EVP_F_EVP_PKEY_GET0_HMAC 0 +# define EVP_F_EVP_PKEY_GET0_POLY1305 0 +# define EVP_F_EVP_PKEY_GET0_RSA 0 +# define EVP_F_EVP_PKEY_GET0_SIPHASH 0 +# define EVP_F_EVP_PKEY_GET_RAW_PRIVATE_KEY 0 +# define EVP_F_EVP_PKEY_GET_RAW_PUBLIC_KEY 0 +# define EVP_F_EVP_PKEY_KEYGEN 0 +# define EVP_F_EVP_PKEY_KEYGEN_INIT 0 +# define EVP_F_EVP_PKEY_METH_ADD0 0 +# define EVP_F_EVP_PKEY_METH_NEW 0 +# define EVP_F_EVP_PKEY_NEW 0 +# define EVP_F_EVP_PKEY_NEW_CMAC_KEY 0 +# define EVP_F_EVP_PKEY_NEW_RAW_PRIVATE_KEY 0 +# define EVP_F_EVP_PKEY_NEW_RAW_PUBLIC_KEY 0 +# define EVP_F_EVP_PKEY_PARAMGEN 0 +# define EVP_F_EVP_PKEY_PARAMGEN_INIT 0 +# define EVP_F_EVP_PKEY_PARAM_CHECK 0 +# define EVP_F_EVP_PKEY_PUBLIC_CHECK 0 +# define EVP_F_EVP_PKEY_SET1_ENGINE 0 +# define EVP_F_EVP_PKEY_SET_ALIAS_TYPE 0 +# define EVP_F_EVP_PKEY_SIGN 0 +# define EVP_F_EVP_PKEY_SIGN_INIT 0 +# define EVP_F_EVP_PKEY_VERIFY 0 +# define EVP_F_EVP_PKEY_VERIFY_INIT 0 +# define EVP_F_EVP_PKEY_VERIFY_RECOVER 0 +# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 0 +# define EVP_F_EVP_SIGNFINAL 0 +# define EVP_F_EVP_VERIFYFINAL 0 +# define EVP_F_INT_CTX_NEW 0 +# define EVP_F_OK_NEW 0 +# define EVP_F_PKCS5_PBE_KEYIVGEN 0 +# define EVP_F_PKCS5_V2_PBE_KEYIVGEN 0 +# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 0 +# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 0 +# define EVP_F_PKEY_SET_TYPE 0 +# define EVP_F_RC2_MAGIC_TO_METH 0 +# define EVP_F_RC5_CTRL 0 +# define EVP_F_R_32_12_16_INIT_KEY 0 +# define EVP_F_S390X_AES_GCM_CTRL 0 +# define EVP_F_UPDATE 0 /* * KDF function codes. */ -# define KDF_F_PKEY_HKDF_CTRL_STR 0 -# define KDF_F_PKEY_HKDF_DERIVE 0 -# define KDF_F_PKEY_HKDF_INIT 0 -# define KDF_F_PKEY_SCRYPT_CTRL_STR 0 -# define KDF_F_PKEY_SCRYPT_CTRL_UINT64 0 -# define KDF_F_PKEY_SCRYPT_DERIVE 0 -# define KDF_F_PKEY_SCRYPT_INIT 0 -# define KDF_F_PKEY_SCRYPT_SET_MEMBUF 0 -# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 0 -# define KDF_F_PKEY_TLS1_PRF_DERIVE 0 -# define KDF_F_PKEY_TLS1_PRF_INIT 0 -# define KDF_F_TLS1_PRF_ALG 0 +# define KDF_F_PKEY_HKDF_CTRL_STR 0 +# define KDF_F_PKEY_HKDF_DERIVE 0 +# define KDF_F_PKEY_HKDF_INIT 0 +# define KDF_F_PKEY_SCRYPT_CTRL_STR 0 +# define KDF_F_PKEY_SCRYPT_CTRL_UINT64 0 +# define KDF_F_PKEY_SCRYPT_DERIVE 0 +# define KDF_F_PKEY_SCRYPT_INIT 0 +# define KDF_F_PKEY_SCRYPT_SET_MEMBUF 0 +# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 0 +# define KDF_F_PKEY_TLS1_PRF_DERIVE 0 +# define KDF_F_PKEY_TLS1_PRF_INIT 0 +# define KDF_F_TLS1_PRF_ALG 0 /* * KDF reason codes. */ -# define KDF_R_INVALID_DIGEST 0 -# define KDF_R_MISSING_ITERATION_COUNT 0 -# define KDF_R_MISSING_KEY 0 -# define KDF_R_MISSING_MESSAGE_DIGEST 0 -# define KDF_R_MISSING_PARAMETER 0 -# define KDF_R_MISSING_PASS 0 -# define KDF_R_MISSING_SALT 0 -# define KDF_R_MISSING_SECRET 0 -# define KDF_R_MISSING_SEED 0 -# define KDF_R_UNKNOWN_PARAMETER_TYPE 0 -# define KDF_R_VALUE_ERROR 0 -# define KDF_R_VALUE_MISSING 0 +# define KDF_R_INVALID_DIGEST 0 +# define KDF_R_MISSING_ITERATION_COUNT 0 +# define KDF_R_MISSING_KEY 0 +# define KDF_R_MISSING_MESSAGE_DIGEST 0 +# define KDF_R_MISSING_PARAMETER 0 +# define KDF_R_MISSING_PASS 0 +# define KDF_R_MISSING_SALT 0 +# define KDF_R_MISSING_SECRET 0 +# define KDF_R_MISSING_SEED 0 +# define KDF_R_UNKNOWN_PARAMETER_TYPE 0 +# define KDF_R_VALUE_ERROR 0 +# define KDF_R_VALUE_MISSING 0 /* * OBJ function codes. */ -# define OBJ_F_OBJ_ADD_OBJECT 0 -# define OBJ_F_OBJ_ADD_SIGID 0 -# define OBJ_F_OBJ_CREATE 0 -# define OBJ_F_OBJ_DUP 0 -# define OBJ_F_OBJ_NAME_NEW_INDEX 0 -# define OBJ_F_OBJ_NID2LN 0 -# define OBJ_F_OBJ_NID2OBJ 0 -# define OBJ_F_OBJ_NID2SN 0 -# define OBJ_F_OBJ_TXT2OBJ 0 +# define OBJ_F_OBJ_ADD_OBJECT 0 +# define OBJ_F_OBJ_ADD_SIGID 0 +# define OBJ_F_OBJ_CREATE 0 +# define OBJ_F_OBJ_DUP 0 +# define OBJ_F_OBJ_NAME_NEW_INDEX 0 +# define OBJ_F_OBJ_NID2LN 0 +# define OBJ_F_OBJ_NID2OBJ 0 +# define OBJ_F_OBJ_NID2SN 0 +# define OBJ_F_OBJ_TXT2OBJ 0 -# ifndef OPENSSL_NO_OCSP +# ifndef OPENSSL_NO_OCSP /* * OCSP function codes. */ -# define OCSP_F_D2I_OCSP_NONCE 0 -# define OCSP_F_OCSP_BASIC_ADD1_STATUS 0 -# define OCSP_F_OCSP_BASIC_SIGN 0 -# define OCSP_F_OCSP_BASIC_SIGN_CTX 0 -# define OCSP_F_OCSP_BASIC_VERIFY 0 -# define OCSP_F_OCSP_CERT_ID_NEW 0 -# define OCSP_F_OCSP_CHECK_DELEGATED 0 -# define OCSP_F_OCSP_CHECK_IDS 0 -# define OCSP_F_OCSP_CHECK_ISSUER 0 -# define OCSP_F_OCSP_CHECK_VALIDITY 0 -# define OCSP_F_OCSP_MATCH_ISSUERID 0 -# define OCSP_F_OCSP_PARSE_URL 0 -# define OCSP_F_OCSP_REQUEST_SIGN 0 -# define OCSP_F_OCSP_REQUEST_VERIFY 0 -# define OCSP_F_OCSP_RESPONSE_GET1_BASIC 0 -# define OCSP_F_PARSE_HTTP_LINE1 0 -# endif +# define OCSP_F_D2I_OCSP_NONCE 0 +# define OCSP_F_OCSP_BASIC_ADD1_STATUS 0 +# define OCSP_F_OCSP_BASIC_SIGN 0 +# define OCSP_F_OCSP_BASIC_SIGN_CTX 0 +# define OCSP_F_OCSP_BASIC_VERIFY 0 +# define OCSP_F_OCSP_CERT_ID_NEW 0 +# define OCSP_F_OCSP_CHECK_DELEGATED 0 +# define OCSP_F_OCSP_CHECK_IDS 0 +# define OCSP_F_OCSP_CHECK_ISSUER 0 +# define OCSP_F_OCSP_CHECK_VALIDITY 0 +# define OCSP_F_OCSP_MATCH_ISSUERID 0 +# define OCSP_F_OCSP_PARSE_URL 0 +# define OCSP_F_OCSP_REQUEST_SIGN 0 +# define OCSP_F_OCSP_REQUEST_VERIFY 0 +# define OCSP_F_OCSP_RESPONSE_GET1_BASIC 0 +# define OCSP_F_PARSE_HTTP_LINE1 0 +# endif /* * PEM function codes. */ -# define PEM_F_B2I_DSS 0 -# define PEM_F_B2I_PVK_BIO 0 -# define PEM_F_B2I_RSA 0 -# define PEM_F_CHECK_BITLEN_DSA 0 -# define PEM_F_CHECK_BITLEN_RSA 0 -# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 0 -# define PEM_F_D2I_PKCS8PRIVATEKEY_FP 0 -# define PEM_F_DO_B2I 0 -# define PEM_F_DO_B2I_BIO 0 -# define PEM_F_DO_BLOB_HEADER 0 -# define PEM_F_DO_I2B 0 -# define PEM_F_DO_PK8PKEY 0 -# define PEM_F_DO_PK8PKEY_FP 0 -# define PEM_F_DO_PVK_BODY 0 -# define PEM_F_DO_PVK_HEADER 0 -# define PEM_F_GET_HEADER_AND_DATA 0 -# define PEM_F_GET_NAME 0 -# define PEM_F_I2B_PVK 0 -# define PEM_F_I2B_PVK_BIO 0 -# define PEM_F_LOAD_IV 0 -# define PEM_F_PEM_ASN1_READ 0 -# define PEM_F_PEM_ASN1_READ_BIO 0 -# define PEM_F_PEM_ASN1_WRITE 0 -# define PEM_F_PEM_ASN1_WRITE_BIO 0 -# define PEM_F_PEM_DEF_CALLBACK 0 -# define PEM_F_PEM_DO_HEADER 0 -# define PEM_F_PEM_GET_EVP_CIPHER_INFO 0 -# define PEM_F_PEM_READ 0 -# define PEM_F_PEM_READ_BIO 0 -# define PEM_F_PEM_READ_BIO_DHPARAMS 0 -# define PEM_F_PEM_READ_BIO_EX 0 -# define PEM_F_PEM_READ_BIO_PARAMETERS 0 -# define PEM_F_PEM_READ_BIO_PRIVATEKEY 0 -# define PEM_F_PEM_READ_DHPARAMS 0 -# define PEM_F_PEM_READ_PRIVATEKEY 0 -# define PEM_F_PEM_SIGNFINAL 0 -# define PEM_F_PEM_WRITE 0 -# define PEM_F_PEM_WRITE_BIO 0 -# define PEM_F_PEM_WRITE_BIO_PRIVATEKEY_TRADITIONAL 0 -# define PEM_F_PEM_WRITE_PRIVATEKEY 0 -# define PEM_F_PEM_X509_INFO_READ 0 -# define PEM_F_PEM_X509_INFO_READ_BIO 0 -# define PEM_F_PEM_X509_INFO_WRITE_BIO 0 +# define PEM_F_B2I_DSS 0 +# define PEM_F_B2I_PVK_BIO 0 +# define PEM_F_B2I_RSA 0 +# define PEM_F_CHECK_BITLEN_DSA 0 +# define PEM_F_CHECK_BITLEN_RSA 0 +# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 0 +# define PEM_F_D2I_PKCS8PRIVATEKEY_FP 0 +# define PEM_F_DO_B2I 0 +# define PEM_F_DO_B2I_BIO 0 +# define PEM_F_DO_BLOB_HEADER 0 +# define PEM_F_DO_I2B 0 +# define PEM_F_DO_PK8PKEY 0 +# define PEM_F_DO_PK8PKEY_FP 0 +# define PEM_F_DO_PVK_BODY 0 +# define PEM_F_DO_PVK_HEADER 0 +# define PEM_F_GET_HEADER_AND_DATA 0 +# define PEM_F_GET_NAME 0 +# define PEM_F_I2B_PVK 0 +# define PEM_F_I2B_PVK_BIO 0 +# define PEM_F_LOAD_IV 0 +# define PEM_F_PEM_ASN1_READ 0 +# define PEM_F_PEM_ASN1_READ_BIO 0 +# define PEM_F_PEM_ASN1_WRITE 0 +# define PEM_F_PEM_ASN1_WRITE_BIO 0 +# define PEM_F_PEM_DEF_CALLBACK 0 +# define PEM_F_PEM_DO_HEADER 0 +# define PEM_F_PEM_GET_EVP_CIPHER_INFO 0 +# define PEM_F_PEM_READ 0 +# define PEM_F_PEM_READ_BIO 0 +# define PEM_F_PEM_READ_BIO_DHPARAMS 0 +# define PEM_F_PEM_READ_BIO_EX 0 +# define PEM_F_PEM_READ_BIO_PARAMETERS 0 +# define PEM_F_PEM_READ_BIO_PRIVATEKEY 0 +# define PEM_F_PEM_READ_DHPARAMS 0 +# define PEM_F_PEM_READ_PRIVATEKEY 0 +# define PEM_F_PEM_SIGNFINAL 0 +# define PEM_F_PEM_WRITE 0 +# define PEM_F_PEM_WRITE_BIO 0 +# define PEM_F_PEM_WRITE_BIO_PRIVATEKEY_TRADITIONAL 0 +# define PEM_F_PEM_WRITE_PRIVATEKEY 0 +# define PEM_F_PEM_X509_INFO_READ 0 +# define PEM_F_PEM_X509_INFO_READ_BIO 0 +# define PEM_F_PEM_X509_INFO_WRITE_BIO 0 /* * PKCS12 function codes. */ -# define PKCS12_F_OPENSSL_ASC2UNI 0 -# define PKCS12_F_OPENSSL_UNI2ASC 0 -# define PKCS12_F_OPENSSL_UNI2UTF8 0 -# define PKCS12_F_OPENSSL_UTF82UNI 0 -# define PKCS12_F_PKCS12_CREATE 0 -# define PKCS12_F_PKCS12_GEN_MAC 0 -# define PKCS12_F_PKCS12_INIT 0 -# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 0 -# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 0 -# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 0 -# define PKCS12_F_PKCS12_KEY_GEN_ASC 0 -# define PKCS12_F_PKCS12_KEY_GEN_UNI 0 -# define PKCS12_F_PKCS12_KEY_GEN_UTF8 0 -# define PKCS12_F_PKCS12_NEWPASS 0 -# define PKCS12_F_PKCS12_PACK_P7DATA 0 -# define PKCS12_F_PKCS12_PACK_P7ENCDATA 0 -# define PKCS12_F_PKCS12_PARSE 0 -# define PKCS12_F_PKCS12_PBE_CRYPT 0 -# define PKCS12_F_PKCS12_PBE_KEYIVGEN 0 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 0 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 0 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 0 -# define PKCS12_F_PKCS12_SETUP_MAC 0 -# define PKCS12_F_PKCS12_SET_MAC 0 -# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 0 -# define PKCS12_F_PKCS12_UNPACK_P7DATA 0 -# define PKCS12_F_PKCS12_VERIFY_MAC 0 -# define PKCS12_F_PKCS8_ENCRYPT 0 -# define PKCS12_F_PKCS8_SET0_PBE 0 +# define PKCS12_F_OPENSSL_ASC2UNI 0 +# define PKCS12_F_OPENSSL_UNI2ASC 0 +# define PKCS12_F_OPENSSL_UNI2UTF8 0 +# define PKCS12_F_OPENSSL_UTF82UNI 0 +# define PKCS12_F_PKCS12_CREATE 0 +# define PKCS12_F_PKCS12_GEN_MAC 0 +# define PKCS12_F_PKCS12_INIT 0 +# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 0 +# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 0 +# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 0 +# define PKCS12_F_PKCS12_KEY_GEN_ASC 0 +# define PKCS12_F_PKCS12_KEY_GEN_UNI 0 +# define PKCS12_F_PKCS12_KEY_GEN_UTF8 0 +# define PKCS12_F_PKCS12_NEWPASS 0 +# define PKCS12_F_PKCS12_PACK_P7DATA 0 +# define PKCS12_F_PKCS12_PACK_P7ENCDATA 0 +# define PKCS12_F_PKCS12_PARSE 0 +# define PKCS12_F_PKCS12_PBE_CRYPT 0 +# define PKCS12_F_PKCS12_PBE_KEYIVGEN 0 +# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 0 +# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 0 +# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 0 +# define PKCS12_F_PKCS12_SETUP_MAC 0 +# define PKCS12_F_PKCS12_SET_MAC 0 +# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 0 +# define PKCS12_F_PKCS12_UNPACK_P7DATA 0 +# define PKCS12_F_PKCS12_VERIFY_MAC 0 +# define PKCS12_F_PKCS8_ENCRYPT 0 +# define PKCS12_F_PKCS8_SET0_PBE 0 /* * PKCS7 function codes. */ -# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 0 -# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 0 -# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 0 -# define PKCS7_F_PKCS7_ADD_CERTIFICATE 0 -# define PKCS7_F_PKCS7_ADD_CRL 0 -# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 0 -# define PKCS7_F_PKCS7_ADD_SIGNATURE 0 -# define PKCS7_F_PKCS7_ADD_SIGNER 0 -# define PKCS7_F_PKCS7_BIO_ADD_DIGEST 0 -# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 0 -# define PKCS7_F_PKCS7_CTRL 0 -# define PKCS7_F_PKCS7_DATADECODE 0 -# define PKCS7_F_PKCS7_DATAFINAL 0 -# define PKCS7_F_PKCS7_DATAINIT 0 -# define PKCS7_F_PKCS7_DATAVERIFY 0 -# define PKCS7_F_PKCS7_DECRYPT 0 -# define PKCS7_F_PKCS7_DECRYPT_RINFO 0 -# define PKCS7_F_PKCS7_ENCODE_RINFO 0 -# define PKCS7_F_PKCS7_ENCRYPT 0 -# define PKCS7_F_PKCS7_FINAL 0 -# define PKCS7_F_PKCS7_FIND_DIGEST 0 -# define PKCS7_F_PKCS7_GET0_SIGNERS 0 -# define PKCS7_F_PKCS7_RECIP_INFO_SET 0 -# define PKCS7_F_PKCS7_SET_CIPHER 0 -# define PKCS7_F_PKCS7_SET_CONTENT 0 -# define PKCS7_F_PKCS7_SET_DIGEST 0 -# define PKCS7_F_PKCS7_SET_TYPE 0 -# define PKCS7_F_PKCS7_SIGN 0 -# define PKCS7_F_PKCS7_SIGNATUREVERIFY 0 -# define PKCS7_F_PKCS7_SIGNER_INFO_SET 0 -# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 0 -# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 0 -# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 0 -# define PKCS7_F_PKCS7_VERIFY 0 +# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 0 +# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 0 +# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 0 +# define PKCS7_F_PKCS7_ADD_CERTIFICATE 0 +# define PKCS7_F_PKCS7_ADD_CRL 0 +# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 0 +# define PKCS7_F_PKCS7_ADD_SIGNATURE 0 +# define PKCS7_F_PKCS7_ADD_SIGNER 0 +# define PKCS7_F_PKCS7_BIO_ADD_DIGEST 0 +# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 0 +# define PKCS7_F_PKCS7_CTRL 0 +# define PKCS7_F_PKCS7_DATADECODE 0 +# define PKCS7_F_PKCS7_DATAFINAL 0 +# define PKCS7_F_PKCS7_DATAINIT 0 +# define PKCS7_F_PKCS7_DATAVERIFY 0 +# define PKCS7_F_PKCS7_DECRYPT 0 +# define PKCS7_F_PKCS7_DECRYPT_RINFO 0 +# define PKCS7_F_PKCS7_ENCODE_RINFO 0 +# define PKCS7_F_PKCS7_ENCRYPT 0 +# define PKCS7_F_PKCS7_FINAL 0 +# define PKCS7_F_PKCS7_FIND_DIGEST 0 +# define PKCS7_F_PKCS7_GET0_SIGNERS 0 +# define PKCS7_F_PKCS7_RECIP_INFO_SET 0 +# define PKCS7_F_PKCS7_SET_CIPHER 0 +# define PKCS7_F_PKCS7_SET_CONTENT 0 +# define PKCS7_F_PKCS7_SET_DIGEST 0 +# define PKCS7_F_PKCS7_SET_TYPE 0 +# define PKCS7_F_PKCS7_SIGN 0 +# define PKCS7_F_PKCS7_SIGNATUREVERIFY 0 +# define PKCS7_F_PKCS7_SIGNER_INFO_SET 0 +# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 0 +# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 0 +# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 0 +# define PKCS7_F_PKCS7_VERIFY 0 /* * RAND function codes. */ -# define RAND_F_DATA_COLLECT_METHOD 0 -# define RAND_F_DRBG_BYTES 0 -# define RAND_F_DRBG_GET_ENTROPY 0 -# define RAND_F_DRBG_SETUP 0 -# define RAND_F_GET_ENTROPY 0 -# define RAND_F_RAND_BYTES 0 -# define RAND_F_RAND_DRBG_ENABLE_LOCKING 0 -# define RAND_F_RAND_DRBG_GENERATE 0 -# define RAND_F_RAND_DRBG_GET_ENTROPY 0 -# define RAND_F_RAND_DRBG_GET_NONCE 0 -# define RAND_F_RAND_DRBG_INSTANTIATE 0 -# define RAND_F_RAND_DRBG_NEW 0 -# define RAND_F_RAND_DRBG_RESEED 0 -# define RAND_F_RAND_DRBG_RESTART 0 -# define RAND_F_RAND_DRBG_SET 0 -# define RAND_F_RAND_DRBG_SET_DEFAULTS 0 -# define RAND_F_RAND_DRBG_UNINSTANTIATE 0 -# define RAND_F_RAND_LOAD_FILE 0 -# define RAND_F_RAND_POOL_ACQUIRE_ENTROPY 0 -# define RAND_F_RAND_POOL_ADD 0 -# define RAND_F_RAND_POOL_ADD_BEGIN 0 -# define RAND_F_RAND_POOL_ADD_END 0 -# define RAND_F_RAND_POOL_ATTACH 0 -# define RAND_F_RAND_POOL_BYTES_NEEDED 0 -# define RAND_F_RAND_POOL_GROW 0 -# define RAND_F_RAND_POOL_NEW 0 -# define RAND_F_RAND_PSEUDO_BYTES 0 -# define RAND_F_RAND_WRITE_FILE 0 +# define RAND_F_DATA_COLLECT_METHOD 0 +# define RAND_F_DRBG_BYTES 0 +# define RAND_F_DRBG_GET_ENTROPY 0 +# define RAND_F_DRBG_SETUP 0 +# define RAND_F_GET_ENTROPY 0 +# define RAND_F_RAND_BYTES 0 +# define RAND_F_RAND_DRBG_ENABLE_LOCKING 0 +# define RAND_F_RAND_DRBG_GENERATE 0 +# define RAND_F_RAND_DRBG_GET_ENTROPY 0 +# define RAND_F_RAND_DRBG_GET_NONCE 0 +# define RAND_F_RAND_DRBG_INSTANTIATE 0 +# define RAND_F_RAND_DRBG_NEW 0 +# define RAND_F_RAND_DRBG_RESEED 0 +# define RAND_F_RAND_DRBG_RESTART 0 +# define RAND_F_RAND_DRBG_SET 0 +# define RAND_F_RAND_DRBG_SET_DEFAULTS 0 +# define RAND_F_RAND_DRBG_UNINSTANTIATE 0 +# define RAND_F_RAND_LOAD_FILE 0 +# define RAND_F_RAND_POOL_ACQUIRE_ENTROPY 0 +# define RAND_F_RAND_POOL_ADD 0 +# define RAND_F_RAND_POOL_ADD_BEGIN 0 +# define RAND_F_RAND_POOL_ADD_END 0 +# define RAND_F_RAND_POOL_ATTACH 0 +# define RAND_F_RAND_POOL_BYTES_NEEDED 0 +# define RAND_F_RAND_POOL_GROW 0 +# define RAND_F_RAND_POOL_NEW 0 +# define RAND_F_RAND_PSEUDO_BYTES 0 +# define RAND_F_RAND_WRITE_FILE 0 /* * RSA function codes. */ -# define RSA_F_CHECK_PADDING_MD 0 -# define RSA_F_ENCODE_PKCS1 0 -# define RSA_F_INT_RSA_VERIFY 0 -# define RSA_F_OLD_RSA_PRIV_DECODE 0 -# define RSA_F_PKEY_PSS_INIT 0 -# define RSA_F_PKEY_RSA_CTRL 0 -# define RSA_F_PKEY_RSA_CTRL_STR 0 -# define RSA_F_PKEY_RSA_SIGN 0 -# define RSA_F_PKEY_RSA_VERIFY 0 -# define RSA_F_PKEY_RSA_VERIFYRECOVER 0 -# define RSA_F_RSA_ALGOR_TO_MD 0 -# define RSA_F_RSA_BUILTIN_KEYGEN 0 -# define RSA_F_RSA_CHECK_KEY 0 -# define RSA_F_RSA_CHECK_KEY_EX 0 -# define RSA_F_RSA_CMS_DECRYPT 0 -# define RSA_F_RSA_CMS_VERIFY 0 -# define RSA_F_RSA_ITEM_VERIFY 0 -# define RSA_F_RSA_METH_DUP 0 -# define RSA_F_RSA_METH_NEW 0 -# define RSA_F_RSA_METH_SET1_NAME 0 -# define RSA_F_RSA_MGF1_TO_MD 0 -# define RSA_F_RSA_MULTIP_INFO_NEW 0 -# define RSA_F_RSA_NEW_METHOD 0 -# define RSA_F_RSA_NULL 0 -# define RSA_F_RSA_NULL_PRIVATE_DECRYPT 0 -# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 0 -# define RSA_F_RSA_NULL_PUBLIC_DECRYPT 0 -# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 0 -# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 0 -# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 0 -# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 0 -# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 0 -# define RSA_F_RSA_PADDING_ADD_NONE 0 -# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 0 -# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 0 -# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 0 -# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 0 -# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 0 -# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 0 -# define RSA_F_RSA_PADDING_ADD_SSLV23 0 -# define RSA_F_RSA_PADDING_ADD_X931 0 -# define RSA_F_RSA_PADDING_CHECK_NONE 0 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 0 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1 0 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 0 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 0 -# define RSA_F_RSA_PADDING_CHECK_SSLV23 0 -# define RSA_F_RSA_PADDING_CHECK_X931 0 -# define RSA_F_RSA_PARAM_DECODE 0 -# define RSA_F_RSA_PRINT 0 -# define RSA_F_RSA_PRINT_FP 0 -# define RSA_F_RSA_PRIV_DECODE 0 -# define RSA_F_RSA_PRIV_ENCODE 0 -# define RSA_F_RSA_PSS_GET_PARAM 0 -# define RSA_F_RSA_PSS_TO_CTX 0 -# define RSA_F_RSA_PUB_DECODE 0 -# define RSA_F_RSA_SETUP_BLINDING 0 -# define RSA_F_RSA_SIGN 0 -# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 0 -# define RSA_F_RSA_VERIFY 0 -# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 0 -# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 0 -# define RSA_F_SETUP_TBUF 0 +# define RSA_F_CHECK_PADDING_MD 0 +# define RSA_F_ENCODE_PKCS1 0 +# define RSA_F_INT_RSA_VERIFY 0 +# define RSA_F_OLD_RSA_PRIV_DECODE 0 +# define RSA_F_PKEY_PSS_INIT 0 +# define RSA_F_PKEY_RSA_CTRL 0 +# define RSA_F_PKEY_RSA_CTRL_STR 0 +# define RSA_F_PKEY_RSA_SIGN 0 +# define RSA_F_PKEY_RSA_VERIFY 0 +# define RSA_F_PKEY_RSA_VERIFYRECOVER 0 +# define RSA_F_RSA_ALGOR_TO_MD 0 +# define RSA_F_RSA_BUILTIN_KEYGEN 0 +# define RSA_F_RSA_CHECK_KEY 0 +# define RSA_F_RSA_CHECK_KEY_EX 0 +# define RSA_F_RSA_CMS_DECRYPT 0 +# define RSA_F_RSA_CMS_VERIFY 0 +# define RSA_F_RSA_ITEM_VERIFY 0 +# define RSA_F_RSA_METH_DUP 0 +# define RSA_F_RSA_METH_NEW 0 +# define RSA_F_RSA_METH_SET1_NAME 0 +# define RSA_F_RSA_MGF1_TO_MD 0 +# define RSA_F_RSA_MULTIP_INFO_NEW 0 +# define RSA_F_RSA_NEW_METHOD 0 +# define RSA_F_RSA_NULL 0 +# define RSA_F_RSA_NULL_PRIVATE_DECRYPT 0 +# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 0 +# define RSA_F_RSA_NULL_PUBLIC_DECRYPT 0 +# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 0 +# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 0 +# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 0 +# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 0 +# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 0 +# define RSA_F_RSA_PADDING_ADD_NONE 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 0 +# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 0 +# define RSA_F_RSA_PADDING_ADD_SSLV23 0 +# define RSA_F_RSA_PADDING_ADD_X931 0 +# define RSA_F_RSA_PADDING_CHECK_NONE 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 0 +# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 0 +# define RSA_F_RSA_PADDING_CHECK_SSLV23 0 +# define RSA_F_RSA_PADDING_CHECK_X931 0 +# define RSA_F_RSA_PARAM_DECODE 0 +# define RSA_F_RSA_PRINT 0 +# define RSA_F_RSA_PRINT_FP 0 +# define RSA_F_RSA_PRIV_DECODE 0 +# define RSA_F_RSA_PRIV_ENCODE 0 +# define RSA_F_RSA_PSS_GET_PARAM 0 +# define RSA_F_RSA_PSS_TO_CTX 0 +# define RSA_F_RSA_PUB_DECODE 0 +# define RSA_F_RSA_SETUP_BLINDING 0 +# define RSA_F_RSA_SIGN 0 +# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 0 +# define RSA_F_RSA_VERIFY 0 +# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 0 +# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 0 +# define RSA_F_SETUP_TBUF 0 /* * OSSL_STORE function codes. */ -# define OSSL_STORE_F_FILE_CTRL 0 -# define OSSL_STORE_F_FILE_FIND 0 -# define OSSL_STORE_F_FILE_GET_PASS 0 -# define OSSL_STORE_F_FILE_LOAD 0 -# define OSSL_STORE_F_FILE_LOAD_TRY_DECODE 0 -# define OSSL_STORE_F_FILE_NAME_TO_URI 0 -# define OSSL_STORE_F_FILE_OPEN 0 -# define OSSL_STORE_F_OSSL_STORE_ATTACH_PEM_BIO 0 -# define OSSL_STORE_F_OSSL_STORE_EXPECT 0 -# define OSSL_STORE_F_OSSL_STORE_FILE_ATTACH_PEM_BIO_INT 0 -# define OSSL_STORE_F_OSSL_STORE_FIND 0 -# define OSSL_STORE_F_OSSL_STORE_GET0_LOADER_INT 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CERT 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CRL 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME_DESCRIPTION 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PARAMS 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PKEY 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CERT 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CRL 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_EMBEDDED 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_NAME 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PARAMS 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PKEY 0 -# define OSSL_STORE_F_OSSL_STORE_INFO_SET0_NAME_DESCRIPTION 0 -# define OSSL_STORE_F_OSSL_STORE_INIT_ONCE 0 -# define OSSL_STORE_F_OSSL_STORE_LOADER_NEW 0 -# define OSSL_STORE_F_OSSL_STORE_OPEN 0 -# define OSSL_STORE_F_OSSL_STORE_OPEN_INT 0 -# define OSSL_STORE_F_OSSL_STORE_REGISTER_LOADER_INT 0 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ALIAS 0 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ISSUER_SERIAL 0 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 0 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_NAME 0 -# define OSSL_STORE_F_OSSL_STORE_UNREGISTER_LOADER_INT 0 -# define OSSL_STORE_F_TRY_DECODE_PARAMS 0 -# define OSSL_STORE_F_TRY_DECODE_PKCS12 0 -# define OSSL_STORE_F_TRY_DECODE_PKCS8ENCRYPTED 0 +# define OSSL_STORE_F_FILE_CTRL 0 +# define OSSL_STORE_F_FILE_FIND 0 +# define OSSL_STORE_F_FILE_GET_PASS 0 +# define OSSL_STORE_F_FILE_LOAD 0 +# define OSSL_STORE_F_FILE_LOAD_TRY_DECODE 0 +# define OSSL_STORE_F_FILE_NAME_TO_URI 0 +# define OSSL_STORE_F_FILE_OPEN 0 +# define OSSL_STORE_F_OSSL_STORE_ATTACH_PEM_BIO 0 +# define OSSL_STORE_F_OSSL_STORE_EXPECT 0 +# define OSSL_STORE_F_OSSL_STORE_FILE_ATTACH_PEM_BIO_INT 0 +# define OSSL_STORE_F_OSSL_STORE_FIND 0 +# define OSSL_STORE_F_OSSL_STORE_GET0_LOADER_INT 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CERT 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CRL 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME_DESCRIPTION 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PARAMS 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PKEY 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CERT 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CRL 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_EMBEDDED 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_NAME 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PARAMS 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PKEY 0 +# define OSSL_STORE_F_OSSL_STORE_INFO_SET0_NAME_DESCRIPTION 0 +# define OSSL_STORE_F_OSSL_STORE_INIT_ONCE 0 +# define OSSL_STORE_F_OSSL_STORE_LOADER_NEW 0 +# define OSSL_STORE_F_OSSL_STORE_OPEN 0 +# define OSSL_STORE_F_OSSL_STORE_OPEN_INT 0 +# define OSSL_STORE_F_OSSL_STORE_REGISTER_LOADER_INT 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ALIAS 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ISSUER_SERIAL 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 0 +# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_NAME 0 +# define OSSL_STORE_F_OSSL_STORE_UNREGISTER_LOADER_INT 0 +# define OSSL_STORE_F_TRY_DECODE_PARAMS 0 +# define OSSL_STORE_F_TRY_DECODE_PKCS12 0 +# define OSSL_STORE_F_TRY_DECODE_PKCS8ENCRYPTED 0 -# ifndef OPENSSL_NO_TS +# ifndef OPENSSL_NO_TS /* * TS function codes. */ -# define TS_F_DEF_SERIAL_CB 0 -# define TS_F_DEF_TIME_CB 0 -# define TS_F_ESS_ADD_SIGNING_CERT 0 -# define TS_F_ESS_ADD_SIGNING_CERT_V2 0 -# define TS_F_ESS_CERT_ID_NEW_INIT 0 -# define TS_F_ESS_CERT_ID_V2_NEW_INIT 0 -# define TS_F_ESS_SIGNING_CERT_NEW_INIT 0 -# define TS_F_ESS_SIGNING_CERT_V2_NEW_INIT 0 -# define TS_F_INT_TS_RESP_VERIFY_TOKEN 0 -# define TS_F_PKCS7_TO_TS_TST_INFO 0 -# define TS_F_TS_ACCURACY_SET_MICROS 0 -# define TS_F_TS_ACCURACY_SET_MILLIS 0 -# define TS_F_TS_ACCURACY_SET_SECONDS 0 -# define TS_F_TS_CHECK_IMPRINTS 0 -# define TS_F_TS_CHECK_NONCES 0 -# define TS_F_TS_CHECK_POLICY 0 -# define TS_F_TS_CHECK_SIGNING_CERTS 0 -# define TS_F_TS_CHECK_STATUS_INFO 0 -# define TS_F_TS_COMPUTE_IMPRINT 0 -# define TS_F_TS_CONF_INVALID 0 -# define TS_F_TS_CONF_LOAD_CERT 0 -# define TS_F_TS_CONF_LOAD_CERTS 0 -# define TS_F_TS_CONF_LOAD_KEY 0 -# define TS_F_TS_CONF_LOOKUP_FAIL 0 -# define TS_F_TS_CONF_SET_DEFAULT_ENGINE 0 -# define TS_F_TS_GET_STATUS_TEXT 0 -# define TS_F_TS_MSG_IMPRINT_SET_ALGO 0 -# define TS_F_TS_REQ_SET_MSG_IMPRINT 0 -# define TS_F_TS_REQ_SET_NONCE 0 -# define TS_F_TS_REQ_SET_POLICY_ID 0 -# define TS_F_TS_RESP_CREATE_RESPONSE 0 -# define TS_F_TS_RESP_CREATE_TST_INFO 0 -# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO 0 -# define TS_F_TS_RESP_CTX_ADD_MD 0 -# define TS_F_TS_RESP_CTX_ADD_POLICY 0 -# define TS_F_TS_RESP_CTX_NEW 0 -# define TS_F_TS_RESP_CTX_SET_ACCURACY 0 -# define TS_F_TS_RESP_CTX_SET_CERTS 0 -# define TS_F_TS_RESP_CTX_SET_DEF_POLICY 0 -# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT 0 -# define TS_F_TS_RESP_CTX_SET_STATUS_INFO 0 -# define TS_F_TS_RESP_GET_POLICY 0 -# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION 0 -# define TS_F_TS_RESP_SET_STATUS_INFO 0 -# define TS_F_TS_RESP_SET_TST_INFO 0 -# define TS_F_TS_RESP_SIGN 0 -# define TS_F_TS_RESP_VERIFY_SIGNATURE 0 -# define TS_F_TS_TST_INFO_SET_ACCURACY 0 -# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT 0 -# define TS_F_TS_TST_INFO_SET_NONCE 0 -# define TS_F_TS_TST_INFO_SET_POLICY_ID 0 -# define TS_F_TS_TST_INFO_SET_SERIAL 0 -# define TS_F_TS_TST_INFO_SET_TIME 0 -# define TS_F_TS_TST_INFO_SET_TSA 0 -# define TS_F_TS_VERIFY 0 -# define TS_F_TS_VERIFY_CERT 0 -# define TS_F_TS_VERIFY_CTX_NEW 0 -# endif +# define TS_F_DEF_SERIAL_CB 0 +# define TS_F_DEF_TIME_CB 0 +# define TS_F_ESS_ADD_SIGNING_CERT 0 +# define TS_F_ESS_ADD_SIGNING_CERT_V2 0 +# define TS_F_ESS_CERT_ID_NEW_INIT 0 +# define TS_F_ESS_CERT_ID_V2_NEW_INIT 0 +# define TS_F_ESS_SIGNING_CERT_NEW_INIT 0 +# define TS_F_ESS_SIGNING_CERT_V2_NEW_INIT 0 +# define TS_F_INT_TS_RESP_VERIFY_TOKEN 0 +# define TS_F_PKCS7_TO_TS_TST_INFO 0 +# define TS_F_TS_ACCURACY_SET_MICROS 0 +# define TS_F_TS_ACCURACY_SET_MILLIS 0 +# define TS_F_TS_ACCURACY_SET_SECONDS 0 +# define TS_F_TS_CHECK_IMPRINTS 0 +# define TS_F_TS_CHECK_NONCES 0 +# define TS_F_TS_CHECK_POLICY 0 +# define TS_F_TS_CHECK_SIGNING_CERTS 0 +# define TS_F_TS_CHECK_STATUS_INFO 0 +# define TS_F_TS_COMPUTE_IMPRINT 0 +# define TS_F_TS_CONF_INVALID 0 +# define TS_F_TS_CONF_LOAD_CERT 0 +# define TS_F_TS_CONF_LOAD_CERTS 0 +# define TS_F_TS_CONF_LOAD_KEY 0 +# define TS_F_TS_CONF_LOOKUP_FAIL 0 +# define TS_F_TS_CONF_SET_DEFAULT_ENGINE 0 +# define TS_F_TS_GET_STATUS_TEXT 0 +# define TS_F_TS_MSG_IMPRINT_SET_ALGO 0 +# define TS_F_TS_REQ_SET_MSG_IMPRINT 0 +# define TS_F_TS_REQ_SET_NONCE 0 +# define TS_F_TS_REQ_SET_POLICY_ID 0 +# define TS_F_TS_RESP_CREATE_RESPONSE 0 +# define TS_F_TS_RESP_CREATE_TST_INFO 0 +# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO 0 +# define TS_F_TS_RESP_CTX_ADD_MD 0 +# define TS_F_TS_RESP_CTX_ADD_POLICY 0 +# define TS_F_TS_RESP_CTX_NEW 0 +# define TS_F_TS_RESP_CTX_SET_ACCURACY 0 +# define TS_F_TS_RESP_CTX_SET_CERTS 0 +# define TS_F_TS_RESP_CTX_SET_DEF_POLICY 0 +# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT 0 +# define TS_F_TS_RESP_CTX_SET_STATUS_INFO 0 +# define TS_F_TS_RESP_GET_POLICY 0 +# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION 0 +# define TS_F_TS_RESP_SET_STATUS_INFO 0 +# define TS_F_TS_RESP_SET_TST_INFO 0 +# define TS_F_TS_RESP_SIGN 0 +# define TS_F_TS_RESP_VERIFY_SIGNATURE 0 +# define TS_F_TS_TST_INFO_SET_ACCURACY 0 +# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT 0 +# define TS_F_TS_TST_INFO_SET_NONCE 0 +# define TS_F_TS_TST_INFO_SET_POLICY_ID 0 +# define TS_F_TS_TST_INFO_SET_SERIAL 0 +# define TS_F_TS_TST_INFO_SET_TIME 0 +# define TS_F_TS_TST_INFO_SET_TSA 0 +# define TS_F_TS_VERIFY 0 +# define TS_F_TS_VERIFY_CERT 0 +# define TS_F_TS_VERIFY_CTX_NEW 0 +# endif /* * UI function codes. */ -# define UI_F_CLOSE_CONSOLE 0 -# define UI_F_ECHO_CONSOLE 0 -# define UI_F_GENERAL_ALLOCATE_BOOLEAN 0 -# define UI_F_GENERAL_ALLOCATE_PROMPT 0 -# define UI_F_NOECHO_CONSOLE 0 -# define UI_F_OPEN_CONSOLE 0 -# define UI_F_UI_CONSTRUCT_PROMPT 0 -# define UI_F_UI_CREATE_METHOD 0 -# define UI_F_UI_CTRL 0 -# define UI_F_UI_DUP_ERROR_STRING 0 -# define UI_F_UI_DUP_INFO_STRING 0 -# define UI_F_UI_DUP_INPUT_BOOLEAN 0 -# define UI_F_UI_DUP_INPUT_STRING 0 -# define UI_F_UI_DUP_USER_DATA 0 -# define UI_F_UI_DUP_VERIFY_STRING 0 -# define UI_F_UI_GET0_RESULT 0 -# define UI_F_UI_GET_RESULT_LENGTH 0 -# define UI_F_UI_NEW_METHOD 0 -# define UI_F_UI_PROCESS 0 -# define UI_F_UI_SET_RESULT 0 -# define UI_F_UI_SET_RESULT_EX 0 +# define UI_F_CLOSE_CONSOLE 0 +# define UI_F_ECHO_CONSOLE 0 +# define UI_F_GENERAL_ALLOCATE_BOOLEAN 0 +# define UI_F_GENERAL_ALLOCATE_PROMPT 0 +# define UI_F_NOECHO_CONSOLE 0 +# define UI_F_OPEN_CONSOLE 0 +# define UI_F_UI_CONSTRUCT_PROMPT 0 +# define UI_F_UI_CREATE_METHOD 0 +# define UI_F_UI_CTRL 0 +# define UI_F_UI_DUP_ERROR_STRING 0 +# define UI_F_UI_DUP_INFO_STRING 0 +# define UI_F_UI_DUP_INPUT_BOOLEAN 0 +# define UI_F_UI_DUP_INPUT_STRING 0 +# define UI_F_UI_DUP_USER_DATA 0 +# define UI_F_UI_DUP_VERIFY_STRING 0 +# define UI_F_UI_GET0_RESULT 0 +# define UI_F_UI_GET_RESULT_LENGTH 0 +# define UI_F_UI_NEW_METHOD 0 +# define UI_F_UI_PROCESS 0 +# define UI_F_UI_SET_RESULT 0 +# define UI_F_UI_SET_RESULT_EX 0 /* * X509 function codes. */ -# define X509_F_ADD_CERT_DIR 0 -# define X509_F_BUILD_CHAIN 0 -# define X509_F_BY_FILE_CTRL 0 -# define X509_F_CHECK_NAME_CONSTRAINTS 0 -# define X509_F_CHECK_POLICY 0 -# define X509_F_DANE_I2D 0 -# define X509_F_DIR_CTRL 0 -# define X509_F_GET_CERT_BY_SUBJECT 0 -# define X509_F_I2D_X509_AUX 0 -# define X509_F_LOOKUP_CERTS_SK 0 -# define X509_F_NETSCAPE_SPKI_B64_DECODE 0 -# define X509_F_NETSCAPE_SPKI_B64_ENCODE 0 -# define X509_F_NEW_DIR 0 -# define X509_F_X509AT_ADD1_ATTR 0 -# define X509_F_X509V3_ADD_EXT 0 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 0 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 0 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 0 -# define X509_F_X509_ATTRIBUTE_GET0_DATA 0 -# define X509_F_X509_ATTRIBUTE_SET1_DATA 0 -# define X509_F_X509_CHECK_PRIVATE_KEY 0 -# define X509_F_X509_CRL_DIFF 0 -# define X509_F_X509_CRL_METHOD_NEW 0 -# define X509_F_X509_CRL_PRINT_FP 0 -# define X509_F_X509_EXTENSION_CREATE_BY_NID 0 -# define X509_F_X509_EXTENSION_CREATE_BY_OBJ 0 -# define X509_F_X509_GET_PUBKEY_PARAMETERS 0 -# define X509_F_X509_LOAD_CERT_CRL_FILE 0 -# define X509_F_X509_LOAD_CERT_FILE 0 -# define X509_F_X509_LOAD_CRL_FILE 0 -# define X509_F_X509_LOOKUP_METH_NEW 0 -# define X509_F_X509_LOOKUP_NEW 0 -# define X509_F_X509_NAME_ADD_ENTRY 0 -# define X509_F_X509_NAME_CANON 0 -# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 0 -# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 0 -# define X509_F_X509_NAME_ENTRY_SET_OBJECT 0 -# define X509_F_X509_NAME_ONELINE 0 -# define X509_F_X509_NAME_PRINT 0 -# define X509_F_X509_OBJECT_NEW 0 -# define X509_F_X509_PRINT_EX_FP 0 -# define X509_F_X509_PUBKEY_DECODE 0 -# define X509_F_X509_PUBKEY_GET 0 -# define X509_F_X509_PUBKEY_GET0 0 -# define X509_F_X509_PUBKEY_SET 0 -# define X509_F_X509_REQ_CHECK_PRIVATE_KEY 0 -# define X509_F_X509_REQ_PRINT_EX 0 -# define X509_F_X509_REQ_PRINT_FP 0 -# define X509_F_X509_REQ_TO_X509 0 -# define X509_F_X509_STORE_ADD_CERT 0 -# define X509_F_X509_STORE_ADD_CRL 0 -# define X509_F_X509_STORE_ADD_LOOKUP 0 -# define X509_F_X509_STORE_CTX_GET1_ISSUER 0 -# define X509_F_X509_STORE_CTX_INIT 0 -# define X509_F_X509_STORE_CTX_NEW 0 -# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 0 -# define X509_F_X509_STORE_NEW 0 -# define X509_F_X509_TO_X509_REQ 0 -# define X509_F_X509_TRUST_ADD 0 -# define X509_F_X509_TRUST_SET 0 -# define X509_F_X509_VERIFY_CERT 0 -# define X509_F_X509_VERIFY_PARAM_NEW 0 +# define X509_F_ADD_CERT_DIR 0 +# define X509_F_BUILD_CHAIN 0 +# define X509_F_BY_FILE_CTRL 0 +# define X509_F_CHECK_NAME_CONSTRAINTS 0 +# define X509_F_CHECK_POLICY 0 +# define X509_F_DANE_I2D 0 +# define X509_F_DIR_CTRL 0 +# define X509_F_GET_CERT_BY_SUBJECT 0 +# define X509_F_I2D_X509_AUX 0 +# define X509_F_LOOKUP_CERTS_SK 0 +# define X509_F_NETSCAPE_SPKI_B64_DECODE 0 +# define X509_F_NETSCAPE_SPKI_B64_ENCODE 0 +# define X509_F_NEW_DIR 0 +# define X509_F_X509AT_ADD1_ATTR 0 +# define X509_F_X509V3_ADD_EXT 0 +# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 0 +# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 0 +# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 0 +# define X509_F_X509_ATTRIBUTE_GET0_DATA 0 +# define X509_F_X509_ATTRIBUTE_SET1_DATA 0 +# define X509_F_X509_CHECK_PRIVATE_KEY 0 +# define X509_F_X509_CRL_DIFF 0 +# define X509_F_X509_CRL_METHOD_NEW 0 +# define X509_F_X509_CRL_PRINT_FP 0 +# define X509_F_X509_EXTENSION_CREATE_BY_NID 0 +# define X509_F_X509_EXTENSION_CREATE_BY_OBJ 0 +# define X509_F_X509_GET_PUBKEY_PARAMETERS 0 +# define X509_F_X509_LOAD_CERT_CRL_FILE 0 +# define X509_F_X509_LOAD_CERT_FILE 0 +# define X509_F_X509_LOAD_CRL_FILE 0 +# define X509_F_X509_LOOKUP_METH_NEW 0 +# define X509_F_X509_LOOKUP_NEW 0 +# define X509_F_X509_NAME_ADD_ENTRY 0 +# define X509_F_X509_NAME_CANON 0 +# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 0 +# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 0 +# define X509_F_X509_NAME_ENTRY_SET_OBJECT 0 +# define X509_F_X509_NAME_ONELINE 0 +# define X509_F_X509_NAME_PRINT 0 +# define X509_F_X509_OBJECT_NEW 0 +# define X509_F_X509_PRINT_EX_FP 0 +# define X509_F_X509_PUBKEY_DECODE 0 +# define X509_F_X509_PUBKEY_GET 0 +# define X509_F_X509_PUBKEY_GET0 0 +# define X509_F_X509_PUBKEY_SET 0 +# define X509_F_X509_REQ_CHECK_PRIVATE_KEY 0 +# define X509_F_X509_REQ_PRINT_EX 0 +# define X509_F_X509_REQ_PRINT_FP 0 +# define X509_F_X509_REQ_TO_X509 0 +# define X509_F_X509_STORE_ADD_CERT 0 +# define X509_F_X509_STORE_ADD_CRL 0 +# define X509_F_X509_STORE_ADD_LOOKUP 0 +# define X509_F_X509_STORE_CTX_GET1_ISSUER 0 +# define X509_F_X509_STORE_CTX_INIT 0 +# define X509_F_X509_STORE_CTX_NEW 0 +# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 0 +# define X509_F_X509_STORE_NEW 0 +# define X509_F_X509_TO_X509_REQ 0 +# define X509_F_X509_TRUST_ADD 0 +# define X509_F_X509_TRUST_SET 0 +# define X509_F_X509_VERIFY_CERT 0 +# define X509_F_X509_VERIFY_PARAM_NEW 0 /* * X509V3 function codes. */ -# define X509V3_F_A2I_GENERAL_NAME 0 -# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 0 -# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 0 -# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 0 -# define X509V3_F_BIGNUM_TO_STRING 0 -# define X509V3_F_COPY_EMAIL 0 -# define X509V3_F_COPY_ISSUER 0 -# define X509V3_F_DO_DIRNAME 0 -# define X509V3_F_DO_EXT_I2D 0 -# define X509V3_F_DO_EXT_NCONF 0 -# define X509V3_F_GNAMES_FROM_SECTNAME 0 -# define X509V3_F_I2S_ASN1_ENUMERATED 0 -# define X509V3_F_I2S_ASN1_IA5STRING 0 -# define X509V3_F_I2S_ASN1_INTEGER 0 -# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 0 -# define X509V3_F_LEVEL_ADD_NODE 0 -# define X509V3_F_NOTICE_SECTION 0 -# define X509V3_F_NREF_NOS 0 -# define X509V3_F_POLICY_CACHE_CREATE 0 -# define X509V3_F_POLICY_CACHE_NEW 0 -# define X509V3_F_POLICY_DATA_NEW 0 -# define X509V3_F_POLICY_SECTION 0 -# define X509V3_F_PROCESS_PCI_VALUE 0 -# define X509V3_F_R2I_CERTPOL 0 -# define X509V3_F_R2I_PCI 0 -# define X509V3_F_S2I_ASN1_IA5STRING 0 -# define X509V3_F_S2I_ASN1_INTEGER 0 -# define X509V3_F_S2I_ASN1_OCTET_STRING 0 -# define X509V3_F_S2I_SKEY_ID 0 -# define X509V3_F_SET_DIST_POINT_NAME 0 -# define X509V3_F_SXNET_ADD_ID_ASC 0 -# define X509V3_F_SXNET_ADD_ID_INTEGER 0 -# define X509V3_F_SXNET_ADD_ID_ULONG 0 -# define X509V3_F_SXNET_GET_ID_ASC 0 -# define X509V3_F_SXNET_GET_ID_ULONG 0 -# define X509V3_F_TREE_INIT 0 -# define X509V3_F_V2I_ASIDENTIFIERS 0 -# define X509V3_F_V2I_ASN1_BIT_STRING 0 -# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 0 -# define X509V3_F_V2I_AUTHORITY_KEYID 0 -# define X509V3_F_V2I_BASIC_CONSTRAINTS 0 -# define X509V3_F_V2I_CRLD 0 -# define X509V3_F_V2I_EXTENDED_KEY_USAGE 0 -# define X509V3_F_V2I_GENERAL_NAMES 0 -# define X509V3_F_V2I_GENERAL_NAME_EX 0 -# define X509V3_F_V2I_IDP 0 -# define X509V3_F_V2I_IPADDRBLOCKS 0 -# define X509V3_F_V2I_ISSUER_ALT 0 -# define X509V3_F_V2I_NAME_CONSTRAINTS 0 -# define X509V3_F_V2I_POLICY_CONSTRAINTS 0 -# define X509V3_F_V2I_POLICY_MAPPINGS 0 -# define X509V3_F_V2I_SUBJECT_ALT 0 -# define X509V3_F_V2I_TLS_FEATURE 0 -# define X509V3_F_V3_GENERIC_EXTENSION 0 -# define X509V3_F_X509V3_ADD1_I2D 0 -# define X509V3_F_X509V3_ADD_VALUE 0 -# define X509V3_F_X509V3_EXT_ADD 0 -# define X509V3_F_X509V3_EXT_ADD_ALIAS 0 -# define X509V3_F_X509V3_EXT_I2D 0 -# define X509V3_F_X509V3_EXT_NCONF 0 -# define X509V3_F_X509V3_GET_SECTION 0 -# define X509V3_F_X509V3_GET_STRING 0 -# define X509V3_F_X509V3_GET_VALUE_BOOL 0 -# define X509V3_F_X509V3_PARSE_LIST 0 -# define X509V3_F_X509_PURPOSE_ADD 0 -# define X509V3_F_X509_PURPOSE_SET 0 +# define X509V3_F_A2I_GENERAL_NAME 0 +# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 0 +# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 0 +# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 0 +# define X509V3_F_BIGNUM_TO_STRING 0 +# define X509V3_F_COPY_EMAIL 0 +# define X509V3_F_COPY_ISSUER 0 +# define X509V3_F_DO_DIRNAME 0 +# define X509V3_F_DO_EXT_I2D 0 +# define X509V3_F_DO_EXT_NCONF 0 +# define X509V3_F_GNAMES_FROM_SECTNAME 0 +# define X509V3_F_I2S_ASN1_ENUMERATED 0 +# define X509V3_F_I2S_ASN1_IA5STRING 0 +# define X509V3_F_I2S_ASN1_INTEGER 0 +# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 0 +# define X509V3_F_LEVEL_ADD_NODE 0 +# define X509V3_F_NOTICE_SECTION 0 +# define X509V3_F_NREF_NOS 0 +# define X509V3_F_POLICY_CACHE_CREATE 0 +# define X509V3_F_POLICY_CACHE_NEW 0 +# define X509V3_F_POLICY_DATA_NEW 0 +# define X509V3_F_POLICY_SECTION 0 +# define X509V3_F_PROCESS_PCI_VALUE 0 +# define X509V3_F_R2I_CERTPOL 0 +# define X509V3_F_R2I_PCI 0 +# define X509V3_F_S2I_ASN1_IA5STRING 0 +# define X509V3_F_S2I_ASN1_INTEGER 0 +# define X509V3_F_S2I_ASN1_OCTET_STRING 0 +# define X509V3_F_S2I_SKEY_ID 0 +# define X509V3_F_SET_DIST_POINT_NAME 0 +# define X509V3_F_SXNET_ADD_ID_ASC 0 +# define X509V3_F_SXNET_ADD_ID_INTEGER 0 +# define X509V3_F_SXNET_ADD_ID_ULONG 0 +# define X509V3_F_SXNET_GET_ID_ASC 0 +# define X509V3_F_SXNET_GET_ID_ULONG 0 +# define X509V3_F_TREE_INIT 0 +# define X509V3_F_V2I_ASIDENTIFIERS 0 +# define X509V3_F_V2I_ASN1_BIT_STRING 0 +# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 0 +# define X509V3_F_V2I_AUTHORITY_KEYID 0 +# define X509V3_F_V2I_BASIC_CONSTRAINTS 0 +# define X509V3_F_V2I_CRLD 0 +# define X509V3_F_V2I_EXTENDED_KEY_USAGE 0 +# define X509V3_F_V2I_GENERAL_NAMES 0 +# define X509V3_F_V2I_GENERAL_NAME_EX 0 +# define X509V3_F_V2I_IDP 0 +# define X509V3_F_V2I_IPADDRBLOCKS 0 +# define X509V3_F_V2I_ISSUER_ALT 0 +# define X509V3_F_V2I_NAME_CONSTRAINTS 0 +# define X509V3_F_V2I_POLICY_CONSTRAINTS 0 +# define X509V3_F_V2I_POLICY_MAPPINGS 0 +# define X509V3_F_V2I_SUBJECT_ALT 0 +# define X509V3_F_V2I_TLS_FEATURE 0 +# define X509V3_F_V3_GENERIC_EXTENSION 0 +# define X509V3_F_X509V3_ADD1_I2D 0 +# define X509V3_F_X509V3_ADD_VALUE 0 +# define X509V3_F_X509V3_EXT_ADD 0 +# define X509V3_F_X509V3_EXT_ADD_ALIAS 0 +# define X509V3_F_X509V3_EXT_I2D 0 +# define X509V3_F_X509V3_EXT_NCONF 0 +# define X509V3_F_X509V3_GET_SECTION 0 +# define X509V3_F_X509V3_GET_STRING 0 +# define X509V3_F_X509V3_GET_VALUE_BOOL 0 +# define X509V3_F_X509V3_PARSE_LIST 0 +# define X509V3_F_X509_PURPOSE_ADD 0 +# define X509V3_F_X509_PURPOSE_SET 0 /* * Compatibility defines. */ -# define EVP_R_OPERATON_NOT_INITIALIZED EVP_R_OPERATION_NOT_INITIALIZED +# define EVP_R_OPERATON_NOT_INITIALIZED EVP_R_OPERATION_NOT_INITIALIZED #endif diff --git a/libs/OpenSSL/include/openssl/ct.h b/libs/OpenSSL/include/openssl/ct.h index 71fc2fb2..0a54fc8b 100644 --- a/libs/OpenSSL/include/openssl/ct.h +++ b/libs/OpenSSL/include/openssl/ct.h @@ -16,140 +16,166 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_CT_H +# define HEADER_CT_H #endif #include #ifndef OPENSSL_NO_CT -# include -# include -# include -# include -# ifdef __cplusplus +# include +# include +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif /* Minimum RSA key size, from RFC6962 */ -# define SCT_MIN_RSA_BITS 2048 +# define SCT_MIN_RSA_BITS 2048 /* All hashes are SHA256 in v1 of Certificate Transparency */ -# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH +# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH SKM_DEFINE_STACK_OF_INTERNAL(SCT, SCT, SCT) -# define sk_SCT_num(sk) OPENSSL_sk_num(ossl_check_const_SCT_sk_type(sk)) -# define sk_SCT_value(sk, idx) ((SCT *)OPENSSL_sk_value(ossl_check_const_SCT_sk_type(sk), (idx))) -# define sk_SCT_new(cmp) ((STACK_OF(SCT) *)OPENSSL_sk_new(ossl_check_SCT_compfunc_type(cmp))) -# define sk_SCT_new_null() ((STACK_OF(SCT) *)OPENSSL_sk_new_null()) -# define sk_SCT_new_reserve(cmp, n) \ - ((STACK_OF(SCT) *)OPENSSL_sk_new_reserve(ossl_check_SCT_compfunc_type(cmp), (n))) -# define sk_SCT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SCT_sk_type(sk), (n)) -# define sk_SCT_free(sk) OPENSSL_sk_free(ossl_check_SCT_sk_type(sk)) -# define sk_SCT_zero(sk) OPENSSL_sk_zero(ossl_check_SCT_sk_type(sk)) -# define sk_SCT_delete(sk, i) ((SCT *)OPENSSL_sk_delete(ossl_check_SCT_sk_type(sk), (i))) -# define sk_SCT_delete_ptr(sk, ptr) \ - ((SCT *)OPENSSL_sk_delete_ptr(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr))) -# define sk_SCT_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) -# define sk_SCT_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) -# define sk_SCT_pop(sk) ((SCT *)OPENSSL_sk_pop(ossl_check_SCT_sk_type(sk))) -# define sk_SCT_shift(sk) ((SCT *)OPENSSL_sk_shift(ossl_check_SCT_sk_type(sk))) -# define sk_SCT_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SCT_sk_type(sk), ossl_check_SCT_freefunc_type(freefunc)) -# define sk_SCT_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), (idx)) -# define sk_SCT_set(sk, idx, ptr) \ - ((SCT *)OPENSSL_sk_set(ossl_check_SCT_sk_type(sk), (idx), ossl_check_SCT_type(ptr))) -# define sk_SCT_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) -# define sk_SCT_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) -# define sk_SCT_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), pnum) -# define sk_SCT_sort(sk) OPENSSL_sk_sort(ossl_check_SCT_sk_type(sk)) -# define sk_SCT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SCT_sk_type(sk)) -# define sk_SCT_dup(sk) ((STACK_OF(SCT) *)OPENSSL_sk_dup(ossl_check_const_SCT_sk_type(sk))) -# define sk_SCT_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SCT) *)OPENSSL_sk_deep_copy(ossl_check_const_SCT_sk_type(sk), \ - ossl_check_SCT_copyfunc_type(copyfunc), \ - ossl_check_SCT_freefunc_type(freefunc))) -# define sk_SCT_set_cmp_func(sk, cmp) \ - ((sk_SCT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SCT_sk_type(sk), \ - ossl_check_SCT_compfunc_type(cmp))) +# define sk_SCT_num(sk) OPENSSL_sk_num(ossl_check_const_SCT_sk_type(sk)) +# define sk_SCT_value(sk, idx) \ + ((SCT *)OPENSSL_sk_value(ossl_check_const_SCT_sk_type(sk), (idx))) +# define sk_SCT_new(cmp) \ + ((STACK_OF(SCT) *)OPENSSL_sk_new(ossl_check_SCT_compfunc_type(cmp))) +# define sk_SCT_new_null() ((STACK_OF(SCT) *)OPENSSL_sk_new_null()) +# define sk_SCT_new_reserve(cmp, n) \ + ((STACK_OF(SCT) *)OPENSSL_sk_new_reserve( \ + ossl_check_SCT_compfunc_type(cmp), (n))) +# define sk_SCT_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SCT_sk_type(sk), (n)) +# define sk_SCT_free(sk) OPENSSL_sk_free(ossl_check_SCT_sk_type(sk)) +# define sk_SCT_zero(sk) OPENSSL_sk_zero(ossl_check_SCT_sk_type(sk)) +# define sk_SCT_delete(sk, i) \ + ((SCT *)OPENSSL_sk_delete(ossl_check_SCT_sk_type(sk), (i))) +# define sk_SCT_delete_ptr(sk, ptr) \ + ((SCT *)OPENSSL_sk_delete_ptr(ossl_check_SCT_sk_type(sk), \ + ossl_check_SCT_type(ptr))) +# define sk_SCT_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +# define sk_SCT_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +# define sk_SCT_pop(sk) ((SCT *)OPENSSL_sk_pop(ossl_check_SCT_sk_type(sk))) +# define sk_SCT_shift(sk) ((SCT *)OPENSSL_sk_shift(ossl_check_SCT_sk_type(sk))) +# define sk_SCT_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SCT_sk_type(sk), \ + ossl_check_SCT_freefunc_type(freefunc)) +# define sk_SCT_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), \ + (idx)) +# define sk_SCT_set(sk, idx, ptr) \ + ((SCT *)OPENSSL_sk_set(ossl_check_SCT_sk_type(sk), (idx), \ + ossl_check_SCT_type(ptr))) +# define sk_SCT_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +# define sk_SCT_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)) +# define sk_SCT_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), \ + pnum) +# define sk_SCT_sort(sk) OPENSSL_sk_sort(ossl_check_SCT_sk_type(sk)) +# define sk_SCT_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SCT_sk_type(sk)) +# define sk_SCT_dup(sk) \ + ((STACK_OF(SCT) *)OPENSSL_sk_dup(ossl_check_const_SCT_sk_type(sk))) +# define sk_SCT_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SCT) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SCT_sk_type(sk), \ + ossl_check_SCT_copyfunc_type(copyfunc), \ + ossl_check_SCT_freefunc_type(freefunc))) +# define sk_SCT_set_cmp_func(sk, cmp) \ + ((sk_SCT_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SCT_sk_type(sk), ossl_check_SCT_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(CTLOG, CTLOG, CTLOG) -# define sk_CTLOG_num(sk) OPENSSL_sk_num(ossl_check_const_CTLOG_sk_type(sk)) -# define sk_CTLOG_value(sk, idx) \ - ((CTLOG *)OPENSSL_sk_value(ossl_check_const_CTLOG_sk_type(sk), (idx))) -# define sk_CTLOG_new(cmp) \ - ((STACK_OF(CTLOG) *)OPENSSL_sk_new(ossl_check_CTLOG_compfunc_type(cmp))) -# define sk_CTLOG_new_null() ((STACK_OF(CTLOG) *)OPENSSL_sk_new_null()) -# define sk_CTLOG_new_reserve(cmp, n) \ - ((STACK_OF(CTLOG) *)OPENSSL_sk_new_reserve(ossl_check_CTLOG_compfunc_type(cmp), (n))) -# define sk_CTLOG_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CTLOG_sk_type(sk), (n)) -# define sk_CTLOG_free(sk) OPENSSL_sk_free(ossl_check_CTLOG_sk_type(sk)) -# define sk_CTLOG_zero(sk) OPENSSL_sk_zero(ossl_check_CTLOG_sk_type(sk)) -# define sk_CTLOG_delete(sk, i) ((CTLOG *)OPENSSL_sk_delete(ossl_check_CTLOG_sk_type(sk), (i))) -# define sk_CTLOG_delete_ptr(sk, ptr) \ - ((CTLOG *)OPENSSL_sk_delete_ptr(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr))) -# define sk_CTLOG_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) -# define sk_CTLOG_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) -# define sk_CTLOG_pop(sk) ((CTLOG *)OPENSSL_sk_pop(ossl_check_CTLOG_sk_type(sk))) -# define sk_CTLOG_shift(sk) ((CTLOG *)OPENSSL_sk_shift(ossl_check_CTLOG_sk_type(sk))) -# define sk_CTLOG_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_freefunc_type(freefunc)) -# define sk_CTLOG_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr), (idx)) -# define sk_CTLOG_set(sk, idx, ptr) \ - ((CTLOG *)OPENSSL_sk_set(ossl_check_CTLOG_sk_type(sk), (idx), ossl_check_CTLOG_type(ptr))) -# define sk_CTLOG_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) -# define sk_CTLOG_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) -# define sk_CTLOG_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr), pnum) -# define sk_CTLOG_sort(sk) OPENSSL_sk_sort(ossl_check_CTLOG_sk_type(sk)) -# define sk_CTLOG_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CTLOG_sk_type(sk)) -# define sk_CTLOG_dup(sk) ((STACK_OF(CTLOG) *)OPENSSL_sk_dup(ossl_check_const_CTLOG_sk_type(sk))) -# define sk_CTLOG_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(CTLOG) *)OPENSSL_sk_deep_copy(ossl_check_const_CTLOG_sk_type(sk), \ - ossl_check_CTLOG_copyfunc_type(copyfunc), \ - ossl_check_CTLOG_freefunc_type(freefunc))) -# define sk_CTLOG_set_cmp_func(sk, cmp) \ - ((sk_CTLOG_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CTLOG_sk_type(sk), \ - ossl_check_CTLOG_compfunc_type(cmp))) +# define sk_CTLOG_num(sk) OPENSSL_sk_num(ossl_check_const_CTLOG_sk_type(sk)) +# define sk_CTLOG_value(sk, idx) \ + ((CTLOG *)OPENSSL_sk_value(ossl_check_const_CTLOG_sk_type(sk), (idx))) +# define sk_CTLOG_new(cmp) \ + ((STACK_OF(CTLOG) *)OPENSSL_sk_new(ossl_check_CTLOG_compfunc_type(cmp))) +# define sk_CTLOG_new_null() ((STACK_OF(CTLOG) *)OPENSSL_sk_new_null()) +# define sk_CTLOG_new_reserve(cmp, n) \ + ((STACK_OF(CTLOG) *)OPENSSL_sk_new_reserve( \ + ossl_check_CTLOG_compfunc_type(cmp), (n))) +# define sk_CTLOG_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_CTLOG_sk_type(sk), (n)) +# define sk_CTLOG_free(sk) OPENSSL_sk_free(ossl_check_CTLOG_sk_type(sk)) +# define sk_CTLOG_zero(sk) OPENSSL_sk_zero(ossl_check_CTLOG_sk_type(sk)) +# define sk_CTLOG_delete(sk, i) \ + ((CTLOG *)OPENSSL_sk_delete(ossl_check_CTLOG_sk_type(sk), (i))) +# define sk_CTLOG_delete_ptr(sk, ptr) \ + ((CTLOG *)OPENSSL_sk_delete_ptr(ossl_check_CTLOG_sk_type(sk), \ + ossl_check_CTLOG_type(ptr))) +# define sk_CTLOG_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +# define sk_CTLOG_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +# define sk_CTLOG_pop(sk) \ + ((CTLOG *)OPENSSL_sk_pop(ossl_check_CTLOG_sk_type(sk))) +# define sk_CTLOG_shift(sk) \ + ((CTLOG *)OPENSSL_sk_shift(ossl_check_CTLOG_sk_type(sk))) +# define sk_CTLOG_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_CTLOG_sk_type(sk), \ + ossl_check_CTLOG_freefunc_type(freefunc)) +# define sk_CTLOG_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_CTLOG_sk_type(sk), \ + ossl_check_CTLOG_type(ptr), (idx)) +# define sk_CTLOG_set(sk, idx, ptr) \ + ((CTLOG *)OPENSSL_sk_set(ossl_check_CTLOG_sk_type(sk), (idx), \ + ossl_check_CTLOG_type(ptr))) +# define sk_CTLOG_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +# define sk_CTLOG_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)) +# define sk_CTLOG_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_CTLOG_sk_type(sk), \ + ossl_check_CTLOG_type(ptr), pnum) +# define sk_CTLOG_sort(sk) OPENSSL_sk_sort(ossl_check_CTLOG_sk_type(sk)) +# define sk_CTLOG_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_CTLOG_sk_type(sk)) +# define sk_CTLOG_dup(sk) \ + ((STACK_OF(CTLOG) *)OPENSSL_sk_dup(ossl_check_const_CTLOG_sk_type(sk))) +# define sk_CTLOG_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(CTLOG) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_CTLOG_sk_type(sk), \ + ossl_check_CTLOG_copyfunc_type(copyfunc), \ + ossl_check_CTLOG_freefunc_type(freefunc))) +# define sk_CTLOG_set_cmp_func(sk, cmp) \ + ((sk_CTLOG_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_compfunc_type(cmp))) typedef enum { - CT_LOG_ENTRY_TYPE_NOT_SET = -1, - CT_LOG_ENTRY_TYPE_X509 = 0, - CT_LOG_ENTRY_TYPE_PRECERT = 1 + CT_LOG_ENTRY_TYPE_NOT_SET = -1, + CT_LOG_ENTRY_TYPE_X509 = 0, + CT_LOG_ENTRY_TYPE_PRECERT = 1 } ct_log_entry_type_t; typedef enum { - SCT_VERSION_NOT_SET = -1, - SCT_VERSION_V1 = 0 + SCT_VERSION_NOT_SET = -1, + SCT_VERSION_V1 = 0 } sct_version_t; typedef enum { - SCT_SOURCE_UNKNOWN, - SCT_SOURCE_TLS_EXTENSION, - SCT_SOURCE_X509V3_EXTENSION, - SCT_SOURCE_OCSP_STAPLED_RESPONSE + SCT_SOURCE_UNKNOWN, + SCT_SOURCE_TLS_EXTENSION, + SCT_SOURCE_X509V3_EXTENSION, + SCT_SOURCE_OCSP_STAPLED_RESPONSE } sct_source_t; typedef enum { - SCT_VALIDATION_STATUS_NOT_SET, - SCT_VALIDATION_STATUS_UNKNOWN_LOG, - SCT_VALIDATION_STATUS_VALID, - SCT_VALIDATION_STATUS_INVALID, - SCT_VALIDATION_STATUS_UNVERIFIED, - SCT_VALIDATION_STATUS_UNKNOWN_VERSION + SCT_VALIDATION_STATUS_NOT_SET, + SCT_VALIDATION_STATUS_UNKNOWN_LOG, + SCT_VALIDATION_STATUS_VALID, + SCT_VALIDATION_STATUS_INVALID, + SCT_VALIDATION_STATUS_UNVERIFIED, + SCT_VALIDATION_STATUS_UNKNOWN_VERSION } sct_validation_status_t; /****************************************** @@ -162,7 +188,8 @@ typedef enum * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished * with the CT_POLICY_EVAL_CTX. */ -CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq); +CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx, + const char *propq); /* * The same as CT_POLICY_EVAL_CTX_new_ex() but the default library @@ -194,10 +221,12 @@ X509 *CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx); int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer); /* Gets the CT logs that are trusted sources of SCTs */ -const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx); +const CTLOG_STORE * +CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx); /* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */ -void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, CTLOG_STORE *log_store); +void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, + CTLOG_STORE *log_store); /* * Gets the time, in milliseconds since the Unix epoch, that will be used as the @@ -230,7 +259,8 @@ SCT *SCT_new(void); */ SCT *SCT_new_from_base64(unsigned char version, const char *logid_base64, ct_log_entry_type_t entry_type, uint64_t timestamp, - const char *extensions_base64, const char *signature_base64); + const char *extensions_base64, + const char *signature_base64); /* * Frees the SCT and the underlying data structures. @@ -284,7 +314,8 @@ __owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); * This makes a copy of the log_id. * Returns 1 on success, 0 otherwise. */ -__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, size_t log_id_len); +__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, + size_t log_id_len); /* * Returns the timestamp for the SCT (epoch time in milliseconds). @@ -329,7 +360,8 @@ void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len); * This takes a copy of the ext. * Returns 1 on success, 0 otherwise. */ -__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, size_t ext_len); +__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, + size_t ext_len); /* * Set *sig to point to the signature for the SCT. sig must not be NULL. @@ -348,7 +380,8 @@ void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len); * Set the signature of an SCT to be a copy of the *sig specified. * Returns 1 on success, 0 otherwise. */ -__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, size_t sig_len); +__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, + size_t sig_len); /* * The origin of this SCT, e.g. TLS extension, OCSP response, etc. @@ -381,8 +414,8 @@ void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs); * If |logs| is not NULL, it will be used to lookup the CT log that each SCT * came from, so that the log names can be printed. */ -void SCT_LIST_print(const STACK_OF(SCT) * sct_list, BIO *out, int indent, const char *separator, - const CTLOG_STORE *logs); +void SCT_LIST_print(const STACK_OF(SCT) * sct_list, BIO *out, int indent, + const char *separator, const CTLOG_STORE *logs); /* * Gets the last result of validating this SCT. @@ -406,7 +439,8 @@ __owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx); * Returns 0 if at least one SCT is invalid or could not be verified. * Returns a negative integer if an error occurs. */ -__owur int SCT_LIST_validate(const STACK_OF(SCT) * scts, CT_POLICY_EVAL_CTX *ctx); +__owur int SCT_LIST_validate(const STACK_OF(SCT) * scts, + CT_POLICY_EVAL_CTX *ctx); /********************************* * SCT parsing and serialization * @@ -436,7 +470,8 @@ __owur int i2o_SCT_LIST(const STACK_OF(SCT) * a, unsigned char **pp); * Upon failure, a NULL pointer will be returned, and the position of "*pp" is * not defined. */ -STACK_OF(SCT) * o2i_SCT_LIST(STACK_OF(SCT) * *a, const unsigned char **pp, size_t len); +STACK_OF(SCT) + * o2i_SCT_LIST(STACK_OF(SCT) * *a, const unsigned char **pp, size_t len); /* * Serialize (to DER format) a stack of SCTs and return the length. @@ -462,13 +497,14 @@ __owur int i2d_SCT_LIST(const STACK_OF(SCT) * a, unsigned char **pp); * Upon failure, a NULL pointer will be returned, and the position of "*pp" is * not defined. */ -STACK_OF(SCT) * d2i_SCT_LIST(STACK_OF(SCT) * *a, const unsigned char **pp, long len); +STACK_OF(SCT) + * d2i_SCT_LIST(STACK_OF(SCT) * *a, const unsigned char **pp, long len); /* * Serialize (to TLS format) an |sct| and write it to |out|. - * If |out| is null, no SCT will be output but the length will still be returned. - * If |out| points to a null pointer, a string will be allocated to hold the - * TLS-format SCT. It is the responsibility of the caller to free it. + * If |out| is null, no SCT will be output but the length will still be + * returned. If |out| points to a null pointer, a string will be allocated to + * hold the TLS-format SCT. It is the responsibility of the caller to free it. * If |out| points to an allocated string, the TLS-format SCT will be written * to it. * The length of the SCT in TLS format will be returned. @@ -500,8 +536,8 @@ SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len); * Returns NULL if malloc fails or if |public_key| cannot be converted to DER. * Should be deleted by the caller using CTLOG_free when no longer needed. */ -CTLOG *CTLOG_new_ex(EVP_PKEY *public_key, const char *name, OSSL_LIB_CTX *libctx, - const char *propq); +CTLOG *CTLOG_new_ex(EVP_PKEY *public_key, const char *name, + OSSL_LIB_CTX *libctx, const char *propq); /* * The same as CTLOG_new_ex except that the default library context and @@ -517,15 +553,17 @@ CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name); * Returns 1 on success, 0 on failure. * Should be deleted by the caller using CTLOG_free when no longer needed. */ -int CTLOG_new_from_base64_ex(CTLOG **ct_log, const char *pkey_base64, const char *name, - OSSL_LIB_CTX *libctx, const char *propq); +int CTLOG_new_from_base64_ex(CTLOG **ct_log, const char *pkey_base64, + const char *name, OSSL_LIB_CTX *libctx, + const char *propq); /* * The same as CTLOG_new_from_base64_ex() except that the default * library context and property query string are used. * Returns 1 on success, 0 on failure. */ -int CTLOG_new_from_base64(CTLOG **ct_log, const char *pkey_base64, const char *name); +int CTLOG_new_from_base64(CTLOG **ct_log, const char *pkey_base64, + const char *name); /* * Deletes a CT log instance and its fields. @@ -535,7 +573,8 @@ void CTLOG_free(CTLOG *log); /* Gets the name of the CT log */ const char *CTLOG_get0_name(const CTLOG *log); /* Gets the ID of the CT log */ -void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, size_t *log_id_len); +void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, + size_t *log_id_len); /* Gets the public key of the CT log */ EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log); @@ -566,7 +605,8 @@ void CTLOG_STORE_free(CTLOG_STORE *store); * Finds a CT log in the store based on its log ID. * Returns the CT log, or NULL if no match is found. */ -const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store, const uint8_t *log_id, +const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store, + const uint8_t *log_id, size_t log_id_len); /* @@ -581,8 +621,8 @@ __owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file); */ __owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/cterr.h b/libs/OpenSSL/include/openssl/cterr.h index bcf47664..ec825eda 100644 --- a/libs/OpenSSL/include/openssl/cterr.h +++ b/libs/OpenSSL/include/openssl/cterr.h @@ -21,23 +21,23 @@ /* * CT reason codes. */ -# define CT_R_BASE64_DECODE_ERROR 108 -# define CT_R_INVALID_LOG_ID_LENGTH 100 -# define CT_R_LOG_CONF_INVALID 109 -# define CT_R_LOG_CONF_INVALID_KEY 110 -# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 -# define CT_R_LOG_CONF_MISSING_KEY 112 -# define CT_R_LOG_KEY_INVALID 113 -# define CT_R_SCT_FUTURE_TIMESTAMP 116 -# define CT_R_SCT_INVALID 104 -# define CT_R_SCT_INVALID_SIGNATURE 107 -# define CT_R_SCT_LIST_INVALID 105 -# define CT_R_SCT_LOG_ID_MISMATCH 114 -# define CT_R_SCT_NOT_SET 106 -# define CT_R_SCT_UNSUPPORTED_VERSION 115 -# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 -# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 -# define CT_R_UNSUPPORTED_VERSION 103 +# define CT_R_BASE64_DECODE_ERROR 108 +# define CT_R_INVALID_LOG_ID_LENGTH 100 +# define CT_R_LOG_CONF_INVALID 109 +# define CT_R_LOG_CONF_INVALID_KEY 110 +# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 +# define CT_R_LOG_CONF_MISSING_KEY 112 +# define CT_R_LOG_KEY_INVALID 113 +# define CT_R_SCT_FUTURE_TIMESTAMP 116 +# define CT_R_SCT_INVALID 104 +# define CT_R_SCT_INVALID_SIGNATURE 107 +# define CT_R_SCT_LIST_INVALID 105 +# define CT_R_SCT_LOG_ID_MISMATCH 114 +# define CT_R_SCT_NOT_SET 106 +# define CT_R_SCT_UNSUPPORTED_VERSION 115 +# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 +# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 +# define CT_R_UNSUPPORTED_VERSION 103 #endif #endif diff --git a/libs/OpenSSL/include/openssl/decoder.h b/libs/OpenSSL/include/openssl/decoder.h index 0ed43d21..a94d7a2c 100644 --- a/libs/OpenSSL/include/openssl/decoder.h +++ b/libs/OpenSSL/include/openssl/decoder.h @@ -14,7 +14,7 @@ #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include #include @@ -26,7 +26,8 @@ extern "C" { #endif -OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name, const char *properties); +OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name, + const char *properties); int OSSL_DECODER_up_ref(OSSL_DECODER *encoder); void OSSL_DECODER_free(OSSL_DECODER *encoder); @@ -37,23 +38,30 @@ const char *OSSL_DECODER_get0_description(const OSSL_DECODER *decoder); int OSSL_DECODER_is_a(const OSSL_DECODER *encoder, const char *name); void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx, - void (*fn)(OSSL_DECODER *encoder, void *arg), void *arg); -int OSSL_DECODER_names_do_all(const OSSL_DECODER *encoder, void (*fn)(const char *name, void *data), + void (*fn)(OSSL_DECODER *encoder, void *arg), + void *arg); +int OSSL_DECODER_names_do_all(const OSSL_DECODER *encoder, + void (*fn)(const char *name, void *data), void *data); const OSSL_PARAM *OSSL_DECODER_gettable_params(OSSL_DECODER *decoder); int OSSL_DECODER_get_params(OSSL_DECODER *decoder, OSSL_PARAM params[]); const OSSL_PARAM *OSSL_DECODER_settable_ctx_params(OSSL_DECODER *encoder); OSSL_DECODER_CTX *OSSL_DECODER_CTX_new(void); -int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx, const OSSL_PARAM params[]); +int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx, + const OSSL_PARAM params[]); void OSSL_DECODER_CTX_free(OSSL_DECODER_CTX *ctx); /* Utilities that help set specific parameters */ -int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx, const unsigned char *kstr, size_t klen); -int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx, pem_password_cb *cb, void *cbarg); -int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx, OSSL_PASSPHRASE_CALLBACK *cb, +int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx, + const unsigned char *kstr, size_t klen); +int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx, + pem_password_cb *cb, void *cbarg); +int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx, + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); -int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx, const UI_METHOD *ui_method, +int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx, + const UI_METHOD *ui_method, void *ui_data); /* @@ -62,47 +70,61 @@ int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx, const UI_METHOD *u */ int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection); -int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx, const char *input_type); -int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx, const char *input_structure); +int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx, + const char *input_type); +int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx, + const char *input_structure); int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder); -int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx, OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx, OSSL_LIB_CTX *libctx, + const char *propq); int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx); typedef struct ossl_decoder_instance_st OSSL_DECODER_INSTANCE; -OSSL_DECODER *OSSL_DECODER_INSTANCE_get_decoder(OSSL_DECODER_INSTANCE *decoder_inst); -void *OSSL_DECODER_INSTANCE_get_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst); -const char *OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst); -const char *OSSL_DECODER_INSTANCE_get_input_structure(OSSL_DECODER_INSTANCE *decoder_inst, - int *was_set); +OSSL_DECODER * +OSSL_DECODER_INSTANCE_get_decoder(OSSL_DECODER_INSTANCE *decoder_inst); +void * +OSSL_DECODER_INSTANCE_get_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst); +const char * +OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst); +const char * +OSSL_DECODER_INSTANCE_get_input_structure(OSSL_DECODER_INSTANCE *decoder_inst, + int *was_set); -typedef int OSSL_DECODER_CONSTRUCT(OSSL_DECODER_INSTANCE *decoder_inst, const OSSL_PARAM *params, +typedef int OSSL_DECODER_CONSTRUCT(OSSL_DECODER_INSTANCE *decoder_inst, + const OSSL_PARAM *params, void *construct_data); typedef void OSSL_DECODER_CLEANUP(void *construct_data); -int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx, OSSL_DECODER_CONSTRUCT *construct); -int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx, void *construct_data); -int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx, OSSL_DECODER_CLEANUP *cleanup); +int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx, + OSSL_DECODER_CONSTRUCT *construct); +int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx, + void *construct_data); +int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx, + OSSL_DECODER_CLEANUP *cleanup); OSSL_DECODER_CONSTRUCT *OSSL_DECODER_CTX_get_construct(OSSL_DECODER_CTX *ctx); void *OSSL_DECODER_CTX_get_construct_data(OSSL_DECODER_CTX *ctx); OSSL_DECODER_CLEANUP *OSSL_DECODER_CTX_get_cleanup(OSSL_DECODER_CTX *ctx); -int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst, void *reference, size_t reference_sz, - OSSL_CALLBACK *export_cb, void *export_cbarg); +int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst, void *reference, + size_t reference_sz, OSSL_CALLBACK *export_cb, + void *export_cbarg); int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in); #ifndef OPENSSL_NO_STDIO int OSSL_DECODER_from_fp(OSSL_DECODER_CTX *ctx, FILE *in); #endif -int OSSL_DECODER_from_data(OSSL_DECODER_CTX *ctx, const unsigned char **pdata, size_t *pdata_len); +int OSSL_DECODER_from_data(OSSL_DECODER_CTX *ctx, const unsigned char **pdata, + size_t *pdata_len); /* * Create the OSSL_DECODER_CTX with an associated type. This will perform * an implicit OSSL_DECODER_fetch(), suitable for the object of that type. */ -OSSL_DECODER_CTX *OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey, const char *input_type, - const char *input_struct, const char *keytype, - int selection, OSSL_LIB_CTX *libctx, - const char *propquery); +OSSL_DECODER_CTX * +OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey, const char *input_type, + const char *input_struct, const char *keytype, + int selection, OSSL_LIB_CTX *libctx, + const char *propquery); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/des.h b/libs/OpenSSL/include/openssl/des.h index 527903f6..cef474d5 100644 --- a/libs/OpenSSL/include/openssl/des.h +++ b/libs/OpenSSL/include/openssl/des.h @@ -13,24 +13,24 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_DES_H +# define HEADER_DES_H #endif #include #ifndef OPENSSL_NO_DES -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif -# include +# endif +# include -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef unsigned int DES_LONG; -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif +# ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +# endif typedef unsigned char DES_cblock[8]; typedef /* const */ unsigned char const_DES_cblock[8]; @@ -41,65 +41,72 @@ typedef /* const */ unsigned char const_DES_cblock[8]; typedef struct DES_ks { - union - { - DES_cblock cblock; - /* - * make sure things are correct size on machines with 8 byte longs - */ - DES_LONG deslong[2]; - } ks[16]; + union + { + DES_cblock cblock; + /* + * make sure things are correct size on machines with 8 byte longs + */ + DES_LONG deslong[2]; + } ks[16]; } DES_key_schedule; -# define DES_KEY_SZ (sizeof(DES_cblock)) -# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) +# define DES_KEY_SZ (sizeof(DES_cblock)) +# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) -# define DES_ENCRYPT 1 -# define DES_DECRYPT 0 +# define DES_ENCRYPT 1 +# define DES_DECRYPT 0 -# define DES_CBC_MODE 0 -# define DES_PCBC_MODE 1 +# define DES_CBC_MODE 0 +# define DES_PCBC_MODE 1 -# define DES_ecb2_encrypt(i, o, k1, k2, e) DES_ecb3_encrypt((i), (o), (k1), (k2), (k1), (e)) +# define DES_ecb2_encrypt(i, o, k1, k2, e) \ + DES_ecb3_encrypt((i), (o), (k1), (k2), (k1), (e)) -# define DES_ede2_cbc_encrypt(i, o, l, k1, k2, iv, e) \ - DES_ede3_cbc_encrypt((i), (o), (l), (k1), (k2), (k1), (iv), (e)) +# define DES_ede2_cbc_encrypt(i, o, l, k1, k2, iv, e) \ + DES_ede3_cbc_encrypt((i), (o), (l), (k1), (k2), (k1), (iv), (e)) -# define DES_ede2_cfb64_encrypt(i, o, l, k1, k2, iv, n, e) \ - DES_ede3_cfb64_encrypt((i), (o), (l), (k1), (k2), (k1), (iv), (n), (e)) +# define DES_ede2_cfb64_encrypt(i, o, l, k1, k2, iv, n, e) \ + DES_ede3_cfb64_encrypt((i), (o), (l), (k1), (k2), (k1), (iv), (n), (e)) -# define DES_ede2_ofb64_encrypt(i, o, l, k1, k2, iv, n) \ - DES_ede3_ofb64_encrypt((i), (o), (l), (k1), (k2), (k1), (iv), (n)) +# define DES_ede2_ofb64_encrypt(i, o, l, k1, k2, iv, n) \ + DES_ede3_ofb64_encrypt((i), (o), (l), (k1), (k2), (k1), (iv), (n)) -# define DES_fixup_key_parity DES_set_odd_parity -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DES_fixup_key_parity DES_set_odd_parity +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 const char *DES_options(void); OSSL_DEPRECATEDIN_3_0 -void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, int enc); +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1, DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); OSSL_DEPRECATEDIN_3_0 -DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, long length, - DES_key_schedule *schedule, const_DES_cblock *ivec); -# endif +DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, + long length, DES_key_schedule *schedule, + const_DES_cblock *ivec); +# endif /* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -void DES_cbc_encrypt(const unsigned char *input, unsigned char *output, long length, - DES_key_schedule *schedule, DES_cblock *ivec, int enc); +void DES_cbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); OSSL_DEPRECATEDIN_3_0 -void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, long length, - DES_key_schedule *schedule, DES_cblock *ivec, int enc); +void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); OSSL_DEPRECATEDIN_3_0 -void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, long length, - DES_key_schedule *schedule, DES_cblock *ivec, const_DES_cblock *inw, - const_DES_cblock *outw, int enc); +void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + const_DES_cblock *inw, const_DES_cblock *outw, int enc); OSSL_DEPRECATEDIN_3_0 -void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, long length, - DES_key_schedule *schedule, DES_cblock *ivec, int enc); +void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); OSSL_DEPRECATEDIN_3_0 -void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks, int enc); -# endif +void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks, int enc); +# endif /* * This is the DES encryption function that gets called by just about every @@ -111,10 +118,10 @@ void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedu * long's and ks is the DES_key_schedule to use. enc, is non zero specifies * encryption, zero if decryption. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc); -# endif +# endif /* * This functions is the same as DES_encrypt1() except that the DES initial @@ -124,7 +131,7 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc); * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1() * DES_encrypt1() DES_encrypt1() except faster :-). */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc); OSSL_DEPRECATEDIN_3_0 @@ -134,44 +141,49 @@ OSSL_DEPRECATEDIN_3_0 void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3); OSSL_DEPRECATEDIN_3_0 -void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, long length, - DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, +void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int enc); OSSL_DEPRECATEDIN_3_0 -void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, - DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, +void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc); OSSL_DEPRECATEDIN_3_0 -void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, long length, - DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, +void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, + int numbits, long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int enc); OSSL_DEPRECATEDIN_3_0 -void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, - DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3, +void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int *num); OSSL_DEPRECATEDIN_3_0 char *DES_fcrypt(const char *buf, const char *salt, char *ret); OSSL_DEPRECATEDIN_3_0 char *DES_crypt(const char *buf, const char *salt); OSSL_DEPRECATEDIN_3_0 -void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, long length, - DES_key_schedule *schedule, DES_cblock *ivec); +void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, + long length, DES_key_schedule *schedule, DES_cblock *ivec); OSSL_DEPRECATEDIN_3_0 -void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, long length, - DES_key_schedule *schedule, DES_cblock *ivec, int enc); +void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + int enc); OSSL_DEPRECATEDIN_3_0 -DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], long length, int out_count, - DES_cblock *seed); +DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], + long length, int out_count, DES_cblock *seed); OSSL_DEPRECATEDIN_3_0 int DES_random_key(DES_cblock *ret); OSSL_DEPRECATEDIN_3_0 void DES_set_odd_parity(DES_cblock *key); OSSL_DEPRECATEDIN_3_0 int DES_check_key_parity(const_DES_cblock *key); OSSL_DEPRECATEDIN_3_0 int DES_is_weak_key(const_DES_cblock *key); -# endif +# endif /* * DES_set_key (= set_key = DES_key_sched = key_sched) calls * DES_set_key_checked */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); OSSL_DEPRECATEDIN_3_0 @@ -185,15 +197,16 @@ OSSL_DEPRECATEDIN_3_0 void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2); OSSL_DEPRECATEDIN_3_0 void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, - DES_key_schedule *schedule, DES_cblock *ivec, int *num, int enc); + DES_key_schedule *schedule, DES_cblock *ivec, int *num, + int enc); OSSL_DEPRECATEDIN_3_0 void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *schedule, DES_cblock *ivec, int *num); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/dh.h b/libs/OpenSSL/include/openssl/dh.h index 373699ff..93d54d3d 100644 --- a/libs/OpenSSL/include/openssl/dh.h +++ b/libs/OpenSSL/include/openssl/dh.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_DH_H +# define HEADER_DH_H #endif #include @@ -26,14 +26,16 @@ extern "C" { #include /* DH parameter generation types used by EVP_PKEY_CTX_set_dh_paramgen_type() */ -#define DH_PARAMGEN_TYPE_GENERATOR 0 /* Use a safe prime generator */ +#define DH_PARAMGEN_TYPE_GENERATOR 0 /* Use a safe prime generator */ #define DH_PARAMGEN_TYPE_FIPS_186_2 1 /* Use FIPS186-2 standard */ #define DH_PARAMGEN_TYPE_FIPS_186_4 2 /* Use FIPS186-4 standard */ -#define DH_PARAMGEN_TYPE_GROUP 3 /* Use a named safe prime group */ +#define DH_PARAMGEN_TYPE_GROUP 3 /* Use a named safe prime group */ int EVP_PKEY_CTX_set_dh_paramgen_type(EVP_PKEY_CTX *ctx, int typ); int EVP_PKEY_CTX_set_dh_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex); -int EVP_PKEY_CTX_set_dh_paramgen_seed(EVP_PKEY_CTX *ctx, const unsigned char *seed, size_t seedlen); +int EVP_PKEY_CTX_set_dh_paramgen_seed(EVP_PKEY_CTX *ctx, + const unsigned char *seed, + size_t seedlen); int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int pbits); int EVP_PKEY_CTX_set_dh_paramgen_subprime_len(EVP_PKEY_CTX *ctx, int qlen); int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen); @@ -50,7 +52,8 @@ int EVP_PKEY_CTX_set_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); int EVP_PKEY_CTX_get_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); int EVP_PKEY_CTX_set_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); int EVP_PKEY_CTX_get_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); -int EVP_PKEY_CTX_set0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len); +int EVP_PKEY_CTX_set0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, + int len); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); @@ -78,37 +81,37 @@ int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); #define EVP_PKEY_DH_KDF_X9_42 2 #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifndef OPENSSL_NO_DH -# include -# include -# include -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include -# endif -# include +# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include -# ifndef OPENSSL_DH_MAX_MODULUS_BITS -# define OPENSSL_DH_MAX_MODULUS_BITS 10000 -# endif +# ifndef OPENSSL_DH_MAX_MODULUS_BITS +# define OPENSSL_DH_MAX_MODULUS_BITS 10000 +# endif -# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 +# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 -# define DH_FLAG_CACHE_MONT_P 0x01 +# define DH_FLAG_CACHE_MONT_P 0x01 -# define DH_FLAG_TYPE_MASK 0xF000 -# define DH_FLAG_TYPE_DH 0x0000 -# define DH_FLAG_TYPE_DHX 0x1000 +# define DH_FLAG_TYPE_MASK 0xF000 +# define DH_FLAG_TYPE_DH 0x0000 +# define DH_FLAG_TYPE_DHX 0x1000 -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 /* * Does nothing. Previously this switched off constant time behaviour. */ -# define DH_FLAG_NO_EXP_CONSTTIME 0x00 -# endif +# define DH_FLAG_NO_EXP_CONSTTIME 0x00 +# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /* * If this flag is set the DH method is FIPS compliant and can be used in * FIPS mode. This is set in the validated module method. If an application @@ -116,7 +119,7 @@ int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); * result is compliant. */ -# define DH_FLAG_FIPS_METHOD 0x0400 +# define DH_FLAG_FIPS_METHOD 0x0400 /* * If this flag is set the operations normally disabled in FIPS mode are @@ -124,8 +127,8 @@ int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); * usage is compliant. */ -# define DH_FLAG_NON_FIPS_ALLOW 0x0400 -# endif +# define DH_FLAG_NON_FIPS_ALLOW 0x0400 +# endif /* Already defined in ossl_typ.h */ /* typedef struct dh_st DH; */ @@ -133,50 +136,54 @@ int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); DECLARE_ASN1_ITEM(DHparams) -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DH_GENERATOR_2 2 -# define DH_GENERATOR_3 3 -# define DH_GENERATOR_5 5 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DH_GENERATOR_2 2 +# define DH_GENERATOR_3 3 +# define DH_GENERATOR_5 5 /* DH_check error codes */ /* * NB: These values must align with the equivalently named macros in * internal/ffc.h. */ -# define DH_CHECK_P_NOT_PRIME 0x01 -# define DH_CHECK_P_NOT_SAFE_PRIME 0x02 -# define DH_UNABLE_TO_CHECK_GENERATOR 0x04 -# define DH_NOT_SUITABLE_GENERATOR 0x08 -# define DH_CHECK_Q_NOT_PRIME 0x10 -# define DH_CHECK_INVALID_Q_VALUE 0x20 -# define DH_CHECK_INVALID_J_VALUE 0x40 -# define DH_MODULUS_TOO_SMALL 0x80 -# define DH_MODULUS_TOO_LARGE 0x100 +# define DH_CHECK_P_NOT_PRIME 0x01 +# define DH_CHECK_P_NOT_SAFE_PRIME 0x02 +# define DH_UNABLE_TO_CHECK_GENERATOR 0x04 +# define DH_NOT_SUITABLE_GENERATOR 0x08 +# define DH_CHECK_Q_NOT_PRIME 0x10 +# define DH_CHECK_INVALID_Q_VALUE 0x20 +# define DH_CHECK_INVALID_J_VALUE 0x40 +# define DH_MODULUS_TOO_SMALL 0x80 +# define DH_MODULUS_TOO_LARGE 0x100 /* DH_check_pub_key error codes */ -# define DH_CHECK_PUBKEY_TOO_SMALL 0x01 -# define DH_CHECK_PUBKEY_TOO_LARGE 0x02 -# define DH_CHECK_PUBKEY_INVALID 0x04 +# define DH_CHECK_PUBKEY_TOO_SMALL 0x01 +# define DH_CHECK_PUBKEY_TOO_LARGE 0x02 +# define DH_CHECK_PUBKEY_INVALID 0x04 /* * primes p where (p-1)/2 is prime too are called "safe"; we define this for * backward compatibility: */ -# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME +# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME -# define d2i_DHparams_fp(fp, x) \ - (DH *)ASN1_d2i_fp((char *(*)())DH_new, (char *(*)())d2i_DHparams, (fp), \ - (unsigned char **)(x)) -# define i2d_DHparams_fp(fp, x) ASN1_i2d_fp(i2d_DHparams, (fp), (unsigned char *)(x)) -# define d2i_DHparams_bio(bp, x) ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x) -# define i2d_DHparams_bio(bp, x) ASN1_i2d_bio_of(DH, i2d_DHparams, bp, x) +# define d2i_DHparams_fp(fp, x) \ + (DH *)ASN1_d2i_fp((char *(*)())DH_new, (char *(*)())d2i_DHparams, (fp), \ + (unsigned char **)(x)) +# define i2d_DHparams_fp(fp, x) \ + ASN1_i2d_fp(i2d_DHparams, (fp), (unsigned char *)(x)) +# define d2i_DHparams_bio(bp, x) \ + ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x) +# define i2d_DHparams_bio(bp, x) ASN1_i2d_bio_of(DH, i2d_DHparams, bp, x) -# define d2i_DHxparams_fp(fp, x) \ - (DH *)ASN1_d2i_fp((char *(*)())DH_new, (char *(*)())d2i_DHxparams, (fp), \ - (unsigned char **)(x)) -# define i2d_DHxparams_fp(fp, x) ASN1_i2d_fp(i2d_DHxparams, (fp), (unsigned char *)(x)) -# define d2i_DHxparams_bio(bp, x) ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x) -# define i2d_DHxparams_bio(bp, x) ASN1_i2d_bio_of(DH, i2d_DHxparams, bp, x) +# define d2i_DHxparams_fp(fp, x) \ + (DH *)ASN1_d2i_fp((char *(*)())DH_new, (char *(*)())d2i_DHxparams, (fp), \ + (unsigned char **)(x)) +# define i2d_DHxparams_fp(fp, x) \ + ASN1_i2d_fp(i2d_DHxparams, (fp), (unsigned char *)(x)) +# define d2i_DHxparams_bio(bp, x) \ + ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x) +# define i2d_DHxparams_bio(bp, x) ASN1_i2d_bio_of(DH, i2d_DHxparams, bp, x) DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DH, DHparams) @@ -194,31 +201,36 @@ OSSL_DEPRECATEDIN_3_0 int DH_bits(const DH *dh); OSSL_DEPRECATEDIN_3_0 int DH_size(const DH *dh); OSSL_DEPRECATEDIN_3_0 int DH_security_bits(const DH *dh); -# define DH_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef) +# define DH_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef) OSSL_DEPRECATEDIN_3_0 int DH_set_ex_data(DH *d, int idx, void *arg); OSSL_DEPRECATEDIN_3_0 void *DH_get_ex_data(const DH *d, int idx); -OSSL_DEPRECATEDIN_3_0 int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, - BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 int +DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 int DH_check_params_ex(const DH *dh); OSSL_DEPRECATEDIN_3_0 int DH_check_ex(const DH *dh); -OSSL_DEPRECATEDIN_3_0 int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key); +OSSL_DEPRECATEDIN_3_0 int DH_check_pub_key_ex(const DH *dh, + const BIGNUM *pub_key); OSSL_DEPRECATEDIN_3_0 int DH_check_params(const DH *dh, int *ret); OSSL_DEPRECATEDIN_3_0 int DH_check(const DH *dh, int *codes); -OSSL_DEPRECATEDIN_3_0 int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes); +OSSL_DEPRECATEDIN_3_0 int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, + int *codes); OSSL_DEPRECATEDIN_3_0 int DH_generate_key(DH *dh); -OSSL_DEPRECATEDIN_3_0 int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); -OSSL_DEPRECATEDIN_3_0 int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_compute_key(unsigned char *key, + const BIGNUM *pub_key, DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_compute_key_padded(unsigned char *key, + const BIGNUM *pub_key, DH *dh); DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DH, DHparams) - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DH, DHxparams) + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DH, + DHxparams) -# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_STDIO OSSL_DEPRECATEDIN_3_0 int DHparams_print_fp(FILE *fp, const DH *x); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int DHparams_print(BIO *bp, const DH *x); /* RFC 5114 parameters */ @@ -231,16 +243,19 @@ OSSL_DEPRECATEDIN_3_0 DH *DH_new_by_nid(int nid); OSSL_DEPRECATEDIN_3_0 int DH_get_nid(const DH *dh); /* RFC2631 KDF */ -OSSL_DEPRECATEDIN_3_0 int DH_KDF_X9_42(unsigned char *out, size_t outlen, const unsigned char *Z, - size_t Zlen, ASN1_OBJECT *key_oid, const unsigned char *ukm, - size_t ukmlen, const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 int DH_KDF_X9_42(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + ASN1_OBJECT *key_oid, + const unsigned char *ukm, size_t ukmlen, + const EVP_MD *md); -OSSL_DEPRECATEDIN_3_0 void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, - const BIGNUM **g); +OSSL_DEPRECATEDIN_3_0 void DH_get0_pqg(const DH *dh, const BIGNUM **p, + const BIGNUM **q, const BIGNUM **g); OSSL_DEPRECATEDIN_3_0 int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); OSSL_DEPRECATEDIN_3_0 void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); -OSSL_DEPRECATEDIN_3_0 int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); +OSSL_DEPRECATEDIN_3_0 int DH_set0_key(DH *dh, BIGNUM *pub_key, + BIGNUM *priv_key); OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_p(const DH *dh); OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_q(const DH *dh); OSSL_DEPRECATEDIN_3_0 const BIGNUM *DH_get0_g(const DH *dh); @@ -262,35 +277,39 @@ OSSL_DEPRECATEDIN_3_0 int DH_meth_get_flags(const DH_METHOD *dhm); OSSL_DEPRECATEDIN_3_0 int DH_meth_set_flags(DH_METHOD *dhm, int flags); OSSL_DEPRECATEDIN_3_0 void *DH_meth_get0_app_data(const DH_METHOD *dhm); OSSL_DEPRECATEDIN_3_0 int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data); -OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_generate_key(const DH_METHOD *dhm))(DH *); -OSSL_DEPRECATEDIN_3_0 int DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key)(DH *)); -OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_compute_key(const DH_METHOD *dhm))(unsigned char *key, - const BIGNUM *pub_key, - DH *dh); -OSSL_DEPRECATEDIN_3_0 int -DH_meth_set_compute_key(DH_METHOD *dhm, - int (*compute_key)(unsigned char *key, const BIGNUM *pub_key, DH *dh)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_generate_key(const DH_METHOD *dhm))( + DH *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_generate_key(DH_METHOD *dhm, + int (*generate_key)(DH *)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_compute_key(const DH_METHOD *dhm))( + unsigned char *key, const BIGNUM *pub_key, DH *dh); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_compute_key( + DH_METHOD *dhm, + int (*compute_key)(unsigned char *key, const BIGNUM *pub_key, DH *dh)); OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm))( - const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *); -OSSL_DEPRECATEDIN_3_0 int -DH_meth_set_bn_mod_exp(DH_METHOD *dhm, - int (*bn_mod_exp)(const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); + const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, + BN_CTX *, BN_MONT_CTX *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_bn_mod_exp( + DH_METHOD *dhm, + int (*bn_mod_exp)(const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *); OSSL_DEPRECATEDIN_3_0 int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *)); OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_finish(const DH_METHOD *dhm))(DH *); -OSSL_DEPRECATEDIN_3_0 int DH_meth_set_finish(DH_METHOD *dhm, int (*finish)(DH *)); -OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_generate_params(const DH_METHOD *dhm))(DH *, int, int, - BN_GENCB *); +OSSL_DEPRECATEDIN_3_0 int DH_meth_set_finish(DH_METHOD *dhm, + int (*finish)(DH *)); +OSSL_DEPRECATEDIN_3_0 int (*DH_meth_get_generate_params(const DH_METHOD *dhm))( + DH *, int, int, BN_GENCB *); OSSL_DEPRECATEDIN_3_0 int -DH_meth_set_generate_params(DH_METHOD *dhm, int (*generate_params)(DH *, int, int, BN_GENCB *)); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +DH_meth_set_generate_params(DH_METHOD *dhm, + int (*generate_params)(DH *, int, int, BN_GENCB *)); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -# ifndef OPENSSL_NO_DEPRECATED_0_9_8 -OSSL_DEPRECATEDIN_0_9_8 DH *DH_generate_parameters(int prime_len, int generator, - void (*callback)(int, int, void *), - void *cb_arg); -# endif +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +OSSL_DEPRECATEDIN_0_9_8 DH * +DH_generate_parameters(int prime_len, int generator, + void (*callback)(int, int, void *), void *cb_arg); +# endif #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/dherr.h b/libs/OpenSSL/include/openssl/dherr.h index db6e2ced..617b9ec6 100644 --- a/libs/OpenSSL/include/openssl/dherr.h +++ b/libs/OpenSSL/include/openssl/dherr.h @@ -21,36 +21,36 @@ /* * DH reason codes. */ -# define DH_R_BAD_FFC_PARAMETERS 127 -# define DH_R_BAD_GENERATOR 101 -# define DH_R_BN_DECODE_ERROR 109 -# define DH_R_BN_ERROR 106 -# define DH_R_CHECK_INVALID_J_VALUE 115 -# define DH_R_CHECK_INVALID_Q_VALUE 116 -# define DH_R_CHECK_PUBKEY_INVALID 122 -# define DH_R_CHECK_PUBKEY_TOO_LARGE 123 -# define DH_R_CHECK_PUBKEY_TOO_SMALL 124 -# define DH_R_CHECK_P_NOT_PRIME 117 -# define DH_R_CHECK_P_NOT_SAFE_PRIME 118 -# define DH_R_CHECK_Q_NOT_PRIME 119 -# define DH_R_DECODE_ERROR 104 -# define DH_R_INVALID_PARAMETER_NAME 110 -# define DH_R_INVALID_PARAMETER_NID 114 -# define DH_R_INVALID_PUBKEY 102 -# define DH_R_INVALID_SECRET 128 -# define DH_R_INVALID_SIZE 129 -# define DH_R_KDF_PARAMETER_ERROR 112 -# define DH_R_KEYS_NOT_SET 108 -# define DH_R_MISSING_PUBKEY 125 -# define DH_R_MODULUS_TOO_LARGE 103 -# define DH_R_MODULUS_TOO_SMALL 126 -# define DH_R_NOT_SUITABLE_GENERATOR 120 -# define DH_R_NO_PARAMETERS_SET 107 -# define DH_R_NO_PRIVATE_VALUE 100 -# define DH_R_PARAMETER_ENCODING_ERROR 105 -# define DH_R_PEER_KEY_ERROR 111 -# define DH_R_SHARED_INFO_ERROR 113 -# define DH_R_UNABLE_TO_CHECK_GENERATOR 121 +# define DH_R_BAD_FFC_PARAMETERS 127 +# define DH_R_BAD_GENERATOR 101 +# define DH_R_BN_DECODE_ERROR 109 +# define DH_R_BN_ERROR 106 +# define DH_R_CHECK_INVALID_J_VALUE 115 +# define DH_R_CHECK_INVALID_Q_VALUE 116 +# define DH_R_CHECK_PUBKEY_INVALID 122 +# define DH_R_CHECK_PUBKEY_TOO_LARGE 123 +# define DH_R_CHECK_PUBKEY_TOO_SMALL 124 +# define DH_R_CHECK_P_NOT_PRIME 117 +# define DH_R_CHECK_P_NOT_SAFE_PRIME 118 +# define DH_R_CHECK_Q_NOT_PRIME 119 +# define DH_R_DECODE_ERROR 104 +# define DH_R_INVALID_PARAMETER_NAME 110 +# define DH_R_INVALID_PARAMETER_NID 114 +# define DH_R_INVALID_PUBKEY 102 +# define DH_R_INVALID_SECRET 128 +# define DH_R_INVALID_SIZE 129 +# define DH_R_KDF_PARAMETER_ERROR 112 +# define DH_R_KEYS_NOT_SET 108 +# define DH_R_MISSING_PUBKEY 125 +# define DH_R_MODULUS_TOO_LARGE 103 +# define DH_R_MODULUS_TOO_SMALL 126 +# define DH_R_NOT_SUITABLE_GENERATOR 120 +# define DH_R_NO_PARAMETERS_SET 107 +# define DH_R_NO_PRIVATE_VALUE 100 +# define DH_R_PARAMETER_ENCODING_ERROR 105 +# define DH_R_PEER_KEY_ERROR 111 +# define DH_R_SHARED_INFO_ERROR 113 +# define DH_R_UNABLE_TO_CHECK_GENERATOR 121 #endif #endif diff --git a/libs/OpenSSL/include/openssl/dsa.h b/libs/OpenSSL/include/openssl/dsa.h index 3efa125e..f098562b 100644 --- a/libs/OpenSSL/include/openssl/dsa.h +++ b/libs/OpenSSL/include/openssl/dsa.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_DSA_H +# define HEADER_DSA_H #endif #include @@ -22,18 +22,18 @@ #include #ifndef OPENSSL_NO_DSA -# include -# include -# include -# include -# include -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include -# endif -# include -# ifndef OPENSSL_NO_STDIO -# include -# endif +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif #endif #ifdef __cplusplus @@ -42,11 +42,13 @@ extern "C" { int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits); int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits); -int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx, const char *md_name, +int EVP_PKEY_CTX_set_dsa_paramgen_md_props(EVP_PKEY_CTX *ctx, + const char *md_name, const char *md_properties); int EVP_PKEY_CTX_set_dsa_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex); int EVP_PKEY_CTX_set_dsa_paramgen_type(EVP_PKEY_CTX *ctx, const char *name); -int EVP_PKEY_CTX_set_dsa_paramgen_seed(EVP_PKEY_CTX *ctx, const unsigned char *seed, +int EVP_PKEY_CTX_set_dsa_paramgen_seed(EVP_PKEY_CTX *ctx, + const unsigned char *seed, size_t seedlen); int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); @@ -55,29 +57,28 @@ int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); #define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3) #ifndef OPENSSL_NO_DSA -# ifndef OPENSSL_DSA_MAX_MODULUS_BITS -# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 -# endif +# ifndef OPENSSL_DSA_MAX_MODULUS_BITS +# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 +# endif -# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024 +# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024 typedef struct DSA_SIG_st DSA_SIG; DSA_SIG *DSA_SIG_new(void); void DSA_SIG_free(DSA_SIG *a); -DECLARE_ASN1_ENCODE_FUNCTIONS_only(DSA_SIG, DSA_SIG) void DSA_SIG_get0(const DSA_SIG *sig, - const BIGNUM **pr, - const BIGNUM **ps); +DECLARE_ASN1_ENCODE_FUNCTIONS_only(DSA_SIG, DSA_SIG) void DSA_SIG_get0( + const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 /* * Does nothing. Previously this switched off constant time behaviour. */ -# define DSA_FLAG_NO_EXP_CONSTTIME 0x00 -# endif +# define DSA_FLAG_NO_EXP_CONSTTIME 0x00 +# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DSA_FLAG_CACHE_MONT_P 0x01 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DSA_FLAG_CACHE_MONT_P 0x01 /* * If this flag is set the DSA method is FIPS compliant and can be used in @@ -86,7 +87,7 @@ int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); * result is compliant. */ -# define DSA_FLAG_FIPS_METHOD 0x0400 +# define DSA_FLAG_FIPS_METHOD 0x0400 /* * If this flag is set the operations normally disabled in FIPS mode are @@ -94,24 +95,27 @@ int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); * usage is compliant. */ -# define DSA_FLAG_NON_FIPS_ALLOW 0x0400 -# define DSA_FLAG_FIPS_CHECKED 0x0800 +# define DSA_FLAG_NON_FIPS_ALLOW 0x0400 +# define DSA_FLAG_FIPS_CHECKED 0x0800 /* Already defined in ossl_typ.h */ /* typedef struct dsa_st DSA; */ /* typedef struct dsa_method DSA_METHOD; */ -# define d2i_DSAparams_fp(fp, x) \ - (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, (char *(*)())d2i_DSAparams, (fp), \ - (unsigned char **)(x)) -# define i2d_DSAparams_fp(fp, x) ASN1_i2d_fp(i2d_DSAparams, (fp), (unsigned char *)(x)) -# define d2i_DSAparams_bio(bp, x) ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAparams, bp, x) -# define i2d_DSAparams_bio(bp, x) ASN1_i2d_bio_of(DSA, i2d_DSAparams, bp, x) +# define d2i_DSAparams_fp(fp, x) \ + (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, (char *(*)())d2i_DSAparams, \ + (fp), (unsigned char **)(x)) +# define i2d_DSAparams_fp(fp, x) \ + ASN1_i2d_fp(i2d_DSAparams, (fp), (unsigned char *)(x)) +# define d2i_DSAparams_bio(bp, x) \ + ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAparams, bp, x) +# define i2d_DSAparams_bio(bp, x) ASN1_i2d_bio_of(DSA, i2d_DSAparams, bp, x) DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAparams) - OSSL_DEPRECATEDIN_3_0 DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); -OSSL_DEPRECATEDIN_3_0 int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, - DSA *dsa); + OSSL_DEPRECATEDIN_3_0 DSA_SIG *DSA_do_sign(const unsigned char *dgst, + int dlen, DSA *dsa); +OSSL_DEPRECATEDIN_3_0 int DSA_do_verify(const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); OSSL_DEPRECATEDIN_3_0 const DSA_METHOD *DSA_OpenSSL(void); @@ -129,70 +133,76 @@ OSSL_DEPRECATEDIN_3_0 int DSA_size(const DSA *); OSSL_DEPRECATEDIN_3_0 int DSA_bits(const DSA *d); OSSL_DEPRECATEDIN_3_0 int DSA_security_bits(const DSA *d); /* next 4 return -1 on error */ -OSSL_DEPRECATEDIN_3_0 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); -OSSL_DEPRECATEDIN_3_0 int DSA_sign(int type, const unsigned char *dgst, int dlen, - unsigned char *sig, unsigned int *siglen, DSA *dsa); -OSSL_DEPRECATEDIN_3_0 int DSA_verify(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int siglen, DSA *dsa); +OSSL_DEPRECATEDIN_3_0 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, + BIGNUM **kinvp, BIGNUM **rp); +OSSL_DEPRECATEDIN_3_0 int DSA_sign(int type, const unsigned char *dgst, + int dlen, unsigned char *sig, + unsigned int *siglen, DSA *dsa); +OSSL_DEPRECATEDIN_3_0 int DSA_verify(int type, const unsigned char *dgst, + int dgst_len, const unsigned char *sigbuf, + int siglen, DSA *dsa); -# define DSA_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef) +# define DSA_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef) OSSL_DEPRECATEDIN_3_0 int DSA_set_ex_data(DSA *d, int idx, void *arg); OSSL_DEPRECATEDIN_3_0 void *DSA_get_ex_data(const DSA *d, int idx); -DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAPublicKey) - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAPrivateKey) - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSAparams) -# endif +DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, + DSAPublicKey) + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, + DSAPrivateKey) + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, + DSAparams) +# endif -# ifndef OPENSSL_NO_DEPRECATED_0_9_8 +# ifndef OPENSSL_NO_DEPRECATED_0_9_8 /* Deprecated version */ - OSSL_DEPRECATEDIN_0_9_8 DSA *DSA_generate_parameters(int bits, unsigned char *seed, - int seed_len, int *counter_ret, - unsigned long *h_ret, - void (*callback)(int, int, void *), - void *cb_arg); -# endif + OSSL_DEPRECATEDIN_0_9_8 DSA *DSA_generate_parameters( + int bits, unsigned char *seed, int seed_len, int *counter_ret, + unsigned long *h_ret, void (*callback)(int, int, void *), void *cb_arg); +# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /* New version */ -OSSL_DEPRECATEDIN_3_0 int DSA_generate_parameters_ex(DSA *dsa, int bits, const unsigned char *seed, - int seed_len, int *counter_ret, - unsigned long *h_ret, BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 int +DSA_generate_parameters_ex(DSA *dsa, int bits, const unsigned char *seed, + int seed_len, int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 int DSA_generate_key(DSA *a); OSSL_DEPRECATEDIN_3_0 int DSAparams_print(BIO *bp, const DSA *x); OSSL_DEPRECATEDIN_3_0 int DSA_print(BIO *bp, const DSA *x, int off); -# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_STDIO OSSL_DEPRECATEDIN_3_0 int DSAparams_print_fp(FILE *fp, const DSA *x); OSSL_DEPRECATEDIN_3_0 int DSA_print_fp(FILE *bp, const DSA *x, int off); -# endif +# endif -# define DSS_prime_checks 64 +# define DSS_prime_checks 64 /* * Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only * have one value here we set the number of checks to 64 which is the 128 bit * security level that is the highest level and valid for creating a 3072 bit * DSA key. */ -# define DSA_is_prime(n, callback, cb_arg) \ - BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) +# define DSA_is_prime(n, callback, cb_arg) \ + BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) -# ifndef OPENSSL_NO_DH +# ifndef OPENSSL_NO_DH /* * Convert DSA structure (key or just parameters) into DH structure (be * careful to avoid small subgroup attacks when using this!) */ OSSL_DEPRECATEDIN_3_0 DH *DSA_dup_DH(const DSA *r); -# endif +# endif -OSSL_DEPRECATEDIN_3_0 void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, - const BIGNUM **g); +OSSL_DEPRECATEDIN_3_0 void DSA_get0_pqg(const DSA *d, const BIGNUM **p, + const BIGNUM **q, const BIGNUM **g); OSSL_DEPRECATEDIN_3_0 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); OSSL_DEPRECATEDIN_3_0 void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key); -OSSL_DEPRECATEDIN_3_0 int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); +OSSL_DEPRECATEDIN_3_0 int DSA_set0_key(DSA *d, BIGNUM *pub_key, + BIGNUM *priv_key); OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_p(const DSA *d); OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_q(const DSA *d); OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_g(const DSA *d); @@ -207,50 +217,59 @@ OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_new(const char *name, int flags); OSSL_DEPRECATEDIN_3_0 void DSA_meth_free(DSA_METHOD *dsam); OSSL_DEPRECATEDIN_3_0 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam); OSSL_DEPRECATEDIN_3_0 const char *DSA_meth_get0_name(const DSA_METHOD *dsam); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set1_name(DSA_METHOD *dsam, + const char *name); OSSL_DEPRECATEDIN_3_0 int DSA_meth_get_flags(const DSA_METHOD *dsam); OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags); OSSL_DEPRECATEDIN_3_0 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data); -OSSL_DEPRECATEDIN_3_0 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))(const unsigned char *, - int, DSA *); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign(DSA_METHOD *dsam, - DSA_SIG *(*sign)(const unsigned char *, int, DSA *)); -OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))(DSA *, BN_CTX *, - BIGNUM **, BIGNUM **); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set0_app_data(DSA_METHOD *dsam, + void *app_data); +OSSL_DEPRECATEDIN_3_0 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))( + const unsigned char *, int, DSA *); OSSL_DEPRECATEDIN_3_0 int -DSA_meth_set_sign_setup(DSA_METHOD *dsam, int (*sign_setup)(DSA *, BN_CTX *, BIGNUM **, BIGNUM **)); -OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))(const unsigned char *, int, - DSA_SIG *, DSA *); +DSA_meth_set_sign(DSA_METHOD *dsam, + DSA_SIG *(*sign)(const unsigned char *, int, DSA *)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))( + DSA *, BN_CTX *, BIGNUM **, BIGNUM **); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_sign_setup( + DSA_METHOD *dsam, int (*sign_setup)(DSA *, BN_CTX *, BIGNUM **, BIGNUM **)); +OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))( + const unsigned char *, int, DSA_SIG *, DSA *); OSSL_DEPRECATEDIN_3_0 int -DSA_meth_set_verify(DSA_METHOD *dsam, int (*verify)(const unsigned char *, int, DSA_SIG *, DSA *)); +DSA_meth_set_verify(DSA_METHOD *dsam, int (*verify)(const unsigned char *, int, + DSA_SIG *, DSA *)); OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))( - DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - BN_CTX *, BN_MONT_CTX *); -OSSL_DEPRECATEDIN_3_0 int -DSA_meth_set_mod_exp(DSA_METHOD *dsam, - int (*mod_exp)(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); + DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_mod_exp( + DSA_METHOD *dsam, + int (*mod_exp)(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, + BN_MONT_CTX *)); OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))( - DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam, - int (*bn_mod_exp)(DSA *, BIGNUM *, const BIGNUM *, - const BIGNUM *, const BIGNUM *, - BN_CTX *, BN_MONT_CTX *)); + DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, + BN_MONT_CTX *); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_bn_mod_exp( + DSA_METHOD *dsam, + int (*bn_mod_exp)(DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *)); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_init(DSA_METHOD *dsam, + int (*init)(DSA *)); OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_finish(const DSA_METHOD *dsam))(DSA *); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish)(DSA *)); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_finish(DSA_METHOD *dsam, + int (*finish)(DSA *)); OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))( DSA *, int, const unsigned char *, int, int *, unsigned long *, BN_GENCB *); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_paramgen(DSA_METHOD *dsam, - int (*paramgen)(DSA *, int, const unsigned char *, - int, int *, unsigned long *, - BN_GENCB *)); +OSSL_DEPRECATEDIN_3_0 int +DSA_meth_set_paramgen(DSA_METHOD *dsam, + int (*paramgen)(DSA *, int, const unsigned char *, int, + int *, unsigned long *, BN_GENCB *)); OSSL_DEPRECATEDIN_3_0 int (*DSA_meth_get_keygen(const DSA_METHOD *dsam))(DSA *); -OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen)(DSA *)); +OSSL_DEPRECATEDIN_3_0 int DSA_meth_set_keygen(DSA_METHOD *dsam, + int (*keygen)(DSA *)); -# endif +# endif #endif #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/dsaerr.h b/libs/OpenSSL/include/openssl/dsaerr.h index b4221d53..ecc16e05 100644 --- a/libs/OpenSSL/include/openssl/dsaerr.h +++ b/libs/OpenSSL/include/openssl/dsaerr.h @@ -21,21 +21,21 @@ /* * DSA reason codes. */ -# define DSA_R_BAD_FFC_PARAMETERS 114 -# define DSA_R_BAD_Q_VALUE 102 -# define DSA_R_BN_DECODE_ERROR 108 -# define DSA_R_BN_ERROR 109 -# define DSA_R_DECODE_ERROR 104 -# define DSA_R_INVALID_DIGEST_TYPE 106 -# define DSA_R_INVALID_PARAMETERS 112 -# define DSA_R_MISSING_PARAMETERS 101 -# define DSA_R_MISSING_PRIVATE_KEY 111 -# define DSA_R_MODULUS_TOO_LARGE 103 -# define DSA_R_NO_PARAMETERS_SET 107 -# define DSA_R_PARAMETER_ENCODING_ERROR 105 -# define DSA_R_P_NOT_PRIME 115 -# define DSA_R_Q_NOT_PRIME 113 -# define DSA_R_SEED_LEN_SMALL 110 +# define DSA_R_BAD_FFC_PARAMETERS 114 +# define DSA_R_BAD_Q_VALUE 102 +# define DSA_R_BN_DECODE_ERROR 108 +# define DSA_R_BN_ERROR 109 +# define DSA_R_DECODE_ERROR 104 +# define DSA_R_INVALID_DIGEST_TYPE 106 +# define DSA_R_INVALID_PARAMETERS 112 +# define DSA_R_MISSING_PARAMETERS 101 +# define DSA_R_MISSING_PRIVATE_KEY 111 +# define DSA_R_MODULUS_TOO_LARGE 103 +# define DSA_R_NO_PARAMETERS_SET 107 +# define DSA_R_PARAMETER_ENCODING_ERROR 105 +# define DSA_R_P_NOT_PRIME 115 +# define DSA_R_Q_NOT_PRIME 113 +# define DSA_R_SEED_LEN_SMALL 110 #endif #endif diff --git a/libs/OpenSSL/include/openssl/dtls1.h b/libs/OpenSSL/include/openssl/dtls1.h index c4975ca0..35adb0e1 100644 --- a/libs/OpenSSL/include/openssl/dtls1.h +++ b/libs/OpenSSL/include/openssl/dtls1.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_DTLS1_H +# define HEADER_DTLS1_H #endif #include @@ -26,8 +26,8 @@ extern "C" { /* DTLS*_VERSION constants are defined in prov_ssl.h */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DTLS_MIN_VERSION DTLS1_VERSION -# define DTLS_MAX_VERSION DTLS1_2_VERSION +# define DTLS_MIN_VERSION DTLS1_VERSION +# define DTLS_MAX_VERSION DTLS1_2_VERSION #endif #define DTLS1_VERSION_MAJOR 0xFE diff --git a/libs/OpenSSL/include/openssl/e_os2.h b/libs/OpenSSL/include/openssl/e_os2.h index b2f8631f..4447c1c1 100644 --- a/libs/OpenSSL/include/openssl/e_os2.h +++ b/libs/OpenSSL/include/openssl/e_os2.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_E_OS2_H +# define HEADER_E_OS2_H #endif #include @@ -37,7 +37,7 @@ extern "C" { * MS-DOS, such as DJGPP one. */ #if defined(OPENSSL_SYS_MSDOS) -# undef OPENSSL_SYS_UNIX +# undef OPENSSL_SYS_UNIX #endif /* @@ -49,43 +49,43 @@ extern "C" { * we need to avoid the false positive match on Windows. */ #if defined(OPENSSL_SYS_UEFI) -# undef OPENSSL_SYS_UNIX +# undef OPENSSL_SYS_UNIX #elif defined(OPENSSL_SYS_UWIN) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32_UWIN +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WIN32_UWIN #else -# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) -# define OPENSSL_SYS_WIN32_CYGWIN -# else -# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) -# undef OPENSSL_SYS_UNIX -# if !defined(OPENSSL_SYS_WIN32) -# define OPENSSL_SYS_WIN32 -# endif -# endif -# if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) -# undef OPENSSL_SYS_UNIX -# if !defined(OPENSSL_SYS_WIN64) -# define OPENSSL_SYS_WIN64 -# endif -# endif -# if defined(OPENSSL_SYS_WINNT) -# undef OPENSSL_SYS_UNIX -# endif -# if defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# endif +# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) +# define OPENSSL_SYS_WIN32_CYGWIN +# else +# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) +# undef OPENSSL_SYS_UNIX +# if !defined(OPENSSL_SYS_WIN32) +# define OPENSSL_SYS_WIN32 +# endif # endif +# if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) +# undef OPENSSL_SYS_UNIX +# if !defined(OPENSSL_SYS_WIN64) +# define OPENSSL_SYS_WIN64 +# endif +# endif +# if defined(OPENSSL_SYS_WINNT) +# undef OPENSSL_SYS_UNIX +# endif +# if defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# endif +# endif #endif /* Anything that tries to look like Microsoft is "Windows" */ -#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) \ - || defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_SYS_MSDOS -# define OPENSSL_SYS_MSDOS -# endif +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) \ + || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_WINDOWS +# ifndef OPENSSL_SYS_MSDOS +# define OPENSSL_SYS_MSDOS +# endif #endif /* @@ -94,64 +94,64 @@ extern "C" { * requires some macro to be used. */ #ifdef OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_OPT_WINDLL -# if defined(_WINDLL) /* This is used when building OpenSSL to \ - * indicate that DLL linkage should be used */ -# define OPENSSL_OPT_WINDLL -# endif +# ifndef OPENSSL_OPT_WINDLL +# if defined(_WINDLL) /* This is used when building OpenSSL to \ + * indicate that DLL linkage should be used */ +# define OPENSSL_OPT_WINDLL # endif +# endif #endif /* ------------------------------- OpenVMS -------------------------------- */ #if defined(__VMS) || defined(VMS) -# if !defined(OPENSSL_SYS_VMS) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_VMS -# endif -# if defined(__DECC) -# define OPENSSL_SYS_VMS_DECC -# elif defined(__DECCXX) -# define OPENSSL_SYS_VMS_DECC -# define OPENSSL_SYS_VMS_DECCXX -# else -# define OPENSSL_SYS_VMS_NODECC -# endif +# if !defined(OPENSSL_SYS_VMS) +# undef OPENSSL_SYS_UNIX +# define OPENSSL_SYS_VMS +# endif +# if defined(__DECC) +# define OPENSSL_SYS_VMS_DECC +# elif defined(__DECCXX) +# define OPENSSL_SYS_VMS_DECC +# define OPENSSL_SYS_VMS_DECCXX +# else +# define OPENSSL_SYS_VMS_NODECC +# endif #endif /* -------------------------------- Unix ---------------------------------- */ #ifdef OPENSSL_SYS_UNIX -# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) -# define OPENSSL_SYS_LINUX -# endif -# if defined(_AIX) && !defined(OPENSSL_SYS_AIX) -# define OPENSSL_SYS_AIX -# endif +# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) +# define OPENSSL_SYS_LINUX +# endif +# if defined(_AIX) && !defined(OPENSSL_SYS_AIX) +# define OPENSSL_SYS_AIX +# endif #endif /* -------------------------------- VOS ----------------------------------- */ #if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) -# define OPENSSL_SYS_VOS -# ifdef __HPPA__ -# define OPENSSL_SYS_VOS_HPPA -# endif -# ifdef __IA32__ -# define OPENSSL_SYS_VOS_IA32 -# endif +# define OPENSSL_SYS_VOS +# ifdef __HPPA__ +# define OPENSSL_SYS_VOS_HPPA +# endif +# ifdef __IA32__ +# define OPENSSL_SYS_VOS_IA32 +# endif #endif /* ---------------------------- HP NonStop -------------------------------- */ #ifdef __TANDEM -# ifdef _STRING -# include -# endif -# define OPENSSL_USE_BUILD_DATE -# if defined(OPENSSL_THREADS) && defined(_SPT_MODEL_) -# define SPT_THREAD_SIGNAL 1 -# define SPT_THREAD_AWARE 1 -# include -# elif defined(OPENSSL_THREADS) && defined(_PUT_MODEL_) -# include -# endif +# ifdef _STRING +# include +# endif +# define OPENSSL_USE_BUILD_DATE +# if defined(OPENSSL_THREADS) && defined(_SPT_MODEL_) +# define SPT_THREAD_SIGNAL 1 +# define SPT_THREAD_AWARE 1 +# include +# elif defined(OPENSSL_THREADS) && defined(_PUT_MODEL_) +# include +# endif #endif /** @@ -178,43 +178,43 @@ extern "C" { */ #if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) -# define OPENSSL_EXPORT extern __declspec(dllexport) -# define OPENSSL_EXTERN extern __declspec(dllimport) +# define OPENSSL_EXPORT extern __declspec(dllexport) +# define OPENSSL_EXTERN extern __declspec(dllimport) #else -# define OPENSSL_EXPORT extern -# define OPENSSL_EXTERN extern +# define OPENSSL_EXPORT extern +# define OPENSSL_EXTERN extern #endif #ifdef _WIN32 -# ifdef _WIN64 -# define ossl_ssize_t __int64 -# define OSSL_SSIZE_MAX _I64_MAX -# else -# define ossl_ssize_t int -# define OSSL_SSIZE_MAX INT_MAX -# endif +# ifdef _WIN64 +# define ossl_ssize_t __int64 +# define OSSL_SSIZE_MAX _I64_MAX +# else +# define ossl_ssize_t int +# define OSSL_SSIZE_MAX INT_MAX +# endif #endif #if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t) -# define ossl_ssize_t INTN -# define OSSL_SSIZE_MAX MAX_INTN +# define ossl_ssize_t INTN +# define OSSL_SSIZE_MAX MAX_INTN #endif #ifndef ossl_ssize_t -# define ossl_ssize_t ssize_t -# if defined(SSIZE_MAX) -# define OSSL_SSIZE_MAX SSIZE_MAX -# elif defined(_POSIX_SSIZE_MAX) -# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX -# else -# define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1)) -# endif +# define ossl_ssize_t ssize_t +# if defined(SSIZE_MAX) +# define OSSL_SSIZE_MAX SSIZE_MAX +# elif defined(_POSIX_SSIZE_MAX) +# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX +# else +# define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1)) +# endif #endif #if defined(UNUSEDRESULT_DEBUG) -# define __owur __attribute__((__warn_unused_result__)) +# define __owur __attribute__((__warn_unused_result__)) #else -# define __owur +# define __owur #endif /* Standard integer types */ @@ -229,12 +229,13 @@ typedef INT32 int32_t; typedef UINT32 uint32_t; typedef INT64 int64_t; typedef UINT64 uint64_t; -#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__osf__) \ - || defined(__sgi) || defined(__hpux) || defined(OPENSSL_SYS_VMS) || defined(__OpenBSD__) -# include -# undef OPENSSL_NO_INTTYPES_H +#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ + || defined(__osf__) || defined(__sgi) || defined(__hpux) \ + || defined(OPENSSL_SYS_VMS) || defined(__OpenBSD__) +# include +# undef OPENSSL_NO_INTTYPES_H /* Because the specs say that inttypes.h includes stdint.h if present */ -# undef OPENSSL_NO_STDINT_H +# undef OPENSSL_NO_STDINT_H #elif defined(_MSC_VER) && _MSC_VER < 1600 /* * minimally required typdefs for systems not supporting inttypes.h or @@ -249,14 +250,14 @@ typedef unsigned int uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #elif defined(OPENSSL_SYS_TANDEM) -# include -# include +# include +# include #else -# include -# undef OPENSSL_NO_STDINT_H +# include +# undef OPENSSL_NO_STDINT_H #endif -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && defined(INTMAX_MAX) \ - && defined(UINTMAX_MAX) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L \ + && defined(INTMAX_MAX) && defined(UINTMAX_MAX) typedef intmax_t ossl_intmax_t; typedef uintmax_t ossl_uintmax_t; #else @@ -267,38 +268,39 @@ typedef uint64_t ossl_uintmax_t; /* ossl_inline: portable inline definition usable in public headers */ #if !defined(inline) && !defined(__cplusplus) -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* just use inline */ -# define ossl_inline inline -# elif defined(__GNUC__) && __GNUC__ >= 2 -# define ossl_inline __inline__ -# elif defined(_MSC_VER) +# define ossl_inline inline +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define ossl_inline __inline__ +# elif defined(_MSC_VER) /* * Visual Studio: inline is available in C++ only, however * __inline is available for C, see * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx */ -# define ossl_inline __inline -# else -# define ossl_inline -# endif +# define ossl_inline __inline +# else +# define ossl_inline +# endif #else -# define ossl_inline inline +# define ossl_inline inline #endif -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) -# define ossl_noreturn _Noreturn +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ + && !defined(__cplusplus) +# define ossl_noreturn _Noreturn #elif defined(__GNUC__) && __GNUC__ >= 2 -# define ossl_noreturn __attribute__((noreturn)) +# define ossl_noreturn __attribute__((noreturn)) #else -# define ossl_noreturn +# define ossl_noreturn #endif /* ossl_unused: portable unused attribute for use in public headers */ #if defined(__GNUC__) -# define ossl_unused __attribute__((unused)) +# define ossl_unused __attribute__((unused)) #else -# define ossl_unused +# define ossl_unused #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/ebcdic.h b/libs/OpenSSL/include/openssl/ebcdic.h index 3613863c..614bcd8b 100644 --- a/libs/OpenSSL/include/openssl/ebcdic.h +++ b/libs/OpenSSL/include/openssl/ebcdic.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_EBCDIC_H +# define HEADER_EBCDIC_H #endif #include diff --git a/libs/OpenSSL/include/openssl/ec.h b/libs/OpenSSL/include/openssl/ec.h index dc1a77f5..54f6bb2c 100644 --- a/libs/OpenSSL/include/openssl/ec.h +++ b/libs/OpenSSL/include/openssl/ec.h @@ -14,7 +14,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_EC_H +# define HEADER_EC_H #endif #include @@ -44,7 +44,8 @@ int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len); int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len); -int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len); +int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, + int len); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); @@ -76,37 +77,37 @@ int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm); * for the encoding of a elliptic curve point (x,y) */ typedef enum { - /** the point is encoded as z||x, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_COMPRESSED = 2, - /** the point is encoded as z||x||y, where z is the octet 0x04 */ - POINT_CONVERSION_UNCOMPRESSED = 4, - /** the point is encoded as z||x||y, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_HYBRID = 6 + /** the point is encoded as z||x, where the octet z specifies + * which solution of the quadratic equation y is */ + POINT_CONVERSION_COMPRESSED = 2, + /** the point is encoded as z||x||y, where z is the octet 0x04 */ + POINT_CONVERSION_UNCOMPRESSED = 4, + /** the point is encoded as z||x||y, where the octet z specifies + * which solution of the quadratic equation y is */ + POINT_CONVERSION_HYBRID = 6 } point_conversion_form_t; const char *OSSL_EC_curve_nid2name(int nid); #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifndef OPENSSL_NO_EC -# include -# include -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include -# endif -# include +# include +# include +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# endif +# include -# ifndef OPENSSL_ECC_MAX_FIELD_BITS -# define OPENSSL_ECC_MAX_FIELD_BITS 661 -# endif +# ifndef OPENSSL_ECC_MAX_FIELD_BITS +# define OPENSSL_ECC_MAX_FIELD_BITS 661 +# endif -# include -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# include +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct ec_method_st EC_METHOD; -# endif +# endif typedef struct ec_group_st EC_GROUP; typedef struct ec_point_st EC_POINT; typedef struct ecpk_parameters_st ECPKPARAMETERS; @@ -116,7 +117,7 @@ typedef struct ec_parameters_st ECPARAMETERS; /* EC_METHODs for curves over GF(p) */ /********************************************************************/ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Returns the basic GFp ec methods which provides the basis for the * optimized methods. * \return EC_METHOD object @@ -133,7 +134,7 @@ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_mont_method(void); */ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nist_method(void); -# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 /** Returns 64-bit optimized methods for nistp224 * \return EC_METHOD object */ @@ -148,9 +149,9 @@ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp256_method(void); * \return EC_METHOD object */ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void); -# endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */ +# endif /* OPENSSL_NO_EC_NISTP_64_GCC_128 */ -# ifndef OPENSSL_NO_EC2M +# ifndef OPENSSL_NO_EC2M /********************************************************************/ /* EC_METHOD for curves over GF(2^m) */ /********************************************************************/ @@ -160,7 +161,7 @@ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GFp_nistp521_method(void); */ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GF2m_simple_method(void); -# endif +# endif /********************************************************************/ /* EC_GROUP functions */ @@ -182,14 +183,15 @@ OSSL_DEPRECATEDIN_3_0 void EC_GROUP_clear_free(EC_GROUP *group); * \param group EC_GROUP object * \return EC_METHOD used in this EC_GROUP object. */ -OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); +OSSL_DEPRECATEDIN_3_0 const EC_METHOD * +EC_GROUP_method_of(const EC_GROUP *group); /** Returns the field type of the EC_METHOD. * \param meth EC_METHOD object * \return NID of the underlying field type OID. */ OSSL_DEPRECATEDIN_3_0 int EC_METHOD_get_field_type(const EC_METHOD *meth); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /** Frees a EC_GROUP object * \param group EC_GROUP object to be freed. @@ -218,8 +220,8 @@ EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); * in the group of all points on the elliptic curve. * \return 1 on success and 0 if an error occurred */ -int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, - const BIGNUM *cofactor); +int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, + const BIGNUM *order, const BIGNUM *cofactor); /** Returns the generator of a EC_GROUP object. * \param group EC_GROUP object @@ -294,7 +296,8 @@ int EC_GROUP_get_field_type(const EC_GROUP *group); void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); int EC_GROUP_get_asn1_flag(const EC_GROUP *group); -void EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form); +void EC_GROUP_set_point_conversion_form(EC_GROUP *group, + point_conversion_form_t form); point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); @@ -311,8 +314,8 @@ size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, - BN_CTX *ctx); +int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); /** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp) * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) @@ -324,9 +327,10 @@ int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); +int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, + BN_CTX *ctx); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve * \param group EC_GROUP object * \param p BIGNUM with the prime number (GFp) or the polynomial @@ -336,7 +340,9 @@ int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, B * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GFp(EC_GROUP *group, + const BIGNUM *p, + const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve @@ -348,10 +354,11 @@ OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM * * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, + BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); -# ifndef OPENSSL_NO_EC2M +# ifndef OPENSSL_NO_EC2M /** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve * \param group EC_GROUP object * \param p BIGNUM with the prime number (GFp) or the polynomial @@ -361,7 +368,9 @@ OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM * * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, + const BIGNUM *p, + const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve @@ -373,10 +382,11 @@ OSSL_DEPRECATEDIN_3_0 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, + BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); -# endif /* OPENSSL_NO_EC2M */ -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_EC2M */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /** Returns the number of bits needed to represent a field element * \param group EC_GROUP object @@ -419,8 +429,9 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); * \param ctx BN_CTX object (optional) * \return newly created EC_GROUP object with the specified parameters */ -EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -# ifndef OPENSSL_NO_EC2M +EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); +# ifndef OPENSSL_NO_EC2M /** Creates a new EC_GROUP object with the specified parameters defined * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) * \param p BIGNUM with the polynomial defining the underlying field @@ -429,8 +440,9 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM * \param ctx BN_CTX object (optional) * \return newly created EC_GROUP object with the specified parameters */ -EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -# endif +EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); +# endif /** * Creates a EC_GROUP object with a curve specified by parameters. @@ -442,8 +454,8 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM * \return newly created EC_GROUP object with specified parameters or NULL * if an error occurred */ -EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], OSSL_LIB_CTX *libctx, - const char *propq); +EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], + OSSL_LIB_CTX *libctx, const char *propq); /** * Creates a EC_GROUP object with a curve specified by a NID @@ -454,7 +466,8 @@ EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], OSSL_LIB_CTX *libc * \return newly created EC_GROUP object with specified curve or NULL * if an error occurred */ -EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq, int nid); +EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq, + int nid); /** * Creates a EC_GROUP object with a curve specified by a NID. Same as @@ -479,7 +492,8 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); * \return pointer to the new ECPARAMETERS object or NULL * if an error occurred. */ -ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, ECPARAMETERS *params); +ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, + ECPARAMETERS *params); /** Creates a new EC_GROUP object from an ECPKPARAMETERS object * \param params pointer to an existing ECPKPARAMETERS object, or NULL @@ -494,7 +508,8 @@ EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); * \return pointer to the new ECPKPARAMETERS object or NULL * if an error occurred. */ -ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, ECPKPARAMETERS *params); +ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, + ECPKPARAMETERS *params); /********************************************************************/ /* handling of internal curves */ @@ -502,8 +517,8 @@ ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, ECPKPARAMETER typedef struct { - int nid; - const char *comment; + int nid; + const char *comment; } EC_builtin_curve; /* @@ -516,7 +531,8 @@ size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); const char *EC_curve_nid2nist(int nid); int EC_curve_nist2nid(const char *name); -int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only, BN_CTX *ctx); +int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only, + BN_CTX *ctx); /********************************************************************/ /* EC_POINT functions */ @@ -560,12 +576,13 @@ EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); */ int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Returns the EC_METHOD used in EC_POINT object * \param point EC_POINT object * \return the EC_METHOD used */ -OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); +OSSL_DEPRECATEDIN_3_0 const EC_METHOD * +EC_POINT_method_of(const EC_POINT *point); /** Sets the jacobian projective coordinates of a EC_POINT over GFp * \param group underlying EC_GROUP object @@ -576,10 +593,10 @@ OSSL_DEPRECATEDIN_3_0 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point) * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - const BIGNUM *y, const BIGNUM *z, - BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, + const BIGNUM *z, BN_CTX *ctx); /** Gets the jacobian projective coordinates of a EC_POINT over GFp * \param group underlying EC_GROUP object @@ -590,11 +607,11 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROU * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BIGNUM *z, - BN_CTX *ctx); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, + const EC_POINT *p, BIGNUM *x, + BIGNUM *y, BIGNUM *z, BN_CTX *ctx); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /** Sets the affine coordinates of an EC_POINT * \param group underlying EC_GROUP object @@ -604,8 +621,9 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROU * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, - const BIGNUM *y, BN_CTX *ctx); +int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, + BN_CTX *ctx); /** Gets the affine coordinates of an EC_POINT. * \param group underlying EC_GROUP object @@ -615,10 +633,10 @@ int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, const BI * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, - BN_CTX *ctx); +int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Sets the affine coordinates of an EC_POINT. A synonym of * EC_POINT_set_affine_coordinates * \param group underlying EC_GROUP object @@ -628,9 +646,10 @@ int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, BI * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, - const BIGNUM *x, const BIGNUM *y, - BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, + BN_CTX *ctx); /** Gets the affine coordinates of an EC_POINT. A synonym of * EC_POINT_get_affine_coordinates @@ -641,10 +660,10 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *gr * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BN_CTX *ctx); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /** Sets the x9.62 compressed coordinates of a EC_POINT * \param group underlying EC_GROUP object @@ -654,10 +673,11 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *gr * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, - int y_bit, BN_CTX *ctx); +int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, + BN_CTX *ctx); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of * EC_POINT_set_compressed_coordinates * \param group underlying EC_GROUP object @@ -667,10 +687,11 @@ int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, cons * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - int y_bit, BN_CTX *ctx); -# ifndef OPENSSL_NO_EC2M +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, + BN_CTX *ctx); +# ifndef OPENSSL_NO_EC2M /** Sets the affine coordinates of an EC_POINT. A synonym of * EC_POINT_set_affine_coordinates * \param group underlying EC_GROUP object @@ -680,9 +701,10 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, - const BIGNUM *x, const BIGNUM *y, - BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, const BIGNUM *y, + BN_CTX *ctx); /** Gets the affine coordinates of an EC_POINT. A synonym of * EC_POINT_get_affine_coordinates @@ -693,9 +715,9 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *g * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *p, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx); /** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of * EC_POINT_set_compressed_coordinates @@ -706,11 +728,12 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *g * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - int y_bit, BN_CTX *ctx); -# endif -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +OSSL_DEPRECATEDIN_3_0 int +EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, + const BIGNUM *x, int y_bit, + BN_CTX *ctx); +# endif +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /** Encodes a EC_POINT object to a octet string * \param group underlying EC_GROUP object @@ -722,8 +745,9 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROU * \param ctx BN_CTX object (optional) * \return the length of the encoded octet string or 0 if an error occurred */ -size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX *ctx); +size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, + point_conversion_form_t form, unsigned char *buf, + size_t len, BN_CTX *ctx); /** Decodes a EC_POINT from a octet string * \param group underlying EC_GROUP object @@ -733,8 +757,8 @@ size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, point_conver * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, const unsigned char *buf, size_t len, - BN_CTX *ctx); +int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, + const unsigned char *buf, size_t len, BN_CTX *ctx); /** Encodes an EC_POINT object to an allocated octet string * \param group underlying EC_GROUP object @@ -745,19 +769,23 @@ int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, const unsigned char * * \return the length of the encoded octet string or 0 if an error occurred */ size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, - point_conversion_form_t form, unsigned char **pbuf, BN_CTX *ctx); + point_conversion_form_t form, unsigned char **pbuf, + BN_CTX *ctx); /* other interfaces to point2oct/oct2point: */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BIGNUM *, BN_CTX *); -OSSL_DEPRECATEDIN_3_0 EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, EC_POINT *, - BN_CTX *); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 BIGNUM *EC_POINT_point2bn(const EC_GROUP *, + const EC_POINT *, + point_conversion_form_t form, + BIGNUM *, BN_CTX *); +OSSL_DEPRECATEDIN_3_0 EC_POINT * +EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, EC_POINT *, BN_CTX *); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, - BN_CTX *); -EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, EC_POINT *, BN_CTX *); +char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, BN_CTX *); +EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, EC_POINT *, + BN_CTX *); /********************************************************************/ /* functions for doing EC_POINT arithmetic */ @@ -771,8 +799,8 @@ EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, EC_POINT *, BN_CTX * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, - BN_CTX *ctx); +int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, + const EC_POINT *b, BN_CTX *ctx); /** Computes the double of a EC_POINT * \param group underlying EC_GROUP object @@ -781,13 +809,14 @@ int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx); +int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, + BN_CTX *ctx); /** Computes the inverse of a EC_POINT * \param group underlying EC_GROUP object - * \param a EC_POINT object to be inverted (it's used for the result as well) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred + * \param a EC_POINT object to be inverted (it's used for the result as + * well) \param ctx BN_CTX object (optional) \return 1 on success and 0 if + * an error occurred */ int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); @@ -804,7 +833,8 @@ int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); * \param ctx BN_CTX object (optional) * \return 1 if the point is on the curve, 0 if not, or -1 on error */ -int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx); +int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, + BN_CTX *ctx); /** Compares two EC_POINTs * \param group underlying EC_GROUP object @@ -813,12 +843,15 @@ int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *c * \param ctx BN_CTX object (optional) * \return 1 if the points are not equal, 0 if they are, or -1 on error */ -int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); +int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, + BN_CTX *ctx); -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); -OSSL_DEPRECATEDIN_3_0 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, - EC_POINT *points[], BN_CTX *ctx); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int EC_POINT_make_affine(const EC_GROUP *group, + EC_POINT *point, BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int EC_POINTs_make_affine(const EC_GROUP *group, + size_t num, EC_POINT *points[], + BN_CTX *ctx); /** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] * \param group underlying EC_GROUP object @@ -830,10 +863,11 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINTs_make_affine(const EC_GROUP *group, size_t nu * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, - size_t num, const EC_POINT *p[], const BIGNUM *m[], +OSSL_DEPRECATEDIN_3_0 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *n, size_t num, + const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /** Computes r = generator * n + q * m * \param group underlying EC_GROUP object @@ -844,23 +878,24 @@ OSSL_DEPRECATEDIN_3_0 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, cons * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, - const BIGNUM *m, BN_CTX *ctx); +int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, + const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Stores multiples of generator for faster point multiplication * \param group EC_GROUP object * \param ctx BN_CTX object (optional) * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int EC_GROUP_precompute_mult(EC_GROUP *group, + BN_CTX *ctx); /** Reports whether a precomputation has been done * \param group EC_GROUP object * \return 1 if a pre-computation has been done and 0 otherwise */ OSSL_DEPRECATEDIN_3_0 int EC_GROUP_have_precompute_mult(const EC_GROUP *group); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /********************************************************************/ /* ASN1 stuff */ @@ -876,57 +911,63 @@ DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) * represent the field elements */ int EC_GROUP_get_basis_type(const EC_GROUP *); -# ifndef OPENSSL_NO_EC2M +# ifndef OPENSSL_NO_EC2M int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); -int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, unsigned int *k2, - unsigned int *k3); -# endif +int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); +# endif EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); -# define d2i_ECPKParameters_bio(bp, x) ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x) -# define i2d_ECPKParameters_bio(bp, x) ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x) -# define d2i_ECPKParameters_fp(fp, x) \ - (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), (void **)(x)) -# define i2d_ECPKParameters_fp(fp, x) \ - ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x)) +# define d2i_ECPKParameters_bio(bp, x) \ + ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x) +# define i2d_ECPKParameters_bio(bp, x) \ + ASN1_i2d_bio_of(EC_GROUP, i2d_ECPKParameters, bp, x) +# define d2i_ECPKParameters_fp(fp, x) \ + (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), \ + (void **)(x)) +# define i2d_ECPKParameters_fp(fp, x) \ + ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x)) -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); -# ifndef OPENSSL_NO_STDIO -OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); -# endif -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print(BIO *bp, const EC_GROUP *x, + int off); +# ifndef OPENSSL_NO_STDIO +OSSL_DEPRECATEDIN_3_0 int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, + int off); +# endif +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /********************************************************************/ /* EC_KEY functions */ /********************************************************************/ /* some values for the encoding_flag */ -# define EC_PKEY_NO_PARAMETERS 0x001 -# define EC_PKEY_NO_PUBKEY 0x002 +# define EC_PKEY_NO_PARAMETERS 0x001 +# define EC_PKEY_NO_PUBKEY 0x002 /* some values for the flags field */ -# define EC_FLAG_SM2_RANGE 0x0004 -# define EC_FLAG_COFACTOR_ECDH 0x1000 -# define EC_FLAG_CHECK_NAMED_GROUP 0x2000 -# define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000 -# define EC_FLAG_CHECK_NAMED_GROUP_MASK \ - (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST) +# define EC_FLAG_SM2_RANGE 0x0004 +# define EC_FLAG_COFACTOR_ECDH 0x1000 +# define EC_FLAG_CHECK_NAMED_GROUP 0x2000 +# define EC_FLAG_CHECK_NAMED_GROUP_NIST 0x4000 +# define EC_FLAG_CHECK_NAMED_GROUP_MASK \ + (EC_FLAG_CHECK_NAMED_GROUP | EC_FLAG_CHECK_NAMED_GROUP_NIST) /* Deprecated flags - it was using 0x01..0x02 */ -# define EC_FLAG_NON_FIPS_ALLOW 0x0000 -# define EC_FLAG_FIPS_CHECKED 0x0000 +# define EC_FLAG_NON_FIPS_ALLOW 0x0000 +# define EC_FLAG_FIPS_CHECKED 0x0000 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** * Creates a new EC_KEY object. * \param ctx The library context for to use for this EC_KEY. May be NULL in * which case the default library context is used. * \return EC_KEY object or NULL if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, const char *propq); +OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_ex(OSSL_LIB_CTX *ctx, + const char *propq); /** * Creates a new EC_KEY object. Same as calling EC_KEY_new_ex with a @@ -941,7 +982,8 @@ OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_flags(EC_KEY *key, int flags); OSSL_DEPRECATEDIN_3_0 void EC_KEY_clear_flags(EC_KEY *key, int flags); -OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key); +OSSL_DEPRECATEDIN_3_0 int +EC_KEY_decoded_from_explicit_params(const EC_KEY *key); /** * Creates a new EC_KEY object using a named curve as underlying @@ -952,8 +994,8 @@ OSSL_DEPRECATEDIN_3_0 int EC_KEY_decoded_from_explicit_params(const EC_KEY *key) * \param nid NID of the named curve. * \return EC_KEY object or NULL if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX *ctx, const char *propq, - int nid); +OSSL_DEPRECATEDIN_3_0 EC_KEY * +EC_KEY_new_by_curve_name_ex(OSSL_LIB_CTX *ctx, const char *propq, int nid); /** * Creates a new EC_KEY object using a named curve as underlying @@ -1020,7 +1062,8 @@ OSSL_DEPRECATEDIN_3_0 const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); * will use an own copy of the BIGNUM). * \return 1 on success and 0 if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_private_key(EC_KEY *key, + const BIGNUM *prv); /** Returns the public key of a EC_KEY object. * \param key the EC_KEY object @@ -1034,18 +1077,22 @@ OSSL_DEPRECATEDIN_3_0 const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); * will use an own copy of the EC_POINT object). * \return 1 on success and 0 if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key(EC_KEY *key, + const EC_POINT *pub); OSSL_DEPRECATEDIN_3_0 unsigned EC_KEY_get_enc_flags(const EC_KEY *key); -OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); -OSSL_DEPRECATEDIN_3_0 point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); -OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); -# endif /*OPENSSL_NO_DEPRECATED_3_0 */ +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_enc_flags(EC_KEY *eckey, + unsigned int flags); +OSSL_DEPRECATEDIN_3_0 point_conversion_form_t +EC_KEY_get_conv_form(const EC_KEY *key); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_conv_form(EC_KEY *eckey, + point_conversion_form_t cform); +# endif /*OPENSSL_NO_DEPRECATED_3_0 */ -# define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) +# define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); OSSL_DEPRECATEDIN_3_0 void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); @@ -1085,8 +1132,8 @@ OSSL_DEPRECATEDIN_3_0 int EC_KEY_can_sign(const EC_KEY *eckey); * \param y public key y coordinate * \return 1 on success and 0 otherwise. */ -OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, - BIGNUM *y); +OSSL_DEPRECATEDIN_3_0 int +EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y); /** Encodes an EC_KEY public key to an allocated octet string * \param key key to encode @@ -1095,7 +1142,8 @@ OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, * \param ctx BN_CTX object (optional) * \return the length of the encoded octet string or 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form, +OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key, + point_conversion_form_t form, unsigned char **pbuf, BN_CTX *ctx); /** Decodes a EC_KEY public key from a octet string @@ -1106,8 +1154,8 @@ OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_ * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len, - BN_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, + size_t len, BN_CTX *ctx); /** Decodes an EC_KEY private key from an octet string * \param key key to decode @@ -1116,7 +1164,8 @@ OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len); +OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, + size_t len); /** Encodes a EC_KEY private key to an octet string * \param key key to encode @@ -1126,14 +1175,16 @@ OSSL_DEPRECATEDIN_3_0 int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, * \return the length of the encoded octet string or 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len); +OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2oct(const EC_KEY *key, + unsigned char *buf, size_t len); /** Encodes an EC_KEY private key to an allocated octet string * \param eckey key to encode * \param pbuf returns pointer to allocated buffer * \return the length of the encoded octet string or 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf); +OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey, + unsigned char **pbuf); /********************************************************************/ /* de- and encoding functions for SEC1 ECPrivateKey */ @@ -1145,7 +1196,8 @@ OSSL_DEPRECATEDIN_3_0 size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char * \param len length of the DER encoded private key * \return the decoded private key or NULL if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); +OSSL_DEPRECATEDIN_3_0 EC_KEY * +d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); /** Encodes a private key object and stores the result in a buffer. * \param key the EC_KEY object to encode @@ -1153,7 +1205,8 @@ OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char * of bytes needed). * \return 1 on success and 0 if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key, unsigned char **out); +OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key, + unsigned char **out); /********************************************************************/ /* de- and encoding functions for EC parameters */ @@ -1166,7 +1219,8 @@ OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey(const EC_KEY *key, unsigned char **ou * \return a EC_KEY object with the decoded parameters or NULL if an error * occurred. */ -OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); +OSSL_DEPRECATEDIN_3_0 EC_KEY * +d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); /** Encodes ec parameter and stores the result in a buffer. * \param key the EC_KEY object with ec parameters to encode @@ -1174,7 +1228,8 @@ OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char * of bytes needed). * \return 1 on success and 0 if an error occurred. */ -OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key, unsigned char **out); +OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key, + unsigned char **out); /********************************************************************/ /* de- and encoding functions for EC public key */ @@ -1188,7 +1243,8 @@ OSSL_DEPRECATEDIN_3_0 int i2d_ECParameters(const EC_KEY *key, unsigned char **ou * \return EC_KEY object with decoded public key or NULL if an error * occurred. */ -OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); +OSSL_DEPRECATEDIN_3_0 EC_KEY * +o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); /** Encodes an ec public key in an octet string. * \param key the EC_KEY object with the public key @@ -1196,7 +1252,8 @@ OSSL_DEPRECATEDIN_3_0 EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char * of bytes needed). * \return 1 on success and 0 if an error occurred */ -OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); +OSSL_DEPRECATEDIN_3_0 int i2o_ECPublicKey(const EC_KEY *key, + unsigned char **out); /** Prints out the ec parameters on human readable form. * \param bp BIO object to which the information is printed @@ -1213,7 +1270,7 @@ OSSL_DEPRECATEDIN_3_0 int ECParameters_print(BIO *bp, const EC_KEY *key); */ OSSL_DEPRECATEDIN_3_0 int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); -# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_STDIO /** Prints out the ec parameters on human readable form. * \param fp file descriptor to which the information is printed * \param key EC_KEY object @@ -1228,13 +1285,14 @@ OSSL_DEPRECATEDIN_3_0 int ECParameters_print_fp(FILE *fp, const EC_KEY *key); * \return 1 on success and 0 if an error occurred */ OSSL_DEPRECATEDIN_3_0 int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); -# endif /* OPENSSL_NO_STDIO */ +# endif /* OPENSSL_NO_STDIO */ OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_OpenSSL(void); OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_default_method(void); OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); OSSL_DEPRECATEDIN_3_0 const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); -OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_method(EC_KEY *key, + const EC_KEY_METHOD *meth); OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_method(ENGINE *engine); /** The old name for ecdh_KDF_X9_63 @@ -1242,14 +1300,15 @@ OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_method(ENGINE *engine); * it is actually specified in ANSI X9.63. * This identifier is retained for backwards compatibility */ -OSSL_DEPRECATEDIN_3_0 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, const unsigned char *Z, - size_t Zlen, const unsigned char *sinfo, size_t sinfolen, - const EVP_MD *md); +OSSL_DEPRECATEDIN_3_0 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + const unsigned char *sinfo, + size_t sinfolen, const EVP_MD *md); -OSSL_DEPRECATEDIN_3_0 int -ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, const EC_KEY *ecdh, - void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +OSSL_DEPRECATEDIN_3_0 int ECDH_compute_key( + void *out, size_t outlen, const EC_POINT *pub_key, const EC_KEY *ecdh, + void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ typedef struct ECDSA_SIG_st ECDSA_SIG; @@ -1272,7 +1331,8 @@ void ECDSA_SIG_free(ECDSA_SIG *sig); */ DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG) - /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies *pp + /** d2i_ECDSA_SIG decodes an ECDSA signature (note: this function modifies + * *pp * (*pp += len)). * \param sig pointer to ECDSA_SIG pointer (may be NULL) * \param pp memory buffer with the DER encoded signature @@ -1285,7 +1345,8 @@ DECLARE_ASN1_ENCODE_FUNCTIONS_only(ECDSA_SIG, ECDSA_SIG) * \param pr pointer to BIGNUM pointer for r (may be NULL) * \param ps pointer to BIGNUM pointer for s (may be NULL) */ - void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); + void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, + const BIGNUM **ps); /** Accessor for r field of ECDSA_SIG * \param sig pointer to ECDSA_SIG structure @@ -1304,7 +1365,7 @@ const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); */ int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /** Computes the ECDSA signature of the given hash value using * the supplied private key and returns the created signature. * \param dgst pointer to the hash value @@ -1312,8 +1373,8 @@ int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); * \param eckey EC_KEY object containing a private EC key * \return pointer to a ECDSA_SIG structure or NULL if an error occurred */ -OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len, - EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, + int dgst_len, EC_KEY *eckey); /** Computes ECDSA signature of a given hash value using the supplied * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). @@ -1325,9 +1386,9 @@ OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dg * \param eckey EC_KEY object containing a private EC key * \return pointer to a ECDSA_SIG structure or NULL if an error occurred */ -OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, - const BIGNUM *kinv, const BIGNUM *rp, - EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 ECDSA_SIG * +ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, const BIGNUM *kinv, + const BIGNUM *rp, EC_KEY *eckey); /** Verifies that the supplied signature is a valid ECDSA * signature of the supplied hash value using the supplied public key. @@ -1338,8 +1399,9 @@ OSSL_DEPRECATEDIN_3_0 ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int * \return 1 if the signature is valid, 0 if the signature is invalid * and -1 on error */ -OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, + int dgst_len, const ECDSA_SIG *sig, + EC_KEY *eckey); /** Precompute parts of the signing operation * \param eckey EC_KEY object containing a private EC key @@ -1348,7 +1410,8 @@ OSSL_DEPRECATEDIN_3_0 int ECDSA_do_verify(const unsigned char *dgst, int dgst_le * \param rp BIGNUM pointer for x coordinate of k * generator * \return 1 on success and 0 otherwise */ -OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp); +OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, + BIGNUM **kinv, BIGNUM **rp); /** Computes ECDSA signature of a given hash value using the supplied * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). @@ -1360,8 +1423,9 @@ OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM ** * \param eckey EC_KEY object containing a private EC key * \return 1 on success and 0 otherwise */ -OSSL_DEPRECATEDIN_3_0 int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 int ECDSA_sign(int type, const unsigned char *dgst, + int dgstlen, unsigned char *sig, + unsigned int *siglen, EC_KEY *eckey); /** Computes ECDSA signature of a given hash value using the supplied * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). @@ -1376,9 +1440,11 @@ OSSL_DEPRECATEDIN_3_0 int ECDSA_sign(int type, const unsigned char *dgst, int dg * \param eckey EC_KEY object containing a private EC key * \return 1 on success and 0 otherwise */ -OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_ex(int type, const unsigned char *dgst, + int dgstlen, unsigned char *sig, + unsigned int *siglen, + const BIGNUM *kinv, const BIGNUM *rp, + EC_KEY *eckey); /** Verifies that the given signature is valid ECDSA signature * of the supplied hash value using the specified public key. @@ -1391,8 +1457,9 @@ OSSL_DEPRECATEDIN_3_0 int ECDSA_sign_ex(int type, const unsigned char *dgst, int * \return 1 if the signature is valid, 0 if the signature is invalid * and -1 on error */ -OSSL_DEPRECATEDIN_3_0 int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, - const unsigned char *sig, int siglen, EC_KEY *eckey); +OSSL_DEPRECATEDIN_3_0 int ECDSA_verify(int type, const unsigned char *dgst, + int dgstlen, const unsigned char *sig, + int siglen, EC_KEY *eckey); /** Returns the maximum length of the DER encoded signature * \param eckey EC_KEY object @@ -1404,10 +1471,12 @@ OSSL_DEPRECATEDIN_3_0 int ECDSA_size(const EC_KEY *eckey); /* EC_KEY_METHOD constructors, destructors, writers and accessors */ /********************************************************************/ -OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); +OSSL_DEPRECATEDIN_3_0 EC_KEY_METHOD * +EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); OSSL_DEPRECATEDIN_3_0 void -EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth, int (*init)(EC_KEY *key), void (*finish)(EC_KEY *key), +EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth, int (*init)(EC_KEY *key), + void (*finish)(EC_KEY *key), int (*copy)(EC_KEY *dest, const EC_KEY *src), int (*set_group)(EC_KEY *key, const EC_GROUP *grp), int (*set_private)(EC_KEY *key, const BIGNUM *priv_key), @@ -1416,69 +1485,79 @@ EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth, int (*init)(EC_KEY *key), void (*fin OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, int (*keygen)(EC_KEY *key)); -OSSL_DEPRECATEDIN_3_0 void -EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth, - int (*ckey)(unsigned char **psec, size_t *pseclen, - const EC_POINT *pub_key, const EC_KEY *ecdh)); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_compute_key( + EC_KEY_METHOD *meth, + int (*ckey)(unsigned char **psec, size_t *pseclen, const EC_POINT *pub_key, + const EC_KEY *ecdh)); OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_sign( EC_KEY_METHOD *meth, - int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char *sig, - unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey), - int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp), - ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len, const BIGNUM *in_kinv, - const BIGNUM *in_r, EC_KEY *eckey)); + int (*sign)(int type, const unsigned char *dgst, int dlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *r, EC_KEY *eckey), + int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp), + ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len, + const BIGNUM *in_kinv, const BIGNUM *in_r, + EC_KEY *eckey)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_set_verify( + EC_KEY_METHOD *meth, + int (*verify)(int type, const unsigned char *dgst, int dgst_len, + const unsigned char *sigbuf, int sig_len, EC_KEY *eckey), + int (*verify_sig)(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey)); + +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_init( + const EC_KEY_METHOD *meth, int (**pinit)(EC_KEY *key), + void (**pfinish)(EC_KEY *key), + int (**pcopy)(EC_KEY *dest, const EC_KEY *src), + int (**pset_group)(EC_KEY *key, const EC_GROUP *grp), + int (**pset_private)(EC_KEY *key, const BIGNUM *priv_key), + int (**pset_public)(EC_KEY *key, const EC_POINT *pub_key)); OSSL_DEPRECATEDIN_3_0 void -EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth, - int (*verify)(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int sig_len, EC_KEY *eckey), - int (*verify_sig)(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey)); +EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth, + int (**pkeygen)(EC_KEY *key)); -OSSL_DEPRECATEDIN_3_0 void -EC_KEY_METHOD_get_init(const EC_KEY_METHOD *meth, int (**pinit)(EC_KEY *key), - void (**pfinish)(EC_KEY *key), - int (**pcopy)(EC_KEY *dest, const EC_KEY *src), - int (**pset_group)(EC_KEY *key, const EC_GROUP *grp), - int (**pset_private)(EC_KEY *key, const BIGNUM *priv_key), - int (**pset_public)(EC_KEY *key, const EC_POINT *pub_key)); - -OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth, - int (**pkeygen)(EC_KEY *key)); - -OSSL_DEPRECATEDIN_3_0 void -EC_KEY_METHOD_get_compute_key(const EC_KEY_METHOD *meth, - int (**pck)(unsigned char **psec, size_t *pseclen, - const EC_POINT *pub_key, const EC_KEY *ecdh)); +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_compute_key( + const EC_KEY_METHOD *meth, + int (**pck)(unsigned char **psec, size_t *pseclen, const EC_POINT *pub_key, + const EC_KEY *ecdh)); OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_sign( const EC_KEY_METHOD *meth, - int (**psign)(int type, const unsigned char *dgst, int dlen, unsigned char *sig, - unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey), - int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp), - ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, int dgst_len, const BIGNUM *in_kinv, - const BIGNUM *in_r, EC_KEY *eckey)); + int (**psign)(int type, const unsigned char *dgst, int dlen, + unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *r, EC_KEY *eckey), + int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp), + ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, int dgst_len, + const BIGNUM *in_kinv, const BIGNUM *in_r, + EC_KEY *eckey)); -OSSL_DEPRECATEDIN_3_0 void -EC_KEY_METHOD_get_verify(const EC_KEY_METHOD *meth, - int (**pverify)(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int sig_len, EC_KEY *eckey), - int (**pverify_sig)(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey)); -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_verify( + const EC_KEY_METHOD *meth, + int (**pverify)(int type, const unsigned char *dgst, int dgst_len, + const unsigned char *sigbuf, int sig_len, EC_KEY *eckey), + int (**pverify_sig)(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey)); +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -# define EVP_EC_gen(curve) EVP_PKEY_Q_keygen(NULL, NULL, "EC", (char *)(strstr(curve, ""))) +# define EVP_EC_gen(curve) \ + EVP_PKEY_Q_keygen(NULL, NULL, "EC", (char *)(strstr(curve, ""))) /* strstr is used to enable type checking for the variadic string arg */ -# define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, d2i_ECParameters, x) +# define ECParameters_dup(x) \ + ASN1_dup_of(EC_KEY, i2d_ECParameters, d2i_ECParameters, x) -# ifndef __cplusplus -# if defined(__SUNPRO_C) -# if __SUNPRO_C >= 0x520 -# pragma error_messages(default, E_ARRAY_OF_INCOMPLETE_NONAME, E_ARRAY_OF_INCOMPLETE) -# endif -# endif +# ifndef __cplusplus +# if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages(default, E_ARRAY_OF_INCOMPLETE_NONAME, \ + E_ARRAY_OF_INCOMPLETE) +# endif # endif +# endif #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/ecerr.h b/libs/OpenSSL/include/openssl/ecerr.h index 1c18ba5d..a9d8bcdb 100644 --- a/libs/OpenSSL/include/openssl/ecerr.h +++ b/libs/OpenSSL/include/openssl/ecerr.h @@ -21,81 +21,81 @@ /* * EC reason codes. */ -# define EC_R_ASN1_ERROR 115 -# define EC_R_BAD_SIGNATURE 156 -# define EC_R_BIGNUM_OUT_OF_RANGE 144 -# define EC_R_BUFFER_TOO_SMALL 100 -# define EC_R_CANNOT_INVERT 165 -# define EC_R_COORDINATES_OUT_OF_RANGE 146 -# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160 -# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDSA 170 -# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159 -# define EC_R_DECODE_ERROR 142 -# define EC_R_DISCRIMINANT_IS_ZERO 118 -# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 -# define EC_R_EXPLICIT_PARAMS_NOT_SUPPORTED 127 -# define EC_R_FAILED_MAKING_PUBLIC_KEY 166 -# define EC_R_FIELD_TOO_LARGE 143 -# define EC_R_GF2M_NOT_SUPPORTED 147 -# define EC_R_GROUP2PKPARAMETERS_FAILURE 120 -# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 -# define EC_R_INCOMPATIBLE_OBJECTS 101 -# define EC_R_INVALID_A 168 -# define EC_R_INVALID_ARGUMENT 112 -# define EC_R_INVALID_B 169 -# define EC_R_INVALID_COFACTOR 171 -# define EC_R_INVALID_COMPRESSED_POINT 110 -# define EC_R_INVALID_COMPRESSION_BIT 109 -# define EC_R_INVALID_CURVE 141 -# define EC_R_INVALID_DIGEST 151 -# define EC_R_INVALID_DIGEST_TYPE 138 -# define EC_R_INVALID_ENCODING 102 -# define EC_R_INVALID_FIELD 103 -# define EC_R_INVALID_FORM 104 -# define EC_R_INVALID_GENERATOR 173 -# define EC_R_INVALID_GROUP_ORDER 122 -# define EC_R_INVALID_KEY 116 -# define EC_R_INVALID_LENGTH 117 -# define EC_R_INVALID_NAMED_GROUP_CONVERSION 174 -# define EC_R_INVALID_OUTPUT_LENGTH 161 -# define EC_R_INVALID_P 172 -# define EC_R_INVALID_PEER_KEY 133 -# define EC_R_INVALID_PENTANOMIAL_BASIS 132 -# define EC_R_INVALID_PRIVATE_KEY 123 -# define EC_R_INVALID_SEED 175 -# define EC_R_INVALID_TRINOMIAL_BASIS 137 -# define EC_R_KDF_PARAMETER_ERROR 148 -# define EC_R_KEYS_NOT_SET 140 -# define EC_R_LADDER_POST_FAILURE 136 -# define EC_R_LADDER_PRE_FAILURE 153 -# define EC_R_LADDER_STEP_FAILURE 162 -# define EC_R_MISSING_OID 167 -# define EC_R_MISSING_PARAMETERS 124 -# define EC_R_MISSING_PRIVATE_KEY 125 -# define EC_R_NEED_NEW_SETUP_VALUES 157 -# define EC_R_NOT_A_NIST_PRIME 135 -# define EC_R_NOT_IMPLEMENTED 126 -# define EC_R_NOT_INITIALIZED 111 -# define EC_R_NO_PARAMETERS_SET 139 -# define EC_R_NO_PRIVATE_VALUE 154 -# define EC_R_OPERATION_NOT_SUPPORTED 152 -# define EC_R_PASSED_NULL_PARAMETER 134 -# define EC_R_PEER_KEY_ERROR 149 -# define EC_R_POINT_ARITHMETIC_FAILURE 155 -# define EC_R_POINT_AT_INFINITY 106 -# define EC_R_POINT_COORDINATES_BLIND_FAILURE 163 -# define EC_R_POINT_IS_NOT_ON_CURVE 107 -# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158 -# define EC_R_SHARED_INFO_ERROR 150 -# define EC_R_SLOT_FULL 108 -# define EC_R_UNDEFINED_GENERATOR 113 -# define EC_R_UNDEFINED_ORDER 128 -# define EC_R_UNKNOWN_COFACTOR 164 -# define EC_R_UNKNOWN_GROUP 129 -# define EC_R_UNKNOWN_ORDER 114 -# define EC_R_UNSUPPORTED_FIELD 131 -# define EC_R_WRONG_CURVE_PARAMETERS 145 -# define EC_R_WRONG_ORDER 130 +# define EC_R_ASN1_ERROR 115 +# define EC_R_BAD_SIGNATURE 156 +# define EC_R_BIGNUM_OUT_OF_RANGE 144 +# define EC_R_BUFFER_TOO_SMALL 100 +# define EC_R_CANNOT_INVERT 165 +# define EC_R_COORDINATES_OUT_OF_RANGE 146 +# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160 +# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDSA 170 +# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159 +# define EC_R_DECODE_ERROR 142 +# define EC_R_DISCRIMINANT_IS_ZERO 118 +# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 +# define EC_R_EXPLICIT_PARAMS_NOT_SUPPORTED 127 +# define EC_R_FAILED_MAKING_PUBLIC_KEY 166 +# define EC_R_FIELD_TOO_LARGE 143 +# define EC_R_GF2M_NOT_SUPPORTED 147 +# define EC_R_GROUP2PKPARAMETERS_FAILURE 120 +# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 +# define EC_R_INCOMPATIBLE_OBJECTS 101 +# define EC_R_INVALID_A 168 +# define EC_R_INVALID_ARGUMENT 112 +# define EC_R_INVALID_B 169 +# define EC_R_INVALID_COFACTOR 171 +# define EC_R_INVALID_COMPRESSED_POINT 110 +# define EC_R_INVALID_COMPRESSION_BIT 109 +# define EC_R_INVALID_CURVE 141 +# define EC_R_INVALID_DIGEST 151 +# define EC_R_INVALID_DIGEST_TYPE 138 +# define EC_R_INVALID_ENCODING 102 +# define EC_R_INVALID_FIELD 103 +# define EC_R_INVALID_FORM 104 +# define EC_R_INVALID_GENERATOR 173 +# define EC_R_INVALID_GROUP_ORDER 122 +# define EC_R_INVALID_KEY 116 +# define EC_R_INVALID_LENGTH 117 +# define EC_R_INVALID_NAMED_GROUP_CONVERSION 174 +# define EC_R_INVALID_OUTPUT_LENGTH 161 +# define EC_R_INVALID_P 172 +# define EC_R_INVALID_PEER_KEY 133 +# define EC_R_INVALID_PENTANOMIAL_BASIS 132 +# define EC_R_INVALID_PRIVATE_KEY 123 +# define EC_R_INVALID_SEED 175 +# define EC_R_INVALID_TRINOMIAL_BASIS 137 +# define EC_R_KDF_PARAMETER_ERROR 148 +# define EC_R_KEYS_NOT_SET 140 +# define EC_R_LADDER_POST_FAILURE 136 +# define EC_R_LADDER_PRE_FAILURE 153 +# define EC_R_LADDER_STEP_FAILURE 162 +# define EC_R_MISSING_OID 167 +# define EC_R_MISSING_PARAMETERS 124 +# define EC_R_MISSING_PRIVATE_KEY 125 +# define EC_R_NEED_NEW_SETUP_VALUES 157 +# define EC_R_NOT_A_NIST_PRIME 135 +# define EC_R_NOT_IMPLEMENTED 126 +# define EC_R_NOT_INITIALIZED 111 +# define EC_R_NO_PARAMETERS_SET 139 +# define EC_R_NO_PRIVATE_VALUE 154 +# define EC_R_OPERATION_NOT_SUPPORTED 152 +# define EC_R_PASSED_NULL_PARAMETER 134 +# define EC_R_PEER_KEY_ERROR 149 +# define EC_R_POINT_ARITHMETIC_FAILURE 155 +# define EC_R_POINT_AT_INFINITY 106 +# define EC_R_POINT_COORDINATES_BLIND_FAILURE 163 +# define EC_R_POINT_IS_NOT_ON_CURVE 107 +# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158 +# define EC_R_SHARED_INFO_ERROR 150 +# define EC_R_SLOT_FULL 108 +# define EC_R_UNDEFINED_GENERATOR 113 +# define EC_R_UNDEFINED_ORDER 128 +# define EC_R_UNKNOWN_COFACTOR 164 +# define EC_R_UNKNOWN_GROUP 129 +# define EC_R_UNKNOWN_ORDER 114 +# define EC_R_UNSUPPORTED_FIELD 131 +# define EC_R_WRONG_CURVE_PARAMETERS 145 +# define EC_R_WRONG_ORDER 130 #endif #endif diff --git a/libs/OpenSSL/include/openssl/encoder.h b/libs/OpenSSL/include/openssl/encoder.h index 6621f511..05dbe7f5 100644 --- a/libs/OpenSSL/include/openssl/encoder.h +++ b/libs/OpenSSL/include/openssl/encoder.h @@ -14,7 +14,7 @@ #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include #include @@ -26,7 +26,8 @@ extern "C" { #endif -OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *libctx, const char *name, const char *properties); +OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *libctx, const char *name, + const char *properties); int OSSL_ENCODER_up_ref(OSSL_ENCODER *encoder); void OSSL_ENCODER_free(OSSL_ENCODER *encoder); @@ -37,63 +38,83 @@ const char *OSSL_ENCODER_get0_description(const OSSL_ENCODER *kdf); int OSSL_ENCODER_is_a(const OSSL_ENCODER *encoder, const char *name); void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx, - void (*fn)(OSSL_ENCODER *encoder, void *arg), void *arg); -int OSSL_ENCODER_names_do_all(const OSSL_ENCODER *encoder, void (*fn)(const char *name, void *data), + void (*fn)(OSSL_ENCODER *encoder, void *arg), + void *arg); +int OSSL_ENCODER_names_do_all(const OSSL_ENCODER *encoder, + void (*fn)(const char *name, void *data), void *data); const OSSL_PARAM *OSSL_ENCODER_gettable_params(OSSL_ENCODER *encoder); int OSSL_ENCODER_get_params(OSSL_ENCODER *encoder, OSSL_PARAM params[]); const OSSL_PARAM *OSSL_ENCODER_settable_ctx_params(OSSL_ENCODER *encoder); OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new(void); -int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx, const OSSL_PARAM params[]); +int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx, + const OSSL_PARAM params[]); void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx); /* Utilities that help set specific parameters */ -int OSSL_ENCODER_CTX_set_passphrase(OSSL_ENCODER_CTX *ctx, const unsigned char *kstr, size_t klen); -int OSSL_ENCODER_CTX_set_pem_password_cb(OSSL_ENCODER_CTX *ctx, pem_password_cb *cb, void *cbarg); -int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX *ctx, OSSL_PASSPHRASE_CALLBACK *cb, +int OSSL_ENCODER_CTX_set_passphrase(OSSL_ENCODER_CTX *ctx, + const unsigned char *kstr, size_t klen); +int OSSL_ENCODER_CTX_set_pem_password_cb(OSSL_ENCODER_CTX *ctx, + pem_password_cb *cb, void *cbarg); +int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX *ctx, + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); -int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX *ctx, const UI_METHOD *ui_method, +int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX *ctx, + const UI_METHOD *ui_method, void *ui_data); int OSSL_ENCODER_CTX_set_cipher(OSSL_ENCODER_CTX *ctx, const char *cipher_name, const char *propquery); int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection); -int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx, const char *output_type); -int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx, const char *output_structure); +int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx, + const char *output_type); +int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx, + const char *output_structure); /* Utilities to add encoders */ int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder); -int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx, OSSL_LIB_CTX *libctx, const char *propq); +int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx, OSSL_LIB_CTX *libctx, + const char *propq); int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX *ctx); typedef struct ossl_encoder_instance_st OSSL_ENCODER_INSTANCE; -OSSL_ENCODER *OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE *encoder_inst); -void *OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst); -const char *OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst); -const char *OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst); +OSSL_ENCODER * +OSSL_ENCODER_INSTANCE_get_encoder(OSSL_ENCODER_INSTANCE *encoder_inst); +void * +OSSL_ENCODER_INSTANCE_get_encoder_ctx(OSSL_ENCODER_INSTANCE *encoder_inst); +const char * +OSSL_ENCODER_INSTANCE_get_output_type(OSSL_ENCODER_INSTANCE *encoder_inst); +const char * +OSSL_ENCODER_INSTANCE_get_output_structure(OSSL_ENCODER_INSTANCE *encoder_inst); typedef const void *OSSL_ENCODER_CONSTRUCT(OSSL_ENCODER_INSTANCE *encoder_inst, void *construct_data); typedef void OSSL_ENCODER_CLEANUP(void *construct_data); -int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER_CONSTRUCT *construct); -int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx, void *construct_data); -int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER_CLEANUP *cleanup); +int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx, + OSSL_ENCODER_CONSTRUCT *construct); +int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx, + void *construct_data); +int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx, + OSSL_ENCODER_CLEANUP *cleanup); /* Utilities to output the object to encode */ int OSSL_ENCODER_to_bio(OSSL_ENCODER_CTX *ctx, BIO *out); #ifndef OPENSSL_NO_STDIO int OSSL_ENCODER_to_fp(OSSL_ENCODER_CTX *ctx, FILE *fp); #endif -int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata, size_t *pdata_len); +int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata, + size_t *pdata_len); /* * Create the OSSL_ENCODER_CTX with an associated type. This will perform * an implicit OSSL_ENCODER_fetch(), suitable for the object of that type. * This is more useful than calling OSSL_ENCODER_CTX_new(). */ -OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey, int selection, - const char *output_type, const char *output_struct, +OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey, + int selection, + const char *output_type, + const char *output_struct, const char *propquery); #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/engine.h b/libs/OpenSSL/include/openssl/engine.h index 0e5f9bde..0d6b0a4f 100644 --- a/libs/OpenSSL/include/openssl/engine.h +++ b/libs/OpenSSL/include/openssl/engine.h @@ -14,46 +14,46 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_ENGINE_H +# define HEADER_ENGINE_H #endif #include #ifndef OPENSSL_NO_ENGINE -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include -# include -# include -# include -# include -# include -# include -# include -# endif -# include -# include -# include -# include -# ifdef __cplusplus +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# include +# include +# include +# include +# include +# include +# include +# include +# endif +# include +# include +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif /* * These flags are used to control combinations of algorithm (methods) by * bitwise "OR"ing. */ -# define ENGINE_METHOD_RSA (unsigned int)0x0001 -# define ENGINE_METHOD_DSA (unsigned int)0x0002 -# define ENGINE_METHOD_DH (unsigned int)0x0004 -# define ENGINE_METHOD_RAND (unsigned int)0x0008 -# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 -# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 -# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 -# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 -# define ENGINE_METHOD_EC (unsigned int)0x0800 +# define ENGINE_METHOD_RSA (unsigned int)0x0001 +# define ENGINE_METHOD_DSA (unsigned int)0x0002 +# define ENGINE_METHOD_DH (unsigned int)0x0004 +# define ENGINE_METHOD_RAND (unsigned int)0x0008 +# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 +# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 +# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 +# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 +# define ENGINE_METHOD_EC (unsigned int)0x0800 /* Obvious all-or-nothing cases. */ -# define ENGINE_METHOD_ALL (unsigned int)0xFFFF -# define ENGINE_METHOD_NONE (unsigned int)0x0000 +# define ENGINE_METHOD_ALL (unsigned int)0xFFFF +# define ENGINE_METHOD_NONE (unsigned int)0x0000 /* * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used @@ -61,7 +61,7 @@ extern "C" { * set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to * initialise registered ENGINEs if they are not already initialised. */ -# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 +# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 /* ENGINE flags that can be set by ENGINE_set_flags(). */ /* Not used */ @@ -73,7 +73,7 @@ extern "C" { * these control commands on behalf of the ENGINE using their "cmd_defns" * data. */ -# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 +# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 /* * This flag is for ENGINEs who return new duplicate structures when found @@ -85,7 +85,7 @@ extern "C" { * ENGINE_by_id() just increments the existing ENGINE's structural reference * count. */ -# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 +# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 /* * This flag if for an ENGINE that does not want its methods registered as @@ -93,7 +93,7 @@ extern "C" { * usable as default methods. */ -# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008 +# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008 /* * ENGINEs can support their own command types, and these flags are used in @@ -108,23 +108,23 @@ extern "C" { */ /* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ -# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 +# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 /* * accepts string input (cast from 'void*' to 'const char *', 4th parameter * to ENGINE_ctrl) */ -# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 +# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 /* * Indicates that the control command takes *no* input. Ie. the control * command is unparameterised. */ -# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 +# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 /* * Indicates that the control command is internal. This control command won't * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() * function. */ -# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 +# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 /* * NB: These 3 control commands are deprecated and should not be used. @@ -143,27 +143,27 @@ extern "C" { * sense to some engines. In such a case, they do nothing but return the * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ -# define ENGINE_CTRL_SET_LOGSTREAM 1 -# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 -# define ENGINE_CTRL_HUP \ - 3 /* Close and reinitialise \ - * any handles/connections \ - * etc. */ -# define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ -# define ENGINE_CTRL_SET_CALLBACK_DATA \ - 5 /* User-specific data, used \ - * when calling the password \ - * callback and the user \ - * interface */ -# define ENGINE_CTRL_LOAD_CONFIGURATION \ - 6 /* Load a configuration, \ - * given a string that \ - * represents a file name \ - * or so */ -# define ENGINE_CTRL_LOAD_SECTION \ - 7 /* Load data from a given \ - * section in the already \ - * loaded configuration */ +# define ENGINE_CTRL_SET_LOGSTREAM 1 +# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 +# define ENGINE_CTRL_HUP \ + 3 /* Close and reinitialise \ + * any handles/connections \ + * etc. */ +# define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */ +# define ENGINE_CTRL_SET_CALLBACK_DATA \ + 5 /* User-specific data, used \ + * when calling the password \ + * callback and the user \ + * interface */ +# define ENGINE_CTRL_LOAD_CONFIGURATION \ + 6 /* Load a configuration, \ + * given a string that \ + * represents a file name \ + * or so */ +# define ENGINE_CTRL_LOAD_SECTION \ + 7 /* Load data from a given \ + * section in the already \ + * loaded configuration */ /* * These control commands allow an application to deal with an arbitrary @@ -185,22 +185,22 @@ extern "C" { * worth checking this first if the caller is trying to "discover" the * engine's capabilities and doesn't want errors generated unnecessarily. */ -# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 +# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 /* * Returns a positive command number for the first command supported by the * engine. Returns zero if no ctrl commands are supported. */ -# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 +# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 /* * The 'long' argument specifies a command implemented by the engine, and the * return value is the next command supported, or zero if there are no more. */ -# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 +# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 /* * The 'void*' argument is a command name (cast from 'const char *'), and the * return value is the command that corresponds to it. */ -# define ENGINE_CTRL_GET_CMD_FROM_NAME 13 +# define ENGINE_CTRL_GET_CMD_FROM_NAME 13 /* * The next two allow a command to be converted into its corresponding string * form. In each case, the 'long' argument supplies the command. In the @@ -209,23 +209,23 @@ extern "C" { * string buffer large enough, and it will be populated with the name of the * command (WITH a trailing EOL). */ -# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 -# define ENGINE_CTRL_GET_NAME_FROM_CMD 15 +# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 +# define ENGINE_CTRL_GET_NAME_FROM_CMD 15 /* The next two are similar but give a "short description" of a command. */ -# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 -# define ENGINE_CTRL_GET_DESC_FROM_CMD 17 +# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 +# define ENGINE_CTRL_GET_DESC_FROM_CMD 17 /* * With this command, the return value is the OR'd combination of * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given * engine-specific ctrl command expects. */ -# define ENGINE_CTRL_GET_CMD_FLAGS 18 +# define ENGINE_CTRL_GET_CMD_FLAGS 18 /* * ENGINE implementations should start the numbering of their own control * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */ -# define ENGINE_CMD_BASE 200 +# define ENGINE_CMD_BASE 200 /* * NB: These 2 nCipher "chil" control commands are deprecated, and their @@ -236,13 +236,13 @@ extern "C" { */ /* Flags specific to the nCipher "chil" engine */ -# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 +# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 /* * Depending on the value of the (long)i argument, this sets or * unsets the SimpleForkCheck flag in the CHIL API to enable or * disable checking and workarounds for applications that fork(). */ -# define ENGINE_CTRL_CHIL_NO_LOCKING 101 +# define ENGINE_CTRL_CHIL_NO_LOCKING 101 /* * This prevents the initialisation function from providing mutex * callbacks to the nCipher library. @@ -260,10 +260,10 @@ extern "C" { */ typedef struct ENGINE_CMD_DEFN_st { - unsigned int cmd_num; /* The command number */ - const char *cmd_name; /* The command name itself */ - const char *cmd_desc; /* A short description of the command */ - unsigned int cmd_flags; /* The input the command expects */ + unsigned int cmd_num; /* The command number */ + const char *cmd_name; /* The command name itself */ + const char *cmd_desc; /* A short description of the command */ + unsigned int cmd_flags; /* The input the command expects */ } ENGINE_CMD_DEFN; /* Generic function pointer */ @@ -271,13 +271,18 @@ typedef int (*ENGINE_GEN_FUNC_PTR)(void); /* Generic function pointer taking no arguments */ typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); /* Specific control function pointer */ -typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)(void)); +typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, + void (*f)(void)); /* Generic load_key function pointer */ -typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, UI_METHOD *ui_method, +typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, + UI_METHOD *ui_method, void *callback_data); -typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, STACK_OF(X509_NAME) * ca_dn, - X509 **pcert, EVP_PKEY **pkey, STACK_OF(X509) * *pother, - UI_METHOD *ui_method, void *callback_data); +typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, + STACK_OF(X509_NAME) * ca_dn, + X509 **pcert, EVP_PKEY **pkey, + STACK_OF(X509) * *pother, + UI_METHOD *ui_method, + void *callback_data); /*- * These callback types are for an ENGINE's handler for cipher and digest logic. * These handlers have these prototypes; @@ -293,10 +298,13 @@ typedef int (*ENGINE_SSL_CLIENT_CERT_PTR)(ENGINE *, SSL *ssl, STACK_OF(X509_NAME * Returns to a pointer to the array of supported cipher 'nid's. If the * second parameter is non-NULL it is set to the size of the returned array. */ -typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int); +typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, + int); typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int); -typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, const int **, int); -typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, const int **, int); +typedef int (*ENGINE_PKEY_METHS_PTR)(ENGINE *, EVP_PKEY_METHOD **, const int **, + int); +typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, + const int **, int); /* * STRUCTURE functions ... all of these functions deal with pointers to * ENGINE structures where the pointers have a "structural reference". This @@ -310,60 +318,67 @@ typedef int (*ENGINE_PKEY_ASN1_METHS_PTR)(ENGINE *, EVP_PKEY_ASN1_METHOD **, con */ /* Get the first/last "ENGINE" type available. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_first(void); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_last(void); -# endif +# endif /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_next(ENGINE *e); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_prev(ENGINE *e); -# endif +# endif /* Add another "ENGINE" type into the array. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_add(ENGINE *e); -# endif +# endif /* Remove an existing "ENGINE" type from the array. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_remove(ENGINE *e); -# endif +# endif /* Retrieve an engine from the list by its unique "id" value. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_by_id(const char *id); -# endif +# endif -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define ENGINE_load_openssl() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL) -# define ENGINE_load_dynamic() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL) -# ifndef OPENSSL_NO_STATIC_ENGINE -# define ENGINE_load_padlock() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL) -# define ENGINE_load_capi() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL) -# define ENGINE_load_afalg() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL) -# endif -# define ENGINE_load_cryptodev() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL) -# define ENGINE_load_rdrand() OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL) +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define ENGINE_load_openssl() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL) +# define ENGINE_load_dynamic() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL) +# ifndef OPENSSL_NO_STATIC_ENGINE +# define ENGINE_load_padlock() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL) +# define ENGINE_load_capi() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL) +# define ENGINE_load_afalg() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL) # endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define ENGINE_load_cryptodev() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL) +# define ENGINE_load_rdrand() \ + OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL) +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 void ENGINE_load_builtin_engines(void); -# endif +# endif /* * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation * "registry" handling. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 unsigned int ENGINE_get_table_flags(void); OSSL_DEPRECATEDIN_3_0 void ENGINE_set_table_flags(unsigned int flags); -# endif +# endif /*- Manage registration of ENGINEs per "table". For each type, there are 3 * functions; - * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) - * ENGINE_unregister_***(e) - unregister the implementation from 'e' - * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list - * Cleanup is automatically registered from each table when required. + * ENGINE_register_***(e) - registers the implementation from 'e' (if it has + * one) ENGINE_unregister_***(e) - unregister the implementation from 'e' + * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the + * list Cleanup is automatically registered from each table when required. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_register_RSA(ENGINE *e); OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_RSA(ENGINE *e); OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_RSA(void); @@ -391,7 +406,7 @@ OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_pkey_meths(void); OSSL_DEPRECATEDIN_3_0 int ENGINE_register_pkey_asn1_meths(ENGINE *e); OSSL_DEPRECATEDIN_3_0 void ENGINE_unregister_pkey_asn1_meths(ENGINE *e); OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_pkey_asn1_meths(void); -# endif +# endif /* * These functions register all support from the above categories. Note, use @@ -399,10 +414,10 @@ OSSL_DEPRECATEDIN_3_0 void ENGINE_register_all_pkey_asn1_meths(void); * may not need. If you only need a subset of functionality, consider using * more selective initialisation. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_register_complete(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_register_all_complete(void); -# endif +# endif /* * Send parameterised control commands to the engine. The possibilities to @@ -414,9 +429,10 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_register_all_complete(void); * commands that require an operational ENGINE, and only use functional * references in such situations. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); -# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, + void (*f)(void)); +# endif /* * This function tests if an ENGINE-specific command is usable as a @@ -424,9 +440,9 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_cmd_is_executable(ENGINE *e, int cmd); -# endif +# endif /* * This function works like ENGINE_ctrl() with the exception of taking a @@ -434,10 +450,11 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_cmd_is_executable(ENGINE *e, int cmd); * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation * on how to use the cmd_name and cmd_optional. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, long i, void *p, - void (*f)(void), int cmd_optional); -# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, + long i, void *p, void (*f)(void), + int cmd_optional); +# endif /* * This function passes a command-name and argument to an ENGINE. The @@ -461,10 +478,11 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, long * applications can work consistently with the same configuration for the * same ENGINE-enabled devices, across applications. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, int cmd_optional); -# endif +int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, + int cmd_optional); +# endif /* * These functions are useful for manufacturing new ENGINE structures. They @@ -474,7 +492,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, int * These are also here so that the ENGINE structure doesn't have to be * exposed and break binary compatibility! */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_new(void); OSSL_DEPRECATEDIN_3_0 int ENGINE_free(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_up_ref(ENGINE *e); @@ -482,9 +500,11 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_set_id(ENGINE *e, const char *id); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_name(ENGINE *e, const char *name); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); -OSSL_DEPRECATEDIN_3_0 int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_EC(ENGINE *e, + const EC_KEY_METHOD *ecdsa_meth); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); -OSSL_DEPRECATEDIN_3_0 int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_RAND(ENGINE *e, + const RAND_METHOD *rand_meth); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); OSSL_DEPRECATEDIN_3_0 @@ -498,7 +518,8 @@ int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); OSSL_DEPRECATEDIN_3_0 -int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); +int ENGINE_set_load_ssl_client_cert_function( + ENGINE *e, ENGINE_SSL_CLIENT_CERT_PTR loadssl_f); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); OSSL_DEPRECATEDIN_3_0 @@ -508,25 +529,26 @@ int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_flags(ENGINE *e, int flags); -OSSL_DEPRECATEDIN_3_0 int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); -# endif +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_cmd_defns(ENGINE *e, + const ENGINE_CMD_DEFN *defns); +# endif /* These functions allow control over any per-structure ENGINE data. */ -# define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef) -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef) +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); OSSL_DEPRECATEDIN_3_0 void *ENGINE_get_ex_data(const ENGINE *e, int idx); -# endif +# endif -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 /* * This function previously cleaned up anything that needs it. Auto-deinit will * now take care of it so it is no longer required to call this function. */ -# define ENGINE_cleanup() \ - while (0) \ - continue -# endif +# define ENGINE_cleanup() \ + while (0) \ + continue +# endif /* * These return values from within the ENGINE structure. These can be useful @@ -534,7 +556,7 @@ OSSL_DEPRECATEDIN_3_0 void *ENGINE_get_ex_data(const ENGINE *e, int idx); * which you obtained. Using the result for functional purposes if you only * obtained a structural reference may be problematic! */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 const char *ENGINE_get_id(const ENGINE *e); OSSL_DEPRECATEDIN_3_0 const char *ENGINE_get_name(const ENGINE *e); OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); @@ -573,13 +595,15 @@ const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); OSSL_DEPRECATEDIN_3_0 -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, const char *str, int len); +const EVP_PKEY_ASN1_METHOD * +ENGINE_get_pkey_asn1_meth_str(ENGINE *e, const char *str, int len); OSSL_DEPRECATEDIN_3_0 -const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, const char *str, int len); +const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, + const char *str, int len); OSSL_DEPRECATEDIN_3_0 const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_get_flags(const ENGINE *e); -# endif +# endif /* * FUNCTIONAL functions. These functions deal with ENGINE structures that @@ -599,35 +623,36 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_get_flags(const ENGINE *e); * already in use). This will fail if the engine is not currently operational * and cannot initialise. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_init(ENGINE *e); -# endif +# endif /* * Free a functional reference to an engine type. This does not require a * corresponding call to ENGINE_free as it also releases a structural * reference. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_finish(ENGINE *e); -# endif +# endif /* * The following functions handle keys that are stored in some secondary * location, handled by the engine. The storage may be on a card or * whatever. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, UI_METHOD *ui_method, - void *callback_data); +EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); OSSL_DEPRECATEDIN_3_0 -EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, UI_METHOD *ui_method, - void *callback_data); +EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); OSSL_DEPRECATEDIN_3_0 -int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, STACK_OF(X509_NAME) * ca_dn, X509 **pcert, - EVP_PKEY **ppkey, STACK_OF(X509) * *pother, UI_METHOD *ui_method, +int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, STACK_OF(X509_NAME) * ca_dn, + X509 **pcert, EVP_PKEY **ppkey, + STACK_OF(X509) * *pother, UI_METHOD *ui_method, void *callback_data); -# endif +# endif /* * This returns a pointer for the current ENGINE structure that is (by @@ -635,26 +660,26 @@ int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, STACK_OF(X509_NAME) * ca_dn, * incremented reference, so it should be free'd (ENGINE_finish) before it is * discarded. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_RSA(void); -# endif +# endif /* Same for the other "methods" */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_DSA(void); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_EC(void); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_DH(void); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_default_RAND(void); -# endif +# endif /* * These functions can be used to get a functional reference to perform * ciphering or digesting corresponding to "nid". */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_cipher_engine(int nid); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_digest_engine(int nid); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_pkey_meth_engine(int nid); OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid); -# endif +# endif /* * This sets a new default ENGINE structure for performing RSA operations. If @@ -662,12 +687,13 @@ OSSL_DEPRECATEDIN_3_0 ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid); * its reference count up'd so the caller should still free their own * reference 'e'. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_RSA(ENGINE *e); -OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_string(ENGINE *e, const char *def_list); -# endif +OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_string(ENGINE *e, + const char *def_list); +# endif /* Same for the other "methods" */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_DSA(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_EC(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_DH(ENGINE *e); @@ -676,7 +702,7 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_ciphers(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_digests(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_pkey_meths(ENGINE *e); OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_pkey_asn1_meths(ENGINE *e); -# endif +# endif /* * The combination "set" - the flags are bitwise "OR"d from the @@ -685,10 +711,10 @@ OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default_pkey_asn1_meths(ENGINE *e); * application requires only specific functionality, consider using more * selective functions. */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int ENGINE_set_default(ENGINE *e, unsigned int flags); OSSL_DEPRECATEDIN_3_0 void ENGINE_add_conf_module(void); -# endif +# endif /* Deprecated functions ... */ /* int ENGINE_clear_defaults(void); */ @@ -698,12 +724,12 @@ OSSL_DEPRECATEDIN_3_0 void ENGINE_add_conf_module(void); /**************************/ /* Binary/behaviour compatibility levels */ -# define OSSL_DYNAMIC_VERSION (unsigned long)0x00030000 +# define OSSL_DYNAMIC_VERSION (unsigned long)0x00030000 /* * Binary versions older than this are too old for us (whether we're a loader * or a loadee) */ -# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00030000 +# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00030000 /* * When compiling an ENGINE entirely as an external shared library, loadable @@ -721,9 +747,9 @@ typedef void *(*dyn_MEM_realloc_fn)(void *, size_t, const char *, int); typedef void (*dyn_MEM_free_fn)(void *, const char *, int); typedef struct st_dynamic_MEM_fns { - dyn_MEM_malloc_fn malloc_fn; - dyn_MEM_realloc_fn realloc_fn; - dyn_MEM_free_fn free_fn; + dyn_MEM_malloc_fn malloc_fn; + dyn_MEM_realloc_fn realloc_fn; + dyn_MEM_free_fn free_fn; } dynamic_MEM_fns; /* * FIXME: Perhaps the memory and locking code (crypto.h) should declare and @@ -732,8 +758,8 @@ typedef struct st_dynamic_MEM_fns /* The top-level structure */ typedef struct st_dynamic_fns { - void *static_state; - dynamic_MEM_fns mem_fns; + void *static_state; + dynamic_MEM_fns mem_fns; } dynamic_fns; /* @@ -749,14 +775,14 @@ typedef struct st_dynamic_fns * IMPLEMENT_DYNAMIC_CHECK_FN(). */ typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); -# define IMPLEMENT_DYNAMIC_CHECK_FN() \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v); \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v) \ - { \ - if (v >= OSSL_DYNAMIC_OLDEST) \ - return OSSL_DYNAMIC_VERSION; \ - return 0; \ - } +# define IMPLEMENT_DYNAMIC_CHECK_FN() \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v); \ + OPENSSL_EXPORT unsigned long v_check(unsigned long v) \ + { \ + if (v >= OSSL_DYNAMIC_OLDEST) \ + return OSSL_DYNAMIC_VERSION; \ + return 0; \ + } /* * This function is passed the ENGINE structure to initialise with its own @@ -776,23 +802,24 @@ typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); * returns an int value (zero for failure). 'fn' should have prototype; * [static] int fn(ENGINE *e, const char *id); */ -typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, const dynamic_fns *fns); -# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) \ - { \ - if (ENGINE_get_static_state() == fns->static_state) \ - goto skip_cbs; \ - CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, fns->mem_fns.realloc_fn, \ - fns->mem_fns.free_fn); \ - OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \ - skip_cbs: \ - if (!fn(e, id)) \ - return 0; \ - return 1; \ - } +typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, + const dynamic_fns *fns); +# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ + OPENSSL_EXPORT \ + int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) \ + { \ + if (ENGINE_get_static_state() == fns->static_state) \ + goto skip_cbs; \ + CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \ + fns->mem_fns.realloc_fn, fns->mem_fns.free_fn); \ + OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \ + skip_cbs: \ + if (!fn(e, id)) \ + return 0; \ + return 1; \ + } /* * If the loading application (or library) and the loaded ENGINE library @@ -807,14 +834,14 @@ typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, const dynamic_fns */ void *ENGINE_get_static_state(void); -# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 void ENGINE_setup_bsd_cryptodev(void); -# endif # endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* OPENSSL_NO_ENGINE */ #endif /* OPENSSL_ENGINE_H */ diff --git a/libs/OpenSSL/include/openssl/engineerr.h b/libs/OpenSSL/include/openssl/engineerr.h index 6a91092a..96ad7d34 100644 --- a/libs/OpenSSL/include/openssl/engineerr.h +++ b/libs/OpenSSL/include/openssl/engineerr.h @@ -21,41 +21,41 @@ /* * ENGINE reason codes. */ -# define ENGINE_R_ALREADY_LOADED 100 -# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 -# define ENGINE_R_CMD_NOT_EXECUTABLE 134 -# define ENGINE_R_COMMAND_TAKES_INPUT 135 -# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 -# define ENGINE_R_CONFLICTING_ENGINE_ID 103 -# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 -# define ENGINE_R_DSO_FAILURE 104 -# define ENGINE_R_DSO_NOT_FOUND 132 -# define ENGINE_R_ENGINES_SECTION_ERROR 148 -# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102 -# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 -# define ENGINE_R_ENGINE_SECTION_ERROR 149 -# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 -# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 -# define ENGINE_R_FINISH_FAILED 106 -# define ENGINE_R_ID_OR_NAME_MISSING 108 -# define ENGINE_R_INIT_FAILED 109 -# define ENGINE_R_INTERNAL_LIST_ERROR 110 -# define ENGINE_R_INVALID_ARGUMENT 143 -# define ENGINE_R_INVALID_CMD_NAME 137 -# define ENGINE_R_INVALID_CMD_NUMBER 138 -# define ENGINE_R_INVALID_INIT_VALUE 151 -# define ENGINE_R_INVALID_STRING 150 -# define ENGINE_R_NOT_INITIALISED 117 -# define ENGINE_R_NOT_LOADED 112 -# define ENGINE_R_NO_CONTROL_FUNCTION 120 -# define ENGINE_R_NO_INDEX 144 -# define ENGINE_R_NO_LOAD_FUNCTION 125 -# define ENGINE_R_NO_REFERENCE 130 -# define ENGINE_R_NO_SUCH_ENGINE 116 -# define ENGINE_R_UNIMPLEMENTED_CIPHER 146 -# define ENGINE_R_UNIMPLEMENTED_DIGEST 147 -# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101 -# define ENGINE_R_VERSION_INCOMPATIBILITY 145 +# define ENGINE_R_ALREADY_LOADED 100 +# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 +# define ENGINE_R_CMD_NOT_EXECUTABLE 134 +# define ENGINE_R_COMMAND_TAKES_INPUT 135 +# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 +# define ENGINE_R_CONFLICTING_ENGINE_ID 103 +# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 +# define ENGINE_R_DSO_FAILURE 104 +# define ENGINE_R_DSO_NOT_FOUND 132 +# define ENGINE_R_ENGINES_SECTION_ERROR 148 +# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102 +# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 +# define ENGINE_R_ENGINE_SECTION_ERROR 149 +# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 +# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 +# define ENGINE_R_FINISH_FAILED 106 +# define ENGINE_R_ID_OR_NAME_MISSING 108 +# define ENGINE_R_INIT_FAILED 109 +# define ENGINE_R_INTERNAL_LIST_ERROR 110 +# define ENGINE_R_INVALID_ARGUMENT 143 +# define ENGINE_R_INVALID_CMD_NAME 137 +# define ENGINE_R_INVALID_CMD_NUMBER 138 +# define ENGINE_R_INVALID_INIT_VALUE 151 +# define ENGINE_R_INVALID_STRING 150 +# define ENGINE_R_NOT_INITIALISED 117 +# define ENGINE_R_NOT_LOADED 112 +# define ENGINE_R_NO_CONTROL_FUNCTION 120 +# define ENGINE_R_NO_INDEX 144 +# define ENGINE_R_NO_LOAD_FUNCTION 125 +# define ENGINE_R_NO_REFERENCE 130 +# define ENGINE_R_NO_SUCH_ENGINE 116 +# define ENGINE_R_UNIMPLEMENTED_CIPHER 146 +# define ENGINE_R_UNIMPLEMENTED_DIGEST 147 +# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101 +# define ENGINE_R_VERSION_INCOMPATIBILITY 145 #endif #endif diff --git a/libs/OpenSSL/include/openssl/err.h b/libs/OpenSSL/include/openssl/err.h index f2f71df5..390a46fd 100644 --- a/libs/OpenSSL/include/openssl/err.h +++ b/libs/OpenSSL/include/openssl/err.h @@ -13,14 +13,14 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_ERR_H +# define HEADER_ERR_H #endif #include #ifndef OPENSSL_NO_STDIO -# include -# include +# include +# include #endif #include @@ -33,11 +33,11 @@ extern "C" { #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_FILENAMES -# define ERR_PUT_error(l, f, r, fn, ln) ERR_put_error(l, f, r, fn, ln) -# else -# define ERR_PUT_error(l, f, r, fn, ln) ERR_put_error(l, f, r, NULL, 0) -# endif +# ifndef OPENSSL_NO_FILENAMES +# define ERR_PUT_error(l, f, r, fn, ln) ERR_put_error(l, f, r, fn, ln) +# else +# define ERR_PUT_error(l, f, r, fn, ln) ERR_put_error(l, f, r, NULL, 0) +# endif #endif #include @@ -47,22 +47,22 @@ extern "C" { #define ERR_TXT_STRING 0x02 #if !defined(OPENSSL_NO_DEPRECATED_3_0) || defined(OSSL_FORCE_ERR_STATE) -# define ERR_FLAG_MARK 0x01 -# define ERR_FLAG_CLEAR 0x02 +# define ERR_FLAG_MARK 0x01 +# define ERR_FLAG_CLEAR 0x02 -# define ERR_NUM_ERRORS 16 +# define ERR_NUM_ERRORS 16 struct err_state_st { - int err_flags[ERR_NUM_ERRORS]; - int err_marks[ERR_NUM_ERRORS]; - unsigned long err_buffer[ERR_NUM_ERRORS]; - char *err_data[ERR_NUM_ERRORS]; - size_t err_data_size[ERR_NUM_ERRORS]; - int err_data_flags[ERR_NUM_ERRORS]; - char *err_file[ERR_NUM_ERRORS]; - int err_line[ERR_NUM_ERRORS]; - char *err_func[ERR_NUM_ERRORS]; - int top, bottom; + int err_flags[ERR_NUM_ERRORS]; + int err_marks[ERR_NUM_ERRORS]; + unsigned long err_buffer[ERR_NUM_ERRORS]; + char *err_data[ERR_NUM_ERRORS]; + size_t err_data_size[ERR_NUM_ERRORS]; + int err_data_flags[ERR_NUM_ERRORS]; + char *err_file[ERR_NUM_ERRORS]; + int err_line[ERR_NUM_ERRORS]; + char *err_func[ERR_NUM_ERRORS]; + int top, bottom; }; #endif @@ -123,49 +123,49 @@ struct err_state_st #define ERR_LIB_USER 128 #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define ASN1err(f, r) ERR_raise_data(ERR_LIB_ASN1, (r), NULL) -# define ASYNCerr(f, r) ERR_raise_data(ERR_LIB_ASYNC, (r), NULL) -# define BIOerr(f, r) ERR_raise_data(ERR_LIB_BIO, (r), NULL) -# define BNerr(f, r) ERR_raise_data(ERR_LIB_BN, (r), NULL) -# define BUFerr(f, r) ERR_raise_data(ERR_LIB_BUF, (r), NULL) -# define CMPerr(f, r) ERR_raise_data(ERR_LIB_CMP, (r), NULL) -# define CMSerr(f, r) ERR_raise_data(ERR_LIB_CMS, (r), NULL) -# define COMPerr(f, r) ERR_raise_data(ERR_LIB_COMP, (r), NULL) -# define CONFerr(f, r) ERR_raise_data(ERR_LIB_CONF, (r), NULL) -# define CRMFerr(f, r) ERR_raise_data(ERR_LIB_CRMF, (r), NULL) -# define CRYPTOerr(f, r) ERR_raise_data(ERR_LIB_CRYPTO, (r), NULL) -# define CTerr(f, r) ERR_raise_data(ERR_LIB_CT, (r), NULL) -# define DHerr(f, r) ERR_raise_data(ERR_LIB_DH, (r), NULL) -# define DSAerr(f, r) ERR_raise_data(ERR_LIB_DSA, (r), NULL) -# define DSOerr(f, r) ERR_raise_data(ERR_LIB_DSO, (r), NULL) -# define ECDHerr(f, r) ERR_raise_data(ERR_LIB_ECDH, (r), NULL) -# define ECDSAerr(f, r) ERR_raise_data(ERR_LIB_ECDSA, (r), NULL) -# define ECerr(f, r) ERR_raise_data(ERR_LIB_EC, (r), NULL) -# define ENGINEerr(f, r) ERR_raise_data(ERR_LIB_ENGINE, (r), NULL) -# define ESSerr(f, r) ERR_raise_data(ERR_LIB_ESS, (r), NULL) -# define EVPerr(f, r) ERR_raise_data(ERR_LIB_EVP, (r), NULL) -# define FIPSerr(f, r) ERR_raise_data(ERR_LIB_FIPS, (r), NULL) -# define HMACerr(f, r) ERR_raise_data(ERR_LIB_HMAC, (r), NULL) -# define HTTPerr(f, r) ERR_raise_data(ERR_LIB_HTTP, (r), NULL) -# define KDFerr(f, r) ERR_raise_data(ERR_LIB_KDF, (r), NULL) -# define OBJerr(f, r) ERR_raise_data(ERR_LIB_OBJ, (r), NULL) -# define OCSPerr(f, r) ERR_raise_data(ERR_LIB_OCSP, (r), NULL) -# define OSSL_STOREerr(f, r) ERR_raise_data(ERR_LIB_OSSL_STORE, (r), NULL) -# define PEMerr(f, r) ERR_raise_data(ERR_LIB_PEM, (r), NULL) -# define PKCS12err(f, r) ERR_raise_data(ERR_LIB_PKCS12, (r), NULL) -# define PKCS7err(f, r) ERR_raise_data(ERR_LIB_PKCS7, (r), NULL) -# define PROPerr(f, r) ERR_raise_data(ERR_LIB_PROP, (r), NULL) -# define PROVerr(f, r) ERR_raise_data(ERR_LIB_PROV, (r), NULL) -# define RANDerr(f, r) ERR_raise_data(ERR_LIB_RAND, (r), NULL) -# define RSAerr(f, r) ERR_raise_data(ERR_LIB_RSA, (r), NULL) -# define KDFerr(f, r) ERR_raise_data(ERR_LIB_KDF, (r), NULL) -# define SM2err(f, r) ERR_raise_data(ERR_LIB_SM2, (r), NULL) -# define SSLerr(f, r) ERR_raise_data(ERR_LIB_SSL, (r), NULL) -# define SYSerr(f, r) ERR_raise_data(ERR_LIB_SYS, (r), NULL) -# define TSerr(f, r) ERR_raise_data(ERR_LIB_TS, (r), NULL) -# define UIerr(f, r) ERR_raise_data(ERR_LIB_UI, (r), NULL) -# define X509V3err(f, r) ERR_raise_data(ERR_LIB_X509V3, (r), NULL) -# define X509err(f, r) ERR_raise_data(ERR_LIB_X509, (r), NULL) +# define ASN1err(f, r) ERR_raise_data(ERR_LIB_ASN1, (r), NULL) +# define ASYNCerr(f, r) ERR_raise_data(ERR_LIB_ASYNC, (r), NULL) +# define BIOerr(f, r) ERR_raise_data(ERR_LIB_BIO, (r), NULL) +# define BNerr(f, r) ERR_raise_data(ERR_LIB_BN, (r), NULL) +# define BUFerr(f, r) ERR_raise_data(ERR_LIB_BUF, (r), NULL) +# define CMPerr(f, r) ERR_raise_data(ERR_LIB_CMP, (r), NULL) +# define CMSerr(f, r) ERR_raise_data(ERR_LIB_CMS, (r), NULL) +# define COMPerr(f, r) ERR_raise_data(ERR_LIB_COMP, (r), NULL) +# define CONFerr(f, r) ERR_raise_data(ERR_LIB_CONF, (r), NULL) +# define CRMFerr(f, r) ERR_raise_data(ERR_LIB_CRMF, (r), NULL) +# define CRYPTOerr(f, r) ERR_raise_data(ERR_LIB_CRYPTO, (r), NULL) +# define CTerr(f, r) ERR_raise_data(ERR_LIB_CT, (r), NULL) +# define DHerr(f, r) ERR_raise_data(ERR_LIB_DH, (r), NULL) +# define DSAerr(f, r) ERR_raise_data(ERR_LIB_DSA, (r), NULL) +# define DSOerr(f, r) ERR_raise_data(ERR_LIB_DSO, (r), NULL) +# define ECDHerr(f, r) ERR_raise_data(ERR_LIB_ECDH, (r), NULL) +# define ECDSAerr(f, r) ERR_raise_data(ERR_LIB_ECDSA, (r), NULL) +# define ECerr(f, r) ERR_raise_data(ERR_LIB_EC, (r), NULL) +# define ENGINEerr(f, r) ERR_raise_data(ERR_LIB_ENGINE, (r), NULL) +# define ESSerr(f, r) ERR_raise_data(ERR_LIB_ESS, (r), NULL) +# define EVPerr(f, r) ERR_raise_data(ERR_LIB_EVP, (r), NULL) +# define FIPSerr(f, r) ERR_raise_data(ERR_LIB_FIPS, (r), NULL) +# define HMACerr(f, r) ERR_raise_data(ERR_LIB_HMAC, (r), NULL) +# define HTTPerr(f, r) ERR_raise_data(ERR_LIB_HTTP, (r), NULL) +# define KDFerr(f, r) ERR_raise_data(ERR_LIB_KDF, (r), NULL) +# define OBJerr(f, r) ERR_raise_data(ERR_LIB_OBJ, (r), NULL) +# define OCSPerr(f, r) ERR_raise_data(ERR_LIB_OCSP, (r), NULL) +# define OSSL_STOREerr(f, r) ERR_raise_data(ERR_LIB_OSSL_STORE, (r), NULL) +# define PEMerr(f, r) ERR_raise_data(ERR_LIB_PEM, (r), NULL) +# define PKCS12err(f, r) ERR_raise_data(ERR_LIB_PKCS12, (r), NULL) +# define PKCS7err(f, r) ERR_raise_data(ERR_LIB_PKCS7, (r), NULL) +# define PROPerr(f, r) ERR_raise_data(ERR_LIB_PROP, (r), NULL) +# define PROVerr(f, r) ERR_raise_data(ERR_LIB_PROV, (r), NULL) +# define RANDerr(f, r) ERR_raise_data(ERR_LIB_RAND, (r), NULL) +# define RSAerr(f, r) ERR_raise_data(ERR_LIB_RSA, (r), NULL) +# define KDFerr(f, r) ERR_raise_data(ERR_LIB_KDF, (r), NULL) +# define SM2err(f, r) ERR_raise_data(ERR_LIB_SM2, (r), NULL) +# define SSLerr(f, r) ERR_raise_data(ERR_LIB_SSL, (r), NULL) +# define SYSerr(f, r) ERR_raise_data(ERR_LIB_SYS, (r), NULL) +# define TSerr(f, r) ERR_raise_data(ERR_LIB_TS, (r), NULL) +# define UIerr(f, r) ERR_raise_data(ERR_LIB_UI, (r), NULL) +# define X509V3err(f, r) ERR_raise_data(ERR_LIB_X509V3, (r), NULL) +# define X509err(f, r) ERR_raise_data(ERR_LIB_X509, (r), NULL) #endif /*- @@ -235,37 +235,37 @@ struct err_state_st #define ERR_RFLAG_FATAL (0x1 << ERR_RFLAGS_OFFSET) #define ERR_RFLAG_COMMON (0x2 << ERR_RFLAGS_OFFSET) -#define ERR_SYSTEM_ERROR(errcode) (((errcode)&ERR_SYSTEM_FLAG) != 0) +#define ERR_SYSTEM_ERROR(errcode) (((errcode) & ERR_SYSTEM_FLAG) != 0) static ossl_unused ossl_inline int ERR_GET_LIB(unsigned long errcode) { - if (ERR_SYSTEM_ERROR(errcode)) - return ERR_LIB_SYS; - return (errcode >> ERR_LIB_OFFSET) & ERR_LIB_MASK; + if (ERR_SYSTEM_ERROR(errcode)) + return ERR_LIB_SYS; + return (errcode >> ERR_LIB_OFFSET) & ERR_LIB_MASK; } static ossl_unused ossl_inline int ERR_GET_RFLAGS(unsigned long errcode) { - if (ERR_SYSTEM_ERROR(errcode)) - return 0; - return errcode & (ERR_RFLAGS_MASK << ERR_RFLAGS_OFFSET); + if (ERR_SYSTEM_ERROR(errcode)) + return 0; + return errcode & (ERR_RFLAGS_MASK << ERR_RFLAGS_OFFSET); } static ossl_unused ossl_inline int ERR_GET_REASON(unsigned long errcode) { - if (ERR_SYSTEM_ERROR(errcode)) - return errcode & ERR_SYSTEM_MASK; - return errcode & ERR_REASON_MASK; + if (ERR_SYSTEM_ERROR(errcode)) + return errcode & ERR_SYSTEM_MASK; + return errcode & ERR_REASON_MASK; } static ossl_unused ossl_inline int ERR_FATAL_ERROR(unsigned long errcode) { - return (ERR_GET_RFLAGS(errcode) & ERR_RFLAG_FATAL) != 0; + return (ERR_GET_RFLAGS(errcode) & ERR_RFLAG_FATAL) != 0; } static ossl_unused ossl_inline int ERR_COMMON_ERROR(unsigned long errcode) { - return (ERR_GET_RFLAGS(errcode) & ERR_RFLAG_COMMON) != 0; + return (ERR_GET_RFLAGS(errcode) & ERR_RFLAG_COMMON) != 0; } /* @@ -274,36 +274,36 @@ static ossl_unused ossl_inline int ERR_COMMON_ERROR(unsigned long errcode) * ERR_PACK takes reason flags and reason code combined in |reason|. * ERR_PACK ignores |func|, that parameter is just legacy from pre-3.0 OpenSSL. */ -#define ERR_PACK(lib, func, reason) \ - ((((unsigned long)(lib)&ERR_LIB_MASK) << ERR_LIB_OFFSET) \ - | (((unsigned long)(reason)&ERR_REASON_MASK))) +#define ERR_PACK(lib, func, reason) \ + ((((unsigned long)(lib) & ERR_LIB_MASK) << ERR_LIB_OFFSET) \ + | (((unsigned long)(reason) & ERR_REASON_MASK))) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SYS_F_FOPEN 0 -# define SYS_F_CONNECT 0 -# define SYS_F_GETSERVBYNAME 0 -# define SYS_F_SOCKET 0 -# define SYS_F_IOCTLSOCKET 0 -# define SYS_F_BIND 0 -# define SYS_F_LISTEN 0 -# define SYS_F_ACCEPT 0 -# define SYS_F_WSASTARTUP 0 -# define SYS_F_OPENDIR 0 -# define SYS_F_FREAD 0 -# define SYS_F_GETADDRINFO 0 -# define SYS_F_GETNAMEINFO 0 -# define SYS_F_SETSOCKOPT 0 -# define SYS_F_GETSOCKOPT 0 -# define SYS_F_GETSOCKNAME 0 -# define SYS_F_GETHOSTBYNAME 0 -# define SYS_F_FFLUSH 0 -# define SYS_F_OPEN 0 -# define SYS_F_CLOSE 0 -# define SYS_F_IOCTL 0 -# define SYS_F_STAT 0 -# define SYS_F_FCNTL 0 -# define SYS_F_FSTAT 0 -# define SYS_F_SENDFILE 0 +# define SYS_F_FOPEN 0 +# define SYS_F_CONNECT 0 +# define SYS_F_GETSERVBYNAME 0 +# define SYS_F_SOCKET 0 +# define SYS_F_IOCTLSOCKET 0 +# define SYS_F_BIND 0 +# define SYS_F_LISTEN 0 +# define SYS_F_ACCEPT 0 +# define SYS_F_WSASTARTUP 0 +# define SYS_F_OPENDIR 0 +# define SYS_F_FREAD 0 +# define SYS_F_GETADDRINFO 0 +# define SYS_F_GETNAMEINFO 0 +# define SYS_F_SETSOCKOPT 0 +# define SYS_F_GETSOCKOPT 0 +# define SYS_F_GETSOCKNAME 0 +# define SYS_F_GETHOSTBYNAME 0 +# define SYS_F_FFLUSH 0 +# define SYS_F_OPEN 0 +# define SYS_F_CLOSE 0 +# define SYS_F_IOCTL 0 +# define SYS_F_STAT 0 +# define SYS_F_FCNTL 0 +# define SYS_F_FSTAT 0 +# define SYS_F_SENDFILE 0 #endif /* @@ -342,8 +342,10 @@ static ossl_unused ossl_inline int ERR_COMMON_ERROR(unsigned long errcode) #define ERR_R_PROV_LIB (ERR_LIB_PROV /* 57 */ | ERR_RFLAG_COMMON) #define ERR_R_ESS_LIB (ERR_LIB_ESS /* 54 */ | ERR_RFLAG_COMMON) #define ERR_R_CMP_LIB (ERR_LIB_CMP /* 58 */ | ERR_RFLAG_COMMON) -#define ERR_R_OSSL_ENCODER_LIB (ERR_LIB_OSSL_ENCODER /* 59 */ | ERR_RFLAG_COMMON) -#define ERR_R_OSSL_DECODER_LIB (ERR_LIB_OSSL_DECODER /* 60 */ | ERR_RFLAG_COMMON) +#define ERR_R_OSSL_ENCODER_LIB \ + (ERR_LIB_OSSL_ENCODER /* 59 */ | ERR_RFLAG_COMMON) +#define ERR_R_OSSL_DECODER_LIB \ + (ERR_LIB_OSSL_DECODER /* 60 */ | ERR_RFLAG_COMMON) /* Other common error codes, range 256..2^ERR_RFLAGS_OFFSET-1 */ #define ERR_R_FATAL (ERR_RFLAG_FATAL | ERR_RFLAG_COMMON) @@ -367,42 +369,49 @@ static ossl_unused ossl_inline int ERR_COMMON_ERROR(unsigned long errcode) typedef struct ERR_string_data_st { - unsigned long error; - const char *string; + unsigned long error; + const char *string; } ERR_STRING_DATA; DEFINE_LHASH_OF_INTERNAL(ERR_STRING_DATA); -#define lh_ERR_STRING_DATA_new(hfn, cmp) \ - ((LHASH_OF(ERR_STRING_DATA) *)OPENSSL_LH_new( \ - ossl_check_ERR_STRING_DATA_lh_hashfunc_type(hfn), \ - ossl_check_ERR_STRING_DATA_lh_compfunc_type(cmp))) -#define lh_ERR_STRING_DATA_free(lh) OPENSSL_LH_free(ossl_check_ERR_STRING_DATA_lh_type(lh)) -#define lh_ERR_STRING_DATA_flush(lh) OPENSSL_LH_flush(ossl_check_ERR_STRING_DATA_lh_type(lh)) -#define lh_ERR_STRING_DATA_insert(lh, ptr) \ - ((ERR_STRING_DATA *)OPENSSL_LH_insert(ossl_check_ERR_STRING_DATA_lh_type(lh), \ - ossl_check_ERR_STRING_DATA_lh_plain_type(ptr))) -#define lh_ERR_STRING_DATA_delete(lh, ptr) \ - ((ERR_STRING_DATA *)OPENSSL_LH_delete(ossl_check_ERR_STRING_DATA_lh_type(lh), \ - ossl_check_const_ERR_STRING_DATA_lh_plain_type(ptr))) -#define lh_ERR_STRING_DATA_retrieve(lh, ptr) \ - ((ERR_STRING_DATA *)OPENSSL_LH_retrieve(ossl_check_ERR_STRING_DATA_lh_type(lh), \ - ossl_check_const_ERR_STRING_DATA_lh_plain_type(ptr))) -#define lh_ERR_STRING_DATA_error(lh) OPENSSL_LH_error(ossl_check_ERR_STRING_DATA_lh_type(lh)) -#define lh_ERR_STRING_DATA_num_items(lh) \ - OPENSSL_LH_num_items(ossl_check_ERR_STRING_DATA_lh_type(lh)) -#define lh_ERR_STRING_DATA_node_stats_bio(lh, out) \ - OPENSSL_LH_node_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) -#define lh_ERR_STRING_DATA_node_usage_stats_bio(lh, out) \ - OPENSSL_LH_node_usage_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) -#define lh_ERR_STRING_DATA_stats_bio(lh, out) \ - OPENSSL_LH_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) -#define lh_ERR_STRING_DATA_get_down_load(lh) \ - OPENSSL_LH_get_down_load(ossl_check_ERR_STRING_DATA_lh_type(lh)) -#define lh_ERR_STRING_DATA_set_down_load(lh, dl) \ - OPENSSL_LH_set_down_load(ossl_check_ERR_STRING_DATA_lh_type(lh), dl) -#define lh_ERR_STRING_DATA_doall(lh, dfn) \ - OPENSSL_LH_doall(ossl_check_ERR_STRING_DATA_lh_type(lh), \ - ossl_check_ERR_STRING_DATA_lh_doallfunc_type(dfn)) +#define lh_ERR_STRING_DATA_new(hfn, cmp) \ + ((LHASH_OF(ERR_STRING_DATA) *)OPENSSL_LH_new( \ + ossl_check_ERR_STRING_DATA_lh_hashfunc_type(hfn), \ + ossl_check_ERR_STRING_DATA_lh_compfunc_type(cmp))) +#define lh_ERR_STRING_DATA_free(lh) \ + OPENSSL_LH_free(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_flush(lh) \ + OPENSSL_LH_flush(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_insert(lh, ptr) \ + ((ERR_STRING_DATA *)OPENSSL_LH_insert( \ + ossl_check_ERR_STRING_DATA_lh_type(lh), \ + ossl_check_ERR_STRING_DATA_lh_plain_type(ptr))) +#define lh_ERR_STRING_DATA_delete(lh, ptr) \ + ((ERR_STRING_DATA *)OPENSSL_LH_delete( \ + ossl_check_ERR_STRING_DATA_lh_type(lh), \ + ossl_check_const_ERR_STRING_DATA_lh_plain_type(ptr))) +#define lh_ERR_STRING_DATA_retrieve(lh, ptr) \ + ((ERR_STRING_DATA *)OPENSSL_LH_retrieve( \ + ossl_check_ERR_STRING_DATA_lh_type(lh), \ + ossl_check_const_ERR_STRING_DATA_lh_plain_type(ptr))) +#define lh_ERR_STRING_DATA_error(lh) \ + OPENSSL_LH_error(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_num_items(lh) \ + OPENSSL_LH_num_items(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_node_stats_bio(lh, out) \ + OPENSSL_LH_node_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) +#define lh_ERR_STRING_DATA_node_usage_stats_bio(lh, out) \ + OPENSSL_LH_node_usage_stats_bio( \ + ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) +#define lh_ERR_STRING_DATA_stats_bio(lh, out) \ + OPENSSL_LH_stats_bio(ossl_check_const_ERR_STRING_DATA_lh_type(lh), out) +#define lh_ERR_STRING_DATA_get_down_load(lh) \ + OPENSSL_LH_get_down_load(ossl_check_ERR_STRING_DATA_lh_type(lh)) +#define lh_ERR_STRING_DATA_set_down_load(lh, dl) \ + OPENSSL_LH_set_down_load(ossl_check_ERR_STRING_DATA_lh_type(lh), dl) +#define lh_ERR_STRING_DATA_doall(lh, dfn) \ + OPENSSL_LH_doall(ossl_check_ERR_STRING_DATA_lh_type(lh), \ + ossl_check_ERR_STRING_DATA_lh_doallfunc_type(dfn)) /* 12 lines and some on an 80 column terminal */ #define ERR_MAX_DATA_SIZE 1024 @@ -415,47 +424,52 @@ void ERR_vset_error(int lib, int reason, const char *fmt, va_list args); /* Main error raising functions */ #define ERR_raise(lib, reason) ERR_raise_data((lib), (reason), NULL) -#define ERR_raise_data \ - (ERR_new(), ERR_set_debug(OPENSSL_FILE, OPENSSL_LINE, OPENSSL_FUNC), ERR_set_error) +#define ERR_raise_data \ + (ERR_new(), ERR_set_debug(OPENSSL_FILE, OPENSSL_LINE, OPENSSL_FUNC), \ + ERR_set_error) #ifndef OPENSSL_NO_DEPRECATED_3_0 /* Backward compatibility */ -# define ERR_put_error(lib, func, reason, file, line) \ - (ERR_new(), ERR_set_debug((file), (line), OPENSSL_FUNC), \ - ERR_set_error((lib), (reason), NULL)) +# define ERR_put_error(lib, func, reason, file, line) \ + (ERR_new(), ERR_set_debug((file), (line), OPENSSL_FUNC), \ + ERR_set_error((lib), (reason), NULL)) #endif void ERR_set_error_data(char *data, int flags); unsigned long ERR_get_error(void); -unsigned long ERR_get_error_all(const char **file, int *line, const char **func, const char **data, - int *flags); +unsigned long ERR_get_error_all(const char **file, int *line, const char **func, + const char **data, int *flags); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 unsigned long ERR_get_error_line(const char **file, int *line); OSSL_DEPRECATEDIN_3_0 -unsigned long ERR_get_error_line_data(const char **file, int *line, const char **data, int *flags); +unsigned long ERR_get_error_line_data(const char **file, int *line, + const char **data, int *flags); #endif unsigned long ERR_peek_error(void); unsigned long ERR_peek_error_line(const char **file, int *line); unsigned long ERR_peek_error_func(const char **func); unsigned long ERR_peek_error_data(const char **data, int *flags); -unsigned long ERR_peek_error_all(const char **file, int *line, const char **func, const char **data, +unsigned long ERR_peek_error_all(const char **file, int *line, + const char **func, const char **data, int *flags); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -unsigned long ERR_peek_error_line_data(const char **file, int *line, const char **data, int *flags); +unsigned long ERR_peek_error_line_data(const char **file, int *line, + const char **data, int *flags); #endif unsigned long ERR_peek_last_error(void); unsigned long ERR_peek_last_error_line(const char **file, int *line); unsigned long ERR_peek_last_error_func(const char **func); unsigned long ERR_peek_last_error_data(const char **data, int *flags); -unsigned long ERR_peek_last_error_all(const char **file, int *line, const char **func, - const char **data, int *flags); +unsigned long ERR_peek_last_error_all(const char **file, int *line, + const char **func, const char **data, + int *flags); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -unsigned long ERR_peek_last_error_line_data(const char **file, int *line, const char **data, - int *flags); +unsigned long ERR_peek_last_error_line_data(const char **file, int *line, + const char **data, int *flags); #endif void ERR_clear_error(void); @@ -468,7 +482,8 @@ OSSL_DEPRECATEDIN_3_0 const char *ERR_func_error_string(unsigned long e); #endif const char *ERR_reason_error_string(unsigned long e); -void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), void *u); +void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), + void *u); #ifndef OPENSSL_NO_STDIO void ERR_print_errors_fp(FILE *fp); #endif @@ -484,10 +499,11 @@ int ERR_load_strings_const(const ERR_STRING_DATA *str); int ERR_unload_strings(int lib, ERR_STRING_DATA *str); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define ERR_load_crypto_strings() OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) -# define ERR_free_strings() \ - while (0) \ - continue +# define ERR_load_crypto_strings() \ + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) +# define ERR_free_strings() \ + while (0) \ + continue #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 void ERR_remove_thread_state(void *); diff --git a/libs/OpenSSL/include/openssl/ess.h b/libs/OpenSSL/include/openssl/ess.h index 0bcd531c..a40d2e3a 100644 --- a/libs/OpenSSL/include/openssl/ess.h +++ b/libs/OpenSSL/include/openssl/ess.h @@ -29,141 +29,185 @@ typedef struct ESS_cert_id ESS_CERT_ID; typedef struct ESS_signing_cert ESS_SIGNING_CERT; SKM_DEFINE_STACK_OF_INTERNAL(ESS_CERT_ID, ESS_CERT_ID, ESS_CERT_ID) -#define sk_ESS_CERT_ID_num(sk) OPENSSL_sk_num(ossl_check_const_ESS_CERT_ID_sk_type(sk)) -#define sk_ESS_CERT_ID_value(sk, idx) \ - ((ESS_CERT_ID *)OPENSSL_sk_value(ossl_check_const_ESS_CERT_ID_sk_type(sk), (idx))) -#define sk_ESS_CERT_ID_new(cmp) \ - ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new(ossl_check_ESS_CERT_ID_compfunc_type(cmp))) -#define sk_ESS_CERT_ID_new_null() ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new_null()) -#define sk_ESS_CERT_ID_new_reserve(cmp, n) \ - ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new_reserve(ossl_check_ESS_CERT_ID_compfunc_type(cmp), \ - (n))) -#define sk_ESS_CERT_ID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ESS_CERT_ID_sk_type(sk), (n)) -#define sk_ESS_CERT_ID_free(sk) OPENSSL_sk_free(ossl_check_ESS_CERT_ID_sk_type(sk)) -#define sk_ESS_CERT_ID_zero(sk) OPENSSL_sk_zero(ossl_check_ESS_CERT_ID_sk_type(sk)) -#define sk_ESS_CERT_ID_delete(sk, i) \ - ((ESS_CERT_ID *)OPENSSL_sk_delete(ossl_check_ESS_CERT_ID_sk_type(sk), (i))) -#define sk_ESS_CERT_ID_delete_ptr(sk, ptr) \ - ((ESS_CERT_ID *)OPENSSL_sk_delete_ptr(ossl_check_ESS_CERT_ID_sk_type(sk), \ - ossl_check_ESS_CERT_ID_type(ptr))) -#define sk_ESS_CERT_ID_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) -#define sk_ESS_CERT_ID_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) -#define sk_ESS_CERT_ID_pop(sk) ((ESS_CERT_ID *)OPENSSL_sk_pop(ossl_check_ESS_CERT_ID_sk_type(sk))) -#define sk_ESS_CERT_ID_shift(sk) \ - ((ESS_CERT_ID *)OPENSSL_sk_shift(ossl_check_ESS_CERT_ID_sk_type(sk))) -#define sk_ESS_CERT_ID_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ESS_CERT_ID_sk_type(sk), \ - ossl_check_ESS_CERT_ID_freefunc_type(freefunc)) -#define sk_ESS_CERT_ID_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr), (idx)) -#define sk_ESS_CERT_ID_set(sk, idx, ptr) \ - ((ESS_CERT_ID *)OPENSSL_sk_set(ossl_check_ESS_CERT_ID_sk_type(sk), (idx), \ - ossl_check_ESS_CERT_ID_type(ptr))) -#define sk_ESS_CERT_ID_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) -#define sk_ESS_CERT_ID_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr)) -#define sk_ESS_CERT_ID_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_type(ptr), pnum) -#define sk_ESS_CERT_ID_sort(sk) OPENSSL_sk_sort(ossl_check_ESS_CERT_ID_sk_type(sk)) -#define sk_ESS_CERT_ID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ESS_CERT_ID_sk_type(sk)) -#define sk_ESS_CERT_ID_dup(sk) \ - ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_dup(ossl_check_const_ESS_CERT_ID_sk_type(sk))) -#define sk_ESS_CERT_ID_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ESS_CERT_ID_sk_type(sk), ossl_check_ESS_CERT_ID_copyfunc_type(copyfunc), \ - ossl_check_ESS_CERT_ID_freefunc_type(freefunc))) -#define sk_ESS_CERT_ID_set_cmp_func(sk, cmp) \ - ((sk_ESS_CERT_ID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ESS_CERT_ID_sk_type(sk), \ - ossl_check_ESS_CERT_ID_compfunc_type(cmp))) +#define sk_ESS_CERT_ID_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_value(sk, idx) \ + ((ESS_CERT_ID *)OPENSSL_sk_value(ossl_check_const_ESS_CERT_ID_sk_type(sk), \ + (idx))) +#define sk_ESS_CERT_ID_new(cmp) \ + ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new( \ + ossl_check_ESS_CERT_ID_compfunc_type(cmp))) +#define sk_ESS_CERT_ID_new_null() \ + ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new_null()) +#define sk_ESS_CERT_ID_new_reserve(cmp, n) \ + ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_new_reserve( \ + ossl_check_ESS_CERT_ID_compfunc_type(cmp), (n))) +#define sk_ESS_CERT_ID_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ESS_CERT_ID_sk_type(sk), (n)) +#define sk_ESS_CERT_ID_free(sk) \ + OPENSSL_sk_free(ossl_check_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_delete(sk, i) \ + ((ESS_CERT_ID *)OPENSSL_sk_delete(ossl_check_ESS_CERT_ID_sk_type(sk), (i))) +#define sk_ESS_CERT_ID_delete_ptr(sk, ptr) \ + ((ESS_CERT_ID *)OPENSSL_sk_delete_ptr(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr))) +#define sk_ESS_CERT_ID_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_pop(sk) \ + ((ESS_CERT_ID *)OPENSSL_sk_pop(ossl_check_ESS_CERT_ID_sk_type(sk))) +#define sk_ESS_CERT_ID_shift(sk) \ + ((ESS_CERT_ID *)OPENSSL_sk_shift(ossl_check_ESS_CERT_ID_sk_type(sk))) +#define sk_ESS_CERT_ID_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_freefunc_type(freefunc)) +#define sk_ESS_CERT_ID_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr), (idx)) +#define sk_ESS_CERT_ID_set(sk, idx, ptr) \ + ((ESS_CERT_ID *)OPENSSL_sk_set(ossl_check_ESS_CERT_ID_sk_type(sk), (idx), \ + ossl_check_ESS_CERT_ID_type(ptr))) +#define sk_ESS_CERT_ID_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr)) +#define sk_ESS_CERT_ID_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_type(ptr), pnum) +#define sk_ESS_CERT_ID_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ESS_CERT_ID_sk_type(sk)) +#define sk_ESS_CERT_ID_dup(sk) \ + ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_dup( \ + ossl_check_const_ESS_CERT_ID_sk_type(sk))) +#define sk_ESS_CERT_ID_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ESS_CERT_ID) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_copyfunc_type(copyfunc), \ + ossl_check_ESS_CERT_ID_freefunc_type(freefunc))) +#define sk_ESS_CERT_ID_set_cmp_func(sk, cmp) \ + ((sk_ESS_CERT_ID_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ESS_CERT_ID_sk_type(sk), \ + ossl_check_ESS_CERT_ID_compfunc_type(cmp))) typedef struct ESS_signing_cert_v2_st ESS_SIGNING_CERT_V2; typedef struct ESS_cert_id_v2_st ESS_CERT_ID_V2; SKM_DEFINE_STACK_OF_INTERNAL(ESS_CERT_ID_V2, ESS_CERT_ID_V2, ESS_CERT_ID_V2) -#define sk_ESS_CERT_ID_V2_num(sk) OPENSSL_sk_num(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk)) -#define sk_ESS_CERT_ID_V2_value(sk, idx) \ - ((ESS_CERT_ID_V2 *)OPENSSL_sk_value(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk), (idx))) -#define sk_ESS_CERT_ID_V2_new(cmp) \ - ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new(ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp))) -#define sk_ESS_CERT_ID_V2_new_null() ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new_null()) -#define sk_ESS_CERT_ID_V2_new_reserve(cmp, n) \ - ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new_reserve( \ - ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp), (n))) -#define sk_ESS_CERT_ID_V2_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (n)) -#define sk_ESS_CERT_ID_V2_free(sk) OPENSSL_sk_free(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) -#define sk_ESS_CERT_ID_V2_zero(sk) OPENSSL_sk_zero(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) -#define sk_ESS_CERT_ID_V2_delete(sk, i) \ - ((ESS_CERT_ID_V2 *)OPENSSL_sk_delete(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (i))) -#define sk_ESS_CERT_ID_V2_delete_ptr(sk, ptr) \ - ((ESS_CERT_ID_V2 *)OPENSSL_sk_delete_ptr(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ - ossl_check_ESS_CERT_ID_V2_type(ptr))) -#define sk_ESS_CERT_ID_V2_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) -#define sk_ESS_CERT_ID_V2_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) -#define sk_ESS_CERT_ID_V2_pop(sk) \ - ((ESS_CERT_ID_V2 *)OPENSSL_sk_pop(ossl_check_ESS_CERT_ID_V2_sk_type(sk))) -#define sk_ESS_CERT_ID_V2_shift(sk) \ - ((ESS_CERT_ID_V2 *)OPENSSL_sk_shift(ossl_check_ESS_CERT_ID_V2_sk_type(sk))) -#define sk_ESS_CERT_ID_V2_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ - ossl_check_ESS_CERT_ID_V2_freefunc_type(freefunc)) -#define sk_ESS_CERT_ID_V2_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr), \ - (idx)) -#define sk_ESS_CERT_ID_V2_set(sk, idx, ptr) \ - ((ESS_CERT_ID_V2 *)OPENSSL_sk_set(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (idx), \ - ossl_check_ESS_CERT_ID_V2_type(ptr))) -#define sk_ESS_CERT_ID_V2_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) -#define sk_ESS_CERT_ID_V2_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_type(ptr)) -#define sk_ESS_CERT_ID_V2_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ - ossl_check_ESS_CERT_ID_V2_type(ptr), pnum) -#define sk_ESS_CERT_ID_V2_sort(sk) OPENSSL_sk_sort(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) -#define sk_ESS_CERT_ID_V2_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk)) -#define sk_ESS_CERT_ID_V2_dup(sk) \ - ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_dup(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk))) -#define sk_ESS_CERT_ID_V2_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ESS_CERT_ID_V2_sk_type(sk), \ - ossl_check_ESS_CERT_ID_V2_copyfunc_type(copyfunc), \ - ossl_check_ESS_CERT_ID_V2_freefunc_type(freefunc))) -#define sk_ESS_CERT_ID_V2_set_cmp_func(sk, cmp) \ - ((sk_ESS_CERT_ID_V2_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ESS_CERT_ID_V2_sk_type(sk), ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp))) +#define sk_ESS_CERT_ID_V2_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_value(sk, idx) \ + ((ESS_CERT_ID_V2 *)OPENSSL_sk_value( \ + ossl_check_const_ESS_CERT_ID_V2_sk_type(sk), (idx))) +#define sk_ESS_CERT_ID_V2_new(cmp) \ + ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new( \ + ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp))) +#define sk_ESS_CERT_ID_V2_new_null() \ + ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new_null()) +#define sk_ESS_CERT_ID_V2_new_reserve(cmp, n) \ + ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_new_reserve( \ + ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp), (n))) +#define sk_ESS_CERT_ID_V2_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ESS_CERT_ID_V2_sk_type(sk), (n)) +#define sk_ESS_CERT_ID_V2_free(sk) \ + OPENSSL_sk_free(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_delete(sk, i) \ + ((ESS_CERT_ID_V2 *)OPENSSL_sk_delete(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + (i))) +#define sk_ESS_CERT_ID_V2_delete_ptr(sk, ptr) \ + ((ESS_CERT_ID_V2 *)OPENSSL_sk_delete_ptr( \ + ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr))) +#define sk_ESS_CERT_ID_V2_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_pop(sk) \ + ((ESS_CERT_ID_V2 *)OPENSSL_sk_pop(ossl_check_ESS_CERT_ID_V2_sk_type(sk))) +#define sk_ESS_CERT_ID_V2_shift(sk) \ + ((ESS_CERT_ID_V2 *)OPENSSL_sk_shift(ossl_check_ESS_CERT_ID_V2_sk_type(sk))) +#define sk_ESS_CERT_ID_V2_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_freefunc_type(freefunc)) +#define sk_ESS_CERT_ID_V2_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr), (idx)) +#define sk_ESS_CERT_ID_V2_set(sk, idx, ptr) \ + ((ESS_CERT_ID_V2 *)OPENSSL_sk_set(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + (idx), \ + ossl_check_ESS_CERT_ID_V2_type(ptr))) +#define sk_ESS_CERT_ID_V2_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr)) +#define sk_ESS_CERT_ID_V2_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_type(ptr), pnum) +#define sk_ESS_CERT_ID_V2_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ESS_CERT_ID_V2_sk_type(sk)) +#define sk_ESS_CERT_ID_V2_dup(sk) \ + ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_dup( \ + ossl_check_const_ESS_CERT_ID_V2_sk_type(sk))) +#define sk_ESS_CERT_ID_V2_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ESS_CERT_ID_V2) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_copyfunc_type(copyfunc), \ + ossl_check_ESS_CERT_ID_V2_freefunc_type(freefunc))) +#define sk_ESS_CERT_ID_V2_set_cmp_func(sk, cmp) \ + ((sk_ESS_CERT_ID_V2_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ESS_CERT_ID_V2_sk_type(sk), \ + ossl_check_ESS_CERT_ID_V2_compfunc_type(cmp))) DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_ISSUER_SERIAL) DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_ISSUER_SERIAL, ESS_ISSUER_SERIAL) DECLARE_ASN1_DUP_FUNCTION(ESS_ISSUER_SERIAL) - DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_CERT_ID) DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_CERT_ID, - ESS_CERT_ID) - DECLARE_ASN1_DUP_FUNCTION(ESS_CERT_ID) + DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_CERT_ID) + DECLARE_ASN1_ENCODE_FUNCTIONS_only( + ESS_CERT_ID, ESS_CERT_ID) DECLARE_ASN1_DUP_FUNCTION(ESS_CERT_ID) - DECLARE_ASN1_FUNCTIONS(ESS_SIGNING_CERT) DECLARE_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT) + DECLARE_ASN1_FUNCTIONS(ESS_SIGNING_CERT) + DECLARE_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT) - DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_CERT_ID_V2) - DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_CERT_ID_V2, ESS_CERT_ID_V2) - DECLARE_ASN1_DUP_FUNCTION(ESS_CERT_ID_V2) + DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_CERT_ID_V2) + DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_CERT_ID_V2, + ESS_CERT_ID_V2) + DECLARE_ASN1_DUP_FUNCTION(ESS_CERT_ID_V2) - DECLARE_ASN1_FUNCTIONS(ESS_SIGNING_CERT_V2) - DECLARE_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT_V2) + DECLARE_ASN1_FUNCTIONS(ESS_SIGNING_CERT_V2) + DECLARE_ASN1_DUP_FUNCTION( + ESS_SIGNING_CERT_V2) - ESS_SIGNING_CERT *OSSL_ESS_signing_cert_new_init( - const X509 *signcert, const STACK_OF(X509) * certs, - int set_issuer_serial); -ESS_SIGNING_CERT_V2 *OSSL_ESS_signing_cert_v2_new_init(const EVP_MD *hash_alg, const X509 *signcert, - const STACK_OF(X509) * certs, - int set_issuer_serial); -int OSSL_ESS_check_signing_certs(const ESS_SIGNING_CERT *ss, const ESS_SIGNING_CERT_V2 *ssv2, - const STACK_OF(X509) * chain, int require_signing_cert); + ESS_SIGNING_CERT + *OSSL_ESS_signing_cert_new_init( + const X509 *signcert, + const STACK_OF(X509) + * certs, + int set_issuer_serial); +ESS_SIGNING_CERT_V2 * +OSSL_ESS_signing_cert_v2_new_init(const EVP_MD *hash_alg, const X509 *signcert, + const STACK_OF(X509) * certs, + int set_issuer_serial); +int OSSL_ESS_check_signing_certs(const ESS_SIGNING_CERT *ss, + const ESS_SIGNING_CERT_V2 *ssv2, + const STACK_OF(X509) * chain, + int require_signing_cert); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/evp.h b/libs/OpenSSL/include/openssl/evp.h index 5d6aee27..3fbc23fd 100644 --- a/libs/OpenSSL/include/openssl/evp.h +++ b/libs/OpenSSL/include/openssl/evp.h @@ -13,13 +13,13 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_ENVELOPE_H +# define HEADER_ENVELOPE_H #endif #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #include @@ -43,16 +43,16 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define EVP_PK_RSA 0x0001 -# define EVP_PK_DSA 0x0002 -# define EVP_PK_DH 0x0004 -# define EVP_PK_EC 0x0008 -# define EVP_PKT_SIGN 0x0010 -# define EVP_PKT_ENC 0x0020 -# define EVP_PKT_EXCH 0x0040 -# define EVP_PKS_RSA 0x0100 -# define EVP_PKS_DSA 0x0200 -# define EVP_PKS_EC 0x0400 +# define EVP_PK_RSA 0x0001 +# define EVP_PK_DSA 0x0002 +# define EVP_PK_DH 0x0004 +# define EVP_PK_EC 0x0008 +# define EVP_PKT_SIGN 0x0010 +# define EVP_PKT_ENC 0x0020 +# define EVP_PKT_EXCH 0x0040 +# define EVP_PKS_RSA 0x0100 +# define EVP_PKS_DSA 0x0200 +# define EVP_PKS_EC 0x0400 #endif #define EVP_PKEY_NONE NID_undef @@ -84,7 +84,8 @@ /* Easy to use macros for EVP_PKEY related selections */ #define EVP_PKEY_KEY_PARAMETERS (OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) -#define EVP_PKEY_PUBLIC_KEY (EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PUBLIC_KEY) +#define EVP_PKEY_PUBLIC_KEY \ + (EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PUBLIC_KEY) #define EVP_PKEY_KEYPAIR (EVP_PKEY_PUBLIC_KEY | OSSL_KEYMGMT_SELECT_PRIVATE_KEY) #ifdef __cplusplus @@ -101,7 +102,7 @@ int EVP_default_properties_enable_fips(OSSL_LIB_CTX *libctx, int enable); #define EVP_PKEY_MO_DECRYPT 0x0008 #ifndef EVP_MD -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type); OSSL_DEPRECATEDIN_3_0 EVP_MD *EVP_MD_meth_dup(const EVP_MD *md); OSSL_DEPRECATEDIN_3_0 void EVP_MD_meth_free(EVP_MD *md); @@ -117,15 +118,19 @@ OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)); OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_set_update(EVP_MD *md, - int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count)); + int (*update)(EVP_MD_CTX *ctx, const void *data, + size_t count)); OSSL_DEPRECATEDIN_3_0 -int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx, unsigned char *md)); +int EVP_MD_meth_set_final(EVP_MD *md, + int (*final)(EVP_MD_CTX *ctx, unsigned char *md)); OSSL_DEPRECATEDIN_3_0 -int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from)); +int EVP_MD_meth_set_copy(EVP_MD *md, + int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from)); OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx)); OSSL_DEPRECATEDIN_3_0 -int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)); +int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd, + int p1, void *p2)); OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_input_blocksize(const EVP_MD *md); OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_result_size(const EVP_MD *md); OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_app_datasize(const EVP_MD *md); @@ -133,65 +138,69 @@ OSSL_DEPRECATEDIN_3_0 unsigned long EVP_MD_meth_get_flags(const EVP_MD *md); OSSL_DEPRECATEDIN_3_0 int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx); OSSL_DEPRECATEDIN_3_0 -int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx, const void *data, size_t count); +int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx, + const void *data, size_t count); OSSL_DEPRECATEDIN_3_0 -int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx, unsigned char *md); +int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx, + unsigned char *md); OSSL_DEPRECATEDIN_3_0 -int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to, const EVP_MD_CTX *from); +int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to, + const EVP_MD_CTX *from); OSSL_DEPRECATEDIN_3_0 int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx); OSSL_DEPRECATEDIN_3_0 -int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); -# endif +int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, int p1, + void *p2); +# endif /* digest can only handle a single block */ -# define EVP_MD_FLAG_ONESHOT 0x0001 +# define EVP_MD_FLAG_ONESHOT 0x0001 /* digest is extensible-output function, XOF */ -# define EVP_MD_FLAG_XOF 0x0002 +# define EVP_MD_FLAG_XOF 0x0002 /* DigestAlgorithmIdentifier flags... */ -# define EVP_MD_FLAG_DIGALGID_MASK 0x0018 +# define EVP_MD_FLAG_DIGALGID_MASK 0x0018 /* NULL or absent parameter accepted. Use NULL */ -# define EVP_MD_FLAG_DIGALGID_NULL 0x0000 +# define EVP_MD_FLAG_DIGALGID_NULL 0x0000 /* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */ -# define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008 +# define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008 /* Custom handling via ctrl */ -# define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018 +# define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018 /* Note if suitable for use in FIPS mode */ -# define EVP_MD_FLAG_FIPS 0x0400 +# define EVP_MD_FLAG_FIPS 0x0400 /* Digest ctrls */ -# define EVP_MD_CTRL_DIGALGID 0x1 -# define EVP_MD_CTRL_MICALG 0x2 -# define EVP_MD_CTRL_XOF_LEN 0x3 -# define EVP_MD_CTRL_TLSTREE 0x4 +# define EVP_MD_CTRL_DIGALGID 0x1 +# define EVP_MD_CTRL_MICALG 0x2 +# define EVP_MD_CTRL_XOF_LEN 0x3 +# define EVP_MD_CTRL_TLSTREE 0x4 /* Minimum Algorithm specific ctrl value */ -# define EVP_MD_CTRL_ALG_CTRL 0x1000 +# define EVP_MD_CTRL_ALG_CTRL 0x1000 #endif /* !EVP_MD */ /* values for EVP_MD_CTX flags */ -#define EVP_MD_CTX_FLAG_ONESHOT \ - 0x0001 /* digest update will be \ - * called once only */ -#define EVP_MD_CTX_FLAG_CLEANED \ - 0x0002 /* context has already been \ - * cleaned */ -#define EVP_MD_CTX_FLAG_REUSE \ - 0x0004 /* Don't free up ctx->md_data \ - * in EVP_MD_CTX_reset */ +#define EVP_MD_CTX_FLAG_ONESHOT \ + 0x0001 /* digest update will be \ + * called once only */ +#define EVP_MD_CTX_FLAG_CLEANED \ + 0x0002 /* context has already been \ + * cleaned */ +#define EVP_MD_CTX_FLAG_REUSE \ + 0x0004 /* Don't free up ctx->md_data \ + * in EVP_MD_CTX_reset */ /* * FIPS and pad options are ignored in 1.0.0, definitions are here so we * don't accidentally reuse the values for other purposes. @@ -205,10 +214,10 @@ int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, int p1, * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*() * instead. */ -#define EVP_MD_CTX_FLAG_PAD_MASK 0xF0 /* RSA mode to use */ +#define EVP_MD_CTX_FLAG_PAD_MASK 0xF0 /* RSA mode to use */ #define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00 /* PKCS#1 v1.5 mode */ -#define EVP_MD_CTX_FLAG_PAD_X931 0x10 /* X9.31 mode */ -#define EVP_MD_CTX_FLAG_PAD_PSS 0x20 /* PSS mode */ +#define EVP_MD_CTX_FLAG_PAD_X931 0x10 /* X9.31 mode */ +#define EVP_MD_CTX_FLAG_PAD_PSS 0x20 /* PSS mode */ #define EVP_MD_CTX_FLAG_NO_INIT 0x0100 /* Don't initialize md_data */ /* @@ -234,36 +243,44 @@ OSSL_DEPRECATEDIN_3_0 int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size); OSSL_DEPRECATEDIN_3_0 int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher, - int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + int (*init)(EVP_CIPHER_CTX *ctx, + const unsigned char *key, const unsigned char *iv, int enc)); OSSL_DEPRECATEDIN_3_0 int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher, - int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl)); + int (*do_cipher)(EVP_CIPHER_CTX *ctx, + unsigned char *out, + const unsigned char *in, + size_t inl)); OSSL_DEPRECATEDIN_3_0 -int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, int (*cleanup)(EVP_CIPHER_CTX *)); +int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, + int (*cleanup)(EVP_CIPHER_CTX *)); OSSL_DEPRECATEDIN_3_0 -int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher, - int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)); +int EVP_CIPHER_meth_set_set_asn1_params( + EVP_CIPHER *cipher, + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)); OSSL_DEPRECATEDIN_3_0 -int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher, - int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)); +int EVP_CIPHER_meth_set_get_asn1_params( + EVP_CIPHER *cipher, + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)); OSSL_DEPRECATEDIN_3_0 int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher, - int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr)); + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, + void *ptr)); OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))( - EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); -OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))( - EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl); -OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))( - EVP_CIPHER_CTX *); -OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))( - EVP_CIPHER_CTX *, ASN1_TYPE *); -OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))( - EVP_CIPHER_CTX *, ASN1_TYPE *); -OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - int type, int arg, - void *ptr); + EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, + int enc); +OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_do_cipher( + const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, size_t inl); +OSSL_DEPRECATEDIN_3_0 int ( + *EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *); +OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_set_asn1_params( + const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, ASN1_TYPE *); +OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_get_asn1_params( + const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, ASN1_TYPE *); +OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))( + EVP_CIPHER_CTX *, int type, int arg, void *ptr); #endif /* Values for cipher flags */ @@ -424,10 +441,10 @@ OSSL_DEPRECATEDIN_3_0 int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))( typedef struct { - unsigned char *out; - const unsigned char *inp; - size_t len; - unsigned int interleave; + unsigned char *out; + const unsigned char *inp; + size_t len; + unsigned int interleave; } EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM; /* GCM TLS constants */ @@ -455,42 +472,50 @@ typedef struct typedef struct evp_cipher_info_st { - const EVP_CIPHER *cipher; - unsigned char iv[EVP_MAX_IV_LENGTH]; + const EVP_CIPHER *cipher; + unsigned char iv[EVP_MAX_IV_LENGTH]; } EVP_CIPHER_INFO; /* Password based encryption function */ -typedef int(EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, int en_de); +typedef int(EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); -typedef int(EVP_PBE_KEYGEN_EX)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, int en_de, - OSSL_LIB_CTX *libctx, const char *propq); +typedef int(EVP_PBE_KEYGEN_EX)(EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *cipher, const EVP_MD *md, + int en_de, OSSL_LIB_CTX *libctx, + const char *propq); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define EVP_PKEY_assign_RSA(pkey, rsa) EVP_PKEY_assign((pkey), EVP_PKEY_RSA, (rsa)) +# define EVP_PKEY_assign_RSA(pkey, rsa) \ + EVP_PKEY_assign((pkey), EVP_PKEY_RSA, (rsa)) #endif #ifndef OPENSSL_NO_DSA -# define EVP_PKEY_assign_DSA(pkey, dsa) EVP_PKEY_assign((pkey), EVP_PKEY_DSA, (dsa)) +# define EVP_PKEY_assign_DSA(pkey, dsa) \ + EVP_PKEY_assign((pkey), EVP_PKEY_DSA, (dsa)) #endif #if !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_DEPRECATED_3_0) -# define EVP_PKEY_assign_DH(pkey, dh) EVP_PKEY_assign((pkey), EVP_PKEY_DH, (dh)) +# define EVP_PKEY_assign_DH(pkey, dh) \ + EVP_PKEY_assign((pkey), EVP_PKEY_DH, (dh)) #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_EC -# define EVP_PKEY_assign_EC_KEY(pkey, eckey) EVP_PKEY_assign((pkey), EVP_PKEY_EC, (eckey)) -# endif +# ifndef OPENSSL_NO_EC +# define EVP_PKEY_assign_EC_KEY(pkey, eckey) \ + EVP_PKEY_assign((pkey), EVP_PKEY_EC, (eckey)) +# endif #endif #ifndef OPENSSL_NO_SIPHASH -# define EVP_PKEY_assign_SIPHASH(pkey, shkey) EVP_PKEY_assign((pkey), EVP_PKEY_SIPHASH, (shkey)) +# define EVP_PKEY_assign_SIPHASH(pkey, shkey) \ + EVP_PKEY_assign((pkey), EVP_PKEY_SIPHASH, (shkey)) #endif #ifndef OPENSSL_NO_POLY1305 -# define EVP_PKEY_assign_POLY1305(pkey, polykey) \ - EVP_PKEY_assign((pkey), EVP_PKEY_POLY1305, (polykey)) +# define EVP_PKEY_assign_POLY1305(pkey, polykey) \ + EVP_PKEY_assign((pkey), EVP_PKEY_POLY1305, (polykey)) #endif /* Add some extra combinations */ @@ -506,7 +531,8 @@ const char *EVP_MD_get0_name(const EVP_MD *md); #define EVP_MD_name EVP_MD_get0_name const char *EVP_MD_get0_description(const EVP_MD *md); int EVP_MD_is_a(const EVP_MD *md, const char *name); -int EVP_MD_names_do_all(const EVP_MD *md, void (*fn)(const char *name, void *data), void *data); +int EVP_MD_names_do_all(const EVP_MD *md, + void (*fn)(const char *name, void *data), void *data); const OSSL_PROVIDER *EVP_MD_get0_provider(const EVP_MD *md); int EVP_MD_get_pkey_type(const EVP_MD *md); #define EVP_MD_pkey_type EVP_MD_get_pkey_type @@ -523,15 +549,18 @@ EVP_MD *EVP_MD_CTX_get1_md(EVP_MD_CTX *ctx); OSSL_DEPRECATEDIN_3_0 const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); OSSL_DEPRECATEDIN_3_0 -int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx, const void *data, size_t count); +int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx, const void *data, + size_t count); OSSL_DEPRECATEDIN_3_0 void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx, - int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count)); + int (*update)(EVP_MD_CTX *ctx, const void *data, + size_t count)); #endif #define EVP_MD_CTX_get0_name(e) EVP_MD_get0_name(EVP_MD_CTX_get0_md(e)) #define EVP_MD_CTX_get_size(e) EVP_MD_get_size(EVP_MD_CTX_get0_md(e)) #define EVP_MD_CTX_size EVP_MD_CTX_get_size -#define EVP_MD_CTX_get_block_size(e) EVP_MD_get_block_size(EVP_MD_CTX_get0_md(e)) +#define EVP_MD_CTX_get_block_size(e) \ + EVP_MD_get_block_size(EVP_MD_CTX_get0_md(e)) #define EVP_MD_CTX_block_size EVP_MD_CTX_get_block_size #define EVP_MD_CTX_get_type(e) EVP_MD_get_type(EVP_MD_CTX_get0_md(e)) #define EVP_MD_CTX_type EVP_MD_CTX_get_type @@ -547,7 +576,8 @@ const char *EVP_CIPHER_get0_name(const EVP_CIPHER *cipher); #define EVP_CIPHER_name EVP_CIPHER_get0_name const char *EVP_CIPHER_get0_description(const EVP_CIPHER *cipher); int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name); -int EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher, void (*fn)(const char *name, void *data), +int EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher, + void (*fn)(const char *name, void *data), void *data); const OSSL_PROVIDER *EVP_CIPHER_get0_provider(const EVP_CIPHER *cipher); int EVP_CIPHER_get_block_size(const EVP_CIPHER *cipher); @@ -566,7 +596,8 @@ int EVP_CIPHER_get_mode(const EVP_CIPHER *cipher); #define EVP_CIPHER_mode EVP_CIPHER_get_mode int EVP_CIPHER_get_type(const EVP_CIPHER *cipher); #define EVP_CIPHER_type EVP_CIPHER_get_type -EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties); +EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); int EVP_CIPHER_up_ref(EVP_CIPHER *cipher); void EVP_CIPHER_free(EVP_CIPHER *cipher); @@ -586,9 +617,12 @@ int EVP_CIPHER_CTX_get_tag_length(const EVP_CIPHER_CTX *ctx); #define EVP_CIPHER_CTX_tag_length EVP_CIPHER_CTX_get_tag_length #ifndef OPENSSL_NO_DEPRECATED_3_0 const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); -OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); -OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx); -OSSL_DEPRECATEDIN_3_0 unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 const unsigned char * +EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 const unsigned char * +EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx); +OSSL_DEPRECATEDIN_3_0 unsigned char * +EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); #endif int EVP_CIPHER_CTX_get_updated_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len); int EVP_CIPHER_CTX_get_original_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len); @@ -605,13 +639,17 @@ void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx); void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data); -#define EVP_CIPHER_CTX_get0_name(c) EVP_CIPHER_get0_name(EVP_CIPHER_CTX_get0_cipher(c)) -#define EVP_CIPHER_CTX_get_type(c) EVP_CIPHER_get_type(EVP_CIPHER_CTX_get0_cipher(c)) +#define EVP_CIPHER_CTX_get0_name(c) \ + EVP_CIPHER_get0_name(EVP_CIPHER_CTX_get0_cipher(c)) +#define EVP_CIPHER_CTX_get_type(c) \ + EVP_CIPHER_get_type(EVP_CIPHER_CTX_get0_cipher(c)) #define EVP_CIPHER_CTX_type EVP_CIPHER_CTX_get_type #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(c)) +# define EVP_CIPHER_CTX_flags(c) \ + EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(c)) #endif -#define EVP_CIPHER_CTX_get_mode(c) EVP_CIPHER_get_mode(EVP_CIPHER_CTX_get0_cipher(c)) +#define EVP_CIPHER_CTX_get_mode(c) \ + EVP_CIPHER_get_mode(EVP_CIPHER_CTX_get0_cipher(c)) #define EVP_CIPHER_CTX_mode EVP_CIPHER_CTX_get_mode #define EVP_ENCODE_LENGTH(l) ((((l) + 2) / 3 * 4) + ((l) / 48 + 1) * 2 + 80) @@ -629,7 +667,7 @@ void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data); #ifdef CONST_STRICT void BIO_set_md(BIO *, const EVP_MD *md); #else -# define BIO_set_md(b, md) BIO_ctrl(b, BIO_C_SET_MD, 0, (void *)(md)) +# define BIO_set_md(b, md) BIO_ctrl(b, BIO_C_SET_MD, 0, (void *)(md)) #endif #define BIO_get_md(b, mdp) BIO_ctrl(b, BIO_C_GET_MD, 0, (mdp)) #define BIO_get_md_ctx(b, mdcp) BIO_ctrl(b, BIO_C_GET_MD_CTX, 0, (mdcp)) @@ -637,17 +675,17 @@ void BIO_set_md(BIO *, const EVP_MD *md); #define BIO_get_cipher_status(b) BIO_ctrl(b, BIO_C_GET_CIPHER_STATUS, 0, NULL) #define BIO_get_cipher_ctx(b, c_pp) BIO_ctrl(b, BIO_C_GET_CIPHER_CTX, 0, (c_pp)) -/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c, unsigned char *out, const unsigned char *in, - unsigned int inl); +/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c, unsigned char *out, + const unsigned char *in, unsigned int inl); -#define EVP_add_cipher_alias(n, alias) \ - OBJ_NAME_add((alias), OBJ_NAME_TYPE_CIPHER_METH | OBJ_NAME_ALIAS, (n)) -#define EVP_add_digest_alias(n, alias) \ - OBJ_NAME_add((alias), OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, (n)) -#define EVP_delete_cipher_alias(alias) \ - OBJ_NAME_remove(alias, OBJ_NAME_TYPE_CIPHER_METH | OBJ_NAME_ALIAS); -#define EVP_delete_digest_alias(alias) \ - OBJ_NAME_remove(alias, OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS); +#define EVP_add_cipher_alias(n, alias) \ + OBJ_NAME_add((alias), OBJ_NAME_TYPE_CIPHER_METH | OBJ_NAME_ALIAS, (n)) +#define EVP_add_digest_alias(n, alias) \ + OBJ_NAME_add((alias), OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, (n)) +#define EVP_delete_cipher_alias(alias) \ + OBJ_NAME_remove(alias, OBJ_NAME_TYPE_CIPHER_METH | OBJ_NAME_ALIAS); +#define EVP_delete_digest_alias(alias) \ + OBJ_NAME_remove(alias, OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS); int EVP_MD_get_params(const EVP_MD *digest, OSSL_PARAM params[]); int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]); @@ -669,111 +707,140 @@ __owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); -__owur int EVP_DigestInit_ex2(EVP_MD_CTX *ctx, const EVP_MD *type, const OSSL_PARAM params[]); +__owur int EVP_DigestInit_ex2(EVP_MD_CTX *ctx, const EVP_MD *type, + const OSSL_PARAM params[]); __owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); __owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); -__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s); -__owur int EVP_Digest(const void *data, size_t count, unsigned char *md, unsigned int *size, - const EVP_MD *type, ENGINE *impl); -__owur int EVP_Q_digest(OSSL_LIB_CTX *libctx, const char *name, const char *propq, const void *data, - size_t datalen, unsigned char *md, size_t *mdlen); +__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, + unsigned int *s); +__owur int EVP_Digest(const void *data, size_t count, unsigned char *md, + unsigned int *size, const EVP_MD *type, ENGINE *impl); +__owur int EVP_Q_digest(OSSL_LIB_CTX *libctx, const char *name, + const char *propq, const void *data, size_t datalen, + unsigned char *md, size_t *mdlen); __owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in); __owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); __owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s); __owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t len); -__owur EVP_MD *EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties); +__owur EVP_MD *EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); int EVP_MD_up_ref(EVP_MD *md); void EVP_MD_free(EVP_MD *md); int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify); -int EVP_read_pw_string_min(char *buf, int minlen, int maxlen, const char *prompt, int verify); +int EVP_read_pw_string_min(char *buf, int minlen, int maxlen, + const char *prompt, int verify); void EVP_set_pw_prompt(const char *prompt); char *EVP_get_pw_prompt(void); -__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, const unsigned char *salt, - const unsigned char *data, int datal, int count, unsigned char *key, +__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, + const unsigned char *salt, const unsigned char *data, + int datal, int count, unsigned char *key, unsigned char *iv); void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags); void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags); int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags); -__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, - const unsigned char *iv); -/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, const unsigned char *iv); +__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + ENGINE *impl, const unsigned char *key, + const unsigned char *iv); __owur int EVP_EncryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, + const unsigned char *key, + const unsigned char *iv, const OSSL_PARAM params[]); -/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl); -/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); -/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); +/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl); +/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl); -__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, - const unsigned char *iv); -/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, const unsigned char *iv); +__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv); +/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + ENGINE *impl, const unsigned char *key, + const unsigned char *iv); __owur int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, + const unsigned char *key, + const unsigned char *iv, const OSSL_PARAM params[]); -/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl); -__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); -/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, + int *outl, const unsigned char *in, int inl); +__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); +/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); -__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, - const unsigned char *iv, int enc); -/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, const unsigned char *iv, int enc); +__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + const unsigned char *key, const unsigned char *iv, + int enc); +/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + ENGINE *impl, const unsigned char *key, + const unsigned char *iv, int enc); __owur int EVP_CipherInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, int enc, - const OSSL_PARAM params[]); + const unsigned char *key, const unsigned char *iv, + int enc, const OSSL_PARAM params[]); __owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl); __owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); -__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); +__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, + int *outl); -__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, EVP_PKEY *pkey); -__owur int EVP_SignFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, EVP_PKEY *pkey, - OSSL_LIB_CTX *libctx, const char *propq); +__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, + EVP_PKEY *pkey); +__owur int EVP_SignFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, + EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, + const char *propq); -__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen, - const unsigned char *tbs, size_t tbslen); +__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, + size_t *siglen, const unsigned char *tbs, + size_t tbslen); -__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, unsigned int siglen, - EVP_PKEY *pkey); -__owur int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf, unsigned int siglen, - EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, const char *propq); +__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, + unsigned int siglen, EVP_PKEY *pkey); +__owur int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf, + unsigned int siglen, EVP_PKEY *pkey, + OSSL_LIB_CTX *libctx, const char *propq); -__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, size_t siglen, - const unsigned char *tbs, size_t tbslen); +__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, + size_t siglen, const unsigned char *tbs, + size_t tbslen); -int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const char *mdname, - OSSL_LIB_CTX *libctx, const char *props, EVP_PKEY *pkey, +int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const char *mdname, OSSL_LIB_CTX *libctx, + const char *props, EVP_PKEY *pkey, const OSSL_PARAM params[]); -/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, - ENGINE *e, EVP_PKEY *pkey); +/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const EVP_MD *type, ENGINE *e, + EVP_PKEY *pkey); int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize); -__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen); +__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, + size_t *siglen); -int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const char *mdname, - OSSL_LIB_CTX *libctx, const char *props, EVP_PKEY *pkey, +int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const char *mdname, OSSL_LIB_CTX *libctx, + const char *props, EVP_PKEY *pkey, const OSSL_PARAM params[]); -__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); +__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, + const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey); int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize); -__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen); +__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen); -__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *ek, - int ekl, const unsigned char *iv, EVP_PKEY *priv); +__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + const unsigned char *ek, int ekl, + const unsigned char *iv, EVP_PKEY *priv); __owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); -__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, int *ekl, - unsigned char *iv, EVP_PKEY **pubk, int npubk); +__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); __owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void); @@ -781,20 +848,20 @@ void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx); int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, const EVP_ENCODE_CTX *sctx); int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx); void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); -int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, - int inl); +int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, + const unsigned char *in, int inl); void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl); int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); -int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, - int inl); +int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, + const unsigned char *in, int inl); int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl); int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c) -# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c) +# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c) +# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c) #endif EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c); @@ -868,13 +935,13 @@ const EVP_CIPHER *EVP_des_ede3(void); const EVP_CIPHER *EVP_des_ede_ecb(void); const EVP_CIPHER *EVP_des_ede3_ecb(void); const EVP_CIPHER *EVP_des_cfb64(void); -# define EVP_des_cfb EVP_des_cfb64 +# define EVP_des_cfb EVP_des_cfb64 const EVP_CIPHER *EVP_des_cfb1(void); const EVP_CIPHER *EVP_des_cfb8(void); const EVP_CIPHER *EVP_des_ede_cfb64(void); -# define EVP_des_ede_cfb EVP_des_ede_cfb64 +# define EVP_des_ede_cfb EVP_des_ede_cfb64 const EVP_CIPHER *EVP_des_ede3_cfb64(void); -# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 +# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 const EVP_CIPHER *EVP_des_ede3_cfb1(void); const EVP_CIPHER *EVP_des_ede3_cfb8(void); const EVP_CIPHER *EVP_des_ofb(void); @@ -894,14 +961,14 @@ const EVP_CIPHER *EVP_des_ede3_wrap(void); #ifndef OPENSSL_NO_RC4 const EVP_CIPHER *EVP_rc4(void); const EVP_CIPHER *EVP_rc4_40(void); -# ifndef OPENSSL_NO_MD5 +# ifndef OPENSSL_NO_MD5 const EVP_CIPHER *EVP_rc4_hmac_md5(void); -# endif +# endif #endif #ifndef OPENSSL_NO_IDEA const EVP_CIPHER *EVP_idea_ecb(void); const EVP_CIPHER *EVP_idea_cfb64(void); -# define EVP_idea_cfb EVP_idea_cfb64 +# define EVP_idea_cfb EVP_idea_cfb64 const EVP_CIPHER *EVP_idea_ofb(void); const EVP_CIPHER *EVP_idea_cbc(void); #endif @@ -911,28 +978,28 @@ const EVP_CIPHER *EVP_rc2_cbc(void); const EVP_CIPHER *EVP_rc2_40_cbc(void); const EVP_CIPHER *EVP_rc2_64_cbc(void); const EVP_CIPHER *EVP_rc2_cfb64(void); -# define EVP_rc2_cfb EVP_rc2_cfb64 +# define EVP_rc2_cfb EVP_rc2_cfb64 const EVP_CIPHER *EVP_rc2_ofb(void); #endif #ifndef OPENSSL_NO_BF const EVP_CIPHER *EVP_bf_ecb(void); const EVP_CIPHER *EVP_bf_cbc(void); const EVP_CIPHER *EVP_bf_cfb64(void); -# define EVP_bf_cfb EVP_bf_cfb64 +# define EVP_bf_cfb EVP_bf_cfb64 const EVP_CIPHER *EVP_bf_ofb(void); #endif #ifndef OPENSSL_NO_CAST const EVP_CIPHER *EVP_cast5_ecb(void); const EVP_CIPHER *EVP_cast5_cbc(void); const EVP_CIPHER *EVP_cast5_cfb64(void); -# define EVP_cast5_cfb EVP_cast5_cfb64 +# define EVP_cast5_cfb EVP_cast5_cfb64 const EVP_CIPHER *EVP_cast5_ofb(void); #endif #ifndef OPENSSL_NO_RC5 const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); -# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 +# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); #endif const EVP_CIPHER *EVP_aes_128_ecb(void); @@ -992,7 +1059,7 @@ const EVP_CIPHER *EVP_aria_128_cbc(void); const EVP_CIPHER *EVP_aria_128_cfb1(void); const EVP_CIPHER *EVP_aria_128_cfb8(void); const EVP_CIPHER *EVP_aria_128_cfb128(void); -# define EVP_aria_128_cfb EVP_aria_128_cfb128 +# define EVP_aria_128_cfb EVP_aria_128_cfb128 const EVP_CIPHER *EVP_aria_128_ctr(void); const EVP_CIPHER *EVP_aria_128_ofb(void); const EVP_CIPHER *EVP_aria_128_gcm(void); @@ -1002,7 +1069,7 @@ const EVP_CIPHER *EVP_aria_192_cbc(void); const EVP_CIPHER *EVP_aria_192_cfb1(void); const EVP_CIPHER *EVP_aria_192_cfb8(void); const EVP_CIPHER *EVP_aria_192_cfb128(void); -# define EVP_aria_192_cfb EVP_aria_192_cfb128 +# define EVP_aria_192_cfb EVP_aria_192_cfb128 const EVP_CIPHER *EVP_aria_192_ctr(void); const EVP_CIPHER *EVP_aria_192_ofb(void); const EVP_CIPHER *EVP_aria_192_gcm(void); @@ -1012,7 +1079,7 @@ const EVP_CIPHER *EVP_aria_256_cbc(void); const EVP_CIPHER *EVP_aria_256_cfb1(void); const EVP_CIPHER *EVP_aria_256_cfb8(void); const EVP_CIPHER *EVP_aria_256_cfb128(void); -# define EVP_aria_256_cfb EVP_aria_256_cfb128 +# define EVP_aria_256_cfb EVP_aria_256_cfb128 const EVP_CIPHER *EVP_aria_256_ctr(void); const EVP_CIPHER *EVP_aria_256_ofb(void); const EVP_CIPHER *EVP_aria_256_gcm(void); @@ -1024,7 +1091,7 @@ const EVP_CIPHER *EVP_camellia_128_cbc(void); const EVP_CIPHER *EVP_camellia_128_cfb1(void); const EVP_CIPHER *EVP_camellia_128_cfb8(void); const EVP_CIPHER *EVP_camellia_128_cfb128(void); -# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 +# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 const EVP_CIPHER *EVP_camellia_128_ofb(void); const EVP_CIPHER *EVP_camellia_128_ctr(void); const EVP_CIPHER *EVP_camellia_192_ecb(void); @@ -1032,7 +1099,7 @@ const EVP_CIPHER *EVP_camellia_192_cbc(void); const EVP_CIPHER *EVP_camellia_192_cfb1(void); const EVP_CIPHER *EVP_camellia_192_cfb8(void); const EVP_CIPHER *EVP_camellia_192_cfb128(void); -# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 +# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 const EVP_CIPHER *EVP_camellia_192_ofb(void); const EVP_CIPHER *EVP_camellia_192_ctr(void); const EVP_CIPHER *EVP_camellia_256_ecb(void); @@ -1040,22 +1107,22 @@ const EVP_CIPHER *EVP_camellia_256_cbc(void); const EVP_CIPHER *EVP_camellia_256_cfb1(void); const EVP_CIPHER *EVP_camellia_256_cfb8(void); const EVP_CIPHER *EVP_camellia_256_cfb128(void); -# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 +# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 const EVP_CIPHER *EVP_camellia_256_ofb(void); const EVP_CIPHER *EVP_camellia_256_ctr(void); #endif #ifndef OPENSSL_NO_CHACHA const EVP_CIPHER *EVP_chacha20(void); -# ifndef OPENSSL_NO_POLY1305 +# ifndef OPENSSL_NO_POLY1305 const EVP_CIPHER *EVP_chacha20_poly1305(void); -# endif +# endif #endif #ifndef OPENSSL_NO_SEED const EVP_CIPHER *EVP_seed_ecb(void); const EVP_CIPHER *EVP_seed_cbc(void); const EVP_CIPHER *EVP_seed_cfb128(void); -# define EVP_seed_cfb EVP_seed_cfb128 +# define EVP_seed_cfb EVP_seed_cfb128 const EVP_CIPHER *EVP_seed_ofb(void); #endif @@ -1063,31 +1130,35 @@ const EVP_CIPHER *EVP_seed_ofb(void); const EVP_CIPHER *EVP_sm4_ecb(void); const EVP_CIPHER *EVP_sm4_cbc(void); const EVP_CIPHER *EVP_sm4_cfb128(void); -# define EVP_sm4_cfb EVP_sm4_cfb128 +# define EVP_sm4_cfb EVP_sm4_cfb128 const EVP_CIPHER *EVP_sm4_ofb(void); const EVP_CIPHER *EVP_sm4_ctr(void); #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define OPENSSL_add_all_algorithms_conf() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS \ - | OPENSSL_INIT_LOAD_CONFIG, \ - NULL) -# define OPENSSL_add_all_algorithms_noconf() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) +# define OPENSSL_add_all_algorithms_conf() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ + | OPENSSL_INIT_ADD_ALL_DIGESTS \ + | OPENSSL_INIT_LOAD_CONFIG, \ + NULL) +# define OPENSSL_add_all_algorithms_noconf() \ + OPENSSL_init_crypto( \ + OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) -# ifdef OPENSSL_LOAD_CONF -# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf() -# else -# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf() -# endif +# ifdef OPENSSL_LOAD_CONF +# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf() +# else +# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf() +# endif -# define OpenSSL_add_all_ciphers() OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL) -# define OpenSSL_add_all_digests() OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) +# define OpenSSL_add_all_ciphers() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL) +# define OpenSSL_add_all_digests() \ + OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) -# define EVP_cleanup() \ - while (0) \ - continue +# define EVP_cleanup() \ + while (0) \ + continue #endif int EVP_add_cipher(const EVP_CIPHER *cipher); @@ -1096,24 +1167,30 @@ int EVP_add_digest(const EVP_MD *digest); const EVP_CIPHER *EVP_get_cipherbyname(const char *name); const EVP_MD *EVP_get_digestbyname(const char *name); -void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph, const char *from, const char *to, - void *x), +void EVP_CIPHER_do_all(void (*fn)(const EVP_CIPHER *ciph, const char *from, + const char *to, void *x), void *arg); -void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph, const char *from, const char *to, +void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph, + const char *from, const char *to, void *x), void *arg); -void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_CIPHER *cipher, void *arg), +void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_CIPHER *cipher, void *arg), void *arg); -void EVP_MD_do_all(void (*fn)(const EVP_MD *ciph, const char *from, const char *to, void *x), +void EVP_MD_do_all(void (*fn)(const EVP_MD *ciph, const char *from, + const char *to, void *x), void *arg); -void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *ciph, const char *from, const char *to, void *x), +void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *ciph, const char *from, + const char *to, void *x), void *arg); -void EVP_MD_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_MD *md, void *arg), void *arg); +void EVP_MD_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_MD *md, void *arg), void *arg); /* MAC stuff */ -EVP_MAC *EVP_MAC_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, const char *properties); +EVP_MAC *EVP_MAC_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, + const char *properties); int EVP_MAC_up_ref(EVP_MAC *mac); void EVP_MAC_free(EVP_MAC *mac); const char *EVP_MAC_get0_name(const EVP_MAC *mac); @@ -1131,14 +1208,17 @@ int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]); size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx); size_t EVP_MAC_CTX_get_block_size(EVP_MAC_CTX *ctx); -unsigned char *EVP_Q_mac(OSSL_LIB_CTX *libctx, const char *name, const char *propq, - const char *subalg, const OSSL_PARAM *params, const void *key, - size_t keylen, const unsigned char *data, size_t datalen, - unsigned char *out, size_t outsize, size_t *outlen); +unsigned char *EVP_Q_mac(OSSL_LIB_CTX *libctx, const char *name, + const char *propq, const char *subalg, + const OSSL_PARAM *params, const void *key, + size_t keylen, const unsigned char *data, + size_t datalen, unsigned char *out, size_t outsize, + size_t *outlen); int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen, const OSSL_PARAM params[]); int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen); -int EVP_MAC_final(EVP_MAC_CTX *ctx, unsigned char *out, size_t *outl, size_t outsize); +int EVP_MAC_final(EVP_MAC_CTX *ctx, unsigned char *out, size_t *outl, + size_t outsize); int EVP_MAC_finalXOF(EVP_MAC_CTX *ctx, unsigned char *out, size_t outsize); const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac); @@ -1146,11 +1226,14 @@ const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_CTX_gettable_params(EVP_MAC_CTX *ctx); const OSSL_PARAM *EVP_MAC_CTX_settable_params(EVP_MAC_CTX *ctx); -void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_MAC *mac, void *arg), void *arg); -int EVP_MAC_names_do_all(const EVP_MAC *mac, void (*fn)(const char *name, void *data), void *data); +void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_MAC *mac, void *arg), void *arg); +int EVP_MAC_names_do_all(const EVP_MAC *mac, + void (*fn)(const char *name, void *data), void *data); /* RAND stuff */ -EVP_RAND *EVP_RAND_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, const char *properties); +EVP_RAND *EVP_RAND_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, + const char *properties); int EVP_RAND_up_ref(EVP_RAND *rand); void EVP_RAND_free(EVP_RAND *rand); const char *EVP_RAND_get0_name(const EVP_RAND *rand); @@ -1171,20 +1254,23 @@ const OSSL_PARAM *EVP_RAND_settable_ctx_params(const EVP_RAND *rand); const OSSL_PARAM *EVP_RAND_CTX_gettable_params(EVP_RAND_CTX *ctx); const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx); -void EVP_RAND_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_RAND *rand, void *arg), - void *arg); -int EVP_RAND_names_do_all(const EVP_RAND *rand, void (*fn)(const char *name, void *data), - void *data); +void EVP_RAND_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_RAND *rand, void *arg), void *arg); +int EVP_RAND_names_do_all(const EVP_RAND *rand, + void (*fn)(const char *name, void *data), void *data); -__owur int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength, int prediction_resistance, +__owur int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength, + int prediction_resistance, const unsigned char *pstr, size_t pstr_len, const OSSL_PARAM params[]); int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx); -__owur int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen, - unsigned int strength, int prediction_resistance, +__owur int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, + size_t outlen, unsigned int strength, + int prediction_resistance, const unsigned char *addin, size_t addin_len); -int EVP_RAND_reseed(EVP_RAND_CTX *ctx, int prediction_resistance, const unsigned char *ent, - size_t ent_len, const unsigned char *addin, size_t addin_len); +int EVP_RAND_reseed(EVP_RAND_CTX *ctx, int prediction_resistance, + const unsigned char *ent, size_t ent_len, + const unsigned char *addin, size_t addin_len); __owur int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen); __owur int EVP_RAND_enable_locking(EVP_RAND_CTX *ctx); @@ -1198,13 +1284,17 @@ int EVP_RAND_get_state(EVP_RAND_CTX *ctx); /* PKEY stuff */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_decrypt_old(unsigned char *dec_key, const unsigned char *enc_key, - int enc_key_len, EVP_PKEY *private_key); -OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_encrypt_old(unsigned char *enc_key, const unsigned char *key, +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_decrypt_old(unsigned char *dec_key, + const unsigned char *enc_key, + int enc_key_len, + EVP_PKEY *private_key); +OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_encrypt_old(unsigned char *enc_key, + const unsigned char *key, int key_len, EVP_PKEY *pub_key); #endif int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name); -int EVP_PKEY_type_names_do_all(const EVP_PKEY *pkey, void (*fn)(const char *name, void *data), +int EVP_PKEY_type_names_do_all(const EVP_PKEY *pkey, + void (*fn)(const char *name, void *data), void *data); int EVP_PKEY_type(int type); int EVP_PKEY_get_id(const EVP_PKEY *pkey); @@ -1222,26 +1312,26 @@ int EVP_PKEY_set_type(EVP_PKEY *pkey, int type); int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len); int EVP_PKEY_set_type_by_keymgmt(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e); OSSL_DEPRECATEDIN_3_0 ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); OSSL_DEPRECATEDIN_3_0 void *EVP_PKEY_get0(const EVP_PKEY *pkey); OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len); -# ifndef OPENSSL_NO_POLY1305 +# ifndef OPENSSL_NO_POLY1305 OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len); -# endif -# ifndef OPENSSL_NO_SIPHASH +# endif +# ifndef OPENSSL_NO_SIPHASH OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len); -# endif +# endif struct rsa_st; OSSL_DEPRECATEDIN_3_0 @@ -1251,7 +1341,7 @@ const struct rsa_st *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey); OSSL_DEPRECATEDIN_3_0 struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); -# ifndef OPENSSL_NO_DSA +# ifndef OPENSSL_NO_DSA struct dsa_st; OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key); @@ -1259,16 +1349,17 @@ OSSL_DEPRECATEDIN_3_0 const struct dsa_st *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey); OSSL_DEPRECATEDIN_3_0 struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); -# endif +# endif -# ifndef OPENSSL_NO_DH +# ifndef OPENSSL_NO_DH struct dh_st; OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key); -OSSL_DEPRECATEDIN_3_0 const struct dh_st *EVP_PKEY_get0_DH(const EVP_PKEY *pkey); +OSSL_DEPRECATEDIN_3_0 const struct dh_st * +EVP_PKEY_get0_DH(const EVP_PKEY *pkey); OSSL_DEPRECATEDIN_3_0 struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); -# endif +# endif -# ifndef OPENSSL_NO_EC +# ifndef OPENSSL_NO_EC struct ec_key_st; OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key); @@ -1276,7 +1367,7 @@ OSSL_DEPRECATEDIN_3_0 const struct ec_key_st *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey); OSSL_DEPRECATEDIN_3_0 struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); -# endif +# endif #endif /* OPENSSL_NO_DEPRECATED_3_0 */ EVP_PKEY *EVP_PKEY_new(void); @@ -1286,19 +1377,25 @@ void EVP_PKEY_free(EVP_PKEY *pkey); const char *EVP_PKEY_get0_description(const EVP_PKEY *pkey); const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key); -EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length); +EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, + long length); int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp); -EVP_PKEY *d2i_PrivateKey_ex(int type, EVP_PKEY **a, const unsigned char **pp, long length, - OSSL_LIB_CTX *libctx, const char *propq); -EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length); -EVP_PKEY *d2i_AutoPrivateKey_ex(EVP_PKEY **a, const unsigned char **pp, long length, - OSSL_LIB_CTX *libctx, const char *propq); -EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, long length); +EVP_PKEY *d2i_PrivateKey_ex(int type, EVP_PKEY **a, const unsigned char **pp, + long length, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, + long length); +EVP_PKEY *d2i_AutoPrivateKey_ex(EVP_PKEY **a, const unsigned char **pp, + long length, OSSL_LIB_CTX *libctx, + const char *propq); +EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, + long length); int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp); int i2d_KeyParams(const EVP_PKEY *a, unsigned char **pp); -EVP_PKEY *d2i_KeyParams(int type, EVP_PKEY **a, const unsigned char **pp, long length); +EVP_PKEY *d2i_KeyParams(int type, EVP_PKEY **a, const unsigned char **pp, + long length); int i2d_KeyParams_bio(BIO *bp, const EVP_PKEY *pkey); EVP_PKEY *d2i_KeyParams_bio(int type, EVP_PKEY **a, BIO *in); @@ -1315,38 +1412,46 @@ OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); #endif -int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); +int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); +int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); +int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); #ifndef OPENSSL_NO_STDIO -int EVP_PKEY_print_public_fp(FILE *fp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_private_fp(FILE *fp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_params_fp(FILE *fp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx); +int EVP_PKEY_print_public_fp(FILE *fp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); +int EVP_PKEY_print_private_fp(FILE *fp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); +int EVP_PKEY_print_params_fp(FILE *fp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); #endif int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); -int EVP_PKEY_get_default_digest_name(EVP_PKEY *pkey, char *mdname, size_t mdname_sz); -int EVP_PKEY_digestsign_supports_digest(EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, const char *name, - const char *propq); +int EVP_PKEY_get_default_digest_name(EVP_PKEY *pkey, char *mdname, + size_t mdname_sz); +int EVP_PKEY_digestsign_supports_digest(EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, + const char *name, const char *propq); #ifndef OPENSSL_NO_DEPRECATED_3_0 /* * For backwards compatibility. Use EVP_PKEY_set1_encoded_public_key in * preference */ -# define EVP_PKEY_set1_tls_encodedpoint(pkey, pt, ptlen) \ - EVP_PKEY_set1_encoded_public_key((pkey), (pt), (ptlen)) +# define EVP_PKEY_set1_tls_encodedpoint(pkey, pt, ptlen) \ + EVP_PKEY_set1_encoded_public_key((pkey), (pt), (ptlen)) #endif -int EVP_PKEY_set1_encoded_public_key(EVP_PKEY *pkey, const unsigned char *pub, size_t publen); +int EVP_PKEY_set1_encoded_public_key(EVP_PKEY *pkey, const unsigned char *pub, + size_t publen); #ifndef OPENSSL_NO_DEPRECATED_3_0 /* * For backwards compatibility. Use EVP_PKEY_get1_encoded_public_key in * preference */ -# define EVP_PKEY_get1_tls_encodedpoint(pkey, ppt) \ - EVP_PKEY_get1_encoded_public_key((pkey), (ppt)) +# define EVP_PKEY_get1_tls_encodedpoint(pkey, ppt) \ + EVP_PKEY_get1_encoded_public_key((pkey), (ppt)) #endif size_t EVP_PKEY_get1_encoded_public_key(EVP_PKEY *pkey, unsigned char **ppub); @@ -1360,43 +1465,55 @@ int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); /* PKCS5 password based encryption */ -int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, int en_de); -int PKCS5_PBE_keyivgen_ex(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, int en_de, - OSSL_LIB_CTX *libctx, const char *propq); -int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, const unsigned char *salt, int saltlen, - int iter, int keylen, unsigned char *out); -int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, const unsigned char *salt, int saltlen, - int iter, const EVP_MD *digest, int keylen, unsigned char *out); -int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, int en_de); -int PKCS5_v2_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, int en_de, - OSSL_LIB_CTX *libctx, const char *propq); +int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); +int PKCS5_PBE_keyivgen_ex(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de, OSSL_LIB_CTX *libctx, + const char *propq); +int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, + const unsigned char *salt, int saltlen, int iter, + int keylen, unsigned char *out); +int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, const unsigned char *salt, + int saltlen, int iter, const EVP_MD *digest, int keylen, + unsigned char *out); +int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de); +int PKCS5_v2_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md, int en_de, OSSL_LIB_CTX *libctx, + const char *propq); #ifndef OPENSSL_NO_SCRYPT -int EVP_PBE_scrypt(const char *pass, size_t passlen, const unsigned char *salt, size_t saltlen, - uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem, unsigned char *key, - size_t keylen); -int EVP_PBE_scrypt_ex(const char *pass, size_t passlen, const unsigned char *salt, size_t saltlen, - uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem, unsigned char *key, - size_t keylen, OSSL_LIB_CTX *ctx, const char *propq); +int EVP_PBE_scrypt(const char *pass, size_t passlen, const unsigned char *salt, + size_t saltlen, uint64_t N, uint64_t r, uint64_t p, + uint64_t maxmem, unsigned char *key, size_t keylen); +int EVP_PBE_scrypt_ex(const char *pass, size_t passlen, + const unsigned char *salt, size_t saltlen, uint64_t N, + uint64_t r, uint64_t p, uint64_t maxmem, + unsigned char *key, size_t keylen, OSSL_LIB_CTX *ctx, + const char *propq); -int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *c, const EVP_MD *md, int en_de); -int PKCS5_v2_scrypt_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de, - OSSL_LIB_CTX *libctx, const char *propq); +int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *c, + const EVP_MD *md, int en_de); +int PKCS5_v2_scrypt_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *c, const EVP_MD *md, + int en_de, OSSL_LIB_CTX *libctx, + const char *propq); #endif void PKCS5_PBE_add(void); -int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, ASN1_TYPE *param, - EVP_CIPHER_CTX *ctx, int en_de); +int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); -int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, ASN1_TYPE *param, - EVP_CIPHER_CTX *ctx, int en_de, OSSL_LIB_CTX *libctx, const char *propq); +int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, + ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de, + OSSL_LIB_CTX *libctx, const char *propq); /* PBE type */ @@ -1409,10 +1526,12 @@ int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, A int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid, EVP_PBE_KEYGEN *keygen); -int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, EVP_PBE_KEYGEN *keygen); -int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen); -int EVP_PBE_find_ex(int type, int pbe_nid, int *pcnid, int *pmnid, EVP_PBE_KEYGEN **pkeygen, - EVP_PBE_KEYGEN_EX **pkeygen_ex); +int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, + EVP_PBE_KEYGEN *keygen); +int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid, + EVP_PBE_KEYGEN **pkeygen); +int EVP_PBE_find_ex(int type, int pbe_nid, int *pcnid, int *pmnid, + EVP_PBE_KEYGEN **pkeygen, EVP_PBE_KEYGEN_EX **pkeygen_ex); void EVP_PBE_cleanup(void); int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num); @@ -1434,51 +1553,64 @@ int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num); int EVP_PKEY_asn1_get_count(void); const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx); const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len); +const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, + int len); int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth); int EVP_PKEY_asn1_add_alias(int to, int from); -int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags, const char **pinfo, - const char **ppem_str, const EVP_PKEY_ASN1_METHOD *ameth); +int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags, + const char **pinfo, const char **ppem_str, + const EVP_PKEY_ASN1_METHOD *ameth); const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey); -EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info); -void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src); +EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, + const char *info); +void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, + const EVP_PKEY_ASN1_METHOD *src); void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth); void EVP_PKEY_asn1_set_public( - EVP_PKEY_ASN1_METHOD *ameth, int (*pub_decode)(EVP_PKEY *pk, const X509_PUBKEY *pub), + EVP_PKEY_ASN1_METHOD *ameth, + int (*pub_decode)(EVP_PKEY *pk, const X509_PUBKEY *pub), int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk), int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b), - int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx), + int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx), int (*pkey_size)(const EVP_PKEY *pk), int (*pkey_bits)(const EVP_PKEY *pk)); -void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, - int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf), - int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk), - int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, - ASN1_PCTX *pctx)); +void EVP_PKEY_asn1_set_private( + EVP_PKEY_ASN1_METHOD *ameth, + int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf), + int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk), + int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx)); void EVP_PKEY_asn1_set_param( EVP_PKEY_ASN1_METHOD *ameth, int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen), int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder), - int (*param_missing)(const EVP_PKEY *pk), int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from), + int (*param_missing)(const EVP_PKEY *pk), + int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from), int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b), - int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)); + int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx)); -void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, void (*pkey_free)(EVP_PKEY *pkey)); +void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, + void (*pkey_free)(EVP_PKEY *pkey)); void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)); -void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth, - int (*item_verify)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, - const void *data, const X509_ALGOR *a, - const ASN1_BIT_STRING *sig, EVP_PKEY *pkey), - int (*item_sign)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, - X509_ALGOR *alg1, X509_ALGOR *alg2, - ASN1_BIT_STRING *sig)); + int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, + void *arg2)); +void EVP_PKEY_asn1_set_item( + EVP_PKEY_ASN1_METHOD *ameth, + int (*item_verify)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, + const X509_ALGOR *a, const ASN1_BIT_STRING *sig, + EVP_PKEY *pkey), + int (*item_sign)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, const void *data, + X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig)); void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth, - int (*siginf_set)(X509_SIG_INFO *siginf, const X509_ALGOR *alg, + int (*siginf_set)(X509_SIG_INFO *siginf, + const X509_ALGOR *alg, const ASN1_STRING *sig)); -void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_check)(const EVP_PKEY *pk)); +void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, + int (*pkey_check)(const EVP_PKEY *pk)); void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_pub_check)(const EVP_PKEY *pk)); @@ -1486,21 +1618,24 @@ void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_param_check)(const EVP_PKEY *pk)); -void EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*set_priv_key)(EVP_PKEY *pk, const unsigned char *priv, - size_t len)); +void EVP_PKEY_asn1_set_set_priv_key( + EVP_PKEY_ASN1_METHOD *ameth, + int (*set_priv_key)(EVP_PKEY *pk, const unsigned char *priv, size_t len)); void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*set_pub_key)(EVP_PKEY *pk, const unsigned char *pub, + int (*set_pub_key)(EVP_PKEY *pk, + const unsigned char *pub, size_t len)); void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*get_priv_key)(const EVP_PKEY *pk, unsigned char *priv, + int (*get_priv_key)(const EVP_PKEY *pk, + unsigned char *priv, size_t *len)); void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*get_pub_key)(const EVP_PKEY *pk, unsigned char *pub, + int (*get_pub_key)(const EVP_PKEY *pk, + unsigned char *pub, size_t *len)); -void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_security_bits)(const EVP_PKEY *pk)); +void EVP_PKEY_asn1_set_security_bits( + EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_security_bits)(const EVP_PKEY *pk)); int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); @@ -1528,17 +1663,19 @@ const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key); #define EVP_PKEY_OP_ENCAPSULATE (1 << 12) #define EVP_PKEY_OP_DECAPSULATE (1 << 13) -#define EVP_PKEY_OP_TYPE_SIG \ - (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER | EVP_PKEY_OP_SIGNCTX \ - | EVP_PKEY_OP_VERIFYCTX) +#define EVP_PKEY_OP_TYPE_SIG \ + (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \ + | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX) #define EVP_PKEY_OP_TYPE_CRYPT (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT) -#define EVP_PKEY_OP_TYPE_NOGEN (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE) +#define EVP_PKEY_OP_TYPE_NOGEN \ + (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE) #define EVP_PKEY_OP_TYPE_GEN (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN) -int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, int keylen); +int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, + int keylen); #define EVP_PKEY_CTRL_MD 1 #define EVP_PKEY_CTRL_PEER_KEY 2 @@ -1547,12 +1684,12 @@ int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, int ke /* Used by GOST key encryption in TLS */ #define EVP_PKEY_CTRL_SET_IV 8 #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3 -# define EVP_PKEY_CTRL_PKCS7_DECRYPT 4 -# define EVP_PKEY_CTRL_PKCS7_SIGN 5 -# define EVP_PKEY_CTRL_CMS_ENCRYPT 9 -# define EVP_PKEY_CTRL_CMS_DECRYPT 10 -# define EVP_PKEY_CTRL_CMS_SIGN 11 +# define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3 +# define EVP_PKEY_CTRL_PKCS7_DECRYPT 4 +# define EVP_PKEY_CTRL_PKCS7_SIGN 5 +# define EVP_PKEY_CTRL_CMS_ENCRYPT 9 +# define EVP_PKEY_CTRL_CMS_DECRYPT 10 +# define EVP_PKEY_CTRL_CMS_SIGN 11 #endif #define EVP_PKEY_CTRL_CIPHER 12 #define EVP_PKEY_CTRL_GET_MD 13 @@ -1573,7 +1710,8 @@ OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type); OSSL_DEPRECATEDIN_3_0 EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, const EVP_PKEY_METHOD *meth); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, + const EVP_PKEY_METHOD *src); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth); OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth); OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth); @@ -1581,16 +1719,19 @@ OSSL_DEPRECATEDIN_3_0 size_t EVP_PKEY_meth_get_count(void); OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx); #endif -EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties); +EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt); void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt); const OSSL_PROVIDER *EVP_KEYMGMT_get0_provider(const EVP_KEYMGMT *keymgmt); const char *EVP_KEYMGMT_get0_name(const EVP_KEYMGMT *keymgmt); const char *EVP_KEYMGMT_get0_description(const EVP_KEYMGMT *keymgmt); int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name); -void EVP_KEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), +void EVP_KEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), void *arg); -int EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt, void (*fn)(const char *name, void *data), +int EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt, + void (*fn)(const char *name, void *data), void *data); const OSSL_PARAM *EVP_KEYMGMT_gettable_params(const EVP_KEYMGMT *keymgmt); const OSSL_PARAM *EVP_KEYMGMT_settable_params(const EVP_KEYMGMT *keymgmt); @@ -1610,9 +1751,12 @@ int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params); const OSSL_PARAM *EVP_PKEY_CTX_gettable_params(const EVP_PKEY_CTX *ctx); int EVP_PKEY_CTX_set_params(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params); const OSSL_PARAM *EVP_PKEY_CTX_settable_params(const EVP_PKEY_CTX *ctx); -int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2); -int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value); -int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, uint64_t value); +int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, + int p1, void *p2); +int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, + const char *value); +int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype, + int cmd, uint64_t value); int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str); int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex); @@ -1622,20 +1766,29 @@ int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md); int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx); void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen); -EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key, int keylen); -EVP_PKEY *EVP_PKEY_new_raw_private_key_ex(OSSL_LIB_CTX *libctx, const char *keytype, - const char *propq, const unsigned char *priv, size_t len); -EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e, const unsigned char *priv, size_t len); -EVP_PKEY *EVP_PKEY_new_raw_public_key_ex(OSSL_LIB_CTX *libctx, const char *keytype, - const char *propq, const unsigned char *pub, size_t len); -EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e, const unsigned char *pub, size_t len); -int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv, size_t *len); -int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub, size_t *len); +EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key, + int keylen); +EVP_PKEY *EVP_PKEY_new_raw_private_key_ex(OSSL_LIB_CTX *libctx, + const char *keytype, + const char *propq, + const unsigned char *priv, + size_t len); +EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e, + const unsigned char *priv, size_t len); +EVP_PKEY *EVP_PKEY_new_raw_public_key_ex(OSSL_LIB_CTX *libctx, + const char *keytype, const char *propq, + const unsigned char *pub, size_t len); +EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e, + const unsigned char *pub, size_t len); +int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv, + size_t *len); +int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub, + size_t *len); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, size_t len, - const EVP_CIPHER *cipher); +EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, + size_t len, const EVP_CIPHER *cipher); #endif void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data); @@ -1656,9 +1809,12 @@ int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name); const char *EVP_SIGNATURE_get0_name(const EVP_SIGNATURE *signature); const char *EVP_SIGNATURE_get0_description(const EVP_SIGNATURE *signature); void EVP_SIGNATURE_do_all_provided(OSSL_LIB_CTX *libctx, - void (*fn)(EVP_SIGNATURE *signature, void *data), void *data); + void (*fn)(EVP_SIGNATURE *signature, + void *data), + void *data); int EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature, - void (*fn)(const char *name, void *data), void *data); + void (*fn)(const char *name, void *data), + void *data); const OSSL_PARAM *EVP_SIGNATURE_gettable_ctx_params(const EVP_SIGNATURE *sig); const OSSL_PARAM *EVP_SIGNATURE_settable_ctx_params(const EVP_SIGNATURE *sig); @@ -1671,93 +1827,116 @@ int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name); const char *EVP_ASYM_CIPHER_get0_name(const EVP_ASYM_CIPHER *cipher); const char *EVP_ASYM_CIPHER_get0_description(const EVP_ASYM_CIPHER *cipher); void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx, - void (*fn)(EVP_ASYM_CIPHER *cipher, void *arg), void *arg); + void (*fn)(EVP_ASYM_CIPHER *cipher, + void *arg), + void *arg); int EVP_ASYM_CIPHER_names_do_all(const EVP_ASYM_CIPHER *cipher, - void (*fn)(const char *name, void *data), void *data); -const OSSL_PARAM *EVP_ASYM_CIPHER_gettable_ctx_params(const EVP_ASYM_CIPHER *ciph); -const OSSL_PARAM *EVP_ASYM_CIPHER_settable_ctx_params(const EVP_ASYM_CIPHER *ciph); + void (*fn)(const char *name, void *data), + void *data); +const OSSL_PARAM * +EVP_ASYM_CIPHER_gettable_ctx_params(const EVP_ASYM_CIPHER *ciph); +const OSSL_PARAM * +EVP_ASYM_CIPHER_settable_ctx_params(const EVP_ASYM_CIPHER *ciph); void EVP_KEM_free(EVP_KEM *wrap); int EVP_KEM_up_ref(EVP_KEM *wrap); OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *wrap); -EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties); +EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); int EVP_KEM_is_a(const EVP_KEM *wrap, const char *name); const char *EVP_KEM_get0_name(const EVP_KEM *wrap); const char *EVP_KEM_get0_description(const EVP_KEM *wrap); -void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_KEM *wrap, void *arg), void *arg); -int EVP_KEM_names_do_all(const EVP_KEM *wrap, void (*fn)(const char *name, void *data), void *data); +void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KEM *wrap, void *arg), void *arg); +int EVP_KEM_names_do_all(const EVP_KEM *wrap, + void (*fn)(const char *name, void *data), void *data); const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem); const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem); int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_sign_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); -int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, - size_t tbslen); +int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_verify_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen); int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_verify_recover_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); -int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, - const unsigned char *sig, size_t siglen); +int EVP_PKEY_verify_recover_init_ex(EVP_PKEY_CTX *ctx, + const OSSL_PARAM params[]); +int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, unsigned char *rout, + size_t *routlen, const unsigned char *sig, + size_t siglen); int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_encrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); -int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, - size_t inlen); +int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_decrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); -int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, const unsigned char *in, - size_t inlen); +int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); -int EVP_PKEY_derive_set_peer_ex(EVP_PKEY_CTX *ctx, EVP_PKEY *peer, int validate_peer); +int EVP_PKEY_derive_set_peer_ex(EVP_PKEY_CTX *ctx, EVP_PKEY *peer, + int validate_peer); int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); int EVP_PKEY_encapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); int EVP_PKEY_auth_encapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpriv, const OSSL_PARAM params[]); -int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx, unsigned char *wrappedkey, size_t *wrappedkeylen, - unsigned char *genkey, size_t *genkeylen); +int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx, unsigned char *wrappedkey, + size_t *wrappedkeylen, unsigned char *genkey, + size_t *genkeylen); int EVP_PKEY_decapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); -int EVP_PKEY_auth_decapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpub, const OSSL_PARAM params[]); -int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx, unsigned char *unwrapped, size_t *unwrappedlen, - const unsigned char *wrapped, size_t wrappedlen); +int EVP_PKEY_auth_decapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpub, + const OSSL_PARAM params[]); +int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx, unsigned char *unwrapped, + size_t *unwrappedlen, const unsigned char *wrapped, + size_t wrappedlen); typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx); int EVP_PKEY_fromdata_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_fromdata(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey, int selection, OSSL_PARAM param[]); +int EVP_PKEY_fromdata(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey, int selection, + OSSL_PARAM param[]); const OSSL_PARAM *EVP_PKEY_fromdata_settable(EVP_PKEY_CTX *ctx, int selection); int EVP_PKEY_todata(const EVP_PKEY *pkey, int selection, OSSL_PARAM **params); -int EVP_PKEY_export(const EVP_PKEY *pkey, int selection, OSSL_CALLBACK *export_cb, - void *export_cbarg); +int EVP_PKEY_export(const EVP_PKEY *pkey, int selection, + OSSL_CALLBACK *export_cb, void *export_cbarg); const OSSL_PARAM *EVP_PKEY_gettable_params(const EVP_PKEY *pkey); int EVP_PKEY_get_params(const EVP_PKEY *pkey, OSSL_PARAM params[]); -int EVP_PKEY_get_int_param(const EVP_PKEY *pkey, const char *key_name, int *out); -int EVP_PKEY_get_size_t_param(const EVP_PKEY *pkey, const char *key_name, size_t *out); -int EVP_PKEY_get_bn_param(const EVP_PKEY *pkey, const char *key_name, BIGNUM **bn); -int EVP_PKEY_get_utf8_string_param(const EVP_PKEY *pkey, const char *key_name, char *str, - size_t max_buf_sz, size_t *out_sz); -int EVP_PKEY_get_octet_string_param(const EVP_PKEY *pkey, const char *key_name, unsigned char *buf, - size_t max_buf_sz, size_t *out_sz); +int EVP_PKEY_get_int_param(const EVP_PKEY *pkey, const char *key_name, + int *out); +int EVP_PKEY_get_size_t_param(const EVP_PKEY *pkey, const char *key_name, + size_t *out); +int EVP_PKEY_get_bn_param(const EVP_PKEY *pkey, const char *key_name, + BIGNUM **bn); +int EVP_PKEY_get_utf8_string_param(const EVP_PKEY *pkey, const char *key_name, + char *str, size_t max_buf_sz, + size_t *out_sz); +int EVP_PKEY_get_octet_string_param(const EVP_PKEY *pkey, const char *key_name, + unsigned char *buf, size_t max_buf_sz, + size_t *out_sz); const OSSL_PARAM *EVP_PKEY_settable_params(const EVP_PKEY *pkey); int EVP_PKEY_set_params(EVP_PKEY *pkey, OSSL_PARAM params[]); int EVP_PKEY_set_int_param(EVP_PKEY *pkey, const char *key_name, int in); int EVP_PKEY_set_size_t_param(EVP_PKEY *pkey, const char *key_name, size_t in); -int EVP_PKEY_set_bn_param(EVP_PKEY *pkey, const char *key_name, const BIGNUM *bn); -int EVP_PKEY_set_utf8_string_param(EVP_PKEY *pkey, const char *key_name, const char *str); -int EVP_PKEY_set_octet_string_param(EVP_PKEY *pkey, const char *key_name, const unsigned char *buf, - size_t bsize); +int EVP_PKEY_set_bn_param(EVP_PKEY *pkey, const char *key_name, + const BIGNUM *bn); +int EVP_PKEY_set_utf8_string_param(EVP_PKEY *pkey, const char *key_name, + const char *str); +int EVP_PKEY_set_octet_string_param(EVP_PKEY *pkey, const char *key_name, + const unsigned char *buf, size_t bsize); int EVP_PKEY_get_ec_point_conv_form(const EVP_PKEY *pkey); int EVP_PKEY_get_field_type(const EVP_PKEY *pkey); -EVP_PKEY *EVP_PKEY_Q_keygen(OSSL_LIB_CTX *libctx, const char *propq, const char *type, ...); +EVP_PKEY *EVP_PKEY_Q_keygen(OSSL_LIB_CTX *libctx, const char *propq, + const char *type, ...); int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); @@ -1771,8 +1950,8 @@ int EVP_PKEY_param_check_quick(EVP_PKEY_CTX *ctx); int EVP_PKEY_private_check(EVP_PKEY_CTX *ctx); int EVP_PKEY_pairwise_check(EVP_PKEY_CTX *ctx); -#define EVP_PKEY_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EVP_PKEY, l, p, newf, dupf, freef) +#define EVP_PKEY_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EVP_PKEY, l, p, newf, dupf, freef) int EVP_PKEY_set_ex_data(EVP_PKEY *key, int idx, void *arg); void *EVP_PKEY_get_ex_data(const EVP_PKEY *key, int idx); @@ -1781,144 +1960,170 @@ EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx); int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx); #ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, - int (*init)(EVP_PKEY_CTX *ctx)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth, - int (*copy)(EVP_PKEY_CTX *dst, - const EVP_PKEY_CTX *src)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth, - void (*cleanup)(EVP_PKEY_CTX *ctx)); OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth, int (*paramgen_init)(EVP_PKEY_CTX *ctx), +EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, int (*init)(EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth, + int (*copy)(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth, + void (*cleanup)(EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth, + int (*paramgen_init)(EVP_PKEY_CTX *ctx), int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth, int (*keygen_init)(EVP_PKEY_CTX *ctx), +EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth, + int (*keygen_init)(EVP_PKEY_CTX *ctx), int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth, int (*sign_init)(EVP_PKEY_CTX *ctx), - int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth, int (*verify_init)(EVP_PKEY_CTX *ctx), - int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_sign( + EVP_PKEY_METHOD *pmeth, int (*sign_init)(EVP_PKEY_CTX *ctx), + int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verify( + EVP_PKEY_METHOD *pmeth, int (*verify_init)(EVP_PKEY_CTX *ctx), + int (*verify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verify_recover( EVP_PKEY_METHOD *pmeth, int (*verify_recover_init)(EVP_PKEY_CTX *ctx), int (*verify_recover)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_signctx( - EVP_PKEY_METHOD *pmeth, int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), - int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx)); + EVP_PKEY_METHOD *pmeth, + int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), + int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verifyctx( - EVP_PKEY_METHOD *pmeth, int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), - int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, EVP_MD_CTX *mctx)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth, int (*encrypt_init)(EVP_PKEY_CTX *ctx), - int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth, int (*decrypt_init)(EVP_PKEY_CTX *ctx), - int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth, int (*derive_init)(EVP_PKEY_CTX *ctx), - int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, - int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), - int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth, - int (*digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)); + EVP_PKEY_METHOD *pmeth, + int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), + int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, + EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_encrypt( + EVP_PKEY_METHOD *pmeth, int (*encrypt_init)(EVP_PKEY_CTX *ctx), + int (*encryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_decrypt( + EVP_PKEY_METHOD *pmeth, int (*decrypt_init)(EVP_PKEY_CTX *ctx), + int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_derive( + EVP_PKEY_METHOD *pmeth, int (*derive_init)(EVP_PKEY_CTX *ctx), + int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_ctrl( + EVP_PKEY_METHOD *pmeth, + int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), + int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digestsign( + EVP_PKEY_METHOD *pmeth, + int (*digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digestverify( EVP_PKEY_METHOD *pmeth, - int (*digestverify)(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, - int (*check)(EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth, - int (*check)(EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth, - int (*check)(EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth, - int (*digest_custom)(EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth, - int (**pinit)(EVP_PKEY_CTX *ctx)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth, - int (**pcopy)(EVP_PKEY_CTX *dst, - const EVP_PKEY_CTX *src)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth, - void (**pcleanup)(EVP_PKEY_CTX *ctx)); + int (*digestverify)(EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth, int (**pparamgen_init)(EVP_PKEY_CTX *ctx), - int (**pparamgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); +EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, int (*check)(EVP_PKEY *pkey)); OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth, int (**pkeygen_init)(EVP_PKEY_CTX *ctx), +EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth, + int (*check)(EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth, + int (*check)(EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digest_custom( + EVP_PKEY_METHOD *pmeth, + int (*digest_custom)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth, + int (**pinit)(EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_copy( + const EVP_PKEY_METHOD *pmeth, + int (**pcopy)(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth, + void (**pcleanup)(EVP_PKEY_CTX *ctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_paramgen( + const EVP_PKEY_METHOD *pmeth, int (**pparamgen_init)(EVP_PKEY_CTX *ctx), + int (**pparamgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth, + int (**pkeygen_init)(EVP_PKEY_CTX *ctx), int (**pkeygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth, int (**psign_init)(EVP_PKEY_CTX *ctx), - int (**psign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth, int (**pverify_init)(EVP_PKEY_CTX *ctx), - int (**pverify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_sign( + const EVP_PKEY_METHOD *pmeth, int (**psign_init)(EVP_PKEY_CTX *ctx), + int (**psign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verify( + const EVP_PKEY_METHOD *pmeth, int (**pverify_init)(EVP_PKEY_CTX *ctx), + int (**pverify)(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verify_recover( - const EVP_PKEY_METHOD *pmeth, int (**pverify_recover_init)(EVP_PKEY_CTX *ctx), - int (**pverify_recover)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)); + const EVP_PKEY_METHOD *pmeth, + int (**pverify_recover_init)(EVP_PKEY_CTX *ctx), + int (**pverify_recover)(EVP_PKEY_CTX *ctx, unsigned char *sig, + size_t *siglen, const unsigned char *tbs, + size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_signctx( - const EVP_PKEY_METHOD *pmeth, int (**psignctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), - int (**psignctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx)); + const EVP_PKEY_METHOD *pmeth, + int (**psignctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), + int (**psignctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verifyctx( - const EVP_PKEY_METHOD *pmeth, int (**pverifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), - int (**pverifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, EVP_MD_CTX *mctx)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth, int (**pencrypt_init)(EVP_PKEY_CTX *ctx), - int (**pencryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth, int (**pdecrypt_init)(EVP_PKEY_CTX *ctx), - int (**pdecrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth, int (**pderive_init)(EVP_PKEY_CTX *ctx), - int (**pderive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth, - int (**pctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), - int (**pctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)); -OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_digestsign(const EVP_PKEY_METHOD *pmeth, - int (**digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)); + const EVP_PKEY_METHOD *pmeth, + int (**pverifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx), + int (**pverifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, + EVP_MD_CTX *mctx)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_encrypt( + const EVP_PKEY_METHOD *pmeth, int (**pencrypt_init)(EVP_PKEY_CTX *ctx), + int (**pencryptfn)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_decrypt( + const EVP_PKEY_METHOD *pmeth, int (**pdecrypt_init)(EVP_PKEY_CTX *ctx), + int (**pdecrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_derive( + const EVP_PKEY_METHOD *pmeth, int (**pderive_init)(EVP_PKEY_CTX *ctx), + int (**pderive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_ctrl( + const EVP_PKEY_METHOD *pmeth, + int (**pctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2), + int (**pctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digestsign( + const EVP_PKEY_METHOD *pmeth, + int (**digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digestverify( const EVP_PKEY_METHOD *pmeth, - int (**digestverify)(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth, - int (**pcheck)(EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth, - int (**pcheck)(EVP_PKEY *pkey)); -OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth, - int (**pcheck)(EVP_PKEY *pkey)); + int (**digestverify)(EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen)); OSSL_DEPRECATEDIN_3_0 void -EVP_PKEY_meth_get_digest_custom(const EVP_PKEY_METHOD *pmeth, - int (**pdigest_custom)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)); +EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth, + int (**pcheck)(EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth, + int (**pcheck)(EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void +EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth, + int (**pcheck)(EVP_PKEY *pkey)); +OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digest_custom( + const EVP_PKEY_METHOD *pmeth, + int (**pdigest_custom)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)); #endif void EVP_KEYEXCH_free(EVP_KEYEXCH *exchange); int EVP_KEYEXCH_up_ref(EVP_KEYEXCH *exchange); -EVP_KEYEXCH *EVP_KEYEXCH_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties); +EVP_KEYEXCH *EVP_KEYEXCH_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, + const char *properties); OSSL_PROVIDER *EVP_KEYEXCH_get0_provider(const EVP_KEYEXCH *exchange); int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name); const char *EVP_KEYEXCH_get0_name(const EVP_KEYEXCH *keyexch); const char *EVP_KEYEXCH_get0_description(const EVP_KEYEXCH *keyexch); -void EVP_KEYEXCH_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_KEYEXCH *keyexch, void *data), +void EVP_KEYEXCH_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KEYEXCH *keyexch, void *data), void *data); -int EVP_KEYEXCH_names_do_all(const EVP_KEYEXCH *keyexch, void (*fn)(const char *name, void *data), +int EVP_KEYEXCH_names_do_all(const EVP_KEYEXCH *keyexch, + void (*fn)(const char *name, void *data), void *data); const OSSL_PARAM *EVP_KEYEXCH_gettable_ctx_params(const EVP_KEYEXCH *keyexch); const OSSL_PARAM *EVP_KEYEXCH_settable_ctx_params(const EVP_KEYEXCH *keyexch); @@ -1927,7 +2132,8 @@ void EVP_add_alg_module(void); int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name); int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); -int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *name, size_t name_sz, size_t *gname_len); +int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *name, size_t name_sz, + size_t *gname_len); OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx); const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx); diff --git a/libs/OpenSSL/include/openssl/fips_names.h b/libs/OpenSSL/include/openssl/fips_names.h index a0da713c..c8a231b0 100644 --- a/libs/OpenSSL/include/openssl/fips_names.h +++ b/libs/OpenSSL/include/openssl/fips_names.h @@ -30,8 +30,8 @@ extern "C" { */ #define OSSL_PROV_FIPS_PARAM_INSTALL_VERSION "install-version" /* - * The calculated MAC of the install status indicator (Used for FIPS Self Testing) - * Type: OSSL_PARAM_UTF8_STRING + * The calculated MAC of the install status indicator (Used for FIPS Self + * Testing) Type: OSSL_PARAM_UTF8_STRING */ #define OSSL_PROV_FIPS_PARAM_INSTALL_MAC "install-mac" /* diff --git a/libs/OpenSSL/include/openssl/fipskey.h b/libs/OpenSSL/include/openssl/fipskey.h index 85b8e112..9cfda4a0 100644 --- a/libs/OpenSSL/include/openssl/fipskey.h +++ b/libs/OpenSSL/include/openssl/fipskey.h @@ -21,15 +21,16 @@ extern "C" { /* * The FIPS validation HMAC key, usable as an array initializer. */ -#define FIPS_KEY_ELEMENTS \ - 0xf4, 0x55, 0x66, 0x50, 0xac, 0x31, 0xd3, 0x54, 0x61, 0x61, 0x0b, 0xac, 0x4e, 0xd8, 0x1b, \ - 0x1a, 0x18, 0x1b, 0x2d, 0x8a, 0x43, 0xea, 0x28, 0x54, 0xcb, 0xae, 0x22, 0xca, 0x74, 0x56, \ - 0x08, 0x13 +#define FIPS_KEY_ELEMENTS \ + 0xf4, 0x55, 0x66, 0x50, 0xac, 0x31, 0xd3, 0x54, 0x61, 0x61, 0x0b, 0xac, \ + 0x4e, 0xd8, 0x1b, 0x1a, 0x18, 0x1b, 0x2d, 0x8a, 0x43, 0xea, 0x28, 0x54, \ + 0xcb, 0xae, 0x22, 0xca, 0x74, 0x56, 0x08, 0x13 /* * The FIPS validation key, as a string. */ -#define FIPS_KEY_STRING "f4556650ac31d35461610bac4ed81b1a181b2d8a43ea2854cbae22ca74560813" +#define FIPS_KEY_STRING \ + "f4556650ac31d35461610bac4ed81b1a181b2d8a43ea2854cbae22ca74560813" #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/hmac.h b/libs/OpenSSL/include/openssl/hmac.h index 2b7b2072..620ec2c4 100644 --- a/libs/OpenSSL/include/openssl/hmac.h +++ b/libs/OpenSSL/include/openssl/hmac.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_HMAC_H +# define HEADER_HMAC_H #endif #include @@ -21,7 +21,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HMAC_MAX_MD_CBLOCK 200 /* Deprecated */ +# define HMAC_MAX_MD_CBLOCK 200 /* Deprecated */ #endif #ifdef __cplusplus @@ -35,21 +35,25 @@ OSSL_DEPRECATEDIN_3_0 int HMAC_CTX_reset(HMAC_CTX *ctx); OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_free(HMAC_CTX *ctx); #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -OSSL_DEPRECATEDIN_1_1_0 __owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md); +OSSL_DEPRECATEDIN_1_1_0 __owur int HMAC_Init(HMAC_CTX *ctx, const void *key, + int len, const EVP_MD *md); #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md, - ENGINE *impl); -OSSL_DEPRECATEDIN_3_0 int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); -OSSL_DEPRECATEDIN_3_0 int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); +OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, + const EVP_MD *md, ENGINE *impl); +OSSL_DEPRECATEDIN_3_0 int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, + size_t len); +OSSL_DEPRECATEDIN_3_0 int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, + unsigned int *len); OSSL_DEPRECATEDIN_3_0 __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); -OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); +OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_set_flags(HMAC_CTX *ctx, + unsigned long flags); OSSL_DEPRECATEDIN_3_0 const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); #endif -unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *data, - size_t data_len, unsigned char *md, unsigned int *md_len); +unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, + const unsigned char *data, size_t data_len, + unsigned char *md, unsigned int *md_len); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/hpke.h b/libs/OpenSSL/include/openssl/hpke.h index e9984ec9..bf15e081 100644 --- a/libs/OpenSSL/include/openssl/hpke.h +++ b/libs/OpenSSL/include/openssl/hpke.h @@ -15,9 +15,9 @@ #include /* HPKE modes */ -#define OSSL_HPKE_MODE_BASE 0 /* Base mode */ -#define OSSL_HPKE_MODE_PSK 1 /* Pre-shared key mode */ -#define OSSL_HPKE_MODE_AUTH 2 /* Authenticated mode */ +#define OSSL_HPKE_MODE_BASE 0 /* Base mode */ +#define OSSL_HPKE_MODE_PSK 1 /* Pre-shared key mode */ +#define OSSL_HPKE_MODE_AUTH 2 /* Authenticated mode */ #define OSSL_HPKE_MODE_PSKAUTH 3 /* PSK+authenticated mode */ /* @@ -34,36 +34,36 @@ * crypto/hpke/hpke_util.c that must also be updated. */ #define OSSL_HPKE_KEM_ID_RESERVED 0x0000 /* not used */ -#define OSSL_HPKE_KEM_ID_P256 0x0010 /* NIST P-256 */ -#define OSSL_HPKE_KEM_ID_P384 0x0011 /* NIST P-384 */ -#define OSSL_HPKE_KEM_ID_P521 0x0012 /* NIST P-521 */ -#define OSSL_HPKE_KEM_ID_X25519 0x0020 /* Curve25519 */ -#define OSSL_HPKE_KEM_ID_X448 0x0021 /* Curve448 */ +#define OSSL_HPKE_KEM_ID_P256 0x0010 /* NIST P-256 */ +#define OSSL_HPKE_KEM_ID_P384 0x0011 /* NIST P-384 */ +#define OSSL_HPKE_KEM_ID_P521 0x0012 /* NIST P-521 */ +#define OSSL_HPKE_KEM_ID_X25519 0x0020 /* Curve25519 */ +#define OSSL_HPKE_KEM_ID_X448 0x0021 /* Curve448 */ -#define OSSL_HPKE_KDF_ID_RESERVED 0x0000 /* not used */ +#define OSSL_HPKE_KDF_ID_RESERVED 0x0000 /* not used */ #define OSSL_HPKE_KDF_ID_HKDF_SHA256 0x0001 /* HKDF-SHA256 */ #define OSSL_HPKE_KDF_ID_HKDF_SHA384 0x0002 /* HKDF-SHA384 */ #define OSSL_HPKE_KDF_ID_HKDF_SHA512 0x0003 /* HKDF-SHA512 */ -#define OSSL_HPKE_AEAD_ID_RESERVED 0x0000 /* not used */ -#define OSSL_HPKE_AEAD_ID_AES_GCM_128 0x0001 /* AES-GCM-128 */ -#define OSSL_HPKE_AEAD_ID_AES_GCM_256 0x0002 /* AES-GCM-256 */ +#define OSSL_HPKE_AEAD_ID_RESERVED 0x0000 /* not used */ +#define OSSL_HPKE_AEAD_ID_AES_GCM_128 0x0001 /* AES-GCM-128 */ +#define OSSL_HPKE_AEAD_ID_AES_GCM_256 0x0002 /* AES-GCM-256 */ #define OSSL_HPKE_AEAD_ID_CHACHA_POLY1305 0x0003 /* Chacha20-Poly1305 */ -#define OSSL_HPKE_AEAD_ID_EXPORTONLY 0xFFFF /* export-only fake ID */ +#define OSSL_HPKE_AEAD_ID_EXPORTONLY 0xFFFF /* export-only fake ID */ /* strings for suite components */ -#define OSSL_HPKE_KEMSTR_P256 "P-256" /* KEM id 0x10 */ -#define OSSL_HPKE_KEMSTR_P384 "P-384" /* KEM id 0x11 */ -#define OSSL_HPKE_KEMSTR_P521 "P-521" /* KEM id 0x12 */ -#define OSSL_HPKE_KEMSTR_X25519 "X25519" /* KEM id 0x20 */ -#define OSSL_HPKE_KEMSTR_X448 "X448" /* KEM id 0x21 */ -#define OSSL_HPKE_KDFSTR_256 "hkdf-sha256" /* KDF id 1 */ -#define OSSL_HPKE_KDFSTR_384 "hkdf-sha384" /* KDF id 2 */ -#define OSSL_HPKE_KDFSTR_512 "hkdf-sha512" /* KDF id 3 */ +#define OSSL_HPKE_KEMSTR_P256 "P-256" /* KEM id 0x10 */ +#define OSSL_HPKE_KEMSTR_P384 "P-384" /* KEM id 0x11 */ +#define OSSL_HPKE_KEMSTR_P521 "P-521" /* KEM id 0x12 */ +#define OSSL_HPKE_KEMSTR_X25519 "X25519" /* KEM id 0x20 */ +#define OSSL_HPKE_KEMSTR_X448 "X448" /* KEM id 0x21 */ +#define OSSL_HPKE_KDFSTR_256 "hkdf-sha256" /* KDF id 1 */ +#define OSSL_HPKE_KDFSTR_384 "hkdf-sha384" /* KDF id 2 */ +#define OSSL_HPKE_KDFSTR_512 "hkdf-sha512" /* KDF id 3 */ #define OSSL_HPKE_AEADSTR_AES128GCM "aes-128-gcm" /* AEAD id 1 */ #define OSSL_HPKE_AEADSTR_AES256GCM "aes-256-gcm" /* AEAD id 2 */ -#define OSSL_HPKE_AEADSTR_CP "chacha20-poly1305" /* AEAD id 3 */ -#define OSSL_HPKE_AEADSTR_EXP "exporter" /* AEAD id 0xff */ +#define OSSL_HPKE_AEADSTR_CP "chacha20-poly1305" /* AEAD id 3 */ +#define OSSL_HPKE_AEADSTR_EXP "exporter" /* AEAD id 0xff */ /* * Roles for use in creating an OSSL_HPKE_CTX, most @@ -74,57 +74,65 @@ typedef struct { - uint16_t kem_id; /* Key Encapsulation Method id */ - uint16_t kdf_id; /* Key Derivation Function id */ - uint16_t aead_id; /* AEAD alg id */ + uint16_t kem_id; /* Key Encapsulation Method id */ + uint16_t kdf_id; /* Key Derivation Function id */ + uint16_t aead_id; /* AEAD alg id */ } OSSL_HPKE_SUITE; /** * Suite constants, use this like: * OSSL_HPKE_SUITE myvar = OSSL_HPKE_SUITE_DEFAULT; */ -#define OSSL_HPKE_SUITE_DEFAULT \ - { \ - OSSL_HPKE_KEM_ID_X25519, OSSL_HPKE_KDF_ID_HKDF_SHA256, OSSL_HPKE_AEAD_ID_AES_GCM_128 \ - } +#define OSSL_HPKE_SUITE_DEFAULT \ + { \ + OSSL_HPKE_KEM_ID_X25519, OSSL_HPKE_KDF_ID_HKDF_SHA256, \ + OSSL_HPKE_AEAD_ID_AES_GCM_128 \ + } typedef struct ossl_hpke_ctx_st OSSL_HPKE_CTX; -OSSL_HPKE_CTX *OSSL_HPKE_CTX_new(int mode, OSSL_HPKE_SUITE suite, int role, OSSL_LIB_CTX *libctx, - const char *propq); +OSSL_HPKE_CTX *OSSL_HPKE_CTX_new(int mode, OSSL_HPKE_SUITE suite, int role, + OSSL_LIB_CTX *libctx, const char *propq); void OSSL_HPKE_CTX_free(OSSL_HPKE_CTX *ctx); int OSSL_HPKE_encap(OSSL_HPKE_CTX *ctx, unsigned char *enc, size_t *enclen, - const unsigned char *pub, size_t publen, const unsigned char *info, - size_t infolen); -int OSSL_HPKE_seal(OSSL_HPKE_CTX *ctx, unsigned char *ct, size_t *ctlen, const unsigned char *aad, - size_t aadlen, const unsigned char *pt, size_t ptlen); + const unsigned char *pub, size_t publen, + const unsigned char *info, size_t infolen); +int OSSL_HPKE_seal(OSSL_HPKE_CTX *ctx, unsigned char *ct, size_t *ctlen, + const unsigned char *aad, size_t aadlen, + const unsigned char *pt, size_t ptlen); -int OSSL_HPKE_keygen(OSSL_HPKE_SUITE suite, unsigned char *pub, size_t *publen, EVP_PKEY **priv, - const unsigned char *ikm, size_t ikmlen, OSSL_LIB_CTX *libctx, - const char *propq); +int OSSL_HPKE_keygen(OSSL_HPKE_SUITE suite, unsigned char *pub, size_t *publen, + EVP_PKEY **priv, const unsigned char *ikm, size_t ikmlen, + OSSL_LIB_CTX *libctx, const char *propq); int OSSL_HPKE_decap(OSSL_HPKE_CTX *ctx, const unsigned char *enc, size_t enclen, - EVP_PKEY *recippriv, const unsigned char *info, size_t infolen); -int OSSL_HPKE_open(OSSL_HPKE_CTX *ctx, unsigned char *pt, size_t *ptlen, const unsigned char *aad, - size_t aadlen, const unsigned char *ct, size_t ctlen); + EVP_PKEY *recippriv, const unsigned char *info, + size_t infolen); +int OSSL_HPKE_open(OSSL_HPKE_CTX *ctx, unsigned char *pt, size_t *ptlen, + const unsigned char *aad, size_t aadlen, + const unsigned char *ct, size_t ctlen); -int OSSL_HPKE_export(OSSL_HPKE_CTX *ctx, unsigned char *secret, size_t secretlen, - const unsigned char *label, size_t labellen); +int OSSL_HPKE_export(OSSL_HPKE_CTX *ctx, unsigned char *secret, + size_t secretlen, const unsigned char *label, + size_t labellen); int OSSL_HPKE_CTX_set1_authpriv(OSSL_HPKE_CTX *ctx, EVP_PKEY *priv); -int OSSL_HPKE_CTX_set1_authpub(OSSL_HPKE_CTX *ctx, const unsigned char *pub, size_t publen); -int OSSL_HPKE_CTX_set1_psk(OSSL_HPKE_CTX *ctx, const char *pskid, const unsigned char *psk, - size_t psklen); +int OSSL_HPKE_CTX_set1_authpub(OSSL_HPKE_CTX *ctx, const unsigned char *pub, + size_t publen); +int OSSL_HPKE_CTX_set1_psk(OSSL_HPKE_CTX *ctx, const char *pskid, + const unsigned char *psk, size_t psklen); -int OSSL_HPKE_CTX_set1_ikme(OSSL_HPKE_CTX *ctx, const unsigned char *ikme, size_t ikmelen); +int OSSL_HPKE_CTX_set1_ikme(OSSL_HPKE_CTX *ctx, const unsigned char *ikme, + size_t ikmelen); int OSSL_HPKE_CTX_set_seq(OSSL_HPKE_CTX *ctx, uint64_t seq); int OSSL_HPKE_CTX_get_seq(OSSL_HPKE_CTX *ctx, uint64_t *seq); int OSSL_HPKE_suite_check(OSSL_HPKE_SUITE suite); int OSSL_HPKE_get_grease_value(OSSL_LIB_CTX *libctx, const char *propq, - const OSSL_HPKE_SUITE *suite_in, OSSL_HPKE_SUITE *suite, - unsigned char *enc, size_t *enclen, unsigned char *ct, size_t ctlen); + const OSSL_HPKE_SUITE *suite_in, + OSSL_HPKE_SUITE *suite, unsigned char *enc, + size_t *enclen, unsigned char *ct, size_t ctlen); int OSSL_HPKE_str2suite(const char *str, OSSL_HPKE_SUITE *suite); size_t OSSL_HPKE_get_ciphertext_size(OSSL_HPKE_SUITE suite, size_t clearlen); size_t OSSL_HPKE_get_public_encap_size(OSSL_HPKE_SUITE suite); diff --git a/libs/OpenSSL/include/openssl/http.h b/libs/OpenSSL/include/openssl/http.h index 3e1c5bc5..078ce406 100644 --- a/libs/OpenSSL/include/openssl/http.h +++ b/libs/OpenSSL/include/openssl/http.h @@ -38,53 +38,69 @@ extern "C" { /* Low-level HTTP API */ OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size); void OSSL_HTTP_REQ_CTX_free(OSSL_HTTP_REQ_CTX *rctx); -int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST, const char *server, - const char *port, const char *path); -int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX *rctx, const char *name, const char *value); -int OSSL_HTTP_REQ_CTX_set_expected(OSSL_HTTP_REQ_CTX *rctx, const char *content_type, int asn1, +int OSSL_HTTP_REQ_CTX_set_request_line(OSSL_HTTP_REQ_CTX *rctx, int method_POST, + const char *server, const char *port, + const char *path); +int OSSL_HTTP_REQ_CTX_add1_header(OSSL_HTTP_REQ_CTX *rctx, const char *name, + const char *value); +int OSSL_HTTP_REQ_CTX_set_expected(OSSL_HTTP_REQ_CTX *rctx, + const char *content_type, int asn1, int timeout, int keep_alive); -int OSSL_HTTP_REQ_CTX_set1_req(OSSL_HTTP_REQ_CTX *rctx, const char *content_type, - const ASN1_ITEM *it, const ASN1_VALUE *req); +int OSSL_HTTP_REQ_CTX_set1_req(OSSL_HTTP_REQ_CTX *rctx, + const char *content_type, const ASN1_ITEM *it, + const ASN1_VALUE *req); int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx); -int OSSL_HTTP_REQ_CTX_nbio_d2i(OSSL_HTTP_REQ_CTX *rctx, ASN1_VALUE **pval, const ASN1_ITEM *it); +int OSSL_HTTP_REQ_CTX_nbio_d2i(OSSL_HTTP_REQ_CTX *rctx, ASN1_VALUE **pval, + const ASN1_ITEM *it); BIO *OSSL_HTTP_REQ_CTX_exchange(OSSL_HTTP_REQ_CTX *rctx); BIO *OSSL_HTTP_REQ_CTX_get0_mem_bio(const OSSL_HTTP_REQ_CTX *rctx); size_t OSSL_HTTP_REQ_CTX_get_resp_len(const OSSL_HTTP_REQ_CTX *rctx); -void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx, unsigned long len); +void OSSL_HTTP_REQ_CTX_set_max_response_length(OSSL_HTTP_REQ_CTX *rctx, + unsigned long len); int OSSL_HTTP_is_alive(const OSSL_HTTP_REQ_CTX *rctx); /* High-level HTTP API */ -typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, int detail); -OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port, const char *proxy, - const char *no_proxy, int use_ssl, BIO *bio, BIO *rbio, - OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, int buf_size, - int overall_timeout); -int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port, const char *proxyuser, - const char *proxypass, int timeout, BIO *bio_err, const char *prog); +typedef BIO *(*OSSL_HTTP_bio_cb_t)(BIO *bio, void *arg, int connect, + int detail); +OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port, + const char *proxy, const char *no_proxy, + int use_ssl, BIO *bio, BIO *rbio, + OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, + int buf_size, int overall_timeout); +int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port, + const char *proxyuser, const char *proxypass, + int timeout, BIO *bio_err, const char *prog); int OSSL_HTTP_set1_request(OSSL_HTTP_REQ_CTX *rctx, const char *path, - const STACK_OF(CONF_VALUE) * headers, const char *content_type, BIO *req, - const char *expected_content_type, int expect_asn1, size_t max_resp_len, - int timeout, int keep_alive); + const STACK_OF(CONF_VALUE) * headers, + const char *content_type, BIO *req, + const char *expected_content_type, int expect_asn1, + size_t max_resp_len, int timeout, int keep_alive); BIO *OSSL_HTTP_exchange(OSSL_HTTP_REQ_CTX *rctx, char **redirection_url); -BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy, BIO *bio, BIO *rbio, - OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, int buf_size, - const STACK_OF(CONF_VALUE) * headers, const char *expected_content_type, - int expect_asn1, size_t max_resp_len, int timeout); -BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx, const char *server, const char *port, - const char *path, int use_ssl, const char *proxy, const char *no_proxy, - BIO *bio, BIO *rbio, OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, +BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy, + BIO *bio, BIO *rbio, OSSL_HTTP_bio_cb_t bio_update_fn, + void *arg, int buf_size, + const STACK_OF(CONF_VALUE) * headers, + const char *expected_content_type, int expect_asn1, + size_t max_resp_len, int timeout); +BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx, const char *server, + const char *port, const char *path, int use_ssl, + const char *proxy, const char *no_proxy, BIO *bio, + BIO *rbio, OSSL_HTTP_bio_cb_t bio_update_fn, void *arg, int buf_size, const STACK_OF(CONF_VALUE) * headers, - const char *content_type, BIO *req, const char *expected_content_type, - int expect_asn1, size_t max_resp_len, int timeout, int keep_alive); + const char *content_type, BIO *req, + const char *expected_content_type, int expect_asn1, + size_t max_resp_len, int timeout, int keep_alive); int OSSL_HTTP_close(OSSL_HTTP_REQ_CTX *rctx, int ok); /* Auxiliary functions */ -int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost, char **pport, - int *pport_num, char **ppath, char **pquery, char **pfrag); -int OSSL_HTTP_parse_url(const char *url, int *pssl, char **puser, char **phost, char **pport, - int *pport_num, char **ppath, char **pquery, char **pfrag); -const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy, const char *server, - int use_ssl); +int OSSL_parse_url(const char *url, char **pscheme, char **puser, char **phost, + char **pport, int *pport_num, char **ppath, char **pquery, + char **pfrag); +int OSSL_HTTP_parse_url(const char *url, int *pssl, char **puser, char **phost, + char **pport, int *pport_num, char **ppath, + char **pquery, char **pfrag); +const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy, + const char *server, int use_ssl); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/idea.h b/libs/OpenSSL/include/openssl/idea.h index e39a8726..51950f43 100644 --- a/libs/OpenSSL/include/openssl/idea.h +++ b/libs/OpenSSL/include/openssl/idea.h @@ -13,63 +13,69 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_IDEA_H +# define HEADER_IDEA_H #endif #include #ifndef OPENSSL_NO_IDEA -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define IDEA_BLOCK 8 -# define IDEA_KEY_LENGTH 16 +# define IDEA_BLOCK 8 +# define IDEA_KEY_LENGTH 16 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef unsigned int IDEA_INT; -# define IDEA_ENCRYPT 1 -# define IDEA_DECRYPT 0 +# define IDEA_ENCRYPT 1 +# define IDEA_DECRYPT 0 typedef struct idea_key_st { - IDEA_INT data[9][6]; + IDEA_INT data[9][6]; } IDEA_KEY_SCHEDULE; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 const char *IDEA_options(void); -OSSL_DEPRECATEDIN_3_0 void IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out, +OSSL_DEPRECATEDIN_3_0 void IDEA_ecb_encrypt(const unsigned char *in, + unsigned char *out, IDEA_KEY_SCHEDULE *ks); -OSSL_DEPRECATEDIN_3_0 void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); -OSSL_DEPRECATEDIN_3_0 void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); -OSSL_DEPRECATEDIN_3_0 void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int enc); -OSSL_DEPRECATEDIN_3_0 void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num, int enc); -OSSL_DEPRECATEDIN_3_0 void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num); -OSSL_DEPRECATEDIN_3_0 void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); -# endif +OSSL_DEPRECATEDIN_3_0 void IDEA_set_encrypt_key(const unsigned char *key, + IDEA_KEY_SCHEDULE *ks); +OSSL_DEPRECATEDIN_3_0 void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, + IDEA_KEY_SCHEDULE *dk); +OSSL_DEPRECATEDIN_3_0 void IDEA_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + IDEA_KEY_SCHEDULE *ks, + unsigned char *iv, int enc); +OSSL_DEPRECATEDIN_3_0 void +IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num, int enc); +OSSL_DEPRECATEDIN_3_0 void IDEA_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + IDEA_KEY_SCHEDULE *ks, + unsigned char *iv, int *num); +OSSL_DEPRECATEDIN_3_0 void IDEA_encrypt(unsigned long *in, + IDEA_KEY_SCHEDULE *ks); +# endif -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define idea_options IDEA_options -# define idea_ecb_encrypt IDEA_ecb_encrypt -# define idea_set_encrypt_key IDEA_set_encrypt_key -# define idea_set_decrypt_key IDEA_set_decrypt_key -# define idea_cbc_encrypt IDEA_cbc_encrypt -# define idea_cfb64_encrypt IDEA_cfb64_encrypt -# define idea_ofb64_encrypt IDEA_ofb64_encrypt -# define idea_encrypt IDEA_encrypt -# endif +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# define idea_options IDEA_options +# define idea_ecb_encrypt IDEA_ecb_encrypt +# define idea_set_encrypt_key IDEA_set_encrypt_key +# define idea_set_decrypt_key IDEA_set_decrypt_key +# define idea_cbc_encrypt IDEA_cbc_encrypt +# define idea_cfb64_encrypt IDEA_cfb64_encrypt +# define idea_ofb64_encrypt IDEA_ofb64_encrypt +# define idea_encrypt IDEA_encrypt +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/kdf.h b/libs/OpenSSL/include/openssl/kdf.h index 7754db17..24dfc355 100644 --- a/libs/OpenSSL/include/openssl/kdf.h +++ b/libs/OpenSSL/include/openssl/kdf.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_KDF_H +# define HEADER_KDF_H #endif #include @@ -27,7 +27,8 @@ extern "C" { int EVP_KDF_up_ref(EVP_KDF *kdf); void EVP_KDF_free(EVP_KDF *kdf); -EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, const char *properties); +EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, + const char *properties); EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf); void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx); @@ -40,7 +41,8 @@ const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx); void EVP_KDF_CTX_reset(EVP_KDF_CTX *ctx); size_t EVP_KDF_CTX_get_kdf_size(EVP_KDF_CTX *ctx); -int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen, const OSSL_PARAM params[]); +int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen, + const OSSL_PARAM params[]); int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]); int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]); int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]); @@ -50,8 +52,10 @@ const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf); const OSSL_PARAM *EVP_KDF_CTX_gettable_params(EVP_KDF_CTX *ctx); const OSSL_PARAM *EVP_KDF_CTX_settable_params(EVP_KDF_CTX *ctx); -void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_KDF *kdf, void *arg), void *arg); -int EVP_KDF_names_do_all(const EVP_KDF *kdf, void (*fn)(const char *name, void *data), void *data); +void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx, + void (*fn)(EVP_KDF *kdf, void *arg), void *arg); +int EVP_KDF_names_do_all(const EVP_KDF *kdf, + void (*fn)(const char *name, void *data), void *data); #define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 0 #define EVP_KDF_HKDF_MODE_EXTRACT_ONLY 1 @@ -81,30 +85,38 @@ int EVP_KDF_names_do_all(const EVP_KDF *kdf, void (*fn)(const char *name, void * #define EVP_PKEY_CTRL_SCRYPT_P (EVP_PKEY_ALG_CTRL + 12) #define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES (EVP_PKEY_ALG_CTRL + 13) -#define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND +#define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND \ + EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND #define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY EVP_KDF_HKDF_MODE_EXTRACT_ONLY #define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY EVP_KDF_HKDF_MODE_EXPAND_ONLY int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); -int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx, const unsigned char *sec, int seclen); +int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx, + const unsigned char *sec, int seclen); -int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx, const unsigned char *seed, int seedlen); +int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx, + const unsigned char *seed, int seedlen); int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); -int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx, const unsigned char *salt, int saltlen); +int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx, const unsigned char *salt, + int saltlen); -int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx, const unsigned char *key, int keylen); +int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx, const unsigned char *key, + int keylen); -int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx, const unsigned char *info, int infolen); +int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx, const unsigned char *info, + int infolen); int EVP_PKEY_CTX_set_hkdf_mode(EVP_PKEY_CTX *ctx, int mode); #define EVP_PKEY_CTX_hkdf_mode EVP_PKEY_CTX_set_hkdf_mode -int EVP_PKEY_CTX_set1_pbe_pass(EVP_PKEY_CTX *ctx, const char *pass, int passlen); +int EVP_PKEY_CTX_set1_pbe_pass(EVP_PKEY_CTX *ctx, const char *pass, + int passlen); -int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *ctx, const unsigned char *salt, int saltlen); +int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *ctx, const unsigned char *salt, + int saltlen); int EVP_PKEY_CTX_set_scrypt_N(EVP_PKEY_CTX *ctx, uint64_t n); @@ -112,7 +124,8 @@ int EVP_PKEY_CTX_set_scrypt_r(EVP_PKEY_CTX *ctx, uint64_t r); int EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *ctx, uint64_t p); -int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx, uint64_t maxmem_bytes); +int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx, + uint64_t maxmem_bytes); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/lhash.h b/libs/OpenSSL/include/openssl/lhash.h index 6d005ee7..9a6ab64d 100644 --- a/libs/OpenSSL/include/openssl/lhash.h +++ b/libs/OpenSSL/include/openssl/lhash.h @@ -17,13 +17,13 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_LHASH_H +# define HEADER_LHASH_H #endif #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -47,36 +47,38 @@ typedef struct lhash_st OPENSSL_LHASH; */ /* First: "hash" functions */ -#define DECLARE_LHASH_HASH_FN(name, o_type) unsigned long name##_LHASH_HASH(const void *); -#define IMPLEMENT_LHASH_HASH_FN(name, o_type) \ - unsigned long name##_LHASH_HASH(const void *arg) \ - { \ - const o_type *a = arg; \ - return name##_hash(a); \ - } +#define DECLARE_LHASH_HASH_FN(name, o_type) \ + unsigned long name##_LHASH_HASH(const void *); +#define IMPLEMENT_LHASH_HASH_FN(name, o_type) \ + unsigned long name##_LHASH_HASH(const void *arg) \ + { \ + const o_type *a = arg; \ + return name##_hash(a); \ + } #define LHASH_HASH_FN(name) name##_LHASH_HASH /* Second: "compare" functions */ -#define DECLARE_LHASH_COMP_FN(name, o_type) int name##_LHASH_COMP(const void *, const void *); -#define IMPLEMENT_LHASH_COMP_FN(name, o_type) \ - int name##_LHASH_COMP(const void *arg1, const void *arg2) \ - { \ - const o_type *a = arg1; \ - const o_type *b = arg2; \ - return name##_cmp(a, b); \ - } +#define DECLARE_LHASH_COMP_FN(name, o_type) \ + int name##_LHASH_COMP(const void *, const void *); +#define IMPLEMENT_LHASH_COMP_FN(name, o_type) \ + int name##_LHASH_COMP(const void *arg1, const void *arg2) \ + { \ + const o_type *a = arg1; \ + const o_type *b = arg2; \ + return name##_cmp(a, b); \ + } #define LHASH_COMP_FN(name) name##_LHASH_COMP /* Fourth: "doall_arg" functions */ -#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ - void name##_LHASH_DOALL_ARG(void *, void *); -#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ - void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) \ - { \ - o_type *a = arg1; \ - a_type *b = arg2; \ - name##_doall_arg(a, b); \ - } +#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ + void name##_LHASH_DOALL_ARG(void *, void *); +#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ + void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) \ + { \ + o_type *a = arg1; \ + a_type *b = arg2; \ + name##_doall_arg(a, b); \ + } #define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG #define LH_LOAD_MULT 256 @@ -89,46 +91,52 @@ void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data); void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data); void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data); void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func); -void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg); +void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, + void *arg); unsigned long OPENSSL_LH_strhash(const char *c); unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh); unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh); void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load); #ifndef OPENSSL_NO_STDIO -# ifndef OPENSSL_NO_DEPRECATED_3_2 +# ifndef OPENSSL_NO_DEPRECATED_3_2 OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp); -OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp); -OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp); -# endif +OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, + FILE *fp); +OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, + FILE *fp); +# endif #endif #ifndef OPENSSL_NO_DEPRECATED_3_2 -OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out); -OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out); -OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); +OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, + BIO *out); +OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, + BIO *out); +OSSL_DEPRECATEDIN_3_2 void +OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define _LHASH OPENSSL_LHASH -# define LHASH_NODE OPENSSL_LH_NODE -# define lh_error OPENSSL_LH_error -# define lh_new OPENSSL_LH_new -# define lh_free OPENSSL_LH_free -# define lh_insert OPENSSL_LH_insert -# define lh_delete OPENSSL_LH_delete -# define lh_retrieve OPENSSL_LH_retrieve -# define lh_doall OPENSSL_LH_doall -# define lh_doall_arg OPENSSL_LH_doall_arg -# define lh_strhash OPENSSL_LH_strhash -# define lh_num_items OPENSSL_LH_num_items -# ifndef OPENSSL_NO_STDIO -# define lh_stats OPENSSL_LH_stats -# define lh_node_stats OPENSSL_LH_node_stats -# define lh_node_usage_stats OPENSSL_LH_node_usage_stats -# endif -# define lh_stats_bio OPENSSL_LH_stats_bio -# define lh_node_stats_bio OPENSSL_LH_node_stats_bio -# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio +# define _LHASH OPENSSL_LHASH +# define LHASH_NODE OPENSSL_LH_NODE +# define lh_error OPENSSL_LH_error +# define lh_new OPENSSL_LH_new +# define lh_free OPENSSL_LH_free +# define lh_insert OPENSSL_LH_insert +# define lh_delete OPENSSL_LH_delete +# define lh_retrieve OPENSSL_LH_retrieve +# define lh_doall OPENSSL_LH_doall +# define lh_doall_arg OPENSSL_LH_doall_arg +# define lh_strhash OPENSSL_LH_strhash +# define lh_num_items OPENSSL_LH_num_items +# ifndef OPENSSL_NO_STDIO +# define lh_stats OPENSSL_LH_stats +# define lh_node_stats OPENSSL_LH_node_stats +# define lh_node_usage_stats OPENSSL_LH_node_usage_stats +# endif +# define lh_stats_bio OPENSSL_LH_stats_bio +# define lh_node_stats_bio OPENSSL_LH_node_stats_bio +# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio #endif /* Type checking... */ @@ -136,221 +144,247 @@ OSSL_DEPRECATEDIN_3_2 void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH * #define LHASH_OF(type) struct lhash_st_##type /* Helper macro for internal use */ -#define DEFINE_LHASH_OF_INTERNAL(type) \ - LHASH_OF(type) \ - { \ - union lh_##type##_dummy \ - { \ - void *d1; \ - unsigned long d2; \ - int d3; \ - } dummy; \ - }; \ - typedef int (*lh_##type##_compfunc)(const type *a, const type *b); \ - typedef unsigned long (*lh_##type##_hashfunc)(const type *a); \ - typedef void (*lh_##type##_doallfunc)(type * a); \ - static ossl_unused ossl_inline type *ossl_check_##type##_lh_plain_type(type *ptr) \ - { \ - return ptr; \ - } \ - static ossl_unused ossl_inline const type *ossl_check_const_##type##_lh_plain_type( \ - const type *ptr) \ - { \ - return ptr; \ - } \ - static ossl_unused ossl_inline const OPENSSL_LHASH *ossl_check_const_##type##_lh_type( \ - const LHASH_OF(type) * lh) \ - { \ - return (const OPENSSL_LHASH *)lh; \ - } \ - static ossl_unused ossl_inline OPENSSL_LHASH *ossl_check_##type##_lh_type(LHASH_OF(type) * lh) \ - { \ - return (OPENSSL_LHASH *)lh; \ - } \ - static ossl_unused ossl_inline OPENSSL_LH_COMPFUNC ossl_check_##type##_lh_compfunc_type( \ - lh_##type##_compfunc cmp) \ - { \ - return (OPENSSL_LH_COMPFUNC)cmp; \ - } \ - static ossl_unused ossl_inline OPENSSL_LH_HASHFUNC ossl_check_##type##_lh_hashfunc_type( \ - lh_##type##_hashfunc hfn) \ - { \ - return (OPENSSL_LH_HASHFUNC)hfn; \ - } \ - static ossl_unused ossl_inline OPENSSL_LH_DOALL_FUNC ossl_check_##type##_lh_doallfunc_type( \ - lh_##type##_doallfunc dfn) \ - { \ - return (OPENSSL_LH_DOALL_FUNC)dfn; \ - } \ - LHASH_OF(type) +#define DEFINE_LHASH_OF_INTERNAL(type) \ + LHASH_OF(type) \ + { \ + union lh_##type##_dummy \ + { \ + void *d1; \ + unsigned long d2; \ + int d3; \ + } dummy; \ + }; \ + typedef int (*lh_##type##_compfunc)(const type *a, const type *b); \ + typedef unsigned long (*lh_##type##_hashfunc)(const type *a); \ + typedef void (*lh_##type##_doallfunc)(type * a); \ + static ossl_unused ossl_inline type *ossl_check_##type##_lh_plain_type( \ + type *ptr) \ + { \ + return ptr; \ + } \ + static ossl_unused ossl_inline const type \ + *ossl_check_const_##type##_lh_plain_type(const type *ptr) \ + { \ + return ptr; \ + } \ + static ossl_unused ossl_inline const OPENSSL_LHASH \ + *ossl_check_const_##type##_lh_type(const LHASH_OF(type) * lh) \ + { \ + return (const OPENSSL_LHASH *)lh; \ + } \ + static ossl_unused ossl_inline OPENSSL_LHASH *ossl_check_##type##_lh_type( \ + LHASH_OF(type) * lh) \ + { \ + return (OPENSSL_LHASH *)lh; \ + } \ + static ossl_unused ossl_inline OPENSSL_LH_COMPFUNC \ + ossl_check_##type##_lh_compfunc_type(lh_##type##_compfunc cmp) \ + { \ + return (OPENSSL_LH_COMPFUNC)cmp; \ + } \ + static ossl_unused ossl_inline OPENSSL_LH_HASHFUNC \ + ossl_check_##type##_lh_hashfunc_type(lh_##type##_hashfunc hfn) \ + { \ + return (OPENSSL_LH_HASHFUNC)hfn; \ + } \ + static ossl_unused ossl_inline OPENSSL_LH_DOALL_FUNC \ + ossl_check_##type##_lh_doallfunc_type(lh_##type##_doallfunc dfn) \ + { \ + return (OPENSSL_LH_DOALL_FUNC)dfn; \ + } \ + LHASH_OF(type) #ifndef OPENSSL_NO_DEPRECATED_3_2 -# define DEFINE_LHASH_OF_DEPRECATED(type) \ - static ossl_unused ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) * lh, \ - BIO * out) \ - { \ - OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_unused ossl_inline void lh_##type##_node_usage_stats_bio( \ - const LHASH_OF(type) * lh, BIO * out) \ - { \ - OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_unused ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) * lh, \ - BIO * out) \ - { \ - OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } +# define DEFINE_LHASH_OF_DEPRECATED(type) \ + static ossl_unused ossl_inline void lh_##type##_node_stats_bio( \ + const LHASH_OF(type) * lh, BIO * out) \ + { \ + OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ + } \ + static ossl_unused ossl_inline void lh_##type##_node_usage_stats_bio( \ + const LHASH_OF(type) * lh, BIO * out) \ + { \ + OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ + } \ + static ossl_unused ossl_inline void lh_##type##_stats_bio( \ + const LHASH_OF(type) * lh, BIO * out) \ + { \ + OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ + } #else -# define DEFINE_LHASH_OF_DEPRECATED(type) +# define DEFINE_LHASH_OF_DEPRECATED(type) #endif -#define DEFINE_LHASH_OF_EX(type) \ - LHASH_OF(type) \ - { \ - union lh_##type##_dummy \ - { \ - void *d1; \ - unsigned long d2; \ - int d3; \ - } dummy; \ - }; \ - static ossl_unused ossl_inline LHASH_OF(type) \ - * lh_##type##_new(unsigned long (*hfn)(const type *), \ - int (*cfn)(const type *, const type *)) \ - { \ - return (LHASH_OF(type) *)OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, \ - (OPENSSL_LH_COMPFUNC)cfn); \ - } \ - static ossl_unused ossl_inline void lh_##type##_free(LHASH_OF(type) * lh) \ - { \ - OPENSSL_LH_free((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline void lh_##type##_flush(LHASH_OF(type) * lh) \ - { \ - OPENSSL_LH_flush((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline type *lh_##type##_insert(LHASH_OF(type) * lh, type * d) \ - { \ - return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_unused ossl_inline type *lh_##type##_delete(LHASH_OF(type) * lh, const type *d) \ - { \ - return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_unused ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) * lh, const type *d) \ - { \ - return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_unused ossl_inline int lh_##type##_error(LHASH_OF(type) * lh) \ - { \ - return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) * lh) \ - { \ - return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) * lh) \ - { \ - return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) * lh, \ - unsigned long dl) \ - { \ - OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \ - } \ - static ossl_unused ossl_inline void lh_##type##_doall(LHASH_OF(type) * lh, \ - void (*doall)(type *)) \ - { \ - OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \ - } \ - static ossl_unused ossl_inline void lh_##type##_doall_arg( \ - LHASH_OF(type) * lh, void (*doallarg)(type *, void *), void *arg) \ - { \ - OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)doallarg, arg); \ - } \ - LHASH_OF(type) +#define DEFINE_LHASH_OF_EX(type) \ + LHASH_OF(type) \ + { \ + union lh_##type##_dummy \ + { \ + void *d1; \ + unsigned long d2; \ + int d3; \ + } dummy; \ + }; \ + static ossl_unused ossl_inline LHASH_OF(type) \ + * lh_##type##_new(unsigned long (*hfn)(const type *), \ + int (*cfn)(const type *, const type *)) \ + { \ + return (LHASH_OF(type) *)OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, \ + (OPENSSL_LH_COMPFUNC)cfn); \ + } \ + static ossl_unused ossl_inline void lh_##type##_free(LHASH_OF(type) * lh) \ + { \ + OPENSSL_LH_free((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline void lh_##type##_flush(LHASH_OF(type) * lh) \ + { \ + OPENSSL_LH_flush((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline type *lh_##type##_insert(LHASH_OF(type) * lh, \ + type * d) \ + { \ + return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \ + } \ + static ossl_unused ossl_inline type *lh_##type##_delete(LHASH_OF(type) * lh, \ + const type *d) \ + { \ + return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \ + } \ + static ossl_unused ossl_inline type *lh_##type##_retrieve( \ + LHASH_OF(type) * lh, const type *d) \ + { \ + return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \ + } \ + static ossl_unused ossl_inline int lh_##type##_error(LHASH_OF(type) * lh) \ + { \ + return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline unsigned long lh_##type##_num_items( \ + LHASH_OF(type) * lh) \ + { \ + return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline unsigned long lh_##type##_get_down_load( \ + LHASH_OF(type) * lh) \ + { \ + return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \ + } \ + static ossl_unused ossl_inline void lh_##type##_set_down_load( \ + LHASH_OF(type) * lh, unsigned long dl) \ + { \ + OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \ + } \ + static ossl_unused ossl_inline void lh_##type##_doall(LHASH_OF(type) * lh, \ + void (*doall)(type *)) \ + { \ + OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \ + } \ + static ossl_unused ossl_inline void lh_##type##_doall_arg( \ + LHASH_OF(type) * lh, void (*doallarg)(type *, void *), void *arg) \ + { \ + OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, \ + (OPENSSL_LH_DOALL_FUNCARG)doallarg, arg); \ + } \ + LHASH_OF(type) -#define DEFINE_LHASH_OF(type) \ - DEFINE_LHASH_OF_EX(type); \ - DEFINE_LHASH_OF_DEPRECATED(type) \ - LHASH_OF(type) +#define DEFINE_LHASH_OF(type) \ + DEFINE_LHASH_OF_EX(type); \ + DEFINE_LHASH_OF_DEPRECATED(type) \ + LHASH_OF(type) -#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \ - int_implement_lhash_doall(type, argtype, const type) +#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \ + int_implement_lhash_doall(type, argtype, const type) -#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) int_implement_lhash_doall(type, argtype, type) +#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \ + int_implement_lhash_doall(type, argtype, type) -#define int_implement_lhash_doall(type, argtype, cbargtype) \ - static ossl_unused ossl_inline void lh_##type##_doall_##argtype( \ - LHASH_OF(type) * lh, void (*fn)(cbargtype *, argtype *), argtype *arg) \ - { \ - OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \ - } \ - LHASH_OF(type) +#define int_implement_lhash_doall(type, argtype, cbargtype) \ + static ossl_unused ossl_inline void lh_##type##_doall_##argtype( \ + LHASH_OF(type) * lh, void (*fn)(cbargtype *, argtype *), argtype *arg) \ + { \ + OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, \ + (void *)arg); \ + } \ + LHASH_OF(type) DEFINE_LHASH_OF_INTERNAL(OPENSSL_STRING); -#define lh_OPENSSL_STRING_new(hfn, cmp) \ - ((LHASH_OF(OPENSSL_STRING) *)OPENSSL_LH_new(ossl_check_OPENSSL_STRING_lh_hashfunc_type(hfn), \ - ossl_check_OPENSSL_STRING_lh_compfunc_type(cmp))) -#define lh_OPENSSL_STRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_STRING_lh_type(lh)) -#define lh_OPENSSL_STRING_flush(lh) OPENSSL_LH_flush(ossl_check_OPENSSL_STRING_lh_type(lh)) -#define lh_OPENSSL_STRING_insert(lh, ptr) \ - ((OPENSSL_STRING *)OPENSSL_LH_insert(ossl_check_OPENSSL_STRING_lh_type(lh), \ - ossl_check_OPENSSL_STRING_lh_plain_type(ptr))) -#define lh_OPENSSL_STRING_delete(lh, ptr) \ - ((OPENSSL_STRING *)OPENSSL_LH_delete(ossl_check_OPENSSL_STRING_lh_type(lh), \ - ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr))) -#define lh_OPENSSL_STRING_retrieve(lh, ptr) \ - ((OPENSSL_STRING *)OPENSSL_LH_retrieve(ossl_check_OPENSSL_STRING_lh_type(lh), \ - ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr))) -#define lh_OPENSSL_STRING_error(lh) OPENSSL_LH_error(ossl_check_OPENSSL_STRING_lh_type(lh)) -#define lh_OPENSSL_STRING_num_items(lh) OPENSSL_LH_num_items(ossl_check_OPENSSL_STRING_lh_type(lh)) -#define lh_OPENSSL_STRING_node_stats_bio(lh, out) \ - OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) -#define lh_OPENSSL_STRING_node_usage_stats_bio(lh, out) \ - OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) -#define lh_OPENSSL_STRING_stats_bio(lh, out) \ - OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) -#define lh_OPENSSL_STRING_get_down_load(lh) \ - OPENSSL_LH_get_down_load(ossl_check_OPENSSL_STRING_lh_type(lh)) -#define lh_OPENSSL_STRING_set_down_load(lh, dl) \ - OPENSSL_LH_set_down_load(ossl_check_OPENSSL_STRING_lh_type(lh), dl) -#define lh_OPENSSL_STRING_doall(lh, dfn) \ - OPENSSL_LH_doall(ossl_check_OPENSSL_STRING_lh_type(lh), \ - ossl_check_OPENSSL_STRING_lh_doallfunc_type(dfn)) +#define lh_OPENSSL_STRING_new(hfn, cmp) \ + ((LHASH_OF(OPENSSL_STRING) *)OPENSSL_LH_new( \ + ossl_check_OPENSSL_STRING_lh_hashfunc_type(hfn), \ + ossl_check_OPENSSL_STRING_lh_compfunc_type(cmp))) +#define lh_OPENSSL_STRING_free(lh) \ + OPENSSL_LH_free(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_flush(lh) \ + OPENSSL_LH_flush(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_insert(lh, ptr) \ + ((OPENSSL_STRING *)OPENSSL_LH_insert( \ + ossl_check_OPENSSL_STRING_lh_type(lh), \ + ossl_check_OPENSSL_STRING_lh_plain_type(ptr))) +#define lh_OPENSSL_STRING_delete(lh, ptr) \ + ((OPENSSL_STRING *)OPENSSL_LH_delete( \ + ossl_check_OPENSSL_STRING_lh_type(lh), \ + ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr))) +#define lh_OPENSSL_STRING_retrieve(lh, ptr) \ + ((OPENSSL_STRING *)OPENSSL_LH_retrieve( \ + ossl_check_OPENSSL_STRING_lh_type(lh), \ + ossl_check_const_OPENSSL_STRING_lh_plain_type(ptr))) +#define lh_OPENSSL_STRING_error(lh) \ + OPENSSL_LH_error(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_num_items(lh) \ + OPENSSL_LH_num_items(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_node_stats_bio(lh, out) \ + OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) +#define lh_OPENSSL_STRING_node_usage_stats_bio(lh, out) \ + OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), \ + out) +#define lh_OPENSSL_STRING_stats_bio(lh, out) \ + OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_STRING_lh_type(lh), out) +#define lh_OPENSSL_STRING_get_down_load(lh) \ + OPENSSL_LH_get_down_load(ossl_check_OPENSSL_STRING_lh_type(lh)) +#define lh_OPENSSL_STRING_set_down_load(lh, dl) \ + OPENSSL_LH_set_down_load(ossl_check_OPENSSL_STRING_lh_type(lh), dl) +#define lh_OPENSSL_STRING_doall(lh, dfn) \ + OPENSSL_LH_doall(ossl_check_OPENSSL_STRING_lh_type(lh), \ + ossl_check_OPENSSL_STRING_lh_doallfunc_type(dfn)) DEFINE_LHASH_OF_INTERNAL(OPENSSL_CSTRING); -#define lh_OPENSSL_CSTRING_new(hfn, cmp) \ - ((LHASH_OF(OPENSSL_CSTRING) *)OPENSSL_LH_new( \ - ossl_check_OPENSSL_CSTRING_lh_hashfunc_type(hfn), \ - ossl_check_OPENSSL_CSTRING_lh_compfunc_type(cmp))) -#define lh_OPENSSL_CSTRING_free(lh) OPENSSL_LH_free(ossl_check_OPENSSL_CSTRING_lh_type(lh)) -#define lh_OPENSSL_CSTRING_flush(lh) OPENSSL_LH_flush(ossl_check_OPENSSL_CSTRING_lh_type(lh)) -#define lh_OPENSSL_CSTRING_insert(lh, ptr) \ - ((OPENSSL_CSTRING *)OPENSSL_LH_insert(ossl_check_OPENSSL_CSTRING_lh_type(lh), \ - ossl_check_OPENSSL_CSTRING_lh_plain_type(ptr))) -#define lh_OPENSSL_CSTRING_delete(lh, ptr) \ - ((OPENSSL_CSTRING *)OPENSSL_LH_delete(ossl_check_OPENSSL_CSTRING_lh_type(lh), \ - ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr))) -#define lh_OPENSSL_CSTRING_retrieve(lh, ptr) \ - ((OPENSSL_CSTRING *)OPENSSL_LH_retrieve(ossl_check_OPENSSL_CSTRING_lh_type(lh), \ - ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr))) -#define lh_OPENSSL_CSTRING_error(lh) OPENSSL_LH_error(ossl_check_OPENSSL_CSTRING_lh_type(lh)) -#define lh_OPENSSL_CSTRING_num_items(lh) \ - OPENSSL_LH_num_items(ossl_check_OPENSSL_CSTRING_lh_type(lh)) -#define lh_OPENSSL_CSTRING_node_stats_bio(lh, out) \ - OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) -#define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh, out) \ - OPENSSL_LH_node_usage_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) -#define lh_OPENSSL_CSTRING_stats_bio(lh, out) \ - OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) -#define lh_OPENSSL_CSTRING_get_down_load(lh) \ - OPENSSL_LH_get_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh)) -#define lh_OPENSSL_CSTRING_set_down_load(lh, dl) \ - OPENSSL_LH_set_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh), dl) -#define lh_OPENSSL_CSTRING_doall(lh, dfn) \ - OPENSSL_LH_doall(ossl_check_OPENSSL_CSTRING_lh_type(lh), \ - ossl_check_OPENSSL_CSTRING_lh_doallfunc_type(dfn)) +#define lh_OPENSSL_CSTRING_new(hfn, cmp) \ + ((LHASH_OF(OPENSSL_CSTRING) *)OPENSSL_LH_new( \ + ossl_check_OPENSSL_CSTRING_lh_hashfunc_type(hfn), \ + ossl_check_OPENSSL_CSTRING_lh_compfunc_type(cmp))) +#define lh_OPENSSL_CSTRING_free(lh) \ + OPENSSL_LH_free(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_flush(lh) \ + OPENSSL_LH_flush(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_insert(lh, ptr) \ + ((OPENSSL_CSTRING *)OPENSSL_LH_insert( \ + ossl_check_OPENSSL_CSTRING_lh_type(lh), \ + ossl_check_OPENSSL_CSTRING_lh_plain_type(ptr))) +#define lh_OPENSSL_CSTRING_delete(lh, ptr) \ + ((OPENSSL_CSTRING *)OPENSSL_LH_delete( \ + ossl_check_OPENSSL_CSTRING_lh_type(lh), \ + ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr))) +#define lh_OPENSSL_CSTRING_retrieve(lh, ptr) \ + ((OPENSSL_CSTRING *)OPENSSL_LH_retrieve( \ + ossl_check_OPENSSL_CSTRING_lh_type(lh), \ + ossl_check_const_OPENSSL_CSTRING_lh_plain_type(ptr))) +#define lh_OPENSSL_CSTRING_error(lh) \ + OPENSSL_LH_error(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_num_items(lh) \ + OPENSSL_LH_num_items(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_node_stats_bio(lh, out) \ + OPENSSL_LH_node_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) +#define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh, out) \ + OPENSSL_LH_node_usage_stats_bio( \ + ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) +#define lh_OPENSSL_CSTRING_stats_bio(lh, out) \ + OPENSSL_LH_stats_bio(ossl_check_const_OPENSSL_CSTRING_lh_type(lh), out) +#define lh_OPENSSL_CSTRING_get_down_load(lh) \ + OPENSSL_LH_get_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh)) +#define lh_OPENSSL_CSTRING_set_down_load(lh, dl) \ + OPENSSL_LH_set_down_load(ossl_check_OPENSSL_CSTRING_lh_type(lh), dl) +#define lh_OPENSSL_CSTRING_doall(lh, dfn) \ + OPENSSL_LH_doall(ossl_check_OPENSSL_CSTRING_lh_type(lh), \ + ossl_check_OPENSSL_CSTRING_lh_doallfunc_type(dfn)) #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/macros.h b/libs/OpenSSL/include/openssl/macros.h index 4e366e88..b05db519 100644 --- a/libs/OpenSSL/include/openssl/macros.h +++ b/libs/OpenSSL/include/openssl/macros.h @@ -31,41 +31,43 @@ * OSSL_DEPRECATED_FOR become no-ops */ #ifndef OSSL_DEPRECATED -# undef OSSL_DEPRECATED_FOR -# ifndef OPENSSL_SUPPRESS_DEPRECATED -# if defined(_MSC_VER) +# undef OSSL_DEPRECATED_FOR +# ifndef OPENSSL_SUPPRESS_DEPRECATED +# if defined(_MSC_VER) /* * MSVC supports __declspec(deprecated) since MSVC 2003 (13.10), * and __declspec(deprecated(message)) since MSVC 2005 (14.00) */ -# if _MSC_VER >= 1400 -# define OSSL_DEPRECATED(since) __declspec(deprecated("Since OpenSSL " # since)) -# define OSSL_DEPRECATED_FOR(since, message) \ - __declspec(deprecated("Since OpenSSL " #since ";" message)) -# elif _MSC_VER >= 1310 -# define OSSL_DEPRECATED(since) __declspec(deprecated) -# define OSSL_DEPRECATED_FOR(since, message) __declspec(deprecated) -# endif -# elif defined(__GNUC__) +# if _MSC_VER >= 1400 +# define OSSL_DEPRECATED(since) \ + __declspec(deprecated("Since OpenSSL " #since)) +# define OSSL_DEPRECATED_FOR(since, message) \ + __declspec(deprecated("Since OpenSSL " #since ";" message)) +# elif _MSC_VER >= 1310 +# define OSSL_DEPRECATED(since) __declspec(deprecated) +# define OSSL_DEPRECATED_FOR(since, message) __declspec(deprecated) +# endif +# elif defined(__GNUC__) /* * According to GCC documentation, deprecations with message appeared in * GCC 4.5.0 */ -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -# define OSSL_DEPRECATED(since) __attribute__((deprecated("Since OpenSSL " # since))) -# define OSSL_DEPRECATED_FOR(since, message) \ - __attribute__((deprecated("Since OpenSSL " #since ";" message))) -# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) -# define OSSL_DEPRECATED(since) __attribute__((deprecated)) -# define OSSL_DEPRECATED_FOR(since, message) __attribute__((deprecated)) -# endif -# elif defined(__SUNPRO_C) -# if (__SUNPRO_C >= 0x5130) -# define OSSL_DEPRECATED(since) __attribute__((deprecated)) -# define OSSL_DEPRECATED_FOR(since, message) __attribute__((deprecated)) -# endif -# endif +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define OSSL_DEPRECATED(since) \ + __attribute__((deprecated("Since OpenSSL " #since))) +# define OSSL_DEPRECATED_FOR(since, message) \ + __attribute__((deprecated("Since OpenSSL " #since ";" message))) +# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) +# define OSSL_DEPRECATED(since) __attribute__((deprecated)) +# define OSSL_DEPRECATED_FOR(since, message) __attribute__((deprecated)) +# endif +# elif defined(__SUNPRO_C) +# if (__SUNPRO_C >= 0x5130) +# define OSSL_DEPRECATED(since) __attribute__((deprecated)) +# define OSSL_DEPRECATED_FOR(since, message) __attribute__((deprecated)) +# endif # endif +# endif #endif /* @@ -73,8 +75,8 @@ * are unsuitable for use in a typedef. */ #ifndef OSSL_DEPRECATED -# define OSSL_DEPRECATED(since) extern -# define OSSL_DEPRECATED_FOR(since, message) extern +# define OSSL_DEPRECATED(since) extern +# define OSSL_DEPRECATED_FOR(since, message) extern #endif /* @@ -99,7 +101,7 @@ */ #ifdef OPENSSL_API_LEVEL -# error "OPENSSL_API_LEVEL must not be defined by application" +# error "OPENSSL_API_LEVEL must not be defined by application" #endif /* @@ -109,13 +111,14 @@ * number. This allows new versions up to and including v943.71.83. */ #ifdef OPENSSL_API_COMPAT -# if OPENSSL_API_COMPAT < 0x900000L -# define OPENSSL_API_LEVEL (OPENSSL_API_COMPAT) -# else -# define OPENSSL_API_LEVEL \ - (((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \ - + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 + ((OPENSSL_API_COMPAT >> 12) & 0xFF)) -# endif +# if OPENSSL_API_COMPAT < 0x900000L +# define OPENSSL_API_LEVEL (OPENSSL_API_COMPAT) +# else +# define OPENSSL_API_LEVEL \ + (((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \ + + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \ + + ((OPENSSL_API_COMPAT >> 12) & 0xFF)) +# endif #endif /* @@ -123,31 +126,34 @@ * the API compatibility level. */ #ifndef OPENSSL_API_LEVEL -# if OPENSSL_CONFIGURED_API > 0 -# define OPENSSL_API_LEVEL (OPENSSL_CONFIGURED_API) -# else -# define OPENSSL_API_LEVEL (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100) -# endif +# if OPENSSL_CONFIGURED_API > 0 +# define OPENSSL_API_LEVEL (OPENSSL_CONFIGURED_API) +# else +# define OPENSSL_API_LEVEL \ + (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100) +# endif #endif #if OPENSSL_API_LEVEL > OPENSSL_CONFIGURED_API -# error "The requested API level higher than the configured API compatibility level" +# error \ + "The requested API level higher than the configured API compatibility level" #endif /* * Check of sane values. */ /* Can't go higher than the current version. */ -#if OPENSSL_API_LEVEL > (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100) -# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" +#if OPENSSL_API_LEVEL \ + > (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100) +# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" #endif /* OpenSSL will have no version 2.y.z */ #if OPENSSL_API_LEVEL < 30000 && OPENSSL_API_LEVEL >= 20000 -# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" +# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" #endif /* Below 0.9.8 is unacceptably low */ #if OPENSSL_API_LEVEL < 908 -# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" +# error "OPENSSL_API_COMPAT expresses an impossible API compatibility level" #endif /* @@ -174,92 +180,92 @@ #undef OPENSSL_NO_DEPRECATED_0_9_8 #if OPENSSL_API_LEVEL >= 30200 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_3_2 OSSL_DEPRECATED(3.2) -# define OSSL_DEPRECATEDIN_3_2_FOR(msg) OSSL_DEPRECATED_FOR(3.2, msg) -# else -# define OPENSSL_NO_DEPRECATED_3_2 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_3_2 OSSL_DEPRECATED(3.2) +# define OSSL_DEPRECATEDIN_3_2_FOR(msg) OSSL_DEPRECATED_FOR(3.2, msg) +# else +# define OPENSSL_NO_DEPRECATED_3_2 +# endif #else -# define OSSL_DEPRECATEDIN_3_2 -# define OSSL_DEPRECATEDIN_3_2_FOR(msg) +# define OSSL_DEPRECATEDIN_3_2 +# define OSSL_DEPRECATEDIN_3_2_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 30000 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_3_0 OSSL_DEPRECATED(3.0) -# define OSSL_DEPRECATEDIN_3_0_FOR(msg) OSSL_DEPRECATED_FOR(3.0, msg) -# else -# define OPENSSL_NO_DEPRECATED_3_0 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_3_0 OSSL_DEPRECATED(3.0) +# define OSSL_DEPRECATEDIN_3_0_FOR(msg) OSSL_DEPRECATED_FOR(3.0, msg) +# else +# define OPENSSL_NO_DEPRECATED_3_0 +# endif #else -# define OSSL_DEPRECATEDIN_3_0 -# define OSSL_DEPRECATEDIN_3_0_FOR(msg) +# define OSSL_DEPRECATEDIN_3_0 +# define OSSL_DEPRECATEDIN_3_0_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 10101 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_1_1_1 OSSL_DEPRECATED(1.1.1) -# define OSSL_DEPRECATEDIN_1_1_1_FOR(msg) OSSL_DEPRECATED_FOR(1.1.1, msg) -# else -# define OPENSSL_NO_DEPRECATED_1_1_1 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_1_1 OSSL_DEPRECATED(1.1.1) +# define OSSL_DEPRECATEDIN_1_1_1_FOR(msg) OSSL_DEPRECATED_FOR(1.1.1, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_1_1 +# endif #else -# define OSSL_DEPRECATEDIN_1_1_1 -# define OSSL_DEPRECATEDIN_1_1_1_FOR(msg) +# define OSSL_DEPRECATEDIN_1_1_1 +# define OSSL_DEPRECATEDIN_1_1_1_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 10100 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_1_1_0 OSSL_DEPRECATED(1.1.0) -# define OSSL_DEPRECATEDIN_1_1_0_FOR(msg) OSSL_DEPRECATED_FOR(1.1.0, msg) -# else -# define OPENSSL_NO_DEPRECATED_1_1_0 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_1_0 OSSL_DEPRECATED(1.1.0) +# define OSSL_DEPRECATEDIN_1_1_0_FOR(msg) OSSL_DEPRECATED_FOR(1.1.0, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_1_0 +# endif #else -# define OSSL_DEPRECATEDIN_1_1_0 -# define OSSL_DEPRECATEDIN_1_1_0_FOR(msg) +# define OSSL_DEPRECATEDIN_1_1_0 +# define OSSL_DEPRECATEDIN_1_1_0_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 10002 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_1_0_2 OSSL_DEPRECATED(1.0.2) -# define OSSL_DEPRECATEDIN_1_0_2_FOR(msg) OSSL_DEPRECATED_FOR(1.0.2, msg) -# else -# define OPENSSL_NO_DEPRECATED_1_0_2 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_0_2 OSSL_DEPRECATED(1.0.2) +# define OSSL_DEPRECATEDIN_1_0_2_FOR(msg) OSSL_DEPRECATED_FOR(1.0.2, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_0_2 +# endif #else -# define OSSL_DEPRECATEDIN_1_0_2 -# define OSSL_DEPRECATEDIN_1_0_2_FOR(msg) +# define OSSL_DEPRECATEDIN_1_0_2 +# define OSSL_DEPRECATEDIN_1_0_2_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 10001 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_1_0_1 OSSL_DEPRECATED(1.0.1) -# define OSSL_DEPRECATEDIN_1_0_1_FOR(msg) OSSL_DEPRECATED_FOR(1.0.1, msg) -# else -# define OPENSSL_NO_DEPRECATED_1_0_1 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_0_1 OSSL_DEPRECATED(1.0.1) +# define OSSL_DEPRECATEDIN_1_0_1_FOR(msg) OSSL_DEPRECATED_FOR(1.0.1, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_0_1 +# endif #else -# define OSSL_DEPRECATEDIN_1_0_1 -# define OSSL_DEPRECATEDIN_1_0_1_FOR(msg) +# define OSSL_DEPRECATEDIN_1_0_1 +# define OSSL_DEPRECATEDIN_1_0_1_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 10000 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_1_0_0 OSSL_DEPRECATED(1.0.0) -# define OSSL_DEPRECATEDIN_1_0_0_FOR(msg) OSSL_DEPRECATED_FOR(1.0.0, msg) -# else -# define OPENSSL_NO_DEPRECATED_1_0_0 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_1_0_0 OSSL_DEPRECATED(1.0.0) +# define OSSL_DEPRECATEDIN_1_0_0_FOR(msg) OSSL_DEPRECATED_FOR(1.0.0, msg) +# else +# define OPENSSL_NO_DEPRECATED_1_0_0 +# endif #else -# define OSSL_DEPRECATEDIN_1_0_0 -# define OSSL_DEPRECATEDIN_1_0_0_FOR(msg) +# define OSSL_DEPRECATEDIN_1_0_0 +# define OSSL_DEPRECATEDIN_1_0_0_FOR(msg) #endif #if OPENSSL_API_LEVEL >= 908 -# ifndef OPENSSL_NO_DEPRECATED -# define OSSL_DEPRECATEDIN_0_9_8 OSSL_DEPRECATED(0.9.8) -# define OSSL_DEPRECATEDIN_0_9_8_FOR(msg) OSSL_DEPRECATED_FOR(0.9.8, msg) -# else -# define OPENSSL_NO_DEPRECATED_0_9_8 -# endif +# ifndef OPENSSL_NO_DEPRECATED +# define OSSL_DEPRECATEDIN_0_9_8 OSSL_DEPRECATED(0.9.8) +# define OSSL_DEPRECATEDIN_0_9_8_FOR(msg) OSSL_DEPRECATED_FOR(0.9.8, msg) +# else +# define OPENSSL_NO_DEPRECATED_0_9_8 +# endif #else -# define OSSL_DEPRECATEDIN_0_9_8 -# define OSSL_DEPRECATEDIN_0_9_8_FOR(msg) +# define OSSL_DEPRECATEDIN_0_9_8 +# define OSSL_DEPRECATEDIN_0_9_8_FOR(msg) #endif /* @@ -267,13 +273,13 @@ */ #ifndef OPENSSL_FILE -# ifdef OPENSSL_NO_FILENAMES -# define OPENSSL_FILE "" -# define OPENSSL_LINE 0 -# else -# define OPENSSL_FILE __FILE__ -# define OPENSSL_LINE __LINE__ -# endif +# ifdef OPENSSL_NO_FILENAMES +# define OPENSSL_FILE "" +# define OPENSSL_LINE 0 +# else +# define OPENSSL_FILE __FILE__ +# define OPENSSL_LINE __LINE__ +# endif #endif /* @@ -290,32 +296,32 @@ * and use __FUNCTION__ if that's the case. */ #ifndef OPENSSL_FUNC -# if defined(__STDC_VERSION__) -# if __STDC_VERSION__ >= 199901L -# define OPENSSL_FUNC __func__ -# elif defined(__GNUC__) && __GNUC__ >= 2 -# define OPENSSL_FUNC __FUNCTION__ -# endif -# elif defined(_MSC_VER) -# define OPENSSL_FUNC __FUNCTION__ +# if defined(__STDC_VERSION__) +# if __STDC_VERSION__ >= 199901L +# define OPENSSL_FUNC __func__ +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define OPENSSL_FUNC __FUNCTION__ # endif +# elif defined(_MSC_VER) +# define OPENSSL_FUNC __FUNCTION__ +# endif /* * If all these possibilities are exhausted, we give up and use a * static string. */ -# ifndef OPENSSL_FUNC -# define OPENSSL_FUNC "(unknown function)" -# endif +# ifndef OPENSSL_FUNC +# define OPENSSL_FUNC "(unknown function)" +# endif #endif #ifndef OSSL_CRYPTO_ALLOC -# if defined(__GNUC__) -# define OSSL_CRYPTO_ALLOC __attribute__((malloc)) -# elif defined(_MSC_VER) -# define OSSL_CRYPTO_ALLOC __declspec(restrict) -# else -# define OSSL_CRYPTO_ALLOC -# endif +# if defined(__GNUC__) +# define OSSL_CRYPTO_ALLOC __attribute__((malloc)) +# elif defined(_MSC_VER) +# define OSSL_CRYPTO_ALLOC __declspec(restrict) +# else +# define OSSL_CRYPTO_ALLOC +# endif #endif #endif /* OPENSSL_MACROS_H */ diff --git a/libs/OpenSSL/include/openssl/md2.h b/libs/OpenSSL/include/openssl/md2.h index d0a4a36a..a6e5c95a 100644 --- a/libs/OpenSSL/include/openssl/md2.h +++ b/libs/OpenSSL/include/openssl/md2.h @@ -13,43 +13,45 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_MD2_H +# define HEADER_MD2_H #endif #include #ifndef OPENSSL_NO_MD2 -# include -# ifdef __cplusplus +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define MD2_DIGEST_LENGTH 16 +# define MD2_DIGEST_LENGTH 16 -# if !defined(OPENSSL_NO_DEPRECATED_3_0) +# if !defined(OPENSSL_NO_DEPRECATED_3_0) typedef unsigned char MD2_INT; -# define MD2_BLOCK 16 +# define MD2_BLOCK 16 typedef struct MD2state_st { - unsigned int num; - unsigned char data[MD2_BLOCK]; - MD2_INT cksm[MD2_BLOCK]; - MD2_INT state[MD2_BLOCK]; + unsigned int num; + unsigned char data[MD2_BLOCK]; + MD2_INT cksm[MD2_BLOCK]; + MD2_INT state[MD2_BLOCK]; } MD2_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 const char *MD2_options(void); OSSL_DEPRECATEDIN_3_0 int MD2_Init(MD2_CTX *c); -OSSL_DEPRECATEDIN_3_0 int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int MD2_Update(MD2_CTX *c, const unsigned char *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int MD2_Final(unsigned char *md, MD2_CTX *c); -OSSL_DEPRECATEDIN_3_0 unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md); -# endif +OSSL_DEPRECATEDIN_3_0 unsigned char *MD2(const unsigned char *d, size_t n, + unsigned char *md); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/md4.h b/libs/OpenSSL/include/openssl/md4.h index 869c7334..f847c51a 100644 --- a/libs/OpenSSL/include/openssl/md4.h +++ b/libs/OpenSSL/include/openssl/md4.h @@ -13,51 +13,52 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_MD4_H +# define HEADER_MD4_H #endif #include #ifndef OPENSSL_NO_MD4 -# include -# include -# ifdef __cplusplus +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define MD4_DIGEST_LENGTH 16 +# define MD4_DIGEST_LENGTH 16 -# if !defined(OPENSSL_NO_DEPRECATED_3_0) +# if !defined(OPENSSL_NO_DEPRECATED_3_0) /*- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * ! MD4_LONG has to be at least 32 bits wide. ! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -# define MD4_LONG unsigned int +# define MD4_LONG unsigned int -# define MD4_CBLOCK 64 -# define MD4_LBLOCK (MD4_CBLOCK / 4) +# define MD4_CBLOCK 64 +# define MD4_LBLOCK (MD4_CBLOCK / 4) typedef struct MD4state_st { - MD4_LONG A, B, C, D; - MD4_LONG Nl, Nh; - MD4_LONG data[MD4_LBLOCK]; - unsigned int num; + MD4_LONG A, B, C, D; + MD4_LONG Nl, Nh; + MD4_LONG data[MD4_LBLOCK]; + unsigned int num; } MD4_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int MD4_Init(MD4_CTX *c); OSSL_DEPRECATEDIN_3_0 int MD4_Update(MD4_CTX *c, const void *data, size_t len); OSSL_DEPRECATEDIN_3_0 int MD4_Final(unsigned char *md, MD4_CTX *c); -OSSL_DEPRECATEDIN_3_0 unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); +OSSL_DEPRECATEDIN_3_0 unsigned char *MD4(const unsigned char *d, size_t n, + unsigned char *md); OSSL_DEPRECATEDIN_3_0 void MD4_Transform(MD4_CTX *c, const unsigned char *b); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/md5.h b/libs/OpenSSL/include/openssl/md5.h index 64e9cb62..c5b82b34 100644 --- a/libs/OpenSSL/include/openssl/md5.h +++ b/libs/OpenSSL/include/openssl/md5.h @@ -13,50 +13,51 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_MD5_H +# define HEADER_MD5_H #endif #include #ifndef OPENSSL_NO_MD5 -# include -# include -# ifdef __cplusplus +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define MD5_DIGEST_LENGTH 16 +# define MD5_DIGEST_LENGTH 16 -# if !defined(OPENSSL_NO_DEPRECATED_3_0) +# if !defined(OPENSSL_NO_DEPRECATED_3_0) /* * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * ! MD5_LONG has to be at least 32 bits wide. ! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -# define MD5_LONG unsigned int +# define MD5_LONG unsigned int -# define MD5_CBLOCK 64 -# define MD5_LBLOCK (MD5_CBLOCK / 4) +# define MD5_CBLOCK 64 +# define MD5_LBLOCK (MD5_CBLOCK / 4) typedef struct MD5state_st { - MD5_LONG A, B, C, D; - MD5_LONG Nl, Nh; - MD5_LONG data[MD5_LBLOCK]; - unsigned int num; + MD5_LONG A, B, C, D; + MD5_LONG Nl, Nh; + MD5_LONG data[MD5_LBLOCK]; + unsigned int num; } MD5_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c); OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len); OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c); -OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); +OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n, + unsigned char *md); OSSL_DEPRECATEDIN_3_0 void MD5_Transform(MD5_CTX *c, const unsigned char *b); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/mdc2.h b/libs/OpenSSL/include/openssl/mdc2.h index f2ddcb31..490966e7 100644 --- a/libs/OpenSSL/include/openssl/mdc2.h +++ b/libs/OpenSSL/include/openssl/mdc2.h @@ -13,42 +13,44 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_MDC2_H +# define HEADER_MDC2_H #endif #include #ifndef OPENSSL_NO_MDC2 -# include -# include -# ifdef __cplusplus +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define MDC2_DIGEST_LENGTH 16 +# define MDC2_DIGEST_LENGTH 16 -# if !defined(OPENSSL_NO_DEPRECATED_3_0) +# if !defined(OPENSSL_NO_DEPRECATED_3_0) -# define MDC2_BLOCK 8 +# define MDC2_BLOCK 8 typedef struct mdc2_ctx_st { - unsigned int num; - unsigned char data[MDC2_BLOCK]; - DES_cblock h, hh; - unsigned int pad_type; /* either 1 or 2, default 1 */ + unsigned int num; + unsigned char data[MDC2_BLOCK]; + DES_cblock h, hh; + unsigned int pad_type; /* either 1 or 2, default 1 */ } MDC2_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int MDC2_Init(MDC2_CTX *c); -OSSL_DEPRECATEDIN_3_0 int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int MDC2_Update(MDC2_CTX *c, const unsigned char *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int MDC2_Final(unsigned char *md, MDC2_CTX *c); -OSSL_DEPRECATEDIN_3_0 unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); -# endif +OSSL_DEPRECATEDIN_3_0 unsigned char *MDC2(const unsigned char *d, size_t n, + unsigned char *md); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/modes.h b/libs/OpenSSL/include/openssl/modes.h index a9df2452..fe362e1a 100644 --- a/libs/OpenSSL/include/openssl/modes.h +++ b/libs/OpenSSL/include/openssl/modes.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_MODES_H +# define HEADER_MODES_H #endif #include @@ -22,131 +22,174 @@ #ifdef __cplusplus extern "C" { #endif -typedef void (*block128_f)(const unsigned char in[16], unsigned char out[16], const void *key); +typedef void (*block128_f)(const unsigned char in[16], unsigned char out[16], + const void *key); -typedef void (*cbc128_f)(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], int enc); - -typedef void (*ecb128_f)(const unsigned char *in, unsigned char *out, size_t len, const void *key, +typedef void (*cbc128_f)(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], int enc); -typedef void (*ctr128_f)(const unsigned char *in, unsigned char *out, size_t blocks, - const void *key, const unsigned char ivec[16]); +typedef void (*ecb128_f)(const unsigned char *in, unsigned char *out, + size_t len, const void *key, int enc); -typedef void (*ccm128_f)(const unsigned char *in, unsigned char *out, size_t blocks, - const void *key, const unsigned char ivec[16], unsigned char cmac[16]); +typedef void (*ctr128_f)(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char ivec[16]); -void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], block128_f block); -void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], block128_f block); +typedef void (*ccm128_f)(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, + const unsigned char ivec[16], unsigned char cmac[16]); -void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], unsigned char ecount_buf[16], unsigned int *num, +void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + block128_f block); +void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], block128_f block); -void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], - unsigned char ecount_buf[16], unsigned int *num, ctr128_f ctr); +void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + unsigned char ecount_buf[16], unsigned int *num, + block128_f block); -void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], int *num, block128_f block); +void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], + unsigned char ecount_buf[16], + unsigned int *num, ctr128_f ctr); -void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, const void *key, - unsigned char ivec[16], int *num, int enc, block128_f block); -void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, size_t length, - const void *key, unsigned char ivec[16], int *num, int enc, +void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + int *num, block128_f block); + +void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, unsigned char ivec[16], + int *num, int enc, block128_f block); +void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, + size_t length, const void *key, + unsigned char ivec[16], int *num, int enc, block128_f block); -void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, size_t bits, - const void *key, unsigned char ivec[16], int *num, int enc, +void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, + size_t bits, const void *key, + unsigned char ivec[16], int *num, int enc, block128_f block); -size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], block128_f block); -size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], block128_f block); -size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], cbc128_f cbc); +size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], block128_f block); +size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); +size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], block128_f block); +size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], block128_f block); -size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], block128_f block); -size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], cbc128_f cbc); +size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, + unsigned char *out, size_t len, + const void *key, unsigned char ivec[16], + block128_f block); +size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); +size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, + unsigned char *out, size_t len, + const void *key, unsigned char ivec[16], + block128_f block); +size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, + size_t len, const void *key, + unsigned char ivec[16], cbc128_f cbc); typedef struct gcm128_context GCM128_CONTEXT; GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block); void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block); -void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, size_t len); -int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, size_t len); -int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len, ctr128_f stream); -int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len, ctr128_f stream); -int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, size_t len); +void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, + size_t len); +int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, + size_t len); +int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len, + ctr128_f stream); +int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len, + ctr128_f stream); +int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, + size_t len); void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len); void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); typedef struct ccm128_context CCM128_CONTEXT; -void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, unsigned int M, unsigned int L, void *key, - block128_f block); -int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce, size_t nlen, size_t mlen); -void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad, size_t alen); -int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, - size_t len); -int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, - size_t len); -int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, - size_t len, ccm128_f stream); -int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, unsigned char *out, - size_t len, ccm128_f stream); +void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, unsigned int M, unsigned int L, + void *key, block128_f block); +int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce, + size_t nlen, size_t mlen); +void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad, + size_t alen); +int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len); +int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len); +int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len, + ccm128_f stream); +int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, + unsigned char *out, size_t len, + ccm128_f stream); size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len); typedef struct xts128_context XTS128_CONTEXT; int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, const unsigned char iv[16], - const unsigned char *inp, unsigned char *out, size_t len, int enc); + const unsigned char *inp, unsigned char *out, + size_t len, int enc); size_t CRYPTO_128_wrap(void *key, const unsigned char *iv, unsigned char *out, const unsigned char *in, size_t inlen, block128_f block); size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv, unsigned char *out, - const unsigned char *in, size_t inlen, block128_f block); -size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv, unsigned char *out, - const unsigned char *in, size_t inlen, block128_f block); -size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv, unsigned char *out, - const unsigned char *in, size_t inlen, block128_f block); + const unsigned char *in, size_t inlen, + block128_f block); +size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv, + unsigned char *out, const unsigned char *in, + size_t inlen, block128_f block); +size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv, + unsigned char *out, const unsigned char *in, + size_t inlen, block128_f block); #ifndef OPENSSL_NO_OCB typedef struct ocb128_context OCB128_CONTEXT; -typedef void (*ocb128_f)(const unsigned char *in, unsigned char *out, size_t blocks, - const void *key, size_t start_block_num, unsigned char offset_i[16], - const unsigned char L_[][16], unsigned char checksum[16]); +typedef void (*ocb128_f)(const unsigned char *in, unsigned char *out, + size_t blocks, const void *key, size_t start_block_num, + unsigned char offset_i[16], + const unsigned char L_[][16], + unsigned char checksum[16]); -OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, block128_f encrypt, - block128_f decrypt, ocb128_f stream); -int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec, block128_f encrypt, - block128_f decrypt, ocb128_f stream); -int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src, void *keyenc, void *keydec); -int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv, size_t len, size_t taglen); -int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad, size_t len); -int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag, size_t len); +OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, + block128_f encrypt, block128_f decrypt, + ocb128_f stream); +int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec, + block128_f encrypt, block128_f decrypt, ocb128_f stream); +int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src, + void *keyenc, void *keydec); +int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv, + size_t len, size_t taglen); +int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad, + size_t len); +int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in, + unsigned char *out, size_t len); +int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag, + size_t len); int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len); void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx); #endif /* OPENSSL_NO_OCB */ diff --git a/libs/OpenSSL/include/openssl/obj_mac.h b/libs/OpenSSL/include/openssl/obj_mac.h index 73ead805..6bd412b2 100644 --- a/libs/OpenSSL/include/openssl/obj_mac.h +++ b/libs/OpenSSL/include/openssl/obj_mac.h @@ -158,7 +158,8 @@ #define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" #define NID_X9_62_id_characteristic_two_basis 680 -#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field, 3L +#define OBJ_X9_62_id_characteristic_two_basis \ + OBJ_X9_62_characteristic_two_field, 3L #define SN_X9_62_onBasis "onBasis" #define NID_X9_62_onBasis 681 @@ -1737,9 +1738,10 @@ #define NID_id_kp_bgpsec_router 1220 #define OBJ_id_kp_bgpsec_router OBJ_id_kp, 30L -#define SN_id_kp_BrandIndicatorforMessageIdentification \ - "id-kp-BrandIndicatorforMessageIdentification" -#define LN_id_kp_BrandIndicatorforMessageIdentification "Brand Indicator for Message Identification" +#define SN_id_kp_BrandIndicatorforMessageIdentification \ + "id-kp-BrandIndicatorforMessageIdentification" +#define LN_id_kp_BrandIndicatorforMessageIdentification \ + "Brand Indicator for Message Identification" #define NID_id_kp_BrandIndicatorforMessageIdentification 1221 #define OBJ_id_kp_BrandIndicatorforMessageIdentification OBJ_id_kp, 31L @@ -4217,13 +4219,16 @@ #define NID_id_tc26 974 #define OBJ_id_tc26 OBJ_member_body, 643L, 7L, 1L -#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001" -#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001" +#define SN_id_GostR3411_94_with_GostR3410_2001 \ + "id-GostR3411-94-with-GostR3410-2001" +#define LN_id_GostR3411_94_with_GostR3410_2001 \ + "GOST R 34.11-94 with GOST R 34.10-2001" #define NID_id_GostR3411_94_with_GostR3410_2001 807 #define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro, 3L #define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94" -#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94" +#define LN_id_GostR3411_94_with_GostR3410_94 \ + "GOST R 34.11-94 with GOST R 34.10-94" #define NID_id_GostR3411_94_with_GostR3410_94 808 #define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro, 4L @@ -4290,7 +4295,8 @@ #define NID_id_GostR3410_94DH 818 #define OBJ_id_GostR3410_94DH OBJ_cryptopro, 99L -#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing" +#define SN_id_Gost28147_89_CryptoPro_KeyMeshing \ + "id-Gost28147-89-CryptoPro-KeyMeshing" #define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819 #define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro, 14L, 1L @@ -4310,33 +4316,38 @@ #define NID_id_Gost28147_89_TestParamSet 823 #define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro, 31L, 0L -#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_A_ParamSet \ + "id-Gost28147-89-CryptoPro-A-ParamSet" #define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824 #define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro, 31L, 1L -#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_B_ParamSet \ + "id-Gost28147-89-CryptoPro-B-ParamSet" #define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825 #define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro, 31L, 2L -#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_C_ParamSet \ + "id-Gost28147-89-CryptoPro-C-ParamSet" #define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826 #define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro, 31L, 3L -#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_D_ParamSet \ + "id-Gost28147-89-CryptoPro-D-ParamSet" #define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827 #define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro, 31L, 4L -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet \ - "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet \ + "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" #define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828 #define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro, 31L, 5L -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet \ - "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet \ + "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" #define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829 #define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro, 31L, 6L -#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" +#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet \ + "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" #define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830 #define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro, 31L, 7L @@ -4344,31 +4355,38 @@ #define NID_id_GostR3410_94_TestParamSet 831 #define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro, 32L, 0L -#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_A_ParamSet \ + "id-GostR3410-94-CryptoPro-A-ParamSet" #define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832 #define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro, 32L, 2L -#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_B_ParamSet \ + "id-GostR3410-94-CryptoPro-B-ParamSet" #define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833 #define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro, 32L, 3L -#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_C_ParamSet \ + "id-GostR3410-94-CryptoPro-C-ParamSet" #define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834 #define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro, 32L, 4L -#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_D_ParamSet \ + "id-GostR3410-94-CryptoPro-D-ParamSet" #define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835 #define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro, 32L, 5L -#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet \ + "id-GostR3410-94-CryptoPro-XchA-ParamSet" #define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836 #define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro, 33L, 1L -#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet \ + "id-GostR3410-94-CryptoPro-XchB-ParamSet" #define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837 #define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro, 33L, 2L -#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet" +#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet \ + "id-GostR3410-94-CryptoPro-XchC-ParamSet" #define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838 #define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro, 33L, 3L @@ -4376,23 +4394,28 @@ #define NID_id_GostR3410_2001_TestParamSet 839 #define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro, 35L, 0L -#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet" +#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet \ + "id-GostR3410-2001-CryptoPro-A-ParamSet" #define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840 #define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro, 35L, 1L -#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet" +#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet \ + "id-GostR3410-2001-CryptoPro-B-ParamSet" #define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841 #define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro, 35L, 2L -#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet" +#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet \ + "id-GostR3410-2001-CryptoPro-C-ParamSet" #define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842 #define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro, 35L, 3L -#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet" +#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet \ + "id-GostR3410-2001-CryptoPro-XchA-ParamSet" #define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843 #define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro, 36L, 0L -#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet" +#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet \ + "id-GostR3410-2001-CryptoPro-XchB-ParamSet" #define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844 #define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro, 36L, 1L @@ -4427,18 +4450,23 @@ #define NID_id_GostR3410_2001_cc 851 #define OBJ_id_GostR3410_2001_cc OBJ_cryptocom, 1L, 5L, 4L -#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc" -#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" +#define SN_id_GostR3411_94_with_GostR3410_94_cc \ + "id-GostR3411-94-with-GostR3410-94-cc" +#define LN_id_GostR3411_94_with_GostR3410_94_cc \ + "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" #define NID_id_GostR3411_94_with_GostR3410_94_cc 852 #define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom, 1L, 3L, 3L -#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc" -#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" +#define SN_id_GostR3411_94_with_GostR3410_2001_cc \ + "id-GostR3411-94-with-GostR3410-2001-cc" +#define LN_id_GostR3411_94_with_GostR3410_2001_cc \ + "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" #define NID_id_GostR3411_94_with_GostR3410_2001_cc 853 #define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom, 1L, 3L, 4L #define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc" -#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom" +#define LN_id_GostR3410_2001_ParamSet_cc \ + "GOST R 3410-2001 Parameter Set Cryptocom" #define NID_id_GostR3410_2001_ParamSet_cc 854 #define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom, 1L, 8L, 1L @@ -4478,17 +4506,21 @@ #define NID_id_tc26_signwithdigest 984 #define OBJ_id_tc26_signwithdigest OBJ_id_tc26_algorithms, 3L -#define SN_id_tc26_signwithdigest_gost3410_2012_256 "id-tc26-signwithdigest-gost3410-2012-256" -#define LN_id_tc26_signwithdigest_gost3410_2012_256 \ - "GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)" +#define SN_id_tc26_signwithdigest_gost3410_2012_256 \ + "id-tc26-signwithdigest-gost3410-2012-256" +#define LN_id_tc26_signwithdigest_gost3410_2012_256 \ + "GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)" #define NID_id_tc26_signwithdigest_gost3410_2012_256 985 -#define OBJ_id_tc26_signwithdigest_gost3410_2012_256 OBJ_id_tc26_signwithdigest, 2L +#define OBJ_id_tc26_signwithdigest_gost3410_2012_256 \ + OBJ_id_tc26_signwithdigest, 2L -#define SN_id_tc26_signwithdigest_gost3410_2012_512 "id-tc26-signwithdigest-gost3410-2012-512" -#define LN_id_tc26_signwithdigest_gost3410_2012_512 \ - "GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)" +#define SN_id_tc26_signwithdigest_gost3410_2012_512 \ + "id-tc26-signwithdigest-gost3410-2012-512" +#define LN_id_tc26_signwithdigest_gost3410_2012_512 \ + "GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)" #define NID_id_tc26_signwithdigest_gost3410_2012_512 986 -#define OBJ_id_tc26_signwithdigest_gost3410_2012_512 OBJ_id_tc26_signwithdigest, 3L +#define OBJ_id_tc26_signwithdigest_gost3410_2012_512 \ + OBJ_id_tc26_signwithdigest, 3L #define SN_id_tc26_mac "id-tc26-mac" #define NID_id_tc26_mac 987 @@ -4508,7 +4540,8 @@ #define NID_id_tc26_cipher 990 #define OBJ_id_tc26_cipher OBJ_id_tc26_algorithms, 5L -#define SN_id_tc26_cipher_gostr3412_2015_magma "id-tc26-cipher-gostr3412-2015-magma" +#define SN_id_tc26_cipher_gostr3412_2015_magma \ + "id-tc26-cipher-gostr3412-2015-magma" #define NID_id_tc26_cipher_gostr3412_2015_magma 1173 #define OBJ_id_tc26_cipher_gostr3412_2015_magma OBJ_id_tc26_cipher, 1L @@ -4520,27 +4553,32 @@ #define NID_magma_ctr_acpkm_omac 1175 #define OBJ_magma_ctr_acpkm_omac OBJ_id_tc26_cipher_gostr3412_2015_magma, 2L -#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik "id-tc26-cipher-gostr3412-2015-kuznyechik" +#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik \ + "id-tc26-cipher-gostr3412-2015-kuznyechik" #define NID_id_tc26_cipher_gostr3412_2015_kuznyechik 1176 #define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik OBJ_id_tc26_cipher, 2L #define SN_kuznyechik_ctr_acpkm "kuznyechik-ctr-acpkm" #define NID_kuznyechik_ctr_acpkm 1177 -#define OBJ_kuznyechik_ctr_acpkm OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik, 1L +#define OBJ_kuznyechik_ctr_acpkm \ + OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik, 1L #define SN_kuznyechik_ctr_acpkm_omac "kuznyechik-ctr-acpkm-omac" #define NID_kuznyechik_ctr_acpkm_omac 1178 -#define OBJ_kuznyechik_ctr_acpkm_omac OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik, 2L +#define OBJ_kuznyechik_ctr_acpkm_omac \ + OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik, 2L #define SN_id_tc26_agreement "id-tc26-agreement" #define NID_id_tc26_agreement 991 #define OBJ_id_tc26_agreement OBJ_id_tc26_algorithms, 6L -#define SN_id_tc26_agreement_gost_3410_2012_256 "id-tc26-agreement-gost-3410-2012-256" +#define SN_id_tc26_agreement_gost_3410_2012_256 \ + "id-tc26-agreement-gost-3410-2012-256" #define NID_id_tc26_agreement_gost_3410_2012_256 992 #define OBJ_id_tc26_agreement_gost_3410_2012_256 OBJ_id_tc26_agreement, 1L -#define SN_id_tc26_agreement_gost_3410_2012_512 "id-tc26-agreement-gost-3410-2012-512" +#define SN_id_tc26_agreement_gost_3410_2012_512 \ + "id-tc26-agreement-gost-3410-2012-512" #define NID_id_tc26_agreement_gost_3410_2012_512 993 #define OBJ_id_tc26_agreement_gost_3410_2012_512 OBJ_id_tc26_agreement, 2L @@ -4556,7 +4594,8 @@ #define NID_magma_kexp15 1181 #define OBJ_magma_kexp15 OBJ_id_tc26_wrap_gostr3412_2015_magma, 1L -#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik "id-tc26-wrap-gostr3412-2015-kuznyechik" +#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik \ + "id-tc26-wrap-gostr3412-2015-kuznyechik" #define NID_id_tc26_wrap_gostr3412_2015_kuznyechik 1182 #define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik OBJ_id_tc26_wrap, 2L @@ -4572,54 +4611,79 @@ #define NID_id_tc26_sign_constants 995 #define OBJ_id_tc26_sign_constants OBJ_id_tc26_constants, 1L -#define SN_id_tc26_gost_3410_2012_256_constants "id-tc26-gost-3410-2012-256-constants" +#define SN_id_tc26_gost_3410_2012_256_constants \ + "id-tc26-gost-3410-2012-256-constants" #define NID_id_tc26_gost_3410_2012_256_constants 1147 #define OBJ_id_tc26_gost_3410_2012_256_constants OBJ_id_tc26_sign_constants, 1L -#define SN_id_tc26_gost_3410_2012_256_paramSetA "id-tc26-gost-3410-2012-256-paramSetA" -#define LN_id_tc26_gost_3410_2012_256_paramSetA "GOST R 34.10-2012 (256 bit) ParamSet A" +#define SN_id_tc26_gost_3410_2012_256_paramSetA \ + "id-tc26-gost-3410-2012-256-paramSetA" +#define LN_id_tc26_gost_3410_2012_256_paramSetA \ + "GOST R 34.10-2012 (256 bit) ParamSet A" #define NID_id_tc26_gost_3410_2012_256_paramSetA 1148 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetA OBJ_id_tc26_gost_3410_2012_256_constants, 1L +#define OBJ_id_tc26_gost_3410_2012_256_paramSetA \ + OBJ_id_tc26_gost_3410_2012_256_constants, 1L -#define SN_id_tc26_gost_3410_2012_256_paramSetB "id-tc26-gost-3410-2012-256-paramSetB" -#define LN_id_tc26_gost_3410_2012_256_paramSetB "GOST R 34.10-2012 (256 bit) ParamSet B" +#define SN_id_tc26_gost_3410_2012_256_paramSetB \ + "id-tc26-gost-3410-2012-256-paramSetB" +#define LN_id_tc26_gost_3410_2012_256_paramSetB \ + "GOST R 34.10-2012 (256 bit) ParamSet B" #define NID_id_tc26_gost_3410_2012_256_paramSetB 1184 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetB OBJ_id_tc26_gost_3410_2012_256_constants, 2L +#define OBJ_id_tc26_gost_3410_2012_256_paramSetB \ + OBJ_id_tc26_gost_3410_2012_256_constants, 2L -#define SN_id_tc26_gost_3410_2012_256_paramSetC "id-tc26-gost-3410-2012-256-paramSetC" -#define LN_id_tc26_gost_3410_2012_256_paramSetC "GOST R 34.10-2012 (256 bit) ParamSet C" +#define SN_id_tc26_gost_3410_2012_256_paramSetC \ + "id-tc26-gost-3410-2012-256-paramSetC" +#define LN_id_tc26_gost_3410_2012_256_paramSetC \ + "GOST R 34.10-2012 (256 bit) ParamSet C" #define NID_id_tc26_gost_3410_2012_256_paramSetC 1185 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetC OBJ_id_tc26_gost_3410_2012_256_constants, 3L +#define OBJ_id_tc26_gost_3410_2012_256_paramSetC \ + OBJ_id_tc26_gost_3410_2012_256_constants, 3L -#define SN_id_tc26_gost_3410_2012_256_paramSetD "id-tc26-gost-3410-2012-256-paramSetD" -#define LN_id_tc26_gost_3410_2012_256_paramSetD "GOST R 34.10-2012 (256 bit) ParamSet D" +#define SN_id_tc26_gost_3410_2012_256_paramSetD \ + "id-tc26-gost-3410-2012-256-paramSetD" +#define LN_id_tc26_gost_3410_2012_256_paramSetD \ + "GOST R 34.10-2012 (256 bit) ParamSet D" #define NID_id_tc26_gost_3410_2012_256_paramSetD 1186 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetD OBJ_id_tc26_gost_3410_2012_256_constants, 4L +#define OBJ_id_tc26_gost_3410_2012_256_paramSetD \ + OBJ_id_tc26_gost_3410_2012_256_constants, 4L -#define SN_id_tc26_gost_3410_2012_512_constants "id-tc26-gost-3410-2012-512-constants" +#define SN_id_tc26_gost_3410_2012_512_constants \ + "id-tc26-gost-3410-2012-512-constants" #define NID_id_tc26_gost_3410_2012_512_constants 996 #define OBJ_id_tc26_gost_3410_2012_512_constants OBJ_id_tc26_sign_constants, 2L -#define SN_id_tc26_gost_3410_2012_512_paramSetTest "id-tc26-gost-3410-2012-512-paramSetTest" -#define LN_id_tc26_gost_3410_2012_512_paramSetTest \ - "GOST R 34.10-2012 (512 bit) testing parameter set" +#define SN_id_tc26_gost_3410_2012_512_paramSetTest \ + "id-tc26-gost-3410-2012-512-paramSetTest" +#define LN_id_tc26_gost_3410_2012_512_paramSetTest \ + "GOST R 34.10-2012 (512 bit) testing parameter set" #define NID_id_tc26_gost_3410_2012_512_paramSetTest 997 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest OBJ_id_tc26_gost_3410_2012_512_constants, 0L +#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest \ + OBJ_id_tc26_gost_3410_2012_512_constants, 0L -#define SN_id_tc26_gost_3410_2012_512_paramSetA "id-tc26-gost-3410-2012-512-paramSetA" -#define LN_id_tc26_gost_3410_2012_512_paramSetA "GOST R 34.10-2012 (512 bit) ParamSet A" +#define SN_id_tc26_gost_3410_2012_512_paramSetA \ + "id-tc26-gost-3410-2012-512-paramSetA" +#define LN_id_tc26_gost_3410_2012_512_paramSetA \ + "GOST R 34.10-2012 (512 bit) ParamSet A" #define NID_id_tc26_gost_3410_2012_512_paramSetA 998 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetA OBJ_id_tc26_gost_3410_2012_512_constants, 1L +#define OBJ_id_tc26_gost_3410_2012_512_paramSetA \ + OBJ_id_tc26_gost_3410_2012_512_constants, 1L -#define SN_id_tc26_gost_3410_2012_512_paramSetB "id-tc26-gost-3410-2012-512-paramSetB" -#define LN_id_tc26_gost_3410_2012_512_paramSetB "GOST R 34.10-2012 (512 bit) ParamSet B" +#define SN_id_tc26_gost_3410_2012_512_paramSetB \ + "id-tc26-gost-3410-2012-512-paramSetB" +#define LN_id_tc26_gost_3410_2012_512_paramSetB \ + "GOST R 34.10-2012 (512 bit) ParamSet B" #define NID_id_tc26_gost_3410_2012_512_paramSetB 999 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetB OBJ_id_tc26_gost_3410_2012_512_constants, 2L +#define OBJ_id_tc26_gost_3410_2012_512_paramSetB \ + OBJ_id_tc26_gost_3410_2012_512_constants, 2L -#define SN_id_tc26_gost_3410_2012_512_paramSetC "id-tc26-gost-3410-2012-512-paramSetC" -#define LN_id_tc26_gost_3410_2012_512_paramSetC "GOST R 34.10-2012 (512 bit) ParamSet C" +#define SN_id_tc26_gost_3410_2012_512_paramSetC \ + "id-tc26-gost-3410-2012-512-paramSetC" +#define LN_id_tc26_gost_3410_2012_512_paramSetC \ + "GOST R 34.10-2012 (512 bit) ParamSet C" #define NID_id_tc26_gost_3410_2012_512_paramSetC 1149 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetC OBJ_id_tc26_gost_3410_2012_512_constants, 3L +#define OBJ_id_tc26_gost_3410_2012_512_paramSetC \ + OBJ_id_tc26_gost_3410_2012_512_constants, 3L #define SN_id_tc26_digest_constants "id-tc26-digest-constants" #define NID_id_tc26_digest_constants 1000 @@ -5227,39 +5291,48 @@ #define NID_dhSinglePass_stdDH_sha1kdf_scheme 936 #define OBJ_dhSinglePass_stdDH_sha1kdf_scheme OBJ_x9_63_scheme, 2L -#define SN_dhSinglePass_stdDH_sha224kdf_scheme "dhSinglePass-stdDH-sha224kdf-scheme" +#define SN_dhSinglePass_stdDH_sha224kdf_scheme \ + "dhSinglePass-stdDH-sha224kdf-scheme" #define NID_dhSinglePass_stdDH_sha224kdf_scheme 937 #define OBJ_dhSinglePass_stdDH_sha224kdf_scheme OBJ_secg_scheme, 11L, 0L -#define SN_dhSinglePass_stdDH_sha256kdf_scheme "dhSinglePass-stdDH-sha256kdf-scheme" +#define SN_dhSinglePass_stdDH_sha256kdf_scheme \ + "dhSinglePass-stdDH-sha256kdf-scheme" #define NID_dhSinglePass_stdDH_sha256kdf_scheme 938 #define OBJ_dhSinglePass_stdDH_sha256kdf_scheme OBJ_secg_scheme, 11L, 1L -#define SN_dhSinglePass_stdDH_sha384kdf_scheme "dhSinglePass-stdDH-sha384kdf-scheme" +#define SN_dhSinglePass_stdDH_sha384kdf_scheme \ + "dhSinglePass-stdDH-sha384kdf-scheme" #define NID_dhSinglePass_stdDH_sha384kdf_scheme 939 #define OBJ_dhSinglePass_stdDH_sha384kdf_scheme OBJ_secg_scheme, 11L, 2L -#define SN_dhSinglePass_stdDH_sha512kdf_scheme "dhSinglePass-stdDH-sha512kdf-scheme" +#define SN_dhSinglePass_stdDH_sha512kdf_scheme \ + "dhSinglePass-stdDH-sha512kdf-scheme" #define NID_dhSinglePass_stdDH_sha512kdf_scheme 940 #define OBJ_dhSinglePass_stdDH_sha512kdf_scheme OBJ_secg_scheme, 11L, 3L -#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme "dhSinglePass-cofactorDH-sha1kdf-scheme" +#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme \ + "dhSinglePass-cofactorDH-sha1kdf-scheme" #define NID_dhSinglePass_cofactorDH_sha1kdf_scheme 941 #define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme OBJ_x9_63_scheme, 3L -#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme "dhSinglePass-cofactorDH-sha224kdf-scheme" +#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme \ + "dhSinglePass-cofactorDH-sha224kdf-scheme" #define NID_dhSinglePass_cofactorDH_sha224kdf_scheme 942 #define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme OBJ_secg_scheme, 14L, 0L -#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme "dhSinglePass-cofactorDH-sha256kdf-scheme" +#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme \ + "dhSinglePass-cofactorDH-sha256kdf-scheme" #define NID_dhSinglePass_cofactorDH_sha256kdf_scheme 943 #define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme OBJ_secg_scheme, 14L, 1L -#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme "dhSinglePass-cofactorDH-sha384kdf-scheme" +#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme \ + "dhSinglePass-cofactorDH-sha384kdf-scheme" #define NID_dhSinglePass_cofactorDH_sha384kdf_scheme 944 #define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme OBJ_secg_scheme, 14L, 2L -#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme "dhSinglePass-cofactorDH-sha512kdf-scheme" +#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme \ + "dhSinglePass-cofactorDH-sha512kdf-scheme" #define NID_dhSinglePass_cofactorDH_sha512kdf_scheme 945 #define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme OBJ_secg_scheme, 14L, 3L @@ -5292,17 +5365,20 @@ #define SN_jurisdictionLocalityName "jurisdictionL" #define LN_jurisdictionLocalityName "jurisdictionLocalityName" #define NID_jurisdictionLocalityName 955 -#define OBJ_jurisdictionLocalityName 1L, 3L, 6L, 1L, 4L, 1L, 311L, 60L, 2L, 1L, 1L +#define OBJ_jurisdictionLocalityName \ + 1L, 3L, 6L, 1L, 4L, 1L, 311L, 60L, 2L, 1L, 1L #define SN_jurisdictionStateOrProvinceName "jurisdictionST" #define LN_jurisdictionStateOrProvinceName "jurisdictionStateOrProvinceName" #define NID_jurisdictionStateOrProvinceName 956 -#define OBJ_jurisdictionStateOrProvinceName 1L, 3L, 6L, 1L, 4L, 1L, 311L, 60L, 2L, 1L, 2L +#define OBJ_jurisdictionStateOrProvinceName \ + 1L, 3L, 6L, 1L, 4L, 1L, 311L, 60L, 2L, 1L, 2L #define SN_jurisdictionCountryName "jurisdictionC" #define LN_jurisdictionCountryName "jurisdictionCountryName" #define NID_jurisdictionCountryName 957 -#define OBJ_jurisdictionCountryName 1L, 3L, 6L, 1L, 4L, 1L, 311L, 60L, 2L, 1L, 3L +#define OBJ_jurisdictionCountryName \ + 1L, 3L, 6L, 1L, 4L, 1L, 311L, 60L, 2L, 1L, 3L #define SN_id_scrypt "id-scrypt" #define LN_id_scrypt "scrypt" @@ -5620,17 +5696,26 @@ #define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm NID_magma_ctr_acpkm #define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm OBJ_magma_ctr_acpkm -#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac SN_magma_ctr_acpkm_omac -#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac NID_magma_ctr_acpkm_omac -#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac OBJ_magma_ctr_acpkm_omac +#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac \ + SN_magma_ctr_acpkm_omac +#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac \ + NID_magma_ctr_acpkm_omac +#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac \ + OBJ_magma_ctr_acpkm_omac -#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm SN_kuznyechik_ctr_acpkm -#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm NID_kuznyechik_ctr_acpkm -#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm OBJ_kuznyechik_ctr_acpkm +#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm \ + SN_kuznyechik_ctr_acpkm +#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm \ + NID_kuznyechik_ctr_acpkm +#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm \ + OBJ_kuznyechik_ctr_acpkm -#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac SN_kuznyechik_ctr_acpkm_omac -#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac NID_kuznyechik_ctr_acpkm_omac -#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac OBJ_kuznyechik_ctr_acpkm_omac +#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac \ + SN_kuznyechik_ctr_acpkm_omac +#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac \ + NID_kuznyechik_ctr_acpkm_omac +#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac \ + OBJ_kuznyechik_ctr_acpkm_omac #define SN_id_tc26_wrap_gostr3412_2015_magma_kexp15 SN_magma_kexp15 #define NID_id_tc26_wrap_gostr3412_2015_magma_kexp15 NID_magma_kexp15 diff --git a/libs/OpenSSL/include/openssl/objects.h b/libs/OpenSSL/include/openssl/objects.h index 61fc6953..29236f77 100644 --- a/libs/OpenSSL/include/openssl/objects.h +++ b/libs/OpenSSL/include/openssl/objects.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_OBJECTS_H +# define HEADER_OBJECTS_H #endif #include @@ -41,10 +41,10 @@ extern "C" { typedef struct obj_name_st { - int type; - int alias; - const char *name; - const char *data; + int type; + int alias; + const char *name; + const char *data; } OBJ_NAME; #define OBJ_create_and_add_object(a, b, c) OBJ_create(a, b, c) @@ -57,10 +57,13 @@ const char *OBJ_NAME_get(const char *name, int type); int OBJ_NAME_add(const char *name, int type, const char *data); int OBJ_NAME_remove(const char *name, int type); void OBJ_NAME_cleanup(int type); /* -1 for everything */ -void OBJ_NAME_do_all(int type, void (*fn)(const OBJ_NAME *, void *arg), void *arg); -void OBJ_NAME_do_all_sorted(int type, void (*fn)(const OBJ_NAME *, void *arg), void *arg); +void OBJ_NAME_do_all(int type, void (*fn)(const OBJ_NAME *, void *arg), + void *arg); +void OBJ_NAME_do_all_sorted(int type, void (*fn)(const OBJ_NAME *, void *arg), + void *arg); -DECLARE_ASN1_DUP_FUNCTION_name(ASN1_OBJECT, OBJ) ASN1_OBJECT *OBJ_nid2obj(int n); +DECLARE_ASN1_DUP_FUNCTION_name(ASN1_OBJECT, + OBJ) ASN1_OBJECT *OBJ_nid2obj(int n); const char *OBJ_nid2ln(int n); const char *OBJ_nid2sn(int n); int OBJ_obj2nid(const ASN1_OBJECT *o); @@ -72,18 +75,19 @@ int OBJ_sn2nid(const char *s); int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); const void *OBJ_bsearch_(const void *key, const void *base, int num, int size, int (*cmp)(const void *, const void *)); -const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, int size, - int (*cmp)(const void *, const void *), int flags); +const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, + int size, int (*cmp)(const void *, const void *), + int flags); -#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ - static int nm##_cmp(type1 const *, type2 const *); \ - scope type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) +#define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ + static int nm##_cmp(type1 const *, type2 const *); \ + scope type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) -#define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ - _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) -#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ - type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) +#define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ + _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) +#define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ + type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) /*- * Unsolved problem: if a type is actually a pointer type, like @@ -112,52 +116,57 @@ const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, int size * comparison routines do always not touch their arguments. */ -#define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ - { \ - type1 const *a = a_; \ - type2 const *b = b_; \ - return nm##_cmp(a, b); \ - } \ - static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ - { \ - return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), nm##_cmp_BSEARCH_CMP_FN); \ - } \ - extern void dummy_prototype(void) +#define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ + { \ + type1 const *a = a_; \ + type2 const *b = b_; \ + return nm##_cmp(a, b); \ + } \ + static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ + { \ + return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ + nm##_cmp_BSEARCH_CMP_FN); \ + } \ + extern void dummy_prototype(void) -#define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ - { \ - type1 const *a = a_; \ - type2 const *b = b_; \ - return nm##_cmp(a, b); \ - } \ - type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ - { \ - return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), nm##_cmp_BSEARCH_CMP_FN); \ - } \ - extern void dummy_prototype(void) +#define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ + static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ + { \ + type1 const *a = a_; \ + type2 const *b = b_; \ + return nm##_cmp(a, b); \ + } \ + type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ + { \ + return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ + nm##_cmp_BSEARCH_CMP_FN); \ + } \ + extern void dummy_prototype(void) -#define OBJ_bsearch(type1, key, type2, base, num, cmp) \ - ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1, key), CHECKED_PTR_OF(type2, base), num, \ - sizeof(type2), \ - ((void)CHECKED_PTR_OF(type1, cmp##_type_1), \ - (void)CHECKED_PTR_OF(type2, cmp##_type_2), cmp##_BSEARCH_CMP_FN))) +#define OBJ_bsearch(type1, key, type2, base, num, cmp) \ + ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1, key), \ + CHECKED_PTR_OF(type2, base), num, sizeof(type2), \ + ((void)CHECKED_PTR_OF(type1, cmp##_type_1), \ + (void)CHECKED_PTR_OF(type2, cmp##_type_2), \ + cmp##_BSEARCH_CMP_FN))) -#define OBJ_bsearch_ex(type1, key, type2, base, num, cmp, flags) \ - ((type2 *)OBJ_bsearch_ex_( \ - CHECKED_PTR_OF(type1, key), CHECKED_PTR_OF(type2, base), num, sizeof(type2), \ - ((void)CHECKED_PTR_OF(type1, cmp##_type_1), \ - (void)type_2 = CHECKED_PTR_OF(type2, cmp##_type_2), cmp##_BSEARCH_CMP_FN)), \ - flags) +#define OBJ_bsearch_ex(type1, key, type2, base, num, cmp, flags) \ + ((type2 *)OBJ_bsearch_ex_( \ + CHECKED_PTR_OF(type1, key), CHECKED_PTR_OF(type2, base), num, \ + sizeof(type2), \ + ((void)CHECKED_PTR_OF(type1, cmp##_type_1), \ + (void)type_2 = CHECKED_PTR_OF(type2, cmp##_type_2), \ + cmp##_BSEARCH_CMP_FN)), \ + flags) int OBJ_new_nid(int num); int OBJ_add_object(const ASN1_OBJECT *obj); int OBJ_create(const char *oid, const char *sn, const char *ln); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define OBJ_cleanup() \ - while (0) \ - continue +# define OBJ_cleanup() \ + while (0) \ + continue #endif int OBJ_create_objects(BIO *in); diff --git a/libs/OpenSSL/include/openssl/ocsp.h b/libs/OpenSSL/include/openssl/ocsp.h index cf40c02c..c4a5dd98 100644 --- a/libs/OpenSSL/include/openssl/ocsp.h +++ b/libs/OpenSSL/include/openssl/ocsp.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_OCSP_H +# define HEADER_OCSP_H #endif #include @@ -56,32 +56,32 @@ #ifndef OPENSSL_NO_OCSP -# include -# include -# include -# include +# include +# include +# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif /* Various flags and values */ -# define OCSP_DEFAULT_NONCE_LENGTH 16 +# define OCSP_DEFAULT_NONCE_LENGTH 16 -# define OCSP_NOCERTS 0x1 -# define OCSP_NOINTERN 0x2 -# define OCSP_NOSIGS 0x4 -# define OCSP_NOCHAIN 0x8 -# define OCSP_NOVERIFY 0x10 -# define OCSP_NOEXPLICIT 0x20 -# define OCSP_NOCASIGN 0x40 -# define OCSP_NODELEGATED 0x80 -# define OCSP_NOCHECKS 0x100 -# define OCSP_TRUSTOTHER 0x200 -# define OCSP_RESPID_KEY 0x400 -# define OCSP_NOTIME 0x800 -# define OCSP_PARTIAL_CHAIN 0x1000 +# define OCSP_NOCERTS 0x1 +# define OCSP_NOINTERN 0x2 +# define OCSP_NOSIGS 0x4 +# define OCSP_NOCHAIN 0x8 +# define OCSP_NOVERIFY 0x10 +# define OCSP_NOEXPLICIT 0x20 +# define OCSP_NOCASIGN 0x40 +# define OCSP_NODELEGATED 0x80 +# define OCSP_NOCHECKS 0x100 +# define OCSP_TRUSTOTHER 0x200 +# define OCSP_RESPID_KEY 0x400 +# define OCSP_NOTIME 0x800 +# define OCSP_PARTIAL_CHAIN 0x1000 typedef struct ocsp_cert_id_st OCSP_CERTID; typedef struct ocsp_one_request_st OCSP_ONEREQ; @@ -90,257 +90,308 @@ typedef struct ocsp_signature_st OCSP_SIGNATURE; typedef struct ocsp_request_st OCSP_REQUEST; SKM_DEFINE_STACK_OF_INTERNAL(OCSP_CERTID, OCSP_CERTID, OCSP_CERTID) -# define sk_OCSP_CERTID_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_CERTID_sk_type(sk)) -# define sk_OCSP_CERTID_value(sk, idx) \ - ((OCSP_CERTID *)OPENSSL_sk_value(ossl_check_const_OCSP_CERTID_sk_type(sk), (idx))) -# define sk_OCSP_CERTID_new(cmp) \ - ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new(ossl_check_OCSP_CERTID_compfunc_type(cmp))) -# define sk_OCSP_CERTID_new_null() ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new_null()) -# define sk_OCSP_CERTID_new_reserve(cmp, n) \ - ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new_reserve( \ - ossl_check_OCSP_CERTID_compfunc_type(cmp), (n))) -# define sk_OCSP_CERTID_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OCSP_CERTID_sk_type(sk), (n)) -# define sk_OCSP_CERTID_free(sk) OPENSSL_sk_free(ossl_check_OCSP_CERTID_sk_type(sk)) -# define sk_OCSP_CERTID_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_CERTID_sk_type(sk)) -# define sk_OCSP_CERTID_delete(sk, i) \ - ((OCSP_CERTID *)OPENSSL_sk_delete(ossl_check_OCSP_CERTID_sk_type(sk), (i))) -# define sk_OCSP_CERTID_delete_ptr(sk, ptr) \ - ((OCSP_CERTID *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_CERTID_sk_type(sk), \ - ossl_check_OCSP_CERTID_type(ptr))) -# define sk_OCSP_CERTID_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) -# define sk_OCSP_CERTID_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) -# define sk_OCSP_CERTID_pop(sk) \ - ((OCSP_CERTID *)OPENSSL_sk_pop(ossl_check_OCSP_CERTID_sk_type(sk))) -# define sk_OCSP_CERTID_shift(sk) \ - ((OCSP_CERTID *)OPENSSL_sk_shift(ossl_check_OCSP_CERTID_sk_type(sk))) -# define sk_OCSP_CERTID_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OCSP_CERTID_sk_type(sk), \ - ossl_check_OCSP_CERTID_freefunc_type(freefunc)) -# define sk_OCSP_CERTID_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr), \ - (idx)) -# define sk_OCSP_CERTID_set(sk, idx, ptr) \ - ((OCSP_CERTID *)OPENSSL_sk_set(ossl_check_OCSP_CERTID_sk_type(sk), (idx), \ - ossl_check_OCSP_CERTID_type(ptr))) -# define sk_OCSP_CERTID_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) -# define sk_OCSP_CERTID_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr)) -# define sk_OCSP_CERTID_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_type(ptr), \ - pnum) -# define sk_OCSP_CERTID_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_CERTID_sk_type(sk)) -# define sk_OCSP_CERTID_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OCSP_CERTID_sk_type(sk)) -# define sk_OCSP_CERTID_dup(sk) \ - ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_dup(ossl_check_const_OCSP_CERTID_sk_type(sk))) -# define sk_OCSP_CERTID_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OCSP_CERTID_sk_type(sk), \ - ossl_check_OCSP_CERTID_copyfunc_type(copyfunc), \ - ossl_check_OCSP_CERTID_freefunc_type(freefunc))) -# define sk_OCSP_CERTID_set_cmp_func(sk, cmp) \ - ((sk_OCSP_CERTID_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OCSP_CERTID_sk_type(sk), ossl_check_OCSP_CERTID_compfunc_type(cmp))) +# define sk_OCSP_CERTID_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OCSP_CERTID_sk_type(sk)) +# define sk_OCSP_CERTID_value(sk, idx) \ + ((OCSP_CERTID *)OPENSSL_sk_value(ossl_check_const_OCSP_CERTID_sk_type(sk), \ + (idx))) +# define sk_OCSP_CERTID_new(cmp) \ + ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new( \ + ossl_check_OCSP_CERTID_compfunc_type(cmp))) +# define sk_OCSP_CERTID_new_null() \ + ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new_null()) +# define sk_OCSP_CERTID_new_reserve(cmp, n) \ + ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_new_reserve( \ + ossl_check_OCSP_CERTID_compfunc_type(cmp), (n))) +# define sk_OCSP_CERTID_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OCSP_CERTID_sk_type(sk), (n)) +# define sk_OCSP_CERTID_free(sk) \ + OPENSSL_sk_free(ossl_check_OCSP_CERTID_sk_type(sk)) +# define sk_OCSP_CERTID_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OCSP_CERTID_sk_type(sk)) +# define sk_OCSP_CERTID_delete(sk, i) \ + ((OCSP_CERTID *)OPENSSL_sk_delete(ossl_check_OCSP_CERTID_sk_type(sk), (i))) +# define sk_OCSP_CERTID_delete_ptr(sk, ptr) \ + ((OCSP_CERTID *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr))) +# define sk_OCSP_CERTID_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr)) +# define sk_OCSP_CERTID_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr)) +# define sk_OCSP_CERTID_pop(sk) \ + ((OCSP_CERTID *)OPENSSL_sk_pop(ossl_check_OCSP_CERTID_sk_type(sk))) +# define sk_OCSP_CERTID_shift(sk) \ + ((OCSP_CERTID *)OPENSSL_sk_shift(ossl_check_OCSP_CERTID_sk_type(sk))) +# define sk_OCSP_CERTID_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_freefunc_type(freefunc)) +# define sk_OCSP_CERTID_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr), (idx)) +# define sk_OCSP_CERTID_set(sk, idx, ptr) \ + ((OCSP_CERTID *)OPENSSL_sk_set(ossl_check_OCSP_CERTID_sk_type(sk), (idx), \ + ossl_check_OCSP_CERTID_type(ptr))) +# define sk_OCSP_CERTID_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr)) +# define sk_OCSP_CERTID_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr)) +# define sk_OCSP_CERTID_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_type(ptr), pnum) +# define sk_OCSP_CERTID_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OCSP_CERTID_sk_type(sk)) +# define sk_OCSP_CERTID_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OCSP_CERTID_sk_type(sk)) +# define sk_OCSP_CERTID_dup(sk) \ + ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_dup( \ + ossl_check_const_OCSP_CERTID_sk_type(sk))) +# define sk_OCSP_CERTID_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OCSP_CERTID) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_copyfunc_type(copyfunc), \ + ossl_check_OCSP_CERTID_freefunc_type(freefunc))) +# define sk_OCSP_CERTID_set_cmp_func(sk, cmp) \ + ((sk_OCSP_CERTID_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OCSP_CERTID_sk_type(sk), \ + ossl_check_OCSP_CERTID_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(OCSP_ONEREQ, OCSP_ONEREQ, OCSP_ONEREQ) -# define sk_OCSP_ONEREQ_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_ONEREQ_sk_type(sk)) -# define sk_OCSP_ONEREQ_value(sk, idx) \ - ((OCSP_ONEREQ *)OPENSSL_sk_value(ossl_check_const_OCSP_ONEREQ_sk_type(sk), (idx))) -# define sk_OCSP_ONEREQ_new(cmp) \ - ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new(ossl_check_OCSP_ONEREQ_compfunc_type(cmp))) -# define sk_OCSP_ONEREQ_new_null() ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new_null()) -# define sk_OCSP_ONEREQ_new_reserve(cmp, n) \ - ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new_reserve( \ - ossl_check_OCSP_ONEREQ_compfunc_type(cmp), (n))) -# define sk_OCSP_ONEREQ_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OCSP_ONEREQ_sk_type(sk), (n)) -# define sk_OCSP_ONEREQ_free(sk) OPENSSL_sk_free(ossl_check_OCSP_ONEREQ_sk_type(sk)) -# define sk_OCSP_ONEREQ_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_ONEREQ_sk_type(sk)) -# define sk_OCSP_ONEREQ_delete(sk, i) \ - ((OCSP_ONEREQ *)OPENSSL_sk_delete(ossl_check_OCSP_ONEREQ_sk_type(sk), (i))) -# define sk_OCSP_ONEREQ_delete_ptr(sk, ptr) \ - ((OCSP_ONEREQ *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_ONEREQ_sk_type(sk), \ - ossl_check_OCSP_ONEREQ_type(ptr))) -# define sk_OCSP_ONEREQ_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) -# define sk_OCSP_ONEREQ_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) -# define sk_OCSP_ONEREQ_pop(sk) \ - ((OCSP_ONEREQ *)OPENSSL_sk_pop(ossl_check_OCSP_ONEREQ_sk_type(sk))) -# define sk_OCSP_ONEREQ_shift(sk) \ - ((OCSP_ONEREQ *)OPENSSL_sk_shift(ossl_check_OCSP_ONEREQ_sk_type(sk))) -# define sk_OCSP_ONEREQ_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OCSP_ONEREQ_sk_type(sk), \ - ossl_check_OCSP_ONEREQ_freefunc_type(freefunc)) -# define sk_OCSP_ONEREQ_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr), \ - (idx)) -# define sk_OCSP_ONEREQ_set(sk, idx, ptr) \ - ((OCSP_ONEREQ *)OPENSSL_sk_set(ossl_check_OCSP_ONEREQ_sk_type(sk), (idx), \ - ossl_check_OCSP_ONEREQ_type(ptr))) -# define sk_OCSP_ONEREQ_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) -# define sk_OCSP_ONEREQ_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr)) -# define sk_OCSP_ONEREQ_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_type(ptr), \ - pnum) -# define sk_OCSP_ONEREQ_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_ONEREQ_sk_type(sk)) -# define sk_OCSP_ONEREQ_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OCSP_ONEREQ_sk_type(sk)) -# define sk_OCSP_ONEREQ_dup(sk) \ - ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_dup(ossl_check_const_OCSP_ONEREQ_sk_type(sk))) -# define sk_OCSP_ONEREQ_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OCSP_ONEREQ_sk_type(sk), \ - ossl_check_OCSP_ONEREQ_copyfunc_type(copyfunc), \ - ossl_check_OCSP_ONEREQ_freefunc_type(freefunc))) -# define sk_OCSP_ONEREQ_set_cmp_func(sk, cmp) \ - ((sk_OCSP_ONEREQ_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OCSP_ONEREQ_sk_type(sk), ossl_check_OCSP_ONEREQ_compfunc_type(cmp))) +# define sk_OCSP_ONEREQ_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OCSP_ONEREQ_sk_type(sk)) +# define sk_OCSP_ONEREQ_value(sk, idx) \ + ((OCSP_ONEREQ *)OPENSSL_sk_value(ossl_check_const_OCSP_ONEREQ_sk_type(sk), \ + (idx))) +# define sk_OCSP_ONEREQ_new(cmp) \ + ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new( \ + ossl_check_OCSP_ONEREQ_compfunc_type(cmp))) +# define sk_OCSP_ONEREQ_new_null() \ + ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new_null()) +# define sk_OCSP_ONEREQ_new_reserve(cmp, n) \ + ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_new_reserve( \ + ossl_check_OCSP_ONEREQ_compfunc_type(cmp), (n))) +# define sk_OCSP_ONEREQ_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OCSP_ONEREQ_sk_type(sk), (n)) +# define sk_OCSP_ONEREQ_free(sk) \ + OPENSSL_sk_free(ossl_check_OCSP_ONEREQ_sk_type(sk)) +# define sk_OCSP_ONEREQ_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OCSP_ONEREQ_sk_type(sk)) +# define sk_OCSP_ONEREQ_delete(sk, i) \ + ((OCSP_ONEREQ *)OPENSSL_sk_delete(ossl_check_OCSP_ONEREQ_sk_type(sk), (i))) +# define sk_OCSP_ONEREQ_delete_ptr(sk, ptr) \ + ((OCSP_ONEREQ *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr))) +# define sk_OCSP_ONEREQ_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr)) +# define sk_OCSP_ONEREQ_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr)) +# define sk_OCSP_ONEREQ_pop(sk) \ + ((OCSP_ONEREQ *)OPENSSL_sk_pop(ossl_check_OCSP_ONEREQ_sk_type(sk))) +# define sk_OCSP_ONEREQ_shift(sk) \ + ((OCSP_ONEREQ *)OPENSSL_sk_shift(ossl_check_OCSP_ONEREQ_sk_type(sk))) +# define sk_OCSP_ONEREQ_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_freefunc_type(freefunc)) +# define sk_OCSP_ONEREQ_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr), (idx)) +# define sk_OCSP_ONEREQ_set(sk, idx, ptr) \ + ((OCSP_ONEREQ *)OPENSSL_sk_set(ossl_check_OCSP_ONEREQ_sk_type(sk), (idx), \ + ossl_check_OCSP_ONEREQ_type(ptr))) +# define sk_OCSP_ONEREQ_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr)) +# define sk_OCSP_ONEREQ_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr)) +# define sk_OCSP_ONEREQ_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_type(ptr), pnum) +# define sk_OCSP_ONEREQ_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OCSP_ONEREQ_sk_type(sk)) +# define sk_OCSP_ONEREQ_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OCSP_ONEREQ_sk_type(sk)) +# define sk_OCSP_ONEREQ_dup(sk) \ + ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_dup( \ + ossl_check_const_OCSP_ONEREQ_sk_type(sk))) +# define sk_OCSP_ONEREQ_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OCSP_ONEREQ) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_copyfunc_type(copyfunc), \ + ossl_check_OCSP_ONEREQ_freefunc_type(freefunc))) +# define sk_OCSP_ONEREQ_set_cmp_func(sk, cmp) \ + ((sk_OCSP_ONEREQ_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OCSP_ONEREQ_sk_type(sk), \ + ossl_check_OCSP_ONEREQ_compfunc_type(cmp))) -# define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 -# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 -# define OCSP_RESPONSE_STATUS_INTERNALERROR 2 -# define OCSP_RESPONSE_STATUS_TRYLATER 3 -# define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 -# define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 +# define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 +# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 +# define OCSP_RESPONSE_STATUS_INTERNALERROR 2 +# define OCSP_RESPONSE_STATUS_TRYLATER 3 +# define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 +# define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES; -# define V_OCSP_RESPID_NAME 0 -# define V_OCSP_RESPID_KEY 1 +# define V_OCSP_RESPID_NAME 0 +# define V_OCSP_RESPID_KEY 1 SKM_DEFINE_STACK_OF_INTERNAL(OCSP_RESPID, OCSP_RESPID, OCSP_RESPID) -# define sk_OCSP_RESPID_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_RESPID_sk_type(sk)) -# define sk_OCSP_RESPID_value(sk, idx) \ - ((OCSP_RESPID *)OPENSSL_sk_value(ossl_check_const_OCSP_RESPID_sk_type(sk), (idx))) -# define sk_OCSP_RESPID_new(cmp) \ - ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new(ossl_check_OCSP_RESPID_compfunc_type(cmp))) -# define sk_OCSP_RESPID_new_null() ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new_null()) -# define sk_OCSP_RESPID_new_reserve(cmp, n) \ - ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new_reserve( \ - ossl_check_OCSP_RESPID_compfunc_type(cmp), (n))) -# define sk_OCSP_RESPID_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OCSP_RESPID_sk_type(sk), (n)) -# define sk_OCSP_RESPID_free(sk) OPENSSL_sk_free(ossl_check_OCSP_RESPID_sk_type(sk)) -# define sk_OCSP_RESPID_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_RESPID_sk_type(sk)) -# define sk_OCSP_RESPID_delete(sk, i) \ - ((OCSP_RESPID *)OPENSSL_sk_delete(ossl_check_OCSP_RESPID_sk_type(sk), (i))) -# define sk_OCSP_RESPID_delete_ptr(sk, ptr) \ - ((OCSP_RESPID *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_RESPID_sk_type(sk), \ - ossl_check_OCSP_RESPID_type(ptr))) -# define sk_OCSP_RESPID_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) -# define sk_OCSP_RESPID_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) -# define sk_OCSP_RESPID_pop(sk) \ - ((OCSP_RESPID *)OPENSSL_sk_pop(ossl_check_OCSP_RESPID_sk_type(sk))) -# define sk_OCSP_RESPID_shift(sk) \ - ((OCSP_RESPID *)OPENSSL_sk_shift(ossl_check_OCSP_RESPID_sk_type(sk))) -# define sk_OCSP_RESPID_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OCSP_RESPID_sk_type(sk), \ - ossl_check_OCSP_RESPID_freefunc_type(freefunc)) -# define sk_OCSP_RESPID_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr), \ - (idx)) -# define sk_OCSP_RESPID_set(sk, idx, ptr) \ - ((OCSP_RESPID *)OPENSSL_sk_set(ossl_check_OCSP_RESPID_sk_type(sk), (idx), \ - ossl_check_OCSP_RESPID_type(ptr))) -# define sk_OCSP_RESPID_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) -# define sk_OCSP_RESPID_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr)) -# define sk_OCSP_RESPID_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_type(ptr), \ - pnum) -# define sk_OCSP_RESPID_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_RESPID_sk_type(sk)) -# define sk_OCSP_RESPID_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OCSP_RESPID_sk_type(sk)) -# define sk_OCSP_RESPID_dup(sk) \ - ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_dup(ossl_check_const_OCSP_RESPID_sk_type(sk))) -# define sk_OCSP_RESPID_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OCSP_RESPID_sk_type(sk), \ - ossl_check_OCSP_RESPID_copyfunc_type(copyfunc), \ - ossl_check_OCSP_RESPID_freefunc_type(freefunc))) -# define sk_OCSP_RESPID_set_cmp_func(sk, cmp) \ - ((sk_OCSP_RESPID_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OCSP_RESPID_sk_type(sk), ossl_check_OCSP_RESPID_compfunc_type(cmp))) +# define sk_OCSP_RESPID_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OCSP_RESPID_sk_type(sk)) +# define sk_OCSP_RESPID_value(sk, idx) \ + ((OCSP_RESPID *)OPENSSL_sk_value(ossl_check_const_OCSP_RESPID_sk_type(sk), \ + (idx))) +# define sk_OCSP_RESPID_new(cmp) \ + ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new( \ + ossl_check_OCSP_RESPID_compfunc_type(cmp))) +# define sk_OCSP_RESPID_new_null() \ + ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new_null()) +# define sk_OCSP_RESPID_new_reserve(cmp, n) \ + ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_new_reserve( \ + ossl_check_OCSP_RESPID_compfunc_type(cmp), (n))) +# define sk_OCSP_RESPID_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OCSP_RESPID_sk_type(sk), (n)) +# define sk_OCSP_RESPID_free(sk) \ + OPENSSL_sk_free(ossl_check_OCSP_RESPID_sk_type(sk)) +# define sk_OCSP_RESPID_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OCSP_RESPID_sk_type(sk)) +# define sk_OCSP_RESPID_delete(sk, i) \ + ((OCSP_RESPID *)OPENSSL_sk_delete(ossl_check_OCSP_RESPID_sk_type(sk), (i))) +# define sk_OCSP_RESPID_delete_ptr(sk, ptr) \ + ((OCSP_RESPID *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr))) +# define sk_OCSP_RESPID_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr)) +# define sk_OCSP_RESPID_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr)) +# define sk_OCSP_RESPID_pop(sk) \ + ((OCSP_RESPID *)OPENSSL_sk_pop(ossl_check_OCSP_RESPID_sk_type(sk))) +# define sk_OCSP_RESPID_shift(sk) \ + ((OCSP_RESPID *)OPENSSL_sk_shift(ossl_check_OCSP_RESPID_sk_type(sk))) +# define sk_OCSP_RESPID_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_freefunc_type(freefunc)) +# define sk_OCSP_RESPID_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr), (idx)) +# define sk_OCSP_RESPID_set(sk, idx, ptr) \ + ((OCSP_RESPID *)OPENSSL_sk_set(ossl_check_OCSP_RESPID_sk_type(sk), (idx), \ + ossl_check_OCSP_RESPID_type(ptr))) +# define sk_OCSP_RESPID_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr)) +# define sk_OCSP_RESPID_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr)) +# define sk_OCSP_RESPID_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_type(ptr), pnum) +# define sk_OCSP_RESPID_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OCSP_RESPID_sk_type(sk)) +# define sk_OCSP_RESPID_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OCSP_RESPID_sk_type(sk)) +# define sk_OCSP_RESPID_dup(sk) \ + ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_dup( \ + ossl_check_const_OCSP_RESPID_sk_type(sk))) +# define sk_OCSP_RESPID_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OCSP_RESPID) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_copyfunc_type(copyfunc), \ + ossl_check_OCSP_RESPID_freefunc_type(freefunc))) +# define sk_OCSP_RESPID_set_cmp_func(sk, cmp) \ + ((sk_OCSP_RESPID_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OCSP_RESPID_sk_type(sk), \ + ossl_check_OCSP_RESPID_compfunc_type(cmp))) typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO; -# define V_OCSP_CERTSTATUS_GOOD 0 -# define V_OCSP_CERTSTATUS_REVOKED 1 -# define V_OCSP_CERTSTATUS_UNKNOWN 2 +# define V_OCSP_CERTSTATUS_GOOD 0 +# define V_OCSP_CERTSTATUS_REVOKED 1 +# define V_OCSP_CERTSTATUS_UNKNOWN 2 typedef struct ocsp_cert_status_st OCSP_CERTSTATUS; typedef struct ocsp_single_response_st OCSP_SINGLERESP; SKM_DEFINE_STACK_OF_INTERNAL(OCSP_SINGLERESP, OCSP_SINGLERESP, OCSP_SINGLERESP) -# define sk_OCSP_SINGLERESP_num(sk) OPENSSL_sk_num(ossl_check_const_OCSP_SINGLERESP_sk_type(sk)) -# define sk_OCSP_SINGLERESP_value(sk, idx) \ - ((OCSP_SINGLERESP *)OPENSSL_sk_value(ossl_check_const_OCSP_SINGLERESP_sk_type(sk), (idx))) -# define sk_OCSP_SINGLERESP_new(cmp) \ - ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new(ossl_check_OCSP_SINGLERESP_compfunc_type(cmp))) -# define sk_OCSP_SINGLERESP_new_null() ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new_null()) -# define sk_OCSP_SINGLERESP_new_reserve(cmp, n) \ - ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new_reserve( \ - ossl_check_OCSP_SINGLERESP_compfunc_type(cmp), (n))) -# define sk_OCSP_SINGLERESP_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OCSP_SINGLERESP_sk_type(sk), (n)) -# define sk_OCSP_SINGLERESP_free(sk) OPENSSL_sk_free(ossl_check_OCSP_SINGLERESP_sk_type(sk)) -# define sk_OCSP_SINGLERESP_zero(sk) OPENSSL_sk_zero(ossl_check_OCSP_SINGLERESP_sk_type(sk)) -# define sk_OCSP_SINGLERESP_delete(sk, i) \ - ((OCSP_SINGLERESP *)OPENSSL_sk_delete(ossl_check_OCSP_SINGLERESP_sk_type(sk), (i))) -# define sk_OCSP_SINGLERESP_delete_ptr(sk, ptr) \ - ((OCSP_SINGLERESP *)OPENSSL_sk_delete_ptr(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr))) -# define sk_OCSP_SINGLERESP_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr)) -# define sk_OCSP_SINGLERESP_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr)) -# define sk_OCSP_SINGLERESP_pop(sk) \ - ((OCSP_SINGLERESP *)OPENSSL_sk_pop(ossl_check_OCSP_SINGLERESP_sk_type(sk))) -# define sk_OCSP_SINGLERESP_shift(sk) \ - ((OCSP_SINGLERESP *)OPENSSL_sk_shift(ossl_check_OCSP_SINGLERESP_sk_type(sk))) -# define sk_OCSP_SINGLERESP_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_freefunc_type(freefunc)) -# define sk_OCSP_SINGLERESP_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr), (idx)) -# define sk_OCSP_SINGLERESP_set(sk, idx, ptr) \ - ((OCSP_SINGLERESP *)OPENSSL_sk_set(ossl_check_OCSP_SINGLERESP_sk_type(sk), (idx), \ - ossl_check_OCSP_SINGLERESP_type(ptr))) -# define sk_OCSP_SINGLERESP_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr)) -# define sk_OCSP_SINGLERESP_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr)) -# define sk_OCSP_SINGLERESP_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_type(ptr), pnum) -# define sk_OCSP_SINGLERESP_sort(sk) OPENSSL_sk_sort(ossl_check_OCSP_SINGLERESP_sk_type(sk)) -# define sk_OCSP_SINGLERESP_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OCSP_SINGLERESP_sk_type(sk)) -# define sk_OCSP_SINGLERESP_dup(sk) \ - ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_dup(ossl_check_const_OCSP_SINGLERESP_sk_type(sk))) -# define sk_OCSP_SINGLERESP_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_copyfunc_type(copyfunc), \ - ossl_check_OCSP_SINGLERESP_freefunc_type(freefunc))) -# define sk_OCSP_SINGLERESP_set_cmp_func(sk, cmp) \ - ((sk_OCSP_SINGLERESP_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OCSP_SINGLERESP_sk_type(sk), \ - ossl_check_OCSP_SINGLERESP_compfunc_type(cmp))) +# define sk_OCSP_SINGLERESP_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OCSP_SINGLERESP_sk_type(sk)) +# define sk_OCSP_SINGLERESP_value(sk, idx) \ + ((OCSP_SINGLERESP *)OPENSSL_sk_value( \ + ossl_check_const_OCSP_SINGLERESP_sk_type(sk), (idx))) +# define sk_OCSP_SINGLERESP_new(cmp) \ + ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new( \ + ossl_check_OCSP_SINGLERESP_compfunc_type(cmp))) +# define sk_OCSP_SINGLERESP_new_null() \ + ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new_null()) +# define sk_OCSP_SINGLERESP_new_reserve(cmp, n) \ + ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_new_reserve( \ + ossl_check_OCSP_SINGLERESP_compfunc_type(cmp), (n))) +# define sk_OCSP_SINGLERESP_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OCSP_SINGLERESP_sk_type(sk), (n)) +# define sk_OCSP_SINGLERESP_free(sk) \ + OPENSSL_sk_free(ossl_check_OCSP_SINGLERESP_sk_type(sk)) +# define sk_OCSP_SINGLERESP_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OCSP_SINGLERESP_sk_type(sk)) +# define sk_OCSP_SINGLERESP_delete(sk, i) \ + ((OCSP_SINGLERESP *)OPENSSL_sk_delete( \ + ossl_check_OCSP_SINGLERESP_sk_type(sk), (i))) +# define sk_OCSP_SINGLERESP_delete_ptr(sk, ptr) \ + ((OCSP_SINGLERESP *)OPENSSL_sk_delete_ptr( \ + ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr))) +# define sk_OCSP_SINGLERESP_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr)) +# define sk_OCSP_SINGLERESP_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr)) +# define sk_OCSP_SINGLERESP_pop(sk) \ + ((OCSP_SINGLERESP *)OPENSSL_sk_pop(ossl_check_OCSP_SINGLERESP_sk_type(sk))) +# define sk_OCSP_SINGLERESP_shift(sk) \ + ((OCSP_SINGLERESP *)OPENSSL_sk_shift( \ + ossl_check_OCSP_SINGLERESP_sk_type(sk))) +# define sk_OCSP_SINGLERESP_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_freefunc_type(freefunc)) +# define sk_OCSP_SINGLERESP_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr), (idx)) +# define sk_OCSP_SINGLERESP_set(sk, idx, ptr) \ + ((OCSP_SINGLERESP *)OPENSSL_sk_set(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + (idx), \ + ossl_check_OCSP_SINGLERESP_type(ptr))) +# define sk_OCSP_SINGLERESP_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr)) +# define sk_OCSP_SINGLERESP_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr)) +# define sk_OCSP_SINGLERESP_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_type(ptr), pnum) +# define sk_OCSP_SINGLERESP_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OCSP_SINGLERESP_sk_type(sk)) +# define sk_OCSP_SINGLERESP_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OCSP_SINGLERESP_sk_type(sk)) +# define sk_OCSP_SINGLERESP_dup(sk) \ + ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_dup( \ + ossl_check_const_OCSP_SINGLERESP_sk_type(sk))) +# define sk_OCSP_SINGLERESP_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OCSP_SINGLERESP) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_copyfunc_type(copyfunc), \ + ossl_check_OCSP_SINGLERESP_freefunc_type(freefunc))) +# define sk_OCSP_SINGLERESP_set_cmp_func(sk, cmp) \ + ((sk_OCSP_SINGLERESP_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OCSP_SINGLERESP_sk_type(sk), \ + ossl_check_OCSP_SINGLERESP_compfunc_type(cmp))) typedef struct ocsp_response_data_st OCSP_RESPDATA; @@ -349,73 +400,83 @@ typedef struct ocsp_basic_response_st OCSP_BASICRESP; typedef struct ocsp_crl_id_st OCSP_CRLID; typedef struct ocsp_service_locator_st OCSP_SERVICELOC; -# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" -# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" +# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" +# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" -# define d2i_OCSP_REQUEST_bio(bp, p) \ - ASN1_d2i_bio_of(OCSP_REQUEST, OCSP_REQUEST_new, d2i_OCSP_REQUEST, bp, p) +# define d2i_OCSP_REQUEST_bio(bp, p) \ + ASN1_d2i_bio_of(OCSP_REQUEST, OCSP_REQUEST_new, d2i_OCSP_REQUEST, bp, p) -# define d2i_OCSP_RESPONSE_bio(bp, p) \ - ASN1_d2i_bio_of(OCSP_RESPONSE, OCSP_RESPONSE_new, d2i_OCSP_RESPONSE, bp, p) +# define d2i_OCSP_RESPONSE_bio(bp, p) \ + ASN1_d2i_bio_of(OCSP_RESPONSE, OCSP_RESPONSE_new, d2i_OCSP_RESPONSE, bp, p) -# define PEM_read_bio_OCSP_REQUEST(bp, x, cb) \ - (OCSP_REQUEST *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_REQUEST, PEM_STRING_OCSP_REQUEST, \ - bp, (char **)(x), cb, NULL) +# define PEM_read_bio_OCSP_REQUEST(bp, x, cb) \ + (OCSP_REQUEST *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_REQUEST, \ + PEM_STRING_OCSP_REQUEST, bp, \ + (char **)(x), cb, NULL) -# define PEM_read_bio_OCSP_RESPONSE(bp, x, cb) \ - (OCSP_RESPONSE *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_RESPONSE, \ - PEM_STRING_OCSP_RESPONSE, bp, (char **)(x), cb, NULL) +# define PEM_read_bio_OCSP_RESPONSE(bp, x, cb) \ + (OCSP_RESPONSE *)PEM_ASN1_read_bio((char *(*)())d2i_OCSP_RESPONSE, \ + PEM_STRING_OCSP_RESPONSE, bp, \ + (char **)(x), cb, NULL) -# define PEM_write_bio_OCSP_REQUEST(bp, o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST, PEM_STRING_OCSP_REQUEST, bp, (char *)(o), \ - NULL, NULL, 0, NULL, NULL) +# define PEM_write_bio_OCSP_REQUEST(bp, o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST, PEM_STRING_OCSP_REQUEST, \ + bp, (char *)(o), NULL, NULL, 0, NULL, NULL) -# define PEM_write_bio_OCSP_RESPONSE(bp, o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE, PEM_STRING_OCSP_RESPONSE, bp, \ - (char *)(o), NULL, NULL, 0, NULL, NULL) +# define PEM_write_bio_OCSP_RESPONSE(bp, o) \ + PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE, PEM_STRING_OCSP_RESPONSE, \ + bp, (char *)(o), NULL, NULL, 0, NULL, NULL) -# define i2d_OCSP_RESPONSE_bio(bp, o) ASN1_i2d_bio_of(OCSP_RESPONSE, i2d_OCSP_RESPONSE, bp, o) +# define i2d_OCSP_RESPONSE_bio(bp, o) \ + ASN1_i2d_bio_of(OCSP_RESPONSE, i2d_OCSP_RESPONSE, bp, o) -# define i2d_OCSP_REQUEST_bio(bp, o) ASN1_i2d_bio_of(OCSP_REQUEST, i2d_OCSP_REQUEST, bp, o) +# define i2d_OCSP_REQUEST_bio(bp, o) \ + ASN1_i2d_bio_of(OCSP_REQUEST, i2d_OCSP_REQUEST, bp, o) -# define ASN1_BIT_STRING_digest(data, type, md, len) \ - ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING), type, data, md, len) +# define ASN1_BIT_STRING_digest(data, type, md, len) \ + ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING), type, data, md, len) -# define OCSP_CERTSTATUS_dup(cs) \ - (OCSP_CERTSTATUS *)ASN1_dup((i2d_of_void *)i2d_OCSP_CERTSTATUS, \ - (d2i_of_void *)d2i_OCSP_CERTSTATUS, (char *)(cs)) +# define OCSP_CERTSTATUS_dup(cs) \ + (OCSP_CERTSTATUS *)ASN1_dup((i2d_of_void *)i2d_OCSP_CERTSTATUS, \ + (d2i_of_void *)d2i_OCSP_CERTSTATUS, \ + (char *)(cs)) DECLARE_ASN1_DUP_FUNCTION(OCSP_CERTID) -OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, const OCSP_REQUEST *req, - int buf_size); +OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, + const OCSP_REQUEST *req, int buf_size); OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef OSSL_HTTP_REQ_CTX OCSP_REQ_CTX; -# define OCSP_REQ_CTX_new(io, buf_size) OSSL_HTTP_REQ_CTX_new(io, io, buf_size) -# define OCSP_REQ_CTX_free OSSL_HTTP_REQ_CTX_free -# define OCSP_REQ_CTX_http(rctx, op, path) \ - (OSSL_HTTP_REQ_CTX_set_expected(rctx, NULL, 1 /* asn1 */, 0, 0) \ - && OSSL_HTTP_REQ_CTX_set_request_line(rctx, strcmp(op, "POST") == 0, NULL, NULL, \ - path)) -# define OCSP_REQ_CTX_add1_header OSSL_HTTP_REQ_CTX_add1_header -# define OCSP_REQ_CTX_i2d(r, it, req) \ - OSSL_HTTP_REQ_CTX_set1_req(r, "application/ocsp-request", it, req) -# define OCSP_REQ_CTX_set1_req(r, req) \ - OCSP_REQ_CTX_i2d(r, ASN1_ITEM_rptr(OCSP_REQUEST), (ASN1_VALUE *)(req)) -# define OCSP_REQ_CTX_nbio OSSL_HTTP_REQ_CTX_nbio -# define OCSP_REQ_CTX_nbio_d2i OSSL_HTTP_REQ_CTX_nbio_d2i -# define OCSP_sendreq_nbio(p, r) \ - OSSL_HTTP_REQ_CTX_nbio_d2i(r, (ASN1_VALUE **)(p), ASN1_ITEM_rptr(OCSP_RESPONSE)) -# define OCSP_REQ_CTX_get0_mem_bio OSSL_HTTP_REQ_CTX_get0_mem_bio -# define OCSP_set_max_response_length OSSL_HTTP_REQ_CTX_set_max_response_length -# endif +# define OCSP_REQ_CTX_new(io, buf_size) \ + OSSL_HTTP_REQ_CTX_new(io, io, buf_size) +# define OCSP_REQ_CTX_free OSSL_HTTP_REQ_CTX_free +# define OCSP_REQ_CTX_http(rctx, op, path) \ + (OSSL_HTTP_REQ_CTX_set_expected(rctx, NULL, 1 /* asn1 */, 0, 0) \ + && OSSL_HTTP_REQ_CTX_set_request_line(rctx, strcmp(op, "POST") == 0, \ + NULL, NULL, path)) +# define OCSP_REQ_CTX_add1_header OSSL_HTTP_REQ_CTX_add1_header +# define OCSP_REQ_CTX_i2d(r, it, req) \ + OSSL_HTTP_REQ_CTX_set1_req(r, "application/ocsp-request", it, req) +# define OCSP_REQ_CTX_set1_req(r, req) \ + OCSP_REQ_CTX_i2d(r, ASN1_ITEM_rptr(OCSP_REQUEST), (ASN1_VALUE *)(req)) +# define OCSP_REQ_CTX_nbio OSSL_HTTP_REQ_CTX_nbio +# define OCSP_REQ_CTX_nbio_d2i OSSL_HTTP_REQ_CTX_nbio_d2i +# define OCSP_sendreq_nbio(p, r) \ + OSSL_HTTP_REQ_CTX_nbio_d2i(r, (ASN1_VALUE **)(p), \ + ASN1_ITEM_rptr(OCSP_RESPONSE)) +# define OCSP_REQ_CTX_get0_mem_bio OSSL_HTTP_REQ_CTX_get0_mem_bio +# define OCSP_set_max_response_length \ + OSSL_HTTP_REQ_CTX_set_max_response_length +# endif -OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, const X509 *issuer); +OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, + const X509 *issuer); OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, const X509_NAME *issuerName, - const ASN1_BIT_STRING *issuerKey, const ASN1_INTEGER *serialNumber); + const ASN1_BIT_STRING *issuerKey, + const ASN1_INTEGER *serialNumber); OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); @@ -427,8 +488,9 @@ int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); int OCSP_request_set1_name(OCSP_REQUEST *req, const X509_NAME *nm); int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); -int OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, - STACK_OF(X509) * certs, unsigned long flags); +int OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key, + const EVP_MD *dgst, STACK_OF(X509) * certs, + unsigned long flags); int OCSP_response_status(OCSP_RESPONSE *resp); OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); @@ -436,30 +498,36 @@ OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs); const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs); const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs); -int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer, STACK_OF(X509) * extra_certs); +int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer, + STACK_OF(X509) * extra_certs); int OCSP_resp_count(OCSP_BASICRESP *bs); OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); -const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP *bs); +const ASN1_GENERALIZEDTIME * +OCSP_resp_get0_produced_at(const OCSP_BASICRESP *bs); const STACK_OF(X509) * OCSP_resp_get0_certs(const OCSP_BASICRESP *bs); int OCSP_resp_get0_id(const OCSP_BASICRESP *bs, const ASN1_OCTET_STRING **pid, const X509_NAME **pname); -int OCSP_resp_get1_id(const OCSP_BASICRESP *bs, ASN1_OCTET_STRING **pid, X509_NAME **pname); +int OCSP_resp_get1_id(const OCSP_BASICRESP *bs, ASN1_OCTET_STRING **pid, + X509_NAME **pname); int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); -int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd); -int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, int *reason, - ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd, +int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, + ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, + ASN1_GENERALIZEDTIME **nextupd); +int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, + int *reason, ASN1_GENERALIZEDTIME **revtime, + ASN1_GENERALIZEDTIME **thisupd, ASN1_GENERALIZEDTIME **nextupd); -int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, ASN1_GENERALIZEDTIME *nextupd, long sec, - long maxsec); +int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, + ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec); -int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) * certs, X509_STORE *store, - unsigned long flags); +int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) * certs, + X509_STORE *store, unsigned long flags); -# define OCSP_parse_url(url, host, port, path, ssl) \ - OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL) +# define OCSP_parse_url(url, host, port, path, ssl) \ + OSSL_HTTP_parse_url(url, ssl, NULL, host, port, NULL, path, NULL, NULL) int OCSP_id_issuer_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b); int OCSP_id_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b); @@ -468,22 +536,26 @@ int OCSP_request_onereq_count(OCSP_REQUEST *req); OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, - ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial, OCSP_CERTID *cid); + ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial, + OCSP_CERTID *cid); int OCSP_request_is_signed(OCSP_REQUEST *req); OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid, int status, - int reason, ASN1_TIME *revtime, ASN1_TIME *thisupd, +OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTID *cid, + int status, int reason, + ASN1_TIME *revtime, ASN1_TIME *thisupd, ASN1_TIME *nextupd); int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); -int OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, - STACK_OF(X509) * certs, unsigned long flags); -int OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp, X509 *signer, EVP_MD_CTX *ctx, STACK_OF(X509) * certs, - unsigned long flags); +int OCSP_basic_sign(OCSP_BASICRESP *brsp, X509 *signer, EVP_PKEY *key, + const EVP_MD *dgst, STACK_OF(X509) * certs, + unsigned long flags); +int OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp, X509 *signer, EVP_MD_CTX *ctx, + STACK_OF(X509) * certs, unsigned long flags); int OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert); -int OCSP_RESPID_set_by_key_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx, - const char *propq); +int OCSP_RESPID_set_by_key_ex(OCSP_RESPID *respid, X509 *cert, + OSSL_LIB_CTX *libctx, const char *propq); int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert); -int OCSP_RESPID_match_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx, const char *propq); +int OCSP_RESPID_match_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx, + const char *propq); int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert); X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim); @@ -496,44 +568,54 @@ X509_EXTENSION *OCSP_url_svcloc_new(const X509_NAME *issuer, const char **urls); int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); -int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, int lastpos); +int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, + int lastpos); int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx); -int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, unsigned long flags); +int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, + unsigned long flags); int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); -int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos); +int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, + int lastpos); int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); -int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, unsigned long flags); +int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, + unsigned long flags); int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); -int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, int lastpos); -int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos); +int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, + int lastpos); +int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, + int lastpos); X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); -void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx); -int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, - unsigned long flags); +void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, + int *idx); +int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, + int crit, unsigned long flags); int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); -int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj, int lastpos); -int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos); +int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj, + int lastpos); +int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, + int lastpos); X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); -void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx); -int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit, - unsigned long flags); +void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, + int *idx); +int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, + int crit, unsigned long flags); int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); const OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x); @@ -560,11 +642,11 @@ const char *OCSP_crl_reason_str(long s); int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags); int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags); -int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) * certs, X509_STORE *st, - unsigned long flags); +int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) * certs, + X509_STORE *st, unsigned long flags); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* !defined(OPENSSL_NO_OCSP) */ #endif diff --git a/libs/OpenSSL/include/openssl/ocsperr.h b/libs/OpenSSL/include/openssl/ocsperr.h index 47ddbc94..444476d5 100644 --- a/libs/OpenSSL/include/openssl/ocsperr.h +++ b/libs/OpenSSL/include/openssl/ocsperr.h @@ -21,31 +21,31 @@ /* * OCSP reason codes. */ -# define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 -# define OCSP_R_DIGEST_ERR 102 -# define OCSP_R_DIGEST_NAME_ERR 106 -# define OCSP_R_DIGEST_SIZE_ERR 107 -# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 -# define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 -# define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 -# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 -# define OCSP_R_NOT_BASIC_RESPONSE 104 -# define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 -# define OCSP_R_NO_RESPONSE_DATA 108 -# define OCSP_R_NO_REVOKED_TIME 109 -# define OCSP_R_NO_SIGNER_KEY 130 -# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 -# define OCSP_R_REQUEST_NOT_SIGNED 128 -# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 -# define OCSP_R_ROOT_CA_NOT_TRUSTED 112 -# define OCSP_R_SIGNATURE_FAILURE 117 -# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 -# define OCSP_R_STATUS_EXPIRED 125 -# define OCSP_R_STATUS_NOT_YET_VALID 126 -# define OCSP_R_STATUS_TOO_OLD 127 -# define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 -# define OCSP_R_UNKNOWN_NID 120 -# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 +# define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 +# define OCSP_R_DIGEST_ERR 102 +# define OCSP_R_DIGEST_NAME_ERR 106 +# define OCSP_R_DIGEST_SIZE_ERR 107 +# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 +# define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 +# define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 +# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 +# define OCSP_R_NOT_BASIC_RESPONSE 104 +# define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 +# define OCSP_R_NO_RESPONSE_DATA 108 +# define OCSP_R_NO_REVOKED_TIME 109 +# define OCSP_R_NO_SIGNER_KEY 130 +# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 +# define OCSP_R_REQUEST_NOT_SIGNED 128 +# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 +# define OCSP_R_ROOT_CA_NOT_TRUSTED 112 +# define OCSP_R_SIGNATURE_FAILURE 117 +# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 +# define OCSP_R_STATUS_EXPIRED 125 +# define OCSP_R_STATUS_NOT_YET_VALID 126 +# define OCSP_R_STATUS_TOO_OLD 127 +# define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 +# define OCSP_R_UNKNOWN_NID 120 +# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 #endif #endif diff --git a/libs/OpenSSL/include/openssl/opensslv.h b/libs/OpenSSL/include/openssl/opensslv.h index 59fd6f03..ccd9f5cb 100644 --- a/libs/OpenSSL/include/openssl/opensslv.h +++ b/libs/OpenSSL/include/openssl/opensslv.h @@ -64,8 +64,9 @@ extern "C" { */ /* For checking general API compatibility when preprocessing */ -#define OPENSSL_VERSION_PREREQ(maj, min) \ - ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= ((maj) << 16) + (min)) +#define OPENSSL_VERSION_PREREQ(maj, min) \ + ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR \ + >= ((maj) << 16) + (min)) /* * Macros to get the version in easily digested string form, both the short @@ -92,13 +93,13 @@ extern "C" { /* Synthesize OPENSSL_VERSION_NUMBER with the layout 0xMNN00PPSL */ #ifdef OPENSSL_VERSION_PRE_RELEASE -# define _OPENSSL_VERSION_PRE_RELEASE 0x0L +# define _OPENSSL_VERSION_PRE_RELEASE 0x0L #else -# define _OPENSSL_VERSION_PRE_RELEASE 0xfL +# define _OPENSSL_VERSION_PRE_RELEASE 0xfL #endif -#define OPENSSL_VERSION_NUMBER \ - ((OPENSSL_VERSION_MAJOR << 28) | (OPENSSL_VERSION_MINOR << 20) | (OPENSSL_VERSION_PATCH << 4) \ - | _OPENSSL_VERSION_PRE_RELEASE) +#define OPENSSL_VERSION_NUMBER \ + ((OPENSSL_VERSION_MAJOR << 28) | (OPENSSL_VERSION_MINOR << 20) \ + | (OPENSSL_VERSION_PATCH << 4) | _OPENSSL_VERSION_PRE_RELEASE) #ifdef __cplusplus } @@ -106,7 +107,7 @@ extern "C" { #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_OPENSSLV_H +# define HEADER_OPENSSLV_H #endif #endif /* OPENSSL_OPENSSLV_H */ diff --git a/libs/OpenSSL/include/openssl/param_build.h b/libs/OpenSSL/include/openssl/param_build.h index ce196657..e85a9f48 100644 --- a/libs/OpenSSL/include/openssl/param_build.h +++ b/libs/OpenSSL/include/openssl/param_build.h @@ -24,24 +24,38 @@ OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld); void OSSL_PARAM_BLD_free(OSSL_PARAM_BLD *bld); int OSSL_PARAM_BLD_push_int(OSSL_PARAM_BLD *bld, const char *key, int val); -int OSSL_PARAM_BLD_push_uint(OSSL_PARAM_BLD *bld, const char *key, unsigned int val); -int OSSL_PARAM_BLD_push_long(OSSL_PARAM_BLD *bld, const char *key, long int val); -int OSSL_PARAM_BLD_push_ulong(OSSL_PARAM_BLD *bld, const char *key, unsigned long int val); -int OSSL_PARAM_BLD_push_int32(OSSL_PARAM_BLD *bld, const char *key, int32_t val); -int OSSL_PARAM_BLD_push_uint32(OSSL_PARAM_BLD *bld, const char *key, uint32_t val); -int OSSL_PARAM_BLD_push_int64(OSSL_PARAM_BLD *bld, const char *key, int64_t val); -int OSSL_PARAM_BLD_push_uint64(OSSL_PARAM_BLD *bld, const char *key, uint64_t val); -int OSSL_PARAM_BLD_push_size_t(OSSL_PARAM_BLD *bld, const char *key, size_t val); -int OSSL_PARAM_BLD_push_time_t(OSSL_PARAM_BLD *bld, const char *key, time_t val); -int OSSL_PARAM_BLD_push_double(OSSL_PARAM_BLD *bld, const char *key, double val); -int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key, const BIGNUM *bn); -int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key, const BIGNUM *bn, size_t sz); -int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key, const char *buf, - size_t bsize); -int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key, char *buf, size_t bsize); -int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key, const void *buf, - size_t bsize); -int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key, void *buf, size_t bsize); +int OSSL_PARAM_BLD_push_uint(OSSL_PARAM_BLD *bld, const char *key, + unsigned int val); +int OSSL_PARAM_BLD_push_long(OSSL_PARAM_BLD *bld, const char *key, + long int val); +int OSSL_PARAM_BLD_push_ulong(OSSL_PARAM_BLD *bld, const char *key, + unsigned long int val); +int OSSL_PARAM_BLD_push_int32(OSSL_PARAM_BLD *bld, const char *key, + int32_t val); +int OSSL_PARAM_BLD_push_uint32(OSSL_PARAM_BLD *bld, const char *key, + uint32_t val); +int OSSL_PARAM_BLD_push_int64(OSSL_PARAM_BLD *bld, const char *key, + int64_t val); +int OSSL_PARAM_BLD_push_uint64(OSSL_PARAM_BLD *bld, const char *key, + uint64_t val); +int OSSL_PARAM_BLD_push_size_t(OSSL_PARAM_BLD *bld, const char *key, + size_t val); +int OSSL_PARAM_BLD_push_time_t(OSSL_PARAM_BLD *bld, const char *key, + time_t val); +int OSSL_PARAM_BLD_push_double(OSSL_PARAM_BLD *bld, const char *key, + double val); +int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key, + const BIGNUM *bn); +int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key, + const BIGNUM *bn, size_t sz); +int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key, + const char *buf, size_t bsize); +int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key, + char *buf, size_t bsize); +int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key, + const void *buf, size_t bsize); +int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key, + void *buf, size_t bsize); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/params.h b/libs/OpenSSL/include/openssl/params.h index ea94f03f..f8411acf 100644 --- a/libs/OpenSSL/include/openssl/params.h +++ b/libs/OpenSSL/include/openssl/params.h @@ -19,48 +19,55 @@ extern "C" { #endif -#define OSSL_PARAM_UNMODIFIED ((size_t)-1) +#define OSSL_PARAM_UNMODIFIED ((size_t) - 1) -#define OSSL_PARAM_END \ - { \ - NULL, 0, NULL, 0, 0 \ - } +#define OSSL_PARAM_END \ + { \ + NULL, 0, NULL, 0, 0 \ + } -#define OSSL_PARAM_DEFN(key, type, addr, sz) \ - { \ - (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED \ - } +#define OSSL_PARAM_DEFN(key, type, addr, sz) \ + { \ + (key), (type), (addr), (sz), OSSL_PARAM_UNMODIFIED \ + } /* Basic parameter types without return sizes */ -#define OSSL_PARAM_int(key, addr) OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int)) -#define OSSL_PARAM_uint(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(unsigned int)) -#define OSSL_PARAM_long(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int)) -#define OSSL_PARAM_ulong(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(unsigned long int)) -#define OSSL_PARAM_int32(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t)) -#define OSSL_PARAM_uint32(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(uint32_t)) -#define OSSL_PARAM_int64(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t)) -#define OSSL_PARAM_uint64(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(uint64_t)) -#define OSSL_PARAM_size_t(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t)) -#define OSSL_PARAM_time_t(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(time_t)) -#define OSSL_PARAM_double(key, addr) OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double)) +#define OSSL_PARAM_int(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int)) +#define OSSL_PARAM_uint(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(unsigned int)) +#define OSSL_PARAM_long(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int)) +#define OSSL_PARAM_ulong(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(unsigned long int)) +#define OSSL_PARAM_int32(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t)) +#define OSSL_PARAM_uint32(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(uint32_t)) +#define OSSL_PARAM_int64(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t)) +#define OSSL_PARAM_uint64(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(uint64_t)) +#define OSSL_PARAM_size_t(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t)) +#define OSSL_PARAM_time_t(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(time_t)) +#define OSSL_PARAM_double(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double)) -#define OSSL_PARAM_BN(key, bn, sz) OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (bn), (sz)) -#define OSSL_PARAM_utf8_string(key, addr, sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz) -#define OSSL_PARAM_octet_string(key, addr, sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz) +#define OSSL_PARAM_BN(key, bn, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (bn), (sz)) +#define OSSL_PARAM_utf8_string(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz) +#define OSSL_PARAM_octet_string(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz) -#define OSSL_PARAM_utf8_ptr(key, addr, sz) OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, (addr), sz) -#define OSSL_PARAM_octet_ptr(key, addr, sz) OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, (addr), sz) +#define OSSL_PARAM_utf8_ptr(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, (addr), sz) +#define OSSL_PARAM_octet_ptr(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, (addr), sz) /* Search an OSSL_PARAM array for a matching name */ OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key); @@ -77,16 +84,22 @@ OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf); OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf); OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf); OSSL_PARAM OSSL_PARAM_construct_time_t(const char *key, time_t *buf); -OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf); -OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, size_t bsize); -OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, size_t bsize); -OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, size_t bsize); -OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_end(void); -int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to, const OSSL_PARAM *paramdefs, const char *key, - const char *value, size_t value_n, int *found); +int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to, const OSSL_PARAM *paramdefs, + const char *key, const char *value, + size_t value_n, int *found); int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val); int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val); @@ -119,17 +132,20 @@ int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val); int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len); int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val); -int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, size_t *used_len); +int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, + size_t *used_len); int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len); int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val); int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val); -int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, size_t *used_len); +int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, + size_t *used_len); int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, size_t used_len); int OSSL_PARAM_get_utf8_string_ptr(const OSSL_PARAM *p, const char **val); -int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, size_t *used_len); +int OSSL_PARAM_get_octet_string_ptr(const OSSL_PARAM *p, const void **val, + size_t *used_len); int OSSL_PARAM_modified(const OSSL_PARAM *p); void OSSL_PARAM_set_all_unmodified(OSSL_PARAM *p); diff --git a/libs/OpenSSL/include/openssl/pem.h b/libs/OpenSSL/include/openssl/pem.h index 73025191..18a31ade 100644 --- a/libs/OpenSSL/include/openssl/pem.h +++ b/libs/OpenSSL/include/openssl/pem.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_PEM_H +# define HEADER_PEM_H #endif #include @@ -23,7 +23,7 @@ #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -70,130 +70,142 @@ extern "C" { * IMPLEMENT_PEM_rw_cb(...) */ -#define PEM_read_cb_fnsig(name, type, INTYPE, readname) \ - type *PEM_##readname##_##name(INTYPE *out, type **x, pem_password_cb *cb, void *u) -#define PEM_read_cb_ex_fnsig(name, type, INTYPE, readname) \ - type *PEM_##readname##_##name##_ex(INTYPE *out, type **x, pem_password_cb *cb, void *u, \ - OSSL_LIB_CTX *libctx, const char *propq) +#define PEM_read_cb_fnsig(name, type, INTYPE, readname) \ + type *PEM_##readname##_##name(INTYPE *out, type **x, pem_password_cb *cb, \ + void *u) +#define PEM_read_cb_ex_fnsig(name, type, INTYPE, readname) \ + type *PEM_##readname##_##name##_ex(INTYPE *out, type **x, \ + pem_password_cb *cb, void *u, \ + OSSL_LIB_CTX *libctx, const char *propq) -#define PEM_write_fnsig(name, type, OUTTYPE, writename) \ - int PEM_##writename##_##name(OUTTYPE *out, const type *x) -#define PEM_write_cb_fnsig(name, type, OUTTYPE, writename) \ - int PEM_##writename##_##name(OUTTYPE *out, const type *x, const EVP_CIPHER *enc, \ - const unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) -#define PEM_write_ex_fnsig(name, type, OUTTYPE, writename) \ - int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, OSSL_LIB_CTX *libctx, \ - const char *propq) -#define PEM_write_cb_ex_fnsig(name, type, OUTTYPE, writename) \ - int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, const EVP_CIPHER *enc, \ - const unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u, OSSL_LIB_CTX *libctx, const char *propq) +#define PEM_write_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name(OUTTYPE *out, const type *x) +#define PEM_write_cb_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name( \ + OUTTYPE *out, const type *x, const EVP_CIPHER *enc, \ + const unsigned char *kstr, int klen, pem_password_cb *cb, void *u) +#define PEM_write_ex_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name##_ex(OUTTYPE *out, const type *x, \ + OSSL_LIB_CTX *libctx, const char *propq) +#define PEM_write_cb_ex_fnsig(name, type, OUTTYPE, writename) \ + int PEM_##writename##_##name##_ex( \ + OUTTYPE *out, const type *x, const EVP_CIPHER *enc, \ + const unsigned char *kstr, int klen, pem_password_cb *cb, void *u, \ + OSSL_LIB_CTX *libctx, const char *propq) #ifdef OPENSSL_NO_STDIO -# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ -# endif -# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ -# endif +# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ +# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ +# endif +# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ +# endif #else -# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ - type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str, fp, (void **)x, cb, u); \ - } - -# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ - PEM_write_fnsig(name, type, FILE, write) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, x, NULL, NULL, 0, NULL, \ - NULL); \ - } - -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp(name, type, str, asn1) -# endif - -# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ - PEM_write_cb_fnsig(name, type, FILE, write) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, x, enc, kstr, klen, cb, u); \ - } - -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) -# endif -#endif - -#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ - type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp, (void **)x, cb, u); \ +# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ + type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u) \ + { \ + return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str, fp, (void **)x, cb, \ + u); \ } -#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ - PEM_write_fnsig(name, type, BIO, write_bio) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, x, NULL, NULL, 0, NULL, \ - NULL); \ +# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ + PEM_write_fnsig(name, type, FILE, write) \ + { \ + return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, x, NULL, \ + NULL, 0, NULL, NULL); \ } -#ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio(name, type, str, asn1) -#endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) +# endif -#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ - PEM_write_cb_fnsig(name, type, BIO, write_bio) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, x, enc, kstr, klen, cb, u); \ +# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ + PEM_write_cb_fnsig(name, type, FILE, write) \ + { \ + return PEM_ASN1_write((i2d_of_void *)i2d_##asn1, str, out, x, enc, kstr, \ + klen, cb, u); \ } -#ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) +# endif #endif -#define IMPLEMENT_PEM_write(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio(name, type, str, asn1) IMPLEMENT_PEM_write_fp(name, type, str, asn1) +#define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u) \ + { \ + return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str, bp, (void **)x, \ + cb, u); \ + } + +#define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + PEM_write_fnsig(name, type, BIO, write_bio) \ + { \ + return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, x, NULL, \ + NULL, 0, NULL, NULL); \ + } #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) +# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) #endif -#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) +#define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + PEM_write_cb_fnsig(name, type, BIO, write_bio) \ + { \ + return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1, str, out, x, enc, \ + kstr, klen, cb, u); \ + } #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) +# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) #endif -#define IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_read_bio(name, type, str, asn1) IMPLEMENT_PEM_read_fp(name, type, str, asn1) - -#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) IMPLEMENT_PEM_write(name, type, str, asn1) +#define IMPLEMENT_PEM_write(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp(name, type, str, asn1) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) IMPLEMENT_PEM_write_const(name, type, str, asn1) +# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) #endif -#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) IMPLEMENT_PEM_write_cb(name, type, str, asn1) +#define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) + +#ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) +#endif + +#define IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ + IMPLEMENT_PEM_read_fp(name, type, str, asn1) + +#define IMPLEMENT_PEM_rw(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write(name, type, str, asn1) + +#ifndef OPENSSL_NO_DEPRECATED_3_0 +# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_const(name, type, str, asn1) +#endif + +#define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ + IMPLEMENT_PEM_read(name, type, str, asn1) \ + IMPLEMENT_PEM_write_cb(name, type, str, asn1) /* These are the same except they are for the declarations */ @@ -204,171 +216,208 @@ extern "C" { */ #if defined(OPENSSL_NO_STDIO) -# define DECLARE_PEM_read_fp_attr(attr, name, type) /**/ -# define DECLARE_PEM_read_fp_ex_attr(attr, name, type) /**/ -# define DECLARE_PEM_write_fp_attr(attr, name, type) /**/ -# define DECLARE_PEM_write_fp_ex_attr(attr, name, type) /**/ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DECLARE_PEM_write_fp_const_attr(attr, name, type) /**/ -# endif -# define DECLARE_PEM_write_cb_fp_attr(attr, name, type) /**/ -# define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) /**/ +# define DECLARE_PEM_read_fp_attr(attr, name, type) /**/ +# define DECLARE_PEM_read_fp_ex_attr(attr, name, type) /**/ +# define DECLARE_PEM_write_fp_attr(attr, name, type) /**/ +# define DECLARE_PEM_write_fp_ex_attr(attr, name, type) /**/ +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_fp_const_attr(attr, name, type) /**/ +# endif +# define DECLARE_PEM_write_cb_fp_attr(attr, name, type) /**/ +# define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) /**/ #else -# define DECLARE_PEM_read_fp_attr(attr, name, type) \ - attr PEM_read_cb_fnsig(name, type, FILE, read); -# define DECLARE_PEM_read_fp_ex_attr(attr, name, type) \ - attr PEM_read_cb_fnsig(name, type, FILE, read); \ - attr PEM_read_cb_ex_fnsig(name, type, FILE, read); +# define DECLARE_PEM_read_fp_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, FILE, read); +# define DECLARE_PEM_read_fp_ex_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, FILE, read); \ + attr PEM_read_cb_ex_fnsig(name, type, FILE, read); -# define DECLARE_PEM_write_fp_attr(attr, name, type) \ - attr PEM_write_fnsig(name, type, FILE, write); -# define DECLARE_PEM_write_fp_ex_attr(attr, name, type) \ - attr PEM_write_fnsig(name, type, FILE, write); \ - attr PEM_write_ex_fnsig(name, type, FILE, write); -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DECLARE_PEM_write_fp_const_attr(attr, name, type) \ - attr PEM_write_fnsig(name, type, FILE, write); -# endif -# define DECLARE_PEM_write_cb_fp_attr(attr, name, type) \ - attr PEM_write_cb_fnsig(name, type, FILE, write); -# define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) \ - attr PEM_write_cb_fnsig(name, type, FILE, write); \ - attr PEM_write_cb_ex_fnsig(name, type, FILE, write); +# define DECLARE_PEM_write_fp_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, FILE, write); +# define DECLARE_PEM_write_fp_ex_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, FILE, write); \ + attr PEM_write_ex_fnsig(name, type, FILE, write); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_fp_const_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, FILE, write); +# endif +# define DECLARE_PEM_write_cb_fp_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, FILE, write); +# define DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, FILE, write); \ + attr PEM_write_cb_ex_fnsig(name, type, FILE, write); #endif -#define DECLARE_PEM_read_fp(name, type) DECLARE_PEM_read_fp_attr(extern, name, type) -#define DECLARE_PEM_write_fp(name, type) DECLARE_PEM_write_fp_attr(extern, name, type) +#define DECLARE_PEM_read_fp(name, type) \ + DECLARE_PEM_read_fp_attr(extern, name, type) +#define DECLARE_PEM_write_fp(name, type) \ + DECLARE_PEM_write_fp_attr(extern, name, type) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DECLARE_PEM_write_fp_const(name, type) \ - DECLARE_PEM_write_fp_const_attr(extern, name, type) +# define DECLARE_PEM_write_fp_const(name, type) \ + DECLARE_PEM_write_fp_const_attr(extern, name, type) #endif -#define DECLARE_PEM_write_cb_fp(name, type) DECLARE_PEM_write_cb_fp_attr(extern, name, type) +#define DECLARE_PEM_write_cb_fp(name, type) \ + DECLARE_PEM_write_cb_fp_attr(extern, name, type) -#define DECLARE_PEM_read_bio_attr(attr, name, type) \ - attr PEM_read_cb_fnsig(name, type, BIO, read_bio); -#define DECLARE_PEM_read_bio_ex_attr(attr, name, type) \ - attr PEM_read_cb_fnsig(name, type, BIO, read_bio); \ - attr PEM_read_cb_ex_fnsig(name, type, BIO, read_bio); -#define DECLARE_PEM_read_bio(name, type) DECLARE_PEM_read_bio_attr(extern, name, type) -#define DECLARE_PEM_read_bio_ex(name, type) DECLARE_PEM_read_bio_ex_attr(extern, name, type) +#define DECLARE_PEM_read_bio_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, BIO, read_bio); +#define DECLARE_PEM_read_bio_ex_attr(attr, name, type) \ + attr PEM_read_cb_fnsig(name, type, BIO, read_bio); \ + attr PEM_read_cb_ex_fnsig(name, type, BIO, read_bio); +#define DECLARE_PEM_read_bio(name, type) \ + DECLARE_PEM_read_bio_attr(extern, name, type) +#define DECLARE_PEM_read_bio_ex(name, type) \ + DECLARE_PEM_read_bio_ex_attr(extern, name, type) -#define DECLARE_PEM_write_bio_attr(attr, name, type) \ +#define DECLARE_PEM_write_bio_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, BIO, write_bio); +#define DECLARE_PEM_write_bio_ex_attr(attr, name, type) \ + attr PEM_write_fnsig(name, type, BIO, write_bio); \ + attr PEM_write_ex_fnsig(name, type, BIO, write_bio); +#define DECLARE_PEM_write_bio(name, type) \ + DECLARE_PEM_write_bio_attr(extern, name, type) +#define DECLARE_PEM_write_bio_ex(name, type) \ + DECLARE_PEM_write_bio_ex_attr(extern, name, type) + +#ifndef OPENSSL_NO_DEPRECATED_3_0 +# define DECLARE_PEM_write_bio_const_attr(attr, name, type) \ attr PEM_write_fnsig(name, type, BIO, write_bio); -#define DECLARE_PEM_write_bio_ex_attr(attr, name, type) \ - attr PEM_write_fnsig(name, type, BIO, write_bio); \ - attr PEM_write_ex_fnsig(name, type, BIO, write_bio); -#define DECLARE_PEM_write_bio(name, type) DECLARE_PEM_write_bio_attr(extern, name, type) -#define DECLARE_PEM_write_bio_ex(name, type) DECLARE_PEM_write_bio_ex_attr(extern, name, type) - -#ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DECLARE_PEM_write_bio_const_attr(attr, name, type) \ - attr PEM_write_fnsig(name, type, BIO, write_bio); -# define DECLARE_PEM_write_bio_const(name, type) \ - DECLARE_PEM_write_bio_const_attr(extern, name, type) +# define DECLARE_PEM_write_bio_const(name, type) \ + DECLARE_PEM_write_bio_const_attr(extern, name, type) #endif -#define DECLARE_PEM_write_cb_bio_attr(attr, name, type) \ - attr PEM_write_cb_fnsig(name, type, BIO, write_bio); -#define DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \ - attr PEM_write_cb_fnsig(name, type, BIO, write_bio); \ - attr PEM_write_cb_ex_fnsig(name, type, BIO, write_bio); -#define DECLARE_PEM_write_cb_bio(name, type) DECLARE_PEM_write_cb_bio_attr(extern, name, type) -#define DECLARE_PEM_write_cb_ex_bio(name, type) DECLARE_PEM_write_cb_bio_ex_attr(extern, name, type) +#define DECLARE_PEM_write_cb_bio_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, BIO, write_bio); +#define DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \ + attr PEM_write_cb_fnsig(name, type, BIO, write_bio); \ + attr PEM_write_cb_ex_fnsig(name, type, BIO, write_bio); +#define DECLARE_PEM_write_cb_bio(name, type) \ + DECLARE_PEM_write_cb_bio_attr(extern, name, type) +#define DECLARE_PEM_write_cb_ex_bio(name, type) \ + DECLARE_PEM_write_cb_bio_ex_attr(extern, name, type) -#define DECLARE_PEM_write_attr(attr, name, type) \ - DECLARE_PEM_write_bio_attr(attr, name, type) DECLARE_PEM_write_fp_attr(attr, name, type) -#define DECLARE_PEM_write_ex_attr(attr, name, type) \ - DECLARE_PEM_write_bio_ex_attr(attr, name, type) DECLARE_PEM_write_fp_ex_attr(attr, name, type) +#define DECLARE_PEM_write_attr(attr, name, type) \ + DECLARE_PEM_write_bio_attr(attr, name, type) \ + DECLARE_PEM_write_fp_attr(attr, name, type) +#define DECLARE_PEM_write_ex_attr(attr, name, type) \ + DECLARE_PEM_write_bio_ex_attr(attr, name, type) \ + DECLARE_PEM_write_fp_ex_attr(attr, name, type) #define DECLARE_PEM_write(name, type) DECLARE_PEM_write_attr(extern, name, type) -#define DECLARE_PEM_write_ex(name, type) DECLARE_PEM_write_ex_attr(extern, name, type) +#define DECLARE_PEM_write_ex(name, type) \ + DECLARE_PEM_write_ex_attr(extern, name, type) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DECLARE_PEM_write_const_attr(attr, name, type) \ - DECLARE_PEM_write_bio_const_attr(attr, name, type) \ - DECLARE_PEM_write_fp_const_attr(attr, name, type) -# define DECLARE_PEM_write_const(name, type) DECLARE_PEM_write_const_attr(extern, name, type) +# define DECLARE_PEM_write_const_attr(attr, name, type) \ + DECLARE_PEM_write_bio_const_attr(attr, name, type) \ + DECLARE_PEM_write_fp_const_attr(attr, name, type) +# define DECLARE_PEM_write_const(name, type) \ + DECLARE_PEM_write_const_attr(extern, name, type) #endif -#define DECLARE_PEM_write_cb_attr(attr, name, type) \ - DECLARE_PEM_write_cb_bio_attr(attr, name, type) DECLARE_PEM_write_cb_fp_attr(attr, name, type) -#define DECLARE_PEM_write_cb_ex_attr(attr, name, type) \ - DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \ - DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) -#define DECLARE_PEM_write_cb(name, type) DECLARE_PEM_write_cb_attr(extern, name, type) -#define DECLARE_PEM_write_cb_ex(name, type) DECLARE_PEM_write_cb_ex_attr(extern, name, type) -#define DECLARE_PEM_read_attr(attr, name, type) \ - DECLARE_PEM_read_bio_attr(attr, name, type) DECLARE_PEM_read_fp_attr(attr, name, type) -#define DECLARE_PEM_read_ex_attr(attr, name, type) \ - DECLARE_PEM_read_bio_ex_attr(attr, name, type) DECLARE_PEM_read_fp_ex_attr(attr, name, type) +#define DECLARE_PEM_write_cb_attr(attr, name, type) \ + DECLARE_PEM_write_cb_bio_attr(attr, name, type) \ + DECLARE_PEM_write_cb_fp_attr(attr, name, type) +#define DECLARE_PEM_write_cb_ex_attr(attr, name, type) \ + DECLARE_PEM_write_cb_bio_ex_attr(attr, name, type) \ + DECLARE_PEM_write_cb_fp_ex_attr(attr, name, type) +#define DECLARE_PEM_write_cb(name, type) \ + DECLARE_PEM_write_cb_attr(extern, name, type) +#define DECLARE_PEM_write_cb_ex(name, type) \ + DECLARE_PEM_write_cb_ex_attr(extern, name, type) +#define DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_read_bio_attr(attr, name, type) \ + DECLARE_PEM_read_fp_attr(attr, name, type) +#define DECLARE_PEM_read_ex_attr(attr, name, type) \ + DECLARE_PEM_read_bio_ex_attr(attr, name, type) \ + DECLARE_PEM_read_fp_ex_attr(attr, name, type) #define DECLARE_PEM_read(name, type) DECLARE_PEM_read_attr(extern, name, type) -#define DECLARE_PEM_read_ex(name, type) DECLARE_PEM_read_ex_attr(extern, name, type) -#define DECLARE_PEM_rw_attr(attr, name, type) \ - DECLARE_PEM_read_attr(attr, name, type) DECLARE_PEM_write_attr(attr, name, type) -#define DECLARE_PEM_rw_ex_attr(attr, name, type) \ - DECLARE_PEM_read_ex_attr(attr, name, type) DECLARE_PEM_write_ex_attr(attr, name, type) +#define DECLARE_PEM_read_ex(name, type) \ + DECLARE_PEM_read_ex_attr(extern, name, type) +#define DECLARE_PEM_rw_attr(attr, name, type) \ + DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_write_attr(attr, name, type) +#define DECLARE_PEM_rw_ex_attr(attr, name, type) \ + DECLARE_PEM_read_ex_attr(attr, name, type) \ + DECLARE_PEM_write_ex_attr(attr, name, type) #define DECLARE_PEM_rw(name, type) DECLARE_PEM_rw_attr(extern, name, type) #define DECLARE_PEM_rw_ex(name, type) DECLARE_PEM_rw_ex_attr(extern, name, type) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define DECLARE_PEM_rw_const_attr(attr, name, type) \ - DECLARE_PEM_read_attr(attr, name, type) DECLARE_PEM_write_const_attr(attr, name, type) -# define DECLARE_PEM_rw_const(name, type) DECLARE_PEM_rw_const_attr(extern, name, type) +# define DECLARE_PEM_rw_const_attr(attr, name, type) \ + DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_write_const_attr(attr, name, type) +# define DECLARE_PEM_rw_const(name, type) \ + DECLARE_PEM_rw_const_attr(extern, name, type) #endif -#define DECLARE_PEM_rw_cb_attr(attr, name, type) \ - DECLARE_PEM_read_attr(attr, name, type) DECLARE_PEM_write_cb_attr(attr, name, type) -#define DECLARE_PEM_rw_cb_ex_attr(attr, name, type) \ - DECLARE_PEM_read_ex_attr(attr, name, type) DECLARE_PEM_write_cb_ex_attr(attr, name, type) +#define DECLARE_PEM_rw_cb_attr(attr, name, type) \ + DECLARE_PEM_read_attr(attr, name, type) \ + DECLARE_PEM_write_cb_attr(attr, name, type) +#define DECLARE_PEM_rw_cb_ex_attr(attr, name, type) \ + DECLARE_PEM_read_ex_attr(attr, name, type) \ + DECLARE_PEM_write_cb_ex_attr(attr, name, type) #define DECLARE_PEM_rw_cb(name, type) DECLARE_PEM_rw_cb_attr(extern, name, type) -#define DECLARE_PEM_rw_cb_ex(name, type) DECLARE_PEM_rw_cb_ex_attr(extern, name, type) +#define DECLARE_PEM_rw_cb_ex(name, type) \ + DECLARE_PEM_rw_cb_ex_attr(extern, name, type) int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, pem_password_cb *callback, void *u); -int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data, long *len); +int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data, + long *len); #define PEM_FLAG_SECURE 0x1 #define PEM_FLAG_EAY_COMPATIBLE 0x2 #define PEM_FLAG_ONLY_B64 0x4 -int PEM_read_bio_ex(BIO *bp, char **name, char **header, unsigned char **data, long *len, - unsigned int flags); -int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm, const char *name, - BIO *bp, pem_password_cb *cb, void *u); -int PEM_write_bio(BIO *bp, const char *name, const char *hdr, const unsigned char *data, long len); -int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, - pem_password_cb *cb, void *u); -void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, pem_password_cb *cb, - void *u); -int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, const void *x, - const EVP_CIPHER *enc, const unsigned char *kstr, int klen, - pem_password_cb *cb, void *u); +int PEM_read_bio_ex(BIO *bp, char **name, char **header, unsigned char **data, + long *len, unsigned int flags); +int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm, + const char *name, BIO *bp, pem_password_cb *cb, + void *u); +int PEM_write_bio(BIO *bp, const char *name, const char *hdr, + const unsigned char *data, long len); +int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, + const char *name, BIO *bp, pem_password_cb *cb, void *u); +void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, + pem_password_cb *cb, void *u); +int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, + const void *x, const EVP_CIPHER *enc, + const unsigned char *kstr, int klen, pem_password_cb *cb, + void *u); STACK_OF(X509_INFO) -*PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, void *u); +*PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, + void *u); STACK_OF(X509_INFO) -*PEM_X509_INFO_read_bio_ex(BIO *bp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq); +*PEM_X509_INFO_read_bio_ex(BIO *bp, STACK_OF(X509_INFO) * sk, + pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx, + const char *propq); int PEM_X509_INFO_write_bio(BIO *bp, const X509_INFO *xi, EVP_CIPHER *enc, - const unsigned char *kstr, int klen, pem_password_cb *cd, void *u); + const unsigned char *kstr, int klen, + pem_password_cb *cd, void *u); #ifndef OPENSSL_NO_STDIO -int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, long *len); -int PEM_write(FILE *fp, const char *name, const char *hdr, const unsigned char *data, long len); -void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, pem_password_cb *cb, - void *u); +int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, + long *len); +int PEM_write(FILE *fp, const char *name, const char *hdr, + const unsigned char *data, long len); +void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, + pem_password_cb *cb, void *u); int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, const void *x, const EVP_CIPHER *enc, const unsigned char *kstr, int klen, pem_password_cb *callback, void *u); STACK_OF(X509_INFO) -*PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, void *u); +*PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, + void *u); STACK_OF(X509_INFO) -*PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq); +*PEM_X509_INFO_read_ex(FILE *fp, STACK_OF(X509_INFO) * sk, pem_password_cb *cb, + void *u, OSSL_LIB_CTX *libctx, const char *propq); #endif int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); int PEM_SignUpdate(EVP_MD_CTX *ctx, const unsigned char *d, unsigned int cnt); -int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey); +int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, + EVP_PKEY *pkey); /* The default pem_password_cb that's used internally */ int PEM_def_callback(char *buf, int num, int rwflag, void *userdata); @@ -377,76 +426,99 @@ void PEM_dek_info(char *buf, const char *type, int len, const char *str); #include -DECLARE_PEM_rw(X509, X509) DECLARE_PEM_rw(X509_AUX, X509) DECLARE_PEM_rw(X509_REQ, X509_REQ) - DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) DECLARE_PEM_rw(X509_CRL, X509_CRL) DECLARE_PEM_rw( - X509_PUBKEY, X509_PUBKEY) DECLARE_PEM_rw(PKCS7, - PKCS7) DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, - NETSCAPE_CERT_SEQUENCE) - DECLARE_PEM_rw(PKCS8, X509_SIG) DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) +DECLARE_PEM_rw(X509, X509) DECLARE_PEM_rw(X509_AUX, X509) DECLARE_PEM_rw( + X509_REQ, X509_REQ) DECLARE_PEM_write(X509_REQ_NEW, + X509_REQ) DECLARE_PEM_rw(X509_CRL, + X509_CRL) + DECLARE_PEM_rw(X509_PUBKEY, X509_PUBKEY) DECLARE_PEM_rw( + PKCS7, PKCS7) DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, + NETSCAPE_CERT_SEQUENCE) + DECLARE_PEM_rw(PKCS8, X509_SIG) DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, + PKCS8_PRIV_KEY_INFO) #ifndef OPENSSL_NO_DEPRECATED_3_0 - DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, RSAPrivateKey, RSA) - DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSAPublicKey, - RSA) DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSA_PUBKEY, RSA) + DECLARE_PEM_rw_cb_attr( + OSSL_DEPRECATEDIN_3_0, RSAPrivateKey, + RSA) DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSAPublicKey, + RSA) DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, + RSA_PUBKEY, + RSA) #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_DSA - DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, DSAPrivateKey, DSA) - DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSA_PUBKEY, - DSA) DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, - DSAparams, DSA) -# endif +# ifndef OPENSSL_NO_DSA + DECLARE_PEM_rw_cb_attr( + OSSL_DEPRECATEDIN_3_0, DSAPrivateKey, + DSA) DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSA_PUBKEY, + DSA) + DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DSAparams, DSA) +# endif #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_EC - DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, ECPKParameters, EC_GROUP) - DECLARE_PEM_rw_cb_attr(OSSL_DEPRECATEDIN_3_0, ECPrivateKey, EC_KEY) - DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, EC_PUBKEY, EC_KEY) -# endif +# ifndef OPENSSL_NO_EC + DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, + ECPKParameters, EC_GROUP) + DECLARE_PEM_rw_cb_attr( + OSSL_DEPRECATEDIN_3_0, ECPrivateKey, + EC_KEY) DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, + EC_PUBKEY, EC_KEY) +# endif #endif #ifndef OPENSSL_NO_DH -# ifndef OPENSSL_NO_DEPRECATED_3_0 - DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, DHparams, DH) - DECLARE_PEM_write_attr(OSSL_DEPRECATEDIN_3_0, DHxparams, - DH) -# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 + DECLARE_PEM_rw_attr( + OSSL_DEPRECATEDIN_3_0, DHparams, + DH) DECLARE_PEM_write_attr(OSSL_DEPRECATEDIN_3_0, + DHxparams, DH) +# endif #endif - DECLARE_PEM_rw_cb_ex(PrivateKey, EVP_PKEY) - DECLARE_PEM_rw_ex(PUBKEY, EVP_PKEY) + DECLARE_PEM_rw_cb_ex( + PrivateKey, + EVP_PKEY) DECLARE_PEM_rw_ex(PUBKEY, + EVP_PKEY) - int PEM_write_bio_PrivateKey_traditional( - BIO *bp, const EVP_PKEY *x, - const EVP_CIPHER *enc, - const unsigned char *kstr, int klen, - pem_password_cb *cb, void *u); + int PEM_write_bio_PrivateKey_traditional( + BIO *bp, const EVP_PKEY *x, + const EVP_CIPHER *enc, + const unsigned char *kstr, int klen, + pem_password_cb *cb, void *u); /* Why do these take a signed char *kstr? */ -int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid, const char *kstr, - int klen, pem_password_cb *cb, void *u); -int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, const EVP_CIPHER *, const char *kstr, - int klen, pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, - int klen, pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid, const char *kstr, int klen, - pem_password_cb *cb, void *u); -EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int PEM_write_bio_PKCS8PrivateKey(BIO *, const EVP_PKEY *, const EVP_CIPHER *, + const char *kstr, int klen, + pem_password_cb *cb, void *u); +int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc, + const char *kstr, int klen, pem_password_cb *cb, + void *u); +int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, pem_password_cb *cb, + void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, + void *u); #ifndef OPENSSL_NO_STDIO -int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, - int klen, pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid, const char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid, const char *kstr, int klen, +int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, + const char *kstr, int klen, pem_password_cb *cb, + void *u); +int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, pem_password_cb *cb, + void *u); +int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid, + const char *kstr, int klen, pem_password_cb *cb, void *u); -EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); +EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, + void *u); -int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, - int klen, pem_password_cb *cd, void *u); +int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, + const EVP_CIPHER *enc, const char *kstr, int klen, + pem_password_cb *cd, void *u); #endif -EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x, OSSL_LIB_CTX *libctx, - const char *propq); +EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x, + OSSL_LIB_CTX *libctx, const char *propq); EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); int PEM_write_bio_Parameters(BIO *bp, const EVP_PKEY *x); @@ -457,11 +529,13 @@ EVP_PKEY *b2i_PublicKey_bio(BIO *in); int i2b_PrivateKey_bio(BIO *out, const EVP_PKEY *pk); int i2b_PublicKey_bio(BIO *out, const EVP_PKEY *pk); EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); -EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx, - const char *propq); -int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel, pem_password_cb *cb, void *u); -int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel, pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u, + OSSL_LIB_CTX *libctx, const char *propq); +int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel, pem_password_cb *cb, + void *u); +int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel, + pem_password_cb *cb, void *u, OSSL_LIB_CTX *libctx, + const char *propq); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/pem2.h b/libs/OpenSSL/include/openssl/pem2.h index 8e05c438..6a009a57 100644 --- a/libs/OpenSSL/include/openssl/pem2.h +++ b/libs/OpenSSL/include/openssl/pem2.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_PEM2_H +# define HEADER_PEM2_H #endif #include #endif diff --git a/libs/OpenSSL/include/openssl/pkcs12.h b/libs/OpenSSL/include/openssl/pkcs12.h index d0bf8980..ce652dbb 100644 --- a/libs/OpenSSL/include/openssl/pkcs12.h +++ b/libs/OpenSSL/include/openssl/pkcs12.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_PKCS12_H +# define HEADER_PKCS12_H #endif #include @@ -24,7 +24,7 @@ #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -37,12 +37,13 @@ extern "C" { /* Default iteration count */ #ifndef PKCS12_DEFAULT_ITER -# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER +# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER #endif #define PKCS12_MAC_KEY_LENGTH 20 -/* The macro is expected to be used only internally. Kept for backwards compatibility. */ +/* The macro is expected to be used only internally. Kept for backwards + * compatibility. */ #define PKCS12_SALT_LEN 8 /* It's not clear if these are actually needed... */ @@ -61,61 +62,77 @@ typedef struct PKCS12_st PKCS12; typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG; SKM_DEFINE_STACK_OF_INTERNAL(PKCS12_SAFEBAG, PKCS12_SAFEBAG, PKCS12_SAFEBAG) -#define sk_PKCS12_SAFEBAG_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk)) -#define sk_PKCS12_SAFEBAG_value(sk, idx) \ - ((PKCS12_SAFEBAG *)OPENSSL_sk_value(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk), (idx))) -#define sk_PKCS12_SAFEBAG_new(cmp) \ - ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new(ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp))) -#define sk_PKCS12_SAFEBAG_new_null() ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new_null()) -#define sk_PKCS12_SAFEBAG_new_reserve(cmp, n) \ - ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new_reserve( \ - ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp), (n))) -#define sk_PKCS12_SAFEBAG_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (n)) -#define sk_PKCS12_SAFEBAG_free(sk) OPENSSL_sk_free(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) -#define sk_PKCS12_SAFEBAG_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) -#define sk_PKCS12_SAFEBAG_delete(sk, i) \ - ((PKCS12_SAFEBAG *)OPENSSL_sk_delete(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (i))) -#define sk_PKCS12_SAFEBAG_delete_ptr(sk, ptr) \ - ((PKCS12_SAFEBAG *)OPENSSL_sk_delete_ptr(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ - ossl_check_PKCS12_SAFEBAG_type(ptr))) -#define sk_PKCS12_SAFEBAG_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) -#define sk_PKCS12_SAFEBAG_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) -#define sk_PKCS12_SAFEBAG_pop(sk) \ - ((PKCS12_SAFEBAG *)OPENSSL_sk_pop(ossl_check_PKCS12_SAFEBAG_sk_type(sk))) -#define sk_PKCS12_SAFEBAG_shift(sk) \ - ((PKCS12_SAFEBAG *)OPENSSL_sk_shift(ossl_check_PKCS12_SAFEBAG_sk_type(sk))) -#define sk_PKCS12_SAFEBAG_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ - ossl_check_PKCS12_SAFEBAG_freefunc_type(freefunc)) -#define sk_PKCS12_SAFEBAG_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr), \ - (idx)) -#define sk_PKCS12_SAFEBAG_set(sk, idx, ptr) \ - ((PKCS12_SAFEBAG *)OPENSSL_sk_set(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (idx), \ - ossl_check_PKCS12_SAFEBAG_type(ptr))) -#define sk_PKCS12_SAFEBAG_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) -#define sk_PKCS12_SAFEBAG_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_type(ptr)) -#define sk_PKCS12_SAFEBAG_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ - ossl_check_PKCS12_SAFEBAG_type(ptr), pnum) -#define sk_PKCS12_SAFEBAG_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) -#define sk_PKCS12_SAFEBAG_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk)) -#define sk_PKCS12_SAFEBAG_dup(sk) \ - ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_dup(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk))) -#define sk_PKCS12_SAFEBAG_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_PKCS12_SAFEBAG_sk_type(sk), \ - ossl_check_PKCS12_SAFEBAG_copyfunc_type(copyfunc), \ - ossl_check_PKCS12_SAFEBAG_freefunc_type(freefunc))) -#define sk_PKCS12_SAFEBAG_set_cmp_func(sk, cmp) \ - ((sk_PKCS12_SAFEBAG_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_PKCS12_SAFEBAG_sk_type(sk), ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp))) +#define sk_PKCS12_SAFEBAG_num(sk) \ + OPENSSL_sk_num(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_value(sk, idx) \ + ((PKCS12_SAFEBAG *)OPENSSL_sk_value( \ + ossl_check_const_PKCS12_SAFEBAG_sk_type(sk), (idx))) +#define sk_PKCS12_SAFEBAG_new(cmp) \ + ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new( \ + ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp))) +#define sk_PKCS12_SAFEBAG_new_null() \ + ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new_null()) +#define sk_PKCS12_SAFEBAG_new_reserve(cmp, n) \ + ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_new_reserve( \ + ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp), (n))) +#define sk_PKCS12_SAFEBAG_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_PKCS12_SAFEBAG_sk_type(sk), (n)) +#define sk_PKCS12_SAFEBAG_free(sk) \ + OPENSSL_sk_free(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_zero(sk) \ + OPENSSL_sk_zero(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_delete(sk, i) \ + ((PKCS12_SAFEBAG *)OPENSSL_sk_delete(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + (i))) +#define sk_PKCS12_SAFEBAG_delete_ptr(sk, ptr) \ + ((PKCS12_SAFEBAG *)OPENSSL_sk_delete_ptr( \ + ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr))) +#define sk_PKCS12_SAFEBAG_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_pop(sk) \ + ((PKCS12_SAFEBAG *)OPENSSL_sk_pop(ossl_check_PKCS12_SAFEBAG_sk_type(sk))) +#define sk_PKCS12_SAFEBAG_shift(sk) \ + ((PKCS12_SAFEBAG *)OPENSSL_sk_shift(ossl_check_PKCS12_SAFEBAG_sk_type(sk))) +#define sk_PKCS12_SAFEBAG_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_freefunc_type(freefunc)) +#define sk_PKCS12_SAFEBAG_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr), (idx)) +#define sk_PKCS12_SAFEBAG_set(sk, idx, ptr) \ + ((PKCS12_SAFEBAG *)OPENSSL_sk_set(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + (idx), \ + ossl_check_PKCS12_SAFEBAG_type(ptr))) +#define sk_PKCS12_SAFEBAG_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr)) +#define sk_PKCS12_SAFEBAG_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_type(ptr), pnum) +#define sk_PKCS12_SAFEBAG_sort(sk) \ + OPENSSL_sk_sort(ossl_check_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_PKCS12_SAFEBAG_sk_type(sk)) +#define sk_PKCS12_SAFEBAG_dup(sk) \ + ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_dup( \ + ossl_check_const_PKCS12_SAFEBAG_sk_type(sk))) +#define sk_PKCS12_SAFEBAG_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(PKCS12_SAFEBAG) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_copyfunc_type(copyfunc), \ + ossl_check_PKCS12_SAFEBAG_freefunc_type(freefunc))) +#define sk_PKCS12_SAFEBAG_set_cmp_func(sk, cmp) \ + ((sk_PKCS12_SAFEBAG_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_PKCS12_SAFEBAG_sk_type(sk), \ + ossl_check_PKCS12_SAFEBAG_compfunc_type(cmp))) typedef struct pkcs12_bag_st PKCS12_BAGS; @@ -126,31 +143,33 @@ typedef struct pkcs12_bag_st PKCS12_BAGS; #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define M_PKCS12_bag_type PKCS12_bag_type -# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type -# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type +# define M_PKCS12_bag_type PKCS12_bag_type +# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type +# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type -# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert -# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl -# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid -# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid -# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert -# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl -# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf -# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt +# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert +# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl +# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid +# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid +# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert +# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl +# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf +# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt #endif #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -OSSL_DEPRECATEDIN_1_1_0 ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid); +OSSL_DEPRECATEDIN_1_1_0 ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, + int attr_nid); #endif ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid); int PKCS12_mac_present(const PKCS12 *p12); void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac, const X509_ALGOR **pmacalg, - const ASN1_OCTET_STRING **psalt, const ASN1_INTEGER **piter, - const PKCS12 *p12); + const ASN1_OCTET_STRING **psalt, + const ASN1_INTEGER **piter, const PKCS12 *p12); -const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag, int attr_nid); +const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag, + int attr_nid); const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag); int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag); int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag); @@ -159,118 +178,157 @@ const ASN1_OBJECT *PKCS12_SAFEBAG_get0_bag_type(const PKCS12_SAFEBAG *bag); X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag); X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag); -const STACK_OF(PKCS12_SAFEBAG) * PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag); +const STACK_OF(PKCS12_SAFEBAG) + * PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag); const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag); const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag); PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509); PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_secret(int type, int vtype, const unsigned char *value, +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_secret(int type, int vtype, + const unsigned char *value, int len); PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8); PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8inf); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(int pbe_nid, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8inf, - OSSL_LIB_CTX *ctx, const char *propq); +PKCS12_SAFEBAG * +PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8inf); +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt_ex( + int pbe_nid, const char *pass, int passlen, unsigned char *salt, + int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *ctx, + const char *propq); -PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, int nid2); -PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, int passlen); -PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_ex(const X509_SIG *p8, const char *pass, int passlen, - OSSL_LIB_CTX *ctx, const char *propq); -PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, const char *pass, int passlen); -PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey_ex(const PKCS12_SAFEBAG *bag, const char *pass, - int passlen, OSSL_LIB_CTX *ctx, const char *propq); -X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8); -X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8, +PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, + int nid1, int nid2); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, + int passlen); +PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_ex(const X509_SIG *p8, const char *pass, + int passlen, OSSL_LIB_CTX *ctx, + const char *propq); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, + const char *pass, int passlen); +PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey_ex(const PKCS12_SAFEBAG *bag, + const char *pass, int passlen, + OSSL_LIB_CTX *ctx, + const char *propq); +X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, + int passlen, unsigned char *salt, int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8); +X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher, + const char *pass, int passlen, unsigned char *salt, + int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *ctx, const char *propq); -X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen, PKCS8_PRIV_KEY_INFO *p8inf, - X509_ALGOR *pbe); -X509_SIG *PKCS8_set0_pbe_ex(const char *pass, int passlen, PKCS8_PRIV_KEY_INFO *p8inf, - X509_ALGOR *pbe, OSSL_LIB_CTX *ctx, const char *propq); +X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen, + PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe); +X509_SIG *PKCS8_set0_pbe_ex(const char *pass, int passlen, + PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe, + OSSL_LIB_CTX *ctx, const char *propq); PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) * sk); STACK_OF(PKCS12_SAFEBAG) * PKCS12_unpack_p7data(PKCS7 *p7); -PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, unsigned char *salt, - int saltlen, int iter, STACK_OF(PKCS12_SAFEBAG) * bags); -PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen, unsigned char *salt, - int saltlen, int iter, STACK_OF(PKCS12_SAFEBAG) * bags, +PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) * bags); +PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + STACK_OF(PKCS12_SAFEBAG) * bags, OSSL_LIB_CTX *ctx, const char *propq); -STACK_OF(PKCS12_SAFEBAG) * PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); +STACK_OF(PKCS12_SAFEBAG) + * PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen); int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) * safes); STACK_OF(PKCS7) * PKCS12_unpack_authsafes(const PKCS12 *p12); -int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); -int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen); -int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name, int namelen); +int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, + int namelen); +int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, + int namelen); +int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name, + int namelen); int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen); -int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, int namelen); -int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type, const unsigned char *bytes, - int len); +int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, + int namelen); +int PKCS12_add1_attr_by_NID(PKCS12_SAFEBAG *bag, int nid, int type, + const unsigned char *bytes, int len); int PKCS12_add1_attr_by_txt(PKCS12_SAFEBAG *bag, const char *attrname, int type, const unsigned char *bytes, int len); int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); -ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) * attrs, int attr_nid); +ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) * attrs, + int attr_nid); char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); -const STACK_OF(X509_ATTRIBUTE) * PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag); -void PKCS12_SAFEBAG_set0_attrs(PKCS12_SAFEBAG *bag, STACK_OF(X509_ATTRIBUTE) * attrs); -unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, int passlen, - const unsigned char *in, int inlen, unsigned char **data, - int *datalen, int en_de); -unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor, const char *pass, int passlen, - const unsigned char *in, int inlen, unsigned char **data, - int *datalen, int en_de, OSSL_LIB_CTX *libctx, - const char *propq); -void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, const char *pass, - int passlen, const ASN1_OCTET_STRING *oct, int zbuf); -void *PKCS12_item_decrypt_d2i_ex(const X509_ALGOR *algor, const ASN1_ITEM *it, const char *pass, - int passlen, const ASN1_OCTET_STRING *oct, int zbuf, +const STACK_OF(X509_ATTRIBUTE) + * PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag); +void PKCS12_SAFEBAG_set0_attrs(PKCS12_SAFEBAG *bag, + STACK_OF(X509_ATTRIBUTE) * attrs); +unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, + int passlen, const unsigned char *in, int inlen, + unsigned char **data, int *datalen, int en_de); +unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor, const char *pass, + int passlen, const unsigned char *in, + int inlen, unsigned char **data, + int *datalen, int en_de, + OSSL_LIB_CTX *libctx, const char *propq); +void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + const ASN1_OCTET_STRING *oct, int zbuf); +void *PKCS12_item_decrypt_d2i_ex(const X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, + const ASN1_OCTET_STRING *oct, int zbuf, OSSL_LIB_CTX *libctx, const char *propq); -ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, const char *pass, - int passlen, void *obj, int zbuf); -ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt_ex(X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, void *obj, int zbuf, - OSSL_LIB_CTX *ctx, const char *propq); +ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, + const ASN1_ITEM *it, + const char *pass, int passlen, + void *obj, int zbuf); +ASN1_OCTET_STRING * +PKCS12_item_i2d_encrypt_ex(X509_ALGOR *algor, const ASN1_ITEM *it, + const char *pass, int passlen, void *obj, int zbuf, + OSSL_LIB_CTX *ctx, const char *propq); PKCS12 *PKCS12_init(int mode); PKCS12 *PKCS12_init_ex(int mode, OSSL_LIB_CTX *ctx, const char *propq); -int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, int saltlen, int id, - int iter, int n, unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_asc_ex(const char *pass, int passlen, unsigned char *salt, int saltlen, int id, - int iter, int n, unsigned char *out, const EVP_MD *md_type, +int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, unsigned char *out, + const EVP_MD *md_type); +int PKCS12_key_gen_asc_ex(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type, OSSL_LIB_CTX *ctx, const char *propq); -int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, - int iter, int n, unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_uni_ex(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, - int id, int iter, int n, unsigned char *out, const EVP_MD *md_type, +int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, unsigned char *out, + const EVP_MD *md_type); +int PKCS12_key_gen_uni_ex(unsigned char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type, OSSL_LIB_CTX *ctx, const char *propq); -int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, int saltlen, int id, - int iter, int n, unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_utf8_ex(const char *pass, int passlen, unsigned char *salt, int saltlen, int id, - int iter, int n, unsigned char *out, const EVP_MD *md_type, +int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type); +int PKCS12_key_gen_utf8_ex(const char *pass, int passlen, unsigned char *salt, + int saltlen, int id, int iter, int n, + unsigned char *out, const EVP_MD *md_type, OSSL_LIB_CTX *ctx, const char *propq); -int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md_type, int en_de); -int PKCS12_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md_type, int en_de, +int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md_type, int en_de); +int PKCS12_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, + ASN1_TYPE *param, const EVP_CIPHER *cipher, + const EVP_MD *md_type, int en_de, OSSL_LIB_CTX *libctx, const char *propq); -int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, unsigned char *mac, - unsigned int *maclen); +int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *mac, unsigned int *maclen); int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); -int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, unsigned char *salt, int saltlen, - int iter, const EVP_MD *md_type); +int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, + unsigned char *salt, int saltlen, int iter, + const EVP_MD *md_type); int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, const EVP_MD *md_type); -unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); +unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, + int *unilen); char *OPENSSL_uni2asc(const unsigned char *uni, int unilen); -unsigned char *OPENSSL_utf82uni(const char *asc, int asclen, unsigned char **uni, int *unilen); +unsigned char *OPENSSL_utf82uni(const char *asc, int asclen, + unsigned char **uni, int *unilen); char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen); DECLARE_ASN1_FUNCTIONS(PKCS12) @@ -282,36 +340,43 @@ DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) void PKCS12_PBE_add(void); -int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, STACK_OF(X509) * *ca); +int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, + STACK_OF(X509) * *ca); typedef int PKCS12_create_cb(PKCS12_SAFEBAG *bag, void *cbarg); -PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, - STACK_OF(X509) * ca, int nid_key, int nid_cert, int iter, int mac_iter, - int keytype); -PKCS12 *PKCS12_create_ex(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, - STACK_OF(X509) * ca, int nid_key, int nid_cert, int iter, int mac_iter, - int keytype, OSSL_LIB_CTX *ctx, const char *propq); -PKCS12 *PKCS12_create_ex2(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, - STACK_OF(X509) * ca, int nid_key, int nid_cert, int iter, int mac_iter, - int keytype, OSSL_LIB_CTX *ctx, const char *propq, PKCS12_create_cb *cb, - void *cbarg); +PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) * ca, int nid_key, + int nid_cert, int iter, int mac_iter, int keytype); +PKCS12 *PKCS12_create_ex(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) * ca, int nid_key, + int nid_cert, int iter, int mac_iter, int keytype, + OSSL_LIB_CTX *ctx, const char *propq); +PKCS12 *PKCS12_create_ex2(const char *pass, const char *name, EVP_PKEY *pkey, + X509 *cert, STACK_OF(X509) * ca, int nid_key, + int nid_cert, int iter, int mac_iter, int keytype, + OSSL_LIB_CTX *ctx, const char *propq, + PKCS12_create_cb *cb, void *cbarg); PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) * *pbags, X509 *cert); -PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) * *pbags, EVP_PKEY *key, int key_usage, - int iter, int key_nid, const char *pass); -PKCS12_SAFEBAG *PKCS12_add_key_ex(STACK_OF(PKCS12_SAFEBAG) * *pbags, EVP_PKEY *key, int key_usage, - int iter, int key_nid, const char *pass, OSSL_LIB_CTX *ctx, - const char *propq); +PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) * *pbags, EVP_PKEY *key, + int key_usage, int iter, int key_nid, + const char *pass); +PKCS12_SAFEBAG *PKCS12_add_key_ex(STACK_OF(PKCS12_SAFEBAG) * *pbags, + EVP_PKEY *key, int key_usage, int iter, + int key_nid, const char *pass, + OSSL_LIB_CTX *ctx, const char *propq); -PKCS12_SAFEBAG *PKCS12_add_secret(STACK_OF(PKCS12_SAFEBAG) * *pbags, int nid_type, - const unsigned char *value, int len); -int PKCS12_add_safe(STACK_OF(PKCS7) * *psafes, STACK_OF(PKCS12_SAFEBAG) * bags, int safe_nid, - int iter, const char *pass); -int PKCS12_add_safe_ex(STACK_OF(PKCS7) * *psafes, STACK_OF(PKCS12_SAFEBAG) * bags, int safe_nid, - int iter, const char *pass, OSSL_LIB_CTX *ctx, const char *propq); +PKCS12_SAFEBAG *PKCS12_add_secret(STACK_OF(PKCS12_SAFEBAG) * *pbags, + int nid_type, const unsigned char *value, + int len); +int PKCS12_add_safe(STACK_OF(PKCS7) * *psafes, STACK_OF(PKCS12_SAFEBAG) * bags, + int safe_nid, int iter, const char *pass); +int PKCS12_add_safe_ex(STACK_OF(PKCS7) * *psafes, + STACK_OF(PKCS12_SAFEBAG) * bags, int safe_nid, int iter, + const char *pass, OSSL_LIB_CTX *ctx, const char *propq); PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) * safes, int p7_nid); -PKCS12 *PKCS12_add_safes_ex(STACK_OF(PKCS7) * safes, int p7_nid, OSSL_LIB_CTX *ctx, - const char *propq); +PKCS12 *PKCS12_add_safes_ex(STACK_OF(PKCS7) * safes, int p7_nid, + OSSL_LIB_CTX *ctx, const char *propq); int i2d_PKCS12_bio(BIO *bp, const PKCS12 *p12); #ifndef OPENSSL_NO_STDIO diff --git a/libs/OpenSSL/include/openssl/pkcs7.h b/libs/OpenSSL/include/openssl/pkcs7.h index 2971e400..98c59457 100644 --- a/libs/OpenSSL/include/openssl/pkcs7.h +++ b/libs/OpenSSL/include/openssl/pkcs7.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_PKCS7_H +# define HEADER_PKCS7_H #endif #include @@ -27,7 +27,7 @@ #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -43,167 +43,197 @@ Key_Encryption_ID rsaEncryption typedef struct PKCS7_CTX_st { - OSSL_LIB_CTX *libctx; - char *propq; + OSSL_LIB_CTX *libctx; + char *propq; } PKCS7_CTX; typedef struct pkcs7_issuer_and_serial_st { - X509_NAME *issuer; - ASN1_INTEGER *serial; + X509_NAME *issuer; + ASN1_INTEGER *serial; } PKCS7_ISSUER_AND_SERIAL; typedef struct pkcs7_signer_info_st { - ASN1_INTEGER *version; /* version 1 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *digest_alg; - STACK_OF(X509_ATTRIBUTE) * auth_attr; /* [ 0 ] */ - X509_ALGOR *digest_enc_alg; - ASN1_OCTET_STRING *enc_digest; - STACK_OF(X509_ATTRIBUTE) * unauth_attr; /* [ 1 ] */ - /* The private key to sign with */ - EVP_PKEY *pkey; - const PKCS7_CTX *ctx; + ASN1_INTEGER *version; /* version 1 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *digest_alg; + STACK_OF(X509_ATTRIBUTE) * auth_attr; /* [ 0 ] */ + X509_ALGOR *digest_enc_alg; + ASN1_OCTET_STRING *enc_digest; + STACK_OF(X509_ATTRIBUTE) * unauth_attr; /* [ 1 ] */ + /* The private key to sign with */ + EVP_PKEY *pkey; + const PKCS7_CTX *ctx; } PKCS7_SIGNER_INFO; -SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO) -#define sk_PKCS7_SIGNER_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) -#define sk_PKCS7_SIGNER_INFO_value(sk, idx) \ - ((PKCS7_SIGNER_INFO *)OPENSSL_sk_value(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), (idx))) -#define sk_PKCS7_SIGNER_INFO_new(cmp) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new(ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) -#define sk_PKCS7_SIGNER_INFO_new_null() ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_null()) -#define sk_PKCS7_SIGNER_INFO_new_reserve(cmp, n) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_reserve( \ - ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp), (n))) -#define sk_PKCS7_SIGNER_INFO_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (n)) -#define sk_PKCS7_SIGNER_INFO_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) -#define sk_PKCS7_SIGNER_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) -#define sk_PKCS7_SIGNER_INFO_delete(sk, i) \ - ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (i))) -#define sk_PKCS7_SIGNER_INFO_delete_ptr(sk, ptr) \ - ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr))) -#define sk_PKCS7_SIGNER_INFO_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr)) -#define sk_PKCS7_SIGNER_INFO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr)) -#define sk_PKCS7_SIGNER_INFO_pop(sk) \ - ((PKCS7_SIGNER_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) -#define sk_PKCS7_SIGNER_INFO_shift(sk) \ - ((PKCS7_SIGNER_INFO *)OPENSSL_sk_shift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) -#define sk_PKCS7_SIGNER_INFO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc)) -#define sk_PKCS7_SIGNER_INFO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr), (idx)) -#define sk_PKCS7_SIGNER_INFO_set(sk, idx, ptr) \ - ((PKCS7_SIGNER_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (idx), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr))) -#define sk_PKCS7_SIGNER_INFO_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr)) -#define sk_PKCS7_SIGNER_INFO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr)) -#define sk_PKCS7_SIGNER_INFO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_type(ptr), pnum) -#define sk_PKCS7_SIGNER_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) -#define sk_PKCS7_SIGNER_INFO_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) -#define sk_PKCS7_SIGNER_INFO_dup(sk) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk))) -#define sk_PKCS7_SIGNER_INFO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_copyfunc_type(copyfunc), \ - ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc))) -#define sk_PKCS7_SIGNER_INFO_set_cmp_func(sk, cmp) \ - ((sk_PKCS7_SIGNER_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ - ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO, + PKCS7_SIGNER_INFO) +#define sk_PKCS7_SIGNER_INFO_num(sk) \ + OPENSSL_sk_num(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_value(sk, idx) \ + ((PKCS7_SIGNER_INFO *)OPENSSL_sk_value( \ + ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), (idx))) +#define sk_PKCS7_SIGNER_INFO_new(cmp) \ + ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new( \ + ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) +#define sk_PKCS7_SIGNER_INFO_new_null() \ + ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_null()) +#define sk_PKCS7_SIGNER_INFO_new_reserve(cmp, n) \ + ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_reserve( \ + ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp), (n))) +#define sk_PKCS7_SIGNER_INFO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (n)) +#define sk_PKCS7_SIGNER_INFO_free(sk) \ + OPENSSL_sk_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_zero(sk) \ + OPENSSL_sk_zero(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_delete(sk, i) \ + ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete( \ + ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (i))) +#define sk_PKCS7_SIGNER_INFO_delete_ptr(sk, ptr) \ + ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete_ptr( \ + ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr))) +#define sk_PKCS7_SIGNER_INFO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_pop(sk) \ + ((PKCS7_SIGNER_INFO *)OPENSSL_sk_pop( \ + ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) +#define sk_PKCS7_SIGNER_INFO_shift(sk) \ + ((PKCS7_SIGNER_INFO *)OPENSSL_sk_shift( \ + ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) +#define sk_PKCS7_SIGNER_INFO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc)) +#define sk_PKCS7_SIGNER_INFO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr), (idx)) +#define sk_PKCS7_SIGNER_INFO_set(sk, idx, ptr) \ + ((PKCS7_SIGNER_INFO *)OPENSSL_sk_set( \ + ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (idx), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr))) +#define sk_PKCS7_SIGNER_INFO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr)) +#define sk_PKCS7_SIGNER_INFO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_type(ptr), pnum) +#define sk_PKCS7_SIGNER_INFO_sort(sk) \ + OPENSSL_sk_sort(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) +#define sk_PKCS7_SIGNER_INFO_dup(sk) \ + ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_dup( \ + ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk))) +#define sk_PKCS7_SIGNER_INFO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_copyfunc_type(copyfunc), \ + ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc))) +#define sk_PKCS7_SIGNER_INFO_set_cmp_func(sk, cmp) \ + ((sk_PKCS7_SIGNER_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), \ + ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) typedef struct pkcs7_recip_info_st { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *key_enc_algor; - ASN1_OCTET_STRING *enc_key; - X509 *cert; /* get the pub-key from this */ - const PKCS7_CTX *ctx; + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; + X509_ALGOR *key_enc_algor; + ASN1_OCTET_STRING *enc_key; + X509 *cert; /* get the pub-key from this */ + const PKCS7_CTX *ctx; } PKCS7_RECIP_INFO; -SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO, PKCS7_RECIP_INFO) -#define sk_PKCS7_RECIP_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) -#define sk_PKCS7_RECIP_INFO_value(sk, idx) \ - ((PKCS7_RECIP_INFO *)OPENSSL_sk_value(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), (idx))) -#define sk_PKCS7_RECIP_INFO_new(cmp) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new(ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) -#define sk_PKCS7_RECIP_INFO_new_null() ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_null()) -#define sk_PKCS7_RECIP_INFO_new_reserve(cmp, n) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_reserve( \ - ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp), (n))) -#define sk_PKCS7_RECIP_INFO_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (n)) -#define sk_PKCS7_RECIP_INFO_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) -#define sk_PKCS7_RECIP_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) -#define sk_PKCS7_RECIP_INFO_delete(sk, i) \ - ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (i))) -#define sk_PKCS7_RECIP_INFO_delete_ptr(sk, ptr) \ - ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_type(ptr))) -#define sk_PKCS7_RECIP_INFO_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) -#define sk_PKCS7_RECIP_INFO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_type(ptr)) -#define sk_PKCS7_RECIP_INFO_pop(sk) \ - ((PKCS7_RECIP_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) -#define sk_PKCS7_RECIP_INFO_shift(sk) \ - ((PKCS7_RECIP_INFO *)OPENSSL_sk_shift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) -#define sk_PKCS7_RECIP_INFO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc)) -#define sk_PKCS7_RECIP_INFO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_type(ptr), (idx)) -#define sk_PKCS7_RECIP_INFO_set(sk, idx, ptr) \ - ((PKCS7_RECIP_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (idx), \ - ossl_check_PKCS7_RECIP_INFO_type(ptr))) -#define sk_PKCS7_RECIP_INFO_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) -#define sk_PKCS7_RECIP_INFO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_type(ptr)) -#define sk_PKCS7_RECIP_INFO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_type(ptr), pnum) -#define sk_PKCS7_RECIP_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) -#define sk_PKCS7_RECIP_INFO_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) -#define sk_PKCS7_RECIP_INFO_dup(sk) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk))) -#define sk_PKCS7_RECIP_INFO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), \ - ossl_check_PKCS7_RECIP_INFO_copyfunc_type(copyfunc), \ - ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc))) -#define sk_PKCS7_RECIP_INFO_set_cmp_func(sk, cmp) \ - ((sk_PKCS7_RECIP_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO, + PKCS7_RECIP_INFO) +#define sk_PKCS7_RECIP_INFO_num(sk) \ + OPENSSL_sk_num(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_value(sk, idx) \ + ((PKCS7_RECIP_INFO *)OPENSSL_sk_value( \ + ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), (idx))) +#define sk_PKCS7_RECIP_INFO_new(cmp) \ + ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new( \ + ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) +#define sk_PKCS7_RECIP_INFO_new_null() \ + ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_null()) +#define sk_PKCS7_RECIP_INFO_new_reserve(cmp, n) \ + ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_reserve( \ + ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp), (n))) +#define sk_PKCS7_RECIP_INFO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (n)) +#define sk_PKCS7_RECIP_INFO_free(sk) \ + OPENSSL_sk_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_zero(sk) \ + OPENSSL_sk_zero(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_delete(sk, i) \ + ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete( \ + ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (i))) +#define sk_PKCS7_RECIP_INFO_delete_ptr(sk, ptr) \ + ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete_ptr( \ + ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr))) +#define sk_PKCS7_RECIP_INFO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_pop(sk) \ + ((PKCS7_RECIP_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) +#define sk_PKCS7_RECIP_INFO_shift(sk) \ + ((PKCS7_RECIP_INFO *)OPENSSL_sk_shift( \ + ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) +#define sk_PKCS7_RECIP_INFO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc)) +#define sk_PKCS7_RECIP_INFO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr), (idx)) +#define sk_PKCS7_RECIP_INFO_set(sk, idx, ptr) \ + ((PKCS7_RECIP_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + (idx), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr))) +#define sk_PKCS7_RECIP_INFO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr)) +#define sk_PKCS7_RECIP_INFO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_type(ptr), pnum) +#define sk_PKCS7_RECIP_INFO_sort(sk) \ + OPENSSL_sk_sort(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) +#define sk_PKCS7_RECIP_INFO_dup(sk) \ + ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_dup( \ + ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk))) +#define sk_PKCS7_RECIP_INFO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_copyfunc_type(copyfunc), \ + ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc))) +#define sk_PKCS7_RECIP_INFO_set_cmp_func(sk, cmp) \ + ((sk_PKCS7_RECIP_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_PKCS7_RECIP_INFO_sk_type(sk), \ + ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) typedef struct pkcs7_signed_st { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) * md_algs; /* md used */ - STACK_OF(X509) * cert; /* [ 0 ] */ /* name should be 'certificates' */ - STACK_OF(X509_CRL) * crl; /* [ 1 ] */ /* name should be 'crls' */ - STACK_OF(PKCS7_SIGNER_INFO) * signer_info; - struct pkcs7_st *contents; + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) * md_algs; /* md used */ + STACK_OF(X509) * cert; /* [ 0 ] */ /* name should be 'certificates' */ + STACK_OF(X509_CRL) * crl; /* [ 1 ] */ /* name should be 'crls' */ + STACK_OF(PKCS7_SIGNER_INFO) * signer_info; + struct pkcs7_st *contents; } PKCS7_SIGNED; /* * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about @@ -212,126 +242,139 @@ typedef struct pkcs7_signed_st typedef struct pkcs7_enc_content_st { - ASN1_OBJECT *content_type; - X509_ALGOR *algorithm; - ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ - const EVP_CIPHER *cipher; - const PKCS7_CTX *ctx; + ASN1_OBJECT *content_type; + X509_ALGOR *algorithm; + ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ + const EVP_CIPHER *cipher; + const PKCS7_CTX *ctx; } PKCS7_ENC_CONTENT; typedef struct pkcs7_enveloped_st { - ASN1_INTEGER *version; /* version 0 */ - STACK_OF(PKCS7_RECIP_INFO) * recipientinfo; - PKCS7_ENC_CONTENT *enc_data; + ASN1_INTEGER *version; /* version 0 */ + STACK_OF(PKCS7_RECIP_INFO) * recipientinfo; + PKCS7_ENC_CONTENT *enc_data; } PKCS7_ENVELOPE; typedef struct pkcs7_signedandenveloped_st { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) * md_algs; /* md used */ - STACK_OF(X509) * cert; /* [ 0 ] */ /* name should be 'certificates' */ - STACK_OF(X509_CRL) * crl; /* [ 1 ] */ /* name should be 'crls' */ - STACK_OF(PKCS7_SIGNER_INFO) * signer_info; - PKCS7_ENC_CONTENT *enc_data; - STACK_OF(PKCS7_RECIP_INFO) * recipientinfo; + ASN1_INTEGER *version; /* version 1 */ + STACK_OF(X509_ALGOR) * md_algs; /* md used */ + STACK_OF(X509) * cert; /* [ 0 ] */ /* name should be 'certificates' */ + STACK_OF(X509_CRL) * crl; /* [ 1 ] */ /* name should be 'crls' */ + STACK_OF(PKCS7_SIGNER_INFO) * signer_info; + PKCS7_ENC_CONTENT *enc_data; + STACK_OF(PKCS7_RECIP_INFO) * recipientinfo; } PKCS7_SIGN_ENVELOPE; typedef struct pkcs7_digest_st { - ASN1_INTEGER *version; /* version 0 */ - X509_ALGOR *md; /* md used */ - struct pkcs7_st *contents; - ASN1_OCTET_STRING *digest; + ASN1_INTEGER *version; /* version 0 */ + X509_ALGOR *md; /* md used */ + struct pkcs7_st *contents; + ASN1_OCTET_STRING *digest; } PKCS7_DIGEST; typedef struct pkcs7_encrypted_st { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ENC_CONTENT *enc_data; + ASN1_INTEGER *version; /* version 0 */ + PKCS7_ENC_CONTENT *enc_data; } PKCS7_ENCRYPT; typedef struct pkcs7_st { - /* - * The following is non NULL if it contains ASN1 encoding of this - * structure - */ - unsigned char *asn1; - long length; + /* + * The following is non NULL if it contains ASN1 encoding of this + * structure + */ + unsigned char *asn1; + long length; #define PKCS7_S_HEADER 0 #define PKCS7_S_BODY 1 #define PKCS7_S_TAIL 2 - int state; /* used during processing */ - int detached; - ASN1_OBJECT *type; - /* content as defined by the type */ - /* - * all encryption/message digests are applied to the 'contents', leaving - * out the 'type' field. - */ - union - { - char *ptr; - /* NID_pkcs7_data */ - ASN1_OCTET_STRING *data; - /* NID_pkcs7_signed */ - PKCS7_SIGNED *sign; /* field name 'signed' would clash with C keyword */ - /* NID_pkcs7_enveloped */ - PKCS7_ENVELOPE *enveloped; - /* NID_pkcs7_signedAndEnveloped */ - PKCS7_SIGN_ENVELOPE *signed_and_enveloped; - /* NID_pkcs7_digest */ - PKCS7_DIGEST *digest; - /* NID_pkcs7_encrypted */ - PKCS7_ENCRYPT *encrypted; - /* Anything else */ - ASN1_TYPE *other; - } d; - PKCS7_CTX ctx; + int state; /* used during processing */ + int detached; + ASN1_OBJECT *type; + /* content as defined by the type */ + /* + * all encryption/message digests are applied to the 'contents', leaving + * out the 'type' field. + */ + union + { + char *ptr; + /* NID_pkcs7_data */ + ASN1_OCTET_STRING *data; + /* NID_pkcs7_signed */ + PKCS7_SIGNED *sign; /* field name 'signed' would clash with C keyword */ + /* NID_pkcs7_enveloped */ + PKCS7_ENVELOPE *enveloped; + /* NID_pkcs7_signedAndEnveloped */ + PKCS7_SIGN_ENVELOPE *signed_and_enveloped; + /* NID_pkcs7_digest */ + PKCS7_DIGEST *digest; + /* NID_pkcs7_encrypted */ + PKCS7_ENCRYPT *encrypted; + /* Anything else */ + ASN1_TYPE *other; + } d; + PKCS7_CTX ctx; } PKCS7; SKM_DEFINE_STACK_OF_INTERNAL(PKCS7, PKCS7, PKCS7) #define sk_PKCS7_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_sk_type(sk)) -#define sk_PKCS7_value(sk, idx) \ - ((PKCS7 *)OPENSSL_sk_value(ossl_check_const_PKCS7_sk_type(sk), (idx))) -#define sk_PKCS7_new(cmp) ((STACK_OF(PKCS7) *)OPENSSL_sk_new(ossl_check_PKCS7_compfunc_type(cmp))) +#define sk_PKCS7_value(sk, idx) \ + ((PKCS7 *)OPENSSL_sk_value(ossl_check_const_PKCS7_sk_type(sk), (idx))) +#define sk_PKCS7_new(cmp) \ + ((STACK_OF(PKCS7) *)OPENSSL_sk_new(ossl_check_PKCS7_compfunc_type(cmp))) #define sk_PKCS7_new_null() ((STACK_OF(PKCS7) *)OPENSSL_sk_new_null()) -#define sk_PKCS7_new_reserve(cmp, n) \ - ((STACK_OF(PKCS7) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_compfunc_type(cmp), (n))) -#define sk_PKCS7_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_sk_type(sk), (n)) +#define sk_PKCS7_new_reserve(cmp, n) \ + ((STACK_OF(PKCS7) *)OPENSSL_sk_new_reserve( \ + ossl_check_PKCS7_compfunc_type(cmp), (n))) +#define sk_PKCS7_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_PKCS7_sk_type(sk), (n)) #define sk_PKCS7_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_sk_type(sk)) #define sk_PKCS7_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_sk_type(sk)) -#define sk_PKCS7_delete(sk, i) ((PKCS7 *)OPENSSL_sk_delete(ossl_check_PKCS7_sk_type(sk), (i))) -#define sk_PKCS7_delete_ptr(sk, ptr) \ - ((PKCS7 *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr))) -#define sk_PKCS7_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) -#define sk_PKCS7_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_delete(sk, i) \ + ((PKCS7 *)OPENSSL_sk_delete(ossl_check_PKCS7_sk_type(sk), (i))) +#define sk_PKCS7_delete_ptr(sk, ptr) \ + ((PKCS7 *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_sk_type(sk), \ + ossl_check_PKCS7_type(ptr))) +#define sk_PKCS7_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) #define sk_PKCS7_pop(sk) ((PKCS7 *)OPENSSL_sk_pop(ossl_check_PKCS7_sk_type(sk))) -#define sk_PKCS7_shift(sk) ((PKCS7 *)OPENSSL_sk_shift(ossl_check_PKCS7_sk_type(sk))) -#define sk_PKCS7_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_freefunc_type(freefunc)) -#define sk_PKCS7_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), (idx)) -#define sk_PKCS7_set(sk, idx, ptr) \ - ((PKCS7 *)OPENSSL_sk_set(ossl_check_PKCS7_sk_type(sk), (idx), ossl_check_PKCS7_type(ptr))) -#define sk_PKCS7_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) -#define sk_PKCS7_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) -#define sk_PKCS7_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), pnum) +#define sk_PKCS7_shift(sk) \ + ((PKCS7 *)OPENSSL_sk_shift(ossl_check_PKCS7_sk_type(sk))) +#define sk_PKCS7_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_PKCS7_sk_type(sk), \ + ossl_check_PKCS7_freefunc_type(freefunc)) +#define sk_PKCS7_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), \ + (idx)) +#define sk_PKCS7_set(sk, idx, ptr) \ + ((PKCS7 *)OPENSSL_sk_set(ossl_check_PKCS7_sk_type(sk), (idx), \ + ossl_check_PKCS7_type(ptr))) +#define sk_PKCS7_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) +#define sk_PKCS7_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_PKCS7_sk_type(sk), \ + ossl_check_PKCS7_type(ptr), pnum) #define sk_PKCS7_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_sk_type(sk)) -#define sk_PKCS7_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_sk_type(sk)) -#define sk_PKCS7_dup(sk) ((STACK_OF(PKCS7) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_sk_type(sk))) -#define sk_PKCS7_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(PKCS7) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_sk_type(sk), \ - ossl_check_PKCS7_copyfunc_type(copyfunc), \ - ossl_check_PKCS7_freefunc_type(freefunc))) -#define sk_PKCS7_set_cmp_func(sk, cmp) \ - ((sk_PKCS7_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_sk_type(sk), \ - ossl_check_PKCS7_compfunc_type(cmp))) +#define sk_PKCS7_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_sk_type(sk)) +#define sk_PKCS7_dup(sk) \ + ((STACK_OF(PKCS7) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_sk_type(sk))) +#define sk_PKCS7_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(PKCS7) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_PKCS7_sk_type(sk), \ + ossl_check_PKCS7_copyfunc_type(copyfunc), \ + ossl_check_PKCS7_freefunc_type(freefunc))) +#define sk_PKCS7_set_cmp_func(sk, cmp) \ + ((sk_PKCS7_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_compfunc_type(cmp))) #define PKCS7_OP_SET_DETACHED_SIGNATURE 1 #define PKCS7_OP_GET_DETACHED_SIGNATURE 2 @@ -340,16 +383,22 @@ SKM_DEFINE_STACK_OF_INTERNAL(PKCS7, PKCS7, PKCS7) #define PKCS7_get_attributes(si) ((si)->unauth_attr) #define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) -#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) -#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) -#define PKCS7_type_is_signedAndEnveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) +#define PKCS7_type_is_encrypted(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) +#define PKCS7_type_is_enveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) +#define PKCS7_type_is_signedAndEnveloped(a) \ + (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) #define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) #define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) -#define PKCS7_set_detached(p, v) PKCS7_ctrl(p, PKCS7_OP_SET_DETACHED_SIGNATURE, v, NULL) -#define PKCS7_get_detached(p) PKCS7_ctrl(p, PKCS7_OP_GET_DETACHED_SIGNATURE, 0, NULL) +#define PKCS7_set_detached(p, v) \ + PKCS7_ctrl(p, PKCS7_OP_SET_DETACHED_SIGNATURE, v, NULL) +#define PKCS7_get_detached(p) \ + PKCS7_ctrl(p, PKCS7_OP_GET_DETACHED_SIGNATURE, 0, NULL) -#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) +#define PKCS7_is_detached(p7) \ + (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) /* S/MIME related flags */ @@ -388,8 +437,9 @@ SKM_DEFINE_STACK_OF_INTERNAL(PKCS7, PKCS7, PKCS7) DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) -int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); +int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, + const EVP_MD *type, unsigned char *md, + unsigned int *len); #ifndef OPENSSL_NO_STDIO PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7); int i2d_PKCS7_fp(FILE *fp, const PKCS7 *p7); @@ -423,28 +473,31 @@ int PKCS7_type_is_other(PKCS7 *p7); int PKCS7_set_type(PKCS7 *p7, int type); int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); -int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, const EVP_MD *dgst); +int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si); int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); int PKCS7_add_certificate(PKCS7 *p7, X509 *cert); int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl); int PKCS7_content_new(PKCS7 *p7, int nid); -int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio, PKCS7 *p7, - PKCS7_SIGNER_INFO *si); -int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, X509 *signer); +int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio, + PKCS7 *p7, PKCS7_SIGNER_INFO *si); +int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, + X509 *signer); BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); -PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, const EVP_MD *dgst); +PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, + const EVP_MD *dgst); X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); STACK_OF(PKCS7_SIGNER_INFO) * PKCS7_get_signer_info(PKCS7 *p7); PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); -void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, X509_ALGOR **pdig, - X509_ALGOR **psig); +void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, + X509_ALGOR **pdig, X509_ALGOR **psig); void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc); int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); @@ -454,36 +507,48 @@ int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7); PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7); ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) * sk); -int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, void *data); -int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, void *value); +int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, + void *data); +int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, + void *value); ASN1_TYPE *PKCS7_get_attribute(const PKCS7_SIGNER_INFO *si, int nid); ASN1_TYPE *PKCS7_get_signed_attribute(const PKCS7_SIGNER_INFO *si, int nid); -int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) * sk); -int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) * sk); +int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) * sk); +int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, + STACK_OF(X509_ATTRIBUTE) * sk); -PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) * certs, BIO *data, int flags); -PKCS7 *PKCS7_sign_ex(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) * certs, BIO *data, int flags, - OSSL_LIB_CTX *libctx, const char *propq); +PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) * certs, + BIO *data, int flags); +PKCS7 *PKCS7_sign_ex(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) * certs, + BIO *data, int flags, OSSL_LIB_CTX *libctx, + const char *propq); -PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, EVP_PKEY *pkey, - const EVP_MD *md, int flags); +PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, + EVP_PKEY *pkey, const EVP_MD *md, + int flags); int PKCS7_final(PKCS7 *p7, BIO *data, int flags); -int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) * certs, X509_STORE *store, BIO *indata, BIO *out, - int flags); -STACK_OF(X509) * PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) * certs, int flags); -PKCS7 *PKCS7_encrypt(STACK_OF(X509) * certs, BIO *in, const EVP_CIPHER *cipher, int flags); -PKCS7 *PKCS7_encrypt_ex(STACK_OF(X509) * certs, BIO *in, const EVP_CIPHER *cipher, int flags, +int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) * certs, X509_STORE *store, + BIO *indata, BIO *out, int flags); +STACK_OF(X509) + * PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) * certs, int flags); +PKCS7 *PKCS7_encrypt(STACK_OF(X509) * certs, BIO *in, const EVP_CIPHER *cipher, + int flags); +PKCS7 *PKCS7_encrypt_ex(STACK_OF(X509) * certs, BIO *in, + const EVP_CIPHER *cipher, int flags, OSSL_LIB_CTX *libctx, const char *propq); int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); -int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) * cap); +int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, + STACK_OF(X509_ALGOR) * cap); STACK_OF(X509_ALGOR) * PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) * sk, int nid, int arg); int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid); int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t); -int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md, int mdlen); +int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md, + int mdlen); int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7); diff --git a/libs/OpenSSL/include/openssl/provider.h b/libs/OpenSSL/include/openssl/provider.h index 9cc7052a..2808d9a4 100644 --- a/libs/OpenSSL/include/openssl/provider.h +++ b/libs/OpenSSL/include/openssl/provider.h @@ -23,27 +23,33 @@ const char *OSSL_PROVIDER_get0_default_search_path(OSSL_LIB_CTX *libctx); /* Load and unload a provider */ OSSL_PROVIDER *OSSL_PROVIDER_load(OSSL_LIB_CTX *, const char *name); -OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *, const char *name, int retain_fallbacks); +OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *, const char *name, + int retain_fallbacks); int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov); int OSSL_PROVIDER_available(OSSL_LIB_CTX *, const char *name); -int OSSL_PROVIDER_do_all(OSSL_LIB_CTX *ctx, int (*cb)(OSSL_PROVIDER *provider, void *cbdata), +int OSSL_PROVIDER_do_all(OSSL_LIB_CTX *ctx, + int (*cb)(OSSL_PROVIDER *provider, void *cbdata), void *cbdata); const OSSL_PARAM *OSSL_PROVIDER_gettable_params(const OSSL_PROVIDER *prov); int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); int OSSL_PROVIDER_self_test(const OSSL_PROVIDER *prov); -int OSSL_PROVIDER_get_capabilities(const OSSL_PROVIDER *prov, const char *capability, - OSSL_CALLBACK *cb, void *arg); +int OSSL_PROVIDER_get_capabilities(const OSSL_PROVIDER *prov, + const char *capability, OSSL_CALLBACK *cb, + void *arg); -const OSSL_ALGORITHM *OSSL_PROVIDER_query_operation(const OSSL_PROVIDER *prov, int operation_id, +const OSSL_ALGORITHM *OSSL_PROVIDER_query_operation(const OSSL_PROVIDER *prov, + int operation_id, int *no_cache); -void OSSL_PROVIDER_unquery_operation(const OSSL_PROVIDER *prov, int operation_id, +void OSSL_PROVIDER_unquery_operation(const OSSL_PROVIDER *prov, + int operation_id, const OSSL_ALGORITHM *algs); void *OSSL_PROVIDER_get0_provider_ctx(const OSSL_PROVIDER *prov); const OSSL_DISPATCH *OSSL_PROVIDER_get0_dispatch(const OSSL_PROVIDER *prov); /* Add a built in providers */ -int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *, const char *name, OSSL_provider_init_fn *init_fn); +int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *, const char *name, + OSSL_provider_init_fn *init_fn); /* Information */ const char *OSSL_PROVIDER_get0_name(const OSSL_PROVIDER *prov); diff --git a/libs/OpenSSL/include/openssl/quic.h b/libs/OpenSSL/include/openssl/quic.h index 38c8d520..c54f8ba1 100644 --- a/libs/OpenSSL/include/openssl/quic.h +++ b/libs/OpenSSL/include/openssl/quic.h @@ -16,9 +16,9 @@ #ifndef OPENSSL_NO_QUIC -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif /* * Method used for non-thread-assisted QUIC client operation. @@ -35,9 +35,9 @@ __owur const SSL_METHOD *OSSL_QUIC_client_thread_method(void); */ __owur const SSL_METHOD *OSSL_QUIC_server_method(void); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* OPENSSL_NO_QUIC */ #endif diff --git a/libs/OpenSSL/include/openssl/rand.h b/libs/OpenSSL/include/openssl/rand.h index 89903321..fc75ddee 100644 --- a/libs/OpenSSL/include/openssl/rand.h +++ b/libs/OpenSSL/include/openssl/rand.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_RAND_H +# define HEADER_RAND_H #endif #include @@ -39,27 +39,27 @@ extern "C" { #ifndef OPENSSL_NO_DEPRECATED_3_0 struct rand_meth_st { - int (*seed)(const void *buf, int num); - int (*bytes)(unsigned char *buf, int num); - void (*cleanup)(void); - int (*add)(const void *buf, int num, double randomness); - int (*pseudorand)(unsigned char *buf, int num); - int (*status)(void); + int (*seed)(const void *buf, int num); + int (*bytes)(unsigned char *buf, int num); + void (*cleanup)(void); + int (*add)(const void *buf, int num, double randomness); + int (*pseudorand)(unsigned char *buf, int num); + int (*status)(void); }; OSSL_DEPRECATEDIN_3_0 int RAND_set_rand_method(const RAND_METHOD *meth); OSSL_DEPRECATEDIN_3_0 const RAND_METHOD *RAND_get_rand_method(void); -# ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE OSSL_DEPRECATEDIN_3_0 int RAND_set_rand_engine(ENGINE *engine); -# endif +# endif OSSL_DEPRECATEDIN_3_0 RAND_METHOD *RAND_OpenSSL(void); #endif /* OPENSSL_NO_DEPRECATED_3_0 */ #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define RAND_cleanup() \ - while (0) \ - continue +# define RAND_cleanup() \ + while (0) \ + continue #endif int RAND_bytes(unsigned char *buf, int num); int RAND_priv_bytes(unsigned char *buf, int num); @@ -68,13 +68,15 @@ int RAND_priv_bytes(unsigned char *buf, int num); * Equivalent of RAND_priv_bytes() but additionally taking an OSSL_LIB_CTX and * a strength. */ -int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num, unsigned int strength); +int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num, + unsigned int strength); /* * Equivalent of RAND_bytes() but additionally taking an OSSL_LIB_CTX and * a strength. */ -int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num, unsigned int strength); +int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num, + unsigned int strength); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 int RAND_pseudo_bytes(unsigned char *buf, int num); @@ -86,9 +88,10 @@ EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx); int RAND_set0_public(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand); int RAND_set0_private(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand); -int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq, const char *cipher, - const char *digest); -int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed, const char *propq); +int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq, + const char *cipher, const char *digest); +int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed, + const char *propq); void RAND_seed(const void *buf, int num); void RAND_keep_random_devices_open(int keep); @@ -113,10 +116,10 @@ int RAND_poll(void); #if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) /* application has to include in order to use these */ -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 void RAND_screen(void); OSSL_DEPRECATEDIN_1_1_0 int RAND_event(UINT, WPARAM, LPARAM); -# endif +# endif #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/rc2.h b/libs/OpenSSL/include/openssl/rc2.h index c3dc5b2b..f76aca61 100644 --- a/libs/OpenSSL/include/openssl/rc2.h +++ b/libs/OpenSSL/include/openssl/rc2.h @@ -13,49 +13,54 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_RC2_H +# define HEADER_RC2_H #endif #include #ifndef OPENSSL_NO_RC2 -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define RC2_BLOCK 8 -# define RC2_KEY_LENGTH 16 +# define RC2_BLOCK 8 +# define RC2_KEY_LENGTH 16 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef unsigned int RC2_INT; -# define RC2_ENCRYPT 1 -# define RC2_DECRYPT 0 +# define RC2_ENCRYPT 1 +# define RC2_DECRYPT 0 typedef struct rc2_key_st { - RC2_INT data[64]; + RC2_INT data[64]; } RC2_KEY; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits); -OSSL_DEPRECATEDIN_3_0 void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, - RC2_KEY *key, int enc); +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 void RC2_set_key(RC2_KEY *key, int len, + const unsigned char *data, int bits); +OSSL_DEPRECATEDIN_3_0 void RC2_ecb_encrypt(const unsigned char *in, + unsigned char *out, RC2_KEY *key, + int enc); OSSL_DEPRECATEDIN_3_0 void RC2_encrypt(unsigned long *data, RC2_KEY *key); OSSL_DEPRECATEDIN_3_0 void RC2_decrypt(unsigned long *data, RC2_KEY *key); -OSSL_DEPRECATEDIN_3_0 void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - RC2_KEY *ks, unsigned char *iv, int enc); -OSSL_DEPRECATEDIN_3_0 void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num, int enc); -OSSL_DEPRECATEDIN_3_0 void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num); -# endif +OSSL_DEPRECATEDIN_3_0 void RC2_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC2_KEY *ks, unsigned char *iv, + int enc); +OSSL_DEPRECATEDIN_3_0 void +RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + RC2_KEY *schedule, unsigned char *ivec, int *num, int enc); +OSSL_DEPRECATEDIN_3_0 void RC2_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC2_KEY *schedule, + unsigned char *ivec, int *num); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/rc4.h b/libs/OpenSSL/include/openssl/rc4.h index c4fddc81..97094587 100644 --- a/libs/OpenSSL/include/openssl/rc4.h +++ b/libs/OpenSSL/include/openssl/rc4.h @@ -13,34 +13,36 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_RC4_H +# define HEADER_RC4_H #endif #include #ifndef OPENSSL_NO_RC4 -# include -# ifdef __cplusplus +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct rc4_key_st { - RC4_INT x, y; - RC4_INT data[256]; + RC4_INT x, y; + RC4_INT data[256]; } RC4_KEY; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 const char *RC4_options(void); -OSSL_DEPRECATEDIN_3_0 void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); -OSSL_DEPRECATEDIN_3_0 void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, +OSSL_DEPRECATEDIN_3_0 void RC4_set_key(RC4_KEY *key, int len, + const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 void RC4(RC4_KEY *key, size_t len, + const unsigned char *indata, unsigned char *outdata); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/rc5.h b/libs/OpenSSL/include/openssl/rc5.h index ad851b6e..13a732c0 100644 --- a/libs/OpenSSL/include/openssl/rc5.h +++ b/libs/OpenSSL/include/openssl/rc5.h @@ -13,61 +13,66 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_RC5_H +# define HEADER_RC5_H #endif #include #ifndef OPENSSL_NO_RC5 -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define RC5_32_BLOCK 8 -# define RC5_32_KEY_LENGTH 16 /* This is a default, max is 255 */ +# define RC5_32_BLOCK 8 +# define RC5_32_KEY_LENGTH 16 /* This is a default, max is 255 */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define RC5_ENCRYPT 1 -# define RC5_DECRYPT 0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define RC5_ENCRYPT 1 +# define RC5_DECRYPT 0 -# define RC5_32_INT unsigned int +# define RC5_32_INT unsigned int /* * This are the only values supported. Tweak the code if you want more The * most supported modes will be RC5-32/12/16 RC5-32/16/8 */ -# define RC5_8_ROUNDS 8 -# define RC5_12_ROUNDS 12 -# define RC5_16_ROUNDS 16 +# define RC5_8_ROUNDS 8 +# define RC5_12_ROUNDS 12 +# define RC5_16_ROUNDS 16 typedef struct rc5_key_st { - /* Number of rounds */ - int rounds; - RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; + /* Number of rounds */ + int rounds; + RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; } RC5_32_KEY; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds); -OSSL_DEPRECATEDIN_3_0 void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +OSSL_DEPRECATEDIN_3_0 int RC5_32_set_key(RC5_32_KEY *key, int len, + const unsigned char *data, int rounds); +OSSL_DEPRECATEDIN_3_0 void RC5_32_ecb_encrypt(const unsigned char *in, + unsigned char *out, RC5_32_KEY *key, int enc); OSSL_DEPRECATEDIN_3_0 void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); OSSL_DEPRECATEDIN_3_0 void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); -OSSL_DEPRECATEDIN_3_0 void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *ks, unsigned char *iv, +OSSL_DEPRECATEDIN_3_0 void RC5_32_cbc_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC5_32_KEY *ks, unsigned char *iv, int enc); -OSSL_DEPRECATEDIN_3_0 void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num, int enc); -OSSL_DEPRECATEDIN_3_0 void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, +OSSL_DEPRECATEDIN_3_0 void RC5_32_cfb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC5_32_KEY *schedule, + unsigned char *ivec, int *num, + int enc); +OSSL_DEPRECATEDIN_3_0 void RC5_32_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, + RC5_32_KEY *schedule, unsigned char *ivec, int *num); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/ripemd.h b/libs/OpenSSL/include/openssl/ripemd.h index f7f320a2..ab912904 100644 --- a/libs/OpenSSL/include/openssl/ripemd.h +++ b/libs/OpenSSL/include/openssl/ripemd.h @@ -13,45 +13,48 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_RIPEMD_H +# define HEADER_RIPEMD_H #endif #include #ifndef OPENSSL_NO_RMD160 -# include -# include +# include +# include -# define RIPEMD160_DIGEST_LENGTH 20 +# define RIPEMD160_DIGEST_LENGTH 20 -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif -# if !defined(OPENSSL_NO_DEPRECATED_3_0) +# endif +# if !defined(OPENSSL_NO_DEPRECATED_3_0) -# define RIPEMD160_LONG unsigned int +# define RIPEMD160_LONG unsigned int -# define RIPEMD160_CBLOCK 64 -# define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK / 4) +# define RIPEMD160_CBLOCK 64 +# define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK / 4) typedef struct RIPEMD160state_st { - RIPEMD160_LONG A, B, C, D, E; - RIPEMD160_LONG Nl, Nh; - RIPEMD160_LONG data[RIPEMD160_LBLOCK]; - unsigned int num; + RIPEMD160_LONG A, B, C, D, E; + RIPEMD160_LONG Nl, Nh; + RIPEMD160_LONG data[RIPEMD160_LBLOCK]; + unsigned int num; } RIPEMD160_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Init(RIPEMD160_CTX *c); -OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); -OSSL_DEPRECATEDIN_3_0 unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md); -OSSL_DEPRECATEDIN_3_0 void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); -# endif +OSSL_DEPRECATEDIN_3_0 unsigned char *RIPEMD160(const unsigned char *d, size_t n, + unsigned char *md); +OSSL_DEPRECATEDIN_3_0 void RIPEMD160_Transform(RIPEMD160_CTX *c, + const unsigned char *b); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/rsa.h b/libs/OpenSSL/include/openssl/rsa.h index 788e8d7a..1e740e7d 100644 --- a/libs/OpenSSL/include/openssl/rsa.h +++ b/libs/OpenSSL/include/openssl/rsa.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_RSA_H +# define HEADER_RSA_H #endif #include @@ -23,12 +23,12 @@ #include #include #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include +# include #endif #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -36,7 +36,7 @@ extern "C" { #endif #ifndef OPENSSL_RSA_MAX_MODULUS_BITS -# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 +# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 #endif #define RSA_3 0x3L @@ -45,34 +45,34 @@ extern "C" { #ifndef OPENSSL_NO_DEPRECATED_3_0 /* The types RSA and RSA_METHOD are defined in ossl_typ.h */ -# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 2048 +# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 2048 -# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS -# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 -# endif +# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS +# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 +# endif /* exponent limit enforced for "large" modulus only */ -# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS -# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 -# endif +# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS +# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 +# endif /* based on RFC 8017 appendix A.1.2 */ -# define RSA_ASN1_VERSION_DEFAULT 0 -# define RSA_ASN1_VERSION_MULTI 1 +# define RSA_ASN1_VERSION_DEFAULT 0 +# define RSA_ASN1_VERSION_MULTI 1 -# define RSA_DEFAULT_PRIME_NUM 2 +# define RSA_DEFAULT_PRIME_NUM 2 -# define RSA_METHOD_FLAG_NO_CHECK 0x0001 -# define RSA_FLAG_CACHE_PUBLIC 0x0002 -# define RSA_FLAG_CACHE_PRIVATE 0x0004 -# define RSA_FLAG_BLINDING 0x0008 -# define RSA_FLAG_THREAD_SAFE 0x0010 +# define RSA_METHOD_FLAG_NO_CHECK 0x0001 +# define RSA_FLAG_CACHE_PUBLIC 0x0002 +# define RSA_FLAG_CACHE_PRIVATE 0x0004 +# define RSA_FLAG_BLINDING 0x0008 +# define RSA_FLAG_THREAD_SAFE 0x0010 /* * This flag means the private key operations will be handled by rsa_mod_exp * and that they do not depend on the private key components being present: * for example a key stored in external hardware. Without this flag * bn_mod_exp gets called when private key components are absent. */ -# define RSA_FLAG_EXT_PKEY 0x0020 +# define RSA_FLAG_EXT_PKEY 0x0020 /* * new with 0.9.6j and 0.9.7b; the built-in @@ -80,13 +80,13 @@ extern "C" { * default (ignoring RSA_FLAG_BLINDING), * but other engines might not need it */ -# define RSA_FLAG_NO_BLINDING 0x0080 +# define RSA_FLAG_NO_BLINDING 0x0080 #endif /* OPENSSL_NO_DEPRECATED_3_0 */ /* * Does nothing. Previously this switched off constant time behaviour. */ #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define RSA_FLAG_NO_CONSTTIME 0x0000 +# define RSA_FLAG_NO_CONSTTIME 0x0000 #endif /* deprecated name for the flag*/ /* @@ -98,7 +98,7 @@ extern "C" { * be used for all exponents. */ #ifndef OPENSSL_NO_DEPRECATED_0_9_8 -# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME +# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME #endif /*- @@ -147,20 +147,27 @@ int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); #define RSA_PSS_SALTLEN_MAX_SIGN -2 int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); -int EVP_PKEY_CTX_set_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname, const char *mdprops); +int EVP_PKEY_CTX_set_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname, + const char *mdprops); int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); -int EVP_PKEY_CTX_get_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); -int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); -int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname); +int EVP_PKEY_CTX_get_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, char *name, + size_t namelen); +int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx, + const EVP_MD *md); +int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name(EVP_PKEY_CTX *ctx, + const char *mdname); int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); -int EVP_PKEY_CTX_set_rsa_pss_keygen_md_name(EVP_PKEY_CTX *ctx, const char *mdname, +int EVP_PKEY_CTX_set_rsa_pss_keygen_md_name(EVP_PKEY_CTX *ctx, + const char *mdname, const char *mdprops); int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); -int EVP_PKEY_CTX_set_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, const char *mdname, const char *mdprops); +int EVP_PKEY_CTX_set_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, const char *mdname, + const char *mdprops); int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD **md); -int EVP_PKEY_CTX_get_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen); +int EVP_PKEY_CTX_get_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, char *name, + size_t namelen); int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen); int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char **label); @@ -211,18 +218,26 @@ OSSL_DEPRECATEDIN_3_0 int RSA_security_bits(const RSA *rsa); OSSL_DEPRECATEDIN_3_0 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); OSSL_DEPRECATEDIN_3_0 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); -OSSL_DEPRECATEDIN_3_0 int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); -OSSL_DEPRECATEDIN_3_0 int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[], - BIGNUM *coeffs[], int pnum); -OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, - const BIGNUM **d); -OSSL_DEPRECATEDIN_3_0 void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); +OSSL_DEPRECATEDIN_3_0 int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, + BIGNUM *dmq1, BIGNUM *iqmp); +OSSL_DEPRECATEDIN_3_0 int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], + BIGNUM *exps[], + BIGNUM *coeffs[], + int pnum); +OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r, const BIGNUM **n, + const BIGNUM **e, const BIGNUM **d); +OSSL_DEPRECATEDIN_3_0 void RSA_get0_factors(const RSA *r, const BIGNUM **p, + const BIGNUM **q); OSSL_DEPRECATEDIN_3_0 int RSA_get_multi_prime_extra_count(const RSA *r); -OSSL_DEPRECATEDIN_3_0 int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]); -OSSL_DEPRECATEDIN_3_0 void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, - const BIGNUM **dmq1, const BIGNUM **iqmp); +OSSL_DEPRECATEDIN_3_0 int RSA_get0_multi_prime_factors(const RSA *r, + const BIGNUM *primes[]); +OSSL_DEPRECATEDIN_3_0 void RSA_get0_crt_params(const RSA *r, + const BIGNUM **dmp1, + const BIGNUM **dmq1, + const BIGNUM **iqmp); OSSL_DEPRECATEDIN_3_0 -int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[], const BIGNUM *coeffs[]); +int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[], + const BIGNUM *coeffs[]); OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_n(const RSA *d); OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_e(const RSA *d); OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_d(const RSA *d); @@ -239,43 +254,48 @@ OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r); OSSL_DEPRECATEDIN_3_0 ENGINE *RSA_get0_engine(const RSA *r); #endif /* !OPENSSL_NO_DEPRECATED_3_0 */ -#define EVP_RSA_gen(bits) EVP_PKEY_Q_keygen(NULL, NULL, "RSA", (size_t)(0 + (bits))) +#define EVP_RSA_gen(bits) \ + EVP_PKEY_Q_keygen(NULL, NULL, "RSA", (size_t)(0 + (bits))) /* Deprecated version */ #ifndef OPENSSL_NO_DEPRECATED_0_9_8 -OSSL_DEPRECATEDIN_0_9_8 RSA *RSA_generate_key(int bits, unsigned long e, - void (*callback)(int, int, void *), void *cb_arg); +OSSL_DEPRECATEDIN_0_9_8 RSA * +RSA_generate_key(int bits, unsigned long e, void (*callback)(int, int, void *), + void *cb_arg); #endif /* New version */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, + BN_GENCB *cb); /* Multi-prime version */ -OSSL_DEPRECATEDIN_3_0 int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, BIGNUM *e, +OSSL_DEPRECATEDIN_3_0 int RSA_generate_multi_prime_key(RSA *rsa, int bits, + int primes, BIGNUM *e, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 -int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2, const BIGNUM *Xp1, - const BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2, - const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb); -OSSL_DEPRECATEDIN_3_0 int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, - BN_GENCB *cb); +int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2, + const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp, + const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq, + const BIGNUM *e, BN_GENCB *cb); +OSSL_DEPRECATEDIN_3_0 int +RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 int RSA_check_key(const RSA *); OSSL_DEPRECATEDIN_3_0 int RSA_check_key_ex(const RSA *, BN_GENCB *cb); /* next 4 return -1 on error */ OSSL_DEPRECATEDIN_3_0 -int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, - int padding); +int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); OSSL_DEPRECATEDIN_3_0 -int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, - int padding); +int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); OSSL_DEPRECATEDIN_3_0 -int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, - int padding); +int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); OSSL_DEPRECATEDIN_3_0 -int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, - int padding); +int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to, + RSA *rsa, int padding); OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r); /* "up" the RSA object's reference count */ OSSL_DEPRECATEDIN_3_0 int RSA_up_ref(RSA *r); @@ -290,20 +310,23 @@ OSSL_DEPRECATEDIN_3_0 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); /* these are the actual RSA functions */ OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_PKCS1_OpenSSL(void); -DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey) - DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPrivateKey) +DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, + RSAPublicKey) + DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, + RSAPrivateKey) #endif /* !OPENSSL_NO_DEPRECATED_3_0 */ - int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2); + int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, + void *p2); struct rsa_pss_params_st { - X509_ALGOR *hashAlgorithm; - X509_ALGOR *maskGenAlgorithm; - ASN1_INTEGER *saltLength; - ASN1_INTEGER *trailerField; - /* Decoded hash algorithm from maskGenAlgorithm */ - X509_ALGOR *maskHash; + X509_ALGOR *hashAlgorithm; + X509_ALGOR *maskGenAlgorithm; + ASN1_INTEGER *saltLength; + ASN1_INTEGER *trailerField; + /* Decoded hash algorithm from maskGenAlgorithm */ + X509_ALGOR *maskHash; }; DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS) @@ -311,19 +334,19 @@ DECLARE_ASN1_DUP_FUNCTION(RSA_PSS_PARAMS) typedef struct rsa_oaep_params_st { - X509_ALGOR *hashFunc; - X509_ALGOR *maskGenFunc; - X509_ALGOR *pSourceFunc; - /* Decoded hash algorithm from maskGenFunc */ - X509_ALGOR *maskHash; + X509_ALGOR *hashFunc; + X509_ALGOR *maskGenFunc; + X509_ALGOR *pSourceFunc; + /* Decoded hash algorithm from maskGenFunc */ + X509_ALGOR *maskHash; } RSA_OAEP_PARAMS; DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_STDIO OSSL_DEPRECATEDIN_3_0 int RSA_print_fp(FILE *fp, const RSA *r, int offset); -# endif +# endif OSSL_DEPRECATEDIN_3_0 int RSA_print(BIO *bp, const RSA *r, int offset); @@ -331,84 +354,104 @@ OSSL_DEPRECATEDIN_3_0 int RSA_print(BIO *bp, const RSA *r, int offset); * The following 2 functions sign and verify a X509_SIG ASN1 object inside * PKCS#1 padded RSA encryption */ -OSSL_DEPRECATEDIN_3_0 int RSA_sign(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, RSA *rsa); -OSSL_DEPRECATEDIN_3_0 int RSA_verify(int type, const unsigned char *m, unsigned int m_length, - const unsigned char *sigbuf, unsigned int siglen, RSA *rsa); +OSSL_DEPRECATEDIN_3_0 int RSA_sign(int type, const unsigned char *m, + unsigned int m_length, unsigned char *sigret, + unsigned int *siglen, RSA *rsa); +OSSL_DEPRECATEDIN_3_0 int RSA_verify(int type, const unsigned char *m, + unsigned int m_length, + const unsigned char *sigbuf, + unsigned int siglen, RSA *rsa); /* * The following 2 function sign and verify a ASN1_OCTET_STRING object inside * PKCS#1 padded RSA encryption */ OSSL_DEPRECATEDIN_3_0 -int RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, RSA *rsa); +int RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, + unsigned int m_length, unsigned char *sigret, + unsigned int *siglen, RSA *rsa); OSSL_DEPRECATEDIN_3_0 -int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigbuf, unsigned int siglen, RSA *rsa); +int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m, + unsigned int m_length, unsigned char *sigbuf, + unsigned int siglen, RSA *rsa); OSSL_DEPRECATEDIN_3_0 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); OSSL_DEPRECATEDIN_3_0 void RSA_blinding_off(RSA *rsa); OSSL_DEPRECATEDIN_3_0 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, const unsigned char *f, int fl); +int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, + const unsigned char *f, int fl); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, const unsigned char *f, int fl, - int rsa_len); +int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, + const unsigned char *f, int fl, int rsa_len); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, const unsigned char *f, int fl); +int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, + const unsigned char *f, int fl); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, const unsigned char *f, int fl, - int rsa_len); -OSSL_DEPRECATEDIN_3_0 int PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed, - long seedlen, const EVP_MD *dgst); +int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, + const unsigned char *f, int fl, int rsa_len); +OSSL_DEPRECATEDIN_3_0 int PKCS1_MGF1(unsigned char *mask, long len, + const unsigned char *seed, long seedlen, + const EVP_MD *dgst); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, const unsigned char *f, int fl, +int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, + const unsigned char *f, int fl, const unsigned char *p, int pl); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, const unsigned char *f, int fl, - int rsa_len, const unsigned char *p, int pl); +int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, + const unsigned char *f, int fl, int rsa_len, + const unsigned char *p, int pl); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, const unsigned char *from, - int flen, const unsigned char *param, int plen, +int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, + const unsigned char *from, int flen, + const unsigned char *param, int plen, const EVP_MD *md, const EVP_MD *mgf1md); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, const unsigned char *from, - int flen, int num, const unsigned char *param, int plen, - const EVP_MD *md, const EVP_MD *mgf1md); -OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f, - int fl); +int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, + const unsigned char *from, int flen, + int num, const unsigned char *param, + int plen, const EVP_MD *md, + const EVP_MD *mgf1md); +OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_none(unsigned char *to, int tlen, + const unsigned char *f, int fl); OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_none(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f, - int fl); + const unsigned char *f, int fl, + int rsa_len); +OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_X931(unsigned char *to, int tlen, + const unsigned char *f, int fl); OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_X931(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); + const unsigned char *f, int fl, + int rsa_len); OSSL_DEPRECATEDIN_3_0 int RSA_X931_hash_id(int nid); OSSL_DEPRECATEDIN_3_0 -int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash, - const unsigned char *EM, int sLen); +int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const unsigned char *EM, int sLen); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, const unsigned char *mHash, - const EVP_MD *Hash, int sLen); +int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, const EVP_MD *Hash, + int sLen); OSSL_DEPRECATEDIN_3_0 -int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, const EVP_MD *Hash, - const EVP_MD *mgf1Hash, const unsigned char *EM, int sLen); +int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, + const EVP_MD *Hash, const EVP_MD *mgf1Hash, + const unsigned char *EM, int sLen); OSSL_DEPRECATEDIN_3_0 -int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, const unsigned char *mHash, - const EVP_MD *Hash, const EVP_MD *mgf1Hash, int sLen); +int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, const EVP_MD *mgf1Hash, + int sLen); -# define RSA_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef) +# define RSA_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef) OSSL_DEPRECATEDIN_3_0 int RSA_set_ex_data(RSA *r, int idx, void *arg); OSSL_DEPRECATEDIN_3_0 void *RSA_get_ex_data(const RSA *r, int idx); DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey) - DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPrivateKey) + DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, + RSAPrivateKey) /* * If this flag is set the RSA method is FIPS compliant and can be used in @@ -417,7 +460,7 @@ DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey) * result is compliant. */ -# define RSA_FLAG_FIPS_METHOD 0x0400 +# define RSA_FLAG_FIPS_METHOD 0x0400 /* * If this flag is set the operations normally disabled in FIPS mode are @@ -425,64 +468,81 @@ DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey) * usage is compliant. */ -# define RSA_FLAG_NON_FIPS_ALLOW 0x0400 +# define RSA_FLAG_NON_FIPS_ALLOW 0x0400 /* * Application has decided PRNG is good enough to generate a key: don't * check. */ -# define RSA_FLAG_CHECKED 0x0800 +# define RSA_FLAG_CHECKED 0x0800 - OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, int flags); + OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, + int flags); OSSL_DEPRECATEDIN_3_0 void RSA_meth_free(RSA_METHOD *meth); OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); OSSL_DEPRECATEDIN_3_0 const char *RSA_meth_get0_name(const RSA_METHOD *meth); -OSSL_DEPRECATEDIN_3_0 int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); +OSSL_DEPRECATEDIN_3_0 int RSA_meth_set1_name(RSA_METHOD *meth, + const char *name); OSSL_DEPRECATEDIN_3_0 int RSA_meth_get_flags(const RSA_METHOD *meth); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_flags(RSA_METHOD *meth, int flags); OSSL_DEPRECATEDIN_3_0 void *RSA_meth_get0_app_data(const RSA_METHOD *meth); -OSSL_DEPRECATEDIN_3_0 int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data); +OSSL_DEPRECATEDIN_3_0 int RSA_meth_set0_app_data(RSA_METHOD *meth, + void *app_data); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); +int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, + const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_pub_enc(RSA_METHOD *rsa, - int (*pub_enc)(int flen, const unsigned char *from, unsigned char *to, - RSA *rsa, int padding)); + int (*pub_enc)(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); +int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen, + const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_pub_dec(RSA_METHOD *rsa, - int (*pub_dec)(int flen, const unsigned char *from, unsigned char *to, - RSA *rsa, int padding)); + int (*pub_dec)(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); +int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, + const unsigned char *from, + unsigned char *to, + RSA *rsa, int padding); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_priv_enc(RSA_METHOD *rsa, - int (*priv_enc)(int flen, const unsigned char *from, unsigned char *to, - RSA *rsa, int padding)); + int (*priv_enc)(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); +int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, + const unsigned char *from, + unsigned char *to, + RSA *rsa, int padding); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_priv_dec(RSA_METHOD *rsa, - int (*priv_dec)(int flen, const unsigned char *from, unsigned char *to, - RSA *rsa, int padding)); + int (*priv_dec)(int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i, RSA *rsa, - BN_CTX *ctx); +int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i, + RSA *rsa, BN_CTX *ctx); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_mod_exp(RSA_METHOD *rsa, - int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx)); + int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa, + BN_CTX *ctx)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); +int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))( + BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa, - int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)); + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, + const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *m_ctx)); OSSL_DEPRECATEDIN_3_0 int (*RSA_meth_get_init(const RSA_METHOD *meth))(RSA *rsa); OSSL_DEPRECATEDIN_3_0 @@ -492,34 +552,38 @@ int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish)(RSA *rsa)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type, const unsigned char *m, - unsigned int m_length, unsigned char *sigret, - unsigned int *siglen, const RSA *rsa); +int (*RSA_meth_get_sign(const RSA_METHOD *meth))( + int type, const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, const RSA *rsa); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_sign(RSA_METHOD *rsa, - int (*sign)(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, const RSA *rsa)); + int (*sign)(int type, const unsigned char *m, + unsigned int m_length, unsigned char *sigret, + unsigned int *siglen, const RSA *rsa)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype, const unsigned char *m, - unsigned int m_length, - const unsigned char *sigbuf, unsigned int siglen, - const RSA *rsa); +int (*RSA_meth_get_verify(const RSA_METHOD *meth))( + int dtype, const unsigned char *m, unsigned int m_length, + const unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_verify(RSA_METHOD *rsa, - int (*verify)(int dtype, const unsigned char *m, unsigned int m_length, - const unsigned char *sigbuf, unsigned int siglen, - const RSA *rsa)); + int (*verify)(int dtype, const unsigned char *m, + unsigned int m_length, + const unsigned char *sigbuf, + unsigned int siglen, const RSA *rsa)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); +int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, + BIGNUM *e, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_keygen(RSA_METHOD *rsa, - int (*keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)); + int (*keygen)(RSA *rsa, int bits, BIGNUM *e, + BN_GENCB *cb)); OSSL_DEPRECATEDIN_3_0 -int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, int primes, - BIGNUM *e, BN_GENCB *cb); +int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))( + RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb); OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth, - int (*keygen)(RSA *rsa, int bits, int primes, BIGNUM *e, + int (*keygen)(RSA *rsa, int bits, + int primes, BIGNUM *e, BN_GENCB *cb)); #endif /* !OPENSSL_NO_DEPRECATED_3_0 */ diff --git a/libs/OpenSSL/include/openssl/safestack.h b/libs/OpenSSL/include/openssl/safestack.h index 2927c733..5cda82da 100644 --- a/libs/OpenSSL/include/openssl/safestack.h +++ b/libs/OpenSSL/include/openssl/safestack.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SAFESTACK_H +# define HEADER_SAFESTACK_H #endif #include @@ -29,158 +29,177 @@ extern "C" { #define STACK_OF(type) struct stack_st_##type /* Helper macro for internal use */ -#define SKM_DEFINE_STACK_OF_INTERNAL(t1, t2, t3) \ - STACK_OF(t1); \ - typedef int (*sk_##t1##_compfunc)(const t3 *const *a, const t3 *const *b); \ - typedef void (*sk_##t1##_freefunc)(t3 * a); \ - typedef t3 *(*sk_##t1##_copyfunc)(const t3 *a); \ - static ossl_unused ossl_inline t2 *ossl_check_##t1##_type(t2 *ptr) \ - { \ - return ptr; \ - } \ - static ossl_unused ossl_inline const OPENSSL_STACK *ossl_check_const_##t1##_sk_type( \ - const STACK_OF(t1) * sk) \ - { \ - return (const OPENSSL_STACK *)sk; \ - } \ - static ossl_unused ossl_inline OPENSSL_STACK *ossl_check_##t1##_sk_type(STACK_OF(t1) * sk) \ - { \ - return (OPENSSL_STACK *)sk; \ - } \ - static ossl_unused ossl_inline OPENSSL_sk_compfunc ossl_check_##t1##_compfunc_type( \ - sk_##t1##_compfunc cmp) \ - { \ - return (OPENSSL_sk_compfunc)cmp; \ - } \ - static ossl_unused ossl_inline OPENSSL_sk_copyfunc ossl_check_##t1##_copyfunc_type( \ - sk_##t1##_copyfunc cpy) \ - { \ - return (OPENSSL_sk_copyfunc)cpy; \ - } \ - static ossl_unused ossl_inline OPENSSL_sk_freefunc ossl_check_##t1##_freefunc_type( \ - sk_##t1##_freefunc fr) \ - { \ - return (OPENSSL_sk_freefunc)fr; \ - } +#define SKM_DEFINE_STACK_OF_INTERNAL(t1, t2, t3) \ + STACK_OF(t1); \ + typedef int (*sk_##t1##_compfunc)(const t3 *const *a, const t3 *const *b); \ + typedef void (*sk_##t1##_freefunc)(t3 * a); \ + typedef t3 *(*sk_##t1##_copyfunc)(const t3 *a); \ + static ossl_unused ossl_inline t2 *ossl_check_##t1##_type(t2 *ptr) \ + { \ + return ptr; \ + } \ + static ossl_unused ossl_inline const OPENSSL_STACK \ + *ossl_check_const_##t1##_sk_type(const STACK_OF(t1) * sk) \ + { \ + return (const OPENSSL_STACK *)sk; \ + } \ + static ossl_unused ossl_inline OPENSSL_STACK *ossl_check_##t1##_sk_type( \ + STACK_OF(t1) * sk) \ + { \ + return (OPENSSL_STACK *)sk; \ + } \ + static ossl_unused ossl_inline OPENSSL_sk_compfunc \ + ossl_check_##t1##_compfunc_type(sk_##t1##_compfunc cmp) \ + { \ + return (OPENSSL_sk_compfunc)cmp; \ + } \ + static ossl_unused ossl_inline OPENSSL_sk_copyfunc \ + ossl_check_##t1##_copyfunc_type(sk_##t1##_copyfunc cpy) \ + { \ + return (OPENSSL_sk_copyfunc)cpy; \ + } \ + static ossl_unused ossl_inline OPENSSL_sk_freefunc \ + ossl_check_##t1##_freefunc_type(sk_##t1##_freefunc fr) \ + { \ + return (OPENSSL_sk_freefunc)fr; \ + } -#define SKM_DEFINE_STACK_OF(t1, t2, t3) \ - STACK_OF(t1); \ - typedef int (*sk_##t1##_compfunc)(const t3 *const *a, const t3 *const *b); \ - typedef void (*sk_##t1##_freefunc)(t3 * a); \ - typedef t3 *(*sk_##t1##_copyfunc)(const t3 *a); \ - static ossl_unused ossl_inline int sk_##t1##_num(const STACK_OF(t1) * sk) \ - { \ - return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) * sk, int idx) \ - { \ - return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_new(sk_##t1##_compfunc compare) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_new_null(void) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) \ - * sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_reserve(STACK_OF(t1) * sk, int n) \ - { \ - return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_free(STACK_OF(t1) * sk) \ - { \ - OPENSSL_sk_free((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_zero(STACK_OF(t1) * sk) \ - { \ - OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) * sk, int i) \ - { \ - return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) * sk, t2 * ptr) \ - { \ - return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_push(STACK_OF(t1) * sk, t2 * ptr) \ - { \ - return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_unshift(STACK_OF(t1) * sk, t2 * ptr) \ - { \ - return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) * sk) \ - { \ - return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) * sk) \ - { \ - return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) * sk, \ - sk_##t1##_freefunc freefunc) \ - { \ - OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_insert(STACK_OF(t1) * sk, t2 * ptr, int idx) \ - { \ - return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) * sk, int idx, t2 *ptr) \ - { \ - return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_find(STACK_OF(t1) * sk, t2 * ptr) \ - { \ - return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) * sk, t2 * ptr) \ - { \ - return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_find_all(STACK_OF(t1) * sk, t2 * ptr, int *pnum) \ - { \ - return OPENSSL_sk_find_all((OPENSSL_STACK *)sk, (const void *)ptr, pnum); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_sort(STACK_OF(t1) * sk) \ - { \ - OPENSSL_sk_sort((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) * sk) \ - { \ - return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) * sk) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) \ - * sk_##t1##_deep_copy(const STACK_OF(t1) * sk, sk_##t1##_copyfunc copyfunc, \ - sk_##t1##_freefunc freefunc) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \ - (OPENSSL_sk_copyfunc)copyfunc, \ - (OPENSSL_sk_freefunc)freefunc); \ - } \ - static ossl_unused ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func( \ - STACK_OF(t1) * sk, sk_##t1##_compfunc compare) \ - { \ - return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, \ - (OPENSSL_sk_compfunc)compare); \ - } +#define SKM_DEFINE_STACK_OF(t1, t2, t3) \ + STACK_OF(t1); \ + typedef int (*sk_##t1##_compfunc)(const t3 *const *a, const t3 *const *b); \ + typedef void (*sk_##t1##_freefunc)(t3 * a); \ + typedef t3 *(*sk_##t1##_copyfunc)(const t3 *a); \ + static ossl_unused ossl_inline int sk_##t1##_num(const STACK_OF(t1) * sk) \ + { \ + return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) * sk, \ + int idx) \ + { \ + return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) \ + * sk_##t1##_new(sk_##t1##_compfunc compare) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_new_null(void) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) \ + * sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_new_reserve( \ + (OPENSSL_sk_compfunc)compare, n); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_reserve(STACK_OF(t1) * sk, \ + int n) \ + { \ + return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_free(STACK_OF(t1) * sk) \ + { \ + OPENSSL_sk_free((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_zero(STACK_OF(t1) * sk) \ + { \ + OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) * sk, \ + int i) \ + { \ + return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) * sk, \ + t2 * ptr) \ + { \ + return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ + (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_push(STACK_OF(t1) * sk, \ + t2 * ptr) \ + { \ + return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_unshift(STACK_OF(t1) * sk, \ + t2 * ptr) \ + { \ + return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) * sk) \ + { \ + return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) * sk) \ + { \ + return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_pop_free( \ + STACK_OF(t1) * sk, sk_##t1##_freefunc freefunc) \ + { \ + OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_insert(STACK_OF(t1) * sk, \ + t2 * ptr, int idx) \ + { \ + return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \ + } \ + static ossl_unused ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) * sk, int idx, \ + t2 *ptr) \ + { \ + return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_find(STACK_OF(t1) * sk, \ + t2 * ptr) \ + { \ + return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) * sk, \ + t2 * ptr) \ + { \ + return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_find_all(STACK_OF(t1) * sk, \ + t2 * ptr, int *pnum) \ + { \ + return OPENSSL_sk_find_all((OPENSSL_STACK *)sk, (const void *)ptr, pnum); \ + } \ + static ossl_unused ossl_inline void sk_##t1##_sort(STACK_OF(t1) * sk) \ + { \ + OPENSSL_sk_sort((OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) \ + * sk) \ + { \ + return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) \ + * sk_##t1##_dup(const STACK_OF(t1) * sk) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ + } \ + static ossl_unused ossl_inline STACK_OF(t1) \ + * sk_##t1##_deep_copy(const STACK_OF(t1) * sk, \ + sk_##t1##_copyfunc copyfunc, \ + sk_##t1##_freefunc freefunc) \ + { \ + return (STACK_OF(t1) *)OPENSSL_sk_deep_copy( \ + (const OPENSSL_STACK *)sk, (OPENSSL_sk_copyfunc)copyfunc, \ + (OPENSSL_sk_freefunc)freefunc); \ + } \ + static ossl_unused ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func( \ + STACK_OF(t1) * sk, sk_##t1##_compfunc compare) \ + { \ + return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func( \ + (OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \ + } #define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t) #define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t) #define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2) -#define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) SKM_DEFINE_STACK_OF(t1, const t2, t2) +#define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \ + SKM_DEFINE_STACK_OF(t1, const t2, t2) /*- * Strings are special: normally an lhash entry will point to a single @@ -207,116 +226,142 @@ typedef const char *OPENSSL_CSTRING; * dealt with in the autogenerated macros below. */ SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_STRING, char, char) -#define sk_OPENSSL_STRING_num(sk) OPENSSL_sk_num(ossl_check_const_OPENSSL_STRING_sk_type(sk)) -#define sk_OPENSSL_STRING_value(sk, idx) \ - ((char *)OPENSSL_sk_value(ossl_check_const_OPENSSL_STRING_sk_type(sk), (idx))) -#define sk_OPENSSL_STRING_new(cmp) \ - ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new(ossl_check_OPENSSL_STRING_compfunc_type(cmp))) -#define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new_null()) -#define sk_OPENSSL_STRING_new_reserve(cmp, n) \ - ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new_reserve( \ - ossl_check_OPENSSL_STRING_compfunc_type(cmp), (n))) -#define sk_OPENSSL_STRING_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OPENSSL_STRING_sk_type(sk), (n)) -#define sk_OPENSSL_STRING_free(sk) OPENSSL_sk_free(ossl_check_OPENSSL_STRING_sk_type(sk)) -#define sk_OPENSSL_STRING_zero(sk) OPENSSL_sk_zero(ossl_check_OPENSSL_STRING_sk_type(sk)) -#define sk_OPENSSL_STRING_delete(sk, i) \ - ((char *)OPENSSL_sk_delete(ossl_check_OPENSSL_STRING_sk_type(sk), (i))) -#define sk_OPENSSL_STRING_delete_ptr(sk, ptr) \ - ((char *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_STRING_sk_type(sk), \ - ossl_check_OPENSSL_STRING_type(ptr))) -#define sk_OPENSSL_STRING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) -#define sk_OPENSSL_STRING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) -#define sk_OPENSSL_STRING_pop(sk) ((char *)OPENSSL_sk_pop(ossl_check_OPENSSL_STRING_sk_type(sk))) -#define sk_OPENSSL_STRING_shift(sk) \ - ((char *)OPENSSL_sk_shift(ossl_check_OPENSSL_STRING_sk_type(sk))) -#define sk_OPENSSL_STRING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OPENSSL_STRING_sk_type(sk), \ - ossl_check_OPENSSL_STRING_freefunc_type(freefunc)) -#define sk_OPENSSL_STRING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr), \ - (idx)) -#define sk_OPENSSL_STRING_set(sk, idx, ptr) \ - ((char *)OPENSSL_sk_set(ossl_check_OPENSSL_STRING_sk_type(sk), (idx), \ - ossl_check_OPENSSL_STRING_type(ptr))) -#define sk_OPENSSL_STRING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) -#define sk_OPENSSL_STRING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_type(ptr)) -#define sk_OPENSSL_STRING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OPENSSL_STRING_sk_type(sk), \ - ossl_check_OPENSSL_STRING_type(ptr), pnum) -#define sk_OPENSSL_STRING_sort(sk) OPENSSL_sk_sort(ossl_check_OPENSSL_STRING_sk_type(sk)) -#define sk_OPENSSL_STRING_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_STRING_sk_type(sk)) -#define sk_OPENSSL_STRING_dup(sk) \ - ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_dup(ossl_check_const_OPENSSL_STRING_sk_type(sk))) -#define sk_OPENSSL_STRING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OPENSSL_STRING_sk_type(sk), \ - ossl_check_OPENSSL_STRING_copyfunc_type(copyfunc), \ - ossl_check_OPENSSL_STRING_freefunc_type(freefunc))) -#define sk_OPENSSL_STRING_set_cmp_func(sk, cmp) \ - ((sk_OPENSSL_STRING_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OPENSSL_STRING_sk_type(sk), ossl_check_OPENSSL_STRING_compfunc_type(cmp))) +#define sk_OPENSSL_STRING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_value(sk, idx) \ + ((char *)OPENSSL_sk_value(ossl_check_const_OPENSSL_STRING_sk_type(sk), (idx))) +#define sk_OPENSSL_STRING_new(cmp) \ + ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new( \ + ossl_check_OPENSSL_STRING_compfunc_type(cmp))) +#define sk_OPENSSL_STRING_new_null() \ + ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new_null()) +#define sk_OPENSSL_STRING_new_reserve(cmp, n) \ + ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_new_reserve( \ + ossl_check_OPENSSL_STRING_compfunc_type(cmp), (n))) +#define sk_OPENSSL_STRING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OPENSSL_STRING_sk_type(sk), (n)) +#define sk_OPENSSL_STRING_free(sk) \ + OPENSSL_sk_free(ossl_check_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_delete(sk, i) \ + ((char *)OPENSSL_sk_delete(ossl_check_OPENSSL_STRING_sk_type(sk), (i))) +#define sk_OPENSSL_STRING_delete_ptr(sk, ptr) \ + ((char *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr))) +#define sk_OPENSSL_STRING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_pop(sk) \ + ((char *)OPENSSL_sk_pop(ossl_check_OPENSSL_STRING_sk_type(sk))) +#define sk_OPENSSL_STRING_shift(sk) \ + ((char *)OPENSSL_sk_shift(ossl_check_OPENSSL_STRING_sk_type(sk))) +#define sk_OPENSSL_STRING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_freefunc_type(freefunc)) +#define sk_OPENSSL_STRING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr), (idx)) +#define sk_OPENSSL_STRING_set(sk, idx, ptr) \ + ((char *)OPENSSL_sk_set(ossl_check_OPENSSL_STRING_sk_type(sk), (idx), \ + ossl_check_OPENSSL_STRING_type(ptr))) +#define sk_OPENSSL_STRING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr)) +#define sk_OPENSSL_STRING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_type(ptr), pnum) +#define sk_OPENSSL_STRING_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_STRING_sk_type(sk)) +#define sk_OPENSSL_STRING_dup(sk) \ + ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_dup( \ + ossl_check_const_OPENSSL_STRING_sk_type(sk))) +#define sk_OPENSSL_STRING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OPENSSL_STRING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_copyfunc_type(copyfunc), \ + ossl_check_OPENSSL_STRING_freefunc_type(freefunc))) +#define sk_OPENSSL_STRING_set_cmp_func(sk, cmp) \ + ((sk_OPENSSL_STRING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OPENSSL_STRING_sk_type(sk), \ + ossl_check_OPENSSL_STRING_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_CSTRING, const char, char) -#define sk_OPENSSL_CSTRING_num(sk) OPENSSL_sk_num(ossl_check_const_OPENSSL_CSTRING_sk_type(sk)) -#define sk_OPENSSL_CSTRING_value(sk, idx) \ - ((const char *)OPENSSL_sk_value(ossl_check_const_OPENSSL_CSTRING_sk_type(sk), (idx))) -#define sk_OPENSSL_CSTRING_new(cmp) \ - ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new(ossl_check_OPENSSL_CSTRING_compfunc_type(cmp))) -#define sk_OPENSSL_CSTRING_new_null() ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new_null()) -#define sk_OPENSSL_CSTRING_new_reserve(cmp, n) \ - ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new_reserve( \ - ossl_check_OPENSSL_CSTRING_compfunc_type(cmp), (n))) -#define sk_OPENSSL_CSTRING_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OPENSSL_CSTRING_sk_type(sk), (n)) -#define sk_OPENSSL_CSTRING_free(sk) OPENSSL_sk_free(ossl_check_OPENSSL_CSTRING_sk_type(sk)) -#define sk_OPENSSL_CSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_OPENSSL_CSTRING_sk_type(sk)) -#define sk_OPENSSL_CSTRING_delete(sk, i) \ - ((const char *)OPENSSL_sk_delete(ossl_check_OPENSSL_CSTRING_sk_type(sk), (i))) -#define sk_OPENSSL_CSTRING_delete_ptr(sk, ptr) \ - ((const char *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ - ossl_check_OPENSSL_CSTRING_type(ptr))) -#define sk_OPENSSL_CSTRING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) -#define sk_OPENSSL_CSTRING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) -#define sk_OPENSSL_CSTRING_pop(sk) \ - ((const char *)OPENSSL_sk_pop(ossl_check_OPENSSL_CSTRING_sk_type(sk))) -#define sk_OPENSSL_CSTRING_shift(sk) \ - ((const char *)OPENSSL_sk_shift(ossl_check_OPENSSL_CSTRING_sk_type(sk))) -#define sk_OPENSSL_CSTRING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ - ossl_check_OPENSSL_CSTRING_freefunc_type(freefunc)) -#define sk_OPENSSL_CSTRING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ - ossl_check_OPENSSL_CSTRING_type(ptr), (idx)) -#define sk_OPENSSL_CSTRING_set(sk, idx, ptr) \ - ((const char *)OPENSSL_sk_set(ossl_check_OPENSSL_CSTRING_sk_type(sk), (idx), \ - ossl_check_OPENSSL_CSTRING_type(ptr))) -#define sk_OPENSSL_CSTRING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) -#define sk_OPENSSL_CSTRING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_type(ptr)) -#define sk_OPENSSL_CSTRING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ - ossl_check_OPENSSL_CSTRING_type(ptr), pnum) -#define sk_OPENSSL_CSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_OPENSSL_CSTRING_sk_type(sk)) -#define sk_OPENSSL_CSTRING_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_CSTRING_sk_type(sk)) -#define sk_OPENSSL_CSTRING_dup(sk) \ - ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_dup(ossl_check_const_OPENSSL_CSTRING_sk_type(sk))) -#define sk_OPENSSL_CSTRING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OPENSSL_CSTRING_sk_type(sk), \ - ossl_check_OPENSSL_CSTRING_copyfunc_type(copyfunc), \ - ossl_check_OPENSSL_CSTRING_freefunc_type(freefunc))) -#define sk_OPENSSL_CSTRING_set_cmp_func(sk, cmp) \ - ((sk_OPENSSL_CSTRING_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OPENSSL_CSTRING_sk_type(sk), ossl_check_OPENSSL_CSTRING_compfunc_type(cmp))) +#define sk_OPENSSL_CSTRING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_value(sk, idx) \ + ((const char *)OPENSSL_sk_value( \ + ossl_check_const_OPENSSL_CSTRING_sk_type(sk), (idx))) +#define sk_OPENSSL_CSTRING_new(cmp) \ + ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new( \ + ossl_check_OPENSSL_CSTRING_compfunc_type(cmp))) +#define sk_OPENSSL_CSTRING_new_null() \ + ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new_null()) +#define sk_OPENSSL_CSTRING_new_reserve(cmp, n) \ + ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_new_reserve( \ + ossl_check_OPENSSL_CSTRING_compfunc_type(cmp), (n))) +#define sk_OPENSSL_CSTRING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OPENSSL_CSTRING_sk_type(sk), (n)) +#define sk_OPENSSL_CSTRING_free(sk) \ + OPENSSL_sk_free(ossl_check_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_delete(sk, i) \ + ((const char *)OPENSSL_sk_delete(ossl_check_OPENSSL_CSTRING_sk_type(sk), (i))) +#define sk_OPENSSL_CSTRING_delete_ptr(sk, ptr) \ + ((const char *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr))) +#define sk_OPENSSL_CSTRING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_pop(sk) \ + ((const char *)OPENSSL_sk_pop(ossl_check_OPENSSL_CSTRING_sk_type(sk))) +#define sk_OPENSSL_CSTRING_shift(sk) \ + ((const char *)OPENSSL_sk_shift(ossl_check_OPENSSL_CSTRING_sk_type(sk))) +#define sk_OPENSSL_CSTRING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_freefunc_type(freefunc)) +#define sk_OPENSSL_CSTRING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr), (idx)) +#define sk_OPENSSL_CSTRING_set(sk, idx, ptr) \ + ((const char *)OPENSSL_sk_set(ossl_check_OPENSSL_CSTRING_sk_type(sk), (idx), \ + ossl_check_OPENSSL_CSTRING_type(ptr))) +#define sk_OPENSSL_CSTRING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr)) +#define sk_OPENSSL_CSTRING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_type(ptr), pnum) +#define sk_OPENSSL_CSTRING_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_CSTRING_sk_type(sk)) +#define sk_OPENSSL_CSTRING_dup(sk) \ + ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_dup( \ + ossl_check_const_OPENSSL_CSTRING_sk_type(sk))) +#define sk_OPENSSL_CSTRING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OPENSSL_CSTRING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_copyfunc_type(copyfunc), \ + ossl_check_OPENSSL_CSTRING_freefunc_type(freefunc))) +#define sk_OPENSSL_CSTRING_set_cmp_func(sk, cmp) \ + ((sk_OPENSSL_CSTRING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OPENSSL_CSTRING_sk_type(sk), \ + ossl_check_OPENSSL_CSTRING_compfunc_type(cmp))) #if !defined(OPENSSL_NO_DEPRECATED_3_0) /* @@ -325,60 +370,74 @@ SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_CSTRING, const char, char) */ typedef void *OPENSSL_BLOCK; SKM_DEFINE_STACK_OF_INTERNAL(OPENSSL_BLOCK, void, void) -# define sk_OPENSSL_BLOCK_num(sk) OPENSSL_sk_num(ossl_check_const_OPENSSL_BLOCK_sk_type(sk)) -# define sk_OPENSSL_BLOCK_value(sk, idx) \ - ((void *)OPENSSL_sk_value(ossl_check_const_OPENSSL_BLOCK_sk_type(sk), (idx))) -# define sk_OPENSSL_BLOCK_new(cmp) \ - ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new(ossl_check_OPENSSL_BLOCK_compfunc_type(cmp))) -# define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new_null()) -# define sk_OPENSSL_BLOCK_new_reserve(cmp, n) \ - ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new_reserve( \ - ossl_check_OPENSSL_BLOCK_compfunc_type(cmp), (n))) -# define sk_OPENSSL_BLOCK_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_OPENSSL_BLOCK_sk_type(sk), (n)) -# define sk_OPENSSL_BLOCK_free(sk) OPENSSL_sk_free(ossl_check_OPENSSL_BLOCK_sk_type(sk)) -# define sk_OPENSSL_BLOCK_zero(sk) OPENSSL_sk_zero(ossl_check_OPENSSL_BLOCK_sk_type(sk)) -# define sk_OPENSSL_BLOCK_delete(sk, i) \ - ((void *)OPENSSL_sk_delete(ossl_check_OPENSSL_BLOCK_sk_type(sk), (i))) -# define sk_OPENSSL_BLOCK_delete_ptr(sk, ptr) \ - ((void *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ - ossl_check_OPENSSL_BLOCK_type(ptr))) -# define sk_OPENSSL_BLOCK_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) -# define sk_OPENSSL_BLOCK_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) -# define sk_OPENSSL_BLOCK_pop(sk) ((void *)OPENSSL_sk_pop(ossl_check_OPENSSL_BLOCK_sk_type(sk))) -# define sk_OPENSSL_BLOCK_shift(sk) \ - ((void *)OPENSSL_sk_shift(ossl_check_OPENSSL_BLOCK_sk_type(sk))) -# define sk_OPENSSL_BLOCK_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ - ossl_check_OPENSSL_BLOCK_freefunc_type(freefunc)) -# define sk_OPENSSL_BLOCK_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ - ossl_check_OPENSSL_BLOCK_type(ptr), (idx)) -# define sk_OPENSSL_BLOCK_set(sk, idx, ptr) \ - ((void *)OPENSSL_sk_set(ossl_check_OPENSSL_BLOCK_sk_type(sk), (idx), \ - ossl_check_OPENSSL_BLOCK_type(ptr))) -# define sk_OPENSSL_BLOCK_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) -# define sk_OPENSSL_BLOCK_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_type(ptr)) -# define sk_OPENSSL_BLOCK_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ - ossl_check_OPENSSL_BLOCK_type(ptr), pnum) -# define sk_OPENSSL_BLOCK_sort(sk) OPENSSL_sk_sort(ossl_check_OPENSSL_BLOCK_sk_type(sk)) -# define sk_OPENSSL_BLOCK_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_BLOCK_sk_type(sk)) -# define sk_OPENSSL_BLOCK_dup(sk) \ - ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_dup(ossl_check_const_OPENSSL_BLOCK_sk_type(sk))) -# define sk_OPENSSL_BLOCK_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_OPENSSL_BLOCK_sk_type(sk), \ - ossl_check_OPENSSL_BLOCK_copyfunc_type(copyfunc), \ - ossl_check_OPENSSL_BLOCK_freefunc_type(freefunc))) -# define sk_OPENSSL_BLOCK_set_cmp_func(sk, cmp) \ - ((sk_OPENSSL_BLOCK_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_OPENSSL_BLOCK_sk_type(sk), ossl_check_OPENSSL_BLOCK_compfunc_type(cmp))) +# define sk_OPENSSL_BLOCK_num(sk) \ + OPENSSL_sk_num(ossl_check_const_OPENSSL_BLOCK_sk_type(sk)) +# define sk_OPENSSL_BLOCK_value(sk, idx) \ + ((void *)OPENSSL_sk_value(ossl_check_const_OPENSSL_BLOCK_sk_type(sk), \ + (idx))) +# define sk_OPENSSL_BLOCK_new(cmp) \ + ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new( \ + ossl_check_OPENSSL_BLOCK_compfunc_type(cmp))) +# define sk_OPENSSL_BLOCK_new_null() \ + ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new_null()) +# define sk_OPENSSL_BLOCK_new_reserve(cmp, n) \ + ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_new_reserve( \ + ossl_check_OPENSSL_BLOCK_compfunc_type(cmp), (n))) +# define sk_OPENSSL_BLOCK_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_OPENSSL_BLOCK_sk_type(sk), (n)) +# define sk_OPENSSL_BLOCK_free(sk) \ + OPENSSL_sk_free(ossl_check_OPENSSL_BLOCK_sk_type(sk)) +# define sk_OPENSSL_BLOCK_zero(sk) \ + OPENSSL_sk_zero(ossl_check_OPENSSL_BLOCK_sk_type(sk)) +# define sk_OPENSSL_BLOCK_delete(sk, i) \ + ((void *)OPENSSL_sk_delete(ossl_check_OPENSSL_BLOCK_sk_type(sk), (i))) +# define sk_OPENSSL_BLOCK_delete_ptr(sk, ptr) \ + ((void *)OPENSSL_sk_delete_ptr(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr))) +# define sk_OPENSSL_BLOCK_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr)) +# define sk_OPENSSL_BLOCK_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr)) +# define sk_OPENSSL_BLOCK_pop(sk) \ + ((void *)OPENSSL_sk_pop(ossl_check_OPENSSL_BLOCK_sk_type(sk))) +# define sk_OPENSSL_BLOCK_shift(sk) \ + ((void *)OPENSSL_sk_shift(ossl_check_OPENSSL_BLOCK_sk_type(sk))) +# define sk_OPENSSL_BLOCK_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_freefunc_type(freefunc)) +# define sk_OPENSSL_BLOCK_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr), (idx)) +# define sk_OPENSSL_BLOCK_set(sk, idx, ptr) \ + ((void *)OPENSSL_sk_set(ossl_check_OPENSSL_BLOCK_sk_type(sk), (idx), \ + ossl_check_OPENSSL_BLOCK_type(ptr))) +# define sk_OPENSSL_BLOCK_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr)) +# define sk_OPENSSL_BLOCK_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr)) +# define sk_OPENSSL_BLOCK_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_type(ptr), pnum) +# define sk_OPENSSL_BLOCK_sort(sk) \ + OPENSSL_sk_sort(ossl_check_OPENSSL_BLOCK_sk_type(sk)) +# define sk_OPENSSL_BLOCK_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_OPENSSL_BLOCK_sk_type(sk)) +# define sk_OPENSSL_BLOCK_dup(sk) \ + ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_dup( \ + ossl_check_const_OPENSSL_BLOCK_sk_type(sk))) +# define sk_OPENSSL_BLOCK_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(OPENSSL_BLOCK) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_copyfunc_type(copyfunc), \ + ossl_check_OPENSSL_BLOCK_freefunc_type(freefunc))) +# define sk_OPENSSL_BLOCK_set_cmp_func(sk, cmp) \ + ((sk_OPENSSL_BLOCK_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_OPENSSL_BLOCK_sk_type(sk), \ + ossl_check_OPENSSL_BLOCK_compfunc_type(cmp))) #endif diff --git a/libs/OpenSSL/include/openssl/seed.h b/libs/OpenSSL/include/openssl/seed.h index 7484e52c..54edc993 100644 --- a/libs/OpenSSL/include/openssl/seed.h +++ b/libs/OpenSSL/include/openssl/seed.h @@ -8,7 +8,8 @@ */ /* - * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. + * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights + * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,68 +39,73 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SEED_H +# define HEADER_SEED_H #endif #include #ifndef OPENSSL_NO_SEED -# include -# include -# include +# include +# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# define SEED_BLOCK_SIZE 16 -# define SEED_KEY_LENGTH 16 +# define SEED_BLOCK_SIZE 16 +# define SEED_KEY_LENGTH 16 -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /* look whether we need 'long' to get 32 bits */ -# ifdef AES_LONG -# ifndef SEED_LONG -# define SEED_LONG 1 -# endif -# endif +# ifdef AES_LONG +# ifndef SEED_LONG +# define SEED_LONG 1 +# endif +# endif typedef struct seed_key_st { -# ifdef SEED_LONG - unsigned long data[32]; -# else - unsigned int data[32]; -# endif +# ifdef SEED_LONG + unsigned long data[32]; +# else + unsigned int data[32]; +# endif } SEED_KEY_SCHEDULE; -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks); +void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], + SEED_KEY_SCHEDULE *ks); OSSL_DEPRECATEDIN_3_0 -void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], +void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], + unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks); OSSL_DEPRECATEDIN_3_0 -void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], +void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], + unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks); OSSL_DEPRECATEDIN_3_0 -void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, const SEED_KEY_SCHEDULE *ks, - int enc); +void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, + const SEED_KEY_SCHEDULE *ks, int enc); OSSL_DEPRECATEDIN_3_0 void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int enc); + const SEED_KEY_SCHEDULE *ks, + unsigned char ivec[SEED_BLOCK_SIZE], int enc); OSSL_DEPRECATEDIN_3_0 -void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num, +void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const SEED_KEY_SCHEDULE *ks, + unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc); OSSL_DEPRECATEDIN_3_0 -void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], - int *num); -# endif +void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const SEED_KEY_SCHEDULE *ks, + unsigned char ivec[SEED_BLOCK_SIZE], int *num); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/self_test.h b/libs/OpenSSL/include/openssl/self_test.h index 523f529b..b18af8c6 100644 --- a/libs/OpenSSL/include/openssl/self_test.h +++ b/libs/OpenSSL/include/openssl/self_test.h @@ -75,13 +75,16 @@ extern "C" { #define OSSL_SELF_TEST_DESC_KDF_TLS13_EXPAND "TLS13_KDF_EXPAND" #define OSSL_SELF_TEST_DESC_RNG "RNG" -void OSSL_SELF_TEST_set_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK *cb, void *cbarg); -void OSSL_SELF_TEST_get_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK **cb, void **cbarg); +void OSSL_SELF_TEST_set_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK *cb, + void *cbarg); +void OSSL_SELF_TEST_get_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK **cb, + void **cbarg); OSSL_SELF_TEST *OSSL_SELF_TEST_new(OSSL_CALLBACK *cb, void *cbarg); void OSSL_SELF_TEST_free(OSSL_SELF_TEST *st); -void OSSL_SELF_TEST_onbegin(OSSL_SELF_TEST *st, const char *type, const char *desc); +void OSSL_SELF_TEST_onbegin(OSSL_SELF_TEST *st, const char *type, + const char *desc); int OSSL_SELF_TEST_oncorrupt_byte(OSSL_SELF_TEST *st, unsigned char *bytes); void OSSL_SELF_TEST_onend(OSSL_SELF_TEST *st, int ret); diff --git a/libs/OpenSSL/include/openssl/sha.h b/libs/OpenSSL/include/openssl/sha.h index dd6e154d..8d116b93 100644 --- a/libs/OpenSSL/include/openssl/sha.h +++ b/libs/OpenSSL/include/openssl/sha.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SHA_H +# define HEADER_SHA_H #endif #include @@ -31,52 +31,56 @@ extern "C" { * ! SHA_LONG has to be at least 32 bits wide. ! * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -# define SHA_LONG unsigned int +# define SHA_LONG unsigned int -# define SHA_LBLOCK 16 -# define SHA_CBLOCK \ - (SHA_LBLOCK * 4) /* SHA treats input data as a \ - * contiguous array of 32 bit wide \ - * big-endian values. */ -# define SHA_LAST_BLOCK (SHA_CBLOCK - 8) +# define SHA_LBLOCK 16 +# define SHA_CBLOCK \ + (SHA_LBLOCK * 4) /* SHA treats input data as a \ + * contiguous array of 32 bit wide \ + * big-endian values. */ +# define SHA_LAST_BLOCK (SHA_CBLOCK - 8) typedef struct SHAstate_st { - SHA_LONG h0, h1, h2, h3, h4; - SHA_LONG Nl, Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num; + SHA_LONG h0, h1, h2, h3, h4; + SHA_LONG Nl, Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num; } SHA_CTX; OSSL_DEPRECATEDIN_3_0 int SHA1_Init(SHA_CTX *c); OSSL_DEPRECATEDIN_3_0 int SHA1_Update(SHA_CTX *c, const void *data, size_t len); OSSL_DEPRECATEDIN_3_0 int SHA1_Final(unsigned char *md, SHA_CTX *c); -OSSL_DEPRECATEDIN_3_0 void SHA1_Transform(SHA_CTX *c, const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 void SHA1_Transform(SHA_CTX *c, + const unsigned char *data); #endif unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SHA256_CBLOCK \ - (SHA_LBLOCK * 4) /* SHA-256 treats input data as a \ - * contiguous array of 32 bit wide \ - * big-endian values. */ +# define SHA256_CBLOCK \ + (SHA_LBLOCK * 4) /* SHA-256 treats input data as a \ + * contiguous array of 32 bit wide \ + * big-endian values. */ typedef struct SHA256state_st { - SHA_LONG h[8]; - SHA_LONG Nl, Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num, md_len; + SHA_LONG h[8]; + SHA_LONG Nl, Nh; + SHA_LONG data[SHA_LBLOCK]; + unsigned int num, md_len; } SHA256_CTX; OSSL_DEPRECATEDIN_3_0 int SHA224_Init(SHA256_CTX *c); -OSSL_DEPRECATEDIN_3_0 int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA224_Update(SHA256_CTX *c, const void *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int SHA224_Final(unsigned char *md, SHA256_CTX *c); OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c); -OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c, const void *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c); -OSSL_DEPRECATEDIN_3_0 void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 void SHA256_Transform(SHA256_CTX *c, + const unsigned char *data); #endif unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md); @@ -98,34 +102,37 @@ unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md); * contiguous array of 64 bit * wide big-endian values. */ -# define SHA512_CBLOCK (SHA_LBLOCK * 8) -# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -# define SHA_LONG64 unsigned __int64 -# elif defined(__arch64__) -# define SHA_LONG64 unsigned long -# else -# define SHA_LONG64 unsigned long long -# endif +# define SHA512_CBLOCK (SHA_LBLOCK * 8) +# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +# define SHA_LONG64 unsigned __int64 +# elif defined(__arch64__) +# define SHA_LONG64 unsigned long +# else +# define SHA_LONG64 unsigned long long +# endif typedef struct SHA512state_st { - SHA_LONG64 h[8]; - SHA_LONG64 Nl, Nh; - union - { - SHA_LONG64 d[SHA_LBLOCK]; - unsigned char p[SHA512_CBLOCK]; - } u; - unsigned int num, md_len; + SHA_LONG64 h[8]; + SHA_LONG64 Nl, Nh; + union + { + SHA_LONG64 d[SHA_LBLOCK]; + unsigned char p[SHA512_CBLOCK]; + } u; + unsigned int num, md_len; } SHA512_CTX; OSSL_DEPRECATEDIN_3_0 int SHA384_Init(SHA512_CTX *c); -OSSL_DEPRECATEDIN_3_0 int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA384_Update(SHA512_CTX *c, const void *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int SHA384_Final(unsigned char *md, SHA512_CTX *c); OSSL_DEPRECATEDIN_3_0 int SHA512_Init(SHA512_CTX *c); -OSSL_DEPRECATEDIN_3_0 int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); +OSSL_DEPRECATEDIN_3_0 int SHA512_Update(SHA512_CTX *c, const void *data, + size_t len); OSSL_DEPRECATEDIN_3_0 int SHA512_Final(unsigned char *md, SHA512_CTX *c); -OSSL_DEPRECATEDIN_3_0 void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); +OSSL_DEPRECATEDIN_3_0 void SHA512_Transform(SHA512_CTX *c, + const unsigned char *data); #endif unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md); diff --git a/libs/OpenSSL/include/openssl/srp.h b/libs/OpenSSL/include/openssl/srp.h index a87d6862..57efa744 100644 --- a/libs/OpenSSL/include/openssl/srp.h +++ b/libs/OpenSSL/include/openssl/srp.h @@ -20,158 +20,186 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SRP_H +# define HEADER_SRP_H #endif #include #ifndef OPENSSL_NO_SRP -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct SRP_gN_cache_st { - char *b64_bn; - BIGNUM *bn; + char *b64_bn; + BIGNUM *bn; } SRP_gN_cache; SKM_DEFINE_STACK_OF_INTERNAL(SRP_gN_cache, SRP_gN_cache, SRP_gN_cache) -# define sk_SRP_gN_cache_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_gN_cache_sk_type(sk)) -# define sk_SRP_gN_cache_value(sk, idx) \ - ((SRP_gN_cache *)OPENSSL_sk_value(ossl_check_const_SRP_gN_cache_sk_type(sk), (idx))) -# define sk_SRP_gN_cache_new(cmp) \ - ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new(ossl_check_SRP_gN_cache_compfunc_type(cmp))) -# define sk_SRP_gN_cache_new_null() ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new_null()) -# define sk_SRP_gN_cache_new_reserve(cmp, n) \ - ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new_reserve( \ - ossl_check_SRP_gN_cache_compfunc_type(cmp), (n))) -# define sk_SRP_gN_cache_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_SRP_gN_cache_sk_type(sk), (n)) -# define sk_SRP_gN_cache_free(sk) OPENSSL_sk_free(ossl_check_SRP_gN_cache_sk_type(sk)) -# define sk_SRP_gN_cache_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_gN_cache_sk_type(sk)) -# define sk_SRP_gN_cache_delete(sk, i) \ - ((SRP_gN_cache *)OPENSSL_sk_delete(ossl_check_SRP_gN_cache_sk_type(sk), (i))) -# define sk_SRP_gN_cache_delete_ptr(sk, ptr) \ - ((SRP_gN_cache *)OPENSSL_sk_delete_ptr(ossl_check_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_type(ptr))) -# define sk_SRP_gN_cache_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr)) -# define sk_SRP_gN_cache_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_type(ptr)) -# define sk_SRP_gN_cache_pop(sk) \ - ((SRP_gN_cache *)OPENSSL_sk_pop(ossl_check_SRP_gN_cache_sk_type(sk))) -# define sk_SRP_gN_cache_shift(sk) \ - ((SRP_gN_cache *)OPENSSL_sk_shift(ossl_check_SRP_gN_cache_sk_type(sk))) -# define sk_SRP_gN_cache_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_freefunc_type(freefunc)) -# define sk_SRP_gN_cache_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_type(ptr), (idx)) -# define sk_SRP_gN_cache_set(sk, idx, ptr) \ - ((SRP_gN_cache *)OPENSSL_sk_set(ossl_check_SRP_gN_cache_sk_type(sk), (idx), \ - ossl_check_SRP_gN_cache_type(ptr))) -# define sk_SRP_gN_cache_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_type(ptr)) -# define sk_SRP_gN_cache_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_type(ptr)) -# define sk_SRP_gN_cache_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_type(ptr), pnum) -# define sk_SRP_gN_cache_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_gN_cache_sk_type(sk)) -# define sk_SRP_gN_cache_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_SRP_gN_cache_sk_type(sk)) -# define sk_SRP_gN_cache_dup(sk) \ - ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_dup(ossl_check_const_SRP_gN_cache_sk_type(sk))) -# define sk_SRP_gN_cache_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_SRP_gN_cache_sk_type(sk), \ - ossl_check_SRP_gN_cache_copyfunc_type(copyfunc), \ - ossl_check_SRP_gN_cache_freefunc_type(freefunc))) -# define sk_SRP_gN_cache_set_cmp_func(sk, cmp) \ - ((sk_SRP_gN_cache_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_SRP_gN_cache_sk_type(sk), ossl_check_SRP_gN_cache_compfunc_type(cmp))) +# define sk_SRP_gN_cache_num(sk) \ + OPENSSL_sk_num(ossl_check_const_SRP_gN_cache_sk_type(sk)) +# define sk_SRP_gN_cache_value(sk, idx) \ + ((SRP_gN_cache *)OPENSSL_sk_value( \ + ossl_check_const_SRP_gN_cache_sk_type(sk), (idx))) +# define sk_SRP_gN_cache_new(cmp) \ + ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new( \ + ossl_check_SRP_gN_cache_compfunc_type(cmp))) +# define sk_SRP_gN_cache_new_null() \ + ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new_null()) +# define sk_SRP_gN_cache_new_reserve(cmp, n) \ + ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_new_reserve( \ + ossl_check_SRP_gN_cache_compfunc_type(cmp), (n))) +# define sk_SRP_gN_cache_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SRP_gN_cache_sk_type(sk), (n)) +# define sk_SRP_gN_cache_free(sk) \ + OPENSSL_sk_free(ossl_check_SRP_gN_cache_sk_type(sk)) +# define sk_SRP_gN_cache_zero(sk) \ + OPENSSL_sk_zero(ossl_check_SRP_gN_cache_sk_type(sk)) +# define sk_SRP_gN_cache_delete(sk, i) \ + ((SRP_gN_cache *)OPENSSL_sk_delete(ossl_check_SRP_gN_cache_sk_type(sk), \ + (i))) +# define sk_SRP_gN_cache_delete_ptr(sk, ptr) \ + ((SRP_gN_cache *)OPENSSL_sk_delete_ptr( \ + ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr))) +# define sk_SRP_gN_cache_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr)) +# define sk_SRP_gN_cache_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr)) +# define sk_SRP_gN_cache_pop(sk) \ + ((SRP_gN_cache *)OPENSSL_sk_pop(ossl_check_SRP_gN_cache_sk_type(sk))) +# define sk_SRP_gN_cache_shift(sk) \ + ((SRP_gN_cache *)OPENSSL_sk_shift(ossl_check_SRP_gN_cache_sk_type(sk))) +# define sk_SRP_gN_cache_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_freefunc_type(freefunc)) +# define sk_SRP_gN_cache_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr), (idx)) +# define sk_SRP_gN_cache_set(sk, idx, ptr) \ + ((SRP_gN_cache *)OPENSSL_sk_set(ossl_check_SRP_gN_cache_sk_type(sk), \ + (idx), \ + ossl_check_SRP_gN_cache_type(ptr))) +# define sk_SRP_gN_cache_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr)) +# define sk_SRP_gN_cache_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr)) +# define sk_SRP_gN_cache_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_type(ptr), pnum) +# define sk_SRP_gN_cache_sort(sk) \ + OPENSSL_sk_sort(ossl_check_SRP_gN_cache_sk_type(sk)) +# define sk_SRP_gN_cache_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SRP_gN_cache_sk_type(sk)) +# define sk_SRP_gN_cache_dup(sk) \ + ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_dup( \ + ossl_check_const_SRP_gN_cache_sk_type(sk))) +# define sk_SRP_gN_cache_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SRP_gN_cache) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_copyfunc_type(copyfunc), \ + ossl_check_SRP_gN_cache_freefunc_type(freefunc))) +# define sk_SRP_gN_cache_set_cmp_func(sk, cmp) \ + ((sk_SRP_gN_cache_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SRP_gN_cache_sk_type(sk), \ + ossl_check_SRP_gN_cache_compfunc_type(cmp))) typedef struct SRP_user_pwd_st { - /* Owned by us. */ - char *id; - BIGNUM *s; - BIGNUM *v; - /* Not owned by us. */ - const BIGNUM *g; - const BIGNUM *N; - /* Owned by us. */ - char *info; + /* Owned by us. */ + char *id; + BIGNUM *s; + BIGNUM *v; + /* Not owned by us. */ + const BIGNUM *g; + const BIGNUM *N; + /* Owned by us. */ + char *info; } SRP_user_pwd; SKM_DEFINE_STACK_OF_INTERNAL(SRP_user_pwd, SRP_user_pwd, SRP_user_pwd) -# define sk_SRP_user_pwd_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_user_pwd_sk_type(sk)) -# define sk_SRP_user_pwd_value(sk, idx) \ - ((SRP_user_pwd *)OPENSSL_sk_value(ossl_check_const_SRP_user_pwd_sk_type(sk), (idx))) -# define sk_SRP_user_pwd_new(cmp) \ - ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new(ossl_check_SRP_user_pwd_compfunc_type(cmp))) -# define sk_SRP_user_pwd_new_null() ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new_null()) -# define sk_SRP_user_pwd_new_reserve(cmp, n) \ - ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new_reserve( \ - ossl_check_SRP_user_pwd_compfunc_type(cmp), (n))) -# define sk_SRP_user_pwd_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_SRP_user_pwd_sk_type(sk), (n)) -# define sk_SRP_user_pwd_free(sk) OPENSSL_sk_free(ossl_check_SRP_user_pwd_sk_type(sk)) -# define sk_SRP_user_pwd_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_user_pwd_sk_type(sk)) -# define sk_SRP_user_pwd_delete(sk, i) \ - ((SRP_user_pwd *)OPENSSL_sk_delete(ossl_check_SRP_user_pwd_sk_type(sk), (i))) -# define sk_SRP_user_pwd_delete_ptr(sk, ptr) \ - ((SRP_user_pwd *)OPENSSL_sk_delete_ptr(ossl_check_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_type(ptr))) -# define sk_SRP_user_pwd_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr)) -# define sk_SRP_user_pwd_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_type(ptr)) -# define sk_SRP_user_pwd_pop(sk) \ - ((SRP_user_pwd *)OPENSSL_sk_pop(ossl_check_SRP_user_pwd_sk_type(sk))) -# define sk_SRP_user_pwd_shift(sk) \ - ((SRP_user_pwd *)OPENSSL_sk_shift(ossl_check_SRP_user_pwd_sk_type(sk))) -# define sk_SRP_user_pwd_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_freefunc_type(freefunc)) -# define sk_SRP_user_pwd_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_type(ptr), (idx)) -# define sk_SRP_user_pwd_set(sk, idx, ptr) \ - ((SRP_user_pwd *)OPENSSL_sk_set(ossl_check_SRP_user_pwd_sk_type(sk), (idx), \ - ossl_check_SRP_user_pwd_type(ptr))) -# define sk_SRP_user_pwd_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_type(ptr)) -# define sk_SRP_user_pwd_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_type(ptr)) -# define sk_SRP_user_pwd_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_type(ptr), pnum) -# define sk_SRP_user_pwd_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_user_pwd_sk_type(sk)) -# define sk_SRP_user_pwd_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_SRP_user_pwd_sk_type(sk)) -# define sk_SRP_user_pwd_dup(sk) \ - ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_dup(ossl_check_const_SRP_user_pwd_sk_type(sk))) -# define sk_SRP_user_pwd_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_SRP_user_pwd_sk_type(sk), \ - ossl_check_SRP_user_pwd_copyfunc_type(copyfunc), \ - ossl_check_SRP_user_pwd_freefunc_type(freefunc))) -# define sk_SRP_user_pwd_set_cmp_func(sk, cmp) \ - ((sk_SRP_user_pwd_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_SRP_user_pwd_sk_type(sk), ossl_check_SRP_user_pwd_compfunc_type(cmp))) +# define sk_SRP_user_pwd_num(sk) \ + OPENSSL_sk_num(ossl_check_const_SRP_user_pwd_sk_type(sk)) +# define sk_SRP_user_pwd_value(sk, idx) \ + ((SRP_user_pwd *)OPENSSL_sk_value( \ + ossl_check_const_SRP_user_pwd_sk_type(sk), (idx))) +# define sk_SRP_user_pwd_new(cmp) \ + ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new( \ + ossl_check_SRP_user_pwd_compfunc_type(cmp))) +# define sk_SRP_user_pwd_new_null() \ + ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new_null()) +# define sk_SRP_user_pwd_new_reserve(cmp, n) \ + ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_new_reserve( \ + ossl_check_SRP_user_pwd_compfunc_type(cmp), (n))) +# define sk_SRP_user_pwd_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SRP_user_pwd_sk_type(sk), (n)) +# define sk_SRP_user_pwd_free(sk) \ + OPENSSL_sk_free(ossl_check_SRP_user_pwd_sk_type(sk)) +# define sk_SRP_user_pwd_zero(sk) \ + OPENSSL_sk_zero(ossl_check_SRP_user_pwd_sk_type(sk)) +# define sk_SRP_user_pwd_delete(sk, i) \ + ((SRP_user_pwd *)OPENSSL_sk_delete(ossl_check_SRP_user_pwd_sk_type(sk), \ + (i))) +# define sk_SRP_user_pwd_delete_ptr(sk, ptr) \ + ((SRP_user_pwd *)OPENSSL_sk_delete_ptr( \ + ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr))) +# define sk_SRP_user_pwd_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr)) +# define sk_SRP_user_pwd_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr)) +# define sk_SRP_user_pwd_pop(sk) \ + ((SRP_user_pwd *)OPENSSL_sk_pop(ossl_check_SRP_user_pwd_sk_type(sk))) +# define sk_SRP_user_pwd_shift(sk) \ + ((SRP_user_pwd *)OPENSSL_sk_shift(ossl_check_SRP_user_pwd_sk_type(sk))) +# define sk_SRP_user_pwd_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_freefunc_type(freefunc)) +# define sk_SRP_user_pwd_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr), (idx)) +# define sk_SRP_user_pwd_set(sk, idx, ptr) \ + ((SRP_user_pwd *)OPENSSL_sk_set(ossl_check_SRP_user_pwd_sk_type(sk), \ + (idx), \ + ossl_check_SRP_user_pwd_type(ptr))) +# define sk_SRP_user_pwd_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr)) +# define sk_SRP_user_pwd_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr)) +# define sk_SRP_user_pwd_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_type(ptr), pnum) +# define sk_SRP_user_pwd_sort(sk) \ + OPENSSL_sk_sort(ossl_check_SRP_user_pwd_sk_type(sk)) +# define sk_SRP_user_pwd_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SRP_user_pwd_sk_type(sk)) +# define sk_SRP_user_pwd_dup(sk) \ + ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_dup( \ + ossl_check_const_SRP_user_pwd_sk_type(sk))) +# define sk_SRP_user_pwd_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SRP_user_pwd) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_copyfunc_type(copyfunc), \ + ossl_check_SRP_user_pwd_freefunc_type(freefunc))) +# define sk_SRP_user_pwd_set_cmp_func(sk, cmp) \ + ((sk_SRP_user_pwd_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SRP_user_pwd_sk_type(sk), \ + ossl_check_SRP_user_pwd_compfunc_type(cmp))) OSSL_DEPRECATEDIN_3_0 SRP_user_pwd *SRP_user_pwd_new(void); @@ -179,20 +207,22 @@ OSSL_DEPRECATEDIN_3_0 void SRP_user_pwd_free(SRP_user_pwd *user_pwd); OSSL_DEPRECATEDIN_3_0 -void SRP_user_pwd_set_gN(SRP_user_pwd *user_pwd, const BIGNUM *g, const BIGNUM *N); +void SRP_user_pwd_set_gN(SRP_user_pwd *user_pwd, const BIGNUM *g, + const BIGNUM *N); OSSL_DEPRECATEDIN_3_0 -int SRP_user_pwd_set1_ids(SRP_user_pwd *user_pwd, const char *id, const char *info); +int SRP_user_pwd_set1_ids(SRP_user_pwd *user_pwd, const char *id, + const char *info); OSSL_DEPRECATEDIN_3_0 int SRP_user_pwd_set0_sv(SRP_user_pwd *user_pwd, BIGNUM *s, BIGNUM *v); typedef struct SRP_VBASE_st { - STACK_OF(SRP_user_pwd) * users_pwd; - STACK_OF(SRP_gN_cache) * gN_cache; - /* to simulate a user */ - char *seed_key; - const BIGNUM *default_g; - const BIGNUM *default_N; + STACK_OF(SRP_user_pwd) * users_pwd; + STACK_OF(SRP_gN_cache) * gN_cache; + /* to simulate a user */ + char *seed_key; + const BIGNUM *default_g; + const BIGNUM *default_N; } SRP_VBASE; /* @@ -200,58 +230,72 @@ typedef struct SRP_VBASE_st */ typedef struct SRP_gN_st { - char *id; - const BIGNUM *g; - const BIGNUM *N; + char *id; + const BIGNUM *g; + const BIGNUM *N; } SRP_gN; SKM_DEFINE_STACK_OF_INTERNAL(SRP_gN, SRP_gN, SRP_gN) -# define sk_SRP_gN_num(sk) OPENSSL_sk_num(ossl_check_const_SRP_gN_sk_type(sk)) -# define sk_SRP_gN_value(sk, idx) \ - ((SRP_gN *)OPENSSL_sk_value(ossl_check_const_SRP_gN_sk_type(sk), (idx))) -# define sk_SRP_gN_new(cmp) \ - ((STACK_OF(SRP_gN) *)OPENSSL_sk_new(ossl_check_SRP_gN_compfunc_type(cmp))) -# define sk_SRP_gN_new_null() ((STACK_OF(SRP_gN) *)OPENSSL_sk_new_null()) -# define sk_SRP_gN_new_reserve(cmp, n) \ - ((STACK_OF(SRP_gN) *)OPENSSL_sk_new_reserve(ossl_check_SRP_gN_compfunc_type(cmp), (n))) -# define sk_SRP_gN_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SRP_gN_sk_type(sk), (n)) -# define sk_SRP_gN_free(sk) OPENSSL_sk_free(ossl_check_SRP_gN_sk_type(sk)) -# define sk_SRP_gN_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_gN_sk_type(sk)) -# define sk_SRP_gN_delete(sk, i) \ - ((SRP_gN *)OPENSSL_sk_delete(ossl_check_SRP_gN_sk_type(sk), (i))) -# define sk_SRP_gN_delete_ptr(sk, ptr) \ - ((SRP_gN *)OPENSSL_sk_delete_ptr(ossl_check_SRP_gN_sk_type(sk), \ - ossl_check_SRP_gN_type(ptr))) -# define sk_SRP_gN_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) -# define sk_SRP_gN_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) -# define sk_SRP_gN_pop(sk) ((SRP_gN *)OPENSSL_sk_pop(ossl_check_SRP_gN_sk_type(sk))) -# define sk_SRP_gN_shift(sk) ((SRP_gN *)OPENSSL_sk_shift(ossl_check_SRP_gN_sk_type(sk))) -# define sk_SRP_gN_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SRP_gN_sk_type(sk), \ - ossl_check_SRP_gN_freefunc_type(freefunc)) -# define sk_SRP_gN_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr), (idx)) -# define sk_SRP_gN_set(sk, idx, ptr) \ - ((SRP_gN *)OPENSSL_sk_set(ossl_check_SRP_gN_sk_type(sk), (idx), \ - ossl_check_SRP_gN_type(ptr))) -# define sk_SRP_gN_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) -# define sk_SRP_gN_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr)) -# define sk_SRP_gN_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SRP_gN_sk_type(sk), ossl_check_SRP_gN_type(ptr), pnum) -# define sk_SRP_gN_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_gN_sk_type(sk)) -# define sk_SRP_gN_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SRP_gN_sk_type(sk)) -# define sk_SRP_gN_dup(sk) \ - ((STACK_OF(SRP_gN) *)OPENSSL_sk_dup(ossl_check_const_SRP_gN_sk_type(sk))) -# define sk_SRP_gN_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SRP_gN) *)OPENSSL_sk_deep_copy(ossl_check_const_SRP_gN_sk_type(sk), \ - ossl_check_SRP_gN_copyfunc_type(copyfunc), \ - ossl_check_SRP_gN_freefunc_type(freefunc))) -# define sk_SRP_gN_set_cmp_func(sk, cmp) \ - ((sk_SRP_gN_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SRP_gN_sk_type(sk), \ - ossl_check_SRP_gN_compfunc_type(cmp))) +# define sk_SRP_gN_num(sk) \ + OPENSSL_sk_num(ossl_check_const_SRP_gN_sk_type(sk)) +# define sk_SRP_gN_value(sk, idx) \ + ((SRP_gN *)OPENSSL_sk_value(ossl_check_const_SRP_gN_sk_type(sk), (idx))) +# define sk_SRP_gN_new(cmp) \ + ((STACK_OF(SRP_gN) *)OPENSSL_sk_new(ossl_check_SRP_gN_compfunc_type(cmp))) +# define sk_SRP_gN_new_null() ((STACK_OF(SRP_gN) *)OPENSSL_sk_new_null()) +# define sk_SRP_gN_new_reserve(cmp, n) \ + ((STACK_OF(SRP_gN) *)OPENSSL_sk_new_reserve( \ + ossl_check_SRP_gN_compfunc_type(cmp), (n))) +# define sk_SRP_gN_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SRP_gN_sk_type(sk), (n)) +# define sk_SRP_gN_free(sk) OPENSSL_sk_free(ossl_check_SRP_gN_sk_type(sk)) +# define sk_SRP_gN_zero(sk) OPENSSL_sk_zero(ossl_check_SRP_gN_sk_type(sk)) +# define sk_SRP_gN_delete(sk, i) \ + ((SRP_gN *)OPENSSL_sk_delete(ossl_check_SRP_gN_sk_type(sk), (i))) +# define sk_SRP_gN_delete_ptr(sk, ptr) \ + ((SRP_gN *)OPENSSL_sk_delete_ptr(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr))) +# define sk_SRP_gN_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr)) +# define sk_SRP_gN_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr)) +# define sk_SRP_gN_pop(sk) \ + ((SRP_gN *)OPENSSL_sk_pop(ossl_check_SRP_gN_sk_type(sk))) +# define sk_SRP_gN_shift(sk) \ + ((SRP_gN *)OPENSSL_sk_shift(ossl_check_SRP_gN_sk_type(sk))) +# define sk_SRP_gN_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_freefunc_type(freefunc)) +# define sk_SRP_gN_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr), (idx)) +# define sk_SRP_gN_set(sk, idx, ptr) \ + ((SRP_gN *)OPENSSL_sk_set(ossl_check_SRP_gN_sk_type(sk), (idx), \ + ossl_check_SRP_gN_type(ptr))) +# define sk_SRP_gN_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr)) +# define sk_SRP_gN_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr)) +# define sk_SRP_gN_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_type(ptr), pnum) +# define sk_SRP_gN_sort(sk) OPENSSL_sk_sort(ossl_check_SRP_gN_sk_type(sk)) +# define sk_SRP_gN_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SRP_gN_sk_type(sk)) +# define sk_SRP_gN_dup(sk) \ + ((STACK_OF(SRP_gN) *)OPENSSL_sk_dup(ossl_check_const_SRP_gN_sk_type(sk))) +# define sk_SRP_gN_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SRP_gN) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_copyfunc_type(copyfunc), \ + ossl_check_SRP_gN_freefunc_type(freefunc))) +# define sk_SRP_gN_set_cmp_func(sk, cmp) \ + ((sk_SRP_gN_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SRP_gN_sk_type(sk), \ + ossl_check_SRP_gN_compfunc_type(cmp))) OSSL_DEPRECATEDIN_3_0 SRP_VBASE *SRP_VBASE_new(char *seed_key); @@ -268,38 +312,40 @@ OSSL_DEPRECATEDIN_3_0 SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); OSSL_DEPRECATEDIN_3_0 -char *SRP_create_verifier_ex(const char *user, const char *pass, char **salt, char **verifier, - const char *N, const char *g, OSSL_LIB_CTX *libctx, const char *propq); +char *SRP_create_verifier_ex(const char *user, const char *pass, char **salt, + char **verifier, const char *N, const char *g, + OSSL_LIB_CTX *libctx, const char *propq); OSSL_DEPRECATEDIN_3_0 -char *SRP_create_verifier(const char *user, const char *pass, char **salt, char **verifier, - const char *N, const char *g); +char *SRP_create_verifier(const char *user, const char *pass, char **salt, + char **verifier, const char *N, const char *g); OSSL_DEPRECATEDIN_3_0 -int SRP_create_verifier_BN_ex(const char *user, const char *pass, BIGNUM **salt, BIGNUM **verifier, - const BIGNUM *N, const BIGNUM *g, OSSL_LIB_CTX *libctx, +int SRP_create_verifier_BN_ex(const char *user, const char *pass, BIGNUM **salt, + BIGNUM **verifier, const BIGNUM *N, + const BIGNUM *g, OSSL_LIB_CTX *libctx, const char *propq); OSSL_DEPRECATEDIN_3_0 -int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, BIGNUM **verifier, - const BIGNUM *N, const BIGNUM *g); +int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, + BIGNUM **verifier, const BIGNUM *N, const BIGNUM *g); -# define SRP_NO_ERROR 0 -# define SRP_ERR_VBASE_INCOMPLETE_FILE 1 -# define SRP_ERR_VBASE_BN_LIB 2 -# define SRP_ERR_OPEN_FILE 3 -# define SRP_ERR_MEMORY 4 +# define SRP_NO_ERROR 0 +# define SRP_ERR_VBASE_INCOMPLETE_FILE 1 +# define SRP_ERR_VBASE_BN_LIB 2 +# define SRP_ERR_OPEN_FILE 3 +# define SRP_ERR_MEMORY 4 -# define DB_srptype 0 -# define DB_srpverifier 1 -# define DB_srpsalt 2 -# define DB_srpid 3 -# define DB_srpgN 4 -# define DB_srpinfo 5 -# undef DB_NUMBER -# define DB_NUMBER 6 +# define DB_srptype 0 +# define DB_srpverifier 1 +# define DB_srpsalt 2 +# define DB_srpid 3 +# define DB_srpgN 4 +# define DB_srpinfo 5 +# undef DB_NUMBER +# define DB_NUMBER 6 -# define DB_SRP_INDEX 'I' -# define DB_SRP_VALID 'V' -# define DB_SRP_REVOKED 'R' -# define DB_SRP_MODIF 'v' +# define DB_SRP_INDEX 'I' +# define DB_SRP_VALID 'V' +# define DB_SRP_REVOKED 'R' +# define DB_SRP_MODIF 'v' /* see srp.c */ OSSL_DEPRECATEDIN_3_0 @@ -309,54 +355,56 @@ SRP_gN *SRP_get_default_gN(const char *id); /* server side .... */ OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u, const BIGNUM *b, - const BIGNUM *N); +BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u, + const BIGNUM *b, const BIGNUM *N); OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_B_ex(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, const BIGNUM *v, - OSSL_LIB_CTX *libctx, const char *propq); +BIGNUM *SRP_Calc_B_ex(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, + const BIGNUM *v, OSSL_LIB_CTX *libctx, const char *propq); OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, const BIGNUM *v); +BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, + const BIGNUM *v); OSSL_DEPRECATEDIN_3_0 int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N); OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_u_ex(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N, OSSL_LIB_CTX *libctx, - const char *propq); +BIGNUM *SRP_Calc_u_ex(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N, + OSSL_LIB_CTX *libctx, const char *propq); OSSL_DEPRECATEDIN_3_0 BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N); /* client side .... */ OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_x_ex(const BIGNUM *s, const char *user, const char *pass, OSSL_LIB_CTX *libctx, - const char *propq); +BIGNUM *SRP_Calc_x_ex(const BIGNUM *s, const char *user, const char *pass, + OSSL_LIB_CTX *libctx, const char *propq); OSSL_DEPRECATEDIN_3_0 BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass); OSSL_DEPRECATEDIN_3_0 BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g); OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_client_key_ex(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, const BIGNUM *x, - const BIGNUM *a, const BIGNUM *u, OSSL_LIB_CTX *libctx, - const char *propq); +BIGNUM *SRP_Calc_client_key_ex(const BIGNUM *N, const BIGNUM *B, + const BIGNUM *g, const BIGNUM *x, + const BIGNUM *a, const BIGNUM *u, + OSSL_LIB_CTX *libctx, const char *propq); OSSL_DEPRECATEDIN_3_0 -BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, const BIGNUM *x, - const BIGNUM *a, const BIGNUM *u); +BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, + const BIGNUM *x, const BIGNUM *a, const BIGNUM *u); OSSL_DEPRECATEDIN_3_0 int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N); -# define SRP_MINIMAL_N 1024 +# define SRP_MINIMAL_N 1024 -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ /* This method ignores the configured seed and fails for an unknown user. */ -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username); -# endif +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/srtp.h b/libs/OpenSSL/include/openssl/srtp.h index 0f9631f6..08802986 100644 --- a/libs/OpenSSL/include/openssl/srtp.h +++ b/libs/OpenSSL/include/openssl/srtp.h @@ -19,7 +19,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_D1_SRTP_H +# define HEADER_D1_SRTP_H #endif #include diff --git a/libs/OpenSSL/include/openssl/ssl.h b/libs/OpenSSL/include/openssl/ssl.h index 93547863..d8358225 100644 --- a/libs/OpenSSL/include/openssl/ssl.h +++ b/libs/OpenSSL/include/openssl/ssl.h @@ -18,7 +18,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SSL_H +# define HEADER_SSL_H #endif #include @@ -26,9 +26,9 @@ #include #include #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include -# include -# include +# include +# include +# include #endif #include #include @@ -41,7 +41,7 @@ #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -81,12 +81,12 @@ extern "C" { #define SSL_TXT_kRSA "kRSA" #define SSL_TXT_kDHr "kDHr" /* this cipher class has been removed */ #define SSL_TXT_kDHd "kDHd" /* this cipher class has been removed */ -#define SSL_TXT_kDH "kDH" /* this cipher class has been removed */ +#define SSL_TXT_kDH "kDH" /* this cipher class has been removed */ #define SSL_TXT_kEDH "kEDH" /* alias for kDHE */ #define SSL_TXT_kDHE "kDHE" #define SSL_TXT_kECDHr "kECDHr" /* this cipher class has been removed */ #define SSL_TXT_kECDHe "kECDHe" /* this cipher class has been removed */ -#define SSL_TXT_kECDH "kECDH" /* this cipher class has been removed */ +#define SSL_TXT_kECDH "kECDH" /* this cipher class has been removed */ #define SSL_TXT_kEECDH "kEECDH" /* alias for kECDHE */ #define SSL_TXT_kECDHE "kECDHE" #define SSL_TXT_kPSK "kPSK" @@ -99,7 +99,7 @@ extern "C" { #define SSL_TXT_aRSA "aRSA" #define SSL_TXT_aDSS "aDSS" -#define SSL_TXT_aDH "aDH" /* this cipher class has been removed */ +#define SSL_TXT_aDH "aDH" /* this cipher class has been removed */ #define SSL_TXT_aECDH "aECDH" /* this cipher class has been removed */ #define SSL_TXT_aECDSA "aECDSA" #define SSL_TXT_aPSK "aPSK" @@ -189,16 +189,16 @@ extern "C" { * Update both macro and function simultaneously */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" +# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" /* * This is the default set of TLSv1.3 ciphersuites * DEPRECATED IN 3.0.0, in favor of OSSL_default_ciphersuites() * Update both macro and function simultaneously */ -# define TLS_DEFAULT_CIPHERSUITES \ - "TLS_AES_256_GCM_SHA384:" \ - "TLS_CHACHA20_POLY1305_SHA256:" \ - "TLS_AES_128_GCM_SHA256" +# define TLS_DEFAULT_CIPHERSUITES \ + "TLS_AES_256_GCM_SHA384:" \ + "TLS_CHACHA20_POLY1305_SHA256:" \ + "TLS_AES_128_GCM_SHA256" #endif /* * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always @@ -241,84 +241,88 @@ STACK_OF(SSL_COMP); /* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/ typedef struct srtp_protection_profile_st { - const char *name; - unsigned long id; + const char *name; + unsigned long id; } SRTP_PROTECTION_PROFILE; SKM_DEFINE_STACK_OF_INTERNAL(SRTP_PROTECTION_PROFILE, SRTP_PROTECTION_PROFILE, SRTP_PROTECTION_PROFILE) -#define sk_SRTP_PROTECTION_PROFILE_num(sk) \ - OPENSSL_sk_num(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk)) -#define sk_SRTP_PROTECTION_PROFILE_value(sk, idx) \ - ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_value( \ - ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk), (idx))) -#define sk_SRTP_PROTECTION_PROFILE_new(cmp) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new( \ - ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp))) -#define sk_SRTP_PROTECTION_PROFILE_new_null() \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new_null()) -#define sk_SRTP_PROTECTION_PROFILE_new_reserve(cmp, n) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new_reserve( \ - ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp), (n))) -#define sk_SRTP_PROTECTION_PROFILE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (n)) -#define sk_SRTP_PROTECTION_PROFILE_free(sk) \ - OPENSSL_sk_free(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) -#define sk_SRTP_PROTECTION_PROFILE_zero(sk) \ - OPENSSL_sk_zero(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) -#define sk_SRTP_PROTECTION_PROFILE_delete(sk, i) \ - ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_delete(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - (i))) -#define sk_SRTP_PROTECTION_PROFILE_delete_ptr(sk, ptr) \ - ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_delete_ptr( \ - ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr))) -#define sk_SRTP_PROTECTION_PROFILE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) -#define sk_SRTP_PROTECTION_PROFILE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) -#define sk_SRTP_PROTECTION_PROFILE_pop(sk) \ - ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_pop(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk))) -#define sk_SRTP_PROTECTION_PROFILE_shift(sk) \ - ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_shift(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk))) -#define sk_SRTP_PROTECTION_PROFILE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_freefunc_type(freefunc)) -#define sk_SRTP_PROTECTION_PROFILE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr), (idx)) -#define sk_SRTP_PROTECTION_PROFILE_set(sk, idx, ptr) \ - ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_set(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - (idx), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr))) -#define sk_SRTP_PROTECTION_PROFILE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) -#define sk_SRTP_PROTECTION_PROFILE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) -#define sk_SRTP_PROTECTION_PROFILE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_type(ptr), pnum) -#define sk_SRTP_PROTECTION_PROFILE_sort(sk) \ - OPENSSL_sk_sort(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) -#define sk_SRTP_PROTECTION_PROFILE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk)) -#define sk_SRTP_PROTECTION_PROFILE_dup(sk) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_dup( \ - ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk))) -#define sk_SRTP_PROTECTION_PROFILE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_copyfunc_type(copyfunc), \ - ossl_check_SRTP_PROTECTION_PROFILE_freefunc_type(freefunc))) -#define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(sk, cmp) \ - ((sk_SRTP_PROTECTION_PROFILE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ - ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp))) +#define sk_SRTP_PROTECTION_PROFILE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_value(sk, idx) \ + ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_value( \ + ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk), (idx))) +#define sk_SRTP_PROTECTION_PROFILE_new(cmp) \ + ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new( \ + ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp))) +#define sk_SRTP_PROTECTION_PROFILE_new_null() \ + ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new_null()) +#define sk_SRTP_PROTECTION_PROFILE_new_reserve(cmp, n) \ + ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_new_reserve( \ + ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp), (n))) +#define sk_SRTP_PROTECTION_PROFILE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (n)) +#define sk_SRTP_PROTECTION_PROFILE_free(sk) \ + OPENSSL_sk_free(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_delete(sk, i) \ + ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_delete( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (i))) +#define sk_SRTP_PROTECTION_PROFILE_delete_ptr(sk, ptr) \ + ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_delete_ptr( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr))) +#define sk_SRTP_PROTECTION_PROFILE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_pop(sk) \ + ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_pop( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk))) +#define sk_SRTP_PROTECTION_PROFILE_shift(sk) \ + ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_shift( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk))) +#define sk_SRTP_PROTECTION_PROFILE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_freefunc_type(freefunc)) +#define sk_SRTP_PROTECTION_PROFILE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr), (idx)) +#define sk_SRTP_PROTECTION_PROFILE_set(sk, idx, ptr) \ + ((SRTP_PROTECTION_PROFILE *)OPENSSL_sk_set( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), (idx), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr))) +#define sk_SRTP_PROTECTION_PROFILE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr)) +#define sk_SRTP_PROTECTION_PROFILE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_type(ptr), pnum) +#define sk_SRTP_PROTECTION_PROFILE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk)) +#define sk_SRTP_PROTECTION_PROFILE_dup(sk) \ + ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_dup( \ + ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk))) +#define sk_SRTP_PROTECTION_PROFILE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SRTP_PROTECTION_PROFILE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_copyfunc_type(copyfunc), \ + ossl_check_SRTP_PROTECTION_PROFILE_freefunc_type(freefunc))) +#define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(sk, cmp) \ + ((sk_SRTP_PROTECTION_PROFILE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SRTP_PROTECTION_PROFILE_sk_type(sk), \ + ossl_check_SRTP_PROTECTION_PROFILE_compfunc_type(cmp))) -typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, int len, void *arg); +typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, + int len, void *arg); typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, STACK_OF(SSL_CIPHER) * peer_ciphers, const SSL_CIPHER **cipher, void *arg); @@ -351,25 +355,34 @@ typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, /* Typedefs for handling custom extensions */ -typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type, const unsigned char **out, - size_t *outlen, int *al, void *add_arg); +typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type, + const unsigned char **out, size_t *outlen, + int *al, void *add_arg); -typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type, const unsigned char *out, - void *add_arg); +typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type, + const unsigned char *out, void *add_arg); -typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type, const unsigned char *in, - size_t inlen, int *al, void *parse_arg); +typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type, + const unsigned char *in, size_t inlen, + int *al, void *parse_arg); -typedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type, unsigned int context, - const unsigned char **out, size_t *outlen, X509 *x, - size_t chainidx, int *al, void *add_arg); +typedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type, + unsigned int context, + const unsigned char **out, + size_t *outlen, X509 *x, + size_t chainidx, int *al, + void *add_arg); -typedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type, unsigned int context, - const unsigned char *out, void *add_arg); +typedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type, + unsigned int context, + const unsigned char *out, + void *add_arg); -typedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type, unsigned int context, - const unsigned char *in, size_t inlen, X509 *x, - size_t chainidx, int *al, void *parse_arg); +typedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type, + unsigned int context, + const unsigned char *in, size_t inlen, + X509 *x, size_t chainidx, int *al, + void *parse_arg); /* Typedef for verification callback */ typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); @@ -416,7 +429,7 @@ typedef int (*SSL_async_callback_fn)(SSL *s, void *arg); * Use Cisco's version identifier of DTLS_BAD_VER * (only with deprecated DTLSv1_client_method()) */ -# define SSL_OP_CISCO_ANYCONNECT SSL_OP_BIT(15) +# define SSL_OP_CISCO_ANYCONNECT SSL_OP_BIT(15) #endif /* As server, disallow session resumption on renegotiation */ #define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION SSL_OP_BIT(16) @@ -482,14 +495,15 @@ typedef int (*SSL_async_callback_fn)(SSL *s, void *arg); /* * Option "collections." */ -#define SSL_OP_NO_SSL_MASK \ - (SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3) +#define SSL_OP_NO_SSL_MASK \ + (SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 \ + | SSL_OP_NO_TLSv1_3) #define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1 | SSL_OP_NO_DTLSv1_2) /* Various bug workarounds that should be rather harmless. */ -#define SSL_OP_ALL \ - (SSL_OP_CRYPTOPRO_TLSEXT_BUG | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS | SSL_OP_TLSEXT_PADDING \ - | SSL_OP_SAFARI_ECDHE_ECDSA_BUG) +#define SSL_OP_ALL \ + (SSL_OP_CRYPTOPRO_TLSEXT_BUG | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS \ + | SSL_OP_TLSEXT_PADDING | SSL_OP_SAFARI_ECDHE_ECDSA_BUG) /* * OBSOLETE OPTIONS retained for compatibility @@ -652,44 +666,56 @@ uint64_t SSL_CTX_set_options(SSL_CTX *ctx, uint64_t op); uint64_t SSL_set_options(SSL *s, uint64_t op); #define SSL_CTX_set_mode(ctx, op) SSL_CTX_ctrl((ctx), SSL_CTRL_MODE, (op), NULL) -#define SSL_CTX_clear_mode(ctx, op) SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_MODE, (op), NULL) +#define SSL_CTX_clear_mode(ctx, op) \ + SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_MODE, (op), NULL) #define SSL_CTX_get_mode(ctx) SSL_CTX_ctrl((ctx), SSL_CTRL_MODE, 0, NULL) #define SSL_clear_mode(ssl, op) SSL_ctrl((ssl), SSL_CTRL_CLEAR_MODE, (op), NULL) #define SSL_set_mode(ssl, op) SSL_ctrl((ssl), SSL_CTRL_MODE, (op), NULL) #define SSL_get_mode(ssl) SSL_ctrl((ssl), SSL_CTRL_MODE, 0, NULL) #define SSL_set_mtu(ssl, mtu) SSL_ctrl((ssl), SSL_CTRL_SET_MTU, (mtu), NULL) -#define DTLS_set_link_mtu(ssl, mtu) SSL_ctrl((ssl), DTLS_CTRL_SET_LINK_MTU, (mtu), NULL) -#define DTLS_get_link_min_mtu(ssl) SSL_ctrl((ssl), DTLS_CTRL_GET_LINK_MIN_MTU, 0, NULL) +#define DTLS_set_link_mtu(ssl, mtu) \ + SSL_ctrl((ssl), DTLS_CTRL_SET_LINK_MTU, (mtu), NULL) +#define DTLS_get_link_min_mtu(ssl) \ + SSL_ctrl((ssl), DTLS_CTRL_GET_LINK_MIN_MTU, 0, NULL) -#define SSL_get_secure_renegotiation_support(ssl) SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL) +#define SSL_get_secure_renegotiation_support(ssl) \ + SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL) -#define SSL_CTX_set_cert_flags(ctx, op) SSL_CTX_ctrl((ctx), SSL_CTRL_CERT_FLAGS, (op), NULL) +#define SSL_CTX_set_cert_flags(ctx, op) \ + SSL_CTX_ctrl((ctx), SSL_CTRL_CERT_FLAGS, (op), NULL) #define SSL_set_cert_flags(s, op) SSL_ctrl((s), SSL_CTRL_CERT_FLAGS, (op), NULL) -#define SSL_CTX_clear_cert_flags(ctx, op) SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_CERT_FLAGS, (op), NULL) -#define SSL_clear_cert_flags(s, op) SSL_ctrl((s), SSL_CTRL_CLEAR_CERT_FLAGS, (op), NULL) +#define SSL_CTX_clear_cert_flags(ctx, op) \ + SSL_CTX_ctrl((ctx), SSL_CTRL_CLEAR_CERT_FLAGS, (op), NULL) +#define SSL_clear_cert_flags(s, op) \ + SSL_ctrl((s), SSL_CTRL_CLEAR_CERT_FLAGS, (op), NULL) void SSL_CTX_set_msg_callback(SSL_CTX *ctx, - void (*cb)(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg)); + void (*cb)(int write_p, int version, + int content_type, const void *buf, + size_t len, SSL *ssl, void *arg)); void SSL_set_msg_callback(SSL *ssl, - void (*cb)(int write_p, int version, int content_type, const void *buf, - size_t len, SSL *ssl, void *arg)); -#define SSL_CTX_set_msg_callback_arg(ctx, arg) \ - SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) -#define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) + void (*cb)(int write_p, int version, int content_type, + const void *buf, size_t len, SSL *ssl, + void *arg)); +#define SSL_CTX_set_msg_callback_arg(ctx, arg) \ + SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) +#define SSL_set_msg_callback_arg(ssl, arg) \ + SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) -#define SSL_get_extms_support(s) SSL_ctrl((s), SSL_CTRL_GET_EXTMS_SUPPORT, 0, NULL) +#define SSL_get_extms_support(s) \ + SSL_ctrl((s), SSL_CTRL_GET_EXTMS_SUPPORT, 0, NULL) #ifndef OPENSSL_NO_SRP /* see tls_srp.c */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 __owur int SSL_SRP_CTX_init(SSL *s); OSSL_DEPRECATEDIN_3_0 __owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx); OSSL_DEPRECATEDIN_3_0 int SSL_SRP_CTX_free(SSL *ctx); OSSL_DEPRECATEDIN_3_0 int SSL_CTX_SRP_CTX_free(SSL_CTX *ctx); -OSSL_DEPRECATEDIN_3_0 __owur int SSL_srp_server_param_with_username(SSL *s, int *ad); +OSSL_DEPRECATEDIN_3_0 __owur int SSL_srp_server_param_with_username(SSL *s, + int *ad); OSSL_DEPRECATEDIN_3_0 __owur int SRP_Calc_A_param(SSL *s); -# endif +# endif #endif /* 100k max cert list */ @@ -709,7 +735,8 @@ OSSL_DEPRECATEDIN_3_0 __owur int SRP_Calc_A_param(SSL *s); * bytes. The callback can alter this length to be less if desired. It is * also an error for the callback to set the size to zero. */ -typedef int (*GEN_SESSION_CB)(SSL *ssl, unsigned char *id, unsigned int *id_len); +typedef int (*GEN_SESSION_CB)(SSL *ssl, unsigned char *id, + unsigned int *id_len); #define SSL_SESS_CACHE_OFF 0x0000 #define SSL_SESS_CACHE_CLIENT 0x0001 @@ -719,81 +746,107 @@ typedef int (*GEN_SESSION_CB)(SSL *ssl, unsigned char *id, unsigned int *id_len) /* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ #define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 #define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 -#define SSL_SESS_CACHE_NO_INTERNAL \ - (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE) +#define SSL_SESS_CACHE_NO_INTERNAL \ + (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE) #define SSL_SESS_CACHE_UPDATE_TIME 0x0400 LHASH_OF(SSL_SESSION) * SSL_CTX_sessions(SSL_CTX *ctx); -#define SSL_CTX_sess_number(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_NUMBER, 0, NULL) -#define SSL_CTX_sess_connect(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT, 0, NULL) -#define SSL_CTX_sess_connect_good(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT_GOOD, 0, NULL) -#define SSL_CTX_sess_connect_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT_RENEGOTIATE, 0, NULL) -#define SSL_CTX_sess_accept(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT, 0, NULL) -#define SSL_CTX_sess_accept_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT_RENEGOTIATE, 0, NULL) -#define SSL_CTX_sess_accept_good(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT_GOOD, 0, NULL) +#define SSL_CTX_sess_number(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_NUMBER, 0, NULL) +#define SSL_CTX_sess_connect(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT, 0, NULL) +#define SSL_CTX_sess_connect_good(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT_GOOD, 0, NULL) +#define SSL_CTX_sess_connect_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CONNECT_RENEGOTIATE, 0, NULL) +#define SSL_CTX_sess_accept(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT, 0, NULL) +#define SSL_CTX_sess_accept_renegotiate(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT_RENEGOTIATE, 0, NULL) +#define SSL_CTX_sess_accept_good(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_ACCEPT_GOOD, 0, NULL) #define SSL_CTX_sess_hits(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_HIT, 0, NULL) -#define SSL_CTX_sess_cb_hits(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CB_HIT, 0, NULL) -#define SSL_CTX_sess_misses(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_MISSES, 0, NULL) -#define SSL_CTX_sess_timeouts(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_TIMEOUTS, 0, NULL) -#define SSL_CTX_sess_cache_full(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CACHE_FULL, 0, NULL) +#define SSL_CTX_sess_cb_hits(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CB_HIT, 0, NULL) +#define SSL_CTX_sess_misses(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_MISSES, 0, NULL) +#define SSL_CTX_sess_timeouts(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_TIMEOUTS, 0, NULL) +#define SSL_CTX_sess_cache_full(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SESS_CACHE_FULL, 0, NULL) void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, - int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess)); -int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess); -void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, - void (*remove_session_cb)(struct ssl_ctx_st *ctx, - SSL_SESSION *sess)); -void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess); -void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, - SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, - const unsigned char *data, int len, - int *copy)); -SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, const unsigned char *data, + int (*new_session_cb)(struct ssl_st *ssl, + SSL_SESSION *sess)); +int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, + SSL_SESSION *sess); +void SSL_CTX_sess_set_remove_cb( + SSL_CTX *ctx, + void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess)); +void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, + SSL_SESSION *sess); +void SSL_CTX_sess_set_get_cb( + SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, + const unsigned char *data, + int len, int *copy)); +SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, + const unsigned char *data, int len, int *copy); -void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl, int type, int val)); -void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type, int val); +void SSL_CTX_set_info_callback(SSL_CTX *ctx, + void (*cb)(const SSL *ssl, int type, int val)); +void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type, + int val); void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, - int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)); -int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey); + int (*client_cert_cb)(SSL *ssl, X509 **x509, + EVP_PKEY **pkey)); +int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509, + EVP_PKEY **pkey); #ifndef OPENSSL_NO_ENGINE __owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e); #endif -void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, - int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, - unsigned int *cookie_len)); -void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, - int (*app_verify_cookie_cb)(SSL *ssl, const unsigned char *cookie, - unsigned int cookie_len)); +void SSL_CTX_set_cookie_generate_cb( + SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len)); +void SSL_CTX_set_cookie_verify_cb( + SSL_CTX *ctx, + int (*app_verify_cookie_cb)(SSL *ssl, const unsigned char *cookie, + unsigned int cookie_len)); -void SSL_CTX_set_stateless_cookie_generate_cb(SSL_CTX *ctx, - int (*gen_stateless_cookie_cb)(SSL *ssl, - unsigned char *cookie, - size_t *cookie_len)); +void SSL_CTX_set_stateless_cookie_generate_cb( + SSL_CTX *ctx, + int (*gen_stateless_cookie_cb)(SSL *ssl, unsigned char *cookie, + size_t *cookie_len)); void SSL_CTX_set_stateless_cookie_verify_cb( SSL_CTX *ctx, - int (*verify_stateless_cookie_cb)(SSL *ssl, const unsigned char *cookie, size_t cookie_len)); + int (*verify_stateless_cookie_cb)(SSL *ssl, const unsigned char *cookie, + size_t cookie_len)); #ifndef OPENSSL_NO_NEXTPROTONEG -typedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl, const unsigned char **out, +typedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl, + const unsigned char **out, unsigned int *outlen, void *arg); -void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, SSL_CTX_npn_advertised_cb_func cb, +void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, + SSL_CTX_npn_advertised_cb_func cb, void *arg); -# define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb +# define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb -typedef int (*SSL_CTX_npn_select_cb_func)(SSL *s, unsigned char **out, unsigned char *outlen, - const unsigned char *in, unsigned int inlen, void *arg); -void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s, SSL_CTX_npn_select_cb_func cb, void *arg); -# define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb +typedef int (*SSL_CTX_npn_select_cb_func)(SSL *s, unsigned char **out, + unsigned char *outlen, + const unsigned char *in, + unsigned int inlen, void *arg); +void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s, SSL_CTX_npn_select_cb_func cb, + void *arg); +# define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb -void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, unsigned *len); -# define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated +void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, + unsigned *len); +# define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated #endif __owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, - const unsigned char *client, unsigned int client_len); + const unsigned char *client, + unsigned int client_len); #define OPENSSL_NPN_UNSUPPORTED 0 #define OPENSSL_NPN_NEGOTIATED 1 @@ -801,65 +854,84 @@ __owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen, __owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, unsigned int protos_len); -__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, unsigned int protos_len); +__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, + unsigned int protos_len); typedef int (*SSL_CTX_alpn_select_cb_func)(SSL *ssl, const unsigned char **out, - unsigned char *outlen, const unsigned char *in, + unsigned char *outlen, + const unsigned char *in, unsigned int inlen, void *arg); -void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, SSL_CTX_alpn_select_cb_func cb, void *arg); -void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, unsigned int *len); +void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, SSL_CTX_alpn_select_cb_func cb, + void *arg); +void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, + unsigned int *len); #ifndef OPENSSL_NO_PSK /* * the maximum length of the buffer given to callbacks containing the * resulting identity/psk */ -# define PSK_MAX_IDENTITY_LEN 256 -# define PSK_MAX_PSK_LEN 512 -typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl, const char *hint, char *identity, - unsigned int max_identity_len, unsigned char *psk, +# define PSK_MAX_IDENTITY_LEN 256 +# define PSK_MAX_PSK_LEN 512 +typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl, const char *hint, + char *identity, + unsigned int max_identity_len, + unsigned char *psk, unsigned int max_psk_len); void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb); void SSL_set_psk_client_callback(SSL *ssl, SSL_psk_client_cb_func cb); -typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl, const char *identity, unsigned char *psk, +typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl, const char *identity, + unsigned char *psk, unsigned int max_psk_len); void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb); void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb); -__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint); +__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, + const char *identity_hint); __owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); const char *SSL_get_psk_identity_hint(const SSL *s); const char *SSL_get_psk_identity(const SSL *s); #endif -typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl, const unsigned char *identity, - size_t identity_len, SSL_SESSION **sess); -typedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md, const unsigned char **id, +typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl, + const unsigned char *identity, + size_t identity_len, + SSL_SESSION **sess); +typedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md, + const unsigned char **id, size_t *idlen, SSL_SESSION **sess); void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb); -void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx, SSL_psk_find_session_cb_func cb); +void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx, + SSL_psk_find_session_cb_func cb); void SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb); -void SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx, SSL_psk_use_session_cb_func cb); +void SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx, + SSL_psk_use_session_cb_func cb); /* Register callbacks to handle custom TLS Extensions for client or server. */ -__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx, unsigned int ext_type); +__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx, + unsigned int ext_type); __owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type, - custom_ext_add_cb add_cb, custom_ext_free_cb free_cb, - void *add_arg, custom_ext_parse_cb parse_cb, + custom_ext_add_cb add_cb, + custom_ext_free_cb free_cb, + void *add_arg, + custom_ext_parse_cb parse_cb, void *parse_arg); __owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type, - custom_ext_add_cb add_cb, custom_ext_free_cb free_cb, - void *add_arg, custom_ext_parse_cb parse_cb, + custom_ext_add_cb add_cb, + custom_ext_free_cb free_cb, + void *add_arg, + custom_ext_parse_cb parse_cb, void *parse_arg); -__owur int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type, unsigned int context, - SSL_custom_ext_add_cb_ex add_cb, - SSL_custom_ext_free_cb_ex free_cb, void *add_arg, - SSL_custom_ext_parse_cb_ex parse_cb, void *parse_arg); +__owur int +SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type, + unsigned int context, SSL_custom_ext_add_cb_ex add_cb, + SSL_custom_ext_free_cb_ex free_cb, void *add_arg, + SSL_custom_ext_parse_cb_ex parse_cb, void *parse_arg); __owur int SSL_extension_supported(unsigned int ext_type); @@ -921,9 +993,9 @@ uint32_t SSL_get_recv_max_early_data(const SSL *s); #include #include -#include /* This is mostly sslv3 with a few tweaks */ +#include /* This is mostly sslv3 with a few tweaks */ #include /* Datagram TLS */ -#include /* Support for the use_srtp extension */ +#include /* Support for the use_srtp extension */ #include #ifdef __cplusplus @@ -935,111 +1007,146 @@ extern "C" { * in VisualStudio 2015 */ SKM_DEFINE_STACK_OF_INTERNAL(SSL_CIPHER, const SSL_CIPHER, SSL_CIPHER) -#define sk_SSL_CIPHER_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_CIPHER_sk_type(sk)) -#define sk_SSL_CIPHER_value(sk, idx) \ - ((const SSL_CIPHER *)OPENSSL_sk_value(ossl_check_const_SSL_CIPHER_sk_type(sk), (idx))) -#define sk_SSL_CIPHER_new(cmp) \ - ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new(ossl_check_SSL_CIPHER_compfunc_type(cmp))) +#define sk_SSL_CIPHER_num(sk) \ + OPENSSL_sk_num(ossl_check_const_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_value(sk, idx) \ + ((const SSL_CIPHER *)OPENSSL_sk_value( \ + ossl_check_const_SSL_CIPHER_sk_type(sk), (idx))) +#define sk_SSL_CIPHER_new(cmp) \ + ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new( \ + ossl_check_SSL_CIPHER_compfunc_type(cmp))) #define sk_SSL_CIPHER_new_null() ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new_null()) -#define sk_SSL_CIPHER_new_reserve(cmp, n) \ - ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new_reserve(ossl_check_SSL_CIPHER_compfunc_type(cmp), (n))) -#define sk_SSL_CIPHER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_CIPHER_sk_type(sk), (n)) -#define sk_SSL_CIPHER_free(sk) OPENSSL_sk_free(ossl_check_SSL_CIPHER_sk_type(sk)) -#define sk_SSL_CIPHER_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_CIPHER_sk_type(sk)) -#define sk_SSL_CIPHER_delete(sk, i) \ - ((const SSL_CIPHER *)OPENSSL_sk_delete(ossl_check_SSL_CIPHER_sk_type(sk), (i))) -#define sk_SSL_CIPHER_delete_ptr(sk, ptr) \ - ((const SSL_CIPHER *)OPENSSL_sk_delete_ptr(ossl_check_SSL_CIPHER_sk_type(sk), \ - ossl_check_SSL_CIPHER_type(ptr))) -#define sk_SSL_CIPHER_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) -#define sk_SSL_CIPHER_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) -#define sk_SSL_CIPHER_pop(sk) \ - ((const SSL_CIPHER *)OPENSSL_sk_pop(ossl_check_SSL_CIPHER_sk_type(sk))) -#define sk_SSL_CIPHER_shift(sk) \ - ((const SSL_CIPHER *)OPENSSL_sk_shift(ossl_check_SSL_CIPHER_sk_type(sk))) -#define sk_SSL_CIPHER_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SSL_CIPHER_sk_type(sk), \ - ossl_check_SSL_CIPHER_freefunc_type(freefunc)) -#define sk_SSL_CIPHER_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr), (idx)) -#define sk_SSL_CIPHER_set(sk, idx, ptr) \ - ((const SSL_CIPHER *)OPENSSL_sk_set(ossl_check_SSL_CIPHER_sk_type(sk), (idx), \ - ossl_check_SSL_CIPHER_type(ptr))) -#define sk_SSL_CIPHER_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) -#define sk_SSL_CIPHER_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr)) -#define sk_SSL_CIPHER_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr), pnum) -#define sk_SSL_CIPHER_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_CIPHER_sk_type(sk)) -#define sk_SSL_CIPHER_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_CIPHER_sk_type(sk)) -#define sk_SSL_CIPHER_dup(sk) \ - ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_dup(ossl_check_const_SSL_CIPHER_sk_type(sk))) -#define sk_SSL_CIPHER_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_deep_copy(ossl_check_const_SSL_CIPHER_sk_type(sk), \ - ossl_check_SSL_CIPHER_copyfunc_type(copyfunc), \ - ossl_check_SSL_CIPHER_freefunc_type(freefunc))) -#define sk_SSL_CIPHER_set_cmp_func(sk, cmp) \ - ((sk_SSL_CIPHER_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SSL_CIPHER_sk_type(sk), \ - ossl_check_SSL_CIPHER_compfunc_type(cmp))) +#define sk_SSL_CIPHER_new_reserve(cmp, n) \ + ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_new_reserve( \ + ossl_check_SSL_CIPHER_compfunc_type(cmp), (n))) +#define sk_SSL_CIPHER_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SSL_CIPHER_sk_type(sk), (n)) +#define sk_SSL_CIPHER_free(sk) \ + OPENSSL_sk_free(ossl_check_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_zero(sk) \ + OPENSSL_sk_zero(ossl_check_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_delete(sk, i) \ + ((const SSL_CIPHER *)OPENSSL_sk_delete(ossl_check_SSL_CIPHER_sk_type(sk), \ + (i))) +#define sk_SSL_CIPHER_delete_ptr(sk, ptr) \ + ((const SSL_CIPHER *)OPENSSL_sk_delete_ptr( \ + ossl_check_SSL_CIPHER_sk_type(sk), ossl_check_SSL_CIPHER_type(ptr))) +#define sk_SSL_CIPHER_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_pop(sk) \ + ((const SSL_CIPHER *)OPENSSL_sk_pop(ossl_check_SSL_CIPHER_sk_type(sk))) +#define sk_SSL_CIPHER_shift(sk) \ + ((const SSL_CIPHER *)OPENSSL_sk_shift(ossl_check_SSL_CIPHER_sk_type(sk))) +#define sk_SSL_CIPHER_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_freefunc_type(freefunc)) +#define sk_SSL_CIPHER_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_type(ptr), (idx)) +#define sk_SSL_CIPHER_set(sk, idx, ptr) \ + ((const SSL_CIPHER *)OPENSSL_sk_set(ossl_check_SSL_CIPHER_sk_type(sk), \ + (idx), ossl_check_SSL_CIPHER_type(ptr))) +#define sk_SSL_CIPHER_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_type(ptr)) +#define sk_SSL_CIPHER_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_type(ptr), pnum) +#define sk_SSL_CIPHER_sort(sk) \ + OPENSSL_sk_sort(ossl_check_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SSL_CIPHER_sk_type(sk)) +#define sk_SSL_CIPHER_dup(sk) \ + ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_dup( \ + ossl_check_const_SSL_CIPHER_sk_type(sk))) +#define sk_SSL_CIPHER_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SSL_CIPHER) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_copyfunc_type(copyfunc), \ + ossl_check_SSL_CIPHER_freefunc_type(freefunc))) +#define sk_SSL_CIPHER_set_cmp_func(sk, cmp) \ + ((sk_SSL_CIPHER_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SSL_CIPHER_sk_type(sk), \ + ossl_check_SSL_CIPHER_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(SSL_COMP, SSL_COMP, SSL_COMP) -#define sk_SSL_COMP_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_COMP_sk_type(sk)) -#define sk_SSL_COMP_value(sk, idx) \ - ((SSL_COMP *)OPENSSL_sk_value(ossl_check_const_SSL_COMP_sk_type(sk), (idx))) -#define sk_SSL_COMP_new(cmp) \ - ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new(ossl_check_SSL_COMP_compfunc_type(cmp))) +#define sk_SSL_COMP_num(sk) \ + OPENSSL_sk_num(ossl_check_const_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_value(sk, idx) \ + ((SSL_COMP *)OPENSSL_sk_value(ossl_check_const_SSL_COMP_sk_type(sk), (idx))) +#define sk_SSL_COMP_new(cmp) \ + ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new(ossl_check_SSL_COMP_compfunc_type(cmp))) #define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_null()) -#define sk_SSL_COMP_new_reserve(cmp, n) \ - ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_reserve(ossl_check_SSL_COMP_compfunc_type(cmp), (n))) -#define sk_SSL_COMP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_COMP_sk_type(sk), (n)) +#define sk_SSL_COMP_new_reserve(cmp, n) \ + ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_reserve( \ + ossl_check_SSL_COMP_compfunc_type(cmp), (n))) +#define sk_SSL_COMP_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SSL_COMP_sk_type(sk), (n)) #define sk_SSL_COMP_free(sk) OPENSSL_sk_free(ossl_check_SSL_COMP_sk_type(sk)) #define sk_SSL_COMP_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_COMP_sk_type(sk)) -#define sk_SSL_COMP_delete(sk, i) \ - ((SSL_COMP *)OPENSSL_sk_delete(ossl_check_SSL_COMP_sk_type(sk), (i))) -#define sk_SSL_COMP_delete_ptr(sk, ptr) \ - ((SSL_COMP *)OPENSSL_sk_delete_ptr(ossl_check_SSL_COMP_sk_type(sk), \ - ossl_check_SSL_COMP_type(ptr))) -#define sk_SSL_COMP_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) -#define sk_SSL_COMP_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) -#define sk_SSL_COMP_pop(sk) ((SSL_COMP *)OPENSSL_sk_pop(ossl_check_SSL_COMP_sk_type(sk))) -#define sk_SSL_COMP_shift(sk) ((SSL_COMP *)OPENSSL_sk_shift(ossl_check_SSL_COMP_sk_type(sk))) -#define sk_SSL_COMP_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SSL_COMP_sk_type(sk), \ - ossl_check_SSL_COMP_freefunc_type(freefunc)) -#define sk_SSL_COMP_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), (idx)) -#define sk_SSL_COMP_set(sk, idx, ptr) \ - ((SSL_COMP *)OPENSSL_sk_set(ossl_check_SSL_COMP_sk_type(sk), (idx), \ - ossl_check_SSL_COMP_type(ptr))) -#define sk_SSL_COMP_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) -#define sk_SSL_COMP_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)) -#define sk_SSL_COMP_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), pnum) +#define sk_SSL_COMP_delete(sk, i) \ + ((SSL_COMP *)OPENSSL_sk_delete(ossl_check_SSL_COMP_sk_type(sk), (i))) +#define sk_SSL_COMP_delete_ptr(sk, ptr) \ + ((SSL_COMP *)OPENSSL_sk_delete_ptr(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr))) +#define sk_SSL_COMP_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_pop(sk) \ + ((SSL_COMP *)OPENSSL_sk_pop(ossl_check_SSL_COMP_sk_type(sk))) +#define sk_SSL_COMP_shift(sk) \ + ((SSL_COMP *)OPENSSL_sk_shift(ossl_check_SSL_COMP_sk_type(sk))) +#define sk_SSL_COMP_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_freefunc_type(freefunc)) +#define sk_SSL_COMP_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr), (idx)) +#define sk_SSL_COMP_set(sk, idx, ptr) \ + ((SSL_COMP *)OPENSSL_sk_set(ossl_check_SSL_COMP_sk_type(sk), (idx), \ + ossl_check_SSL_COMP_type(ptr))) +#define sk_SSL_COMP_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr)) +#define sk_SSL_COMP_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_type(ptr), pnum) #define sk_SSL_COMP_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_COMP_sk_type(sk)) -#define sk_SSL_COMP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_COMP_sk_type(sk)) -#define sk_SSL_COMP_dup(sk) \ - ((STACK_OF(SSL_COMP) *)OPENSSL_sk_dup(ossl_check_const_SSL_COMP_sk_type(sk))) -#define sk_SSL_COMP_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SSL_COMP) *)OPENSSL_sk_deep_copy(ossl_check_const_SSL_COMP_sk_type(sk), \ - ossl_check_SSL_COMP_copyfunc_type(copyfunc), \ - ossl_check_SSL_COMP_freefunc_type(freefunc))) -#define sk_SSL_COMP_set_cmp_func(sk, cmp) \ - ((sk_SSL_COMP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SSL_COMP_sk_type(sk), \ - ossl_check_SSL_COMP_compfunc_type(cmp))) +#define sk_SSL_COMP_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SSL_COMP_sk_type(sk)) +#define sk_SSL_COMP_dup(sk) \ + ((STACK_OF(SSL_COMP) *)OPENSSL_sk_dup(ossl_check_const_SSL_COMP_sk_type(sk))) +#define sk_SSL_COMP_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SSL_COMP) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_copyfunc_type(copyfunc), \ + ossl_check_SSL_COMP_freefunc_type(freefunc))) +#define sk_SSL_COMP_set_cmp_func(sk, cmp) \ + ((sk_SSL_COMP_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SSL_COMP_sk_type(sk), \ + ossl_check_SSL_COMP_compfunc_type(cmp))) /* compatibility */ #define SSL_set_app_data(s, arg) (SSL_set_ex_data(s, 0, (char *)(arg))) #define SSL_get_app_data(s) (SSL_get_ex_data(s, 0)) -#define SSL_SESSION_set_app_data(s, a) (SSL_SESSION_set_ex_data(s, 0, (char *)(a))) +#define SSL_SESSION_set_app_data(s, a) \ + (SSL_SESSION_set_ex_data(s, 0, (char *)(a))) #define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s, 0)) #define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx, 0)) -#define SSL_CTX_set_app_data(ctx, arg) (SSL_CTX_set_ex_data(ctx, 0, (char *)(arg))) +#define SSL_CTX_set_app_data(ctx, arg) \ + (SSL_CTX_set_ex_data(ctx, 0, (char *)(arg))) #ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 void SSL_set_debug(SSL *s, int debug); #endif @@ -1065,60 +1172,60 @@ OSSL_DEPRECATEDIN_1_1_0 void SSL_set_debug(SSL *s, int debug); */ typedef enum { - TLS_ST_BEFORE, - TLS_ST_OK, - DTLS_ST_CR_HELLO_VERIFY_REQUEST, - TLS_ST_CR_SRVR_HELLO, - TLS_ST_CR_CERT, - TLS_ST_CR_COMP_CERT, - TLS_ST_CR_CERT_STATUS, - TLS_ST_CR_KEY_EXCH, - TLS_ST_CR_CERT_REQ, - TLS_ST_CR_SRVR_DONE, - TLS_ST_CR_SESSION_TICKET, - TLS_ST_CR_CHANGE, - TLS_ST_CR_FINISHED, - TLS_ST_CW_CLNT_HELLO, - TLS_ST_CW_CERT, - TLS_ST_CW_COMP_CERT, - TLS_ST_CW_KEY_EXCH, - TLS_ST_CW_CERT_VRFY, - TLS_ST_CW_CHANGE, - TLS_ST_CW_NEXT_PROTO, - TLS_ST_CW_FINISHED, - TLS_ST_SW_HELLO_REQ, - TLS_ST_SR_CLNT_HELLO, - DTLS_ST_SW_HELLO_VERIFY_REQUEST, - TLS_ST_SW_SRVR_HELLO, - TLS_ST_SW_CERT, - TLS_ST_SW_COMP_CERT, - TLS_ST_SW_KEY_EXCH, - TLS_ST_SW_CERT_REQ, - TLS_ST_SW_SRVR_DONE, - TLS_ST_SR_CERT, - TLS_ST_SR_COMP_CERT, - TLS_ST_SR_KEY_EXCH, - TLS_ST_SR_CERT_VRFY, - TLS_ST_SR_NEXT_PROTO, - TLS_ST_SR_CHANGE, - TLS_ST_SR_FINISHED, - TLS_ST_SW_SESSION_TICKET, - TLS_ST_SW_CERT_STATUS, - TLS_ST_SW_CHANGE, - TLS_ST_SW_FINISHED, - TLS_ST_SW_ENCRYPTED_EXTENSIONS, - TLS_ST_CR_ENCRYPTED_EXTENSIONS, - TLS_ST_CR_CERT_VRFY, - TLS_ST_SW_CERT_VRFY, - TLS_ST_CR_HELLO_REQ, - TLS_ST_SW_KEY_UPDATE, - TLS_ST_CW_KEY_UPDATE, - TLS_ST_SR_KEY_UPDATE, - TLS_ST_CR_KEY_UPDATE, - TLS_ST_EARLY_DATA, - TLS_ST_PENDING_EARLY_DATA_END, - TLS_ST_CW_END_OF_EARLY_DATA, - TLS_ST_SR_END_OF_EARLY_DATA + TLS_ST_BEFORE, + TLS_ST_OK, + DTLS_ST_CR_HELLO_VERIFY_REQUEST, + TLS_ST_CR_SRVR_HELLO, + TLS_ST_CR_CERT, + TLS_ST_CR_COMP_CERT, + TLS_ST_CR_CERT_STATUS, + TLS_ST_CR_KEY_EXCH, + TLS_ST_CR_CERT_REQ, + TLS_ST_CR_SRVR_DONE, + TLS_ST_CR_SESSION_TICKET, + TLS_ST_CR_CHANGE, + TLS_ST_CR_FINISHED, + TLS_ST_CW_CLNT_HELLO, + TLS_ST_CW_CERT, + TLS_ST_CW_COMP_CERT, + TLS_ST_CW_KEY_EXCH, + TLS_ST_CW_CERT_VRFY, + TLS_ST_CW_CHANGE, + TLS_ST_CW_NEXT_PROTO, + TLS_ST_CW_FINISHED, + TLS_ST_SW_HELLO_REQ, + TLS_ST_SR_CLNT_HELLO, + DTLS_ST_SW_HELLO_VERIFY_REQUEST, + TLS_ST_SW_SRVR_HELLO, + TLS_ST_SW_CERT, + TLS_ST_SW_COMP_CERT, + TLS_ST_SW_KEY_EXCH, + TLS_ST_SW_CERT_REQ, + TLS_ST_SW_SRVR_DONE, + TLS_ST_SR_CERT, + TLS_ST_SR_COMP_CERT, + TLS_ST_SR_KEY_EXCH, + TLS_ST_SR_CERT_VRFY, + TLS_ST_SR_NEXT_PROTO, + TLS_ST_SR_CHANGE, + TLS_ST_SR_FINISHED, + TLS_ST_SW_SESSION_TICKET, + TLS_ST_SW_CERT_STATUS, + TLS_ST_SW_CHANGE, + TLS_ST_SW_FINISHED, + TLS_ST_SW_ENCRYPTED_EXTENSIONS, + TLS_ST_CR_ENCRYPTED_EXTENSIONS, + TLS_ST_CR_CERT_VRFY, + TLS_ST_SW_CERT_VRFY, + TLS_ST_CR_HELLO_REQ, + TLS_ST_SW_KEY_UPDATE, + TLS_ST_CW_KEY_UPDATE, + TLS_ST_SR_KEY_UPDATE, + TLS_ST_CR_KEY_UPDATE, + TLS_ST_EARLY_DATA, + TLS_ST_PENDING_EARLY_DATA_END, + TLS_ST_CW_END_OF_EARLY_DATA, + TLS_ST_SR_END_OF_EARLY_DATA } OSSL_HANDSHAKE_STATE; /* @@ -1183,28 +1290,31 @@ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); #define SSL_VERIFY_POST_HANDSHAKE 0x08 #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define OpenSSL_add_ssl_algorithms() SSL_library_init() -# define SSLeay_add_ssl_algorithms() SSL_library_init() +# define OpenSSL_add_ssl_algorithms() SSL_library_init() +# define SSLeay_add_ssl_algorithms() SSL_library_init() #endif /* More backward compatibility */ #define SSL_get_cipher(s) SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -#define SSL_get_cipher_bits(s, np) SSL_CIPHER_get_bits(SSL_get_current_cipher(s), np) -#define SSL_get_cipher_version(s) SSL_CIPHER_get_version(SSL_get_current_cipher(s)) +#define SSL_get_cipher_bits(s, np) \ + SSL_CIPHER_get_bits(SSL_get_current_cipher(s), np) +#define SSL_get_cipher_version(s) \ + SSL_CIPHER_get_version(SSL_get_current_cipher(s)) #define SSL_get_cipher_name(s) SSL_CIPHER_get_name(SSL_get_current_cipher(s)) #define SSL_get_time(a) SSL_SESSION_get_time(a) #define SSL_set_time(a, b) SSL_SESSION_set_time((a), (b)) #define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) #define SSL_set_timeout(a, b) SSL_SESSION_set_timeout((a), (b)) -#define d2i_SSL_SESSION_bio(bp, s_id) \ - ASN1_d2i_bio_of(SSL_SESSION, SSL_SESSION_new, d2i_SSL_SESSION, bp, s_id) -#define i2d_SSL_SESSION_bio(bp, s_id) ASN1_i2d_bio_of(SSL_SESSION, i2d_SSL_SESSION, bp, s_id) +#define d2i_SSL_SESSION_bio(bp, s_id) \ + ASN1_d2i_bio_of(SSL_SESSION, SSL_SESSION_new, d2i_SSL_SESSION, bp, s_id) +#define i2d_SSL_SESSION_bio(bp, s_id) \ + ASN1_i2d_bio_of(SSL_SESSION, i2d_SSL_SESSION, bp, s_id) DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) -#define SSL_AD_REASON_OFFSET \ - 1000 /* offset to get SSL_R_... value \ - * from SSL_AD_... */ +#define SSL_AD_REASON_OFFSET \ + 1000 /* offset to get SSL_R_... value \ + * from SSL_AD_... */ /* These alert types are for SSLv3 and TLSv1 */ #define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY /* fatal */ @@ -1248,7 +1358,8 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION #define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE #define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME -#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE +#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE \ + TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE #define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE /* fatal */ #define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY @@ -1260,9 +1371,9 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_ERROR_WANT_READ 2 #define SSL_ERROR_WANT_WRITE 3 #define SSL_ERROR_WANT_X509_LOOKUP 4 -#define SSL_ERROR_SYSCALL \ - 5 /* look at error stack/return \ - * value/errno */ +#define SSL_ERROR_SYSCALL \ + 5 /* look at error stack/return \ + * value/errno */ #define SSL_ERROR_ZERO_RETURN 6 #define SSL_ERROR_WANT_CONNECT 7 #define SSL_ERROR_WANT_ACCEPT 8 @@ -1272,9 +1383,9 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_ERROR_WANT_RETRY_VERIFY 12 #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_CTRL_SET_TMP_DH 3 -# define SSL_CTRL_SET_TMP_ECDH 4 -# define SSL_CTRL_SET_TMP_DH_CB 6 +# define SSL_CTRL_SET_TMP_DH 3 +# define SSL_CTRL_SET_TMP_ECDH 4 +# define SSL_CTRL_SET_TMP_DH_CB 6 #endif #define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 @@ -1331,7 +1442,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70 #define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71 #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72 +# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72 #endif #define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB 75 #define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB 76 @@ -1394,127 +1505,163 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) #define SSL_CERT_SET_FIRST 1 #define SSL_CERT_SET_NEXT 2 #define SSL_CERT_SET_SERVER 3 -#define DTLSv1_get_timeout(ssl, arg) SSL_ctrl(ssl, DTLS_CTRL_GET_TIMEOUT, 0, (void *)(arg)) -#define DTLSv1_handle_timeout(ssl) SSL_ctrl(ssl, DTLS_CTRL_HANDLE_TIMEOUT, 0, NULL) -#define SSL_num_renegotiations(ssl) SSL_ctrl((ssl), SSL_CTRL_GET_NUM_RENEGOTIATIONS, 0, NULL) -#define SSL_clear_num_renegotiations(ssl) \ - SSL_ctrl((ssl), SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS, 0, NULL) -#define SSL_total_renegotiations(ssl) SSL_ctrl((ssl), SSL_CTRL_GET_TOTAL_RENEGOTIATIONS, 0, NULL) +#define DTLSv1_get_timeout(ssl, arg) \ + SSL_ctrl(ssl, DTLS_CTRL_GET_TIMEOUT, 0, (void *)(arg)) +#define DTLSv1_handle_timeout(ssl) \ + SSL_ctrl(ssl, DTLS_CTRL_HANDLE_TIMEOUT, 0, NULL) +#define SSL_num_renegotiations(ssl) \ + SSL_ctrl((ssl), SSL_CTRL_GET_NUM_RENEGOTIATIONS, 0, NULL) +#define SSL_clear_num_renegotiations(ssl) \ + SSL_ctrl((ssl), SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS, 0, NULL) +#define SSL_total_renegotiations(ssl) \ + SSL_ctrl((ssl), SSL_CTRL_GET_TOTAL_RENEGOTIATIONS, 0, NULL) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_CTX_set_tmp_dh(ctx, dh) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_DH, 0, (char *)(dh)) +# define SSL_CTX_set_tmp_dh(ctx, dh) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_DH, 0, (char *)(dh)) #endif -#define SSL_CTX_set_dh_auto(ctx, onoff) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_DH_AUTO, onoff, NULL) +#define SSL_CTX_set_dh_auto(ctx, onoff) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_DH_AUTO, onoff, NULL) #define SSL_set_dh_auto(s, onoff) SSL_ctrl(s, SSL_CTRL_SET_DH_AUTO, onoff, NULL) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_set_tmp_dh(ssl, dh) SSL_ctrl(ssl, SSL_CTRL_SET_TMP_DH, 0, (char *)(dh)) +# define SSL_set_tmp_dh(ssl, dh) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TMP_DH, 0, (char *)(dh)) #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_CTX_set_tmp_ecdh(ctx, ecdh) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH, 0, (char *)(ecdh)) -# define SSL_set_tmp_ecdh(ssl, ecdh) SSL_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH, 0, (char *)(ecdh)) +# define SSL_CTX_set_tmp_ecdh(ctx, ecdh) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH, 0, (char *)(ecdh)) +# define SSL_set_tmp_ecdh(ssl, ecdh) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH, 0, (char *)(ecdh)) #endif -#define SSL_CTX_add_extra_chain_cert(ctx, x509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, (char *)(x509)) -#define SSL_CTX_get_extra_chain_certs(ctx, px509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 0, px509) -#define SSL_CTX_get_extra_chain_certs_only(ctx, px509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 1, px509) -#define SSL_CTX_clear_extra_chain_certs(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS, 0, NULL) -#define SSL_CTX_set0_chain(ctx, sk) SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN, 0, (char *)(sk)) -#define SSL_CTX_set1_chain(ctx, sk) SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN, 1, (char *)(sk)) -#define SSL_CTX_add0_chain_cert(ctx, x509) SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 0, (char *)(x509)) -#define SSL_CTX_add1_chain_cert(ctx, x509) SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 1, (char *)(x509)) -#define SSL_CTX_get0_chain_certs(ctx, px509) SSL_CTX_ctrl(ctx, SSL_CTRL_GET_CHAIN_CERTS, 0, px509) +#define SSL_CTX_add_extra_chain_cert(ctx, x509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, (char *)(x509)) +#define SSL_CTX_get_extra_chain_certs(ctx, px509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 0, px509) +#define SSL_CTX_get_extra_chain_certs_only(ctx, px509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 1, px509) +#define SSL_CTX_clear_extra_chain_certs(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS, 0, NULL) +#define SSL_CTX_set0_chain(ctx, sk) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN, 0, (char *)(sk)) +#define SSL_CTX_set1_chain(ctx, sk) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN, 1, (char *)(sk)) +#define SSL_CTX_add0_chain_cert(ctx, x509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 0, (char *)(x509)) +#define SSL_CTX_add1_chain_cert(ctx, x509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_CHAIN_CERT, 1, (char *)(x509)) +#define SSL_CTX_get0_chain_certs(ctx, px509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_CHAIN_CERTS, 0, px509) #define SSL_CTX_clear_chain_certs(ctx) SSL_CTX_set0_chain(ctx, NULL) -#define SSL_CTX_build_cert_chain(ctx, flags) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -#define SSL_CTX_select_current_cert(ctx, x509) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SELECT_CURRENT_CERT, 0, (char *)(x509)) -#define SSL_CTX_set_current_cert(ctx, op) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CURRENT_CERT, op, NULL) -#define SSL_CTX_set0_verify_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, (char *)(st)) -#define SSL_CTX_set1_verify_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 1, (char *)(st)) -#define SSL_CTX_get0_verify_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_VERIFY_CERT_STORE, 0, (char *)(st)) -#define SSL_CTX_set0_chain_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CHAIN_CERT_STORE, 0, (char *)(st)) -#define SSL_CTX_set1_chain_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CHAIN_CERT_STORE, 1, (char *)(st)) -#define SSL_CTX_get0_chain_cert_store(ctx, st) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_CHAIN_CERT_STORE, 0, (char *)(st)) +#define SSL_CTX_build_cert_chain(ctx, flags) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) +#define SSL_CTX_select_current_cert(ctx, x509) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SELECT_CURRENT_CERT, 0, (char *)(x509)) +#define SSL_CTX_set_current_cert(ctx, op) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CURRENT_CERT, op, NULL) +#define SSL_CTX_set0_verify_cert_store(ctx, st) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, (char *)(st)) +#define SSL_CTX_set1_verify_cert_store(ctx, st) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 1, (char *)(st)) +#define SSL_CTX_get0_verify_cert_store(ctx, st) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_VERIFY_CERT_STORE, 0, (char *)(st)) +#define SSL_CTX_set0_chain_cert_store(ctx, st) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CHAIN_CERT_STORE, 0, (char *)(st)) +#define SSL_CTX_set1_chain_cert_store(ctx, st) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CHAIN_CERT_STORE, 1, (char *)(st)) +#define SSL_CTX_get0_chain_cert_store(ctx, st) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_CHAIN_CERT_STORE, 0, (char *)(st)) #define SSL_set0_chain(s, sk) SSL_ctrl(s, SSL_CTRL_CHAIN, 0, (char *)(sk)) #define SSL_set1_chain(s, sk) SSL_ctrl(s, SSL_CTRL_CHAIN, 1, (char *)(sk)) -#define SSL_add0_chain_cert(s, x509) SSL_ctrl(s, SSL_CTRL_CHAIN_CERT, 0, (char *)(x509)) -#define SSL_add1_chain_cert(s, x509) SSL_ctrl(s, SSL_CTRL_CHAIN_CERT, 1, (char *)(x509)) -#define SSL_get0_chain_certs(s, px509) SSL_ctrl(s, SSL_CTRL_GET_CHAIN_CERTS, 0, px509) +#define SSL_add0_chain_cert(s, x509) \ + SSL_ctrl(s, SSL_CTRL_CHAIN_CERT, 0, (char *)(x509)) +#define SSL_add1_chain_cert(s, x509) \ + SSL_ctrl(s, SSL_CTRL_CHAIN_CERT, 1, (char *)(x509)) +#define SSL_get0_chain_certs(s, px509) \ + SSL_ctrl(s, SSL_CTRL_GET_CHAIN_CERTS, 0, px509) #define SSL_clear_chain_certs(s) SSL_set0_chain(s, NULL) -#define SSL_build_cert_chain(s, flags) SSL_ctrl(s, SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -#define SSL_select_current_cert(s, x509) \ - SSL_ctrl(s, SSL_CTRL_SELECT_CURRENT_CERT, 0, (char *)(x509)) -#define SSL_set_current_cert(s, op) SSL_ctrl(s, SSL_CTRL_SET_CURRENT_CERT, op, NULL) -#define SSL_set0_verify_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, (char *)(st)) -#define SSL_set1_verify_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_SET_VERIFY_CERT_STORE, 1, (char *)(st)) -#define SSL_get0_verify_cert_store(s, st) \ - SSL_ctrl(s, SSL_CTRL_GET_VERIFY_CERT_STORE, 0, (char *)(st)) -#define SSL_set0_chain_cert_store(s, st) SSL_ctrl(s, SSL_CTRL_SET_CHAIN_CERT_STORE, 0, (char *)(st)) -#define SSL_set1_chain_cert_store(s, st) SSL_ctrl(s, SSL_CTRL_SET_CHAIN_CERT_STORE, 1, (char *)(st)) -#define SSL_get0_chain_cert_store(s, st) SSL_ctrl(s, SSL_CTRL_GET_CHAIN_CERT_STORE, 0, (char *)(st)) +#define SSL_build_cert_chain(s, flags) \ + SSL_ctrl(s, SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) +#define SSL_select_current_cert(s, x509) \ + SSL_ctrl(s, SSL_CTRL_SELECT_CURRENT_CERT, 0, (char *)(x509)) +#define SSL_set_current_cert(s, op) \ + SSL_ctrl(s, SSL_CTRL_SET_CURRENT_CERT, op, NULL) +#define SSL_set0_verify_cert_store(s, st) \ + SSL_ctrl(s, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, (char *)(st)) +#define SSL_set1_verify_cert_store(s, st) \ + SSL_ctrl(s, SSL_CTRL_SET_VERIFY_CERT_STORE, 1, (char *)(st)) +#define SSL_get0_verify_cert_store(s, st) \ + SSL_ctrl(s, SSL_CTRL_GET_VERIFY_CERT_STORE, 0, (char *)(st)) +#define SSL_set0_chain_cert_store(s, st) \ + SSL_ctrl(s, SSL_CTRL_SET_CHAIN_CERT_STORE, 0, (char *)(st)) +#define SSL_set1_chain_cert_store(s, st) \ + SSL_ctrl(s, SSL_CTRL_SET_CHAIN_CERT_STORE, 1, (char *)(st)) +#define SSL_get0_chain_cert_store(s, st) \ + SSL_ctrl(s, SSL_CTRL_GET_CHAIN_CERT_STORE, 0, (char *)(st)) -#define SSL_get1_groups(s, glist) SSL_ctrl(s, SSL_CTRL_GET_GROUPS, 0, (int *)(glist)) -#define SSL_get0_iana_groups(s, plst) SSL_ctrl(s, SSL_CTRL_GET_IANA_GROUPS, 0, (uint16_t **)(plst)) -#define SSL_CTX_set1_groups(ctx, glist, glistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_GROUPS, glistlen, (int *)(glist)) -#define SSL_CTX_set1_groups_list(ctx, s) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_GROUPS_LIST, 0, (char *)(s)) -#define SSL_set1_groups(s, glist, glistlen) \ - SSL_ctrl(s, SSL_CTRL_SET_GROUPS, glistlen, (char *)(glist)) -#define SSL_set1_groups_list(s, str) SSL_ctrl(s, SSL_CTRL_SET_GROUPS_LIST, 0, (char *)(str)) -#define SSL_get_shared_group(s, n) SSL_ctrl(s, SSL_CTRL_GET_SHARED_GROUP, n, NULL) -#define SSL_get_negotiated_group(s) SSL_ctrl(s, SSL_CTRL_GET_NEGOTIATED_GROUP, 0, NULL) -#define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SIGALGS, slistlen, (int *)(slist)) -#define SSL_CTX_set1_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SIGALGS_LIST, 0, (char *)(s)) -#define SSL_set1_sigalgs(s, slist, slistlen) \ - SSL_ctrl(s, SSL_CTRL_SET_SIGALGS, slistlen, (int *)(slist)) -#define SSL_set1_sigalgs_list(s, str) SSL_ctrl(s, SSL_CTRL_SET_SIGALGS_LIST, 0, (char *)(str)) -#define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS, slistlen, (int *)(slist)) -#define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS_LIST, 0, (char *)(s)) -#define SSL_set1_client_sigalgs(s, slist, slistlen) \ - SSL_ctrl(s, SSL_CTRL_SET_CLIENT_SIGALGS, slistlen, (int *)(slist)) -#define SSL_set1_client_sigalgs_list(s, str) \ - SSL_ctrl(s, SSL_CTRL_SET_CLIENT_SIGALGS_LIST, 0, (char *)(str)) -#define SSL_get0_certificate_types(s, clist) \ - SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist)) -#define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_CERT_TYPES, clistlen, (char *)(clist)) -#define SSL_set1_client_certificate_types(s, clist, clistlen) \ - SSL_ctrl(s, SSL_CTRL_SET_CLIENT_CERT_TYPES, clistlen, (char *)(clist)) -#define SSL_get_signature_nid(s, pn) SSL_ctrl(s, SSL_CTRL_GET_SIGNATURE_NID, 0, pn) -#define SSL_get_peer_signature_nid(s, pn) SSL_ctrl(s, SSL_CTRL_GET_PEER_SIGNATURE_NID, 0, pn) -#define SSL_get_peer_tmp_key(s, pk) SSL_ctrl(s, SSL_CTRL_GET_PEER_TMP_KEY, 0, pk) +#define SSL_get1_groups(s, glist) \ + SSL_ctrl(s, SSL_CTRL_GET_GROUPS, 0, (int *)(glist)) +#define SSL_get0_iana_groups(s, plst) \ + SSL_ctrl(s, SSL_CTRL_GET_IANA_GROUPS, 0, (uint16_t **)(plst)) +#define SSL_CTX_set1_groups(ctx, glist, glistlen) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_GROUPS, glistlen, (int *)(glist)) +#define SSL_CTX_set1_groups_list(ctx, s) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_GROUPS_LIST, 0, (char *)(s)) +#define SSL_set1_groups(s, glist, glistlen) \ + SSL_ctrl(s, SSL_CTRL_SET_GROUPS, glistlen, (char *)(glist)) +#define SSL_set1_groups_list(s, str) \ + SSL_ctrl(s, SSL_CTRL_SET_GROUPS_LIST, 0, (char *)(str)) +#define SSL_get_shared_group(s, n) \ + SSL_ctrl(s, SSL_CTRL_GET_SHARED_GROUP, n, NULL) +#define SSL_get_negotiated_group(s) \ + SSL_ctrl(s, SSL_CTRL_GET_NEGOTIATED_GROUP, 0, NULL) +#define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SIGALGS, slistlen, (int *)(slist)) +#define SSL_CTX_set1_sigalgs_list(ctx, s) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SIGALGS_LIST, 0, (char *)(s)) +#define SSL_set1_sigalgs(s, slist, slistlen) \ + SSL_ctrl(s, SSL_CTRL_SET_SIGALGS, slistlen, (int *)(slist)) +#define SSL_set1_sigalgs_list(s, str) \ + SSL_ctrl(s, SSL_CTRL_SET_SIGALGS_LIST, 0, (char *)(str)) +#define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS, slistlen, (int *)(slist)) +#define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_SIGALGS_LIST, 0, (char *)(s)) +#define SSL_set1_client_sigalgs(s, slist, slistlen) \ + SSL_ctrl(s, SSL_CTRL_SET_CLIENT_SIGALGS, slistlen, (int *)(slist)) +#define SSL_set1_client_sigalgs_list(s, str) \ + SSL_ctrl(s, SSL_CTRL_SET_CLIENT_SIGALGS_LIST, 0, (char *)(str)) +#define SSL_get0_certificate_types(s, clist) \ + SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist)) +#define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_CLIENT_CERT_TYPES, clistlen, (char *)(clist)) +#define SSL_set1_client_certificate_types(s, clist, clistlen) \ + SSL_ctrl(s, SSL_CTRL_SET_CLIENT_CERT_TYPES, clistlen, (char *)(clist)) +#define SSL_get_signature_nid(s, pn) \ + SSL_ctrl(s, SSL_CTRL_GET_SIGNATURE_NID, 0, pn) +#define SSL_get_peer_signature_nid(s, pn) \ + SSL_ctrl(s, SSL_CTRL_GET_PEER_SIGNATURE_NID, 0, pn) +#define SSL_get_peer_tmp_key(s, pk) \ + SSL_ctrl(s, SSL_CTRL_GET_PEER_TMP_KEY, 0, pk) #define SSL_get_tmp_key(s, pk) SSL_ctrl(s, SSL_CTRL_GET_TMP_KEY, 0, pk) -#define SSL_get0_raw_cipherlist(s, plst) SSL_ctrl(s, SSL_CTRL_GET_RAW_CIPHERLIST, 0, plst) -#define SSL_get0_ec_point_formats(s, plst) SSL_ctrl(s, SSL_CTRL_GET_EC_POINT_FORMATS, 0, plst) -#define SSL_CTX_set_min_proto_version(ctx, version) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) -#define SSL_CTX_set_max_proto_version(ctx, version) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) -#define SSL_CTX_get_min_proto_version(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) -#define SSL_CTX_get_max_proto_version(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) -#define SSL_set_min_proto_version(s, version) \ - SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) -#define SSL_set_max_proto_version(s, version) \ - SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) -#define SSL_get_min_proto_version(s) SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) -#define SSL_get_max_proto_version(s) SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) +#define SSL_get0_raw_cipherlist(s, plst) \ + SSL_ctrl(s, SSL_CTRL_GET_RAW_CIPHERLIST, 0, plst) +#define SSL_get0_ec_point_formats(s, plst) \ + SSL_ctrl(s, SSL_CTRL_GET_EC_POINT_FORMATS, 0, plst) +#define SSL_CTX_set_min_proto_version(ctx, version) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) +#define SSL_CTX_set_max_proto_version(ctx, version) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) +#define SSL_CTX_get_min_proto_version(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) +#define SSL_CTX_get_max_proto_version(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) +#define SSL_set_min_proto_version(s, version) \ + SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) +#define SSL_set_max_proto_version(s, version) \ + SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) +#define SSL_get_min_proto_version(s) \ + SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) +#define SSL_get_max_proto_version(s) \ + SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) const char *SSL_group_to_name(SSL *s, int id); @@ -1543,22 +1690,22 @@ int SSL_CTX_set0_tmp_dh_pkey(SSL_CTX *ctx, EVP_PKEY *dhpkey); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 /* Provide some compatibility macros for removed functionality. */ -# define SSL_CTX_need_tmp_RSA(ctx) 0 -# define SSL_CTX_set_tmp_rsa(ctx, rsa) 1 -# define SSL_need_tmp_RSA(ssl) 0 -# define SSL_set_tmp_rsa(ssl, rsa) 1 -# define SSL_CTX_set_ecdh_auto(dummy, onoff) ((onoff) != 0) -# define SSL_set_ecdh_auto(dummy, onoff) ((onoff) != 0) +# define SSL_CTX_need_tmp_RSA(ctx) 0 +# define SSL_CTX_set_tmp_rsa(ctx, rsa) 1 +# define SSL_need_tmp_RSA(ssl) 0 +# define SSL_set_tmp_rsa(ssl, rsa) 1 +# define SSL_CTX_set_ecdh_auto(dummy, onoff) ((onoff) != 0) +# define SSL_set_ecdh_auto(dummy, onoff) ((onoff) != 0) /* * We "pretend" to call the callback to avoid warnings about unused static * functions. */ -# define SSL_CTX_set_tmp_rsa_callback(ctx, cb) \ - while (0) \ - (cb)(NULL, 0, 0) -# define SSL_set_tmp_rsa_callback(ssl, cb) \ - while (0) \ - (cb)(NULL, 0, 0) +# define SSL_CTX_set_tmp_rsa_callback(ctx, cb) \ + while (0) \ + (cb)(NULL, 0, 0) +# define SSL_set_tmp_rsa_callback(ssl, cb) \ + while (0) \ + (cb)(NULL, 0, 0) #endif __owur const BIO_METHOD *BIO_f_ssl(void); __owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client); @@ -1569,7 +1716,8 @@ void BIO_ssl_shutdown(BIO *ssl_bio); __owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str); __owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth); -__owur SSL_CTX *SSL_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq, const SSL_METHOD *meth); +__owur SSL_CTX *SSL_CTX_new_ex(OSSL_LIB_CTX *libctx, const char *propq, + const SSL_METHOD *meth); int SSL_CTX_up_ref(SSL_CTX *ctx); void SSL_CTX_free(SSL_CTX *); __owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); @@ -1627,14 +1775,16 @@ void SSL_set_cert_cb(SSL *s, int (*cb)(SSL *ssl, void *arg), void *arg); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 __owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); OSSL_DEPRECATEDIN_3_0 -__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d, long len); +__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d, + long len); #endif __owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); -__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, long len); +__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, + long len); __owur int SSL_use_certificate(SSL *ssl, X509 *x); __owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); -__owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey, STACK_OF(X509) * chain, - int override); +__owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey, + STACK_OF(X509) * chain, int override); /* serverinfo file format versions */ #define SSL_SERVERINFOV1 1 @@ -1644,7 +1794,8 @@ __owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey, STAC __owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo, size_t serverinfo_length); __owur int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version, - const unsigned char *serverinfo, size_t serverinfo_length); + const unsigned char *serverinfo, + size_t serverinfo_length); __owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file); #ifndef OPENSSL_NO_DEPRECATED_3_0 @@ -1657,23 +1808,32 @@ __owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); +__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, + int type); #endif -__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); -__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); +__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, + int type); +__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, + int type); /* PEM type */ __owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); __owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file); __owur STACK_OF(X509_NAME) * SSL_load_client_CA_file(const char *file); __owur STACK_OF(X509_NAME) - * SSL_load_client_CA_file_ex(const char *file, OSSL_LIB_CTX *libctx, const char *propq); -__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) * stackCAs, const char *file); -int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) * stackCAs, const char *dir); -int SSL_add_store_cert_subjects_to_stack(STACK_OF(X509_NAME) * stackCAs, const char *uri); + * SSL_load_client_CA_file_ex(const char *file, OSSL_LIB_CTX *libctx, + const char *propq); +__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) * stackCAs, + const char *file); +int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) * stackCAs, + const char *dir); +int SSL_add_store_cert_subjects_to_stack(STACK_OF(X509_NAME) * stackCAs, + const char *uri); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define SSL_load_error_strings() \ - OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) +# define SSL_load_error_strings() \ + OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \ + | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, \ + NULL) #endif __owur const char *SSL_state_string(const SSL *s); @@ -1689,26 +1849,35 @@ __owur int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version); __owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s); __owur int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname); -void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s, const unsigned char **alpn, size_t *len); -__owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, const unsigned char *alpn, size_t len); +void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s, + const unsigned char **alpn, size_t *len); +__owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, + const unsigned char *alpn, + size_t len); __owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s); __owur int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher); __owur int SSL_SESSION_has_ticket(const SSL_SESSION *s); __owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s); -void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick, size_t *len); +void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick, + size_t *len); __owur uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s); -__owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s, uint32_t max_early_data); +__owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s, + uint32_t max_early_data); __owur int SSL_copy_session_id(SSL *to, const SSL *from); __owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s); -__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, +__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, + const unsigned char *sid_ctx, unsigned int sid_ctx_len); -__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid, unsigned int sid_len); +__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid, + unsigned int sid_len); __owur int SSL_SESSION_is_resumable(const SSL_SESSION *s); __owur SSL_SESSION *SSL_SESSION_new(void); __owur SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src); -const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); -const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s, unsigned int *len); +const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, + unsigned int *len); +const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s, + unsigned int *len); __owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s); #ifndef OPENSSL_NO_STDIO int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses); @@ -1723,16 +1892,18 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session); int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session); __owur int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb); __owur int SSL_set_generate_session_id(SSL *s, GEN_SESSION_CB cb); -__owur int SSL_has_matching_session_id(const SSL *s, const unsigned char *id, unsigned int id_len); -SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length); +__owur int SSL_has_matching_session_id(const SSL *s, const unsigned char *id, + unsigned int id_len); +SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, + long length); #ifdef OPENSSL_X509_H __owur X509 *SSL_get0_peer_certificate(const SSL *s); __owur X509 *SSL_get1_peer_certificate(const SSL *s); /* Deprecated in 3.0.0 */ -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_get_peer_certificate SSL_get1_peer_certificate -# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define SSL_get_peer_certificate SSL_get1_peer_certificate +# endif #endif __owur STACK_OF(X509) * SSL_get_peer_cert_chain(const SSL *s); @@ -1742,19 +1913,25 @@ __owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); __owur SSL_verify_cb SSL_CTX_get_verify_callback(const SSL_CTX *ctx); void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback); void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); -void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg); +void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, + int (*cb)(X509_STORE_CTX *, void *), + void *arg); void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb)(SSL *ssl, void *arg), void *arg); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 __owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); OSSL_DEPRECATEDIN_3_0 -__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); +__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, + long len); #endif __owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); -__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, const unsigned char *d, long len); +__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, + const unsigned char *d, long len); __owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); -__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, const unsigned char *d); -__owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, EVP_PKEY *privatekey, +__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, + const unsigned char *d); +__owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, + EVP_PKEY *privatekey, STACK_OF(X509) * chain, int override); void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); @@ -1769,7 +1946,8 @@ void *SSL_get_default_passwd_cb_userdata(SSL *s); __owur int SSL_CTX_check_private_key(const SSL_CTX *ctx); __owur int SSL_check_private_key(const SSL *ctx); -__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, +__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx, + const unsigned char *sid_ctx, unsigned int sid_ctx_len); SSL *SSL_new(SSL_CTX *ctx); @@ -1789,13 +1967,16 @@ __owur const char *SSL_get0_peername(SSL *s); void SSL_set_hostflags(SSL *s, unsigned int flags); __owur int SSL_CTX_dane_enable(SSL_CTX *ctx); -__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md, uint8_t mtype, uint8_t ord); +__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md, uint8_t mtype, + uint8_t ord); __owur int SSL_dane_enable(SSL *s, const char *basedomain); -__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector, uint8_t mtype, - const unsigned char *data, size_t dlen); +__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector, + uint8_t mtype, const unsigned char *data, + size_t dlen); __owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki); -__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector, uint8_t *mtype, - const unsigned char **data, size_t *dlen); +__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector, + uint8_t *mtype, const unsigned char **data, + size_t *dlen); /* * Bridge opacity barrier between libcrypt and libssl, also needed to support * offline testing in test/danetest.c @@ -1816,30 +1997,35 @@ __owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); __owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); #ifndef OPENSSL_NO_SRP -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name); -OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password); +OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_password(SSL_CTX *ctx, + char *password); OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength); OSSL_DEPRECATEDIN_3_0 -int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx, char *(*cb)(SSL *, void *)); +int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx, + char *(*cb)(SSL *, void *)); OSSL_DEPRECATEDIN_3_0 -int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx, int (*cb)(SSL *, void *)); +int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx, + int (*cb)(SSL *, void *)); OSSL_DEPRECATEDIN_3_0 -int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx, int (*cb)(SSL *, int *, void *)); +int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx, + int (*cb)(SSL *, int *, void *)); OSSL_DEPRECATEDIN_3_0 int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg); OSSL_DEPRECATEDIN_3_0 -int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g, BIGNUM *sa, BIGNUM *v, - char *info); +int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g, + BIGNUM *sa, BIGNUM *v, char *info); OSSL_DEPRECATEDIN_3_0 -int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass, const char *grp); +int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass, + const char *grp); OSSL_DEPRECATEDIN_3_0 __owur BIGNUM *SSL_get_srp_g(SSL *s); OSSL_DEPRECATEDIN_3_0 __owur BIGNUM *SSL_get_srp_N(SSL *s); OSSL_DEPRECATEDIN_3_0 __owur char *SSL_get_srp_username(SSL *s); OSSL_DEPRECATEDIN_3_0 __owur char *SSL_get_srp_userinfo(SSL *s); -# endif +# endif #endif /* @@ -1851,16 +2037,20 @@ OSSL_DEPRECATEDIN_3_0 __owur char *SSL_get_srp_userinfo(SSL *s); #define SSL_CLIENT_HELLO_RETRY (-1) typedef int (*SSL_client_hello_cb_fn)(SSL *s, int *al, void *arg); -void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb, void *arg); +void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb, + void *arg); int SSL_client_hello_isv2(SSL *s); unsigned int SSL_client_hello_get0_legacy_version(SSL *s); size_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out); size_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out); size_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out); -size_t SSL_client_hello_get0_compression_methods(SSL *s, const unsigned char **out); +size_t SSL_client_hello_get0_compression_methods(SSL *s, + const unsigned char **out); int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen); -int SSL_client_hello_get_extension_order(SSL *s, uint16_t *exts, size_t *num_exts); -int SSL_client_hello_get0_ext(SSL *s, unsigned int type, const unsigned char **out, size_t *outlen); +int SSL_client_hello_get_extension_order(SSL *s, uint16_t *exts, + size_t *num_exts); +int SSL_client_hello_get0_ext(SSL *s, unsigned int type, + const unsigned char **out, size_t *outlen); void SSL_certs_clear(SSL *s); void SSL_free(SSL *ssl); @@ -1870,9 +2060,11 @@ void SSL_free(SSL *ssl); */ __owur int SSL_waiting_for_async(SSL *s); __owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds); -__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, size_t *numaddfds, - OSSL_ASYNC_FD *delfd, size_t *numdelfds); -__owur int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback); +__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, + size_t *numaddfds, OSSL_ASYNC_FD *delfd, + size_t *numdelfds); +__owur int SSL_CTX_set_async_callback(SSL_CTX *ctx, + SSL_async_callback_fn callback); __owur int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg); __owur int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback); __owur int SSL_set_async_callback_arg(SSL *s, void *arg); @@ -1889,13 +2081,16 @@ __owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); #define SSL_READ_EARLY_DATA_SUCCESS 1 #define SSL_READ_EARLY_DATA_FINISH 2 -__owur int SSL_read_early_data(SSL *s, void *buf, size_t num, size_t *readbytes); +__owur int SSL_read_early_data(SSL *s, void *buf, size_t num, + size_t *readbytes); __owur int SSL_peek(SSL *ssl, void *buf, int num); __owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); -__owur ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, int flags); +__owur ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, + int flags); __owur int SSL_write(SSL *ssl, const void *buf, int num); __owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written); -__owur int SSL_write_early_data(SSL *s, const void *buf, size_t num, size_t *written); +__owur int SSL_write_early_data(SSL *s, const void *buf, size_t num, + size_t *written); long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg); long SSL_callback_ctrl(SSL *, int, void (*)(void)); long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); @@ -1917,11 +2112,11 @@ __owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth); #endif #ifndef OPENSSL_NO_SSL3_METHOD -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *SSLv3_method(void); /* SSLv3 */ OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *SSLv3_server_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *SSLv3_client_method(void); -# endif +# endif #endif #define SSLv23_method TLS_method @@ -1934,47 +2129,51 @@ __owur const SSL_METHOD *TLS_server_method(void); __owur const SSL_METHOD *TLS_client_method(void); #ifndef OPENSSL_NO_TLS1_METHOD -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD * +TLSv1_method(void); /* TLSv1.0 */ OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_server_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_client_method(void); -# endif +# endif #endif #ifndef OPENSSL_NO_TLS1_1_METHOD -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD * +TLSv1_1_method(void); /* TLSv1.1 */ OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_1_server_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_1_client_method(void); -# endif +# endif #endif #ifndef OPENSSL_NO_TLS1_2_METHOD -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD * +TLSv1_2_method(void); /* TLSv1.2 */ OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_server_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *TLSv1_2_client_method(void); -# endif +# endif #endif #ifndef OPENSSL_NO_DTLS1_METHOD -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 -OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */ +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD * +DTLSv1_method(void); /* DTLSv1.0 */ OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_server_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_client_method(void); -# endif +# endif #endif #ifndef OPENSSL_NO_DTLS1_2_METHOD /* DTLSv1.2 */ -# ifndef OPENSSL_NO_DEPRECATED_1_1_0 +# ifndef OPENSSL_NO_DEPRECATED_1_1_0 OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_2_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_2_server_method(void); OSSL_DEPRECATEDIN_1_1_0 __owur const SSL_METHOD *DTLSv1_2_client_method(void); -# endif +# endif #endif -__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */ +__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */ __owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */ __owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */ @@ -2026,7 +2225,7 @@ void SSL_set_accept_state(SSL *s); __owur long SSL_get_default_timeout(const SSL *s); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define SSL_library_init() OPENSSL_init_ssl(0, NULL) +# define SSL_library_init() OPENSSL_init_ssl(0, NULL) #endif __owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size); @@ -2058,78 +2257,101 @@ __owur int SSL_CTX_set_default_verify_store(SSL_CTX *ctx); __owur int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile); __owur int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath); __owur int SSL_CTX_load_verify_store(SSL_CTX *ctx, const char *CAstore); -__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath); +__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, + const char *CApath); #define SSL_get0_session SSL_get_session /* just peek at pointer */ __owur SSL_SESSION *SSL_get_session(const SSL *ssl); __owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ __owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx); -void SSL_set_info_callback(SSL *ssl, void (*cb)(const SSL *ssl, int type, int val)); -void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type, int val); +void SSL_set_info_callback(SSL *ssl, + void (*cb)(const SSL *ssl, int type, int val)); +void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type, + int val); __owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl); void SSL_set_verify_result(SSL *ssl, long v); __owur long SSL_get_verify_result(const SSL *ssl); __owur STACK_OF(X509) * SSL_get0_verified_chain(const SSL *s); -__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, size_t outlen); -__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, size_t outlen); -__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess, unsigned char *out, - size_t outlen); -__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess, const unsigned char *in, size_t len); +__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, + size_t outlen); +__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, + size_t outlen); +__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess, + unsigned char *out, size_t outlen); +__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess, + const unsigned char *in, size_t len); uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *sess); -#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef) +#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef) __owur int SSL_set_ex_data(SSL *ssl, int idx, void *data); void *SSL_get_ex_data(const SSL *ssl, int idx); -#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef) +#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef) __owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data); void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx); -#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef) +#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef) __owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data); void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx); __owur int SSL_get_ex_data_X509_STORE_CTX_idx(void); -#define SSL_CTX_sess_set_cache_size(ctx, t) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, t, NULL) -#define SSL_CTX_sess_get_cache_size(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_GET_SESS_CACHE_SIZE, 0, NULL) -#define SSL_CTX_set_session_cache_mode(ctx, m) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_MODE, m, NULL) -#define SSL_CTX_get_session_cache_mode(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_GET_SESS_CACHE_MODE, 0, NULL) +#define SSL_CTX_sess_set_cache_size(ctx, t) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, t, NULL) +#define SSL_CTX_sess_get_cache_size(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_SESS_CACHE_SIZE, 0, NULL) +#define SSL_CTX_set_session_cache_mode(ctx, m) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_MODE, m, NULL) +#define SSL_CTX_get_session_cache_mode(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_SESS_CACHE_MODE, 0, NULL) #define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) #define SSL_CTX_set_default_read_ahead(ctx, m) SSL_CTX_set_read_ahead(ctx, m) -#define SSL_CTX_get_read_ahead(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_GET_READ_AHEAD, 0, NULL) -#define SSL_CTX_set_read_ahead(ctx, m) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, NULL) -#define SSL_CTX_get_max_cert_list(ctx) SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_CERT_LIST, 0, NULL) -#define SSL_CTX_set_max_cert_list(ctx, m) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_CERT_LIST, m, NULL) -#define SSL_get_max_cert_list(ssl) SSL_ctrl(ssl, SSL_CTRL_GET_MAX_CERT_LIST, 0, NULL) -#define SSL_set_max_cert_list(ssl, m) SSL_ctrl(ssl, SSL_CTRL_SET_MAX_CERT_LIST, m, NULL) +#define SSL_CTX_get_read_ahead(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_READ_AHEAD, 0, NULL) +#define SSL_CTX_set_read_ahead(ctx, m) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, NULL) +#define SSL_CTX_get_max_cert_list(ctx) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_CERT_LIST, 0, NULL) +#define SSL_CTX_set_max_cert_list(ctx, m) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_CERT_LIST, m, NULL) +#define SSL_get_max_cert_list(ssl) \ + SSL_ctrl(ssl, SSL_CTRL_GET_MAX_CERT_LIST, 0, NULL) +#define SSL_set_max_cert_list(ssl, m) \ + SSL_ctrl(ssl, SSL_CTRL_SET_MAX_CERT_LIST, m, NULL) -#define SSL_CTX_set_max_send_fragment(ctx, m) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_SEND_FRAGMENT, m, NULL) -#define SSL_set_max_send_fragment(ssl, m) SSL_ctrl(ssl, SSL_CTRL_SET_MAX_SEND_FRAGMENT, m, NULL) -#define SSL_CTX_set_split_send_fragment(ctx, m) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SPLIT_SEND_FRAGMENT, m, NULL) -#define SSL_set_split_send_fragment(ssl, m) SSL_ctrl(ssl, SSL_CTRL_SET_SPLIT_SEND_FRAGMENT, m, NULL) -#define SSL_CTX_set_max_pipelines(ctx, m) SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PIPELINES, m, NULL) -#define SSL_set_max_pipelines(ssl, m) SSL_ctrl(ssl, SSL_CTRL_SET_MAX_PIPELINES, m, NULL) -#define SSL_set_retry_verify(ssl) (SSL_ctrl(ssl, SSL_CTRL_SET_RETRY_VERIFY, 0, NULL) > 0) +#define SSL_CTX_set_max_send_fragment(ctx, m) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_SEND_FRAGMENT, m, NULL) +#define SSL_set_max_send_fragment(ssl, m) \ + SSL_ctrl(ssl, SSL_CTRL_SET_MAX_SEND_FRAGMENT, m, NULL) +#define SSL_CTX_set_split_send_fragment(ctx, m) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SPLIT_SEND_FRAGMENT, m, NULL) +#define SSL_set_split_send_fragment(ssl, m) \ + SSL_ctrl(ssl, SSL_CTRL_SET_SPLIT_SEND_FRAGMENT, m, NULL) +#define SSL_CTX_set_max_pipelines(ctx, m) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PIPELINES, m, NULL) +#define SSL_set_max_pipelines(ssl, m) \ + SSL_ctrl(ssl, SSL_CTRL_SET_MAX_PIPELINES, m, NULL) +#define SSL_set_retry_verify(ssl) \ + (SSL_ctrl(ssl, SSL_CTRL_SET_RETRY_VERIFY, 0, NULL) > 0) void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len); void SSL_set_default_read_buffer_len(SSL *s, size_t len); #ifndef OPENSSL_NO_DH -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 /* NB: the |keylength| is only applicable when is_export is true */ OSSL_DEPRECATEDIN_3_0 -void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, DH *(*dh)(SSL *ssl, int is_export, int keylength)); +void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, + DH *(*dh)(SSL *ssl, int is_export, + int keylength)); OSSL_DEPRECATEDIN_3_0 -void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*dh)(SSL *ssl, int is_export, int keylength)); -# endif +void SSL_set_tmp_dh_callback(SSL *ssl, + DH *(*dh)(SSL *ssl, int is_export, int keylength)); +# endif #endif __owur const COMP_METHOD *SSL_get_current_compression(const SSL *s); @@ -2138,41 +2360,51 @@ __owur const char *SSL_COMP_get_name(const COMP_METHOD *comp); __owur const char *SSL_COMP_get0_name(const SSL_COMP *comp); __owur int SSL_COMP_get_id(const SSL_COMP *comp); STACK_OF(SSL_COMP) * SSL_COMP_get_compression_methods(void); -__owur STACK_OF(SSL_COMP) * SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP) * meths); +__owur STACK_OF(SSL_COMP) + * SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP) * meths); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define SSL_COMP_free_compression_methods() \ - while (0) \ - continue +# define SSL_COMP_free_compression_methods() \ + while (0) \ + continue #endif __owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm); const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c); int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c); -int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len, int isv2format, - STACK_OF(SSL_CIPHER) * *sk, STACK_OF(SSL_CIPHER) * *scsvs); +int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len, + int isv2format, STACK_OF(SSL_CIPHER) * *sk, + STACK_OF(SSL_CIPHER) * *scsvs); /* TLS extensions functions */ __owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len); -__owur int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb, void *arg); +__owur int SSL_set_session_ticket_ext_cb(SSL *s, + tls_session_ticket_ext_cb_fn cb, + void *arg); /* Pre-shared secret session resumption functions */ -__owur int SSL_set_session_secret_cb(SSL *s, tls_session_secret_cb_fn session_secret_cb, void *arg); +__owur int SSL_set_session_secret_cb(SSL *s, + tls_session_secret_cb_fn session_secret_cb, + void *arg); -void SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx, - int (*cb)(SSL *ssl, int is_forward_secure)); +void SSL_CTX_set_not_resumable_session_callback( + SSL_CTX *ctx, int (*cb)(SSL *ssl, int is_forward_secure)); -void SSL_set_not_resumable_session_callback(SSL *ssl, int (*cb)(SSL *ssl, int is_forward_secure)); +void SSL_set_not_resumable_session_callback(SSL *ssl, + int (*cb)(SSL *ssl, + int is_forward_secure)); void SSL_CTX_set_record_padding_callback(SSL_CTX *ctx, - size_t (*cb)(SSL *ssl, int type, size_t len, void *arg)); + size_t (*cb)(SSL *ssl, int type, + size_t len, void *arg)); void SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg); void *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx); int SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size); int SSL_set_record_padding_callback(SSL *ssl, - size_t (*cb)(SSL *ssl, int type, size_t len, void *arg)); + size_t (*cb)(SSL *ssl, int type, size_t len, + void *arg)); void SSL_set_record_padding_callback_arg(SSL *ssl, void *arg); void *SSL_get_record_padding_callback_arg(const SSL *ssl); int SSL_set_block_padding(SSL *ssl, size_t block_size); @@ -2183,7 +2415,7 @@ int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets); size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define SSL_cache_hit(s) SSL_session_reused(s) +# define SSL_cache_hit(s) SSL_session_reused(s) #endif __owur int SSL_session_reused(const SSL *s); @@ -2193,7 +2425,8 @@ __owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void); int SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx); void SSL_CONF_CTX_free(SSL_CONF_CTX *cctx); unsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags); -__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, unsigned int flags); +__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, + unsigned int flags); __owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre); void SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl); @@ -2208,8 +2441,8 @@ int SSL_config(SSL *s, const char *name); int SSL_CTX_config(SSL_CTX *ctx, const char *name); #ifndef OPENSSL_NO_SSL_TRACE -void SSL_trace(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, - void *arg); +void SSL_trace(int write_p, int version, int content_type, const void *buf, + size_t len, SSL *ssl, void *arg); #endif #ifndef OPENSSL_NO_SOCK @@ -2224,8 +2457,8 @@ int DTLSv1_listen(SSL *s, BIO_ADDR *client); * May return a negative integer if an error occurs. * A connection should be aborted if the SCTs are deemed insufficient. */ -typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx, const STACK_OF(SCT) * scts, - void *arg); +typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx, + const STACK_OF(SCT) * scts, void *arg); /* * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate @@ -2239,10 +2472,14 @@ typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx, const STACK_O * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response * will be requested. */ -int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback, void *arg); -int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx, ssl_ct_validation_cb callback, void *arg); -# define SSL_disable_ct(s) ((void)SSL_set_validation_callback((s), NULL, NULL)) -# define SSL_CTX_disable_ct(ctx) ((void)SSL_CTX_set_validation_callback((ctx), NULL, NULL)) +int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback, + void *arg); +int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx, + ssl_ct_validation_cb callback, + void *arg); +# define SSL_disable_ct(s) ((void)SSL_set_validation_callback((s), NULL, NULL)) +# define SSL_CTX_disable_ct(ctx) \ + ((void)SSL_CTX_set_validation_callback((ctx), NULL, NULL)) /* * The validation type enumerates the available behaviours of the built-in SSL @@ -2251,8 +2488,8 @@ int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx, ssl_ct_validation_cb callba */ enum { - SSL_CT_VALIDATION_PERMISSIVE = 0, - SSL_CT_VALIDATION_STRICT + SSL_CT_VALIDATION_PERMISSIVE = 0, + SSL_CT_VALIDATION_STRICT }; /* @@ -2371,20 +2608,26 @@ const CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx); void SSL_set_security_level(SSL *s, int level); __owur int SSL_get_security_level(const SSL *s); void SSL_set_security_callback(SSL *s, - int (*cb)(const SSL *s, const SSL_CTX *ctx, int op, int bits, - int nid, void *other, void *ex)); -int (*SSL_get_security_callback(const SSL *s))(const SSL *s, const SSL_CTX *ctx, int op, int bits, - int nid, void *other, void *ex); + int (*cb)(const SSL *s, const SSL_CTX *ctx, + int op, int bits, int nid, void *other, + void *ex)); +int (*SSL_get_security_callback(const SSL *s))(const SSL *s, const SSL_CTX *ctx, + int op, int bits, int nid, + void *other, void *ex); void SSL_set0_security_ex_data(SSL *s, void *ex); __owur void *SSL_get0_security_ex_data(const SSL *s); void SSL_CTX_set_security_level(SSL_CTX *ctx, int level); __owur int SSL_CTX_get_security_level(const SSL_CTX *ctx); void SSL_CTX_set_security_callback(SSL_CTX *ctx, - int (*cb)(const SSL *s, const SSL_CTX *ctx, int op, int bits, - int nid, void *other, void *ex)); -int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx))(const SSL *s, const SSL_CTX *ctx, int op, - int bits, int nid, void *other, void *ex); + int (*cb)(const SSL *s, const SSL_CTX *ctx, + int op, int bits, int nid, + void *other, void *ex)); +int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx))(const SSL *s, + const SSL_CTX *ctx, + int op, int bits, + int nid, void *other, + void *ex); void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex); __owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx); @@ -2392,7 +2635,8 @@ __owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx); #define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0x00100000L #define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L -#define OPENSSL_INIT_SSL_DEFAULT (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS) +#define OPENSSL_INIT_SSL_DEFAULT \ + (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS) int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); @@ -2438,13 +2682,15 @@ typedef int SSL_TICKET_RETURN; #define SSL_TICKET_RETURN_USE_RENEW 4 typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg); -typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss, - const unsigned char *keyname, - size_t keyname_length, - SSL_TICKET_STATUS status, void *arg); -int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx, SSL_CTX_generate_session_ticket_fn gen_cb, - SSL_CTX_decrypt_session_ticket_fn dec_cb, void *arg); -int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len); +typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)( + SSL *s, SSL_SESSION *ss, const unsigned char *keyname, + size_t keyname_length, SSL_TICKET_STATUS status, void *arg); +int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx, + SSL_CTX_generate_session_ticket_fn gen_cb, + SSL_CTX_decrypt_session_ticket_fn dec_cb, + void *arg); +int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, + size_t len); int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len); typedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us); @@ -2452,8 +2698,10 @@ typedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us); void DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb); typedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg); -void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx, SSL_allow_early_data_cb_fn cb, void *arg); -void SSL_set_allow_early_data_cb(SSL *s, SSL_allow_early_data_cb_fn cb, void *arg); +void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx, + SSL_allow_early_data_cb_fn cb, void *arg); +void SSL_set_allow_early_data_cb(SSL *s, SSL_allow_early_data_cb_fn cb, + void *arg); /* store the default cipher strings inside the library */ const char *OSSL_default_cipher_list(void); @@ -2467,12 +2715,15 @@ int SSL_compress_certs(SSL *ssl, int alg); int SSL_CTX_set1_cert_comp_preference(SSL_CTX *ctx, int *algs, size_t len); int SSL_set1_cert_comp_preference(SSL *ssl, int *algs, size_t len); -int SSL_CTX_set1_compressed_cert(SSL_CTX *ctx, int algorithm, unsigned char *comp_data, - size_t comp_length, size_t orig_length); -int SSL_set1_compressed_cert(SSL *ssl, int algorithm, unsigned char *comp_data, size_t comp_length, - size_t orig_length); -size_t SSL_CTX_get1_compressed_cert(SSL_CTX *ctx, int alg, unsigned char **data, size_t *orig_len); -size_t SSL_get1_compressed_cert(SSL *ssl, int alg, unsigned char **data, size_t *orig_len); +int SSL_CTX_set1_compressed_cert(SSL_CTX *ctx, int algorithm, + unsigned char *comp_data, size_t comp_length, + size_t orig_length); +int SSL_set1_compressed_cert(SSL *ssl, int algorithm, unsigned char *comp_data, + size_t comp_length, size_t orig_length); +size_t SSL_CTX_get1_compressed_cert(SSL_CTX *ctx, int alg, unsigned char **data, + size_t *orig_len); +size_t SSL_get1_compressed_cert(SSL *ssl, int alg, unsigned char **data, + size_t *orig_len); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/ssl2.h b/libs/OpenSSL/include/openssl/ssl2.h index ab65fb8d..4189b690 100644 --- a/libs/OpenSSL/include/openssl/ssl2.h +++ b/libs/OpenSSL/include/openssl/ssl2.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SSL2_H +# define HEADER_SSL2_H #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/ssl3.h b/libs/OpenSSL/include/openssl/ssl3.h index cb05e749..ada32b6a 100644 --- a/libs/OpenSSL/include/openssl/ssl3.h +++ b/libs/OpenSSL/include/openssl/ssl3.h @@ -14,7 +14,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SSL3_H +# define HEADER_SSL3_H #endif #include @@ -149,12 +149,12 @@ extern "C" { * allocated region to its front, but makes data payload aligned, which * improves performance:-) */ -# define SSL3_ALIGN_PAYLOAD 8 +# define SSL3_ALIGN_PAYLOAD 8 #else -# if (SSL3_ALIGN_PAYLOAD & (SSL3_ALIGN_PAYLOAD - 1)) != 0 -# error "insane SSL3_ALIGN_PAYLOAD" -# undef SSL3_ALIGN_PAYLOAD -# endif +# if (SSL3_ALIGN_PAYLOAD & (SSL3_ALIGN_PAYLOAD - 1)) != 0 +# error "insane SSL3_ALIGN_PAYLOAD" +# undef SSL3_ALIGN_PAYLOAD +# endif #endif /* @@ -191,21 +191,23 @@ extern "C" { * send overhead is smaller. */ -#define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE) +#define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \ + (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE) /* If compression isn't used don't include the compression overhead */ #ifdef OPENSSL_NO_COMP -# define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH +# define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH #else -# define SSL3_RT_MAX_COMPRESSED_LENGTH \ - (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_COMPRESSED_OVERHEAD) +# define SSL3_RT_MAX_COMPRESSED_LENGTH \ + (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_COMPRESSED_OVERHEAD) #endif -#define SSL3_RT_MAX_ENCRYPTED_LENGTH \ - (SSL3_RT_MAX_ENCRYPTED_OVERHEAD + SSL3_RT_MAX_COMPRESSED_LENGTH) -#define SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH \ - (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD) -#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH + SSL3_RT_HEADER_LENGTH) +#define SSL3_RT_MAX_ENCRYPTED_LENGTH \ + (SSL3_RT_MAX_ENCRYPTED_OVERHEAD + SSL3_RT_MAX_COMPRESSED_LENGTH) +#define SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH \ + (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD) +#define SSL3_RT_MAX_PACKET_SIZE \ + (SSL3_RT_MAX_ENCRYPTED_LENGTH + SSL3_RT_HEADER_LENGTH) #define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" #define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" @@ -241,10 +243,10 @@ extern "C" { #define SSL3_AL_FATAL 2 #define SSL3_AD_CLOSE_NOTIFY 0 -#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ -#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ +#define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ +#define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ #define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ -#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ +#define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ #define SSL3_AD_NO_CERTIFICATE 41 #define SSL3_AD_BAD_CERTIFICATE 42 #define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 @@ -270,9 +272,9 @@ extern "C" { #define SSL3_CT_NUMBER 12 #if defined(TLS_CT_NUMBER) -# if TLS_CT_NUMBER != SSL3_CT_NUMBER -# error "SSL/TLS CT_NUMBER values do not match" -# endif +# if TLS_CT_NUMBER != SSL3_CT_NUMBER +# error "SSL/TLS CT_NUMBER values do not match" +# endif #endif /* No longer used as of OpenSSL 1.1.1 */ @@ -316,7 +318,7 @@ extern "C" { #define SSL3_MT_KEY_UPDATE 24 #define SSL3_MT_COMPRESSED_CERTIFICATE 25 #ifndef OPENSSL_NO_NEXTPROTONEG -# define SSL3_MT_NEXT_PROTO 67 +# define SSL3_MT_NEXT_PROTO 67 #endif #define SSL3_MT_MESSAGE_HASH 254 #define DTLS1_MT_HELLO_VERIFY_REQUEST 3 diff --git a/libs/OpenSSL/include/openssl/sslerr_legacy.h b/libs/OpenSSL/include/openssl/sslerr_legacy.h index 4d526ea8..ee7e7d9f 100644 --- a/libs/OpenSSL/include/openssl/sslerr_legacy.h +++ b/libs/OpenSSL/include/openssl/sslerr_legacy.h @@ -33,433 +33,433 @@ OSSL_DEPRECATEDIN_3_0 int ERR_load_SSL_strings(void); /* * SSL function codes. */ -# define SSL_F_ADD_CLIENT_KEY_SHARE_EXT 0 -# define SSL_F_ADD_KEY_SHARE 0 -# define SSL_F_BYTES_TO_CIPHER_LIST 0 -# define SSL_F_CHECK_SUITEB_CIPHER_LIST 0 -# define SSL_F_CIPHERSUITE_CB 0 -# define SSL_F_CONSTRUCT_CA_NAMES 0 -# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS 0 -# define SSL_F_CONSTRUCT_STATEFUL_TICKET 0 -# define SSL_F_CONSTRUCT_STATELESS_TICKET 0 -# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH 0 -# define SSL_F_CREATE_TICKET_PREQUEL 0 -# define SSL_F_CT_MOVE_SCTS 0 -# define SSL_F_CT_STRICT 0 -# define SSL_F_CUSTOM_EXT_ADD 0 -# define SSL_F_CUSTOM_EXT_PARSE 0 -# define SSL_F_D2I_SSL_SESSION 0 -# define SSL_F_DANE_CTX_ENABLE 0 -# define SSL_F_DANE_MTYPE_SET 0 -# define SSL_F_DANE_TLSA_ADD 0 -# define SSL_F_DERIVE_SECRET_KEY_AND_IV 0 -# define SSL_F_DO_DTLS1_WRITE 0 -# define SSL_F_DO_SSL3_WRITE 0 -# define SSL_F_DTLS1_BUFFER_RECORD 0 -# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 0 -# define SSL_F_DTLS1_HEARTBEAT 0 -# define SSL_F_DTLS1_HM_FRAGMENT_NEW 0 -# define SSL_F_DTLS1_PREPROCESS_FRAGMENT 0 -# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS 0 -# define SSL_F_DTLS1_PROCESS_RECORD 0 -# define SSL_F_DTLS1_READ_BYTES 0 -# define SSL_F_DTLS1_READ_FAILED 0 -# define SSL_F_DTLS1_RETRANSMIT_MESSAGE 0 -# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 0 -# define SSL_F_DTLS1_WRITE_BYTES 0 -# define SSL_F_DTLSV1_LISTEN 0 -# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC 0 -# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 0 -# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 0 -# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 0 -# define SSL_F_DTLS_RECORD_LAYER_NEW 0 -# define SSL_F_DTLS_WAIT_FOR_DRY 0 -# define SSL_F_EARLY_DATA_COUNT_OK 0 -# define SSL_F_FINAL_EARLY_DATA 0 -# define SSL_F_FINAL_EC_PT_FORMATS 0 -# define SSL_F_FINAL_EMS 0 -# define SSL_F_FINAL_KEY_SHARE 0 -# define SSL_F_FINAL_MAXFRAGMENTLEN 0 -# define SSL_F_FINAL_RENEGOTIATE 0 -# define SSL_F_FINAL_SERVER_NAME 0 -# define SSL_F_FINAL_SIG_ALGS 0 -# define SSL_F_GET_CERT_VERIFY_TBS_DATA 0 -# define SSL_F_NSS_KEYLOG_INT 0 -# define SSL_F_OPENSSL_INIT_SSL 0 -# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION 0 -# define SSL_F_OSSL_STATEM_CLIENT13_WRITE_TRANSITION 0 -# define SSL_F_OSSL_STATEM_CLIENT_CONSTRUCT_MESSAGE 0 -# define SSL_F_OSSL_STATEM_CLIENT_POST_PROCESS_MESSAGE 0 -# define SSL_F_OSSL_STATEM_CLIENT_PROCESS_MESSAGE 0 -# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION 0 -# define SSL_F_OSSL_STATEM_CLIENT_WRITE_TRANSITION 0 -# define SSL_F_OSSL_STATEM_SERVER13_READ_TRANSITION 0 -# define SSL_F_OSSL_STATEM_SERVER13_WRITE_TRANSITION 0 -# define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE 0 -# define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE 0 -# define SSL_F_OSSL_STATEM_SERVER_POST_WORK 0 -# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK 0 -# define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE 0 -# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 0 -# define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION 0 -# define SSL_F_PARSE_CA_NAMES 0 -# define SSL_F_PITEM_NEW 0 -# define SSL_F_PQUEUE_NEW 0 -# define SSL_F_PROCESS_KEY_SHARE_EXT 0 -# define SSL_F_READ_STATE_MACHINE 0 -# define SSL_F_SET_CLIENT_CIPHERSUITE 0 -# define SSL_F_SRP_GENERATE_CLIENT_MASTER_SECRET 0 -# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET 0 -# define SSL_F_SRP_VERIFY_SERVER_PARAM 0 -# define SSL_F_SSL3_CHANGE_CIPHER_STATE 0 -# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 0 -# define SSL_F_SSL3_CTRL 0 -# define SSL_F_SSL3_CTX_CTRL 0 -# define SSL_F_SSL3_DIGEST_CACHED_RECORDS 0 -# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 0 -# define SSL_F_SSL3_ENC 0 -# define SSL_F_SSL3_FINAL_FINISH_MAC 0 -# define SSL_F_SSL3_FINISH_MAC 0 -# define SSL_F_SSL3_GENERATE_KEY_BLOCK 0 -# define SSL_F_SSL3_GENERATE_MASTER_SECRET 0 -# define SSL_F_SSL3_GET_RECORD 0 -# define SSL_F_SSL3_INIT_FINISHED_MAC 0 -# define SSL_F_SSL3_OUTPUT_CERT_CHAIN 0 -# define SSL_F_SSL3_READ_BYTES 0 -# define SSL_F_SSL3_READ_N 0 -# define SSL_F_SSL3_SETUP_KEY_BLOCK 0 -# define SSL_F_SSL3_SETUP_READ_BUFFER 0 -# define SSL_F_SSL3_SETUP_WRITE_BUFFER 0 -# define SSL_F_SSL3_WRITE_BYTES 0 -# define SSL_F_SSL3_WRITE_PENDING 0 -# define SSL_F_SSL_ADD_CERT_CHAIN 0 -# define SSL_F_SSL_ADD_CERT_TO_BUF 0 -# define SSL_F_SSL_ADD_CERT_TO_WPACKET 0 -# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT 0 -# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT 0 -# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT 0 -# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 0 -# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 0 -# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT 0 -# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT 0 -# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT 0 -# define SSL_F_SSL_BAD_METHOD 0 -# define SSL_F_SSL_BUILD_CERT_CHAIN 0 -# define SSL_F_SSL_BYTES_TO_CIPHER_LIST 0 -# define SSL_F_SSL_CACHE_CIPHERLIST 0 -# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT 0 -# define SSL_F_SSL_CERT_DUP 0 -# define SSL_F_SSL_CERT_NEW 0 -# define SSL_F_SSL_CERT_SET0_CHAIN 0 -# define SSL_F_SSL_CHECK_PRIVATE_KEY 0 -# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 0 -# define SSL_F_SSL_CHECK_SRP_EXT_CLIENTHELLO 0 -# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG 0 -# define SSL_F_SSL_CHOOSE_CLIENT_VERSION 0 -# define SSL_F_SSL_CIPHER_DESCRIPTION 0 -# define SSL_F_SSL_CIPHER_LIST_TO_BYTES 0 -# define SSL_F_SSL_CIPHER_PROCESS_RULESTR 0 -# define SSL_F_SSL_CIPHER_STRENGTH_SORT 0 -# define SSL_F_SSL_CLEAR 0 -# define SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT 0 -# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 0 -# define SSL_F_SSL_CONF_CMD 0 -# define SSL_F_SSL_CREATE_CIPHER_LIST 0 -# define SSL_F_SSL_CTRL 0 -# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 0 -# define SSL_F_SSL_CTX_ENABLE_CT 0 -# define SSL_F_SSL_CTX_MAKE_PROFILES 0 -# define SSL_F_SSL_CTX_NEW 0 -# define SSL_F_SSL_CTX_SET_ALPN_PROTOS 0 -# define SSL_F_SSL_CTX_SET_CIPHER_LIST 0 -# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE 0 -# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK 0 -# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 0 -# define SSL_F_SSL_CTX_SET_SSL_VERSION 0 -# define SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH 0 -# define SSL_F_SSL_CTX_USE_CERTIFICATE 0 -# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 0 -# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 0 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY 0 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 0 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 0 -# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT 0 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 0 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 0 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 0 -# define SSL_F_SSL_CTX_USE_SERVERINFO 0 -# define SSL_F_SSL_CTX_USE_SERVERINFO_EX 0 -# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE 0 -# define SSL_F_SSL_DANE_DUP 0 -# define SSL_F_SSL_DANE_ENABLE 0 -# define SSL_F_SSL_DERIVE 0 -# define SSL_F_SSL_DO_CONFIG 0 -# define SSL_F_SSL_DO_HANDSHAKE 0 -# define SSL_F_SSL_DUP_CA_LIST 0 -# define SSL_F_SSL_ENABLE_CT 0 -# define SSL_F_SSL_GENERATE_PKEY_GROUP 0 -# define SSL_F_SSL_GENERATE_SESSION_ID 0 -# define SSL_F_SSL_GET_NEW_SESSION 0 -# define SSL_F_SSL_GET_PREV_SESSION 0 -# define SSL_F_SSL_GET_SERVER_CERT_INDEX 0 -# define SSL_F_SSL_GET_SIGN_PKEY 0 -# define SSL_F_SSL_HANDSHAKE_HASH 0 -# define SSL_F_SSL_INIT_WBIO_BUFFER 0 -# define SSL_F_SSL_KEY_UPDATE 0 -# define SSL_F_SSL_LOAD_CLIENT_CA_FILE 0 -# define SSL_F_SSL_LOG_MASTER_SECRET 0 -# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE 0 -# define SSL_F_SSL_MODULE_INIT 0 -# define SSL_F_SSL_NEW 0 -# define SSL_F_SSL_NEXT_PROTO_VALIDATE 0 -# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT 0 -# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT 0 -# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT 0 -# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT 0 -# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT 0 -# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT 0 -# define SSL_F_SSL_PEEK 0 -# define SSL_F_SSL_PEEK_EX 0 -# define SSL_F_SSL_PEEK_INTERNAL 0 -# define SSL_F_SSL_READ 0 -# define SSL_F_SSL_READ_EARLY_DATA 0 -# define SSL_F_SSL_READ_EX 0 -# define SSL_F_SSL_READ_INTERNAL 0 -# define SSL_F_SSL_RENEGOTIATE 0 -# define SSL_F_SSL_RENEGOTIATE_ABBREVIATED 0 -# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT 0 -# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT 0 -# define SSL_F_SSL_SESSION_DUP 0 -# define SSL_F_SSL_SESSION_NEW 0 -# define SSL_F_SSL_SESSION_PRINT_FP 0 -# define SSL_F_SSL_SESSION_SET1_ID 0 -# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT 0 -# define SSL_F_SSL_SET_ALPN_PROTOS 0 -# define SSL_F_SSL_SET_CERT 0 -# define SSL_F_SSL_SET_CERT_AND_KEY 0 -# define SSL_F_SSL_SET_CIPHER_LIST 0 -# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK 0 -# define SSL_F_SSL_SET_FD 0 -# define SSL_F_SSL_SET_PKEY 0 -# define SSL_F_SSL_SET_RFD 0 -# define SSL_F_SSL_SET_SESSION 0 -# define SSL_F_SSL_SET_SESSION_ID_CONTEXT 0 -# define SSL_F_SSL_SET_SESSION_TICKET_EXT 0 -# define SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH 0 -# define SSL_F_SSL_SET_WFD 0 -# define SSL_F_SSL_SHUTDOWN 0 -# define SSL_F_SSL_SRP_CTX_INIT 0 -# define SSL_F_SSL_START_ASYNC_JOB 0 -# define SSL_F_SSL_UNDEFINED_FUNCTION 0 -# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 0 -# define SSL_F_SSL_USE_CERTIFICATE 0 -# define SSL_F_SSL_USE_CERTIFICATE_ASN1 0 -# define SSL_F_SSL_USE_CERTIFICATE_FILE 0 -# define SSL_F_SSL_USE_PRIVATEKEY 0 -# define SSL_F_SSL_USE_PRIVATEKEY_ASN1 0 -# define SSL_F_SSL_USE_PRIVATEKEY_FILE 0 -# define SSL_F_SSL_USE_PSK_IDENTITY_HINT 0 -# define SSL_F_SSL_USE_RSAPRIVATEKEY 0 -# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 0 -# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 0 -# define SSL_F_SSL_VALIDATE_CT 0 -# define SSL_F_SSL_VERIFY_CERT_CHAIN 0 -# define SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE 0 -# define SSL_F_SSL_WRITE 0 -# define SSL_F_SSL_WRITE_EARLY_DATA 0 -# define SSL_F_SSL_WRITE_EARLY_FINISH 0 -# define SSL_F_SSL_WRITE_EX 0 -# define SSL_F_SSL_WRITE_INTERNAL 0 -# define SSL_F_STATE_MACHINE 0 -# define SSL_F_TLS12_CHECK_PEER_SIGALG 0 -# define SSL_F_TLS12_COPY_SIGALGS 0 -# define SSL_F_TLS13_CHANGE_CIPHER_STATE 0 -# define SSL_F_TLS13_ENC 0 -# define SSL_F_TLS13_FINAL_FINISH_MAC 0 -# define SSL_F_TLS13_GENERATE_SECRET 0 -# define SSL_F_TLS13_HKDF_EXPAND 0 -# define SSL_F_TLS13_RESTORE_HANDSHAKE_DIGEST_FOR_PHA 0 -# define SSL_F_TLS13_SAVE_HANDSHAKE_DIGEST_FOR_PHA 0 -# define SSL_F_TLS13_SETUP_KEY_BLOCK 0 -# define SSL_F_TLS1_CHANGE_CIPHER_STATE 0 -# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS 0 -# define SSL_F_TLS1_ENC 0 -# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL 0 -# define SSL_F_TLS1_GET_CURVELIST 0 -# define SSL_F_TLS1_PRF 0 -# define SSL_F_TLS1_SAVE_U16 0 -# define SSL_F_TLS1_SETUP_KEY_BLOCK 0 -# define SSL_F_TLS1_SET_GROUPS 0 -# define SSL_F_TLS1_SET_RAW_SIGALGS 0 -# define SSL_F_TLS1_SET_SERVER_SIGALGS 0 -# define SSL_F_TLS1_SET_SHARED_SIGALGS 0 -# define SSL_F_TLS1_SET_SIGALGS 0 -# define SSL_F_TLS_CHOOSE_SIGALG 0 -# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK 0 -# define SSL_F_TLS_COLLECT_EXTENSIONS 0 -# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES 0 -# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST 0 -# define SSL_F_TLS_CONSTRUCT_CERT_STATUS 0 -# define SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY 0 -# define SSL_F_TLS_CONSTRUCT_CERT_VERIFY 0 -# define SSL_F_TLS_CONSTRUCT_CHANGE_CIPHER_SPEC 0 -# define SSL_F_TLS_CONSTRUCT_CKE_DHE 0 -# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE 0 -# define SSL_F_TLS_CONSTRUCT_CKE_GOST 0 -# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE 0 -# define SSL_F_TLS_CONSTRUCT_CKE_RSA 0 -# define SSL_F_TLS_CONSTRUCT_CKE_SRP 0 -# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 0 -# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 0 -# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 0 -# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_ALPN 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_CERTIFICATE 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_COOKIE 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_EMS 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_ETM 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_HELLO 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_EXCHANGE 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_SHARE 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_MAXFRAGMENTLEN 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_NPN 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_PADDING 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_POST_HANDSHAKE_AUTH 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_PSK 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_PSK_KEX_MODES 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_RENEGOTIATE 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SCT 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SERVER_NAME 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SESSION_TICKET 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SIG_ALGS 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SRP 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_STATUS_REQUEST 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_VERSIONS 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_USE_SRTP 0 -# define SSL_F_TLS_CONSTRUCT_CTOS_VERIFY 0 -# define SSL_F_TLS_CONSTRUCT_ENCRYPTED_EXTENSIONS 0 -# define SSL_F_TLS_CONSTRUCT_END_OF_EARLY_DATA 0 -# define SSL_F_TLS_CONSTRUCT_EXTENSIONS 0 -# define SSL_F_TLS_CONSTRUCT_FINISHED 0 -# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST 0 -# define SSL_F_TLS_CONSTRUCT_HELLO_RETRY_REQUEST 0 -# define SSL_F_TLS_CONSTRUCT_KEY_UPDATE 0 -# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET 0 -# define SSL_F_TLS_CONSTRUCT_NEXT_PROTO 0 -# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE 0 -# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO 0 -# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_ALPN 0 -# define SSL_F_TLS_CONSTRUCT_STOC_CERTIFICATE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_COOKIE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_CRYPTOPRO_BUG 0 -# define SSL_F_TLS_CONSTRUCT_STOC_DONE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA 0 -# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA_INFO 0 -# define SSL_F_TLS_CONSTRUCT_STOC_EC_PT_FORMATS 0 -# define SSL_F_TLS_CONSTRUCT_STOC_EMS 0 -# define SSL_F_TLS_CONSTRUCT_STOC_ETM 0 -# define SSL_F_TLS_CONSTRUCT_STOC_HELLO 0 -# define SSL_F_TLS_CONSTRUCT_STOC_KEY_EXCHANGE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_KEY_SHARE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_MAXFRAGMENTLEN 0 -# define SSL_F_TLS_CONSTRUCT_STOC_NEXT_PROTO_NEG 0 -# define SSL_F_TLS_CONSTRUCT_STOC_PSK 0 -# define SSL_F_TLS_CONSTRUCT_STOC_RENEGOTIATE 0 -# define SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME 0 -# define SSL_F_TLS_CONSTRUCT_STOC_SESSION_TICKET 0 -# define SSL_F_TLS_CONSTRUCT_STOC_STATUS_REQUEST 0 -# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_GROUPS 0 -# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_VERSIONS 0 -# define SSL_F_TLS_CONSTRUCT_STOC_USE_SRTP 0 -# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO 0 -# define SSL_F_TLS_FINISH_HANDSHAKE 0 -# define SSL_F_TLS_GET_MESSAGE_BODY 0 -# define SSL_F_TLS_GET_MESSAGE_HEADER 0 -# define SSL_F_TLS_HANDLE_ALPN 0 -# define SSL_F_TLS_HANDLE_STATUS_REQUEST 0 -# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES 0 -# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT 0 -# define SSL_F_TLS_PARSE_CTOS_ALPN 0 -# define SSL_F_TLS_PARSE_CTOS_COOKIE 0 -# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA 0 -# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS 0 -# define SSL_F_TLS_PARSE_CTOS_EMS 0 -# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE 0 -# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN 0 -# define SSL_F_TLS_PARSE_CTOS_POST_HANDSHAKE_AUTH 0 -# define SSL_F_TLS_PARSE_CTOS_PSK 0 -# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES 0 -# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE 0 -# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME 0 -# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET 0 -# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS 0 -# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS_CERT 0 -# define SSL_F_TLS_PARSE_CTOS_SRP 0 -# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST 0 -# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS 0 -# define SSL_F_TLS_PARSE_CTOS_USE_SRTP 0 -# define SSL_F_TLS_PARSE_STOC_ALPN 0 -# define SSL_F_TLS_PARSE_STOC_COOKIE 0 -# define SSL_F_TLS_PARSE_STOC_EARLY_DATA 0 -# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO 0 -# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS 0 -# define SSL_F_TLS_PARSE_STOC_KEY_SHARE 0 -# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN 0 -# define SSL_F_TLS_PARSE_STOC_NPN 0 -# define SSL_F_TLS_PARSE_STOC_PSK 0 -# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE 0 -# define SSL_F_TLS_PARSE_STOC_SCT 0 -# define SSL_F_TLS_PARSE_STOC_SERVER_NAME 0 -# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET 0 -# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST 0 -# define SSL_F_TLS_PARSE_STOC_SUPPORTED_VERSIONS 0 -# define SSL_F_TLS_PARSE_STOC_USE_SRTP 0 -# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 0 -# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 0 -# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE 0 -# define SSL_F_TLS_PROCESS_AS_HELLO_RETRY_REQUEST 0 -# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST 0 -# define SSL_F_TLS_PROCESS_CERT_STATUS 0 -# define SSL_F_TLS_PROCESS_CERT_STATUS_BODY 0 -# define SSL_F_TLS_PROCESS_CERT_VERIFY 0 -# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC 0 -# define SSL_F_TLS_PROCESS_CKE_DHE 0 -# define SSL_F_TLS_PROCESS_CKE_ECDHE 0 -# define SSL_F_TLS_PROCESS_CKE_GOST 0 -# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE 0 -# define SSL_F_TLS_PROCESS_CKE_RSA 0 -# define SSL_F_TLS_PROCESS_CKE_SRP 0 -# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE 0 -# define SSL_F_TLS_PROCESS_CLIENT_HELLO 0 -# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE 0 -# define SSL_F_TLS_PROCESS_ENCRYPTED_EXTENSIONS 0 -# define SSL_F_TLS_PROCESS_END_OF_EARLY_DATA 0 -# define SSL_F_TLS_PROCESS_FINISHED 0 -# define SSL_F_TLS_PROCESS_HELLO_REQ 0 -# define SSL_F_TLS_PROCESS_HELLO_RETRY_REQUEST 0 -# define SSL_F_TLS_PROCESS_INITIAL_SERVER_FLIGHT 0 -# define SSL_F_TLS_PROCESS_KEY_EXCHANGE 0 -# define SSL_F_TLS_PROCESS_KEY_UPDATE 0 -# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET 0 -# define SSL_F_TLS_PROCESS_NEXT_PROTO 0 -# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 0 -# define SSL_F_TLS_PROCESS_SERVER_DONE 0 -# define SSL_F_TLS_PROCESS_SERVER_HELLO 0 -# define SSL_F_TLS_PROCESS_SKE_DHE 0 -# define SSL_F_TLS_PROCESS_SKE_ECDHE 0 -# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE 0 -# define SSL_F_TLS_PROCESS_SKE_SRP 0 -# define SSL_F_TLS_PSK_DO_BINDER 0 -# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT 0 -# define SSL_F_TLS_SETUP_HANDSHAKE 0 -# define SSL_F_USE_CERTIFICATE_CHAIN_FILE 0 -# define SSL_F_WPACKET_INTERN_INIT_LEN 0 -# define SSL_F_WPACKET_START_SUB_PACKET_LEN__ 0 -# define SSL_F_WRITE_STATE_MACHINE 0 +# define SSL_F_ADD_CLIENT_KEY_SHARE_EXT 0 +# define SSL_F_ADD_KEY_SHARE 0 +# define SSL_F_BYTES_TO_CIPHER_LIST 0 +# define SSL_F_CHECK_SUITEB_CIPHER_LIST 0 +# define SSL_F_CIPHERSUITE_CB 0 +# define SSL_F_CONSTRUCT_CA_NAMES 0 +# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS 0 +# define SSL_F_CONSTRUCT_STATEFUL_TICKET 0 +# define SSL_F_CONSTRUCT_STATELESS_TICKET 0 +# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH 0 +# define SSL_F_CREATE_TICKET_PREQUEL 0 +# define SSL_F_CT_MOVE_SCTS 0 +# define SSL_F_CT_STRICT 0 +# define SSL_F_CUSTOM_EXT_ADD 0 +# define SSL_F_CUSTOM_EXT_PARSE 0 +# define SSL_F_D2I_SSL_SESSION 0 +# define SSL_F_DANE_CTX_ENABLE 0 +# define SSL_F_DANE_MTYPE_SET 0 +# define SSL_F_DANE_TLSA_ADD 0 +# define SSL_F_DERIVE_SECRET_KEY_AND_IV 0 +# define SSL_F_DO_DTLS1_WRITE 0 +# define SSL_F_DO_SSL3_WRITE 0 +# define SSL_F_DTLS1_BUFFER_RECORD 0 +# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 0 +# define SSL_F_DTLS1_HEARTBEAT 0 +# define SSL_F_DTLS1_HM_FRAGMENT_NEW 0 +# define SSL_F_DTLS1_PREPROCESS_FRAGMENT 0 +# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS 0 +# define SSL_F_DTLS1_PROCESS_RECORD 0 +# define SSL_F_DTLS1_READ_BYTES 0 +# define SSL_F_DTLS1_READ_FAILED 0 +# define SSL_F_DTLS1_RETRANSMIT_MESSAGE 0 +# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 0 +# define SSL_F_DTLS1_WRITE_BYTES 0 +# define SSL_F_DTLSV1_LISTEN 0 +# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC 0 +# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 0 +# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 0 +# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 0 +# define SSL_F_DTLS_RECORD_LAYER_NEW 0 +# define SSL_F_DTLS_WAIT_FOR_DRY 0 +# define SSL_F_EARLY_DATA_COUNT_OK 0 +# define SSL_F_FINAL_EARLY_DATA 0 +# define SSL_F_FINAL_EC_PT_FORMATS 0 +# define SSL_F_FINAL_EMS 0 +# define SSL_F_FINAL_KEY_SHARE 0 +# define SSL_F_FINAL_MAXFRAGMENTLEN 0 +# define SSL_F_FINAL_RENEGOTIATE 0 +# define SSL_F_FINAL_SERVER_NAME 0 +# define SSL_F_FINAL_SIG_ALGS 0 +# define SSL_F_GET_CERT_VERIFY_TBS_DATA 0 +# define SSL_F_NSS_KEYLOG_INT 0 +# define SSL_F_OPENSSL_INIT_SSL 0 +# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_CLIENT13_WRITE_TRANSITION 0 +# define SSL_F_OSSL_STATEM_CLIENT_CONSTRUCT_MESSAGE 0 +# define SSL_F_OSSL_STATEM_CLIENT_POST_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_CLIENT_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_CLIENT_WRITE_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER13_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER13_WRITE_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE 0 +# define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_SERVER_POST_WORK 0 +# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK 0 +# define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE 0 +# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 0 +# define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION 0 +# define SSL_F_PARSE_CA_NAMES 0 +# define SSL_F_PITEM_NEW 0 +# define SSL_F_PQUEUE_NEW 0 +# define SSL_F_PROCESS_KEY_SHARE_EXT 0 +# define SSL_F_READ_STATE_MACHINE 0 +# define SSL_F_SET_CLIENT_CIPHERSUITE 0 +# define SSL_F_SRP_GENERATE_CLIENT_MASTER_SECRET 0 +# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET 0 +# define SSL_F_SRP_VERIFY_SERVER_PARAM 0 +# define SSL_F_SSL3_CHANGE_CIPHER_STATE 0 +# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 0 +# define SSL_F_SSL3_CTRL 0 +# define SSL_F_SSL3_CTX_CTRL 0 +# define SSL_F_SSL3_DIGEST_CACHED_RECORDS 0 +# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 0 +# define SSL_F_SSL3_ENC 0 +# define SSL_F_SSL3_FINAL_FINISH_MAC 0 +# define SSL_F_SSL3_FINISH_MAC 0 +# define SSL_F_SSL3_GENERATE_KEY_BLOCK 0 +# define SSL_F_SSL3_GENERATE_MASTER_SECRET 0 +# define SSL_F_SSL3_GET_RECORD 0 +# define SSL_F_SSL3_INIT_FINISHED_MAC 0 +# define SSL_F_SSL3_OUTPUT_CERT_CHAIN 0 +# define SSL_F_SSL3_READ_BYTES 0 +# define SSL_F_SSL3_READ_N 0 +# define SSL_F_SSL3_SETUP_KEY_BLOCK 0 +# define SSL_F_SSL3_SETUP_READ_BUFFER 0 +# define SSL_F_SSL3_SETUP_WRITE_BUFFER 0 +# define SSL_F_SSL3_WRITE_BYTES 0 +# define SSL_F_SSL3_WRITE_PENDING 0 +# define SSL_F_SSL_ADD_CERT_CHAIN 0 +# define SSL_F_SSL_ADD_CERT_TO_BUF 0 +# define SSL_F_SSL_ADD_CERT_TO_WPACKET 0 +# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT 0 +# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 0 +# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 0 +# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_BAD_METHOD 0 +# define SSL_F_SSL_BUILD_CERT_CHAIN 0 +# define SSL_F_SSL_BYTES_TO_CIPHER_LIST 0 +# define SSL_F_SSL_CACHE_CIPHERLIST 0 +# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT 0 +# define SSL_F_SSL_CERT_DUP 0 +# define SSL_F_SSL_CERT_NEW 0 +# define SSL_F_SSL_CERT_SET0_CHAIN 0 +# define SSL_F_SSL_CHECK_PRIVATE_KEY 0 +# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_CHECK_SRP_EXT_CLIENTHELLO 0 +# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG 0 +# define SSL_F_SSL_CHOOSE_CLIENT_VERSION 0 +# define SSL_F_SSL_CIPHER_DESCRIPTION 0 +# define SSL_F_SSL_CIPHER_LIST_TO_BYTES 0 +# define SSL_F_SSL_CIPHER_PROCESS_RULESTR 0 +# define SSL_F_SSL_CIPHER_STRENGTH_SORT 0 +# define SSL_F_SSL_CLEAR 0 +# define SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT 0 +# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 0 +# define SSL_F_SSL_CONF_CMD 0 +# define SSL_F_SSL_CREATE_CIPHER_LIST 0 +# define SSL_F_SSL_CTRL 0 +# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 0 +# define SSL_F_SSL_CTX_ENABLE_CT 0 +# define SSL_F_SSL_CTX_MAKE_PROFILES 0 +# define SSL_F_SSL_CTX_NEW 0 +# define SSL_F_SSL_CTX_SET_ALPN_PROTOS 0 +# define SSL_F_SSL_CTX_SET_CIPHER_LIST 0 +# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE 0 +# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK 0 +# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 0 +# define SSL_F_SSL_CTX_SET_SSL_VERSION 0 +# define SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH 0 +# define SSL_F_SSL_CTX_USE_CERTIFICATE 0 +# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 0 +# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 0 +# define SSL_F_SSL_CTX_USE_PRIVATEKEY 0 +# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 0 +# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 0 +# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT 0 +# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 0 +# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 0 +# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 0 +# define SSL_F_SSL_CTX_USE_SERVERINFO 0 +# define SSL_F_SSL_CTX_USE_SERVERINFO_EX 0 +# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE 0 +# define SSL_F_SSL_DANE_DUP 0 +# define SSL_F_SSL_DANE_ENABLE 0 +# define SSL_F_SSL_DERIVE 0 +# define SSL_F_SSL_DO_CONFIG 0 +# define SSL_F_SSL_DO_HANDSHAKE 0 +# define SSL_F_SSL_DUP_CA_LIST 0 +# define SSL_F_SSL_ENABLE_CT 0 +# define SSL_F_SSL_GENERATE_PKEY_GROUP 0 +# define SSL_F_SSL_GENERATE_SESSION_ID 0 +# define SSL_F_SSL_GET_NEW_SESSION 0 +# define SSL_F_SSL_GET_PREV_SESSION 0 +# define SSL_F_SSL_GET_SERVER_CERT_INDEX 0 +# define SSL_F_SSL_GET_SIGN_PKEY 0 +# define SSL_F_SSL_HANDSHAKE_HASH 0 +# define SSL_F_SSL_INIT_WBIO_BUFFER 0 +# define SSL_F_SSL_KEY_UPDATE 0 +# define SSL_F_SSL_LOAD_CLIENT_CA_FILE 0 +# define SSL_F_SSL_LOG_MASTER_SECRET 0 +# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_SSL_MODULE_INIT 0 +# define SSL_F_SSL_NEW 0 +# define SSL_F_SSL_NEXT_PROTO_VALIDATE 0 +# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT 0 +# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT 0 +# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT 0 +# define SSL_F_SSL_PEEK 0 +# define SSL_F_SSL_PEEK_EX 0 +# define SSL_F_SSL_PEEK_INTERNAL 0 +# define SSL_F_SSL_READ 0 +# define SSL_F_SSL_READ_EARLY_DATA 0 +# define SSL_F_SSL_READ_EX 0 +# define SSL_F_SSL_READ_INTERNAL 0 +# define SSL_F_SSL_RENEGOTIATE 0 +# define SSL_F_SSL_RENEGOTIATE_ABBREVIATED 0 +# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT 0 +# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT 0 +# define SSL_F_SSL_SESSION_DUP 0 +# define SSL_F_SSL_SESSION_NEW 0 +# define SSL_F_SSL_SESSION_PRINT_FP 0 +# define SSL_F_SSL_SESSION_SET1_ID 0 +# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT 0 +# define SSL_F_SSL_SET_ALPN_PROTOS 0 +# define SSL_F_SSL_SET_CERT 0 +# define SSL_F_SSL_SET_CERT_AND_KEY 0 +# define SSL_F_SSL_SET_CIPHER_LIST 0 +# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK 0 +# define SSL_F_SSL_SET_FD 0 +# define SSL_F_SSL_SET_PKEY 0 +# define SSL_F_SSL_SET_RFD 0 +# define SSL_F_SSL_SET_SESSION 0 +# define SSL_F_SSL_SET_SESSION_ID_CONTEXT 0 +# define SSL_F_SSL_SET_SESSION_TICKET_EXT 0 +# define SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH 0 +# define SSL_F_SSL_SET_WFD 0 +# define SSL_F_SSL_SHUTDOWN 0 +# define SSL_F_SSL_SRP_CTX_INIT 0 +# define SSL_F_SSL_START_ASYNC_JOB 0 +# define SSL_F_SSL_UNDEFINED_FUNCTION 0 +# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 0 +# define SSL_F_SSL_USE_CERTIFICATE 0 +# define SSL_F_SSL_USE_CERTIFICATE_ASN1 0 +# define SSL_F_SSL_USE_CERTIFICATE_FILE 0 +# define SSL_F_SSL_USE_PRIVATEKEY 0 +# define SSL_F_SSL_USE_PRIVATEKEY_ASN1 0 +# define SSL_F_SSL_USE_PRIVATEKEY_FILE 0 +# define SSL_F_SSL_USE_PSK_IDENTITY_HINT 0 +# define SSL_F_SSL_USE_RSAPRIVATEKEY 0 +# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 0 +# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 0 +# define SSL_F_SSL_VALIDATE_CT 0 +# define SSL_F_SSL_VERIFY_CERT_CHAIN 0 +# define SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE 0 +# define SSL_F_SSL_WRITE 0 +# define SSL_F_SSL_WRITE_EARLY_DATA 0 +# define SSL_F_SSL_WRITE_EARLY_FINISH 0 +# define SSL_F_SSL_WRITE_EX 0 +# define SSL_F_SSL_WRITE_INTERNAL 0 +# define SSL_F_STATE_MACHINE 0 +# define SSL_F_TLS12_CHECK_PEER_SIGALG 0 +# define SSL_F_TLS12_COPY_SIGALGS 0 +# define SSL_F_TLS13_CHANGE_CIPHER_STATE 0 +# define SSL_F_TLS13_ENC 0 +# define SSL_F_TLS13_FINAL_FINISH_MAC 0 +# define SSL_F_TLS13_GENERATE_SECRET 0 +# define SSL_F_TLS13_HKDF_EXPAND 0 +# define SSL_F_TLS13_RESTORE_HANDSHAKE_DIGEST_FOR_PHA 0 +# define SSL_F_TLS13_SAVE_HANDSHAKE_DIGEST_FOR_PHA 0 +# define SSL_F_TLS13_SETUP_KEY_BLOCK 0 +# define SSL_F_TLS1_CHANGE_CIPHER_STATE 0 +# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS 0 +# define SSL_F_TLS1_ENC 0 +# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL 0 +# define SSL_F_TLS1_GET_CURVELIST 0 +# define SSL_F_TLS1_PRF 0 +# define SSL_F_TLS1_SAVE_U16 0 +# define SSL_F_TLS1_SETUP_KEY_BLOCK 0 +# define SSL_F_TLS1_SET_GROUPS 0 +# define SSL_F_TLS1_SET_RAW_SIGALGS 0 +# define SSL_F_TLS1_SET_SERVER_SIGALGS 0 +# define SSL_F_TLS1_SET_SHARED_SIGALGS 0 +# define SSL_F_TLS1_SET_SIGALGS 0 +# define SSL_F_TLS_CHOOSE_SIGALG 0 +# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK 0 +# define SSL_F_TLS_COLLECT_EXTENSIONS 0 +# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES 0 +# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_CERT_STATUS 0 +# define SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY 0 +# define SSL_F_TLS_CONSTRUCT_CERT_VERIFY 0 +# define SSL_F_TLS_CONSTRUCT_CHANGE_CIPHER_SPEC 0 +# define SSL_F_TLS_CONSTRUCT_CKE_DHE 0 +# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE 0 +# define SSL_F_TLS_CONSTRUCT_CKE_GOST 0 +# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE 0 +# define SSL_F_TLS_CONSTRUCT_CKE_RSA 0 +# define SSL_F_TLS_CONSTRUCT_CKE_SRP 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_ALPN 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_COOKIE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_EMS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_ETM 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_SHARE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_NPN 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_PADDING 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_POST_HANDSHAKE_AUTH 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_PSK 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_PSK_KEX_MODES 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_RENEGOTIATE 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SCT 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SERVER_NAME 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SESSION_TICKET 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SIG_ALGS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SRP 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_STATUS_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_VERSIONS 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_USE_SRTP 0 +# define SSL_F_TLS_CONSTRUCT_CTOS_VERIFY 0 +# define SSL_F_TLS_CONSTRUCT_ENCRYPTED_EXTENSIONS 0 +# define SSL_F_TLS_CONSTRUCT_END_OF_EARLY_DATA 0 +# define SSL_F_TLS_CONSTRUCT_EXTENSIONS 0 +# define SSL_F_TLS_CONSTRUCT_FINISHED 0 +# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_HELLO_RETRY_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_KEY_UPDATE 0 +# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET 0 +# define SSL_F_TLS_CONSTRUCT_NEXT_PROTO 0 +# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_ALPN 0 +# define SSL_F_TLS_CONSTRUCT_STOC_CERTIFICATE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_COOKIE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_CRYPTOPRO_BUG 0 +# define SSL_F_TLS_CONSTRUCT_STOC_DONE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA_INFO 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EC_PT_FORMATS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_EMS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_ETM 0 +# define SSL_F_TLS_CONSTRUCT_STOC_HELLO 0 +# define SSL_F_TLS_CONSTRUCT_STOC_KEY_EXCHANGE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_KEY_SHARE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_CONSTRUCT_STOC_NEXT_PROTO_NEG 0 +# define SSL_F_TLS_CONSTRUCT_STOC_PSK 0 +# define SSL_F_TLS_CONSTRUCT_STOC_RENEGOTIATE 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SESSION_TICKET 0 +# define SSL_F_TLS_CONSTRUCT_STOC_STATUS_REQUEST 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_GROUPS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_VERSIONS 0 +# define SSL_F_TLS_CONSTRUCT_STOC_USE_SRTP 0 +# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO 0 +# define SSL_F_TLS_FINISH_HANDSHAKE 0 +# define SSL_F_TLS_GET_MESSAGE_BODY 0 +# define SSL_F_TLS_GET_MESSAGE_HEADER 0 +# define SSL_F_TLS_HANDLE_ALPN 0 +# define SSL_F_TLS_HANDLE_STATUS_REQUEST 0 +# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES 0 +# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT 0 +# define SSL_F_TLS_PARSE_CTOS_ALPN 0 +# define SSL_F_TLS_PARSE_CTOS_COOKIE 0 +# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA 0 +# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS 0 +# define SSL_F_TLS_PARSE_CTOS_EMS 0 +# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE 0 +# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_PARSE_CTOS_POST_HANDSHAKE_AUTH 0 +# define SSL_F_TLS_PARSE_CTOS_PSK 0 +# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES 0 +# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE 0 +# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME 0 +# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET 0 +# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS 0 +# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS_CERT 0 +# define SSL_F_TLS_PARSE_CTOS_SRP 0 +# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST 0 +# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS 0 +# define SSL_F_TLS_PARSE_CTOS_USE_SRTP 0 +# define SSL_F_TLS_PARSE_STOC_ALPN 0 +# define SSL_F_TLS_PARSE_STOC_COOKIE 0 +# define SSL_F_TLS_PARSE_STOC_EARLY_DATA 0 +# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO 0 +# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS 0 +# define SSL_F_TLS_PARSE_STOC_KEY_SHARE 0 +# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN 0 +# define SSL_F_TLS_PARSE_STOC_NPN 0 +# define SSL_F_TLS_PARSE_STOC_PSK 0 +# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE 0 +# define SSL_F_TLS_PARSE_STOC_SCT 0 +# define SSL_F_TLS_PARSE_STOC_SERVER_NAME 0 +# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET 0 +# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST 0 +# define SSL_F_TLS_PARSE_STOC_SUPPORTED_VERSIONS 0 +# define SSL_F_TLS_PARSE_STOC_USE_SRTP 0 +# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 0 +# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE 0 +# define SSL_F_TLS_PROCESS_AS_HELLO_RETRY_REQUEST 0 +# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST 0 +# define SSL_F_TLS_PROCESS_CERT_STATUS 0 +# define SSL_F_TLS_PROCESS_CERT_STATUS_BODY 0 +# define SSL_F_TLS_PROCESS_CERT_VERIFY 0 +# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC 0 +# define SSL_F_TLS_PROCESS_CKE_DHE 0 +# define SSL_F_TLS_PROCESS_CKE_ECDHE 0 +# define SSL_F_TLS_PROCESS_CKE_GOST 0 +# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE 0 +# define SSL_F_TLS_PROCESS_CKE_RSA 0 +# define SSL_F_TLS_PROCESS_CKE_SRP 0 +# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE 0 +# define SSL_F_TLS_PROCESS_CLIENT_HELLO 0 +# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE 0 +# define SSL_F_TLS_PROCESS_ENCRYPTED_EXTENSIONS 0 +# define SSL_F_TLS_PROCESS_END_OF_EARLY_DATA 0 +# define SSL_F_TLS_PROCESS_FINISHED 0 +# define SSL_F_TLS_PROCESS_HELLO_REQ 0 +# define SSL_F_TLS_PROCESS_HELLO_RETRY_REQUEST 0 +# define SSL_F_TLS_PROCESS_INITIAL_SERVER_FLIGHT 0 +# define SSL_F_TLS_PROCESS_KEY_EXCHANGE 0 +# define SSL_F_TLS_PROCESS_KEY_UPDATE 0 +# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET 0 +# define SSL_F_TLS_PROCESS_NEXT_PROTO 0 +# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 0 +# define SSL_F_TLS_PROCESS_SERVER_DONE 0 +# define SSL_F_TLS_PROCESS_SERVER_HELLO 0 +# define SSL_F_TLS_PROCESS_SKE_DHE 0 +# define SSL_F_TLS_PROCESS_SKE_ECDHE 0 +# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE 0 +# define SSL_F_TLS_PROCESS_SKE_SRP 0 +# define SSL_F_TLS_PSK_DO_BINDER 0 +# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT 0 +# define SSL_F_TLS_SETUP_HANDSHAKE 0 +# define SSL_F_USE_CERTIFICATE_CHAIN_FILE 0 +# define SSL_F_WPACKET_INTERN_INIT_LEN 0 +# define SSL_F_WPACKET_START_SUB_PACKET_LEN__ 0 +# define SSL_F_WRITE_STATE_MACHINE 0 #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/stack.h b/libs/OpenSSL/include/openssl/stack.h index 08e5cd26..168183a5 100644 --- a/libs/OpenSSL/include/openssl/stack.h +++ b/libs/OpenSSL/include/openssl/stack.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_STACK_H +# define HEADER_STACK_H #endif #ifdef __cplusplus @@ -37,7 +37,8 @@ OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n); int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n); void OPENSSL_sk_free(OPENSSL_STACK *); void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func)(void *)); -OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, OPENSSL_sk_copyfunc c, +OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, + OPENSSL_sk_copyfunc c, OPENSSL_sk_freefunc f); int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where); void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); @@ -50,35 +51,36 @@ int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data); void *OPENSSL_sk_shift(OPENSSL_STACK *st); void *OPENSSL_sk_pop(OPENSSL_STACK *st); void OPENSSL_sk_zero(OPENSSL_STACK *st); -OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, OPENSSL_sk_compfunc cmp); +OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, + OPENSSL_sk_compfunc cmp); OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st); void OPENSSL_sk_sort(OPENSSL_STACK *st); int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define _STACK OPENSSL_STACK -# define sk_num OPENSSL_sk_num -# define sk_value OPENSSL_sk_value -# define sk_set OPENSSL_sk_set -# define sk_new OPENSSL_sk_new -# define sk_new_null OPENSSL_sk_new_null -# define sk_free OPENSSL_sk_free -# define sk_pop_free OPENSSL_sk_pop_free -# define sk_deep_copy OPENSSL_sk_deep_copy -# define sk_insert OPENSSL_sk_insert -# define sk_delete OPENSSL_sk_delete -# define sk_delete_ptr OPENSSL_sk_delete_ptr -# define sk_find OPENSSL_sk_find -# define sk_find_ex OPENSSL_sk_find_ex -# define sk_push OPENSSL_sk_push -# define sk_unshift OPENSSL_sk_unshift -# define sk_shift OPENSSL_sk_shift -# define sk_pop OPENSSL_sk_pop -# define sk_zero OPENSSL_sk_zero -# define sk_set_cmp_func OPENSSL_sk_set_cmp_func -# define sk_dup OPENSSL_sk_dup -# define sk_sort OPENSSL_sk_sort -# define sk_is_sorted OPENSSL_sk_is_sorted +# define _STACK OPENSSL_STACK +# define sk_num OPENSSL_sk_num +# define sk_value OPENSSL_sk_value +# define sk_set OPENSSL_sk_set +# define sk_new OPENSSL_sk_new +# define sk_new_null OPENSSL_sk_new_null +# define sk_free OPENSSL_sk_free +# define sk_pop_free OPENSSL_sk_pop_free +# define sk_deep_copy OPENSSL_sk_deep_copy +# define sk_insert OPENSSL_sk_insert +# define sk_delete OPENSSL_sk_delete +# define sk_delete_ptr OPENSSL_sk_delete_ptr +# define sk_find OPENSSL_sk_find +# define sk_find_ex OPENSSL_sk_find_ex +# define sk_push OPENSSL_sk_push +# define sk_unshift OPENSSL_sk_unshift +# define sk_shift OPENSSL_sk_shift +# define sk_pop OPENSSL_sk_pop +# define sk_zero OPENSSL_sk_zero +# define sk_set_cmp_func OPENSSL_sk_set_cmp_func +# define sk_dup OPENSSL_sk_dup +# define sk_sort OPENSSL_sk_sort +# define sk_is_sorted OPENSSL_sk_is_sorted #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/store.h b/libs/OpenSSL/include/openssl/store.h index 70e16900..268a9470 100644 --- a/libs/OpenSSL/include/openssl/store.h +++ b/libs/OpenSSL/include/openssl/store.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_OSSL_STORE_H +# define HEADER_OSSL_STORE_H #endif #include @@ -41,7 +41,8 @@ typedef struct ossl_store_ctx_st OSSL_STORE_CTX; * to massage the given OSSL_STORE_INFO, or to drop it entirely (by returning * NULL). */ -typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *, void *); +typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *, + void *); /* * Open a channel given a URI. The given UI method will be used any time the @@ -51,10 +52,12 @@ typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *, v * Returns a context reference which represents the channel to communicate * through. */ -OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method, void *ui_data, +OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method, + void *ui_data, OSSL_STORE_post_process_info_fn post_process, void *post_process_data); -OSSL_STORE_CTX *OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, +OSSL_STORE_CTX *OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, + const char *propq, const UI_METHOD *ui_method, void *ui_data, const OSSL_PARAM params[], OSSL_STORE_post_process_info_fn post_process, @@ -67,8 +70,10 @@ OSSL_STORE_CTX *OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const * Each command takes different arguments. */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */); -OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, va_list args); +OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, + ... /* args */); +OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, + va_list args); #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 @@ -77,9 +82,9 @@ OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, va_list * Common ctrl commands that different loaders may choose to support. */ /* int on = 0 or 1; STORE_ctrl(ctx, STORE_C_USE_SECMEM, &on); */ -# define OSSL_STORE_C_USE_SECMEM 1 +# define OSSL_STORE_C_USE_SECMEM 1 /* Where custom commands start */ -# define OSSL_STORE_C_CUSTOM_START 100 +# define OSSL_STORE_C_CUSTOM_START 100 #endif @@ -124,8 +129,9 @@ int OSSL_STORE_close(OSSL_STORE_CTX *ctx); * Note that this function is considered unsafe, all depending on what the * BIO actually reads. */ -OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bio, const char *scheme, OSSL_LIB_CTX *libctx, - const char *propq, const UI_METHOD *ui_method, void *ui_data, +OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bio, const char *scheme, + OSSL_LIB_CTX *libctx, const char *propq, + const UI_METHOD *ui_method, void *ui_data, const OSSL_PARAM params[], OSSL_STORE_post_process_info_fn post_process, void *post_process_data); @@ -140,12 +146,12 @@ OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bio, const char *scheme, OSSL_LIB_CTX *li * OSSL_STORE_INFO_NAME is typically found when getting a listing of * available "files" / "tokens" / what have you. */ -#define OSSL_STORE_INFO_NAME 1 /* char * */ +#define OSSL_STORE_INFO_NAME 1 /* char * */ #define OSSL_STORE_INFO_PARAMS 2 /* EVP_PKEY * */ #define OSSL_STORE_INFO_PUBKEY 3 /* EVP_PKEY * */ -#define OSSL_STORE_INFO_PKEY 4 /* EVP_PKEY * */ -#define OSSL_STORE_INFO_CERT 5 /* X509 * */ -#define OSSL_STORE_INFO_CRL 6 /* X509_CRL * */ +#define OSSL_STORE_INFO_PKEY 4 /* EVP_PKEY * */ +#define OSSL_STORE_INFO_CERT 5 /* X509 * */ +#define OSSL_STORE_INFO_CRL 6 /* X509_CRL * */ /* * Functions to generate OSSL_STORE_INFOs, one function for each type we @@ -210,9 +216,11 @@ int OSSL_STORE_supports_search(OSSL_STORE_CTX *ctx, int search_type); * remain present throughout the lifetime of the returned OSSL_STORE_SEARCH */ OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_name(X509_NAME *name); -OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name, const ASN1_INTEGER *serial); -OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest, - const unsigned char *bytes, size_t len); +OSSL_STORE_SEARCH * +OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name, const ASN1_INTEGER *serial); +OSSL_STORE_SEARCH * +OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest, + const unsigned char *bytes, size_t len); OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_alias(const char *alias); /* Search term destructor */ @@ -221,9 +229,11 @@ void OSSL_STORE_SEARCH_free(OSSL_STORE_SEARCH *search); /* Search term accessors */ int OSSL_STORE_SEARCH_get_type(const OSSL_STORE_SEARCH *criterion); X509_NAME *OSSL_STORE_SEARCH_get0_name(const OSSL_STORE_SEARCH *criterion); -const ASN1_INTEGER *OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH *criterion); -const unsigned char *OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH *criterion, - size_t *length); +const ASN1_INTEGER * +OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH *criterion); +const unsigned char * +OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH *criterion, + size_t *length); const char *OSSL_STORE_SEARCH_get0_string(const OSSL_STORE_SEARCH *criterion); const EVP_MD *OSSL_STORE_SEARCH_get0_digest(const OSSL_STORE_SEARCH *criterion); @@ -241,18 +251,23 @@ int OSSL_STORE_find(OSSL_STORE_CTX *ctx, const OSSL_STORE_SEARCH *search); typedef struct ossl_store_loader_st OSSL_STORE_LOADER; -OSSL_STORE_LOADER *OSSL_STORE_LOADER_fetch(OSSL_LIB_CTX *libctx, const char *scheme, +OSSL_STORE_LOADER *OSSL_STORE_LOADER_fetch(OSSL_LIB_CTX *libctx, + const char *scheme, const char *properties); int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader); void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader); -const OSSL_PROVIDER *OSSL_STORE_LOADER_get0_provider(const OSSL_STORE_LOADER *loader); +const OSSL_PROVIDER * +OSSL_STORE_LOADER_get0_provider(const OSSL_STORE_LOADER *loader); const char *OSSL_STORE_LOADER_get0_properties(const OSSL_STORE_LOADER *loader); const char *OSSL_STORE_LOADER_get0_description(const OSSL_STORE_LOADER *loader); int OSSL_STORE_LOADER_is_a(const OSSL_STORE_LOADER *loader, const char *scheme); void OSSL_STORE_LOADER_do_all_provided(OSSL_LIB_CTX *libctx, - void (*fn)(OSSL_STORE_LOADER *loader, void *arg), void *arg); + void (*fn)(OSSL_STORE_LOADER *loader, + void *arg), + void *arg); int OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader, - void (*fn)(const char *name, void *data), void *data); + void (*fn)(const char *name, void *data), + void *data); /*- * Function to register a loader for the given URI scheme. @@ -266,22 +281,24 @@ int OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader, /* struct ossl_store_loader_ctx_st is defined differently by each loader */ typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX; -typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(const OSSL_STORE_LOADER *loader, - const char *uri, const UI_METHOD *ui_method, - void *ui_data); -typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_ex_fn)(const OSSL_STORE_LOADER *loader, - const char *uri, OSSL_LIB_CTX *libctx, - const char *propq, - const UI_METHOD *ui_method, void *ui_data); +typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)( + const OSSL_STORE_LOADER *loader, const char *uri, + const UI_METHOD *ui_method, void *ui_data); +typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_ex_fn)( + const OSSL_STORE_LOADER *loader, const char *uri, OSSL_LIB_CTX *libctx, + const char *propq, const UI_METHOD *ui_method, void *ui_data); -typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn)(const OSSL_STORE_LOADER *loader, BIO *bio, - OSSL_LIB_CTX *libctx, const char *propq, - const UI_METHOD *ui_method, void *ui_data); -typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd, va_list args); +typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn)( + const OSSL_STORE_LOADER *loader, BIO *bio, OSSL_LIB_CTX *libctx, + const char *propq, const UI_METHOD *ui_method, void *ui_data); +typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd, + va_list args); typedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected); -typedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx, const OSSL_STORE_SEARCH *criteria); +typedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx, + const OSSL_STORE_SEARCH *criteria); typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx, - const UI_METHOD *ui_method, void *ui_data); + const UI_METHOD *ui_method, + void *ui_data); typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx); typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx); typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx); @@ -291,26 +308,35 @@ typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx); OSSL_DEPRECATEDIN_3_0 OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader, OSSL_STORE_open_fn open_function); +int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader, + OSSL_STORE_open_fn open_function); OSSL_DEPRECATEDIN_3_0 int OSSL_STORE_LOADER_set_open_ex(OSSL_STORE_LOADER *loader, OSSL_STORE_open_ex_fn open_ex_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader, OSSL_STORE_attach_fn attach_function); +int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader, + OSSL_STORE_attach_fn attach_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *loader, OSSL_STORE_ctrl_fn ctrl_function); +int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *loader, + OSSL_STORE_ctrl_fn ctrl_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader, OSSL_STORE_expect_fn expect_function); +int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader, + OSSL_STORE_expect_fn expect_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader, OSSL_STORE_find_fn find_function); +int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader, + OSSL_STORE_find_fn find_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *loader, OSSL_STORE_load_fn load_function); +int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *loader, + OSSL_STORE_load_fn load_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *loader, OSSL_STORE_eof_fn eof_function); +int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *loader, + OSSL_STORE_eof_fn eof_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader, OSSL_STORE_error_fn error_function); +int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader, + OSSL_STORE_error_fn error_function); OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader, OSSL_STORE_close_fn close_function); +int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader, + OSSL_STORE_close_fn close_function); OSSL_DEPRECATEDIN_3_0 const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader); OSSL_DEPRECATEDIN_3_0 @@ -327,8 +353,9 @@ OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme); */ #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -int OSSL_STORE_do_all_loaders(void (*do_function)(const OSSL_STORE_LOADER *loader, void *do_arg), - void *do_arg); +int OSSL_STORE_do_all_loaders( + void (*do_function)(const OSSL_STORE_LOADER *loader, void *do_arg), + void *do_arg); #endif #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/symhacks.h b/libs/OpenSSL/include/openssl/symhacks.h index fdef8cfc..b7a0ab0f 100644 --- a/libs/OpenSSL/include/openssl/symhacks.h +++ b/libs/OpenSSL/include/openssl/symhacks.h @@ -13,26 +13,26 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_SYMHACKS_H +# define HEADER_SYMHACKS_H #endif #include /* Case insensitive linking causes problems.... */ #if defined(OPENSSL_SYS_VMS) -# undef ERR_load_CRYPTO_strings -# define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings -# undef OCSP_crlID_new -# define OCSP_crlID_new OCSP_crlID2_new +# undef ERR_load_CRYPTO_strings +# define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings +# undef OCSP_crlID_new +# define OCSP_crlID_new OCSP_crlID2_new -# undef d2i_ECPARAMETERS -# define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS -# undef i2d_ECPARAMETERS -# define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS -# undef d2i_ECPKPARAMETERS -# define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS -# undef i2d_ECPKPARAMETERS -# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS +# undef d2i_ECPARAMETERS +# define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS +# undef i2d_ECPARAMETERS +# define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS +# undef d2i_ECPKPARAMETERS +# define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS +# undef i2d_ECPKPARAMETERS +# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS #endif diff --git a/libs/OpenSSL/include/openssl/tls1.h b/libs/OpenSSL/include/openssl/tls1.h index 27764d6f..12c47d18 100644 --- a/libs/OpenSSL/include/openssl/tls1.h +++ b/libs/OpenSSL/include/openssl/tls1.h @@ -15,7 +15,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_TLS1_H +# define HEADER_TLS1_H #endif #include @@ -28,12 +28,12 @@ extern "C" { /* Default security level if not overridden at config time */ #ifndef OPENSSL_TLS_SECURITY_LEVEL -# define OPENSSL_TLS_SECURITY_LEVEL 2 +# define OPENSSL_TLS_SECURITY_LEVEL 2 #endif /* TLS*_VERSION constants are defined in prov_ssl.h */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define TLS_MAX_VERSION TLS1_3_VERSION +# define TLS_MAX_VERSION TLS1_3_VERSION #endif /* Special value for method supporting multiple versions */ @@ -48,26 +48,28 @@ extern "C" { #define TLS1_2_VERSION_MAJOR 0x03 #define TLS1_2_VERSION_MINOR 0x03 -#define TLS1_get_version(s) ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0) +#define TLS1_get_version(s) \ + ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0) -#define TLS1_get_client_version(s) \ - ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0) +#define TLS1_get_client_version(s) \ + ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) \ + : 0) #define TLS1_AD_DECRYPTION_FAILED 21 #define TLS1_AD_RECORD_OVERFLOW 22 -#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ +#define TLS1_AD_UNKNOWN_CA 48 /* fatal */ #define TLS1_AD_ACCESS_DENIED 49 /* fatal */ -#define TLS1_AD_DECODE_ERROR 50 /* fatal */ +#define TLS1_AD_DECODE_ERROR 50 /* fatal */ #define TLS1_AD_DECRYPT_ERROR 51 -#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ -#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ -#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ -#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ +#define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ +#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ +#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ +#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ #define TLS1_AD_INAPPROPRIATE_FALLBACK 86 /* fatal */ #define TLS1_AD_USER_CANCELLED 90 #define TLS1_AD_NO_RENEGOTIATION 100 /* TLSv1.3 alerts */ -#define TLS13_AD_MISSING_EXTENSION 109 /* fatal */ +#define TLS13_AD_MISSING_EXTENSION 109 /* fatal */ #define TLS13_AD_CERTIFICATE_REQUIRED 116 /* fatal */ /* codes 110-114 are from RFC3546 */ #define TLS1_AD_UNSUPPORTED_EXTENSION 110 @@ -75,7 +77,7 @@ extern "C" { #define TLS1_AD_UNRECOGNIZED_NAME 112 #define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113 #define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114 -#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */ +#define TLS1_AD_UNKNOWN_PSK_IDENTITY 115 /* fatal */ #define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */ /* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */ @@ -154,7 +156,7 @@ extern "C" { #ifndef OPENSSL_NO_NEXTPROTONEG /* This is not an IANA defined extension number */ -# define TLSEXT_TYPE_next_proto_neg 13172 +# define TLSEXT_TYPE_next_proto_neg 13172 #endif /* NameType value from RFC3546 */ @@ -202,7 +204,8 @@ extern "C" { #define TLSEXT_comp_cert_zlib 1 #define TLSEXT_comp_cert_brotli 2 #define TLSEXT_comp_cert_zstd 3 -/* one more than the number of defined values - used as size of 0-terminated array */ +/* one more than the number of defined values - used as size of 0-terminated + * array */ #define TLSEXT_comp_cert_limit 4 /* Flag set for unrecognised algorithms */ @@ -235,9 +238,10 @@ __owur int SSL_get_servername_type(const SSL *s); * flag controls whether a context is included.) It returns 1 on success and * 0 or -1 otherwise. */ -__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, - size_t llen, const unsigned char *context, size_t contextlen, - int use_context); +__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, + const char *label, size_t llen, + const unsigned char *context, + size_t contextlen, int use_context); /* * SSL_export_keying_material_early exports a value derived from the @@ -246,91 +250,101 @@ __owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, c * |olen| bytes to |out| given a label and optional context. It * returns 1 on success and 0 otherwise. */ -__owur int SSL_export_keying_material_early(SSL *s, unsigned char *out, size_t olen, - const char *label, size_t llen, - const unsigned char *context, size_t contextlen); +__owur int SSL_export_keying_material_early(SSL *s, unsigned char *out, + size_t olen, const char *label, + size_t llen, + const unsigned char *context, + size_t contextlen); int SSL_get_peer_signature_type_nid(const SSL *s, int *pnid); int SSL_get_signature_type_nid(const SSL *s, int *pnid); -int SSL_get_sigalgs(SSL *s, int idx, int *psign, int *phash, int *psignandhash, unsigned char *rsig, - unsigned char *rhash); +int SSL_get_sigalgs(SSL *s, int idx, int *psign, int *phash, int *psignandhash, + unsigned char *rsig, unsigned char *rhash); -int SSL_get_shared_sigalgs(SSL *s, int idx, int *psign, int *phash, int *psignandhash, - unsigned char *rsig, unsigned char *rhash); +int SSL_get_shared_sigalgs(SSL *s, int idx, int *psign, int *phash, + int *psignandhash, unsigned char *rsig, + unsigned char *rhash); -__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) * chain); +__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, + STACK_OF(X509) * chain); -#define SSL_set_tlsext_host_name(s, name) \ - SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, (void *)name) +#define SSL_set_tlsext_host_name(s, name) \ + SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, \ + (void *)name) -#define SSL_set_tlsext_debug_callback(ssl, cb) \ - SSL_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_DEBUG_CB, (void (*)(void))cb) +#define SSL_set_tlsext_debug_callback(ssl, cb) \ + SSL_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_DEBUG_CB, (void (*)(void))cb) -#define SSL_set_tlsext_debug_arg(ssl, arg) SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_DEBUG_ARG, 0, arg) +#define SSL_set_tlsext_debug_arg(ssl, arg) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_DEBUG_ARG, 0, arg) -#define SSL_get_tlsext_status_type(ssl) SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE, 0, NULL) +#define SSL_get_tlsext_status_type(ssl) \ + SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE, 0, NULL) -#define SSL_set_tlsext_status_type(ssl, type) \ - SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, type, NULL) +#define SSL_set_tlsext_status_type(ssl, type) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, type, NULL) -#define SSL_get_tlsext_status_exts(ssl, arg) \ - SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS, 0, arg) +#define SSL_get_tlsext_status_exts(ssl, arg) \ + SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS, 0, arg) -#define SSL_set_tlsext_status_exts(ssl, arg) \ - SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS, 0, arg) +#define SSL_set_tlsext_status_exts(ssl, arg) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS, 0, arg) -#define SSL_get_tlsext_status_ids(ssl, arg) \ - SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS, 0, arg) +#define SSL_get_tlsext_status_ids(ssl, arg) \ + SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS, 0, arg) -#define SSL_set_tlsext_status_ids(ssl, arg) \ - SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS, 0, arg) +#define SSL_set_tlsext_status_ids(ssl, arg) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS, 0, arg) -#define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \ - SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP, 0, arg) +#define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \ + SSL_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP, 0, arg) -#define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \ - SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP, arglen, arg) +#define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \ + SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP, arglen, arg) -#define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \ - SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, (void (*)(void))cb) +#define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \ + SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, \ + (void (*)(void))cb) #define SSL_TLSEXT_ERR_OK 0 #define SSL_TLSEXT_ERR_ALERT_WARNING 1 #define SSL_TLSEXT_ERR_ALERT_FATAL 2 #define SSL_TLSEXT_ERR_NOACK 3 -#define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, 0, arg) +#define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, 0, arg) -#define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_TLSEXT_TICKET_KEYS, keylen, keys) -#define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_TICKET_KEYS, keylen, keys) +#define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_GET_TLSEXT_TICKET_KEYS, keylen, keys) +#define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ + SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_TICKET_KEYS, keylen, keys) -#define SSL_CTX_get_tlsext_status_cb(ssl, cb) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB, 0, (void *)cb) -#define SSL_CTX_set_tlsext_status_cb(ssl, cb) \ - SSL_CTX_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB, (void (*)(void))cb) +#define SSL_CTX_get_tlsext_status_cb(ssl, cb) \ + SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB, 0, (void *)cb) +#define SSL_CTX_set_tlsext_status_cb(ssl, cb) \ + SSL_CTX_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB, \ + (void (*)(void))cb) -#define SSL_CTX_get_tlsext_status_arg(ssl, arg) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg) -#define SSL_CTX_set_tlsext_status_arg(ssl, arg) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg) +#define SSL_CTX_get_tlsext_status_arg(ssl, arg) \ + SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg) +#define SSL_CTX_set_tlsext_status_arg(ssl, arg) \ + SSL_CTX_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg) -#define SSL_CTX_set_tlsext_status_type(ssl, type) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, type, NULL) +#define SSL_CTX_set_tlsext_status_type(ssl, type) \ + SSL_CTX_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, type, NULL) -#define SSL_CTX_get_tlsext_status_type(ssl) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE, 0, NULL) +#define SSL_CTX_get_tlsext_status_type(ssl) \ + SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE, 0, NULL) #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \ - SSL_CTX_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB, (void (*)(void))cb) +# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \ + SSL_CTX_callback_ctrl(ssl, SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB, \ + (void (*)(void))cb) #endif -int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, - int (*fp)(SSL *, unsigned char *, unsigned char *, - EVP_CIPHER_CTX *, EVP_MAC_CTX *, int)); +int SSL_CTX_set_tlsext_ticket_key_evp_cb( + SSL_CTX *ctx, int (*fp)(SSL *, unsigned char *, unsigned char *, + EVP_CIPHER_CTX *, EVP_MAC_CTX *, int)); /* PSK ciphersuites from 4279 */ #define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A @@ -630,20 +644,30 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_RFC_RSA_WITH_NULL_SHA256 "TLS_RSA_WITH_NULL_SHA256" #define TLS1_RFC_RSA_WITH_AES_128_SHA256 "TLS_RSA_WITH_AES_128_CBC_SHA256" #define TLS1_RFC_RSA_WITH_AES_256_SHA256 "TLS_RSA_WITH_AES_256_CBC_SHA256" -#define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA256 "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA256 "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA256 "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" -#define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA256 "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" +#define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA256 \ + "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA256 \ + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA256 \ + "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" +#define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA256 \ + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" #define TLS1_RFC_ADH_WITH_AES_128_SHA256 "TLS_DH_anon_WITH_AES_128_CBC_SHA256" #define TLS1_RFC_ADH_WITH_AES_256_SHA256 "TLS_DH_anon_WITH_AES_256_CBC_SHA256" #define TLS1_RFC_RSA_WITH_AES_128_GCM_SHA256 "TLS_RSA_WITH_AES_128_GCM_SHA256" #define TLS1_RFC_RSA_WITH_AES_256_GCM_SHA384 "TLS_RSA_WITH_AES_256_GCM_SHA384" -#define TLS1_RFC_DHE_RSA_WITH_AES_128_GCM_SHA256 "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_DHE_RSA_WITH_AES_256_GCM_SHA384 "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" -#define TLS1_RFC_DHE_DSS_WITH_AES_128_GCM_SHA256 "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_DHE_DSS_WITH_AES_256_GCM_SHA384 "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" -#define TLS1_RFC_ADH_WITH_AES_128_GCM_SHA256 "TLS_DH_anon_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_ADH_WITH_AES_256_GCM_SHA384 "TLS_DH_anon_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_DHE_RSA_WITH_AES_128_GCM_SHA256 \ + "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_DHE_RSA_WITH_AES_256_GCM_SHA384 \ + "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_DHE_DSS_WITH_AES_128_GCM_SHA256 \ + "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_DHE_DSS_WITH_AES_256_GCM_SHA384 \ + "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_ADH_WITH_AES_128_GCM_SHA256 \ + "TLS_DH_anon_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_ADH_WITH_AES_256_GCM_SHA384 \ + "TLS_DH_anon_WITH_AES_256_GCM_SHA384" #define TLS1_RFC_RSA_WITH_AES_128_CCM "TLS_RSA_WITH_AES_128_CCM" #define TLS1_RFC_RSA_WITH_AES_256_CCM "TLS_RSA_WITH_AES_256_CCM" #define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM "TLS_DHE_RSA_WITH_AES_128_CCM" @@ -662,117 +686,191 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM_8 "TLS_PSK_DHE_WITH_AES_256_CCM_8" #define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM "TLS_ECDHE_ECDSA_WITH_AES_128_CCM" #define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM "TLS_ECDHE_ECDSA_WITH_AES_256_CCM" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM_8 "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM_8 "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM_8 \ + "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM_8 \ + "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8" #define TLS1_3_RFC_AES_128_GCM_SHA256 "TLS_AES_128_GCM_SHA256" #define TLS1_3_RFC_AES_256_GCM_SHA384 "TLS_AES_256_GCM_SHA384" #define TLS1_3_RFC_CHACHA20_POLY1305_SHA256 "TLS_CHACHA20_POLY1305_SHA256" #define TLS1_3_RFC_AES_128_CCM_SHA256 "TLS_AES_128_CCM_SHA256" #define TLS1_3_RFC_AES_128_CCM_8_SHA256 "TLS_AES_128_CCM_8_SHA256" #define TLS1_RFC_ECDHE_ECDSA_WITH_NULL_SHA "TLS_ECDHE_ECDSA_WITH_NULL_SHA" -#define TLS1_RFC_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" +#define TLS1_RFC_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA \ + "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CBC_SHA \ + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CBC_SHA \ + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" #define TLS1_RFC_ECDHE_RSA_WITH_NULL_SHA "TLS_ECDHE_RSA_WITH_NULL_SHA" -#define TLS1_RFC_ECDHE_RSA_WITH_DES_192_CBC3_SHA "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" -#define TLS1_RFC_ECDHE_RSA_WITH_AES_128_CBC_SHA "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" -#define TLS1_RFC_ECDHE_RSA_WITH_AES_256_CBC_SHA "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" +#define TLS1_RFC_ECDHE_RSA_WITH_DES_192_CBC3_SHA \ + "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_ECDHE_RSA_WITH_AES_128_CBC_SHA \ + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" +#define TLS1_RFC_ECDHE_RSA_WITH_AES_256_CBC_SHA \ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" #define TLS1_RFC_ECDH_anon_WITH_NULL_SHA "TLS_ECDH_anon_WITH_NULL_SHA" -#define TLS1_RFC_ECDH_anon_WITH_DES_192_CBC3_SHA "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" -#define TLS1_RFC_ECDH_anon_WITH_AES_128_CBC_SHA "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" -#define TLS1_RFC_ECDH_anon_WITH_AES_256_CBC_SHA "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_SHA256 "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_SHA384 "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" -#define TLS1_RFC_ECDHE_RSA_WITH_AES_128_SHA256 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_ECDHE_RSA_WITH_AES_256_SHA384 "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" -#define TLS1_RFC_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_ECDH_anon_WITH_DES_192_CBC3_SHA \ + "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_ECDH_anon_WITH_AES_128_CBC_SHA \ + "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" +#define TLS1_RFC_ECDH_anon_WITH_AES_256_CBC_SHA \ + "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_SHA256 \ + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_SHA384 \ + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" +#define TLS1_RFC_ECDHE_RSA_WITH_AES_128_SHA256 \ + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_ECDHE_RSA_WITH_AES_256_SHA384 \ + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 \ + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 \ + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_ECDHE_RSA_WITH_AES_128_GCM_SHA256 \ + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384 \ + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" #define TLS1_RFC_PSK_WITH_NULL_SHA "TLS_PSK_WITH_NULL_SHA" #define TLS1_RFC_DHE_PSK_WITH_NULL_SHA "TLS_DHE_PSK_WITH_NULL_SHA" #define TLS1_RFC_RSA_PSK_WITH_NULL_SHA "TLS_RSA_PSK_WITH_NULL_SHA" #define TLS1_RFC_PSK_WITH_3DES_EDE_CBC_SHA "TLS_PSK_WITH_3DES_EDE_CBC_SHA" #define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA "TLS_PSK_WITH_AES_128_CBC_SHA" #define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA "TLS_PSK_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_DHE_PSK_WITH_3DES_EDE_CBC_SHA "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_DHE_PSK_WITH_3DES_EDE_CBC_SHA \ + "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" #define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA "TLS_DHE_PSK_WITH_AES_128_CBC_SHA" #define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA "TLS_DHE_PSK_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_RSA_PSK_WITH_3DES_EDE_CBC_SHA "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_RSA_PSK_WITH_3DES_EDE_CBC_SHA \ + "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" #define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA "TLS_RSA_PSK_WITH_AES_128_CBC_SHA" #define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA "TLS_RSA_PSK_WITH_AES_256_CBC_SHA" #define TLS1_RFC_PSK_WITH_AES_128_GCM_SHA256 "TLS_PSK_WITH_AES_128_GCM_SHA256" #define TLS1_RFC_PSK_WITH_AES_256_GCM_SHA384 "TLS_PSK_WITH_AES_256_GCM_SHA384" -#define TLS1_RFC_DHE_PSK_WITH_AES_128_GCM_SHA256 "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_DHE_PSK_WITH_AES_256_GCM_SHA384 "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" -#define TLS1_RFC_RSA_PSK_WITH_AES_128_GCM_SHA256 "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" -#define TLS1_RFC_RSA_PSK_WITH_AES_256_GCM_SHA384 "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_DHE_PSK_WITH_AES_128_GCM_SHA256 \ + "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_DHE_PSK_WITH_AES_256_GCM_SHA384 \ + "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" +#define TLS1_RFC_RSA_PSK_WITH_AES_128_GCM_SHA256 \ + "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" +#define TLS1_RFC_RSA_PSK_WITH_AES_256_GCM_SHA384 \ + "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" #define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA256 "TLS_PSK_WITH_AES_128_CBC_SHA256" #define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA384 "TLS_PSK_WITH_AES_256_CBC_SHA384" #define TLS1_RFC_PSK_WITH_NULL_SHA256 "TLS_PSK_WITH_NULL_SHA256" #define TLS1_RFC_PSK_WITH_NULL_SHA384 "TLS_PSK_WITH_NULL_SHA384" -#define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA256 "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA384 "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" +#define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA256 \ + "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA384 \ + "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" #define TLS1_RFC_DHE_PSK_WITH_NULL_SHA256 "TLS_DHE_PSK_WITH_NULL_SHA256" #define TLS1_RFC_DHE_PSK_WITH_NULL_SHA384 "TLS_DHE_PSK_WITH_NULL_SHA384" -#define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA256 "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA384 "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" +#define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA256 \ + "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA384 \ + "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" #define TLS1_RFC_RSA_PSK_WITH_NULL_SHA256 "TLS_RSA_PSK_WITH_NULL_SHA256" #define TLS1_RFC_RSA_PSK_WITH_NULL_SHA384 "TLS_RSA_PSK_WITH_NULL_SHA384" -#define TLS1_RFC_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" -#define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" -#define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" -#define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" +#define TLS1_RFC_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA \ + "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA \ + "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" +#define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA \ + "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" +#define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA256 \ + "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" +#define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA384 \ + "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" #define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA "TLS_ECDHE_PSK_WITH_NULL_SHA" #define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA256 "TLS_ECDHE_PSK_WITH_NULL_SHA256" #define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA384 "TLS_ECDHE_PSK_WITH_NULL_SHA384" -#define TLS1_RFC_SRP_SHA_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" -#define TLS1_RFC_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" -#define TLS1_RFC_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_SRP_SHA_WITH_3DES_EDE_CBC_SHA \ + "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA \ + "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" +#define TLS1_RFC_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA \ + "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" #define TLS1_RFC_SRP_SHA_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_WITH_AES_128_CBC_SHA" -#define TLS1_RFC_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" -#define TLS1_RFC_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" +#define TLS1_RFC_SRP_SHA_RSA_WITH_AES_128_CBC_SHA \ + "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" +#define TLS1_RFC_SRP_SHA_DSS_WITH_AES_128_CBC_SHA \ + "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" #define TLS1_RFC_SRP_SHA_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" -#define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305 "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305 "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305 "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305 "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_RSA_PSK_WITH_CHACHA20_POLY1305 "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256" -#define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA256 "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" -#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" -#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" -#define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" -#define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" -#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" -#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" -#define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" -#define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" -#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" -#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" -#define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" -#define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \ - "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \ - "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" -#define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" -#define TLS1_RFC_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384" -#define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" -#define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384" -#define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" -#define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" +#define TLS1_RFC_SRP_SHA_RSA_WITH_AES_256_CBC_SHA \ + "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" +#define TLS1_RFC_SRP_SHA_DSS_WITH_AES_256_CBC_SHA \ + "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" +#define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305 \ + "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305 \ + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 \ + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305 \ + "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305 \ + "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305 \ + "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_RSA_PSK_WITH_CHACHA20_POLY1305 \ + "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256" +#define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA256 \ + "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" +#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 \ + "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" +#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 \ + "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" +#define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA256 \ + "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" +#define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA \ + "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" +#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA \ + "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" +#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA \ + "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" +#define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA \ + "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" +#define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA \ + "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" +#define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA \ + "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" +#define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA \ + "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" +#define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA \ + "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" +#define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \ + "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" +#define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 \ + "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" +#define TLS1_RFC_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384" +#define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" +#define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384" +#define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" +#define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" #define TLS1_RFC_RSA_WITH_SEED_SHA "TLS_RSA_WITH_SEED_CBC_SHA" #define TLS1_RFC_DHE_DSS_WITH_SEED_SHA "TLS_DHE_DSS_WITH_SEED_CBC_SHA" #define TLS1_RFC_DHE_RSA_WITH_SEED_SHA "TLS_DHE_RSA_WITH_SEED_CBC_SHA" @@ -786,30 +884,52 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_RFC_DHE_PSK_WITH_RC4_128_SHA "TLS_DHE_PSK_WITH_RC4_128_SHA" #define TLS1_RFC_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_WITH_ARIA_128_GCM_SHA256" #define TLS1_RFC_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_DHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_DHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_DH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_DH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_DHE_DSS_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_DHE_DSS_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_DH_DSS_WITH_ARIA_128_GCM_SHA256 "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_DH_DSS_WITH_ARIA_256_GCM_SHA384 "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_DH_anon_WITH_ARIA_128_GCM_SHA256 "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_DH_anon_WITH_ARIA_256_GCM_SHA384 "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_DHE_RSA_WITH_ARIA_128_GCM_SHA256 \ + "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_DHE_RSA_WITH_ARIA_256_GCM_SHA384 \ + "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_DH_RSA_WITH_ARIA_128_GCM_SHA256 \ + "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_DH_RSA_WITH_ARIA_256_GCM_SHA384 \ + "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_DHE_DSS_WITH_ARIA_128_GCM_SHA256 \ + "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_DHE_DSS_WITH_ARIA_256_GCM_SHA384 \ + "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_DH_DSS_WITH_ARIA_128_GCM_SHA256 \ + "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_DH_DSS_WITH_ARIA_256_GCM_SHA384 \ + "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_DH_anon_WITH_ARIA_128_GCM_SHA256 \ + "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_DH_anon_WITH_ARIA_256_GCM_SHA384 \ + "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 \ + "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 \ + "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 \ + "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 \ + "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 \ + "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 \ + "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 \ + "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 \ + "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384" #define TLS1_RFC_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_PSK_WITH_ARIA_128_GCM_SHA256" #define TLS1_RFC_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_PSK_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384" -#define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256" -#define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256 \ + "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384 \ + "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384" +#define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256 \ + "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256" +#define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384 \ + "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384" /* * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE @@ -937,25 +1057,35 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256 "CAMELLIA128-SHA256" #define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DH-DSS-CAMELLIA128-SHA256" #define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DH-RSA-CAMELLIA128-SHA256" -#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DHE-DSS-CAMELLIA128-SHA256" -#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DHE-RSA-CAMELLIA128-SHA256" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 \ + "DHE-DSS-CAMELLIA128-SHA256" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "DHE-RSA-CAMELLIA128-SHA256" #define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256 "ADH-CAMELLIA128-SHA256" #define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256 "CAMELLIA256-SHA256" #define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DH-DSS-CAMELLIA256-SHA256" #define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DH-RSA-CAMELLIA256-SHA256" -#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DHE-DSS-CAMELLIA256-SHA256" -#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DHE-RSA-CAMELLIA256-SHA256" +#define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 \ + "DHE-DSS-CAMELLIA256-SHA256" +#define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 \ + "DHE-RSA-CAMELLIA256-SHA256" #define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256 "ADH-CAMELLIA256-SHA256" #define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256 "PSK-CAMELLIA128-SHA256" #define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384 "PSK-CAMELLIA256-SHA384" -#define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "DHE-PSK-CAMELLIA128-SHA256" -#define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "DHE-PSK-CAMELLIA256-SHA384" -#define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "RSA-PSK-CAMELLIA128-SHA256" -#define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "RSA-PSK-CAMELLIA256-SHA384" -#define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-PSK-CAMELLIA128-SHA256" -#define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-PSK-CAMELLIA256-SHA384" +#define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "DHE-PSK-CAMELLIA128-SHA256" +#define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "DHE-PSK-CAMELLIA256-SHA384" +#define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "RSA-PSK-CAMELLIA128-SHA256" +#define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "RSA-PSK-CAMELLIA256-SHA384" +#define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \ + "ECDHE-PSK-CAMELLIA128-SHA256" +#define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \ + "ECDHE-PSK-CAMELLIA256-SHA384" /* SEED ciphersuites from RFC4162 */ #define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA" @@ -1032,10 +1162,14 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384" /* ECDH GCM based ciphersuites from RFC5289 */ -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "ECDHE-ECDSA-AES128-GCM-SHA256" -#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "ECDHE-ECDSA-AES256-GCM-SHA384" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 "ECDH-ECDSA-AES128-GCM-SHA256" -#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 "ECDH-ECDSA-AES256-GCM-SHA384" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 \ + "ECDHE-ECDSA-AES128-GCM-SHA256" +#define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 \ + "ECDHE-ECDSA-AES256-GCM-SHA384" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 \ + "ECDH-ECDSA-AES128-GCM-SHA256" +#define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 \ + "ECDH-ECDSA-AES256-GCM-SHA384" #define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256" #define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384" #define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256" @@ -1059,18 +1193,27 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384 "ECDHE-PSK-NULL-SHA384" /* Camellia-CBC ciphersuites from RFC6367 */ -#define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-ECDSA-CAMELLIA128-SHA256" -#define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-ECDSA-CAMELLIA256-SHA384" -#define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-ECDSA-CAMELLIA128-SHA256" -#define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-ECDSA-CAMELLIA256-SHA384" -#define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-RSA-CAMELLIA128-SHA256" -#define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-RSA-CAMELLIA256-SHA384" -#define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-RSA-CAMELLIA128-SHA256" -#define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-RSA-CAMELLIA256-SHA384" +#define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "ECDHE-ECDSA-CAMELLIA128-SHA256" +#define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \ + "ECDHE-ECDSA-CAMELLIA256-SHA384" +#define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "ECDH-ECDSA-CAMELLIA128-SHA256" +#define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \ + "ECDH-ECDSA-CAMELLIA256-SHA384" +#define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "ECDHE-RSA-CAMELLIA128-SHA256" +#define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 \ + "ECDHE-RSA-CAMELLIA256-SHA384" +#define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 \ + "ECDH-RSA-CAMELLIA128-SHA256" +#define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 \ + "ECDH-RSA-CAMELLIA256-SHA384" /* draft-ietf-tls-chacha20-poly1305-03 */ #define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305" -#define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305" +#define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 \ + "ECDHE-ECDSA-CHACHA20-POLY1305" #define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305" #define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305 "PSK-CHACHA20-POLY1305" #define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305 "ECDHE-PSK-CHACHA20-POLY1305" @@ -1090,10 +1233,14 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS1_TXT_DH_DSS_WITH_ARIA_256_GCM_SHA384 "DH-DSS-ARIA256-GCM-SHA384" #define TLS1_TXT_DH_anon_WITH_ARIA_128_GCM_SHA256 "ADH-ARIA128-GCM-SHA256" #define TLS1_TXT_DH_anon_WITH_ARIA_256_GCM_SHA384 "ADH-ARIA256-GCM-SHA384" -#define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 "ECDHE-ECDSA-ARIA128-GCM-SHA256" -#define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 "ECDHE-ECDSA-ARIA256-GCM-SHA384" -#define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 "ECDH-ECDSA-ARIA128-GCM-SHA256" -#define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 "ECDH-ECDSA-ARIA256-GCM-SHA384" +#define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 \ + "ECDHE-ECDSA-ARIA128-GCM-SHA256" +#define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 \ + "ECDHE-ECDSA-ARIA256-GCM-SHA384" +#define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 \ + "ECDH-ECDSA-ARIA128-GCM-SHA256" +#define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 \ + "ECDH-ECDSA-ARIA256-GCM-SHA384" #define TLS1_TXT_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "ECDHE-ARIA128-GCM-SHA256" #define TLS1_TXT_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "ECDHE-ARIA256-GCM-SHA384" #define TLS1_TXT_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "ECDH-ARIA128-GCM-SHA256" @@ -1119,8 +1266,8 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS_CT_GOST12_LEGACY_512_SIGN 239 #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define TLS_CT_GOST12_SIGN TLS_CT_GOST12_LEGACY_SIGN -# define TLS_CT_GOST12_512_SIGN TLS_CT_GOST12_LEGACY_512_SIGN +# define TLS_CT_GOST12_SIGN TLS_CT_GOST12_LEGACY_SIGN +# define TLS_CT_GOST12_512_SIGN TLS_CT_GOST12_LEGACY_512_SIGN #endif /* @@ -1130,9 +1277,9 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS_CT_NUMBER 12 #if defined(SSL3_CT_NUMBER) -# if TLS_CT_NUMBER != SSL3_CT_NUMBER -# error "SSL/TLS CT_NUMBER values do not match" -# endif +# if TLS_CT_NUMBER != SSL3_CT_NUMBER +# error "SSL/TLS CT_NUMBER values do not match" +# endif #endif #define TLS1_FINISH_MAC_LENGTH 12 @@ -1140,42 +1287,47 @@ int SSL_CTX_set_tlsext_ticket_key_evp_cb(SSL_CTX *ctx, #define TLS_MD_MAX_CONST_SIZE 22 /* ASCII: "client finished", in hex for EBCDIC compatibility */ -#define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" +#define TLS_MD_CLIENT_FINISH_CONST \ + "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" #define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 /* ASCII: "server finished", in hex for EBCDIC compatibility */ -#define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" +#define TLS_MD_SERVER_FINISH_CONST \ + "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" #define TLS_MD_SERVER_FINISH_CONST_SIZE 15 /* ASCII: "server write key", in hex for EBCDIC compatibility */ -#define TLS_MD_SERVER_WRITE_KEY_CONST \ - "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" +#define TLS_MD_SERVER_WRITE_KEY_CONST \ + "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" #define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 /* ASCII: "key expansion", in hex for EBCDIC compatibility */ -#define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" +#define TLS_MD_KEY_EXPANSION_CONST \ + "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" #define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 /* ASCII: "client write key", in hex for EBCDIC compatibility */ -#define TLS_MD_CLIENT_WRITE_KEY_CONST \ - "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" +#define TLS_MD_CLIENT_WRITE_KEY_CONST \ + "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" #define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 /* ASCII: "server write key", in hex for EBCDIC compatibility */ -#define TLS_MD_SERVER_WRITE_KEY_CONST \ - "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" +#define TLS_MD_SERVER_WRITE_KEY_CONST \ + "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" #define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 /* ASCII: "IV block", in hex for EBCDIC compatibility */ #define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" #define TLS_MD_IV_BLOCK_CONST_SIZE 8 /* ASCII: "master secret", in hex for EBCDIC compatibility */ -#define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" +#define TLS_MD_MASTER_SECRET_CONST \ + "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" #define TLS_MD_MASTER_SECRET_CONST_SIZE 13 /* ASCII: "extended master secret", in hex for EBCDIC compatibility */ -#define TLS_MD_EXTENDED_MASTER_SECRET_CONST \ - "\x65\x78\x74\x65\x6e\x64\x65\x64\x20\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" +#define TLS_MD_EXTENDED_MASTER_SECRET_CONST \ + "\x65\x78\x74\x65\x6e\x64\x65\x64\x20\x6d\x61\x73\x74\x65\x72\x20\x73\x65" \ + "\x63\x72\x65\x74" #define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE 22 /* TLS Session Ticket extension struct */ struct tls_session_ticket_ext_st { - unsigned short length; - void *data; + unsigned short length; + void *data; }; #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/trace.h b/libs/OpenSSL/include/openssl/trace.h index 71785c8c..224c69a7 100644 --- a/libs/OpenSSL/include/openssl/trace.h +++ b/libs/OpenSSL/include/openssl/trace.h @@ -102,8 +102,8 @@ int OSSL_trace_set_suffix(int category, const char *suffix); * * The |category| number is given, as well as a |cmd| number, described below. */ -typedef size_t (*OSSL_trace_cb)(const char *buffer, size_t count, int category, int cmd, - void *data); +typedef size_t (*OSSL_trace_cb)(const char *buffer, size_t count, int category, + int cmd, void *data); /* * Possible |cmd| numbers. */ @@ -200,33 +200,34 @@ void OSSL_trace_end(int category, BIO *channel); #if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE -# define OSSL_TRACE_BEGIN(category) \ - do \ - { \ - BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_##category); \ - \ - if (trc_out != NULL) +# define OSSL_TRACE_BEGIN(category) \ + do \ + { \ + BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_##category); \ + \ + if (trc_out != NULL) -# define OSSL_TRACE_END(category) \ - OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out); \ - } \ - while (0) +# define OSSL_TRACE_END(category) \ + OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out); \ + } \ + while (0) -# define OSSL_TRACE_CANCEL(category) OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out) +# define OSSL_TRACE_CANCEL(category) \ + OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out) #else -# define OSSL_TRACE_BEGIN(category) \ - do \ - { \ - BIO *trc_out = NULL; \ - if (0) +# define OSSL_TRACE_BEGIN(category) \ + do \ + { \ + BIO *trc_out = NULL; \ + if (0) -# define OSSL_TRACE_END(category) \ - } \ - while (0) +# define OSSL_TRACE_END(category) \ + } \ + while (0) -# define OSSL_TRACE_CANCEL(category) ((void)0) +# define OSSL_TRACE_CANCEL(category) ((void)0) #endif @@ -241,11 +242,12 @@ void OSSL_trace_end(int category, BIO *channel); */ #if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE -# define OSSL_TRACE_ENABLED(category) OSSL_trace_enabled(OSSL_TRACE_CATEGORY_##category) +# define OSSL_TRACE_ENABLED(category) \ + OSSL_trace_enabled(OSSL_TRACE_CATEGORY_##category) #else -# define OSSL_TRACE_ENABLED(category) (0) +# define OSSL_TRACE_ENABLED(category) (0) #endif @@ -273,36 +275,43 @@ void OSSL_trace_end(int category, BIO *channel); #if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE -# define OSSL_TRACEV(category, args) \ - OSSL_TRACE_BEGIN(category) \ - BIO_printf args; \ - OSSL_TRACE_END(category) +# define OSSL_TRACEV(category, args) \ + OSSL_TRACE_BEGIN(category) \ + BIO_printf args; \ + OSSL_TRACE_END(category) #else -# define OSSL_TRACEV(category, args) ((void)0) +# define OSSL_TRACEV(category, args) ((void)0) #endif #define OSSL_TRACE(category, text) OSSL_TRACEV(category, (trc_out, "%s", text)) -#define OSSL_TRACE1(category, format, arg1) OSSL_TRACEV(category, (trc_out, format, arg1)) -#define OSSL_TRACE2(category, format, arg1, arg2) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2)) -#define OSSL_TRACE3(category, format, arg1, arg2, arg3) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3)) -#define OSSL_TRACE4(category, format, arg1, arg2, arg3, arg4) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4)) -#define OSSL_TRACE5(category, format, arg1, arg2, arg3, arg4, arg5) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5)) -#define OSSL_TRACE6(category, format, arg1, arg2, arg3, arg4, arg5, arg6) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6)) -#define OSSL_TRACE7(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7)) -#define OSSL_TRACE8(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)) -#define OSSL_TRACE9(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \ - OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)) +#define OSSL_TRACE1(category, format, arg1) \ + OSSL_TRACEV(category, (trc_out, format, arg1)) +#define OSSL_TRACE2(category, format, arg1, arg2) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2)) +#define OSSL_TRACE3(category, format, arg1, arg2, arg3) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3)) +#define OSSL_TRACE4(category, format, arg1, arg2, arg3, arg4) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4)) +#define OSSL_TRACE5(category, format, arg1, arg2, arg3, arg4, arg5) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5)) +#define OSSL_TRACE6(category, format, arg1, arg2, arg3, arg4, arg5, arg6) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6)) +#define OSSL_TRACE7(category, format, arg1, arg2, arg3, arg4, arg5, arg6, \ + arg7) \ + OSSL_TRACEV(category, \ + (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7)) +#define OSSL_TRACE8(category, format, arg1, arg2, arg3, arg4, arg5, arg6, \ + arg7, arg8) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, \ + arg7, arg8)) +#define OSSL_TRACE9(category, format, arg1, arg2, arg3, arg4, arg5, arg6, \ + arg7, arg8, arg9) \ + OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, \ + arg7, arg8, arg9)) #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/ts.h b/libs/OpenSSL/include/openssl/ts.h index c7dec0fb..07d3feef 100644 --- a/libs/OpenSSL/include/openssl/ts.h +++ b/libs/OpenSSL/include/openssl/ts.h @@ -13,31 +13,31 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_TS_H +# define HEADER_TS_H #endif #include #ifndef OPENSSL_NO_TS -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# ifndef OPENSSL_NO_STDIO -# include -# endif -# ifdef __cplusplus +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# ifndef OPENSSL_NO_STDIO +# include +# endif +# ifdef __cplusplus extern "C" { -# endif +# endif typedef struct TS_msg_imprint_st TS_MSG_IMPRINT; typedef struct TS_req_st TS_REQ; @@ -45,34 +45,35 @@ typedef struct TS_accuracy_st TS_ACCURACY; typedef struct TS_tst_info_st TS_TST_INFO; /* Possible values for status. */ -# define TS_STATUS_GRANTED 0 -# define TS_STATUS_GRANTED_WITH_MODS 1 -# define TS_STATUS_REJECTION 2 -# define TS_STATUS_WAITING 3 -# define TS_STATUS_REVOCATION_WARNING 4 -# define TS_STATUS_REVOCATION_NOTIFICATION 5 +# define TS_STATUS_GRANTED 0 +# define TS_STATUS_GRANTED_WITH_MODS 1 +# define TS_STATUS_REJECTION 2 +# define TS_STATUS_WAITING 3 +# define TS_STATUS_REVOCATION_WARNING 4 +# define TS_STATUS_REVOCATION_NOTIFICATION 5 /* Possible values for failure_info. */ -# define TS_INFO_BAD_ALG 0 -# define TS_INFO_BAD_REQUEST 2 -# define TS_INFO_BAD_DATA_FORMAT 5 -# define TS_INFO_TIME_NOT_AVAILABLE 14 -# define TS_INFO_UNACCEPTED_POLICY 15 -# define TS_INFO_UNACCEPTED_EXTENSION 16 -# define TS_INFO_ADD_INFO_NOT_AVAILABLE 17 -# define TS_INFO_SYSTEM_FAILURE 25 +# define TS_INFO_BAD_ALG 0 +# define TS_INFO_BAD_REQUEST 2 +# define TS_INFO_BAD_DATA_FORMAT 5 +# define TS_INFO_TIME_NOT_AVAILABLE 14 +# define TS_INFO_UNACCEPTED_POLICY 15 +# define TS_INFO_UNACCEPTED_EXTENSION 16 +# define TS_INFO_ADD_INFO_NOT_AVAILABLE 17 +# define TS_INFO_SYSTEM_FAILURE 25 typedef struct TS_status_info_st TS_STATUS_INFO; typedef struct TS_resp_st TS_RESP; DECLARE_ASN1_ALLOC_FUNCTIONS(TS_REQ) -DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_REQ, TS_REQ) DECLARE_ASN1_DUP_FUNCTION(TS_REQ) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_REQ, TS_REQ) + DECLARE_ASN1_DUP_FUNCTION(TS_REQ) -# ifndef OPENSSL_NO_STDIO - TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a); +# ifndef OPENSSL_NO_STDIO + TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a); int i2d_TS_REQ_fp(FILE *fp, const TS_REQ *a); -# endif +# endif TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a); int i2d_TS_REQ_bio(BIO *fp, const TS_REQ *a); @@ -80,20 +81,21 @@ DECLARE_ASN1_ALLOC_FUNCTIONS(TS_MSG_IMPRINT) DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_MSG_IMPRINT, TS_MSG_IMPRINT) DECLARE_ASN1_DUP_FUNCTION(TS_MSG_IMPRINT) -# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_STDIO TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a); int i2d_TS_MSG_IMPRINT_fp(FILE *fp, const TS_MSG_IMPRINT *a); -# endif +# endif TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a); int i2d_TS_MSG_IMPRINT_bio(BIO *bio, const TS_MSG_IMPRINT *a); DECLARE_ASN1_ALLOC_FUNCTIONS(TS_RESP) -DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_RESP, TS_RESP) DECLARE_ASN1_DUP_FUNCTION(TS_RESP) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_RESP, TS_RESP) + DECLARE_ASN1_DUP_FUNCTION(TS_RESP) -# ifndef OPENSSL_NO_STDIO - TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a); +# ifndef OPENSSL_NO_STDIO + TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a); int i2d_TS_RESP_fp(FILE *fp, const TS_RESP *a); -# endif +# endif TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a); int i2d_TS_RESP_bio(BIO *bio, const TS_RESP *a); @@ -101,29 +103,33 @@ DECLARE_ASN1_ALLOC_FUNCTIONS(TS_STATUS_INFO) DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_STATUS_INFO, TS_STATUS_INFO) DECLARE_ASN1_DUP_FUNCTION(TS_STATUS_INFO) - DECLARE_ASN1_ALLOC_FUNCTIONS(TS_TST_INFO) DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_TST_INFO, - TS_TST_INFO) - DECLARE_ASN1_DUP_FUNCTION(TS_TST_INFO) TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token); + DECLARE_ASN1_ALLOC_FUNCTIONS(TS_TST_INFO) + DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_TST_INFO, TS_TST_INFO) + DECLARE_ASN1_DUP_FUNCTION(TS_TST_INFO) + TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token); -# ifndef OPENSSL_NO_STDIO +# ifndef OPENSSL_NO_STDIO TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a); int i2d_TS_TST_INFO_fp(FILE *fp, const TS_TST_INFO *a); -# endif +# endif TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a); int i2d_TS_TST_INFO_bio(BIO *bio, const TS_TST_INFO *a); DECLARE_ASN1_ALLOC_FUNCTIONS(TS_ACCURACY) -DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_ACCURACY, TS_ACCURACY) DECLARE_ASN1_DUP_FUNCTION(TS_ACCURACY) +DECLARE_ASN1_ENCODE_FUNCTIONS_only(TS_ACCURACY, TS_ACCURACY) + DECLARE_ASN1_DUP_FUNCTION(TS_ACCURACY) - int TS_REQ_set_version(TS_REQ *a, long version); + int TS_REQ_set_version(TS_REQ *a, long version); long TS_REQ_get_version(const TS_REQ *a); int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i); const ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a); -const STACK_OF(ASN1_UTF8STRING) * TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a); +const STACK_OF(ASN1_UTF8STRING) + * TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a); -const ASN1_BIT_STRING *TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a); +const ASN1_BIT_STRING * +TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a); int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint); TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a); @@ -208,7 +214,8 @@ STACK_OF(X509_EXTENSION) * TS_TST_INFO_get_exts(TS_TST_INFO *a); void TS_TST_INFO_ext_free(TS_TST_INFO *a); int TS_TST_INFO_get_ext_count(TS_TST_INFO *a); int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos); -int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, int lastpos); +int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, + int lastpos); int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos); X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc); X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc); @@ -222,17 +229,17 @@ void *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx); /* Optional flags for response generation. */ /* Don't include the TSA name in response. */ -# define TS_TSA_NAME 0x01 +# define TS_TSA_NAME 0x01 /* Set ordering to true in response. */ -# define TS_ORDERING 0x02 +# define TS_ORDERING 0x02 /* * Include the signer certificate and the other specified certificates in * the ESS signing certificate attribute beside the PKCS7 signed data. * Only the signer certificates is included by default. */ -# define TS_ESS_CERT_ID_CHAIN 0x04 +# define TS_ESS_CERT_ID_CHAIN 0x04 /* Forward declaration. */ struct TS_resp_ctx; @@ -267,7 +274,8 @@ int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer); /* This parameter must be set. */ int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key); -int TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx, const EVP_MD *signer_digest); +int TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx, + const EVP_MD *signer_digest); int TS_RESP_CTX_set_ess_cert_id_digest(TS_RESP_CTX *ctx, const EVP_MD *md); /* This parameter must be set. */ @@ -289,18 +297,20 @@ int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy); int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md); /* Accuracy is not included by default. */ -int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, int secs, int millis, int micros); +int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, int secs, int millis, + int micros); /* * Clock precision digits, i.e. the number of decimal digits: '0' means sec, * '3' msec, '6' usec, and so on. Default is 0. */ -int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx, unsigned clock_precision_digits); +int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx, + unsigned clock_precision_digits); /* At most we accept usec precision. */ -# define TS_MAX_CLOCK_PRECISION_DIGITS 6 +# define TS_MAX_CLOCK_PRECISION_DIGITS 6 /* Maximum status message length */ -# define TS_MAX_STATUS_LENGTH (1024 * 1024) +# define TS_MAX_STATUS_LENGTH (1024 * 1024) /* No flags are set by default. */ void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags); @@ -316,13 +326,15 @@ void TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data); * when the TS_TST_INFO object is already set up and not signed yet. */ /* FIXME: extension handling is not tested yet. */ -void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx, TS_extension_cb cb, void *data); +void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx, TS_extension_cb cb, + void *data); /* The following methods can be used in the callbacks. */ int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx, int status, const char *text); /* Sets the status info only if it is still TS_STATUS_GRANTED. */ -int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx, int status, const char *text); +int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx, int status, + const char *text); int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure); @@ -343,42 +355,42 @@ TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio); * they are defined in ts/ts_resp_verify.c. */ -int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) * certs, X509_STORE *store, - X509 **signer_out); +int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) * certs, + X509_STORE *store, X509 **signer_out); /* Context structure for the generic verify method. */ /* Verify the signer's certificate and the signature of the response. */ -# define TS_VFY_SIGNATURE (1u << 0) +# define TS_VFY_SIGNATURE (1u << 0) /* Verify the version number of the response. */ -# define TS_VFY_VERSION (1u << 1) +# define TS_VFY_VERSION (1u << 1) /* Verify if the policy supplied by the user matches the policy of the TSA. */ -# define TS_VFY_POLICY (1u << 2) +# define TS_VFY_POLICY (1u << 2) /* * Verify the message imprint provided by the user. This flag should not be * specified with TS_VFY_DATA. */ -# define TS_VFY_IMPRINT (1u << 3) +# define TS_VFY_IMPRINT (1u << 3) /* * Verify the message imprint computed by the verify method from the user * provided data and the MD algorithm of the response. This flag should not * be specified with TS_VFY_IMPRINT. */ -# define TS_VFY_DATA (1u << 4) +# define TS_VFY_DATA (1u << 4) /* Verify the nonce value. */ -# define TS_VFY_NONCE (1u << 5) +# define TS_VFY_NONCE (1u << 5) /* Verify if the TSA name field matches the signer certificate. */ -# define TS_VFY_SIGNER (1u << 6) +# define TS_VFY_SIGNER (1u << 6) /* Verify if the TSA name field equals to the user provided name. */ -# define TS_VFY_TSA_NAME (1u << 7) +# define TS_VFY_TSA_NAME (1u << 7) /* You can use the following convenience constants. */ -# define TS_VFY_ALL_IMPRINT \ - (TS_VFY_SIGNATURE | TS_VFY_VERSION | TS_VFY_POLICY | TS_VFY_IMPRINT | TS_VFY_NONCE \ - | TS_VFY_SIGNER | TS_VFY_TSA_NAME) -# define TS_VFY_ALL_DATA \ - (TS_VFY_SIGNATURE | TS_VFY_VERSION | TS_VFY_POLICY | TS_VFY_DATA | TS_VFY_NONCE \ - | TS_VFY_SIGNER | TS_VFY_TSA_NAME) +# define TS_VFY_ALL_IMPRINT \ + (TS_VFY_SIGNATURE | TS_VFY_VERSION | TS_VFY_POLICY | TS_VFY_IMPRINT \ + | TS_VFY_NONCE | TS_VFY_SIGNER | TS_VFY_TSA_NAME) +# define TS_VFY_ALL_DATA \ + (TS_VFY_SIGNATURE | TS_VFY_VERSION | TS_VFY_POLICY | TS_VFY_DATA \ + | TS_VFY_NONCE | TS_VFY_SIGNER | TS_VFY_TSA_NAME) typedef struct TS_verify_ctx TS_VERIFY_CTX; @@ -395,12 +407,15 @@ void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx); int TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f); int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f); BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b); -unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx, unsigned char *hexstr, long len); +unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx, + unsigned char *hexstr, long len); X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s); -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# define TS_VERIFY_CTS_set_certs(ctx, cert) TS_VERIFY_CTX_set_certs(ctx, cert) -# endif -STACK_OF(X509) * TS_VERIFY_CTX_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) * certs); +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# define TS_VERIFY_CTS_set_certs(ctx, cert) \ + TS_VERIFY_CTX_set_certs(ctx, cert) +# endif +STACK_OF(X509) + * TS_VERIFY_CTX_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) * certs); /*- * If ctx is NULL, it allocates and returns a new object, otherwise @@ -443,28 +458,37 @@ X509 *TS_CONF_load_cert(const char *file); STACK_OF(X509) * TS_CONF_load_certs(const char *file); EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass); const char *TS_CONF_get_tsa_section(CONF *conf, const char *section); -int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb, TS_RESP_CTX *ctx); -# ifndef OPENSSL_NO_ENGINE -int TS_CONF_set_crypto_device(CONF *conf, const char *section, const char *device); +int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb, + TS_RESP_CTX *ctx); +# ifndef OPENSSL_NO_ENGINE +int TS_CONF_set_crypto_device(CONF *conf, const char *section, + const char *device); int TS_CONF_set_default_engine(const char *name); -# endif -int TS_CONF_set_signer_cert(CONF *conf, const char *section, const char *cert, TS_RESP_CTX *ctx); -int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs, TS_RESP_CTX *ctx); -int TS_CONF_set_signer_key(CONF *conf, const char *section, const char *key, const char *pass, +# endif +int TS_CONF_set_signer_cert(CONF *conf, const char *section, const char *cert, + TS_RESP_CTX *ctx); +int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs, + TS_RESP_CTX *ctx); +int TS_CONF_set_signer_key(CONF *conf, const char *section, const char *key, + const char *pass, TS_RESP_CTX *ctx); +int TS_CONF_set_signer_digest(CONF *conf, const char *section, const char *md, + TS_RESP_CTX *ctx); +int TS_CONF_set_def_policy(CONF *conf, const char *section, const char *policy, TS_RESP_CTX *ctx); -int TS_CONF_set_signer_digest(CONF *conf, const char *section, const char *md, TS_RESP_CTX *ctx); -int TS_CONF_set_def_policy(CONF *conf, const char *section, const char *policy, TS_RESP_CTX *ctx); int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx); int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx); int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_clock_precision_digits(const CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_clock_precision_digits(const CONF *conf, const char *section, + TS_RESP_CTX *ctx); int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx); int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_ess_cert_id_digest(CONF *conf, const char *section, TS_RESP_CTX *ctx); +int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section, + TS_RESP_CTX *ctx); +int TS_CONF_set_ess_cert_id_digest(CONF *conf, const char *section, + TS_RESP_CTX *ctx); -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/tserr.h b/libs/OpenSSL/include/openssl/tserr.h index 8430d02e..94d1524a 100644 --- a/libs/OpenSSL/include/openssl/tserr.h +++ b/libs/OpenSSL/include/openssl/tserr.h @@ -21,45 +21,45 @@ /* * TS reason codes. */ -# define TS_R_BAD_PKCS7_TYPE 132 -# define TS_R_BAD_TYPE 133 -# define TS_R_CANNOT_LOAD_CERT 137 -# define TS_R_CANNOT_LOAD_KEY 138 -# define TS_R_CERTIFICATE_VERIFY_ERROR 100 -# define TS_R_COULD_NOT_SET_ENGINE 127 -# define TS_R_COULD_NOT_SET_TIME 115 -# define TS_R_DETACHED_CONTENT 134 -# define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116 -# define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR 139 -# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101 -# define TS_R_INVALID_NULL_POINTER 102 -# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117 -# define TS_R_MESSAGE_IMPRINT_MISMATCH 103 -# define TS_R_NONCE_MISMATCH 104 -# define TS_R_NONCE_NOT_RETURNED 105 -# define TS_R_NO_CONTENT 106 -# define TS_R_NO_TIME_STAMP_TOKEN 107 -# define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118 -# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119 -# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129 -# define TS_R_POLICY_MISMATCH 108 -# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 120 -# define TS_R_RESPONSE_SETUP_ERROR 121 -# define TS_R_SIGNATURE_FAILURE 109 -# define TS_R_THERE_MUST_BE_ONE_SIGNER 110 -# define TS_R_TIME_SYSCALL_ERROR 122 -# define TS_R_TOKEN_NOT_PRESENT 130 -# define TS_R_TOKEN_PRESENT 131 -# define TS_R_TSA_NAME_MISMATCH 111 -# define TS_R_TSA_UNTRUSTED 112 -# define TS_R_TST_INFO_SETUP_ERROR 123 -# define TS_R_TS_DATASIGN 124 -# define TS_R_UNACCEPTABLE_POLICY 125 -# define TS_R_UNSUPPORTED_MD_ALGORITHM 126 -# define TS_R_UNSUPPORTED_VERSION 113 -# define TS_R_VAR_BAD_VALUE 135 -# define TS_R_VAR_LOOKUP_FAILURE 136 -# define TS_R_WRONG_CONTENT_TYPE 114 +# define TS_R_BAD_PKCS7_TYPE 132 +# define TS_R_BAD_TYPE 133 +# define TS_R_CANNOT_LOAD_CERT 137 +# define TS_R_CANNOT_LOAD_KEY 138 +# define TS_R_CERTIFICATE_VERIFY_ERROR 100 +# define TS_R_COULD_NOT_SET_ENGINE 127 +# define TS_R_COULD_NOT_SET_TIME 115 +# define TS_R_DETACHED_CONTENT 134 +# define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116 +# define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR 139 +# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101 +# define TS_R_INVALID_NULL_POINTER 102 +# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117 +# define TS_R_MESSAGE_IMPRINT_MISMATCH 103 +# define TS_R_NONCE_MISMATCH 104 +# define TS_R_NONCE_NOT_RETURNED 105 +# define TS_R_NO_CONTENT 106 +# define TS_R_NO_TIME_STAMP_TOKEN 107 +# define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118 +# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119 +# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129 +# define TS_R_POLICY_MISMATCH 108 +# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 120 +# define TS_R_RESPONSE_SETUP_ERROR 121 +# define TS_R_SIGNATURE_FAILURE 109 +# define TS_R_THERE_MUST_BE_ONE_SIGNER 110 +# define TS_R_TIME_SYSCALL_ERROR 122 +# define TS_R_TOKEN_NOT_PRESENT 130 +# define TS_R_TOKEN_PRESENT 131 +# define TS_R_TSA_NAME_MISMATCH 111 +# define TS_R_TSA_UNTRUSTED 112 +# define TS_R_TST_INFO_SETUP_ERROR 123 +# define TS_R_TS_DATASIGN 124 +# define TS_R_UNACCEPTABLE_POLICY 125 +# define TS_R_UNSUPPORTED_MD_ALGORITHM 126 +# define TS_R_UNSUPPORTED_VERSION 113 +# define TS_R_VAR_BAD_VALUE 135 +# define TS_R_VAR_LOOKUP_FAILURE 136 +# define TS_R_WRONG_CONTENT_TYPE 114 #endif #endif diff --git a/libs/OpenSSL/include/openssl/txt_db.h b/libs/OpenSSL/include/openssl/txt_db.h index 67cc02ac..f20a8830 100644 --- a/libs/OpenSSL/include/openssl/txt_db.h +++ b/libs/OpenSSL/include/openssl/txt_db.h @@ -13,7 +13,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_TXT_DB_H +# define HEADER_TXT_DB_H #endif #include @@ -38,14 +38,14 @@ DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING) typedef struct txt_db_st { - int num_fields; - STACK_OF(OPENSSL_PSTRING) * data; - LHASH_OF(OPENSSL_STRING) * *index; - int (**qual)(OPENSSL_STRING *); - long error; - long arg1; - long arg2; - OPENSSL_STRING *arg_row; + int num_fields; + STACK_OF(OPENSSL_PSTRING) * data; + LHASH_OF(OPENSSL_STRING) * *index; + int (**qual)(OPENSSL_STRING *); + long error; + long arg1; + long arg2; + OPENSSL_STRING *arg_row; } TXT_DB; TXT_DB *TXT_DB_read(BIO *in, int num); diff --git a/libs/OpenSSL/include/openssl/types.h b/libs/OpenSSL/include/openssl/types.h index 8461d096..3c298e03 100644 --- a/libs/OpenSSL/include/openssl/types.h +++ b/libs/OpenSSL/include/openssl/types.h @@ -12,48 +12,48 @@ * See https://github.com/openssl/openssl/issues/9981 */ #ifdef _WIN32 -# define WINCRYPT_USE_SYMBOL_PREFIX -# undef X509_NAME -# undef X509_EXTENSIONS -# undef PKCS7_SIGNER_INFO -# undef OCSP_REQUEST -# undef OCSP_RESPONSE +# define WINCRYPT_USE_SYMBOL_PREFIX +# undef X509_NAME +# undef X509_EXTENSIONS +# undef PKCS7_SIGNER_INFO +# undef OCSP_REQUEST +# undef OCSP_RESPONSE #endif #ifndef OPENSSL_TYPES_H -# define OPENSSL_TYPES_H +# define OPENSSL_TYPES_H -# include +# include -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif -# include -# include -# include +# include +# include +# include typedef struct ossl_provider_st OSSL_PROVIDER; /* Provider Object */ -# ifdef NO_ASN1_TYPEDEFS -# define ASN1_INTEGER ASN1_STRING -# define ASN1_ENUMERATED ASN1_STRING -# define ASN1_BIT_STRING ASN1_STRING -# define ASN1_OCTET_STRING ASN1_STRING -# define ASN1_PRINTABLESTRING ASN1_STRING -# define ASN1_T61STRING ASN1_STRING -# define ASN1_IA5STRING ASN1_STRING -# define ASN1_UTCTIME ASN1_STRING -# define ASN1_GENERALIZEDTIME ASN1_STRING -# define ASN1_TIME ASN1_STRING -# define ASN1_GENERALSTRING ASN1_STRING -# define ASN1_UNIVERSALSTRING ASN1_STRING -# define ASN1_BMPSTRING ASN1_STRING -# define ASN1_VISIBLESTRING ASN1_STRING -# define ASN1_UTF8STRING ASN1_STRING -# define ASN1_BOOLEAN int -# define ASN1_NULL int -# else +# ifdef NO_ASN1_TYPEDEFS +# define ASN1_INTEGER ASN1_STRING +# define ASN1_ENUMERATED ASN1_STRING +# define ASN1_BIT_STRING ASN1_STRING +# define ASN1_OCTET_STRING ASN1_STRING +# define ASN1_PRINTABLESTRING ASN1_STRING +# define ASN1_T61STRING ASN1_STRING +# define ASN1_IA5STRING ASN1_STRING +# define ASN1_UTCTIME ASN1_STRING +# define ASN1_GENERALIZEDTIME ASN1_STRING +# define ASN1_TIME ASN1_STRING +# define ASN1_GENERALSTRING ASN1_STRING +# define ASN1_UNIVERSALSTRING ASN1_STRING +# define ASN1_BMPSTRING ASN1_STRING +# define ASN1_VISIBLESTRING ASN1_STRING +# define ASN1_UTF8STRING ASN1_STRING +# define ASN1_BOOLEAN int +# define ASN1_NULL int +# else typedef struct asn1_string_st ASN1_INTEGER; typedef struct asn1_string_st ASN1_ENUMERATED; typedef struct asn1_string_st ASN1_BIT_STRING; @@ -72,7 +72,7 @@ typedef struct asn1_string_st ASN1_UTF8STRING; typedef struct asn1_string_st ASN1_STRING; typedef int ASN1_BOOLEAN; typedef int ASN1_NULL; -# endif +# endif typedef struct asn1_type_st ASN1_TYPE; typedef struct asn1_object_st ASN1_OBJECT; @@ -82,9 +82,9 @@ typedef struct ASN1_ITEM_st ASN1_ITEM; typedef struct asn1_pctx_st ASN1_PCTX; typedef struct asn1_sctx_st ASN1_SCTX; -# ifdef BIGNUM -# undef BIGNUM -# endif +# ifdef BIGNUM +# undef BIGNUM +# endif typedef struct bio_st BIO; typedef struct bignum_st BIGNUM; @@ -137,21 +137,21 @@ typedef struct hmac_ctx_st HMAC_CTX; typedef struct dh_st DH; typedef struct dh_method DH_METHOD; -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct dsa_st DSA; typedef struct dsa_method DSA_METHOD; -# endif +# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct rsa_st RSA; typedef struct rsa_meth_st RSA_METHOD; -# endif +# endif typedef struct rsa_pss_params_st RSA_PSS_PARAMS; -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct ec_key_st EC_KEY; typedef struct ec_key_method_st EC_KEY_METHOD; -# endif +# endif typedef struct rand_meth_st RAND_METHOD; typedef struct rand_drbg_st RAND_DRBG; @@ -232,8 +232,8 @@ typedef struct ossl_decoder_ctx_st OSSL_DECODER_CTX; typedef struct ossl_self_test_st OSSL_SELF_TEST; -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif /* OPENSSL_TYPES_H */ diff --git a/libs/OpenSSL/include/openssl/ui.h b/libs/OpenSSL/include/openssl/ui.h index 6ba5aa91..bf2dc618 100644 --- a/libs/OpenSSL/include/openssl/ui.h +++ b/libs/OpenSSL/include/openssl/ui.h @@ -16,13 +16,13 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_UI_H +# define HEADER_UI_H #endif #include #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include +# include #endif #include #include @@ -31,9 +31,9 @@ /* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */ #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifdef OPENSSL_NO_UI_CONSOLE -# define OPENSSL_NO_UI -# endif +# ifdef OPENSSL_NO_UI_CONSOLE +# define OPENSSL_NO_UI +# endif #endif #ifdef __cplusplus @@ -95,18 +95,22 @@ void UI_free(UI *ui); On success, the all return an index of the added information. That index is useful when retrieving results with UI_get0_result(). */ -int UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, - int maxsize); -int UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, - int maxsize); -int UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, - int maxsize, const char *test_buf); -int UI_dup_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, int minsize, - int maxsize, const char *test_buf); -int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, const char *ok_chars, - const char *cancel_chars, int flags, char *result_buf); -int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, const char *ok_chars, - const char *cancel_chars, int flags, char *result_buf); +int UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf, + int minsize, int maxsize); +int UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf, + int minsize, int maxsize); +int UI_add_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, + const char *test_buf); +int UI_dup_verify_string(UI *ui, const char *prompt, int flags, + char *result_buf, int minsize, int maxsize, + const char *test_buf); +int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); +int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, + const char *ok_chars, const char *cancel_chars, + int flags, char *result_buf); int UI_add_info_string(UI *ui, const char *text); int UI_dup_info_string(UI *ui, const char *text); int UI_add_error_string(UI *ui, const char *text); @@ -155,7 +159,8 @@ int UI_dup_error_string(UI *ui, const char *text); * * "Enter pass phrase for foo.key:" */ -char *UI_construct_prompt(UI *ui_method, const char *phrase_desc, const char *object_name); +char *UI_construct_prompt(UI *ui_method, const char *phrase_desc, + const char *object_name); /* * The following function is used to store a pointer to user-specific data. @@ -210,8 +215,8 @@ int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void)); #define UI_set_app_data(s, arg) UI_set_ex_data(s, 0, arg) #define UI_get_app_data(s) UI_get_ex_data(s, 0) -#define UI_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef) +#define UI_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef) int UI_set_ex_data(UI *r, int idx, void *arg); void *UI_get_ex_data(const UI *r, int idx); @@ -284,53 +289,69 @@ const UI_METHOD *UI_null(void); typedef struct ui_string_st UI_STRING; SKM_DEFINE_STACK_OF_INTERNAL(UI_STRING, UI_STRING, UI_STRING) -#define sk_UI_STRING_num(sk) OPENSSL_sk_num(ossl_check_const_UI_STRING_sk_type(sk)) -#define sk_UI_STRING_value(sk, idx) \ - ((UI_STRING *)OPENSSL_sk_value(ossl_check_const_UI_STRING_sk_type(sk), (idx))) -#define sk_UI_STRING_new(cmp) \ - ((STACK_OF(UI_STRING) *)OPENSSL_sk_new(ossl_check_UI_STRING_compfunc_type(cmp))) +#define sk_UI_STRING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_value(sk, idx) \ + ((UI_STRING *)OPENSSL_sk_value(ossl_check_const_UI_STRING_sk_type(sk), (idx))) +#define sk_UI_STRING_new(cmp) \ + ((STACK_OF(UI_STRING) *)OPENSSL_sk_new( \ + ossl_check_UI_STRING_compfunc_type(cmp))) #define sk_UI_STRING_new_null() ((STACK_OF(UI_STRING) *)OPENSSL_sk_new_null()) -#define sk_UI_STRING_new_reserve(cmp, n) \ - ((STACK_OF(UI_STRING) *)OPENSSL_sk_new_reserve(ossl_check_UI_STRING_compfunc_type(cmp), (n))) -#define sk_UI_STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_UI_STRING_sk_type(sk), (n)) +#define sk_UI_STRING_new_reserve(cmp, n) \ + ((STACK_OF(UI_STRING) *)OPENSSL_sk_new_reserve( \ + ossl_check_UI_STRING_compfunc_type(cmp), (n))) +#define sk_UI_STRING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_UI_STRING_sk_type(sk), (n)) #define sk_UI_STRING_free(sk) OPENSSL_sk_free(ossl_check_UI_STRING_sk_type(sk)) #define sk_UI_STRING_zero(sk) OPENSSL_sk_zero(ossl_check_UI_STRING_sk_type(sk)) -#define sk_UI_STRING_delete(sk, i) \ - ((UI_STRING *)OPENSSL_sk_delete(ossl_check_UI_STRING_sk_type(sk), (i))) -#define sk_UI_STRING_delete_ptr(sk, ptr) \ - ((UI_STRING *)OPENSSL_sk_delete_ptr(ossl_check_UI_STRING_sk_type(sk), \ - ossl_check_UI_STRING_type(ptr))) -#define sk_UI_STRING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) -#define sk_UI_STRING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) -#define sk_UI_STRING_pop(sk) ((UI_STRING *)OPENSSL_sk_pop(ossl_check_UI_STRING_sk_type(sk))) -#define sk_UI_STRING_shift(sk) ((UI_STRING *)OPENSSL_sk_shift(ossl_check_UI_STRING_sk_type(sk))) -#define sk_UI_STRING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_UI_STRING_sk_type(sk), \ - ossl_check_UI_STRING_freefunc_type(freefunc)) -#define sk_UI_STRING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr), (idx)) -#define sk_UI_STRING_set(sk, idx, ptr) \ - ((UI_STRING *)OPENSSL_sk_set(ossl_check_UI_STRING_sk_type(sk), (idx), \ - ossl_check_UI_STRING_type(ptr))) -#define sk_UI_STRING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) -#define sk_UI_STRING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr)) -#define sk_UI_STRING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_UI_STRING_sk_type(sk), ossl_check_UI_STRING_type(ptr), pnum) +#define sk_UI_STRING_delete(sk, i) \ + ((UI_STRING *)OPENSSL_sk_delete(ossl_check_UI_STRING_sk_type(sk), (i))) +#define sk_UI_STRING_delete_ptr(sk, ptr) \ + ((UI_STRING *)OPENSSL_sk_delete_ptr(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr))) +#define sk_UI_STRING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_pop(sk) \ + ((UI_STRING *)OPENSSL_sk_pop(ossl_check_UI_STRING_sk_type(sk))) +#define sk_UI_STRING_shift(sk) \ + ((UI_STRING *)OPENSSL_sk_shift(ossl_check_UI_STRING_sk_type(sk))) +#define sk_UI_STRING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_freefunc_type(freefunc)) +#define sk_UI_STRING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr), (idx)) +#define sk_UI_STRING_set(sk, idx, ptr) \ + ((UI_STRING *)OPENSSL_sk_set(ossl_check_UI_STRING_sk_type(sk), (idx), \ + ossl_check_UI_STRING_type(ptr))) +#define sk_UI_STRING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr)) +#define sk_UI_STRING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_type(ptr), pnum) #define sk_UI_STRING_sort(sk) OPENSSL_sk_sort(ossl_check_UI_STRING_sk_type(sk)) -#define sk_UI_STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_UI_STRING_sk_type(sk)) -#define sk_UI_STRING_dup(sk) \ - ((STACK_OF(UI_STRING) *)OPENSSL_sk_dup(ossl_check_const_UI_STRING_sk_type(sk))) -#define sk_UI_STRING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(UI_STRING) *)OPENSSL_sk_deep_copy(ossl_check_const_UI_STRING_sk_type(sk), \ - ossl_check_UI_STRING_copyfunc_type(copyfunc), \ - ossl_check_UI_STRING_freefunc_type(freefunc))) -#define sk_UI_STRING_set_cmp_func(sk, cmp) \ - ((sk_UI_STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_UI_STRING_sk_type(sk), \ - ossl_check_UI_STRING_compfunc_type(cmp))) +#define sk_UI_STRING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_UI_STRING_sk_type(sk)) +#define sk_UI_STRING_dup(sk) \ + ((STACK_OF(UI_STRING) *)OPENSSL_sk_dup( \ + ossl_check_const_UI_STRING_sk_type(sk))) +#define sk_UI_STRING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(UI_STRING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_copyfunc_type(copyfunc), \ + ossl_check_UI_STRING_freefunc_type(freefunc))) +#define sk_UI_STRING_set_cmp_func(sk, cmp) \ + ((sk_UI_STRING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_UI_STRING_sk_type(sk), \ + ossl_check_UI_STRING_compfunc_type(cmp))) /* * The different types of strings that are currently supported. This is only @@ -338,35 +359,39 @@ SKM_DEFINE_STACK_OF_INTERNAL(UI_STRING, UI_STRING, UI_STRING) */ enum UI_string_types { - UIT_NONE = 0, - UIT_PROMPT, /* Prompt for a string */ - UIT_VERIFY, /* Prompt for a string and verify */ - UIT_BOOLEAN, /* Prompt for a yes/no response */ - UIT_INFO, /* Send info to the user */ - UIT_ERROR /* Send an error message to the user */ + UIT_NONE = 0, + UIT_PROMPT, /* Prompt for a string */ + UIT_VERIFY, /* Prompt for a string and verify */ + UIT_BOOLEAN, /* Prompt for a yes/no response */ + UIT_INFO, /* Send info to the user */ + UIT_ERROR /* Send an error message to the user */ }; /* Create and manipulate methods */ UI_METHOD *UI_create_method(const char *name); void UI_destroy_method(UI_METHOD *ui_method); int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)); -int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)); +int UI_method_set_writer(UI_METHOD *method, + int (*writer)(UI *ui, UI_STRING *uis)); int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)); -int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)); +int UI_method_set_reader(UI_METHOD *method, + int (*reader)(UI *ui, UI_STRING *uis)); int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); -int UI_method_set_data_duplicator(UI_METHOD *method, void *(*duplicator)(UI *ui, void *ui_data), +int UI_method_set_data_duplicator(UI_METHOD *method, + void *(*duplicator)(UI *ui, void *ui_data), void (*destructor)(UI *ui, void *ui_data)); -int UI_method_set_prompt_constructor(UI_METHOD *method, - char *(*prompt_constructor)(UI *ui, const char *phrase_desc, - const char *object_name)); +int UI_method_set_prompt_constructor( + UI_METHOD *method, + char *(*prompt_constructor)(UI *ui, const char *phrase_desc, + const char *object_name)); int UI_method_set_ex_data(UI_METHOD *method, int idx, void *data); int (*UI_method_get_opener(const UI_METHOD *method))(UI *); int (*UI_method_get_writer(const UI_METHOD *method))(UI *, UI_STRING *); int (*UI_method_get_flusher(const UI_METHOD *method))(UI *); int (*UI_method_get_reader(const UI_METHOD *method))(UI *, UI_STRING *); int (*UI_method_get_closer(const UI_METHOD *method))(UI *); -char *(*UI_method_get_prompt_constructor(const UI_METHOD *method))(UI *, const char *, - const char *); +char *(*UI_method_get_prompt_constructor(const UI_METHOD *method))( + UI *, const char *, const char *); void *(*UI_method_get_data_duplicator(const UI_METHOD *method))(UI *, void *); void (*UI_method_get_data_destructor(const UI_METHOD *method))(UI *, void *); const void *UI_method_get_ex_data(const UI_METHOD *method, int idx); @@ -403,8 +428,10 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result); int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len); /* A couple of popular utility functions */ -int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify); -int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify); +int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, + int verify); +int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, + int verify); UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag); #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/whrlpool.h b/libs/OpenSSL/include/openssl/whrlpool.h index 25d2e647..fe43ac1e 100644 --- a/libs/OpenSSL/include/openssl/whrlpool.h +++ b/libs/OpenSSL/include/openssl/whrlpool.h @@ -13,49 +13,52 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_WHRLPOOL_H +# define HEADER_WHRLPOOL_H #endif #include #ifndef OPENSSL_NO_WHIRLPOOL -# include -# include -# ifdef __cplusplus +# include +# include +# ifdef __cplusplus extern "C" { -# endif +# endif -# define WHIRLPOOL_DIGEST_LENGTH (512 / 8) +# define WHIRLPOOL_DIGEST_LENGTH (512 / 8) -# if !defined(OPENSSL_NO_DEPRECATED_3_0) +# if !defined(OPENSSL_NO_DEPRECATED_3_0) -# define WHIRLPOOL_BBLOCK 512 -# define WHIRLPOOL_COUNTER (256 / 8) +# define WHIRLPOOL_BBLOCK 512 +# define WHIRLPOOL_COUNTER (256 / 8) typedef struct { - union - { - unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; - /* double q is here to ensure 64-bit alignment */ - double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; - } H; - unsigned char data[WHIRLPOOL_BBLOCK / 8]; - unsigned int bitoff; - size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; + union + { + unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; + /* double q is here to ensure 64-bit alignment */ + double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; + } H; + unsigned char data[WHIRLPOOL_BBLOCK / 8]; + unsigned int bitoff; + size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; } WHIRLPOOL_CTX; -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); -OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes); -OSSL_DEPRECATEDIN_3_0 void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits); +OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, + size_t bytes); +OSSL_DEPRECATEDIN_3_0 void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, + const void *inp, size_t bits); OSSL_DEPRECATEDIN_3_0 int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); -OSSL_DEPRECATEDIN_3_0 unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md); -# endif +OSSL_DEPRECATEDIN_3_0 unsigned char *WHIRLPOOL(const void *inp, size_t bytes, + unsigned char *md); +# endif -# ifdef __cplusplus +# ifdef __cplusplus } -# endif +# endif #endif #endif diff --git a/libs/OpenSSL/include/openssl/x509.h b/libs/OpenSSL/include/openssl/x509.h index 5e901c41..56c04298 100644 --- a/libs/OpenSSL/include/openssl/x509.h +++ b/libs/OpenSSL/include/openssl/x509.h @@ -17,7 +17,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_X509_H +# define HEADER_X509_H #endif #include @@ -31,15 +31,15 @@ #include #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# include -# include -# include +# include +# include +# include #endif #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -48,196 +48,255 @@ extern "C" { /* Needed stacks for types defined in other headers */ SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME, X509_NAME, X509_NAME) -#define sk_X509_NAME_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_sk_type(sk)) -#define sk_X509_NAME_value(sk, idx) \ - ((X509_NAME *)OPENSSL_sk_value(ossl_check_const_X509_NAME_sk_type(sk), (idx))) -#define sk_X509_NAME_new(cmp) \ - ((STACK_OF(X509_NAME) *)OPENSSL_sk_new(ossl_check_X509_NAME_compfunc_type(cmp))) +#define sk_X509_NAME_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_value(sk, idx) \ + ((X509_NAME *)OPENSSL_sk_value(ossl_check_const_X509_NAME_sk_type(sk), (idx))) +#define sk_X509_NAME_new(cmp) \ + ((STACK_OF(X509_NAME) *)OPENSSL_sk_new( \ + ossl_check_X509_NAME_compfunc_type(cmp))) #define sk_X509_NAME_new_null() ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_null()) -#define sk_X509_NAME_new_reserve(cmp, n) \ - ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_reserve(ossl_check_X509_NAME_compfunc_type(cmp), (n))) -#define sk_X509_NAME_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_NAME_sk_type(sk), (n)) +#define sk_X509_NAME_new_reserve(cmp, n) \ + ((STACK_OF(X509_NAME) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_NAME_compfunc_type(cmp), (n))) +#define sk_X509_NAME_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_NAME_sk_type(sk), (n)) #define sk_X509_NAME_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_sk_type(sk)) #define sk_X509_NAME_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_sk_type(sk)) -#define sk_X509_NAME_delete(sk, i) \ - ((X509_NAME *)OPENSSL_sk_delete(ossl_check_X509_NAME_sk_type(sk), (i))) -#define sk_X509_NAME_delete_ptr(sk, ptr) \ - ((X509_NAME *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_sk_type(sk), \ - ossl_check_X509_NAME_type(ptr))) -#define sk_X509_NAME_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) -#define sk_X509_NAME_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) -#define sk_X509_NAME_pop(sk) ((X509_NAME *)OPENSSL_sk_pop(ossl_check_X509_NAME_sk_type(sk))) -#define sk_X509_NAME_shift(sk) ((X509_NAME *)OPENSSL_sk_shift(ossl_check_X509_NAME_sk_type(sk))) -#define sk_X509_NAME_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_NAME_sk_type(sk), \ - ossl_check_X509_NAME_freefunc_type(freefunc)) -#define sk_X509_NAME_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr), (idx)) -#define sk_X509_NAME_set(sk, idx, ptr) \ - ((X509_NAME *)OPENSSL_sk_set(ossl_check_X509_NAME_sk_type(sk), (idx), \ - ossl_check_X509_NAME_type(ptr))) -#define sk_X509_NAME_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) -#define sk_X509_NAME_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr)) -#define sk_X509_NAME_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_NAME_sk_type(sk), ossl_check_X509_NAME_type(ptr), pnum) +#define sk_X509_NAME_delete(sk, i) \ + ((X509_NAME *)OPENSSL_sk_delete(ossl_check_X509_NAME_sk_type(sk), (i))) +#define sk_X509_NAME_delete_ptr(sk, ptr) \ + ((X509_NAME *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr))) +#define sk_X509_NAME_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_pop(sk) \ + ((X509_NAME *)OPENSSL_sk_pop(ossl_check_X509_NAME_sk_type(sk))) +#define sk_X509_NAME_shift(sk) \ + ((X509_NAME *)OPENSSL_sk_shift(ossl_check_X509_NAME_sk_type(sk))) +#define sk_X509_NAME_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_freefunc_type(freefunc)) +#define sk_X509_NAME_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr), (idx)) +#define sk_X509_NAME_set(sk, idx, ptr) \ + ((X509_NAME *)OPENSSL_sk_set(ossl_check_X509_NAME_sk_type(sk), (idx), \ + ossl_check_X509_NAME_type(ptr))) +#define sk_X509_NAME_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr)) +#define sk_X509_NAME_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_type(ptr), pnum) #define sk_X509_NAME_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_sk_type(sk)) -#define sk_X509_NAME_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_sk_type(sk)) -#define sk_X509_NAME_dup(sk) \ - ((STACK_OF(X509_NAME) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_sk_type(sk))) -#define sk_X509_NAME_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_NAME) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_NAME_sk_type(sk), \ - ossl_check_X509_NAME_copyfunc_type(copyfunc), \ - ossl_check_X509_NAME_freefunc_type(freefunc))) -#define sk_X509_NAME_set_cmp_func(sk, cmp) \ - ((sk_X509_NAME_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_NAME_sk_type(sk), \ - ossl_check_X509_NAME_compfunc_type(cmp))) +#define sk_X509_NAME_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_sk_type(sk)) +#define sk_X509_NAME_dup(sk) \ + ((STACK_OF(X509_NAME) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_NAME_sk_type(sk))) +#define sk_X509_NAME_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_NAME) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_copyfunc_type(copyfunc), \ + ossl_check_X509_NAME_freefunc_type(freefunc))) +#define sk_X509_NAME_set_cmp_func(sk, cmp) \ + ((sk_X509_NAME_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_NAME_sk_type(sk), \ + ossl_check_X509_NAME_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(X509, X509, X509) #define sk_X509_num(sk) OPENSSL_sk_num(ossl_check_const_X509_sk_type(sk)) -#define sk_X509_value(sk, idx) ((X509 *)OPENSSL_sk_value(ossl_check_const_X509_sk_type(sk), (idx))) -#define sk_X509_new(cmp) ((STACK_OF(X509) *)OPENSSL_sk_new(ossl_check_X509_compfunc_type(cmp))) +#define sk_X509_value(sk, idx) \ + ((X509 *)OPENSSL_sk_value(ossl_check_const_X509_sk_type(sk), (idx))) +#define sk_X509_new(cmp) \ + ((STACK_OF(X509) *)OPENSSL_sk_new(ossl_check_X509_compfunc_type(cmp))) #define sk_X509_new_null() ((STACK_OF(X509) *)OPENSSL_sk_new_null()) -#define sk_X509_new_reserve(cmp, n) \ - ((STACK_OF(X509) *)OPENSSL_sk_new_reserve(ossl_check_X509_compfunc_type(cmp), (n))) -#define sk_X509_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_sk_type(sk), (n)) +#define sk_X509_new_reserve(cmp, n) \ + ((STACK_OF(X509) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_compfunc_type(cmp), (n))) +#define sk_X509_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_sk_type(sk), (n)) #define sk_X509_free(sk) OPENSSL_sk_free(ossl_check_X509_sk_type(sk)) #define sk_X509_zero(sk) OPENSSL_sk_zero(ossl_check_X509_sk_type(sk)) -#define sk_X509_delete(sk, i) ((X509 *)OPENSSL_sk_delete(ossl_check_X509_sk_type(sk), (i))) -#define sk_X509_delete_ptr(sk, ptr) \ - ((X509 *)OPENSSL_sk_delete_ptr(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr))) -#define sk_X509_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) -#define sk_X509_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_delete(sk, i) \ + ((X509 *)OPENSSL_sk_delete(ossl_check_X509_sk_type(sk), (i))) +#define sk_X509_delete_ptr(sk, ptr) \ + ((X509 *)OPENSSL_sk_delete_ptr(ossl_check_X509_sk_type(sk), \ + ossl_check_X509_type(ptr))) +#define sk_X509_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) #define sk_X509_pop(sk) ((X509 *)OPENSSL_sk_pop(ossl_check_X509_sk_type(sk))) -#define sk_X509_shift(sk) ((X509 *)OPENSSL_sk_shift(ossl_check_X509_sk_type(sk))) -#define sk_X509_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_sk_type(sk), ossl_check_X509_freefunc_type(freefunc)) -#define sk_X509_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), (idx)) -#define sk_X509_set(sk, idx, ptr) \ - ((X509 *)OPENSSL_sk_set(ossl_check_X509_sk_type(sk), (idx), ossl_check_X509_type(ptr))) -#define sk_X509_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) -#define sk_X509_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) -#define sk_X509_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), pnum) +#define sk_X509_shift(sk) \ + ((X509 *)OPENSSL_sk_shift(ossl_check_X509_sk_type(sk))) +#define sk_X509_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_sk_type(sk), \ + ossl_check_X509_freefunc_type(freefunc)) +#define sk_X509_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), \ + (idx)) +#define sk_X509_set(sk, idx, ptr) \ + ((X509 *)OPENSSL_sk_set(ossl_check_X509_sk_type(sk), (idx), \ + ossl_check_X509_type(ptr))) +#define sk_X509_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr)) +#define sk_X509_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_sk_type(sk), ossl_check_X509_type(ptr), \ + pnum) #define sk_X509_sort(sk) OPENSSL_sk_sort(ossl_check_X509_sk_type(sk)) -#define sk_X509_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_sk_type(sk)) -#define sk_X509_dup(sk) ((STACK_OF(X509) *)OPENSSL_sk_dup(ossl_check_const_X509_sk_type(sk))) -#define sk_X509_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_sk_type(sk), \ - ossl_check_X509_copyfunc_type(copyfunc), \ - ossl_check_X509_freefunc_type(freefunc))) -#define sk_X509_set_cmp_func(sk, cmp) \ - ((sk_X509_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_sk_type(sk), \ - ossl_check_X509_compfunc_type(cmp))) +#define sk_X509_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_sk_type(sk)) +#define sk_X509_dup(sk) \ + ((STACK_OF(X509) *)OPENSSL_sk_dup(ossl_check_const_X509_sk_type(sk))) +#define sk_X509_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_sk_type(sk), \ + ossl_check_X509_copyfunc_type(copyfunc), \ + ossl_check_X509_freefunc_type(freefunc))) +#define sk_X509_set_cmp_func(sk, cmp) \ + ((sk_X509_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_sk_type(sk), ossl_check_X509_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(X509_REVOKED, X509_REVOKED, X509_REVOKED) -#define sk_X509_REVOKED_num(sk) OPENSSL_sk_num(ossl_check_const_X509_REVOKED_sk_type(sk)) -#define sk_X509_REVOKED_value(sk, idx) \ - ((X509_REVOKED *)OPENSSL_sk_value(ossl_check_const_X509_REVOKED_sk_type(sk), (idx))) -#define sk_X509_REVOKED_new(cmp) \ - ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new(ossl_check_X509_REVOKED_compfunc_type(cmp))) -#define sk_X509_REVOKED_new_null() ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_null()) -#define sk_X509_REVOKED_new_reserve(cmp, n) \ - ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_reserve(ossl_check_X509_REVOKED_compfunc_type(cmp), \ - (n))) -#define sk_X509_REVOKED_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_REVOKED_sk_type(sk), (n)) -#define sk_X509_REVOKED_free(sk) OPENSSL_sk_free(ossl_check_X509_REVOKED_sk_type(sk)) -#define sk_X509_REVOKED_zero(sk) OPENSSL_sk_zero(ossl_check_X509_REVOKED_sk_type(sk)) -#define sk_X509_REVOKED_delete(sk, i) \ - ((X509_REVOKED *)OPENSSL_sk_delete(ossl_check_X509_REVOKED_sk_type(sk), (i))) -#define sk_X509_REVOKED_delete_ptr(sk, ptr) \ - ((X509_REVOKED *)OPENSSL_sk_delete_ptr(ossl_check_X509_REVOKED_sk_type(sk), \ - ossl_check_X509_REVOKED_type(ptr))) -#define sk_X509_REVOKED_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) -#define sk_X509_REVOKED_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) -#define sk_X509_REVOKED_pop(sk) \ - ((X509_REVOKED *)OPENSSL_sk_pop(ossl_check_X509_REVOKED_sk_type(sk))) -#define sk_X509_REVOKED_shift(sk) \ - ((X509_REVOKED *)OPENSSL_sk_shift(ossl_check_X509_REVOKED_sk_type(sk))) -#define sk_X509_REVOKED_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_REVOKED_sk_type(sk), \ - ossl_check_X509_REVOKED_freefunc_type(freefunc)) -#define sk_X509_REVOKED_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr), (idx)) -#define sk_X509_REVOKED_set(sk, idx, ptr) \ - ((X509_REVOKED *)OPENSSL_sk_set(ossl_check_X509_REVOKED_sk_type(sk), (idx), \ - ossl_check_X509_REVOKED_type(ptr))) -#define sk_X509_REVOKED_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) -#define sk_X509_REVOKED_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr)) -#define sk_X509_REVOKED_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_type(ptr), \ - pnum) -#define sk_X509_REVOKED_sort(sk) OPENSSL_sk_sort(ossl_check_X509_REVOKED_sk_type(sk)) -#define sk_X509_REVOKED_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_REVOKED_sk_type(sk)) -#define sk_X509_REVOKED_dup(sk) \ - ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_dup(ossl_check_const_X509_REVOKED_sk_type(sk))) -#define sk_X509_REVOKED_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_REVOKED_sk_type(sk), \ - ossl_check_X509_REVOKED_copyfunc_type(copyfunc), \ - ossl_check_X509_REVOKED_freefunc_type(freefunc))) -#define sk_X509_REVOKED_set_cmp_func(sk, cmp) \ - ((sk_X509_REVOKED_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_REVOKED_sk_type(sk), ossl_check_X509_REVOKED_compfunc_type(cmp))) +#define sk_X509_REVOKED_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_value(sk, idx) \ + ((X509_REVOKED *)OPENSSL_sk_value(ossl_check_const_X509_REVOKED_sk_type(sk), \ + (idx))) +#define sk_X509_REVOKED_new(cmp) \ + ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new( \ + ossl_check_X509_REVOKED_compfunc_type(cmp))) +#define sk_X509_REVOKED_new_null() \ + ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_null()) +#define sk_X509_REVOKED_new_reserve(cmp, n) \ + ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_REVOKED_compfunc_type(cmp), (n))) +#define sk_X509_REVOKED_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_REVOKED_sk_type(sk), (n)) +#define sk_X509_REVOKED_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_delete(sk, i) \ + ((X509_REVOKED *)OPENSSL_sk_delete(ossl_check_X509_REVOKED_sk_type(sk), (i))) +#define sk_X509_REVOKED_delete_ptr(sk, ptr) \ + ((X509_REVOKED *)OPENSSL_sk_delete_ptr(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr))) +#define sk_X509_REVOKED_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_pop(sk) \ + ((X509_REVOKED *)OPENSSL_sk_pop(ossl_check_X509_REVOKED_sk_type(sk))) +#define sk_X509_REVOKED_shift(sk) \ + ((X509_REVOKED *)OPENSSL_sk_shift(ossl_check_X509_REVOKED_sk_type(sk))) +#define sk_X509_REVOKED_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_freefunc_type(freefunc)) +#define sk_X509_REVOKED_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr), (idx)) +#define sk_X509_REVOKED_set(sk, idx, ptr) \ + ((X509_REVOKED *)OPENSSL_sk_set(ossl_check_X509_REVOKED_sk_type(sk), (idx), \ + ossl_check_X509_REVOKED_type(ptr))) +#define sk_X509_REVOKED_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr)) +#define sk_X509_REVOKED_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_type(ptr), pnum) +#define sk_X509_REVOKED_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_REVOKED_sk_type(sk)) +#define sk_X509_REVOKED_dup(sk) \ + ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_REVOKED_sk_type(sk))) +#define sk_X509_REVOKED_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_REVOKED) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_copyfunc_type(copyfunc), \ + ossl_check_X509_REVOKED_freefunc_type(freefunc))) +#define sk_X509_REVOKED_set_cmp_func(sk, cmp) \ + ((sk_X509_REVOKED_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_REVOKED_sk_type(sk), \ + ossl_check_X509_REVOKED_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(X509_CRL, X509_CRL, X509_CRL) -#define sk_X509_CRL_num(sk) OPENSSL_sk_num(ossl_check_const_X509_CRL_sk_type(sk)) -#define sk_X509_CRL_value(sk, idx) \ - ((X509_CRL *)OPENSSL_sk_value(ossl_check_const_X509_CRL_sk_type(sk), (idx))) -#define sk_X509_CRL_new(cmp) \ - ((STACK_OF(X509_CRL) *)OPENSSL_sk_new(ossl_check_X509_CRL_compfunc_type(cmp))) +#define sk_X509_CRL_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_value(sk, idx) \ + ((X509_CRL *)OPENSSL_sk_value(ossl_check_const_X509_CRL_sk_type(sk), (idx))) +#define sk_X509_CRL_new(cmp) \ + ((STACK_OF(X509_CRL) *)OPENSSL_sk_new(ossl_check_X509_CRL_compfunc_type(cmp))) #define sk_X509_CRL_new_null() ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_null()) -#define sk_X509_CRL_new_reserve(cmp, n) \ - ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_reserve(ossl_check_X509_CRL_compfunc_type(cmp), (n))) -#define sk_X509_CRL_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_CRL_sk_type(sk), (n)) +#define sk_X509_CRL_new_reserve(cmp, n) \ + ((STACK_OF(X509_CRL) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_CRL_compfunc_type(cmp), (n))) +#define sk_X509_CRL_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_CRL_sk_type(sk), (n)) #define sk_X509_CRL_free(sk) OPENSSL_sk_free(ossl_check_X509_CRL_sk_type(sk)) #define sk_X509_CRL_zero(sk) OPENSSL_sk_zero(ossl_check_X509_CRL_sk_type(sk)) -#define sk_X509_CRL_delete(sk, i) \ - ((X509_CRL *)OPENSSL_sk_delete(ossl_check_X509_CRL_sk_type(sk), (i))) -#define sk_X509_CRL_delete_ptr(sk, ptr) \ - ((X509_CRL *)OPENSSL_sk_delete_ptr(ossl_check_X509_CRL_sk_type(sk), \ - ossl_check_X509_CRL_type(ptr))) -#define sk_X509_CRL_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) -#define sk_X509_CRL_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) -#define sk_X509_CRL_pop(sk) ((X509_CRL *)OPENSSL_sk_pop(ossl_check_X509_CRL_sk_type(sk))) -#define sk_X509_CRL_shift(sk) ((X509_CRL *)OPENSSL_sk_shift(ossl_check_X509_CRL_sk_type(sk))) -#define sk_X509_CRL_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_CRL_sk_type(sk), \ - ossl_check_X509_CRL_freefunc_type(freefunc)) -#define sk_X509_CRL_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr), (idx)) -#define sk_X509_CRL_set(sk, idx, ptr) \ - ((X509_CRL *)OPENSSL_sk_set(ossl_check_X509_CRL_sk_type(sk), (idx), \ - ossl_check_X509_CRL_type(ptr))) -#define sk_X509_CRL_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) -#define sk_X509_CRL_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr)) -#define sk_X509_CRL_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_CRL_sk_type(sk), ossl_check_X509_CRL_type(ptr), pnum) +#define sk_X509_CRL_delete(sk, i) \ + ((X509_CRL *)OPENSSL_sk_delete(ossl_check_X509_CRL_sk_type(sk), (i))) +#define sk_X509_CRL_delete_ptr(sk, ptr) \ + ((X509_CRL *)OPENSSL_sk_delete_ptr(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr))) +#define sk_X509_CRL_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_pop(sk) \ + ((X509_CRL *)OPENSSL_sk_pop(ossl_check_X509_CRL_sk_type(sk))) +#define sk_X509_CRL_shift(sk) \ + ((X509_CRL *)OPENSSL_sk_shift(ossl_check_X509_CRL_sk_type(sk))) +#define sk_X509_CRL_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_freefunc_type(freefunc)) +#define sk_X509_CRL_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr), (idx)) +#define sk_X509_CRL_set(sk, idx, ptr) \ + ((X509_CRL *)OPENSSL_sk_set(ossl_check_X509_CRL_sk_type(sk), (idx), \ + ossl_check_X509_CRL_type(ptr))) +#define sk_X509_CRL_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr)) +#define sk_X509_CRL_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_type(ptr), pnum) #define sk_X509_CRL_sort(sk) OPENSSL_sk_sort(ossl_check_X509_CRL_sk_type(sk)) -#define sk_X509_CRL_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_CRL_sk_type(sk)) -#define sk_X509_CRL_dup(sk) \ - ((STACK_OF(X509_CRL) *)OPENSSL_sk_dup(ossl_check_const_X509_CRL_sk_type(sk))) -#define sk_X509_CRL_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_CRL) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_CRL_sk_type(sk), \ - ossl_check_X509_CRL_copyfunc_type(copyfunc), \ - ossl_check_X509_CRL_freefunc_type(freefunc))) -#define sk_X509_CRL_set_cmp_func(sk, cmp) \ - ((sk_X509_CRL_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_CRL_sk_type(sk), \ - ossl_check_X509_CRL_compfunc_type(cmp))) +#define sk_X509_CRL_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_CRL_sk_type(sk)) +#define sk_X509_CRL_dup(sk) \ + ((STACK_OF(X509_CRL) *)OPENSSL_sk_dup(ossl_check_const_X509_CRL_sk_type(sk))) +#define sk_X509_CRL_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_CRL) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_copyfunc_type(copyfunc), \ + ossl_check_X509_CRL_freefunc_type(freefunc))) +#define sk_X509_CRL_set_cmp_func(sk, cmp) \ + ((sk_X509_CRL_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_CRL_sk_type(sk), \ + ossl_check_X509_CRL_compfunc_type(cmp))) /* Flags for X509_get_signature_info() */ /* Signature info is valid */ @@ -262,16 +321,16 @@ SKM_DEFINE_STACK_OF_INTERNAL(X509_CRL, X509_CRL, X509_CRL) struct X509_algor_st { - ASN1_OBJECT *algorithm; - ASN1_TYPE *parameter; + ASN1_OBJECT *algorithm; + ASN1_TYPE *parameter; } /* X509_ALGOR */; typedef STACK_OF(X509_ALGOR) X509_ALGORS; typedef struct X509_val_st { - ASN1_TIME *notBefore; - ASN1_TIME *notAfter; + ASN1_TIME *notBefore; + ASN1_TIME *notAfter; } X509_VAL; typedef struct X509_sig_st X509_SIG; @@ -279,180 +338,228 @@ typedef struct X509_sig_st X509_SIG; typedef struct X509_name_entry_st X509_NAME_ENTRY; SKM_DEFINE_STACK_OF_INTERNAL(X509_NAME_ENTRY, X509_NAME_ENTRY, X509_NAME_ENTRY) -#define sk_X509_NAME_ENTRY_num(sk) OPENSSL_sk_num(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)) -#define sk_X509_NAME_ENTRY_value(sk, idx) \ - ((X509_NAME_ENTRY *)OPENSSL_sk_value(ossl_check_const_X509_NAME_ENTRY_sk_type(sk), (idx))) -#define sk_X509_NAME_ENTRY_new(cmp) \ - ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new(ossl_check_X509_NAME_ENTRY_compfunc_type(cmp))) -#define sk_X509_NAME_ENTRY_new_null() ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_null()) -#define sk_X509_NAME_ENTRY_new_reserve(cmp, n) \ - ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_reserve( \ - ossl_check_X509_NAME_ENTRY_compfunc_type(cmp), (n))) -#define sk_X509_NAME_ENTRY_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_X509_NAME_ENTRY_sk_type(sk), (n)) -#define sk_X509_NAME_ENTRY_free(sk) OPENSSL_sk_free(ossl_check_X509_NAME_ENTRY_sk_type(sk)) -#define sk_X509_NAME_ENTRY_zero(sk) OPENSSL_sk_zero(ossl_check_X509_NAME_ENTRY_sk_type(sk)) -#define sk_X509_NAME_ENTRY_delete(sk, i) \ - ((X509_NAME_ENTRY *)OPENSSL_sk_delete(ossl_check_X509_NAME_ENTRY_sk_type(sk), (i))) -#define sk_X509_NAME_ENTRY_delete_ptr(sk, ptr) \ - ((X509_NAME_ENTRY *)OPENSSL_sk_delete_ptr(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ - ossl_check_X509_NAME_ENTRY_type(ptr))) -#define sk_X509_NAME_ENTRY_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) -#define sk_X509_NAME_ENTRY_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) -#define sk_X509_NAME_ENTRY_pop(sk) \ - ((X509_NAME_ENTRY *)OPENSSL_sk_pop(ossl_check_X509_NAME_ENTRY_sk_type(sk))) -#define sk_X509_NAME_ENTRY_shift(sk) \ - ((X509_NAME_ENTRY *)OPENSSL_sk_shift(ossl_check_X509_NAME_ENTRY_sk_type(sk))) -#define sk_X509_NAME_ENTRY_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ - ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc)) -#define sk_X509_NAME_ENTRY_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ - ossl_check_X509_NAME_ENTRY_type(ptr), (idx)) -#define sk_X509_NAME_ENTRY_set(sk, idx, ptr) \ - ((X509_NAME_ENTRY *)OPENSSL_sk_set(ossl_check_X509_NAME_ENTRY_sk_type(sk), (idx), \ - ossl_check_X509_NAME_ENTRY_type(ptr))) -#define sk_X509_NAME_ENTRY_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) -#define sk_X509_NAME_ENTRY_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_type(ptr)) -#define sk_X509_NAME_ENTRY_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ - ossl_check_X509_NAME_ENTRY_type(ptr), pnum) -#define sk_X509_NAME_ENTRY_sort(sk) OPENSSL_sk_sort(ossl_check_X509_NAME_ENTRY_sk_type(sk)) -#define sk_X509_NAME_ENTRY_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)) -#define sk_X509_NAME_ENTRY_dup(sk) \ - ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_dup(ossl_check_const_X509_NAME_ENTRY_sk_type(sk))) -#define sk_X509_NAME_ENTRY_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_NAME_ENTRY_sk_type(sk), \ - ossl_check_X509_NAME_ENTRY_copyfunc_type(copyfunc), \ - ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc))) -#define sk_X509_NAME_ENTRY_set_cmp_func(sk, cmp) \ - ((sk_X509_NAME_ENTRY_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_NAME_ENTRY_sk_type(sk), ossl_check_X509_NAME_ENTRY_compfunc_type(cmp))) +#define sk_X509_NAME_ENTRY_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_value(sk, idx) \ + ((X509_NAME_ENTRY *)OPENSSL_sk_value( \ + ossl_check_const_X509_NAME_ENTRY_sk_type(sk), (idx))) +#define sk_X509_NAME_ENTRY_new(cmp) \ + ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new( \ + ossl_check_X509_NAME_ENTRY_compfunc_type(cmp))) +#define sk_X509_NAME_ENTRY_new_null() \ + ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_null()) +#define sk_X509_NAME_ENTRY_new_reserve(cmp, n) \ + ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_NAME_ENTRY_compfunc_type(cmp), (n))) +#define sk_X509_NAME_ENTRY_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_NAME_ENTRY_sk_type(sk), (n)) +#define sk_X509_NAME_ENTRY_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_delete(sk, i) \ + ((X509_NAME_ENTRY *)OPENSSL_sk_delete( \ + ossl_check_X509_NAME_ENTRY_sk_type(sk), (i))) +#define sk_X509_NAME_ENTRY_delete_ptr(sk, ptr) \ + ((X509_NAME_ENTRY *)OPENSSL_sk_delete_ptr( \ + ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr))) +#define sk_X509_NAME_ENTRY_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_pop(sk) \ + ((X509_NAME_ENTRY *)OPENSSL_sk_pop(ossl_check_X509_NAME_ENTRY_sk_type(sk))) +#define sk_X509_NAME_ENTRY_shift(sk) \ + ((X509_NAME_ENTRY *)OPENSSL_sk_shift(ossl_check_X509_NAME_ENTRY_sk_type(sk))) +#define sk_X509_NAME_ENTRY_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc)) +#define sk_X509_NAME_ENTRY_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr), (idx)) +#define sk_X509_NAME_ENTRY_set(sk, idx, ptr) \ + ((X509_NAME_ENTRY *)OPENSSL_sk_set(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + (idx), \ + ossl_check_X509_NAME_ENTRY_type(ptr))) +#define sk_X509_NAME_ENTRY_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr)) +#define sk_X509_NAME_ENTRY_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_type(ptr), pnum) +#define sk_X509_NAME_ENTRY_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_NAME_ENTRY_sk_type(sk)) +#define sk_X509_NAME_ENTRY_dup(sk) \ + ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_NAME_ENTRY_sk_type(sk))) +#define sk_X509_NAME_ENTRY_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_NAME_ENTRY) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_copyfunc_type(copyfunc), \ + ossl_check_X509_NAME_ENTRY_freefunc_type(freefunc))) +#define sk_X509_NAME_ENTRY_set_cmp_func(sk, cmp) \ + ((sk_X509_NAME_ENTRY_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_NAME_ENTRY_sk_type(sk), \ + ossl_check_X509_NAME_ENTRY_compfunc_type(cmp))) #define X509_EX_V_NETSCAPE_HACK 0x8000 #define X509_EX_V_INIT 0x0001 typedef struct X509_extension_st X509_EXTENSION; SKM_DEFINE_STACK_OF_INTERNAL(X509_EXTENSION, X509_EXTENSION, X509_EXTENSION) -#define sk_X509_EXTENSION_num(sk) OPENSSL_sk_num(ossl_check_const_X509_EXTENSION_sk_type(sk)) -#define sk_X509_EXTENSION_value(sk, idx) \ - ((X509_EXTENSION *)OPENSSL_sk_value(ossl_check_const_X509_EXTENSION_sk_type(sk), (idx))) -#define sk_X509_EXTENSION_new(cmp) \ - ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new(ossl_check_X509_EXTENSION_compfunc_type(cmp))) -#define sk_X509_EXTENSION_new_null() ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_null()) -#define sk_X509_EXTENSION_new_reserve(cmp, n) \ - ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_reserve( \ - ossl_check_X509_EXTENSION_compfunc_type(cmp), (n))) -#define sk_X509_EXTENSION_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_X509_EXTENSION_sk_type(sk), (n)) -#define sk_X509_EXTENSION_free(sk) OPENSSL_sk_free(ossl_check_X509_EXTENSION_sk_type(sk)) -#define sk_X509_EXTENSION_zero(sk) OPENSSL_sk_zero(ossl_check_X509_EXTENSION_sk_type(sk)) -#define sk_X509_EXTENSION_delete(sk, i) \ - ((X509_EXTENSION *)OPENSSL_sk_delete(ossl_check_X509_EXTENSION_sk_type(sk), (i))) -#define sk_X509_EXTENSION_delete_ptr(sk, ptr) \ - ((X509_EXTENSION *)OPENSSL_sk_delete_ptr(ossl_check_X509_EXTENSION_sk_type(sk), \ - ossl_check_X509_EXTENSION_type(ptr))) -#define sk_X509_EXTENSION_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) -#define sk_X509_EXTENSION_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) -#define sk_X509_EXTENSION_pop(sk) \ - ((X509_EXTENSION *)OPENSSL_sk_pop(ossl_check_X509_EXTENSION_sk_type(sk))) -#define sk_X509_EXTENSION_shift(sk) \ - ((X509_EXTENSION *)OPENSSL_sk_shift(ossl_check_X509_EXTENSION_sk_type(sk))) -#define sk_X509_EXTENSION_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_EXTENSION_sk_type(sk), \ - ossl_check_X509_EXTENSION_freefunc_type(freefunc)) -#define sk_X509_EXTENSION_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr), \ - (idx)) -#define sk_X509_EXTENSION_set(sk, idx, ptr) \ - ((X509_EXTENSION *)OPENSSL_sk_set(ossl_check_X509_EXTENSION_sk_type(sk), (idx), \ - ossl_check_X509_EXTENSION_type(ptr))) -#define sk_X509_EXTENSION_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) -#define sk_X509_EXTENSION_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_type(ptr)) -#define sk_X509_EXTENSION_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_EXTENSION_sk_type(sk), \ - ossl_check_X509_EXTENSION_type(ptr), pnum) -#define sk_X509_EXTENSION_sort(sk) OPENSSL_sk_sort(ossl_check_X509_EXTENSION_sk_type(sk)) -#define sk_X509_EXTENSION_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_EXTENSION_sk_type(sk)) -#define sk_X509_EXTENSION_dup(sk) \ - ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_dup(ossl_check_const_X509_EXTENSION_sk_type(sk))) -#define sk_X509_EXTENSION_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_EXTENSION_sk_type(sk), \ - ossl_check_X509_EXTENSION_copyfunc_type(copyfunc), \ - ossl_check_X509_EXTENSION_freefunc_type(freefunc))) -#define sk_X509_EXTENSION_set_cmp_func(sk, cmp) \ - ((sk_X509_EXTENSION_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_EXTENSION_sk_type(sk), ossl_check_X509_EXTENSION_compfunc_type(cmp))) +#define sk_X509_EXTENSION_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_value(sk, idx) \ + ((X509_EXTENSION *)OPENSSL_sk_value( \ + ossl_check_const_X509_EXTENSION_sk_type(sk), (idx))) +#define sk_X509_EXTENSION_new(cmp) \ + ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new( \ + ossl_check_X509_EXTENSION_compfunc_type(cmp))) +#define sk_X509_EXTENSION_new_null() \ + ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_null()) +#define sk_X509_EXTENSION_new_reserve(cmp, n) \ + ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_EXTENSION_compfunc_type(cmp), (n))) +#define sk_X509_EXTENSION_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_EXTENSION_sk_type(sk), (n)) +#define sk_X509_EXTENSION_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_delete(sk, i) \ + ((X509_EXTENSION *)OPENSSL_sk_delete(ossl_check_X509_EXTENSION_sk_type(sk), \ + (i))) +#define sk_X509_EXTENSION_delete_ptr(sk, ptr) \ + ((X509_EXTENSION *)OPENSSL_sk_delete_ptr( \ + ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr))) +#define sk_X509_EXTENSION_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_pop(sk) \ + ((X509_EXTENSION *)OPENSSL_sk_pop(ossl_check_X509_EXTENSION_sk_type(sk))) +#define sk_X509_EXTENSION_shift(sk) \ + ((X509_EXTENSION *)OPENSSL_sk_shift(ossl_check_X509_EXTENSION_sk_type(sk))) +#define sk_X509_EXTENSION_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_freefunc_type(freefunc)) +#define sk_X509_EXTENSION_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr), (idx)) +#define sk_X509_EXTENSION_set(sk, idx, ptr) \ + ((X509_EXTENSION *)OPENSSL_sk_set(ossl_check_X509_EXTENSION_sk_type(sk), \ + (idx), \ + ossl_check_X509_EXTENSION_type(ptr))) +#define sk_X509_EXTENSION_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr)) +#define sk_X509_EXTENSION_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_type(ptr), pnum) +#define sk_X509_EXTENSION_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_EXTENSION_sk_type(sk)) +#define sk_X509_EXTENSION_dup(sk) \ + ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_EXTENSION_sk_type(sk))) +#define sk_X509_EXTENSION_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_EXTENSION) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_copyfunc_type(copyfunc), \ + ossl_check_X509_EXTENSION_freefunc_type(freefunc))) +#define sk_X509_EXTENSION_set_cmp_func(sk, cmp) \ + ((sk_X509_EXTENSION_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_EXTENSION_sk_type(sk), \ + ossl_check_X509_EXTENSION_compfunc_type(cmp))) typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS; typedef struct x509_attributes_st X509_ATTRIBUTE; SKM_DEFINE_STACK_OF_INTERNAL(X509_ATTRIBUTE, X509_ATTRIBUTE, X509_ATTRIBUTE) -#define sk_X509_ATTRIBUTE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)) -#define sk_X509_ATTRIBUTE_value(sk, idx) \ - ((X509_ATTRIBUTE *)OPENSSL_sk_value(ossl_check_const_X509_ATTRIBUTE_sk_type(sk), (idx))) -#define sk_X509_ATTRIBUTE_new(cmp) \ - ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new(ossl_check_X509_ATTRIBUTE_compfunc_type(cmp))) -#define sk_X509_ATTRIBUTE_new_null() ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_null()) -#define sk_X509_ATTRIBUTE_new_reserve(cmp, n) \ - ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_reserve( \ - ossl_check_X509_ATTRIBUTE_compfunc_type(cmp), (n))) -#define sk_X509_ATTRIBUTE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_X509_ATTRIBUTE_sk_type(sk), (n)) -#define sk_X509_ATTRIBUTE_free(sk) OPENSSL_sk_free(ossl_check_X509_ATTRIBUTE_sk_type(sk)) -#define sk_X509_ATTRIBUTE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ATTRIBUTE_sk_type(sk)) -#define sk_X509_ATTRIBUTE_delete(sk, i) \ - ((X509_ATTRIBUTE *)OPENSSL_sk_delete(ossl_check_X509_ATTRIBUTE_sk_type(sk), (i))) -#define sk_X509_ATTRIBUTE_delete_ptr(sk, ptr) \ - ((X509_ATTRIBUTE *)OPENSSL_sk_delete_ptr(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ - ossl_check_X509_ATTRIBUTE_type(ptr))) -#define sk_X509_ATTRIBUTE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) -#define sk_X509_ATTRIBUTE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) -#define sk_X509_ATTRIBUTE_pop(sk) \ - ((X509_ATTRIBUTE *)OPENSSL_sk_pop(ossl_check_X509_ATTRIBUTE_sk_type(sk))) -#define sk_X509_ATTRIBUTE_shift(sk) \ - ((X509_ATTRIBUTE *)OPENSSL_sk_shift(ossl_check_X509_ATTRIBUTE_sk_type(sk))) -#define sk_X509_ATTRIBUTE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ - ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc)) -#define sk_X509_ATTRIBUTE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr), \ - (idx)) -#define sk_X509_ATTRIBUTE_set(sk, idx, ptr) \ - ((X509_ATTRIBUTE *)OPENSSL_sk_set(ossl_check_X509_ATTRIBUTE_sk_type(sk), (idx), \ - ossl_check_X509_ATTRIBUTE_type(ptr))) -#define sk_X509_ATTRIBUTE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) -#define sk_X509_ATTRIBUTE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_type(ptr)) -#define sk_X509_ATTRIBUTE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ - ossl_check_X509_ATTRIBUTE_type(ptr), pnum) -#define sk_X509_ATTRIBUTE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ATTRIBUTE_sk_type(sk)) -#define sk_X509_ATTRIBUTE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)) -#define sk_X509_ATTRIBUTE_dup(sk) \ - ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_dup(ossl_check_const_X509_ATTRIBUTE_sk_type(sk))) -#define sk_X509_ATTRIBUTE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_ATTRIBUTE_sk_type(sk), \ - ossl_check_X509_ATTRIBUTE_copyfunc_type(copyfunc), \ - ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc))) -#define sk_X509_ATTRIBUTE_set_cmp_func(sk, cmp) \ - ((sk_X509_ATTRIBUTE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_ATTRIBUTE_sk_type(sk), ossl_check_X509_ATTRIBUTE_compfunc_type(cmp))) +#define sk_X509_ATTRIBUTE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_value(sk, idx) \ + ((X509_ATTRIBUTE *)OPENSSL_sk_value( \ + ossl_check_const_X509_ATTRIBUTE_sk_type(sk), (idx))) +#define sk_X509_ATTRIBUTE_new(cmp) \ + ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new( \ + ossl_check_X509_ATTRIBUTE_compfunc_type(cmp))) +#define sk_X509_ATTRIBUTE_new_null() \ + ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_null()) +#define sk_X509_ATTRIBUTE_new_reserve(cmp, n) \ + ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_ATTRIBUTE_compfunc_type(cmp), (n))) +#define sk_X509_ATTRIBUTE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_ATTRIBUTE_sk_type(sk), (n)) +#define sk_X509_ATTRIBUTE_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_delete(sk, i) \ + ((X509_ATTRIBUTE *)OPENSSL_sk_delete(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + (i))) +#define sk_X509_ATTRIBUTE_delete_ptr(sk, ptr) \ + ((X509_ATTRIBUTE *)OPENSSL_sk_delete_ptr( \ + ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr))) +#define sk_X509_ATTRIBUTE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_pop(sk) \ + ((X509_ATTRIBUTE *)OPENSSL_sk_pop(ossl_check_X509_ATTRIBUTE_sk_type(sk))) +#define sk_X509_ATTRIBUTE_shift(sk) \ + ((X509_ATTRIBUTE *)OPENSSL_sk_shift(ossl_check_X509_ATTRIBUTE_sk_type(sk))) +#define sk_X509_ATTRIBUTE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc)) +#define sk_X509_ATTRIBUTE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr), (idx)) +#define sk_X509_ATTRIBUTE_set(sk, idx, ptr) \ + ((X509_ATTRIBUTE *)OPENSSL_sk_set(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + (idx), \ + ossl_check_X509_ATTRIBUTE_type(ptr))) +#define sk_X509_ATTRIBUTE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr)) +#define sk_X509_ATTRIBUTE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_type(ptr), pnum) +#define sk_X509_ATTRIBUTE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_ATTRIBUTE_sk_type(sk)) +#define sk_X509_ATTRIBUTE_dup(sk) \ + ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_ATTRIBUTE_sk_type(sk))) +#define sk_X509_ATTRIBUTE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_ATTRIBUTE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_copyfunc_type(copyfunc), \ + ossl_check_X509_ATTRIBUTE_freefunc_type(freefunc))) +#define sk_X509_ATTRIBUTE_set_cmp_func(sk, cmp) \ + ((sk_X509_ATTRIBUTE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_ATTRIBUTE_sk_type(sk), \ + ossl_check_X509_ATTRIBUTE_compfunc_type(cmp))) typedef struct X509_req_info_st X509_REQ_INFO; typedef struct X509_req_st X509_REQ; @@ -485,9 +592,9 @@ typedef struct x509_cinf_st X509_CINF; #define XN_FLAG_COMPAT 0 /* Traditional; use old X509_NAME_print */ #define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */ -#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ -#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ -#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ +#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */ +#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */ +#define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */ #define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */ @@ -495,9 +602,9 @@ typedef struct x509_cinf_st X509_CINF; #define XN_FLAG_FN_MASK (0x3 << 21) -#define XN_FLAG_FN_SN 0 /* Object short name */ -#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ -#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ +#define XN_FLAG_FN_SN 0 /* Object short name */ +#define XN_FLAG_FN_LN (1 << 21) /* Object long name */ +#define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */ #define XN_FLAG_FN_NONE (3 << 21) /* No field names */ #define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */ @@ -509,103 +616,119 @@ typedef struct x509_cinf_st X509_CINF; #define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) -#define XN_FLAG_FN_ALIGN \ - (1 << 25) /* Align field names to 20 \ - * characters */ +#define XN_FLAG_FN_ALIGN \ + (1 << 25) /* Align field names to 20 \ + * characters */ /* Complete set of RFC2253 flags */ -#define XN_FLAG_RFC2253 \ - (ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV | XN_FLAG_FN_SN \ - | XN_FLAG_DUMP_UNKNOWN_FIELDS) +#define XN_FLAG_RFC2253 \ + (ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV \ + | XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS) /* readable oneline form */ -#define XN_FLAG_ONELINE \ - (ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC | XN_FLAG_SPC_EQ \ - | XN_FLAG_FN_SN) +#define XN_FLAG_ONELINE \ + (ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC \ + | XN_FLAG_SPC_EQ | XN_FLAG_FN_SN) /* readable multiline form */ -#define XN_FLAG_MULTILINE \ - (ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE | XN_FLAG_SPC_EQ \ - | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN) +#define XN_FLAG_MULTILINE \ + (ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE \ + | XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN) typedef struct X509_crl_info_st X509_CRL_INFO; typedef struct private_key_st { - int version; - /* The PKCS#8 data types */ - X509_ALGOR *enc_algor; - ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ - /* When decrypted, the following will not be NULL */ - EVP_PKEY *dec_pkey; - /* used to encrypt and decrypt */ - int key_length; - char *key_data; - int key_free; /* true if we should auto free key_data */ - /* expanded version of 'enc_algor' */ - EVP_CIPHER_INFO cipher; + int version; + /* The PKCS#8 data types */ + X509_ALGOR *enc_algor; + ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ + /* When decrypted, the following will not be NULL */ + EVP_PKEY *dec_pkey; + /* used to encrypt and decrypt */ + int key_length; + char *key_data; + int key_free; /* true if we should auto free key_data */ + /* expanded version of 'enc_algor' */ + EVP_CIPHER_INFO cipher; } X509_PKEY; typedef struct X509_info_st { - X509 *x509; - X509_CRL *crl; - X509_PKEY *x_pkey; - EVP_CIPHER_INFO enc_cipher; - int enc_len; - char *enc_data; + X509 *x509; + X509_CRL *crl; + X509_PKEY *x_pkey; + EVP_CIPHER_INFO enc_cipher; + int enc_len; + char *enc_data; } X509_INFO; SKM_DEFINE_STACK_OF_INTERNAL(X509_INFO, X509_INFO, X509_INFO) -#define sk_X509_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_X509_INFO_sk_type(sk)) -#define sk_X509_INFO_value(sk, idx) \ - ((X509_INFO *)OPENSSL_sk_value(ossl_check_const_X509_INFO_sk_type(sk), (idx))) -#define sk_X509_INFO_new(cmp) \ - ((STACK_OF(X509_INFO) *)OPENSSL_sk_new(ossl_check_X509_INFO_compfunc_type(cmp))) +#define sk_X509_INFO_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_value(sk, idx) \ + ((X509_INFO *)OPENSSL_sk_value(ossl_check_const_X509_INFO_sk_type(sk), (idx))) +#define sk_X509_INFO_new(cmp) \ + ((STACK_OF(X509_INFO) *)OPENSSL_sk_new( \ + ossl_check_X509_INFO_compfunc_type(cmp))) #define sk_X509_INFO_new_null() ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_null()) -#define sk_X509_INFO_new_reserve(cmp, n) \ - ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_reserve(ossl_check_X509_INFO_compfunc_type(cmp), (n))) -#define sk_X509_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_INFO_sk_type(sk), (n)) +#define sk_X509_INFO_new_reserve(cmp, n) \ + ((STACK_OF(X509_INFO) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_INFO_compfunc_type(cmp), (n))) +#define sk_X509_INFO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_INFO_sk_type(sk), (n)) #define sk_X509_INFO_free(sk) OPENSSL_sk_free(ossl_check_X509_INFO_sk_type(sk)) #define sk_X509_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_X509_INFO_sk_type(sk)) -#define sk_X509_INFO_delete(sk, i) \ - ((X509_INFO *)OPENSSL_sk_delete(ossl_check_X509_INFO_sk_type(sk), (i))) -#define sk_X509_INFO_delete_ptr(sk, ptr) \ - ((X509_INFO *)OPENSSL_sk_delete_ptr(ossl_check_X509_INFO_sk_type(sk), \ - ossl_check_X509_INFO_type(ptr))) -#define sk_X509_INFO_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) -#define sk_X509_INFO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) -#define sk_X509_INFO_pop(sk) ((X509_INFO *)OPENSSL_sk_pop(ossl_check_X509_INFO_sk_type(sk))) -#define sk_X509_INFO_shift(sk) ((X509_INFO *)OPENSSL_sk_shift(ossl_check_X509_INFO_sk_type(sk))) -#define sk_X509_INFO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_INFO_sk_type(sk), \ - ossl_check_X509_INFO_freefunc_type(freefunc)) -#define sk_X509_INFO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr), (idx)) -#define sk_X509_INFO_set(sk, idx, ptr) \ - ((X509_INFO *)OPENSSL_sk_set(ossl_check_X509_INFO_sk_type(sk), (idx), \ - ossl_check_X509_INFO_type(ptr))) -#define sk_X509_INFO_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) -#define sk_X509_INFO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr)) -#define sk_X509_INFO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_INFO_sk_type(sk), ossl_check_X509_INFO_type(ptr), pnum) +#define sk_X509_INFO_delete(sk, i) \ + ((X509_INFO *)OPENSSL_sk_delete(ossl_check_X509_INFO_sk_type(sk), (i))) +#define sk_X509_INFO_delete_ptr(sk, ptr) \ + ((X509_INFO *)OPENSSL_sk_delete_ptr(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr))) +#define sk_X509_INFO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_pop(sk) \ + ((X509_INFO *)OPENSSL_sk_pop(ossl_check_X509_INFO_sk_type(sk))) +#define sk_X509_INFO_shift(sk) \ + ((X509_INFO *)OPENSSL_sk_shift(ossl_check_X509_INFO_sk_type(sk))) +#define sk_X509_INFO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_freefunc_type(freefunc)) +#define sk_X509_INFO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr), (idx)) +#define sk_X509_INFO_set(sk, idx, ptr) \ + ((X509_INFO *)OPENSSL_sk_set(ossl_check_X509_INFO_sk_type(sk), (idx), \ + ossl_check_X509_INFO_type(ptr))) +#define sk_X509_INFO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr)) +#define sk_X509_INFO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_type(ptr), pnum) #define sk_X509_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_X509_INFO_sk_type(sk)) -#define sk_X509_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_INFO_sk_type(sk)) -#define sk_X509_INFO_dup(sk) \ - ((STACK_OF(X509_INFO) *)OPENSSL_sk_dup(ossl_check_const_X509_INFO_sk_type(sk))) -#define sk_X509_INFO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_INFO_sk_type(sk), \ - ossl_check_X509_INFO_copyfunc_type(copyfunc), \ - ossl_check_X509_INFO_freefunc_type(freefunc))) -#define sk_X509_INFO_set_cmp_func(sk, cmp) \ - ((sk_X509_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_INFO_sk_type(sk), \ - ossl_check_X509_INFO_compfunc_type(cmp))) +#define sk_X509_INFO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_INFO_sk_type(sk)) +#define sk_X509_INFO_dup(sk) \ + ((STACK_OF(X509_INFO) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_INFO_sk_type(sk))) +#define sk_X509_INFO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_INFO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_copyfunc_type(copyfunc), \ + ossl_check_X509_INFO_freefunc_type(freefunc))) +#define sk_X509_INFO_set_cmp_func(sk, cmp) \ + ((sk_X509_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_INFO_sk_type(sk), \ + ossl_check_X509_INFO_compfunc_type(cmp))) /* * The next 2 structures and their 8 routines are used to manipulate Netscape's @@ -613,22 +736,22 @@ SKM_DEFINE_STACK_OF_INTERNAL(X509_INFO, X509_INFO, X509_INFO) */ typedef struct Netscape_spkac_st { - X509_PUBKEY *pubkey; - ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ } NETSCAPE_SPKAC; typedef struct Netscape_spki_st { - NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ - X509_ALGOR sig_algor; - ASN1_BIT_STRING *signature; + NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ + X509_ALGOR sig_algor; + ASN1_BIT_STRING *signature; } NETSCAPE_SPKI; /* Netscape certificate sequence structure */ typedef struct Netscape_certificate_sequence { - ASN1_OBJECT *type; - STACK_OF(X509) * certs; + ASN1_OBJECT *type; + STACK_OF(X509) * certs; } NETSCAPE_CERT_SEQUENCE; /*- Unused (and iv length is wrong) @@ -642,35 +765,35 @@ typedef struct CBCParameter_st typedef struct PBEPARAM_st { - ASN1_OCTET_STRING *salt; - ASN1_INTEGER *iter; + ASN1_OCTET_STRING *salt; + ASN1_INTEGER *iter; } PBEPARAM; /* Password based encryption V2 structures */ typedef struct PBE2PARAM_st { - X509_ALGOR *keyfunc; - X509_ALGOR *encryption; + X509_ALGOR *keyfunc; + X509_ALGOR *encryption; } PBE2PARAM; typedef struct PBKDF2PARAM_st { - /* Usually OCTET STRING but could be anything */ - ASN1_TYPE *salt; - ASN1_INTEGER *iter; - ASN1_INTEGER *keylength; - X509_ALGOR *prf; + /* Usually OCTET STRING but could be anything */ + ASN1_TYPE *salt; + ASN1_INTEGER *iter; + ASN1_INTEGER *keylength; + X509_ALGOR *prf; } PBKDF2PARAM; #ifndef OPENSSL_NO_SCRYPT typedef struct SCRYPT_PARAMS_st { - ASN1_OCTET_STRING *salt; - ASN1_INTEGER *costParameter; - ASN1_INTEGER *blockSize; - ASN1_INTEGER *parallelizationParameter; - ASN1_INTEGER *keyLength; + ASN1_OCTET_STRING *salt; + ASN1_INTEGER *costParameter; + ASN1_INTEGER *blockSize; + ASN1_INTEGER *parallelizationParameter; + ASN1_INTEGER *keyLength; } SCRYPT_PARAMS; #endif @@ -693,11 +816,11 @@ extern "C" { #define X509_name_cmp(a, b) X509_NAME_cmp((a), (b)) void X509_CRL_set_default_method(const X509_CRL_METHOD *meth); -X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init)(X509_CRL *crl), int (*crl_free)(X509_CRL *crl), - int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret, - const ASN1_INTEGER *serial, - const X509_NAME *issuer), - int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk)); +X509_CRL_METHOD *X509_CRL_METHOD_new( + int (*crl_init)(X509_CRL *crl), int (*crl_free)(X509_CRL *crl), + int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret, + const ASN1_INTEGER *serial, const X509_NAME *issuer), + int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk)); void X509_CRL_METHOD_free(X509_CRL_METHOD *m); void X509_CRL_set_meth_data(X509_CRL *crl, void *dat); @@ -708,7 +831,8 @@ const char *X509_verify_cert_error_string(long n); int X509_verify(X509 *a, EVP_PKEY *r); int X509_self_signed(X509 *cert, int verify_signature); -int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *r, OSSL_LIB_CTX *libctx, const char *propq); +int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *r, OSSL_LIB_CTX *libctx, + const char *propq); int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); @@ -721,7 +845,8 @@ int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent); -int X509_signature_print(BIO *bp, const X509_ALGOR *alg, const ASN1_STRING *sig); +int X509_signature_print(BIO *bp, const X509_ALGOR *alg, + const ASN1_STRING *sig); int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); @@ -731,22 +856,27 @@ int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx); int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len); -int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len); -ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert, EVP_MD **md_used, int *md_is_fallback); -int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, unsigned int *len); -int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md, unsigned int *len); -int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, - unsigned int *len); +int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, + unsigned int *len); +int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, + unsigned int *len); +ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert, EVP_MD **md_used, + int *md_is_fallback); +int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, + unsigned int *len); +int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md, + unsigned int *len); +int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, + unsigned char *md, unsigned int *len); X509 *X509_load_http(const char *url, BIO *bio, BIO *rbio, int timeout); X509_CRL *X509_CRL_load_http(const char *url, BIO *bio, BIO *rbio, int timeout); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# include /* OSSL_HTTP_REQ_CTX_nbio_d2i */ -# define X509_http_nbio(rctx, pcert) \ - OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcert, ASN1_ITEM_rptr(X509)) -# define X509_CRL_http_nbio(rctx, pcrl) \ - OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcrl, ASN1_ITEM_rptr(X509_CRL)) +# include /* OSSL_HTTP_REQ_CTX_nbio_d2i */ +# define X509_http_nbio(rctx, pcert) \ + OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcert, ASN1_ITEM_rptr(X509)) +# define X509_CRL_http_nbio(rctx, pcrl) \ + OSSL_HTTP_REQ_CTX_nbio_d2i(rctx, pcrl, ASN1_ITEM_rptr(X509_CRL)) #endif #ifndef OPENSSL_NO_STDIO @@ -756,42 +886,45 @@ X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl); int i2d_X509_CRL_fp(FILE *fp, const X509_CRL *crl); X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req); int i2d_X509_REQ_fp(FILE *fp, const X509_REQ *req); -# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa); OSSL_DEPRECATEDIN_3_0 int i2d_RSAPrivateKey_fp(FILE *fp, const RSA *rsa); OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa); OSSL_DEPRECATEDIN_3_0 int i2d_RSAPublicKey_fp(FILE *fp, const RSA *rsa); OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa); OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_fp(FILE *fp, const RSA *rsa); -# endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_DSA +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_DSA OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_fp(FILE *fp, const DSA *dsa); OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_fp(FILE *fp, const DSA *dsa); -# endif # endif -# ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_EC +# endif +# ifndef OPENSSL_NO_DEPRECATED_3_0 +# ifndef OPENSSL_NO_EC OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_fp(FILE *fp, const EC_KEY *eckey); OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_fp(FILE *fp, const EC_KEY *eckey); -# endif /* OPENSSL_NO_EC */ -# endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_EC */ +# endif /* OPENSSL_NO_DEPRECATED_3_0 */ X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8); int i2d_PKCS8_fp(FILE *fp, const X509_SIG *p8); X509_PUBKEY *d2i_X509_PUBKEY_fp(FILE *fp, X509_PUBKEY **xpk); int i2d_X509_PUBKEY_fp(FILE *fp, const X509_PUBKEY *xpk); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO **p8inf); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, + PKCS8_PRIV_KEY_INFO **p8inf); int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, const PKCS8_PRIV_KEY_INFO *p8inf); int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key); int i2d_PrivateKey_fp(FILE *fp, const EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *d2i_PrivateKey_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); int i2d_PUBKEY_fp(FILE *fp, const EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *d2i_PUBKEY_ex_fp(FILE *fp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); #endif @@ -810,35 +943,38 @@ OSSL_DEPRECATEDIN_3_0 RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa); OSSL_DEPRECATEDIN_3_0 int i2d_RSA_PUBKEY_bio(BIO *bp, const RSA *rsa); #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_DSA +# ifndef OPENSSL_NO_DSA OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); OSSL_DEPRECATEDIN_3_0 int i2d_DSA_PUBKEY_bio(BIO *bp, const DSA *dsa); OSSL_DEPRECATEDIN_3_0 DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); OSSL_DEPRECATEDIN_3_0 int i2d_DSAPrivateKey_bio(BIO *bp, const DSA *dsa); -# endif +# endif #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_EC +# ifndef OPENSSL_NO_EC OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); OSSL_DEPRECATEDIN_3_0 int i2d_EC_PUBKEY_bio(BIO *bp, const EC_KEY *eckey); OSSL_DEPRECATEDIN_3_0 EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); OSSL_DEPRECATEDIN_3_0 int i2d_ECPrivateKey_bio(BIO *bp, const EC_KEY *eckey); -# endif /* OPENSSL_NO_EC */ -#endif /* OPENSSL_NO_DEPRECATED_3_0 */ +# endif /* OPENSSL_NO_EC */ +#endif /* OPENSSL_NO_DEPRECATED_3_0 */ X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8); int i2d_PKCS8_bio(BIO *bp, const X509_SIG *p8); X509_PUBKEY *d2i_X509_PUBKEY_bio(BIO *bp, X509_PUBKEY **xpk); int i2d_X509_PUBKEY_bio(BIO *bp, const X509_PUBKEY *xpk); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO **p8inf); +PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, + PKCS8_PRIV_KEY_INFO **p8inf); int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, const PKCS8_PRIV_KEY_INFO *p8inf); int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key); int i2d_PrivateKey_bio(BIO *bp, const EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *d2i_PrivateKey_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); int i2d_PUBKEY_bio(BIO *bp, const EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *d2i_PUBKEY_ex_bio(BIO *bp, EVP_PKEY **a, OSSL_LIB_CTX *libctx, + const char *propq); EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); DECLARE_ASN1_DUP_FUNCTION(X509) @@ -861,9 +997,11 @@ DECLARE_ASN1_DUP_FUNCTION(X509_NAME_ENTRY) int X509_cmp_time(const ASN1_TIME *s, time_t *t); int X509_cmp_current_time(const ASN1_TIME *s); -int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm, const ASN1_TIME *start, const ASN1_TIME *end); +int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm, const ASN1_TIME *start, + const ASN1_TIME *end); ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t); -ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, time_t *t); +ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, + time_t *t); ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj); const char *X509_get_default_cert_area(void); @@ -892,25 +1030,29 @@ EVP_PKEY *X509_PUBKEY_get(const X509_PUBKEY *key); int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) * chain); long X509_get_pathlen(X509 *x); DECLARE_ASN1_ENCODE_FUNCTIONS_only(EVP_PKEY, PUBKEY) EVP_PKEY *d2i_PUBKEY_ex( - EVP_PKEY **a, const unsigned char **pp, long length, OSSL_LIB_CTX *libctx, const char *propq); + EVP_PKEY **a, const unsigned char **pp, long length, OSSL_LIB_CTX *libctx, + const char *propq); #ifndef OPENSSL_NO_DEPRECATED_3_0 DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSA_PUBKEY) #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_DSA - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, DSA_PUBKEY) -# endif +# ifndef OPENSSL_NO_DSA + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, DSA, + DSA_PUBKEY) +# endif #endif #ifndef OPENSSL_NO_DEPRECATED_3_0 -# ifndef OPENSSL_NO_EC - DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, EC_KEY, EC_PUBKEY) -# endif +# ifndef OPENSSL_NO_EC + DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(OSSL_DEPRECATEDIN_3_0, EC_KEY, + EC_PUBKEY) +# endif #endif - DECLARE_ASN1_FUNCTIONS(X509_SIG) void X509_SIG_get0(const X509_SIG *sig, - const X509_ALGOR **palg, - const ASN1_OCTET_STRING **pdigest); -void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg, ASN1_OCTET_STRING **pdigest); + DECLARE_ASN1_FUNCTIONS(X509_SIG) void X509_SIG_get0( + const X509_SIG *sig, const X509_ALGOR **palg, + const ASN1_OCTET_STRING **pdigest); +void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg, + ASN1_OCTET_STRING **pdigest); DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) DECLARE_ASN1_FUNCTIONS(X509_REQ) @@ -933,21 +1075,24 @@ DECLARE_ASN1_FUNCTIONS(X509) X509 *X509_new_ex(OSSL_LIB_CTX *libctx, const char *propq); DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) -#define X509_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef) +#define X509_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef) int X509_set_ex_data(X509 *r, int idx, void *arg); void *X509_get_ex_data(const X509 *r, int idx); DECLARE_ASN1_ENCODE_FUNCTIONS_only(X509, X509_AUX) int i2d_re_X509_tbs(X509 *x, unsigned char **pp); -int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid, int *secbits, - uint32_t *flags); -void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid, int secbits, uint32_t flags); +int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid, + int *secbits, uint32_t *flags); +void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid, int secbits, + uint32_t flags); -int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits, uint32_t *flags); +int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits, + uint32_t *flags); -void X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, const X509 *x); +void X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, + const X509 *x); int X509_get_signature_nid(const X509 *x); void X509_set0_distinguishing_id(X509 *x, ASN1_OCTET_STRING *d_id); @@ -966,7 +1111,8 @@ DECLARE_ASN1_FUNCTIONS(X509_CRL) X509_CRL *X509_CRL_new_ex(OSSL_LIB_CTX *libctx, const char *propq); int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); -int X509_CRL_get0_by_serial(X509_CRL *crl, X509_REVOKED **ret, const ASN1_INTEGER *serial); +int X509_CRL_get0_by_serial(X509_CRL *crl, X509_REVOKED **ret, + const ASN1_INTEGER *serial); int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x); X509_PKEY *X509_PKEY_new(void); @@ -982,25 +1128,30 @@ char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size); #ifndef OPENSSL_NO_DEPRECATED_3_0 OSSL_DEPRECATEDIN_3_0 -int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, ASN1_BIT_STRING *signature, char *data, - EVP_PKEY *pkey); +int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, + ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey); OSSL_DEPRECATEDIN_3_0 -int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, unsigned char *md, - unsigned int *len); +int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, + unsigned char *md, unsigned int *len); OSSL_DEPRECATEDIN_3_0 -int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2, ASN1_BIT_STRING *signature, - char *data, EVP_PKEY *pkey, const EVP_MD *type); +int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2, + ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey, + const EVP_MD *type); #endif -int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data, unsigned char *md, - unsigned int *len); -int ASN1_item_verify(const ASN1_ITEM *it, const X509_ALGOR *alg, const ASN1_BIT_STRING *signature, - const void *data, EVP_PKEY *pkey); +int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data, + unsigned char *md, unsigned int *len); +int ASN1_item_verify(const ASN1_ITEM *it, const X509_ALGOR *alg, + const ASN1_BIT_STRING *signature, const void *data, + EVP_PKEY *pkey); int ASN1_item_verify_ctx(const ASN1_ITEM *it, const X509_ALGOR *alg, - const ASN1_BIT_STRING *signature, const void *data, EVP_MD_CTX *ctx); + const ASN1_BIT_STRING *signature, const void *data, + EVP_MD_CTX *ctx); int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, const void *data, EVP_PKEY *pkey, const EVP_MD *md); -int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, - ASN1_BIT_STRING *signature, const void *data, EVP_MD_CTX *ctx); + ASN1_BIT_STRING *signature, const void *data, EVP_PKEY *pkey, + const EVP_MD *md); +int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, + X509_ALGOR *algor2, ASN1_BIT_STRING *signature, + const void *data, EVP_MD_CTX *ctx); #define X509_VERSION_1 0 #define X509_VERSION_2 1 @@ -1026,10 +1177,10 @@ int X509_up_ref(X509 *x); int X509_get_signature_type(const X509 *x); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define X509_get_notBefore X509_getm_notBefore -# define X509_get_notAfter X509_getm_notAfter -# define X509_set_notBefore X509_set1_notBefore -# define X509_set_notAfter X509_set1_notAfter +# define X509_get_notBefore X509_getm_notBefore +# define X509_get_notAfter X509_getm_notAfter +# define X509_set_notBefore X509_set1_notBefore +# define X509_set_notAfter X509_set1_notAfter #endif /* @@ -1038,7 +1189,8 @@ int X509_get_signature_type(const X509 *x); */ X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x); const STACK_OF(X509_EXTENSION) * X509_get0_extensions(const X509 *x); -void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, const ASN1_BIT_STRING **psuid); +void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, + const ASN1_BIT_STRING **psuid); const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); EVP_PKEY *X509_get0_pubkey(const X509 *x); @@ -1065,18 +1217,21 @@ int X509_REQ_extension_nid(int nid); int *X509_REQ_get_extension_nids(void); void X509_REQ_set_extension_nids(int *nids); STACK_OF(X509_EXTENSION) * X509_REQ_get_extensions(X509_REQ *req); -int X509_REQ_add_extensions_nid(X509_REQ *req, const STACK_OF(X509_EXTENSION) * exts, int nid); -int X509_REQ_add_extensions(X509_REQ *req, const STACK_OF(X509_EXTENSION) * ext); +int X509_REQ_add_extensions_nid(X509_REQ *req, + const STACK_OF(X509_EXTENSION) * exts, int nid); +int X509_REQ_add_extensions(X509_REQ *req, + const STACK_OF(X509_EXTENSION) * ext); int X509_REQ_get_attr_count(const X509_REQ *req); int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos); -int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, int lastpos); +int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, + int lastpos); X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int type, const unsigned char *bytes, - int len); +int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int type, + const unsigned char *bytes, int len); int X509_REQ_add1_attr_by_txt(X509_REQ *req, const char *attrname, int type, const unsigned char *bytes, int len); @@ -1091,8 +1246,8 @@ int X509_CRL_sort(X509_CRL *crl); int X509_CRL_up_ref(X509_CRL *crl); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate -# define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate +# define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate +# define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate #endif long X509_CRL_get_version(const X509_CRL *crl); @@ -1114,10 +1269,11 @@ const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x); int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x); int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); -const STACK_OF(X509_EXTENSION) * X509_REVOKED_get0_extensions(const X509_REVOKED *r); +const STACK_OF(X509_EXTENSION) + * X509_REVOKED_get0_extensions(const X509_REVOKED *r); -X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, EVP_PKEY *skey, const EVP_MD *md, - unsigned int flags); +X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, EVP_PKEY *skey, + const EVP_MD *md, unsigned int flags); int X509_REQ_check_private_key(const X509_REQ *req, EVP_PKEY *pkey); @@ -1153,71 +1309,94 @@ int X509_add_certs(STACK_OF(X509) * sk, STACK_OF(X509) * certs, int flags); int X509_cmp(const X509 *a, const X509 *b); int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define X509_NAME_hash(x) X509_NAME_hash_ex(x, NULL, NULL, NULL) -OSSL_DEPRECATEDIN_3_0 int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey); +# define X509_NAME_hash(x) X509_NAME_hash_ex(x, NULL, NULL, NULL) +OSSL_DEPRECATEDIN_3_0 int X509_certificate_type(const X509 *x, + const EVP_PKEY *pubkey); #endif -unsigned long X509_NAME_hash_ex(const X509_NAME *x, OSSL_LIB_CTX *libctx, const char *propq, - int *ok); +unsigned long X509_NAME_hash_ex(const X509_NAME *x, OSSL_LIB_CTX *libctx, + const char *propq, int *ok); unsigned long X509_NAME_hash_old(const X509_NAME *x); int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); int X509_aux_print(BIO *out, X509 *x, int indent); #ifndef OPENSSL_NO_STDIO -int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag, unsigned long cflag); +int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag, + unsigned long cflag); int X509_print_fp(FILE *bp, X509 *x); int X509_CRL_print_fp(FILE *bp, X509_CRL *x); int X509_REQ_print_fp(FILE *bp, X509_REQ *req); -int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, unsigned long flags); +int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, + unsigned long flags); #endif int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); -int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, unsigned long flags); +int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, + unsigned long flags); int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag, unsigned long cflag); int X509_print(BIO *bp, X509 *x); int X509_ocspid_print(BIO *bp, X509 *x); int X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag); int X509_CRL_print(BIO *bp, X509_CRL *x); -int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag); +int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, + unsigned long cflag); int X509_REQ_print(BIO *bp, X509_REQ *req); int X509_NAME_entry_count(const X509_NAME *name); -int X509_NAME_get_text_by_NID(const X509_NAME *name, int nid, char *buf, int len); -int X509_NAME_get_text_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, char *buf, int len); +int X509_NAME_get_text_by_NID(const X509_NAME *name, int nid, char *buf, + int len); +int X509_NAME_get_text_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, + char *buf, int len); /* * NOTE: you should be passing -1, not 0 as lastpos. The functions that use * lastpos, search after that position on. */ int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos); -int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, int lastpos); +int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, + int lastpos); X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc); X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); -int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, int set); -int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len, int loc, int set); -int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, const unsigned char *bytes, - int len, int loc, int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, const char *field, int type, - const unsigned char *bytes, int len); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, - const unsigned char *bytes, int len); +int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, + int set); +int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, + int type, const unsigned char *bytes, int len, + int loc, int set); +int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, + const unsigned char *bytes, int len, int loc, + int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, + const char *field, int type, + const unsigned char *bytes, + int len); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, + int type, + const unsigned char *bytes, + int len); int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const unsigned char *bytes, int len, int loc, int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, const ASN1_OBJECT *obj, - int type, const unsigned char *bytes, int len); + const unsigned char *bytes, int len, int loc, + int set); +X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, + const ASN1_OBJECT *obj, int type, + const unsigned char *bytes, + int len); int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj); -int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, const unsigned char *bytes, int len); +int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, + const unsigned char *bytes, int len); ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne); ASN1_STRING *X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne); int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne); -int X509_NAME_get0_der(const X509_NAME *nm, const unsigned char **pder, size_t *pderlen); +int X509_NAME_get0_der(const X509_NAME *nm, const unsigned char **pder, + size_t *pderlen); int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) * x); -int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) * x, int nid, int lastpos); -int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) * x, const ASN1_OBJECT *obj, int lastpos); -int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) * x, int crit, int lastpos); +int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) * x, int nid, + int lastpos); +int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) * x, + const ASN1_OBJECT *obj, int lastpos); +int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) * x, int crit, + int lastpos); X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) * x, int loc); X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) * x, int loc); STACK_OF(X509_EXTENSION) @@ -1231,31 +1410,39 @@ X509_EXTENSION *X509_get_ext(const X509 *x, int loc); X509_EXTENSION *X509_delete_ext(X509 *x, int loc); int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx); -int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags); +int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, + unsigned long flags); int X509_CRL_get_ext_count(const X509_CRL *x); int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos); -int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, int lastpos); +int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, + int lastpos); int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos); X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc); X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx); -int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, unsigned long flags); +int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, + unsigned long flags); int X509_REVOKED_get_ext_count(const X509_REVOKED *x); int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos); -int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, int lastpos); -int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, int lastpos); +int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, + int lastpos); +int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, + int lastpos); X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc); X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); -void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, int *idx); -int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, unsigned long flags); +void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, + int *idx); +int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, + unsigned long flags); -X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, - ASN1_OCTET_STRING *data); -X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj, int crit, +X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, + int crit, ASN1_OCTET_STRING *data); +X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, + const ASN1_OBJECT *obj, int crit, ASN1_OCTET_STRING *data); int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj); int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); @@ -1265,46 +1452,56 @@ ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); int X509_EXTENSION_get_critical(const X509_EXTENSION *ex); int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) * x); -int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) * x, int nid, int lastpos); -int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) * sk, const ASN1_OBJECT *obj, +int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) * x, int nid, int lastpos); +int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) * sk, + const ASN1_OBJECT *obj, int lastpos); X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) * x, int loc); X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) * x, int loc); -STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) * *x, X509_ATTRIBUTE *attr); STACK_OF(X509_ATTRIBUTE) -*X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) * *x, const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); + * X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) * *x, X509_ATTRIBUTE *attr); +STACK_OF(X509_ATTRIBUTE) +*X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) * *x, const ASN1_OBJECT *obj, + int type, const unsigned char *bytes, int len); STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) * *x, int nid, int type, const unsigned char *bytes, int len); STACK_OF(X509_ATTRIBUTE) -*X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) * *x, const char *attrname, int type, - const unsigned char *bytes, int len); -void *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) * x, const ASN1_OBJECT *obj, - int lastpos, int type); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, int atrtype, - const void *data, int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, - int atrtype, const void *data, int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, const char *atrname, int type, - const unsigned char *bytes, int len); +*X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) * *x, const char *attrname, + int type, const unsigned char *bytes, int len); +void *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) * x, + const ASN1_OBJECT *obj, int lastpos, int type); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, + int atrtype, const void *data, + int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, + const ASN1_OBJECT *obj, + int atrtype, const void *data, + int len); +X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, + const char *atrname, int type, + const unsigned char *bytes, + int len); int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); -int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len); -void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, void *data); +int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, + const void *data, int len); +void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, + void *data); int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); int EVP_PKEY_get_attr_count(const EVP_PKEY *key); int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos); -int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, int lastpos); +int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, + int lastpos); X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, int nid, int type, const unsigned char *bytes, - int len); +int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, int nid, int type, + const unsigned char *bytes, int len); int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, const char *attrname, int type, const unsigned char *bytes, int len); @@ -1320,56 +1517,69 @@ DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) DECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS) #endif -int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, const unsigned char *salt, - int saltlen); -int PKCS5_pbe_set0_algor_ex(X509_ALGOR *algor, int alg, int iter, const unsigned char *salt, - int saltlen, OSSL_LIB_CTX *libctx); +int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, + const unsigned char *salt, int saltlen); +int PKCS5_pbe_set0_algor_ex(X509_ALGOR *algor, int alg, int iter, + const unsigned char *salt, int saltlen, + OSSL_LIB_CTX *libctx); -X509_ALGOR *PKCS5_pbe_set(int alg, int iter, const unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe_set_ex(int alg, int iter, const unsigned char *salt, int saltlen, - OSSL_LIB_CTX *libctx); +X509_ALGOR *PKCS5_pbe_set(int alg, int iter, const unsigned char *salt, + int saltlen); +X509_ALGOR *PKCS5_pbe_set_ex(int alg, int iter, const unsigned char *salt, + int saltlen, OSSL_LIB_CTX *libctx); -X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt, int saltlen, +X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen); +X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen, unsigned char *aiv, int prf_nid); -X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter, unsigned char *salt, - int saltlen, unsigned char *aiv, int prf_nid, +X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter, + unsigned char *salt, int saltlen, + unsigned char *aiv, int prf_nid, OSSL_LIB_CTX *libctx); #ifndef OPENSSL_NO_SCRYPT -X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher, const unsigned char *salt, int saltlen, - unsigned char *aiv, uint64_t N, uint64_t r, uint64_t p); +X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher, + const unsigned char *salt, int saltlen, + unsigned char *aiv, uint64_t N, uint64_t r, + uint64_t p); #endif -X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, int prf_nid, int keylen); -X509_ALGOR *PKCS5_pbkdf2_set_ex(int iter, unsigned char *salt, int saltlen, int prf_nid, int keylen, - OSSL_LIB_CTX *libctx); +X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, + int prf_nid, int keylen); +X509_ALGOR *PKCS5_pbkdf2_set_ex(int iter, unsigned char *salt, int saltlen, + int prf_nid, int keylen, OSSL_LIB_CTX *libctx); /* PKCS#8 utilities */ DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8); -EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx, const char *propq); +EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx, + const char *propq); PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey); -int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version, int ptype, - void *pval, unsigned char *penc, int penclen); -int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, - const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8); +int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version, + int ptype, void *pval, unsigned char *penc, int penclen); +int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, const unsigned char **pk, + int *ppklen, const X509_ALGOR **pa, + const PKCS8_PRIV_KEY_INFO *p8); -const STACK_OF(X509_ATTRIBUTE) * PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8); +const STACK_OF(X509_ATTRIBUTE) + * PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8); int PKCS8_pkey_add1_attr(PKCS8_PRIV_KEY_INFO *p8, X509_ATTRIBUTE *attr); int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type, const unsigned char *bytes, int len); -int PKCS8_pkey_add1_attr_by_OBJ(PKCS8_PRIV_KEY_INFO *p8, const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); +int PKCS8_pkey_add1_attr_by_OBJ(PKCS8_PRIV_KEY_INFO *p8, const ASN1_OBJECT *obj, + int type, const unsigned char *bytes, int len); -void X509_PUBKEY_set0_public_key(X509_PUBKEY *pub, unsigned char *penc, int penclen); -int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, int ptype, void *pval, - unsigned char *penc, int penclen); -int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, const X509_PUBKEY *pub); +void X509_PUBKEY_set0_public_key(X509_PUBKEY *pub, unsigned char *penc, + int penclen); +int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, int ptype, + void *pval, unsigned char *penc, int penclen); +int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, const unsigned char **pk, + int *ppklen, X509_ALGOR **pa, + const X509_PUBKEY *pub); int X509_PUBKEY_eq(const X509_PUBKEY *a, const X509_PUBKEY *b); #ifdef __cplusplus diff --git a/libs/OpenSSL/include/openssl/x509_vfy.h b/libs/OpenSSL/include/openssl/x509_vfy.h index aaf91b89..1a5d7c67 100644 --- a/libs/OpenSSL/include/openssl/x509_vfy.h +++ b/libs/OpenSSL/include/openssl/x509_vfy.h @@ -16,14 +16,14 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_X509_VFY_H +# define HEADER_X509_VFY_H #endif /* * Protect against recursion, x509.h and x509_vfy.h each include the other. */ #ifndef OPENSSL_X509_H -# include +# include #endif #include @@ -55,236 +55,308 @@ certificate chain. typedef enum { - X509_LU_NONE = 0, - X509_LU_X509, - X509_LU_CRL + X509_LU_NONE = 0, + X509_LU_X509, + X509_LU_CRL } X509_LOOKUP_TYPE; #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define X509_LU_RETRY -1 -# define X509_LU_FAIL 0 +# define X509_LU_RETRY -1 +# define X509_LU_FAIL 0 #endif SKM_DEFINE_STACK_OF_INTERNAL(X509_LOOKUP, X509_LOOKUP, X509_LOOKUP) -#define sk_X509_LOOKUP_num(sk) OPENSSL_sk_num(ossl_check_const_X509_LOOKUP_sk_type(sk)) -#define sk_X509_LOOKUP_value(sk, idx) \ - ((X509_LOOKUP *)OPENSSL_sk_value(ossl_check_const_X509_LOOKUP_sk_type(sk), (idx))) -#define sk_X509_LOOKUP_new(cmp) \ - ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new(ossl_check_X509_LOOKUP_compfunc_type(cmp))) -#define sk_X509_LOOKUP_new_null() ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_null()) -#define sk_X509_LOOKUP_new_reserve(cmp, n) \ - ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_reserve(ossl_check_X509_LOOKUP_compfunc_type(cmp), \ - (n))) -#define sk_X509_LOOKUP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_LOOKUP_sk_type(sk), (n)) -#define sk_X509_LOOKUP_free(sk) OPENSSL_sk_free(ossl_check_X509_LOOKUP_sk_type(sk)) -#define sk_X509_LOOKUP_zero(sk) OPENSSL_sk_zero(ossl_check_X509_LOOKUP_sk_type(sk)) -#define sk_X509_LOOKUP_delete(sk, i) \ - ((X509_LOOKUP *)OPENSSL_sk_delete(ossl_check_X509_LOOKUP_sk_type(sk), (i))) -#define sk_X509_LOOKUP_delete_ptr(sk, ptr) \ - ((X509_LOOKUP *)OPENSSL_sk_delete_ptr(ossl_check_X509_LOOKUP_sk_type(sk), \ - ossl_check_X509_LOOKUP_type(ptr))) -#define sk_X509_LOOKUP_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) -#define sk_X509_LOOKUP_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) -#define sk_X509_LOOKUP_pop(sk) ((X509_LOOKUP *)OPENSSL_sk_pop(ossl_check_X509_LOOKUP_sk_type(sk))) -#define sk_X509_LOOKUP_shift(sk) \ - ((X509_LOOKUP *)OPENSSL_sk_shift(ossl_check_X509_LOOKUP_sk_type(sk))) -#define sk_X509_LOOKUP_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_LOOKUP_sk_type(sk), \ - ossl_check_X509_LOOKUP_freefunc_type(freefunc)) -#define sk_X509_LOOKUP_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), (idx)) -#define sk_X509_LOOKUP_set(sk, idx, ptr) \ - ((X509_LOOKUP *)OPENSSL_sk_set(ossl_check_X509_LOOKUP_sk_type(sk), (idx), \ - ossl_check_X509_LOOKUP_type(ptr))) -#define sk_X509_LOOKUP_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) -#define sk_X509_LOOKUP_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr)) -#define sk_X509_LOOKUP_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_type(ptr), pnum) -#define sk_X509_LOOKUP_sort(sk) OPENSSL_sk_sort(ossl_check_X509_LOOKUP_sk_type(sk)) -#define sk_X509_LOOKUP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_LOOKUP_sk_type(sk)) -#define sk_X509_LOOKUP_dup(sk) \ - ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_dup(ossl_check_const_X509_LOOKUP_sk_type(sk))) -#define sk_X509_LOOKUP_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_LOOKUP_sk_type(sk), ossl_check_X509_LOOKUP_copyfunc_type(copyfunc), \ - ossl_check_X509_LOOKUP_freefunc_type(freefunc))) -#define sk_X509_LOOKUP_set_cmp_func(sk, cmp) \ - ((sk_X509_LOOKUP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_LOOKUP_sk_type(sk), \ - ossl_check_X509_LOOKUP_compfunc_type(cmp))) +#define sk_X509_LOOKUP_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_value(sk, idx) \ + ((X509_LOOKUP *)OPENSSL_sk_value(ossl_check_const_X509_LOOKUP_sk_type(sk), \ + (idx))) +#define sk_X509_LOOKUP_new(cmp) \ + ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new( \ + ossl_check_X509_LOOKUP_compfunc_type(cmp))) +#define sk_X509_LOOKUP_new_null() \ + ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_null()) +#define sk_X509_LOOKUP_new_reserve(cmp, n) \ + ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_LOOKUP_compfunc_type(cmp), (n))) +#define sk_X509_LOOKUP_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_LOOKUP_sk_type(sk), (n)) +#define sk_X509_LOOKUP_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_delete(sk, i) \ + ((X509_LOOKUP *)OPENSSL_sk_delete(ossl_check_X509_LOOKUP_sk_type(sk), (i))) +#define sk_X509_LOOKUP_delete_ptr(sk, ptr) \ + ((X509_LOOKUP *)OPENSSL_sk_delete_ptr(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr))) +#define sk_X509_LOOKUP_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_pop(sk) \ + ((X509_LOOKUP *)OPENSSL_sk_pop(ossl_check_X509_LOOKUP_sk_type(sk))) +#define sk_X509_LOOKUP_shift(sk) \ + ((X509_LOOKUP *)OPENSSL_sk_shift(ossl_check_X509_LOOKUP_sk_type(sk))) +#define sk_X509_LOOKUP_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_freefunc_type(freefunc)) +#define sk_X509_LOOKUP_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr), (idx)) +#define sk_X509_LOOKUP_set(sk, idx, ptr) \ + ((X509_LOOKUP *)OPENSSL_sk_set(ossl_check_X509_LOOKUP_sk_type(sk), (idx), \ + ossl_check_X509_LOOKUP_type(ptr))) +#define sk_X509_LOOKUP_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr)) +#define sk_X509_LOOKUP_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_type(ptr), pnum) +#define sk_X509_LOOKUP_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_LOOKUP_sk_type(sk)) +#define sk_X509_LOOKUP_dup(sk) \ + ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_LOOKUP_sk_type(sk))) +#define sk_X509_LOOKUP_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_LOOKUP) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_copyfunc_type(copyfunc), \ + ossl_check_X509_LOOKUP_freefunc_type(freefunc))) +#define sk_X509_LOOKUP_set_cmp_func(sk, cmp) \ + ((sk_X509_LOOKUP_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_LOOKUP_sk_type(sk), \ + ossl_check_X509_LOOKUP_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(X509_OBJECT, X509_OBJECT, X509_OBJECT) -#define sk_X509_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_X509_OBJECT_sk_type(sk)) -#define sk_X509_OBJECT_value(sk, idx) \ - ((X509_OBJECT *)OPENSSL_sk_value(ossl_check_const_X509_OBJECT_sk_type(sk), (idx))) -#define sk_X509_OBJECT_new(cmp) \ - ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new(ossl_check_X509_OBJECT_compfunc_type(cmp))) -#define sk_X509_OBJECT_new_null() ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_null()) -#define sk_X509_OBJECT_new_reserve(cmp, n) \ - ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_X509_OBJECT_compfunc_type(cmp), \ - (n))) -#define sk_X509_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_OBJECT_sk_type(sk), (n)) -#define sk_X509_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_X509_OBJECT_sk_type(sk)) -#define sk_X509_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_X509_OBJECT_sk_type(sk)) -#define sk_X509_OBJECT_delete(sk, i) \ - ((X509_OBJECT *)OPENSSL_sk_delete(ossl_check_X509_OBJECT_sk_type(sk), (i))) -#define sk_X509_OBJECT_delete_ptr(sk, ptr) \ - ((X509_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_X509_OBJECT_sk_type(sk), \ - ossl_check_X509_OBJECT_type(ptr))) -#define sk_X509_OBJECT_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) -#define sk_X509_OBJECT_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) -#define sk_X509_OBJECT_pop(sk) ((X509_OBJECT *)OPENSSL_sk_pop(ossl_check_X509_OBJECT_sk_type(sk))) -#define sk_X509_OBJECT_shift(sk) \ - ((X509_OBJECT *)OPENSSL_sk_shift(ossl_check_X509_OBJECT_sk_type(sk))) -#define sk_X509_OBJECT_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_OBJECT_sk_type(sk), \ - ossl_check_X509_OBJECT_freefunc_type(freefunc)) -#define sk_X509_OBJECT_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr), (idx)) -#define sk_X509_OBJECT_set(sk, idx, ptr) \ - ((X509_OBJECT *)OPENSSL_sk_set(ossl_check_X509_OBJECT_sk_type(sk), (idx), \ - ossl_check_X509_OBJECT_type(ptr))) -#define sk_X509_OBJECT_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) -#define sk_X509_OBJECT_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr)) -#define sk_X509_OBJECT_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_type(ptr), pnum) -#define sk_X509_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_X509_OBJECT_sk_type(sk)) -#define sk_X509_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_OBJECT_sk_type(sk)) -#define sk_X509_OBJECT_dup(sk) \ - ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_X509_OBJECT_sk_type(sk))) -#define sk_X509_OBJECT_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_OBJECT_sk_type(sk), ossl_check_X509_OBJECT_copyfunc_type(copyfunc), \ - ossl_check_X509_OBJECT_freefunc_type(freefunc))) -#define sk_X509_OBJECT_set_cmp_func(sk, cmp) \ - ((sk_X509_OBJECT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_OBJECT_sk_type(sk), \ - ossl_check_X509_OBJECT_compfunc_type(cmp))) -SKM_DEFINE_STACK_OF_INTERNAL(X509_VERIFY_PARAM, X509_VERIFY_PARAM, X509_VERIFY_PARAM) -#define sk_X509_VERIFY_PARAM_num(sk) OPENSSL_sk_num(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)) -#define sk_X509_VERIFY_PARAM_value(sk, idx) \ - ((X509_VERIFY_PARAM *)OPENSSL_sk_value(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), (idx))) -#define sk_X509_VERIFY_PARAM_new(cmp) \ - ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new(ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp))) -#define sk_X509_VERIFY_PARAM_new_null() ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_null()) -#define sk_X509_VERIFY_PARAM_new_reserve(cmp, n) \ - ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_reserve( \ - ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp), (n))) -#define sk_X509_VERIFY_PARAM_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (n)) -#define sk_X509_VERIFY_PARAM_free(sk) OPENSSL_sk_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) -#define sk_X509_VERIFY_PARAM_zero(sk) OPENSSL_sk_zero(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) -#define sk_X509_VERIFY_PARAM_delete(sk, i) \ - ((X509_VERIFY_PARAM *)OPENSSL_sk_delete(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (i))) -#define sk_X509_VERIFY_PARAM_delete_ptr(sk, ptr) \ - ((X509_VERIFY_PARAM *)OPENSSL_sk_delete_ptr(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr))) -#define sk_X509_VERIFY_PARAM_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr)) -#define sk_X509_VERIFY_PARAM_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr)) -#define sk_X509_VERIFY_PARAM_pop(sk) \ - ((X509_VERIFY_PARAM *)OPENSSL_sk_pop(ossl_check_X509_VERIFY_PARAM_sk_type(sk))) -#define sk_X509_VERIFY_PARAM_shift(sk) \ - ((X509_VERIFY_PARAM *)OPENSSL_sk_shift(ossl_check_X509_VERIFY_PARAM_sk_type(sk))) -#define sk_X509_VERIFY_PARAM_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc)) -#define sk_X509_VERIFY_PARAM_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr), (idx)) -#define sk_X509_VERIFY_PARAM_set(sk, idx, ptr) \ - ((X509_VERIFY_PARAM *)OPENSSL_sk_set(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (idx), \ - ossl_check_X509_VERIFY_PARAM_type(ptr))) -#define sk_X509_VERIFY_PARAM_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr)) -#define sk_X509_VERIFY_PARAM_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr)) -#define sk_X509_VERIFY_PARAM_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_type(ptr), pnum) -#define sk_X509_VERIFY_PARAM_sort(sk) OPENSSL_sk_sort(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) -#define sk_X509_VERIFY_PARAM_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)) -#define sk_X509_VERIFY_PARAM_dup(sk) \ - ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_dup(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk))) -#define sk_X509_VERIFY_PARAM_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_copyfunc_type(copyfunc), \ - ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc))) -#define sk_X509_VERIFY_PARAM_set_cmp_func(sk, cmp) \ - ((sk_X509_VERIFY_PARAM_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ - ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp))) +#define sk_X509_OBJECT_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_value(sk, idx) \ + ((X509_OBJECT *)OPENSSL_sk_value(ossl_check_const_X509_OBJECT_sk_type(sk), \ + (idx))) +#define sk_X509_OBJECT_new(cmp) \ + ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new( \ + ossl_check_X509_OBJECT_compfunc_type(cmp))) +#define sk_X509_OBJECT_new_null() \ + ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_null()) +#define sk_X509_OBJECT_new_reserve(cmp, n) \ + ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_OBJECT_compfunc_type(cmp), (n))) +#define sk_X509_OBJECT_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_OBJECT_sk_type(sk), (n)) +#define sk_X509_OBJECT_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_delete(sk, i) \ + ((X509_OBJECT *)OPENSSL_sk_delete(ossl_check_X509_OBJECT_sk_type(sk), (i))) +#define sk_X509_OBJECT_delete_ptr(sk, ptr) \ + ((X509_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr))) +#define sk_X509_OBJECT_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_pop(sk) \ + ((X509_OBJECT *)OPENSSL_sk_pop(ossl_check_X509_OBJECT_sk_type(sk))) +#define sk_X509_OBJECT_shift(sk) \ + ((X509_OBJECT *)OPENSSL_sk_shift(ossl_check_X509_OBJECT_sk_type(sk))) +#define sk_X509_OBJECT_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_freefunc_type(freefunc)) +#define sk_X509_OBJECT_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr), (idx)) +#define sk_X509_OBJECT_set(sk, idx, ptr) \ + ((X509_OBJECT *)OPENSSL_sk_set(ossl_check_X509_OBJECT_sk_type(sk), (idx), \ + ossl_check_X509_OBJECT_type(ptr))) +#define sk_X509_OBJECT_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr)) +#define sk_X509_OBJECT_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_type(ptr), pnum) +#define sk_X509_OBJECT_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_OBJECT_sk_type(sk)) +#define sk_X509_OBJECT_dup(sk) \ + ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_OBJECT_sk_type(sk))) +#define sk_X509_OBJECT_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_OBJECT) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_copyfunc_type(copyfunc), \ + ossl_check_X509_OBJECT_freefunc_type(freefunc))) +#define sk_X509_OBJECT_set_cmp_func(sk, cmp) \ + ((sk_X509_OBJECT_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_OBJECT_sk_type(sk), \ + ossl_check_X509_OBJECT_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509_VERIFY_PARAM, X509_VERIFY_PARAM, + X509_VERIFY_PARAM) +#define sk_X509_VERIFY_PARAM_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_value(sk, idx) \ + ((X509_VERIFY_PARAM *)OPENSSL_sk_value( \ + ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), (idx))) +#define sk_X509_VERIFY_PARAM_new(cmp) \ + ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new( \ + ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp))) +#define sk_X509_VERIFY_PARAM_new_null() \ + ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_null()) +#define sk_X509_VERIFY_PARAM_new_reserve(cmp, n) \ + ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp), (n))) +#define sk_X509_VERIFY_PARAM_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_VERIFY_PARAM_sk_type(sk), (n)) +#define sk_X509_VERIFY_PARAM_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_delete(sk, i) \ + ((X509_VERIFY_PARAM *)OPENSSL_sk_delete( \ + ossl_check_X509_VERIFY_PARAM_sk_type(sk), (i))) +#define sk_X509_VERIFY_PARAM_delete_ptr(sk, ptr) \ + ((X509_VERIFY_PARAM *)OPENSSL_sk_delete_ptr( \ + ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr))) +#define sk_X509_VERIFY_PARAM_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_pop(sk) \ + ((X509_VERIFY_PARAM *)OPENSSL_sk_pop( \ + ossl_check_X509_VERIFY_PARAM_sk_type(sk))) +#define sk_X509_VERIFY_PARAM_shift(sk) \ + ((X509_VERIFY_PARAM *)OPENSSL_sk_shift( \ + ossl_check_X509_VERIFY_PARAM_sk_type(sk))) +#define sk_X509_VERIFY_PARAM_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc)) +#define sk_X509_VERIFY_PARAM_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr), (idx)) +#define sk_X509_VERIFY_PARAM_set(sk, idx, ptr) \ + ((X509_VERIFY_PARAM *)OPENSSL_sk_set( \ + ossl_check_X509_VERIFY_PARAM_sk_type(sk), (idx), \ + ossl_check_X509_VERIFY_PARAM_type(ptr))) +#define sk_X509_VERIFY_PARAM_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr)) +#define sk_X509_VERIFY_PARAM_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_type(ptr), pnum) +#define sk_X509_VERIFY_PARAM_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_VERIFY_PARAM_sk_type(sk)) +#define sk_X509_VERIFY_PARAM_dup(sk) \ + ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_VERIFY_PARAM_sk_type(sk))) +#define sk_X509_VERIFY_PARAM_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_VERIFY_PARAM) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_copyfunc_type(copyfunc), \ + ossl_check_X509_VERIFY_PARAM_freefunc_type(freefunc))) +#define sk_X509_VERIFY_PARAM_set_cmp_func(sk, cmp) \ + ((sk_X509_VERIFY_PARAM_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_VERIFY_PARAM_sk_type(sk), \ + ossl_check_X509_VERIFY_PARAM_compfunc_type(cmp))) /* This is used for a table of trust checking functions */ typedef struct x509_trust_st { - int trust; - int flags; - int (*check_trust)(struct x509_trust_st *, X509 *, int); - char *name; - int arg1; - void *arg2; + int trust; + int flags; + int (*check_trust)(struct x509_trust_st *, X509 *, int); + char *name; + int arg1; + void *arg2; } X509_TRUST; SKM_DEFINE_STACK_OF_INTERNAL(X509_TRUST, X509_TRUST, X509_TRUST) -#define sk_X509_TRUST_num(sk) OPENSSL_sk_num(ossl_check_const_X509_TRUST_sk_type(sk)) -#define sk_X509_TRUST_value(sk, idx) \ - ((X509_TRUST *)OPENSSL_sk_value(ossl_check_const_X509_TRUST_sk_type(sk), (idx))) -#define sk_X509_TRUST_new(cmp) \ - ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new(ossl_check_X509_TRUST_compfunc_type(cmp))) +#define sk_X509_TRUST_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_value(sk, idx) \ + ((X509_TRUST *)OPENSSL_sk_value(ossl_check_const_X509_TRUST_sk_type(sk), \ + (idx))) +#define sk_X509_TRUST_new(cmp) \ + ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new( \ + ossl_check_X509_TRUST_compfunc_type(cmp))) #define sk_X509_TRUST_new_null() ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_null()) -#define sk_X509_TRUST_new_reserve(cmp, n) \ - ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_reserve(ossl_check_X509_TRUST_compfunc_type(cmp), (n))) -#define sk_X509_TRUST_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_TRUST_sk_type(sk), (n)) -#define sk_X509_TRUST_free(sk) OPENSSL_sk_free(ossl_check_X509_TRUST_sk_type(sk)) -#define sk_X509_TRUST_zero(sk) OPENSSL_sk_zero(ossl_check_X509_TRUST_sk_type(sk)) -#define sk_X509_TRUST_delete(sk, i) \ - ((X509_TRUST *)OPENSSL_sk_delete(ossl_check_X509_TRUST_sk_type(sk), (i))) -#define sk_X509_TRUST_delete_ptr(sk, ptr) \ - ((X509_TRUST *)OPENSSL_sk_delete_ptr(ossl_check_X509_TRUST_sk_type(sk), \ - ossl_check_X509_TRUST_type(ptr))) -#define sk_X509_TRUST_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) -#define sk_X509_TRUST_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) -#define sk_X509_TRUST_pop(sk) ((X509_TRUST *)OPENSSL_sk_pop(ossl_check_X509_TRUST_sk_type(sk))) -#define sk_X509_TRUST_shift(sk) ((X509_TRUST *)OPENSSL_sk_shift(ossl_check_X509_TRUST_sk_type(sk))) -#define sk_X509_TRUST_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_TRUST_sk_type(sk), \ - ossl_check_X509_TRUST_freefunc_type(freefunc)) -#define sk_X509_TRUST_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr), (idx)) -#define sk_X509_TRUST_set(sk, idx, ptr) \ - ((X509_TRUST *)OPENSSL_sk_set(ossl_check_X509_TRUST_sk_type(sk), (idx), \ - ossl_check_X509_TRUST_type(ptr))) -#define sk_X509_TRUST_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) -#define sk_X509_TRUST_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr)) -#define sk_X509_TRUST_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_TRUST_sk_type(sk), ossl_check_X509_TRUST_type(ptr), pnum) -#define sk_X509_TRUST_sort(sk) OPENSSL_sk_sort(ossl_check_X509_TRUST_sk_type(sk)) -#define sk_X509_TRUST_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_TRUST_sk_type(sk)) -#define sk_X509_TRUST_dup(sk) \ - ((STACK_OF(X509_TRUST) *)OPENSSL_sk_dup(ossl_check_const_X509_TRUST_sk_type(sk))) -#define sk_X509_TRUST_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_TRUST) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_TRUST_sk_type(sk), \ - ossl_check_X509_TRUST_copyfunc_type(copyfunc), \ - ossl_check_X509_TRUST_freefunc_type(freefunc))) -#define sk_X509_TRUST_set_cmp_func(sk, cmp) \ - ((sk_X509_TRUST_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_TRUST_sk_type(sk), \ - ossl_check_X509_TRUST_compfunc_type(cmp))) +#define sk_X509_TRUST_new_reserve(cmp, n) \ + ((STACK_OF(X509_TRUST) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_TRUST_compfunc_type(cmp), (n))) +#define sk_X509_TRUST_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_TRUST_sk_type(sk), (n)) +#define sk_X509_TRUST_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_delete(sk, i) \ + ((X509_TRUST *)OPENSSL_sk_delete(ossl_check_X509_TRUST_sk_type(sk), (i))) +#define sk_X509_TRUST_delete_ptr(sk, ptr) \ + ((X509_TRUST *)OPENSSL_sk_delete_ptr(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr))) +#define sk_X509_TRUST_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_pop(sk) \ + ((X509_TRUST *)OPENSSL_sk_pop(ossl_check_X509_TRUST_sk_type(sk))) +#define sk_X509_TRUST_shift(sk) \ + ((X509_TRUST *)OPENSSL_sk_shift(ossl_check_X509_TRUST_sk_type(sk))) +#define sk_X509_TRUST_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_freefunc_type(freefunc)) +#define sk_X509_TRUST_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr), (idx)) +#define sk_X509_TRUST_set(sk, idx, ptr) \ + ((X509_TRUST *)OPENSSL_sk_set(ossl_check_X509_TRUST_sk_type(sk), (idx), \ + ossl_check_X509_TRUST_type(ptr))) +#define sk_X509_TRUST_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr)) +#define sk_X509_TRUST_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_type(ptr), pnum) +#define sk_X509_TRUST_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_TRUST_sk_type(sk)) +#define sk_X509_TRUST_dup(sk) \ + ((STACK_OF(X509_TRUST) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_TRUST_sk_type(sk))) +#define sk_X509_TRUST_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_TRUST) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_copyfunc_type(copyfunc), \ + ossl_check_X509_TRUST_freefunc_type(freefunc))) +#define sk_X509_TRUST_set_cmp_func(sk, cmp) \ + ((sk_X509_TRUST_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_TRUST_sk_type(sk), \ + ossl_check_X509_TRUST_compfunc_type(cmp))) /* standard trust ids */ #define X509_TRUST_DEFAULT 0 /* Only valid in purpose settings */ @@ -319,8 +391,8 @@ int X509_TRUST_set(int *t, int trust); int X509_TRUST_get_count(void); X509_TRUST *X509_TRUST_get0(int idx); int X509_TRUST_get_by_id(int id); -int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), const char *name, - int arg1, void *arg2); +int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), + const char *name, int arg1, void *arg2); void X509_TRUST_cleanup(void); int X509_TRUST_get_flags(const X509_TRUST *xp); char *X509_TRUST_get0_name(const X509_TRUST *xp); @@ -340,30 +412,38 @@ int X509_check_trust(X509 *x, int id, int flags); int X509_verify_cert(X509_STORE_CTX *ctx); int X509_STORE_CTX_verify(X509_STORE_CTX *ctx); STACK_OF(X509) -*X509_build_chain(X509 *target, STACK_OF(X509) * certs, X509_STORE *store, int with_self_signed, - OSSL_LIB_CTX *libctx, const char *propq); +*X509_build_chain(X509 *target, STACK_OF(X509) * certs, X509_STORE *store, + int with_self_signed, OSSL_LIB_CTX *libctx, + const char *propq); int X509_STORE_set_depth(X509_STORE *store, int depth); typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *); int X509_STORE_CTX_print_verify_cb(int ok, X509_STORE_CTX *ctx); typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *); -typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); -typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); +typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer, X509_STORE_CTX *ctx, + X509 *x); +typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, X509 *x, + X509 *issuer); typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx); -typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); +typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx, X509_CRL **crl, + X509 *x); typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl); -typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); +typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl, + X509 *x); typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx); typedef STACK_OF(X509) - * (*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx, const X509_NAME *nm); + * (*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx, + const X509_NAME *nm); typedef STACK_OF(X509_CRL) - * (*X509_STORE_CTX_lookup_crls_fn)(const X509_STORE_CTX *ctx, const X509_NAME *nm); + * (*X509_STORE_CTX_lookup_crls_fn)(const X509_STORE_CTX *ctx, + const X509_NAME *nm); typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx); void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); -#define X509_STORE_CTX_set_app_data(ctx, data) X509_STORE_CTX_set_ex_data(ctx, 0, data) +#define X509_STORE_CTX_set_app_data(ctx, data) \ + X509_STORE_CTX_set_ex_data(ctx, 0, data) #define X509_STORE_CTX_get_app_data(ctx) X509_STORE_CTX_get_ex_data(ctx, 0) #define X509_L_FILE_LOAD 1 @@ -371,24 +451,28 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); #define X509_L_ADD_STORE 3 #define X509_L_LOAD_STORE 4 -#define X509_LOOKUP_load_file(x, name, type) \ - X509_LOOKUP_ctrl((x), X509_L_FILE_LOAD, (name), (long)(type), NULL) +#define X509_LOOKUP_load_file(x, name, type) \ + X509_LOOKUP_ctrl((x), X509_L_FILE_LOAD, (name), (long)(type), NULL) -#define X509_LOOKUP_add_dir(x, name, type) \ - X509_LOOKUP_ctrl((x), X509_L_ADD_DIR, (name), (long)(type), NULL) +#define X509_LOOKUP_add_dir(x, name, type) \ + X509_LOOKUP_ctrl((x), X509_L_ADD_DIR, (name), (long)(type), NULL) -#define X509_LOOKUP_add_store(x, name) X509_LOOKUP_ctrl((x), X509_L_ADD_STORE, (name), 0, NULL) +#define X509_LOOKUP_add_store(x, name) \ + X509_LOOKUP_ctrl((x), X509_L_ADD_STORE, (name), 0, NULL) -#define X509_LOOKUP_load_store(x, name) X509_LOOKUP_ctrl((x), X509_L_LOAD_STORE, (name), 0, NULL) +#define X509_LOOKUP_load_store(x, name) \ + X509_LOOKUP_ctrl((x), X509_L_LOAD_STORE, (name), 0, NULL) -#define X509_LOOKUP_load_file_ex(x, name, type, libctx, propq) \ - X509_LOOKUP_ctrl_ex((x), X509_L_FILE_LOAD, (name), (long)(type), NULL, (libctx), (propq)) +#define X509_LOOKUP_load_file_ex(x, name, type, libctx, propq) \ + X509_LOOKUP_ctrl_ex((x), X509_L_FILE_LOAD, (name), (long)(type), NULL, \ + (libctx), (propq)) -#define X509_LOOKUP_load_store_ex(x, name, libctx, propq) \ - X509_LOOKUP_ctrl_ex((x), X509_L_LOAD_STORE, (name), 0, NULL, (libctx), (propq)) +#define X509_LOOKUP_load_store_ex(x, name, libctx, propq) \ + X509_LOOKUP_ctrl_ex((x), X509_L_LOAD_STORE, (name), 0, NULL, (libctx), \ + (propq)) -#define X509_LOOKUP_add_store_ex(x, name, libctx, propq) \ - X509_LOOKUP_ctrl_ex((x), X509_L_ADD_STORE, (name), 0, NULL, (libctx), (propq)) +#define X509_LOOKUP_add_store_ex(x, name, libctx, propq) \ + X509_LOOKUP_ctrl_ex((x), X509_L_ADD_STORE, (name), 0, NULL, (libctx), (propq)) #define X509_V_OK 0 #define X509_V_ERR_UNSPECIFIED 1 @@ -477,8 +561,10 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); #define X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION 72 /* OCSP status errors */ #define X509_V_ERR_OCSP_VERIFY_NEEDED 73 /* Need OCSP verification */ -#define X509_V_ERR_OCSP_VERIFY_FAILED 74 /* Couldn't verify cert through OCSP */ -#define X509_V_ERR_OCSP_CERT_UNKNOWN 75 /* Certificate wasn't recognized by the OCSP responder */ +#define X509_V_ERR_OCSP_VERIFY_FAILED 74 /* Couldn't verify cert through OCSP \ + */ +#define X509_V_ERR_OCSP_CERT_UNKNOWN \ + 75 /* Certificate wasn't recognized by the OCSP responder */ #define X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM 76 #define X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH 77 @@ -504,7 +590,7 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); /* Certificate verify flags */ #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */ +# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */ #endif /* Use check time instead of current time */ #define X509_V_FLAG_USE_CHECK_TIME 0x2 @@ -560,15 +646,17 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); #define X509_VP_FLAG_ONCE 0x10 /* Internal use: mask of policy related options */ -#define X509_V_FLAG_POLICY_MASK \ - (X509_V_FLAG_POLICY_CHECK | X509_V_FLAG_EXPLICIT_POLICY | X509_V_FLAG_INHIBIT_ANY \ - | X509_V_FLAG_INHIBIT_MAP) +#define X509_V_FLAG_POLICY_MASK \ + (X509_V_FLAG_POLICY_CHECK | X509_V_FLAG_EXPLICIT_POLICY \ + | X509_V_FLAG_INHIBIT_ANY | X509_V_FLAG_INHIBIT_MAP) int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) * h, X509_LOOKUP_TYPE type, const X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) * h, X509_LOOKUP_TYPE type, +X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) * h, + X509_LOOKUP_TYPE type, const X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) * h, X509_OBJECT *x); +X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) * h, + X509_OBJECT *x); int X509_OBJECT_up_ref_count(X509_OBJECT *a); X509_OBJECT *X509_OBJECT_new(void); void X509_OBJECT_free(X509_OBJECT *a); @@ -584,8 +672,10 @@ int X509_STORE_unlock(X509_STORE *xs); int X509_STORE_up_ref(X509_STORE *xs); STACK_OF(X509_OBJECT) * X509_STORE_get0_objects(const X509_STORE *xs); STACK_OF(X509) * X509_STORE_get1_all_certs(X509_STORE *xs); -STACK_OF(X509) * X509_STORE_CTX_get1_certs(X509_STORE_CTX *xs, const X509_NAME *nm); -STACK_OF(X509_CRL) * X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st, const X509_NAME *nm); +STACK_OF(X509) + * X509_STORE_CTX_get1_certs(X509_STORE_CTX *xs, const X509_NAME *nm); +STACK_OF(X509_CRL) + * X509_STORE_CTX_get1_crls(const X509_STORE_CTX *st, const X509_NAME *nm); int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags); int X509_STORE_set_purpose(X509_STORE *xs, int purpose); int X509_STORE_set_trust(X509_STORE *xs, int trust); @@ -593,37 +683,50 @@ int X509_STORE_set1_param(X509_STORE *xs, const X509_VERIFY_PARAM *pm); X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *xs); void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify); -#define X509_STORE_set_verify_func(ctx, func) X509_STORE_set_verify((ctx), (func)) -void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_fn verify); +#define X509_STORE_set_verify_func(ctx, func) \ + X509_STORE_set_verify((ctx), (func)) +void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, + X509_STORE_CTX_verify_fn verify); X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *xs); -void X509_STORE_set_verify_cb(X509_STORE *xs, X509_STORE_CTX_verify_cb verify_cb); -#define X509_STORE_set_verify_cb_func(ctx, func) X509_STORE_set_verify_cb((ctx), (func)) +void X509_STORE_set_verify_cb(X509_STORE *xs, + X509_STORE_CTX_verify_cb verify_cb); +#define X509_STORE_set_verify_cb_func(ctx, func) \ + X509_STORE_set_verify_cb((ctx), (func)) X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *xs); -void X509_STORE_set_get_issuer(X509_STORE *xs, X509_STORE_CTX_get_issuer_fn get_issuer); +void X509_STORE_set_get_issuer(X509_STORE *xs, + X509_STORE_CTX_get_issuer_fn get_issuer); X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *xs); -void X509_STORE_set_check_issued(X509_STORE *xs, X509_STORE_CTX_check_issued_fn check_issued); +void X509_STORE_set_check_issued(X509_STORE *xs, + X509_STORE_CTX_check_issued_fn check_issued); X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *s); -void X509_STORE_set_check_revocation(X509_STORE *xs, - X509_STORE_CTX_check_revocation_fn check_revocation); -X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(const X509_STORE *xs); +void X509_STORE_set_check_revocation( + X509_STORE *xs, X509_STORE_CTX_check_revocation_fn check_revocation); +X509_STORE_CTX_check_revocation_fn +X509_STORE_get_check_revocation(const X509_STORE *xs); void X509_STORE_set_get_crl(X509_STORE *xs, X509_STORE_CTX_get_crl_fn get_crl); X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *xs); -void X509_STORE_set_check_crl(X509_STORE *xs, X509_STORE_CTX_check_crl_fn check_crl); +void X509_STORE_set_check_crl(X509_STORE *xs, + X509_STORE_CTX_check_crl_fn check_crl); X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *xs); -void X509_STORE_set_cert_crl(X509_STORE *xs, X509_STORE_CTX_cert_crl_fn cert_crl); +void X509_STORE_set_cert_crl(X509_STORE *xs, + X509_STORE_CTX_cert_crl_fn cert_crl); X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *xs); -void X509_STORE_set_check_policy(X509_STORE *xs, X509_STORE_CTX_check_policy_fn check_policy); +void X509_STORE_set_check_policy(X509_STORE *xs, + X509_STORE_CTX_check_policy_fn check_policy); X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *s); -void X509_STORE_set_lookup_certs(X509_STORE *xs, X509_STORE_CTX_lookup_certs_fn lookup_certs); +void X509_STORE_set_lookup_certs(X509_STORE *xs, + X509_STORE_CTX_lookup_certs_fn lookup_certs); X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *s); -void X509_STORE_set_lookup_crls(X509_STORE *xs, X509_STORE_CTX_lookup_crls_fn lookup_crls); -#define X509_STORE_set_lookup_crls_cb(ctx, func) X509_STORE_set_lookup_crls((ctx), (func)) +void X509_STORE_set_lookup_crls(X509_STORE *xs, + X509_STORE_CTX_lookup_crls_fn lookup_crls); +#define X509_STORE_set_lookup_crls_cb(ctx, func) \ + X509_STORE_set_lookup_crls((ctx), (func)) X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *xs); void X509_STORE_set_cleanup(X509_STORE *xs, X509_STORE_CTX_cleanup_fn cleanup); X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *xs); -#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef) +#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef) int X509_STORE_set_ex_data(X509_STORE *xs, int idx, void *data); void *X509_STORE_get_ex_data(const X509_STORE *xs, int idx); @@ -633,40 +736,51 @@ X509_STORE_CTX *X509_STORE_CTX_new(void); int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); void X509_STORE_CTX_free(X509_STORE_CTX *ctx); -int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *trust_store, X509 *target, - STACK_OF(X509) * untrusted); -void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) * sk); +int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *trust_store, + X509 *target, STACK_OF(X509) * untrusted); +void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, + STACK_OF(X509) * sk); void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx); X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx); STACK_OF(X509) * X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx); void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) * sk); -void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_cb verify); -X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx); +void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, + X509_STORE_CTX_verify_cb verify); +X509_STORE_CTX_verify_cb +X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx); X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx); -X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx); -X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx); -X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx); +X509_STORE_CTX_get_issuer_fn +X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_issued_fn +X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_revocation_fn +X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx); X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(const X509_STORE_CTX *ctx); -X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx); -X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx); -X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx); -X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx); -X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_crl_fn +X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx); +X509_STORE_CTX_cert_crl_fn +X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx); +X509_STORE_CTX_check_policy_fn +X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx); +X509_STORE_CTX_lookup_certs_fn +X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx); +X509_STORE_CTX_lookup_crls_fn +X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx); X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(const X509_STORE_CTX *ctx); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 -# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain -# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted -# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack -# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject -# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs -# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls +# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain +# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted +# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack +# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject +# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs +# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls /* the following macro is misspelled; use X509_STORE_get1_certs instead */ -# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs +# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs /* the following macro is misspelled; use X509_STORE_get1_crls instead */ -# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls +# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls #endif X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *xs, X509_LOOKUP_METHOD *m); @@ -674,93 +788,119 @@ X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); X509_LOOKUP_METHOD *X509_LOOKUP_file(void); X509_LOOKUP_METHOD *X509_LOOKUP_store(void); -typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, - char **ret); -typedef int (*X509_LOOKUP_ctrl_ex_fn)(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, - char **ret, OSSL_LIB_CTX *libctx, const char *propq); +typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc, + long argl, char **ret); +typedef int (*X509_LOOKUP_ctrl_ex_fn)(X509_LOOKUP *ctx, int cmd, + const char *argc, long argl, char **ret, + OSSL_LIB_CTX *libctx, const char *propq); -typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const X509_NAME *name, X509_OBJECT *ret); -typedef int (*X509_LOOKUP_get_by_subject_ex_fn)(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const X509_NAME *name, X509_OBJECT *ret, - OSSL_LIB_CTX *libctx, const char *propq); -typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, +typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const X509_NAME *name, + X509_OBJECT *ret); +typedef int (*X509_LOOKUP_get_by_subject_ex_fn)( + X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const X509_NAME *name, + X509_OBJECT *ret, OSSL_LIB_CTX *libctx, const char *propq); +typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, const X509_NAME *name, - const ASN1_INTEGER *serial, X509_OBJECT *ret); -typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const unsigned char *bytes, int len, - X509_OBJECT *ret); -typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const char *str, - int len, X509_OBJECT *ret); + const ASN1_INTEGER *serial, + X509_OBJECT *ret); +typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const unsigned char *bytes, + int len, X509_OBJECT *ret); +typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx, + X509_LOOKUP_TYPE type, + const char *str, int len, + X509_OBJECT *ret); X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name); void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method); -int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method, int (*new_item)(X509_LOOKUP *ctx)); -int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx); +int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method, + int (*new_item)(X509_LOOKUP *ctx)); +int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD *method))( + X509_LOOKUP *ctx); -int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method, void (*free_fn)(X509_LOOKUP *ctx)); -void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx); +int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method, + void (*free_fn)(X509_LOOKUP *ctx)); +void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD *method))( + X509_LOOKUP *ctx); -int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method, int (*init)(X509_LOOKUP *ctx)); -int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx); +int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method, + int (*init)(X509_LOOKUP *ctx)); +int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD *method))( + X509_LOOKUP *ctx); -int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method, int (*shutdown)(X509_LOOKUP *ctx)); -int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx); +int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method, + int (*shutdown)(X509_LOOKUP *ctx)); +int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD *method))( + X509_LOOKUP *ctx); -int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method, X509_LOOKUP_ctrl_fn ctrl_fn); +int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method, + X509_LOOKUP_ctrl_fn ctrl_fn); X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method); int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method, X509_LOOKUP_get_by_subject_fn fn); -X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(const X509_LOOKUP_METHOD *method); +X509_LOOKUP_get_by_subject_fn +X509_LOOKUP_meth_get_get_by_subject(const X509_LOOKUP_METHOD *method); -int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method, - X509_LOOKUP_get_by_issuer_serial_fn fn); +int X509_LOOKUP_meth_set_get_by_issuer_serial( + X509_LOOKUP_METHOD *method, X509_LOOKUP_get_by_issuer_serial_fn fn); X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(const X509_LOOKUP_METHOD *method); -int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method, - X509_LOOKUP_get_by_fingerprint_fn fn); +int X509_LOOKUP_meth_set_get_by_fingerprint( + X509_LOOKUP_METHOD *method, X509_LOOKUP_get_by_fingerprint_fn fn); X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(const X509_LOOKUP_METHOD *method); -int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method, X509_LOOKUP_get_by_alias_fn fn); -X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(const X509_LOOKUP_METHOD *method); +int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method, + X509_LOOKUP_get_by_alias_fn fn); +X509_LOOKUP_get_by_alias_fn +X509_LOOKUP_meth_get_get_by_alias(const X509_LOOKUP_METHOD *method); int X509_STORE_add_cert(X509_STORE *xs, X509 *x); int X509_STORE_add_crl(X509_STORE *xs, X509_CRL *x); -int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, - const X509_NAME *name, X509_OBJECT *ret); -X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, +int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs, + X509_LOOKUP_TYPE type, const X509_NAME *name, + X509_OBJECT *ret); +X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, + X509_LOOKUP_TYPE type, const X509_NAME *name); -int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); -int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret, - OSSL_LIB_CTX *libctx, const char *propq); +int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, + char **ret); +int X509_LOOKUP_ctrl_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, + char **ret, OSSL_LIB_CTX *libctx, const char *propq); int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type, OSSL_LIB_CTX *libctx, - const char *propq); +int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type, + OSSL_LIB_CTX *libctx, const char *propq); int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type, OSSL_LIB_CTX *libctx, - const char *propq); +int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type, + OSSL_LIB_CTX *libctx, const char *propq); X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); void X509_LOOKUP_free(X509_LOOKUP *ctx); int X509_LOOKUP_init(X509_LOOKUP *ctx); -int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const X509_NAME *name, - X509_OBJECT *ret); -int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const X509_NAME *name, - X509_OBJECT *ret, OSSL_LIB_CTX *libctx, const char *propq); -int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const X509_NAME *name, +int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const X509_NAME *name, X509_OBJECT *ret); +int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const X509_NAME *name, X509_OBJECT *ret, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const X509_NAME *name, const ASN1_INTEGER *serial, X509_OBJECT *ret); -int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const unsigned char *bytes, - int len, X509_OBJECT *ret); -int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const char *str, int len, - X509_OBJECT *ret); +int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const unsigned char *bytes, int len, + X509_OBJECT *ret); +int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const char *str, int len, X509_OBJECT *ret); int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data); void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx); X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx); @@ -772,16 +912,19 @@ int X509_STORE_load_store(X509_STORE *xs, const char *store); int X509_STORE_load_locations(X509_STORE *s, const char *file, const char *dir); int X509_STORE_set_default_paths(X509_STORE *xs); -int X509_STORE_load_file_ex(X509_STORE *xs, const char *file, OSSL_LIB_CTX *libctx, - const char *propq); -int X509_STORE_load_store_ex(X509_STORE *xs, const char *store, OSSL_LIB_CTX *libctx, - const char *propq); -int X509_STORE_load_locations_ex(X509_STORE *xs, const char *file, const char *dir, - OSSL_LIB_CTX *libctx, const char *propq); -int X509_STORE_set_default_paths_ex(X509_STORE *xs, OSSL_LIB_CTX *libctx, const char *propq); +int X509_STORE_load_file_ex(X509_STORE *xs, const char *file, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_STORE_load_store_ex(X509_STORE *xs, const char *store, + OSSL_LIB_CTX *libctx, const char *propq); +int X509_STORE_load_locations_ex(X509_STORE *xs, const char *file, + const char *dir, OSSL_LIB_CTX *libctx, + const char *propq); +int X509_STORE_set_default_paths_ex(X509_STORE *xs, OSSL_LIB_CTX *libctx, + const char *propq); -#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef) +#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ + CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, \ + freef) int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx); int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx); @@ -800,9 +943,11 @@ void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) * sk); void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) * sk); int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); -int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, int purpose, int trust); +int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, + int purpose, int trust); void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); -void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, time_t t); +void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, + time_t t); X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(const X509_STORE_CTX *ctx); int X509_STORE_CTX_get_explicit_policy(const X509_STORE_CTX *ctx); @@ -823,11 +968,14 @@ void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane); X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); +int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, + const X509_VERIFY_PARAM *from); int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); -int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, unsigned long flags); +int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, + unsigned long flags); unsigned long X509_VERIFY_PARAM_get_flags(const X509_VERIFY_PARAM *param); int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); @@ -835,23 +983,30 @@ void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level); time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param); void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); -int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy); -int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, STACK_OF(ASN1_OBJECT) * policies); +int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, + ASN1_OBJECT *policy); +int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, + STACK_OF(ASN1_OBJECT) * policies); int X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param, uint32_t flags); uint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param); char *X509_VERIFY_PARAM_get0_host(X509_VERIFY_PARAM *param, int idx); -int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, const char *name, size_t namelen); -int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, const char *name, size_t namelen); -void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, unsigned int flags); +int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, const char *name, + size_t namelen); +int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, const char *name, + size_t namelen); +void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, + unsigned int flags); unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param); char *X509_VERIFY_PARAM_get0_peername(const X509_VERIFY_PARAM *param); void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *); char *X509_VERIFY_PARAM_get0_email(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, const char *email, size_t emaillen); +int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, const char *email, + size_t emaillen); char *X509_VERIFY_PARAM_get1_ip_asc(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const unsigned char *ip, size_t iplen); +int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const unsigned char *ip, + size_t iplen); int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, const char *ipasc); int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); @@ -873,17 +1028,19 @@ void X509_VERIFY_PARAM_table_cleanup(void); * Positive return values form a bit mask, all but the first are internal to * the library and don't appear in results from X509_policy_check(). */ -#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */ -#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */ +#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */ +#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */ #define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */ -int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, STACK_OF(X509) * certs, +int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, + STACK_OF(X509) * certs, STACK_OF(ASN1_OBJECT) * policy_oids, unsigned int flags); void X509_policy_tree_free(X509_POLICY_TREE *tree); int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); -X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); +X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, + int i); STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); @@ -893,13 +1050,15 @@ STACK_OF(X509_POLICY_NODE) int X509_policy_level_node_count(X509_POLICY_LEVEL *level); -X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level, int i); +X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level, + int i); const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); STACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); -const X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE *node); +const X509_POLICY_NODE * +X509_policy_node_get0_parent(const X509_POLICY_NODE *node); #ifdef __cplusplus } diff --git a/libs/OpenSSL/include/openssl/x509v3.h b/libs/OpenSSL/include/openssl/x509v3.h index 0dd1def9..8ce75148 100644 --- a/libs/OpenSSL/include/openssl/x509v3.h +++ b/libs/OpenSSL/include/openssl/x509v3.h @@ -16,7 +16,7 @@ #include #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define HEADER_X509V3_H +# define HEADER_X509V3_H #endif #include @@ -24,7 +24,7 @@ #include #include #ifndef OPENSSL_NO_STDIO -# include +# include #endif #ifdef __cplusplus @@ -44,46 +44,48 @@ typedef int (*X509V3_EXT_I2D)(const void *, unsigned char **); typedef STACK_OF(CONF_VALUE) * (*X509V3_EXT_I2V)(const struct v3_ext_method *method, void *ext, STACK_OF(CONF_VALUE) * extlist); -typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method, struct v3_ext_ctx *ctx, +typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method, + struct v3_ext_ctx *ctx, STACK_OF(CONF_VALUE) * values); typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext); -typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method, struct v3_ext_ctx *ctx, - const char *str); -typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext, BIO *out, int indent); -typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method, struct v3_ext_ctx *ctx, - const char *str); +typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method, + struct v3_ext_ctx *ctx, const char *str); +typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext, + BIO *out, int indent); +typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method, + struct v3_ext_ctx *ctx, const char *str); /* V3 extension structure */ struct v3_ext_method { - int ext_nid; - int ext_flags; - /* If this is set the following four fields are ignored */ - ASN1_ITEM_EXP *it; - /* Old style ASN1 calls */ - X509V3_EXT_NEW ext_new; - X509V3_EXT_FREE ext_free; - X509V3_EXT_D2I d2i; - X509V3_EXT_I2D i2d; - /* The following pair is used for string extensions */ - X509V3_EXT_I2S i2s; - X509V3_EXT_S2I s2i; - /* The following pair is used for multi-valued extensions */ - X509V3_EXT_I2V i2v; - X509V3_EXT_V2I v2i; - /* The following are used for raw extensions */ - X509V3_EXT_I2R i2r; - X509V3_EXT_R2I r2i; - void *usr_data; /* Any extension specific data */ + int ext_nid; + int ext_flags; + /* If this is set the following four fields are ignored */ + ASN1_ITEM_EXP *it; + /* Old style ASN1 calls */ + X509V3_EXT_NEW ext_new; + X509V3_EXT_FREE ext_free; + X509V3_EXT_D2I d2i; + X509V3_EXT_I2D i2d; + /* The following pair is used for string extensions */ + X509V3_EXT_I2S i2s; + X509V3_EXT_S2I s2i; + /* The following pair is used for multi-valued extensions */ + X509V3_EXT_I2V i2v; + X509V3_EXT_V2I v2i; + /* The following are used for raw extensions */ + X509V3_EXT_I2R i2r; + X509V3_EXT_R2I r2i; + void *usr_data; /* Any extension specific data */ }; typedef struct X509V3_CONF_METHOD_st { - char *(*get_string)(void *db, const char *section, const char *value); - STACK_OF(CONF_VALUE) * (*get_section)(void *db, const char *section); - void (*free_string)(void *db, char *string); - void (*free_section)(void *db, STACK_OF(CONF_VALUE) * section); + char *(*get_string)(void *db, const char *section, const char *value); + STACK_OF(CONF_VALUE) * (*get_section)(void *db, const char *section); + void (*free_string)(void *db, char *string); + void (*free_section)(void *db, STACK_OF(CONF_VALUE) * section); } X509V3_CONF_METHOD; /* Context specific info for producing X509 v3 extensions*/ @@ -91,83 +93,97 @@ struct v3_ext_ctx { #define X509V3_CTX_TEST 0x1 #ifndef OPENSSL_NO_DEPRECATED_3_0 -# define CTX_TEST X509V3_CTX_TEST +# define CTX_TEST X509V3_CTX_TEST #endif #define X509V3_CTX_REPLACE 0x2 - int flags; - X509 *issuer_cert; - X509 *subject_cert; - X509_REQ *subject_req; - X509_CRL *crl; - X509V3_CONF_METHOD *db_meth; - void *db; - EVP_PKEY *issuer_pkey; - /* Maybe more here */ + int flags; + X509 *issuer_cert; + X509 *subject_cert; + X509_REQ *subject_req; + X509_CRL *crl; + X509V3_CONF_METHOD *db_meth; + void *db; + EVP_PKEY *issuer_pkey; + /* Maybe more here */ }; typedef struct v3_ext_method X509V3_EXT_METHOD; -SKM_DEFINE_STACK_OF_INTERNAL(X509V3_EXT_METHOD, X509V3_EXT_METHOD, X509V3_EXT_METHOD) -#define sk_X509V3_EXT_METHOD_num(sk) OPENSSL_sk_num(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk)) -#define sk_X509V3_EXT_METHOD_value(sk, idx) \ - ((X509V3_EXT_METHOD *)OPENSSL_sk_value(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk), (idx))) -#define sk_X509V3_EXT_METHOD_new(cmp) \ - ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new(ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp))) -#define sk_X509V3_EXT_METHOD_new_null() ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new_null()) -#define sk_X509V3_EXT_METHOD_new_reserve(cmp, n) \ - ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new_reserve( \ - ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp), (n))) -#define sk_X509V3_EXT_METHOD_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (n)) -#define sk_X509V3_EXT_METHOD_free(sk) OPENSSL_sk_free(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) -#define sk_X509V3_EXT_METHOD_zero(sk) OPENSSL_sk_zero(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) -#define sk_X509V3_EXT_METHOD_delete(sk, i) \ - ((X509V3_EXT_METHOD *)OPENSSL_sk_delete(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (i))) -#define sk_X509V3_EXT_METHOD_delete_ptr(sk, ptr) \ - ((X509V3_EXT_METHOD *)OPENSSL_sk_delete_ptr(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr))) -#define sk_X509V3_EXT_METHOD_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr)) -#define sk_X509V3_EXT_METHOD_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr)) -#define sk_X509V3_EXT_METHOD_pop(sk) \ - ((X509V3_EXT_METHOD *)OPENSSL_sk_pop(ossl_check_X509V3_EXT_METHOD_sk_type(sk))) -#define sk_X509V3_EXT_METHOD_shift(sk) \ - ((X509V3_EXT_METHOD *)OPENSSL_sk_shift(ossl_check_X509V3_EXT_METHOD_sk_type(sk))) -#define sk_X509V3_EXT_METHOD_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_freefunc_type(freefunc)) -#define sk_X509V3_EXT_METHOD_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr), (idx)) -#define sk_X509V3_EXT_METHOD_set(sk, idx, ptr) \ - ((X509V3_EXT_METHOD *)OPENSSL_sk_set(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (idx), \ - ossl_check_X509V3_EXT_METHOD_type(ptr))) -#define sk_X509V3_EXT_METHOD_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr)) -#define sk_X509V3_EXT_METHOD_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr)) -#define sk_X509V3_EXT_METHOD_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_type(ptr), pnum) -#define sk_X509V3_EXT_METHOD_sort(sk) OPENSSL_sk_sort(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) -#define sk_X509V3_EXT_METHOD_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk)) -#define sk_X509V3_EXT_METHOD_dup(sk) \ - ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_dup(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk))) -#define sk_X509V3_EXT_METHOD_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_copyfunc_type(copyfunc), \ - ossl_check_X509V3_EXT_METHOD_freefunc_type(freefunc))) -#define sk_X509V3_EXT_METHOD_set_cmp_func(sk, cmp) \ - ((sk_X509V3_EXT_METHOD_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ - ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509V3_EXT_METHOD, X509V3_EXT_METHOD, + X509V3_EXT_METHOD) +#define sk_X509V3_EXT_METHOD_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_value(sk, idx) \ + ((X509V3_EXT_METHOD *)OPENSSL_sk_value( \ + ossl_check_const_X509V3_EXT_METHOD_sk_type(sk), (idx))) +#define sk_X509V3_EXT_METHOD_new(cmp) \ + ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new( \ + ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp))) +#define sk_X509V3_EXT_METHOD_new_null() \ + ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new_null()) +#define sk_X509V3_EXT_METHOD_new_reserve(cmp, n) \ + ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp), (n))) +#define sk_X509V3_EXT_METHOD_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509V3_EXT_METHOD_sk_type(sk), (n)) +#define sk_X509V3_EXT_METHOD_free(sk) \ + OPENSSL_sk_free(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_delete(sk, i) \ + ((X509V3_EXT_METHOD *)OPENSSL_sk_delete( \ + ossl_check_X509V3_EXT_METHOD_sk_type(sk), (i))) +#define sk_X509V3_EXT_METHOD_delete_ptr(sk, ptr) \ + ((X509V3_EXT_METHOD *)OPENSSL_sk_delete_ptr( \ + ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr))) +#define sk_X509V3_EXT_METHOD_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_pop(sk) \ + ((X509V3_EXT_METHOD *)OPENSSL_sk_pop( \ + ossl_check_X509V3_EXT_METHOD_sk_type(sk))) +#define sk_X509V3_EXT_METHOD_shift(sk) \ + ((X509V3_EXT_METHOD *)OPENSSL_sk_shift( \ + ossl_check_X509V3_EXT_METHOD_sk_type(sk))) +#define sk_X509V3_EXT_METHOD_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_freefunc_type(freefunc)) +#define sk_X509V3_EXT_METHOD_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr), (idx)) +#define sk_X509V3_EXT_METHOD_set(sk, idx, ptr) \ + ((X509V3_EXT_METHOD *)OPENSSL_sk_set( \ + ossl_check_X509V3_EXT_METHOD_sk_type(sk), (idx), \ + ossl_check_X509V3_EXT_METHOD_type(ptr))) +#define sk_X509V3_EXT_METHOD_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr)) +#define sk_X509V3_EXT_METHOD_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_type(ptr), pnum) +#define sk_X509V3_EXT_METHOD_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509V3_EXT_METHOD_sk_type(sk)) +#define sk_X509V3_EXT_METHOD_dup(sk) \ + ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_dup( \ + ossl_check_const_X509V3_EXT_METHOD_sk_type(sk))) +#define sk_X509V3_EXT_METHOD_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509V3_EXT_METHOD) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_copyfunc_type(copyfunc), \ + ossl_check_X509V3_EXT_METHOD_freefunc_type(freefunc))) +#define sk_X509V3_EXT_METHOD_set_cmp_func(sk, cmp) \ + ((sk_X509V3_EXT_METHOD_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509V3_EXT_METHOD_sk_type(sk), \ + ossl_check_X509V3_EXT_METHOD_compfunc_type(cmp))) /* ext_flags values */ #define X509V3_EXT_DYNAMIC 0x1 @@ -178,26 +194,26 @@ typedef BIT_STRING_BITNAME ENUMERATED_NAMES; typedef struct BASIC_CONSTRAINTS_st { - int ca; - ASN1_INTEGER *pathlen; + int ca; + ASN1_INTEGER *pathlen; } BASIC_CONSTRAINTS; typedef struct PKEY_USAGE_PERIOD_st { - ASN1_GENERALIZEDTIME *notBefore; - ASN1_GENERALIZEDTIME *notAfter; + ASN1_GENERALIZEDTIME *notBefore; + ASN1_GENERALIZEDTIME *notAfter; } PKEY_USAGE_PERIOD; typedef struct otherName_st { - ASN1_OBJECT *type_id; - ASN1_TYPE *value; + ASN1_OBJECT *type_id; + ASN1_TYPE *value; } OTHERNAME; typedef struct EDIPartyName_st { - ASN1_STRING *nameAssigner; - ASN1_STRING *partyName; + ASN1_STRING *nameAssigner; + ASN1_STRING *partyName; } EDIPARTYNAME; typedef struct GENERAL_NAME_st @@ -211,153 +227,179 @@ typedef struct GENERAL_NAME_st #define GEN_URI 6 #define GEN_IPADD 7 #define GEN_RID 8 - int type; - union - { - char *ptr; - OTHERNAME *otherName; /* otherName */ - ASN1_IA5STRING *rfc822Name; - ASN1_IA5STRING *dNSName; - ASN1_TYPE *x400Address; - X509_NAME *directoryName; - EDIPARTYNAME *ediPartyName; - ASN1_IA5STRING *uniformResourceIdentifier; - ASN1_OCTET_STRING *iPAddress; - ASN1_OBJECT *registeredID; - /* Old names */ - ASN1_OCTET_STRING *ip; /* iPAddress */ - X509_NAME *dirn; /* dirn */ - ASN1_IA5STRING *ia5; /* rfc822Name, dNSName, - * uniformResourceIdentifier */ - ASN1_OBJECT *rid; /* registeredID */ - ASN1_TYPE *other; /* x400Address */ - } d; + int type; + union + { + char *ptr; + OTHERNAME *otherName; /* otherName */ + ASN1_IA5STRING *rfc822Name; + ASN1_IA5STRING *dNSName; + ASN1_TYPE *x400Address; + X509_NAME *directoryName; + EDIPARTYNAME *ediPartyName; + ASN1_IA5STRING *uniformResourceIdentifier; + ASN1_OCTET_STRING *iPAddress; + ASN1_OBJECT *registeredID; + /* Old names */ + ASN1_OCTET_STRING *ip; /* iPAddress */ + X509_NAME *dirn; /* dirn */ + ASN1_IA5STRING *ia5; /* rfc822Name, dNSName, + * uniformResourceIdentifier */ + ASN1_OBJECT *rid; /* registeredID */ + ASN1_TYPE *other; /* x400Address */ + } d; } GENERAL_NAME; typedef struct ACCESS_DESCRIPTION_st { - ASN1_OBJECT *method; - GENERAL_NAME *location; + ASN1_OBJECT *method; + GENERAL_NAME *location; } ACCESS_DESCRIPTION; -SKM_DEFINE_STACK_OF_INTERNAL(ACCESS_DESCRIPTION, ACCESS_DESCRIPTION, ACCESS_DESCRIPTION) -#define sk_ACCESS_DESCRIPTION_num(sk) \ - OPENSSL_sk_num(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk)) -#define sk_ACCESS_DESCRIPTION_value(sk, idx) \ - ((ACCESS_DESCRIPTION *)OPENSSL_sk_value(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk), (idx))) -#define sk_ACCESS_DESCRIPTION_new(cmp) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new( \ - ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp))) -#define sk_ACCESS_DESCRIPTION_new_null() ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new_null()) -#define sk_ACCESS_DESCRIPTION_new_reserve(cmp, n) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new_reserve( \ - ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp), (n))) -#define sk_ACCESS_DESCRIPTION_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (n)) -#define sk_ACCESS_DESCRIPTION_free(sk) OPENSSL_sk_free(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) -#define sk_ACCESS_DESCRIPTION_zero(sk) OPENSSL_sk_zero(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) -#define sk_ACCESS_DESCRIPTION_delete(sk, i) \ - ((ACCESS_DESCRIPTION *)OPENSSL_sk_delete(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (i))) -#define sk_ACCESS_DESCRIPTION_delete_ptr(sk, ptr) \ - ((ACCESS_DESCRIPTION *)OPENSSL_sk_delete_ptr(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr))) -#define sk_ACCESS_DESCRIPTION_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr)) -#define sk_ACCESS_DESCRIPTION_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr)) -#define sk_ACCESS_DESCRIPTION_pop(sk) \ - ((ACCESS_DESCRIPTION *)OPENSSL_sk_pop(ossl_check_ACCESS_DESCRIPTION_sk_type(sk))) -#define sk_ACCESS_DESCRIPTION_shift(sk) \ - ((ACCESS_DESCRIPTION *)OPENSSL_sk_shift(ossl_check_ACCESS_DESCRIPTION_sk_type(sk))) -#define sk_ACCESS_DESCRIPTION_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_freefunc_type(freefunc)) -#define sk_ACCESS_DESCRIPTION_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr), (idx)) -#define sk_ACCESS_DESCRIPTION_set(sk, idx, ptr) \ - ((ACCESS_DESCRIPTION *)OPENSSL_sk_set(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (idx), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr))) -#define sk_ACCESS_DESCRIPTION_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr)) -#define sk_ACCESS_DESCRIPTION_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr)) -#define sk_ACCESS_DESCRIPTION_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_type(ptr), pnum) -#define sk_ACCESS_DESCRIPTION_sort(sk) OPENSSL_sk_sort(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) -#define sk_ACCESS_DESCRIPTION_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk)) -#define sk_ACCESS_DESCRIPTION_dup(sk) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_dup( \ - ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk))) -#define sk_ACCESS_DESCRIPTION_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_copyfunc_type(copyfunc), \ - ossl_check_ACCESS_DESCRIPTION_freefunc_type(freefunc))) -#define sk_ACCESS_DESCRIPTION_set_cmp_func(sk, cmp) \ - ((sk_ACCESS_DESCRIPTION_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ - ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(ACCESS_DESCRIPTION, ACCESS_DESCRIPTION, + ACCESS_DESCRIPTION) +#define sk_ACCESS_DESCRIPTION_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_value(sk, idx) \ + ((ACCESS_DESCRIPTION *)OPENSSL_sk_value( \ + ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk), (idx))) +#define sk_ACCESS_DESCRIPTION_new(cmp) \ + ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new( \ + ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp))) +#define sk_ACCESS_DESCRIPTION_new_null() \ + ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new_null()) +#define sk_ACCESS_DESCRIPTION_new_reserve(cmp, n) \ + ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_new_reserve( \ + ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp), (n))) +#define sk_ACCESS_DESCRIPTION_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (n)) +#define sk_ACCESS_DESCRIPTION_free(sk) \ + OPENSSL_sk_free(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_delete(sk, i) \ + ((ACCESS_DESCRIPTION *)OPENSSL_sk_delete( \ + ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (i))) +#define sk_ACCESS_DESCRIPTION_delete_ptr(sk, ptr) \ + ((ACCESS_DESCRIPTION *)OPENSSL_sk_delete_ptr( \ + ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr))) +#define sk_ACCESS_DESCRIPTION_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_pop(sk) \ + ((ACCESS_DESCRIPTION *)OPENSSL_sk_pop( \ + ossl_check_ACCESS_DESCRIPTION_sk_type(sk))) +#define sk_ACCESS_DESCRIPTION_shift(sk) \ + ((ACCESS_DESCRIPTION *)OPENSSL_sk_shift( \ + ossl_check_ACCESS_DESCRIPTION_sk_type(sk))) +#define sk_ACCESS_DESCRIPTION_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_freefunc_type(freefunc)) +#define sk_ACCESS_DESCRIPTION_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr), (idx)) +#define sk_ACCESS_DESCRIPTION_set(sk, idx, ptr) \ + ((ACCESS_DESCRIPTION *)OPENSSL_sk_set( \ + ossl_check_ACCESS_DESCRIPTION_sk_type(sk), (idx), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr))) +#define sk_ACCESS_DESCRIPTION_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr)) +#define sk_ACCESS_DESCRIPTION_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_type(ptr), pnum) +#define sk_ACCESS_DESCRIPTION_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk)) +#define sk_ACCESS_DESCRIPTION_dup(sk) \ + ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_dup( \ + ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk))) +#define sk_ACCESS_DESCRIPTION_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ACCESS_DESCRIPTION) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_copyfunc_type(copyfunc), \ + ossl_check_ACCESS_DESCRIPTION_freefunc_type(freefunc))) +#define sk_ACCESS_DESCRIPTION_set_cmp_func(sk, cmp) \ + ((sk_ACCESS_DESCRIPTION_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ACCESS_DESCRIPTION_sk_type(sk), \ + ossl_check_ACCESS_DESCRIPTION_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_NAME, GENERAL_NAME, GENERAL_NAME) -#define sk_GENERAL_NAME_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_NAME_sk_type(sk)) -#define sk_GENERAL_NAME_value(sk, idx) \ - ((GENERAL_NAME *)OPENSSL_sk_value(ossl_check_const_GENERAL_NAME_sk_type(sk), (idx))) -#define sk_GENERAL_NAME_new(cmp) \ - ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new(ossl_check_GENERAL_NAME_compfunc_type(cmp))) -#define sk_GENERAL_NAME_new_null() ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new_null()) -#define sk_GENERAL_NAME_new_reserve(cmp, n) \ - ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new_reserve(ossl_check_GENERAL_NAME_compfunc_type(cmp), \ - (n))) -#define sk_GENERAL_NAME_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_GENERAL_NAME_sk_type(sk), (n)) -#define sk_GENERAL_NAME_free(sk) OPENSSL_sk_free(ossl_check_GENERAL_NAME_sk_type(sk)) -#define sk_GENERAL_NAME_zero(sk) OPENSSL_sk_zero(ossl_check_GENERAL_NAME_sk_type(sk)) -#define sk_GENERAL_NAME_delete(sk, i) \ - ((GENERAL_NAME *)OPENSSL_sk_delete(ossl_check_GENERAL_NAME_sk_type(sk), (i))) -#define sk_GENERAL_NAME_delete_ptr(sk, ptr) \ - ((GENERAL_NAME *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_NAME_sk_type(sk), \ - ossl_check_GENERAL_NAME_type(ptr))) -#define sk_GENERAL_NAME_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) -#define sk_GENERAL_NAME_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) -#define sk_GENERAL_NAME_pop(sk) \ - ((GENERAL_NAME *)OPENSSL_sk_pop(ossl_check_GENERAL_NAME_sk_type(sk))) -#define sk_GENERAL_NAME_shift(sk) \ - ((GENERAL_NAME *)OPENSSL_sk_shift(ossl_check_GENERAL_NAME_sk_type(sk))) -#define sk_GENERAL_NAME_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_GENERAL_NAME_sk_type(sk), \ - ossl_check_GENERAL_NAME_freefunc_type(freefunc)) -#define sk_GENERAL_NAME_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr), (idx)) -#define sk_GENERAL_NAME_set(sk, idx, ptr) \ - ((GENERAL_NAME *)OPENSSL_sk_set(ossl_check_GENERAL_NAME_sk_type(sk), (idx), \ - ossl_check_GENERAL_NAME_type(ptr))) -#define sk_GENERAL_NAME_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) -#define sk_GENERAL_NAME_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr)) -#define sk_GENERAL_NAME_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_type(ptr), \ - pnum) -#define sk_GENERAL_NAME_sort(sk) OPENSSL_sk_sort(ossl_check_GENERAL_NAME_sk_type(sk)) -#define sk_GENERAL_NAME_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_NAME_sk_type(sk)) -#define sk_GENERAL_NAME_dup(sk) \ - ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_dup(ossl_check_const_GENERAL_NAME_sk_type(sk))) -#define sk_GENERAL_NAME_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_GENERAL_NAME_sk_type(sk), \ - ossl_check_GENERAL_NAME_copyfunc_type(copyfunc), \ - ossl_check_GENERAL_NAME_freefunc_type(freefunc))) -#define sk_GENERAL_NAME_set_cmp_func(sk, cmp) \ - ((sk_GENERAL_NAME_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_GENERAL_NAME_sk_type(sk), ossl_check_GENERAL_NAME_compfunc_type(cmp))) +#define sk_GENERAL_NAME_num(sk) \ + OPENSSL_sk_num(ossl_check_const_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_value(sk, idx) \ + ((GENERAL_NAME *)OPENSSL_sk_value(ossl_check_const_GENERAL_NAME_sk_type(sk), \ + (idx))) +#define sk_GENERAL_NAME_new(cmp) \ + ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new( \ + ossl_check_GENERAL_NAME_compfunc_type(cmp))) +#define sk_GENERAL_NAME_new_null() \ + ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new_null()) +#define sk_GENERAL_NAME_new_reserve(cmp, n) \ + ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_new_reserve( \ + ossl_check_GENERAL_NAME_compfunc_type(cmp), (n))) +#define sk_GENERAL_NAME_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_GENERAL_NAME_sk_type(sk), (n)) +#define sk_GENERAL_NAME_free(sk) \ + OPENSSL_sk_free(ossl_check_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_zero(sk) \ + OPENSSL_sk_zero(ossl_check_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_delete(sk, i) \ + ((GENERAL_NAME *)OPENSSL_sk_delete(ossl_check_GENERAL_NAME_sk_type(sk), (i))) +#define sk_GENERAL_NAME_delete_ptr(sk, ptr) \ + ((GENERAL_NAME *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr))) +#define sk_GENERAL_NAME_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_pop(sk) \ + ((GENERAL_NAME *)OPENSSL_sk_pop(ossl_check_GENERAL_NAME_sk_type(sk))) +#define sk_GENERAL_NAME_shift(sk) \ + ((GENERAL_NAME *)OPENSSL_sk_shift(ossl_check_GENERAL_NAME_sk_type(sk))) +#define sk_GENERAL_NAME_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_freefunc_type(freefunc)) +#define sk_GENERAL_NAME_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr), (idx)) +#define sk_GENERAL_NAME_set(sk, idx, ptr) \ + ((GENERAL_NAME *)OPENSSL_sk_set(ossl_check_GENERAL_NAME_sk_type(sk), (idx), \ + ossl_check_GENERAL_NAME_type(ptr))) +#define sk_GENERAL_NAME_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr)) +#define sk_GENERAL_NAME_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_type(ptr), pnum) +#define sk_GENERAL_NAME_sort(sk) \ + OPENSSL_sk_sort(ossl_check_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_NAME_sk_type(sk)) +#define sk_GENERAL_NAME_dup(sk) \ + ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_dup( \ + ossl_check_const_GENERAL_NAME_sk_type(sk))) +#define sk_GENERAL_NAME_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(GENERAL_NAME) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_copyfunc_type(copyfunc), \ + ossl_check_GENERAL_NAME_freefunc_type(freefunc))) +#define sk_GENERAL_NAME_set_cmp_func(sk, cmp) \ + ((sk_GENERAL_NAME_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_GENERAL_NAME_sk_type(sk), \ + ossl_check_GENERAL_NAME_compfunc_type(cmp))) typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; @@ -365,72 +407,87 @@ typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE; typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_NAMES, GENERAL_NAMES, GENERAL_NAMES) -#define sk_GENERAL_NAMES_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_NAMES_sk_type(sk)) -#define sk_GENERAL_NAMES_value(sk, idx) \ - ((GENERAL_NAMES *)OPENSSL_sk_value(ossl_check_const_GENERAL_NAMES_sk_type(sk), (idx))) -#define sk_GENERAL_NAMES_new(cmp) \ - ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new(ossl_check_GENERAL_NAMES_compfunc_type(cmp))) -#define sk_GENERAL_NAMES_new_null() ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new_null()) -#define sk_GENERAL_NAMES_new_reserve(cmp, n) \ - ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new_reserve( \ - ossl_check_GENERAL_NAMES_compfunc_type(cmp), (n))) -#define sk_GENERAL_NAMES_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_GENERAL_NAMES_sk_type(sk), (n)) -#define sk_GENERAL_NAMES_free(sk) OPENSSL_sk_free(ossl_check_GENERAL_NAMES_sk_type(sk)) -#define sk_GENERAL_NAMES_zero(sk) OPENSSL_sk_zero(ossl_check_GENERAL_NAMES_sk_type(sk)) -#define sk_GENERAL_NAMES_delete(sk, i) \ - ((GENERAL_NAMES *)OPENSSL_sk_delete(ossl_check_GENERAL_NAMES_sk_type(sk), (i))) -#define sk_GENERAL_NAMES_delete_ptr(sk, ptr) \ - ((GENERAL_NAMES *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_NAMES_sk_type(sk), \ - ossl_check_GENERAL_NAMES_type(ptr))) -#define sk_GENERAL_NAMES_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) -#define sk_GENERAL_NAMES_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) -#define sk_GENERAL_NAMES_pop(sk) \ - ((GENERAL_NAMES *)OPENSSL_sk_pop(ossl_check_GENERAL_NAMES_sk_type(sk))) -#define sk_GENERAL_NAMES_shift(sk) \ - ((GENERAL_NAMES *)OPENSSL_sk_shift(ossl_check_GENERAL_NAMES_sk_type(sk))) -#define sk_GENERAL_NAMES_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_GENERAL_NAMES_sk_type(sk), \ - ossl_check_GENERAL_NAMES_freefunc_type(freefunc)) -#define sk_GENERAL_NAMES_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr), \ - (idx)) -#define sk_GENERAL_NAMES_set(sk, idx, ptr) \ - ((GENERAL_NAMES *)OPENSSL_sk_set(ossl_check_GENERAL_NAMES_sk_type(sk), (idx), \ - ossl_check_GENERAL_NAMES_type(ptr))) -#define sk_GENERAL_NAMES_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) -#define sk_GENERAL_NAMES_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr)) -#define sk_GENERAL_NAMES_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_type(ptr), \ - pnum) -#define sk_GENERAL_NAMES_sort(sk) OPENSSL_sk_sort(ossl_check_GENERAL_NAMES_sk_type(sk)) -#define sk_GENERAL_NAMES_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_NAMES_sk_type(sk)) -#define sk_GENERAL_NAMES_dup(sk) \ - ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_dup(ossl_check_const_GENERAL_NAMES_sk_type(sk))) -#define sk_GENERAL_NAMES_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_GENERAL_NAMES_sk_type(sk), \ - ossl_check_GENERAL_NAMES_copyfunc_type(copyfunc), \ - ossl_check_GENERAL_NAMES_freefunc_type(freefunc))) -#define sk_GENERAL_NAMES_set_cmp_func(sk, cmp) \ - ((sk_GENERAL_NAMES_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_GENERAL_NAMES_sk_type(sk), ossl_check_GENERAL_NAMES_compfunc_type(cmp))) +#define sk_GENERAL_NAMES_num(sk) \ + OPENSSL_sk_num(ossl_check_const_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_value(sk, idx) \ + ((GENERAL_NAMES *)OPENSSL_sk_value( \ + ossl_check_const_GENERAL_NAMES_sk_type(sk), (idx))) +#define sk_GENERAL_NAMES_new(cmp) \ + ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new( \ + ossl_check_GENERAL_NAMES_compfunc_type(cmp))) +#define sk_GENERAL_NAMES_new_null() \ + ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new_null()) +#define sk_GENERAL_NAMES_new_reserve(cmp, n) \ + ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_new_reserve( \ + ossl_check_GENERAL_NAMES_compfunc_type(cmp), (n))) +#define sk_GENERAL_NAMES_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_GENERAL_NAMES_sk_type(sk), (n)) +#define sk_GENERAL_NAMES_free(sk) \ + OPENSSL_sk_free(ossl_check_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_zero(sk) \ + OPENSSL_sk_zero(ossl_check_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_delete(sk, i) \ + ((GENERAL_NAMES *)OPENSSL_sk_delete(ossl_check_GENERAL_NAMES_sk_type(sk), \ + (i))) +#define sk_GENERAL_NAMES_delete_ptr(sk, ptr) \ + ((GENERAL_NAMES *)OPENSSL_sk_delete_ptr( \ + ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr))) +#define sk_GENERAL_NAMES_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_pop(sk) \ + ((GENERAL_NAMES *)OPENSSL_sk_pop(ossl_check_GENERAL_NAMES_sk_type(sk))) +#define sk_GENERAL_NAMES_shift(sk) \ + ((GENERAL_NAMES *)OPENSSL_sk_shift(ossl_check_GENERAL_NAMES_sk_type(sk))) +#define sk_GENERAL_NAMES_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_freefunc_type(freefunc)) +#define sk_GENERAL_NAMES_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr), (idx)) +#define sk_GENERAL_NAMES_set(sk, idx, ptr) \ + ((GENERAL_NAMES *)OPENSSL_sk_set(ossl_check_GENERAL_NAMES_sk_type(sk), \ + (idx), ossl_check_GENERAL_NAMES_type(ptr))) +#define sk_GENERAL_NAMES_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr)) +#define sk_GENERAL_NAMES_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_type(ptr), pnum) +#define sk_GENERAL_NAMES_sort(sk) \ + OPENSSL_sk_sort(ossl_check_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_NAMES_sk_type(sk)) +#define sk_GENERAL_NAMES_dup(sk) \ + ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_dup( \ + ossl_check_const_GENERAL_NAMES_sk_type(sk))) +#define sk_GENERAL_NAMES_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(GENERAL_NAMES) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_copyfunc_type(copyfunc), \ + ossl_check_GENERAL_NAMES_freefunc_type(freefunc))) +#define sk_GENERAL_NAMES_set_cmp_func(sk, cmp) \ + ((sk_GENERAL_NAMES_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_GENERAL_NAMES_sk_type(sk), \ + ossl_check_GENERAL_NAMES_compfunc_type(cmp))) typedef struct DIST_POINT_NAME_st { - int type; - union - { - GENERAL_NAMES *fullname; - STACK_OF(X509_NAME_ENTRY) * relativename; - } name; - /* If relativename then this contains the full distribution point name */ - X509_NAME *dpname; + int type; + union + { + GENERAL_NAMES *fullname; + STACK_OF(X509_NAME_ENTRY) * relativename; + } name; + /* If relativename then this contains the full distribution point name */ + X509_NAME *dpname; } DIST_POINT_NAME; /* All existing reasons */ #define CRLDP_ALL_REASONS 0x807f @@ -449,426 +506,528 @@ typedef struct DIST_POINT_NAME_st struct DIST_POINT_st { - DIST_POINT_NAME *distpoint; - ASN1_BIT_STRING *reasons; - GENERAL_NAMES *CRLissuer; - int dp_reasons; + DIST_POINT_NAME *distpoint; + ASN1_BIT_STRING *reasons; + GENERAL_NAMES *CRLissuer; + int dp_reasons; }; SKM_DEFINE_STACK_OF_INTERNAL(DIST_POINT, DIST_POINT, DIST_POINT) -#define sk_DIST_POINT_num(sk) OPENSSL_sk_num(ossl_check_const_DIST_POINT_sk_type(sk)) -#define sk_DIST_POINT_value(sk, idx) \ - ((DIST_POINT *)OPENSSL_sk_value(ossl_check_const_DIST_POINT_sk_type(sk), (idx))) -#define sk_DIST_POINT_new(cmp) \ - ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new(ossl_check_DIST_POINT_compfunc_type(cmp))) +#define sk_DIST_POINT_num(sk) \ + OPENSSL_sk_num(ossl_check_const_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_value(sk, idx) \ + ((DIST_POINT *)OPENSSL_sk_value(ossl_check_const_DIST_POINT_sk_type(sk), \ + (idx))) +#define sk_DIST_POINT_new(cmp) \ + ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new( \ + ossl_check_DIST_POINT_compfunc_type(cmp))) #define sk_DIST_POINT_new_null() ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new_null()) -#define sk_DIST_POINT_new_reserve(cmp, n) \ - ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new_reserve(ossl_check_DIST_POINT_compfunc_type(cmp), (n))) -#define sk_DIST_POINT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_DIST_POINT_sk_type(sk), (n)) -#define sk_DIST_POINT_free(sk) OPENSSL_sk_free(ossl_check_DIST_POINT_sk_type(sk)) -#define sk_DIST_POINT_zero(sk) OPENSSL_sk_zero(ossl_check_DIST_POINT_sk_type(sk)) -#define sk_DIST_POINT_delete(sk, i) \ - ((DIST_POINT *)OPENSSL_sk_delete(ossl_check_DIST_POINT_sk_type(sk), (i))) -#define sk_DIST_POINT_delete_ptr(sk, ptr) \ - ((DIST_POINT *)OPENSSL_sk_delete_ptr(ossl_check_DIST_POINT_sk_type(sk), \ - ossl_check_DIST_POINT_type(ptr))) -#define sk_DIST_POINT_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) -#define sk_DIST_POINT_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) -#define sk_DIST_POINT_pop(sk) ((DIST_POINT *)OPENSSL_sk_pop(ossl_check_DIST_POINT_sk_type(sk))) -#define sk_DIST_POINT_shift(sk) ((DIST_POINT *)OPENSSL_sk_shift(ossl_check_DIST_POINT_sk_type(sk))) -#define sk_DIST_POINT_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_DIST_POINT_sk_type(sk), \ - ossl_check_DIST_POINT_freefunc_type(freefunc)) -#define sk_DIST_POINT_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr), (idx)) -#define sk_DIST_POINT_set(sk, idx, ptr) \ - ((DIST_POINT *)OPENSSL_sk_set(ossl_check_DIST_POINT_sk_type(sk), (idx), \ - ossl_check_DIST_POINT_type(ptr))) -#define sk_DIST_POINT_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) -#define sk_DIST_POINT_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr)) -#define sk_DIST_POINT_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_DIST_POINT_sk_type(sk), ossl_check_DIST_POINT_type(ptr), pnum) -#define sk_DIST_POINT_sort(sk) OPENSSL_sk_sort(ossl_check_DIST_POINT_sk_type(sk)) -#define sk_DIST_POINT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_DIST_POINT_sk_type(sk)) -#define sk_DIST_POINT_dup(sk) \ - ((STACK_OF(DIST_POINT) *)OPENSSL_sk_dup(ossl_check_const_DIST_POINT_sk_type(sk))) -#define sk_DIST_POINT_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(DIST_POINT) *)OPENSSL_sk_deep_copy(ossl_check_const_DIST_POINT_sk_type(sk), \ - ossl_check_DIST_POINT_copyfunc_type(copyfunc), \ - ossl_check_DIST_POINT_freefunc_type(freefunc))) -#define sk_DIST_POINT_set_cmp_func(sk, cmp) \ - ((sk_DIST_POINT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_DIST_POINT_sk_type(sk), \ - ossl_check_DIST_POINT_compfunc_type(cmp))) +#define sk_DIST_POINT_new_reserve(cmp, n) \ + ((STACK_OF(DIST_POINT) *)OPENSSL_sk_new_reserve( \ + ossl_check_DIST_POINT_compfunc_type(cmp), (n))) +#define sk_DIST_POINT_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_DIST_POINT_sk_type(sk), (n)) +#define sk_DIST_POINT_free(sk) \ + OPENSSL_sk_free(ossl_check_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_zero(sk) \ + OPENSSL_sk_zero(ossl_check_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_delete(sk, i) \ + ((DIST_POINT *)OPENSSL_sk_delete(ossl_check_DIST_POINT_sk_type(sk), (i))) +#define sk_DIST_POINT_delete_ptr(sk, ptr) \ + ((DIST_POINT *)OPENSSL_sk_delete_ptr(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr))) +#define sk_DIST_POINT_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_pop(sk) \ + ((DIST_POINT *)OPENSSL_sk_pop(ossl_check_DIST_POINT_sk_type(sk))) +#define sk_DIST_POINT_shift(sk) \ + ((DIST_POINT *)OPENSSL_sk_shift(ossl_check_DIST_POINT_sk_type(sk))) +#define sk_DIST_POINT_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_freefunc_type(freefunc)) +#define sk_DIST_POINT_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr), (idx)) +#define sk_DIST_POINT_set(sk, idx, ptr) \ + ((DIST_POINT *)OPENSSL_sk_set(ossl_check_DIST_POINT_sk_type(sk), (idx), \ + ossl_check_DIST_POINT_type(ptr))) +#define sk_DIST_POINT_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr)) +#define sk_DIST_POINT_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_type(ptr), pnum) +#define sk_DIST_POINT_sort(sk) \ + OPENSSL_sk_sort(ossl_check_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_DIST_POINT_sk_type(sk)) +#define sk_DIST_POINT_dup(sk) \ + ((STACK_OF(DIST_POINT) *)OPENSSL_sk_dup( \ + ossl_check_const_DIST_POINT_sk_type(sk))) +#define sk_DIST_POINT_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(DIST_POINT) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_copyfunc_type(copyfunc), \ + ossl_check_DIST_POINT_freefunc_type(freefunc))) +#define sk_DIST_POINT_set_cmp_func(sk, cmp) \ + ((sk_DIST_POINT_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_DIST_POINT_sk_type(sk), \ + ossl_check_DIST_POINT_compfunc_type(cmp))) typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; struct AUTHORITY_KEYID_st { - ASN1_OCTET_STRING *keyid; - GENERAL_NAMES *issuer; - ASN1_INTEGER *serial; + ASN1_OCTET_STRING *keyid; + GENERAL_NAMES *issuer; + ASN1_INTEGER *serial; }; /* Strong extranet structures */ typedef struct SXNET_ID_st { - ASN1_INTEGER *zone; - ASN1_OCTET_STRING *user; + ASN1_INTEGER *zone; + ASN1_OCTET_STRING *user; } SXNETID; SKM_DEFINE_STACK_OF_INTERNAL(SXNETID, SXNETID, SXNETID) #define sk_SXNETID_num(sk) OPENSSL_sk_num(ossl_check_const_SXNETID_sk_type(sk)) -#define sk_SXNETID_value(sk, idx) \ - ((SXNETID *)OPENSSL_sk_value(ossl_check_const_SXNETID_sk_type(sk), (idx))) -#define sk_SXNETID_new(cmp) \ - ((STACK_OF(SXNETID) *)OPENSSL_sk_new(ossl_check_SXNETID_compfunc_type(cmp))) +#define sk_SXNETID_value(sk, idx) \ + ((SXNETID *)OPENSSL_sk_value(ossl_check_const_SXNETID_sk_type(sk), (idx))) +#define sk_SXNETID_new(cmp) \ + ((STACK_OF(SXNETID) *)OPENSSL_sk_new(ossl_check_SXNETID_compfunc_type(cmp))) #define sk_SXNETID_new_null() ((STACK_OF(SXNETID) *)OPENSSL_sk_new_null()) -#define sk_SXNETID_new_reserve(cmp, n) \ - ((STACK_OF(SXNETID) *)OPENSSL_sk_new_reserve(ossl_check_SXNETID_compfunc_type(cmp), (n))) -#define sk_SXNETID_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SXNETID_sk_type(sk), (n)) +#define sk_SXNETID_new_reserve(cmp, n) \ + ((STACK_OF(SXNETID) *)OPENSSL_sk_new_reserve( \ + ossl_check_SXNETID_compfunc_type(cmp), (n))) +#define sk_SXNETID_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_SXNETID_sk_type(sk), (n)) #define sk_SXNETID_free(sk) OPENSSL_sk_free(ossl_check_SXNETID_sk_type(sk)) #define sk_SXNETID_zero(sk) OPENSSL_sk_zero(ossl_check_SXNETID_sk_type(sk)) -#define sk_SXNETID_delete(sk, i) ((SXNETID *)OPENSSL_sk_delete(ossl_check_SXNETID_sk_type(sk), (i))) -#define sk_SXNETID_delete_ptr(sk, ptr) \ - ((SXNETID *)OPENSSL_sk_delete_ptr(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr))) -#define sk_SXNETID_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) -#define sk_SXNETID_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) -#define sk_SXNETID_pop(sk) ((SXNETID *)OPENSSL_sk_pop(ossl_check_SXNETID_sk_type(sk))) -#define sk_SXNETID_shift(sk) ((SXNETID *)OPENSSL_sk_shift(ossl_check_SXNETID_sk_type(sk))) -#define sk_SXNETID_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_freefunc_type(freefunc)) -#define sk_SXNETID_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr), (idx)) -#define sk_SXNETID_set(sk, idx, ptr) \ - ((SXNETID *)OPENSSL_sk_set(ossl_check_SXNETID_sk_type(sk), (idx), ossl_check_SXNETID_type(ptr))) -#define sk_SXNETID_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) -#define sk_SXNETID_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) -#define sk_SXNETID_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr), pnum) +#define sk_SXNETID_delete(sk, i) \ + ((SXNETID *)OPENSSL_sk_delete(ossl_check_SXNETID_sk_type(sk), (i))) +#define sk_SXNETID_delete_ptr(sk, ptr) \ + ((SXNETID *)OPENSSL_sk_delete_ptr(ossl_check_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_type(ptr))) +#define sk_SXNETID_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_pop(sk) \ + ((SXNETID *)OPENSSL_sk_pop(ossl_check_SXNETID_sk_type(sk))) +#define sk_SXNETID_shift(sk) \ + ((SXNETID *)OPENSSL_sk_shift(ossl_check_SXNETID_sk_type(sk))) +#define sk_SXNETID_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_freefunc_type(freefunc)) +#define sk_SXNETID_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_type(ptr), (idx)) +#define sk_SXNETID_set(sk, idx, ptr) \ + ((SXNETID *)OPENSSL_sk_set(ossl_check_SXNETID_sk_type(sk), (idx), \ + ossl_check_SXNETID_type(ptr))) +#define sk_SXNETID_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_type(ptr)) +#define sk_SXNETID_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_type(ptr), pnum) #define sk_SXNETID_sort(sk) OPENSSL_sk_sort(ossl_check_SXNETID_sk_type(sk)) -#define sk_SXNETID_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SXNETID_sk_type(sk)) -#define sk_SXNETID_dup(sk) \ - ((STACK_OF(SXNETID) *)OPENSSL_sk_dup(ossl_check_const_SXNETID_sk_type(sk))) -#define sk_SXNETID_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(SXNETID) *)OPENSSL_sk_deep_copy(ossl_check_const_SXNETID_sk_type(sk), \ - ossl_check_SXNETID_copyfunc_type(copyfunc), \ - ossl_check_SXNETID_freefunc_type(freefunc))) -#define sk_SXNETID_set_cmp_func(sk, cmp) \ - ((sk_SXNETID_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SXNETID_sk_type(sk), \ - ossl_check_SXNETID_compfunc_type(cmp))) +#define sk_SXNETID_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_SXNETID_sk_type(sk)) +#define sk_SXNETID_dup(sk) \ + ((STACK_OF(SXNETID) *)OPENSSL_sk_dup(ossl_check_const_SXNETID_sk_type(sk))) +#define sk_SXNETID_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(SXNETID) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_SXNETID_sk_type(sk), \ + ossl_check_SXNETID_copyfunc_type(copyfunc), \ + ossl_check_SXNETID_freefunc_type(freefunc))) +#define sk_SXNETID_set_cmp_func(sk, cmp) \ + ((sk_SXNETID_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_SXNETID_sk_type(sk), ossl_check_SXNETID_compfunc_type(cmp))) typedef struct SXNET_st { - ASN1_INTEGER *version; - STACK_OF(SXNETID) * ids; + ASN1_INTEGER *version; + STACK_OF(SXNETID) * ids; } SXNET; typedef struct ISSUER_SIGN_TOOL_st { - ASN1_UTF8STRING *signTool; - ASN1_UTF8STRING *cATool; - ASN1_UTF8STRING *signToolCert; - ASN1_UTF8STRING *cAToolCert; + ASN1_UTF8STRING *signTool; + ASN1_UTF8STRING *cATool; + ASN1_UTF8STRING *signToolCert; + ASN1_UTF8STRING *cAToolCert; } ISSUER_SIGN_TOOL; typedef struct NOTICEREF_st { - ASN1_STRING *organization; - STACK_OF(ASN1_INTEGER) * noticenos; + ASN1_STRING *organization; + STACK_OF(ASN1_INTEGER) * noticenos; } NOTICEREF; typedef struct USERNOTICE_st { - NOTICEREF *noticeref; - ASN1_STRING *exptext; + NOTICEREF *noticeref; + ASN1_STRING *exptext; } USERNOTICE; typedef struct POLICYQUALINFO_st { - ASN1_OBJECT *pqualid; - union - { - ASN1_IA5STRING *cpsuri; - USERNOTICE *usernotice; - ASN1_TYPE *other; - } d; + ASN1_OBJECT *pqualid; + union + { + ASN1_IA5STRING *cpsuri; + USERNOTICE *usernotice; + ASN1_TYPE *other; + } d; } POLICYQUALINFO; SKM_DEFINE_STACK_OF_INTERNAL(POLICYQUALINFO, POLICYQUALINFO, POLICYQUALINFO) -#define sk_POLICYQUALINFO_num(sk) OPENSSL_sk_num(ossl_check_const_POLICYQUALINFO_sk_type(sk)) -#define sk_POLICYQUALINFO_value(sk, idx) \ - ((POLICYQUALINFO *)OPENSSL_sk_value(ossl_check_const_POLICYQUALINFO_sk_type(sk), (idx))) -#define sk_POLICYQUALINFO_new(cmp) \ - ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new(ossl_check_POLICYQUALINFO_compfunc_type(cmp))) -#define sk_POLICYQUALINFO_new_null() ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new_null()) -#define sk_POLICYQUALINFO_new_reserve(cmp, n) \ - ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new_reserve( \ - ossl_check_POLICYQUALINFO_compfunc_type(cmp), (n))) -#define sk_POLICYQUALINFO_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_POLICYQUALINFO_sk_type(sk), (n)) -#define sk_POLICYQUALINFO_free(sk) OPENSSL_sk_free(ossl_check_POLICYQUALINFO_sk_type(sk)) -#define sk_POLICYQUALINFO_zero(sk) OPENSSL_sk_zero(ossl_check_POLICYQUALINFO_sk_type(sk)) -#define sk_POLICYQUALINFO_delete(sk, i) \ - ((POLICYQUALINFO *)OPENSSL_sk_delete(ossl_check_POLICYQUALINFO_sk_type(sk), (i))) -#define sk_POLICYQUALINFO_delete_ptr(sk, ptr) \ - ((POLICYQUALINFO *)OPENSSL_sk_delete_ptr(ossl_check_POLICYQUALINFO_sk_type(sk), \ - ossl_check_POLICYQUALINFO_type(ptr))) -#define sk_POLICYQUALINFO_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) -#define sk_POLICYQUALINFO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) -#define sk_POLICYQUALINFO_pop(sk) \ - ((POLICYQUALINFO *)OPENSSL_sk_pop(ossl_check_POLICYQUALINFO_sk_type(sk))) -#define sk_POLICYQUALINFO_shift(sk) \ - ((POLICYQUALINFO *)OPENSSL_sk_shift(ossl_check_POLICYQUALINFO_sk_type(sk))) -#define sk_POLICYQUALINFO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_POLICYQUALINFO_sk_type(sk), \ - ossl_check_POLICYQUALINFO_freefunc_type(freefunc)) -#define sk_POLICYQUALINFO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr), \ - (idx)) -#define sk_POLICYQUALINFO_set(sk, idx, ptr) \ - ((POLICYQUALINFO *)OPENSSL_sk_set(ossl_check_POLICYQUALINFO_sk_type(sk), (idx), \ - ossl_check_POLICYQUALINFO_type(ptr))) -#define sk_POLICYQUALINFO_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) -#define sk_POLICYQUALINFO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_type(ptr)) -#define sk_POLICYQUALINFO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_POLICYQUALINFO_sk_type(sk), \ - ossl_check_POLICYQUALINFO_type(ptr), pnum) -#define sk_POLICYQUALINFO_sort(sk) OPENSSL_sk_sort(ossl_check_POLICYQUALINFO_sk_type(sk)) -#define sk_POLICYQUALINFO_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_POLICYQUALINFO_sk_type(sk)) -#define sk_POLICYQUALINFO_dup(sk) \ - ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_dup(ossl_check_const_POLICYQUALINFO_sk_type(sk))) -#define sk_POLICYQUALINFO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_POLICYQUALINFO_sk_type(sk), \ - ossl_check_POLICYQUALINFO_copyfunc_type(copyfunc), \ - ossl_check_POLICYQUALINFO_freefunc_type(freefunc))) -#define sk_POLICYQUALINFO_set_cmp_func(sk, cmp) \ - ((sk_POLICYQUALINFO_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_POLICYQUALINFO_sk_type(sk), ossl_check_POLICYQUALINFO_compfunc_type(cmp))) +#define sk_POLICYQUALINFO_num(sk) \ + OPENSSL_sk_num(ossl_check_const_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_value(sk, idx) \ + ((POLICYQUALINFO *)OPENSSL_sk_value( \ + ossl_check_const_POLICYQUALINFO_sk_type(sk), (idx))) +#define sk_POLICYQUALINFO_new(cmp) \ + ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new( \ + ossl_check_POLICYQUALINFO_compfunc_type(cmp))) +#define sk_POLICYQUALINFO_new_null() \ + ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new_null()) +#define sk_POLICYQUALINFO_new_reserve(cmp, n) \ + ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_new_reserve( \ + ossl_check_POLICYQUALINFO_compfunc_type(cmp), (n))) +#define sk_POLICYQUALINFO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_POLICYQUALINFO_sk_type(sk), (n)) +#define sk_POLICYQUALINFO_free(sk) \ + OPENSSL_sk_free(ossl_check_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_zero(sk) \ + OPENSSL_sk_zero(ossl_check_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_delete(sk, i) \ + ((POLICYQUALINFO *)OPENSSL_sk_delete(ossl_check_POLICYQUALINFO_sk_type(sk), \ + (i))) +#define sk_POLICYQUALINFO_delete_ptr(sk, ptr) \ + ((POLICYQUALINFO *)OPENSSL_sk_delete_ptr( \ + ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr))) +#define sk_POLICYQUALINFO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_pop(sk) \ + ((POLICYQUALINFO *)OPENSSL_sk_pop(ossl_check_POLICYQUALINFO_sk_type(sk))) +#define sk_POLICYQUALINFO_shift(sk) \ + ((POLICYQUALINFO *)OPENSSL_sk_shift(ossl_check_POLICYQUALINFO_sk_type(sk))) +#define sk_POLICYQUALINFO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_freefunc_type(freefunc)) +#define sk_POLICYQUALINFO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr), (idx)) +#define sk_POLICYQUALINFO_set(sk, idx, ptr) \ + ((POLICYQUALINFO *)OPENSSL_sk_set(ossl_check_POLICYQUALINFO_sk_type(sk), \ + (idx), \ + ossl_check_POLICYQUALINFO_type(ptr))) +#define sk_POLICYQUALINFO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr)) +#define sk_POLICYQUALINFO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_type(ptr), pnum) +#define sk_POLICYQUALINFO_sort(sk) \ + OPENSSL_sk_sort(ossl_check_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_POLICYQUALINFO_sk_type(sk)) +#define sk_POLICYQUALINFO_dup(sk) \ + ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_dup( \ + ossl_check_const_POLICYQUALINFO_sk_type(sk))) +#define sk_POLICYQUALINFO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(POLICYQUALINFO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_copyfunc_type(copyfunc), \ + ossl_check_POLICYQUALINFO_freefunc_type(freefunc))) +#define sk_POLICYQUALINFO_set_cmp_func(sk, cmp) \ + ((sk_POLICYQUALINFO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_POLICYQUALINFO_sk_type(sk), \ + ossl_check_POLICYQUALINFO_compfunc_type(cmp))) typedef struct POLICYINFO_st { - ASN1_OBJECT *policyid; - STACK_OF(POLICYQUALINFO) * qualifiers; + ASN1_OBJECT *policyid; + STACK_OF(POLICYQUALINFO) * qualifiers; } POLICYINFO; SKM_DEFINE_STACK_OF_INTERNAL(POLICYINFO, POLICYINFO, POLICYINFO) -#define sk_POLICYINFO_num(sk) OPENSSL_sk_num(ossl_check_const_POLICYINFO_sk_type(sk)) -#define sk_POLICYINFO_value(sk, idx) \ - ((POLICYINFO *)OPENSSL_sk_value(ossl_check_const_POLICYINFO_sk_type(sk), (idx))) -#define sk_POLICYINFO_new(cmp) \ - ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new(ossl_check_POLICYINFO_compfunc_type(cmp))) +#define sk_POLICYINFO_num(sk) \ + OPENSSL_sk_num(ossl_check_const_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_value(sk, idx) \ + ((POLICYINFO *)OPENSSL_sk_value(ossl_check_const_POLICYINFO_sk_type(sk), \ + (idx))) +#define sk_POLICYINFO_new(cmp) \ + ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new( \ + ossl_check_POLICYINFO_compfunc_type(cmp))) #define sk_POLICYINFO_new_null() ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new_null()) -#define sk_POLICYINFO_new_reserve(cmp, n) \ - ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new_reserve(ossl_check_POLICYINFO_compfunc_type(cmp), (n))) -#define sk_POLICYINFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_POLICYINFO_sk_type(sk), (n)) -#define sk_POLICYINFO_free(sk) OPENSSL_sk_free(ossl_check_POLICYINFO_sk_type(sk)) -#define sk_POLICYINFO_zero(sk) OPENSSL_sk_zero(ossl_check_POLICYINFO_sk_type(sk)) -#define sk_POLICYINFO_delete(sk, i) \ - ((POLICYINFO *)OPENSSL_sk_delete(ossl_check_POLICYINFO_sk_type(sk), (i))) -#define sk_POLICYINFO_delete_ptr(sk, ptr) \ - ((POLICYINFO *)OPENSSL_sk_delete_ptr(ossl_check_POLICYINFO_sk_type(sk), \ - ossl_check_POLICYINFO_type(ptr))) -#define sk_POLICYINFO_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) -#define sk_POLICYINFO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) -#define sk_POLICYINFO_pop(sk) ((POLICYINFO *)OPENSSL_sk_pop(ossl_check_POLICYINFO_sk_type(sk))) -#define sk_POLICYINFO_shift(sk) ((POLICYINFO *)OPENSSL_sk_shift(ossl_check_POLICYINFO_sk_type(sk))) -#define sk_POLICYINFO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_POLICYINFO_sk_type(sk), \ - ossl_check_POLICYINFO_freefunc_type(freefunc)) -#define sk_POLICYINFO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr), (idx)) -#define sk_POLICYINFO_set(sk, idx, ptr) \ - ((POLICYINFO *)OPENSSL_sk_set(ossl_check_POLICYINFO_sk_type(sk), (idx), \ - ossl_check_POLICYINFO_type(ptr))) -#define sk_POLICYINFO_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) -#define sk_POLICYINFO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr)) -#define sk_POLICYINFO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_POLICYINFO_sk_type(sk), ossl_check_POLICYINFO_type(ptr), pnum) -#define sk_POLICYINFO_sort(sk) OPENSSL_sk_sort(ossl_check_POLICYINFO_sk_type(sk)) -#define sk_POLICYINFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_POLICYINFO_sk_type(sk)) -#define sk_POLICYINFO_dup(sk) \ - ((STACK_OF(POLICYINFO) *)OPENSSL_sk_dup(ossl_check_const_POLICYINFO_sk_type(sk))) -#define sk_POLICYINFO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(POLICYINFO) *)OPENSSL_sk_deep_copy(ossl_check_const_POLICYINFO_sk_type(sk), \ - ossl_check_POLICYINFO_copyfunc_type(copyfunc), \ - ossl_check_POLICYINFO_freefunc_type(freefunc))) -#define sk_POLICYINFO_set_cmp_func(sk, cmp) \ - ((sk_POLICYINFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_POLICYINFO_sk_type(sk), \ - ossl_check_POLICYINFO_compfunc_type(cmp))) +#define sk_POLICYINFO_new_reserve(cmp, n) \ + ((STACK_OF(POLICYINFO) *)OPENSSL_sk_new_reserve( \ + ossl_check_POLICYINFO_compfunc_type(cmp), (n))) +#define sk_POLICYINFO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_POLICYINFO_sk_type(sk), (n)) +#define sk_POLICYINFO_free(sk) \ + OPENSSL_sk_free(ossl_check_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_zero(sk) \ + OPENSSL_sk_zero(ossl_check_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_delete(sk, i) \ + ((POLICYINFO *)OPENSSL_sk_delete(ossl_check_POLICYINFO_sk_type(sk), (i))) +#define sk_POLICYINFO_delete_ptr(sk, ptr) \ + ((POLICYINFO *)OPENSSL_sk_delete_ptr(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr))) +#define sk_POLICYINFO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_pop(sk) \ + ((POLICYINFO *)OPENSSL_sk_pop(ossl_check_POLICYINFO_sk_type(sk))) +#define sk_POLICYINFO_shift(sk) \ + ((POLICYINFO *)OPENSSL_sk_shift(ossl_check_POLICYINFO_sk_type(sk))) +#define sk_POLICYINFO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_freefunc_type(freefunc)) +#define sk_POLICYINFO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr), (idx)) +#define sk_POLICYINFO_set(sk, idx, ptr) \ + ((POLICYINFO *)OPENSSL_sk_set(ossl_check_POLICYINFO_sk_type(sk), (idx), \ + ossl_check_POLICYINFO_type(ptr))) +#define sk_POLICYINFO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr)) +#define sk_POLICYINFO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_type(ptr), pnum) +#define sk_POLICYINFO_sort(sk) \ + OPENSSL_sk_sort(ossl_check_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_POLICYINFO_sk_type(sk)) +#define sk_POLICYINFO_dup(sk) \ + ((STACK_OF(POLICYINFO) *)OPENSSL_sk_dup( \ + ossl_check_const_POLICYINFO_sk_type(sk))) +#define sk_POLICYINFO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(POLICYINFO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_copyfunc_type(copyfunc), \ + ossl_check_POLICYINFO_freefunc_type(freefunc))) +#define sk_POLICYINFO_set_cmp_func(sk, cmp) \ + ((sk_POLICYINFO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_POLICYINFO_sk_type(sk), \ + ossl_check_POLICYINFO_compfunc_type(cmp))) typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; typedef struct POLICY_MAPPING_st { - ASN1_OBJECT *issuerDomainPolicy; - ASN1_OBJECT *subjectDomainPolicy; + ASN1_OBJECT *issuerDomainPolicy; + ASN1_OBJECT *subjectDomainPolicy; } POLICY_MAPPING; SKM_DEFINE_STACK_OF_INTERNAL(POLICY_MAPPING, POLICY_MAPPING, POLICY_MAPPING) -#define sk_POLICY_MAPPING_num(sk) OPENSSL_sk_num(ossl_check_const_POLICY_MAPPING_sk_type(sk)) -#define sk_POLICY_MAPPING_value(sk, idx) \ - ((POLICY_MAPPING *)OPENSSL_sk_value(ossl_check_const_POLICY_MAPPING_sk_type(sk), (idx))) -#define sk_POLICY_MAPPING_new(cmp) \ - ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new(ossl_check_POLICY_MAPPING_compfunc_type(cmp))) -#define sk_POLICY_MAPPING_new_null() ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new_null()) -#define sk_POLICY_MAPPING_new_reserve(cmp, n) \ - ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new_reserve( \ - ossl_check_POLICY_MAPPING_compfunc_type(cmp), (n))) -#define sk_POLICY_MAPPING_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_POLICY_MAPPING_sk_type(sk), (n)) -#define sk_POLICY_MAPPING_free(sk) OPENSSL_sk_free(ossl_check_POLICY_MAPPING_sk_type(sk)) -#define sk_POLICY_MAPPING_zero(sk) OPENSSL_sk_zero(ossl_check_POLICY_MAPPING_sk_type(sk)) -#define sk_POLICY_MAPPING_delete(sk, i) \ - ((POLICY_MAPPING *)OPENSSL_sk_delete(ossl_check_POLICY_MAPPING_sk_type(sk), (i))) -#define sk_POLICY_MAPPING_delete_ptr(sk, ptr) \ - ((POLICY_MAPPING *)OPENSSL_sk_delete_ptr(ossl_check_POLICY_MAPPING_sk_type(sk), \ - ossl_check_POLICY_MAPPING_type(ptr))) -#define sk_POLICY_MAPPING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) -#define sk_POLICY_MAPPING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) -#define sk_POLICY_MAPPING_pop(sk) \ - ((POLICY_MAPPING *)OPENSSL_sk_pop(ossl_check_POLICY_MAPPING_sk_type(sk))) -#define sk_POLICY_MAPPING_shift(sk) \ - ((POLICY_MAPPING *)OPENSSL_sk_shift(ossl_check_POLICY_MAPPING_sk_type(sk))) -#define sk_POLICY_MAPPING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_POLICY_MAPPING_sk_type(sk), \ - ossl_check_POLICY_MAPPING_freefunc_type(freefunc)) -#define sk_POLICY_MAPPING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr), \ - (idx)) -#define sk_POLICY_MAPPING_set(sk, idx, ptr) \ - ((POLICY_MAPPING *)OPENSSL_sk_set(ossl_check_POLICY_MAPPING_sk_type(sk), (idx), \ - ossl_check_POLICY_MAPPING_type(ptr))) -#define sk_POLICY_MAPPING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) -#define sk_POLICY_MAPPING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_type(ptr)) -#define sk_POLICY_MAPPING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_POLICY_MAPPING_sk_type(sk), \ - ossl_check_POLICY_MAPPING_type(ptr), pnum) -#define sk_POLICY_MAPPING_sort(sk) OPENSSL_sk_sort(ossl_check_POLICY_MAPPING_sk_type(sk)) -#define sk_POLICY_MAPPING_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_POLICY_MAPPING_sk_type(sk)) -#define sk_POLICY_MAPPING_dup(sk) \ - ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_dup(ossl_check_const_POLICY_MAPPING_sk_type(sk))) -#define sk_POLICY_MAPPING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_POLICY_MAPPING_sk_type(sk), \ - ossl_check_POLICY_MAPPING_copyfunc_type(copyfunc), \ - ossl_check_POLICY_MAPPING_freefunc_type(freefunc))) -#define sk_POLICY_MAPPING_set_cmp_func(sk, cmp) \ - ((sk_POLICY_MAPPING_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_POLICY_MAPPING_sk_type(sk), ossl_check_POLICY_MAPPING_compfunc_type(cmp))) +#define sk_POLICY_MAPPING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_value(sk, idx) \ + ((POLICY_MAPPING *)OPENSSL_sk_value( \ + ossl_check_const_POLICY_MAPPING_sk_type(sk), (idx))) +#define sk_POLICY_MAPPING_new(cmp) \ + ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new( \ + ossl_check_POLICY_MAPPING_compfunc_type(cmp))) +#define sk_POLICY_MAPPING_new_null() \ + ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new_null()) +#define sk_POLICY_MAPPING_new_reserve(cmp, n) \ + ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_new_reserve( \ + ossl_check_POLICY_MAPPING_compfunc_type(cmp), (n))) +#define sk_POLICY_MAPPING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_POLICY_MAPPING_sk_type(sk), (n)) +#define sk_POLICY_MAPPING_free(sk) \ + OPENSSL_sk_free(ossl_check_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_zero(sk) \ + OPENSSL_sk_zero(ossl_check_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_delete(sk, i) \ + ((POLICY_MAPPING *)OPENSSL_sk_delete(ossl_check_POLICY_MAPPING_sk_type(sk), \ + (i))) +#define sk_POLICY_MAPPING_delete_ptr(sk, ptr) \ + ((POLICY_MAPPING *)OPENSSL_sk_delete_ptr( \ + ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr))) +#define sk_POLICY_MAPPING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_pop(sk) \ + ((POLICY_MAPPING *)OPENSSL_sk_pop(ossl_check_POLICY_MAPPING_sk_type(sk))) +#define sk_POLICY_MAPPING_shift(sk) \ + ((POLICY_MAPPING *)OPENSSL_sk_shift(ossl_check_POLICY_MAPPING_sk_type(sk))) +#define sk_POLICY_MAPPING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_freefunc_type(freefunc)) +#define sk_POLICY_MAPPING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr), (idx)) +#define sk_POLICY_MAPPING_set(sk, idx, ptr) \ + ((POLICY_MAPPING *)OPENSSL_sk_set(ossl_check_POLICY_MAPPING_sk_type(sk), \ + (idx), \ + ossl_check_POLICY_MAPPING_type(ptr))) +#define sk_POLICY_MAPPING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr)) +#define sk_POLICY_MAPPING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_type(ptr), pnum) +#define sk_POLICY_MAPPING_sort(sk) \ + OPENSSL_sk_sort(ossl_check_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_POLICY_MAPPING_sk_type(sk)) +#define sk_POLICY_MAPPING_dup(sk) \ + ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_dup( \ + ossl_check_const_POLICY_MAPPING_sk_type(sk))) +#define sk_POLICY_MAPPING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(POLICY_MAPPING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_copyfunc_type(copyfunc), \ + ossl_check_POLICY_MAPPING_freefunc_type(freefunc))) +#define sk_POLICY_MAPPING_set_cmp_func(sk, cmp) \ + ((sk_POLICY_MAPPING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_POLICY_MAPPING_sk_type(sk), \ + ossl_check_POLICY_MAPPING_compfunc_type(cmp))) typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; typedef struct GENERAL_SUBTREE_st { - GENERAL_NAME *base; - ASN1_INTEGER *minimum; - ASN1_INTEGER *maximum; + GENERAL_NAME *base; + ASN1_INTEGER *minimum; + ASN1_INTEGER *maximum; } GENERAL_SUBTREE; SKM_DEFINE_STACK_OF_INTERNAL(GENERAL_SUBTREE, GENERAL_SUBTREE, GENERAL_SUBTREE) -#define sk_GENERAL_SUBTREE_num(sk) OPENSSL_sk_num(ossl_check_const_GENERAL_SUBTREE_sk_type(sk)) -#define sk_GENERAL_SUBTREE_value(sk, idx) \ - ((GENERAL_SUBTREE *)OPENSSL_sk_value(ossl_check_const_GENERAL_SUBTREE_sk_type(sk), (idx))) -#define sk_GENERAL_SUBTREE_new(cmp) \ - ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new(ossl_check_GENERAL_SUBTREE_compfunc_type(cmp))) -#define sk_GENERAL_SUBTREE_new_null() ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new_null()) -#define sk_GENERAL_SUBTREE_new_reserve(cmp, n) \ - ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new_reserve( \ - ossl_check_GENERAL_SUBTREE_compfunc_type(cmp), (n))) -#define sk_GENERAL_SUBTREE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_GENERAL_SUBTREE_sk_type(sk), (n)) -#define sk_GENERAL_SUBTREE_free(sk) OPENSSL_sk_free(ossl_check_GENERAL_SUBTREE_sk_type(sk)) -#define sk_GENERAL_SUBTREE_zero(sk) OPENSSL_sk_zero(ossl_check_GENERAL_SUBTREE_sk_type(sk)) -#define sk_GENERAL_SUBTREE_delete(sk, i) \ - ((GENERAL_SUBTREE *)OPENSSL_sk_delete(ossl_check_GENERAL_SUBTREE_sk_type(sk), (i))) -#define sk_GENERAL_SUBTREE_delete_ptr(sk, ptr) \ - ((GENERAL_SUBTREE *)OPENSSL_sk_delete_ptr(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ - ossl_check_GENERAL_SUBTREE_type(ptr))) -#define sk_GENERAL_SUBTREE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) -#define sk_GENERAL_SUBTREE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) -#define sk_GENERAL_SUBTREE_pop(sk) \ - ((GENERAL_SUBTREE *)OPENSSL_sk_pop(ossl_check_GENERAL_SUBTREE_sk_type(sk))) -#define sk_GENERAL_SUBTREE_shift(sk) \ - ((GENERAL_SUBTREE *)OPENSSL_sk_shift(ossl_check_GENERAL_SUBTREE_sk_type(sk))) -#define sk_GENERAL_SUBTREE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ - ossl_check_GENERAL_SUBTREE_freefunc_type(freefunc)) -#define sk_GENERAL_SUBTREE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ - ossl_check_GENERAL_SUBTREE_type(ptr), (idx)) -#define sk_GENERAL_SUBTREE_set(sk, idx, ptr) \ - ((GENERAL_SUBTREE *)OPENSSL_sk_set(ossl_check_GENERAL_SUBTREE_sk_type(sk), (idx), \ - ossl_check_GENERAL_SUBTREE_type(ptr))) -#define sk_GENERAL_SUBTREE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) -#define sk_GENERAL_SUBTREE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_type(ptr)) -#define sk_GENERAL_SUBTREE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ - ossl_check_GENERAL_SUBTREE_type(ptr), pnum) -#define sk_GENERAL_SUBTREE_sort(sk) OPENSSL_sk_sort(ossl_check_GENERAL_SUBTREE_sk_type(sk)) -#define sk_GENERAL_SUBTREE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_SUBTREE_sk_type(sk)) -#define sk_GENERAL_SUBTREE_dup(sk) \ - ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_dup(ossl_check_const_GENERAL_SUBTREE_sk_type(sk))) -#define sk_GENERAL_SUBTREE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_GENERAL_SUBTREE_sk_type(sk), \ - ossl_check_GENERAL_SUBTREE_copyfunc_type(copyfunc), \ - ossl_check_GENERAL_SUBTREE_freefunc_type(freefunc))) -#define sk_GENERAL_SUBTREE_set_cmp_func(sk, cmp) \ - ((sk_GENERAL_SUBTREE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_GENERAL_SUBTREE_sk_type(sk), ossl_check_GENERAL_SUBTREE_compfunc_type(cmp))) +#define sk_GENERAL_SUBTREE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_value(sk, idx) \ + ((GENERAL_SUBTREE *)OPENSSL_sk_value( \ + ossl_check_const_GENERAL_SUBTREE_sk_type(sk), (idx))) +#define sk_GENERAL_SUBTREE_new(cmp) \ + ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new( \ + ossl_check_GENERAL_SUBTREE_compfunc_type(cmp))) +#define sk_GENERAL_SUBTREE_new_null() \ + ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new_null()) +#define sk_GENERAL_SUBTREE_new_reserve(cmp, n) \ + ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_new_reserve( \ + ossl_check_GENERAL_SUBTREE_compfunc_type(cmp), (n))) +#define sk_GENERAL_SUBTREE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_GENERAL_SUBTREE_sk_type(sk), (n)) +#define sk_GENERAL_SUBTREE_free(sk) \ + OPENSSL_sk_free(ossl_check_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_delete(sk, i) \ + ((GENERAL_SUBTREE *)OPENSSL_sk_delete( \ + ossl_check_GENERAL_SUBTREE_sk_type(sk), (i))) +#define sk_GENERAL_SUBTREE_delete_ptr(sk, ptr) \ + ((GENERAL_SUBTREE *)OPENSSL_sk_delete_ptr( \ + ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr))) +#define sk_GENERAL_SUBTREE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_pop(sk) \ + ((GENERAL_SUBTREE *)OPENSSL_sk_pop(ossl_check_GENERAL_SUBTREE_sk_type(sk))) +#define sk_GENERAL_SUBTREE_shift(sk) \ + ((GENERAL_SUBTREE *)OPENSSL_sk_shift(ossl_check_GENERAL_SUBTREE_sk_type(sk))) +#define sk_GENERAL_SUBTREE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_freefunc_type(freefunc)) +#define sk_GENERAL_SUBTREE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr), (idx)) +#define sk_GENERAL_SUBTREE_set(sk, idx, ptr) \ + ((GENERAL_SUBTREE *)OPENSSL_sk_set(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + (idx), \ + ossl_check_GENERAL_SUBTREE_type(ptr))) +#define sk_GENERAL_SUBTREE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr)) +#define sk_GENERAL_SUBTREE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_type(ptr), pnum) +#define sk_GENERAL_SUBTREE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_GENERAL_SUBTREE_sk_type(sk)) +#define sk_GENERAL_SUBTREE_dup(sk) \ + ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_dup( \ + ossl_check_const_GENERAL_SUBTREE_sk_type(sk))) +#define sk_GENERAL_SUBTREE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(GENERAL_SUBTREE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_copyfunc_type(copyfunc), \ + ossl_check_GENERAL_SUBTREE_freefunc_type(freefunc))) +#define sk_GENERAL_SUBTREE_set_cmp_func(sk, cmp) \ + ((sk_GENERAL_SUBTREE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_GENERAL_SUBTREE_sk_type(sk), \ + ossl_check_GENERAL_SUBTREE_compfunc_type(cmp))) struct NAME_CONSTRAINTS_st { - STACK_OF(GENERAL_SUBTREE) * permittedSubtrees; - STACK_OF(GENERAL_SUBTREE) * excludedSubtrees; + STACK_OF(GENERAL_SUBTREE) * permittedSubtrees; + STACK_OF(GENERAL_SUBTREE) * excludedSubtrees; }; typedef struct POLICY_CONSTRAINTS_st { - ASN1_INTEGER *requireExplicitPolicy; - ASN1_INTEGER *inhibitPolicyMapping; + ASN1_INTEGER *requireExplicitPolicy; + ASN1_INTEGER *inhibitPolicyMapping; } POLICY_CONSTRAINTS; /* Proxy certificate structures, see RFC 3820 */ typedef struct PROXY_POLICY_st { - ASN1_OBJECT *policyLanguage; - ASN1_OCTET_STRING *policy; + ASN1_OBJECT *policyLanguage; + ASN1_OCTET_STRING *policy; } PROXY_POLICY; typedef struct PROXY_CERT_INFO_EXTENSION_st { - ASN1_INTEGER *pcPathLengthConstraint; - PROXY_POLICY *proxyPolicy; + ASN1_INTEGER *pcPathLengthConstraint; + PROXY_POLICY *proxyPolicy; } PROXY_CERT_INFO_EXTENSION; DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) @@ -876,12 +1035,12 @@ DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) struct ISSUING_DIST_POINT_st { - DIST_POINT_NAME *distpoint; - int onlyuser; - int onlyCA; - ASN1_BIT_STRING *onlysomereasons; - int indirectCRL; - int onlyattr; + DIST_POINT_NAME *distpoint; + int onlyuser; + int onlyCA; + ASN1_BIT_STRING *onlysomereasons; + int indirectCRL; + int onlyattr; }; /* Values in idp_flags field */ @@ -900,36 +1059,39 @@ struct ISSUING_DIST_POINT_st /* onlysomereasons present */ #define IDP_REASONS 0x40 -#define X509V3_conf_err(val) \ - ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, \ - ",value:", (val)->value) +#define X509V3_conf_err(val) \ + ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, \ + ",value:", (val)->value) -#define X509V3_set_ctx_test(ctx) X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, X509V3_CTX_TEST) +#define X509V3_set_ctx_test(ctx) \ + X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, X509V3_CTX_TEST) #define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; -#define EXT_BITSTRING(nid, table) \ - { \ - nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), 0, 0, 0, 0, 0, 0, \ - (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, NULL, NULL, \ - table \ - } +#define EXT_BITSTRING(nid, table) \ + { \ + nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), 0, 0, 0, 0, 0, 0, \ + (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ + (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, NULL, NULL, table \ + } -#define EXT_IA5STRING(nid) \ - { \ - nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ - (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, 0, 0, 0, 0, NULL \ - } +#define EXT_IA5STRING(nid) \ + { \ + nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), 0, 0, 0, 0, \ + (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, 0, 0, 0, 0, NULL \ + } -#define EXT_UTF8STRING(nid) \ - { \ - nid, 0, ASN1_ITEM_ref(ASN1_UTF8STRING), 0, 0, 0, 0, (X509V3_EXT_I2S)i2s_ASN1_UTF8STRING, \ - (X509V3_EXT_S2I)s2i_ASN1_UTF8STRING, 0, 0, 0, 0, NULL \ - } +#define EXT_UTF8STRING(nid) \ + { \ + nid, 0, ASN1_ITEM_ref(ASN1_UTF8STRING), 0, 0, 0, 0, \ + (X509V3_EXT_I2S)i2s_ASN1_UTF8STRING, \ + (X509V3_EXT_S2I)s2i_ASN1_UTF8STRING, 0, 0, 0, 0, NULL \ + } -#define EXT_END \ - { \ - -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ - } +#define EXT_END \ + { \ + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ + } /* X509_PURPOSE stuff */ @@ -991,69 +1153,84 @@ struct ISSUING_DIST_POINT_st typedef struct x509_purpose_st { - int purpose; - int trust; /* Default trust ID */ - int flags; - int (*check_purpose)(const struct x509_purpose_st *, const X509 *, int); - char *name; - char *sname; - void *usr_data; + int purpose; + int trust; /* Default trust ID */ + int flags; + int (*check_purpose)(const struct x509_purpose_st *, const X509 *, int); + char *name; + char *sname; + void *usr_data; } X509_PURPOSE; SKM_DEFINE_STACK_OF_INTERNAL(X509_PURPOSE, X509_PURPOSE, X509_PURPOSE) -#define sk_X509_PURPOSE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_PURPOSE_sk_type(sk)) -#define sk_X509_PURPOSE_value(sk, idx) \ - ((X509_PURPOSE *)OPENSSL_sk_value(ossl_check_const_X509_PURPOSE_sk_type(sk), (idx))) -#define sk_X509_PURPOSE_new(cmp) \ - ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new(ossl_check_X509_PURPOSE_compfunc_type(cmp))) -#define sk_X509_PURPOSE_new_null() ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new_null()) -#define sk_X509_PURPOSE_new_reserve(cmp, n) \ - ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new_reserve(ossl_check_X509_PURPOSE_compfunc_type(cmp), \ - (n))) -#define sk_X509_PURPOSE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_PURPOSE_sk_type(sk), (n)) -#define sk_X509_PURPOSE_free(sk) OPENSSL_sk_free(ossl_check_X509_PURPOSE_sk_type(sk)) -#define sk_X509_PURPOSE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_PURPOSE_sk_type(sk)) -#define sk_X509_PURPOSE_delete(sk, i) \ - ((X509_PURPOSE *)OPENSSL_sk_delete(ossl_check_X509_PURPOSE_sk_type(sk), (i))) -#define sk_X509_PURPOSE_delete_ptr(sk, ptr) \ - ((X509_PURPOSE *)OPENSSL_sk_delete_ptr(ossl_check_X509_PURPOSE_sk_type(sk), \ - ossl_check_X509_PURPOSE_type(ptr))) -#define sk_X509_PURPOSE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) -#define sk_X509_PURPOSE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) -#define sk_X509_PURPOSE_pop(sk) \ - ((X509_PURPOSE *)OPENSSL_sk_pop(ossl_check_X509_PURPOSE_sk_type(sk))) -#define sk_X509_PURPOSE_shift(sk) \ - ((X509_PURPOSE *)OPENSSL_sk_shift(ossl_check_X509_PURPOSE_sk_type(sk))) -#define sk_X509_PURPOSE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_PURPOSE_sk_type(sk), \ - ossl_check_X509_PURPOSE_freefunc_type(freefunc)) -#define sk_X509_PURPOSE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr), (idx)) -#define sk_X509_PURPOSE_set(sk, idx, ptr) \ - ((X509_PURPOSE *)OPENSSL_sk_set(ossl_check_X509_PURPOSE_sk_type(sk), (idx), \ - ossl_check_X509_PURPOSE_type(ptr))) -#define sk_X509_PURPOSE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) -#define sk_X509_PURPOSE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr)) -#define sk_X509_PURPOSE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_type(ptr), \ - pnum) -#define sk_X509_PURPOSE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_PURPOSE_sk_type(sk)) -#define sk_X509_PURPOSE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_PURPOSE_sk_type(sk)) -#define sk_X509_PURPOSE_dup(sk) \ - ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_dup(ossl_check_const_X509_PURPOSE_sk_type(sk))) -#define sk_X509_PURPOSE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_PURPOSE_sk_type(sk), \ - ossl_check_X509_PURPOSE_copyfunc_type(copyfunc), \ - ossl_check_X509_PURPOSE_freefunc_type(freefunc))) -#define sk_X509_PURPOSE_set_cmp_func(sk, cmp) \ - ((sk_X509_PURPOSE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_PURPOSE_sk_type(sk), ossl_check_X509_PURPOSE_compfunc_type(cmp))) +#define sk_X509_PURPOSE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_value(sk, idx) \ + ((X509_PURPOSE *)OPENSSL_sk_value(ossl_check_const_X509_PURPOSE_sk_type(sk), \ + (idx))) +#define sk_X509_PURPOSE_new(cmp) \ + ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new( \ + ossl_check_X509_PURPOSE_compfunc_type(cmp))) +#define sk_X509_PURPOSE_new_null() \ + ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new_null()) +#define sk_X509_PURPOSE_new_reserve(cmp, n) \ + ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_PURPOSE_compfunc_type(cmp), (n))) +#define sk_X509_PURPOSE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_PURPOSE_sk_type(sk), (n)) +#define sk_X509_PURPOSE_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_delete(sk, i) \ + ((X509_PURPOSE *)OPENSSL_sk_delete(ossl_check_X509_PURPOSE_sk_type(sk), (i))) +#define sk_X509_PURPOSE_delete_ptr(sk, ptr) \ + ((X509_PURPOSE *)OPENSSL_sk_delete_ptr(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr))) +#define sk_X509_PURPOSE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_pop(sk) \ + ((X509_PURPOSE *)OPENSSL_sk_pop(ossl_check_X509_PURPOSE_sk_type(sk))) +#define sk_X509_PURPOSE_shift(sk) \ + ((X509_PURPOSE *)OPENSSL_sk_shift(ossl_check_X509_PURPOSE_sk_type(sk))) +#define sk_X509_PURPOSE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_freefunc_type(freefunc)) +#define sk_X509_PURPOSE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr), (idx)) +#define sk_X509_PURPOSE_set(sk, idx, ptr) \ + ((X509_PURPOSE *)OPENSSL_sk_set(ossl_check_X509_PURPOSE_sk_type(sk), (idx), \ + ossl_check_X509_PURPOSE_type(ptr))) +#define sk_X509_PURPOSE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr)) +#define sk_X509_PURPOSE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_type(ptr), pnum) +#define sk_X509_PURPOSE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_PURPOSE_sk_type(sk)) +#define sk_X509_PURPOSE_dup(sk) \ + ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_PURPOSE_sk_type(sk))) +#define sk_X509_PURPOSE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_PURPOSE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_copyfunc_type(copyfunc), \ + ossl_check_X509_PURPOSE_freefunc_type(freefunc))) +#define sk_X509_PURPOSE_set_cmp_func(sk, cmp) \ + ((sk_X509_PURPOSE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_PURPOSE_sk_type(sk), \ + ossl_check_X509_PURPOSE_compfunc_type(cmp))) #define X509_PURPOSE_SSL_CLIENT 1 #define X509_PURPOSE_SSL_SERVER 2 @@ -1099,9 +1276,12 @@ DECLARE_ASN1_FUNCTIONS(SXNETID) DECLARE_ASN1_FUNCTIONS(ISSUER_SIGN_TOOL) -int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen); -int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, int userlen); -int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, int userlen); +int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, + int userlen); +int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, + int userlen); +int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, + int userlen); ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone); ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); @@ -1121,32 +1301,39 @@ STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits, STACK_OF(CONF_VALUE) * extlist); char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); -ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str); +ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + const char *str); char *i2s_ASN1_UTF8STRING(X509V3_EXT_METHOD *method, ASN1_UTF8STRING *utf8); -ASN1_UTF8STRING *s2i_ASN1_UTF8STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str); +ASN1_UTF8STRING *s2i_ASN1_UTF8STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + const char *str); STACK_OF(CONF_VALUE) -*i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) * ret); +*i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, + STACK_OF(CONF_VALUE) * ret); int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) STACK_OF(CONF_VALUE) -*i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) * extlist); -GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - STACK_OF(CONF_VALUE) * nval); +*i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, GENERAL_NAMES *gen, + STACK_OF(CONF_VALUE) * extlist); +GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) * nval); DECLARE_ASN1_FUNCTIONS(OTHERNAME) DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype); -int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, ASN1_TYPE *value); -int GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen, ASN1_OBJECT **poid, ASN1_TYPE **pvalue); +int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, + ASN1_TYPE *value); +int GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen, ASN1_OBJECT **poid, + ASN1_TYPE **pvalue); -char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, const ASN1_OCTET_STRING *ia5); -ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, - const char *str); +char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, + const ASN1_OCTET_STRING *ia5); +ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, + X509V3_CTX *ctx, const char *str); DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a); @@ -1185,36 +1372,46 @@ DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) -GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, +GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, + const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, int gen_type, const char *value, int is_nc); #ifdef OPENSSL_CONF_H -GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf); -GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, +GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + CONF_VALUE *cnf); +GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, + const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc); void X509V3_conf_free(CONF_VALUE *val); -X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, const char *value); -X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, const char *value); +X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, + const char *value); +X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, + const char *value); int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, STACK_OF(X509_EXTENSION) * *sk); -int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, X509 *cert); -int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, X509_REQ *req); -int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, X509_CRL *crl); +int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509 *cert); +int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509_REQ *req); +int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, + X509_CRL *crl); -X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, int ext_nid, +X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) * conf, + X509V3_CTX *ctx, int ext_nid, const char *value); -X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, const char *name, - const char *value); -int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, const char *section, - X509 *cert); -int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, const char *section, - X509_REQ *req); -int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, const char *section, - X509_CRL *crl); +X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, + const char *name, const char *value); +int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, + const char *section, X509 *cert); +int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, + const char *section, X509_REQ *req); +int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) * conf, X509V3_CTX *ctx, + const char *section, X509_CRL *crl); -int X509V3_add_value_bool_nf(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) * *extlist); +int X509V3_add_value_bool_nf(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) * *extlist); int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool); int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint); void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); @@ -1225,21 +1422,24 @@ char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section); STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, const char *section); void X509V3_string_free(X509V3_CTX *ctx, char *str); void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) * section); -void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, X509_REQ *req, X509_CRL *crl, - int flags); +void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, X509_REQ *req, + X509_CRL *crl, int flags); /* For API backward compatibility, this is separate from X509V3_set_ctx(): */ int X509V3_set_issuer_pkey(X509V3_CTX *ctx, EVP_PKEY *pkey); -int X509V3_add_value(const char *name, const char *value, STACK_OF(CONF_VALUE) * *extlist); +int X509V3_add_value(const char *name, const char *value, + STACK_OF(CONF_VALUE) * *extlist); int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) * *extlist); -int X509V3_add_value_bool(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) * *extlist); +int X509V3_add_value_bool(const char *name, int asn1_bool, + STACK_OF(CONF_VALUE) * *extlist); int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, STACK_OF(CONF_VALUE) * *extlist); char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint); ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value); char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); -char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); +char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, + const ASN1_ENUMERATED *aint); int X509V3_EXT_add(X509V3_EXT_METHOD *ext); int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); int X509V3_EXT_add_alias(int nid_to, int nid_from); @@ -1250,24 +1450,28 @@ const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); int X509V3_add_standard_extensions(void); STACK_OF(CONF_VALUE) * X509V3_parse_list(const char *line); void *X509V3_EXT_d2i(X509_EXTENSION *ext); -void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) * x, int nid, int *crit, int *idx); +void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) * x, int nid, int *crit, + int *idx); X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); -int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) * *x, int nid, void *value, int crit, - unsigned long flags); +int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) * *x, int nid, void *value, + int crit, unsigned long flags); #ifndef OPENSSL_NO_DEPRECATED_1_1_0 /* The new declarations are in crypto.h, but the old ones were here. */ -# define hex_to_string OPENSSL_buf2hexstr -# define string_to_hex OPENSSL_hexstr2buf +# define hex_to_string OPENSSL_buf2hexstr +# define string_to_hex OPENSSL_hexstr2buf #endif -void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) * val, int indent, int ml); -int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent); +void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) * val, int indent, + int ml); +int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, + int indent); #ifndef OPENSSL_NO_STDIO int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); #endif -int X509V3_extensions_print(BIO *out, const char *title, const STACK_OF(X509_EXTENSION) * exts, +int X509V3_extensions_print(BIO *out, const char *title, + const STACK_OF(X509_EXTENSION) * exts, unsigned long flag, int indent); int X509_check_ca(X509 *x); @@ -1293,8 +1497,8 @@ X509_PURPOSE *X509_PURPOSE_get0(int idx); int X509_PURPOSE_get_by_sname(const char *sname); int X509_PURPOSE_get_by_id(int id); int X509_PURPOSE_add(int id, int trust, int flags, - int (*ck)(const X509_PURPOSE *, const X509 *, int), const char *name, - const char *sname, void *arg); + int (*ck)(const X509_PURPOSE *, const X509 *, int), + const char *name, const char *sname, void *arg); char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); @@ -1328,169 +1532,202 @@ STACK_OF(OPENSSL_STRING) * X509_get1_ocsp(X509 *x); */ #define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 -int X509_check_host(X509 *x, const char *chk, size_t chklen, unsigned int flags, char **peername); -int X509_check_email(X509 *x, const char *chk, size_t chklen, unsigned int flags); -int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, unsigned int flags); +int X509_check_host(X509 *x, const char *chk, size_t chklen, unsigned int flags, + char **peername); +int X509_check_email(X509 *x, const char *chk, size_t chklen, + unsigned int flags); +int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, + unsigned int flags); int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); -int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) * dn_sk, unsigned long chtype); +int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) * dn_sk, + unsigned long chtype); void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); -SKM_DEFINE_STACK_OF_INTERNAL(X509_POLICY_NODE, X509_POLICY_NODE, X509_POLICY_NODE) -#define sk_X509_POLICY_NODE_num(sk) OPENSSL_sk_num(ossl_check_const_X509_POLICY_NODE_sk_type(sk)) -#define sk_X509_POLICY_NODE_value(sk, idx) \ - ((X509_POLICY_NODE *)OPENSSL_sk_value(ossl_check_const_X509_POLICY_NODE_sk_type(sk), (idx))) -#define sk_X509_POLICY_NODE_new(cmp) \ - ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new(ossl_check_X509_POLICY_NODE_compfunc_type(cmp))) -#define sk_X509_POLICY_NODE_new_null() ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new_null()) -#define sk_X509_POLICY_NODE_new_reserve(cmp, n) \ - ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new_reserve( \ - ossl_check_X509_POLICY_NODE_compfunc_type(cmp), (n))) -#define sk_X509_POLICY_NODE_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_X509_POLICY_NODE_sk_type(sk), (n)) -#define sk_X509_POLICY_NODE_free(sk) OPENSSL_sk_free(ossl_check_X509_POLICY_NODE_sk_type(sk)) -#define sk_X509_POLICY_NODE_zero(sk) OPENSSL_sk_zero(ossl_check_X509_POLICY_NODE_sk_type(sk)) -#define sk_X509_POLICY_NODE_delete(sk, i) \ - ((X509_POLICY_NODE *)OPENSSL_sk_delete(ossl_check_X509_POLICY_NODE_sk_type(sk), (i))) -#define sk_X509_POLICY_NODE_delete_ptr(sk, ptr) \ - ((X509_POLICY_NODE *)OPENSSL_sk_delete_ptr(ossl_check_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_type(ptr))) -#define sk_X509_POLICY_NODE_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr)) -#define sk_X509_POLICY_NODE_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_type(ptr)) -#define sk_X509_POLICY_NODE_pop(sk) \ - ((X509_POLICY_NODE *)OPENSSL_sk_pop(ossl_check_X509_POLICY_NODE_sk_type(sk))) -#define sk_X509_POLICY_NODE_shift(sk) \ - ((X509_POLICY_NODE *)OPENSSL_sk_shift(ossl_check_X509_POLICY_NODE_sk_type(sk))) -#define sk_X509_POLICY_NODE_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_freefunc_type(freefunc)) -#define sk_X509_POLICY_NODE_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_type(ptr), (idx)) -#define sk_X509_POLICY_NODE_set(sk, idx, ptr) \ - ((X509_POLICY_NODE *)OPENSSL_sk_set(ossl_check_X509_POLICY_NODE_sk_type(sk), (idx), \ - ossl_check_X509_POLICY_NODE_type(ptr))) -#define sk_X509_POLICY_NODE_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_type(ptr)) -#define sk_X509_POLICY_NODE_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_type(ptr)) -#define sk_X509_POLICY_NODE_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_type(ptr), pnum) -#define sk_X509_POLICY_NODE_sort(sk) OPENSSL_sk_sort(ossl_check_X509_POLICY_NODE_sk_type(sk)) -#define sk_X509_POLICY_NODE_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_X509_POLICY_NODE_sk_type(sk)) -#define sk_X509_POLICY_NODE_dup(sk) \ - ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_dup(ossl_check_const_X509_POLICY_NODE_sk_type(sk))) -#define sk_X509_POLICY_NODE_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_X509_POLICY_NODE_sk_type(sk), \ - ossl_check_X509_POLICY_NODE_copyfunc_type(copyfunc), \ - ossl_check_X509_POLICY_NODE_freefunc_type(freefunc))) -#define sk_X509_POLICY_NODE_set_cmp_func(sk, cmp) \ - ((sk_X509_POLICY_NODE_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_X509_POLICY_NODE_sk_type(sk), ossl_check_X509_POLICY_NODE_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(X509_POLICY_NODE, X509_POLICY_NODE, + X509_POLICY_NODE) +#define sk_X509_POLICY_NODE_num(sk) \ + OPENSSL_sk_num(ossl_check_const_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_value(sk, idx) \ + ((X509_POLICY_NODE *)OPENSSL_sk_value( \ + ossl_check_const_X509_POLICY_NODE_sk_type(sk), (idx))) +#define sk_X509_POLICY_NODE_new(cmp) \ + ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new( \ + ossl_check_X509_POLICY_NODE_compfunc_type(cmp))) +#define sk_X509_POLICY_NODE_new_null() \ + ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new_null()) +#define sk_X509_POLICY_NODE_new_reserve(cmp, n) \ + ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_new_reserve( \ + ossl_check_X509_POLICY_NODE_compfunc_type(cmp), (n))) +#define sk_X509_POLICY_NODE_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_X509_POLICY_NODE_sk_type(sk), (n)) +#define sk_X509_POLICY_NODE_free(sk) \ + OPENSSL_sk_free(ossl_check_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_zero(sk) \ + OPENSSL_sk_zero(ossl_check_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_delete(sk, i) \ + ((X509_POLICY_NODE *)OPENSSL_sk_delete( \ + ossl_check_X509_POLICY_NODE_sk_type(sk), (i))) +#define sk_X509_POLICY_NODE_delete_ptr(sk, ptr) \ + ((X509_POLICY_NODE *)OPENSSL_sk_delete_ptr( \ + ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr))) +#define sk_X509_POLICY_NODE_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_pop(sk) \ + ((X509_POLICY_NODE *)OPENSSL_sk_pop(ossl_check_X509_POLICY_NODE_sk_type(sk))) +#define sk_X509_POLICY_NODE_shift(sk) \ + ((X509_POLICY_NODE *)OPENSSL_sk_shift( \ + ossl_check_X509_POLICY_NODE_sk_type(sk))) +#define sk_X509_POLICY_NODE_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_freefunc_type(freefunc)) +#define sk_X509_POLICY_NODE_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr), (idx)) +#define sk_X509_POLICY_NODE_set(sk, idx, ptr) \ + ((X509_POLICY_NODE *)OPENSSL_sk_set(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + (idx), \ + ossl_check_X509_POLICY_NODE_type(ptr))) +#define sk_X509_POLICY_NODE_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr)) +#define sk_X509_POLICY_NODE_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_type(ptr), pnum) +#define sk_X509_POLICY_NODE_sort(sk) \ + OPENSSL_sk_sort(ossl_check_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_X509_POLICY_NODE_sk_type(sk)) +#define sk_X509_POLICY_NODE_dup(sk) \ + ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_dup( \ + ossl_check_const_X509_POLICY_NODE_sk_type(sk))) +#define sk_X509_POLICY_NODE_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(X509_POLICY_NODE) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_copyfunc_type(copyfunc), \ + ossl_check_X509_POLICY_NODE_freefunc_type(freefunc))) +#define sk_X509_POLICY_NODE_set_cmp_func(sk, cmp) \ + ((sk_X509_POLICY_NODE_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_X509_POLICY_NODE_sk_type(sk), \ + ossl_check_X509_POLICY_NODE_compfunc_type(cmp))) #ifndef OPENSSL_NO_RFC3779 typedef struct ASRange_st { - ASN1_INTEGER *min, *max; + ASN1_INTEGER *min, *max; } ASRange; -# define ASIdOrRange_id 0 -# define ASIdOrRange_range 1 +# define ASIdOrRange_id 0 +# define ASIdOrRange_range 1 typedef struct ASIdOrRange_st { - int type; - union - { - ASN1_INTEGER *id; - ASRange *range; - } u; + int type; + union + { + ASN1_INTEGER *id; + ASRange *range; + } u; } ASIdOrRange; SKM_DEFINE_STACK_OF_INTERNAL(ASIdOrRange, ASIdOrRange, ASIdOrRange) -# define sk_ASIdOrRange_num(sk) OPENSSL_sk_num(ossl_check_const_ASIdOrRange_sk_type(sk)) -# define sk_ASIdOrRange_value(sk, idx) \ - ((ASIdOrRange *)OPENSSL_sk_value(ossl_check_const_ASIdOrRange_sk_type(sk), (idx))) -# define sk_ASIdOrRange_new(cmp) \ - ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new(ossl_check_ASIdOrRange_compfunc_type(cmp))) -# define sk_ASIdOrRange_new_null() ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new_null()) -# define sk_ASIdOrRange_new_reserve(cmp, n) \ - ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new_reserve( \ - ossl_check_ASIdOrRange_compfunc_type(cmp), (n))) -# define sk_ASIdOrRange_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_ASIdOrRange_sk_type(sk), (n)) -# define sk_ASIdOrRange_free(sk) OPENSSL_sk_free(ossl_check_ASIdOrRange_sk_type(sk)) -# define sk_ASIdOrRange_zero(sk) OPENSSL_sk_zero(ossl_check_ASIdOrRange_sk_type(sk)) -# define sk_ASIdOrRange_delete(sk, i) \ - ((ASIdOrRange *)OPENSSL_sk_delete(ossl_check_ASIdOrRange_sk_type(sk), (i))) -# define sk_ASIdOrRange_delete_ptr(sk, ptr) \ - ((ASIdOrRange *)OPENSSL_sk_delete_ptr(ossl_check_ASIdOrRange_sk_type(sk), \ - ossl_check_ASIdOrRange_type(ptr))) -# define sk_ASIdOrRange_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) -# define sk_ASIdOrRange_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) -# define sk_ASIdOrRange_pop(sk) \ - ((ASIdOrRange *)OPENSSL_sk_pop(ossl_check_ASIdOrRange_sk_type(sk))) -# define sk_ASIdOrRange_shift(sk) \ - ((ASIdOrRange *)OPENSSL_sk_shift(ossl_check_ASIdOrRange_sk_type(sk))) -# define sk_ASIdOrRange_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASIdOrRange_sk_type(sk), \ - ossl_check_ASIdOrRange_freefunc_type(freefunc)) -# define sk_ASIdOrRange_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr), \ - (idx)) -# define sk_ASIdOrRange_set(sk, idx, ptr) \ - ((ASIdOrRange *)OPENSSL_sk_set(ossl_check_ASIdOrRange_sk_type(sk), (idx), \ - ossl_check_ASIdOrRange_type(ptr))) -# define sk_ASIdOrRange_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) -# define sk_ASIdOrRange_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr)) -# define sk_ASIdOrRange_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_type(ptr), \ - pnum) -# define sk_ASIdOrRange_sort(sk) OPENSSL_sk_sort(ossl_check_ASIdOrRange_sk_type(sk)) -# define sk_ASIdOrRange_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_ASIdOrRange_sk_type(sk)) -# define sk_ASIdOrRange_dup(sk) \ - ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_dup(ossl_check_const_ASIdOrRange_sk_type(sk))) -# define sk_ASIdOrRange_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASIdOrRange_sk_type(sk), \ - ossl_check_ASIdOrRange_copyfunc_type(copyfunc), \ - ossl_check_ASIdOrRange_freefunc_type(freefunc))) -# define sk_ASIdOrRange_set_cmp_func(sk, cmp) \ - ((sk_ASIdOrRange_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_ASIdOrRange_sk_type(sk), ossl_check_ASIdOrRange_compfunc_type(cmp))) +# define sk_ASIdOrRange_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASIdOrRange_sk_type(sk)) +# define sk_ASIdOrRange_value(sk, idx) \ + ((ASIdOrRange *)OPENSSL_sk_value(ossl_check_const_ASIdOrRange_sk_type(sk), \ + (idx))) +# define sk_ASIdOrRange_new(cmp) \ + ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new( \ + ossl_check_ASIdOrRange_compfunc_type(cmp))) +# define sk_ASIdOrRange_new_null() \ + ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new_null()) +# define sk_ASIdOrRange_new_reserve(cmp, n) \ + ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASIdOrRange_compfunc_type(cmp), (n))) +# define sk_ASIdOrRange_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASIdOrRange_sk_type(sk), (n)) +# define sk_ASIdOrRange_free(sk) \ + OPENSSL_sk_free(ossl_check_ASIdOrRange_sk_type(sk)) +# define sk_ASIdOrRange_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASIdOrRange_sk_type(sk)) +# define sk_ASIdOrRange_delete(sk, i) \ + ((ASIdOrRange *)OPENSSL_sk_delete(ossl_check_ASIdOrRange_sk_type(sk), (i))) +# define sk_ASIdOrRange_delete_ptr(sk, ptr) \ + ((ASIdOrRange *)OPENSSL_sk_delete_ptr(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr))) +# define sk_ASIdOrRange_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr)) +# define sk_ASIdOrRange_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr)) +# define sk_ASIdOrRange_pop(sk) \ + ((ASIdOrRange *)OPENSSL_sk_pop(ossl_check_ASIdOrRange_sk_type(sk))) +# define sk_ASIdOrRange_shift(sk) \ + ((ASIdOrRange *)OPENSSL_sk_shift(ossl_check_ASIdOrRange_sk_type(sk))) +# define sk_ASIdOrRange_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_freefunc_type(freefunc)) +# define sk_ASIdOrRange_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr), (idx)) +# define sk_ASIdOrRange_set(sk, idx, ptr) \ + ((ASIdOrRange *)OPENSSL_sk_set(ossl_check_ASIdOrRange_sk_type(sk), (idx), \ + ossl_check_ASIdOrRange_type(ptr))) +# define sk_ASIdOrRange_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr)) +# define sk_ASIdOrRange_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr)) +# define sk_ASIdOrRange_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_type(ptr), pnum) +# define sk_ASIdOrRange_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASIdOrRange_sk_type(sk)) +# define sk_ASIdOrRange_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASIdOrRange_sk_type(sk)) +# define sk_ASIdOrRange_dup(sk) \ + ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_dup( \ + ossl_check_const_ASIdOrRange_sk_type(sk))) +# define sk_ASIdOrRange_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASIdOrRange) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_copyfunc_type(copyfunc), \ + ossl_check_ASIdOrRange_freefunc_type(freefunc))) +# define sk_ASIdOrRange_set_cmp_func(sk, cmp) \ + ((sk_ASIdOrRange_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASIdOrRange_sk_type(sk), \ + ossl_check_ASIdOrRange_compfunc_type(cmp))) typedef STACK_OF(ASIdOrRange) ASIdOrRanges; -# define ASIdentifierChoice_inherit 0 -# define ASIdentifierChoice_asIdsOrRanges 1 +# define ASIdentifierChoice_inherit 0 +# define ASIdentifierChoice_asIdsOrRanges 1 typedef struct ASIdentifierChoice_st { - int type; - union - { - ASN1_NULL *inherit; - ASIdOrRanges *asIdsOrRanges; - } u; + int type; + union + { + ASN1_NULL *inherit; + ASIdOrRanges *asIdsOrRanges; + } u; } ASIdentifierChoice; typedef struct ASIdentifiers_st { - ASIdentifierChoice *asnum, *rdi; + ASIdentifierChoice *asnum, *rdi; } ASIdentifiers; DECLARE_ASN1_FUNCTIONS(ASRange) @@ -1500,169 +1737,192 @@ DECLARE_ASN1_FUNCTIONS(ASIdentifiers) typedef struct IPAddressRange_st { - ASN1_BIT_STRING *min, *max; + ASN1_BIT_STRING *min, *max; } IPAddressRange; -# define IPAddressOrRange_addressPrefix 0 -# define IPAddressOrRange_addressRange 1 +# define IPAddressOrRange_addressPrefix 0 +# define IPAddressOrRange_addressRange 1 typedef struct IPAddressOrRange_st { - int type; - union - { - ASN1_BIT_STRING *addressPrefix; - IPAddressRange *addressRange; - } u; + int type; + union + { + ASN1_BIT_STRING *addressPrefix; + IPAddressRange *addressRange; + } u; } IPAddressOrRange; -SKM_DEFINE_STACK_OF_INTERNAL(IPAddressOrRange, IPAddressOrRange, IPAddressOrRange) -# define sk_IPAddressOrRange_num(sk) \ - OPENSSL_sk_num(ossl_check_const_IPAddressOrRange_sk_type(sk)) -# define sk_IPAddressOrRange_value(sk, idx) \ - ((IPAddressOrRange *)OPENSSL_sk_value(ossl_check_const_IPAddressOrRange_sk_type(sk), (idx))) -# define sk_IPAddressOrRange_new(cmp) \ - ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new( \ - ossl_check_IPAddressOrRange_compfunc_type(cmp))) -# define sk_IPAddressOrRange_new_null() ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new_null()) -# define sk_IPAddressOrRange_new_reserve(cmp, n) \ - ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new_reserve( \ - ossl_check_IPAddressOrRange_compfunc_type(cmp), (n))) -# define sk_IPAddressOrRange_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_IPAddressOrRange_sk_type(sk), (n)) -# define sk_IPAddressOrRange_free(sk) OPENSSL_sk_free(ossl_check_IPAddressOrRange_sk_type(sk)) -# define sk_IPAddressOrRange_zero(sk) OPENSSL_sk_zero(ossl_check_IPAddressOrRange_sk_type(sk)) -# define sk_IPAddressOrRange_delete(sk, i) \ - ((IPAddressOrRange *)OPENSSL_sk_delete(ossl_check_IPAddressOrRange_sk_type(sk), (i))) -# define sk_IPAddressOrRange_delete_ptr(sk, ptr) \ - ((IPAddressOrRange *)OPENSSL_sk_delete_ptr(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr))) -# define sk_IPAddressOrRange_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr)) -# define sk_IPAddressOrRange_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr)) -# define sk_IPAddressOrRange_pop(sk) \ - ((IPAddressOrRange *)OPENSSL_sk_pop(ossl_check_IPAddressOrRange_sk_type(sk))) -# define sk_IPAddressOrRange_shift(sk) \ - ((IPAddressOrRange *)OPENSSL_sk_shift(ossl_check_IPAddressOrRange_sk_type(sk))) -# define sk_IPAddressOrRange_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_freefunc_type(freefunc)) -# define sk_IPAddressOrRange_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr), (idx)) -# define sk_IPAddressOrRange_set(sk, idx, ptr) \ - ((IPAddressOrRange *)OPENSSL_sk_set(ossl_check_IPAddressOrRange_sk_type(sk), (idx), \ - ossl_check_IPAddressOrRange_type(ptr))) -# define sk_IPAddressOrRange_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr)) -# define sk_IPAddressOrRange_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr)) -# define sk_IPAddressOrRange_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_type(ptr), pnum) -# define sk_IPAddressOrRange_sort(sk) OPENSSL_sk_sort(ossl_check_IPAddressOrRange_sk_type(sk)) -# define sk_IPAddressOrRange_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_IPAddressOrRange_sk_type(sk)) -# define sk_IPAddressOrRange_dup(sk) \ - ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_dup( \ - ossl_check_const_IPAddressOrRange_sk_type(sk))) -# define sk_IPAddressOrRange_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_copyfunc_type(copyfunc), \ - ossl_check_IPAddressOrRange_freefunc_type(freefunc))) -# define sk_IPAddressOrRange_set_cmp_func(sk, cmp) \ - ((sk_IPAddressOrRange_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_IPAddressOrRange_sk_type(sk), \ - ossl_check_IPAddressOrRange_compfunc_type(cmp))) +SKM_DEFINE_STACK_OF_INTERNAL(IPAddressOrRange, IPAddressOrRange, + IPAddressOrRange) +# define sk_IPAddressOrRange_num(sk) \ + OPENSSL_sk_num(ossl_check_const_IPAddressOrRange_sk_type(sk)) +# define sk_IPAddressOrRange_value(sk, idx) \ + ((IPAddressOrRange *)OPENSSL_sk_value( \ + ossl_check_const_IPAddressOrRange_sk_type(sk), (idx))) +# define sk_IPAddressOrRange_new(cmp) \ + ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new( \ + ossl_check_IPAddressOrRange_compfunc_type(cmp))) +# define sk_IPAddressOrRange_new_null() \ + ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new_null()) +# define sk_IPAddressOrRange_new_reserve(cmp, n) \ + ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_new_reserve( \ + ossl_check_IPAddressOrRange_compfunc_type(cmp), (n))) +# define sk_IPAddressOrRange_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_IPAddressOrRange_sk_type(sk), (n)) +# define sk_IPAddressOrRange_free(sk) \ + OPENSSL_sk_free(ossl_check_IPAddressOrRange_sk_type(sk)) +# define sk_IPAddressOrRange_zero(sk) \ + OPENSSL_sk_zero(ossl_check_IPAddressOrRange_sk_type(sk)) +# define sk_IPAddressOrRange_delete(sk, i) \ + ((IPAddressOrRange *)OPENSSL_sk_delete( \ + ossl_check_IPAddressOrRange_sk_type(sk), (i))) +# define sk_IPAddressOrRange_delete_ptr(sk, ptr) \ + ((IPAddressOrRange *)OPENSSL_sk_delete_ptr( \ + ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr))) +# define sk_IPAddressOrRange_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr)) +# define sk_IPAddressOrRange_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr)) +# define sk_IPAddressOrRange_pop(sk) \ + ((IPAddressOrRange *)OPENSSL_sk_pop( \ + ossl_check_IPAddressOrRange_sk_type(sk))) +# define sk_IPAddressOrRange_shift(sk) \ + ((IPAddressOrRange *)OPENSSL_sk_shift( \ + ossl_check_IPAddressOrRange_sk_type(sk))) +# define sk_IPAddressOrRange_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_freefunc_type(freefunc)) +# define sk_IPAddressOrRange_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr), (idx)) +# define sk_IPAddressOrRange_set(sk, idx, ptr) \ + ((IPAddressOrRange *)OPENSSL_sk_set( \ + ossl_check_IPAddressOrRange_sk_type(sk), (idx), \ + ossl_check_IPAddressOrRange_type(ptr))) +# define sk_IPAddressOrRange_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr)) +# define sk_IPAddressOrRange_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr)) +# define sk_IPAddressOrRange_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_type(ptr), pnum) +# define sk_IPAddressOrRange_sort(sk) \ + OPENSSL_sk_sort(ossl_check_IPAddressOrRange_sk_type(sk)) +# define sk_IPAddressOrRange_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_IPAddressOrRange_sk_type(sk)) +# define sk_IPAddressOrRange_dup(sk) \ + ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_dup( \ + ossl_check_const_IPAddressOrRange_sk_type(sk))) +# define sk_IPAddressOrRange_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(IPAddressOrRange) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_copyfunc_type(copyfunc), \ + ossl_check_IPAddressOrRange_freefunc_type(freefunc))) +# define sk_IPAddressOrRange_set_cmp_func(sk, cmp) \ + ((sk_IPAddressOrRange_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_IPAddressOrRange_sk_type(sk), \ + ossl_check_IPAddressOrRange_compfunc_type(cmp))) typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; -# define IPAddressChoice_inherit 0 -# define IPAddressChoice_addressesOrRanges 1 +# define IPAddressChoice_inherit 0 +# define IPAddressChoice_addressesOrRanges 1 typedef struct IPAddressChoice_st { - int type; - union - { - ASN1_NULL *inherit; - IPAddressOrRanges *addressesOrRanges; - } u; + int type; + union + { + ASN1_NULL *inherit; + IPAddressOrRanges *addressesOrRanges; + } u; } IPAddressChoice; typedef struct IPAddressFamily_st { - ASN1_OCTET_STRING *addressFamily; - IPAddressChoice *ipAddressChoice; + ASN1_OCTET_STRING *addressFamily; + IPAddressChoice *ipAddressChoice; } IPAddressFamily; SKM_DEFINE_STACK_OF_INTERNAL(IPAddressFamily, IPAddressFamily, IPAddressFamily) -# define sk_IPAddressFamily_num(sk) OPENSSL_sk_num(ossl_check_const_IPAddressFamily_sk_type(sk)) -# define sk_IPAddressFamily_value(sk, idx) \ - ((IPAddressFamily *)OPENSSL_sk_value(ossl_check_const_IPAddressFamily_sk_type(sk), (idx))) -# define sk_IPAddressFamily_new(cmp) \ - ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new(ossl_check_IPAddressFamily_compfunc_type(cmp))) -# define sk_IPAddressFamily_new_null() ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new_null()) -# define sk_IPAddressFamily_new_reserve(cmp, n) \ - ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new_reserve( \ - ossl_check_IPAddressFamily_compfunc_type(cmp), (n))) -# define sk_IPAddressFamily_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_IPAddressFamily_sk_type(sk), (n)) -# define sk_IPAddressFamily_free(sk) OPENSSL_sk_free(ossl_check_IPAddressFamily_sk_type(sk)) -# define sk_IPAddressFamily_zero(sk) OPENSSL_sk_zero(ossl_check_IPAddressFamily_sk_type(sk)) -# define sk_IPAddressFamily_delete(sk, i) \ - ((IPAddressFamily *)OPENSSL_sk_delete(ossl_check_IPAddressFamily_sk_type(sk), (i))) -# define sk_IPAddressFamily_delete_ptr(sk, ptr) \ - ((IPAddressFamily *)OPENSSL_sk_delete_ptr(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr))) -# define sk_IPAddressFamily_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr)) -# define sk_IPAddressFamily_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr)) -# define sk_IPAddressFamily_pop(sk) \ - ((IPAddressFamily *)OPENSSL_sk_pop(ossl_check_IPAddressFamily_sk_type(sk))) -# define sk_IPAddressFamily_shift(sk) \ - ((IPAddressFamily *)OPENSSL_sk_shift(ossl_check_IPAddressFamily_sk_type(sk))) -# define sk_IPAddressFamily_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_freefunc_type(freefunc)) -# define sk_IPAddressFamily_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr), (idx)) -# define sk_IPAddressFamily_set(sk, idx, ptr) \ - ((IPAddressFamily *)OPENSSL_sk_set(ossl_check_IPAddressFamily_sk_type(sk), (idx), \ - ossl_check_IPAddressFamily_type(ptr))) -# define sk_IPAddressFamily_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr)) -# define sk_IPAddressFamily_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr)) -# define sk_IPAddressFamily_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_type(ptr), pnum) -# define sk_IPAddressFamily_sort(sk) OPENSSL_sk_sort(ossl_check_IPAddressFamily_sk_type(sk)) -# define sk_IPAddressFamily_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_IPAddressFamily_sk_type(sk)) -# define sk_IPAddressFamily_dup(sk) \ - ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_dup(ossl_check_const_IPAddressFamily_sk_type(sk))) -# define sk_IPAddressFamily_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_copyfunc_type(copyfunc), \ - ossl_check_IPAddressFamily_freefunc_type(freefunc))) -# define sk_IPAddressFamily_set_cmp_func(sk, cmp) \ - ((sk_IPAddressFamily_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_IPAddressFamily_sk_type(sk), \ - ossl_check_IPAddressFamily_compfunc_type(cmp))) +# define sk_IPAddressFamily_num(sk) \ + OPENSSL_sk_num(ossl_check_const_IPAddressFamily_sk_type(sk)) +# define sk_IPAddressFamily_value(sk, idx) \ + ((IPAddressFamily *)OPENSSL_sk_value( \ + ossl_check_const_IPAddressFamily_sk_type(sk), (idx))) +# define sk_IPAddressFamily_new(cmp) \ + ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new( \ + ossl_check_IPAddressFamily_compfunc_type(cmp))) +# define sk_IPAddressFamily_new_null() \ + ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new_null()) +# define sk_IPAddressFamily_new_reserve(cmp, n) \ + ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_new_reserve( \ + ossl_check_IPAddressFamily_compfunc_type(cmp), (n))) +# define sk_IPAddressFamily_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_IPAddressFamily_sk_type(sk), (n)) +# define sk_IPAddressFamily_free(sk) \ + OPENSSL_sk_free(ossl_check_IPAddressFamily_sk_type(sk)) +# define sk_IPAddressFamily_zero(sk) \ + OPENSSL_sk_zero(ossl_check_IPAddressFamily_sk_type(sk)) +# define sk_IPAddressFamily_delete(sk, i) \ + ((IPAddressFamily *)OPENSSL_sk_delete( \ + ossl_check_IPAddressFamily_sk_type(sk), (i))) +# define sk_IPAddressFamily_delete_ptr(sk, ptr) \ + ((IPAddressFamily *)OPENSSL_sk_delete_ptr( \ + ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr))) +# define sk_IPAddressFamily_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr)) +# define sk_IPAddressFamily_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr)) +# define sk_IPAddressFamily_pop(sk) \ + ((IPAddressFamily *)OPENSSL_sk_pop(ossl_check_IPAddressFamily_sk_type(sk))) +# define sk_IPAddressFamily_shift(sk) \ + ((IPAddressFamily *)OPENSSL_sk_shift( \ + ossl_check_IPAddressFamily_sk_type(sk))) +# define sk_IPAddressFamily_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_freefunc_type(freefunc)) +# define sk_IPAddressFamily_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr), (idx)) +# define sk_IPAddressFamily_set(sk, idx, ptr) \ + ((IPAddressFamily *)OPENSSL_sk_set(ossl_check_IPAddressFamily_sk_type(sk), \ + (idx), \ + ossl_check_IPAddressFamily_type(ptr))) +# define sk_IPAddressFamily_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr)) +# define sk_IPAddressFamily_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr)) +# define sk_IPAddressFamily_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_type(ptr), pnum) +# define sk_IPAddressFamily_sort(sk) \ + OPENSSL_sk_sort(ossl_check_IPAddressFamily_sk_type(sk)) +# define sk_IPAddressFamily_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_IPAddressFamily_sk_type(sk)) +# define sk_IPAddressFamily_dup(sk) \ + ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_dup( \ + ossl_check_const_IPAddressFamily_sk_type(sk))) +# define sk_IPAddressFamily_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(IPAddressFamily) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_copyfunc_type(copyfunc), \ + ossl_check_IPAddressFamily_freefunc_type(freefunc))) +# define sk_IPAddressFamily_set_cmp_func(sk, cmp) \ + ((sk_IPAddressFamily_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_IPAddressFamily_sk_type(sk), \ + ossl_check_IPAddressFamily_compfunc_type(cmp))) typedef STACK_OF(IPAddressFamily) IPAddrBlocks; @@ -1674,8 +1934,8 @@ DECLARE_ASN1_FUNCTIONS(IPAddressFamily) /* * API tag for elements of the ASIdentifer SEQUENCE. */ -# define V3_ASID_ASNUM 0 -# define V3_ASID_RDI 1 +# define V3_ASID_ASNUM 0 +# define V3_ASID_RDI 1 /* * AFI values, assigned by IANA. It'd be nice to make the AFI @@ -1683,8 +1943,8 @@ DECLARE_ASN1_FUNCTIONS(IPAddressFamily) * that would need to be defined for other address families for it to * be worth the trouble. */ -# define IANA_AFI_IPV4 1 -# define IANA_AFI_IPV6 2 +# define IANA_AFI_IPV4 1 +# define IANA_AFI_IPV6 2 /* * Utilities to construct and extract values from RFC3779 extensions, @@ -1692,16 +1952,20 @@ DECLARE_ASN1_FUNCTIONS(IPAddressFamily) * and ranges) are a bit tedious to work with directly. */ int X509v3_asid_add_inherit(ASIdentifiers *asid, int which); -int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, ASN1_INTEGER *min, - ASN1_INTEGER *max); -int X509v3_addr_add_inherit(IPAddrBlocks *addr, const unsigned afi, const unsigned *safi); -int X509v3_addr_add_prefix(IPAddrBlocks *addr, const unsigned afi, const unsigned *safi, - unsigned char *a, const int prefixlen); -int X509v3_addr_add_range(IPAddrBlocks *addr, const unsigned afi, const unsigned *safi, - unsigned char *min, unsigned char *max); +int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, + ASN1_INTEGER *min, ASN1_INTEGER *max); +int X509v3_addr_add_inherit(IPAddrBlocks *addr, const unsigned afi, + const unsigned *safi); +int X509v3_addr_add_prefix(IPAddrBlocks *addr, const unsigned afi, + const unsigned *safi, unsigned char *a, + const int prefixlen); +int X509v3_addr_add_range(IPAddrBlocks *addr, const unsigned afi, + const unsigned *safi, unsigned char *min, + unsigned char *max); unsigned X509v3_addr_get_afi(const IPAddressFamily *f); -int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, unsigned char *min, - unsigned char *max, const int length); +int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, + unsigned char *min, unsigned char *max, + const int length); /* * Canonical forms. @@ -1724,7 +1988,8 @@ int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); */ int X509v3_asid_validate_path(X509_STORE_CTX *); int X509v3_addr_validate_path(X509_STORE_CTX *); -int X509v3_asid_validate_resource_set(STACK_OF(X509) * chain, ASIdentifiers *ext, +int X509v3_asid_validate_resource_set(STACK_OF(X509) * chain, + ASIdentifiers *ext, int allow_inheritance); int X509v3_addr_validate_resource_set(STACK_OF(X509) * chain, IPAddrBlocks *ext, int allow_inheritance); @@ -1732,55 +1997,74 @@ int X509v3_addr_validate_resource_set(STACK_OF(X509) * chain, IPAddrBlocks *ext, #endif /* OPENSSL_NO_RFC3779 */ SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING, ASN1_STRING, ASN1_STRING) -#define sk_ASN1_STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_sk_type(sk)) -#define sk_ASN1_STRING_value(sk, idx) \ - ((ASN1_STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_sk_type(sk), (idx))) -#define sk_ASN1_STRING_new(cmp) \ - ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new(ossl_check_ASN1_STRING_compfunc_type(cmp))) -#define sk_ASN1_STRING_new_null() ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new_null()) -#define sk_ASN1_STRING_new_reserve(cmp, n) \ - ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_STRING_compfunc_type(cmp), \ - (n))) -#define sk_ASN1_STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_STRING_sk_type(sk), (n)) -#define sk_ASN1_STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_sk_type(sk)) -#define sk_ASN1_STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_sk_type(sk)) -#define sk_ASN1_STRING_delete(sk, i) \ - ((ASN1_STRING *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_sk_type(sk), (i))) -#define sk_ASN1_STRING_delete_ptr(sk, ptr) \ - ((ASN1_STRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_STRING_sk_type(sk), \ - ossl_check_ASN1_STRING_type(ptr))) -#define sk_ASN1_STRING_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) -#define sk_ASN1_STRING_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) -#define sk_ASN1_STRING_pop(sk) ((ASN1_STRING *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_sk_type(sk))) -#define sk_ASN1_STRING_shift(sk) \ - ((ASN1_STRING *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_sk_type(sk))) -#define sk_ASN1_STRING_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_sk_type(sk), \ - ossl_check_ASN1_STRING_freefunc_type(freefunc)) -#define sk_ASN1_STRING_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr), (idx)) -#define sk_ASN1_STRING_set(sk, idx, ptr) \ - ((ASN1_STRING *)OPENSSL_sk_set(ossl_check_ASN1_STRING_sk_type(sk), (idx), \ - ossl_check_ASN1_STRING_type(ptr))) -#define sk_ASN1_STRING_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) -#define sk_ASN1_STRING_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr)) -#define sk_ASN1_STRING_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_type(ptr), pnum) -#define sk_ASN1_STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_sk_type(sk)) -#define sk_ASN1_STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_sk_type(sk)) -#define sk_ASN1_STRING_dup(sk) \ - ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_sk_type(sk))) -#define sk_ASN1_STRING_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_ASN1_STRING_sk_type(sk), ossl_check_ASN1_STRING_copyfunc_type(copyfunc), \ - ossl_check_ASN1_STRING_freefunc_type(freefunc))) -#define sk_ASN1_STRING_set_cmp_func(sk, cmp) \ - ((sk_ASN1_STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_STRING_sk_type(sk), \ - ossl_check_ASN1_STRING_compfunc_type(cmp))) +#define sk_ASN1_STRING_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_value(sk, idx) \ + ((ASN1_STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_sk_type(sk), \ + (idx))) +#define sk_ASN1_STRING_new(cmp) \ + ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new( \ + ossl_check_ASN1_STRING_compfunc_type(cmp))) +#define sk_ASN1_STRING_new_null() \ + ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new_null()) +#define sk_ASN1_STRING_new_reserve(cmp, n) \ + ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_new_reserve( \ + ossl_check_ASN1_STRING_compfunc_type(cmp), (n))) +#define sk_ASN1_STRING_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ASN1_STRING_sk_type(sk), (n)) +#define sk_ASN1_STRING_free(sk) \ + OPENSSL_sk_free(ossl_check_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_delete(sk, i) \ + ((ASN1_STRING *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_sk_type(sk), (i))) +#define sk_ASN1_STRING_delete_ptr(sk, ptr) \ + ((ASN1_STRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr))) +#define sk_ASN1_STRING_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_pop(sk) \ + ((ASN1_STRING *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_sk_type(sk))) +#define sk_ASN1_STRING_shift(sk) \ + ((ASN1_STRING *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_sk_type(sk))) +#define sk_ASN1_STRING_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_freefunc_type(freefunc)) +#define sk_ASN1_STRING_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr), (idx)) +#define sk_ASN1_STRING_set(sk, idx, ptr) \ + ((ASN1_STRING *)OPENSSL_sk_set(ossl_check_ASN1_STRING_sk_type(sk), (idx), \ + ossl_check_ASN1_STRING_type(ptr))) +#define sk_ASN1_STRING_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr)) +#define sk_ASN1_STRING_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_type(ptr), pnum) +#define sk_ASN1_STRING_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_sk_type(sk)) +#define sk_ASN1_STRING_dup(sk) \ + ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_dup( \ + ossl_check_const_ASN1_STRING_sk_type(sk))) +#define sk_ASN1_STRING_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ASN1_STRING) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_copyfunc_type(copyfunc), \ + ossl_check_ASN1_STRING_freefunc_type(freefunc))) +#define sk_ASN1_STRING_set_cmp_func(sk, cmp) \ + ((sk_ASN1_STRING_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ASN1_STRING_sk_type(sk), \ + ossl_check_ASN1_STRING_compfunc_type(cmp))) /* * Admission Syntax @@ -1794,139 +2078,194 @@ DECLARE_ASN1_FUNCTIONS(PROFESSION_INFO) DECLARE_ASN1_FUNCTIONS(ADMISSIONS) DECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX) SKM_DEFINE_STACK_OF_INTERNAL(PROFESSION_INFO, PROFESSION_INFO, PROFESSION_INFO) -#define sk_PROFESSION_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PROFESSION_INFO_sk_type(sk)) -#define sk_PROFESSION_INFO_value(sk, idx) \ - ((PROFESSION_INFO *)OPENSSL_sk_value(ossl_check_const_PROFESSION_INFO_sk_type(sk), (idx))) -#define sk_PROFESSION_INFO_new(cmp) \ - ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new(ossl_check_PROFESSION_INFO_compfunc_type(cmp))) -#define sk_PROFESSION_INFO_new_null() ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new_null()) -#define sk_PROFESSION_INFO_new_reserve(cmp, n) \ - ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new_reserve( \ - ossl_check_PROFESSION_INFO_compfunc_type(cmp), (n))) -#define sk_PROFESSION_INFO_reserve(sk, n) \ - OPENSSL_sk_reserve(ossl_check_PROFESSION_INFO_sk_type(sk), (n)) -#define sk_PROFESSION_INFO_free(sk) OPENSSL_sk_free(ossl_check_PROFESSION_INFO_sk_type(sk)) -#define sk_PROFESSION_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PROFESSION_INFO_sk_type(sk)) -#define sk_PROFESSION_INFO_delete(sk, i) \ - ((PROFESSION_INFO *)OPENSSL_sk_delete(ossl_check_PROFESSION_INFO_sk_type(sk), (i))) -#define sk_PROFESSION_INFO_delete_ptr(sk, ptr) \ - ((PROFESSION_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PROFESSION_INFO_sk_type(sk), \ - ossl_check_PROFESSION_INFO_type(ptr))) -#define sk_PROFESSION_INFO_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) -#define sk_PROFESSION_INFO_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) -#define sk_PROFESSION_INFO_pop(sk) \ - ((PROFESSION_INFO *)OPENSSL_sk_pop(ossl_check_PROFESSION_INFO_sk_type(sk))) -#define sk_PROFESSION_INFO_shift(sk) \ - ((PROFESSION_INFO *)OPENSSL_sk_shift(ossl_check_PROFESSION_INFO_sk_type(sk))) -#define sk_PROFESSION_INFO_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_PROFESSION_INFO_sk_type(sk), \ - ossl_check_PROFESSION_INFO_freefunc_type(freefunc)) -#define sk_PROFESSION_INFO_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_PROFESSION_INFO_sk_type(sk), \ - ossl_check_PROFESSION_INFO_type(ptr), (idx)) -#define sk_PROFESSION_INFO_set(sk, idx, ptr) \ - ((PROFESSION_INFO *)OPENSSL_sk_set(ossl_check_PROFESSION_INFO_sk_type(sk), (idx), \ - ossl_check_PROFESSION_INFO_type(ptr))) -#define sk_PROFESSION_INFO_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) -#define sk_PROFESSION_INFO_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_type(ptr)) -#define sk_PROFESSION_INFO_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_PROFESSION_INFO_sk_type(sk), \ - ossl_check_PROFESSION_INFO_type(ptr), pnum) -#define sk_PROFESSION_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PROFESSION_INFO_sk_type(sk)) -#define sk_PROFESSION_INFO_is_sorted(sk) \ - OPENSSL_sk_is_sorted(ossl_check_const_PROFESSION_INFO_sk_type(sk)) -#define sk_PROFESSION_INFO_dup(sk) \ - ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_dup(ossl_check_const_PROFESSION_INFO_sk_type(sk))) -#define sk_PROFESSION_INFO_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_deep_copy( \ - ossl_check_const_PROFESSION_INFO_sk_type(sk), \ - ossl_check_PROFESSION_INFO_copyfunc_type(copyfunc), \ - ossl_check_PROFESSION_INFO_freefunc_type(freefunc))) -#define sk_PROFESSION_INFO_set_cmp_func(sk, cmp) \ - ((sk_PROFESSION_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ - ossl_check_PROFESSION_INFO_sk_type(sk), ossl_check_PROFESSION_INFO_compfunc_type(cmp))) +#define sk_PROFESSION_INFO_num(sk) \ + OPENSSL_sk_num(ossl_check_const_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_value(sk, idx) \ + ((PROFESSION_INFO *)OPENSSL_sk_value( \ + ossl_check_const_PROFESSION_INFO_sk_type(sk), (idx))) +#define sk_PROFESSION_INFO_new(cmp) \ + ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new( \ + ossl_check_PROFESSION_INFO_compfunc_type(cmp))) +#define sk_PROFESSION_INFO_new_null() \ + ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new_null()) +#define sk_PROFESSION_INFO_new_reserve(cmp, n) \ + ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_new_reserve( \ + ossl_check_PROFESSION_INFO_compfunc_type(cmp), (n))) +#define sk_PROFESSION_INFO_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_PROFESSION_INFO_sk_type(sk), (n)) +#define sk_PROFESSION_INFO_free(sk) \ + OPENSSL_sk_free(ossl_check_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_zero(sk) \ + OPENSSL_sk_zero(ossl_check_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_delete(sk, i) \ + ((PROFESSION_INFO *)OPENSSL_sk_delete( \ + ossl_check_PROFESSION_INFO_sk_type(sk), (i))) +#define sk_PROFESSION_INFO_delete_ptr(sk, ptr) \ + ((PROFESSION_INFO *)OPENSSL_sk_delete_ptr( \ + ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr))) +#define sk_PROFESSION_INFO_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_pop(sk) \ + ((PROFESSION_INFO *)OPENSSL_sk_pop(ossl_check_PROFESSION_INFO_sk_type(sk))) +#define sk_PROFESSION_INFO_shift(sk) \ + ((PROFESSION_INFO *)OPENSSL_sk_shift(ossl_check_PROFESSION_INFO_sk_type(sk))) +#define sk_PROFESSION_INFO_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_freefunc_type(freefunc)) +#define sk_PROFESSION_INFO_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr), (idx)) +#define sk_PROFESSION_INFO_set(sk, idx, ptr) \ + ((PROFESSION_INFO *)OPENSSL_sk_set(ossl_check_PROFESSION_INFO_sk_type(sk), \ + (idx), \ + ossl_check_PROFESSION_INFO_type(ptr))) +#define sk_PROFESSION_INFO_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr)) +#define sk_PROFESSION_INFO_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_type(ptr), pnum) +#define sk_PROFESSION_INFO_sort(sk) \ + OPENSSL_sk_sort(ossl_check_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_PROFESSION_INFO_sk_type(sk)) +#define sk_PROFESSION_INFO_dup(sk) \ + ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_dup( \ + ossl_check_const_PROFESSION_INFO_sk_type(sk))) +#define sk_PROFESSION_INFO_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(PROFESSION_INFO) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_copyfunc_type(copyfunc), \ + ossl_check_PROFESSION_INFO_freefunc_type(freefunc))) +#define sk_PROFESSION_INFO_set_cmp_func(sk, cmp) \ + ((sk_PROFESSION_INFO_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_PROFESSION_INFO_sk_type(sk), \ + ossl_check_PROFESSION_INFO_compfunc_type(cmp))) SKM_DEFINE_STACK_OF_INTERNAL(ADMISSIONS, ADMISSIONS, ADMISSIONS) -#define sk_ADMISSIONS_num(sk) OPENSSL_sk_num(ossl_check_const_ADMISSIONS_sk_type(sk)) -#define sk_ADMISSIONS_value(sk, idx) \ - ((ADMISSIONS *)OPENSSL_sk_value(ossl_check_const_ADMISSIONS_sk_type(sk), (idx))) -#define sk_ADMISSIONS_new(cmp) \ - ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new(ossl_check_ADMISSIONS_compfunc_type(cmp))) +#define sk_ADMISSIONS_num(sk) \ + OPENSSL_sk_num(ossl_check_const_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_value(sk, idx) \ + ((ADMISSIONS *)OPENSSL_sk_value(ossl_check_const_ADMISSIONS_sk_type(sk), \ + (idx))) +#define sk_ADMISSIONS_new(cmp) \ + ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new( \ + ossl_check_ADMISSIONS_compfunc_type(cmp))) #define sk_ADMISSIONS_new_null() ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new_null()) -#define sk_ADMISSIONS_new_reserve(cmp, n) \ - ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new_reserve(ossl_check_ADMISSIONS_compfunc_type(cmp), (n))) -#define sk_ADMISSIONS_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ADMISSIONS_sk_type(sk), (n)) -#define sk_ADMISSIONS_free(sk) OPENSSL_sk_free(ossl_check_ADMISSIONS_sk_type(sk)) -#define sk_ADMISSIONS_zero(sk) OPENSSL_sk_zero(ossl_check_ADMISSIONS_sk_type(sk)) -#define sk_ADMISSIONS_delete(sk, i) \ - ((ADMISSIONS *)OPENSSL_sk_delete(ossl_check_ADMISSIONS_sk_type(sk), (i))) -#define sk_ADMISSIONS_delete_ptr(sk, ptr) \ - ((ADMISSIONS *)OPENSSL_sk_delete_ptr(ossl_check_ADMISSIONS_sk_type(sk), \ - ossl_check_ADMISSIONS_type(ptr))) -#define sk_ADMISSIONS_push(sk, ptr) \ - OPENSSL_sk_push(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) -#define sk_ADMISSIONS_unshift(sk, ptr) \ - OPENSSL_sk_unshift(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) -#define sk_ADMISSIONS_pop(sk) ((ADMISSIONS *)OPENSSL_sk_pop(ossl_check_ADMISSIONS_sk_type(sk))) -#define sk_ADMISSIONS_shift(sk) ((ADMISSIONS *)OPENSSL_sk_shift(ossl_check_ADMISSIONS_sk_type(sk))) -#define sk_ADMISSIONS_pop_free(sk, freefunc) \ - OPENSSL_sk_pop_free(ossl_check_ADMISSIONS_sk_type(sk), \ - ossl_check_ADMISSIONS_freefunc_type(freefunc)) -#define sk_ADMISSIONS_insert(sk, ptr, idx) \ - OPENSSL_sk_insert(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr), (idx)) -#define sk_ADMISSIONS_set(sk, idx, ptr) \ - ((ADMISSIONS *)OPENSSL_sk_set(ossl_check_ADMISSIONS_sk_type(sk), (idx), \ - ossl_check_ADMISSIONS_type(ptr))) -#define sk_ADMISSIONS_find(sk, ptr) \ - OPENSSL_sk_find(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) -#define sk_ADMISSIONS_find_ex(sk, ptr) \ - OPENSSL_sk_find_ex(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr)) -#define sk_ADMISSIONS_find_all(sk, ptr, pnum) \ - OPENSSL_sk_find_all(ossl_check_ADMISSIONS_sk_type(sk), ossl_check_ADMISSIONS_type(ptr), pnum) -#define sk_ADMISSIONS_sort(sk) OPENSSL_sk_sort(ossl_check_ADMISSIONS_sk_type(sk)) -#define sk_ADMISSIONS_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ADMISSIONS_sk_type(sk)) -#define sk_ADMISSIONS_dup(sk) \ - ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_dup(ossl_check_const_ADMISSIONS_sk_type(sk))) -#define sk_ADMISSIONS_deep_copy(sk, copyfunc, freefunc) \ - ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_deep_copy(ossl_check_const_ADMISSIONS_sk_type(sk), \ - ossl_check_ADMISSIONS_copyfunc_type(copyfunc), \ - ossl_check_ADMISSIONS_freefunc_type(freefunc))) -#define sk_ADMISSIONS_set_cmp_func(sk, cmp) \ - ((sk_ADMISSIONS_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ADMISSIONS_sk_type(sk), \ - ossl_check_ADMISSIONS_compfunc_type(cmp))) +#define sk_ADMISSIONS_new_reserve(cmp, n) \ + ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_new_reserve( \ + ossl_check_ADMISSIONS_compfunc_type(cmp), (n))) +#define sk_ADMISSIONS_reserve(sk, n) \ + OPENSSL_sk_reserve(ossl_check_ADMISSIONS_sk_type(sk), (n)) +#define sk_ADMISSIONS_free(sk) \ + OPENSSL_sk_free(ossl_check_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_zero(sk) \ + OPENSSL_sk_zero(ossl_check_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_delete(sk, i) \ + ((ADMISSIONS *)OPENSSL_sk_delete(ossl_check_ADMISSIONS_sk_type(sk), (i))) +#define sk_ADMISSIONS_delete_ptr(sk, ptr) \ + ((ADMISSIONS *)OPENSSL_sk_delete_ptr(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr))) +#define sk_ADMISSIONS_push(sk, ptr) \ + OPENSSL_sk_push(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_unshift(sk, ptr) \ + OPENSSL_sk_unshift(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_pop(sk) \ + ((ADMISSIONS *)OPENSSL_sk_pop(ossl_check_ADMISSIONS_sk_type(sk))) +#define sk_ADMISSIONS_shift(sk) \ + ((ADMISSIONS *)OPENSSL_sk_shift(ossl_check_ADMISSIONS_sk_type(sk))) +#define sk_ADMISSIONS_pop_free(sk, freefunc) \ + OPENSSL_sk_pop_free(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_freefunc_type(freefunc)) +#define sk_ADMISSIONS_insert(sk, ptr, idx) \ + OPENSSL_sk_insert(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr), (idx)) +#define sk_ADMISSIONS_set(sk, idx, ptr) \ + ((ADMISSIONS *)OPENSSL_sk_set(ossl_check_ADMISSIONS_sk_type(sk), (idx), \ + ossl_check_ADMISSIONS_type(ptr))) +#define sk_ADMISSIONS_find(sk, ptr) \ + OPENSSL_sk_find(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_find_ex(sk, ptr) \ + OPENSSL_sk_find_ex(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr)) +#define sk_ADMISSIONS_find_all(sk, ptr, pnum) \ + OPENSSL_sk_find_all(ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_type(ptr), pnum) +#define sk_ADMISSIONS_sort(sk) \ + OPENSSL_sk_sort(ossl_check_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_is_sorted(sk) \ + OPENSSL_sk_is_sorted(ossl_check_const_ADMISSIONS_sk_type(sk)) +#define sk_ADMISSIONS_dup(sk) \ + ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_dup( \ + ossl_check_const_ADMISSIONS_sk_type(sk))) +#define sk_ADMISSIONS_deep_copy(sk, copyfunc, freefunc) \ + ((STACK_OF(ADMISSIONS) *)OPENSSL_sk_deep_copy( \ + ossl_check_const_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_copyfunc_type(copyfunc), \ + ossl_check_ADMISSIONS_freefunc_type(freefunc))) +#define sk_ADMISSIONS_set_cmp_func(sk, cmp) \ + ((sk_ADMISSIONS_compfunc)OPENSSL_sk_set_cmp_func( \ + ossl_check_ADMISSIONS_sk_type(sk), \ + ossl_check_ADMISSIONS_compfunc_type(cmp))) typedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS; const ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId(const NAMING_AUTHORITY *n); -const ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL(const NAMING_AUTHORITY *n); -const ASN1_STRING *NAMING_AUTHORITY_get0_authorityText(const NAMING_AUTHORITY *n); -void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n, ASN1_OBJECT *namingAuthorityId); -void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n, ASN1_IA5STRING *namingAuthorityUrl); -void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n, ASN1_STRING *namingAuthorityText); +const ASN1_IA5STRING * +NAMING_AUTHORITY_get0_authorityURL(const NAMING_AUTHORITY *n); +const ASN1_STRING * +NAMING_AUTHORITY_get0_authorityText(const NAMING_AUTHORITY *n); +void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n, + ASN1_OBJECT *namingAuthorityId); +void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n, + ASN1_IA5STRING *namingAuthorityUrl); +void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n, + ASN1_STRING *namingAuthorityText); -const GENERAL_NAME *ADMISSION_SYNTAX_get0_admissionAuthority(const ADMISSION_SYNTAX *as); -void ADMISSION_SYNTAX_set0_admissionAuthority(ADMISSION_SYNTAX *as, GENERAL_NAME *aa); -const STACK_OF(ADMISSIONS) * ADMISSION_SYNTAX_get0_contentsOfAdmissions(const ADMISSION_SYNTAX *as); -void ADMISSION_SYNTAX_set0_contentsOfAdmissions(ADMISSION_SYNTAX *as, STACK_OF(ADMISSIONS) * a); +const GENERAL_NAME * +ADMISSION_SYNTAX_get0_admissionAuthority(const ADMISSION_SYNTAX *as); +void ADMISSION_SYNTAX_set0_admissionAuthority(ADMISSION_SYNTAX *as, + GENERAL_NAME *aa); +const STACK_OF(ADMISSIONS) + * ADMISSION_SYNTAX_get0_contentsOfAdmissions(const ADMISSION_SYNTAX *as); +void ADMISSION_SYNTAX_set0_contentsOfAdmissions(ADMISSION_SYNTAX *as, + STACK_OF(ADMISSIONS) * a); const GENERAL_NAME *ADMISSIONS_get0_admissionAuthority(const ADMISSIONS *a); void ADMISSIONS_set0_admissionAuthority(ADMISSIONS *a, GENERAL_NAME *aa); const NAMING_AUTHORITY *ADMISSIONS_get0_namingAuthority(const ADMISSIONS *a); void ADMISSIONS_set0_namingAuthority(ADMISSIONS *a, NAMING_AUTHORITY *na); const PROFESSION_INFOS *ADMISSIONS_get0_professionInfos(const ADMISSIONS *a); void ADMISSIONS_set0_professionInfos(ADMISSIONS *a, PROFESSION_INFOS *pi); -const ASN1_OCTET_STRING *PROFESSION_INFO_get0_addProfessionInfo(const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_addProfessionInfo(PROFESSION_INFO *pi, ASN1_OCTET_STRING *aos); -const NAMING_AUTHORITY *PROFESSION_INFO_get0_namingAuthority(const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_namingAuthority(PROFESSION_INFO *pi, NAMING_AUTHORITY *na); -const STACK_OF(ASN1_STRING) * PROFESSION_INFO_get0_professionItems(const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_professionItems(PROFESSION_INFO *pi, STACK_OF(ASN1_STRING) * as); -const STACK_OF(ASN1_OBJECT) * PROFESSION_INFO_get0_professionOIDs(const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_professionOIDs(PROFESSION_INFO *pi, STACK_OF(ASN1_OBJECT) * po); -const ASN1_PRINTABLESTRING *PROFESSION_INFO_get0_registrationNumber(const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_registrationNumber(PROFESSION_INFO *pi, ASN1_PRINTABLESTRING *rn); +const ASN1_OCTET_STRING * +PROFESSION_INFO_get0_addProfessionInfo(const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_addProfessionInfo(PROFESSION_INFO *pi, + ASN1_OCTET_STRING *aos); +const NAMING_AUTHORITY * +PROFESSION_INFO_get0_namingAuthority(const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_namingAuthority(PROFESSION_INFO *pi, + NAMING_AUTHORITY *na); +const STACK_OF(ASN1_STRING) + * PROFESSION_INFO_get0_professionItems(const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_professionItems(PROFESSION_INFO *pi, + STACK_OF(ASN1_STRING) * as); +const STACK_OF(ASN1_OBJECT) + * PROFESSION_INFO_get0_professionOIDs(const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_professionOIDs(PROFESSION_INFO *pi, + STACK_OF(ASN1_OBJECT) * po); +const ASN1_PRINTABLESTRING * +PROFESSION_INFO_get0_registrationNumber(const PROFESSION_INFO *pi); +void PROFESSION_INFO_set0_registrationNumber(PROFESSION_INFO *pi, + ASN1_PRINTABLESTRING *rn); #ifdef __cplusplus } diff --git a/libs/QRealFourier/fftreal/Array.h b/libs/QRealFourier/fftreal/Array.h index b67f238e..b7a73162 100644 --- a/libs/QRealFourier/fftreal/Array.h +++ b/libs/QRealFourier/fftreal/Array.h @@ -13,86 +13,57 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_Array_HEADER_INCLUDED) +# define ffft_Array_HEADER_INCLUDED - -#if ! defined (ffft_Array_HEADER_INCLUDED) -#define ffft_Array_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - namespace ffft { - - -template +template class Array { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef T DataType; - typedef T DataType; + Array(); - Array (); + inline const DataType &operator[](long pos) const; + inline DataType &operator[](long pos); - inline const DataType & - operator [] (long pos) const; - inline DataType & - operator [] (long pos); + static inline long size(); - static inline long - size (); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + DataType _data_arr[LEN]; - DataType _data_arr [LEN]; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + Array(const Array &other); + Array &operator=(const Array &other); + bool operator==(const Array &other); + bool operator!=(const Array &other); - Array (const Array &other); - Array & operator = (const Array &other); - bool operator == (const Array &other); - bool operator != (const Array &other); +}; // class Array -}; // class Array - - - -} // namespace ffft - - - -#include "Array.hpp" - - - -#endif // ffft_Array_HEADER_INCLUDED +} // namespace ffft +# include "Array.hpp" +#endif // ffft_Array_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/Array.hpp b/libs/QRealFourier/fftreal/Array.hpp index 73b4aba8..1f4e399c 100644 --- a/libs/QRealFourier/fftreal/Array.hpp +++ b/libs/QRealFourier/fftreal/Array.hpp @@ -13,87 +13,62 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_Array_CURRENT_CODEHEADER) - #error Recursive inclusion of Array code header. +#if defined(ffft_Array_CURRENT_CODEHEADER) +# error Recursive inclusion of Array code header. #endif -#define ffft_Array_CURRENT_CODEHEADER - -#if ! defined (ffft_Array_CODEHEADER_INCLUDED) -#define ffft_Array_CODEHEADER_INCLUDED - +#define ffft_Array_CURRENT_CODEHEADER +#if !defined(ffft_Array_CODEHEADER_INCLUDED) +# define ffft_Array_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include - - +# include namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -Array ::Array () +template +Array::Array() { - // Nothing + // Nothing } - - -template -const typename Array ::DataType & Array ::operator [] (long pos) const +template +const typename Array::DataType & +Array::operator[](long pos) const { - assert (pos >= 0); - assert (pos < LEN); + assert(pos >= 0); + assert(pos < LEN); - return (_data_arr [pos]); + return (_data_arr[pos]); } - - -template -typename Array ::DataType & Array ::operator [] (long pos) +template +typename Array::DataType &Array::operator[](long pos) { - assert (pos >= 0); - assert (pos < LEN); + assert(pos >= 0); + assert(pos < LEN); - return (_data_arr [pos]); + return (_data_arr[pos]); } - - -template -long Array ::size () +template +long Array::size() { - return (LEN); + return (LEN); } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_Array_CODEHEADER_INCLUDED +#endif // ffft_Array_CODEHEADER_INCLUDED #undef ffft_Array_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/DynArray.h b/libs/QRealFourier/fftreal/DynArray.h index 82a12767..d240a64c 100644 --- a/libs/QRealFourier/fftreal/DynArray.h +++ b/libs/QRealFourier/fftreal/DynArray.h @@ -13,89 +13,61 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_DynArray_HEADER_INCLUDED) +# define ffft_DynArray_HEADER_INCLUDED - -#if ! defined (ffft_DynArray_HEADER_INCLUDED) -#define ffft_DynArray_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - namespace ffft { - - -template +template class DynArray { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef T DataType; - typedef T DataType; + DynArray(); + explicit DynArray(long size); + ~DynArray(); - DynArray (); - explicit DynArray (long size); - ~DynArray (); + inline long size() const; + inline void resize(long size); - inline long size () const; - inline void resize (long size); + inline const DataType &operator[](long pos) const; + inline DataType &operator[](long pos); - inline const DataType & - operator [] (long pos) const; - inline DataType & - operator [] (long pos); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + DataType *_data_ptr; + long _len; - DataType * _data_ptr; - long _len; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + DynArray(const DynArray &other); + DynArray &operator=(const DynArray &other); + bool operator==(const DynArray &other); + bool operator!=(const DynArray &other); - DynArray (const DynArray &other); - DynArray & operator = (const DynArray &other); - bool operator == (const DynArray &other); - bool operator != (const DynArray &other); +}; // class DynArray -}; // class DynArray - - - -} // namespace ffft - - - -#include "DynArray.hpp" - - - -#endif // ffft_DynArray_HEADER_INCLUDED +} // namespace ffft +# include "DynArray.hpp" +#endif // ffft_DynArray_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/DynArray.hpp b/libs/QRealFourier/fftreal/DynArray.hpp index 130fa24d..2483192d 100644 --- a/libs/QRealFourier/fftreal/DynArray.hpp +++ b/libs/QRealFourier/fftreal/DynArray.hpp @@ -13,132 +13,100 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_DynArray_CURRENT_CODEHEADER) - #error Recursive inclusion of DynArray code header. +#if defined(ffft_DynArray_CURRENT_CODEHEADER) +# error Recursive inclusion of DynArray code header. #endif -#define ffft_DynArray_CURRENT_CODEHEADER - -#if ! defined (ffft_DynArray_CODEHEADER_INCLUDED) -#define ffft_DynArray_CODEHEADER_INCLUDED - +#define ffft_DynArray_CURRENT_CODEHEADER +#if !defined(ffft_DynArray_CODEHEADER_INCLUDED) +# define ffft_DynArray_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include - - +# include namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -DynArray ::DynArray () -: _data_ptr (0) -, _len (0) +template +DynArray::DynArray() + : _data_ptr(0) + , _len(0) { - // Nothing + // Nothing } - - -template -DynArray ::DynArray (long size) -: _data_ptr (0) -, _len (0) +template +DynArray::DynArray(long size) + : _data_ptr(0) + , _len(0) { - assert (size >= 0); - if (size > 0) - { - _data_ptr = new DataType [size]; - _len = size; - } + assert(size >= 0); + if (size > 0) + { + _data_ptr = new DataType[size]; + _len = size; + } } - - -template -DynArray ::~DynArray () +template +DynArray::~DynArray() { - delete [] _data_ptr; - _data_ptr = 0; - _len = 0; + delete[] _data_ptr; + _data_ptr = 0; + _len = 0; } - - -template -long DynArray ::size () const +template +long DynArray::size() const { - return (_len); + return (_len); } - - -template -void DynArray ::resize (long size) +template +void DynArray::resize(long size) { - assert (size >= 0); - if (size > 0) - { - DataType * old_data_ptr = _data_ptr; - DataType * tmp_data_ptr = new DataType [size]; + assert(size >= 0); + if (size > 0) + { + DataType *old_data_ptr = _data_ptr; + DataType *tmp_data_ptr = new DataType[size]; - _data_ptr = tmp_data_ptr; - _len = size; + _data_ptr = tmp_data_ptr; + _len = size; - delete [] old_data_ptr; - } + delete[] old_data_ptr; + } } - - -template -const typename DynArray ::DataType & DynArray ::operator [] (long pos) const +template +const typename DynArray::DataType &DynArray::operator[](long pos) const { - assert (pos >= 0); - assert (pos < _len); + assert(pos >= 0); + assert(pos < _len); - return (_data_ptr [pos]); + return (_data_ptr[pos]); } - - -template -typename DynArray ::DataType & DynArray ::operator [] (long pos) +template +typename DynArray::DataType &DynArray::operator[](long pos) { - assert (pos >= 0); - assert (pos < _len); + assert(pos >= 0); + assert(pos < _len); - return (_data_ptr [pos]); + return (_data_ptr[pos]); } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_DynArray_CODEHEADER_INCLUDED +#endif // ffft_DynArray_CODEHEADER_INCLUDED #undef ffft_DynArray_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTReal.h b/libs/QRealFourier/fftreal/FFTReal.h index 458ca7d6..b2744c90 100644 --- a/libs/QRealFourier/fftreal/FFTReal.h +++ b/libs/QRealFourier/fftreal/FFTReal.h @@ -13,131 +13,110 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTReal_HEADER_INCLUDED) +# define ffft_FFTReal_HEADER_INCLUDED - -#if ! defined (ffft_FFTReal_HEADER_INCLUDED) -#define ffft_FFTReal_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" -#include "DynArray.h" -#include "OscSinCos.h" - - +# include "def.h" +# include "DynArray.h" +# include "OscSinCos.h" namespace ffft { - - -template +template class FFTReal { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + enum + { + MAX_BIT_DEPTH = 30 + }; // So length can be represented as long int - enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int + typedef DT DataType; - typedef DT DataType; + explicit FFTReal(long length); + virtual ~FFTReal() {} - explicit FFTReal (long length); - virtual ~FFTReal () {} + long get_length() const; + void do_fft(DataType f[], const DataType x[]) const; + void do_ifft(const DataType f[], DataType x[]) const; + void rescale(DataType x[]) const; + DataType *use_buffer() const; - long get_length () const; - void do_fft (DataType f [], const DataType x []) const; - void do_ifft (const DataType f [], DataType x []) const; - void rescale (DataType x []) const; - DataType * use_buffer () const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + // Over this bit depth, we use direct calculation for sin/cos + enum + { + TRIGO_BD_LIMIT = 12 + }; - // Over this bit depth, we use direct calculation for sin/cos - enum { TRIGO_BD_LIMIT = 12 }; + typedef OscSinCos OscType; - typedef OscSinCos OscType; + void init_br_lut(); + void init_trigo_lut(); + void init_trigo_osc(); - void init_br_lut (); - void init_trigo_lut (); - void init_trigo_osc (); + ffft_FORCEINLINE const long *get_br_ptr() const; + ffft_FORCEINLINE const DataType *get_trigo_ptr(int level) const; + ffft_FORCEINLINE long get_trigo_level_index(int level) const; - ffft_FORCEINLINE const long * - get_br_ptr () const; - ffft_FORCEINLINE const DataType * - get_trigo_ptr (int level) const; - ffft_FORCEINLINE long - get_trigo_level_index (int level) const; + inline void compute_fft_general(DataType f[], const DataType x[]) const; + inline void compute_direct_pass_1_2(DataType df[], const DataType x[]) const; + inline void compute_direct_pass_3(DataType df[], const DataType sf[]) const; + inline void compute_direct_pass_n(DataType df[], const DataType sf[], + int pass) const; + inline void compute_direct_pass_n_lut(DataType df[], const DataType sf[], + int pass) const; + inline void compute_direct_pass_n_osc(DataType df[], const DataType sf[], + int pass) const; - inline void compute_fft_general (DataType f [], const DataType x []) const; - inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const; - inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const; - inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const; - inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const; - inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const; + inline void compute_ifft_general(const DataType f[], DataType x[]) const; + inline void compute_inverse_pass_n(DataType df[], const DataType sf[], + int pass) const; + inline void compute_inverse_pass_n_osc(DataType df[], const DataType sf[], + int pass) const; + inline void compute_inverse_pass_n_lut(DataType df[], const DataType sf[], + int pass) const; + inline void compute_inverse_pass_3(DataType df[], const DataType sf[]) const; + inline void compute_inverse_pass_1_2(DataType x[], const DataType sf[]) const; - inline void compute_ifft_general (const DataType f [], DataType x []) const; - inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const; - inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const; + const long _length; + const int _nbr_bits; + DynArray _br_lut; + DynArray _trigo_lut; + mutable DynArray _buffer; + mutable DynArray _trigo_osc; - const long _length; - const int _nbr_bits; - DynArray - _br_lut; - DynArray - _trigo_lut; - mutable DynArray - _buffer; - mutable DynArray - _trigo_osc; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTReal(); + FFTReal(const FFTReal &other); + FFTReal &operator=(const FFTReal &other); + bool operator==(const FFTReal &other); + bool operator!=(const FFTReal &other); - FFTReal (); - FFTReal (const FFTReal &other); - FFTReal & operator = (const FFTReal &other); - bool operator == (const FFTReal &other); - bool operator != (const FFTReal &other); +}; // class FFTReal -}; // class FFTReal - - - -} // namespace ffft - - - -#include "FFTReal.hpp" - - - -#endif // ffft_FFTReal_HEADER_INCLUDED +} // namespace ffft +# include "FFTReal.hpp" +#endif // ffft_FFTReal_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTReal.hpp b/libs/QRealFourier/fftreal/FFTReal.hpp index 194f7255..6e004a8f 100644 --- a/libs/QRealFourier/fftreal/FFTReal.hpp +++ b/libs/QRealFourier/fftreal/FFTReal.hpp @@ -13,905 +13,832 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_FFTReal_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTReal code header. +#if defined(ffft_FFTReal_CURRENT_CODEHEADER) +# error Recursive inclusion of FFTReal code header. #endif -#define ffft_FFTReal_CURRENT_CODEHEADER - -#if ! defined (ffft_FFTReal_CODEHEADER_INCLUDED) -#define ffft_FFTReal_CODEHEADER_INCLUDED - +#define ffft_FFTReal_CURRENT_CODEHEADER +#if !defined(ffft_FFTReal_CODEHEADER_INCLUDED) +# define ffft_FFTReal_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include -#include - - +# include +# include namespace ffft { - - -static inline bool FFTReal_is_pow2 (long x) +static inline bool FFTReal_is_pow2(long x) { - assert (x > 0); + assert(x > 0); - return ((x & -x) == x); + return ((x & -x) == x); } - - -static inline int FFTReal_get_next_pow2 (long x) +static inline int FFTReal_get_next_pow2(long x) { - --x; + --x; - int p = 0; - while ((x & ~0xFFFFL) != 0) - { - p += 16; - x >>= 16; - } - while ((x & ~0xFL) != 0) - { - p += 4; - x >>= 4; - } - while (x > 0) - { - ++p; - x >>= 1; - } + int p = 0; + while ((x & ~0xFFFFL) != 0) + { + p += 16; + x >>= 16; + } + while ((x & ~0xFL) != 0) + { + p += 4; + x >>= 4; + } + while (x > 0) + { + ++p; + x >>= 1; + } - return (p); + return (p); } - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /* ============================================================================== Name: ctor Input parameters: - - length: length of the array on which we want to do a FFT. Range: power of - 2 only, > 0. -Throws: std::bad_alloc + - length: length of the array on which we want to do a FFT. Range: power +of 2 only, > 0. Throws: std::bad_alloc ============================================================================== */ -template -FFTReal
::FFTReal (long length) -: _length (length) -, _nbr_bits (FFTReal_get_next_pow2 (length)) -, _br_lut () -, _trigo_lut () -, _buffer (length) -, _trigo_osc () +template +FFTReal
::FFTReal(long length) + : _length(length) + , _nbr_bits(FFTReal_get_next_pow2(length)) + , _br_lut() + , _trigo_lut() + , _buffer(length) + , _trigo_osc() { - assert (FFTReal_is_pow2 (length)); - assert (_nbr_bits <= MAX_BIT_DEPTH); + assert(FFTReal_is_pow2(length)); + assert(_nbr_bits <= MAX_BIT_DEPTH); - init_br_lut (); - init_trigo_lut (); - init_trigo_osc (); + init_br_lut(); + init_trigo_lut(); + init_trigo_osc(); } - - /* ============================================================================== Name: get_length Description: - Returns the number of points processed by this FFT object. + Returns the number of points processed by this FFT object. Returns: The number of points, power of 2, > 0. Throws: Nothing ============================================================================== */ -template -long FFTReal
::get_length () const +template +long FFTReal
::get_length() const { - return (_length); + return (_length); } - - /* ============================================================================== Name: do_fft Description: - Compute the FFT of the array. + Compute the FFT of the array. Input parameters: - - x: pointer on the source array (time). + - x: pointer on the source array (time). Output parameters: - - f: pointer on the destination array (frequencies). - f [0...length(x)/2] = real values, - f [length(x)/2+1...length(x)-1] = negative imaginary values of - coefficents 1...length(x)/2-1. + - f: pointer on the destination array (frequencies). + f [0...length(x)/2] = real values, + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. Throws: Nothing ============================================================================== */ -template -void FFTReal
::do_fft (DataType f [], const DataType x []) const +template +void FFTReal
::do_fft(DataType f[], const DataType x[]) const { - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); + assert(f != 0); + assert(f != use_buffer()); + assert(x != 0); + assert(x != use_buffer()); + assert(x != f); - // General case - if (_nbr_bits > 2) - { - compute_fft_general (f, x); - } + // General case + if (_nbr_bits > 2) + { + compute_fft_general(f, x); + } - // 4-point FFT - else if (_nbr_bits == 2) - { - f [1] = x [0] - x [2]; - f [3] = x [1] - x [3]; + // 4-point FFT + else if (_nbr_bits == 2) + { + f[1] = x[0] - x[2]; + f[3] = x[1] - x[3]; - const DataType b_0 = x [0] + x [2]; - const DataType b_2 = x [1] + x [3]; - - f [0] = b_0 + b_2; - f [2] = b_0 - b_2; - } + const DataType b_0 = x[0] + x[2]; + const DataType b_2 = x[1] + x[3]; - // 2-point FFT - else if (_nbr_bits == 1) - { - f [0] = x [0] + x [1]; - f [1] = x [0] - x [1]; - } + f[0] = b_0 + b_2; + f[2] = b_0 - b_2; + } - // 1-point FFT - else - { - f [0] = x [0]; - } + // 2-point FFT + else if (_nbr_bits == 1) + { + f[0] = x[0] + x[1]; + f[1] = x[0] - x[1]; + } + + // 1-point FFT + else + { + f[0] = x[0]; + } } - - /* ============================================================================== Name: do_ifft Description: - Compute the inverse FFT of the array. Note that data must be post-scaled: - IFFT (FFT (x)) = x * length (x). -Input parameters: - - f: pointer on the source array (frequencies). - f [0...length(x)/2] = real values - f [length(x)/2+1...length(x)-1] = negative imaginary values of - coefficents 1...length(x)/2-1. + Compute the inverse FFT of the array. Note that data must be +post-scaled: IFFT (FFT (x)) = x * length (x). Input parameters: + - f: pointer on the source array (frequencies). + f [0...length(x)/2] = real values + f [length(x)/2+1...length(x)-1] = negative imaginary values of + coefficents 1...length(x)/2-1. Output parameters: - - x: pointer on the destination array (time). + - x: pointer on the destination array (time). Throws: Nothing ============================================================================== */ -template -void FFTReal
::do_ifft (const DataType f [], DataType x []) const +template +void FFTReal
::do_ifft(const DataType f[], DataType x[]) const { - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); + assert(f != 0); + assert(f != use_buffer()); + assert(x != 0); + assert(x != use_buffer()); + assert(x != f); - // General case - if (_nbr_bits > 2) - { - compute_ifft_general (f, x); - } + // General case + if (_nbr_bits > 2) + { + compute_ifft_general(f, x); + } - // 4-point IFFT - else if (_nbr_bits == 2) - { - const DataType b_0 = f [0] + f [2]; - const DataType b_2 = f [0] - f [2]; + // 4-point IFFT + else if (_nbr_bits == 2) + { + const DataType b_0 = f[0] + f[2]; + const DataType b_2 = f[0] - f[2]; - x [0] = b_0 + f [1] * 2; - x [2] = b_0 - f [1] * 2; - x [1] = b_2 + f [3] * 2; - x [3] = b_2 - f [3] * 2; - } + x[0] = b_0 + f[1] * 2; + x[2] = b_0 - f[1] * 2; + x[1] = b_2 + f[3] * 2; + x[3] = b_2 - f[3] * 2; + } - // 2-point IFFT - else if (_nbr_bits == 1) - { - x [0] = f [0] + f [1]; - x [1] = f [0] - f [1]; - } + // 2-point IFFT + else if (_nbr_bits == 1) + { + x[0] = f[0] + f[1]; + x[1] = f[0] - f[1]; + } - // 1-point IFFT - else - { - x [0] = f [0]; - } + // 1-point IFFT + else + { + x[0] = f[0]; + } } - - /* ============================================================================== Name: rescale Description: - Scale an array by divide each element by its length. This function should - be called after FFT + IFFT. -Input parameters: - - x: pointer on array to rescale (time or frequency). + Scale an array by divide each element by its length. This function +should be called after FFT + IFFT. Input parameters: + - x: pointer on array to rescale (time or frequency). Throws: Nothing ============================================================================== */ -template -void FFTReal
::rescale (DataType x []) const +template +void FFTReal
::rescale(DataType x[]) const { - const DataType mul = DataType (1.0 / _length); + const DataType mul = DataType(1.0 / _length); - if (_length < 4) - { - long i = _length - 1; - do - { - x [i] *= mul; - --i; - } - while (i >= 0); - } + if (_length < 4) + { + long i = _length - 1; + do + { + x[i] *= mul; + --i; + } while (i >= 0); + } - else - { - assert ((_length & 3) == 0); + else + { + assert((_length & 3) == 0); - // Could be optimized with SIMD instruction sets (needs alignment check) - long i = _length - 4; - do - { - x [i + 0] *= mul; - x [i + 1] *= mul; - x [i + 2] *= mul; - x [i + 3] *= mul; - i -= 4; - } - while (i >= 0); - } + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = _length - 4; + do + { + x[i + 0] *= mul; + x[i + 1] *= mul; + x[i + 2] *= mul; + x[i + 3] *= mul; + i -= 4; + } while (i >= 0); + } } - - /* ============================================================================== Name: use_buffer Description: - Access the internal buffer, whose length is the FFT one. - Buffer content will be erased at each do_fft() / do_ifft() call! - This buffer cannot be used as: - - source for FFT or IFFT done with this object - - destination for FFT or IFFT done with this object + Access the internal buffer, whose length is the FFT one. + Buffer content will be erased at each do_fft() / do_ifft() call! + This buffer cannot be used as: + - source for FFT or IFFT done with this object + - destination for FFT or IFFT done with this object Returns: - Buffer start address + Buffer start address Throws: Nothing ============================================================================== */ -template -typename FFTReal
::DataType * FFTReal
::use_buffer () const +template +typename FFTReal
::DataType *FFTReal
::use_buffer() const { - return (&_buffer [0]); + return (&_buffer[0]); } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -void FFTReal
::init_br_lut () +template +void FFTReal
::init_br_lut() { - const long length = 1L << _nbr_bits; - _br_lut.resize (length); + const long length = 1L << _nbr_bits; + _br_lut.resize(length); - _br_lut [0] = 0; - long br_index = 0; - for (long cnt = 1; cnt < length; ++cnt) - { - // ++br_index (bit reversed) - long bit = length >> 1; - while (((br_index ^= bit) & bit) == 0) - { - bit >>= 1; - } + _br_lut[0] = 0; + long br_index = 0; + for (long cnt = 1; cnt < length; ++cnt) + { + // ++br_index (bit reversed) + long bit = length >> 1; + while (((br_index ^= bit) & bit) == 0) + { + bit >>= 1; + } - _br_lut [cnt] = br_index; - } + _br_lut[cnt] = br_index; + } } - - -template -void FFTReal
::init_trigo_lut () +template +void FFTReal
::init_trigo_lut() { - using namespace std; + using namespace std; - if (_nbr_bits > 3) - { - const long total_len = (1L << (_nbr_bits - 1)) - 4; - _trigo_lut.resize (total_len); + if (_nbr_bits > 3) + { + const long total_len = (1L << (_nbr_bits - 1)) - 4; + _trigo_lut.resize(total_len); - for (int level = 3; level < _nbr_bits; ++level) - { - const long level_len = 1L << (level - 1); - DataType * const level_ptr = - &_trigo_lut [get_trigo_level_index (level)]; - const double mul = PI / (level_len << 1); + for (int level = 3; level < _nbr_bits; ++level) + { + const long level_len = 1L << (level - 1); + DataType *const level_ptr = &_trigo_lut[get_trigo_level_index(level)]; + const double mul = PI / (level_len << 1); - for (long i = 0; i < level_len; ++ i) - { - level_ptr [i] = static_cast (cos (i * mul)); - } - } - } + for (long i = 0; i < level_len; ++i) + { + level_ptr[i] = static_cast(cos(i * mul)); + } + } + } } - - -template -void FFTReal
::init_trigo_osc () +template +void FFTReal
::init_trigo_osc() { - const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; - if (nbr_osc > 0) - { - _trigo_osc.resize (nbr_osc); + const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; + if (nbr_osc > 0) + { + _trigo_osc.resize(nbr_osc); - for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) - { - OscType & osc = _trigo_osc [osc_cnt]; + for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) + { + OscType &osc = _trigo_osc[osc_cnt]; - const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); - const double mul = (0.5 * PI) / len; - osc.set_step (mul); - } - } + const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); + const double mul = (0.5 * PI) / len; + osc.set_step(mul); + } + } } - - -template -const long * FFTReal
::get_br_ptr () const +template +const long *FFTReal
::get_br_ptr() const { - return (&_br_lut [0]); + return (&_br_lut[0]); } - - -template -const typename FFTReal
::DataType * FFTReal
::get_trigo_ptr (int level) const +template +const typename FFTReal
::DataType * +FFTReal
::get_trigo_ptr(int level) const { - assert (level >= 3); + assert(level >= 3); - return (&_trigo_lut [get_trigo_level_index (level)]); + return (&_trigo_lut[get_trigo_level_index(level)]); } - - -template -long FFTReal
::get_trigo_level_index (int level) const +template +long FFTReal
::get_trigo_level_index(int level) const { - assert (level >= 3); + assert(level >= 3); - return ((1L << (level - 1)) - 4); + return ((1L << (level - 1)) - 4); } - - // Transform in several passes -template -void FFTReal
::compute_fft_general (DataType f [], const DataType x []) const +template +void FFTReal
::compute_fft_general(DataType f[], const DataType x[]) const { - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); + assert(f != 0); + assert(f != use_buffer()); + assert(x != 0); + assert(x != use_buffer()); + assert(x != f); - DataType * sf; - DataType * df; + DataType *sf; + DataType *df; - if ((_nbr_bits & 1) != 0) - { - df = use_buffer (); - sf = f; - } - else - { - df = f; - sf = use_buffer (); - } + if ((_nbr_bits & 1) != 0) + { + df = use_buffer(); + sf = f; + } + else + { + df = f; + sf = use_buffer(); + } - compute_direct_pass_1_2 (df, x); - compute_direct_pass_3 (sf, df); + compute_direct_pass_1_2(df, x); + compute_direct_pass_3(sf, df); - for (int pass = 3; pass < _nbr_bits; ++ pass) - { - compute_direct_pass_n (df, sf, pass); + for (int pass = 3; pass < _nbr_bits; ++pass) + { + compute_direct_pass_n(df, sf, pass); - DataType * const temp_ptr = df; - df = sf; - sf = temp_ptr; - } + DataType *const temp_ptr = df; + df = sf; + sf = temp_ptr; + } } - - -template -void FFTReal
::compute_direct_pass_1_2 (DataType df [], const DataType x []) const +template +void FFTReal
::compute_direct_pass_1_2(DataType df[], + const DataType x[]) const { - assert (df != 0); - assert (x != 0); - assert (df != x); + assert(df != 0); + assert(x != 0); + assert(df != x); - const long * const bit_rev_lut_ptr = get_br_ptr (); - long coef_index = 0; - do - { - const long rev_index_0 = bit_rev_lut_ptr [coef_index]; - const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1]; - const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2]; - const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3]; + const long *const bit_rev_lut_ptr = get_br_ptr(); + long coef_index = 0; + do + { + const long rev_index_0 = bit_rev_lut_ptr[coef_index]; + const long rev_index_1 = bit_rev_lut_ptr[coef_index + 1]; + const long rev_index_2 = bit_rev_lut_ptr[coef_index + 2]; + const long rev_index_3 = bit_rev_lut_ptr[coef_index + 3]; - DataType * const df2 = df + coef_index; - df2 [1] = x [rev_index_0] - x [rev_index_1]; - df2 [3] = x [rev_index_2] - x [rev_index_3]; + DataType *const df2 = df + coef_index; + df2[1] = x[rev_index_0] - x[rev_index_1]; + df2[3] = x[rev_index_2] - x[rev_index_3]; - const DataType sf_0 = x [rev_index_0] + x [rev_index_1]; - const DataType sf_2 = x [rev_index_2] + x [rev_index_3]; + const DataType sf_0 = x[rev_index_0] + x[rev_index_1]; + const DataType sf_2 = x[rev_index_2] + x[rev_index_3]; - df2 [0] = sf_0 + sf_2; - df2 [2] = sf_0 - sf_2; - - coef_index += 4; - } - while (coef_index < _length); + df2[0] = sf_0 + sf_2; + df2[2] = sf_0 - sf_2; + + coef_index += 4; + } while (coef_index < _length); } - - -template -void FFTReal
::compute_direct_pass_3 (DataType df [], const DataType sf []) const +template +void FFTReal
::compute_direct_pass_3(DataType df[], + const DataType sf[]) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); + assert(df != 0); + assert(sf != 0); + assert(df != sf); - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - long coef_index = 0; - do - { - DataType v; + const DataType sqrt2_2 = DataType(SQRT2 * 0.5); + long coef_index = 0; + do + { + DataType v; - df [coef_index] = sf [coef_index] + sf [coef_index + 4]; - df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; - df [coef_index + 2] = sf [coef_index + 2]; - df [coef_index + 6] = sf [coef_index + 6]; + df[coef_index] = sf[coef_index] + sf[coef_index + 4]; + df[coef_index + 4] = sf[coef_index] - sf[coef_index + 4]; + df[coef_index + 2] = sf[coef_index + 2]; + df[coef_index + 6] = sf[coef_index + 6]; - v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2; - df [coef_index + 1] = sf [coef_index + 1] + v; - df [coef_index + 3] = sf [coef_index + 1] - v; + v = (sf[coef_index + 5] - sf[coef_index + 7]) * sqrt2_2; + df[coef_index + 1] = sf[coef_index + 1] + v; + df[coef_index + 3] = sf[coef_index + 1] - v; - v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2; - df [coef_index + 5] = v + sf [coef_index + 3]; - df [coef_index + 7] = v - sf [coef_index + 3]; + v = (sf[coef_index + 5] + sf[coef_index + 7]) * sqrt2_2; + df[coef_index + 5] = v + sf[coef_index + 3]; + df[coef_index + 7] = v - sf[coef_index + 3]; - coef_index += 8; - } - while (coef_index < _length); + coef_index += 8; + } while (coef_index < _length); } - - -template -void FFTReal
::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const +template +void FFTReal
::compute_direct_pass_n(DataType df[], const DataType sf[], + int pass) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); + assert(df != 0); + assert(sf != 0); + assert(df != sf); + assert(pass >= 3); + assert(pass < _nbr_bits); - if (pass <= TRIGO_BD_LIMIT) - { - compute_direct_pass_n_lut (df, sf, pass); - } - else - { - compute_direct_pass_n_osc (df, sf, pass); - } + if (pass <= TRIGO_BD_LIMIT) + { + compute_direct_pass_n_lut(df, sf, pass); + } + else + { + compute_direct_pass_n_osc(df, sf, pass); + } } - - -template -void FFTReal
::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const +template +void FFTReal
::compute_direct_pass_n_lut(DataType df[], const DataType sf[], + int pass) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); + assert(df != 0); + assert(sf != 0); + assert(df != sf); + assert(pass >= 3); + assert(pass < _nbr_bits); - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - const DataType * const cos_ptr = get_trigo_ptr (pass); - do - { - const DataType * const sf1r = sf + coef_index; - const DataType * const sf2r = sf1r + nbr_coef; - DataType * const dfr = df + coef_index; - DataType * const dfi = dfr + nbr_coef; + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType *const cos_ptr = get_trigo_ptr(pass); + do + { + const DataType *const sf1r = sf + coef_index; + const DataType *const sf2r = sf1r + nbr_coef; + DataType *const dfr = df + coef_index; + DataType *const dfi = dfr + nbr_coef; - // Extreme coefficients are always real - dfr [0] = sf1r [0] + sf2r [0]; - dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = - dfr [h_nbr_coef] = sf1r [h_nbr_coef]; - dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + // Extreme coefficients are always real + dfr[0] = sf1r[0] + sf2r[0]; + dfi[0] = sf1r[0] - sf2r[0]; // dfr [nbr_coef] = + dfr[h_nbr_coef] = sf1r[h_nbr_coef]; + dfi[h_nbr_coef] = sf2r[h_nbr_coef]; - // Others are conjugate complex numbers - const DataType * const sf1i = sf1r + h_nbr_coef; - const DataType * const sf2i = sf1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); - const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); - DataType v; + // Others are conjugate complex numbers + const DataType *const sf1i = sf1r + h_nbr_coef; + const DataType *const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++i) + { + const DataType c = cos_ptr[i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + DataType v; - v = sf2r [i] * c - sf2i [i] * s; - dfr [i] = sf1r [i] + v; - dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + v = sf2r[i] * c - sf2i[i] * s; + dfr[i] = sf1r[i] + v; + dfi[-i] = sf1r[i] - v; // dfr [nbr_coef - i] = - v = sf2r [i] * s + sf2i [i] * c; - dfi [i] = v + sf1i [i]; - dfi [nbr_coef - i] = v - sf1i [i]; - } + v = sf2r[i] * s + sf2i[i] * c; + dfi[i] = v + sf1i[i]; + dfi[nbr_coef - i] = v - sf1i[i]; + } - coef_index += d_nbr_coef; - } - while (coef_index < _length); + coef_index += d_nbr_coef; + } while (coef_index < _length); } - - -template -void FFTReal
::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const +template +void FFTReal
::compute_direct_pass_n_osc(DataType df[], const DataType sf[], + int pass) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass > TRIGO_BD_LIMIT); - assert (pass < _nbr_bits); + assert(df != 0); + assert(sf != 0); + assert(df != sf); + assert(pass > TRIGO_BD_LIMIT); + assert(pass < _nbr_bits); - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; - do - { - const DataType * const sf1r = sf + coef_index; - const DataType * const sf2r = sf1r + nbr_coef; - DataType * const dfr = df + coef_index; - DataType * const dfi = dfr + nbr_coef; + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType &osc = _trigo_osc[pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType *const sf1r = sf + coef_index; + const DataType *const sf2r = sf1r + nbr_coef; + DataType *const dfr = df + coef_index; + DataType *const dfi = dfr + nbr_coef; - osc.clear_buffers (); + osc.clear_buffers(); - // Extreme coefficients are always real - dfr [0] = sf1r [0] + sf2r [0]; - dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = - dfr [h_nbr_coef] = sf1r [h_nbr_coef]; - dfi [h_nbr_coef] = sf2r [h_nbr_coef]; + // Extreme coefficients are always real + dfr[0] = sf1r[0] + sf2r[0]; + dfi[0] = sf1r[0] - sf2r[0]; // dfr [nbr_coef] = + dfr[h_nbr_coef] = sf1r[h_nbr_coef]; + dfi[h_nbr_coef] = sf2r[h_nbr_coef]; - // Others are conjugate complex numbers - const DataType * const sf1i = sf1r + h_nbr_coef; - const DataType * const sf2i = sf1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - osc.step (); - const DataType c = osc.get_cos (); - const DataType s = osc.get_sin (); - DataType v; + // Others are conjugate complex numbers + const DataType *const sf1i = sf1r + h_nbr_coef; + const DataType *const sf2i = sf1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++i) + { + osc.step(); + const DataType c = osc.get_cos(); + const DataType s = osc.get_sin(); + DataType v; - v = sf2r [i] * c - sf2i [i] * s; - dfr [i] = sf1r [i] + v; - dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = + v = sf2r[i] * c - sf2i[i] * s; + dfr[i] = sf1r[i] + v; + dfi[-i] = sf1r[i] - v; // dfr [nbr_coef - i] = - v = sf2r [i] * s + sf2i [i] * c; - dfi [i] = v + sf1i [i]; - dfi [nbr_coef - i] = v - sf1i [i]; - } + v = sf2r[i] * s + sf2i[i] * c; + dfi[i] = v + sf1i[i]; + dfi[nbr_coef - i] = v - sf1i[i]; + } - coef_index += d_nbr_coef; - } - while (coef_index < _length); + coef_index += d_nbr_coef; + } while (coef_index < _length); } - - // Transform in several pass -template -void FFTReal
::compute_ifft_general (const DataType f [], DataType x []) const +template +void FFTReal
::compute_ifft_general(const DataType f[], DataType x[]) const { - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); + assert(f != 0); + assert(f != use_buffer()); + assert(x != 0); + assert(x != use_buffer()); + assert(x != f); - DataType * sf = const_cast (f); - DataType * df; - DataType * df_temp; + DataType *sf = const_cast(f); + DataType *df; + DataType *df_temp; - if (_nbr_bits & 1) - { - df = use_buffer (); - df_temp = x; - } - else - { - df = x; - df_temp = use_buffer (); - } + if (_nbr_bits & 1) + { + df = use_buffer(); + df_temp = x; + } + else + { + df = x; + df_temp = use_buffer(); + } - for (int pass = _nbr_bits - 1; pass >= 3; -- pass) - { - compute_inverse_pass_n (df, sf, pass); + for (int pass = _nbr_bits - 1; pass >= 3; --pass) + { + compute_inverse_pass_n(df, sf, pass); - if (pass < _nbr_bits - 1) - { - DataType * const temp_ptr = df; - df = sf; - sf = temp_ptr; - } - else - { - sf = df; - df = df_temp; - } - } + if (pass < _nbr_bits - 1) + { + DataType *const temp_ptr = df; + df = sf; + sf = temp_ptr; + } + else + { + sf = df; + df = df_temp; + } + } - compute_inverse_pass_3 (df, sf); - compute_inverse_pass_1_2 (x, df); + compute_inverse_pass_3(df, sf); + compute_inverse_pass_1_2(x, df); } - - -template -void FFTReal
::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const +template +void FFTReal
::compute_inverse_pass_n(DataType df[], const DataType sf[], + int pass) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); + assert(df != 0); + assert(sf != 0); + assert(df != sf); + assert(pass >= 3); + assert(pass < _nbr_bits); - if (pass <= TRIGO_BD_LIMIT) - { - compute_inverse_pass_n_lut (df, sf, pass); - } - else - { - compute_inverse_pass_n_osc (df, sf, pass); - } + if (pass <= TRIGO_BD_LIMIT) + { + compute_inverse_pass_n_lut(df, sf, pass); + } + else + { + compute_inverse_pass_n_osc(df, sf, pass); + } } - - -template -void FFTReal
::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const +template +void FFTReal
::compute_inverse_pass_n_lut(DataType df[], const DataType sf[], + int pass) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); + assert(df != 0); + assert(sf != 0); + assert(df != sf); + assert(pass >= 3); + assert(pass < _nbr_bits); - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - const DataType * const cos_ptr = get_trigo_ptr (pass); - do - { - const DataType * const sfr = sf + coef_index; - const DataType * const sfi = sfr + nbr_coef; - DataType * const df1r = df + coef_index; - DataType * const df2r = df1r + nbr_coef; + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + const DataType *const cos_ptr = get_trigo_ptr(pass); + do + { + const DataType *const sfr = sf + coef_index; + const DataType *const sfi = sfr + nbr_coef; + DataType *const df1r = df + coef_index; + DataType *const df2r = df1r + nbr_coef; - // Extreme coefficients are always real - df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] - df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] - df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; - df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + // Extreme coefficients are always real + df1r[0] = sfr[0] + sfi[0]; // + sfr [nbr_coef] + df2r[0] = sfr[0] - sfi[0]; // - sfr [nbr_coef] + df1r[h_nbr_coef] = sfr[h_nbr_coef] * 2; + df2r[h_nbr_coef] = sfi[h_nbr_coef] * 2; - // Others are conjugate complex numbers - DataType * const df1i = df1r + h_nbr_coef; - DataType * const df2i = df1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] - df1i [i] = sfi [i] - sfi [nbr_coef - i]; + // Others are conjugate complex numbers + DataType *const df1i = df1r + h_nbr_coef; + DataType *const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++i) + { + df1r[i] = sfr[i] + sfi[-i]; // + sfr [nbr_coef - i] + df1i[i] = sfi[i] - sfi[nbr_coef - i]; - const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); - const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); - const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] - const DataType vi = sfi [i] + sfi [nbr_coef - i]; + const DataType c = cos_ptr[i]; // cos (i*PI/nbr_coef); + const DataType s = cos_ptr[h_nbr_coef - i]; // sin (i*PI/nbr_coef); + const DataType vr = sfr[i] - sfi[-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi[i] + sfi[nbr_coef - i]; - df2r [i] = vr * c + vi * s; - df2i [i] = vi * c - vr * s; - } + df2r[i] = vr * c + vi * s; + df2i[i] = vi * c - vr * s; + } - coef_index += d_nbr_coef; - } - while (coef_index < _length); + coef_index += d_nbr_coef; + } while (coef_index < _length); } - - -template -void FFTReal
::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const +template +void FFTReal
::compute_inverse_pass_n_osc(DataType df[], const DataType sf[], + int pass) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass > TRIGO_BD_LIMIT); - assert (pass < _nbr_bits); + assert(df != 0); + assert(sf != 0); + assert(df != sf); + assert(pass > TRIGO_BD_LIMIT); + assert(pass < _nbr_bits); - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; - do - { - const DataType * const sfr = sf + coef_index; - const DataType * const sfi = sfr + nbr_coef; - DataType * const df1r = df + coef_index; - DataType * const df2r = df1r + nbr_coef; + const long nbr_coef = 1 << pass; + const long h_nbr_coef = nbr_coef >> 1; + const long d_nbr_coef = nbr_coef << 1; + long coef_index = 0; + OscType &osc = _trigo_osc[pass - (TRIGO_BD_LIMIT + 1)]; + do + { + const DataType *const sfr = sf + coef_index; + const DataType *const sfi = sfr + nbr_coef; + DataType *const df1r = df + coef_index; + DataType *const df2r = df1r + nbr_coef; - osc.clear_buffers (); + osc.clear_buffers(); - // Extreme coefficients are always real - df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] - df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] - df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; - df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; + // Extreme coefficients are always real + df1r[0] = sfr[0] + sfi[0]; // + sfr [nbr_coef] + df2r[0] = sfr[0] - sfi[0]; // - sfr [nbr_coef] + df1r[h_nbr_coef] = sfr[h_nbr_coef] * 2; + df2r[h_nbr_coef] = sfi[h_nbr_coef] * 2; - // Others are conjugate complex numbers - DataType * const df1i = df1r + h_nbr_coef; - DataType * const df2i = df1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] - df1i [i] = sfi [i] - sfi [nbr_coef - i]; + // Others are conjugate complex numbers + DataType *const df1i = df1r + h_nbr_coef; + DataType *const df2i = df1i + nbr_coef; + for (long i = 1; i < h_nbr_coef; ++i) + { + df1r[i] = sfr[i] + sfi[-i]; // + sfr [nbr_coef - i] + df1i[i] = sfi[i] - sfi[nbr_coef - i]; - osc.step (); - const DataType c = osc.get_cos (); - const DataType s = osc.get_sin (); - const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] - const DataType vi = sfi [i] + sfi [nbr_coef - i]; + osc.step(); + const DataType c = osc.get_cos(); + const DataType s = osc.get_sin(); + const DataType vr = sfr[i] - sfi[-i]; // - sfr [nbr_coef - i] + const DataType vi = sfi[i] + sfi[nbr_coef - i]; - df2r [i] = vr * c + vi * s; - df2i [i] = vi * c - vr * s; - } + df2r[i] = vr * c + vi * s; + df2i[i] = vi * c - vr * s; + } - coef_index += d_nbr_coef; - } - while (coef_index < _length); + coef_index += d_nbr_coef; + } while (coef_index < _length); } - - -template -void FFTReal
::compute_inverse_pass_3 (DataType df [], const DataType sf []) const +template +void FFTReal
::compute_inverse_pass_3(DataType df[], + const DataType sf[]) const { - assert (df != 0); - assert (sf != 0); - assert (df != sf); + assert(df != 0); + assert(sf != 0); + assert(df != sf); - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - long coef_index = 0; - do - { - df [coef_index] = sf [coef_index] + sf [coef_index + 4]; - df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; - df [coef_index + 2] = sf [coef_index + 2] * 2; - df [coef_index + 6] = sf [coef_index + 6] * 2; + const DataType sqrt2_2 = DataType(SQRT2 * 0.5); + long coef_index = 0; + do + { + df[coef_index] = sf[coef_index] + sf[coef_index + 4]; + df[coef_index + 4] = sf[coef_index] - sf[coef_index + 4]; + df[coef_index + 2] = sf[coef_index + 2] * 2; + df[coef_index + 6] = sf[coef_index + 6] * 2; - df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3]; - df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7]; + df[coef_index + 1] = sf[coef_index + 1] + sf[coef_index + 3]; + df[coef_index + 3] = sf[coef_index + 5] - sf[coef_index + 7]; - const DataType vr = sf [coef_index + 1] - sf [coef_index + 3]; - const DataType vi = sf [coef_index + 5] + sf [coef_index + 7]; + const DataType vr = sf[coef_index + 1] - sf[coef_index + 3]; + const DataType vi = sf[coef_index + 5] + sf[coef_index + 7]; - df [coef_index + 5] = (vr + vi) * sqrt2_2; - df [coef_index + 7] = (vi - vr) * sqrt2_2; + df[coef_index + 5] = (vr + vi) * sqrt2_2; + df[coef_index + 7] = (vi - vr) * sqrt2_2; - coef_index += 8; - } - while (coef_index < _length); + coef_index += 8; + } while (coef_index < _length); } - - -template -void FFTReal
::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const +template +void FFTReal
::compute_inverse_pass_1_2(DataType x[], + const DataType sf[]) const { - assert (x != 0); - assert (sf != 0); - assert (x != sf); + assert(x != 0); + assert(sf != 0); + assert(x != sf); - const long * bit_rev_lut_ptr = get_br_ptr (); - const DataType * sf2 = sf; - long coef_index = 0; - do - { - { - const DataType b_0 = sf2 [0] + sf2 [2]; - const DataType b_2 = sf2 [0] - sf2 [2]; - const DataType b_1 = sf2 [1] * 2; - const DataType b_3 = sf2 [3] * 2; + const long *bit_rev_lut_ptr = get_br_ptr(); + const DataType *sf2 = sf; + long coef_index = 0; + do + { + { + const DataType b_0 = sf2[0] + sf2[2]; + const DataType b_2 = sf2[0] - sf2[2]; + const DataType b_1 = sf2[1] * 2; + const DataType b_3 = sf2[3] * 2; - x [bit_rev_lut_ptr [0]] = b_0 + b_1; - x [bit_rev_lut_ptr [1]] = b_0 - b_1; - x [bit_rev_lut_ptr [2]] = b_2 + b_3; - x [bit_rev_lut_ptr [3]] = b_2 - b_3; - } - { - const DataType b_0 = sf2 [4] + sf2 [6]; - const DataType b_2 = sf2 [4] - sf2 [6]; - const DataType b_1 = sf2 [5] * 2; - const DataType b_3 = sf2 [7] * 2; + x[bit_rev_lut_ptr[0]] = b_0 + b_1; + x[bit_rev_lut_ptr[1]] = b_0 - b_1; + x[bit_rev_lut_ptr[2]] = b_2 + b_3; + x[bit_rev_lut_ptr[3]] = b_2 - b_3; + } + { + const DataType b_0 = sf2[4] + sf2[6]; + const DataType b_2 = sf2[4] - sf2[6]; + const DataType b_1 = sf2[5] * 2; + const DataType b_3 = sf2[7] * 2; - x [bit_rev_lut_ptr [4]] = b_0 + b_1; - x [bit_rev_lut_ptr [5]] = b_0 - b_1; - x [bit_rev_lut_ptr [6]] = b_2 + b_3; - x [bit_rev_lut_ptr [7]] = b_2 - b_3; - } + x[bit_rev_lut_ptr[4]] = b_0 + b_1; + x[bit_rev_lut_ptr[5]] = b_0 - b_1; + x[bit_rev_lut_ptr[6]] = b_2 + b_3; + x[bit_rev_lut_ptr[7]] = b_2 - b_3; + } - sf2 += 8; - coef_index += 8; - bit_rev_lut_ptr += 8; - } - while (coef_index < _length); + sf2 += 8; + coef_index += 8; + bit_rev_lut_ptr += 8; + } while (coef_index < _length); } +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_FFTReal_CODEHEADER_INCLUDED +#endif // ffft_FFTReal_CODEHEADER_INCLUDED #undef ffft_FFTReal_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealFixLen.h b/libs/QRealFourier/fftreal/FFTRealFixLen.h index cf2e13aa..c9d062d7 100644 --- a/libs/QRealFourier/fftreal/FFTRealFixLen.h +++ b/libs/QRealFourier/fftreal/FFTRealFixLen.h @@ -13,119 +13,118 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTRealFixLen_HEADER_INCLUDED) +# define ffft_FFTRealFixLen_HEADER_INCLUDED - -#if ! defined (ffft_FFTRealFixLen_HEADER_INCLUDED) -#define ffft_FFTRealFixLen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "Array.h" -#include "DynArray.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - +# include "Array.h" +# include "DynArray.h" +# include "FFTRealFixLenParam.h" +# include "OscSinCos.h" namespace ffft { - - -template +template class FFTRealFixLen { - typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; - typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; + typedef int CompileTimeCheck1[(LL2 >= 0) ? 1 : -1]; + typedef int CompileTimeCheck2[(LL2 <= 30) ? 1 : -1]; -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; + enum + { + FFT_LEN_L2 = LL2 + }; + enum + { + FFT_LEN = 1 << FFT_LEN_L2 + }; - enum { FFT_LEN_L2 = LL2 }; - enum { FFT_LEN = 1 << FFT_LEN_L2 }; + FFTRealFixLen(); - FFTRealFixLen (); + inline long get_length() const; + void do_fft(DataType f[], const DataType x[]); + void do_ifft(const DataType f[], DataType x[]); + void rescale(DataType x[]) const; - inline long get_length () const; - void do_fft (DataType f [], const DataType x []); - void do_ifft (const DataType f [], DataType x []); - void rescale (DataType x []) const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + enum + { + TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT + }; - enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; + enum + { + BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) + }; + enum + { + BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 + }; - enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; - enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; + enum + { + TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) ? (int)FFT_LEN_L2 + : (int)TRIGO_BD_LIMIT + }; + enum + { + TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) + }; + enum + { + TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 + }; - enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) - ? (int)FFT_LEN_L2 - : (int)TRIGO_BD_LIMIT }; - enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; - enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; + enum + { + NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD + }; + enum + { + TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 + }; - enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; - enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; + void build_br_lut(); + void build_trigo_lut(); + void build_trigo_osc(); - void build_br_lut (); - void build_trigo_lut (); - void build_trigo_osc (); + DynArray _buffer; + DynArray _br_data; + DynArray _trigo_data; + Array _trigo_osc; - DynArray - _buffer; - DynArray - _br_data; - DynArray - _trigo_data; - Array - _trigo_osc; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTRealFixLen(const FFTRealFixLen &other); + FFTRealFixLen &operator=(const FFTRealFixLen &other); + bool operator==(const FFTRealFixLen &other); + bool operator!=(const FFTRealFixLen &other); - FFTRealFixLen (const FFTRealFixLen &other); - FFTRealFixLen& operator = (const FFTRealFixLen &other); - bool operator == (const FFTRealFixLen &other); - bool operator != (const FFTRealFixLen &other); +}; // class FFTRealFixLen -}; // class FFTRealFixLen - - - -} // namespace ffft - - - -#include "FFTRealFixLen.hpp" - - - -#endif // ffft_FFTRealFixLen_HEADER_INCLUDED +} // namespace ffft +# include "FFTRealFixLen.hpp" +#endif // ffft_FFTRealFixLen_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealFixLen.hpp b/libs/QRealFourier/fftreal/FFTRealFixLen.hpp index f1521b42..1e3c94b1 100644 --- a/libs/QRealFourier/fftreal/FFTRealFixLen.hpp +++ b/libs/QRealFourier/fftreal/FFTRealFixLen.hpp @@ -13,311 +13,259 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_FFTRealFixLen_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealFixLen code header. +#if defined(ffft_FFTRealFixLen_CURRENT_CODEHEADER) +# error Recursive inclusion of FFTRealFixLen code header. #endif -#define ffft_FFTRealFixLen_CURRENT_CODEHEADER - -#if ! defined (ffft_FFTRealFixLen_CODEHEADER_INCLUDED) -#define ffft_FFTRealFixLen_CODEHEADER_INCLUDED - +#define ffft_FFTRealFixLen_CURRENT_CODEHEADER +#if !defined(ffft_FFTRealFixLen_CODEHEADER_INCLUDED) +# define ffft_FFTRealFixLen_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" -#include "FFTRealPassDirect.h" -#include "FFTRealPassInverse.h" -#include "FFTRealSelect.h" - -#include -#include - -namespace std { } +# include "def.h" +# include "FFTRealPassDirect.h" +# include "FFTRealPassInverse.h" +# include "FFTRealSelect.h" +# include +# include +namespace std +{ +} namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -FFTRealFixLen ::FFTRealFixLen () -: _buffer (FFT_LEN) -, _br_data (BR_ARR_SIZE) -, _trigo_data (TRIGO_TABLE_ARR_SIZE) -, _trigo_osc () +template +FFTRealFixLen::FFTRealFixLen() + : _buffer(FFT_LEN) + , _br_data(BR_ARR_SIZE) + , _trigo_data(TRIGO_TABLE_ARR_SIZE) + , _trigo_osc() { - build_br_lut (); - build_trigo_lut (); - build_trigo_osc (); + build_br_lut(); + build_trigo_lut(); + build_trigo_osc(); } - - -template -long FFTRealFixLen ::get_length () const +template +long FFTRealFixLen::get_length() const { - return (FFT_LEN); + return (FFT_LEN); } - - // General case -template -void FFTRealFixLen ::do_fft (DataType f [], const DataType x []) +template +void FFTRealFixLen::do_fft(DataType f[], const DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); - assert (FFT_LEN_L2 >= 3); + assert(f != 0); + assert(x != 0); + assert(x != f); + assert(FFT_LEN_L2 >= 3); - // Do the transform in several passes - const DataType * cos_ptr = &_trigo_data [0]; - const long * br_ptr = &_br_data [0]; + // Do the transform in several passes + const DataType *cos_ptr = &_trigo_data[0]; + const long *br_ptr = &_br_data[0]; - FFTRealPassDirect ::process ( - FFT_LEN, - f, - &_buffer [0], - x, - cos_ptr, - TRIGO_TABLE_ARR_SIZE, - br_ptr, - &_trigo_osc [0] - ); + FFTRealPassDirect::process(FFT_LEN, f, &_buffer[0], x, + cos_ptr, TRIGO_TABLE_ARR_SIZE, + br_ptr, &_trigo_osc[0]); } // 4-point FFT -template <> -inline void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x []) +template<> +inline void FFTRealFixLen<2>::do_fft(DataType f[], const DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); + assert(f != 0); + assert(x != 0); + assert(x != f); - f [1] = x [0] - x [2]; - f [3] = x [1] - x [3]; + f[1] = x[0] - x[2]; + f[3] = x[1] - x[3]; - const DataType b_0 = x [0] + x [2]; - const DataType b_2 = x [1] + x [3]; - - f [0] = b_0 + b_2; - f [2] = b_0 - b_2; + const DataType b_0 = x[0] + x[2]; + const DataType b_2 = x[1] + x[3]; + + f[0] = b_0 + b_2; + f[2] = b_0 - b_2; } // 2-point FFT -template <> -inline void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x []) +template<> +inline void FFTRealFixLen<1>::do_fft(DataType f[], const DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); + assert(f != 0); + assert(x != 0); + assert(x != f); - f [0] = x [0] + x [1]; - f [1] = x [0] - x [1]; + f[0] = x[0] + x[1]; + f[1] = x[0] - x[1]; } // 1-point FFT -template <> -inline void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x []) +template<> +inline void FFTRealFixLen<0>::do_fft(DataType f[], const DataType x[]) { - assert (f != 0); - assert (x != 0); + assert(f != 0); + assert(x != 0); - f [0] = x [0]; + f[0] = x[0]; } - - // General case -template -void FFTRealFixLen ::do_ifft (const DataType f [], DataType x []) +template +void FFTRealFixLen::do_ifft(const DataType f[], DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); - assert (FFT_LEN_L2 >= 3); + assert(f != 0); + assert(x != 0); + assert(x != f); + assert(FFT_LEN_L2 >= 3); - // Do the transform in several passes - DataType * s_ptr = - FFTRealSelect ::sel_bin (&_buffer [0], x); - DataType * d_ptr = - FFTRealSelect ::sel_bin (x, &_buffer [0]); - const DataType * cos_ptr = &_trigo_data [0]; - const long * br_ptr = &_br_data [0]; + // Do the transform in several passes + DataType *s_ptr = FFTRealSelect::sel_bin(&_buffer[0], x); + DataType *d_ptr = FFTRealSelect::sel_bin(x, &_buffer[0]); + const DataType *cos_ptr = &_trigo_data[0]; + const long *br_ptr = &_br_data[0]; - FFTRealPassInverse ::process ( - FFT_LEN, - d_ptr, - s_ptr, - f, - cos_ptr, - TRIGO_TABLE_ARR_SIZE, - br_ptr, - &_trigo_osc [0] - ); + FFTRealPassInverse::process(FFT_LEN, d_ptr, s_ptr, f, cos_ptr, + TRIGO_TABLE_ARR_SIZE, br_ptr, + &_trigo_osc[0]); } // 4-point IFFT -template <> -inline void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x []) +template<> +inline void FFTRealFixLen<2>::do_ifft(const DataType f[], DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); + assert(f != 0); + assert(x != 0); + assert(x != f); - const DataType b_0 = f [0] + f [2]; - const DataType b_2 = f [0] - f [2]; + const DataType b_0 = f[0] + f[2]; + const DataType b_2 = f[0] - f[2]; - x [0] = b_0 + f [1] * 2; - x [2] = b_0 - f [1] * 2; - x [1] = b_2 + f [3] * 2; - x [3] = b_2 - f [3] * 2; + x[0] = b_0 + f[1] * 2; + x[2] = b_0 - f[1] * 2; + x[1] = b_2 + f[3] * 2; + x[3] = b_2 - f[3] * 2; } // 2-point IFFT -template <> -inline void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x []) +template<> +inline void FFTRealFixLen<1>::do_ifft(const DataType f[], DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); + assert(f != 0); + assert(x != 0); + assert(x != f); - x [0] = f [0] + f [1]; - x [1] = f [0] - f [1]; + x[0] = f[0] + f[1]; + x[1] = f[0] - f[1]; } // 1-point IFFT -template <> -inline void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x []) +template<> +inline void FFTRealFixLen<0>::do_ifft(const DataType f[], DataType x[]) { - assert (f != 0); - assert (x != 0); - assert (x != f); + assert(f != 0); + assert(x != 0); + assert(x != f); - x [0] = f [0]; + x[0] = f[0]; } - - - -template -void FFTRealFixLen ::rescale (DataType x []) const +template +void FFTRealFixLen::rescale(DataType x[]) const { - assert (x != 0); + assert(x != 0); - const DataType mul = DataType (1.0 / FFT_LEN); + const DataType mul = DataType(1.0 / FFT_LEN); - if (FFT_LEN < 4) - { - long i = FFT_LEN - 1; - do - { - x [i] *= mul; - --i; - } - while (i >= 0); - } + if (FFT_LEN < 4) + { + long i = FFT_LEN - 1; + do + { + x[i] *= mul; + --i; + } while (i >= 0); + } - else - { - assert ((FFT_LEN & 3) == 0); + else + { + assert((FFT_LEN & 3) == 0); - // Could be optimized with SIMD instruction sets (needs alignment check) - long i = FFT_LEN - 4; - do - { - x [i + 0] *= mul; - x [i + 1] *= mul; - x [i + 2] *= mul; - x [i + 3] *= mul; - i -= 4; - } - while (i >= 0); - } + // Could be optimized with SIMD instruction sets (needs alignment check) + long i = FFT_LEN - 4; + do + { + x[i + 0] *= mul; + x[i + 1] *= mul; + x[i + 2] *= mul; + x[i + 3] *= mul; + i -= 4; + } while (i >= 0); + } } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -void FFTRealFixLen ::build_br_lut () +template +void FFTRealFixLen::build_br_lut() { - _br_data [0] = 0; - for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) - { - long index = cnt << 2; - long br_index = 0; + _br_data[0] = 0; + for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) + { + long index = cnt << 2; + long br_index = 0; - int bit_cnt = FFT_LEN_L2; - do - { - br_index <<= 1; - br_index += (index & 1); - index >>= 1; + int bit_cnt = FFT_LEN_L2; + do + { + br_index <<= 1; + br_index += (index & 1); + index >>= 1; - -- bit_cnt; - } - while (bit_cnt > 0); + --bit_cnt; + } while (bit_cnt > 0); - _br_data [cnt] = br_index; - } + _br_data[cnt] = br_index; + } } - - -template -void FFTRealFixLen ::build_trigo_lut () +template +void FFTRealFixLen::build_trigo_lut() { - const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; - for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i) - { - using namespace std; + const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; + for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++i) + { + using namespace std; - _trigo_data [i] = DataType (cos (i * mul)); - } + _trigo_data[i] = DataType(cos(i * mul)); + } } - - -template -void FFTRealFixLen ::build_trigo_osc () +template +void FFTRealFixLen::build_trigo_osc() { - for (int i = 0; i < NBR_TRIGO_OSC; ++i) - { - OscType & osc = _trigo_osc [i]; + for (int i = 0; i < NBR_TRIGO_OSC; ++i) + { + OscType &osc = _trigo_osc[i]; - const long len = static_cast (TRIGO_TABLE_ARR_SIZE) << (i + 1); - const double mul = (0.5 * PI) / len; - osc.set_step (mul); - } + const long len = static_cast(TRIGO_TABLE_ARR_SIZE) << (i + 1); + const double mul = (0.5 * PI) / len; + osc.set_step(mul); + } } +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_FFTRealFixLen_CODEHEADER_INCLUDED +#endif // ffft_FFTRealFixLen_CODEHEADER_INCLUDED #undef ffft_FFTRealFixLen_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealFixLenParam.h b/libs/QRealFourier/fftreal/FFTRealFixLenParam.h index bd0c41b0..76f70216 100644 --- a/libs/QRealFourier/fftreal/FFTRealFixLenParam.h +++ b/libs/QRealFourier/fftreal/FFTRealFixLenParam.h @@ -13,78 +13,54 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTRealFixLenParam_HEADER_INCLUDED) +# define ffft_FFTRealFixLenParam_HEADER_INCLUDED - -#if ! defined (ffft_FFTRealFixLenParam_HEADER_INCLUDED) -#define ffft_FFTRealFixLenParam_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - namespace ffft { - - class FFTRealFixLenParam { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + // Over this bit depth, we use direct calculation for sin/cos + enum + { + TRIGO_BD_LIMIT = 12 + }; - // Over this bit depth, we use direct calculation for sin/cos - enum { TRIGO_BD_LIMIT = 12 }; + typedef float DataType; - typedef float DataType; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTRealFixLenParam(); + FFTRealFixLenParam(const FFTRealFixLenParam &other); + FFTRealFixLenParam &operator=(const FFTRealFixLenParam &other); + bool operator==(const FFTRealFixLenParam &other); + bool operator!=(const FFTRealFixLenParam &other); - FFTRealFixLenParam (); - FFTRealFixLenParam (const FFTRealFixLenParam &other); - FFTRealFixLenParam & - operator = (const FFTRealFixLenParam &other); - bool operator == (const FFTRealFixLenParam &other); - bool operator != (const FFTRealFixLenParam &other); +}; // class FFTRealFixLenParam -}; // class FFTRealFixLenParam - - - -} // namespace ffft - - - -//#include "FFTRealFixLenParam.hpp" - - - -#endif // ffft_FFTRealFixLenParam_HEADER_INCLUDED +} // namespace ffft +// #include "FFTRealFixLenParam.hpp" +#endif // ffft_FFTRealFixLenParam_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealPassDirect.h b/libs/QRealFourier/fftreal/FFTRealPassDirect.h index bf126162..78732c95 100644 --- a/libs/QRealFourier/fftreal/FFTRealPassDirect.h +++ b/libs/QRealFourier/fftreal/FFTRealPassDirect.h @@ -13,84 +13,60 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTRealPassDirect_HEADER_INCLUDED) +# define ffft_FFTRealPassDirect_HEADER_INCLUDED - -#if ! defined (ffft_FFTRealPassDirect_HEADER_INCLUDED) -#define ffft_FFTRealPassDirect_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - +# include "def.h" +# include "FFTRealFixLenParam.h" +# include "OscSinCos.h" namespace ffft { - - -template +template class FFTRealPassDirect { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; + ffft_FORCEINLINE static void process(long len, DataType dest_ptr[], + DataType src_ptr[], + const DataType x_ptr[], + const DataType cos_ptr[], long cos_len, + const long br_ptr[], OscType osc_list[]); - ffft_FORCEINLINE static void - process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTRealPassDirect(); + FFTRealPassDirect(const FFTRealPassDirect &other); + FFTRealPassDirect &operator=(const FFTRealPassDirect &other); + bool operator==(const FFTRealPassDirect &other); + bool operator!=(const FFTRealPassDirect &other); - FFTRealPassDirect (); - FFTRealPassDirect (const FFTRealPassDirect &other); - FFTRealPassDirect & - operator = (const FFTRealPassDirect &other); - bool operator == (const FFTRealPassDirect &other); - bool operator != (const FFTRealPassDirect &other); +}; // class FFTRealPassDirect -}; // class FFTRealPassDirect - - - -} // namespace ffft - - - -#include "FFTRealPassDirect.hpp" - - - -#endif // ffft_FFTRealPassDirect_HEADER_INCLUDED +} // namespace ffft +# include "FFTRealPassDirect.hpp" +#endif // ffft_FFTRealPassDirect_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealPassDirect.hpp b/libs/QRealFourier/fftreal/FFTRealPassDirect.hpp index 70d5d1b4..96585726 100644 --- a/libs/QRealFourier/fftreal/FFTRealPassDirect.hpp +++ b/libs/QRealFourier/fftreal/FFTRealPassDirect.hpp @@ -13,197 +13,171 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_FFTRealPassDirect_CURRENT_CODEHEADER) -#error Recursive inclusion of FFTRealPassDirect code header. +#if defined(ffft_FFTRealPassDirect_CURRENT_CODEHEADER) +# error Recursive inclusion of FFTRealPassDirect code header. #endif -#define ffft_FFTRealPassDirect_CURRENT_CODEHEADER - -#if ! defined (ffft_FFTRealPassDirect_CODEHEADER_INCLUDED) -#define ffft_FFTRealPassDirect_CODEHEADER_INCLUDED - +#define ffft_FFTRealPassDirect_CURRENT_CODEHEADER +#if !defined(ffft_FFTRealPassDirect_CODEHEADER_INCLUDED) +# define ffft_FFTRealPassDirect_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "FFTRealUseTrigo.h" - - +# include "FFTRealUseTrigo.h" namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template <> -inline void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template<> +inline void +FFTRealPassDirect<1>::process(long len, DataType dest_ptr[], DataType src_ptr[], + const DataType x_ptr[], const DataType cos_ptr[], + long cos_len, const long br_ptr[], + OscType osc_list[]) { - (void) src_ptr; - (void) cos_len; - (void) cos_ptr; - (void) osc_list; - // First and second pass at once - const long qlen = len >> 2; + (void)src_ptr; + (void)cos_len; + (void)cos_ptr; + (void)osc_list; + // First and second pass at once + const long qlen = len >> 2; - long coef_index = 0; - do - { - // To do: unroll the loop (2x). - const long ri_0 = br_ptr [coef_index >> 2]; - const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; - const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; - const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; + long coef_index = 0; + do + { + // To do: unroll the loop (2x). + const long ri_0 = br_ptr[coef_index >> 2]; + const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; + const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; + const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; - DataType * const df2 = dest_ptr + coef_index; - df2 [1] = x_ptr [ri_0] - x_ptr [ri_1]; - df2 [3] = x_ptr [ri_2] - x_ptr [ri_3]; + DataType *const df2 = dest_ptr + coef_index; + df2[1] = x_ptr[ri_0] - x_ptr[ri_1]; + df2[3] = x_ptr[ri_2] - x_ptr[ri_3]; - const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1]; - const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3]; + const DataType sf_0 = x_ptr[ri_0] + x_ptr[ri_1]; + const DataType sf_2 = x_ptr[ri_2] + x_ptr[ri_3]; - df2 [0] = sf_0 + sf_2; - df2 [2] = sf_0 - sf_2; + df2[0] = sf_0 + sf_2; + df2[2] = sf_0 - sf_2; - coef_index += 4; - } - while (coef_index < len); + coef_index += 4; + } while (coef_index < len); } -template <> -inline void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template<> +inline void +FFTRealPassDirect<2>::process(long len, DataType dest_ptr[], DataType src_ptr[], + const DataType x_ptr[], const DataType cos_ptr[], + long cos_len, const long br_ptr[], + OscType osc_list[]) { - // Executes "previous" passes first. Inverts source and destination buffers - FFTRealPassDirect <1>::process ( - len, - src_ptr, - dest_ptr, - x_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect<1>::process(len, src_ptr, dest_ptr, x_ptr, cos_ptr, cos_len, + br_ptr, osc_list); - // Third pass - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + // Third pass + const DataType sqrt2_2 = DataType(SQRT2 * 0.5); - long coef_index = 0; - do - { - dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; - dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; - dest_ptr [coef_index + 2] = src_ptr [coef_index + 2]; - dest_ptr [coef_index + 6] = src_ptr [coef_index + 6]; + long coef_index = 0; + do + { + dest_ptr[coef_index] = src_ptr[coef_index] + src_ptr[coef_index + 4]; + dest_ptr[coef_index + 4] = src_ptr[coef_index] - src_ptr[coef_index + 4]; + dest_ptr[coef_index + 2] = src_ptr[coef_index + 2]; + dest_ptr[coef_index + 6] = src_ptr[coef_index + 6]; - DataType v; + DataType v; - v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2; - dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v; - dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v; + v = (src_ptr[coef_index + 5] - src_ptr[coef_index + 7]) * sqrt2_2; + dest_ptr[coef_index + 1] = src_ptr[coef_index + 1] + v; + dest_ptr[coef_index + 3] = src_ptr[coef_index + 1] - v; - v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2; - dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3]; - dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3]; + v = (src_ptr[coef_index + 5] + src_ptr[coef_index + 7]) * sqrt2_2; + dest_ptr[coef_index + 5] = v + src_ptr[coef_index + 3]; + dest_ptr[coef_index + 7] = v - src_ptr[coef_index + 3]; - coef_index += 8; - } - while (coef_index < len); + coef_index += 8; + } while (coef_index < len); } -template -void FFTRealPassDirect ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template +void FFTRealPassDirect::process(long len, DataType dest_ptr[], + DataType src_ptr[], + const DataType x_ptr[], + const DataType cos_ptr[], long cos_len, + const long br_ptr[], OscType osc_list[]) { - // Executes "previous" passes first. Inverts source and destination buffers - FFTRealPassDirect ::process ( - len, - src_ptr, - dest_ptr, - x_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); + // Executes "previous" passes first. Inverts source and destination buffers + FFTRealPassDirect::process(len, src_ptr, dest_ptr, x_ptr, cos_ptr, + cos_len, br_ptr, osc_list); - const long dist = 1L << (PASS - 1); - const long c1_r = 0; - const long c1_i = dist; - const long c2_r = dist * 2; - const long c2_i = dist * 3; - const long cend = dist * 4; - const long table_step = cos_len >> (PASS - 1); + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); - enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; - enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + enum + { + TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT + }; + enum + { + TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 + }; - long coef_index = 0; - do + long coef_index = 0; + do + { + const DataType *const sf = src_ptr + coef_index; + DataType *const df = dest_ptr + coef_index; + + // Extreme coefficients are always real + df[c1_r] = sf[c1_r] + sf[c2_r]; + df[c2_r] = sf[c1_r] - sf[c2_r]; + df[c1_i] = sf[c1_i]; + df[c2_i] = sf[c2_i]; + + FFTRealUseTrigo::prepare(osc_list[TRIGO_OSC]); + + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++i) { - const DataType * const sf = src_ptr + coef_index; - DataType * const df = dest_ptr + coef_index; + DataType c; + DataType s; + FFTRealUseTrigo::iterate(osc_list[TRIGO_OSC], c, s, cos_ptr, + i * table_step, + (dist - i) * table_step); - // Extreme coefficients are always real - df [c1_r] = sf [c1_r] + sf [c2_r]; - df [c2_r] = sf [c1_r] - sf [c2_r]; - df [c1_i] = sf [c1_i]; - df [c2_i] = sf [c2_i]; + const DataType sf_r_i = sf[c1_r + i]; + const DataType sf_i_i = sf[c1_i + i]; - FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); + const DataType v1 = sf[c2_r + i] * c - sf[c2_i + i] * s; + df[c1_r + i] = sf_r_i + v1; + df[c2_r - i] = sf_r_i - v1; - // Others are conjugate complex numbers - for (long i = 1; i < dist; ++ i) - { - DataType c; - DataType s; - FFTRealUseTrigo ::iterate ( - osc_list [TRIGO_OSC], - c, - s, - cos_ptr, - i * table_step, - (dist - i) * table_step - ); - - const DataType sf_r_i = sf [c1_r + i]; - const DataType sf_i_i = sf [c1_i + i]; - - const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s; - df [c1_r + i] = sf_r_i + v1; - df [c2_r - i] = sf_r_i - v1; - - const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c; - df [c2_r + i] = v2 + sf_i_i; - df [cend - i] = v2 - sf_i_i; - } - - coef_index += cend; + const DataType v2 = sf[c2_r + i] * s + sf[c2_i + i] * c; + df[c2_r + i] = v2 + sf_i_i; + df[cend - i] = v2 - sf_i_i; } - while (coef_index < len); + + coef_index += cend; + } while (coef_index < len); } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_FFTRealPassDirect_CODEHEADER_INCLUDED +#endif // ffft_FFTRealPassDirect_CODEHEADER_INCLUDED #undef ffft_FFTRealPassDirect_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealPassInverse.h b/libs/QRealFourier/fftreal/FFTRealPassInverse.h index b50b69f0..814e8e04 100644 --- a/libs/QRealFourier/fftreal/FFTRealPassInverse.h +++ b/libs/QRealFourier/fftreal/FFTRealPassInverse.h @@ -13,89 +13,69 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTRealPassInverse_HEADER_INCLUDED) +# define ffft_FFTRealPassInverse_HEADER_INCLUDED - -#if ! defined (ffft_FFTRealPassInverse_HEADER_INCLUDED) -#define ffft_FFTRealPassInverse_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - +# include "def.h" +# include "FFTRealFixLenParam.h" +# include "OscSinCos.h" namespace ffft { - - -template +template class FFTRealPassInverse { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; + ffft_FORCEINLINE static void process(long len, DataType dest_ptr[], + DataType src_ptr[], + const DataType f_ptr[], + const DataType cos_ptr[], long cos_len, + const long br_ptr[], OscType osc_list[]); + ffft_FORCEINLINE static void process_rec(long len, DataType dest_ptr[], + DataType src_ptr[], + const DataType cos_ptr[], + long cos_len, const long br_ptr[], + OscType osc_list[]); + ffft_FORCEINLINE static void + process_internal(long len, DataType dest_ptr[], const DataType src_ptr[], + const DataType cos_ptr[], long cos_len, const long br_ptr[], + OscType osc_list[]); - ffft_FORCEINLINE static void - process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - ffft_FORCEINLINE static void - process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - ffft_FORCEINLINE static void - process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTRealPassInverse(); + FFTRealPassInverse(const FFTRealPassInverse &other); + FFTRealPassInverse &operator=(const FFTRealPassInverse &other); + bool operator==(const FFTRealPassInverse &other); + bool operator!=(const FFTRealPassInverse &other); - FFTRealPassInverse (); - FFTRealPassInverse (const FFTRealPassInverse &other); - FFTRealPassInverse & - operator = (const FFTRealPassInverse &other); - bool operator == (const FFTRealPassInverse &other); - bool operator != (const FFTRealPassInverse &other); +}; // class FFTRealPassInverse -}; // class FFTRealPassInverse - - - -} // namespace ffft - - - -#include "FFTRealPassInverse.hpp" - - - -#endif // ffft_FFTRealPassInverse_HEADER_INCLUDED +} // namespace ffft +# include "FFTRealPassInverse.hpp" +#endif // ffft_FFTRealPassInverse_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealPassInverse.hpp b/libs/QRealFourier/fftreal/FFTRealPassInverse.hpp index 6fc9b5be..1c16b9e1 100644 --- a/libs/QRealFourier/fftreal/FFTRealPassInverse.hpp +++ b/libs/QRealFourier/fftreal/FFTRealPassInverse.hpp @@ -13,236 +13,205 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_FFTRealPassInverse_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealPassInverse code header. +#if defined(ffft_FFTRealPassInverse_CURRENT_CODEHEADER) +# error Recursive inclusion of FFTRealPassInverse code header. #endif -#define ffft_FFTRealPassInverse_CURRENT_CODEHEADER - -#if ! defined (ffft_FFTRealPassInverse_CODEHEADER_INCLUDED) -#define ffft_FFTRealPassInverse_CODEHEADER_INCLUDED - +#define ffft_FFTRealPassInverse_CURRENT_CODEHEADER +#if !defined(ffft_FFTRealPassInverse_CODEHEADER_INCLUDED) +# define ffft_FFTRealPassInverse_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "FFTRealUseTrigo.h" - - +# include "FFTRealUseTrigo.h" namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -void FFTRealPassInverse ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template +void FFTRealPassInverse::process(long len, DataType dest_ptr[], + DataType src_ptr[], + const DataType f_ptr[], + const DataType cos_ptr[], long cos_len, + const long br_ptr[], OscType osc_list[]) { - process_internal ( - len, - dest_ptr, - f_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - FFTRealPassInverse ::process_rec ( - len, - src_ptr, - dest_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); + process_internal(len, dest_ptr, f_ptr, cos_ptr, cos_len, br_ptr, osc_list); + FFTRealPassInverse::process_rec(len, src_ptr, dest_ptr, cos_ptr, + cos_len, br_ptr, osc_list); } - - -template -void FFTRealPassInverse ::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template +void FFTRealPassInverse::process_rec(long len, DataType dest_ptr[], + DataType src_ptr[], + const DataType cos_ptr[], + long cos_len, const long br_ptr[], + OscType osc_list[]) { - process_internal ( - len, - dest_ptr, - src_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - FFTRealPassInverse ::process_rec ( - len, - src_ptr, - dest_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); + process_internal(len, dest_ptr, src_ptr, cos_ptr, cos_len, br_ptr, osc_list); + FFTRealPassInverse::process_rec(len, src_ptr, dest_ptr, cos_ptr, + cos_len, br_ptr, osc_list); } -template <> -inline void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template<> +inline void FFTRealPassInverse<0>::process_rec( + long len, DataType dest_ptr[], DataType src_ptr[], const DataType cos_ptr[], + long cos_len, const long br_ptr[], OscType osc_list[]) { - (void) len; - (void) br_ptr; - (void) src_ptr; - (void) cos_ptr; - (void) cos_len; - (void) dest_ptr; - (void) osc_list; - // Stops recursion + (void)len; + (void)br_ptr; + (void)src_ptr; + (void)cos_ptr; + (void)cos_len; + (void)dest_ptr; + (void)osc_list; + // Stops recursion } - - -template -void FFTRealPassInverse ::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template +void FFTRealPassInverse::process_internal(long len, DataType dest_ptr[], + const DataType src_ptr[], + const DataType cos_ptr[], + long cos_len, + const long br_ptr[], + OscType osc_list[]) { - (void) br_ptr; + (void)br_ptr; - const long dist = 1L << (PASS - 1); - const long c1_r = 0; - const long c1_i = dist; - const long c2_r = dist * 2; - const long c2_i = dist * 3; - const long cend = dist * 4; - const long table_step = cos_len >> (PASS - 1); + const long dist = 1L << (PASS - 1); + const long c1_r = 0; + const long c1_i = dist; + const long c2_r = dist * 2; + const long c2_i = dist * 3; + const long cend = dist * 4; + const long table_step = cos_len >> (PASS - 1); - enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; - enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; + enum + { + TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT + }; + enum + { + TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 + }; - long coef_index = 0; - do - { - const DataType * const sf = src_ptr + coef_index; - DataType * const df = dest_ptr + coef_index; + long coef_index = 0; + do + { + const DataType *const sf = src_ptr + coef_index; + DataType *const df = dest_ptr + coef_index; - // Extreme coefficients are always real - df [c1_r] = sf [c1_r] + sf [c2_r]; - df [c2_r] = sf [c1_r] - sf [c2_r]; - df [c1_i] = sf [c1_i] * 2; - df [c2_i] = sf [c2_i] * 2; + // Extreme coefficients are always real + df[c1_r] = sf[c1_r] + sf[c2_r]; + df[c2_r] = sf[c1_r] - sf[c2_r]; + df[c1_i] = sf[c1_i] * 2; + df[c2_i] = sf[c2_i] * 2; - FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); + FFTRealUseTrigo::prepare(osc_list[TRIGO_OSC]); - // Others are conjugate complex numbers - for (long i = 1; i < dist; ++ i) - { - df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i]; - df [c1_i + i] = sf [c2_r + i] - sf [cend - i]; + // Others are conjugate complex numbers + for (long i = 1; i < dist; ++i) + { + df[c1_r + i] = sf[c1_r + i] + sf[c2_r - i]; + df[c1_i + i] = sf[c2_r + i] - sf[cend - i]; - DataType c; - DataType s; - FFTRealUseTrigo ::iterate ( - osc_list [TRIGO_OSC], - c, - s, - cos_ptr, - i * table_step, - (dist - i) * table_step - ); + DataType c; + DataType s; + FFTRealUseTrigo::iterate(osc_list[TRIGO_OSC], c, s, cos_ptr, + i * table_step, + (dist - i) * table_step); - const DataType vr = sf [c1_r + i] - sf [c2_r - i]; - const DataType vi = sf [c2_r + i] + sf [cend - i]; + const DataType vr = sf[c1_r + i] - sf[c2_r - i]; + const DataType vi = sf[c2_r + i] + sf[cend - i]; - df [c2_r + i] = vr * c + vi * s; - df [c2_i + i] = vi * c - vr * s; - } + df[c2_r + i] = vr * c + vi * s; + df[c2_i + i] = vi * c - vr * s; + } - coef_index += cend; - } - while (coef_index < len); + coef_index += cend; + } while (coef_index < len); } -template <> -inline void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template<> +inline void +FFTRealPassInverse<2>::process_internal(long len, DataType dest_ptr[], + const DataType src_ptr[], + const DataType cos_ptr[], long cos_len, + const long br_ptr[], OscType osc_list[]) { - (void) br_ptr; - (void) cos_len; - (void) cos_ptr; - (void) osc_list; + (void)br_ptr; + (void)cos_len; + (void)cos_ptr; + (void)osc_list; - // Antepenultimate pass - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); + // Antepenultimate pass + const DataType sqrt2_2 = DataType(SQRT2 * 0.5); - long coef_index = 0; - do - { - dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; - dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; - dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2; - dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2; + long coef_index = 0; + do + { + dest_ptr[coef_index] = src_ptr[coef_index] + src_ptr[coef_index + 4]; + dest_ptr[coef_index + 4] = src_ptr[coef_index] - src_ptr[coef_index + 4]; + dest_ptr[coef_index + 2] = src_ptr[coef_index + 2] * 2; + dest_ptr[coef_index + 6] = src_ptr[coef_index + 6] * 2; - dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3]; - dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7]; + dest_ptr[coef_index + 1] + = src_ptr[coef_index + 1] + src_ptr[coef_index + 3]; + dest_ptr[coef_index + 3] + = src_ptr[coef_index + 5] - src_ptr[coef_index + 7]; - const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3]; - const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7]; + const DataType vr = src_ptr[coef_index + 1] - src_ptr[coef_index + 3]; + const DataType vi = src_ptr[coef_index + 5] + src_ptr[coef_index + 7]; - dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2; - dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2; + dest_ptr[coef_index + 5] = (vr + vi) * sqrt2_2; + dest_ptr[coef_index + 7] = (vi - vr) * sqrt2_2; - coef_index += 8; - } - while (coef_index < len); + coef_index += 8; + } while (coef_index < len); } -template <> -inline void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) +template<> +inline void +FFTRealPassInverse<1>::process_internal(long len, DataType dest_ptr[], + const DataType src_ptr[], + const DataType cos_ptr[], long cos_len, + const long br_ptr[], OscType osc_list[]) { - (void) cos_ptr; - (void) cos_len; - (void) osc_list; + (void)cos_ptr; + (void)cos_len; + (void)osc_list; - // Penultimate and last pass at once - const long qlen = len >> 2; + // Penultimate and last pass at once + const long qlen = len >> 2; - long coef_index = 0; - do - { - const long ri_0 = br_ptr [coef_index >> 2]; + long coef_index = 0; + do + { + const long ri_0 = br_ptr[coef_index >> 2]; - const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2]; - const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2]; - const DataType b_1 = src_ptr [coef_index + 1] * 2; - const DataType b_3 = src_ptr [coef_index + 3] * 2; + const DataType b_0 = src_ptr[coef_index] + src_ptr[coef_index + 2]; + const DataType b_2 = src_ptr[coef_index] - src_ptr[coef_index + 2]; + const DataType b_1 = src_ptr[coef_index + 1] * 2; + const DataType b_3 = src_ptr[coef_index + 3] * 2; - dest_ptr [ri_0 ] = b_0 + b_1; - dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1; - dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3; - dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3; + dest_ptr[ri_0] = b_0 + b_1; + dest_ptr[ri_0 + 2 * qlen] = b_0 - b_1; + dest_ptr[ri_0 + 1 * qlen] = b_2 + b_3; + dest_ptr[ri_0 + 3 * qlen] = b_2 - b_3; - coef_index += 4; - } - while (coef_index < len); + coef_index += 4; + } while (coef_index < len); } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_FFTRealPassInverse_CODEHEADER_INCLUDED +#endif // ffft_FFTRealPassInverse_CODEHEADER_INCLUDED #undef ffft_FFTRealPassInverse_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealSelect.h b/libs/QRealFourier/fftreal/FFTRealSelect.h index 09edfc1f..5575ad2b 100644 --- a/libs/QRealFourier/fftreal/FFTRealSelect.h +++ b/libs/QRealFourier/fftreal/FFTRealSelect.h @@ -13,66 +13,45 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTRealSelect_HEADER_INCLUDED) +# define ffft_FFTRealSelect_HEADER_INCLUDED - -#if ! defined (ffft_FFTRealSelect_HEADER_INCLUDED) -#define ffft_FFTRealSelect_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once -#endif - - +# if defined(_MSC_VER) +# pragma once +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" - - +# include "def.h" namespace ffft { - - -template +template class FFTRealSelect { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + ffft_FORCEINLINE static float *sel_bin(float *e_ptr, float *o_ptr); - ffft_FORCEINLINE static float * - sel_bin (float *e_ptr, float *o_ptr); - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTRealSelect(); + ~FFTRealSelect(); + FFTRealSelect(const FFTRealSelect &other); + FFTRealSelect &operator=(const FFTRealSelect &other); + bool operator==(const FFTRealSelect &other); + bool operator!=(const FFTRealSelect &other); - FFTRealSelect (); - ~FFTRealSelect (); - FFTRealSelect (const FFTRealSelect &other); - FFTRealSelect& operator = (const FFTRealSelect &other); - bool operator == (const FFTRealSelect &other); - bool operator != (const FFTRealSelect &other); +}; // class FFTRealSelect -}; // class FFTRealSelect - - - -} // namespace ffft - - - -#include "FFTRealSelect.hpp" - - - -#endif // ffft_FFTRealSelect_HEADER_INCLUDED +} // namespace ffft +# include "FFTRealSelect.hpp" +#endif // ffft_FFTRealSelect_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealSelect.hpp b/libs/QRealFourier/fftreal/FFTRealSelect.hpp index b67ee303..23ba242a 100644 --- a/libs/QRealFourier/fftreal/FFTRealSelect.hpp +++ b/libs/QRealFourier/fftreal/FFTRealSelect.hpp @@ -13,53 +13,37 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_FFTRealSelect_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealSelect code header. +#if defined(ffft_FFTRealSelect_CURRENT_CODEHEADER) +# error Recursive inclusion of FFTRealSelect code header. #endif -#define ffft_FFTRealSelect_CURRENT_CODEHEADER - -#if ! defined (ffft_FFTRealSelect_CODEHEADER_INCLUDED) -#define ffft_FFTRealSelect_CODEHEADER_INCLUDED - +#define ffft_FFTRealSelect_CURRENT_CODEHEADER +#if !defined(ffft_FFTRealSelect_CODEHEADER_INCLUDED) +# define ffft_FFTRealSelect_CODEHEADER_INCLUDED namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -float * FFTRealSelect

::sel_bin (float *e_ptr, float *o_ptr) +template +float *FFTRealSelect

::sel_bin(float *e_ptr, float *o_ptr) { - (void) e_ptr; - return (o_ptr); + (void)e_ptr; + return (o_ptr); } - - -template <> -inline float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) +template<> +inline float *FFTRealSelect<0>::sel_bin(float *e_ptr, float *o_ptr) { - (void) o_ptr; - return (e_ptr); + (void)o_ptr; + return (e_ptr); } +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_FFTRealSelect_CODEHEADER_INCLUDED +#endif // ffft_FFTRealSelect_CODEHEADER_INCLUDED #undef ffft_FFTRealSelect_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealUseTrigo.h b/libs/QRealFourier/fftreal/FFTRealUseTrigo.h index 8146a450..08cca7b0 100644 --- a/libs/QRealFourier/fftreal/FFTRealUseTrigo.h +++ b/libs/QRealFourier/fftreal/FFTRealUseTrigo.h @@ -13,87 +13,60 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_FFTRealUseTrigo_HEADER_INCLUDED) +# define ffft_FFTRealUseTrigo_HEADER_INCLUDED - -#if ! defined (ffft_FFTRealUseTrigo_HEADER_INCLUDED) -#define ffft_FFTRealUseTrigo_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - +# include "def.h" +# include "FFTRealFixLenParam.h" +# include "OscSinCos.h" namespace ffft { - - -template +template class FFTRealUseTrigo { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef FFTRealFixLenParam::DataType DataType; + typedef OscSinCos OscType; - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; + ffft_FORCEINLINE static void prepare(OscType &osc); + ffft_FORCEINLINE static void iterate(OscType &osc, DataType &c, DataType &s, + const DataType cos_ptr[], long index_c, + long index_s); - ffft_FORCEINLINE static void - prepare (OscType &osc); - ffft_FORCEINLINE static void - iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + FFTRealUseTrigo(); + ~FFTRealUseTrigo(); + FFTRealUseTrigo(const FFTRealUseTrigo &other); + FFTRealUseTrigo &operator=(const FFTRealUseTrigo &other); + bool operator==(const FFTRealUseTrigo &other); + bool operator!=(const FFTRealUseTrigo &other); - FFTRealUseTrigo (); - ~FFTRealUseTrigo (); - FFTRealUseTrigo (const FFTRealUseTrigo &other); - FFTRealUseTrigo & - operator = (const FFTRealUseTrigo &other); - bool operator == (const FFTRealUseTrigo &other); - bool operator != (const FFTRealUseTrigo &other); +}; // class FFTRealUseTrigo -}; // class FFTRealUseTrigo - - - -} // namespace ffft - - - -#include "FFTRealUseTrigo.hpp" - - - -#endif // ffft_FFTRealUseTrigo_HEADER_INCLUDED +} // namespace ffft +# include "FFTRealUseTrigo.hpp" +#endif // ffft_FFTRealUseTrigo_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/FFTRealUseTrigo.hpp b/libs/QRealFourier/fftreal/FFTRealUseTrigo.hpp index 36b585ab..793a0ba1 100644 --- a/libs/QRealFourier/fftreal/FFTRealUseTrigo.hpp +++ b/libs/QRealFourier/fftreal/FFTRealUseTrigo.hpp @@ -13,85 +13,67 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_FFTRealUseTrigo_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealUseTrigo code header. +#if defined(ffft_FFTRealUseTrigo_CURRENT_CODEHEADER) +# error Recursive inclusion of FFTRealUseTrigo code header. #endif -#define ffft_FFTRealUseTrigo_CURRENT_CODEHEADER - -#if ! defined (ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED) -#define ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED - +#define ffft_FFTRealUseTrigo_CURRENT_CODEHEADER +#if !defined(ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED) +# define ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "OscSinCos.h" - - +# include "OscSinCos.h" namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -void FFTRealUseTrigo ::prepare (OscType &osc) +template +void FFTRealUseTrigo::prepare(OscType &osc) { - osc.clear_buffers (); + osc.clear_buffers(); } -template <> -inline void FFTRealUseTrigo <0>::prepare (OscType &osc) +template<> +inline void FFTRealUseTrigo<0>::prepare(OscType &osc) { - (void) osc; - // Nothing + (void)osc; + // Nothing } - - -template -void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +template +void FFTRealUseTrigo::iterate(OscType &osc, DataType &c, DataType &s, + const DataType cos_ptr[], long index_c, + long index_s) { - (void) index_c; - (void) index_s; - (void) cos_ptr; - osc.step (); - c = osc.get_cos (); - s = osc.get_sin (); + (void)index_c; + (void)index_s; + (void)cos_ptr; + osc.step(); + c = osc.get_cos(); + s = osc.get_sin(); } -template <> -inline void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) +template<> +inline void FFTRealUseTrigo<0>::iterate(OscType &osc, DataType &c, DataType &s, + const DataType cos_ptr[], long index_c, + long index_s) { - (void) osc; - c = cos_ptr [index_c]; - s = cos_ptr [index_s]; + (void)osc; + c = cos_ptr[index_c]; + s = cos_ptr[index_s]; } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED +#endif // ffft_FFTRealUseTrigo_CODEHEADER_INCLUDED #undef ffft_FFTRealUseTrigo_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/OscSinCos.h b/libs/QRealFourier/fftreal/OscSinCos.h index 866f5982..c3cdaff5 100644 --- a/libs/QRealFourier/fftreal/OscSinCos.h +++ b/libs/QRealFourier/fftreal/OscSinCos.h @@ -13,95 +13,64 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_OscSinCos_HEADER_INCLUDED) +# define ffft_OscSinCos_HEADER_INCLUDED - -#if ! defined (ffft_OscSinCos_HEADER_INCLUDED) -#define ffft_OscSinCos_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include "def.h" - - +# include "def.h" namespace ffft { - - -template +template class OscSinCos { -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: + typedef T DataType; - typedef T DataType; + OscSinCos(); - OscSinCos (); + ffft_FORCEINLINE void set_step(double angle_rad); - ffft_FORCEINLINE void - set_step (double angle_rad); + ffft_FORCEINLINE DataType get_cos() const; + ffft_FORCEINLINE DataType get_sin() const; + ffft_FORCEINLINE void step(); + ffft_FORCEINLINE void clear_buffers(); - ffft_FORCEINLINE DataType - get_cos () const; - ffft_FORCEINLINE DataType - get_sin () const; - ffft_FORCEINLINE void - step (); - ffft_FORCEINLINE void - clear_buffers (); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] + DataType _pos_sin; // - + DataType _step_cos; // Phase increment per step, [-1 ; 1] + DataType _step_sin; // - - DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] - DataType _pos_sin; // - - DataType _step_cos; // Phase increment per step, [-1 ; 1] - DataType _step_sin; // - - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ + /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: + OscSinCos(const OscSinCos &other); + OscSinCos &operator=(const OscSinCos &other); + bool operator==(const OscSinCos &other); + bool operator!=(const OscSinCos &other); - OscSinCos (const OscSinCos &other); - OscSinCos & operator = (const OscSinCos &other); - bool operator == (const OscSinCos &other); - bool operator != (const OscSinCos &other); +}; // class OscSinCos -}; // class OscSinCos - - - -} // namespace ffft - - - -#include "OscSinCos.hpp" - - - -#endif // ffft_OscSinCos_HEADER_INCLUDED +} // namespace ffft +# include "OscSinCos.hpp" +#endif // ffft_OscSinCos_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/OscSinCos.hpp b/libs/QRealFourier/fftreal/OscSinCos.hpp index 8f3686c5..50722363 100644 --- a/libs/QRealFourier/fftreal/OscSinCos.hpp +++ b/libs/QRealFourier/fftreal/OscSinCos.hpp @@ -13,111 +13,83 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ - - -#if defined (ffft_OscSinCos_CURRENT_CODEHEADER) - #error Recursive inclusion of OscSinCos code header. +#if defined(ffft_OscSinCos_CURRENT_CODEHEADER) +# error Recursive inclusion of OscSinCos code header. #endif -#define ffft_OscSinCos_CURRENT_CODEHEADER - -#if ! defined (ffft_OscSinCos_CODEHEADER_INCLUDED) -#define ffft_OscSinCos_CODEHEADER_INCLUDED - +#define ffft_OscSinCos_CURRENT_CODEHEADER +#if !defined(ffft_OscSinCos_CODEHEADER_INCLUDED) +# define ffft_OscSinCos_CODEHEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ -#include - -namespace std { } - +# include +namespace std +{ +} namespace ffft { - - /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - -template -OscSinCos ::OscSinCos () -: _pos_cos (1) -, _pos_sin (0) -, _step_cos (1) -, _step_sin (0) +template +OscSinCos::OscSinCos() + : _pos_cos(1) + , _pos_sin(0) + , _step_cos(1) + , _step_sin(0) { - // Nothing + // Nothing } - - -template -void OscSinCos ::set_step (double angle_rad) +template +void OscSinCos::set_step(double angle_rad) { - using namespace std; + using namespace std; - _step_cos = static_cast (cos (angle_rad)); - _step_sin = static_cast (sin (angle_rad)); + _step_cos = static_cast(cos(angle_rad)); + _step_sin = static_cast(sin(angle_rad)); } - - -template -typename OscSinCos ::DataType OscSinCos ::get_cos () const +template +typename OscSinCos::DataType OscSinCos::get_cos() const { - return (_pos_cos); + return (_pos_cos); } - - -template -typename OscSinCos ::DataType OscSinCos ::get_sin () const +template +typename OscSinCos::DataType OscSinCos::get_sin() const { - return (_pos_sin); + return (_pos_sin); } - - -template -void OscSinCos ::step () +template +void OscSinCos::step() { - const DataType old_cos = _pos_cos; - const DataType old_sin = _pos_sin; + const DataType old_cos = _pos_cos; + const DataType old_sin = _pos_sin; - _pos_cos = old_cos * _step_cos - old_sin * _step_sin; - _pos_sin = old_cos * _step_sin + old_sin * _step_cos; + _pos_cos = old_cos * _step_cos - old_sin * _step_sin; + _pos_sin = old_cos * _step_sin + old_sin * _step_cos; } - - -template -void OscSinCos ::clear_buffers () +template +void OscSinCos::clear_buffers() { - _pos_cos = static_cast (1); - _pos_sin = static_cast (0); + _pos_cos = static_cast(1); + _pos_sin = static_cast(0); } - - /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ +} // namespace ffft - -} // namespace ffft - - - -#endif // ffft_OscSinCos_CODEHEADER_INCLUDED +#endif // ffft_OscSinCos_CODEHEADER_INCLUDED #undef ffft_OscSinCos_CURRENT_CODEHEADER - - /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/fftreal/def.h b/libs/QRealFourier/fftreal/def.h index a93c8b9e..efbc7a62 100644 --- a/libs/QRealFourier/fftreal/def.h +++ b/libs/QRealFourier/fftreal/def.h @@ -13,48 +13,34 @@ http://sam.zoy.org/wtfpl/COPYING for more details. *Tab=3***********************************************************************/ +#if !defined(ffft_def_HEADER_INCLUDED) +# define ffft_def_HEADER_INCLUDED - -#if ! defined (ffft_def_HEADER_INCLUDED) -#define ffft_def_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - +# if defined(_MSC_VER) +# pragma once +# pragma warning(4 : 4250) // "Inherits via dominance." +# endif /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - namespace ffft { +const double PI = 3.1415926535897932384626433832795; +const double SQRT2 = 1.41421356237309514547462185873883; +# if defined(_MSC_VER) -const double PI = 3.1415926535897932384626433832795; -const double SQRT2 = 1.41421356237309514547462185873883; +# define ffft_FORCEINLINE __forceinline -#if defined (_MSC_VER) +# else - #define ffft_FORCEINLINE __forceinline +# define ffft_FORCEINLINE inline -#else - - #define ffft_FORCEINLINE inline - -#endif - - - -} // namespace ffft - - - -#endif // ffft_def_HEADER_INCLUDED +# endif +} // namespace ffft +#endif // ffft_def_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/libs/QRealFourier/headers/qcomplexnumber.h b/libs/QRealFourier/headers/qcomplexnumber.h index 6b86d561..cadc051e 100644 --- a/libs/QRealFourier/headers/qcomplexnumber.h +++ b/libs/QRealFourier/headers/qcomplexnumber.h @@ -3,7 +3,7 @@ qcomplexnumber.h - Header file for QComplexNumber Template class for handling complex numbers with a real and imaginary -part. +part. ************************************************************************ @@ -42,36 +42,33 @@ qrealfourier@gmail.com #ifndef QCOMPLEXNUMBER_H #define QCOMPLEXNUMBER_H -template +template class QComplexNumber { - public: +public: + QComplexNumber(); + QComplexNumber(T real, T imaginary); - QComplexNumber(); - QComplexNumber(T real, T imaginary); + void setReal(T real); + void setImaginary(T imaginary); + void set(T real, T imaginary); + void set(QComplexNumber complex); - void setReal(T real); - void setImaginary(T imaginary); - void set(T real, T imaginary); - void set(QComplexNumber complex); + T real(); + T imaginary(); - T real(); - T imaginary(); + QComplexNumber &operator+=(const QComplexNumber &number); + QComplexNumber &operator-=(const QComplexNumber &number); + QComplexNumber &operator/=(const QComplexNumber &number); + QComplexNumber &operator*=(const QComplexNumber &number); - QComplexNumber& operator+=(const QComplexNumber &number); - QComplexNumber& operator-=(const QComplexNumber &number); - QComplexNumber& operator/=(const QComplexNumber &number); - QComplexNumber& operator*=(const QComplexNumber &number); - - QComplexNumber& operator/=(const T &value); - QComplexNumber& operator*=(const T &value); - - private: - - T mReal; - T mImaginary; + QComplexNumber &operator/=(const T &value); + QComplexNumber &operator*=(const T &value); +private: + T mReal; + T mImaginary; }; typedef QComplexNumber QComplexFloat; diff --git a/libs/QRealFourier/headers/qfouriercalculator.h b/libs/QRealFourier/headers/qfouriercalculator.h index 869159f4..9e1fb230 100644 --- a/libs/QRealFourier/headers/qfouriercalculator.h +++ b/libs/QRealFourier/headers/qfouriercalculator.h @@ -39,31 +39,27 @@ qrealfourier@gmail.com ***********************************************************************/ - #ifndef QFOURIERCALCULATOR_H #define QFOURIERCALCULATOR_H class QFourierCalculator { - public: - - QFourierCalculator(); - virtual ~QFourierCalculator(); - virtual void setData(float input[], float output[] = 0); - virtual void setSize(int size); - virtual int size(); +public: + QFourierCalculator(); + virtual ~QFourierCalculator(); + virtual void setData(float input[], float output[] = 0); + virtual void setSize(int size); + virtual int size(); - virtual void forward() = 0; - virtual void inverse() = 0; - virtual void rescale() = 0; - - protected: - - float *mInput; - float *mOutput; - int mSize; + virtual void forward() = 0; + virtual void inverse() = 0; + virtual void rescale() = 0; +protected: + float *mInput; + float *mOutput; + int mSize; }; #endif diff --git a/libs/QRealFourier/headers/qfourierfixedcalculator.h b/libs/QRealFourier/headers/qfourierfixedcalculator.h index 0ce12ea7..eb730334 100644 --- a/libs/QRealFourier/headers/qfourierfixedcalculator.h +++ b/libs/QRealFourier/headers/qfourierfixedcalculator.h @@ -45,22 +45,19 @@ qrealfourier@gmail.com #include "FFTRealFixLen.h" #include "qfouriercalculator.h" -template +template class QFourierFixedCalculator : public QFourierCalculator { - public: - - QFourierFixedCalculator(); - void setSize(int size); - void forward(); - void inverse(); - void rescale(); - - protected: - - ffft::FFTRealFixLen mFourierTransform; +public: + QFourierFixedCalculator(); + void setSize(int size); + void forward(); + void inverse(); + void rescale(); +protected: + ffft::FFTRealFixLen mFourierTransform; }; #endif diff --git a/libs/QRealFourier/headers/qfouriertransformer.h b/libs/QRealFourier/headers/qfouriertransformer.h index 7f6fff64..171a6a7f 100644 --- a/libs/QRealFourier/headers/qfouriertransformer.h +++ b/libs/QRealFourier/headers/qfouriertransformer.h @@ -51,53 +51,49 @@ typedef QVector QComplexVector; class QFourierTransformer { - public: +public: + enum Direction + { + Forward = 0, + Inverse = 1 + }; - enum Direction - { - Forward = 0, - Inverse = 1 - }; + enum Initialization + { + VariableSize = 0, + FixedSize = 1, + InvalidSize = 2 + }; - enum Initialization - { - VariableSize = 0, - FixedSize = 1, - InvalidSize = 2 - }; +public: + QFourierTransformer(int size = 0, QString functionName = ""); + ~QFourierTransformer(); - public: + Initialization setSize(int size); + bool setWindowFunction(QString functionName); + QStringList windowFunctions(); - QFourierTransformer(int size = 0, QString functionName = ""); - ~QFourierTransformer(); + void transform(float input[], float output[], + Direction direction = QFourierTransformer::Forward); + void forwardTransform(float *input, float *output); + void inverseTransform(float input[], float output[]); + void rescale(float input[]); - Initialization setSize(int size); - bool setWindowFunction(QString functionName); - QStringList windowFunctions(); + void conjugate(float input[]); + QComplexVector toComplex(float input[]); - void transform(float input[], float output[], Direction direction = QFourierTransformer::Forward); - void forwardTransform(float *input, float *output); - void inverseTransform(float input[], float output[]); - void rescale(float input[]); - - void conjugate(float input[]); - QComplexVector toComplex(float input[]); - - protected: - - void initialize(); - int sizeToKey(int size); - bool isValidSize(int value); - - private: - - int mSize; - QMap mFixedCalculators; - QFourierCalculator* mVariableCalculator; - QFourierCalculator *mCalculator; - QStringList mWindowFunctions; - QWindowFunction *mWindowFunction; +protected: + void initialize(); + int sizeToKey(int size); + bool isValidSize(int value); +private: + int mSize; + QMap mFixedCalculators; + QFourierCalculator *mVariableCalculator; + QFourierCalculator *mCalculator; + QStringList mWindowFunctions; + QWindowFunction *mWindowFunction; }; #endif diff --git a/libs/QRealFourier/headers/qfouriervariablecalculator.h b/libs/QRealFourier/headers/qfouriervariablecalculator.h index 07534992..dbe1402a 100644 --- a/libs/QRealFourier/headers/qfouriervariablecalculator.h +++ b/libs/QRealFourier/headers/qfouriervariablecalculator.h @@ -1,7 +1,7 @@ /*********************************************************************** qfouriervariablecalculator.h - Header file for - QFourierVariableCalculator + QFourierVariableCalculator Class for calculating FFts of a variable size. @@ -48,19 +48,16 @@ qrealfourier@gmail.com class QFourierVariableCalculator : public QFourierCalculator { - public: - - QFourierVariableCalculator(); - ~QFourierVariableCalculator(); - void setSize(int size); - void forward(); - void inverse(); - void rescale(); - - protected: - - ffft::FFTReal *mFourierTransform; +public: + QFourierVariableCalculator(); + ~QFourierVariableCalculator(); + void setSize(int size); + void forward(); + void inverse(); + void rescale(); +protected: + ffft::FFTReal *mFourierTransform; }; #endif diff --git a/libs/QRealFourier/headers/qwindowfunction.h b/libs/QRealFourier/headers/qwindowfunction.h index 0fc31bb8..99ca3d7a 100644 --- a/libs/QRealFourier/headers/qwindowfunction.h +++ b/libs/QRealFourier/headers/qwindowfunction.h @@ -1,8 +1,8 @@ /*********************************************************************** qwindowfunction.h - Header file for QWindowFunction, - QWindowFunctionManager, QRectangularFunction, - QHammingFunction, QHannFunction + QWindowFunctionManager, +QRectangularFunction, QHammingFunction, QHannFunction Template classes necessary for applying a window function to a discrete set of samples. @@ -54,84 +54,72 @@ qrealfourier@gmail.com QWindowFunction **********************************************************/ -template +template class QWindowFunction { - typedef QVector QWindow; + typedef QVector QWindow; - public: +public: + virtual ~QWindowFunction() = default; + void apply(T *data, int size); + void create(int size); - virtual ~QWindowFunction() = default; - void apply(T *data, int size); - void create(int size); - - protected: - - void fillWindow(int size); - virtual T calculate(int currentSample, int totalSamples) = 0; - - protected: - - QWindow mWindow; +protected: + void fillWindow(int size); + virtual T calculate(int currentSample, int totalSamples) = 0; +protected: + QWindow mWindow; }; /********************************************************** QWindowFunctionManager **********************************************************/ -template +template class QWindowFunctionManager { - public: - - static QWindowFunction* createFunction(QString functionName); - static QStringList functions(); - +public: + static QWindowFunction *createFunction(QString functionName); + static QStringList functions(); }; /********************************************************** QRectangularFunction **********************************************************/ -template +template class QRectangularFunction : public QWindowFunction { - protected: - - T calculate(int currentSample, int totalSamples); - +protected: + T calculate(int currentSample, int totalSamples); }; /********************************************************** QHammingFunction **********************************************************/ -template +template class QHammingFunction : public QWindowFunction { - protected: - - T calculate(int currentSample, int totalSamples); - +protected: + T calculate(int currentSample, int totalSamples); }; /********************************************************** QHannFunction **********************************************************/ -template +template class QHannFunction : public QWindowFunction { - protected: - - T calculate(int currentSample, int totalSamples); - +protected: + T calculate(int currentSample, int totalSamples); }; #endif diff --git a/libs/QRealFourier/sources/qcomplexnumber.cpp b/libs/QRealFourier/sources/qcomplexnumber.cpp index 809200e5..cd66fb7b 100644 --- a/libs/QRealFourier/sources/qcomplexnumber.cpp +++ b/libs/QRealFourier/sources/qcomplexnumber.cpp @@ -3,7 +3,7 @@ qcomplexnumber.cpp - Source file for QComplexNumber Template class for handling complex numbers with a real and imaginary -part. +part. ************************************************************************ @@ -41,104 +41,108 @@ qrealfourier@gmail.com #include "qcomplexnumber.h" -template +template QComplexNumber::QComplexNumber() { - mReal = 0; - mImaginary = 0; + mReal = 0; + mImaginary = 0; } -template +template QComplexNumber::QComplexNumber(T real, T imaginary) { - mReal = real; - mImaginary = imaginary; + mReal = real; + mImaginary = imaginary; } -template +template void QComplexNumber::setReal(T real) { - mReal = real; + mReal = real; } -template +template void QComplexNumber::setImaginary(T imaginary) { - mImaginary = imaginary; + mImaginary = imaginary; } -template +template void QComplexNumber::set(T real, T imaginary) { - mReal = real; - mImaginary = imaginary; + mReal = real; + mImaginary = imaginary; } -template +template void QComplexNumber::set(QComplexNumber complex) { - mReal = complex.real(); - mImaginary = complex.imaginary(); + mReal = complex.real(); + mImaginary = complex.imaginary(); } -template +template T QComplexNumber::real() { - return mReal; + return mReal; } -template +template T QComplexNumber::imaginary() { - return mImaginary; + return mImaginary; } -template -QComplexNumber& QComplexNumber::operator+=(const QComplexNumber &number) +template +QComplexNumber & +QComplexNumber::operator+=(const QComplexNumber &number) { - mReal += number.mReal; - mImaginary += number.mImaginary; - return *this; + mReal += number.mReal; + mImaginary += number.mImaginary; + return *this; } -template -QComplexNumber& QComplexNumber::operator-=(const QComplexNumber &number) +template +QComplexNumber & +QComplexNumber::operator-=(const QComplexNumber &number) { - mReal -= number.mReal; - mImaginary -= number.mImaginary; - return *this; + mReal -= number.mReal; + mImaginary -= number.mImaginary; + return *this; } -template -QComplexNumber& QComplexNumber::operator/=(const QComplexNumber &number) +template +QComplexNumber & +QComplexNumber::operator/=(const QComplexNumber &number) { - mReal /= number.mReal; - mImaginary /= number.mImaginary; - return *this; + mReal /= number.mReal; + mImaginary /= number.mImaginary; + return *this; } -template -QComplexNumber& QComplexNumber::operator*=(const QComplexNumber &number) +template +QComplexNumber & +QComplexNumber::operator*=(const QComplexNumber &number) { - mReal *= number.mReal; - mImaginary *= number.mImaginary; - return *this; + mReal *= number.mReal; + mImaginary *= number.mImaginary; + return *this; } -template -QComplexNumber& QComplexNumber::operator/=(const T &value) +template +QComplexNumber &QComplexNumber::operator/=(const T &value) { - mReal /= value; - mImaginary /= value; - return *this; + mReal /= value; + mImaginary /= value; + return *this; } -template -QComplexNumber& QComplexNumber::operator*=(const T &value) +template +QComplexNumber &QComplexNumber::operator*=(const T &value) { - mReal *= value; - mImaginary *= value; - return *this; + mReal *= value; + mImaginary *= value; + return *this; } template class QComplexNumber; diff --git a/libs/QRealFourier/sources/qfouriercalculator.cpp b/libs/QRealFourier/sources/qfouriercalculator.cpp index bfd04caf..999a7205 100644 --- a/libs/QRealFourier/sources/qfouriercalculator.cpp +++ b/libs/QRealFourier/sources/qfouriercalculator.cpp @@ -43,27 +43,25 @@ qrealfourier@gmail.com QFourierCalculator::QFourierCalculator() { - mInput = 0; - mOutput = 0; - mSize = 0; + mInput = 0; + mOutput = 0; + mSize = 0; } -QFourierCalculator::~QFourierCalculator() -{ -} +QFourierCalculator::~QFourierCalculator() {} void QFourierCalculator::setData(float input[], float output[]) { - mInput = input; - mOutput = output; + mInput = input; + mOutput = output; } void QFourierCalculator::setSize(int size) { - mSize = size; + mSize = size; } int QFourierCalculator::size() { - return mSize; + return mSize; } diff --git a/libs/QRealFourier/sources/qfourierfixedcalculator.cpp b/libs/QRealFourier/sources/qfourierfixedcalculator.cpp index 3bfa09ca..968ee4e6 100644 --- a/libs/QRealFourier/sources/qfourierfixedcalculator.cpp +++ b/libs/QRealFourier/sources/qfourierfixedcalculator.cpp @@ -41,35 +41,38 @@ qrealfourier@gmail.com #include "qfourierfixedcalculator.h" -template +template QFourierFixedCalculator::QFourierFixedCalculator() - : QFourierCalculator() + : QFourierCalculator() { - setSize(mFourierTransform.get_length()); + setSize(mFourierTransform.get_length()); } -template +template void QFourierFixedCalculator::setSize(int size) { - (void) size; + (void)size; } -template +template void QFourierFixedCalculator::forward() { - QFourierFixedCalculator::mFourierTransform.do_fft(QFourierCalculator::mOutput, QFourierCalculator::mInput); + QFourierFixedCalculator::mFourierTransform.do_fft( + QFourierCalculator::mOutput, QFourierCalculator::mInput); } -template +template void QFourierFixedCalculator::inverse() { - QFourierFixedCalculator::mFourierTransform.do_ifft(QFourierCalculator::mInput, QFourierCalculator::mOutput); + QFourierFixedCalculator::mFourierTransform.do_ifft( + QFourierCalculator::mInput, QFourierCalculator::mOutput); } -template +template void QFourierFixedCalculator::rescale() { - QFourierFixedCalculator::mFourierTransform.rescale(QFourierCalculator::mInput); + QFourierFixedCalculator::mFourierTransform.rescale( + QFourierCalculator::mInput); } template class QFourierFixedCalculator<3>; diff --git a/libs/QRealFourier/sources/qfouriertransformer.cpp b/libs/QRealFourier/sources/qfouriertransformer.cpp index 915d4e7a..f15e6c1a 100644 --- a/libs/QRealFourier/sources/qfouriertransformer.cpp +++ b/libs/QRealFourier/sources/qfouriertransformer.cpp @@ -44,161 +44,164 @@ qrealfourier@gmail.com QFourierTransformer::QFourierTransformer(int size, QString functionName) { - mWindowFunctions = QWindowFunctionManager::functions(); - mWindowFunction = 0; - mCalculator = 0; - initialize(); - setSize(size); - setWindowFunction(functionName); + mWindowFunctions = QWindowFunctionManager::functions(); + mWindowFunction = 0; + mCalculator = 0; + initialize(); + setSize(size); + setWindowFunction(functionName); } QFourierTransformer::~QFourierTransformer() { - qDeleteAll(mFixedCalculators.begin(), mFixedCalculators.end()); - mFixedCalculators.clear(); - delete mVariableCalculator; - if(mWindowFunction != 0) - { - delete mWindowFunction; - } + qDeleteAll(mFixedCalculators.begin(), mFixedCalculators.end()); + mFixedCalculators.clear(); + delete mVariableCalculator; + if (mWindowFunction != 0) + { + delete mWindowFunction; + } } QFourierTransformer::Initialization QFourierTransformer::setSize(int size) { - if(isValidSize(size)) - { - mSize = size; - if(mWindowFunction != 0) - { - mWindowFunction->create(mSize); - } - int key = sizeToKey(mSize); - if(mFixedCalculators.contains(key)) - { - mCalculator = mFixedCalculators[key]; - return QFourierTransformer::FixedSize; - } - else - { - mCalculator = mVariableCalculator; - mCalculator->setSize(mSize); - return QFourierTransformer::VariableSize; - } - } - mSize = 0; - return QFourierTransformer::InvalidSize; + if (isValidSize(size)) + { + mSize = size; + if (mWindowFunction != 0) + { + mWindowFunction->create(mSize); + } + int key = sizeToKey(mSize); + if (mFixedCalculators.contains(key)) + { + mCalculator = mFixedCalculators[key]; + return QFourierTransformer::FixedSize; + } + else + { + mCalculator = mVariableCalculator; + mCalculator->setSize(mSize); + return QFourierTransformer::VariableSize; + } + } + mSize = 0; + return QFourierTransformer::InvalidSize; } bool QFourierTransformer::setWindowFunction(QString functionName) { - for(int i = 0; i < mWindowFunctions.size(); ++i) - { - if(functionName.trimmed().toLower().replace("function", "") == mWindowFunctions[i].trimmed().toLower().replace("function", "")) - { - if(mWindowFunction != 0) - { - delete mWindowFunction; - } - mWindowFunction = QWindowFunctionManager::createFunction(functionName); - if(mWindowFunction != 0 && isValidSize(mSize)) - { - mWindowFunction->create(mSize); - } - return true; - } - } - return false; + for (int i = 0; i < mWindowFunctions.size(); ++i) + { + if (functionName.trimmed().toLower().replace("function", "") + == mWindowFunctions[i].trimmed().toLower().replace("function", "")) + { + if (mWindowFunction != 0) + { + delete mWindowFunction; + } + mWindowFunction + = QWindowFunctionManager::createFunction(functionName); + if (mWindowFunction != 0 && isValidSize(mSize)) + { + mWindowFunction->create(mSize); + } + return true; + } + } + return false; } QStringList QFourierTransformer::windowFunctions() { - return mWindowFunctions; + return mWindowFunctions; } -void QFourierTransformer::transform(float input[], float output[], Direction direction) +void QFourierTransformer::transform(float input[], float output[], + Direction direction) { - if(direction == QFourierTransformer::Forward) - { - forwardTransform(input, output); - } - else - { - inverseTransform(input, output); - } + if (direction == QFourierTransformer::Forward) + { + forwardTransform(input, output); + } + else + { + inverseTransform(input, output); + } } void QFourierTransformer::forwardTransform(float *input, float *output) { - if(mWindowFunction != 0) - { - mWindowFunction->apply(input, mSize); - } - mCalculator->setData(input, output); - mCalculator->forward(); + if (mWindowFunction != 0) + { + mWindowFunction->apply(input, mSize); + } + mCalculator->setData(input, output); + mCalculator->forward(); } void QFourierTransformer::inverseTransform(float input[], float output[]) { - mCalculator->setData(input, output); - mCalculator->inverse(); + mCalculator->setData(input, output); + mCalculator->inverse(); } void QFourierTransformer::rescale(float input[]) { - mCalculator->setData(input); - mCalculator->rescale(); + mCalculator->setData(input); + mCalculator->rescale(); } void QFourierTransformer::initialize() { - mFixedCalculators.insert(3, new QFourierFixedCalculator<3>()); - mFixedCalculators.insert(4, new QFourierFixedCalculator<4>()); - mFixedCalculators.insert(5, new QFourierFixedCalculator<5>()); - mFixedCalculators.insert(6, new QFourierFixedCalculator<6>()); - mFixedCalculators.insert(7, new QFourierFixedCalculator<7>()); - mFixedCalculators.insert(8, new QFourierFixedCalculator<8>()); - mFixedCalculators.insert(9, new QFourierFixedCalculator<9>()); - mFixedCalculators.insert(10, new QFourierFixedCalculator<10>()); - mFixedCalculators.insert(11, new QFourierFixedCalculator<11>()); - mFixedCalculators.insert(12, new QFourierFixedCalculator<12>()); - mFixedCalculators.insert(13, new QFourierFixedCalculator<13>()); - mFixedCalculators.insert(14, new QFourierFixedCalculator<14>()); + mFixedCalculators.insert(3, new QFourierFixedCalculator<3>()); + mFixedCalculators.insert(4, new QFourierFixedCalculator<4>()); + mFixedCalculators.insert(5, new QFourierFixedCalculator<5>()); + mFixedCalculators.insert(6, new QFourierFixedCalculator<6>()); + mFixedCalculators.insert(7, new QFourierFixedCalculator<7>()); + mFixedCalculators.insert(8, new QFourierFixedCalculator<8>()); + mFixedCalculators.insert(9, new QFourierFixedCalculator<9>()); + mFixedCalculators.insert(10, new QFourierFixedCalculator<10>()); + mFixedCalculators.insert(11, new QFourierFixedCalculator<11>()); + mFixedCalculators.insert(12, new QFourierFixedCalculator<12>()); + mFixedCalculators.insert(13, new QFourierFixedCalculator<13>()); + mFixedCalculators.insert(14, new QFourierFixedCalculator<14>()); - mVariableCalculator = new QFourierVariableCalculator(); + mVariableCalculator = new QFourierVariableCalculator(); } int QFourierTransformer::sizeToKey(int size) { - float result = log(float(size)) / log(2.0); - if(result == float(int(result))) - { - return result; - } - return -1; + float result = log(float(size)) / log(2.0); + if (result == float(int(result))) + { + return result; + } + return -1; } bool QFourierTransformer::isValidSize(int value) { - return ((value > 0) && ((value & (~value + 1)) == value)); + return ((value > 0) && ((value & (~value + 1)) == value)); } void QFourierTransformer::conjugate(float input[]) { - for(int i = mSize / 2 + 1; i < mSize; ++i) - { - input[i] = -input[i]; - } + for (int i = mSize / 2 + 1; i < mSize; ++i) + { + input[i] = -input[i]; + } } QComplexVector QFourierTransformer::toComplex(float input[]) { - int last = mSize / 2; - QVector result(last + 1); - result[0] = QComplexFloat(input[0], 0); - for(int i = 1; i < last; ++i) - { - result[i] = QComplexFloat(input[i], -input[last + i]); - } - result[last] = QComplexFloat(input[last], 0); - return result; + int last = mSize / 2; + QVector result(last + 1); + result[0] = QComplexFloat(input[0], 0); + for (int i = 1; i < last; ++i) + { + result[i] = QComplexFloat(input[i], -input[last + i]); + } + result[last] = QComplexFloat(input[last], 0); + return result; } diff --git a/libs/QRealFourier/sources/qfouriervariablecalculator.cpp b/libs/QRealFourier/sources/qfouriervariablecalculator.cpp index f170b813..5b13315a 100644 --- a/libs/QRealFourier/sources/qfouriervariablecalculator.cpp +++ b/libs/QRealFourier/sources/qfouriervariablecalculator.cpp @@ -1,7 +1,7 @@ /*********************************************************************** qfouriervariablecalculator.cpp - Source file for - QFourierVariableCalculator + QFourierVariableCalculator Class for calculating FFts of a variable size. @@ -42,44 +42,44 @@ qrealfourier@gmail.com #include "qfouriervariablecalculator.h" QFourierVariableCalculator::QFourierVariableCalculator() - : QFourierCalculator() + : QFourierCalculator() { - mFourierTransform = 0; + mFourierTransform = 0; } QFourierVariableCalculator::~QFourierVariableCalculator() { - if(mFourierTransform != 0) - { - delete mFourierTransform; - } + if (mFourierTransform != 0) + { + delete mFourierTransform; + } } void QFourierVariableCalculator::setSize(int size) { - QFourierCalculator::setSize(size); - if(mFourierTransform == 0) - { - mFourierTransform = new ffft::FFTReal(mSize); - } - else if(mFourierTransform->get_length() != mSize) - { - delete mFourierTransform; - mFourierTransform = new ffft::FFTReal(mSize); - } + QFourierCalculator::setSize(size); + if (mFourierTransform == 0) + { + mFourierTransform = new ffft::FFTReal(mSize); + } + else if (mFourierTransform->get_length() != mSize) + { + delete mFourierTransform; + mFourierTransform = new ffft::FFTReal(mSize); + } } void QFourierVariableCalculator::forward() { - mFourierTransform->do_fft(mOutput, mInput); + mFourierTransform->do_fft(mOutput, mInput); } void QFourierVariableCalculator::inverse() { - mFourierTransform->do_ifft(mInput, mOutput); + mFourierTransform->do_ifft(mInput, mOutput); } void QFourierVariableCalculator::rescale() { - mFourierTransform->rescale(mInput); + mFourierTransform->rescale(mInput); } diff --git a/libs/QRealFourier/sources/qwindowfunction.cpp b/libs/QRealFourier/sources/qwindowfunction.cpp index 5d4533e8..5f82256a 100644 --- a/libs/QRealFourier/sources/qwindowfunction.cpp +++ b/libs/QRealFourier/sources/qwindowfunction.cpp @@ -1,8 +1,8 @@ /*********************************************************************** qwindowfunction.cpp - Source file for QWindowFunction, - QWindowFunctionManager, QRectangularFunction, - QHammingFunction, QHannFunction + QWindowFunctionManager, +QRectangularFunction, QHammingFunction, QHannFunction Template classes necessary for applying a window function to a discrete set of samples. @@ -47,33 +47,33 @@ qrealfourier@gmail.com QWindowFunction ***********************************************************************/ -template +template void QWindowFunction::apply(T *data, int size) { - for(int i = 0; i < size; ++i) - { - data[i] *= mWindow[i]; - } + for (int i = 0; i < size; ++i) + { + data[i] *= mWindow[i]; + } } -template +template void QWindowFunction::create(int size) { - if(size != mWindow.size()) - { - mWindow.clear(); - mWindow.resize(size); - fillWindow(size); - } + if (size != mWindow.size()) + { + mWindow.clear(); + mWindow.resize(size); + fillWindow(size); + } } -template +template void QWindowFunction::fillWindow(int size) { - for(int i = 0; i < size; ++i) - { - mWindow[i] = calculate(i, size); - } + for (int i = 0; i < size; ++i) + { + mWindow[i] = calculate(i, size); + } } template class QWindowFunction; @@ -86,27 +86,28 @@ template class QWindowFunction; QWindowFunctionManager ***********************************************************************/ -template -QWindowFunction* QWindowFunctionManager::createFunction(QString functionName) +template +QWindowFunction * +QWindowFunctionManager::createFunction(QString functionName) { - functionName = functionName.trimmed().toLower().replace("function", ""); - if(functionName == "hamming") - { - return new QHammingFunction; - } - else if(functionName == "hann") - { - return new QHannFunction; - } - return NULL; + functionName = functionName.trimmed().toLower().replace("function", ""); + if (functionName == "hamming") + { + return new QHammingFunction; + } + else if (functionName == "hann") + { + return new QHannFunction; + } + return NULL; } -template +template QStringList QWindowFunctionManager::functions() { - QStringList result; - result << "Rectangular" << "Hamming" << "Hann"; - return result; + QStringList result; + result << "Rectangular" << "Hamming" << "Hann"; + return result; } template class QWindowFunctionManager; @@ -119,13 +120,13 @@ template class QWindowFunctionManager; QRectangularFunction ***********************************************************************/ -template +template T QRectangularFunction::calculate(int currentSample, int totalSamples) { - (void) currentSample; - (void) totalSamples; + (void)currentSample; + (void)totalSamples; - return 1.0; + return 1.0; } template class QRectangularFunction; @@ -138,10 +139,10 @@ template class QRectangularFunction; QHammingFunction ***********************************************************************/ -template +template T QHammingFunction::calculate(int currentSample, int totalSamples) { - return 0.54 + (0.46 * qCos((2 * M_PI * currentSample) / (totalSamples - 1))); + return 0.54 + (0.46 * qCos((2 * M_PI * currentSample) / (totalSamples - 1))); } template class QHammingFunction; @@ -154,10 +155,10 @@ template class QHammingFunction; QHannFunction ***********************************************************************/ -template +template T QHannFunction::calculate(int currentSample, int totalSamples) { - return 0.5 * (1 - qCos((2 * M_PI * currentSample) / (totalSamples - 1))); + return 0.5 * (1 - qCos((2 * M_PI * currentSample) / (totalSamples - 1))); } template class QHannFunction; diff --git a/libs/QSourceHighlite/languagedata.cpp b/libs/QSourceHighlite/languagedata.cpp old mode 100755 new mode 100644 index dc416f87..2a8f9201 --- a/libs/QSourceHighlite/languagedata.cpp +++ b/libs/QSourceHighlite/languagedata.cpp @@ -8,8 +8,8 @@ * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -33,7 +33,8 @@ * types are built-in types i.e, int, char, var * literals are words like, true false * builtin are the library functions - * other can contain any other thing, for e.g, in cpp it contains the preprocessor + * other can contain any other thing, for e.g, in cpp it contains the + preprocessor xxx_keywords = { }; @@ -52,7 +53,8 @@ */ -namespace QSourceHighlite { +namespace QSourceHighlite +{ /**********************************************************/ /* LuaData ************************************************/ @@ -64,100 +66,80 @@ static LanguageData lua_types; static LanguageData lua_builtin; static LanguageData lua_literals; static LanguageData lua_other; -void initLuaData() { - lua_keywords = LanguageData{ - {('a'), QLatin1String("and")}, - {('b'), QLatin1String("break")}, - {('d'), QLatin1String("do")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("elseif")}, - {('e'), QLatin1String("end")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("function")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("in")}, - {('l'), QLatin1String("local")}, - {('n'), QLatin1String("not")}, - {('o'), QLatin1String("or")}, - {('r'), QLatin1String("repeat")}, - {('r'), QLatin1String("require")}, - {('r'), QLatin1String("return")}, - {('t'), QLatin1String("then")}, - {('u'), QLatin1String("until")}, - {('w'), QLatin1String("while")}}; +void initLuaData() +{ + lua_keywords = LanguageData{ + {('a'), QLatin1String("and")}, {('b'), QLatin1String("break")}, + {('d'), QLatin1String("do")}, {('e'), QLatin1String("else")}, + {('e'), QLatin1String("elseif")}, {('e'), QLatin1String("end")}, + {('f'), QLatin1String("for")}, {('f'), QLatin1String("function")}, + {('i'), QLatin1String("if")}, {('i'), QLatin1String("in")}, + {('l'), QLatin1String("local")}, {('n'), QLatin1String("not")}, + {('o'), QLatin1String("or")}, {('r'), QLatin1String("repeat")}, + {('r'), QLatin1String("require")}, {('r'), QLatin1String("return")}, + {('t'), QLatin1String("then")}, {('u'), QLatin1String("until")}, + {('w'), QLatin1String("while")}}; - lua_literals = LanguageData{ - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("nil")}, - {('t'), QLatin1String("true")}}; + lua_literals = LanguageData{{('f'), QLatin1String("false")}, + {('n'), QLatin1String("nil")}, + {('t'), QLatin1String("true")}}; - lua_other = LanguageData{ - {('_'), QLatin1String("_G")}, - {('_'), QLatin1String("__add")}, - {('_'), QLatin1String("__call")}, - {('_'), QLatin1String("__contact")}, - {('_'), QLatin1String("__div")}, - {('_'), QLatin1String("__eq")}, - {('_'), QLatin1String("__index")}, - {('_'), QLatin1String("__le")}, - {('_'), QLatin1String("__lt")}, - {('_'), QLatin1String("__mod")}, - {('_'), QLatin1String("__mul")}, - {('_'), QLatin1String("__newindex")}, - {('_'), QLatin1String("__sub")}, - {('_'), QLatin1String("__tostring")}, - {('_'), QLatin1String("__unm")} - }; - - lua_builtin = LanguageData{ - {('d'), QLatin1String("debug")}, - {('d'), QLatin1String("dofile")}, - {('g'), QLatin1String("getfenv")}, - {('g'), QLatin1String("gethook")}, - {('g'), QLatin1String("getinfo")}, - {('g'), QLatin1String("getlocal")}, - {('g'), QLatin1String("getmetatable")}, - {('g'), QLatin1String("getregistry")}, - {('g'), QLatin1String("getupvalue")}, - {('i'), QLatin1String("ipairs")}, - {('l'), QLatin1String("load")}, - {('l'), QLatin1String("loadfile")}, - {('l'), QLatin1String("loadstring")}, - {('n'), QLatin1String("next")}, - {('p'), QLatin1String("pairs")}, - {('p'), QLatin1String("print")}, - {('r'), QLatin1String("rawequal")}, - {('r'), QLatin1String("rawget")}, - {('r'), QLatin1String("rawset")}, - {('s'), QLatin1String("select")}, - {('s'), QLatin1String("setfenv")}, - {('s'), QLatin1String("sethook")}, - {('s'), QLatin1String("setlocal")}, - {('s'), QLatin1String("setmetatable")}, - {('s'), QLatin1String("setupvalue")}, - {('t'), QLatin1String("tonumber")}, - {('t'), QLatin1String("tostring")}, - {('t'), QLatin1String("traceback")}, - {('t'), QLatin1String("type")}, - {('u'), QLatin1String("unpack")} - }; + lua_other = LanguageData{ + {('_'), QLatin1String("_G")}, {('_'), QLatin1String("__add")}, + {('_'), QLatin1String("__call")}, {('_'), QLatin1String("__contact")}, + {('_'), QLatin1String("__div")}, {('_'), QLatin1String("__eq")}, + {('_'), QLatin1String("__index")}, {('_'), QLatin1String("__le")}, + {('_'), QLatin1String("__lt")}, {('_'), QLatin1String("__mod")}, + {('_'), QLatin1String("__mul")}, {('_'), QLatin1String("__newindex")}, + {('_'), QLatin1String("__sub")}, {('_'), QLatin1String("__tostring")}, + {('_'), QLatin1String("__unm")}}; + lua_builtin = LanguageData{{('d'), QLatin1String("debug")}, + {('d'), QLatin1String("dofile")}, + {('g'), QLatin1String("getfenv")}, + {('g'), QLatin1String("gethook")}, + {('g'), QLatin1String("getinfo")}, + {('g'), QLatin1String("getlocal")}, + {('g'), QLatin1String("getmetatable")}, + {('g'), QLatin1String("getregistry")}, + {('g'), QLatin1String("getupvalue")}, + {('i'), QLatin1String("ipairs")}, + {('l'), QLatin1String("load")}, + {('l'), QLatin1String("loadfile")}, + {('l'), QLatin1String("loadstring")}, + {('n'), QLatin1String("next")}, + {('p'), QLatin1String("pairs")}, + {('p'), QLatin1String("print")}, + {('r'), QLatin1String("rawequal")}, + {('r'), QLatin1String("rawget")}, + {('r'), QLatin1String("rawset")}, + {('s'), QLatin1String("select")}, + {('s'), QLatin1String("setfenv")}, + {('s'), QLatin1String("sethook")}, + {('s'), QLatin1String("setlocal")}, + {('s'), QLatin1String("setmetatable")}, + {('s'), QLatin1String("setupvalue")}, + {('t'), QLatin1String("tonumber")}, + {('t'), QLatin1String("tostring")}, + {('t'), QLatin1String("traceback")}, + {('t'), QLatin1String("type")}, + {('u'), QLatin1String("unpack")}}; } -void loadLuaData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others){ - if (!luaDataInitialized) { - initLuaData(); - luaDataInitialized = true; - } - typess = lua_types; - keywordss = lua_keywords; - builtins = lua_builtin; - literalss = lua_literals; - others = lua_other; +void loadLuaData(LanguageData &typess, LanguageData &keywordss, + LanguageData &builtins, LanguageData &literalss, + LanguageData &others) +{ + if (!luaDataInitialized) + { + initLuaData(); + luaDataInitialized = true; + } + typess = lua_types; + keywordss = lua_keywords; + builtins = lua_builtin; + literalss = lua_literals; + others = lua_other; } /**********************************************************/ @@ -170,286 +152,272 @@ static LanguageData cpp_types; static LanguageData cpp_builtin; static LanguageData cpp_literals; static LanguageData cpp_other; -void initCppData() { - cpp_keywords = LanguageData{ - {('a'), QLatin1String("alignas")}, - {('a'), QLatin1String("alignof")}, - {('a'), QLatin1String("and")}, - {('a'), QLatin1String("and_eq")}, - {('a'), QLatin1String("asm")}, - {('b'), QLatin1String("bit_and")}, - {('b'), QLatin1String("bit_or")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("compl")}, - {('c'), QLatin1String("concept")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("constinit")}, - {('c'), QLatin1String("constexpr")}, - {('c'), QLatin1String("consteval")}, - {('c'), QLatin1String("const_cast")}, - {('c'), QLatin1String("continue")}, - {('c'), QLatin1String("co_await")}, - {('c'), QLatin1String("co_return")}, - {('c'), QLatin1String("co_yield")}, - {('d'), QLatin1String("decltype")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("delete")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("dynamic_cast")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("explicit")}, - {('e'), QLatin1String("export")}, - {('e'), QLatin1String("extern")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("friend")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("inline")}, - {('m'), QLatin1String("mutable")}, - {('n'), QLatin1String("new")}, - {('n'), QLatin1String("not")}, - {('n'), QLatin1String("not_eq")}, - {('n'), QLatin1String("noexcept")}, - {('o'), QLatin1String("or")}, - {('o'), QLatin1String("or_eq")}, - {('o'), QLatin1String("operator")}, - {('p'), QLatin1String("private")}, - {('p'), QLatin1String("protected")}, - {('p'), QLatin1String("public")}, - {('r'), QLatin1String("register")}, - {('r'), QLatin1String("reinterpret_cast")}, - {('r'), QLatin1String("requires")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("signal")}, - {('s'), QLatin1String("sizeof")}, - {('s'), QLatin1String("slot")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("static_assert")}, - {('s'), QLatin1String("static_cast")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("template")}, - {('t'), QLatin1String("this")}, - {('t'), QLatin1String("thread_local")}, - {('t'), QLatin1String("throw")}, - {('t'), QLatin1String("try")}, - {('t'), QLatin1String("typeid")}, - {('t'), QLatin1String("typedef")}, - {('t'), QLatin1String("typename")}, - {('u'), QLatin1String("using")}, - {('v'), QLatin1String("volatile")}, - {('w'), QLatin1String("while")}, - {('x'), QLatin1String("xor")}, - {('x'), QLatin1String("xor_eq")}}; +void initCppData() +{ + cpp_keywords = LanguageData{{('a'), QLatin1String("alignas")}, + {('a'), QLatin1String("alignof")}, + {('a'), QLatin1String("and")}, + {('a'), QLatin1String("and_eq")}, + {('a'), QLatin1String("asm")}, + {('b'), QLatin1String("bit_and")}, + {('b'), QLatin1String("bit_or")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("compl")}, + {('c'), QLatin1String("concept")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("constinit")}, + {('c'), QLatin1String("constexpr")}, + {('c'), QLatin1String("consteval")}, + {('c'), QLatin1String("const_cast")}, + {('c'), QLatin1String("continue")}, + {('c'), QLatin1String("co_await")}, + {('c'), QLatin1String("co_return")}, + {('c'), QLatin1String("co_yield")}, + {('d'), QLatin1String("decltype")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("delete")}, + {('d'), QLatin1String("do")}, + {('d'), QLatin1String("dynamic_cast")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("explicit")}, + {('e'), QLatin1String("export")}, + {('e'), QLatin1String("extern")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("friend")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("inline")}, + {('m'), QLatin1String("mutable")}, + {('n'), QLatin1String("new")}, + {('n'), QLatin1String("not")}, + {('n'), QLatin1String("not_eq")}, + {('n'), QLatin1String("noexcept")}, + {('o'), QLatin1String("or")}, + {('o'), QLatin1String("or_eq")}, + {('o'), QLatin1String("operator")}, + {('p'), QLatin1String("private")}, + {('p'), QLatin1String("protected")}, + {('p'), QLatin1String("public")}, + {('r'), QLatin1String("register")}, + {('r'), QLatin1String("reinterpret_cast")}, + {('r'), QLatin1String("requires")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("signal")}, + {('s'), QLatin1String("sizeof")}, + {('s'), QLatin1String("slot")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("static_assert")}, + {('s'), QLatin1String("static_cast")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("template")}, + {('t'), QLatin1String("this")}, + {('t'), QLatin1String("thread_local")}, + {('t'), QLatin1String("throw")}, + {('t'), QLatin1String("try")}, + {('t'), QLatin1String("typeid")}, + {('t'), QLatin1String("typedef")}, + {('t'), QLatin1String("typename")}, + {('u'), QLatin1String("using")}, + {('v'), QLatin1String("volatile")}, + {('w'), QLatin1String("while")}, + {('x'), QLatin1String("xor")}, + {('x'), QLatin1String("xor_eq")}}; - cpp_types = { - {('a'), QLatin1String("auto")}, - {('b'), QLatin1String("bool")}, - {('c'), QLatin1String("char")}, - {('c'), QLatin1String("char8_t")}, - {('c'), QLatin1String("char16_t")}, - {('c'), QLatin1String("char32_t")}, - {('c'), QLatin1String("class")}, - {('d'), QLatin1String("double")}, - {('e'), QLatin1String("enum")}, - {('f'), QLatin1String("float")}, - {('i'), QLatin1String("int")}, - {('i'), QLatin1String("int8_t")}, - {('i'), QLatin1String("int16_t")}, - {('i'), QLatin1String("int32_t")}, - {('i'), QLatin1String("int64_t")}, - {('i'), QLatin1String("int_fast8_t")}, - {('i'), QLatin1String("int_fast16_t")}, - {('i'), QLatin1String("int_fast32_t")}, - {('i'), QLatin1String("int_fast64_t")}, - {('i'), QLatin1String("intmax_t")}, - {('i'), QLatin1String("intptr_t")}, - {('l'), QLatin1String("long")}, - {('n'), QLatin1String("namespace")}, - {('Q'), QLatin1String("QHash")}, - {('Q'), QLatin1String("QList")}, - {('Q'), QLatin1String("QMap")}, - {('Q'), QLatin1String("QString")}, - {('Q'), QLatin1String("QVector")}, - {('s'), QLatin1String("short")}, - {('s'), QLatin1String("size_t")}, - {('s'), QLatin1String("signed")}, - {('s'), QLatin1String("struct")}, - {('s'), QLatin1String("ssize_t")}, - {('u'), QLatin1String("uint8_t")}, - {('u'), QLatin1String("uint16_t")}, - {('u'), QLatin1String("uint32_t")}, - {('u'), QLatin1String("uint64_t")}, - {('u'), QLatin1String("uint_fast8_t")}, - {('u'), QLatin1String("uint_fast16_t")}, - {('u'), QLatin1String("uint_fast32_t")}, - {('u'), QLatin1String("uint_fast64_t")}, - {('u'), QLatin1String("uint_least8_t")}, - {('u'), QLatin1String("uint_least16_t")}, - {('u'), QLatin1String("uint_least32_t")}, - {('u'), QLatin1String("uint_least64_t")}, - {('u'), QLatin1String("uintmax_t")}, - {('u'), QLatin1String("uintptr_t")}, - {('u'), QLatin1String("unsigned")}, - {('u'), QLatin1String("union")}, - {('v'), QLatin1String("void")}, - {('w'), QLatin1String("wchar_t")}}; + cpp_types = {{('a'), QLatin1String("auto")}, + {('b'), QLatin1String("bool")}, + {('c'), QLatin1String("char")}, + {('c'), QLatin1String("char8_t")}, + {('c'), QLatin1String("char16_t")}, + {('c'), QLatin1String("char32_t")}, + {('c'), QLatin1String("class")}, + {('d'), QLatin1String("double")}, + {('e'), QLatin1String("enum")}, + {('f'), QLatin1String("float")}, + {('i'), QLatin1String("int")}, + {('i'), QLatin1String("int8_t")}, + {('i'), QLatin1String("int16_t")}, + {('i'), QLatin1String("int32_t")}, + {('i'), QLatin1String("int64_t")}, + {('i'), QLatin1String("int_fast8_t")}, + {('i'), QLatin1String("int_fast16_t")}, + {('i'), QLatin1String("int_fast32_t")}, + {('i'), QLatin1String("int_fast64_t")}, + {('i'), QLatin1String("intmax_t")}, + {('i'), QLatin1String("intptr_t")}, + {('l'), QLatin1String("long")}, + {('n'), QLatin1String("namespace")}, + {('Q'), QLatin1String("QHash")}, + {('Q'), QLatin1String("QList")}, + {('Q'), QLatin1String("QMap")}, + {('Q'), QLatin1String("QString")}, + {('Q'), QLatin1String("QVector")}, + {('s'), QLatin1String("short")}, + {('s'), QLatin1String("size_t")}, + {('s'), QLatin1String("signed")}, + {('s'), QLatin1String("struct")}, + {('s'), QLatin1String("ssize_t")}, + {('u'), QLatin1String("uint8_t")}, + {('u'), QLatin1String("uint16_t")}, + {('u'), QLatin1String("uint32_t")}, + {('u'), QLatin1String("uint64_t")}, + {('u'), QLatin1String("uint_fast8_t")}, + {('u'), QLatin1String("uint_fast16_t")}, + {('u'), QLatin1String("uint_fast32_t")}, + {('u'), QLatin1String("uint_fast64_t")}, + {('u'), QLatin1String("uint_least8_t")}, + {('u'), QLatin1String("uint_least16_t")}, + {('u'), QLatin1String("uint_least32_t")}, + {('u'), QLatin1String("uint_least64_t")}, + {('u'), QLatin1String("uintmax_t")}, + {('u'), QLatin1String("uintptr_t")}, + {('u'), QLatin1String("unsigned")}, + {('u'), QLatin1String("union")}, + {('v'), QLatin1String("void")}, + {('w'), QLatin1String("wchar_t")}}; - cpp_literals = { - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("nullptr")}, - {('N'), QLatin1String("NULL")}, - {('t'), QLatin1String("true")} - }; + cpp_literals = {{('f'), QLatin1String("false")}, + {('n'), QLatin1String("nullptr")}, + {('N'), QLatin1String("NULL")}, + {('t'), QLatin1String("true")}}; - cpp_builtin = { - {('s'), QLatin1String("std")}, - {('s'), QLatin1String("string")}, - {('w'), QLatin1String("wstring")}, - {('c'), QLatin1String("cin")}, - {('c'), QLatin1String("cout")}, - {('c'), QLatin1String("cerr")}, - {('c'), QLatin1String("clog")}, - {('s'), QLatin1String("stdin")}, - {('s'), QLatin1String("stdout")}, - {('s'), QLatin1String("stderr")}, - {('s'), QLatin1String("stringstream")}, - {('i'), QLatin1String("istringstream")}, - {('o'), QLatin1String("ostringstream")}, - {('a'), QLatin1String("auto_ptr")}, - {('d'), QLatin1String("deque")}, - {('l'), QLatin1String("list")}, - {('q'), QLatin1String("queue")}, - {('s'), QLatin1String("stack")}, - {('v'), QLatin1String("vector")}, - {('m'), QLatin1String("map")}, - {('s'), QLatin1String("set")}, - {('b'), QLatin1String("bitset")}, - {('m'), QLatin1String("multiset")}, - {('m'), QLatin1String("multimap")}, - {('u'), QLatin1String("unordered_set")}, - {('u'), QLatin1String("unordered_map")}, - {('u'), QLatin1String("unordered_multiset")}, - {('u'), QLatin1String("unordered_multimap")}, - {('a'), QLatin1String("array")}, - {('s'), QLatin1String("shared_ptr")}, - {('a'), QLatin1String("abort")}, - {('t'), QLatin1String("terminate")}, - {('a'), QLatin1String("abs")}, - {('a'), QLatin1String("acos")}, - {('a'), QLatin1String("asin")}, - {('a'), QLatin1String("atan2")}, - {('a'), QLatin1String("atan")}, - {('c'), QLatin1String("calloc")}, - {('c'), QLatin1String("ceil")}, - {('c'), QLatin1String("cosh")}, - {('c'), QLatin1String("cos")}, - {('e'), QLatin1String("exit")}, - {('e'), QLatin1String("exp")}, - {('f'), QLatin1String("fabs")}, - {('f'), QLatin1String("floor")}, - {('f'), QLatin1String("fmod")}, - {('f'), QLatin1String("fprintf")}, - {('f'), QLatin1String("fputs")}, - {('f'), QLatin1String("free")}, - {('f'), QLatin1String("frexp")}, - {('f'), QLatin1String("fscanf")}, - {('f'), QLatin1String("future")}, - {('i'), QLatin1String("isalnum")}, - {('i'), QLatin1String("isalpha")}, - {('i'), QLatin1String("iscntrl")}, - {('i'), QLatin1String("isdigit")}, - {('i'), QLatin1String("isgraph")}, - {('i'), QLatin1String("islower")}, - {('i'), QLatin1String("isprint")}, - {('i'), QLatin1String("ispunct")}, - {('i'), QLatin1String("isspace")}, - {('i'), QLatin1String("isupper")}, - {('i'), QLatin1String("isxdigit")}, - {('t'), QLatin1String("tolower")}, - {('t'), QLatin1String("toupper")}, - {('l'), QLatin1String("labs")}, - {('l'), QLatin1String("ldexp")}, - {('l'), QLatin1String("log10")}, - {('l'), QLatin1String("log")}, - {('m'), QLatin1String("malloc")}, - {('r'), QLatin1String("realloc")}, - {('m'), QLatin1String("main")}, - {('m'), QLatin1String("memchr")}, - {('m'), QLatin1String("memcmp")}, - {('m'), QLatin1String("memcpy")}, - {('m'), QLatin1String("memset")}, - {('m'), QLatin1String("modf")}, - {('p'), QLatin1String("pow")}, - {('p'), QLatin1String("printf")}, - {('p'), QLatin1String("putchar")}, - {('p'), QLatin1String("puts")}, - {('s'), QLatin1String("scanf")}, - {('s'), QLatin1String("sinh")}, - {('s'), QLatin1String("sin")}, - {('s'), QLatin1String("snprintf")}, - {('s'), QLatin1String("sprintf")}, - {('s'), QLatin1String("sqrt")}, - {('s'), QLatin1String("sscanf")}, - {('s'), QLatin1String("strcat")}, - {('s'), QLatin1String("strchr")}, - {('s'), QLatin1String("strcmp")}, - {('s'), QLatin1String("strcpy")}, - {('s'), QLatin1String("strcspn")}, - {('s'), QLatin1String("strlen")}, - {('s'), QLatin1String("strncat")}, - {('s'), QLatin1String("strncmp")}, - {('s'), QLatin1String("strncpy")}, - {('s'), QLatin1String("strpbrk")}, - {('s'), QLatin1String("strrchr")}, - {('s'), QLatin1String("strspn")}, - {('s'), QLatin1String("strstr")}, - {('t'), QLatin1String("tanh")}, - {('t'), QLatin1String("tan")}, - {('v'), QLatin1String("vfprintf")}, - {('v'), QLatin1String("vprintf")}, - {('v'), QLatin1String("vsprintf")}, - {('e'), QLatin1String("endl")}, - {('i'), QLatin1String("initializer_list")}, - {('u'), QLatin1String("unique_ptr")}, - {('c'), QLatin1String("complex")}, - {('i'), QLatin1String("imaginary")} - }; + cpp_builtin = {{('s'), QLatin1String("std")}, + {('s'), QLatin1String("string")}, + {('w'), QLatin1String("wstring")}, + {('c'), QLatin1String("cin")}, + {('c'), QLatin1String("cout")}, + {('c'), QLatin1String("cerr")}, + {('c'), QLatin1String("clog")}, + {('s'), QLatin1String("stdin")}, + {('s'), QLatin1String("stdout")}, + {('s'), QLatin1String("stderr")}, + {('s'), QLatin1String("stringstream")}, + {('i'), QLatin1String("istringstream")}, + {('o'), QLatin1String("ostringstream")}, + {('a'), QLatin1String("auto_ptr")}, + {('d'), QLatin1String("deque")}, + {('l'), QLatin1String("list")}, + {('q'), QLatin1String("queue")}, + {('s'), QLatin1String("stack")}, + {('v'), QLatin1String("vector")}, + {('m'), QLatin1String("map")}, + {('s'), QLatin1String("set")}, + {('b'), QLatin1String("bitset")}, + {('m'), QLatin1String("multiset")}, + {('m'), QLatin1String("multimap")}, + {('u'), QLatin1String("unordered_set")}, + {('u'), QLatin1String("unordered_map")}, + {('u'), QLatin1String("unordered_multiset")}, + {('u'), QLatin1String("unordered_multimap")}, + {('a'), QLatin1String("array")}, + {('s'), QLatin1String("shared_ptr")}, + {('a'), QLatin1String("abort")}, + {('t'), QLatin1String("terminate")}, + {('a'), QLatin1String("abs")}, + {('a'), QLatin1String("acos")}, + {('a'), QLatin1String("asin")}, + {('a'), QLatin1String("atan2")}, + {('a'), QLatin1String("atan")}, + {('c'), QLatin1String("calloc")}, + {('c'), QLatin1String("ceil")}, + {('c'), QLatin1String("cosh")}, + {('c'), QLatin1String("cos")}, + {('e'), QLatin1String("exit")}, + {('e'), QLatin1String("exp")}, + {('f'), QLatin1String("fabs")}, + {('f'), QLatin1String("floor")}, + {('f'), QLatin1String("fmod")}, + {('f'), QLatin1String("fprintf")}, + {('f'), QLatin1String("fputs")}, + {('f'), QLatin1String("free")}, + {('f'), QLatin1String("frexp")}, + {('f'), QLatin1String("fscanf")}, + {('f'), QLatin1String("future")}, + {('i'), QLatin1String("isalnum")}, + {('i'), QLatin1String("isalpha")}, + {('i'), QLatin1String("iscntrl")}, + {('i'), QLatin1String("isdigit")}, + {('i'), QLatin1String("isgraph")}, + {('i'), QLatin1String("islower")}, + {('i'), QLatin1String("isprint")}, + {('i'), QLatin1String("ispunct")}, + {('i'), QLatin1String("isspace")}, + {('i'), QLatin1String("isupper")}, + {('i'), QLatin1String("isxdigit")}, + {('t'), QLatin1String("tolower")}, + {('t'), QLatin1String("toupper")}, + {('l'), QLatin1String("labs")}, + {('l'), QLatin1String("ldexp")}, + {('l'), QLatin1String("log10")}, + {('l'), QLatin1String("log")}, + {('m'), QLatin1String("malloc")}, + {('r'), QLatin1String("realloc")}, + {('m'), QLatin1String("main")}, + {('m'), QLatin1String("memchr")}, + {('m'), QLatin1String("memcmp")}, + {('m'), QLatin1String("memcpy")}, + {('m'), QLatin1String("memset")}, + {('m'), QLatin1String("modf")}, + {('p'), QLatin1String("pow")}, + {('p'), QLatin1String("printf")}, + {('p'), QLatin1String("putchar")}, + {('p'), QLatin1String("puts")}, + {('s'), QLatin1String("scanf")}, + {('s'), QLatin1String("sinh")}, + {('s'), QLatin1String("sin")}, + {('s'), QLatin1String("snprintf")}, + {('s'), QLatin1String("sprintf")}, + {('s'), QLatin1String("sqrt")}, + {('s'), QLatin1String("sscanf")}, + {('s'), QLatin1String("strcat")}, + {('s'), QLatin1String("strchr")}, + {('s'), QLatin1String("strcmp")}, + {('s'), QLatin1String("strcpy")}, + {('s'), QLatin1String("strcspn")}, + {('s'), QLatin1String("strlen")}, + {('s'), QLatin1String("strncat")}, + {('s'), QLatin1String("strncmp")}, + {('s'), QLatin1String("strncpy")}, + {('s'), QLatin1String("strpbrk")}, + {('s'), QLatin1String("strrchr")}, + {('s'), QLatin1String("strspn")}, + {('s'), QLatin1String("strstr")}, + {('t'), QLatin1String("tanh")}, + {('t'), QLatin1String("tan")}, + {('v'), QLatin1String("vfprintf")}, + {('v'), QLatin1String("vprintf")}, + {('v'), QLatin1String("vsprintf")}, + {('e'), QLatin1String("endl")}, + {('i'), QLatin1String("initializer_list")}, + {('u'), QLatin1String("unique_ptr")}, + {('c'), QLatin1String("complex")}, + {('i'), QLatin1String("imaginary")}}; - cpp_other = { - {('d'), QLatin1String("define")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("elif")}, - {('e'), QLatin1String("endif")}, - {('e'), QLatin1String("error")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("ifdef")}, - {('i'), QLatin1String("ifndef")}, - {('i'), QLatin1String("include")}, - {('l'), QLatin1String("line")}, - {('p'), QLatin1String("pragma")}, - {('P'), QLatin1String("_Pragma")}, - {('u'), QLatin1String("undef")}, - {('w'), QLatin1String("warning")} - }; + cpp_other + = {{('d'), QLatin1String("define")}, {('e'), QLatin1String("else")}, + {('e'), QLatin1String("elif")}, {('e'), QLatin1String("endif")}, + {('e'), QLatin1String("error")}, {('i'), QLatin1String("if")}, + {('i'), QLatin1String("ifdef")}, {('i'), QLatin1String("ifndef")}, + {('i'), QLatin1String("include")}, {('l'), QLatin1String("line")}, + {('p'), QLatin1String("pragma")}, {('P'), QLatin1String("_Pragma")}, + {('u'), QLatin1String("undef")}, {('w'), QLatin1String("warning")}}; } -void loadCppData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others){ - if (!cppDataInitialized) { - initCppData(); - cppDataInitialized = true; - } - - typess = cpp_types; - keywordss = cpp_keywords; - builtins = cpp_builtin; - literalss = cpp_literals; - others = cpp_other; +void loadCppData(LanguageData &typess, LanguageData &keywordss, + LanguageData &builtins, LanguageData &literalss, + LanguageData &others) +{ + if (!cppDataInitialized) + { + initCppData(); + cppDataInitialized = true; + } + typess = cpp_types; + keywordss = cpp_keywords; + builtins = cpp_builtin; + literalss = cpp_literals; + others = cpp_other; } /**********************************************************/ @@ -462,187 +430,176 @@ static LanguageData shell_types; static LanguageData shell_literals; static LanguageData shell_builtin; static LanguageData shell_other; -void initShellData() { - shell_keywords = { - {('i'), QLatin1String("if")}, - {('t'), QLatin1String("then")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("elif")}, - {('f'), QLatin1String("fi")}, - {('f'), QLatin1String("for")}, - {('w'), QLatin1String("while")}, - {('i'), QLatin1String("in")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("done")}, - {('c'), QLatin1String("case")}, - {('e'), QLatin1String("esac")}, - {('f'), QLatin1String("function")} - }; +void initShellData() +{ + shell_keywords + = {{('i'), QLatin1String("if")}, {('t'), QLatin1String("then")}, + {('e'), QLatin1String("else")}, {('e'), QLatin1String("elif")}, + {('f'), QLatin1String("fi")}, {('f'), QLatin1String("for")}, + {('w'), QLatin1String("while")}, {('i'), QLatin1String("in")}, + {('d'), QLatin1String("do")}, {('d'), QLatin1String("done")}, + {('c'), QLatin1String("case")}, {('e'), QLatin1String("esac")}, + {('f'), QLatin1String("function")}}; - shell_types = {}; + shell_types = {}; - shell_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} - }; + shell_literals + = {{('f'), QLatin1String("false")}, {('t'), QLatin1String("true")}}; - shell_builtin = { - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("cd")}, - {('c'), QLatin1String("continue")}, - {('e'), QLatin1String("eval")}, - {('e'), QLatin1String("exec")}, - {('e'), QLatin1String("exit")}, - {('e'), QLatin1String("export")}, - {('g'), QLatin1String("getopts")}, - {('h'), QLatin1String("hash")}, - {('p'), QLatin1String("pwd")}, - {('r'), QLatin1String("readonly")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("shift")}, - {('t'), QLatin1String("test")}, - {('t'), QLatin1String("timestrap")}, - {('u'), QLatin1String("umask")}, - {('u'), QLatin1String("unset")}, - {('B'), QLatin1String("Bash")}, - {('a'), QLatin1String("alias")}, - {('b'), QLatin1String("bind")}, - {('b'), QLatin1String("builtin")}, - {('c'), QLatin1String("caller")}, - {('c'), QLatin1String("command")}, - {('d'), QLatin1String("declare")}, - {('e'), QLatin1String("echo")}, - {('e'), QLatin1String("enable")}, - {('h'), QLatin1String("help")}, - {('l'), QLatin1String("let")}, - {('l'), QLatin1String("local")}, - {('l'), QLatin1String("logout")}, - {('m'), QLatin1String("mapfile")}, - {('p'), QLatin1String("printfread")}, - {('r'), QLatin1String("readarray")}, - {('s'), QLatin1String("source")}, - {('t'), QLatin1String("type")}, - {('t'), QLatin1String("typeset")}, - {('u'), QLatin1String("ulimit")}, - {('u'), QLatin1String("unalias")}, - {('m'), QLatin1String("modifiers")}, - {('s'), QLatin1String("set")}, - {('s'), QLatin1String("shopt")}, - {('a'), QLatin1String("autoload")}, - {('b'), QLatin1String("bg")}, - {('b'), QLatin1String("bindkey")}, - {('b'), QLatin1String("bye")}, - {('c'), QLatin1String("cap")}, - {('c'), QLatin1String("chdir")}, - {('c'), QLatin1String("clone")}, - {('c'), QLatin1String("comparguments")}, - {('c'), QLatin1String("compcall")}, - {('c'), QLatin1String("compctl")}, - {('c'), QLatin1String("compdescribe")}, - {('c'), QLatin1String("compfilescompgroups")}, - {('c'), QLatin1String("compquote")}, - {('c'), QLatin1String("comptags")}, - {('c'), QLatin1String("comptry")}, - {('c'), QLatin1String("compvalues")}, - {('d'), QLatin1String("dirs")}, - {('d'), QLatin1String("disable")}, - {('d'), QLatin1String("disown")}, - {('e'), QLatin1String("echotc")}, - {('e'), QLatin1String("echoti")}, - {('e'), QLatin1String("emulatefc")}, - {('f'), QLatin1String("fg")}, - {('f'), QLatin1String("float")}, - {('f'), QLatin1String("functions")}, - {('g'), QLatin1String("getcap")}, - {('g'), QLatin1String("getln")}, - {('h'), QLatin1String("history")}, - {('i'), QLatin1String("integer")}, - {('j'), QLatin1String("jobs")}, - {('k'), QLatin1String("kill")}, - {('l'), QLatin1String("limit")}, - {('l'), QLatin1String("log")}, - {('n'), QLatin1String("noglob")}, - {('p'), QLatin1String("popd")}, - {('p'), QLatin1String("printpushd")}, - {('p'), QLatin1String("pushln")}, - {('r'), QLatin1String("rehash")}, - {('s'), QLatin1String("sched")}, - {('s'), QLatin1String("setcap")}, - {('s'), QLatin1String("setopt")}, - {('s'), QLatin1String("stat")}, - {('s'), QLatin1String("suspend")}, - {('t'), QLatin1String("ttyctl")}, - {('u'), QLatin1String("unfunction")}, - {('u'), QLatin1String("unhash")}, - {('u'), QLatin1String("unlimitunsetopt")}, - {('v'), QLatin1String("vared")}, - {('w'), QLatin1String("wait")}, - {('w'), QLatin1String("whence")}, - {('w'), QLatin1String("where")}, - {('w'), QLatin1String("which")}, - {('z'), QLatin1String("zcompile")}, - {('z'), QLatin1String("zformat")}, - {('z'), QLatin1String("zftp")}, - {('z'), QLatin1String("zle")}, - {('z'), QLatin1String("zmodload")}, - {('z'), QLatin1String("zparseopts")}, - {('z'), QLatin1String("zprof")}, - {('z'), QLatin1String("zpty")}, - {('z'), QLatin1String("zregexparse")}, - {('z'), QLatin1String("zsocket")}, - {('z'), QLatin1String("zstyle")}, - {('z'), QLatin1String("ztcp")}, - {('g'), QLatin1String("git")}, - {('r'), QLatin1String("rm")}, - {('s'), QLatin1String("sudo")}, - {('f'), QLatin1String("fdisk")}, - {('a'), QLatin1String("apt")}, - {('s'), QLatin1String("snap")}, - {('f'), QLatin1String("flatpak")}, - {('s'), QLatin1String("snapcraft")}, - {('y'), QLatin1String("yaourt")}, - {('n'), QLatin1String("nmcli")}, - {('p'), QLatin1String("pacman")}, - {('p'), QLatin1String("pamac")}, - {('f'), QLatin1String("fsck")}, - {('m'), QLatin1String("mount")}, - {('m'), QLatin1String("mkdir")}, - {('m'), QLatin1String("mkswap")}, - {('s'), QLatin1String("sleep")}, - {('l'), QLatin1String("ls")}, - {('w'), QLatin1String("wget")}, - {('k'), QLatin1String("kill")}, - {('k'), QLatin1String("killall")}, - {('g'), QLatin1String("gdb")}, - {('Q'), QLatin1String("QOwnNotes")}, - {('q'), QLatin1String("qownnotes")}, - {('d'), QLatin1String("docker")}, - {('o'), QLatin1String("openssl")}, - {('p'), QLatin1String("php")}, - {('p'), QLatin1String("python")}, - {('p'), QLatin1String("perl")}, - {('g'), QLatin1String("go")}, - {('c'), QLatin1String("curl")} - }; + shell_builtin = {{('b'), QLatin1String("break")}, + {('c'), QLatin1String("cd")}, + {('c'), QLatin1String("continue")}, + {('e'), QLatin1String("eval")}, + {('e'), QLatin1String("exec")}, + {('e'), QLatin1String("exit")}, + {('e'), QLatin1String("export")}, + {('g'), QLatin1String("getopts")}, + {('h'), QLatin1String("hash")}, + {('p'), QLatin1String("pwd")}, + {('r'), QLatin1String("readonly")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("shift")}, + {('t'), QLatin1String("test")}, + {('t'), QLatin1String("timestrap")}, + {('u'), QLatin1String("umask")}, + {('u'), QLatin1String("unset")}, + {('B'), QLatin1String("Bash")}, + {('a'), QLatin1String("alias")}, + {('b'), QLatin1String("bind")}, + {('b'), QLatin1String("builtin")}, + {('c'), QLatin1String("caller")}, + {('c'), QLatin1String("command")}, + {('d'), QLatin1String("declare")}, + {('e'), QLatin1String("echo")}, + {('e'), QLatin1String("enable")}, + {('h'), QLatin1String("help")}, + {('l'), QLatin1String("let")}, + {('l'), QLatin1String("local")}, + {('l'), QLatin1String("logout")}, + {('m'), QLatin1String("mapfile")}, + {('p'), QLatin1String("printfread")}, + {('r'), QLatin1String("readarray")}, + {('s'), QLatin1String("source")}, + {('t'), QLatin1String("type")}, + {('t'), QLatin1String("typeset")}, + {('u'), QLatin1String("ulimit")}, + {('u'), QLatin1String("unalias")}, + {('m'), QLatin1String("modifiers")}, + {('s'), QLatin1String("set")}, + {('s'), QLatin1String("shopt")}, + {('a'), QLatin1String("autoload")}, + {('b'), QLatin1String("bg")}, + {('b'), QLatin1String("bindkey")}, + {('b'), QLatin1String("bye")}, + {('c'), QLatin1String("cap")}, + {('c'), QLatin1String("chdir")}, + {('c'), QLatin1String("clone")}, + {('c'), QLatin1String("comparguments")}, + {('c'), QLatin1String("compcall")}, + {('c'), QLatin1String("compctl")}, + {('c'), QLatin1String("compdescribe")}, + {('c'), QLatin1String("compfilescompgroups")}, + {('c'), QLatin1String("compquote")}, + {('c'), QLatin1String("comptags")}, + {('c'), QLatin1String("comptry")}, + {('c'), QLatin1String("compvalues")}, + {('d'), QLatin1String("dirs")}, + {('d'), QLatin1String("disable")}, + {('d'), QLatin1String("disown")}, + {('e'), QLatin1String("echotc")}, + {('e'), QLatin1String("echoti")}, + {('e'), QLatin1String("emulatefc")}, + {('f'), QLatin1String("fg")}, + {('f'), QLatin1String("float")}, + {('f'), QLatin1String("functions")}, + {('g'), QLatin1String("getcap")}, + {('g'), QLatin1String("getln")}, + {('h'), QLatin1String("history")}, + {('i'), QLatin1String("integer")}, + {('j'), QLatin1String("jobs")}, + {('k'), QLatin1String("kill")}, + {('l'), QLatin1String("limit")}, + {('l'), QLatin1String("log")}, + {('n'), QLatin1String("noglob")}, + {('p'), QLatin1String("popd")}, + {('p'), QLatin1String("printpushd")}, + {('p'), QLatin1String("pushln")}, + {('r'), QLatin1String("rehash")}, + {('s'), QLatin1String("sched")}, + {('s'), QLatin1String("setcap")}, + {('s'), QLatin1String("setopt")}, + {('s'), QLatin1String("stat")}, + {('s'), QLatin1String("suspend")}, + {('t'), QLatin1String("ttyctl")}, + {('u'), QLatin1String("unfunction")}, + {('u'), QLatin1String("unhash")}, + {('u'), QLatin1String("unlimitunsetopt")}, + {('v'), QLatin1String("vared")}, + {('w'), QLatin1String("wait")}, + {('w'), QLatin1String("whence")}, + {('w'), QLatin1String("where")}, + {('w'), QLatin1String("which")}, + {('z'), QLatin1String("zcompile")}, + {('z'), QLatin1String("zformat")}, + {('z'), QLatin1String("zftp")}, + {('z'), QLatin1String("zle")}, + {('z'), QLatin1String("zmodload")}, + {('z'), QLatin1String("zparseopts")}, + {('z'), QLatin1String("zprof")}, + {('z'), QLatin1String("zpty")}, + {('z'), QLatin1String("zregexparse")}, + {('z'), QLatin1String("zsocket")}, + {('z'), QLatin1String("zstyle")}, + {('z'), QLatin1String("ztcp")}, + {('g'), QLatin1String("git")}, + {('r'), QLatin1String("rm")}, + {('s'), QLatin1String("sudo")}, + {('f'), QLatin1String("fdisk")}, + {('a'), QLatin1String("apt")}, + {('s'), QLatin1String("snap")}, + {('f'), QLatin1String("flatpak")}, + {('s'), QLatin1String("snapcraft")}, + {('y'), QLatin1String("yaourt")}, + {('n'), QLatin1String("nmcli")}, + {('p'), QLatin1String("pacman")}, + {('p'), QLatin1String("pamac")}, + {('f'), QLatin1String("fsck")}, + {('m'), QLatin1String("mount")}, + {('m'), QLatin1String("mkdir")}, + {('m'), QLatin1String("mkswap")}, + {('s'), QLatin1String("sleep")}, + {('l'), QLatin1String("ls")}, + {('w'), QLatin1String("wget")}, + {('k'), QLatin1String("kill")}, + {('k'), QLatin1String("killall")}, + {('g'), QLatin1String("gdb")}, + {('Q'), QLatin1String("QOwnNotes")}, + {('q'), QLatin1String("qownnotes")}, + {('d'), QLatin1String("docker")}, + {('o'), QLatin1String("openssl")}, + {('p'), QLatin1String("php")}, + {('p'), QLatin1String("python")}, + {('p'), QLatin1String("perl")}, + {('g'), QLatin1String("go")}, + {('c'), QLatin1String("curl")}}; - shell_other = {}; + shell_other = {}; } -void loadShellData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!shellDataInitialized) { - initShellData(); - shellDataInitialized = true; - } - types = shell_types; - keywords = shell_keywords; - builtin = shell_builtin; - literals = shell_literals; - other = shell_other; - +void loadShellData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!shellDataInitialized) + { + initShellData(); + shellDataInitialized = true; + } + types = shell_types; + keywords = shell_keywords; + builtin = shell_builtin; + literals = shell_literals; + other = shell_other; } /**********************************************************/ @@ -654,147 +611,116 @@ static LanguageData js_types; static LanguageData js_literals; static LanguageData js_builtin; static LanguageData js_other; -void initJSData() { - js_keywords = { - {('i'), QLatin1String("in")}, - {('o'), QLatin1String("of")}, - {('i'), QLatin1String("if")}, - {('f'), QLatin1String("for")}, - {('w'), QLatin1String("while")}, - {('f'), QLatin1String("finally")}, - {('n'), QLatin1String("new")}, - {('f'), QLatin1String("function")}, - {('d'), QLatin1String("do")}, - {('r'), QLatin1String("return")}, - {('v'), QLatin1String("void")}, - {('e'), QLatin1String("else")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("catch")}, - {('i'), QLatin1String("instanceof")}, - {('w'), QLatin1String("with")}, - {('t'), QLatin1String("throw")}, - {('c'), QLatin1String("case")}, - {('d'), QLatin1String("default")}, - {('t'), QLatin1String("try")}, - {('t'), QLatin1String("this")}, - {('s'), QLatin1String("switch")}, - {('c'), QLatin1String("continue")}, - {('t'), QLatin1String("typeof")}, - {('d'), QLatin1String("delete")}, - {('l'), QLatin1String("let")}, - {('y'), QLatin1String("yield")}, - {('c'), QLatin1String("const")}, - {('e'), QLatin1String("export")}, - {('s'), QLatin1String("super")}, - {('d'), QLatin1String("debugger")}, - {('a'), QLatin1String("as")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('s'), QLatin1String("static")}, - {('i'), QLatin1String("import")}, - {('f'), QLatin1String("from")}, - {('a'), QLatin1String("as")} - }; +void initJSData() +{ + js_keywords = { + {('i'), QLatin1String("in")}, {('o'), QLatin1String("of")}, + {('i'), QLatin1String("if")}, {('f'), QLatin1String("for")}, + {('w'), QLatin1String("while")}, {('f'), QLatin1String("finally")}, + {('n'), QLatin1String("new")}, {('f'), QLatin1String("function")}, + {('d'), QLatin1String("do")}, {('r'), QLatin1String("return")}, + {('v'), QLatin1String("void")}, {('e'), QLatin1String("else")}, + {('b'), QLatin1String("break")}, {('c'), QLatin1String("catch")}, + {('i'), QLatin1String("instanceof")}, {('w'), QLatin1String("with")}, + {('t'), QLatin1String("throw")}, {('c'), QLatin1String("case")}, + {('d'), QLatin1String("default")}, {('t'), QLatin1String("try")}, + {('t'), QLatin1String("this")}, {('s'), QLatin1String("switch")}, + {('c'), QLatin1String("continue")}, {('t'), QLatin1String("typeof")}, + {('d'), QLatin1String("delete")}, {('l'), QLatin1String("let")}, + {('y'), QLatin1String("yield")}, {('c'), QLatin1String("const")}, + {('e'), QLatin1String("export")}, {('s'), QLatin1String("super")}, + {('d'), QLatin1String("debugger")}, {('a'), QLatin1String("as")}, + {('a'), QLatin1String("async")}, {('a'), QLatin1String("await")}, + {('s'), QLatin1String("static")}, {('i'), QLatin1String("import")}, + {('f'), QLatin1String("from")}, {('a'), QLatin1String("as")}}; - js_types = { - {('v'), QLatin1String("var")}, - {('c'), QLatin1String("class")}, - {('b'), QLatin1String("byte")}, - {('e'), QLatin1String("enum")}, - {('f'), QLatin1String("float")}, - {('s'), QLatin1String("short")}, - {('l'), QLatin1String("long")}, - {('i'), QLatin1String("int")}, - {('v'), QLatin1String("void")}, - {('b'), QLatin1String("boolean")}, - {('d'), QLatin1String("double")} - }; + js_types + = {{('v'), QLatin1String("var")}, {('c'), QLatin1String("class")}, + {('b'), QLatin1String("byte")}, {('e'), QLatin1String("enum")}, + {('f'), QLatin1String("float")}, {('s'), QLatin1String("short")}, + {('l'), QLatin1String("long")}, {('i'), QLatin1String("int")}, + {('v'), QLatin1String("void")}, {('b'), QLatin1String("boolean")}, + {('d'), QLatin1String("double")}}; - js_literals = { - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("null")}, - {('t'), QLatin1String("true")}, - {('u'), QLatin1String("undefined")}, - {('N'), QLatin1String("NaN")}, - {('I'), QLatin1String("Infinity")} - }; + js_literals + = {{('f'), QLatin1String("false")}, {('n'), QLatin1String("null")}, + {('t'), QLatin1String("true")}, {('u'), QLatin1String("undefined")}, + {('N'), QLatin1String("NaN")}, {('I'), QLatin1String("Infinity")}}; - js_builtin = { - {('e'), QLatin1String("eval")}, - {('i'), QLatin1String("isFinite")}, - {('i'), QLatin1String("isNaN")}, - {('p'), QLatin1String("parseFloat")}, - {('p'), QLatin1String("parseInt")}, - {('d'), QLatin1String("decodeURI")}, - {('d'), QLatin1String("decodeURIComponent")}, - {('e'), QLatin1String("encodeURI")}, - {('e'), QLatin1String("encodeURIComponent")}, - {('e'), QLatin1String("escape")}, - {('u'), QLatin1String("unescape")}, - {('O'), QLatin1String("Object")}, - {('F'), QLatin1String("Function")}, - {('B'), QLatin1String("Boolean")}, - {('E'), QLatin1String("Error")}, - {('E'), QLatin1String("EvalError")}, - {('I'), QLatin1String("InternalError")}, - {('R'), QLatin1String("RangeError")}, - {('R'), QLatin1String("ReferenceError")}, - {('S'), QLatin1String("StopIteration")}, - {('S'), QLatin1String("SyntaxError")}, - {('T'), QLatin1String("TypeError")}, - {('U'), QLatin1String("URIError")}, - {('N'), QLatin1String("Number")}, - {('M'), QLatin1String("Math")}, - {('D'), QLatin1String("Date")}, - {('S'), QLatin1String("String")}, - {('R'), QLatin1String("RegExp")}, - {('A'), QLatin1String("Array")}, - {('F'), QLatin1String("Float32Array")}, - {('F'), QLatin1String("Float64Array")}, - {('I'), QLatin1String("Int16Array")}, - {('I'), QLatin1String("Int32Array")}, - {('I'), QLatin1String("Int8Array")}, - {('U'), QLatin1String("Uint16Array")}, - {('U'), QLatin1String("Uint32Array")}, - {('U'), QLatin1String("Uint8Array")}, - {('U'), QLatin1String("Uint8ClampedArray")}, - {('A'), QLatin1String("ArrayBuffer")}, - {('D'), QLatin1String("DataView")}, - {('J'), QLatin1String("JSON")}, - {('I'), QLatin1String("Intl")}, - {('a'), QLatin1String("arguments")}, - {('r'), QLatin1String("require")}, - {('m'), QLatin1String("module")}, - {('c'), QLatin1String("console")}, - {('w'), QLatin1String("window")}, - {('d'), QLatin1String("document")}, - {('S'), QLatin1String("Symbol")}, - {('S'), QLatin1String("Set")}, - {('M'), QLatin1String("Map")}, - {('W'), QLatin1String("WeakSet")}, - {('W'), QLatin1String("WeakMap")}, - {('P'), QLatin1String("Proxy")}, - {('R'), QLatin1String("Reflect")}, - {('P'), QLatin1String("Promise")} - }; + js_builtin = {{('e'), QLatin1String("eval")}, + {('i'), QLatin1String("isFinite")}, + {('i'), QLatin1String("isNaN")}, + {('p'), QLatin1String("parseFloat")}, + {('p'), QLatin1String("parseInt")}, + {('d'), QLatin1String("decodeURI")}, + {('d'), QLatin1String("decodeURIComponent")}, + {('e'), QLatin1String("encodeURI")}, + {('e'), QLatin1String("encodeURIComponent")}, + {('e'), QLatin1String("escape")}, + {('u'), QLatin1String("unescape")}, + {('O'), QLatin1String("Object")}, + {('F'), QLatin1String("Function")}, + {('B'), QLatin1String("Boolean")}, + {('E'), QLatin1String("Error")}, + {('E'), QLatin1String("EvalError")}, + {('I'), QLatin1String("InternalError")}, + {('R'), QLatin1String("RangeError")}, + {('R'), QLatin1String("ReferenceError")}, + {('S'), QLatin1String("StopIteration")}, + {('S'), QLatin1String("SyntaxError")}, + {('T'), QLatin1String("TypeError")}, + {('U'), QLatin1String("URIError")}, + {('N'), QLatin1String("Number")}, + {('M'), QLatin1String("Math")}, + {('D'), QLatin1String("Date")}, + {('S'), QLatin1String("String")}, + {('R'), QLatin1String("RegExp")}, + {('A'), QLatin1String("Array")}, + {('F'), QLatin1String("Float32Array")}, + {('F'), QLatin1String("Float64Array")}, + {('I'), QLatin1String("Int16Array")}, + {('I'), QLatin1String("Int32Array")}, + {('I'), QLatin1String("Int8Array")}, + {('U'), QLatin1String("Uint16Array")}, + {('U'), QLatin1String("Uint32Array")}, + {('U'), QLatin1String("Uint8Array")}, + {('U'), QLatin1String("Uint8ClampedArray")}, + {('A'), QLatin1String("ArrayBuffer")}, + {('D'), QLatin1String("DataView")}, + {('J'), QLatin1String("JSON")}, + {('I'), QLatin1String("Intl")}, + {('a'), QLatin1String("arguments")}, + {('r'), QLatin1String("require")}, + {('m'), QLatin1String("module")}, + {('c'), QLatin1String("console")}, + {('w'), QLatin1String("window")}, + {('d'), QLatin1String("document")}, + {('S'), QLatin1String("Symbol")}, + {('S'), QLatin1String("Set")}, + {('M'), QLatin1String("Map")}, + {('W'), QLatin1String("WeakSet")}, + {('W'), QLatin1String("WeakMap")}, + {('P'), QLatin1String("Proxy")}, + {('R'), QLatin1String("Reflect")}, + {('P'), QLatin1String("Promise")}}; - js_other = {}; + js_other = {}; } -void loadJSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!JSDataInitialized) { - initJSData(); - JSDataInitialized = true; - } - types = js_types; - keywords = js_keywords; - builtin = js_builtin; - literals = js_literals; - other = js_other; +void loadJSData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!JSDataInitialized) + { + initJSData(); + JSDataInitialized = true; + } + types = js_types; + keywords = js_keywords; + builtin = js_builtin; + literals = js_literals; + other = js_other; } /**********************************************************/ @@ -806,128 +732,120 @@ static LanguageData php_types; static LanguageData php_literals; static LanguageData php_builtin; static LanguageData php_other; -void initPHPData() { - php_keywords = { - {('a'), QLatin1String("and")}, - {('l'), QLatin1String("list")}, - {('a'), QLatin1String("abstract")}, - {('g'), QLatin1String("global")}, - {('p'), QLatin1String("private")}, - {('e'), QLatin1String("echo")}, - {('i'), QLatin1String("interface")}, - {('a'), QLatin1String("as")}, - {('s'), QLatin1String("static")}, - {('e'), QLatin1String("endswitch")}, - {('i'), QLatin1String("if")}, - {('e'), QLatin1String("endwhile")}, - {('o'), QLatin1String("or")}, - {('c'), QLatin1String("const")}, - {('f'), QLatin1String("for")}, - {('e'), QLatin1String("endforeach")}, - {('s'), QLatin1String("self")}, - {('w'), QLatin1String("while")}, - {('i'), QLatin1String("isset")}, - {('p'), QLatin1String("public")}, - {('p'), QLatin1String("protected")}, - {('e'), QLatin1String("exit")}, - {('f'), QLatin1String("foreach")}, - {('t'), QLatin1String("throw")}, - {('e'), QLatin1String("elseif")}, - {('e'), QLatin1String("empty")}, - {('d'), QLatin1String("do")}, - {('x'), QLatin1String("xor")}, - {('r'), QLatin1String("return")}, - {('p'), QLatin1String("parent")}, - {('c'), QLatin1String("clone")}, - {('u'), QLatin1String("use")}, - {('e'), QLatin1String("else")}, - {('b'), QLatin1String("break")}, - {('p'), QLatin1String("print")}, - {('e'), QLatin1String("eval")}, - {('n'), QLatin1String("new")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("case")}, - {('e'), QLatin1String("exception")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("die")}, - {('e'), QLatin1String("enddeclare")}, - {('f'), QLatin1String("final")}, - {('t'), QLatin1String("try")}, - {('s'), QLatin1String("switch")}, - {('c'), QLatin1String("continue")}, - {('e'), QLatin1String("endfor")}, - {('e'), QLatin1String("endif")}, - {('d'), QLatin1String("declare")}, - {('u'), QLatin1String("unset")}, - {('t'), QLatin1String("trait")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("instanceof")}, - {('i'), QLatin1String("insteadof")}, - {('y'), QLatin1String("yield")}, - {('f'), QLatin1String("finally")} - }; +void initPHPData() +{ + php_keywords = {{('a'), QLatin1String("and")}, + {('l'), QLatin1String("list")}, + {('a'), QLatin1String("abstract")}, + {('g'), QLatin1String("global")}, + {('p'), QLatin1String("private")}, + {('e'), QLatin1String("echo")}, + {('i'), QLatin1String("interface")}, + {('a'), QLatin1String("as")}, + {('s'), QLatin1String("static")}, + {('e'), QLatin1String("endswitch")}, + {('i'), QLatin1String("if")}, + {('e'), QLatin1String("endwhile")}, + {('o'), QLatin1String("or")}, + {('c'), QLatin1String("const")}, + {('f'), QLatin1String("for")}, + {('e'), QLatin1String("endforeach")}, + {('s'), QLatin1String("self")}, + {('w'), QLatin1String("while")}, + {('i'), QLatin1String("isset")}, + {('p'), QLatin1String("public")}, + {('p'), QLatin1String("protected")}, + {('e'), QLatin1String("exit")}, + {('f'), QLatin1String("foreach")}, + {('t'), QLatin1String("throw")}, + {('e'), QLatin1String("elseif")}, + {('e'), QLatin1String("empty")}, + {('d'), QLatin1String("do")}, + {('x'), QLatin1String("xor")}, + {('r'), QLatin1String("return")}, + {('p'), QLatin1String("parent")}, + {('c'), QLatin1String("clone")}, + {('u'), QLatin1String("use")}, + {('e'), QLatin1String("else")}, + {('b'), QLatin1String("break")}, + {('p'), QLatin1String("print")}, + {('e'), QLatin1String("eval")}, + {('n'), QLatin1String("new")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("case")}, + {('e'), QLatin1String("exception")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("die")}, + {('e'), QLatin1String("enddeclare")}, + {('f'), QLatin1String("final")}, + {('t'), QLatin1String("try")}, + {('s'), QLatin1String("switch")}, + {('c'), QLatin1String("continue")}, + {('e'), QLatin1String("endfor")}, + {('e'), QLatin1String("endif")}, + {('d'), QLatin1String("declare")}, + {('u'), QLatin1String("unset")}, + {('t'), QLatin1String("trait")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("instanceof")}, + {('i'), QLatin1String("insteadof")}, + {('y'), QLatin1String("yield")}, + {('f'), QLatin1String("finally")}}; - php_types = { - {('v'), QLatin1String("var")}, - {('c'), QLatin1String("class")}, - {('e'), QLatin1String("enum")}, - {('a'), QLatin1String("array")} - }; + php_types = {{('v'), QLatin1String("var")}, + {('c'), QLatin1String("class")}, + {('e'), QLatin1String("enum")}, + {('a'), QLatin1String("array")}}; - php_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")} - }; + php_literals = {{('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}}; - php_builtin = { + php_builtin = { + }; - }; + php_other = {{('i'), QLatin1String("include_once")}, + {('i'), QLatin1String("include")}, + {('_'), QLatin1String("__FILE__")}, + {('r'), QLatin1String("require")}, + {('r'), QLatin1String("require_once")}, + {('_'), QLatin1String("__CLASS__")}, + {('_'), QLatin1String("__LINE__")}, + {('_'), QLatin1String("__METHOD__")}, + {('_'), QLatin1String("__FUNCTION__")}, + {('_'), QLatin1String("__DIR__")}, + {('_'), QLatin1String("__NAMESPACE__")}, - php_other = { - {('i'), QLatin1String("include_once")}, - {('i'), QLatin1String("include")}, - {('_'), QLatin1String("__FILE__")}, - {('r'), QLatin1String("require")}, - {('r'), QLatin1String("require_once")}, - {('_'), QLatin1String("__CLASS__")}, - {('_'), QLatin1String("__LINE__")}, - {('_'), QLatin1String("__METHOD__")}, - {('_'), QLatin1String("__FUNCTION__")}, - {('_'), QLatin1String("__DIR__")}, - {('_'), QLatin1String("__NAMESPACE__")}, - - {('S'), QLatin1String("SERVER")}, - {('G'), QLatin1String("GET")}, - {('P'), QLatin1String("POST")}, - {('F'), QLatin1String("FILES")}, - {('R'), QLatin1String("REQUEST")}, - {('S'), QLatin1String("SESSION")}, - {('E'), QLatin1String("ENV")}, - {('C'), QLatin1String("COOKIE")}, - {('G'), QLatin1String("GLOBALS")}, - {('H'), QLatin1String("HTTP_RAW_POST_DATA")}, - {('a'), QLatin1String("argc")}, - {('a'), QLatin1String("argv")}, - {('p'), QLatin1String("php_errormsg")}, - {('h'), QLatin1String("http_response_header")} -}; + {('S'), QLatin1String("SERVER")}, + {('G'), QLatin1String("GET")}, + {('P'), QLatin1String("POST")}, + {('F'), QLatin1String("FILES")}, + {('R'), QLatin1String("REQUEST")}, + {('S'), QLatin1String("SESSION")}, + {('E'), QLatin1String("ENV")}, + {('C'), QLatin1String("COOKIE")}, + {('G'), QLatin1String("GLOBALS")}, + {('H'), QLatin1String("HTTP_RAW_POST_DATA")}, + {('a'), QLatin1String("argc")}, + {('a'), QLatin1String("argv")}, + {('p'), QLatin1String("php_errormsg")}, + {('h'), QLatin1String("http_response_header")}}; } -void loadPHPData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!PHPDataInitialized) { - initPHPData(); - PHPDataInitialized = true; - } - types = php_types; - keywords = php_keywords; - builtin = php_builtin; - literals = php_literals; - other = php_other; +void loadPHPData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!PHPDataInitialized) + { + initPHPData(); + PHPDataInitialized = true; + } + types = php_types; + keywords = php_keywords; + builtin = php_builtin; + literals = php_literals; + other = php_other; } /**********************************************************/ @@ -940,137 +858,127 @@ static LanguageData qml_literals; static LanguageData qml_builtin; static LanguageData qml_other; -void initQMLData() { - qml_keywords = { - {('d'), QLatin1String("default")}, - {('p'), QLatin1String("property")}, - {('i'), QLatin1String("int")}, - {('v'), QLatin1String("var")}, - {('s'), QLatin1String("string")}, - {('f'), QLatin1String("function")}, - {('r'), QLatin1String("readonly")}, - {('M'), QLatin1String("MouseArea")}, - {('d'), QLatin1String("delegate")}, - {('i'), QLatin1String("if")}, - {('e'), QLatin1String("else")}, +void initQMLData() +{ + qml_keywords = {{('d'), QLatin1String("default")}, + {('p'), QLatin1String("property")}, + {('i'), QLatin1String("int")}, + {('v'), QLatin1String("var")}, + {('s'), QLatin1String("string")}, + {('f'), QLatin1String("function")}, + {('r'), QLatin1String("readonly")}, + {('M'), QLatin1String("MouseArea")}, + {('d'), QLatin1String("delegate")}, + {('i'), QLatin1String("if")}, + {('e'), QLatin1String("else")}, - {('e'), QLatin1String("eval")}, - {('i'), QLatin1String("isFinite")}, - {('i'), QLatin1String("isNaN")}, - {('p'), QLatin1String("parseFloat")}, - {('p'), QLatin1String("parseInt")}, - {('d'), QLatin1String("decodeURI")}, - {('d'), QLatin1String("decodeURIComponent")}, - {('e'), QLatin1String("encodeURI")}, - {('e'), QLatin1String("encodeURIComponent")}, - {('e'), QLatin1String("escape")}, - {('u'), QLatin1String("unescape")}, - {('O'), QLatin1String("Object")}, - {('E'), QLatin1String("Error")}, - {('E'), QLatin1String("EvalError")}, - {('I'), QLatin1String("InternalError")}, - {('R'), QLatin1String("RangeError")}, - {('R'), QLatin1String("ReferenceError")}, - {('S'), QLatin1String("StopIteration")}, - {('S'), QLatin1String("SyntaxError")}, - {('T'), QLatin1String("TypeError")}, - {('U'), QLatin1String("URIError")}, - {('N'), QLatin1String("Number")}, - {('M'), QLatin1String("Math")}, - {('D'), QLatin1String("Date")}, - {('S'), QLatin1String("String")}, - {('R'), QLatin1String("RegExp")}, - {('A'), QLatin1String("Array")}, - {('F'), QLatin1String("Float32Array")}, - {('F'), QLatin1String("Float64Array")}, - {('I'), QLatin1String("Int16Array")}, - {('I'), QLatin1String("Int32Array")}, - {('I'), QLatin1String("Int8Array")}, - {('U'), QLatin1String("Uint16Array")}, - {('U'), QLatin1String("Uint32Array")}, - {('U'), QLatin1String("Uint8Array")}, - {('U'), QLatin1String("Uint8ClampedArray")}, - {('A'), QLatin1String("ArrayBuffer")}, - {('D'), QLatin1String("DataView")}, - {('J'), QLatin1String("JSON")}, - {('I'), QLatin1String("Intl")}, - {('a'), QLatin1String("arguments")}, - {('m'), QLatin1String("module")}, - {('c'), QLatin1String("console")}, - {('w'), QLatin1String("window")}, - {('d'), QLatin1String("document")}, - {('S'), QLatin1String("Symbol")}, - {('S'), QLatin1String("Set")}, - {('M'), QLatin1String("Map")}, - {('W'), QLatin1String("WeakSet")}, - {('W'), QLatin1String("WeakMap")}, - {('P'), QLatin1String("Proxy")}, - {('R'), QLatin1String("Reflect")}, - {('B'), QLatin1String("Behavior")}, - {('c'), QLatin1String("color")}, - {('c'), QLatin1String("coordinate")}, - {('d'), QLatin1String("date")}, - {('e'), QLatin1String("enumeration")}, - {('f'), QLatin1String("font")}, - {('g'), QLatin1String("geocircle")}, - {('g'), QLatin1String("georectangle")}, - {('g'), QLatin1String("geoshape")}, - {('l'), QLatin1String("list")}, - {('m'), QLatin1String("matrix4x4")}, - {('p'), QLatin1String("parent")}, - {('p'), QLatin1String("point")}, - {('q'), QLatin1String("quaternion")}, - {('r'), QLatin1String("real")}, - {('s'), QLatin1String("size")}, - {('s'), QLatin1String("string")}, - {('v'), QLatin1String("variant")}, - {('v'), QLatin1String("vector2d")}, - {('v'), QLatin1String("vector3d")}, - {('v'), QLatin1String("vector4d")}, - {('P'), QLatin1String("Promise")} -}; + {('e'), QLatin1String("eval")}, + {('i'), QLatin1String("isFinite")}, + {('i'), QLatin1String("isNaN")}, + {('p'), QLatin1String("parseFloat")}, + {('p'), QLatin1String("parseInt")}, + {('d'), QLatin1String("decodeURI")}, + {('d'), QLatin1String("decodeURIComponent")}, + {('e'), QLatin1String("encodeURI")}, + {('e'), QLatin1String("encodeURIComponent")}, + {('e'), QLatin1String("escape")}, + {('u'), QLatin1String("unescape")}, + {('O'), QLatin1String("Object")}, + {('E'), QLatin1String("Error")}, + {('E'), QLatin1String("EvalError")}, + {('I'), QLatin1String("InternalError")}, + {('R'), QLatin1String("RangeError")}, + {('R'), QLatin1String("ReferenceError")}, + {('S'), QLatin1String("StopIteration")}, + {('S'), QLatin1String("SyntaxError")}, + {('T'), QLatin1String("TypeError")}, + {('U'), QLatin1String("URIError")}, + {('N'), QLatin1String("Number")}, + {('M'), QLatin1String("Math")}, + {('D'), QLatin1String("Date")}, + {('S'), QLatin1String("String")}, + {('R'), QLatin1String("RegExp")}, + {('A'), QLatin1String("Array")}, + {('F'), QLatin1String("Float32Array")}, + {('F'), QLatin1String("Float64Array")}, + {('I'), QLatin1String("Int16Array")}, + {('I'), QLatin1String("Int32Array")}, + {('I'), QLatin1String("Int8Array")}, + {('U'), QLatin1String("Uint16Array")}, + {('U'), QLatin1String("Uint32Array")}, + {('U'), QLatin1String("Uint8Array")}, + {('U'), QLatin1String("Uint8ClampedArray")}, + {('A'), QLatin1String("ArrayBuffer")}, + {('D'), QLatin1String("DataView")}, + {('J'), QLatin1String("JSON")}, + {('I'), QLatin1String("Intl")}, + {('a'), QLatin1String("arguments")}, + {('m'), QLatin1String("module")}, + {('c'), QLatin1String("console")}, + {('w'), QLatin1String("window")}, + {('d'), QLatin1String("document")}, + {('S'), QLatin1String("Symbol")}, + {('S'), QLatin1String("Set")}, + {('M'), QLatin1String("Map")}, + {('W'), QLatin1String("WeakSet")}, + {('W'), QLatin1String("WeakMap")}, + {('P'), QLatin1String("Proxy")}, + {('R'), QLatin1String("Reflect")}, + {('B'), QLatin1String("Behavior")}, + {('c'), QLatin1String("color")}, + {('c'), QLatin1String("coordinate")}, + {('d'), QLatin1String("date")}, + {('e'), QLatin1String("enumeration")}, + {('f'), QLatin1String("font")}, + {('g'), QLatin1String("geocircle")}, + {('g'), QLatin1String("georectangle")}, + {('g'), QLatin1String("geoshape")}, + {('l'), QLatin1String("list")}, + {('m'), QLatin1String("matrix4x4")}, + {('p'), QLatin1String("parent")}, + {('p'), QLatin1String("point")}, + {('q'), QLatin1String("quaternion")}, + {('r'), QLatin1String("real")}, + {('s'), QLatin1String("size")}, + {('s'), QLatin1String("string")}, + {('v'), QLatin1String("variant")}, + {('v'), QLatin1String("vector2d")}, + {('v'), QLatin1String("vector3d")}, + {('v'), QLatin1String("vector4d")}, + {('P'), QLatin1String("Promise")}}; - qml_types = { - {('R'), QLatin1String("Rectangle")}, - {('T'), QLatin1String("Text")}, - {('c'), QLatin1String("color")}, - {('I'), QLatin1String("Item")}, - {('u'), QLatin1String("url")}, - {('C'), QLatin1String("Component")}, - {('B'), QLatin1String("Button")}, - {('T'), QLatin1String("TextInput")}, - {('L'), QLatin1String("ListView")}, + qml_types = { + {('R'), QLatin1String("Rectangle")}, {('T'), QLatin1String("Text")}, + {('c'), QLatin1String("color")}, {('I'), QLatin1String("Item")}, + {('u'), QLatin1String("url")}, {('C'), QLatin1String("Component")}, + {('B'), QLatin1String("Button")}, {('T'), QLatin1String("TextInput")}, + {('L'), QLatin1String("ListView")}, + }; -}; + qml_literals + = {{('f'), QLatin1String("false")}, {('t'), QLatin1String("true")}}; - qml_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} -}; + qml_builtin = { - qml_builtin = { + }; -}; - - qml_other = { - {('i'), QLatin1String("import")} -}; + qml_other = {{('i'), QLatin1String("import")}}; } -void loadQMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other){ - if (!QMLDataInitialized) { - initQMLData(); - QMLDataInitialized = true; - } - types = qml_types; - keywords = qml_keywords; - builtin = qml_builtin; - literals = qml_literals; - other = qml_other; +void loadQMLData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!QMLDataInitialized) + { + initQMLData(); + QMLDataInitialized = true; + } + types = qml_types; + keywords = qml_keywords; + builtin = qml_builtin; + literals = qml_literals; + other = qml_other; } /**********************************************************/ @@ -1083,155 +991,134 @@ static LanguageData py_literals; static LanguageData py_builtin; static LanguageData py_other; -void initPyData() { - py_keywords = { - {('a'), QLatin1String("and")}, - {('e'), QLatin1String("elif")}, - {('i'), QLatin1String("is")}, - {('g'), QLatin1String("global")}, - {('a'), QLatin1String("as")}, - {('i'), QLatin1String("in")}, - {('i'), QLatin1String("if")}, - {('f'), QLatin1String("from")}, - {('r'), QLatin1String("raise")}, - {('f'), QLatin1String("for")}, - {('e'), QLatin1String("except")}, - {('f'), QLatin1String("finally")}, - {('p'), QLatin1String("print")}, - {('p'), QLatin1String("pass")}, - {('r'), QLatin1String("return")}, - {('e'), QLatin1String("exec")}, - {('e'), QLatin1String("else")}, - {('b'), QLatin1String("break")}, - {('n'), QLatin1String("not")}, - {('w'), QLatin1String("with")}, - {('c'), QLatin1String("class")}, - {('a'), QLatin1String("assert")}, - {('y'), QLatin1String("yield")}, - {('t'), QLatin1String("try")}, - {('w'), QLatin1String("while")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("del")}, - {('o'), QLatin1String("or")}, - {('d'), QLatin1String("def")}, - {('l'), QLatin1String("lambda")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('n'), QLatin1String("nonlocal")}, - }; +void initPyData() +{ + py_keywords = { + {('a'), QLatin1String("and")}, {('e'), QLatin1String("elif")}, + {('i'), QLatin1String("is")}, {('g'), QLatin1String("global")}, + {('a'), QLatin1String("as")}, {('i'), QLatin1String("in")}, + {('i'), QLatin1String("if")}, {('f'), QLatin1String("from")}, + {('r'), QLatin1String("raise")}, {('f'), QLatin1String("for")}, + {('e'), QLatin1String("except")}, {('f'), QLatin1String("finally")}, + {('p'), QLatin1String("print")}, {('p'), QLatin1String("pass")}, + {('r'), QLatin1String("return")}, {('e'), QLatin1String("exec")}, + {('e'), QLatin1String("else")}, {('b'), QLatin1String("break")}, + {('n'), QLatin1String("not")}, {('w'), QLatin1String("with")}, + {('c'), QLatin1String("class")}, {('a'), QLatin1String("assert")}, + {('y'), QLatin1String("yield")}, {('t'), QLatin1String("try")}, + {('w'), QLatin1String("while")}, {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("del")}, {('o'), QLatin1String("or")}, + {('d'), QLatin1String("def")}, {('l'), QLatin1String("lambda")}, + {('a'), QLatin1String("async")}, {('a'), QLatin1String("await")}, + {('n'), QLatin1String("nonlocal")}, + }; - py_types = { + py_types = { - }; + }; - py_literals = { - {('F'), QLatin1String("False")}, - {('T'), QLatin1String("True")}, - {('N'), QLatin1String("None")} - }; + py_literals = {{('F'), QLatin1String("False")}, + {('T'), QLatin1String("True")}, + {('N'), QLatin1String("None")}}; - py_builtin = { - { ('_'), QLatin1String("__import__") }, - { ('a'), QLatin1String("abs") }, - { ('a'), QLatin1String("all") }, - { ('a'), QLatin1String("any") }, - { ('a'), QLatin1String("apply") }, - { ('a'), QLatin1String("ascii") }, - { ('b'), QLatin1String("basestring") }, - { ('b'), QLatin1String("bin") }, - { ('b'), QLatin1String("bool") }, - { ('b'), QLatin1String("buffer") }, - { ('b'), QLatin1String("bytearray") }, - { ('b'), QLatin1String("bytes") }, - { ('c'), QLatin1String("callable") }, - { ('c'), QLatin1String("chr") }, - { ('c'), QLatin1String("classmethod") }, - { ('c'), QLatin1String("cmp") }, - { ('c'), QLatin1String("coerce") }, - { ('c'), QLatin1String("compile") }, - { ('c'), QLatin1String("complex") }, - { ('d'), QLatin1String("delattr") }, - { ('d'), QLatin1String("dict") }, - { ('d'), QLatin1String("dir") }, - { ('d'), QLatin1String("divmod") }, - { ('e'), QLatin1String("enumerate") }, - { ('e'), QLatin1String("eval") }, - { ('e'), QLatin1String("execfile") }, - { ('f'), QLatin1String("file") }, - { ('f'), QLatin1String("filter") }, - { ('f'), QLatin1String("float") }, - { ('f'), QLatin1String("format") }, - { ('f'), QLatin1String("frozenset") }, - { ('g'), QLatin1String("getattr") }, - { ('g'), QLatin1String("globals") }, - { ('h'), QLatin1String("hasattr") }, - { ('h'), QLatin1String("hash") }, - { ('h'), QLatin1String("help") }, - { ('h'), QLatin1String("hex") }, - { ('i'), QLatin1String("id") }, - { ('i'), QLatin1String("input") }, - { ('i'), QLatin1String("int") }, - { ('i'), QLatin1String("intern") }, - { ('i'), QLatin1String("isinstance") }, - { ('i'), QLatin1String("issubclass") }, - { ('i'), QLatin1String("iter") }, - { ('l'), QLatin1String("len") }, - { ('l'), QLatin1String("list") }, - { ('l'), QLatin1String("locals") }, - { ('l'), QLatin1String("long") }, - { ('m'), QLatin1String("map") }, - { ('m'), QLatin1String("max") }, - { ('m'), QLatin1String("memoryview") }, - { ('m'), QLatin1String("min") }, - { ('n'), QLatin1String("next") }, - { ('o'), QLatin1String("object") }, - { ('o'), QLatin1String("oct") }, - { ('o'), QLatin1String("open") }, - { ('o'), QLatin1String("ord") }, - { ('p'), QLatin1String("pow") }, - { ('p'), QLatin1String("property") }, - { ('r'), QLatin1String("range") }, - { ('r'), QLatin1String("raw_input") }, - { ('r'), QLatin1String("reduce") }, - { ('r'), QLatin1String("reload") }, - { ('r'), QLatin1String("repr") }, - { ('r'), QLatin1String("reversed") }, - { ('r'), QLatin1String("round") }, - { ('s'), QLatin1String("set") }, - { ('s'), QLatin1String("setattr") }, - { ('s'), QLatin1String("slice") }, - { ('s'), QLatin1String("sorted") }, - { ('s'), QLatin1String("staticmethod") }, - { ('s'), QLatin1String("str") }, - { ('s'), QLatin1String("sum") }, - { ('s'), QLatin1String("super") }, - { ('t'), QLatin1String("tuple") }, - { ('t'), QLatin1String("type") }, - { ('u'), QLatin1String("unichr") }, - { ('u'), QLatin1String("unicode") }, - { ('v'), QLatin1String("vars") }, - { ('x'), QLatin1String("xrange") }, - { ('z'), QLatin1String("zip") } - }; + py_builtin = {{('_'), QLatin1String("__import__")}, + {('a'), QLatin1String("abs")}, + {('a'), QLatin1String("all")}, + {('a'), QLatin1String("any")}, + {('a'), QLatin1String("apply")}, + {('a'), QLatin1String("ascii")}, + {('b'), QLatin1String("basestring")}, + {('b'), QLatin1String("bin")}, + {('b'), QLatin1String("bool")}, + {('b'), QLatin1String("buffer")}, + {('b'), QLatin1String("bytearray")}, + {('b'), QLatin1String("bytes")}, + {('c'), QLatin1String("callable")}, + {('c'), QLatin1String("chr")}, + {('c'), QLatin1String("classmethod")}, + {('c'), QLatin1String("cmp")}, + {('c'), QLatin1String("coerce")}, + {('c'), QLatin1String("compile")}, + {('c'), QLatin1String("complex")}, + {('d'), QLatin1String("delattr")}, + {('d'), QLatin1String("dict")}, + {('d'), QLatin1String("dir")}, + {('d'), QLatin1String("divmod")}, + {('e'), QLatin1String("enumerate")}, + {('e'), QLatin1String("eval")}, + {('e'), QLatin1String("execfile")}, + {('f'), QLatin1String("file")}, + {('f'), QLatin1String("filter")}, + {('f'), QLatin1String("float")}, + {('f'), QLatin1String("format")}, + {('f'), QLatin1String("frozenset")}, + {('g'), QLatin1String("getattr")}, + {('g'), QLatin1String("globals")}, + {('h'), QLatin1String("hasattr")}, + {('h'), QLatin1String("hash")}, + {('h'), QLatin1String("help")}, + {('h'), QLatin1String("hex")}, + {('i'), QLatin1String("id")}, + {('i'), QLatin1String("input")}, + {('i'), QLatin1String("int")}, + {('i'), QLatin1String("intern")}, + {('i'), QLatin1String("isinstance")}, + {('i'), QLatin1String("issubclass")}, + {('i'), QLatin1String("iter")}, + {('l'), QLatin1String("len")}, + {('l'), QLatin1String("list")}, + {('l'), QLatin1String("locals")}, + {('l'), QLatin1String("long")}, + {('m'), QLatin1String("map")}, + {('m'), QLatin1String("max")}, + {('m'), QLatin1String("memoryview")}, + {('m'), QLatin1String("min")}, + {('n'), QLatin1String("next")}, + {('o'), QLatin1String("object")}, + {('o'), QLatin1String("oct")}, + {('o'), QLatin1String("open")}, + {('o'), QLatin1String("ord")}, + {('p'), QLatin1String("pow")}, + {('p'), QLatin1String("property")}, + {('r'), QLatin1String("range")}, + {('r'), QLatin1String("raw_input")}, + {('r'), QLatin1String("reduce")}, + {('r'), QLatin1String("reload")}, + {('r'), QLatin1String("repr")}, + {('r'), QLatin1String("reversed")}, + {('r'), QLatin1String("round")}, + {('s'), QLatin1String("set")}, + {('s'), QLatin1String("setattr")}, + {('s'), QLatin1String("slice")}, + {('s'), QLatin1String("sorted")}, + {('s'), QLatin1String("staticmethod")}, + {('s'), QLatin1String("str")}, + {('s'), QLatin1String("sum")}, + {('s'), QLatin1String("super")}, + {('t'), QLatin1String("tuple")}, + {('t'), QLatin1String("type")}, + {('u'), QLatin1String("unichr")}, + {('u'), QLatin1String("unicode")}, + {('v'), QLatin1String("vars")}, + {('x'), QLatin1String("xrange")}, + {('z'), QLatin1String("zip")}}; - py_other = { - {('i'), QLatin1String("import")} - }; + py_other = {{('i'), QLatin1String("import")}}; } -void loadPythonData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other){ - if (!PyDataInitialized) { - initPyData(); - PyDataInitialized = true; - } - types = py_types; - keywords = py_keywords; - builtin = py_builtin; - literals = py_literals; - other = py_other; +void loadPythonData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!PyDataInitialized) + { + initPyData(); + PyDataInitialized = true; + } + types = py_types; + keywords = py_keywords; + builtin = py_builtin; + literals = py_literals; + other = py_other; } /********************************************************/ @@ -1243,149 +1130,108 @@ static LanguageData rust_types; static LanguageData rust_literals; static LanguageData rust_builtin; static LanguageData rust_other; -void initRustData() { -rust_keywords = { - {('a'), QLatin1String("abstract")}, - {('a'), QLatin1String("alignof")}, - {('a'), QLatin1String("as")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('b'), QLatin1String("be")}, - {('b'), QLatin1String("box")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('c'), QLatin1String("crate")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("dyn")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("extern")}, - {('f'), QLatin1String("final")}, - {('f'), QLatin1String("fn")}, - {('f'), QLatin1String("for")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("impl")}, - {('i'), QLatin1String("in")}, - {('l'), QLatin1String("let")}, - {('l'), QLatin1String("loop")}, - {('m'), QLatin1String("match")}, - {('m'), QLatin1String("mod")}, - {('m'), QLatin1String("move")}, - {('m'), QLatin1String("mut")}, - {('o'), QLatin1String("offsetof")}, - {('o'), QLatin1String("once")}, - {('o'), QLatin1String("override")}, - {('p'), QLatin1String("priv")}, - {('p'), QLatin1String("pub")}, - {('p'), QLatin1String("pure")}, - {('r'), QLatin1String("ref")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("sizeof")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("self")}, - {('S'), QLatin1String("Self")}, - {('s'), QLatin1String("super")}, - {('t'), QLatin1String("trait")}, - {('t'), QLatin1String("type")}, - {('t'), QLatin1String("typeof")}, - {('u'), QLatin1String("unsafe")}, - {('u'), QLatin1String("unsized")}, - {('u'), QLatin1String("use")}, - {('v'), QLatin1String("virtual")}, - {('w'), QLatin1String("where")}, - {('w'), QLatin1String("while")}, - {('y'), QLatin1String("yield")}, -}; +void initRustData() +{ + rust_keywords = { + {('a'), QLatin1String("abstract")}, {('a'), QLatin1String("alignof")}, + {('a'), QLatin1String("as")}, {('a'), QLatin1String("async")}, + {('a'), QLatin1String("await")}, {('b'), QLatin1String("be")}, + {('b'), QLatin1String("box")}, {('b'), QLatin1String("break")}, + {('c'), QLatin1String("const")}, {('c'), QLatin1String("continue")}, + {('c'), QLatin1String("crate")}, {('d'), QLatin1String("do")}, + {('d'), QLatin1String("dyn")}, {('e'), QLatin1String("else")}, + {('e'), QLatin1String("extern")}, {('f'), QLatin1String("final")}, + {('f'), QLatin1String("fn")}, {('f'), QLatin1String("for")}, + {('i'), QLatin1String("if")}, {('i'), QLatin1String("impl")}, + {('i'), QLatin1String("in")}, {('l'), QLatin1String("let")}, + {('l'), QLatin1String("loop")}, {('m'), QLatin1String("match")}, + {('m'), QLatin1String("mod")}, {('m'), QLatin1String("move")}, + {('m'), QLatin1String("mut")}, {('o'), QLatin1String("offsetof")}, + {('o'), QLatin1String("once")}, {('o'), QLatin1String("override")}, + {('p'), QLatin1String("priv")}, {('p'), QLatin1String("pub")}, + {('p'), QLatin1String("pure")}, {('r'), QLatin1String("ref")}, + {('r'), QLatin1String("return")}, {('s'), QLatin1String("sizeof")}, + {('s'), QLatin1String("static")}, {('s'), QLatin1String("self")}, + {('S'), QLatin1String("Self")}, {('s'), QLatin1String("super")}, + {('t'), QLatin1String("trait")}, {('t'), QLatin1String("type")}, + {('t'), QLatin1String("typeof")}, {('u'), QLatin1String("unsafe")}, + {('u'), QLatin1String("unsized")}, {('u'), QLatin1String("use")}, + {('v'), QLatin1String("virtual")}, {('w'), QLatin1String("where")}, + {('w'), QLatin1String("while")}, {('y'), QLatin1String("yield")}, + }; -rust_types = { - {('u'), QLatin1String("union")}, - {('e'), QLatin1String("enum")}, - {('s'), QLatin1String("struct")}, + rust_types + = {{('u'), QLatin1String("union")}, {('e'), QLatin1String("enum")}, + {('s'), QLatin1String("struct")}, - {('i'), QLatin1String("i8")}, - {('i'), QLatin1String("i16")}, - {('i'), QLatin1String("i32")}, - {('i'), QLatin1String("i64")}, - {('i'), QLatin1String("i128")}, - {('i'), QLatin1String("isize")}, - {('u'), QLatin1String("u8")}, - {('u'), QLatin1String("u16")}, - {('u'), QLatin1String("u32")}, - {('u'), QLatin1String("u64")}, - {('u'), QLatin1String("u128")}, - {('u'), QLatin1String("usize")}, - {('f'), QLatin1String("f32")}, - {('f'), QLatin1String("f64")}, - {('s'), QLatin1String("str")}, - {('c'), QLatin1String("char")}, - {('b'), QLatin1String("bool")}, - {('B'), QLatin1String("Box")}, - {('O'), QLatin1String("Option")}, - {('R'), QLatin1String("Result")}, - {('S'), QLatin1String("String")}, - {('V'), QLatin1String("Vec")} -}; + {('i'), QLatin1String("i8")}, {('i'), QLatin1String("i16")}, + {('i'), QLatin1String("i32")}, {('i'), QLatin1String("i64")}, + {('i'), QLatin1String("i128")}, {('i'), QLatin1String("isize")}, + {('u'), QLatin1String("u8")}, {('u'), QLatin1String("u16")}, + {('u'), QLatin1String("u32")}, {('u'), QLatin1String("u64")}, + {('u'), QLatin1String("u128")}, {('u'), QLatin1String("usize")}, + {('f'), QLatin1String("f32")}, {('f'), QLatin1String("f64")}, + {('s'), QLatin1String("str")}, {('c'), QLatin1String("char")}, + {('b'), QLatin1String("bool")}, {('B'), QLatin1String("Box")}, + {('O'), QLatin1String("Option")}, {('R'), QLatin1String("Result")}, + {('S'), QLatin1String("String")}, {('V'), QLatin1String("Vec")}}; -rust_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} -}; + rust_literals + = {{('f'), QLatin1String("false")}, {('t'), QLatin1String("true")}}; -rust_builtin = { + rust_builtin = { -}; + }; -rust_other = { - {('a'), QLatin1String("assert!")}, - {('a'), QLatin1String("assert_eq!")}, - {('b'), QLatin1String("bitflags!")}, - {('b'), QLatin1String("bytes!")}, - {('c'), QLatin1String("cfg!")}, - {('c'), QLatin1String("col!")}, - {('c'), QLatin1String("concat!")}, - {('c'), QLatin1String("concat_idents!")}, - {('d'), QLatin1String("debug_assert!")}, - {('d'), QLatin1String("debug_assert_eq!")}, - {('e'), QLatin1String("env!")}, - {('p'), QLatin1String("panic!")}, - {('f'), QLatin1String("file!")}, - {('f'), QLatin1String("format!")}, - {('f'), QLatin1String("format_args!")}, - {('i'), QLatin1String("include_bin!")}, - {('i'), QLatin1String("include_str!")}, - {('l'), QLatin1String("line!")}, - {('l'), QLatin1String("local_data_key!")}, - {('m'), QLatin1String("module_path!")}, - {('o'), QLatin1String("option_env!")}, - {('p'), QLatin1String("print!")}, - {('p'), QLatin1String("println!")}, - {('s'), QLatin1String("select!")}, - {('s'), QLatin1String("stringify!")}, - {('t'), QLatin1String("try!")}, - {('u'), QLatin1String("unimplemented!")}, - {('u'), QLatin1String("unreachable!")}, - {('v'), QLatin1String("vec!")}, - {('w'), QLatin1String("write!")}, - {('w'), QLatin1String("writeln!")}, - {('m'), QLatin1String("macro_rules!")}, - {('a'), QLatin1String("assert_ne!")}, - {('d'), QLatin1String("debug_assert_ne!")} -}; + rust_other = {{('a'), QLatin1String("assert!")}, + {('a'), QLatin1String("assert_eq!")}, + {('b'), QLatin1String("bitflags!")}, + {('b'), QLatin1String("bytes!")}, + {('c'), QLatin1String("cfg!")}, + {('c'), QLatin1String("col!")}, + {('c'), QLatin1String("concat!")}, + {('c'), QLatin1String("concat_idents!")}, + {('d'), QLatin1String("debug_assert!")}, + {('d'), QLatin1String("debug_assert_eq!")}, + {('e'), QLatin1String("env!")}, + {('p'), QLatin1String("panic!")}, + {('f'), QLatin1String("file!")}, + {('f'), QLatin1String("format!")}, + {('f'), QLatin1String("format_args!")}, + {('i'), QLatin1String("include_bin!")}, + {('i'), QLatin1String("include_str!")}, + {('l'), QLatin1String("line!")}, + {('l'), QLatin1String("local_data_key!")}, + {('m'), QLatin1String("module_path!")}, + {('o'), QLatin1String("option_env!")}, + {('p'), QLatin1String("print!")}, + {('p'), QLatin1String("println!")}, + {('s'), QLatin1String("select!")}, + {('s'), QLatin1String("stringify!")}, + {('t'), QLatin1String("try!")}, + {('u'), QLatin1String("unimplemented!")}, + {('u'), QLatin1String("unreachable!")}, + {('v'), QLatin1String("vec!")}, + {('w'), QLatin1String("write!")}, + {('w'), QLatin1String("writeln!")}, + {('m'), QLatin1String("macro_rules!")}, + {('a'), QLatin1String("assert_ne!")}, + {('d'), QLatin1String("debug_assert_ne!")}}; } -void loadRustData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!rustDataInitialized) { - initRustData(); - rustDataInitialized = true; - } - types = rust_types; - keywords = rust_keywords; - builtin = rust_builtin; - literals = rust_literals; - other = rust_other; +void loadRustData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!rustDataInitialized) + { + initRustData(); + rustDataInitialized = true; + } + types = rust_types; + keywords = rust_keywords; + builtin = rust_builtin; + literals = rust_literals; + other = rust_other; } /********************************************************/ @@ -1397,104 +1243,96 @@ static LanguageData java_types; static LanguageData java_literals; static LanguageData java_builtin; static LanguageData java_other; -void initJavaData() { - java_keywords = { - {('a'), QLatin1String("abstract")}, - {('a'), QLatin1String("assert")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("do")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("exports")}, - {('e'), QLatin1String("extends")}, - {('f'), QLatin1String("final")}, - {('f'), QLatin1String("finally")}, - {('f'), QLatin1String("for")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("implements")}, - {('i'), QLatin1String("import")}, - {('i'), QLatin1String("instanceof")}, - {('i'), QLatin1String("interface")}, - {('l'), QLatin1String("long")}, - {('m'), QLatin1String("module")}, - {('n'), QLatin1String("native")}, - {('n'), QLatin1String("new")}, - {('n'), QLatin1String("null")}, - {('o'), QLatin1String("open")}, - {('o'), QLatin1String("opens")}, - {('p'), QLatin1String("package")}, - {('p'), QLatin1String("private")}, - {('p'), QLatin1String("protected")}, - {('p'), QLatin1String("provides")}, - {('p'), QLatin1String("public")}, - {('r'), QLatin1String("requires")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("strictfp")}, - {('s'), QLatin1String("super")}, - {('s'), QLatin1String("switch")}, - {('s'), QLatin1String("synchronized")}, - {('t'), QLatin1String("this")}, - {('t'), QLatin1String("throw")}, - {('t'), QLatin1String("throws")}, - {('t'), QLatin1String("to")}, - {('t'), QLatin1String("transient")}, - {('t'), QLatin1String("transitive")}, - {('t'), QLatin1String("try")}, - {('u'), QLatin1String("uses")}, - {('v'), QLatin1String("var")}, - {('v'), QLatin1String("volatile")}, - {('w'), QLatin1String("while")}, - {('w'), QLatin1String("with")}, - {('y'), QLatin1String("yield")} - }; +void initJavaData() +{ + java_keywords = {{('a'), QLatin1String("abstract")}, + {('a'), QLatin1String("assert")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("do")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("exports")}, + {('e'), QLatin1String("extends")}, + {('f'), QLatin1String("final")}, + {('f'), QLatin1String("finally")}, + {('f'), QLatin1String("for")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("implements")}, + {('i'), QLatin1String("import")}, + {('i'), QLatin1String("instanceof")}, + {('i'), QLatin1String("interface")}, + {('l'), QLatin1String("long")}, + {('m'), QLatin1String("module")}, + {('n'), QLatin1String("native")}, + {('n'), QLatin1String("new")}, + {('n'), QLatin1String("null")}, + {('o'), QLatin1String("open")}, + {('o'), QLatin1String("opens")}, + {('p'), QLatin1String("package")}, + {('p'), QLatin1String("private")}, + {('p'), QLatin1String("protected")}, + {('p'), QLatin1String("provides")}, + {('p'), QLatin1String("public")}, + {('r'), QLatin1String("requires")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("strictfp")}, + {('s'), QLatin1String("super")}, + {('s'), QLatin1String("switch")}, + {('s'), QLatin1String("synchronized")}, + {('t'), QLatin1String("this")}, + {('t'), QLatin1String("throw")}, + {('t'), QLatin1String("throws")}, + {('t'), QLatin1String("to")}, + {('t'), QLatin1String("transient")}, + {('t'), QLatin1String("transitive")}, + {('t'), QLatin1String("try")}, + {('u'), QLatin1String("uses")}, + {('v'), QLatin1String("var")}, + {('v'), QLatin1String("volatile")}, + {('w'), QLatin1String("while")}, + {('w'), QLatin1String("with")}, + {('y'), QLatin1String("yield")}}; - java_types = { - {('v'), QLatin1String("void")}, - {('f'), QLatin1String("float")}, - {('b'), QLatin1String("boolean")}, - {('b'), QLatin1String("byte")}, - {('i'), QLatin1String("int")}, - {('c'), QLatin1String("char")}, - {('c'), QLatin1String("class")}, - {('d'), QLatin1String("double")}, - {('e'), QLatin1String("enum")}, - {('s'), QLatin1String("short")}, + java_types = { + {('v'), QLatin1String("void")}, {('f'), QLatin1String("float")}, + {('b'), QLatin1String("boolean")}, {('b'), QLatin1String("byte")}, + {('i'), QLatin1String("int")}, {('c'), QLatin1String("char")}, + {('c'), QLatin1String("class")}, {('d'), QLatin1String("double")}, + {('e'), QLatin1String("enum")}, {('s'), QLatin1String("short")}, - }; + }; - java_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} - }; + java_literals + = {{('f'), QLatin1String("false")}, {('t'), QLatin1String("true")}}; - java_builtin = { + java_builtin = { - }; + }; - java_other = { + java_other = { - }; + }; } -void loadJavaData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!javaDataInitialized) { - initJavaData(); - javaDataInitialized = true; - } - types = java_types; - keywords = java_keywords; - builtin = java_builtin; - literals = java_literals; - other = java_other; +void loadJavaData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!javaDataInitialized) + { + initJavaData(); + javaDataInitialized = true; + } + types = java_types; + keywords = java_keywords; + builtin = java_builtin; + literals = java_literals; + other = java_other; } /********************************************************/ @@ -1506,149 +1344,131 @@ static LanguageData csharp_types; static LanguageData csharp_literals; static LanguageData csharp_builtin; static LanguageData csharp_other; -void initCSharpData() { - csharp_keywords = { - {('a'), QLatin1String("abstract")}, - {('a'), QLatin1String("add")}, - {('a'), QLatin1String("alias")}, - {('a'), QLatin1String("as")}, - {('a'), QLatin1String("ascending")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('b'), QLatin1String("base")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("checked")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("decimal")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("delegate")}, - {('d'), QLatin1String("descending")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("dynamic")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("event")}, - {('e'), QLatin1String("explicit")}, - {('e'), QLatin1String("extern")}, - {('f'), QLatin1String("finally")}, - {('f'), QLatin1String("fixed")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("foreach")}, - {('f'), QLatin1String("from")}, - {('g'), QLatin1String("get")}, - {('g'), QLatin1String("global")}, - {('g'), QLatin1String("goto")}, - {('g'), QLatin1String("group")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("implicit")}, - {('i'), QLatin1String("in")}, - {('i'), QLatin1String("interface")}, - {('i'), QLatin1String("internal")}, - {('i'), QLatin1String("into")}, - {('i'), QLatin1String("is")}, - {('j'), QLatin1String("join")}, - {('l'), QLatin1String("let")}, - {('l'), QLatin1String("lock")}, - {('l'), QLatin1String("long")}, - {('n'), QLatin1String("namespace")}, - {('n'), QLatin1String("new")}, - {('o'), QLatin1String("object")}, - {('o'), QLatin1String("operator")}, - {('o'), QLatin1String("orderby")}, - {('o'), QLatin1String("out")}, - {('o'), QLatin1String("override")}, - {('p'), QLatin1String("params")}, - {('p'), QLatin1String("partial")}, - {('p'), QLatin1String("private")}, - {('p'), QLatin1String("protected")}, - {('p'), QLatin1String("public")}, - {('r'), QLatin1String("readonly")}, - {('r'), QLatin1String("ref")}, - {('r'), QLatin1String("remove")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("sealed")}, - {('s'), QLatin1String("select")}, - {('s'), QLatin1String("set")}, - {('s'), QLatin1String("sizeof")}, - {('s'), QLatin1String("stackalloc")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("this")}, - {('t'), QLatin1String("throw")}, - {('t'), QLatin1String("try")}, - {('t'), QLatin1String("typeof")}, - {('u'), QLatin1String("unchecked")}, - {('u'), QLatin1String("unsafe")}, - {('u'), QLatin1String("using")}, - {('v'), QLatin1String("value")}, - {('v'), QLatin1String("virtual")}, - {('v'), QLatin1String("volatile")}, - {('w'), QLatin1String("where")}, - {('w'), QLatin1String("while")}, - {('y'), QLatin1String("yield")} - }; +void initCSharpData() +{ + csharp_keywords = {{('a'), QLatin1String("abstract")}, + {('a'), QLatin1String("add")}, + {('a'), QLatin1String("alias")}, + {('a'), QLatin1String("as")}, + {('a'), QLatin1String("ascending")}, + {('a'), QLatin1String("async")}, + {('a'), QLatin1String("await")}, + {('b'), QLatin1String("base")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("checked")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("decimal")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("delegate")}, + {('d'), QLatin1String("descending")}, + {('d'), QLatin1String("do")}, + {('d'), QLatin1String("dynamic")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("event")}, + {('e'), QLatin1String("explicit")}, + {('e'), QLatin1String("extern")}, + {('f'), QLatin1String("finally")}, + {('f'), QLatin1String("fixed")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("foreach")}, + {('f'), QLatin1String("from")}, + {('g'), QLatin1String("get")}, + {('g'), QLatin1String("global")}, + {('g'), QLatin1String("goto")}, + {('g'), QLatin1String("group")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("implicit")}, + {('i'), QLatin1String("in")}, + {('i'), QLatin1String("interface")}, + {('i'), QLatin1String("internal")}, + {('i'), QLatin1String("into")}, + {('i'), QLatin1String("is")}, + {('j'), QLatin1String("join")}, + {('l'), QLatin1String("let")}, + {('l'), QLatin1String("lock")}, + {('l'), QLatin1String("long")}, + {('n'), QLatin1String("namespace")}, + {('n'), QLatin1String("new")}, + {('o'), QLatin1String("object")}, + {('o'), QLatin1String("operator")}, + {('o'), QLatin1String("orderby")}, + {('o'), QLatin1String("out")}, + {('o'), QLatin1String("override")}, + {('p'), QLatin1String("params")}, + {('p'), QLatin1String("partial")}, + {('p'), QLatin1String("private")}, + {('p'), QLatin1String("protected")}, + {('p'), QLatin1String("public")}, + {('r'), QLatin1String("readonly")}, + {('r'), QLatin1String("ref")}, + {('r'), QLatin1String("remove")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("sealed")}, + {('s'), QLatin1String("select")}, + {('s'), QLatin1String("set")}, + {('s'), QLatin1String("sizeof")}, + {('s'), QLatin1String("stackalloc")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("this")}, + {('t'), QLatin1String("throw")}, + {('t'), QLatin1String("try")}, + {('t'), QLatin1String("typeof")}, + {('u'), QLatin1String("unchecked")}, + {('u'), QLatin1String("unsafe")}, + {('u'), QLatin1String("using")}, + {('v'), QLatin1String("value")}, + {('v'), QLatin1String("virtual")}, + {('v'), QLatin1String("volatile")}, + {('w'), QLatin1String("where")}, + {('w'), QLatin1String("while")}, + {('y'), QLatin1String("yield")}}; - csharp_types = { - {('b'), QLatin1String("bool")}, - {('b'), QLatin1String("byte")}, - {('c'), QLatin1String("char")}, - {('c'), QLatin1String("class")}, - {('d'), QLatin1String("double")}, - {('e'), QLatin1String("enum")}, - {('f'), QLatin1String("float")}, - {('i'), QLatin1String("int")}, - {('s'), QLatin1String("sbyte")}, - {('s'), QLatin1String("short")}, - {('s'), QLatin1String("string")}, - {('s'), QLatin1String("struct")}, - {('u'), QLatin1String("uint")}, - {('u'), QLatin1String("ulong")}, - {('u'), QLatin1String("ushort")}, - {('v'), QLatin1String("var")}, - {('v'), QLatin1String("void")}, - }; + csharp_types = { + {('b'), QLatin1String("bool")}, {('b'), QLatin1String("byte")}, + {('c'), QLatin1String("char")}, {('c'), QLatin1String("class")}, + {('d'), QLatin1String("double")}, {('e'), QLatin1String("enum")}, + {('f'), QLatin1String("float")}, {('i'), QLatin1String("int")}, + {('s'), QLatin1String("sbyte")}, {('s'), QLatin1String("short")}, + {('s'), QLatin1String("string")}, {('s'), QLatin1String("struct")}, + {('u'), QLatin1String("uint")}, {('u'), QLatin1String("ulong")}, + {('u'), QLatin1String("ushort")}, {('v'), QLatin1String("var")}, + {('v'), QLatin1String("void")}, + }; - csharp_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")} - }; + csharp_literals = {{('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}}; - csharp_builtin = { + csharp_builtin = { - }; + }; - csharp_other = { - {('d'), QLatin1String("define")}, - {('e'), QLatin1String("elif")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("endif")}, - {('e'), QLatin1String("endregion")}, - {('e'), QLatin1String("error")}, - {('i'), QLatin1String("if")}, - {('l'), QLatin1String("line")}, - {('p'), QLatin1String("pragma")}, - {('r'), QLatin1String("region")}, - {('u'), QLatin1String("undef")}, - {('w'), QLatin1String("warning")} - }; + csharp_other = { + {('d'), QLatin1String("define")}, {('e'), QLatin1String("elif")}, + {('e'), QLatin1String("else")}, {('e'), QLatin1String("endif")}, + {('e'), QLatin1String("endregion")}, {('e'), QLatin1String("error")}, + {('i'), QLatin1String("if")}, {('l'), QLatin1String("line")}, + {('p'), QLatin1String("pragma")}, {('r'), QLatin1String("region")}, + {('u'), QLatin1String("undef")}, {('w'), QLatin1String("warning")}}; } -void loadCSharpData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other){ - if (!csharpDataInitialized) { - initCSharpData(); - csharpDataInitialized = true; - } - types = csharp_types; - keywords = csharp_keywords; - builtin = csharp_builtin; - literals = csharp_literals; - other = csharp_other; +void loadCSharpData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!csharpDataInitialized) + { + initCSharpData(); + csharpDataInitialized = true; + } + types = csharp_types; + keywords = csharp_keywords; + builtin = csharp_builtin; + literals = csharp_literals; + other = csharp_other; } /********************************************************/ @@ -1660,101 +1480,80 @@ static LanguageData go_types; static LanguageData go_literals; static LanguageData go_builtin; static LanguageData go_other; -void initGoData(){ - go_keywords = { - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("chan")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("defer")}, - {('e'), QLatin1String("else")}, - {('f'), QLatin1String("fallthrough")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("func")}, - {('g'), QLatin1String("go")}, - {('t'), QLatin1String("to")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("import")}, - {('i'), QLatin1String("interface")}, - {('p'), QLatin1String("package")}, - {('r'), QLatin1String("range")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("select")}, - {('s'), QLatin1String("struct")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("type")}, - }; +void initGoData() +{ + go_keywords = { + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("chan")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("defer")}, + {('e'), QLatin1String("else")}, + {('f'), QLatin1String("fallthrough")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("func")}, + {('g'), QLatin1String("go")}, + {('t'), QLatin1String("to")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("import")}, + {('i'), QLatin1String("interface")}, + {('p'), QLatin1String("package")}, + {('r'), QLatin1String("range")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("select")}, + {('s'), QLatin1String("struct")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("type")}, + }; - go_types = { - {('m'), QLatin1String("map")}, - {('s'), QLatin1String("struct")}, - {('v'), QLatin1String("var")}, - {('b'), QLatin1String("bool")}, - {('b'), QLatin1String("byte")}, - {('c'), QLatin1String("complex64")}, - {('c'), QLatin1String("complex128")}, - {('f'), QLatin1String("float32")}, - {('f'), QLatin1String("float64")}, - {('i'), QLatin1String("int8")}, - {('i'), QLatin1String("int16")}, - {('i'), QLatin1String("int32")}, - {('i'), QLatin1String("int64")}, - {('s'), QLatin1String("string")}, - {('u'), QLatin1String("uint8")}, - {('u'), QLatin1String("uint16")}, - {('u'), QLatin1String("uint32")}, - {('u'), QLatin1String("uint64")}, - {('i'), QLatin1String("int")}, - {('u'), QLatin1String("uint")}, - {('u'), QLatin1String("uintptr")}, - {('r'), QLatin1String("rune")} - }; + go_types = { + {('m'), QLatin1String("map")}, {('s'), QLatin1String("struct")}, + {('v'), QLatin1String("var")}, {('b'), QLatin1String("bool")}, + {('b'), QLatin1String("byte")}, {('c'), QLatin1String("complex64")}, + {('c'), QLatin1String("complex128")}, {('f'), QLatin1String("float32")}, + {('f'), QLatin1String("float64")}, {('i'), QLatin1String("int8")}, + {('i'), QLatin1String("int16")}, {('i'), QLatin1String("int32")}, + {('i'), QLatin1String("int64")}, {('s'), QLatin1String("string")}, + {('u'), QLatin1String("uint8")}, {('u'), QLatin1String("uint16")}, + {('u'), QLatin1String("uint32")}, {('u'), QLatin1String("uint64")}, + {('i'), QLatin1String("int")}, {('u'), QLatin1String("uint")}, + {('u'), QLatin1String("uintptr")}, {('r'), QLatin1String("rune")}}; - go_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("nil")}, - {('i'), QLatin1String("iota")} - }; + go_literals = {{('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("nil")}, + {('i'), QLatin1String("iota")}}; - go_builtin = { - {('a'), QLatin1String("append")}, - {('c'), QLatin1String("cap")}, - {('c'), QLatin1String("close")}, - {('c'), QLatin1String("complex")}, - {('c'), QLatin1String("copy")}, - {('i'), QLatin1String("imag")}, - {('l'), QLatin1String("len")}, - {('m'), QLatin1String("make")}, - {('n'), QLatin1String("new")}, - {('p'), QLatin1String("panic")}, - {('p'), QLatin1String("print")}, - {('p'), QLatin1String("println")}, - {('r'), QLatin1String("real")}, - {('r'), QLatin1String("recover")}, - {('d'), QLatin1String("delete")} - }; + go_builtin + = {{('a'), QLatin1String("append")}, {('c'), QLatin1String("cap")}, + {('c'), QLatin1String("close")}, {('c'), QLatin1String("complex")}, + {('c'), QLatin1String("copy")}, {('i'), QLatin1String("imag")}, + {('l'), QLatin1String("len")}, {('m'), QLatin1String("make")}, + {('n'), QLatin1String("new")}, {('p'), QLatin1String("panic")}, + {('p'), QLatin1String("print")}, {('p'), QLatin1String("println")}, + {('r'), QLatin1String("real")}, {('r'), QLatin1String("recover")}, + {('d'), QLatin1String("delete")}}; - go_other = { + go_other = { - }; + }; } -void loadGoData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!goDataInitialized) { - initGoData(); - goDataInitialized = true; - } - types = go_types; - keywords = go_keywords; - builtin = go_builtin; - literals = go_literals; - other = go_other; +void loadGoData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!goDataInitialized) + { + initGoData(); + goDataInitialized = true; + } + types = go_types; + keywords = go_keywords; + builtin = go_builtin; + literals = go_literals; + other = go_other; } /********************************************************/ @@ -1766,77 +1565,57 @@ static LanguageData v_types; static LanguageData v_literals; static LanguageData v_builtin; static LanguageData v_other; -void initVData() { - v_keywords = { - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("defer")}, - {('e'), QLatin1String("else")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("fn")}, - {('g'), QLatin1String("go")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("import")}, - {('i'), QLatin1String("interface")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("struct")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("type")}, - {('p'), QLatin1String("pub")}, - {('o'), QLatin1String("or")}, - {('n'), QLatin1String("none")} - }; +void initVData() +{ + v_keywords = { + {('b'), QLatin1String("break")}, {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, {('d'), QLatin1String("defer")}, + {('e'), QLatin1String("else")}, {('f'), QLatin1String("for")}, + {('f'), QLatin1String("fn")}, {('g'), QLatin1String("go")}, + {('g'), QLatin1String("goto")}, {('i'), QLatin1String("if")}, + {('i'), QLatin1String("import")}, {('i'), QLatin1String("interface")}, + {('r'), QLatin1String("return")}, {('s'), QLatin1String("struct")}, + {('s'), QLatin1String("switch")}, {('t'), QLatin1String("type")}, + {('p'), QLatin1String("pub")}, {('o'), QLatin1String("or")}, + {('n'), QLatin1String("none")}}; - v_types = { - {('m'), QLatin1String("map")}, - {('s'), QLatin1String("struct")}, - {('b'), QLatin1String("bool")}, - {('b'), QLatin1String("byte")}, - {('f'), QLatin1String("f32")}, - {('f'), QLatin1String("f64")}, - {('i'), QLatin1String("i8")}, - {('i'), QLatin1String("i16")}, - {('i'), QLatin1String("int")}, - {('i'), QLatin1String("i64")}, - {('i'), QLatin1String("i128")}, - {('s'), QLatin1String("string")}, - {('u'), QLatin1String("u16")}, - {('u'), QLatin1String("u32")}, - {('u'), QLatin1String("u64")}, - {('u'), QLatin1String("u128")}, - {('u'), QLatin1String("byteptr")}, - {('u'), QLatin1String("voidptr")}, - {('r'), QLatin1String("rune")} - }; + v_types + = {{('m'), QLatin1String("map")}, {('s'), QLatin1String("struct")}, + {('b'), QLatin1String("bool")}, {('b'), QLatin1String("byte")}, + {('f'), QLatin1String("f32")}, {('f'), QLatin1String("f64")}, + {('i'), QLatin1String("i8")}, {('i'), QLatin1String("i16")}, + {('i'), QLatin1String("int")}, {('i'), QLatin1String("i64")}, + {('i'), QLatin1String("i128")}, {('s'), QLatin1String("string")}, + {('u'), QLatin1String("u16")}, {('u'), QLatin1String("u32")}, + {('u'), QLatin1String("u64")}, {('u'), QLatin1String("u128")}, + {('u'), QLatin1String("byteptr")}, {('u'), QLatin1String("voidptr")}, + {('r'), QLatin1String("rune")}}; - v_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - }; + v_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + }; - v_builtin = { - }; + v_builtin = {}; - v_other = { + v_other = { - }; + }; } -void loadVData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!vDataInitialized) { - initVData(); - vDataInitialized = true; - } - types = v_types; - keywords = v_keywords; - builtin = v_builtin; - literals = v_literals; - other = v_other; +void loadVData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!vDataInitialized) + { + initVData(); + vDataInitialized = true; + } + types = v_types; + keywords = v_keywords; + builtin = v_builtin; + literals = v_literals; + other = v_other; } /********************************************************/ @@ -1848,364 +1627,355 @@ static LanguageData sql_types; static LanguageData sql_literals; static LanguageData sql_builtin; static LanguageData sql_other; -void initSQLData() { - sql_keywords = { - {('A'), QLatin1String("ACTION")}, - {('A'), QLatin1String("ADD")}, - {('A'), QLatin1String("AFTER")}, - {('A'), QLatin1String("ALGORITHM")}, - {('A'), QLatin1String("ALL")}, - {('A'), QLatin1String("ALTER")}, - {('A'), QLatin1String("ANALYZE")}, - {('A'), QLatin1String("ANY")}, - {('A'), QLatin1String("APPLY")}, - {('A'), QLatin1String("AS")}, - {('A'), QLatin1String("ASC")}, - {('A'), QLatin1String("AUTHORIZATION")}, - {('A'), QLatin1String("AUTO_INCREMENT")}, - {('B'), QLatin1String("BACKUP")}, - {('B'), QLatin1String("BDB")}, - {('B'), QLatin1String("BEGIN")}, - {('B'), QLatin1String("BERKELEYDB")}, - {('B'), QLatin1String("BIGINT")}, - {('B'), QLatin1String("BINARY")}, - {('B'), QLatin1String("BIT")}, - {('B'), QLatin1String("BLOB")}, - {('B'), QLatin1String("BOOL")}, - {('B'), QLatin1String("BOOLEAN")}, - {('B'), QLatin1String("BREAK")}, - {('B'), QLatin1String("BROWSE")}, - {('B'), QLatin1String("BTREE")}, - {('B'), QLatin1String("BULK")}, - {('B'), QLatin1String("BY")}, - {('C'), QLatin1String("CALL")}, - {('C'), QLatin1String("CASCADED")}, - {('C'), QLatin1String("CASE")}, - {('C'), QLatin1String("CHAIN")}, - {('C'), QLatin1String("CHARACTER")}, - {('S'), QLatin1String("SET")}, - {('C'), QLatin1String("CHECKPOINT")}, - {('C'), QLatin1String("CLOSE")}, - {('C'), QLatin1String("CLUSTERED")}, - {('C'), QLatin1String("COALESCE")}, - {('C'), QLatin1String("COLLATE")}, - {('C'), QLatin1String("COLUMNS")}, - {('C'), QLatin1String("COMMENT")}, - {('C'), QLatin1String("COMMITTED")}, - {('C'), QLatin1String("COMPUTE")}, - {('C'), QLatin1String("CONNECT")}, - {('C'), QLatin1String("CONSISTENT")}, - {('C'), QLatin1String("CONSTRAINT")}, - {('C'), QLatin1String("CONTAINSTABLE")}, - {('C'), QLatin1String("CONTINUE")}, - {('C'), QLatin1String("CONVERT")}, - {('C'), QLatin1String("CREATE")}, - {('C'), QLatin1String("CROSS")}, - {('C'), QLatin1String("CURRENT_DATE")}, - {('_'), QLatin1String("_TIME")}, - {('_'), QLatin1String("_TIMESTAMP")}, - {('_'), QLatin1String("_USER")}, - {('C'), QLatin1String("CURSOR")}, - {('C'), QLatin1String("CYCLE")}, - {('D'), QLatin1String("DATABASES")}, - {('D'), QLatin1String("DATETIME")}, - {('D'), QLatin1String("DAY")}, - {('D'), QLatin1String("DBCC")}, - {('D'), QLatin1String("DEALLOCATE")}, - {('D'), QLatin1String("DEC")}, - {('D'), QLatin1String("DECIMAL")}, - {('D'), QLatin1String("DECLARE")}, - {('D'), QLatin1String("DEFAULT")}, - {('D'), QLatin1String("DEFINER")}, - {('D'), QLatin1String("DELAYED")}, - {('D'), QLatin1String("DELETE")}, - {('D'), QLatin1String("DELIMITERS")}, - {('D'), QLatin1String("DENY")}, - {('D'), QLatin1String("DESC")}, - {('D'), QLatin1String("DESCRIBE")}, - {('D'), QLatin1String("DETERMINISTIC")}, - {('D'), QLatin1String("DISABLE")}, - {('D'), QLatin1String("DISCARD")}, - {('D'), QLatin1String("DISK")}, - {('D'), QLatin1String("DISTINCT")}, - {('D'), QLatin1String("DISTINCTROW")}, - {('D'), QLatin1String("DISTRIBUTED")}, - {('D'), QLatin1String("DO")}, - {('D'), QLatin1String("DOUBLE")}, - {('D'), QLatin1String("DROP")}, - {('D'), QLatin1String("DUMMY")}, - {('D'), QLatin1String("DUMPFILE")}, - {('D'), QLatin1String("DUPLICATE")}, - {('E'), QLatin1String("ELSEIF")}, - {('E'), QLatin1String("ENABLE")}, - {('E'), QLatin1String("ENCLOSED")}, - {('E'), QLatin1String("END")}, - {('E'), QLatin1String("ENGINE")}, - {('E'), QLatin1String("ENUM")}, - {('E'), QLatin1String("ERRLVL")}, - {('E'), QLatin1String("ERRORS")}, - {('E'), QLatin1String("ESCAPED")}, - {('E'), QLatin1String("EXCEPT")}, - {('E'), QLatin1String("EXECUTE")}, - {('E'), QLatin1String("EXISTS")}, - {('E'), QLatin1String("EXIT")}, - {('E'), QLatin1String("EXPLAIN")}, - {('E'), QLatin1String("EXTENDED")}, - {('F'), QLatin1String("FETCH")}, - {('F'), QLatin1String("FIELDS")}, - {('F'), QLatin1String("FILE")}, - {('F'), QLatin1String("FILLFACTOR")}, - {('F'), QLatin1String("FIRST")}, - {('F'), QLatin1String("FIXED")}, - {('F'), QLatin1String("FLOAT")}, - {('F'), QLatin1String("FOLLOWING")}, - {('F'), QLatin1String("FOR")}, - {('E'), QLatin1String("EACH")}, - {('R'), QLatin1String("ROW")}, - {('F'), QLatin1String("FORCE")}, - {('F'), QLatin1String("FOREIGN")}, - {('F'), QLatin1String("FREETEXTTABLE")}, - {('F'), QLatin1String("FROM")}, - {('F'), QLatin1String("FULL")}, - {('F'), QLatin1String("FUNCTION")}, - {('G'), QLatin1String("GEOMETRYCOLLECTION")}, - {('G'), QLatin1String("GLOBAL")}, - {('G'), QLatin1String("GOTO")}, - {('G'), QLatin1String("GRANT")}, - {('G'), QLatin1String("GROUP")}, - {('H'), QLatin1String("HANDLER")}, - {('H'), QLatin1String("HASH")}, - {('H'), QLatin1String("HAVING")}, - {('H'), QLatin1String("HOLDLOCK")}, - {('H'), QLatin1String("HOUR")}, - {('I'), QLatin1String("IDENTITY_INSERT")}, - {('C'), QLatin1String("COL")}, - {('I'), QLatin1String("IF")}, - {('I'), QLatin1String("IGNORE")}, - {('I'), QLatin1String("IMPORT")}, - {('I'), QLatin1String("INDEX")}, - {('I'), QLatin1String("INFILE")}, - {('I'), QLatin1String("INNER")}, - {('I'), QLatin1String("INNODB")}, - {('I'), QLatin1String("INOUT")}, - {('I'), QLatin1String("INSERT")}, - {('I'), QLatin1String("INT")}, - {('I'), QLatin1String("INTEGER")}, - {('I'), QLatin1String("INTERSECT")}, - {('I'), QLatin1String("INTERVAL")}, - {('I'), QLatin1String("INTO")}, - {('I'), QLatin1String("INVOKER")}, - {('I'), QLatin1String("ISOLATION")}, - {('I'), QLatin1String("ITERATE")}, - {('J'), QLatin1String("JOIN")}, - {('K'), QLatin1String("KEYS")}, - {('K'), QLatin1String("KILL")}, - {('L'), QLatin1String("LANGUAGE")}, - {('L'), QLatin1String("LAST")}, - {('L'), QLatin1String("LEAVE")}, - {('L'), QLatin1String("LEFT")}, - {('L'), QLatin1String("LEVEL")}, - {('L'), QLatin1String("LIMIT")}, - {('L'), QLatin1String("LINENO")}, - {('L'), QLatin1String("LINES")}, - {('L'), QLatin1String("LINESTRING")}, - {('L'), QLatin1String("LOAD")}, - {('L'), QLatin1String("LOCAL")}, - {('L'), QLatin1String("LOCK")}, - {('L'), QLatin1String("LONGBLOB")}, - {('T'), QLatin1String("TEXT")}, - {('L'), QLatin1String("LOOP")}, - {('M'), QLatin1String("MATCHED")}, - {('M'), QLatin1String("MEDIUMBLOB")}, - {('I'), QLatin1String("INT")}, - {('T'), QLatin1String("TEXT")}, - {('M'), QLatin1String("MERGE")}, - {('M'), QLatin1String("MIDDLEINT")}, - {('M'), QLatin1String("MINUTE")}, - {('M'), QLatin1String("MODE")}, - {('M'), QLatin1String("MODIFIES")}, - {('M'), QLatin1String("MODIFY")}, - {('M'), QLatin1String("MONTH")}, - {('M'), QLatin1String("MULTILINESTRING")}, - {('P'), QLatin1String("POINT")}, - {('P'), QLatin1String("POLYGON")}, - {('N'), QLatin1String("NATIONAL")}, - {('N'), QLatin1String("NATURAL")}, - {('N'), QLatin1String("NCHAR")}, - {('N'), QLatin1String("NEXT")}, - {('N'), QLatin1String("NO")}, - {('N'), QLatin1String("NONCLUSTERED")}, - {('N'), QLatin1String("NULLIF")}, - {('N'), QLatin1String("NUMERIC")}, - {('O'), QLatin1String("OFF")}, - {('O'), QLatin1String("OFFSETS")}, - {('O'), QLatin1String("ON")}, - {('O'), QLatin1String("OPENDATASOURCE")}, - {('Q'), QLatin1String("QUERY")}, - {('R'), QLatin1String("ROWSET")}, - {('O'), QLatin1String("OPTIMIZE")}, - {('O'), QLatin1String("OPTIONALLY")}, - {('O'), QLatin1String("ORDER")}, - {('O'), QLatin1String("OUTER")}, - {('F'), QLatin1String("FILE")}, - {('O'), QLatin1String("OVER")}, - {('P'), QLatin1String("PARTIAL")}, - {('P'), QLatin1String("PARTITION")}, - {('P'), QLatin1String("PERCENT")}, - {('P'), QLatin1String("PIVOT")}, - {('P'), QLatin1String("PLAN")}, - {('P'), QLatin1String("POINT")}, - {('P'), QLatin1String("POLYGON")}, - {('P'), QLatin1String("PRECEDING")}, - {('P'), QLatin1String("PRECISION")}, - {('P'), QLatin1String("PREPARE")}, - {('P'), QLatin1String("PREV")}, - {('P'), QLatin1String("PRIMARY")}, - {('P'), QLatin1String("PRINT")}, - {('P'), QLatin1String("PRIVILEGES")}, - {('P'), QLatin1String("PROCEDURE")}, - {('P'), QLatin1String("PUBLIC")}, - {('P'), QLatin1String("PURGE")}, - {('Q'), QLatin1String("QUICK")}, - {('R'), QLatin1String("RAISERROR")}, - {('R'), QLatin1String("READS")}, - {('R'), QLatin1String("REAL")}, - {('R'), QLatin1String("RECONFIGURE")}, - {('R'), QLatin1String("REFERENCES")}, - {('R'), QLatin1String("RELEASE")}, - {('R'), QLatin1String("RENAME")}, - {('R'), QLatin1String("REPEATABLE")}, - {('R'), QLatin1String("REPLACE")}, - {('R'), QLatin1String("REPLICATION")}, - {('R'), QLatin1String("REQUIRE")}, - {('R'), QLatin1String("RESIGNAL")}, - {('R'), QLatin1String("RESTORE")}, - {('R'), QLatin1String("RESTRICT")}, - {('R'), QLatin1String("RETURNS")}, - {('R'), QLatin1String("REVOKE")}, - {('R'), QLatin1String("RIGHT")}, - {('R'), QLatin1String("ROLLBACK")}, - {('R'), QLatin1String("ROUTINE")}, - {('R'), QLatin1String("ROWCOUNT")}, - {('G'), QLatin1String("GUIDCOL")}, - {('R'), QLatin1String("RTREE")}, - {('R'), QLatin1String("RULE")}, - {('S'), QLatin1String("SAVEPOINT")}, - {('S'), QLatin1String("SCHEMA")}, - {('S'), QLatin1String("SECOND")}, - {('S'), QLatin1String("SELECT")}, - {('S'), QLatin1String("SERIALIZABLE")}, - {('S'), QLatin1String("SESSION_USER")}, - {('S'), QLatin1String("SETUSER")}, - {('S'), QLatin1String("SHARE")}, - {('S'), QLatin1String("SHOW")}, - {('S'), QLatin1String("SHUTDOWN")}, - {('S'), QLatin1String("SIMPLE")}, - {('S'), QLatin1String("SMALLINT")}, - {('S'), QLatin1String("SNAPSHOT")}, - {('S'), QLatin1String("SOME")}, - {('S'), QLatin1String("SONAME")}, - {('S'), QLatin1String("SQL")}, - {('S'), QLatin1String("STARTING")}, - {('S'), QLatin1String("STATISTICS")}, - {('S'), QLatin1String("STATUS")}, - {('S'), QLatin1String("STRIPED")}, - {('S'), QLatin1String("SYSTEM_USER")}, - {('T'), QLatin1String("TABLES")}, - {('T'), QLatin1String("TABLESPACE")}, - {('T'), QLatin1String("TEMPORARY")}, - {('T'), QLatin1String("TABLE")}, - {('T'), QLatin1String("TERMINATED")}, - {('T'), QLatin1String("TEXTSIZE")}, - {('T'), QLatin1String("THEN")}, - {('T'), QLatin1String("TIMESTAMP")}, - {('T'), QLatin1String("TINYBLOB")}, - {('I'), QLatin1String("INT")}, - {('T'), QLatin1String("TEXT")}, - {('T'), QLatin1String("TOP")}, - {('T'), QLatin1String("TRANSACTIONS")}, - {('T'), QLatin1String("TRIGGER")}, - {('T'), QLatin1String("TRUNCATE")}, - {('T'), QLatin1String("TSEQUAL")}, - {('T'), QLatin1String("TYPES")}, - {('U'), QLatin1String("UNBOUNDED")}, - {('U'), QLatin1String("UNCOMMITTED")}, - {('U'), QLatin1String("UNDEFINED")}, - {('U'), QLatin1String("UNION")}, - {('U'), QLatin1String("UNIQUE")}, - {('U'), QLatin1String("UNLOCK")}, - {('U'), QLatin1String("UNPIVOT")}, - {('U'), QLatin1String("UNSIGNED")}, - {('U'), QLatin1String("UPDATETEXT")}, - {('U'), QLatin1String("USAGE")}, - {('U'), QLatin1String("USE")}, - {('U'), QLatin1String("USER")}, - {('U'), QLatin1String("USING")}, - {('V'), QLatin1String("VALUES")}, - {('V'), QLatin1String("VARBINARY")}, - {('C'), QLatin1String("CHAR")}, - {('C'), QLatin1String("CHARACTER")}, - {('Y'), QLatin1String("YING")}, - {('V'), QLatin1String("VIEW")}, - {('W'), QLatin1String("WAITFOR")}, - {('W'), QLatin1String("WARNINGS")}, - {('W'), QLatin1String("WHEN")}, - {('W'), QLatin1String("WHERE")}, - {('W'), QLatin1String("WHILE")}, - {('W'), QLatin1String("WITH")}, - {('R'), QLatin1String("ROLLUP")}, - {('I'), QLatin1String("IN")}, - {('W'), QLatin1String("WORK")}, - {('W'), QLatin1String("WRITETEXT")}, - {('Y'), QLatin1String("YEAR")} - }; +void initSQLData() +{ + sql_keywords = {{('A'), QLatin1String("ACTION")}, + {('A'), QLatin1String("ADD")}, + {('A'), QLatin1String("AFTER")}, + {('A'), QLatin1String("ALGORITHM")}, + {('A'), QLatin1String("ALL")}, + {('A'), QLatin1String("ALTER")}, + {('A'), QLatin1String("ANALYZE")}, + {('A'), QLatin1String("ANY")}, + {('A'), QLatin1String("APPLY")}, + {('A'), QLatin1String("AS")}, + {('A'), QLatin1String("ASC")}, + {('A'), QLatin1String("AUTHORIZATION")}, + {('A'), QLatin1String("AUTO_INCREMENT")}, + {('B'), QLatin1String("BACKUP")}, + {('B'), QLatin1String("BDB")}, + {('B'), QLatin1String("BEGIN")}, + {('B'), QLatin1String("BERKELEYDB")}, + {('B'), QLatin1String("BIGINT")}, + {('B'), QLatin1String("BINARY")}, + {('B'), QLatin1String("BIT")}, + {('B'), QLatin1String("BLOB")}, + {('B'), QLatin1String("BOOL")}, + {('B'), QLatin1String("BOOLEAN")}, + {('B'), QLatin1String("BREAK")}, + {('B'), QLatin1String("BROWSE")}, + {('B'), QLatin1String("BTREE")}, + {('B'), QLatin1String("BULK")}, + {('B'), QLatin1String("BY")}, + {('C'), QLatin1String("CALL")}, + {('C'), QLatin1String("CASCADED")}, + {('C'), QLatin1String("CASE")}, + {('C'), QLatin1String("CHAIN")}, + {('C'), QLatin1String("CHARACTER")}, + {('S'), QLatin1String("SET")}, + {('C'), QLatin1String("CHECKPOINT")}, + {('C'), QLatin1String("CLOSE")}, + {('C'), QLatin1String("CLUSTERED")}, + {('C'), QLatin1String("COALESCE")}, + {('C'), QLatin1String("COLLATE")}, + {('C'), QLatin1String("COLUMNS")}, + {('C'), QLatin1String("COMMENT")}, + {('C'), QLatin1String("COMMITTED")}, + {('C'), QLatin1String("COMPUTE")}, + {('C'), QLatin1String("CONNECT")}, + {('C'), QLatin1String("CONSISTENT")}, + {('C'), QLatin1String("CONSTRAINT")}, + {('C'), QLatin1String("CONTAINSTABLE")}, + {('C'), QLatin1String("CONTINUE")}, + {('C'), QLatin1String("CONVERT")}, + {('C'), QLatin1String("CREATE")}, + {('C'), QLatin1String("CROSS")}, + {('C'), QLatin1String("CURRENT_DATE")}, + {('_'), QLatin1String("_TIME")}, + {('_'), QLatin1String("_TIMESTAMP")}, + {('_'), QLatin1String("_USER")}, + {('C'), QLatin1String("CURSOR")}, + {('C'), QLatin1String("CYCLE")}, + {('D'), QLatin1String("DATABASES")}, + {('D'), QLatin1String("DATETIME")}, + {('D'), QLatin1String("DAY")}, + {('D'), QLatin1String("DBCC")}, + {('D'), QLatin1String("DEALLOCATE")}, + {('D'), QLatin1String("DEC")}, + {('D'), QLatin1String("DECIMAL")}, + {('D'), QLatin1String("DECLARE")}, + {('D'), QLatin1String("DEFAULT")}, + {('D'), QLatin1String("DEFINER")}, + {('D'), QLatin1String("DELAYED")}, + {('D'), QLatin1String("DELETE")}, + {('D'), QLatin1String("DELIMITERS")}, + {('D'), QLatin1String("DENY")}, + {('D'), QLatin1String("DESC")}, + {('D'), QLatin1String("DESCRIBE")}, + {('D'), QLatin1String("DETERMINISTIC")}, + {('D'), QLatin1String("DISABLE")}, + {('D'), QLatin1String("DISCARD")}, + {('D'), QLatin1String("DISK")}, + {('D'), QLatin1String("DISTINCT")}, + {('D'), QLatin1String("DISTINCTROW")}, + {('D'), QLatin1String("DISTRIBUTED")}, + {('D'), QLatin1String("DO")}, + {('D'), QLatin1String("DOUBLE")}, + {('D'), QLatin1String("DROP")}, + {('D'), QLatin1String("DUMMY")}, + {('D'), QLatin1String("DUMPFILE")}, + {('D'), QLatin1String("DUPLICATE")}, + {('E'), QLatin1String("ELSEIF")}, + {('E'), QLatin1String("ENABLE")}, + {('E'), QLatin1String("ENCLOSED")}, + {('E'), QLatin1String("END")}, + {('E'), QLatin1String("ENGINE")}, + {('E'), QLatin1String("ENUM")}, + {('E'), QLatin1String("ERRLVL")}, + {('E'), QLatin1String("ERRORS")}, + {('E'), QLatin1String("ESCAPED")}, + {('E'), QLatin1String("EXCEPT")}, + {('E'), QLatin1String("EXECUTE")}, + {('E'), QLatin1String("EXISTS")}, + {('E'), QLatin1String("EXIT")}, + {('E'), QLatin1String("EXPLAIN")}, + {('E'), QLatin1String("EXTENDED")}, + {('F'), QLatin1String("FETCH")}, + {('F'), QLatin1String("FIELDS")}, + {('F'), QLatin1String("FILE")}, + {('F'), QLatin1String("FILLFACTOR")}, + {('F'), QLatin1String("FIRST")}, + {('F'), QLatin1String("FIXED")}, + {('F'), QLatin1String("FLOAT")}, + {('F'), QLatin1String("FOLLOWING")}, + {('F'), QLatin1String("FOR")}, + {('E'), QLatin1String("EACH")}, + {('R'), QLatin1String("ROW")}, + {('F'), QLatin1String("FORCE")}, + {('F'), QLatin1String("FOREIGN")}, + {('F'), QLatin1String("FREETEXTTABLE")}, + {('F'), QLatin1String("FROM")}, + {('F'), QLatin1String("FULL")}, + {('F'), QLatin1String("FUNCTION")}, + {('G'), QLatin1String("GEOMETRYCOLLECTION")}, + {('G'), QLatin1String("GLOBAL")}, + {('G'), QLatin1String("GOTO")}, + {('G'), QLatin1String("GRANT")}, + {('G'), QLatin1String("GROUP")}, + {('H'), QLatin1String("HANDLER")}, + {('H'), QLatin1String("HASH")}, + {('H'), QLatin1String("HAVING")}, + {('H'), QLatin1String("HOLDLOCK")}, + {('H'), QLatin1String("HOUR")}, + {('I'), QLatin1String("IDENTITY_INSERT")}, + {('C'), QLatin1String("COL")}, + {('I'), QLatin1String("IF")}, + {('I'), QLatin1String("IGNORE")}, + {('I'), QLatin1String("IMPORT")}, + {('I'), QLatin1String("INDEX")}, + {('I'), QLatin1String("INFILE")}, + {('I'), QLatin1String("INNER")}, + {('I'), QLatin1String("INNODB")}, + {('I'), QLatin1String("INOUT")}, + {('I'), QLatin1String("INSERT")}, + {('I'), QLatin1String("INT")}, + {('I'), QLatin1String("INTEGER")}, + {('I'), QLatin1String("INTERSECT")}, + {('I'), QLatin1String("INTERVAL")}, + {('I'), QLatin1String("INTO")}, + {('I'), QLatin1String("INVOKER")}, + {('I'), QLatin1String("ISOLATION")}, + {('I'), QLatin1String("ITERATE")}, + {('J'), QLatin1String("JOIN")}, + {('K'), QLatin1String("KEYS")}, + {('K'), QLatin1String("KILL")}, + {('L'), QLatin1String("LANGUAGE")}, + {('L'), QLatin1String("LAST")}, + {('L'), QLatin1String("LEAVE")}, + {('L'), QLatin1String("LEFT")}, + {('L'), QLatin1String("LEVEL")}, + {('L'), QLatin1String("LIMIT")}, + {('L'), QLatin1String("LINENO")}, + {('L'), QLatin1String("LINES")}, + {('L'), QLatin1String("LINESTRING")}, + {('L'), QLatin1String("LOAD")}, + {('L'), QLatin1String("LOCAL")}, + {('L'), QLatin1String("LOCK")}, + {('L'), QLatin1String("LONGBLOB")}, + {('T'), QLatin1String("TEXT")}, + {('L'), QLatin1String("LOOP")}, + {('M'), QLatin1String("MATCHED")}, + {('M'), QLatin1String("MEDIUMBLOB")}, + {('I'), QLatin1String("INT")}, + {('T'), QLatin1String("TEXT")}, + {('M'), QLatin1String("MERGE")}, + {('M'), QLatin1String("MIDDLEINT")}, + {('M'), QLatin1String("MINUTE")}, + {('M'), QLatin1String("MODE")}, + {('M'), QLatin1String("MODIFIES")}, + {('M'), QLatin1String("MODIFY")}, + {('M'), QLatin1String("MONTH")}, + {('M'), QLatin1String("MULTILINESTRING")}, + {('P'), QLatin1String("POINT")}, + {('P'), QLatin1String("POLYGON")}, + {('N'), QLatin1String("NATIONAL")}, + {('N'), QLatin1String("NATURAL")}, + {('N'), QLatin1String("NCHAR")}, + {('N'), QLatin1String("NEXT")}, + {('N'), QLatin1String("NO")}, + {('N'), QLatin1String("NONCLUSTERED")}, + {('N'), QLatin1String("NULLIF")}, + {('N'), QLatin1String("NUMERIC")}, + {('O'), QLatin1String("OFF")}, + {('O'), QLatin1String("OFFSETS")}, + {('O'), QLatin1String("ON")}, + {('O'), QLatin1String("OPENDATASOURCE")}, + {('Q'), QLatin1String("QUERY")}, + {('R'), QLatin1String("ROWSET")}, + {('O'), QLatin1String("OPTIMIZE")}, + {('O'), QLatin1String("OPTIONALLY")}, + {('O'), QLatin1String("ORDER")}, + {('O'), QLatin1String("OUTER")}, + {('F'), QLatin1String("FILE")}, + {('O'), QLatin1String("OVER")}, + {('P'), QLatin1String("PARTIAL")}, + {('P'), QLatin1String("PARTITION")}, + {('P'), QLatin1String("PERCENT")}, + {('P'), QLatin1String("PIVOT")}, + {('P'), QLatin1String("PLAN")}, + {('P'), QLatin1String("POINT")}, + {('P'), QLatin1String("POLYGON")}, + {('P'), QLatin1String("PRECEDING")}, + {('P'), QLatin1String("PRECISION")}, + {('P'), QLatin1String("PREPARE")}, + {('P'), QLatin1String("PREV")}, + {('P'), QLatin1String("PRIMARY")}, + {('P'), QLatin1String("PRINT")}, + {('P'), QLatin1String("PRIVILEGES")}, + {('P'), QLatin1String("PROCEDURE")}, + {('P'), QLatin1String("PUBLIC")}, + {('P'), QLatin1String("PURGE")}, + {('Q'), QLatin1String("QUICK")}, + {('R'), QLatin1String("RAISERROR")}, + {('R'), QLatin1String("READS")}, + {('R'), QLatin1String("REAL")}, + {('R'), QLatin1String("RECONFIGURE")}, + {('R'), QLatin1String("REFERENCES")}, + {('R'), QLatin1String("RELEASE")}, + {('R'), QLatin1String("RENAME")}, + {('R'), QLatin1String("REPEATABLE")}, + {('R'), QLatin1String("REPLACE")}, + {('R'), QLatin1String("REPLICATION")}, + {('R'), QLatin1String("REQUIRE")}, + {('R'), QLatin1String("RESIGNAL")}, + {('R'), QLatin1String("RESTORE")}, + {('R'), QLatin1String("RESTRICT")}, + {('R'), QLatin1String("RETURNS")}, + {('R'), QLatin1String("REVOKE")}, + {('R'), QLatin1String("RIGHT")}, + {('R'), QLatin1String("ROLLBACK")}, + {('R'), QLatin1String("ROUTINE")}, + {('R'), QLatin1String("ROWCOUNT")}, + {('G'), QLatin1String("GUIDCOL")}, + {('R'), QLatin1String("RTREE")}, + {('R'), QLatin1String("RULE")}, + {('S'), QLatin1String("SAVEPOINT")}, + {('S'), QLatin1String("SCHEMA")}, + {('S'), QLatin1String("SECOND")}, + {('S'), QLatin1String("SELECT")}, + {('S'), QLatin1String("SERIALIZABLE")}, + {('S'), QLatin1String("SESSION_USER")}, + {('S'), QLatin1String("SETUSER")}, + {('S'), QLatin1String("SHARE")}, + {('S'), QLatin1String("SHOW")}, + {('S'), QLatin1String("SHUTDOWN")}, + {('S'), QLatin1String("SIMPLE")}, + {('S'), QLatin1String("SMALLINT")}, + {('S'), QLatin1String("SNAPSHOT")}, + {('S'), QLatin1String("SOME")}, + {('S'), QLatin1String("SONAME")}, + {('S'), QLatin1String("SQL")}, + {('S'), QLatin1String("STARTING")}, + {('S'), QLatin1String("STATISTICS")}, + {('S'), QLatin1String("STATUS")}, + {('S'), QLatin1String("STRIPED")}, + {('S'), QLatin1String("SYSTEM_USER")}, + {('T'), QLatin1String("TABLES")}, + {('T'), QLatin1String("TABLESPACE")}, + {('T'), QLatin1String("TEMPORARY")}, + {('T'), QLatin1String("TABLE")}, + {('T'), QLatin1String("TERMINATED")}, + {('T'), QLatin1String("TEXTSIZE")}, + {('T'), QLatin1String("THEN")}, + {('T'), QLatin1String("TIMESTAMP")}, + {('T'), QLatin1String("TINYBLOB")}, + {('I'), QLatin1String("INT")}, + {('T'), QLatin1String("TEXT")}, + {('T'), QLatin1String("TOP")}, + {('T'), QLatin1String("TRANSACTIONS")}, + {('T'), QLatin1String("TRIGGER")}, + {('T'), QLatin1String("TRUNCATE")}, + {('T'), QLatin1String("TSEQUAL")}, + {('T'), QLatin1String("TYPES")}, + {('U'), QLatin1String("UNBOUNDED")}, + {('U'), QLatin1String("UNCOMMITTED")}, + {('U'), QLatin1String("UNDEFINED")}, + {('U'), QLatin1String("UNION")}, + {('U'), QLatin1String("UNIQUE")}, + {('U'), QLatin1String("UNLOCK")}, + {('U'), QLatin1String("UNPIVOT")}, + {('U'), QLatin1String("UNSIGNED")}, + {('U'), QLatin1String("UPDATETEXT")}, + {('U'), QLatin1String("USAGE")}, + {('U'), QLatin1String("USE")}, + {('U'), QLatin1String("USER")}, + {('U'), QLatin1String("USING")}, + {('V'), QLatin1String("VALUES")}, + {('V'), QLatin1String("VARBINARY")}, + {('C'), QLatin1String("CHAR")}, + {('C'), QLatin1String("CHARACTER")}, + {('Y'), QLatin1String("YING")}, + {('V'), QLatin1String("VIEW")}, + {('W'), QLatin1String("WAITFOR")}, + {('W'), QLatin1String("WARNINGS")}, + {('W'), QLatin1String("WHEN")}, + {('W'), QLatin1String("WHERE")}, + {('W'), QLatin1String("WHILE")}, + {('W'), QLatin1String("WITH")}, + {('R'), QLatin1String("ROLLUP")}, + {('I'), QLatin1String("IN")}, + {('W'), QLatin1String("WORK")}, + {('W'), QLatin1String("WRITETEXT")}, + {('Y'), QLatin1String("YEAR")}}; - sql_types = { + sql_types = { - }; + }; - sql_literals = { - {('A'), QLatin1String("TRUE")}, - {('F'), QLatin1String("FALSE")}, - {('N'), QLatin1String("NULL")}, - }; + sql_literals = { + {('A'), QLatin1String("TRUE")}, + {('F'), QLatin1String("FALSE")}, + {('N'), QLatin1String("NULL")}, + }; - sql_builtin = { - {('A'), QLatin1String("AVG")}, - {('C'), QLatin1String("COUNT")}, - {('F'), QLatin1String("FIRST")}, - {('F'), QLatin1String("FORMAT")}, - {('L'), QLatin1String("LAST")}, - {('L'), QLatin1String("LCASE")}, - {('L'), QLatin1String("LEN")}, - {('M'), QLatin1String("MAX")}, - {('M'), QLatin1String("MID")}, - {('M'), QLatin1String("MIN")}, - {('M'), QLatin1String("MOD")}, - {('N'), QLatin1String("NOW")}, - {('R'), QLatin1String("ROUND")}, - {('S'), QLatin1String("SUM")}, - {('U'), QLatin1String("UCASE")} - }; + sql_builtin + = {{('A'), QLatin1String("AVG")}, {('C'), QLatin1String("COUNT")}, + {('F'), QLatin1String("FIRST")}, {('F'), QLatin1String("FORMAT")}, + {('L'), QLatin1String("LAST")}, {('L'), QLatin1String("LCASE")}, + {('L'), QLatin1String("LEN")}, {('M'), QLatin1String("MAX")}, + {('M'), QLatin1String("MID")}, {('M'), QLatin1String("MIN")}, + {('M'), QLatin1String("MOD")}, {('N'), QLatin1String("NOW")}, + {('R'), QLatin1String("ROUND")}, {('S'), QLatin1String("SUM")}, + {('U'), QLatin1String("UCASE")}}; - sql_other = { + sql_other = { - }; + }; } -void loadSQLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!sqlDataInitialized) { - initSQLData(); - sqlDataInitialized = true; - } - types = sql_types; - keywords = sql_keywords; - builtin = sql_builtin; - literals = sql_literals; - other = sql_other; +void loadSQLData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!sqlDataInitialized) + { + initSQLData(); + sqlDataInitialized = true; + } + types = sql_types; + keywords = sql_keywords; + builtin = sql_builtin; + literals = sql_literals; + other = sql_other; } /********************************************************/ @@ -2217,39 +1987,34 @@ static LanguageData json_types; static LanguageData json_literals; static LanguageData json_builtin; static LanguageData json_other; -void initJSONData() { - json_keywords = { - }; +void initJSONData() +{ + json_keywords = {}; - json_types = { - }; + json_types = {}; - json_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")} - }; + json_literals = {{('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}}; - json_builtin = { - }; + json_builtin = {}; - json_other = { -}; + json_other = {}; } -void loadJSONData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!jsonDataInitialized) { - initJSONData(); - jsonDataInitialized = true; - } - types = json_types; - keywords = json_keywords; - builtin = json_builtin; - literals = json_literals; - other = json_other; +void loadJSONData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!jsonDataInitialized) + { + initJSONData(); + jsonDataInitialized = true; + } + types = json_types; + keywords = json_keywords; + builtin = json_builtin; + literals = json_literals; + other = json_other; } /********************************************************/ @@ -2261,350 +2026,190 @@ static LanguageData css_types; static LanguageData css_literals; static LanguageData css_builtin; static LanguageData css_other; -void initCSSData() { - css_keywords = { - {'i', QLatin1String("important")}, - {'p', QLatin1String("px")}, - {'e', QLatin1String("em")} - }; +void initCSSData() +{ + css_keywords = {{'i', QLatin1String("important")}, + {'p', QLatin1String("px")}, + {'e', QLatin1String("em")}}; - css_types = { - {'a', QLatin1String("align")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("items")}, - {'s', QLatin1String("self")}, - {'a', QLatin1String("all")}, - {'a', QLatin1String("animation")}, - {'d', QLatin1String("delay")}, - {'d', QLatin1String("direction")}, - {'d', QLatin1String("duration")}, - {'f', QLatin1String("fill")}, - {'m', QLatin1String("mode")}, - {'i', QLatin1String("iteration")}, - {'c', QLatin1String("count")}, - {'n', QLatin1String("name")}, - {'p', QLatin1String("play")}, - {'s', QLatin1String("state")}, - {'t', QLatin1String("timing")}, - {'f', QLatin1String("function")}, - {'a', QLatin1String("azimuth")}, - {'b', QLatin1String("backface")}, - {'v', QLatin1String("visibility")}, - {'a', QLatin1String("attachment")}, - {'b', QLatin1String("blend")}, - {'m', QLatin1String("mode")}, - {'c', QLatin1String("clip")}, - {'c', QLatin1String("color")}, - {'i', QLatin1String("image")}, - {'o', QLatin1String("origin")}, - {'p', QLatin1String("position")}, - {'r', QLatin1String("repeat")}, - {'s', QLatin1String("size")}, - {'b', QLatin1String("background")}, - {'b', QLatin1String("bleed")}, - {'c', QLatin1String("color")}, - {'r', QLatin1String("radius")}, - {'r', QLatin1String("radius")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'b', QLatin1String("bottom")}, - {'c', QLatin1String("collapse")}, - {'c', QLatin1String("color")}, - {'i', QLatin1String("image")}, - {'o', QLatin1String("outset")}, - {'r', QLatin1String("repeat")}, - {'s', QLatin1String("source")}, - {'s', QLatin1String("slice")}, - {'w', QLatin1String("width")}, - {'c', QLatin1String("color")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("radius")}, - {'c', QLatin1String("color")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'r', QLatin1String("right")}, - {'s', QLatin1String("spacing")}, - {'s', QLatin1String("style")}, - {'c', QLatin1String("color")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("radius")}, - {'r', QLatin1String("radius")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'t', QLatin1String("top")}, - {'w', QLatin1String("width")}, - {'b', QLatin1String("border")}, - {'b', QLatin1String("bottom")}, - {'b', QLatin1String("break")}, - {'b', QLatin1String("box")}, - {'s', QLatin1String("shadow")}, - {'b', QLatin1String("box")}, - {'s', QLatin1String("sizing")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'b', QLatin1String("break")}, - {'i', QLatin1String("inside")}, - {'c', QLatin1String("caption")}, - {'s', QLatin1String("side")}, - {'c', QLatin1String("caret")}, - {'c', QLatin1String("color")}, - {'c', QLatin1String("clear")}, - {'c', QLatin1String("clip")}, - {'c', QLatin1String("color")}, - {'c', QLatin1String("columns")}, - {'c', QLatin1String("column")}, - {'c', QLatin1String("count")}, - {'f', QLatin1String("fill")}, - {'g', QLatin1String("gap")}, - {'r', QLatin1String("rule")}, - {'c', QLatin1String("color")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'s', QLatin1String("span")}, - {'w', QLatin1String("width")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("increment")}, - {'c', QLatin1String("counter")}, - {'r', QLatin1String("reset")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'c', QLatin1String("cue")}, - {'c', QLatin1String("cursor")}, - {'d', QLatin1String("direction")}, - {'d', QLatin1String("display")}, - {'e', QLatin1String("elevation")}, - {'e', QLatin1String("empty")}, - {'c', QLatin1String("cells")}, - {'f', QLatin1String("filter")}, - {'f', QLatin1String("flex")}, - {'b', QLatin1String("basis")}, - {'d', QLatin1String("direction")}, - {'f', QLatin1String("feature")}, - {'s', QLatin1String("settings")}, - {'f', QLatin1String("flex")}, - {'f', QLatin1String("flow")}, - {'g', QLatin1String("grow")}, - {'s', QLatin1String("shrink")}, - {'w', QLatin1String("wrap")}, - {'f', QLatin1String("float")}, - {'f', QLatin1String("family")}, - {'k', QLatin1String("kerning")}, - {'l', QLatin1String("language")}, - {'o', QLatin1String("override")}, - {'a', QLatin1String("adjust")}, - {'s', QLatin1String("size")}, - {'s', QLatin1String("stretch")}, - {'s', QLatin1String("style")}, - {'s', QLatin1String("synthesis")}, - {'v', QLatin1String("variant")}, - {'a', QLatin1String("alternates")}, - {'c', QLatin1String("caps")}, - {'e', QLatin1String("east")}, - {'a', QLatin1String("asian")}, - {'l', QLatin1String("ligatures")}, - {'n', QLatin1String("numeric")}, - {'p', QLatin1String("position")}, - {'w', QLatin1String("weight")}, - {'f', QLatin1String("font")}, - {'a', QLatin1String("area")}, - {'a', QLatin1String("auto")}, - {'c', QLatin1String("columns")}, - {'f', QLatin1String("flow")}, - {'r', QLatin1String("rows")}, - {'e', QLatin1String("end")}, - {'g', QLatin1String("gap")}, - {'s', QLatin1String("start")}, - {'c', QLatin1String("column")}, - {'g', QLatin1String("gap")}, - {'e', QLatin1String("end")}, - {'g', QLatin1String("gap")}, - {'s', QLatin1String("start")}, - {'r', QLatin1String("row")}, - {'a', QLatin1String("areas")}, - {'c', QLatin1String("columns")}, - {'r', QLatin1String("rows")}, - {'t', QLatin1String("template")}, - {'g', QLatin1String("grid")}, - {'h', QLatin1String("hanging")}, - {'p', QLatin1String("punctuation")}, - {'h', QLatin1String("height")}, - {'h', QLatin1String("hyphens")}, - {'i', QLatin1String("isolation")}, - {'j', QLatin1String("justify")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("items")}, - {'s', QLatin1String("self")}, - {'l', QLatin1String("leftimage")}, - {'l', QLatin1String("letter")}, - {'s', QLatin1String("spacing")}, - {'b', QLatin1String("break")}, - {'l', QLatin1String("line")}, - {'s', QLatin1String("style")}, - {'i', QLatin1String("image")}, - {'s', QLatin1String("style")}, - {'p', QLatin1String("position")}, - {'t', QLatin1String("type")}, - {'l', QLatin1String("list")}, - {'s', QLatin1String("style")}, - {'b', QLatin1String("bottom")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("right")}, - {'t', QLatin1String("top")}, - {'m', QLatin1String("margin")}, - {'m', QLatin1String("marker")}, - {'o', QLatin1String("offset")}, - {'m', QLatin1String("marks")}, - {'m', QLatin1String("max")}, - {'h', QLatin1String("height")}, - {'w', QLatin1String("width")}, - {'m', QLatin1String("min")}, - {'m', QLatin1String("mix")}, - {'b', QLatin1String("blend")}, - {'m', QLatin1String("mode")}, - {'n', QLatin1String("nav")}, - {'u', QLatin1String("up")}, - {'d', QLatin1String("down")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("right")}, - {'o', QLatin1String("opacity")}, - {'o', QLatin1String("order")}, - {'o', QLatin1String("orphans")}, - {'c', QLatin1String("color")}, - {'o', QLatin1String("offset")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'o', QLatin1String("outline")}, - {'w', QLatin1String("wrap")}, - {'o', QLatin1String("overflow")}, - {'b', QLatin1String("bottom")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("right")}, - {'t', QLatin1String("top")}, - {'p', QLatin1String("padding")}, - {'b', QLatin1String("break")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'i', QLatin1String("inside")}, - {'p', QLatin1String("page")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'p', QLatin1String("pause")}, - {'p', QLatin1String("perspective")}, - {'o', QLatin1String("origin")}, - {'r', QLatin1String("range")}, - {'p', QLatin1String("pitch")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("items")}, - {'p', QLatin1String("place")}, - {'s', QLatin1String("self")}, - {'p', QLatin1String("play")}, - {'d', QLatin1String("during")}, - {'p', QLatin1String("position")}, - {'q', QLatin1String("quotes")}, - {'r', QLatin1String("resize")}, - {'r', QLatin1String("rest")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'r', QLatin1String("rest")}, - {'r', QLatin1String("richness")}, - {'r', QLatin1String("right")}, - {'s', QLatin1String("size")}, - {'h', QLatin1String("header")}, - {'n', QLatin1String("numeral")}, - {'s', QLatin1String("speak")}, - {'p', QLatin1String("punctuation")}, - {'s', QLatin1String("speak")}, - {'s', QLatin1String("speech")}, - {'r', QLatin1String("rate")}, - {'s', QLatin1String("stress")}, - {'t', QLatin1String("tab")}, - {'s', QLatin1String("size")}, - {'t', QLatin1String("table")}, - {'l', QLatin1String("layout")}, - {'t', QLatin1String("text")}, - {'a', QLatin1String("align")}, - {'l', QLatin1String("last")}, - {'d', QLatin1String("decoration")}, - {'c', QLatin1String("color")}, - {'l', QLatin1String("line")}, - {'s', QLatin1String("skip")}, - {'s', QLatin1String("style")}, - {'i', QLatin1String("indent")}, - {'o', QLatin1String("overflow")}, - {'s', QLatin1String("shadow")}, - {'t', QLatin1String("transform")}, - {'u', QLatin1String("underline")}, - {'p', QLatin1String("position")}, - {'t', QLatin1String("top")}, - {'t', QLatin1String("transform")}, - {'o', QLatin1String("origin")}, - {'s', QLatin1String("style")}, - {'t', QLatin1String("transition")}, - {'d', QLatin1String("delay")}, - {'d', QLatin1String("duration")}, - {'p', QLatin1String("property")}, - {'t', QLatin1String("timing")}, - {'f', QLatin1String("function")}, - {'u', QLatin1String("unicode")}, - {'b', QLatin1String("bidi")}, - {'v', QLatin1String("vertical")}, - {'a', QLatin1String("align")}, - {'v', QLatin1String("visibility")}, - {'b', QLatin1String("balance")}, - {'d', QLatin1String("duration")}, - {'f', QLatin1String("family")}, - {'p', QLatin1String("pitch")}, - {'r', QLatin1String("range")}, - {'r', QLatin1String("rate")}, - {'s', QLatin1String("stress")}, - {'v', QLatin1String("volume")}, - {'v', QLatin1String("voice")}, - {'v', QLatin1String("volume")}, - {'w', QLatin1String("white")}, - {'s', QLatin1String("space")}, - {'w', QLatin1String("widows")}, - {'w', QLatin1String("width")}, - {'w', QLatin1String("will")}, - {'c', QLatin1String("change")}, - {'w', QLatin1String("word")}, - {'b', QLatin1String("break")}, - {'s', QLatin1String("spacing")}, - {'w', QLatin1String("wrap")}, - {'x', QLatin1String("x")}, - {'y', QLatin1String("y")}, - {'z', QLatin1String("z")}, - {'i', QLatin1String("index")}, - {'r', QLatin1String("rgb")}, - {'s', QLatin1String("sans")}, - {'s', QLatin1String("serif")}, - {'n', QLatin1String("normal")} - }; + css_types = { + {'a', QLatin1String("align")}, {'c', QLatin1String("content")}, + {'i', QLatin1String("items")}, {'s', QLatin1String("self")}, + {'a', QLatin1String("all")}, {'a', QLatin1String("animation")}, + {'d', QLatin1String("delay")}, {'d', QLatin1String("direction")}, + {'d', QLatin1String("duration")}, {'f', QLatin1String("fill")}, + {'m', QLatin1String("mode")}, {'i', QLatin1String("iteration")}, + {'c', QLatin1String("count")}, {'n', QLatin1String("name")}, + {'p', QLatin1String("play")}, {'s', QLatin1String("state")}, + {'t', QLatin1String("timing")}, {'f', QLatin1String("function")}, + {'a', QLatin1String("azimuth")}, {'b', QLatin1String("backface")}, + {'v', QLatin1String("visibility")}, {'a', QLatin1String("attachment")}, + {'b', QLatin1String("blend")}, {'m', QLatin1String("mode")}, + {'c', QLatin1String("clip")}, {'c', QLatin1String("color")}, + {'i', QLatin1String("image")}, {'o', QLatin1String("origin")}, + {'p', QLatin1String("position")}, {'r', QLatin1String("repeat")}, + {'s', QLatin1String("size")}, {'b', QLatin1String("background")}, + {'b', QLatin1String("bleed")}, {'c', QLatin1String("color")}, + {'r', QLatin1String("radius")}, {'r', QLatin1String("radius")}, + {'s', QLatin1String("style")}, {'w', QLatin1String("width")}, + {'b', QLatin1String("bottom")}, {'c', QLatin1String("collapse")}, + {'c', QLatin1String("color")}, {'i', QLatin1String("image")}, + {'o', QLatin1String("outset")}, {'r', QLatin1String("repeat")}, + {'s', QLatin1String("source")}, {'s', QLatin1String("slice")}, + {'w', QLatin1String("width")}, {'c', QLatin1String("color")}, + {'s', QLatin1String("style")}, {'w', QLatin1String("width")}, + {'l', QLatin1String("left")}, {'r', QLatin1String("radius")}, + {'c', QLatin1String("color")}, {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, {'r', QLatin1String("right")}, + {'s', QLatin1String("spacing")}, {'s', QLatin1String("style")}, + {'c', QLatin1String("color")}, {'l', QLatin1String("left")}, + {'r', QLatin1String("radius")}, {'r', QLatin1String("radius")}, + {'s', QLatin1String("style")}, {'w', QLatin1String("width")}, + {'t', QLatin1String("top")}, {'w', QLatin1String("width")}, + {'b', QLatin1String("border")}, {'b', QLatin1String("bottom")}, + {'b', QLatin1String("break")}, {'b', QLatin1String("box")}, + {'s', QLatin1String("shadow")}, {'b', QLatin1String("box")}, + {'s', QLatin1String("sizing")}, {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, {'b', QLatin1String("break")}, + {'i', QLatin1String("inside")}, {'c', QLatin1String("caption")}, + {'s', QLatin1String("side")}, {'c', QLatin1String("caret")}, + {'c', QLatin1String("color")}, {'c', QLatin1String("clear")}, + {'c', QLatin1String("clip")}, {'c', QLatin1String("color")}, + {'c', QLatin1String("columns")}, {'c', QLatin1String("column")}, + {'c', QLatin1String("count")}, {'f', QLatin1String("fill")}, + {'g', QLatin1String("gap")}, {'r', QLatin1String("rule")}, + {'c', QLatin1String("color")}, {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, {'s', QLatin1String("span")}, + {'w', QLatin1String("width")}, {'c', QLatin1String("content")}, + {'i', QLatin1String("increment")}, {'c', QLatin1String("counter")}, + {'r', QLatin1String("reset")}, {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, {'c', QLatin1String("cue")}, + {'c', QLatin1String("cursor")}, {'d', QLatin1String("direction")}, + {'d', QLatin1String("display")}, {'e', QLatin1String("elevation")}, + {'e', QLatin1String("empty")}, {'c', QLatin1String("cells")}, + {'f', QLatin1String("filter")}, {'f', QLatin1String("flex")}, + {'b', QLatin1String("basis")}, {'d', QLatin1String("direction")}, + {'f', QLatin1String("feature")}, {'s', QLatin1String("settings")}, + {'f', QLatin1String("flex")}, {'f', QLatin1String("flow")}, + {'g', QLatin1String("grow")}, {'s', QLatin1String("shrink")}, + {'w', QLatin1String("wrap")}, {'f', QLatin1String("float")}, + {'f', QLatin1String("family")}, {'k', QLatin1String("kerning")}, + {'l', QLatin1String("language")}, {'o', QLatin1String("override")}, + {'a', QLatin1String("adjust")}, {'s', QLatin1String("size")}, + {'s', QLatin1String("stretch")}, {'s', QLatin1String("style")}, + {'s', QLatin1String("synthesis")}, {'v', QLatin1String("variant")}, + {'a', QLatin1String("alternates")}, {'c', QLatin1String("caps")}, + {'e', QLatin1String("east")}, {'a', QLatin1String("asian")}, + {'l', QLatin1String("ligatures")}, {'n', QLatin1String("numeric")}, + {'p', QLatin1String("position")}, {'w', QLatin1String("weight")}, + {'f', QLatin1String("font")}, {'a', QLatin1String("area")}, + {'a', QLatin1String("auto")}, {'c', QLatin1String("columns")}, + {'f', QLatin1String("flow")}, {'r', QLatin1String("rows")}, + {'e', QLatin1String("end")}, {'g', QLatin1String("gap")}, + {'s', QLatin1String("start")}, {'c', QLatin1String("column")}, + {'g', QLatin1String("gap")}, {'e', QLatin1String("end")}, + {'g', QLatin1String("gap")}, {'s', QLatin1String("start")}, + {'r', QLatin1String("row")}, {'a', QLatin1String("areas")}, + {'c', QLatin1String("columns")}, {'r', QLatin1String("rows")}, + {'t', QLatin1String("template")}, {'g', QLatin1String("grid")}, + {'h', QLatin1String("hanging")}, {'p', QLatin1String("punctuation")}, + {'h', QLatin1String("height")}, {'h', QLatin1String("hyphens")}, + {'i', QLatin1String("isolation")}, {'j', QLatin1String("justify")}, + {'c', QLatin1String("content")}, {'i', QLatin1String("items")}, + {'s', QLatin1String("self")}, {'l', QLatin1String("leftimage")}, + {'l', QLatin1String("letter")}, {'s', QLatin1String("spacing")}, + {'b', QLatin1String("break")}, {'l', QLatin1String("line")}, + {'s', QLatin1String("style")}, {'i', QLatin1String("image")}, + {'s', QLatin1String("style")}, {'p', QLatin1String("position")}, + {'t', QLatin1String("type")}, {'l', QLatin1String("list")}, + {'s', QLatin1String("style")}, {'b', QLatin1String("bottom")}, + {'l', QLatin1String("left")}, {'r', QLatin1String("right")}, + {'t', QLatin1String("top")}, {'m', QLatin1String("margin")}, + {'m', QLatin1String("marker")}, {'o', QLatin1String("offset")}, + {'m', QLatin1String("marks")}, {'m', QLatin1String("max")}, + {'h', QLatin1String("height")}, {'w', QLatin1String("width")}, + {'m', QLatin1String("min")}, {'m', QLatin1String("mix")}, + {'b', QLatin1String("blend")}, {'m', QLatin1String("mode")}, + {'n', QLatin1String("nav")}, {'u', QLatin1String("up")}, + {'d', QLatin1String("down")}, {'l', QLatin1String("left")}, + {'r', QLatin1String("right")}, {'o', QLatin1String("opacity")}, + {'o', QLatin1String("order")}, {'o', QLatin1String("orphans")}, + {'c', QLatin1String("color")}, {'o', QLatin1String("offset")}, + {'s', QLatin1String("style")}, {'w', QLatin1String("width")}, + {'o', QLatin1String("outline")}, {'w', QLatin1String("wrap")}, + {'o', QLatin1String("overflow")}, {'b', QLatin1String("bottom")}, + {'l', QLatin1String("left")}, {'r', QLatin1String("right")}, + {'t', QLatin1String("top")}, {'p', QLatin1String("padding")}, + {'b', QLatin1String("break")}, {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, {'i', QLatin1String("inside")}, + {'p', QLatin1String("page")}, {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, {'p', QLatin1String("pause")}, + {'p', QLatin1String("perspective")}, {'o', QLatin1String("origin")}, + {'r', QLatin1String("range")}, {'p', QLatin1String("pitch")}, + {'c', QLatin1String("content")}, {'i', QLatin1String("items")}, + {'p', QLatin1String("place")}, {'s', QLatin1String("self")}, + {'p', QLatin1String("play")}, {'d', QLatin1String("during")}, + {'p', QLatin1String("position")}, {'q', QLatin1String("quotes")}, + {'r', QLatin1String("resize")}, {'r', QLatin1String("rest")}, + {'a', QLatin1String("after")}, {'b', QLatin1String("before")}, + {'r', QLatin1String("rest")}, {'r', QLatin1String("richness")}, + {'r', QLatin1String("right")}, {'s', QLatin1String("size")}, + {'h', QLatin1String("header")}, {'n', QLatin1String("numeral")}, + {'s', QLatin1String("speak")}, {'p', QLatin1String("punctuation")}, + {'s', QLatin1String("speak")}, {'s', QLatin1String("speech")}, + {'r', QLatin1String("rate")}, {'s', QLatin1String("stress")}, + {'t', QLatin1String("tab")}, {'s', QLatin1String("size")}, + {'t', QLatin1String("table")}, {'l', QLatin1String("layout")}, + {'t', QLatin1String("text")}, {'a', QLatin1String("align")}, + {'l', QLatin1String("last")}, {'d', QLatin1String("decoration")}, + {'c', QLatin1String("color")}, {'l', QLatin1String("line")}, + {'s', QLatin1String("skip")}, {'s', QLatin1String("style")}, + {'i', QLatin1String("indent")}, {'o', QLatin1String("overflow")}, + {'s', QLatin1String("shadow")}, {'t', QLatin1String("transform")}, + {'u', QLatin1String("underline")}, {'p', QLatin1String("position")}, + {'t', QLatin1String("top")}, {'t', QLatin1String("transform")}, + {'o', QLatin1String("origin")}, {'s', QLatin1String("style")}, + {'t', QLatin1String("transition")}, {'d', QLatin1String("delay")}, + {'d', QLatin1String("duration")}, {'p', QLatin1String("property")}, + {'t', QLatin1String("timing")}, {'f', QLatin1String("function")}, + {'u', QLatin1String("unicode")}, {'b', QLatin1String("bidi")}, + {'v', QLatin1String("vertical")}, {'a', QLatin1String("align")}, + {'v', QLatin1String("visibility")}, {'b', QLatin1String("balance")}, + {'d', QLatin1String("duration")}, {'f', QLatin1String("family")}, + {'p', QLatin1String("pitch")}, {'r', QLatin1String("range")}, + {'r', QLatin1String("rate")}, {'s', QLatin1String("stress")}, + {'v', QLatin1String("volume")}, {'v', QLatin1String("voice")}, + {'v', QLatin1String("volume")}, {'w', QLatin1String("white")}, + {'s', QLatin1String("space")}, {'w', QLatin1String("widows")}, + {'w', QLatin1String("width")}, {'w', QLatin1String("will")}, + {'c', QLatin1String("change")}, {'w', QLatin1String("word")}, + {'b', QLatin1String("break")}, {'s', QLatin1String("spacing")}, + {'w', QLatin1String("wrap")}, {'x', QLatin1String("x")}, + {'y', QLatin1String("y")}, {'z', QLatin1String("z")}, + {'i', QLatin1String("index")}, {'r', QLatin1String("rgb")}, + {'s', QLatin1String("sans")}, {'s', QLatin1String("serif")}, + {'n', QLatin1String("normal")}}; - css_literals = { - }; + css_literals = {}; - css_builtin = { - }; + css_builtin = {}; - css_other = { - }; + css_other = {}; } -void loadCSSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!cssDataInitialized) { - initCSSData(); - cssDataInitialized = true; - } - types = css_types; - keywords = css_keywords; - builtin = css_builtin; - literals = css_literals; - other = css_other; +void loadCSSData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!cssDataInitialized) + { + initCSSData(); + cssDataInitialized = true; + } + types = css_types; + keywords = css_keywords; + builtin = css_builtin; + literals = css_literals; + other = css_other; } /********************************************************/ @@ -2616,145 +2221,113 @@ static LanguageData typescript_types; static LanguageData typescript_literals; static LanguageData typescript_builtin; static LanguageData typescript_other; -void initTypescriptData() { - typescript_keywords = { - {'i', QLatin1String("in")}, - {'i', QLatin1String("if")}, - {'f', QLatin1String("for")}, - {'w', QLatin1String("while")}, - {'f', QLatin1String("finally")}, - {'n', QLatin1String("new")}, - {'f', QLatin1String("function")}, - {'d', QLatin1String("do")}, - {'r', QLatin1String("return")}, - {'v', QLatin1String("void")}, - {'e', QLatin1String("else")}, - {'b', QLatin1String("break")}, - {'c', QLatin1String("catch")}, - {'i', QLatin1String("instanceof")}, - {'w', QLatin1String("with")}, - {'t', QLatin1String("throw")}, - {'c', QLatin1String("case")}, - {'d', QLatin1String("default")}, - {'t', QLatin1String("try")}, - {'t', QLatin1String("this")}, - {'s', QLatin1String("switch")}, - {'c', QLatin1String("continue")}, - {'t', QLatin1String("typeof")}, - {'d', QLatin1String("delete")}, - {'l', QLatin1String("let")}, - {'y', QLatin1String("yield")}, - {'c', QLatin1String("const")}, - {'p', QLatin1String("public")}, - {'p', QLatin1String("private")}, - {'p', QLatin1String("protected")}, - {'g', QLatin1String("get")}, - {'s', QLatin1String("set")}, - {'s', QLatin1String("super")}, - {'s', QLatin1String("static")}, - {'i', QLatin1String("implements")}, - {'e', QLatin1String("export")}, - {'i', QLatin1String("import")}, - {'d', QLatin1String("declare")}, - {'t', QLatin1String("type")}, - {'n', QLatin1String("namespace")}, - {'a', QLatin1String("abstract")}, - {'a', QLatin1String("as")}, - {'f', QLatin1String("from")}, - {'e', QLatin1String("extends")}, - {'a', QLatin1String("async")}, - {'a', QLatin1String("await")} - }; +void initTypescriptData() +{ + typescript_keywords + = {{'i', QLatin1String("in")}, {'i', QLatin1String("if")}, + {'f', QLatin1String("for")}, {'w', QLatin1String("while")}, + {'f', QLatin1String("finally")}, {'n', QLatin1String("new")}, + {'f', QLatin1String("function")}, {'d', QLatin1String("do")}, + {'r', QLatin1String("return")}, {'v', QLatin1String("void")}, + {'e', QLatin1String("else")}, {'b', QLatin1String("break")}, + {'c', QLatin1String("catch")}, {'i', QLatin1String("instanceof")}, + {'w', QLatin1String("with")}, {'t', QLatin1String("throw")}, + {'c', QLatin1String("case")}, {'d', QLatin1String("default")}, + {'t', QLatin1String("try")}, {'t', QLatin1String("this")}, + {'s', QLatin1String("switch")}, {'c', QLatin1String("continue")}, + {'t', QLatin1String("typeof")}, {'d', QLatin1String("delete")}, + {'l', QLatin1String("let")}, {'y', QLatin1String("yield")}, + {'c', QLatin1String("const")}, {'p', QLatin1String("public")}, + {'p', QLatin1String("private")}, {'p', QLatin1String("protected")}, + {'g', QLatin1String("get")}, {'s', QLatin1String("set")}, + {'s', QLatin1String("super")}, {'s', QLatin1String("static")}, + {'i', QLatin1String("implements")}, {'e', QLatin1String("export")}, + {'i', QLatin1String("import")}, {'d', QLatin1String("declare")}, + {'t', QLatin1String("type")}, {'n', QLatin1String("namespace")}, + {'a', QLatin1String("abstract")}, {'a', QLatin1String("as")}, + {'f', QLatin1String("from")}, {'e', QLatin1String("extends")}, + {'a', QLatin1String("async")}, {'a', QLatin1String("await")}}; - typescript_types = { - {'v', QLatin1String("var")}, - {'c', QLatin1String("class")}, - {'e', QLatin1String("enum")} - }; + typescript_types = {{'v', QLatin1String("var")}, + {'c', QLatin1String("class")}, + {'e', QLatin1String("enum")}}; - typescript_literals = { - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("null")}, - {('t'), QLatin1String("true")}, - {('u'), QLatin1String("undefined")}, - {('N'), QLatin1String("NaN")}, - {('I'), QLatin1String("Infinity")} - }; + typescript_literals + = {{('f'), QLatin1String("false")}, {('n'), QLatin1String("null")}, + {('t'), QLatin1String("true")}, {('u'), QLatin1String("undefined")}, + {('N'), QLatin1String("NaN")}, {('I'), QLatin1String("Infinity")}}; - typescript_builtin = { - {'e', QLatin1String("eval")}, - {'i', QLatin1String("isFinite")}, - {'i', QLatin1String("isNaN")}, - {'p', QLatin1String("parseFloat")}, - {'p', QLatin1String("parseInt")}, - {'d', QLatin1String("decodeURI")}, - {'d', QLatin1String("decodeURIComponent")}, - {'e', QLatin1String("encodeURI")}, - {'e', QLatin1String("encodeURIComponent")}, - {'e', QLatin1String("escape")}, - {'u', QLatin1String("unescape")}, - {'O', QLatin1String("Object")}, - {'F', QLatin1String("Function")}, - {'B', QLatin1String("Boolean")}, - {'E', QLatin1String("Error")}, - {'E', QLatin1String("EvalError")}, - {'I', QLatin1String("InternalError")}, - {'R', QLatin1String("RangeError")}, - {'R', QLatin1String("ReferenceError")}, - {'S', QLatin1String("StopIteration")}, - {'S', QLatin1String("SyntaxError")}, - {'T', QLatin1String("TypeError")}, - {'U', QLatin1String("URIError")}, - {'N', QLatin1String("Number")}, - {'M', QLatin1String("Math")}, - {'D', QLatin1String("Date")}, - {'S', QLatin1String("String")}, - {'R', QLatin1String("RegExp")}, - {'A', QLatin1String("Array")}, - {'F', QLatin1String("Float32Array")}, - {'F', QLatin1String("Float64Array")}, - {'I', QLatin1String("Int16Array")}, - {'I', QLatin1String("Int32Array")}, - {'I', QLatin1String("Int8Array")}, - {'U', QLatin1String("Uint16Array")}, - {'U', QLatin1String("Uint32Array")}, - {'U', QLatin1String("Uint8Array")}, - {'U', QLatin1String("Uint8ClampedArray")}, - {'A', QLatin1String("ArrayBuffer")}, - {'D', QLatin1String("DataView")}, - {'J', QLatin1String("JSON")}, - {'I', QLatin1String("Intl")}, - {'a', QLatin1String("arguments")}, - {'r', QLatin1String("require")}, - {'m', QLatin1String("module")}, - {'c', QLatin1String("console")}, - {'w', QLatin1String("window")}, - {'d', QLatin1String("document")}, - {'a', QLatin1String("any")}, - {'n', QLatin1String("number")}, - {'b', QLatin1String("boolean")}, - {'s', QLatin1String("string")}, - {'v', QLatin1String("void")}, - {'P', QLatin1String("Promise")} - }; + typescript_builtin = {{'e', QLatin1String("eval")}, + {'i', QLatin1String("isFinite")}, + {'i', QLatin1String("isNaN")}, + {'p', QLatin1String("parseFloat")}, + {'p', QLatin1String("parseInt")}, + {'d', QLatin1String("decodeURI")}, + {'d', QLatin1String("decodeURIComponent")}, + {'e', QLatin1String("encodeURI")}, + {'e', QLatin1String("encodeURIComponent")}, + {'e', QLatin1String("escape")}, + {'u', QLatin1String("unescape")}, + {'O', QLatin1String("Object")}, + {'F', QLatin1String("Function")}, + {'B', QLatin1String("Boolean")}, + {'E', QLatin1String("Error")}, + {'E', QLatin1String("EvalError")}, + {'I', QLatin1String("InternalError")}, + {'R', QLatin1String("RangeError")}, + {'R', QLatin1String("ReferenceError")}, + {'S', QLatin1String("StopIteration")}, + {'S', QLatin1String("SyntaxError")}, + {'T', QLatin1String("TypeError")}, + {'U', QLatin1String("URIError")}, + {'N', QLatin1String("Number")}, + {'M', QLatin1String("Math")}, + {'D', QLatin1String("Date")}, + {'S', QLatin1String("String")}, + {'R', QLatin1String("RegExp")}, + {'A', QLatin1String("Array")}, + {'F', QLatin1String("Float32Array")}, + {'F', QLatin1String("Float64Array")}, + {'I', QLatin1String("Int16Array")}, + {'I', QLatin1String("Int32Array")}, + {'I', QLatin1String("Int8Array")}, + {'U', QLatin1String("Uint16Array")}, + {'U', QLatin1String("Uint32Array")}, + {'U', QLatin1String("Uint8Array")}, + {'U', QLatin1String("Uint8ClampedArray")}, + {'A', QLatin1String("ArrayBuffer")}, + {'D', QLatin1String("DataView")}, + {'J', QLatin1String("JSON")}, + {'I', QLatin1String("Intl")}, + {'a', QLatin1String("arguments")}, + {'r', QLatin1String("require")}, + {'m', QLatin1String("module")}, + {'c', QLatin1String("console")}, + {'w', QLatin1String("window")}, + {'d', QLatin1String("document")}, + {'a', QLatin1String("any")}, + {'n', QLatin1String("number")}, + {'b', QLatin1String("boolean")}, + {'s', QLatin1String("string")}, + {'v', QLatin1String("void")}, + {'P', QLatin1String("Promise")}}; - typescript_other = { -}; + typescript_other = {}; } -void loadTypescriptData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!typescriptDataInitialized) { - initTypescriptData(); - typescriptDataInitialized = true; - } - types = typescript_types; - keywords = typescript_keywords; - builtin = typescript_builtin; - literals = typescript_literals; - other = typescript_other; +void loadTypescriptData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!typescriptDataInitialized) + { + initTypescriptData(); + typescriptDataInitialized = true; + } + types = typescript_types; + keywords = typescript_keywords; + builtin = typescript_builtin; + literals = typescript_literals; + other = typescript_other; } /********************************************************/ @@ -2766,32 +2339,33 @@ static LanguageData YAML_types; static LanguageData YAML_literals; static LanguageData YAML_builtin; static LanguageData YAML_other; -void initYAMLData() { - YAML_keywords = {}; - YAML_types = {}; - YAML_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")}, - }; +void initYAMLData() +{ + YAML_keywords = {}; + YAML_types = {}; + YAML_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}, + }; - YAML_builtin = {}; - YAML_other = {}; + YAML_builtin = {}; + YAML_other = {}; } -void loadYAMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!YAMLDataInitialized) { - initYAMLData(); - YAMLDataInitialized = true; - } - types = YAML_types; - keywords = YAML_keywords; - builtin = YAML_builtin; - literals = YAML_literals; - other = YAML_other; +void loadYAMLData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!YAMLDataInitialized) + { + initYAMLData(); + YAMLDataInitialized = true; + } + types = YAML_types; + keywords = YAML_keywords; + builtin = YAML_builtin; + literals = YAML_literals; + other = YAML_other; } /********************************************************/ @@ -2803,735 +2377,713 @@ static LanguageData vex_types; static LanguageData vex_literals; static LanguageData vex_builtin; static LanguageData vex_other; -void initVEXData() { - vex_keywords = { - {'b', QLatin1String("break")}, - {'c', QLatin1String("continue")}, - {'d', QLatin1String("do")}, - {'e', QLatin1String("else")}, - {'f', QLatin1String("for")}, - {'f', QLatin1String("foreach")}, - {'f', QLatin1String("forpoints")}, - {'f', QLatin1String("function")}, - {'g', QLatin1String("gather")}, - {'i', QLatin1String("if")}, - {'i', QLatin1String("illuminance")}, - {'r', QLatin1String("return")}, - {'w', QLatin1String("while")} - }; - vex_types = { - {'b', QLatin1String("bsdf")}, - {'c', QLatin1String("char")}, - {'c', QLatin1String("color")}, - {'f', QLatin1String("float")}, - {'i', QLatin1String("int")}, - {'i', QLatin1String("integer")}, - {'m', QLatin1String("matrix")}, - {'m', QLatin1String("matrix2")}, - {'m', QLatin1String("matrix3")}, - {'m', QLatin1String("matrix4")}, - {'n', QLatin1String("normal")}, - {'p', QLatin1String("point")}, - {'s', QLatin1String("string")}, - {'s', QLatin1String("struct")}, - {'t', QLatin1String("typedef")}, - {'u', QLatin1String("union")}, - {'v', QLatin1String("vector")}, - {'v', QLatin1String("vector2")}, - {'v', QLatin1String("vector4")}, - {'v', QLatin1String("void")}, - }; - vex_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")}, - }; +void initVEXData() +{ + vex_keywords + = {{'b', QLatin1String("break")}, {'c', QLatin1String("continue")}, + {'d', QLatin1String("do")}, {'e', QLatin1String("else")}, + {'f', QLatin1String("for")}, {'f', QLatin1String("foreach")}, + {'f', QLatin1String("forpoints")}, {'f', QLatin1String("function")}, + {'g', QLatin1String("gather")}, {'i', QLatin1String("if")}, + {'i', QLatin1String("illuminance")}, {'r', QLatin1String("return")}, + {'w', QLatin1String("while")}}; + vex_types = { + {'b', QLatin1String("bsdf")}, {'c', QLatin1String("char")}, + {'c', QLatin1String("color")}, {'f', QLatin1String("float")}, + {'i', QLatin1String("int")}, {'i', QLatin1String("integer")}, + {'m', QLatin1String("matrix")}, {'m', QLatin1String("matrix2")}, + {'m', QLatin1String("matrix3")}, {'m', QLatin1String("matrix4")}, + {'n', QLatin1String("normal")}, {'p', QLatin1String("point")}, + {'s', QLatin1String("string")}, {'s', QLatin1String("struct")}, + {'t', QLatin1String("typedef")}, {'u', QLatin1String("union")}, + {'v', QLatin1String("vector")}, {'v', QLatin1String("vector2")}, + {'v', QLatin1String("vector4")}, {'v', QLatin1String("void")}, + }; + vex_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}, + }; - vex_builtin = { - {'D', QLatin1String("Du")}, - {'D', QLatin1String("Dv")}, - {'D', QLatin1String("Dw")}, - {'a', QLatin1String("abs")}, - {'a', QLatin1String("accessframe")}, - {'a', QLatin1String("acos")}, - {'a', QLatin1String("addattrib")}, - {'a', QLatin1String("addattribute")}, - {'a', QLatin1String("adddetailattrib")}, - {'a', QLatin1String("addgroup")}, - {'a', QLatin1String("addpoint")}, - {'a', QLatin1String("addpointattrib")}, - {'a', QLatin1String("addprim")}, - {'a', QLatin1String("addprimattrib")}, - {'a', QLatin1String("addvariablename")}, - {'a', QLatin1String("addvertex")}, - {'a', QLatin1String("addvertexattrib")}, - {'a', QLatin1String("addvisualizer")}, - {'a', QLatin1String("agentaddclip")}, - {'a', QLatin1String("agentclipcatalog")}, - {'a', QLatin1String("agentclipchannel")}, - {'a', QLatin1String("agentcliplength")}, - {'a', QLatin1String("agentclipnames")}, - {'a', QLatin1String("agentclipsample")}, - {'a', QLatin1String("agentclipsamplelocal")}, - {'a', QLatin1String("agentclipsamplerate")}, - {'a', QLatin1String("agentclipsampleworld")}, - {'a', QLatin1String("agentcliptimes")}, - {'a', QLatin1String("agentclipweights")}, - {'a', QLatin1String("agentcollisionlayer")}, - {'a', QLatin1String("agentcurrentlayer")}, - {'a', QLatin1String("agentlayerbindings")}, - {'a', QLatin1String("agentlayers")}, - {'a', QLatin1String("agentlayershapes")}, - {'a', QLatin1String("agentlocaltransform")}, - {'a', QLatin1String("agentlocaltransforms")}, - {'a', QLatin1String("agentrigchildren")}, - {'a', QLatin1String("agentrigfind")}, - {'a', QLatin1String("agentrigparent")}, - {'a', QLatin1String("agenttransformcount")}, - {'a', QLatin1String("agenttransformnames")}, - {'a', QLatin1String("agenttransformtolocal")}, - {'a', QLatin1String("agenttransformtoworld")}, - {'a', QLatin1String("agentworldtransform")}, - {'a', QLatin1String("agentworldtransforms")}, - {'a', QLatin1String("albedo")}, - {'a', QLatin1String("alphaname")}, - {'a', QLatin1String("ambient")}, - {'a', QLatin1String("anoise")}, - {'a', QLatin1String("append")}, - {'a', QLatin1String("area")}, - {'a', QLatin1String("argsort")}, - {'a', QLatin1String("array")}, - {'a', QLatin1String("ashikhmin")}, - {'a', QLatin1String("asin")}, - {'a', QLatin1String("assert_enabled")}, - {'a', QLatin1String("assign")}, - {'a', QLatin1String("atan")}, - {'a', QLatin1String("atan2")}, - {'a', QLatin1String("atof")}, - {'a', QLatin1String("atoi")}, - {'a', QLatin1String("atten")}, - {'a', QLatin1String("attrib")}, - {'a', QLatin1String("attribclass")}, - {'a', QLatin1String("attribsize")}, - {'a', QLatin1String("attribtype")}, - {'a', QLatin1String("attribtypeinfo")}, - {'a', QLatin1String("avg")}, - {'b', QLatin1String("binput")}, - {'b', QLatin1String("blackbody")}, - {'b', QLatin1String("blinn")}, - {'b', QLatin1String("blinnBRDF")}, - {'b', QLatin1String("bouncelabel")}, - {'b', QLatin1String("bouncemask")}, - {'b', QLatin1String("bumpmap")}, - {'b', QLatin1String("bumpmapA")}, - {'b', QLatin1String("bumpmapB")}, - {'b', QLatin1String("bumpmapG")}, - {'b', QLatin1String("bumpmapL")}, - {'b', QLatin1String("bumpmapR")}, - {'b', QLatin1String("bumpname")}, - {'c', QLatin1String("cbrt")}, - {'c', QLatin1String("ceil")}, - {'c', QLatin1String("ch")}, - {'c', QLatin1String("ch3")}, - {'c', QLatin1String("ch4")}, - {'c', QLatin1String("chend")}, - {'c', QLatin1String("chendf")}, - {'c', QLatin1String("chendt")}, - {'c', QLatin1String("chf")}, - {'c', QLatin1String("chi")}, - {'c', QLatin1String("chinput")}, - {'c', QLatin1String("chname")}, - {'c', QLatin1String("chnumchan")}, - {'c', QLatin1String("chp")}, - {'c', QLatin1String("chr")}, - {'c', QLatin1String("chramp")}, - {'c', QLatin1String("chrate")}, - {'c', QLatin1String("chs")}, - {'c', QLatin1String("chsraw")}, - {'c', QLatin1String("chstart")}, - {'c', QLatin1String("chstartf")}, - {'c', QLatin1String("chstartt")}, - {'c', QLatin1String("chv")}, - {'c', QLatin1String("cinput")}, - {'c', QLatin1String("ckspline")}, - {'c', QLatin1String("clamp")}, - {'c', QLatin1String("clip")}, - {'c', QLatin1String("colormap")}, - {'c', QLatin1String("colorname")}, - {'c', QLatin1String("computenormal")}, - {'c', QLatin1String("concat")}, - {'c', QLatin1String("cone")}, - {'c', QLatin1String("cos")}, - {'c', QLatin1String("cosh")}, - {'c', QLatin1String("cracktransform")}, - {'c', QLatin1String("cross")}, - {'c', QLatin1String("cspline")}, - {'c', QLatin1String("ctransform")}, - {'c', QLatin1String("curlnoise")}, - {'c', QLatin1String("curlnoise2d")}, - {'c', QLatin1String("curlxnoise")}, - {'c', QLatin1String("curlxnoise2d")}, - {'c', QLatin1String("cvex_bsdf")}, - {'d', QLatin1String("degrees")}, - {'d', QLatin1String("depthmap")}, - {'d', QLatin1String("depthname")}, - {'d', QLatin1String("detail")}, - {'d', QLatin1String("detailattrib")}, - {'d', QLatin1String("detailattribsize")}, - {'d', QLatin1String("detailattribtype")}, - {'d', QLatin1String("detailattribtypeinfo")}, - {'d', QLatin1String("detailintrinsic")}, - {'d', QLatin1String("determinant")}, - {'d', QLatin1String("diffuse")}, - {'d', QLatin1String("diffuseBRDF")}, - {'d', QLatin1String("dihedral")}, - {'d', QLatin1String("dimport")}, - {'d', QLatin1String("distance")}, - {'d', QLatin1String("distance2")}, - {'d', QLatin1String("dot")}, - {'d', QLatin1String("dsmpixel")}, - {'e', QLatin1String("eigenvalues")}, - {'e', QLatin1String("endswith")}, - {'e', QLatin1String("environment")}, - {'e', QLatin1String("erf")}, - {'e', QLatin1String("erf_inv")}, - {'e', QLatin1String("erfc")}, - {'e', QLatin1String("error")}, - {'e', QLatin1String("eulertoquaternion")}, - {'e', QLatin1String("eval_bsdf")}, - {'e', QLatin1String("exp")}, - {'e', QLatin1String("expand_udim")}, - {'e', QLatin1String("expandpointgroup")}, - {'e', QLatin1String("expandprimgroup")}, - {'f', QLatin1String("fastshadow")}, - {'f', QLatin1String("filamentsample")}, - {'f', QLatin1String("file_stat")}, - {'f', QLatin1String("filtershadow")}, - {'f', QLatin1String("filterstep")}, - {'f', QLatin1String("find")}, - {'f', QLatin1String("findattribval")}, - {'f', QLatin1String("findattribvalcount")}, - {'f', QLatin1String("finput")}, - {'f', QLatin1String("fit")}, - {'f', QLatin1String("fit01")}, - {'f', QLatin1String("fit10")}, - {'f', QLatin1String("fit11")}, - {'f', QLatin1String("floor")}, - {'f', QLatin1String("flownoise")}, - {'f', QLatin1String("flowpnoise")}, - {'f', QLatin1String("frac")}, - {'f', QLatin1String("fresnel")}, - {'f', QLatin1String("fromNDC")}, - {'f', QLatin1String("frontface")}, - {'f', QLatin1String("fuzzify")}, - {'f', QLatin1String("fuzzy_and")}, - {'f', QLatin1String("fuzzy_defuzz_centroid")}, - {'f', QLatin1String("fuzzy_nand")}, - {'f', QLatin1String("fuzzy_nor")}, - {'f', QLatin1String("fuzzy_not")}, - {'f', QLatin1String("fuzzy_nxor")}, - {'f', QLatin1String("fuzzy_or")}, - {'f', QLatin1String("fuzzy_xor")}, - {'g', QLatin1String("geoself")}, - {'g', QLatin1String("getattrib")}, - {'g', QLatin1String("getattribute")}, - {'g', QLatin1String("getbbox")}, - {'g', QLatin1String("getblurP")}, - {'g', QLatin1String("getbounces")}, - {'g', QLatin1String("getbounds")}, - {'g', QLatin1String("getcomp")}, - {'g', QLatin1String("getcomponents")}, - {'g', QLatin1String("getderiv")}, - {'g', QLatin1String("getfogname")}, - {'g', QLatin1String("getglobalraylevel")}, - {'g', QLatin1String("getlight")}, - {'g', QLatin1String("getlightid")}, - {'g', QLatin1String("getlightname")}, - {'g', QLatin1String("getlights")}, - {'g', QLatin1String("getlightscope")}, - {'g', QLatin1String("getmaterial")}, - {'g', QLatin1String("getobjectname")}, - {'g', QLatin1String("getphotonlight")}, - {'g', QLatin1String("getpointbbox")}, - {'g', QLatin1String("getprimid")}, - {'g', QLatin1String("getptextureid")}, - {'g', QLatin1String("getraylevel")}, - {'g', QLatin1String("getrayweight")}, - {'g', QLatin1String("getsamplestore")}, - {'g', QLatin1String("getscope")}, - {'g', QLatin1String("getsmoothP")}, - {'g', QLatin1String("getspace")}, - {'g', QLatin1String("getuvobjects")}, - {'g', QLatin1String("getuvtangents")}, - {'g', QLatin1String("gradient")}, - {'h', QLatin1String("hair")}, - {'h', QLatin1String("hasattrib")}, - {'h', QLatin1String("hasdetailattrib")}, - {'h', QLatin1String("haslight")}, - {'h', QLatin1String("hasplane")}, - {'h', QLatin1String("haspointattrib")}, - {'h', QLatin1String("hasprimattrib")}, - {'h', QLatin1String("hasvertexattrib")}, - {'h', QLatin1String("hedge_dstpoint")}, - {'h', QLatin1String("hedge_dstvertex")}, - {'h', QLatin1String("hedge_equivcount")}, - {'h', QLatin1String("hedge_isequiv")}, - {'h', QLatin1String("hedge_isprimary")}, - {'h', QLatin1String("hedge_isvalid")}, - {'h', QLatin1String("hedge_next")}, - {'h', QLatin1String("hedge_nextequiv")}, - {'h', QLatin1String("hedge_postdstpoint")}, - {'h', QLatin1String("hedge_postdstvertex")}, - {'h', QLatin1String("hedge_presrcpoint")}, - {'h', QLatin1String("hedge_presrcvertex")}, - {'h', QLatin1String("hedge_prev")}, - {'h', QLatin1String("hedge_prim")}, - {'h', QLatin1String("hedge_primary")}, - {'h', QLatin1String("hedge_srcpoint")}, - {'h', QLatin1String("hedge_srcvertex")}, - {'h', QLatin1String("henyeygreenstein")}, - {'h', QLatin1String("hscript_noise")}, - {'h', QLatin1String("hscript_rand")}, - {'h', QLatin1String("hscript_snoise")}, - {'h', QLatin1String("hscript_sturb")}, - {'h', QLatin1String("hscript_turb")}, - {'h', QLatin1String("hsvtorgb")}, - {'i', QLatin1String("iaspect")}, - {'i', QLatin1String("ichname")}, - {'i', QLatin1String("ident")}, - {'i', QLatin1String("idtopoint")}, - {'i', QLatin1String("idtoprim")}, - {'i', QLatin1String("iend")}, - {'i', QLatin1String("iendtime")}, - {'i', QLatin1String("ihasplane")}, - {'i', QLatin1String("import")}, - {'i', QLatin1String("ingroup")}, - {'i', QLatin1String("inpointgroup")}, - {'i', QLatin1String("inprimgroup")}, - {'i', QLatin1String("insert")}, - {'i', QLatin1String("instance")}, - {'i', QLatin1String("interpolate")}, - {'i', QLatin1String("intersect")}, - {'i', QLatin1String("intersect_all")}, - {'i', QLatin1String("intersect_lights")}, - {'i', QLatin1String("inumplanes")}, - {'i', QLatin1String("invert")}, - {'i', QLatin1String("invertexgroup")}, - {'i', QLatin1String("iplaneindex")}, - {'i', QLatin1String("iplanename")}, - {'i', QLatin1String("iplanesize")}, - {'i', QLatin1String("irate")}, - {'i', QLatin1String("irradiance")}, - {'i', QLatin1String("isalpha")}, - {'i', QLatin1String("isbound")}, - {'i', QLatin1String("isconnected")}, - {'i', QLatin1String("isdigit")}, - {'i', QLatin1String("isfinite")}, - {'i', QLatin1String("isfogray")}, - {'i', QLatin1String("isframes")}, - {'i', QLatin1String("isnan")}, - {'i', QLatin1String("isotropic")}, - {'i', QLatin1String("israytracing")}, - {'i', QLatin1String("issamples")}, - {'i', QLatin1String("isseconds")}, - {'i', QLatin1String("isshadowray")}, - {'i', QLatin1String("istart")}, - {'i', QLatin1String("istarttime")}, - {'i', QLatin1String("isuvrendering")}, - {'i', QLatin1String("isvalidindex")}, - {'i', QLatin1String("isvarying")}, - {'i', QLatin1String("itoa")}, - {'i', QLatin1String("ixres")}, - {'i', QLatin1String("iyres")}, - {'j', QLatin1String("join")}, - {'k', QLatin1String("kspline")}, - {'l', QLatin1String("len")}, - {'l', QLatin1String("length")}, - {'l', QLatin1String("length2")}, - {'l', QLatin1String("lerp")}, - {'l', QLatin1String("lightid")}, - {'l', QLatin1String("limit_sample_space")}, - {'l', QLatin1String("limport")}, - {'l', QLatin1String("lkspline")}, - {'l', QLatin1String("log")}, - {'l', QLatin1String("log10")}, - {'l', QLatin1String("lookat")}, - {'l', QLatin1String("lspline")}, - {'l', QLatin1String("lstrip")}, - {'l', QLatin1String("luminance")}, - {'l', QLatin1String("lumname")}, - {'m', QLatin1String("makebasis")}, - {'m', QLatin1String("maketransform")}, - {'m', QLatin1String("maskname")}, - {'m', QLatin1String("match")}, - {'m', QLatin1String("matchvex_blinn")}, - {'m', QLatin1String("matchvex_specular")}, - {'m', QLatin1String("mattrib")}, - {'m', QLatin1String("max")}, - {'m', QLatin1String("mdensity")}, - {'m', QLatin1String("metaimport")}, - {'m', QLatin1String("metamarch")}, - {'m', QLatin1String("metanext")}, - {'m', QLatin1String("metastart")}, - {'m', QLatin1String("metaweight")}, - {'m', QLatin1String("min")}, - {'m', QLatin1String("minpos")}, - {'m', QLatin1String("mspace")}, - {'n', QLatin1String("nametopoint")}, - {'n', QLatin1String("nametoprim")}, - {'n', QLatin1String("nbouncetypes")}, - {'n', QLatin1String("nearpoint")}, - {'n', QLatin1String("nearpoints")}, - {'n', QLatin1String("neighbour")}, - {'n', QLatin1String("neighbourcount")}, - {'n', QLatin1String("neighbours")}, - {'n', QLatin1String("newgroup")}, - {'n', QLatin1String("newsampler")}, - {'n', QLatin1String("nextsample")}, - {'n', QLatin1String("ninput")}, - {'n', QLatin1String("noise")}, - {'n', QLatin1String("noised")}, - {'n', QLatin1String("normal_bsdf")}, - {'n', QLatin1String("normalize")}, - {'n', QLatin1String("normalname")}, - {'n', QLatin1String("npoints")}, - {'n', QLatin1String("npointsgroup")}, - {'n', QLatin1String("nprimitives")}, - {'n', QLatin1String("nprimitivesgroup")}, - {'n', QLatin1String("nrandom")}, - {'n', QLatin1String("ntransform")}, - {'n', QLatin1String("nuniqueval")}, - {'n', QLatin1String("nvertices")}, - {'n', QLatin1String("nverticesgroup")}, - {'o', QLatin1String("occlusion")}, - {'o', QLatin1String("onoise")}, - {'o', QLatin1String("opdigits")}, - {'o', QLatin1String("opend")}, - {'o', QLatin1String("opfullpath")}, - {'o', QLatin1String("opstart")}, - {'o', QLatin1String("optransform")}, - {'o', QLatin1String("ord")}, - {'o', QLatin1String("osd_facecount")}, - {'o', QLatin1String("osd_firstpatch")}, - {'o', QLatin1String("osd_limitsurface")}, - {'o', QLatin1String("osd_limitsurfacevertex")}, - {'o', QLatin1String("osd_patchcount")}, - {'o', QLatin1String("osd_patches")}, - {'o', QLatin1String("outerproduct")}, - {'o', QLatin1String("ow_nspace")}, - {'o', QLatin1String("ow_space")}, - {'o', QLatin1String("ow_vspace")}, - {'p', QLatin1String("pack_inttosafefloat")}, - {'p', QLatin1String("pathtrace")}, - {'p', QLatin1String("pcclose")}, - {'p', QLatin1String("pcconvex")}, - {'p', QLatin1String("pcexport")}, - {'p', QLatin1String("pcfarthest")}, - {'p', QLatin1String("pcfilter")}, - {'p', QLatin1String("pcfind")}, - {'p', QLatin1String("pcfind_radius")}, - {'p', QLatin1String("pcgenerate")}, - {'p', QLatin1String("pcimport")}, - {'p', QLatin1String("pcimportbyidx3")}, - {'p', QLatin1String("pcimportbyidx4")}, - {'p', QLatin1String("pcimportbyidxf")}, - {'p', QLatin1String("pcimportbyidxi")}, - {'p', QLatin1String("pcimportbyidxp")}, - {'p', QLatin1String("pcimportbyidxs")}, - {'p', QLatin1String("pcimportbyidxv")}, - {'p', QLatin1String("pciterate")}, - {'p', QLatin1String("pcnumfound")}, - {'p', QLatin1String("pcopen")}, - {'p', QLatin1String("pcopenlod")}, - {'p', QLatin1String("pcsampleleaf")}, - {'p', QLatin1String("pcsize")}, - {'p', QLatin1String("pcunshaded")}, - {'p', QLatin1String("pcwrite")}, - {'p', QLatin1String("pgfind")}, - {'p', QLatin1String("phong")}, - {'p', QLatin1String("phongBRDF")}, - {'p', QLatin1String("phonglobe")}, - {'p', QLatin1String("photonmap")}, - {'p', QLatin1String("planeindex")}, - {'p', QLatin1String("planename")}, - {'p', QLatin1String("planesize")}, - {'p', QLatin1String("pluralize")}, - {'p', QLatin1String("pnoise")}, - {'p', QLatin1String("point")}, - {'p', QLatin1String("pointattrib")}, - {'p', QLatin1String("pointattribsize")}, - {'p', QLatin1String("pointattribtype")}, - {'p', QLatin1String("pointattribtypeinfo")}, - {'p', QLatin1String("pointedge")}, - {'p', QLatin1String("pointhedge")}, - {'p', QLatin1String("pointhedgenext")}, - {'p', QLatin1String("pointname")}, - {'p', QLatin1String("pointprims")}, - {'p', QLatin1String("pointvertex")}, - {'p', QLatin1String("pointvertices")}, - {'p', QLatin1String("polardecomp")}, - {'p', QLatin1String("pop")}, - {'p', QLatin1String("pow")}, - {'p', QLatin1String("prim")}, - {'p', QLatin1String("prim_attribute")}, - {'p', QLatin1String("prim_normal")}, - {'p', QLatin1String("primattrib")}, - {'p', QLatin1String("primattribsize")}, - {'p', QLatin1String("primattribtype")}, - {'p', QLatin1String("primattribtypeinfo")}, - {'p', QLatin1String("primhedge")}, - {'p', QLatin1String("primintrinsic")}, - {'p', QLatin1String("primpoint")}, - {'p', QLatin1String("primpoints")}, - {'p', QLatin1String("primuv")}, - {'p', QLatin1String("primvertex")}, - {'p', QLatin1String("primvertexcount")}, - {'p', QLatin1String("primvertices")}, - {'p', QLatin1String("print_once")}, - {'p', QLatin1String("printf")}, - {'p', QLatin1String("product")}, - {'p', QLatin1String("ptexture")}, - {'p', QLatin1String("ptlined")}, - {'p', QLatin1String("ptransform")}, - {'p', QLatin1String("push")}, - {'q', QLatin1String("qconvert")}, - {'q', QLatin1String("qdistance")}, - {'q', QLatin1String("qinvert")}, - {'q', QLatin1String("qmultiply")}, - {'q', QLatin1String("qrotate")}, - {'q', QLatin1String("quaternion")}, - {'r', QLatin1String("radians")}, - {'r', QLatin1String("rand")}, - {'r', QLatin1String("random")}, - {'r', QLatin1String("random_fhash")}, - {'r', QLatin1String("random_ihash")}, - {'r', QLatin1String("random_shash")}, - {'r', QLatin1String("random_sobol")}, - {'r', QLatin1String("rawbumpmap")}, - {'r', QLatin1String("rawbumpmapA")}, - {'r', QLatin1String("rawbumpmapB")}, - {'r', QLatin1String("rawbumpmapG")}, - {'r', QLatin1String("rawbumpmapL")}, - {'r', QLatin1String("rawbumpmapR")}, - {'r', QLatin1String("rawcolormap")}, - {'r', QLatin1String("rayhittest")}, - {'r', QLatin1String("rayimport")}, - {'r', QLatin1String("re_find")}, - {'r', QLatin1String("re_findall")}, - {'r', QLatin1String("re_match")}, - {'r', QLatin1String("re_replace")}, - {'r', QLatin1String("re_split")}, - {'r', QLatin1String("reflect")}, - {'r', QLatin1String("reflectlight")}, - {'r', QLatin1String("refract")}, - {'r', QLatin1String("refractlight")}, - {'r', QLatin1String("relativepath")}, - {'r', QLatin1String("relbbox")}, - {'r', QLatin1String("relpointbbox")}, - {'r', QLatin1String("removegroup")}, - {'r', QLatin1String("removeindex")}, - {'r', QLatin1String("removepoint")}, - {'r', QLatin1String("removeprim")}, - {'r', QLatin1String("removevalue")}, - {'r', QLatin1String("renderstate")}, - {'r', QLatin1String("reorder")}, - {'r', QLatin1String("resample_linear")}, - {'r', QLatin1String("resize")}, - {'r', QLatin1String("resolvemissedray")}, - {'r', QLatin1String("reverse")}, - {'r', QLatin1String("rgbtohsv")}, - {'r', QLatin1String("rgbtoxyz")}, - {'r', QLatin1String("rint")}, - {'r', QLatin1String("rotate")}, - {'r', QLatin1String("rotate_x_to")}, - {'r', QLatin1String("rstrip")}, - {'s', QLatin1String("sample_bsdf")}, - {'s', QLatin1String("sample_cauchy")}, - {'s', QLatin1String("sample_circle_arc")}, - {'s', QLatin1String("sample_circle_edge_uniform")}, - {'s', QLatin1String("sample_circle_slice")}, - {'s', QLatin1String("sample_circle_uniform")}, - {'s', QLatin1String("sample_direction_cone")}, - {'s', QLatin1String("sample_direction_uniform")}, - {'s', QLatin1String("sample_discrete")}, - {'s', QLatin1String("sample_exponential")}, - {'s', QLatin1String("sample_geometry")}, - {'s', QLatin1String("sample_hemisphere")}, - {'s', QLatin1String("sample_hypersphere_cone")}, - {'s', QLatin1String("sample_hypersphere_uniform")}, - {'s', QLatin1String("sample_light")}, - {'s', QLatin1String("sample_lognormal")}, - {'s', QLatin1String("sample_lognormal_by_median")}, - {'s', QLatin1String("sample_normal")}, - {'s', QLatin1String("sample_orientation_cone")}, - {'s', QLatin1String("sample_orientation_uniform")}, - {'s', QLatin1String("sample_photon")}, - {'s', QLatin1String("sample_sphere_cone")}, - {'s', QLatin1String("sample_sphere_uniform")}, - {'s', QLatin1String("sampledisk")}, - {'s', QLatin1String("scale")}, - {'s', QLatin1String("select")}, - {'s', QLatin1String("sensor_panorama_create")}, - {'s', QLatin1String("sensor_panorama_getcolor")}, - {'s', QLatin1String("sensor_panorama_getcone")}, - {'s', QLatin1String("sensor_panorama_getdepth")}, - {'s', QLatin1String("sensor_save")}, - {'s', QLatin1String("serialize")}, - {'s', QLatin1String("set")}, - {'s', QLatin1String("setagentclipnames")}, - {'s', QLatin1String("setagentcliptimes")}, - {'s', QLatin1String("setagentclipweights")}, - {'s', QLatin1String("setagentcollisionlayer")}, - {'s', QLatin1String("setagentcurrentlayer")}, - {'s', QLatin1String("setagentlocaltransform")}, - {'s', QLatin1String("setagentlocaltransforms")}, - {'s', QLatin1String("setagentworldtransform")}, - {'s', QLatin1String("setagentworldtransforms")}, - {'s', QLatin1String("setattrib")}, - {'s', QLatin1String("setattribtypeinfo")}, - {'s', QLatin1String("setcomp")}, - {'s', QLatin1String("setcurrentlight")}, - {'s', QLatin1String("setdetailattrib")}, - {'s', QLatin1String("setpointattrib")}, - {'s', QLatin1String("setpointgroup")}, - {'s', QLatin1String("setprimattrib")}, - {'s', QLatin1String("setprimgroup")}, - {'s', QLatin1String("setprimintrinsic")}, - {'s', QLatin1String("setprimvertex")}, - {'s', QLatin1String("setsamplestore")}, - {'s', QLatin1String("setvertexattrib")}, - {'s', QLatin1String("setvertexgroup")}, - {'s', QLatin1String("setvertexpoint")}, - {'s', QLatin1String("shadow")}, - {'s', QLatin1String("shadow_light")}, - {'s', QLatin1String("shadowmap")}, - {'s', QLatin1String("shimport")}, - {'s', QLatin1String("shl")}, - {'s', QLatin1String("shr")}, - {'s', QLatin1String("shrz")}, - {'s', QLatin1String("sign")}, - {'s', QLatin1String("simport")}, - {'s', QLatin1String("sin")}, - {'s', QLatin1String("sinh")}, - {'s', QLatin1String("sleep")}, - {'s', QLatin1String("slerp")}, - {'s', QLatin1String("slice")}, - {'s', QLatin1String("slideframe")}, - {'s', QLatin1String("smooth")}, - {'s', QLatin1String("smoothrotation")}, - {'s', QLatin1String("snoise")}, - {'s', QLatin1String("solvecubic")}, - {'s', QLatin1String("solvepoly")}, - {'s', QLatin1String("solvequadratic")}, - {'s', QLatin1String("sort")}, - {'s', QLatin1String("specular")}, - {'s', QLatin1String("specularBRDF")}, - {'s', QLatin1String("spline")}, - {'s', QLatin1String("split")}, - {'s', QLatin1String("splitpath")}, - {'s', QLatin1String("sprintf")}, - {'s', QLatin1String("sqrt")}, - {'s', QLatin1String("startswith")}, - {'s', QLatin1String("storelightexport")}, - {'s', QLatin1String("strip")}, - {'s', QLatin1String("strlen")}, - {'s', QLatin1String("sum")}, - {'s', QLatin1String("switch")}, - {'s', QLatin1String("swizzle")}, - {'t', QLatin1String("tan")}, - {'t', QLatin1String("tanh")}, - {'t', QLatin1String("tet_adjacent")}, - {'t', QLatin1String("tet_faceindex")}, - {'t', QLatin1String("teximport")}, - {'t', QLatin1String("texprintf")}, - {'t', QLatin1String("texture")}, - {'t', QLatin1String("texture3d")}, - {'t', QLatin1String("texture3dBox")}, - {'t', QLatin1String("titlecase")}, - {'t', QLatin1String("toNDC")}, - {'t', QLatin1String("tolower")}, - {'t', QLatin1String("toupper")}, - {'t', QLatin1String("trace")}, - {'t', QLatin1String("translate")}, - {'t', QLatin1String("translucent")}, - {'t', QLatin1String("transpose")}, - {'t', QLatin1String("trunc")}, - {'t', QLatin1String("tw_nspace")}, - {'t', QLatin1String("tw_space")}, - {'t', QLatin1String("tw_vspace")}, - {'u', QLatin1String("uniqueval")}, - {'u', QLatin1String("unpack_intfromsafefloat")}, - {'u', QLatin1String("unserialize")}, - {'u', QLatin1String("upush")}, - {'u', QLatin1String("uvunwrap")}, - {'v', QLatin1String("variance")}, - {'v', QLatin1String("velocityname")}, - {'v', QLatin1String("vertex")}, - {'v', QLatin1String("vertexattrib")}, - {'v', QLatin1String("vertexattribsize")}, - {'v', QLatin1String("vertexattribtype")}, - {'v', QLatin1String("vertexattribtypeinfo")}, - {'v', QLatin1String("vertexhedge")}, - {'v', QLatin1String("vertexindex")}, - {'v', QLatin1String("vertexnext")}, - {'v', QLatin1String("vertexpoint")}, - {'v', QLatin1String("vertexprev")}, - {'v', QLatin1String("vertexprim")}, - {'v', QLatin1String("vertexprimindex")}, - {'v', QLatin1String("vnoise")}, - {'v', QLatin1String("volume")}, - {'v', QLatin1String("volumegradient")}, - {'v', QLatin1String("volumeindex")}, - {'v', QLatin1String("volumeindexorigin")}, - {'v', QLatin1String("volumeindextopos")}, - {'v', QLatin1String("volumeindexv")}, - {'v', QLatin1String("volumepostoindex")}, - {'v', QLatin1String("volumeres")}, - {'v', QLatin1String("volumesample")}, - {'v', QLatin1String("volumesamplev")}, - {'v', QLatin1String("vtransform")}, - {'w', QLatin1String("warning")}, - {'w', QLatin1String("wireblinn")}, - {'w', QLatin1String("wirediffuse")}, - {'w', QLatin1String("wnoise")}, - {'w', QLatin1String("wo_nspace")}, - {'w', QLatin1String("wo_space")}, - {'w', QLatin1String("wo_vspace")}, - {'w', QLatin1String("writepixel")}, - {'w', QLatin1String("wt_nspace")}, - {'w', QLatin1String("wt_space")}, - {'w', QLatin1String("wt_vspace")}, - {'x', QLatin1String("xnoise")}, - {'x', QLatin1String("xnoised")}, - {'x', QLatin1String("xyzdist")}, - {'x', QLatin1String("xyztorgb")} - }; - vex_other = { - {('d'), QLatin1String("define")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("endif")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("ifdef")}, - {('i'), QLatin1String("ifndef")}, - {('i'), QLatin1String("include")}, - {('p'), QLatin1String("pragma")}, - {('u'), QLatin1String("undef")}, - }; + vex_builtin = {{'D', QLatin1String("Du")}, + {'D', QLatin1String("Dv")}, + {'D', QLatin1String("Dw")}, + {'a', QLatin1String("abs")}, + {'a', QLatin1String("accessframe")}, + {'a', QLatin1String("acos")}, + {'a', QLatin1String("addattrib")}, + {'a', QLatin1String("addattribute")}, + {'a', QLatin1String("adddetailattrib")}, + {'a', QLatin1String("addgroup")}, + {'a', QLatin1String("addpoint")}, + {'a', QLatin1String("addpointattrib")}, + {'a', QLatin1String("addprim")}, + {'a', QLatin1String("addprimattrib")}, + {'a', QLatin1String("addvariablename")}, + {'a', QLatin1String("addvertex")}, + {'a', QLatin1String("addvertexattrib")}, + {'a', QLatin1String("addvisualizer")}, + {'a', QLatin1String("agentaddclip")}, + {'a', QLatin1String("agentclipcatalog")}, + {'a', QLatin1String("agentclipchannel")}, + {'a', QLatin1String("agentcliplength")}, + {'a', QLatin1String("agentclipnames")}, + {'a', QLatin1String("agentclipsample")}, + {'a', QLatin1String("agentclipsamplelocal")}, + {'a', QLatin1String("agentclipsamplerate")}, + {'a', QLatin1String("agentclipsampleworld")}, + {'a', QLatin1String("agentcliptimes")}, + {'a', QLatin1String("agentclipweights")}, + {'a', QLatin1String("agentcollisionlayer")}, + {'a', QLatin1String("agentcurrentlayer")}, + {'a', QLatin1String("agentlayerbindings")}, + {'a', QLatin1String("agentlayers")}, + {'a', QLatin1String("agentlayershapes")}, + {'a', QLatin1String("agentlocaltransform")}, + {'a', QLatin1String("agentlocaltransforms")}, + {'a', QLatin1String("agentrigchildren")}, + {'a', QLatin1String("agentrigfind")}, + {'a', QLatin1String("agentrigparent")}, + {'a', QLatin1String("agenttransformcount")}, + {'a', QLatin1String("agenttransformnames")}, + {'a', QLatin1String("agenttransformtolocal")}, + {'a', QLatin1String("agenttransformtoworld")}, + {'a', QLatin1String("agentworldtransform")}, + {'a', QLatin1String("agentworldtransforms")}, + {'a', QLatin1String("albedo")}, + {'a', QLatin1String("alphaname")}, + {'a', QLatin1String("ambient")}, + {'a', QLatin1String("anoise")}, + {'a', QLatin1String("append")}, + {'a', QLatin1String("area")}, + {'a', QLatin1String("argsort")}, + {'a', QLatin1String("array")}, + {'a', QLatin1String("ashikhmin")}, + {'a', QLatin1String("asin")}, + {'a', QLatin1String("assert_enabled")}, + {'a', QLatin1String("assign")}, + {'a', QLatin1String("atan")}, + {'a', QLatin1String("atan2")}, + {'a', QLatin1String("atof")}, + {'a', QLatin1String("atoi")}, + {'a', QLatin1String("atten")}, + {'a', QLatin1String("attrib")}, + {'a', QLatin1String("attribclass")}, + {'a', QLatin1String("attribsize")}, + {'a', QLatin1String("attribtype")}, + {'a', QLatin1String("attribtypeinfo")}, + {'a', QLatin1String("avg")}, + {'b', QLatin1String("binput")}, + {'b', QLatin1String("blackbody")}, + {'b', QLatin1String("blinn")}, + {'b', QLatin1String("blinnBRDF")}, + {'b', QLatin1String("bouncelabel")}, + {'b', QLatin1String("bouncemask")}, + {'b', QLatin1String("bumpmap")}, + {'b', QLatin1String("bumpmapA")}, + {'b', QLatin1String("bumpmapB")}, + {'b', QLatin1String("bumpmapG")}, + {'b', QLatin1String("bumpmapL")}, + {'b', QLatin1String("bumpmapR")}, + {'b', QLatin1String("bumpname")}, + {'c', QLatin1String("cbrt")}, + {'c', QLatin1String("ceil")}, + {'c', QLatin1String("ch")}, + {'c', QLatin1String("ch3")}, + {'c', QLatin1String("ch4")}, + {'c', QLatin1String("chend")}, + {'c', QLatin1String("chendf")}, + {'c', QLatin1String("chendt")}, + {'c', QLatin1String("chf")}, + {'c', QLatin1String("chi")}, + {'c', QLatin1String("chinput")}, + {'c', QLatin1String("chname")}, + {'c', QLatin1String("chnumchan")}, + {'c', QLatin1String("chp")}, + {'c', QLatin1String("chr")}, + {'c', QLatin1String("chramp")}, + {'c', QLatin1String("chrate")}, + {'c', QLatin1String("chs")}, + {'c', QLatin1String("chsraw")}, + {'c', QLatin1String("chstart")}, + {'c', QLatin1String("chstartf")}, + {'c', QLatin1String("chstartt")}, + {'c', QLatin1String("chv")}, + {'c', QLatin1String("cinput")}, + {'c', QLatin1String("ckspline")}, + {'c', QLatin1String("clamp")}, + {'c', QLatin1String("clip")}, + {'c', QLatin1String("colormap")}, + {'c', QLatin1String("colorname")}, + {'c', QLatin1String("computenormal")}, + {'c', QLatin1String("concat")}, + {'c', QLatin1String("cone")}, + {'c', QLatin1String("cos")}, + {'c', QLatin1String("cosh")}, + {'c', QLatin1String("cracktransform")}, + {'c', QLatin1String("cross")}, + {'c', QLatin1String("cspline")}, + {'c', QLatin1String("ctransform")}, + {'c', QLatin1String("curlnoise")}, + {'c', QLatin1String("curlnoise2d")}, + {'c', QLatin1String("curlxnoise")}, + {'c', QLatin1String("curlxnoise2d")}, + {'c', QLatin1String("cvex_bsdf")}, + {'d', QLatin1String("degrees")}, + {'d', QLatin1String("depthmap")}, + {'d', QLatin1String("depthname")}, + {'d', QLatin1String("detail")}, + {'d', QLatin1String("detailattrib")}, + {'d', QLatin1String("detailattribsize")}, + {'d', QLatin1String("detailattribtype")}, + {'d', QLatin1String("detailattribtypeinfo")}, + {'d', QLatin1String("detailintrinsic")}, + {'d', QLatin1String("determinant")}, + {'d', QLatin1String("diffuse")}, + {'d', QLatin1String("diffuseBRDF")}, + {'d', QLatin1String("dihedral")}, + {'d', QLatin1String("dimport")}, + {'d', QLatin1String("distance")}, + {'d', QLatin1String("distance2")}, + {'d', QLatin1String("dot")}, + {'d', QLatin1String("dsmpixel")}, + {'e', QLatin1String("eigenvalues")}, + {'e', QLatin1String("endswith")}, + {'e', QLatin1String("environment")}, + {'e', QLatin1String("erf")}, + {'e', QLatin1String("erf_inv")}, + {'e', QLatin1String("erfc")}, + {'e', QLatin1String("error")}, + {'e', QLatin1String("eulertoquaternion")}, + {'e', QLatin1String("eval_bsdf")}, + {'e', QLatin1String("exp")}, + {'e', QLatin1String("expand_udim")}, + {'e', QLatin1String("expandpointgroup")}, + {'e', QLatin1String("expandprimgroup")}, + {'f', QLatin1String("fastshadow")}, + {'f', QLatin1String("filamentsample")}, + {'f', QLatin1String("file_stat")}, + {'f', QLatin1String("filtershadow")}, + {'f', QLatin1String("filterstep")}, + {'f', QLatin1String("find")}, + {'f', QLatin1String("findattribval")}, + {'f', QLatin1String("findattribvalcount")}, + {'f', QLatin1String("finput")}, + {'f', QLatin1String("fit")}, + {'f', QLatin1String("fit01")}, + {'f', QLatin1String("fit10")}, + {'f', QLatin1String("fit11")}, + {'f', QLatin1String("floor")}, + {'f', QLatin1String("flownoise")}, + {'f', QLatin1String("flowpnoise")}, + {'f', QLatin1String("frac")}, + {'f', QLatin1String("fresnel")}, + {'f', QLatin1String("fromNDC")}, + {'f', QLatin1String("frontface")}, + {'f', QLatin1String("fuzzify")}, + {'f', QLatin1String("fuzzy_and")}, + {'f', QLatin1String("fuzzy_defuzz_centroid")}, + {'f', QLatin1String("fuzzy_nand")}, + {'f', QLatin1String("fuzzy_nor")}, + {'f', QLatin1String("fuzzy_not")}, + {'f', QLatin1String("fuzzy_nxor")}, + {'f', QLatin1String("fuzzy_or")}, + {'f', QLatin1String("fuzzy_xor")}, + {'g', QLatin1String("geoself")}, + {'g', QLatin1String("getattrib")}, + {'g', QLatin1String("getattribute")}, + {'g', QLatin1String("getbbox")}, + {'g', QLatin1String("getblurP")}, + {'g', QLatin1String("getbounces")}, + {'g', QLatin1String("getbounds")}, + {'g', QLatin1String("getcomp")}, + {'g', QLatin1String("getcomponents")}, + {'g', QLatin1String("getderiv")}, + {'g', QLatin1String("getfogname")}, + {'g', QLatin1String("getglobalraylevel")}, + {'g', QLatin1String("getlight")}, + {'g', QLatin1String("getlightid")}, + {'g', QLatin1String("getlightname")}, + {'g', QLatin1String("getlights")}, + {'g', QLatin1String("getlightscope")}, + {'g', QLatin1String("getmaterial")}, + {'g', QLatin1String("getobjectname")}, + {'g', QLatin1String("getphotonlight")}, + {'g', QLatin1String("getpointbbox")}, + {'g', QLatin1String("getprimid")}, + {'g', QLatin1String("getptextureid")}, + {'g', QLatin1String("getraylevel")}, + {'g', QLatin1String("getrayweight")}, + {'g', QLatin1String("getsamplestore")}, + {'g', QLatin1String("getscope")}, + {'g', QLatin1String("getsmoothP")}, + {'g', QLatin1String("getspace")}, + {'g', QLatin1String("getuvobjects")}, + {'g', QLatin1String("getuvtangents")}, + {'g', QLatin1String("gradient")}, + {'h', QLatin1String("hair")}, + {'h', QLatin1String("hasattrib")}, + {'h', QLatin1String("hasdetailattrib")}, + {'h', QLatin1String("haslight")}, + {'h', QLatin1String("hasplane")}, + {'h', QLatin1String("haspointattrib")}, + {'h', QLatin1String("hasprimattrib")}, + {'h', QLatin1String("hasvertexattrib")}, + {'h', QLatin1String("hedge_dstpoint")}, + {'h', QLatin1String("hedge_dstvertex")}, + {'h', QLatin1String("hedge_equivcount")}, + {'h', QLatin1String("hedge_isequiv")}, + {'h', QLatin1String("hedge_isprimary")}, + {'h', QLatin1String("hedge_isvalid")}, + {'h', QLatin1String("hedge_next")}, + {'h', QLatin1String("hedge_nextequiv")}, + {'h', QLatin1String("hedge_postdstpoint")}, + {'h', QLatin1String("hedge_postdstvertex")}, + {'h', QLatin1String("hedge_presrcpoint")}, + {'h', QLatin1String("hedge_presrcvertex")}, + {'h', QLatin1String("hedge_prev")}, + {'h', QLatin1String("hedge_prim")}, + {'h', QLatin1String("hedge_primary")}, + {'h', QLatin1String("hedge_srcpoint")}, + {'h', QLatin1String("hedge_srcvertex")}, + {'h', QLatin1String("henyeygreenstein")}, + {'h', QLatin1String("hscript_noise")}, + {'h', QLatin1String("hscript_rand")}, + {'h', QLatin1String("hscript_snoise")}, + {'h', QLatin1String("hscript_sturb")}, + {'h', QLatin1String("hscript_turb")}, + {'h', QLatin1String("hsvtorgb")}, + {'i', QLatin1String("iaspect")}, + {'i', QLatin1String("ichname")}, + {'i', QLatin1String("ident")}, + {'i', QLatin1String("idtopoint")}, + {'i', QLatin1String("idtoprim")}, + {'i', QLatin1String("iend")}, + {'i', QLatin1String("iendtime")}, + {'i', QLatin1String("ihasplane")}, + {'i', QLatin1String("import")}, + {'i', QLatin1String("ingroup")}, + {'i', QLatin1String("inpointgroup")}, + {'i', QLatin1String("inprimgroup")}, + {'i', QLatin1String("insert")}, + {'i', QLatin1String("instance")}, + {'i', QLatin1String("interpolate")}, + {'i', QLatin1String("intersect")}, + {'i', QLatin1String("intersect_all")}, + {'i', QLatin1String("intersect_lights")}, + {'i', QLatin1String("inumplanes")}, + {'i', QLatin1String("invert")}, + {'i', QLatin1String("invertexgroup")}, + {'i', QLatin1String("iplaneindex")}, + {'i', QLatin1String("iplanename")}, + {'i', QLatin1String("iplanesize")}, + {'i', QLatin1String("irate")}, + {'i', QLatin1String("irradiance")}, + {'i', QLatin1String("isalpha")}, + {'i', QLatin1String("isbound")}, + {'i', QLatin1String("isconnected")}, + {'i', QLatin1String("isdigit")}, + {'i', QLatin1String("isfinite")}, + {'i', QLatin1String("isfogray")}, + {'i', QLatin1String("isframes")}, + {'i', QLatin1String("isnan")}, + {'i', QLatin1String("isotropic")}, + {'i', QLatin1String("israytracing")}, + {'i', QLatin1String("issamples")}, + {'i', QLatin1String("isseconds")}, + {'i', QLatin1String("isshadowray")}, + {'i', QLatin1String("istart")}, + {'i', QLatin1String("istarttime")}, + {'i', QLatin1String("isuvrendering")}, + {'i', QLatin1String("isvalidindex")}, + {'i', QLatin1String("isvarying")}, + {'i', QLatin1String("itoa")}, + {'i', QLatin1String("ixres")}, + {'i', QLatin1String("iyres")}, + {'j', QLatin1String("join")}, + {'k', QLatin1String("kspline")}, + {'l', QLatin1String("len")}, + {'l', QLatin1String("length")}, + {'l', QLatin1String("length2")}, + {'l', QLatin1String("lerp")}, + {'l', QLatin1String("lightid")}, + {'l', QLatin1String("limit_sample_space")}, + {'l', QLatin1String("limport")}, + {'l', QLatin1String("lkspline")}, + {'l', QLatin1String("log")}, + {'l', QLatin1String("log10")}, + {'l', QLatin1String("lookat")}, + {'l', QLatin1String("lspline")}, + {'l', QLatin1String("lstrip")}, + {'l', QLatin1String("luminance")}, + {'l', QLatin1String("lumname")}, + {'m', QLatin1String("makebasis")}, + {'m', QLatin1String("maketransform")}, + {'m', QLatin1String("maskname")}, + {'m', QLatin1String("match")}, + {'m', QLatin1String("matchvex_blinn")}, + {'m', QLatin1String("matchvex_specular")}, + {'m', QLatin1String("mattrib")}, + {'m', QLatin1String("max")}, + {'m', QLatin1String("mdensity")}, + {'m', QLatin1String("metaimport")}, + {'m', QLatin1String("metamarch")}, + {'m', QLatin1String("metanext")}, + {'m', QLatin1String("metastart")}, + {'m', QLatin1String("metaweight")}, + {'m', QLatin1String("min")}, + {'m', QLatin1String("minpos")}, + {'m', QLatin1String("mspace")}, + {'n', QLatin1String("nametopoint")}, + {'n', QLatin1String("nametoprim")}, + {'n', QLatin1String("nbouncetypes")}, + {'n', QLatin1String("nearpoint")}, + {'n', QLatin1String("nearpoints")}, + {'n', QLatin1String("neighbour")}, + {'n', QLatin1String("neighbourcount")}, + {'n', QLatin1String("neighbours")}, + {'n', QLatin1String("newgroup")}, + {'n', QLatin1String("newsampler")}, + {'n', QLatin1String("nextsample")}, + {'n', QLatin1String("ninput")}, + {'n', QLatin1String("noise")}, + {'n', QLatin1String("noised")}, + {'n', QLatin1String("normal_bsdf")}, + {'n', QLatin1String("normalize")}, + {'n', QLatin1String("normalname")}, + {'n', QLatin1String("npoints")}, + {'n', QLatin1String("npointsgroup")}, + {'n', QLatin1String("nprimitives")}, + {'n', QLatin1String("nprimitivesgroup")}, + {'n', QLatin1String("nrandom")}, + {'n', QLatin1String("ntransform")}, + {'n', QLatin1String("nuniqueval")}, + {'n', QLatin1String("nvertices")}, + {'n', QLatin1String("nverticesgroup")}, + {'o', QLatin1String("occlusion")}, + {'o', QLatin1String("onoise")}, + {'o', QLatin1String("opdigits")}, + {'o', QLatin1String("opend")}, + {'o', QLatin1String("opfullpath")}, + {'o', QLatin1String("opstart")}, + {'o', QLatin1String("optransform")}, + {'o', QLatin1String("ord")}, + {'o', QLatin1String("osd_facecount")}, + {'o', QLatin1String("osd_firstpatch")}, + {'o', QLatin1String("osd_limitsurface")}, + {'o', QLatin1String("osd_limitsurfacevertex")}, + {'o', QLatin1String("osd_patchcount")}, + {'o', QLatin1String("osd_patches")}, + {'o', QLatin1String("outerproduct")}, + {'o', QLatin1String("ow_nspace")}, + {'o', QLatin1String("ow_space")}, + {'o', QLatin1String("ow_vspace")}, + {'p', QLatin1String("pack_inttosafefloat")}, + {'p', QLatin1String("pathtrace")}, + {'p', QLatin1String("pcclose")}, + {'p', QLatin1String("pcconvex")}, + {'p', QLatin1String("pcexport")}, + {'p', QLatin1String("pcfarthest")}, + {'p', QLatin1String("pcfilter")}, + {'p', QLatin1String("pcfind")}, + {'p', QLatin1String("pcfind_radius")}, + {'p', QLatin1String("pcgenerate")}, + {'p', QLatin1String("pcimport")}, + {'p', QLatin1String("pcimportbyidx3")}, + {'p', QLatin1String("pcimportbyidx4")}, + {'p', QLatin1String("pcimportbyidxf")}, + {'p', QLatin1String("pcimportbyidxi")}, + {'p', QLatin1String("pcimportbyidxp")}, + {'p', QLatin1String("pcimportbyidxs")}, + {'p', QLatin1String("pcimportbyidxv")}, + {'p', QLatin1String("pciterate")}, + {'p', QLatin1String("pcnumfound")}, + {'p', QLatin1String("pcopen")}, + {'p', QLatin1String("pcopenlod")}, + {'p', QLatin1String("pcsampleleaf")}, + {'p', QLatin1String("pcsize")}, + {'p', QLatin1String("pcunshaded")}, + {'p', QLatin1String("pcwrite")}, + {'p', QLatin1String("pgfind")}, + {'p', QLatin1String("phong")}, + {'p', QLatin1String("phongBRDF")}, + {'p', QLatin1String("phonglobe")}, + {'p', QLatin1String("photonmap")}, + {'p', QLatin1String("planeindex")}, + {'p', QLatin1String("planename")}, + {'p', QLatin1String("planesize")}, + {'p', QLatin1String("pluralize")}, + {'p', QLatin1String("pnoise")}, + {'p', QLatin1String("point")}, + {'p', QLatin1String("pointattrib")}, + {'p', QLatin1String("pointattribsize")}, + {'p', QLatin1String("pointattribtype")}, + {'p', QLatin1String("pointattribtypeinfo")}, + {'p', QLatin1String("pointedge")}, + {'p', QLatin1String("pointhedge")}, + {'p', QLatin1String("pointhedgenext")}, + {'p', QLatin1String("pointname")}, + {'p', QLatin1String("pointprims")}, + {'p', QLatin1String("pointvertex")}, + {'p', QLatin1String("pointvertices")}, + {'p', QLatin1String("polardecomp")}, + {'p', QLatin1String("pop")}, + {'p', QLatin1String("pow")}, + {'p', QLatin1String("prim")}, + {'p', QLatin1String("prim_attribute")}, + {'p', QLatin1String("prim_normal")}, + {'p', QLatin1String("primattrib")}, + {'p', QLatin1String("primattribsize")}, + {'p', QLatin1String("primattribtype")}, + {'p', QLatin1String("primattribtypeinfo")}, + {'p', QLatin1String("primhedge")}, + {'p', QLatin1String("primintrinsic")}, + {'p', QLatin1String("primpoint")}, + {'p', QLatin1String("primpoints")}, + {'p', QLatin1String("primuv")}, + {'p', QLatin1String("primvertex")}, + {'p', QLatin1String("primvertexcount")}, + {'p', QLatin1String("primvertices")}, + {'p', QLatin1String("print_once")}, + {'p', QLatin1String("printf")}, + {'p', QLatin1String("product")}, + {'p', QLatin1String("ptexture")}, + {'p', QLatin1String("ptlined")}, + {'p', QLatin1String("ptransform")}, + {'p', QLatin1String("push")}, + {'q', QLatin1String("qconvert")}, + {'q', QLatin1String("qdistance")}, + {'q', QLatin1String("qinvert")}, + {'q', QLatin1String("qmultiply")}, + {'q', QLatin1String("qrotate")}, + {'q', QLatin1String("quaternion")}, + {'r', QLatin1String("radians")}, + {'r', QLatin1String("rand")}, + {'r', QLatin1String("random")}, + {'r', QLatin1String("random_fhash")}, + {'r', QLatin1String("random_ihash")}, + {'r', QLatin1String("random_shash")}, + {'r', QLatin1String("random_sobol")}, + {'r', QLatin1String("rawbumpmap")}, + {'r', QLatin1String("rawbumpmapA")}, + {'r', QLatin1String("rawbumpmapB")}, + {'r', QLatin1String("rawbumpmapG")}, + {'r', QLatin1String("rawbumpmapL")}, + {'r', QLatin1String("rawbumpmapR")}, + {'r', QLatin1String("rawcolormap")}, + {'r', QLatin1String("rayhittest")}, + {'r', QLatin1String("rayimport")}, + {'r', QLatin1String("re_find")}, + {'r', QLatin1String("re_findall")}, + {'r', QLatin1String("re_match")}, + {'r', QLatin1String("re_replace")}, + {'r', QLatin1String("re_split")}, + {'r', QLatin1String("reflect")}, + {'r', QLatin1String("reflectlight")}, + {'r', QLatin1String("refract")}, + {'r', QLatin1String("refractlight")}, + {'r', QLatin1String("relativepath")}, + {'r', QLatin1String("relbbox")}, + {'r', QLatin1String("relpointbbox")}, + {'r', QLatin1String("removegroup")}, + {'r', QLatin1String("removeindex")}, + {'r', QLatin1String("removepoint")}, + {'r', QLatin1String("removeprim")}, + {'r', QLatin1String("removevalue")}, + {'r', QLatin1String("renderstate")}, + {'r', QLatin1String("reorder")}, + {'r', QLatin1String("resample_linear")}, + {'r', QLatin1String("resize")}, + {'r', QLatin1String("resolvemissedray")}, + {'r', QLatin1String("reverse")}, + {'r', QLatin1String("rgbtohsv")}, + {'r', QLatin1String("rgbtoxyz")}, + {'r', QLatin1String("rint")}, + {'r', QLatin1String("rotate")}, + {'r', QLatin1String("rotate_x_to")}, + {'r', QLatin1String("rstrip")}, + {'s', QLatin1String("sample_bsdf")}, + {'s', QLatin1String("sample_cauchy")}, + {'s', QLatin1String("sample_circle_arc")}, + {'s', QLatin1String("sample_circle_edge_uniform")}, + {'s', QLatin1String("sample_circle_slice")}, + {'s', QLatin1String("sample_circle_uniform")}, + {'s', QLatin1String("sample_direction_cone")}, + {'s', QLatin1String("sample_direction_uniform")}, + {'s', QLatin1String("sample_discrete")}, + {'s', QLatin1String("sample_exponential")}, + {'s', QLatin1String("sample_geometry")}, + {'s', QLatin1String("sample_hemisphere")}, + {'s', QLatin1String("sample_hypersphere_cone")}, + {'s', QLatin1String("sample_hypersphere_uniform")}, + {'s', QLatin1String("sample_light")}, + {'s', QLatin1String("sample_lognormal")}, + {'s', QLatin1String("sample_lognormal_by_median")}, + {'s', QLatin1String("sample_normal")}, + {'s', QLatin1String("sample_orientation_cone")}, + {'s', QLatin1String("sample_orientation_uniform")}, + {'s', QLatin1String("sample_photon")}, + {'s', QLatin1String("sample_sphere_cone")}, + {'s', QLatin1String("sample_sphere_uniform")}, + {'s', QLatin1String("sampledisk")}, + {'s', QLatin1String("scale")}, + {'s', QLatin1String("select")}, + {'s', QLatin1String("sensor_panorama_create")}, + {'s', QLatin1String("sensor_panorama_getcolor")}, + {'s', QLatin1String("sensor_panorama_getcone")}, + {'s', QLatin1String("sensor_panorama_getdepth")}, + {'s', QLatin1String("sensor_save")}, + {'s', QLatin1String("serialize")}, + {'s', QLatin1String("set")}, + {'s', QLatin1String("setagentclipnames")}, + {'s', QLatin1String("setagentcliptimes")}, + {'s', QLatin1String("setagentclipweights")}, + {'s', QLatin1String("setagentcollisionlayer")}, + {'s', QLatin1String("setagentcurrentlayer")}, + {'s', QLatin1String("setagentlocaltransform")}, + {'s', QLatin1String("setagentlocaltransforms")}, + {'s', QLatin1String("setagentworldtransform")}, + {'s', QLatin1String("setagentworldtransforms")}, + {'s', QLatin1String("setattrib")}, + {'s', QLatin1String("setattribtypeinfo")}, + {'s', QLatin1String("setcomp")}, + {'s', QLatin1String("setcurrentlight")}, + {'s', QLatin1String("setdetailattrib")}, + {'s', QLatin1String("setpointattrib")}, + {'s', QLatin1String("setpointgroup")}, + {'s', QLatin1String("setprimattrib")}, + {'s', QLatin1String("setprimgroup")}, + {'s', QLatin1String("setprimintrinsic")}, + {'s', QLatin1String("setprimvertex")}, + {'s', QLatin1String("setsamplestore")}, + {'s', QLatin1String("setvertexattrib")}, + {'s', QLatin1String("setvertexgroup")}, + {'s', QLatin1String("setvertexpoint")}, + {'s', QLatin1String("shadow")}, + {'s', QLatin1String("shadow_light")}, + {'s', QLatin1String("shadowmap")}, + {'s', QLatin1String("shimport")}, + {'s', QLatin1String("shl")}, + {'s', QLatin1String("shr")}, + {'s', QLatin1String("shrz")}, + {'s', QLatin1String("sign")}, + {'s', QLatin1String("simport")}, + {'s', QLatin1String("sin")}, + {'s', QLatin1String("sinh")}, + {'s', QLatin1String("sleep")}, + {'s', QLatin1String("slerp")}, + {'s', QLatin1String("slice")}, + {'s', QLatin1String("slideframe")}, + {'s', QLatin1String("smooth")}, + {'s', QLatin1String("smoothrotation")}, + {'s', QLatin1String("snoise")}, + {'s', QLatin1String("solvecubic")}, + {'s', QLatin1String("solvepoly")}, + {'s', QLatin1String("solvequadratic")}, + {'s', QLatin1String("sort")}, + {'s', QLatin1String("specular")}, + {'s', QLatin1String("specularBRDF")}, + {'s', QLatin1String("spline")}, + {'s', QLatin1String("split")}, + {'s', QLatin1String("splitpath")}, + {'s', QLatin1String("sprintf")}, + {'s', QLatin1String("sqrt")}, + {'s', QLatin1String("startswith")}, + {'s', QLatin1String("storelightexport")}, + {'s', QLatin1String("strip")}, + {'s', QLatin1String("strlen")}, + {'s', QLatin1String("sum")}, + {'s', QLatin1String("switch")}, + {'s', QLatin1String("swizzle")}, + {'t', QLatin1String("tan")}, + {'t', QLatin1String("tanh")}, + {'t', QLatin1String("tet_adjacent")}, + {'t', QLatin1String("tet_faceindex")}, + {'t', QLatin1String("teximport")}, + {'t', QLatin1String("texprintf")}, + {'t', QLatin1String("texture")}, + {'t', QLatin1String("texture3d")}, + {'t', QLatin1String("texture3dBox")}, + {'t', QLatin1String("titlecase")}, + {'t', QLatin1String("toNDC")}, + {'t', QLatin1String("tolower")}, + {'t', QLatin1String("toupper")}, + {'t', QLatin1String("trace")}, + {'t', QLatin1String("translate")}, + {'t', QLatin1String("translucent")}, + {'t', QLatin1String("transpose")}, + {'t', QLatin1String("trunc")}, + {'t', QLatin1String("tw_nspace")}, + {'t', QLatin1String("tw_space")}, + {'t', QLatin1String("tw_vspace")}, + {'u', QLatin1String("uniqueval")}, + {'u', QLatin1String("unpack_intfromsafefloat")}, + {'u', QLatin1String("unserialize")}, + {'u', QLatin1String("upush")}, + {'u', QLatin1String("uvunwrap")}, + {'v', QLatin1String("variance")}, + {'v', QLatin1String("velocityname")}, + {'v', QLatin1String("vertex")}, + {'v', QLatin1String("vertexattrib")}, + {'v', QLatin1String("vertexattribsize")}, + {'v', QLatin1String("vertexattribtype")}, + {'v', QLatin1String("vertexattribtypeinfo")}, + {'v', QLatin1String("vertexhedge")}, + {'v', QLatin1String("vertexindex")}, + {'v', QLatin1String("vertexnext")}, + {'v', QLatin1String("vertexpoint")}, + {'v', QLatin1String("vertexprev")}, + {'v', QLatin1String("vertexprim")}, + {'v', QLatin1String("vertexprimindex")}, + {'v', QLatin1String("vnoise")}, + {'v', QLatin1String("volume")}, + {'v', QLatin1String("volumegradient")}, + {'v', QLatin1String("volumeindex")}, + {'v', QLatin1String("volumeindexorigin")}, + {'v', QLatin1String("volumeindextopos")}, + {'v', QLatin1String("volumeindexv")}, + {'v', QLatin1String("volumepostoindex")}, + {'v', QLatin1String("volumeres")}, + {'v', QLatin1String("volumesample")}, + {'v', QLatin1String("volumesamplev")}, + {'v', QLatin1String("vtransform")}, + {'w', QLatin1String("warning")}, + {'w', QLatin1String("wireblinn")}, + {'w', QLatin1String("wirediffuse")}, + {'w', QLatin1String("wnoise")}, + {'w', QLatin1String("wo_nspace")}, + {'w', QLatin1String("wo_space")}, + {'w', QLatin1String("wo_vspace")}, + {'w', QLatin1String("writepixel")}, + {'w', QLatin1String("wt_nspace")}, + {'w', QLatin1String("wt_space")}, + {'w', QLatin1String("wt_vspace")}, + {'x', QLatin1String("xnoise")}, + {'x', QLatin1String("xnoised")}, + {'x', QLatin1String("xyzdist")}, + {'x', QLatin1String("xyztorgb")}}; + vex_other = { + {('d'), QLatin1String("define")}, {('e'), QLatin1String("else")}, + {('e'), QLatin1String("endif")}, {('i'), QLatin1String("if")}, + {('i'), QLatin1String("ifdef")}, {('i'), QLatin1String("ifndef")}, + {('i'), QLatin1String("include")}, {('p'), QLatin1String("pragma")}, + {('u'), QLatin1String("undef")}, + }; } -void loadVEXData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!vexDataInitialized) { - initVEXData(); - vexDataInitialized = true; - } - types = vex_types; - keywords = vex_keywords; - builtin = vex_builtin; - literals = vex_literals; - other = vex_other; +void loadVEXData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other) +{ + if (!vexDataInitialized) + { + initVEXData(); + vexDataInitialized = true; + } + types = vex_types; + keywords = vex_keywords; + builtin = vex_builtin; + literals = vex_literals; + other = vex_other; } /********************************************************/ @@ -3543,607 +3095,603 @@ static QMultiHash cmake_types; static QMultiHash cmake_literals; static QMultiHash cmake_builtin; static QMultiHash cmake_other; -void initCMakeData() { - cmake_keywords = { - {'b', QLatin1String("break")}, - {'c', QLatin1String("cmake_host_system_information")}, - {'c', QLatin1String("cmake_minimum_required")}, - {'c', QLatin1String("cmake_parse_arguments")}, - {'c', QLatin1String("cmake_policy")}, - {'c', QLatin1String("configure_file")}, - {'c', QLatin1String("continue")}, - {'e', QLatin1String("elseif")}, - {'e', QLatin1String("else")}, - {'e', QLatin1String("endforeach")}, - {'e', QLatin1String("endfunction")}, - {'e', QLatin1String("endif")}, - {'e', QLatin1String("endmacro")}, - {'e', QLatin1String("endwhile")}, - {'e', QLatin1String("execute_process")}, - {'f', QLatin1String("file")}, - {'f', QLatin1String("find_file")}, - {'f', QLatin1String("find_library")}, - {'f', QLatin1String("find_package")}, - {'f', QLatin1String("find_path")}, - {'f', QLatin1String("find_program")}, - {'f', QLatin1String("foreach")}, - {'f', QLatin1String("function")}, - {'g', QLatin1String("get_cmake_property")}, - {'g', QLatin1String("get_directory_property")}, - {'g', QLatin1String("get_filename_component")}, - {'g', QLatin1String("get_property")}, - {'i', QLatin1String("if")}, - {'i', QLatin1String("include")}, - {'i', QLatin1String("include_guard")}, - {'l', QLatin1String("list")}, - {'m', QLatin1String("macro")}, - {'m', QLatin1String("mark_as_advanced")}, - {'m', QLatin1String("math")}, - {'m', QLatin1String("message")}, - {'o', QLatin1String("option")}, - {'r', QLatin1String("return")}, - {'s', QLatin1String("separate_arguments")}, - {'s', QLatin1String("set_directory_properties")}, - {'s', QLatin1String("set")}, - {'s', QLatin1String("set_property")}, - {'s', QLatin1String("site_name")}, - {'s', QLatin1String("string")}, - {'u', QLatin1String("unset")}, - {'v', QLatin1String("variable_watch")}, - {'w', QLatin1String("while")}, - {'a', QLatin1String("add_compile_definitions")}, - {'a', QLatin1String("add_compile_options")}, - {'A', QLatin1String("ADD_COMPILE_OPTIONS")}, - {'a', QLatin1String("add_custom_command")}, - {'a', QLatin1String("add_custom_target")}, - {'a', QLatin1String("add_definitions")}, - {'a', QLatin1String("add_dependencies")}, - {'a', QLatin1String("add_executable")}, - {'a', QLatin1String("add_library")}, - {'a', QLatin1String("add_link_options")}, - {'a', QLatin1String("add_subdirectory")}, - {'a', QLatin1String("add_test")}, - {'a', QLatin1String("aux_source_directory")}, - {'b', QLatin1String("build_command")}, - {'c', QLatin1String("create_test_sourcelist")}, - {'d', QLatin1String("define_property")}, - {'e', QLatin1String("enable_language")}, - {'e', QLatin1String("enable_testing")}, - {'e', QLatin1String("export")}, - {'f', QLatin1String("fltk_wrap_ui")}, - {'g', QLatin1String("get_source_file_property")}, - {'g', QLatin1String("get_target_property")}, - {'g', QLatin1String("get_test_property")}, - {'i', QLatin1String("include_directories")}, - {'i', QLatin1String("include_external_msproject")}, - {'i', QLatin1String("include_regular_expression")}, - {'i', QLatin1String("install")}, - {'l', QLatin1String("link_directories")}, - {'l', QLatin1String("link_libraries")}, - {'l', QLatin1String("load_cache")}, - {'p', QLatin1String("project")}, - {'q', QLatin1String("qt_wrap_cpp")}, - {'q', QLatin1String("qt_wrap_ui")}, - {'r', QLatin1String("remove_definitions")}, - {'s', QLatin1String("set_source_files_properties")}, - {'s', QLatin1String("set_target_properties")}, - {'s', QLatin1String("set_tests_properties")}, - {'s', QLatin1String("source_group")}, - {'t', QLatin1String("target_compile_definitions")}, - {'t', QLatin1String("target_compile_features")}, - {'t', QLatin1String("target_compile_options")}, - {'t', QLatin1String("target_include_directories")}, - {'t', QLatin1String("target_link_directories")}, - {'t', QLatin1String("target_link_libraries")}, - {'t', QLatin1String("target_link_options")}, - {'t', QLatin1String("target_sources")}, - {'t', QLatin1String("try_compile")}, - {'t', QLatin1String("try_run")}, - {'c', QLatin1String("ctest_build")}, - {'c', QLatin1String("ctest_configure")}, - {'c', QLatin1String("ctest_coverage")}, - {'c', QLatin1String("ctest_empty_binary_directory")}, - {'c', QLatin1String("ctest_memcheck")}, - {'c', QLatin1String("ctest_read_custom_files")}, - {'c', QLatin1String("ctest_run_script")}, - {'c', QLatin1String("ctest_sleep")}, - {'c', QLatin1String("ctest_start")}, - {'c', QLatin1String("ctest_submit")}, - {'c', QLatin1String("ctest_test")}, - {'c', QLatin1String("ctest_update")}, - {'c', QLatin1String("ctest_upload")}, - {'b', QLatin1String("build_name")}, - {'e', QLatin1String("exec_program")}, - {'e', QLatin1String("export_library_dependencies")}, - {'i', QLatin1String("install_files")}, - {'i', QLatin1String("install_programs")}, - {'i', QLatin1String("install_targets")}, - {'l', QLatin1String("load_command")}, - {'m', QLatin1String("make_directory")}, - {'o', QLatin1String("output_required_files")}, - {'r', QLatin1String("remove")}, - {'s', QLatin1String("subdir_depends")}, - {'s', QLatin1String("subdirs")}, - {'u', QLatin1String("use_mangled_mesa")}, - {'u', QLatin1String("utility_source")}, - {'v', QLatin1String("variable_requires")}, - {'w', QLatin1String("write_file")}, - {'q', QLatin1String("qt5_use_modules")}, - {'q', QLatin1String("qt5_use_package")}, - {'q', QLatin1String("qt5_wrap_cpp")}, - {'a', QLatin1String("and")}, - {'o', QLatin1String("or")}, - {'n', QLatin1String("not")}, - {'c', QLatin1String("command")}, - {'p', QLatin1String("policy")}, - {'t', QLatin1String("target")}, - {'t', QLatin1String("test")}, - {'e', QLatin1String("exists")}, - {'i', QLatin1String("is_newer_than")}, - {'i', QLatin1String("is_directory")}, - {'i', QLatin1String("is_symlink")}, - {'i', QLatin1String("is_absolute")}, - {'m', QLatin1String("matches")}, - {'l', QLatin1String("less")}, - {'g', QLatin1String("greater")}, - {'e', QLatin1String("equal")}, - {'l', QLatin1String("less_equal")}, - {'g', QLatin1String("greater_equal")}, - {'s', QLatin1String("strless")}, - {'s', QLatin1String("strgreater")}, - {'s', QLatin1String("strequal")}, - {'s', QLatin1String("strless_equal")}, - {'s', QLatin1String("strgreater_equal")}, - {'v', QLatin1String("version_less")}, - {'v', QLatin1String("version_greater")}, - {'v', QLatin1String("version_equal")}, - {'v', QLatin1String("version_less_equal")}, - {'v', QLatin1String("version_greater_equal")}, - {'i', QLatin1String("in_list")}, - {'d', QLatin1String("defined")} - }; - cmake_types = {}; - cmake_literals = { - {'o', QLatin1String("on")}, - {'o', QLatin1String("off")}, - {'O', QLatin1String("ON")}, - {'O', QLatin1String("OFF")}, - {'t', QLatin1String("true")}, - {'f', QLatin1String("false")}, - {'T', QLatin1String("TRUE")}, - {'F', QLatin1String("FALSE")} - }; - cmake_builtin = { - {'A', QLatin1String("ALLOW_DUPLICATE_CUSTOM_TARGETS")}, - {'A', QLatin1String("AUTOGEN_TARGETS_FOLDER")}, - {'A', QLatin1String("AUTOMOC_TARGETS_FOLDER")}, - {'D', QLatin1String("DEBUG_CONFIGURATIONS")}, - {'D', QLatin1String("DISABLED_FEATURES")}, - {'E', QLatin1String("ENABLED_FEATURES")}, - {'E', QLatin1String("ENABLED_LANGUAGES")}, - {'F', QLatin1String("FIND_LIBRARY_USE_LIB64_PATHS")}, - {'F', QLatin1String("FIND_LIBRARY_USE_OPENBSD_VERSIONING")}, - {'G', QLatin1String("GLOBAL_DEPENDS_DEBUG_MODE")}, - {'G', QLatin1String("GLOBAL_DEPENDS_NO_CYCLES")}, - {'I', QLatin1String("IN_TRY_COMPILE")}, - {'P', QLatin1String("PACKAGES_FOUND")}, - {'P', QLatin1String("PACKAGES_NOT_FOUND")}, - {'J', QLatin1String("JOB_POOLS")}, - {'P', QLatin1String("PREDEFINED_TARGETS_FOLDER")}, - {'E', QLatin1String("ECLIPSE_EXTRA_NATURES")}, - {'R', QLatin1String("REPORT_UNDEFINED_PROPERTIES")}, - {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, - {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, - {'R', QLatin1String("RULE_LAUNCH_LINK")}, - {'R', QLatin1String("RULE_MESSAGES")}, - {'T', QLatin1String("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS")}, - {'T', QLatin1String("TARGET_SUPPORTS_SHARED_LIBS")}, - {'U', QLatin1String("USE_FOLDERS")}, - {'A', QLatin1String("ADDITIONAL_MAKE_CLEAN_FILES")}, - {'C', QLatin1String("CACHE_VARIABLES")}, - {'C', QLatin1String("CLEAN_NO_CUSTOM")}, - {'C', QLatin1String("CMAKE_CONFIGURE_DEPENDS")}, - {'C', QLatin1String("COMPILE_DEFINITIONS")}, - {'C', QLatin1String("COMPILE_OPTIONS")}, - {'D', QLatin1String("DEFINITIONS")}, - {'E', QLatin1String("EXCLUDE_FROM_ALL")}, - {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, - {'I', QLatin1String("INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INCLUDE_REGULAR_EXPRESSION")}, - {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, - {'L', QLatin1String("LINK_DIRECTORIES")}, - {'L', QLatin1String("LISTFILE_STACK")}, - {'M', QLatin1String("MACROS")}, - {'P', QLatin1String("PARENT_DIRECTORY")}, - {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, - {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, - {'R', QLatin1String("RULE_LAUNCH_LINK")}, - {'T', QLatin1String("TEST_INCLUDE_FILE")}, - {'V', QLatin1String("VARIABLES")}, - {'A', QLatin1String("ALIASED_TARGET")}, - {'A', QLatin1String("ARCHIVE_OUTPUT_DIRECTORY")}, - {'A', QLatin1String("ARCHIVE_OUTPUT_NAME")}, - {'A', QLatin1String("AUTOGEN_TARGET_DEPENDS")}, - {'A', QLatin1String("AUTOMOC_MOC_OPTIONS")}, - {'A', QLatin1String("AUTOMOC")}, - {'A', QLatin1String("AUTOUIC")}, - {'A', QLatin1String("AUTOUIC_OPTIONS")}, - {'A', QLatin1String("AUTORCC")}, - {'A', QLatin1String("AUTORCC_OPTIONS")}, - {'B', QLatin1String("BUILD_WITH_INSTALL_RPATH")}, - {'B', QLatin1String("BUNDLE_EXTENSION")}, - {'B', QLatin1String("BUNDLE")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_BOOL")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MAX")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MIN")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_STRING")}, - {'C', QLatin1String("COMPILE_DEFINITIONS")}, - {'C', QLatin1String("COMPILE_FLAGS")}, - {'C', QLatin1String("COMPILE_OPTIONS")}, - {'D', QLatin1String("DEBUG_POSTFIX")}, - {'D', QLatin1String("DEFINE_SYMBOL")}, - {'E', QLatin1String("EchoString")}, - {'E', QLatin1String("ENABLE_EXPORTS")}, - {'E', QLatin1String("EXCLUDE_FROM_ALL")}, - {'E', QLatin1String("EXCLUDE_FROM_DEFAULT_BUILD")}, - {'E', QLatin1String("EXPORT_NAME")}, - {'F', QLatin1String("FOLDER")}, - {'F', QLatin1String("Fortran_FORMAT")}, - {'F', QLatin1String("Fortran_MODULE_DIRECTORY")}, - {'F', QLatin1String("FRAMEWORK")}, - {'G', QLatin1String("GENERATOR_FILE_NAME")}, - {'G', QLatin1String("GNUtoMS")}, - {'H', QLatin1String("HAS_CXX")}, - {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, - {'I', QLatin1String("IMPORTED_CONFIGURATIONS")}, - {'I', QLatin1String("IMPORTED_IMPLIB")}, - {'I', QLatin1String("IMPORTED_LINK_DEPENDENT_LIBRARIES")}, - {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LANGUAGES")}, - {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LIBRARIES")}, - {'I', QLatin1String("IMPORTED_LINK_INTERFACE_MULTIPLICITY")}, - {'I', QLatin1String("IMPORTED_LOCATION")}, - {'I', QLatin1String("IMPORTED_NO_SONAME")}, - {'I', QLatin1String("IMPORTED")}, - {'I', QLatin1String("IMPORTED_SONAME")}, - {'I', QLatin1String("IMPORT_PREFIX")}, - {'I', QLatin1String("IMPORT_SUFFIX")}, - {'I', QLatin1String("INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INSTALL_NAME_DIR")}, - {'I', QLatin1String("INSTALL_RPATH")}, - {'I', QLatin1String("INSTALL_RPATH_USE_LINK_PATH")}, - {'I', QLatin1String("INTERFACE_AUTOUIC_OPTIONS")}, - {'I', QLatin1String("INTERFACE_COMPILE_DEFINITIONS")}, - {'I', QLatin1String("INTERFACE_COMPILE_OPTIONS")}, - {'I', QLatin1String("INTERFACE_INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INTERFACE_LINK_LIBRARIES")}, - {'I', QLatin1String("INTERFACE_POSITION_INDEPENDENT_CODE")}, - {'I', QLatin1String("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, - {'J', QLatin1String("JOB_POOL_COMPILE")}, - {'J', QLatin1String("JOB_POOL_LINK")}, - {'L', QLatin1String("LABELS")}, - {'L', QLatin1String("LIBRARY_OUTPUT_DIRECTORY")}, - {'L', QLatin1String("LIBRARY_OUTPUT_NAME")}, - {'L', QLatin1String("LINK_DEPENDS_NO_SHARED")}, - {'L', QLatin1String("LINK_DEPENDS")}, - {'L', QLatin1String("LINKER_LANGUAGE")}, - {'L', QLatin1String("LINK_FLAGS")}, - {'L', QLatin1String("LINK_INTERFACE_LIBRARIES")}, - {'L', QLatin1String("LINK_INTERFACE_MULTIPLICITY")}, - {'L', QLatin1String("LINK_LIBRARIES")}, - {'L', QLatin1String("LINK_SEARCH_END_STATIC")}, - {'L', QLatin1String("LINK_SEARCH_START_STATIC")}, - {'L', QLatin1String("LOCATION")}, - {'M', QLatin1String("MACOSX_BUNDLE_INFO_PLIST")}, - {'M', QLatin1String("MACOSX_BUNDLE")}, - {'M', QLatin1String("MACOSX_FRAMEWORK_INFO_PLIST")}, - {'M', QLatin1String("MACOSX_RPATH")}, -// {'N', QLatin1String("NAME")}, - {'N', QLatin1String("NO_SONAME")}, - {'N', QLatin1String("NO_SYSTEM_FROM_IMPORTED")}, - {'O', QLatin1String("OSX_ARCHITECTURES")}, - {'O', QLatin1String("OUTPUT_NAME")}, - {'P', QLatin1String("PDB_NAME")}, - {'P', QLatin1String("PDB_OUTPUT_DIRECTORY")}, - {'P', QLatin1String("POSITION_INDEPENDENT_CODE")}, - {'P', QLatin1String("POST_INSTALL_SCRIPT")}, - {'P', QLatin1String("PREFIX")}, - {'P', QLatin1String("PROPERTY")}, - {'P', QLatin1String("PRE_INSTALL_SCRIPT")}, - {'P', QLatin1String("PRIVATE_HEADER")}, - {'P', QLatin1String("PROJECT_LABEL")}, - {'P', QLatin1String("PUBLIC_HEADER")}, - {'R', QLatin1String("RESOURCE")}, - {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, - {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, - {'R', QLatin1String("RULE_LAUNCH_LINK")}, - {'R', QLatin1String("RUNTIME_OUTPUT_DIRECTORY")}, - {'R', QLatin1String("RUNTIME_OUTPUT_NAME")}, - {'S', QLatin1String("SKIP_BUILD_RPATH")}, - {'S', QLatin1String("SOURCES")}, - {'S', QLatin1String("SOVERSION")}, - {'S', QLatin1String("STATIC_LIBRARY_FLAGS")}, - {'S', QLatin1String("SUFFIX")}, - {'T', QLatin1String("TARGET")}, - {'T', QLatin1String("TYPE")}, - {'V', QLatin1String("VERSION")}, - {'V', QLatin1String("VISIBILITY_INLINES_HIDDEN")}, - {'V', QLatin1String("VS_DOTNET_REFERENCES")}, - {'V', QLatin1String("VS_DOTNET_TARGET_FRAMEWORK_VERSION")}, - {'V', QLatin1String("VS_GLOBAL_KEYWORD")}, - {'V', QLatin1String("VS_GLOBAL_PROJECT_TYPES")}, - {'V', QLatin1String("VS_GLOBAL_ROOTNAMESPACE")}, - {'V', QLatin1String("VS_KEYWORD")}, - {'V', QLatin1String("VS_SCC_AUXPATH")}, - {'V', QLatin1String("VS_SCC_LOCALPATH")}, - {'V', QLatin1String("VS_SCC_PROJECTNAME")}, - {'V', QLatin1String("VS_SCC_PROVIDER")}, - {'V', QLatin1String("VS_WINRT_EXTENSIONS")}, - {'V', QLatin1String("VS_WINRT_REFERENCES")}, - {'W', QLatin1String("WIN32_EXECUTABLE")}, - {'A', QLatin1String("ATTACHED_FILES_ON_FAIL")}, - {'A', QLatin1String("ATTACHED_FILES")}, - {'C', QLatin1String("COST")}, - {'D', QLatin1String("DEPENDS")}, - {'E', QLatin1String("ENVIRONMENT")}, - {'F', QLatin1String("FAIL_REGULAR_EXPRESSION")}, - {'L', QLatin1String("LABELS")}, - {'M', QLatin1String("MEASUREMENT")}, - {'P', QLatin1String("PASS_REGULAR_EXPRESSION")}, - {'P', QLatin1String("PROCESSORS")}, - {'R', QLatin1String("REQUIRED_FILES")}, - {'R', QLatin1String("RESOURCE_LOCK")}, - {'R', QLatin1String("RUN_SERIAL")}, - {'S', QLatin1String("SKIP_RETURN_CODE")}, - {'T', QLatin1String("TIMEOUT")}, - {'W', QLatin1String("WILL_FAIL")}, - {'W', QLatin1String("WORKING_DIRECTORY")}, - {'A', QLatin1String("ABSTRACT")}, - {'A', QLatin1String("AUTOUIC_OPTIONS")}, - {'A', QLatin1String("AUTORCC_OPTIONS")}, - {'C', QLatin1String("COMPILE_DEFINITIONS")}, - {'C', QLatin1String("COMPILE_FLAGS")}, - {'E', QLatin1String("EXTERNAL_OBJECT")}, - {'F', QLatin1String("Fortran_FORMAT")}, - {'G', QLatin1String("GENERATED")}, - {'H', QLatin1String("HEADER_FILE_ONLY")}, - {'K', QLatin1String("KEEP_EXTENSION")}, - {'L', QLatin1String("LABELS")}, -// {'L', QLatin1String("LANGUAGE")}, - {'L', QLatin1String("LOCATION")}, - {'M', QLatin1String("MACOSX_PACKAGE_LOCATION")}, - {'O', QLatin1String("OBJECT_DEPENDS")}, - {'O', QLatin1String("OBJECT_OUTPUTS")}, - {'S', QLatin1String("SYMBOLIC")}, - {'W', QLatin1String("WRAP_EXCLUDE")}, - {'A', QLatin1String("ADVANCED")}, - {'H', QLatin1String("HELPSTRING")}, - {'M', QLatin1String("MODIFIED")}, - {'S', QLatin1String("STRINGS")}, - {'T', QLatin1String("TYPE")}, - {'V', QLatin1String("VALUE")} - }; - cmake_other = { - {'C', QLatin1String("CMAKE_ARGC")}, - {'C', QLatin1String("CMAKE_ARGV0")}, - {'C', QLatin1String("CMAKE_AR")}, - {'C', QLatin1String("CMAKE_BINARY_DIR")}, - {'C', QLatin1String("CMAKE_BUILD_TOOL")}, - {'C', QLatin1String("CMAKE_CACHEFILE_DIR")}, - {'C', QLatin1String("CMAKE_CACHE_MAJOR_VERSION")}, - {'C', QLatin1String("CMAKE_CACHE_MINOR_VERSION")}, - {'C', QLatin1String("CMAKE_CACHE_PATCH_VERSION")}, - {'C', QLatin1String("CMAKE_CFG_INTDIR")}, - {'C', QLatin1String("CMAKE_COMMAND")}, - {'C', QLatin1String("CMAKE_CROSSCOMPILING")}, - {'C', QLatin1String("CMAKE_CTEST_COMMAND")}, - {'C', QLatin1String("CMAKE_CURRENT_BINARY_DIR")}, - {'C', QLatin1String("CMAKE_CURRENT_LIST_DIR")}, - {'C', QLatin1String("CMAKE_CURRENT_LIST_FILE")}, - {'C', QLatin1String("CMAKE_CURRENT_LIST_LINE")}, - {'C', QLatin1String("CMAKE_CURRENT_SOURCE_DIR")}, - {'C', QLatin1String("CMAKE_DL_LIBS")}, - {'C', QLatin1String("CMAKE_EDIT_COMMAND")}, - {'C', QLatin1String("CMAKE_EXECUTABLE_SUFFIX")}, - {'C', QLatin1String("CMAKE_EXTRA_GENERATOR")}, - {'C', QLatin1String("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")}, - {'C', QLatin1String("CMAKE_GENERATOR")}, - {'C', QLatin1String("CMAKE_GENERATOR_TOOLSET")}, - {'C', QLatin1String("CMAKE_HOME_DIRECTORY")}, - {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_PREFIX")}, - {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_JOB_POOL_COMPILE")}, - {'C', QLatin1String("CMAKE_JOB_POOL_LINK")}, - {'C', QLatin1String("CMAKE_LINK_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_MAJOR_VERSION")}, - {'C', QLatin1String("CMAKE_MAKE_PROGRAM")}, - {'C', QLatin1String("CMAKE_MINIMUM_REQUIRED_VERSION")}, - {'C', QLatin1String("CMAKE_MINOR_VERSION")}, - {'C', QLatin1String("CMAKE_PARENT_LIST_FILE")}, - {'C', QLatin1String("CMAKE_PATCH_VERSION")}, - {'C', QLatin1String("CMAKE_PROJECT_NAME")}, - {'C', QLatin1String("CMAKE_RANLIB")}, - {'C', QLatin1String("CMAKE_ROOT")}, - {'C', QLatin1String("CMAKE_SCRIPT_MODE_FILE")}, - {'C', QLatin1String("CMAKE_SHARED_LIBRARY_PREFIX")}, - {'C', QLatin1String("CMAKE_SHARED_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_SHARED_MODULE_PREFIX")}, - {'C', QLatin1String("CMAKE_SHARED_MODULE_SUFFIX")}, - {'C', QLatin1String("CMAKE_SIZEOF_VOID_P")}, - {'C', QLatin1String("CMAKE_SKIP_INSTALL_RULES")}, - {'C', QLatin1String("CMAKE_SKIP_RPATH")}, - {'C', QLatin1String("CMAKE_SOURCE_DIR")}, - {'C', QLatin1String("CMAKE_STANDARD_LIBRARIES")}, - {'C', QLatin1String("CMAKE_STATIC_LIBRARY_PREFIX")}, - {'C', QLatin1String("CMAKE_STATIC_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_TOOLCHAIN_FILE")}, - {'C', QLatin1String("CMAKE_TWEAK_VERSION")}, - {'C', QLatin1String("CMAKE_VERBOSE_MAKEFILE")}, - {'C', QLatin1String("CMAKE_VERSION")}, - {'C', QLatin1String("CMAKE_VS_DEVENV_COMMAND")}, - {'C', QLatin1String("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION")}, - {'C', QLatin1String("CMAKE_VS_MSBUILD_COMMAND")}, - {'C', QLatin1String("CMAKE_VS_MSDEV_COMMAND")}, - {'C', QLatin1String("CMAKE_VS_PLATFORM_TOOLSET")}, - {'C', QLatin1String("CMAKE_XCODE_PLATFORM_TOOLSET")}, - {'P', QLatin1String("PROJECT_BINARY_DIR")}, -// {'P', QLatin1String("PROJECT_NAME")}, - {'P', QLatin1String("PROJECT_SOURCE_DIR")}, - {'P', QLatin1String("PROJECT_VERSION")}, - {'P', QLatin1String("PROJECT_VERSION_MAJOR")}, - {'P', QLatin1String("PROJECT_VERSION_MINOR")}, - {'P', QLatin1String("PROJECT_VERSION_PATCH")}, - {'P', QLatin1String("PROJECT_VERSION_TWEAK")}, - {'B', QLatin1String("BUILD_SHARED_LIBS")}, - {'C', QLatin1String("CMAKE_ABSOLUTE_DESTINATION_FILES")}, - {'C', QLatin1String("CMAKE_APPBUNDLE_PATH")}, - {'C', QLatin1String("CMAKE_AUTOMOC_RELAXED_MODE")}, - {'C', QLatin1String("CMAKE_BACKWARDS_COMPATIBILITY")}, - {'C', QLatin1String("CMAKE_BUILD_TYPE")}, - {'C', QLatin1String("CMAKE_COLOR_MAKEFILE")}, - {'C', QLatin1String("CMAKE_CONFIGURATION_TYPES")}, - {'C', QLatin1String("CMAKE_DEBUG_TARGET_PROPERTIES")}, - {'C', QLatin1String("CMAKE_ERROR_DEPRECATED")}, - {'C', QLatin1String("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, - {'C', QLatin1String("CMAKE_SYSROOT")}, - {'C', QLatin1String("CMAKE_FIND_LIBRARY_PREFIXES")}, - {'C', QLatin1String("CMAKE_FIND_LIBRARY_SUFFIXES")}, - {'C', QLatin1String("CMAKE_FIND_NO_INSTALL_PREFIX")}, - {'C', QLatin1String("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_INCLUDE")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_LIBRARY")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PACKAGE")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PROGRAM")}, - {'C', QLatin1String("CMAKE_FRAMEWORK_PATH")}, - {'C', QLatin1String("CMAKE_IGNORE_PATH")}, - {'C', QLatin1String("CMAKE_INCLUDE_PATH")}, - {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_BEFORE")}, - {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")}, - {'C', QLatin1String("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")}, - {'C', QLatin1String("CMAKE_INSTALL_PREFIX")}, - {'C', QLatin1String("CMAKE_LIBRARY_PATH")}, - {'C', QLatin1String("CMAKE_MFC_FLAG")}, - {'C', QLatin1String("CMAKE_MODULE_PATH")}, - {'C', QLatin1String("CMAKE_NOT_USING_CONFIG_FLAGS")}, - {'C', QLatin1String("CMAKE_PREFIX_PATH")}, - {'C', QLatin1String("CMAKE_PROGRAM_PATH")}, - {'C', QLatin1String("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY")}, - {'C', QLatin1String("CMAKE_STAGING_PREFIX")}, - {'C', QLatin1String("CMAKE_SYSTEM_IGNORE_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_INCLUDE_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_LIBRARY_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_PREFIX_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_PROGRAM_PATH")}, - {'C', QLatin1String("CMAKE_USER_MAKE_RULES_OVERRIDE")}, - {'C', QLatin1String("CMAKE_WARN_DEPRECATED")}, - {'C', QLatin1String("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")}, - {'A', QLatin1String("APPLE")}, - {'B', QLatin1String("BORLAND")}, - {'C', QLatin1String("CMAKE_CL_64")}, - {'C', QLatin1String("CMAKE_COMPILER_2005")}, - {'C', QLatin1String("CMAKE_HOST_APPLE")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM_NAME")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM_PROCESSOR")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM_VERSION")}, - {'C', QLatin1String("CMAKE_HOST_UNIX")}, - {'C', QLatin1String("CMAKE_HOST_WIN32")}, - {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE_REGEX")}, - {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE")}, - {'C', QLatin1String("CMAKE_OBJECT_PATH_MAX")}, - {'C', QLatin1String("CMAKE_SYSTEM_NAME")}, - {'C', QLatin1String("CMAKE_SYSTEM_PROCESSOR")}, - {'C', QLatin1String("CMAKE_SYSTEM")}, - {'C', QLatin1String("CMAKE_SYSTEM_VERSION")}, - {'C', QLatin1String("CYGWIN")}, - {'E', QLatin1String("ENV")}, - {'M', QLatin1String("MSVC10")}, - {'M', QLatin1String("MSVC11")}, - {'M', QLatin1String("MSVC12")}, - {'M', QLatin1String("MSVC60")}, - {'M', QLatin1String("MSVC70")}, - {'M', QLatin1String("MSVC71")}, - {'M', QLatin1String("MSVC80")}, - {'M', QLatin1String("MSVC90")}, - {'M', QLatin1String("MSVC_IDE")}, - {'M', QLatin1String("MSVC")}, - {'M', QLatin1String("MSVC_VERSION")}, - {'U', QLatin1String("UNIX")}, - {'W', QLatin1String("WIN32")}, - {'X', QLatin1String("XCODE_VERSION")}, - {'C', QLatin1String("CMAKE_ARCHIVE_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_AUTOMOC_MOC_OPTIONS")}, - {'C', QLatin1String("CMAKE_AUTOMOC")}, - {'C', QLatin1String("CMAKE_AUTORCC")}, - {'C', QLatin1String("CMAKE_AUTORCC_OPTIONS")}, - {'C', QLatin1String("CMAKE_AUTOUIC")}, - {'C', QLatin1String("CMAKE_AUTOUIC_OPTIONS")}, - {'C', QLatin1String("CMAKE_BUILD_WITH_INSTALL_RPATH")}, - {'C', QLatin1String("CMAKE_DEBUG_POSTFIX")}, - {'C', QLatin1String("CMAKE_EXE_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_Fortran_FORMAT")}, - {'C', QLatin1String("CMAKE_Fortran_MODULE_DIRECTORY")}, - {'C', QLatin1String("CMAKE_GNUtoMS")}, - {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")}, - {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR")}, - {'C', QLatin1String("CMAKE_INSTALL_NAME_DIR")}, - {'C', QLatin1String("CMAKE_INSTALL_RPATH")}, - {'C', QLatin1String("CMAKE_INSTALL_RPATH_USE_LINK_PATH")}, - {'C', QLatin1String("CMAKE_LIBRARY_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_LIBRARY_PATH_FLAG")}, - {'C', QLatin1String("CMAKE_LINK_DEF_FILE_FLAG")}, - {'C', QLatin1String("CMAKE_LINK_DEPENDS_NO_SHARED")}, - {'C', QLatin1String("CMAKE_LINK_INTERFACE_LIBRARIES")}, - {'C', QLatin1String("CMAKE_LINK_LIBRARY_FILE_FLAG")}, - {'C', QLatin1String("CMAKE_LINK_LIBRARY_FLAG")}, - {'C', QLatin1String("CMAKE_MACOSX_BUNDLE")}, - {'C', QLatin1String("CMAKE_MACOSX_RPATH")}, - {'C', QLatin1String("CMAKE_MODULE_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_NO_BUILTIN_CHRPATH")}, - {'C', QLatin1String("CMAKE_NO_SYSTEM_FROM_IMPORTED")}, - {'C', QLatin1String("CMAKE_OSX_ARCHITECTURES")}, - {'C', QLatin1String("CMAKE_OSX_DEPLOYMENT_TARGET")}, - {'C', QLatin1String("CMAKE_OSX_SYSROOT")}, - {'C', QLatin1String("CMAKE_PDB_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_POSITION_INDEPENDENT_CODE")}, - {'C', QLatin1String("CMAKE_RUNTIME_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_SHARED_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_SKIP_BUILD_RPATH")}, - {'C', QLatin1String("CMAKE_SKIP_INSTALL_RPATH")}, - {'C', QLatin1String("CMAKE_STATIC_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_TRY_COMPILE_CONFIGURATION")}, - {'C', QLatin1String("CMAKE_USE_RELATIVE_PATHS")}, - {'C', QLatin1String("CMAKE_VISIBILITY_INLINES_HIDDEN")}, - {'C', QLatin1String("CMAKE_WIN32_EXECUTABLE")}, - {'E', QLatin1String("EXECUTABLE_OUTPUT_PATH")}, - {'L', QLatin1String("LIBRARY_OUTPUT_PATH")}, - {'C', QLatin1String("CMAKE_Fortran_MODDIR_DEFAULT")}, - {'C', QLatin1String("CMAKE_Fortran_MODDIR_FLAG")}, - {'C', QLatin1String("CMAKE_Fortran_MODOUT_FLAG")}, - {'C', QLatin1String("CMAKE_INTERNAL_PLATFORM_ABI")}, - {'C', QLatin1String("CPACK_ABSOLUTE_DESTINATION_FILES")}, - {'C', QLatin1String("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")}, - {'C', QLatin1String("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, - {'C', QLatin1String("CPACK_INCLUDE_TOPLEVEL_DIRECTORY")}, - {'C', QLatin1String("CPACK_INSTALL_SCRIPT")}, - {'C', QLatin1String("CPACK_PACKAGING_INSTALL_PREFIX")}, - {'C', QLatin1String("CPACK_SET_DESTDIR")}, - {'C', QLatin1String("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")} - }; +void initCMakeData() +{ + cmake_keywords = {{'b', QLatin1String("break")}, + {'c', QLatin1String("cmake_host_system_information")}, + {'c', QLatin1String("cmake_minimum_required")}, + {'c', QLatin1String("cmake_parse_arguments")}, + {'c', QLatin1String("cmake_policy")}, + {'c', QLatin1String("configure_file")}, + {'c', QLatin1String("continue")}, + {'e', QLatin1String("elseif")}, + {'e', QLatin1String("else")}, + {'e', QLatin1String("endforeach")}, + {'e', QLatin1String("endfunction")}, + {'e', QLatin1String("endif")}, + {'e', QLatin1String("endmacro")}, + {'e', QLatin1String("endwhile")}, + {'e', QLatin1String("execute_process")}, + {'f', QLatin1String("file")}, + {'f', QLatin1String("find_file")}, + {'f', QLatin1String("find_library")}, + {'f', QLatin1String("find_package")}, + {'f', QLatin1String("find_path")}, + {'f', QLatin1String("find_program")}, + {'f', QLatin1String("foreach")}, + {'f', QLatin1String("function")}, + {'g', QLatin1String("get_cmake_property")}, + {'g', QLatin1String("get_directory_property")}, + {'g', QLatin1String("get_filename_component")}, + {'g', QLatin1String("get_property")}, + {'i', QLatin1String("if")}, + {'i', QLatin1String("include")}, + {'i', QLatin1String("include_guard")}, + {'l', QLatin1String("list")}, + {'m', QLatin1String("macro")}, + {'m', QLatin1String("mark_as_advanced")}, + {'m', QLatin1String("math")}, + {'m', QLatin1String("message")}, + {'o', QLatin1String("option")}, + {'r', QLatin1String("return")}, + {'s', QLatin1String("separate_arguments")}, + {'s', QLatin1String("set_directory_properties")}, + {'s', QLatin1String("set")}, + {'s', QLatin1String("set_property")}, + {'s', QLatin1String("site_name")}, + {'s', QLatin1String("string")}, + {'u', QLatin1String("unset")}, + {'v', QLatin1String("variable_watch")}, + {'w', QLatin1String("while")}, + {'a', QLatin1String("add_compile_definitions")}, + {'a', QLatin1String("add_compile_options")}, + {'A', QLatin1String("ADD_COMPILE_OPTIONS")}, + {'a', QLatin1String("add_custom_command")}, + {'a', QLatin1String("add_custom_target")}, + {'a', QLatin1String("add_definitions")}, + {'a', QLatin1String("add_dependencies")}, + {'a', QLatin1String("add_executable")}, + {'a', QLatin1String("add_library")}, + {'a', QLatin1String("add_link_options")}, + {'a', QLatin1String("add_subdirectory")}, + {'a', QLatin1String("add_test")}, + {'a', QLatin1String("aux_source_directory")}, + {'b', QLatin1String("build_command")}, + {'c', QLatin1String("create_test_sourcelist")}, + {'d', QLatin1String("define_property")}, + {'e', QLatin1String("enable_language")}, + {'e', QLatin1String("enable_testing")}, + {'e', QLatin1String("export")}, + {'f', QLatin1String("fltk_wrap_ui")}, + {'g', QLatin1String("get_source_file_property")}, + {'g', QLatin1String("get_target_property")}, + {'g', QLatin1String("get_test_property")}, + {'i', QLatin1String("include_directories")}, + {'i', QLatin1String("include_external_msproject")}, + {'i', QLatin1String("include_regular_expression")}, + {'i', QLatin1String("install")}, + {'l', QLatin1String("link_directories")}, + {'l', QLatin1String("link_libraries")}, + {'l', QLatin1String("load_cache")}, + {'p', QLatin1String("project")}, + {'q', QLatin1String("qt_wrap_cpp")}, + {'q', QLatin1String("qt_wrap_ui")}, + {'r', QLatin1String("remove_definitions")}, + {'s', QLatin1String("set_source_files_properties")}, + {'s', QLatin1String("set_target_properties")}, + {'s', QLatin1String("set_tests_properties")}, + {'s', QLatin1String("source_group")}, + {'t', QLatin1String("target_compile_definitions")}, + {'t', QLatin1String("target_compile_features")}, + {'t', QLatin1String("target_compile_options")}, + {'t', QLatin1String("target_include_directories")}, + {'t', QLatin1String("target_link_directories")}, + {'t', QLatin1String("target_link_libraries")}, + {'t', QLatin1String("target_link_options")}, + {'t', QLatin1String("target_sources")}, + {'t', QLatin1String("try_compile")}, + {'t', QLatin1String("try_run")}, + {'c', QLatin1String("ctest_build")}, + {'c', QLatin1String("ctest_configure")}, + {'c', QLatin1String("ctest_coverage")}, + {'c', QLatin1String("ctest_empty_binary_directory")}, + {'c', QLatin1String("ctest_memcheck")}, + {'c', QLatin1String("ctest_read_custom_files")}, + {'c', QLatin1String("ctest_run_script")}, + {'c', QLatin1String("ctest_sleep")}, + {'c', QLatin1String("ctest_start")}, + {'c', QLatin1String("ctest_submit")}, + {'c', QLatin1String("ctest_test")}, + {'c', QLatin1String("ctest_update")}, + {'c', QLatin1String("ctest_upload")}, + {'b', QLatin1String("build_name")}, + {'e', QLatin1String("exec_program")}, + {'e', QLatin1String("export_library_dependencies")}, + {'i', QLatin1String("install_files")}, + {'i', QLatin1String("install_programs")}, + {'i', QLatin1String("install_targets")}, + {'l', QLatin1String("load_command")}, + {'m', QLatin1String("make_directory")}, + {'o', QLatin1String("output_required_files")}, + {'r', QLatin1String("remove")}, + {'s', QLatin1String("subdir_depends")}, + {'s', QLatin1String("subdirs")}, + {'u', QLatin1String("use_mangled_mesa")}, + {'u', QLatin1String("utility_source")}, + {'v', QLatin1String("variable_requires")}, + {'w', QLatin1String("write_file")}, + {'q', QLatin1String("qt5_use_modules")}, + {'q', QLatin1String("qt5_use_package")}, + {'q', QLatin1String("qt5_wrap_cpp")}, + {'a', QLatin1String("and")}, + {'o', QLatin1String("or")}, + {'n', QLatin1String("not")}, + {'c', QLatin1String("command")}, + {'p', QLatin1String("policy")}, + {'t', QLatin1String("target")}, + {'t', QLatin1String("test")}, + {'e', QLatin1String("exists")}, + {'i', QLatin1String("is_newer_than")}, + {'i', QLatin1String("is_directory")}, + {'i', QLatin1String("is_symlink")}, + {'i', QLatin1String("is_absolute")}, + {'m', QLatin1String("matches")}, + {'l', QLatin1String("less")}, + {'g', QLatin1String("greater")}, + {'e', QLatin1String("equal")}, + {'l', QLatin1String("less_equal")}, + {'g', QLatin1String("greater_equal")}, + {'s', QLatin1String("strless")}, + {'s', QLatin1String("strgreater")}, + {'s', QLatin1String("strequal")}, + {'s', QLatin1String("strless_equal")}, + {'s', QLatin1String("strgreater_equal")}, + {'v', QLatin1String("version_less")}, + {'v', QLatin1String("version_greater")}, + {'v', QLatin1String("version_equal")}, + {'v', QLatin1String("version_less_equal")}, + {'v', QLatin1String("version_greater_equal")}, + {'i', QLatin1String("in_list")}, + {'d', QLatin1String("defined")}}; + cmake_types = {}; + cmake_literals + = {{'o', QLatin1String("on")}, {'o', QLatin1String("off")}, + {'O', QLatin1String("ON")}, {'O', QLatin1String("OFF")}, + {'t', QLatin1String("true")}, {'f', QLatin1String("false")}, + {'T', QLatin1String("TRUE")}, {'F', QLatin1String("FALSE")}}; + cmake_builtin = {{'A', QLatin1String("ALLOW_DUPLICATE_CUSTOM_TARGETS")}, + {'A', QLatin1String("AUTOGEN_TARGETS_FOLDER")}, + {'A', QLatin1String("AUTOMOC_TARGETS_FOLDER")}, + {'D', QLatin1String("DEBUG_CONFIGURATIONS")}, + {'D', QLatin1String("DISABLED_FEATURES")}, + {'E', QLatin1String("ENABLED_FEATURES")}, + {'E', QLatin1String("ENABLED_LANGUAGES")}, + {'F', QLatin1String("FIND_LIBRARY_USE_LIB64_PATHS")}, + {'F', QLatin1String("FIND_LIBRARY_USE_OPENBSD_VERSIONING")}, + {'G', QLatin1String("GLOBAL_DEPENDS_DEBUG_MODE")}, + {'G', QLatin1String("GLOBAL_DEPENDS_NO_CYCLES")}, + {'I', QLatin1String("IN_TRY_COMPILE")}, + {'P', QLatin1String("PACKAGES_FOUND")}, + {'P', QLatin1String("PACKAGES_NOT_FOUND")}, + {'J', QLatin1String("JOB_POOLS")}, + {'P', QLatin1String("PREDEFINED_TARGETS_FOLDER")}, + {'E', QLatin1String("ECLIPSE_EXTRA_NATURES")}, + {'R', QLatin1String("REPORT_UNDEFINED_PROPERTIES")}, + {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, + {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, + {'R', QLatin1String("RULE_LAUNCH_LINK")}, + {'R', QLatin1String("RULE_MESSAGES")}, + {'T', QLatin1String("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS")}, + {'T', QLatin1String("TARGET_SUPPORTS_SHARED_LIBS")}, + {'U', QLatin1String("USE_FOLDERS")}, + {'A', QLatin1String("ADDITIONAL_MAKE_CLEAN_FILES")}, + {'C', QLatin1String("CACHE_VARIABLES")}, + {'C', QLatin1String("CLEAN_NO_CUSTOM")}, + {'C', QLatin1String("CMAKE_CONFIGURE_DEPENDS")}, + {'C', QLatin1String("COMPILE_DEFINITIONS")}, + {'C', QLatin1String("COMPILE_OPTIONS")}, + {'D', QLatin1String("DEFINITIONS")}, + {'E', QLatin1String("EXCLUDE_FROM_ALL")}, + {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, + {'I', QLatin1String("INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INCLUDE_REGULAR_EXPRESSION")}, + {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, + {'L', QLatin1String("LINK_DIRECTORIES")}, + {'L', QLatin1String("LISTFILE_STACK")}, + {'M', QLatin1String("MACROS")}, + {'P', QLatin1String("PARENT_DIRECTORY")}, + {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, + {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, + {'R', QLatin1String("RULE_LAUNCH_LINK")}, + {'T', QLatin1String("TEST_INCLUDE_FILE")}, + {'V', QLatin1String("VARIABLES")}, + {'A', QLatin1String("ALIASED_TARGET")}, + {'A', QLatin1String("ARCHIVE_OUTPUT_DIRECTORY")}, + {'A', QLatin1String("ARCHIVE_OUTPUT_NAME")}, + {'A', QLatin1String("AUTOGEN_TARGET_DEPENDS")}, + {'A', QLatin1String("AUTOMOC_MOC_OPTIONS")}, + {'A', QLatin1String("AUTOMOC")}, + {'A', QLatin1String("AUTOUIC")}, + {'A', QLatin1String("AUTOUIC_OPTIONS")}, + {'A', QLatin1String("AUTORCC")}, + {'A', QLatin1String("AUTORCC_OPTIONS")}, + {'B', QLatin1String("BUILD_WITH_INSTALL_RPATH")}, + {'B', QLatin1String("BUNDLE_EXTENSION")}, + {'B', QLatin1String("BUNDLE")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_BOOL")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MAX")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MIN")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_STRING")}, + {'C', QLatin1String("COMPILE_DEFINITIONS")}, + {'C', QLatin1String("COMPILE_FLAGS")}, + {'C', QLatin1String("COMPILE_OPTIONS")}, + {'D', QLatin1String("DEBUG_POSTFIX")}, + {'D', QLatin1String("DEFINE_SYMBOL")}, + {'E', QLatin1String("EchoString")}, + {'E', QLatin1String("ENABLE_EXPORTS")}, + {'E', QLatin1String("EXCLUDE_FROM_ALL")}, + {'E', QLatin1String("EXCLUDE_FROM_DEFAULT_BUILD")}, + {'E', QLatin1String("EXPORT_NAME")}, + {'F', QLatin1String("FOLDER")}, + {'F', QLatin1String("Fortran_FORMAT")}, + {'F', QLatin1String("Fortran_MODULE_DIRECTORY")}, + {'F', QLatin1String("FRAMEWORK")}, + {'G', QLatin1String("GENERATOR_FILE_NAME")}, + {'G', QLatin1String("GNUtoMS")}, + {'H', QLatin1String("HAS_CXX")}, + {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, + {'I', QLatin1String("IMPORTED_CONFIGURATIONS")}, + {'I', QLatin1String("IMPORTED_IMPLIB")}, + {'I', QLatin1String("IMPORTED_LINK_DEPENDENT_LIBRARIES")}, + {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LANGUAGES")}, + {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LIBRARIES")}, + {'I', QLatin1String("IMPORTED_LINK_INTERFACE_MULTIPLICITY")}, + {'I', QLatin1String("IMPORTED_LOCATION")}, + {'I', QLatin1String("IMPORTED_NO_SONAME")}, + {'I', QLatin1String("IMPORTED")}, + {'I', QLatin1String("IMPORTED_SONAME")}, + {'I', QLatin1String("IMPORT_PREFIX")}, + {'I', QLatin1String("IMPORT_SUFFIX")}, + {'I', QLatin1String("INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INSTALL_NAME_DIR")}, + {'I', QLatin1String("INSTALL_RPATH")}, + {'I', QLatin1String("INSTALL_RPATH_USE_LINK_PATH")}, + {'I', QLatin1String("INTERFACE_AUTOUIC_OPTIONS")}, + {'I', QLatin1String("INTERFACE_COMPILE_DEFINITIONS")}, + {'I', QLatin1String("INTERFACE_COMPILE_OPTIONS")}, + {'I', QLatin1String("INTERFACE_INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INTERFACE_LINK_LIBRARIES")}, + {'I', QLatin1String("INTERFACE_POSITION_INDEPENDENT_CODE")}, + {'I', QLatin1String("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, + {'J', QLatin1String("JOB_POOL_COMPILE")}, + {'J', QLatin1String("JOB_POOL_LINK")}, + {'L', QLatin1String("LABELS")}, + {'L', QLatin1String("LIBRARY_OUTPUT_DIRECTORY")}, + {'L', QLatin1String("LIBRARY_OUTPUT_NAME")}, + {'L', QLatin1String("LINK_DEPENDS_NO_SHARED")}, + {'L', QLatin1String("LINK_DEPENDS")}, + {'L', QLatin1String("LINKER_LANGUAGE")}, + {'L', QLatin1String("LINK_FLAGS")}, + {'L', QLatin1String("LINK_INTERFACE_LIBRARIES")}, + {'L', QLatin1String("LINK_INTERFACE_MULTIPLICITY")}, + {'L', QLatin1String("LINK_LIBRARIES")}, + {'L', QLatin1String("LINK_SEARCH_END_STATIC")}, + {'L', QLatin1String("LINK_SEARCH_START_STATIC")}, + {'L', QLatin1String("LOCATION")}, + {'M', QLatin1String("MACOSX_BUNDLE_INFO_PLIST")}, + {'M', QLatin1String("MACOSX_BUNDLE")}, + {'M', QLatin1String("MACOSX_FRAMEWORK_INFO_PLIST")}, + {'M', QLatin1String("MACOSX_RPATH")}, + // {'N', QLatin1String("NAME")}, + {'N', QLatin1String("NO_SONAME")}, + {'N', QLatin1String("NO_SYSTEM_FROM_IMPORTED")}, + {'O', QLatin1String("OSX_ARCHITECTURES")}, + {'O', QLatin1String("OUTPUT_NAME")}, + {'P', QLatin1String("PDB_NAME")}, + {'P', QLatin1String("PDB_OUTPUT_DIRECTORY")}, + {'P', QLatin1String("POSITION_INDEPENDENT_CODE")}, + {'P', QLatin1String("POST_INSTALL_SCRIPT")}, + {'P', QLatin1String("PREFIX")}, + {'P', QLatin1String("PROPERTY")}, + {'P', QLatin1String("PRE_INSTALL_SCRIPT")}, + {'P', QLatin1String("PRIVATE_HEADER")}, + {'P', QLatin1String("PROJECT_LABEL")}, + {'P', QLatin1String("PUBLIC_HEADER")}, + {'R', QLatin1String("RESOURCE")}, + {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, + {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, + {'R', QLatin1String("RULE_LAUNCH_LINK")}, + {'R', QLatin1String("RUNTIME_OUTPUT_DIRECTORY")}, + {'R', QLatin1String("RUNTIME_OUTPUT_NAME")}, + {'S', QLatin1String("SKIP_BUILD_RPATH")}, + {'S', QLatin1String("SOURCES")}, + {'S', QLatin1String("SOVERSION")}, + {'S', QLatin1String("STATIC_LIBRARY_FLAGS")}, + {'S', QLatin1String("SUFFIX")}, + {'T', QLatin1String("TARGET")}, + {'T', QLatin1String("TYPE")}, + {'V', QLatin1String("VERSION")}, + {'V', QLatin1String("VISIBILITY_INLINES_HIDDEN")}, + {'V', QLatin1String("VS_DOTNET_REFERENCES")}, + {'V', QLatin1String("VS_DOTNET_TARGET_FRAMEWORK_VERSION")}, + {'V', QLatin1String("VS_GLOBAL_KEYWORD")}, + {'V', QLatin1String("VS_GLOBAL_PROJECT_TYPES")}, + {'V', QLatin1String("VS_GLOBAL_ROOTNAMESPACE")}, + {'V', QLatin1String("VS_KEYWORD")}, + {'V', QLatin1String("VS_SCC_AUXPATH")}, + {'V', QLatin1String("VS_SCC_LOCALPATH")}, + {'V', QLatin1String("VS_SCC_PROJECTNAME")}, + {'V', QLatin1String("VS_SCC_PROVIDER")}, + {'V', QLatin1String("VS_WINRT_EXTENSIONS")}, + {'V', QLatin1String("VS_WINRT_REFERENCES")}, + {'W', QLatin1String("WIN32_EXECUTABLE")}, + {'A', QLatin1String("ATTACHED_FILES_ON_FAIL")}, + {'A', QLatin1String("ATTACHED_FILES")}, + {'C', QLatin1String("COST")}, + {'D', QLatin1String("DEPENDS")}, + {'E', QLatin1String("ENVIRONMENT")}, + {'F', QLatin1String("FAIL_REGULAR_EXPRESSION")}, + {'L', QLatin1String("LABELS")}, + {'M', QLatin1String("MEASUREMENT")}, + {'P', QLatin1String("PASS_REGULAR_EXPRESSION")}, + {'P', QLatin1String("PROCESSORS")}, + {'R', QLatin1String("REQUIRED_FILES")}, + {'R', QLatin1String("RESOURCE_LOCK")}, + {'R', QLatin1String("RUN_SERIAL")}, + {'S', QLatin1String("SKIP_RETURN_CODE")}, + {'T', QLatin1String("TIMEOUT")}, + {'W', QLatin1String("WILL_FAIL")}, + {'W', QLatin1String("WORKING_DIRECTORY")}, + {'A', QLatin1String("ABSTRACT")}, + {'A', QLatin1String("AUTOUIC_OPTIONS")}, + {'A', QLatin1String("AUTORCC_OPTIONS")}, + {'C', QLatin1String("COMPILE_DEFINITIONS")}, + {'C', QLatin1String("COMPILE_FLAGS")}, + {'E', QLatin1String("EXTERNAL_OBJECT")}, + {'F', QLatin1String("Fortran_FORMAT")}, + {'G', QLatin1String("GENERATED")}, + {'H', QLatin1String("HEADER_FILE_ONLY")}, + {'K', QLatin1String("KEEP_EXTENSION")}, + {'L', QLatin1String("LABELS")}, + // {'L', QLatin1String("LANGUAGE")}, + {'L', QLatin1String("LOCATION")}, + {'M', QLatin1String("MACOSX_PACKAGE_LOCATION")}, + {'O', QLatin1String("OBJECT_DEPENDS")}, + {'O', QLatin1String("OBJECT_OUTPUTS")}, + {'S', QLatin1String("SYMBOLIC")}, + {'W', QLatin1String("WRAP_EXCLUDE")}, + {'A', QLatin1String("ADVANCED")}, + {'H', QLatin1String("HELPSTRING")}, + {'M', QLatin1String("MODIFIED")}, + {'S', QLatin1String("STRINGS")}, + {'T', QLatin1String("TYPE")}, + {'V', QLatin1String("VALUE")}}; + cmake_other + = {{'C', QLatin1String("CMAKE_ARGC")}, + {'C', QLatin1String("CMAKE_ARGV0")}, + {'C', QLatin1String("CMAKE_AR")}, + {'C', QLatin1String("CMAKE_BINARY_DIR")}, + {'C', QLatin1String("CMAKE_BUILD_TOOL")}, + {'C', QLatin1String("CMAKE_CACHEFILE_DIR")}, + {'C', QLatin1String("CMAKE_CACHE_MAJOR_VERSION")}, + {'C', QLatin1String("CMAKE_CACHE_MINOR_VERSION")}, + {'C', QLatin1String("CMAKE_CACHE_PATCH_VERSION")}, + {'C', QLatin1String("CMAKE_CFG_INTDIR")}, + {'C', QLatin1String("CMAKE_COMMAND")}, + {'C', QLatin1String("CMAKE_CROSSCOMPILING")}, + {'C', QLatin1String("CMAKE_CTEST_COMMAND")}, + {'C', QLatin1String("CMAKE_CURRENT_BINARY_DIR")}, + {'C', QLatin1String("CMAKE_CURRENT_LIST_DIR")}, + {'C', QLatin1String("CMAKE_CURRENT_LIST_FILE")}, + {'C', QLatin1String("CMAKE_CURRENT_LIST_LINE")}, + {'C', QLatin1String("CMAKE_CURRENT_SOURCE_DIR")}, + {'C', QLatin1String("CMAKE_DL_LIBS")}, + {'C', QLatin1String("CMAKE_EDIT_COMMAND")}, + {'C', QLatin1String("CMAKE_EXECUTABLE_SUFFIX")}, + {'C', QLatin1String("CMAKE_EXTRA_GENERATOR")}, + {'C', QLatin1String("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")}, + {'C', QLatin1String("CMAKE_GENERATOR")}, + {'C', QLatin1String("CMAKE_GENERATOR_TOOLSET")}, + {'C', QLatin1String("CMAKE_HOME_DIRECTORY")}, + {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_PREFIX")}, + {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_JOB_POOL_COMPILE")}, + {'C', QLatin1String("CMAKE_JOB_POOL_LINK")}, + {'C', QLatin1String("CMAKE_LINK_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_MAJOR_VERSION")}, + {'C', QLatin1String("CMAKE_MAKE_PROGRAM")}, + {'C', QLatin1String("CMAKE_MINIMUM_REQUIRED_VERSION")}, + {'C', QLatin1String("CMAKE_MINOR_VERSION")}, + {'C', QLatin1String("CMAKE_PARENT_LIST_FILE")}, + {'C', QLatin1String("CMAKE_PATCH_VERSION")}, + {'C', QLatin1String("CMAKE_PROJECT_NAME")}, + {'C', QLatin1String("CMAKE_RANLIB")}, + {'C', QLatin1String("CMAKE_ROOT")}, + {'C', QLatin1String("CMAKE_SCRIPT_MODE_FILE")}, + {'C', QLatin1String("CMAKE_SHARED_LIBRARY_PREFIX")}, + {'C', QLatin1String("CMAKE_SHARED_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_SHARED_MODULE_PREFIX")}, + {'C', QLatin1String("CMAKE_SHARED_MODULE_SUFFIX")}, + {'C', QLatin1String("CMAKE_SIZEOF_VOID_P")}, + {'C', QLatin1String("CMAKE_SKIP_INSTALL_RULES")}, + {'C', QLatin1String("CMAKE_SKIP_RPATH")}, + {'C', QLatin1String("CMAKE_SOURCE_DIR")}, + {'C', QLatin1String("CMAKE_STANDARD_LIBRARIES")}, + {'C', QLatin1String("CMAKE_STATIC_LIBRARY_PREFIX")}, + {'C', QLatin1String("CMAKE_STATIC_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_TOOLCHAIN_FILE")}, + {'C', QLatin1String("CMAKE_TWEAK_VERSION")}, + {'C', QLatin1String("CMAKE_VERBOSE_MAKEFILE")}, + {'C', QLatin1String("CMAKE_VERSION")}, + {'C', QLatin1String("CMAKE_VS_DEVENV_COMMAND")}, + {'C', QLatin1String("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION")}, + {'C', QLatin1String("CMAKE_VS_MSBUILD_COMMAND")}, + {'C', QLatin1String("CMAKE_VS_MSDEV_COMMAND")}, + {'C', QLatin1String("CMAKE_VS_PLATFORM_TOOLSET")}, + {'C', QLatin1String("CMAKE_XCODE_PLATFORM_TOOLSET")}, + {'P', QLatin1String("PROJECT_BINARY_DIR")}, + // {'P', QLatin1String("PROJECT_NAME")}, + {'P', QLatin1String("PROJECT_SOURCE_DIR")}, + {'P', QLatin1String("PROJECT_VERSION")}, + {'P', QLatin1String("PROJECT_VERSION_MAJOR")}, + {'P', QLatin1String("PROJECT_VERSION_MINOR")}, + {'P', QLatin1String("PROJECT_VERSION_PATCH")}, + {'P', QLatin1String("PROJECT_VERSION_TWEAK")}, + {'B', QLatin1String("BUILD_SHARED_LIBS")}, + {'C', QLatin1String("CMAKE_ABSOLUTE_DESTINATION_FILES")}, + {'C', QLatin1String("CMAKE_APPBUNDLE_PATH")}, + {'C', QLatin1String("CMAKE_AUTOMOC_RELAXED_MODE")}, + {'C', QLatin1String("CMAKE_BACKWARDS_COMPATIBILITY")}, + {'C', QLatin1String("CMAKE_BUILD_TYPE")}, + {'C', QLatin1String("CMAKE_COLOR_MAKEFILE")}, + {'C', QLatin1String("CMAKE_CONFIGURATION_TYPES")}, + {'C', QLatin1String("CMAKE_DEBUG_TARGET_PROPERTIES")}, + {'C', QLatin1String("CMAKE_ERROR_DEPRECATED")}, + {'C', QLatin1String("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, + {'C', QLatin1String("CMAKE_SYSROOT")}, + {'C', QLatin1String("CMAKE_FIND_LIBRARY_PREFIXES")}, + {'C', QLatin1String("CMAKE_FIND_LIBRARY_SUFFIXES")}, + {'C', QLatin1String("CMAKE_FIND_NO_INSTALL_PREFIX")}, + {'C', QLatin1String("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_INCLUDE")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_LIBRARY")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PACKAGE")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PROGRAM")}, + {'C', QLatin1String("CMAKE_FRAMEWORK_PATH")}, + {'C', QLatin1String("CMAKE_IGNORE_PATH")}, + {'C', QLatin1String("CMAKE_INCLUDE_PATH")}, + {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_BEFORE")}, + {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")}, + {'C', QLatin1String("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")}, + {'C', QLatin1String("CMAKE_INSTALL_PREFIX")}, + {'C', QLatin1String("CMAKE_LIBRARY_PATH")}, + {'C', QLatin1String("CMAKE_MFC_FLAG")}, + {'C', QLatin1String("CMAKE_MODULE_PATH")}, + {'C', QLatin1String("CMAKE_NOT_USING_CONFIG_FLAGS")}, + {'C', QLatin1String("CMAKE_PREFIX_PATH")}, + {'C', QLatin1String("CMAKE_PROGRAM_PATH")}, + {'C', QLatin1String("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY")}, + {'C', QLatin1String("CMAKE_STAGING_PREFIX")}, + {'C', QLatin1String("CMAKE_SYSTEM_IGNORE_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_INCLUDE_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_LIBRARY_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_PREFIX_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_PROGRAM_PATH")}, + {'C', QLatin1String("CMAKE_USER_MAKE_RULES_OVERRIDE")}, + {'C', QLatin1String("CMAKE_WARN_DEPRECATED")}, + {'C', QLatin1String("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")}, + {'A', QLatin1String("APPLE")}, + {'B', QLatin1String("BORLAND")}, + {'C', QLatin1String("CMAKE_CL_64")}, + {'C', QLatin1String("CMAKE_COMPILER_2005")}, + {'C', QLatin1String("CMAKE_HOST_APPLE")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM_NAME")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM_PROCESSOR")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM_VERSION")}, + {'C', QLatin1String("CMAKE_HOST_UNIX")}, + {'C', QLatin1String("CMAKE_HOST_WIN32")}, + {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE_REGEX")}, + {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE")}, + {'C', QLatin1String("CMAKE_OBJECT_PATH_MAX")}, + {'C', QLatin1String("CMAKE_SYSTEM_NAME")}, + {'C', QLatin1String("CMAKE_SYSTEM_PROCESSOR")}, + {'C', QLatin1String("CMAKE_SYSTEM")}, + {'C', QLatin1String("CMAKE_SYSTEM_VERSION")}, + {'C', QLatin1String("CYGWIN")}, + {'E', QLatin1String("ENV")}, + {'M', QLatin1String("MSVC10")}, + {'M', QLatin1String("MSVC11")}, + {'M', QLatin1String("MSVC12")}, + {'M', QLatin1String("MSVC60")}, + {'M', QLatin1String("MSVC70")}, + {'M', QLatin1String("MSVC71")}, + {'M', QLatin1String("MSVC80")}, + {'M', QLatin1String("MSVC90")}, + {'M', QLatin1String("MSVC_IDE")}, + {'M', QLatin1String("MSVC")}, + {'M', QLatin1String("MSVC_VERSION")}, + {'U', QLatin1String("UNIX")}, + {'W', QLatin1String("WIN32")}, + {'X', QLatin1String("XCODE_VERSION")}, + {'C', QLatin1String("CMAKE_ARCHIVE_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_AUTOMOC_MOC_OPTIONS")}, + {'C', QLatin1String("CMAKE_AUTOMOC")}, + {'C', QLatin1String("CMAKE_AUTORCC")}, + {'C', QLatin1String("CMAKE_AUTORCC_OPTIONS")}, + {'C', QLatin1String("CMAKE_AUTOUIC")}, + {'C', QLatin1String("CMAKE_AUTOUIC_OPTIONS")}, + {'C', QLatin1String("CMAKE_BUILD_WITH_INSTALL_RPATH")}, + {'C', QLatin1String("CMAKE_DEBUG_POSTFIX")}, + {'C', QLatin1String("CMAKE_EXE_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_Fortran_FORMAT")}, + {'C', QLatin1String("CMAKE_Fortran_MODULE_DIRECTORY")}, + {'C', QLatin1String("CMAKE_GNUtoMS")}, + {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")}, + {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR")}, + {'C', QLatin1String("CMAKE_INSTALL_NAME_DIR")}, + {'C', QLatin1String("CMAKE_INSTALL_RPATH")}, + {'C', QLatin1String("CMAKE_INSTALL_RPATH_USE_LINK_PATH")}, + {'C', QLatin1String("CMAKE_LIBRARY_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_LIBRARY_PATH_FLAG")}, + {'C', QLatin1String("CMAKE_LINK_DEF_FILE_FLAG")}, + {'C', QLatin1String("CMAKE_LINK_DEPENDS_NO_SHARED")}, + {'C', QLatin1String("CMAKE_LINK_INTERFACE_LIBRARIES")}, + {'C', QLatin1String("CMAKE_LINK_LIBRARY_FILE_FLAG")}, + {'C', QLatin1String("CMAKE_LINK_LIBRARY_FLAG")}, + {'C', QLatin1String("CMAKE_MACOSX_BUNDLE")}, + {'C', QLatin1String("CMAKE_MACOSX_RPATH")}, + {'C', QLatin1String("CMAKE_MODULE_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_NO_BUILTIN_CHRPATH")}, + {'C', QLatin1String("CMAKE_NO_SYSTEM_FROM_IMPORTED")}, + {'C', QLatin1String("CMAKE_OSX_ARCHITECTURES")}, + {'C', QLatin1String("CMAKE_OSX_DEPLOYMENT_TARGET")}, + {'C', QLatin1String("CMAKE_OSX_SYSROOT")}, + {'C', QLatin1String("CMAKE_PDB_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_POSITION_INDEPENDENT_CODE")}, + {'C', QLatin1String("CMAKE_RUNTIME_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_SHARED_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_SKIP_BUILD_RPATH")}, + {'C', QLatin1String("CMAKE_SKIP_INSTALL_RPATH")}, + {'C', QLatin1String("CMAKE_STATIC_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_TRY_COMPILE_CONFIGURATION")}, + {'C', QLatin1String("CMAKE_USE_RELATIVE_PATHS")}, + {'C', QLatin1String("CMAKE_VISIBILITY_INLINES_HIDDEN")}, + {'C', QLatin1String("CMAKE_WIN32_EXECUTABLE")}, + {'E', QLatin1String("EXECUTABLE_OUTPUT_PATH")}, + {'L', QLatin1String("LIBRARY_OUTPUT_PATH")}, + {'C', QLatin1String("CMAKE_Fortran_MODDIR_DEFAULT")}, + {'C', QLatin1String("CMAKE_Fortran_MODDIR_FLAG")}, + {'C', QLatin1String("CMAKE_Fortran_MODOUT_FLAG")}, + {'C', QLatin1String("CMAKE_INTERNAL_PLATFORM_ABI")}, + {'C', QLatin1String("CPACK_ABSOLUTE_DESTINATION_FILES")}, + {'C', QLatin1String("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")}, + {'C', QLatin1String("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, + {'C', QLatin1String("CPACK_INCLUDE_TOPLEVEL_DIRECTORY")}, + {'C', QLatin1String("CPACK_INSTALL_SCRIPT")}, + {'C', QLatin1String("CPACK_PACKAGING_INSTALL_PREFIX")}, + {'C', QLatin1String("CPACK_SET_DESTDIR")}, + {'C', QLatin1String("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")}}; } -void loadCMakeData(QMultiHash &types, QMultiHash &keywords, QMultiHash &builtin, QMultiHash &literals, QMultiHash &other) +void loadCMakeData(QMultiHash &types, + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other) { - if (!cmakeDataInitialized) { - initCMakeData(); - cmakeDataInitialized = true; - } - types = cmake_types; - keywords = cmake_keywords; - builtin = cmake_builtin; - literals = cmake_literals; - other = cmake_other; + if (!cmakeDataInitialized) + { + initCMakeData(); + cmakeDataInitialized = true; + } + types = cmake_types; + keywords = cmake_keywords; + builtin = cmake_builtin; + literals = cmake_literals; + other = cmake_other; } /********************************************************/ @@ -4155,2170 +3703,1996 @@ static QMultiHash make_types; static QMultiHash make_literals; static QMultiHash make_builtin; static QMultiHash make_other; -void initMakeData() { - make_keywords = { - {'i', QLatin1String("include")}, - {'d', QLatin1String("define")}, - {'e', QLatin1String("else")}, - {'e', QLatin1String("endef")}, - {'e', QLatin1String("endif")}, - {'e', QLatin1String("export")}, - {'i', QLatin1String("ifn?def")}, - {'i', QLatin1String("ifn?eq")}, - {'i', QLatin1String("include")}, - {'o', QLatin1String("override")}, - {'p', QLatin1String("private")}, - {'s', QLatin1String("sinclude")}, - {'u', QLatin1String("undefine")}, - {'u', QLatin1String("unexport")}, - {'v', QLatin1String("vpath")} - }; - make_types = { - {'a', QLatin1String("addsuffix")}, - {'a', QLatin1String("abspath")}, - {'a', QLatin1String("and")}, - {'a', QLatin1String("ar")}, - {'b', QLatin1String("basename")}, - {'c', QLatin1String("call")}, - {'d', QLatin1String("dir")}, - {'e', QLatin1String("error")}, - {'e', QLatin1String("eval")}, - {'f', QLatin1String("file")}, - {'f', QLatin1String("filter")}, - {'f', QLatin1String("find")}, - {'f', QLatin1String("findstring")}, - {'f', QLatin1String("firstword")}, - {'f', QLatin1String("flavor")}, - {'f', QLatin1String("foreach")}, - {'g', QLatin1String("guile")}, - {'i', QLatin1String("if")}, - {'i', QLatin1String("info")}, - {'i', QLatin1String("install")}, - {'j', QLatin1String("join")}, - {'l', QLatin1String("lastword")}, - {'l', QLatin1String("load")}, - {'n', QLatin1String("notdir")}, - {'o', QLatin1String("or")}, - {'o', QLatin1String("origin")}, - {'p', QLatin1String("patsubst")}, - {'r', QLatin1String("ranlib")}, - {'r', QLatin1String("realpath")}, - {'r', QLatin1String("rm")}, - {'s', QLatin1String("shell")}, - {'s', QLatin1String("sort")}, - {'s', QLatin1String("strip")}, - {'s', QLatin1String("subst")}, - {'s', QLatin1String("suffix")}, - {'v', QLatin1String("value")}, - {'w', QLatin1String("warning")}, - {'w', QLatin1String("wildcard")}, - {'w', QLatin1String("word")} - }; - make_literals = { - {'t', QLatin1String("true")}, - {'f', QLatin1String("false")}, - }; - make_builtin = { - }; - make_other = { - {'C', QLatin1String("CFLAGS")}, - {'L', QLatin1String("LIBS")}, - {'P', QLatin1String("PREFIX")}, - }; -} - -void loadMakeData(QMultiHash &types, QMultiHash &keywords, QMultiHash &builtin, QMultiHash &literals, QMultiHash &other) +void initMakeData() { - if (!makeDataInitialized) { - initMakeData(); - makeDataInitialized = true; - } - types = make_types; - keywords = make_keywords; - builtin = make_builtin; - literals = make_literals; - other = make_other; + make_keywords + = {{'i', QLatin1String("include")}, {'d', QLatin1String("define")}, + {'e', QLatin1String("else")}, {'e', QLatin1String("endef")}, + {'e', QLatin1String("endif")}, {'e', QLatin1String("export")}, + {'i', QLatin1String("ifn?def")}, {'i', QLatin1String("ifn?eq")}, + {'i', QLatin1String("include")}, {'o', QLatin1String("override")}, + {'p', QLatin1String("private")}, {'s', QLatin1String("sinclude")}, + {'u', QLatin1String("undefine")}, {'u', QLatin1String("unexport")}, + {'v', QLatin1String("vpath")}}; + make_types + = {{'a', QLatin1String("addsuffix")}, {'a', QLatin1String("abspath")}, + {'a', QLatin1String("and")}, {'a', QLatin1String("ar")}, + {'b', QLatin1String("basename")}, {'c', QLatin1String("call")}, + {'d', QLatin1String("dir")}, {'e', QLatin1String("error")}, + {'e', QLatin1String("eval")}, {'f', QLatin1String("file")}, + {'f', QLatin1String("filter")}, {'f', QLatin1String("find")}, + {'f', QLatin1String("findstring")}, {'f', QLatin1String("firstword")}, + {'f', QLatin1String("flavor")}, {'f', QLatin1String("foreach")}, + {'g', QLatin1String("guile")}, {'i', QLatin1String("if")}, + {'i', QLatin1String("info")}, {'i', QLatin1String("install")}, + {'j', QLatin1String("join")}, {'l', QLatin1String("lastword")}, + {'l', QLatin1String("load")}, {'n', QLatin1String("notdir")}, + {'o', QLatin1String("or")}, {'o', QLatin1String("origin")}, + {'p', QLatin1String("patsubst")}, {'r', QLatin1String("ranlib")}, + {'r', QLatin1String("realpath")}, {'r', QLatin1String("rm")}, + {'s', QLatin1String("shell")}, {'s', QLatin1String("sort")}, + {'s', QLatin1String("strip")}, {'s', QLatin1String("subst")}, + {'s', QLatin1String("suffix")}, {'v', QLatin1String("value")}, + {'w', QLatin1String("warning")}, {'w', QLatin1String("wildcard")}, + {'w', QLatin1String("word")}}; + make_literals = { + {'t', QLatin1String("true")}, + {'f', QLatin1String("false")}, + }; + make_builtin = {}; + make_other = { + {'C', QLatin1String("CFLAGS")}, + {'L', QLatin1String("LIBS")}, + {'P', QLatin1String("PREFIX")}, + }; } -void loadAsmData(QMultiHash& types, QMultiHash& keywords, QMultiHash& builtin, QMultiHash& literals, QMultiHash& other) +void loadMakeData(QMultiHash &types, + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other) { - Q_UNUSED(literals); - types = { - { 'i', QLatin1String("ip") }, - { 'e', QLatin1String("eip") }, - { 'r', QLatin1String("rip") }, - { 'a', QLatin1String("al") }, - { 'a', QLatin1String("ah") }, - { 'b', QLatin1String("bl") }, - { 'b', QLatin1String("bh") }, - { 'c', QLatin1String("cl") }, - { 'c', QLatin1String("ch") }, - { 'd', QLatin1String("dl") }, - { 'd', QLatin1String("dh") }, - { 's', QLatin1String("sil") }, - { 'd', QLatin1String("dil") }, - { 'b', QLatin1String("bpl") }, - { 's', QLatin1String("spl") }, - { 'r', QLatin1String("r8b") }, - { 'r', QLatin1String("r9b") }, - { 'r', QLatin1String("r10b") }, - { 'r', QLatin1String("r11b") }, - { 'r', QLatin1String("r12b") }, - { 'r', QLatin1String("r13b") }, - { 'r', QLatin1String("r14b") }, - { 'r', QLatin1String("r15b") }, - { 'b', QLatin1String("bx") }, - { 'c', QLatin1String("cx") }, - { 'd', QLatin1String("dx") }, - { 's', QLatin1String("si") }, - { 'd', QLatin1String("di") }, - { 'b', QLatin1String("bp") }, - { 's', QLatin1String("sp") }, - { 'r', QLatin1String("r8w") }, - { 'r', QLatin1String("r9w") }, - { 'r', QLatin1String("r10w") }, - { 'r', QLatin1String("r11w") }, - { 'r', QLatin1String("r12w") }, - { 'r', QLatin1String("r13w") }, - { 'r', QLatin1String("r14w") }, - { 'r', QLatin1String("r15w") }, - { 'e', QLatin1String("eax") }, - { 'e', QLatin1String("ebx") }, - { 'e', QLatin1String("ecx") }, - { 'e', QLatin1String("edx") }, - { 'e', QLatin1String("esi") }, - { 'e', QLatin1String("edi") }, - { 'e', QLatin1String("ebp") }, - { 'e', QLatin1String("esp") }, - { 'e', QLatin1String("eip") }, - { 'r', QLatin1String("r8d") }, - { 'r', QLatin1String("r9d") }, - { 'r', QLatin1String("r10d") }, - { 'r', QLatin1String("r11d") }, - { 'r', QLatin1String("r12d") }, - { 'r', QLatin1String("r13d") }, - { 'r', QLatin1String("r14d") }, - { 'r', QLatin1String("r15d") }, - { 'r', QLatin1String("rax") }, - { 'r', QLatin1String("rbx") }, - { 'r', QLatin1String("rcx") }, - { 'r', QLatin1String("rdx") }, - { 'r', QLatin1String("rsi") }, - { 'r', QLatin1String("rdi") }, - { 'r', QLatin1String("rbp") }, - { 'r', QLatin1String("rsp") }, - { 'r', QLatin1String("r8") }, - { 'r', QLatin1String("r9") }, - { 'r', QLatin1String("r10") }, - { 'r', QLatin1String("r11") }, - { 'r', QLatin1String("r12") }, - { 'r', QLatin1String("r13") }, - { 'r', QLatin1String("r14") }, - { 'r', QLatin1String("r15") }, - { 'd', QLatin1String("ds") }, - { 'e', QLatin1String("es") }, - { 'f', QLatin1String("fs") }, - { 'g', QLatin1String("gs") }, - { 's', QLatin1String("ss") }, - { 's', QLatin1String("st0") }, - { 's', QLatin1String("st1") }, - { 's', QLatin1String("st2") }, - { 's', QLatin1String("st3") }, - { 's', QLatin1String("st4") }, - { 's', QLatin1String("st5") }, - { 's', QLatin1String("st6") }, - { 's', QLatin1String("st7") }, - { 'm', QLatin1String("mm0") }, - { 'm', QLatin1String("mm1") }, - { 'm', QLatin1String("mm2") }, - { 'm', QLatin1String("mm3") }, - { 'm', QLatin1String("mm4") }, - { 'm', QLatin1String("mm5") }, - { 'm', QLatin1String("mm6") }, - { 'm', QLatin1String("mm7") }, - { 'x', QLatin1String("xmm0") }, - { 'x', QLatin1String("xmm1") }, - { 'x', QLatin1String("xmm2") }, - { 'x', QLatin1String("xmm3") }, - { 'x', QLatin1String("xmm4") }, - { 'x', QLatin1String("xmm5") }, - { 'x', QLatin1String("xmm6") }, - { 'x', QLatin1String("xmm7") }, - { 'x', QLatin1String("xmm8") }, - { 'x', QLatin1String("xmm9") }, - { 'x', QLatin1String("xmm10") }, - { 'x', QLatin1String("xmm11") }, - { 'x', QLatin1String("xmm12") }, - { 'x', QLatin1String("xmm13") }, - { 'x', QLatin1String("xmm14") }, - { 'x', QLatin1String("xmm15") }, - { 'x', QLatin1String("xmm16") }, - { 'x', QLatin1String("xmm17") }, - { 'x', QLatin1String("xmm18") }, - { 'x', QLatin1String("xmm19") }, - { 'x', QLatin1String("xmm20") }, - { 'x', QLatin1String("xmm21") }, - { 'x', QLatin1String("xmm22") }, - { 'x', QLatin1String("xmm23") }, - { 'x', QLatin1String("xmm24") }, - { 'x', QLatin1String("xmm25") }, - { 'x', QLatin1String("xmm26") }, - { 'x', QLatin1String("xmm27") }, - { 'x', QLatin1String("xmm28") }, - { 'x', QLatin1String("xmm29") }, - { 'x', QLatin1String("xmm30") }, - { 'x', QLatin1String("xmm31") }, - { 'y', QLatin1String("ymm0") }, - { 'y', QLatin1String("ymm1") }, - { 'y', QLatin1String("ymm2") }, - { 'y', QLatin1String("ymm3") }, - { 'y', QLatin1String("ymm4") }, - { 'y', QLatin1String("ymm5") }, - { 'y', QLatin1String("ymm6") }, - { 'y', QLatin1String("ymm7") }, - { 'y', QLatin1String("ymm8") }, - { 'y', QLatin1String("ymm9") }, - { 'y', QLatin1String("ymm10") }, - { 'y', QLatin1String("ymm11") }, - { 'y', QLatin1String("ymm12") }, - { 'y', QLatin1String("ymm13") }, - { 'y', QLatin1String("ymm14") }, - { 'y', QLatin1String("ymm15") }, - { 'y', QLatin1String("ymm16") }, - { 'y', QLatin1String("ymm17") }, - { 'y', QLatin1String("ymm18") }, - { 'y', QLatin1String("ymm19") }, - { 'y', QLatin1String("ymm20") }, - { 'y', QLatin1String("ymm21") }, - { 'y', QLatin1String("ymm22") }, - { 'y', QLatin1String("ymm23") }, - { 'y', QLatin1String("ymm24") }, - { 'y', QLatin1String("ymm25") }, - { 'y', QLatin1String("ymm26") }, - { 'y', QLatin1String("ymm27") }, - { 'y', QLatin1String("ymm28") }, - { 'y', QLatin1String("ymm29") }, - { 'y', QLatin1String("ymm30") }, - { 'y', QLatin1String("ymm31") }, - { 'z', QLatin1String("zmm0") }, - { 'z', QLatin1String("zmm1") }, - { 'z', QLatin1String("zmm2") }, - { 'z', QLatin1String("zmm3") }, - { 'z', QLatin1String("zmm4") }, - { 'z', QLatin1String("zmm5") }, - { 'z', QLatin1String("zmm6") }, - { 'z', QLatin1String("zmm7") }, - { 'z', QLatin1String("zmm8") }, - { 'z', QLatin1String("zmm9") }, - { 'z', QLatin1String("zmm10") }, - { 'z', QLatin1String("zmm11") }, - { 'z', QLatin1String("zmm12") }, - { 'z', QLatin1String("zmm13") }, - { 'z', QLatin1String("zmm14") }, - { 'z', QLatin1String("zmm15") }, - { 'z', QLatin1String("zmm16") }, - { 'z', QLatin1String("zmm17") }, - { 'z', QLatin1String("zmm18") }, - { 'z', QLatin1String("zmm19") }, - { 'z', QLatin1String("zmm20") }, - { 'z', QLatin1String("zmm21") }, - { 'z', QLatin1String("zmm22") }, - { 'z', QLatin1String("zmm23") }, - { 'z', QLatin1String("zmm24") }, - { 'z', QLatin1String("zmm25") }, - { 'z', QLatin1String("zmm26") }, - { 'z', QLatin1String("zmm27") }, - { 'z', QLatin1String("zmm28") }, - { 'z', QLatin1String("zmm29") }, - { 'z', QLatin1String("zmm30") }, - { 'z', QLatin1String("zmm31") }, - { 'k', QLatin1String("k0") }, - { 'k', QLatin1String("k1") }, - { 'k', QLatin1String("k2") }, - { 'k', QLatin1String("k3") }, - { 'k', QLatin1String("k4") }, - { 'k', QLatin1String("k5") }, - { 'k', QLatin1String("k6") }, - { 'k', QLatin1String("k7") }, - { 'b', QLatin1String("bnd0") }, - { 'b', QLatin1String("bnd1") }, - { 'b', QLatin1String("bnd2") }, - { 'b', QLatin1String("bnd3") }, - { 'c', QLatin1String("cr0") }, - { 'c', QLatin1String("cr1") }, - { 'c', QLatin1String("cr2") }, - { 'c', QLatin1String("cr3") }, - { 'c', QLatin1String("cr4") }, - { 'c', QLatin1String("cr8") }, - { 'd', QLatin1String("dr0") }, - { 'd', QLatin1String("dr1") }, - { 'd', QLatin1String("dr2") }, - { 'd', QLatin1String("dr3") }, - { 'd', QLatin1String("dr8") }, - { 't', QLatin1String("tr3") }, - { 't', QLatin1String("tr4") }, - { 't', QLatin1String("tr5") }, - { 't', QLatin1String("tr6") }, - { 't', QLatin1String("tr7") }, - { 'r', QLatin1String("r0") }, - { 'r', QLatin1String("r1") }, - { 'r', QLatin1String("r2") }, - { 'r', QLatin1String("r3") }, - { 'r', QLatin1String("r4") }, - { 'r', QLatin1String("r5") }, - { 'r', QLatin1String("r6") }, - { 'r', QLatin1String("r7") }, - { 'r', QLatin1String("r0b") }, - { 'r', QLatin1String("r1b") }, - { 'r', QLatin1String("r2b") }, - { 'r', QLatin1String("r3b") }, - { 'r', QLatin1String("r4b") }, - { 'r', QLatin1String("r5b") }, - { 'r', QLatin1String("r6b") }, - { 'r', QLatin1String("r7b") }, - { 'r', QLatin1String("r0w") }, - { 'r', QLatin1String("r1w") }, - { 'r', QLatin1String("r2w") }, - { 'r', QLatin1String("r3w") }, - { 'r', QLatin1String("r4w") }, - { 'r', QLatin1String("r5w") }, - { 'r', QLatin1String("r6w") }, - { 'r', QLatin1String("r7w") }, - { 'r', QLatin1String("r0d") }, - { 'r', QLatin1String("r1d") }, - { 'r', QLatin1String("r2d") }, - { 'r', QLatin1String("r3d") }, - { 'r', QLatin1String("r4d") }, - { 'r', QLatin1String("r5d") }, - { 'r', QLatin1String("r6d") }, - { 'r', QLatin1String("r7d") }, - { 'r', QLatin1String("r0h") }, - { 'r', QLatin1String("r1h") }, - { 'r', QLatin1String("r2h") }, - { 'r', QLatin1String("r3h") }, - { 'r', QLatin1String("r0l") }, - { 'r', QLatin1String("r1l") }, - { 'r', QLatin1String("r2l") }, - { 'r', QLatin1String("r3l") }, - { 'r', QLatin1String("r4l") }, - { 'r', QLatin1String("r5l") }, - { 'r', QLatin1String("r6l") }, - { 'r', QLatin1String("r7l") }, - { 'r', QLatin1String("r8l") }, - { 'r', QLatin1String("r9l") }, - { 'r', QLatin1String("r10l") }, - { 'r', QLatin1String("r11l") }, - { 'r', QLatin1String("r12l") }, - { 'r', QLatin1String("r13l") }, - { 'r', QLatin1String("r14l") }, - { 'r', QLatin1String("r15l") }, - { 'd', QLatin1String("db") }, - { 'd', QLatin1String("dw") }, - { 'd', QLatin1String("dd") }, - { 'd', QLatin1String("dq") }, - { 'd', QLatin1String("dt") }, - { 'd', QLatin1String("ddq") }, - { 'd', QLatin1String("do") }, - { 'd', QLatin1String("dy") }, - { 'd', QLatin1String("dz") }, - { 'r', QLatin1String("resb") }, - { 'r', QLatin1String("resw") }, - { 'r', QLatin1String("resd") }, - { 'r', QLatin1String("resq") }, - { 'r', QLatin1String("rest") }, - { 'r', QLatin1String("resdq") }, - { 'r', QLatin1String("reso") }, - { 'r', QLatin1String("resy") }, - { 'r', QLatin1String("resz") }, - { 'i', QLatin1String("inc") }, - { 'b', QLatin1String("bin") }, - { 'e', QLatin1String("equ") }, - { 't', QLatin1String("times") }, - { 'b', QLatin1String("byte") }, - { 'w', QLatin1String("word") }, - { 'd', QLatin1String("dword") }, - { 'q', QLatin1String("qword") }, - { 'n', QLatin1String("nosplit") }, - { 'r', QLatin1String("rel") }, - { 'a', QLatin1String("abs") }, - { 's', QLatin1String("seg") }, - { 'w', QLatin1String("wrt") }, - { 's', QLatin1String("strict") }, - { 'n', QLatin1String("near") }, - { 'f', QLatin1String("far") }, - { 'a', QLatin1String("a32") }, - { 'p', QLatin1String("ptr") } - }; - - keywords = { - { 'l', QLatin1String("lock") }, - { 'r', QLatin1String("rep") }, - { 'r', QLatin1String("repe") }, - { 'r', QLatin1String("repz") }, - { 'r', QLatin1String("repne") }, - { 'r', QLatin1String("repnz") }, - { 'x', QLatin1String("xaquire") }, - { 'x', QLatin1String("xrelease") }, - { 'b', QLatin1String("bnd") }, - { 'n', QLatin1String("nobnd") }, - { 'a', QLatin1String("aaa") }, - { 'a', QLatin1String("aad") }, - { 'a', QLatin1String("aam") }, - { 'a', QLatin1String("aas") }, - { 'a', QLatin1String("adc") }, - { 'a', QLatin1String("add") }, - { 'a', QLatin1String("addl") }, - { 'a', QLatin1String("and") }, - { 'a', QLatin1String("arpl") }, - { 'b', QLatin1String("bb0_reset") }, - { 'b', QLatin1String("bb1_reset") }, - { 'b', QLatin1String("bound") }, - { 'b', QLatin1String("bsf") }, - { 'b', QLatin1String("bsr") }, - { 'b', QLatin1String("bswap") }, - { 'b', QLatin1String("bt") }, - { 'b', QLatin1String("btc") }, - { 'b', QLatin1String("btr") }, - { 'b', QLatin1String("bts") }, - { 'c', QLatin1String("call") }, - { 'c', QLatin1String("cbw") }, - { 'c', QLatin1String("cdq") }, - { 'c', QLatin1String("cdqe") }, - { 'c', QLatin1String("clc") }, - { 'c', QLatin1String("cld") }, - { 'c', QLatin1String("cli") }, - { 'c', QLatin1String("clts") }, - { 'c', QLatin1String("cltd") }, - { 'c', QLatin1String("cmc") }, - { 'c', QLatin1String("cmp") }, - { 'c', QLatin1String("cmpl") }, - { 'c', QLatin1String("cmpsb") }, - { 'c', QLatin1String("cmpsd") }, - { 'c', QLatin1String("cmpsq") }, - { 'c', QLatin1String("cmpsw") }, - { 'c', QLatin1String("cmpxchg") }, - { 'c', QLatin1String("cmpxchg486") }, - { 'c', QLatin1String("cmpxchg8b") }, - { 'c', QLatin1String("cmpxchg16b") }, - { 'c', QLatin1String("cpuid") }, - { 'c', QLatin1String("cpu_read") }, - { 'c', QLatin1String("cpu_write") }, - { 'c', QLatin1String("cqo") }, - { 'c', QLatin1String("cwd") }, - { 'c', QLatin1String("cwde") }, - { 'd', QLatin1String("daa") }, - { 'd', QLatin1String("das") }, - { 'd', QLatin1String("dec") }, - { 'd', QLatin1String("div") }, - { 'd', QLatin1String("dmint") }, - { 'e', QLatin1String("emms") }, - { 'e', QLatin1String("enter") }, - { 'e', QLatin1String("equ") }, - { 'f', QLatin1String("f2xm1") }, - { 'f', QLatin1String("fabs") }, - { 'f', QLatin1String("fadd") }, - { 'f', QLatin1String("faddp") }, - { 'f', QLatin1String("fbld") }, - { 'f', QLatin1String("fbstp") }, - { 'f', QLatin1String("fchs") }, - { 'f', QLatin1String("fclex") }, - { 'f', QLatin1String("fcmovb") }, - { 'f', QLatin1String("fcmovbe") }, - { 'f', QLatin1String("fcmove") }, - { 'f', QLatin1String("fcmovnb") }, - { 'f', QLatin1String("fcmovnbe") }, - { 'f', QLatin1String("fcmovne") }, - { 'f', QLatin1String("fcmovnu") }, - { 'f', QLatin1String("fcmovu") }, - { 'f', QLatin1String("fcom") }, - { 'f', QLatin1String("fcomi") }, - { 'f', QLatin1String("fcomip") }, - { 'f', QLatin1String("fcomp") }, - { 'f', QLatin1String("fcompp") }, - { 'f', QLatin1String("fcos") }, - { 'f', QLatin1String("fdecstp") }, - { 'f', QLatin1String("fdisi") }, - { 'f', QLatin1String("fdiv") }, - { 'f', QLatin1String("fdivp") }, - { 'f', QLatin1String("fdivr") }, - { 'f', QLatin1String("fdivrp") }, - { 'f', QLatin1String("femms") }, - { 'f', QLatin1String("feni") }, - { 'f', QLatin1String("ffree") }, - { 'f', QLatin1String("ffreep") }, - { 'f', QLatin1String("fiadd") }, - { 'f', QLatin1String("ficom") }, - { 'f', QLatin1String("ficomp") }, - { 'f', QLatin1String("fidiv") }, - { 'f', QLatin1String("fidivr") }, - { 'f', QLatin1String("fild") }, - { 'f', QLatin1String("fimul") }, - { 'f', QLatin1String("fincstp") }, - { 'f', QLatin1String("finit") }, - { 'f', QLatin1String("fist") }, - { 'f', QLatin1String("fistp") }, - { 'f', QLatin1String("fisttp") }, - { 'f', QLatin1String("fisub") }, - { 'f', QLatin1String("fisubr") }, - { 'f', QLatin1String("fld") }, - { 'f', QLatin1String("fld1") }, - { 'f', QLatin1String("fldcw") }, - { 'f', QLatin1String("fldenv") }, - { 'f', QLatin1String("fldl2e") }, - { 'f', QLatin1String("fldl2t") }, - { 'f', QLatin1String("fldlg2") }, - { 'f', QLatin1String("fldln2") }, - { 'f', QLatin1String("fldpi") }, - { 'f', QLatin1String("fldz") }, - { 'f', QLatin1String("fmul") }, - { 'f', QLatin1String("fmulp") }, - { 'f', QLatin1String("fnclex") }, - { 'f', QLatin1String("fndisi") }, - { 'f', QLatin1String("fneni") }, - { 'f', QLatin1String("fninit") }, - { 'f', QLatin1String("fnop") }, - { 'f', QLatin1String("fnsave") }, - { 'f', QLatin1String("fnstcw") }, - { 'f', QLatin1String("fnstenv") }, - { 'f', QLatin1String("fnstsw") }, - { 'f', QLatin1String("fpatan") }, - { 'f', QLatin1String("fprem") }, - { 'f', QLatin1String("fprem1") }, - { 'f', QLatin1String("fptan") }, - { 'f', QLatin1String("frndint") }, - { 'f', QLatin1String("frstor") }, - { 'f', QLatin1String("fsave") }, - { 'f', QLatin1String("fscale") }, - { 'f', QLatin1String("fsetpm") }, - { 'f', QLatin1String("fsin") }, - { 'f', QLatin1String("fsincos") }, - { 'f', QLatin1String("fsqrt") }, - { 'f', QLatin1String("fst") }, - { 'f', QLatin1String("fstcw") }, - { 'f', QLatin1String("fstenv") }, - { 'f', QLatin1String("fstp") }, - { 'f', QLatin1String("fstsw") }, - { 'f', QLatin1String("fsub") }, - { 'f', QLatin1String("fsubp") }, - { 'f', QLatin1String("fsubr") }, - { 'f', QLatin1String("fsubrp") }, - { 'f', QLatin1String("ftst") }, - { 'f', QLatin1String("fucom") }, - { 'f', QLatin1String("fucomi") }, - { 'f', QLatin1String("fucomip") }, - { 'f', QLatin1String("fucomp") }, - { 'f', QLatin1String("fucompp") }, - { 'f', QLatin1String("fxam") }, - { 'f', QLatin1String("fxch") }, - { 'f', QLatin1String("fxtract") }, - { 'f', QLatin1String("fyl2x") }, - { 'f', QLatin1String("fyl2xp1") }, - { 'g', QLatin1String("global") }, - { 'g', QLatin1String("globl") }, - { 'h', QLatin1String("hlt") }, - { 'i', QLatin1String("ibts") }, - { 'i', QLatin1String("icebp") }, - { 'i', QLatin1String("idiv") }, - { 'i', QLatin1String("idivl") }, - { 'i', QLatin1String("idivq") }, - { 'i', QLatin1String("imul") }, - { 'i', QLatin1String("imull") }, - { 'i', QLatin1String("imulq") }, - { 'i', QLatin1String("in") }, - { 'i', QLatin1String("inc") }, - { 'i', QLatin1String("incbin") }, - { 'i', QLatin1String("insb") }, - { 'i', QLatin1String("insd") }, - { 'i', QLatin1String("insw") }, - { 'i', QLatin1String("int") }, - { 'i', QLatin1String("int01") }, - { 'i', QLatin1String("int1") }, - { 'i', QLatin1String("int03") }, - { 'i', QLatin1String("int3") }, - { 'i', QLatin1String("into") }, - { 'i', QLatin1String("invd") }, - { 'i', QLatin1String("invpcid") }, - { 'i', QLatin1String("invlpg") }, - { 'i', QLatin1String("invlpga") }, - { 'i', QLatin1String("iret") }, - { 'i', QLatin1String("iretd") }, - { 'i', QLatin1String("iretq") }, - { 'i', QLatin1String("iretw") }, - { 'j', QLatin1String("jcxz") }, - { 'j', QLatin1String("jecxz") }, - { 'j', QLatin1String("jrcxz") }, - { 'j', QLatin1String("jmp") }, - { 'j', QLatin1String("jmpe") }, - { 'l', QLatin1String("lahf") }, - { 'l', QLatin1String("lar") }, - { 'l', QLatin1String("lds") }, - { 'l', QLatin1String("lea") }, - { 'l', QLatin1String("leal") }, - { 'l', QLatin1String("leaq") }, - { 'l', QLatin1String("leave") }, - { 'l', QLatin1String("les") }, - { 'l', QLatin1String("lfence") }, - { 'l', QLatin1String("lfs") }, - { 'l', QLatin1String("lgdt") }, - { 'l', QLatin1String("lgs") }, - { 'l', QLatin1String("lidt") }, - { 'l', QLatin1String("lldt") }, - { 'l', QLatin1String("lmsw") }, - { 'l', QLatin1String("loadall") }, - { 'l', QLatin1String("loadall286") }, - { 'l', QLatin1String("lodsb") }, - { 'l', QLatin1String("lodsd") }, - { 'l', QLatin1String("lodsq") }, - { 'l', QLatin1String("lodsw") }, - { 'l', QLatin1String("loop") }, - { 'l', QLatin1String("loope") }, - { 'l', QLatin1String("loopne") }, - { 'l', QLatin1String("loopnz") }, - { 'l', QLatin1String("loopz") }, - { 'l', QLatin1String("lsl") }, - { 'l', QLatin1String("lss") }, - { 'l', QLatin1String("ltr") }, - { 'm', QLatin1String("mfence") }, - { 'm', QLatin1String("monitor") }, - { 'm', QLatin1String("mov") }, - { 'm', QLatin1String("movd") }, - { 'm', QLatin1String("movl") }, - { 'm', QLatin1String("movq") }, - { 'm', QLatin1String("movsb") }, - { 'm', QLatin1String("movsd") }, - { 'm', QLatin1String("movsq") }, - { 'm', QLatin1String("movsw") }, - { 'm', QLatin1String("movsx") }, - { 'm', QLatin1String("movsxd") }, - { 'm', QLatin1String("movzx") }, - { 'm', QLatin1String("mul") }, - { 'm', QLatin1String("mwait") }, - { 'n', QLatin1String("neg") }, - { 'n', QLatin1String("nop") }, - { 'n', QLatin1String("not") }, - { 'o', QLatin1String("or") }, - { 'o', QLatin1String("out") }, - { 'o', QLatin1String("outsb") }, - { 'o', QLatin1String("outsd") }, - { 'o', QLatin1String("outsw") }, - { 'p', QLatin1String("packssdw") }, - { 'p', QLatin1String("packsswb") }, - { 'p', QLatin1String("packuswb") }, - { 'p', QLatin1String("paddb") }, - { 'p', QLatin1String("paddd") }, - { 'p', QLatin1String("paddsb") }, - { 'p', QLatin1String("paddsiw") }, - { 'p', QLatin1String("paddsw") }, - { 'p', QLatin1String("paddusb") }, - { 'p', QLatin1String("paddusw") }, - { 'p', QLatin1String("paddw") }, - { 'p', QLatin1String("pand") }, - { 'p', QLatin1String("pandn") }, - { 'p', QLatin1String("pause") }, - { 'p', QLatin1String("paveb") }, - { 'p', QLatin1String("pavgusb") }, - { 'p', QLatin1String("pcmpeqb") }, - { 'p', QLatin1String("pcmpeqd") }, - { 'p', QLatin1String("pcmpeqw") }, - { 'p', QLatin1String("pcmpgtb") }, - { 'p', QLatin1String("pcmpgtd") }, - { 'p', QLatin1String("pcmpgtw") }, - { 'p', QLatin1String("pdistib") }, - { 'p', QLatin1String("pf2id") }, - { 'p', QLatin1String("pfacc") }, - { 'p', QLatin1String("pfadd") }, - { 'p', QLatin1String("pfcmpeq") }, - { 'p', QLatin1String("pfcmpge") }, - { 'p', QLatin1String("pfcmpgt") }, - { 'p', QLatin1String("pfmax") }, - { 'p', QLatin1String("pfmin") }, - { 'p', QLatin1String("pfmul") }, - { 'p', QLatin1String("pfrcp") }, - { 'p', QLatin1String("pfrcpit1") }, - { 'p', QLatin1String("pfrcpit2") }, - { 'p', QLatin1String("pfrsqit1") }, - { 'p', QLatin1String("pfrsqrt") }, - { 'p', QLatin1String("pfsub") }, - { 'p', QLatin1String("pfsubr") }, - { 'p', QLatin1String("pi2fd") }, - { 'p', QLatin1String("pmachriw") }, - { 'p', QLatin1String("pmaddwd") }, - { 'p', QLatin1String("pmagw") }, - { 'p', QLatin1String("pmulhriw") }, - { 'p', QLatin1String("pmulhrwa") }, - { 'p', QLatin1String("pmulhrwc") }, - { 'p', QLatin1String("pmulhw") }, - { 'p', QLatin1String("pmullw") }, - { 'p', QLatin1String("pmvgezb") }, - { 'p', QLatin1String("pmvlzb") }, - { 'p', QLatin1String("pmvnzb") }, - { 'p', QLatin1String("pmvzb") }, - { 'p', QLatin1String("pop") }, - { 'p', QLatin1String("popq") }, - { 'p', QLatin1String("popa") }, - { 'p', QLatin1String("popad") }, - { 'p', QLatin1String("popaw") }, - { 'p', QLatin1String("popf") }, - { 'p', QLatin1String("popfd") }, - { 'p', QLatin1String("popfq") }, - { 'p', QLatin1String("popfw") }, - { 'p', QLatin1String("por") }, - { 'p', QLatin1String("prefetch") }, - { 'p', QLatin1String("prefetchw") }, - { 'p', QLatin1String("pslld") }, - { 'p', QLatin1String("psllq") }, - { 'p', QLatin1String("psllw") }, - { 'p', QLatin1String("psrad") }, - { 'p', QLatin1String("psraw") }, - { 'p', QLatin1String("psrld") }, - { 'p', QLatin1String("psrlq") }, - { 'p', QLatin1String("psrlw") }, - { 'p', QLatin1String("psubb") }, - { 'p', QLatin1String("psubd") }, - { 'p', QLatin1String("psubsb") }, - { 'p', QLatin1String("psubsiw") }, - { 'p', QLatin1String("psubsw") }, - { 'p', QLatin1String("psubusb") }, - { 'p', QLatin1String("psubusw") }, - { 'p', QLatin1String("psubw") }, - { 'p', QLatin1String("punpckhbw") }, - { 'p', QLatin1String("punpckhdq") }, - { 'p', QLatin1String("punpckhwd") }, - { 'p', QLatin1String("punpcklbw") }, - { 'p', QLatin1String("punpckldq") }, - { 'p', QLatin1String("punpcklwd") }, - { 'p', QLatin1String("push") }, - { 'p', QLatin1String("pusha") }, - { 'p', QLatin1String("pushq") }, - { 'p', QLatin1String("pushad") }, - { 'p', QLatin1String("pushaw") }, - { 'p', QLatin1String("pushf") }, - { 'p', QLatin1String("pushfd") }, - { 'p', QLatin1String("pushfq") }, - { 'p', QLatin1String("pushfw") }, - { 'p', QLatin1String("pxor") }, - { 'r', QLatin1String("rcl") }, - { 'r', QLatin1String("rcr") }, - { 'r', QLatin1String("rdshr") }, - { 'r', QLatin1String("rdmsr") }, - { 'r', QLatin1String("rdpmc") }, - { 'r', QLatin1String("rdtsc") }, - { 'r', QLatin1String("rdtscp") }, - { 'r', QLatin1String("ret") }, - { 'r', QLatin1String("retf") }, - { 'r', QLatin1String("retn") }, - { 'r', QLatin1String("retq") }, - { 'r', QLatin1String("rol") }, - { 'r', QLatin1String("ror") }, - { 'r', QLatin1String("rdm") }, - { 'r', QLatin1String("rsdc") }, - { 'r', QLatin1String("rsldt") }, - { 'r', QLatin1String("rsm") }, - { 'r', QLatin1String("rsts") }, - { 's', QLatin1String("sahf") }, - { 's', QLatin1String("sal") }, - { 's', QLatin1String("sall") }, - { 's', QLatin1String("salq") }, - { 's', QLatin1String("salc") }, - { 's', QLatin1String("sar") }, - { 's', QLatin1String("sarl") }, - { 's', QLatin1String("sarq") }, - { 's', QLatin1String("sbb") }, - { 's', QLatin1String("scasb") }, - { 's', QLatin1String("scasd") }, - { 's', QLatin1String("scasq") }, - { 's', QLatin1String("scasw") }, - { 's', QLatin1String("sfence") }, - { 's', QLatin1String("sgdt") }, - { 's', QLatin1String("shl") }, - { 's', QLatin1String("shll") }, - { 's', QLatin1String("shllq") }, - { 's', QLatin1String("shld") }, - { 's', QLatin1String("shr") }, - { 's', QLatin1String("shrd") }, - { 's', QLatin1String("sidt") }, - { 's', QLatin1String("sldt") }, - { 's', QLatin1String("skinit") }, - { 's', QLatin1String("smi") }, - { 's', QLatin1String("smint") }, - { 's', QLatin1String("smintold") }, - { 's', QLatin1String("smsw") }, - { 's', QLatin1String("stc") }, - { 's', QLatin1String("std") }, - { 's', QLatin1String("sti") }, - { 's', QLatin1String("stosb") }, - { 's', QLatin1String("stosd") }, - { 's', QLatin1String("stosq") }, - { 's', QLatin1String("stosw") }, - { 's', QLatin1String("str") }, - { 's', QLatin1String("sub") }, - { 's', QLatin1String("svdc") }, - { 's', QLatin1String("svldt") }, - { 's', QLatin1String("svts") }, - { 's', QLatin1String("swapgs") }, - { 's', QLatin1String("syscall") }, - { 's', QLatin1String("sysenter") }, - { 's', QLatin1String("sysexit") }, - { 's', QLatin1String("sysret") }, - { 't', QLatin1String("test") }, - { 't', QLatin1String("testl") }, - { 't', QLatin1String("testq") }, - { 'u', QLatin1String("ud0") }, - { 'u', QLatin1String("ud1") }, - { 'u', QLatin1String("ud2b") }, - { 'u', QLatin1String("ud2") }, - { 'u', QLatin1String("ud2a") }, - { 'u', QLatin1String("umov") }, - { 'v', QLatin1String("verr") }, - { 'v', QLatin1String("verw") }, - { 'f', QLatin1String("fwait") }, - { 'w', QLatin1String("wbinvd") }, - { 'w', QLatin1String("wrshr") }, - { 'w', QLatin1String("wrmsr") }, - { 'x', QLatin1String("xadd") }, - { 'x', QLatin1String("xbts") }, - { 'x', QLatin1String("xchg") }, - { 'x', QLatin1String("xlatb") }, - { 'x', QLatin1String("xlat") }, - { 'x', QLatin1String("xor") }, - { 'c', QLatin1String("cmove") }, - { 'c', QLatin1String("cmovz") }, - { 'c', QLatin1String("cmovne") }, - { 'c', QLatin1String("cmovnz") }, - { 'c', QLatin1String("cmova") }, - { 'c', QLatin1String("cmovnbe") }, - { 'c', QLatin1String("cmovae") }, - { 'c', QLatin1String("cmovnb") }, - { 'c', QLatin1String("cmovb") }, - { 'c', QLatin1String("cmovnae") }, - { 'c', QLatin1String("cmovbe") }, - { 'c', QLatin1String("cmovna") }, - { 'c', QLatin1String("cmovg") }, - { 'c', QLatin1String("cmovnle") }, - { 'c', QLatin1String("cmovge") }, - { 'c', QLatin1String("cmovnl") }, - { 'c', QLatin1String("cmovl") }, - { 'c', QLatin1String("cmovnge") }, - { 'c', QLatin1String("cmovle") }, - { 'c', QLatin1String("cmovng") }, - { 'c', QLatin1String("cmovc") }, - { 'c', QLatin1String("cmovnc") }, - { 'c', QLatin1String("cmovo") }, - { 'c', QLatin1String("cmovno") }, - { 'c', QLatin1String("cmovs") }, - { 'c', QLatin1String("cmovns") }, - { 'c', QLatin1String("cmovp") }, - { 'c', QLatin1String("cmovpe") }, - { 'c', QLatin1String("cmovnp") }, - { 'c', QLatin1String("cmovpo") }, - { 'j', QLatin1String("je") }, - { 'j', QLatin1String("jz") }, - { 'j', QLatin1String("jne") }, - { 'j', QLatin1String("jnz") }, - { 'j', QLatin1String("ja") }, - { 'j', QLatin1String("jnbe") }, - { 'j', QLatin1String("jae") }, - { 'j', QLatin1String("jnb") }, - { 'j', QLatin1String("jb") }, - { 'j', QLatin1String("jnae") }, - { 'j', QLatin1String("jbe") }, - { 'j', QLatin1String("jna") }, - { 'j', QLatin1String("jg") }, - { 'j', QLatin1String("jnle") }, - { 'j', QLatin1String("jge") }, - { 'j', QLatin1String("jnl") }, - { 'j', QLatin1String("jl") }, - { 'j', QLatin1String("jnge") }, - { 'j', QLatin1String("jle") }, - { 'j', QLatin1String("jng") }, - { 'j', QLatin1String("jc") }, - { 'j', QLatin1String("jnc") }, - { 'j', QLatin1String("jo") }, - { 'j', QLatin1String("jno") }, - { 'j', QLatin1String("js") }, - { 'j', QLatin1String("jns") }, - { 'j', QLatin1String("jpo") }, - { 'j', QLatin1String("jnp") }, - { 'j', QLatin1String("jpe") }, - { 'j', QLatin1String("jp") }, - { 's', QLatin1String("sete") }, - { 's', QLatin1String("setz") }, - { 's', QLatin1String("setne") }, - { 's', QLatin1String("setnz") }, - { 's', QLatin1String("seta") }, - { 's', QLatin1String("setnbe") }, - { 's', QLatin1String("setae") }, - { 's', QLatin1String("setnb") }, - { 's', QLatin1String("setnc") }, - { 's', QLatin1String("setb") }, - { 's', QLatin1String("setnae") }, - { 's', QLatin1String("setcset") }, - { 's', QLatin1String("setbe") }, - { 's', QLatin1String("setna") }, - { 's', QLatin1String("setg") }, - { 's', QLatin1String("setnle") }, - { 's', QLatin1String("setge") }, - { 's', QLatin1String("setnl") }, - { 's', QLatin1String("setl") }, - { 's', QLatin1String("setnge") }, - { 's', QLatin1String("setle") }, - { 's', QLatin1String("setng") }, - { 's', QLatin1String("sets") }, - { 's', QLatin1String("setns") }, - { 's', QLatin1String("seto") }, - { 's', QLatin1String("setno") }, - { 's', QLatin1String("setpe") }, - { 's', QLatin1String("setp") }, - { 's', QLatin1String("setpo") }, - { 's', QLatin1String("setnp") }, - { 'a', QLatin1String("addps") }, - { 'a', QLatin1String("addss") }, - { 'a', QLatin1String("andnps") }, - { 'a', QLatin1String("andps") }, - { 'c', QLatin1String("cmpeqps") }, - { 'c', QLatin1String("cmpeqss") }, - { 'c', QLatin1String("cmpleps") }, - { 'c', QLatin1String("cmpless") }, - { 'c', QLatin1String("cmpltps") }, - { 'c', QLatin1String("cmpltss") }, - { 'c', QLatin1String("cmpneqps") }, - { 'c', QLatin1String("cmpneqss") }, - { 'c', QLatin1String("cmpnleps") }, - { 'c', QLatin1String("cmpnless") }, - { 'c', QLatin1String("cmpnltps") }, - { 'c', QLatin1String("cmpnltss") }, - { 'c', QLatin1String("cmpordps") }, - { 'c', QLatin1String("cmpordss") }, - { 'c', QLatin1String("cmpunordps") }, - { 'c', QLatin1String("cmpunordss") }, - { 'c', QLatin1String("cmpps") }, - { 'c', QLatin1String("cmpss") }, - { 'c', QLatin1String("comiss") }, - { 'c', QLatin1String("cvtpi2ps") }, - { 'c', QLatin1String("cvtps2pi") }, - { 'c', QLatin1String("cvtsi2ss") }, - { 'c', QLatin1String("cvtss2si") }, - { 'c', QLatin1String("cvttps2pi") }, - { 'c', QLatin1String("cvttss2si") }, - { 'd', QLatin1String("divps") }, - { 'd', QLatin1String("divss") }, - { 'l', QLatin1String("ldmxcsr") }, - { 'm', QLatin1String("maxps") }, - { 'm', QLatin1String("maxss") }, - { 'm', QLatin1String("minps") }, - { 'm', QLatin1String("minss") }, - { 'm', QLatin1String("movaps") }, - { 'm', QLatin1String("movhps") }, - { 'm', QLatin1String("movlhps") }, - { 'm', QLatin1String("movlps") }, - { 'm', QLatin1String("movhlps") }, - { 'm', QLatin1String("movmskps") }, - { 'm', QLatin1String("movntps") }, - { 'm', QLatin1String("movss") }, - { 'm', QLatin1String("movups") }, - { 'm', QLatin1String("mulps") }, - { 'm', QLatin1String("mulss") }, - { 'o', QLatin1String("orps") }, - { 'r', QLatin1String("rcpps") }, - { 'r', QLatin1String("rcpss") }, - { 'r', QLatin1String("rsqrtps") }, - { 'r', QLatin1String("rsqrtss") }, - { 's', QLatin1String("shufps") }, - { 's', QLatin1String("sqrtps") }, - { 's', QLatin1String("sqrtss") }, - { 's', QLatin1String("stmxcsr") }, - { 's', QLatin1String("subps") }, - { 's', QLatin1String("subss") }, - { 'u', QLatin1String("ucomiss") }, - { 'u', QLatin1String("unpckhps") }, - { 'u', QLatin1String("unpcklps") }, - { 'x', QLatin1String("xorps") }, - { 'f', QLatin1String("fxrstor") }, - { 'f', QLatin1String("fxrstor64") }, - { 'f', QLatin1String("fxsave") }, - { 'f', QLatin1String("fxsave64") }, - { 'x', QLatin1String("xgetbv") }, - { 'x', QLatin1String("xsetbv") }, - { 'x', QLatin1String("xsave") }, - { 'x', QLatin1String("xsave64") }, - { 'x', QLatin1String("xsaveopt") }, - { 'x', QLatin1String("xsaveopt64") }, - { 'x', QLatin1String("xrstor") }, - { 'x', QLatin1String("xrstor64") }, - { 'p', QLatin1String("prefetchnta") }, - { 'p', QLatin1String("prefetcht0") }, - { 'p', QLatin1String("prefetcht1") }, - { 'p', QLatin1String("prefetcht2") }, - { 'm', QLatin1String("maskmovq") }, - { 'm', QLatin1String("movntq") }, - { 'p', QLatin1String("pavgb") }, - { 'p', QLatin1String("pavgw") }, - { 'p', QLatin1String("pextrw") }, - { 'p', QLatin1String("pinsrw") }, - { 'p', QLatin1String("pmaxsw") }, - { 'p', QLatin1String("pmaxub") }, - { 'p', QLatin1String("pminsw") }, - { 'p', QLatin1String("pminub") }, - { 'p', QLatin1String("pmovmskb") }, - { 'p', QLatin1String("pmulhuw") }, - { 'p', QLatin1String("psadbw") }, - { 'p', QLatin1String("pshufw") }, - { 'p', QLatin1String("pf2iw") }, - { 'p', QLatin1String("pfnacc") }, - { 'p', QLatin1String("pfpnacc") }, - { 'p', QLatin1String("pi2fw") }, - { 'p', QLatin1String("pswapd") }, - { 'm', QLatin1String("maskmovdqu") }, - { 'c', QLatin1String("clflush") }, - { 'm', QLatin1String("movntdq") }, - { 'm', QLatin1String("movnti") }, - { 'm', QLatin1String("movntpd") }, - { 'm', QLatin1String("movdqa") }, - { 'm', QLatin1String("movdqu") }, - { 'm', QLatin1String("movdq2q") }, - { 'm', QLatin1String("movq2dq") }, - { 'p', QLatin1String("paddq") }, - { 'p', QLatin1String("pmuludq") }, - { 'p', QLatin1String("pshufd") }, - { 'p', QLatin1String("pshufhw") }, - { 'p', QLatin1String("pshuflw") }, - { 'p', QLatin1String("pslldq") }, - { 'p', QLatin1String("psrldq") }, - { 'p', QLatin1String("psubq") }, - { 'p', QLatin1String("punpckhqdq") }, - { 'p', QLatin1String("punpcklqdq") }, - { 'a', QLatin1String("addpd") }, - { 'a', QLatin1String("addsd") }, - { 'a', QLatin1String("andnpd") }, - { 'a', QLatin1String("andpd") }, - { 'c', QLatin1String("cmpeqpd") }, - { 'c', QLatin1String("cmpeqsd") }, - { 'c', QLatin1String("cmplepd") }, - { 'c', QLatin1String("cmplesd") }, - { 'c', QLatin1String("cmpltpd") }, - { 'c', QLatin1String("cmpltsd") }, - { 'c', QLatin1String("cmpneqpd") }, - { 'c', QLatin1String("cmpneqsd") }, - { 'c', QLatin1String("cmpnlepd") }, - { 'c', QLatin1String("cmpnlesd") }, - { 'c', QLatin1String("cmpnltpd") }, - { 'c', QLatin1String("cmpnltsd") }, - { 'c', QLatin1String("cmpordpd") }, - { 'c', QLatin1String("cmpordsd") }, - { 'c', QLatin1String("cmpunordpd") }, - { 'c', QLatin1String("cmpunordsd") }, - { 'c', QLatin1String("cmppd") }, - { 'c', QLatin1String("comisd") }, - { 'c', QLatin1String("cvtdq2pd") }, - { 'c', QLatin1String("cvtdq2ps") }, - { 'c', QLatin1String("cvtpd2dq") }, - { 'c', QLatin1String("cvtpd2pi") }, - { 'c', QLatin1String("cvtpd2ps") }, - { 'c', QLatin1String("cvtpi2pd") }, - { 'c', QLatin1String("cvtps2dq") }, - { 'c', QLatin1String("cvtps2pd") }, - { 'c', QLatin1String("cvtsd2si") }, - { 'c', QLatin1String("cvtsd2ss") }, - { 'c', QLatin1String("cvtsi2sd") }, - { 'c', QLatin1String("cvtss2sd") }, - { 'c', QLatin1String("cvttpd2pi") }, - { 'c', QLatin1String("cvttpd2dq") }, - { 'c', QLatin1String("cvttps2dq") }, - { 'c', QLatin1String("cvttsd2si") }, - { 'd', QLatin1String("divpd") }, - { 'd', QLatin1String("divsd") }, - { 'm', QLatin1String("maxpd") }, - { 'm', QLatin1String("maxsd") }, - { 'm', QLatin1String("minpd") }, - { 'm', QLatin1String("minsd") }, - { 'm', QLatin1String("movapd") }, - { 'm', QLatin1String("movhpd") }, - { 'm', QLatin1String("movlpd") }, - { 'm', QLatin1String("movmskpd") }, - { 'm', QLatin1String("movupd") }, - { 'm', QLatin1String("mulpd") }, - { 'm', QLatin1String("mulsd") }, - { 'o', QLatin1String("orpd") }, - { 's', QLatin1String("shufpd") }, - { 's', QLatin1String("sqrtpd") }, - { 's', QLatin1String("sqrtsd") }, - { 's', QLatin1String("subpd") }, - { 's', QLatin1String("subsd") }, - { 'u', QLatin1String("ucomisd") }, - { 'u', QLatin1String("unpckhpd") }, - { 'u', QLatin1String("unpcklpd") }, - { 'x', QLatin1String("xorpd") }, - { 'a', QLatin1String("addsubpd") }, - { 'a', QLatin1String("addsubps") }, - { 'h', QLatin1String("haddpd") }, - { 'h', QLatin1String("haddps") }, - { 'h', QLatin1String("hsubpd") }, - { 'h', QLatin1String("hsubps") }, - { 'l', QLatin1String("lddqu") }, - { 'm', QLatin1String("movddup") }, - { 'm', QLatin1String("movshdup") }, - { 'm', QLatin1String("movsldup") }, - { 'c', QLatin1String("clgi") }, - { 's', QLatin1String("stgi") }, - { 'v', QLatin1String("vmcall") }, - { 'v', QLatin1String("vmclear") }, - { 'v', QLatin1String("vmfunc") }, - { 'v', QLatin1String("vmlaunch") }, - { 'v', QLatin1String("vmload") }, - { 'v', QLatin1String("vmmcall") }, - { 'v', QLatin1String("vmptrld") }, - { 'v', QLatin1String("vmptrst") }, - { 'v', QLatin1String("vmread") }, - { 'v', QLatin1String("vmresume") }, - { 'v', QLatin1String("vmrun") }, - { 'v', QLatin1String("vmsave") }, - { 'v', QLatin1String("vmwrite") }, - { 'v', QLatin1String("vmxoff") }, - { 'v', QLatin1String("vmxon") }, - { 'i', QLatin1String("invept") }, - { 'i', QLatin1String("invvpid") }, - { 'p', QLatin1String("pabsb") }, - { 'p', QLatin1String("pabsw") }, - { 'p', QLatin1String("pabsd") }, - { 'p', QLatin1String("palignr") }, - { 'p', QLatin1String("phaddw") }, - { 'p', QLatin1String("phaddd") }, - { 'p', QLatin1String("phaddsw") }, - { 'p', QLatin1String("phsubw") }, - { 'p', QLatin1String("phsubd") }, - { 'p', QLatin1String("phsubsw") }, - { 'p', QLatin1String("pmaddubsw") }, - { 'p', QLatin1String("pmulhrsw") }, - { 'p', QLatin1String("pshufb") }, - { 'p', QLatin1String("psignb") }, - { 'p', QLatin1String("psignw") }, - { 'p', QLatin1String("psignd") }, - { 'e', QLatin1String("extrq") }, - { 'i', QLatin1String("insertq") }, - { 'm', QLatin1String("movntsd") }, - { 'm', QLatin1String("movntss") }, - { 'l', QLatin1String("lzcnt") }, - { 'b', QLatin1String("blendpd") }, - { 'b', QLatin1String("blendps") }, - { 'b', QLatin1String("blendvpd") }, - { 'b', QLatin1String("blendvps") }, - { 'd', QLatin1String("dppd") }, - { 'd', QLatin1String("dpps") }, - { 'e', QLatin1String("extractps") }, - { 'i', QLatin1String("insertps") }, - { 'm', QLatin1String("movntdqa") }, - { 'm', QLatin1String("mpsadbw") }, - { 'p', QLatin1String("packusdw") }, - { 'p', QLatin1String("pblendvb") }, - { 'p', QLatin1String("pblendw") }, - { 'p', QLatin1String("pcmpeqq") }, - { 'p', QLatin1String("pextrb") }, - { 'p', QLatin1String("pextrd") }, - { 'p', QLatin1String("pextrq") }, - { 'p', QLatin1String("phminposuw") }, - { 'p', QLatin1String("pinsrb") }, - { 'p', QLatin1String("pinsrd") }, - { 'p', QLatin1String("pinsrq") }, - { 'p', QLatin1String("pmaxsb") }, - { 'p', QLatin1String("pmaxsd") }, - { 'p', QLatin1String("pmaxud") }, - { 'p', QLatin1String("pmaxuw") }, - { 'p', QLatin1String("pminsb") }, - { 'p', QLatin1String("pminsd") }, - { 'p', QLatin1String("pminud") }, - { 'p', QLatin1String("pminuw") }, - { 'p', QLatin1String("pmovsxbw") }, - { 'p', QLatin1String("pmovsxbd") }, - { 'p', QLatin1String("pmovsxbq") }, - { 'p', QLatin1String("pmovsxwd") }, - { 'p', QLatin1String("pmovsxwq") }, - { 'p', QLatin1String("pmovsxdq") }, - { 'p', QLatin1String("pmovzxbw") }, - { 'p', QLatin1String("pmovzxbd") }, - { 'p', QLatin1String("pmovzxbq") }, - { 'p', QLatin1String("pmovzxwd") }, - { 'p', QLatin1String("pmovzxwq") }, - { 'p', QLatin1String("pmovzxdq") }, - { 'p', QLatin1String("pmuldq") }, - { 'p', QLatin1String("pmulld") }, - { 'p', QLatin1String("ptest") }, - { 'r', QLatin1String("roundpd") }, - { 'r', QLatin1String("roundps") }, - { 'r', QLatin1String("roundsd") }, - { 'r', QLatin1String("roundss") }, - { 'c', QLatin1String("crc32") }, - { 'p', QLatin1String("pcmpestri") }, - { 'p', QLatin1String("pcmpestrm") }, - { 'p', QLatin1String("pcmpistri") }, - { 'p', QLatin1String("pcmpistrm") }, - { 'p', QLatin1String("pcmpgtq") }, - { 'p', QLatin1String("popcnt") }, - { 'g', QLatin1String("getsec") }, - { 'p', QLatin1String("pfrcpv") }, - { 'p', QLatin1String("pfrsqrtv") }, - { 'm', QLatin1String("movbe") }, - { 'a', QLatin1String("aesenc") }, - { 'a', QLatin1String("aesenclast") }, - { 'a', QLatin1String("aesdec") }, - { 'a', QLatin1String("aesdeclast") }, - { 'a', QLatin1String("aesimc") }, - { 'a', QLatin1String("aeskeygenassist") }, - { 'v', QLatin1String("vaesenc") }, - { 'v', QLatin1String("vaesenclast") }, - { 'v', QLatin1String("vaesdec") }, - { 'v', QLatin1String("vaesdeclast") }, - { 'v', QLatin1String("vaesimc") }, - { 'v', QLatin1String("vaeskeygenassist") }, - { 'v', QLatin1String("vaddpd") }, - { 'v', QLatin1String("vaddps") }, - { 'v', QLatin1String("vaddsd") }, - { 'v', QLatin1String("vaddss") }, - { 'v', QLatin1String("vaddsubpd") }, - { 'v', QLatin1String("vaddsubps") }, - { 'v', QLatin1String("vandpd") }, - { 'v', QLatin1String("vandps") }, - { 'v', QLatin1String("vandnpd") }, - { 'v', QLatin1String("vandnps") }, - { 'v', QLatin1String("vblendpd") }, - { 'v', QLatin1String("vblendps") }, - { 'v', QLatin1String("vblendvpd") }, - { 'v', QLatin1String("vblendvps") }, - { 'v', QLatin1String("vbroadcastss") }, - { 'v', QLatin1String("vbroadcastsd") }, - { 'v', QLatin1String("vbroadcastf128") }, - { 'v', QLatin1String("vcmpeq_ospd") }, - { 'v', QLatin1String("vcmpeqpd") }, - { 'v', QLatin1String("vcmplt_ospd") }, - { 'v', QLatin1String("vcmpltpd") }, - { 'v', QLatin1String("vcmple_ospd") }, - { 'v', QLatin1String("vcmplepd") }, - { 'v', QLatin1String("vcmpunord_qpd") }, - { 'v', QLatin1String("vcmpunordpd") }, - { 'v', QLatin1String("vcmpneq_uqpd") }, - { 'v', QLatin1String("vcmpneqpd") }, - { 'v', QLatin1String("vcmpnlt_uspd") }, - { 'v', QLatin1String("vcmpnltpd") }, - { 'v', QLatin1String("vcmpnle_uspd") }, - { 'v', QLatin1String("vcmpnlepd") }, - { 'v', QLatin1String("vcmpord_qpd") }, - { 'v', QLatin1String("vcmpordpd") }, - { 'v', QLatin1String("vcmpeq_uqpd") }, - { 'v', QLatin1String("vcmpnge_uspd") }, - { 'v', QLatin1String("vcmpngepd") }, - { 'v', QLatin1String("vcmpngt_uspd") }, - { 'v', QLatin1String("vcmpngtpd") }, - { 'v', QLatin1String("vcmpfalse_oqpd") }, - { 'v', QLatin1String("vcmpfalsepd") }, - { 'v', QLatin1String("vcmpneq_oqpd") }, - { 'v', QLatin1String("vcmpge_ospd") }, - { 'v', QLatin1String("vcmpgepd") }, - { 'v', QLatin1String("vcmpgt_ospd") }, - { 'v', QLatin1String("vcmpgtpd") }, - { 'v', QLatin1String("vcmptrue_uqpd") }, - { 'v', QLatin1String("vcmptruepd") }, - { 'v', QLatin1String("vcmplt_oqpd") }, - { 'v', QLatin1String("vcmple_oqpd") }, - { 'v', QLatin1String("vcmpunord_spd") }, - { 'v', QLatin1String("vcmpneq_uspd") }, - { 'v', QLatin1String("vcmpnlt_uqpd") }, - { 'v', QLatin1String("vcmpnle_uqpd") }, - { 'v', QLatin1String("vcmpord_spd") }, - { 'v', QLatin1String("vcmpeq_uspd") }, - { 'v', QLatin1String("vcmpnge_uqpd") }, - { 'v', QLatin1String("vcmpngt_uqpd") }, - { 'v', QLatin1String("vcmpfalse_ospd") }, - { 'v', QLatin1String("vcmpneq_ospd") }, - { 'v', QLatin1String("vcmpge_oqpd") }, - { 'v', QLatin1String("vcmpgt_oqpd") }, - { 'v', QLatin1String("vcmptrue_uspd") }, - { 'v', QLatin1String("vcmppd") }, - { 'v', QLatin1String("vcmpeq_osps") }, - { 'v', QLatin1String("vcmpeqps") }, - { 'v', QLatin1String("vcmplt_osps") }, - { 'v', QLatin1String("vcmpltps") }, - { 'v', QLatin1String("vcmple_osps") }, - { 'v', QLatin1String("vcmpleps") }, - { 'v', QLatin1String("vcmpunord_qps") }, - { 'v', QLatin1String("vcmpunordps") }, - { 'v', QLatin1String("vcmpneq_uqps") }, - { 'v', QLatin1String("vcmpneqps") }, - { 'v', QLatin1String("vcmpnlt_usps") }, - { 'v', QLatin1String("vcmpnltps") }, - { 'v', QLatin1String("vcmpnle_usps") }, - { 'v', QLatin1String("vcmpnleps") }, - { 'v', QLatin1String("vcmpord_qps") }, - { 'v', QLatin1String("vcmpordps") }, - { 'v', QLatin1String("vcmpeq_uqps") }, - { 'v', QLatin1String("vcmpnge_usps") }, - { 'v', QLatin1String("vcmpngeps") }, - { 'v', QLatin1String("vcmpngt_usps") }, - { 'v', QLatin1String("vcmpngtps") }, - { 'v', QLatin1String("vcmpfalse_oqps") }, - { 'v', QLatin1String("vcmpfalseps") }, - { 'v', QLatin1String("vcmpneq_oqps") }, - { 'v', QLatin1String("vcmpge_osps") }, - { 'v', QLatin1String("vcmpgeps") }, - { 'v', QLatin1String("vcmpgt_osps") }, - { 'v', QLatin1String("vcmpgtps") }, - { 'v', QLatin1String("vcmptrue_uqps") }, - { 'v', QLatin1String("vcmptrueps") }, - { 'v', QLatin1String("vcmplt_oqps") }, - { 'v', QLatin1String("vcmple_oqps") }, - { 'v', QLatin1String("vcmpunord_sps") }, - { 'v', QLatin1String("vcmpneq_usps") }, - { 'v', QLatin1String("vcmpnlt_uqps") }, - { 'v', QLatin1String("vcmpnle_uqps") }, - { 'v', QLatin1String("vcmpord_sps") }, - { 'v', QLatin1String("vcmpeq_usps") }, - { 'v', QLatin1String("vcmpnge_uqps") }, - { 'v', QLatin1String("vcmpngt_uqps") }, - { 'v', QLatin1String("vcmpfalse_osps") }, - { 'v', QLatin1String("vcmpneq_osps") }, - { 'v', QLatin1String("vcmpge_oqps") }, - { 'v', QLatin1String("vcmpgt_oqps") }, - { 'v', QLatin1String("vcmptrue_usps") }, - { 'v', QLatin1String("vcmpps") }, - { 'v', QLatin1String("vcmpeq_ossd") }, - { 'v', QLatin1String("vcmpeqsd") }, - { 'v', QLatin1String("vcmplt_ossd") }, - { 'v', QLatin1String("vcmpltsd") }, - { 'v', QLatin1String("vcmple_ossd") }, - { 'v', QLatin1String("vcmplesd") }, - { 'v', QLatin1String("vcmpunord_qsd") }, - { 'v', QLatin1String("vcmpunordsd") }, - { 'v', QLatin1String("vcmpneq_uqsd") }, - { 'v', QLatin1String("vcmpneqsd") }, - { 'v', QLatin1String("vcmpnlt_ussd") }, - { 'v', QLatin1String("vcmpnltsd") }, - { 'v', QLatin1String("vcmpnle_ussd") }, - { 'v', QLatin1String("vcmpnlesd") }, - { 'v', QLatin1String("vcmpord_qsd") }, - { 'v', QLatin1String("vcmpordsd") }, - { 'v', QLatin1String("vcmpeq_uqsd") }, - { 'v', QLatin1String("vcmpnge_ussd") }, - { 'v', QLatin1String("vcmpngesd") }, - { 'v', QLatin1String("vcmpngt_ussd") }, - { 'v', QLatin1String("vcmpngtsd") }, - { 'v', QLatin1String("vcmpfalse_oqsd") }, - { 'v', QLatin1String("vcmpfalsesd") }, - { 'v', QLatin1String("vcmpneq_oqsd") }, - { 'v', QLatin1String("vcmpge_ossd") }, - { 'v', QLatin1String("vcmpgesd") }, - { 'v', QLatin1String("vcmpgt_ossd") }, - { 'v', QLatin1String("vcmpgtsd") }, - { 'v', QLatin1String("vcmptrue_uqsd") }, - { 'v', QLatin1String("vcmptruesd") }, - { 'v', QLatin1String("vcmplt_oqsd") }, - { 'v', QLatin1String("vcmple_oqsd") }, - { 'v', QLatin1String("vcmpunord_ssd") }, - { 'v', QLatin1String("vcmpneq_ussd") }, - { 'v', QLatin1String("vcmpnlt_uqsd") }, - { 'v', QLatin1String("vcmpnle_uqsd") }, - { 'v', QLatin1String("vcmpord_ssd") }, - { 'v', QLatin1String("vcmpeq_ussd") }, - { 'v', QLatin1String("vcmpnge_uqsd") }, - { 'v', QLatin1String("vcmpngt_uqsd") }, - { 'v', QLatin1String("vcmpfalse_ossd") }, - { 'v', QLatin1String("vcmpneq_ossd") }, - { 'v', QLatin1String("vcmpge_oqsd") }, - { 'v', QLatin1String("vcmpgt_oqsd") }, - { 'v', QLatin1String("vcmptrue_ussd") }, - { 'v', QLatin1String("vcmpsd") }, - { 'v', QLatin1String("vcmpeq_osss") }, - { 'v', QLatin1String("vcmpeqss") }, - { 'v', QLatin1String("vcmplt_osss") }, - { 'v', QLatin1String("vcmpltss") }, - { 'v', QLatin1String("vcmple_osss") }, - { 'v', QLatin1String("vcmpless") }, - { 'v', QLatin1String("vcmpunord_qss") }, - { 'v', QLatin1String("vcmpunordss") }, - { 'v', QLatin1String("vcmpneq_uqss") }, - { 'v', QLatin1String("vcmpneqss") }, - { 'v', QLatin1String("vcmpnlt_usss") }, - { 'v', QLatin1String("vcmpnltss") }, - { 'v', QLatin1String("vcmpnle_usss") }, - { 'v', QLatin1String("vcmpnless") }, - { 'v', QLatin1String("vcmpord_qss") }, - { 'v', QLatin1String("vcmpordss") }, - { 'v', QLatin1String("vcmpeq_uqss") }, - { 'v', QLatin1String("vcmpnge_usss") }, - { 'v', QLatin1String("vcmpngess") }, - { 'v', QLatin1String("vcmpngt_usss") }, - { 'v', QLatin1String("vcmpngtss") }, - { 'v', QLatin1String("vcmpfalse_oqss") }, - { 'v', QLatin1String("vcmpfalsess") }, - { 'v', QLatin1String("vcmpneq_oqss") }, - { 'v', QLatin1String("vcmpge_osss") }, - { 'v', QLatin1String("vcmpgess") }, - { 'v', QLatin1String("vcmpgt_osss") }, - { 'v', QLatin1String("vcmpgtss") }, - { 'v', QLatin1String("vcmptrue_uqss") }, - { 'v', QLatin1String("vcmptruess") }, - { 'v', QLatin1String("vcmplt_oqss") }, - { 'v', QLatin1String("vcmple_oqss") }, - { 'v', QLatin1String("vcmpunord_sss") }, - { 'v', QLatin1String("vcmpneq_usss") }, - { 'v', QLatin1String("vcmpnlt_uqss") }, - { 'v', QLatin1String("vcmpnle_uqss") }, - { 'v', QLatin1String("vcmpord_sss") }, - { 'v', QLatin1String("vcmpeq_usss") }, - { 'v', QLatin1String("vcmpnge_uqss") }, - { 'v', QLatin1String("vcmpngt_uqss") }, - { 'v', QLatin1String("vcmpfalse_osss") }, - { 'v', QLatin1String("vcmpneq_osss") }, - { 'v', QLatin1String("vcmpge_oqss") }, - { 'v', QLatin1String("vcmpgt_oqss") }, - { 'v', QLatin1String("vcmptrue_usss") }, - { 'v', QLatin1String("vcmpss") }, - { 'v', QLatin1String("vcomisd") }, - { 'v', QLatin1String("vcomiss") }, - { 'v', QLatin1String("vcvtdq2pd") }, - { 'v', QLatin1String("vcvtdq2ps") }, - { 'v', QLatin1String("vcvtpd2dq") }, - { 'v', QLatin1String("vcvtpd2ps") }, - { 'v', QLatin1String("vcvtps2dq") }, - { 'v', QLatin1String("vcvtps2pd") }, - { 'v', QLatin1String("vcvtsd2si") }, - { 'v', QLatin1String("vcvtsd2ss") }, - { 'v', QLatin1String("vcvtsi2sd") }, - { 'v', QLatin1String("vcvtsi2ss") }, - { 'v', QLatin1String("vcvtss2sd") }, - { 'v', QLatin1String("vcvtss2si") }, - { 'v', QLatin1String("vcvttpd2dq") }, - { 'v', QLatin1String("vcvttps2dq") }, - { 'v', QLatin1String("vcvttsd2si") }, - { 'v', QLatin1String("vcvttss2si") }, - { 'v', QLatin1String("vdivpd") }, - { 'v', QLatin1String("vdivps") }, - { 'v', QLatin1String("vdivsd") }, - { 'v', QLatin1String("vdivss") }, - { 'v', QLatin1String("vdppd") }, - { 'v', QLatin1String("vdpps") }, - { 'v', QLatin1String("vextractf128") }, - { 'v', QLatin1String("vextractps") }, - { 'v', QLatin1String("vhaddpd") }, - { 'v', QLatin1String("vhaddps") }, - { 'v', QLatin1String("vhsubpd") }, - { 'v', QLatin1String("vhsubps") }, - { 'v', QLatin1String("vinsertf128") }, - { 'v', QLatin1String("vinsertps") }, - { 'v', QLatin1String("vlddqu") }, - { 'v', QLatin1String("vldqqu") }, - { 'v', QLatin1String("vldmxcsr") }, - { 'v', QLatin1String("vmaskmovdqu") }, - { 'v', QLatin1String("vmaskmovps") }, - { 'v', QLatin1String("vmaskmovpd") }, - { 'v', QLatin1String("vmaxpd") }, - { 'v', QLatin1String("vmaxps") }, - { 'v', QLatin1String("vmaxsd") }, - { 'v', QLatin1String("vmaxss") }, - { 'v', QLatin1String("vminpd") }, - { 'v', QLatin1String("vminps") }, - { 'v', QLatin1String("vminsd") }, - { 'v', QLatin1String("vminss") }, - { 'v', QLatin1String("vmovapd") }, - { 'v', QLatin1String("vmovaps") }, - { 'v', QLatin1String("vmovd") }, - { 'v', QLatin1String("vmovq") }, - { 'v', QLatin1String("vmovddup") }, - { 'v', QLatin1String("vmovdqa") }, - { 'v', QLatin1String("vmovqqa") }, - { 'v', QLatin1String("vmovdqu") }, - { 'v', QLatin1String("vmovqqu") }, - { 'v', QLatin1String("vmovhlps") }, - { 'v', QLatin1String("vmovhpd") }, - { 'v', QLatin1String("vmovhps") }, - { 'v', QLatin1String("vmovlhps") }, - { 'v', QLatin1String("vmovlpd") }, - { 'v', QLatin1String("vmovlps") }, - { 'v', QLatin1String("vmovmskpd") }, - { 'v', QLatin1String("vmovmskps") }, - { 'v', QLatin1String("vmovntdq") }, - { 'v', QLatin1String("vmovntqq") }, - { 'v', QLatin1String("vmovntdqa") }, - { 'v', QLatin1String("vmovntpd") }, - { 'v', QLatin1String("vmovntps") }, - { 'v', QLatin1String("vmovsd") }, - { 'v', QLatin1String("vmovshdup") }, - { 'v', QLatin1String("vmovsldup") }, - { 'v', QLatin1String("vmovss") }, - { 'v', QLatin1String("vmovupd") }, - { 'v', QLatin1String("vmovups") }, - { 'v', QLatin1String("vmpsadbw") }, - { 'v', QLatin1String("vmulpd") }, - { 'v', QLatin1String("vmulps") }, - { 'v', QLatin1String("vmulsd") }, - { 'v', QLatin1String("vmulss") }, - { 'v', QLatin1String("vorpd") }, - { 'v', QLatin1String("vorps") }, - { 'v', QLatin1String("vpabsb") }, - { 'v', QLatin1String("vpabsw") }, - { 'v', QLatin1String("vpabsd") }, - { 'v', QLatin1String("vpacksswb") }, - { 'v', QLatin1String("vpackssdw") }, - { 'v', QLatin1String("vpackuswb") }, - { 'v', QLatin1String("vpackusdw") }, - { 'v', QLatin1String("vpaddb") }, - { 'v', QLatin1String("vpaddw") }, - { 'v', QLatin1String("vpaddd") }, - { 'v', QLatin1String("vpaddq") }, - { 'v', QLatin1String("vpaddsb") }, - { 'v', QLatin1String("vpaddsw") }, - { 'v', QLatin1String("vpaddusb") }, - { 'v', QLatin1String("vpaddusw") }, - { 'v', QLatin1String("vpalignr") }, - { 'v', QLatin1String("vpand") }, - { 'v', QLatin1String("vpandn") }, - { 'v', QLatin1String("vpavgb") }, - { 'v', QLatin1String("vpavgw") }, - { 'v', QLatin1String("vpblendvb") }, - { 'v', QLatin1String("vpblendw") }, - { 'v', QLatin1String("vpcmpestri") }, - { 'v', QLatin1String("vpcmpestrm") }, - { 'v', QLatin1String("vpcmpistri") }, - { 'v', QLatin1String("vpcmpistrm") }, - { 'v', QLatin1String("vpcmpeqb") }, - { 'v', QLatin1String("vpcmpeqw") }, - { 'v', QLatin1String("vpcmpeqd") }, - { 'v', QLatin1String("vpcmpeqq") }, - { 'v', QLatin1String("vpcmpgtb") }, - { 'v', QLatin1String("vpcmpgtw") }, - { 'v', QLatin1String("vpcmpgtd") }, - { 'v', QLatin1String("vpcmpgtq") }, - { 'v', QLatin1String("vpermilpd") }, - { 'v', QLatin1String("vpermilps") }, - { 'v', QLatin1String("vperm2f128") }, - { 'v', QLatin1String("vpextrb") }, - { 'v', QLatin1String("vpextrw") }, - { 'v', QLatin1String("vpextrd") }, - { 'v', QLatin1String("vpextrq") }, - { 'v', QLatin1String("vphaddw") }, - { 'v', QLatin1String("vphaddd") }, - { 'v', QLatin1String("vphaddsw") }, - { 'v', QLatin1String("vphminposuw") }, - { 'v', QLatin1String("vphsubw") }, - { 'v', QLatin1String("vphsubd") }, - { 'v', QLatin1String("vphsubsw") }, - { 'v', QLatin1String("vpinsrb") }, - { 'v', QLatin1String("vpinsrw") }, - { 'v', QLatin1String("vpinsrd") }, - { 'v', QLatin1String("vpinsrq") }, - { 'v', QLatin1String("vpmaddwd") }, - { 'v', QLatin1String("vpmaddubsw") }, - { 'v', QLatin1String("vpmaxsb") }, - { 'v', QLatin1String("vpmaxsw") }, - { 'v', QLatin1String("vpmaxsd") }, - { 'v', QLatin1String("vpmaxub") }, - { 'v', QLatin1String("vpmaxuw") }, - { 'v', QLatin1String("vpmaxud") }, - { 'v', QLatin1String("vpminsb") }, - { 'v', QLatin1String("vpminsw") }, - { 'v', QLatin1String("vpminsd") }, - { 'v', QLatin1String("vpminub") }, - { 'v', QLatin1String("vpminuw") }, - { 'v', QLatin1String("vpminud") }, - { 'v', QLatin1String("vpmovmskb") }, - { 'v', QLatin1String("vpmovsxbw") }, - { 'v', QLatin1String("vpmovsxbd") }, - { 'v', QLatin1String("vpmovsxbq") }, - { 'v', QLatin1String("vpmovsxwd") }, - { 'v', QLatin1String("vpmovsxwq") }, - { 'v', QLatin1String("vpmovsxdq") }, - { 'v', QLatin1String("vpmovzxbw") }, - { 'v', QLatin1String("vpmovzxbd") }, - { 'v', QLatin1String("vpmovzxbq") }, - { 'v', QLatin1String("vpmovzxwd") }, - { 'v', QLatin1String("vpmovzxwq") }, - { 'v', QLatin1String("vpmovzxdq") }, - { 'v', QLatin1String("vpmulhuw") }, - { 'v', QLatin1String("vpmulhrsw") }, - { 'v', QLatin1String("vpmulhw") }, - { 'v', QLatin1String("vpmullw") }, - { 'v', QLatin1String("vpmulld") }, - { 'v', QLatin1String("vpmuludq") }, - { 'v', QLatin1String("vpmuldq") }, - { 'v', QLatin1String("vpor") }, - { 'v', QLatin1String("vpsadbw") }, - { 'v', QLatin1String("vpshufb") }, - { 'v', QLatin1String("vpshufd") }, - { 'v', QLatin1String("vpshufhw") }, - { 'v', QLatin1String("vpshuflw") }, - { 'v', QLatin1String("vpsignb") }, - { 'v', QLatin1String("vpsignw") }, - { 'v', QLatin1String("vpsignd") }, - { 'v', QLatin1String("vpslldq") }, - { 'v', QLatin1String("vpsrldq") }, - { 'v', QLatin1String("vpsllw") }, - { 'v', QLatin1String("vpslld") }, - { 'v', QLatin1String("vpsllq") }, - { 'v', QLatin1String("vpsraw") }, - { 'v', QLatin1String("vpsrad") }, - { 'v', QLatin1String("vpsrlw") }, - { 'v', QLatin1String("vpsrld") }, - { 'v', QLatin1String("vpsrlq") }, - { 'v', QLatin1String("vptest") }, - { 'v', QLatin1String("vpsubb") }, - { 'v', QLatin1String("vpsubw") }, - { 'v', QLatin1String("vpsubd") }, - { 'v', QLatin1String("vpsubq") }, - { 'v', QLatin1String("vpsubsb") }, - { 'v', QLatin1String("vpsubsw") }, - { 'v', QLatin1String("vpsubusb") }, - { 'v', QLatin1String("vpsubusw") }, - { 'v', QLatin1String("vpunpckhbw") }, - { 'v', QLatin1String("vpunpckhwd") }, - { 'v', QLatin1String("vpunpckhdq") }, - { 'v', QLatin1String("vpunpckhqdq") }, - { 'v', QLatin1String("vpunpcklbw") }, - { 'v', QLatin1String("vpunpcklwd") }, - { 'v', QLatin1String("vpunpckldq") }, - { 'v', QLatin1String("vpunpcklqdq") }, - { 'v', QLatin1String("vpxor") }, - { 'v', QLatin1String("vrcpps") }, - { 'v', QLatin1String("vrcpss") }, - { 'v', QLatin1String("vrsqrtps") }, - { 'v', QLatin1String("vrsqrtss") }, - { 'v', QLatin1String("vroundpd") }, - { 'v', QLatin1String("vroundps") }, - { 'v', QLatin1String("vroundsd") }, - { 'v', QLatin1String("vroundss") }, - { 'v', QLatin1String("vshufpd") }, - { 'v', QLatin1String("vshufps") }, - { 'v', QLatin1String("vsqrtpd") }, - { 'v', QLatin1String("vsqrtps") }, - { 'v', QLatin1String("vsqrtsd") }, - { 'v', QLatin1String("vsqrtss") }, - { 'v', QLatin1String("vstmxcsr") }, - { 'v', QLatin1String("vsubpd") }, - { 'v', QLatin1String("vsubps") }, - { 'v', QLatin1String("vsubsd") }, - { 'v', QLatin1String("vsubss") }, - { 'v', QLatin1String("vtestps") }, - { 'v', QLatin1String("vtestpd") }, - { 'v', QLatin1String("vucomisd") }, - { 'v', QLatin1String("vucomiss") }, - { 'v', QLatin1String("vunpckhpd") }, - { 'v', QLatin1String("vunpckhps") }, - { 'v', QLatin1String("vunpcklpd") }, - { 'v', QLatin1String("vunpcklps") }, - { 'v', QLatin1String("vxorpd") }, - { 'v', QLatin1String("vxorps") }, - { 'v', QLatin1String("vzeroall") }, - { 'v', QLatin1String("vzeroupper") }, - { 'p', QLatin1String("pclmullqlqdq") }, - { 'p', QLatin1String("pclmulhqlqdq") }, - { 'p', QLatin1String("pclmullqhqdq") }, - { 'p', QLatin1String("pclmulhqhqdq") }, - { 'p', QLatin1String("pclmulqdq") }, - { 'v', QLatin1String("vpclmullqlqdq") }, - { 'v', QLatin1String("vpclmulhqlqdq") }, - { 'v', QLatin1String("vpclmullqhqdq") }, - { 'v', QLatin1String("vpclmulhqhqdq") }, - { 'v', QLatin1String("vpclmulqdq") }, - { 'v', QLatin1String("vfmadd132ps") }, - { 'v', QLatin1String("vfmadd132pd") }, - { 'v', QLatin1String("vfmadd312ps") }, - { 'v', QLatin1String("vfmadd312pd") }, - { 'v', QLatin1String("vfmadd213ps") }, - { 'v', QLatin1String("vfmadd213pd") }, - { 'v', QLatin1String("vfmadd123ps") }, - { 'v', QLatin1String("vfmadd123pd") }, - { 'v', QLatin1String("vfmadd231ps") }, - { 'v', QLatin1String("vfmadd231pd") }, - { 'v', QLatin1String("vfmadd321ps") }, - { 'v', QLatin1String("vfmadd321pd") }, - { 'v', QLatin1String("vfmaddsub132ps") }, - { 'v', QLatin1String("vfmaddsub132pd") }, - { 'v', QLatin1String("vfmaddsub312ps") }, - { 'v', QLatin1String("vfmaddsub312pd") }, - { 'v', QLatin1String("vfmaddsub213ps") }, - { 'v', QLatin1String("vfmaddsub213pd") }, - { 'v', QLatin1String("vfmaddsub123ps") }, - { 'v', QLatin1String("vfmaddsub123pd") }, - { 'v', QLatin1String("vfmaddsub231ps") }, - { 'v', QLatin1String("vfmaddsub231pd") }, - { 'v', QLatin1String("vfmaddsub321ps") }, - { 'v', QLatin1String("vfmaddsub321pd") }, - { 'v', QLatin1String("vfmsub132ps") }, - { 'v', QLatin1String("vfmsub132pd") }, - { 'v', QLatin1String("vfmsub312ps") }, - { 'v', QLatin1String("vfmsub312pd") }, - { 'v', QLatin1String("vfmsub213ps") }, - { 'v', QLatin1String("vfmsub213pd") }, - { 'v', QLatin1String("vfmsub123ps") }, - { 'v', QLatin1String("vfmsub123pd") }, - { 'v', QLatin1String("vfmsub231ps") }, - { 'v', QLatin1String("vfmsub231pd") }, - { 'v', QLatin1String("vfmsub321ps") }, - { 'v', QLatin1String("vfmsub321pd") }, - { 'v', QLatin1String("vfmsubadd132ps") }, - { 'v', QLatin1String("vfmsubadd132pd") }, - { 'v', QLatin1String("vfmsubadd312ps") }, - { 'v', QLatin1String("vfmsubadd312pd") }, - { 'v', QLatin1String("vfmsubadd213ps") }, - { 'v', QLatin1String("vfmsubadd213pd") }, - { 'v', QLatin1String("vfmsubadd123ps") }, - { 'v', QLatin1String("vfmsubadd123pd") }, - { 'v', QLatin1String("vfmsubadd231ps") }, - { 'v', QLatin1String("vfmsubadd231pd") }, - { 'v', QLatin1String("vfmsubadd321ps") }, - { 'v', QLatin1String("vfmsubadd321pd") }, - { 'v', QLatin1String("vfnmadd132ps") }, - { 'v', QLatin1String("vfnmadd132pd") }, - { 'v', QLatin1String("vfnmadd312ps") }, - { 'v', QLatin1String("vfnmadd312pd") }, - { 'v', QLatin1String("vfnmadd213ps") }, - { 'v', QLatin1String("vfnmadd213pd") }, - { 'v', QLatin1String("vfnmadd123ps") }, - { 'v', QLatin1String("vfnmadd123pd") }, - { 'v', QLatin1String("vfnmadd231ps") }, - { 'v', QLatin1String("vfnmadd231pd") }, - { 'v', QLatin1String("vfnmadd321ps") }, - { 'v', QLatin1String("vfnmadd321pd") }, - { 'v', QLatin1String("vfnmsub132ps") }, - { 'v', QLatin1String("vfnmsub132pd") }, - { 'v', QLatin1String("vfnmsub312ps") }, - { 'v', QLatin1String("vfnmsub312pd") }, - { 'v', QLatin1String("vfnmsub213ps") }, - { 'v', QLatin1String("vfnmsub213pd") }, - { 'v', QLatin1String("vfnmsub123ps") }, - { 'v', QLatin1String("vfnmsub123pd") }, - { 'v', QLatin1String("vfnmsub231ps") }, - { 'v', QLatin1String("vfnmsub231pd") }, - { 'v', QLatin1String("vfnmsub321ps") }, - { 'v', QLatin1String("vfnmsub321pd") }, - { 'v', QLatin1String("vfmadd132ss") }, - { 'v', QLatin1String("vfmadd132sd") }, - { 'v', QLatin1String("vfmadd312ss") }, - { 'v', QLatin1String("vfmadd312sd") }, - { 'v', QLatin1String("vfmadd213ss") }, - { 'v', QLatin1String("vfmadd213sd") }, - { 'v', QLatin1String("vfmadd123ss") }, - { 'v', QLatin1String("vfmadd123sd") }, - { 'v', QLatin1String("vfmadd231ss") }, - { 'v', QLatin1String("vfmadd231sd") }, - { 'v', QLatin1String("vfmadd321ss") }, - { 'v', QLatin1String("vfmadd321sd") }, - { 'v', QLatin1String("vfmsub132ss") }, - { 'v', QLatin1String("vfmsub132sd") }, - { 'v', QLatin1String("vfmsub312ss") }, - { 'v', QLatin1String("vfmsub312sd") }, - { 'v', QLatin1String("vfmsub213ss") }, - { 'v', QLatin1String("vfmsub213sd") }, - { 'v', QLatin1String("vfmsub123ss") }, - { 'v', QLatin1String("vfmsub123sd") }, - { 'v', QLatin1String("vfmsub231ss") }, - { 'v', QLatin1String("vfmsub231sd") }, - { 'v', QLatin1String("vfmsub321ss") }, - { 'v', QLatin1String("vfmsub321sd") }, - { 'v', QLatin1String("vfnmadd132ss") }, - { 'v', QLatin1String("vfnmadd132sd") }, - { 'v', QLatin1String("vfnmadd312ss") }, - { 'v', QLatin1String("vfnmadd312sd") }, - { 'v', QLatin1String("vfnmadd213ss") }, - { 'v', QLatin1String("vfnmadd213sd") }, - { 'v', QLatin1String("vfnmadd123ss") }, - { 'v', QLatin1String("vfnmadd123sd") }, - { 'v', QLatin1String("vfnmadd231ss") }, - { 'v', QLatin1String("vfnmadd231sd") }, - { 'v', QLatin1String("vfnmadd321ss") }, - { 'v', QLatin1String("vfnmadd321sd") }, - { 'v', QLatin1String("vfnmsub132ss") }, - { 'v', QLatin1String("vfnmsub132sd") }, - { 'v', QLatin1String("vfnmsub312ss") }, - { 'v', QLatin1String("vfnmsub312sd") }, - { 'v', QLatin1String("vfnmsub213ss") }, - { 'v', QLatin1String("vfnmsub213sd") }, - { 'v', QLatin1String("vfnmsub123ss") }, - { 'v', QLatin1String("vfnmsub123sd") }, - { 'v', QLatin1String("vfnmsub231ss") }, - { 'v', QLatin1String("vfnmsub231sd") }, - { 'v', QLatin1String("vfnmsub321ss") }, - { 'v', QLatin1String("vfnmsub321sd") }, - { 'r', QLatin1String("rdfsbase") }, - { 'r', QLatin1String("rdgsbase") }, - { 'r', QLatin1String("rdrand") }, - { 'w', QLatin1String("wrfsbase") }, - { 'w', QLatin1String("wrgsbase") }, - { 'v', QLatin1String("vcvtph2ps") }, - { 'v', QLatin1String("vcvtps2ph") }, - { 'a', QLatin1String("adcx") }, - { 'a', QLatin1String("adox") }, - { 'r', QLatin1String("rdseed") }, - { 'c', QLatin1String("clac") }, - { 's', QLatin1String("stac") }, - { 'x', QLatin1String("xstore") }, - { 'x', QLatin1String("xcryptecb") }, - { 'x', QLatin1String("xcryptcbc") }, - { 'x', QLatin1String("xcryptctr") }, - { 'x', QLatin1String("xcryptcfb") }, - { 'x', QLatin1String("xcryptofb") }, - { 'm', QLatin1String("montmul") }, - { 'x', QLatin1String("xsha1") }, - { 'x', QLatin1String("xsha256") }, - { 'l', QLatin1String("llwpcb") }, - { 's', QLatin1String("slwpcb") }, - { 'l', QLatin1String("lwpval") }, - { 'l', QLatin1String("lwpins") }, - { 'v', QLatin1String("vfmaddpd") }, - { 'v', QLatin1String("vfmaddps") }, - { 'v', QLatin1String("vfmaddsd") }, - { 'v', QLatin1String("vfmaddss") }, - { 'v', QLatin1String("vfmaddsubpd") }, - { 'v', QLatin1String("vfmaddsubps") }, - { 'v', QLatin1String("vfmsubaddpd") }, - { 'v', QLatin1String("vfmsubaddps") }, - { 'v', QLatin1String("vfmsubpd") }, - { 'v', QLatin1String("vfmsubps") }, - { 'v', QLatin1String("vfmsubsd") }, - { 'v', QLatin1String("vfmsubss") }, - { 'v', QLatin1String("vfnmaddpd") }, - { 'v', QLatin1String("vfnmaddps") }, - { 'v', QLatin1String("vfnmaddsd") }, - { 'v', QLatin1String("vfnmaddss") }, - { 'v', QLatin1String("vfnmsubpd") }, - { 'v', QLatin1String("vfnmsubps") }, - { 'v', QLatin1String("vfnmsubsd") }, - { 'v', QLatin1String("vfnmsubss") }, - { 'v', QLatin1String("vfrczpd") }, - { 'v', QLatin1String("vfrczps") }, - { 'v', QLatin1String("vfrczsd") }, - { 'v', QLatin1String("vfrczss") }, - { 'v', QLatin1String("vpcmov") }, - { 'v', QLatin1String("vpcomb") }, - { 'v', QLatin1String("vpcomd") }, - { 'v', QLatin1String("vpcomq") }, - { 'v', QLatin1String("vpcomub") }, - { 'v', QLatin1String("vpcomud") }, - { 'v', QLatin1String("vpcomuq") }, - { 'v', QLatin1String("vpcomuw") }, - { 'v', QLatin1String("vpcomw") }, - { 'v', QLatin1String("vphaddbd") }, - { 'v', QLatin1String("vphaddbq") }, - { 'v', QLatin1String("vphaddbw") }, - { 'v', QLatin1String("vphadddq") }, - { 'v', QLatin1String("vphaddubd") }, - { 'v', QLatin1String("vphaddubq") }, - { 'v', QLatin1String("vphaddubw") }, - { 'v', QLatin1String("vphaddudq") }, - { 'v', QLatin1String("vphadduwd") }, - { 'v', QLatin1String("vphadduwq") }, - { 'v', QLatin1String("vphaddwd") }, - { 'v', QLatin1String("vphaddwq") }, - { 'v', QLatin1String("vphsubbw") }, - { 'v', QLatin1String("vphsubdq") }, - { 'v', QLatin1String("vphsubwd") }, - { 'v', QLatin1String("vpmacsdd") }, - { 'v', QLatin1String("vpmacsdqh") }, - { 'v', QLatin1String("vpmacsdql") }, - { 'v', QLatin1String("vpmacssdd") }, - { 'v', QLatin1String("vpmacssdqh") }, - { 'v', QLatin1String("vpmacssdql") }, - { 'v', QLatin1String("vpmacsswd") }, - { 'v', QLatin1String("vpmacssww") }, - { 'v', QLatin1String("vpmacswd") }, - { 'v', QLatin1String("vpmacsww") }, - { 'v', QLatin1String("vpmadcsswd") }, - { 'v', QLatin1String("vpmadcswd") }, - { 'v', QLatin1String("vpperm") }, - { 'v', QLatin1String("vprotb") }, - { 'v', QLatin1String("vprotd") }, - { 'v', QLatin1String("vprotq") }, - { 'v', QLatin1String("vprotw") }, - { 'v', QLatin1String("vpshab") }, - { 'v', QLatin1String("vpshad") }, - { 'v', QLatin1String("vpshaq") }, - { 'v', QLatin1String("vpshaw") }, - { 'v', QLatin1String("vpshlb") }, - { 'v', QLatin1String("vpshld") }, - { 'v', QLatin1String("vpshlq") }, - { 'v', QLatin1String("vpshlw") }, - { 'v', QLatin1String("vbroadcasti128") }, - { 'v', QLatin1String("vpblendd") }, - { 'v', QLatin1String("vpbroadcastb") }, - { 'v', QLatin1String("vpbroadcastw") }, - { 'v', QLatin1String("vpbroadcastd") }, - { 'v', QLatin1String("vpbroadcastq") }, - { 'v', QLatin1String("vpermd") }, - { 'v', QLatin1String("vpermpd") }, - { 'v', QLatin1String("vpermps") }, - { 'v', QLatin1String("vpermq") }, - { 'v', QLatin1String("vperm2i128") }, - { 'v', QLatin1String("vextracti128") }, - { 'v', QLatin1String("vinserti128") }, - { 'v', QLatin1String("vpmaskmovd") }, - { 'v', QLatin1String("vpmaskmovq") }, - { 'v', QLatin1String("vpsllvd") }, - { 'v', QLatin1String("vpsllvq") }, - { 'v', QLatin1String("vpsravd") }, - { 'v', QLatin1String("vpsrlvd") }, - { 'v', QLatin1String("vpsrlvq") }, - { 'v', QLatin1String("vgatherdpd") }, - { 'v', QLatin1String("vgatherqpd") }, - { 'v', QLatin1String("vgatherdps") }, - { 'v', QLatin1String("vgatherqps") }, - { 'v', QLatin1String("vpgatherdd") }, - { 'v', QLatin1String("vpgatherqd") }, - { 'v', QLatin1String("vpgatherdq") }, - { 'v', QLatin1String("vpgatherqq") }, - { 'x', QLatin1String("xabort") }, - { 'x', QLatin1String("xbegin") }, - { 'x', QLatin1String("xend") }, - { 'x', QLatin1String("xtest") }, - { 'a', QLatin1String("andn") }, - { 'b', QLatin1String("bextr") }, - { 'b', QLatin1String("blci") }, - { 'b', QLatin1String("blcic") }, - { 'b', QLatin1String("blsi") }, - { 'b', QLatin1String("blsic") }, - { 'b', QLatin1String("blcfill") }, - { 'b', QLatin1String("blsfill") }, - { 'b', QLatin1String("blcmsk") }, - { 'b', QLatin1String("blsmsk") }, - { 'b', QLatin1String("blsr") }, - { 'b', QLatin1String("blcs") }, - { 'b', QLatin1String("bzhi") }, - { 'm', QLatin1String("mulx") }, - { 'p', QLatin1String("pdep") }, - { 'p', QLatin1String("pext") }, - { 'r', QLatin1String("rorx") }, - { 's', QLatin1String("sarx") }, - { 's', QLatin1String("shlx") }, - { 's', QLatin1String("shrx") }, - { 't', QLatin1String("tzcnt") }, - { 't', QLatin1String("tzmsk") }, - { 't', QLatin1String("t1mskc") }, - { 'v', QLatin1String("valignd") }, - { 'v', QLatin1String("valignq") }, - { 'v', QLatin1String("vblendmpd") }, - { 'v', QLatin1String("vblendmps") }, - { 'v', QLatin1String("vbroadcastf32x4") }, - { 'v', QLatin1String("vbroadcastf64x4") }, - { 'v', QLatin1String("vbroadcasti32x4") }, - { 'v', QLatin1String("vbroadcasti64x4") }, - { 'v', QLatin1String("vcompresspd") }, - { 'v', QLatin1String("vcompressps") }, - { 'v', QLatin1String("vcvtpd2udq") }, - { 'v', QLatin1String("vcvtps2udq") }, - { 'v', QLatin1String("vcvtsd2usi") }, - { 'v', QLatin1String("vcvtss2usi") }, - { 'v', QLatin1String("vcvttpd2udq") }, - { 'v', QLatin1String("vcvttps2udq") }, - { 'v', QLatin1String("vcvttsd2usi") }, - { 'v', QLatin1String("vcvttss2usi") }, - { 'v', QLatin1String("vcvtudq2pd") }, - { 'v', QLatin1String("vcvtudq2ps") }, - { 'v', QLatin1String("vcvtusi2sd") }, - { 'v', QLatin1String("vcvtusi2ss") }, - { 'v', QLatin1String("vexpandpd") }, - { 'v', QLatin1String("vexpandps") }, - { 'v', QLatin1String("vextractf32x4") }, - { 'v', QLatin1String("vextractf64x4") }, - { 'v', QLatin1String("vextracti32x4") }, - { 'v', QLatin1String("vextracti64x4") }, - { 'v', QLatin1String("vfixupimmpd") }, - { 'v', QLatin1String("vfixupimmps") }, - { 'v', QLatin1String("vfixupimmsd") }, - { 'v', QLatin1String("vfixupimmss") }, - { 'v', QLatin1String("vgetexppd") }, - { 'v', QLatin1String("vgetexpps") }, - { 'v', QLatin1String("vgetexpsd") }, - { 'v', QLatin1String("vgetexpss") }, - { 'v', QLatin1String("vgetmantpd") }, - { 'v', QLatin1String("vgetmantps") }, - { 'v', QLatin1String("vgetmantsd") }, - { 'v', QLatin1String("vgetmantss") }, - { 'v', QLatin1String("vinsertf32x4") }, - { 'v', QLatin1String("vinsertf64x4") }, - { 'v', QLatin1String("vinserti32x4") }, - { 'v', QLatin1String("vinserti64x4") }, - { 'v', QLatin1String("vmovdqa32") }, - { 'v', QLatin1String("vmovdqa64") }, - { 'v', QLatin1String("vmovdqu32") }, - { 'v', QLatin1String("vmovdqu64") }, - { 'v', QLatin1String("vpabsq") }, - { 'v', QLatin1String("vpandd") }, - { 'v', QLatin1String("vpandnd") }, - { 'v', QLatin1String("vpandnq") }, - { 'v', QLatin1String("vpandq") }, - { 'v', QLatin1String("vpblendmd") }, - { 'v', QLatin1String("vpblendmq") }, - { 'v', QLatin1String("vpcmpltd") }, - { 'v', QLatin1String("vpcmpled") }, - { 'v', QLatin1String("vpcmpneqd") }, - { 'v', QLatin1String("vpcmpnltd") }, - { 'v', QLatin1String("vpcmpnled") }, - { 'v', QLatin1String("vpcmpd") }, - { 'v', QLatin1String("vpcmpltq") }, - { 'v', QLatin1String("vpcmpleq") }, - { 'v', QLatin1String("vpcmpneqq") }, - { 'v', QLatin1String("vpcmpnltq") }, - { 'v', QLatin1String("vpcmpnleq") }, - { 'v', QLatin1String("vpcmpq") }, - { 'v', QLatin1String("vpcmpequd") }, - { 'v', QLatin1String("vpcmpltud") }, - { 'v', QLatin1String("vpcmpleud") }, - { 'v', QLatin1String("vpcmpnequd") }, - { 'v', QLatin1String("vpcmpnltud") }, - { 'v', QLatin1String("vpcmpnleud") }, - { 'v', QLatin1String("vpcmpud") }, - { 'v', QLatin1String("vpcmpequq") }, - { 'v', QLatin1String("vpcmpltuq") }, - { 'v', QLatin1String("vpcmpleuq") }, - { 'v', QLatin1String("vpcmpnequq") }, - { 'v', QLatin1String("vpcmpnltuq") }, - { 'v', QLatin1String("vpcmpnleuq") }, - { 'v', QLatin1String("vpcmpuq") }, - { 'v', QLatin1String("vpcompressd") }, - { 'v', QLatin1String("vpcompressq") }, - { 'v', QLatin1String("vpermi2d") }, - { 'v', QLatin1String("vpermi2pd") }, - { 'v', QLatin1String("vpermi2ps") }, - { 'v', QLatin1String("vpermi2q") }, - { 'v', QLatin1String("vpermt2d") }, - { 'v', QLatin1String("vpermt2pd") }, - { 'v', QLatin1String("vpermt2ps") }, - { 'v', QLatin1String("vpermt2q") }, - { 'v', QLatin1String("vpexpandd") }, - { 'v', QLatin1String("vpexpandq") }, - { 'v', QLatin1String("vpmaxsq") }, - { 'v', QLatin1String("vpmaxuq") }, - { 'v', QLatin1String("vpminsq") }, - { 'v', QLatin1String("vpminuq") }, - { 'v', QLatin1String("vpmovdb") }, - { 'v', QLatin1String("vpmovdw") }, - { 'v', QLatin1String("vpmovqb") }, - { 'v', QLatin1String("vpmovqd") }, - { 'v', QLatin1String("vpmovqw") }, - { 'v', QLatin1String("vpmovsdb") }, - { 'v', QLatin1String("vpmovsdw") }, - { 'v', QLatin1String("vpmovsqb") }, - { 'v', QLatin1String("vpmovsqd") }, - { 'v', QLatin1String("vpmovsqw") }, - { 'v', QLatin1String("vpmovusdb") }, - { 'v', QLatin1String("vpmovusdw") }, - { 'v', QLatin1String("vpmovusqb") }, - { 'v', QLatin1String("vpmovusqd") }, - { 'v', QLatin1String("vpmovusqw") }, - { 'v', QLatin1String("vpord") }, - { 'v', QLatin1String("vporq") }, - { 'v', QLatin1String("vprold") }, - { 'v', QLatin1String("vprolq") }, - { 'v', QLatin1String("vprolvd") }, - { 'v', QLatin1String("vprolvq") }, - { 'v', QLatin1String("vprord") }, - { 'v', QLatin1String("vprorq") }, - { 'v', QLatin1String("vprorvd") }, - { 'v', QLatin1String("vprorvq") }, - { 'v', QLatin1String("vpscatterdd") }, - { 'v', QLatin1String("vpscatterdq") }, - { 'v', QLatin1String("vpscatterqd") }, - { 'v', QLatin1String("vpscatterqq") }, - { 'v', QLatin1String("vpsraq") }, - { 'v', QLatin1String("vpsravq") }, - { 'v', QLatin1String("vpternlogd") }, - { 'v', QLatin1String("vpternlogq") }, - { 'v', QLatin1String("vptestmd") }, - { 'v', QLatin1String("vptestmq") }, - { 'v', QLatin1String("vptestnmd") }, - { 'v', QLatin1String("vptestnmq") }, - { 'v', QLatin1String("vpxord") }, - { 'v', QLatin1String("vpxorq") }, - { 'v', QLatin1String("vrcp14pd") }, - { 'v', QLatin1String("vrcp14ps") }, - { 'v', QLatin1String("vrcp14sd") }, - { 'v', QLatin1String("vrcp14ss") }, - { 'v', QLatin1String("vrndscalepd") }, - { 'v', QLatin1String("vrndscaleps") }, - { 'v', QLatin1String("vrndscalesd") }, - { 'v', QLatin1String("vrndscaless") }, - { 'v', QLatin1String("vrsqrt14pd") }, - { 'v', QLatin1String("vrsqrt14ps") }, - { 'v', QLatin1String("vrsqrt14sd") }, - { 'v', QLatin1String("vrsqrt14ss") }, - { 'v', QLatin1String("vscalefpd") }, - { 'v', QLatin1String("vscalefps") }, - { 'v', QLatin1String("vscalefsd") }, - { 'v', QLatin1String("vscalefss") }, - { 'v', QLatin1String("vscatterdpd") }, - { 'v', QLatin1String("vscatterdps") }, - { 'v', QLatin1String("vscatterqpd") }, - { 'v', QLatin1String("vscatterqps") }, - { 'v', QLatin1String("vshuff32x4") }, - { 'v', QLatin1String("vshuff64x2") }, - { 'v', QLatin1String("vshufi32x4") }, - { 'v', QLatin1String("vshufi64x2") }, - { 'k', QLatin1String("kandnw") }, - { 'k', QLatin1String("kandw") }, - { 'k', QLatin1String("kmovw") }, - { 'k', QLatin1String("knotw") }, - { 'k', QLatin1String("kortestw") }, - { 'k', QLatin1String("korw") }, - { 'k', QLatin1String("kshiftlw") }, - { 'k', QLatin1String("kshiftrw") }, - { 'k', QLatin1String("kunpckbw") }, - { 'k', QLatin1String("kxnorw") }, - { 'k', QLatin1String("kxorw") }, - { 'v', QLatin1String("vpbroadcastmb2q") }, - { 'v', QLatin1String("vpbroadcastmw2d") }, - { 'v', QLatin1String("vpconflictd") }, - { 'v', QLatin1String("vpconflictq") }, - { 'v', QLatin1String("vplzcntd") }, - { 'v', QLatin1String("vplzcntq") }, - { 'v', QLatin1String("vexp2pd") }, - { 'v', QLatin1String("vexp2ps") }, - { 'v', QLatin1String("vrcp28pd") }, - { 'v', QLatin1String("vrcp28ps") }, - { 'v', QLatin1String("vrcp28sd") }, - { 'v', QLatin1String("vrcp28ss") }, - { 'v', QLatin1String("vrsqrt28pd") }, - { 'v', QLatin1String("vrsqrt28ps") }, - { 'v', QLatin1String("vrsqrt28sd") }, - { 'v', QLatin1String("vrsqrt28ss") }, - { 'v', QLatin1String("vgatherpf0dpd") }, - { 'v', QLatin1String("vgatherpf0dps") }, - { 'v', QLatin1String("vgatherpf0qpd") }, - { 'v', QLatin1String("vgatherpf0qps") }, - { 'v', QLatin1String("vgatherpf1dpd") }, - { 'v', QLatin1String("vgatherpf1dps") }, - { 'v', QLatin1String("vgatherpf1qpd") }, - { 'v', QLatin1String("vgatherpf1qps") }, - { 'v', QLatin1String("vscatterpf0dpd") }, - { 'v', QLatin1String("vscatterpf0dps") }, - { 'v', QLatin1String("vscatterpf0qpd") }, - { 'v', QLatin1String("vscatterpf0qps") }, - { 'v', QLatin1String("vscatterpf1dpd") }, - { 'v', QLatin1String("vscatterpf1dps") }, - { 'v', QLatin1String("vscatterpf1qpd") }, - { 'v', QLatin1String("vscatterpf1qps") }, - { 'p', QLatin1String("prefetchwt1") }, - { 'b', QLatin1String("bndmk") }, - { 'b', QLatin1String("bndcl") }, - { 'b', QLatin1String("bndcu") }, - { 'b', QLatin1String("bndcn") }, - { 'b', QLatin1String("bndmov") }, - { 'b', QLatin1String("bndldx") }, - { 'b', QLatin1String("bndstx") }, - { 's', QLatin1String("sha1rnds4") }, - { 's', QLatin1String("sha1nexte") }, - { 's', QLatin1String("sha1msg1") }, - { 's', QLatin1String("sha1msg2") }, - { 's', QLatin1String("sha256rnds2") }, - { 's', QLatin1String("sha256msg1") }, - { 's', QLatin1String("sha256msg2") }, - { 'h', QLatin1String("hint_nop") }, - }; - - other = { - { 's', QLatin1String("section") }, - }; - builtin = { - - { 't', QLatin1String("text") }, - { 'c', QLatin1String("code") }, - { 'd', QLatin1String("data") }, - { 'b', QLatin1String("bss") } - }; + if (!makeDataInitialized) + { + initMakeData(); + makeDataInitialized = true; + } + types = make_types; + keywords = make_keywords; + builtin = make_builtin; + literals = make_literals; + other = make_other; } +void loadAsmData(QMultiHash &types, + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other) +{ + Q_UNUSED(literals); + types = {{'i', QLatin1String("ip")}, {'e', QLatin1String("eip")}, + {'r', QLatin1String("rip")}, {'a', QLatin1String("al")}, + {'a', QLatin1String("ah")}, {'b', QLatin1String("bl")}, + {'b', QLatin1String("bh")}, {'c', QLatin1String("cl")}, + {'c', QLatin1String("ch")}, {'d', QLatin1String("dl")}, + {'d', QLatin1String("dh")}, {'s', QLatin1String("sil")}, + {'d', QLatin1String("dil")}, {'b', QLatin1String("bpl")}, + {'s', QLatin1String("spl")}, {'r', QLatin1String("r8b")}, + {'r', QLatin1String("r9b")}, {'r', QLatin1String("r10b")}, + {'r', QLatin1String("r11b")}, {'r', QLatin1String("r12b")}, + {'r', QLatin1String("r13b")}, {'r', QLatin1String("r14b")}, + {'r', QLatin1String("r15b")}, {'b', QLatin1String("bx")}, + {'c', QLatin1String("cx")}, {'d', QLatin1String("dx")}, + {'s', QLatin1String("si")}, {'d', QLatin1String("di")}, + {'b', QLatin1String("bp")}, {'s', QLatin1String("sp")}, + {'r', QLatin1String("r8w")}, {'r', QLatin1String("r9w")}, + {'r', QLatin1String("r10w")}, {'r', QLatin1String("r11w")}, + {'r', QLatin1String("r12w")}, {'r', QLatin1String("r13w")}, + {'r', QLatin1String("r14w")}, {'r', QLatin1String("r15w")}, + {'e', QLatin1String("eax")}, {'e', QLatin1String("ebx")}, + {'e', QLatin1String("ecx")}, {'e', QLatin1String("edx")}, + {'e', QLatin1String("esi")}, {'e', QLatin1String("edi")}, + {'e', QLatin1String("ebp")}, {'e', QLatin1String("esp")}, + {'e', QLatin1String("eip")}, {'r', QLatin1String("r8d")}, + {'r', QLatin1String("r9d")}, {'r', QLatin1String("r10d")}, + {'r', QLatin1String("r11d")}, {'r', QLatin1String("r12d")}, + {'r', QLatin1String("r13d")}, {'r', QLatin1String("r14d")}, + {'r', QLatin1String("r15d")}, {'r', QLatin1String("rax")}, + {'r', QLatin1String("rbx")}, {'r', QLatin1String("rcx")}, + {'r', QLatin1String("rdx")}, {'r', QLatin1String("rsi")}, + {'r', QLatin1String("rdi")}, {'r', QLatin1String("rbp")}, + {'r', QLatin1String("rsp")}, {'r', QLatin1String("r8")}, + {'r', QLatin1String("r9")}, {'r', QLatin1String("r10")}, + {'r', QLatin1String("r11")}, {'r', QLatin1String("r12")}, + {'r', QLatin1String("r13")}, {'r', QLatin1String("r14")}, + {'r', QLatin1String("r15")}, {'d', QLatin1String("ds")}, + {'e', QLatin1String("es")}, {'f', QLatin1String("fs")}, + {'g', QLatin1String("gs")}, {'s', QLatin1String("ss")}, + {'s', QLatin1String("st0")}, {'s', QLatin1String("st1")}, + {'s', QLatin1String("st2")}, {'s', QLatin1String("st3")}, + {'s', QLatin1String("st4")}, {'s', QLatin1String("st5")}, + {'s', QLatin1String("st6")}, {'s', QLatin1String("st7")}, + {'m', QLatin1String("mm0")}, {'m', QLatin1String("mm1")}, + {'m', QLatin1String("mm2")}, {'m', QLatin1String("mm3")}, + {'m', QLatin1String("mm4")}, {'m', QLatin1String("mm5")}, + {'m', QLatin1String("mm6")}, {'m', QLatin1String("mm7")}, + {'x', QLatin1String("xmm0")}, {'x', QLatin1String("xmm1")}, + {'x', QLatin1String("xmm2")}, {'x', QLatin1String("xmm3")}, + {'x', QLatin1String("xmm4")}, {'x', QLatin1String("xmm5")}, + {'x', QLatin1String("xmm6")}, {'x', QLatin1String("xmm7")}, + {'x', QLatin1String("xmm8")}, {'x', QLatin1String("xmm9")}, + {'x', QLatin1String("xmm10")}, {'x', QLatin1String("xmm11")}, + {'x', QLatin1String("xmm12")}, {'x', QLatin1String("xmm13")}, + {'x', QLatin1String("xmm14")}, {'x', QLatin1String("xmm15")}, + {'x', QLatin1String("xmm16")}, {'x', QLatin1String("xmm17")}, + {'x', QLatin1String("xmm18")}, {'x', QLatin1String("xmm19")}, + {'x', QLatin1String("xmm20")}, {'x', QLatin1String("xmm21")}, + {'x', QLatin1String("xmm22")}, {'x', QLatin1String("xmm23")}, + {'x', QLatin1String("xmm24")}, {'x', QLatin1String("xmm25")}, + {'x', QLatin1String("xmm26")}, {'x', QLatin1String("xmm27")}, + {'x', QLatin1String("xmm28")}, {'x', QLatin1String("xmm29")}, + {'x', QLatin1String("xmm30")}, {'x', QLatin1String("xmm31")}, + {'y', QLatin1String("ymm0")}, {'y', QLatin1String("ymm1")}, + {'y', QLatin1String("ymm2")}, {'y', QLatin1String("ymm3")}, + {'y', QLatin1String("ymm4")}, {'y', QLatin1String("ymm5")}, + {'y', QLatin1String("ymm6")}, {'y', QLatin1String("ymm7")}, + {'y', QLatin1String("ymm8")}, {'y', QLatin1String("ymm9")}, + {'y', QLatin1String("ymm10")}, {'y', QLatin1String("ymm11")}, + {'y', QLatin1String("ymm12")}, {'y', QLatin1String("ymm13")}, + {'y', QLatin1String("ymm14")}, {'y', QLatin1String("ymm15")}, + {'y', QLatin1String("ymm16")}, {'y', QLatin1String("ymm17")}, + {'y', QLatin1String("ymm18")}, {'y', QLatin1String("ymm19")}, + {'y', QLatin1String("ymm20")}, {'y', QLatin1String("ymm21")}, + {'y', QLatin1String("ymm22")}, {'y', QLatin1String("ymm23")}, + {'y', QLatin1String("ymm24")}, {'y', QLatin1String("ymm25")}, + {'y', QLatin1String("ymm26")}, {'y', QLatin1String("ymm27")}, + {'y', QLatin1String("ymm28")}, {'y', QLatin1String("ymm29")}, + {'y', QLatin1String("ymm30")}, {'y', QLatin1String("ymm31")}, + {'z', QLatin1String("zmm0")}, {'z', QLatin1String("zmm1")}, + {'z', QLatin1String("zmm2")}, {'z', QLatin1String("zmm3")}, + {'z', QLatin1String("zmm4")}, {'z', QLatin1String("zmm5")}, + {'z', QLatin1String("zmm6")}, {'z', QLatin1String("zmm7")}, + {'z', QLatin1String("zmm8")}, {'z', QLatin1String("zmm9")}, + {'z', QLatin1String("zmm10")}, {'z', QLatin1String("zmm11")}, + {'z', QLatin1String("zmm12")}, {'z', QLatin1String("zmm13")}, + {'z', QLatin1String("zmm14")}, {'z', QLatin1String("zmm15")}, + {'z', QLatin1String("zmm16")}, {'z', QLatin1String("zmm17")}, + {'z', QLatin1String("zmm18")}, {'z', QLatin1String("zmm19")}, + {'z', QLatin1String("zmm20")}, {'z', QLatin1String("zmm21")}, + {'z', QLatin1String("zmm22")}, {'z', QLatin1String("zmm23")}, + {'z', QLatin1String("zmm24")}, {'z', QLatin1String("zmm25")}, + {'z', QLatin1String("zmm26")}, {'z', QLatin1String("zmm27")}, + {'z', QLatin1String("zmm28")}, {'z', QLatin1String("zmm29")}, + {'z', QLatin1String("zmm30")}, {'z', QLatin1String("zmm31")}, + {'k', QLatin1String("k0")}, {'k', QLatin1String("k1")}, + {'k', QLatin1String("k2")}, {'k', QLatin1String("k3")}, + {'k', QLatin1String("k4")}, {'k', QLatin1String("k5")}, + {'k', QLatin1String("k6")}, {'k', QLatin1String("k7")}, + {'b', QLatin1String("bnd0")}, {'b', QLatin1String("bnd1")}, + {'b', QLatin1String("bnd2")}, {'b', QLatin1String("bnd3")}, + {'c', QLatin1String("cr0")}, {'c', QLatin1String("cr1")}, + {'c', QLatin1String("cr2")}, {'c', QLatin1String("cr3")}, + {'c', QLatin1String("cr4")}, {'c', QLatin1String("cr8")}, + {'d', QLatin1String("dr0")}, {'d', QLatin1String("dr1")}, + {'d', QLatin1String("dr2")}, {'d', QLatin1String("dr3")}, + {'d', QLatin1String("dr8")}, {'t', QLatin1String("tr3")}, + {'t', QLatin1String("tr4")}, {'t', QLatin1String("tr5")}, + {'t', QLatin1String("tr6")}, {'t', QLatin1String("tr7")}, + {'r', QLatin1String("r0")}, {'r', QLatin1String("r1")}, + {'r', QLatin1String("r2")}, {'r', QLatin1String("r3")}, + {'r', QLatin1String("r4")}, {'r', QLatin1String("r5")}, + {'r', QLatin1String("r6")}, {'r', QLatin1String("r7")}, + {'r', QLatin1String("r0b")}, {'r', QLatin1String("r1b")}, + {'r', QLatin1String("r2b")}, {'r', QLatin1String("r3b")}, + {'r', QLatin1String("r4b")}, {'r', QLatin1String("r5b")}, + {'r', QLatin1String("r6b")}, {'r', QLatin1String("r7b")}, + {'r', QLatin1String("r0w")}, {'r', QLatin1String("r1w")}, + {'r', QLatin1String("r2w")}, {'r', QLatin1String("r3w")}, + {'r', QLatin1String("r4w")}, {'r', QLatin1String("r5w")}, + {'r', QLatin1String("r6w")}, {'r', QLatin1String("r7w")}, + {'r', QLatin1String("r0d")}, {'r', QLatin1String("r1d")}, + {'r', QLatin1String("r2d")}, {'r', QLatin1String("r3d")}, + {'r', QLatin1String("r4d")}, {'r', QLatin1String("r5d")}, + {'r', QLatin1String("r6d")}, {'r', QLatin1String("r7d")}, + {'r', QLatin1String("r0h")}, {'r', QLatin1String("r1h")}, + {'r', QLatin1String("r2h")}, {'r', QLatin1String("r3h")}, + {'r', QLatin1String("r0l")}, {'r', QLatin1String("r1l")}, + {'r', QLatin1String("r2l")}, {'r', QLatin1String("r3l")}, + {'r', QLatin1String("r4l")}, {'r', QLatin1String("r5l")}, + {'r', QLatin1String("r6l")}, {'r', QLatin1String("r7l")}, + {'r', QLatin1String("r8l")}, {'r', QLatin1String("r9l")}, + {'r', QLatin1String("r10l")}, {'r', QLatin1String("r11l")}, + {'r', QLatin1String("r12l")}, {'r', QLatin1String("r13l")}, + {'r', QLatin1String("r14l")}, {'r', QLatin1String("r15l")}, + {'d', QLatin1String("db")}, {'d', QLatin1String("dw")}, + {'d', QLatin1String("dd")}, {'d', QLatin1String("dq")}, + {'d', QLatin1String("dt")}, {'d', QLatin1String("ddq")}, + {'d', QLatin1String("do")}, {'d', QLatin1String("dy")}, + {'d', QLatin1String("dz")}, {'r', QLatin1String("resb")}, + {'r', QLatin1String("resw")}, {'r', QLatin1String("resd")}, + {'r', QLatin1String("resq")}, {'r', QLatin1String("rest")}, + {'r', QLatin1String("resdq")}, {'r', QLatin1String("reso")}, + {'r', QLatin1String("resy")}, {'r', QLatin1String("resz")}, + {'i', QLatin1String("inc")}, {'b', QLatin1String("bin")}, + {'e', QLatin1String("equ")}, {'t', QLatin1String("times")}, + {'b', QLatin1String("byte")}, {'w', QLatin1String("word")}, + {'d', QLatin1String("dword")}, {'q', QLatin1String("qword")}, + {'n', QLatin1String("nosplit")}, {'r', QLatin1String("rel")}, + {'a', QLatin1String("abs")}, {'s', QLatin1String("seg")}, + {'w', QLatin1String("wrt")}, {'s', QLatin1String("strict")}, + {'n', QLatin1String("near")}, {'f', QLatin1String("far")}, + {'a', QLatin1String("a32")}, {'p', QLatin1String("ptr")}}; + + keywords = { + {'l', QLatin1String("lock")}, + {'r', QLatin1String("rep")}, + {'r', QLatin1String("repe")}, + {'r', QLatin1String("repz")}, + {'r', QLatin1String("repne")}, + {'r', QLatin1String("repnz")}, + {'x', QLatin1String("xaquire")}, + {'x', QLatin1String("xrelease")}, + {'b', QLatin1String("bnd")}, + {'n', QLatin1String("nobnd")}, + {'a', QLatin1String("aaa")}, + {'a', QLatin1String("aad")}, + {'a', QLatin1String("aam")}, + {'a', QLatin1String("aas")}, + {'a', QLatin1String("adc")}, + {'a', QLatin1String("add")}, + {'a', QLatin1String("addl")}, + {'a', QLatin1String("and")}, + {'a', QLatin1String("arpl")}, + {'b', QLatin1String("bb0_reset")}, + {'b', QLatin1String("bb1_reset")}, + {'b', QLatin1String("bound")}, + {'b', QLatin1String("bsf")}, + {'b', QLatin1String("bsr")}, + {'b', QLatin1String("bswap")}, + {'b', QLatin1String("bt")}, + {'b', QLatin1String("btc")}, + {'b', QLatin1String("btr")}, + {'b', QLatin1String("bts")}, + {'c', QLatin1String("call")}, + {'c', QLatin1String("cbw")}, + {'c', QLatin1String("cdq")}, + {'c', QLatin1String("cdqe")}, + {'c', QLatin1String("clc")}, + {'c', QLatin1String("cld")}, + {'c', QLatin1String("cli")}, + {'c', QLatin1String("clts")}, + {'c', QLatin1String("cltd")}, + {'c', QLatin1String("cmc")}, + {'c', QLatin1String("cmp")}, + {'c', QLatin1String("cmpl")}, + {'c', QLatin1String("cmpsb")}, + {'c', QLatin1String("cmpsd")}, + {'c', QLatin1String("cmpsq")}, + {'c', QLatin1String("cmpsw")}, + {'c', QLatin1String("cmpxchg")}, + {'c', QLatin1String("cmpxchg486")}, + {'c', QLatin1String("cmpxchg8b")}, + {'c', QLatin1String("cmpxchg16b")}, + {'c', QLatin1String("cpuid")}, + {'c', QLatin1String("cpu_read")}, + {'c', QLatin1String("cpu_write")}, + {'c', QLatin1String("cqo")}, + {'c', QLatin1String("cwd")}, + {'c', QLatin1String("cwde")}, + {'d', QLatin1String("daa")}, + {'d', QLatin1String("das")}, + {'d', QLatin1String("dec")}, + {'d', QLatin1String("div")}, + {'d', QLatin1String("dmint")}, + {'e', QLatin1String("emms")}, + {'e', QLatin1String("enter")}, + {'e', QLatin1String("equ")}, + {'f', QLatin1String("f2xm1")}, + {'f', QLatin1String("fabs")}, + {'f', QLatin1String("fadd")}, + {'f', QLatin1String("faddp")}, + {'f', QLatin1String("fbld")}, + {'f', QLatin1String("fbstp")}, + {'f', QLatin1String("fchs")}, + {'f', QLatin1String("fclex")}, + {'f', QLatin1String("fcmovb")}, + {'f', QLatin1String("fcmovbe")}, + {'f', QLatin1String("fcmove")}, + {'f', QLatin1String("fcmovnb")}, + {'f', QLatin1String("fcmovnbe")}, + {'f', QLatin1String("fcmovne")}, + {'f', QLatin1String("fcmovnu")}, + {'f', QLatin1String("fcmovu")}, + {'f', QLatin1String("fcom")}, + {'f', QLatin1String("fcomi")}, + {'f', QLatin1String("fcomip")}, + {'f', QLatin1String("fcomp")}, + {'f', QLatin1String("fcompp")}, + {'f', QLatin1String("fcos")}, + {'f', QLatin1String("fdecstp")}, + {'f', QLatin1String("fdisi")}, + {'f', QLatin1String("fdiv")}, + {'f', QLatin1String("fdivp")}, + {'f', QLatin1String("fdivr")}, + {'f', QLatin1String("fdivrp")}, + {'f', QLatin1String("femms")}, + {'f', QLatin1String("feni")}, + {'f', QLatin1String("ffree")}, + {'f', QLatin1String("ffreep")}, + {'f', QLatin1String("fiadd")}, + {'f', QLatin1String("ficom")}, + {'f', QLatin1String("ficomp")}, + {'f', QLatin1String("fidiv")}, + {'f', QLatin1String("fidivr")}, + {'f', QLatin1String("fild")}, + {'f', QLatin1String("fimul")}, + {'f', QLatin1String("fincstp")}, + {'f', QLatin1String("finit")}, + {'f', QLatin1String("fist")}, + {'f', QLatin1String("fistp")}, + {'f', QLatin1String("fisttp")}, + {'f', QLatin1String("fisub")}, + {'f', QLatin1String("fisubr")}, + {'f', QLatin1String("fld")}, + {'f', QLatin1String("fld1")}, + {'f', QLatin1String("fldcw")}, + {'f', QLatin1String("fldenv")}, + {'f', QLatin1String("fldl2e")}, + {'f', QLatin1String("fldl2t")}, + {'f', QLatin1String("fldlg2")}, + {'f', QLatin1String("fldln2")}, + {'f', QLatin1String("fldpi")}, + {'f', QLatin1String("fldz")}, + {'f', QLatin1String("fmul")}, + {'f', QLatin1String("fmulp")}, + {'f', QLatin1String("fnclex")}, + {'f', QLatin1String("fndisi")}, + {'f', QLatin1String("fneni")}, + {'f', QLatin1String("fninit")}, + {'f', QLatin1String("fnop")}, + {'f', QLatin1String("fnsave")}, + {'f', QLatin1String("fnstcw")}, + {'f', QLatin1String("fnstenv")}, + {'f', QLatin1String("fnstsw")}, + {'f', QLatin1String("fpatan")}, + {'f', QLatin1String("fprem")}, + {'f', QLatin1String("fprem1")}, + {'f', QLatin1String("fptan")}, + {'f', QLatin1String("frndint")}, + {'f', QLatin1String("frstor")}, + {'f', QLatin1String("fsave")}, + {'f', QLatin1String("fscale")}, + {'f', QLatin1String("fsetpm")}, + {'f', QLatin1String("fsin")}, + {'f', QLatin1String("fsincos")}, + {'f', QLatin1String("fsqrt")}, + {'f', QLatin1String("fst")}, + {'f', QLatin1String("fstcw")}, + {'f', QLatin1String("fstenv")}, + {'f', QLatin1String("fstp")}, + {'f', QLatin1String("fstsw")}, + {'f', QLatin1String("fsub")}, + {'f', QLatin1String("fsubp")}, + {'f', QLatin1String("fsubr")}, + {'f', QLatin1String("fsubrp")}, + {'f', QLatin1String("ftst")}, + {'f', QLatin1String("fucom")}, + {'f', QLatin1String("fucomi")}, + {'f', QLatin1String("fucomip")}, + {'f', QLatin1String("fucomp")}, + {'f', QLatin1String("fucompp")}, + {'f', QLatin1String("fxam")}, + {'f', QLatin1String("fxch")}, + {'f', QLatin1String("fxtract")}, + {'f', QLatin1String("fyl2x")}, + {'f', QLatin1String("fyl2xp1")}, + {'g', QLatin1String("global")}, + {'g', QLatin1String("globl")}, + {'h', QLatin1String("hlt")}, + {'i', QLatin1String("ibts")}, + {'i', QLatin1String("icebp")}, + {'i', QLatin1String("idiv")}, + {'i', QLatin1String("idivl")}, + {'i', QLatin1String("idivq")}, + {'i', QLatin1String("imul")}, + {'i', QLatin1String("imull")}, + {'i', QLatin1String("imulq")}, + {'i', QLatin1String("in")}, + {'i', QLatin1String("inc")}, + {'i', QLatin1String("incbin")}, + {'i', QLatin1String("insb")}, + {'i', QLatin1String("insd")}, + {'i', QLatin1String("insw")}, + {'i', QLatin1String("int")}, + {'i', QLatin1String("int01")}, + {'i', QLatin1String("int1")}, + {'i', QLatin1String("int03")}, + {'i', QLatin1String("int3")}, + {'i', QLatin1String("into")}, + {'i', QLatin1String("invd")}, + {'i', QLatin1String("invpcid")}, + {'i', QLatin1String("invlpg")}, + {'i', QLatin1String("invlpga")}, + {'i', QLatin1String("iret")}, + {'i', QLatin1String("iretd")}, + {'i', QLatin1String("iretq")}, + {'i', QLatin1String("iretw")}, + {'j', QLatin1String("jcxz")}, + {'j', QLatin1String("jecxz")}, + {'j', QLatin1String("jrcxz")}, + {'j', QLatin1String("jmp")}, + {'j', QLatin1String("jmpe")}, + {'l', QLatin1String("lahf")}, + {'l', QLatin1String("lar")}, + {'l', QLatin1String("lds")}, + {'l', QLatin1String("lea")}, + {'l', QLatin1String("leal")}, + {'l', QLatin1String("leaq")}, + {'l', QLatin1String("leave")}, + {'l', QLatin1String("les")}, + {'l', QLatin1String("lfence")}, + {'l', QLatin1String("lfs")}, + {'l', QLatin1String("lgdt")}, + {'l', QLatin1String("lgs")}, + {'l', QLatin1String("lidt")}, + {'l', QLatin1String("lldt")}, + {'l', QLatin1String("lmsw")}, + {'l', QLatin1String("loadall")}, + {'l', QLatin1String("loadall286")}, + {'l', QLatin1String("lodsb")}, + {'l', QLatin1String("lodsd")}, + {'l', QLatin1String("lodsq")}, + {'l', QLatin1String("lodsw")}, + {'l', QLatin1String("loop")}, + {'l', QLatin1String("loope")}, + {'l', QLatin1String("loopne")}, + {'l', QLatin1String("loopnz")}, + {'l', QLatin1String("loopz")}, + {'l', QLatin1String("lsl")}, + {'l', QLatin1String("lss")}, + {'l', QLatin1String("ltr")}, + {'m', QLatin1String("mfence")}, + {'m', QLatin1String("monitor")}, + {'m', QLatin1String("mov")}, + {'m', QLatin1String("movd")}, + {'m', QLatin1String("movl")}, + {'m', QLatin1String("movq")}, + {'m', QLatin1String("movsb")}, + {'m', QLatin1String("movsd")}, + {'m', QLatin1String("movsq")}, + {'m', QLatin1String("movsw")}, + {'m', QLatin1String("movsx")}, + {'m', QLatin1String("movsxd")}, + {'m', QLatin1String("movzx")}, + {'m', QLatin1String("mul")}, + {'m', QLatin1String("mwait")}, + {'n', QLatin1String("neg")}, + {'n', QLatin1String("nop")}, + {'n', QLatin1String("not")}, + {'o', QLatin1String("or")}, + {'o', QLatin1String("out")}, + {'o', QLatin1String("outsb")}, + {'o', QLatin1String("outsd")}, + {'o', QLatin1String("outsw")}, + {'p', QLatin1String("packssdw")}, + {'p', QLatin1String("packsswb")}, + {'p', QLatin1String("packuswb")}, + {'p', QLatin1String("paddb")}, + {'p', QLatin1String("paddd")}, + {'p', QLatin1String("paddsb")}, + {'p', QLatin1String("paddsiw")}, + {'p', QLatin1String("paddsw")}, + {'p', QLatin1String("paddusb")}, + {'p', QLatin1String("paddusw")}, + {'p', QLatin1String("paddw")}, + {'p', QLatin1String("pand")}, + {'p', QLatin1String("pandn")}, + {'p', QLatin1String("pause")}, + {'p', QLatin1String("paveb")}, + {'p', QLatin1String("pavgusb")}, + {'p', QLatin1String("pcmpeqb")}, + {'p', QLatin1String("pcmpeqd")}, + {'p', QLatin1String("pcmpeqw")}, + {'p', QLatin1String("pcmpgtb")}, + {'p', QLatin1String("pcmpgtd")}, + {'p', QLatin1String("pcmpgtw")}, + {'p', QLatin1String("pdistib")}, + {'p', QLatin1String("pf2id")}, + {'p', QLatin1String("pfacc")}, + {'p', QLatin1String("pfadd")}, + {'p', QLatin1String("pfcmpeq")}, + {'p', QLatin1String("pfcmpge")}, + {'p', QLatin1String("pfcmpgt")}, + {'p', QLatin1String("pfmax")}, + {'p', QLatin1String("pfmin")}, + {'p', QLatin1String("pfmul")}, + {'p', QLatin1String("pfrcp")}, + {'p', QLatin1String("pfrcpit1")}, + {'p', QLatin1String("pfrcpit2")}, + {'p', QLatin1String("pfrsqit1")}, + {'p', QLatin1String("pfrsqrt")}, + {'p', QLatin1String("pfsub")}, + {'p', QLatin1String("pfsubr")}, + {'p', QLatin1String("pi2fd")}, + {'p', QLatin1String("pmachriw")}, + {'p', QLatin1String("pmaddwd")}, + {'p', QLatin1String("pmagw")}, + {'p', QLatin1String("pmulhriw")}, + {'p', QLatin1String("pmulhrwa")}, + {'p', QLatin1String("pmulhrwc")}, + {'p', QLatin1String("pmulhw")}, + {'p', QLatin1String("pmullw")}, + {'p', QLatin1String("pmvgezb")}, + {'p', QLatin1String("pmvlzb")}, + {'p', QLatin1String("pmvnzb")}, + {'p', QLatin1String("pmvzb")}, + {'p', QLatin1String("pop")}, + {'p', QLatin1String("popq")}, + {'p', QLatin1String("popa")}, + {'p', QLatin1String("popad")}, + {'p', QLatin1String("popaw")}, + {'p', QLatin1String("popf")}, + {'p', QLatin1String("popfd")}, + {'p', QLatin1String("popfq")}, + {'p', QLatin1String("popfw")}, + {'p', QLatin1String("por")}, + {'p', QLatin1String("prefetch")}, + {'p', QLatin1String("prefetchw")}, + {'p', QLatin1String("pslld")}, + {'p', QLatin1String("psllq")}, + {'p', QLatin1String("psllw")}, + {'p', QLatin1String("psrad")}, + {'p', QLatin1String("psraw")}, + {'p', QLatin1String("psrld")}, + {'p', QLatin1String("psrlq")}, + {'p', QLatin1String("psrlw")}, + {'p', QLatin1String("psubb")}, + {'p', QLatin1String("psubd")}, + {'p', QLatin1String("psubsb")}, + {'p', QLatin1String("psubsiw")}, + {'p', QLatin1String("psubsw")}, + {'p', QLatin1String("psubusb")}, + {'p', QLatin1String("psubusw")}, + {'p', QLatin1String("psubw")}, + {'p', QLatin1String("punpckhbw")}, + {'p', QLatin1String("punpckhdq")}, + {'p', QLatin1String("punpckhwd")}, + {'p', QLatin1String("punpcklbw")}, + {'p', QLatin1String("punpckldq")}, + {'p', QLatin1String("punpcklwd")}, + {'p', QLatin1String("push")}, + {'p', QLatin1String("pusha")}, + {'p', QLatin1String("pushq")}, + {'p', QLatin1String("pushad")}, + {'p', QLatin1String("pushaw")}, + {'p', QLatin1String("pushf")}, + {'p', QLatin1String("pushfd")}, + {'p', QLatin1String("pushfq")}, + {'p', QLatin1String("pushfw")}, + {'p', QLatin1String("pxor")}, + {'r', QLatin1String("rcl")}, + {'r', QLatin1String("rcr")}, + {'r', QLatin1String("rdshr")}, + {'r', QLatin1String("rdmsr")}, + {'r', QLatin1String("rdpmc")}, + {'r', QLatin1String("rdtsc")}, + {'r', QLatin1String("rdtscp")}, + {'r', QLatin1String("ret")}, + {'r', QLatin1String("retf")}, + {'r', QLatin1String("retn")}, + {'r', QLatin1String("retq")}, + {'r', QLatin1String("rol")}, + {'r', QLatin1String("ror")}, + {'r', QLatin1String("rdm")}, + {'r', QLatin1String("rsdc")}, + {'r', QLatin1String("rsldt")}, + {'r', QLatin1String("rsm")}, + {'r', QLatin1String("rsts")}, + {'s', QLatin1String("sahf")}, + {'s', QLatin1String("sal")}, + {'s', QLatin1String("sall")}, + {'s', QLatin1String("salq")}, + {'s', QLatin1String("salc")}, + {'s', QLatin1String("sar")}, + {'s', QLatin1String("sarl")}, + {'s', QLatin1String("sarq")}, + {'s', QLatin1String("sbb")}, + {'s', QLatin1String("scasb")}, + {'s', QLatin1String("scasd")}, + {'s', QLatin1String("scasq")}, + {'s', QLatin1String("scasw")}, + {'s', QLatin1String("sfence")}, + {'s', QLatin1String("sgdt")}, + {'s', QLatin1String("shl")}, + {'s', QLatin1String("shll")}, + {'s', QLatin1String("shllq")}, + {'s', QLatin1String("shld")}, + {'s', QLatin1String("shr")}, + {'s', QLatin1String("shrd")}, + {'s', QLatin1String("sidt")}, + {'s', QLatin1String("sldt")}, + {'s', QLatin1String("skinit")}, + {'s', QLatin1String("smi")}, + {'s', QLatin1String("smint")}, + {'s', QLatin1String("smintold")}, + {'s', QLatin1String("smsw")}, + {'s', QLatin1String("stc")}, + {'s', QLatin1String("std")}, + {'s', QLatin1String("sti")}, + {'s', QLatin1String("stosb")}, + {'s', QLatin1String("stosd")}, + {'s', QLatin1String("stosq")}, + {'s', QLatin1String("stosw")}, + {'s', QLatin1String("str")}, + {'s', QLatin1String("sub")}, + {'s', QLatin1String("svdc")}, + {'s', QLatin1String("svldt")}, + {'s', QLatin1String("svts")}, + {'s', QLatin1String("swapgs")}, + {'s', QLatin1String("syscall")}, + {'s', QLatin1String("sysenter")}, + {'s', QLatin1String("sysexit")}, + {'s', QLatin1String("sysret")}, + {'t', QLatin1String("test")}, + {'t', QLatin1String("testl")}, + {'t', QLatin1String("testq")}, + {'u', QLatin1String("ud0")}, + {'u', QLatin1String("ud1")}, + {'u', QLatin1String("ud2b")}, + {'u', QLatin1String("ud2")}, + {'u', QLatin1String("ud2a")}, + {'u', QLatin1String("umov")}, + {'v', QLatin1String("verr")}, + {'v', QLatin1String("verw")}, + {'f', QLatin1String("fwait")}, + {'w', QLatin1String("wbinvd")}, + {'w', QLatin1String("wrshr")}, + {'w', QLatin1String("wrmsr")}, + {'x', QLatin1String("xadd")}, + {'x', QLatin1String("xbts")}, + {'x', QLatin1String("xchg")}, + {'x', QLatin1String("xlatb")}, + {'x', QLatin1String("xlat")}, + {'x', QLatin1String("xor")}, + {'c', QLatin1String("cmove")}, + {'c', QLatin1String("cmovz")}, + {'c', QLatin1String("cmovne")}, + {'c', QLatin1String("cmovnz")}, + {'c', QLatin1String("cmova")}, + {'c', QLatin1String("cmovnbe")}, + {'c', QLatin1String("cmovae")}, + {'c', QLatin1String("cmovnb")}, + {'c', QLatin1String("cmovb")}, + {'c', QLatin1String("cmovnae")}, + {'c', QLatin1String("cmovbe")}, + {'c', QLatin1String("cmovna")}, + {'c', QLatin1String("cmovg")}, + {'c', QLatin1String("cmovnle")}, + {'c', QLatin1String("cmovge")}, + {'c', QLatin1String("cmovnl")}, + {'c', QLatin1String("cmovl")}, + {'c', QLatin1String("cmovnge")}, + {'c', QLatin1String("cmovle")}, + {'c', QLatin1String("cmovng")}, + {'c', QLatin1String("cmovc")}, + {'c', QLatin1String("cmovnc")}, + {'c', QLatin1String("cmovo")}, + {'c', QLatin1String("cmovno")}, + {'c', QLatin1String("cmovs")}, + {'c', QLatin1String("cmovns")}, + {'c', QLatin1String("cmovp")}, + {'c', QLatin1String("cmovpe")}, + {'c', QLatin1String("cmovnp")}, + {'c', QLatin1String("cmovpo")}, + {'j', QLatin1String("je")}, + {'j', QLatin1String("jz")}, + {'j', QLatin1String("jne")}, + {'j', QLatin1String("jnz")}, + {'j', QLatin1String("ja")}, + {'j', QLatin1String("jnbe")}, + {'j', QLatin1String("jae")}, + {'j', QLatin1String("jnb")}, + {'j', QLatin1String("jb")}, + {'j', QLatin1String("jnae")}, + {'j', QLatin1String("jbe")}, + {'j', QLatin1String("jna")}, + {'j', QLatin1String("jg")}, + {'j', QLatin1String("jnle")}, + {'j', QLatin1String("jge")}, + {'j', QLatin1String("jnl")}, + {'j', QLatin1String("jl")}, + {'j', QLatin1String("jnge")}, + {'j', QLatin1String("jle")}, + {'j', QLatin1String("jng")}, + {'j', QLatin1String("jc")}, + {'j', QLatin1String("jnc")}, + {'j', QLatin1String("jo")}, + {'j', QLatin1String("jno")}, + {'j', QLatin1String("js")}, + {'j', QLatin1String("jns")}, + {'j', QLatin1String("jpo")}, + {'j', QLatin1String("jnp")}, + {'j', QLatin1String("jpe")}, + {'j', QLatin1String("jp")}, + {'s', QLatin1String("sete")}, + {'s', QLatin1String("setz")}, + {'s', QLatin1String("setne")}, + {'s', QLatin1String("setnz")}, + {'s', QLatin1String("seta")}, + {'s', QLatin1String("setnbe")}, + {'s', QLatin1String("setae")}, + {'s', QLatin1String("setnb")}, + {'s', QLatin1String("setnc")}, + {'s', QLatin1String("setb")}, + {'s', QLatin1String("setnae")}, + {'s', QLatin1String("setcset")}, + {'s', QLatin1String("setbe")}, + {'s', QLatin1String("setna")}, + {'s', QLatin1String("setg")}, + {'s', QLatin1String("setnle")}, + {'s', QLatin1String("setge")}, + {'s', QLatin1String("setnl")}, + {'s', QLatin1String("setl")}, + {'s', QLatin1String("setnge")}, + {'s', QLatin1String("setle")}, + {'s', QLatin1String("setng")}, + {'s', QLatin1String("sets")}, + {'s', QLatin1String("setns")}, + {'s', QLatin1String("seto")}, + {'s', QLatin1String("setno")}, + {'s', QLatin1String("setpe")}, + {'s', QLatin1String("setp")}, + {'s', QLatin1String("setpo")}, + {'s', QLatin1String("setnp")}, + {'a', QLatin1String("addps")}, + {'a', QLatin1String("addss")}, + {'a', QLatin1String("andnps")}, + {'a', QLatin1String("andps")}, + {'c', QLatin1String("cmpeqps")}, + {'c', QLatin1String("cmpeqss")}, + {'c', QLatin1String("cmpleps")}, + {'c', QLatin1String("cmpless")}, + {'c', QLatin1String("cmpltps")}, + {'c', QLatin1String("cmpltss")}, + {'c', QLatin1String("cmpneqps")}, + {'c', QLatin1String("cmpneqss")}, + {'c', QLatin1String("cmpnleps")}, + {'c', QLatin1String("cmpnless")}, + {'c', QLatin1String("cmpnltps")}, + {'c', QLatin1String("cmpnltss")}, + {'c', QLatin1String("cmpordps")}, + {'c', QLatin1String("cmpordss")}, + {'c', QLatin1String("cmpunordps")}, + {'c', QLatin1String("cmpunordss")}, + {'c', QLatin1String("cmpps")}, + {'c', QLatin1String("cmpss")}, + {'c', QLatin1String("comiss")}, + {'c', QLatin1String("cvtpi2ps")}, + {'c', QLatin1String("cvtps2pi")}, + {'c', QLatin1String("cvtsi2ss")}, + {'c', QLatin1String("cvtss2si")}, + {'c', QLatin1String("cvttps2pi")}, + {'c', QLatin1String("cvttss2si")}, + {'d', QLatin1String("divps")}, + {'d', QLatin1String("divss")}, + {'l', QLatin1String("ldmxcsr")}, + {'m', QLatin1String("maxps")}, + {'m', QLatin1String("maxss")}, + {'m', QLatin1String("minps")}, + {'m', QLatin1String("minss")}, + {'m', QLatin1String("movaps")}, + {'m', QLatin1String("movhps")}, + {'m', QLatin1String("movlhps")}, + {'m', QLatin1String("movlps")}, + {'m', QLatin1String("movhlps")}, + {'m', QLatin1String("movmskps")}, + {'m', QLatin1String("movntps")}, + {'m', QLatin1String("movss")}, + {'m', QLatin1String("movups")}, + {'m', QLatin1String("mulps")}, + {'m', QLatin1String("mulss")}, + {'o', QLatin1String("orps")}, + {'r', QLatin1String("rcpps")}, + {'r', QLatin1String("rcpss")}, + {'r', QLatin1String("rsqrtps")}, + {'r', QLatin1String("rsqrtss")}, + {'s', QLatin1String("shufps")}, + {'s', QLatin1String("sqrtps")}, + {'s', QLatin1String("sqrtss")}, + {'s', QLatin1String("stmxcsr")}, + {'s', QLatin1String("subps")}, + {'s', QLatin1String("subss")}, + {'u', QLatin1String("ucomiss")}, + {'u', QLatin1String("unpckhps")}, + {'u', QLatin1String("unpcklps")}, + {'x', QLatin1String("xorps")}, + {'f', QLatin1String("fxrstor")}, + {'f', QLatin1String("fxrstor64")}, + {'f', QLatin1String("fxsave")}, + {'f', QLatin1String("fxsave64")}, + {'x', QLatin1String("xgetbv")}, + {'x', QLatin1String("xsetbv")}, + {'x', QLatin1String("xsave")}, + {'x', QLatin1String("xsave64")}, + {'x', QLatin1String("xsaveopt")}, + {'x', QLatin1String("xsaveopt64")}, + {'x', QLatin1String("xrstor")}, + {'x', QLatin1String("xrstor64")}, + {'p', QLatin1String("prefetchnta")}, + {'p', QLatin1String("prefetcht0")}, + {'p', QLatin1String("prefetcht1")}, + {'p', QLatin1String("prefetcht2")}, + {'m', QLatin1String("maskmovq")}, + {'m', QLatin1String("movntq")}, + {'p', QLatin1String("pavgb")}, + {'p', QLatin1String("pavgw")}, + {'p', QLatin1String("pextrw")}, + {'p', QLatin1String("pinsrw")}, + {'p', QLatin1String("pmaxsw")}, + {'p', QLatin1String("pmaxub")}, + {'p', QLatin1String("pminsw")}, + {'p', QLatin1String("pminub")}, + {'p', QLatin1String("pmovmskb")}, + {'p', QLatin1String("pmulhuw")}, + {'p', QLatin1String("psadbw")}, + {'p', QLatin1String("pshufw")}, + {'p', QLatin1String("pf2iw")}, + {'p', QLatin1String("pfnacc")}, + {'p', QLatin1String("pfpnacc")}, + {'p', QLatin1String("pi2fw")}, + {'p', QLatin1String("pswapd")}, + {'m', QLatin1String("maskmovdqu")}, + {'c', QLatin1String("clflush")}, + {'m', QLatin1String("movntdq")}, + {'m', QLatin1String("movnti")}, + {'m', QLatin1String("movntpd")}, + {'m', QLatin1String("movdqa")}, + {'m', QLatin1String("movdqu")}, + {'m', QLatin1String("movdq2q")}, + {'m', QLatin1String("movq2dq")}, + {'p', QLatin1String("paddq")}, + {'p', QLatin1String("pmuludq")}, + {'p', QLatin1String("pshufd")}, + {'p', QLatin1String("pshufhw")}, + {'p', QLatin1String("pshuflw")}, + {'p', QLatin1String("pslldq")}, + {'p', QLatin1String("psrldq")}, + {'p', QLatin1String("psubq")}, + {'p', QLatin1String("punpckhqdq")}, + {'p', QLatin1String("punpcklqdq")}, + {'a', QLatin1String("addpd")}, + {'a', QLatin1String("addsd")}, + {'a', QLatin1String("andnpd")}, + {'a', QLatin1String("andpd")}, + {'c', QLatin1String("cmpeqpd")}, + {'c', QLatin1String("cmpeqsd")}, + {'c', QLatin1String("cmplepd")}, + {'c', QLatin1String("cmplesd")}, + {'c', QLatin1String("cmpltpd")}, + {'c', QLatin1String("cmpltsd")}, + {'c', QLatin1String("cmpneqpd")}, + {'c', QLatin1String("cmpneqsd")}, + {'c', QLatin1String("cmpnlepd")}, + {'c', QLatin1String("cmpnlesd")}, + {'c', QLatin1String("cmpnltpd")}, + {'c', QLatin1String("cmpnltsd")}, + {'c', QLatin1String("cmpordpd")}, + {'c', QLatin1String("cmpordsd")}, + {'c', QLatin1String("cmpunordpd")}, + {'c', QLatin1String("cmpunordsd")}, + {'c', QLatin1String("cmppd")}, + {'c', QLatin1String("comisd")}, + {'c', QLatin1String("cvtdq2pd")}, + {'c', QLatin1String("cvtdq2ps")}, + {'c', QLatin1String("cvtpd2dq")}, + {'c', QLatin1String("cvtpd2pi")}, + {'c', QLatin1String("cvtpd2ps")}, + {'c', QLatin1String("cvtpi2pd")}, + {'c', QLatin1String("cvtps2dq")}, + {'c', QLatin1String("cvtps2pd")}, + {'c', QLatin1String("cvtsd2si")}, + {'c', QLatin1String("cvtsd2ss")}, + {'c', QLatin1String("cvtsi2sd")}, + {'c', QLatin1String("cvtss2sd")}, + {'c', QLatin1String("cvttpd2pi")}, + {'c', QLatin1String("cvttpd2dq")}, + {'c', QLatin1String("cvttps2dq")}, + {'c', QLatin1String("cvttsd2si")}, + {'d', QLatin1String("divpd")}, + {'d', QLatin1String("divsd")}, + {'m', QLatin1String("maxpd")}, + {'m', QLatin1String("maxsd")}, + {'m', QLatin1String("minpd")}, + {'m', QLatin1String("minsd")}, + {'m', QLatin1String("movapd")}, + {'m', QLatin1String("movhpd")}, + {'m', QLatin1String("movlpd")}, + {'m', QLatin1String("movmskpd")}, + {'m', QLatin1String("movupd")}, + {'m', QLatin1String("mulpd")}, + {'m', QLatin1String("mulsd")}, + {'o', QLatin1String("orpd")}, + {'s', QLatin1String("shufpd")}, + {'s', QLatin1String("sqrtpd")}, + {'s', QLatin1String("sqrtsd")}, + {'s', QLatin1String("subpd")}, + {'s', QLatin1String("subsd")}, + {'u', QLatin1String("ucomisd")}, + {'u', QLatin1String("unpckhpd")}, + {'u', QLatin1String("unpcklpd")}, + {'x', QLatin1String("xorpd")}, + {'a', QLatin1String("addsubpd")}, + {'a', QLatin1String("addsubps")}, + {'h', QLatin1String("haddpd")}, + {'h', QLatin1String("haddps")}, + {'h', QLatin1String("hsubpd")}, + {'h', QLatin1String("hsubps")}, + {'l', QLatin1String("lddqu")}, + {'m', QLatin1String("movddup")}, + {'m', QLatin1String("movshdup")}, + {'m', QLatin1String("movsldup")}, + {'c', QLatin1String("clgi")}, + {'s', QLatin1String("stgi")}, + {'v', QLatin1String("vmcall")}, + {'v', QLatin1String("vmclear")}, + {'v', QLatin1String("vmfunc")}, + {'v', QLatin1String("vmlaunch")}, + {'v', QLatin1String("vmload")}, + {'v', QLatin1String("vmmcall")}, + {'v', QLatin1String("vmptrld")}, + {'v', QLatin1String("vmptrst")}, + {'v', QLatin1String("vmread")}, + {'v', QLatin1String("vmresume")}, + {'v', QLatin1String("vmrun")}, + {'v', QLatin1String("vmsave")}, + {'v', QLatin1String("vmwrite")}, + {'v', QLatin1String("vmxoff")}, + {'v', QLatin1String("vmxon")}, + {'i', QLatin1String("invept")}, + {'i', QLatin1String("invvpid")}, + {'p', QLatin1String("pabsb")}, + {'p', QLatin1String("pabsw")}, + {'p', QLatin1String("pabsd")}, + {'p', QLatin1String("palignr")}, + {'p', QLatin1String("phaddw")}, + {'p', QLatin1String("phaddd")}, + {'p', QLatin1String("phaddsw")}, + {'p', QLatin1String("phsubw")}, + {'p', QLatin1String("phsubd")}, + {'p', QLatin1String("phsubsw")}, + {'p', QLatin1String("pmaddubsw")}, + {'p', QLatin1String("pmulhrsw")}, + {'p', QLatin1String("pshufb")}, + {'p', QLatin1String("psignb")}, + {'p', QLatin1String("psignw")}, + {'p', QLatin1String("psignd")}, + {'e', QLatin1String("extrq")}, + {'i', QLatin1String("insertq")}, + {'m', QLatin1String("movntsd")}, + {'m', QLatin1String("movntss")}, + {'l', QLatin1String("lzcnt")}, + {'b', QLatin1String("blendpd")}, + {'b', QLatin1String("blendps")}, + {'b', QLatin1String("blendvpd")}, + {'b', QLatin1String("blendvps")}, + {'d', QLatin1String("dppd")}, + {'d', QLatin1String("dpps")}, + {'e', QLatin1String("extractps")}, + {'i', QLatin1String("insertps")}, + {'m', QLatin1String("movntdqa")}, + {'m', QLatin1String("mpsadbw")}, + {'p', QLatin1String("packusdw")}, + {'p', QLatin1String("pblendvb")}, + {'p', QLatin1String("pblendw")}, + {'p', QLatin1String("pcmpeqq")}, + {'p', QLatin1String("pextrb")}, + {'p', QLatin1String("pextrd")}, + {'p', QLatin1String("pextrq")}, + {'p', QLatin1String("phminposuw")}, + {'p', QLatin1String("pinsrb")}, + {'p', QLatin1String("pinsrd")}, + {'p', QLatin1String("pinsrq")}, + {'p', QLatin1String("pmaxsb")}, + {'p', QLatin1String("pmaxsd")}, + {'p', QLatin1String("pmaxud")}, + {'p', QLatin1String("pmaxuw")}, + {'p', QLatin1String("pminsb")}, + {'p', QLatin1String("pminsd")}, + {'p', QLatin1String("pminud")}, + {'p', QLatin1String("pminuw")}, + {'p', QLatin1String("pmovsxbw")}, + {'p', QLatin1String("pmovsxbd")}, + {'p', QLatin1String("pmovsxbq")}, + {'p', QLatin1String("pmovsxwd")}, + {'p', QLatin1String("pmovsxwq")}, + {'p', QLatin1String("pmovsxdq")}, + {'p', QLatin1String("pmovzxbw")}, + {'p', QLatin1String("pmovzxbd")}, + {'p', QLatin1String("pmovzxbq")}, + {'p', QLatin1String("pmovzxwd")}, + {'p', QLatin1String("pmovzxwq")}, + {'p', QLatin1String("pmovzxdq")}, + {'p', QLatin1String("pmuldq")}, + {'p', QLatin1String("pmulld")}, + {'p', QLatin1String("ptest")}, + {'r', QLatin1String("roundpd")}, + {'r', QLatin1String("roundps")}, + {'r', QLatin1String("roundsd")}, + {'r', QLatin1String("roundss")}, + {'c', QLatin1String("crc32")}, + {'p', QLatin1String("pcmpestri")}, + {'p', QLatin1String("pcmpestrm")}, + {'p', QLatin1String("pcmpistri")}, + {'p', QLatin1String("pcmpistrm")}, + {'p', QLatin1String("pcmpgtq")}, + {'p', QLatin1String("popcnt")}, + {'g', QLatin1String("getsec")}, + {'p', QLatin1String("pfrcpv")}, + {'p', QLatin1String("pfrsqrtv")}, + {'m', QLatin1String("movbe")}, + {'a', QLatin1String("aesenc")}, + {'a', QLatin1String("aesenclast")}, + {'a', QLatin1String("aesdec")}, + {'a', QLatin1String("aesdeclast")}, + {'a', QLatin1String("aesimc")}, + {'a', QLatin1String("aeskeygenassist")}, + {'v', QLatin1String("vaesenc")}, + {'v', QLatin1String("vaesenclast")}, + {'v', QLatin1String("vaesdec")}, + {'v', QLatin1String("vaesdeclast")}, + {'v', QLatin1String("vaesimc")}, + {'v', QLatin1String("vaeskeygenassist")}, + {'v', QLatin1String("vaddpd")}, + {'v', QLatin1String("vaddps")}, + {'v', QLatin1String("vaddsd")}, + {'v', QLatin1String("vaddss")}, + {'v', QLatin1String("vaddsubpd")}, + {'v', QLatin1String("vaddsubps")}, + {'v', QLatin1String("vandpd")}, + {'v', QLatin1String("vandps")}, + {'v', QLatin1String("vandnpd")}, + {'v', QLatin1String("vandnps")}, + {'v', QLatin1String("vblendpd")}, + {'v', QLatin1String("vblendps")}, + {'v', QLatin1String("vblendvpd")}, + {'v', QLatin1String("vblendvps")}, + {'v', QLatin1String("vbroadcastss")}, + {'v', QLatin1String("vbroadcastsd")}, + {'v', QLatin1String("vbroadcastf128")}, + {'v', QLatin1String("vcmpeq_ospd")}, + {'v', QLatin1String("vcmpeqpd")}, + {'v', QLatin1String("vcmplt_ospd")}, + {'v', QLatin1String("vcmpltpd")}, + {'v', QLatin1String("vcmple_ospd")}, + {'v', QLatin1String("vcmplepd")}, + {'v', QLatin1String("vcmpunord_qpd")}, + {'v', QLatin1String("vcmpunordpd")}, + {'v', QLatin1String("vcmpneq_uqpd")}, + {'v', QLatin1String("vcmpneqpd")}, + {'v', QLatin1String("vcmpnlt_uspd")}, + {'v', QLatin1String("vcmpnltpd")}, + {'v', QLatin1String("vcmpnle_uspd")}, + {'v', QLatin1String("vcmpnlepd")}, + {'v', QLatin1String("vcmpord_qpd")}, + {'v', QLatin1String("vcmpordpd")}, + {'v', QLatin1String("vcmpeq_uqpd")}, + {'v', QLatin1String("vcmpnge_uspd")}, + {'v', QLatin1String("vcmpngepd")}, + {'v', QLatin1String("vcmpngt_uspd")}, + {'v', QLatin1String("vcmpngtpd")}, + {'v', QLatin1String("vcmpfalse_oqpd")}, + {'v', QLatin1String("vcmpfalsepd")}, + {'v', QLatin1String("vcmpneq_oqpd")}, + {'v', QLatin1String("vcmpge_ospd")}, + {'v', QLatin1String("vcmpgepd")}, + {'v', QLatin1String("vcmpgt_ospd")}, + {'v', QLatin1String("vcmpgtpd")}, + {'v', QLatin1String("vcmptrue_uqpd")}, + {'v', QLatin1String("vcmptruepd")}, + {'v', QLatin1String("vcmplt_oqpd")}, + {'v', QLatin1String("vcmple_oqpd")}, + {'v', QLatin1String("vcmpunord_spd")}, + {'v', QLatin1String("vcmpneq_uspd")}, + {'v', QLatin1String("vcmpnlt_uqpd")}, + {'v', QLatin1String("vcmpnle_uqpd")}, + {'v', QLatin1String("vcmpord_spd")}, + {'v', QLatin1String("vcmpeq_uspd")}, + {'v', QLatin1String("vcmpnge_uqpd")}, + {'v', QLatin1String("vcmpngt_uqpd")}, + {'v', QLatin1String("vcmpfalse_ospd")}, + {'v', QLatin1String("vcmpneq_ospd")}, + {'v', QLatin1String("vcmpge_oqpd")}, + {'v', QLatin1String("vcmpgt_oqpd")}, + {'v', QLatin1String("vcmptrue_uspd")}, + {'v', QLatin1String("vcmppd")}, + {'v', QLatin1String("vcmpeq_osps")}, + {'v', QLatin1String("vcmpeqps")}, + {'v', QLatin1String("vcmplt_osps")}, + {'v', QLatin1String("vcmpltps")}, + {'v', QLatin1String("vcmple_osps")}, + {'v', QLatin1String("vcmpleps")}, + {'v', QLatin1String("vcmpunord_qps")}, + {'v', QLatin1String("vcmpunordps")}, + {'v', QLatin1String("vcmpneq_uqps")}, + {'v', QLatin1String("vcmpneqps")}, + {'v', QLatin1String("vcmpnlt_usps")}, + {'v', QLatin1String("vcmpnltps")}, + {'v', QLatin1String("vcmpnle_usps")}, + {'v', QLatin1String("vcmpnleps")}, + {'v', QLatin1String("vcmpord_qps")}, + {'v', QLatin1String("vcmpordps")}, + {'v', QLatin1String("vcmpeq_uqps")}, + {'v', QLatin1String("vcmpnge_usps")}, + {'v', QLatin1String("vcmpngeps")}, + {'v', QLatin1String("vcmpngt_usps")}, + {'v', QLatin1String("vcmpngtps")}, + {'v', QLatin1String("vcmpfalse_oqps")}, + {'v', QLatin1String("vcmpfalseps")}, + {'v', QLatin1String("vcmpneq_oqps")}, + {'v', QLatin1String("vcmpge_osps")}, + {'v', QLatin1String("vcmpgeps")}, + {'v', QLatin1String("vcmpgt_osps")}, + {'v', QLatin1String("vcmpgtps")}, + {'v', QLatin1String("vcmptrue_uqps")}, + {'v', QLatin1String("vcmptrueps")}, + {'v', QLatin1String("vcmplt_oqps")}, + {'v', QLatin1String("vcmple_oqps")}, + {'v', QLatin1String("vcmpunord_sps")}, + {'v', QLatin1String("vcmpneq_usps")}, + {'v', QLatin1String("vcmpnlt_uqps")}, + {'v', QLatin1String("vcmpnle_uqps")}, + {'v', QLatin1String("vcmpord_sps")}, + {'v', QLatin1String("vcmpeq_usps")}, + {'v', QLatin1String("vcmpnge_uqps")}, + {'v', QLatin1String("vcmpngt_uqps")}, + {'v', QLatin1String("vcmpfalse_osps")}, + {'v', QLatin1String("vcmpneq_osps")}, + {'v', QLatin1String("vcmpge_oqps")}, + {'v', QLatin1String("vcmpgt_oqps")}, + {'v', QLatin1String("vcmptrue_usps")}, + {'v', QLatin1String("vcmpps")}, + {'v', QLatin1String("vcmpeq_ossd")}, + {'v', QLatin1String("vcmpeqsd")}, + {'v', QLatin1String("vcmplt_ossd")}, + {'v', QLatin1String("vcmpltsd")}, + {'v', QLatin1String("vcmple_ossd")}, + {'v', QLatin1String("vcmplesd")}, + {'v', QLatin1String("vcmpunord_qsd")}, + {'v', QLatin1String("vcmpunordsd")}, + {'v', QLatin1String("vcmpneq_uqsd")}, + {'v', QLatin1String("vcmpneqsd")}, + {'v', QLatin1String("vcmpnlt_ussd")}, + {'v', QLatin1String("vcmpnltsd")}, + {'v', QLatin1String("vcmpnle_ussd")}, + {'v', QLatin1String("vcmpnlesd")}, + {'v', QLatin1String("vcmpord_qsd")}, + {'v', QLatin1String("vcmpordsd")}, + {'v', QLatin1String("vcmpeq_uqsd")}, + {'v', QLatin1String("vcmpnge_ussd")}, + {'v', QLatin1String("vcmpngesd")}, + {'v', QLatin1String("vcmpngt_ussd")}, + {'v', QLatin1String("vcmpngtsd")}, + {'v', QLatin1String("vcmpfalse_oqsd")}, + {'v', QLatin1String("vcmpfalsesd")}, + {'v', QLatin1String("vcmpneq_oqsd")}, + {'v', QLatin1String("vcmpge_ossd")}, + {'v', QLatin1String("vcmpgesd")}, + {'v', QLatin1String("vcmpgt_ossd")}, + {'v', QLatin1String("vcmpgtsd")}, + {'v', QLatin1String("vcmptrue_uqsd")}, + {'v', QLatin1String("vcmptruesd")}, + {'v', QLatin1String("vcmplt_oqsd")}, + {'v', QLatin1String("vcmple_oqsd")}, + {'v', QLatin1String("vcmpunord_ssd")}, + {'v', QLatin1String("vcmpneq_ussd")}, + {'v', QLatin1String("vcmpnlt_uqsd")}, + {'v', QLatin1String("vcmpnle_uqsd")}, + {'v', QLatin1String("vcmpord_ssd")}, + {'v', QLatin1String("vcmpeq_ussd")}, + {'v', QLatin1String("vcmpnge_uqsd")}, + {'v', QLatin1String("vcmpngt_uqsd")}, + {'v', QLatin1String("vcmpfalse_ossd")}, + {'v', QLatin1String("vcmpneq_ossd")}, + {'v', QLatin1String("vcmpge_oqsd")}, + {'v', QLatin1String("vcmpgt_oqsd")}, + {'v', QLatin1String("vcmptrue_ussd")}, + {'v', QLatin1String("vcmpsd")}, + {'v', QLatin1String("vcmpeq_osss")}, + {'v', QLatin1String("vcmpeqss")}, + {'v', QLatin1String("vcmplt_osss")}, + {'v', QLatin1String("vcmpltss")}, + {'v', QLatin1String("vcmple_osss")}, + {'v', QLatin1String("vcmpless")}, + {'v', QLatin1String("vcmpunord_qss")}, + {'v', QLatin1String("vcmpunordss")}, + {'v', QLatin1String("vcmpneq_uqss")}, + {'v', QLatin1String("vcmpneqss")}, + {'v', QLatin1String("vcmpnlt_usss")}, + {'v', QLatin1String("vcmpnltss")}, + {'v', QLatin1String("vcmpnle_usss")}, + {'v', QLatin1String("vcmpnless")}, + {'v', QLatin1String("vcmpord_qss")}, + {'v', QLatin1String("vcmpordss")}, + {'v', QLatin1String("vcmpeq_uqss")}, + {'v', QLatin1String("vcmpnge_usss")}, + {'v', QLatin1String("vcmpngess")}, + {'v', QLatin1String("vcmpngt_usss")}, + {'v', QLatin1String("vcmpngtss")}, + {'v', QLatin1String("vcmpfalse_oqss")}, + {'v', QLatin1String("vcmpfalsess")}, + {'v', QLatin1String("vcmpneq_oqss")}, + {'v', QLatin1String("vcmpge_osss")}, + {'v', QLatin1String("vcmpgess")}, + {'v', QLatin1String("vcmpgt_osss")}, + {'v', QLatin1String("vcmpgtss")}, + {'v', QLatin1String("vcmptrue_uqss")}, + {'v', QLatin1String("vcmptruess")}, + {'v', QLatin1String("vcmplt_oqss")}, + {'v', QLatin1String("vcmple_oqss")}, + {'v', QLatin1String("vcmpunord_sss")}, + {'v', QLatin1String("vcmpneq_usss")}, + {'v', QLatin1String("vcmpnlt_uqss")}, + {'v', QLatin1String("vcmpnle_uqss")}, + {'v', QLatin1String("vcmpord_sss")}, + {'v', QLatin1String("vcmpeq_usss")}, + {'v', QLatin1String("vcmpnge_uqss")}, + {'v', QLatin1String("vcmpngt_uqss")}, + {'v', QLatin1String("vcmpfalse_osss")}, + {'v', QLatin1String("vcmpneq_osss")}, + {'v', QLatin1String("vcmpge_oqss")}, + {'v', QLatin1String("vcmpgt_oqss")}, + {'v', QLatin1String("vcmptrue_usss")}, + {'v', QLatin1String("vcmpss")}, + {'v', QLatin1String("vcomisd")}, + {'v', QLatin1String("vcomiss")}, + {'v', QLatin1String("vcvtdq2pd")}, + {'v', QLatin1String("vcvtdq2ps")}, + {'v', QLatin1String("vcvtpd2dq")}, + {'v', QLatin1String("vcvtpd2ps")}, + {'v', QLatin1String("vcvtps2dq")}, + {'v', QLatin1String("vcvtps2pd")}, + {'v', QLatin1String("vcvtsd2si")}, + {'v', QLatin1String("vcvtsd2ss")}, + {'v', QLatin1String("vcvtsi2sd")}, + {'v', QLatin1String("vcvtsi2ss")}, + {'v', QLatin1String("vcvtss2sd")}, + {'v', QLatin1String("vcvtss2si")}, + {'v', QLatin1String("vcvttpd2dq")}, + {'v', QLatin1String("vcvttps2dq")}, + {'v', QLatin1String("vcvttsd2si")}, + {'v', QLatin1String("vcvttss2si")}, + {'v', QLatin1String("vdivpd")}, + {'v', QLatin1String("vdivps")}, + {'v', QLatin1String("vdivsd")}, + {'v', QLatin1String("vdivss")}, + {'v', QLatin1String("vdppd")}, + {'v', QLatin1String("vdpps")}, + {'v', QLatin1String("vextractf128")}, + {'v', QLatin1String("vextractps")}, + {'v', QLatin1String("vhaddpd")}, + {'v', QLatin1String("vhaddps")}, + {'v', QLatin1String("vhsubpd")}, + {'v', QLatin1String("vhsubps")}, + {'v', QLatin1String("vinsertf128")}, + {'v', QLatin1String("vinsertps")}, + {'v', QLatin1String("vlddqu")}, + {'v', QLatin1String("vldqqu")}, + {'v', QLatin1String("vldmxcsr")}, + {'v', QLatin1String("vmaskmovdqu")}, + {'v', QLatin1String("vmaskmovps")}, + {'v', QLatin1String("vmaskmovpd")}, + {'v', QLatin1String("vmaxpd")}, + {'v', QLatin1String("vmaxps")}, + {'v', QLatin1String("vmaxsd")}, + {'v', QLatin1String("vmaxss")}, + {'v', QLatin1String("vminpd")}, + {'v', QLatin1String("vminps")}, + {'v', QLatin1String("vminsd")}, + {'v', QLatin1String("vminss")}, + {'v', QLatin1String("vmovapd")}, + {'v', QLatin1String("vmovaps")}, + {'v', QLatin1String("vmovd")}, + {'v', QLatin1String("vmovq")}, + {'v', QLatin1String("vmovddup")}, + {'v', QLatin1String("vmovdqa")}, + {'v', QLatin1String("vmovqqa")}, + {'v', QLatin1String("vmovdqu")}, + {'v', QLatin1String("vmovqqu")}, + {'v', QLatin1String("vmovhlps")}, + {'v', QLatin1String("vmovhpd")}, + {'v', QLatin1String("vmovhps")}, + {'v', QLatin1String("vmovlhps")}, + {'v', QLatin1String("vmovlpd")}, + {'v', QLatin1String("vmovlps")}, + {'v', QLatin1String("vmovmskpd")}, + {'v', QLatin1String("vmovmskps")}, + {'v', QLatin1String("vmovntdq")}, + {'v', QLatin1String("vmovntqq")}, + {'v', QLatin1String("vmovntdqa")}, + {'v', QLatin1String("vmovntpd")}, + {'v', QLatin1String("vmovntps")}, + {'v', QLatin1String("vmovsd")}, + {'v', QLatin1String("vmovshdup")}, + {'v', QLatin1String("vmovsldup")}, + {'v', QLatin1String("vmovss")}, + {'v', QLatin1String("vmovupd")}, + {'v', QLatin1String("vmovups")}, + {'v', QLatin1String("vmpsadbw")}, + {'v', QLatin1String("vmulpd")}, + {'v', QLatin1String("vmulps")}, + {'v', QLatin1String("vmulsd")}, + {'v', QLatin1String("vmulss")}, + {'v', QLatin1String("vorpd")}, + {'v', QLatin1String("vorps")}, + {'v', QLatin1String("vpabsb")}, + {'v', QLatin1String("vpabsw")}, + {'v', QLatin1String("vpabsd")}, + {'v', QLatin1String("vpacksswb")}, + {'v', QLatin1String("vpackssdw")}, + {'v', QLatin1String("vpackuswb")}, + {'v', QLatin1String("vpackusdw")}, + {'v', QLatin1String("vpaddb")}, + {'v', QLatin1String("vpaddw")}, + {'v', QLatin1String("vpaddd")}, + {'v', QLatin1String("vpaddq")}, + {'v', QLatin1String("vpaddsb")}, + {'v', QLatin1String("vpaddsw")}, + {'v', QLatin1String("vpaddusb")}, + {'v', QLatin1String("vpaddusw")}, + {'v', QLatin1String("vpalignr")}, + {'v', QLatin1String("vpand")}, + {'v', QLatin1String("vpandn")}, + {'v', QLatin1String("vpavgb")}, + {'v', QLatin1String("vpavgw")}, + {'v', QLatin1String("vpblendvb")}, + {'v', QLatin1String("vpblendw")}, + {'v', QLatin1String("vpcmpestri")}, + {'v', QLatin1String("vpcmpestrm")}, + {'v', QLatin1String("vpcmpistri")}, + {'v', QLatin1String("vpcmpistrm")}, + {'v', QLatin1String("vpcmpeqb")}, + {'v', QLatin1String("vpcmpeqw")}, + {'v', QLatin1String("vpcmpeqd")}, + {'v', QLatin1String("vpcmpeqq")}, + {'v', QLatin1String("vpcmpgtb")}, + {'v', QLatin1String("vpcmpgtw")}, + {'v', QLatin1String("vpcmpgtd")}, + {'v', QLatin1String("vpcmpgtq")}, + {'v', QLatin1String("vpermilpd")}, + {'v', QLatin1String("vpermilps")}, + {'v', QLatin1String("vperm2f128")}, + {'v', QLatin1String("vpextrb")}, + {'v', QLatin1String("vpextrw")}, + {'v', QLatin1String("vpextrd")}, + {'v', QLatin1String("vpextrq")}, + {'v', QLatin1String("vphaddw")}, + {'v', QLatin1String("vphaddd")}, + {'v', QLatin1String("vphaddsw")}, + {'v', QLatin1String("vphminposuw")}, + {'v', QLatin1String("vphsubw")}, + {'v', QLatin1String("vphsubd")}, + {'v', QLatin1String("vphsubsw")}, + {'v', QLatin1String("vpinsrb")}, + {'v', QLatin1String("vpinsrw")}, + {'v', QLatin1String("vpinsrd")}, + {'v', QLatin1String("vpinsrq")}, + {'v', QLatin1String("vpmaddwd")}, + {'v', QLatin1String("vpmaddubsw")}, + {'v', QLatin1String("vpmaxsb")}, + {'v', QLatin1String("vpmaxsw")}, + {'v', QLatin1String("vpmaxsd")}, + {'v', QLatin1String("vpmaxub")}, + {'v', QLatin1String("vpmaxuw")}, + {'v', QLatin1String("vpmaxud")}, + {'v', QLatin1String("vpminsb")}, + {'v', QLatin1String("vpminsw")}, + {'v', QLatin1String("vpminsd")}, + {'v', QLatin1String("vpminub")}, + {'v', QLatin1String("vpminuw")}, + {'v', QLatin1String("vpminud")}, + {'v', QLatin1String("vpmovmskb")}, + {'v', QLatin1String("vpmovsxbw")}, + {'v', QLatin1String("vpmovsxbd")}, + {'v', QLatin1String("vpmovsxbq")}, + {'v', QLatin1String("vpmovsxwd")}, + {'v', QLatin1String("vpmovsxwq")}, + {'v', QLatin1String("vpmovsxdq")}, + {'v', QLatin1String("vpmovzxbw")}, + {'v', QLatin1String("vpmovzxbd")}, + {'v', QLatin1String("vpmovzxbq")}, + {'v', QLatin1String("vpmovzxwd")}, + {'v', QLatin1String("vpmovzxwq")}, + {'v', QLatin1String("vpmovzxdq")}, + {'v', QLatin1String("vpmulhuw")}, + {'v', QLatin1String("vpmulhrsw")}, + {'v', QLatin1String("vpmulhw")}, + {'v', QLatin1String("vpmullw")}, + {'v', QLatin1String("vpmulld")}, + {'v', QLatin1String("vpmuludq")}, + {'v', QLatin1String("vpmuldq")}, + {'v', QLatin1String("vpor")}, + {'v', QLatin1String("vpsadbw")}, + {'v', QLatin1String("vpshufb")}, + {'v', QLatin1String("vpshufd")}, + {'v', QLatin1String("vpshufhw")}, + {'v', QLatin1String("vpshuflw")}, + {'v', QLatin1String("vpsignb")}, + {'v', QLatin1String("vpsignw")}, + {'v', QLatin1String("vpsignd")}, + {'v', QLatin1String("vpslldq")}, + {'v', QLatin1String("vpsrldq")}, + {'v', QLatin1String("vpsllw")}, + {'v', QLatin1String("vpslld")}, + {'v', QLatin1String("vpsllq")}, + {'v', QLatin1String("vpsraw")}, + {'v', QLatin1String("vpsrad")}, + {'v', QLatin1String("vpsrlw")}, + {'v', QLatin1String("vpsrld")}, + {'v', QLatin1String("vpsrlq")}, + {'v', QLatin1String("vptest")}, + {'v', QLatin1String("vpsubb")}, + {'v', QLatin1String("vpsubw")}, + {'v', QLatin1String("vpsubd")}, + {'v', QLatin1String("vpsubq")}, + {'v', QLatin1String("vpsubsb")}, + {'v', QLatin1String("vpsubsw")}, + {'v', QLatin1String("vpsubusb")}, + {'v', QLatin1String("vpsubusw")}, + {'v', QLatin1String("vpunpckhbw")}, + {'v', QLatin1String("vpunpckhwd")}, + {'v', QLatin1String("vpunpckhdq")}, + {'v', QLatin1String("vpunpckhqdq")}, + {'v', QLatin1String("vpunpcklbw")}, + {'v', QLatin1String("vpunpcklwd")}, + {'v', QLatin1String("vpunpckldq")}, + {'v', QLatin1String("vpunpcklqdq")}, + {'v', QLatin1String("vpxor")}, + {'v', QLatin1String("vrcpps")}, + {'v', QLatin1String("vrcpss")}, + {'v', QLatin1String("vrsqrtps")}, + {'v', QLatin1String("vrsqrtss")}, + {'v', QLatin1String("vroundpd")}, + {'v', QLatin1String("vroundps")}, + {'v', QLatin1String("vroundsd")}, + {'v', QLatin1String("vroundss")}, + {'v', QLatin1String("vshufpd")}, + {'v', QLatin1String("vshufps")}, + {'v', QLatin1String("vsqrtpd")}, + {'v', QLatin1String("vsqrtps")}, + {'v', QLatin1String("vsqrtsd")}, + {'v', QLatin1String("vsqrtss")}, + {'v', QLatin1String("vstmxcsr")}, + {'v', QLatin1String("vsubpd")}, + {'v', QLatin1String("vsubps")}, + {'v', QLatin1String("vsubsd")}, + {'v', QLatin1String("vsubss")}, + {'v', QLatin1String("vtestps")}, + {'v', QLatin1String("vtestpd")}, + {'v', QLatin1String("vucomisd")}, + {'v', QLatin1String("vucomiss")}, + {'v', QLatin1String("vunpckhpd")}, + {'v', QLatin1String("vunpckhps")}, + {'v', QLatin1String("vunpcklpd")}, + {'v', QLatin1String("vunpcklps")}, + {'v', QLatin1String("vxorpd")}, + {'v', QLatin1String("vxorps")}, + {'v', QLatin1String("vzeroall")}, + {'v', QLatin1String("vzeroupper")}, + {'p', QLatin1String("pclmullqlqdq")}, + {'p', QLatin1String("pclmulhqlqdq")}, + {'p', QLatin1String("pclmullqhqdq")}, + {'p', QLatin1String("pclmulhqhqdq")}, + {'p', QLatin1String("pclmulqdq")}, + {'v', QLatin1String("vpclmullqlqdq")}, + {'v', QLatin1String("vpclmulhqlqdq")}, + {'v', QLatin1String("vpclmullqhqdq")}, + {'v', QLatin1String("vpclmulhqhqdq")}, + {'v', QLatin1String("vpclmulqdq")}, + {'v', QLatin1String("vfmadd132ps")}, + {'v', QLatin1String("vfmadd132pd")}, + {'v', QLatin1String("vfmadd312ps")}, + {'v', QLatin1String("vfmadd312pd")}, + {'v', QLatin1String("vfmadd213ps")}, + {'v', QLatin1String("vfmadd213pd")}, + {'v', QLatin1String("vfmadd123ps")}, + {'v', QLatin1String("vfmadd123pd")}, + {'v', QLatin1String("vfmadd231ps")}, + {'v', QLatin1String("vfmadd231pd")}, + {'v', QLatin1String("vfmadd321ps")}, + {'v', QLatin1String("vfmadd321pd")}, + {'v', QLatin1String("vfmaddsub132ps")}, + {'v', QLatin1String("vfmaddsub132pd")}, + {'v', QLatin1String("vfmaddsub312ps")}, + {'v', QLatin1String("vfmaddsub312pd")}, + {'v', QLatin1String("vfmaddsub213ps")}, + {'v', QLatin1String("vfmaddsub213pd")}, + {'v', QLatin1String("vfmaddsub123ps")}, + {'v', QLatin1String("vfmaddsub123pd")}, + {'v', QLatin1String("vfmaddsub231ps")}, + {'v', QLatin1String("vfmaddsub231pd")}, + {'v', QLatin1String("vfmaddsub321ps")}, + {'v', QLatin1String("vfmaddsub321pd")}, + {'v', QLatin1String("vfmsub132ps")}, + {'v', QLatin1String("vfmsub132pd")}, + {'v', QLatin1String("vfmsub312ps")}, + {'v', QLatin1String("vfmsub312pd")}, + {'v', QLatin1String("vfmsub213ps")}, + {'v', QLatin1String("vfmsub213pd")}, + {'v', QLatin1String("vfmsub123ps")}, + {'v', QLatin1String("vfmsub123pd")}, + {'v', QLatin1String("vfmsub231ps")}, + {'v', QLatin1String("vfmsub231pd")}, + {'v', QLatin1String("vfmsub321ps")}, + {'v', QLatin1String("vfmsub321pd")}, + {'v', QLatin1String("vfmsubadd132ps")}, + {'v', QLatin1String("vfmsubadd132pd")}, + {'v', QLatin1String("vfmsubadd312ps")}, + {'v', QLatin1String("vfmsubadd312pd")}, + {'v', QLatin1String("vfmsubadd213ps")}, + {'v', QLatin1String("vfmsubadd213pd")}, + {'v', QLatin1String("vfmsubadd123ps")}, + {'v', QLatin1String("vfmsubadd123pd")}, + {'v', QLatin1String("vfmsubadd231ps")}, + {'v', QLatin1String("vfmsubadd231pd")}, + {'v', QLatin1String("vfmsubadd321ps")}, + {'v', QLatin1String("vfmsubadd321pd")}, + {'v', QLatin1String("vfnmadd132ps")}, + {'v', QLatin1String("vfnmadd132pd")}, + {'v', QLatin1String("vfnmadd312ps")}, + {'v', QLatin1String("vfnmadd312pd")}, + {'v', QLatin1String("vfnmadd213ps")}, + {'v', QLatin1String("vfnmadd213pd")}, + {'v', QLatin1String("vfnmadd123ps")}, + {'v', QLatin1String("vfnmadd123pd")}, + {'v', QLatin1String("vfnmadd231ps")}, + {'v', QLatin1String("vfnmadd231pd")}, + {'v', QLatin1String("vfnmadd321ps")}, + {'v', QLatin1String("vfnmadd321pd")}, + {'v', QLatin1String("vfnmsub132ps")}, + {'v', QLatin1String("vfnmsub132pd")}, + {'v', QLatin1String("vfnmsub312ps")}, + {'v', QLatin1String("vfnmsub312pd")}, + {'v', QLatin1String("vfnmsub213ps")}, + {'v', QLatin1String("vfnmsub213pd")}, + {'v', QLatin1String("vfnmsub123ps")}, + {'v', QLatin1String("vfnmsub123pd")}, + {'v', QLatin1String("vfnmsub231ps")}, + {'v', QLatin1String("vfnmsub231pd")}, + {'v', QLatin1String("vfnmsub321ps")}, + {'v', QLatin1String("vfnmsub321pd")}, + {'v', QLatin1String("vfmadd132ss")}, + {'v', QLatin1String("vfmadd132sd")}, + {'v', QLatin1String("vfmadd312ss")}, + {'v', QLatin1String("vfmadd312sd")}, + {'v', QLatin1String("vfmadd213ss")}, + {'v', QLatin1String("vfmadd213sd")}, + {'v', QLatin1String("vfmadd123ss")}, + {'v', QLatin1String("vfmadd123sd")}, + {'v', QLatin1String("vfmadd231ss")}, + {'v', QLatin1String("vfmadd231sd")}, + {'v', QLatin1String("vfmadd321ss")}, + {'v', QLatin1String("vfmadd321sd")}, + {'v', QLatin1String("vfmsub132ss")}, + {'v', QLatin1String("vfmsub132sd")}, + {'v', QLatin1String("vfmsub312ss")}, + {'v', QLatin1String("vfmsub312sd")}, + {'v', QLatin1String("vfmsub213ss")}, + {'v', QLatin1String("vfmsub213sd")}, + {'v', QLatin1String("vfmsub123ss")}, + {'v', QLatin1String("vfmsub123sd")}, + {'v', QLatin1String("vfmsub231ss")}, + {'v', QLatin1String("vfmsub231sd")}, + {'v', QLatin1String("vfmsub321ss")}, + {'v', QLatin1String("vfmsub321sd")}, + {'v', QLatin1String("vfnmadd132ss")}, + {'v', QLatin1String("vfnmadd132sd")}, + {'v', QLatin1String("vfnmadd312ss")}, + {'v', QLatin1String("vfnmadd312sd")}, + {'v', QLatin1String("vfnmadd213ss")}, + {'v', QLatin1String("vfnmadd213sd")}, + {'v', QLatin1String("vfnmadd123ss")}, + {'v', QLatin1String("vfnmadd123sd")}, + {'v', QLatin1String("vfnmadd231ss")}, + {'v', QLatin1String("vfnmadd231sd")}, + {'v', QLatin1String("vfnmadd321ss")}, + {'v', QLatin1String("vfnmadd321sd")}, + {'v', QLatin1String("vfnmsub132ss")}, + {'v', QLatin1String("vfnmsub132sd")}, + {'v', QLatin1String("vfnmsub312ss")}, + {'v', QLatin1String("vfnmsub312sd")}, + {'v', QLatin1String("vfnmsub213ss")}, + {'v', QLatin1String("vfnmsub213sd")}, + {'v', QLatin1String("vfnmsub123ss")}, + {'v', QLatin1String("vfnmsub123sd")}, + {'v', QLatin1String("vfnmsub231ss")}, + {'v', QLatin1String("vfnmsub231sd")}, + {'v', QLatin1String("vfnmsub321ss")}, + {'v', QLatin1String("vfnmsub321sd")}, + {'r', QLatin1String("rdfsbase")}, + {'r', QLatin1String("rdgsbase")}, + {'r', QLatin1String("rdrand")}, + {'w', QLatin1String("wrfsbase")}, + {'w', QLatin1String("wrgsbase")}, + {'v', QLatin1String("vcvtph2ps")}, + {'v', QLatin1String("vcvtps2ph")}, + {'a', QLatin1String("adcx")}, + {'a', QLatin1String("adox")}, + {'r', QLatin1String("rdseed")}, + {'c', QLatin1String("clac")}, + {'s', QLatin1String("stac")}, + {'x', QLatin1String("xstore")}, + {'x', QLatin1String("xcryptecb")}, + {'x', QLatin1String("xcryptcbc")}, + {'x', QLatin1String("xcryptctr")}, + {'x', QLatin1String("xcryptcfb")}, + {'x', QLatin1String("xcryptofb")}, + {'m', QLatin1String("montmul")}, + {'x', QLatin1String("xsha1")}, + {'x', QLatin1String("xsha256")}, + {'l', QLatin1String("llwpcb")}, + {'s', QLatin1String("slwpcb")}, + {'l', QLatin1String("lwpval")}, + {'l', QLatin1String("lwpins")}, + {'v', QLatin1String("vfmaddpd")}, + {'v', QLatin1String("vfmaddps")}, + {'v', QLatin1String("vfmaddsd")}, + {'v', QLatin1String("vfmaddss")}, + {'v', QLatin1String("vfmaddsubpd")}, + {'v', QLatin1String("vfmaddsubps")}, + {'v', QLatin1String("vfmsubaddpd")}, + {'v', QLatin1String("vfmsubaddps")}, + {'v', QLatin1String("vfmsubpd")}, + {'v', QLatin1String("vfmsubps")}, + {'v', QLatin1String("vfmsubsd")}, + {'v', QLatin1String("vfmsubss")}, + {'v', QLatin1String("vfnmaddpd")}, + {'v', QLatin1String("vfnmaddps")}, + {'v', QLatin1String("vfnmaddsd")}, + {'v', QLatin1String("vfnmaddss")}, + {'v', QLatin1String("vfnmsubpd")}, + {'v', QLatin1String("vfnmsubps")}, + {'v', QLatin1String("vfnmsubsd")}, + {'v', QLatin1String("vfnmsubss")}, + {'v', QLatin1String("vfrczpd")}, + {'v', QLatin1String("vfrczps")}, + {'v', QLatin1String("vfrczsd")}, + {'v', QLatin1String("vfrczss")}, + {'v', QLatin1String("vpcmov")}, + {'v', QLatin1String("vpcomb")}, + {'v', QLatin1String("vpcomd")}, + {'v', QLatin1String("vpcomq")}, + {'v', QLatin1String("vpcomub")}, + {'v', QLatin1String("vpcomud")}, + {'v', QLatin1String("vpcomuq")}, + {'v', QLatin1String("vpcomuw")}, + {'v', QLatin1String("vpcomw")}, + {'v', QLatin1String("vphaddbd")}, + {'v', QLatin1String("vphaddbq")}, + {'v', QLatin1String("vphaddbw")}, + {'v', QLatin1String("vphadddq")}, + {'v', QLatin1String("vphaddubd")}, + {'v', QLatin1String("vphaddubq")}, + {'v', QLatin1String("vphaddubw")}, + {'v', QLatin1String("vphaddudq")}, + {'v', QLatin1String("vphadduwd")}, + {'v', QLatin1String("vphadduwq")}, + {'v', QLatin1String("vphaddwd")}, + {'v', QLatin1String("vphaddwq")}, + {'v', QLatin1String("vphsubbw")}, + {'v', QLatin1String("vphsubdq")}, + {'v', QLatin1String("vphsubwd")}, + {'v', QLatin1String("vpmacsdd")}, + {'v', QLatin1String("vpmacsdqh")}, + {'v', QLatin1String("vpmacsdql")}, + {'v', QLatin1String("vpmacssdd")}, + {'v', QLatin1String("vpmacssdqh")}, + {'v', QLatin1String("vpmacssdql")}, + {'v', QLatin1String("vpmacsswd")}, + {'v', QLatin1String("vpmacssww")}, + {'v', QLatin1String("vpmacswd")}, + {'v', QLatin1String("vpmacsww")}, + {'v', QLatin1String("vpmadcsswd")}, + {'v', QLatin1String("vpmadcswd")}, + {'v', QLatin1String("vpperm")}, + {'v', QLatin1String("vprotb")}, + {'v', QLatin1String("vprotd")}, + {'v', QLatin1String("vprotq")}, + {'v', QLatin1String("vprotw")}, + {'v', QLatin1String("vpshab")}, + {'v', QLatin1String("vpshad")}, + {'v', QLatin1String("vpshaq")}, + {'v', QLatin1String("vpshaw")}, + {'v', QLatin1String("vpshlb")}, + {'v', QLatin1String("vpshld")}, + {'v', QLatin1String("vpshlq")}, + {'v', QLatin1String("vpshlw")}, + {'v', QLatin1String("vbroadcasti128")}, + {'v', QLatin1String("vpblendd")}, + {'v', QLatin1String("vpbroadcastb")}, + {'v', QLatin1String("vpbroadcastw")}, + {'v', QLatin1String("vpbroadcastd")}, + {'v', QLatin1String("vpbroadcastq")}, + {'v', QLatin1String("vpermd")}, + {'v', QLatin1String("vpermpd")}, + {'v', QLatin1String("vpermps")}, + {'v', QLatin1String("vpermq")}, + {'v', QLatin1String("vperm2i128")}, + {'v', QLatin1String("vextracti128")}, + {'v', QLatin1String("vinserti128")}, + {'v', QLatin1String("vpmaskmovd")}, + {'v', QLatin1String("vpmaskmovq")}, + {'v', QLatin1String("vpsllvd")}, + {'v', QLatin1String("vpsllvq")}, + {'v', QLatin1String("vpsravd")}, + {'v', QLatin1String("vpsrlvd")}, + {'v', QLatin1String("vpsrlvq")}, + {'v', QLatin1String("vgatherdpd")}, + {'v', QLatin1String("vgatherqpd")}, + {'v', QLatin1String("vgatherdps")}, + {'v', QLatin1String("vgatherqps")}, + {'v', QLatin1String("vpgatherdd")}, + {'v', QLatin1String("vpgatherqd")}, + {'v', QLatin1String("vpgatherdq")}, + {'v', QLatin1String("vpgatherqq")}, + {'x', QLatin1String("xabort")}, + {'x', QLatin1String("xbegin")}, + {'x', QLatin1String("xend")}, + {'x', QLatin1String("xtest")}, + {'a', QLatin1String("andn")}, + {'b', QLatin1String("bextr")}, + {'b', QLatin1String("blci")}, + {'b', QLatin1String("blcic")}, + {'b', QLatin1String("blsi")}, + {'b', QLatin1String("blsic")}, + {'b', QLatin1String("blcfill")}, + {'b', QLatin1String("blsfill")}, + {'b', QLatin1String("blcmsk")}, + {'b', QLatin1String("blsmsk")}, + {'b', QLatin1String("blsr")}, + {'b', QLatin1String("blcs")}, + {'b', QLatin1String("bzhi")}, + {'m', QLatin1String("mulx")}, + {'p', QLatin1String("pdep")}, + {'p', QLatin1String("pext")}, + {'r', QLatin1String("rorx")}, + {'s', QLatin1String("sarx")}, + {'s', QLatin1String("shlx")}, + {'s', QLatin1String("shrx")}, + {'t', QLatin1String("tzcnt")}, + {'t', QLatin1String("tzmsk")}, + {'t', QLatin1String("t1mskc")}, + {'v', QLatin1String("valignd")}, + {'v', QLatin1String("valignq")}, + {'v', QLatin1String("vblendmpd")}, + {'v', QLatin1String("vblendmps")}, + {'v', QLatin1String("vbroadcastf32x4")}, + {'v', QLatin1String("vbroadcastf64x4")}, + {'v', QLatin1String("vbroadcasti32x4")}, + {'v', QLatin1String("vbroadcasti64x4")}, + {'v', QLatin1String("vcompresspd")}, + {'v', QLatin1String("vcompressps")}, + {'v', QLatin1String("vcvtpd2udq")}, + {'v', QLatin1String("vcvtps2udq")}, + {'v', QLatin1String("vcvtsd2usi")}, + {'v', QLatin1String("vcvtss2usi")}, + {'v', QLatin1String("vcvttpd2udq")}, + {'v', QLatin1String("vcvttps2udq")}, + {'v', QLatin1String("vcvttsd2usi")}, + {'v', QLatin1String("vcvttss2usi")}, + {'v', QLatin1String("vcvtudq2pd")}, + {'v', QLatin1String("vcvtudq2ps")}, + {'v', QLatin1String("vcvtusi2sd")}, + {'v', QLatin1String("vcvtusi2ss")}, + {'v', QLatin1String("vexpandpd")}, + {'v', QLatin1String("vexpandps")}, + {'v', QLatin1String("vextractf32x4")}, + {'v', QLatin1String("vextractf64x4")}, + {'v', QLatin1String("vextracti32x4")}, + {'v', QLatin1String("vextracti64x4")}, + {'v', QLatin1String("vfixupimmpd")}, + {'v', QLatin1String("vfixupimmps")}, + {'v', QLatin1String("vfixupimmsd")}, + {'v', QLatin1String("vfixupimmss")}, + {'v', QLatin1String("vgetexppd")}, + {'v', QLatin1String("vgetexpps")}, + {'v', QLatin1String("vgetexpsd")}, + {'v', QLatin1String("vgetexpss")}, + {'v', QLatin1String("vgetmantpd")}, + {'v', QLatin1String("vgetmantps")}, + {'v', QLatin1String("vgetmantsd")}, + {'v', QLatin1String("vgetmantss")}, + {'v', QLatin1String("vinsertf32x4")}, + {'v', QLatin1String("vinsertf64x4")}, + {'v', QLatin1String("vinserti32x4")}, + {'v', QLatin1String("vinserti64x4")}, + {'v', QLatin1String("vmovdqa32")}, + {'v', QLatin1String("vmovdqa64")}, + {'v', QLatin1String("vmovdqu32")}, + {'v', QLatin1String("vmovdqu64")}, + {'v', QLatin1String("vpabsq")}, + {'v', QLatin1String("vpandd")}, + {'v', QLatin1String("vpandnd")}, + {'v', QLatin1String("vpandnq")}, + {'v', QLatin1String("vpandq")}, + {'v', QLatin1String("vpblendmd")}, + {'v', QLatin1String("vpblendmq")}, + {'v', QLatin1String("vpcmpltd")}, + {'v', QLatin1String("vpcmpled")}, + {'v', QLatin1String("vpcmpneqd")}, + {'v', QLatin1String("vpcmpnltd")}, + {'v', QLatin1String("vpcmpnled")}, + {'v', QLatin1String("vpcmpd")}, + {'v', QLatin1String("vpcmpltq")}, + {'v', QLatin1String("vpcmpleq")}, + {'v', QLatin1String("vpcmpneqq")}, + {'v', QLatin1String("vpcmpnltq")}, + {'v', QLatin1String("vpcmpnleq")}, + {'v', QLatin1String("vpcmpq")}, + {'v', QLatin1String("vpcmpequd")}, + {'v', QLatin1String("vpcmpltud")}, + {'v', QLatin1String("vpcmpleud")}, + {'v', QLatin1String("vpcmpnequd")}, + {'v', QLatin1String("vpcmpnltud")}, + {'v', QLatin1String("vpcmpnleud")}, + {'v', QLatin1String("vpcmpud")}, + {'v', QLatin1String("vpcmpequq")}, + {'v', QLatin1String("vpcmpltuq")}, + {'v', QLatin1String("vpcmpleuq")}, + {'v', QLatin1String("vpcmpnequq")}, + {'v', QLatin1String("vpcmpnltuq")}, + {'v', QLatin1String("vpcmpnleuq")}, + {'v', QLatin1String("vpcmpuq")}, + {'v', QLatin1String("vpcompressd")}, + {'v', QLatin1String("vpcompressq")}, + {'v', QLatin1String("vpermi2d")}, + {'v', QLatin1String("vpermi2pd")}, + {'v', QLatin1String("vpermi2ps")}, + {'v', QLatin1String("vpermi2q")}, + {'v', QLatin1String("vpermt2d")}, + {'v', QLatin1String("vpermt2pd")}, + {'v', QLatin1String("vpermt2ps")}, + {'v', QLatin1String("vpermt2q")}, + {'v', QLatin1String("vpexpandd")}, + {'v', QLatin1String("vpexpandq")}, + {'v', QLatin1String("vpmaxsq")}, + {'v', QLatin1String("vpmaxuq")}, + {'v', QLatin1String("vpminsq")}, + {'v', QLatin1String("vpminuq")}, + {'v', QLatin1String("vpmovdb")}, + {'v', QLatin1String("vpmovdw")}, + {'v', QLatin1String("vpmovqb")}, + {'v', QLatin1String("vpmovqd")}, + {'v', QLatin1String("vpmovqw")}, + {'v', QLatin1String("vpmovsdb")}, + {'v', QLatin1String("vpmovsdw")}, + {'v', QLatin1String("vpmovsqb")}, + {'v', QLatin1String("vpmovsqd")}, + {'v', QLatin1String("vpmovsqw")}, + {'v', QLatin1String("vpmovusdb")}, + {'v', QLatin1String("vpmovusdw")}, + {'v', QLatin1String("vpmovusqb")}, + {'v', QLatin1String("vpmovusqd")}, + {'v', QLatin1String("vpmovusqw")}, + {'v', QLatin1String("vpord")}, + {'v', QLatin1String("vporq")}, + {'v', QLatin1String("vprold")}, + {'v', QLatin1String("vprolq")}, + {'v', QLatin1String("vprolvd")}, + {'v', QLatin1String("vprolvq")}, + {'v', QLatin1String("vprord")}, + {'v', QLatin1String("vprorq")}, + {'v', QLatin1String("vprorvd")}, + {'v', QLatin1String("vprorvq")}, + {'v', QLatin1String("vpscatterdd")}, + {'v', QLatin1String("vpscatterdq")}, + {'v', QLatin1String("vpscatterqd")}, + {'v', QLatin1String("vpscatterqq")}, + {'v', QLatin1String("vpsraq")}, + {'v', QLatin1String("vpsravq")}, + {'v', QLatin1String("vpternlogd")}, + {'v', QLatin1String("vpternlogq")}, + {'v', QLatin1String("vptestmd")}, + {'v', QLatin1String("vptestmq")}, + {'v', QLatin1String("vptestnmd")}, + {'v', QLatin1String("vptestnmq")}, + {'v', QLatin1String("vpxord")}, + {'v', QLatin1String("vpxorq")}, + {'v', QLatin1String("vrcp14pd")}, + {'v', QLatin1String("vrcp14ps")}, + {'v', QLatin1String("vrcp14sd")}, + {'v', QLatin1String("vrcp14ss")}, + {'v', QLatin1String("vrndscalepd")}, + {'v', QLatin1String("vrndscaleps")}, + {'v', QLatin1String("vrndscalesd")}, + {'v', QLatin1String("vrndscaless")}, + {'v', QLatin1String("vrsqrt14pd")}, + {'v', QLatin1String("vrsqrt14ps")}, + {'v', QLatin1String("vrsqrt14sd")}, + {'v', QLatin1String("vrsqrt14ss")}, + {'v', QLatin1String("vscalefpd")}, + {'v', QLatin1String("vscalefps")}, + {'v', QLatin1String("vscalefsd")}, + {'v', QLatin1String("vscalefss")}, + {'v', QLatin1String("vscatterdpd")}, + {'v', QLatin1String("vscatterdps")}, + {'v', QLatin1String("vscatterqpd")}, + {'v', QLatin1String("vscatterqps")}, + {'v', QLatin1String("vshuff32x4")}, + {'v', QLatin1String("vshuff64x2")}, + {'v', QLatin1String("vshufi32x4")}, + {'v', QLatin1String("vshufi64x2")}, + {'k', QLatin1String("kandnw")}, + {'k', QLatin1String("kandw")}, + {'k', QLatin1String("kmovw")}, + {'k', QLatin1String("knotw")}, + {'k', QLatin1String("kortestw")}, + {'k', QLatin1String("korw")}, + {'k', QLatin1String("kshiftlw")}, + {'k', QLatin1String("kshiftrw")}, + {'k', QLatin1String("kunpckbw")}, + {'k', QLatin1String("kxnorw")}, + {'k', QLatin1String("kxorw")}, + {'v', QLatin1String("vpbroadcastmb2q")}, + {'v', QLatin1String("vpbroadcastmw2d")}, + {'v', QLatin1String("vpconflictd")}, + {'v', QLatin1String("vpconflictq")}, + {'v', QLatin1String("vplzcntd")}, + {'v', QLatin1String("vplzcntq")}, + {'v', QLatin1String("vexp2pd")}, + {'v', QLatin1String("vexp2ps")}, + {'v', QLatin1String("vrcp28pd")}, + {'v', QLatin1String("vrcp28ps")}, + {'v', QLatin1String("vrcp28sd")}, + {'v', QLatin1String("vrcp28ss")}, + {'v', QLatin1String("vrsqrt28pd")}, + {'v', QLatin1String("vrsqrt28ps")}, + {'v', QLatin1String("vrsqrt28sd")}, + {'v', QLatin1String("vrsqrt28ss")}, + {'v', QLatin1String("vgatherpf0dpd")}, + {'v', QLatin1String("vgatherpf0dps")}, + {'v', QLatin1String("vgatherpf0qpd")}, + {'v', QLatin1String("vgatherpf0qps")}, + {'v', QLatin1String("vgatherpf1dpd")}, + {'v', QLatin1String("vgatherpf1dps")}, + {'v', QLatin1String("vgatherpf1qpd")}, + {'v', QLatin1String("vgatherpf1qps")}, + {'v', QLatin1String("vscatterpf0dpd")}, + {'v', QLatin1String("vscatterpf0dps")}, + {'v', QLatin1String("vscatterpf0qpd")}, + {'v', QLatin1String("vscatterpf0qps")}, + {'v', QLatin1String("vscatterpf1dpd")}, + {'v', QLatin1String("vscatterpf1dps")}, + {'v', QLatin1String("vscatterpf1qpd")}, + {'v', QLatin1String("vscatterpf1qps")}, + {'p', QLatin1String("prefetchwt1")}, + {'b', QLatin1String("bndmk")}, + {'b', QLatin1String("bndcl")}, + {'b', QLatin1String("bndcu")}, + {'b', QLatin1String("bndcn")}, + {'b', QLatin1String("bndmov")}, + {'b', QLatin1String("bndldx")}, + {'b', QLatin1String("bndstx")}, + {'s', QLatin1String("sha1rnds4")}, + {'s', QLatin1String("sha1nexte")}, + {'s', QLatin1String("sha1msg1")}, + {'s', QLatin1String("sha1msg2")}, + {'s', QLatin1String("sha256rnds2")}, + {'s', QLatin1String("sha256msg1")}, + {'s', QLatin1String("sha256msg2")}, + {'h', QLatin1String("hint_nop")}, + }; + + other = { + {'s', QLatin1String("section")}, + }; + builtin = { + + {'t', QLatin1String("text")}, + {'c', QLatin1String("code")}, + {'d', QLatin1String("data")}, + {'b', QLatin1String("bss")}}; } + +} // namespace QSourceHighlite diff --git a/libs/QSourceHighlite/languagedata.h b/libs/QSourceHighlite/languagedata.h old mode 100755 new mode 100644 index fe244e0a..bc523535 --- a/libs/QSourceHighlite/languagedata.h +++ b/libs/QSourceHighlite/languagedata.h @@ -8,8 +8,8 @@ * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -29,194 +29,159 @@ class QMultiHash; class QLatin1String; -namespace QSourceHighlite { +namespace QSourceHighlite +{ using LanguageData = QMultiHash; /**********************************************************/ /* LuaData ************************************************/ /**********************************************************/ -void loadLuaData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, +void loadLuaData(LanguageData &typess, LanguageData &keywordss, + LanguageData &builtins, LanguageData &literalss, LanguageData &others); /**********************************************************/ /* C/C++ Data *********************************************/ /**********************************************************/ -void loadCppData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others); +void loadCppData(LanguageData &typess, LanguageData &keywordss, + LanguageData &builtins, LanguageData &literalss, + LanguageData &others); /**********************************************************/ /* Shell Data *********************************************/ /**********************************************************/ -void loadShellData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadShellData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /**********************************************************/ /* JS Data *********************************************/ /**********************************************************/ -void loadJSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadJSData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /**********************************************************/ /* PHP Data *********************************************/ /**********************************************************/ -void loadPHPData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadPHPData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /**********************************************************/ /* QML Data *********************************************/ /**********************************************************/ -void loadQMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadQMLData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /**********************************************************/ /* Python Data *********************************************/ /**********************************************************/ -void loadPythonData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadPythonData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** Rust DATA ***********************************/ /********************************************************/ -void loadRustData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadRustData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** Java DATA ***********************************/ /********************************************************/ -void loadJavaData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadJavaData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** C# DATA *************************************/ /********************************************************/ -void loadCSharpData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadCSharpData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** Go DATA *************************************/ /********************************************************/ -void loadGoData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadGoData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** V DATA **************************************/ /********************************************************/ -void loadVData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadVData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** SQL DATA ************************************/ /********************************************************/ -void loadSQLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadSQLData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** JSON DATA ***********************************/ /********************************************************/ -void loadJSONData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadJSONData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** CSS DATA ***********************************/ /********************************************************/ -void loadCSSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadCSSData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** Typescript DATA *********************************/ /********************************************************/ -void loadTypescriptData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadTypescriptData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** YAML DATA ***************************************/ /********************************************************/ -void loadYAMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadYAMLData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** VEX DATA ***************************************/ /********************************************************/ -void loadVEXData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); +void loadVEXData(LanguageData &types, LanguageData &keywords, + LanguageData &builtin, LanguageData &literals, + LanguageData &other); /********************************************************/ /*** CMake DATA **************************************/ /********************************************************/ void loadCMakeData(QMultiHash &types, - QMultiHash &keywords, - QMultiHash &builtin, - QMultiHash &literals, - QMultiHash &other); + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other); /********************************************************/ /*** Make DATA ***************************************/ /********************************************************/ -void loadMakeData(QMultiHash& types, - QMultiHash& keywords, - QMultiHash& builtin, - QMultiHash& literals, - QMultiHash& other); +void loadMakeData(QMultiHash &types, + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other); -void loadAsmData(QMultiHash& types, - QMultiHash& keywords, - QMultiHash& builtin, - QMultiHash& literals, - QMultiHash& other); -} +void loadAsmData(QMultiHash &types, + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other); +} // namespace QSourceHighlite #endif diff --git a/libs/QSourceHighlite/qsourcehighliter.cpp b/libs/QSourceHighlite/qsourcehighliter.cpp old mode 100755 new mode 100644 index ed4cf64f..8d4fbaf0 --- a/libs/QSourceHighlite/qsourcehighliter.cpp +++ b/libs/QSourceHighlite/qsourcehighliter.cpp @@ -8,8 +8,8 @@ * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -29,86 +29,93 @@ #include #include -namespace QSourceHighlite { +namespace QSourceHighlite +{ QSourceHighliter::QSourceHighliter(QTextDocument *doc) - : QSyntaxHighlighter(doc), - _language(CodeC) + : QSyntaxHighlighter(doc) + , _language(CodeC) { - initFormats(); + initFormats(); } -QSourceHighliter::QSourceHighliter(QTextDocument *doc, QSourceHighliter::Themes theme) - : QSyntaxHighlighter(doc), - _language(CodeC) +QSourceHighliter::QSourceHighliter(QTextDocument *doc, + QSourceHighliter::Themes theme) + : QSyntaxHighlighter(doc) + , _language(CodeC) { - setTheme(theme); + setTheme(theme); } -void QSourceHighliter::initFormats() { - /**************************************** - * Formats for syntax highlighting - ***************************************/ +void QSourceHighliter::initFormats() +{ + /**************************************** + * Formats for syntax highlighting + ***************************************/ - QTextCharFormat format = QTextCharFormat(); + QTextCharFormat format = QTextCharFormat(); - _formats[Token::CodeBlock] = format; - format = QTextCharFormat(); + _formats[Token::CodeBlock] = format; + format = QTextCharFormat(); - format.setForeground(QColor("#F92672")); - _formats[Token::CodeKeyWord] = format; - format = QTextCharFormat(); + format.setForeground(QColor("#F92672")); + _formats[Token::CodeKeyWord] = format; + format = QTextCharFormat(); - format.setForeground(QColor("#a39b4e")); - _formats[Token::CodeString] = format; - format = QTextCharFormat(); + format.setForeground(QColor("#a39b4e")); + _formats[Token::CodeString] = format; + format = QTextCharFormat(); - format.setForeground(QColor("#75715E")); - _formats[Token::CodeComment] = format; - format = QTextCharFormat(); + format.setForeground(QColor("#75715E")); + _formats[Token::CodeComment] = format; + format = QTextCharFormat(); - format.setForeground(QColor("#54aebf")); - _formats[Token::CodeType] = format; + format.setForeground(QColor("#54aebf")); + _formats[Token::CodeType] = format; - format = QTextCharFormat(); - format.setForeground(QColor("#db8744")); - _formats[Token::CodeOther] = format; + format = QTextCharFormat(); + format.setForeground(QColor("#db8744")); + _formats[Token::CodeOther] = format; - format = QTextCharFormat(); - format.setForeground(QColor("#AE81FF")); - _formats[Token::CodeNumLiteral] = format; + format = QTextCharFormat(); + format.setForeground(QColor("#AE81FF")); + _formats[Token::CodeNumLiteral] = format; - format = QTextCharFormat(); - format.setForeground(QColor("#018a0f")); - _formats[Token::CodeBuiltIn] = format; + format = QTextCharFormat(); + format.setForeground(QColor("#018a0f")); + _formats[Token::CodeBuiltIn] = format; } -void QSourceHighliter::setCurrentLanguage(Language language) { - if (language != _language) - _language = language; +void QSourceHighliter::setCurrentLanguage(Language language) +{ + if (language != _language) + _language = language; } -QSourceHighliter::Language QSourceHighliter::currentLanguage() { - return _language; +QSourceHighliter::Language QSourceHighliter::currentLanguage() +{ + return _language; } void QSourceHighliter::setTheme(QSourceHighliter::Themes theme) { - _formats = QSourceHighliterTheme::theme(theme); - rehighlight(); + _formats = QSourceHighliterTheme::theme(theme); + rehighlight(); } void QSourceHighliter::highlightBlock(const QString &text) { - if (currentBlock() == document()->firstBlock()) { - setCurrentBlockState(_language); - } else { - previousBlockState() == _language ? - setCurrentBlockState(_language) : - setCurrentBlockState(_language + 1); - } + if (currentBlock() == document()->firstBlock()) + { + setCurrentBlockState(_language); + } + else + { + previousBlockState() == _language ? setCurrentBlockState(_language) + : setCurrentBlockState(_language + 1); + } - highlightSyntax(text); + highlightSyntax(text); } /** @@ -117,293 +124,340 @@ void QSourceHighliter::highlightBlock(const QString &text) */ void QSourceHighliter::highlightSyntax(const QString &text) { - if (text.isEmpty()) return; + if (text.isEmpty()) + return; - const auto textLen = text.length(); + const auto textLen = text.length(); - QChar comment; - bool isCSS = false; - bool isYAML = false; - bool isMake = false; - bool isAsm = false; - bool isSQL = false; + QChar comment; + bool isCSS = false; + bool isYAML = false; + bool isMake = false; + bool isAsm = false; + bool isSQL = false; - LanguageData keywords{}, - others{}, - types{}, - builtin{}, - literals{}; + LanguageData keywords{}, others{}, types{}, builtin{}, literals{}; - switch (currentBlockState()) { - case CodeLua : - case CodeLuaComment : - loadLuaData(types, keywords, builtin, literals, others); - break; - case CodeCpp : - case CodeCppComment : - loadCppData(types, keywords, builtin, literals, others); - break; - case CodeJs : - case CodeJsComment : - loadJSData(types, keywords, builtin, literals, others); - break; - case CodeC : - case CodeCComment : - loadCppData(types, keywords, builtin, literals, others); - break; - case CodeBash : - loadShellData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodePHP : - case CodePHPComment : - loadPHPData(types, keywords, builtin, literals, others); - break; - case CodeQML : - case CodeQMLComment : - loadQMLData(types, keywords, builtin, literals, others); - break; - case CodePython : - loadPythonData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeRust : - case CodeRustComment : - loadRustData(types, keywords, builtin, literals, others); - break; - case CodeJava : - case CodeJavaComment : - loadJavaData(types, keywords, builtin, literals, others); - break; - case CodeCSharp : - case CodeCSharpComment : - loadCSharpData(types, keywords, builtin, literals, others); - break; - case CodeGo : - case CodeGoComment : - loadGoData(types, keywords, builtin, literals, others); - break; - case CodeV : - case CodeVComment : - loadVData(types, keywords, builtin, literals, others); - break; - case CodeSQL : - isSQL = true; - loadSQLData(types, keywords, builtin, literals, others); - break; - case CodeJSON : - loadJSONData(types, keywords, builtin, literals, others); - break; - case CodeXML : - xmlHighlighter(text); + switch (currentBlockState()) + { + case CodeLua: + case CodeLuaComment: + loadLuaData(types, keywords, builtin, literals, others); + break; + case CodeCpp: + case CodeCppComment: + loadCppData(types, keywords, builtin, literals, others); + break; + case CodeJs: + case CodeJsComment: + loadJSData(types, keywords, builtin, literals, others); + break; + case CodeC: + case CodeCComment: + loadCppData(types, keywords, builtin, literals, others); + break; + case CodeBash: + loadShellData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodePHP: + case CodePHPComment: + loadPHPData(types, keywords, builtin, literals, others); + break; + case CodeQML: + case CodeQMLComment: + loadQMLData(types, keywords, builtin, literals, others); + break; + case CodePython: + loadPythonData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeRust: + case CodeRustComment: + loadRustData(types, keywords, builtin, literals, others); + break; + case CodeJava: + case CodeJavaComment: + loadJavaData(types, keywords, builtin, literals, others); + break; + case CodeCSharp: + case CodeCSharpComment: + loadCSharpData(types, keywords, builtin, literals, others); + break; + case CodeGo: + case CodeGoComment: + loadGoData(types, keywords, builtin, literals, others); + break; + case CodeV: + case CodeVComment: + loadVData(types, keywords, builtin, literals, others); + break; + case CodeSQL: + isSQL = true; + loadSQLData(types, keywords, builtin, literals, others); + break; + case CodeJSON: + loadJSONData(types, keywords, builtin, literals, others); + break; + case CodeXML: + xmlHighlighter(text); + return; + case CodeCSS: + case CodeCSSComment: + isCSS = true; + loadCSSData(types, keywords, builtin, literals, others); + break; + case CodeTypeScript: + case CodeTypeScriptComment: + loadTypescriptData(types, keywords, builtin, literals, others); + break; + case CodeYAML: + isYAML = true; + loadYAMLData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeINI: + comment = QLatin1Char('#'); + break; + case CodeVex: + case CodeVexComment: + loadVEXData(types, keywords, builtin, literals, others); + break; + case CodeCMake: + loadCMakeData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeMake: + isMake = true; + loadMakeData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeAsm: + isAsm = true; + loadAsmData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + default: + break; + } + + // keep the default code block format + // this statement is very slow + // TODO: do this formatting when necessary instead of + // applying it to the whole block in the beginning + setFormat(0, textLen, _formats[CodeBlock]); + + auto applyCodeFormat + = [this](int i, const LanguageData &data, const QString &text, + const QTextCharFormat &fmt) -> int { + // check if we are at the beginning OR if this is the start of a word + if (i == 0 + || (!text.at(i - 1).isLetterOrNumber() + && text.at(i - 1) != QLatin1Char('_'))) + { + const auto wordList = data.values(text.at(i).toLatin1()); + for (const QLatin1String &word : wordList) + { + // we have a word match check + // 1. if we are at the end + // 2. if we have a complete word + if (word == strMidRef(text, i, word.size()) + && (i + word.size() == text.length() + || (!text.at(i + word.size()).isLetterOrNumber() + && text.at(i + word.size()) != QLatin1Char('_')))) + { + setFormat(i, word.size(), fmt); + i += word.size(); + } + } + } + return i; + }; + + const QTextCharFormat &formatType = _formats[CodeType]; + const QTextCharFormat &formatKeyword = _formats[CodeKeyWord]; + const QTextCharFormat &formatComment = _formats[CodeComment]; + const QTextCharFormat &formatNumLit = _formats[CodeNumLiteral]; + const QTextCharFormat &formatBuiltIn = _formats[CodeBuiltIn]; + const QTextCharFormat &formatOther = _formats[CodeOther]; + + for (int i = 0; i < textLen; ++i) + { + + if (currentBlockState() % 2 != 0) + goto Comment; + + while (i < textLen && !text[i].isLetter()) + { + if (text[i].isSpace()) + { + ++i; + // make sure we don't cross the bound + if (i == textLen) + return; + if (text[i].isLetter()) + break; + else + continue; + } + // inline comment + if (comment.isNull() && text[i] == QLatin1Char('/')) + { + if ((i + 1) < textLen) + { + if (text[i + 1] == QLatin1Char('/')) + { + setFormat(i, textLen, formatComment); return; - case CodeCSS : - case CodeCSSComment : - isCSS = true; - loadCSSData(types, keywords, builtin, literals, others); - break; - case CodeTypeScript: - case CodeTypeScriptComment: - loadTypescriptData(types, keywords, builtin, literals, others); - break; - case CodeYAML: - isYAML = true; - loadYAMLData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeINI: - comment = QLatin1Char('#'); - break; - case CodeVex: - case CodeVexComment: - loadVEXData(types, keywords, builtin, literals, others); - break; - case CodeCMake: - loadCMakeData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeMake: - isMake = true; - loadMakeData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeAsm: - isAsm = true; - loadAsmData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - default: - break; + } + else if (text[i + 1] == QLatin1Char('*')) + { + Comment: + int next = text.indexOf(QLatin1String("*/")); + if (next == -1) + { + // we didn't find a comment end. + // Check if we are already in a comment block + if (currentBlockState() % 2 == 0) + setCurrentBlockState(currentBlockState() + 1); + setFormat(i, textLen, formatComment); + return; + } + else + { + // we found a comment end + // mark this block as code if it was previously comment + // first check if the comment ended on the same line + // if modulo 2 is not equal to zero, it means we are in a comment + //-1 will set this block's state as language + if (currentBlockState() % 2 != 0) + { + setCurrentBlockState(currentBlockState() - 1); + } + next += 2; + setFormat(i, next - i, formatComment); + i = next; + if (i >= textLen) + return; + } + } + } + } + else if (isSQL && comment.isNull() && text[i] == QLatin1Char('-')) + { + if ((i + 1) < textLen) + { + if (text[i + 1] == QLatin1Char('-')) + { + setFormat(i, textLen, formatComment); + return; + } + } + } + else if (text[i] == comment) + { + setFormat(i, textLen, formatComment); + i = textLen; + // integer literal + } + else if (text[i].isNumber()) + { + i = highlightNumericLiterals(text, i); + // string literals + } + else if (text[i] == QLatin1Char('\"')) + { + i = highlightStringLiterals('\"', text, i); + } + else if (text[i] == QLatin1Char('\'')) + { + i = highlightStringLiterals('\'', text, i); + } + if (i >= textLen) + { + break; + } + ++i; } - // keep the default code block format - // this statement is very slow - // TODO: do this formatting when necessary instead of - // applying it to the whole block in the beginning - setFormat(0, textLen, _formats[CodeBlock]); + const int pos = i; - auto applyCodeFormat = - [this](int i, const LanguageData &data, - const QString &text, const QTextCharFormat &fmt) -> int { - // check if we are at the beginning OR if this is the start of a word - if (i == 0 || (!text.at(i - 1).isLetterOrNumber() && - text.at(i-1) != QLatin1Char('_'))) { - const auto wordList = data.values(text.at(i).toLatin1()); - for (const QLatin1String &word : wordList) { - // we have a word match check - // 1. if we are at the end - // 2. if we have a complete word - if (word == strMidRef(text, i, word.size()) && - (i + word.size() == text.length() || - (!text.at(i + word.size()).isLetterOrNumber() && - text.at(i + word.size()) != QLatin1Char('_')))) { - setFormat(i, word.size(), fmt); - i += word.size(); - } - } - } - return i; - }; - - const QTextCharFormat &formatType = _formats[CodeType]; - const QTextCharFormat &formatKeyword = _formats[CodeKeyWord]; - const QTextCharFormat &formatComment = _formats[CodeComment]; - const QTextCharFormat &formatNumLit = _formats[CodeNumLiteral]; - const QTextCharFormat &formatBuiltIn = _formats[CodeBuiltIn]; - const QTextCharFormat &formatOther = _formats[CodeOther]; - - for (int i = 0; i < textLen; ++i) { - - if (currentBlockState() % 2 != 0) goto Comment; - - while (i < textLen && !text[i].isLetter()) { - if (text[i].isSpace()) { - ++i; - //make sure we don't cross the bound - if (i == textLen) return; - if (text[i].isLetter()) break; - else continue; - } - //inline comment - if (comment.isNull() && text[i] == QLatin1Char('/')) { - if((i+1) < textLen){ - if(text[i+1] == QLatin1Char('/')) { - setFormat(i, textLen, formatComment); - return; - } else if(text[i+1] == QLatin1Char('*')) { - Comment: - int next = text.indexOf(QLatin1String("*/")); - if (next == -1) { - //we didn't find a comment end. - //Check if we are already in a comment block - if (currentBlockState() % 2 == 0) - setCurrentBlockState(currentBlockState() + 1); - setFormat(i, textLen, formatComment); - return; - } else { - //we found a comment end - //mark this block as code if it was previously comment - //first check if the comment ended on the same line - //if modulo 2 is not equal to zero, it means we are in a comment - //-1 will set this block's state as language - if (currentBlockState() % 2 != 0) { - setCurrentBlockState(currentBlockState() - 1); - } - next += 2; - setFormat(i, next - i, formatComment); - i = next; - if (i >= textLen) return; - } - } - } - } else if (isSQL && comment.isNull() && text[i] == QLatin1Char('-')) { - if((i+1) < textLen){ - if(text[i+1] == QLatin1Char('-')) { - setFormat(i, textLen, formatComment); - return; - } - } - } else if (text[i] == comment) { - setFormat(i, textLen, formatComment); - i = textLen; - //integer literal - } else if (text[i].isNumber()) { - i = highlightNumericLiterals(text, i); - //string literals - } else if (text[i] == QLatin1Char('\"')) { - i = highlightStringLiterals('\"', text, i); - } else if (text[i] == QLatin1Char('\'')) { - i = highlightStringLiterals('\'', text, i); - } - if (i >= textLen) { - break; - } - ++i; - } - - const int pos = i; - - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Types */ - i = applyCodeFormat(i, types, text, formatType); - /************************************************ - next letter is usually a space, in that case - going forward is useless, so continue; - We can ++i here and go to the beginning of the next word - so that the next formatter can check for formatting but this will - cause problems in case the next word is also of 'Type' or the current - type(keyword/builtin). We can work around it and reset the value of i - in the beginning of the loop to the word's first letter but I am not - sure about its efficiency yet. - ************************************************/ - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Keywords */ - i = applyCodeFormat(i, keywords, text, formatKeyword); - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Literals (true/false/NULL,nullptr) */ - i = applyCodeFormat(i, literals, text, formatNumLit); - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Builtin library stuff */ - i = applyCodeFormat(i, builtin, text, formatBuiltIn); - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight other stuff (preprocessor etc.) */ - if (( i == 0 || !text.at(i-1).isLetter()) && others.contains(text[i].toLatin1())) { - const QList wordList = others.values(text[i].toLatin1()); - for(const QLatin1String &word : wordList) { - if (word == strMidRef(text, i, word.size()) // we have a word match - && - (i + word.size() == text.length() // check if we are at the end - || - !text.at(i + word.size()).isLetter()) //OR if we have a complete word - ) { - currentBlockState() == CodeCpp ? - setFormat(i - 1, word.size() + 1, formatOther) : - setFormat(i, word.size(), formatOther); - i += word.size(); - } - } - } - - //we were unable to find any match, lets skip this word - if (pos == i) { - int count = i; - while (count < textLen) { - if (!text[count].isLetter()) break; - ++count; - } - i = count; + if (i == textLen || !text[i].isLetter()) + continue; + + /* Highlight Types */ + i = applyCodeFormat(i, types, text, formatType); + /************************************************ + next letter is usually a space, in that case + going forward is useless, so continue; + We can ++i here and go to the beginning of the next word + so that the next formatter can check for formatting but this will + cause problems in case the next word is also of 'Type' or the current + type(keyword/builtin). We can work around it and reset the value of i + in the beginning of the loop to the word's first letter but I am not + sure about its efficiency yet. + ************************************************/ + if (i == textLen || !text[i].isLetter()) + continue; + + /* Highlight Keywords */ + i = applyCodeFormat(i, keywords, text, formatKeyword); + if (i == textLen || !text[i].isLetter()) + continue; + + /* Highlight Literals (true/false/NULL,nullptr) */ + i = applyCodeFormat(i, literals, text, formatNumLit); + if (i == textLen || !text[i].isLetter()) + continue; + + /* Highlight Builtin library stuff */ + i = applyCodeFormat(i, builtin, text, formatBuiltIn); + if (i == textLen || !text[i].isLetter()) + continue; + + /* Highlight other stuff (preprocessor etc.) */ + if ((i == 0 || !text.at(i - 1).isLetter()) + && others.contains(text[i].toLatin1())) + { + const QList wordList = others.values(text[i].toLatin1()); + for (const QLatin1String &word : wordList) + { + if (word == strMidRef(text, i, word.size()) // we have a word match + && (i + word.size() == text.length() // check if we are at the end + || !text.at(i + word.size()) + .isLetter()) // OR if we have a complete word + ) + { + currentBlockState() == CodeCpp + ? setFormat(i - 1, word.size() + 1, formatOther) + : setFormat(i, word.size(), formatOther); + i += word.size(); } + } } - if (isCSS) cssHighlighter(text); - if (isYAML) ymlHighlighter(text); - if (isMake) makeHighlighter(text); - if (isAsm) asmHighlighter(text); + // we were unable to find any match, lets skip this word + if (pos == i) + { + int count = i; + while (count < textLen) + { + if (!text[count].isLetter()) + break; + ++count; + } + i = count; + } + } + + if (isCSS) + cssHighlighter(text); + if (isYAML) + ymlHighlighter(text); + if (isMake) + makeHighlighter(text); + if (isAsm) + asmHighlighter(text); } /** @@ -413,99 +467,110 @@ void QSourceHighliter::highlightSyntax(const QString &text) * @param i pos of i in loop * @return pos of i after the string */ -int QSourceHighliter::highlightStringLiterals(const QChar strType, const QString &text, int i) { - setFormat(i, 1, _formats[CodeString]); - ++i; +int QSourceHighliter::highlightStringLiterals(const QChar strType, + const QString &text, int i) +{ + setFormat(i, 1, _formats[CodeString]); + ++i; - while (i < text.length()) { - //look for string end - //make sure it's not an escape seq - if (text.at(i) == strType && text.at(i-1) != QLatin1Char('\\')) { - setFormat(i, 1, _formats[CodeString]); - ++i; - break; - } - //look for escape sequence - if (text.at(i) == QLatin1Char('\\') && (i+1) < text.length()) { - int len = 0; - switch(text.at(i+1).toLatin1()) { - case 'a': - case 'b': - case 'e': - case 'f': - case 'n': - case 'r': - case 't': - case 'v': - case '\'': - case '"': - case '\\': - case '\?': - //2 because we have to highlight \ as well as the following char - len = 2; - break; - //octal esc sequence \123 - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - if (i + 4 <= text.length()) { - bool isCurrentOctal = true; - if (!isOctal(text.at(i+2).toLatin1())) { - isCurrentOctal = false; - break; - } - if (!isOctal(text.at(i+3).toLatin1())) { - isCurrentOctal = false; - break; - } - len = isCurrentOctal ? 4 : 0; - } - break; - } - //hex numbers \xFA - case 'x': - { - if (i + 3 <= text.length()) { - bool isCurrentHex = true; - if (!isHex(text.at(i+2).toLatin1())) { - isCurrentHex = false; - break; - } - if (!isHex(text.at(i+3).toLatin1())) { - isCurrentHex = false; - break; - } - len = isCurrentHex ? 4 : 0; - } - break; - } - //TODO: implement unicode code point escaping - default: - break; - } - - //if len is zero, that means this wasn't an esc seq - //increment i so that we skip this backslash - if (len == 0) { - setFormat(i, 1, _formats[CodeString]); - ++i; - continue; - } - - setFormat(i, len, _formats[CodeNumLiteral]); - i += len; - continue; - } - setFormat(i, 1, _formats[CodeString]); - ++i; + while (i < text.length()) + { + // look for string end + // make sure it's not an escape seq + if (text.at(i) == strType && text.at(i - 1) != QLatin1Char('\\')) + { + setFormat(i, 1, _formats[CodeString]); + ++i; + break; } - return i; + // look for escape sequence + if (text.at(i) == QLatin1Char('\\') && (i + 1) < text.length()) + { + int len = 0; + switch (text.at(i + 1).toLatin1()) + { + case 'a': + case 'b': + case 'e': + case 'f': + case 'n': + case 'r': + case 't': + case 'v': + case '\'': + case '"': + case '\\': + case '\?': + // 2 because we have to highlight \ as well as the following char + len = 2; + break; + // octal esc sequence \123 + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': { + if (i + 4 <= text.length()) + { + bool isCurrentOctal = true; + if (!isOctal(text.at(i + 2).toLatin1())) + { + isCurrentOctal = false; + break; + } + if (!isOctal(text.at(i + 3).toLatin1())) + { + isCurrentOctal = false; + break; + } + len = isCurrentOctal ? 4 : 0; + } + break; + } + // hex numbers \xFA + case 'x': { + if (i + 3 <= text.length()) + { + bool isCurrentHex = true; + if (!isHex(text.at(i + 2).toLatin1())) + { + isCurrentHex = false; + break; + } + if (!isHex(text.at(i + 3).toLatin1())) + { + isCurrentHex = false; + break; + } + len = isCurrentHex ? 4 : 0; + } + break; + } + // TODO: implement unicode code point escaping + default: + break; + } + + // if len is zero, that means this wasn't an esc seq + // increment i so that we skip this backslash + if (len == 0) + { + setFormat(i, 1, _formats[CodeString]); + ++i; + continue; + } + + setFormat(i, len, _formats[CodeNumLiteral]); + i += len; + continue; + } + setFormat(i, 1, _formats[CodeString]); + ++i; + } + return i; } /** @@ -516,117 +581,131 @@ int QSourceHighliter::highlightStringLiterals(const QChar strType, const QString */ int QSourceHighliter::highlightNumericLiterals(const QString &text, int i) { - bool isPreAllowed = false; - if (i == 0) isPreAllowed = true; - else { - //these values are allowed before a number - switch(text.at(i - 1).toLatin1()) { - //css number - case ':': - if (currentBlockState() == CodeCSS) - isPreAllowed = true; - break; - case '$': - if (currentBlockState() == CodeAsm) - isPreAllowed = true; - break; - case '[': - case '(': - case '{': - case ' ': - case ',': - case '=': - case '+': - case '-': - case '*': - case '/': - case '%': - case '<': - case '>': - isPreAllowed = true; - break; - } + bool isPreAllowed = false; + if (i == 0) + isPreAllowed = true; + else + { + // these values are allowed before a number + switch (text.at(i - 1).toLatin1()) + { + // css number + case ':': + if (currentBlockState() == CodeCSS) + isPreAllowed = true; + break; + case '$': + if (currentBlockState() == CodeAsm) + isPreAllowed = true; + break; + case '[': + case '(': + case '{': + case ' ': + case ',': + case '=': + case '+': + case '-': + case '*': + case '/': + case '%': + case '<': + case '>': + isPreAllowed = true; + break; } + } - if (!isPreAllowed) return i; + if (!isPreAllowed) + return i; - const int start = i; + const int start = i; - if ((i+1) >= text.length()) { - setFormat(i, 1, _formats[CodeNumLiteral]); - return ++i; - } + if ((i + 1) >= text.length()) + { + setFormat(i, 1, _formats[CodeNumLiteral]); + return ++i; + } + ++i; + // hex numbers highlighting (only if there's a preceding zero) + if (text.at(i) == QChar('x') && text.at(i - 1) == QChar('0')) ++i; - //hex numbers highlighting (only if there's a preceding zero) - if (text.at(i) == QChar('x') && text.at(i - 1) == QChar('0')) - ++i; - while (i < text.length()) { - if (!text.at(i).isNumber() && text.at(i) != QChar('.') && - text.at(i) != QChar('e')) //exponent - break; - ++i; - } + while (i < text.length()) + { + if (!text.at(i).isNumber() && text.at(i) != QChar('.') + && text.at(i) != QChar('e')) // exponent + break; + ++i; + } - bool isPostAllowed = false; - if (i == text.length()) { - //cant have e at the end - if (text.at(i - 1) != QChar('e')) - isPostAllowed = true; - } else { - //these values are allowed after a number - switch(text.at(i).toLatin1()) { - case ']': - case ')': - case '}': - case ' ': - case ',': - case '=': - case '+': - case '-': - case '*': - case '/': - case '%': - case '>': - case '<': - case ';': - isPostAllowed = true; - break; - // for 100u, 1.0F - case 'p': - if (currentBlockState() == CodeCSS) - if (i + 1 < text.length() && text.at(i+1) == QChar('x')) { - if (i + 2 == text.length() || !text.at(i+2).isLetterOrNumber()) - isPostAllowed = true; - } - break; - case 'e': - if (currentBlockState() == CodeCSS) - if (i + 1 < text.length() && text.at(i+1) == QChar('m')) { - if (i + 2 == text.length() || !text.at(i+2).isLetterOrNumber()) - isPostAllowed = true; - } - break; - case 'u': - case 'l': - case 'f': - case 'U': - case 'L': - case 'F': - if (i + 1 == text.length() || !text.at(i+1).isLetterOrNumber()) { - isPostAllowed = true; - ++i; - } - break; + bool isPostAllowed = false; + if (i == text.length()) + { + // cant have e at the end + if (text.at(i - 1) != QChar('e')) + isPostAllowed = true; + } + else + { + // these values are allowed after a number + switch (text.at(i).toLatin1()) + { + case ']': + case ')': + case '}': + case ' ': + case ',': + case '=': + case '+': + case '-': + case '*': + case '/': + case '%': + case '>': + case '<': + case ';': + isPostAllowed = true; + break; + // for 100u, 1.0F + case 'p': + if (currentBlockState() == CodeCSS) + if (i + 1 < text.length() && text.at(i + 1) == QChar('x')) + { + if (i + 2 == text.length() || !text.at(i + 2).isLetterOrNumber()) + isPostAllowed = true; + } + break; + case 'e': + if (currentBlockState() == CodeCSS) + if (i + 1 < text.length() && text.at(i + 1) == QChar('m')) + { + if (i + 2 == text.length() || !text.at(i + 2).isLetterOrNumber()) + isPostAllowed = true; + } + break; + case 'u': + case 'l': + case 'f': + case 'U': + case 'L': + case 'F': + if (i + 1 == text.length() || !text.at(i + 1).isLetterOrNumber()) + { + isPostAllowed = true; + ++i; } + break; } - if (isPostAllowed) { - int end = i; - setFormat(start, end - start, _formats[CodeNumLiteral]); - } - //decrement so that the index is at the last number, not after it - return --i; + } + if (isPostAllowed) + { + int end = i; + setFormat(start, end - start, _formats[CodeNumLiteral]); + } + // decrement so that the index is at the last number, not after it + return --i; } /** @@ -646,199 +725,261 @@ int QSourceHighliter::highlightNumericLiterals(const QString &text, int i) * If an h letter is found, check the next 4/5 letters for http/https and * highlight them as a link (underlined) */ -void QSourceHighliter::ymlHighlighter(const QString &text) { - if (text.isEmpty()) return; - const auto textLen = text.length(); - bool colonNotFound = false; +void QSourceHighliter::ymlHighlighter(const QString &text) +{ + if (text.isEmpty()) + return; + const auto textLen = text.length(); + bool colonNotFound = false; - //if this is a comment don't do anything and just return - if (text.trimmed().at(0) == QLatin1Char('#')) - return; + // if this is a comment don't do anything and just return + if (text.trimmed().at(0) == QLatin1Char('#')) + return; - for (int i = 0; i < textLen; ++i) { - if (!text.at(i).isLetter()) continue; + for (int i = 0; i < textLen; ++i) + { + if (!text.at(i).isLetter()) + continue; - if (colonNotFound && text.at(i) != QLatin1Char('h')) continue; + if (colonNotFound && text.at(i) != QLatin1Char('h')) + continue; - //we found a string literal, skip it - if (i != 0 && (text.at(i-1) == QLatin1Char('"') || text.at(i-1) == QLatin1Char('\''))) { - const int next = text.indexOf(text.at(i-1), i); - if (next == -1) break; - i = next; - continue; - } - - const int colon = text.indexOf(QLatin1Char(':'), i); - - //if colon isn't found, we set this true - if (colon == -1) colonNotFound = true; - - if (!colonNotFound) { - //if the line ends here, format and return - if (colon+1 == textLen) { - setFormat(i, colon - i, _formats[CodeKeyWord]); - return; - } else { - //colon is found, check if it isn't some path or something else - if (!(text.at(colon+1) == QLatin1Char('\\') && text.at(colon+1) == QLatin1Char('/'))) { - setFormat(i, colon - i, _formats[CodeKeyWord]); - } - } - } - - //underlined links - if (text.at(i) == QLatin1Char('h')) { - if (strMidRef(text, i, 5) == QLatin1String("https") || - strMidRef(text, i, 4) == QLatin1String("http")) { - int space = text.indexOf(QChar(' '), i); - if (space == -1) space = textLen; - QTextCharFormat f = _formats[CodeString]; - f.setUnderlineStyle(QTextCharFormat::SingleUnderline); - setFormat(i, space - i, f); - i = space; - } - } + // we found a string literal, skip it + if (i != 0 + && (text.at(i - 1) == QLatin1Char('"') + || text.at(i - 1) == QLatin1Char('\''))) + { + const int next = text.indexOf(text.at(i - 1), i); + if (next == -1) + break; + i = next; + continue; } + + const int colon = text.indexOf(QLatin1Char(':'), i); + + // if colon isn't found, we set this true + if (colon == -1) + colonNotFound = true; + + if (!colonNotFound) + { + // if the line ends here, format and return + if (colon + 1 == textLen) + { + setFormat(i, colon - i, _formats[CodeKeyWord]); + return; + } + else + { + // colon is found, check if it isn't some path or something else + if (!(text.at(colon + 1) == QLatin1Char('\\') + && text.at(colon + 1) == QLatin1Char('/'))) + { + setFormat(i, colon - i, _formats[CodeKeyWord]); + } + } + } + + // underlined links + if (text.at(i) == QLatin1Char('h')) + { + if (strMidRef(text, i, 5) == QLatin1String("https") + || strMidRef(text, i, 4) == QLatin1String("http")) + { + int space = text.indexOf(QChar(' '), i); + if (space == -1) + space = textLen; + QTextCharFormat f = _formats[CodeString]; + f.setUnderlineStyle(QTextCharFormat::SingleUnderline); + setFormat(i, space - i, f); + i = space; + } + } + } } void QSourceHighliter::cssHighlighter(const QString &text) { - if (text.isEmpty()) return; - const auto textLen = text.length(); - for (int i = 0; i= textLen) return; - if (text[i + 1].isSpace() || text[i+1].isNumber()) continue; - int space = text.indexOf(QLatin1Char(' '), i); - if (space < 0) { - space = text.indexOf('{'); - if (space < 0) { - space = textLen; - } - } - setFormat(i, space - i, _formats[CodeKeyWord]); - i = space; - } else if (text[i] == QLatin1Char('c')) { - if (strMidRef(text, i, 5) == QLatin1String("color")) { - i += 5; - int colon = text.indexOf(QLatin1Char(':'), i); - if (colon < 0) continue; - i = colon; - i++; - while(i < textLen) { - if (!text[i].isSpace()) break; - i++; - } - int semicolon = text.indexOf(QLatin1Char(';')); - if (semicolon < 0) semicolon = textLen; - const QString color = text.mid(i, semicolon-i); - QTextCharFormat f = _formats[CodeBlock]; - QColor c(color); - if (color.startsWith(QLatin1String("rgb"))) { - int t = text.indexOf(QLatin1Char('('), i); - int rPos = text.indexOf(QLatin1Char(','), t); - int gPos = text.indexOf(QLatin1Char(','), rPos+1); - int bPos = text.indexOf(QLatin1Char(')'), gPos); - if (rPos > -1 && gPos > -1 && bPos > -1) { - const auto r = strMidRef(text, t+1, rPos - (t+1)); - const auto g = strMidRef(text, rPos+1, gPos - (rPos + 1)); - const auto b = strMidRef(text, gPos+1, bPos - (gPos+1)); - c.setRgb(r.toInt(), g.toInt(), b.toInt()); - } else { - c = _formats[CodeBlock].background().color(); - } - } - - if (!c.isValid()) { - continue; - } - - int lightness{}; - QColor foreground; - //really dark - if (c.lightness() <= 20) { - foreground = Qt::white; - } else if (c.lightness() > 20 && c.lightness() <= 51){ - foreground = QColor("#ccc"); - } else if (c.lightness() > 51 && c.lightness() <= 78){ - foreground = QColor("#bbb"); - } else if (c.lightness() > 78 && c.lightness() <= 110){ - foreground = QColor("#bbb"); - } else if (c.lightness() > 127) { - lightness = c.lightness() + 100; - foreground = c.darker(lightness); - } - else { - lightness = c.lightness() + 100; - foreground = c.lighter(lightness); - } - - f.setBackground(c); - f.setForeground(foreground); - setFormat(i, semicolon - i, QTextCharFormat()); //clear prev format - setFormat(i, semicolon - i, f); - i = semicolon; - } + if (text.isEmpty()) + return; + const auto textLen = text.length(); + for (int i = 0; i < textLen; ++i) + { + if (text[i] == QLatin1Char('.') || text[i] == QLatin1Char('#')) + { + if (i + 1 >= textLen) + return; + if (text[i + 1].isSpace() || text[i + 1].isNumber()) + continue; + int space = text.indexOf(QLatin1Char(' '), i); + if (space < 0) + { + space = text.indexOf('{'); + if (space < 0) + { + space = textLen; } + } + setFormat(i, space - i, _formats[CodeKeyWord]); + i = space; } + else if (text[i] == QLatin1Char('c')) + { + if (strMidRef(text, i, 5) == QLatin1String("color")) + { + i += 5; + int colon = text.indexOf(QLatin1Char(':'), i); + if (colon < 0) + continue; + i = colon; + i++; + while (i < textLen) + { + if (!text[i].isSpace()) + break; + i++; + } + int semicolon = text.indexOf(QLatin1Char(';')); + if (semicolon < 0) + semicolon = textLen; + const QString color = text.mid(i, semicolon - i); + QTextCharFormat f = _formats[CodeBlock]; + QColor c(color); + if (color.startsWith(QLatin1String("rgb"))) + { + int t = text.indexOf(QLatin1Char('('), i); + int rPos = text.indexOf(QLatin1Char(','), t); + int gPos = text.indexOf(QLatin1Char(','), rPos + 1); + int bPos = text.indexOf(QLatin1Char(')'), gPos); + if (rPos > -1 && gPos > -1 && bPos > -1) + { + const auto r = strMidRef(text, t + 1, rPos - (t + 1)); + const auto g = strMidRef(text, rPos + 1, gPos - (rPos + 1)); + const auto b = strMidRef(text, gPos + 1, bPos - (gPos + 1)); + c.setRgb(r.toInt(), g.toInt(), b.toInt()); + } + else + { + c = _formats[CodeBlock].background().color(); + } + } + + if (!c.isValid()) + { + continue; + } + + int lightness{}; + QColor foreground; + // really dark + if (c.lightness() <= 20) + { + foreground = Qt::white; + } + else if (c.lightness() > 20 && c.lightness() <= 51) + { + foreground = QColor("#ccc"); + } + else if (c.lightness() > 51 && c.lightness() <= 78) + { + foreground = QColor("#bbb"); + } + else if (c.lightness() > 78 && c.lightness() <= 110) + { + foreground = QColor("#bbb"); + } + else if (c.lightness() > 127) + { + lightness = c.lightness() + 100; + foreground = c.darker(lightness); + } + else + { + lightness = c.lightness() + 100; + foreground = c.lighter(lightness); + } + + f.setBackground(c); + f.setForeground(foreground); + setFormat(i, semicolon - i, QTextCharFormat()); // clear prev format + setFormat(i, semicolon - i, f); + i = semicolon; + } + } + } } +void QSourceHighliter::xmlHighlighter(const QString &text) +{ + if (text.isEmpty()) + return; + const auto textLen = text.length(); -void QSourceHighliter::xmlHighlighter(const QString &text) { - if (text.isEmpty()) return; - const auto textLen = text.length(); + setFormat(0, textLen, _formats[CodeBlock]); - setFormat(0, textLen, _formats[CodeBlock]); + for (int i = 0; i < textLen; ++i) + { + if (text[i] == QLatin1Char('<') && text[i + 1] != QLatin1Char('!')) + { - for (int i = 0; i < textLen; ++i) { - if (text[i] == QLatin1Char('<') && text[i+1] != QLatin1Char('!')) { - - const int found = text.indexOf(QLatin1Char('>'), i); - if (found > 0) { - ++i; - if (text[i] == QLatin1Char('/')) ++i; - setFormat(i, found - i, _formats[CodeKeyWord]); - } - } - - if (text[i] == QLatin1Char('=')) { - int lastSpace = text.lastIndexOf(QLatin1Char(' '), i); - if (lastSpace == i-1) lastSpace = text.lastIndexOf(QLatin1Char(' '), i-2); - if (lastSpace > 0) { - setFormat(lastSpace, i - lastSpace, _formats[CodeBuiltIn]); - } - } - - if (text[i] == QLatin1Char('\"')) { - const int pos = i; - int cnt = 1; - ++i; - //bound check - if ( (i+1) >= textLen) return; - while (i < textLen) { - if (text[i] == QLatin1Char('\"')) { - ++cnt; - ++i; - break; - } - ++i; ++cnt; - //bound check - if ( (i+1) >= textLen) { - ++cnt; - break; - } - } - setFormat(pos, cnt, _formats[CodeString]); - } + const int found = text.indexOf(QLatin1Char('>'), i); + if (found > 0) + { + ++i; + if (text[i] == QLatin1Char('/')) + ++i; + setFormat(i, found - i, _formats[CodeKeyWord]); + } } + + if (text[i] == QLatin1Char('=')) + { + int lastSpace = text.lastIndexOf(QLatin1Char(' '), i); + if (lastSpace == i - 1) + lastSpace = text.lastIndexOf(QLatin1Char(' '), i - 2); + if (lastSpace > 0) + { + setFormat(lastSpace, i - lastSpace, _formats[CodeBuiltIn]); + } + } + + if (text[i] == QLatin1Char('\"')) + { + const int pos = i; + int cnt = 1; + ++i; + // bound check + if ((i + 1) >= textLen) + return; + while (i < textLen) + { + if (text[i] == QLatin1Char('\"')) + { + ++cnt; + ++i; + break; + } + ++i; + ++cnt; + // bound check + if ((i + 1) >= textLen) + { + ++cnt; + break; + } + } + setFormat(pos, cnt, _formats[CodeString]); + } + } } void QSourceHighliter::makeHighlighter(const QString &text) { - int colonPos = text.indexOf(QLatin1Char(':')); - if (colonPos == -1) - return; - setFormat(0, colonPos, _formats[Token::CodeBuiltIn]); + int colonPos = text.indexOf(QLatin1Char(':')); + if (colonPos == -1) + return; + setFormat(0, colonPos, _formats[Token::CodeBuiltIn]); } /** @@ -848,93 +989,110 @@ void QSourceHighliter::makeHighlighter(const QString &text) void QSourceHighliter::highlightInlineAsmLabels(const QString &text) { #define Q(s) QStringLiteral(s) - static const QString jumps[27] = { - //0 - 19 - Q("jmp"), Q("je"), Q("jne"), Q("jz"), Q("jnz"), Q("ja"), Q("jb"), Q("jg"), Q("jge"), Q("jae"), Q("jl"), Q("jle"), - Q("jbe"), Q("jo"), Q("jno"), Q("js"), Q("jns"), Q("jcxz"), Q("jecxz"), Q("jrcxz"), - //20 - 24 - Q("loop"), Q("loope"), Q("loopne"), Q("loopz"), Q("loopnz"), - //25 - 26 - Q("call"), Q("callq") - }; + static const QString jumps[27] + = {// 0 - 19 + Q("jmp"), Q("je"), Q("jne"), Q("jz"), Q("jnz"), Q("ja"), Q("jb"), + Q("jg"), Q("jge"), Q("jae"), Q("jl"), Q("jle"), Q("jbe"), Q("jo"), + Q("jno"), Q("js"), Q("jns"), Q("jcxz"), Q("jecxz"), Q("jrcxz"), + // 20 - 24 + Q("loop"), Q("loope"), Q("loopne"), Q("loopz"), Q("loopnz"), + // 25 - 26 + Q("call"), Q("callq")}; #undef Q - auto format = _formats[Token::CodeBuiltIn]; - format.setFontUnderline(true); + auto format = _formats[Token::CodeBuiltIn]; + format.setFontUnderline(true); - const QString trimmed = text.trimmed(); - int start = -1; - int end = -1; - char c{}; - if (!trimmed.isEmpty()) - c = trimmed.at(0).toLatin1(); - if (c == 'j') { - start = 0; end = 20; - } else if (c == 'c') { - start = 25; end = 27; - } else if (c == 'l') { - start = 20; end = 25; - } else { - return; - } - - auto skipSpaces = [&text](int& j){ - while (text.at(j).isSpace()) j++; - return j; - }; - - for (int i = start; i < end; ++i) { - if (trimmed.startsWith(jumps[i])) { - int j = 0; - skipSpaces(j); - j = j + jumps[i].length() + 1; - skipSpaces(j); - int len = text.length() - j; - setFormat(j, len, format); - } + const QString trimmed = text.trimmed(); + int start = -1; + int end = -1; + char c{}; + if (!trimmed.isEmpty()) + c = trimmed.at(0).toLatin1(); + if (c == 'j') + { + start = 0; + end = 20; + } + else if (c == 'c') + { + start = 25; + end = 27; + } + else if (c == 'l') + { + start = 20; + end = 25; + } + else + { + return; + } + + auto skipSpaces = [&text](int &j) { + while (text.at(j).isSpace()) + j++; + return j; + }; + + for (int i = start; i < end; ++i) + { + if (trimmed.startsWith(jumps[i])) + { + int j = 0; + skipSpaces(j); + j = j + jumps[i].length() + 1; + skipSpaces(j); + int len = text.length() - j; + setFormat(j, len, format); } + } } -void QSourceHighliter::asmHighlighter(const QString& text) +void QSourceHighliter::asmHighlighter(const QString &text) { - highlightInlineAsmLabels(text); - //label highlighting - //examples: - //L1: - //LFB1: # local func begin - // - //following e.gs are not a label - //mov %eax, Count::count(%rip) - //.string ": #%s" + highlightInlineAsmLabels(text); + // label highlighting + // examples: + // L1: + // LFB1: # local func begin + // + // following e.gs are not a label + // mov %eax, Count::count(%rip) + //.string ": #%s" - //look for the last occurence of a colon - int colonPos = text.lastIndexOf(QLatin1Char(':')); - if (colonPos == -1) - return; - //check if this colon is in a comment maybe? - bool isComment = text.lastIndexOf('#', colonPos) != -1; - if (isComment) { - int commentPos = text.lastIndexOf('#', colonPos); - colonPos = text.lastIndexOf(':', commentPos); + // look for the last occurence of a colon + int colonPos = text.lastIndexOf(QLatin1Char(':')); + if (colonPos == -1) + return; + // check if this colon is in a comment maybe? + bool isComment = text.lastIndexOf('#', colonPos) != -1; + if (isComment) + { + int commentPos = text.lastIndexOf('#', colonPos); + colonPos = text.lastIndexOf(':', commentPos); + } + + auto format = _formats[Token::CodeBuiltIn]; + format.setFontUnderline(true); + + if (colonPos >= text.length() - 1) + { + setFormat(0, colonPos, format); + } + + int i = 0; + bool isLabel = true; + for (i = colonPos + 1; i < text.length(); ++i) + { + if (!text.at(i).isSpace()) + { + isLabel = false; + break; } + } - auto format = _formats[Token::CodeBuiltIn]; - format.setFontUnderline(true); - - if (colonPos >= text.length() - 1) { - setFormat(0, colonPos, format); - } - - int i = 0; - bool isLabel = true; - for (i = colonPos + 1; i < text.length(); ++i) { - if (!text.at(i).isSpace()) { - isLabel = false; - break; - } - } - - if (!isLabel && i < text.length() && text.at(i) == QLatin1Char('#')) - setFormat(0, colonPos, format); -} + if (!isLabel && i < text.length() && text.at(i) == QLatin1Char('#')) + setFormat(0, colonPos, format); } +} // namespace QSourceHighlite diff --git a/libs/QSourceHighlite/qsourcehighliter.h b/libs/QSourceHighlite/qsourcehighliter.h old mode 100755 new mode 100644 index 2008720e..726f0b2f --- a/libs/QSourceHighlite/qsourcehighliter.h +++ b/libs/QSourceHighlite/qsourcehighliter.h @@ -8,8 +8,8 @@ * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -27,143 +27,146 @@ #include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include +# include #endif -namespace QSourceHighlite { +namespace QSourceHighlite +{ class QSourceHighliter : public QSyntaxHighlighter { public: - enum Themes { - Monokai = 1 - }; + enum Themes + { + Monokai = 1 + }; - explicit QSourceHighliter(QTextDocument *doc); - QSourceHighliter(QTextDocument *doc, Themes theme); + explicit QSourceHighliter(QTextDocument *doc); + QSourceHighliter(QTextDocument *doc, Themes theme); - //languages - /********* - * When adding a language make sure that its value is a multiple of 2 - * This is because we use the next number as comment for that language - * In case the language doesn't support multiline comments in the traditional C++ - * sense, leave the next value empty. Otherwise mark the next value as comment for - * that language. - * e.g - * CodeCpp = 200 - * CodeCppComment = 201 - */ - enum Language { - //languages - CodeCpp = 200, - CodeCppComment = 201, - CodeJs = 202, - CodeJsComment = 203, - CodeC = 204, - CodeCComment = 205, - CodeBash = 206, - CodePHP = 208, - CodePHPComment = 209, - CodeQML = 210, - CodeQMLComment = 211, - CodePython = 212, - CodeRust = 214, - CodeRustComment = 215, - CodeJava = 216, - CodeJavaComment = 217, - CodeCSharp = 218, - CodeCSharpComment = 219, - CodeGo = 220, - CodeGoComment = 221, - CodeV = 222, - CodeVComment = 223, - CodeSQL = 224, - CodeJSON = 226, - CodeXML = 228, - CodeCSS = 230, - CodeCSSComment = 231, - CodeTypeScript = 232, - CodeTypeScriptComment = 233, - CodeYAML = 234, - CodeINI = 236, - CodeVex = 238, - CodeVexComment = 239, - CodeCMake = 240, - CodeMake = 242, - CodeAsm = 244, - CodeLua = 246, - CodeLuaComment = 247 - }; - Q_ENUM(Language) + // languages + /********* + * When adding a language make sure that its value is a multiple of 2 + * This is because we use the next number as comment for that language + * In case the language doesn't support multiline comments in the traditional + * C++ sense, leave the next value empty. Otherwise mark the next value as + * comment for that language. e.g CodeCpp = 200 CodeCppComment = 201 + */ + enum Language + { + // languages + CodeCpp = 200, + CodeCppComment = 201, + CodeJs = 202, + CodeJsComment = 203, + CodeC = 204, + CodeCComment = 205, + CodeBash = 206, + CodePHP = 208, + CodePHPComment = 209, + CodeQML = 210, + CodeQMLComment = 211, + CodePython = 212, + CodeRust = 214, + CodeRustComment = 215, + CodeJava = 216, + CodeJavaComment = 217, + CodeCSharp = 218, + CodeCSharpComment = 219, + CodeGo = 220, + CodeGoComment = 221, + CodeV = 222, + CodeVComment = 223, + CodeSQL = 224, + CodeJSON = 226, + CodeXML = 228, + CodeCSS = 230, + CodeCSSComment = 231, + CodeTypeScript = 232, + CodeTypeScriptComment = 233, + CodeYAML = 234, + CodeINI = 236, + CodeVex = 238, + CodeVexComment = 239, + CodeCMake = 240, + CodeMake = 242, + CodeAsm = 244, + CodeLua = 246, + CodeLuaComment = 247 + }; + Q_ENUM(Language) - enum Token { - CodeBlock, - CodeKeyWord, - CodeString, - CodeComment, - CodeType, - CodeOther, - CodeNumLiteral, - CodeBuiltIn, - }; - Q_ENUM(Token) + enum Token + { + CodeBlock, + CodeKeyWord, + CodeString, + CodeComment, + CodeType, + CodeOther, + CodeNumLiteral, + CodeBuiltIn, + }; + Q_ENUM(Token) - void setCurrentLanguage(Language language); - Q_REQUIRED_RESULT Language currentLanguage(); - void setTheme(Themes theme); + void setCurrentLanguage(Language language); + Q_REQUIRED_RESULT Language currentLanguage(); + void setTheme(Themes theme); protected: - void highlightBlock(const QString &text) override; + void highlightBlock(const QString &text) override; private: - void highlightSyntax(const QString &text); - Q_REQUIRED_RESULT int highlightNumericLiterals(const QString &text, int i); - Q_REQUIRED_RESULT int highlightStringLiterals(const QChar strType, const QString &text, int i); + void highlightSyntax(const QString &text); + Q_REQUIRED_RESULT int highlightNumericLiterals(const QString &text, int i); + Q_REQUIRED_RESULT int highlightStringLiterals(const QChar strType, + const QString &text, int i); - /** - * @brief returns true if c is octal - * @param c the char being checked - * @returns true if the number is octal, false otherwise - */ - Q_REQUIRED_RESULT static constexpr inline bool isOctal(const char c) { - return (c >= '0' && c <= '7'); - } + /** + * @brief returns true if c is octal + * @param c the char being checked + * @returns true if the number is octal, false otherwise + */ + Q_REQUIRED_RESULT static constexpr inline bool isOctal(const char c) + { + return (c >= '0' && c <= '7'); + } - /** - * @brief returns true if c is hex - * @param c the char being checked - * @returns true if the number is hex, false otherwise - */ - Q_REQUIRED_RESULT static constexpr inline bool isHex(const char c) { - return ( - (c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F') - ); - } + /** + * @brief returns true if c is hex + * @param c the char being checked + * @returns true if the number is hex, false otherwise + */ + Q_REQUIRED_RESULT static constexpr inline bool isHex(const char c) + { + return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F')); + } - void cssHighlighter(const QString &text); - void ymlHighlighter(const QString &text); - void xmlHighlighter(const QString &text); - void makeHighlighter(const QString &text); - void highlightInlineAsmLabels(const QString& text); - void asmHighlighter(const QString& text); - void initFormats(); + void cssHighlighter(const QString &text); + void ymlHighlighter(const QString &text); + void xmlHighlighter(const QString &text); + void makeHighlighter(const QString &text); + void highlightInlineAsmLabels(const QString &text); + void asmHighlighter(const QString &text); + void initFormats(); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - static inline QStringView strMidRef(const QString& str, qsizetype position, qsizetype n = -1) - { - return QStringView(str).mid(position, n); - } + static inline QStringView strMidRef(const QString &str, qsizetype position, + qsizetype n = -1) + { + return QStringView(str).mid(position, n); + } #else - static inline QStringRef strMidRef(const QString& str, int position, int n = -1) - { - return str.midRef(position, n); - } + static inline QStringRef strMidRef(const QString &str, int position, + int n = -1) + { + return str.midRef(position, n); + } #endif - QHash _formats; - Language _language; + QHash _formats; + Language _language; }; -} +} // namespace QSourceHighlite #endif // QSOURCEHIGHLITER_H diff --git a/libs/QSourceHighlite/qsourcehighliterthemes.cpp b/libs/QSourceHighlite/qsourcehighliterthemes.cpp old mode 100755 new mode 100644 index 5ba7a8b2..80afb91b --- a/libs/QSourceHighlite/qsourcehighliterthemes.cpp +++ b/libs/QSourceHighlite/qsourcehighliterthemes.cpp @@ -8,8 +8,8 @@ * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -23,50 +23,61 @@ #include "qsourcehighliterthemes.h" -namespace QSourceHighlite { +namespace QSourceHighlite +{ static QHash formats() { - QHash _formats; + QHash _formats; - QTextCharFormat defaultFormat = QTextCharFormat(); + QTextCharFormat defaultFormat = QTextCharFormat(); - _formats[QSourceHighliter::Token::CodeBlock] = defaultFormat; - _formats[QSourceHighliter::Token::CodeKeyWord] = defaultFormat; - _formats[QSourceHighliter::Token::CodeString] = defaultFormat; - _formats[QSourceHighliter::Token::CodeComment] = defaultFormat; - _formats[QSourceHighliter::Token::CodeType] = defaultFormat; - _formats[QSourceHighliter::Token::CodeOther] = defaultFormat; - _formats[QSourceHighliter::Token::CodeNumLiteral] = defaultFormat; - _formats[QSourceHighliter::Token::CodeBuiltIn] = defaultFormat; + _formats[QSourceHighliter::Token::CodeBlock] = defaultFormat; + _formats[QSourceHighliter::Token::CodeKeyWord] = defaultFormat; + _formats[QSourceHighliter::Token::CodeString] = defaultFormat; + _formats[QSourceHighliter::Token::CodeComment] = defaultFormat; + _formats[QSourceHighliter::Token::CodeType] = defaultFormat; + _formats[QSourceHighliter::Token::CodeOther] = defaultFormat; + _formats[QSourceHighliter::Token::CodeNumLiteral] = defaultFormat; + _formats[QSourceHighliter::Token::CodeBuiltIn] = defaultFormat; - return _formats; + return _formats; } static QHash monokai() { - QHash _formats = formats(); + QHash _formats = formats(); - _formats[QSourceHighliter::Token::CodeBlock].setForeground(QColor(227, 226, 214)); - _formats[QSourceHighliter::Token::CodeKeyWord].setForeground(QColor(249, 38, 114)); - _formats[QSourceHighliter::Token::CodeString].setForeground(QColor(230, 219, 116)); - _formats[QSourceHighliter::Token::CodeComment].setForeground(QColor(117, 113, 94)); - _formats[QSourceHighliter::Token::CodeType].setForeground(QColor(102, 217, 239)); - _formats[QSourceHighliter::Token::CodeOther].setForeground(QColor(249, 38, 114)); - _formats[QSourceHighliter::Token::CodeNumLiteral].setForeground(QColor(174, 129, 255)); - _formats[QSourceHighliter::Token::CodeBuiltIn].setForeground(QColor(166, 226, 46)); + _formats[QSourceHighliter::Token::CodeBlock].setForeground( + QColor(227, 226, 214)); + _formats[QSourceHighliter::Token::CodeKeyWord].setForeground( + QColor(249, 38, 114)); + _formats[QSourceHighliter::Token::CodeString].setForeground( + QColor(230, 219, 116)); + _formats[QSourceHighliter::Token::CodeComment].setForeground( + QColor(117, 113, 94)); + _formats[QSourceHighliter::Token::CodeType].setForeground( + QColor(102, 217, 239)); + _formats[QSourceHighliter::Token::CodeOther].setForeground( + QColor(249, 38, 114)); + _formats[QSourceHighliter::Token::CodeNumLiteral].setForeground( + QColor(174, 129, 255)); + _formats[QSourceHighliter::Token::CodeBuiltIn].setForeground( + QColor(166, 226, 46)); - return _formats; + return _formats; } QHash - QSourceHighliterTheme::theme(QSourceHighliter::Themes theme) { - switch (theme) { +QSourceHighliterTheme::theme(QSourceHighliter::Themes theme) +{ + switch (theme) + { case QSourceHighliter::Themes::Monokai: - return monokai(); + return monokai(); default: - return {}; - } + return {}; + } } -} +} // namespace QSourceHighlite diff --git a/libs/QSourceHighlite/qsourcehighliterthemes.h b/libs/QSourceHighlite/qsourcehighliterthemes.h old mode 100755 new mode 100644 index eacabaec..6dd5a4a6 --- a/libs/QSourceHighlite/qsourcehighliterthemes.h +++ b/libs/QSourceHighlite/qsourcehighliterthemes.h @@ -8,8 +8,8 @@ * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -26,11 +26,12 @@ #include "qsourcehighliter.h" -namespace QSourceHighlite { +namespace QSourceHighlite +{ namespace QSourceHighliterTheme { - QHash theme(QSourceHighliter::Themes); +QHash theme(QSourceHighliter::Themes); } // namespace QSourceHighliterTheme diff --git a/libs/qwt/src/qwt.cpp b/libs/qwt/src/qwt.cpp index 8804441e..3292ff0e 100644 --- a/libs/qwt/src/qwt.cpp +++ b/libs/qwt/src/qwt.cpp @@ -13,16 +13,16 @@ #define QWT_GLOBAL_STRUT #if QT_VERSION >= 0x050000 - #if QT_VERSION >= 0x060000 || !QT_DEPRECATED_SINCE(5, 15) - #undef QWT_GLOBAL_STRUT - #endif +# if QT_VERSION >= 0x060000 || !QT_DEPRECATED_SINCE(5, 15) +# undef QWT_GLOBAL_STRUT +# endif #endif -QSize qwtExpandedToGlobalStrut( const QSize& size ) +QSize qwtExpandedToGlobalStrut(const QSize &size) { #ifdef QWT_GLOBAL_STRUT - return size.expandedTo( QApplication::globalStrut() ); + return size.expandedTo(QApplication::globalStrut()); #else - return size; + return size; #endif } diff --git a/libs/qwt/src/qwt.h b/libs/qwt/src/qwt.h index b6105500..fc442263 100644 --- a/libs/qwt/src/qwt.h +++ b/libs/qwt/src/qwt.h @@ -21,6 +21,6 @@ namespace Qwt { } -QWT_EXPORT QSize qwtExpandedToGlobalStrut( const QSize& ); +QWT_EXPORT QSize qwtExpandedToGlobalStrut(const QSize &); #endif diff --git a/libs/qwt/src/qwt_abstract_legend.cpp b/libs/qwt/src/qwt_abstract_legend.cpp index 739ef441..81c4676c 100644 --- a/libs/qwt/src/qwt_abstract_legend.cpp +++ b/libs/qwt/src/qwt_abstract_legend.cpp @@ -15,15 +15,13 @@ \param parent Parent widget */ -QwtAbstractLegend::QwtAbstractLegend( QWidget* parent ) - : QFrame( parent ) +QwtAbstractLegend::QwtAbstractLegend(QWidget *parent) + : QFrame(parent) { } //! Destructor -QwtAbstractLegend::~QwtAbstractLegend() -{ -} +QwtAbstractLegend::~QwtAbstractLegend() {} /*! Return the extent, that is needed for elements to scroll @@ -32,12 +30,12 @@ QwtAbstractLegend::~QwtAbstractLegend() \param orientation Orientation \return Extent of the corresponding scroll element */ -int QwtAbstractLegend::scrollExtent( Qt::Orientation orientation ) const +int QwtAbstractLegend::scrollExtent(Qt::Orientation orientation) const { - Q_UNUSED( orientation ); - return 0; + Q_UNUSED(orientation); + return 0; } #if QWT_MOC_INCLUDE -#include "moc_qwt_abstract_legend.cpp" +# include "moc_qwt_abstract_legend.cpp" #endif diff --git a/libs/qwt/src/qwt_abstract_legend.h b/libs/qwt/src/qwt_abstract_legend.h index 576a6bee..a0b16831 100644 --- a/libs/qwt/src/qwt_abstract_legend.h +++ b/libs/qwt/src/qwt_abstract_legend.h @@ -14,7 +14,8 @@ #include class QwtLegendData; -template< typename T > class QList; +template +class QList; class QVariant; /*! @@ -33,39 +34,41 @@ class QVariant; */ class QWT_EXPORT QwtAbstractLegend : public QFrame { - Q_OBJECT + Q_OBJECT - public: - explicit QwtAbstractLegend( QWidget* parent = NULL ); - virtual ~QwtAbstractLegend(); +public: + explicit QwtAbstractLegend(QWidget *parent = NULL); + virtual ~QwtAbstractLegend(); - /*! - Render the legend into a given rectangle. + /*! + Render the legend into a given rectangle. - \param painter Painter - \param rect Bounding rectangle - \param fillBackground When true, fill rect with the widget background + \param painter Painter + \param rect Bounding rectangle + \param fillBackground When true, fill rect with the widget background - \sa renderLegend() is used by QwtPlotRenderer - */ - virtual void renderLegend( QPainter* painter, - const QRectF& rect, bool fillBackground ) const = 0; + \sa renderLegend() is used by QwtPlotRenderer + */ + virtual void renderLegend(QPainter *painter, const QRectF &rect, + bool fillBackground) const + = 0; - //! \return True, when no plot item is inserted - virtual bool isEmpty() const = 0; + //! \return True, when no plot item is inserted + virtual bool isEmpty() const = 0; - virtual int scrollExtent( Qt::Orientation ) const; + virtual int scrollExtent(Qt::Orientation) const; - public Q_SLOTS: +public Q_SLOTS: - /*! - \brief Update the entries for a plot item + /*! + \brief Update the entries for a plot item - \param itemInfo Info about an item - \param data List of legend entry attributes for the item - */ - virtual void updateLegend( const QVariant& itemInfo, - const QList< QwtLegendData >& data ) = 0; + \param itemInfo Info about an item + \param data List of legend entry attributes for the item + */ + virtual void updateLegend(const QVariant &itemInfo, + const QList &data) + = 0; }; #endif diff --git a/libs/qwt/src/qwt_abstract_scale.cpp b/libs/qwt/src/qwt_abstract_scale.cpp index b04bfc95..4a429af6 100644 --- a/libs/qwt/src/qwt_abstract_scale.cpp +++ b/libs/qwt/src/qwt_abstract_scale.cpp @@ -18,28 +18,28 @@ class QwtAbstractScale::PrivateData { - public: - PrivateData(): - maxMajor( 5 ), - maxMinor( 3 ), - stepSize( 0.0 ) - { - scaleEngine = new QwtLinearScaleEngine(); - scaleDraw = new QwtScaleDraw(); - } +public: + PrivateData() + : maxMajor(5) + , maxMinor(3) + , stepSize(0.0) + { + scaleEngine = new QwtLinearScaleEngine(); + scaleDraw = new QwtScaleDraw(); + } - ~PrivateData() - { - delete scaleEngine; - delete scaleDraw; - } + ~PrivateData() + { + delete scaleEngine; + delete scaleDraw; + } - QwtScaleEngine* scaleEngine; - QwtAbstractScaleDraw* scaleDraw; + QwtScaleEngine *scaleEngine; + QwtAbstractScaleDraw *scaleDraw; - int maxMajor; - int maxMinor; - double stepSize; + int maxMajor; + int maxMinor; + double stepSize; }; /*! @@ -54,17 +54,17 @@ class QwtAbstractScale::PrivateData and scaleMaxMajor to 3. */ -QwtAbstractScale::QwtAbstractScale( QWidget* parent ) - : QWidget( parent ) +QwtAbstractScale::QwtAbstractScale(QWidget *parent) + : QWidget(parent) { - m_data = new PrivateData; - rescale( 0.0, 100.0, m_data->stepSize ); + m_data = new PrivateData; + rescale(0.0, 100.0, m_data->stepSize); } //! Destructor QwtAbstractScale::~QwtAbstractScale() { - delete m_data; + delete m_data; } /*! @@ -76,9 +76,9 @@ QwtAbstractScale::~QwtAbstractScale() \note For inverted scales the lower bound is greater than the upper bound */ -void QwtAbstractScale::setLowerBound( double value ) +void QwtAbstractScale::setLowerBound(double value) { - setScale( value, upperBound() ); + setScale(value, upperBound()); } /*! @@ -87,7 +87,7 @@ void QwtAbstractScale::setLowerBound( double value ) */ double QwtAbstractScale::lowerBound() const { - return m_data->scaleDraw->scaleDiv().lowerBound(); + return m_data->scaleDraw->scaleDiv().lowerBound(); } /*! @@ -99,9 +99,9 @@ double QwtAbstractScale::lowerBound() const \note For inverted scales the lower bound is greater than the upper bound */ -void QwtAbstractScale::setUpperBound( double value ) +void QwtAbstractScale::setUpperBound(double value) { - setScale( lowerBound(), value ); + setScale(lowerBound(), value); } /*! @@ -110,7 +110,7 @@ void QwtAbstractScale::setUpperBound( double value ) */ double QwtAbstractScale::upperBound() const { - return m_data->scaleDraw->scaleDiv().upperBound(); + return m_data->scaleDraw->scaleDiv().upperBound(); } /*! @@ -127,9 +127,9 @@ double QwtAbstractScale::upperBound() const \note For inverted scales the lower bound is greater than the upper bound */ -void QwtAbstractScale::setScale( double lowerBound, double upperBound ) +void QwtAbstractScale::setScale(double lowerBound, double upperBound) { - rescale( lowerBound, upperBound, m_data->stepSize ); + rescale(lowerBound, upperBound, m_data->stepSize); } /*! @@ -142,9 +142,9 @@ void QwtAbstractScale::setScale( double lowerBound, double upperBound ) \param interval Interval */ -void QwtAbstractScale::setScale( const QwtInterval& interval ) +void QwtAbstractScale::setScale(const QwtInterval &interval) { - setScale( interval.minValue(), interval.maxValue() ); + setScale(interval.minValue(), interval.maxValue()); } /*! @@ -155,22 +155,22 @@ void QwtAbstractScale::setScale( const QwtInterval& interval ) \param scaleDiv Scale division \sa setAutoScale() */ -void QwtAbstractScale::setScale( const QwtScaleDiv& scaleDiv ) +void QwtAbstractScale::setScale(const QwtScaleDiv &scaleDiv) { - if ( scaleDiv != m_data->scaleDraw->scaleDiv() ) - { + if (scaleDiv != m_data->scaleDraw->scaleDiv()) + { #if 1 - if ( m_data->scaleEngine ) - { - m_data->scaleDraw->setTransformation( - m_data->scaleEngine->transformation() ); - } + if (m_data->scaleEngine) + { + m_data->scaleDraw->setTransformation( + m_data->scaleEngine->transformation()); + } #endif - m_data->scaleDraw->setScaleDiv( scaleDiv ); + m_data->scaleDraw->setScaleDiv(scaleDiv); - scaleChange(); - } + scaleChange(); + } } /*! @@ -186,13 +186,13 @@ void QwtAbstractScale::setScale( const QwtScaleDiv& scaleDiv ) \sa scaleMaxMajor(), setScaleMaxMinor(), setScaleStepSize(), QwtScaleEngine::divideInterval() */ -void QwtAbstractScale::setScaleMaxMajor( int ticks ) +void QwtAbstractScale::setScaleMaxMajor(int ticks) { - if ( ticks != m_data->maxMajor ) - { - m_data->maxMajor = ticks; - updateScaleDraw(); - } + if (ticks != m_data->maxMajor) + { + m_data->maxMajor = ticks; + updateScaleDraw(); + } } /*! @@ -201,7 +201,7 @@ void QwtAbstractScale::setScaleMaxMajor( int ticks ) */ int QwtAbstractScale::scaleMaxMajor() const { - return m_data->maxMajor; + return m_data->maxMajor; } /*! @@ -216,13 +216,13 @@ int QwtAbstractScale::scaleMaxMajor() const \sa scaleMaxMajor(), setScaleMaxMinor(), setScaleStepSize(), QwtScaleEngine::divideInterval() */ -void QwtAbstractScale::setScaleMaxMinor( int ticks ) +void QwtAbstractScale::setScaleMaxMinor(int ticks) { - if ( ticks != m_data->maxMinor ) - { - m_data->maxMinor = ticks; - updateScaleDraw(); - } + if (ticks != m_data->maxMinor) + { + m_data->maxMinor = ticks; + updateScaleDraw(); + } } /*! @@ -231,7 +231,7 @@ void QwtAbstractScale::setScaleMaxMinor( int ticks ) */ int QwtAbstractScale::scaleMaxMinor() const { - return m_data->maxMinor; + return m_data->maxMinor; } /*! @@ -248,13 +248,13 @@ int QwtAbstractScale::scaleMaxMinor() const \note Position and distance between the major ticks also depends on scaleMaxMajor(). */ -void QwtAbstractScale::setScaleStepSize( double stepSize ) +void QwtAbstractScale::setScaleStepSize(double stepSize) { - if ( stepSize != m_data->stepSize ) - { - m_data->stepSize = stepSize; - updateScaleDraw(); - } + if (stepSize != m_data->stepSize) + { + m_data->stepSize = stepSize; + updateScaleDraw(); + } } /*! @@ -263,7 +263,7 @@ void QwtAbstractScale::setScaleStepSize( double stepSize ) */ double QwtAbstractScale::scaleStepSize() const { - return m_data->stepSize; + return m_data->stepSize; } /*! @@ -274,34 +274,34 @@ double QwtAbstractScale::scaleStepSize() const \sa abstractScaleDraw() */ -void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw* scaleDraw ) +void QwtAbstractScale::setAbstractScaleDraw(QwtAbstractScaleDraw *scaleDraw) { - if ( scaleDraw == NULL || scaleDraw == m_data->scaleDraw ) - return; + if (scaleDraw == NULL || scaleDraw == m_data->scaleDraw) + return; - if ( m_data->scaleDraw != NULL ) - scaleDraw->setScaleDiv( m_data->scaleDraw->scaleDiv() ); + if (m_data->scaleDraw != NULL) + scaleDraw->setScaleDiv(m_data->scaleDraw->scaleDiv()); - delete m_data->scaleDraw; - m_data->scaleDraw = scaleDraw; + delete m_data->scaleDraw; + m_data->scaleDraw = scaleDraw; } /*! \return Scale draw \sa setAbstractScaleDraw() */ -QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw() +QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() { - return m_data->scaleDraw; + return m_data->scaleDraw; } /*! \return Scale draw \sa setAbstractScaleDraw() */ -const QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw() const +const QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() const { - return m_data->scaleDraw; + return m_data->scaleDraw; } /*! @@ -313,31 +313,31 @@ const QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw() const scaleEngine has to be created with new and will be deleted in the destructor or the next call of setScaleEngine. */ -void QwtAbstractScale::setScaleEngine( QwtScaleEngine* scaleEngine ) +void QwtAbstractScale::setScaleEngine(QwtScaleEngine *scaleEngine) { - if ( scaleEngine != NULL && scaleEngine != m_data->scaleEngine ) - { - delete m_data->scaleEngine; - m_data->scaleEngine = scaleEngine; - } + if (scaleEngine != NULL && scaleEngine != m_data->scaleEngine) + { + delete m_data->scaleEngine; + m_data->scaleEngine = scaleEngine; + } } /*! \return Scale engine \sa setScaleEngine() */ -const QwtScaleEngine* QwtAbstractScale::scaleEngine() const +const QwtScaleEngine *QwtAbstractScale::scaleEngine() const { - return m_data->scaleEngine; + return m_data->scaleEngine; } /*! \return Scale engine \sa setScaleEngine() */ -QwtScaleEngine* QwtAbstractScale::scaleEngine() +QwtScaleEngine *QwtAbstractScale::scaleEngine() { - return m_data->scaleEngine; + return m_data->scaleEngine; } /*! @@ -346,17 +346,17 @@ QwtScaleEngine* QwtAbstractScale::scaleEngine() The scale division might have been assigned explicitly or calculated implicitly by rescale(). */ -const QwtScaleDiv& QwtAbstractScale::scaleDiv() const +const QwtScaleDiv &QwtAbstractScale::scaleDiv() const { - return m_data->scaleDraw->scaleDiv(); + return m_data->scaleDraw->scaleDiv(); } /*! \return Map to translate between scale and widget coordinates */ -const QwtScaleMap& QwtAbstractScale::scaleMap() const +const QwtScaleMap &QwtAbstractScale::scaleMap() const { - return m_data->scaleDraw->scaleMap(); + return m_data->scaleDraw->scaleMap(); } /*! @@ -366,9 +366,9 @@ const QwtScaleMap& QwtAbstractScale::scaleMap() const \return Corresponding widget coordinate for value \sa scaleMap(), invTransform() */ -int QwtAbstractScale::transform( double value ) const +int QwtAbstractScale::transform(double value) const { - return qRound( m_data->scaleDraw->scaleMap().transform( value ) ); + return qRound(m_data->scaleDraw->scaleMap().transform(value)); } /*! @@ -378,9 +378,9 @@ int QwtAbstractScale::transform( double value ) const \return Corresponding scale coordinate for value \sa scaleMap(), transform() */ -double QwtAbstractScale::invTransform( int value ) const +double QwtAbstractScale::invTransform(int value) const { - return m_data->scaleDraw->scaleMap().invTransform( value ); + return m_data->scaleDraw->scaleMap().invTransform(value); } /*! @@ -389,7 +389,7 @@ double QwtAbstractScale::invTransform( int value ) const */ bool QwtAbstractScale::isInverted() const { - return m_data->scaleDraw->scaleMap().isInverting(); + return m_data->scaleDraw->scaleMap().isInverting(); } /*! @@ -398,8 +398,8 @@ bool QwtAbstractScale::isInverted() const */ double QwtAbstractScale::minimum() const { - return qMin( m_data->scaleDraw->scaleDiv().lowerBound(), - m_data->scaleDraw->scaleDiv().upperBound() ); + return qMin(m_data->scaleDraw->scaleDiv().lowerBound(), + m_data->scaleDraw->scaleDiv().upperBound()); } /*! @@ -408,14 +408,12 @@ double QwtAbstractScale::minimum() const */ double QwtAbstractScale::maximum() const { - return qMax( m_data->scaleDraw->scaleDiv().lowerBound(), - m_data->scaleDraw->scaleDiv().upperBound() ); + return qMax(m_data->scaleDraw->scaleDiv().lowerBound(), + m_data->scaleDraw->scaleDiv().upperBound()); } //! Notify changed scale -void QwtAbstractScale::scaleChange() -{ -} +void QwtAbstractScale::scaleChange() {} /*! Recalculate the scale division and update the scale. @@ -426,22 +424,21 @@ void QwtAbstractScale::scaleChange() \sa scaleChange() */ -void QwtAbstractScale::rescale( - double lowerBound, double upperBound, double stepSize ) +void QwtAbstractScale::rescale(double lowerBound, double upperBound, + double stepSize) { - const QwtScaleDiv scaleDiv = m_data->scaleEngine->divideScale( - lowerBound, upperBound, m_data->maxMajor, m_data->maxMinor, stepSize ); + const QwtScaleDiv scaleDiv = m_data->scaleEngine->divideScale( + lowerBound, upperBound, m_data->maxMajor, m_data->maxMinor, stepSize); - if ( scaleDiv != m_data->scaleDraw->scaleDiv() ) - { + if (scaleDiv != m_data->scaleDraw->scaleDiv()) + { #if 1 - m_data->scaleDraw->setTransformation( - m_data->scaleEngine->transformation() ); + m_data->scaleDraw->setTransformation(m_data->scaleEngine->transformation()); #endif - m_data->scaleDraw->setScaleDiv( scaleDiv ); - scaleChange(); - } + m_data->scaleDraw->setScaleDiv(scaleDiv); + scaleChange(); + } } /*! @@ -450,14 +447,14 @@ void QwtAbstractScale::rescale( Invalidates internal caches if necessary */ -void QwtAbstractScale::changeEvent( QEvent* event ) +void QwtAbstractScale::changeEvent(QEvent *event) { - if ( event->type() == QEvent::LocaleChange ) - { - m_data->scaleDraw->invalidateCache(); - } + if (event->type() == QEvent::LocaleChange) + { + m_data->scaleDraw->invalidateCache(); + } - QWidget::changeEvent( event ); + QWidget::changeEvent(event); } /*! @@ -465,10 +462,10 @@ void QwtAbstractScale::changeEvent( QEvent* event ) */ void QwtAbstractScale::updateScaleDraw() { - rescale( m_data->scaleDraw->scaleDiv().lowerBound(), - m_data->scaleDraw->scaleDiv().upperBound(), m_data->stepSize ); + rescale(m_data->scaleDraw->scaleDiv().lowerBound(), + m_data->scaleDraw->scaleDiv().upperBound(), m_data->stepSize); } #if QWT_MOC_INCLUDE -#include "moc_qwt_abstract_scale.cpp" +# include "moc_qwt_abstract_scale.cpp" #endif diff --git a/libs/qwt/src/qwt_abstract_scale.h b/libs/qwt/src/qwt_abstract_scale.h index ec55f2a4..620e8c2f 100644 --- a/libs/qwt/src/qwt_abstract_scale.h +++ b/libs/qwt/src/qwt_abstract_scale.h @@ -35,72 +35,71 @@ class QwtInterval; class QWT_EXPORT QwtAbstractScale : public QWidget { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( double lowerBound READ lowerBound WRITE setLowerBound ) - Q_PROPERTY( double upperBound READ upperBound WRITE setUpperBound ) + Q_PROPERTY(double lowerBound READ lowerBound WRITE setLowerBound) + Q_PROPERTY(double upperBound READ upperBound WRITE setUpperBound) - Q_PROPERTY( int scaleMaxMajor READ scaleMaxMajor WRITE setScaleMaxMajor ) - Q_PROPERTY( int scaleMaxMinor READ scaleMaxMinor WRITE setScaleMaxMinor ) + Q_PROPERTY(int scaleMaxMajor READ scaleMaxMajor WRITE setScaleMaxMajor) + Q_PROPERTY(int scaleMaxMinor READ scaleMaxMinor WRITE setScaleMaxMinor) - Q_PROPERTY( double scaleStepSize READ scaleStepSize WRITE setScaleStepSize ) + Q_PROPERTY(double scaleStepSize READ scaleStepSize WRITE setScaleStepSize) - public: - explicit QwtAbstractScale( QWidget* parent = NULL ); - virtual ~QwtAbstractScale(); +public: + explicit QwtAbstractScale(QWidget *parent = NULL); + virtual ~QwtAbstractScale(); - void setScale( double lowerBound, double upperBound ); - void setScale( const QwtInterval& ); - void setScale( const QwtScaleDiv& ); + void setScale(double lowerBound, double upperBound); + void setScale(const QwtInterval &); + void setScale(const QwtScaleDiv &); - const QwtScaleDiv& scaleDiv() const; + const QwtScaleDiv &scaleDiv() const; - void setLowerBound( double value ); - double lowerBound() const; + void setLowerBound(double value); + double lowerBound() const; - void setUpperBound( double value ); - double upperBound() const; + void setUpperBound(double value); + double upperBound() const; - void setScaleStepSize( double stepSize ); - double scaleStepSize() const; + void setScaleStepSize(double stepSize); + double scaleStepSize() const; - void setScaleMaxMajor( int ticks ); - int scaleMaxMinor() const; + void setScaleMaxMajor(int ticks); + int scaleMaxMinor() const; - void setScaleMaxMinor( int ticks ); - int scaleMaxMajor() const; + void setScaleMaxMinor(int ticks); + int scaleMaxMajor() const; - void setScaleEngine( QwtScaleEngine* ); - const QwtScaleEngine* scaleEngine() const; - QwtScaleEngine* scaleEngine(); + void setScaleEngine(QwtScaleEngine *); + const QwtScaleEngine *scaleEngine() const; + QwtScaleEngine *scaleEngine(); - int transform( double ) const; - double invTransform( int ) const; + int transform(double) const; + double invTransform(int) const; - bool isInverted() const; + bool isInverted() const; - double minimum() const; - double maximum() const; + double minimum() const; + double maximum() const; - const QwtScaleMap& scaleMap() const; + const QwtScaleMap &scaleMap() const; - protected: - virtual void changeEvent( QEvent* ) QWT_OVERRIDE; +protected: + virtual void changeEvent(QEvent *) QWT_OVERRIDE; - void rescale( double lowerBound, - double upperBound, double stepSize ); + void rescale(double lowerBound, double upperBound, double stepSize); - void setAbstractScaleDraw( QwtAbstractScaleDraw* ); + void setAbstractScaleDraw(QwtAbstractScaleDraw *); - const QwtAbstractScaleDraw* abstractScaleDraw() const; - QwtAbstractScaleDraw* abstractScaleDraw(); + const QwtAbstractScaleDraw *abstractScaleDraw() const; + QwtAbstractScaleDraw *abstractScaleDraw(); - void updateScaleDraw(); - virtual void scaleChange(); + void updateScaleDraw(); + virtual void scaleChange(); - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_abstract_scale_draw.cpp b/libs/qwt/src/qwt_abstract_scale_draw.cpp index abbcb91a..cf9e60ef 100644 --- a/libs/qwt/src/qwt_abstract_scale_draw.cpp +++ b/libs/qwt/src/qwt_abstract_scale_draw.cpp @@ -21,33 +21,32 @@ class QwtAbstractScaleDraw::PrivateData { - public: - PrivateData(): - spacing( 4.0 ), - penWidthF( 0.0 ), - minExtent( 0.0 ) - { - components = QwtAbstractScaleDraw::Backbone - | QwtAbstractScaleDraw::Ticks - | QwtAbstractScaleDraw::Labels; +public: + PrivateData() + : spacing(4.0) + , penWidthF(0.0) + , minExtent(0.0) + { + components = QwtAbstractScaleDraw::Backbone | QwtAbstractScaleDraw::Ticks + | QwtAbstractScaleDraw::Labels; - tickLength[QwtScaleDiv::MinorTick] = 4.0; - tickLength[QwtScaleDiv::MediumTick] = 6.0; - tickLength[QwtScaleDiv::MajorTick] = 8.0; - } + tickLength[QwtScaleDiv::MinorTick] = 4.0; + tickLength[QwtScaleDiv::MediumTick] = 6.0; + tickLength[QwtScaleDiv::MajorTick] = 8.0; + } - ScaleComponents components; + ScaleComponents components; - QwtScaleMap map; - QwtScaleDiv scaleDiv; + QwtScaleMap map; + QwtScaleDiv scaleDiv; - double spacing; - double tickLength[QwtScaleDiv::NTickTypes]; - qreal penWidthF; + double spacing; + double tickLength[QwtScaleDiv::NTickTypes]; + qreal penWidthF; - double minExtent; + double minExtent; - QMap< double, QwtText > labelCache; + QMap labelCache; }; /*! @@ -59,13 +58,13 @@ class QwtAbstractScaleDraw::PrivateData */ QwtAbstractScaleDraw::QwtAbstractScaleDraw() { - m_data = new QwtAbstractScaleDraw::PrivateData; + m_data = new QwtAbstractScaleDraw::PrivateData; } //! Destructor QwtAbstractScaleDraw::~QwtAbstractScaleDraw() { - delete m_data; + delete m_data; } /*! @@ -76,13 +75,13 @@ QwtAbstractScaleDraw::~QwtAbstractScaleDraw() \sa hasComponent() */ -void QwtAbstractScaleDraw::enableComponent( - ScaleComponent component, bool enable ) +void QwtAbstractScaleDraw::enableComponent(ScaleComponent component, + bool enable) { - if ( enable ) - m_data->components |= component; - else - m_data->components &= ~component; + if (enable) + m_data->components |= component; + else + m_data->components &= ~component; } /*! @@ -92,47 +91,47 @@ void QwtAbstractScaleDraw::enableComponent( \return true, when component is enabled \sa enableComponent() */ -bool QwtAbstractScaleDraw::hasComponent( ScaleComponent component ) const +bool QwtAbstractScaleDraw::hasComponent(ScaleComponent component) const { - return ( m_data->components & component ); + return (m_data->components & component); } /*! Change the scale division \param scaleDiv New scale division */ -void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv& scaleDiv ) +void QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &scaleDiv) { - m_data->scaleDiv = scaleDiv; - m_data->map.setScaleInterval( scaleDiv.lowerBound(), scaleDiv.upperBound() ); - m_data->labelCache.clear(); + m_data->scaleDiv = scaleDiv; + m_data->map.setScaleInterval(scaleDiv.lowerBound(), scaleDiv.upperBound()); + m_data->labelCache.clear(); } /*! Change the transformation of the scale \param transformation New scale transformation */ -void QwtAbstractScaleDraw::setTransformation( QwtTransform* transformation ) +void QwtAbstractScaleDraw::setTransformation(QwtTransform *transformation) { - m_data->map.setTransformation( transformation ); + m_data->map.setTransformation(transformation); } //! \return Map how to translate between scale and pixel values -const QwtScaleMap& QwtAbstractScaleDraw::scaleMap() const +const QwtScaleMap &QwtAbstractScaleDraw::scaleMap() const { - return m_data->map; + return m_data->map; } //! \return Map how to translate between scale and pixel values -QwtScaleMap& QwtAbstractScaleDraw::scaleMap() +QwtScaleMap &QwtAbstractScaleDraw::scaleMap() { - return m_data->map; + return m_data->map; } //! \return scale division -const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const +const QwtScaleDiv &QwtAbstractScaleDraw::scaleDiv() const { - return m_data->scaleDiv; + return m_data->scaleDiv; } /*! @@ -141,12 +140,12 @@ const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const \sa penWidth() */ -void QwtAbstractScaleDraw::setPenWidthF( qreal width ) +void QwtAbstractScaleDraw::setPenWidthF(qreal width) { - if ( width < 0.0 ) - width = 0.0; + if (width < 0.0) + width = 0.0; - m_data->penWidthF = width; + m_data->penWidthF = width; } /*! @@ -155,7 +154,7 @@ void QwtAbstractScaleDraw::setPenWidthF( qreal width ) */ qreal QwtAbstractScaleDraw::penWidthF() const { - return m_data->penWidthF; + return m_data->penWidthF; } /*! @@ -166,79 +165,79 @@ qreal QwtAbstractScaleDraw::penWidthF() const \param palette Palette, text color is used for the labels, foreground color for ticks and backbone */ -void QwtAbstractScaleDraw::draw( QPainter* painter, - const QPalette& palette ) const +void QwtAbstractScaleDraw::draw(QPainter *painter, + const QPalette &palette) const { + painter->save(); + + QPen pen = painter->pen(); + pen.setWidthF(m_data->penWidthF); + + painter->setPen(pen); + + if (hasComponent(QwtAbstractScaleDraw::Labels)) + { painter->save(); + painter->setPen(palette.color(QPalette::Text)); // ignore pen style - QPen pen = painter->pen(); - pen.setWidthF( m_data->penWidthF ); + const QList &majorTicks + = m_data->scaleDiv.ticks(QwtScaleDiv::MajorTick); - painter->setPen( pen ); - - if ( hasComponent( QwtAbstractScaleDraw::Labels ) ) + for (int i = 0; i < majorTicks.count(); i++) { - painter->save(); - painter->setPen( palette.color( QPalette::Text ) ); // ignore pen style - - const QList< double >& majorTicks = - m_data->scaleDiv.ticks( QwtScaleDiv::MajorTick ); - - for ( int i = 0; i < majorTicks.count(); i++ ) - { - const double v = majorTicks[i]; - if ( m_data->scaleDiv.contains( v ) ) - drawLabel( painter, v ); - } - - painter->restore(); - } - - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - { - painter->save(); - - pen = painter->pen(); - pen.setColor( palette.color( QPalette::WindowText ) ); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - - for ( int tickType = QwtScaleDiv::MinorTick; - tickType < QwtScaleDiv::NTickTypes; tickType++ ) - { - const double tickLen = m_data->tickLength[tickType]; - if ( tickLen <= 0.0 ) - continue; - - const QList< double >& ticks = m_data->scaleDiv.ticks( tickType ); - for ( int i = 0; i < ticks.count(); i++ ) - { - const double v = ticks[i]; - if ( m_data->scaleDiv.contains( v ) ) - drawTick( painter, v, tickLen ); - } - } - - painter->restore(); - } - - if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) - { - painter->save(); - - pen = painter->pen(); - pen.setColor( palette.color( QPalette::WindowText ) ); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - - drawBackbone( painter ); - - painter->restore(); + const double v = majorTicks[i]; + if (m_data->scaleDiv.contains(v)) + drawLabel(painter, v); } painter->restore(); + } + + if (hasComponent(QwtAbstractScaleDraw::Ticks)) + { + painter->save(); + + pen = painter->pen(); + pen.setColor(palette.color(QPalette::WindowText)); + pen.setCapStyle(Qt::FlatCap); + + painter->setPen(pen); + + for (int tickType = QwtScaleDiv::MinorTick; + tickType < QwtScaleDiv::NTickTypes; tickType++) + { + const double tickLen = m_data->tickLength[tickType]; + if (tickLen <= 0.0) + continue; + + const QList &ticks = m_data->scaleDiv.ticks(tickType); + for (int i = 0; i < ticks.count(); i++) + { + const double v = ticks[i]; + if (m_data->scaleDiv.contains(v)) + drawTick(painter, v, tickLen); + } + } + + painter->restore(); + } + + if (hasComponent(QwtAbstractScaleDraw::Backbone)) + { + painter->save(); + + pen = painter->pen(); + pen.setColor(palette.color(QPalette::WindowText)); + pen.setCapStyle(Qt::FlatCap); + + painter->setPen(pen); + + drawBackbone(painter); + + painter->restore(); + } + + painter->restore(); } /*! @@ -251,12 +250,12 @@ void QwtAbstractScaleDraw::draw( QPainter* painter, \sa spacing() */ -void QwtAbstractScaleDraw::setSpacing( double spacing ) +void QwtAbstractScaleDraw::setSpacing(double spacing) { - if ( spacing < 0 ) - spacing = 0; + if (spacing < 0) + spacing = 0; - m_data->spacing = spacing; + m_data->spacing = spacing; } /*! @@ -270,7 +269,7 @@ void QwtAbstractScaleDraw::setSpacing( double spacing ) */ double QwtAbstractScaleDraw::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! @@ -286,12 +285,12 @@ double QwtAbstractScaleDraw::spacing() const \sa extent(), minimumExtent() */ -void QwtAbstractScaleDraw::setMinimumExtent( double minExtent ) +void QwtAbstractScaleDraw::setMinimumExtent(double minExtent) { - if ( minExtent < 0.0 ) - minExtent = 0.0; + if (minExtent < 0.0) + minExtent = 0.0; - m_data->minExtent = minExtent; + m_data->minExtent = minExtent; } /*! @@ -301,7 +300,7 @@ void QwtAbstractScaleDraw::setMinimumExtent( double minExtent ) */ double QwtAbstractScaleDraw::minimumExtent() const { - return m_data->minExtent; + return m_data->minExtent; } /*! @@ -312,38 +311,36 @@ double QwtAbstractScaleDraw::minimumExtent() const \warning the length is limited to [0..1000] */ -void QwtAbstractScaleDraw::setTickLength( - QwtScaleDiv::TickType tickType, double length ) +void QwtAbstractScaleDraw::setTickLength(QwtScaleDiv::TickType tickType, + double length) { - if ( tickType < QwtScaleDiv::MinorTick || - tickType > QwtScaleDiv::MajorTick ) - { - return; - } + if (tickType < QwtScaleDiv::MinorTick || tickType > QwtScaleDiv::MajorTick) + { + return; + } - if ( length < 0.0 ) - length = 0.0; + if (length < 0.0) + length = 0.0; - const double maxTickLen = 1000.0; - if ( length > maxTickLen ) - length = maxTickLen; + const double maxTickLen = 1000.0; + if (length > maxTickLen) + length = maxTickLen; - m_data->tickLength[tickType] = length; + m_data->tickLength[tickType] = length; } /*! \return Length of the ticks \sa setTickLength(), maxTickLength() */ -double QwtAbstractScaleDraw::tickLength( QwtScaleDiv::TickType tickType ) const +double QwtAbstractScaleDraw::tickLength(QwtScaleDiv::TickType tickType) const { - if ( tickType < QwtScaleDiv::MinorTick || - tickType > QwtScaleDiv::MajorTick ) - { - return 0; - } + if (tickType < QwtScaleDiv::MinorTick || tickType > QwtScaleDiv::MajorTick) + { + return 0; + } - return m_data->tickLength[tickType]; + return m_data->tickLength[tickType]; } /*! @@ -354,11 +351,11 @@ double QwtAbstractScaleDraw::tickLength( QwtScaleDiv::TickType tickType ) const */ double QwtAbstractScaleDraw::maxTickLength() const { - double length = 0.0; - for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) - length = qwtMaxF( length, m_data->tickLength[i] ); + double length = 0.0; + for (int i = 0; i < QwtScaleDiv::NTickTypes; i++) + length = qwtMaxF(length, m_data->tickLength[i]); - return length; + return length; } /*! @@ -372,9 +369,9 @@ double QwtAbstractScaleDraw::maxTickLength() const \param value Value \return Label string. */ -QwtText QwtAbstractScaleDraw::label( double value ) const +QwtText QwtAbstractScaleDraw::label(double value) const { - return QLocale().toString( value ); + return QLocale().toString(value); } /*! @@ -390,21 +387,22 @@ QwtText QwtAbstractScaleDraw::label( double value ) const \return Tick label */ -const QwtText& QwtAbstractScaleDraw::tickLabel( - const QFont& font, double value ) const +const QwtText &QwtAbstractScaleDraw::tickLabel(const QFont &font, + double value) const { - QMap< double, QwtText >::const_iterator it1 = m_data->labelCache.constFind( value ); - if ( it1 != m_data->labelCache.constEnd() ) - return *it1; + QMap::const_iterator it1 + = m_data->labelCache.constFind(value); + if (it1 != m_data->labelCache.constEnd()) + return *it1; - QwtText lbl = label( value ); - lbl.setRenderFlags( 0 ); - lbl.setLayoutAttribute( QwtText::MinimumLayout ); + QwtText lbl = label(value); + lbl.setRenderFlags(0); + lbl.setLayoutAttribute(QwtText::MinimumLayout); - ( void )lbl.textSize( font ); // initialize the internal cache + (void)lbl.textSize(font); // initialize the internal cache - QMap< double, QwtText >::iterator it2 = m_data->labelCache.insert( value, lbl ); - return *it2; + QMap::iterator it2 = m_data->labelCache.insert(value, lbl); + return *it2; } /*! @@ -416,5 +414,5 @@ const QwtText& QwtAbstractScaleDraw::tickLabel( */ void QwtAbstractScaleDraw::invalidateCache() { - m_data->labelCache.clear(); + m_data->labelCache.clear(); } diff --git a/libs/qwt/src/qwt_abstract_scale_draw.h b/libs/qwt/src/qwt_abstract_scale_draw.h index 969deba8..be58f3cb 100644 --- a/libs/qwt/src/qwt_abstract_scale_draw.h +++ b/libs/qwt/src/qwt_abstract_scale_draw.h @@ -30,111 +30,110 @@ class QwtScaleMap; */ class QWT_EXPORT QwtAbstractScaleDraw { - public: +public: + /*! + Components of a scale + \sa enableComponent(), hasComponent + */ + enum ScaleComponent + { + //! Backbone = the line where the ticks are located + Backbone = 0x01, - /*! - Components of a scale - \sa enableComponent(), hasComponent - */ - enum ScaleComponent - { - //! Backbone = the line where the ticks are located - Backbone = 0x01, + //! Ticks + Ticks = 0x02, - //! Ticks - Ticks = 0x02, + //! Labels + Labels = 0x04 + }; - //! Labels - Labels = 0x04 - }; + Q_DECLARE_FLAGS(ScaleComponents, ScaleComponent) - Q_DECLARE_FLAGS( ScaleComponents, ScaleComponent ) + QwtAbstractScaleDraw(); + virtual ~QwtAbstractScaleDraw(); - QwtAbstractScaleDraw(); - virtual ~QwtAbstractScaleDraw(); + void setScaleDiv(const QwtScaleDiv &); + const QwtScaleDiv &scaleDiv() const; - void setScaleDiv( const QwtScaleDiv& ); - const QwtScaleDiv& scaleDiv() const; + void setTransformation(QwtTransform *); + const QwtScaleMap &scaleMap() const; + QwtScaleMap &scaleMap(); - void setTransformation( QwtTransform* ); - const QwtScaleMap& scaleMap() const; - QwtScaleMap& scaleMap(); + void enableComponent(ScaleComponent, bool enable = true); + bool hasComponent(ScaleComponent) const; - void enableComponent( ScaleComponent, bool enable = true ); - bool hasComponent( ScaleComponent ) const; + void setTickLength(QwtScaleDiv::TickType, double length); + double tickLength(QwtScaleDiv::TickType) const; + double maxTickLength() const; - void setTickLength( QwtScaleDiv::TickType, double length ); - double tickLength( QwtScaleDiv::TickType ) const; - double maxTickLength() const; + void setSpacing(double); + double spacing() const; - void setSpacing( double ); - double spacing() const; + void setPenWidthF(qreal width); + qreal penWidthF() const; - void setPenWidthF( qreal width ); - qreal penWidthF() const; + virtual void draw(QPainter *, const QPalette &) const; - virtual void draw( QPainter*, const QPalette& ) const; + virtual QwtText label(double) const; - virtual QwtText label( double ) const; + /*! + Calculate the extent - /*! - Calculate the extent + The extent is the distance from the baseline to the outermost + pixel of the scale draw in opposite to its orientation. + It is at least minimumExtent() pixels. - The extent is the distance from the baseline to the outermost - pixel of the scale draw in opposite to its orientation. - It is at least minimumExtent() pixels. + \param font Font used for drawing the tick labels + \return Number of pixels - \param font Font used for drawing the tick labels - \return Number of pixels + \sa setMinimumExtent(), minimumExtent() + */ + virtual double extent(const QFont &font) const = 0; - \sa setMinimumExtent(), minimumExtent() - */ - virtual double extent( const QFont& font ) const = 0; + void setMinimumExtent(double); + double minimumExtent() const; - void setMinimumExtent( double ); - double minimumExtent() const; + void invalidateCache(); - void invalidateCache(); +protected: + /*! + Draw a tick - protected: - /*! - Draw a tick + \param painter Painter + \param value Value of the tick + \param len Length of the tick - \param painter Painter - \param value Value of the tick - \param len Length of the tick + \sa drawBackbone(), drawLabel() + */ + virtual void drawTick(QPainter *painter, double value, double len) const = 0; - \sa drawBackbone(), drawLabel() - */ - virtual void drawTick( QPainter* painter, double value, double len ) const = 0; + /*! + Draws the baseline of the scale + \param painter Painter - /*! - Draws the baseline of the scale - \param painter Painter + \sa drawTick(), drawLabel() + */ + virtual void drawBackbone(QPainter *painter) const = 0; - \sa drawTick(), drawLabel() - */ - virtual void drawBackbone( QPainter* painter ) const = 0; + /*! + Draws the label for a major scale tick - /*! - Draws the label for a major scale tick + \param painter Painter + \param value Value - \param painter Painter - \param value Value + \sa drawTick(), drawBackbone() + */ + virtual void drawLabel(QPainter *painter, double value) const = 0; - \sa drawTick(), drawBackbone() - */ - virtual void drawLabel( QPainter* painter, double value ) const = 0; + const QwtText &tickLabel(const QFont &, double value) const; - const QwtText& tickLabel( const QFont&, double value ) const; +private: + Q_DISABLE_COPY(QwtAbstractScaleDraw) - private: - Q_DISABLE_COPY(QwtAbstractScaleDraw) - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtAbstractScaleDraw::ScaleComponents) #endif diff --git a/libs/qwt/src/qwt_abstract_slider.cpp b/libs/qwt/src/qwt_abstract_slider.cpp index 6f1510dc..8ce4c388 100644 --- a/libs/qwt/src/qwt_abstract_slider.cpp +++ b/libs/qwt/src/qwt_abstract_slider.cpp @@ -14,67 +14,66 @@ #include -static double qwtAlignToScaleDiv( - const QwtAbstractSlider* slider, double value ) +static double qwtAlignToScaleDiv(const QwtAbstractSlider *slider, double value) { - const QwtScaleDiv& sd = slider->scaleDiv(); + const QwtScaleDiv &sd = slider->scaleDiv(); - const int tValue = slider->transform( value ); + const int tValue = slider->transform(value); - if ( tValue == slider->transform( sd.lowerBound() ) ) - return sd.lowerBound(); + if (tValue == slider->transform(sd.lowerBound())) + return sd.lowerBound(); - if ( tValue == slider->transform( sd.upperBound() ) ) - return sd.upperBound(); + if (tValue == slider->transform(sd.upperBound())) + return sd.upperBound(); - for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) + for (int i = 0; i < QwtScaleDiv::NTickTypes; i++) + { + const QList ticks = sd.ticks(i); + for (int j = 0; j < ticks.size(); j++) { - const QList< double > ticks = sd.ticks( i ); - for ( int j = 0; j < ticks.size(); j++ ) - { - if ( slider->transform( ticks[ j ] ) == tValue ) - return ticks[ j ]; - } + if (slider->transform(ticks[j]) == tValue) + return ticks[j]; } + } - return value; + return value; } class QwtAbstractSlider::PrivateData { - public: - PrivateData() - : isScrolling( false ) - , isTracking( true ) - , pendingValueChanged( false ) - , readOnly( false ) - , totalSteps( 100 ) - , singleSteps( 1 ) - , pageSteps( 10 ) - , stepAlignment( true ) - , isValid( false ) - , value( 0.0 ) - , wrapping( false ) - , invertedControls( false ) - { - } +public: + PrivateData() + : isScrolling(false) + , isTracking(true) + , pendingValueChanged(false) + , readOnly(false) + , totalSteps(100) + , singleSteps(1) + , pageSteps(10) + , stepAlignment(true) + , isValid(false) + , value(0.0) + , wrapping(false) + , invertedControls(false) + { + } - bool isScrolling; - bool isTracking; - bool pendingValueChanged; + bool isScrolling; + bool isTracking; + bool pendingValueChanged; - bool readOnly; + bool readOnly; - uint totalSteps; - uint singleSteps; - uint pageSteps; - bool stepAlignment; + uint totalSteps; + uint singleSteps; + uint pageSteps; + bool stepAlignment; - bool isValid; - double value; + bool isValid; + double value; - bool wrapping; - bool invertedControls; + bool wrapping; + bool invertedControls; }; /*! @@ -88,19 +87,19 @@ class QwtAbstractSlider::PrivateData \param parent Parent widget */ -QwtAbstractSlider::QwtAbstractSlider( QWidget* parent ) - : QwtAbstractScale( parent ) +QwtAbstractSlider::QwtAbstractSlider(QWidget *parent) + : QwtAbstractScale(parent) { - m_data = new QwtAbstractSlider::PrivateData; + m_data = new QwtAbstractSlider::PrivateData; - setScale( 0.0, 100.0 ); - setFocusPolicy( Qt::StrongFocus ); + setScale(0.0, 100.0); + setFocusPolicy(Qt::StrongFocus); } //! Destructor QwtAbstractSlider::~QwtAbstractSlider() { - delete m_data; + delete m_data; } /*! @@ -110,21 +109,21 @@ QwtAbstractSlider::~QwtAbstractSlider() \sa setValue() */ -void QwtAbstractSlider::setValid( bool on ) +void QwtAbstractSlider::setValid(bool on) { - if ( on != m_data->isValid ) - { - m_data->isValid = on; - sliderChange(); + if (on != m_data->isValid) + { + m_data->isValid = on; + sliderChange(); - Q_EMIT valueChanged( m_data->value ); - } + Q_EMIT valueChanged(m_data->value); + } } //! \return True, when the value is invalid bool QwtAbstractSlider::isValid() const { - return m_data->isValid; + return m_data->isValid; } /*! @@ -138,15 +137,15 @@ bool QwtAbstractSlider::isValid() const \warning The focus policy is set to Qt::StrongFocus or Qt::NoFocus */ -void QwtAbstractSlider::setReadOnly( bool on ) +void QwtAbstractSlider::setReadOnly(bool on) { - if ( m_data->readOnly != on ) - { - m_data->readOnly = on; - setFocusPolicy( on ? Qt::StrongFocus : Qt::NoFocus ); + if (m_data->readOnly != on) + { + m_data->readOnly = on; + setFocusPolicy(on ? Qt::StrongFocus : Qt::NoFocus); - update(); - } + update(); + } } /*! @@ -158,7 +157,7 @@ void QwtAbstractSlider::setReadOnly( bool on ) */ bool QwtAbstractSlider::isReadOnly() const { - return m_data->readOnly; + return m_data->readOnly; } /*! @@ -174,9 +173,9 @@ bool QwtAbstractSlider::isReadOnly() const \sa isTracking(), sliderMoved() */ -void QwtAbstractSlider::setTracking( bool on ) +void QwtAbstractSlider::setTracking(bool on) { - m_data->isTracking = on; + m_data->isTracking = on; } /*! @@ -185,100 +184,100 @@ void QwtAbstractSlider::setTracking( bool on ) */ bool QwtAbstractSlider::isTracking() const { - return m_data->isTracking; + return m_data->isTracking; } /*! Mouse press event handler \param event Mouse event */ -void QwtAbstractSlider::mousePressEvent( QMouseEvent* event ) +void QwtAbstractSlider::mousePressEvent(QMouseEvent *event) { - if ( isReadOnly() ) - { - event->ignore(); - return; - } + if (isReadOnly()) + { + event->ignore(); + return; + } - if ( !m_data->isValid || lowerBound() == upperBound() ) - return; + if (!m_data->isValid || lowerBound() == upperBound()) + return; - m_data->isScrolling = isScrollPosition( event->pos() ); + m_data->isScrolling = isScrollPosition(event->pos()); - if ( m_data->isScrolling ) - { - m_data->pendingValueChanged = false; + if (m_data->isScrolling) + { + m_data->pendingValueChanged = false; - Q_EMIT sliderPressed(); - } + Q_EMIT sliderPressed(); + } } /*! Mouse Move Event handler \param event Mouse event */ -void QwtAbstractSlider::mouseMoveEvent( QMouseEvent* event ) +void QwtAbstractSlider::mouseMoveEvent(QMouseEvent *event) { - if ( isReadOnly() ) + if (isReadOnly()) + { + event->ignore(); + return; + } + + if (m_data->isValid && m_data->isScrolling) + { + double value = scrolledTo(event->pos()); + if (value != m_data->value) { - event->ignore(); - return; - } - - if ( m_data->isValid && m_data->isScrolling ) - { - double value = scrolledTo( event->pos() ); - if ( value != m_data->value ) - { - value = boundedValue( value ); - - if ( m_data->stepAlignment ) - { - value = alignedValue( value ); - } - else - { - value = qwtAlignToScaleDiv( this, value ); - } - - if ( value != m_data->value ) - { - m_data->value = value; - - sliderChange(); - - Q_EMIT sliderMoved( m_data->value ); - - if ( m_data->isTracking ) - Q_EMIT valueChanged( m_data->value ); - else - m_data->pendingValueChanged = true; - } - } + value = boundedValue(value); + + if (m_data->stepAlignment) + { + value = alignedValue(value); + } + else + { + value = qwtAlignToScaleDiv(this, value); + } + + if (value != m_data->value) + { + m_data->value = value; + + sliderChange(); + + Q_EMIT sliderMoved(m_data->value); + + if (m_data->isTracking) + Q_EMIT valueChanged(m_data->value); + else + m_data->pendingValueChanged = true; + } } + } } /*! Mouse Release Event handler \param event Mouse event */ -void QwtAbstractSlider::mouseReleaseEvent( QMouseEvent* event ) +void QwtAbstractSlider::mouseReleaseEvent(QMouseEvent *event) { - if ( isReadOnly() ) - { - event->ignore(); - return; - } + if (isReadOnly()) + { + event->ignore(); + return; + } - if ( m_data->isScrolling && m_data->isValid ) - { - m_data->isScrolling = false; + if (m_data->isScrolling && m_data->isValid) + { + m_data->isScrolling = false; - if ( m_data->pendingValueChanged ) - Q_EMIT valueChanged( m_data->value ); + if (m_data->pendingValueChanged) + Q_EMIT valueChanged(m_data->value); - Q_EMIT sliderReleased(); - } + Q_EMIT sliderReleased(); + } } /*! @@ -293,53 +292,53 @@ void QwtAbstractSlider::mouseReleaseEvent( QMouseEvent* event ) \param event Wheel event */ -void QwtAbstractSlider::wheelEvent( QWheelEvent* event ) +void QwtAbstractSlider::wheelEvent(QWheelEvent *event) { - if ( isReadOnly() ) - { - event->ignore(); - return; - } + if (isReadOnly()) + { + event->ignore(); + return; + } - if ( !m_data->isValid || m_data->isScrolling ) - return; + if (!m_data->isValid || m_data->isScrolling) + return; #if QT_VERSION < 0x050000 - const int wheelDelta = event->delta(); + const int wheelDelta = event->delta(); #else - const QPoint delta = event->angleDelta(); - const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) ) - ? delta.x() : delta.y(); + const QPoint delta = event->angleDelta(); + const int wheelDelta + = (qAbs(delta.x()) > qAbs(delta.y())) ? delta.x() : delta.y(); #endif - int numSteps = 0; + int numSteps = 0; - if ( ( event->modifiers() & Qt::ControlModifier ) || - ( event->modifiers() & Qt::ShiftModifier ) ) - { - // one page regardless of delta - numSteps = m_data->pageSteps; - if ( wheelDelta < 0 ) - numSteps = -numSteps; - } - else - { - const int numTurns = ( wheelDelta / 120 ); - numSteps = numTurns * m_data->singleSteps; - } + if ((event->modifiers() & Qt::ControlModifier) + || (event->modifiers() & Qt::ShiftModifier)) + { + // one page regardless of delta + numSteps = m_data->pageSteps; + if (wheelDelta < 0) + numSteps = -numSteps; + } + else + { + const int numTurns = (wheelDelta / 120); + numSteps = numTurns * m_data->singleSteps; + } - if ( m_data->invertedControls ) - numSteps = -numSteps; + if (m_data->invertedControls) + numSteps = -numSteps; - const double value = incrementedValue( m_data->value, numSteps ); - if ( value != m_data->value ) - { - m_data->value = value; - sliderChange(); + const double value = incrementedValue(m_data->value, numSteps); + if (value != m_data->value) + { + m_data->value = value; + sliderChange(); - Q_EMIT sliderMoved( m_data->value ); - Q_EMIT valueChanged( m_data->value ); - } + Q_EMIT sliderMoved(m_data->value); + Q_EMIT valueChanged(m_data->value); + } } /*! @@ -367,96 +366,87 @@ void QwtAbstractSlider::wheelEvent( QWheelEvent* event ) \param event Key event \sa isReadOnly() */ -void QwtAbstractSlider::keyPressEvent( QKeyEvent* event ) +void QwtAbstractSlider::keyPressEvent(QKeyEvent *event) { - if ( isReadOnly() ) - { - event->ignore(); - return; + if (isReadOnly()) + { + event->ignore(); + return; + } + + if (!m_data->isValid || m_data->isScrolling) + return; + + int numSteps = 0; + double value = m_data->value; + + switch (event->key()) + { + case Qt::Key_Left: { + numSteps = -static_cast(m_data->singleSteps); + if (isInverted()) + numSteps = -numSteps; + + break; } + case Qt::Key_Right: { + numSteps = m_data->singleSteps; + if (isInverted()) + numSteps = -numSteps; - if ( !m_data->isValid || m_data->isScrolling ) - return; - - int numSteps = 0; - double value = m_data->value; - - switch ( event->key() ) - { - case Qt::Key_Left: - { - numSteps = -static_cast< int >( m_data->singleSteps ); - if ( isInverted() ) - numSteps = -numSteps; - - break; - } - case Qt::Key_Right: - { - numSteps = m_data->singleSteps; - if ( isInverted() ) - numSteps = -numSteps; - - break; - } - case Qt::Key_Down: - { - numSteps = -static_cast< int >( m_data->singleSteps ); - if ( m_data->invertedControls ) - numSteps = -numSteps; - break; - } - case Qt::Key_Up: - { - numSteps = m_data->singleSteps; - if ( m_data->invertedControls ) - numSteps = -numSteps; - - break; - } - case Qt::Key_PageUp: - { - numSteps = m_data->pageSteps; - if ( m_data->invertedControls ) - numSteps = -numSteps; - break; - } - case Qt::Key_PageDown: - { - numSteps = -static_cast< int >( m_data->pageSteps ); - if ( m_data->invertedControls ) - numSteps = -numSteps; - break; - } - case Qt::Key_Home: - { - value = minimum(); - break; - } - case Qt::Key_End: - { - value = maximum(); - break; - } - default: - { - event->ignore(); - } + break; } - - if ( numSteps != 0 ) - { - value = incrementedValue( m_data->value, numSteps ); + case Qt::Key_Down: { + numSteps = -static_cast(m_data->singleSteps); + if (m_data->invertedControls) + numSteps = -numSteps; + break; } + case Qt::Key_Up: { + numSteps = m_data->singleSteps; + if (m_data->invertedControls) + numSteps = -numSteps; - if ( value != m_data->value ) - { - m_data->value = value; - sliderChange(); - - Q_EMIT sliderMoved( m_data->value ); - Q_EMIT valueChanged( m_data->value ); + break; } + case Qt::Key_PageUp: { + numSteps = m_data->pageSteps; + if (m_data->invertedControls) + numSteps = -numSteps; + break; + } + case Qt::Key_PageDown: { + numSteps = -static_cast(m_data->pageSteps); + if (m_data->invertedControls) + numSteps = -numSteps; + break; + } + case Qt::Key_Home: { + value = minimum(); + break; + } + case Qt::Key_End: { + value = maximum(); + break; + } + default: { + event->ignore(); + } + } + + if (numSteps != 0) + { + value = incrementedValue(m_data->value, numSteps); + } + + if (value != m_data->value) + { + m_data->value = value; + sliderChange(); + + Q_EMIT sliderMoved(m_data->value); + Q_EMIT valueChanged(m_data->value); + } } /*! @@ -471,9 +461,9 @@ void QwtAbstractSlider::keyPressEvent( QKeyEvent* event ) \sa totalSteps(), setSingleSteps(), setPageSteps() */ -void QwtAbstractSlider::setTotalSteps( uint stepCount ) +void QwtAbstractSlider::setTotalSteps(uint stepCount) { - m_data->totalSteps = stepCount; + m_data->totalSteps = stepCount; } /*! @@ -482,7 +472,7 @@ void QwtAbstractSlider::setTotalSteps( uint stepCount ) */ uint QwtAbstractSlider::totalSteps() const { - return m_data->totalSteps; + return m_data->totalSteps; } /*! @@ -496,9 +486,9 @@ uint QwtAbstractSlider::totalSteps() const \sa singleSteps(), setTotalSteps(), setPageSteps() */ -void QwtAbstractSlider::setSingleSteps( uint stepCount ) +void QwtAbstractSlider::setSingleSteps(uint stepCount) { - m_data->singleSteps = stepCount; + m_data->singleSteps = stepCount; } /*! @@ -507,7 +497,7 @@ void QwtAbstractSlider::setSingleSteps( uint stepCount ) */ uint QwtAbstractSlider::singleSteps() const { - return m_data->singleSteps; + return m_data->singleSteps; } /*! @@ -521,9 +511,9 @@ uint QwtAbstractSlider::singleSteps() const \sa pageSteps(), setTotalSteps(), setSingleSteps() */ -void QwtAbstractSlider::setPageSteps( uint stepCount ) +void QwtAbstractSlider::setPageSteps(uint stepCount) { - m_data->pageSteps = stepCount; + m_data->pageSteps = stepCount; } /*! @@ -532,7 +522,7 @@ void QwtAbstractSlider::setPageSteps( uint stepCount ) */ uint QwtAbstractSlider::pageSteps() const { - return m_data->pageSteps; + return m_data->pageSteps; } /*! @@ -544,12 +534,12 @@ uint QwtAbstractSlider::pageSteps() const \param on Enable step alignment when true \sa stepAlignment() */ -void QwtAbstractSlider::setStepAlignment( bool on ) +void QwtAbstractSlider::setStepAlignment(bool on) { - if ( on != m_data->stepAlignment ) - { - m_data->stepAlignment = on; - } + if (on != m_data->stepAlignment) + { + m_data->stepAlignment = on; + } } /*! @@ -558,7 +548,7 @@ void QwtAbstractSlider::setStepAlignment( bool on ) */ bool QwtAbstractSlider::stepAlignment() const { - return m_data->stepAlignment; + return m_data->stepAlignment; } /*! @@ -567,26 +557,26 @@ bool QwtAbstractSlider::stepAlignment() const \param value New value \sa setValid(), sliderChange(), valueChanged() */ -void QwtAbstractSlider::setValue( double value ) +void QwtAbstractSlider::setValue(double value) { - value = qBound( minimum(), value, maximum() ); + value = qBound(minimum(), value, maximum()); - const bool changed = ( m_data->value != value ) || !m_data->isValid; + const bool changed = (m_data->value != value) || !m_data->isValid; - m_data->value = value; - m_data->isValid = true; + m_data->value = value; + m_data->isValid = true; - if ( changed ) - { - sliderChange(); - Q_EMIT valueChanged( m_data->value ); - } + if (changed) + { + sliderChange(); + Q_EMIT valueChanged(m_data->value); + } } //! Returns the current value. double QwtAbstractSlider::value() const { - return m_data->value; + return m_data->value; } /*! @@ -596,9 +586,9 @@ double QwtAbstractSlider::value() const \param on En/Disable wrapping \sa wrapping() */ -void QwtAbstractSlider::setWrapping( bool on ) +void QwtAbstractSlider::setWrapping(bool on) { - m_data->wrapping = on; + m_data->wrapping = on; } /*! @@ -607,7 +597,7 @@ void QwtAbstractSlider::setWrapping( bool on ) */ bool QwtAbstractSlider::wrapping() const { - return m_data->wrapping; + return m_data->wrapping; } /*! @@ -625,9 +615,9 @@ bool QwtAbstractSlider::wrapping() const \sa invertedControls(), keyEvent(), wheelEvent() */ -void QwtAbstractSlider::setInvertedControls( bool on ) +void QwtAbstractSlider::setInvertedControls(bool on) { - m_data->invertedControls = on; + m_data->invertedControls = on; } /*! @@ -636,7 +626,7 @@ void QwtAbstractSlider::setInvertedControls( bool on ) */ bool QwtAbstractSlider::invertedControls() const { - return m_data->invertedControls; + return m_data->invertedControls; } /*! @@ -647,16 +637,15 @@ bool QwtAbstractSlider::invertedControls() const \param stepCount Number of steps \sa setTotalSteps(), incrementedValue() */ -void QwtAbstractSlider::incrementValue( int stepCount ) +void QwtAbstractSlider::incrementValue(int stepCount) { - const double value = incrementedValue( - m_data->value, stepCount ); + const double value = incrementedValue(m_data->value, stepCount); - if ( value != m_data->value ) - { - m_data->value = value; - sliderChange(); - } + if (value != m_data->value) + { + m_data->value = value; + sliderChange(); + } } /*! @@ -667,142 +656,139 @@ void QwtAbstractSlider::incrementValue( int stepCount ) \return Incremented value */ -double QwtAbstractSlider::incrementedValue( - double value, int stepCount ) const +double QwtAbstractSlider::incrementedValue(double value, int stepCount) const { - if ( m_data->totalSteps == 0 ) - return value; - - const QwtTransform* transformation = - scaleMap().transformation(); - - if ( transformation == NULL ) - { - const double range = maximum() - minimum(); - value += stepCount * range / m_data->totalSteps; - } - else - { - QwtScaleMap map = scaleMap(); - map.setPaintInterval( 0, m_data->totalSteps ); - - // we need equidistant steps according to - // paint device coordinates - const double range = transformation->transform( maximum() ) - - transformation->transform( minimum() ); - - const double stepSize = range / m_data->totalSteps; - - double v = transformation->transform( value ); - - v = qRound( v / stepSize ) * stepSize; - v += stepCount * range / m_data->totalSteps; - - value = transformation->invTransform( v ); - } - - value = boundedValue( value ); - - if ( m_data->stepAlignment ) - value = alignedValue( value ); - + if (m_data->totalSteps == 0) return value; + + const QwtTransform *transformation = scaleMap().transformation(); + + if (transformation == NULL) + { + const double range = maximum() - minimum(); + value += stepCount * range / m_data->totalSteps; + } + else + { + QwtScaleMap map = scaleMap(); + map.setPaintInterval(0, m_data->totalSteps); + + // we need equidistant steps according to + // paint device coordinates + const double range = transformation->transform(maximum()) + - transformation->transform(minimum()); + + const double stepSize = range / m_data->totalSteps; + + double v = transformation->transform(value); + + v = qRound(v / stepSize) * stepSize; + v += stepCount * range / m_data->totalSteps; + + value = transformation->invTransform(v); + } + + value = boundedValue(value); + + if (m_data->stepAlignment) + value = alignedValue(value); + + return value; } -double QwtAbstractSlider::boundedValue( double value ) const +double QwtAbstractSlider::boundedValue(double value) const { - const double vmin = minimum(); - const double vmax = maximum(); + const double vmin = minimum(); + const double vmax = maximum(); - if ( m_data->wrapping && vmin != vmax ) + if (m_data->wrapping && vmin != vmax) + { + if (qFuzzyCompare(scaleMap().pDist(), 360.0)) { - if ( qFuzzyCompare( scaleMap().pDist(), 360.0 ) ) - { - // full circle scales: min and max are the same + // full circle scales: min and max are the same - if ( qFuzzyCompare( value, vmax ) ) - { - value = vmin; - } - else - { - const double range = vmax - vmin; + if (qFuzzyCompare(value, vmax)) + { + value = vmin; + } + else + { + const double range = vmax - vmin; - if ( value < vmin ) - { - value += std::ceil( ( vmin - value ) / range ) * range; - } - else if ( value > vmax ) - { - value -= std::ceil( ( value - vmax ) / range ) * range; - } - } - } - else + if (value < vmin) { - if ( value < vmin ) - value = vmax; - else if ( value > vmax ) - value = vmin; + value += std::ceil((vmin - value) / range) * range; } + else if (value > vmax) + { + value -= std::ceil((value - vmax) / range) * range; + } + } } else { - value = qBound( vmin, value, vmax ); + if (value < vmin) + value = vmax; + else if (value > vmax) + value = vmin; } + } + else + { + value = qBound(vmin, value, vmax); + } - return value; + return value; } -double QwtAbstractSlider::alignedValue( double value ) const +double QwtAbstractSlider::alignedValue(double value) const { - if ( m_data->totalSteps == 0 ) - return value; + if (m_data->totalSteps == 0) + return value; - double stepSize; + double stepSize; - if ( scaleMap().transformation() == NULL ) + if (scaleMap().transformation() == NULL) + { + stepSize = (maximum() - minimum()) / m_data->totalSteps; + if (stepSize > 0.0) { - stepSize = ( maximum() - minimum() ) / m_data->totalSteps; - if ( stepSize > 0.0 ) - { - value = lowerBound() + - qRound( ( value - lowerBound() ) / stepSize ) * stepSize; - } + value + = lowerBound() + qRound((value - lowerBound()) / stepSize) * stepSize; + } + } + else + { + stepSize = (scaleMap().p2() - scaleMap().p1()) / m_data->totalSteps; + + if (stepSize > 0.0) + { + double v = scaleMap().transform(value); + + v = scaleMap().p1() + qRound((v - scaleMap().p1()) / stepSize) * stepSize; + + value = scaleMap().invTransform(v); + } + } + + if (qAbs(stepSize) > 1e-12) + { + if (qFuzzyCompare(value + 1.0, 1.0)) + { + // correct rounding error if value = 0 + value = 0.0; } else { - stepSize = ( scaleMap().p2() - scaleMap().p1() ) / m_data->totalSteps; - - if ( stepSize > 0.0 ) - { - double v = scaleMap().transform( value ); - - v = scaleMap().p1() + - qRound( ( v - scaleMap().p1() ) / stepSize ) * stepSize; - - value = scaleMap().invTransform( v ); - } + // correct rounding error at the border + if (qFuzzyCompare(value, upperBound())) + value = upperBound(); + else if (qFuzzyCompare(value, lowerBound())) + value = lowerBound(); } + } - if ( qAbs( stepSize ) > 1e-12 ) - { - if ( qFuzzyCompare( value + 1.0, 1.0 ) ) - { - // correct rounding error if value = 0 - value = 0.0; - } - else - { - // correct rounding error at the border - if ( qFuzzyCompare( value, upperBound() ) ) - value = upperBound(); - else if ( qFuzzyCompare( value, lowerBound() ) ) - value = lowerBound(); - } - } - - return value; + return value; } /*! @@ -810,27 +796,27 @@ double QwtAbstractSlider::alignedValue( double value ) const */ void QwtAbstractSlider::scaleChange() { - const double value = qBound( minimum(), m_data->value, maximum() ); + const double value = qBound(minimum(), m_data->value, maximum()); - const bool changed = ( value != m_data->value ); - if ( changed ) - { - m_data->value = value; - } + const bool changed = (value != m_data->value); + if (changed) + { + m_data->value = value; + } - if ( m_data->isValid || changed ) - Q_EMIT valueChanged( m_data->value ); + if (m_data->isValid || changed) + Q_EMIT valueChanged(m_data->value); - updateGeometry(); - update(); + updateGeometry(); + update(); } //! Calling update() void QwtAbstractSlider::sliderChange() { - update(); + update(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_abstract_slider.cpp" +# include "moc_qwt_abstract_slider.cpp" #endif diff --git a/libs/qwt/src/qwt_abstract_slider.h b/libs/qwt/src/qwt_abstract_slider.h index 38ca55a7..23b73a06 100644 --- a/libs/qwt/src/qwt_abstract_slider.h +++ b/libs/qwt/src/qwt_abstract_slider.h @@ -31,137 +31,138 @@ class QWT_EXPORT QwtAbstractSlider : public QwtAbstractScale { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true ) + Q_PROPERTY( + double value READ value WRITE setValue NOTIFY valueChanged USER true) - Q_PROPERTY( uint totalSteps READ totalSteps WRITE setTotalSteps ) - Q_PROPERTY( uint singleSteps READ singleSteps WRITE setSingleSteps ) - Q_PROPERTY( uint pageSteps READ pageSteps WRITE setPageSteps ) - Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment ) + Q_PROPERTY(uint totalSteps READ totalSteps WRITE setTotalSteps) + Q_PROPERTY(uint singleSteps READ singleSteps WRITE setSingleSteps) + Q_PROPERTY(uint pageSteps READ pageSteps WRITE setPageSteps) + Q_PROPERTY(bool stepAlignment READ stepAlignment WRITE setStepAlignment) - Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly ) - Q_PROPERTY( bool tracking READ isTracking WRITE setTracking ) - Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping ) + Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) + Q_PROPERTY(bool tracking READ isTracking WRITE setTracking) + Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping) - Q_PROPERTY( bool invertedControls READ invertedControls WRITE setInvertedControls ) + Q_PROPERTY( + bool invertedControls READ invertedControls WRITE setInvertedControls) - public: - explicit QwtAbstractSlider( QWidget* parent = NULL ); - virtual ~QwtAbstractSlider(); +public: + explicit QwtAbstractSlider(QWidget *parent = NULL); + virtual ~QwtAbstractSlider(); - void setValid( bool ); - bool isValid() const; + void setValid(bool); + bool isValid() const; - double value() const; + double value() const; - void setWrapping( bool ); - bool wrapping() const; + void setWrapping(bool); + bool wrapping() const; - void setTotalSteps( uint ); - uint totalSteps() const; + void setTotalSteps(uint); + uint totalSteps() const; - void setSingleSteps( uint ); - uint singleSteps() const; + void setSingleSteps(uint); + uint singleSteps() const; - void setPageSteps( uint ); - uint pageSteps() const; + void setPageSteps(uint); + uint pageSteps() const; - void setStepAlignment( bool ); - bool stepAlignment() const; + void setStepAlignment(bool); + bool stepAlignment() const; - void setTracking( bool ); - bool isTracking() const; + void setTracking(bool); + bool isTracking() const; - void setReadOnly( bool ); - bool isReadOnly() const; + void setReadOnly(bool); + bool isReadOnly() const; - void setInvertedControls( bool ); - bool invertedControls() const; + void setInvertedControls(bool); + bool invertedControls() const; - public Q_SLOTS: - void setValue( double value ); +public Q_SLOTS: + void setValue(double value); - Q_SIGNALS: +Q_SIGNALS: - /*! - \brief Notify a change of value. + /*! + \brief Notify a change of value. - When tracking is enabled (default setting), - this signal will be emitted every time the value changes. + When tracking is enabled (default setting), + this signal will be emitted every time the value changes. - \param value New value + \param value New value - \sa setTracking(), sliderMoved() - */ - void valueChanged( double value ); + \sa setTracking(), sliderMoved() + */ + void valueChanged(double value); - /*! - This signal is emitted when the user presses the - movable part of the slider. - */ - void sliderPressed(); + /*! + This signal is emitted when the user presses the + movable part of the slider. + */ + void sliderPressed(); - /*! - This signal is emitted when the user releases the - movable part of the slider. - */ - void sliderReleased(); + /*! + This signal is emitted when the user releases the + movable part of the slider. + */ + void sliderReleased(); - /*! - This signal is emitted when the user moves the - slider with the mouse. + /*! + This signal is emitted when the user moves the + slider with the mouse. - \param value New value + \param value New value - \sa valueChanged() - */ - void sliderMoved( double value ); + \sa valueChanged() + */ + void sliderMoved(double value); - protected: - virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void mouseMoveEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE; - virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE; +protected: + virtual void mousePressEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE; + virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE; - /*! - \brief Determine what to do when the user presses a mouse button. + /*! + \brief Determine what to do when the user presses a mouse button. - \param pos Mouse position + \param pos Mouse position - \retval True, when pos is a valid scroll position - \sa scrolledTo() - */ - virtual bool isScrollPosition( const QPoint& pos ) const = 0; + \retval True, when pos is a valid scroll position + \sa scrolledTo() + */ + virtual bool isScrollPosition(const QPoint &pos) const = 0; - /*! - \brief Determine the value for a new position of the - movable part of the slider + /*! + \brief Determine the value for a new position of the + movable part of the slider - \param pos Mouse position + \param pos Mouse position - \return Value for the mouse position - \sa isScrollPosition() - */ - virtual double scrolledTo( const QPoint& pos ) const = 0; + \return Value for the mouse position + \sa isScrollPosition() + */ + virtual double scrolledTo(const QPoint &pos) const = 0; - void incrementValue( int stepCount ); + void incrementValue(int stepCount); - virtual void scaleChange() QWT_OVERRIDE; + virtual void scaleChange() QWT_OVERRIDE; - protected: - virtual void sliderChange(); +protected: + virtual void sliderChange(); - double incrementedValue( - double value, int stepCount ) const; + double incrementedValue(double value, int stepCount) const; - private: - double alignedValue( double ) const; - double boundedValue( double ) const; +private: + double alignedValue(double) const; + double boundedValue(double) const; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_analog_clock.cpp b/libs/qwt/src/qwt_analog_clock.cpp index 81a25b63..c0299fd6 100644 --- a/libs/qwt/src/qwt_analog_clock.cpp +++ b/libs/qwt/src/qwt_analog_clock.cpp @@ -18,109 +18,109 @@ namespace { - class QwtAnalogClockScaleDraw QWT_FINAL : public QwtRoundScaleDraw - { - public: - QwtAnalogClockScaleDraw() - { - setSpacing( 8 ); +class QwtAnalogClockScaleDraw QWT_FINAL : public QwtRoundScaleDraw +{ +public: + QwtAnalogClockScaleDraw() + { + setSpacing(8); - enableComponent( QwtAbstractScaleDraw::Backbone, false ); + enableComponent(QwtAbstractScaleDraw::Backbone, false); - setTickLength( QwtScaleDiv::MinorTick, 2 ); - setTickLength( QwtScaleDiv::MediumTick, 4 ); - setTickLength( QwtScaleDiv::MajorTick, 8 ); + setTickLength(QwtScaleDiv::MinorTick, 2); + setTickLength(QwtScaleDiv::MediumTick, 4); + setTickLength(QwtScaleDiv::MajorTick, 8); - setPenWidthF( 1.0 ); - } + setPenWidthF(1.0); + } - virtual QwtText label( double value ) const QWT_OVERRIDE - { - if ( qFuzzyCompare( value + 1.0, 1.0 ) ) - value = 60.0 * 60.0 * 12.0; + virtual QwtText label(double value) const QWT_OVERRIDE + { + if (qFuzzyCompare(value + 1.0, 1.0)) + value = 60.0 * 60.0 * 12.0; - return QLocale().toString( qRound( value / ( 60.0 * 60.0 ) ) ); - } - }; -} + return QLocale().toString(qRound(value / (60.0 * 60.0))); + } +}; +} // namespace /*! Constructor \param parent Parent widget */ -QwtAnalogClock::QwtAnalogClock( QWidget* parent ) - : QwtDial( parent ) +QwtAnalogClock::QwtAnalogClock(QWidget *parent) + : QwtDial(parent) { - setWrapping( true ); - setReadOnly( true ); + setWrapping(true); + setReadOnly(true); - setOrigin( 270.0 ); - setScaleDraw( new QwtAnalogClockScaleDraw() ); + setOrigin(270.0); + setScaleDraw(new QwtAnalogClockScaleDraw()); - setTotalSteps( 60 ); + setTotalSteps(60); - const int secondsPerHour = 60.0 * 60.0; + const int secondsPerHour = 60.0 * 60.0; - QList< double > majorTicks; - QList< double > minorTicks; + QList majorTicks; + QList minorTicks; - for ( int i = 0; i < 12; i++ ) + for (int i = 0; i < 12; i++) + { + majorTicks += i * secondsPerHour; + + for (int j = 1; j < 5; j++) + minorTicks += i * secondsPerHour + j * secondsPerHour / 5.0; + } + + QwtScaleDiv scaleDiv; + scaleDiv.setInterval(0.0, 12.0 * secondsPerHour); + scaleDiv.setTicks(QwtScaleDiv::MajorTick, majorTicks); + scaleDiv.setTicks(QwtScaleDiv::MinorTick, minorTicks); + setScale(scaleDiv); + + QColor knobColor = palette().color(QPalette::Active, QPalette::Text); + knobColor = knobColor.darker(120); + + QColor handColor; + int width; + + for (int i = 0; i < NHands; i++) + { + if (i == SecondHand) { - majorTicks += i * secondsPerHour; - - for ( int j = 1; j < 5; j++ ) - minorTicks += i * secondsPerHour + j * secondsPerHour / 5.0; + width = 2; + handColor = knobColor.darker(120); + } + else + { + width = 8; + handColor = knobColor; } - QwtScaleDiv scaleDiv; - scaleDiv.setInterval( 0.0, 12.0 * secondsPerHour ); - scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks ); - scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks ); - setScale( scaleDiv ); + QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle( + QwtDialSimpleNeedle::Arrow, true, handColor, knobColor); + hand->setWidth(width); - QColor knobColor = palette().color( QPalette::Active, QPalette::Text ); - knobColor = knobColor.darker( 120 ); - - QColor handColor; - int width; - - for ( int i = 0; i < NHands; i++ ) - { - if ( i == SecondHand ) - { - width = 2; - handColor = knobColor.darker( 120 ); - } - else - { - width = 8; - handColor = knobColor; - } - - QwtDialSimpleNeedle* hand = new QwtDialSimpleNeedle( - QwtDialSimpleNeedle::Arrow, true, handColor, knobColor ); - hand->setWidth( width ); - - m_hand[i] = NULL; - setHand( static_cast< Hand >( i ), hand ); - } + m_hand[i] = NULL; + setHand(static_cast(i), hand); + } } //! Destructor QwtAnalogClock::~QwtAnalogClock() { - for ( int i = 0; i < NHands; i++ ) - delete m_hand[i]; + for (int i = 0; i < NHands; i++) + delete m_hand[i]; } /*! Nop method, use setHand() instead \sa setHand() */ -void QwtAnalogClock::setNeedle( QwtDialNeedle* ) +void QwtAnalogClock::setNeedle(QwtDialNeedle *) { - // no op - return; + // no op + return; } /*! @@ -129,13 +129,13 @@ void QwtAnalogClock::setNeedle( QwtDialNeedle* ) \param needle Hand \sa hand() */ -void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle* needle ) +void QwtAnalogClock::setHand(Hand hand, QwtDialNeedle *needle) { - if ( hand >= 0 && hand < NHands ) - { - delete m_hand[hand]; - m_hand[hand] = needle; - } + if (hand >= 0 && hand < NHands) + { + delete m_hand[hand]; + m_hand[hand] = needle; + } } /*! @@ -143,12 +143,12 @@ void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle* needle ) \param hd Specifies the type of hand \sa setHand() */ -QwtDialNeedle* QwtAnalogClock::hand( Hand hd ) +QwtDialNeedle *QwtAnalogClock::hand(Hand hd) { - if ( hd < 0 || hd >= NHands ) - return NULL; + if (hd < 0 || hd >= NHands) + return NULL; - return m_hand[hd]; + return m_hand[hd]; } /*! @@ -156,9 +156,9 @@ QwtDialNeedle* QwtAnalogClock::hand( Hand hd ) \param hd Specifies the type of hand \sa setHand() */ -const QwtDialNeedle* QwtAnalogClock::hand( Hand hd ) const +const QwtDialNeedle *QwtAnalogClock::hand(Hand hd) const { - return const_cast< QwtAnalogClock* >( this )->hand( hd ); + return const_cast(this)->hand(hd); } /*! @@ -166,22 +166,22 @@ const QwtDialNeedle* QwtAnalogClock::hand( Hand hd ) const */ void QwtAnalogClock::setCurrentTime() { - setTime( QTime::currentTime() ); + setTime(QTime::currentTime()); } /*! Set a time \param time Time to display */ -void QwtAnalogClock::setTime( const QTime& time ) +void QwtAnalogClock::setTime(const QTime &time) { - if ( time.isValid() ) - { - setValue( ( time.hour() % 12 ) * 60.0 * 60.0 - + time.minute() * 60.0 + time.second() ); - } - else - setValid( false ); + if (time.isValid()) + { + setValue((time.hour() % 12) * 60.0 * 60.0 + time.minute() * 60.0 + + time.second()); + } + else + setValid(false); } /*! @@ -199,31 +199,30 @@ void QwtAnalogClock::setTime( const QTime& time ) \sa drawHand() */ -void QwtAnalogClock::drawNeedle( QPainter* painter, const QPointF& center, - double radius, double direction, QPalette::ColorGroup colorGroup ) const +void QwtAnalogClock::drawNeedle(QPainter *painter, const QPointF ¢er, + double radius, double direction, + QPalette::ColorGroup colorGroup) const { - Q_UNUSED( direction ); + Q_UNUSED(direction); - if ( isValid() ) + if (isValid()) + { + const double hours = value() / (60.0 * 60.0); + const double minutes = (value() - std::floor(hours) * 60.0 * 60.0) / 60.0; + const double seconds = value() - std::floor(hours) * 60.0 * 60.0 + - std::floor(minutes) * 60.0; + + double angle[NHands]; + angle[HourHand] = 360.0 * hours / 12.0; + angle[MinuteHand] = 360.0 * minutes / 60.0; + angle[SecondHand] = 360.0 * seconds / 60.0; + + for (int hand = 0; hand < NHands; hand++) { - const double hours = value() / ( 60.0 * 60.0 ); - const double minutes = - ( value() - std::floor(hours) * 60.0 * 60.0 ) / 60.0; - const double seconds = value() - std::floor(hours) * 60.0 * 60.0 - - std::floor(minutes) * 60.0; - - double angle[NHands]; - angle[HourHand] = 360.0 * hours / 12.0; - angle[MinuteHand] = 360.0 * minutes / 60.0; - angle[SecondHand] = 360.0 * seconds / 60.0; - - for ( int hand = 0; hand < NHands; hand++ ) - { - const double d = 360.0 - angle[hand] - origin(); - drawHand( painter, static_cast< Hand >( hand ), - center, radius, d, colorGroup ); - } + const double d = 360.0 - angle[hand] - origin(); + drawHand(painter, static_cast(hand), center, radius, d, colorGroup); } + } } /*! @@ -236,20 +235,20 @@ void QwtAnalogClock::drawNeedle( QPainter* painter, const QPointF& center, \param direction Direction of the hand in degrees, counter clockwise \param cg ColorGroup */ -void QwtAnalogClock::drawHand( QPainter* painter, Hand hd, - const QPointF& center, double radius, double direction, - QPalette::ColorGroup cg ) const +void QwtAnalogClock::drawHand(QPainter *painter, Hand hd, const QPointF ¢er, + double radius, double direction, + QPalette::ColorGroup cg) const { - const QwtDialNeedle* needle = hand( hd ); - if ( needle ) - { - if ( hd == HourHand ) - radius = qRound( 0.8 * radius ); + const QwtDialNeedle *needle = hand(hd); + if (needle) + { + if (hd == HourHand) + radius = qRound(0.8 * radius); - needle->draw( painter, center, radius, direction, cg ); - } + needle->draw(painter, center, radius, direction, cg); + } } #if QWT_MOC_INCLUDE -#include "moc_qwt_analog_clock.cpp" +# include "moc_qwt_analog_clock.cpp" #endif diff --git a/libs/qwt/src/qwt_analog_clock.h b/libs/qwt/src/qwt_analog_clock.h index fb848302..3f19a3f6 100644 --- a/libs/qwt/src/qwt_analog_clock.h +++ b/libs/qwt/src/qwt_analog_clock.h @@ -42,52 +42,53 @@ class QwtDialNeedle; class QWT_EXPORT QwtAnalogClock : public QwtDial { - Q_OBJECT + Q_OBJECT - public: - /*! - Hand type - \sa setHand(), hand() - */ - enum Hand - { - //! Needle displaying the seconds - SecondHand, +public: + /*! + Hand type + \sa setHand(), hand() + */ + enum Hand + { + //! Needle displaying the seconds + SecondHand, - //! Needle displaying the minutes - MinuteHand, + //! Needle displaying the minutes + MinuteHand, - //! Needle displaying the hours - HourHand, + //! Needle displaying the hours + HourHand, - //! Number of needles - NHands - }; + //! Number of needles + NHands + }; - explicit QwtAnalogClock( QWidget* parent = NULL ); - virtual ~QwtAnalogClock(); + explicit QwtAnalogClock(QWidget *parent = NULL); + virtual ~QwtAnalogClock(); - void setHand( Hand, QwtDialNeedle* ); + void setHand(Hand, QwtDialNeedle *); - const QwtDialNeedle* hand( Hand ) const; - QwtDialNeedle* hand( Hand ); + const QwtDialNeedle *hand(Hand) const; + QwtDialNeedle *hand(Hand); - public Q_SLOTS: - void setCurrentTime(); - void setTime( const QTime& ); +public Q_SLOTS: + void setCurrentTime(); + void setTime(const QTime &); - protected: - virtual void drawNeedle( QPainter*, const QPointF&, double radius, - double direction, QPalette::ColorGroup ) const QWT_OVERRIDE; +protected: + virtual void drawNeedle(QPainter *, const QPointF &, double radius, + double direction, + QPalette::ColorGroup) const QWT_OVERRIDE; - virtual void drawHand( QPainter*, Hand, const QPointF&, - double radius, double direction, QPalette::ColorGroup ) const; + virtual void drawHand(QPainter *, Hand, const QPointF &, double radius, + double direction, QPalette::ColorGroup) const; - private: - // use setHand instead - void setNeedle( QwtDialNeedle* ); +private: + // use setHand instead + void setNeedle(QwtDialNeedle *); - QwtDialNeedle* m_hand[NHands]; + QwtDialNeedle *m_hand[NHands]; }; #endif diff --git a/libs/qwt/src/qwt_arrow_button.cpp b/libs/qwt/src/qwt_arrow_button.cpp index 0825d42e..b5d0c314 100644 --- a/libs/qwt/src/qwt_arrow_button.cpp +++ b/libs/qwt/src/qwt_arrow_button.cpp @@ -21,30 +21,30 @@ static const int QwtArrowButton_Spacing = 1; class QwtArrowButton::PrivateData { - public: - int num; - Qt::ArrowType arrowType; +public: + int num; + Qt::ArrowType arrowType; }; -static QStyleOptionButton QwtArrowButton_styleOpt( const QwtArrowButton* btn ) +static QStyleOptionButton QwtArrowButton_styleOpt(const QwtArrowButton *btn) { - QStyleOptionButton option; - option.initFrom( btn ); - option.features = QStyleOptionButton::None; - if ( btn->isFlat() ) - option.features |= QStyleOptionButton::Flat; - if ( btn->menu() ) - option.features |= QStyleOptionButton::HasMenu; - if ( btn->autoDefault() || btn->isDefault() ) - option.features |= QStyleOptionButton::AutoDefaultButton; - if ( btn->isDefault() ) - option.features |= QStyleOptionButton::DefaultButton; - if ( btn->isDown() ) - option.state |= QStyle::State_Sunken; - if ( !btn->isFlat() && !btn->isDown() ) - option.state |= QStyle::State_Raised; + QStyleOptionButton option; + option.initFrom(btn); + option.features = QStyleOptionButton::None; + if (btn->isFlat()) + option.features |= QStyleOptionButton::Flat; + if (btn->menu()) + option.features |= QStyleOptionButton::HasMenu; + if (btn->autoDefault() || btn->isDefault()) + option.features |= QStyleOptionButton::AutoDefaultButton; + if (btn->isDefault()) + option.features |= QStyleOptionButton::DefaultButton; + if (btn->isDown()) + option.state |= QStyle::State_Sunken; + if (!btn->isFlat() && !btn->isDown()) + option.state |= QStyle::State_Raised; - return option; + return option; } /*! @@ -52,34 +52,33 @@ static QStyleOptionButton QwtArrowButton_styleOpt( const QwtArrowButton* btn ) \param arrowType see Qt::ArrowType in the Qt docs. \param parent Parent widget */ -QwtArrowButton::QwtArrowButton( int num, Qt::ArrowType arrowType, QWidget* parent ) - : QPushButton( parent ) +QwtArrowButton::QwtArrowButton(int num, Qt::ArrowType arrowType, + QWidget *parent) + : QPushButton(parent) { - m_data = new PrivateData; - m_data->num = qBound( 1, num, QwtArrowButton_MaxNum ); - m_data->arrowType = arrowType; + m_data = new PrivateData; + m_data->num = qBound(1, num, QwtArrowButton_MaxNum); + m_data->arrowType = arrowType; - setAutoRepeat( true ); - setAutoDefault( false ); + setAutoRepeat(true); + setAutoDefault(false); - switch ( m_data->arrowType ) - { - case Qt::LeftArrow: - case Qt::RightArrow: - setSizePolicy( QSizePolicy::Expanding, - QSizePolicy::Fixed ); - break; - default: - setSizePolicy( QSizePolicy::Fixed, - QSizePolicy::Expanding ); - } + switch (m_data->arrowType) + { + case Qt::LeftArrow: + case Qt::RightArrow: + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + break; + default: + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + } } //! Destructor QwtArrowButton::~QwtArrowButton() { - delete m_data; - m_data = NULL; + delete m_data; + m_data = NULL; } /*! @@ -87,7 +86,7 @@ QwtArrowButton::~QwtArrowButton() */ Qt::ArrowType QwtArrowButton::arrowType() const { - return m_data->arrowType; + return m_data->arrowType; } /*! @@ -95,7 +94,7 @@ Qt::ArrowType QwtArrowButton::arrowType() const */ int QwtArrowButton::num() const { - return m_data->num; + return m_data->num; } /*! @@ -103,35 +102,34 @@ int QwtArrowButton::num() const */ QRect QwtArrowButton::labelRect() const { - const int m = QwtArrowButton_Margin; + const int m = QwtArrowButton_Margin; - QRect r = rect(); - r.setRect( r.x() + m, r.y() + m, - r.width() - 2 * m, r.height() - 2 * m ); + QRect r = rect(); + r.setRect(r.x() + m, r.y() + m, r.width() - 2 * m, r.height() - 2 * m); - if ( isDown() ) - { - QStyleOptionButton option = QwtArrowButton_styleOpt( this ); - const int ph = style()->pixelMetric( - QStyle::PM_ButtonShiftHorizontal, &option, this ); - const int pv = style()->pixelMetric( - QStyle::PM_ButtonShiftVertical, &option, this ); + if (isDown()) + { + QStyleOptionButton option = QwtArrowButton_styleOpt(this); + const int ph + = style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &option, this); + const int pv + = style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &option, this); - r.translate( ph, pv ); - } + r.translate(ph, pv); + } - return r; + return r; } /*! Paint event handler \param event Paint event */ -void QwtArrowButton::paintEvent( QPaintEvent* event ) +void QwtArrowButton::paintEvent(QPaintEvent *event) { - QPushButton::paintEvent( event ); - QPainter painter( this ); - drawButtonLabel( &painter ); + QPushButton::paintEvent(event); + QPainter painter(this); + drawButtonLabel(&painter); } /*! @@ -140,69 +138,68 @@ void QwtArrowButton::paintEvent( QPaintEvent* event ) \param painter Painter \sa The Qt Manual for QPushButton */ -void QwtArrowButton::drawButtonLabel( QPainter* painter ) +void QwtArrowButton::drawButtonLabel(QPainter *painter) { - const bool isVertical = m_data->arrowType == Qt::UpArrow || - m_data->arrowType == Qt::DownArrow; + const bool isVertical + = m_data->arrowType == Qt::UpArrow || m_data->arrowType == Qt::DownArrow; - const QRect r = labelRect(); - QSize boundingSize = labelRect().size(); - if ( isVertical ) - boundingSize.transpose(); + const QRect r = labelRect(); + QSize boundingSize = labelRect().size(); + if (isVertical) + boundingSize.transpose(); - const int w = - ( boundingSize.width() - ( QwtArrowButton_MaxNum - 1 ) * QwtArrowButton_Spacing ) / QwtArrowButton_MaxNum; + const int w = (boundingSize.width() + - (QwtArrowButton_MaxNum - 1) * QwtArrowButton_Spacing) + / QwtArrowButton_MaxNum; - QSize arrow = arrowSize( Qt::RightArrow, - QSize( w, boundingSize.height() ) ); + QSize arrow = arrowSize(Qt::RightArrow, QSize(w, boundingSize.height())); - if ( isVertical ) - arrow.transpose(); + if (isVertical) + arrow.transpose(); - QRect contentsSize; // aligned rect where to paint all arrows - if ( m_data->arrowType == Qt::LeftArrow || m_data->arrowType == Qt::RightArrow ) - { - contentsSize.setWidth( m_data->num * arrow.width() - + ( m_data->num - 1 ) * QwtArrowButton_Spacing ); - contentsSize.setHeight( arrow.height() ); - } + QRect contentsSize; // aligned rect where to paint all arrows + if (m_data->arrowType == Qt::LeftArrow || m_data->arrowType == Qt::RightArrow) + { + contentsSize.setWidth(m_data->num * arrow.width() + + (m_data->num - 1) * QwtArrowButton_Spacing); + contentsSize.setHeight(arrow.height()); + } + else + { + contentsSize.setWidth(arrow.width()); + contentsSize.setHeight(m_data->num * arrow.height() + + (m_data->num - 1) * QwtArrowButton_Spacing); + } + + QRect arrowRect(contentsSize); + arrowRect.moveCenter(r.center()); + arrowRect.setSize(arrow); + + painter->save(); + for (int i = 0; i < m_data->num; i++) + { + drawArrow(painter, arrowRect, m_data->arrowType); + + int dx = 0; + int dy = 0; + + if (isVertical) + dy = arrow.height() + QwtArrowButton_Spacing; else - { - contentsSize.setWidth( arrow.width() ); - contentsSize.setHeight( m_data->num * arrow.height() - + ( m_data->num - 1 ) * QwtArrowButton_Spacing ); - } + dx = arrow.width() + QwtArrowButton_Spacing; - QRect arrowRect( contentsSize ); - arrowRect.moveCenter( r.center() ); - arrowRect.setSize( arrow ); + arrowRect.translate(dx, dy); + } + painter->restore(); - painter->save(); - for ( int i = 0; i < m_data->num; i++ ) - { - drawArrow( painter, arrowRect, m_data->arrowType ); + if (hasFocus()) + { + QStyleOptionFocusRect option; + option.initFrom(this); + option.backgroundColor = palette().color(QPalette::Window); - int dx = 0; - int dy = 0; - - if ( isVertical ) - dy = arrow.height() + QwtArrowButton_Spacing; - else - dx = arrow.width() + QwtArrowButton_Spacing; - - arrowRect.translate( dx, dy ); - } - painter->restore(); - - if ( hasFocus() ) - { - QStyleOptionFocusRect option; - option.initFrom( this ); - option.backgroundColor = palette().color( QPalette::Window ); - - style()->drawPrimitive( QStyle::PE_FrameFocusRect, - &option, painter, this ); - } + style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, painter, this); + } } /*! @@ -212,45 +209,45 @@ void QwtArrowButton::drawButtonLabel( QPainter* painter ) \param r Rectangle where to paint the arrow \param arrowType Arrow type */ -void QwtArrowButton::drawArrow( QPainter* painter, - const QRect& r, Qt::ArrowType arrowType ) const +void QwtArrowButton::drawArrow(QPainter *painter, const QRect &r, + Qt::ArrowType arrowType) const { - QPolygon pa( 3 ); + QPolygon pa(3); - switch ( arrowType ) - { - case Qt::UpArrow: - pa.setPoint( 0, r.bottomLeft() ); - pa.setPoint( 1, r.bottomRight() ); - pa.setPoint( 2, r.center().x(), r.top() ); - break; - case Qt::DownArrow: - pa.setPoint( 0, r.topLeft() ); - pa.setPoint( 1, r.topRight() ); - pa.setPoint( 2, r.center().x(), r.bottom() ); - break; - case Qt::RightArrow: - pa.setPoint( 0, r.topLeft() ); - pa.setPoint( 1, r.bottomLeft() ); - pa.setPoint( 2, r.right(), r.center().y() ); - break; - case Qt::LeftArrow: - pa.setPoint( 0, r.topRight() ); - pa.setPoint( 1, r.bottomRight() ); - pa.setPoint( 2, r.left(), r.center().y() ); - break; - default: - break; - } + switch (arrowType) + { + case Qt::UpArrow: + pa.setPoint(0, r.bottomLeft()); + pa.setPoint(1, r.bottomRight()); + pa.setPoint(2, r.center().x(), r.top()); + break; + case Qt::DownArrow: + pa.setPoint(0, r.topLeft()); + pa.setPoint(1, r.topRight()); + pa.setPoint(2, r.center().x(), r.bottom()); + break; + case Qt::RightArrow: + pa.setPoint(0, r.topLeft()); + pa.setPoint(1, r.bottomLeft()); + pa.setPoint(2, r.right(), r.center().y()); + break; + case Qt::LeftArrow: + pa.setPoint(0, r.topRight()); + pa.setPoint(1, r.bottomRight()); + pa.setPoint(2, r.left(), r.center().y()); + break; + default: + break; + } - painter->save(); + painter->save(); - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().brush( QPalette::ButtonText ) ); - painter->drawPolygon( pa ); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setPen(Qt::NoPen); + painter->setBrush(palette().brush(QPalette::ButtonText)); + painter->drawPolygon(pa); - painter->restore(); + painter->restore(); } /*! @@ -258,8 +255,8 @@ void QwtArrowButton::drawArrow( QPainter* painter, */ QSize QwtArrowButton::sizeHint() const { - const QSize hint = minimumSizeHint(); - return qwtExpandedToGlobalStrut( hint ); + const QSize hint = minimumSizeHint(); + return qwtExpandedToGlobalStrut(hint); } /*! @@ -267,23 +264,22 @@ QSize QwtArrowButton::sizeHint() const */ QSize QwtArrowButton::minimumSizeHint() const { - const QSize asz = arrowSize( Qt::RightArrow, QSize() ); + const QSize asz = arrowSize(Qt::RightArrow, QSize()); - QSize sz( - 2 * QwtArrowButton_Margin + ( QwtArrowButton_MaxNum - 1 ) * QwtArrowButton_Spacing + QwtArrowButton_MaxNum * asz.width(), - 2 * QwtArrowButton_Margin + asz.height() - ); + QSize sz(2 * QwtArrowButton_Margin + + (QwtArrowButton_MaxNum - 1) * QwtArrowButton_Spacing + + QwtArrowButton_MaxNum * asz.width(), + 2 * QwtArrowButton_Margin + asz.height()); - if ( m_data->arrowType == Qt::UpArrow || m_data->arrowType == Qt::DownArrow ) - sz.transpose(); + if (m_data->arrowType == Qt::UpArrow || m_data->arrowType == Qt::DownArrow) + sz.transpose(); - QStyleOption styleOption; - styleOption.initFrom( this ); + QStyleOption styleOption; + styleOption.initFrom(this); - sz = style()->sizeFromContents( QStyle::CT_PushButton, - &styleOption, sz, this ); + sz = style()->sizeFromContents(QStyle::CT_PushButton, &styleOption, sz, this); - return sz; + return sz; } /*! @@ -293,40 +289,39 @@ QSize QwtArrowButton::minimumSizeHint() const \param boundingSize Bounding size \return Size of the arrow */ -QSize QwtArrowButton::arrowSize( Qt::ArrowType arrowType, - const QSize& boundingSize ) const +QSize QwtArrowButton::arrowSize(Qt::ArrowType arrowType, + const QSize &boundingSize) const { - QSize bs = boundingSize; - if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) - bs.transpose(); + QSize bs = boundingSize; + if (arrowType == Qt::UpArrow || arrowType == Qt::DownArrow) + bs.transpose(); - const int MinLen = 2; - const QSize sz = bs.expandedTo( - QSize( MinLen, 2 * MinLen - 1 ) ); // minimum + const int MinLen = 2; + const QSize sz = bs.expandedTo(QSize(MinLen, 2 * MinLen - 1)); // minimum - int w = sz.width(); - int h = 2 * w - 1; + int w = sz.width(); + int h = 2 * w - 1; - if ( h > sz.height() ) - { - h = sz.height(); - w = ( h + 1 ) / 2; - } + if (h > sz.height()) + { + h = sz.height(); + w = (h + 1) / 2; + } - QSize arrSize( w, h ); - if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) - arrSize.transpose(); + QSize arrSize(w, h); + if (arrowType == Qt::UpArrow || arrowType == Qt::DownArrow) + arrSize.transpose(); - return arrSize; + return arrSize; } /*! \brief autoRepeat for the space keys */ -void QwtArrowButton::keyPressEvent( QKeyEvent* event ) +void QwtArrowButton::keyPressEvent(QKeyEvent *event) { - if ( event->isAutoRepeat() && event->key() == Qt::Key_Space ) - Q_EMIT clicked(); + if (event->isAutoRepeat() && event->key() == Qt::Key_Space) + Q_EMIT clicked(); - QPushButton::keyPressEvent( event ); + QPushButton::keyPressEvent(event); } diff --git a/libs/qwt/src/qwt_arrow_button.h b/libs/qwt/src/qwt_arrow_button.h index 85f42102..df8ab002 100644 --- a/libs/qwt/src/qwt_arrow_button.h +++ b/libs/qwt/src/qwt_arrow_button.h @@ -22,30 +22,28 @@ */ class QWT_EXPORT QwtArrowButton : public QPushButton { - public: - explicit QwtArrowButton ( int num, Qt::ArrowType, QWidget* parent = NULL ); - virtual ~QwtArrowButton(); +public: + explicit QwtArrowButton(int num, Qt::ArrowType, QWidget *parent = NULL); + virtual ~QwtArrowButton(); - Qt::ArrowType arrowType() const; - int num() const; + Qt::ArrowType arrowType() const; + int num() const; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - protected: - virtual void paintEvent( QPaintEvent*) QWT_OVERRIDE; - virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE; - virtual void drawButtonLabel( QPainter* ); - virtual void drawArrow( QPainter*, - const QRect&, Qt::ArrowType ) const; - virtual QRect labelRect() const; - virtual QSize arrowSize( Qt::ArrowType, - const QSize& boundingSize ) const; + virtual void drawButtonLabel(QPainter *); + virtual void drawArrow(QPainter *, const QRect &, Qt::ArrowType) const; + virtual QRect labelRect() const; + virtual QSize arrowSize(Qt::ArrowType, const QSize &boundingSize) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_axis.h b/libs/qwt/src/qwt_axis.h index 433abae8..1a96f4fd 100644 --- a/libs/qwt/src/qwt_axis.h +++ b/libs/qwt/src/qwt_axis.h @@ -17,46 +17,49 @@ */ namespace QwtAxis { - //! \brief Axis position - enum Position - { - //! Y axis left of the canvas - YLeft, +//! \brief Axis position +enum Position +{ + //! Y axis left of the canvas + YLeft, - //! Y axis right of the canvas - YRight, + //! Y axis right of the canvas + YRight, - //! X axis below the canvas - XBottom, + //! X axis below the canvas + XBottom, - //! X axis above the canvas - XTop - }; + //! X axis above the canvas + XTop +}; - //! \brief Number of axis positions - enum { AxisPositions = XTop + 1 }; +//! \brief Number of axis positions +enum +{ + AxisPositions = XTop + 1 +}; - bool isValid( int axisPos ); - bool isYAxis( int axisPos ); - bool isXAxis( int axisPos ); -} +bool isValid(int axisPos); +bool isYAxis(int axisPos); +bool isXAxis(int axisPos); +} // namespace QwtAxis //! \return true, when axisPos is in the valid range [ YLeft, XTop ] -inline bool QwtAxis::isValid( int axisPos ) +inline bool QwtAxis::isValid(int axisPos) { - return ( axisPos >= 0 && axisPos < AxisPositions ); + return (axisPos >= 0 && axisPos < AxisPositions); } //! \return true, when axisPos is XBottom or XTop -inline bool QwtAxis::isXAxis( int axisPos ) +inline bool QwtAxis::isXAxis(int axisPos) { - return ( axisPos == XBottom ) || ( axisPos == XTop ); + return (axisPos == XBottom) || (axisPos == XTop); } //! \return true, when axisPos is YLeft or YRight -inline bool QwtAxis::isYAxis( int axisPos ) +inline bool QwtAxis::isYAxis(int axisPos) { - return ( axisPos == YLeft ) || ( axisPos == YRight ); + return (axisPos == YLeft) || (axisPos == YRight); } #endif diff --git a/libs/qwt/src/qwt_bezier.cpp b/libs/qwt/src/qwt_bezier.cpp index 11229eae..1f7f3add 100644 --- a/libs/qwt/src/qwt_bezier.cpp +++ b/libs/qwt/src/qwt_bezier.cpp @@ -15,96 +15,90 @@ namespace { - class BezierData - { - public: - inline BezierData() - { - // default constructor with uninitialized points - } +class BezierData +{ +public: + inline BezierData() + { + // default constructor with uninitialized points + } - inline BezierData( const QPointF& p1, const QPointF& cp1, - const QPointF& cp2, const QPointF& p2 ): - m_x1( p1.x() ), - m_y1( p1.y() ), - m_cx1( cp1.x() ), - m_cy1( cp1.y() ), - m_cx2( cp2.x() ), - m_cy2( cp2.y() ), - m_x2( p2.x() ), - m_y2( p2.y() ) - { - } + inline BezierData(const QPointF &p1, const QPointF &cp1, const QPointF &cp2, + const QPointF &p2) + : m_x1(p1.x()) + , m_y1(p1.y()) + , m_cx1(cp1.x()) + , m_cy1(cp1.y()) + , m_cx2(cp2.x()) + , m_cy2(cp2.y()) + , m_x2(p2.x()) + , m_y2(p2.y()) + { + } - static inline double minFlatness( double tolerance ) - { - // we can simplify the tolerance criterion check in - // the subdivision loop, by precalculating some - // flatness value. + static inline double minFlatness(double tolerance) + { + // we can simplify the tolerance criterion check in + // the subdivision loop, by precalculating some + // flatness value. - return 16 * ( tolerance * tolerance ); - } + return 16 * (tolerance * tolerance); + } - inline double flatness() const - { - // algo by Roger Willcocks ( http://www.rops.org ) + inline double flatness() const + { + // algo by Roger Willcocks ( http://www.rops.org ) - const double ux = 3.0 * m_cx1 - 2.0 * m_x1 - m_x2; - const double uy = 3.0 * m_cy1 - 2.0 * m_y1 - m_y2; - const double vx = 3.0 * m_cx2 - 2.0 * m_x2 - m_x1; - const double vy = 3.0 * m_cy2 - 2.0 * m_y2 - m_y1; + const double ux = 3.0 * m_cx1 - 2.0 * m_x1 - m_x2; + const double uy = 3.0 * m_cy1 - 2.0 * m_y1 - m_y2; + const double vx = 3.0 * m_cx2 - 2.0 * m_x2 - m_x1; + const double vy = 3.0 * m_cy2 - 2.0 * m_y2 - m_y1; - const double ux2 = ux * ux; - const double uy2 = uy * uy; + const double ux2 = ux * ux; + const double uy2 = uy * uy; - const double vx2 = vx * vx; - const double vy2 = vy * vy; + const double vx2 = vx * vx; + const double vy2 = vy * vy; - return qwtMaxF( ux2, vx2 ) + qwtMaxF( uy2, vy2 ); - } + return qwtMaxF(ux2, vx2) + qwtMaxF(uy2, vy2); + } - inline BezierData subdivided() - { - BezierData bz; + inline BezierData subdivided() + { + BezierData bz; - const double c1 = midValue( m_cx1, m_cx2 ); + const double c1 = midValue(m_cx1, m_cx2); - bz.m_cx1 = midValue( m_x1, m_cx1 ); - m_cx2 = midValue( m_cx2, m_x2 ); - bz.m_x1 = m_x1; - bz.m_cx2 = midValue( bz.m_cx1, c1 ); - m_cx1 = midValue( c1, m_cx2 ); - bz.m_x2 = m_x1 = midValue( bz.m_cx2, m_cx1 ); + bz.m_cx1 = midValue(m_x1, m_cx1); + m_cx2 = midValue(m_cx2, m_x2); + bz.m_x1 = m_x1; + bz.m_cx2 = midValue(bz.m_cx1, c1); + m_cx1 = midValue(c1, m_cx2); + bz.m_x2 = m_x1 = midValue(bz.m_cx2, m_cx1); - const double c2 = midValue( m_cy1, m_cy2 ); + const double c2 = midValue(m_cy1, m_cy2); - bz.m_cy1 = midValue( m_y1, m_cy1 ); - m_cy2 = midValue( m_cy2, m_y2 ); - bz.m_y1 = m_y1; - bz.m_cy2 = midValue( bz.m_cy1, c2 ); - m_cy1 = midValue( m_cy2, c2 ); - bz.m_y2 = m_y1 = midValue( bz.m_cy2, m_cy1 ); + bz.m_cy1 = midValue(m_y1, m_cy1); + m_cy2 = midValue(m_cy2, m_y2); + bz.m_y1 = m_y1; + bz.m_cy2 = midValue(bz.m_cy1, c2); + m_cy1 = midValue(m_cy2, c2); + bz.m_y2 = m_y1 = midValue(bz.m_cy2, m_cy1); - return bz; - } + return bz; + } - inline QPointF p2() const - { - return QPointF( m_x2, m_y2 ); - } + inline QPointF p2() const { return QPointF(m_x2, m_y2); } - private: - inline double midValue( double v1, double v2 ) - { - return 0.5 * ( v1 + v2 ); - } +private: + inline double midValue(double v1, double v2) { return 0.5 * (v1 + v2); } - double m_x1, m_y1; - double m_cx1, m_cy1; - double m_cx2, m_cy2; - double m_x2, m_y2; - }; -} + double m_x1, m_y1; + double m_cx1, m_cy1; + double m_cx2, m_cy2; + double m_x2, m_y2; +}; +} // namespace /*! \brief Constructor @@ -113,16 +107,14 @@ namespace \sa setTolerance() */ -QwtBezier::QwtBezier( double tolerance ) - : m_tolerance( qwtMaxF( tolerance, 0.0 ) ) - , m_flatness( BezierData::minFlatness( m_tolerance ) ) +QwtBezier::QwtBezier(double tolerance) + : m_tolerance(qwtMaxF(tolerance, 0.0)) + , m_flatness(BezierData::minFlatness(m_tolerance)) { } //! Destructor -QwtBezier::~QwtBezier() -{ -} +QwtBezier::~QwtBezier() {} /*! Set the tolerance @@ -138,10 +130,10 @@ QwtBezier::~QwtBezier() \param tolerance Termination criterion for the subdivision \sa tolerance() */ -void QwtBezier::setTolerance( double tolerance ) +void QwtBezier::setTolerance(double tolerance) { - m_tolerance = qwtMaxF( tolerance, 0.0 ); - m_flatness = BezierData::minFlatness( m_tolerance ); + m_tolerance = qwtMaxF(tolerance, 0.0); + m_flatness = BezierData::minFlatness(m_tolerance); } /*! @@ -154,18 +146,18 @@ void QwtBezier::setTolerance( double tolerance ) \return Interpolating polygon */ -QPolygonF QwtBezier::toPolygon( const QPointF& p1, - const QPointF& cp1, const QPointF& cp2, const QPointF& p2 ) const +QPolygonF QwtBezier::toPolygon(const QPointF &p1, const QPointF &cp1, + const QPointF &cp2, const QPointF &p2) const { - QPolygonF polygon; + QPolygonF polygon; - if ( m_flatness > 0.0 ) - { - // a flatness of 0.0 is not achievable - appendToPolygon( p1, cp1, cp2, p2, polygon ); - } + if (m_flatness > 0.0) + { + // a flatness of 0.0 is not achievable + appendToPolygon(p1, cp1, cp2, p2, polygon); + } - return polygon; + return polygon; } /*! @@ -183,46 +175,46 @@ QPolygonF QwtBezier::toPolygon( const QPointF& p1, \note If the last point of the incoming polygon matches p1 it won't be inserted a second time. */ -void QwtBezier::appendToPolygon( const QPointF& p1, const QPointF& cp1, - const QPointF& cp2, const QPointF& p2, QPolygonF& polygon ) const +void QwtBezier::appendToPolygon(const QPointF &p1, const QPointF &cp1, + const QPointF &cp2, const QPointF &p2, + QPolygonF &polygon) const { - if ( m_flatness <= 0.0 ) + if (m_flatness <= 0.0) + { + // a flatness of 0.0 is not achievable + return; + } + + if (polygon.isEmpty() || polygon.last() != p1) + polygon += p1; + + // to avoid deep stacks we convert the recursive algo + // to something iterative, where the parameters of the + // recursive class are pushed to a stack instead + + QStack stack; + stack.push(BezierData(p1, cp1, cp2, p2)); + + while (true) + { + BezierData &bz = stack.top(); + + if (bz.flatness() < m_flatness) { - // a flatness of 0.0 is not achievable + if (stack.size() == 1) + { + polygon += p2; return; + } + + polygon += bz.p2(); + stack.pop(); } - - if ( polygon.isEmpty() || polygon.last() != p1 ) - polygon += p1; - - // to avoid deep stacks we convert the recursive algo - // to something iterative, where the parameters of the - // recursive class are pushed to a stack instead - - QStack< BezierData > stack; - stack.push( BezierData( p1, cp1, cp2, p2 ) ); - - while( true ) + else { - BezierData& bz = stack.top(); - - if ( bz.flatness() < m_flatness ) - { - if ( stack.size() == 1 ) - { - polygon += p2; - return; - } - - polygon += bz.p2(); - stack.pop(); - } - else - { - stack.push( bz.subdivided() ); - } + stack.push(bz.subdivided()); } - + } } /*! @@ -236,17 +228,18 @@ void QwtBezier::appendToPolygon( const QPointF& p1, const QPointF& cp1, \return Point on the curve */ -QPointF QwtBezier::pointAt( const QPointF& p1, - const QPointF& cp1, const QPointF& cp2, const QPointF& p2, double t ) +QPointF QwtBezier::pointAt(const QPointF &p1, const QPointF &cp1, + const QPointF &cp2, const QPointF &p2, double t) { - const double d1 = 3.0 * t; - const double d2 = 3.0 * t * t; - const double d3 = t * t * t; - const double s = 1.0 - t; + const double d1 = 3.0 * t; + const double d2 = 3.0 * t * t; + const double d3 = t * t * t; + const double s = 1.0 - t; - const double x = ( ( s * p1.x() + d1 * cp1.x() ) * s + d2 * cp2.x() ) * s + d3 * p2.x(); - const double y = ( ( s * p1.y() + d1 * cp1.y() ) * s + d2 * cp2.y() ) * s + d3 * p2.y(); + const double x + = ((s * p1.x() + d1 * cp1.x()) * s + d2 * cp2.x()) * s + d3 * p2.x(); + const double y + = ((s * p1.y() + d1 * cp1.y()) * s + d2 * cp2.y()) * s + d3 * p2.y(); - return QPointF( x, y ); + return QPointF(x, y); } - diff --git a/libs/qwt/src/qwt_bezier.h b/libs/qwt/src/qwt_bezier.h index 7b0cbe33..2c2ff874 100644 --- a/libs/qwt/src/qwt_bezier.h +++ b/libs/qwt/src/qwt_bezier.h @@ -28,25 +28,26 @@ class QPolygonF; */ class QWT_EXPORT QwtBezier { - public: - QwtBezier( double tolerance = 0.5 ); - ~QwtBezier(); +public: + QwtBezier(double tolerance = 0.5); + ~QwtBezier(); - void setTolerance( double tolerance ); - double tolerance() const; + void setTolerance(double tolerance); + double tolerance() const; - QPolygonF toPolygon( const QPointF& p1, const QPointF& cp1, - const QPointF& cp2, const QPointF& p2 ) const; + QPolygonF toPolygon(const QPointF &p1, const QPointF &cp1, const QPointF &cp2, + const QPointF &p2) const; - void appendToPolygon( const QPointF& p1, const QPointF& cp1, - const QPointF& cp2, const QPointF& p2, QPolygonF& polygon ) const; + void appendToPolygon(const QPointF &p1, const QPointF &cp1, + const QPointF &cp2, const QPointF &p2, + QPolygonF &polygon) const; - static QPointF pointAt( const QPointF& p1, const QPointF& cp1, - const QPointF& cp2, const QPointF& p2, double t ); + static QPointF pointAt(const QPointF &p1, const QPointF &cp1, + const QPointF &cp2, const QPointF &p2, double t); - private: - double m_tolerance; - double m_flatness; +private: + double m_tolerance; + double m_flatness; }; /*! @@ -55,7 +56,7 @@ class QWT_EXPORT QwtBezier */ inline double QwtBezier::tolerance() const { - return m_tolerance; + return m_tolerance; } #endif diff --git a/libs/qwt/src/qwt_clipper.cpp b/libs/qwt/src/qwt_clipper.cpp index f58ad79b..d84d340e 100644 --- a/libs/qwt/src/qwt_clipper.cpp +++ b/libs/qwt/src/qwt_clipper.cpp @@ -19,344 +19,335 @@ namespace QwtClip { - // some templates used for inlining - template< class Point, typename T > class LeftEdge; - template< class Point, typename T > class RightEdge; - template< class Point, typename T > class TopEdge; - template< class Point, typename T > class BottomEdge; -} +// some templates used for inlining +template +class LeftEdge; +template +class RightEdge; +template +class TopEdge; +template +class BottomEdge; +} // namespace QwtClip -template< class Point, typename Value > +template class QwtClip::LeftEdge { - public: - inline LeftEdge( Value x1, Value, Value, Value ): - m_x1( x1 ) - { - } +public: + inline LeftEdge(Value x1, Value, Value, Value) + : m_x1(x1) + { + } - inline bool isInside( const Point& p ) const - { - return p.x() >= m_x1; - } + inline bool isInside(const Point &p) const { return p.x() >= m_x1; } - inline Point intersection( const Point& p1, const Point& p2 ) const - { - double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() ); - return Point( m_x1, static_cast< Value >( p2.y() + ( m_x1 - p2.x() ) * dy ) ); - } - private: - const Value m_x1; + inline Point intersection(const Point &p1, const Point &p2) const + { + double dy = (p1.y() - p2.y()) / double(p1.x() - p2.x()); + return Point(m_x1, static_cast(p2.y() + (m_x1 - p2.x()) * dy)); + } + +private: + const Value m_x1; }; -template< class Point, typename Value > +template class QwtClip::RightEdge { - public: - inline RightEdge( Value, Value x2, Value, Value ): - m_x2( x2 ) - { - } +public: + inline RightEdge(Value, Value x2, Value, Value) + : m_x2(x2) + { + } - inline bool isInside( const Point& p ) const - { - return p.x() <= m_x2; - } + inline bool isInside(const Point &p) const { return p.x() <= m_x2; } - inline Point intersection( const Point& p1, const Point& p2 ) const - { - double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() ); - return Point( m_x2, static_cast< Value >( p2.y() + ( m_x2 - p2.x() ) * dy ) ); - } + inline Point intersection(const Point &p1, const Point &p2) const + { + double dy = (p1.y() - p2.y()) / double(p1.x() - p2.x()); + return Point(m_x2, static_cast(p2.y() + (m_x2 - p2.x()) * dy)); + } - private: - const Value m_x2; +private: + const Value m_x2; }; -template< class Point, typename Value > +template class QwtClip::TopEdge { - public: - inline TopEdge( Value, Value, Value y1, Value ): - m_y1( y1 ) - { - } +public: + inline TopEdge(Value, Value, Value y1, Value) + : m_y1(y1) + { + } - inline bool isInside( const Point& p ) const - { - return p.y() >= m_y1; - } + inline bool isInside(const Point &p) const { return p.y() >= m_y1; } - inline Point intersection( const Point& p1, const Point& p2 ) const - { - double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() ); - return Point( static_cast< Value >( p2.x() + ( m_y1 - p2.y() ) * dx ), m_y1 ); - } + inline Point intersection(const Point &p1, const Point &p2) const + { + double dx = (p1.x() - p2.x()) / double(p1.y() - p2.y()); + return Point(static_cast(p2.x() + (m_y1 - p2.y()) * dx), m_y1); + } - private: - const Value m_y1; +private: + const Value m_y1; }; -template< class Point, typename Value > +template class QwtClip::BottomEdge { - public: - inline BottomEdge( Value, Value, Value, Value y2 ): - m_y2( y2 ) - { - } +public: + inline BottomEdge(Value, Value, Value, Value y2) + : m_y2(y2) + { + } - inline bool isInside( const Point& p ) const - { - return p.y() <= m_y2; - } + inline bool isInside(const Point &p) const { return p.y() <= m_y2; } - inline Point intersection( const Point& p1, const Point& p2 ) const - { - double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() ); - return Point( static_cast< Value >( p2.x() + ( m_y2 - p2.y() ) * dx ), m_y2 ); - } + inline Point intersection(const Point &p1, const Point &p2) const + { + double dx = (p1.x() - p2.x()) / double(p1.y() - p2.y()); + return Point(static_cast(p2.x() + (m_y2 - p2.y()) * dx), m_y2); + } - private: - const Value m_y2; +private: + const Value m_y2; }; using namespace QwtClip; -template< class Polygon, class Rect, typename T > +template class QwtPolygonClipper { - typedef typename Polygon::value_type Point; - public: - explicit QwtPolygonClipper( const Rect& clipRect ): - m_clipRect( clipRect ) - { - } + typedef typename Polygon::value_type Point; - void clipPolygon( Polygon& points1, bool closePolygon ) const - { +public: + explicit QwtPolygonClipper(const Rect &clipRect) + : m_clipRect(clipRect) + { + } + + void clipPolygon(Polygon &points1, bool closePolygon) const + { #if 0 if ( m_clipRect.contains( points1.boundingRect() ) ) return polygon; #endif - Polygon points2; - points2.reserve( qMin( 256, points1.size() ) ); + Polygon points2; + points2.reserve(qMin(256, points1.size())); - clipEdge< LeftEdge< Point, T > >( closePolygon, points1, points2 ); - clipEdge< RightEdge< Point, T > >( closePolygon, points2, points1 ); - clipEdge< TopEdge< Point, T > >( closePolygon, points1, points2 ); - clipEdge< BottomEdge< Point, T > >( closePolygon, points2, points1 ); - } + clipEdge>(closePolygon, points1, points2); + clipEdge>(closePolygon, points2, points1); + clipEdge>(closePolygon, points1, points2); + clipEdge>(closePolygon, points2, points1); + } - private: - template< class Edge > - inline void clipEdge( bool closePolygon, - const Polygon& points, Polygon& clippedPoints ) const +private: + template + inline void clipEdge(bool closePolygon, const Polygon &points, + Polygon &clippedPoints) const + { + clippedPoints.clear(); + + if (points.size() < 2) { - clippedPoints.clear(); + if (points.size() == 1) + clippedPoints += points[0]; - if ( points.size() < 2 ) - { - if ( points.size() == 1 ) - clippedPoints += points[0]; - - return; - } - - const Edge edge( m_clipRect.x(), m_clipRect.x() + m_clipRect.width(), - m_clipRect.y(), m_clipRect.y() + m_clipRect.height() ); - - if ( !closePolygon ) - { - const Point& p1 = points.first(); - - if ( edge.isInside( p1 ) ) - clippedPoints += p1; - } - else - { - const Point& p1 = points.first(); - const Point& p2 = points.last(); - - if ( edge.isInside( p1 ) ) - { - if ( !edge.isInside( p2 ) ) - clippedPoints += edge.intersection( p1, p2 ); - - clippedPoints += p1; - } - else if ( edge.isInside( p2 ) ) - { - clippedPoints += edge.intersection( p1, p2 ); - } - } - - const uint nPoints = points.size(); - const Point* p = points.constData(); - - for ( uint i = 1; i < nPoints; i++ ) - { - const Point& p1 = p[i]; - const Point& p2 = p[i - 1]; - - if ( edge.isInside( p1 ) ) - { - if ( !edge.isInside( p2 ) ) - clippedPoints += edge.intersection( p1, p2 ); - - clippedPoints += p1; - } - else if ( edge.isInside( p2 ) ) - { - clippedPoints += edge.intersection( p1, p2 ); - } - } + return; } - const Rect m_clipRect; + const Edge edge(m_clipRect.x(), m_clipRect.x() + m_clipRect.width(), + m_clipRect.y(), m_clipRect.y() + m_clipRect.height()); + + if (!closePolygon) + { + const Point &p1 = points.first(); + + if (edge.isInside(p1)) + clippedPoints += p1; + } + else + { + const Point &p1 = points.first(); + const Point &p2 = points.last(); + + if (edge.isInside(p1)) + { + if (!edge.isInside(p2)) + clippedPoints += edge.intersection(p1, p2); + + clippedPoints += p1; + } + else if (edge.isInside(p2)) + { + clippedPoints += edge.intersection(p1, p2); + } + } + + const uint nPoints = points.size(); + const Point *p = points.constData(); + + for (uint i = 1; i < nPoints; i++) + { + const Point &p1 = p[i]; + const Point &p2 = p[i - 1]; + + if (edge.isInside(p1)) + { + if (!edge.isInside(p2)) + clippedPoints += edge.intersection(p1, p2); + + clippedPoints += p1; + } + else if (edge.isInside(p2)) + { + clippedPoints += edge.intersection(p1, p2); + } + } + } + + const Rect m_clipRect; }; class QwtCircleClipper { - public: - explicit QwtCircleClipper( const QRectF& r ); - QVector< QwtInterval > clipCircle( const QPointF&, double radius ) const; +public: + explicit QwtCircleClipper(const QRectF &r); + QVector clipCircle(const QPointF &, double radius) const; - private: - enum Edge - { - Left, - Top, - Right, - Bottom, +private: + enum Edge + { + Left, + Top, + Right, + Bottom, - NEdges - }; + NEdges + }; - QVector< QPointF > cuttingPoints( - Edge, const QPointF& pos, double radius ) const; + QVector cuttingPoints(Edge, const QPointF &pos, double radius) const; - double toAngle( const QPointF&, const QPointF& ) const; + double toAngle(const QPointF &, const QPointF &) const; - const QRectF m_rect; + const QRectF m_rect; }; - -QwtCircleClipper::QwtCircleClipper( const QRectF& r ) - : m_rect( r ) +QwtCircleClipper::QwtCircleClipper(const QRectF &r) + : m_rect(r) { } -QVector< QwtInterval > QwtCircleClipper::clipCircle( - const QPointF& pos, double radius ) const +QVector QwtCircleClipper::clipCircle(const QPointF &pos, + double radius) const { - // using QVarLengthArray TODO ... + // using QVarLengthArray TODO ... - QVector< QPointF > points; - for ( int edge = 0; edge < NEdges; edge++ ) - points += cuttingPoints( static_cast< Edge >( edge ), pos, radius ); + QVector points; + for (int edge = 0; edge < NEdges; edge++) + points += cuttingPoints(static_cast(edge), pos, radius); - QVector< QwtInterval > intv; - if ( points.size() <= 0 ) + QVector intv; + if (points.size() <= 0) + { + QRectF cRect(0, 0, 2 * radius, 2 * radius); + cRect.moveCenter(pos); + if (m_rect.contains(cRect)) + intv += QwtInterval(0.0, 2 * M_PI); + } + else + { + QVector angles; + angles.reserve(points.size()); + + for (int i = 0; i < points.size(); i++) + angles += toAngle(pos, points[i]); + + std::sort(angles.begin(), angles.end()); + + const int in = m_rect.contains( + qwtPolar2Pos(pos, radius, angles[0] + (angles[1] - angles[0]) / 2)); + + intv.reserve(angles.size() / 2); + if (in) { - QRectF cRect( 0, 0, 2 * radius, 2 * radius ); - cRect.moveCenter( pos ); - if ( m_rect.contains( cRect ) ) - intv += QwtInterval( 0.0, 2 * M_PI ); + for (int i = 0; i < angles.size() - 1; i += 2) + intv += QwtInterval(angles[i], angles[i + 1]); } else { - QVector< double > angles; - angles.reserve( points.size() ); + for (int i = 1; i < angles.size() - 1; i += 2) + intv += QwtInterval(angles[i], angles[i + 1]); - for ( int i = 0; i < points.size(); i++ ) - angles += toAngle( pos, points[i] ); - - std::sort( angles.begin(), angles.end() ); - - const int in = m_rect.contains( qwtPolar2Pos( pos, radius, - angles[0] + ( angles[1] - angles[0] ) / 2 ) ); - - intv.reserve( angles.size() / 2 ); - if ( in ) - { - for ( int i = 0; i < angles.size() - 1; i += 2 ) - intv += QwtInterval( angles[i], angles[i + 1] ); - } - else - { - for ( int i = 1; i < angles.size() - 1; i += 2 ) - intv += QwtInterval( angles[i], angles[i + 1] ); - - intv += QwtInterval( angles.last(), angles.first() ); - } + intv += QwtInterval(angles.last(), angles.first()); } + } - return intv; + return intv; } -double QwtCircleClipper::toAngle( - const QPointF& from, const QPointF& to ) const +double QwtCircleClipper::toAngle(const QPointF &from, const QPointF &to) const { - if ( from.x() == to.x() ) - return from.y() <= to.y() ? M_PI / 2.0 : 3 * M_PI / 2.0; + if (from.x() == to.x()) + return from.y() <= to.y() ? M_PI / 2.0 : 3 * M_PI / 2.0; - const double m = qAbs( ( to.y() - from.y() ) / ( to.x() - from.x() ) ); + const double m = qAbs((to.y() - from.y()) / (to.x() - from.x())); - double angle = std::atan( m ); - if ( to.x() > from.x() ) - { - if ( to.y() > from.y() ) - angle = 2 * M_PI - angle; - } + double angle = std::atan(m); + if (to.x() > from.x()) + { + if (to.y() > from.y()) + angle = 2 * M_PI - angle; + } + else + { + if (to.y() > from.y()) + angle = M_PI + angle; else - { - if ( to.y() > from.y() ) - angle = M_PI + angle; - else - angle = M_PI - angle; - } + angle = M_PI - angle; + } - return angle; + return angle; } -QVector< QPointF > QwtCircleClipper::cuttingPoints( - Edge edge, const QPointF& pos, double radius ) const +QVector QwtCircleClipper::cuttingPoints(Edge edge, const QPointF &pos, + double radius) const { - QVector< QPointF > points; + QVector points; - if ( edge == Left || edge == Right ) + if (edge == Left || edge == Right) + { + const double x = (edge == Left) ? m_rect.left() : m_rect.right(); + if (qAbs(pos.x() - x) < radius) { - const double x = ( edge == Left ) ? m_rect.left() : m_rect.right(); - if ( qAbs( pos.x() - x ) < radius ) - { - const double off = std::sqrt( qwtSqr( radius ) - qwtSqr( pos.x() - x ) ); - const double m_y1 = pos.y() + off; - if ( m_y1 >= m_rect.top() && m_y1 <= m_rect.bottom() ) - points += QPointF( x, m_y1 ); + const double off = std::sqrt(qwtSqr(radius) - qwtSqr(pos.x() - x)); + const double m_y1 = pos.y() + off; + if (m_y1 >= m_rect.top() && m_y1 <= m_rect.bottom()) + points += QPointF(x, m_y1); - const double m_y2 = pos.y() - off; - if ( m_y2 >= m_rect.top() && m_y2 <= m_rect.bottom() ) - points += QPointF( x, m_y2 ); - } + const double m_y2 = pos.y() - off; + if (m_y2 >= m_rect.top() && m_y2 <= m_rect.bottom()) + points += QPointF(x, m_y2); } - else + } + else + { + const double y = (edge == Top) ? m_rect.top() : m_rect.bottom(); + if (qAbs(pos.y() - y) < radius) { - const double y = ( edge == Top ) ? m_rect.top() : m_rect.bottom(); - if ( qAbs( pos.y() - y ) < radius ) - { - const double off = std::sqrt( qwtSqr( radius ) - qwtSqr( pos.y() - y ) ); - const double x1 = pos.x() + off; - if ( x1 >= m_rect.left() && x1 <= m_rect.right() ) - points += QPointF( x1, y ); + const double off = std::sqrt(qwtSqr(radius) - qwtSqr(pos.y() - y)); + const double x1 = pos.x() + off; + if (x1 >= m_rect.left() && x1 <= m_rect.right()) + points += QPointF(x1, y); - const double m_x2 = pos.x() - off; - if ( m_x2 >= m_rect.left() && m_x2 <= m_rect.right() ) - points += QPointF( m_x2, y ); - } + const double m_x2 = pos.x() - off; + if (m_x2 >= m_rect.left() && m_x2 <= m_rect.right()) + points += QPointF(m_x2, y); } - return points; + } + return points; } /*! @@ -366,18 +357,18 @@ QVector< QPointF > QwtCircleClipper::cuttingPoints( \param polygon Polygon IN/OUT \param closePolygon True, when the polygon is closed */ -void QwtClipper::clipPolygon( - const QRectF& clipRect, QPolygon& polygon, bool closePolygon ) +void QwtClipper::clipPolygon(const QRectF &clipRect, QPolygon &polygon, + bool closePolygon) { - const int minX = qCeil( clipRect.left() ); - const int maxX = qFloor( clipRect.right() ); - const int minY = qCeil( clipRect.top() ); - const int maxY = qFloor( clipRect.bottom() ); + const int minX = qCeil(clipRect.left()); + const int maxX = qFloor(clipRect.right()); + const int minY = qCeil(clipRect.top()); + const int maxY = qFloor(clipRect.bottom()); - const QRect r( minX, minY, maxX - minX, maxY - minY ); + const QRect r(minX, minY, maxX - minX, maxY - minY); - QwtPolygonClipper< QPolygon, QRect, int > clipper( r ); - clipper.clipPolygon( polygon, closePolygon ); + QwtPolygonClipper clipper(r); + clipper.clipPolygon(polygon, closePolygon); } /*! @@ -387,11 +378,11 @@ void QwtClipper::clipPolygon( \param polygon Polygon IN/OUT \param closePolygon True, when the polygon is closed */ -void QwtClipper::clipPolygon( - const QRect& clipRect, QPolygon& polygon, bool closePolygon ) +void QwtClipper::clipPolygon(const QRect &clipRect, QPolygon &polygon, + bool closePolygon) { - QwtPolygonClipper< QPolygon, QRect, int > clipper( clipRect ); - clipper.clipPolygon( polygon, closePolygon ); + QwtPolygonClipper clipper(clipRect); + clipper.clipPolygon(polygon, closePolygon); } /*! @@ -401,11 +392,11 @@ void QwtClipper::clipPolygon( \param polygon Polygon IN/OUT \param closePolygon True, when the polygon is closed */ -void QwtClipper::clipPolygonF( - const QRectF& clipRect, QPolygonF& polygon, bool closePolygon ) +void QwtClipper::clipPolygonF(const QRectF &clipRect, QPolygonF &polygon, + bool closePolygon) { - QwtPolygonClipper< QPolygonF, QRectF, double > clipper( clipRect ); - clipper.clipPolygon( polygon, closePolygon ); + QwtPolygonClipper clipper(clipRect); + clipper.clipPolygon(polygon, closePolygon); } /*! @@ -417,13 +408,13 @@ void QwtClipper::clipPolygonF( \return Clipped polygon */ -QPolygon QwtClipper::clippedPolygon( - const QRectF& clipRect, const QPolygon& polygon, bool closePolygon ) +QPolygon QwtClipper::clippedPolygon(const QRectF &clipRect, + const QPolygon &polygon, bool closePolygon) { - QPolygon points( polygon ); - clipPolygon( clipRect, points, closePolygon ); + QPolygon points(polygon); + clipPolygon(clipRect, points, closePolygon); - return points; + return points; } /*! Sutherland-Hodgman polygon clipping @@ -434,13 +425,13 @@ QPolygon QwtClipper::clippedPolygon( \return Clipped polygon */ -QPolygon QwtClipper::clippedPolygon( - const QRect& clipRect, const QPolygon& polygon, bool closePolygon ) +QPolygon QwtClipper::clippedPolygon(const QRect &clipRect, + const QPolygon &polygon, bool closePolygon) { - QPolygon points( polygon ); - clipPolygon( clipRect, points, closePolygon ); + QPolygon points(polygon); + clipPolygon(clipRect, points, closePolygon); - return points; + return points; } /*! @@ -452,13 +443,14 @@ QPolygon QwtClipper::clippedPolygon( \return Clipped polygon */ -QPolygonF QwtClipper::clippedPolygonF( - const QRectF& clipRect, const QPolygonF& polygon, bool closePolygon ) +QPolygonF QwtClipper::clippedPolygonF(const QRectF &clipRect, + const QPolygonF &polygon, + bool closePolygon) { - QPolygonF points( polygon ); - clipPolygonF( clipRect, points, closePolygon ); + QPolygonF points(polygon); + clipPolygonF(clipRect, points, closePolygon); - return points; + return points; } /*! @@ -474,9 +466,10 @@ QPolygonF QwtClipper::clippedPolygonF( \return Arcs of the circle */ -QVector< QwtInterval > QwtClipper::clipCircle( const QRectF& clipRect, - const QPointF& center, double radius ) +QVector QwtClipper::clipCircle(const QRectF &clipRect, + const QPointF ¢er, + double radius) { - QwtCircleClipper clipper( clipRect ); - return clipper.clipCircle( center, radius ); + QwtCircleClipper clipper(clipRect); + return clipper.clipCircle(center, radius); } diff --git a/libs/qwt/src/qwt_clipper.h b/libs/qwt/src/qwt_clipper.h index 346d616e..eea30c6f 100644 --- a/libs/qwt/src/qwt_clipper.h +++ b/libs/qwt/src/qwt_clipper.h @@ -20,7 +20,8 @@ class QPolygon; class QPolygonF; #if QT_VERSION < 0x060000 -template< typename T > class QVector; +template +class QVector; #endif /*! @@ -29,26 +30,26 @@ template< typename T > class QVector; namespace QwtClipper { - QWT_EXPORT void clipPolygon( const QRect&, - QPolygon&, bool closePolygon = false ); +QWT_EXPORT void clipPolygon(const QRect &, QPolygon &, + bool closePolygon = false); - QWT_EXPORT void clipPolygon( const QRectF&, - QPolygon&, bool closePolygon = false ); +QWT_EXPORT void clipPolygon(const QRectF &, QPolygon &, + bool closePolygon = false); - QWT_EXPORT void clipPolygonF( const QRectF&, - QPolygonF&, bool closePolygon = false ); +QWT_EXPORT void clipPolygonF(const QRectF &, QPolygonF &, + bool closePolygon = false); - QWT_EXPORT QPolygon clippedPolygon( const QRect&, - const QPolygon&, bool closePolygon = false ); +QWT_EXPORT QPolygon clippedPolygon(const QRect &, const QPolygon &, + bool closePolygon = false); - QWT_EXPORT QPolygon clippedPolygon( const QRectF&, - const QPolygon&, bool closePolygon = false ); +QWT_EXPORT QPolygon clippedPolygon(const QRectF &, const QPolygon &, + bool closePolygon = false); - QWT_EXPORT QPolygonF clippedPolygonF( const QRectF&, - const QPolygonF&, bool closePolygon = false ); +QWT_EXPORT QPolygonF clippedPolygonF(const QRectF &, const QPolygonF &, + bool closePolygon = false); - QWT_EXPORT QVector< QwtInterval > clipCircle( - const QRectF&, const QPointF&, double radius ); -}; +QWT_EXPORT QVector clipCircle(const QRectF &, const QPointF &, + double radius); +}; // namespace QwtClipper #endif diff --git a/libs/qwt/src/qwt_color_map.cpp b/libs/qwt/src/qwt_color_map.cpp index e797d1d3..4c50a8b5 100644 --- a/libs/qwt/src/qwt_color_map.cpp +++ b/libs/qwt/src/qwt_color_map.cpp @@ -12,258 +12,246 @@ #include -static inline QRgb qwtHsvToRgb( int h, int s, int v, int a ) +static inline QRgb qwtHsvToRgb(int h, int s, int v, int a) { #if 0 return QColor::fromHsv( h, s, v, a ).rgb(); #else - const double vs = v * s / 255.0; - const int p = v - qRound( vs ); + const double vs = v * s / 255.0; + const int p = v - qRound(vs); - switch( h / 60 ) - { - case 0: - { - const double r = ( 60 - h ) / 60.0; - return qRgba( v, v - qRound( r * vs ), p, a ); - } - case 1: - { - const double r = ( h - 60 ) / 60.0; - return qRgba( v - qRound( r * vs ), v, p, a ); - } - case 2: - { - const double r = ( 180 - h ) / 60.0; - return qRgba( p, v, v - qRound( r * vs ), a ); - } - case 3: - { - const double r = ( h - 180 ) / 60.0; - return qRgba( p, v - qRound( r * vs ), v, a ); - } - case 4: - { - const double r = ( 300 - h ) / 60.0; - return qRgba( v - qRound( r * vs ), p, v, a ); - } - case 5: - default: - { - const double r = ( h - 300 ) / 60.0; - return qRgba( v, p, v - qRound( r * vs ), a ); - } + switch (h / 60) + { + case 0: { + const double r = (60 - h) / 60.0; + return qRgba(v, v - qRound(r * vs), p, a); } + case 1: { + const double r = (h - 60) / 60.0; + return qRgba(v - qRound(r * vs), v, p, a); + } + case 2: { + const double r = (180 - h) / 60.0; + return qRgba(p, v, v - qRound(r * vs), a); + } + case 3: { + const double r = (h - 180) / 60.0; + return qRgba(p, v - qRound(r * vs), v, a); + } + case 4: { + const double r = (300 - h) / 60.0; + return qRgba(v - qRound(r * vs), p, v, a); + } + case 5: + default: { + const double r = (h - 300) / 60.0; + return qRgba(v, p, v - qRound(r * vs), a); + } + } #endif } class QwtLinearColorMap::ColorStops { +public: + ColorStops() + : m_doAlpha(false) + { + m_stops.reserve(256); + } + + void insert(double pos, const QColor &color); + QRgb rgb(QwtLinearColorMap::Mode, double pos) const; + + QVector stops() const; + +private: + class ColorStop + { public: - ColorStops(): - m_doAlpha( false ) + ColorStop() + : pos(0.0) + , rgb(0) {}; + + ColorStop(double p, const QColor &c) + : pos(p) + , rgb(c.rgba()) { - m_stops.reserve( 256 ); + r = qRed(rgb); + g = qGreen(rgb); + b = qBlue(rgb); + a = qAlpha(rgb); + + /* + when mapping a value to rgb we will have to calculate: + - const int v = int( ( s1.v0 + ratio * s1.vStep ) + 0.5 ); + + Thus adding 0.5 ( for rounding ) can be done in advance + */ + r0 = r + 0.5; + g0 = g + 0.5; + b0 = b + 0.5; + a0 = a + 0.5; + + rStep = gStep = bStep = aStep = 0.0; + posStep = 0.0; } - void insert( double pos, const QColor& color ); - QRgb rgb( QwtLinearColorMap::Mode, double pos ) const; - - QVector< double > stops() const; - - private: - - class ColorStop + void updateSteps(const ColorStop &nextStop) { - public: - ColorStop(): - pos( 0.0 ), - rgb( 0 ) - { - }; + rStep = nextStop.r - r; + gStep = nextStop.g - g; + bStep = nextStop.b - b; + aStep = nextStop.a - a; + posStep = nextStop.pos - pos; + } - ColorStop( double p, const QColor& c ): - pos( p ), - rgb( c.rgba() ) - { - r = qRed( rgb ); - g = qGreen( rgb ); - b = qBlue( rgb ); - a = qAlpha( rgb ); + double pos; + QRgb rgb; + int r, g, b, a; - /* - when mapping a value to rgb we will have to calculate: - - const int v = int( ( s1.v0 + ratio * s1.vStep ) + 0.5 ); + // precalculated values + double rStep, gStep, bStep, aStep; + double r0, g0, b0, a0; + double posStep; + }; - Thus adding 0.5 ( for rounding ) can be done in advance - */ - r0 = r + 0.5; - g0 = g + 0.5; - b0 = b + 0.5; - a0 = a + 0.5; - - rStep = gStep = bStep = aStep = 0.0; - posStep = 0.0; - } - - void updateSteps( const ColorStop& nextStop ) - { - rStep = nextStop.r - r; - gStep = nextStop.g - g; - bStep = nextStop.b - b; - aStep = nextStop.a - a; - posStep = nextStop.pos - pos; - } - - double pos; - QRgb rgb; - int r, g, b, a; - - // precalculated values - double rStep, gStep, bStep, aStep; - double r0, g0, b0, a0; - double posStep; - }; - - inline int findUpper( double pos ) const; - QVector< ColorStop > m_stops; - bool m_doAlpha; + inline int findUpper(double pos) const; + QVector m_stops; + bool m_doAlpha; }; -void QwtLinearColorMap::ColorStops::insert( double pos, const QColor& color ) +void QwtLinearColorMap::ColorStops::insert(double pos, const QColor &color) { - // Lookups need to be very fast, insertions are not so important. - // Anyway, a balanced tree is what we need here. TODO ... + // Lookups need to be very fast, insertions are not so important. + // Anyway, a balanced tree is what we need here. TODO ... - if ( pos < 0.0 || pos > 1.0 ) - return; + if (pos < 0.0 || pos > 1.0) + return; - int index; - if ( m_stops.size() == 0 ) + int index; + if (m_stops.size() == 0) + { + index = 0; + m_stops.resize(1); + } + else + { + index = findUpper(pos); + if (index == m_stops.size() || qAbs(m_stops[index].pos - pos) >= 0.001) { - index = 0; - m_stops.resize( 1 ); + m_stops.resize(m_stops.size() + 1); + for (int i = m_stops.size() - 1; i > index; i--) + m_stops[i] = m_stops[i - 1]; + } + } + + m_stops[index] = ColorStop(pos, color); + if (color.alpha() != 255) + m_doAlpha = true; + + if (index > 0) + m_stops[index - 1].updateSteps(m_stops[index]); + + if (index < m_stops.size() - 1) + m_stops[index].updateSteps(m_stops[index + 1]); +} + +inline QVector QwtLinearColorMap::ColorStops::stops() const +{ + QVector positions(m_stops.size()); + for (int i = 0; i < m_stops.size(); i++) + positions[i] = m_stops[i].pos; + return positions; +} + +inline int QwtLinearColorMap::ColorStops::findUpper(double pos) const +{ + int index = 0; + int n = m_stops.size(); + + const ColorStop *stops = m_stops.data(); + + while (n > 0) + { + const int half = n >> 1; + const int middle = index + half; + + if (stops[middle].pos <= pos) + { + index = middle + 1; + n -= half + 1; + } + else + n = half; + } + + return index; +} + +inline QRgb QwtLinearColorMap::ColorStops::rgb(QwtLinearColorMap::Mode mode, + double pos) const +{ + if (pos <= 0.0) + return m_stops[0].rgb; + if (pos >= 1.0) + return m_stops[m_stops.size() - 1].rgb; + + const int index = findUpper(pos); + if (mode == FixedColors) + { + return m_stops[index - 1].rgb; + } + else + { + const ColorStop &s1 = m_stops[index - 1]; + + const double ratio = (pos - s1.pos) / (s1.posStep); + + const int r = int(s1.r0 + ratio * s1.rStep); + const int g = int(s1.g0 + ratio * s1.gStep); + const int b = int(s1.b0 + ratio * s1.bStep); + + if (m_doAlpha) + { + if (s1.aStep) + { + const int a = int(s1.a0 + ratio * s1.aStep); + return qRgba(r, g, b, a); + } + else + { + return qRgba(r, g, b, s1.a); + } } else { - index = findUpper( pos ); - if ( index == m_stops.size() || - qAbs( m_stops[index].pos - pos ) >= 0.001 ) - { - m_stops.resize( m_stops.size() + 1 ); - for ( int i = m_stops.size() - 1; i > index; i-- ) - m_stops[i] = m_stops[i - 1]; - } - } - - m_stops[index] = ColorStop( pos, color ); - if ( color.alpha() != 255 ) - m_doAlpha = true; - - if ( index > 0 ) - m_stops[index - 1].updateSteps( m_stops[index] ); - - if ( index < m_stops.size() - 1 ) - m_stops[index].updateSteps( m_stops[index + 1] ); -} - -inline QVector< double > QwtLinearColorMap::ColorStops::stops() const -{ - QVector< double > positions( m_stops.size() ); - for ( int i = 0; i < m_stops.size(); i++ ) - positions[i] = m_stops[i].pos; - return positions; -} - -inline int QwtLinearColorMap::ColorStops::findUpper( double pos ) const -{ - int index = 0; - int n = m_stops.size(); - - const ColorStop* stops = m_stops.data(); - - while ( n > 0 ) - { - const int half = n >> 1; - const int middle = index + half; - - if ( stops[middle].pos <= pos ) - { - index = middle + 1; - n -= half + 1; - } - else - n = half; - } - - return index; -} - -inline QRgb QwtLinearColorMap::ColorStops::rgb( - QwtLinearColorMap::Mode mode, double pos ) const -{ - if ( pos <= 0.0 ) - return m_stops[0].rgb; - if ( pos >= 1.0 ) - return m_stops[ m_stops.size() - 1 ].rgb; - - const int index = findUpper( pos ); - if ( mode == FixedColors ) - { - return m_stops[index - 1].rgb; - } - else - { - const ColorStop& s1 = m_stops[index - 1]; - - const double ratio = ( pos - s1.pos ) / ( s1.posStep ); - - const int r = int( s1.r0 + ratio * s1.rStep ); - const int g = int( s1.g0 + ratio * s1.gStep ); - const int b = int( s1.b0 + ratio * s1.bStep ); - - if ( m_doAlpha ) - { - if ( s1.aStep ) - { - const int a = int( s1.a0 + ratio * s1.aStep ); - return qRgba( r, g, b, a ); - } - else - { - return qRgba( r, g, b, s1.a ); - } - } - else - { - return qRgb( r, g, b ); - } + return qRgb(r, g, b); } + } } /*! Constructor \param format Format of the color map */ -QwtColorMap::QwtColorMap( Format format ) - : m_format( format ) +QwtColorMap::QwtColorMap(Format format) + : m_format(format) { } //! Destructor -QwtColorMap::~QwtColorMap() -{ -} +QwtColorMap::~QwtColorMap() {} /*! Set the format of the color map \param format Format of the color map */ -void QwtColorMap::setFormat( Format format ) +void QwtColorMap::setFormat(Format format) { - m_format = format; + m_format = format; } /*! @@ -275,22 +263,22 @@ void QwtColorMap::setFormat( Format format ) \return Index, between 0 and numColors - 1, or -1 for an invalid value */ -uint QwtColorMap::colorIndex( int numColors, - const QwtInterval& interval, double value ) const +uint QwtColorMap::colorIndex(int numColors, const QwtInterval &interval, + double value) const { - const double width = interval.width(); - if ( width <= 0.0 ) - return 0; + const double width = interval.width(); + if (width <= 0.0) + return 0; - if ( value <= interval.minValue() ) - return 0; + if (value <= interval.minValue()) + return 0; - const int maxIndex = numColors - 1; - if ( value >= interval.maxValue() ) - return maxIndex; + const int maxIndex = numColors - 1; + if (value >= interval.maxValue()) + return maxIndex; - const double v = maxIndex * ( ( value - interval.minValue() ) / width ); - return static_cast< unsigned int >( v + 0.5 ); + const double v = maxIndex * ((value - interval.minValue()) / width); + return static_cast(v + 0.5); } /*! @@ -301,16 +289,16 @@ uint QwtColorMap::colorIndex( int numColors, \return A color table, that can be used for a QImage */ -QVector< QRgb > QwtColorMap::colorTable256() const +QVector QwtColorMap::colorTable256() const { - QVector< QRgb > table( 256 ); + QVector table(256); - const QwtInterval interval( 0, 256 ); + const QwtInterval interval(0, 256); - for ( int i = 0; i < 256; i++ ) - table[i] = rgb( interval, i ); + for (int i = 0; i < 256; i++) + table[i] = rgb(interval, i); - return table; + return table; } /*! @@ -322,24 +310,24 @@ QVector< QRgb > QwtColorMap::colorTable256() const \param numColors Number of colors \return A color table */ -QVector< QRgb > QwtColorMap::colorTable( int numColors ) const +QVector QwtColorMap::colorTable(int numColors) const { - QVector< QRgb > table( numColors ); + QVector table(numColors); - const QwtInterval interval( 0.0, 1.0 ); + const QwtInterval interval(0.0, 1.0); - const double step = 1.0 / ( numColors - 1 ); - for ( int i = 0; i < numColors; i++ ) - table[i] = rgb( interval, step * i ); + const double step = 1.0 / (numColors - 1); + for (int i = 0; i < numColors; i++) + table[i] = rgb(interval, step * i); - return table; + return table; } class QwtLinearColorMap::PrivateData { - public: - ColorStops colorStops; - QwtLinearColorMap::Mode mode; +public: + ColorStops colorStops; + QwtLinearColorMap::Mode mode; }; /*! @@ -348,13 +336,13 @@ class QwtLinearColorMap::PrivateData \param format Preferred format of the color map */ -QwtLinearColorMap::QwtLinearColorMap( QwtColorMap::Format format ): - QwtColorMap( format ) +QwtLinearColorMap::QwtLinearColorMap(QwtColorMap::Format format) + : QwtColorMap(format) { - m_data = new PrivateData; - m_data->mode = ScaledColors; + m_data = new PrivateData; + m_data->mode = ScaledColors; - setColorInterval( Qt::blue, Qt::yellow ); + setColorInterval(Qt::blue, Qt::yellow); } /*! @@ -364,19 +352,19 @@ QwtLinearColorMap::QwtLinearColorMap( QwtColorMap::Format format ): \param color2 Color used for the maximum value of the value interval \param format Preferred format for the color map */ -QwtLinearColorMap::QwtLinearColorMap( const QColor& color1, - const QColor& color2, QwtColorMap::Format format ) - : QwtColorMap( format ) +QwtLinearColorMap::QwtLinearColorMap(const QColor &color1, const QColor &color2, + QwtColorMap::Format format) + : QwtColorMap(format) { - m_data = new PrivateData; - m_data->mode = ScaledColors; - setColorInterval( color1, color2 ); + m_data = new PrivateData; + m_data->mode = ScaledColors; + setColorInterval(color1, color2); } //! Destructor QwtLinearColorMap::~QwtLinearColorMap() { - delete m_data; + delete m_data; } /*! @@ -388,9 +376,9 @@ QwtLinearColorMap::~QwtLinearColorMap() \sa mode() */ -void QwtLinearColorMap::setMode( Mode mode ) +void QwtLinearColorMap::setMode(Mode mode) { - m_data->mode = mode; + m_data->mode = mode; } /*! @@ -399,7 +387,7 @@ void QwtLinearColorMap::setMode( Mode mode ) */ QwtLinearColorMap::Mode QwtLinearColorMap::mode() const { - return m_data->mode; + return m_data->mode; } /*! @@ -412,12 +400,12 @@ QwtLinearColorMap::Mode QwtLinearColorMap::mode() const \sa color1(), color2() */ -void QwtLinearColorMap::setColorInterval( - const QColor& color1, const QColor& color2 ) +void QwtLinearColorMap::setColorInterval(const QColor &color1, + const QColor &color2) { - m_data->colorStops = ColorStops(); - m_data->colorStops.insert( 0.0, color1 ); - m_data->colorStops.insert( 1.0, color2 ); + m_data->colorStops = ColorStops(); + m_data->colorStops.insert(0.0, color1); + m_data->colorStops.insert(1.0, color2); } /*! @@ -430,18 +418,18 @@ void QwtLinearColorMap::setColorInterval( \param value Value between [0.0, 1.0] \param color Color stop */ -void QwtLinearColorMap::addColorStop( double value, const QColor& color ) +void QwtLinearColorMap::addColorStop(double value, const QColor &color) { - if ( value >= 0.0 && value <= 1.0 ) - m_data->colorStops.insert( value, color ); + if (value >= 0.0 && value <= 1.0) + m_data->colorStops.insert(value, color); } /*! \return Positions of color stops in increasing order */ -QVector< double > QwtLinearColorMap::colorStops() const +QVector QwtLinearColorMap::colorStops() const { - return m_data->colorStops.stops(); + return m_data->colorStops.stops(); } /*! @@ -450,7 +438,7 @@ QVector< double > QwtLinearColorMap::colorStops() const */ QColor QwtLinearColorMap::color1() const { - return QColor::fromRgba( m_data->colorStops.rgb( m_data->mode, 0.0 ) ); + return QColor::fromRgba(m_data->colorStops.rgb(m_data->mode, 0.0)); } /*! @@ -459,7 +447,7 @@ QColor QwtLinearColorMap::color1() const */ QColor QwtLinearColorMap::color2() const { - return QColor::fromRgba( m_data->colorStops.rgb( m_data->mode, 1.0 ) ); + return QColor::fromRgba(m_data->colorStops.rgb(m_data->mode, 1.0)); } /*! @@ -470,15 +458,14 @@ QColor QwtLinearColorMap::color2() const \return RGB value for value */ -QRgb QwtLinearColorMap::rgb( - const QwtInterval& interval, double value ) const +QRgb QwtLinearColorMap::rgb(const QwtInterval &interval, double value) const { - const double width = interval.width(); - if ( width <= 0.0 ) - return 0u; + const double width = interval.width(); + if (width <= 0.0) + return 0u; - const double ratio = ( value - interval.minValue() ) / width; - return m_data->colorStops.rgb( m_data->mode, ratio ); + const double ratio = (value - interval.minValue()) / width; + return m_data->colorStops.rgb(m_data->mode, ratio); } /*! @@ -491,42 +478,41 @@ QRgb QwtLinearColorMap::rgb( \return Index, between 0 and 255 \note NaN values are mapped to 0 */ -uint QwtLinearColorMap::colorIndex( int numColors, - const QwtInterval& interval, double value ) const +uint QwtLinearColorMap::colorIndex(int numColors, const QwtInterval &interval, + double value) const { - const double width = interval.width(); - if ( width <= 0.0 ) - return 0; + const double width = interval.width(); + if (width <= 0.0) + return 0; - if ( value <= interval.minValue() ) - return 0; + if (value <= interval.minValue()) + return 0; - if ( value >= interval.maxValue() ) - return numColors - 1; + if (value >= interval.maxValue()) + return numColors - 1; - const double v = ( numColors - 1 ) * ( value - interval.minValue() ) / width; - return static_cast< unsigned int >( ( m_data->mode == FixedColors ) ? v : v + 0.5 ); + const double v = (numColors - 1) * (value - interval.minValue()) / width; + return static_cast((m_data->mode == FixedColors) ? v : v + 0.5); } class QwtAlphaColorMap::PrivateData { - public: - PrivateData() - : alpha1(0) - , alpha2(255) - { - } +public: + PrivateData() + : alpha1(0) + , alpha2(255) + { + } - int alpha1, alpha2; + int alpha1, alpha2; - QColor color; - QRgb rgb; + QColor color; + QRgb rgb; - QRgb rgbMin; - QRgb rgbMax; + QRgb rgbMin; + QRgb rgbMax; }; - /*! \brief Constructor @@ -536,17 +522,17 @@ class QwtAlphaColorMap::PrivateData \sa setColor(), setAlphaInterval() */ -QwtAlphaColorMap::QwtAlphaColorMap( const QColor& color ) - : QwtColorMap( QwtColorMap::RGB ) +QwtAlphaColorMap::QwtAlphaColorMap(const QColor &color) + : QwtColorMap(QwtColorMap::RGB) { - m_data = new PrivateData; - setColor( color ); + m_data = new PrivateData; + setColor(color); } //! Destructor QwtAlphaColorMap::~QwtAlphaColorMap() { - delete m_data; + delete m_data; } /*! @@ -555,13 +541,13 @@ QwtAlphaColorMap::~QwtAlphaColorMap() \param color Color \sa color() */ -void QwtAlphaColorMap::setColor( const QColor& color ) +void QwtAlphaColorMap::setColor(const QColor &color) { - m_data->color = color; - m_data->rgb = color.rgb() & qRgba( 255, 255, 255, 0 ); + m_data->color = color; + m_data->rgb = color.rgb() & qRgba(255, 255, 255, 0); - m_data->rgbMin = m_data->rgb | ( m_data->alpha1 << 24 ); - m_data->rgbMax = m_data->rgb | ( m_data->alpha2 << 24 ); + m_data->rgbMin = m_data->rgb | (m_data->alpha1 << 24); + m_data->rgbMax = m_data->rgb | (m_data->alpha2 << 24); } /*! @@ -570,7 +556,7 @@ void QwtAlphaColorMap::setColor( const QColor& color ) */ QColor QwtAlphaColorMap::color() const { - return m_data->color; + return m_data->color; } /*! @@ -584,13 +570,13 @@ QColor QwtAlphaColorMap::color() const \sa alpha1(), alpha2() */ -void QwtAlphaColorMap::setAlphaInterval( int alpha1, int alpha2 ) +void QwtAlphaColorMap::setAlphaInterval(int alpha1, int alpha2) { - m_data->alpha1 = qBound( 0, alpha1, 255 ); - m_data->alpha2 = qBound( 0, alpha2, 255 ); + m_data->alpha1 = qBound(0, alpha1, 255); + m_data->alpha2 = qBound(0, alpha2, 255); - m_data->rgbMin = m_data->rgb | ( alpha1 << 24 ); - m_data->rgbMax = m_data->rgb | ( alpha2 << 24 ); + m_data->rgbMin = m_data->rgb | (alpha1 << 24); + m_data->rgbMax = m_data->rgb | (alpha2 << 24); } /*! @@ -599,7 +585,7 @@ void QwtAlphaColorMap::setAlphaInterval( int alpha1, int alpha2 ) */ int QwtAlphaColorMap::alpha1() const { - return m_data->alpha1; + return m_data->alpha1; } /*! @@ -608,7 +594,7 @@ int QwtAlphaColorMap::alpha1() const */ int QwtAlphaColorMap::alpha2() const { - return m_data->alpha2; + return m_data->alpha2; } /*! @@ -619,95 +605,96 @@ int QwtAlphaColorMap::alpha2() const \return RGB value, with an alpha value */ -QRgb QwtAlphaColorMap::rgb( const QwtInterval& interval, double value ) const +QRgb QwtAlphaColorMap::rgb(const QwtInterval &interval, double value) const { - const double width = interval.width(); - if ( width <= 0.0 ) - return 0u; + const double width = interval.width(); + if (width <= 0.0) + return 0u; - if ( value <= interval.minValue() ) - return m_data->rgb; + if (value <= interval.minValue()) + return m_data->rgb; - if ( value >= interval.maxValue() ) - return m_data->rgbMax; + if (value >= interval.maxValue()) + return m_data->rgbMax; - const double ratio = ( value - interval.minValue() ) / width; - const int alpha = m_data->alpha1 + qRound( ratio * ( m_data->alpha2 - m_data->alpha1 ) ); + const double ratio = (value - interval.minValue()) / width; + const int alpha + = m_data->alpha1 + qRound(ratio * (m_data->alpha2 - m_data->alpha1)); - return m_data->rgb | ( alpha << 24 ); + return m_data->rgb | (alpha << 24); } class QwtHueColorMap::PrivateData { - public: - PrivateData(); +public: + PrivateData(); - void updateTable(); + void updateTable(); - int hue1, hue2; - int saturation; - int value; - int alpha; + int hue1, hue2; + int saturation; + int value; + int alpha; - QRgb rgbMin; - QRgb rgbMax; + QRgb rgbMin; + QRgb rgbMax; - QRgb rgbTable[360]; + QRgb rgbTable[360]; }; QwtHueColorMap::PrivateData::PrivateData() - : hue1(0) - , hue2(359) - , saturation(255) - , value(255) - , alpha(255) + : hue1(0) + , hue2(359) + , saturation(255) + , value(255) + , alpha(255) { - updateTable(); + updateTable(); } void QwtHueColorMap::PrivateData::updateTable() { - const int p = qRound( value * ( 255 - saturation ) / 255.0 ); - const double vs = value * saturation / 255.0; + const int p = qRound(value * (255 - saturation) / 255.0); + const double vs = value * saturation / 255.0; - for ( int i = 0; i < 60; i++ ) - { - const double r = ( 60 - i ) / 60.0; - rgbTable[i] = qRgba( value, qRound( value - r * vs ), p, alpha ); - } + for (int i = 0; i < 60; i++) + { + const double r = (60 - i) / 60.0; + rgbTable[i] = qRgba(value, qRound(value - r * vs), p, alpha); + } - for ( int i = 60; i < 120; i++ ) - { - const double r = ( i - 60 ) / 60.0; - rgbTable[i] = qRgba( qRound( value - r * vs ), value, p, alpha ); - } + for (int i = 60; i < 120; i++) + { + const double r = (i - 60) / 60.0; + rgbTable[i] = qRgba(qRound(value - r * vs), value, p, alpha); + } - for ( int i = 120; i < 180; i++ ) - { - const double r = ( 180 - i ) / 60.0; - rgbTable[i] = qRgba( p, value, qRound( value - r * vs ), alpha ); - } + for (int i = 120; i < 180; i++) + { + const double r = (180 - i) / 60.0; + rgbTable[i] = qRgba(p, value, qRound(value - r * vs), alpha); + } - for ( int i = 180; i < 240; i++ ) - { - const double r = ( i - 180 ) / 60.0; - rgbTable[i] = qRgba( p, qRound( value - r * vs ), value, alpha ); - } + for (int i = 180; i < 240; i++) + { + const double r = (i - 180) / 60.0; + rgbTable[i] = qRgba(p, qRound(value - r * vs), value, alpha); + } - for ( int i = 240; i < 300; i++ ) - { - const double r = ( 300 - i ) / 60.0; - rgbTable[i] = qRgba( qRound( value - r * vs ), p, value, alpha ); - } + for (int i = 240; i < 300; i++) + { + const double r = (300 - i) / 60.0; + rgbTable[i] = qRgba(qRound(value - r * vs), p, value, alpha); + } - for ( int i = 300; i < 360; i++ ) - { - const double r = ( i - 300 ) / 60.0; - rgbTable[i] = qRgba( value, p, qRound( value - r * vs ), alpha ); - } + for (int i = 300; i < 360; i++) + { + const double r = (i - 300) / 60.0; + rgbTable[i] = qRgba(value, p, qRound(value - r * vs), alpha); + } - rgbMin = rgbTable[ hue1 % 360 ]; - rgbMax = rgbTable[ hue2 % 360 ]; + rgbMin = rgbTable[hue1 % 360]; + rgbMax = rgbTable[hue2 % 360]; } /*! @@ -720,16 +707,16 @@ void QwtHueColorMap::PrivateData::updateTable() \sa setHueInterval(), setSaturation(), setValue(), setValue() */ -QwtHueColorMap::QwtHueColorMap( QwtColorMap::Format format ) - : QwtColorMap( format ) +QwtHueColorMap::QwtHueColorMap(QwtColorMap::Format format) + : QwtColorMap(format) { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtHueColorMap::~QwtHueColorMap() { - delete m_data; + delete m_data; } /*! @@ -743,13 +730,13 @@ QwtHueColorMap::~QwtHueColorMap() \sa hue1(), hue2() */ -void QwtHueColorMap::setHueInterval( int hue1, int hue2 ) +void QwtHueColorMap::setHueInterval(int hue1, int hue2) { - m_data->hue1 = qMax( hue1, 0 ); - m_data->hue2 = qMax( hue2, 0 ); + m_data->hue1 = qMax(hue1, 0); + m_data->hue2 = qMax(hue2, 0); - m_data->rgbMin = m_data->rgbTable[ hue1 % 360 ]; - m_data->rgbMax = m_data->rgbTable[ hue2 % 360 ]; + m_data->rgbMin = m_data->rgbTable[hue1 % 360]; + m_data->rgbMax = m_data->rgbTable[hue2 % 360]; } /*! @@ -761,15 +748,15 @@ void QwtHueColorMap::setHueInterval( int hue1, int hue2 ) \sa saturation() */ -void QwtHueColorMap::setSaturation( int saturation ) +void QwtHueColorMap::setSaturation(int saturation) { - saturation = qBound( 0, saturation, 255 ); + saturation = qBound(0, saturation, 255); - if ( saturation != m_data->saturation ) - { - m_data->saturation = saturation; - m_data->updateTable(); - } + if (saturation != m_data->saturation) + { + m_data->saturation = saturation; + m_data->updateTable(); + } } /*! @@ -781,15 +768,15 @@ void QwtHueColorMap::setSaturation( int saturation ) \sa value() */ -void QwtHueColorMap::setValue( int value ) +void QwtHueColorMap::setValue(int value) { - value = qBound( 0, value, 255 ); + value = qBound(0, value, 255); - if ( value != m_data->value ) - { - m_data->value = value; - m_data->updateTable(); - } + if (value != m_data->value) + { + m_data->value = value; + m_data->updateTable(); + } } /*! @@ -802,15 +789,15 @@ void QwtHueColorMap::setValue( int value ) \sa alpha() */ -void QwtHueColorMap::setAlpha( int alpha ) +void QwtHueColorMap::setAlpha(int alpha) { - alpha = qBound( 0, alpha, 255 ); + alpha = qBound(0, alpha, 255); - if ( alpha != m_data->alpha ) - { - m_data->alpha = alpha; - m_data->updateTable(); - } + if (alpha != m_data->alpha) + { + m_data->alpha = alpha; + m_data->updateTable(); + } } /*! @@ -819,7 +806,7 @@ void QwtHueColorMap::setAlpha( int alpha ) */ int QwtHueColorMap::hue1() const { - return m_data->hue1; + return m_data->hue1; } /*! @@ -828,7 +815,7 @@ int QwtHueColorMap::hue1() const */ int QwtHueColorMap::hue2() const { - return m_data->hue2; + return m_data->hue2; } /*! @@ -837,7 +824,7 @@ int QwtHueColorMap::hue2() const */ int QwtHueColorMap::saturation() const { - return m_data->saturation; + return m_data->saturation; } /*! @@ -846,7 +833,7 @@ int QwtHueColorMap::saturation() const */ int QwtHueColorMap::value() const { - return m_data->value; + return m_data->value; } /*! @@ -855,7 +842,7 @@ int QwtHueColorMap::value() const */ int QwtHueColorMap::alpha() const { - return m_data->alpha; + return m_data->alpha; } /*! @@ -866,97 +853,97 @@ int QwtHueColorMap::alpha() const \return RGB value for value */ -QRgb QwtHueColorMap::rgb( const QwtInterval& interval, double value ) const +QRgb QwtHueColorMap::rgb(const QwtInterval &interval, double value) const { - const double width = interval.width(); - if ( width <= 0 ) - return 0u; + const double width = interval.width(); + if (width <= 0) + return 0u; - if ( value <= interval.minValue() ) - return m_data->rgbMin; + if (value <= interval.minValue()) + return m_data->rgbMin; - if ( value >= interval.maxValue() ) - return m_data->rgbMax; + if (value >= interval.maxValue()) + return m_data->rgbMax; - const double ratio = ( value - interval.minValue() ) / width; + const double ratio = (value - interval.minValue()) / width; - int hue = m_data->hue1 + qRound( ratio * ( m_data->hue2 - m_data->hue1 ) ); - if ( hue >= 360 ) - { - hue -= 360; + int hue = m_data->hue1 + qRound(ratio * (m_data->hue2 - m_data->hue1)); + if (hue >= 360) + { + hue -= 360; - if ( hue >= 360 ) - hue = hue % 360; - } + if (hue >= 360) + hue = hue % 360; + } - return m_data->rgbTable[hue]; + return m_data->rgbTable[hue]; } class QwtSaturationValueColorMap::PrivateData { - public: - PrivateData() - : hue(0) - , sat1(255) - , sat2(255) - , value1(0) - , value2(255) - , alpha(255) - , tableType(Invalid) +public: + PrivateData() + : hue(0) + , sat1(255) + , sat2(255) + , value1(0) + , value2(255) + , alpha(255) + , tableType(Invalid) + { + updateTable(); + } + + void updateTable() + { + tableType = Invalid; + + if ((value1 == value2) && (sat1 != sat2)) { - updateTable(); + rgbTable.resize(256); + + for (int i = 0; i < 256; i++) + rgbTable[i] = qwtHsvToRgb(hue, i, value1, alpha); + + tableType = Saturation; } - - void updateTable() + else if ((value1 != value2) && (sat1 == sat2)) { - tableType = Invalid; + rgbTable.resize(256); - if ( ( value1 == value2 ) && ( sat1 != sat2 ) ) - { - rgbTable.resize( 256 ); + for (int i = 0; i < 256; i++) + rgbTable[i] = qwtHsvToRgb(hue, sat1, i, alpha); - for ( int i = 0; i < 256; i++ ) - rgbTable[i] = qwtHsvToRgb( hue, i, value1, alpha ); - - tableType = Saturation; - } - else if ( ( value1 != value2 ) && ( sat1 == sat2 ) ) - { - rgbTable.resize( 256 ); - - for ( int i = 0; i < 256; i++ ) - rgbTable[i] = qwtHsvToRgb( hue, sat1, i, alpha ); - - tableType = Value; - } - else - { - rgbTable.resize( 256 * 256 ); - - for ( int s = 0; s < 256; s++ ) - { - const int v0 = s * 256; - - for ( int v = 0; v < 256; v++ ) - rgbTable[v0 + v] = qwtHsvToRgb( hue, s, v, alpha ); - } - } + tableType = Value; } - - int hue; - int sat1, sat2; - int value1, value2; - int alpha; - - enum + else { - Invalid, - Value, - Saturation + rgbTable.resize(256 * 256); - } tableType; + for (int s = 0; s < 256; s++) + { + const int v0 = s * 256; - QVector< QRgb > rgbTable; + for (int v = 0; v < 256; v++) + rgbTable[v0 + v] = qwtHsvToRgb(hue, s, v, alpha); + } + } + } + + int hue; + int sat1, sat2; + int value1, value2; + int alpha; + + enum + { + Invalid, + Value, + Saturation + + } tableType; + + QVector rgbTable; }; /*! @@ -971,13 +958,13 @@ class QwtSaturationValueColorMap::PrivateData */ QwtSaturationValueColorMap::QwtSaturationValueColorMap() { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtSaturationValueColorMap::~QwtSaturationValueColorMap() { - delete m_data; + delete m_data; } /*! @@ -989,15 +976,15 @@ QwtSaturationValueColorMap::~QwtSaturationValueColorMap() \sa hue() */ -void QwtSaturationValueColorMap::setHue( int hue ) +void QwtSaturationValueColorMap::setHue(int hue) { - hue = hue % 360; + hue = hue % 360; - if ( hue != m_data->hue ) - { - m_data->hue = hue; - m_data->updateTable(); - } + if (hue != m_data->hue) + { + m_data->hue = hue; + m_data->updateTable(); + } } /*! @@ -1013,25 +1000,26 @@ void QwtSaturationValueColorMap::setHue( int hue ) \sa saturation1(), saturation2(), setValueInterval() */ -void QwtSaturationValueColorMap::setSaturationInterval( - int saturation1, int saturation2 ) +void QwtSaturationValueColorMap::setSaturationInterval(int saturation1, + int saturation2) { - saturation1 = qBound( 0, saturation1, 255 ); - saturation2 = qBound( 0, saturation2, 255 ); + saturation1 = qBound(0, saturation1, 255); + saturation2 = qBound(0, saturation2, 255); - if ( ( saturation1 != m_data->sat1 ) || ( saturation2 != m_data->sat2 ) ) - { - m_data->sat1 = saturation1; - m_data->sat2 = saturation2; + if ((saturation1 != m_data->sat1) || (saturation2 != m_data->sat2)) + { + m_data->sat1 = saturation1; + m_data->sat2 = saturation2; - m_data->updateTable(); - } + m_data->updateTable(); + } } /*! \brief Set the interval for the value coordinate - When value1 == value2 the map interpolates between the saturation coordinates only. + When value1 == value2 the map interpolates between the saturation coordinates + only. value1/value2 need to be in the range 0 to 255. @@ -1040,18 +1028,18 @@ void QwtSaturationValueColorMap::setSaturationInterval( \sa value1(), value2(), setSaturationInterval() */ -void QwtSaturationValueColorMap::setValueInterval( int value1, int value2 ) +void QwtSaturationValueColorMap::setValueInterval(int value1, int value2) { - value1 = qBound( 0, value1, 255 ); - value2 = qBound( 0, value2, 255 ); + value1 = qBound(0, value1, 255); + value2 = qBound(0, value2, 255); - if ( ( value1 != m_data->value1 ) || ( value2 != m_data->value2 ) ) - { - m_data->value1 = value1; - m_data->value2 = value2; + if ((value1 != m_data->value1) || (value2 != m_data->value2)) + { + m_data->value1 = value1; + m_data->value2 = value2; - m_data->updateTable(); - } + m_data->updateTable(); + } } /*! @@ -1064,15 +1052,15 @@ void QwtSaturationValueColorMap::setValueInterval( int value1, int value2 ) \sa alpha() */ -void QwtSaturationValueColorMap::setAlpha( int alpha ) +void QwtSaturationValueColorMap::setAlpha(int alpha) { - alpha = qBound( 0, alpha, 255 ); + alpha = qBound(0, alpha, 255); - if ( alpha != m_data->alpha ) - { - m_data->alpha = alpha; - m_data->updateTable(); - } + if (alpha != m_data->alpha) + { + m_data->alpha = alpha; + m_data->updateTable(); + } } /*! @@ -1081,7 +1069,7 @@ void QwtSaturationValueColorMap::setAlpha( int alpha ) */ int QwtSaturationValueColorMap::hue() const { - return m_data->hue; + return m_data->hue; } /*! @@ -1090,7 +1078,7 @@ int QwtSaturationValueColorMap::hue() const */ int QwtSaturationValueColorMap::saturation1() const { - return m_data->sat1; + return m_data->sat1; } /*! @@ -1099,7 +1087,7 @@ int QwtSaturationValueColorMap::saturation1() const */ int QwtSaturationValueColorMap::saturation2() const { - return m_data->sat2; + return m_data->sat2; } /*! @@ -1108,7 +1096,7 @@ int QwtSaturationValueColorMap::saturation2() const */ int QwtSaturationValueColorMap::value1() const { - return m_data->value1; + return m_data->value1; } /*! @@ -1117,7 +1105,7 @@ int QwtSaturationValueColorMap::value1() const */ int QwtSaturationValueColorMap::value2() const { - return m_data->value2; + return m_data->value2; } /*! @@ -1126,7 +1114,7 @@ int QwtSaturationValueColorMap::value2() const */ int QwtSaturationValueColorMap::alpha() const { - return m_data->alpha; + return m_data->alpha; } /*! @@ -1137,67 +1125,64 @@ int QwtSaturationValueColorMap::alpha() const \return RGB value for value */ -QRgb QwtSaturationValueColorMap::rgb( - const QwtInterval& interval, double value ) const +QRgb QwtSaturationValueColorMap::rgb(const QwtInterval &interval, + double value) const { - const double width = interval.width(); - if ( width <= 0 ) - return 0u; + const double width = interval.width(); + if (width <= 0) + return 0u; - const QRgb* rgbTable = m_data->rgbTable.constData(); + const QRgb *rgbTable = m_data->rgbTable.constData(); - switch( m_data->tableType ) - { - case PrivateData::Saturation: - { - if ( value <= interval.minValue() ) - return m_data->rgbTable[m_data->sat1]; + switch (m_data->tableType) + { + case PrivateData::Saturation: { + if (value <= interval.minValue()) + return m_data->rgbTable[m_data->sat1]; - if ( value >= interval.maxValue() ) - return m_data->rgbTable[m_data->sat2]; + if (value >= interval.maxValue()) + return m_data->rgbTable[m_data->sat2]; - const double ratio = ( value - interval.minValue() ) / width; - const int sat = m_data->sat1 - + qRound( ratio * ( m_data->sat2 - m_data->sat1 ) ); + const double ratio = (value - interval.minValue()) / width; + const int sat + = m_data->sat1 + qRound(ratio * (m_data->sat2 - m_data->sat1)); - return rgbTable[sat]; - } - case PrivateData::Value: - { - if ( value <= interval.minValue() ) - return m_data->rgbTable[m_data->value1]; - - if ( value >= interval.maxValue() ) - return m_data->rgbTable[m_data->value2]; - - const double ratio = ( value - interval.minValue() ) / width; - const int v = m_data->value1 + - qRound( ratio * ( m_data->value2 - m_data->value1 ) ); - - return rgbTable[ v ]; - } - default: - { - int s, v; - if ( value <= interval.minValue() ) - { - s = m_data->sat1; - v = m_data->value1; - } - else if ( value >= interval.maxValue() ) - { - s = m_data->sat2; - v = m_data->value2; - } - else - { - const double ratio = ( value - interval.minValue() ) / width; - - v = m_data->value1 + qRound( ratio * ( m_data->value2 - m_data->value1 ) ); - s = m_data->sat1 + qRound( ratio * ( m_data->sat2 - m_data->sat1 ) ); - } - - return rgbTable[ 256 * s + v ]; - } + return rgbTable[sat]; } + case PrivateData::Value: { + if (value <= interval.minValue()) + return m_data->rgbTable[m_data->value1]; + + if (value >= interval.maxValue()) + return m_data->rgbTable[m_data->value2]; + + const double ratio = (value - interval.minValue()) / width; + const int v + = m_data->value1 + qRound(ratio * (m_data->value2 - m_data->value1)); + + return rgbTable[v]; + } + default: { + int s, v; + if (value <= interval.minValue()) + { + s = m_data->sat1; + v = m_data->value1; + } + else if (value >= interval.maxValue()) + { + s = m_data->sat2; + v = m_data->value2; + } + else + { + const double ratio = (value - interval.minValue()) / width; + + v = m_data->value1 + qRound(ratio * (m_data->value2 - m_data->value1)); + s = m_data->sat1 + qRound(ratio * (m_data->sat2 - m_data->sat1)); + } + + return rgbTable[256 * s + v]; + } + } } diff --git a/libs/qwt/src/qwt_color_map.h b/libs/qwt/src/qwt_color_map.h index 247e7b84..8534550f 100644 --- a/libs/qwt/src/qwt_color_map.h +++ b/libs/qwt/src/qwt_color_map.h @@ -16,7 +16,8 @@ class QwtInterval; #if QT_VERSION < 0x060000 -template< typename T > class QVector; +template +class QVector; #endif /*! @@ -36,56 +37,56 @@ template< typename T > class QVector; class QWT_EXPORT QwtColorMap { - public: - /*! - Format for color mapping - \sa rgb(), colorIndex(), colorTable() - */ +public: + /*! + Format for color mapping + \sa rgb(), colorIndex(), colorTable() + */ - enum Format - { - //! The map is intended to map into RGB values. - RGB, - - /*! - Map values into 8 bit values, that - are used as indexes into the color table. - - Indexed color maps are used to generate QImage::Format_Indexed8 - images. The calculation of the color index is usually faster - and the resulting image has a lower memory footprint. - - \sa colorIndex(), colorTable() - */ - Indexed - }; - - explicit QwtColorMap( Format = QwtColorMap::RGB ); - virtual ~QwtColorMap(); - - void setFormat( Format ); - Format format() const; + enum Format + { + //! The map is intended to map into RGB values. + RGB, /*! - Map a value of a given interval into a RGB value. + Map values into 8 bit values, that + are used as indexes into the color table. - \param interval Range for the values - \param value Value - \return RGB value, corresponding to value + Indexed color maps are used to generate QImage::Format_Indexed8 + images. The calculation of the color index is usually faster + and the resulting image has a lower memory footprint. + + \sa colorIndex(), colorTable() */ - virtual QRgb rgb( const QwtInterval& interval, double value ) const = 0; + Indexed + }; - virtual uint colorIndex( int numColors, - const QwtInterval& interval, double value ) const; + explicit QwtColorMap(Format = QwtColorMap::RGB); + virtual ~QwtColorMap(); - QColor color( const QwtInterval&, double value ) const; - virtual QVector< QRgb > colorTable( int numColors ) const; - virtual QVector< QRgb > colorTable256() const; + void setFormat(Format); + Format format() const; - private: - Q_DISABLE_COPY(QwtColorMap) + /*! + Map a value of a given interval into a RGB value. - Format m_format; + \param interval Range for the values + \param value Value + \return RGB value, corresponding to value + */ + virtual QRgb rgb(const QwtInterval &interval, double value) const = 0; + + virtual uint colorIndex(int numColors, const QwtInterval &interval, + double value) const; + + QColor color(const QwtInterval &, double value) const; + virtual QVector colorTable(int numColors) const; + virtual QVector colorTable256() const; + +private: + Q_DISABLE_COPY(QwtColorMap) + + Format m_format; }; /*! @@ -97,48 +98,47 @@ class QWT_EXPORT QwtColorMap */ class QWT_EXPORT QwtLinearColorMap : public QwtColorMap { - public: - /*! - Mode of color map - \sa setMode(), mode() - */ - enum Mode - { - //! Return the color from the next lower color stop - FixedColors, +public: + /*! + Mode of color map + \sa setMode(), mode() + */ + enum Mode + { + //! Return the color from the next lower color stop + FixedColors, - //! Interpolating the colors of the adjacent stops. - ScaledColors - }; + //! Interpolating the colors of the adjacent stops. + ScaledColors + }; - explicit QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB ); + explicit QwtLinearColorMap(QwtColorMap::Format = QwtColorMap::RGB); - QwtLinearColorMap( const QColor& from, const QColor& to, - QwtColorMap::Format = QwtColorMap::RGB ); + QwtLinearColorMap(const QColor &from, const QColor &to, + QwtColorMap::Format = QwtColorMap::RGB); - virtual ~QwtLinearColorMap(); + virtual ~QwtLinearColorMap(); - void setMode( Mode ); - Mode mode() const; + void setMode(Mode); + Mode mode() const; - void setColorInterval( const QColor& color1, const QColor& color2 ); - void addColorStop( double value, const QColor& ); - QVector< double > colorStops() const; + void setColorInterval(const QColor &color1, const QColor &color2); + void addColorStop(double value, const QColor &); + QVector colorStops() const; - QColor color1() const; - QColor color2() const; + QColor color1() const; + QColor color2() const; - virtual QRgb rgb( const QwtInterval&, - double value ) const QWT_OVERRIDE; + virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE; - virtual uint colorIndex( int numColors, - const QwtInterval&, double value ) const QWT_OVERRIDE; + virtual uint colorIndex(int numColors, const QwtInterval &, + double value) const QWT_OVERRIDE; - class ColorStops; + class ColorStops; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; /*! @@ -146,31 +146,30 @@ class QWT_EXPORT QwtLinearColorMap : public QwtColorMap */ class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap { - public: - explicit QwtAlphaColorMap( const QColor& = QColor( Qt::gray ) ); - virtual ~QwtAlphaColorMap(); +public: + explicit QwtAlphaColorMap(const QColor & = QColor(Qt::gray)); + virtual ~QwtAlphaColorMap(); - void setAlphaInterval( int alpha1, int alpha2 ); + void setAlphaInterval(int alpha1, int alpha2); - int alpha1() const; - int alpha2() const; + int alpha1() const; + int alpha2() const; - void setColor( const QColor& ); - QColor color() const; + void setColor(const QColor &); + QColor color() const; - virtual QRgb rgb( const QwtInterval&, - double value ) const QWT_OVERRIDE; + virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; /*! \brief QwtHueColorMap varies the hue value of the HSV color model. - QwtHueColorMap can be used to set up a color map easily, that runs cyclic over - all colors. Each cycle has 360 different steps. + QwtHueColorMap can be used to set up a color map easily, that runs cyclic + over all colors. Each cycle has 360 different steps. The values for value and saturation are in the range of 0 to 255 and doesn't depend on the data value to be mapped. @@ -179,32 +178,31 @@ class QWT_EXPORT QwtAlphaColorMap : public QwtColorMap */ class QWT_EXPORT QwtHueColorMap : public QwtColorMap { - public: - explicit QwtHueColorMap( QwtColorMap::Format = QwtColorMap::RGB ); - virtual ~QwtHueColorMap(); +public: + explicit QwtHueColorMap(QwtColorMap::Format = QwtColorMap::RGB); + virtual ~QwtHueColorMap(); - void setHueInterval( int hue1, int hue2 ); // direction ? - void setSaturation( int saturation ); - void setValue( int value ); - void setAlpha( int alpha ); + void setHueInterval(int hue1, int hue2); // direction ? + void setSaturation(int saturation); + void setValue(int value); + void setAlpha(int alpha); - int hue1() const; - int hue2() const; - int saturation() const; - int value() const; - int alpha() const; + int hue1() const; + int hue2() const; + int saturation() const; + int value() const; + int alpha() const; - virtual QRgb rgb( const QwtInterval&, - double value ) const QWT_OVERRIDE; + virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; /*! - \brief QwtSaturationValueColorMap varies the saturation and/or value for a given - hue in the HSV color model. + \brief QwtSaturationValueColorMap varies the saturation and/or value for a + given hue in the HSV color model. Value and saturation are in the range of 0 to 255 while hue is in the range of 0 to 259. @@ -213,28 +211,27 @@ class QWT_EXPORT QwtHueColorMap : public QwtColorMap */ class QWT_EXPORT QwtSaturationValueColorMap : public QwtColorMap { - public: - QwtSaturationValueColorMap(); - virtual ~QwtSaturationValueColorMap(); +public: + QwtSaturationValueColorMap(); + virtual ~QwtSaturationValueColorMap(); - void setHue( int hue ); - void setSaturationInterval( int sat1, int sat2 ); - void setValueInterval( int value1, int value2 ); - void setAlpha( int alpha ); + void setHue(int hue); + void setSaturationInterval(int sat1, int sat2); + void setValueInterval(int value1, int value2); + void setAlpha(int alpha); - int hue() const; - int saturation1() const; - int saturation2() const; - int value1() const; - int value2() const; - int alpha() const; + int hue() const; + int saturation1() const; + int saturation2() const; + int value1() const; + int value2() const; + int alpha() const; - virtual QRgb rgb( const QwtInterval&, - double value ) const QWT_OVERRIDE; + virtual QRgb rgb(const QwtInterval &, double value) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; /*! @@ -245,9 +242,10 @@ class QWT_EXPORT QwtSaturationValueColorMap : public QwtColorMap \return Color corresponding to value */ -inline QColor QwtColorMap::color( const QwtInterval& interval, double value ) const +inline QColor QwtColorMap::color(const QwtInterval &interval, + double value) const { - return QColor::fromRgba( rgb( interval, value ) ); + return QColor::fromRgba(rgb(interval, value)); } /*! @@ -256,7 +254,7 @@ inline QColor QwtColorMap::color( const QwtInterval& interval, double value ) co */ inline QwtColorMap::Format QwtColorMap::format() const { - return m_format; + return m_format; } #endif diff --git a/libs/qwt/src/qwt_column_symbol.cpp b/libs/qwt/src/qwt_column_symbol.cpp index c2cc6989..333c063f 100644 --- a/libs/qwt/src/qwt_column_symbol.cpp +++ b/libs/qwt/src/qwt_column_symbol.cpp @@ -14,116 +14,116 @@ #include #include -static void qwtDrawBox( QPainter* p, const QRectF& rect, - const QPalette& pal, double lw ) +static void qwtDrawBox(QPainter *p, const QRectF &rect, const QPalette &pal, + double lw) { - if ( lw > 0.0 ) + if (lw > 0.0) + { + if (rect.width() == 0.0) { - if ( rect.width() == 0.0 ) - { - p->setPen( pal.dark().color() ); - p->drawLine( rect.topLeft(), rect.bottomLeft() ); - return; - } - - if ( rect.height() == 0.0 ) - { - p->setPen( pal.dark().color() ); - p->drawLine( rect.topLeft(), rect.topRight() ); - return; - } - - lw = qwtMinF( lw, rect.height() / 2.0 - 1.0 ); - lw = qwtMinF( lw, rect.width() / 2.0 - 1.0 ); - - const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 ); - QPolygonF polygon( outerRect ); - - if ( outerRect.width() > 2 * lw && outerRect.height() > 2 * lw ) - { - const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw ); - polygon = polygon.subtracted( innerRect ); - } - - p->setPen( Qt::NoPen ); - - p->setBrush( pal.dark() ); - p->drawPolygon( polygon ); + p->setPen(pal.dark().color()); + p->drawLine(rect.topLeft(), rect.bottomLeft()); + return; } - const QRectF windowRect = rect.adjusted( lw, lw, -lw + 1, -lw + 1 ); - if ( windowRect.isValid() ) - p->fillRect( windowRect, pal.window() ); + if (rect.height() == 0.0) + { + p->setPen(pal.dark().color()); + p->drawLine(rect.topLeft(), rect.topRight()); + return; + } + + lw = qwtMinF(lw, rect.height() / 2.0 - 1.0); + lw = qwtMinF(lw, rect.width() / 2.0 - 1.0); + + const QRectF outerRect = rect.adjusted(0, 0, 1, 1); + QPolygonF polygon(outerRect); + + if (outerRect.width() > 2 * lw && outerRect.height() > 2 * lw) + { + const QRectF innerRect = outerRect.adjusted(lw, lw, -lw, -lw); + polygon = polygon.subtracted(innerRect); + } + + p->setPen(Qt::NoPen); + + p->setBrush(pal.dark()); + p->drawPolygon(polygon); + } + + const QRectF windowRect = rect.adjusted(lw, lw, -lw + 1, -lw + 1); + if (windowRect.isValid()) + p->fillRect(windowRect, pal.window()); } -static void qwtDrawPanel( QPainter* painter, const QRectF& rect, - const QPalette& pal, double lw ) +static void qwtDrawPanel(QPainter *painter, const QRectF &rect, + const QPalette &pal, double lw) { - if ( lw > 0.0 ) + if (lw > 0.0) + { + if (rect.width() == 0.0) { - if ( rect.width() == 0.0 ) - { - painter->setPen( pal.window().color() ); - painter->drawLine( rect.topLeft(), rect.bottomLeft() ); - return; - } - - if ( rect.height() == 0.0 ) - { - painter->setPen( pal.window().color() ); - painter->drawLine( rect.topLeft(), rect.topRight() ); - return; - } - - lw = qwtMinF( lw, rect.height() / 2.0 - 1.0 ); - lw = qwtMinF( lw, rect.width() / 2.0 - 1.0 ); - - const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 ); - const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw ); - - QPolygonF lines[2]; - - lines[0] += outerRect.bottomLeft(); - lines[0] += outerRect.topLeft(); - lines[0] += outerRect.topRight(); - lines[0] += innerRect.topRight(); - lines[0] += innerRect.topLeft(); - lines[0] += innerRect.bottomLeft(); - - lines[1] += outerRect.topRight(); - lines[1] += outerRect.bottomRight(); - lines[1] += outerRect.bottomLeft(); - lines[1] += innerRect.bottomLeft(); - lines[1] += innerRect.bottomRight(); - lines[1] += innerRect.topRight(); - - painter->setPen( Qt::NoPen ); - - painter->setBrush( pal.light() ); - painter->drawPolygon( lines[0] ); - painter->setBrush( pal.dark() ); - painter->drawPolygon( lines[1] ); + painter->setPen(pal.window().color()); + painter->drawLine(rect.topLeft(), rect.bottomLeft()); + return; } - painter->fillRect( rect.adjusted( lw, lw, -lw + 1, -lw + 1 ), pal.window() ); + if (rect.height() == 0.0) + { + painter->setPen(pal.window().color()); + painter->drawLine(rect.topLeft(), rect.topRight()); + return; + } + + lw = qwtMinF(lw, rect.height() / 2.0 - 1.0); + lw = qwtMinF(lw, rect.width() / 2.0 - 1.0); + + const QRectF outerRect = rect.adjusted(0, 0, 1, 1); + const QRectF innerRect = outerRect.adjusted(lw, lw, -lw, -lw); + + QPolygonF lines[2]; + + lines[0] += outerRect.bottomLeft(); + lines[0] += outerRect.topLeft(); + lines[0] += outerRect.topRight(); + lines[0] += innerRect.topRight(); + lines[0] += innerRect.topLeft(); + lines[0] += innerRect.bottomLeft(); + + lines[1] += outerRect.topRight(); + lines[1] += outerRect.bottomRight(); + lines[1] += outerRect.bottomLeft(); + lines[1] += innerRect.bottomLeft(); + lines[1] += innerRect.bottomRight(); + lines[1] += innerRect.topRight(); + + painter->setPen(Qt::NoPen); + + painter->setBrush(pal.light()); + painter->drawPolygon(lines[0]); + painter->setBrush(pal.dark()); + painter->drawPolygon(lines[1]); + } + + painter->fillRect(rect.adjusted(lw, lw, -lw + 1, -lw + 1), pal.window()); } class QwtColumnSymbol::PrivateData { - public: - PrivateData() - : style( QwtColumnSymbol::Box ) - , frameStyle( QwtColumnSymbol::Raised ) - , palette( Qt::gray ) - , lineWidth( 2 ) - { - } +public: + PrivateData() + : style(QwtColumnSymbol::Box) + , frameStyle(QwtColumnSymbol::Raised) + , palette(Qt::gray) + , lineWidth(2) + { + } - QwtColumnSymbol::Style style; - QwtColumnSymbol::FrameStyle frameStyle; + QwtColumnSymbol::Style style; + QwtColumnSymbol::FrameStyle frameStyle; - QPalette palette; - int lineWidth; + QPalette palette; + int lineWidth; }; /*! @@ -132,16 +132,16 @@ class QwtColumnSymbol::PrivateData \param style Style of the symbol \sa setStyle(), style(), Style */ -QwtColumnSymbol::QwtColumnSymbol( Style style ) +QwtColumnSymbol::QwtColumnSymbol(Style style) { - m_data = new PrivateData(); - m_data->style = style; + m_data = new PrivateData(); + m_data->style = style; } //! Destructor QwtColumnSymbol::~QwtColumnSymbol() { - delete m_data; + delete m_data; } /*! @@ -150,9 +150,9 @@ QwtColumnSymbol::~QwtColumnSymbol() \param style Style \sa style(), setPalette() */ -void QwtColumnSymbol::setStyle( Style style ) +void QwtColumnSymbol::setStyle(Style style) { - m_data->style = style; + m_data->style = style; } /*! @@ -161,7 +161,7 @@ void QwtColumnSymbol::setStyle( Style style ) */ QwtColumnSymbol::Style QwtColumnSymbol::style() const { - return m_data->style; + return m_data->style; } /*! @@ -170,18 +170,18 @@ QwtColumnSymbol::Style QwtColumnSymbol::style() const \param palette Palette \sa palette(), setStyle() */ -void QwtColumnSymbol::setPalette( const QPalette& palette ) +void QwtColumnSymbol::setPalette(const QPalette &palette) { - m_data->palette = palette; + m_data->palette = palette; } /*! \return Current palette \sa setPalette() */ -const QPalette& QwtColumnSymbol::palette() const +const QPalette &QwtColumnSymbol::palette() const { - return m_data->palette; + return m_data->palette; } /*! @@ -190,9 +190,9 @@ const QPalette& QwtColumnSymbol::palette() const \param frameStyle Frame style \sa frameStyle(), setLineWidth(), setStyle() */ -void QwtColumnSymbol::setFrameStyle( FrameStyle frameStyle ) +void QwtColumnSymbol::setFrameStyle(FrameStyle frameStyle) { - m_data->frameStyle = frameStyle; + m_data->frameStyle = frameStyle; } /*! @@ -201,7 +201,7 @@ void QwtColumnSymbol::setFrameStyle( FrameStyle frameStyle ) */ QwtColumnSymbol::FrameStyle QwtColumnSymbol::frameStyle() const { - return m_data->frameStyle; + return m_data->frameStyle; } /*! @@ -210,12 +210,12 @@ QwtColumnSymbol::FrameStyle QwtColumnSymbol::frameStyle() const \param width Width \sa lineWidth(), setFrameStyle() */ -void QwtColumnSymbol::setLineWidth( int width ) +void QwtColumnSymbol::setLineWidth(int width) { - if ( width < 0 ) - width = 0; + if (width < 0) + width = 0; - m_data->lineWidth = width; + m_data->lineWidth = width; } /*! @@ -224,7 +224,7 @@ void QwtColumnSymbol::setLineWidth( int width ) */ int QwtColumnSymbol::lineWidth() const { - return m_data->lineWidth; + return m_data->lineWidth; } /*! @@ -235,22 +235,20 @@ int QwtColumnSymbol::lineWidth() const \sa drawBox() */ -void QwtColumnSymbol::draw( QPainter* painter, - const QwtColumnRect& rect ) const +void QwtColumnSymbol::draw(QPainter *painter, const QwtColumnRect &rect) const { - painter->save(); + painter->save(); - switch ( m_data->style ) - { - case QwtColumnSymbol::Box: - { - drawBox( painter, rect ); - break; - } - default:; + switch (m_data->style) + { + case QwtColumnSymbol::Box: { + drawBox(painter, rect); + break; } + default:; + } - painter->restore(); + painter->restore(); } /*! @@ -261,58 +259,54 @@ void QwtColumnSymbol::draw( QPainter* painter, \sa draw() */ -void QwtColumnSymbol::drawBox( QPainter* painter, - const QwtColumnRect& rect ) const +void QwtColumnSymbol::drawBox(QPainter *painter, + const QwtColumnRect &rect) const { - QRectF r = rect.toRect(); - if ( QwtPainter::roundingAlignment( painter ) ) - { - r.setLeft( qRound( r.left() ) ); - r.setRight( qRound( r.right() ) ); - r.setTop( qRound( r.top() ) ); - r.setBottom( qRound( r.bottom() ) ); - } + QRectF r = rect.toRect(); + if (QwtPainter::roundingAlignment(painter)) + { + r.setLeft(qRound(r.left())); + r.setRight(qRound(r.right())); + r.setTop(qRound(r.top())); + r.setBottom(qRound(r.bottom())); + } - switch ( m_data->frameStyle ) - { - case QwtColumnSymbol::Raised: - { - qwtDrawPanel( painter, r, m_data->palette, m_data->lineWidth ); - break; - } - case QwtColumnSymbol::Plain: - { - qwtDrawBox( painter, r, m_data->palette, m_data->lineWidth ); - break; - } - default: - { - painter->fillRect( r.adjusted( 0, 0, 1, 1 ), m_data->palette.window() ); - } + switch (m_data->frameStyle) + { + case QwtColumnSymbol::Raised: { + qwtDrawPanel(painter, r, m_data->palette, m_data->lineWidth); + break; } + case QwtColumnSymbol::Plain: { + qwtDrawBox(painter, r, m_data->palette, m_data->lineWidth); + break; + } + default: { + painter->fillRect(r.adjusted(0, 0, 1, 1), m_data->palette.window()); + } + } } //! \return A normalized QRect built from the intervals QRectF QwtColumnRect::toRect() const { - QRectF r( hInterval.minValue(), vInterval.minValue(), - hInterval.maxValue() - hInterval.minValue(), - vInterval.maxValue() - vInterval.minValue() ); + QRectF r(hInterval.minValue(), vInterval.minValue(), + hInterval.maxValue() - hInterval.minValue(), + vInterval.maxValue() - vInterval.minValue()); - r = r.normalized(); + r = r.normalized(); - if ( hInterval.borderFlags() & QwtInterval::ExcludeMinimum ) - r.adjust( 1, 0, 0, 0 ); + if (hInterval.borderFlags() & QwtInterval::ExcludeMinimum) + r.adjust(1, 0, 0, 0); - if ( hInterval.borderFlags() & QwtInterval::ExcludeMaximum ) - r.adjust( 0, 0, -1, 0 ); + if (hInterval.borderFlags() & QwtInterval::ExcludeMaximum) + r.adjust(0, 0, -1, 0); - if ( vInterval.borderFlags() & QwtInterval::ExcludeMinimum ) - r.adjust( 0, 1, 0, 0 ); + if (vInterval.borderFlags() & QwtInterval::ExcludeMinimum) + r.adjust(0, 1, 0, 0); - if ( vInterval.borderFlags() & QwtInterval::ExcludeMaximum ) - r.adjust( 0, 0, 0, -1 ); + if (vInterval.borderFlags() & QwtInterval::ExcludeMaximum) + r.adjust(0, 0, 0, -1); - return r; + return r; } - diff --git a/libs/qwt/src/qwt_column_symbol.h b/libs/qwt/src/qwt_column_symbol.h index a29ff51c..2a87206e 100644 --- a/libs/qwt/src/qwt_column_symbol.h +++ b/libs/qwt/src/qwt_column_symbol.h @@ -25,120 +25,120 @@ class QRectF; */ class QWT_EXPORT QwtColumnRect { - public: - //! Direction of the column - enum Direction - { - //! From left to right - LeftToRight, +public: + //! Direction of the column + enum Direction + { + //! From left to right + LeftToRight, - //! From right to left - RightToLeft, + //! From right to left + RightToLeft, - //! From bottom to top - BottomToTop, + //! From bottom to top + BottomToTop, - //! From top to bottom - TopToBottom - }; + //! From top to bottom + TopToBottom + }; - //! Build an rectangle with invalid intervals directed BottomToTop. - QwtColumnRect() - : direction( BottomToTop ) - { - } + //! Build an rectangle with invalid intervals directed BottomToTop. + QwtColumnRect() + : direction(BottomToTop) + { + } - //! \return A normalized QRect built from the intervals - QRectF toRect() const; + //! \return A normalized QRect built from the intervals + QRectF toRect() const; - //! \return Orientation - Qt::Orientation orientation() const - { - if ( direction == LeftToRight || direction == RightToLeft ) - return Qt::Horizontal; + //! \return Orientation + Qt::Orientation orientation() const + { + if (direction == LeftToRight || direction == RightToLeft) + return Qt::Horizontal; - return Qt::Vertical; - } + return Qt::Vertical; + } - //! Interval for the horizontal coordinates - QwtInterval hInterval; + //! Interval for the horizontal coordinates + QwtInterval hInterval; - //! Interval for the vertical coordinates - QwtInterval vInterval; + //! Interval for the vertical coordinates + QwtInterval vInterval; - //! Direction - Direction direction; + //! Direction + Direction direction; }; //! A drawing primitive for columns class QWT_EXPORT QwtColumnSymbol { - public: - /*! - Style - \sa setStyle(), style() - */ - enum Style - { - //! No Style, the symbol draws nothing - NoStyle = -1, - - /*! - The column is painted with a frame depending on the frameStyle() - and lineWidth() using the palette(). - */ - Box, - - /*! - Styles >= QwtColumnSymbol::UserStyle are reserved for derived - classes of QwtColumnSymbol that overload draw() with - additional application specific symbol types. - */ - UserStyle = 1000 - }; +public: + /*! + Style + \sa setStyle(), style() + */ + enum Style + { + //! No Style, the symbol draws nothing + NoStyle = -1, /*! - Frame Style used in Box style(). - \sa Style, setFrameStyle(), frameStyle(), setStyle(), setPalette() + The column is painted with a frame depending on the frameStyle() + and lineWidth() using the palette(). */ - enum FrameStyle - { - //! No frame - NoFrame, + Box, - //! A plain frame style - Plain, + /*! + Styles >= QwtColumnSymbol::UserStyle are reserved for derived + classes of QwtColumnSymbol that overload draw() with + additional application specific symbol types. + */ + UserStyle = 1000 + }; - //! A raised frame style - Raised - }; + /*! + Frame Style used in Box style(). + \sa Style, setFrameStyle(), frameStyle(), setStyle(), setPalette() + */ + enum FrameStyle + { + //! No frame + NoFrame, - public: - explicit QwtColumnSymbol( Style = NoStyle ); - virtual ~QwtColumnSymbol(); + //! A plain frame style + Plain, - void setFrameStyle( FrameStyle ); - FrameStyle frameStyle() const; + //! A raised frame style + Raised + }; - void setLineWidth( int width ); - int lineWidth() const; +public: + explicit QwtColumnSymbol(Style = NoStyle); + virtual ~QwtColumnSymbol(); - void setPalette( const QPalette& ); - const QPalette& palette() const; + void setFrameStyle(FrameStyle); + FrameStyle frameStyle() const; - void setStyle( Style ); - Style style() const; + void setLineWidth(int width); + int lineWidth() const; - virtual void draw( QPainter*, const QwtColumnRect& ) const; + void setPalette(const QPalette &); + const QPalette &palette() const; - protected: - void drawBox( QPainter*, const QwtColumnRect& ) const; + void setStyle(Style); + Style style() const; - private: - Q_DISABLE_COPY(QwtColumnSymbol) + virtual void draw(QPainter *, const QwtColumnRect &) const; - class PrivateData; - PrivateData* m_data; +protected: + void drawBox(QPainter *, const QwtColumnRect &) const; + +private: + Q_DISABLE_COPY(QwtColumnSymbol) + + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_compass.cpp b/libs/qwt/src/qwt_compass.cpp index 783edf74..e026cfae 100644 --- a/libs/qwt/src/qwt_compass.cpp +++ b/libs/qwt/src/qwt_compass.cpp @@ -16,8 +16,8 @@ class QwtCompassScaleDraw::PrivateData { - public: - QMap< double, QString > labelMap; +public: + QMap labelMap; }; /*! @@ -27,21 +27,21 @@ class QwtCompassScaleDraw::PrivateData */ QwtCompassScaleDraw::QwtCompassScaleDraw() { - m_data = new PrivateData; + m_data = new PrivateData; - enableComponent( QwtAbstractScaleDraw::Backbone, false ); - enableComponent( QwtAbstractScaleDraw::Ticks, false ); + enableComponent(QwtAbstractScaleDraw::Backbone, false); + enableComponent(QwtAbstractScaleDraw::Ticks, false); - QMap< double, QString >& map = m_data->labelMap; + QMap &map = m_data->labelMap; - map.insert( 0.0, QString::fromLatin1( "N" ) ); - map.insert( 45.0, QString::fromLatin1( "NE" ) ); - map.insert( 90.0, QString::fromLatin1( "E" ) ); - map.insert( 135.0, QString::fromLatin1( "SE" ) ); - map.insert( 180.0, QString::fromLatin1( "S" ) ); - map.insert( 225.0, QString::fromLatin1( "SW" ) ); - map.insert( 270.0, QString::fromLatin1( "W" ) ); - map.insert( 315.0, QString::fromLatin1( "NW" ) ); + map.insert(0.0, QString::fromLatin1("N")); + map.insert(45.0, QString::fromLatin1("NE")); + map.insert(90.0, QString::fromLatin1("E")); + map.insert(135.0, QString::fromLatin1("SE")); + map.insert(180.0, QString::fromLatin1("S")); + map.insert(225.0, QString::fromLatin1("SW")); + map.insert(270.0, QString::fromLatin1("W")); + map.insert(315.0, QString::fromLatin1("NW")); #if 0 map.insert( 22.5, QString::fromLatin1( "NNE" ) ); @@ -60,19 +60,19 @@ QwtCompassScaleDraw::QwtCompassScaleDraw() \param map Value to label map */ -QwtCompassScaleDraw::QwtCompassScaleDraw( const QMap< double, QString >& map ) +QwtCompassScaleDraw::QwtCompassScaleDraw(const QMap &map) { - m_data = new PrivateData; - m_data->labelMap = map; + m_data = new PrivateData; + m_data->labelMap = map; - enableComponent( QwtAbstractScaleDraw::Backbone, false ); - enableComponent( QwtAbstractScaleDraw::Ticks, false ); + enableComponent(QwtAbstractScaleDraw::Backbone, false); + enableComponent(QwtAbstractScaleDraw::Ticks, false); } //! Destructor QwtCompassScaleDraw::~QwtCompassScaleDraw() { - delete m_data; + delete m_data; } /*! @@ -87,18 +87,18 @@ QwtCompassScaleDraw::~QwtCompassScaleDraw() \sa labelMap(), scaleDraw(), setScale() */ -void QwtCompassScaleDraw::setLabelMap( const QMap< double, QString >& map ) +void QwtCompassScaleDraw::setLabelMap(const QMap &map) { - m_data->labelMap = map; + m_data->labelMap = map; } /*! \return map, mapping values to labels \sa setLabelMap() */ -QMap< double, QString > QwtCompassScaleDraw::labelMap() const +QMap QwtCompassScaleDraw::labelMap() const { - return m_data->labelMap; + return m_data->labelMap; } /*! @@ -113,37 +113,33 @@ QMap< double, QString > QwtCompassScaleDraw::labelMap() const \sa labelMap(), setLabelMap() */ -QwtText QwtCompassScaleDraw::label( double value ) const +QwtText QwtCompassScaleDraw::label(double value) const { - if ( qFuzzyCompare( value + 1.0, 1.0 ) ) - value = 0.0; + if (qFuzzyCompare(value + 1.0, 1.0)) + value = 0.0; - if ( value < 0.0 ) - value += 360.0; + if (value < 0.0) + value += 360.0; - QMap< double, QString >::const_iterator it = - m_data->labelMap.constFind( value ); + QMap::const_iterator it = m_data->labelMap.constFind(value); - if ( it != m_data->labelMap.constEnd() ) - return *it; + if (it != m_data->labelMap.constEnd()) + return *it; - return QwtText(); + return QwtText(); } class QwtCompass::PrivateData { - public: - PrivateData(): - rose( NULL ) - { - } +public: + PrivateData() + : rose(NULL) + { + } - ~PrivateData() - { - delete rose; - } + ~PrivateData() { delete rose; } - QwtCompassRose* rose; + QwtCompassRose *rose; }; /*! @@ -155,30 +151,29 @@ class QwtCompass::PrivateData mouse and keyboard inputs and has no step size. The default mode is QwtDial::RotateNeedle. */ -QwtCompass::QwtCompass( QWidget* parent ) - : QwtDial( parent ) +QwtCompass::QwtCompass(QWidget *parent) + : QwtDial(parent) { - m_data = new PrivateData; + m_data = new PrivateData; - setScaleDraw( new QwtCompassScaleDraw() ); + setScaleDraw(new QwtCompassScaleDraw()); - setOrigin( 270.0 ); - setWrapping( true ); + setOrigin(270.0); + setWrapping(true); - setScaleMaxMajor( 36 ); - setScaleMaxMinor( 10 ); + setScaleMaxMajor(36); + setScaleMaxMinor(10); - setScale( 0.0, 360.0 ); // degrees as default - setTotalSteps( 360 ); + setScale(0.0, 360.0); // degrees as default + setTotalSteps(360); } //! Destructor QwtCompass::~QwtCompass() { - delete m_data; + delete m_data; } - /*! Draw the contents of the scale @@ -186,24 +181,24 @@ QwtCompass::~QwtCompass() \param center Center of the content circle \param radius Radius of the content circle */ -void QwtCompass::drawScaleContents( QPainter* painter, - const QPointF& center, double radius ) const +void QwtCompass::drawScaleContents(QPainter *painter, const QPointF ¢er, + double radius) const { - QPalette::ColorGroup cg; - if ( isEnabled() ) - cg = hasFocus() ? QPalette::Active : QPalette::Inactive; - else - cg = QPalette::Disabled; + QPalette::ColorGroup cg; + if (isEnabled()) + cg = hasFocus() ? QPalette::Active : QPalette::Inactive; + else + cg = QPalette::Disabled; - double north = origin(); - if ( isValid() ) - { - if ( mode() == RotateScale ) - north -= value(); - } + double north = origin(); + if (isValid()) + { + if (mode() == RotateScale) + north -= value(); + } - const int margin = 4; - drawRose( painter, center, radius - margin, 360.0 - north, cg ); + const int margin = 4; + drawRose(painter, center, radius - margin, 360.0 - north, cg); } /*! @@ -215,11 +210,12 @@ void QwtCompass::drawScaleContents( QPainter* painter, \param north Direction pointing north, in degrees counter clockwise \param cg Color group */ -void QwtCompass::drawRose( QPainter* painter, const QPointF& center, - double radius, double north, QPalette::ColorGroup cg ) const +void QwtCompass::drawRose(QPainter *painter, const QPointF ¢er, + double radius, double north, + QPalette::ColorGroup cg) const { - if ( m_data->rose ) - m_data->rose->draw( painter, center, radius, north, cg ); + if (m_data->rose) + m_data->rose->draw(painter, center, radius, north, cg); } /*! @@ -229,34 +225,34 @@ void QwtCompass::drawRose( QPainter* painter, const QPointF& center, set or in ~QwtCompass \sa rose() */ -void QwtCompass::setRose( QwtCompassRose* rose ) +void QwtCompass::setRose(QwtCompassRose *rose) { - if ( rose != m_data->rose ) - { - if ( m_data->rose ) - delete m_data->rose; + if (rose != m_data->rose) + { + if (m_data->rose) + delete m_data->rose; - m_data->rose = rose; - update(); - } + m_data->rose = rose; + update(); + } } /*! \return rose \sa setRose() */ -const QwtCompassRose* QwtCompass::rose() const +const QwtCompassRose *QwtCompass::rose() const { - return m_data->rose; + return m_data->rose; } /*! \return rose \sa setRose() */ -QwtCompassRose* QwtCompass::rose() +QwtCompassRose *QwtCompass::rose() { - return m_data->rose; + return m_data->rose; } /*! @@ -268,10 +264,10 @@ QwtCompassRose* QwtCompass::rose() \sa isReadOnly() */ -void QwtCompass::keyPressEvent( QKeyEvent* kev ) +void QwtCompass::keyPressEvent(QKeyEvent *kev) { - if ( isReadOnly() ) - return; + if (isReadOnly()) + return; #if 0 if ( kev->key() == Key_5 ) @@ -281,49 +277,49 @@ void QwtCompass::keyPressEvent( QKeyEvent* kev ) } #endif - double newValue = value(); + double newValue = value(); - if ( kev->key() >= Qt::Key_1 && kev->key() <= Qt::Key_9 ) - { - if ( mode() != RotateNeedle || kev->key() == Qt::Key_5 ) - return; + if (kev->key() >= Qt::Key_1 && kev->key() <= Qt::Key_9) + { + if (mode() != RotateNeedle || kev->key() == Qt::Key_5) + return; - switch ( kev->key() ) - { - case Qt::Key_6: - newValue = 180.0 * 0.0; - break; - case Qt::Key_3: - newValue = 180.0 * 0.25; - break; - case Qt::Key_2: - newValue = 180.0 * 0.5; - break; - case Qt::Key_1: - newValue = 180.0 * 0.75; - break; - case Qt::Key_4: - newValue = 180.0 * 1.0; - break; - case Qt::Key_7: - newValue = 180.0 * 1.25; - break; - case Qt::Key_8: - newValue = 180.0 * 1.5; - break; - case Qt::Key_9: - newValue = 180.0 * 1.75; - break; - } - newValue -= origin(); - setValue( newValue ); - } - else + switch (kev->key()) { - QwtDial::keyPressEvent( kev ); + case Qt::Key_6: + newValue = 180.0 * 0.0; + break; + case Qt::Key_3: + newValue = 180.0 * 0.25; + break; + case Qt::Key_2: + newValue = 180.0 * 0.5; + break; + case Qt::Key_1: + newValue = 180.0 * 0.75; + break; + case Qt::Key_4: + newValue = 180.0 * 1.0; + break; + case Qt::Key_7: + newValue = 180.0 * 1.25; + break; + case Qt::Key_8: + newValue = 180.0 * 1.5; + break; + case Qt::Key_9: + newValue = 180.0 * 1.75; + break; } + newValue -= origin(); + setValue(newValue); + } + else + { + QwtDial::keyPressEvent(kev); + } } #if QWT_MOC_INCLUDE -#include "moc_qwt_compass.cpp" +# include "moc_qwt_compass.cpp" #endif diff --git a/libs/qwt/src/qwt_compass.h b/libs/qwt/src/qwt_compass.h index 23466d42..f5d0f715 100644 --- a/libs/qwt/src/qwt_compass.h +++ b/libs/qwt/src/qwt_compass.h @@ -16,8 +16,8 @@ class QwtCompassRose; class QString; -template< class Key, class T > class QMap; - +template +class QMap; /*! \brief A special scale draw made for QwtCompass @@ -31,20 +31,20 @@ template< class Key, class T > class QMap; */ class QWT_EXPORT QwtCompassScaleDraw : public QwtRoundScaleDraw { - public: - explicit QwtCompassScaleDraw(); - explicit QwtCompassScaleDraw( const QMap< double, QString >& map ); +public: + explicit QwtCompassScaleDraw(); + explicit QwtCompassScaleDraw(const QMap &map); - virtual ~QwtCompassScaleDraw(); + virtual ~QwtCompassScaleDraw(); - void setLabelMap( const QMap< double, QString >& map ); - QMap< double, QString > labelMap() const; + void setLabelMap(const QMap &map); + QMap labelMap() const; - virtual QwtText label( double value ) const QWT_OVERRIDE; + virtual QwtText label(double value) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; /*! @@ -60,28 +60,28 @@ class QWT_EXPORT QwtCompassScaleDraw : public QwtRoundScaleDraw class QWT_EXPORT QwtCompass : public QwtDial { - Q_OBJECT + Q_OBJECT - public: - explicit QwtCompass( QWidget* parent = NULL ); - virtual ~QwtCompass(); +public: + explicit QwtCompass(QWidget *parent = NULL); + virtual ~QwtCompass(); - void setRose( QwtCompassRose* rose ); - const QwtCompassRose* rose() const; - QwtCompassRose* rose(); + void setRose(QwtCompassRose *rose); + const QwtCompassRose *rose() const; + QwtCompassRose *rose(); - protected: - virtual void drawRose( QPainter*, const QPointF& center, - double radius, double north, QPalette::ColorGroup ) const; +protected: + virtual void drawRose(QPainter *, const QPointF ¢er, double radius, + double north, QPalette::ColorGroup) const; - virtual void drawScaleContents( QPainter*, - const QPointF& center, double radius ) const QWT_OVERRIDE; + virtual void drawScaleContents(QPainter *, const QPointF ¢er, + double radius) const QWT_OVERRIDE; - virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_compass_rose.cpp b/libs/qwt/src/qwt_compass_rose.cpp index 1903f707..ef0c78b9 100644 --- a/libs/qwt/src/qwt_compass_rose.cpp +++ b/libs/qwt/src/qwt_compass_rose.cpp @@ -13,60 +13,56 @@ #include #include -static QPointF qwtIntersection( - QPointF p11, QPointF p12, QPointF p21, QPointF p22 ) +static QPointF qwtIntersection(QPointF p11, QPointF p12, QPointF p21, + QPointF p22) { - const QLineF line1( p11, p12 ); - const QLineF line2( p21, p22 ); + const QLineF line1(p11, p12); + const QLineF line2(p21, p22); - QPointF pos; + QPointF pos; #if QT_VERSION >= 0x050e00 - if ( line1.intersects( line2, &pos ) == QLineF::NoIntersection ) + if (line1.intersects(line2, &pos) == QLineF::NoIntersection) #else - if ( line1.intersect( line2, &pos ) == QLineF::NoIntersection ) + if (line1.intersect(line2, &pos) == QLineF::NoIntersection) #endif - return QPointF(); + return QPointF(); - return pos; + return pos; } //! Constructor -QwtCompassRose::QwtCompassRose() -{ -} +QwtCompassRose::QwtCompassRose() {} //! Destructor -QwtCompassRose::~QwtCompassRose() -{ -} +QwtCompassRose::~QwtCompassRose() {} //! Assign a palette -void QwtCompassRose::setPalette( const QPalette& p ) +void QwtCompassRose::setPalette(const QPalette &p) { - m_palette = p; + m_palette = p; } //! \return Current palette -const QPalette& QwtCompassRose::palette() const +const QPalette &QwtCompassRose::palette() const { - return m_palette; + return m_palette; } class QwtSimpleCompassRose::PrivateData { - public: - PrivateData() - : width( 0.2 ) - , numThorns( 8 ) - , numThornLevels( -1 ) - , shrinkFactor( 0.9 ) - { - } +public: + PrivateData() + : width(0.2) + , numThorns(8) + , numThornLevels(-1) + , shrinkFactor(0.9) + { + } - double width; - int numThorns; - int numThornLevels; - double shrinkFactor; + double width; + int numThorns; + int numThornLevels; + double shrinkFactor; }; /*! @@ -75,27 +71,26 @@ class QwtSimpleCompassRose::PrivateData \param numThorns Number of thorns \param numThornLevels Number of thorn levels */ -QwtSimpleCompassRose::QwtSimpleCompassRose( - int numThorns, int numThornLevels ) +QwtSimpleCompassRose::QwtSimpleCompassRose(int numThorns, int numThornLevels) { - m_data = new PrivateData(); - m_data->numThorns = numThorns; - m_data->numThornLevels = numThornLevels; + m_data = new PrivateData(); + m_data->numThorns = numThorns; + m_data->numThornLevels = numThornLevels; - const QColor dark( 128, 128, 255 ); - const QColor light( 192, 255, 255 ); + const QColor dark(128, 128, 255); + const QColor light(192, 255, 255); - QPalette palette; - palette.setColor( QPalette::Dark, dark ); - palette.setColor( QPalette::Light, light ); + QPalette palette; + palette.setColor(QPalette::Dark, dark); + palette.setColor(QPalette::Light, light); - setPalette( palette ); + setPalette(palette); } //! Destructor QwtSimpleCompassRose::~QwtSimpleCompassRose() { - delete m_data; + delete m_data; } /*! @@ -105,9 +100,9 @@ QwtSimpleCompassRose::~QwtSimpleCompassRose() \param factor Shrink factor \sa shrinkFactor() */ -void QwtSimpleCompassRose::setShrinkFactor( double factor ) +void QwtSimpleCompassRose::setShrinkFactor(double factor) { - m_data->shrinkFactor = factor; + m_data->shrinkFactor = factor; } /*! @@ -116,7 +111,7 @@ void QwtSimpleCompassRose::setShrinkFactor( double factor ) */ double QwtSimpleCompassRose::shrinkFactor() const { - return m_data->shrinkFactor; + return m_data->shrinkFactor; } /*! @@ -128,14 +123,15 @@ double QwtSimpleCompassRose::shrinkFactor() const \param north Position \param cg Color group */ -void QwtSimpleCompassRose::draw( QPainter* painter, const QPointF& center, - double radius, double north, QPalette::ColorGroup cg ) const +void QwtSimpleCompassRose::draw(QPainter *painter, const QPointF ¢er, + double radius, double north, + QPalette::ColorGroup cg) const { - QPalette pal = palette(); - pal.setCurrentColorGroup( cg ); + QPalette pal = palette(); + pal.setCurrentColorGroup(cg); - drawRose( painter, pal, center, radius, north, m_data->width, - m_data->numThorns, m_data->numThornLevels, m_data->shrinkFactor ); + drawRose(painter, pal, center, radius, north, m_data->width, + m_data->numThorns, m_data->numThornLevels, m_data->shrinkFactor); } /*! @@ -151,76 +147,74 @@ void QwtSimpleCompassRose::draw( QPainter* painter, const QPointF& center, \param numThornLevels Number of thorn levels \param shrinkFactor Factor to shrink the thorns with each level */ -void QwtSimpleCompassRose::drawRose( - QPainter* painter, - const QPalette& palette, - const QPointF& center, double radius, double north, double width, - int numThorns, int numThornLevels, double shrinkFactor ) +void QwtSimpleCompassRose::drawRose(QPainter *painter, const QPalette &palette, + const QPointF ¢er, double radius, + double north, double width, int numThorns, + int numThornLevels, double shrinkFactor) { - if ( numThorns < 4 ) - numThorns = 4; + if (numThorns < 4) + numThorns = 4; - if ( numThorns % 4 ) - numThorns += 4 - numThorns % 4; + if (numThorns % 4) + numThorns += 4 - numThorns % 4; - if ( numThornLevels <= 0 ) - numThornLevels = numThorns / 4; + if (numThornLevels <= 0) + numThornLevels = numThorns / 4; - if ( shrinkFactor >= 1.0 ) - shrinkFactor = 1.0; + if (shrinkFactor >= 1.0) + shrinkFactor = 1.0; - if ( shrinkFactor <= 0.5 ) - shrinkFactor = 0.5; + if (shrinkFactor <= 0.5) + shrinkFactor = 0.5; - painter->save(); + painter->save(); - painter->setPen( Qt::NoPen ); + painter->setPen(Qt::NoPen); - for ( int j = 1; j <= numThornLevels; j++ ) + for (int j = 1; j <= numThornLevels; j++) + { + double step = std::pow(2.0, j) * M_PI / numThorns; + if (step > M_PI_2) + break; + + double r = radius; + for (int k = 0; k < 3; k++) { - double step = std::pow( 2.0, j ) * M_PI / numThorns; - if ( step > M_PI_2 ) - break; - - double r = radius; - for ( int k = 0; k < 3; k++ ) - { - if ( j + k < numThornLevels ) - r *= shrinkFactor; - } - - double leafWidth = r * width; - if ( 2.0 * M_PI / step > 32 ) - leafWidth = 16; - - const double origin = qwtRadians( north ); - for ( double angle = origin; - angle < 2.0 * M_PI + origin; angle += step ) - { - const QPointF p = qwtPolar2Pos( center, r, angle ); - const QPointF p1 = qwtPolar2Pos( center, leafWidth, angle + M_PI_2 ); - const QPointF p2 = qwtPolar2Pos( center, leafWidth, angle - M_PI_2 ); - const QPointF p3 = qwtPolar2Pos( center, r, angle + step / 2.0 ); - const QPointF p4 = qwtPolar2Pos( center, r, angle - step / 2.0 ); - - QPainterPath darkPath; - darkPath.moveTo( center ); - darkPath.lineTo( p ); - darkPath.lineTo( qwtIntersection( center, p3, p1, p ) ); - - painter->setBrush( palette.brush( QPalette::Dark ) ); - painter->drawPath( darkPath ); - - QPainterPath lightPath; - lightPath.moveTo( center ); - lightPath.lineTo( p ); - lightPath.lineTo( qwtIntersection( center, p4, p2, p ) ); - - painter->setBrush( palette.brush( QPalette::Light ) ); - painter->drawPath( lightPath ); - } + if (j + k < numThornLevels) + r *= shrinkFactor; } - painter->restore(); + + double leafWidth = r * width; + if (2.0 * M_PI / step > 32) + leafWidth = 16; + + const double origin = qwtRadians(north); + for (double angle = origin; angle < 2.0 * M_PI + origin; angle += step) + { + const QPointF p = qwtPolar2Pos(center, r, angle); + const QPointF p1 = qwtPolar2Pos(center, leafWidth, angle + M_PI_2); + const QPointF p2 = qwtPolar2Pos(center, leafWidth, angle - M_PI_2); + const QPointF p3 = qwtPolar2Pos(center, r, angle + step / 2.0); + const QPointF p4 = qwtPolar2Pos(center, r, angle - step / 2.0); + + QPainterPath darkPath; + darkPath.moveTo(center); + darkPath.lineTo(p); + darkPath.lineTo(qwtIntersection(center, p3, p1, p)); + + painter->setBrush(palette.brush(QPalette::Dark)); + painter->drawPath(darkPath); + + QPainterPath lightPath; + lightPath.moveTo(center); + lightPath.lineTo(p); + lightPath.lineTo(qwtIntersection(center, p4, p2, p)); + + painter->setBrush(palette.brush(QPalette::Light)); + painter->drawPath(lightPath); + } + } + painter->restore(); } /*! @@ -229,14 +223,14 @@ void QwtSimpleCompassRose::drawRose( \param width Width */ -void QwtSimpleCompassRose::setWidth( double width ) +void QwtSimpleCompassRose::setWidth(double width) { - m_data->width = width; - if ( m_data->width < 0.03 ) - m_data->width = 0.03; + m_data->width = width; + if (m_data->width < 0.03) + m_data->width = 0.03; - if ( m_data->width > 0.4 ) - m_data->width = 0.4; + if (m_data->width > 0.4) + m_data->width = 0.4; } /*! @@ -245,7 +239,7 @@ void QwtSimpleCompassRose::setWidth( double width ) */ double QwtSimpleCompassRose::width() const { - return m_data->width; + return m_data->width; } /*! @@ -255,15 +249,15 @@ double QwtSimpleCompassRose::width() const \param numThorns Number of thorns \sa numThorns(), setNumThornLevels() */ -void QwtSimpleCompassRose::setNumThorns( int numThorns ) +void QwtSimpleCompassRose::setNumThorns(int numThorns) { - if ( numThorns < 4 ) - numThorns = 4; + if (numThorns < 4) + numThorns = 4; - if ( numThorns % 4 ) - numThorns += 4 - numThorns % 4; + if (numThorns % 4) + numThorns += 4 - numThorns % 4; - m_data->numThorns = numThorns; + m_data->numThorns = numThorns; } /*! @@ -272,7 +266,7 @@ void QwtSimpleCompassRose::setNumThorns( int numThorns ) */ int QwtSimpleCompassRose::numThorns() const { - return m_data->numThorns; + return m_data->numThorns; } /*! @@ -281,9 +275,9 @@ int QwtSimpleCompassRose::numThorns() const \param numThornLevels Number of thorns levels \sa setNumThorns(), numThornLevels() */ -void QwtSimpleCompassRose::setNumThornLevels( int numThornLevels ) +void QwtSimpleCompassRose::setNumThornLevels(int numThornLevels) { - m_data->numThornLevels = numThornLevels; + m_data->numThornLevels = numThornLevels; } /*! @@ -292,5 +286,5 @@ void QwtSimpleCompassRose::setNumThornLevels( int numThornLevels ) */ int QwtSimpleCompassRose::numThornLevels() const { - return m_data->numThornLevels; + return m_data->numThornLevels; } diff --git a/libs/qwt/src/qwt_compass_rose.h b/libs/qwt/src/qwt_compass_rose.h index a4f7f330..dcf188ec 100644 --- a/libs/qwt/src/qwt_compass_rose.h +++ b/libs/qwt/src/qwt_compass_rose.h @@ -20,30 +20,31 @@ class QPainter; */ class QWT_EXPORT QwtCompassRose { - public: - QwtCompassRose(); - virtual ~QwtCompassRose(); +public: + QwtCompassRose(); + virtual ~QwtCompassRose(); - virtual void setPalette( const QPalette& ); - const QPalette& palette() const; + virtual void setPalette(const QPalette &); + const QPalette &palette() const; - /*! - Draw the rose + /*! + Draw the rose - \param painter Painter - \param center Center point - \param radius Radius of the rose - \param north Position - \param colorGroup Color group - */ - virtual void draw( QPainter* painter, - const QPointF& center, double radius, double north, - QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0; + \param painter Painter + \param center Center point + \param radius Radius of the rose + \param north Position + \param colorGroup Color group + */ + virtual void draw(QPainter *painter, const QPointF ¢er, double radius, + double north, + QPalette::ColorGroup colorGroup = QPalette::Active) const + = 0; - private: - Q_DISABLE_COPY(QwtCompassRose) +private: + Q_DISABLE_COPY(QwtCompassRose) - QPalette m_palette; + QPalette m_palette; }; /*! @@ -51,33 +52,33 @@ class QWT_EXPORT QwtCompassRose */ class QWT_EXPORT QwtSimpleCompassRose : public QwtCompassRose { - public: - QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 ); - virtual ~QwtSimpleCompassRose(); +public: + QwtSimpleCompassRose(int numThorns = 8, int numThornLevels = -1); + virtual ~QwtSimpleCompassRose(); - void setWidth( double ); - double width() const; + void setWidth(double); + double width() const; - void setNumThorns( int ); - int numThorns() const; + void setNumThorns(int); + int numThorns() const; - void setNumThornLevels( int ); - int numThornLevels() const; + void setNumThornLevels(int); + int numThornLevels() const; - void setShrinkFactor( double factor ); - double shrinkFactor() const; + void setShrinkFactor(double factor); + double shrinkFactor() const; - virtual void draw( QPainter*, - const QPointF& center, double radius, double north, - QPalette::ColorGroup = QPalette::Active ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QPointF ¢er, double radius, + double north, + QPalette::ColorGroup = QPalette::Active) const QWT_OVERRIDE; - static void drawRose( QPainter*, const QPalette&, - const QPointF& center, double radius, double north, double width, - int numThorns, int numThornLevels, double shrinkFactor ); + static void drawRose(QPainter *, const QPalette &, const QPointF ¢er, + double radius, double north, double width, int numThorns, + int numThornLevels, double shrinkFactor); - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_counter.cpp b/libs/qwt/src/qwt_counter.cpp index e9be373f..ef570cab 100644 --- a/libs/qwt/src/qwt_counter.cpp +++ b/libs/qwt/src/qwt_counter.cpp @@ -20,35 +20,35 @@ class QwtCounter::PrivateData { - public: - PrivateData() - : minimum( 0.0 ) - , maximum( 0.0 ) - , singleStep( 1.0 ) - , isValid( false ) - , value( 0.0 ) - , wrapping( false ) - { - increment[Button1] = 1; - increment[Button2] = 10; - increment[Button3] = 100; - } +public: + PrivateData() + : minimum(0.0) + , maximum(0.0) + , singleStep(1.0) + , isValid(false) + , value(0.0) + , wrapping(false) + { + increment[Button1] = 1; + increment[Button2] = 10; + increment[Button3] = 100; + } - QwtArrowButton* buttonDown[ButtonCnt]; - QwtArrowButton* buttonUp[ButtonCnt]; - QLineEdit* valueEdit; + QwtArrowButton *buttonDown[ButtonCnt]; + QwtArrowButton *buttonUp[ButtonCnt]; + QLineEdit *valueEdit; - int increment[ButtonCnt]; - int numButtons; + int increment[ButtonCnt]; + int numButtons; - double minimum; - double maximum; - double singleStep; + double minimum; + double maximum; + double singleStep; - bool isValid; - double value; + bool isValid; + double value; - bool wrapping; + bool wrapping; }; /*! @@ -62,71 +62,68 @@ class QwtCounter::PrivateData \param parent */ -QwtCounter::QwtCounter( QWidget* parent ) - : QWidget( parent ) +QwtCounter::QwtCounter(QWidget *parent) + : QWidget(parent) { - initCounter(); + initCounter(); } void QwtCounter::initCounter() { - m_data = new PrivateData; + m_data = new PrivateData; - QHBoxLayout* layout = new QHBoxLayout( this ); - layout->setSpacing( 0 ); - layout->setContentsMargins( QMargins() ); + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setSpacing(0); + layout->setContentsMargins(QMargins()); - for ( int i = ButtonCnt - 1; i >= 0; i-- ) - { - QwtArrowButton* btn = - new QwtArrowButton( i + 1, Qt::DownArrow, this ); - btn->setFocusPolicy( Qt::NoFocus ); - layout->addWidget( btn ); + for (int i = ButtonCnt - 1; i >= 0; i--) + { + QwtArrowButton *btn = new QwtArrowButton(i + 1, Qt::DownArrow, this); + btn->setFocusPolicy(Qt::NoFocus); + layout->addWidget(btn); - connect( btn, SIGNAL(released()), SLOT(btnReleased()) ); - connect( btn, SIGNAL(clicked()), SLOT(btnClicked()) ); + connect(btn, SIGNAL(released()), SLOT(btnReleased())); + connect(btn, SIGNAL(clicked()), SLOT(btnClicked())); - m_data->buttonDown[i] = btn; - } + m_data->buttonDown[i] = btn; + } - m_data->valueEdit = new QLineEdit( this ); - m_data->valueEdit->setReadOnly( false ); - m_data->valueEdit->setValidator( new QDoubleValidator( m_data->valueEdit ) ); - layout->addWidget( m_data->valueEdit ); + m_data->valueEdit = new QLineEdit(this); + m_data->valueEdit->setReadOnly(false); + m_data->valueEdit->setValidator(new QDoubleValidator(m_data->valueEdit)); + layout->addWidget(m_data->valueEdit); - connect( m_data->valueEdit, SIGNAL(editingFinished()), SLOT(textChanged()) ); + connect(m_data->valueEdit, SIGNAL(editingFinished()), SLOT(textChanged())); - layout->setStretchFactor( m_data->valueEdit, 10 ); + layout->setStretchFactor(m_data->valueEdit, 10); - for ( int i = 0; i < ButtonCnt; i++ ) - { - QwtArrowButton* btn = - new QwtArrowButton( i + 1, Qt::UpArrow, this ); - btn->setFocusPolicy( Qt::NoFocus ); - layout->addWidget( btn ); + for (int i = 0; i < ButtonCnt; i++) + { + QwtArrowButton *btn = new QwtArrowButton(i + 1, Qt::UpArrow, this); + btn->setFocusPolicy(Qt::NoFocus); + layout->addWidget(btn); - connect( btn, SIGNAL(released()), SLOT(btnReleased()) ); - connect( btn, SIGNAL(clicked()), SLOT(btnClicked()) ); + connect(btn, SIGNAL(released()), SLOT(btnReleased())); + connect(btn, SIGNAL(clicked()), SLOT(btnClicked())); - m_data->buttonUp[i] = btn; - } + m_data->buttonUp[i] = btn; + } - setNumButtons( 2 ); - setRange( 0.0, 1.0 ); - setSingleStep( 0.001 ); - setValue( 0.0 ); + setNumButtons(2); + setRange(0.0, 1.0); + setSingleStep(0.001); + setValue(0.0); - setSizePolicy( - QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) ); + setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); - setFocusProxy( m_data->valueEdit ); - setFocusPolicy( Qt::StrongFocus ); + setFocusProxy(m_data->valueEdit); + setFocusPolicy(Qt::StrongFocus); } //! Destructor QwtCounter::~QwtCounter() { - delete m_data; + delete m_data; } /*! @@ -139,24 +136,24 @@ QwtCounter::~QwtCounter() \sa setValue(), isValid() */ -void QwtCounter::setValid( bool on ) +void QwtCounter::setValid(bool on) { - if ( on != m_data->isValid ) + if (on != m_data->isValid) + { + m_data->isValid = on; + + updateButtons(); + + if (m_data->isValid) { - m_data->isValid = on; - - updateButtons(); - - if ( m_data->isValid ) - { - showNumber( value() ); - Q_EMIT valueChanged( value() ); - } - else - { - m_data->valueEdit->setText( QString() ); - } + showNumber(value()); + Q_EMIT valueChanged(value()); } + else + { + m_data->valueEdit->setText(QString()); + } + } } /*! @@ -165,7 +162,7 @@ void QwtCounter::setValid( bool on ) */ bool QwtCounter::isValid() const { - return m_data->isValid; + return m_data->isValid; } /*! @@ -174,9 +171,9 @@ bool QwtCounter::isValid() const \param on True disable editing \sa isReadOnly() */ -void QwtCounter::setReadOnly( bool on ) +void QwtCounter::setReadOnly(bool on) { - m_data->valueEdit->setReadOnly( on ); + m_data->valueEdit->setReadOnly(on); } /*! @@ -185,7 +182,7 @@ void QwtCounter::setReadOnly( bool on ) */ bool QwtCounter::isReadOnly() const { - return m_data->valueEdit->isReadOnly(); + return m_data->valueEdit->isReadOnly(); } /*! @@ -199,23 +196,23 @@ bool QwtCounter::isReadOnly() const \warning The value is clipped when it lies outside the range. */ -void QwtCounter::setValue( double value ) +void QwtCounter::setValue(double value) { - const double vmin = qwtMinF( m_data->minimum, m_data->maximum ); - const double vmax = qwtMaxF( m_data->minimum, m_data->maximum ); + const double vmin = qwtMinF(m_data->minimum, m_data->maximum); + const double vmax = qwtMaxF(m_data->minimum, m_data->maximum); - value = qBound( vmin, value, vmax ); + value = qBound(vmin, value, vmax); - if ( !m_data->isValid || value != m_data->value ) - { - m_data->isValid = true; - m_data->value = value; + if (!m_data->isValid || value != m_data->value) + { + m_data->isValid = true; + m_data->value = value; - showNumber( value ); - updateButtons(); + showNumber(value); + updateButtons(); - Q_EMIT valueChanged( value ); - } + Q_EMIT valueChanged(value); + } } /*! @@ -224,7 +221,7 @@ void QwtCounter::setValue( double value ) */ double QwtCounter::value() const { - return m_data->value; + return m_data->value; } /*! @@ -238,32 +235,32 @@ double QwtCounter::value() const \sa minimum(), maximum() */ -void QwtCounter::setRange( double min, double max ) +void QwtCounter::setRange(double min, double max) { - max = qwtMaxF( min, max ); + max = qwtMaxF(min, max); - if ( m_data->maximum == max && m_data->minimum == min ) - return; + if (m_data->maximum == max && m_data->minimum == min) + return; - m_data->minimum = min; - m_data->maximum = max; + m_data->minimum = min; + m_data->maximum = max; - setSingleStep( singleStep() ); + setSingleStep(singleStep()); - const double value = qBound( min, m_data->value, max ); + const double value = qBound(min, m_data->value, max); - if ( value != m_data->value ) + if (value != m_data->value) + { + m_data->value = value; + + if (m_data->isValid) { - m_data->value = value; - - if ( m_data->isValid ) - { - showNumber( value ); - Q_EMIT valueChanged( value ); - } + showNumber(value); + Q_EMIT valueChanged(value); } + } - updateButtons(); + updateButtons(); } /*! @@ -272,11 +269,12 @@ void QwtCounter::setRange( double min, double max ) \param value Minimum value \sa setRange(), setMaximum(), minimum() - \note The maximum is adjusted if necessary to ensure that the range remains valid. + \note The maximum is adjusted if necessary to ensure that the range remains + valid. */ -void QwtCounter::setMinimum( double value ) +void QwtCounter::setMinimum(double value) { - setRange( value, maximum() ); + setRange(value, maximum()); } /*! @@ -285,7 +283,7 @@ void QwtCounter::setMinimum( double value ) */ double QwtCounter::minimum() const { - return m_data->minimum; + return m_data->minimum; } /*! @@ -294,9 +292,9 @@ double QwtCounter::minimum() const \param value Maximum value \sa setRange(), setMinimum(), maximum() */ -void QwtCounter::setMaximum( double value ) +void QwtCounter::setMaximum(double value) { - setRange( minimum(), value ); + setRange(minimum(), value); } /*! @@ -305,7 +303,7 @@ void QwtCounter::setMaximum( double value ) */ double QwtCounter::maximum() const { - return m_data->maximum; + return m_data->maximum; } /*! @@ -316,9 +314,9 @@ double QwtCounter::maximum() const \param stepSize Single step size \sa singleStep() */ -void QwtCounter::setSingleStep( double stepSize ) +void QwtCounter::setSingleStep(double stepSize) { - m_data->singleStep = qwtMaxF( stepSize, 0.0 ); + m_data->singleStep = qwtMaxF(stepSize, 0.0); } /*! @@ -327,7 +325,7 @@ void QwtCounter::setSingleStep( double stepSize ) */ double QwtCounter::singleStep() const { - return m_data->singleStep; + return m_data->singleStep; } /*! @@ -339,9 +337,9 @@ double QwtCounter::singleStep() const \param on En/Disable wrapping \sa wrapping() */ -void QwtCounter::setWrapping( bool on ) +void QwtCounter::setWrapping(bool on) { - m_data->wrapping = on; + m_data->wrapping = on; } /*! @@ -350,7 +348,7 @@ void QwtCounter::setWrapping( bool on ) */ bool QwtCounter::wrapping() const { - return m_data->wrapping; + return m_data->wrapping; } /*! @@ -359,26 +357,26 @@ bool QwtCounter::wrapping() const \param numButtons Number of buttons \sa numButtons() */ -void QwtCounter::setNumButtons( int numButtons ) +void QwtCounter::setNumButtons(int numButtons) { - if ( numButtons < 0 || numButtons > QwtCounter::ButtonCnt ) - return; + if (numButtons < 0 || numButtons > QwtCounter::ButtonCnt) + return; - for ( int i = 0; i < QwtCounter::ButtonCnt; i++ ) + for (int i = 0; i < QwtCounter::ButtonCnt; i++) + { + if (i < numButtons) { - if ( i < numButtons ) - { - m_data->buttonDown[i]->show(); - m_data->buttonUp[i]->show(); - } - else - { - m_data->buttonDown[i]->hide(); - m_data->buttonUp[i]->hide(); - } + m_data->buttonDown[i]->show(); + m_data->buttonUp[i]->show(); } + else + { + m_data->buttonDown[i]->hide(); + m_data->buttonUp[i]->hide(); + } + } - m_data->numButtons = numButtons; + m_data->numButtons = numButtons; } /*! @@ -387,7 +385,7 @@ void QwtCounter::setNumButtons( int numButtons ) */ int QwtCounter::numButtons() const { - return m_data->numButtons; + return m_data->numButtons; } /*! @@ -400,10 +398,10 @@ int QwtCounter::numButtons() const \sa incSteps() */ -void QwtCounter::setIncSteps( QwtCounter::Button button, int numSteps ) +void QwtCounter::setIncSteps(QwtCounter::Button button, int numSteps) { - if ( button >= 0 && button < QwtCounter::ButtonCnt ) - m_data->increment[ button ] = numSteps; + if (button >= 0 && button < QwtCounter::ButtonCnt) + m_data->increment[button] = numSteps; } /*! @@ -413,68 +411,67 @@ void QwtCounter::setIncSteps( QwtCounter::Button button, int numSteps ) \sa setIncSteps() */ -int QwtCounter::incSteps( QwtCounter::Button button ) const +int QwtCounter::incSteps(QwtCounter::Button button) const { - if ( button >= 0 && button < QwtCounter::ButtonCnt ) - return m_data->increment[ button ]; + if (button >= 0 && button < QwtCounter::ButtonCnt) + return m_data->increment[button]; - return 0; + return 0; } - /*! Set the number of increment steps for button 1 \param nSteps Number of steps */ -void QwtCounter::setStepButton1( int nSteps ) +void QwtCounter::setStepButton1(int nSteps) { - setIncSteps( QwtCounter::Button1, nSteps ); + setIncSteps(QwtCounter::Button1, nSteps); } //! returns the number of increment steps for button 1 int QwtCounter::stepButton1() const { - return incSteps( QwtCounter::Button1 ); + return incSteps(QwtCounter::Button1); } /*! Set the number of increment steps for button 2 \param nSteps Number of steps */ -void QwtCounter::setStepButton2( int nSteps ) +void QwtCounter::setStepButton2(int nSteps) { - setIncSteps( QwtCounter::Button2, nSteps ); + setIncSteps(QwtCounter::Button2, nSteps); } //! returns the number of increment steps for button 2 int QwtCounter::stepButton2() const { - return incSteps( QwtCounter::Button2 ); + return incSteps(QwtCounter::Button2); } /*! Set the number of increment steps for button 3 \param nSteps Number of steps */ -void QwtCounter::setStepButton3( int nSteps ) +void QwtCounter::setStepButton3(int nSteps) { - setIncSteps( QwtCounter::Button3, nSteps ); + setIncSteps(QwtCounter::Button3, nSteps); } //! returns the number of increment steps for button 3 int QwtCounter::stepButton3() const { - return incSteps( QwtCounter::Button3 ); + return incSteps(QwtCounter::Button3); } //! Set from lineedit void QwtCounter::textChanged() { - bool converted = false; + bool converted = false; - const double value = m_data->valueEdit->text().toDouble( &converted ); - if ( converted ) - setValue( value ); + const double value = m_data->valueEdit->text().toDouble(&converted); + if (converted) + setValue(value); } /*! @@ -482,21 +479,21 @@ void QwtCounter::textChanged() \param event Event \return see QWidget::event() */ -bool QwtCounter::event( QEvent* event ) +bool QwtCounter::event(QEvent *event) { - if ( event->type() == QEvent::PolishRequest ) + if (event->type() == QEvent::PolishRequest) + { + const QFontMetrics fm = m_data->valueEdit->fontMetrics(); + + const int w = QwtPainter::horizontalAdvance(fm, "W") + 8; + for (int i = 0; i < ButtonCnt; i++) { - const QFontMetrics fm = m_data->valueEdit->fontMetrics(); - - const int w = QwtPainter::horizontalAdvance( fm, "W" ) + 8; - for ( int i = 0; i < ButtonCnt; i++ ) - { - m_data->buttonDown[i]->setMinimumWidth( w ); - m_data->buttonUp[i]->setMinimumWidth( w ); - } + m_data->buttonDown[i]->setMinimumWidth(w); + m_data->buttonUp[i]->setMinimumWidth(w); } + } - return QWidget::event( event ); + return QWidget::event(event); } /*! @@ -521,176 +518,168 @@ bool QwtCounter::event( QEvent* event ) \param event Key event */ -void QwtCounter::keyPressEvent ( QKeyEvent* event ) +void QwtCounter::keyPressEvent(QKeyEvent *event) { - bool accepted = true; + bool accepted = true; - switch ( event->key() ) - { - case Qt::Key_Home: - { - if ( event->modifiers() & Qt::ControlModifier ) - setValue( minimum() ); - else - accepted = false; - break; - } - case Qt::Key_End: - { - if ( event->modifiers() & Qt::ControlModifier ) - setValue( maximum() ); - else - accepted = false; - break; - } - case Qt::Key_Up: - { - incrementValue( m_data->increment[0] ); - break; - } - case Qt::Key_Down: - { - incrementValue( -m_data->increment[0] ); - break; - } - case Qt::Key_PageUp: - case Qt::Key_PageDown: - { - int increment = m_data->increment[0]; - if ( m_data->numButtons >= 2 ) - increment = m_data->increment[1]; - if ( m_data->numButtons >= 3 ) - { - if ( event->modifiers() & Qt::ShiftModifier ) - increment = m_data->increment[2]; - } - if ( event->key() == Qt::Key_PageDown ) - increment = -increment; - incrementValue( increment ); - break; - } - default: - { - accepted = false; - } + switch (event->key()) + { + case Qt::Key_Home: { + if (event->modifiers() & Qt::ControlModifier) + setValue(minimum()); + else + accepted = false; + break; } - - if ( accepted ) - { - event->accept(); - return; + case Qt::Key_End: { + if (event->modifiers() & Qt::ControlModifier) + setValue(maximum()); + else + accepted = false; + break; } + case Qt::Key_Up: { + incrementValue(m_data->increment[0]); + break; + } + case Qt::Key_Down: { + incrementValue(-m_data->increment[0]); + break; + } + case Qt::Key_PageUp: + case Qt::Key_PageDown: { + int increment = m_data->increment[0]; + if (m_data->numButtons >= 2) + increment = m_data->increment[1]; + if (m_data->numButtons >= 3) + { + if (event->modifiers() & Qt::ShiftModifier) + increment = m_data->increment[2]; + } + if (event->key() == Qt::Key_PageDown) + increment = -increment; + incrementValue(increment); + break; + } + default: { + accepted = false; + } + } - QWidget::keyPressEvent ( event ); + if (accepted) + { + event->accept(); + return; + } + + QWidget::keyPressEvent(event); } /*! Handle wheel events \param event Wheel event */ -void QwtCounter::wheelEvent( QWheelEvent* event ) +void QwtCounter::wheelEvent(QWheelEvent *event) { - event->accept(); + event->accept(); - if ( m_data->numButtons <= 0 ) - return; + if (m_data->numButtons <= 0) + return; - int increment = m_data->increment[0]; - if ( m_data->numButtons >= 2 ) - { - if ( event->modifiers() & Qt::ControlModifier ) - increment = m_data->increment[1]; - } - if ( m_data->numButtons >= 3 ) - { - if ( event->modifiers() & Qt::ShiftModifier ) - increment = m_data->increment[2]; - } + int increment = m_data->increment[0]; + if (m_data->numButtons >= 2) + { + if (event->modifiers() & Qt::ControlModifier) + increment = m_data->increment[1]; + } + if (m_data->numButtons >= 3) + { + if (event->modifiers() & Qt::ShiftModifier) + increment = m_data->increment[2]; + } #if QT_VERSION < 0x050e00 - const QPoint wheelPos = event->pos(); - const int wheelDelta = event->delta(); + const QPoint wheelPos = event->pos(); + const int wheelDelta = event->delta(); #else - const QPoint wheelPos = event->position().toPoint(); + const QPoint wheelPos = event->position().toPoint(); - const QPoint delta = event->angleDelta(); - const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) ) - ? delta.x() : delta.y(); + const QPoint delta = event->angleDelta(); + const int wheelDelta + = (qAbs(delta.x()) > qAbs(delta.y())) ? delta.x() : delta.y(); #endif - for ( int i = 0; i < m_data->numButtons; i++ ) + for (int i = 0; i < m_data->numButtons; i++) + { + if (m_data->buttonDown[i]->geometry().contains(wheelPos) + || m_data->buttonUp[i]->geometry().contains(wheelPos)) { - if ( m_data->buttonDown[i]->geometry().contains( wheelPos ) || - m_data->buttonUp[i]->geometry().contains( wheelPos ) ) - { - increment = m_data->increment[i]; - } + increment = m_data->increment[i]; } + } - incrementValue( wheelDelta / 120 * increment ); + incrementValue(wheelDelta / 120 * increment); } -void QwtCounter::incrementValue( int numSteps ) +void QwtCounter::incrementValue(int numSteps) { - const double min = m_data->minimum; - const double max = m_data->maximum; - double stepSize = m_data->singleStep; - - if ( !m_data->isValid || min >= max || stepSize <= 0.0 ) - return; + const double min = m_data->minimum; + const double max = m_data->maximum; + double stepSize = m_data->singleStep; + if (!m_data->isValid || min >= max || stepSize <= 0.0) + return; #if 1 - stepSize = qwtMaxF( stepSize, 1.0e-10 * ( max - min ) ); + stepSize = qwtMaxF(stepSize, 1.0e-10 * (max - min)); #endif - double value = m_data->value + numSteps * stepSize; + double value = m_data->value + numSteps * stepSize; - if ( m_data->wrapping ) + if (m_data->wrapping) + { + const double range = max - min; + + if (value < min) { - const double range = max - min; - - if ( value < min ) - { - value += std::ceil( ( min - value ) / range ) * range; - } - else if ( value > max ) - { - value -= std::ceil( ( value - max ) / range ) * range; - } + value += std::ceil((min - value) / range) * range; } - else + else if (value > max) { - value = qBound( min, value, max ); + value -= std::ceil((value - max) / range) * range; } + } + else + { + value = qBound(min, value, max); + } - value = min + qRound( ( value - min ) / stepSize ) * stepSize; + value = min + qRound((value - min) / stepSize) * stepSize; - if ( stepSize > 1e-12 ) + if (stepSize > 1e-12) + { + if (qFuzzyCompare(value + 1.0, 1.0)) { - if ( qFuzzyCompare( value + 1.0, 1.0 ) ) - { - // correct rounding error if value = 0 - value = 0.0; - } - else if ( qFuzzyCompare( value, max ) ) - { - // correct rounding error at the border - value = max; - } + // correct rounding error if value = 0 + value = 0.0; } - - if ( value != m_data->value ) + else if (qFuzzyCompare(value, max)) { - m_data->value = value; - showNumber( m_data->value ); - updateButtons(); - - Q_EMIT valueChanged( m_data->value ); + // correct rounding error at the border + value = max; } + } + + if (value != m_data->value) + { + m_data->value = value; + showNumber(m_data->value); + updateButtons(); + + Q_EMIT valueChanged(m_data->value); + } } - /*! \brief Update buttons according to the current value @@ -701,94 +690,94 @@ void QwtCounter::incrementValue( int numSteps ) */ void QwtCounter::updateButtons() { - if ( m_data->isValid ) - { - // 1. save enabled state of the smallest down- and up-button - // 2. change enabled state on under- or over-flow + if (m_data->isValid) + { + // 1. save enabled state of the smallest down- and up-button + // 2. change enabled state on under- or over-flow - for ( int i = 0; i < QwtCounter::ButtonCnt; i++ ) - { - m_data->buttonDown[i]->setEnabled( value() > minimum() ); - m_data->buttonUp[i]->setEnabled( value() < maximum() ); - } - } - else + for (int i = 0; i < QwtCounter::ButtonCnt; i++) { - for ( int i = 0; i < QwtCounter::ButtonCnt; i++ ) - { - m_data->buttonDown[i]->setEnabled( false ); - m_data->buttonUp[i]->setEnabled( false ); - } + m_data->buttonDown[i]->setEnabled(value() > minimum()); + m_data->buttonUp[i]->setEnabled(value() < maximum()); } + } + else + { + for (int i = 0; i < QwtCounter::ButtonCnt; i++) + { + m_data->buttonDown[i]->setEnabled(false); + m_data->buttonUp[i]->setEnabled(false); + } + } } /*! Display number string \param number Number */ -void QwtCounter::showNumber( double number ) +void QwtCounter::showNumber(double number) { - QString text; - text.setNum( number ); + QString text; + text.setNum(number); - const int cursorPos = m_data->valueEdit->cursorPosition(); - m_data->valueEdit->setText( text ); - m_data->valueEdit->setCursorPosition( cursorPos ); + const int cursorPos = m_data->valueEdit->cursorPosition(); + m_data->valueEdit->setText(text); + m_data->valueEdit->setCursorPosition(cursorPos); } //! Button clicked void QwtCounter::btnClicked() { - for ( int i = 0; i < ButtonCnt; i++ ) - { - if ( m_data->buttonUp[i] == sender() ) - incrementValue( m_data->increment[i] ); + for (int i = 0; i < ButtonCnt; i++) + { + if (m_data->buttonUp[i] == sender()) + incrementValue(m_data->increment[i]); - if ( m_data->buttonDown[i] == sender() ) - incrementValue( -m_data->increment[i] ); - } + if (m_data->buttonDown[i] == sender()) + incrementValue(-m_data->increment[i]); + } } //! Button released void QwtCounter::btnReleased() { - Q_EMIT buttonReleased( value() ); + Q_EMIT buttonReleased(value()); } //! A size hint QSize QwtCounter::sizeHint() const { - QString tmp; + QString tmp; - int w = tmp.setNum( minimum() ).length(); - int w1 = tmp.setNum( maximum() ).length(); - if ( w1 > w ) - w = w1; - w1 = tmp.setNum( minimum() + singleStep() ).length(); - if ( w1 > w ) - w = w1; - w1 = tmp.setNum( maximum() - singleStep() ).length(); - if ( w1 > w ) - w = w1; + int w = tmp.setNum(minimum()).length(); + int w1 = tmp.setNum(maximum()).length(); + if (w1 > w) + w = w1; + w1 = tmp.setNum(minimum() + singleStep()).length(); + if (w1 > w) + w = w1; + w1 = tmp.setNum(maximum() - singleStep()).length(); + if (w1 > w) + w = w1; - tmp.fill( '9', w ); + tmp.fill('9', w); - w = QwtPainter::horizontalAdvance( m_data->valueEdit->fontMetrics(), tmp ) + 2; + w = QwtPainter::horizontalAdvance(m_data->valueEdit->fontMetrics(), tmp) + 2; - if ( m_data->valueEdit->hasFrame() ) - w += 2 * style()->pixelMetric( QStyle::PM_DefaultFrameWidth ); + if (m_data->valueEdit->hasFrame()) + w += 2 * style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - // Now we replace default sizeHint contribution of m_data->valueEdit by - // what we really need. + // Now we replace default sizeHint contribution of m_data->valueEdit by + // what we really need. - w += QWidget::sizeHint().width() - m_data->valueEdit->sizeHint().width(); + w += QWidget::sizeHint().width() - m_data->valueEdit->sizeHint().width(); - const int h = qMin( QWidget::sizeHint().height(), - m_data->valueEdit->minimumSizeHint().height() ); + const int h = qMin(QWidget::sizeHint().height(), + m_data->valueEdit->minimumSizeHint().height()); - return QSize( w, h ); + return QSize(w, h); } #if QWT_MOC_INCLUDE -#include "moc_qwt_counter.cpp" +# include "moc_qwt_counter.cpp" #endif diff --git a/libs/qwt/src/qwt_counter.h b/libs/qwt/src/qwt_counter.h index 4d0577f9..5fa7a0b5 100644 --- a/libs/qwt/src/qwt_counter.h +++ b/libs/qwt/src/qwt_counter.h @@ -39,123 +39,124 @@ counter->setSingleStep( 1.0 ); // Step size 1.0 counter->setNumButtons(2); // Two buttons each side counter->setIncSteps(QwtCounter::Button1, 1); // Button 1 increments 1 step - counter->setIncSteps(QwtCounter::Button2, 20); // Button 2 increments 20 steps + counter->setIncSteps(QwtCounter::Button2, 20); // Button 2 increments 20 + steps - connect(counter, SIGNAL(valueChanged(double)), myClass, SLOT(newValue(double))); - \endcode + connect(counter, SIGNAL(valueChanged(double)), myClass, + SLOT(newValue(double))); \endcode */ class QWT_EXPORT QwtCounter : public QWidget { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true ) - Q_PROPERTY( double minimum READ minimum WRITE setMinimum ) - Q_PROPERTY( double maximum READ maximum WRITE setMaximum ) - Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep ) + Q_PROPERTY( + double value READ value WRITE setValue NOTIFY valueChanged USER true) + Q_PROPERTY(double minimum READ minimum WRITE setMinimum) + Q_PROPERTY(double maximum READ maximum WRITE setMaximum) + Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep) - Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons ) - Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 ) - Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 ) - Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 ) + Q_PROPERTY(int numButtons READ numButtons WRITE setNumButtons) + Q_PROPERTY(int stepButton1 READ stepButton1 WRITE setStepButton1) + Q_PROPERTY(int stepButton2 READ stepButton2 WRITE setStepButton2) + Q_PROPERTY(int stepButton3 READ stepButton3 WRITE setStepButton3) - Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly ) - Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping ) + Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) + Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping) - public: - //! Button index - enum Button - { - //! Button intended for minor steps - Button1, +public: + //! Button index + enum Button + { + //! Button intended for minor steps + Button1, - //! Button intended for medium steps - Button2, + //! Button intended for medium steps + Button2, - //! Button intended for large steps - Button3, + //! Button intended for large steps + Button3, - //! Number of buttons - ButtonCnt - }; + //! Number of buttons + ButtonCnt + }; - explicit QwtCounter( QWidget* parent = NULL ); - virtual ~QwtCounter(); + explicit QwtCounter(QWidget *parent = NULL); + virtual ~QwtCounter(); - void setValid( bool ); - bool isValid() const; + void setValid(bool); + bool isValid() const; - void setWrapping( bool ); - bool wrapping() const; + void setWrapping(bool); + bool wrapping() const; - bool isReadOnly() const; - void setReadOnly( bool ); + bool isReadOnly() const; + void setReadOnly(bool); - void setNumButtons( int ); - int numButtons() const; + void setNumButtons(int); + int numButtons() const; - void setIncSteps( QwtCounter::Button, int numSteps ); - int incSteps( QwtCounter::Button ) const; + void setIncSteps(QwtCounter::Button, int numSteps); + int incSteps(QwtCounter::Button) const; - virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; - double singleStep() const; - void setSingleStep( double stepSize ); + double singleStep() const; + void setSingleStep(double stepSize); - void setRange( double min, double max ); + void setRange(double min, double max); - double minimum() const; - void setMinimum( double ); + double minimum() const; + void setMinimum(double); - double maximum() const; - void setMaximum( double ); + double maximum() const; + void setMaximum(double); - void setStepButton1( int nSteps ); - int stepButton1() const; + void setStepButton1(int nSteps); + int stepButton1() const; - void setStepButton2( int nSteps ); - int stepButton2() const; + void setStepButton2(int nSteps); + int stepButton2() const; - void setStepButton3( int nSteps ); - int stepButton3() const; + void setStepButton3(int nSteps); + int stepButton3() const; - double value() const; + double value() const; - public Q_SLOTS: - void setValue( double ); +public Q_SLOTS: + void setValue(double); +Q_SIGNALS: + /*! + This signal is emitted when a button has been released + \param value The new value + */ + void buttonReleased(double value); - Q_SIGNALS: - /*! - This signal is emitted when a button has been released - \param value The new value - */ - void buttonReleased ( double value ); + /*! + This signal is emitted when the counter's value has changed + \param value The new value + */ + void valueChanged(double value); - /*! - This signal is emitted when the counter's value has changed - \param value The new value - */ - void valueChanged ( double value ); +protected: + virtual bool event(QEvent *) QWT_OVERRIDE; + virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE; - protected: - virtual bool event( QEvent* ) QWT_OVERRIDE; - virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE; - virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE; +private Q_SLOTS: + void btnReleased(); + void btnClicked(); + void textChanged(); - private Q_SLOTS: - void btnReleased(); - void btnClicked(); - void textChanged(); +private: + void incrementValue(int numSteps); + void initCounter(); + void updateButtons(); + void showNumber(double); - private: - void incrementValue( int numSteps ); - void initCounter(); - void updateButtons(); - void showNumber( double ); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_curve_fitter.cpp b/libs/qwt/src/qwt_curve_fitter.cpp index 3e80f69f..0e4649d8 100644 --- a/libs/qwt/src/qwt_curve_fitter.cpp +++ b/libs/qwt/src/qwt_curve_fitter.cpp @@ -13,18 +13,16 @@ Constructor \param mode Preferred fitting mode */ -QwtCurveFitter::QwtCurveFitter( Mode mode ) - : m_mode( mode ) +QwtCurveFitter::QwtCurveFitter(Mode mode) + : m_mode(mode) { } //! Destructor -QwtCurveFitter::~QwtCurveFitter() -{ -} +QwtCurveFitter::~QwtCurveFitter() {} //! \return Preferred fitting mode QwtCurveFitter::Mode QwtCurveFitter::mode() const { - return m_mode; + return m_mode; } diff --git a/libs/qwt/src/qwt_curve_fitter.h b/libs/qwt/src/qwt_curve_fitter.h index 1dba67f9..8b0ba21a 100644 --- a/libs/qwt/src/qwt_curve_fitter.h +++ b/libs/qwt/src/qwt_curve_fitter.h @@ -20,65 +20,65 @@ class QPolygonF; */ class QWT_EXPORT QwtCurveFitter { - public: +public: + /*! + \brief Preferred mode of the fitting algorithm + + Even if a QPainterPath can always be created from a QPolygonF + the overhead of the conversion can be avoided by indicating + the preference of the implementation to the application + code. + */ + enum Mode + { /*! - \brief Preferred mode of the fitting algorithm + The fitting algorithm creates a polygon - the implementation + of fitCurvePath() simply wraps the polygon into a path. - Even if a QPainterPath can always be created from a QPolygonF - the overhead of the conversion can be avoided by indicating - the preference of the implementation to the application - code. + \sa QwtWeedingCurveFitter */ - enum Mode - { - /*! - The fitting algorithm creates a polygon - the implementation - of fitCurvePath() simply wraps the polygon into a path. - - \sa QwtWeedingCurveFitter - */ - Polygon, - - /*! - The fitting algorithm creates a painter path - the implementation - of fitCurve() extracts a polygon from the path. - - \sa QwtSplineCurveFitter - */ - Path - }; - - virtual ~QwtCurveFitter(); - - Mode mode() const; + Polygon, /*! - Find a curve which has the best fit to a series of data points + The fitting algorithm creates a painter path - the implementation + of fitCurve() extracts a polygon from the path. - \param polygon Series of data points - \return Curve points - - \sa fitCurvePath() + \sa QwtSplineCurveFitter */ - virtual QPolygonF fitCurve( const QPolygonF& polygon ) const = 0; + Path + }; - /*! - Find a curve path which has the best fit to a series of data points + virtual ~QwtCurveFitter(); - \param polygon Series of data points - \return Curve path + Mode mode() const; - \sa fitCurve() - */ - virtual QPainterPath fitCurvePath( const QPolygonF& polygon ) const = 0; + /*! + Find a curve which has the best fit to a series of data points - protected: - explicit QwtCurveFitter( Mode mode ); + \param polygon Series of data points + \return Curve points - private: - Q_DISABLE_COPY(QwtCurveFitter) + \sa fitCurvePath() + */ + virtual QPolygonF fitCurve(const QPolygonF &polygon) const = 0; - const Mode m_mode; + /*! + Find a curve path which has the best fit to a series of data points + + \param polygon Series of data points + \return Curve path + + \sa fitCurve() + */ + virtual QPainterPath fitCurvePath(const QPolygonF &polygon) const = 0; + +protected: + explicit QwtCurveFitter(Mode mode); + +private: + Q_DISABLE_COPY(QwtCurveFitter) + + const Mode m_mode; }; #endif diff --git a/libs/qwt/src/qwt_date.cpp b/libs/qwt/src/qwt_date.cpp index 9f086e2d..0fb3420a 100644 --- a/libs/qwt/src/qwt_date.cpp +++ b/libs/qwt/src/qwt_date.cpp @@ -18,8 +18,8 @@ #if QT_VERSION >= 0x050000 typedef qint64 QwtJulianDay; -static const QwtJulianDay minJulianDayD = Q_INT64_C( -784350574879 ); -static const QwtJulianDay maxJulianDayD = Q_INT64_C( 784354017364 ); +static const QwtJulianDay minJulianDayD = Q_INT64_C(-784350574879); +static const QwtJulianDay maxJulianDayD = Q_INT64_C(784354017364); #else @@ -29,157 +29,154 @@ static const QwtJulianDay maxJulianDayD = Q_INT64_C( 784354017364 ); typedef int QwtJulianDay; static const QwtJulianDay minJulianDayD = 1; -static const QwtJulianDay maxJulianDayD = std::numeric_limits< int >::max(); +static const QwtJulianDay maxJulianDayD = std::numeric_limits::max(); #endif -static QString qwtExpandedFormat( const QString& format, - const QDateTime& dateTime, QwtDate::Week0Type week0Type ) +static QString qwtExpandedFormat(const QString &format, + const QDateTime &dateTime, + QwtDate::Week0Type week0Type) { - const int week = QwtDate::weekNumber( dateTime.date(), week0Type ); + const int week = QwtDate::weekNumber(dateTime.date(), week0Type); - QString weekNo; - weekNo.setNum( week ); + QString weekNo; + weekNo.setNum(week); - QString weekNoWW; - if ( weekNo.length() == 1 ) - weekNoWW += QLatin1Char( '0' ); + QString weekNoWW; + if (weekNo.length() == 1) + weekNoWW += QLatin1Char('0'); - weekNoWW += weekNo; + weekNoWW += weekNo; - QString fmt = format; - fmt.replace( QLatin1String( "ww" ), weekNoWW ); - fmt.replace( QLatin1Char( 'w' ), weekNo ); + QString fmt = format; + fmt.replace(QLatin1String("ww"), weekNoWW); + fmt.replace(QLatin1Char('w'), weekNo); - if ( week == 1 && dateTime.date().month() != 1 ) + if (week == 1 && dateTime.date().month() != 1) + { + // in case of week 1, we might need to increment the year + + QLatin1String s_yyyy("yyyy"); + QLatin1String s_yy("yy"); + + // week 1 might start in the previous year + + bool doReplaceYear = fmt.contains(s_yy); + + if (doReplaceYear) { - // in case of week 1, we might need to increment the year + if (fmt.contains('M')) + { + // in case of also having 'M' we have a conflict about + // which year to show - QLatin1String s_yyyy( "yyyy" ); - QLatin1String s_yy( "yy" ); + doReplaceYear = false; + } + else + { + // in case of also having 'd' or 'dd' we have a conflict about + // which year to show - // week 1 might start in the previous year + int numD = 0; - bool doReplaceYear = fmt.contains( s_yy ); - - if ( doReplaceYear ) + for (int i = 0; i < fmt.size(); i++) { - if ( fmt.contains( 'M' ) ) - { - // in case of also having 'M' we have a conflict about - // which year to show + if (fmt[i] == 'd') + { + numD++; + } + else + { + if (numD > 0 && numD <= 2) + break; - doReplaceYear = false; - } - else - { - // in case of also having 'd' or 'dd' we have a conflict about - // which year to show - - int numD = 0; - - for ( int i = 0; i < fmt.size(); i++ ) - { - if ( fmt[i] == 'd' ) - { - numD++; - } - else - { - if ( numD > 0 && numD <= 2 ) - break; - - numD = 0; - } - } - - if ( numD > 0 && numD <= 2 ) - doReplaceYear = false; - } + numD = 0; + } } - if ( doReplaceYear ) - { - const QDate dt( dateTime.date().year() + 1, 1, 1 ); - const QString dtString = QLocale().toString( dt, s_yyyy ); - - if ( fmt.contains( s_yyyy ) ) - { - fmt.replace( s_yyyy, dtString ); - } - else - { - fmt.replace( s_yy, dtString ); - } - } + if (numD > 0 && numD <= 2) + doReplaceYear = false; + } } - return fmt; + if (doReplaceYear) + { + const QDate dt(dateTime.date().year() + 1, 1, 1); + const QString dtString = QLocale().toString(dt, s_yyyy); + + if (fmt.contains(s_yyyy)) + { + fmt.replace(s_yyyy, dtString); + } + else + { + fmt.replace(s_yy, dtString); + } + } + } + + return fmt; } static inline Qt::DayOfWeek qwtFirstDayOfWeek() { - return QLocale().firstDayOfWeek(); + return QLocale().firstDayOfWeek(); } -static inline void qwtFloorTime( - QwtDate::IntervalType intervalType, QDateTime& dt ) +static inline void qwtFloorTime(QwtDate::IntervalType intervalType, + QDateTime &dt) { - // when dt is inside the special hour where DST is ending - // an hour is no unique. Therefore we have to - // use UTC time. + // when dt is inside the special hour where DST is ending + // an hour is no unique. Therefore we have to + // use UTC time. - const Qt::TimeSpec timeSpec = dt.timeSpec(); + const Qt::TimeSpec timeSpec = dt.timeSpec(); - if ( timeSpec == Qt::LocalTime ) - dt = dt.toTimeSpec( Qt::UTC ); + if (timeSpec == Qt::LocalTime) + dt = dt.toTimeSpec(Qt::UTC); - const QTime t = dt.time(); - switch( intervalType ) - { - case QwtDate::Second: - { - dt.setTime( QTime( t.hour(), t.minute(), t.second() ) ); - break; - } - case QwtDate::Minute: - { - dt.setTime( QTime( t.hour(), t.minute(), 0 ) ); - break; - } - case QwtDate::Hour: - { - dt.setTime( QTime( t.hour(), 0, 0 ) ); - break; - } - default: - break; + const QTime t = dt.time(); + switch (intervalType) + { + case QwtDate::Second: { + dt.setTime(QTime(t.hour(), t.minute(), t.second())); + break; } + case QwtDate::Minute: { + dt.setTime(QTime(t.hour(), t.minute(), 0)); + break; + } + case QwtDate::Hour: { + dt.setTime(QTime(t.hour(), 0, 0)); + break; + } + default: + break; + } - if ( timeSpec == Qt::LocalTime ) - dt = dt.toTimeSpec( Qt::LocalTime ); + if (timeSpec == Qt::LocalTime) + dt = dt.toTimeSpec(Qt::LocalTime); } -static inline QDateTime qwtToTimeSpec( - const QDateTime& dt, Qt::TimeSpec spec ) +static inline QDateTime qwtToTimeSpec(const QDateTime &dt, Qt::TimeSpec spec) { - if ( dt.timeSpec() == spec ) - return dt; + if (dt.timeSpec() == spec) + return dt; - const qint64 jd = dt.date().toJulianDay(); - if ( jd < 0 || jd >= std::numeric_limits< int >::max() ) - { - // the conversion between local time and UTC - // is internally limited. To avoid - // overflows we simply ignore the difference - // for those dates + const qint64 jd = dt.date().toJulianDay(); + if (jd < 0 || jd >= std::numeric_limits::max()) + { + // the conversion between local time and UTC + // is internally limited. To avoid + // overflows we simply ignore the difference + // for those dates - QDateTime dt2 = dt; - dt2.setTimeSpec( spec ); - return dt2; - } + QDateTime dt2 = dt; + dt2.setTimeSpec(spec); + return dt2; + } - return dt.toTimeSpec( spec ); + return dt.toTimeSpec(spec); } #if 0 @@ -215,35 +212,35 @@ static inline qint64 qwtFloorDiv( int a, int b ) #endif -static inline QDate qwtToDate( int year, int month = 1, int day = 1 ) +static inline QDate qwtToDate(int year, int month = 1, int day = 1) { #if QT_VERSION >= 0x050000 - return QDate( year, month, day ); + return QDate(year, month, day); #else - if ( year > 100000 ) + if (year > 100000) + { + // code from QDate but using doubles to avoid overflows + // for large values + + const int m1 = (month - 14) / 12; + const int m2 = (367 * (month - 2 - 12 * m1)) / 12; + const double y1 = std::floor((4900.0 + year + m1) / 100); + + const double jd = std::floor((1461.0 * (year + 4800 + m1)) / 4) + m2 + - std::floor((3 * y1) / 4) + day - 32075; + + if (jd > maxJulianDayD) { - // code from QDate but using doubles to avoid overflows - // for large values - - const int m1 = ( month - 14 ) / 12; - const int m2 = ( 367 * ( month - 2 - 12 * m1 ) ) / 12; - const double y1 = std::floor( ( 4900.0 + year + m1 ) / 100 ); - - const double jd = std::floor( ( 1461.0 * ( year + 4800 + m1 ) ) / 4 ) + m2 - - std::floor( ( 3 * y1 ) / 4 ) + day - 32075; - - if ( jd > maxJulianDayD ) - { - qWarning() << "qwtToDate: overflow"; - return QDate(); - } - - return QDate::fromJulianDay( static_cast< QwtJulianDay >( jd ) ); - } - else - { - return QDate( year, month, day ); + qWarning() << "qwtToDate: overflow"; + return QDate(); } + + return QDate::fromJulianDay(static_cast(jd)); + } + else + { + return QDate(year, month, day); + } #endif } @@ -258,31 +255,31 @@ static inline QDate qwtToDate( int year, int month = 1, int day = 1 ) \sa toDouble(), QDateTime::setMSecsSinceEpoch() \note The return datetime for Qt::OffsetFromUTC will be Qt::UTC */ -QDateTime QwtDate::toDateTime( double value, Qt::TimeSpec timeSpec ) +QDateTime QwtDate::toDateTime(double value, Qt::TimeSpec timeSpec) { - const int msecsPerDay = 86400000; + const int msecsPerDay = 86400000; - const double days = static_cast< qint64 >( std::floor( value / msecsPerDay ) ); + const double days = static_cast(std::floor(value / msecsPerDay)); - const double jd = QwtDate::JulianDayForEpoch + days; - if ( ( jd > maxJulianDayD ) || ( jd < minJulianDayD ) ) - { - qWarning() << "QwtDate::toDateTime: overflow"; - return QDateTime(); - } + const double jd = QwtDate::JulianDayForEpoch + days; + if ((jd > maxJulianDayD) || (jd < minJulianDayD)) + { + qWarning() << "QwtDate::toDateTime: overflow"; + return QDateTime(); + } - const QDate d = QDate::fromJulianDay( static_cast< QwtJulianDay >( jd ) ); + const QDate d = QDate::fromJulianDay(static_cast(jd)); - const int msecs = static_cast< int >( value - days * msecsPerDay ); + const int msecs = static_cast(value - days * msecsPerDay); - static const QTime timeNull( 0, 0, 0, 0 ); + static const QTime timeNull(0, 0, 0, 0); - QDateTime dt( d, timeNull.addMSecs( msecs ), Qt::UTC ); + QDateTime dt(d, timeNull.addMSecs(msecs), Qt::UTC); - if ( timeSpec == Qt::LocalTime ) - dt = qwtToTimeSpec( dt, timeSpec ); + if (timeSpec == Qt::LocalTime) + dt = qwtToTimeSpec(dt, timeSpec); - return dt; + return dt; } /*! @@ -295,19 +292,19 @@ QDateTime QwtDate::toDateTime( double value, Qt::TimeSpec timeSpec ) \warning For values very far below or above 1970-01-01 UTC rounding errors will happen due to the limited significance of a double. */ -double QwtDate::toDouble( const QDateTime& dateTime ) +double QwtDate::toDouble(const QDateTime &dateTime) { - const int msecsPerDay = 86400000; + const int msecsPerDay = 86400000; - const QDateTime dt = qwtToTimeSpec( dateTime, Qt::UTC ); + const QDateTime dt = qwtToTimeSpec(dateTime, Qt::UTC); - const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch; + const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch; - const QTime time = dt.time(); - const double secs = 3600.0 * time.hour() + - 60.0 * time.minute() + time.second(); + const QTime time = dt.time(); + const double secs + = 3600.0 * time.hour() + 60.0 * time.minute() + time.second(); - return days * msecsPerDay + time.msec() + 1000.0 * secs; + return days * msecsPerDay + time.msec() + 1000.0 * secs; } /*! @@ -320,95 +317,86 @@ double QwtDate::toDouble( const QDateTime& dateTime ) \return Ceiled datetime \sa floor() */ -QDateTime QwtDate::ceil( const QDateTime& dateTime, IntervalType intervalType ) +QDateTime QwtDate::ceil(const QDateTime &dateTime, IntervalType intervalType) { - if ( dateTime.date() >= QwtDate::maxDate() ) - return dateTime; + if (dateTime.date() >= QwtDate::maxDate()) + return dateTime; - QDateTime dt = dateTime; + QDateTime dt = dateTime; - switch ( intervalType ) - { - case QwtDate::Millisecond: - { - break; - } - case QwtDate::Second: - { - qwtFloorTime( QwtDate::Second, dt ); - if ( dt < dateTime ) - dt = dt.addSecs( 1 ); - - break; - } - case QwtDate::Minute: - { - qwtFloorTime( QwtDate::Minute, dt ); - if ( dt < dateTime ) - dt = dt.addSecs( 60 ); - - break; - } - case QwtDate::Hour: - { - qwtFloorTime( QwtDate::Hour, dt ); - if ( dt < dateTime ) - dt = dt.addSecs( 3600 ); - - break; - } - case QwtDate::Day: - { - dt.setTime( QTime( 0, 0 ) ); - if ( dt < dateTime ) - dt = dt.addDays( 1 ); - - break; - } - case QwtDate::Week: - { - dt.setTime( QTime( 0, 0 ) ); - if ( dt < dateTime ) - dt = dt.addDays( 1 ); - - int days = qwtFirstDayOfWeek() - dt.date().dayOfWeek(); - if ( days < 0 ) - days += 7; - - dt = dt.addDays( days ); - - break; - } - case QwtDate::Month: - { - dt.setTime( QTime( 0, 0 ) ); - dt.setDate( qwtToDate( dateTime.date().year(), - dateTime.date().month() ) ); - - if ( dt < dateTime ) - dt = dt.addMonths( 1 ); - - break; - } - case QwtDate::Year: - { - dt.setTime( QTime( 0, 0 ) ); - - const QDate d = dateTime.date(); - - int year = d.year(); - if ( d.month() > 1 || d.day() > 1 || !dateTime.time().isNull() ) - year++; - - if ( year == 0 ) - year++; // there is no year 0 - - dt.setDate( qwtToDate( year ) ); - break; - } + switch (intervalType) + { + case QwtDate::Millisecond: { + break; } + case QwtDate::Second: { + qwtFloorTime(QwtDate::Second, dt); + if (dt < dateTime) + dt = dt.addSecs(1); - return dt; + break; + } + case QwtDate::Minute: { + qwtFloorTime(QwtDate::Minute, dt); + if (dt < dateTime) + dt = dt.addSecs(60); + + break; + } + case QwtDate::Hour: { + qwtFloorTime(QwtDate::Hour, dt); + if (dt < dateTime) + dt = dt.addSecs(3600); + + break; + } + case QwtDate::Day: { + dt.setTime(QTime(0, 0)); + if (dt < dateTime) + dt = dt.addDays(1); + + break; + } + case QwtDate::Week: { + dt.setTime(QTime(0, 0)); + if (dt < dateTime) + dt = dt.addDays(1); + + int days = qwtFirstDayOfWeek() - dt.date().dayOfWeek(); + if (days < 0) + days += 7; + + dt = dt.addDays(days); + + break; + } + case QwtDate::Month: { + dt.setTime(QTime(0, 0)); + dt.setDate(qwtToDate(dateTime.date().year(), dateTime.date().month())); + + if (dt < dateTime) + dt = dt.addMonths(1); + + break; + } + case QwtDate::Year: { + dt.setTime(QTime(0, 0)); + + const QDate d = dateTime.date(); + + int year = d.year(); + if (d.month() > 1 || d.day() > 1 || !dateTime.time().isNull()) + year++; + + if (year == 0) + year++; // there is no year 0 + + dt.setDate(qwtToDate(year)); + break; + } + } + + return dt; } /*! @@ -422,66 +410,58 @@ QDateTime QwtDate::ceil( const QDateTime& dateTime, IntervalType intervalType ) \return Floored datetime \sa floor() */ -QDateTime QwtDate::floor( const QDateTime& dateTime, - IntervalType intervalType ) +QDateTime QwtDate::floor(const QDateTime &dateTime, IntervalType intervalType) { - if ( dateTime.date() <= QwtDate::minDate() ) - return dateTime; + if (dateTime.date() <= QwtDate::minDate()) + return dateTime; - QDateTime dt = dateTime; + QDateTime dt = dateTime; - switch ( intervalType ) - { - case QwtDate::Millisecond: - { - break; - } - case QwtDate::Second: - case QwtDate::Minute: - case QwtDate::Hour: - { - qwtFloorTime( intervalType, dt ); - break; - } - case QwtDate::Day: - { - dt.setTime( QTime( 0, 0 ) ); - break; - } - case QwtDate::Week: - { - dt.setTime( QTime( 0, 0 ) ); - - int days = dt.date().dayOfWeek() - qwtFirstDayOfWeek(); - if ( days < 0 ) - days += 7; - - dt = dt.addDays( -days ); - - break; - } - case QwtDate::Month: - { - dt.setTime( QTime( 0, 0 ) ); - - const QDate date = qwtToDate( dt.date().year(), - dt.date().month() ); - dt.setDate( date ); - - break; - } - case QwtDate::Year: - { - dt.setTime( QTime( 0, 0 ) ); - - const QDate date = qwtToDate( dt.date().year() ); - dt.setDate( date ); - - break; - } + switch (intervalType) + { + case QwtDate::Millisecond: { + break; } + case QwtDate::Second: + case QwtDate::Minute: + case QwtDate::Hour: { + qwtFloorTime(intervalType, dt); + break; + } + case QwtDate::Day: { + dt.setTime(QTime(0, 0)); + break; + } + case QwtDate::Week: { + dt.setTime(QTime(0, 0)); - return dt; + int days = dt.date().dayOfWeek() - qwtFirstDayOfWeek(); + if (days < 0) + days += 7; + + dt = dt.addDays(-days); + + break; + } + case QwtDate::Month: { + dt.setTime(QTime(0, 0)); + + const QDate date = qwtToDate(dt.date().year(), dt.date().month()); + dt.setDate(date); + + break; + } + case QwtDate::Year: { + dt.setTime(QTime(0, 0)); + + const QDate date = qwtToDate(dt.date().year()); + dt.setDate(date); + + break; + } + } + + return dt; } /*! @@ -498,11 +478,11 @@ QDateTime QwtDate::floor( const QDateTime& dateTime, */ QDate QwtDate::minDate() { - static QDate date; - if ( !date.isValid() ) - date = QDate::fromJulianDay( minJulianDayD ); + static QDate date; + if (!date.isValid()) + date = QDate::fromJulianDay(minJulianDayD); - return date; + return date; } /*! @@ -520,11 +500,11 @@ QDate QwtDate::minDate() */ QDate QwtDate::maxDate() { - static QDate date; - if ( !date.isValid() ) - date = QDate::fromJulianDay( maxJulianDayD ); + static QDate date; + if (!date.isValid()) + date = QDate::fromJulianDay(maxJulianDayD); - return date; + return date; } /*! @@ -539,33 +519,33 @@ QDate QwtDate::maxDate() \sa QLocale::firstDayOfWeek(), weekNumber() */ -QDate QwtDate::dateOfWeek0( int year, Week0Type type ) +QDate QwtDate::dateOfWeek0(int year, Week0Type type) { - const Qt::DayOfWeek firstDayOfWeek = qwtFirstDayOfWeek(); + const Qt::DayOfWeek firstDayOfWeek = qwtFirstDayOfWeek(); - QDate dt0( year, 1, 1 ); + QDate dt0(year, 1, 1); - // floor to the first day of the week - int days = dt0.dayOfWeek() - firstDayOfWeek; - if ( days < 0 ) - days += 7; + // floor to the first day of the week + int days = dt0.dayOfWeek() - firstDayOfWeek; + if (days < 0) + days += 7; - dt0 = dt0.addDays( -days ); + dt0 = dt0.addDays(-days); - if ( type == QwtDate::FirstThursday ) - { - // according to ISO 8601 the first week is defined - // by the first Thursday. + if (type == QwtDate::FirstThursday) + { + // according to ISO 8601 the first week is defined + // by the first Thursday. - int d = Qt::Thursday - firstDayOfWeek; - if ( d < 0 ) - d += 7; + int d = Qt::Thursday - firstDayOfWeek; + if (d < 0) + d += 7; - if ( dt0.addDays( d ).year() < year ) - dt0 = dt0.addDays( 7 ); - } + if (dt0.addDays(d).year() < year) + dt0 = dt0.addDays(7); + } - return dt0; + return dt0; } /*! @@ -582,36 +562,36 @@ QDate QwtDate::dateOfWeek0( int year, Week0Type type ) \return Week number, starting with 1 */ -int QwtDate::weekNumber( const QDate& date, Week0Type type ) +int QwtDate::weekNumber(const QDate &date, Week0Type type) { - int weekNo; + int weekNo; - if ( type == QwtDate::FirstDay ) + if (type == QwtDate::FirstDay) + { + QDate day0; + + if (date.month() == 12 && date.day() >= 24) { - QDate day0; + // week 1 usually starts in the previous years. + // and we have to check if we are already there - if ( date.month() == 12 && date.day() >= 24 ) - { - // week 1 usually starts in the previous years. - // and we have to check if we are already there - - day0 = dateOfWeek0( date.year() + 1, type ); - if ( day0.daysTo( date ) < 0 ) - day0 = dateOfWeek0( date.year(), type ); - } - else - { - day0 = dateOfWeek0( date.year(), type ); - } - - weekNo = day0.daysTo( date ) / 7 + 1; + day0 = dateOfWeek0(date.year() + 1, type); + if (day0.daysTo(date) < 0) + day0 = dateOfWeek0(date.year(), type); } else { - weekNo = date.weekNumber(); + day0 = dateOfWeek0(date.year(), type); } - return weekNo; + weekNo = day0.daysTo(date) / 7 + 1; + } + else + { + weekNo = date.weekNumber(); + } + + return weekNo; } /*! @@ -632,33 +612,30 @@ int QwtDate::weekNumber( const QDate& date, Week0Type type ) \param dateTime Datetime value \return Offset in seconds */ -int QwtDate::utcOffset( const QDateTime& dateTime ) +int QwtDate::utcOffset(const QDateTime &dateTime) { - int seconds = 0; + int seconds = 0; - switch( dateTime.timeSpec() ) - { - case Qt::UTC: - { - break; - } - case Qt::OffsetFromUTC: - { -#if QT_VERSION >= 0x050200 - seconds = dateTime.offsetFromUtc(); -#else - seconds = dateTime.utcOffset(); -#endif - break; - } - default: - { - const QDateTime dt1( dateTime.date(), dateTime.time(), Qt::UTC ); - seconds = dateTime.secsTo( dt1 ); - } + switch (dateTime.timeSpec()) + { + case Qt::UTC: { + break; } + case Qt::OffsetFromUTC: { +#if QT_VERSION >= 0x050200 + seconds = dateTime.offsetFromUtc(); +#else + seconds = dateTime.utcOffset(); +#endif + break; + } + default: { + const QDateTime dt1(dateTime.date(), dateTime.time(), Qt::UTC); + seconds = dateTime.secsTo(dt1); + } + } - return seconds; + return seconds; } /*! @@ -683,14 +660,14 @@ int QwtDate::utcOffset( const QDateTime& dateTime ) \return Datetime string \sa QDateTime::toString(), weekNumber(), QwtDateScaleDraw */ -QString QwtDate::toString( const QDateTime& dateTime, - const QString& format, Week0Type week0Type ) +QString QwtDate::toString(const QDateTime &dateTime, const QString &format, + Week0Type week0Type) { - QString fmt = format; - if ( fmt.contains( 'w' ) ) - { - fmt = qwtExpandedFormat( fmt, dateTime, week0Type ); - } + QString fmt = format; + if (fmt.contains('w')) + { + fmt = qwtExpandedFormat(fmt, dateTime, week0Type); + } - return QLocale().toString( dateTime, fmt ); + return QLocale().toString(dateTime, fmt); } diff --git a/libs/qwt/src/qwt_date.h b/libs/qwt/src/qwt_date.h index 49a1f0dd..dd9b076e 100644 --- a/libs/qwt/src/qwt_date.h +++ b/libs/qwt/src/qwt_date.h @@ -41,88 +41,86 @@ */ class QWT_EXPORT QwtDate { - public: +public: + /*! + How to identify the first week of year differs between + countries. + */ + enum Week0Type + { /*! - How to identify the first week of year differs between - countries. + According to ISO 8601 the first week of a year is defined + as "the week with the year's first Thursday in it". + + FirstThursday corresponds to the numbering that is + implemented in QDate::weekNumber(). */ - enum Week0Type - { - /*! - According to ISO 8601 the first week of a year is defined - as "the week with the year's first Thursday in it". - - FirstThursday corresponds to the numbering that is - implemented in QDate::weekNumber(). - */ - FirstThursday, - - /*! - "The week with January 1.1 in it." - - In the U.S. this definition is more common than - FirstThursday. - */ - FirstDay - }; + FirstThursday, /*! - Classification of an time interval + "The week with January 1.1 in it." - Time intervals needs to be classified to decide how to - align and divide it. + In the U.S. this definition is more common than + FirstThursday. */ - enum IntervalType - { - //! The interval is related to milliseconds - Millisecond, + FirstDay + }; - //! The interval is related to seconds - Second, + /*! + Classification of an time interval - //! The interval is related to minutes - Minute, + Time intervals needs to be classified to decide how to + align and divide it. + */ + enum IntervalType + { + //! The interval is related to milliseconds + Millisecond, - //! The interval is related to hours - Hour, + //! The interval is related to seconds + Second, - //! The interval is related to days - Day, + //! The interval is related to minutes + Minute, - //! The interval is related to weeks - Week, + //! The interval is related to hours + Hour, - //! The interval is related to months - Month, + //! The interval is related to days + Day, - //! The interval is related to years - Year - }; + //! The interval is related to weeks + Week, - enum - { - //! The Julian day of "The Epoch" - JulianDayForEpoch = 2440588 - }; + //! The interval is related to months + Month, - static QDate minDate(); - static QDate maxDate(); + //! The interval is related to years + Year + }; - static QDateTime toDateTime( double value, - Qt::TimeSpec = Qt::UTC ); + enum + { + //! The Julian day of "The Epoch" + JulianDayForEpoch = 2440588 + }; - static double toDouble( const QDateTime& ); + static QDate minDate(); + static QDate maxDate(); - static QDateTime ceil( const QDateTime&, IntervalType ); - static QDateTime floor( const QDateTime&, IntervalType ); + static QDateTime toDateTime(double value, Qt::TimeSpec = Qt::UTC); - static QDate dateOfWeek0( int year, Week0Type ); - static int weekNumber( const QDate&, Week0Type ); + static double toDouble(const QDateTime &); - static int utcOffset( const QDateTime& ); + static QDateTime ceil(const QDateTime &, IntervalType); + static QDateTime floor(const QDateTime &, IntervalType); - static QString toString( const QDateTime&, - const QString& format, Week0Type ); + static QDate dateOfWeek0(int year, Week0Type); + static int weekNumber(const QDate &, Week0Type); + + static int utcOffset(const QDateTime &); + + static QString toString(const QDateTime &, const QString &format, Week0Type); }; #endif diff --git a/libs/qwt/src/qwt_date_scale_draw.cpp b/libs/qwt/src/qwt_date_scale_draw.cpp index 57af0fdf..0610b95c 100644 --- a/libs/qwt/src/qwt_date_scale_draw.cpp +++ b/libs/qwt/src/qwt_date_scale_draw.cpp @@ -12,26 +12,26 @@ class QwtDateScaleDraw::PrivateData { - public: - explicit PrivateData( Qt::TimeSpec spec ) - : timeSpec( spec ) - , utcOffset( 0 ) - , week0Type( QwtDate::FirstThursday ) - { - dateFormats[ QwtDate::Millisecond ] = "hh:mm:ss:zzz\nddd dd MMM yyyy"; - dateFormats[ QwtDate::Second ] = "hh:mm:ss\nddd dd MMM yyyy"; - dateFormats[ QwtDate::Minute ] = "hh:mm\nddd dd MMM yyyy"; - dateFormats[ QwtDate::Hour ] = "hh:mm\nddd dd MMM yyyy"; - dateFormats[ QwtDate::Day ] = "ddd dd MMM yyyy"; - dateFormats[ QwtDate::Week ] = "Www yyyy"; - dateFormats[ QwtDate::Month ] = "MMM yyyy"; - dateFormats[ QwtDate::Year ] = "yyyy"; - } +public: + explicit PrivateData(Qt::TimeSpec spec) + : timeSpec(spec) + , utcOffset(0) + , week0Type(QwtDate::FirstThursday) + { + dateFormats[QwtDate::Millisecond] = "hh:mm:ss:zzz\nddd dd MMM yyyy"; + dateFormats[QwtDate::Second] = "hh:mm:ss\nddd dd MMM yyyy"; + dateFormats[QwtDate::Minute] = "hh:mm\nddd dd MMM yyyy"; + dateFormats[QwtDate::Hour] = "hh:mm\nddd dd MMM yyyy"; + dateFormats[QwtDate::Day] = "ddd dd MMM yyyy"; + dateFormats[QwtDate::Week] = "Www yyyy"; + dateFormats[QwtDate::Month] = "MMM yyyy"; + dateFormats[QwtDate::Year] = "yyyy"; + } - Qt::TimeSpec timeSpec; - int utcOffset; - QwtDate::Week0Type week0Type; - QString dateFormats[ QwtDate::Year + 1 ]; + Qt::TimeSpec timeSpec; + int utcOffset; + QwtDate::Week0Type week0Type; + QString dateFormats[QwtDate::Year + 1]; }; /*! @@ -45,15 +45,15 @@ class QwtDateScaleDraw::PrivateData \sa setTimeSpec(), setWeek0Type() */ -QwtDateScaleDraw::QwtDateScaleDraw( Qt::TimeSpec timeSpec ) +QwtDateScaleDraw::QwtDateScaleDraw(Qt::TimeSpec timeSpec) { - m_data = new PrivateData( timeSpec ); + m_data = new PrivateData(timeSpec); } //! Destructor QwtDateScaleDraw::~QwtDateScaleDraw() { - delete m_data; + delete m_data; } /*! @@ -62,9 +62,9 @@ QwtDateScaleDraw::~QwtDateScaleDraw() \param timeSpec Time specification \sa timeSpec(), setUtcOffset(), toDateTime() */ -void QwtDateScaleDraw::setTimeSpec( Qt::TimeSpec timeSpec ) +void QwtDateScaleDraw::setTimeSpec(Qt::TimeSpec timeSpec) { - m_data->timeSpec = timeSpec; + m_data->timeSpec = timeSpec; } /*! @@ -73,7 +73,7 @@ void QwtDateScaleDraw::setTimeSpec( Qt::TimeSpec timeSpec ) */ Qt::TimeSpec QwtDateScaleDraw::timeSpec() const { - return m_data->timeSpec; + return m_data->timeSpec; } /*! @@ -86,9 +86,9 @@ Qt::TimeSpec QwtDateScaleDraw::timeSpec() const \sa QDate::utcOffset(), setTimeSpec(), toDateTime() */ -void QwtDateScaleDraw::setUtcOffset( int seconds ) +void QwtDateScaleDraw::setUtcOffset(int seconds) { - m_data->utcOffset = seconds; + m_data->utcOffset = seconds; } /*! @@ -100,7 +100,7 @@ void QwtDateScaleDraw::setUtcOffset( int seconds ) */ int QwtDateScaleDraw::utcOffset() const { - return m_data->utcOffset; + return m_data->utcOffset; } /*! @@ -112,9 +112,9 @@ int QwtDateScaleDraw::utcOffset() const \note week0Type has no effect beside for intervals classified as QwtDate::Week. */ -void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type ) +void QwtDateScaleDraw::setWeek0Type(QwtDate::Week0Type week0Type) { - m_data->week0Type = week0Type; + m_data->week0Type = week0Type; } /*! @@ -123,7 +123,7 @@ void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type ) */ QwtDate::Week0Type QwtDateScaleDraw::week0Type() const { - return m_data->week0Type; + return m_data->week0Type; } /*! @@ -134,14 +134,13 @@ QwtDate::Week0Type QwtDateScaleDraw::week0Type() const \sa dateFormat(), dateFormatOfDate(), QwtDate::toString() */ -void QwtDateScaleDraw::setDateFormat( - QwtDate::IntervalType intervalType, const QString& format ) +void QwtDateScaleDraw::setDateFormat(QwtDate::IntervalType intervalType, + const QString &format) { - if ( intervalType >= QwtDate::Millisecond && - intervalType <= QwtDate::Year ) - { - m_data->dateFormats[ intervalType ] = format; - } + if (intervalType >= QwtDate::Millisecond && intervalType <= QwtDate::Year) + { + m_data->dateFormats[intervalType] = format; + } } /*! @@ -149,16 +148,14 @@ void QwtDateScaleDraw::setDateFormat( \return Default format string for an datetime interval type \sa setDateFormat(), dateFormatOfDate() */ -QString QwtDateScaleDraw::dateFormat( - QwtDate::IntervalType intervalType ) const +QString QwtDateScaleDraw::dateFormat(QwtDate::IntervalType intervalType) const { - if ( intervalType >= QwtDate::Millisecond && - intervalType <= QwtDate::Year ) - { - return m_data->dateFormats[ intervalType ]; - } + if (intervalType >= QwtDate::Millisecond && intervalType <= QwtDate::Year) + { + return m_data->dateFormats[intervalType]; + } - return QString(); + return QString(); } /*! @@ -177,18 +174,18 @@ QString QwtDateScaleDraw::dateFormat( \sa setDateFormat(), QwtDate::toString() */ -QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime& dateTime, - QwtDate::IntervalType intervalType ) const +QString +QwtDateScaleDraw::dateFormatOfDate(const QDateTime &dateTime, + QwtDate::IntervalType intervalType) const { - Q_UNUSED( dateTime ) + Q_UNUSED(dateTime) - if ( intervalType >= QwtDate::Millisecond && - intervalType <= QwtDate::Year ) - { - return m_data->dateFormats[ intervalType ]; - } + if (intervalType >= QwtDate::Millisecond && intervalType <= QwtDate::Year) + { + return m_data->dateFormats[intervalType]; + } - return m_data->dateFormats[ QwtDate::Second ]; + return m_data->dateFormats[QwtDate::Second]; } /*! @@ -202,13 +199,12 @@ QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime& dateTime, \sa dateFormatOfDate() */ -QwtText QwtDateScaleDraw::label( double value ) const +QwtText QwtDateScaleDraw::label(double value) const { - const QDateTime dt = toDateTime( value ); - const QString fmt = dateFormatOfDate( - dt, intervalType( scaleDiv() ) ); + const QDateTime dt = toDateTime(value); + const QString fmt = dateFormatOfDate(dt, intervalType(scaleDiv())); - return QwtDate::toString( dt, fmt, m_data->week0Type ); + return QwtDate::toString(dt, fmt, m_data->week0Type); } /*! @@ -220,44 +216,44 @@ QwtText QwtDateScaleDraw::label( double value ) const \sa dateFormatOfDate() */ -QwtDate::IntervalType QwtDateScaleDraw::intervalType( - const QwtScaleDiv& scaleDiv ) const +QwtDate::IntervalType +QwtDateScaleDraw::intervalType(const QwtScaleDiv &scaleDiv) const { - int intvType = QwtDate::Year; + int intvType = QwtDate::Year; - bool alignedToWeeks = true; + bool alignedToWeeks = true; - const QList< double > ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick ); - for ( int i = 0; i < ticks.size(); i++ ) + const QList ticks = scaleDiv.ticks(QwtScaleDiv::MajorTick); + for (int i = 0; i < ticks.size(); i++) + { + const QDateTime dt = toDateTime(ticks[i]); + for (int j = QwtDate::Second; j <= intvType; j++) { - const QDateTime dt = toDateTime( ticks[i] ); - for ( int j = QwtDate::Second; j <= intvType; j++ ) + const QDateTime dt0 + = QwtDate::floor(dt, static_cast(j)); + + if (dt0 != dt) + { + if (j == QwtDate::Week) { - const QDateTime dt0 = QwtDate::floor( dt, - static_cast< QwtDate::IntervalType >( j ) ); - - if ( dt0 != dt ) - { - if ( j == QwtDate::Week ) - { - alignedToWeeks = false; - } - else - { - intvType = j - 1; - break; - } - } + alignedToWeeks = false; } - - if ( intvType == QwtDate::Millisecond ) - break; + else + { + intvType = j - 1; + break; + } + } } - if ( intvType == QwtDate::Week && !alignedToWeeks ) - intvType = QwtDate::Day; + if (intvType == QwtDate::Millisecond) + break; + } - return static_cast< QwtDate::IntervalType >( intvType ); + if (intvType == QwtDate::Week && !alignedToWeeks) + intvType = QwtDate::Day; + + return static_cast(intvType); } /*! @@ -266,18 +262,18 @@ QwtDate::IntervalType QwtDateScaleDraw::intervalType( \return QDateTime object initialized with timeSpec() and utcOffset(). \sa timeSpec(), utcOffset(), QwtDate::toDateTime() */ -QDateTime QwtDateScaleDraw::toDateTime( double value ) const +QDateTime QwtDateScaleDraw::toDateTime(double value) const { - QDateTime dt = QwtDate::toDateTime( value, m_data->timeSpec ); - if ( m_data->timeSpec == Qt::OffsetFromUTC ) - { - dt = dt.addSecs( m_data->utcOffset ); + QDateTime dt = QwtDate::toDateTime(value, m_data->timeSpec); + if (m_data->timeSpec == Qt::OffsetFromUTC) + { + dt = dt.addSecs(m_data->utcOffset); #if QT_VERSION >= 0x050200 - dt.setOffsetFromUtc( m_data->utcOffset ); + dt.setOffsetFromUtc(m_data->utcOffset); #else - dt.setUtcOffset( m_data->utcOffset ); + dt.setUtcOffset(m_data->utcOffset); #endif - } + } - return dt; + return dt; } diff --git a/libs/qwt/src/qwt_date_scale_draw.h b/libs/qwt/src/qwt_date_scale_draw.h index c49fd1e2..0aaf3deb 100644 --- a/libs/qwt/src/qwt_date_scale_draw.h +++ b/libs/qwt/src/qwt_date_scale_draw.h @@ -51,36 +51,35 @@ */ class QWT_EXPORT QwtDateScaleDraw : public QwtScaleDraw { - public: - explicit QwtDateScaleDraw( Qt::TimeSpec = Qt::LocalTime ); - virtual ~QwtDateScaleDraw(); +public: + explicit QwtDateScaleDraw(Qt::TimeSpec = Qt::LocalTime); + virtual ~QwtDateScaleDraw(); - void setDateFormat( QwtDate::IntervalType, const QString& ); - QString dateFormat( QwtDate::IntervalType ) const; + void setDateFormat(QwtDate::IntervalType, const QString &); + QString dateFormat(QwtDate::IntervalType) const; - void setTimeSpec( Qt::TimeSpec ); - Qt::TimeSpec timeSpec() const; + void setTimeSpec(Qt::TimeSpec); + Qt::TimeSpec timeSpec() const; - void setUtcOffset( int seconds ); - int utcOffset() const; + void setUtcOffset(int seconds); + int utcOffset() const; - void setWeek0Type( QwtDate::Week0Type ); - QwtDate::Week0Type week0Type() const; + void setWeek0Type(QwtDate::Week0Type); + QwtDate::Week0Type week0Type() const; - virtual QwtText label( double ) const QWT_OVERRIDE; + virtual QwtText label(double) const QWT_OVERRIDE; - QDateTime toDateTime( double ) const; + QDateTime toDateTime(double) const; - protected: - virtual QwtDate::IntervalType - intervalType( const QwtScaleDiv& ) const; +protected: + virtual QwtDate::IntervalType intervalType(const QwtScaleDiv &) const; - virtual QString dateFormatOfDate( const QDateTime&, - QwtDate::IntervalType ) const; + virtual QString dateFormatOfDate(const QDateTime &, + QwtDate::IntervalType) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_date_scale_engine.cpp b/libs/qwt/src/qwt_date_scale_engine.cpp index 1379840f..04de86a9 100644 --- a/libs/qwt/src/qwt_date_scale_engine.cpp +++ b/libs/qwt/src/qwt_date_scale_engine.cpp @@ -15,723 +15,682 @@ #include -static inline double qwtMsecsForType( int type ) +static inline double qwtMsecsForType(int type) { - static const double msecs[] = - { - 1.0, - 1000.0, - 60.0 * 1000.0, - 3600.0 * 1000.0, - 24.0 * 3600.0 * 1000.0, - 7.0 * 24.0 * 3600.0 * 1000.0, - 30.0 * 24.0 * 3600.0 * 1000.0, - 365.0 * 24.0 * 3600.0 * 1000.0, - }; + static const double msecs[] = { + 1.0, + 1000.0, + 60.0 * 1000.0, + 3600.0 * 1000.0, + 24.0 * 3600.0 * 1000.0, + 7.0 * 24.0 * 3600.0 * 1000.0, + 30.0 * 24.0 * 3600.0 * 1000.0, + 365.0 * 24.0 * 3600.0 * 1000.0, + }; - if ( type < 0 || type >= static_cast< int >( sizeof( msecs ) / sizeof( msecs[0] ) ) ) - return 1.0; + if (type < 0 || type >= static_cast(sizeof(msecs) / sizeof(msecs[0]))) + return 1.0; - return msecs[ type ]; + return msecs[type]; } -static inline int qwtAlignValue( - double value, double stepSize, bool up ) +static inline int qwtAlignValue(double value, double stepSize, bool up) { - double d = value / stepSize; - d = up ? std::ceil( d ) : std::floor( d ); + double d = value / stepSize; + d = up ? std::ceil(d) : std::floor(d); - return static_cast< int >( d * stepSize ); + return static_cast(d * stepSize); } -static double qwtIntervalWidth( const QDateTime& minDate, - const QDateTime& maxDate, QwtDate::IntervalType intervalType ) +static double qwtIntervalWidth(const QDateTime &minDate, + const QDateTime &maxDate, + QwtDate::IntervalType intervalType) { - switch( intervalType ) - { - case QwtDate::Millisecond: - { - return minDate.msecsTo( maxDate ); - } - case QwtDate::Second: - { - return minDate.secsTo( maxDate ); - } - case QwtDate::Minute: - { - const double secsTo = minDate.secsTo( maxDate ); - return std::floor( secsTo / 60 ); - } - case QwtDate::Hour: - { - const double secsTo = minDate.secsTo( maxDate ); - return std::floor( secsTo / 3600 ); - } - case QwtDate::Day: - { - return minDate.daysTo( maxDate ); - } - case QwtDate::Week: - { - return std::floor( minDate.daysTo( maxDate ) / 7.0 ); - } - case QwtDate::Month: - { - const double years = - double( maxDate.date().year() ) - minDate.date().year(); - - int months = maxDate.date().month() - minDate.date().month(); - if ( maxDate.date().day() < minDate.date().day() ) - months--; - - return years * 12 + months; - } - case QwtDate::Year: - { - double years = - double( maxDate.date().year() ) - minDate.date().year(); - - if ( maxDate.date().month() < minDate.date().month() ) - years -= 1.0; - - return years; - } + switch (intervalType) + { + case QwtDate::Millisecond: { + return minDate.msecsTo(maxDate); } - - return 0.0; -} - -static double qwtRoundedIntervalWidth( - const QDateTime& minDate, const QDateTime& maxDate, - QwtDate::IntervalType intervalType ) -{ - const QDateTime minD = QwtDate::floor( minDate, intervalType ); - const QDateTime maxD = QwtDate::ceil( maxDate, intervalType ); - - return qwtIntervalWidth( minD, maxD, intervalType ); -} - -static inline int qwtStepCount( int intervalSize, int maxSteps, - const int limits[], int numLimits ) -{ - for ( int i = 0; i < numLimits; i++ ) - { - const int numSteps = intervalSize / limits[ i ]; - - if ( numSteps > 1 && numSteps <= maxSteps && - numSteps * limits[ i ] == intervalSize ) - { - return numSteps; - } + case QwtDate::Second: { + return minDate.secsTo(maxDate); } + case QwtDate::Minute: { + const double secsTo = minDate.secsTo(maxDate); + return std::floor(secsTo / 60); + } + case QwtDate::Hour: { + const double secsTo = minDate.secsTo(maxDate); + return std::floor(secsTo / 3600); + } + case QwtDate::Day: { + return minDate.daysTo(maxDate); + } + case QwtDate::Week: { + return std::floor(minDate.daysTo(maxDate) / 7.0); + } + case QwtDate::Month: { + const double years + = double(maxDate.date().year()) - minDate.date().year(); + int months = maxDate.date().month() - minDate.date().month(); + if (maxDate.date().day() < minDate.date().day()) + months--; + + return years * 12 + months; + } + case QwtDate::Year: { + double years = double(maxDate.date().year()) - minDate.date().year(); + + if (maxDate.date().month() < minDate.date().month()) + years -= 1.0; + + return years; + } + } + + return 0.0; +} + +static double qwtRoundedIntervalWidth(const QDateTime &minDate, + const QDateTime &maxDate, + QwtDate::IntervalType intervalType) +{ + const QDateTime minD = QwtDate::floor(minDate, intervalType); + const QDateTime maxD = QwtDate::ceil(maxDate, intervalType); + + return qwtIntervalWidth(minD, maxD, intervalType); +} + +static inline int qwtStepCount(int intervalSize, int maxSteps, + const int limits[], int numLimits) +{ + for (int i = 0; i < numLimits; i++) + { + const int numSteps = intervalSize / limits[i]; + + if (numSteps > 1 && numSteps <= maxSteps + && numSteps * limits[i] == intervalSize) + { + return numSteps; + } + } + + return 0; +} + +static int qwtStepSize(int intervalSize, int maxSteps, uint base) +{ + if (maxSteps <= 0) return 0; + + if (maxSteps > 2) + { + for (int numSteps = maxSteps; numSteps > 1; numSteps--) + { + const double stepSize = double(intervalSize) / numSteps; + + const double p = std::floor(std::log(stepSize) / std::log(double(base))); + const double fraction = std::pow(base, p); + + for (uint n = base; n >= 1; n /= 2) + { + if (qFuzzyCompare(stepSize, n * fraction)) + return qRound(stepSize); + + if (n == 3 && (base % 2) == 0) + { + if (qFuzzyCompare(stepSize, 2 * fraction)) + return qRound(stepSize); + } + } + } + } + + return 0; } -static int qwtStepSize( int intervalSize, int maxSteps, uint base ) +static int qwtDivideInterval(double intervalSize, int numSteps, + const int limits[], int numLimits) { - if ( maxSteps <= 0 ) - return 0; + const int v = qwtCeil(intervalSize / double(numSteps)); - if ( maxSteps > 2 ) - { - for ( int numSteps = maxSteps; numSteps > 1; numSteps-- ) - { - const double stepSize = double( intervalSize ) / numSteps; + for (int i = 0; i < numLimits - 1; i++) + { + if (v <= limits[i]) + return limits[i]; + } - const double p = std::floor( std::log( stepSize ) / std::log( double( base ) ) ); - const double fraction = std::pow( base, p ); - - for ( uint n = base; n >= 1; n /= 2 ) - { - if ( qFuzzyCompare( stepSize, n * fraction ) ) - return qRound( stepSize ); - - if ( n == 3 && ( base % 2 ) == 0 ) - { - if ( qFuzzyCompare( stepSize, 2 * fraction ) ) - return qRound( stepSize ); - } - } - } - } - - return 0; + return limits[numLimits - 1]; } -static int qwtDivideInterval( double intervalSize, int numSteps, - const int limits[], int numLimits ) +static double qwtDivideScale(double intervalSize, int numSteps, + QwtDate::IntervalType intervalType) { - const int v = qwtCeil( intervalSize / double( numSteps ) ); - - for ( int i = 0; i < numLimits - 1; i++ ) + if (intervalType != QwtDate::Day) + { + if ((intervalSize > numSteps) && (intervalSize <= 2 * numSteps)) { - if ( v <= limits[i] ) - return limits[i]; + return 2.0; } + } - return limits[ numLimits - 1 ]; + double stepSize; + + switch (intervalType) + { + case QwtDate::Second: + case QwtDate::Minute: { + static int limits[] = {1, 2, 5, 10, 15, 20, 30, 60}; + + stepSize = qwtDivideInterval(intervalSize, numSteps, limits, + sizeof(limits) / sizeof(int)); + + break; + } + case QwtDate::Hour: { + static int limits[] = {1, 2, 3, 4, 6, 12, 24}; + + stepSize = qwtDivideInterval(intervalSize, numSteps, limits, + sizeof(limits) / sizeof(int)); + + break; + } + case QwtDate::Day: { + const double v = intervalSize / double(numSteps); + if (v <= 5.0) + stepSize = std::ceil(v); + else + stepSize = std::ceil(v / 7) * 7; + + break; + } + case QwtDate::Week: { + static int limits[] = {1, 2, 4, 8, 12, 26, 52}; + + stepSize = qwtDivideInterval(intervalSize, numSteps, limits, + sizeof(limits) / sizeof(int)); + + break; + } + case QwtDate::Month: { + static int limits[] = {1, 2, 3, 4, 6, 12}; + + stepSize = qwtDivideInterval(intervalSize, numSteps, limits, + sizeof(limits) / sizeof(int)); + + break; + } + case QwtDate::Year: + case QwtDate::Millisecond: + default: { + stepSize = QwtScaleArithmetic::divideInterval(intervalSize, numSteps, 10); + } + } + + return stepSize; } -static double qwtDivideScale( double intervalSize, int numSteps, - QwtDate::IntervalType intervalType ) +static double qwtDivideMajorStep(double stepSize, int maxMinSteps, + QwtDate::IntervalType intervalType) { - if ( intervalType != QwtDate::Day ) - { - if ( ( intervalSize > numSteps ) && - ( intervalSize <= 2 * numSteps ) ) - { - return 2.0; - } - } + double minStepSize = 0.0; - double stepSize; - - switch( intervalType ) - { - case QwtDate::Second: - case QwtDate::Minute: - { - static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 }; - - stepSize = qwtDivideInterval( intervalSize, numSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - break; - } - case QwtDate::Hour: - { - static int limits[] = { 1, 2, 3, 4, 6, 12, 24 }; - - stepSize = qwtDivideInterval( intervalSize, numSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - break; - } - case QwtDate::Day: - { - const double v = intervalSize / double( numSteps ); - if ( v <= 5.0 ) - stepSize = std::ceil( v ); - else - stepSize = std::ceil( v / 7 ) * 7; - - break; - } - case QwtDate::Week: - { - static int limits[] = { 1, 2, 4, 8, 12, 26, 52 }; - - stepSize = qwtDivideInterval( intervalSize, numSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - break; - } - case QwtDate::Month: - { - static int limits[] = { 1, 2, 3, 4, 6, 12 }; - - stepSize = qwtDivideInterval( intervalSize, numSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - break; - } - case QwtDate::Year: - case QwtDate::Millisecond: - default: - { - stepSize = QwtScaleArithmetic::divideInterval( - intervalSize, numSteps, 10 ); - } - } - - return stepSize; -} - -static double qwtDivideMajorStep( double stepSize, int maxMinSteps, - QwtDate::IntervalType intervalType ) -{ - double minStepSize = 0.0; - - switch( intervalType ) - { - case QwtDate::Second: - { - minStepSize = qwtStepSize( stepSize, maxMinSteps, 10 ); - if ( minStepSize == 0.0 ) - minStepSize = 0.5 * stepSize; - - break; - } - case QwtDate::Minute: - { - static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 }; - - int numSteps; - - if ( stepSize > maxMinSteps ) - { - numSteps = qwtStepCount( stepSize, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - } - else - { - numSteps = qwtStepCount( stepSize * 60, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - } - - if ( numSteps > 0 ) - minStepSize = stepSize / numSteps; - - break; - } - case QwtDate::Hour: - { - int numSteps = 0; - - if ( stepSize > maxMinSteps ) - { - static int limits[] = { 1, 2, 3, 4, 6, 12, 24, 48, 72 }; - - numSteps = qwtStepCount( stepSize, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - } - else - { - static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 }; - - numSteps = qwtStepCount( stepSize * 60, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - } - - if ( numSteps > 0 ) - minStepSize = stepSize / numSteps; - - break; - } - case QwtDate::Day: - { - int numSteps = 0; - - if ( stepSize > maxMinSteps ) - { - static int limits[] = { 1, 2, 3, 7, 14, 28 }; - - numSteps = qwtStepCount( stepSize, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - } - else - { - static int limits[] = { 1, 2, 3, 4, 6, 12, 24, 48, 72 }; - - numSteps = qwtStepCount( stepSize * 24, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - } - - if ( numSteps > 0 ) - minStepSize = stepSize / numSteps; - - break; - } - case QwtDate::Week: - { - const int daysInStep = stepSize * 7; - - if ( maxMinSteps >= daysInStep ) - { - // we want to have one tick per day - minStepSize = 1.0 / 7.0; - } - else - { - // when the stepSize is more than a week we want to - // have a tick for each week - - const int stepSizeInWeeks = stepSize; - - if ( stepSizeInWeeks <= maxMinSteps ) - { - minStepSize = 1; - } - else - { - minStepSize = QwtScaleArithmetic::divideInterval( - stepSizeInWeeks, maxMinSteps, 10 ); - } - } - break; - } - case QwtDate::Month: - { - // fractions of months doesn't make any sense - - if ( stepSize < maxMinSteps ) - maxMinSteps = static_cast< int >( stepSize ); - - static int limits[] = { 1, 2, 3, 4, 6, 12 }; - - int numSteps = qwtStepCount( stepSize, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - if ( numSteps > 0 ) - minStepSize = stepSize / numSteps; - - break; - } - case QwtDate::Year: - { - if ( stepSize >= maxMinSteps ) - { - minStepSize = QwtScaleArithmetic::divideInterval( - stepSize, maxMinSteps, 10 ); - } - else - { - // something in months - - static int limits[] = { 1, 2, 3, 4, 6, 12 }; - - int numSteps = qwtStepCount( 12 * stepSize, maxMinSteps, - limits, sizeof( limits ) / sizeof( int ) ); - - if ( numSteps > 0 ) - minStepSize = stepSize / numSteps; - } - - break; - } - default: - break; - } - - if ( intervalType != QwtDate::Month - && minStepSize == 0.0 ) - { + switch (intervalType) + { + case QwtDate::Second: { + minStepSize = qwtStepSize(stepSize, maxMinSteps, 10); + if (minStepSize == 0.0) minStepSize = 0.5 * stepSize; + + break; } + case QwtDate::Minute: { + static int limits[] = {1, 2, 5, 10, 15, 20, 30, 60}; - return minStepSize; -} + int numSteps; -static QList< double > qwtDstTicks( const QDateTime& dateTime, - int secondsMajor, int secondsMinor ) -{ - if ( secondsMinor <= 0 ) - QList< double >(); + if (stepSize > maxMinSteps) + { + numSteps = qwtStepCount(stepSize, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); + } + else + { + numSteps = qwtStepCount(stepSize * 60, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); + } - QDateTime minDate = dateTime.addSecs( -secondsMajor ); - minDate = QwtDate::floor( minDate, QwtDate::Hour ); + if (numSteps > 0) + minStepSize = stepSize / numSteps; - const double utcOffset = QwtDate::utcOffset( dateTime ); - - // find the hours where daylight saving time happens - - double dstMin = QwtDate::toDouble( minDate ); - while ( minDate < dateTime && - QwtDate::utcOffset( minDate ) != utcOffset ) - { - minDate = minDate.addSecs( 3600 ); - dstMin += 3600 * 1000.0; + break; } + case QwtDate::Hour: { + int numSteps = 0; - QList< double > ticks; - ticks.reserve( 3600 / secondsMinor); + if (stepSize > maxMinSteps) + { + static int limits[] = {1, 2, 3, 4, 6, 12, 24, 48, 72}; - for ( int i = 0; i < 3600; i += secondsMinor ) - ticks += dstMin + i * 1000.0; + numSteps = qwtStepCount(stepSize, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); + } + else + { + static int limits[] = {1, 2, 5, 10, 15, 20, 30, 60}; - return ticks; -} + numSteps = qwtStepCount(stepSize * 60, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); + } -static QwtScaleDiv qwtDivideToSeconds( - const QDateTime& minDate, const QDateTime& maxDate, - double stepSize, int maxMinSteps, - QwtDate::IntervalType intervalType ) -{ - // calculate the min step size - double minStepSize = 0; + if (numSteps > 0) + minStepSize = stepSize / numSteps; - if ( maxMinSteps > 1 ) - { - minStepSize = qwtDivideMajorStep( stepSize, - maxMinSteps, intervalType ); + break; } + case QwtDate::Day: { + int numSteps = 0; - bool daylightSaving = false; - if ( minDate.timeSpec() == Qt::LocalTime ) - { - daylightSaving = intervalType > QwtDate::Hour; - if ( intervalType == QwtDate::Hour ) + if (stepSize > maxMinSteps) + { + static int limits[] = {1, 2, 3, 7, 14, 28}; + + numSteps = qwtStepCount(stepSize, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); + } + else + { + static int limits[] = {1, 2, 3, 4, 6, 12, 24, 48, 72}; + + numSteps = qwtStepCount(stepSize * 24, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); + } + + if (numSteps > 0) + minStepSize = stepSize / numSteps; + + break; + } + case QwtDate::Week: { + const int daysInStep = stepSize * 7; + + if (maxMinSteps >= daysInStep) + { + // we want to have one tick per day + minStepSize = 1.0 / 7.0; + } + else + { + // when the stepSize is more than a week we want to + // have a tick for each week + + const int stepSizeInWeeks = stepSize; + + if (stepSizeInWeeks <= maxMinSteps) { - daylightSaving = stepSize > 1; - } - } - - const double s = qwtMsecsForType( intervalType ) / 1000; - const int secondsMajor = static_cast< int >( stepSize * s ); - const double secondsMinor = minStepSize * s; - - // UTC excludes daylight savings. So from the difference - // of a date and its UTC counterpart we can find out - // the daylight saving hours - - const double utcOffset = QwtDate::utcOffset( minDate ); - double dstOff = 0; - - QList< double > majorTicks; - QList< double > mediumTicks; - QList< double > minorTicks; - - for ( QDateTime dt = minDate; dt <= maxDate; - dt = dt.addSecs( secondsMajor ) ) - { - if ( !dt.isValid() ) - break; - - double majorValue = QwtDate::toDouble( dt ); - - if ( daylightSaving ) - { - const double offset = utcOffset - QwtDate::utcOffset( dt ); - majorValue += offset * 1000.0; - - if ( offset > dstOff ) - { - // we add some minor ticks for the DST hour, - // otherwise the ticks will be unaligned: 0, 2, 3, 5 ... - minorTicks += qwtDstTicks( - dt, secondsMajor, qRound( secondsMinor ) ); - } - - dstOff = offset; - } - - if ( majorTicks.isEmpty() || majorTicks.last() != majorValue ) - majorTicks += majorValue; - - if ( secondsMinor > 0.0 ) - { - const int numMinorSteps = qwtFloor( secondsMajor / secondsMinor ); - - for ( int i = 1; i < numMinorSteps; i++ ) - { - const QDateTime mt = dt.addMSecs( - qRound64( i * secondsMinor * 1000 ) ); - - double minorValue = QwtDate::toDouble( mt ); - if ( daylightSaving ) - { - const double offset = utcOffset - QwtDate::utcOffset( mt ); - minorValue += offset * 1000.0; - } - - if ( minorTicks.isEmpty() || minorTicks.last() != minorValue ) - { - const bool isMedium = ( numMinorSteps % 2 == 0 ) - && ( i != 1 ) && ( i == numMinorSteps / 2 ); - - if ( isMedium ) - mediumTicks += minorValue; - else - minorTicks += minorValue; - } - } - } - } - - QwtScaleDiv scaleDiv; - - scaleDiv.setInterval( QwtDate::toDouble( minDate ), - QwtDate::toDouble( maxDate ) ); - - scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks ); - scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks ); - scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks ); - - return scaleDiv; -} - -static QwtScaleDiv qwtDivideToMonths( - QDateTime& minDate, const QDateTime& maxDate, - double stepSize, int maxMinSteps ) -{ - // months are intervals with non - // equidistant ( in ms ) steps: we have to build the - // scale division manually - - int minStepDays = 0; - int minStepSize = 0.0; - - if ( maxMinSteps > 1 ) - { - if ( stepSize == 1 ) - { - if ( maxMinSteps >= 30 ) - minStepDays = 1; - else if ( maxMinSteps >= 6 ) - minStepDays = 5; - else if ( maxMinSteps >= 3 ) - minStepDays = 10; - else - minStepDays = 15; + minStepSize = 1; } else { - minStepSize = qwtDivideMajorStep( - stepSize, maxMinSteps, QwtDate::Month ); + minStepSize = QwtScaleArithmetic::divideInterval(stepSizeInWeeks, + maxMinSteps, 10); } + } + break; } + case QwtDate::Month: { + // fractions of months doesn't make any sense - QList< double > majorTicks; - QList< double > mediumTicks; - QList< double > minorTicks; + if (stepSize < maxMinSteps) + maxMinSteps = static_cast(stepSize); - for ( QDateTime dt = minDate; - dt <= maxDate; dt = dt.addMonths( stepSize ) ) - { - if ( !dt.isValid() ) - break; + static int limits[] = {1, 2, 3, 4, 6, 12}; - majorTicks += QwtDate::toDouble( dt ); + int numSteps = qwtStepCount(stepSize, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); - if ( minStepDays > 0 ) - { - for ( int days = minStepDays; - days < 30; days += minStepDays ) - { - const double tick = QwtDate::toDouble( dt.addDays( days ) ); + if (numSteps > 0) + minStepSize = stepSize / numSteps; - if ( days == 15 && minStepDays != 15 ) - mediumTicks += tick; - else - minorTicks += tick; - } - } - else if ( minStepSize > 0.0 ) - { - const int numMinorSteps = qRound( stepSize / (double) minStepSize ); - - for ( int i = 1; i < numMinorSteps; i++ ) - { - const double minorValue = - QwtDate::toDouble( dt.addMonths( i * minStepSize ) ); - - if ( ( numMinorSteps % 2 == 0 ) && ( i == numMinorSteps / 2 ) ) - mediumTicks += minorValue; - else - minorTicks += minorValue; - } - } + break; } + case QwtDate::Year: { + if (stepSize >= maxMinSteps) + { + minStepSize + = QwtScaleArithmetic::divideInterval(stepSize, maxMinSteps, 10); + } + else + { + // something in months - QwtScaleDiv scaleDiv; - scaleDiv.setInterval( QwtDate::toDouble( minDate ), - QwtDate::toDouble( maxDate ) ); + static int limits[] = {1, 2, 3, 4, 6, 12}; - scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks ); - scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks ); - scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks ); + int numSteps = qwtStepCount(12 * stepSize, maxMinSteps, limits, + sizeof(limits) / sizeof(int)); - return scaleDiv; + if (numSteps > 0) + minStepSize = stepSize / numSteps; + } + + break; + } + default: + break; + } + + if (intervalType != QwtDate::Month && minStepSize == 0.0) + { + minStepSize = 0.5 * stepSize; + } + + return minStepSize; } -static QwtScaleDiv qwtDivideToYears( - const QDateTime& minDate, const QDateTime& maxDate, - double stepSize, int maxMinSteps ) +static QList qwtDstTicks(const QDateTime &dateTime, int secondsMajor, + int secondsMinor) { - QList< double > majorTicks; - QList< double > mediumTicks; - QList< double > minorTicks; + if (secondsMinor <= 0) + QList(); - double minStepSize = 0.0; + QDateTime minDate = dateTime.addSecs(-secondsMajor); + minDate = QwtDate::floor(minDate, QwtDate::Hour); - if ( maxMinSteps > 1 ) + const double utcOffset = QwtDate::utcOffset(dateTime); + + // find the hours where daylight saving time happens + + double dstMin = QwtDate::toDouble(minDate); + while (minDate < dateTime && QwtDate::utcOffset(minDate) != utcOffset) + { + minDate = minDate.addSecs(3600); + dstMin += 3600 * 1000.0; + } + + QList ticks; + ticks.reserve(3600 / secondsMinor); + + for (int i = 0; i < 3600; i += secondsMinor) + ticks += dstMin + i * 1000.0; + + return ticks; +} + +static QwtScaleDiv qwtDivideToSeconds(const QDateTime &minDate, + const QDateTime &maxDate, double stepSize, + int maxMinSteps, + QwtDate::IntervalType intervalType) +{ + // calculate the min step size + double minStepSize = 0; + + if (maxMinSteps > 1) + { + minStepSize = qwtDivideMajorStep(stepSize, maxMinSteps, intervalType); + } + + bool daylightSaving = false; + if (minDate.timeSpec() == Qt::LocalTime) + { + daylightSaving = intervalType > QwtDate::Hour; + if (intervalType == QwtDate::Hour) { - minStepSize = qwtDivideMajorStep( - stepSize, maxMinSteps, QwtDate::Year ); + daylightSaving = stepSize > 1; + } + } + + const double s = qwtMsecsForType(intervalType) / 1000; + const int secondsMajor = static_cast(stepSize * s); + const double secondsMinor = minStepSize * s; + + // UTC excludes daylight savings. So from the difference + // of a date and its UTC counterpart we can find out + // the daylight saving hours + + const double utcOffset = QwtDate::utcOffset(minDate); + double dstOff = 0; + + QList majorTicks; + QList mediumTicks; + QList minorTicks; + + for (QDateTime dt = minDate; dt <= maxDate; dt = dt.addSecs(secondsMajor)) + { + if (!dt.isValid()) + break; + + double majorValue = QwtDate::toDouble(dt); + + if (daylightSaving) + { + const double offset = utcOffset - QwtDate::utcOffset(dt); + majorValue += offset * 1000.0; + + if (offset > dstOff) + { + // we add some minor ticks for the DST hour, + // otherwise the ticks will be unaligned: 0, 2, 3, 5 ... + minorTicks += qwtDstTicks(dt, secondsMajor, qRound(secondsMinor)); + } + + dstOff = offset; } - int numMinorSteps = 0; - if ( minStepSize > 0.0 ) - numMinorSteps = qwtFloor( stepSize / minStepSize ); + if (majorTicks.isEmpty() || majorTicks.last() != majorValue) + majorTicks += majorValue; - bool dateBC = minDate.date().year() < -1; - - for ( QDateTime dt = minDate; dt <= maxDate; - dt = dt.addYears( stepSize ) ) + if (secondsMinor > 0.0) { - if ( dateBC && dt.date().year() > 1 ) + const int numMinorSteps = qwtFloor(secondsMajor / secondsMinor); + + for (int i = 1; i < numMinorSteps; i++) + { + const QDateTime mt = dt.addMSecs(qRound64(i * secondsMinor * 1000)); + + double minorValue = QwtDate::toDouble(mt); + if (daylightSaving) { - // there is no year 0 in the Julian calendar - dt = dt.addYears( -1 ); - dateBC = false; + const double offset = utcOffset - QwtDate::utcOffset(mt); + minorValue += offset * 1000.0; } - if ( !dt.isValid() ) - break; - - majorTicks += QwtDate::toDouble( dt ); - - for ( int i = 1; i < numMinorSteps; i++ ) + if (minorTicks.isEmpty() || minorTicks.last() != minorValue) { - QDateTime tickDate; + const bool isMedium = (numMinorSteps % 2 == 0) && (i != 1) + && (i == numMinorSteps / 2); - const double years = qRound( i * minStepSize ); - if ( years >= std::numeric_limits< int >::max() / 12 ) - { - tickDate = dt.addYears( years ); - } - else - { - tickDate = dt.addMonths( qRound( years * 12 ) ); - } - - const bool isMedium = ( numMinorSteps > 2 ) && - ( numMinorSteps % 2 == 0 ) && ( i == numMinorSteps / 2 ); - - const double minorValue = QwtDate::toDouble( tickDate ); - if ( isMedium ) - mediumTicks += minorValue; - else - minorTicks += minorValue; + if (isMedium) + mediumTicks += minorValue; + else + minorTicks += minorValue; } + } + } + } - if ( QwtDate::maxDate().addYears( -stepSize ) < dt.date() ) - { - break; - } + QwtScaleDiv scaleDiv; + + scaleDiv.setInterval(QwtDate::toDouble(minDate), QwtDate::toDouble(maxDate)); + + scaleDiv.setTicks(QwtScaleDiv::MajorTick, majorTicks); + scaleDiv.setTicks(QwtScaleDiv::MediumTick, mediumTicks); + scaleDiv.setTicks(QwtScaleDiv::MinorTick, minorTicks); + + return scaleDiv; +} + +static QwtScaleDiv qwtDivideToMonths(QDateTime &minDate, + const QDateTime &maxDate, double stepSize, + int maxMinSteps) +{ + // months are intervals with non + // equidistant ( in ms ) steps: we have to build the + // scale division manually + + int minStepDays = 0; + int minStepSize = 0.0; + + if (maxMinSteps > 1) + { + if (stepSize == 1) + { + if (maxMinSteps >= 30) + minStepDays = 1; + else if (maxMinSteps >= 6) + minStepDays = 5; + else if (maxMinSteps >= 3) + minStepDays = 10; + else + minStepDays = 15; + } + else + { + minStepSize = qwtDivideMajorStep(stepSize, maxMinSteps, QwtDate::Month); + } + } + + QList majorTicks; + QList mediumTicks; + QList minorTicks; + + for (QDateTime dt = minDate; dt <= maxDate; dt = dt.addMonths(stepSize)) + { + if (!dt.isValid()) + break; + + majorTicks += QwtDate::toDouble(dt); + + if (minStepDays > 0) + { + for (int days = minStepDays; days < 30; days += minStepDays) + { + const double tick = QwtDate::toDouble(dt.addDays(days)); + + if (days == 15 && minStepDays != 15) + mediumTicks += tick; + else + minorTicks += tick; + } + } + else if (minStepSize > 0.0) + { + const int numMinorSteps = qRound(stepSize / (double)minStepSize); + + for (int i = 1; i < numMinorSteps; i++) + { + const double minorValue + = QwtDate::toDouble(dt.addMonths(i * minStepSize)); + + if ((numMinorSteps % 2 == 0) && (i == numMinorSteps / 2)) + mediumTicks += minorValue; + else + minorTicks += minorValue; + } + } + } + + QwtScaleDiv scaleDiv; + scaleDiv.setInterval(QwtDate::toDouble(minDate), QwtDate::toDouble(maxDate)); + + scaleDiv.setTicks(QwtScaleDiv::MajorTick, majorTicks); + scaleDiv.setTicks(QwtScaleDiv::MediumTick, mediumTicks); + scaleDiv.setTicks(QwtScaleDiv::MinorTick, minorTicks); + + return scaleDiv; +} + +static QwtScaleDiv qwtDivideToYears(const QDateTime &minDate, + const QDateTime &maxDate, double stepSize, + int maxMinSteps) +{ + QList majorTicks; + QList mediumTicks; + QList minorTicks; + + double minStepSize = 0.0; + + if (maxMinSteps > 1) + { + minStepSize = qwtDivideMajorStep(stepSize, maxMinSteps, QwtDate::Year); + } + + int numMinorSteps = 0; + if (minStepSize > 0.0) + numMinorSteps = qwtFloor(stepSize / minStepSize); + + bool dateBC = minDate.date().year() < -1; + + for (QDateTime dt = minDate; dt <= maxDate; dt = dt.addYears(stepSize)) + { + if (dateBC && dt.date().year() > 1) + { + // there is no year 0 in the Julian calendar + dt = dt.addYears(-1); + dateBC = false; } - QwtScaleDiv scaleDiv; - scaleDiv.setInterval( QwtDate::toDouble( minDate ), - QwtDate::toDouble( maxDate ) ); + if (!dt.isValid()) + break; - scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks ); - scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks ); - scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks ); + majorTicks += QwtDate::toDouble(dt); - return scaleDiv; + for (int i = 1; i < numMinorSteps; i++) + { + QDateTime tickDate; + + const double years = qRound(i * minStepSize); + if (years >= std::numeric_limits::max() / 12) + { + tickDate = dt.addYears(years); + } + else + { + tickDate = dt.addMonths(qRound(years * 12)); + } + + const bool isMedium = (numMinorSteps > 2) && (numMinorSteps % 2 == 0) + && (i == numMinorSteps / 2); + + const double minorValue = QwtDate::toDouble(tickDate); + if (isMedium) + mediumTicks += minorValue; + else + minorTicks += minorValue; + } + + if (QwtDate::maxDate().addYears(-stepSize) < dt.date()) + { + break; + } + } + + QwtScaleDiv scaleDiv; + scaleDiv.setInterval(QwtDate::toDouble(minDate), QwtDate::toDouble(maxDate)); + + scaleDiv.setTicks(QwtScaleDiv::MajorTick, majorTicks); + scaleDiv.setTicks(QwtScaleDiv::MediumTick, mediumTicks); + scaleDiv.setTicks(QwtScaleDiv::MinorTick, minorTicks); + + return scaleDiv; } class QwtDateScaleEngine::PrivateData { - public: - explicit PrivateData( Qt::TimeSpec spec ) - : timeSpec( spec ) - , utcOffset( 0 ) - , week0Type( QwtDate::FirstThursday ) - , maxWeeks( 4 ) - { - } +public: + explicit PrivateData(Qt::TimeSpec spec) + : timeSpec(spec) + , utcOffset(0) + , week0Type(QwtDate::FirstThursday) + , maxWeeks(4) + { + } - Qt::TimeSpec timeSpec; - int utcOffset; - QwtDate::Week0Type week0Type; - int maxWeeks; + Qt::TimeSpec timeSpec; + int utcOffset; + QwtDate::Week0Type week0Type; + int maxWeeks; }; - /*! \brief Constructor @@ -744,16 +703,16 @@ class QwtDateScaleEngine::PrivateData \sa setTimeSpec(), setMaxWeeks(), setWeek0Type() */ -QwtDateScaleEngine::QwtDateScaleEngine( Qt::TimeSpec timeSpec ) - : QwtLinearScaleEngine( 10 ) +QwtDateScaleEngine::QwtDateScaleEngine(Qt::TimeSpec timeSpec) + : QwtLinearScaleEngine(10) { - m_data = new PrivateData( timeSpec ); + m_data = new PrivateData(timeSpec); } //! Destructor QwtDateScaleEngine::~QwtDateScaleEngine() { - delete m_data; + delete m_data; } /*! @@ -762,9 +721,9 @@ QwtDateScaleEngine::~QwtDateScaleEngine() \param timeSpec Time specification \sa timeSpec(), setUtcOffset(), toDateTime() */ -void QwtDateScaleEngine::setTimeSpec( Qt::TimeSpec timeSpec ) +void QwtDateScaleEngine::setTimeSpec(Qt::TimeSpec timeSpec) { - m_data->timeSpec = timeSpec; + m_data->timeSpec = timeSpec; } /*! @@ -773,7 +732,7 @@ void QwtDateScaleEngine::setTimeSpec( Qt::TimeSpec timeSpec ) */ Qt::TimeSpec QwtDateScaleEngine::timeSpec() const { - return m_data->timeSpec; + return m_data->timeSpec; } /*! @@ -786,9 +745,9 @@ Qt::TimeSpec QwtDateScaleEngine::timeSpec() const \sa QDate::utcOffset(), setTimeSpec(), toDateTime() */ -void QwtDateScaleEngine::setUtcOffset( int seconds ) +void QwtDateScaleEngine::setUtcOffset(int seconds) { - m_data->utcOffset = seconds; + m_data->utcOffset = seconds; } /*! @@ -800,7 +759,7 @@ void QwtDateScaleEngine::setUtcOffset( int seconds ) */ int QwtDateScaleEngine::utcOffset() const { - return m_data->utcOffset; + return m_data->utcOffset; } /*! @@ -812,9 +771,9 @@ int QwtDateScaleEngine::utcOffset() const \note week0Type has no effect beside for intervals classified as QwtDate::Week. */ -void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type ) +void QwtDateScaleEngine::setWeek0Type(QwtDate::Week0Type week0Type) { - m_data->week0Type = week0Type; + m_data->week0Type = week0Type; } /*! @@ -823,7 +782,7 @@ void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type ) */ QwtDate::Week0Type QwtDateScaleEngine::week0Type() const { - return m_data->week0Type; + return m_data->week0Type; } /*! @@ -838,9 +797,9 @@ QwtDate::Week0Type QwtDateScaleEngine::week0Type() const into weeks [1-52] \sa maxWeeks(), setWeek0Type() */ -void QwtDateScaleEngine::setMaxWeeks( int weeks ) +void QwtDateScaleEngine::setMaxWeeks(int weeks) { - m_data->maxWeeks = qMax( weeks, 0 ); + m_data->maxWeeks = qMax(weeks, 0); } /*! @@ -850,7 +809,7 @@ void QwtDateScaleEngine::setMaxWeeks( int weeks ) */ int QwtDateScaleEngine::maxWeeks() const { - return m_data->maxWeeks; + return m_data->maxWeeks; } /*! @@ -862,48 +821,49 @@ int QwtDateScaleEngine::maxWeeks() const \return Interval classification */ -QwtDate::IntervalType QwtDateScaleEngine::intervalType( - const QDateTime& minDate, const QDateTime& maxDate, - int maxSteps ) const +QwtDate::IntervalType QwtDateScaleEngine::intervalType(const QDateTime &minDate, + const QDateTime &maxDate, + int maxSteps) const { - const double jdMin = minDate.date().toJulianDay(); - const double jdMax = maxDate.date().toJulianDay(); + const double jdMin = minDate.date().toJulianDay(); + const double jdMax = maxDate.date().toJulianDay(); - if ( ( jdMax - jdMin ) / 365 > maxSteps ) - return QwtDate::Year; + if ((jdMax - jdMin) / 365 > maxSteps) + return QwtDate::Year; - const int months = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Month ); - if ( months > maxSteps * 6 ) - return QwtDate::Year; + const int months = qwtRoundedIntervalWidth(minDate, maxDate, QwtDate::Month); + if (months > maxSteps * 6) + return QwtDate::Year; - const int days = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Day ); - const int weeks = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Week ); + const int days = qwtRoundedIntervalWidth(minDate, maxDate, QwtDate::Day); + const int weeks = qwtRoundedIntervalWidth(minDate, maxDate, QwtDate::Week); - if ( weeks > m_data->maxWeeks ) - { - if ( days > 4 * maxSteps * 7 ) - return QwtDate::Month; - } + if (weeks > m_data->maxWeeks) + { + if (days > 4 * maxSteps * 7) + return QwtDate::Month; + } - if ( days > maxSteps * 7 ) - return QwtDate::Week; + if (days > maxSteps * 7) + return QwtDate::Week; - const int hours = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Hour ); - if ( hours > maxSteps * 24 ) - return QwtDate::Day; + const int hours = qwtRoundedIntervalWidth(minDate, maxDate, QwtDate::Hour); + if (hours > maxSteps * 24) + return QwtDate::Day; - const int seconds = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Second ); + const int seconds + = qwtRoundedIntervalWidth(minDate, maxDate, QwtDate::Second); - if ( seconds >= maxSteps * 3600 ) - return QwtDate::Hour; + if (seconds >= maxSteps * 3600) + return QwtDate::Hour; - if ( seconds >= maxSteps * 60 ) - return QwtDate::Minute; + if (seconds >= maxSteps * 60) + return QwtDate::Minute; - if ( seconds >= maxSteps ) - return QwtDate::Second; + if (seconds >= maxSteps) + return QwtDate::Second; - return QwtDate::Millisecond; + return QwtDate::Millisecond; } /*! @@ -922,60 +882,59 @@ QwtDate::IntervalType QwtDateScaleEngine::intervalType( \sa QwtScaleEngine::setAttribute() */ -void QwtDateScaleEngine::autoScale( int maxNumSteps, - double& x1, double& x2, double& stepSize ) const +void QwtDateScaleEngine::autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const { - stepSize = 0.0; + stepSize = 0.0; - QwtInterval interval( x1, x2 ); - interval = interval.normalized(); + QwtInterval interval(x1, x2); + interval = interval.normalized(); - interval.setMinValue( interval.minValue() - lowerMargin() ); - interval.setMaxValue( interval.maxValue() + upperMargin() ); + interval.setMinValue(interval.minValue() - lowerMargin()); + interval.setMaxValue(interval.maxValue() + upperMargin()); - if ( testAttribute( QwtScaleEngine::Symmetric ) ) - interval = interval.symmetrize( reference() ); + if (testAttribute(QwtScaleEngine::Symmetric)) + interval = interval.symmetrize(reference()); - if ( testAttribute( QwtScaleEngine::IncludeReference ) ) - interval = interval.extend( reference() ); + if (testAttribute(QwtScaleEngine::IncludeReference)) + interval = interval.extend(reference()); - if ( interval.width() == 0.0 ) - interval = buildInterval( interval.minValue() ); + if (interval.width() == 0.0) + interval = buildInterval(interval.minValue()); - const QDateTime from = toDateTime( interval.minValue() ); - const QDateTime to = toDateTime( interval.maxValue() ); + const QDateTime from = toDateTime(interval.minValue()); + const QDateTime to = toDateTime(interval.maxValue()); - if ( from.isValid() && to.isValid() ) + if (from.isValid() && to.isValid()) + { + if (maxNumSteps < 1) + maxNumSteps = 1; + + const QwtDate::IntervalType intvType = intervalType(from, to, maxNumSteps); + + const double width = qwtIntervalWidth(from, to, intvType); + + const double stepWidth = qwtDivideScale(width, maxNumSteps, intvType); + if (stepWidth != 0.0 && !testAttribute(QwtScaleEngine::Floating)) { - if ( maxNumSteps < 1 ) - maxNumSteps = 1; + const QDateTime d1 = alignDate(from, stepWidth, intvType, false); + const QDateTime d2 = alignDate(to, stepWidth, intvType, true); - const QwtDate::IntervalType intvType = - intervalType( from, to, maxNumSteps ); - - const double width = qwtIntervalWidth( from, to, intvType ); - - const double stepWidth = qwtDivideScale( width, maxNumSteps, intvType ); - if ( stepWidth != 0.0 && !testAttribute( QwtScaleEngine::Floating ) ) - { - const QDateTime d1 = alignDate( from, stepWidth, intvType, false ); - const QDateTime d2 = alignDate( to, stepWidth, intvType, true ); - - interval.setMinValue( QwtDate::toDouble( d1 ) ); - interval.setMaxValue( QwtDate::toDouble( d2 ) ); - } - - stepSize = stepWidth * qwtMsecsForType( intvType ); + interval.setMinValue(QwtDate::toDouble(d1)); + interval.setMaxValue(QwtDate::toDouble(d2)); } - x1 = interval.minValue(); - x2 = interval.maxValue(); + stepSize = stepWidth * qwtMsecsForType(intvType); + } - if ( testAttribute( QwtScaleEngine::Inverted ) ) - { - qSwap( x1, x2 ); - stepSize = -stepSize; - } + x1 = interval.minValue(); + x2 = interval.maxValue(); + + if (testAttribute(QwtScaleEngine::Inverted)) + { + qSwap(x1, x2); + stepSize = -stepSize; + } } /*! @@ -989,104 +948,101 @@ void QwtDateScaleEngine::autoScale( int maxNumSteps, calculates one. \return Calculated scale division */ -QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2, - int maxMajorSteps, int maxMinorSteps, double stepSize ) const +QwtScaleDiv QwtDateScaleEngine::divideScale(double x1, double x2, + int maxMajorSteps, + int maxMinorSteps, + double stepSize) const { - if ( maxMajorSteps < 1 ) - maxMajorSteps = 1; + if (maxMajorSteps < 1) + maxMajorSteps = 1; - const double min = qwtMinF( x1, x2 ); - const double max = qwtMaxF( x1, x2 ); + const double min = qwtMinF(x1, x2); + const double max = qwtMaxF(x1, x2); - const QDateTime from = toDateTime( min ); - const QDateTime to = toDateTime( max ); + const QDateTime from = toDateTime(min); + const QDateTime to = toDateTime(max); - if ( from == to ) - return QwtScaleDiv(); + if (from == to) + return QwtScaleDiv(); - stepSize = qAbs( stepSize ); - if ( stepSize > 0.0 ) - { - // as interval types above hours are not equidistant - // ( even days might have 23/25 hours because of daylight saving ) - // the stepSize is used as a hint only + stepSize = qAbs(stepSize); + if (stepSize > 0.0) + { + // as interval types above hours are not equidistant + // ( even days might have 23/25 hours because of daylight saving ) + // the stepSize is used as a hint only - maxMajorSteps = qwtCeil( ( max - min ) / stepSize ); - } + maxMajorSteps = qwtCeil((max - min) / stepSize); + } - const QwtDate::IntervalType intvType = - intervalType( from, to, maxMajorSteps ); + const QwtDate::IntervalType intvType = intervalType(from, to, maxMajorSteps); - QwtScaleDiv scaleDiv; + QwtScaleDiv scaleDiv; - if ( intvType == QwtDate::Millisecond ) - { - // for milliseconds and below we can use the decimal system - scaleDiv = QwtLinearScaleEngine::divideScale( min, max, - maxMajorSteps, maxMinorSteps, stepSize ); - } - else - { - const QDateTime minDate = QwtDate::floor( from, intvType ); - const QDateTime maxDate = QwtDate::ceil( to, intvType ); + if (intvType == QwtDate::Millisecond) + { + // for milliseconds and below we can use the decimal system + scaleDiv = QwtLinearScaleEngine::divideScale(min, max, maxMajorSteps, + maxMinorSteps, stepSize); + } + else + { + const QDateTime minDate = QwtDate::floor(from, intvType); + const QDateTime maxDate = QwtDate::ceil(to, intvType); - scaleDiv = buildScaleDiv( minDate, maxDate, - maxMajorSteps, maxMinorSteps, intvType ); + scaleDiv = buildScaleDiv(minDate, maxDate, maxMajorSteps, maxMinorSteps, + intvType); - // scaleDiv has been calculated from an extended interval - // adjusted to the step size. We have to shrink it again. + // scaleDiv has been calculated from an extended interval + // adjusted to the step size. We have to shrink it again. - scaleDiv = scaleDiv.bounded( min, max ); - } + scaleDiv = scaleDiv.bounded(min, max); + } - if ( x1 > x2 ) - scaleDiv.invert(); + if (x1 > x2) + scaleDiv.invert(); - return scaleDiv; + return scaleDiv; } QwtScaleDiv QwtDateScaleEngine::buildScaleDiv( - const QDateTime& minDate, const QDateTime& maxDate, - int maxMajorSteps, int maxMinorSteps, - QwtDate::IntervalType intervalType ) const + const QDateTime &minDate, const QDateTime &maxDate, int maxMajorSteps, + int maxMinorSteps, QwtDate::IntervalType intervalType) const { - // calculate the step size - const double stepSize = qwtDivideScale( - qwtIntervalWidth( minDate, maxDate, intervalType ), - maxMajorSteps, intervalType ); + // calculate the step size + const double stepSize + = qwtDivideScale(qwtIntervalWidth(minDate, maxDate, intervalType), + maxMajorSteps, intervalType); - // align minDate to the step size - QDateTime dt0 = alignDate( minDate, stepSize, intervalType, false ); - if ( !dt0.isValid() ) + // align minDate to the step size + QDateTime dt0 = alignDate(minDate, stepSize, intervalType, false); + if (!dt0.isValid()) + { + // the floored date is out of the range of a + // QDateTime - we ceil instead. + dt0 = alignDate(minDate, stepSize, intervalType, true); + } + + QwtScaleDiv scaleDiv; + + if (intervalType <= QwtDate::Week) + { + scaleDiv = qwtDivideToSeconds(dt0, maxDate, stepSize, maxMinorSteps, + intervalType); + } + else + { + if (intervalType == QwtDate::Month) { - // the floored date is out of the range of a - // QDateTime - we ceil instead. - dt0 = alignDate( minDate, stepSize, intervalType, true ); + scaleDiv = qwtDivideToMonths(dt0, maxDate, stepSize, maxMinorSteps); } - - QwtScaleDiv scaleDiv; - - if ( intervalType <= QwtDate::Week ) + else if (intervalType == QwtDate::Year) { - scaleDiv = qwtDivideToSeconds( dt0, maxDate, - stepSize, maxMinorSteps, intervalType ); - } - else - { - if( intervalType == QwtDate::Month ) - { - scaleDiv = qwtDivideToMonths( dt0, maxDate, - stepSize, maxMinorSteps ); - } - else if ( intervalType == QwtDate::Year ) - { - scaleDiv = qwtDivideToYears( dt0, maxDate, - stepSize, maxMinorSteps ); - } + scaleDiv = qwtDivideToYears(dt0, maxDate, stepSize, maxMinorSteps); } + } - - return scaleDiv; + return scaleDiv; } /*! @@ -1105,186 +1061,175 @@ QwtScaleDiv QwtDateScaleEngine::buildScaleDiv( \return Aligned date/time value */ -QDateTime QwtDateScaleEngine::alignDate( - const QDateTime& dateTime, double stepSize, - QwtDate::IntervalType intervalType, bool up ) const +QDateTime QwtDateScaleEngine::alignDate(const QDateTime &dateTime, + double stepSize, + QwtDate::IntervalType intervalType, + bool up) const { - // what about: (year == 1582 && month == 10 && day > 4 && day < 15) ?? + // what about: (year == 1582 && month == 10 && day > 4 && day < 15) ?? - QDateTime dt = dateTime; + QDateTime dt = dateTime; - if ( dateTime.timeSpec() == Qt::OffsetFromUTC ) - { + if (dateTime.timeSpec() == Qt::OffsetFromUTC) + { #if QT_VERSION >= 0x050200 - dt.setOffsetFromUtc( 0 ); + dt.setOffsetFromUtc(0); #else - dt.setUtcOffset( 0 ); + dt.setUtcOffset(0); #endif + } + + switch (intervalType) + { + case QwtDate::Millisecond: { + const int ms = qwtAlignValue(dt.time().msec(), stepSize, up); + + dt = QwtDate::floor(dateTime, QwtDate::Second); + dt = dt.addMSecs(ms); + + break; } + case QwtDate::Second: { + int second = dt.time().second(); + if (up) + { + if (dt.time().msec() > 0) + second++; + } - switch( intervalType ) - { - case QwtDate::Millisecond: - { - const int ms = qwtAlignValue( - dt.time().msec(), stepSize, up ); + const int s = qwtAlignValue(second, stepSize, up); - dt = QwtDate::floor( dateTime, QwtDate::Second ); - dt = dt.addMSecs( ms ); + dt = QwtDate::floor(dt, QwtDate::Minute); + dt = dt.addSecs(s); - break; - } - case QwtDate::Second: - { - int second = dt.time().second(); - if ( up ) - { - if ( dt.time().msec() > 0 ) - second++; - } - - const int s = qwtAlignValue( second, stepSize, up ); - - dt = QwtDate::floor( dt, QwtDate::Minute ); - dt = dt.addSecs( s ); - - break; - } - case QwtDate::Minute: - { - int minute = dt.time().minute(); - if ( up ) - { - if ( dt.time().msec() > 0 || dt.time().second() > 0 ) - minute++; - } - - const int m = qwtAlignValue( minute, stepSize, up ); - - dt = QwtDate::floor( dt, QwtDate::Hour ); - dt = dt.addSecs( m * 60 ); - - break; - } - case QwtDate::Hour: - { - int hour = dt.time().hour(); - if ( up ) - { - if ( dt.time().msec() > 0 || dt.time().second() > 0 - || dt.time().minute() > 0 ) - { - hour++; - } - } - const int h = qwtAlignValue( hour, stepSize, up ); - - dt = QwtDate::floor( dt, QwtDate::Day ); - dt = dt.addSecs( h * 3600 ); - - break; - } - case QwtDate::Day: - { - // What date do we expect f.e. from an alignment of 5 days ?? - // Aligning them to the beginning of the year avoids at least - // jumping major ticks when panning - - int day = dt.date().dayOfYear(); - if ( up ) - { - if ( dt.time() > QTime( 0, 0 ) ) - day++; - } - - const int d = qwtAlignValue( day, stepSize, up ); - - dt = QwtDate::floor( dt, QwtDate::Year ); - dt = dt.addDays( d - 1 ); - - break; - } - case QwtDate::Week: - { - const QDate date = QwtDate::dateOfWeek0( - dt.date().year(), m_data->week0Type ); - - int numWeeks = date.daysTo( dt.date() ) / 7; - if ( up ) - { - if ( dt.time() > QTime( 0, 0 ) || - date.daysTo( dt.date() ) % 7 ) - { - numWeeks++; - } - } - - const int d = qwtAlignValue( numWeeks, stepSize, up ) * 7; - - dt = QwtDate::floor( dt, QwtDate::Day ); - dt.setDate( date ); - dt = dt.addDays( d ); - - break; - } - case QwtDate::Month: - { - int month = dt.date().month(); - if ( up ) - { - if ( dt.date().day() > 1 || - dt.time() > QTime( 0, 0 ) ) - { - month++; - } - } - - const int m = qwtAlignValue( month - 1, stepSize, up ); - - dt = QwtDate::floor( dt, QwtDate::Year ); - dt = dt.addMonths( m ); - - break; - } - case QwtDate::Year: - { - int year = dateTime.date().year(); - if ( up ) - { - if ( dateTime.date().dayOfYear() > 1 || - dt.time() > QTime( 0, 0 ) ) - { - year++; - } - } - - const int y = qwtAlignValue( year, stepSize, up ); - - dt = QwtDate::floor( dt, QwtDate::Day ); - if ( y == 0 ) - { - // there is no year 0 in the Julian calendar - dt.setDate( QDate( stepSize, 1, 1 ).addYears( -stepSize ) ); - } - else - { - dt.setDate( QDate( y, 1, 1 ) ); - } - - break; - } + break; } + case QwtDate::Minute: { + int minute = dt.time().minute(); + if (up) + { + if (dt.time().msec() > 0 || dt.time().second() > 0) + minute++; + } - if ( dateTime.timeSpec() == Qt::OffsetFromUTC ) - { + const int m = qwtAlignValue(minute, stepSize, up); + + dt = QwtDate::floor(dt, QwtDate::Hour); + dt = dt.addSecs(m * 60); + + break; + } + case QwtDate::Hour: { + int hour = dt.time().hour(); + if (up) + { + if (dt.time().msec() > 0 || dt.time().second() > 0 + || dt.time().minute() > 0) + { + hour++; + } + } + const int h = qwtAlignValue(hour, stepSize, up); + + dt = QwtDate::floor(dt, QwtDate::Day); + dt = dt.addSecs(h * 3600); + + break; + } + case QwtDate::Day: { + // What date do we expect f.e. from an alignment of 5 days ?? + // Aligning them to the beginning of the year avoids at least + // jumping major ticks when panning + + int day = dt.date().dayOfYear(); + if (up) + { + if (dt.time() > QTime(0, 0)) + day++; + } + + const int d = qwtAlignValue(day, stepSize, up); + + dt = QwtDate::floor(dt, QwtDate::Year); + dt = dt.addDays(d - 1); + + break; + } + case QwtDate::Week: { + const QDate date + = QwtDate::dateOfWeek0(dt.date().year(), m_data->week0Type); + + int numWeeks = date.daysTo(dt.date()) / 7; + if (up) + { + if (dt.time() > QTime(0, 0) || date.daysTo(dt.date()) % 7) + { + numWeeks++; + } + } + + const int d = qwtAlignValue(numWeeks, stepSize, up) * 7; + + dt = QwtDate::floor(dt, QwtDate::Day); + dt.setDate(date); + dt = dt.addDays(d); + + break; + } + case QwtDate::Month: { + int month = dt.date().month(); + if (up) + { + if (dt.date().day() > 1 || dt.time() > QTime(0, 0)) + { + month++; + } + } + + const int m = qwtAlignValue(month - 1, stepSize, up); + + dt = QwtDate::floor(dt, QwtDate::Year); + dt = dt.addMonths(m); + + break; + } + case QwtDate::Year: { + int year = dateTime.date().year(); + if (up) + { + if (dateTime.date().dayOfYear() > 1 || dt.time() > QTime(0, 0)) + { + year++; + } + } + + const int y = qwtAlignValue(year, stepSize, up); + + dt = QwtDate::floor(dt, QwtDate::Day); + if (y == 0) + { + // there is no year 0 in the Julian calendar + dt.setDate(QDate(stepSize, 1, 1).addYears(-stepSize)); + } + else + { + dt.setDate(QDate(y, 1, 1)); + } + + break; + } + } + + if (dateTime.timeSpec() == Qt::OffsetFromUTC) + { #if QT_VERSION >= 0x050200 - dt.setOffsetFromUtc( dateTime.offsetFromUtc() ); + dt.setOffsetFromUtc(dateTime.offsetFromUtc()); #else - dt.setUtcOffset( dateTime.utcOffset() ); + dt.setUtcOffset(dateTime.utcOffset()); #endif - } + } - return dt; + return dt; } /*! @@ -1295,27 +1240,25 @@ QDateTime QwtDateScaleEngine::alignDate( \return QDateTime object initialized with timeSpec() and utcOffset(). \sa timeSpec(), utcOffset(), QwtDate::toDateTime() */ -QDateTime QwtDateScaleEngine::toDateTime( double value ) const +QDateTime QwtDateScaleEngine::toDateTime(double value) const { - QDateTime dt = QwtDate::toDateTime( value, m_data->timeSpec ); - if ( !dt.isValid() ) - { - const QDate date = ( value <= 0.0 ) - ? QwtDate::minDate() : QwtDate::maxDate(); + QDateTime dt = QwtDate::toDateTime(value, m_data->timeSpec); + if (!dt.isValid()) + { + const QDate date = (value <= 0.0) ? QwtDate::minDate() : QwtDate::maxDate(); - dt = QDateTime( date, QTime( 0, 0 ), m_data->timeSpec ); - } + dt = QDateTime(date, QTime(0, 0), m_data->timeSpec); + } - if ( m_data->timeSpec == Qt::OffsetFromUTC ) - { - dt = dt.addSecs( m_data->utcOffset ); + if (m_data->timeSpec == Qt::OffsetFromUTC) + { + dt = dt.addSecs(m_data->utcOffset); #if QT_VERSION >= 0x050200 - dt.setOffsetFromUtc( m_data->utcOffset ); + dt.setOffsetFromUtc(m_data->utcOffset); #else - dt.setUtcOffset( m_data->utcOffset ); + dt.setUtcOffset(m_data->utcOffset); #endif - } + } - return dt; + return dt; } - diff --git a/libs/qwt/src/qwt_date_scale_engine.h b/libs/qwt/src/qwt_date_scale_engine.h index 6e5f68b1..6d0c10d2 100644 --- a/libs/qwt/src/qwt_date_scale_engine.h +++ b/libs/qwt/src/qwt_date_scale_engine.h @@ -41,48 +41,46 @@ */ class QWT_EXPORT QwtDateScaleEngine : public QwtLinearScaleEngine { - public: - explicit QwtDateScaleEngine( Qt::TimeSpec = Qt::LocalTime ); - virtual ~QwtDateScaleEngine(); +public: + explicit QwtDateScaleEngine(Qt::TimeSpec = Qt::LocalTime); + virtual ~QwtDateScaleEngine(); - void setTimeSpec( Qt::TimeSpec ); - Qt::TimeSpec timeSpec() const; + void setTimeSpec(Qt::TimeSpec); + Qt::TimeSpec timeSpec() const; - void setUtcOffset( int seconds ); - int utcOffset() const; + void setUtcOffset(int seconds); + int utcOffset() const; - void setWeek0Type( QwtDate::Week0Type ); - QwtDate::Week0Type week0Type() const; + void setWeek0Type(QwtDate::Week0Type); + QwtDate::Week0Type week0Type() const; - void setMaxWeeks( int ); - int maxWeeks() const; + void setMaxWeeks(int); + int maxWeeks() const; - virtual void autoScale( - int maxNumSteps, double& x1, double& x2, - double& stepSize ) const QWT_OVERRIDE; + virtual void autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const QWT_OVERRIDE; - virtual QwtScaleDiv divideScale( - double x1, double x2, - int maxMajorSteps, int maxMinorSteps, - double stepSize = 0.0 ) const QWT_OVERRIDE; + virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, + int maxMinorSteps, + double stepSize = 0.0) const QWT_OVERRIDE; - virtual QwtDate::IntervalType intervalType( - const QDateTime&, const QDateTime&, int maxSteps ) const; + virtual QwtDate::IntervalType + intervalType(const QDateTime &, const QDateTime &, int maxSteps) const; - QDateTime toDateTime( double ) const; + QDateTime toDateTime(double) const; - protected: - virtual QDateTime alignDate( const QDateTime&, double stepSize, - QwtDate::IntervalType, bool up ) const; +protected: + virtual QDateTime alignDate(const QDateTime &, double stepSize, + QwtDate::IntervalType, bool up) const; - private: - QwtScaleDiv buildScaleDiv( const QDateTime&, const QDateTime&, - int maxMajorSteps, int maxMinorSteps, - QwtDate::IntervalType ) const; +private: + QwtScaleDiv buildScaleDiv(const QDateTime &, const QDateTime &, + int maxMajorSteps, int maxMinorSteps, + QwtDate::IntervalType) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_dial.cpp b/libs/qwt/src/qwt_dial.cpp index 5615d7ae..8a302e74 100644 --- a/libs/qwt/src/qwt_dial.cpp +++ b/libs/qwt/src/qwt_dial.cpp @@ -22,91 +22,87 @@ #include #include -static inline double qwtAngleDist( double a1, double a2 ) +static inline double qwtAngleDist(double a1, double a2) { - double dist = qAbs( a2 - a1 ); - if ( dist > 360.0 ) - dist -= 360.0; + double dist = qAbs(a2 - a1); + if (dist > 360.0) + dist -= 360.0; - return dist; + return dist; } -static inline bool qwtIsOnArc( double angle, double min, double max ) +static inline bool qwtIsOnArc(double angle, double min, double max) { - if ( min < max ) + if (min < max) + { + return (angle >= min) && (angle <= max); + } + else + { + return (angle >= min) || (angle <= max); + } +} + +static inline double qwtBoundedAngle(double min, double angle, double max) +{ + double from = qwtNormalizeDegrees(min); + double to = qwtNormalizeDegrees(max); + + double a; + + if (qwtIsOnArc(angle, from, to)) + { + a = angle; + if (a < min) + a += 360.0; + } + else + { + if (qwtAngleDist(angle, from) < qwtAngleDist(angle, to)) { - return ( angle >= min ) && ( angle <= max ); + a = min; } else { - return ( angle >= min ) || ( angle <= max ); + a = max; } -} + } -static inline double qwtBoundedAngle( double min, double angle, double max ) -{ - double from = qwtNormalizeDegrees( min ); - double to = qwtNormalizeDegrees( max ); - - double a; - - if ( qwtIsOnArc( angle, from, to ) ) - { - a = angle; - if ( a < min ) - a += 360.0; - } - else - { - if ( qwtAngleDist( angle, from ) < - qwtAngleDist( angle, to ) ) - { - a = min; - } - else - { - a = max; - } - } - - return a; + return a; } class QwtDial::PrivateData { - public: - PrivateData() - : frameShadow( Sunken ) - , lineWidth( 0 ) - , mode( RotateNeedle ) - , origin( 90.0 ) - , minScaleArc( 0.0 ) - , maxScaleArc( 0.0 ) - , needle( NULL ) - , arcOffset( 0.0 ) - , mouseOffset( 0.0 ) - { - } +public: + PrivateData() + : frameShadow(Sunken) + , lineWidth(0) + , mode(RotateNeedle) + , origin(90.0) + , minScaleArc(0.0) + , maxScaleArc(0.0) + , needle(NULL) + , arcOffset(0.0) + , mouseOffset(0.0) + { + } - ~PrivateData() - { - delete needle; - } - Shadow frameShadow; - int lineWidth; + ~PrivateData() { delete needle; } + Shadow frameShadow; + int lineWidth; - QwtDial::Mode mode; + QwtDial::Mode mode; - double origin; - double minScaleArc; - double maxScaleArc; + double origin; + double minScaleArc; + double maxScaleArc; - QwtDialNeedle* needle; + QwtDialNeedle *needle; - double arcOffset; - double mouseOffset; + double arcOffset; + double mouseOffset; - QPixmap pixmapCache; + QPixmap pixmapCache; }; /*! @@ -121,44 +117,44 @@ class QwtDial::PrivateData The default mode is QwtDial::RotateNeedle. */ -QwtDial::QwtDial( QWidget* parent ) - : QwtAbstractSlider( parent ) +QwtDial::QwtDial(QWidget *parent) + : QwtAbstractSlider(parent) { - m_data = new PrivateData; + m_data = new PrivateData; - setFocusPolicy( Qt::TabFocus ); + setFocusPolicy(Qt::TabFocus); - QPalette p = palette(); - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - const QPalette::ColorGroup colorGroup = - static_cast< QPalette::ColorGroup >( i ); + QPalette p = palette(); + for (int i = 0; i < QPalette::NColorGroups; i++) + { + const QPalette::ColorGroup colorGroup + = static_cast(i); - // Base: background color of the circle inside the frame. - // WindowText: background color of the circle inside the scale + // Base: background color of the circle inside the frame. + // WindowText: background color of the circle inside the scale - p.setColor( colorGroup, QPalette::WindowText, - p.color( colorGroup, QPalette::Base ) ); - } - setPalette( p ); + p.setColor(colorGroup, QPalette::WindowText, + p.color(colorGroup, QPalette::Base)); + } + setPalette(p); - QwtRoundScaleDraw* scaleDraw = new QwtRoundScaleDraw(); - scaleDraw->setRadius( 0 ); + QwtRoundScaleDraw *scaleDraw = new QwtRoundScaleDraw(); + scaleDraw->setRadius(0); - setScaleDraw( scaleDraw ); + setScaleDraw(scaleDraw); - setScaleArc( 0.0, 360.0 ); // scale as a full circle + setScaleArc(0.0, 360.0); // scale as a full circle - setScaleMaxMajor( 10 ); - setScaleMaxMinor( 5 ); + setScaleMaxMajor(10); + setScaleMaxMinor(5); - setValue( 0.0 ); + setValue(0.0); } //! Destructor QwtDial::~QwtDial() { - delete m_data; + delete m_data; } /*! @@ -167,16 +163,16 @@ QwtDial::~QwtDial() \param shadow Frame shadow \sa setLineWidth(), QFrame::setFrameShadow() */ -void QwtDial::setFrameShadow( Shadow shadow ) +void QwtDial::setFrameShadow(Shadow shadow) { - if ( shadow != m_data->frameShadow ) - { - invalidateCache(); + if (shadow != m_data->frameShadow) + { + invalidateCache(); - m_data->frameShadow = shadow; - if ( lineWidth() > 0 ) - update(); - } + m_data->frameShadow = shadow; + if (lineWidth() > 0) + update(); + } } /*! @@ -185,7 +181,7 @@ void QwtDial::setFrameShadow( Shadow shadow ) */ QwtDial::Shadow QwtDial::frameShadow() const { - return m_data->frameShadow; + return m_data->frameShadow; } /*! @@ -194,18 +190,18 @@ QwtDial::Shadow QwtDial::frameShadow() const \param lineWidth Line width \sa setFrameShadow() */ -void QwtDial::setLineWidth( int lineWidth ) +void QwtDial::setLineWidth(int lineWidth) { - if ( lineWidth < 0 ) - lineWidth = 0; + if (lineWidth < 0) + lineWidth = 0; - if ( m_data->lineWidth != lineWidth ) - { - invalidateCache(); + if (m_data->lineWidth != lineWidth) + { + invalidateCache(); - m_data->lineWidth = lineWidth; - update(); - } + m_data->lineWidth = lineWidth; + update(); + } } /*! @@ -214,7 +210,7 @@ void QwtDial::setLineWidth( int lineWidth ) */ int QwtDial::lineWidth() const { - return m_data->lineWidth; + return m_data->lineWidth; } /*! @@ -223,8 +219,8 @@ int QwtDial::lineWidth() const */ QRect QwtDial::innerRect() const { - const int lw = lineWidth(); - return boundingRect().adjusted( lw, lw, -lw, -lw ); + const int lw = lineWidth(); + return boundingRect().adjusted(lw, lw, -lw, -lw); } /*! @@ -233,14 +229,14 @@ QRect QwtDial::innerRect() const */ QRect QwtDial::boundingRect() const { - const QRect cr = contentsRect(); + const QRect cr = contentsRect(); - const int dim = qMin( cr.width(), cr.height() ); + const int dim = qMin(cr.width(), cr.height()); - QRect inner( 0, 0, dim, dim ); - inner.moveCenter( cr.center() ); + QRect inner(0, 0, dim, dim); + inner.moveCenter(cr.center()); - return inner; + return inner; } /*! @@ -249,18 +245,18 @@ QRect QwtDial::boundingRect() const */ QRect QwtDial::scaleInnerRect() const { - QRect rect = innerRect(); + QRect rect = innerRect(); - const QwtAbstractScaleDraw* sd = scaleDraw(); - if ( sd ) - { - int scaleDist = qwtCeil( sd->extent( font() ) ); - scaleDist++; // margin + const QwtAbstractScaleDraw *sd = scaleDraw(); + if (sd) + { + int scaleDist = qwtCeil(sd->extent(font())); + scaleDist++; // margin - rect.adjust( scaleDist, scaleDist, -scaleDist, -scaleDist ); - } + rect.adjust(scaleDist, scaleDist, -scaleDist, -scaleDist); + } - return rect; + return rect; } /*! @@ -275,15 +271,15 @@ QRect QwtDial::scaleInnerRect() const \sa mode(), setValue(), setOrigin() */ -void QwtDial::setMode( Mode mode ) +void QwtDial::setMode(Mode mode) { - if ( mode != m_data->mode ) - { - invalidateCache(); + if (mode != m_data->mode) + { + invalidateCache(); - m_data->mode = mode; - sliderChange(); - } + m_data->mode = mode; + sliderChange(); + } } /*! @@ -292,7 +288,7 @@ void QwtDial::setMode( Mode mode ) */ QwtDial::Mode QwtDial::mode() const { - return m_data->mode; + return m_data->mode; } /*! @@ -300,68 +296,68 @@ QwtDial::Mode QwtDial::mode() const */ void QwtDial::invalidateCache() { - m_data->pixmapCache = QPixmap(); + m_data->pixmapCache = QPixmap(); } /*! Paint the dial \param event Paint event */ -void QwtDial::paintEvent( QPaintEvent* event ) +void QwtDial::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - if ( m_data->mode == QwtDial::RotateScale ) - { - painter.save(); - painter.setRenderHint( QPainter::Antialiasing, true ); + if (m_data->mode == QwtDial::RotateScale) + { + painter.save(); + painter.setRenderHint(QPainter::Antialiasing, true); - drawContents( &painter ); + drawContents(&painter); - painter.restore(); - } + painter.restore(); + } - const QRect r = contentsRect(); - if ( r.size() != m_data->pixmapCache.size() ) - { - m_data->pixmapCache = QwtPainter::backingStore( this, r.size() ); - m_data->pixmapCache.fill( Qt::transparent ); + const QRect r = contentsRect(); + if (r.size() != m_data->pixmapCache.size()) + { + m_data->pixmapCache = QwtPainter::backingStore(this, r.size()); + m_data->pixmapCache.fill(Qt::transparent); - QPainter p( &m_data->pixmapCache ); - p.setRenderHint( QPainter::Antialiasing, true ); - p.translate( -r.topLeft() ); + QPainter p(&m_data->pixmapCache); + p.setRenderHint(QPainter::Antialiasing, true); + p.translate(-r.topLeft()); - if ( m_data->mode != QwtDial::RotateScale ) - drawContents( &p ); + if (m_data->mode != QwtDial::RotateScale) + drawContents(&p); - if ( lineWidth() > 0 ) - drawFrame( &p ); + if (lineWidth() > 0) + drawFrame(&p); - if ( m_data->mode != QwtDial::RotateNeedle ) - drawNeedle( &p ); - } + if (m_data->mode != QwtDial::RotateNeedle) + drawNeedle(&p); + } - painter.drawPixmap( r.topLeft(), m_data->pixmapCache ); + painter.drawPixmap(r.topLeft(), m_data->pixmapCache); - if ( m_data->mode == QwtDial::RotateNeedle ) - drawNeedle( &painter ); + if (m_data->mode == QwtDial::RotateNeedle) + drawNeedle(&painter); - if ( hasFocus() ) - drawFocusIndicator( &painter ); + if (hasFocus()) + drawFocusIndicator(&painter); } /*! Draw the focus indicator \param painter Painter */ -void QwtDial::drawFocusIndicator( QPainter* painter ) const +void QwtDial::drawFocusIndicator(QPainter *painter) const { - QwtPainter::drawFocusRect( painter, this, boundingRect() ); + QwtPainter::drawFocusRect(painter, this, boundingRect()); } /*! @@ -370,10 +366,10 @@ void QwtDial::drawFocusIndicator( QPainter* painter ) const \param painter Painter \sa lineWidth(), frameShadow() */ -void QwtDial::drawFrame( QPainter* painter ) +void QwtDial::drawFrame(QPainter *painter) { - QwtPainter::drawRoundFrame( painter, boundingRect(), - palette(), lineWidth(), m_data->frameShadow ); + QwtPainter::drawRoundFrame(painter, boundingRect(), palette(), lineWidth(), + m_data->frameShadow); } /*! @@ -388,42 +384,40 @@ void QwtDial::drawFrame( QPainter* painter ) \sa boundingRect(), innerRect(), scaleInnerRect(), QWidget::setPalette() */ -void QwtDial::drawContents( QPainter* painter ) const +void QwtDial::drawContents(QPainter *painter) const { - if ( testAttribute( Qt::WA_NoSystemBackground ) || - palette().brush( QPalette::Base ) != - palette().brush( QPalette::Window ) ) - { - const QRectF br = boundingRect(); - - painter->save(); - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().brush( QPalette::Base ) ); - painter->drawEllipse( br ); - painter->restore(); - } - - const QRectF insideScaleRect = scaleInnerRect(); - if ( palette().brush( QPalette::WindowText ) != - palette().brush( QPalette::Base ) ) - { - painter->save(); - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().brush( QPalette::WindowText ) ); - painter->drawEllipse( insideScaleRect ); - painter->restore(); - } - - const QPointF center = insideScaleRect.center(); - const double radius = 0.5 * insideScaleRect.width(); + if (testAttribute(Qt::WA_NoSystemBackground) + || palette().brush(QPalette::Base) != palette().brush(QPalette::Window)) + { + const QRectF br = boundingRect(); painter->save(); - drawScale( painter, center, radius ); + painter->setPen(Qt::NoPen); + painter->setBrush(palette().brush(QPalette::Base)); + painter->drawEllipse(br); painter->restore(); + } + const QRectF insideScaleRect = scaleInnerRect(); + if (palette().brush(QPalette::WindowText) != palette().brush(QPalette::Base)) + { painter->save(); - drawScaleContents( painter, center, radius ); + painter->setPen(Qt::NoPen); + painter->setBrush(palette().brush(QPalette::WindowText)); + painter->drawEllipse(insideScaleRect); painter->restore(); + } + + const QPointF center = insideScaleRect.center(); + const double radius = 0.5 * insideScaleRect.width(); + + painter->save(); + drawScale(painter, center, radius); + painter->restore(); + + painter->save(); + drawScaleContents(painter, center, radius); + painter->restore(); } /*! @@ -435,34 +429,35 @@ void QwtDial::drawContents( QPainter* painter ) const \param direction Direction of the needle in degrees, counter clockwise \param colorGroup ColorGroup */ -void QwtDial::drawNeedle( QPainter* painter, const QPointF& center, - double radius, double direction, QPalette::ColorGroup colorGroup ) const +void QwtDial::drawNeedle(QPainter *painter, const QPointF ¢er, + double radius, double direction, + QPalette::ColorGroup colorGroup) const { - if ( m_data->needle ) - { - direction = 360.0 - direction; // counter clockwise - m_data->needle->draw( painter, center, radius, direction, colorGroup ); - } + if (m_data->needle) + { + direction = 360.0 - direction; // counter clockwise + m_data->needle->draw(painter, center, radius, direction, colorGroup); + } } -void QwtDial::drawNeedle( QPainter* painter ) const +void QwtDial::drawNeedle(QPainter *painter) const { - if ( !isValid() ) - return; + if (!isValid()) + return; - QPalette::ColorGroup colorGroup; - if ( isEnabled() ) - colorGroup = hasFocus() ? QPalette::Active : QPalette::Inactive; - else - colorGroup = QPalette::Disabled; + QPalette::ColorGroup colorGroup; + if (isEnabled()) + colorGroup = hasFocus() ? QPalette::Active : QPalette::Inactive; + else + colorGroup = QPalette::Disabled; - const QRectF sr = scaleInnerRect(); + const QRectF sr = scaleInnerRect(); - painter->save(); - painter->setRenderHint( QPainter::Antialiasing, true ); - drawNeedle( painter, sr.center(), 0.5 * sr.width(), - scaleMap().transform( value() ) + 270.0, colorGroup ); - painter->restore(); + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, true); + drawNeedle(painter, sr.center(), 0.5 * sr.width(), + scaleMap().transform(value()) + 270.0, colorGroup); + painter->restore(); } /*! @@ -472,26 +467,26 @@ void QwtDial::drawNeedle( QPainter* painter ) const \param center Center of the dial \param radius Radius of the scale */ -void QwtDial::drawScale( QPainter* painter, - const QPointF& center, double radius ) const +void QwtDial::drawScale(QPainter *painter, const QPointF ¢er, + double radius) const { - QwtRoundScaleDraw* sd = const_cast< QwtRoundScaleDraw* >( scaleDraw() ); - if ( sd == NULL ) - return; + QwtRoundScaleDraw *sd = const_cast(scaleDraw()); + if (sd == NULL) + return; - sd->setRadius( radius ); - sd->moveCenter( center ); + sd->setRadius(radius); + sd->moveCenter(center); - QPalette pal = palette(); + QPalette pal = palette(); - const QColor textColor = pal.color( QPalette::Text ); - pal.setColor( QPalette::WindowText, textColor ); // ticks, backbone + const QColor textColor = pal.color(QPalette::Text); + pal.setColor(QPalette::WindowText, textColor); // ticks, backbone - painter->setFont( font() ); - painter->setPen( QPen( textColor, sd->penWidthF() ) ); + painter->setFont(font()); + painter->setPen(QPen(textColor, sd->penWidthF())); - painter->setBrush( Qt::red ); - sd->draw( painter, pal ); + painter->setBrush(Qt::red); + sd->draw(painter, pal); } /*! @@ -503,12 +498,12 @@ void QwtDial::drawScale( QPainter* painter, \param center Center of the contents circle \param radius Radius of the contents circle */ -void QwtDial::drawScaleContents( QPainter* painter, - const QPointF& center, double radius ) const +void QwtDial::drawScaleContents(QPainter *painter, const QPointF ¢er, + double radius) const { - Q_UNUSED(painter); - Q_UNUSED(center); - Q_UNUSED(radius); + Q_UNUSED(painter); + Q_UNUSED(center); + Q_UNUSED(radius); } /*! @@ -519,46 +514,46 @@ void QwtDial::drawScaleContents( QPainter* painter, \warning The needle will be deleted, when a different needle is set or in ~QwtDial() */ -void QwtDial::setNeedle( QwtDialNeedle* needle ) +void QwtDial::setNeedle(QwtDialNeedle *needle) { - if ( needle != m_data->needle ) - { - if ( m_data->needle ) - delete m_data->needle; + if (needle != m_data->needle) + { + if (m_data->needle) + delete m_data->needle; - m_data->needle = needle; - update(); - } + m_data->needle = needle; + update(); + } } /*! \return needle \sa setNeedle() */ -const QwtDialNeedle* QwtDial::needle() const +const QwtDialNeedle *QwtDial::needle() const { - return m_data->needle; + return m_data->needle; } /*! \return needle \sa setNeedle() */ -QwtDialNeedle* QwtDial::needle() +QwtDialNeedle *QwtDial::needle() { - return m_data->needle; + return m_data->needle; } //! \return the scale draw -QwtRoundScaleDraw* QwtDial::scaleDraw() +QwtRoundScaleDraw *QwtDial::scaleDraw() { - return static_cast< QwtRoundScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } //! \return the scale draw -const QwtRoundScaleDraw* QwtDial::scaleDraw() const +const QwtRoundScaleDraw *QwtDial::scaleDraw() const { - return static_cast< const QwtRoundScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } /*! @@ -571,10 +566,10 @@ const QwtRoundScaleDraw* QwtDial::scaleDraw() const \param scaleDraw Scale draw \warning The previous scale draw is deleted */ -void QwtDial::setScaleDraw( QwtRoundScaleDraw* scaleDraw ) +void QwtDial::setScaleDraw(QwtRoundScaleDraw *scaleDraw) { - setAbstractScaleDraw( scaleDraw ); - sliderChange(); + setAbstractScaleDraw(scaleDraw); + sliderChange(); } /*! @@ -585,28 +580,28 @@ void QwtDial::setScaleDraw( QwtRoundScaleDraw* scaleDraw ) \sa minScaleArc(), maxScaleArc() */ -void QwtDial::setScaleArc( double minArc, double maxArc ) +void QwtDial::setScaleArc(double minArc, double maxArc) { - if ( minArc != 360.0 && minArc != -360.0 ) - minArc = std::fmod( minArc, 360.0 ); - if ( maxArc != 360.0 && maxArc != -360.0 ) - maxArc = std::fmod( maxArc, 360.0 ); + if (minArc != 360.0 && minArc != -360.0) + minArc = std::fmod(minArc, 360.0); + if (maxArc != 360.0 && maxArc != -360.0) + maxArc = std::fmod(maxArc, 360.0); - double minScaleArc = qwtMinF( minArc, maxArc ); - double maxScaleArc = qwtMaxF( minArc, maxArc ); + double minScaleArc = qwtMinF(minArc, maxArc); + double maxScaleArc = qwtMaxF(minArc, maxArc); - if ( maxScaleArc - minScaleArc > 360.0 ) - maxScaleArc = minScaleArc + 360.0; + if (maxScaleArc - minScaleArc > 360.0) + maxScaleArc = minScaleArc + 360.0; - if ( ( minScaleArc != m_data->minScaleArc ) || - ( maxScaleArc != m_data->maxScaleArc ) ) - { - m_data->minScaleArc = minScaleArc; - m_data->maxScaleArc = maxScaleArc; + if ((minScaleArc != m_data->minScaleArc) + || (maxScaleArc != m_data->maxScaleArc)) + { + m_data->minScaleArc = minScaleArc; + m_data->maxScaleArc = maxScaleArc; - invalidateCache(); - sliderChange(); - } + invalidateCache(); + sliderChange(); + } } /*! @@ -615,9 +610,9 @@ void QwtDial::setScaleArc( double minArc, double maxArc ) \param min Lower limit of the scale arc \sa setScaleArc(), setMaxScaleArc() */ -void QwtDial::setMinScaleArc( double min ) +void QwtDial::setMinScaleArc(double min) { - setScaleArc( min, m_data->maxScaleArc ); + setScaleArc(min, m_data->maxScaleArc); } /*! @@ -626,7 +621,7 @@ void QwtDial::setMinScaleArc( double min ) */ double QwtDial::minScaleArc() const { - return m_data->minScaleArc; + return m_data->minScaleArc; } /*! @@ -635,9 +630,9 @@ double QwtDial::minScaleArc() const \param max Upper limit of the scale arc \sa setScaleArc(), setMinScaleArc() */ -void QwtDial::setMaxScaleArc( double max ) +void QwtDial::setMaxScaleArc(double max) { - setScaleArc( m_data->minScaleArc, max ); + setScaleArc(m_data->minScaleArc, max); } /*! @@ -646,7 +641,7 @@ void QwtDial::setMaxScaleArc( double max ) */ double QwtDial::maxScaleArc() const { - return m_data->maxScaleArc; + return m_data->maxScaleArc; } /*! @@ -657,12 +652,12 @@ double QwtDial::maxScaleArc() const \param origin New origin \sa origin() */ -void QwtDial::setOrigin( double origin ) +void QwtDial::setOrigin(double origin) { - invalidateCache(); + invalidateCache(); - m_data->origin = origin; - sliderChange(); + m_data->origin = origin; + sliderChange(); } /*! @@ -673,7 +668,7 @@ void QwtDial::setOrigin( double origin ) */ double QwtDial::origin() const { - return m_data->origin; + return m_data->origin; } /*! @@ -682,17 +677,17 @@ double QwtDial::origin() const */ QSize QwtDial::sizeHint() const { - int sh = 0; - if ( scaleDraw() ) - sh = qwtCeil( scaleDraw()->extent( font() ) ); + int sh = 0; + if (scaleDraw()) + sh = qwtCeil(scaleDraw()->extent(font())); - const int d = 6 * sh + 2 * lineWidth(); + const int d = 6 * sh + 2 * lineWidth(); - QSize hint( d, d ); - if ( !isReadOnly() ) - hint = qwtExpandedToGlobalStrut( hint ); + QSize hint(d, d); + if (!isReadOnly()) + hint = qwtExpandedToGlobalStrut(hint); - return hint; + return hint; } /*! @@ -701,13 +696,13 @@ QSize QwtDial::sizeHint() const */ QSize QwtDial::minimumSizeHint() const { - int sh = 0; - if ( scaleDraw() ) - sh = qwtCeil( scaleDraw()->extent( font() ) ); + int sh = 0; + if (scaleDraw()) + sh = qwtCeil(scaleDraw()->extent(font())); - const int d = 3 * sh + 2 * lineWidth(); + const int d = 3 * sh + 2 * lineWidth(); - return QSize( d, d ); + return QSize(d, d); } /*! @@ -718,25 +713,25 @@ QSize QwtDial::minimumSizeHint() const \retval True, when the inner circle contains pos \sa scrolledTo() */ -bool QwtDial::isScrollPosition( const QPoint& pos ) const +bool QwtDial::isScrollPosition(const QPoint &pos) const { - const QRegion region( innerRect(), QRegion::Ellipse ); - if ( region.contains( pos ) && ( pos != innerRect().center() ) ) - { - double angle = QLineF( rect().center(), pos ).angle(); - if ( m_data->mode == QwtDial::RotateScale ) - angle = 360.0 - angle; + const QRegion region(innerRect(), QRegion::Ellipse); + if (region.contains(pos) && (pos != innerRect().center())) + { + double angle = QLineF(rect().center(), pos).angle(); + if (m_data->mode == QwtDial::RotateScale) + angle = 360.0 - angle; - double valueAngle = - qwtNormalizeDegrees( 90.0 - scaleMap().transform( value() ) ); + double valueAngle + = qwtNormalizeDegrees(90.0 - scaleMap().transform(value())); - m_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle ); - m_data->arcOffset = scaleMap().p1(); + m_data->mouseOffset = qwtNormalizeDegrees(angle - valueAngle); + m_data->arcOffset = scaleMap().p1(); - return true; - } + return true; + } - return false; + return false; } /*! @@ -748,51 +743,50 @@ bool QwtDial::isScrollPosition( const QPoint& pos ) const \return Value for the mouse position \sa isScrollPosition() */ -double QwtDial::scrolledTo( const QPoint& pos ) const +double QwtDial::scrolledTo(const QPoint &pos) const { - double angle = QLineF( rect().center(), pos ).angle(); - if ( m_data->mode == QwtDial::RotateScale ) + double angle = QLineF(rect().center(), pos).angle(); + if (m_data->mode == QwtDial::RotateScale) + { + angle += scaleMap().p1() - m_data->arcOffset; + angle = 360.0 - angle; + } + + angle = qwtNormalizeDegrees(angle - m_data->mouseOffset); + angle = qwtNormalizeDegrees(90.0 - angle); + + if (scaleMap().pDist() >= 360.0) + { + if (angle < scaleMap().p1()) + angle += 360.0; + + if (!wrapping()) { - angle += scaleMap().p1() - m_data->arcOffset; - angle = 360.0 - angle; + double boundedAngle = angle; + + const double arc = angle - scaleMap().transform(value()); + if (qAbs(arc) > 180.0) + { + boundedAngle = (arc > 0) ? scaleMap().p1() : scaleMap().p2(); + } + + m_data->mouseOffset += (boundedAngle - angle); + + angle = boundedAngle; } + } + else + { + const double boundedAngle + = qwtBoundedAngle(scaleMap().p1(), angle, scaleMap().p2()); - angle = qwtNormalizeDegrees( angle - m_data->mouseOffset ); - angle = qwtNormalizeDegrees( 90.0 - angle ); + if (!wrapping()) + m_data->mouseOffset += (boundedAngle - angle); - if ( scaleMap().pDist() >= 360.0 ) - { - if ( angle < scaleMap().p1() ) - angle += 360.0; + angle = boundedAngle; + } - if ( !wrapping() ) - { - double boundedAngle = angle; - - const double arc = angle - scaleMap().transform( value() ); - if ( qAbs( arc ) > 180.0 ) - { - boundedAngle = ( arc > 0 ) - ? scaleMap().p1() : scaleMap().p2(); - } - - m_data->mouseOffset += ( boundedAngle - angle ); - - angle = boundedAngle; - } - } - else - { - const double boundedAngle = - qwtBoundedAngle( scaleMap().p1(), angle, scaleMap().p2() ); - - if ( !wrapping() ) - m_data->mouseOffset += ( boundedAngle - angle ); - - angle = boundedAngle; - } - - return scaleMap().invTransform( angle ); + return scaleMap().invTransform(angle); } /*! @@ -801,51 +795,50 @@ double QwtDial::scrolledTo( const QPoint& pos ) const Invalidates internal paint caches if necessary */ -void QwtDial::changeEvent( QEvent* event ) +void QwtDial::changeEvent(QEvent *event) { - switch( event->type() ) - { - case QEvent::EnabledChange: - case QEvent::FontChange: - case QEvent::StyleChange: - case QEvent::PaletteChange: - case QEvent::LanguageChange: - case QEvent::LocaleChange: - { - invalidateCache(); - break; - } - default: - break; + switch (event->type()) + { + case QEvent::EnabledChange: + case QEvent::FontChange: + case QEvent::StyleChange: + case QEvent::PaletteChange: + case QEvent::LanguageChange: + case QEvent::LocaleChange: { + invalidateCache(); + break; } + default: + break; + } - QwtAbstractSlider::changeEvent( event ); + QwtAbstractSlider::changeEvent(event); } /*! Wheel Event handler \param event Wheel event */ -void QwtDial::wheelEvent( QWheelEvent* event ) +void QwtDial::wheelEvent(QWheelEvent *event) { #if QT_VERSION < 0x050e00 - const QPoint wheelPos = event->pos(); + const QPoint wheelPos = event->pos(); #else - const QPoint wheelPos = event->position().toPoint(); + const QPoint wheelPos = event->position().toPoint(); #endif - const QRegion region( innerRect(), QRegion::Ellipse ); - if ( region.contains( wheelPos ) ) - QwtAbstractSlider::wheelEvent( event ); + const QRegion region(innerRect(), QRegion::Ellipse); + if (region.contains(wheelPos)) + QwtAbstractSlider::wheelEvent(event); } -void QwtDial::setAngleRange( double angle, double span ) +void QwtDial::setAngleRange(double angle, double span) { - if ( QwtRoundScaleDraw* sd = scaleDraw() ) - { - angle = qwtNormalizeDegrees( angle - 270.0 ); - sd->setAngleRange( angle, angle + span ); - } + if (QwtRoundScaleDraw *sd = scaleDraw()) + { + angle = qwtNormalizeDegrees(angle - 270.0); + sd->setAngleRange(angle, angle + span); + } } /*! @@ -854,25 +847,25 @@ void QwtDial::setAngleRange( double angle, double span ) */ void QwtDial::scaleChange() { - invalidateCache(); - QwtAbstractSlider::scaleChange(); + invalidateCache(); + QwtAbstractSlider::scaleChange(); } void QwtDial::sliderChange() { - setAngleRange( m_data->origin + m_data->minScaleArc, - m_data->maxScaleArc - m_data->minScaleArc ); + setAngleRange(m_data->origin + m_data->minScaleArc, + m_data->maxScaleArc - m_data->minScaleArc); - if ( mode() == RotateScale ) - { - const double arc = scaleMap().transform( value() ) - scaleMap().p1(); - setAngleRange( m_data->origin - arc, - m_data->maxScaleArc - m_data->minScaleArc ); - } + if (mode() == RotateScale) + { + const double arc = scaleMap().transform(value()) - scaleMap().p1(); + setAngleRange(m_data->origin - arc, + m_data->maxScaleArc - m_data->minScaleArc); + } - QwtAbstractSlider::sliderChange(); + QwtAbstractSlider::sliderChange(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_dial.cpp" +# include "moc_qwt_dial.cpp" #endif diff --git a/libs/qwt/src/qwt_dial.h b/libs/qwt/src/qwt_dial.h index e4aeff6b..ad96bf31 100644 --- a/libs/qwt/src/qwt_dial.h +++ b/libs/qwt/src/qwt_dial.h @@ -32,10 +32,10 @@ class QwtAbstractScaleDraw; of the dial. Depending on Mode one of them is fixed and the other is rotating. If not isReadOnly() the dial can be rotated by dragging the mouse or using keyboard inputs - (see QwtAbstractSlider::keyPressEvent()). A dial might be wrapping, what means - a rotation below/above one limit continues on the other limit (f.e compass). - The scale might cover any arc of the dial, its values are related to - the origin() of the dial. + (see QwtAbstractSlider::keyPressEvent()). A dial might be wrapping, what + means a rotation below/above one limit continues on the other limit (f.e + compass). The scale might cover any arc of the dial, its values are related + to the origin() of the dial. Often dials have to be updated very often according to values from external devices. For these high refresh rates QwtDial caches as much as possible. @@ -49,121 +49,120 @@ class QwtAbstractScaleDraw; class QWT_EXPORT QwtDial : public QwtAbstractSlider { - Q_OBJECT + Q_OBJECT - Q_ENUMS( Shadow Mode Direction ) + Q_ENUMS(Shadow Mode Direction) - Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth ) - Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow ) - Q_PROPERTY( Mode mode READ mode WRITE setMode ) - Q_PROPERTY( double origin READ origin WRITE setOrigin ) - Q_PROPERTY( double minScaleArc READ minScaleArc WRITE setMinScaleArc ) - Q_PROPERTY( double maxScaleArc READ maxScaleArc WRITE setMaxScaleArc ) + Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) + Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow) + Q_PROPERTY(Mode mode READ mode WRITE setMode) + Q_PROPERTY(double origin READ origin WRITE setOrigin) + Q_PROPERTY(double minScaleArc READ minScaleArc WRITE setMinScaleArc) + Q_PROPERTY(double maxScaleArc READ maxScaleArc WRITE setMaxScaleArc) - public: +public: + /*! + \brief Frame shadow - /*! - \brief Frame shadow + Unfortunately it is not possible to use QFrame::Shadow + as a property of a widget that is not derived from QFrame. + The following enum is made for the designer only. It is safe + to use QFrame::Shadow instead. + */ + enum Shadow + { + //! QFrame::Plain + Plain = QFrame::Plain, - Unfortunately it is not possible to use QFrame::Shadow - as a property of a widget that is not derived from QFrame. - The following enum is made for the designer only. It is safe - to use QFrame::Shadow instead. - */ - enum Shadow - { - //! QFrame::Plain - Plain = QFrame::Plain, + //! QFrame::Raised + Raised = QFrame::Raised, - //! QFrame::Raised - Raised = QFrame::Raised, + //! QFrame::Sunken + Sunken = QFrame::Sunken + }; - //! QFrame::Sunken - Sunken = QFrame::Sunken - }; + //! Mode controlling whether the needle or the scale is rotating + enum Mode + { + //! The needle is rotating + RotateNeedle, - //! Mode controlling whether the needle or the scale is rotating - enum Mode - { - //! The needle is rotating - RotateNeedle, + //! The needle is fixed, the scales are rotating + RotateScale + }; - //! The needle is fixed, the scales are rotating - RotateScale - }; + explicit QwtDial(QWidget *parent = NULL); + virtual ~QwtDial(); - explicit QwtDial( QWidget* parent = NULL ); - virtual ~QwtDial(); + void setFrameShadow(Shadow); + Shadow frameShadow() const; - void setFrameShadow( Shadow ); - Shadow frameShadow() const; + void setLineWidth(int); + int lineWidth() const; - void setLineWidth( int ); - int lineWidth() const; + void setMode(Mode); + Mode mode() const; - void setMode( Mode ); - Mode mode() const; + void setScaleArc(double minArc, double maxArc); - void setScaleArc( double minArc, double maxArc ); + void setMinScaleArc(double); + double minScaleArc() const; - void setMinScaleArc( double ); - double minScaleArc() const; + void setMaxScaleArc(double); + double maxScaleArc() const; - void setMaxScaleArc( double ); - double maxScaleArc() const; + virtual void setOrigin(double); + double origin() const; - virtual void setOrigin( double ); - double origin() const; + void setNeedle(QwtDialNeedle *); + const QwtDialNeedle *needle() const; + QwtDialNeedle *needle(); - void setNeedle( QwtDialNeedle* ); - const QwtDialNeedle* needle() const; - QwtDialNeedle* needle(); + QRect boundingRect() const; + QRect innerRect() const; - QRect boundingRect() const; - QRect innerRect() const; + virtual QRect scaleInnerRect() const; - virtual QRect scaleInnerRect() const; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + void setScaleDraw(QwtRoundScaleDraw *); - void setScaleDraw( QwtRoundScaleDraw* ); + QwtRoundScaleDraw *scaleDraw(); + const QwtRoundScaleDraw *scaleDraw() const; - QwtRoundScaleDraw* scaleDraw(); - const QwtRoundScaleDraw* scaleDraw() const; +protected: + virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE; + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void changeEvent(QEvent *) QWT_OVERRIDE; - protected: - virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE; - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void changeEvent( QEvent* ) QWT_OVERRIDE; + virtual void drawFrame(QPainter *); + virtual void drawContents(QPainter *) const; + virtual void drawFocusIndicator(QPainter *) const; - virtual void drawFrame( QPainter* ); - virtual void drawContents( QPainter* ) const; - virtual void drawFocusIndicator( QPainter* ) const; + void invalidateCache(); - void invalidateCache(); + virtual void drawScale(QPainter *, const QPointF ¢er, + double radius) const; - virtual void drawScale( QPainter*, - const QPointF& center, double radius ) const; + virtual void drawScaleContents(QPainter *painter, const QPointF ¢er, + double radius) const; - virtual void drawScaleContents( QPainter* painter, - const QPointF& center, double radius ) const; + virtual void drawNeedle(QPainter *, const QPointF &, double radius, + double direction, QPalette::ColorGroup) const; - virtual void drawNeedle( QPainter*, const QPointF&, - double radius, double direction, QPalette::ColorGroup ) const; + virtual double scrolledTo(const QPoint &) const QWT_OVERRIDE; + virtual bool isScrollPosition(const QPoint &) const QWT_OVERRIDE; - virtual double scrolledTo( const QPoint& ) const QWT_OVERRIDE; - virtual bool isScrollPosition( const QPoint& ) const QWT_OVERRIDE; + virtual void sliderChange() QWT_OVERRIDE; + virtual void scaleChange() QWT_OVERRIDE; - virtual void sliderChange() QWT_OVERRIDE; - virtual void scaleChange() QWT_OVERRIDE; +private: + void setAngleRange(double angle, double span); + void drawNeedle(QPainter *) const; - private: - void setAngleRange( double angle, double span ); - void drawNeedle( QPainter* ) const; - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_dial_needle.cpp b/libs/qwt/src/qwt_dial_needle.cpp index bf71850a..08149926 100644 --- a/libs/qwt/src/qwt_dial_needle.cpp +++ b/libs/qwt/src/qwt_dial_needle.cpp @@ -15,196 +15,193 @@ #include #include -static void qwtDrawStyle1Needle( QPainter* painter, - const QPalette& palette, QPalette::ColorGroup colorGroup, qreal length ) +static void qwtDrawStyle1Needle(QPainter *painter, const QPalette &palette, + QPalette::ColorGroup colorGroup, qreal length) { - const qreal r[] = { 0.4, 0.3, 1, 0.8, 1, 0.3, 0.4 }; - const qreal a[] = { -45, -20, -15, 0, 15, 20, 45 }; + const qreal r[] = {0.4, 0.3, 1, 0.8, 1, 0.3, 0.4}; + const qreal a[] = {-45, -20, -15, 0, 15, 20, 45}; - QPainterPath path; - for ( int i = 0; i < 7; i++ ) - { - const qreal angle = a[i] / 180.0 * M_PI; - const qreal radius = r[i] * length; + QPainterPath path; + for (int i = 0; i < 7; i++) + { + const qreal angle = a[i] / 180.0 * M_PI; + const qreal radius = r[i] * length; - const qreal x = radius * qFastCos( angle ); - const qreal y = radius * qFastSin( angle ); + const qreal x = radius * qFastCos(angle); + const qreal y = radius * qFastSin(angle); - path.lineTo( x, -y ); - } + path.lineTo(x, -y); + } - painter->setPen( Qt::NoPen ); - painter->setBrush( palette.brush( colorGroup, QPalette::Light ) ); - painter->drawPath( path ); + painter->setPen(Qt::NoPen); + painter->setBrush(palette.brush(colorGroup, QPalette::Light)); + painter->drawPath(path); } -static void qwtDrawStyle2Needle( QPainter* painter, - const QPalette& palette, QPalette::ColorGroup colorGroup, qreal length ) +static void qwtDrawStyle2Needle(QPainter *painter, const QPalette &palette, + QPalette::ColorGroup colorGroup, qreal length) { - const qreal ratioX = 0.7; - const qreal ratioY = 0.3; + const qreal ratioX = 0.7; + const qreal ratioY = 0.3; - QPainterPath path1; - path1.lineTo( ratioX * length, 0.0 ); - path1.lineTo( length, ratioY * length ); + QPainterPath path1; + path1.lineTo(ratioX * length, 0.0); + path1.lineTo(length, ratioY * length); - QPainterPath path2; - path2.lineTo( ratioX * length, 0.0 ); - path2.lineTo( length, -ratioY * length ); + QPainterPath path2; + path2.lineTo(ratioX * length, 0.0); + path2.lineTo(length, -ratioY * length); - painter->setPen( Qt::NoPen ); + painter->setPen(Qt::NoPen); - painter->setBrush( palette.brush( colorGroup, QPalette::Light ) ); - painter->drawPath( path1 ); + painter->setBrush(palette.brush(colorGroup, QPalette::Light)); + painter->drawPath(path1); - painter->setBrush( palette.brush( colorGroup, QPalette::Dark ) ); - painter->drawPath( path2 ); + painter->setBrush(palette.brush(colorGroup, QPalette::Dark)); + painter->drawPath(path2); } -static void qwtDrawShadedPointer( QPainter* painter, - const QColor& lightColor, const QColor& darkColor, - qreal length, qreal width ) +static void qwtDrawShadedPointer(QPainter *painter, const QColor &lightColor, + const QColor &darkColor, qreal length, + qreal width) { - const qreal peak = qwtMaxF( length / 10.0, 5.0 ); + const qreal peak = qwtMaxF(length / 10.0, 5.0); - const qreal knobWidth = width + 8; - QRectF knobRect( 0, 0, knobWidth, knobWidth ); - knobRect.moveCenter( QPointF(0, 0) ); + const qreal knobWidth = width + 8; + QRectF knobRect(0, 0, knobWidth, knobWidth); + knobRect.moveCenter(QPointF(0, 0)); - QPainterPath path1; - path1.lineTo( 0.0, 0.5 * width ); - path1.lineTo( length - peak, 0.5 * width ); - path1.lineTo( length, 0.0 ); - path1.lineTo( 0.0, 0.0 ); + QPainterPath path1; + path1.lineTo(0.0, 0.5 * width); + path1.lineTo(length - peak, 0.5 * width); + path1.lineTo(length, 0.0); + path1.lineTo(0.0, 0.0); - QPainterPath arcPath1; - arcPath1.arcTo( knobRect, 0.0, -90.0 ); + QPainterPath arcPath1; + arcPath1.arcTo(knobRect, 0.0, -90.0); - path1 = path1.united( arcPath1 ); + path1 = path1.united(arcPath1); - QPainterPath path2; - path2.lineTo( 0.0, -0.5 * width ); - path2.lineTo( length - peak, -0.5 * width ); - path2.lineTo( length, 0.0 ); - path2.lineTo( 0.0, 0.0 ); + QPainterPath path2; + path2.lineTo(0.0, -0.5 * width); + path2.lineTo(length - peak, -0.5 * width); + path2.lineTo(length, 0.0); + path2.lineTo(0.0, 0.0); - QPainterPath arcPath2; - arcPath2.arcTo( knobRect, 0.0, 90.0 ); + QPainterPath arcPath2; + arcPath2.arcTo(knobRect, 0.0, 90.0); - path2 = path2.united( arcPath2 ); + path2 = path2.united(arcPath2); - painter->setPen( Qt::NoPen ); + painter->setPen(Qt::NoPen); - painter->setBrush( lightColor ); - painter->drawPath( path1 ); + painter->setBrush(lightColor); + painter->drawPath(path1); - painter->setBrush( darkColor ); - painter->drawPath( path2 ); + painter->setBrush(darkColor); + painter->drawPath(path2); } -static void qwtDrawArrowNeedle( QPainter* painter, - const QPalette& palette, QPalette::ColorGroup colorGroup, - qreal length, qreal width ) +static void qwtDrawArrowNeedle(QPainter *painter, const QPalette &palette, + QPalette::ColorGroup colorGroup, qreal length, + qreal width) { - if ( width <= 0 ) - width = qwtMaxF( length * 0.06, 9.0 ); + if (width <= 0) + width = qwtMaxF(length * 0.06, 9.0); - const qreal peak = qwtMaxF( 2.0, 0.4 * width ); + const qreal peak = qwtMaxF(2.0, 0.4 * width); - QPainterPath path; - path.moveTo( 0.0, 0.5 * width ); - path.lineTo( length - peak, 0.3 * width ); - path.lineTo( length, 0.0 ); - path.lineTo( length - peak, -0.3 * width ); - path.lineTo( 0.0, -0.5 * width ); + QPainterPath path; + path.moveTo(0.0, 0.5 * width); + path.lineTo(length - peak, 0.3 * width); + path.lineTo(length, 0.0); + path.lineTo(length - peak, -0.3 * width); + path.lineTo(0.0, -0.5 * width); - QRectF br = path.boundingRect(); + QRectF br = path.boundingRect(); - QPalette pal( palette.color( QPalette::Mid ) ); - QColor c1 = pal.color( QPalette::Light ); - QColor c2 = pal.color( QPalette::Dark ); + QPalette pal(palette.color(QPalette::Mid)); + QColor c1 = pal.color(QPalette::Light); + QColor c2 = pal.color(QPalette::Dark); - QLinearGradient gradient( br.topLeft(), br.bottomLeft() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 0.5, c1 ); - gradient.setColorAt( 0.5001, c2 ); - gradient.setColorAt( 1.0, c2 ); + QLinearGradient gradient(br.topLeft(), br.bottomLeft()); + gradient.setColorAt(0.0, c1); + gradient.setColorAt(0.5, c1); + gradient.setColorAt(0.5001, c2); + gradient.setColorAt(1.0, c2); - QPen pen( gradient, 1 ); - pen.setJoinStyle( Qt::MiterJoin ); + QPen pen(gradient, 1); + pen.setJoinStyle(Qt::MiterJoin); - painter->setPen( pen ); - painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) ); + painter->setPen(pen); + painter->setBrush(palette.brush(colorGroup, QPalette::Mid)); - painter->drawPath( path ); + painter->drawPath(path); } -static void qwtDrawTriangleNeedle( QPainter* painter, - const QPalette& palette, QPalette::ColorGroup colorGroup, qreal length ) +static void qwtDrawTriangleNeedle(QPainter *painter, const QPalette &palette, + QPalette::ColorGroup colorGroup, qreal length) { - const qreal width = qRound( length / 3.0 ); + const qreal width = qRound(length / 3.0); - QPainterPath path[4]; + QPainterPath path[4]; - path[0].lineTo( length, 0.0 ); - path[0].lineTo( 0.0, width / 2 ); + path[0].lineTo(length, 0.0); + path[0].lineTo(0.0, width / 2); - path[1].lineTo( length, 0.0 ); - path[1].lineTo( 0.0, -width / 2 ); + path[1].lineTo(length, 0.0); + path[1].lineTo(0.0, -width / 2); - path[2].lineTo( -length, 0.0 ); - path[2].lineTo( 0.0, width / 2 ); + path[2].lineTo(-length, 0.0); + path[2].lineTo(0.0, width / 2); - path[3].lineTo( -length, 0.0 ); - path[3].lineTo( 0.0, -width / 2 ); + path[3].lineTo(-length, 0.0); + path[3].lineTo(0.0, -width / 2); + const int colorOffset = 10; + const QColor darkColor = palette.color(colorGroup, QPalette::Dark); + const QColor lightColor = palette.color(colorGroup, QPalette::Light); - const int colorOffset = 10; - const QColor darkColor = palette.color( colorGroup, QPalette::Dark ); - const QColor lightColor = palette.color( colorGroup, QPalette::Light ); + QColor color[4]; + color[0] = darkColor.lighter(100 + colorOffset); + color[1] = darkColor.darker(100 + colorOffset); + color[2] = lightColor.lighter(100 + colorOffset); + color[3] = lightColor.darker(100 + colorOffset); - QColor color[4]; - color[0] = darkColor.lighter( 100 + colorOffset ); - color[1] = darkColor.darker( 100 + colorOffset ); - color[2] = lightColor.lighter( 100 + colorOffset ); - color[3] = lightColor.darker( 100 + colorOffset ); + painter->setPen(Qt::NoPen); - painter->setPen( Qt::NoPen ); - - for ( int i = 0; i < 4; i++ ) - { - painter->setBrush( color[i] ); - painter->drawPath( path[i] ); - } + for (int i = 0; i < 4; i++) + { + painter->setBrush(color[i]); + painter->drawPath(path[i]); + } } //! Constructor QwtDialNeedle::QwtDialNeedle() - : m_palette( QApplication::palette() ) + : m_palette(QApplication::palette()) { } //! Destructor -QwtDialNeedle::~QwtDialNeedle() -{ -} +QwtDialNeedle::~QwtDialNeedle() {} /*! Sets the palette for the needle. \param palette New Palette */ -void QwtDialNeedle::setPalette( const QPalette& palette ) +void QwtDialNeedle::setPalette(const QPalette &palette) { - m_palette = palette; + m_palette = palette; } /*! \return the palette of the needle. */ -const QPalette& QwtDialNeedle::palette() const +const QPalette &QwtDialNeedle::palette() const { - return m_palette; + return m_palette; } /*! @@ -216,53 +213,53 @@ const QPalette& QwtDialNeedle::palette() const \param direction Direction of the needle, in degrees counter clockwise \param colorGroup Color group, used for painting */ -void QwtDialNeedle::draw( QPainter* painter, - const QPointF& center, double length, double direction, - QPalette::ColorGroup colorGroup ) const +void QwtDialNeedle::draw(QPainter *painter, const QPointF ¢er, + double length, double direction, + QPalette::ColorGroup colorGroup) const { - painter->save(); + painter->save(); - painter->translate( center ); - painter->rotate( -direction ); + painter->translate(center); + painter->rotate(-direction); - drawNeedle( painter, length, colorGroup ); + drawNeedle(painter, length, colorGroup); - painter->restore(); + painter->restore(); } //! Draw the knob //! -void QwtDialNeedle::drawKnob( QPainter* painter, - double width, const QBrush& brush, bool sunken ) const +void QwtDialNeedle::drawKnob(QPainter *painter, double width, + const QBrush &brush, bool sunken) const { - QPalette palette( brush.color() ); + QPalette palette(brush.color()); - QColor c1 = palette.color( QPalette::Light ); - QColor c2 = palette.color( QPalette::Dark ); + QColor c1 = palette.color(QPalette::Light); + QColor c2 = palette.color(QPalette::Dark); - if ( sunken ) - qSwap( c1, c2 ); + if (sunken) + qSwap(c1, c2); - QRectF rect( 0.0, 0.0, width, width ); - qreal hc = painter->window().width() / 2.0; - qreal vc = painter->window().height() / 2.0; - rect.moveCenter( QPointF( hc, vc) ); + QRectF rect(0.0, 0.0, width, width); + qreal hc = painter->window().width() / 2.0; + qreal vc = painter->window().height() / 2.0; + rect.moveCenter(QPointF(hc, vc)); - QLinearGradient gradient( rect.topLeft(), rect.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 0.3, c1 ); - gradient.setColorAt( 0.7, c2 ); - gradient.setColorAt( 1.0, c2 ); + QLinearGradient gradient(rect.topLeft(), rect.bottomRight()); + gradient.setColorAt(0.0, c1); + gradient.setColorAt(0.3, c1); + gradient.setColorAt(0.7, c2); + gradient.setColorAt(1.0, c2); - painter->save(); + painter->save(); - painter->resetTransform(); + painter->resetTransform(); - painter->setPen( QPen( gradient, 1 ) ); - painter->setBrush( brush ); - painter->drawEllipse( rect ); + painter->setPen(QPen(gradient, 1)); + painter->setBrush(brush); + painter->drawEllipse(rect); - painter->restore(); + painter->restore(); } /*! @@ -273,17 +270,17 @@ void QwtDialNeedle::drawKnob( QPainter* painter, \param mid Middle color \param base Base color */ -QwtDialSimpleNeedle::QwtDialSimpleNeedle( Style style, bool hasKnob, - const QColor& mid, const QColor& base ): - m_style( style ), - m_hasKnob( hasKnob ), - m_width( -1 ) +QwtDialSimpleNeedle::QwtDialSimpleNeedle(Style style, bool hasKnob, + const QColor &mid, const QColor &base) + : m_style(style) + , m_hasKnob(hasKnob) + , m_width(-1) { - QPalette palette; - palette.setColor( QPalette::Mid, mid ); - palette.setColor( QPalette::Base, base ); + QPalette palette; + palette.setColor(QPalette::Mid, mid); + palette.setColor(QPalette::Base, base); - setPalette( palette ); + setPalette(palette); } /*! @@ -291,9 +288,9 @@ QwtDialSimpleNeedle::QwtDialSimpleNeedle( Style style, bool hasKnob, \param width Width \sa width() */ -void QwtDialSimpleNeedle::setWidth( double width ) +void QwtDialSimpleNeedle::setWidth(double width) { - m_width = width; + m_width = width; } /*! @@ -302,7 +299,7 @@ void QwtDialSimpleNeedle::setWidth( double width ) */ double QwtDialSimpleNeedle::width() const { - return m_width; + return m_width; } /*! @@ -312,54 +309,53 @@ double QwtDialSimpleNeedle::width() const \param length Length of the needle \param colorGroup Color group, used for painting */ -void QwtDialSimpleNeedle::drawNeedle( QPainter* painter, - double length, QPalette::ColorGroup colorGroup ) const +void QwtDialSimpleNeedle::drawNeedle(QPainter *painter, double length, + QPalette::ColorGroup colorGroup) const { - qreal knobWidth = 0.0; - qreal width = m_width; + qreal knobWidth = 0.0; + qreal width = m_width; - if ( m_style == Arrow ) - { - if ( width <= 0.0 ) - width = qwtMaxF( length * 0.06, 6.0 ); + if (m_style == Arrow) + { + if (width <= 0.0) + width = qwtMaxF(length * 0.06, 6.0); - qwtDrawArrowNeedle( painter, - palette(), colorGroup, length, width ); + qwtDrawArrowNeedle(painter, palette(), colorGroup, length, width); - knobWidth = qwtMinF( width * 2.0, 0.2 * length ); - } - else - { - if ( width <= 0.0 ) - width = 5.0; + knobWidth = qwtMinF(width * 2.0, 0.2 * length); + } + else + { + if (width <= 0.0) + width = 5.0; - QPen pen ( palette().brush( colorGroup, QPalette::Mid ), width ); - pen.setCapStyle( Qt::FlatCap ); + QPen pen(palette().brush(colorGroup, QPalette::Mid), width); + pen.setCapStyle(Qt::FlatCap); - painter->setPen( pen ); - painter->drawLine( QPointF( 0.0, 0.0 ), QPointF( length, 0.0 ) ); + painter->setPen(pen); + painter->drawLine(QPointF(0.0, 0.0), QPointF(length, 0.0)); - knobWidth = qwtMaxF( width * 3.0, 5.0 ); - } + knobWidth = qwtMaxF(width * 3.0, 5.0); + } - if ( m_hasKnob && knobWidth > 0.0 ) - { - drawKnob( painter, knobWidth, - palette().brush( colorGroup, QPalette::Base ), false ); - } + if (m_hasKnob && knobWidth > 0.0) + { + drawKnob(painter, knobWidth, palette().brush(colorGroup, QPalette::Base), + false); + } } //! Constructor -QwtCompassMagnetNeedle::QwtCompassMagnetNeedle( Style style, - const QColor& light, const QColor& dark ): - m_style( style ) +QwtCompassMagnetNeedle::QwtCompassMagnetNeedle(Style style, const QColor &light, + const QColor &dark) + : m_style(style) { - QPalette palette; - palette.setColor( QPalette::Light, light ); - palette.setColor( QPalette::Dark, dark ); - palette.setColor( QPalette::Base, Qt::gray ); + QPalette palette; + palette.setColor(QPalette::Light, light); + palette.setColor(QPalette::Dark, dark); + palette.setColor(QPalette::Base, Qt::gray); - setPalette( palette ); + setPalette(palette); } /*! @@ -369,37 +365,33 @@ QwtCompassMagnetNeedle::QwtCompassMagnetNeedle( Style style, \param length Length of the needle \param colorGroup Color group, used for painting */ -void QwtCompassMagnetNeedle::drawNeedle( QPainter* painter, - double length, QPalette::ColorGroup colorGroup ) const +void QwtCompassMagnetNeedle::drawNeedle(QPainter *painter, double length, + QPalette::ColorGroup colorGroup) const { - if ( m_style == ThinStyle ) - { - const qreal width = qwtMaxF( length / 6.0, 3.0 ); + if (m_style == ThinStyle) + { + const qreal width = qwtMaxF(length / 6.0, 3.0); - const int colorOffset = 10; + const int colorOffset = 10; - const QColor light = palette().color( colorGroup, QPalette::Light ); - const QColor dark = palette().color( colorGroup, QPalette::Dark ); + const QColor light = palette().color(colorGroup, QPalette::Light); + const QColor dark = palette().color(colorGroup, QPalette::Dark); - qwtDrawShadedPointer( painter, - dark.lighter( 100 + colorOffset ), - dark.darker( 100 + colorOffset ), - length, width ); + qwtDrawShadedPointer(painter, dark.lighter(100 + colorOffset), + dark.darker(100 + colorOffset), length, width); - painter->rotate( 180.0 ); + painter->rotate(180.0); - qwtDrawShadedPointer( painter, - light.lighter( 100 + colorOffset ), - light.darker( 100 + colorOffset ), - length, width ); + qwtDrawShadedPointer(painter, light.lighter(100 + colorOffset), + light.darker(100 + colorOffset), length, width); - const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base ); - drawKnob( painter, width, baseBrush, true ); - } - else - { - qwtDrawTriangleNeedle( painter, palette(), colorGroup, length ); - } + const QBrush baseBrush = palette().brush(colorGroup, QPalette::Base); + drawKnob(painter, width, baseBrush, true); + } + else + { + qwtDrawTriangleNeedle(painter, palette(), colorGroup, length); + } } /*! @@ -409,15 +401,15 @@ void QwtCompassMagnetNeedle::drawNeedle( QPainter* painter, \param light Light color \param dark Dark color */ -QwtCompassWindArrow::QwtCompassWindArrow( Style style, - const QColor& light, const QColor& dark ): - m_style( style ) +QwtCompassWindArrow::QwtCompassWindArrow(Style style, const QColor &light, + const QColor &dark) + : m_style(style) { - QPalette palette; - palette.setColor( QPalette::Light, light ); - palette.setColor( QPalette::Dark, dark ); + QPalette palette; + palette.setColor(QPalette::Light, light); + palette.setColor(QPalette::Dark, dark); - setPalette( palette ); + setPalette(palette); } /*! @@ -427,11 +419,11 @@ QwtCompassWindArrow::QwtCompassWindArrow( Style style, \param length Length of the needle \param colorGroup Color group, used for painting */ -void QwtCompassWindArrow::drawNeedle( QPainter* painter, - double length, QPalette::ColorGroup colorGroup ) const +void QwtCompassWindArrow::drawNeedle(QPainter *painter, double length, + QPalette::ColorGroup colorGroup) const { - if ( m_style == Style1 ) - qwtDrawStyle1Needle( painter, palette(), colorGroup, length ); - else - qwtDrawStyle2Needle( painter, palette(), colorGroup, length ); + if (m_style == Style1) + qwtDrawStyle1Needle(painter, palette(), colorGroup, length); + else + qwtDrawStyle2Needle(painter, palette(), colorGroup, length); } diff --git a/libs/qwt/src/qwt_dial_needle.h b/libs/qwt/src/qwt_dial_needle.h index 3f2230d0..bdcfe5f3 100644 --- a/libs/qwt/src/qwt_dial_needle.h +++ b/libs/qwt/src/qwt_dial_needle.h @@ -26,43 +26,44 @@ class QPainter; class QWT_EXPORT QwtDialNeedle { - public: - QwtDialNeedle(); - virtual ~QwtDialNeedle(); +public: + QwtDialNeedle(); + virtual ~QwtDialNeedle(); - virtual void setPalette( const QPalette& ); - const QPalette& palette() const; + virtual void setPalette(const QPalette &); + const QPalette &palette() const; - virtual void draw( QPainter*, const QPointF& center, - double length, double direction, - QPalette::ColorGroup = QPalette::Active ) const; + virtual void draw(QPainter *, const QPointF ¢er, double length, + double direction, + QPalette::ColorGroup = QPalette::Active) const; - protected: - /*! - \brief Draw the needle +protected: + /*! + \brief Draw the needle - The origin of the needle is at position (0.0, 0.0 ) - pointing in direction 0.0 ( = east ). + The origin of the needle is at position (0.0, 0.0 ) + pointing in direction 0.0 ( = east ). - The painter is already initialized with translation and - rotation. + The painter is already initialized with translation and + rotation. - \param painter Painter - \param length Length of the needle - \param colorGroup Color group, used for painting + \param painter Painter + \param length Length of the needle + \param colorGroup Color group, used for painting - \sa setPalette(), palette() - */ - virtual void drawNeedle( QPainter* painter, - double length, QPalette::ColorGroup colorGroup ) const = 0; + \sa setPalette(), palette() + */ + virtual void drawNeedle(QPainter *painter, double length, + QPalette::ColorGroup colorGroup) const + = 0; - virtual void drawKnob( QPainter*, double width, - const QBrush&, bool sunken ) const; + virtual void drawKnob(QPainter *, double width, const QBrush &, + bool sunken) const; - private: - Q_DISABLE_COPY(QwtDialNeedle) +private: + Q_DISABLE_COPY(QwtDialNeedle) - QPalette m_palette; + QPalette m_palette; }; /*! @@ -80,31 +81,31 @@ class QWT_EXPORT QwtDialNeedle class QWT_EXPORT QwtDialSimpleNeedle : public QwtDialNeedle { - public: - //! Style of the needle - enum Style - { - //! Arrow - Arrow, +public: + //! Style of the needle + enum Style + { + //! Arrow + Arrow, - //! A straight line from the center - Ray - }; + //! A straight line from the center + Ray + }; - QwtDialSimpleNeedle( Style, bool hasKnob = true, - const QColor& mid = Qt::gray, const QColor& base = Qt::darkGray ); + QwtDialSimpleNeedle(Style, bool hasKnob = true, const QColor &mid = Qt::gray, + const QColor &base = Qt::darkGray); - void setWidth( double width ); - double width() const; + void setWidth(double width); + double width() const; - protected: - virtual void drawNeedle( QPainter*, double length, - QPalette::ColorGroup ) const QWT_OVERRIDE; +protected: + virtual void drawNeedle(QPainter *, double length, + QPalette::ColorGroup) const QWT_OVERRIDE; - private: - Style m_style; - bool m_hasKnob; - double m_width; +private: + Style m_style; + bool m_hasKnob; + double m_width; }; /*! @@ -126,26 +127,26 @@ class QWT_EXPORT QwtDialSimpleNeedle : public QwtDialNeedle class QWT_EXPORT QwtCompassMagnetNeedle : public QwtDialNeedle { - public: - //! Style of the needle - enum Style - { - //! A needle with a triangular shape - TriangleStyle, +public: + //! Style of the needle + enum Style + { + //! A needle with a triangular shape + TriangleStyle, - //! A thin needle - ThinStyle - }; + //! A thin needle + ThinStyle + }; - QwtCompassMagnetNeedle( Style = TriangleStyle, - const QColor& light = Qt::white, const QColor& dark = Qt::red ); + QwtCompassMagnetNeedle(Style = TriangleStyle, const QColor &light = Qt::white, + const QColor &dark = Qt::red); - protected: - virtual void drawNeedle( QPainter*, - double length, QPalette::ColorGroup ) const QWT_OVERRIDE; +protected: + virtual void drawNeedle(QPainter *, double length, + QPalette::ColorGroup) const QWT_OVERRIDE; - private: - Style m_style; +private: + Style m_style; }; /*! @@ -163,26 +164,26 @@ class QWT_EXPORT QwtCompassMagnetNeedle : public QwtDialNeedle class QWT_EXPORT QwtCompassWindArrow : public QwtDialNeedle { - public: - //! Style of the arrow - enum Style - { - //! A needle pointing to the center - Style1, +public: + //! Style of the arrow + enum Style + { + //! A needle pointing to the center + Style1, - //! A needle pointing to the center - Style2 - }; + //! A needle pointing to the center + Style2 + }; - QwtCompassWindArrow( Style, const QColor& light = Qt::white, - const QColor& dark = Qt::gray ); + QwtCompassWindArrow(Style, const QColor &light = Qt::white, + const QColor &dark = Qt::gray); - protected: - virtual void drawNeedle( QPainter*, - double length, QPalette::ColorGroup ) const QWT_OVERRIDE; +protected: + virtual void drawNeedle(QPainter *, double length, + QPalette::ColorGroup) const QWT_OVERRIDE; - private: - Style m_style; +private: + Style m_style; }; #endif diff --git a/libs/qwt/src/qwt_dyngrid_layout.cpp b/libs/qwt/src/qwt_dyngrid_layout.cpp index 89c73bb6..23decce1 100644 --- a/libs/qwt/src/qwt_dyngrid_layout.cpp +++ b/libs/qwt/src/qwt_dyngrid_layout.cpp @@ -14,39 +14,39 @@ class QwtDynGridLayout::PrivateData { - public: - PrivateData() - : isDirty( true ) - { - } +public: + PrivateData() + : isDirty(true) + { + } - void updateLayoutCache(); + void updateLayoutCache(); - mutable QList< QLayoutItem* > itemList; + mutable QList itemList; - uint maxColumns; - uint numRows; - uint numColumns; + uint maxColumns; + uint numRows; + uint numColumns; - Qt::Orientations expanding; + Qt::Orientations expanding; - bool isDirty; - QVector< QSize > itemSizeHints; + bool isDirty; + QVector itemSizeHints; }; void QwtDynGridLayout::PrivateData::updateLayoutCache() { - itemSizeHints.resize( itemList.count() ); + itemSizeHints.resize(itemList.count()); - int index = 0; + int index = 0; - for ( QList< QLayoutItem* >::const_iterator it = itemList.constBegin(); - it != itemList.constEnd(); ++it, index++ ) - { - itemSizeHints[ index ] = ( *it )->sizeHint(); - } + for (QList::const_iterator it = itemList.constBegin(); + it != itemList.constEnd(); ++it, index++) + { + itemSizeHints[index] = (*it)->sizeHint(); + } - isDirty = false; + isDirty = false; } /*! @@ -55,23 +55,23 @@ void QwtDynGridLayout::PrivateData::updateLayoutCache() \param spacing Spacing */ -QwtDynGridLayout::QwtDynGridLayout( QWidget* parent, int margin, int spacing ) - : QLayout( parent ) +QwtDynGridLayout::QwtDynGridLayout(QWidget *parent, int margin, int spacing) + : QLayout(parent) { - init(); + init(); - setSpacing( spacing ); - setContentsMargins( margin, margin, margin, margin ); + setSpacing(spacing); + setContentsMargins(margin, margin, margin, margin); } /*! \param spacing Spacing */ -QwtDynGridLayout::QwtDynGridLayout( int spacing ) +QwtDynGridLayout::QwtDynGridLayout(int spacing) { - init(); - setSpacing( spacing ); + init(); + setSpacing(spacing); } /*! @@ -79,23 +79,23 @@ QwtDynGridLayout::QwtDynGridLayout( int spacing ) */ void QwtDynGridLayout::init() { - m_data = new QwtDynGridLayout::PrivateData; - m_data->maxColumns = m_data->numRows = m_data->numColumns = 0; + m_data = new QwtDynGridLayout::PrivateData; + m_data->maxColumns = m_data->numRows = m_data->numColumns = 0; } //! Destructor QwtDynGridLayout::~QwtDynGridLayout() { - qDeleteAll( m_data->itemList ); - delete m_data; + qDeleteAll(m_data->itemList); + delete m_data; } //! Invalidate all internal caches void QwtDynGridLayout::invalidate() { - m_data->isDirty = true; - QLayout::invalidate(); + m_data->isDirty = true; + QLayout::invalidate(); } /*! @@ -103,9 +103,9 @@ void QwtDynGridLayout::invalidate() \param maxColumns upper limit, 0 means unlimited \sa maxColumns() */ -void QwtDynGridLayout::setMaxColumns( uint maxColumns ) +void QwtDynGridLayout::setMaxColumns(uint maxColumns) { - m_data->maxColumns = maxColumns; + m_data->maxColumns = maxColumns; } /*! @@ -118,17 +118,17 @@ void QwtDynGridLayout::setMaxColumns( uint maxColumns ) */ uint QwtDynGridLayout::maxColumns() const { - return m_data->maxColumns; + return m_data->maxColumns; } /*! \brief Add an item to the next free position. \param item Layout item */ -void QwtDynGridLayout::addItem( QLayoutItem* item ) +void QwtDynGridLayout::addItem(QLayoutItem *item) { - m_data->itemList.append( item ); - invalidate(); + m_data->itemList.append(item); + invalidate(); } /*! @@ -136,7 +136,7 @@ void QwtDynGridLayout::addItem( QLayoutItem* item ) */ bool QwtDynGridLayout::isEmpty() const { - return m_data->itemList.isEmpty(); + return m_data->itemList.isEmpty(); } /*! @@ -144,7 +144,7 @@ bool QwtDynGridLayout::isEmpty() const */ uint QwtDynGridLayout::itemCount() const { - return m_data->itemList.count(); + return m_data->itemList.count(); } /*! @@ -154,12 +154,12 @@ uint QwtDynGridLayout::itemCount() const \return Item at a specific index \sa takeAt() */ -QLayoutItem* QwtDynGridLayout::itemAt( int index ) const +QLayoutItem *QwtDynGridLayout::itemAt(int index) const { - if ( index < 0 || index >= m_data->itemList.count() ) - return NULL; + if (index < 0 || index >= m_data->itemList.count()) + return NULL; - return m_data->itemList.at( index ); + return m_data->itemList.at(index); } /*! @@ -169,19 +169,19 @@ QLayoutItem* QwtDynGridLayout::itemAt( int index ) const \return Layout item, removed from the layout \sa itemAt() */ -QLayoutItem* QwtDynGridLayout::takeAt( int index ) +QLayoutItem *QwtDynGridLayout::takeAt(int index) { - if ( index < 0 || index >= m_data->itemList.count() ) - return NULL; + if (index < 0 || index >= m_data->itemList.count()) + return NULL; - m_data->isDirty = true; - return m_data->itemList.takeAt( index ); + m_data->isDirty = true; + return m_data->itemList.takeAt(index); } //! \return Number of items in the layout int QwtDynGridLayout::count() const { - return m_data->itemList.count(); + return m_data->itemList.count(); } /*! @@ -193,13 +193,14 @@ int QwtDynGridLayout::count() const \param expanding Or'd orientations \sa expandingDirections() */ -void QwtDynGridLayout::setExpandingDirections( Qt::Orientations expanding ) +void QwtDynGridLayout::setExpandingDirections(Qt::Orientations expanding) { - m_data->expanding = expanding; + m_data->expanding = expanding; } /*! - \brief Returns whether this layout can make use of more space than sizeHint(). + \brief Returns whether this layout can make use of more space than + sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, while Qt::Vertical | Qt::Horizontal means that it wants @@ -210,7 +211,7 @@ void QwtDynGridLayout::setExpandingDirections( Qt::Orientations expanding ) */ Qt::Orientations QwtDynGridLayout::expandingDirections() const { - return m_data->expanding; + return m_data->expanding; } /*! @@ -219,27 +220,27 @@ Qt::Orientations QwtDynGridLayout::expandingDirections() const \param rect Layout geometry */ -void QwtDynGridLayout::setGeometry( const QRect& rect ) +void QwtDynGridLayout::setGeometry(const QRect &rect) { - QLayout::setGeometry( rect ); + QLayout::setGeometry(rect); - if ( isEmpty() ) - return; + if (isEmpty()) + return; - m_data->numColumns = columnsForWidth( rect.width() ); - m_data->numRows = itemCount() / m_data->numColumns; - if ( itemCount() % m_data->numColumns ) - m_data->numRows++; + m_data->numColumns = columnsForWidth(rect.width()); + m_data->numRows = itemCount() / m_data->numColumns; + if (itemCount() % m_data->numColumns) + m_data->numRows++; - const QList< QRect > itemGeometries = layoutItems( rect, m_data->numColumns ); + const QList itemGeometries = layoutItems(rect, m_data->numColumns); - int index = 0; - for ( QList< QLayoutItem* >::const_iterator it = m_data->itemList.constBegin(); - it != m_data->itemList.constEnd(); ++it ) - { - ( *it )->setGeometry( itemGeometries[index] ); - index++; - } + int index = 0; + for (QList::const_iterator it = m_data->itemList.constBegin(); + it != m_data->itemList.constEnd(); ++it) + { + (*it)->setGeometry(itemGeometries[index]); + index++; + } } /*! @@ -253,26 +254,26 @@ void QwtDynGridLayout::setGeometry( const QRect& rect ) \sa maxColumns(), setMaxColumns() */ -uint QwtDynGridLayout::columnsForWidth( int width ) const +uint QwtDynGridLayout::columnsForWidth(int width) const { - if ( isEmpty() ) - return 0; + if (isEmpty()) + return 0; - uint maxColumns = itemCount(); - if ( m_data->maxColumns > 0 ) - maxColumns = qMin( m_data->maxColumns, maxColumns ); + uint maxColumns = itemCount(); + if (m_data->maxColumns > 0) + maxColumns = qMin(m_data->maxColumns, maxColumns); - if ( maxRowWidth( maxColumns ) <= width ) - return maxColumns; + if (maxRowWidth(maxColumns) <= width) + return maxColumns; - for ( uint numColumns = 2; numColumns <= maxColumns; numColumns++ ) - { - const int rowWidth = maxRowWidth( numColumns ); - if ( rowWidth > width ) - return numColumns - 1; - } + for (uint numColumns = 2; numColumns <= maxColumns; numColumns++) + { + const int rowWidth = maxRowWidth(numColumns); + if (rowWidth > width) + return numColumns - 1; + } - return 1; // At least 1 column + return 1; // At least 1 column } /*! @@ -282,32 +283,30 @@ uint QwtDynGridLayout::columnsForWidth( int width ) const \param numColumns Given number of columns \param itemWidth Array of the width hints for all items */ -int QwtDynGridLayout::maxRowWidth( int numColumns ) const +int QwtDynGridLayout::maxRowWidth(int numColumns) const { - int col; + int col; - QVector< int > colWidth( numColumns ); - for ( col = 0; col < numColumns; col++ ) - colWidth[col] = 0; + QVector colWidth(numColumns); + for (col = 0; col < numColumns; col++) + colWidth[col] = 0; - if ( m_data->isDirty ) - m_data->updateLayoutCache(); + if (m_data->isDirty) + m_data->updateLayoutCache(); - for ( int index = 0; - index < m_data->itemSizeHints.count(); index++ ) - { - col = index % numColumns; - colWidth[col] = qMax( colWidth[col], - m_data->itemSizeHints[index].width() ); - } + for (int index = 0; index < m_data->itemSizeHints.count(); index++) + { + col = index % numColumns; + colWidth[col] = qMax(colWidth[col], m_data->itemSizeHints[index].width()); + } - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - int rowWidth = m.left() + m.right() + ( numColumns - 1 ) * spacing(); - for ( col = 0; col < numColumns; col++ ) - rowWidth += colWidth[col]; + int rowWidth = m.left() + m.right() + (numColumns - 1) * spacing(); + for (col = 0; col < numColumns; col++) + rowWidth += colWidth[col]; - return rowWidth; + return rowWidth; } /*! @@ -315,21 +314,21 @@ int QwtDynGridLayout::maxRowWidth( int numColumns ) const */ int QwtDynGridLayout::maxItemWidth() const { - if ( isEmpty() ) - return 0; + if (isEmpty()) + return 0; - if ( m_data->isDirty ) - m_data->updateLayoutCache(); + if (m_data->isDirty) + m_data->updateLayoutCache(); - int w = 0; - for ( int i = 0; i < m_data->itemSizeHints.count(); i++ ) - { - const int itemW = m_data->itemSizeHints[i].width(); - if ( itemW > w ) - w = itemW; - } + int w = 0; + for (int i = 0; i < m_data->itemSizeHints.count(); i++) + { + const int itemW = m_data->itemSizeHints[i].width(); + if (itemW > w) + w = itemW; + } - return w; + return w; } /*! @@ -341,71 +340,70 @@ int QwtDynGridLayout::maxItemWidth() const \return item geometries */ -QList< QRect > QwtDynGridLayout::layoutItems( const QRect& rect, - uint numColumns ) const +QList QwtDynGridLayout::layoutItems(const QRect &rect, + uint numColumns) const { - QList< QRect > itemGeometries; - if ( numColumns == 0 || isEmpty() ) - return itemGeometries; - - uint numRows = itemCount() / numColumns; - if ( numColumns % itemCount() ) - numRows++; - - if ( numRows == 0 ) - return itemGeometries; - - QVector< int > rowHeight( numRows ); - QVector< int > colWidth( numColumns ); - - layoutGrid( numColumns, rowHeight, colWidth ); - - bool expandH, expandV; - expandH = expandingDirections() & Qt::Horizontal; - expandV = expandingDirections() & Qt::Vertical; - - if ( expandH || expandV ) - stretchGrid( rect, numColumns, rowHeight, colWidth ); - - const int maxColumns = m_data->maxColumns; - m_data->maxColumns = numColumns; - const QRect alignedRect = alignmentRect( rect ); - m_data->maxColumns = maxColumns; - - const int xOffset = expandH ? 0 : alignedRect.x(); - const int yOffset = expandV ? 0 : alignedRect.y(); - - QVector< int > colX( numColumns ); - QVector< int > rowY( numRows ); - - const int xySpace = spacing(); - - const QMargins m = contentsMargins(); - - rowY[0] = yOffset + m.top(); - for ( uint r = 1; r < numRows; r++ ) - rowY[r] = rowY[r - 1] + rowHeight[r - 1] + xySpace; - - colX[0] = xOffset + m.left(); - for ( uint c = 1; c < numColumns; c++ ) - colX[c] = colX[c - 1] + colWidth[c - 1] + xySpace; - - const int itemCount = m_data->itemList.size(); - itemGeometries.reserve( itemCount ); - - for ( int i = 0; i < itemCount; i++ ) - { - const int row = i / numColumns; - const int col = i % numColumns; - - const QRect itemGeometry( colX[col], rowY[row], - colWidth[col], rowHeight[row] ); - itemGeometries.append( itemGeometry ); - } - + QList itemGeometries; + if (numColumns == 0 || isEmpty()) return itemGeometries; -} + uint numRows = itemCount() / numColumns; + if (numColumns % itemCount()) + numRows++; + + if (numRows == 0) + return itemGeometries; + + QVector rowHeight(numRows); + QVector colWidth(numColumns); + + layoutGrid(numColumns, rowHeight, colWidth); + + bool expandH, expandV; + expandH = expandingDirections() & Qt::Horizontal; + expandV = expandingDirections() & Qt::Vertical; + + if (expandH || expandV) + stretchGrid(rect, numColumns, rowHeight, colWidth); + + const int maxColumns = m_data->maxColumns; + m_data->maxColumns = numColumns; + const QRect alignedRect = alignmentRect(rect); + m_data->maxColumns = maxColumns; + + const int xOffset = expandH ? 0 : alignedRect.x(); + const int yOffset = expandV ? 0 : alignedRect.y(); + + QVector colX(numColumns); + QVector rowY(numRows); + + const int xySpace = spacing(); + + const QMargins m = contentsMargins(); + + rowY[0] = yOffset + m.top(); + for (uint r = 1; r < numRows; r++) + rowY[r] = rowY[r - 1] + rowHeight[r - 1] + xySpace; + + colX[0] = xOffset + m.left(); + for (uint c = 1; c < numColumns; c++) + colX[c] = colX[c - 1] + colWidth[c - 1] + xySpace; + + const int itemCount = m_data->itemList.size(); + itemGeometries.reserve(itemCount); + + for (int i = 0; i < itemCount; i++) + { + const int row = i / numColumns; + const int col = i % numColumns; + + const QRect itemGeometry(colX[col], rowY[row], colWidth[col], + rowHeight[row]); + itemGeometries.append(itemGeometry); + } + + return itemGeometries; +} /*! Calculate the dimensions for the columns and rows for a grid @@ -416,27 +414,27 @@ QList< QRect > QwtDynGridLayout::layoutItems( const QRect& rect, \param colWidth Array where to fill in the calculated column widths. */ -void QwtDynGridLayout::layoutGrid( uint numColumns, - QVector< int >& rowHeight, QVector< int >& colWidth ) const +void QwtDynGridLayout::layoutGrid(uint numColumns, QVector &rowHeight, + QVector &colWidth) const { - if ( numColumns <= 0 ) - return; + if (numColumns <= 0) + return; - if ( m_data->isDirty ) - m_data->updateLayoutCache(); + if (m_data->isDirty) + m_data->updateLayoutCache(); - for ( int index = 0; index < m_data->itemSizeHints.count(); index++ ) - { - const int row = index / numColumns; - const int col = index % numColumns; + for (int index = 0; index < m_data->itemSizeHints.count(); index++) + { + const int row = index / numColumns; + const int col = index % numColumns; - const QSize& size = m_data->itemSizeHints[index]; + const QSize &size = m_data->itemSizeHints[index]; - rowHeight[row] = ( col == 0 ) - ? size.height() : qMax( rowHeight[row], size.height() ); - colWidth[col] = ( row == 0 ) - ? size.width() : qMax( colWidth[col], size.width() ); - } + rowHeight[row] + = (col == 0) ? size.height() : qMax(rowHeight[row], size.height()); + colWidth[col] + = (row == 0) ? size.width() : qMax(colWidth[col], size.width()); + } } /*! @@ -445,35 +443,35 @@ void QwtDynGridLayout::layoutGrid( uint numColumns, */ bool QwtDynGridLayout::hasHeightForWidth() const { - return true; + return true; } /*! \return The preferred height for this layout, given a width. \sa hasHeightForWidth() */ -int QwtDynGridLayout::heightForWidth( int width ) const +int QwtDynGridLayout::heightForWidth(int width) const { - if ( isEmpty() ) - return 0; + if (isEmpty()) + return 0; - const uint numColumns = columnsForWidth( width ); - uint numRows = itemCount() / numColumns; - if ( itemCount() % numColumns ) - numRows++; + const uint numColumns = columnsForWidth(width); + uint numRows = itemCount() / numColumns; + if (itemCount() % numColumns) + numRows++; - QVector< int > rowHeight( numRows ); - QVector< int > colWidth( numColumns ); + QVector rowHeight(numRows); + QVector colWidth(numColumns); - layoutGrid( numColumns, rowHeight, colWidth ); + layoutGrid(numColumns, rowHeight, colWidth); - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - int h = m.top() + m.bottom() + ( numRows - 1 ) * spacing(); - for ( uint row = 0; row < numRows; row++ ) - h += rowHeight[row]; + int h = m.top() + m.bottom() + (numRows - 1) * spacing(); + for (uint row = 0; row < numRows; row++) + h += rowHeight[row]; - return h; + return h; } /*! @@ -488,55 +486,58 @@ int QwtDynGridLayout::heightForWidth( int width ) const \sa setExpanding(), expanding() */ -void QwtDynGridLayout::stretchGrid( const QRect& rect, - uint numColumns, QVector< int >& rowHeight, QVector< int >& colWidth ) const +void QwtDynGridLayout::stretchGrid(const QRect &rect, uint numColumns, + QVector &rowHeight, + QVector &colWidth) const { - if ( numColumns == 0 || isEmpty() ) - return; + if (numColumns == 0 || isEmpty()) + return; - bool expandH, expandV; - expandH = expandingDirections() & Qt::Horizontal; - expandV = expandingDirections() & Qt::Vertical; + bool expandH, expandV; + expandH = expandingDirections() & Qt::Horizontal; + expandV = expandingDirections() & Qt::Vertical; - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - if ( expandH ) + if (expandH) + { + int xDelta + = rect.width() - m.left() - m.right() - (numColumns - 1) * spacing(); + for (uint col = 0; col < numColumns; col++) + xDelta -= colWidth[col]; + + if (xDelta > 0) { - int xDelta = rect.width() - m.left() - m.right() - ( numColumns - 1 ) * spacing(); - for ( uint col = 0; col < numColumns; col++ ) - xDelta -= colWidth[col]; - - if ( xDelta > 0 ) - { - for ( uint col = 0; col < numColumns; col++ ) - { - const int space = xDelta / ( numColumns - col ); - colWidth[col] += space; - xDelta -= space; - } - } + for (uint col = 0; col < numColumns; col++) + { + const int space = xDelta / (numColumns - col); + colWidth[col] += space; + xDelta -= space; + } } + } - if ( expandV ) + if (expandV) + { + uint numRows = itemCount() / numColumns; + if (itemCount() % numColumns) + numRows++; + + int yDelta + = rect.height() - m.top() - m.bottom() - (numRows - 1) * spacing(); + for (uint row = 0; row < numRows; row++) + yDelta -= rowHeight[row]; + + if (yDelta > 0) { - uint numRows = itemCount() / numColumns; - if ( itemCount() % numColumns ) - numRows++; - - int yDelta = rect.height() - m.top() - m.bottom() - ( numRows - 1 ) * spacing(); - for ( uint row = 0; row < numRows; row++ ) - yDelta -= rowHeight[row]; - - if ( yDelta > 0 ) - { - for ( uint row = 0; row < numRows; row++ ) - { - const int space = yDelta / ( numRows - row ); - rowHeight[row] += space; - yDelta -= space; - } - } + for (uint row = 0; row < numRows; row++) + { + const int space = yDelta / (numRows - row); + rowHeight[row] += space; + yDelta -= space; + } } + } } /*! @@ -549,33 +550,33 @@ void QwtDynGridLayout::stretchGrid( const QRect& rect, */ QSize QwtDynGridLayout::sizeHint() const { - if ( isEmpty() ) - return QSize(); + if (isEmpty()) + return QSize(); - uint numColumns = itemCount(); - if ( m_data->maxColumns > 0 ) - numColumns = qMin( m_data->maxColumns, numColumns ); + uint numColumns = itemCount(); + if (m_data->maxColumns > 0) + numColumns = qMin(m_data->maxColumns, numColumns); - uint numRows = itemCount() / numColumns; - if ( itemCount() % numColumns ) - numRows++; + uint numRows = itemCount() / numColumns; + if (itemCount() % numColumns) + numRows++; - QVector< int > rowHeight( numRows ); - QVector< int > colWidth( numColumns ); + QVector rowHeight(numRows); + QVector colWidth(numColumns); - layoutGrid( numColumns, rowHeight, colWidth ); + layoutGrid(numColumns, rowHeight, colWidth); - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - int h = m.top() + m.bottom() + ( numRows - 1 ) * spacing(); - for ( uint row = 0; row < numRows; row++ ) - h += rowHeight[row]; + int h = m.top() + m.bottom() + (numRows - 1) * spacing(); + for (uint row = 0; row < numRows; row++) + h += rowHeight[row]; - int w = m.left() + m.right() + ( numColumns - 1 ) * spacing(); - for ( uint col = 0; col < numColumns; col++ ) - w += colWidth[col]; + int w = m.left() + m.right() + (numColumns - 1) * spacing(); + for (uint col = 0; col < numColumns; col++) + w += colWidth[col]; - return QSize( w, h ); + return QSize(w, h); } /*! @@ -585,7 +586,7 @@ QSize QwtDynGridLayout::sizeHint() const */ uint QwtDynGridLayout::numRows() const { - return m_data->numRows; + return m_data->numRows; } /*! @@ -595,9 +596,9 @@ uint QwtDynGridLayout::numRows() const */ uint QwtDynGridLayout::numColumns() const { - return m_data->numColumns; + return m_data->numColumns; } #if QWT_MOC_INCLUDE -#include "moc_qwt_dyngrid_layout.cpp" +# include "moc_qwt_dyngrid_layout.cpp" #endif diff --git a/libs/qwt/src/qwt_dyngrid_layout.h b/libs/qwt/src/qwt_dyngrid_layout.h index c1659e7f..4f094c46 100644 --- a/libs/qwt/src/qwt_dyngrid_layout.h +++ b/libs/qwt/src/qwt_dyngrid_layout.h @@ -13,7 +13,8 @@ #include "qwt_global.h" #include -template< typename T > class QList; +template +class QList; /*! \brief The QwtDynGridLayout class lays out widgets in a grid, @@ -26,59 +27,58 @@ template< typename T > class QList; class QWT_EXPORT QwtDynGridLayout : public QLayout { - Q_OBJECT - public: - explicit QwtDynGridLayout( QWidget*, int margin = 0, int spacing = -1 ); - explicit QwtDynGridLayout( int spacing = -1 ); + Q_OBJECT +public: + explicit QwtDynGridLayout(QWidget *, int margin = 0, int spacing = -1); + explicit QwtDynGridLayout(int spacing = -1); - virtual ~QwtDynGridLayout(); + virtual ~QwtDynGridLayout(); - virtual void invalidate() QWT_OVERRIDE; + virtual void invalidate() QWT_OVERRIDE; - void setMaxColumns( uint maxColumns ); - uint maxColumns() const; + void setMaxColumns(uint maxColumns); + uint maxColumns() const; - uint numRows () const; - uint numColumns () const; + uint numRows() const; + uint numColumns() const; - virtual void addItem( QLayoutItem* ) QWT_OVERRIDE; + virtual void addItem(QLayoutItem *) QWT_OVERRIDE; - virtual QLayoutItem* itemAt( int index ) const QWT_OVERRIDE; - virtual QLayoutItem* takeAt( int index ) QWT_OVERRIDE; - virtual int count() const QWT_OVERRIDE; + virtual QLayoutItem *itemAt(int index) const QWT_OVERRIDE; + virtual QLayoutItem *takeAt(int index) QWT_OVERRIDE; + virtual int count() const QWT_OVERRIDE; - void setExpandingDirections( Qt::Orientations ); - virtual Qt::Orientations expandingDirections() const QWT_OVERRIDE; - QList< QRect > layoutItems( const QRect&, uint numColumns ) const; + void setExpandingDirections(Qt::Orientations); + virtual Qt::Orientations expandingDirections() const QWT_OVERRIDE; + QList layoutItems(const QRect &, uint numColumns) const; - virtual int maxItemWidth() const; + virtual int maxItemWidth() const; - virtual void setGeometry( const QRect& ) QWT_OVERRIDE; + virtual void setGeometry(const QRect &) QWT_OVERRIDE; - virtual bool hasHeightForWidth() const QWT_OVERRIDE; - virtual int heightForWidth( int ) const QWT_OVERRIDE; + virtual bool hasHeightForWidth() const QWT_OVERRIDE; + virtual int heightForWidth(int) const QWT_OVERRIDE; - virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; - virtual bool isEmpty() const QWT_OVERRIDE; - uint itemCount() const; + virtual bool isEmpty() const QWT_OVERRIDE; + uint itemCount() const; - virtual uint columnsForWidth( int width ) const; + virtual uint columnsForWidth(int width) const; - protected: +protected: + void layoutGrid(uint numColumns, QVector &rowHeight, + QVector &colWidth) const; - void layoutGrid( uint numColumns, - QVector< int >& rowHeight, QVector< int >& colWidth ) const; + void stretchGrid(const QRect &rect, uint numColumns, QVector &rowHeight, + QVector &colWidth) const; - void stretchGrid( const QRect& rect, uint numColumns, - QVector< int >& rowHeight, QVector< int >& colWidth ) const; +private: + void init(); + int maxRowWidth(int numColumns) const; - private: - void init(); - int maxRowWidth( int numColumns ) const; - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_event_pattern.cpp b/libs/qwt/src/qwt_event_pattern.cpp index 8d5e1fb5..20ef56fb 100644 --- a/libs/qwt/src/qwt_event_pattern.cpp +++ b/libs/qwt/src/qwt_event_pattern.cpp @@ -17,17 +17,15 @@ */ QwtEventPattern::QwtEventPattern() - : m_mousePattern( MousePatternCount ) - , m_keyPattern( KeyPatternCount ) + : m_mousePattern(MousePatternCount) + , m_keyPattern(KeyPatternCount) { - initKeyPattern(); - initMousePattern( 3 ); + initKeyPattern(); + initMousePattern(3); } //! Destructor -QwtEventPattern::~QwtEventPattern() -{ -} +QwtEventPattern::~QwtEventPattern() {} /*! Set default mouse patterns, depending on the number of mouse buttons @@ -35,42 +33,39 @@ QwtEventPattern::~QwtEventPattern() \param numButtons Number of mouse buttons ( <= 3 ) \sa MousePatternCode */ -void QwtEventPattern::initMousePattern( int numButtons ) +void QwtEventPattern::initMousePattern(int numButtons) { - m_mousePattern.resize( MousePatternCount ); + m_mousePattern.resize(MousePatternCount); - switch ( numButtons ) - { - case 1: - { - setMousePattern( MouseSelect1, Qt::LeftButton ); - setMousePattern( MouseSelect2, Qt::LeftButton, Qt::ControlModifier ); - setMousePattern( MouseSelect3, Qt::LeftButton, Qt::AltModifier ); - break; - } - case 2: - { - setMousePattern( MouseSelect1, Qt::LeftButton ); - setMousePattern( MouseSelect2, Qt::RightButton ); - setMousePattern( MouseSelect3, Qt::LeftButton, Qt::AltModifier ); - break; - } - default: - { - setMousePattern( MouseSelect1, Qt::LeftButton ); - setMousePattern( MouseSelect2, Qt::RightButton ); - setMousePattern( MouseSelect3, Qt::MiddleButton ); - } + switch (numButtons) + { + case 1: { + setMousePattern(MouseSelect1, Qt::LeftButton); + setMousePattern(MouseSelect2, Qt::LeftButton, Qt::ControlModifier); + setMousePattern(MouseSelect3, Qt::LeftButton, Qt::AltModifier); + break; } + case 2: { + setMousePattern(MouseSelect1, Qt::LeftButton); + setMousePattern(MouseSelect2, Qt::RightButton); + setMousePattern(MouseSelect3, Qt::LeftButton, Qt::AltModifier); + break; + } + default: { + setMousePattern(MouseSelect1, Qt::LeftButton); + setMousePattern(MouseSelect2, Qt::RightButton); + setMousePattern(MouseSelect3, Qt::MiddleButton); + } + } - setMousePattern( MouseSelect4, m_mousePattern[MouseSelect1].button, - m_mousePattern[MouseSelect1].modifiers | Qt::ShiftModifier ); + setMousePattern(MouseSelect4, m_mousePattern[MouseSelect1].button, + m_mousePattern[MouseSelect1].modifiers | Qt::ShiftModifier); - setMousePattern( MouseSelect5, m_mousePattern[MouseSelect2].button, - m_mousePattern[MouseSelect2].modifiers | Qt::ShiftModifier ); + setMousePattern(MouseSelect5, m_mousePattern[MouseSelect2].button, + m_mousePattern[MouseSelect2].modifiers | Qt::ShiftModifier); - setMousePattern( MouseSelect6, m_mousePattern[MouseSelect3].button, - m_mousePattern[MouseSelect3].modifiers | Qt::ShiftModifier ); + setMousePattern(MouseSelect6, m_mousePattern[MouseSelect3].button, + m_mousePattern[MouseSelect3].modifiers | Qt::ShiftModifier); } /*! @@ -80,20 +75,20 @@ void QwtEventPattern::initMousePattern( int numButtons ) */ void QwtEventPattern::initKeyPattern() { - m_keyPattern.resize( KeyPatternCount ); + m_keyPattern.resize(KeyPatternCount); - setKeyPattern( KeySelect1, Qt::Key_Return ); - setKeyPattern( KeySelect2, Qt::Key_Space ); - setKeyPattern( KeyAbort, Qt::Key_Escape ); + setKeyPattern(KeySelect1, Qt::Key_Return); + setKeyPattern(KeySelect2, Qt::Key_Space); + setKeyPattern(KeyAbort, Qt::Key_Escape); - setKeyPattern( KeyLeft, Qt::Key_Left ); - setKeyPattern( KeyRight, Qt::Key_Right ); - setKeyPattern( KeyUp, Qt::Key_Up ); - setKeyPattern( KeyDown, Qt::Key_Down ); + setKeyPattern(KeyLeft, Qt::Key_Left); + setKeyPattern(KeyRight, Qt::Key_Right); + setKeyPattern(KeyUp, Qt::Key_Up); + setKeyPattern(KeyDown, Qt::Key_Down); - setKeyPattern( KeyRedo, Qt::Key_Plus ); - setKeyPattern( KeyUndo, Qt::Key_Minus ); - setKeyPattern( KeyHome, Qt::Key_Escape ); + setKeyPattern(KeyRedo, Qt::Key_Plus); + setKeyPattern(KeyUndo, Qt::Key_Minus); + setKeyPattern(KeyHome, Qt::Key_Escape); } /*! @@ -105,14 +100,15 @@ void QwtEventPattern::initKeyPattern() \sa QMouseEvent */ -void QwtEventPattern::setMousePattern( MousePatternCode pattern, - Qt::MouseButton button, Qt::KeyboardModifiers modifiers ) +void QwtEventPattern::setMousePattern(MousePatternCode pattern, + Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) { - if ( pattern >= 0 && pattern < MousePatternCount ) - { - m_mousePattern[ pattern ].button = button; - m_mousePattern[ pattern ].modifiers = modifiers; - } + if (pattern >= 0 && pattern < MousePatternCount) + { + m_mousePattern[pattern].button = button; + m_mousePattern[pattern].modifiers = modifiers; + } } /*! @@ -124,52 +120,51 @@ void QwtEventPattern::setMousePattern( MousePatternCode pattern, \sa QKeyEvent */ -void QwtEventPattern::setKeyPattern( KeyPatternCode pattern, - int key, Qt::KeyboardModifiers modifiers ) +void QwtEventPattern::setKeyPattern(KeyPatternCode pattern, int key, + Qt::KeyboardModifiers modifiers) { - if ( pattern >= 0 && pattern < KeyPatternCount ) - { - m_keyPattern[ pattern ].key = key; - m_keyPattern[ pattern ].modifiers = modifiers; - } + if (pattern >= 0 && pattern < KeyPatternCount) + { + m_keyPattern[pattern].key = key; + m_keyPattern[pattern].modifiers = modifiers; + } } //! Change the mouse event patterns -void QwtEventPattern::setMousePattern( const QVector< MousePattern >& pattern ) +void QwtEventPattern::setMousePattern(const QVector &pattern) { - m_mousePattern = pattern; + m_mousePattern = pattern; } //! Change the key event patterns -void QwtEventPattern::setKeyPattern( const QVector< KeyPattern >& pattern ) +void QwtEventPattern::setKeyPattern(const QVector &pattern) { - m_keyPattern = pattern; + m_keyPattern = pattern; } //! \return Mouse pattern -const QVector< QwtEventPattern::MousePattern >& +const QVector & QwtEventPattern::mousePattern() const { - return m_mousePattern; + return m_mousePattern; } //! \return Key pattern -const QVector< QwtEventPattern::KeyPattern >& -QwtEventPattern::keyPattern() const +const QVector &QwtEventPattern::keyPattern() const { - return m_keyPattern; + return m_keyPattern; } //! \return Mouse pattern -QVector< QwtEventPattern::MousePattern >& QwtEventPattern::mousePattern() +QVector &QwtEventPattern::mousePattern() { - return m_mousePattern; + return m_mousePattern; } //! \return Key pattern -QVector< QwtEventPattern::KeyPattern >& QwtEventPattern::keyPattern() +QVector &QwtEventPattern::keyPattern() { - return m_keyPattern; + return m_keyPattern; } /*! @@ -185,13 +180,13 @@ QVector< QwtEventPattern::KeyPattern >& QwtEventPattern::keyPattern() \sa keyMatch() */ -bool QwtEventPattern::mouseMatch( MousePatternCode code, - const QMouseEvent* event ) const +bool QwtEventPattern::mouseMatch(MousePatternCode code, + const QMouseEvent *event) const { - if ( code >= 0 && code < MousePatternCount ) - return mouseMatch( m_mousePattern[ code ], event ); + if (code >= 0 && code < MousePatternCount) + return mouseMatch(m_mousePattern[code], event); - return false; + return false; } /*! @@ -208,14 +203,14 @@ bool QwtEventPattern::mouseMatch( MousePatternCode code, \sa keyMatch() */ -bool QwtEventPattern::mouseMatch( const MousePattern& pattern, - const QMouseEvent* event ) const +bool QwtEventPattern::mouseMatch(const MousePattern &pattern, + const QMouseEvent *event) const { - if ( event == NULL ) - return false; + if (event == NULL) + return false; - const MousePattern mousePattern( event->button(), event->modifiers() ); - return mousePattern == pattern; + const MousePattern mousePattern(event->button(), event->modifiers()); + return mousePattern == pattern; } /*! @@ -231,13 +226,13 @@ bool QwtEventPattern::mouseMatch( const MousePattern& pattern, \sa mouseMatch() */ -bool QwtEventPattern::keyMatch( KeyPatternCode code, - const QKeyEvent* event ) const +bool QwtEventPattern::keyMatch(KeyPatternCode code, + const QKeyEvent *event) const { - if ( code >= 0 && code < KeyPatternCount ) - return keyMatch( m_keyPattern[ code ], event ); + if (code >= 0 && code < KeyPatternCount) + return keyMatch(m_keyPattern[code], event); - return false; + return false; } /*! @@ -254,12 +249,12 @@ bool QwtEventPattern::keyMatch( KeyPatternCode code, \sa mouseMatch() */ -bool QwtEventPattern::keyMatch( - const KeyPattern& pattern, const QKeyEvent* event ) const +bool QwtEventPattern::keyMatch(const KeyPattern &pattern, + const QKeyEvent *event) const { - if ( event == NULL ) - return false; + if (event == NULL) + return false; - const KeyPattern keyPattern( event->key(), event->modifiers() ); - return keyPattern == pattern; + const KeyPattern keyPattern(event->key(), event->modifiers()); + return keyPattern == pattern; } diff --git a/libs/qwt/src/qwt_event_pattern.h b/libs/qwt/src/qwt_event_pattern.h index bcecc070..4f80f184 100644 --- a/libs/qwt/src/qwt_event_pattern.h +++ b/libs/qwt/src/qwt_event_pattern.h @@ -29,213 +29,212 @@ class QKeyEvent; */ class QWT_EXPORT QwtEventPattern { +public: + /*! + \brief Symbolic mouse input codes + + QwtEventPattern implements 3 different settings for + mice with 1, 2, or 3 buttons that can be activated + using initMousePattern(). The default setting is for + 3 button mice. + + Individual settings can be configured using setMousePattern(). + + \sa initMousePattern(), setMousePattern(), setKeyPattern() + */ + enum MousePatternCode + { + /*! + The default setting for 1, 2 and 3 button mice is: + + - Qt::LeftButton + - Qt::LeftButton + - Qt::LeftButton + */ + MouseSelect1, + + /*! + The default setting for 1, 2 and 3 button mice is: + + - Qt::LeftButton + Qt::ControlModifier + - Qt::RightButton + - Qt::RightButton + */ + MouseSelect2, + + /*! + The default setting for 1, 2 and 3 button mice is: + + - Qt::LeftButton + Qt::AltModifier + - Qt::LeftButton + Qt::AltModifier + - Qt::MidButton + */ + MouseSelect3, + + /*! + The default setting for 1, 2 and 3 button mice is: + + - Qt::LeftButton + Qt::ShiftModifier + - Qt::LeftButton + Qt::ShiftModifier + - Qt::LeftButton + Qt::ShiftModifier + */ + MouseSelect4, + + /*! + The default setting for 1, 2 and 3 button mice is: + + - Qt::LeftButton + Qt::ControlButton | Qt::ShiftModifier + - Qt::RightButton + Qt::ShiftModifier + - Qt::RightButton + Qt::ShiftModifier + */ + MouseSelect5, + + /*! + The default setting for 1, 2 and 3 button mice is: + + - Qt::LeftButton + Qt::AltModifier + Qt::ShiftModifier + - Qt::LeftButton + Qt::AltModifier | Qt::ShiftModifier + - Qt::MidButton + Qt::ShiftModifier + */ + MouseSelect6, + + //! Number of mouse patterns + MousePatternCount + }; + + /*! + \brief Symbolic keyboard input codes + + Individual settings can be configured using setKeyPattern() + + \sa setKeyPattern(), setMousePattern() + */ + enum KeyPatternCode + { + //! Qt::Key_Return + KeySelect1, + + //! Qt::Key_Space + KeySelect2, + + //! Qt::Key_Escape + KeyAbort, + + //! Qt::Key_Left + KeyLeft, + + //! Qt::Key_Right + KeyRight, + + //! Qt::Key_Up + KeyUp, + + //! Qt::Key_Down + KeyDown, + + //! Qt::Key_Plus + KeyRedo, + + //! Qt::Key_Minus + KeyUndo, + + //! Qt::Key_Escape + KeyHome, + + //! Number of key patterns + KeyPatternCount + }; + + //! A pattern for mouse events + class MousePattern + { public: - /*! - \brief Symbolic mouse input codes - - QwtEventPattern implements 3 different settings for - mice with 1, 2, or 3 buttons that can be activated - using initMousePattern(). The default setting is for - 3 button mice. - - Individual settings can be configured using setMousePattern(). - - \sa initMousePattern(), setMousePattern(), setKeyPattern() - */ - enum MousePatternCode + //! Constructor + MousePattern(Qt::MouseButton btn = Qt::NoButton, + Qt::KeyboardModifiers modifierCodes = Qt::NoModifier) + : button(btn) + , modifiers(modifierCodes) { - /*! - The default setting for 1, 2 and 3 button mice is: + } - - Qt::LeftButton - - Qt::LeftButton - - Qt::LeftButton - */ - MouseSelect1, + //! Button + Qt::MouseButton button; - /*! - The default setting for 1, 2 and 3 button mice is: + //! Keyboard modifier + Qt::KeyboardModifiers modifiers; + }; - - Qt::LeftButton + Qt::ControlModifier - - Qt::RightButton - - Qt::RightButton - */ - MouseSelect2, - - /*! - The default setting for 1, 2 and 3 button mice is: - - - Qt::LeftButton + Qt::AltModifier - - Qt::LeftButton + Qt::AltModifier - - Qt::MidButton - */ - MouseSelect3, - - /*! - The default setting for 1, 2 and 3 button mice is: - - - Qt::LeftButton + Qt::ShiftModifier - - Qt::LeftButton + Qt::ShiftModifier - - Qt::LeftButton + Qt::ShiftModifier - */ - MouseSelect4, - - /*! - The default setting for 1, 2 and 3 button mice is: - - - Qt::LeftButton + Qt::ControlButton | Qt::ShiftModifier - - Qt::RightButton + Qt::ShiftModifier - - Qt::RightButton + Qt::ShiftModifier - */ - MouseSelect5, - - /*! - The default setting for 1, 2 and 3 button mice is: - - - Qt::LeftButton + Qt::AltModifier + Qt::ShiftModifier - - Qt::LeftButton + Qt::AltModifier | Qt::ShiftModifier - - Qt::MidButton + Qt::ShiftModifier - */ - MouseSelect6, - - //! Number of mouse patterns - MousePatternCount - }; - - /*! - \brief Symbolic keyboard input codes - - Individual settings can be configured using setKeyPattern() - - \sa setKeyPattern(), setMousePattern() - */ - enum KeyPatternCode + //! A pattern for key events + class KeyPattern + { + public: + //! Constructor + KeyPattern(int keyCode = Qt::Key_unknown, + Qt::KeyboardModifiers modifierCodes = Qt::NoModifier) + : key(keyCode) + , modifiers(modifierCodes) { - //! Qt::Key_Return - KeySelect1, + } - //! Qt::Key_Space - KeySelect2, + //! Key code + int key; - //! Qt::Key_Escape - KeyAbort, + //! Modifiers + Qt::KeyboardModifiers modifiers; + }; - //! Qt::Key_Left - KeyLeft, + QwtEventPattern(); + virtual ~QwtEventPattern(); - //! Qt::Key_Right - KeyRight, + void initMousePattern(int numButtons); + void initKeyPattern(); - //! Qt::Key_Up - KeyUp, + void setMousePattern(MousePatternCode, Qt::MouseButton button, + Qt::KeyboardModifiers = Qt::NoModifier); - //! Qt::Key_Down - KeyDown, + void setKeyPattern(KeyPatternCode, int key, + Qt::KeyboardModifiers modifiers = Qt::NoModifier); - //! Qt::Key_Plus - KeyRedo, + void setMousePattern(const QVector &); + void setKeyPattern(const QVector &); - //! Qt::Key_Minus - KeyUndo, + const QVector &mousePattern() const; + const QVector &keyPattern() const; - //! Qt::Key_Escape - KeyHome, + QVector &mousePattern(); + QVector &keyPattern(); - //! Number of key patterns - KeyPatternCount - }; + bool mouseMatch(MousePatternCode, const QMouseEvent *) const; + bool keyMatch(KeyPatternCode, const QKeyEvent *) const; - //! A pattern for mouse events - class MousePattern - { - public: - //! Constructor - MousePattern( Qt::MouseButton btn = Qt::NoButton, - Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ): - button( btn ), - modifiers( modifierCodes ) - { - } +protected: + virtual bool mouseMatch(const MousePattern &, const QMouseEvent *) const; + virtual bool keyMatch(const KeyPattern &, const QKeyEvent *) const; - //! Button - Qt::MouseButton button; - - //! Keyboard modifier - Qt::KeyboardModifiers modifiers; - }; - - //! A pattern for key events - class KeyPattern - { - public: - //! Constructor - KeyPattern( int keyCode = Qt::Key_unknown, - Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ): - key( keyCode ), - modifiers( modifierCodes ) - { - } - - //! Key code - int key; - - //! Modifiers - Qt::KeyboardModifiers modifiers; - }; - - QwtEventPattern(); - virtual ~QwtEventPattern(); - - void initMousePattern( int numButtons ); - void initKeyPattern(); - - void setMousePattern( MousePatternCode, Qt::MouseButton button, - Qt::KeyboardModifiers = Qt::NoModifier ); - - void setKeyPattern( KeyPatternCode, int key, - Qt::KeyboardModifiers modifiers = Qt::NoModifier ); - - void setMousePattern( const QVector< MousePattern >& ); - void setKeyPattern( const QVector< KeyPattern >& ); - - const QVector< MousePattern >& mousePattern() const; - const QVector< KeyPattern >& keyPattern() const; - - QVector< MousePattern >& mousePattern(); - QVector< KeyPattern >& keyPattern(); - - bool mouseMatch( MousePatternCode, const QMouseEvent* ) const; - bool keyMatch( KeyPatternCode, const QKeyEvent* ) const; - - protected: - virtual bool mouseMatch( const MousePattern&, const QMouseEvent* ) const; - virtual bool keyMatch( const KeyPattern&, const QKeyEvent* ) const; - - private: - -#if defined( _MSC_VER ) -#pragma warning(push) -#pragma warning(disable: 4251) +private: +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4251) #endif - QVector< MousePattern > m_mousePattern; - QVector< KeyPattern > m_keyPattern; -#if defined( _MSC_VER ) -#pragma warning(pop) + QVector m_mousePattern; + QVector m_keyPattern; +#if defined(_MSC_VER) +# pragma warning(pop) #endif }; //! Compare operator -inline bool operator==( QwtEventPattern::MousePattern b1, - QwtEventPattern::MousePattern b2 ) +inline bool operator==(QwtEventPattern::MousePattern b1, + QwtEventPattern::MousePattern b2) { - return b1.button == b2.button && b1.modifiers == b2.modifiers; + return b1.button == b2.button && b1.modifiers == b2.modifiers; } //! Compare operator -inline bool operator==( QwtEventPattern::KeyPattern b1, - QwtEventPattern::KeyPattern b2 ) +inline bool operator==(QwtEventPattern::KeyPattern b1, + QwtEventPattern::KeyPattern b2) { - return b1.key == b2.key && b1.modifiers == b2.modifiers; + return b1.key == b2.key && b1.modifiers == b2.modifiers; } #endif diff --git a/libs/qwt/src/qwt_global.h b/libs/qwt/src/qwt_global.h index 3c5d6c63..0f086eb2 100644 --- a/libs/qwt/src/qwt_global.h +++ b/libs/qwt/src/qwt_global.h @@ -14,47 +14,47 @@ // QWT_VERSION is (major << 16) + (minor << 8) + patch. -#define QWT_VERSION 0x060200 -#define QWT_VERSION_STR "6.2.0" +#define QWT_VERSION 0x060200 +#define QWT_VERSION_STR "6.2.0" -#if defined( _MSC_VER ) /* MSVC Compiler */ +#if defined(_MSC_VER) /* MSVC Compiler */ /* template-class specialization 'identifier' is already instantiated */ -#pragma warning(disable: 4660) +# pragma warning(disable : 4660) /* inherits via dominance */ -#pragma warning(disable: 4250) +# pragma warning(disable : 4250) #endif // _MSC_VER #ifdef QWT_DLL -#if defined( QWT_MAKEDLL ) // create a Qwt DLL library -#define QWT_EXPORT Q_DECL_EXPORT -#else // use a Qwt DLL library -#define QWT_EXPORT Q_DECL_IMPORT -#endif +# if defined(QWT_MAKEDLL) // create a Qwt DLL library +# define QWT_EXPORT Q_DECL_EXPORT +# else // use a Qwt DLL library +# define QWT_EXPORT Q_DECL_IMPORT +# endif #endif // QWT_DLL #ifndef QWT_EXPORT -#define QWT_EXPORT +# define QWT_EXPORT #endif #define QWT_CONSTEXPR Q_DECL_CONSTEXPR #if QT_VERSION >= 0x050000 -#define QWT_OVERRIDE Q_DECL_OVERRIDE -#define QWT_FINAL Q_DECL_FINAL +# define QWT_OVERRIDE Q_DECL_OVERRIDE +# define QWT_FINAL Q_DECL_FINAL #endif #ifndef QWT_CONSTEXPR -#define QWT_CONSTEXPR +# define QWT_CONSTEXPR #endif #ifndef QWT_OVERRIDE -#define QWT_OVERRIDE +# define QWT_OVERRIDE #endif #ifndef QWT_FINAL -#define QWT_FINAL +# define QWT_FINAL #endif #endif diff --git a/libs/qwt/src/qwt_graphic.cpp b/libs/qwt/src/qwt_graphic.cpp index 7f72efb7..90209639 100644 --- a/libs/qwt/src/qwt_graphic.cpp +++ b/libs/qwt/src/qwt_graphic.cpp @@ -20,330 +20,325 @@ #if QT_VERSION >= 0x050000 -#include +# include static inline qreal qwtDevicePixelRatio() { - return qGuiApp ? qGuiApp->devicePixelRatio() : 1.0; + return qGuiApp ? qGuiApp->devicePixelRatio() : 1.0; } #endif -static bool qwtHasScalablePen( const QPainter* painter ) +static bool qwtHasScalablePen(const QPainter *painter) { - const QPen pen = painter->pen(); + const QPen pen = painter->pen(); - bool scalablePen = false; + bool scalablePen = false; - if ( pen.style() != Qt::NoPen && pen.brush().style() != Qt::NoBrush ) - { - scalablePen = !pen.isCosmetic(); + if (pen.style() != Qt::NoPen && pen.brush().style() != Qt::NoBrush) + { + scalablePen = !pen.isCosmetic(); #if QT_VERSION < 0x050000 - if ( !scalablePen && pen.widthF() == 0.0 ) - { - const QPainter::RenderHints hints = painter->renderHints(); - if ( hints.testFlag( QPainter::NonCosmeticDefaultPen ) ) - scalablePen = true; - } + if (!scalablePen && pen.widthF() == 0.0) + { + const QPainter::RenderHints hints = painter->renderHints(); + if (hints.testFlag(QPainter::NonCosmeticDefaultPen)) + scalablePen = true; + } #endif - } + } - return scalablePen; + return scalablePen; } -static QRectF qwtStrokedPathRect( - const QPainter* painter, const QPainterPath& path ) +static QRectF qwtStrokedPathRect(const QPainter *painter, + const QPainterPath &path) { - QPainterPathStroker stroker; - stroker.setWidth( painter->pen().widthF() ); - stroker.setCapStyle( painter->pen().capStyle() ); - stroker.setJoinStyle( painter->pen().joinStyle() ); - stroker.setMiterLimit( painter->pen().miterLimit() ); + QPainterPathStroker stroker; + stroker.setWidth(painter->pen().widthF()); + stroker.setCapStyle(painter->pen().capStyle()); + stroker.setJoinStyle(painter->pen().joinStyle()); + stroker.setMiterLimit(painter->pen().miterLimit()); - QRectF rect; - if ( qwtHasScalablePen( painter ) ) - { - QPainterPath stroke = stroker.createStroke( path ); - rect = painter->transform().map( stroke ).boundingRect(); - } - else - { - QPainterPath mappedPath = painter->transform().map( path ); - mappedPath = stroker.createStroke( mappedPath ); + QRectF rect; + if (qwtHasScalablePen(painter)) + { + QPainterPath stroke = stroker.createStroke(path); + rect = painter->transform().map(stroke).boundingRect(); + } + else + { + QPainterPath mappedPath = painter->transform().map(path); + mappedPath = stroker.createStroke(mappedPath); - rect = mappedPath.boundingRect(); - } + rect = mappedPath.boundingRect(); + } - return rect; + return rect; } -static inline void qwtExecCommand( - QPainter* painter, const QwtPainterCommand& cmd, - QwtGraphic::RenderHints renderHints, - const QTransform& transform, - const QTransform* initialTransform ) +static inline void qwtExecCommand(QPainter *painter, + const QwtPainterCommand &cmd, + QwtGraphic::RenderHints renderHints, + const QTransform &transform, + const QTransform *initialTransform) { - switch( cmd.type() ) - { - case QwtPainterCommand::Path: - { - bool doMap = false; + switch (cmd.type()) + { + case QwtPainterCommand::Path: { + bool doMap = false; - if ( painter->transform().isScaling() ) - { - bool isCosmetic = painter->pen().isCosmetic(); + if (painter->transform().isScaling()) + { + bool isCosmetic = painter->pen().isCosmetic(); #if QT_VERSION < 0x050000 - if ( isCosmetic && painter->pen().widthF() == 0.0 ) - { - QPainter::RenderHints hints = painter->renderHints(); - if ( hints.testFlag( QPainter::NonCosmeticDefaultPen ) ) - isCosmetic = false; - } + if (isCosmetic && painter->pen().widthF() == 0.0) + { + QPainter::RenderHints hints = painter->renderHints(); + if (hints.testFlag(QPainter::NonCosmeticDefaultPen)) + isCosmetic = false; + } #endif - if ( isCosmetic ) - { - // OpenGL2 seems to be buggy for cosmetic pens. - // It interpolates curves in too rough steps then - - doMap = painter->paintEngine()->type() == QPaintEngine::OpenGL2; - } - else - { - doMap = renderHints.testFlag( QwtGraphic::RenderPensUnscaled ); - } - } - - if ( doMap ) - { - const QTransform tr = painter->transform(); - - painter->resetTransform(); - - QPainterPath path = tr.map( *cmd.path() ); - if ( initialTransform ) - { - painter->setTransform( *initialTransform ); - path = initialTransform->inverted().map( path ); - } - - painter->drawPath( path ); - - painter->setTransform( tr ); - } - else - { - painter->drawPath( *cmd.path() ); - } - break; - } - case QwtPainterCommand::Pixmap: + if (isCosmetic) { - const QwtPainterCommand::PixmapData* data = cmd.pixmapData(); - painter->drawPixmap( data->rect, data->pixmap, data->subRect ); - break; + // OpenGL2 seems to be buggy for cosmetic pens. + // It interpolates curves in too rough steps then + + doMap = painter->paintEngine()->type() == QPaintEngine::OpenGL2; } - case QwtPainterCommand::Image: + else { - const QwtPainterCommand::ImageData* data = cmd.imageData(); - painter->drawImage( data->rect, data->image, - data->subRect, data->flags ); - break; + doMap = renderHints.testFlag(QwtGraphic::RenderPensUnscaled); } - case QwtPainterCommand::State: + } + + if (doMap) + { + const QTransform tr = painter->transform(); + + painter->resetTransform(); + + QPainterPath path = tr.map(*cmd.path()); + if (initialTransform) { - const QwtPainterCommand::StateData* data = cmd.stateData(); - - if ( data->flags & QPaintEngine::DirtyPen ) - painter->setPen( data->pen ); - - if ( data->flags & QPaintEngine::DirtyBrush ) - painter->setBrush( data->brush ); - - if ( data->flags & QPaintEngine::DirtyBrushOrigin ) - painter->setBrushOrigin( data->brushOrigin ); - - if ( data->flags & QPaintEngine::DirtyFont ) - painter->setFont( data->font ); - - if ( data->flags & QPaintEngine::DirtyBackground ) - { - painter->setBackgroundMode( data->backgroundMode ); - painter->setBackground( data->backgroundBrush ); - } - - if ( data->flags & QPaintEngine::DirtyTransform ) - { - painter->setTransform( data->transform * transform ); - } - - if ( data->flags & QPaintEngine::DirtyClipEnabled ) - painter->setClipping( data->isClipEnabled ); - - if ( data->flags & QPaintEngine::DirtyClipRegion ) - { - painter->setClipRegion( data->clipRegion, - data->clipOperation ); - } - - if ( data->flags & QPaintEngine::DirtyClipPath ) - { - painter->setClipPath( data->clipPath, data->clipOperation ); - } - - if ( data->flags & QPaintEngine::DirtyHints ) - { - for ( int i = 0; i < 8; i++ ) - { - const QPainter::RenderHint hint = static_cast< QPainter::RenderHint >( 1 << i ); - painter->setRenderHint( hint, data->renderHints.testFlag( hint ) ); - } - } - - if ( data->flags & QPaintEngine::DirtyCompositionMode ) - painter->setCompositionMode( data->compositionMode ); - - if ( data->flags & QPaintEngine::DirtyOpacity ) - painter->setOpacity( data->opacity ); - - break; + painter->setTransform(*initialTransform); + path = initialTransform->inverted().map(path); } - default: - break; + + painter->drawPath(path); + + painter->setTransform(tr); + } + else + { + painter->drawPath(*cmd.path()); + } + break; } + case QwtPainterCommand::Pixmap: { + const QwtPainterCommand::PixmapData *data = cmd.pixmapData(); + painter->drawPixmap(data->rect, data->pixmap, data->subRect); + break; + } + case QwtPainterCommand::Image: { + const QwtPainterCommand::ImageData *data = cmd.imageData(); + painter->drawImage(data->rect, data->image, data->subRect, data->flags); + break; + } + case QwtPainterCommand::State: { + const QwtPainterCommand::StateData *data = cmd.stateData(); + + if (data->flags & QPaintEngine::DirtyPen) + painter->setPen(data->pen); + + if (data->flags & QPaintEngine::DirtyBrush) + painter->setBrush(data->brush); + + if (data->flags & QPaintEngine::DirtyBrushOrigin) + painter->setBrushOrigin(data->brushOrigin); + + if (data->flags & QPaintEngine::DirtyFont) + painter->setFont(data->font); + + if (data->flags & QPaintEngine::DirtyBackground) + { + painter->setBackgroundMode(data->backgroundMode); + painter->setBackground(data->backgroundBrush); + } + + if (data->flags & QPaintEngine::DirtyTransform) + { + painter->setTransform(data->transform * transform); + } + + if (data->flags & QPaintEngine::DirtyClipEnabled) + painter->setClipping(data->isClipEnabled); + + if (data->flags & QPaintEngine::DirtyClipRegion) + { + painter->setClipRegion(data->clipRegion, data->clipOperation); + } + + if (data->flags & QPaintEngine::DirtyClipPath) + { + painter->setClipPath(data->clipPath, data->clipOperation); + } + + if (data->flags & QPaintEngine::DirtyHints) + { + for (int i = 0; i < 8; i++) + { + const QPainter::RenderHint hint + = static_cast(1 << i); + painter->setRenderHint(hint, data->renderHints.testFlag(hint)); + } + } + + if (data->flags & QPaintEngine::DirtyCompositionMode) + painter->setCompositionMode(data->compositionMode); + + if (data->flags & QPaintEngine::DirtyOpacity) + painter->setOpacity(data->opacity); + + break; + } + default: + break; + } } class QwtGraphic::PathInfo { - public: - PathInfo() - : m_scalablePen( false ) +public: + PathInfo() + : m_scalablePen(false) + { + // QVector needs a default constructor + } + + PathInfo(const QRectF &pointRect, const QRectF &boundingRect, + bool scalablePen) + : m_pointRect(pointRect) + , m_boundingRect(boundingRect) + , m_scalablePen(scalablePen) + { + } + + inline QRectF scaledBoundingRect(qreal sx, qreal sy, bool scalePens) const + { + if (sx == 1.0 && sy == 1.0) + return m_boundingRect; + + QTransform transform; + transform.scale(sx, sy); + + QRectF rect; + if (scalePens && m_scalablePen) { - // QVector needs a default constructor + rect = transform.mapRect(m_boundingRect); + } + else + { + rect = transform.mapRect(m_pointRect); + + const qreal l = qAbs(m_pointRect.left() - m_boundingRect.left()); + const qreal r = qAbs(m_pointRect.right() - m_boundingRect.right()); + const qreal t = qAbs(m_pointRect.top() - m_boundingRect.top()); + const qreal b = qAbs(m_pointRect.bottom() - m_boundingRect.bottom()); + + rect.adjust(-l, -t, r, b); } - PathInfo( const QRectF& pointRect, - const QRectF& boundingRect, bool scalablePen ) - : m_pointRect( pointRect ) - , m_boundingRect( boundingRect ) - , m_scalablePen( scalablePen ) + return rect; + } + + inline double scaleFactorX(const QRectF &pathRect, const QRectF &targetRect, + bool scalePens) const + { + if (pathRect.width() <= 0.0) + return 0.0; + + const QPointF p0 = m_pointRect.center(); + + const qreal l = qAbs(pathRect.left() - p0.x()); + const qreal r = qAbs(pathRect.right() - p0.x()); + + const double w + = 2.0 * qwtMinF(l, r) * targetRect.width() / pathRect.width(); + + double sx; + if (scalePens && m_scalablePen) { + sx = w / m_boundingRect.width(); + } + else + { + const qreal pw + = qwtMaxF(qAbs(m_boundingRect.left() - m_pointRect.left()), + qAbs(m_boundingRect.right() - m_pointRect.right())); + + sx = (w - 2 * pw) / m_pointRect.width(); } - inline QRectF scaledBoundingRect( qreal sx, qreal sy, bool scalePens ) const + return sx; + } + + inline double scaleFactorY(const QRectF &pathRect, const QRectF &targetRect, + bool scalePens) const + { + if (pathRect.height() <= 0.0) + return 0.0; + + const QPointF p0 = m_pointRect.center(); + + const qreal t = qAbs(pathRect.top() - p0.y()); + const qreal b = qAbs(pathRect.bottom() - p0.y()); + + const qreal h + = 2.0 * qwtMinF(t, b) * targetRect.height() / pathRect.height(); + + double sy; + if (scalePens && m_scalablePen) { - if ( sx == 1.0 && sy == 1.0 ) - return m_boundingRect; + sy = h / m_boundingRect.height(); + } + else + { + const qreal pw + = qwtMaxF(qAbs(m_boundingRect.top() - m_pointRect.top()), + qAbs(m_boundingRect.bottom() - m_pointRect.bottom())); - QTransform transform; - transform.scale( sx, sy ); - - QRectF rect; - if ( scalePens && m_scalablePen ) - { - rect = transform.mapRect( m_boundingRect ); - } - else - { - rect = transform.mapRect( m_pointRect ); - - const qreal l = qAbs( m_pointRect.left() - m_boundingRect.left() ); - const qreal r = qAbs( m_pointRect.right() - m_boundingRect.right() ); - const qreal t = qAbs( m_pointRect.top() - m_boundingRect.top() ); - const qreal b = qAbs( m_pointRect.bottom() - m_boundingRect.bottom() ); - - rect.adjust( -l, -t, r, b ); - } - - return rect; + sy = (h - 2 * pw) / m_pointRect.height(); } - inline double scaleFactorX( const QRectF& pathRect, - const QRectF& targetRect, bool scalePens ) const - { - if ( pathRect.width() <= 0.0 ) - return 0.0; + return sy; + } - const QPointF p0 = m_pointRect.center(); - - const qreal l = qAbs( pathRect.left() - p0.x() ); - const qreal r = qAbs( pathRect.right() - p0.x() ); - - const double w = 2.0 * qwtMinF( l, r ) - * targetRect.width() / pathRect.width(); - - double sx; - if ( scalePens && m_scalablePen ) - { - sx = w / m_boundingRect.width(); - } - else - { - const qreal pw = qwtMaxF( - qAbs( m_boundingRect.left() - m_pointRect.left() ), - qAbs( m_boundingRect.right() - m_pointRect.right() ) ); - - sx = ( w - 2 * pw ) / m_pointRect.width(); - } - - return sx; - } - - inline double scaleFactorY( const QRectF& pathRect, - const QRectF& targetRect, bool scalePens ) const - { - if ( pathRect.height() <= 0.0 ) - return 0.0; - - const QPointF p0 = m_pointRect.center(); - - const qreal t = qAbs( pathRect.top() - p0.y() ); - const qreal b = qAbs( pathRect.bottom() - p0.y() ); - - const qreal h = 2.0 * qwtMinF( t, b ) - * targetRect.height() / pathRect.height(); - - double sy; - if ( scalePens && m_scalablePen ) - { - sy = h / m_boundingRect.height(); - } - else - { - const qreal pw = qwtMaxF( - qAbs( m_boundingRect.top() - m_pointRect.top() ), - qAbs( m_boundingRect.bottom() - m_pointRect.bottom() ) ); - - sy = ( h - 2 * pw ) / m_pointRect.height(); - } - - return sy; - } - - private: - QRectF m_pointRect; - QRectF m_boundingRect; - bool m_scalablePen; +private: + QRectF m_pointRect; + QRectF m_boundingRect; + bool m_scalablePen; }; class QwtGraphic::PrivateData { - public: - PrivateData() - : boundingRect( 0.0, 0.0, -1.0, -1.0 ) - , pointRect( 0.0, 0.0, -1.0, -1.0 ) - { - } +public: + PrivateData() + : boundingRect(0.0, 0.0, -1.0, -1.0) + , pointRect(0.0, 0.0, -1.0, -1.0) + { + } - QSizeF defaultSize; - QVector< QwtPainterCommand > commands; - QVector< QwtGraphic::PathInfo > pathInfos; + QSizeF defaultSize; + QVector commands; + QVector pathInfos; - QRectF boundingRect; - QRectF pointRect; + QRectF boundingRect; + QRectF pointRect; - QwtGraphic::CommandTypes commandTypes; - QwtGraphic::RenderHints renderHints; + QwtGraphic::CommandTypes commandTypes; + QwtGraphic::RenderHints renderHints; }; /*! @@ -354,8 +349,8 @@ class QwtGraphic::PrivateData */ QwtGraphic::QwtGraphic() { - setMode( QwtNullPaintDevice::PathMode ); - m_data = new PrivateData; + setMode(QwtNullPaintDevice::PathMode); + m_data = new PrivateData; } /*! @@ -364,16 +359,16 @@ QwtGraphic::QwtGraphic() \param other Source \sa operator=() */ -QwtGraphic::QwtGraphic( const QwtGraphic& other ) +QwtGraphic::QwtGraphic(const QwtGraphic &other) { - setMode( other.mode() ); - m_data = new PrivateData( *other.m_data ); + setMode(other.mode()); + m_data = new PrivateData(*other.m_data); } //! Destructor QwtGraphic::~QwtGraphic() { - delete m_data; + delete m_data; } /*! @@ -382,12 +377,12 @@ QwtGraphic::~QwtGraphic() \param other Source \return A reference of this object */ -QwtGraphic& QwtGraphic::operator=( const QwtGraphic& other ) +QwtGraphic &QwtGraphic::operator=(const QwtGraphic &other) { - setMode( other.mode() ); - *m_data = *other.m_data; + setMode(other.mode()); + *m_data = *other.m_data; - return *this; + return *this; } /*! @@ -396,14 +391,14 @@ QwtGraphic& QwtGraphic::operator=( const QwtGraphic& other ) */ void QwtGraphic::reset() { - m_data->commands.clear(); - m_data->pathInfos.clear(); + m_data->commands.clear(); + m_data->pathInfos.clear(); - m_data->commandTypes = CommandTypes(); + m_data->commandTypes = CommandTypes(); - m_data->boundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 ); - m_data->pointRect = QRectF( 0.0, 0.0, -1.0, -1.0 ); - m_data->defaultSize = QSizeF(); + m_data->boundingRect = QRectF(0.0, 0.0, -1.0, -1.0); + m_data->pointRect = QRectF(0.0, 0.0, -1.0, -1.0); + m_data->defaultSize = QSizeF(); } /*! @@ -412,7 +407,7 @@ void QwtGraphic::reset() */ bool QwtGraphic::isNull() const { - return m_data->commands.isEmpty(); + return m_data->commands.isEmpty(); } /*! @@ -421,7 +416,7 @@ bool QwtGraphic::isNull() const */ bool QwtGraphic::isEmpty() const { - return m_data->boundingRect.isEmpty(); + return m_data->boundingRect.isEmpty(); } /*! @@ -429,7 +424,7 @@ bool QwtGraphic::isEmpty() const */ QwtGraphic::CommandTypes QwtGraphic::commandTypes() const { - return m_data->commandTypes; + return m_data->commandTypes; } /*! @@ -440,12 +435,12 @@ QwtGraphic::CommandTypes QwtGraphic::commandTypes() const \sa testRenderHint(), RenderHint */ -void QwtGraphic::setRenderHint( RenderHint hint, bool on ) +void QwtGraphic::setRenderHint(RenderHint hint, bool on) { - if ( on ) - m_data->renderHints |= hint; - else - m_data->renderHints &= ~hint; + if (on) + m_data->renderHints |= hint; + else + m_data->renderHints &= ~hint; } /*! @@ -455,15 +450,15 @@ void QwtGraphic::setRenderHint( RenderHint hint, bool on ) \return true/false \sa setRenderHint(), RenderHint */ -bool QwtGraphic::testRenderHint( RenderHint hint ) const +bool QwtGraphic::testRenderHint(RenderHint hint) const { - return m_data->renderHints.testFlag( hint ); + return m_data->renderHints.testFlag(hint); } //! \return Render hints QwtGraphic::RenderHints QwtGraphic::renderHints() const { - return m_data->renderHints; + return m_data->renderHints; } /*! @@ -476,10 +471,10 @@ QwtGraphic::RenderHints QwtGraphic::renderHints() const */ QRectF QwtGraphic::boundingRect() const { - if ( m_data->boundingRect.width() < 0 ) - return QRectF(); + if (m_data->boundingRect.width() < 0) + return QRectF(); - return m_data->boundingRect; + return m_data->boundingRect; } /*! @@ -492,10 +487,10 @@ QRectF QwtGraphic::boundingRect() const */ QRectF QwtGraphic::controlPointRect() const { - if ( m_data->pointRect.width() < 0 ) - return QRectF(); + if (m_data->pointRect.width() < 0) + return QRectF(); - return m_data->pointRect; + return m_data->pointRect; } /*! @@ -511,29 +506,29 @@ QRectF QwtGraphic::controlPointRect() const \return Scaled bounding rectangle \sa boundingRect(), controlPointRect() */ -QRectF QwtGraphic::scaledBoundingRect( qreal sx, qreal sy ) const +QRectF QwtGraphic::scaledBoundingRect(qreal sx, qreal sy) const { - if ( sx == 1.0 && sy == 1.0 ) - return m_data->boundingRect; + if (sx == 1.0 && sy == 1.0) + return m_data->boundingRect; - const bool scalePens = !( m_data->renderHints & RenderPensUnscaled ); + const bool scalePens = !(m_data->renderHints & RenderPensUnscaled); - QTransform transform; - transform.scale( sx, sy ); + QTransform transform; + transform.scale(sx, sy); - QRectF rect = transform.mapRect( m_data->pointRect ); + QRectF rect = transform.mapRect(m_data->pointRect); - for ( int i = 0; i < m_data->pathInfos.size(); i++ ) - rect |= m_data->pathInfos[i].scaledBoundingRect( sx, sy, scalePens ); + for (int i = 0; i < m_data->pathInfos.size(); i++) + rect |= m_data->pathInfos[i].scaledBoundingRect(sx, sy, scalePens); - return rect; + return rect; } //! \return Ceiled defaultSize() QSize QwtGraphic::sizeMetrics() const { - const QSizeF sz = defaultSize(); - return QSize( qwtCeil( sz.width() ), qwtCeil( sz.height() ) ); + const QSizeF sz = defaultSize(); + return QSize(qwtCeil(sz.width()), qwtCeil(sz.height())); } /*! @@ -550,12 +545,12 @@ QSize QwtGraphic::sizeMetrics() const \sa defaultSize(), boundingRect() */ -void QwtGraphic::setDefaultSize( const QSizeF& size ) +void QwtGraphic::setDefaultSize(const QSizeF &size) { - const double w = qwtMaxF( 0.0, size.width() ); - const double h = qwtMaxF( 0.0, size.height() ); + const double w = qwtMaxF(0.0, size.width()); + const double h = qwtMaxF(0.0, size.height()); - m_data->defaultSize = QSizeF( w, h ); + m_data->defaultSize = QSizeF(w, h); } /*! @@ -573,10 +568,10 @@ void QwtGraphic::setDefaultSize( const QSizeF& size ) */ QSizeF QwtGraphic::defaultSize() const { - if ( !m_data->defaultSize.isEmpty() ) - return m_data->defaultSize; + if (!m_data->defaultSize.isEmpty()) + return m_data->defaultSize; - return boundingRect().size(); + return boundingRect().size(); } /*! @@ -589,13 +584,13 @@ QSizeF QwtGraphic::defaultSize() const \return Calculated height \sa defaultSize() */ -qreal QwtGraphic::heightForWidth( qreal width ) const +qreal QwtGraphic::heightForWidth(qreal width) const { - const QSizeF sz = defaultSize(); - if ( sz.isEmpty() ) - return 0.0; + const QSizeF sz = defaultSize(); + if (sz.isEmpty()) + return 0.0; - return sz.height() * width / sz.width(); + return sz.height() * width / sz.width(); } /*! @@ -608,43 +603,44 @@ qreal QwtGraphic::heightForWidth( qreal width ) const \return Calculated width \sa defaultSize() */ -qreal QwtGraphic::widthForHeight( qreal height ) const +qreal QwtGraphic::widthForHeight(qreal height) const { - const QSizeF sz = defaultSize(); - if ( sz.isEmpty() ) - return 0.0; + const QSizeF sz = defaultSize(); + if (sz.isEmpty()) + return 0.0; - return sz.width() * height / sz.height(); + return sz.width() * height / sz.height(); } /*! \brief Replay all recorded painter commands \param painter Qt painter */ -void QwtGraphic::render( QPainter* painter ) const +void QwtGraphic::render(QPainter *painter) const { - renderGraphic( painter, NULL ); + renderGraphic(painter, NULL); } -void QwtGraphic::renderGraphic( QPainter* painter, QTransform* initialTransform ) const +void QwtGraphic::renderGraphic(QPainter *painter, + QTransform *initialTransform) const { - if ( isNull() ) - return; + if (isNull()) + return; - const int numCommands = m_data->commands.size(); - const QwtPainterCommand* commands = m_data->commands.constData(); + const int numCommands = m_data->commands.size(); + const QwtPainterCommand *commands = m_data->commands.constData(); - const QTransform transform = painter->transform(); + const QTransform transform = painter->transform(); - painter->save(); + painter->save(); - for ( int i = 0; i < numCommands; i++ ) - { - qwtExecCommand( painter, commands[i], - m_data->renderHints, transform, initialTransform ); - } + for (int i = 0; i < numCommands; i++) + { + qwtExecCommand(painter, commands[i], m_data->renderHints, transform, + initialTransform); + } - painter->restore(); + painter->restore(); } /*! @@ -657,11 +653,11 @@ void QwtGraphic::renderGraphic( QPainter* painter, QTransform* initialTransform \param size Size for the scaled graphic \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode */ -void QwtGraphic::render( QPainter* painter, const QSizeF& size, - Qt::AspectRatioMode aspectRatioMode ) const +void QwtGraphic::render(QPainter *painter, const QSizeF &size, + Qt::AspectRatioMode aspectRatioMode) const { - const QRectF r( 0.0, 0.0, size.width(), size.height() ); - render( painter, r, aspectRatioMode ); + const QRectF r(0.0, 0.0, size.width(), size.height()); + render(painter, r, aspectRatioMode); } /*! @@ -673,80 +669,78 @@ void QwtGraphic::render( QPainter* painter, const QSizeF& size, \param rect Rectangle for the scaled graphic \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode */ -void QwtGraphic::render( QPainter* painter, const QRectF& rect, - Qt::AspectRatioMode aspectRatioMode ) const +void QwtGraphic::render(QPainter *painter, const QRectF &rect, + Qt::AspectRatioMode aspectRatioMode) const { - if ( isEmpty() || rect.isEmpty() ) - return; + if (isEmpty() || rect.isEmpty()) + return; - double sx = 1.0; - double sy = 1.0; + double sx = 1.0; + double sy = 1.0; - if ( m_data->pointRect.width() > 0.0 ) - sx = rect.width() / m_data->pointRect.width(); + if (m_data->pointRect.width() > 0.0) + sx = rect.width() / m_data->pointRect.width(); - if ( m_data->pointRect.height() > 0.0 ) - sy = rect.height() / m_data->pointRect.height(); + if (m_data->pointRect.height() > 0.0) + sy = rect.height() / m_data->pointRect.height(); - const bool scalePens = !m_data->renderHints.testFlag( RenderPensUnscaled ); + const bool scalePens = !m_data->renderHints.testFlag(RenderPensUnscaled); - for ( int i = 0; i < m_data->pathInfos.size(); i++ ) - { - const PathInfo& info = m_data->pathInfos[i]; + for (int i = 0; i < m_data->pathInfos.size(); i++) + { + const PathInfo &info = m_data->pathInfos[i]; - const double ssx = info.scaleFactorX( - m_data->pointRect, rect, scalePens ); + const double ssx = info.scaleFactorX(m_data->pointRect, rect, scalePens); - if ( ssx > 0.0 ) - sx = qwtMinF( sx, ssx ); + if (ssx > 0.0) + sx = qwtMinF(sx, ssx); - const double ssy = info.scaleFactorY( - m_data->pointRect, rect, scalePens ); + const double ssy = info.scaleFactorY(m_data->pointRect, rect, scalePens); - if ( ssy > 0.0 ) - sy = qwtMinF( sy, ssy ); - } + if (ssy > 0.0) + sy = qwtMinF(sy, ssy); + } - if ( aspectRatioMode == Qt::KeepAspectRatio ) - { - const qreal s = qwtMinF( sx, sy ); - sx = s; - sy = s; - } - else if ( aspectRatioMode == Qt::KeepAspectRatioByExpanding ) - { - const qreal s = qwtMaxF( sx, sy ); - sx = s; - sy = s; - } + if (aspectRatioMode == Qt::KeepAspectRatio) + { + const qreal s = qwtMinF(sx, sy); + sx = s; + sy = s; + } + else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) + { + const qreal s = qwtMaxF(sx, sy); + sx = s; + sy = s; + } - QTransform tr; - tr.translate( rect.center().x() - 0.5 * sx * m_data->pointRect.width(), - rect.center().y() - 0.5 * sy * m_data->pointRect.height() ); - tr.scale( sx, sy ); - tr.translate( -m_data->pointRect.x(), -m_data->pointRect.y() ); + QTransform tr; + tr.translate(rect.center().x() - 0.5 * sx * m_data->pointRect.width(), + rect.center().y() - 0.5 * sy * m_data->pointRect.height()); + tr.scale(sx, sy); + tr.translate(-m_data->pointRect.x(), -m_data->pointRect.y()); - const QTransform transform = painter->transform(); + const QTransform transform = painter->transform(); - painter->setTransform( tr, true ); + painter->setTransform(tr, true); - if ( !scalePens && transform.isScaling() ) - { - // we don't want to scale pens according to sx/sy, - // but we want to apply the scaling from the - // painter transformation later + if (!scalePens && transform.isScaling()) + { + // we don't want to scale pens according to sx/sy, + // but we want to apply the scaling from the + // painter transformation later - QTransform initialTransform; - initialTransform.scale( transform.m11(), transform.m22() ); + QTransform initialTransform; + initialTransform.scale(transform.m11(), transform.m22()); - renderGraphic( painter, &initialTransform ); - } - else - { - renderGraphic( painter, NULL ); - } + renderGraphic(painter, &initialTransform); + } + else + { + renderGraphic(painter, NULL); + } - painter->setTransform( transform ); + painter->setTransform(transform); } /*! @@ -759,38 +753,38 @@ void QwtGraphic::render( QPainter* painter, const QRectF& rect, \param pos Reference point, where to render \param alignment Flags how to align the target rectangle to pos. */ -void QwtGraphic::render( QPainter* painter, - const QPointF& pos, Qt::Alignment alignment ) const +void QwtGraphic::render(QPainter *painter, const QPointF &pos, + Qt::Alignment alignment) const { - QRectF r( pos, defaultSize() ); + QRectF r(pos, defaultSize()); - if ( alignment & Qt::AlignLeft ) - { - r.moveLeft( pos.x() ); - } - else if ( alignment & Qt::AlignHCenter ) - { - r.moveCenter( QPointF( pos.x(), r.center().y() ) ); - } - else if ( alignment & Qt::AlignRight ) - { - r.moveRight( pos.x() ); - } + if (alignment & Qt::AlignLeft) + { + r.moveLeft(pos.x()); + } + else if (alignment & Qt::AlignHCenter) + { + r.moveCenter(QPointF(pos.x(), r.center().y())); + } + else if (alignment & Qt::AlignRight) + { + r.moveRight(pos.x()); + } - if ( alignment & Qt::AlignTop ) - { - r.moveTop( pos.y() ); - } - else if ( alignment & Qt::AlignVCenter ) - { - r.moveCenter( QPointF( r.center().x(), pos.y() ) ); - } - else if ( alignment & Qt::AlignBottom ) - { - r.moveBottom( pos.y() ); - } + if (alignment & Qt::AlignTop) + { + r.moveTop(pos.y()); + } + else if (alignment & Qt::AlignVCenter) + { + r.moveCenter(QPointF(r.center().x(), pos.y())); + } + else if (alignment & Qt::AlignBottom) + { + r.moveBottom(pos.y()); + } - render( painter, r ); + render(painter, r); } /*! @@ -809,36 +803,36 @@ void QwtGraphic::render( QPainter* painter, \return The graphic as pixmap in default size \sa defaultSize(), toImage(), render() */ -QPixmap QwtGraphic::toPixmap( qreal devicePixelRatio ) const +QPixmap QwtGraphic::toPixmap(qreal devicePixelRatio) const { - if ( isNull() ) - return QPixmap(); + if (isNull()) + return QPixmap(); - const QSizeF sz = defaultSize(); + const QSizeF sz = defaultSize(); - const int w = qwtCeil( sz.width() ); - const int h = qwtCeil( sz.height() ); + const int w = qwtCeil(sz.width()); + const int h = qwtCeil(sz.height()); - QPixmap pixmap( w, h ); + QPixmap pixmap(w, h); #if QT_VERSION >= 0x050000 - if ( devicePixelRatio <= 0.0 ) - devicePixelRatio = qwtDevicePixelRatio(); + if (devicePixelRatio <= 0.0) + devicePixelRatio = qwtDevicePixelRatio(); - pixmap.setDevicePixelRatio( devicePixelRatio ); + pixmap.setDevicePixelRatio(devicePixelRatio); #else - Q_UNUSED( devicePixelRatio ) + Q_UNUSED(devicePixelRatio) #endif - pixmap.fill( Qt::transparent ); + pixmap.fill(Qt::transparent); - const QRectF r( 0.0, 0.0, sz.width(), sz.height() ); + const QRectF r(0.0, 0.0, sz.width(), sz.height()); - QPainter painter( &pixmap ); - render( &painter, r, Qt::KeepAspectRatio ); - painter.end(); + QPainter painter(&pixmap); + render(&painter, r, Qt::KeepAspectRatio); + painter.end(); - return pixmap; + return pixmap; } /*! @@ -856,28 +850,29 @@ QPixmap QwtGraphic::toPixmap( qreal devicePixelRatio ) const \return The graphic as pixmap \sa toImage(), render() */ -QPixmap QwtGraphic::toPixmap( const QSize& size, - Qt::AspectRatioMode aspectRatioMode, qreal devicePixelRatio ) const +QPixmap QwtGraphic::toPixmap(const QSize &size, + Qt::AspectRatioMode aspectRatioMode, + qreal devicePixelRatio) const { - QPixmap pixmap( size ); + QPixmap pixmap(size); #if QT_VERSION >= 0x050000 - if ( devicePixelRatio <= 0.0 ) - devicePixelRatio = qwtDevicePixelRatio(); + if (devicePixelRatio <= 0.0) + devicePixelRatio = qwtDevicePixelRatio(); - pixmap.setDevicePixelRatio( devicePixelRatio ); + pixmap.setDevicePixelRatio(devicePixelRatio); #else - Q_UNUSED( devicePixelRatio ) + Q_UNUSED(devicePixelRatio) #endif - pixmap.fill( Qt::transparent ); + pixmap.fill(Qt::transparent); - const QRect r( 0, 0, size.width(), size.height() ); + const QRect r(0, 0, size.width(), size.height()); - QPainter painter( &pixmap ); - render( &painter, r, aspectRatioMode ); - painter.end(); + QPainter painter(&pixmap); + render(&painter, r, aspectRatioMode); + painter.end(); - return pixmap; + return pixmap; } /*! @@ -897,29 +892,30 @@ QPixmap QwtGraphic::toPixmap( const QSize& size, \return The graphic as image \sa toPixmap(), render() */ -QImage QwtGraphic::toImage( const QSize& size, - Qt::AspectRatioMode aspectRatioMode, qreal devicePixelRatio ) const +QImage QwtGraphic::toImage(const QSize &size, + Qt::AspectRatioMode aspectRatioMode, + qreal devicePixelRatio) const { #if QT_VERSION >= 0x050000 - if ( devicePixelRatio <= 0.0 ) - devicePixelRatio = qwtDevicePixelRatio(); + if (devicePixelRatio <= 0.0) + devicePixelRatio = qwtDevicePixelRatio(); - QImage image( size* devicePixelRatio, QImage::Format_ARGB32_Premultiplied ); - image.setDevicePixelRatio( devicePixelRatio ); + QImage image(size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); + image.setDevicePixelRatio(devicePixelRatio); #else - Q_UNUSED( devicePixelRatio ) - QImage image( size, QImage::Format_ARGB32_Premultiplied ); + Q_UNUSED(devicePixelRatio) + QImage image(size, QImage::Format_ARGB32_Premultiplied); #endif - image.fill( 0 ); + image.fill(0); - const QRect r( 0, 0, size.width(), size.height() ); + const QRect r(0, 0, size.width(), size.height()); - QPainter painter( &image ); - render( &painter, r, aspectRatioMode ); - painter.end(); + QPainter painter(&image); + render(&painter, r, aspectRatioMode); + painter.end(); - return image; + return image; } /*! @@ -940,39 +936,39 @@ QImage QwtGraphic::toImage( const QSize& size, \return The graphic as image in default size \sa defaultSize(), toPixmap(), render() */ -QImage QwtGraphic::toImage( qreal devicePixelRatio ) const +QImage QwtGraphic::toImage(qreal devicePixelRatio) const { - if ( isNull() ) - return QImage(); + if (isNull()) + return QImage(); - const QSizeF sz = defaultSize(); + const QSizeF sz = defaultSize(); - int w = qwtCeil( sz.width() ); - int h = qwtCeil( sz.height() ); + int w = qwtCeil(sz.width()); + int h = qwtCeil(sz.height()); #if QT_VERSION >= 0x050000 - if ( devicePixelRatio <= 0.0 ) - devicePixelRatio = qwtDevicePixelRatio(); + if (devicePixelRatio <= 0.0) + devicePixelRatio = qwtDevicePixelRatio(); - w *= devicePixelRatio; - h *= devicePixelRatio; + w *= devicePixelRatio; + h *= devicePixelRatio; - QImage image( w, h, QImage::Format_ARGB32 ); - image.setDevicePixelRatio( devicePixelRatio ); + QImage image(w, h, QImage::Format_ARGB32); + image.setDevicePixelRatio(devicePixelRatio); #else - Q_UNUSED( devicePixelRatio ) - QImage image( w, h, QImage::Format_ARGB32 ); + Q_UNUSED(devicePixelRatio) + QImage image(w, h, QImage::Format_ARGB32); #endif - image.fill( 0 ); + image.fill(0); - const QRect r( 0, 0, sz.width(), sz.height() ); + const QRect r(0, 0, sz.width(), sz.height()); - QPainter painter( &image ); - render( &painter, r, Qt::KeepAspectRatio ); - painter.end(); + QPainter painter(&image); + render(&painter, r, Qt::KeepAspectRatio); + painter.end(); - return image; + return image; } /*! @@ -981,34 +977,34 @@ QImage QwtGraphic::toImage( qreal devicePixelRatio ) const \param path Painter path \sa QPaintEngine::drawPath() */ -void QwtGraphic::drawPath( const QPainterPath& path ) +void QwtGraphic::drawPath(const QPainterPath &path) { - const QPainter* painter = paintEngine()->painter(); - if ( painter == NULL ) - return; + const QPainter *painter = paintEngine()->painter(); + if (painter == NULL) + return; - m_data->commands += QwtPainterCommand( path ); - m_data->commandTypes |= QwtGraphic::VectorData; + m_data->commands += QwtPainterCommand(path); + m_data->commandTypes |= QwtGraphic::VectorData; - if ( !path.isEmpty() ) + if (!path.isEmpty()) + { + const QPainterPath scaledPath = painter->transform().map(path); + + QRectF pointRect = scaledPath.boundingRect(); + QRectF boundingRect = pointRect; + + if (painter->pen().style() != Qt::NoPen + && painter->pen().brush().style() != Qt::NoBrush) { - const QPainterPath scaledPath = painter->transform().map( path ); - - QRectF pointRect = scaledPath.boundingRect(); - QRectF boundingRect = pointRect; - - if ( painter->pen().style() != Qt::NoPen - && painter->pen().brush().style() != Qt::NoBrush ) - { - boundingRect = qwtStrokedPathRect( painter, path ); - } - - updateControlPointRect( pointRect ); - updateBoundingRect( boundingRect ); - - m_data->pathInfos += PathInfo( pointRect, - boundingRect, qwtHasScalablePen( painter ) ); + boundingRect = qwtStrokedPathRect(painter, path); } + + updateControlPointRect(pointRect); + updateBoundingRect(boundingRect); + + m_data->pathInfos + += PathInfo(pointRect, boundingRect, qwtHasScalablePen(painter)); + } } /*! @@ -1020,19 +1016,19 @@ void QwtGraphic::drawPath( const QPainterPath& path ) \sa QPaintEngine::drawPixmap() */ -void QwtGraphic::drawPixmap( const QRectF& rect, - const QPixmap& pixmap, const QRectF& subRect ) +void QwtGraphic::drawPixmap(const QRectF &rect, const QPixmap &pixmap, + const QRectF &subRect) { - const QPainter* painter = paintEngine()->painter(); - if ( painter == NULL ) - return; + const QPainter *painter = paintEngine()->painter(); + if (painter == NULL) + return; - m_data->commands += QwtPainterCommand( rect, pixmap, subRect ); - m_data->commandTypes |= QwtGraphic::RasterData; + m_data->commands += QwtPainterCommand(rect, pixmap, subRect); + m_data->commandTypes |= QwtGraphic::RasterData; - const QRectF r = painter->transform().mapRect( rect ); - updateControlPointRect( r ); - updateBoundingRect( r ); + const QRectF r = painter->transform().mapRect(rect); + updateControlPointRect(r); + updateBoundingRect(r); } /*! @@ -1045,20 +1041,21 @@ void QwtGraphic::drawPixmap( const QRectF& rect, \sa QPaintEngine::drawImage() */ -void QwtGraphic::drawImage( const QRectF& rect, const QImage& image, - const QRectF& subRect, Qt::ImageConversionFlags flags ) +void QwtGraphic::drawImage(const QRectF &rect, const QImage &image, + const QRectF &subRect, + Qt::ImageConversionFlags flags) { - const QPainter* painter = paintEngine()->painter(); - if ( painter == NULL ) - return; + const QPainter *painter = paintEngine()->painter(); + if (painter == NULL) + return; - m_data->commands += QwtPainterCommand( rect, image, subRect, flags ); - m_data->commandTypes |= QwtGraphic::RasterData; + m_data->commands += QwtPainterCommand(rect, image, subRect, flags); + m_data->commandTypes |= QwtGraphic::RasterData; - const QRectF r = painter->transform().mapRect( rect ); + const QRectF r = painter->transform().mapRect(rect); - updateControlPointRect( r ); - updateBoundingRect( r ); + updateControlPointRect(r); + updateBoundingRect(r); } /*! @@ -1067,59 +1064,59 @@ void QwtGraphic::drawImage( const QRectF& rect, const QImage& image, \param state State to be stored \sa QPaintEngine::updateState() */ -void QwtGraphic::updateState( const QPaintEngineState& state ) +void QwtGraphic::updateState(const QPaintEngineState &state) { - m_data->commands += QwtPainterCommand( state ); + m_data->commands += QwtPainterCommand(state); - if ( state.state() & QPaintEngine::DirtyTransform ) + if (state.state() & QPaintEngine::DirtyTransform) + { + if (!(m_data->commandTypes & QwtGraphic::Transformation)) { - if ( !( m_data->commandTypes & QwtGraphic::Transformation ) ) - { - /* - QTransform::isScaling() returns true for all type - of transformations beside simple translations - even if it is f.e a rotation - */ - if ( state.transform().isScaling() ) - m_data->commandTypes |= QwtGraphic::Transformation; - } + /* + QTransform::isScaling() returns true for all type + of transformations beside simple translations + even if it is f.e a rotation + */ + if (state.transform().isScaling()) + m_data->commandTypes |= QwtGraphic::Transformation; } + } } -void QwtGraphic::updateBoundingRect( const QRectF& rect ) +void QwtGraphic::updateBoundingRect(const QRectF &rect) { - QRectF br = rect; + QRectF br = rect; - const QPainter* painter = paintEngine()->painter(); - if ( painter && painter->hasClipping() ) - { - QRectF cr = painter->clipRegion().boundingRect(); - cr = painter->transform().mapRect( cr ); + const QPainter *painter = paintEngine()->painter(); + if (painter && painter->hasClipping()) + { + QRectF cr = painter->clipRegion().boundingRect(); + cr = painter->transform().mapRect(cr); - br &= cr; - } + br &= cr; + } - if ( m_data->boundingRect.width() < 0 ) - m_data->boundingRect = br; - else - m_data->boundingRect |= br; + if (m_data->boundingRect.width() < 0) + m_data->boundingRect = br; + else + m_data->boundingRect |= br; } -void QwtGraphic::updateControlPointRect( const QRectF& rect ) +void QwtGraphic::updateControlPointRect(const QRectF &rect) { - if ( m_data->pointRect.width() < 0.0 ) - m_data->pointRect = rect; - else - m_data->pointRect |= rect; + if (m_data->pointRect.width() < 0.0) + m_data->pointRect = rect; + else + m_data->pointRect |= rect; } /*! \return List of recorded paint commands \sa setCommands() */ -const QVector< QwtPainterCommand >& QwtGraphic::commands() const +const QVector &QwtGraphic::commands() const { - return m_data->commands; + return m_data->commands; } /*! @@ -1128,25 +1125,25 @@ const QVector< QwtPainterCommand >& QwtGraphic::commands() const \param commands Paint commands \sa commands() */ -void QwtGraphic::setCommands( const QVector< QwtPainterCommand >& commands ) +void QwtGraphic::setCommands(const QVector &commands) { - reset(); + reset(); - const int numCommands = commands.size(); - if ( numCommands <= 0 ) - return; + const int numCommands = commands.size(); + if (numCommands <= 0) + return; - // to calculate a proper bounding rectangle we don't simply copy - // the commands. + // to calculate a proper bounding rectangle we don't simply copy + // the commands. - const QwtPainterCommand* cmds = commands.constData(); + const QwtPainterCommand *cmds = commands.constData(); - const QTransform noTransform; - const RenderHints noRenderHints; + const QTransform noTransform; + const RenderHints noRenderHints; - QPainter painter( this ); - for ( int i = 0; i < numCommands; i++ ) - qwtExecCommand( &painter, cmds[i], noRenderHints, noTransform, NULL ); + QPainter painter(this); + for (int i = 0; i < numCommands; i++) + qwtExecCommand(&painter, cmds[i], noRenderHints, noTransform, NULL); - painter.end(); + painter.end(); } diff --git a/libs/qwt/src/qwt_graphic.h b/libs/qwt/src/qwt_graphic.h index 024cc679..91caf9a9 100644 --- a/libs/qwt/src/qwt_graphic.h +++ b/libs/qwt/src/qwt_graphic.h @@ -66,139 +66,137 @@ class QImage; what is needed for rendering the outline with an unscaled pen. Because the offset for drawing the outline depends on the shape - of the painter path ( the peak of a triangle is different than the flat side ) - scaling with a fixed aspect ratio always needs to be calculated from the + of the painter path ( the peak of a triangle is different than the flat side + ) scaling with a fixed aspect ratio always needs to be calculated from the control point rectangle. \sa QwtPainterCommand */ class QWT_EXPORT QwtGraphic : public QwtNullPaintDevice { - public: +public: + /*! + Hint how to render a graphic + \sa setRenderHint(), testRenderHint() + */ + enum RenderHint + { /*! - Hint how to render a graphic - \sa setRenderHint(), testRenderHint() + When rendering a QwtGraphic a specific scaling between + the controlPointRect() and the coordinates of the target rectangle + is set up internally in render(). + + When RenderPensUnscaled is set this specific scaling is applied + for the control points only, but not for the pens. + All other painter transformations ( set up by application code ) + are supposed to work like usual. + + \sa render(); */ - enum RenderHint - { - /*! - When rendering a QwtGraphic a specific scaling between - the controlPointRect() and the coordinates of the target rectangle - is set up internally in render(). + RenderPensUnscaled = 0x1 + }; - When RenderPensUnscaled is set this specific scaling is applied - for the control points only, but not for the pens. - All other painter transformations ( set up by application code ) - are supposed to work like usual. + Q_DECLARE_FLAGS(RenderHints, RenderHint) - \sa render(); - */ - RenderPensUnscaled = 0x1 - }; + /*! + Indicator if the graphic contains a specific type of painter command + \sa CommandTypes, commandTypes(); + */ + enum CommandType + { + //! The graphic contains scalable vector data + VectorData = 1 << 0, - Q_DECLARE_FLAGS( RenderHints, RenderHint ) + //! The graphic contains raster data ( QPixmap or QImage ) + RasterData = 1 << 1, - /*! - Indicator if the graphic contains a specific type of painter command - \sa CommandTypes, commandTypes(); - */ - enum CommandType - { - //! The graphic contains scalable vector data - VectorData = 1 << 0, + //! The graphic contains transformations beyond simple translations + Transformation = 1 << 2 + }; - //! The graphic contains raster data ( QPixmap or QImage ) - RasterData = 1 << 1, + Q_DECLARE_FLAGS(CommandTypes, CommandType) - //! The graphic contains transformations beyond simple translations - Transformation = 1 << 2 - }; + QwtGraphic(); + QwtGraphic(const QwtGraphic &); - Q_DECLARE_FLAGS( CommandTypes, CommandType ) + virtual ~QwtGraphic(); - QwtGraphic(); - QwtGraphic( const QwtGraphic& ); + QwtGraphic &operator=(const QwtGraphic &); - virtual ~QwtGraphic(); + void reset(); - QwtGraphic& operator=( const QwtGraphic& ); + bool isNull() const; + bool isEmpty() const; - void reset(); + CommandTypes commandTypes() const; - bool isNull() const; - bool isEmpty() const; + void render(QPainter *) const; - CommandTypes commandTypes() const; + void render(QPainter *, const QSizeF &, + Qt::AspectRatioMode = Qt::IgnoreAspectRatio) const; - void render( QPainter* ) const; + void render(QPainter *, const QPointF &, + Qt::Alignment = Qt::AlignTop | Qt::AlignLeft) const; - void render( QPainter*, const QSizeF&, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; + void render(QPainter *, const QRectF &, + Qt::AspectRatioMode = Qt::IgnoreAspectRatio) const; - void render( QPainter*, const QPointF&, - Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const; + QPixmap toPixmap(qreal devicePixelRatio = 0.0) const; - void render( QPainter*, const QRectF&, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; + QPixmap toPixmap(const QSize &, Qt::AspectRatioMode = Qt::IgnoreAspectRatio, + qreal devicePixelRatio = 0.0) const; - QPixmap toPixmap( qreal devicePixelRatio = 0.0 ) const; + QImage toImage(qreal devicePixelRatio = 0.0) const; - QPixmap toPixmap( const QSize&, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio, - qreal devicePixelRatio = 0.0 ) const; + QImage toImage(const QSize &, Qt::AspectRatioMode = Qt::IgnoreAspectRatio, + qreal devicePixelRatio = 0.0) const; - QImage toImage( qreal devicePixelRatio = 0.0 ) const; + QRectF scaledBoundingRect(qreal sx, qreal sy) const; - QImage toImage( const QSize&, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio, - qreal devicePixelRatio = 0.0 ) const; + QRectF boundingRect() const; + QRectF controlPointRect() const; - QRectF scaledBoundingRect( qreal sx, qreal sy ) const; + const QVector &commands() const; + void setCommands(const QVector &); - QRectF boundingRect() const; - QRectF controlPointRect() const; + void setDefaultSize(const QSizeF &); + QSizeF defaultSize() const; - const QVector< QwtPainterCommand >& commands() const; - void setCommands( const QVector< QwtPainterCommand >& ); + qreal heightForWidth(qreal width) const; + qreal widthForHeight(qreal height) const; - void setDefaultSize( const QSizeF& ); - QSizeF defaultSize() const; + void setRenderHint(RenderHint, bool on = true); + bool testRenderHint(RenderHint) const; - qreal heightForWidth( qreal width ) const; - qreal widthForHeight( qreal height ) const; + RenderHints renderHints() const; - void setRenderHint( RenderHint, bool on = true ); - bool testRenderHint( RenderHint ) const; +protected: + virtual QSize sizeMetrics() const QWT_OVERRIDE; - RenderHints renderHints() const; + virtual void drawPath(const QPainterPath &) QWT_OVERRIDE; - protected: - virtual QSize sizeMetrics() const QWT_OVERRIDE; + virtual void drawPixmap(const QRectF &, const QPixmap &, + const QRectF &) QWT_OVERRIDE; - virtual void drawPath( const QPainterPath& ) QWT_OVERRIDE; + virtual void drawImage(const QRectF &, const QImage &, const QRectF &, + Qt::ImageConversionFlags) QWT_OVERRIDE; - virtual void drawPixmap( const QRectF&, - const QPixmap&, const QRectF& ) QWT_OVERRIDE; + virtual void updateState(const QPaintEngineState &) QWT_OVERRIDE; - virtual void drawImage( const QRectF&, const QImage&, - const QRectF&, Qt::ImageConversionFlags ) QWT_OVERRIDE; +private: + void renderGraphic(QPainter *, QTransform *) const; - virtual void updateState( const QPaintEngineState& ) QWT_OVERRIDE; + void updateBoundingRect(const QRectF &); + void updateControlPointRect(const QRectF &); - private: - void renderGraphic( QPainter*, QTransform* ) const; + class PathInfo; - void updateBoundingRect( const QRectF& ); - void updateControlPointRect( const QRectF& ); - - class PathInfo; - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::CommandTypes ) -Q_DECLARE_METATYPE( QwtGraphic ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtGraphic::RenderHints) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtGraphic::CommandTypes) +Q_DECLARE_METATYPE(QwtGraphic) #endif diff --git a/libs/qwt/src/qwt_interval.cpp b/libs/qwt/src/qwt_interval.cpp index 644502da..61d96476 100644 --- a/libs/qwt/src/qwt_interval.cpp +++ b/libs/qwt/src/qwt_interval.cpp @@ -11,12 +11,12 @@ namespace { - static const struct RegisterQwtInterval - { - inline RegisterQwtInterval() { qRegisterMetaType< QwtInterval >(); } +static const struct RegisterQwtInterval +{ + inline RegisterQwtInterval() { qRegisterMetaType(); } - } qwtRegisterQwtInterval; -} +} qwtRegisterQwtInterval; +} // namespace /*! \brief Normalize the limits of the interval @@ -28,16 +28,16 @@ namespace */ QwtInterval QwtInterval::normalized() const { - if ( m_minValue > m_maxValue ) - { - return inverted(); - } - if ( m_minValue == m_maxValue && m_borderFlags == ExcludeMinimum ) - { - return inverted(); - } + if (m_minValue > m_maxValue) + { + return inverted(); + } + if (m_minValue == m_maxValue && m_borderFlags == ExcludeMinimum) + { + return inverted(); + } - return *this; + return *this; } /*! @@ -47,15 +47,15 @@ QwtInterval QwtInterval::normalized() const */ QwtInterval QwtInterval::inverted() const { - BorderFlags borderFlags = IncludeBorders; + BorderFlags borderFlags = IncludeBorders; - if ( m_borderFlags & ExcludeMinimum ) - borderFlags |= ExcludeMaximum; + if (m_borderFlags & ExcludeMinimum) + borderFlags |= ExcludeMaximum; - if ( m_borderFlags & ExcludeMaximum ) - borderFlags |= ExcludeMinimum; + if (m_borderFlags & ExcludeMaximum) + borderFlags |= ExcludeMinimum; - return QwtInterval( m_maxValue, m_minValue, borderFlags ); + return QwtInterval(m_maxValue, m_minValue, borderFlags); } /*! @@ -64,21 +64,21 @@ QwtInterval QwtInterval::inverted() const \param value Value \return true, if value lies inside the boundaries */ -bool QwtInterval::contains( double value ) const +bool QwtInterval::contains(double value) const { - if ( !isValid() ) - return false; + if (!isValid()) + return false; - if ( ( value < m_minValue ) || ( value > m_maxValue ) ) - return false; + if ((value < m_minValue) || (value > m_maxValue)) + return false; - if ( ( value == m_minValue ) && ( m_borderFlags & ExcludeMinimum ) ) - return false; + if ((value == m_minValue) && (m_borderFlags & ExcludeMinimum)) + return false; - if ( ( value == m_maxValue ) && ( m_borderFlags & ExcludeMaximum ) ) - return false; + if ((value == m_maxValue) && (m_borderFlags & ExcludeMaximum)) + return false; - return true; + return true; } /*! @@ -87,94 +87,94 @@ bool QwtInterval::contains( double value ) const \param interval Interval \return true, if interval lies inside the boundaries */ -bool QwtInterval::contains( const QwtInterval& interval ) const +bool QwtInterval::contains(const QwtInterval &interval) const { - if ( !isValid() || !interval.isValid() ) - return false; + if (!isValid() || !interval.isValid()) + return false; - if ( ( interval.m_minValue < m_minValue ) || ( interval.m_maxValue > m_maxValue ) ) - return false; + if ((interval.m_minValue < m_minValue) || (interval.m_maxValue > m_maxValue)) + return false; - if ( m_borderFlags ) + if (m_borderFlags) + { + if (interval.m_minValue == m_minValue) { - if ( interval.m_minValue == m_minValue ) - { - if ( ( m_borderFlags & ExcludeMinimum ) - && !( interval.m_borderFlags & ExcludeMinimum ) ) - { - return false; - } - } - - if ( interval.m_maxValue == m_maxValue ) - { - if ( ( m_borderFlags & ExcludeMaximum ) - && !( interval.m_borderFlags & ExcludeMaximum ) ) - { - return false; - } - } + if ((m_borderFlags & ExcludeMinimum) + && !(interval.m_borderFlags & ExcludeMinimum)) + { + return false; + } } - return true; + if (interval.m_maxValue == m_maxValue) + { + if ((m_borderFlags & ExcludeMaximum) + && !(interval.m_borderFlags & ExcludeMaximum)) + { + return false; + } + } + } + + return true; } //! Unite 2 intervals -QwtInterval QwtInterval::unite( const QwtInterval& other ) const +QwtInterval QwtInterval::unite(const QwtInterval &other) const { - /* - If one of the intervals is invalid return the other one. - If both are invalid return an invalid default interval - */ - if ( !isValid() ) - { - if ( !other.isValid() ) - return QwtInterval(); - else - return other; - } - if ( !other.isValid() ) - return *this; + /* + If one of the intervals is invalid return the other one. + If both are invalid return an invalid default interval + */ + if (!isValid()) + { + if (!other.isValid()) + return QwtInterval(); + else + return other; + } + if (!other.isValid()) + return *this; - QwtInterval united; - BorderFlags flags = IncludeBorders; + QwtInterval united; + BorderFlags flags = IncludeBorders; - // minimum - if ( m_minValue < other.minValue() ) - { - united.setMinValue( m_minValue ); - flags &= m_borderFlags & ExcludeMinimum; - } - else if ( other.minValue() < m_minValue ) - { - united.setMinValue( other.minValue() ); - flags &= other.borderFlags() & ExcludeMinimum; - } - else // m_minValue == other.minValue() - { - united.setMinValue( m_minValue ); - flags &= ( m_borderFlags & other.borderFlags() ) & ExcludeMinimum; - } + // minimum + if (m_minValue < other.minValue()) + { + united.setMinValue(m_minValue); + flags &= m_borderFlags & ExcludeMinimum; + } + else if (other.minValue() < m_minValue) + { + united.setMinValue(other.minValue()); + flags &= other.borderFlags() & ExcludeMinimum; + } + else // m_minValue == other.minValue() + { + united.setMinValue(m_minValue); + flags &= (m_borderFlags & other.borderFlags()) & ExcludeMinimum; + } - // maximum - if ( m_maxValue > other.maxValue() ) - { - united.setMaxValue( m_maxValue ); - flags &= m_borderFlags & ExcludeMaximum; - } - else if ( other.maxValue() > m_maxValue ) - { - united.setMaxValue( other.maxValue() ); - flags &= other.borderFlags() & ExcludeMaximum; - } - else // m_maxValue == other.maxValue() ) - { - united.setMaxValue( m_maxValue ); - flags &= m_borderFlags & other.borderFlags() & ExcludeMaximum; - } + // maximum + if (m_maxValue > other.maxValue()) + { + united.setMaxValue(m_maxValue); + flags &= m_borderFlags & ExcludeMaximum; + } + else if (other.maxValue() > m_maxValue) + { + united.setMaxValue(other.maxValue()); + flags &= other.borderFlags() & ExcludeMaximum; + } + else // m_maxValue == other.maxValue() ) + { + united.setMaxValue(m_maxValue); + flags &= m_borderFlags & other.borderFlags() & ExcludeMaximum; + } - united.setBorderFlags( flags ); - return united; + united.setBorderFlags(flags); + return united; } /*! @@ -183,65 +183,64 @@ QwtInterval QwtInterval::unite( const QwtInterval& other ) const \param other Interval to be intersect with \return Intersection */ -QwtInterval QwtInterval::intersect( const QwtInterval& other ) const +QwtInterval QwtInterval::intersect(const QwtInterval &other) const { - if ( !other.isValid() || !isValid() ) - return QwtInterval(); + if (!other.isValid() || !isValid()) + return QwtInterval(); - QwtInterval i1 = *this; - QwtInterval i2 = other; + QwtInterval i1 = *this; + QwtInterval i2 = other; - // swap i1/i2, so that the minimum of i1 - // is smaller then the minimum of i2 + // swap i1/i2, so that the minimum of i1 + // is smaller then the minimum of i2 - if ( i1.minValue() > i2.minValue() ) + if (i1.minValue() > i2.minValue()) + { + qSwap(i1, i2); + } + else if (i1.minValue() == i2.minValue()) + { + if (i1.borderFlags() & ExcludeMinimum) + qSwap(i1, i2); + } + + if (i1.maxValue() < i2.minValue()) + { + return QwtInterval(); + } + + if (i1.maxValue() == i2.minValue()) + { + if (i1.borderFlags() & ExcludeMaximum || i2.borderFlags() & ExcludeMinimum) { - qSwap( i1, i2 ); - } - else if ( i1.minValue() == i2.minValue() ) - { - if ( i1.borderFlags() & ExcludeMinimum ) - qSwap( i1, i2 ); + return QwtInterval(); } + } - if ( i1.maxValue() < i2.minValue() ) - { - return QwtInterval(); - } + QwtInterval intersected; + BorderFlags flags = IncludeBorders; - if ( i1.maxValue() == i2.minValue() ) - { - if ( i1.borderFlags() & ExcludeMaximum || - i2.borderFlags() & ExcludeMinimum ) - { - return QwtInterval(); - } - } + intersected.setMinValue(i2.minValue()); + flags |= i2.borderFlags() & ExcludeMinimum; - QwtInterval intersected; - BorderFlags flags = IncludeBorders; + if (i1.maxValue() < i2.maxValue()) + { + intersected.setMaxValue(i1.maxValue()); + flags |= i1.borderFlags() & ExcludeMaximum; + } + else if (i2.maxValue() < i1.maxValue()) + { + intersected.setMaxValue(i2.maxValue()); + flags |= i2.borderFlags() & ExcludeMaximum; + } + else // i1.maxValue() == i2.maxValue() + { + intersected.setMaxValue(i1.maxValue()); + flags |= i1.borderFlags() & i2.borderFlags() & ExcludeMaximum; + } - intersected.setMinValue( i2.minValue() ); - flags |= i2.borderFlags() & ExcludeMinimum; - - if ( i1.maxValue() < i2.maxValue() ) - { - intersected.setMaxValue( i1.maxValue() ); - flags |= i1.borderFlags() & ExcludeMaximum; - } - else if ( i2.maxValue() < i1.maxValue() ) - { - intersected.setMaxValue( i2.maxValue() ); - flags |= i2.borderFlags() & ExcludeMaximum; - } - else // i1.maxValue() == i2.maxValue() - { - intersected.setMaxValue( i1.maxValue() ); - flags |= i1.borderFlags() & i2.borderFlags() & ExcludeMaximum; - } - - intersected.setBorderFlags( flags ); - return intersected; + intersected.setBorderFlags(flags); + return intersected; } /*! @@ -250,10 +249,10 @@ QwtInterval QwtInterval::intersect( const QwtInterval& other ) const \param other Interval to be united with \return This interval */ -QwtInterval& QwtInterval::operator|=( const QwtInterval& other ) +QwtInterval &QwtInterval::operator|=(const QwtInterval &other) { - *this = *this | other; - return *this; + *this = *this | other; + return *this; } /*! @@ -262,10 +261,10 @@ QwtInterval& QwtInterval::operator|=( const QwtInterval& other ) \param other Interval to be intersected with \return This interval */ -QwtInterval& QwtInterval::operator&=( const QwtInterval& other ) +QwtInterval &QwtInterval::operator&=(const QwtInterval &other) { - *this = *this & other; - return *this; + *this = *this & other; + return *this; } /*! @@ -274,37 +273,36 @@ QwtInterval& QwtInterval::operator&=( const QwtInterval& other ) \param other Interval \return True, when the intervals are intersecting */ -bool QwtInterval::intersects( const QwtInterval& other ) const +bool QwtInterval::intersects(const QwtInterval &other) const { - if ( !isValid() || !other.isValid() ) - return false; - - QwtInterval i1 = *this; - QwtInterval i2 = other; - - // swap i1/i2, so that the minimum of i1 - // is smaller then the minimum of i2 - - if ( i1.minValue() > i2.minValue() ) - { - qSwap( i1, i2 ); - } - else if ( i1.minValue() == i2.minValue() && - i1.borderFlags() & ExcludeMinimum ) - { - qSwap( i1, i2 ); - } - - if ( i1.maxValue() > i2.minValue() ) - { - return true; - } - if ( i1.maxValue() == i2.minValue() ) - { - return !( ( i1.borderFlags() & ExcludeMaximum ) || - ( i2.borderFlags() & ExcludeMinimum ) ); - } + if (!isValid() || !other.isValid()) return false; + + QwtInterval i1 = *this; + QwtInterval i2 = other; + + // swap i1/i2, so that the minimum of i1 + // is smaller then the minimum of i2 + + if (i1.minValue() > i2.minValue()) + { + qSwap(i1, i2); + } + else if (i1.minValue() == i2.minValue() && i1.borderFlags() & ExcludeMinimum) + { + qSwap(i1, i2); + } + + if (i1.maxValue() > i2.minValue()) + { + return true; + } + if (i1.maxValue() == i2.minValue()) + { + return !((i1.borderFlags() & ExcludeMaximum) + || (i2.borderFlags() & ExcludeMinimum)); + } + return false; } /*! @@ -314,15 +312,14 @@ bool QwtInterval::intersects( const QwtInterval& other ) const \param value Center \return Interval with value as center */ -QwtInterval QwtInterval::symmetrize( double value ) const +QwtInterval QwtInterval::symmetrize(double value) const { - if ( !isValid() ) - return *this; + if (!isValid()) + return *this; - const double delta = - qMax( qAbs( value - m_maxValue ), qAbs( value - m_minValue ) ); + const double delta = qMax(qAbs(value - m_maxValue), qAbs(value - m_minValue)); - return QwtInterval( value - delta, value + delta ); + return QwtInterval(value - delta, value + delta); } /*! @@ -333,18 +330,18 @@ QwtInterval QwtInterval::symmetrize( double value ) const \return Limited interval */ -QwtInterval QwtInterval::limited( double lowerBound, double upperBound ) const +QwtInterval QwtInterval::limited(double lowerBound, double upperBound) const { - if ( !isValid() || lowerBound > upperBound ) - return QwtInterval(); + if (!isValid() || lowerBound > upperBound) + return QwtInterval(); - double minValue = qMax( m_minValue, lowerBound ); - minValue = qMin( minValue, upperBound ); + double minValue = qMax(m_minValue, lowerBound); + minValue = qMin(minValue, upperBound); - double maxValue = qMax( m_maxValue, lowerBound ); - maxValue = qMin( maxValue, upperBound ); + double maxValue = qMax(m_maxValue, lowerBound); + maxValue = qMin(maxValue, upperBound); - return QwtInterval( minValue, maxValue, m_borderFlags ); + return QwtInterval(minValue, maxValue, m_borderFlags); } /*! @@ -360,13 +357,13 @@ QwtInterval QwtInterval::limited( double lowerBound, double upperBound ) const \sa isValid() */ -QwtInterval QwtInterval::extend( double value ) const +QwtInterval QwtInterval::extend(double value) const { - if ( !isValid() ) - return *this; + if (!isValid()) + return *this; - return QwtInterval( qMin( value, m_minValue ), - qMax( value, m_maxValue ), m_borderFlags ); + return QwtInterval(qMin(value, m_minValue), qMax(value, m_maxValue), + m_borderFlags); } /*! @@ -377,27 +374,26 @@ QwtInterval QwtInterval::extend( double value ) const \sa extend() */ -QwtInterval& QwtInterval::operator|=( double value ) +QwtInterval &QwtInterval::operator|=(double value) { - *this = *this | value; - return *this; + *this = *this | value; + return *this; } #ifndef QT_NO_DEBUG_STREAM -#include +# include -QDebug operator<<( QDebug debug, const QwtInterval& interval ) +QDebug operator<<(QDebug debug, const QwtInterval &interval) { - const int flags = interval.borderFlags(); + const int flags = interval.borderFlags(); - debug.nospace() << "QwtInterval(" - << ( ( flags& QwtInterval::ExcludeMinimum ) ? "]" : "[" ) - << interval.minValue() << "," << interval.maxValue() - << ( ( flags& QwtInterval::ExcludeMaximum ) ? "[" : "]" ) - << ")"; + debug.nospace() << "QwtInterval(" + << ((flags & QwtInterval::ExcludeMinimum) ? "]" : "[") + << interval.minValue() << "," << interval.maxValue() + << ((flags & QwtInterval::ExcludeMaximum) ? "[" : "]") << ")"; - return debug.space(); + return debug.space(); } #endif diff --git a/libs/qwt/src/qwt_interval.h b/libs/qwt/src/qwt_interval.h index 9d59fac7..56e64267 100644 --- a/libs/qwt/src/qwt_interval.h +++ b/libs/qwt/src/qwt_interval.h @@ -21,87 +21,86 @@ class QWT_EXPORT QwtInterval { - public: - /*! - Flag indicating if a border is included or excluded - \sa setBorderFlags(), borderFlags() - */ - enum BorderFlag - { - //! Min/Max values are inside the interval - IncludeBorders = 0x00, +public: + /*! + Flag indicating if a border is included or excluded + \sa setBorderFlags(), borderFlags() + */ + enum BorderFlag + { + //! Min/Max values are inside the interval + IncludeBorders = 0x00, - //! Min value is not included in the interval - ExcludeMinimum = 0x01, + //! Min value is not included in the interval + ExcludeMinimum = 0x01, - //! Max value is not included in the interval - ExcludeMaximum = 0x02, + //! Max value is not included in the interval + ExcludeMaximum = 0x02, - //! Min/Max values are not included in the interval - ExcludeBorders = ExcludeMinimum | ExcludeMaximum - }; + //! Min/Max values are not included in the interval + ExcludeBorders = ExcludeMinimum | ExcludeMaximum + }; - //! Border flags - Q_DECLARE_FLAGS( BorderFlags, BorderFlag ) + //! Border flags + Q_DECLARE_FLAGS(BorderFlags, BorderFlag) - QwtInterval(); - QwtInterval( double minValue, double maxValue, - BorderFlags = IncludeBorders ); + QwtInterval(); + QwtInterval(double minValue, double maxValue, BorderFlags = IncludeBorders); - void setInterval( double minValue, double maxValue, - BorderFlags = IncludeBorders ); + void setInterval(double minValue, double maxValue, + BorderFlags = IncludeBorders); - QwtInterval normalized() const; - QwtInterval inverted() const; - QwtInterval limited( double lowerBound, double upperBound ) const; + QwtInterval normalized() const; + QwtInterval inverted() const; + QwtInterval limited(double lowerBound, double upperBound) const; - bool operator==( const QwtInterval& ) const; - bool operator!=( const QwtInterval& ) const; + bool operator==(const QwtInterval &) const; + bool operator!=(const QwtInterval &) const; - void setBorderFlags( BorderFlags ); - BorderFlags borderFlags() const; + void setBorderFlags(BorderFlags); + BorderFlags borderFlags() const; - double minValue() const; - double maxValue() const; + double minValue() const; + double maxValue() const; - double width() const; - long double widthL() const; + double width() const; + long double widthL() const; - void setMinValue( double ); - void setMaxValue( double ); + void setMinValue(double); + void setMaxValue(double); - bool contains( double value ) const; - bool contains( const QwtInterval& ) const; + bool contains(double value) const; + bool contains(const QwtInterval &) const; - bool intersects( const QwtInterval& ) const; - QwtInterval intersect( const QwtInterval& ) const; - QwtInterval unite( const QwtInterval& ) const; + bool intersects(const QwtInterval &) const; + QwtInterval intersect(const QwtInterval &) const; + QwtInterval unite(const QwtInterval &) const; - QwtInterval operator|( const QwtInterval& ) const; - QwtInterval operator&( const QwtInterval& ) const; + QwtInterval operator|(const QwtInterval &) const; + QwtInterval operator&(const QwtInterval &) const; - QwtInterval& operator|=( const QwtInterval& ); - QwtInterval& operator&=( const QwtInterval& ); + QwtInterval &operator|=(const QwtInterval &); + QwtInterval &operator&=(const QwtInterval &); - QwtInterval extend( double value ) const; - QwtInterval operator|( double ) const; - QwtInterval& operator|=( double ); + QwtInterval extend(double value) const; + QwtInterval operator|(double) const; + QwtInterval &operator|=(double); - bool isValid() const; - bool isNull() const; - void invalidate(); + bool isValid() const; + bool isNull() const; + void invalidate(); - QwtInterval symmetrize( double value ) const; + QwtInterval symmetrize(double value) const; - private: - double m_minValue; - double m_maxValue; - BorderFlags m_borderFlags; +private: + double m_minValue; + double m_maxValue; + BorderFlags m_borderFlags; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags ) -Q_DECLARE_METATYPE( QwtInterval ) -Q_DECLARE_TYPEINFO( QwtInterval, Q_MOVABLE_TYPE ); +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtInterval::BorderFlags) +Q_DECLARE_METATYPE(QwtInterval) +Q_DECLARE_TYPEINFO(QwtInterval, Q_MOVABLE_TYPE); /*! \brief Default Constructor @@ -110,9 +109,9 @@ Q_DECLARE_TYPEINFO( QwtInterval, Q_MOVABLE_TYPE ); \sa setInterval(), isValid() */ inline QwtInterval::QwtInterval() - : m_minValue( 0.0 ) - , m_maxValue( -1.0 ) - , m_borderFlags( IncludeBorders ) + : m_minValue(0.0) + , m_maxValue(-1.0) + , m_borderFlags(IncludeBorders) { } @@ -125,11 +124,11 @@ inline QwtInterval::QwtInterval() \param maxValue Maximum value \param borderFlags Include/Exclude borders */ -inline QwtInterval::QwtInterval( - double minValue, double maxValue, BorderFlags borderFlags ) - : m_minValue( minValue ) - , m_maxValue( maxValue ) - , m_borderFlags( borderFlags ) +inline QwtInterval::QwtInterval(double minValue, double maxValue, + BorderFlags borderFlags) + : m_minValue(minValue) + , m_maxValue(maxValue) + , m_borderFlags(borderFlags) { } @@ -140,12 +139,12 @@ inline QwtInterval::QwtInterval( \param maxValue Maximum value \param borderFlags Include/Exclude borders */ -inline void QwtInterval::setInterval( - double minValue, double maxValue, BorderFlags borderFlags ) +inline void QwtInterval::setInterval(double minValue, double maxValue, + BorderFlags borderFlags) { - m_minValue = minValue; - m_maxValue = maxValue; - m_borderFlags = borderFlags; + m_minValue = minValue; + m_maxValue = maxValue; + m_borderFlags = borderFlags; } /*! @@ -154,9 +153,9 @@ inline void QwtInterval::setInterval( \param borderFlags Or'd BorderMode flags \sa borderFlags() */ -inline void QwtInterval::setBorderFlags( BorderFlags borderFlags ) +inline void QwtInterval::setBorderFlags(BorderFlags borderFlags) { - m_borderFlags = borderFlags; + m_borderFlags = borderFlags; } /*! @@ -165,7 +164,7 @@ inline void QwtInterval::setBorderFlags( BorderFlags borderFlags ) */ inline QwtInterval::BorderFlags QwtInterval::borderFlags() const { - return m_borderFlags; + return m_borderFlags; } /*! @@ -173,9 +172,9 @@ inline QwtInterval::BorderFlags QwtInterval::borderFlags() const \param minValue Minimum value */ -inline void QwtInterval::setMinValue( double minValue ) +inline void QwtInterval::setMinValue(double minValue) { - m_minValue = minValue; + m_minValue = minValue; } /*! @@ -183,21 +182,21 @@ inline void QwtInterval::setMinValue( double minValue ) \param maxValue Maximum value */ -inline void QwtInterval::setMaxValue( double maxValue ) +inline void QwtInterval::setMaxValue(double maxValue) { - m_maxValue = maxValue; + m_maxValue = maxValue; } //! \return Lower limit of the interval inline double QwtInterval::minValue() const { - return m_minValue; + return m_minValue; } //! \return Upper limit of the interval inline double QwtInterval::maxValue() const { - return m_maxValue; + return m_maxValue; } /*! @@ -209,10 +208,10 @@ inline double QwtInterval::maxValue() const */ inline bool QwtInterval::isValid() const { - if ( ( m_borderFlags & ExcludeBorders ) == 0 ) - return m_minValue <= m_maxValue; - else - return m_minValue < m_maxValue; + if ((m_borderFlags & ExcludeBorders) == 0) + return m_minValue <= m_maxValue; + else + return m_minValue < m_maxValue; } /*! @@ -226,7 +225,7 @@ inline bool QwtInterval::isValid() const */ inline double QwtInterval::width() const { - return isValid() ? ( m_maxValue - m_minValue ) : 0.0; + return isValid() ? (m_maxValue - m_minValue) : 0.0; } /*! @@ -240,11 +239,11 @@ inline double QwtInterval::width() const */ inline long double QwtInterval::widthL() const { - if ( !isValid() ) - return 0.0; + if (!isValid()) + return 0.0; - return static_cast< long double >( m_maxValue ) - - static_cast< long double >( m_minValue ); + return static_cast(m_maxValue) + - static_cast(m_minValue); } /*! @@ -255,10 +254,9 @@ inline long double QwtInterval::widthL() const \sa intersect() */ -inline QwtInterval QwtInterval::operator&( - const QwtInterval& other ) const +inline QwtInterval QwtInterval::operator&(const QwtInterval &other) const { - return intersect( other ); + return intersect(other); } /*! @@ -269,10 +267,9 @@ inline QwtInterval QwtInterval::operator&( \sa unite() */ -inline QwtInterval QwtInterval::operator|( - const QwtInterval& other ) const +inline QwtInterval QwtInterval::operator|(const QwtInterval &other) const { - return unite( other ); + return unite(other); } /*! @@ -281,11 +278,10 @@ inline QwtInterval QwtInterval::operator|( \param other Interval to compare with \return True, when this and other are equal */ -inline bool QwtInterval::operator==( const QwtInterval& other ) const +inline bool QwtInterval::operator==(const QwtInterval &other) const { - return ( m_minValue == other.m_minValue ) && - ( m_maxValue == other.m_maxValue ) && - ( m_borderFlags == other.m_borderFlags ); + return (m_minValue == other.m_minValue) && (m_maxValue == other.m_maxValue) + && (m_borderFlags == other.m_borderFlags); } /*! \brief Compare two intervals @@ -293,9 +289,9 @@ inline bool QwtInterval::operator==( const QwtInterval& other ) const \param other Interval to compare with \return True, when this and other are not equal */ -inline bool QwtInterval::operator!=( const QwtInterval& other ) const +inline bool QwtInterval::operator!=(const QwtInterval &other) const { - return ( !( *this == other ) ); + return (!(*this == other)); } /*! @@ -305,15 +301,15 @@ inline bool QwtInterval::operator!=( const QwtInterval& other ) const \return Extended interval \sa extend() */ -inline QwtInterval QwtInterval::operator|( double value ) const +inline QwtInterval QwtInterval::operator|(double value) const { - return extend( value ); + return extend(value); } //! \return true, if isValid() && (minValue() >= maxValue()) inline bool QwtInterval::isNull() const { - return isValid() && m_minValue >= m_maxValue; + return isValid() && m_minValue >= m_maxValue; } /*! @@ -324,12 +320,12 @@ inline bool QwtInterval::isNull() const */ inline void QwtInterval::invalidate() { - m_minValue = 0.0; - m_maxValue = -1.0; + m_minValue = 0.0; + m_maxValue = -1.0; } #ifndef QT_NO_DEBUG_STREAM -QWT_EXPORT QDebug operator<<( QDebug, const QwtInterval& ); +QWT_EXPORT QDebug operator<<(QDebug, const QwtInterval &); #endif #endif diff --git a/libs/qwt/src/qwt_interval_symbol.cpp b/libs/qwt/src/qwt_interval_symbol.cpp index 85f72ffc..80e00861 100644 --- a/libs/qwt/src/qwt_interval_symbol.cpp +++ b/libs/qwt/src/qwt_interval_symbol.cpp @@ -16,26 +16,24 @@ class QwtIntervalSymbol::PrivateData { - public: - PrivateData() - : style( QwtIntervalSymbol::NoSymbol ) - , width( 6 ) - { - } +public: + PrivateData() + : style(QwtIntervalSymbol::NoSymbol) + , width(6) + { + } - bool operator==( const PrivateData& other ) const - { - return ( style == other.style ) - && ( width == other.width ) - && ( brush == other.brush ) - && ( pen == other.pen ); - } + bool operator==(const PrivateData &other) const + { + return (style == other.style) && (width == other.width) + && (brush == other.brush) && (pen == other.pen); + } - QwtIntervalSymbol::Style style; - int width; + QwtIntervalSymbol::Style style; + int width; - QPen pen; - QBrush brush; + QPen pen; + QBrush brush; }; /*! @@ -44,45 +42,42 @@ class QwtIntervalSymbol::PrivateData \param style Style of the symbol \sa setStyle(), style(), Style */ -QwtIntervalSymbol::QwtIntervalSymbol( Style style ) +QwtIntervalSymbol::QwtIntervalSymbol(Style style) { - m_data = new PrivateData(); - m_data->style = style; + m_data = new PrivateData(); + m_data->style = style; } //! Copy constructor -QwtIntervalSymbol::QwtIntervalSymbol( const QwtIntervalSymbol& other ) +QwtIntervalSymbol::QwtIntervalSymbol(const QwtIntervalSymbol &other) { - m_data = new PrivateData(); - *m_data = *other.m_data; + m_data = new PrivateData(); + *m_data = *other.m_data; } //! Destructor QwtIntervalSymbol::~QwtIntervalSymbol() { - delete m_data; + delete m_data; } //! \brief Assignment operator -QwtIntervalSymbol& QwtIntervalSymbol::operator=( - const QwtIntervalSymbol& other ) +QwtIntervalSymbol &QwtIntervalSymbol::operator=(const QwtIntervalSymbol &other) { - *m_data = *other.m_data; - return *this; + *m_data = *other.m_data; + return *this; } //! \brief Compare two symbols -bool QwtIntervalSymbol::operator==( - const QwtIntervalSymbol& other ) const +bool QwtIntervalSymbol::operator==(const QwtIntervalSymbol &other) const { - return *m_data == *other.m_data; + return *m_data == *other.m_data; } //! \brief Compare two symbols -bool QwtIntervalSymbol::operator!=( - const QwtIntervalSymbol& other ) const +bool QwtIntervalSymbol::operator!=(const QwtIntervalSymbol &other) const { - return !( *m_data == *other.m_data ); + return !(*m_data == *other.m_data); } /*! @@ -91,9 +86,9 @@ bool QwtIntervalSymbol::operator!=( \param style Style \sa style(), Style */ -void QwtIntervalSymbol::setStyle( Style style ) +void QwtIntervalSymbol::setStyle(Style style) { - m_data->style = style; + m_data->style = style; } /*! @@ -102,7 +97,7 @@ void QwtIntervalSymbol::setStyle( Style style ) */ QwtIntervalSymbol::Style QwtIntervalSymbol::style() const { - return m_data->style; + return m_data->style; } /*! @@ -112,9 +107,9 @@ QwtIntervalSymbol::Style QwtIntervalSymbol::style() const \param width Width \sa width(), setStyle() */ -void QwtIntervalSymbol::setWidth( int width ) +void QwtIntervalSymbol::setWidth(int width) { - m_data->width = width; + m_data->width = width; } /*! @@ -123,7 +118,7 @@ void QwtIntervalSymbol::setWidth( int width ) */ int QwtIntervalSymbol::width() const { - return m_data->width; + return m_data->width; } /*! @@ -134,18 +129,18 @@ int QwtIntervalSymbol::width() const \param brush Brush \sa brush() */ -void QwtIntervalSymbol::setBrush( const QBrush& brush ) +void QwtIntervalSymbol::setBrush(const QBrush &brush) { - m_data->brush = brush; + m_data->brush = brush; } /*! \return Brush \sa setBrush() */ -const QBrush& QwtIntervalSymbol::brush() const +const QBrush &QwtIntervalSymbol::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -161,10 +156,10 @@ const QBrush& QwtIntervalSymbol::brush() const \sa pen(), brush() */ -void QwtIntervalSymbol::setPen( const QColor& color, - qreal width, Qt::PenStyle style ) +void QwtIntervalSymbol::setPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -173,18 +168,18 @@ void QwtIntervalSymbol::setPen( const QColor& color, \param pen Pen \sa pen(), setBrush() */ -void QwtIntervalSymbol::setPen( const QPen& pen ) +void QwtIntervalSymbol::setPen(const QPen &pen) { - m_data->pen = pen; + m_data->pen = pen; } /*! \return Pen \sa setPen(), brush() */ -const QPen& QwtIntervalSymbol::pen() const +const QPen &QwtIntervalSymbol::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -197,119 +192,105 @@ const QPen& QwtIntervalSymbol::pen() const \sa setStyle() */ -void QwtIntervalSymbol::draw( QPainter* painter, Qt::Orientation orientation, - const QPointF& from, const QPointF& to ) const +void QwtIntervalSymbol::draw(QPainter *painter, Qt::Orientation orientation, + const QPointF &from, const QPointF &to) const { - const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); + const qreal pw = QwtPainter::effectivePenWidth(painter->pen()); - QPointF p1 = from; - QPointF p2 = to; - if ( QwtPainter::roundingAlignment( painter ) ) - { - p1 = p1.toPoint(); - p2 = p2.toPoint(); - } + QPointF p1 = from; + QPointF p2 = to; + if (QwtPainter::roundingAlignment(painter)) + { + p1 = p1.toPoint(); + p2 = p2.toPoint(); + } - switch ( m_data->style ) - { - case QwtIntervalSymbol::Bar: + switch (m_data->style) + { + case QwtIntervalSymbol::Bar: { + QwtPainter::drawLine(painter, p1, p2); + if (m_data->width > pw) + { + if ((orientation == Qt::Horizontal) && (p1.y() == p2.y())) { - QwtPainter::drawLine( painter, p1, p2 ); - if ( m_data->width > pw ) - { - if ( ( orientation == Qt::Horizontal ) - && ( p1.y() == p2.y() ) ) - { - const double sw = m_data->width; + const double sw = m_data->width; - const double y = p1.y() - sw / 2; - QwtPainter::drawLine( painter, - p1.x(), y, p1.x(), y + sw ); - QwtPainter::drawLine( painter, - p2.x(), y, p2.x(), y + sw ); - } - else if ( ( orientation == Qt::Vertical ) - && ( p1.x() == p2.x() ) ) - { - const double sw = m_data->width; - - const double x = p1.x() - sw / 2; - QwtPainter::drawLine( painter, - x, p1.y(), x + sw, p1.y() ); - QwtPainter::drawLine( painter, - x, p2.y(), x + sw, p2.y() ); - } - else - { - const double sw = m_data->width; - - const double dx = p2.x() - p1.x(); - const double dy = p2.y() - p1.y(); - const double angle = std::atan2( dy, dx ) + M_PI_2; - double dw2 = sw / 2.0; - - const double cx = qFastCos( angle ) * dw2; - const double sy = qFastSin( angle ) * dw2; - - QwtPainter::drawLine( painter, - p1.x() - cx, p1.y() - sy, - p1.x() + cx, p1.y() + sy ); - QwtPainter::drawLine( painter, - p2.x() - cx, p2.y() - sy, - p2.x() + cx, p2.y() + sy ); - } - } - break; + const double y = p1.y() - sw / 2; + QwtPainter::drawLine(painter, p1.x(), y, p1.x(), y + sw); + QwtPainter::drawLine(painter, p2.x(), y, p2.x(), y + sw); } - case QwtIntervalSymbol::Box: + else if ((orientation == Qt::Vertical) && (p1.x() == p2.x())) { - if ( m_data->width <= pw ) - { - QwtPainter::drawLine( painter, p1, p2 ); - } - else - { - if ( ( orientation == Qt::Horizontal ) - && ( p1.y() == p2.y() ) ) - { - const double sw = m_data->width; + const double sw = m_data->width; - const double y = p1.y() - m_data->width / 2; - QwtPainter::drawRect( painter, - p1.x(), y, p2.x() - p1.x(), sw ); - } - else if ( ( orientation == Qt::Vertical ) - && ( p1.x() == p2.x() ) ) - { - const double sw = m_data->width; - - const double x = p1.x() - m_data->width / 2; - QwtPainter::drawRect( painter, - x, p1.y(), sw, p2.y() - p1.y() ); - } - else - { - const double sw = m_data->width; - - const double dx = p2.x() - p1.x(); - const double dy = p2.y() - p1.y(); - const double angle = std::atan2( dy, dx ) + M_PI_2; - double dw2 = sw / 2.0; - - const double cx = qFastCos( angle ) * dw2; - const double sy = qFastSin( angle ) * dw2; - - QPolygonF polygon; - polygon += QPointF( p1.x() - cx, p1.y() - sy ); - polygon += QPointF( p1.x() + cx, p1.y() + sy ); - polygon += QPointF( p2.x() + cx, p2.y() + sy ); - polygon += QPointF( p2.x() - cx, p2.y() - sy ); - - QwtPainter::drawPolygon( painter, polygon ); - } - } - break; + const double x = p1.x() - sw / 2; + QwtPainter::drawLine(painter, x, p1.y(), x + sw, p1.y()); + QwtPainter::drawLine(painter, x, p2.y(), x + sw, p2.y()); } - default:; + else + { + const double sw = m_data->width; + + const double dx = p2.x() - p1.x(); + const double dy = p2.y() - p1.y(); + const double angle = std::atan2(dy, dx) + M_PI_2; + double dw2 = sw / 2.0; + + const double cx = qFastCos(angle) * dw2; + const double sy = qFastSin(angle) * dw2; + + QwtPainter::drawLine(painter, p1.x() - cx, p1.y() - sy, p1.x() + cx, + p1.y() + sy); + QwtPainter::drawLine(painter, p2.x() - cx, p2.y() - sy, p2.x() + cx, + p2.y() + sy); + } + } + break; } + case QwtIntervalSymbol::Box: { + if (m_data->width <= pw) + { + QwtPainter::drawLine(painter, p1, p2); + } + else + { + if ((orientation == Qt::Horizontal) && (p1.y() == p2.y())) + { + const double sw = m_data->width; + + const double y = p1.y() - m_data->width / 2; + QwtPainter::drawRect(painter, p1.x(), y, p2.x() - p1.x(), sw); + } + else if ((orientation == Qt::Vertical) && (p1.x() == p2.x())) + { + const double sw = m_data->width; + + const double x = p1.x() - m_data->width / 2; + QwtPainter::drawRect(painter, x, p1.y(), sw, p2.y() - p1.y()); + } + else + { + const double sw = m_data->width; + + const double dx = p2.x() - p1.x(); + const double dy = p2.y() - p1.y(); + const double angle = std::atan2(dy, dx) + M_PI_2; + double dw2 = sw / 2.0; + + const double cx = qFastCos(angle) * dw2; + const double sy = qFastSin(angle) * dw2; + + QPolygonF polygon; + polygon += QPointF(p1.x() - cx, p1.y() - sy); + polygon += QPointF(p1.x() + cx, p1.y() + sy); + polygon += QPointF(p2.x() + cx, p2.y() + sy); + polygon += QPointF(p2.x() - cx, p2.y() - sy); + + QwtPainter::drawPolygon(painter, polygon); + } + } + break; + } + default:; + } } diff --git a/libs/qwt/src/qwt_interval_symbol.h b/libs/qwt/src/qwt_interval_symbol.h index 770cdd9f..eddd680d 100644 --- a/libs/qwt/src/qwt_interval_symbol.h +++ b/libs/qwt/src/qwt_interval_symbol.h @@ -26,63 +26,63 @@ class QColor; */ class QWT_EXPORT QwtIntervalSymbol { - public: - //! Symbol style - enum Style - { - //! No Style. The symbol cannot be drawn. - NoSymbol = -1, +public: + //! Symbol style + enum Style + { + //! No Style. The symbol cannot be drawn. + NoSymbol = -1, - /*! - The symbol displays a line with caps at the beginning/end. - The size of the caps depends on the symbol width(). - */ - Bar, + /*! + The symbol displays a line with caps at the beginning/end. + The size of the caps depends on the symbol width(). + */ + Bar, - /*! - The symbol displays a plain rectangle using pen() and brush(). - The size of the rectangle depends on the translated interval and - the width(), - */ - Box, + /*! + The symbol displays a plain rectangle using pen() and brush(). + The size of the rectangle depends on the translated interval and + the width(), + */ + Box, - /*! - Styles >= UserSymbol are reserved for derived - classes of QwtIntervalSymbol that overload draw() with - additional application specific symbol types. - */ - UserSymbol = 1000 - }; + /*! + Styles >= UserSymbol are reserved for derived + classes of QwtIntervalSymbol that overload draw() with + additional application specific symbol types. + */ + UserSymbol = 1000 + }; - public: - explicit QwtIntervalSymbol( Style = NoSymbol ); - QwtIntervalSymbol( const QwtIntervalSymbol& ); +public: + explicit QwtIntervalSymbol(Style = NoSymbol); + QwtIntervalSymbol(const QwtIntervalSymbol &); - virtual ~QwtIntervalSymbol(); + virtual ~QwtIntervalSymbol(); - QwtIntervalSymbol& operator=( const QwtIntervalSymbol& ); - bool operator==( const QwtIntervalSymbol& ) const; - bool operator!=( const QwtIntervalSymbol& ) const; + QwtIntervalSymbol &operator=(const QwtIntervalSymbol &); + bool operator==(const QwtIntervalSymbol &) const; + bool operator!=(const QwtIntervalSymbol &) const; - void setWidth( int ); - int width() const; + void setWidth(int); + int width() const; - void setBrush( const QBrush& ); - const QBrush& brush() const; + void setBrush(const QBrush &); + const QBrush &brush() const; - void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setPen( const QPen& ); - const QPen& pen() const; + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); + void setPen(const QPen &); + const QPen &pen() const; - void setStyle( Style ); - Style style() const; + void setStyle(Style); + Style style() const; - virtual void draw( QPainter*, Qt::Orientation, - const QPointF& from, const QPointF& to ) const; + virtual void draw(QPainter *, Qt::Orientation, const QPointF &from, + const QPointF &to) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_knob.cpp b/libs/qwt/src/qwt_knob.cpp index 34cb0ff2..fbf66b42 100644 --- a/libs/qwt/src/qwt_knob.cpp +++ b/libs/qwt/src/qwt_knob.cpp @@ -22,71 +22,71 @@ #include #include -static QSize qwtKnobSizeHint( const QwtKnob* knob, int min ) +static QSize qwtKnobSizeHint(const QwtKnob *knob, int min) { - int knobWidth = knob->knobWidth(); - if ( knobWidth <= 0 ) - knobWidth = qMax( 3 * knob->markerSize(), min ); + int knobWidth = knob->knobWidth(); + if (knobWidth <= 0) + knobWidth = qMax(3 * knob->markerSize(), min); - // Add the scale radial thickness to the knobWidth - const int extent = qwtCeil( knob->scaleDraw()->extent( knob->font() ) ); - const int d = 2 * ( extent + 4 ) + knobWidth; + // Add the scale radial thickness to the knobWidth + const int extent = qwtCeil(knob->scaleDraw()->extent(knob->font())); + const int d = 2 * (extent + 4) + knobWidth; - const QMargins m = knob->contentsMargins(); - return QSize( d + m.left() + m.right(), d + m.top() + m.bottom() ); + const QMargins m = knob->contentsMargins(); + return QSize(d + m.left() + m.right(), d + m.top() + m.bottom()); } -static inline double qwtToScaleAngle( double angle ) +static inline double qwtToScaleAngle(double angle) { - // the map is counter clockwise with the origin - // at 90° using angles from -180° -> 180° + // the map is counter clockwise with the origin + // at 90° using angles from -180° -> 180° - double a = 90.0 - angle; - if ( a <= -180.0 ) - a += 360.0; - else if ( a >= 180.0 ) - a -= 360.0; + double a = 90.0 - angle; + if (a <= -180.0) + a += 360.0; + else if (a >= 180.0) + a -= 360.0; - return a; + return a; } -static double qwtToDegrees( double value ) +static double qwtToDegrees(double value) { - return qwtNormalizeDegrees( 90.0 - value ); + return qwtNormalizeDegrees(90.0 - value); } class QwtKnob::PrivateData { - public: - PrivateData() - : knobStyle( QwtKnob::Raised ) - , markerStyle( QwtKnob::Notch ) - , borderWidth( 2 ) - , borderDist( 4 ) - , scaleDist( 4 ) - , maxScaleTicks( 11 ) - , knobWidth( 0 ) - , alignment( Qt::AlignCenter ) - , markerSize( 8 ) - , totalAngle( 270.0 ) - , mouseOffset( 0.0 ) - { - } +public: + PrivateData() + : knobStyle(QwtKnob::Raised) + , markerStyle(QwtKnob::Notch) + , borderWidth(2) + , borderDist(4) + , scaleDist(4) + , maxScaleTicks(11) + , knobWidth(0) + , alignment(Qt::AlignCenter) + , markerSize(8) + , totalAngle(270.0) + , mouseOffset(0.0) + { + } - QwtKnob::KnobStyle knobStyle; - QwtKnob::MarkerStyle markerStyle; + QwtKnob::KnobStyle knobStyle; + QwtKnob::MarkerStyle markerStyle; - int borderWidth; - int borderDist; - int scaleDist; - int maxScaleTicks; - int knobWidth; - Qt::Alignment alignment; - int markerSize; + int borderWidth; + int borderDist; + int scaleDist; + int maxScaleTicks; + int knobWidth; + Qt::Alignment alignment; + int markerSize; - double totalAngle; + double totalAngle; - double mouseOffset; + double mouseOffset; }; /*! @@ -100,26 +100,25 @@ class QwtKnob::PrivateData \sa setTotalAngle() */ -QwtKnob::QwtKnob( QWidget* parent ) - : QwtAbstractSlider( parent ) +QwtKnob::QwtKnob(QWidget *parent) + : QwtAbstractSlider(parent) { - m_data = new PrivateData; + m_data = new PrivateData; - setScaleDraw( new QwtRoundScaleDraw() ); + setScaleDraw(new QwtRoundScaleDraw()); - setTotalAngle( 270.0 ); + setTotalAngle(270.0); - setScale( 0.0, 10.0 ); - setValue( 0.0 ); + setScale(0.0, 10.0); + setValue(0.0); - setSizePolicy( QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding ); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); } //! Destructor QwtKnob::~QwtKnob() { - delete m_data; + delete m_data; } /*! @@ -128,13 +127,13 @@ QwtKnob::~QwtKnob() \param knobStyle Knob type \sa knobStyle(), setBorderWidth() */ -void QwtKnob::setKnobStyle( KnobStyle knobStyle ) +void QwtKnob::setKnobStyle(KnobStyle knobStyle) { - if ( m_data->knobStyle != knobStyle ) - { - m_data->knobStyle = knobStyle; - update(); - } + if (m_data->knobStyle != knobStyle) + { + m_data->knobStyle = knobStyle; + update(); + } } /*! @@ -143,7 +142,7 @@ void QwtKnob::setKnobStyle( KnobStyle knobStyle ) */ QwtKnob::KnobStyle QwtKnob::knobStyle() const { - return m_data->knobStyle; + return m_data->knobStyle; } /*! @@ -152,13 +151,13 @@ QwtKnob::KnobStyle QwtKnob::knobStyle() const \param markerStyle Marker type \sa markerStyle(), setMarkerSize() */ -void QwtKnob::setMarkerStyle( MarkerStyle markerStyle ) +void QwtKnob::setMarkerStyle(MarkerStyle markerStyle) { - if ( m_data->markerStyle != markerStyle ) - { - m_data->markerStyle = markerStyle; - update(); - } + if (m_data->markerStyle != markerStyle) + { + m_data->markerStyle = markerStyle; + update(); + } } /*! @@ -167,7 +166,7 @@ void QwtKnob::setMarkerStyle( MarkerStyle markerStyle ) */ QwtKnob::MarkerStyle QwtKnob::markerStyle() const { - return m_data->markerStyle; + return m_data->markerStyle; } /*! @@ -182,20 +181,20 @@ QwtKnob::MarkerStyle QwtKnob::markerStyle() const \sa totalAngle(), setNumTurns() */ -void QwtKnob::setTotalAngle ( double angle ) +void QwtKnob::setTotalAngle(double angle) { - angle = qBound( 10.0, angle, 360.0 ); + angle = qBound(10.0, angle, 360.0); - if ( angle != m_data->totalAngle ) - { - m_data->totalAngle = angle; + if (angle != m_data->totalAngle) + { + m_data->totalAngle = angle; - scaleDraw()->setAngleRange( -0.5 * m_data->totalAngle, - 0.5 * m_data->totalAngle ); + scaleDraw()->setAngleRange(-0.5 * m_data->totalAngle, + 0.5 * m_data->totalAngle); - updateGeometry(); - update(); - } + updateGeometry(); + update(); + } } /*! @@ -204,7 +203,7 @@ void QwtKnob::setTotalAngle ( double angle ) */ double QwtKnob::totalAngle() const { - return m_data->totalAngle; + return m_data->totalAngle; } /*! @@ -216,24 +215,24 @@ double QwtKnob::totalAngle() const \sa numTurns(), totalAngle(), setTotalAngle() */ -void QwtKnob::setNumTurns( int numTurns ) +void QwtKnob::setNumTurns(int numTurns) { - numTurns = qMax( numTurns, 1 ); + numTurns = qMax(numTurns, 1); - if ( numTurns == 1 && m_data->totalAngle <= 360.0 ) - return; + if (numTurns == 1 && m_data->totalAngle <= 360.0) + return; - const double angle = numTurns * 360.0; - if ( angle != m_data->totalAngle ) - { - m_data->totalAngle = angle; + const double angle = numTurns * 360.0; + if (angle != m_data->totalAngle) + { + m_data->totalAngle = angle; - scaleDraw()->setAngleRange( -0.5 * m_data->totalAngle, - 0.5 * m_data->totalAngle ); + scaleDraw()->setAngleRange(-0.5 * m_data->totalAngle, + 0.5 * m_data->totalAngle); - updateGeometry(); - update(); - } + updateGeometry(); + update(); + } } /*! @@ -244,7 +243,7 @@ void QwtKnob::setNumTurns( int numTurns ) */ int QwtKnob::numTurns() const { - return qwtCeil( m_data->totalAngle / 360.0 ); + return qwtCeil(m_data->totalAngle / 360.0); } /*! @@ -256,31 +255,31 @@ int QwtKnob::numTurns() const \sa scaleDraw() */ -void QwtKnob::setScaleDraw( QwtRoundScaleDraw* scaleDraw ) +void QwtKnob::setScaleDraw(QwtRoundScaleDraw *scaleDraw) { - setAbstractScaleDraw( scaleDraw ); - setTotalAngle( m_data->totalAngle ); + setAbstractScaleDraw(scaleDraw); + setTotalAngle(m_data->totalAngle); - updateGeometry(); - update(); + updateGeometry(); + update(); } /*! \return the scale draw of the knob \sa setScaleDraw() */ -const QwtRoundScaleDraw* QwtKnob::scaleDraw() const +const QwtRoundScaleDraw *QwtKnob::scaleDraw() const { - return static_cast< const QwtRoundScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } /*! \return the scale draw of the knob \sa setScaleDraw() */ -QwtRoundScaleDraw* QwtKnob::scaleDraw() +QwtRoundScaleDraw *QwtKnob::scaleDraw() { - return static_cast< QwtRoundScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } /*! @@ -291,49 +290,49 @@ QwtRoundScaleDraw* QwtKnob::scaleDraw() */ QRect QwtKnob::knobRect() const { - const QRect cr = contentsRect(); + const QRect cr = contentsRect(); - const int extent = qwtCeil( scaleDraw()->extent( font() ) ); - const int d = extent + m_data->scaleDist; + const int extent = qwtCeil(scaleDraw()->extent(font())); + const int d = extent + m_data->scaleDist; - int w = m_data->knobWidth; - if ( w <= 0 ) - { - const int dim = qMin( cr.width(), cr.height() ); + int w = m_data->knobWidth; + if (w <= 0) + { + const int dim = qMin(cr.width(), cr.height()); - w = dim - 2 * ( d ); - w = qMax( 0, w ); - } + w = dim - 2 * (d); + w = qMax(0, w); + } - QRect r( 0, 0, w, w ); + QRect r(0, 0, w, w); - if ( m_data->alignment & Qt::AlignLeft ) - { - r.moveLeft( cr.left() + d ); - } - else if ( m_data->alignment & Qt::AlignRight ) - { - r.moveRight( cr.right() - d ); - } - else - { - r.moveCenter( QPoint( cr.center().x(), r.center().y() ) ); - } + if (m_data->alignment & Qt::AlignLeft) + { + r.moveLeft(cr.left() + d); + } + else if (m_data->alignment & Qt::AlignRight) + { + r.moveRight(cr.right() - d); + } + else + { + r.moveCenter(QPoint(cr.center().x(), r.center().y())); + } - if ( m_data->alignment & Qt::AlignTop ) - { - r.moveTop( cr.top() + d ); - } - else if ( m_data->alignment & Qt::AlignBottom ) - { - r.moveBottom( cr.bottom() - d ); - } - else - { - r.moveCenter( QPoint( r.center().x(), cr.center().y() ) ); - } + if (m_data->alignment & Qt::AlignTop) + { + r.moveTop(cr.top() + d); + } + else if (m_data->alignment & Qt::AlignBottom) + { + r.moveBottom(cr.bottom() - d); + } + else + { + r.moveCenter(QPoint(r.center().x(), cr.center().y())); + } - return r; + return r; } /*! @@ -344,22 +343,22 @@ QRect QwtKnob::knobRect() const \retval True, when pos is inside the circle of the knob. \sa scrolledTo() */ -bool QwtKnob::isScrollPosition( const QPoint& pos ) const +bool QwtKnob::isScrollPosition(const QPoint &pos) const { - const QRect kr = knobRect(); + const QRect kr = knobRect(); - const QRegion region( kr, QRegion::Ellipse ); - if ( region.contains( pos ) && ( pos != kr.center() ) ) - { - const double angle = QLineF( kr.center(), pos ).angle(); - const double valueAngle = qwtToDegrees( scaleMap().transform( value() ) ); + const QRegion region(kr, QRegion::Ellipse); + if (region.contains(pos) && (pos != kr.center())) + { + const double angle = QLineF(kr.center(), pos).angle(); + const double valueAngle = qwtToDegrees(scaleMap().transform(value())); - m_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle ); + m_data->mouseOffset = qwtNormalizeDegrees(angle - valueAngle); - return true; - } + return true; + } - return false; + return false; } /*! @@ -370,114 +369,113 @@ bool QwtKnob::isScrollPosition( const QPoint& pos ) const \return Value for the mouse position \sa isScrollPosition() */ -double QwtKnob::scrolledTo( const QPoint& pos ) const +double QwtKnob::scrolledTo(const QPoint &pos) const { - double angle = QLineF( rect().center(), pos ).angle(); - angle = qwtNormalizeDegrees( angle - m_data->mouseOffset ); + double angle = QLineF(rect().center(), pos).angle(); + angle = qwtNormalizeDegrees(angle - m_data->mouseOffset); - if ( scaleMap().pDist() > 360.0 ) + if (scaleMap().pDist() > 360.0) + { + angle = qwtToDegrees(angle); + + const double v = scaleMap().transform(value()); + + int numTurns = qwtFloor((v - scaleMap().p1()) / 360.0); + + double valueAngle = qwtNormalizeDegrees(v); + if (qAbs(valueAngle - angle) > 180.0) { - angle = qwtToDegrees( angle ); - - const double v = scaleMap().transform( value() ); - - int numTurns = qwtFloor( ( v - scaleMap().p1() ) / 360.0 ); - - double valueAngle = qwtNormalizeDegrees( v ); - if ( qAbs( valueAngle - angle ) > 180.0 ) - { - numTurns += ( angle > valueAngle ) ? -1 : 1; - } - - angle += scaleMap().p1() + numTurns * 360.0; - - if ( !wrapping() ) - { - const double boundedAngle = - qBound( scaleMap().p1(), angle, scaleMap().p2() ); - - m_data->mouseOffset += ( boundedAngle - angle ); - angle = boundedAngle; - } - } - else - { - angle = qwtToScaleAngle( angle ); - - double boundedAngle = qBound( scaleMap().p1(), angle, scaleMap().p2() ); - - if ( !wrapping() ) - { - const double currentAngle = scaleMap().transform( value() ); - - if ( ( currentAngle > 90.0 ) && ( boundedAngle < -90.0 ) ) - boundedAngle = scaleMap().p2(); - else if ( ( currentAngle < -90.0 ) && ( boundedAngle > 90.0 ) ) - boundedAngle = scaleMap().p1(); - - m_data->mouseOffset += ( boundedAngle - angle ); - } - - angle = boundedAngle; + numTurns += (angle > valueAngle) ? -1 : 1; } - return scaleMap().invTransform( angle ); + angle += scaleMap().p1() + numTurns * 360.0; + + if (!wrapping()) + { + const double boundedAngle + = qBound(scaleMap().p1(), angle, scaleMap().p2()); + + m_data->mouseOffset += (boundedAngle - angle); + angle = boundedAngle; + } + } + else + { + angle = qwtToScaleAngle(angle); + + double boundedAngle = qBound(scaleMap().p1(), angle, scaleMap().p2()); + + if (!wrapping()) + { + const double currentAngle = scaleMap().transform(value()); + + if ((currentAngle > 90.0) && (boundedAngle < -90.0)) + boundedAngle = scaleMap().p2(); + else if ((currentAngle < -90.0) && (boundedAngle > 90.0)) + boundedAngle = scaleMap().p1(); + + m_data->mouseOffset += (boundedAngle - angle); + } + + angle = boundedAngle; + } + + return scaleMap().invTransform(angle); } /*! Handle QEvent::StyleChange and QEvent::FontChange; \param event Change event */ -void QwtKnob::changeEvent( QEvent* event ) +void QwtKnob::changeEvent(QEvent *event) { - switch( event->type() ) - { - case QEvent::StyleChange: - case QEvent::FontChange: - { - updateGeometry(); - update(); - break; - } - default: - break; + switch (event->type()) + { + case QEvent::StyleChange: + case QEvent::FontChange: { + updateGeometry(); + update(); + break; } + default: + break; + } } /*! Repaint the knob \param event Paint event */ -void QwtKnob::paintEvent( QPaintEvent* event ) +void QwtKnob::paintEvent(QPaintEvent *event) { - const QRectF knobRect = this->knobRect(); + const QRectF knobRect = this->knobRect(); - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - painter.setRenderHint( QPainter::Antialiasing, true ); + painter.setRenderHint(QPainter::Antialiasing, true); - if ( !knobRect.contains( event->region().boundingRect() ) ) - { - scaleDraw()->setRadius( 0.5 * knobRect.width() + m_data->scaleDist ); - scaleDraw()->moveCenter( knobRect.center() ); + if (!knobRect.contains(event->region().boundingRect())) + { + scaleDraw()->setRadius(0.5 * knobRect.width() + m_data->scaleDist); + scaleDraw()->moveCenter(knobRect.center()); - scaleDraw()->draw( &painter, palette() ); - } + scaleDraw()->draw(&painter, palette()); + } - drawKnob( &painter, knobRect ); + drawKnob(&painter, knobRect); - drawMarker( &painter, knobRect, - qwtNormalizeDegrees( scaleMap().transform( value() ) ) ); + drawMarker(&painter, knobRect, + qwtNormalizeDegrees(scaleMap().transform(value()))); - painter.setRenderHint( QPainter::Antialiasing, false ); + painter.setRenderHint(QPainter::Antialiasing, false); - if ( hasFocus() ) - drawFocusIndicator( &painter ); + if (hasFocus()) + drawFocusIndicator(&painter); } /*! @@ -486,85 +484,79 @@ void QwtKnob::paintEvent( QPaintEvent* event ) \param painter painter \param knobRect Bounding rectangle of the knob (without scale) */ -void QwtKnob::drawKnob( QPainter* painter, const QRectF& knobRect ) const +void QwtKnob::drawKnob(QPainter *painter, const QRectF &knobRect) const { - double dim = qMin( knobRect.width(), knobRect.height() ); - dim -= m_data->borderWidth * 0.5; + double dim = qMin(knobRect.width(), knobRect.height()); + dim -= m_data->borderWidth * 0.5; - QRectF aRect( 0, 0, dim, dim ); - aRect.moveCenter( knobRect.center() ); + QRectF aRect(0, 0, dim, dim); + aRect.moveCenter(knobRect.center()); - QPen pen( Qt::NoPen ); - if ( m_data->borderWidth > 0 ) - { - QColor c1 = palette().color( QPalette::Light ); - QColor c2 = palette().color( QPalette::Dark ); + QPen pen(Qt::NoPen); + if (m_data->borderWidth > 0) + { + QColor c1 = palette().color(QPalette::Light); + QColor c2 = palette().color(QPalette::Dark); - QLinearGradient gradient( aRect.topLeft(), aRect.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 0.3, c1 ); - gradient.setColorAt( 0.7, c2 ); - gradient.setColorAt( 1.0, c2 ); + QLinearGradient gradient(aRect.topLeft(), aRect.bottomRight()); + gradient.setColorAt(0.0, c1); + gradient.setColorAt(0.3, c1); + gradient.setColorAt(0.7, c2); + gradient.setColorAt(1.0, c2); - pen = QPen( gradient, m_data->borderWidth ); + pen = QPen(gradient, m_data->borderWidth); + } + + QBrush brush; + switch (m_data->knobStyle) + { + case QwtKnob::Raised: { + double off = 0.3 * knobRect.width(); + QRadialGradient gradient(knobRect.center(), knobRect.width(), + knobRect.topLeft() + QPointF(off, off)); + + gradient.setColorAt(0.0, palette().color(QPalette::Midlight)); + gradient.setColorAt(1.0, palette().color(QPalette::Button)); + + brush = QBrush(gradient); + + break; } + case QwtKnob::Styled: { + QRadialGradient gradient(knobRect.center().x() - knobRect.width() / 3, + knobRect.center().y() - knobRect.height() / 2, + knobRect.width() * 1.3, knobRect.center().x(), + knobRect.center().y() - knobRect.height() / 2); - QBrush brush; - switch( m_data->knobStyle ) - { - case QwtKnob::Raised: - { - double off = 0.3 * knobRect.width(); - QRadialGradient gradient( knobRect.center(), - knobRect.width(), knobRect.topLeft() + QPointF( off, off ) ); + const QColor c = palette().color(QPalette::Button); + gradient.setColorAt(0, c.lighter(110)); + gradient.setColorAt(0.5, c); + gradient.setColorAt(0.501, c.darker(102)); + gradient.setColorAt(1, c.darker(115)); - gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) ); - gradient.setColorAt( 1.0, palette().color( QPalette::Button ) ); + brush = QBrush(gradient); - brush = QBrush( gradient ); - - break; - } - case QwtKnob::Styled: - { - QRadialGradient gradient(knobRect.center().x() - knobRect.width() / 3, - knobRect.center().y() - knobRect.height() / 2, - knobRect.width() * 1.3, - knobRect.center().x(), - knobRect.center().y() - knobRect.height() / 2); - - const QColor c = palette().color( QPalette::Button ); - gradient.setColorAt(0, c.lighter(110) ); - gradient.setColorAt( 0.5, c); - gradient.setColorAt( 0.501, c.darker(102) ); - gradient.setColorAt(1, c.darker(115) ); - - brush = QBrush( gradient ); - - break; - } - case QwtKnob::Sunken: - { - QLinearGradient gradient( - knobRect.topLeft(), knobRect.bottomRight() ); - gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) ); - gradient.setColorAt( 0.5, palette().color( QPalette::Button ) ); - gradient.setColorAt( 1.0, palette().color( QPalette::Midlight ) ); - brush = QBrush( gradient ); - - break; - } - case QwtKnob::Flat: - default: - brush = palette().brush( QPalette::Button ); + break; } + case QwtKnob::Sunken: { + QLinearGradient gradient(knobRect.topLeft(), knobRect.bottomRight()); + gradient.setColorAt(0.0, palette().color(QPalette::Mid)); + gradient.setColorAt(0.5, palette().color(QPalette::Button)); + gradient.setColorAt(1.0, palette().color(QPalette::Midlight)); + brush = QBrush(gradient); - painter->setPen( pen ); - painter->setBrush( brush ); - painter->drawEllipse( aRect ); + break; + } + case QwtKnob::Flat: + default: + brush = palette().brush(QPalette::Button); + } + + painter->setPen(pen); + painter->setBrush(brush); + painter->drawEllipse(aRect); } - /*! \brief Draw the marker at the knob's front @@ -573,146 +565,141 @@ void QwtKnob::drawKnob( QPainter* painter, const QRectF& knobRect ) const \param angle Angle of the marker in degrees ( clockwise, 0 at the 12 o'clock position ) */ -void QwtKnob::drawMarker( QPainter* painter, - const QRectF& rect, double angle ) const +void QwtKnob::drawMarker(QPainter *painter, const QRectF &rect, + double angle) const { - if ( m_data->markerStyle == NoMarker || !isValid() ) - return; + if (m_data->markerStyle == NoMarker || !isValid()) + return; - const double radians = qwtRadians( angle ); - const double sinA = -qFastSin( radians ); - const double cosA = qFastCos( radians ); + const double radians = qwtRadians(angle); + const double sinA = -qFastSin(radians); + const double cosA = qFastCos(radians); - const double xm = rect.center().x(); - const double ym = rect.center().y(); - const double margin = 4.0; + const double xm = rect.center().x(); + const double ym = rect.center().y(); + const double margin = 4.0; - double radius = 0.5 * ( rect.width() - m_data->borderWidth ) - margin; - if ( radius < 1.0 ) - radius = 1.0; + double radius = 0.5 * (rect.width() - m_data->borderWidth) - margin; + if (radius < 1.0) + radius = 1.0; - double markerSize = m_data->markerSize; - if ( markerSize <= 0 ) - markerSize = qRound( 0.4 * radius ); + double markerSize = m_data->markerSize; + if (markerSize <= 0) + markerSize = qRound(0.4 * radius); - switch ( m_data->markerStyle ) - { - case Notch: - case Nub: - { - const double dotWidth = qwtMinF( markerSize, radius ); + switch (m_data->markerStyle) + { + case Notch: + case Nub: { + const double dotWidth = qwtMinF(markerSize, radius); - const double dotCenterDist = radius - 0.5 * dotWidth; - if ( dotCenterDist > 0.0 ) - { - const QPointF center( xm - sinA * dotCenterDist, - ym - cosA * dotCenterDist ); + const double dotCenterDist = radius - 0.5 * dotWidth; + if (dotCenterDist > 0.0) + { + const QPointF center(xm - sinA * dotCenterDist, + ym - cosA * dotCenterDist); - QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth ); - ellipse.moveCenter( center ); + QRectF ellipse(0.0, 0.0, dotWidth, dotWidth); + ellipse.moveCenter(center); - QColor c1 = palette().color( QPalette::Light ); - QColor c2 = palette().color( QPalette::Mid ); + QColor c1 = palette().color(QPalette::Light); + QColor c2 = palette().color(QPalette::Mid); - if ( m_data->markerStyle == Notch ) - qSwap( c1, c2 ); + if (m_data->markerStyle == Notch) + qSwap(c1, c2); - QLinearGradient gradient( - ellipse.topLeft(), ellipse.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 1.0, c2 ); + QLinearGradient gradient(ellipse.topLeft(), ellipse.bottomRight()); + gradient.setColorAt(0.0, c1); + gradient.setColorAt(1.0, c2); - painter->setPen( Qt::NoPen ); - painter->setBrush( gradient ); + painter->setPen(Qt::NoPen); + painter->setBrush(gradient); - painter->drawEllipse( ellipse ); - } - break; - } - case Dot: - { - const double dotWidth = qwtMinF( markerSize, radius); - - const double dotCenterDist = radius - 0.5 * dotWidth; - if ( dotCenterDist > 0.0 ) - { - const QPointF center( xm - sinA * dotCenterDist, - ym - cosA * dotCenterDist ); - - QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth ); - ellipse.moveCenter( center ); - - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().color( QPalette::ButtonText ) ); - painter->drawEllipse( ellipse ); - } - - break; - } - case Tick: - { - const double rb = qwtMaxF( radius - markerSize, 1.0 ); - const double re = radius; - - const QLineF line( xm - sinA * rb, ym - cosA * rb, - xm - sinA * re, ym - cosA * re ); - - QPen pen( palette().color( QPalette::ButtonText ), 0 ); - pen.setCapStyle( Qt::FlatCap ); - painter->setPen( pen ); - painter->drawLine ( line ); - - break; - } - case Triangle: - { - const double rb = qwtMaxF( radius - markerSize, 1.0 ); - const double re = radius; - - painter->translate( rect.center() ); - painter->rotate( angle - 90.0 ); - - QPolygonF polygon; - polygon += QPointF( re, 0.0 ); - polygon += QPointF( rb, 0.5 * ( re - rb ) ); - polygon += QPointF( rb, -0.5 * ( re - rb ) ); - - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().color( QPalette::ButtonText ) ); - painter->drawPolygon( polygon ); - - painter->resetTransform(); - - break; - } - default: - break; + painter->drawEllipse(ellipse); + } + break; } + case Dot: { + const double dotWidth = qwtMinF(markerSize, radius); + + const double dotCenterDist = radius - 0.5 * dotWidth; + if (dotCenterDist > 0.0) + { + const QPointF center(xm - sinA * dotCenterDist, + ym - cosA * dotCenterDist); + + QRectF ellipse(0.0, 0.0, dotWidth, dotWidth); + ellipse.moveCenter(center); + + painter->setPen(Qt::NoPen); + painter->setBrush(palette().color(QPalette::ButtonText)); + painter->drawEllipse(ellipse); + } + + break; + } + case Tick: { + const double rb = qwtMaxF(radius - markerSize, 1.0); + const double re = radius; + + const QLineF line(xm - sinA * rb, ym - cosA * rb, xm - sinA * re, + ym - cosA * re); + + QPen pen(palette().color(QPalette::ButtonText), 0); + pen.setCapStyle(Qt::FlatCap); + painter->setPen(pen); + painter->drawLine(line); + + break; + } + case Triangle: { + const double rb = qwtMaxF(radius - markerSize, 1.0); + const double re = radius; + + painter->translate(rect.center()); + painter->rotate(angle - 90.0); + + QPolygonF polygon; + polygon += QPointF(re, 0.0); + polygon += QPointF(rb, 0.5 * (re - rb)); + polygon += QPointF(rb, -0.5 * (re - rb)); + + painter->setPen(Qt::NoPen); + painter->setBrush(palette().color(QPalette::ButtonText)); + painter->drawPolygon(polygon); + + painter->resetTransform(); + + break; + } + default: + break; + } } /*! Draw the focus indicator \param painter Painter */ -void QwtKnob::drawFocusIndicator( QPainter* painter ) const +void QwtKnob::drawFocusIndicator(QPainter *painter) const { - const QRect cr = contentsRect(); + const QRect cr = contentsRect(); - int w = m_data->knobWidth; - if ( w <= 0 ) - { - w = qMin( cr.width(), cr.height() ); - } - else - { - const int extent = qCeil( scaleDraw()->extent( font() ) ); - w += 2 * ( extent + m_data->scaleDist ); - } + int w = m_data->knobWidth; + if (w <= 0) + { + w = qMin(cr.width(), cr.height()); + } + else + { + const int extent = qCeil(scaleDraw()->extent(font())); + w += 2 * (extent + m_data->scaleDist); + } - QRect focusRect( 0, 0, w, w ); - focusRect.moveCenter( cr.center() ); + QRect focusRect(0, 0, w, w); + focusRect.moveCenter(cr.center()); - QwtPainter::drawFocusRect( painter, this, focusRect ); + QwtPainter::drawFocusRect(painter, this, focusRect); } /*! @@ -727,13 +714,13 @@ void QwtKnob::drawFocusIndicator( QPainter* painter ) const \sa alignment(), setKnobWidth(), knobRect() */ -void QwtKnob::setAlignment( Qt::Alignment alignment ) +void QwtKnob::setAlignment(Qt::Alignment alignment) { - if ( m_data->alignment != alignment ) - { - m_data->alignment = alignment; - update(); - } + if (m_data->alignment != alignment) + { + m_data->alignment = alignment; + update(); + } } /*! @@ -742,7 +729,7 @@ void QwtKnob::setAlignment( Qt::Alignment alignment ) */ Qt::Alignment QwtKnob::alignment() const { - return m_data->alignment; + return m_data->alignment; } /*! @@ -756,49 +743,49 @@ Qt::Alignment QwtKnob::alignment() const \sa knobWidth(), setAlignment() \note Modifies the sizePolicy() */ -void QwtKnob::setKnobWidth( int width ) +void QwtKnob::setKnobWidth(int width) { - width = qMax( width, 0 ); + width = qMax(width, 0); - if ( width != m_data->knobWidth ) - { - QSizePolicy::Policy policy; - if ( width > 0 ) - policy = QSizePolicy::Minimum; - else - policy = QSizePolicy::MinimumExpanding; + if (width != m_data->knobWidth) + { + QSizePolicy::Policy policy; + if (width > 0) + policy = QSizePolicy::Minimum; + else + policy = QSizePolicy::MinimumExpanding; - setSizePolicy( policy, policy ); + setSizePolicy(policy, policy); - m_data->knobWidth = width; + m_data->knobWidth = width; - updateGeometry(); - update(); - } + updateGeometry(); + update(); + } } //! Return the width of the knob int QwtKnob::knobWidth() const { - return m_data->knobWidth; + return m_data->knobWidth; } /*! \brief Set the knob's border width \param borderWidth new border width */ -void QwtKnob::setBorderWidth( int borderWidth ) +void QwtKnob::setBorderWidth(int borderWidth) { - m_data->borderWidth = qMax( borderWidth, 0 ); + m_data->borderWidth = qMax(borderWidth, 0); - updateGeometry(); - update(); + updateGeometry(); + update(); } //! Return the border width int QwtKnob::borderWidth() const { - return m_data->borderWidth; + return m_data->borderWidth; } /*! @@ -809,13 +796,13 @@ int QwtKnob::borderWidth() const \sa markerSize(), markerStyle() */ -void QwtKnob::setMarkerSize( int size ) +void QwtKnob::setMarkerSize(int size) { - if ( m_data->markerSize != size ) - { - m_data->markerSize = size; - update(); - } + if (m_data->markerSize != size) + { + m_data->markerSize = size; + update(); + } } /*! @@ -824,7 +811,7 @@ void QwtKnob::setMarkerSize( int size ) */ int QwtKnob::markerSize() const { - return m_data->markerSize; + return m_data->markerSize; } /*! @@ -832,8 +819,8 @@ int QwtKnob::markerSize() const */ QSize QwtKnob::sizeHint() const { - const QSize hint = qwtKnobSizeHint( this, 50 ); - return qwtExpandedToGlobalStrut( hint ); + const QSize hint = qwtKnobSizeHint(this, 50); + return qwtExpandedToGlobalStrut(hint); } /*! @@ -842,9 +829,9 @@ QSize QwtKnob::sizeHint() const */ QSize QwtKnob::minimumSizeHint() const { - return qwtKnobSizeHint( this, 20 ); + return qwtKnobSizeHint(this, 20); } #if QWT_MOC_INCLUDE -#include "moc_qwt_knob.cpp" +# include "moc_qwt_knob.cpp" #endif diff --git a/libs/qwt/src/qwt_knob.h b/libs/qwt/src/qwt_knob.h index 9d8c7a65..0c93b16a 100644 --- a/libs/qwt/src/qwt_knob.h +++ b/libs/qwt/src/qwt_knob.h @@ -41,138 +41,137 @@ class QwtRoundScaleDraw; class QWT_EXPORT QwtKnob : public QwtAbstractSlider { - Q_OBJECT + Q_OBJECT - Q_ENUMS ( KnobStyle MarkerStyle ) + Q_ENUMS(KnobStyle MarkerStyle) - Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle ) - Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth ) - Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment ) - Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle ) - Q_PROPERTY( int numTurns READ numTurns WRITE setNumTurns ) - Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle ) - Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) + Q_PROPERTY(KnobStyle knobStyle READ knobStyle WRITE setKnobStyle) + Q_PROPERTY(int knobWidth READ knobWidth WRITE setKnobWidth) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) + Q_PROPERTY(double totalAngle READ totalAngle WRITE setTotalAngle) + Q_PROPERTY(int numTurns READ numTurns WRITE setNumTurns) + Q_PROPERTY(MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle) + Q_PROPERTY(int markerSize READ markerSize WRITE setMarkerSize) + Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) - public: - /*! - \brief Style of the knob surface +public: + /*! + \brief Style of the knob surface - Depending on the KnobStyle the surface of the knob is - filled from the brushes of the widget palette(). + Depending on the KnobStyle the surface of the knob is + filled from the brushes of the widget palette(). - \sa setKnobStyle(), knobStyle() - */ - enum KnobStyle - { - //! Fill the knob with a brush from QPalette::Button. - Flat, + \sa setKnobStyle(), knobStyle() + */ + enum KnobStyle + { + //! Fill the knob with a brush from QPalette::Button. + Flat, - //! Build a gradient from QPalette::Midlight and QPalette::Button - Raised, - - /*! - Build a gradient from QPalette::Midlight, QPalette::Button - and QPalette::Midlight - */ - Sunken, - - /*! - Build a radial gradient from QPalette::Button - like it is used for QDial in various Qt styles. - */ - Styled - }; + //! Build a gradient from QPalette::Midlight and QPalette::Button + Raised, /*! - \brief Marker type - - The marker indicates the current value on the knob - The default setting is a Notch marker. - - \sa setMarkerStyle(), setMarkerSize() + Build a gradient from QPalette::Midlight, QPalette::Button + and QPalette::Midlight */ - enum MarkerStyle - { - //! Don't paint any marker - NoMarker = -1, + Sunken, - //! Paint a single tick in QPalette::ButtonText color - Tick, + /*! + Build a radial gradient from QPalette::Button + like it is used for QDial in various Qt styles. + */ + Styled + }; - //! Paint a triangle in QPalette::ButtonText color - Triangle, + /*! + \brief Marker type - //! Paint a circle in QPalette::ButtonText color - Dot, + The marker indicates the current value on the knob + The default setting is a Notch marker. - /*! - Draw a raised ellipse with a gradient build from - QPalette::Light and QPalette::Mid - */ - Nub, + \sa setMarkerStyle(), setMarkerSize() + */ + enum MarkerStyle + { + //! Don't paint any marker + NoMarker = -1, - /*! - Draw a sunken ellipse with a gradient build from - QPalette::Light and QPalette::Mid - */ - Notch - }; + //! Paint a single tick in QPalette::ButtonText color + Tick, - explicit QwtKnob( QWidget* parent = NULL ); - virtual ~QwtKnob(); + //! Paint a triangle in QPalette::ButtonText color + Triangle, - void setAlignment( Qt::Alignment ); - Qt::Alignment alignment() const; + //! Paint a circle in QPalette::ButtonText color + Dot, - void setKnobWidth( int ); - int knobWidth() const; + /*! + Draw a raised ellipse with a gradient build from + QPalette::Light and QPalette::Mid + */ + Nub, - void setNumTurns( int ); - int numTurns() const; + /*! + Draw a sunken ellipse with a gradient build from + QPalette::Light and QPalette::Mid + */ + Notch + }; - void setTotalAngle ( double angle ); - double totalAngle() const; + explicit QwtKnob(QWidget *parent = NULL); + virtual ~QwtKnob(); - void setKnobStyle( KnobStyle ); - KnobStyle knobStyle() const; + void setAlignment(Qt::Alignment); + Qt::Alignment alignment() const; - void setBorderWidth( int ); - int borderWidth() const; + void setKnobWidth(int); + int knobWidth() const; - void setMarkerStyle( MarkerStyle ); - MarkerStyle markerStyle() const; + void setNumTurns(int); + int numTurns() const; - void setMarkerSize( int ); - int markerSize() const; + void setTotalAngle(double angle); + double totalAngle() const; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + void setKnobStyle(KnobStyle); + KnobStyle knobStyle() const; - void setScaleDraw( QwtRoundScaleDraw* ); + void setBorderWidth(int); + int borderWidth() const; - const QwtRoundScaleDraw* scaleDraw() const; - QwtRoundScaleDraw* scaleDraw(); + void setMarkerStyle(MarkerStyle); + MarkerStyle markerStyle() const; - QRect knobRect() const; + void setMarkerSize(int); + int markerSize() const; - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void changeEvent( QEvent* ) QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual void drawKnob( QPainter*, const QRectF& ) const; + void setScaleDraw(QwtRoundScaleDraw *); - virtual void drawFocusIndicator( QPainter* ) const; + const QwtRoundScaleDraw *scaleDraw() const; + QwtRoundScaleDraw *scaleDraw(); - virtual void drawMarker( QPainter*, - const QRectF&, double angle ) const; + QRect knobRect() const; - virtual double scrolledTo( const QPoint& ) const QWT_OVERRIDE; - virtual bool isScrollPosition( const QPoint& ) const QWT_OVERRIDE; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void changeEvent(QEvent *) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; + virtual void drawKnob(QPainter *, const QRectF &) const; + + virtual void drawFocusIndicator(QPainter *) const; + + virtual void drawMarker(QPainter *, const QRectF &, double angle) const; + + virtual double scrolledTo(const QPoint &) const QWT_OVERRIDE; + virtual bool isScrollPosition(const QPoint &) const QWT_OVERRIDE; + +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_legend.cpp b/libs/qwt/src/qwt_legend.cpp index ce3c0294..63fdbe17 100644 --- a/libs/qwt/src/qwt_legend.cpp +++ b/libs/qwt/src/qwt_legend.cpp @@ -22,265 +22,265 @@ namespace QwtLegendPrivate { - class LegendMap +class LegendMap +{ +public: + inline bool isEmpty() const { return m_entries.isEmpty(); } + + void insert(const QVariant &, const QList &); + void remove(const QVariant &); + + void removeWidget(const QWidget *); + + QList legendWidgets(const QVariant &) const; + QVariant itemInfo(const QWidget *) const; + +private: + // we don't know anything about itemInfo and therefore don't have + // any key that can be used for a map or hashtab. + // But a simple linear list is o.k. here, as we will never have + // more than a few entries. + + class Entry + { + public: + QVariant itemInfo; + QList widgets; + }; + + QList m_entries; +}; + +void LegendMap::insert(const QVariant &itemInfo, + const QList &widgets) +{ + for (int i = 0; i < m_entries.size(); i++) + { + Entry &entry = m_entries[i]; + if (entry.itemInfo == itemInfo) { - public: - inline bool isEmpty() const { return m_entries.isEmpty(); } - - void insert( const QVariant&, const QList< QWidget* >& ); - void remove( const QVariant& ); - - void removeWidget( const QWidget* ); - - QList< QWidget* > legendWidgets( const QVariant& ) const; - QVariant itemInfo( const QWidget* ) const; - - private: - // we don't know anything about itemInfo and therefore don't have - // any key that can be used for a map or hashtab. - // But a simple linear list is o.k. here, as we will never have - // more than a few entries. - - class Entry - { - public: - QVariant itemInfo; - QList< QWidget* > widgets; - }; - - QList< Entry > m_entries; - }; - - void LegendMap::insert( const QVariant& itemInfo, - const QList< QWidget* >& widgets ) - { - for ( int i = 0; i < m_entries.size(); i++ ) - { - Entry& entry = m_entries[i]; - if ( entry.itemInfo == itemInfo ) - { - entry.widgets = widgets; - return; - } - } - - Entry newEntry; - newEntry.itemInfo = itemInfo; - newEntry.widgets = widgets; - - m_entries += newEntry; + entry.widgets = widgets; + return; } + } - void LegendMap::remove( const QVariant& itemInfo ) - { - for ( int i = 0; i < m_entries.size(); i++ ) - { - Entry& entry = m_entries[i]; - if ( entry.itemInfo == itemInfo ) - { - m_entries.removeAt( i ); - return; - } - } - } + Entry newEntry; + newEntry.itemInfo = itemInfo; + newEntry.widgets = widgets; - void LegendMap::removeWidget( const QWidget* widget ) - { - QWidget* w = const_cast< QWidget* >( widget ); - - for ( int i = 0; i < m_entries.size(); i++ ) - m_entries[ i ].widgets.removeAll( w ); - } - - QVariant LegendMap::itemInfo( const QWidget* widget ) const - { - if ( widget != NULL ) - { - QWidget* w = const_cast< QWidget* >( widget ); - - for ( int i = 0; i < m_entries.size(); i++ ) - { - const Entry& entry = m_entries[i]; - if ( entry.widgets.indexOf( w ) >= 0 ) - return entry.itemInfo; - } - } - - return QVariant(); - } - - QList< QWidget* > LegendMap::legendWidgets( const QVariant& itemInfo ) const - { - if ( itemInfo.isValid() ) - { - for ( int i = 0; i < m_entries.size(); i++ ) - { - const Entry& entry = m_entries[i]; - if ( entry.itemInfo == itemInfo ) - return entry.widgets; - } - } - - return QList< QWidget* >(); - } + m_entries += newEntry; } +void LegendMap::remove(const QVariant &itemInfo) +{ + for (int i = 0; i < m_entries.size(); i++) + { + Entry &entry = m_entries[i]; + if (entry.itemInfo == itemInfo) + { + m_entries.removeAt(i); + return; + } + } +} + +void LegendMap::removeWidget(const QWidget *widget) +{ + QWidget *w = const_cast(widget); + + for (int i = 0; i < m_entries.size(); i++) + m_entries[i].widgets.removeAll(w); +} + +QVariant LegendMap::itemInfo(const QWidget *widget) const +{ + if (widget != NULL) + { + QWidget *w = const_cast(widget); + + for (int i = 0; i < m_entries.size(); i++) + { + const Entry &entry = m_entries[i]; + if (entry.widgets.indexOf(w) >= 0) + return entry.itemInfo; + } + } + + return QVariant(); +} + +QList LegendMap::legendWidgets(const QVariant &itemInfo) const +{ + if (itemInfo.isValid()) + { + for (int i = 0; i < m_entries.size(); i++) + { + const Entry &entry = m_entries[i]; + if (entry.itemInfo == itemInfo) + return entry.widgets; + } + } + + return QList(); +} +} // namespace QwtLegendPrivate + class QwtLegend::PrivateData { - public: - PrivateData() - : itemMode( QwtLegendData::ReadOnly ) - , view( NULL ) - { - } +public: + PrivateData() + : itemMode(QwtLegendData::ReadOnly) + , view(NULL) + { + } - QwtLegendData::Mode itemMode; - QwtLegendPrivate::LegendMap itemMap; + QwtLegendData::Mode itemMode; + QwtLegendPrivate::LegendMap itemMap; - class LegendView; - LegendView* view; + class LegendView; + LegendView *view; }; class QwtLegend::PrivateData::LegendView QWT_FINAL : public QScrollArea { - public: - explicit LegendView( QWidget * parent ) : - QScrollArea( parent ) +public: + explicit LegendView(QWidget *parent) + : QScrollArea(parent) + { + contentsWidget = new QWidget(this); + contentsWidget->setObjectName("QwtLegendViewContents"); + + setWidget(contentsWidget); + setWidgetResizable(false); + + viewport()->setObjectName("QwtLegendViewport"); + + // QScrollArea::setWidget internally sets autoFillBackground to true + // But we don't want a background. + contentsWidget->setAutoFillBackground(false); + viewport()->setAutoFillBackground(false); + } + + virtual bool event(QEvent *event) QWT_OVERRIDE + { + if (event->type() == QEvent::PolishRequest) { - contentsWidget = new QWidget( this ); - contentsWidget->setObjectName( "QwtLegendViewContents" ); - - setWidget( contentsWidget ); - setWidgetResizable( false ); - - viewport()->setObjectName( "QwtLegendViewport" ); - - // QScrollArea::setWidget internally sets autoFillBackground to true - // But we don't want a background. - contentsWidget->setAutoFillBackground( false ); - viewport()->setAutoFillBackground( false ); + setFocusPolicy(Qt::NoFocus); } - virtual bool event( QEvent* event ) QWT_OVERRIDE + if (event->type() == QEvent::Resize) { - if ( event->type() == QEvent::PolishRequest ) - { - setFocusPolicy( Qt::NoFocus ); - } + // adjust the size to en/disable the scrollbars + // before QScrollArea adjusts the viewport size - if ( event->type() == QEvent::Resize ) - { - // adjust the size to en/disable the scrollbars - // before QScrollArea adjusts the viewport size + const QRect cr = contentsRect(); - const QRect cr = contentsRect(); + int w = cr.width(); + int h = contentsWidget->heightForWidth(cr.width()); + if (h > w) + { + w -= verticalScrollBar()->sizeHint().width(); + h = contentsWidget->heightForWidth(w); + } - int w = cr.width(); - int h = contentsWidget->heightForWidth( cr.width() ); - if ( h > w ) - { - w -= verticalScrollBar()->sizeHint().width(); - h = contentsWidget->heightForWidth( w ); - } - - contentsWidget->resize( w, h ); - } - - return QScrollArea::event( event ); + contentsWidget->resize(w, h); } - virtual bool viewportEvent( QEvent* event ) QWT_OVERRIDE - { - bool ok = QScrollArea::viewportEvent( event ); + return QScrollArea::event(event); + } - if ( event->type() == QEvent::Resize ) - { - layoutContents(); - } - return ok; + virtual bool viewportEvent(QEvent *event) QWT_OVERRIDE + { + bool ok = QScrollArea::viewportEvent(event); + + if (event->type() == QEvent::Resize) + { + layoutContents(); + } + return ok; + } + + QSize viewportSize(int w, int h) const + { + const int sbHeight = horizontalScrollBar()->sizeHint().height(); + const int sbWidth = verticalScrollBar()->sizeHint().width(); + + const int cw = contentsRect().width(); + const int ch = contentsRect().height(); + + int vw = cw; + int vh = ch; + + if (w > vw) + vh -= sbHeight; + + if (h > vh) + { + vw -= sbWidth; + if (w > vw && vh == ch) + vh -= sbHeight; + } + return QSize(vw, vh); + } + + void layoutContents() + { + const QwtDynGridLayout *tl + = qobject_cast(contentsWidget->layout()); + if (tl == NULL) + return; + + const QSize visibleSize = viewport()->contentsRect().size(); + + const QMargins m = tl->contentsMargins(); + const int minW = tl->maxItemWidth() + m.left() + m.right(); + + int w = qMax(visibleSize.width(), minW); + int h = qMax(tl->heightForWidth(w), visibleSize.height()); + + const int vpWidth = viewportSize(w, h).width(); + if (w > vpWidth) + { + w = qMax(vpWidth, minW); + h = qMax(tl->heightForWidth(w), visibleSize.height()); } - QSize viewportSize( int w, int h ) const - { - const int sbHeight = horizontalScrollBar()->sizeHint().height(); - const int sbWidth = verticalScrollBar()->sizeHint().width(); + contentsWidget->resize(w, h); + } - const int cw = contentsRect().width(); - const int ch = contentsRect().height(); - - int vw = cw; - int vh = ch; - - if ( w > vw ) - vh -= sbHeight; - - if ( h > vh ) - { - vw -= sbWidth; - if ( w > vw && vh == ch ) - vh -= sbHeight; - } - return QSize( vw, vh ); - } - - void layoutContents() - { - const QwtDynGridLayout* tl = qobject_cast< QwtDynGridLayout* >( - contentsWidget->layout() ); - if ( tl == NULL ) - return; - - const QSize visibleSize = viewport()->contentsRect().size(); - - const QMargins m = tl->contentsMargins(); - const int minW = tl->maxItemWidth() + m.left() + m.right(); - - int w = qMax( visibleSize.width(), minW ); - int h = qMax( tl->heightForWidth( w ), visibleSize.height() ); - - const int vpWidth = viewportSize( w, h ).width(); - if ( w > vpWidth ) - { - w = qMax( vpWidth, minW ); - h = qMax( tl->heightForWidth( w ), visibleSize.height() ); - } - - contentsWidget->resize( w, h ); - } - - QWidget* contentsWidget; + QWidget *contentsWidget; }; /*! Constructor \param parent Parent widget */ -QwtLegend::QwtLegend( QWidget* parent ) - : QwtAbstractLegend( parent ) +QwtLegend::QwtLegend(QWidget *parent) + : QwtAbstractLegend(parent) { - setFrameStyle( NoFrame ); + setFrameStyle(NoFrame); - m_data = new QwtLegend::PrivateData; + m_data = new QwtLegend::PrivateData; - m_data->view = new QwtLegend::PrivateData::LegendView( this ); - m_data->view->setObjectName( "QwtLegendView" ); - m_data->view->setFrameStyle( NoFrame ); + m_data->view = new QwtLegend::PrivateData::LegendView(this); + m_data->view->setObjectName("QwtLegendView"); + m_data->view->setFrameStyle(NoFrame); - QwtDynGridLayout* gridLayout = new QwtDynGridLayout( - m_data->view->contentsWidget ); - gridLayout->setAlignment( Qt::AlignHCenter | Qt::AlignTop ); + QwtDynGridLayout *gridLayout + = new QwtDynGridLayout(m_data->view->contentsWidget); + gridLayout->setAlignment(Qt::AlignHCenter | Qt::AlignTop); - m_data->view->contentsWidget->installEventFilter( this ); + m_data->view->contentsWidget->installEventFilter(this); - QVBoxLayout* layout = new QVBoxLayout( this ); - layout->setContentsMargins( 0, 0, 0, 0 ); - layout->addWidget( m_data->view ); + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(m_data->view); } //! Destructor QwtLegend::~QwtLegend() { - delete m_data; + delete m_data; } /*! @@ -293,14 +293,14 @@ QwtLegend::~QwtLegend() \sa maxColumns(), QwtDynGridLayout::setMaxColumns() */ -void QwtLegend::setMaxColumns( uint numColums ) +void QwtLegend::setMaxColumns(uint numColums) { - QwtDynGridLayout* tl = qobject_cast< QwtDynGridLayout* >( - m_data->view->contentsWidget->layout() ); - if ( tl ) - tl->setMaxColumns( numColums ); + QwtDynGridLayout *tl = qobject_cast( + m_data->view->contentsWidget->layout()); + if (tl) + tl->setMaxColumns(numColums); - updateGeometry(); + updateGeometry(); } /*! @@ -309,14 +309,14 @@ void QwtLegend::setMaxColumns( uint numColums ) */ uint QwtLegend::maxColumns() const { - uint maxCols = 0; + uint maxCols = 0; - const QwtDynGridLayout* tl = qobject_cast< const QwtDynGridLayout* >( - m_data->view->contentsWidget->layout() ); - if ( tl ) - maxCols = tl->maxColumns(); + const QwtDynGridLayout *tl = qobject_cast( + m_data->view->contentsWidget->layout()); + if (tl) + maxCols = tl->maxColumns(); - return maxCols; + return maxCols; } /*! @@ -332,9 +332,9 @@ uint QwtLegend::maxColumns() const \sa itemMode(), QwtLegendData::value(), QwtPlotItem::legendData() \note Changing the mode doesn't have any effect on existing labels. */ -void QwtLegend::setDefaultItemMode( QwtLegendData::Mode mode ) +void QwtLegend::setDefaultItemMode(QwtLegendData::Mode mode) { - m_data->itemMode = mode; + m_data->itemMode = mode; } /*! @@ -343,7 +343,7 @@ void QwtLegend::setDefaultItemMode( QwtLegendData::Mode mode ) */ QwtLegendData::Mode QwtLegend::defaultItemMode() const { - return m_data->itemMode; + return m_data->itemMode; } /*! @@ -352,27 +352,27 @@ QwtLegendData::Mode QwtLegend::defaultItemMode() const \return Container widget of the legend items */ -QWidget* QwtLegend::contentsWidget() +QWidget *QwtLegend::contentsWidget() { - return m_data->view->contentsWidget; + return m_data->view->contentsWidget; } /*! \return Horizontal scrollbar \sa verticalScrollBar() */ -QScrollBar* QwtLegend::horizontalScrollBar() const +QScrollBar *QwtLegend::horizontalScrollBar() const { - return m_data->view->horizontalScrollBar(); + return m_data->view->horizontalScrollBar(); } /*! \return Vertical scrollbar \sa horizontalScrollBar() */ -QScrollBar* QwtLegend::verticalScrollBar() const +QScrollBar *QwtLegend::verticalScrollBar() const { - return m_data->view->verticalScrollBar(); + return m_data->view->verticalScrollBar(); } /*! @@ -382,9 +382,9 @@ QScrollBar* QwtLegend::verticalScrollBar() const \return Container widget of the legend items */ -const QWidget* QwtLegend::contentsWidget() const +const QWidget *QwtLegend::contentsWidget() const { - return m_data->view->contentsWidget; + return m_data->view->contentsWidget; } /*! @@ -393,64 +393,64 @@ const QWidget* QwtLegend::contentsWidget() const \param itemInfo Info for an item \param legendData List of legend entry attributes for the item */ -void QwtLegend::updateLegend( const QVariant& itemInfo, - const QList< QwtLegendData >& legendData ) +void QwtLegend::updateLegend(const QVariant &itemInfo, + const QList &legendData) { - QList< QWidget* > widgetList = legendWidgets( itemInfo ); + QList widgetList = legendWidgets(itemInfo); - if ( widgetList.size() != legendData.size() ) + if (widgetList.size() != legendData.size()) + { + QLayout *contentsLayout = m_data->view->contentsWidget->layout(); + + while (widgetList.size() > legendData.size()) { - QLayout* contentsLayout = m_data->view->contentsWidget->layout(); + QWidget *w = widgetList.takeLast(); - while ( widgetList.size() > legendData.size() ) - { - QWidget* w = widgetList.takeLast(); + contentsLayout->removeWidget(w); - contentsLayout->removeWidget( w ); + // updates might be triggered by signals from the legend widget + // itself. So we better don't delete it here. - // updates might be triggered by signals from the legend widget - // itself. So we better don't delete it here. - - w->hide(); - w->deleteLater(); - } - - widgetList.reserve( legendData.size() ); - - for ( int i = widgetList.size(); i < legendData.size(); i++ ) - { - QWidget* widget = createWidget( legendData[i] ); - - if ( contentsLayout ) - contentsLayout->addWidget( widget ); - - if ( isVisible() ) - { - // QLayout does a delayed show, with the effect, that - // the size hint will be wrong, when applications - // call replot() right after changing the list - // of plot items. So we better do the show now. - - widget->setVisible( true ); - } - - widgetList += widget; - } - - if ( widgetList.isEmpty() ) - { - m_data->itemMap.remove( itemInfo ); - } - else - { - m_data->itemMap.insert( itemInfo, widgetList ); - } - - updateTabOrder(); + w->hide(); + w->deleteLater(); } - for ( int i = 0; i < legendData.size(); i++ ) - updateWidget( widgetList[i], legendData[i] ); + widgetList.reserve(legendData.size()); + + for (int i = widgetList.size(); i < legendData.size(); i++) + { + QWidget *widget = createWidget(legendData[i]); + + if (contentsLayout) + contentsLayout->addWidget(widget); + + if (isVisible()) + { + // QLayout does a delayed show, with the effect, that + // the size hint will be wrong, when applications + // call replot() right after changing the list + // of plot items. So we better do the show now. + + widget->setVisible(true); + } + + widgetList += widget; + } + + if (widgetList.isEmpty()) + { + m_data->itemMap.remove(itemInfo); + } + else + { + m_data->itemMap.insert(itemInfo, widgetList); + } + + updateTabOrder(); + } + + for (int i = 0; i < legendData.size(); i++) + updateWidget(widgetList[i], legendData[i]); } /*! @@ -464,17 +464,17 @@ void QwtLegend::updateLegend( const QVariant& itemInfo, \note updateWidget() will called soon after createWidget() with the same attributes. */ -QWidget* QwtLegend::createWidget( const QwtLegendData& legendData ) const +QWidget *QwtLegend::createWidget(const QwtLegendData &legendData) const { - Q_UNUSED( legendData ); + Q_UNUSED(legendData); - QwtLegendLabel* label = new QwtLegendLabel(); - label->setItemMode( defaultItemMode() ); + QwtLegendLabel *label = new QwtLegendLabel(); + label->setItemMode(defaultItemMode()); - connect( label, SIGNAL(clicked()), SLOT(itemClicked()) ); - connect( label, SIGNAL(checked(bool)), SLOT(itemChecked(bool)) ); + connect(label, SIGNAL(clicked()), SLOT(itemClicked())); + connect(label, SIGNAL(checked(bool)), SLOT(itemChecked(bool))); - return label; + return label; } /*! @@ -486,67 +486,66 @@ QWidget* QwtLegend::createWidget( const QwtLegendData& legendData ) const \sa createWidget() \note When widget is no QwtLegendLabel updateWidget() does nothing. */ -void QwtLegend::updateWidget( QWidget* widget, const QwtLegendData& legendData ) +void QwtLegend::updateWidget(QWidget *widget, const QwtLegendData &legendData) { - QwtLegendLabel* label = qobject_cast< QwtLegendLabel* >( widget ); - if ( label ) + QwtLegendLabel *label = qobject_cast(widget); + if (label) + { + label->setData(legendData); + if (!legendData.value(QwtLegendData::ModeRole).isValid()) { - label->setData( legendData ); - if ( !legendData.value( QwtLegendData::ModeRole ).isValid() ) - { - // use the default mode, when there is no specific - // hint from the legend data + // use the default mode, when there is no specific + // hint from the legend data - label->setItemMode( defaultItemMode() ); - } + label->setItemMode(defaultItemMode()); } + } } void QwtLegend::updateTabOrder() { - QLayout* contentsLayout = m_data->view->contentsWidget->layout(); - if ( contentsLayout ) + QLayout *contentsLayout = m_data->view->contentsWidget->layout(); + if (contentsLayout) + { + // set tab focus chain + + QWidget *w = NULL; + + for (int i = 0; i < contentsLayout->count(); i++) { - // set tab focus chain + QLayoutItem *item = contentsLayout->itemAt(i); + if (w && item->widget()) + QWidget::setTabOrder(w, item->widget()); - QWidget* w = NULL; - - for ( int i = 0; i < contentsLayout->count(); i++ ) - { - QLayoutItem* item = contentsLayout->itemAt( i ); - if ( w && item->widget() ) - QWidget::setTabOrder( w, item->widget() ); - - w = item->widget(); - } + w = item->widget(); } + } } //! Return a size hint. QSize QwtLegend::sizeHint() const { - QSize hint = m_data->view->contentsWidget->sizeHint(); - hint += QSize( 2 * frameWidth(), 2 * frameWidth() ); + QSize hint = m_data->view->contentsWidget->sizeHint(); + hint += QSize(2 * frameWidth(), 2 * frameWidth()); - return hint; + return hint; } /*! \return The preferred height, for a width. \param width Width */ -int QwtLegend::heightForWidth( int width ) const +int QwtLegend::heightForWidth(int width) const { - width -= 2 * frameWidth(); + width -= 2 * frameWidth(); - int h = m_data->view->contentsWidget->heightForWidth( width ); - if ( h >= 0 ) - h += 2 * frameWidth(); + int h = m_data->view->contentsWidget->heightForWidth(width); + if (h >= 0) + h += 2 * frameWidth(); - return h; + return h; } - /*! Handle QEvent::ChildRemoved and QEvent::LayoutRequest events for the contentsWidget(). @@ -556,57 +555,54 @@ int QwtLegend::heightForWidth( int width ) const \return Forwarded to QwtAbstractLegend::eventFilter() */ -bool QwtLegend::eventFilter( QObject* object, QEvent* event ) +bool QwtLegend::eventFilter(QObject *object, QEvent *event) { - if ( object == m_data->view->contentsWidget ) + if (object == m_data->view->contentsWidget) + { + switch (event->type()) { - switch ( event->type() ) + case QEvent::ChildRemoved: { + const QChildEvent *ce = static_cast(event); + + if (ce->child()->isWidgetType()) { - case QEvent::ChildRemoved: - { - const QChildEvent* ce = - static_cast< const QChildEvent* >( event ); - - if ( ce->child()->isWidgetType() ) - { - /* - We are called from the ~QObject and ce->child() is - no widget anymore. But all we need is the address - to remove it from the map. - */ - QWidget* w = reinterpret_cast< QWidget* >( ce->child() ); - m_data->itemMap.removeWidget( w ); - } - break; - } - case QEvent::LayoutRequest: - { - m_data->view->layoutContents(); - - if ( parentWidget() && parentWidget()->layout() == NULL ) - { - /* - We want the parent widget ( usually QwtPlot ) to recalculate - its layout, when the contentsWidget has changed. But - because of the scroll view we have to forward the LayoutRequest - event manually. - - We don't use updateGeometry() because it doesn't post LayoutRequest - events when the legend is hidden. But we want the - parent widget notified, so it can show/hide the legend - depending on its items. - */ - QApplication::postEvent( parentWidget(), - new QEvent( QEvent::LayoutRequest ) ); - } - break; - } - default: - break; + /* + We are called from the ~QObject and ce->child() is + no widget anymore. But all we need is the address + to remove it from the map. + */ + QWidget *w = reinterpret_cast(ce->child()); + m_data->itemMap.removeWidget(w); } - } + break; + } + case QEvent::LayoutRequest: { + m_data->view->layoutContents(); - return QwtAbstractLegend::eventFilter( object, event ); + if (parentWidget() && parentWidget()->layout() == NULL) + { + /* + We want the parent widget ( usually QwtPlot ) to recalculate + its layout, when the contentsWidget has changed. But + because of the scroll view we have to forward the LayoutRequest + event manually. + + We don't use updateGeometry() because it doesn't post LayoutRequest + events when the legend is hidden. But we want the + parent widget notified, so it can show/hide the legend + depending on its items. + */ + QApplication::postEvent(parentWidget(), + new QEvent(QEvent::LayoutRequest)); + } + break; + } + default: + break; + } + } + + return QwtAbstractLegend::eventFilter(object, event); } /*! @@ -615,42 +611,42 @@ bool QwtLegend::eventFilter( QObject* object, QEvent* event ) */ void QwtLegend::itemClicked() { - QWidget* w = qobject_cast< QWidget* >( sender() ); - if ( w ) + QWidget *w = qobject_cast(sender()); + if (w) + { + const QVariant itemInfo = m_data->itemMap.itemInfo(w); + if (itemInfo.isValid()) { - const QVariant itemInfo = m_data->itemMap.itemInfo( w ); - if ( itemInfo.isValid() ) - { - const QList< QWidget* > widgetList = - m_data->itemMap.legendWidgets( itemInfo ); + const QList widgetList + = m_data->itemMap.legendWidgets(itemInfo); - const int index = widgetList.indexOf( w ); - if ( index >= 0 ) - Q_EMIT clicked( itemInfo, index ); - } + const int index = widgetList.indexOf(w); + if (index >= 0) + Q_EMIT clicked(itemInfo, index); } + } } /*! Called internally when the legend has been checked Emits a checked() signal. */ -void QwtLegend::itemChecked( bool on ) +void QwtLegend::itemChecked(bool on) { - QWidget* w = qobject_cast< QWidget* >( sender() ); - if ( w ) + QWidget *w = qobject_cast(sender()); + if (w) + { + const QVariant itemInfo = m_data->itemMap.itemInfo(w); + if (itemInfo.isValid()) { - const QVariant itemInfo = m_data->itemMap.itemInfo( w ); - if ( itemInfo.isValid() ) - { - const QList< QWidget* > widgetList = - m_data->itemMap.legendWidgets( itemInfo ); + const QList widgetList + = m_data->itemMap.legendWidgets(itemInfo); - const int index = widgetList.indexOf( w ); - if ( index >= 0 ) - Q_EMIT checked( itemInfo, on, index ); - } + const int index = widgetList.indexOf(w); + if (index >= 0) + Q_EMIT checked(itemInfo, on, index); } + } } /*! @@ -662,55 +658,53 @@ void QwtLegend::itemChecked( bool on ) \sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself */ -void QwtLegend::renderLegend( QPainter* painter, - const QRectF& rect, bool fillBackground ) const +void QwtLegend::renderLegend(QPainter *painter, const QRectF &rect, + bool fillBackground) const { - if ( m_data->itemMap.isEmpty() ) - return; + if (m_data->itemMap.isEmpty()) + return; - if ( fillBackground ) + if (fillBackground) + { + if (autoFillBackground() || testAttribute(Qt::WA_StyledBackground)) { - if ( autoFillBackground() || - testAttribute( Qt::WA_StyledBackground ) ) - { - QwtPainter::drawBackgound( painter, rect, this ); - } + QwtPainter::drawBackgound(painter, rect, this); } + } - const QwtDynGridLayout* legendLayout = - qobject_cast< QwtDynGridLayout* >( contentsWidget()->layout() ); - if ( legendLayout == NULL ) - return; + const QwtDynGridLayout *legendLayout + = qobject_cast(contentsWidget()->layout()); + if (legendLayout == NULL) + return; - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - QRect layoutRect; - layoutRect.setLeft( qwtCeil( rect.left() ) + m.left() ); - layoutRect.setTop( qwtCeil( rect.top() ) + m.top() ); - layoutRect.setRight( qwtFloor( rect.right() ) - m.right() ); - layoutRect.setBottom( qwtFloor( rect.bottom() ) - m.bottom() ); + QRect layoutRect; + layoutRect.setLeft(qwtCeil(rect.left()) + m.left()); + layoutRect.setTop(qwtCeil(rect.top()) + m.top()); + layoutRect.setRight(qwtFloor(rect.right()) - m.right()); + layoutRect.setBottom(qwtFloor(rect.bottom()) - m.bottom()); - uint numCols = legendLayout->columnsForWidth( layoutRect.width() ); - const QList< QRect > itemRects = - legendLayout->layoutItems( layoutRect, numCols ); + uint numCols = legendLayout->columnsForWidth(layoutRect.width()); + const QList itemRects = legendLayout->layoutItems(layoutRect, numCols); - int index = 0; + int index = 0; - for ( int i = 0; i < legendLayout->count(); i++ ) + for (int i = 0; i < legendLayout->count(); i++) + { + QLayoutItem *item = legendLayout->itemAt(i); + QWidget *w = item->widget(); + if (w) { - QLayoutItem* item = legendLayout->itemAt( i ); - QWidget* w = item->widget(); - if ( w ) - { - painter->save(); + painter->save(); - painter->setClipRect( itemRects[index], Qt::IntersectClip ); - renderItem( painter, w, itemRects[index], fillBackground ); + painter->setClipRect(itemRects[index], Qt::IntersectClip); + renderItem(painter, w, itemRects[index], fillBackground); - index++; - painter->restore(); - } + index++; + painter->restore(); } + } } /*! @@ -724,49 +718,49 @@ void QwtLegend::renderLegend( QPainter* painter, \note When widget is not derived from QwtLegendLabel renderItem does nothing beside the background */ -void QwtLegend::renderItem( QPainter* painter, - const QWidget* widget, const QRectF& rect, bool fillBackground ) const +void QwtLegend::renderItem(QPainter *painter, const QWidget *widget, + const QRectF &rect, bool fillBackground) const { - if ( fillBackground ) + if (fillBackground) + { + if (widget->autoFillBackground() + || widget->testAttribute(Qt::WA_StyledBackground)) { - if ( widget->autoFillBackground() || - widget->testAttribute( Qt::WA_StyledBackground ) ) - { - QwtPainter::drawBackgound( painter, rect, widget ); - } + QwtPainter::drawBackgound(painter, rect, widget); } + } - const QwtLegendLabel* label = qobject_cast< const QwtLegendLabel* >( widget ); - if ( label ) - { - // icon + const QwtLegendLabel *label = qobject_cast(widget); + if (label) + { + // icon - const QwtGraphic& icon = label->data().icon(); - const QSizeF sz = icon.defaultSize(); + const QwtGraphic &icon = label->data().icon(); + const QSizeF sz = icon.defaultSize(); - const QRectF iconRect( rect.x() + label->margin(), - rect.center().y() - 0.5 * sz.height(), - sz.width(), sz.height() ); + const QRectF iconRect(rect.x() + label->margin(), + rect.center().y() - 0.5 * sz.height(), sz.width(), + sz.height()); - icon.render( painter, iconRect, Qt::KeepAspectRatio ); + icon.render(painter, iconRect, Qt::KeepAspectRatio); - // title + // title - QRectF titleRect = rect; - titleRect.setX( iconRect.right() + 2 * label->spacing() ); + QRectF titleRect = rect; + titleRect.setX(iconRect.right() + 2 * label->spacing()); - QFont labelFont = label->font(); + QFont labelFont = label->font(); #if QT_VERSION >= 0x060000 - labelFont.setResolveMask( QFont::AllPropertiesResolved ); + labelFont.setResolveMask(QFont::AllPropertiesResolved); #else - labelFont.resolve( QFont::AllPropertiesResolved ); + labelFont.resolve(QFont::AllPropertiesResolved); #endif - painter->setFont( labelFont ); - painter->setPen( label->palette().color( QPalette::Text ) ); + painter->setFont(labelFont); + painter->setPen(label->palette().color(QPalette::Text)); - const_cast< QwtLegendLabel* >( label )->drawText( painter, titleRect ); - } + const_cast(label)->drawText(painter, titleRect); + } } /*! @@ -774,9 +768,9 @@ void QwtLegend::renderItem( QPainter* painter, \param itemInfo Info about an item \sa legendWidget(), itemInfo(), QwtPlot::itemToInfo() */ -QList< QWidget* > QwtLegend::legendWidgets( const QVariant& itemInfo ) const +QList QwtLegend::legendWidgets(const QVariant &itemInfo) const { - return m_data->itemMap.legendWidgets( itemInfo ); + return m_data->itemMap.legendWidgets(itemInfo); } /*! @@ -785,13 +779,13 @@ QList< QWidget* > QwtLegend::legendWidgets( const QVariant& itemInfo ) const \sa itemInfo(), QwtPlot::itemToInfo() \note Almost all types of items have only one widget */ -QWidget* QwtLegend::legendWidget( const QVariant& itemInfo ) const +QWidget *QwtLegend::legendWidget(const QVariant &itemInfo) const { - const QList< QWidget* > list = m_data->itemMap.legendWidgets( itemInfo ); - if ( list.isEmpty() ) - return NULL; + const QList list = m_data->itemMap.legendWidgets(itemInfo); + if (list.isEmpty()) + return NULL; - return list[0]; + return list[0]; } /*! @@ -801,15 +795,15 @@ QWidget* QwtLegend::legendWidget( const QVariant& itemInfo ) const \return Associated item info \sa legendWidget() */ -QVariant QwtLegend::itemInfo( const QWidget* widget ) const +QVariant QwtLegend::itemInfo(const QWidget *widget) const { - return m_data->itemMap.itemInfo( widget ); + return m_data->itemMap.itemInfo(widget); } //! \return True, when no item is inserted bool QwtLegend::isEmpty() const { - return m_data->itemMap.isEmpty(); + return m_data->itemMap.isEmpty(); } /*! @@ -818,18 +812,18 @@ bool QwtLegend::isEmpty() const \param orientation Orientation \return The width of the vertical scrollbar for Qt::Horizontal and v.v. */ -int QwtLegend::scrollExtent( Qt::Orientation orientation ) const +int QwtLegend::scrollExtent(Qt::Orientation orientation) const { - int extent = 0; + int extent = 0; - if ( orientation == Qt::Horizontal ) - extent = verticalScrollBar()->sizeHint().width(); - else - extent = horizontalScrollBar()->sizeHint().height(); + if (orientation == Qt::Horizontal) + extent = verticalScrollBar()->sizeHint().width(); + else + extent = horizontalScrollBar()->sizeHint().height(); - return extent; + return extent; } #if QWT_MOC_INCLUDE -#include "moc_qwt_legend.cpp" +# include "moc_qwt_legend.cpp" #endif diff --git a/libs/qwt/src/qwt_legend.h b/libs/qwt/src/qwt_legend.h index b67c6cfd..1e728ba7 100644 --- a/libs/qwt/src/qwt_legend.h +++ b/libs/qwt/src/qwt_legend.h @@ -30,90 +30,90 @@ class QScrollBar; class QWT_EXPORT QwtLegend : public QwtAbstractLegend { - Q_OBJECT + Q_OBJECT - public: - explicit QwtLegend( QWidget* parent = NULL ); - virtual ~QwtLegend(); +public: + explicit QwtLegend(QWidget *parent = NULL); + virtual ~QwtLegend(); - void setMaxColumns( uint numColums ); - uint maxColumns() const; + void setMaxColumns(uint numColums); + uint maxColumns() const; - void setDefaultItemMode( QwtLegendData::Mode ); - QwtLegendData::Mode defaultItemMode() const; + void setDefaultItemMode(QwtLegendData::Mode); + QwtLegendData::Mode defaultItemMode() const; - QWidget* contentsWidget(); - const QWidget* contentsWidget() const; + QWidget *contentsWidget(); + const QWidget *contentsWidget() const; - QWidget* legendWidget( const QVariant& ) const; - QList< QWidget* > legendWidgets( const QVariant& ) const; + QWidget *legendWidget(const QVariant &) const; + QList legendWidgets(const QVariant &) const; - QVariant itemInfo( const QWidget* ) const; + QVariant itemInfo(const QWidget *) const; - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual int heightForWidth( int w ) const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual int heightForWidth(int w) const QWT_OVERRIDE; - QScrollBar* horizontalScrollBar() const; - QScrollBar* verticalScrollBar() const; + QScrollBar *horizontalScrollBar() const; + QScrollBar *verticalScrollBar() const; - virtual void renderLegend( QPainter*, - const QRectF&, bool fillBackground ) const QWT_OVERRIDE; + virtual void renderLegend(QPainter *, const QRectF &, + bool fillBackground) const QWT_OVERRIDE; - virtual void renderItem( QPainter*, - const QWidget*, const QRectF&, bool fillBackground ) const; + virtual void renderItem(QPainter *, const QWidget *, const QRectF &, + bool fillBackground) const; - virtual bool isEmpty() const QWT_OVERRIDE; - virtual int scrollExtent( Qt::Orientation ) const QWT_OVERRIDE; + virtual bool isEmpty() const QWT_OVERRIDE; + virtual int scrollExtent(Qt::Orientation) const QWT_OVERRIDE; - Q_SIGNALS: - /*! - A signal which is emitted when the user has clicked on - a legend label, which is in QwtLegendData::Clickable mode. +Q_SIGNALS: + /*! + A signal which is emitted when the user has clicked on + a legend label, which is in QwtLegendData::Clickable mode. - \param itemInfo Info for the item item of the - selected legend item - \param index Index of the legend label in the list of widgets - that are associated with the plot item + \param itemInfo Info for the item item of the + selected legend item + \param index Index of the legend label in the list of widgets + that are associated with the plot item - \note clicks are disabled as default - \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo() - */ - void clicked( const QVariant& itemInfo, int index ); + \note clicks are disabled as default + \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo() + */ + void clicked(const QVariant &itemInfo, int index); - /*! - A signal which is emitted when the user has clicked on - a legend label, which is in QwtLegendData::Checkable mode + /*! + A signal which is emitted when the user has clicked on + a legend label, which is in QwtLegendData::Checkable mode - \param itemInfo Info for the item of the - selected legend label - \param index Index of the legend label in the list of widgets - that are associated with the plot item - \param on True when the legend label is checked + \param itemInfo Info for the item of the + selected legend label + \param index Index of the legend label in the list of widgets + that are associated with the plot item + \param on True when the legend label is checked - \note clicks are disabled as default - \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo() - */ - void checked( const QVariant& itemInfo, bool on, int index ); + \note clicks are disabled as default + \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo() + */ + void checked(const QVariant &itemInfo, bool on, int index); - public Q_SLOTS: - virtual void updateLegend( const QVariant&, - const QList< QwtLegendData >& ) QWT_OVERRIDE; +public Q_SLOTS: + virtual void updateLegend(const QVariant &, + const QList &) QWT_OVERRIDE; - protected Q_SLOTS: - void itemClicked(); - void itemChecked( bool ); +protected Q_SLOTS: + void itemClicked(); + void itemChecked(bool); - protected: - virtual QWidget* createWidget( const QwtLegendData& ) const; - virtual void updateWidget( QWidget*, const QwtLegendData& ); +protected: + virtual QWidget *createWidget(const QwtLegendData &) const; + virtual void updateWidget(QWidget *, const QwtLegendData &); - private: - void updateTabOrder(); +private: + void updateTabOrder(); - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_legend_data.cpp b/libs/qwt/src/qwt_legend_data.cpp index 036f0cec..f305fb1d 100644 --- a/libs/qwt/src/qwt_legend_data.cpp +++ b/libs/qwt/src/qwt_legend_data.cpp @@ -12,14 +12,10 @@ #include "qwt_graphic.h" //! Constructor -QwtLegendData::QwtLegendData() -{ -} +QwtLegendData::QwtLegendData() {} //! Destructor -QwtLegendData::~QwtLegendData() -{ -} +QwtLegendData::~QwtLegendData() {} /*! Set the legend attributes @@ -30,27 +26,27 @@ QwtLegendData::~QwtLegendData() \param map Values \sa values() */ -void QwtLegendData::setValues( const QMap< int, QVariant >& map ) +void QwtLegendData::setValues(const QMap &map) { - m_map = map; + m_map = map; } /*! \return Legend attributes \sa setValues() */ -const QMap< int, QVariant >& QwtLegendData::values() const +const QMap &QwtLegendData::values() const { - return m_map; + return m_map; } /*! \param role Attribute role \return True, when the internal map has an entry for role */ -bool QwtLegendData::hasRole( int role ) const +bool QwtLegendData::hasRole(int role) const { - return m_map.contains( role ); + return m_map.contains(role); } /*! @@ -61,71 +57,70 @@ bool QwtLegendData::hasRole( int role ) const \sa value() */ -void QwtLegendData::setValue( int role, const QVariant& data ) +void QwtLegendData::setValue(int role, const QVariant &data) { - m_map[role] = data; + m_map[role] = data; } /*! \param role Attribute role \return Attribute value for a specific role */ -QVariant QwtLegendData::value( int role ) const +QVariant QwtLegendData::value(int role) const { - if ( !m_map.contains( role ) ) - return QVariant(); + if (!m_map.contains(role)) + return QVariant(); - return m_map[role]; + return m_map[role]; } //! \return True, when the internal map is empty bool QwtLegendData::isValid() const { - return !m_map.isEmpty(); + return !m_map.isEmpty(); } //! \return Value of the TitleRole attribute QwtText QwtLegendData::title() const { - QwtText text; + QwtText text; - const QVariant titleValue = value( QwtLegendData::TitleRole ); - if ( titleValue.canConvert< QwtText >() ) - { - text = qvariant_cast< QwtText >( titleValue ); - } - else if ( titleValue.canConvert< QString >() ) - { - text.setText( qvariant_cast< QString >( titleValue ) ); - } + const QVariant titleValue = value(QwtLegendData::TitleRole); + if (titleValue.canConvert()) + { + text = qvariant_cast(titleValue); + } + else if (titleValue.canConvert()) + { + text.setText(qvariant_cast(titleValue)); + } - return text; + return text; } //! \return Value of the IconRole attribute QwtGraphic QwtLegendData::icon() const { - const QVariant iconValue = value( QwtLegendData::IconRole ); + const QVariant iconValue = value(QwtLegendData::IconRole); - QwtGraphic graphic; - if ( iconValue.canConvert< QwtGraphic >() ) - { - graphic = qvariant_cast< QwtGraphic >( iconValue ); - } + QwtGraphic graphic; + if (iconValue.canConvert()) + { + graphic = qvariant_cast(iconValue); + } - return graphic; + return graphic; } //! \return Value of the ModeRole attribute QwtLegendData::Mode QwtLegendData::mode() const { - const QVariant modeValue = value( QwtLegendData::ModeRole ); - if ( modeValue.canConvert< int >() ) - { - const int mode = qvariant_cast< int >( modeValue ); - return static_cast< QwtLegendData::Mode >( mode ); - } + const QVariant modeValue = value(QwtLegendData::ModeRole); + if (modeValue.canConvert()) + { + const int mode = qvariant_cast(modeValue); + return static_cast(mode); + } - return QwtLegendData::ReadOnly; + return QwtLegendData::ReadOnly; } - diff --git a/libs/qwt/src/qwt_legend_data.h b/libs/qwt/src/qwt_legend_data.h index 68550cf7..33583213 100644 --- a/libs/qwt/src/qwt_legend_data.h +++ b/libs/qwt/src/qwt_legend_data.h @@ -35,54 +35,54 @@ class QwtGraphic; */ class QWT_EXPORT QwtLegendData { - public: - //! Mode defining how a legend entry interacts - enum Mode - { - //! The legend item is not interactive, like a label - ReadOnly, +public: + //! Mode defining how a legend entry interacts + enum Mode + { + //! The legend item is not interactive, like a label + ReadOnly, - //! The legend item is clickable, like a push button - Clickable, + //! The legend item is clickable, like a push button + Clickable, - //! The legend item is checkable, like a checkable button - Checkable - }; + //! The legend item is checkable, like a checkable button + Checkable + }; - //! Identifier how to interpret a QVariant - enum Role - { - // The value is a Mode - ModeRole, + //! Identifier how to interpret a QVariant + enum Role + { + // The value is a Mode + ModeRole, - // The value is a title - TitleRole, + // The value is a title + TitleRole, - // The value is an icon - IconRole, + // The value is an icon + IconRole, - // Values < UserRole are reserved for internal use - UserRole = 32 - }; + // Values < UserRole are reserved for internal use + UserRole = 32 + }; - QwtLegendData(); - ~QwtLegendData(); + QwtLegendData(); + ~QwtLegendData(); - void setValues( const QMap< int, QVariant >& ); - const QMap< int, QVariant >& values() const; + void setValues(const QMap &); + const QMap &values() const; - void setValue( int role, const QVariant& ); - QVariant value( int role ) const; + void setValue(int role, const QVariant &); + QVariant value(int role) const; - bool hasRole( int role ) const; - bool isValid() const; + bool hasRole(int role) const; + bool isValid() const; - QwtGraphic icon() const; - QwtText title() const; - Mode mode() const; + QwtGraphic icon() const; + QwtText title() const; + Mode mode() const; - private: - QMap< int, QVariant > m_map; +private: + QMap m_map; }; #endif diff --git a/libs/qwt/src/qwt_legend_label.cpp b/libs/qwt/src/qwt_legend_label.cpp index c5370891..6d8ab5e6 100644 --- a/libs/qwt/src/qwt_legend_label.cpp +++ b/libs/qwt/src/qwt_legend_label.cpp @@ -21,35 +21,35 @@ static const int ButtonFrame = 2; static const int Margin = 2; -static QSize buttonShift( const QwtLegendLabel* w ) +static QSize buttonShift(const QwtLegendLabel *w) { - QStyleOption option; - option.initFrom( w ); + QStyleOption option; + option.initFrom(w); - const int ph = w->style()->pixelMetric( - QStyle::PM_ButtonShiftHorizontal, &option, w ); - const int pv = w->style()->pixelMetric( - QStyle::PM_ButtonShiftVertical, &option, w ); - return QSize( ph, pv ); + const int ph + = w->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &option, w); + const int pv + = w->style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &option, w); + return QSize(ph, pv); } class QwtLegendLabel::PrivateData { - public: - PrivateData() - : itemMode( QwtLegendData::ReadOnly ) - , isDown( false ) - , spacing( Margin ) - { - } +public: + PrivateData() + : itemMode(QwtLegendData::ReadOnly) + , isDown(false) + , spacing(Margin) + { + } - QwtLegendData::Mode itemMode; - QwtLegendData legendData; - bool isDown; + QwtLegendData::Mode itemMode; + QwtLegendData legendData; + bool isDown; - QPixmap icon; + QPixmap icon; - int spacing; + int spacing; }; /*! @@ -58,49 +58,49 @@ class QwtLegendLabel::PrivateData \param legendData Attributes of the label \sa data() */ -void QwtLegendLabel::setData( const QwtLegendData& legendData ) +void QwtLegendLabel::setData(const QwtLegendData &legendData) { - m_data->legendData = legendData; + m_data->legendData = legendData; - const bool doUpdate = updatesEnabled(); - if ( doUpdate ) - setUpdatesEnabled( false ); + const bool doUpdate = updatesEnabled(); + if (doUpdate) + setUpdatesEnabled(false); - setText( legendData.title() ); - setIcon( legendData.icon().toPixmap() ); + setText(legendData.title()); + setIcon(legendData.icon().toPixmap()); - if ( legendData.hasRole( QwtLegendData::ModeRole ) ) - setItemMode( legendData.mode() ); + if (legendData.hasRole(QwtLegendData::ModeRole)) + setItemMode(legendData.mode()); - if ( doUpdate ) - setUpdatesEnabled( true ); + if (doUpdate) + setUpdatesEnabled(true); } /*! \return Attributes of the label \sa setData(), QwtPlotItem::legendData() */ -const QwtLegendData& QwtLegendLabel::data() const +const QwtLegendData &QwtLegendLabel::data() const { - return m_data->legendData; + return m_data->legendData; } /*! \param parent Parent widget */ -QwtLegendLabel::QwtLegendLabel( QWidget* parent ) - : QwtTextLabel( parent ) +QwtLegendLabel::QwtLegendLabel(QWidget *parent) + : QwtTextLabel(parent) { - m_data = new PrivateData; - setMargin( Margin ); - setIndent( Margin ); + m_data = new PrivateData; + setMargin(Margin); + setIndent(Margin); } //! Destructor QwtLegendLabel::~QwtLegendLabel() { - delete m_data; - m_data = NULL; + delete m_data; + m_data = NULL; } /*! @@ -109,15 +109,15 @@ QwtLegendLabel::~QwtLegendLabel() \param text Text label \sa QwtTextLabel::text() */ -void QwtLegendLabel::setText( const QwtText& text ) +void QwtLegendLabel::setText(const QwtText &text) { - const int flags = Qt::AlignLeft | Qt::AlignVCenter - | Qt::TextExpandTabs | Qt::TextWordWrap; + const int flags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs + | Qt::TextWordWrap; - QwtText txt = text; - txt.setRenderFlags( flags ); + QwtText txt = text; + txt.setRenderFlags(flags); - QwtTextLabel::setText( txt ); + QwtTextLabel::setText(txt); } /*! @@ -127,19 +127,19 @@ void QwtLegendLabel::setText( const QwtText& text ) \param mode Item mode \sa itemMode() */ -void QwtLegendLabel::setItemMode( QwtLegendData::Mode mode ) +void QwtLegendLabel::setItemMode(QwtLegendData::Mode mode) { - if ( mode != m_data->itemMode ) - { - m_data->itemMode = mode; - m_data->isDown = false; + if (mode != m_data->itemMode) + { + m_data->itemMode = mode; + m_data->isDown = false; - setFocusPolicy( ( mode != QwtLegendData::ReadOnly ) - ? Qt::TabFocus : Qt::NoFocus ); - setMargin( ButtonFrame + Margin ); + setFocusPolicy((mode != QwtLegendData::ReadOnly) ? Qt::TabFocus + : Qt::NoFocus); + setMargin(ButtonFrame + Margin); - updateGeometry(); - } + updateGeometry(); + } } /*! @@ -148,7 +148,7 @@ void QwtLegendLabel::setItemMode( QwtLegendData::Mode mode ) */ QwtLegendData::Mode QwtLegendLabel::itemMode() const { - return m_data->itemMode; + return m_data->itemMode; } /*! @@ -158,15 +158,15 @@ QwtLegendData::Mode QwtLegendLabel::itemMode() const \sa icon(), QwtPlotItem::legendIcon() */ -void QwtLegendLabel::setIcon( const QPixmap& icon ) +void QwtLegendLabel::setIcon(const QPixmap &icon) { - m_data->icon = icon; + m_data->icon = icon; - int indent = margin() + m_data->spacing; - if ( icon.width() > 0 ) - indent += icon.width() + m_data->spacing; + int indent = margin() + m_data->spacing; + if (icon.width() > 0) + indent += icon.width() + m_data->spacing; - setIndent( indent ); + setIndent(indent); } /*! @@ -175,7 +175,7 @@ void QwtLegendLabel::setIcon( const QPixmap& icon ) */ QPixmap QwtLegendLabel::icon() const { - return m_data->icon; + return m_data->icon; } /*! @@ -184,19 +184,19 @@ QPixmap QwtLegendLabel::icon() const \param spacing Spacing \sa spacing(), QwtTextLabel::margin() */ -void QwtLegendLabel::setSpacing( int spacing ) +void QwtLegendLabel::setSpacing(int spacing) { - spacing = qMax( spacing, 0 ); - if ( spacing != m_data->spacing ) - { - m_data->spacing = spacing; + spacing = qMax(spacing, 0); + if (spacing != m_data->spacing) + { + m_data->spacing = spacing; - int indent = margin() + m_data->spacing; - if ( m_data->icon.width() > 0 ) - indent += m_data->icon.width() + m_data->spacing; + int indent = margin() + m_data->spacing; + if (m_data->icon.width() > 0) + indent += m_data->icon.width() + m_data->spacing; - setIndent( indent ); - } + setIndent(indent); + } } /*! @@ -205,7 +205,7 @@ void QwtLegendLabel::setSpacing( int spacing ) */ int QwtLegendLabel::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! @@ -214,207 +214,198 @@ int QwtLegendLabel::spacing() const \param on check/uncheck \sa setItemMode() */ -void QwtLegendLabel::setChecked( bool on ) +void QwtLegendLabel::setChecked(bool on) { - if ( m_data->itemMode == QwtLegendData::Checkable ) - { - const bool isBlocked = signalsBlocked(); - blockSignals( true ); + if (m_data->itemMode == QwtLegendData::Checkable) + { + const bool isBlocked = signalsBlocked(); + blockSignals(true); - setDown( on ); + setDown(on); - blockSignals( isBlocked ); - } + blockSignals(isBlocked); + } } //! Return true, if the item is checked bool QwtLegendLabel::isChecked() const { - return m_data->itemMode == QwtLegendData::Checkable && isDown(); + return m_data->itemMode == QwtLegendData::Checkable && isDown(); } //! Set the item being down -void QwtLegendLabel::setDown( bool down ) +void QwtLegendLabel::setDown(bool down) { - if ( down == m_data->isDown ) - return; + if (down == m_data->isDown) + return; - m_data->isDown = down; - update(); + m_data->isDown = down; + update(); - if ( m_data->itemMode == QwtLegendData::Clickable ) + if (m_data->itemMode == QwtLegendData::Clickable) + { + if (m_data->isDown) + Q_EMIT pressed(); + else { - if ( m_data->isDown ) - Q_EMIT pressed(); - else - { - Q_EMIT released(); - Q_EMIT clicked(); - } + Q_EMIT released(); + Q_EMIT clicked(); } + } - if ( m_data->itemMode == QwtLegendData::Checkable ) - Q_EMIT checked( m_data->isDown ); + if (m_data->itemMode == QwtLegendData::Checkable) + Q_EMIT checked(m_data->isDown); } //! Return true, if the item is down bool QwtLegendLabel::isDown() const { - return m_data->isDown; + return m_data->isDown; } //! Return a size hint QSize QwtLegendLabel::sizeHint() const { - QSize sz = QwtTextLabel::sizeHint(); - sz.setHeight( qMax( sz.height(), m_data->icon.height() + 4 ) ); + QSize sz = QwtTextLabel::sizeHint(); + sz.setHeight(qMax(sz.height(), m_data->icon.height() + 4)); - if ( m_data->itemMode != QwtLegendData::ReadOnly ) - { - sz += buttonShift( this ); - sz = qwtExpandedToGlobalStrut( sz ); - } + if (m_data->itemMode != QwtLegendData::ReadOnly) + { + sz += buttonShift(this); + sz = qwtExpandedToGlobalStrut(sz); + } - return sz; + return sz; } //! Paint event -void QwtLegendLabel::paintEvent( QPaintEvent* e ) +void QwtLegendLabel::paintEvent(QPaintEvent *e) { - const QRect cr = contentsRect(); + const QRect cr = contentsRect(); - QPainter painter( this ); - painter.setClipRegion( e->region() ); + QPainter painter(this); + painter.setClipRegion(e->region()); - if ( m_data->isDown ) - { - qDrawWinButton( &painter, 0, 0, width(), height(), - palette(), true ); - } + if (m_data->isDown) + { + qDrawWinButton(&painter, 0, 0, width(), height(), palette(), true); + } - painter.save(); + painter.save(); - if ( m_data->isDown ) - { - const QSize shiftSize = buttonShift( this ); - painter.translate( shiftSize.width(), shiftSize.height() ); - } + if (m_data->isDown) + { + const QSize shiftSize = buttonShift(this); + painter.translate(shiftSize.width(), shiftSize.height()); + } - painter.setClipRect( cr ); + painter.setClipRect(cr); - drawContents( &painter ); + drawContents(&painter); - if ( !m_data->icon.isNull() ) - { - QRect iconRect = cr; - iconRect.setX( iconRect.x() + margin() ); - if ( m_data->itemMode != QwtLegendData::ReadOnly ) - iconRect.setX( iconRect.x() + ButtonFrame ); + if (!m_data->icon.isNull()) + { + QRect iconRect = cr; + iconRect.setX(iconRect.x() + margin()); + if (m_data->itemMode != QwtLegendData::ReadOnly) + iconRect.setX(iconRect.x() + ButtonFrame); - iconRect.setSize( m_data->icon.size() ); - iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) ); + iconRect.setSize(m_data->icon.size()); + iconRect.moveCenter(QPoint(iconRect.center().x(), cr.center().y())); - painter.drawPixmap( iconRect, m_data->icon ); - } + painter.drawPixmap(iconRect, m_data->icon); + } - painter.restore(); + painter.restore(); } //! Handle mouse press events -void QwtLegendLabel::mousePressEvent( QMouseEvent* e ) +void QwtLegendLabel::mousePressEvent(QMouseEvent *e) { - if ( e->button() == Qt::LeftButton ) + if (e->button() == Qt::LeftButton) + { + switch (m_data->itemMode) { - switch ( m_data->itemMode ) - { - case QwtLegendData::Clickable: - { - setDown( true ); - return; - } - case QwtLegendData::Checkable: - { - setDown( !isDown() ); - return; - } - default:; - } + case QwtLegendData::Clickable: { + setDown(true); + return; + } + case QwtLegendData::Checkable: { + setDown(!isDown()); + return; + } + default:; } - QwtTextLabel::mousePressEvent( e ); + } + QwtTextLabel::mousePressEvent(e); } //! Handle mouse release events -void QwtLegendLabel::mouseReleaseEvent( QMouseEvent* e ) +void QwtLegendLabel::mouseReleaseEvent(QMouseEvent *e) { - if ( e->button() == Qt::LeftButton ) + if (e->button() == Qt::LeftButton) + { + switch (m_data->itemMode) { - switch ( m_data->itemMode ) - { - case QwtLegendData::Clickable: - { - setDown( false ); - return; - } - case QwtLegendData::Checkable: - { - return; // do nothing, but accept - } - default:; - } + case QwtLegendData::Clickable: { + setDown(false); + return; + } + case QwtLegendData::Checkable: { + return; // do nothing, but accept + } + default:; } - QwtTextLabel::mouseReleaseEvent( e ); + } + QwtTextLabel::mouseReleaseEvent(e); } //! Handle key press events -void QwtLegendLabel::keyPressEvent( QKeyEvent* e ) +void QwtLegendLabel::keyPressEvent(QKeyEvent *e) { - if ( e->key() == Qt::Key_Space ) + if (e->key() == Qt::Key_Space) + { + switch (m_data->itemMode) { - switch ( m_data->itemMode ) - { - case QwtLegendData::Clickable: - { - if ( !e->isAutoRepeat() ) - setDown( true ); - return; - } - case QwtLegendData::Checkable: - { - if ( !e->isAutoRepeat() ) - setDown( !isDown() ); - return; - } - default:; - } + case QwtLegendData::Clickable: { + if (!e->isAutoRepeat()) + setDown(true); + return; + } + case QwtLegendData::Checkable: { + if (!e->isAutoRepeat()) + setDown(!isDown()); + return; + } + default:; } + } - QwtTextLabel::keyPressEvent( e ); + QwtTextLabel::keyPressEvent(e); } //! Handle key release events -void QwtLegendLabel::keyReleaseEvent( QKeyEvent* e ) +void QwtLegendLabel::keyReleaseEvent(QKeyEvent *e) { - if ( e->key() == Qt::Key_Space ) + if (e->key() == Qt::Key_Space) + { + switch (m_data->itemMode) { - switch ( m_data->itemMode ) - { - case QwtLegendData::Clickable: - { - if ( !e->isAutoRepeat() ) - setDown( false ); - return; - } - case QwtLegendData::Checkable: - { - return; // do nothing, but accept - } - default:; - } + case QwtLegendData::Clickable: { + if (!e->isAutoRepeat()) + setDown(false); + return; + } + case QwtLegendData::Checkable: { + return; // do nothing, but accept + } + default:; } + } - QwtTextLabel::keyReleaseEvent( e ); + QwtTextLabel::keyReleaseEvent(e); } #if QWT_MOC_INCLUDE -#include "moc_qwt_legend_label.cpp" +# include "moc_qwt_legend_label.cpp" #endif diff --git a/libs/qwt/src/qwt_legend_label.h b/libs/qwt/src/qwt_legend_label.h index d75f2b01..f96b9004 100644 --- a/libs/qwt/src/qwt_legend_label.h +++ b/libs/qwt/src/qwt_legend_label.h @@ -21,58 +21,58 @@ class QwtText; */ class QWT_EXPORT QwtLegendLabel : public QwtTextLabel { - Q_OBJECT - public: - explicit QwtLegendLabel( QWidget* parent = 0 ); - virtual ~QwtLegendLabel(); + Q_OBJECT +public: + explicit QwtLegendLabel(QWidget *parent = 0); + virtual ~QwtLegendLabel(); - void setData( const QwtLegendData& ); - const QwtLegendData& data() const; + void setData(const QwtLegendData &); + const QwtLegendData &data() const; - void setItemMode( QwtLegendData::Mode ); - QwtLegendData::Mode itemMode() const; + void setItemMode(QwtLegendData::Mode); + QwtLegendData::Mode itemMode() const; - void setSpacing( int spacing ); - int spacing() const; + void setSpacing(int spacing); + int spacing() const; - virtual void setText( const QwtText& ) QWT_OVERRIDE; + virtual void setText(const QwtText &) QWT_OVERRIDE; - void setIcon( const QPixmap& ); - QPixmap icon() const; + void setIcon(const QPixmap &); + QPixmap icon() const; - virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; - bool isChecked() const; + bool isChecked() const; - public Q_SLOTS: - void setChecked( bool on ); +public Q_SLOTS: + void setChecked(bool on); - Q_SIGNALS: - //! Signal, when the legend item has been clicked - void clicked(); +Q_SIGNALS: + //! Signal, when the legend item has been clicked + void clicked(); - //! Signal, when the legend item has been pressed - void pressed(); + //! Signal, when the legend item has been pressed + void pressed(); - //! Signal, when the legend item has been released - void released(); + //! Signal, when the legend item has been released + void released(); - //! Signal, when the legend item has been toggled - void checked( bool ); + //! Signal, when the legend item has been toggled + void checked(bool); - protected: - void setDown( bool ); - bool isDown() const; +protected: + void setDown(bool); + bool isDown() const; - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE; - virtual void keyReleaseEvent( QKeyEvent* ) QWT_OVERRIDE; + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent *) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_magnifier.cpp b/libs/qwt/src/qwt_magnifier.cpp index 5a0bf7ff..eed2428b 100644 --- a/libs/qwt/src/qwt_magnifier.cpp +++ b/libs/qwt/src/qwt_magnifier.cpp @@ -15,69 +15,69 @@ class QwtMagnifier::PrivateData { - public: - PrivateData() - : isEnabled( false ) - , wheelFactor( 0.9 ) - , wheelModifiers( Qt::NoModifier ) - , mouseFactor( 0.95 ) - , mouseButton( Qt::RightButton ) - , mouseButtonModifiers( Qt::NoModifier ) - , keyFactor( 0.9 ) - , zoomInKey( Qt::Key_Plus ) - , zoomInKeyModifiers( Qt::NoModifier ) - , zoomOutKey( Qt::Key_Minus ) - , zoomOutKeyModifiers( Qt::NoModifier ) - , mousePressed( false ) - , hasMouseTracking( false ) - { - } +public: + PrivateData() + : isEnabled(false) + , wheelFactor(0.9) + , wheelModifiers(Qt::NoModifier) + , mouseFactor(0.95) + , mouseButton(Qt::RightButton) + , mouseButtonModifiers(Qt::NoModifier) + , keyFactor(0.9) + , zoomInKey(Qt::Key_Plus) + , zoomInKeyModifiers(Qt::NoModifier) + , zoomOutKey(Qt::Key_Minus) + , zoomOutKeyModifiers(Qt::NoModifier) + , mousePressed(false) + , hasMouseTracking(false) + { + } - bool isEnabled; + bool isEnabled; - double wheelFactor; - Qt::KeyboardModifiers wheelModifiers; + double wheelFactor; + Qt::KeyboardModifiers wheelModifiers; - double mouseFactor; + double mouseFactor; - Qt::MouseButton mouseButton; - Qt::KeyboardModifiers mouseButtonModifiers; + Qt::MouseButton mouseButton; + Qt::KeyboardModifiers mouseButtonModifiers; - double keyFactor; + double keyFactor; - int zoomInKey; - Qt::KeyboardModifiers zoomInKeyModifiers; + int zoomInKey; + Qt::KeyboardModifiers zoomInKeyModifiers; - int zoomOutKey; - Qt::KeyboardModifiers zoomOutKeyModifiers; + int zoomOutKey; + Qt::KeyboardModifiers zoomOutKeyModifiers; - bool mousePressed; - bool hasMouseTracking; - QPoint mousePos; + bool mousePressed; + bool hasMouseTracking; + QPoint mousePos; }; /*! Constructor \param parent Widget to be magnified */ -QwtMagnifier::QwtMagnifier( QWidget* parent ) - : QObject( parent ) +QwtMagnifier::QwtMagnifier(QWidget *parent) + : QObject(parent) { - m_data = new PrivateData(); + m_data = new PrivateData(); - if ( parent ) - { - if ( parent->focusPolicy() == Qt::NoFocus ) - parent->setFocusPolicy( Qt::WheelFocus ); - } + if (parent) + { + if (parent->focusPolicy() == Qt::NoFocus) + parent->setFocusPolicy(Qt::WheelFocus); + } - setEnabled( true ); + setEnabled(true); } //! Destructor QwtMagnifier::~QwtMagnifier() { - delete m_data; + delete m_data; } /*! @@ -89,21 +89,21 @@ QwtMagnifier::~QwtMagnifier() \param on true or false \sa isEnabled(), eventFilter() */ -void QwtMagnifier::setEnabled( bool on ) +void QwtMagnifier::setEnabled(bool on) { - if ( m_data->isEnabled != on ) - { - m_data->isEnabled = on; + if (m_data->isEnabled != on) + { + m_data->isEnabled = on; - QObject* o = parent(); - if ( o ) - { - if ( m_data->isEnabled ) - o->installEventFilter( this ); - else - o->removeEventFilter( this ); - } + QObject *o = parent(); + if (o) + { + if (m_data->isEnabled) + o->installEventFilter(this); + else + o->removeEventFilter(this); } + } } /*! @@ -112,7 +112,7 @@ void QwtMagnifier::setEnabled( bool on ) */ bool QwtMagnifier::isEnabled() const { - return m_data->isEnabled; + return m_data->isEnabled; } /*! @@ -131,9 +131,9 @@ bool QwtMagnifier::isEnabled() const \sa wheelFactor(), setWheelButtonState(), setMouseFactor(), setKeyFactor() */ -void QwtMagnifier::setWheelFactor( double factor ) +void QwtMagnifier::setWheelFactor(double factor) { - m_data->wheelFactor = factor; + m_data->wheelFactor = factor; } /*! @@ -142,7 +142,7 @@ void QwtMagnifier::setWheelFactor( double factor ) */ double QwtMagnifier::wheelFactor() const { - return m_data->wheelFactor; + return m_data->wheelFactor; } /*! @@ -152,9 +152,9 @@ double QwtMagnifier::wheelFactor() const \param modifiers Keyboard modifiers \sa wheelModifiers() */ -void QwtMagnifier::setWheelModifiers( Qt::KeyboardModifiers modifiers ) +void QwtMagnifier::setWheelModifiers(Qt::KeyboardModifiers modifiers) { - m_data->wheelModifiers = modifiers; + m_data->wheelModifiers = modifiers; } /*! @@ -163,7 +163,7 @@ void QwtMagnifier::setWheelModifiers( Qt::KeyboardModifiers modifiers ) */ Qt::KeyboardModifiers QwtMagnifier::wheelModifiers() const { - return m_data->wheelModifiers; + return m_data->wheelModifiers; } /*! @@ -176,9 +176,9 @@ Qt::KeyboardModifiers QwtMagnifier::wheelModifiers() const \param factor Wheel factor \sa mouseFactor(), setMouseButton(), setWheelFactor(), setKeyFactor() */ -void QwtMagnifier::setMouseFactor( double factor ) +void QwtMagnifier::setMouseFactor(double factor) { - m_data->mouseFactor = factor; + m_data->mouseFactor = factor; } /*! @@ -187,7 +187,7 @@ void QwtMagnifier::setMouseFactor( double factor ) */ double QwtMagnifier::mouseFactor() const { - return m_data->mouseFactor; + return m_data->mouseFactor; } /*! @@ -199,19 +199,19 @@ double QwtMagnifier::mouseFactor() const \sa getMouseButton() */ -void QwtMagnifier::setMouseButton( - Qt::MouseButton button, Qt::KeyboardModifiers modifiers ) +void QwtMagnifier::setMouseButton(Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) { - m_data->mouseButton = button; - m_data->mouseButtonModifiers = modifiers; + m_data->mouseButton = button; + m_data->mouseButtonModifiers = modifiers; } //! \sa setMouseButton() -void QwtMagnifier::getMouseButton( - Qt::MouseButton& button, Qt::KeyboardModifiers& modifiers ) const +void QwtMagnifier::getMouseButton(Qt::MouseButton &button, + Qt::KeyboardModifiers &modifiers) const { - button = m_data->mouseButton; - modifiers = m_data->mouseButtonModifiers; + button = m_data->mouseButton; + modifiers = m_data->mouseButtonModifiers; } /*! @@ -225,9 +225,9 @@ void QwtMagnifier::getMouseButton( \sa keyFactor(), setZoomInKey(), setZoomOutKey(), setWheelFactor, setMouseFactor() */ -void QwtMagnifier::setKeyFactor( double factor ) +void QwtMagnifier::setKeyFactor(double factor) { - m_data->keyFactor = factor; + m_data->keyFactor = factor; } /*! @@ -236,7 +236,7 @@ void QwtMagnifier::setKeyFactor( double factor ) */ double QwtMagnifier::keyFactor() const { - return m_data->keyFactor; + return m_data->keyFactor; } /*! @@ -247,11 +247,10 @@ double QwtMagnifier::keyFactor() const \param modifiers \sa getZoomInKey(), setZoomOutKey() */ -void QwtMagnifier::setZoomInKey( int key, - Qt::KeyboardModifiers modifiers ) +void QwtMagnifier::setZoomInKey(int key, Qt::KeyboardModifiers modifiers) { - m_data->zoomInKey = key; - m_data->zoomInKeyModifiers = modifiers; + m_data->zoomInKey = key; + m_data->zoomInKeyModifiers = modifiers; } /*! @@ -262,11 +261,11 @@ void QwtMagnifier::setZoomInKey( int key, \sa setZoomInKey() */ -void QwtMagnifier::getZoomInKey( int& key, - Qt::KeyboardModifiers& modifiers ) const +void QwtMagnifier::getZoomInKey(int &key, + Qt::KeyboardModifiers &modifiers) const { - key = m_data->zoomInKey; - modifiers = m_data->zoomInKeyModifiers; + key = m_data->zoomInKey; + modifiers = m_data->zoomInKeyModifiers; } /*! @@ -277,11 +276,10 @@ void QwtMagnifier::getZoomInKey( int& key, \param modifiers \sa getZoomOutKey(), setZoomOutKey() */ -void QwtMagnifier::setZoomOutKey( int key, - Qt::KeyboardModifiers modifiers ) +void QwtMagnifier::setZoomOutKey(int key, Qt::KeyboardModifiers modifiers) { - m_data->zoomOutKey = key; - m_data->zoomOutKeyModifiers = modifiers; + m_data->zoomOutKey = key; + m_data->zoomOutKeyModifiers = modifiers; } /*! @@ -292,11 +290,11 @@ void QwtMagnifier::setZoomOutKey( int key, \sa setZoomOutKey() */ -void QwtMagnifier::getZoomOutKey( int& key, - Qt::KeyboardModifiers& modifiers ) const +void QwtMagnifier::getZoomOutKey(int &key, + Qt::KeyboardModifiers &modifiers) const { - key = m_data->zoomOutKey; - modifiers = m_data->zoomOutKeyModifiers; + key = m_data->zoomOutKey; + modifiers = m_data->zoomOutKeyModifiers; } /*! @@ -314,46 +312,40 @@ void QwtMagnifier::getZoomOutKey( int& key, widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent() widgetKeyReleaseEvent() */ -bool QwtMagnifier::eventFilter( QObject* object, QEvent* event ) +bool QwtMagnifier::eventFilter(QObject *object, QEvent *event) { - if ( object && object == parent() ) + if (object && object == parent()) + { + switch (event->type()) { - switch ( event->type() ) - { - case QEvent::MouseButtonPress: - { - widgetMousePressEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseMove: - { - widgetMouseMoveEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseButtonRelease: - { - widgetMouseReleaseEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::Wheel: - { - widgetWheelEvent( static_cast< QWheelEvent* >( event ) ); - break; - } - case QEvent::KeyPress: - { - widgetKeyPressEvent( static_cast< QKeyEvent* >( event ) ); - break; - } - case QEvent::KeyRelease: - { - widgetKeyReleaseEvent( static_cast< QKeyEvent* >( event ) ); - break; - } - default:; - } + case QEvent::MouseButtonPress: { + widgetMousePressEvent(static_cast(event)); + break; + } + case QEvent::MouseMove: { + widgetMouseMoveEvent(static_cast(event)); + break; + } + case QEvent::MouseButtonRelease: { + widgetMouseReleaseEvent(static_cast(event)); + break; + } + case QEvent::Wheel: { + widgetWheelEvent(static_cast(event)); + break; + } + case QEvent::KeyPress: { + widgetKeyPressEvent(static_cast(event)); + break; + } + case QEvent::KeyRelease: { + widgetKeyReleaseEvent(static_cast(event)); + break; + } + default:; } - return QObject::eventFilter( object, event ); + } + return QObject::eventFilter(object, event); } /*! @@ -362,22 +354,22 @@ bool QwtMagnifier::eventFilter( QObject* object, QEvent* event ) \param mouseEvent Mouse event \sa eventFilter(), widgetMouseReleaseEvent(), widgetMouseMoveEvent() */ -void QwtMagnifier::widgetMousePressEvent( QMouseEvent* mouseEvent ) +void QwtMagnifier::widgetMousePressEvent(QMouseEvent *mouseEvent) { - if ( parentWidget() == NULL ) - return; + if (parentWidget() == NULL) + return; - if ( ( mouseEvent->button() != m_data->mouseButton ) || - ( mouseEvent->modifiers() != m_data->mouseButtonModifiers ) ) - { - return; - } + if ((mouseEvent->button() != m_data->mouseButton) + || (mouseEvent->modifiers() != m_data->mouseButtonModifiers)) + { + return; + } - m_data->hasMouseTracking = parentWidget()->hasMouseTracking(); + m_data->hasMouseTracking = parentWidget()->hasMouseTracking(); - parentWidget()->setMouseTracking( true ); - m_data->mousePos = mouseEvent->pos(); - m_data->mousePressed = true; + parentWidget()->setMouseTracking(true); + m_data->mousePos = mouseEvent->pos(); + m_data->mousePressed = true; } /*! @@ -387,15 +379,15 @@ void QwtMagnifier::widgetMousePressEvent( QMouseEvent* mouseEvent ) \sa eventFilter(), widgetMousePressEvent(), widgetMouseMoveEvent(), */ -void QwtMagnifier::widgetMouseReleaseEvent( QMouseEvent* mouseEvent ) +void QwtMagnifier::widgetMouseReleaseEvent(QMouseEvent *mouseEvent) { - Q_UNUSED( mouseEvent ); + Q_UNUSED(mouseEvent); - if ( m_data->mousePressed && parentWidget() ) - { - m_data->mousePressed = false; - parentWidget()->setMouseTracking( m_data->hasMouseTracking ); - } + if (m_data->mousePressed && parentWidget()) + { + m_data->mousePressed = false; + parentWidget()->setMouseTracking(m_data->hasMouseTracking); + } } /*! @@ -404,22 +396,22 @@ void QwtMagnifier::widgetMouseReleaseEvent( QMouseEvent* mouseEvent ) \param mouseEvent Mouse event \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), */ -void QwtMagnifier::widgetMouseMoveEvent( QMouseEvent* mouseEvent ) +void QwtMagnifier::widgetMouseMoveEvent(QMouseEvent *mouseEvent) { - if ( !m_data->mousePressed ) - return; + if (!m_data->mousePressed) + return; - const int dy = mouseEvent->pos().y() - m_data->mousePos.y(); - if ( dy != 0 ) - { - double f = m_data->mouseFactor; - if ( dy < 0 ) - f = 1 / f; + const int dy = mouseEvent->pos().y() - m_data->mousePos.y(); + if (dy != 0) + { + double f = m_data->mouseFactor; + if (dy < 0) + f = 1 / f; - rescale( f ); - } + rescale(f); + } - m_data->mousePos = mouseEvent->pos(); + m_data->mousePos = mouseEvent->pos(); } /*! @@ -428,40 +420,39 @@ void QwtMagnifier::widgetMouseMoveEvent( QMouseEvent* mouseEvent ) \param wheelEvent Wheel event \sa eventFilter() */ -void QwtMagnifier::widgetWheelEvent( QWheelEvent* wheelEvent ) +void QwtMagnifier::widgetWheelEvent(QWheelEvent *wheelEvent) { - if ( wheelEvent->modifiers() != m_data->wheelModifiers ) - { - return; - } + if (wheelEvent->modifiers() != m_data->wheelModifiers) + { + return; + } - if ( m_data->wheelFactor != 0.0 ) - { + if (m_data->wheelFactor != 0.0) + { #if QT_VERSION < 0x050000 - const int wheelDelta = wheelEvent->delta(); + const int wheelDelta = wheelEvent->delta(); #else - const QPoint delta = wheelEvent->angleDelta(); - const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) ) - ? delta.x() : delta.y(); + const QPoint delta = wheelEvent->angleDelta(); + const int wheelDelta + = (qAbs(delta.x()) > qAbs(delta.y())) ? delta.x() : delta.y(); #endif - /* - A positive delta indicates that the wheel was - rotated forwards away from the user; a negative - value indicates that the wheel was rotated - backwards toward the user. - Most mouse types work in steps of 15 degrees, - in which case the delta value is a multiple - of 120 (== 15 * 8). - */ - double f = std::pow( m_data->wheelFactor, - qAbs( wheelDelta / 120.0 ) ); + /* + A positive delta indicates that the wheel was + rotated forwards away from the user; a negative + value indicates that the wheel was rotated + backwards toward the user. + Most mouse types work in steps of 15 degrees, + in which case the delta value is a multiple + of 120 (== 15 * 8). + */ + double f = std::pow(m_data->wheelFactor, qAbs(wheelDelta / 120.0)); - if ( wheelDelta > 0 ) - f = 1 / f; + if (wheelDelta > 0) + f = 1 / f; - rescale( f ); - } + rescale(f); + } } /*! @@ -470,18 +461,18 @@ void QwtMagnifier::widgetWheelEvent( QWheelEvent* wheelEvent ) \param keyEvent Key event \sa eventFilter(), widgetKeyReleaseEvent() */ -void QwtMagnifier::widgetKeyPressEvent( QKeyEvent* keyEvent ) +void QwtMagnifier::widgetKeyPressEvent(QKeyEvent *keyEvent) { - if ( keyEvent->key() == m_data->zoomInKey && - keyEvent->modifiers() == m_data->zoomInKeyModifiers ) - { - rescale( m_data->keyFactor ); - } - else if ( keyEvent->key() == m_data->zoomOutKey && - keyEvent->modifiers() == m_data->zoomOutKeyModifiers ) - { - rescale( 1.0 / m_data->keyFactor ); - } + if (keyEvent->key() == m_data->zoomInKey + && keyEvent->modifiers() == m_data->zoomInKeyModifiers) + { + rescale(m_data->keyFactor); + } + else if (keyEvent->key() == m_data->zoomOutKey + && keyEvent->modifiers() == m_data->zoomOutKeyModifiers) + { + rescale(1.0 / m_data->keyFactor); + } } /*! @@ -490,23 +481,23 @@ void QwtMagnifier::widgetKeyPressEvent( QKeyEvent* keyEvent ) \param keyEvent Key event \sa eventFilter(), widgetKeyReleaseEvent() */ -void QwtMagnifier::widgetKeyReleaseEvent( QKeyEvent* keyEvent ) +void QwtMagnifier::widgetKeyReleaseEvent(QKeyEvent *keyEvent) { - Q_UNUSED( keyEvent ); + Q_UNUSED(keyEvent); } //! \return Parent widget, where the rescaling happens -QWidget* QwtMagnifier::parentWidget() +QWidget *QwtMagnifier::parentWidget() { - return qobject_cast< QWidget* >( parent() ); + return qobject_cast(parent()); } //! \return Parent widget, where the rescaling happens -const QWidget* QwtMagnifier::parentWidget() const +const QWidget *QwtMagnifier::parentWidget() const { - return qobject_cast< const QWidget* >( parent() ); + return qobject_cast(parent()); } #if QWT_MOC_INCLUDE -#include "moc_qwt_magnifier.cpp" +# include "moc_qwt_magnifier.cpp" #endif diff --git a/libs/qwt/src/qwt_magnifier.h b/libs/qwt/src/qwt_magnifier.h index fa744c6b..5e00a194 100644 --- a/libs/qwt/src/qwt_magnifier.h +++ b/libs/qwt/src/qwt_magnifier.h @@ -26,61 +26,61 @@ class QKeyEvent; */ class QWT_EXPORT QwtMagnifier : public QObject { - Q_OBJECT + Q_OBJECT - public: - explicit QwtMagnifier( QWidget* ); - virtual ~QwtMagnifier(); +public: + explicit QwtMagnifier(QWidget *); + virtual ~QwtMagnifier(); - QWidget* parentWidget(); - const QWidget* parentWidget() const; + QWidget *parentWidget(); + const QWidget *parentWidget() const; - void setEnabled( bool ); - bool isEnabled() const; + void setEnabled(bool); + bool isEnabled() const; - // mouse - void setMouseFactor( double ); - double mouseFactor() const; + // mouse + void setMouseFactor(double); + double mouseFactor() const; - void setMouseButton( Qt::MouseButton, Qt::KeyboardModifiers = Qt::NoModifier ); - void getMouseButton( Qt::MouseButton&, Qt::KeyboardModifiers& ) const; + void setMouseButton(Qt::MouseButton, Qt::KeyboardModifiers = Qt::NoModifier); + void getMouseButton(Qt::MouseButton &, Qt::KeyboardModifiers &) const; - // mouse wheel - void setWheelFactor( double ); - double wheelFactor() const; + // mouse wheel + void setWheelFactor(double); + double wheelFactor() const; - void setWheelModifiers( Qt::KeyboardModifiers ); - Qt::KeyboardModifiers wheelModifiers() const; + void setWheelModifiers(Qt::KeyboardModifiers); + Qt::KeyboardModifiers wheelModifiers() const; - // keyboard - void setKeyFactor( double ); - double keyFactor() const; + // keyboard + void setKeyFactor(double); + double keyFactor() const; - void setZoomInKey( int key, Qt::KeyboardModifiers = Qt::NoModifier ); - void getZoomInKey( int& key, Qt::KeyboardModifiers& ) const; + void setZoomInKey(int key, Qt::KeyboardModifiers = Qt::NoModifier); + void getZoomInKey(int &key, Qt::KeyboardModifiers &) const; - void setZoomOutKey( int key, Qt::KeyboardModifiers = Qt::NoModifier ); - void getZoomOutKey( int& key, Qt::KeyboardModifiers& ) const; + void setZoomOutKey(int key, Qt::KeyboardModifiers = Qt::NoModifier); + void getZoomOutKey(int &key, Qt::KeyboardModifiers &) const; - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - protected: - /*! - Rescale the parent widget - \param factor Scale factor - */ - virtual void rescale( double factor ) = 0; +protected: + /*! + Rescale the parent widget + \param factor Scale factor + */ + virtual void rescale(double factor) = 0; - virtual void widgetMousePressEvent( QMouseEvent* ); - virtual void widgetMouseReleaseEvent( QMouseEvent* ); - virtual void widgetMouseMoveEvent( QMouseEvent* ); - virtual void widgetWheelEvent( QWheelEvent* ); - virtual void widgetKeyPressEvent( QKeyEvent* ); - virtual void widgetKeyReleaseEvent( QKeyEvent* ); + virtual void widgetMousePressEvent(QMouseEvent *); + virtual void widgetMouseReleaseEvent(QMouseEvent *); + virtual void widgetMouseMoveEvent(QMouseEvent *); + virtual void widgetWheelEvent(QWheelEvent *); + virtual void widgetKeyPressEvent(QKeyEvent *); + virtual void widgetKeyReleaseEvent(QKeyEvent *); - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_math.cpp b/libs/qwt/src/qwt_math.cpp index 9ef11b85..e489901c 100644 --- a/libs/qwt/src/qwt_math.cpp +++ b/libs/qwt/src/qwt_math.cpp @@ -9,7 +9,7 @@ #include "qwt_math.h" #if QT_VERSION >= 0x050a00 -#include +# include #endif /*! @@ -17,14 +17,13 @@ \param radians Angle in radians \return Normalized angle in radians */ -double qwtNormalizeRadians( double radians ) +double qwtNormalizeRadians(double radians) { - double a = std::fmod( radians, 2.0 * M_PI ); - if ( a < 0.0 ) - a += 2.0 * M_PI; - - return a; + double a = std::fmod(radians, 2.0 * M_PI); + if (a < 0.0) + a += 2.0 * M_PI; + return a; } /*! @@ -32,13 +31,13 @@ double qwtNormalizeRadians( double radians ) \param radians Angle in degrees \return Normalized angle in degrees */ -double qwtNormalizeDegrees( double degrees ) +double qwtNormalizeDegrees(double degrees) { - double a = std::fmod( degrees, 360.0 ); - if ( a < 0.0 ) - a += 360.0; + double a = std::fmod(degrees, 360.0); + if (a < 0.0) + a += 360.0; - return a; + return a; } /*! @@ -48,8 +47,8 @@ double qwtNormalizeDegrees( double degrees ) quint32 qwtRand() { #if QT_VERSION >= 0x050a00 - return QRandomGenerator::global()->generate(); + return QRandomGenerator::global()->generate(); #else - return static_cast< quint32 >( qrand() ); // [0, RAND_MAX ] + return static_cast(qrand()); // [0, RAND_MAX ] #endif } diff --git a/libs/qwt/src/qwt_math.h b/libs/qwt/src/qwt_math.h index 71344fc5..da077111 100644 --- a/libs/qwt/src/qwt_math.h +++ b/libs/qwt/src/qwt_math.h @@ -21,77 +21,77 @@ */ #ifndef _USE_MATH_DEFINES -#define _USE_MATH_DEFINES -#define undef_USE_MATH_DEFINES +# define _USE_MATH_DEFINES +# define undef_USE_MATH_DEFINES #endif #include #ifdef undef_USE_MATH_DEFINES -#undef _USE_MATH_DEFINES -#undef undef_USE_MATH_DEFINES +# undef _USE_MATH_DEFINES +# undef undef_USE_MATH_DEFINES #endif #ifndef M_E -#define M_E ( 2.7182818284590452354 ) +# define M_E (2.7182818284590452354) #endif #ifndef M_LOG2E -#define M_LOG2E ( 1.4426950408889634074 ) +# define M_LOG2E (1.4426950408889634074) #endif #ifndef M_LOG10E -#define M_LOG10E ( 0.43429448190325182765 ) +# define M_LOG10E (0.43429448190325182765) #endif #ifndef M_LN2 -#define M_LN2 ( 0.69314718055994530942 ) +# define M_LN2 (0.69314718055994530942) #endif #ifndef M_LN10 -#define M_LN10 ( 2.30258509299404568402 ) +# define M_LN10 (2.30258509299404568402) #endif #ifndef M_PI -#define M_PI ( 3.14159265358979323846 ) +# define M_PI (3.14159265358979323846) #endif #ifndef M_PI_2 -#define M_PI_2 ( 1.57079632679489661923 ) +# define M_PI_2 (1.57079632679489661923) #endif #ifndef M_PI_4 -#define M_PI_4 ( 0.78539816339744830962 ) +# define M_PI_4 (0.78539816339744830962) #endif #ifndef M_1_PI -#define M_1_PI ( 0.31830988618379067154 ) +# define M_1_PI (0.31830988618379067154) #endif #ifndef M_2_PI -#define M_2_PI ( 0.63661977236758134308 ) +# define M_2_PI (0.63661977236758134308) #endif #ifndef M_2_SQRTPI -#define M_2_SQRTPI ( 1.12837916709551257390 ) +# define M_2_SQRTPI (1.12837916709551257390) #endif #ifndef M_SQRT2 -#define M_SQRT2 ( 1.41421356237309504880 ) +# define M_SQRT2 (1.41421356237309504880) #endif #ifndef M_SQRT1_2 -#define M_SQRT1_2 ( 0.70710678118654752440 ) +# define M_SQRT1_2 (0.70710678118654752440) #endif -#if defined( QT_WARNING_PUSH ) - /* - early Qt versions not having QT_WARNING_PUSH is full of warnings - so that we do not care of suppressing those from below - */ - QT_WARNING_PUSH - QT_WARNING_DISABLE_CLANG("-Wdouble-promotion") - QT_WARNING_DISABLE_GCC("-Wdouble-promotion") +#if defined(QT_WARNING_PUSH) +/* + early Qt versions not having QT_WARNING_PUSH is full of warnings + so that we do not care of suppressing those from below + */ +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wdouble-promotion") +QT_WARNING_DISABLE_GCC("-Wdouble-promotion") #endif /* @@ -100,59 +100,59 @@ */ //! \return Minimum of a and b. -QWT_CONSTEXPR inline float qwtMinF( float a, float b ) +QWT_CONSTEXPR inline float qwtMinF(float a, float b) { - return ( a < b ) ? a : b; + return (a < b) ? a : b; } //! \return Minimum of a and b. -QWT_CONSTEXPR inline double qwtMinF( double a, double b ) +QWT_CONSTEXPR inline double qwtMinF(double a, double b) { - return ( a < b ) ? a : b; + return (a < b) ? a : b; } //! \return Minimum of a and b. -QWT_CONSTEXPR inline qreal qwtMinF( float a, double b ) +QWT_CONSTEXPR inline qreal qwtMinF(float a, double b) { - return ( a < b ) ? a : b; + return (a < b) ? a : b; } //! \return Minimum of a and b. -QWT_CONSTEXPR inline qreal qwtMinF( double a, float b ) +QWT_CONSTEXPR inline qreal qwtMinF(double a, float b) { - return ( a < b ) ? a : b; + return (a < b) ? a : b; } //! \return Maximum of a and b. -QWT_CONSTEXPR inline float qwtMaxF( float a, float b ) +QWT_CONSTEXPR inline float qwtMaxF(float a, float b) { - return ( a < b ) ? b : a; + return (a < b) ? b : a; } //! \return Maximum of a and b. -QWT_CONSTEXPR inline double qwtMaxF( double a, double b ) +QWT_CONSTEXPR inline double qwtMaxF(double a, double b) { - return ( a < b ) ? b : a; + return (a < b) ? b : a; } //! \return Maximum of a and b. -QWT_CONSTEXPR inline qreal qwtMaxF( float a, double b ) +QWT_CONSTEXPR inline qreal qwtMaxF(float a, double b) { - return ( a < b ) ? b : a; + return (a < b) ? b : a; } //! \return Maximum of a and b. -QWT_CONSTEXPR inline qreal qwtMaxF( double a, float b ) +QWT_CONSTEXPR inline qreal qwtMaxF(double a, float b) { - return ( a < b ) ? b : a; + return (a < b) ? b : a; } -#if defined( QT_WARNING_POP ) - QT_WARNING_POP +#if defined(QT_WARNING_POP) +QT_WARNING_POP #endif -QWT_EXPORT double qwtNormalizeRadians( double radians ); -QWT_EXPORT double qwtNormalizeDegrees( double degrees ); +QWT_EXPORT double qwtNormalizeRadians(double radians); +QWT_EXPORT double qwtNormalizeDegrees(double degrees); QWT_EXPORT quint32 qwtRand(); /*! @@ -167,67 +167,67 @@ QWT_EXPORT quint32 qwtRand(); \return 0: if equal, -1: if value2 > value1, 1: if value1 > value2 */ -inline int qwtFuzzyCompare( double value1, double value2, double intervalSize ) +inline int qwtFuzzyCompare(double value1, double value2, double intervalSize) { - const double eps = qAbs( 1.0e-6 * intervalSize ); + const double eps = qAbs(1.0e-6 * intervalSize); - if ( value2 - value1 > eps ) - return -1; + if (value2 - value1 > eps) + return -1; - if ( value1 - value2 > eps ) - return 1; + if (value1 - value2 > eps) + return 1; - return 0; + return 0; } //! Return the sign -inline int qwtSign( double x ) +inline int qwtSign(double x) { - if ( x > 0.0 ) - return 1; - else if ( x < 0.0 ) - return ( -1 ); - else - return 0; + if (x > 0.0) + return 1; + else if (x < 0.0) + return (-1); + else + return 0; } //! Return the square of a number -inline double qwtSqr( double x ) +inline double qwtSqr(double x) { - return x * x; + return x * x; } //! Approximation of arc tangent ( error below 0,005 radians ) -inline double qwtFastAtan( double x ) +inline double qwtFastAtan(double x) { - if ( x < -1.0 ) - return -M_PI_2 - x / ( x * x + 0.28 ); + if (x < -1.0) + return -M_PI_2 - x / (x * x + 0.28); - if ( x > 1.0 ) - return M_PI_2 - x / ( x * x + 0.28 ); + if (x > 1.0) + return M_PI_2 - x / (x * x + 0.28); - return x / ( 1.0 + x * x * 0.28 ); + return x / (1.0 + x * x * 0.28); } //! Approximation of arc tangent ( error below 0,005 radians ) -inline double qwtFastAtan2( double y, double x ) +inline double qwtFastAtan2(double y, double x) { - if ( x > 0 ) - return qwtFastAtan( y / x ); + if (x > 0) + return qwtFastAtan(y / x); - if ( x < 0 ) - { - const double d = qwtFastAtan( y / x ); - return ( y >= 0 ) ? d + M_PI : d - M_PI; - } + if (x < 0) + { + const double d = qwtFastAtan(y / x); + return (y >= 0) ? d + M_PI : d - M_PI; + } - if ( y < 0.0 ) - return -M_PI_2; + if (y < 0.0) + return -M_PI_2; - if ( y > 0.0 ) - return M_PI_2; + if (y > 0.0) + return M_PI_2; - return 0.0; + return 0.0; } /* ! @@ -241,41 +241,41 @@ inline double qwtFastAtan2( double y, double x ) \return Value of the polyonom for x */ -inline double qwtCubicPolynomial( double x, - double a, double b, double c, double d ) +inline double qwtCubicPolynomial(double x, double a, double b, double c, + double d) { - return ( ( ( a * x ) + b ) * x + c ) * x + d; + return (((a * x) + b) * x + c) * x + d; } //! Translate degrees into radians -inline double qwtRadians( double degrees ) +inline double qwtRadians(double degrees) { - return degrees * M_PI / 180.0; + return degrees * M_PI / 180.0; } //! Translate radians into degrees -inline double qwtDegrees( double degrees ) +inline double qwtDegrees(double degrees) { - return degrees * 180.0 / M_PI; + return degrees * 180.0 / M_PI; } /*! The same as qCeil, but avoids including qmath.h \return Ceiling of value. */ -inline int qwtCeil( qreal value ) +inline int qwtCeil(qreal value) { - using std::ceil; - return int( ceil( value ) ); + using std::ceil; + return int(ceil(value)); } /*! The same as qFloor, but avoids including qmath.h \return Floor of value. */ -inline int qwtFloor( qreal value ) +inline int qwtFloor(qreal value) { - using std::floor; - return int( floor( value ) ); + using std::floor; + return int(floor(value)); } #endif diff --git a/libs/qwt/src/qwt_matrix_raster_data.cpp b/libs/qwt/src/qwt_matrix_raster_data.cpp index 40800264..9c3f967e 100644 --- a/libs/qwt/src/qwt_matrix_raster_data.cpp +++ b/libs/qwt/src/qwt_matrix_raster_data.cpp @@ -14,71 +14,71 @@ #include #include -static inline double qwtHermiteInterpolate( - double A, double B, double C, double D, double t ) +static inline double qwtHermiteInterpolate(double A, double B, double C, + double D, double t) { - const double t2 = t * t; - const double t3 = t2 * t; + const double t2 = t * t; + const double t3 = t2 * t; - const double a = -A / 2.0 + ( 3.0 * B ) / 2.0 - ( 3.0 * C ) / 2.0 + D / 2.0; - const double b = A - ( 5.0 * B ) / 2.0 + 2.0 * C - D / 2.0; - const double c = -A / 2.0 + C / 2.0; - const double d = B; + const double a = -A / 2.0 + (3.0 * B) / 2.0 - (3.0 * C) / 2.0 + D / 2.0; + const double b = A - (5.0 * B) / 2.0 + 2.0 * C - D / 2.0; + const double c = -A / 2.0 + C / 2.0; + const double d = B; - return a * t3 + b * t2 + c * t + d; + return a * t3 + b * t2 + c * t + d; } -static inline double qwtBicubicInterpolate( - double v00, double v10, double v20, double v30, - double v01, double v11, double v21, double v31, - double v02, double v12, double v22, double v32, - double v03, double v13, double v23, double v33, - double dx, double dy ) +static inline double qwtBicubicInterpolate(double v00, double v10, double v20, + double v30, double v01, double v11, + double v21, double v31, double v02, + double v12, double v22, double v32, + double v03, double v13, double v23, + double v33, double dx, double dy) { - const double v0 = qwtHermiteInterpolate( v00, v10, v20, v30, dx ); - const double v1 = qwtHermiteInterpolate( v01, v11, v21, v31, dx ); - const double v2 = qwtHermiteInterpolate( v02, v12, v22, v32, dx ); - const double v3 = qwtHermiteInterpolate( v03, v13, v23, v33, dx ); + const double v0 = qwtHermiteInterpolate(v00, v10, v20, v30, dx); + const double v1 = qwtHermiteInterpolate(v01, v11, v21, v31, dx); + const double v2 = qwtHermiteInterpolate(v02, v12, v22, v32, dx); + const double v3 = qwtHermiteInterpolate(v03, v13, v23, v33, dx); - return qwtHermiteInterpolate( v0, v1, v2, v3, dy ); + return qwtHermiteInterpolate(v0, v1, v2, v3, dy); } class QwtMatrixRasterData::PrivateData { - public: - PrivateData() - : resampleMode( QwtMatrixRasterData::NearestNeighbour ) - , numColumns(0) - { - } +public: + PrivateData() + : resampleMode(QwtMatrixRasterData::NearestNeighbour) + , numColumns(0) + { + } - inline double value(int row, int col) const - { - return values.data()[ row * numColumns + col ]; - } + inline double value(int row, int col) const + { + return values.data()[row * numColumns + col]; + } - QwtInterval intervals[3]; - QwtMatrixRasterData::ResampleMode resampleMode; + QwtInterval intervals[3]; + QwtMatrixRasterData::ResampleMode resampleMode; - QVector< double > values; - int numColumns; - int numRows; + QVector values; + int numColumns; + int numRows; - double dx; - double dy; + double dx; + double dy; }; //! Constructor QwtMatrixRasterData::QwtMatrixRasterData() { - m_data = new PrivateData(); - update(); + m_data = new PrivateData(); + update(); } //! Destructor QwtMatrixRasterData::~QwtMatrixRasterData() { - delete m_data; + delete m_data; } /*! @@ -87,9 +87,9 @@ QwtMatrixRasterData::~QwtMatrixRasterData() \param mode Resampling mode \sa resampleMode(), value() */ -void QwtMatrixRasterData::setResampleMode( ResampleMode mode ) +void QwtMatrixRasterData::setResampleMode(ResampleMode mode) { - m_data->resampleMode = mode; + m_data->resampleMode = mode; } /*! @@ -98,7 +98,7 @@ void QwtMatrixRasterData::setResampleMode( ResampleMode mode ) */ QwtMatrixRasterData::ResampleMode QwtMatrixRasterData::resampleMode() const { - return m_data->resampleMode; + return m_data->resampleMode; } /*! @@ -117,26 +117,26 @@ QwtMatrixRasterData::ResampleMode QwtMatrixRasterData::resampleMode() const \sa QwtRasterData::interval(), setValueMatrix() */ -void QwtMatrixRasterData::setInterval( - Qt::Axis axis, const QwtInterval& interval ) +void QwtMatrixRasterData::setInterval(Qt::Axis axis, + const QwtInterval &interval) { - if ( axis >= 0 && axis <= 2 ) - { - m_data->intervals[axis] = interval; - update(); - } + if (axis >= 0 && axis <= 2) + { + m_data->intervals[axis] = interval; + update(); + } } /*! \return Bounding interval for an axis \sa setInterval */ -QwtInterval QwtMatrixRasterData::interval( Qt::Axis axis ) const +QwtInterval QwtMatrixRasterData::interval(Qt::Axis axis) const { - if ( axis >= 0 && axis <= 2 ) - return m_data->intervals[ axis ]; + if (axis >= 0 && axis <= 2) + return m_data->intervals[axis]; - return QwtInterval(); + return QwtInterval(); } /*! @@ -152,21 +152,21 @@ QwtInterval QwtMatrixRasterData::interval( Qt::Axis axis ) const \sa valueMatrix(), numColumns(), numRows(), setInterval()() */ -void QwtMatrixRasterData::setValueMatrix( - const QVector< double >& values, int numColumns ) +void QwtMatrixRasterData::setValueMatrix(const QVector &values, + int numColumns) { - m_data->values = values; - m_data->numColumns = qMax( numColumns, 0 ); - update(); + m_data->values = values; + m_data->numColumns = qMax(numColumns, 0); + update(); } /*! \return Value matrix \sa setValueMatrix(), numColumns(), numRows(), setInterval() */ -const QVector< double > QwtMatrixRasterData::valueMatrix() const +const QVector QwtMatrixRasterData::valueMatrix() const { - return m_data->values; + return m_data->values; } /*! @@ -178,14 +178,13 @@ const QVector< double > QwtMatrixRasterData::valueMatrix() const \sa value(), setValueMatrix() */ -void QwtMatrixRasterData::setValue( int row, int col, double value ) +void QwtMatrixRasterData::setValue(int row, int col, double value) { - if ( row >= 0 && row < m_data->numRows && - col >= 0 && col < m_data->numColumns ) - { - const int index = row * m_data->numColumns + col; - m_data->values.data()[ index ] = value; - } + if (row >= 0 && row < m_data->numRows && col >= 0 && col < m_data->numColumns) + { + const int index = row * m_data->numColumns + col; + m_data->values.data()[index] = value; + } } /*! @@ -194,7 +193,7 @@ void QwtMatrixRasterData::setValue( int row, int col, double value ) */ int QwtMatrixRasterData::numColumns() const { - return m_data->numColumns; + return m_data->numColumns; } /*! @@ -203,7 +202,7 @@ int QwtMatrixRasterData::numColumns() const */ int QwtMatrixRasterData::numRows() const { - return m_data->numRows; + return m_data->numRows; } /*! @@ -226,23 +225,23 @@ int QwtMatrixRasterData::numRows() const \sa ResampleMode, setMatrix(), setInterval() */ -QRectF QwtMatrixRasterData::pixelHint( const QRectF& area ) const +QRectF QwtMatrixRasterData::pixelHint(const QRectF &area) const { - Q_UNUSED( area ) + Q_UNUSED(area) - QRectF rect; - if ( m_data->resampleMode == NearestNeighbour ) + QRectF rect; + if (m_data->resampleMode == NearestNeighbour) + { + const QwtInterval intervalX = interval(Qt::XAxis); + const QwtInterval intervalY = interval(Qt::YAxis); + if (intervalX.isValid() && intervalY.isValid()) { - const QwtInterval intervalX = interval( Qt::XAxis ); - const QwtInterval intervalY = interval( Qt::YAxis ); - if ( intervalX.isValid() && intervalY.isValid() ) - { - rect = QRectF( intervalX.minValue(), intervalY.minValue(), - m_data->dx, m_data->dy ); - } + rect = QRectF(intervalX.minValue(), intervalY.minValue(), m_data->dx, + m_data->dy); } + } - return rect; + return rect; } /*! @@ -253,165 +252,161 @@ QRectF QwtMatrixRasterData::pixelHint( const QRectF& area ) const \sa ResampleMode */ -double QwtMatrixRasterData::value( double x, double y ) const +double QwtMatrixRasterData::value(double x, double y) const { - const QwtInterval xInterval = interval( Qt::XAxis ); - const QwtInterval yInterval = interval( Qt::YAxis ); + const QwtInterval xInterval = interval(Qt::XAxis); + const QwtInterval yInterval = interval(Qt::YAxis); - if ( !( xInterval.contains(x) && yInterval.contains(y) ) ) - return qQNaN(); + if (!(xInterval.contains(x) && yInterval.contains(y))) + return qQNaN(); - double value; + double value; - switch( m_data->resampleMode ) - { - case BicubicInterpolation: - { - const double colF = ( x - xInterval.minValue() ) / m_data->dx; - const double rowF = ( y - yInterval.minValue() ) / m_data->dy; + switch (m_data->resampleMode) + { + case BicubicInterpolation: { + const double colF = (x - xInterval.minValue()) / m_data->dx; + const double rowF = (y - yInterval.minValue()) / m_data->dy; - const int col = qRound( colF ); - const int row = qRound( rowF ); + const int col = qRound(colF); + const int row = qRound(rowF); - int col0 = col - 2; - int col1 = col - 1; - int col2 = col; - int col3 = col + 1; + int col0 = col - 2; + int col1 = col - 1; + int col2 = col; + int col3 = col + 1; - if ( col1 < 0 ) - col1 = col2; + if (col1 < 0) + col1 = col2; - if ( col0 < 0 ) - col0 = col1; + if (col0 < 0) + col0 = col1; - if ( col2 >= m_data->numColumns ) - col2 = col1; + if (col2 >= m_data->numColumns) + col2 = col1; - if ( col3 >= m_data->numColumns ) - col3 = col2; + if (col3 >= m_data->numColumns) + col3 = col2; - int row0 = row - 2; - int row1 = row - 1; - int row2 = row; - int row3 = row + 1; + int row0 = row - 2; + int row1 = row - 1; + int row2 = row; + int row3 = row + 1; - if ( row1 < 0 ) - row1 = row2; + if (row1 < 0) + row1 = row2; - if ( row0 < 0 ) - row0 = row1; + if (row0 < 0) + row0 = row1; - if ( row2 >= m_data->numRows ) - row2 = row1; + if (row2 >= m_data->numRows) + row2 = row1; - if ( row3 >= m_data->numRows ) - row3 = row2; + if (row3 >= m_data->numRows) + row3 = row2; - // First row - const double v00 = m_data->value( row0, col0 ); - const double v10 = m_data->value( row0, col1 ); - const double v20 = m_data->value( row0, col2 ); - const double v30 = m_data->value( row0, col3 ); + // First row + const double v00 = m_data->value(row0, col0); + const double v10 = m_data->value(row0, col1); + const double v20 = m_data->value(row0, col2); + const double v30 = m_data->value(row0, col3); - // Second row - const double v01 = m_data->value( row1, col0 ); - const double v11 = m_data->value( row1, col1 ); - const double v21 = m_data->value( row1, col2 ); - const double v31 = m_data->value( row1, col3 ); + // Second row + const double v01 = m_data->value(row1, col0); + const double v11 = m_data->value(row1, col1); + const double v21 = m_data->value(row1, col2); + const double v31 = m_data->value(row1, col3); - // Third row - const double v02 = m_data->value( row2, col0 ); - const double v12 = m_data->value( row2, col1 ); - const double v22 = m_data->value( row2, col2 ); - const double v32 = m_data->value( row2, col3 ); + // Third row + const double v02 = m_data->value(row2, col0); + const double v12 = m_data->value(row2, col1); + const double v22 = m_data->value(row2, col2); + const double v32 = m_data->value(row2, col3); - // Fourth row - const double v03 = m_data->value( row3, col0 ); - const double v13 = m_data->value( row3, col1 ); - const double v23 = m_data->value( row3, col2 ); - const double v33 = m_data->value( row3, col3 ); + // Fourth row + const double v03 = m_data->value(row3, col0); + const double v13 = m_data->value(row3, col1); + const double v23 = m_data->value(row3, col2); + const double v33 = m_data->value(row3, col3); - value = qwtBicubicInterpolate( - v00, v10, v20, v30, v01, v11, v21, v31, - v02, v12, v22, v32, v03, v13, v23, v33, - colF - col + 0.5, rowF - row + 0.5 ); + value = qwtBicubicInterpolate(v00, v10, v20, v30, v01, v11, v21, v31, v02, + v12, v22, v32, v03, v13, v23, v33, + colF - col + 0.5, rowF - row + 0.5); - break; - } - case BilinearInterpolation: - { - int col1 = qRound( ( x - xInterval.minValue() ) / m_data->dx ) - 1; - int row1 = qRound( ( y - yInterval.minValue() ) / m_data->dy ) - 1; - int col2 = col1 + 1; - int row2 = row1 + 1; - - if ( col1 < 0 ) - col1 = col2; - else if ( col2 >= m_data->numColumns ) - col2 = col1; - - if ( row1 < 0 ) - row1 = row2; - else if ( row2 >= m_data->numRows ) - row2 = row1; - - const double v11 = m_data->value( row1, col1 ); - const double v21 = m_data->value( row1, col2 ); - const double v12 = m_data->value( row2, col1 ); - const double v22 = m_data->value( row2, col2 ); - - const double x2 = xInterval.minValue() + ( col2 + 0.5 ) * m_data->dx; - const double y2 = yInterval.minValue() + ( row2 + 0.5 ) * m_data->dy; - - const double rx = ( x2 - x ) / m_data->dx; - const double ry = ( y2 - y ) / m_data->dy; - - const double vr1 = rx * v11 + ( 1.0 - rx ) * v21; - const double vr2 = rx * v12 + ( 1.0 - rx ) * v22; - - value = ry * vr1 + ( 1.0 - ry ) * vr2; - - break; - } - case NearestNeighbour: - default: - { - int row = int( ( y - yInterval.minValue() ) / m_data->dy ); - int col = int( ( x - xInterval.minValue() ) / m_data->dx ); - - // In case of intervals, where the maximum is included - // we get out of bound for row/col, when the value for the - // maximum is requested. Instead we return the value - // from the last row/col - - if ( row >= m_data->numRows ) - row = m_data->numRows - 1; - - if ( col >= m_data->numColumns ) - col = m_data->numColumns - 1; - - value = m_data->value( row, col ); - } + break; } + case BilinearInterpolation: { + int col1 = qRound((x - xInterval.minValue()) / m_data->dx) - 1; + int row1 = qRound((y - yInterval.minValue()) / m_data->dy) - 1; + int col2 = col1 + 1; + int row2 = row1 + 1; - return value; + if (col1 < 0) + col1 = col2; + else if (col2 >= m_data->numColumns) + col2 = col1; + + if (row1 < 0) + row1 = row2; + else if (row2 >= m_data->numRows) + row2 = row1; + + const double v11 = m_data->value(row1, col1); + const double v21 = m_data->value(row1, col2); + const double v12 = m_data->value(row2, col1); + const double v22 = m_data->value(row2, col2); + + const double x2 = xInterval.minValue() + (col2 + 0.5) * m_data->dx; + const double y2 = yInterval.minValue() + (row2 + 0.5) * m_data->dy; + + const double rx = (x2 - x) / m_data->dx; + const double ry = (y2 - y) / m_data->dy; + + const double vr1 = rx * v11 + (1.0 - rx) * v21; + const double vr2 = rx * v12 + (1.0 - rx) * v22; + + value = ry * vr1 + (1.0 - ry) * vr2; + + break; + } + case NearestNeighbour: + default: { + int row = int((y - yInterval.minValue()) / m_data->dy); + int col = int((x - xInterval.minValue()) / m_data->dx); + + // In case of intervals, where the maximum is included + // we get out of bound for row/col, when the value for the + // maximum is requested. Instead we return the value + // from the last row/col + + if (row >= m_data->numRows) + row = m_data->numRows - 1; + + if (col >= m_data->numColumns) + col = m_data->numColumns - 1; + + value = m_data->value(row, col); + } + } + + return value; } void QwtMatrixRasterData::update() { - m_data->numRows = 0; - m_data->dx = 0.0; - m_data->dy = 0.0; + m_data->numRows = 0; + m_data->dx = 0.0; + m_data->dy = 0.0; - if ( m_data->numColumns > 0 ) - { - m_data->numRows = m_data->values.size() / m_data->numColumns; + if (m_data->numColumns > 0) + { + m_data->numRows = m_data->values.size() / m_data->numColumns; - const QwtInterval xInterval = interval( Qt::XAxis ); - const QwtInterval yInterval = interval( Qt::YAxis ); - if ( xInterval.isValid() ) - m_data->dx = xInterval.width() / m_data->numColumns; - if ( yInterval.isValid() ) - m_data->dy = yInterval.width() / m_data->numRows; - } + const QwtInterval xInterval = interval(Qt::XAxis); + const QwtInterval yInterval = interval(Qt::YAxis); + if (xInterval.isValid()) + m_data->dx = xInterval.width() / m_data->numColumns; + if (yInterval.isValid()) + m_data->dy = yInterval.width() / m_data->numRows; + } } diff --git a/libs/qwt/src/qwt_matrix_raster_data.h b/libs/qwt/src/qwt_matrix_raster_data.h index 96f625d5..bb33a702 100644 --- a/libs/qwt/src/qwt_matrix_raster_data.h +++ b/libs/qwt/src/qwt_matrix_raster_data.h @@ -14,7 +14,8 @@ #include "qwt_raster_data.h" #if QT_VERSION < 0x060000 -template< typename T > class QVector; +template +class QVector; #endif /*! @@ -27,58 +28,58 @@ template< typename T > class QVector; */ class QWT_EXPORT QwtMatrixRasterData : public QwtRasterData { - public: +public: + /*! + \brief Resampling algorithm + The default setting is NearestNeighbour; + */ + enum ResampleMode + { /*! - \brief Resampling algorithm - The default setting is NearestNeighbour; + Return the value from the matrix, that is nearest to the + the requested position. */ - enum ResampleMode - { - /*! - Return the value from the matrix, that is nearest to the - the requested position. - */ - NearestNeighbour, + NearestNeighbour, - /*! - Interpolate the value from the distances and values of the - 4 surrounding values in the matrix, - */ - BilinearInterpolation, + /*! + Interpolate the value from the distances and values of the + 4 surrounding values in the matrix, + */ + BilinearInterpolation, - /*! - Interpolate the value from the 16 surrounding values in the - matrix using hermite bicubic interpolation - */ - BicubicInterpolation - }; + /*! + Interpolate the value from the 16 surrounding values in the + matrix using hermite bicubic interpolation + */ + BicubicInterpolation + }; - QwtMatrixRasterData(); - virtual ~QwtMatrixRasterData(); + QwtMatrixRasterData(); + virtual ~QwtMatrixRasterData(); - void setResampleMode(ResampleMode mode); - ResampleMode resampleMode() const; + void setResampleMode(ResampleMode mode); + ResampleMode resampleMode() const; - void setInterval( Qt::Axis, const QwtInterval& ); - virtual QwtInterval interval( Qt::Axis axis) const QWT_OVERRIDE QWT_FINAL; + void setInterval(Qt::Axis, const QwtInterval &); + virtual QwtInterval interval(Qt::Axis axis) const QWT_OVERRIDE QWT_FINAL; - void setValueMatrix( const QVector< double >& values, int numColumns ); - const QVector< double > valueMatrix() const; + void setValueMatrix(const QVector &values, int numColumns); + const QVector valueMatrix() const; - void setValue( int row, int col, double value ); + void setValue(int row, int col, double value); - int numColumns() const; - int numRows() const; + int numColumns() const; + int numRows() const; - virtual QRectF pixelHint( const QRectF& ) const QWT_OVERRIDE; + virtual QRectF pixelHint(const QRectF &) const QWT_OVERRIDE; - virtual double value( double x, double y ) const QWT_OVERRIDE; + virtual double value(double x, double y) const QWT_OVERRIDE; - private: - void update(); +private: + void update(); - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_null_paintdevice.cpp b/libs/qwt/src/qwt_null_paintdevice.cpp index 922b32da..c8d54aff 100644 --- a/libs/qwt/src/qwt_null_paintdevice.cpp +++ b/libs/qwt/src/qwt_null_paintdevice.cpp @@ -13,368 +13,365 @@ class QwtNullPaintDevice::PrivateData { - public: - PrivateData(): - mode( QwtNullPaintDevice::NormalMode ) - { - } +public: + PrivateData() + : mode(QwtNullPaintDevice::NormalMode) + { + } - QwtNullPaintDevice::Mode mode; + QwtNullPaintDevice::Mode mode; }; class QwtNullPaintDevice::PaintEngine QWT_FINAL : public QPaintEngine { - public: - PaintEngine(); +public: + PaintEngine(); - virtual bool begin( QPaintDevice* ) QWT_OVERRIDE; - virtual bool end() QWT_OVERRIDE; + virtual bool begin(QPaintDevice *) QWT_OVERRIDE; + virtual bool end() QWT_OVERRIDE; - virtual Type type () const QWT_OVERRIDE; - virtual void updateState(const QPaintEngineState&) QWT_OVERRIDE; + virtual Type type() const QWT_OVERRIDE; + virtual void updateState(const QPaintEngineState &) QWT_OVERRIDE; - virtual void drawRects(const QRect*, int ) QWT_OVERRIDE; - virtual void drawRects(const QRectF*, int ) QWT_OVERRIDE; + virtual void drawRects(const QRect *, int) QWT_OVERRIDE; + virtual void drawRects(const QRectF *, int) QWT_OVERRIDE; - virtual void drawLines(const QLine*, int ) QWT_OVERRIDE; - virtual void drawLines(const QLineF*, int ) QWT_OVERRIDE; + virtual void drawLines(const QLine *, int) QWT_OVERRIDE; + virtual void drawLines(const QLineF *, int) QWT_OVERRIDE; - virtual void drawEllipse(const QRectF&) QWT_OVERRIDE; - virtual void drawEllipse(const QRect&) QWT_OVERRIDE; + virtual void drawEllipse(const QRectF &) QWT_OVERRIDE; + virtual void drawEllipse(const QRect &) QWT_OVERRIDE; - virtual void drawPath(const QPainterPath&) QWT_OVERRIDE; + virtual void drawPath(const QPainterPath &) QWT_OVERRIDE; - virtual void drawPoints(const QPointF*, int ) QWT_OVERRIDE; - virtual void drawPoints(const QPoint*, int ) QWT_OVERRIDE; + virtual void drawPoints(const QPointF *, int) QWT_OVERRIDE; + virtual void drawPoints(const QPoint *, int) QWT_OVERRIDE; - virtual void drawPolygon( - const QPointF*, int, PolygonDrawMode ) QWT_OVERRIDE; + virtual void drawPolygon(const QPointF *, int, PolygonDrawMode) QWT_OVERRIDE; - virtual void drawPolygon( - const QPoint*, int, PolygonDrawMode ) QWT_OVERRIDE; + virtual void drawPolygon(const QPoint *, int, PolygonDrawMode) QWT_OVERRIDE; - virtual void drawPixmap(const QRectF&, - const QPixmap&, const QRectF&) QWT_OVERRIDE; + virtual void drawPixmap(const QRectF &, const QPixmap &, + const QRectF &) QWT_OVERRIDE; - virtual void drawTextItem( - const QPointF&, const QTextItem&) QWT_OVERRIDE; + virtual void drawTextItem(const QPointF &, const QTextItem &) QWT_OVERRIDE; - virtual void drawTiledPixmap(const QRectF&, - const QPixmap&, const QPointF& s) QWT_OVERRIDE; + virtual void drawTiledPixmap(const QRectF &, const QPixmap &, + const QPointF &s) QWT_OVERRIDE; - virtual void drawImage(const QRectF&, const QImage&, - const QRectF&, Qt::ImageConversionFlags ) QWT_OVERRIDE; + virtual void drawImage(const QRectF &, const QImage &, const QRectF &, + Qt::ImageConversionFlags) QWT_OVERRIDE; - private: - QwtNullPaintDevice* nullDevice(); +private: + QwtNullPaintDevice *nullDevice(); }; QwtNullPaintDevice::PaintEngine::PaintEngine() - : QPaintEngine( QPaintEngine::AllFeatures ) + : QPaintEngine(QPaintEngine::AllFeatures) { } -bool QwtNullPaintDevice::PaintEngine::begin( QPaintDevice* ) +bool QwtNullPaintDevice::PaintEngine::begin(QPaintDevice *) { - setActive( true ); - return true; + setActive(true); + return true; } bool QwtNullPaintDevice::PaintEngine::end() { - setActive( false ); - return true; + setActive(false); + return true; } QPaintEngine::Type QwtNullPaintDevice::PaintEngine::type() const { - /* - How to avoid conflicts with other 3rd party pain engines ? - At least we don't use QPaintEngine::User what is known to - be the value of some print engines - */ - return static_cast< QPaintEngine::Type >( QPaintEngine::MaxUser - 2 ); + /* + How to avoid conflicts with other 3rd party pain engines ? + At least we don't use QPaintEngine::User what is known to + be the value of some print engines + */ + return static_cast(QPaintEngine::MaxUser - 2); } -void QwtNullPaintDevice::PaintEngine::drawRects( - const QRect* rects, int rectCount) +void QwtNullPaintDevice::PaintEngine::drawRects(const QRect *rects, + int rectCount) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - if ( device->mode() != QwtNullPaintDevice::NormalMode ) + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawRects(rects, rectCount); + return; + } + + device->drawRects(rects, rectCount); +} + +void QwtNullPaintDevice::PaintEngine::drawRects(const QRectF *rects, + int rectCount) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawRects(rects, rectCount); + return; + } + + device->drawRects(rects, rectCount); +} + +void QwtNullPaintDevice::PaintEngine::drawLines(const QLine *lines, + int lineCount) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawLines(lines, lineCount); + return; + } + + device->drawLines(lines, lineCount); +} + +void QwtNullPaintDevice::PaintEngine::drawLines(const QLineF *lines, + int lineCount) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawLines(lines, lineCount); + return; + } + + device->drawLines(lines, lineCount); +} + +void QwtNullPaintDevice::PaintEngine::drawEllipse(const QRectF &rect) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawEllipse(rect); + return; + } + + device->drawEllipse(rect); +} + +void QwtNullPaintDevice::PaintEngine::drawEllipse(const QRect &rect) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawEllipse(rect); + return; + } + + device->drawEllipse(rect); +} + +void QwtNullPaintDevice::PaintEngine::drawPath(const QPainterPath &path) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + device->drawPath(path); +} + +void QwtNullPaintDevice::PaintEngine::drawPoints(const QPointF *points, + int pointCount) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawPoints(points, pointCount); + return; + } + + device->drawPoints(points, pointCount); +} + +void QwtNullPaintDevice::PaintEngine::drawPoints(const QPoint *points, + int pointCount) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawPoints(points, pointCount); + return; + } + + device->drawPoints(points, pointCount); +} + +void QwtNullPaintDevice::PaintEngine::drawPolygon(const QPointF *points, + int pointCount, + PolygonDrawMode mode) +{ + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; + + if (device->mode() == QwtNullPaintDevice::PathMode) + { + QPainterPath path; + + if (pointCount > 0) { - QPaintEngine::drawRects( rects, rectCount ); - return; + path.moveTo(points[0]); + for (int i = 1; i < pointCount; i++) + path.lineTo(points[i]); + + if (mode != PolylineMode) + path.closeSubpath(); } - device->drawRects( rects, rectCount ); + device->drawPath(path); + return; + } + + device->drawPolygon(points, pointCount, mode); } -void QwtNullPaintDevice::PaintEngine::drawRects( - const QRectF* rects, int rectCount) +void QwtNullPaintDevice::PaintEngine::drawPolygon(const QPoint *points, + int pointCount, + PolygonDrawMode mode) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - if ( device->mode() != QwtNullPaintDevice::NormalMode ) + if (device->mode() == QwtNullPaintDevice::PathMode) + { + QPainterPath path; + + if (pointCount > 0) { - QPaintEngine::drawRects( rects, rectCount ); - return; + path.moveTo(points[0]); + for (int i = 1; i < pointCount; i++) + path.lineTo(points[i]); + + if (mode != PolylineMode) + path.closeSubpath(); } - device->drawRects( rects, rectCount ); + device->drawPath(path); + return; + } + + device->drawPolygon(points, pointCount, mode); } -void QwtNullPaintDevice::PaintEngine::drawLines( - const QLine* lines, int lineCount) +void QwtNullPaintDevice::PaintEngine::drawPixmap(const QRectF &rect, + const QPixmap &pm, + const QRectF &subRect) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawLines( lines, lineCount ); - return; - } - - device->drawLines( lines, lineCount ); + device->drawPixmap(rect, pm, subRect); } -void QwtNullPaintDevice::PaintEngine::drawLines( - const QLineF* lines, int lineCount) +void QwtNullPaintDevice::PaintEngine::drawTextItem(const QPointF &pos, + const QTextItem &textItem) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawLines( lines, lineCount ); - return; - } + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawTextItem(pos, textItem); + return; + } - device->drawLines( lines, lineCount ); + device->drawTextItem(pos, textItem); } -void QwtNullPaintDevice::PaintEngine::drawEllipse( - const QRectF& rect) +void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(const QRectF &rect, + const QPixmap &pixmap, + const QPointF &subRect) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawEllipse( rect ); - return; - } + if (device->mode() != QwtNullPaintDevice::NormalMode) + { + QPaintEngine::drawTiledPixmap(rect, pixmap, subRect); + return; + } - device->drawEllipse( rect ); + device->drawTiledPixmap(rect, pixmap, subRect); } -void QwtNullPaintDevice::PaintEngine::drawEllipse( - const QRect& rect) +void QwtNullPaintDevice::PaintEngine::drawImage(const QRectF &rect, + const QImage &image, + const QRectF &subRect, + Qt::ImageConversionFlags flags) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawEllipse( rect ); - return; - } - - device->drawEllipse( rect ); -} - - -void QwtNullPaintDevice::PaintEngine::drawPath( - const QPainterPath& path) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - device->drawPath( path ); -} - -void QwtNullPaintDevice::PaintEngine::drawPoints( - const QPointF* points, int pointCount) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawPoints( points, pointCount ); - return; - } - - device->drawPoints( points, pointCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawPoints( - const QPoint* points, int pointCount) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawPoints( points, pointCount ); - return; - } - - device->drawPoints( points, pointCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawPolygon( - const QPointF* points, int pointCount, PolygonDrawMode mode) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - if ( device->mode() == QwtNullPaintDevice::PathMode ) - { - QPainterPath path; - - if ( pointCount > 0 ) - { - path.moveTo( points[0] ); - for ( int i = 1; i < pointCount; i++ ) - path.lineTo( points[i] ); - - if ( mode != PolylineMode ) - path.closeSubpath(); - } - - device->drawPath( path ); - return; - } - - device->drawPolygon( points, pointCount, mode ); -} - -void QwtNullPaintDevice::PaintEngine::drawPolygon( - const QPoint* points, int pointCount, PolygonDrawMode mode) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - if ( device->mode() == QwtNullPaintDevice::PathMode ) - { - QPainterPath path; - - if ( pointCount > 0 ) - { - path.moveTo( points[0] ); - for ( int i = 1; i < pointCount; i++ ) - path.lineTo( points[i] ); - - if ( mode != PolylineMode ) - path.closeSubpath(); - } - - device->drawPath( path ); - return; - } - - device->drawPolygon( points, pointCount, mode ); -} - -void QwtNullPaintDevice::PaintEngine::drawPixmap( - const QRectF& rect, const QPixmap& pm, const QRectF& subRect ) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - device->drawPixmap( rect, pm, subRect ); -} - -void QwtNullPaintDevice::PaintEngine::drawTextItem( - const QPointF& pos, const QTextItem& textItem) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawTextItem( pos, textItem ); - return; - } - - device->drawTextItem( pos, textItem ); -} - -void QwtNullPaintDevice::PaintEngine::drawTiledPixmap( - const QRectF& rect, const QPixmap& pixmap, - const QPointF& subRect) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - if ( device->mode() != QwtNullPaintDevice::NormalMode ) - { - QPaintEngine::drawTiledPixmap( rect, pixmap, subRect ); - return; - } - - device->drawTiledPixmap( rect, pixmap, subRect ); -} - -void QwtNullPaintDevice::PaintEngine::drawImage( - const QRectF& rect, const QImage& image, - const QRectF& subRect, Qt::ImageConversionFlags flags) -{ - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; - - device->drawImage( rect, image, subRect, flags ); + device->drawImage(rect, image, subRect, flags); } void QwtNullPaintDevice::PaintEngine::updateState( - const QPaintEngineState& engineState) + const QPaintEngineState &engineState) { - QwtNullPaintDevice* device = nullDevice(); - if ( device == NULL ) - return; + QwtNullPaintDevice *device = nullDevice(); + if (device == NULL) + return; - device->updateState( engineState ); + device->updateState(engineState); } -inline QwtNullPaintDevice* QwtNullPaintDevice::PaintEngine::nullDevice() +inline QwtNullPaintDevice *QwtNullPaintDevice::PaintEngine::nullDevice() { - if ( !isActive() ) - return NULL; + if (!isActive()) + return NULL; - return static_cast< QwtNullPaintDevice* >( paintDevice() ); + return static_cast(paintDevice()); } //! Constructor -QwtNullPaintDevice::QwtNullPaintDevice(): - m_engine( NULL ) +QwtNullPaintDevice::QwtNullPaintDevice() + : m_engine(NULL) { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtNullPaintDevice::~QwtNullPaintDevice() { - delete m_engine; - delete m_data; + delete m_engine; + delete m_data; } /*! @@ -383,9 +380,9 @@ QwtNullPaintDevice::~QwtNullPaintDevice() \param mode New mode \sa mode() */ -void QwtNullPaintDevice::setMode( Mode mode ) +void QwtNullPaintDevice::setMode(Mode mode) { - m_data->mode = mode; + m_data->mode = mode; } /*! @@ -394,21 +391,20 @@ void QwtNullPaintDevice::setMode( Mode mode ) */ QwtNullPaintDevice::Mode QwtNullPaintDevice::mode() const { - return m_data->mode; + return m_data->mode; } //! See QPaintDevice::paintEngine() -QPaintEngine* QwtNullPaintDevice::paintEngine() const +QPaintEngine *QwtNullPaintDevice::paintEngine() const { - if ( m_engine == NULL ) - { - QwtNullPaintDevice* that = - const_cast< QwtNullPaintDevice* >( this ); + if (m_engine == NULL) + { + QwtNullPaintDevice *that = const_cast(this); - that->m_engine = new PaintEngine(); - } + that->m_engine = new PaintEngine(); + } - return m_engine; + return m_engine; } /*! @@ -419,184 +415,167 @@ QPaintEngine* QwtNullPaintDevice::paintEngine() const \sa sizeMetrics() */ -int QwtNullPaintDevice::metric( PaintDeviceMetric deviceMetric ) const +int QwtNullPaintDevice::metric(PaintDeviceMetric deviceMetric) const { - int value; + int value; - switch ( deviceMetric ) - { - case PdmWidth: - { - value = sizeMetrics().width(); - break; - } - case PdmHeight: - { - value = sizeMetrics().height(); - break; - } - case PdmNumColors: - { - value = 0xffffffff; - break; - } - case PdmDepth: - { - value = 32; - break; - } - case PdmPhysicalDpiX: - case PdmPhysicalDpiY: - case PdmDpiY: - case PdmDpiX: - { - value = 72; - break; - } - case PdmWidthMM: - { - value = qRound( metric( PdmWidth ) * 25.4 / metric( PdmDpiX ) ); - break; - } - case PdmHeightMM: - { - value = qRound( metric( PdmHeight ) * 25.4 / metric( PdmDpiY ) ); - break; - } - default: - value = 0; + switch (deviceMetric) + { + case PdmWidth: { + value = sizeMetrics().width(); + break; } - return value; - + case PdmHeight: { + value = sizeMetrics().height(); + break; + } + case PdmNumColors: { + value = 0xffffffff; + break; + } + case PdmDepth: { + value = 32; + break; + } + case PdmPhysicalDpiX: + case PdmPhysicalDpiY: + case PdmDpiY: + case PdmDpiX: { + value = 72; + break; + } + case PdmWidthMM: { + value = qRound(metric(PdmWidth) * 25.4 / metric(PdmDpiX)); + break; + } + case PdmHeightMM: { + value = qRound(metric(PdmHeight) * 25.4 / metric(PdmDpiY)); + break; + } + default: + value = 0; + } + return value; } //! See QPaintEngine::drawRects() -void QwtNullPaintDevice::drawRects( - const QRect* rects, int rectCount) +void QwtNullPaintDevice::drawRects(const QRect *rects, int rectCount) { - Q_UNUSED(rects); - Q_UNUSED(rectCount); + Q_UNUSED(rects); + Q_UNUSED(rectCount); } //! See QPaintEngine::drawRects() -void QwtNullPaintDevice::drawRects( - const QRectF* rects, int rectCount) +void QwtNullPaintDevice::drawRects(const QRectF *rects, int rectCount) { - Q_UNUSED(rects); - Q_UNUSED(rectCount); + Q_UNUSED(rects); + Q_UNUSED(rectCount); } //! See QPaintEngine::drawLines() -void QwtNullPaintDevice::drawLines( - const QLine* lines, int lineCount) +void QwtNullPaintDevice::drawLines(const QLine *lines, int lineCount) { - Q_UNUSED(lines); - Q_UNUSED(lineCount); + Q_UNUSED(lines); + Q_UNUSED(lineCount); } //! See QPaintEngine::drawLines() -void QwtNullPaintDevice::drawLines( - const QLineF* lines, int lineCount) +void QwtNullPaintDevice::drawLines(const QLineF *lines, int lineCount) { - Q_UNUSED(lines); - Q_UNUSED(lineCount); + Q_UNUSED(lines); + Q_UNUSED(lineCount); } //! See QPaintEngine::drawEllipse() -void QwtNullPaintDevice::drawEllipse( const QRectF& rect ) +void QwtNullPaintDevice::drawEllipse(const QRectF &rect) { - Q_UNUSED(rect); + Q_UNUSED(rect); } //! See QPaintEngine::drawEllipse() -void QwtNullPaintDevice::drawEllipse( const QRect& rect ) +void QwtNullPaintDevice::drawEllipse(const QRect &rect) { - Q_UNUSED(rect); + Q_UNUSED(rect); } //! See QPaintEngine::drawPath() -void QwtNullPaintDevice::drawPath( const QPainterPath& path ) +void QwtNullPaintDevice::drawPath(const QPainterPath &path) { - Q_UNUSED(path); + Q_UNUSED(path); } //! See QPaintEngine::drawPoints() -void QwtNullPaintDevice::drawPoints( - const QPointF* points, int pointCount) +void QwtNullPaintDevice::drawPoints(const QPointF *points, int pointCount) { - Q_UNUSED(points); - Q_UNUSED(pointCount); + Q_UNUSED(points); + Q_UNUSED(pointCount); } //! See QPaintEngine::drawPoints() -void QwtNullPaintDevice::drawPoints( - const QPoint* points, int pointCount) +void QwtNullPaintDevice::drawPoints(const QPoint *points, int pointCount) { - Q_UNUSED(points); - Q_UNUSED(pointCount); + Q_UNUSED(points); + Q_UNUSED(pointCount); } //! See QPaintEngine::drawPolygon() -void QwtNullPaintDevice::drawPolygon( - const QPointF* points, int pointCount, - QPaintEngine::PolygonDrawMode mode) +void QwtNullPaintDevice::drawPolygon(const QPointF *points, int pointCount, + QPaintEngine::PolygonDrawMode mode) { - Q_UNUSED(points); - Q_UNUSED(pointCount); - Q_UNUSED(mode); + Q_UNUSED(points); + Q_UNUSED(pointCount); + Q_UNUSED(mode); } //! See QPaintEngine::drawPolygon() -void QwtNullPaintDevice::drawPolygon( - const QPoint* points, int pointCount, - QPaintEngine::PolygonDrawMode mode) +void QwtNullPaintDevice::drawPolygon(const QPoint *points, int pointCount, + QPaintEngine::PolygonDrawMode mode) { - Q_UNUSED(points); - Q_UNUSED(pointCount); - Q_UNUSED(mode); + Q_UNUSED(points); + Q_UNUSED(pointCount); + Q_UNUSED(mode); } //! See QPaintEngine::drawPixmap() -void QwtNullPaintDevice::drawPixmap( const QRectF& rect, - const QPixmap& pm, const QRectF& subRect ) +void QwtNullPaintDevice::drawPixmap(const QRectF &rect, const QPixmap &pm, + const QRectF &subRect) { - Q_UNUSED(rect); - Q_UNUSED(pm); - Q_UNUSED(subRect); + Q_UNUSED(rect); + Q_UNUSED(pm); + Q_UNUSED(subRect); } //! See QPaintEngine::drawTextItem() -void QwtNullPaintDevice::drawTextItem( - const QPointF& pos, const QTextItem& textItem) +void QwtNullPaintDevice::drawTextItem(const QPointF &pos, + const QTextItem &textItem) { - Q_UNUSED(pos); - Q_UNUSED(textItem); + Q_UNUSED(pos); + Q_UNUSED(textItem); } //! See QPaintEngine::drawTiledPixmap() -void QwtNullPaintDevice::drawTiledPixmap( - const QRectF& rect, const QPixmap& pixmap, - const QPointF& subRect) +void QwtNullPaintDevice::drawTiledPixmap(const QRectF &rect, + const QPixmap &pixmap, + const QPointF &subRect) { - Q_UNUSED(rect); - Q_UNUSED(pixmap); - Q_UNUSED(subRect); + Q_UNUSED(rect); + Q_UNUSED(pixmap); + Q_UNUSED(subRect); } //! See QPaintEngine::drawImage() -void QwtNullPaintDevice::drawImage( - const QRectF& rect, const QImage& image, - const QRectF& subRect, Qt::ImageConversionFlags flags) +void QwtNullPaintDevice::drawImage(const QRectF &rect, const QImage &image, + const QRectF &subRect, + Qt::ImageConversionFlags flags) { - Q_UNUSED(rect); - Q_UNUSED(image); - Q_UNUSED(subRect); - Q_UNUSED(flags); + Q_UNUSED(rect); + Q_UNUSED(image); + Q_UNUSED(subRect); + Q_UNUSED(flags); } //! See QPaintEngine::updateState() -void QwtNullPaintDevice::updateState( - const QPaintEngineState& state ) +void QwtNullPaintDevice::updateState(const QPaintEngineState &state) { - Q_UNUSED(state); + Q_UNUSED(state); } diff --git a/libs/qwt/src/qwt_null_paintdevice.h b/libs/qwt/src/qwt_null_paintdevice.h index 76118970..39059954 100644 --- a/libs/qwt/src/qwt_null_paintdevice.h +++ b/libs/qwt/src/qwt_null_paintdevice.h @@ -31,97 +31,94 @@ class QWT_EXPORT QwtNullPaintDevice : public QPaintDevice { - public: +public: + /*! + \brief Render mode + + \sa setMode(), mode() + */ + enum Mode + { /*! - \brief Render mode - - \sa setMode(), mode() + All vector graphic primitives are painted by + the corresponding draw methods */ - enum Mode - { - /*! - All vector graphic primitives are painted by - the corresponding draw methods - */ - NormalMode, + NormalMode, - /*! - Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath - and are painted by drawPath. In PathMode mode - only a few draw methods are called: + /*! + Vector graphic primitives ( beside polygons ) are mapped to a + QPainterPath and are painted by drawPath. In PathMode mode only a few + draw methods are called: - - drawPath() - - drawPixmap() - - drawImage() - - drawPolygon() - */ - PolygonPathMode, + - drawPath() + - drawPixmap() + - drawImage() + - drawPolygon() + */ + PolygonPathMode, - /*! - Vector graphic primitives are mapped to a QPainterPath - and are painted by drawPath. In PathMode mode - only a few draw methods are called: + /*! + Vector graphic primitives are mapped to a QPainterPath + and are painted by drawPath. In PathMode mode + only a few draw methods are called: - - drawPath() - - drawPixmap() - - drawImage() - */ - PathMode - }; + - drawPath() + - drawPixmap() + - drawImage() + */ + PathMode + }; - QwtNullPaintDevice(); - virtual ~QwtNullPaintDevice(); + QwtNullPaintDevice(); + virtual ~QwtNullPaintDevice(); - void setMode( Mode ); - Mode mode() const; + void setMode(Mode); + Mode mode() const; - virtual QPaintEngine* paintEngine() const QWT_OVERRIDE; + virtual QPaintEngine *paintEngine() const QWT_OVERRIDE; - virtual int metric( PaintDeviceMetric ) const QWT_OVERRIDE; + virtual int metric(PaintDeviceMetric) const QWT_OVERRIDE; - virtual void drawRects(const QRect*, int ); - virtual void drawRects(const QRectF*, int ); + virtual void drawRects(const QRect *, int); + virtual void drawRects(const QRectF *, int); - virtual void drawLines(const QLine*, int ); - virtual void drawLines(const QLineF*, int ); + virtual void drawLines(const QLine *, int); + virtual void drawLines(const QLineF *, int); - virtual void drawEllipse(const QRectF&); - virtual void drawEllipse(const QRect&); + virtual void drawEllipse(const QRectF &); + virtual void drawEllipse(const QRect &); - virtual void drawPath(const QPainterPath&); + virtual void drawPath(const QPainterPath &); - virtual void drawPoints(const QPointF*, int ); - virtual void drawPoints(const QPoint*, int ); + virtual void drawPoints(const QPointF *, int); + virtual void drawPoints(const QPoint *, int); - virtual void drawPolygon( const QPointF*, int, - QPaintEngine::PolygonDrawMode ); + virtual void drawPolygon(const QPointF *, int, QPaintEngine::PolygonDrawMode); - virtual void drawPolygon( const QPoint*, int, - QPaintEngine::PolygonDrawMode ); + virtual void drawPolygon(const QPoint *, int, QPaintEngine::PolygonDrawMode); - virtual void drawPixmap(const QRectF&, - const QPixmap&, const QRectF&); + virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &); - virtual void drawTextItem(const QPointF&, const QTextItem&); + virtual void drawTextItem(const QPointF &, const QTextItem &); - virtual void drawTiledPixmap(const QRectF&, - const QPixmap&, const QPointF& ); + virtual void drawTiledPixmap(const QRectF &, const QPixmap &, + const QPointF &); - virtual void drawImage(const QRectF&, const QImage&, - const QRectF&, Qt::ImageConversionFlags ); + virtual void drawImage(const QRectF &, const QImage &, const QRectF &, + Qt::ImageConversionFlags); - virtual void updateState( const QPaintEngineState& ); + virtual void updateState(const QPaintEngineState &); - protected: - //! \return Size needed to implement metric() - virtual QSize sizeMetrics() const = 0; +protected: + //! \return Size needed to implement metric() + virtual QSize sizeMetrics() const = 0; - private: - class PaintEngine; - PaintEngine* m_engine; +private: + class PaintEngine; + PaintEngine *m_engine; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_painter.cpp b/libs/qwt/src/qwt_painter.cpp index f24486ea..f4d70c80 100644 --- a/libs/qwt/src/qwt_painter.cpp +++ b/libs/qwt/src/qwt_painter.cpp @@ -29,16 +29,16 @@ #include #if QT_VERSION >= 0x060000 -#include +# include #else -#include +# include #endif #if QT_VERSION < 0x050000 -#ifdef Q_WS_X11 -#include -#endif +# ifdef Q_WS_X11 +# include +# endif #endif @@ -76,151 +76,151 @@ static inline bool qwtIsRasterPaintEngineBuggy() #endif #if QT_VERSION < 0x050000 - return true; + return true; #elif QT_VERSION < 0x050100 - return false; + return false; #elif QT_VERSION < 0x050400 - return true; + return true; #else - return false; + return false; #endif } -static inline bool qwtIsClippingNeeded( - const QPainter* painter, QRectF& clipRect ) +static inline bool qwtIsClippingNeeded(const QPainter *painter, + QRectF &clipRect) { - bool doClipping = false; - const QPaintEngine* pe = painter->paintEngine(); - if ( pe && pe->type() == QPaintEngine::SVG ) + bool doClipping = false; + const QPaintEngine *pe = painter->paintEngine(); + if (pe && pe->type() == QPaintEngine::SVG) + { + // The SVG paint engine ignores any clipping, + + if (painter->hasClipping()) { - // The SVG paint engine ignores any clipping, - - if ( painter->hasClipping() ) - { - doClipping = true; - clipRect = painter->clipRegion().boundingRect(); - } + doClipping = true; + clipRect = painter->clipRegion().boundingRect(); } + } - return doClipping; + return doClipping; } -template< class T > -static inline void qwtDrawPolyline( QPainter* painter, - const T* points, int pointCount, bool polylineSplitting ) +template +static inline void qwtDrawPolyline(QPainter *painter, const T *points, + int pointCount, bool polylineSplitting) { - bool doSplit = false; - if ( polylineSplitting && pointCount > 3 ) + bool doSplit = false; + if (polylineSplitting && pointCount > 3) + { + const QPaintEngine *pe = painter->paintEngine(); + if (pe && pe->type() == QPaintEngine::Raster) { - const QPaintEngine* pe = painter->paintEngine(); - if ( pe && pe->type() == QPaintEngine::Raster ) - { - if ( painter->pen().width() <= 1 ) - { - // work around a bug with short lines below 2 pixels difference - // in height and width + if (painter->pen().width() <= 1) + { + // work around a bug with short lines below 2 pixels difference + // in height and width - doSplit = qwtIsRasterPaintEngineBuggy(); - } - else - { - /* - Raster paint engine is much faster when splitting - the polygon, but of course we might see some issues where - the pieces are joining - */ - doSplit = true; - } - } + doSplit = qwtIsRasterPaintEngineBuggy(); + } + else + { + /* + Raster paint engine is much faster when splitting + the polygon, but of course we might see some issues where + the pieces are joining + */ + doSplit = true; + } } + } - if ( doSplit ) + if (doSplit) + { + QPen pen = painter->pen(); + + const int splitSize = 6; + + if (pen.width() <= 1 && pen.isSolid() && qwtIsRasterPaintEngineBuggy() + && !(painter->renderHints() & QPainter::Antialiasing)) { - QPen pen = painter->pen(); + int k = 0; - const int splitSize = 6; + for (int i = k + 1; i < pointCount; i++) + { + const QPointF &p1 = points[i - 1]; + const QPointF &p2 = points[i]; - if ( pen.width() <= 1 && pen.isSolid() && qwtIsRasterPaintEngineBuggy() - && !( painter->renderHints() & QPainter::Antialiasing ) ) + const bool isBad + = (qAbs(p2.y() - p1.y()) <= 1) && qAbs(p2.x() - p1.x()) <= 1; + + if (isBad || (i - k >= splitSize)) { - int k = 0; - - for ( int i = k + 1; i < pointCount; i++ ) - { - const QPointF& p1 = points[i - 1]; - const QPointF& p2 = points[i]; - - const bool isBad = ( qAbs( p2.y() - p1.y() ) <= 1 ) - && qAbs( p2.x() - p1.x() ) <= 1; - - if ( isBad || ( i - k >= splitSize ) ) - { - painter->drawPolyline( points + k, i - k + 1 ); - k = i; - } - } - - painter->drawPolyline( points + k, pointCount - k ); - } - else - { - for ( int i = 0; i < pointCount; i += splitSize ) - { - const int n = qMin( splitSize + 1, pointCount - i ); - painter->drawPolyline( points + i, n ); - } + painter->drawPolyline(points + k, i - k + 1); + k = i; } + } + + painter->drawPolyline(points + k, pointCount - k); } else { - painter->drawPolyline( points, pointCount ); + for (int i = 0; i < pointCount; i += splitSize) + { + const int n = qMin(splitSize + 1, pointCount - i); + painter->drawPolyline(points + i, n); + } } + } + else + { + painter->drawPolyline(points, pointCount); + } } static inline QSize qwtScreenResolution() { - static QSize screenResolution; - if ( !screenResolution.isValid() ) - { - /* - We might have screens with different resolutions. TODO ... - */ + static QSize screenResolution; + if (!screenResolution.isValid()) + { + /* + We might have screens with different resolutions. TODO ... + */ #if QT_VERSION >= 0x060000 - QScreen* screen = QGuiApplication::primaryScreen(); - if ( screen ) - { - screenResolution.setWidth( screen->logicalDotsPerInchX() ); - screenResolution.setHeight( screen->logicalDotsPerInchY() ); - } -#else - QDesktopWidget* desktop = QApplication::desktop(); - if ( desktop ) - { - screenResolution.setWidth( desktop->logicalDpiX() ); - screenResolution.setHeight( desktop->logicalDpiY() ); - } -#endif + QScreen *screen = QGuiApplication::primaryScreen(); + if (screen) + { + screenResolution.setWidth(screen->logicalDotsPerInchX()); + screenResolution.setHeight(screen->logicalDotsPerInchY()); } +#else + QDesktopWidget *desktop = QApplication::desktop(); + if (desktop) + { + screenResolution.setWidth(desktop->logicalDpiX()); + screenResolution.setHeight(desktop->logicalDpiY()); + } +#endif + } - return screenResolution; + return screenResolution; } -static inline void qwtUnscaleFont( QPainter* painter ) +static inline void qwtUnscaleFont(QPainter *painter) { - if ( painter->font().pixelSize() >= 0 ) - return; + if (painter->font().pixelSize() >= 0) + return; - const QSize screenResolution = qwtScreenResolution(); + const QSize screenResolution = qwtScreenResolution(); - const QPaintDevice* pd = painter->device(); - if ( pd->logicalDpiX() != screenResolution.width() || - pd->logicalDpiY() != screenResolution.height() ) - { - QFont pixelFont = QwtPainter::scaledFont( painter->font() ); - pixelFont.setPixelSize( QFontInfo( pixelFont ).pixelSize() ); + const QPaintDevice *pd = painter->device(); + if (pd->logicalDpiX() != screenResolution.width() + || pd->logicalDpiY() != screenResolution.height()) + { + QFont pixelFont = QwtPainter::scaledFont(painter->font()); + pixelFont.setPixelSize(QFontInfo(pixelFont).pixelSize()); - painter->setFont( pixelFont ); - } + painter->setFont(pixelFont); + } } /*! @@ -232,22 +232,22 @@ static inline void qwtUnscaleFont( QPainter* painter ) */ bool QwtPainter::isX11GraphicsSystem() { - /* - The X11 paint engine has been removed with Qt 5.0, but - reintroduced with Qt 5.10. It can be enabled with - "export QT_XCB_NATIVE_PAINTING=1". - */ + /* + The X11 paint engine has been removed with Qt 5.0, but + reintroduced with Qt 5.10. It can be enabled with + "export QT_XCB_NATIVE_PAINTING=1". + */ - static int onX11 = -1; - if ( onX11 < 0 ) - { - QPixmap pm( 1, 1 ); - QPainter painter( &pm ); + static int onX11 = -1; + if (onX11 < 0) + { + QPixmap pm(1, 1); + QPainter painter(&pm); - onX11 = ( painter.paintEngine()->type() == QPaintEngine::X11 ) ? 1 : 0; - } + onX11 = (painter.paintEngine()->type() == QPaintEngine::X11) ? 1 : 0; + } - return onX11 == 1; + return onX11 == 1; } /*! @@ -264,41 +264,40 @@ bool QwtPainter::isX11GraphicsSystem() \sa setRoundingAlignment() */ -bool QwtPainter::isAligning( const QPainter* painter ) +bool QwtPainter::isAligning(const QPainter *painter) { - if ( painter && painter->isActive() ) + if (painter && painter->isActive()) + { + const QPaintEngine::Type type = painter->paintEngine()->type(); + + if (type >= QPaintEngine::User) { - const QPaintEngine::Type type = - painter->paintEngine()->type(); + // we have no idea - better don't align + return false; + } - if ( type >= QPaintEngine::User ) - { - // we have no idea - better don't align - return false; - } - - switch ( type ) - { - case QPaintEngine::Pdf: - case QPaintEngine::SVG: + switch (type) + { + case QPaintEngine::Pdf: + case QPaintEngine::SVG: #if 0 case QPaintEngine::MacPrinter: #endif - return false; + return false; - default: - break; - } - - const QTransform& tr = painter->transform(); - if ( tr.isRotating() || tr.isScaling() ) - { - // we might have to check translations too - return false; - } + default: + break; } - return true; + const QTransform &tr = painter->transform(); + if (tr.isRotating() || tr.isScaling()) + { + // we might have to check translations too + return false; + } + } + + return true; } /*! @@ -312,168 +311,166 @@ bool QwtPainter::isAligning( const QPainter* painter ) \sa roundingAlignment(), isAligning() */ -void QwtPainter::setRoundingAlignment( bool enable ) +void QwtPainter::setRoundingAlignment(bool enable) { - m_roundingAlignment = enable; + m_roundingAlignment = enable; } /*! \brief En/Disable line splitting for the raster paint engine In some Qt versions the raster paint engine paints polylines of many points - much faster when they are split in smaller chunks: f.e all supported Qt versions + much faster when they are split in smaller chunks: f.e all supported Qt + versions >= Qt 5.0 when drawing an antialiased polyline with a pen width >=2. - Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... ) - for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked - around in this mode. + Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... + ) for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is + worked around in this mode. The default setting is true. \sa polylineSplitting() */ -void QwtPainter::setPolylineSplitting( bool enable ) +void QwtPainter::setPolylineSplitting(bool enable) { - m_polylineSplitting = enable; + m_polylineSplitting = enable; } //! Wrapper for QPainter::drawPath() -void QwtPainter::drawPath( QPainter* painter, const QPainterPath& path ) +void QwtPainter::drawPath(QPainter *painter, const QPainterPath &path) { - painter->drawPath( path ); + painter->drawPath(path); } //! Wrapper for QPainter::drawRect() -void QwtPainter::drawRect( QPainter* painter, qreal x, qreal y, qreal w, qreal h ) +void QwtPainter::drawRect(QPainter *painter, qreal x, qreal y, qreal w, qreal h) { - drawRect( painter, QRectF( x, y, w, h ) ); + drawRect(painter, QRectF(x, y, w, h)); } //! Wrapper for QPainter::drawRect() -void QwtPainter::drawRect( QPainter* painter, const QRectF& rect ) +void QwtPainter::drawRect(QPainter *painter, const QRectF &rect) { - const QRectF r = rect; + const QRectF r = rect; - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) + if (deviceClipping) + { + if (!clipRect.intersects(r)) + return; + + if (!clipRect.contains(r)) { - if ( !clipRect.intersects( r ) ) - return; + fillRect(painter, r & clipRect, painter->brush()); - if ( !clipRect.contains( r ) ) - { - fillRect( painter, r & clipRect, painter->brush() ); + painter->save(); + painter->setBrush(Qt::NoBrush); + drawPolyline(painter, QPolygonF(r)); + painter->restore(); - painter->save(); - painter->setBrush( Qt::NoBrush ); - drawPolyline( painter, QPolygonF( r ) ); - painter->restore(); - - return; - } + return; } + } - painter->drawRect( r ); + painter->drawRect(r); } //! Wrapper for QPainter::fillRect() -void QwtPainter::fillRect( QPainter* painter, - const QRectF& rect, const QBrush& brush ) +void QwtPainter::fillRect(QPainter *painter, const QRectF &rect, + const QBrush &brush) { - if ( !rect.isValid() ) - return; + if (!rect.isValid()) + return; - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - /* - Performance of Qt4 is horrible for a non trivial brush. Without - clipping expect minutes or hours for repainting large rectangles - (might result from zooming) - */ + /* + Performance of Qt4 is horrible for a non trivial brush. Without + clipping expect minutes or hours for repainting large rectangles + (might result from zooming) + */ - if ( deviceClipping ) - clipRect &= painter->window(); - else - clipRect = painter->window(); + if (deviceClipping) + clipRect &= painter->window(); + else + clipRect = painter->window(); - if ( painter->hasClipping() ) - clipRect &= painter->clipRegion().boundingRect(); + if (painter->hasClipping()) + clipRect &= painter->clipRegion().boundingRect(); - QRectF r = rect; - if ( deviceClipping ) - r = r.intersected( clipRect ); + QRectF r = rect; + if (deviceClipping) + r = r.intersected(clipRect); - if ( r.isValid() ) - painter->fillRect( r, brush ); + if (r.isValid()) + painter->fillRect(r, brush); } //! Wrapper for QPainter::drawPie() -void QwtPainter::drawPie( QPainter* painter, const QRectF& rect, - int a, int alen ) +void QwtPainter::drawPie(QPainter *painter, const QRectF &rect, int a, int alen) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); - if ( deviceClipping && !clipRect.contains( rect ) ) - return; + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); + if (deviceClipping && !clipRect.contains(rect)) + return; - painter->drawPie( rect, a, alen ); + painter->drawPie(rect, a, alen); } //! Wrapper for QPainter::drawEllipse() -void QwtPainter::drawEllipse( QPainter* painter, const QRectF& rect ) +void QwtPainter::drawEllipse(QPainter *painter, const QRectF &rect) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping && !clipRect.contains( rect ) ) - return; + if (deviceClipping && !clipRect.contains(rect)) + return; - painter->drawEllipse( rect ); + painter->drawEllipse(rect); } //! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter* painter, - qreal x, qreal y, const QString& text ) +void QwtPainter::drawText(QPainter *painter, qreal x, qreal y, + const QString &text) { - drawText( painter, QPointF( x, y ), text ); + drawText(painter, QPointF(x, y), text); } //! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter* painter, const QPointF& pos, - const QString& text ) +void QwtPainter::drawText(QPainter *painter, const QPointF &pos, + const QString &text) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping && !clipRect.contains( pos ) ) - return; + if (deviceClipping && !clipRect.contains(pos)) + return; - - painter->save(); - qwtUnscaleFont( painter ); - painter->drawText( pos, text ); - painter->restore(); + painter->save(); + qwtUnscaleFont(painter); + painter->drawText(pos, text); + painter->restore(); } //! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter* painter, - qreal x, qreal y, qreal w, qreal h, - int flags, const QString& text ) +void QwtPainter::drawText(QPainter *painter, qreal x, qreal y, qreal w, qreal h, + int flags, const QString &text) { - drawText( painter, QRectF( x, y, w, h ), flags, text ); + drawText(painter, QRectF(x, y, w, h), flags, text); } //! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter* painter, const QRectF& rect, - int flags, const QString& text ) +void QwtPainter::drawText(QPainter *painter, const QRectF &rect, int flags, + const QString &text) { - painter->save(); - qwtUnscaleFont( painter ); - painter->drawText( rect, flags, text ); - painter->restore(); + painter->save(); + qwtUnscaleFont(painter); + painter->drawText(rect, flags, text); + painter->restore(); } #ifndef QT_NO_RICHTEXT @@ -486,349 +483,343 @@ void QwtPainter::drawText( QPainter* painter, const QRectF& rect, \param flags Alignments/Text flags, see QPainter::drawText() \param text Text document */ -void QwtPainter::drawSimpleRichText( QPainter* painter, const QRectF& rect, - int flags, const QTextDocument& text ) +void QwtPainter::drawSimpleRichText(QPainter *painter, const QRectF &rect, + int flags, const QTextDocument &text) { - QTextDocument* txt = text.clone(); + QTextDocument *txt = text.clone(); - painter->save(); + painter->save(); - QRectF unscaledRect = rect; + QRectF unscaledRect = rect; - if ( painter->font().pixelSize() < 0 ) + if (painter->font().pixelSize() < 0) + { + const QSize res = qwtScreenResolution(); + + const QPaintDevice *pd = painter->device(); + if (pd->logicalDpiX() != res.width() || pd->logicalDpiY() != res.height()) { - const QSize res = qwtScreenResolution(); + QTransform transform; + transform.scale(res.width() / qreal(pd->logicalDpiX()), + res.height() / qreal(pd->logicalDpiY())); - const QPaintDevice* pd = painter->device(); - if ( pd->logicalDpiX() != res.width() || - pd->logicalDpiY() != res.height() ) - { - QTransform transform; - transform.scale( res.width() / qreal( pd->logicalDpiX() ), - res.height() / qreal( pd->logicalDpiY() ) ); - - painter->setWorldTransform( transform, true ); - unscaledRect = transform.inverted().mapRect(rect); - } + painter->setWorldTransform(transform, true); + unscaledRect = transform.inverted().mapRect(rect); } + } - txt->setDefaultFont( painter->font() ); - txt->setPageSize( QSizeF( unscaledRect.width(), QWIDGETSIZE_MAX ) ); + txt->setDefaultFont(painter->font()); + txt->setPageSize(QSizeF(unscaledRect.width(), QWIDGETSIZE_MAX)); - QAbstractTextDocumentLayout* layout = txt->documentLayout(); + QAbstractTextDocumentLayout *layout = txt->documentLayout(); - const qreal height = layout->documentSize().height(); - qreal y = unscaledRect.y(); - if ( flags & Qt::AlignBottom ) - y += ( unscaledRect.height() - height ); - else if ( flags & Qt::AlignVCenter ) - y += ( unscaledRect.height() - height ) / 2; + const qreal height = layout->documentSize().height(); + qreal y = unscaledRect.y(); + if (flags & Qt::AlignBottom) + y += (unscaledRect.height() - height); + else if (flags & Qt::AlignVCenter) + y += (unscaledRect.height() - height) / 2; - QAbstractTextDocumentLayout::PaintContext context; - context.palette.setColor( QPalette::Text, painter->pen().color() ); + QAbstractTextDocumentLayout::PaintContext context; + context.palette.setColor(QPalette::Text, painter->pen().color()); - painter->translate( unscaledRect.x(), y ); - layout->draw( painter, context ); + painter->translate(unscaledRect.x(), y); + layout->draw(painter, context); - painter->restore(); - delete txt; + painter->restore(); + delete txt; } #endif // !QT_NO_RICHTEXT - //! Wrapper for QPainter::drawLine() -void QwtPainter::drawLine( QPainter* painter, - const QPointF& p1, const QPointF& p2 ) +void QwtPainter::drawLine(QPainter *painter, const QPointF &p1, + const QPointF &p2) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping && - !( clipRect.contains( p1 ) && clipRect.contains( p2 ) ) ) - { - QPolygonF polygon; - polygon += p1; - polygon += p2; - drawPolyline( painter, polygon ); - return; - } + if (deviceClipping && !(clipRect.contains(p1) && clipRect.contains(p2))) + { + QPolygonF polygon; + polygon += p1; + polygon += p2; + drawPolyline(painter, polygon); + return; + } - painter->drawLine( p1, p2 ); + painter->drawLine(p1, p2); } //! Wrapper for QPainter::drawPolygon() -void QwtPainter::drawPolygon( QPainter* painter, const QPolygonF& polygon ) +void QwtPainter::drawPolygon(QPainter *painter, const QPolygonF &polygon) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - painter->drawPolygon( - QwtClipper::clippedPolygonF( clipRect, polygon, true ) ); - } - else - { - painter->drawPolygon( polygon ); - } + if (deviceClipping) + { + painter->drawPolygon(QwtClipper::clippedPolygonF(clipRect, polygon, true)); + } + else + { + painter->drawPolygon(polygon); + } } //! Wrapper for QPainter::drawPolyline() -void QwtPainter::drawPolyline( QPainter* painter, const QPolygonF& polygon ) +void QwtPainter::drawPolyline(QPainter *painter, const QPolygonF &polygon) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - const QPolygonF cpa = QwtClipper::clippedPolygonF( clipRect, polygon ); + if (deviceClipping) + { + const QPolygonF cpa = QwtClipper::clippedPolygonF(clipRect, polygon); - qwtDrawPolyline< QPointF >( painter, - cpa.constData(), cpa.size(), m_polylineSplitting ); - } - else - { - qwtDrawPolyline< QPointF >( painter, - polygon.constData(), polygon.size(), m_polylineSplitting ); - } + qwtDrawPolyline(painter, cpa.constData(), cpa.size(), + m_polylineSplitting); + } + else + { + qwtDrawPolyline(painter, polygon.constData(), polygon.size(), + m_polylineSplitting); + } } //! Wrapper for QPainter::drawPolyline() -void QwtPainter::drawPolyline( QPainter* painter, - const QPointF* points, int pointCount ) +void QwtPainter::drawPolyline(QPainter *painter, const QPointF *points, + int pointCount) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - QPolygonF polygon( pointCount ); - std::memcpy( polygon.data(), points, pointCount * sizeof( QPointF ) ); + if (deviceClipping) + { + QPolygonF polygon(pointCount); + std::memcpy(polygon.data(), points, pointCount * sizeof(QPointF)); - QwtClipper::clipPolygonF( clipRect, polygon ); - qwtDrawPolyline< QPointF >( painter, - polygon.constData(), polygon.size(), m_polylineSplitting ); - } - else - { - qwtDrawPolyline< QPointF >( painter, points, pointCount, m_polylineSplitting ); - } + QwtClipper::clipPolygonF(clipRect, polygon); + qwtDrawPolyline(painter, polygon.constData(), polygon.size(), + m_polylineSplitting); + } + else + { + qwtDrawPolyline(painter, points, pointCount, m_polylineSplitting); + } } //! Wrapper for QPainter::drawPolygon() -void QwtPainter::drawPolygon( QPainter* painter, const QPolygon& polygon ) +void QwtPainter::drawPolygon(QPainter *painter, const QPolygon &polygon) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - painter->drawPolygon( - QwtClipper::clippedPolygon( clipRect, polygon, true ) ); - } - else - { - painter->drawPolygon( polygon ); - } + if (deviceClipping) + { + painter->drawPolygon(QwtClipper::clippedPolygon(clipRect, polygon, true)); + } + else + { + painter->drawPolygon(polygon); + } } //! Wrapper for QPainter::drawPolyline() -void QwtPainter::drawPolyline( QPainter* painter, const QPolygon& polygon ) +void QwtPainter::drawPolyline(QPainter *painter, const QPolygon &polygon) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - const QPolygon cpa = QwtClipper::clippedPolygon( clipRect, polygon ); + if (deviceClipping) + { + const QPolygon cpa = QwtClipper::clippedPolygon(clipRect, polygon); - qwtDrawPolyline< QPoint >( painter, - cpa.constData(), cpa.size(), m_polylineSplitting ); - } - else - { - qwtDrawPolyline< QPoint >( painter, - polygon.constData(), polygon.size(), m_polylineSplitting ); - } + qwtDrawPolyline(painter, cpa.constData(), cpa.size(), + m_polylineSplitting); + } + else + { + qwtDrawPolyline(painter, polygon.constData(), polygon.size(), + m_polylineSplitting); + } } //! Wrapper for QPainter::drawPolyline() -void QwtPainter::drawPolyline( QPainter* painter, - const QPoint* points, int pointCount ) +void QwtPainter::drawPolyline(QPainter *painter, const QPoint *points, + int pointCount) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - QPolygon polygon( pointCount ); - std::memcpy( polygon.data(), points, pointCount * sizeof( QPoint ) ); + if (deviceClipping) + { + QPolygon polygon(pointCount); + std::memcpy(polygon.data(), points, pointCount * sizeof(QPoint)); - QwtClipper::clipPolygon( clipRect, polygon ); - qwtDrawPolyline< QPoint >( painter, - polygon.constData(), polygon.size(), m_polylineSplitting ); - } - else - { - qwtDrawPolyline< QPoint >( painter, points, pointCount, m_polylineSplitting ); - } + QwtClipper::clipPolygon(clipRect, polygon); + qwtDrawPolyline(painter, polygon.constData(), polygon.size(), + m_polylineSplitting); + } + else + { + qwtDrawPolyline(painter, points, pointCount, m_polylineSplitting); + } } //! Wrapper for QPainter::drawPoint() -void QwtPainter::drawPoint( QPainter* painter, const QPointF& pos ) +void QwtPainter::drawPoint(QPainter *painter, const QPointF &pos) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping && !clipRect.contains( pos ) ) - return; + if (deviceClipping && !clipRect.contains(pos)) + return; - painter->drawPoint( pos ); + painter->drawPoint(pos); } //! Wrapper for QPainter::drawPoint() -void QwtPainter::drawPoint( QPainter* painter, const QPoint& pos ) +void QwtPainter::drawPoint(QPainter *painter, const QPoint &pos) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) + if (deviceClipping) + { + const int minX = qwtCeil(clipRect.left()); + const int maxX = qwtFloor(clipRect.right()); + const int minY = qwtCeil(clipRect.top()); + const int maxY = qwtFloor(clipRect.bottom()); + + if (pos.x() < minX || pos.x() > maxX || pos.y() < minY || pos.y() > maxY) { - const int minX = qwtCeil( clipRect.left() ); - const int maxX = qwtFloor( clipRect.right() ); - const int minY = qwtCeil( clipRect.top() ); - const int maxY = qwtFloor( clipRect.bottom() ); - - if ( pos.x() < minX || pos.x() > maxX - || pos.y() < minY || pos.y() > maxY ) - { - return; - } + return; } + } - painter->drawPoint( pos ); + painter->drawPoint(pos); } //! Wrapper for QPainter::drawPoints() -void QwtPainter::drawPoints( QPainter* painter, - const QPoint* points, int pointCount ) +void QwtPainter::drawPoints(QPainter *painter, const QPoint *points, + int pointCount) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) + if (deviceClipping) + { + const int minX = qwtCeil(clipRect.left()); + const int maxX = qwtFloor(clipRect.right()); + const int minY = qwtCeil(clipRect.top()); + const int maxY = qwtFloor(clipRect.bottom()); + + const QRect r(minX, minY, maxX - minX, maxY - minY); + + QPolygon clippedPolygon(pointCount); + QPoint *clippedData = clippedPolygon.data(); + + int numClippedPoints = 0; + for (int i = 0; i < pointCount; i++) { - const int minX = qwtCeil( clipRect.left() ); - const int maxX = qwtFloor( clipRect.right() ); - const int minY = qwtCeil( clipRect.top() ); - const int maxY = qwtFloor( clipRect.bottom() ); - - const QRect r( minX, minY, maxX - minX, maxY - minY ); - - QPolygon clippedPolygon( pointCount ); - QPoint* clippedData = clippedPolygon.data(); - - int numClippedPoints = 0; - for ( int i = 0; i < pointCount; i++ ) - { - if ( r.contains( points[i] ) ) - clippedData[ numClippedPoints++ ] = points[i]; - } - painter->drawPoints( clippedData, numClippedPoints ); - } - else - { - painter->drawPoints( points, pointCount ); + if (r.contains(points[i])) + clippedData[numClippedPoints++] = points[i]; } + painter->drawPoints(clippedData, numClippedPoints); + } + else + { + painter->drawPoints(points, pointCount); + } } //! Wrapper for QPainter::drawPoints() -void QwtPainter::drawPoints( QPainter* painter, - const QPointF* points, int pointCount ) +void QwtPainter::drawPoints(QPainter *painter, const QPointF *points, + int pointCount) { - QRectF clipRect; - const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect ); + QRectF clipRect; + const bool deviceClipping = qwtIsClippingNeeded(painter, clipRect); - if ( deviceClipping ) - { - QPolygonF clippedPolygon( pointCount ); - QPointF* clippedData = clippedPolygon.data(); + if (deviceClipping) + { + QPolygonF clippedPolygon(pointCount); + QPointF *clippedData = clippedPolygon.data(); - int numClippedPoints = 0; - for ( int i = 0; i < pointCount; i++ ) - { - if ( clipRect.contains( points[i] ) ) - clippedData[ numClippedPoints++ ] = points[i]; - } - painter->drawPoints( clippedData, numClippedPoints ); - } - else + int numClippedPoints = 0; + for (int i = 0; i < pointCount; i++) { - painter->drawPoints( points, pointCount ); + if (clipRect.contains(points[i])) + clippedData[numClippedPoints++] = points[i]; } + painter->drawPoints(clippedData, numClippedPoints); + } + else + { + painter->drawPoints(points, pointCount); + } } //! Wrapper for QPainter::drawImage() -void QwtPainter::drawImage( QPainter* painter, - const QRectF& rect, const QImage& image ) +void QwtPainter::drawImage(QPainter *painter, const QRectF &rect, + const QImage &image) { - const QRect alignedRect = rect.toAlignedRect(); + const QRect alignedRect = rect.toAlignedRect(); - if ( alignedRect != rect ) - { - const QRectF clipRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); + if (alignedRect != rect) + { + const QRectF clipRect = rect.adjusted(0.0, 0.0, -1.0, -1.0); - painter->save(); - painter->setClipRect( clipRect, Qt::IntersectClip ); - painter->drawImage( alignedRect, image ); - painter->restore(); - } - else - { - painter->drawImage( alignedRect, image ); - } + painter->save(); + painter->setClipRect(clipRect, Qt::IntersectClip); + painter->drawImage(alignedRect, image); + painter->restore(); + } + else + { + painter->drawImage(alignedRect, image); + } } //! Wrapper for QPainter::drawPixmap() -void QwtPainter::drawPixmap( QPainter* painter, - const QRectF& rect, const QPixmap& pixmap ) +void QwtPainter::drawPixmap(QPainter *painter, const QRectF &rect, + const QPixmap &pixmap) { - const QRect alignedRect = rect.toAlignedRect(); + const QRect alignedRect = rect.toAlignedRect(); - if ( alignedRect != rect ) - { - const QRectF clipRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); + if (alignedRect != rect) + { + const QRectF clipRect = rect.adjusted(0.0, 0.0, -1.0, -1.0); - painter->save(); - painter->setClipRect( clipRect, Qt::IntersectClip ); - painter->drawPixmap( alignedRect, pixmap ); - painter->restore(); - } - else - { - painter->drawPixmap( alignedRect, pixmap ); - } + painter->save(); + painter->setClipRect(clipRect, Qt::IntersectClip); + painter->drawPixmap(alignedRect, pixmap); + painter->restore(); + } + else + { + painter->drawPixmap(alignedRect, pixmap); + } } //! Draw a focus rectangle on a widget using its style. -void QwtPainter::drawFocusRect( QPainter* painter, const QWidget* widget ) +void QwtPainter::drawFocusRect(QPainter *painter, const QWidget *widget) { - drawFocusRect( painter, widget, widget->rect() ); + drawFocusRect(painter, widget, widget->rect()); } //! Draw a focus rectangle on a widget using its style. -void QwtPainter::drawFocusRect( QPainter* painter, const QWidget* widget, - const QRect& rect ) +void QwtPainter::drawFocusRect(QPainter *painter, const QWidget *widget, + const QRect &rect) { - QStyleOptionFocusRect opt; - opt.initFrom( widget ); - opt.rect = rect; - opt.state |= QStyle::State_HasFocus; - opt.backgroundColor = widget->palette().color( widget->backgroundRole() ); + QStyleOptionFocusRect opt; + opt.initFrom(widget); + opt.rect = rect; + opt.state |= QStyle::State_HasFocus; + opt.backgroundColor = widget->palette().color(widget->backgroundRole()); - widget->style()->drawPrimitive( - QStyle::PE_FrameFocusRect, &opt, painter, widget ); + widget->style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, painter, + widget); } /*! @@ -842,59 +833,59 @@ void QwtPainter::drawFocusRect( QPainter* painter, const QWidget* widget, \param lineWidth Line width \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow */ -void QwtPainter::drawRoundFrame( QPainter* painter, - const QRectF& rect, const QPalette& palette, - int lineWidth, int frameStyle ) +void QwtPainter::drawRoundFrame(QPainter *painter, const QRectF &rect, + const QPalette &palette, int lineWidth, + int frameStyle) { - enum Style - { - Plain, - Sunken, - Raised - }; + enum Style + { + Plain, + Sunken, + Raised + }; - Style style = Plain; - if ( (frameStyle& QFrame::Sunken) == QFrame::Sunken ) - style = Sunken; - else if ( (frameStyle& QFrame::Raised) == QFrame::Raised ) - style = Raised; + Style style = Plain; + if ((frameStyle & QFrame::Sunken) == QFrame::Sunken) + style = Sunken; + else if ((frameStyle & QFrame::Raised) == QFrame::Raised) + style = Raised; - const qreal lw2 = 0.5 * lineWidth; - QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 ); + const qreal lw2 = 0.5 * lineWidth; + QRectF r = rect.adjusted(lw2, lw2, -lw2, -lw2); - QBrush brush; + QBrush brush; - if ( style != Plain ) - { - QColor c1 = palette.color( QPalette::Light ); - QColor c2 = palette.color( QPalette::Dark ); + if (style != Plain) + { + QColor c1 = palette.color(QPalette::Light); + QColor c2 = palette.color(QPalette::Dark); - if ( style == Sunken ) - qSwap( c1, c2 ); + if (style == Sunken) + qSwap(c1, c2); - QLinearGradient gradient( r.topLeft(), r.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); + QLinearGradient gradient(r.topLeft(), r.bottomRight()); + gradient.setColorAt(0.0, c1); #if 0 gradient.setColorAt( 0.3, c1 ); gradient.setColorAt( 0.7, c2 ); #endif - gradient.setColorAt( 1.0, c2 ); + gradient.setColorAt(1.0, c2); - brush = QBrush( gradient ); - } - else // Plain - { - brush = palette.brush( QPalette::WindowText ); - } + brush = QBrush(gradient); + } + else // Plain + { + brush = palette.brush(QPalette::WindowText); + } - painter->save(); + painter->save(); - painter->setPen( QPen( brush, lineWidth ) ); - painter->setBrush( Qt::NoBrush ); + painter->setPen(QPen(brush, lineWidth)); + painter->setBrush(Qt::NoBrush); - painter->drawEllipse( r ); + painter->drawEllipse(r); - painter->restore(); + painter->restore(); } /*! @@ -908,144 +899,143 @@ void QwtPainter::drawRoundFrame( QPainter* painter, \param midLineWidth Used for QFrame::Box \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow */ -void QwtPainter::drawFrame( QPainter* painter, const QRectF& rect, - const QPalette& palette, QPalette::ColorRole foregroundRole, - int frameWidth, int midLineWidth, int frameStyle ) +void QwtPainter::drawFrame(QPainter *painter, const QRectF &rect, + const QPalette &palette, + QPalette::ColorRole foregroundRole, int frameWidth, + int midLineWidth, int frameStyle) { - if ( frameWidth <= 0 || rect.isEmpty() ) - return; + if (frameWidth <= 0 || rect.isEmpty()) + return; - const int shadow = frameStyle & QFrame::Shadow_Mask; + const int shadow = frameStyle & QFrame::Shadow_Mask; - painter->save(); + painter->save(); - if ( shadow == QFrame::Plain ) + if (shadow == QFrame::Plain) + { + const QRectF outerRect = rect.adjusted(0.0, 0.0, -1.0, -1.0); + const QRectF innerRect + = outerRect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); + + QPainterPath path; + path.addRect(outerRect); + path.addRect(innerRect); + + painter->setPen(Qt::NoPen); + painter->setBrush(palette.color(foregroundRole)); + + painter->drawPath(path); + } + else + { + const int shape = frameStyle & QFrame::Shape_Mask; + + if (shape == QFrame::Box) { - const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); - const QRectF innerRect = outerRect.adjusted( - frameWidth, frameWidth, -frameWidth, -frameWidth ); + const QRectF outerRect = rect.adjusted(0.0, 0.0, -1.0, -1.0); + const QRectF midRect1 = outerRect.adjusted(frameWidth, frameWidth, + -frameWidth, -frameWidth); + const QRectF midRect2 = midRect1.adjusted(midLineWidth, midLineWidth, + -midLineWidth, -midLineWidth); - QPainterPath path; - path.addRect( outerRect ); - path.addRect( innerRect ); + const QRectF innerRect + = midRect2.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); - painter->setPen( Qt::NoPen ); - painter->setBrush( palette.color( foregroundRole ) ); + QPainterPath path1; + path1.moveTo(outerRect.bottomLeft()); + path1.lineTo(outerRect.topLeft()); + path1.lineTo(outerRect.topRight()); + path1.lineTo(midRect1.topRight()); + path1.lineTo(midRect1.topLeft()); + path1.lineTo(midRect1.bottomLeft()); - painter->drawPath( path ); + QPainterPath path2; + path2.moveTo(outerRect.bottomLeft()); + path2.lineTo(outerRect.bottomRight()); + path2.lineTo(outerRect.topRight()); + path2.lineTo(midRect1.topRight()); + path2.lineTo(midRect1.bottomRight()); + path2.lineTo(midRect1.bottomLeft()); + + QPainterPath path3; + path3.moveTo(midRect2.bottomLeft()); + path3.lineTo(midRect2.topLeft()); + path3.lineTo(midRect2.topRight()); + path3.lineTo(innerRect.topRight()); + path3.lineTo(innerRect.topLeft()); + path3.lineTo(innerRect.bottomLeft()); + + QPainterPath path4; + path4.moveTo(midRect2.bottomLeft()); + path4.lineTo(midRect2.bottomRight()); + path4.lineTo(midRect2.topRight()); + path4.lineTo(innerRect.topRight()); + path4.lineTo(innerRect.bottomRight()); + path4.lineTo(innerRect.bottomLeft()); + + QPainterPath path5; + path5.addRect(midRect1); + path5.addRect(midRect2); + + painter->setPen(Qt::NoPen); + + QBrush brush1 = palette.dark().color(); + QBrush brush2 = palette.light().color(); + + if (shadow == QFrame::Raised) + qSwap(brush1, brush2); + + painter->setBrush(brush1); + painter->drawPath(path1); + painter->drawPath(path4); + + painter->setBrush(brush2); + painter->drawPath(path2); + painter->drawPath(path3); + + painter->setBrush(palette.mid()); + painter->drawPath(path5); } else { - const int shape = frameStyle & QFrame::Shape_Mask; + const QRectF outerRect = rect.adjusted(0.0, 0.0, -1.0, -1.0); + const QRectF innerRect + = outerRect.adjusted(frameWidth - 1.0, frameWidth - 1.0, + -(frameWidth - 1.0), -(frameWidth - 1.0)); - if ( shape == QFrame::Box ) - { - const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); - const QRectF midRect1 = outerRect.adjusted( - frameWidth, frameWidth, -frameWidth, -frameWidth ); - const QRectF midRect2 = midRect1.adjusted( - midLineWidth, midLineWidth, -midLineWidth, -midLineWidth ); + QPainterPath path1; + path1.moveTo(outerRect.bottomLeft()); + path1.lineTo(outerRect.topLeft()); + path1.lineTo(outerRect.topRight()); + path1.lineTo(innerRect.topRight()); + path1.lineTo(innerRect.topLeft()); + path1.lineTo(innerRect.bottomLeft()); - const QRectF innerRect = midRect2.adjusted( - frameWidth, frameWidth, -frameWidth, -frameWidth ); + QPainterPath path2; + path2.moveTo(outerRect.bottomLeft()); + path2.lineTo(outerRect.bottomRight()); + path2.lineTo(outerRect.topRight()); + path2.lineTo(innerRect.topRight()); + path2.lineTo(innerRect.bottomRight()); + path2.lineTo(innerRect.bottomLeft()); - QPainterPath path1; - path1.moveTo( outerRect.bottomLeft() ); - path1.lineTo( outerRect.topLeft() ); - path1.lineTo( outerRect.topRight() ); - path1.lineTo( midRect1.topRight() ); - path1.lineTo( midRect1.topLeft() ); - path1.lineTo( midRect1.bottomLeft() ); + painter->setPen(Qt::NoPen); - QPainterPath path2; - path2.moveTo( outerRect.bottomLeft() ); - path2.lineTo( outerRect.bottomRight() ); - path2.lineTo( outerRect.topRight() ); - path2.lineTo( midRect1.topRight() ); - path2.lineTo( midRect1.bottomRight() ); - path2.lineTo( midRect1.bottomLeft() ); + QBrush brush1 = palette.dark().color(); + QBrush brush2 = palette.light().color(); - QPainterPath path3; - path3.moveTo( midRect2.bottomLeft() ); - path3.lineTo( midRect2.topLeft() ); - path3.lineTo( midRect2.topRight() ); - path3.lineTo( innerRect.topRight() ); - path3.lineTo( innerRect.topLeft() ); - path3.lineTo( innerRect.bottomLeft() ); + if (shadow == QFrame::Raised) + qSwap(brush1, brush2); - QPainterPath path4; - path4.moveTo( midRect2.bottomLeft() ); - path4.lineTo( midRect2.bottomRight() ); - path4.lineTo( midRect2.topRight() ); - path4.lineTo( innerRect.topRight() ); - path4.lineTo( innerRect.bottomRight() ); - path4.lineTo( innerRect.bottomLeft() ); - - QPainterPath path5; - path5.addRect( midRect1 ); - path5.addRect( midRect2 ); - - painter->setPen( Qt::NoPen ); - - QBrush brush1 = palette.dark().color(); - QBrush brush2 = palette.light().color(); - - if ( shadow == QFrame::Raised ) - qSwap( brush1, brush2 ); - - painter->setBrush( brush1 ); - painter->drawPath( path1 ); - painter->drawPath( path4 ); - - painter->setBrush( brush2 ); - painter->drawPath( path2 ); - painter->drawPath( path3 ); - - painter->setBrush( palette.mid() ); - painter->drawPath( path5 ); - } - else - { - const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); - const QRectF innerRect = outerRect.adjusted( - frameWidth - 1.0, frameWidth - 1.0, - -( frameWidth - 1.0 ), -( frameWidth - 1.0 ) ); - - QPainterPath path1; - path1.moveTo( outerRect.bottomLeft() ); - path1.lineTo( outerRect.topLeft() ); - path1.lineTo( outerRect.topRight() ); - path1.lineTo( innerRect.topRight() ); - path1.lineTo( innerRect.topLeft() ); - path1.lineTo( innerRect.bottomLeft() ); - - - QPainterPath path2; - path2.moveTo( outerRect.bottomLeft() ); - path2.lineTo( outerRect.bottomRight() ); - path2.lineTo( outerRect.topRight() ); - path2.lineTo( innerRect.topRight() ); - path2.lineTo( innerRect.bottomRight() ); - path2.lineTo( innerRect.bottomLeft() ); - - painter->setPen( Qt::NoPen ); - - QBrush brush1 = palette.dark().color(); - QBrush brush2 = palette.light().color(); - - if ( shadow == QFrame::Raised ) - qSwap( brush1, brush2 ); - - painter->setBrush( brush1 ); - painter->drawPath( path1 ); - - painter->setBrush( brush2 ); - painter->drawPath( path2 ); - } + painter->setBrush(brush1); + painter->drawPath(path1); + painter->setBrush(brush2); + painter->drawPath(path2); } + } - painter->restore(); + painter->restore(); } /*! @@ -1062,134 +1052,125 @@ void QwtPainter::drawFrame( QPainter* painter, const QRectF& rect, \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow */ -void QwtPainter::drawRoundedFrame( QPainter* painter, - const QRectF& rect, qreal xRadius, qreal yRadius, - const QPalette& palette, int lineWidth, int frameStyle ) +void QwtPainter::drawRoundedFrame(QPainter *painter, const QRectF &rect, + qreal xRadius, qreal yRadius, + const QPalette &palette, int lineWidth, + int frameStyle) { - painter->save(); - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->setBrush( Qt::NoBrush ); + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setBrush(Qt::NoBrush); - qreal lw2 = lineWidth * 0.5; - QRectF innerRect = rect.adjusted( lw2, lw2, -lw2, -lw2 ); + qreal lw2 = lineWidth * 0.5; + QRectF innerRect = rect.adjusted(lw2, lw2, -lw2, -lw2); - QPainterPath path; - path.addRoundedRect( innerRect, xRadius, yRadius ); + QPainterPath path; + path.addRoundedRect(innerRect, xRadius, yRadius); - enum Style + enum Style + { + Plain, + Sunken, + Raised + }; + + Style style = Plain; + if ((frameStyle & QFrame::Sunken) == QFrame::Sunken) + style = Sunken; + else if ((frameStyle & QFrame::Raised) == QFrame::Raised) + style = Raised; + + if (style != Plain && path.elementCount() == 17) + { + // move + 4 * ( cubicTo + lineTo ) + QPainterPath pathList[8]; + + for (int i = 0; i < 4; i++) { - Plain, - Sunken, - Raised - }; + const int j = i * 4 + 1; - Style style = Plain; - if ( (frameStyle& QFrame::Sunken) == QFrame::Sunken ) - style = Sunken; - else if ( (frameStyle& QFrame::Raised) == QFrame::Raised ) - style = Raised; + pathList[2 * i].moveTo(path.elementAt(j - 1).x, path.elementAt(j - 1).y); - if ( style != Plain && path.elementCount() == 17 ) - { - // move + 4 * ( cubicTo + lineTo ) - QPainterPath pathList[8]; + pathList[2 * i].cubicTo(path.elementAt(j + 0).x, path.elementAt(j + 0).y, + path.elementAt(j + 1).x, path.elementAt(j + 1).y, + path.elementAt(j + 2).x, path.elementAt(j + 2).y); - for ( int i = 0; i < 4; i++ ) - { - const int j = i * 4 + 1; - - pathList[ 2 * i ].moveTo( - path.elementAt(j - 1).x, path.elementAt( j - 1 ).y - ); - - pathList[ 2 * i ].cubicTo( - path.elementAt(j + 0).x, path.elementAt(j + 0).y, - path.elementAt(j + 1).x, path.elementAt(j + 1).y, - path.elementAt(j + 2).x, path.elementAt(j + 2).y ); - - pathList[ 2 * i + 1 ].moveTo( - path.elementAt(j + 2).x, path.elementAt(j + 2).y - ); - pathList[ 2 * i + 1 ].lineTo( - path.elementAt(j + 3).x, path.elementAt(j + 3).y - ); - } - - QColor c1( palette.color( QPalette::Dark ) ); - QColor c2( palette.color( QPalette::Light ) ); - - if ( style == Raised ) - qSwap( c1, c2 ); - - for ( int i = 0; i < 4; i++ ) - { - const QRectF r = pathList[2 * i].controlPointRect(); - - QPen arcPen; - arcPen.setCapStyle( Qt::FlatCap ); - arcPen.setWidth( lineWidth ); - - QPen linePen; - linePen.setCapStyle( Qt::FlatCap ); - linePen.setWidth( lineWidth ); - - switch( i ) - { - case 0: - { - arcPen.setColor( c1 ); - linePen.setColor( c1 ); - break; - } - case 1: - { - QLinearGradient gradient; - gradient.setStart( r.topLeft() ); - gradient.setFinalStop( r.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 1.0, c2 ); - - arcPen.setBrush( gradient ); - linePen.setColor( c2 ); - break; - } - case 2: - { - arcPen.setColor( c2 ); - linePen.setColor( c2 ); - break; - } - case 3: - { - QLinearGradient gradient; - - gradient.setStart( r.bottomRight() ); - gradient.setFinalStop( r.topLeft() ); - gradient.setColorAt( 0.0, c2 ); - gradient.setColorAt( 1.0, c1 ); - - arcPen.setBrush( gradient ); - linePen.setColor( c1 ); - break; - } - } - - - painter->setPen( arcPen ); - painter->drawPath( pathList[ 2 * i] ); - - painter->setPen( linePen ); - painter->drawPath( pathList[ 2 * i + 1] ); - } - } - else - { - QPen pen( palette.color( QPalette::WindowText ), lineWidth ); - painter->setPen( pen ); - painter->drawPath( path ); + pathList[2 * i + 1].moveTo(path.elementAt(j + 2).x, + path.elementAt(j + 2).y); + pathList[2 * i + 1].lineTo(path.elementAt(j + 3).x, + path.elementAt(j + 3).y); } - painter->restore(); + QColor c1(palette.color(QPalette::Dark)); + QColor c2(palette.color(QPalette::Light)); + + if (style == Raised) + qSwap(c1, c2); + + for (int i = 0; i < 4; i++) + { + const QRectF r = pathList[2 * i].controlPointRect(); + + QPen arcPen; + arcPen.setCapStyle(Qt::FlatCap); + arcPen.setWidth(lineWidth); + + QPen linePen; + linePen.setCapStyle(Qt::FlatCap); + linePen.setWidth(lineWidth); + + switch (i) + { + case 0: { + arcPen.setColor(c1); + linePen.setColor(c1); + break; + } + case 1: { + QLinearGradient gradient; + gradient.setStart(r.topLeft()); + gradient.setFinalStop(r.bottomRight()); + gradient.setColorAt(0.0, c1); + gradient.setColorAt(1.0, c2); + + arcPen.setBrush(gradient); + linePen.setColor(c2); + break; + } + case 2: { + arcPen.setColor(c2); + linePen.setColor(c2); + break; + } + case 3: { + QLinearGradient gradient; + + gradient.setStart(r.bottomRight()); + gradient.setFinalStop(r.topLeft()); + gradient.setColorAt(0.0, c2); + gradient.setColorAt(1.0, c1); + + arcPen.setBrush(gradient); + linePen.setColor(c1); + break; + } + } + + painter->setPen(arcPen); + painter->drawPath(pathList[2 * i]); + + painter->setPen(linePen); + painter->drawPath(pathList[2 * i + 1]); + } + } + else + { + QPen pen(palette.color(QPalette::WindowText), lineWidth); + painter->setPen(pen); + painter->drawPath(path); + } + + painter->restore(); } /*! @@ -1202,97 +1183,96 @@ void QwtPainter::drawRoundedFrame( QPainter* painter, \param orientation Orientation \param rect Target rectangle */ -void QwtPainter::drawColorBar( QPainter* painter, - const QwtColorMap& colorMap, const QwtInterval& interval, - const QwtScaleMap& scaleMap, Qt::Orientation orientation, - const QRectF& rect ) +void QwtPainter::drawColorBar(QPainter *painter, const QwtColorMap &colorMap, + const QwtInterval &interval, + const QwtScaleMap &scaleMap, + Qt::Orientation orientation, const QRectF &rect) { - QVector< QRgb > colorTable; - if ( colorMap.format() == QwtColorMap::Indexed ) - colorTable = colorMap.colorTable256(); + QVector colorTable; + if (colorMap.format() == QwtColorMap::Indexed) + colorTable = colorMap.colorTable256(); - QColor c; + QColor c; - const QRect devRect = rect.toAlignedRect(); + const QRect devRect = rect.toAlignedRect(); - /* - We paint to a pixmap first to have something scalable for printing - ( f.e. in a Pdf document ) - */ + /* + We paint to a pixmap first to have something scalable for printing + ( f.e. in a Pdf document ) + */ - QPixmap pixmap( devRect.size() ); - pixmap.fill( Qt::transparent ); + QPixmap pixmap(devRect.size()); + pixmap.fill(Qt::transparent); - QPainter pmPainter( &pixmap ); - pmPainter.translate( -devRect.x(), -devRect.y() ); + QPainter pmPainter(&pixmap); + pmPainter.translate(-devRect.x(), -devRect.y()); - if ( orientation == Qt::Horizontal ) + if (orientation == Qt::Horizontal) + { + QwtScaleMap sMap = scaleMap; + sMap.setPaintInterval(rect.left(), rect.right()); + + for (int x = devRect.left(); x <= devRect.right(); x++) { - QwtScaleMap sMap = scaleMap; - sMap.setPaintInterval( rect.left(), rect.right() ); + const double value = sMap.invTransform(x); - for ( int x = devRect.left(); x <= devRect.right(); x++ ) - { - const double value = sMap.invTransform( x ); + if (colorMap.format() == QwtColorMap::RGB) + c.setRgba(colorMap.rgb(interval, value)); + else + c = colorTable[colorMap.colorIndex(256, interval, value)]; - if ( colorMap.format() == QwtColorMap::RGB ) - c.setRgba( colorMap.rgb( interval, value ) ); - else - c = colorTable[colorMap.colorIndex( 256, interval, value )]; - - pmPainter.setPen( c ); - pmPainter.drawLine( x, devRect.top(), x, devRect.bottom() ); - } + pmPainter.setPen(c); + pmPainter.drawLine(x, devRect.top(), x, devRect.bottom()); } - else // Vertical + } + else // Vertical + { + QwtScaleMap sMap = scaleMap; + sMap.setPaintInterval(rect.bottom(), rect.top()); + + for (int y = devRect.top(); y <= devRect.bottom(); y++) { - QwtScaleMap sMap = scaleMap; - sMap.setPaintInterval( rect.bottom(), rect.top() ); + const double value = sMap.invTransform(y); - for ( int y = devRect.top(); y <= devRect.bottom(); y++ ) - { - const double value = sMap.invTransform( y ); + if (colorMap.format() == QwtColorMap::RGB) + c.setRgba(colorMap.rgb(interval, value)); + else + c = colorTable[colorMap.colorIndex(256, interval, value)]; - if ( colorMap.format() == QwtColorMap::RGB ) - c.setRgba( colorMap.rgb( interval, value ) ); - else - c = colorTable[colorMap.colorIndex( 256, interval, value )]; - - pmPainter.setPen( c ); - pmPainter.drawLine( devRect.left(), y, devRect.right(), y ); - } + pmPainter.setPen(c); + pmPainter.drawLine(devRect.left(), y, devRect.right(), y); } - pmPainter.end(); + } + pmPainter.end(); - drawPixmap( painter, rect, pixmap ); + drawPixmap(painter, rect, pixmap); } -static inline void qwtFillRect( const QWidget* widget, QPainter* painter, - const QRect& rect, const QBrush& brush) +static inline void qwtFillRect(const QWidget *widget, QPainter *painter, + const QRect &rect, const QBrush &brush) { - if ( brush.style() == Qt::TexturePattern ) - { - painter->save(); + if (brush.style() == Qt::TexturePattern) + { + painter->save(); - painter->setClipRect( rect ); - painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft() ); + painter->setClipRect(rect); + painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); - painter->restore(); - } - else if ( brush.gradient() ) - { - painter->save(); + painter->restore(); + } + else if (brush.gradient()) + { + painter->save(); - painter->setClipRect( rect ); - painter->fillRect(0, 0, widget->width(), - widget->height(), brush); + painter->setClipRect(rect); + painter->fillRect(0, 0, widget->width(), widget->height(), brush); - painter->restore(); - } - else - { - painter->fillRect(rect, brush); - } + painter->restore(); + } + else + { + painter->fillRect(rect, brush); + } } /*! @@ -1308,35 +1288,34 @@ static inline void qwtFillRect( const QWidget* widget, QPainter* painter, \sa QPixmap::fill() */ -void QwtPainter::fillPixmap( const QWidget* widget, - QPixmap& pixmap, const QPoint& offset ) +void QwtPainter::fillPixmap(const QWidget *widget, QPixmap &pixmap, + const QPoint &offset) { - const QRect rect( offset, pixmap.size() ); + const QRect rect(offset, pixmap.size()); - QPainter painter( &pixmap ); - painter.translate( -offset ); + QPainter painter(&pixmap); + painter.translate(-offset); - const QBrush autoFillBrush = - widget->palette().brush( widget->backgroundRole() ); + const QBrush autoFillBrush + = widget->palette().brush(widget->backgroundRole()); - if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) ) - { - const QBrush bg = widget->palette().brush( QPalette::Window ); - qwtFillRect( widget, &painter, rect, bg); - } + if (!(widget->autoFillBackground() && autoFillBrush.isOpaque())) + { + const QBrush bg = widget->palette().brush(QPalette::Window); + qwtFillRect(widget, &painter, rect, bg); + } - if ( widget->autoFillBackground() ) - qwtFillRect( widget, &painter, rect, autoFillBrush); + if (widget->autoFillBackground()) + qwtFillRect(widget, &painter, rect, autoFillBrush); - if ( widget->testAttribute(Qt::WA_StyledBackground) ) - { - painter.setClipRegion( rect ); + if (widget->testAttribute(Qt::WA_StyledBackground)) + { + painter.setClipRegion(rect); - QStyleOption opt; - opt.initFrom( widget ); - widget->style()->drawPrimitive( QStyle::PE_Widget, - &opt, &painter, widget ); - } + QStyleOption opt; + opt.initFrom(widget); + widget->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, widget); + } } /*! @@ -1348,25 +1327,23 @@ void QwtPainter::fillPixmap( const QWidget* widget, \sa QStyle::PE_Widget, QWidget::backgroundRole() */ -void QwtPainter::drawBackgound( QPainter* painter, - const QRectF& rect, const QWidget* widget ) +void QwtPainter::drawBackgound(QPainter *painter, const QRectF &rect, + const QWidget *widget) { - if ( widget->testAttribute( Qt::WA_StyledBackground ) ) - { - QStyleOption opt; - opt.initFrom( widget ); - opt.rect = rect.toAlignedRect(); + if (widget->testAttribute(Qt::WA_StyledBackground)) + { + QStyleOption opt; + opt.initFrom(widget); + opt.rect = rect.toAlignedRect(); - widget->style()->drawPrimitive( - QStyle::PE_Widget, &opt, painter, widget); - } - else - { - const QBrush brush = - widget->palette().brush( widget->backgroundRole() ); + widget->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, widget); + } + else + { + const QBrush brush = widget->palette().brush(widget->backgroundRole()); - painter->fillRect( rect, brush ); - } + painter->fillRect(rect, brush); + } } /*! @@ -1376,15 +1353,14 @@ void QwtPainter::drawBackgound( QPainter* painter, \param text Text \return horizontal advance in pixels */ -int QwtPainter::horizontalAdvance( - const QFontMetrics& fontMetrics, const QString& text ) +int QwtPainter::horizontalAdvance(const QFontMetrics &fontMetrics, + const QString &text) { #if QT_VERSION >= 0x050b00 - return fontMetrics.horizontalAdvance( text ); + return fontMetrics.horizontalAdvance(text); #else - return fontMetrics.width( text ); + return fontMetrics.width(text); #endif - } /*! @@ -1394,13 +1370,13 @@ int QwtPainter::horizontalAdvance( \param text Text \return horizontal advance in pixels */ -qreal QwtPainter::horizontalAdvance( - const QFontMetricsF& fontMetrics, const QString& text ) +qreal QwtPainter::horizontalAdvance(const QFontMetricsF &fontMetrics, + const QString &text) { #if QT_VERSION >= 0x050b00 - return fontMetrics.horizontalAdvance( text ); + return fontMetrics.horizontalAdvance(text); #else - return fontMetrics.width( text ); + return fontMetrics.width(text); #endif } @@ -1411,13 +1387,12 @@ qreal QwtPainter::horizontalAdvance( \param ch Character \return horizontal advance in pixels */ -int QwtPainter::horizontalAdvance( - const QFontMetrics& fontMetrics, QChar ch ) +int QwtPainter::horizontalAdvance(const QFontMetrics &fontMetrics, QChar ch) { #if QT_VERSION >= 0x050b00 - return fontMetrics.horizontalAdvance( ch ); + return fontMetrics.horizontalAdvance(ch); #else - return fontMetrics.width( ch ); + return fontMetrics.width(ch); #endif } @@ -1428,13 +1403,12 @@ int QwtPainter::horizontalAdvance( \param ch Character \return horizontal advance in pixels */ -qreal QwtPainter::horizontalAdvance( - const QFontMetricsF& fontMetrics, QChar ch ) +qreal QwtPainter::horizontalAdvance(const QFontMetricsF &fontMetrics, QChar ch) { #if QT_VERSION >= 0x050b00 - return fontMetrics.horizontalAdvance( ch ); + return fontMetrics.horizontalAdvance(ch); #else - return fontMetrics.width( ch ); + return fontMetrics.width(ch); #endif } @@ -1447,73 +1421,70 @@ qreal QwtPainter::horizontalAdvance( \return Font being adjusted to the DPI value of the paint device */ -QFont QwtPainter::scaledFont( const QFont& font, const QPaintDevice* paintDevice ) +QFont QwtPainter::scaledFont(const QFont &font, const QPaintDevice *paintDevice) { - if ( paintDevice == nullptr ) - { + if (paintDevice == nullptr) + { #if QT_VERSION < 0x060000 - paintDevice = QApplication::desktop(); + paintDevice = QApplication::desktop(); #else - class PaintDevice : public QPaintDevice + class PaintDevice : public QPaintDevice + { + virtual QPaintEngine *paintEngine() const QWT_OVERRIDE { return nullptr; } + + virtual int metric(PaintDeviceMetric metric) const QWT_OVERRIDE + { + if (metric == PdmDpiY) { - virtual QPaintEngine* paintEngine() const QWT_OVERRIDE - { - return nullptr; - } + QScreen *screen = QGuiApplication::primaryScreen(); + if (screen) + { + return screen->logicalDotsPerInchY(); + } + } - virtual int metric( PaintDeviceMetric metric ) const QWT_OVERRIDE - { - if ( metric == PdmDpiY ) - { - QScreen* screen = QGuiApplication::primaryScreen(); - if ( screen ) - { - return screen->logicalDotsPerInchY(); - } - } + return QPaintDevice::metric(metric); + } + }; - return QPaintDevice::metric( metric ); - } - }; - - static PaintDevice dummyPaintDevice; - paintDevice = &dummyPaintDevice; + static PaintDevice dummyPaintDevice; + paintDevice = &dummyPaintDevice; #endif - } + } - return QFont( font, const_cast< QPaintDevice* >( paintDevice ) ); + return QFont(font, const_cast(paintDevice)); } /*! \return Pixel ratio for a paint device \param paintDevice Paint device */ -qreal QwtPainter::devicePixelRatio( const QPaintDevice* paintDevice ) +qreal QwtPainter::devicePixelRatio(const QPaintDevice *paintDevice) { - qreal pixelRatio = 0.0; + qreal pixelRatio = 0.0; #if QT_VERSION >= 0x050100 - if ( paintDevice ) - { -#if QT_VERSION >= 0x050600 - pixelRatio = paintDevice->devicePixelRatioF(); + if (paintDevice) + { +# if QT_VERSION >= 0x050600 + pixelRatio = paintDevice->devicePixelRatioF(); +# else + pixelRatio = paintDevice->devicePixelRatio(); +# endif + } #else - pixelRatio = paintDevice->devicePixelRatio(); -#endif - } -#else - Q_UNUSED( paintDevice ) + Q_UNUSED(paintDevice) #endif #if QT_VERSION >= 0x050000 - if ( pixelRatio == 0.0 && qApp ) - pixelRatio = qApp->devicePixelRatio(); + if (pixelRatio == 0.0 && qApp) + pixelRatio = qApp->devicePixelRatio(); #endif - if ( pixelRatio == 0.0 ) - pixelRatio = 1.0; + if (pixelRatio == 0.0) + pixelRatio = 1.0; - return pixelRatio; + return pixelRatio; } /*! @@ -1522,28 +1493,28 @@ qreal QwtPainter::devicePixelRatio( const QPaintDevice* paintDevice ) \param widget Widget, for which the backingstore is intended \param size Size of the pixmap */ -QPixmap QwtPainter::backingStore( QWidget* widget, const QSize& size ) +QPixmap QwtPainter::backingStore(QWidget *widget, const QSize &size) { - QPixmap pm; + QPixmap pm; #if QT_VERSION >= 0x050000 - const qreal pixelRatio = QwtPainter::devicePixelRatio( widget ); + const qreal pixelRatio = QwtPainter::devicePixelRatio(widget); - pm = QPixmap( size * pixelRatio ); - pm.setDevicePixelRatio( pixelRatio ); + pm = QPixmap(size * pixelRatio); + pm.setDevicePixelRatio(pixelRatio); #else - pm = QPixmap( size ); + pm = QPixmap(size); #endif #ifdef Q_WS_X11 - if ( widget && isX11GraphicsSystem() ) - { - if ( pm.x11Info().screen() != widget->x11Info().screen() ) - pm.x11SetScreen( widget->x11Info().screen() ); - } + if (widget && isX11GraphicsSystem()) + { + if (pm.x11Info().screen() != widget->x11Info().screen()) + pm.x11SetScreen(widget->x11Info().screen()); + } #else - Q_UNUSED( widget ) + Q_UNUSED(widget) #endif - return pm; + return pm; } diff --git a/libs/qwt/src/qwt_painter.h b/libs/qwt/src/qwt_painter.h index dd47ce35..76b96478 100644 --- a/libs/qwt/src/qwt_painter.h +++ b/libs/qwt/src/qwt_painter.h @@ -35,132 +35,130 @@ class QPainterPath; */ class QWT_EXPORT QwtPainter { - public: - static void setPolylineSplitting( bool ); - static bool polylineSplitting(); +public: + static void setPolylineSplitting(bool); + static bool polylineSplitting(); - static void setRoundingAlignment( bool ); - static bool roundingAlignment(); - static bool roundingAlignment( const QPainter* ); + static void setRoundingAlignment(bool); + static bool roundingAlignment(); + static bool roundingAlignment(const QPainter *); - static void drawText( QPainter*, qreal x, qreal y, const QString& ); - static void drawText( QPainter*, const QPointF&, const QString& ); - static void drawText( QPainter*, qreal x, qreal y, qreal w, qreal h, - int flags, const QString& ); - static void drawText( QPainter*, const QRectF&, - int flags, const QString& ); + static void drawText(QPainter *, qreal x, qreal y, const QString &); + static void drawText(QPainter *, const QPointF &, const QString &); + static void drawText(QPainter *, qreal x, qreal y, qreal w, qreal h, + int flags, const QString &); + static void drawText(QPainter *, const QRectF &, int flags, const QString &); #ifndef QT_NO_RICHTEXT - static void drawSimpleRichText( QPainter*, const QRectF&, - int flags, const QTextDocument& ); + static void drawSimpleRichText(QPainter *, const QRectF &, int flags, + const QTextDocument &); #endif - static void drawRect( QPainter*, qreal x, qreal y, qreal w, qreal h ); - static void drawRect( QPainter*, const QRectF& rect ); - static void fillRect( QPainter*, const QRectF&, const QBrush& ); + static void drawRect(QPainter *, qreal x, qreal y, qreal w, qreal h); + static void drawRect(QPainter *, const QRectF &rect); + static void fillRect(QPainter *, const QRectF &, const QBrush &); - static void drawEllipse( QPainter*, const QRectF& ); - static void drawPie( QPainter*, const QRectF& r, int a, int alen ); + static void drawEllipse(QPainter *, const QRectF &); + static void drawPie(QPainter *, const QRectF &r, int a, int alen); - static void drawLine( QPainter*, qreal x1, qreal y1, qreal x2, qreal y2 ); - static void drawLine( QPainter*, const QPointF& p1, const QPointF& p2 ); - static void drawLine( QPainter*, const QLineF& ); + static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2); + static void drawLine(QPainter *, const QPointF &p1, const QPointF &p2); + static void drawLine(QPainter *, const QLineF &); - static void drawPolygon( QPainter*, const QPolygonF& ); - static void drawPolyline( QPainter*, const QPolygonF& ); - static void drawPolyline( QPainter*, const QPointF*, int pointCount ); + static void drawPolygon(QPainter *, const QPolygonF &); + static void drawPolyline(QPainter *, const QPolygonF &); + static void drawPolyline(QPainter *, const QPointF *, int pointCount); - static void drawPolygon( QPainter*, const QPolygon& ); - static void drawPolyline( QPainter*, const QPolygon& ); - static void drawPolyline( QPainter*, const QPoint*, int pointCount ); + static void drawPolygon(QPainter *, const QPolygon &); + static void drawPolyline(QPainter *, const QPolygon &); + static void drawPolyline(QPainter *, const QPoint *, int pointCount); - static void drawPoint( QPainter*, const QPoint& ); - static void drawPoints( QPainter*, const QPolygon& ); - static void drawPoints( QPainter*, const QPoint*, int pointCount ); + static void drawPoint(QPainter *, const QPoint &); + static void drawPoints(QPainter *, const QPolygon &); + static void drawPoints(QPainter *, const QPoint *, int pointCount); - static void drawPoint( QPainter*, qreal x, qreal y ); - static void drawPoint( QPainter*, const QPointF& ); - static void drawPoints( QPainter*, const QPolygonF& ); - static void drawPoints( QPainter*, const QPointF*, int pointCount ); + static void drawPoint(QPainter *, qreal x, qreal y); + static void drawPoint(QPainter *, const QPointF &); + static void drawPoints(QPainter *, const QPolygonF &); + static void drawPoints(QPainter *, const QPointF *, int pointCount); - static void drawPath( QPainter*, const QPainterPath& ); - static void drawImage( QPainter*, const QRectF&, const QImage& ); - static void drawPixmap( QPainter*, const QRectF&, const QPixmap& ); + static void drawPath(QPainter *, const QPainterPath &); + static void drawImage(QPainter *, const QRectF &, const QImage &); + static void drawPixmap(QPainter *, const QRectF &, const QPixmap &); - static void drawRoundFrame( QPainter*, - const QRectF&, const QPalette&, int lineWidth, int frameStyle ); + static void drawRoundFrame(QPainter *, const QRectF &, const QPalette &, + int lineWidth, int frameStyle); - static void drawRoundedFrame( QPainter*, - const QRectF&, qreal xRadius, qreal yRadius, - const QPalette&, int lineWidth, int frameStyle ); + static void drawRoundedFrame(QPainter *, const QRectF &, qreal xRadius, + qreal yRadius, const QPalette &, int lineWidth, + int frameStyle); - static void drawFrame( QPainter*, const QRectF& rect, - const QPalette& palette, QPalette::ColorRole foregroundRole, - int lineWidth, int midLineWidth, int frameStyle ); + static void drawFrame(QPainter *, const QRectF &rect, const QPalette &palette, + QPalette::ColorRole foregroundRole, int lineWidth, + int midLineWidth, int frameStyle); - static void drawFocusRect( QPainter*, const QWidget* ); - static void drawFocusRect( QPainter*, const QWidget*, const QRect& ); + static void drawFocusRect(QPainter *, const QWidget *); + static void drawFocusRect(QPainter *, const QWidget *, const QRect &); - static void drawColorBar( QPainter*, - const QwtColorMap&, const QwtInterval&, - const QwtScaleMap&, Qt::Orientation, const QRectF& ); + static void drawColorBar(QPainter *, const QwtColorMap &, const QwtInterval &, + const QwtScaleMap &, Qt::Orientation, + const QRectF &); - static bool isAligning( const QPainter*); - static bool isX11GraphicsSystem(); + static bool isAligning(const QPainter *); + static bool isX11GraphicsSystem(); - static void fillPixmap( const QWidget*, - QPixmap&, const QPoint& offset = QPoint() ); + static void fillPixmap(const QWidget *, QPixmap &, + const QPoint &offset = QPoint()); - static void drawBackgound( QPainter*, - const QRectF&, const QWidget* ); + static void drawBackgound(QPainter *, const QRectF &, const QWidget *); - static QPixmap backingStore( QWidget*, const QSize& ); - static qreal devicePixelRatio( const QPaintDevice* ); + static QPixmap backingStore(QWidget *, const QSize &); + static qreal devicePixelRatio(const QPaintDevice *); - static qreal effectivePenWidth( const QPen& ); + static qreal effectivePenWidth(const QPen &); - static int horizontalAdvance( const QFontMetrics&, const QString& ); - static qreal horizontalAdvance( const QFontMetricsF&, const QString& ); + static int horizontalAdvance(const QFontMetrics &, const QString &); + static qreal horizontalAdvance(const QFontMetricsF &, const QString &); - static int horizontalAdvance( const QFontMetrics&, QChar ); - static qreal horizontalAdvance( const QFontMetricsF&, QChar ); + static int horizontalAdvance(const QFontMetrics &, QChar); + static qreal horizontalAdvance(const QFontMetricsF &, QChar); - static QFont scaledFont( const QFont&, const QPaintDevice* = nullptr ); + static QFont scaledFont(const QFont &, const QPaintDevice * = nullptr); - private: - static bool m_polylineSplitting; - static bool m_roundingAlignment; +private: + static bool m_polylineSplitting; + static bool m_roundingAlignment; }; //! Wrapper for QPainter::drawPoint() -inline void QwtPainter::drawPoint( QPainter* painter, qreal x, qreal y ) +inline void QwtPainter::drawPoint(QPainter *painter, qreal x, qreal y) { - QwtPainter::drawPoint( painter, QPointF( x, y ) ); + QwtPainter::drawPoint(painter, QPointF(x, y)); } //! Wrapper for QPainter::drawPoints() -inline void QwtPainter::drawPoints( QPainter* painter, const QPolygon& polygon ) +inline void QwtPainter::drawPoints(QPainter *painter, const QPolygon &polygon) { - drawPoints( painter, polygon.data(), polygon.size() ); + drawPoints(painter, polygon.data(), polygon.size()); } //! Wrapper for QPainter::drawPoints() -inline void QwtPainter::drawPoints( QPainter* painter, const QPolygonF& polygon ) +inline void QwtPainter::drawPoints(QPainter *painter, const QPolygonF &polygon) { - drawPoints( painter, polygon.data(), polygon.size() ); + drawPoints(painter, polygon.data(), polygon.size()); } //! Wrapper for QPainter::drawLine() -inline void QwtPainter::drawLine( QPainter* painter, - qreal x1, qreal y1, qreal x2, qreal y2 ) +inline void QwtPainter::drawLine(QPainter *painter, qreal x1, qreal y1, + qreal x2, qreal y2) { - QwtPainter::drawLine( painter, QPointF( x1, y1 ), QPointF( x2, y2 ) ); + QwtPainter::drawLine(painter, QPointF(x1, y1), QPointF(x2, y2)); } //! Wrapper for QPainter::drawLine() -inline void QwtPainter::drawLine( QPainter* painter, const QLineF& line ) +inline void QwtPainter::drawLine(QPainter *painter, const QLineF &line) { - QwtPainter::drawLine( painter, line.p1(), line.p2() ); + QwtPainter::drawLine(painter, line.p1(), line.p2()); } /*! @@ -169,7 +167,7 @@ inline void QwtPainter::drawLine( QPainter* painter, const QLineF& line ) */ inline bool QwtPainter::polylineSplitting() { - return m_polylineSplitting; + return m_polylineSplitting; } /*! @@ -182,26 +180,26 @@ inline bool QwtPainter::polylineSplitting() */ inline bool QwtPainter::roundingAlignment() { - return m_roundingAlignment; + return m_roundingAlignment; } /*! \return roundingAlignment() && isAligning(painter); \param painter Painter */ -inline bool QwtPainter::roundingAlignment( const QPainter* painter ) +inline bool QwtPainter::roundingAlignment(const QPainter *painter) { - return m_roundingAlignment && isAligning(painter); + return m_roundingAlignment && isAligning(painter); } /*! \return pen.widthF() expanded to at least 1.0 \param pen Pen */ -inline qreal QwtPainter::effectivePenWidth( const QPen& pen ) +inline qreal QwtPainter::effectivePenWidth(const QPen &pen) { - const qreal width = pen.widthF(); - return ( width < 1.0 ) ? 1.0 : width; + const qreal width = pen.widthF(); + return (width < 1.0) ? 1.0 : width; } #endif diff --git a/libs/qwt/src/qwt_painter_command.cpp b/libs/qwt/src/qwt_painter_command.cpp index 81a9f00b..6694a7d9 100644 --- a/libs/qwt/src/qwt_painter_command.cpp +++ b/libs/qwt/src/qwt_painter_command.cpp @@ -11,15 +11,15 @@ //! Construct an invalid command QwtPainterCommand::QwtPainterCommand() - : m_type( Invalid ) + : m_type(Invalid) { } //! Copy constructor -QwtPainterCommand::QwtPainterCommand( const QPainterPath& path ) - : m_type( Path ) +QwtPainterCommand::QwtPainterCommand(const QPainterPath &path) + : m_type(Path) { - m_path = new QPainterPath( path ); + m_path = new QPainterPath(path); } /*! @@ -31,14 +31,14 @@ QwtPainterCommand::QwtPainterCommand( const QPainterPath& path ) \sa QPainter::drawPixmap() */ -QwtPainterCommand::QwtPainterCommand( const QRectF& rect, - const QPixmap& pixmap, const QRectF& subRect ) - : m_type( Pixmap ) +QwtPainterCommand::QwtPainterCommand(const QRectF &rect, const QPixmap &pixmap, + const QRectF &subRect) + : m_type(Pixmap) { - m_pixmapData = new PixmapData(); - m_pixmapData->rect = rect; - m_pixmapData->pixmap = pixmap; - m_pixmapData->subRect = subRect; + m_pixmapData = new PixmapData(); + m_pixmapData->rect = rect; + m_pixmapData->pixmap = pixmap; + m_pixmapData->subRect = subRect; } /*! @@ -51,73 +51,73 @@ QwtPainterCommand::QwtPainterCommand( const QRectF& rect, \sa QPainter::drawImage() */ -QwtPainterCommand::QwtPainterCommand( const QRectF& rect, - const QImage& image, const QRectF& subRect, - Qt::ImageConversionFlags flags ) - : m_type( Image ) +QwtPainterCommand::QwtPainterCommand(const QRectF &rect, const QImage &image, + const QRectF &subRect, + Qt::ImageConversionFlags flags) + : m_type(Image) { - m_imageData = new ImageData(); - m_imageData->rect = rect; - m_imageData->image = image; - m_imageData->subRect = subRect; - m_imageData->flags = flags; + m_imageData = new ImageData(); + m_imageData->rect = rect; + m_imageData->image = image; + m_imageData->subRect = subRect; + m_imageData->flags = flags; } /*! Constructor for State paint operation \param state Paint engine state */ -QwtPainterCommand::QwtPainterCommand( const QPaintEngineState& state ) - : m_type( State ) +QwtPainterCommand::QwtPainterCommand(const QPaintEngineState &state) + : m_type(State) { - m_stateData = new StateData(); + m_stateData = new StateData(); - m_stateData->flags = state.state(); + m_stateData->flags = state.state(); - if ( m_stateData->flags & QPaintEngine::DirtyPen ) - m_stateData->pen = state.pen(); + if (m_stateData->flags & QPaintEngine::DirtyPen) + m_stateData->pen = state.pen(); - if ( m_stateData->flags & QPaintEngine::DirtyBrush ) - m_stateData->brush = state.brush(); + if (m_stateData->flags & QPaintEngine::DirtyBrush) + m_stateData->brush = state.brush(); - if ( m_stateData->flags & QPaintEngine::DirtyBrushOrigin ) - m_stateData->brushOrigin = state.brushOrigin(); + if (m_stateData->flags & QPaintEngine::DirtyBrushOrigin) + m_stateData->brushOrigin = state.brushOrigin(); - if ( m_stateData->flags & QPaintEngine::DirtyFont ) - m_stateData->font = state.font(); + if (m_stateData->flags & QPaintEngine::DirtyFont) + m_stateData->font = state.font(); - if ( m_stateData->flags & QPaintEngine::DirtyBackground ) - { - m_stateData->backgroundMode = state.backgroundMode(); - m_stateData->backgroundBrush = state.backgroundBrush(); - } + if (m_stateData->flags & QPaintEngine::DirtyBackground) + { + m_stateData->backgroundMode = state.backgroundMode(); + m_stateData->backgroundBrush = state.backgroundBrush(); + } - if ( m_stateData->flags & QPaintEngine::DirtyTransform ) - m_stateData->transform = state.transform(); + if (m_stateData->flags & QPaintEngine::DirtyTransform) + m_stateData->transform = state.transform(); - if ( m_stateData->flags & QPaintEngine::DirtyClipEnabled ) - m_stateData->isClipEnabled = state.isClipEnabled(); + if (m_stateData->flags & QPaintEngine::DirtyClipEnabled) + m_stateData->isClipEnabled = state.isClipEnabled(); - if ( m_stateData->flags & QPaintEngine::DirtyClipRegion ) - { - m_stateData->clipRegion = state.clipRegion(); - m_stateData->clipOperation = state.clipOperation(); - } + if (m_stateData->flags & QPaintEngine::DirtyClipRegion) + { + m_stateData->clipRegion = state.clipRegion(); + m_stateData->clipOperation = state.clipOperation(); + } - if ( m_stateData->flags & QPaintEngine::DirtyClipPath ) - { - m_stateData->clipPath = state.clipPath(); - m_stateData->clipOperation = state.clipOperation(); - } + if (m_stateData->flags & QPaintEngine::DirtyClipPath) + { + m_stateData->clipPath = state.clipPath(); + m_stateData->clipOperation = state.clipOperation(); + } - if ( m_stateData->flags & QPaintEngine::DirtyHints ) - m_stateData->renderHints = state.renderHints(); + if (m_stateData->flags & QPaintEngine::DirtyHints) + m_stateData->renderHints = state.renderHints(); - if ( m_stateData->flags & QPaintEngine::DirtyCompositionMode ) - m_stateData->compositionMode = state.compositionMode(); + if (m_stateData->flags & QPaintEngine::DirtyCompositionMode) + m_stateData->compositionMode = state.compositionMode(); - if ( m_stateData->flags & QPaintEngine::DirtyOpacity ) - m_stateData->opacity = state.opacity(); + if (m_stateData->flags & QPaintEngine::DirtyOpacity) + m_stateData->opacity = state.opacity(); } /*! @@ -125,15 +125,15 @@ QwtPainterCommand::QwtPainterCommand( const QPaintEngineState& state ) \param other Command to be copied */ -QwtPainterCommand::QwtPainterCommand( const QwtPainterCommand& other ) +QwtPainterCommand::QwtPainterCommand(const QwtPainterCommand &other) { - copy( other ); + copy(other); } //! Destructor QwtPainterCommand::~QwtPainterCommand() { - reset(); + reset(); } /*! @@ -142,96 +142,88 @@ QwtPainterCommand::~QwtPainterCommand() \param other Command to be copied \return Modified command */ -QwtPainterCommand& QwtPainterCommand::operator=( const QwtPainterCommand& other ) +QwtPainterCommand &QwtPainterCommand::operator=(const QwtPainterCommand &other) { - reset(); - copy( other ); + reset(); + copy(other); - return *this; + return *this; } -void QwtPainterCommand::copy( const QwtPainterCommand& other ) +void QwtPainterCommand::copy(const QwtPainterCommand &other) { - m_type = other.m_type; + m_type = other.m_type; - switch( other.m_type ) - { - case Path: - { - m_path = new QPainterPath( *other.m_path ); - break; - } - case Pixmap: - { - m_pixmapData = new PixmapData( *other.m_pixmapData ); - break; - } - case Image: - { - m_imageData = new ImageData( *other.m_imageData ); - break; - } - case State: - { - m_stateData = new StateData( *other.m_stateData ); - break; - } - default: - break; + switch (other.m_type) + { + case Path: { + m_path = new QPainterPath(*other.m_path); + break; } + case Pixmap: { + m_pixmapData = new PixmapData(*other.m_pixmapData); + break; + } + case Image: { + m_imageData = new ImageData(*other.m_imageData); + break; + } + case State: { + m_stateData = new StateData(*other.m_stateData); + break; + } + default: + break; + } } void QwtPainterCommand::reset() { - switch( m_type ) - { - case Path: - { - delete m_path; - break; - } - case Pixmap: - { - delete m_pixmapData; - break; - } - case Image: - { - delete m_imageData; - break; - } - case State: - { - delete m_stateData; - break; - } - default: - break; + switch (m_type) + { + case Path: { + delete m_path; + break; } + case Pixmap: { + delete m_pixmapData; + break; + } + case Image: { + delete m_imageData; + break; + } + case State: { + delete m_stateData; + break; + } + default: + break; + } - m_type = Invalid; + m_type = Invalid; } //! \return Painter path to be painted -QPainterPath* QwtPainterCommand::path() +QPainterPath *QwtPainterCommand::path() { - return m_path; + return m_path; } //! \return Attributes how to paint a QPixmap -QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData() +QwtPainterCommand::PixmapData *QwtPainterCommand::pixmapData() { - return m_pixmapData; + return m_pixmapData; } //! \return Attributes how to paint a QImage -QwtPainterCommand::ImageData* QwtPainterCommand::imageData() +QwtPainterCommand::ImageData *QwtPainterCommand::imageData() { - return m_imageData; + return m_imageData; } //! \return Attributes of a state change -QwtPainterCommand::StateData* QwtPainterCommand::stateData() +QwtPainterCommand::StateData *QwtPainterCommand::stateData() { - return m_stateData; + return m_stateData; } diff --git a/libs/qwt/src/qwt_painter_command.h b/libs/qwt/src/qwt_painter_command.h index 87af9612..1a398c84 100644 --- a/libs/qwt/src/qwt_painter_command.h +++ b/libs/qwt/src/qwt_painter_command.h @@ -31,144 +31,140 @@ class QPainterPath; class QWT_EXPORT QwtPainterCommand { - public: - //! Type of the paint command - enum Type - { - //! Invalid command - Invalid = -1, +public: + //! Type of the paint command + enum Type + { + //! Invalid command + Invalid = -1, - //! Draw a QPainterPath - Path, + //! Draw a QPainterPath + Path, - //! Draw a QPixmap - Pixmap, + //! Draw a QPixmap + Pixmap, - //! Draw a QImage - Image, + //! Draw a QImage + Image, - //! QPainter state change - State - }; + //! QPainter state change + State + }; - //! Attributes how to paint a QPixmap - struct PixmapData - { - QRectF rect; - QPixmap pixmap; - QRectF subRect; - }; + //! Attributes how to paint a QPixmap + struct PixmapData + { + QRectF rect; + QPixmap pixmap; + QRectF subRect; + }; - //! Attributes how to paint a QImage - struct ImageData - { - QRectF rect; - QImage image; - QRectF subRect; - Qt::ImageConversionFlags flags; - }; + //! Attributes how to paint a QImage + struct ImageData + { + QRectF rect; + QImage image; + QRectF subRect; + Qt::ImageConversionFlags flags; + }; - //! Attributes of a state change - struct StateData - { - QPaintEngine::DirtyFlags flags; + //! Attributes of a state change + struct StateData + { + QPaintEngine::DirtyFlags flags; - QPen pen; - QBrush brush; - QPointF brushOrigin; - QBrush backgroundBrush; - Qt::BGMode backgroundMode; - QFont font; - QTransform transform; + QPen pen; + QBrush brush; + QPointF brushOrigin; + QBrush backgroundBrush; + Qt::BGMode backgroundMode; + QFont font; + QTransform transform; - Qt::ClipOperation clipOperation; - QRegion clipRegion; - QPainterPath clipPath; - bool isClipEnabled; + Qt::ClipOperation clipOperation; + QRegion clipRegion; + QPainterPath clipPath; + bool isClipEnabled; - QPainter::RenderHints renderHints; - QPainter::CompositionMode compositionMode; - qreal opacity; - }; + QPainter::RenderHints renderHints; + QPainter::CompositionMode compositionMode; + qreal opacity; + }; - QwtPainterCommand(); - QwtPainterCommand(const QwtPainterCommand&); + QwtPainterCommand(); + QwtPainterCommand(const QwtPainterCommand &); - explicit QwtPainterCommand( const QPainterPath& ); + explicit QwtPainterCommand(const QPainterPath &); - QwtPainterCommand( const QRectF& rect, - const QPixmap&, const QRectF& subRect ); + QwtPainterCommand(const QRectF &rect, const QPixmap &, const QRectF &subRect); - QwtPainterCommand( const QRectF& rect, - const QImage&, const QRectF& subRect, - Qt::ImageConversionFlags ); + QwtPainterCommand(const QRectF &rect, const QImage &, const QRectF &subRect, + Qt::ImageConversionFlags); - explicit QwtPainterCommand( const QPaintEngineState& ); + explicit QwtPainterCommand(const QPaintEngineState &); - ~QwtPainterCommand(); + ~QwtPainterCommand(); - QwtPainterCommand& operator=(const QwtPainterCommand& ); + QwtPainterCommand &operator=(const QwtPainterCommand &); - Type type() const; + Type type() const; - QPainterPath* path(); - const QPainterPath* path() const; + QPainterPath *path(); + const QPainterPath *path() const; - PixmapData* pixmapData(); - const PixmapData* pixmapData() const; + PixmapData *pixmapData(); + const PixmapData *pixmapData() const; - ImageData* imageData(); - const ImageData* imageData() const; + ImageData *imageData(); + const ImageData *imageData() const; - StateData* stateData(); - const StateData* stateData() const; + StateData *stateData(); + const StateData *stateData() const; - private: - void copy( const QwtPainterCommand& ); - void reset(); +private: + void copy(const QwtPainterCommand &); + void reset(); - Type m_type; + Type m_type; - union - { - QPainterPath* m_path; - PixmapData* m_pixmapData; - ImageData* m_imageData; - StateData* m_stateData; - }; + union + { + QPainterPath *m_path; + PixmapData *m_pixmapData; + ImageData *m_imageData; + StateData *m_stateData; + }; }; //! \return Type of the command inline QwtPainterCommand::Type QwtPainterCommand::type() const { - return m_type; + return m_type; } //! \return Painter path to be painted -inline const QPainterPath* QwtPainterCommand::path() const +inline const QPainterPath *QwtPainterCommand::path() const { - return m_path; + return m_path; } //! \return Attributes how to paint a QPixmap -inline const QwtPainterCommand::PixmapData* +inline const QwtPainterCommand::PixmapData * QwtPainterCommand::pixmapData() const { - return m_pixmapData; + return m_pixmapData; } //! \return Attributes how to paint a QImage -inline const QwtPainterCommand::ImageData* -QwtPainterCommand::imageData() const +inline const QwtPainterCommand::ImageData *QwtPainterCommand::imageData() const { - return m_imageData; + return m_imageData; } //! \return Attributes of a state change -inline const QwtPainterCommand::StateData* -QwtPainterCommand::stateData() const +inline const QwtPainterCommand::StateData *QwtPainterCommand::stateData() const { - return m_stateData; + return m_stateData; } #endif diff --git a/libs/qwt/src/qwt_panner.cpp b/libs/qwt/src/qwt_panner.cpp index e56a72d3..4b1c274c 100644 --- a/libs/qwt/src/qwt_panner.cpp +++ b/libs/qwt/src/qwt_panner.cpp @@ -17,66 +17,66 @@ #include #include -static QVector< QwtPicker* > qwtActivePickers( QWidget* w ) +static QVector qwtActivePickers(QWidget *w) { - QVector< QwtPicker* > pickers; + QVector pickers; - QObjectList children = w->children(); - for ( int i = 0; i < children.size(); i++ ) - { - QwtPicker* picker = qobject_cast< QwtPicker* >( children[i] ); - if ( picker && picker->isEnabled() ) - pickers += picker; - } + QObjectList children = w->children(); + for (int i = 0; i < children.size(); i++) + { + QwtPicker *picker = qobject_cast(children[i]); + if (picker && picker->isEnabled()) + pickers += picker; + } - return pickers; + return pickers; } class QwtPanner::PrivateData { - public: - PrivateData() - : button( Qt::LeftButton ) - , buttonModifiers( Qt::NoModifier ) - , abortKey( Qt::Key_Escape ) - , abortKeyModifiers( Qt::NoModifier ) +public: + PrivateData() + : button(Qt::LeftButton) + , buttonModifiers(Qt::NoModifier) + , abortKey(Qt::Key_Escape) + , abortKeyModifiers(Qt::NoModifier) #ifndef QT_NO_CURSOR - , cursor( NULL ) - , restoreCursor( NULL ) - , hasCursor( false ) + , cursor(NULL) + , restoreCursor(NULL) + , hasCursor(false) #endif - , isEnabled( false ) - , orientations( Qt::Vertical | Qt::Horizontal ) - { - } + , isEnabled(false) + , orientations(Qt::Vertical | Qt::Horizontal) + { + } - ~PrivateData() - { + ~PrivateData() + { #ifndef QT_NO_CURSOR - delete cursor; - delete restoreCursor; + delete cursor; + delete restoreCursor; #endif - } + } - Qt::MouseButton button; - Qt::KeyboardModifiers buttonModifiers; + Qt::MouseButton button; + Qt::KeyboardModifiers buttonModifiers; - int abortKey; - Qt::KeyboardModifiers abortKeyModifiers; + int abortKey; + Qt::KeyboardModifiers abortKeyModifiers; - QPoint initialPos; - QPoint pos; + QPoint initialPos; + QPoint pos; - QPixmap pixmap; - QBitmap contentsMask; + QPixmap pixmap; + QBitmap contentsMask; #ifndef QT_NO_CURSOR - QCursor* cursor; - QCursor* restoreCursor; - bool hasCursor; + QCursor *cursor; + QCursor *restoreCursor; + bool hasCursor; #endif - bool isEnabled; - Qt::Orientations orientations; + bool isEnabled; + Qt::Orientations orientations; }; /*! @@ -84,42 +84,42 @@ class QwtPanner::PrivateData \param parent Parent widget to be panned */ -QwtPanner::QwtPanner( QWidget* parent ) - : QWidget( parent ) +QwtPanner::QwtPanner(QWidget *parent) + : QWidget(parent) { - m_data = new PrivateData(); + m_data = new PrivateData(); - setAttribute( Qt::WA_TransparentForMouseEvents ); - setAttribute( Qt::WA_NoSystemBackground ); - setFocusPolicy( Qt::NoFocus ); - hide(); + setAttribute(Qt::WA_TransparentForMouseEvents); + setAttribute(Qt::WA_NoSystemBackground); + setFocusPolicy(Qt::NoFocus); + hide(); - setEnabled( true ); + setEnabled(true); } //! Destructor QwtPanner::~QwtPanner() { - delete m_data; + delete m_data; } /*! Change the mouse button and modifiers used for panning The defaults are Qt::LeftButton and Qt::NoModifier */ -void QwtPanner::setMouseButton( Qt::MouseButton button, - Qt::KeyboardModifiers modifiers ) +void QwtPanner::setMouseButton(Qt::MouseButton button, + Qt::KeyboardModifiers modifiers) { - m_data->button = button; - m_data->buttonModifiers = modifiers; + m_data->button = button; + m_data->buttonModifiers = modifiers; } //! Get mouse button and modifiers used for panning -void QwtPanner::getMouseButton( Qt::MouseButton& button, - Qt::KeyboardModifiers& modifiers ) const +void QwtPanner::getMouseButton(Qt::MouseButton &button, + Qt::KeyboardModifiers &modifiers) const { - button = m_data->button; - modifiers = m_data->buttonModifiers; + button = m_data->button; + modifiers = m_data->buttonModifiers; } /*! @@ -129,19 +129,17 @@ void QwtPanner::getMouseButton( Qt::MouseButton& button, \param key Key ( See Qt::Keycode ) \param modifiers Keyboard modifiers */ -void QwtPanner::setAbortKey( int key, - Qt::KeyboardModifiers modifiers ) +void QwtPanner::setAbortKey(int key, Qt::KeyboardModifiers modifiers) { - m_data->abortKey = key; - m_data->abortKeyModifiers = modifiers; + m_data->abortKey = key; + m_data->abortKeyModifiers = modifiers; } //! Get the abort key and modifiers -void QwtPanner::getAbortKey( int& key, - Qt::KeyboardModifiers& modifiers ) const +void QwtPanner::getAbortKey(int &key, Qt::KeyboardModifiers &modifiers) const { - key = m_data->abortKey; - modifiers = m_data->abortKeyModifiers; + key = m_data->abortKey; + modifiers = m_data->abortKeyModifiers; } /*! @@ -153,9 +151,9 @@ void QwtPanner::getAbortKey( int& key, \sa setCursor() */ #ifndef QT_NO_CURSOR -void QwtPanner::setCursor( const QCursor& cursor ) +void QwtPanner::setCursor(const QCursor &cursor) { - m_data->cursor = new QCursor( cursor ); + m_data->cursor = new QCursor(cursor); } #endif @@ -166,13 +164,13 @@ void QwtPanner::setCursor( const QCursor& cursor ) #ifndef QT_NO_CURSOR const QCursor QwtPanner::cursor() const { - if ( m_data->cursor ) - return *m_data->cursor; + if (m_data->cursor) + return *m_data->cursor; - if ( parentWidget() ) - return parentWidget()->cursor(); + if (parentWidget()) + return parentWidget()->cursor(); - return QCursor(); + return QCursor(); } #endif @@ -185,26 +183,26 @@ const QCursor QwtPanner::cursor() const \param on true or false \sa isEnabled(), eventFilter() */ -void QwtPanner::setEnabled( bool on ) +void QwtPanner::setEnabled(bool on) { - if ( m_data->isEnabled != on ) - { - m_data->isEnabled = on; + if (m_data->isEnabled != on) + { + m_data->isEnabled = on; - QWidget* w = parentWidget(); - if ( w ) - { - if ( m_data->isEnabled ) - { - w->installEventFilter( this ); - } - else - { - w->removeEventFilter( this ); - hide(); - } - } + QWidget *w = parentWidget(); + if (w) + { + if (m_data->isEnabled) + { + w->installEventFilter(this); + } + else + { + w->removeEventFilter(this); + hide(); + } } + } } /*! @@ -213,24 +211,24 @@ void QwtPanner::setEnabled( bool on ) /param o Orientation */ -void QwtPanner::setOrientations( Qt::Orientations o ) +void QwtPanner::setOrientations(Qt::Orientations o) { - m_data->orientations = o; + m_data->orientations = o; } //! Return the orientation, where panning is enabled Qt::Orientations QwtPanner::orientations() const { - return m_data->orientations; + return m_data->orientations; } /*! \return True if an orientation is enabled \sa orientations(), setOrientations() */ -bool QwtPanner::isOrientationEnabled( Qt::Orientation o ) const +bool QwtPanner::isOrientationEnabled(Qt::Orientation o) const { - return m_data->orientations & o; + return m_data->orientations & o; } /*! @@ -239,7 +237,7 @@ bool QwtPanner::isOrientationEnabled( Qt::Orientation o ) const */ bool QwtPanner::isEnabled() const { - return m_data->isEnabled; + return m_data->isEnabled; } /*! @@ -250,39 +248,40 @@ bool QwtPanner::isEnabled() const \param event Paint event */ -void QwtPanner::paintEvent( QPaintEvent* event ) +void QwtPanner::paintEvent(QPaintEvent *event) { - int dx = m_data->pos.x() - m_data->initialPos.x(); - int dy = m_data->pos.y() - m_data->initialPos.y(); + int dx = m_data->pos.x() - m_data->initialPos.x(); + int dy = m_data->pos.y() - m_data->initialPos.y(); - QRectF r; - r.setSize( m_data->pixmap.size() / QwtPainter::devicePixelRatio( &m_data->pixmap ) ); - r.moveCenter( QPointF( r.center().x() + dx, r.center().y() + dy ) ); + QRectF r; + r.setSize(m_data->pixmap.size() + / QwtPainter::devicePixelRatio(&m_data->pixmap)); + r.moveCenter(QPointF(r.center().x() + dx, r.center().y() + dy)); - QPixmap pm = QwtPainter::backingStore( this, size() ); - QwtPainter::fillPixmap( parentWidget(), pm ); + QPixmap pm = QwtPainter::backingStore(this, size()); + QwtPainter::fillPixmap(parentWidget(), pm); - QPainter painter( &pm ); + QPainter painter(&pm); - if ( !m_data->contentsMask.isNull() ) - { - QPixmap masked = m_data->pixmap; - masked.setMask( m_data->contentsMask ); - painter.drawPixmap( r.toRect(), masked ); - } - else - { - painter.drawPixmap( r.toRect(), m_data->pixmap ); - } + if (!m_data->contentsMask.isNull()) + { + QPixmap masked = m_data->pixmap; + masked.setMask(m_data->contentsMask); + painter.drawPixmap(r.toRect(), masked); + } + else + { + painter.drawPixmap(r.toRect(), m_data->pixmap); + } - painter.end(); + painter.end(); - if ( !m_data->contentsMask.isNull() ) - pm.setMask( m_data->contentsMask ); + if (!m_data->contentsMask.isNull()) + pm.setMask(m_data->contentsMask); - painter.begin( this ); - painter.setClipRegion( event->region() ); - painter.drawPixmap( 0, 0, pm ); + painter.begin(this); + painter.setClipRegion(event->region()); + painter.drawPixmap(0, 0, pm); } /*! @@ -296,7 +295,7 @@ void QwtPanner::paintEvent( QPaintEvent* event ) */ QBitmap QwtPanner::contentsMask() const { - return QBitmap(); + return QBitmap(); } /*! @@ -306,9 +305,9 @@ QBitmap QwtPanner::contentsMask() const QPixmap QwtPanner::grab() const { #if QT_VERSION >= 0x050000 - return parentWidget()->grab( parentWidget()->rect() ); + return parentWidget()->grab(parentWidget()->rect()); #else - return QPixmap::grabWidget( parentWidget() ); + return QPixmap::grabWidget(parentWidget()); #endif } @@ -327,48 +326,42 @@ QPixmap QwtPanner::grab() const \sa widgetMousePressEvent(), widgetMouseReleaseEvent(), widgetMouseMoveEvent() */ -bool QwtPanner::eventFilter( QObject* object, QEvent* event ) +bool QwtPanner::eventFilter(QObject *object, QEvent *event) { - if ( object == NULL || object != parentWidget() ) - return false; - - switch ( event->type() ) - { - case QEvent::MouseButtonPress: - { - widgetMousePressEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseMove: - { - widgetMouseMoveEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseButtonRelease: - { - widgetMouseReleaseEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::KeyPress: - { - widgetKeyPressEvent( static_cast< QKeyEvent* >( event ) ); - break; - } - case QEvent::KeyRelease: - { - widgetKeyReleaseEvent( static_cast< QKeyEvent* >( event ) ); - break; - } - case QEvent::Paint: - { - if ( isVisible() ) - return true; - break; - } - default:; - } - + if (object == NULL || object != parentWidget()) return false; + + switch (event->type()) + { + case QEvent::MouseButtonPress: { + widgetMousePressEvent(static_cast(event)); + break; + } + case QEvent::MouseMove: { + widgetMouseMoveEvent(static_cast(event)); + break; + } + case QEvent::MouseButtonRelease: { + widgetMouseReleaseEvent(static_cast(event)); + break; + } + case QEvent::KeyPress: { + widgetKeyPressEvent(static_cast(event)); + break; + } + case QEvent::KeyRelease: { + widgetKeyReleaseEvent(static_cast(event)); + break; + } + case QEvent::Paint: { + if (isVisible()) + return true; + break; + } + default:; + } + + return false; } /*! @@ -378,38 +371,38 @@ bool QwtPanner::eventFilter( QObject* object, QEvent* event ) \sa eventFilter(), widgetMouseReleaseEvent(), widgetMouseMoveEvent(), */ -void QwtPanner::widgetMousePressEvent( QMouseEvent* mouseEvent ) +void QwtPanner::widgetMousePressEvent(QMouseEvent *mouseEvent) { - if ( ( mouseEvent->button() != m_data->button ) - || ( mouseEvent->modifiers() != m_data->buttonModifiers ) ) - { - return; - } + if ((mouseEvent->button() != m_data->button) + || (mouseEvent->modifiers() != m_data->buttonModifiers)) + { + return; + } - QWidget* w = parentWidget(); - if ( w == NULL ) - return; + QWidget *w = parentWidget(); + if (w == NULL) + return; #ifndef QT_NO_CURSOR - showCursor( true ); + showCursor(true); #endif - m_data->initialPos = m_data->pos = mouseEvent->pos(); + m_data->initialPos = m_data->pos = mouseEvent->pos(); - setGeometry( parentWidget()->rect() ); + setGeometry(parentWidget()->rect()); - // We don't want to grab the picker ! - QVector< QwtPicker* > pickers = qwtActivePickers( parentWidget() ); - for ( int i = 0; i < pickers.size(); i++ ) - pickers[i]->setEnabled( false ); + // We don't want to grab the picker ! + QVector pickers = qwtActivePickers(parentWidget()); + for (int i = 0; i < pickers.size(); i++) + pickers[i]->setEnabled(false); - m_data->pixmap = grab(); - m_data->contentsMask = contentsMask(); + m_data->pixmap = grab(); + m_data->contentsMask = contentsMask(); - for ( int i = 0; i < pickers.size(); i++ ) - pickers[i]->setEnabled( true ); + for (int i = 0; i < pickers.size(); i++) + pickers[i]->setEnabled(true); - show(); + show(); } /*! @@ -418,25 +411,25 @@ void QwtPanner::widgetMousePressEvent( QMouseEvent* mouseEvent ) \param mouseEvent Mouse event \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent() */ -void QwtPanner::widgetMouseMoveEvent( QMouseEvent* mouseEvent ) +void QwtPanner::widgetMouseMoveEvent(QMouseEvent *mouseEvent) { - if ( !isVisible() ) - return; + if (!isVisible()) + return; - QPoint pos = mouseEvent->pos(); - if ( !isOrientationEnabled( Qt::Horizontal ) ) - pos.setX( m_data->initialPos.x() ); - if ( !isOrientationEnabled( Qt::Vertical ) ) - pos.setY( m_data->initialPos.y() ); + QPoint pos = mouseEvent->pos(); + if (!isOrientationEnabled(Qt::Horizontal)) + pos.setX(m_data->initialPos.x()); + if (!isOrientationEnabled(Qt::Vertical)) + pos.setY(m_data->initialPos.y()); - if ( pos != m_data->pos && rect().contains( pos ) ) - { - m_data->pos = pos; - update(); + if (pos != m_data->pos && rect().contains(pos)) + { + m_data->pos = pos; + update(); - Q_EMIT moved( m_data->pos.x() - m_data->initialPos.x(), - m_data->pos.y() - m_data->initialPos.y() ); - } + Q_EMIT moved(m_data->pos.x() - m_data->initialPos.x(), + m_data->pos.y() - m_data->initialPos.y()); + } } /*! @@ -446,31 +439,31 @@ void QwtPanner::widgetMouseMoveEvent( QMouseEvent* mouseEvent ) \sa eventFilter(), widgetMousePressEvent(), widgetMouseMoveEvent(), */ -void QwtPanner::widgetMouseReleaseEvent( QMouseEvent* mouseEvent ) +void QwtPanner::widgetMouseReleaseEvent(QMouseEvent *mouseEvent) { - if ( isVisible() ) - { - hide(); + if (isVisible()) + { + hide(); #ifndef QT_NO_CURSOR - showCursor( false ); + showCursor(false); #endif - QPoint pos = mouseEvent->pos(); - if ( !isOrientationEnabled( Qt::Horizontal ) ) - pos.setX( m_data->initialPos.x() ); - if ( !isOrientationEnabled( Qt::Vertical ) ) - pos.setY( m_data->initialPos.y() ); + QPoint pos = mouseEvent->pos(); + if (!isOrientationEnabled(Qt::Horizontal)) + pos.setX(m_data->initialPos.x()); + if (!isOrientationEnabled(Qt::Vertical)) + pos.setY(m_data->initialPos.y()); - m_data->pixmap = QPixmap(); - m_data->contentsMask = QBitmap(); - m_data->pos = pos; + m_data->pixmap = QPixmap(); + m_data->contentsMask = QBitmap(); + m_data->pos = pos; - if ( m_data->pos != m_data->initialPos ) - { - Q_EMIT panned( m_data->pos.x() - m_data->initialPos.x(), - m_data->pos.y() - m_data->initialPos.y() ); - } + if (m_data->pos != m_data->initialPos) + { + Q_EMIT panned(m_data->pos.x() - m_data->initialPos.x(), + m_data->pos.y() - m_data->initialPos.y()); } + } } /*! @@ -479,18 +472,18 @@ void QwtPanner::widgetMouseReleaseEvent( QMouseEvent* mouseEvent ) \param keyEvent Key event \sa eventFilter(), widgetKeyReleaseEvent() */ -void QwtPanner::widgetKeyPressEvent( QKeyEvent* keyEvent ) +void QwtPanner::widgetKeyPressEvent(QKeyEvent *keyEvent) { - if ( ( keyEvent->key() == m_data->abortKey ) - && ( keyEvent->modifiers() == m_data->abortKeyModifiers ) ) - { - hide(); + if ((keyEvent->key() == m_data->abortKey) + && (keyEvent->modifiers() == m_data->abortKeyModifiers)) + { + hide(); #ifndef QT_NO_CURSOR - showCursor( false ); + showCursor(false); #endif - m_data->pixmap = QPixmap(); - } + m_data->pixmap = QPixmap(); + } } /*! @@ -499,46 +492,46 @@ void QwtPanner::widgetKeyPressEvent( QKeyEvent* keyEvent ) \param keyEvent Key event \sa eventFilter(), widgetKeyReleaseEvent() */ -void QwtPanner::widgetKeyReleaseEvent( QKeyEvent* keyEvent ) +void QwtPanner::widgetKeyReleaseEvent(QKeyEvent *keyEvent) { - Q_UNUSED( keyEvent ); + Q_UNUSED(keyEvent); } #ifndef QT_NO_CURSOR -void QwtPanner::showCursor( bool on ) +void QwtPanner::showCursor(bool on) { - if ( on == m_data->hasCursor ) - return; + if (on == m_data->hasCursor) + return; - QWidget* w = parentWidget(); - if ( w == NULL || m_data->cursor == NULL ) - return; + QWidget *w = parentWidget(); + if (w == NULL || m_data->cursor == NULL) + return; - m_data->hasCursor = on; + m_data->hasCursor = on; - if ( on ) + if (on) + { + if (w->testAttribute(Qt::WA_SetCursor)) { - if ( w->testAttribute( Qt::WA_SetCursor ) ) - { - delete m_data->restoreCursor; - m_data->restoreCursor = new QCursor( w->cursor() ); - } - w->setCursor( *m_data->cursor ); + delete m_data->restoreCursor; + m_data->restoreCursor = new QCursor(w->cursor()); + } + w->setCursor(*m_data->cursor); + } + else + { + if (m_data->restoreCursor) + { + w->setCursor(*m_data->restoreCursor); + delete m_data->restoreCursor; + m_data->restoreCursor = NULL; } else - { - if ( m_data->restoreCursor ) - { - w->setCursor( *m_data->restoreCursor ); - delete m_data->restoreCursor; - m_data->restoreCursor = NULL; - } - else - w->unsetCursor(); - } + w->unsetCursor(); + } } #endif #if QWT_MOC_INCLUDE -#include "moc_qwt_panner.cpp" +# include "moc_qwt_panner.cpp" #endif diff --git a/libs/qwt/src/qwt_panner.h b/libs/qwt/src/qwt_panner.h index a640e659..e07fbd9c 100644 --- a/libs/qwt/src/qwt_panner.h +++ b/libs/qwt/src/qwt_panner.h @@ -34,70 +34,68 @@ class QPixmap; */ class QWT_EXPORT QwtPanner : public QWidget { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPanner( QWidget* parent ); - virtual ~QwtPanner(); +public: + explicit QwtPanner(QWidget *parent); + virtual ~QwtPanner(); - void setEnabled( bool ); - bool isEnabled() const; + void setEnabled(bool); + bool isEnabled() const; - void setMouseButton( Qt::MouseButton, - Qt::KeyboardModifiers = Qt::NoModifier ); - void getMouseButton( Qt::MouseButton& button, - Qt::KeyboardModifiers& ) const; + void setMouseButton(Qt::MouseButton, Qt::KeyboardModifiers = Qt::NoModifier); + void getMouseButton(Qt::MouseButton &button, Qt::KeyboardModifiers &) const; - void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier ); - void getAbortKey( int& key, Qt::KeyboardModifiers& ) const; + void setAbortKey(int key, Qt::KeyboardModifiers = Qt::NoModifier); + void getAbortKey(int &key, Qt::KeyboardModifiers &) const; - void setCursor( const QCursor& ); - const QCursor cursor() const; + void setCursor(const QCursor &); + const QCursor cursor() const; - void setOrientations( Qt::Orientations ); - Qt::Orientations orientations() const; + void setOrientations(Qt::Orientations); + Qt::Orientations orientations() const; - bool isOrientationEnabled( Qt::Orientation ) const; + bool isOrientationEnabled(Qt::Orientation) const; - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - Q_SIGNALS: - /*! - Signal emitted, when panning is done +Q_SIGNALS: + /*! + Signal emitted, when panning is done - \param dx Offset in horizontal direction - \param dy Offset in vertical direction - */ - void panned( int dx, int dy ); + \param dx Offset in horizontal direction + \param dy Offset in vertical direction + */ + void panned(int dx, int dy); - /*! - Signal emitted, while the widget moved, but panning - is not finished. + /*! + Signal emitted, while the widget moved, but panning + is not finished. - \param dx Offset in horizontal direction - \param dy Offset in vertical direction - */ - void moved( int dx, int dy ); + \param dx Offset in horizontal direction + \param dy Offset in vertical direction + */ + void moved(int dx, int dy); - protected: - virtual void widgetMousePressEvent( QMouseEvent* ); - virtual void widgetMouseReleaseEvent( QMouseEvent* ); - virtual void widgetMouseMoveEvent( QMouseEvent* ); - virtual void widgetKeyPressEvent( QKeyEvent* ); - virtual void widgetKeyReleaseEvent( QKeyEvent* ); +protected: + virtual void widgetMousePressEvent(QMouseEvent *); + virtual void widgetMouseReleaseEvent(QMouseEvent *); + virtual void widgetMouseMoveEvent(QMouseEvent *); + virtual void widgetKeyPressEvent(QKeyEvent *); + virtual void widgetKeyReleaseEvent(QKeyEvent *); - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; - virtual QBitmap contentsMask() const; - virtual QPixmap grab() const; + virtual QBitmap contentsMask() const; + virtual QPixmap grab() const; - private: +private: #ifndef QT_NO_CURSOR - void showCursor( bool ); + void showCursor(bool); #endif - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_picker.cpp b/libs/qwt/src/qwt_picker.cpp index 71fa4d95..06e5acf8 100644 --- a/libs/qwt/src/qwt_picker.cpp +++ b/libs/qwt/src/qwt_picker.cpp @@ -20,140 +20,138 @@ #include #include -static inline QRegion qwtMaskRegion( const QRect& r, int penWidth ) +static inline QRegion qwtMaskRegion(const QRect &r, int penWidth) { - const int pw = qMax( penWidth, 1 ); - const int pw2 = penWidth / 2; + const int pw = qMax(penWidth, 1); + const int pw2 = penWidth / 2; - int x1 = r.left() - pw2; - int x2 = r.right() + 1 + pw2 + ( pw % 2 ); + int x1 = r.left() - pw2; + int x2 = r.right() + 1 + pw2 + (pw % 2); - int y1 = r.top() - pw2; - int y2 = r.bottom() + 1 + pw2 + ( pw % 2 ); + int y1 = r.top() - pw2; + int y2 = r.bottom() + 1 + pw2 + (pw % 2); - QRegion region; + QRegion region; - region += QRect( x1, y1, x2 - x1, pw ); - region += QRect( x1, y1, pw, y2 - y1 ); - region += QRect( x1, y2 - pw, x2 - x1, pw ); - region += QRect( x2 - pw, y1, pw, y2 - y1 ); + region += QRect(x1, y1, x2 - x1, pw); + region += QRect(x1, y1, pw, y2 - y1); + region += QRect(x1, y2 - pw, x2 - x1, pw); + region += QRect(x2 - pw, y1, pw, y2 - y1); - return region; + return region; } -static inline QRegion qwtMaskRegion( const QLine& l, int penWidth ) +static inline QRegion qwtMaskRegion(const QLine &l, int penWidth) { - const int pw = qMax( penWidth, 1 ); - const int pw2 = penWidth / 2; + const int pw = qMax(penWidth, 1); + const int pw2 = penWidth / 2; - QRegion region; + QRegion region; - if ( l.x1() == l.x2() ) - { - region += QRect( l.x1() - pw2, l.y1(), - pw, l.y2() ).normalized(); - } - else if ( l.y1() == l.y2() ) - { - region += QRect( l.x1(), l.y1() - pw2, - l.x2(), pw ).normalized(); - } + if (l.x1() == l.x2()) + { + region += QRect(l.x1() - pw2, l.y1(), pw, l.y2()).normalized(); + } + else if (l.y1() == l.y2()) + { + region += QRect(l.x1(), l.y1() - pw2, l.x2(), pw).normalized(); + } - return region; + return region; } namespace QwtPickerPrivate { - class Rubberband QWT_FINAL : public QwtWidgetOverlay - { - public: - Rubberband( QwtPicker* picker, QWidget* parent ) - : QwtWidgetOverlay( parent ) - , m_picker( picker ) - { - setMaskMode( QwtWidgetOverlay::MaskHint ); - } +class Rubberband QWT_FINAL : public QwtWidgetOverlay +{ +public: + Rubberband(QwtPicker *picker, QWidget *parent) + : QwtWidgetOverlay(parent) + , m_picker(picker) + { + setMaskMode(QwtWidgetOverlay::MaskHint); + } - protected: - virtual void drawOverlay( QPainter* painter ) const QWT_OVERRIDE - { - painter->setPen( m_picker->rubberBandPen() ); - m_picker->drawRubberBand( painter ); - } +protected: + virtual void drawOverlay(QPainter *painter) const QWT_OVERRIDE + { + painter->setPen(m_picker->rubberBandPen()); + m_picker->drawRubberBand(painter); + } - virtual QRegion maskHint() const QWT_OVERRIDE - { - return m_picker->rubberBandMask(); - } + virtual QRegion maskHint() const QWT_OVERRIDE + { + return m_picker->rubberBandMask(); + } - QwtPicker* m_picker; - }; + QwtPicker *m_picker; +}; - class Tracker QWT_FINAL : public QwtWidgetOverlay - { - public: - Tracker( QwtPicker* picker, QWidget* parent ) - : QwtWidgetOverlay( parent ) - , m_picker( picker ) - { - setMaskMode( QwtWidgetOverlay::MaskHint ); - } +class Tracker QWT_FINAL : public QwtWidgetOverlay +{ +public: + Tracker(QwtPicker *picker, QWidget *parent) + : QwtWidgetOverlay(parent) + , m_picker(picker) + { + setMaskMode(QwtWidgetOverlay::MaskHint); + } - protected: - virtual void drawOverlay( QPainter* painter ) const QWT_OVERRIDE - { - painter->setPen( m_picker->trackerPen() ); - m_picker->drawTracker( painter ); - } +protected: + virtual void drawOverlay(QPainter *painter) const QWT_OVERRIDE + { + painter->setPen(m_picker->trackerPen()); + m_picker->drawTracker(painter); + } - virtual QRegion maskHint() const QWT_OVERRIDE - { - return m_picker->trackerMask(); - } + virtual QRegion maskHint() const QWT_OVERRIDE + { + return m_picker->trackerMask(); + } - QwtPicker* m_picker; - }; -} + QwtPicker *m_picker; +}; +} // namespace QwtPickerPrivate class QwtPicker::PrivateData { - public: - PrivateData(): - enabled( false ), - stateMachine( NULL ), - resizeMode( QwtPicker::Stretch ), - rubberBand( QwtPicker::NoRubberBand ), - trackerMode( QwtPicker::AlwaysOff ), - isActive( false ), - trackerPosition( -1, -1 ), - mouseTracking( false ), - openGL( false ) - { - } +public: + PrivateData() + : enabled(false) + , stateMachine(NULL) + , resizeMode(QwtPicker::Stretch) + , rubberBand(QwtPicker::NoRubberBand) + , trackerMode(QwtPicker::AlwaysOff) + , isActive(false) + , trackerPosition(-1, -1) + , mouseTracking(false) + , openGL(false) + { + } - bool enabled; + bool enabled; - QwtPickerMachine* stateMachine; + QwtPickerMachine *stateMachine; - QwtPicker::ResizeMode resizeMode; + QwtPicker::ResizeMode resizeMode; - QwtPicker::RubberBand rubberBand; - QPen rubberBandPen; + QwtPicker::RubberBand rubberBand; + QPen rubberBandPen; - QwtPicker::DisplayMode trackerMode; - QPen trackerPen; - QFont trackerFont; + QwtPicker::DisplayMode trackerMode; + QPen trackerPen; + QFont trackerFont; - QPolygon pickedPoints; - bool isActive; - QPoint trackerPosition; + QPolygon pickedPoints; + bool isActive; + QPoint trackerPosition; - bool mouseTracking; // used to save previous value + bool mouseTracking; // used to save previous value - QPointer< QwtPickerPrivate::Rubberband > rubberBandOverlay; - QPointer< QwtPickerPrivate::Tracker > trackerOverlay; + QPointer rubberBandOverlay; + QPointer trackerOverlay; - bool openGL; + bool openGL; }; /*! @@ -165,10 +163,10 @@ class QwtPicker::PrivateData \param parent Parent widget, that will be observed */ -QwtPicker::QwtPicker( QWidget* parent ): - QObject( parent ) +QwtPicker::QwtPicker(QWidget *parent) + : QObject(parent) { - init( parent, NoRubberBand, AlwaysOff ); + init(parent, NoRubberBand, AlwaysOff); } /*! @@ -178,46 +176,46 @@ QwtPicker::QwtPicker( QWidget* parent ): \param trackerMode Tracker mode \param parent Parent widget, that will be observed */ -QwtPicker::QwtPicker( RubberBand rubberBand, - DisplayMode trackerMode, QWidget* parent ): - QObject( parent ) +QwtPicker::QwtPicker(RubberBand rubberBand, DisplayMode trackerMode, + QWidget *parent) + : QObject(parent) { - init( parent, rubberBand, trackerMode ); + init(parent, rubberBand, trackerMode); } //! Destructor QwtPicker::~QwtPicker() { - setMouseTracking( false ); + setMouseTracking(false); - delete m_data->stateMachine; - delete m_data->rubberBandOverlay; - delete m_data->trackerOverlay; + delete m_data->stateMachine; + delete m_data->rubberBandOverlay; + delete m_data->trackerOverlay; - delete m_data; + delete m_data; } //! Initialize the picker - used by the constructors -void QwtPicker::init( QWidget* parent, - RubberBand rubberBand, DisplayMode trackerMode ) +void QwtPicker::init(QWidget *parent, RubberBand rubberBand, + DisplayMode trackerMode) { - m_data = new PrivateData; + m_data = new PrivateData; - m_data->rubberBand = rubberBand; + m_data->rubberBand = rubberBand; - if ( parent ) - { - if ( parent->focusPolicy() == Qt::NoFocus ) - parent->setFocusPolicy( Qt::WheelFocus ); + if (parent) + { + if (parent->focusPolicy() == Qt::NoFocus) + parent->setFocusPolicy(Qt::WheelFocus); - m_data->openGL = parent->inherits( "QGLWidget" ); - m_data->trackerFont = parent->font(); - m_data->mouseTracking = parent->hasMouseTracking(); + m_data->openGL = parent->inherits("QGLWidget"); + m_data->trackerFont = parent->font(); + m_data->mouseTracking = parent->hasMouseTracking(); - setEnabled( true ); - } + setEnabled(true); + } - setTrackerMode( trackerMode ); + setTrackerMode(trackerMode); } /*! @@ -226,56 +224,56 @@ void QwtPicker::init( QWidget* parent, \param stateMachine State machine \sa stateMachine() */ -void QwtPicker::setStateMachine( QwtPickerMachine* stateMachine ) +void QwtPicker::setStateMachine(QwtPickerMachine *stateMachine) { - if ( m_data->stateMachine != stateMachine ) - { - reset(); + if (m_data->stateMachine != stateMachine) + { + reset(); - delete m_data->stateMachine; - m_data->stateMachine = stateMachine; + delete m_data->stateMachine; + m_data->stateMachine = stateMachine; - if ( m_data->stateMachine ) - m_data->stateMachine->reset(); - } + if (m_data->stateMachine) + m_data->stateMachine->reset(); + } } /*! \return Assigned state machine \sa setStateMachine() */ -QwtPickerMachine* QwtPicker::stateMachine() +QwtPickerMachine *QwtPicker::stateMachine() { - return m_data->stateMachine; + return m_data->stateMachine; } /*! \return Assigned state machine \sa setStateMachine() */ -const QwtPickerMachine* QwtPicker::stateMachine() const +const QwtPickerMachine *QwtPicker::stateMachine() const { - return m_data->stateMachine; + return m_data->stateMachine; } //! Return the parent widget, where the selection happens -QWidget* QwtPicker::parentWidget() +QWidget *QwtPicker::parentWidget() { - QObject* obj = parent(); - if ( obj && obj->isWidgetType() ) - return static_cast< QWidget* >( obj ); + QObject *obj = parent(); + if (obj && obj->isWidgetType()) + return static_cast(obj); - return NULL; + return NULL; } //! Return the parent widget, where the selection happens -const QWidget* QwtPicker::parentWidget() const +const QWidget *QwtPicker::parentWidget() const { - QObject* obj = parent(); - if ( obj && obj->isWidgetType() ) - return static_cast< const QWidget* >( obj ); + QObject *obj = parent(); + if (obj && obj->isWidgetType()) + return static_cast(obj); - return NULL; + return NULL; } /*! @@ -286,9 +284,9 @@ const QWidget* QwtPicker::parentWidget() const \sa rubberBand(), RubberBand, setRubberBandPen() */ -void QwtPicker::setRubberBand( RubberBand rubberBand ) +void QwtPicker::setRubberBand(RubberBand rubberBand) { - m_data->rubberBand = rubberBand; + m_data->rubberBand = rubberBand; } /*! @@ -297,7 +295,7 @@ void QwtPicker::setRubberBand( RubberBand rubberBand ) */ QwtPicker::RubberBand QwtPicker::rubberBand() const { - return m_data->rubberBand; + return m_data->rubberBand; } /*! @@ -316,13 +314,13 @@ QwtPicker::RubberBand QwtPicker::rubberBand() const \sa trackerMode(), DisplayMode */ -void QwtPicker::setTrackerMode( DisplayMode mode ) +void QwtPicker::setTrackerMode(DisplayMode mode) { - if ( m_data->trackerMode != mode ) - { - m_data->trackerMode = mode; - setMouseTracking( m_data->trackerMode == AlwaysOn ); - } + if (m_data->trackerMode != mode) + { + m_data->trackerMode = mode; + setMouseTracking(m_data->trackerMode == AlwaysOn); + } } /*! @@ -331,7 +329,7 @@ void QwtPicker::setTrackerMode( DisplayMode mode ) */ QwtPicker::DisplayMode QwtPicker::trackerMode() const { - return m_data->trackerMode; + return m_data->trackerMode; } /*! @@ -348,9 +346,9 @@ QwtPicker::DisplayMode QwtPicker::trackerMode() const \param mode Resize mode \sa resizeMode(), ResizeMode */ -void QwtPicker::setResizeMode( ResizeMode mode ) +void QwtPicker::setResizeMode(ResizeMode mode) { - m_data->resizeMode = mode; + m_data->resizeMode = mode; } /*! @@ -360,7 +358,7 @@ void QwtPicker::setResizeMode( ResizeMode mode ) QwtPicker::ResizeMode QwtPicker::resizeMode() const { - return m_data->resizeMode; + return m_data->resizeMode; } /*! @@ -372,23 +370,23 @@ QwtPicker::ResizeMode QwtPicker::resizeMode() const \param enabled true or false \sa isEnabled(), eventFilter() */ -void QwtPicker::setEnabled( bool enabled ) +void QwtPicker::setEnabled(bool enabled) { - if ( m_data->enabled != enabled ) + if (m_data->enabled != enabled) + { + m_data->enabled = enabled; + + QWidget *w = parentWidget(); + if (w) { - m_data->enabled = enabled; - - QWidget* w = parentWidget(); - if ( w ) - { - if ( enabled ) - w->installEventFilter( this ); - else - w->removeEventFilter( this ); - } - - updateDisplay(); + if (enabled) + w->installEventFilter(this); + else + w->removeEventFilter(this); } + + updateDisplay(); + } } /*! @@ -398,7 +396,7 @@ void QwtPicker::setEnabled( bool enabled ) bool QwtPicker::isEnabled() const { - return m_data->enabled; + return m_data->enabled; } /*! @@ -407,13 +405,13 @@ bool QwtPicker::isEnabled() const \param font Tracker font \sa trackerFont(), setTrackerMode(), setTrackerPen() */ -void QwtPicker::setTrackerFont( const QFont& font ) +void QwtPicker::setTrackerFont(const QFont &font) { - if ( font != m_data->trackerFont ) - { - m_data->trackerFont = font; - updateDisplay(); - } + if (font != m_data->trackerFont) + { + m_data->trackerFont = font; + updateDisplay(); + } } /*! @@ -423,7 +421,7 @@ void QwtPicker::setTrackerFont( const QFont& font ) QFont QwtPicker::trackerFont() const { - return m_data->trackerFont; + return m_data->trackerFont; } /*! @@ -432,13 +430,13 @@ QFont QwtPicker::trackerFont() const \param pen Tracker pen \sa trackerPen(), setTrackerMode(), setTrackerFont() */ -void QwtPicker::setTrackerPen( const QPen& pen ) +void QwtPicker::setTrackerPen(const QPen &pen) { - if ( pen != m_data->trackerPen ) - { - m_data->trackerPen = pen; - updateDisplay(); - } + if (pen != m_data->trackerPen) + { + m_data->trackerPen = pen; + updateDisplay(); + } } /*! @@ -447,7 +445,7 @@ void QwtPicker::setTrackerPen( const QPen& pen ) */ QPen QwtPicker::trackerPen() const { - return m_data->trackerPen; + return m_data->trackerPen; } /*! @@ -456,13 +454,13 @@ QPen QwtPicker::trackerPen() const \param pen Rubber band pen \sa rubberBandPen(), setRubberBand() */ -void QwtPicker::setRubberBandPen( const QPen& pen ) +void QwtPicker::setRubberBandPen(const QPen &pen) { - if ( pen != m_data->rubberBandPen ) - { - m_data->rubberBandPen = pen; - updateDisplay(); - } + if (pen != m_data->rubberBandPen) + { + m_data->rubberBandPen = pen; + updateDisplay(); + } } /*! @@ -471,7 +469,7 @@ void QwtPicker::setRubberBandPen( const QPen& pen ) */ QPen QwtPicker::rubberBandPen() const { - return m_data->rubberBandPen; + return m_data->rubberBandPen; } /*! @@ -487,22 +485,22 @@ QPen QwtPicker::rubberBandPen() const \return Converted position as string */ -QwtText QwtPicker::trackerText( const QPoint& pos ) const +QwtText QwtPicker::trackerText(const QPoint &pos) const { - QString label; + QString label; - switch ( rubberBand() ) - { - case HLineRubberBand: - label = QString::number( pos.y() ); - break; - case VLineRubberBand: - label = QString::number( pos.x() ); - break; - default: - label = QString::number( pos.x() ) + ", " + QString::number( pos.y() ); - } - return label; + switch (rubberBand()) + { + case HLineRubberBand: + label = QString::number(pos.y()); + break; + case VLineRubberBand: + label = QString::number(pos.x()); + break; + default: + label = QString::number(pos.x()) + ", " + QString::number(pos.y()); + } + return label; } /*! @@ -513,7 +511,7 @@ QwtText QwtPicker::trackerText( const QPoint& pos ) const */ QRegion QwtPicker::trackerMask() const { - return trackerRect( m_data->trackerFont ); + return trackerRect(m_data->trackerFont); } /*! @@ -524,106 +522,97 @@ QRegion QwtPicker::trackerMask() const */ QRegion QwtPicker::rubberBandMask() const { - QRegion mask; + QRegion mask; - if ( !isActive() || rubberBand() == NoRubberBand || - rubberBandPen().style() == Qt::NoPen ) - { + if (!isActive() || rubberBand() == NoRubberBand + || rubberBandPen().style() == Qt::NoPen) + { + return mask; + } + + const QPolygon pa = adjustedPoints(m_data->pickedPoints); + + QwtPickerMachine::SelectionType selectionType = QwtPickerMachine::NoSelection; + + if (m_data->stateMachine) + selectionType = m_data->stateMachine->selectionType(); + + switch (selectionType) + { + case QwtPickerMachine::NoSelection: + case QwtPickerMachine::PointSelection: { + if (pa.count() < 1) return mask; - } - const QPolygon pa = adjustedPoints( m_data->pickedPoints ); + const QPoint pos = pa[0]; + const int pw = rubberBandPen().width(); - QwtPickerMachine::SelectionType selectionType = - QwtPickerMachine::NoSelection; - - if ( m_data->stateMachine ) - selectionType = m_data->stateMachine->selectionType(); - - switch ( selectionType ) - { - case QwtPickerMachine::NoSelection: - case QwtPickerMachine::PointSelection: - { - if ( pa.count() < 1 ) - return mask; - - const QPoint pos = pa[0]; - const int pw = rubberBandPen().width(); - - const QRect pRect = pickArea().boundingRect().toRect(); - switch ( rubberBand() ) - { - case VLineRubberBand: - { - mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), - pos.x(), pRect.bottom() ), pw ); - break; - } - case HLineRubberBand: - { - mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), - pRect.right(), pos.y() ), pw ); - break; - } - case CrossRubberBand: - { - mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), - pos.x(), pRect.bottom() ), pw ); - mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), - pRect.right(), pos.y() ), pw ); - break; - } - default: - break; - } - break; + const QRect pRect = pickArea().boundingRect().toRect(); + switch (rubberBand()) + { + case VLineRubberBand: { + mask += qwtMaskRegion( + QLine(pos.x(), pRect.top(), pos.x(), pRect.bottom()), pw); + break; } - case QwtPickerMachine::RectSelection: - { - if ( pa.count() < 2 ) - return mask; - - const int pw = rubberBandPen().width(); - - switch ( rubberBand() ) - { - case RectRubberBand: - { - const QRect r = QRect( pa.first(), pa.last() ); - mask = qwtMaskRegion( r.normalized(), pw ); - break; - } - case EllipseRubberBand: - { - const QRect r = QRect( pa.first(), pa.last() ); - mask += r.adjusted( -pw, -pw, pw, pw ); - break; - } - default: - break; - } - break; + case HLineRubberBand: { + mask += qwtMaskRegion( + QLine(pRect.left(), pos.y(), pRect.right(), pos.y()), pw); + break; } - case QwtPickerMachine::PolygonSelection: - { - const int pw = rubberBandPen().width(); - if ( pw <= 1 ) - { - // because of the join style we better - // return a mask for a pen width <= 1 only - - const int off = 2 * pw; - const QRect r = pa.boundingRect(); - mask += r.adjusted( -off, -off, off, off ); - } - break; + case CrossRubberBand: { + mask += qwtMaskRegion( + QLine(pos.x(), pRect.top(), pos.x(), pRect.bottom()), pw); + mask += qwtMaskRegion( + QLine(pRect.left(), pos.y(), pRect.right(), pos.y()), pw); + break; } default: - break; + break; + } + break; } + case QwtPickerMachine::RectSelection: { + if (pa.count() < 2) + return mask; - return mask; + const int pw = rubberBandPen().width(); + + switch (rubberBand()) + { + case RectRubberBand: { + const QRect r = QRect(pa.first(), pa.last()); + mask = qwtMaskRegion(r.normalized(), pw); + break; + } + case EllipseRubberBand: { + const QRect r = QRect(pa.first(), pa.last()); + mask += r.adjusted(-pw, -pw, pw, pw); + break; + } + default: + break; + } + break; + } + case QwtPickerMachine::PolygonSelection: { + const int pw = rubberBandPen().width(); + if (pw <= 1) + { + // because of the join style we better + // return a mask for a pen width <= 1 only + + const int off = 2 * pw; + const QRect r = pa.boundingRect(); + mask += r.adjusted(-off, -off, off, off); + } + break; + } + default: + break; + } + + return mask; } /*! @@ -634,92 +623,83 @@ QRegion QwtPicker::rubberBandMask() const \sa rubberBand(), RubberBand */ -void QwtPicker::drawRubberBand( QPainter* painter ) const +void QwtPicker::drawRubberBand(QPainter *painter) const { - if ( !isActive() || rubberBand() == NoRubberBand || - rubberBandPen().style() == Qt::NoPen ) - { + if (!isActive() || rubberBand() == NoRubberBand + || rubberBandPen().style() == Qt::NoPen) + { + return; + } + + const QPolygon pa = adjustedPoints(m_data->pickedPoints); + + QwtPickerMachine::SelectionType selectionType = QwtPickerMachine::NoSelection; + + if (m_data->stateMachine) + selectionType = m_data->stateMachine->selectionType(); + + switch (selectionType) + { + case QwtPickerMachine::NoSelection: + case QwtPickerMachine::PointSelection: { + if (pa.count() < 1) return; - } - const QPolygon pa = adjustedPoints( m_data->pickedPoints ); + const QPoint pos = pa[0]; - QwtPickerMachine::SelectionType selectionType = - QwtPickerMachine::NoSelection; - - if ( m_data->stateMachine ) - selectionType = m_data->stateMachine->selectionType(); - - switch ( selectionType ) - { - case QwtPickerMachine::NoSelection: - case QwtPickerMachine::PointSelection: - { - if ( pa.count() < 1 ) - return; - - const QPoint pos = pa[0]; - - const QRect pRect = pickArea().boundingRect().toRect(); - switch ( rubberBand() ) - { - case VLineRubberBand: - { - QwtPainter::drawLine( painter, pos.x(), - pRect.top(), pos.x(), pRect.bottom() ); - break; - } - case HLineRubberBand: - { - QwtPainter::drawLine( painter, pRect.left(), - pos.y(), pRect.right(), pos.y() ); - break; - } - case CrossRubberBand: - { - QwtPainter::drawLine( painter, pos.x(), - pRect.top(), pos.x(), pRect.bottom() ); - QwtPainter::drawLine( painter, pRect.left(), - pos.y(), pRect.right(), pos.y() ); - break; - } - default: - break; - } - break; + const QRect pRect = pickArea().boundingRect().toRect(); + switch (rubberBand()) + { + case VLineRubberBand: { + QwtPainter::drawLine(painter, pos.x(), pRect.top(), pos.x(), + pRect.bottom()); + break; } - case QwtPickerMachine::RectSelection: - { - if ( pa.count() < 2 ) - return; - - const QRect rect = QRect( pa.first(), pa.last() ).normalized(); - switch ( rubberBand() ) - { - case EllipseRubberBand: - { - QwtPainter::drawEllipse( painter, rect ); - break; - } - case RectRubberBand: - { - QwtPainter::drawRect( painter, rect ); - break; - } - default: - break; - } - break; + case HLineRubberBand: { + QwtPainter::drawLine(painter, pRect.left(), pos.y(), pRect.right(), + pos.y()); + break; } - case QwtPickerMachine::PolygonSelection: - { - if ( rubberBand() == PolygonRubberBand ) - painter->drawPolyline( pa ); - break; + case CrossRubberBand: { + QwtPainter::drawLine(painter, pos.x(), pRect.top(), pos.x(), + pRect.bottom()); + QwtPainter::drawLine(painter, pRect.left(), pos.y(), pRect.right(), + pos.y()); + break; } default: - break; + break; + } + break; } + case QwtPickerMachine::RectSelection: { + if (pa.count() < 2) + return; + + const QRect rect = QRect(pa.first(), pa.last()).normalized(); + switch (rubberBand()) + { + case EllipseRubberBand: { + QwtPainter::drawEllipse(painter, rect); + break; + } + case RectRubberBand: { + QwtPainter::drawRect(painter, rect); + break; + } + default: + break; + } + break; + } + case QwtPickerMachine::PolygonSelection: { + if (rubberBand() == PolygonRubberBand) + painter->drawPolyline(pa); + break; + } + default: + break; + } } /*! @@ -729,15 +709,15 @@ void QwtPicker::drawRubberBand( QPainter* painter ) const \sa trackerRect(), trackerText() */ -void QwtPicker::drawTracker( QPainter* painter ) const +void QwtPicker::drawTracker(QPainter *painter) const { - const QRect textRect = trackerRect( painter->font() ); - if ( !textRect.isEmpty() ) - { - const QwtText label = trackerText( m_data->trackerPosition ); - if ( !label.isEmpty() ) - label.draw( painter, textRect ); - } + const QRect textRect = trackerRect(painter->font()); + if (!textRect.isEmpty()) + { + const QwtText label = trackerText(m_data->trackerPosition); + if (!label.isEmpty()) + label.draw(painter, textRect); + } } /*! @@ -780,9 +760,9 @@ void QwtPicker::drawTracker( QPainter* painter ) const \param points Selected points \return Selected points unmodified */ -QPolygon QwtPicker::adjustedPoints( const QPolygon& points ) const +QPolygon QwtPicker::adjustedPoints(const QPolygon &points) const { - return points; + return points; } /*! @@ -791,13 +771,13 @@ QPolygon QwtPicker::adjustedPoints( const QPolygon& points ) const */ QPolygon QwtPicker::selection() const { - return adjustedPoints( m_data->pickedPoints ); + return adjustedPoints(m_data->pickedPoints); } //! \return Current position of the tracker QPoint QwtPicker::trackerPosition() const { - return m_data->trackerPosition; + return m_data->trackerPosition; } /*! @@ -809,66 +789,65 @@ QPoint QwtPicker::trackerPosition() const \sa trackerPosition() */ -QRect QwtPicker::trackerRect( const QFont& font ) const +QRect QwtPicker::trackerRect(const QFont &font) const { - if ( trackerMode() == AlwaysOff || - ( trackerMode() == ActiveOnly && !isActive() ) ) - { - return QRect(); - } + if (trackerMode() == AlwaysOff + || (trackerMode() == ActiveOnly && !isActive())) + { + return QRect(); + } - if ( m_data->trackerPosition.x() < 0 || m_data->trackerPosition.y() < 0 ) - return QRect(); + if (m_data->trackerPosition.x() < 0 || m_data->trackerPosition.y() < 0) + return QRect(); - QwtText text = trackerText( m_data->trackerPosition ); - if ( text.isEmpty() ) - return QRect(); + QwtText text = trackerText(m_data->trackerPosition); + if (text.isEmpty()) + return QRect(); - const QSizeF textSize = text.textSize( font ); - QRect textRect( 0, 0, qwtCeil( textSize.width() ), qwtCeil( textSize.height() ) ); + const QSizeF textSize = text.textSize(font); + QRect textRect(0, 0, qwtCeil(textSize.width()), qwtCeil(textSize.height())); - const QPoint& pos = m_data->trackerPosition; + const QPoint &pos = m_data->trackerPosition; - int alignment = 0; - if ( isActive() && m_data->pickedPoints.count() > 1 - && rubberBand() != NoRubberBand ) - { - const QPoint last = - m_data->pickedPoints[ m_data->pickedPoints.count() - 2 ]; + int alignment = 0; + if (isActive() && m_data->pickedPoints.count() > 1 + && rubberBand() != NoRubberBand) + { + const QPoint last = m_data->pickedPoints[m_data->pickedPoints.count() - 2]; - alignment |= ( pos.x() >= last.x() ) ? Qt::AlignRight : Qt::AlignLeft; - alignment |= ( pos.y() > last.y() ) ? Qt::AlignBottom : Qt::AlignTop; - } - else - alignment = Qt::AlignTop | Qt::AlignRight; + alignment |= (pos.x() >= last.x()) ? Qt::AlignRight : Qt::AlignLeft; + alignment |= (pos.y() > last.y()) ? Qt::AlignBottom : Qt::AlignTop; + } + else + alignment = Qt::AlignTop | Qt::AlignRight; - const int margin = 5; + const int margin = 5; - int x = pos.x(); - if ( alignment & Qt::AlignLeft ) - x -= textRect.width() + margin; - else if ( alignment & Qt::AlignRight ) - x += margin; + int x = pos.x(); + if (alignment & Qt::AlignLeft) + x -= textRect.width() + margin; + else if (alignment & Qt::AlignRight) + x += margin; - int y = pos.y(); - if ( alignment & Qt::AlignBottom ) - y += margin; - else if ( alignment & Qt::AlignTop ) - y -= textRect.height() + margin; + int y = pos.y(); + if (alignment & Qt::AlignBottom) + y += margin; + else if (alignment & Qt::AlignTop) + y -= textRect.height() + margin; - textRect.moveTopLeft( QPoint( x, y ) ); + textRect.moveTopLeft(QPoint(x, y)); - const QRect pickRect = pickArea().boundingRect().toRect(); + const QRect pickRect = pickArea().boundingRect().toRect(); - int right = qMin( textRect.right(), pickRect.right() - margin ); - int bottom = qMin( textRect.bottom(), pickRect.bottom() - margin ); - textRect.moveBottomRight( QPoint( right, bottom ) ); + int right = qMin(textRect.right(), pickRect.right() - margin); + int bottom = qMin(textRect.bottom(), pickRect.bottom() - margin); + textRect.moveBottomRight(QPoint(right, bottom)); - int left = qMax( textRect.left(), pickRect.left() + margin ); - int top = qMax( textRect.top(), pickRect.top() + margin ); - textRect.moveTopLeft( QPoint( left, top ) ); + int left = qMax(textRect.left(), pickRect.left() + margin); + int top = qMax(textRect.top(), pickRect.top() + margin); + textRect.moveTopLeft(QPoint(left, top)); - return textRect; + return textRect; } /*! @@ -890,84 +869,75 @@ QRect QwtPicker::trackerRect( const QFont& font ) const widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent(), QObject::installEventFilter(), QObject::event() */ -bool QwtPicker::eventFilter( QObject* object, QEvent* event ) +bool QwtPicker::eventFilter(QObject *object, QEvent *event) { - if ( object && object == parentWidget() ) + if (object && object == parentWidget()) + { + switch (event->type()) { - switch ( event->type() ) - { - case QEvent::Resize: - { - const QResizeEvent* re = static_cast< QResizeEvent* >( event ); + case QEvent::Resize: { + const QResizeEvent *re = static_cast(event); - /* - Adding/deleting additional event filters inside of an event filter - is not safe dues to the implementation in Qt ( changing a list while iterating ). - So we create the overlays in a way, that they don't install en event filter - ( parent set to NULL ) and do the resizing here. - */ - if ( m_data->trackerOverlay ) - m_data->trackerOverlay->resize( re->size() ); + /* + Adding/deleting additional event filters inside of an event filter + is not safe dues to the implementation in Qt ( changing a list while + iterating ). So we create the overlays in a way, that they don't + install en event filter ( parent set to NULL ) and do the resizing + here. + */ + if (m_data->trackerOverlay) + m_data->trackerOverlay->resize(re->size()); - if ( m_data->rubberBandOverlay ) - m_data->rubberBandOverlay->resize( re->size() ); + if (m_data->rubberBandOverlay) + m_data->rubberBandOverlay->resize(re->size()); - if ( m_data->resizeMode == Stretch ) - stretchSelection( re->oldSize(), re->size() ); + if (m_data->resizeMode == Stretch) + stretchSelection(re->oldSize(), re->size()); - updateDisplay(); - break; - } - case QEvent::Enter: - { - widgetEnterEvent( event ); - break; - } - case QEvent::Leave: - { - widgetLeaveEvent( event ); - break; - } - case QEvent::MouseButtonPress: - { - widgetMousePressEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseButtonRelease: - { - widgetMouseReleaseEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseButtonDblClick: - { - widgetMouseDoubleClickEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::MouseMove: - { - widgetMouseMoveEvent( static_cast< QMouseEvent* >( event ) ); - break; - } - case QEvent::KeyPress: - { - widgetKeyPressEvent( static_cast< QKeyEvent* >( event ) ); - break; - } - case QEvent::KeyRelease: - { - widgetKeyReleaseEvent( static_cast< QKeyEvent* >( event ) ); - break; - } - case QEvent::Wheel: - { - widgetWheelEvent( static_cast< QWheelEvent* >( event ) ); - break; - } - default: - break; - } + updateDisplay(); + break; + } + case QEvent::Enter: { + widgetEnterEvent(event); + break; + } + case QEvent::Leave: { + widgetLeaveEvent(event); + break; + } + case QEvent::MouseButtonPress: { + widgetMousePressEvent(static_cast(event)); + break; + } + case QEvent::MouseButtonRelease: { + widgetMouseReleaseEvent(static_cast(event)); + break; + } + case QEvent::MouseButtonDblClick: { + widgetMouseDoubleClickEvent(static_cast(event)); + break; + } + case QEvent::MouseMove: { + widgetMouseMoveEvent(static_cast(event)); + break; + } + case QEvent::KeyPress: { + widgetKeyPressEvent(static_cast(event)); + break; + } + case QEvent::KeyRelease: { + widgetKeyReleaseEvent(static_cast(event)); + break; + } + case QEvent::Wheel: { + widgetWheelEvent(static_cast(event)); + break; + } + default: + break; } - return false; + } + return false; } /*! @@ -979,9 +949,9 @@ bool QwtPicker::eventFilter( QObject* object, QEvent* event ) widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetMousePressEvent( QMouseEvent* mouseEvent ) +void QwtPicker::widgetMousePressEvent(QMouseEvent *mouseEvent) { - transition( mouseEvent ); + transition(mouseEvent); } /*! @@ -993,17 +963,17 @@ void QwtPicker::widgetMousePressEvent( QMouseEvent* mouseEvent ) widgetMouseDoubleClickEvent(), widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetMouseMoveEvent( QMouseEvent* mouseEvent ) +void QwtPicker::widgetMouseMoveEvent(QMouseEvent *mouseEvent) { - if ( pickArea().contains( mouseEvent->pos() ) ) - m_data->trackerPosition = mouseEvent->pos(); - else - m_data->trackerPosition = QPoint( -1, -1 ); + if (pickArea().contains(mouseEvent->pos())) + m_data->trackerPosition = mouseEvent->pos(); + else + m_data->trackerPosition = QPoint(-1, -1); - if ( !isActive() ) - updateDisplay(); + if (!isActive()) + updateDisplay(); - transition( mouseEvent ); + transition(mouseEvent); } /*! @@ -1015,9 +985,9 @@ void QwtPicker::widgetMouseMoveEvent( QMouseEvent* mouseEvent ) widgetMouseDoubleClickEvent(), widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetEnterEvent( QEvent* event ) +void QwtPicker::widgetEnterEvent(QEvent *event) { - transition( event ); + transition(event); } /*! @@ -1029,13 +999,13 @@ void QwtPicker::widgetEnterEvent( QEvent* event ) widgetMouseDoubleClickEvent(), widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetLeaveEvent( QEvent* event ) +void QwtPicker::widgetLeaveEvent(QEvent *event) { - transition( event ); + transition(event); - m_data->trackerPosition = QPoint( -1, -1 ); - if ( !isActive() ) - updateDisplay(); + m_data->trackerPosition = QPoint(-1, -1); + if (!isActive()) + updateDisplay(); } /*! @@ -1047,9 +1017,9 @@ void QwtPicker::widgetLeaveEvent( QEvent* event ) widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetMouseReleaseEvent( QMouseEvent* mouseEvent ) +void QwtPicker::widgetMouseReleaseEvent(QMouseEvent *mouseEvent) { - transition( mouseEvent ); + transition(mouseEvent); } /*! @@ -1061,12 +1031,11 @@ void QwtPicker::widgetMouseReleaseEvent( QMouseEvent* mouseEvent ) widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetMouseDoubleClickEvent( QMouseEvent* mouseEvent ) +void QwtPicker::widgetMouseDoubleClickEvent(QMouseEvent *mouseEvent) { - transition( mouseEvent ); + transition(mouseEvent); } - /*! Handle a wheel event for the observed widget. @@ -1078,21 +1047,21 @@ void QwtPicker::widgetMouseDoubleClickEvent( QMouseEvent* mouseEvent ) widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() */ -void QwtPicker::widgetWheelEvent( QWheelEvent* wheelEvent ) +void QwtPicker::widgetWheelEvent(QWheelEvent *wheelEvent) { #if QT_VERSION < 0x050e00 - const QPoint wheelPos = wheelEvent->pos(); + const QPoint wheelPos = wheelEvent->pos(); #else - const QPoint wheelPos = wheelEvent->position().toPoint(); + const QPoint wheelPos = wheelEvent->position().toPoint(); #endif - if ( pickArea().contains( wheelPos ) ) - m_data->trackerPosition = wheelPos; - else - m_data->trackerPosition = QPoint( -1, -1 ); + if (pickArea().contains(wheelPos)) + m_data->trackerPosition = wheelPos; + else + m_data->trackerPosition = QPoint(-1, -1); - updateDisplay(); + updateDisplay(); - transition( wheelEvent ); + transition(wheelEvent); } /*! @@ -1109,45 +1078,45 @@ void QwtPicker::widgetWheelEvent( QWheelEvent* wheelEvent ) widgetWheelEvent(), widgetKeyReleaseEvent(), stateMachine(), QwtEventPattern::KeyPatternCode */ -void QwtPicker::widgetKeyPressEvent( QKeyEvent* keyEvent ) +void QwtPicker::widgetKeyPressEvent(QKeyEvent *keyEvent) { - int dx = 0; - int dy = 0; + int dx = 0; + int dy = 0; - int offset = 1; - if ( keyEvent->isAutoRepeat() ) - offset = 5; + int offset = 1; + if (keyEvent->isAutoRepeat()) + offset = 5; - if ( keyMatch( KeyLeft, keyEvent ) ) - dx = -offset; - else if ( keyMatch( KeyRight, keyEvent ) ) - dx = offset; - else if ( keyMatch( KeyUp, keyEvent ) ) - dy = -offset; - else if ( keyMatch( KeyDown, keyEvent ) ) - dy = offset; - else if ( keyMatch( KeyAbort, keyEvent ) ) - { - reset(); - } - else - transition( keyEvent ); + if (keyMatch(KeyLeft, keyEvent)) + dx = -offset; + else if (keyMatch(KeyRight, keyEvent)) + dx = offset; + else if (keyMatch(KeyUp, keyEvent)) + dy = -offset; + else if (keyMatch(KeyDown, keyEvent)) + dy = offset; + else if (keyMatch(KeyAbort, keyEvent)) + { + reset(); + } + else + transition(keyEvent); - if ( dx != 0 || dy != 0 ) - { - const QRect rect = pickArea().boundingRect().toRect(); - const QPoint pos = parentWidget()->mapFromGlobal( QCursor::pos() ); + if (dx != 0 || dy != 0) + { + const QRect rect = pickArea().boundingRect().toRect(); + const QPoint pos = parentWidget()->mapFromGlobal(QCursor::pos()); - int x = pos.x() + dx; - x = qMax( rect.left(), x ); - x = qMin( rect.right(), x ); + int x = pos.x() + dx; + x = qMax(rect.left(), x); + x = qMin(rect.right(), x); - int y = pos.y() + dy; - y = qMax( rect.top(), y ); - y = qMin( rect.bottom(), y ); + int y = pos.y() + dy; + y = qMax(rect.top(), y); + y = qMin(rect.bottom(), y); - QCursor::setPos( parentWidget()->mapToGlobal( QPoint( x, y ) ) ); - } + QCursor::setPos(parentWidget()->mapToGlobal(QPoint(x, y))); + } } /*! @@ -1161,9 +1130,9 @@ void QwtPicker::widgetKeyPressEvent( QKeyEvent* keyEvent ) widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent(), stateMachine() */ -void QwtPicker::widgetKeyReleaseEvent( QKeyEvent* keyEvent ) +void QwtPicker::widgetKeyReleaseEvent(QKeyEvent *keyEvent) { - transition( keyEvent ); + transition(keyEvent); } /*! @@ -1173,62 +1142,55 @@ void QwtPicker::widgetKeyReleaseEvent( QKeyEvent* keyEvent ) \param event Event */ -void QwtPicker::transition( const QEvent* event ) +void QwtPicker::transition(const QEvent *event) { - if ( !m_data->stateMachine ) - return; + if (!m_data->stateMachine) + return; - const QList< QwtPickerMachine::Command > commandList = - m_data->stateMachine->transition( *this, event ); + const QList commandList + = m_data->stateMachine->transition(*this, event); - QPoint pos; - switch ( event->type() ) - { - case QEvent::MouseButtonDblClick: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - { - const QMouseEvent* me = - static_cast< const QMouseEvent* >( event ); - pos = me->pos(); - break; - } - default: - pos = parentWidget()->mapFromGlobal( QCursor::pos() ); + QPoint pos; + switch (event->type()) + { + case QEvent::MouseButtonDblClick: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: { + const QMouseEvent *me = static_cast(event); + pos = me->pos(); + break; } + default: + pos = parentWidget()->mapFromGlobal(QCursor::pos()); + } - for ( int i = 0; i < commandList.count(); i++ ) + for (int i = 0; i < commandList.count(); i++) + { + switch (commandList[i]) { - switch ( commandList[i] ) - { - case QwtPickerMachine::Begin: - { - begin(); - break; - } - case QwtPickerMachine::Append: - { - append( pos ); - break; - } - case QwtPickerMachine::Move: - { - move( pos ); - break; - } - case QwtPickerMachine::Remove: - { - remove(); - break; - } - case QwtPickerMachine::End: - { - end(); - break; - } - } + case QwtPickerMachine::Begin: { + begin(); + break; + } + case QwtPickerMachine::Append: { + append(pos); + break; + } + case QwtPickerMachine::Move: { + move(pos); + break; + } + case QwtPickerMachine::Remove: { + remove(); + break; + } + case QwtPickerMachine::End: { + end(); + break; + } } + } } /*! @@ -1238,25 +1200,25 @@ void QwtPicker::transition( const QEvent* event ) */ void QwtPicker::begin() { - if ( m_data->isActive ) - return; + if (m_data->isActive) + return; - m_data->pickedPoints.clear(); - m_data->isActive = true; - Q_EMIT activated( true ); + m_data->pickedPoints.clear(); + m_data->isActive = true; + Q_EMIT activated(true); - if ( trackerMode() != AlwaysOff ) + if (trackerMode() != AlwaysOff) + { + if (m_data->trackerPosition.x() < 0 || m_data->trackerPosition.y() < 0) { - if ( m_data->trackerPosition.x() < 0 || m_data->trackerPosition.y() < 0 ) - { - QWidget* w = parentWidget(); - if ( w ) - m_data->trackerPosition = w->mapFromGlobal( QCursor::pos() ); - } + QWidget *w = parentWidget(); + if (w) + m_data->trackerPosition = w->mapFromGlobal(QCursor::pos()); } + } - updateDisplay(); - setMouseTracking( true ); + updateDisplay(); + setMouseTracking(true); } /*! @@ -1269,32 +1231,32 @@ void QwtPicker::begin() \return true if the selection is accepted, false otherwise \sa isActive(), begin(), append(), move(), selected(), accept() */ -bool QwtPicker::end( bool ok ) +bool QwtPicker::end(bool ok) { - if ( m_data->isActive ) - { - setMouseTracking( false ); + if (m_data->isActive) + { + setMouseTracking(false); - m_data->isActive = false; - Q_EMIT activated( false ); + m_data->isActive = false; + Q_EMIT activated(false); - if ( trackerMode() == ActiveOnly ) - m_data->trackerPosition = QPoint( -1, -1 ); + if (trackerMode() == ActiveOnly) + m_data->trackerPosition = QPoint(-1, -1); - if ( ok ) - ok = accept( m_data->pickedPoints ); + if (ok) + ok = accept(m_data->pickedPoints); - if ( ok ) - Q_EMIT selected( m_data->pickedPoints ); - else - m_data->pickedPoints.clear(); - - updateDisplay(); - } + if (ok) + Q_EMIT selected(m_data->pickedPoints); else - ok = false; + m_data->pickedPoints.clear(); - return ok; + updateDisplay(); + } + else + ok = false; + + return ok; } /*! @@ -1302,11 +1264,11 @@ bool QwtPicker::end( bool ok ) */ void QwtPicker::reset() { - if ( m_data->stateMachine ) - m_data->stateMachine->reset(); + if (m_data->stateMachine) + m_data->stateMachine->reset(); - if ( isActive() ) - end( false ); + if (isActive()) + end(false); } /*! @@ -1317,15 +1279,15 @@ void QwtPicker::reset() \sa isActive(), begin(), end(), move(), appended() */ -void QwtPicker::append( const QPoint& pos ) +void QwtPicker::append(const QPoint &pos) { - if ( m_data->isActive ) - { - m_data->pickedPoints += pos; + if (m_data->isActive) + { + m_data->pickedPoints += pos; - updateDisplay(); - Q_EMIT appended( pos ); - } + updateDisplay(); + Q_EMIT appended(pos); + } } /*! @@ -1335,19 +1297,19 @@ void QwtPicker::append( const QPoint& pos ) \param pos New position \sa isActive(), begin(), end(), append() */ -void QwtPicker::move( const QPoint& pos ) +void QwtPicker::move(const QPoint &pos) { - if ( m_data->isActive && !m_data->pickedPoints.isEmpty() ) + if (m_data->isActive && !m_data->pickedPoints.isEmpty()) + { + QPoint &point = m_data->pickedPoints.last(); + if (point != pos) { - QPoint& point = m_data->pickedPoints.last(); - if ( point != pos ) - { - point = pos; + point = pos; - updateDisplay(); - Q_EMIT moved( pos ); - } + updateDisplay(); + Q_EMIT moved(pos); } + } } /*! @@ -1358,18 +1320,18 @@ void QwtPicker::move( const QPoint& pos ) */ void QwtPicker::remove() { - if ( m_data->isActive && !m_data->pickedPoints.isEmpty() ) - { + if (m_data->isActive && !m_data->pickedPoints.isEmpty()) + { #if QT_VERSION >= 0x050100 - const QPoint pos = m_data->pickedPoints.takeLast(); + const QPoint pos = m_data->pickedPoints.takeLast(); #else - const QPoint pos = m_data->pickedPoints.last(); - m_data->pickedPoints.resize( m_data->pickedPoints.count() - 1 ); + const QPoint pos = m_data->pickedPoints.last(); + m_data->pickedPoints.resize(m_data->pickedPoints.count() - 1); #endif - updateDisplay(); - Q_EMIT removed( pos ); - } + updateDisplay(); + Q_EMIT removed(pos); + } } /*! @@ -1380,10 +1342,10 @@ void QwtPicker::remove() \param selection Selection to validate and fix up \return true, when accepted, false otherwise */ -bool QwtPicker::accept( QPolygon& selection ) const +bool QwtPicker::accept(QPolygon &selection) const { - Q_UNUSED( selection ); - return true; + Q_UNUSED(selection); + return true; } /*! @@ -1392,7 +1354,7 @@ bool QwtPicker::accept( QPolygon& selection ) const */ bool QwtPicker::isActive() const { - return m_data->isActive; + return m_data->isActive; } /*! @@ -1400,9 +1362,9 @@ bool QwtPicker::isActive() const is calculated from the pickedPoints() in adjustedPoints(). \return Picked points */ -const QPolygon& QwtPicker::pickedPoints() const +const QPolygon &QwtPicker::pickedPoints() const { - return m_data->pickedPoints; + return m_data->pickedPoints; } /*! @@ -1414,26 +1376,26 @@ const QPolygon& QwtPicker::pickedPoints() const \sa ResizeMode, setResizeMode(), resizeMode() */ -void QwtPicker::stretchSelection( const QSize& oldSize, const QSize& newSize ) +void QwtPicker::stretchSelection(const QSize &oldSize, const QSize &newSize) { - if ( oldSize.isEmpty() ) - { - // avoid division by zero. But scaling for small sizes also - // doesn't make much sense, because of rounding losses. TODO ... - return; - } + if (oldSize.isEmpty()) + { + // avoid division by zero. But scaling for small sizes also + // doesn't make much sense, because of rounding losses. TODO ... + return; + } - const double xRatio = double( newSize.width() ) / double( oldSize.width() ); - const double yRatio = double( newSize.height() ) / double( oldSize.height() ); + const double xRatio = double(newSize.width()) / double(oldSize.width()); + const double yRatio = double(newSize.height()) / double(oldSize.height()); - for ( int i = 0; i < m_data->pickedPoints.count(); i++ ) - { - QPoint& p = m_data->pickedPoints[i]; - p.setX( qRound( p.x() * xRatio ) ); - p.setY( qRound( p.y() * yRatio ) ); + for (int i = 0; i < m_data->pickedPoints.count(); i++) + { + QPoint &p = m_data->pickedPoints[i]; + p.setX(qRound(p.x() * xRatio)); + p.setY(qRound(p.y() * yRatio)); - Q_EMIT changed( m_data->pickedPoints ); - } + Q_EMIT changed(m_data->pickedPoints); + } } /*! @@ -1449,21 +1411,21 @@ void QwtPicker::stretchSelection( const QSize& oldSize, const QSize& newSize ) be restored. */ -void QwtPicker::setMouseTracking( bool enable ) +void QwtPicker::setMouseTracking(bool enable) { - QWidget* widget = parentWidget(); - if ( !widget ) - return; + QWidget *widget = parentWidget(); + if (!widget) + return; - if ( enable ) - { - m_data->mouseTracking = widget->hasMouseTracking(); - widget->setMouseTracking( true ); - } - else - { - widget->setMouseTracking( m_data->mouseTracking ); - } + if (enable) + { + m_data->mouseTracking = widget->hasMouseTracking(); + widget->setMouseTracking(true); + } + else + { + widget->setMouseTracking(m_data->mouseTracking); + } } /*! @@ -1473,122 +1435,123 @@ void QwtPicker::setMouseTracking( bool enable ) */ QPainterPath QwtPicker::pickArea() const { - QPainterPath path; + QPainterPath path; - const QWidget* widget = parentWidget(); - if ( widget ) - path.addRect( widget->contentsRect() ); + const QWidget *widget = parentWidget(); + if (widget) + path.addRect(widget->contentsRect()); - return path; + return path; } //! Update the state of rubber band and tracker label void QwtPicker::updateDisplay() { - QWidget* w = parentWidget(); + QWidget *w = parentWidget(); - bool showRubberband = false; - bool showTracker = false; + bool showRubberband = false; + bool showTracker = false; - if ( w && w->isVisible() && m_data->enabled ) + if (w && w->isVisible() && m_data->enabled) + { + if (rubberBand() != NoRubberBand && isActive() + && rubberBandPen().style() != Qt::NoPen) { - if ( rubberBand() != NoRubberBand && isActive() && - rubberBandPen().style() != Qt::NoPen ) - { - showRubberband = true; - } - - if ( trackerMode() == AlwaysOn || - ( trackerMode() == ActiveOnly && isActive() ) ) - { - if ( trackerPen() != Qt::NoPen - && !trackerRect( QFont() ).isEmpty() ) - { - showTracker = true; - } - } + showRubberband = true; } - QPointer< QwtPickerPrivate::Rubberband >& rw = m_data->rubberBandOverlay; - if ( showRubberband ) + if (trackerMode() == AlwaysOn + || (trackerMode() == ActiveOnly && isActive())) { - if ( rw.isNull() ) - { - rw = new QwtPickerPrivate::Rubberband( this, NULL ); // NULL -> no extra event filter - rw->setObjectName( "PickerRubberBand" ); - rw->setParent( w ); - rw->resize( w->size() ); - } + if (trackerPen() != Qt::NoPen && !trackerRect(QFont()).isEmpty()) + { + showTracker = true; + } + } + } - if ( m_data->rubberBand <= RectRubberBand ) - rw->setMaskMode( QwtWidgetOverlay::MaskHint ); - else - rw->setMaskMode( QwtWidgetOverlay::AlphaMask ); + QPointer &rw = m_data->rubberBandOverlay; + if (showRubberband) + { + if (rw.isNull()) + { + rw = new QwtPickerPrivate::Rubberband( + this, NULL); // NULL -> no extra event filter + rw->setObjectName("PickerRubberBand"); + rw->setParent(w); + rw->resize(w->size()); + } - rw->updateOverlay(); + if (m_data->rubberBand <= RectRubberBand) + rw->setMaskMode(QwtWidgetOverlay::MaskHint); + else + rw->setMaskMode(QwtWidgetOverlay::AlphaMask); + + rw->updateOverlay(); + } + else + { + if (m_data->openGL) + { + // Qt 4.8 crashes for a delete + if (!rw.isNull()) + { + rw->hide(); + rw->deleteLater(); + rw = NULL; + } } else { - if ( m_data->openGL ) - { - // Qt 4.8 crashes for a delete - if ( !rw.isNull() ) - { - rw->hide(); - rw->deleteLater(); - rw = NULL; - } - } - else - { - delete rw; - } + delete rw; } + } - QPointer< QwtPickerPrivate::Tracker >& tw = m_data->trackerOverlay; - if ( showTracker ) + QPointer &tw = m_data->trackerOverlay; + if (showTracker) + { + if (tw.isNull()) { - if ( tw.isNull() ) - { - tw = new QwtPickerPrivate::Tracker( this, NULL ); // NULL -> no extra event filter - tw->setObjectName( "PickerTracker" ); - tw->setParent( w ); - tw->resize( w->size() ); - } - tw->setFont( m_data->trackerFont ); - tw->updateOverlay(); + tw = new QwtPickerPrivate::Tracker(this, + NULL); // NULL -> no extra event filter + tw->setObjectName("PickerTracker"); + tw->setParent(w); + tw->resize(w->size()); + } + tw->setFont(m_data->trackerFont); + tw->updateOverlay(); + } + else + { + if (m_data->openGL) + { + // Qt 4.8 crashes for a delete + if (!tw.isNull()) + { + tw->hide(); + tw->deleteLater(); + tw = NULL; + } } else { - if ( m_data->openGL ) - { - // Qt 4.8 crashes for a delete - if ( !tw.isNull() ) - { - tw->hide(); - tw->deleteLater(); - tw = NULL; - } - } - else - { - delete tw; - } + delete tw; } + } } //! \return Overlay displaying the rubber band -const QwtWidgetOverlay* QwtPicker::rubberBandOverlay() const +const QwtWidgetOverlay *QwtPicker::rubberBandOverlay() const { - return m_data->rubberBandOverlay; + return m_data->rubberBandOverlay; } //! \return Overlay displaying the tracker text -const QwtWidgetOverlay* QwtPicker::trackerOverlay() const +const QwtWidgetOverlay *QwtPicker::trackerOverlay() const { - return m_data->trackerOverlay; + return m_data->trackerOverlay; } #if QWT_MOC_INCLUDE -#include "moc_qwt_picker.cpp" +# include "moc_qwt_picker.cpp" #endif diff --git a/libs/qwt/src/qwt_picker.h b/libs/qwt/src/qwt_picker.h index 84e67f94..508b24ca 100644 --- a/libs/qwt/src/qwt_picker.h +++ b/libs/qwt/src/qwt_picker.h @@ -102,237 +102,235 @@ class QPolygon; class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern { - Q_OBJECT + Q_OBJECT - Q_ENUMS( RubberBand DisplayMode ResizeMode ) + Q_ENUMS(RubberBand DisplayMode ResizeMode) - Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled ) - Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode ) + Q_PROPERTY(bool isEnabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) - Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode ) - Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen ) - Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont ) + Q_PROPERTY(DisplayMode trackerMode READ trackerMode WRITE setTrackerMode) + Q_PROPERTY(QPen trackerPen READ trackerPen WRITE setTrackerPen) + Q_PROPERTY(QFont trackerFont READ trackerFont WRITE setTrackerFont) - Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand ) - Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen ) + Q_PROPERTY(RubberBand rubberBand READ rubberBand WRITE setRubberBand) + Q_PROPERTY(QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen) - public: - /*! - Rubber band style +public: + /*! + Rubber band style - The default value is QwtPicker::NoRubberBand. - \sa setRubberBand(), rubberBand() - */ + The default value is QwtPicker::NoRubberBand. + \sa setRubberBand(), rubberBand() + */ - enum RubberBand - { - //! No rubberband. - NoRubberBand = 0, + enum RubberBand + { + //! No rubberband. + NoRubberBand = 0, - //! A horizontal line ( only for QwtPickerMachine::PointSelection ) - HLineRubberBand, + //! A horizontal line ( only for QwtPickerMachine::PointSelection ) + HLineRubberBand, - //! A vertical line ( only for QwtPickerMachine::PointSelection ) - VLineRubberBand, + //! A vertical line ( only for QwtPickerMachine::PointSelection ) + VLineRubberBand, - //! A crosshair ( only for QwtPickerMachine::PointSelection ) - CrossRubberBand, + //! A crosshair ( only for QwtPickerMachine::PointSelection ) + CrossRubberBand, - //! A rectangle ( only for QwtPickerMachine::RectSelection ) - RectRubberBand, + //! A rectangle ( only for QwtPickerMachine::RectSelection ) + RectRubberBand, - //! An ellipse ( only for QwtPickerMachine::RectSelection ) - EllipseRubberBand, + //! An ellipse ( only for QwtPickerMachine::RectSelection ) + EllipseRubberBand, - //! A polygon ( only for QwtPickerMachine::PolygonSelection ) - PolygonRubberBand, - - /*! - Values >= UserRubberBand can be used to define additional - rubber bands. - */ - UserRubberBand = 100 - }; + //! A polygon ( only for QwtPickerMachine::PolygonSelection ) + PolygonRubberBand, /*! - \brief Display mode - \sa setTrackerMode(), trackerMode(), isActive() + Values >= UserRubberBand can be used to define additional + rubber bands. */ - enum DisplayMode - { - //! Display never - AlwaysOff, + UserRubberBand = 100 + }; - //! Display always - AlwaysOn, + /*! + \brief Display mode + \sa setTrackerMode(), trackerMode(), isActive() + */ + enum DisplayMode + { + //! Display never + AlwaysOff, - //! Display only when the selection is active - ActiveOnly - }; + //! Display always + AlwaysOn, - /*! - Controls what to do with the selected points of an active - selection when the observed widget is resized. + //! Display only when the selection is active + ActiveOnly + }; - The default value is QwtPicker::Stretch. - \sa setResizeMode() - */ + /*! + Controls what to do with the selected points of an active + selection when the observed widget is resized. - enum ResizeMode - { - //! All points are scaled according to the new size, - Stretch, + The default value is QwtPicker::Stretch. + \sa setResizeMode() + */ - //! All points remain unchanged. - KeepSize - }; + enum ResizeMode + { + //! All points are scaled according to the new size, + Stretch, - explicit QwtPicker( QWidget* parent ); - explicit QwtPicker( RubberBand rubberBand, - DisplayMode trackerMode, QWidget* ); + //! All points remain unchanged. + KeepSize + }; - virtual ~QwtPicker(); + explicit QwtPicker(QWidget *parent); + explicit QwtPicker(RubberBand rubberBand, DisplayMode trackerMode, QWidget *); - void setStateMachine( QwtPickerMachine* ); - const QwtPickerMachine* stateMachine() const; - QwtPickerMachine* stateMachine(); + virtual ~QwtPicker(); - void setRubberBand( RubberBand ); - RubberBand rubberBand() const; + void setStateMachine(QwtPickerMachine *); + const QwtPickerMachine *stateMachine() const; + QwtPickerMachine *stateMachine(); - void setTrackerMode( DisplayMode ); - DisplayMode trackerMode() const; + void setRubberBand(RubberBand); + RubberBand rubberBand() const; - void setResizeMode( ResizeMode ); - ResizeMode resizeMode() const; + void setTrackerMode(DisplayMode); + DisplayMode trackerMode() const; - void setRubberBandPen( const QPen& ); - QPen rubberBandPen() const; + void setResizeMode(ResizeMode); + ResizeMode resizeMode() const; - void setTrackerPen( const QPen& ); - QPen trackerPen() const; + void setRubberBandPen(const QPen &); + QPen rubberBandPen() const; - void setTrackerFont( const QFont& ); - QFont trackerFont() const; + void setTrackerPen(const QPen &); + QPen trackerPen() const; - bool isEnabled() const; - bool isActive() const; + void setTrackerFont(const QFont &); + QFont trackerFont() const; - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + bool isEnabled() const; + bool isActive() const; - QWidget* parentWidget(); - const QWidget* parentWidget() const; + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - virtual QPainterPath pickArea() const; + QWidget *parentWidget(); + const QWidget *parentWidget() const; - virtual void drawRubberBand( QPainter* ) const; - virtual void drawTracker( QPainter* ) const; + virtual QPainterPath pickArea() const; - virtual QRegion trackerMask() const; - virtual QRegion rubberBandMask() const; + virtual void drawRubberBand(QPainter *) const; + virtual void drawTracker(QPainter *) const; - virtual QwtText trackerText( const QPoint& pos ) const; - QPoint trackerPosition() const; - virtual QRect trackerRect( const QFont& ) const; + virtual QRegion trackerMask() const; + virtual QRegion rubberBandMask() const; - QPolygon selection() const; + virtual QwtText trackerText(const QPoint &pos) const; + QPoint trackerPosition() const; + virtual QRect trackerRect(const QFont &) const; - public Q_SLOTS: - void setEnabled( bool ); + QPolygon selection() const; - Q_SIGNALS: - /*! - A signal indicating, when the picker has been activated. - Together with setEnabled() it can be used to implement - selections with more than one picker. +public Q_SLOTS: + void setEnabled(bool); - \param on True, when the picker has been activated - */ - void activated( bool on ); +Q_SIGNALS: + /*! + A signal indicating, when the picker has been activated. + Together with setEnabled() it can be used to implement + selections with more than one picker. - /*! - A signal emitting the selected points, - at the end of a selection. + \param on True, when the picker has been activated + */ + void activated(bool on); - \param polygon Selected points - */ - void selected( const QPolygon& polygon ); + /*! + A signal emitting the selected points, + at the end of a selection. - /*! - A signal emitted when a point has been appended to the selection + \param polygon Selected points + */ + void selected(const QPolygon &polygon); - \param pos Position of the appended point. - \sa append(). moved() - */ - void appended( const QPoint& pos ); + /*! + A signal emitted when a point has been appended to the selection - /*! - A signal emitted whenever the last appended point of the - selection has been moved. + \param pos Position of the appended point. + \sa append(). moved() + */ + void appended(const QPoint &pos); - \param pos Position of the moved last point of the selection. - \sa move(), appended() - */ - void moved( const QPoint& pos ); + /*! + A signal emitted whenever the last appended point of the + selection has been moved. - /*! - A signal emitted whenever the last appended point of the - selection has been removed. + \param pos Position of the moved last point of the selection. + \sa move(), appended() + */ + void moved(const QPoint &pos); - \param pos Position of the point, that has been removed - \sa remove(), appended() - */ - void removed( const QPoint& pos ); - /*! - A signal emitted when the active selection has been changed. - This might happen when the observed widget is resized. + /*! + A signal emitted whenever the last appended point of the + selection has been removed. - \param selection Changed selection - \sa stretchSelection() - */ - void changed( const QPolygon& selection ); + \param pos Position of the point, that has been removed + \sa remove(), appended() + */ + void removed(const QPoint &pos); + /*! + A signal emitted when the active selection has been changed. + This might happen when the observed widget is resized. - protected: - virtual QPolygon adjustedPoints( const QPolygon& ) const; + \param selection Changed selection + \sa stretchSelection() + */ + void changed(const QPolygon &selection); - virtual void transition( const QEvent* ); +protected: + virtual QPolygon adjustedPoints(const QPolygon &) const; - virtual void begin(); - virtual void append( const QPoint& ); - virtual void move( const QPoint& ); - virtual void remove(); - virtual bool end( bool ok = true ); + virtual void transition(const QEvent *); - virtual bool accept( QPolygon& ) const; - virtual void reset(); + virtual void begin(); + virtual void append(const QPoint &); + virtual void move(const QPoint &); + virtual void remove(); + virtual bool end(bool ok = true); - virtual void widgetMousePressEvent( QMouseEvent* ); - virtual void widgetMouseReleaseEvent( QMouseEvent* ); - virtual void widgetMouseDoubleClickEvent( QMouseEvent* ); - virtual void widgetMouseMoveEvent( QMouseEvent* ); - virtual void widgetWheelEvent( QWheelEvent* ); - virtual void widgetKeyPressEvent( QKeyEvent* ); - virtual void widgetKeyReleaseEvent( QKeyEvent* ); - virtual void widgetEnterEvent( QEvent* ); - virtual void widgetLeaveEvent( QEvent* ); + virtual bool accept(QPolygon &) const; + virtual void reset(); - virtual void stretchSelection( - const QSize& oldSize, const QSize& newSize ); + virtual void widgetMousePressEvent(QMouseEvent *); + virtual void widgetMouseReleaseEvent(QMouseEvent *); + virtual void widgetMouseDoubleClickEvent(QMouseEvent *); + virtual void widgetMouseMoveEvent(QMouseEvent *); + virtual void widgetWheelEvent(QWheelEvent *); + virtual void widgetKeyPressEvent(QKeyEvent *); + virtual void widgetKeyReleaseEvent(QKeyEvent *); + virtual void widgetEnterEvent(QEvent *); + virtual void widgetLeaveEvent(QEvent *); - virtual void updateDisplay(); + virtual void stretchSelection(const QSize &oldSize, const QSize &newSize); - const QwtWidgetOverlay* rubberBandOverlay() const; - const QwtWidgetOverlay* trackerOverlay() const; + virtual void updateDisplay(); - const QPolygon& pickedPoints() const; + const QwtWidgetOverlay *rubberBandOverlay() const; + const QwtWidgetOverlay *trackerOverlay() const; - private: - void init( QWidget*, RubberBand rubberBand, DisplayMode trackerMode ); + const QPolygon &pickedPoints() const; - void setMouseTracking( bool ); +private: + void init(QWidget *, RubberBand rubberBand, DisplayMode trackerMode); - class PrivateData; - PrivateData* m_data; + void setMouseTracking(bool); + + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_picker_machine.cpp b/libs/qwt/src/qwt_picker_machine.cpp index 2baa84cd..af4311b4 100644 --- a/libs/qwt/src/qwt_picker_machine.cpp +++ b/libs/qwt/src/qwt_picker_machine.cpp @@ -13,530 +13,508 @@ #include //! Constructor -QwtPickerMachine::QwtPickerMachine( SelectionType type ) - : m_selectionType( type ) - , m_state( 0 ) +QwtPickerMachine::QwtPickerMachine(SelectionType type) + : m_selectionType(type) + , m_state(0) { } //! Destructor -QwtPickerMachine::~QwtPickerMachine() -{ -} +QwtPickerMachine::~QwtPickerMachine() {} //! Return the selection type QwtPickerMachine::SelectionType QwtPickerMachine::selectionType() const { - return m_selectionType; + return m_selectionType; } //! Return the current state int QwtPickerMachine::state() const { - return m_state; + return m_state; } //! Change the current state -void QwtPickerMachine::setState( int state ) +void QwtPickerMachine::setState(int state) { - m_state = state; + m_state = state; } //! Set the current state to 0. void QwtPickerMachine::reset() { - setState( 0 ); + setState(0); } //! Constructor -QwtPickerTrackerMachine::QwtPickerTrackerMachine(): - QwtPickerMachine( NoSelection ) +QwtPickerTrackerMachine::QwtPickerTrackerMachine() + : QwtPickerMachine(NoSelection) { } //! Transition -QList< QwtPickerMachine::Command > QwtPickerTrackerMachine::transition( - const QwtEventPattern&, const QEvent* e ) +QList +QwtPickerTrackerMachine::transition(const QwtEventPattern &, const QEvent *e) { - QList< QwtPickerMachine::Command > cmdList; + QList cmdList; - switch ( e->type() ) - { - case QEvent::Enter: - case QEvent::MouseMove: + switch (e->type()) + { + case QEvent::Enter: + case QEvent::MouseMove: { + if (state() == 0) + { + cmdList += Begin; + cmdList += Append; + setState(1); + } + else + { + cmdList += Move; + } + break; + } + case QEvent::Leave: { + cmdList += Remove; + cmdList += End; + setState(0); + } + default: + break; + } + + return cmdList; +} + +//! Constructor +QwtPickerClickPointMachine::QwtPickerClickPointMachine() + : QwtPickerMachine(PointSelection) +{ +} + +//! Transition +QList +QwtPickerClickPointMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *event) +{ + QList cmdList; + + switch (event->type()) + { + case QEvent::MouseButtonPress: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + cmdList += Begin; + cmdList += Append; + cmdList += End; + } + break; + } + case QEvent::KeyPress: { + const QKeyEvent *keyEvent = static_cast(event); + if (eventPattern.keyMatch(QwtEventPattern::KeySelect1, keyEvent)) + { + if (!keyEvent->isAutoRepeat()) { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += Move; - } - break; + cmdList += Begin; + cmdList += Append; + cmdList += End; } - case QEvent::Leave: + } + break; + } + default: + break; + } + + return cmdList; +} + +//! Constructor +QwtPickerDragPointMachine::QwtPickerDragPointMachine() + : QwtPickerMachine(PointSelection) +{ +} + +//! Transition +QList +QwtPickerDragPointMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *event) +{ + QList cmdList; + + switch (event->type()) + { + case QEvent::MouseButtonPress: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + if (state() == 0) { - cmdList += Remove; + cmdList += Begin; + cmdList += Append; + setState(1); + } + } + break; + } + case QEvent::MouseMove: + case QEvent::Wheel: { + if (state() != 0) + cmdList += Move; + break; + } + case QEvent::MouseButtonRelease: { + if (state() != 0) + { + cmdList += End; + setState(0); + } + break; + } + case QEvent::KeyPress: { + const QKeyEvent *keyEvent = static_cast(event); + if (eventPattern.keyMatch(QwtEventPattern::KeySelect1, keyEvent)) + { + if (!keyEvent->isAutoRepeat()) + { + if (state() == 0) + { + cmdList += Begin; + cmdList += Append; + setState(1); + } + else + { cmdList += End; - setState( 0 ); + setState(0); + } } - default: - break; + } + break; } + default: + break; + } - return cmdList; + return cmdList; } //! Constructor -QwtPickerClickPointMachine::QwtPickerClickPointMachine(): - QwtPickerMachine( PointSelection ) +QwtPickerClickRectMachine::QwtPickerClickRectMachine() + : QwtPickerMachine(RectSelection) { } //! Transition -QList< QwtPickerMachine::Command > QwtPickerClickPointMachine::transition( - const QwtEventPattern& eventPattern, const QEvent* event ) +QList +QwtPickerClickRectMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *event) { - QList< QwtPickerMachine::Command > cmdList; + QList cmdList; - switch ( event->type() ) - { - case QEvent::MouseButtonPress: + switch (event->type()) + { + case QEvent::MouseButtonPress: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + switch (state()) { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - cmdList += Begin; - cmdList += Append; - cmdList += End; - } + case 0: { + cmdList += Begin; + cmdList += Append; + setState(1); break; + } + case 1: { + // Uh, strange we missed the MouseButtonRelease + break; + } + default: { + cmdList += End; + setState(0); + } } - case QEvent::KeyPress: - { - const QKeyEvent* keyEvent = static_cast< const QKeyEvent* > ( event ); - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) ) - { - if ( !keyEvent->isAutoRepeat() ) - { - cmdList += Begin; - cmdList += Append; - cmdList += End; - } - } - break; - } - default: - break; + } + break; } + case QEvent::MouseMove: + case QEvent::Wheel: { + if (state() != 0) + cmdList += Move; + break; + } + case QEvent::MouseButtonRelease: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + if (state() == 1) + { + cmdList += Append; + setState(2); + } + } + break; + } + case QEvent::KeyPress: { + const QKeyEvent *keyEvent = static_cast(event); + if (eventPattern.keyMatch(QwtEventPattern::KeySelect1, keyEvent)) + { + if (!keyEvent->isAutoRepeat()) + { + if (state() == 0) + { + cmdList += Begin; + cmdList += Append; + setState(1); + } + else + { + if (state() == 1) + { + cmdList += Append; + setState(2); + } + else if (state() == 2) + { + cmdList += End; + setState(0); + } + } + } + } + break; + } + default: + break; + } - return cmdList; + return cmdList; } //! Constructor -QwtPickerDragPointMachine::QwtPickerDragPointMachine(): - QwtPickerMachine( PointSelection ) +QwtPickerDragRectMachine::QwtPickerDragRectMachine() + : QwtPickerMachine(RectSelection) { } //! Transition -QList< QwtPickerMachine::Command > QwtPickerDragPointMachine::transition( - const QwtEventPattern& eventPattern, const QEvent* event ) +QList +QwtPickerDragRectMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *event) { - QList< QwtPickerMachine::Command > cmdList; + QList cmdList; - switch ( event->type() ) - { - case QEvent::MouseButtonPress: + switch (event->type()) + { + case QEvent::MouseButtonPress: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + if (state() == 0) { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - } - break; + cmdList += Begin; + cmdList += Append; + cmdList += Append; + setState(2); } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - break; - } - case QEvent::MouseButtonRelease: - { - if ( state() != 0 ) - { - cmdList += End; - setState( 0 ); - } - break; - } - case QEvent::KeyPress: - { - const QKeyEvent* keyEvent = static_cast< const QKeyEvent* > ( event ); - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) ) - { - if ( !keyEvent->isAutoRepeat() ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - } - break; - } - default: - break; + } + break; } + case QEvent::MouseMove: + case QEvent::Wheel: { + if (state() != 0) + cmdList += Move; + break; + } + case QEvent::MouseButtonRelease: { + if (state() == 2) + { + cmdList += End; + setState(0); + } + break; + } + case QEvent::KeyPress: { + if (eventPattern.keyMatch(QwtEventPattern::KeySelect1, + static_cast(event))) + { + if (state() == 0) + { + cmdList += Begin; + cmdList += Append; + cmdList += Append; + setState(2); + } + else + { + cmdList += End; + setState(0); + } + } + break; + } + default: + break; + } - return cmdList; + return cmdList; } //! Constructor -QwtPickerClickRectMachine::QwtPickerClickRectMachine(): - QwtPickerMachine( RectSelection ) +QwtPickerPolygonMachine::QwtPickerPolygonMachine() + : QwtPickerMachine(PolygonSelection) { } //! Transition -QList< QwtPickerMachine::Command > QwtPickerClickRectMachine::transition( - const QwtEventPattern& eventPattern, const QEvent* event ) +QList +QwtPickerPolygonMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *event) { - QList< QwtPickerMachine::Command > cmdList; + QList cmdList; - switch ( event->type() ) - { - case QEvent::MouseButtonPress: + switch (event->type()) + { + case QEvent::MouseButtonPress: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + if (state() == 0) { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - switch ( state() ) - { - case 0: - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - break; - } - case 1: - { - // Uh, strange we missed the MouseButtonRelease - break; - } - default: - { - cmdList += End; - setState( 0 ); - } - } - } - break; + cmdList += Begin; + cmdList += Append; + cmdList += Append; + setState(1); } - case QEvent::MouseMove: - case QEvent::Wheel: + else { - if ( state() != 0 ) - cmdList += Move; - break; + cmdList += Append; } - case QEvent::MouseButtonRelease: + } + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect2, + static_cast(event))) + { + if (state() == 1) { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - if ( state() == 1 ) - { - cmdList += Append; - setState( 2 ); - } - } - break; + cmdList += End; + setState(0); } - case QEvent::KeyPress: - { - const QKeyEvent* keyEvent = static_cast< const QKeyEvent* > ( event ); - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) ) - { - if ( !keyEvent->isAutoRepeat() ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - else - { - if ( state() == 1 ) - { - cmdList += Append; - setState( 2 ); - } - else if ( state() == 2 ) - { - cmdList += End; - setState( 0 ); - } - } - } - } - break; - } - default: - break; + } + break; } + case QEvent::MouseMove: + case QEvent::Wheel: { + if (state() != 0) + cmdList += Move; + break; + } + case QEvent::KeyPress: { + const QKeyEvent *keyEvent = static_cast(event); + if (eventPattern.keyMatch(QwtEventPattern::KeySelect1, keyEvent)) + { + if (!keyEvent->isAutoRepeat()) + { + if (state() == 0) + { + cmdList += Begin; + cmdList += Append; + cmdList += Append; + setState(1); + } + else + { + cmdList += Append; + } + } + } + else if (eventPattern.keyMatch(QwtEventPattern::KeySelect2, keyEvent)) + { + if (!keyEvent->isAutoRepeat()) + { + if (state() == 1) + { + cmdList += End; + setState(0); + } + } + } + break; + } + default: + break; + } - return cmdList; + return cmdList; } //! Constructor -QwtPickerDragRectMachine::QwtPickerDragRectMachine(): - QwtPickerMachine( RectSelection ) +QwtPickerDragLineMachine::QwtPickerDragLineMachine() + : QwtPickerMachine(PolygonSelection) { } //! Transition -QList< QwtPickerMachine::Command > QwtPickerDragRectMachine::transition( - const QwtEventPattern& eventPattern, const QEvent* event ) +QList +QwtPickerDragLineMachine::transition(const QwtEventPattern &eventPattern, + const QEvent *event) { - QList< QwtPickerMachine::Command > cmdList; + QList cmdList; - switch ( event->type() ) - { - case QEvent::MouseButtonPress: + switch (event->type()) + { + case QEvent::MouseButtonPress: { + if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1, + static_cast(event))) + { + if (state() == 0) { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 2 ); - } - } - break; + cmdList += Begin; + cmdList += Append; + cmdList += Append; + setState(1); } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - break; - } - case QEvent::MouseButtonRelease: - { - if ( state() == 2 ) - { - cmdList += End; - setState( 0 ); - } - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, - static_cast< const QKeyEvent* > ( event ) ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 2 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - break; - } - default: - break; + } + break; } - - return cmdList; -} - -//! Constructor -QwtPickerPolygonMachine::QwtPickerPolygonMachine(): - QwtPickerMachine( PolygonSelection ) -{ -} - -//! Transition -QList< QwtPickerMachine::Command > QwtPickerPolygonMachine::transition( - const QwtEventPattern& eventPattern, const QEvent* event ) -{ - QList< QwtPickerMachine::Command > cmdList; - - switch ( event->type() ) - { - case QEvent::MouseButtonPress: + case QEvent::KeyPress: { + if (eventPattern.keyMatch(QwtEventPattern::KeySelect1, + static_cast(event))) + { + if (state() == 0) { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += Append; - } - } - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2, - static_cast< const QMouseEvent* >( event ) ) ) - { - if ( state() == 1 ) - { - cmdList += End; - setState( 0 ); - } - } - break; + cmdList += Begin; + cmdList += Append; + cmdList += Append; + setState(1); } - case QEvent::MouseMove: - case QEvent::Wheel: + else { - if ( state() != 0 ) - cmdList += Move; - break; + cmdList += End; + setState(0); } - case QEvent::KeyPress: - { - const QKeyEvent* keyEvent = static_cast< const QKeyEvent* > ( event ); - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) ) - { - if ( !keyEvent->isAutoRepeat() ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += Append; - } - } - } - else if ( eventPattern.keyMatch( QwtEventPattern::KeySelect2, keyEvent ) ) - { - if ( !keyEvent->isAutoRepeat() ) - { - if ( state() == 1 ) - { - cmdList += End; - setState( 0 ); - } - } - } - break; - } - default: - break; + } + break; } + case QEvent::MouseMove: + case QEvent::Wheel: { + if (state() != 0) + cmdList += Move; - return cmdList; -} - -//! Constructor -QwtPickerDragLineMachine::QwtPickerDragLineMachine(): - QwtPickerMachine( PolygonSelection ) -{ -} - -//! Transition -QList< QwtPickerMachine::Command > QwtPickerDragLineMachine::transition( - const QwtEventPattern& eventPattern, const QEvent* event ) -{ - QList< QwtPickerMachine::Command > cmdList; - - switch( event->type() ) - { - case QEvent::MouseButtonPress: - { - if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, - static_cast< const QMouseEvent* >( event ) ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 1 ); - } - } - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, - static_cast< const QKeyEvent* > ( event ) ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - break; - } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - - break; - } - case QEvent::MouseButtonRelease: - { - if ( state() != 0 ) - { - cmdList += End; - setState( 0 ); - } - } - default: - break; + break; } + case QEvent::MouseButtonRelease: { + if (state() != 0) + { + cmdList += End; + setState(0); + } + } + default: + break; + } - return cmdList; + return cmdList; } diff --git a/libs/qwt/src/qwt_picker_machine.h b/libs/qwt/src/qwt_picker_machine.h index 3feccb99..93baa815 100644 --- a/libs/qwt/src/qwt_picker_machine.h +++ b/libs/qwt/src/qwt_picker_machine.h @@ -14,7 +14,8 @@ class QwtEventPattern; class QEvent; -template< typename T > class QList; +template +class QList; /*! \brief A state machine for QwtPicker selections @@ -27,52 +28,52 @@ template< typename T > class QList; class QWT_EXPORT QwtPickerMachine { - public: - /*! - Type of a selection. - \sa selectionType() - */ - enum SelectionType - { - //! The state machine not usable for any type of selection. - NoSelection = -1, +public: + /*! + Type of a selection. + \sa selectionType() + */ + enum SelectionType + { + //! The state machine not usable for any type of selection. + NoSelection = -1, - //! The state machine is for selecting a single point. - PointSelection, + //! The state machine is for selecting a single point. + PointSelection, - //! The state machine is for selecting a rectangle (2 points). - RectSelection, + //! The state machine is for selecting a rectangle (2 points). + RectSelection, - //! The state machine is for selecting a polygon (many points). - PolygonSelection - }; + //! The state machine is for selecting a polygon (many points). + PolygonSelection + }; - //! Commands - the output of a state machine - enum Command - { - Begin, - Append, - Move, - Remove, - End - }; + //! Commands - the output of a state machine + enum Command + { + Begin, + Append, + Move, + Remove, + End + }; - explicit QwtPickerMachine( SelectionType ); - virtual ~QwtPickerMachine(); + explicit QwtPickerMachine(SelectionType); + virtual ~QwtPickerMachine(); - //! Transition - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) = 0; - void reset(); + //! Transition + virtual QList transition(const QwtEventPattern &, const QEvent *) + = 0; + void reset(); - int state() const; - void setState( int ); + int state() const; + void setState(int); - SelectionType selectionType() const; + SelectionType selectionType() const; - private: - const SelectionType m_selectionType; - int m_state; +private: + const SelectionType m_selectionType; + int m_state; }; /*! @@ -84,11 +85,11 @@ class QWT_EXPORT QwtPickerMachine */ class QWT_EXPORT QwtPickerTrackerMachine : public QwtPickerMachine { - public: - QwtPickerTrackerMachine(); +public: + QwtPickerTrackerMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; /*! @@ -101,11 +102,11 @@ class QWT_EXPORT QwtPickerTrackerMachine : public QwtPickerMachine */ class QWT_EXPORT QwtPickerClickPointMachine : public QwtPickerMachine { - public: - QwtPickerClickPointMachine(); +public: + QwtPickerClickPointMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; /*! @@ -117,11 +118,11 @@ class QWT_EXPORT QwtPickerClickPointMachine : public QwtPickerMachine */ class QWT_EXPORT QwtPickerDragPointMachine : public QwtPickerMachine { - public: - QwtPickerDragPointMachine(); +public: + QwtPickerDragPointMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; /*! @@ -139,11 +140,11 @@ class QWT_EXPORT QwtPickerDragPointMachine : public QwtPickerMachine class QWT_EXPORT QwtPickerClickRectMachine : public QwtPickerMachine { - public: - QwtPickerClickRectMachine(); +public: + QwtPickerClickRectMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; /*! @@ -160,11 +161,11 @@ class QWT_EXPORT QwtPickerClickRectMachine : public QwtPickerMachine class QWT_EXPORT QwtPickerDragRectMachine : public QwtPickerMachine { - public: - QwtPickerDragRectMachine(); +public: + QwtPickerDragRectMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; /*! @@ -184,11 +185,11 @@ class QWT_EXPORT QwtPickerDragRectMachine : public QwtPickerMachine class QWT_EXPORT QwtPickerDragLineMachine : public QwtPickerMachine { - public: - QwtPickerDragLineMachine(); +public: + QwtPickerDragLineMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; /*! @@ -204,11 +205,11 @@ class QWT_EXPORT QwtPickerDragLineMachine : public QwtPickerMachine class QWT_EXPORT QwtPickerPolygonMachine : public QwtPickerMachine { - public: - QwtPickerPolygonMachine(); +public: + QwtPickerPolygonMachine(); - virtual QList< Command > transition( - const QwtEventPattern&, const QEvent* ) QWT_OVERRIDE; + virtual QList transition(const QwtEventPattern &, + const QEvent *) QWT_OVERRIDE; }; #endif diff --git a/libs/qwt/src/qwt_pixel_matrix.cpp b/libs/qwt/src/qwt_pixel_matrix.cpp index e9e4c453..82017016 100644 --- a/libs/qwt/src/qwt_pixel_matrix.cpp +++ b/libs/qwt/src/qwt_pixel_matrix.cpp @@ -14,16 +14,14 @@ \param rect Bounding rectangle for the matrix */ -QwtPixelMatrix::QwtPixelMatrix( const QRect& rect ) - : QBitArray( qMax( rect.width() * rect.height(), 0 ) ) - , m_rect( rect ) +QwtPixelMatrix::QwtPixelMatrix(const QRect &rect) + : QBitArray(qMax(rect.width() * rect.height(), 0)) + , m_rect(rect) { } //! Destructor -QwtPixelMatrix::~QwtPixelMatrix() -{ -} +QwtPixelMatrix::~QwtPixelMatrix() {} /*! Set the bounding rectangle of the matrix @@ -32,20 +30,20 @@ QwtPixelMatrix::~QwtPixelMatrix() \note All bits are cleared */ -void QwtPixelMatrix::setRect( const QRect& rect ) +void QwtPixelMatrix::setRect(const QRect &rect) { - if ( rect != m_rect ) - { - m_rect = rect; - const int sz = qMax( rect.width() * rect.height(), 0 ); - resize( sz ); - } + if (rect != m_rect) + { + m_rect = rect; + const int sz = qMax(rect.width() * rect.height(), 0); + resize(sz); + } - fill( false ); + fill(false); } //! \return Bounding rectangle QRect QwtPixelMatrix::rect() const { - return m_rect; + return m_rect; } diff --git a/libs/qwt/src/qwt_pixel_matrix.h b/libs/qwt/src/qwt_pixel_matrix.h index a6e2a6ff..057b0d00 100644 --- a/libs/qwt/src/qwt_pixel_matrix.h +++ b/libs/qwt/src/qwt_pixel_matrix.h @@ -23,20 +23,20 @@ */ class QWT_EXPORT QwtPixelMatrix : public QBitArray { - public: - explicit QwtPixelMatrix( const QRect& rect ); - ~QwtPixelMatrix(); +public: + explicit QwtPixelMatrix(const QRect &rect); + ~QwtPixelMatrix(); - void setRect( const QRect& rect ); - QRect rect() const; + void setRect(const QRect &rect); + QRect rect() const; - bool testPixel( int x, int y ) const; - bool testAndSetPixel( int x, int y, bool on ); + bool testPixel(int x, int y) const; + bool testAndSetPixel(int x, int y, bool on); - int index( int x, int y ) const; + int index(int x, int y) const; - private: - QRect m_rect; +private: + QRect m_rect; }; /*! @@ -48,10 +48,10 @@ class QWT_EXPORT QwtPixelMatrix : public QBitArray \return true, when pos is outside of rect(), or when the pixel has already been set. */ -inline bool QwtPixelMatrix::testPixel( int x, int y ) const +inline bool QwtPixelMatrix::testPixel(int x, int y) const { - const int idx = index( x, y ); - return ( idx >= 0 ) ? testBit( idx ) : true; + const int idx = index(x, y); + return (idx >= 0) ? testBit(idx) : true; } /*! @@ -64,16 +64,16 @@ inline bool QwtPixelMatrix::testPixel( int x, int y ) const \return true, when pos is outside of rect(), or when the pixel was set before. */ -inline bool QwtPixelMatrix::testAndSetPixel( int x, int y, bool on ) +inline bool QwtPixelMatrix::testAndSetPixel(int x, int y, bool on) { - const int idx = index( x, y ); - if ( idx < 0 ) - return true; + const int idx = index(x, y); + if (idx < 0) + return true; - const bool onBefore = testBit( idx ); - setBit( idx, on ); + const bool onBefore = testBit(idx); + setBit(idx, on); - return onBefore; + return onBefore; } /*! @@ -83,17 +83,17 @@ inline bool QwtPixelMatrix::testAndSetPixel( int x, int y, bool on ) \param y Y-coordinate \return Index, when rect() contains pos - otherwise -1. */ -inline int QwtPixelMatrix::index( int x, int y ) const +inline int QwtPixelMatrix::index(int x, int y) const { - const int dx = x - m_rect.x(); - if ( dx < 0 || dx >= m_rect.width() ) - return -1; + const int dx = x - m_rect.x(); + if (dx < 0 || dx >= m_rect.width()) + return -1; - const int dy = y - m_rect.y(); - if ( dy < 0 || dy >= m_rect.height() ) - return -1; + const int dy = y - m_rect.y(); + if (dy < 0 || dy >= m_rect.height()) + return -1; - return dy * m_rect.width() + dx; + return dy * m_rect.width() + dx; } #endif diff --git a/libs/qwt/src/qwt_plot.cpp b/libs/qwt/src/qwt_plot.cpp index 3b0f278b..8f93b97e 100644 --- a/libs/qwt/src/qwt_plot.cpp +++ b/libs/qwt/src/qwt_plot.cpp @@ -24,86 +24,86 @@ #include #include -static inline void qwtEnableLegendItems( QwtPlot* plot, bool on ) +static inline void qwtEnableLegendItems(QwtPlot *plot, bool on) { - // gcc seems to have problems with const char sig[] in combination with certain options - const char* sig = SIGNAL(legendDataChanged(QVariant,QList)); - const char* slot = SLOT(updateLegendItems(QVariant,QList)); + // gcc seems to have problems with const char sig[] in combination with + // certain options + const char *sig = SIGNAL(legendDataChanged(QVariant, QList)); + const char *slot = SLOT(updateLegendItems(QVariant, QList)); - if ( on ) - QObject::connect( plot, sig, plot, slot ); - else - QObject::disconnect( plot, sig, plot, slot ); + if (on) + QObject::connect(plot, sig, plot, slot); + else + QObject::disconnect(plot, sig, plot, slot); } -static void qwtSetTabOrder( - QWidget* first, QWidget* second, bool withChildren ) +static void qwtSetTabOrder(QWidget *first, QWidget *second, bool withChildren) { - QList< QWidget* > tabChain; - tabChain += first; - tabChain += second; + QList tabChain; + tabChain += first; + tabChain += second; - if ( withChildren ) + if (withChildren) + { + QList children = second->findChildren(); + + QWidget *w = second->nextInFocusChain(); + while (children.contains(w)) { - QList< QWidget* > children = second->findChildren< QWidget* >(); + children.removeAll(w); - QWidget* w = second->nextInFocusChain(); - while ( children.contains( w ) ) - { - children.removeAll( w ); - - tabChain += w; - w = w->nextInFocusChain(); - } + tabChain += w; + w = w->nextInFocusChain(); } + } - for ( int i = 0; i < tabChain.size() - 1; i++ ) - { - QWidget* from = tabChain[i]; - QWidget* to = tabChain[i + 1]; + for (int i = 0; i < tabChain.size() - 1; i++) + { + QWidget *from = tabChain[i]; + QWidget *to = tabChain[i + 1]; - const Qt::FocusPolicy policy1 = from->focusPolicy(); - const Qt::FocusPolicy policy2 = to->focusPolicy(); + const Qt::FocusPolicy policy1 = from->focusPolicy(); + const Qt::FocusPolicy policy2 = to->focusPolicy(); - QWidget* proxy1 = from->focusProxy(); - QWidget* proxy2 = to->focusProxy(); + QWidget *proxy1 = from->focusProxy(); + QWidget *proxy2 = to->focusProxy(); - from->setFocusPolicy( Qt::TabFocus ); - from->setFocusProxy( NULL); + from->setFocusPolicy(Qt::TabFocus); + from->setFocusProxy(NULL); - to->setFocusPolicy( Qt::TabFocus ); - to->setFocusProxy( NULL); + to->setFocusPolicy(Qt::TabFocus); + to->setFocusProxy(NULL); - QWidget::setTabOrder( from, to ); + QWidget::setTabOrder(from, to); - from->setFocusPolicy( policy1 ); - from->setFocusProxy( proxy1); + from->setFocusPolicy(policy1); + from->setFocusProxy(proxy1); - to->setFocusPolicy( policy2 ); - to->setFocusProxy( proxy2 ); - } + to->setFocusPolicy(policy2); + to->setFocusProxy(proxy2); + } } class QwtPlot::PrivateData { - public: - QPointer< QwtTextLabel > titleLabel; - QPointer< QwtTextLabel > footerLabel; - QPointer< QWidget > canvas; - QPointer< QwtAbstractLegend > legend; - QwtPlotLayout* layout; +public: + QPointer titleLabel; + QPointer footerLabel; + QPointer canvas; + QPointer legend; + QwtPlotLayout *layout; - bool autoReplot; + bool autoReplot; }; /*! \brief Constructor \param parent Parent widget */ -QwtPlot::QwtPlot( QWidget* parent ) - : QFrame( parent ) +QwtPlot::QwtPlot(QWidget *parent) + : QFrame(parent) { - initPlot( QwtText() ); + initPlot(QwtText()); } /*! @@ -111,79 +111,77 @@ QwtPlot::QwtPlot( QWidget* parent ) \param title Title text \param parent Parent widget */ -QwtPlot::QwtPlot( const QwtText& title, QWidget* parent ) - : QFrame( parent ) +QwtPlot::QwtPlot(const QwtText &title, QWidget *parent) + : QFrame(parent) { - initPlot( title ); + initPlot(title); } //! Destructor QwtPlot::~QwtPlot() { - setAutoReplot( false ); - detachItems( QwtPlotItem::Rtti_PlotItem, autoDelete() ); + setAutoReplot(false); + detachItems(QwtPlotItem::Rtti_PlotItem, autoDelete()); - delete m_data->layout; - deleteAxesData(); - delete m_data; + delete m_data->layout; + deleteAxesData(); + delete m_data; } /*! \brief Initializes a QwtPlot instance \param title Title text */ -void QwtPlot::initPlot( const QwtText& title ) +void QwtPlot::initPlot(const QwtText &title) { - m_data = new PrivateData; + m_data = new PrivateData; - m_data->layout = new QwtPlotLayout; - m_data->autoReplot = false; + m_data->layout = new QwtPlotLayout; + m_data->autoReplot = false; - // title - m_data->titleLabel = new QwtTextLabel( this ); - m_data->titleLabel->setObjectName( "QwtPlotTitle" ); - m_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) ); + // title + m_data->titleLabel = new QwtTextLabel(this); + m_data->titleLabel->setObjectName("QwtPlotTitle"); + m_data->titleLabel->setFont(QFont(fontInfo().family(), 14, QFont::Bold)); - QwtText text( title ); - text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap ); - m_data->titleLabel->setText( text ); + QwtText text(title); + text.setRenderFlags(Qt::AlignCenter | Qt::TextWordWrap); + m_data->titleLabel->setText(text); - // footer - m_data->footerLabel = new QwtTextLabel( this ); - m_data->footerLabel->setObjectName( "QwtPlotFooter" ); + // footer + m_data->footerLabel = new QwtTextLabel(this); + m_data->footerLabel->setObjectName("QwtPlotFooter"); - QwtText footer; - footer.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap ); - m_data->footerLabel->setText( footer ); + QwtText footer; + footer.setRenderFlags(Qt::AlignCenter | Qt::TextWordWrap); + m_data->footerLabel->setText(footer); - // legend - m_data->legend = NULL; + // legend + m_data->legend = NULL; - // axes - initAxesData(); + // axes + initAxesData(); - // canvas - m_data->canvas = new QwtPlotCanvas( this ); - m_data->canvas->setObjectName( "QwtPlotCanvas" ); - m_data->canvas->installEventFilter( this ); + // canvas + m_data->canvas = new QwtPlotCanvas(this); + m_data->canvas->setObjectName("QwtPlotCanvas"); + m_data->canvas->installEventFilter(this); - setSizePolicy( QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding ); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - resize( 200, 200 ); + resize(200, 200); - using namespace QwtAxis; + using namespace QwtAxis; - QList< QWidget* > focusChain; - focusChain << this << m_data->titleLabel << axisWidget( XTop ) - << axisWidget( YLeft ) << m_data->canvas - << axisWidget( YRight ) << axisWidget( XBottom ) - << m_data->footerLabel; + QList focusChain; + focusChain << this << m_data->titleLabel << axisWidget(XTop) + << axisWidget(YLeft) << m_data->canvas << axisWidget(YRight) + << axisWidget(XBottom) << m_data->footerLabel; - for ( int i = 0; i < focusChain.size() - 1; i++ ) - qwtSetTabOrder( focusChain[i], focusChain[i + 1], false ); + for (int i = 0; i < focusChain.size() - 1; i++) + qwtSetTabOrder(focusChain[i], focusChain[i + 1], false); - qwtEnableLegendItems( this, true ); + qwtEnableLegendItems(this, true); } /*! @@ -210,22 +208,22 @@ void QwtPlot::initPlot( const QwtText& title ) \param canvas Canvas Widget \sa canvas() */ -void QwtPlot::setCanvas( QWidget* canvas ) +void QwtPlot::setCanvas(QWidget *canvas) { - if ( canvas == m_data->canvas ) - return; + if (canvas == m_data->canvas) + return; - delete m_data->canvas; - m_data->canvas = canvas; + delete m_data->canvas; + m_data->canvas = canvas; - if ( canvas ) - { - canvas->setParent( this ); - canvas->installEventFilter( this ); + if (canvas) + { + canvas->setParent(this); + canvas->installEventFilter(this); - if ( isVisible() ) - canvas->show(); - } + if (isVisible()) + canvas->show(); + } } /*! @@ -234,20 +232,20 @@ void QwtPlot::setCanvas( QWidget* canvas ) \return See QFrame::event() */ -bool QwtPlot::event( QEvent* event ) +bool QwtPlot::event(QEvent *event) { - bool ok = QFrame::event( event ); - switch ( event->type() ) - { - case QEvent::LayoutRequest: - updateLayout(); - break; - case QEvent::PolishRequest: - replot(); - break; - default:; - } - return ok; + bool ok = QFrame::event(event); + switch (event->type()) + { + case QEvent::LayoutRequest: + updateLayout(); + break; + case QEvent::PolishRequest: + replot(); + break; + default:; + } + return ok; } /*! @@ -268,28 +266,28 @@ bool QwtPlot::event( QEvent* event ) \sa updateCanvasMargins(), updateLayout() */ -bool QwtPlot::eventFilter( QObject* object, QEvent* event ) +bool QwtPlot::eventFilter(QObject *object, QEvent *event) { - if ( object == m_data->canvas ) + if (object == m_data->canvas) + { + if (event->type() == QEvent::Resize) { - if ( event->type() == QEvent::Resize ) - { - updateCanvasMargins(); - } - else if ( event->type() == QEvent::ContentsRectChange ) - { - updateLayout(); - } + updateCanvasMargins(); } + else if (event->type() == QEvent::ContentsRectChange) + { + updateLayout(); + } + } - return QFrame::eventFilter( object, event ); + return QFrame::eventFilter(object, event); } //! Replots the plot if autoReplot() is \c true. void QwtPlot::autoRefresh() { - if ( m_data->autoReplot ) - replot(); + if (m_data->autoReplot) + replot(); } /*! @@ -307,9 +305,9 @@ void QwtPlot::autoRefresh() \param tf \c true or \c false. Defaults to \c true. \sa replot() */ -void QwtPlot::setAutoReplot( bool tf ) +void QwtPlot::setAutoReplot(bool tf) { - m_data->autoReplot = tf; + m_data->autoReplot = tf; } /*! @@ -318,95 +316,95 @@ void QwtPlot::setAutoReplot( bool tf ) */ bool QwtPlot::autoReplot() const { - return m_data->autoReplot; + return m_data->autoReplot; } /*! Change the plot's title \param title New title */ -void QwtPlot::setTitle( const QString& title ) +void QwtPlot::setTitle(const QString &title) { - if ( title != m_data->titleLabel->text().text() ) - { - m_data->titleLabel->setText( title ); - updateLayout(); - } + if (title != m_data->titleLabel->text().text()) + { + m_data->titleLabel->setText(title); + updateLayout(); + } } /*! Change the plot's title \param title New title */ -void QwtPlot::setTitle( const QwtText& title ) +void QwtPlot::setTitle(const QwtText &title) { - if ( title != m_data->titleLabel->text() ) - { - m_data->titleLabel->setText( title ); - updateLayout(); - } + if (title != m_data->titleLabel->text()) + { + m_data->titleLabel->setText(title); + updateLayout(); + } } //! \return Title of the plot QwtText QwtPlot::title() const { - return m_data->titleLabel->text(); + return m_data->titleLabel->text(); } //! \return Title label widget. -QwtTextLabel* QwtPlot::titleLabel() +QwtTextLabel *QwtPlot::titleLabel() { - return m_data->titleLabel; + return m_data->titleLabel; } //! \return Title label widget. -const QwtTextLabel* QwtPlot::titleLabel() const +const QwtTextLabel *QwtPlot::titleLabel() const { - return m_data->titleLabel; + return m_data->titleLabel; } /*! Change the text the footer \param text New text of the footer */ -void QwtPlot::setFooter( const QString& text ) +void QwtPlot::setFooter(const QString &text) { - if ( text != m_data->footerLabel->text().text() ) - { - m_data->footerLabel->setText( text ); - updateLayout(); - } + if (text != m_data->footerLabel->text().text()) + { + m_data->footerLabel->setText(text); + updateLayout(); + } } /*! Change the text the footer \param text New text of the footer */ -void QwtPlot::setFooter( const QwtText& text ) +void QwtPlot::setFooter(const QwtText &text) { - if ( text != m_data->footerLabel->text() ) - { - m_data->footerLabel->setText( text ); - updateLayout(); - } + if (text != m_data->footerLabel->text()) + { + m_data->footerLabel->setText(text); + updateLayout(); + } } //! \return Text of the footer QwtText QwtPlot::footer() const { - return m_data->footerLabel->text(); + return m_data->footerLabel->text(); } //! \return Footer label widget. -QwtTextLabel* QwtPlot::footerLabel() +QwtTextLabel *QwtPlot::footerLabel() { - return m_data->footerLabel; + return m_data->footerLabel; } //! \return Footer label widget. -const QwtTextLabel* QwtPlot::footerLabel() const +const QwtTextLabel *QwtPlot::footerLabel() const { - return m_data->footerLabel; + return m_data->footerLabel; } /*! @@ -415,62 +413,61 @@ const QwtTextLabel* QwtPlot::footerLabel() const \param layout Layout() \sa plotLayout() */ -void QwtPlot::setPlotLayout( QwtPlotLayout* layout ) +void QwtPlot::setPlotLayout(QwtPlotLayout *layout) { - if ( layout != m_data->layout ) - { - delete m_data->layout; - m_data->layout = layout; + if (layout != m_data->layout) + { + delete m_data->layout; + m_data->layout = layout; - updateLayout(); - } + updateLayout(); + } } //! \return the plot's layout -QwtPlotLayout* QwtPlot::plotLayout() +QwtPlotLayout *QwtPlot::plotLayout() { - return m_data->layout; + return m_data->layout; } //! \return the plot's layout -const QwtPlotLayout* QwtPlot::plotLayout() const +const QwtPlotLayout *QwtPlot::plotLayout() const { - return m_data->layout; + return m_data->layout; } /*! \return the plot's legend \sa insertLegend() */ -QwtAbstractLegend* QwtPlot::legend() +QwtAbstractLegend *QwtPlot::legend() { - return m_data->legend; + return m_data->legend; } /*! \return the plot's legend \sa insertLegend() */ -const QwtAbstractLegend* QwtPlot::legend() const +const QwtAbstractLegend *QwtPlot::legend() const { - return m_data->legend; -} - - -/*! - \return the plot's canvas - */ -QWidget* QwtPlot::canvas() -{ - return m_data->canvas; + return m_data->legend; } /*! \return the plot's canvas */ -const QWidget* QwtPlot::canvas() const +QWidget *QwtPlot::canvas() { - return m_data->canvas; + return m_data->canvas; +} + +/*! + \return the plot's canvas + */ +const QWidget *QwtPlot::canvas() const +{ + return m_data->canvas; } /*! @@ -479,37 +476,37 @@ const QWidget* QwtPlot::canvas() const */ QSize QwtPlot::sizeHint() const { - int dw = 0; - int dh = 0; + int dw = 0; + int dh = 0; - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { + const QwtAxisId axisId(axisPos); + + if (isAxisVisible(axisId)) + { + const int niceDist = 40; + const QwtScaleWidget *scaleWidget = axisWidget(axisId); + const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv(); + const int majCnt = scaleDiv.ticks(QwtScaleDiv::MajorTick).count(); + + const QSize hint = scaleWidget->minimumSizeHint(); + + if (QwtAxis::isYAxis(axisPos)) { - const QwtAxisId axisId( axisPos ); - - if ( isAxisVisible( axisId ) ) - { - const int niceDist = 40; - const QwtScaleWidget* scaleWidget = axisWidget( axisId ); - const QwtScaleDiv& scaleDiv = scaleWidget->scaleDraw()->scaleDiv(); - const int majCnt = scaleDiv.ticks( QwtScaleDiv::MajorTick ).count(); - - const QSize hint = scaleWidget->minimumSizeHint(); - - if ( QwtAxis::isYAxis( axisPos ) ) - { - const int hDiff = ( majCnt - 1 ) * niceDist - hint.height(); - dh = qMax( dh, hDiff ); - } - else - { - const int wDiff = ( majCnt - 1 ) * niceDist - hint.width(); - dw = qMax( dw, wDiff ); - } - } + const int hDiff = (majCnt - 1) * niceDist - hint.height(); + dh = qMax(dh, hDiff); } + else + { + const int wDiff = (majCnt - 1) * niceDist - hint.width(); + dw = qMax(dw, wDiff); + } + } } - return minimumSizeHint() + QSize( dw, dh ); + } + return minimumSizeHint() + QSize(dw, dh); } /*! @@ -517,20 +514,20 @@ QSize QwtPlot::sizeHint() const */ QSize QwtPlot::minimumSizeHint() const { - QSize hint = m_data->layout->minimumSizeHint( this ); - hint += QSize( 2 * frameWidth(), 2 * frameWidth() ); + QSize hint = m_data->layout->minimumSizeHint(this); + hint += QSize(2 * frameWidth(), 2 * frameWidth()); - return hint; + return hint; } /*! Resize and update internal layout \param e Resize event */ -void QwtPlot::resizeEvent( QResizeEvent* e ) +void QwtPlot::resizeEvent(QResizeEvent *e) { - QFrame::resizeEvent( e ); - updateLayout(); + QFrame::resizeEvent(e); + updateLayout(); } /*! @@ -544,30 +541,30 @@ void QwtPlot::resizeEvent( QResizeEvent* e ) */ void QwtPlot::replot() { - bool doAutoReplot = autoReplot(); - setAutoReplot( false ); + bool doAutoReplot = autoReplot(); + setAutoReplot(false); - updateAxes(); + updateAxes(); - /* - Maybe the layout needs to be updated, because of changed - axes labels. We need to process them here before painting - to avoid that scales and canvas get out of sync. - */ - QApplication::sendPostedEvents( this, QEvent::LayoutRequest ); + /* + Maybe the layout needs to be updated, because of changed + axes labels. We need to process them here before painting + to avoid that scales and canvas get out of sync. + */ + QApplication::sendPostedEvents(this, QEvent::LayoutRequest); - if ( m_data->canvas ) + if (m_data->canvas) + { + const bool ok = QMetaObject::invokeMethod(m_data->canvas, "replot", + Qt::DirectConnection); + if (!ok) { - const bool ok = QMetaObject::invokeMethod( - m_data->canvas, "replot", Qt::DirectConnection ); - if ( !ok ) - { - // fallback, when canvas has no a replot method - m_data->canvas->update( m_data->canvas->contentsRect() ); - } + // fallback, when canvas has no a replot method + m_data->canvas->update(m_data->canvas->contentsRect()); } + } - setAutoReplot( doAutoReplot ); + setAutoReplot(doAutoReplot); } /*! @@ -576,123 +573,122 @@ void QwtPlot::replot() */ void QwtPlot::updateLayout() { - QwtPlotLayout* layout = m_data->layout; - layout->activate( this, contentsRect() ); + QwtPlotLayout *layout = m_data->layout; + layout->activate(this, contentsRect()); - const QRect titleRect = layout->titleRect().toRect(); - const QRect footerRect = layout->footerRect().toRect(); - const QRect legendRect = layout->legendRect().toRect(); - const QRect canvasRect = layout->canvasRect().toRect(); + const QRect titleRect = layout->titleRect().toRect(); + const QRect footerRect = layout->footerRect().toRect(); + const QRect legendRect = layout->legendRect().toRect(); + const QRect canvasRect = layout->canvasRect().toRect(); - // resize and show the visible widgets + // resize and show the visible widgets - if ( !m_data->titleLabel->text().isEmpty() ) + if (!m_data->titleLabel->text().isEmpty()) + { + m_data->titleLabel->setGeometry(titleRect); + if (!m_data->titleLabel->isVisibleTo(this)) + m_data->titleLabel->show(); + } + else + m_data->titleLabel->hide(); + + if (!m_data->footerLabel->text().isEmpty()) + { + m_data->footerLabel->setGeometry(footerRect); + if (!m_data->footerLabel->isVisibleTo(this)) + m_data->footerLabel->show(); + } + else + { + m_data->footerLabel->hide(); + } + + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { - m_data->titleLabel->setGeometry( titleRect ); - if ( !m_data->titleLabel->isVisibleTo( this ) ) - m_data->titleLabel->show(); + const QwtAxisId axisId(axisPos); + + QwtScaleWidget *scaleWidget = axisWidget(axisId); + + if (isAxisVisible(axisId)) + { + const QRect scaleRect = layout->scaleRect(axisId).toRect(); + + if (scaleRect != scaleWidget->geometry()) + { + scaleWidget->setGeometry(scaleRect); + + int startDist, endDist; + scaleWidget->getBorderDistHint(startDist, endDist); + scaleWidget->setBorderDist(startDist, endDist); + } + + if (!scaleWidget->isVisibleTo(this)) + scaleWidget->show(); + } + else + { + scaleWidget->hide(); + } } - else - m_data->titleLabel->hide(); + } - if ( !m_data->footerLabel->text().isEmpty() ) + if (m_data->legend) + { + if (m_data->legend->isEmpty()) { - m_data->footerLabel->setGeometry( footerRect ); - if ( !m_data->footerLabel->isVisibleTo( this ) ) - m_data->footerLabel->show(); + m_data->legend->hide(); } else { - m_data->footerLabel->hide(); + m_data->legend->setGeometry(legendRect); + m_data->legend->show(); } + } - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - { - const QwtAxisId axisId( axisPos ); - - QwtScaleWidget* scaleWidget = axisWidget( axisId ); - - if ( isAxisVisible( axisId ) ) - { - const QRect scaleRect = layout->scaleRect( axisId ).toRect(); - - if ( scaleRect != scaleWidget->geometry() ) - { - scaleWidget->setGeometry( scaleRect ); - - int startDist, endDist; - scaleWidget->getBorderDistHint( startDist, endDist ); - scaleWidget->setBorderDist( startDist, endDist ); - } - - if ( !scaleWidget->isVisibleTo( this ) ) - scaleWidget->show(); - } - else - { - scaleWidget->hide(); - } - } - } - - if ( m_data->legend ) - { - if ( m_data->legend->isEmpty() ) - { - m_data->legend->hide(); - } - else - { - m_data->legend->setGeometry( legendRect ); - m_data->legend->show(); - } - } - - m_data->canvas->setGeometry( canvasRect ); + m_data->canvas->setGeometry(canvasRect); } /*! \brief Calculate the canvas margins - \param maps QwtAxis::AxisCount maps, mapping between plot and paint device coordinates - \param canvasRect Bounding rectangle where to paint - \param left Return parameter for the left margin - \param top Return parameter for the top margin - \param right Return parameter for the right margin - \param bottom Return parameter for the bottom margin + \param maps QwtAxis::AxisCount maps, mapping between plot and paint device + coordinates \param canvasRect Bounding rectangle where to paint \param left + Return parameter for the left margin \param top Return parameter for the top + margin \param right Return parameter for the right margin \param bottom + Return parameter for the bottom margin Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag. updateCanvasMargins(), QwtPlotItem::getCanvasMarginHint() */ -void QwtPlot::getCanvasMarginsHint( - const QwtScaleMap maps[], const QRectF& canvasRect, - double& left, double& top, double& right, double& bottom) const +void QwtPlot::getCanvasMarginsHint(const QwtScaleMap maps[], + const QRectF &canvasRect, double &left, + double &top, double &right, + double &bottom) const { - left = top = right = bottom = -1.0; + left = top = right = bottom = -1.0; - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) + const QwtPlotItemList &itmList = itemList(); + for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + const QwtPlotItem *item = *it; + if (item->testItemAttribute(QwtPlotItem::Margins)) { - const QwtPlotItem* item = *it; - if ( item->testItemAttribute( QwtPlotItem::Margins ) ) - { - using namespace QwtAxis; + using namespace QwtAxis; - double m[ AxisPositions ]; - item->getCanvasMarginHint( - maps[ item->xAxis() ], maps[ item->yAxis() ], - canvasRect, m[YLeft], m[XTop], m[YRight], m[XBottom] ); + double m[AxisPositions]; + item->getCanvasMarginHint(maps[item->xAxis()], maps[item->yAxis()], + canvasRect, m[YLeft], m[XTop], m[YRight], + m[XBottom]); - left = qwtMaxF( left, m[YLeft] ); - top = qwtMaxF( top, m[XTop] ); - right = qwtMaxF( right, m[YRight] ); - bottom = qwtMaxF( bottom, m[XBottom] ); - } + left = qwtMaxF(left, m[YLeft]); + top = qwtMaxF(top, m[XTop]); + right = qwtMaxF(right, m[YRight]); + bottom = qwtMaxF(bottom, m[XBottom]); } + } } /*! @@ -705,29 +701,29 @@ void QwtPlot::getCanvasMarginsHint( */ void QwtPlot::updateCanvasMargins() { - using namespace QwtAxis; + using namespace QwtAxis; - QwtScaleMap maps[ AxisPositions ]; - for ( int axisId = 0; axisId < AxisPositions; axisId++ ) - maps[axisId] = canvasMap( axisId ); + QwtScaleMap maps[AxisPositions]; + for (int axisId = 0; axisId < AxisPositions; axisId++) + maps[axisId] = canvasMap(axisId); - double margins[AxisPositions]; - getCanvasMarginsHint( maps, canvas()->contentsRect(), - margins[YLeft], margins[XTop], margins[YRight], margins[XBottom] ); + double margins[AxisPositions]; + getCanvasMarginsHint(maps, canvas()->contentsRect(), margins[YLeft], + margins[XTop], margins[YRight], margins[XBottom]); - bool doUpdate = false; - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) + bool doUpdate = false; + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + if (margins[axisPos] >= 0.0) { - if ( margins[axisPos] >= 0.0 ) - { - const int m = qwtCeil( margins[axisPos] ); - plotLayout()->setCanvasMargin( m, axisPos); - doUpdate = true; - } + const int m = qwtCeil(margins[axisPos]); + plotLayout()->setCanvasMargin(m, axisPos); + doUpdate = true; } + } - if ( doUpdate ) - updateLayout(); + if (doUpdate) + updateLayout(); } /*! @@ -739,13 +735,13 @@ void QwtPlot::updateCanvasMargins() plot items better overload drawItems() \sa drawItems() */ -void QwtPlot::drawCanvas( QPainter* painter ) +void QwtPlot::drawCanvas(QPainter *painter) { - QwtScaleMap maps[ QwtAxis::AxisPositions ]; - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - maps[axisPos] = canvasMap( axisPos ); + QwtScaleMap maps[QwtAxis::AxisPositions]; + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + maps[axisPos] = canvasMap(axisPos); - drawItems( painter, m_data->canvas->contentsRect(), maps ); + drawItems(painter, m_data->canvas->contentsRect(), maps); } /*! @@ -753,7 +749,8 @@ void QwtPlot::drawCanvas( QPainter* painter ) \param painter Painter used for drawing \param canvasRect Bounding rectangle where to paint - \param maps QwtAxis::AxisCount maps, mapping between plot and paint device coordinates + \param maps QwtAxis::AxisCount maps, mapping between plot and paint device + coordinates \note Usually canvasRect is contentsRect() of the plot canvas. Due to a bug in Qt this rectangle might be wrong for certain @@ -761,34 +758,35 @@ void QwtPlot::drawCanvas( QPainter* painter ) fix the margins manually using QWidget::setContentsMargins() */ -void QwtPlot::drawItems( QPainter* painter, const QRectF& canvasRect, - const QwtScaleMap maps[ QwtAxis::AxisPositions ] ) const +void QwtPlot::drawItems(QPainter *painter, const QRectF &canvasRect, + const QwtScaleMap maps[QwtAxis::AxisPositions]) const { - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) + const QwtPlotItemList &itmList = itemList(); + for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + QwtPlotItem *item = *it; + if (item && item->isVisible()) { - QwtPlotItem* item = *it; - if ( item && item->isVisible() ) - { - const QwtAxisId xAxis = item->xAxis(); - const QwtAxisId yAxis = item->yAxis(); + const QwtAxisId xAxis = item->xAxis(); + const QwtAxisId yAxis = item->yAxis(); - painter->save(); + painter->save(); - painter->setRenderHint( QPainter::Antialiasing, - item->testRenderHint( QwtPlotItem::RenderAntialiased ) ); + painter->setRenderHint( + QPainter::Antialiasing, + item->testRenderHint(QwtPlotItem::RenderAntialiased)); #if QT_VERSION < 0x050100 - painter->setRenderHint( QPainter::HighQualityAntialiasing, - item->testRenderHint( QwtPlotItem::RenderAntialiased ) ); + painter->setRenderHint( + QPainter::HighQualityAntialiasing, + item->testRenderHint(QwtPlotItem::RenderAntialiased)); #endif - item->draw( painter, maps[xAxis], maps[yAxis], canvasRect ); + item->draw(painter, maps[xAxis], maps[yAxis], canvasRect); - painter->restore(); - } + painter->restore(); } + } } /*! @@ -797,67 +795,67 @@ void QwtPlot::drawItems( QPainter* painter, const QRectF& canvasRect, translated to plot coordinates and vice versa. \sa QwtScaleMap, transform(), invTransform() */ -QwtScaleMap QwtPlot::canvasMap( QwtAxisId axisId ) const +QwtScaleMap QwtPlot::canvasMap(QwtAxisId axisId) const { - QwtScaleMap map; - if ( !m_data->canvas ) - return map; + QwtScaleMap map; + if (!m_data->canvas) + return map; - map.setTransformation( axisScaleEngine( axisId )->transformation() ); + map.setTransformation(axisScaleEngine(axisId)->transformation()); - const QwtScaleDiv& sd = axisScaleDiv( axisId ); - map.setScaleInterval( sd.lowerBound(), sd.upperBound() ); + const QwtScaleDiv &sd = axisScaleDiv(axisId); + map.setScaleInterval(sd.lowerBound(), sd.upperBound()); - if ( isAxisVisible( axisId ) ) + if (isAxisVisible(axisId)) + { + const QwtScaleWidget *s = axisWidget(axisId); + if (QwtAxis::isYAxis(axisId)) { - const QwtScaleWidget* s = axisWidget( axisId ); - if ( QwtAxis::isYAxis( axisId ) ) - { - double y = s->y() + s->startBorderDist() - m_data->canvas->y(); - double h = s->height() - s->startBorderDist() - s->endBorderDist(); - map.setPaintInterval( y + h, y ); - } - else - { - double x = s->x() + s->startBorderDist() - m_data->canvas->x(); - double w = s->width() - s->startBorderDist() - s->endBorderDist(); - map.setPaintInterval( x, x + w ); - } + double y = s->y() + s->startBorderDist() - m_data->canvas->y(); + double h = s->height() - s->startBorderDist() - s->endBorderDist(); + map.setPaintInterval(y + h, y); } else { - using namespace QwtAxis; - - const QRect& canvasRect = m_data->canvas->contentsRect(); - if ( isYAxis( axisId ) ) - { - int top = 0; - if ( !plotLayout()->alignCanvasToScale( XTop ) ) - top = plotLayout()->canvasMargin( XTop ); - - int bottom = 0; - if ( !plotLayout()->alignCanvasToScale( XBottom ) ) - bottom = plotLayout()->canvasMargin( XBottom ); - - map.setPaintInterval( canvasRect.bottom() - bottom, - canvasRect.top() + top ); - } - else - { - int left = 0; - if ( !plotLayout()->alignCanvasToScale( YLeft ) ) - left = plotLayout()->canvasMargin( YLeft ); - - int right = 0; - if ( !plotLayout()->alignCanvasToScale( YRight ) ) - right = plotLayout()->canvasMargin( YRight ); - - map.setPaintInterval( canvasRect.left() + left, - canvasRect.right() - right ); - } + double x = s->x() + s->startBorderDist() - m_data->canvas->x(); + double w = s->width() - s->startBorderDist() - s->endBorderDist(); + map.setPaintInterval(x, x + w); } + } + else + { + using namespace QwtAxis; - return map; + const QRect &canvasRect = m_data->canvas->contentsRect(); + if (isYAxis(axisId)) + { + int top = 0; + if (!plotLayout()->alignCanvasToScale(XTop)) + top = plotLayout()->canvasMargin(XTop); + + int bottom = 0; + if (!plotLayout()->alignCanvasToScale(XBottom)) + bottom = plotLayout()->canvasMargin(XBottom); + + map.setPaintInterval(canvasRect.bottom() - bottom, + canvasRect.top() + top); + } + else + { + int left = 0; + if (!plotLayout()->alignCanvasToScale(YLeft)) + left = plotLayout()->canvasMargin(YLeft); + + int right = 0; + if (!plotLayout()->alignCanvasToScale(YRight)) + right = plotLayout()->canvasMargin(YRight); + + map.setPaintInterval(canvasRect.left() + left, + canvasRect.right() - right); + } + } + + return map; } /*! @@ -870,12 +868,12 @@ QwtScaleMap QwtPlot::canvasMap( QwtAxisId axisId ) const \param brush New background brush \sa canvasBackground() */ -void QwtPlot::setCanvasBackground( const QBrush& brush ) +void QwtPlot::setCanvasBackground(const QBrush &brush) { - QPalette pal = m_data->canvas->palette(); - pal.setBrush( QPalette::Window, brush ); + QPalette pal = m_data->canvas->palette(); + pal.setBrush(QPalette::Window, brush); - canvas()->setPalette( pal ); + canvas()->setPalette(pal); } /*! @@ -887,8 +885,7 @@ void QwtPlot::setCanvasBackground( const QBrush& brush ) */ QBrush QwtPlot::canvasBackground() const { - return canvas()->palette().brush( - QPalette::Normal, QPalette::Window ); + return canvas()->palette().brush(QPalette::Normal, QPalette::Window); } /*! @@ -924,88 +921,81 @@ QBrush QwtPlot::canvasBackground() const \sa legend(), QwtPlotLayout::legendPosition(), QwtPlotLayout::setLegendPosition() */ -void QwtPlot::insertLegend( QwtAbstractLegend* legend, - QwtPlot::LegendPosition pos, double ratio ) +void QwtPlot::insertLegend(QwtAbstractLegend *legend, + QwtPlot::LegendPosition pos, double ratio) { - m_data->layout->setLegendPosition( pos, ratio ); + m_data->layout->setLegendPosition(pos, ratio); - if ( legend != m_data->legend ) + if (legend != m_data->legend) + { + if (m_data->legend && m_data->legend->parent() == this) + delete m_data->legend; + + m_data->legend = legend; + + if (m_data->legend) { - if ( m_data->legend && m_data->legend->parent() == this ) - delete m_data->legend; + connect(this, SIGNAL(legendDataChanged(QVariant, QList)), + m_data->legend, + SLOT(updateLegend(QVariant, QList))); - m_data->legend = legend; + if (m_data->legend->parent() != this) + m_data->legend->setParent(this); - if ( m_data->legend ) + qwtEnableLegendItems(this, false); + updateLegend(); + qwtEnableLegendItems(this, true); + + QwtLegend *lgd = qobject_cast(legend); + if (lgd) + { + switch (m_data->layout->legendPosition()) { - connect( - this, SIGNAL(legendDataChanged(QVariant,QList)), - m_data->legend, SLOT(updateLegend(QVariant,QList)) - ); - - if ( m_data->legend->parent() != this ) - m_data->legend->setParent( this ); - - qwtEnableLegendItems( this, false ); - updateLegend(); - qwtEnableLegendItems( this, true ); - - QwtLegend* lgd = qobject_cast< QwtLegend* >( legend ); - if ( lgd ) - { - switch ( m_data->layout->legendPosition() ) - { - case LeftLegend: - case RightLegend: - { - if ( lgd->maxColumns() == 0 ) - lgd->setMaxColumns( 1 ); // 1 column: align vertical - break; - } - case TopLegend: - case BottomLegend: - { - lgd->setMaxColumns( 0 ); // unlimited - break; - } - default: - break; - } - } - - QWidget* previousInChain = NULL; - switch ( m_data->layout->legendPosition() ) - { - case LeftLegend: - { - const QwtAxisId axisId( QwtAxis::XTop ); - previousInChain = axisWidget( axisId ); - break; - } - case TopLegend: - { - previousInChain = this; - break; - } - case RightLegend: - { - const QwtAxisId axisId( QwtAxis::YRight ); - previousInChain = axisWidget( axisId ); - break; - } - case BottomLegend: - { - previousInChain = footerLabel(); - break; - } - } - - if ( previousInChain ) - qwtSetTabOrder( previousInChain, legend, true ); + case LeftLegend: + case RightLegend: { + if (lgd->maxColumns() == 0) + lgd->setMaxColumns(1); // 1 column: align vertical + break; + } + case TopLegend: + case BottomLegend: { + lgd->setMaxColumns(0); // unlimited + break; + } + default: + break; } - } + } - updateLayout(); + QWidget *previousInChain = NULL; + switch (m_data->layout->legendPosition()) + { + case LeftLegend: { + const QwtAxisId axisId(QwtAxis::XTop); + previousInChain = axisWidget(axisId); + break; + } + case TopLegend: { + previousInChain = this; + break; + } + case RightLegend: { + const QwtAxisId axisId(QwtAxis::YRight); + previousInChain = axisWidget(axisId); + break; + } + case BottomLegend: { + previousInChain = footerLabel(); + break; + } + } + + if (previousInChain) + qwtSetTabOrder(previousInChain, legend, true); + } + } + + updateLayout(); } /*! @@ -1015,12 +1005,11 @@ void QwtPlot::insertLegend( QwtAbstractLegend* legend, */ void QwtPlot::updateLegend() { - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - updateLegend( *it ); - } + const QwtPlotItemList &itmList = itemList(); + for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + updateLegend(*it); + } } /*! @@ -1029,18 +1018,18 @@ void QwtPlot::updateLegend() \param plotItem Plot item \sa QwtPlotItem::legendData(), legendDataChanged() */ -void QwtPlot::updateLegend( const QwtPlotItem* plotItem ) +void QwtPlot::updateLegend(const QwtPlotItem *plotItem) { - if ( plotItem == NULL ) - return; + if (plotItem == NULL) + return; - QList< QwtLegendData > legendData; + QList legendData; - if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) ) - legendData = plotItem->legendData(); + if (plotItem->testItemAttribute(QwtPlotItem::Legend)) + legendData = plotItem->legendData(); - const QVariant itemInfo = itemToInfo( const_cast< QwtPlotItem* >( plotItem ) ); - Q_EMIT legendDataChanged( itemInfo, legendData ); + const QVariant itemInfo = itemToInfo(const_cast(plotItem)); + Q_EMIT legendDataChanged(itemInfo, legendData); } /*! @@ -1055,21 +1044,20 @@ void QwtPlot::updateLegend( const QwtPlotItem* plotItem ) \sa QwtPlotItem::LegendInterest, QwtPlotLegendItem, QwtPlotItem::updateLegend() */ -void QwtPlot::updateLegendItems( const QVariant& itemInfo, - const QList< QwtLegendData >& legendData ) +void QwtPlot::updateLegendItems(const QVariant &itemInfo, + const QList &legendData) { - QwtPlotItem* plotItem = infoToItem( itemInfo ); - if ( plotItem ) + QwtPlotItem *plotItem = infoToItem(itemInfo); + if (plotItem) + { + const QwtPlotItemList &itmList = itemList(); + for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) { - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - QwtPlotItem* item = *it; - if ( item->testItemInterest( QwtPlotItem::LegendInterest ) ) - item->updateLegend( plotItem, legendData ); - } + QwtPlotItem *item = *it; + if (item->testItemInterest(QwtPlotItem::LegendInterest)) + item->updateLegend(plotItem, legendData); } + } } /*! @@ -1078,50 +1066,49 @@ void QwtPlot::updateLegendItems( const QVariant& itemInfo, \param plotItem Plot item \param on When true attach the item, otherwise detach it */ -void QwtPlot::attachItem( QwtPlotItem* plotItem, bool on ) +void QwtPlot::attachItem(QwtPlotItem *plotItem, bool on) { - if ( plotItem->testItemInterest( QwtPlotItem::LegendInterest ) ) + if (plotItem->testItemInterest(QwtPlotItem::LegendInterest)) + { + // plotItem is some sort of legend + + const QwtPlotItemList &itmList = itemList(); + for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) { - // plotItem is some sort of legend + QwtPlotItem *item = *it; - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - QwtPlotItem* item = *it; - - QList< QwtLegendData > legendData; - if ( on && item->testItemAttribute( QwtPlotItem::Legend ) ) - { - legendData = item->legendData(); - plotItem->updateLegend( item, legendData ); - } - } + QList legendData; + if (on && item->testItemAttribute(QwtPlotItem::Legend)) + { + legendData = item->legendData(); + plotItem->updateLegend(item, legendData); + } } + } - if ( on ) - insertItem( plotItem ); + if (on) + insertItem(plotItem); + else + removeItem(plotItem); + + Q_EMIT itemAttached(plotItem, on); + + if (plotItem->testItemAttribute(QwtPlotItem::Legend)) + { + // the item wants to be represented on the legend + + if (on) + { + updateLegend(plotItem); + } else - removeItem( plotItem ); - - Q_EMIT itemAttached( plotItem, on ); - - if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) ) { - // the item wants to be represented on the legend - - if ( on ) - { - updateLegend( plotItem ); - } - else - { - const QVariant itemInfo = itemToInfo( plotItem ); - Q_EMIT legendDataChanged( itemInfo, QList< QwtLegendData >() ); - } + const QVariant itemInfo = itemToInfo(plotItem); + Q_EMIT legendDataChanged(itemInfo, QList()); } + } - autoRefresh(); + autoRefresh(); } /*! @@ -1136,9 +1123,9 @@ void QwtPlot::attachItem( QwtPlotItem* plotItem, bool on ) \return Plot item embedded in a QVariant \sa infoToItem() */ -QVariant QwtPlot::itemToInfo( QwtPlotItem* plotItem ) const +QVariant QwtPlot::itemToInfo(QwtPlotItem *plotItem) const { - return QVariant::fromValue( plotItem ); + return QVariant::fromValue(plotItem); } /*! @@ -1156,14 +1143,14 @@ QVariant QwtPlot::itemToInfo( QwtPlotItem* plotItem ) const \return A plot item, when successful, otherwise a NULL pointer. \sa itemToInfo() */ -QwtPlotItem* QwtPlot::infoToItem( const QVariant& itemInfo ) const +QwtPlotItem *QwtPlot::infoToItem(const QVariant &itemInfo) const { - if ( itemInfo.canConvert< QwtPlotItem* >() ) - return qvariant_cast< QwtPlotItem* >( itemInfo ); + if (itemInfo.canConvert()) + return qvariant_cast(itemInfo); - return NULL; + return NULL; } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot.cpp" +# include "moc_qwt_plot.cpp" #endif diff --git a/libs/qwt/src/qwt_plot.h b/libs/qwt/src/qwt_plot.h index 2343628d..f40805d4 100644 --- a/libs/qwt/src/qwt_plot.h +++ b/libs/qwt/src/qwt_plot.h @@ -26,7 +26,8 @@ class QwtScaleDraw; class QwtTextLabel; class QwtInterval; class QwtText; -template< typename T > class QList; +template +class QList; // 6.1 compatibility definitions #define QWT_AXIS_COMPAT 1 @@ -77,234 +78,228 @@ template< typename T > class QList; class QWT_EXPORT QwtPlot : public QFrame, public QwtPlotDict { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( QBrush canvasBackground - READ canvasBackground WRITE setCanvasBackground ) + Q_PROPERTY( + QBrush canvasBackground READ canvasBackground WRITE setCanvasBackground) - Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot ) + Q_PROPERTY(bool autoReplot READ autoReplot WRITE setAutoReplot) - public: - /*! - Position of the legend, relative to the canvas. +public: + /*! + Position of the legend, relative to the canvas. - \sa insertLegend() - */ - enum LegendPosition - { - //! The legend will be left from the QwtAxis::YLeft axis. - LeftLegend, + \sa insertLegend() + */ + enum LegendPosition + { + //! The legend will be left from the QwtAxis::YLeft axis. + LeftLegend, - //! The legend will be right from the QwtAxis::YRight axis. - RightLegend, + //! The legend will be right from the QwtAxis::YRight axis. + RightLegend, - //! The legend will be below the footer - BottomLegend, + //! The legend will be below the footer + BottomLegend, - //! The legend will be above the title - TopLegend - }; + //! The legend will be above the title + TopLegend + }; - explicit QwtPlot( QWidget* = NULL ); - explicit QwtPlot( const QwtText& title, QWidget* = NULL ); + explicit QwtPlot(QWidget * = NULL); + explicit QwtPlot(const QwtText &title, QWidget * = NULL); - virtual ~QwtPlot(); + virtual ~QwtPlot(); - void setAutoReplot( bool = true ); - bool autoReplot() const; + void setAutoReplot(bool = true); + bool autoReplot() const; - // Layout + // Layout - void setPlotLayout( QwtPlotLayout* ); + void setPlotLayout(QwtPlotLayout *); - QwtPlotLayout* plotLayout(); - const QwtPlotLayout* plotLayout() const; + QwtPlotLayout *plotLayout(); + const QwtPlotLayout *plotLayout() const; - // Title + // Title - void setTitle( const QString& ); - void setTitle( const QwtText& ); - QwtText title() const; + void setTitle(const QString &); + void setTitle(const QwtText &); + QwtText title() const; - QwtTextLabel* titleLabel(); - const QwtTextLabel* titleLabel() const; + QwtTextLabel *titleLabel(); + const QwtTextLabel *titleLabel() const; - // Footer + // Footer - void setFooter( const QString& ); - void setFooter( const QwtText& ); - QwtText footer() const; + void setFooter(const QString &); + void setFooter(const QwtText &); + QwtText footer() const; - QwtTextLabel* footerLabel(); - const QwtTextLabel* footerLabel() const; + QwtTextLabel *footerLabel(); + const QwtTextLabel *footerLabel() const; - // Canvas + // Canvas - void setCanvas( QWidget* ); + void setCanvas(QWidget *); - QWidget* canvas(); - const QWidget* canvas() const; + QWidget *canvas(); + const QWidget *canvas() const; - void setCanvasBackground( const QBrush& ); - QBrush canvasBackground() const; + void setCanvasBackground(const QBrush &); + QBrush canvasBackground() const; - virtual QwtScaleMap canvasMap( QwtAxisId ) const; + virtual QwtScaleMap canvasMap(QwtAxisId) const; - double invTransform( QwtAxisId, double pos ) const; - double transform( QwtAxisId, double value ) const; + double invTransform(QwtAxisId, double pos) const; + double transform(QwtAxisId, double value) const; - // Axes + // Axes - bool isAxisValid( QwtAxisId ) const; + bool isAxisValid(QwtAxisId) const; - void setAxisVisible( QwtAxisId, bool on = true ); - bool isAxisVisible( QwtAxisId ) const; + void setAxisVisible(QwtAxisId, bool on = true); + bool isAxisVisible(QwtAxisId) const; - // Axes data + // Axes data - QwtScaleEngine* axisScaleEngine( QwtAxisId ); - const QwtScaleEngine* axisScaleEngine( QwtAxisId ) const; - void setAxisScaleEngine( QwtAxisId, QwtScaleEngine* ); + QwtScaleEngine *axisScaleEngine(QwtAxisId); + const QwtScaleEngine *axisScaleEngine(QwtAxisId) const; + void setAxisScaleEngine(QwtAxisId, QwtScaleEngine *); - void setAxisAutoScale( QwtAxisId, bool on = true ); - bool axisAutoScale( QwtAxisId ) const; + void setAxisAutoScale(QwtAxisId, bool on = true); + bool axisAutoScale(QwtAxisId) const; - void setAxisFont( QwtAxisId, const QFont& ); - QFont axisFont( QwtAxisId ) const; + void setAxisFont(QwtAxisId, const QFont &); + QFont axisFont(QwtAxisId) const; - void setAxisScale( QwtAxisId, double min, double max, double stepSize = 0 ); - void setAxisScaleDiv( QwtAxisId, const QwtScaleDiv& ); - void setAxisScaleDraw( QwtAxisId, QwtScaleDraw* ); + void setAxisScale(QwtAxisId, double min, double max, double stepSize = 0); + void setAxisScaleDiv(QwtAxisId, const QwtScaleDiv &); + void setAxisScaleDraw(QwtAxisId, QwtScaleDraw *); - double axisStepSize( QwtAxisId ) const; - QwtInterval axisInterval( QwtAxisId ) const; - const QwtScaleDiv& axisScaleDiv( QwtAxisId ) const; + double axisStepSize(QwtAxisId) const; + QwtInterval axisInterval(QwtAxisId) const; + const QwtScaleDiv &axisScaleDiv(QwtAxisId) const; - const QwtScaleDraw* axisScaleDraw( QwtAxisId ) const; - QwtScaleDraw* axisScaleDraw( QwtAxisId ); + const QwtScaleDraw *axisScaleDraw(QwtAxisId) const; + QwtScaleDraw *axisScaleDraw(QwtAxisId); - const QwtScaleWidget* axisWidget( QwtAxisId ) const; - QwtScaleWidget* axisWidget( QwtAxisId ); + const QwtScaleWidget *axisWidget(QwtAxisId) const; + QwtScaleWidget *axisWidget(QwtAxisId); - void setAxisLabelAlignment( QwtAxisId, Qt::Alignment ); - void setAxisLabelRotation( QwtAxisId, double rotation ); + void setAxisLabelAlignment(QwtAxisId, Qt::Alignment); + void setAxisLabelRotation(QwtAxisId, double rotation); - void setAxisTitle( QwtAxisId, const QString& ); - void setAxisTitle( QwtAxisId, const QwtText& ); - QwtText axisTitle( QwtAxisId ) const; + void setAxisTitle(QwtAxisId, const QString &); + void setAxisTitle(QwtAxisId, const QwtText &); + QwtText axisTitle(QwtAxisId) const; - void setAxisMaxMinor( QwtAxisId, int maxMinor ); - int axisMaxMinor( QwtAxisId ) const; + void setAxisMaxMinor(QwtAxisId, int maxMinor); + int axisMaxMinor(QwtAxisId) const; - void setAxisMaxMajor( QwtAxisId, int maxMajor ); - int axisMaxMajor( QwtAxisId ) const; + void setAxisMaxMajor(QwtAxisId, int maxMajor); + int axisMaxMajor(QwtAxisId) const; - // Legend + // Legend - void insertLegend( QwtAbstractLegend*, - LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 ); + void insertLegend(QwtAbstractLegend *, LegendPosition = QwtPlot::RightLegend, + double ratio = -1.0); - QwtAbstractLegend* legend(); - const QwtAbstractLegend* legend() const; + QwtAbstractLegend *legend(); + const QwtAbstractLegend *legend() const; - void updateLegend(); - void updateLegend( const QwtPlotItem* ); + void updateLegend(); + void updateLegend(const QwtPlotItem *); - // Misc + // Misc - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual void updateLayout(); - virtual void drawCanvas( QPainter* ); + virtual void updateLayout(); + virtual void drawCanvas(QPainter *); - void updateAxes(); - void updateCanvasMargins(); + void updateAxes(); + void updateCanvasMargins(); - virtual void getCanvasMarginsHint( - const QwtScaleMap maps[], const QRectF& canvasRect, - double& left, double& top, double& right, double& bottom) const; + virtual void getCanvasMarginsHint(const QwtScaleMap maps[], + const QRectF &canvasRect, double &left, + double &top, double &right, + double &bottom) const; - virtual bool event( QEvent* ) QWT_OVERRIDE; - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + virtual bool event(QEvent *) QWT_OVERRIDE; + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - virtual void drawItems( QPainter*, const QRectF&, - const QwtScaleMap maps[ QwtAxis::AxisPositions ] ) const; + virtual void drawItems(QPainter *, const QRectF &, + const QwtScaleMap maps[QwtAxis::AxisPositions]) const; - virtual QVariant itemToInfo( QwtPlotItem* ) const; - virtual QwtPlotItem* infoToItem( const QVariant& ) const; + virtual QVariant itemToInfo(QwtPlotItem *) const; + virtual QwtPlotItem *infoToItem(const QVariant &) const; #if QWT_AXIS_COMPAT - enum Axis - { - yLeft = QwtAxis::YLeft, - yRight = QwtAxis::YRight, - xBottom = QwtAxis::XBottom, - xTop = QwtAxis::XTop, + enum Axis + { + yLeft = QwtAxis::YLeft, + yRight = QwtAxis::YRight, + xBottom = QwtAxis::XBottom, + xTop = QwtAxis::XTop, - axisCnt = QwtAxis::AxisPositions - }; + axisCnt = QwtAxis::AxisPositions + }; - void enableAxis( int axisId, bool on = true ) - { - setAxisVisible( axisId, on ); - } + void enableAxis(int axisId, bool on = true) { setAxisVisible(axisId, on); } - bool axisEnabled( int axisId ) const - { - return isAxisVisible( axisId ); - } + bool axisEnabled(int axisId) const { return isAxisVisible(axisId); } #endif - Q_SIGNALS: - /*! - A signal indicating, that an item has been attached/detached +Q_SIGNALS: + /*! + A signal indicating, that an item has been attached/detached - \param plotItem Plot item - \param on Attached/Detached - */ - void itemAttached( QwtPlotItem* plotItem, bool on ); + \param plotItem Plot item + \param on Attached/Detached + */ + void itemAttached(QwtPlotItem *plotItem, bool on); - /*! - A signal with the attributes how to update - the legend entries for a plot item. + /*! + A signal with the attributes how to update + the legend entries for a plot item. - \param itemInfo Info about a plot item, build from itemToInfo() - \param data Attributes of the entries ( usually <= 1 ) for - the plot item. + \param itemInfo Info about a plot item, build from itemToInfo() + \param data Attributes of the entries ( usually <= 1 ) for + the plot item. - \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() - */ - void legendDataChanged( const QVariant& itemInfo, - const QList< QwtLegendData >& data ); + \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() + */ + void legendDataChanged(const QVariant &itemInfo, + const QList &data); - public Q_SLOTS: - virtual void replot(); - void autoRefresh(); +public Q_SLOTS: + virtual void replot(); + void autoRefresh(); - protected: +protected: + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; +private Q_SLOTS: + void updateLegendItems(const QVariant &itemInfo, + const QList &legendData); - private Q_SLOTS: - void updateLegendItems( const QVariant& itemInfo, - const QList< QwtLegendData >& legendData ); +private: + friend class QwtPlotItem; + void attachItem(QwtPlotItem *, bool); - private: - friend class QwtPlotItem; - void attachItem( QwtPlotItem*, bool ); + void initAxesData(); + void deleteAxesData(); + void updateScaleDiv(); - void initAxesData(); - void deleteAxesData(); - void updateScaleDiv(); + void initPlot(const QwtText &title); - void initPlot( const QwtText& title ); + class ScaleData; + ScaleData *m_scaleData; - class ScaleData; - ScaleData* m_scaleData; - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_abstract_barchart.cpp b/libs/qwt/src/qwt_plot_abstract_barchart.cpp index 0867eba5..ef90f502 100644 --- a/libs/qwt/src/qwt_plot_abstract_barchart.cpp +++ b/libs/qwt/src/qwt_plot_abstract_barchart.cpp @@ -11,55 +11,55 @@ #include "qwt_scale_map.h" #include "qwt_math.h" -static inline double qwtTransformWidth( - const QwtScaleMap& map, double value, double width ) +static inline double qwtTransformWidth(const QwtScaleMap &map, double value, + double width) { - const double w2 = 0.5 * width; + const double w2 = 0.5 * width; - const double v1 = map.transform( value - w2 ); - const double v2 = map.transform( value + w2 ); + const double v1 = map.transform(value - w2); + const double v2 = map.transform(value + w2); - return qAbs( v2 - v1 ); + return qAbs(v2 - v1); } class QwtPlotAbstractBarChart::PrivateData { - public: - PrivateData() - : layoutPolicy( QwtPlotAbstractBarChart::AutoAdjustSamples ) - , layoutHint( 0.5 ) - , spacing( 10 ) - , margin( 5 ) - , baseline( 0.0 ) - { - } +public: + PrivateData() + : layoutPolicy(QwtPlotAbstractBarChart::AutoAdjustSamples) + , layoutHint(0.5) + , spacing(10) + , margin(5) + , baseline(0.0) + { + } - QwtPlotAbstractBarChart::LayoutPolicy layoutPolicy; - double layoutHint; - int spacing; - int margin; - double baseline; + QwtPlotAbstractBarChart::LayoutPolicy layoutPolicy; + double layoutHint; + int spacing; + int margin; + double baseline; }; /*! Constructor \param title Title of the chart */ -QwtPlotAbstractBarChart::QwtPlotAbstractBarChart( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotAbstractBarChart::QwtPlotAbstractBarChart(const QwtText &title) + : QwtPlotSeriesItem(title) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemAttribute( QwtPlotItem::Legend, true ); - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Margins, true ); - setZ( 19.0 ); + setItemAttribute(QwtPlotItem::Legend, true); + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Margins, true); + setZ(19.0); } //! Destructor QwtPlotAbstractBarChart::~QwtPlotAbstractBarChart() { - delete m_data; + delete m_data; } /*! @@ -70,13 +70,13 @@ QwtPlotAbstractBarChart::~QwtPlotAbstractBarChart() \sa layoutPolicy(), layoutHint() */ -void QwtPlotAbstractBarChart::setLayoutPolicy( LayoutPolicy policy ) +void QwtPlotAbstractBarChart::setLayoutPolicy(LayoutPolicy policy) { - if ( policy != m_data->layoutPolicy ) - { - m_data->layoutPolicy = policy; - itemChanged(); - } + if (policy != m_data->layoutPolicy) + { + m_data->layoutPolicy = policy; + itemChanged(); + } } /*! @@ -86,9 +86,10 @@ void QwtPlotAbstractBarChart::setLayoutPolicy( LayoutPolicy policy ) \return Layout policy of the chart item \sa setLayoutPolicy(), layoutHint() */ -QwtPlotAbstractBarChart::LayoutPolicy QwtPlotAbstractBarChart::layoutPolicy() const +QwtPlotAbstractBarChart::LayoutPolicy +QwtPlotAbstractBarChart::layoutPolicy() const { - return m_data->layoutPolicy; + return m_data->layoutPolicy; } /*! @@ -99,14 +100,14 @@ QwtPlotAbstractBarChart::LayoutPolicy QwtPlotAbstractBarChart::layoutPolicy() co \sa LayoutPolicy, layoutPolicy(), layoutHint() */ -void QwtPlotAbstractBarChart::setLayoutHint( double hint ) +void QwtPlotAbstractBarChart::setLayoutHint(double hint) { - hint = qwtMaxF( 0.0, hint ); - if ( hint != m_data->layoutHint ) - { - m_data->layoutHint = hint; - itemChanged(); - } + hint = qwtMaxF(0.0, hint); + if (hint != m_data->layoutHint) + { + m_data->layoutHint = hint; + itemChanged(); + } } /*! @@ -118,7 +119,7 @@ void QwtPlotAbstractBarChart::setLayoutHint( double hint ) */ double QwtPlotAbstractBarChart::layoutHint() const { - return m_data->layoutHint; + return m_data->layoutHint; } /*! @@ -129,14 +130,14 @@ double QwtPlotAbstractBarChart::layoutHint() const \sa spacing() */ -void QwtPlotAbstractBarChart::setSpacing( int spacing ) +void QwtPlotAbstractBarChart::setSpacing(int spacing) { - spacing = qMax( spacing, 0 ); - if ( spacing != m_data->spacing ) - { - m_data->spacing = spacing; - itemChanged(); - } + spacing = qMax(spacing, 0); + if (spacing != m_data->spacing) + { + m_data->spacing = spacing; + itemChanged(); + } } /*! @@ -145,7 +146,7 @@ void QwtPlotAbstractBarChart::setSpacing( int spacing ) */ int QwtPlotAbstractBarChart::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! \brief Set the margin @@ -157,14 +158,14 @@ int QwtPlotAbstractBarChart::spacing() const \sa spacing(), margin() */ -void QwtPlotAbstractBarChart::setMargin( int margin ) +void QwtPlotAbstractBarChart::setMargin(int margin) { - margin = qMax( margin, 0 ); - if ( margin != m_data->margin ) - { - m_data->margin = margin; - itemChanged(); - } + margin = qMax(margin, 0); + if (margin != m_data->margin) + { + m_data->margin = margin; + itemChanged(); + } } /*! @@ -175,7 +176,7 @@ void QwtPlotAbstractBarChart::setMargin( int margin ) */ int QwtPlotAbstractBarChart::margin() const { - return m_data->margin; + return m_data->margin; } /*! @@ -192,13 +193,13 @@ int QwtPlotAbstractBarChart::margin() const \sa baseline(), QwtPlotSeriesItem::orientation() */ -void QwtPlotAbstractBarChart::setBaseline( double value ) +void QwtPlotAbstractBarChart::setBaseline(double value) { - if ( value != m_data->baseline ) - { - m_data->baseline = value; - itemChanged(); - } + if (value != m_data->baseline) + { + m_data->baseline = value; + itemChanged(); + } } /*! @@ -207,7 +208,7 @@ void QwtPlotAbstractBarChart::setBaseline( double value ) */ double QwtPlotAbstractBarChart::baseline() const { - return m_data->baseline; + return m_data->baseline; } /*! @@ -222,46 +223,44 @@ double QwtPlotAbstractBarChart::baseline() const \return Sample width \sa layoutPolicy(), layoutHint() */ -double QwtPlotAbstractBarChart::sampleWidth( const QwtScaleMap& map, - double canvasSize, double boundingSize, double value ) const +double QwtPlotAbstractBarChart::sampleWidth(const QwtScaleMap &map, + double canvasSize, + double boundingSize, + double value) const { - double width; + double width; - switch( m_data->layoutPolicy ) - { - case ScaleSamplesToAxes: - { - width = qwtTransformWidth( map, value, m_data->layoutHint ); - break; - } - case ScaleSampleToCanvas: - { - width = canvasSize * m_data->layoutHint; - break; - } - case FixedSampleSize: - { - width = m_data->layoutHint; - break; - } - case AutoAdjustSamples: - default: - { - const int numSamples = dataSize(); - - double w = 1.0; - if ( numSamples > 1 ) - { - w = qAbs( boundingSize / ( numSamples - 1 ) ); - } - - width = qwtTransformWidth( map, value, w ); - width -= m_data->spacing; - width = qwtMaxF( width, m_data->layoutHint ); - } + switch (m_data->layoutPolicy) + { + case ScaleSamplesToAxes: { + width = qwtTransformWidth(map, value, m_data->layoutHint); + break; } + case ScaleSampleToCanvas: { + width = canvasSize * m_data->layoutHint; + break; + } + case FixedSampleSize: { + width = m_data->layoutHint; + break; + } + case AutoAdjustSamples: + default: { + const int numSamples = dataSize(); - return width; + double w = 1.0; + if (numSamples > 1) + { + w = qAbs(boundingSize / (numSamples - 1)); + } + + width = qwtTransformWidth(map, value, w); + width -= m_data->spacing; + width = qwtMaxF(width, m_data->layoutHint); + } + } + + return width; } /*! @@ -286,84 +285,81 @@ double QwtPlotAbstractBarChart::sampleWidth( const QwtScaleMap& map, \sa layoutPolicy(), layoutHint(), QwtPlotItem::Margins QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins() */ -void QwtPlotAbstractBarChart::getCanvasMarginHint( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QRectF& canvasRect, - double& left, double& top, double& right, double& bottom ) const +void QwtPlotAbstractBarChart::getCanvasMarginHint( + const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, + double &left, double &top, double &right, double &bottom) const { - double hint = -1.0; + double hint = -1.0; - switch( layoutPolicy() ) - { - case ScaleSampleToCanvas: - { - if ( orientation() == Qt::Vertical ) - hint = 0.5 * canvasRect.width() * m_data->layoutHint; - else - hint = 0.5 * canvasRect.height() * m_data->layoutHint; + switch (layoutPolicy()) + { + case ScaleSampleToCanvas: { + if (orientation() == Qt::Vertical) + hint = 0.5 * canvasRect.width() * m_data->layoutHint; + else + hint = 0.5 * canvasRect.height() * m_data->layoutHint; - break; - } - case FixedSampleSize: - { - hint = 0.5 * m_data->layoutHint; - break; - } - case AutoAdjustSamples: - case ScaleSamplesToAxes: - default: - { - const int numSamples = dataSize(); - if ( numSamples <= 0 ) - break; - - // doesn't work for nonlinear scales - - const QRectF br = dataRect(); - double spacing = 0.0; - double sampleWidthS = 1.0; - - if ( layoutPolicy() == ScaleSamplesToAxes ) - { - sampleWidthS = qwtMaxF( m_data->layoutHint, 0.0 ); - } - else - { - spacing = m_data->spacing; - - if ( numSamples > 1 ) - { - sampleWidthS = qAbs( br.width() / ( numSamples - 1 ) ); - } - } - - double ds, w; - if ( orientation() == Qt::Vertical ) - { - ds = qAbs( xMap.sDist() ); - w = canvasRect.width(); - } - else - { - ds = qAbs( yMap.sDist() ); - w = canvasRect.height(); - } - - const double sampleWidthP = ( w - spacing * ( numSamples - 1 ) ) - * sampleWidthS / ( ds + sampleWidthS ); - - hint = 0.5 * sampleWidthP; - hint += qMax( m_data->margin, 0 ); - } + break; } + case FixedSampleSize: { + hint = 0.5 * m_data->layoutHint; + break; + } + case AutoAdjustSamples: + case ScaleSamplesToAxes: + default: { + const int numSamples = dataSize(); + if (numSamples <= 0) + break; - if ( orientation() == Qt::Vertical ) - { - left = right = hint; - top = bottom = -1.0; // no hint - } - else - { - left = right = -1.0; // no hint - top = bottom = hint; + // doesn't work for nonlinear scales + + const QRectF br = dataRect(); + double spacing = 0.0; + double sampleWidthS = 1.0; + + if (layoutPolicy() == ScaleSamplesToAxes) + { + sampleWidthS = qwtMaxF(m_data->layoutHint, 0.0); + } + else + { + spacing = m_data->spacing; + + if (numSamples > 1) + { + sampleWidthS = qAbs(br.width() / (numSamples - 1)); + } + } + + double ds, w; + if (orientation() == Qt::Vertical) + { + ds = qAbs(xMap.sDist()); + w = canvasRect.width(); + } + else + { + ds = qAbs(yMap.sDist()); + w = canvasRect.height(); + } + + const double sampleWidthP = (w - spacing * (numSamples - 1)) + * sampleWidthS / (ds + sampleWidthS); + + hint = 0.5 * sampleWidthP; + hint += qMax(m_data->margin, 0); } + } + + if (orientation() == Qt::Vertical) + { + left = right = hint; + top = bottom = -1.0; // no hint + } + else + { + left = right = -1.0; // no hint + top = bottom = hint; + } } diff --git a/libs/qwt/src/qwt_plot_abstract_barchart.h b/libs/qwt/src/qwt_plot_abstract_barchart.h index 9d2b1651..7c303da7 100644 --- a/libs/qwt/src/qwt_plot_abstract_barchart.h +++ b/libs/qwt/src/qwt_plot_abstract_barchart.h @@ -23,74 +23,73 @@ */ class QWT_EXPORT QwtPlotAbstractBarChart : public QwtPlotSeriesItem { - public: +public: + /*! + \brief Mode how to calculate the bar width + + setLayoutPolicy(), setLayoutHint(), barWidthHint() + */ + enum LayoutPolicy + { /*! - \brief Mode how to calculate the bar width + The sample width is calculated by dividing the bounding rectangle + by the number of samples. The layoutHint() is used as a minimum width + in paint device coordinates. - setLayoutPolicy(), setLayoutHint(), barWidthHint() + \sa boundingRectangle() */ - enum LayoutPolicy - { - /*! - The sample width is calculated by dividing the bounding rectangle - by the number of samples. The layoutHint() is used as a minimum width - in paint device coordinates. + AutoAdjustSamples, - \sa boundingRectangle() - */ - AutoAdjustSamples, + /*! + layoutHint() defines an interval in axis coordinates + */ + ScaleSamplesToAxes, - /*! - layoutHint() defines an interval in axis coordinates - */ - ScaleSamplesToAxes, + /*! + The bar width is calculated by multiplying layoutHint() + with the height or width of the canvas. - /*! - The bar width is calculated by multiplying layoutHint() - with the height or width of the canvas. + \sa boundingRectangle() + */ + ScaleSampleToCanvas, - \sa boundingRectangle() - */ - ScaleSampleToCanvas, + /*! + layoutHint() defines a fixed width in paint device coordinates. + */ + FixedSampleSize + }; - /*! - layoutHint() defines a fixed width in paint device coordinates. - */ - FixedSampleSize - }; + explicit QwtPlotAbstractBarChart(const QwtText &title); + virtual ~QwtPlotAbstractBarChart(); - explicit QwtPlotAbstractBarChart( const QwtText& title ); - virtual ~QwtPlotAbstractBarChart(); + void setLayoutPolicy(LayoutPolicy); + LayoutPolicy layoutPolicy() const; - void setLayoutPolicy( LayoutPolicy ); - LayoutPolicy layoutPolicy() const; + void setLayoutHint(double); + double layoutHint() const; - void setLayoutHint( double ); - double layoutHint() const; + void setSpacing(int); + int spacing() const; - void setSpacing( int ); - int spacing() const; + void setMargin(int); + int margin() const; - void setMargin( int ); - int margin() const; + void setBaseline(double); + double baseline() const; - void setBaseline( double ); - double baseline() const; + virtual void getCanvasMarginHint(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, double &left, + double &top, double &right, + double &bottom) const QWT_OVERRIDE; - virtual void getCanvasMarginHint( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, double& left, double& top, - double& right, double& bottom) const QWT_OVERRIDE; +protected: + double sampleWidth(const QwtScaleMap &map, double canvasSize, + double boundingSize, double value) const; - - protected: - double sampleWidth( const QwtScaleMap& map, - double canvasSize, double boundingSize, - double value ) const; - - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_abstract_canvas.cpp b/libs/qwt/src/qwt_plot_abstract_canvas.cpp index d52312fe..dc50b18c 100644 --- a/libs/qwt/src/qwt_plot_abstract_canvas.cpp +++ b/libs/qwt/src/qwt_plot_abstract_canvas.cpp @@ -20,544 +20,528 @@ namespace { - class QwtStyleSheetRecorder QWT_FINAL : public QwtNullPaintDevice - { - public: - explicit QwtStyleSheetRecorder( const QSize& size ) - : m_size( size ) - { - } - - virtual void updateState( const QPaintEngineState& state ) QWT_OVERRIDE - { - if ( state.state() & QPaintEngine::DirtyPen ) - { - m_pen = state.pen(); - } - if ( state.state() & QPaintEngine::DirtyBrush ) - { - m_brush = state.brush(); - } - if ( state.state() & QPaintEngine::DirtyBrushOrigin ) - { - m_origin = state.brushOrigin(); - } - } - - virtual void drawRects(const QRectF* rects, int count ) QWT_OVERRIDE - { - for ( int i = 0; i < count; i++ ) - border.rectList += rects[i]; - } - - virtual void drawRects(const QRect* rects, int count ) QWT_OVERRIDE - { - for ( int i = 0; i < count; i++ ) - border.rectList += rects[i]; - } - - virtual void drawPath( const QPainterPath& path ) QWT_OVERRIDE - { - const QRectF rect( QPointF( 0.0, 0.0 ), m_size ); - if ( path.controlPointRect().contains( rect.center() ) ) - { - setCornerRects( path ); - alignCornerRects( rect ); - - background.path = path; - background.brush = m_brush; - background.origin = m_origin; - } - else - { - border.pathList += path; - } - } - - void setCornerRects( const QPainterPath& path ) - { - QPointF pos( 0.0, 0.0 ); - - for ( int i = 0; i < path.elementCount(); i++ ) - { - QPainterPath::Element el = path.elementAt(i); - switch( el.type ) - { - case QPainterPath::MoveToElement: - case QPainterPath::LineToElement: - { - pos.setX( el.x ); - pos.setY( el.y ); - break; - } - case QPainterPath::CurveToElement: - { - QRectF r( pos, QPointF( el.x, el.y ) ); - clipRects += r.normalized(); - - pos.setX( el.x ); - pos.setY( el.y ); - - break; - } - case QPainterPath::CurveToDataElement: - { - if ( clipRects.size() > 0 ) - { - QRectF r = clipRects.last(); - r.setCoords( - qwtMinF( r.left(), el.x ), - qwtMinF( r.top(), el.y ), - qwtMaxF( r.right(), el.x ), - qwtMaxF( r.bottom(), el.y ) - ); - clipRects.last() = r.normalized(); - } - break; - } - } - } - } - - protected: - virtual QSize sizeMetrics() const QWT_OVERRIDE - { - return m_size; - } - - private: - void alignCornerRects( const QRectF& rect ) - { - for ( int i = 0; i < clipRects.size(); i++ ) - { - QRectF& r = clipRects[i]; - if ( r.center().x() < rect.center().x() ) - r.setLeft( rect.left() ); - else - r.setRight( rect.right() ); - - if ( r.center().y() < rect.center().y() ) - r.setTop( rect.top() ); - else - r.setBottom( rect.bottom() ); - } - } - - - public: - QVector< QRectF > clipRects; - - struct Border - { - QList< QPainterPath > pathList; - QList< QRectF > rectList; - QRegion clipRegion; - } border; - - struct Background - { - QPainterPath path; - QBrush brush; - QPointF origin; - } background; - - private: - const QSize m_size; - - QPen m_pen; - QBrush m_brush; - QPointF m_origin; - }; -} - -static void qwtUpdateContentsRect( int fw, QWidget* canvas ) +class QwtStyleSheetRecorder QWT_FINAL : public QwtNullPaintDevice { - canvas->setContentsMargins( fw, fw, fw, fw ); +public: + explicit QwtStyleSheetRecorder(const QSize &size) + : m_size(size) + { + } + + virtual void updateState(const QPaintEngineState &state) QWT_OVERRIDE + { + if (state.state() & QPaintEngine::DirtyPen) + { + m_pen = state.pen(); + } + if (state.state() & QPaintEngine::DirtyBrush) + { + m_brush = state.brush(); + } + if (state.state() & QPaintEngine::DirtyBrushOrigin) + { + m_origin = state.brushOrigin(); + } + } + + virtual void drawRects(const QRectF *rects, int count) QWT_OVERRIDE + { + for (int i = 0; i < count; i++) + border.rectList += rects[i]; + } + + virtual void drawRects(const QRect *rects, int count) QWT_OVERRIDE + { + for (int i = 0; i < count; i++) + border.rectList += rects[i]; + } + + virtual void drawPath(const QPainterPath &path) QWT_OVERRIDE + { + const QRectF rect(QPointF(0.0, 0.0), m_size); + if (path.controlPointRect().contains(rect.center())) + { + setCornerRects(path); + alignCornerRects(rect); + + background.path = path; + background.brush = m_brush; + background.origin = m_origin; + } + else + { + border.pathList += path; + } + } + + void setCornerRects(const QPainterPath &path) + { + QPointF pos(0.0, 0.0); + + for (int i = 0; i < path.elementCount(); i++) + { + QPainterPath::Element el = path.elementAt(i); + switch (el.type) + { + case QPainterPath::MoveToElement: + case QPainterPath::LineToElement: { + pos.setX(el.x); + pos.setY(el.y); + break; + } + case QPainterPath::CurveToElement: { + QRectF r(pos, QPointF(el.x, el.y)); + clipRects += r.normalized(); + + pos.setX(el.x); + pos.setY(el.y); + + break; + } + case QPainterPath::CurveToDataElement: { + if (clipRects.size() > 0) + { + QRectF r = clipRects.last(); + r.setCoords(qwtMinF(r.left(), el.x), qwtMinF(r.top(), el.y), + qwtMaxF(r.right(), el.x), qwtMaxF(r.bottom(), el.y)); + clipRects.last() = r.normalized(); + } + break; + } + } + } + } + +protected: + virtual QSize sizeMetrics() const QWT_OVERRIDE { return m_size; } + +private: + void alignCornerRects(const QRectF &rect) + { + for (int i = 0; i < clipRects.size(); i++) + { + QRectF &r = clipRects[i]; + if (r.center().x() < rect.center().x()) + r.setLeft(rect.left()); + else + r.setRight(rect.right()); + + if (r.center().y() < rect.center().y()) + r.setTop(rect.top()); + else + r.setBottom(rect.bottom()); + } + } + +public: + QVector clipRects; + + struct Border + { + QList pathList; + QList rectList; + QRegion clipRegion; + } border; + + struct Background + { + QPainterPath path; + QBrush brush; + QPointF origin; + } background; + +private: + const QSize m_size; + + QPen m_pen; + QBrush m_brush; + QPointF m_origin; +}; +} // namespace + +static void qwtUpdateContentsRect(int fw, QWidget *canvas) +{ + canvas->setContentsMargins(fw, fw, fw, fw); } -static void qwtFillRegion( QPainter* painter, const QRegion& region ) +static void qwtFillRegion(QPainter *painter, const QRegion ®ion) { #if QT_VERSION >= 0x050800 - for ( QRegion::const_iterator it = region.cbegin(); - it != region.cend(); ++it ) - { - painter->drawRect( *it ); - } + for (QRegion::const_iterator it = region.cbegin(); it != region.cend(); ++it) + { + painter->drawRect(*it); + } #else - painter->drawRects( region.rects() ); + painter->drawRects(region.rects()); #endif } -static void qwtDrawBackground( QPainter* painter, QWidget* canvas ) +static void qwtDrawBackground(QPainter *painter, QWidget *canvas) { - painter->save(); + painter->save(); - QPainterPath borderClip; + QPainterPath borderClip; - ( void )QMetaObject::invokeMethod( - canvas, "borderPath", Qt::DirectConnection, - Q_RETURN_ARG( QPainterPath, borderClip ), Q_ARG( QRect, canvas->rect() ) ); + (void)QMetaObject::invokeMethod(canvas, "borderPath", Qt::DirectConnection, + Q_RETURN_ARG(QPainterPath, borderClip), + Q_ARG(QRect, canvas->rect())); - if ( !borderClip.isEmpty() ) - painter->setClipPath( borderClip, Qt::IntersectClip ); + if (!borderClip.isEmpty()) + painter->setClipPath(borderClip, Qt::IntersectClip); - const QBrush& brush = canvas->palette().brush( canvas->backgroundRole() ); + const QBrush &brush = canvas->palette().brush(canvas->backgroundRole()); - if ( brush.style() == Qt::TexturePattern ) + if (brush.style() == Qt::TexturePattern) + { + QPixmap pm(canvas->size()); + QwtPainter::fillPixmap(canvas, pm); + painter->drawPixmap(0, 0, pm); + } + else if (brush.gradient()) + { + const bool fillClipRegion + = brush.gradient()->coordinateMode() != QGradient::ObjectBoundingMode; + + painter->setPen(Qt::NoPen); + painter->setBrush(brush); + + if (fillClipRegion) + qwtFillRegion(painter, painter->clipRegion()); + else + painter->drawRect(canvas->rect()); + } + else + { + painter->setPen(Qt::NoPen); + painter->setBrush(brush); + qwtFillRegion(painter, painter->clipRegion()); + } + + painter->restore(); +} + +static inline void qwtDrawStyledBackground(QWidget *w, QPainter *painter) +{ + QStyleOption opt; + opt.initFrom(w); + w->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, w); +} + +static QWidget *qwtBackgroundWidget(QWidget *w) +{ + if (w->parentWidget() == NULL) + return w; + + if (w->autoFillBackground()) + { + const QBrush brush = w->palette().brush(w->backgroundRole()); + if (brush.color().alpha() > 0) + return w; + } + + if (w->testAttribute(Qt::WA_StyledBackground)) + { + QImage image(1, 1, QImage::Format_ARGB32); + image.fill(Qt::transparent); + + QPainter painter(&image); + painter.translate(-w->rect().center()); + qwtDrawStyledBackground(w, &painter); + painter.end(); + + if (qAlpha(image.pixel(0, 0)) != 0) + return w; + } + + return qwtBackgroundWidget(w->parentWidget()); +} + +static void qwtFillBackground(QPainter *painter, QWidget *widget, + const QVector &fillRects) +{ + if (fillRects.isEmpty()) + return; + + QRegion clipRegion; + if (painter->hasClipping()) + clipRegion = painter->transform().map(painter->clipRegion()); + else + clipRegion = widget->contentsRect(); + + // Try to find out which widget fills + // the unfilled areas of the styled background + + QWidget *bgWidget = qwtBackgroundWidget(widget->parentWidget()); + + for (int i = 0; i < fillRects.size(); i++) + { + const QRect rect = fillRects[i].toAlignedRect(); + if (clipRegion.intersects(rect)) { - QPixmap pm( canvas->size() ); - QwtPainter::fillPixmap( canvas, pm ); - painter->drawPixmap( 0, 0, pm ); + QPixmap pm(rect.size()); + QwtPainter::fillPixmap(bgWidget, pm, + widget->mapTo(bgWidget, rect.topLeft())); + painter->drawPixmap(rect, pm); } - else if ( brush.gradient() ) + } +} + +static void qwtFillBackground(QPainter *painter, QWidget *canvas) +{ + QVector rects; + + if (canvas->testAttribute(Qt::WA_StyledBackground)) + { + QwtStyleSheetRecorder recorder(canvas->size()); + + QPainter p(&recorder); + qwtDrawStyledBackground(canvas, &p); + p.end(); + + if (recorder.background.brush.isOpaque()) + rects = recorder.clipRects; + else + rects += canvas->rect(); + } + else + { + const double borderRadius = canvas->property("borderRadius").toDouble(); + if (borderRadius > 0.0) { - const bool fillClipRegion = - brush.gradient()->coordinateMode() != QGradient::ObjectBoundingMode; + QSizeF sz(borderRadius, borderRadius); - painter->setPen( Qt::NoPen ); - painter->setBrush( brush ); + const QRectF r = canvas->rect(); + rects += QRectF(r.topLeft(), sz); + rects += QRectF(r.topRight() - QPointF(borderRadius, 0), sz); + rects + += QRectF(r.bottomRight() - QPointF(borderRadius, borderRadius), sz); + rects += QRectF(r.bottomLeft() - QPointF(0, borderRadius), sz); + } + } - if ( fillClipRegion ) - qwtFillRegion( painter, painter->clipRegion() ); + qwtFillBackground(painter, canvas, rects); +} + +static inline void qwtRevertPath(QPainterPath &path) +{ + if (path.elementCount() == 4) + { + QPainterPath::Element el0 = path.elementAt(0); + QPainterPath::Element el3 = path.elementAt(3); + + path.setElementPositionAt(0, el3.x, el3.y); + path.setElementPositionAt(3, el0.x, el0.y); + } +} + +static QPainterPath qwtCombinePathList(const QRectF &rect, + const QList &pathList) +{ + if (pathList.isEmpty()) + return QPainterPath(); + + QPainterPath ordered[8]; // starting top left + + for (int i = 0; i < pathList.size(); i++) + { + int index = -1; + QPainterPath subPath = pathList[i]; + + const QRectF br = pathList[i].controlPointRect(); + if (br.center().x() < rect.center().x()) + { + if (br.center().y() < rect.center().y()) + { + if (qAbs(br.top() - rect.top()) < qAbs(br.left() - rect.left())) + { + index = 1; + } else - painter->drawRect( canvas->rect() ); + { + index = 0; + } + } + else + { + if (qAbs(br.bottom() - rect.bottom()) < qAbs(br.left() - rect.left())) + { + index = 6; + } + else + { + index = 7; + } + } + + if (subPath.currentPosition().y() > br.center().y()) + qwtRevertPath(subPath); } else { - painter->setPen( Qt::NoPen ); - painter->setBrush( brush ); - qwtFillRegion( painter, painter->clipRegion() ); - } - - painter->restore(); -} - -static inline void qwtDrawStyledBackground( - QWidget* w, QPainter* painter ) -{ - QStyleOption opt; - opt.initFrom(w); - w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w); -} - -static QWidget* qwtBackgroundWidget( QWidget* w ) -{ - if ( w->parentWidget() == NULL ) - return w; - - if ( w->autoFillBackground() ) - { - const QBrush brush = w->palette().brush( w->backgroundRole() ); - if ( brush.color().alpha() > 0 ) - return w; - } - - if ( w->testAttribute( Qt::WA_StyledBackground ) ) - { - QImage image( 1, 1, QImage::Format_ARGB32 ); - image.fill( Qt::transparent ); - - QPainter painter( &image ); - painter.translate( -w->rect().center() ); - qwtDrawStyledBackground( w, &painter ); - painter.end(); - - if ( qAlpha( image.pixel( 0, 0 ) ) != 0 ) - return w; - } - - return qwtBackgroundWidget( w->parentWidget() ); -} - -static void qwtFillBackground( QPainter* painter, - QWidget* widget, const QVector< QRectF >& fillRects ) -{ - if ( fillRects.isEmpty() ) - return; - - QRegion clipRegion; - if ( painter->hasClipping() ) - clipRegion = painter->transform().map( painter->clipRegion() ); - else - clipRegion = widget->contentsRect(); - - // Try to find out which widget fills - // the unfilled areas of the styled background - - QWidget* bgWidget = qwtBackgroundWidget( widget->parentWidget() ); - - for ( int i = 0; i < fillRects.size(); i++ ) - { - const QRect rect = fillRects[i].toAlignedRect(); - if ( clipRegion.intersects( rect ) ) + if (br.center().y() < rect.center().y()) + { + if (qAbs(br.top() - rect.top()) < qAbs(br.right() - rect.right())) { - QPixmap pm( rect.size() ); - QwtPainter::fillPixmap( bgWidget, pm, widget->mapTo( bgWidget, rect.topLeft() ) ); - painter->drawPixmap( rect, pm ); + index = 2; } - } -} - -static void qwtFillBackground( QPainter* painter, QWidget* canvas ) -{ - QVector< QRectF > rects; - - if ( canvas->testAttribute( Qt::WA_StyledBackground ) ) - { - QwtStyleSheetRecorder recorder( canvas->size() ); - - QPainter p( &recorder ); - qwtDrawStyledBackground( canvas, &p ); - p.end(); - - if ( recorder.background.brush.isOpaque() ) - rects = recorder.clipRects; else - rects += canvas->rect(); + { + index = 3; + } + } + else + { + if (qAbs(br.bottom() - rect.bottom()) < qAbs(br.right() - rect.right())) + { + index = 5; + } + else + { + index = 4; + } + } + if (subPath.currentPosition().y() < br.center().y()) + qwtRevertPath(subPath); + } + ordered[index] = subPath; + } + + for (int i = 0; i < 4; i++) + { + if (ordered[2 * i].isEmpty() != ordered[2 * i + 1].isEmpty()) + { + // we don't accept incomplete rounded borders + return QPainterPath(); + } + } + + const QPolygonF corners(rect); + + QPainterPath path; + // path.moveTo( rect.topLeft() ); + + for (int i = 0; i < 4; i++) + { + if (ordered[2 * i].isEmpty()) + { + path.lineTo(corners[i]); } else { - const double borderRadius = canvas->property( "borderRadius" ).toDouble(); - if ( borderRadius > 0.0 ) - { - QSizeF sz( borderRadius, borderRadius ); - - const QRectF r = canvas->rect(); - rects += QRectF( r.topLeft(), sz ); - rects += QRectF( r.topRight() - QPointF( borderRadius, 0 ), sz ); - rects += QRectF( r.bottomRight() - QPointF( borderRadius, borderRadius ), sz ); - rects += QRectF( r.bottomLeft() - QPointF( 0, borderRadius ), sz ); - } + path.connectPath(ordered[2 * i]); + path.connectPath(ordered[2 * i + 1]); } + } - qwtFillBackground( painter, canvas, rects); -} - -static inline void qwtRevertPath( QPainterPath& path ) -{ - if ( path.elementCount() == 4 ) - { - QPainterPath::Element el0 = path.elementAt(0); - QPainterPath::Element el3 = path.elementAt(3); - - path.setElementPositionAt( 0, el3.x, el3.y ); - path.setElementPositionAt( 3, el0.x, el0.y ); - } -} - -static QPainterPath qwtCombinePathList( const QRectF& rect, - const QList< QPainterPath >& pathList ) -{ - if ( pathList.isEmpty() ) - return QPainterPath(); - - QPainterPath ordered[8]; // starting top left - - for ( int i = 0; i < pathList.size(); i++ ) - { - int index = -1; - QPainterPath subPath = pathList[i]; - - const QRectF br = pathList[i].controlPointRect(); - if ( br.center().x() < rect.center().x() ) - { - if ( br.center().y() < rect.center().y() ) - { - if ( qAbs( br.top() - rect.top() ) < - qAbs( br.left() - rect.left() ) ) - { - index = 1; - } - else - { - index = 0; - } - } - else - { - if ( qAbs( br.bottom() - rect.bottom() ) < - qAbs( br.left() - rect.left() ) ) - { - index = 6; - } - else - { - index = 7; - } - } - - if ( subPath.currentPosition().y() > br.center().y() ) - qwtRevertPath( subPath ); - } - else - { - if ( br.center().y() < rect.center().y() ) - { - if ( qAbs( br.top() - rect.top() ) < - qAbs( br.right() - rect.right() ) ) - { - index = 2; - } - else - { - index = 3; - } - } - else - { - if ( qAbs( br.bottom() - rect.bottom() ) < - qAbs( br.right() - rect.right() ) ) - { - index = 5; - } - else - { - index = 4; - } - } - if ( subPath.currentPosition().y() < br.center().y() ) - qwtRevertPath( subPath ); - } - ordered[index] = subPath; - } - - for ( int i = 0; i < 4; i++ ) - { - if ( ordered[ 2 * i].isEmpty() != ordered[2 * i + 1].isEmpty() ) - { - // we don't accept incomplete rounded borders - return QPainterPath(); - } - } - - - const QPolygonF corners( rect ); - - QPainterPath path; - //path.moveTo( rect.topLeft() ); - - for ( int i = 0; i < 4; i++ ) - { - if ( ordered[2 * i].isEmpty() ) - { - path.lineTo( corners[i] ); - } - else - { - path.connectPath( ordered[2 * i] ); - path.connectPath( ordered[2 * i + 1] ); - } - } - - path.closeSubpath(); + path.closeSubpath(); #if 0 return path.simplified(); #else - return path; + return path; #endif } -static QPainterPath qwtBorderPath( const QWidget* canvas, const QRect& rect ) +static QPainterPath qwtBorderPath(const QWidget *canvas, const QRect &rect) { - if ( canvas->testAttribute(Qt::WA_StyledBackground ) ) + if (canvas->testAttribute(Qt::WA_StyledBackground)) + { + QwtStyleSheetRecorder recorder(rect.size()); + + QPainter painter(&recorder); + + QStyleOption opt; + opt.initFrom(canvas); + opt.rect = rect; + canvas->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, canvas); + + painter.end(); + + if (!recorder.background.path.isEmpty()) + return recorder.background.path; + + if (!recorder.border.rectList.isEmpty()) + return qwtCombinePathList(rect, recorder.border.pathList); + } + else + { + const double borderRadius = canvas->property("borderRadius").toDouble(); + + if (borderRadius > 0.0) { - QwtStyleSheetRecorder recorder( rect.size() ); + double fw2 = canvas->property("frameWidth").toInt() * 0.5; + QRectF r = QRectF(rect).adjusted(fw2, fw2, -fw2, -fw2); - QPainter painter( &recorder ); - - QStyleOption opt; - opt.initFrom( canvas ); - opt.rect = rect; - canvas->style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, canvas ); - - painter.end(); - - if ( !recorder.background.path.isEmpty() ) - return recorder.background.path; - - if ( !recorder.border.rectList.isEmpty() ) - return qwtCombinePathList( rect, recorder.border.pathList ); + QPainterPath path; + path.addRoundedRect(r, borderRadius, borderRadius); + return path; } - else - { - const double borderRadius = canvas->property( "borderRadius" ).toDouble(); + } - if ( borderRadius > 0.0 ) - { - double fw2 = canvas->property( "frameWidth" ).toInt() * 0.5; - QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 ); - - QPainterPath path; - path.addRoundedRect( r, borderRadius, borderRadius ); - return path; - } - } - - return QPainterPath(); + return QPainterPath(); } class QwtPlotAbstractCanvas::PrivateData { - public: - PrivateData() - : focusIndicator( NoFocusIndicator ) - , borderRadius( 0 ) +public: + PrivateData() + : focusIndicator(NoFocusIndicator) + , borderRadius(0) + { + styleSheet.hasBorder = false; + } + + FocusIndicator focusIndicator; + double borderRadius; + + struct StyleSheet + { + bool hasBorder; + QPainterPath borderPath; + QVector cornerRects; + + struct StyleSheetBackground { - styleSheet.hasBorder = false; - } + QBrush brush; + QPointF origin; + } background; - FocusIndicator focusIndicator; - double borderRadius; + } styleSheet; - struct StyleSheet - { - bool hasBorder; - QPainterPath borderPath; - QVector< QRectF > cornerRects; - - struct StyleSheetBackground - { - QBrush brush; - QPointF origin; - } background; - - } styleSheet; - - QWidget* canvasWidget; + QWidget *canvasWidget; }; /*! \brief Constructor \param canvasWidget plot canvas widget */ -QwtPlotAbstractCanvas::QwtPlotAbstractCanvas( QWidget* canvasWidget ) +QwtPlotAbstractCanvas::QwtPlotAbstractCanvas(QWidget *canvasWidget) { - m_data = new PrivateData; - m_data->canvasWidget = canvasWidget; + m_data = new PrivateData; + m_data->canvasWidget = canvasWidget; #ifndef QT_NO_CURSOR - canvasWidget->setCursor( Qt::CrossCursor ); + canvasWidget->setCursor(Qt::CrossCursor); #endif - canvasWidget->setAutoFillBackground( true ); + canvasWidget->setAutoFillBackground(true); } //! Destructor QwtPlotAbstractCanvas::~QwtPlotAbstractCanvas() { - delete m_data; + delete m_data; } //! Return parent plot widget -QwtPlot* QwtPlotAbstractCanvas::plot() +QwtPlot *QwtPlotAbstractCanvas::plot() { - return qobject_cast< QwtPlot* >( m_data->canvasWidget->parent() ); + return qobject_cast(m_data->canvasWidget->parent()); } //! Return parent plot widget -const QwtPlot* QwtPlotAbstractCanvas::plot() const +const QwtPlot *QwtPlotAbstractCanvas::plot() const { - return qobject_cast< const QwtPlot* >( m_data->canvasWidget->parent() ); + return qobject_cast(m_data->canvasWidget->parent()); } /*! @@ -565,9 +549,9 @@ const QwtPlot* QwtPlotAbstractCanvas::plot() const \sa FocusIndicator, focusIndicator() */ -void QwtPlotAbstractCanvas::setFocusIndicator( FocusIndicator focusIndicator ) +void QwtPlotAbstractCanvas::setFocusIndicator(FocusIndicator focusIndicator) { - m_data->focusIndicator = focusIndicator; + m_data->focusIndicator = focusIndicator; } /*! @@ -575,24 +559,26 @@ void QwtPlotAbstractCanvas::setFocusIndicator( FocusIndicator focusIndicator ) \sa FocusIndicator, setFocusIndicator() */ -QwtPlotAbstractCanvas::FocusIndicator QwtPlotAbstractCanvas::focusIndicator() const +QwtPlotAbstractCanvas::FocusIndicator +QwtPlotAbstractCanvas::focusIndicator() const { - return m_data->focusIndicator; + return m_data->focusIndicator; } /*! Draw the focus indication \param painter Painter */ -void QwtPlotAbstractCanvas::drawFocusIndicator( QPainter* painter ) +void QwtPlotAbstractCanvas::drawFocusIndicator(QPainter *painter) { - const int margin = 1; + const int margin = 1; - QRect focusRect = m_data->canvasWidget->contentsRect(); - focusRect.setRect( focusRect.x() + margin, focusRect.y() + margin, - focusRect.width() - 2 * margin, focusRect.height() - 2 * margin ); + QRect focusRect = m_data->canvasWidget->contentsRect(); + focusRect.setRect(focusRect.x() + margin, focusRect.y() + margin, + focusRect.width() - 2 * margin, + focusRect.height() - 2 * margin); - QwtPainter::drawFocusRect( painter, m_data->canvasWidget, focusRect ); + QwtPainter::drawFocusRect(painter, m_data->canvasWidget, focusRect); } /*! @@ -601,9 +587,9 @@ void QwtPlotAbstractCanvas::drawFocusIndicator( QPainter* painter ) \param radius Radius of a rounded corner \sa borderRadius() */ -void QwtPlotAbstractCanvas::setBorderRadius( double radius ) +void QwtPlotAbstractCanvas::setBorderRadius(double radius) { - m_data->borderRadius = qwtMaxF( 0.0, radius ); + m_data->borderRadius = qwtMaxF(0.0, radius); } /*! @@ -612,308 +598,306 @@ void QwtPlotAbstractCanvas::setBorderRadius( double radius ) */ double QwtPlotAbstractCanvas::borderRadius() const { - return m_data->borderRadius; + return m_data->borderRadius; } //! \return Path for the canvas border -QPainterPath QwtPlotAbstractCanvas::canvasBorderPath( const QRect& rect ) const +QPainterPath QwtPlotAbstractCanvas::canvasBorderPath(const QRect &rect) const { - return qwtBorderPath( canvasWidget(), rect ); + return qwtBorderPath(canvasWidget(), rect); } /*! Draw the border of the canvas \param painter Painter */ -void QwtPlotAbstractCanvas::drawBorder( QPainter* painter ) +void QwtPlotAbstractCanvas::drawBorder(QPainter *painter) { - const QWidget* w = canvasWidget(); + const QWidget *w = canvasWidget(); - if ( m_data->borderRadius > 0 ) + if (m_data->borderRadius > 0) + { + const int frameWidth = w->property("frameWidth").toInt(); + if (frameWidth > 0) { - const int frameWidth = w->property( "frameWidth" ).toInt(); - if ( frameWidth > 0 ) - { - const int frameShape = w->property( "frameShape" ).toInt(); - const int frameShadow = w->property( "frameShadow" ).toInt(); + const int frameShape = w->property("frameShape").toInt(); + const int frameShadow = w->property("frameShadow").toInt(); - const QRectF frameRect = w->property( "frameRect" ).toRect(); + const QRectF frameRect = w->property("frameRect").toRect(); - QwtPainter::drawRoundedFrame( painter, frameRect, - m_data->borderRadius, m_data->borderRadius, - w->palette(), frameWidth, frameShape | frameShadow ); - } + QwtPainter::drawRoundedFrame(painter, frameRect, m_data->borderRadius, + m_data->borderRadius, w->palette(), + frameWidth, frameShape | frameShadow); } - else - { - const int frameShape = w->property( "frameShape" ).toInt(); - const int frameShadow = w->property( "frameShadow" ).toInt(); + } + else + { + const int frameShape = w->property("frameShape").toInt(); + const int frameShadow = w->property("frameShadow").toInt(); #if QT_VERSION < 0x050000 - QStyleOptionFrameV3 opt; + QStyleOptionFrameV3 opt; #else - QStyleOptionFrame opt; + QStyleOptionFrame opt; #endif - opt.initFrom( w ); + opt.initFrom(w); - opt.frameShape = QFrame::Shape( int( opt.frameShape ) | frameShape ); + opt.frameShape = QFrame::Shape(int(opt.frameShape) | frameShape); - switch (frameShape) - { - case QFrame::Box: - case QFrame::HLine: - case QFrame::VLine: - case QFrame::StyledPanel: - case QFrame::Panel: - { - opt.lineWidth = w->property( "lineWidth" ).toInt(); - opt.midLineWidth = w->property( "midLineWidth" ).toInt(); - break; - } - default: - { - opt.lineWidth = w->property( "frameWidth" ).toInt(); - break; - } - } - - if ( frameShadow == QFrame::Sunken ) - opt.state |= QStyle::State_Sunken; - else if ( frameShadow == QFrame::Raised ) - opt.state |= QStyle::State_Raised; - - w->style()->drawControl(QStyle::CE_ShapedFrame, &opt, painter, w ); + switch (frameShape) + { + case QFrame::Box: + case QFrame::HLine: + case QFrame::VLine: + case QFrame::StyledPanel: + case QFrame::Panel: { + opt.lineWidth = w->property("lineWidth").toInt(); + opt.midLineWidth = w->property("midLineWidth").toInt(); + break; + } + default: { + opt.lineWidth = w->property("frameWidth").toInt(); + break; + } } + + if (frameShadow == QFrame::Sunken) + opt.state |= QStyle::State_Sunken; + else if (frameShadow == QFrame::Raised) + opt.state |= QStyle::State_Raised; + + w->style()->drawControl(QStyle::CE_ShapedFrame, &opt, painter, w); + } } //! Helper function for the derived plot canvas -void QwtPlotAbstractCanvas::drawBackground( QPainter* painter ) +void QwtPlotAbstractCanvas::drawBackground(QPainter *painter) { - qwtDrawBackground( painter, canvasWidget() ); + qwtDrawBackground(painter, canvasWidget()); } //! Helper function for the derived plot canvas -void QwtPlotAbstractCanvas::fillBackground( QPainter* painter ) +void QwtPlotAbstractCanvas::fillBackground(QPainter *painter) { - qwtFillBackground( painter, canvasWidget() ); + qwtFillBackground(painter, canvasWidget()); } //! Helper function for the derived plot canvas -void QwtPlotAbstractCanvas::drawUnstyled( QPainter* painter ) +void QwtPlotAbstractCanvas::drawUnstyled(QPainter *painter) { - fillBackground( painter ); + fillBackground(painter); - QWidget* w = canvasWidget(); + QWidget *w = canvasWidget(); - if ( w->autoFillBackground() ) - { - const QRect canvasRect = w->rect(); - - painter->save(); - - painter->setPen( Qt::NoPen ); - painter->setBrush( w->palette().brush( w->backgroundRole() ) ); - - const QRect frameRect = w->property( "frameRect" ).toRect(); - if ( borderRadius() > 0.0 && ( canvasRect == frameRect ) ) - { - const int frameWidth = w->property( "frameWidth" ).toInt(); - if ( frameWidth > 0 ) - { - painter->setClipPath( canvasBorderPath( canvasRect ) ); - painter->drawRect( canvasRect ); - } - else - { - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->drawPath( canvasBorderPath( canvasRect ) ); - } - } - else - { - painter->drawRect( canvasRect ); - } - - painter->restore(); - } - - drawCanvas( painter ); -} - -//! Helper function for the derived plot canvas -void QwtPlotAbstractCanvas::drawStyled( QPainter* painter, bool hackStyledBackground ) -{ - fillBackground( painter ); - - if ( hackStyledBackground ) - { - // Antialiasing rounded borders is done by - // inserting pixels with colors between the - // border color and the color on the canvas, - // When the border is painted before the plot items - // these colors are interpolated for the canvas - // and the plot items need to be clipped excluding - // the antialiased pixels. In situations, where - // the plot items fill the area at the rounded - // borders this is noticeable. - // The only way to avoid these annoying "artefacts" - // is to paint the border on top of the plot items. - - if ( !m_data->styleSheet.hasBorder || - m_data->styleSheet.borderPath.isEmpty() ) - { - // We have no border with at least one rounded corner - hackStyledBackground = false; - } - } - - QWidget* w = canvasWidget(); - - if ( hackStyledBackground ) - { - painter->save(); - - // paint background without border - painter->setPen( Qt::NoPen ); - painter->setBrush( m_data->styleSheet.background.brush ); - painter->setBrushOrigin( m_data->styleSheet.background.origin ); - painter->setClipPath( m_data->styleSheet.borderPath ); - painter->drawRect( w->contentsRect() ); - - painter->restore(); - - drawCanvas( painter ); - - // Now paint the border on top - QStyleOptionFrame opt; - opt.initFrom( w ); - w->style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, w); - } - else - { - QStyleOption opt; - opt.initFrom( w ); - w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w ); - - drawCanvas( painter ); - } -} - -//! \brief Draw the plot to the canvas -void QwtPlotAbstractCanvas::drawCanvas( QPainter* painter ) -{ - QWidget* w = canvasWidget(); + if (w->autoFillBackground()) + { + const QRect canvasRect = w->rect(); painter->save(); - if ( !m_data->styleSheet.borderPath.isEmpty() ) + painter->setPen(Qt::NoPen); + painter->setBrush(w->palette().brush(w->backgroundRole())); + + const QRect frameRect = w->property("frameRect").toRect(); + if (borderRadius() > 0.0 && (canvasRect == frameRect)) { - painter->setClipPath( - m_data->styleSheet.borderPath, Qt::IntersectClip ); + const int frameWidth = w->property("frameWidth").toInt(); + if (frameWidth > 0) + { + painter->setClipPath(canvasBorderPath(canvasRect)); + painter->drawRect(canvasRect); + } + else + { + painter->setRenderHint(QPainter::Antialiasing, true); + painter->drawPath(canvasBorderPath(canvasRect)); + } } else { - if ( borderRadius() > 0.0 ) - { - const QRect frameRect = w->property( "frameRect" ).toRect(); - painter->setClipPath( canvasBorderPath( frameRect ), Qt::IntersectClip ); - } - else - { - painter->setClipRect( w->contentsRect(), Qt::IntersectClip ); - } + painter->drawRect(canvasRect); } - QwtPlot* plot = qobject_cast< QwtPlot* >( w->parent() ); - if ( plot ) - plot->drawCanvas( painter ); + painter->restore(); + } + + drawCanvas(painter); +} + +//! Helper function for the derived plot canvas +void QwtPlotAbstractCanvas::drawStyled(QPainter *painter, + bool hackStyledBackground) +{ + fillBackground(painter); + + if (hackStyledBackground) + { + // Antialiasing rounded borders is done by + // inserting pixels with colors between the + // border color and the color on the canvas, + // When the border is painted before the plot items + // these colors are interpolated for the canvas + // and the plot items need to be clipped excluding + // the antialiased pixels. In situations, where + // the plot items fill the area at the rounded + // borders this is noticeable. + // The only way to avoid these annoying "artefacts" + // is to paint the border on top of the plot items. + + if (!m_data->styleSheet.hasBorder + || m_data->styleSheet.borderPath.isEmpty()) + { + // We have no border with at least one rounded corner + hackStyledBackground = false; + } + } + + QWidget *w = canvasWidget(); + + if (hackStyledBackground) + { + painter->save(); + + // paint background without border + painter->setPen(Qt::NoPen); + painter->setBrush(m_data->styleSheet.background.brush); + painter->setBrushOrigin(m_data->styleSheet.background.origin); + painter->setClipPath(m_data->styleSheet.borderPath); + painter->drawRect(w->contentsRect()); painter->restore(); + + drawCanvas(painter); + + // Now paint the border on top + QStyleOptionFrame opt; + opt.initFrom(w); + w->style()->drawPrimitive(QStyle::PE_Frame, &opt, painter, w); + } + else + { + QStyleOption opt; + opt.initFrom(w); + w->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, w); + + drawCanvas(painter); + } +} + +//! \brief Draw the plot to the canvas +void QwtPlotAbstractCanvas::drawCanvas(QPainter *painter) +{ + QWidget *w = canvasWidget(); + + painter->save(); + + if (!m_data->styleSheet.borderPath.isEmpty()) + { + painter->setClipPath(m_data->styleSheet.borderPath, Qt::IntersectClip); + } + else + { + if (borderRadius() > 0.0) + { + const QRect frameRect = w->property("frameRect").toRect(); + painter->setClipPath(canvasBorderPath(frameRect), Qt::IntersectClip); + } + else + { + painter->setClipRect(w->contentsRect(), Qt::IntersectClip); + } + } + + QwtPlot *plot = qobject_cast(w->parent()); + if (plot) + plot->drawCanvas(painter); + + painter->restore(); } //! Update the cached information about the current style sheet void QwtPlotAbstractCanvas::updateStyleSheetInfo() { - QWidget* w = canvasWidget(); + QWidget *w = canvasWidget(); - if ( !w->testAttribute( Qt::WA_StyledBackground ) ) - return; + if (!w->testAttribute(Qt::WA_StyledBackground)) + return; - QwtStyleSheetRecorder recorder( w->size() ); + QwtStyleSheetRecorder recorder(w->size()); - QPainter painter( &recorder ); + QPainter painter(&recorder); - QStyleOption opt; - opt.initFrom(w); - w->style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, w); + QStyleOption opt; + opt.initFrom(w); + w->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, w); - painter.end(); + painter.end(); - m_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty(); - m_data->styleSheet.cornerRects = recorder.clipRects; + m_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty(); + m_data->styleSheet.cornerRects = recorder.clipRects; - if ( recorder.background.path.isEmpty() ) + if (recorder.background.path.isEmpty()) + { + if (!recorder.border.rectList.isEmpty()) { - if ( !recorder.border.rectList.isEmpty() ) - { - m_data->styleSheet.borderPath = - qwtCombinePathList( w->rect(), recorder.border.pathList ); - } - } - else - { - m_data->styleSheet.borderPath = recorder.background.path; - m_data->styleSheet.background.brush = recorder.background.brush; - m_data->styleSheet.background.origin = recorder.background.origin; + m_data->styleSheet.borderPath + = qwtCombinePathList(w->rect(), recorder.border.pathList); } + } + else + { + m_data->styleSheet.borderPath = recorder.background.path; + m_data->styleSheet.background.brush = recorder.background.brush; + m_data->styleSheet.background.origin = recorder.background.origin; + } } //! \return canvas widget -QWidget* QwtPlotAbstractCanvas::canvasWidget() +QWidget *QwtPlotAbstractCanvas::canvasWidget() { - return m_data->canvasWidget; + return m_data->canvasWidget; } //! \return canvas widget -const QWidget* QwtPlotAbstractCanvas::canvasWidget() const +const QWidget *QwtPlotAbstractCanvas::canvasWidget() const { - return m_data->canvasWidget; + return m_data->canvasWidget; } class QwtPlotAbstractGLCanvas::PrivateData { - public: - PrivateData(): - frameStyle( QFrame::Panel | QFrame::Sunken), - lineWidth( 2 ), - midLineWidth( 0 ) - { - } +public: + PrivateData() + : frameStyle(QFrame::Panel | QFrame::Sunken) + , lineWidth(2) + , midLineWidth(0) + { + } - QwtPlotAbstractGLCanvas::PaintAttributes paintAttributes; + QwtPlotAbstractGLCanvas::PaintAttributes paintAttributes; - int frameStyle; - int lineWidth; - int midLineWidth; + int frameStyle; + int lineWidth; + int midLineWidth; }; /*! \brief Constructor \param canvasWidget plot canvas widget */ -QwtPlotAbstractGLCanvas::QwtPlotAbstractGLCanvas( QWidget* canvasWidget ): - QwtPlotAbstractCanvas( canvasWidget ) +QwtPlotAbstractGLCanvas::QwtPlotAbstractGLCanvas(QWidget *canvasWidget) + : QwtPlotAbstractCanvas(canvasWidget) { - m_data = new PrivateData; + m_data = new PrivateData; - qwtUpdateContentsRect( frameWidth(), canvasWidget ); - m_data->paintAttributes = QwtPlotAbstractGLCanvas::BackingStore; + qwtUpdateContentsRect(frameWidth(), canvasWidget); + m_data->paintAttributes = QwtPlotAbstractGLCanvas::BackingStore; } //! Destructor QwtPlotAbstractGLCanvas::~QwtPlotAbstractGLCanvas() { - delete m_data; + delete m_data; } /*! @@ -924,22 +908,23 @@ QwtPlotAbstractGLCanvas::~QwtPlotAbstractGLCanvas() \sa testPaintAttribute() */ -void QwtPlotAbstractGLCanvas::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPlotAbstractGLCanvas::setPaintAttribute(PaintAttribute attribute, + bool on) { - if ( bool( m_data->paintAttributes & attribute ) == on ) - return; + if (bool(m_data->paintAttributes & attribute) == on) + return; - if ( on ) - { - m_data->paintAttributes |= attribute; - } - else - { - m_data->paintAttributes &= ~attribute; + if (on) + { + m_data->paintAttributes |= attribute; + } + else + { + m_data->paintAttributes &= ~attribute; - if ( attribute == BackingStore ) - clearBackingStore(); - } + if (attribute == BackingStore) + clearBackingStore(); + } } /*! @@ -949,9 +934,9 @@ void QwtPlotAbstractGLCanvas::setPaintAttribute( PaintAttribute attribute, bool \return true, when attribute is enabled \sa setPaintAttribute() */ -bool QwtPlotAbstractGLCanvas::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPlotAbstractGLCanvas::testPaintAttribute(PaintAttribute attribute) const { - return m_data->paintAttributes & attribute; + return m_data->paintAttributes & attribute; } /*! @@ -962,15 +947,15 @@ bool QwtPlotAbstractGLCanvas::testPaintAttribute( PaintAttribute attribute ) con \sa frameStyle(), QFrame::setFrameStyle(), setFrameShadow(), setFrameShape() */ -void QwtPlotAbstractGLCanvas::setFrameStyle( int style ) +void QwtPlotAbstractGLCanvas::setFrameStyle(int style) { - if ( style != m_data->frameStyle ) - { - m_data->frameStyle = style; - qwtUpdateContentsRect( frameWidth(), canvasWidget() ); + if (style != m_data->frameStyle) + { + m_data->frameStyle = style; + qwtUpdateContentsRect(frameWidth(), canvasWidget()); - canvasWidget()->update(); - } + canvasWidget()->update(); + } } /*! @@ -979,7 +964,7 @@ void QwtPlotAbstractGLCanvas::setFrameStyle( int style ) */ int QwtPlotAbstractGLCanvas::frameStyle() const { - return m_data->frameStyle; + return m_data->frameStyle; } /*! @@ -988,9 +973,9 @@ int QwtPlotAbstractGLCanvas::frameStyle() const \param shadow Frame shadow \sa frameShadow(), setFrameShape(), QFrame::setFrameShadow() */ -void QwtPlotAbstractGLCanvas::setFrameShadow( QFrame::Shadow shadow ) +void QwtPlotAbstractGLCanvas::setFrameShadow(QFrame::Shadow shadow) { - setFrameStyle( ( m_data->frameStyle & QFrame::Shape_Mask ) | shadow ); + setFrameStyle((m_data->frameStyle & QFrame::Shape_Mask) | shadow); } /*! @@ -999,7 +984,7 @@ void QwtPlotAbstractGLCanvas::setFrameShadow( QFrame::Shadow shadow ) */ QFrame::Shadow QwtPlotAbstractGLCanvas::frameShadow() const { - return (QFrame::Shadow) ( m_data->frameStyle & QFrame::Shadow_Mask ); + return (QFrame::Shadow)(m_data->frameStyle & QFrame::Shadow_Mask); } /*! @@ -1008,9 +993,9 @@ QFrame::Shadow QwtPlotAbstractGLCanvas::frameShadow() const \param shape Frame shape \sa frameShape(), setFrameShadow(), QFrame::frameShape() */ -void QwtPlotAbstractGLCanvas::setFrameShape( QFrame::Shape shape ) +void QwtPlotAbstractGLCanvas::setFrameShape(QFrame::Shape shape) { - setFrameStyle( ( m_data->frameStyle & QFrame::Shadow_Mask ) | shape ); + setFrameStyle((m_data->frameStyle & QFrame::Shadow_Mask) | shape); } /*! @@ -1019,7 +1004,7 @@ void QwtPlotAbstractGLCanvas::setFrameShape( QFrame::Shape shape ) */ QFrame::Shape QwtPlotAbstractGLCanvas::frameShape() const { - return (QFrame::Shape) ( m_data->frameStyle & QFrame::Shape_Mask ); + return (QFrame::Shape)(m_data->frameStyle & QFrame::Shape_Mask); } /*! @@ -1030,15 +1015,15 @@ QFrame::Shape QwtPlotAbstractGLCanvas::frameShape() const \param width Line width of the frame \sa lineWidth(), setMidLineWidth() */ -void QwtPlotAbstractGLCanvas::setLineWidth( int width ) +void QwtPlotAbstractGLCanvas::setLineWidth(int width) { - width = qMax( width, 0 ); - if ( width != m_data->lineWidth ) - { - m_data->lineWidth = qMax( width, 0 ); - qwtUpdateContentsRect( frameWidth(), canvasWidget() ); - canvasWidget()->update(); - } + width = qMax(width, 0); + if (width != m_data->lineWidth) + { + m_data->lineWidth = qMax(width, 0); + qwtUpdateContentsRect(frameWidth(), canvasWidget()); + canvasWidget()->update(); + } } /*! @@ -1047,7 +1032,7 @@ void QwtPlotAbstractGLCanvas::setLineWidth( int width ) */ int QwtPlotAbstractGLCanvas::lineWidth() const { - return m_data->lineWidth; + return m_data->lineWidth; } /*! @@ -1058,15 +1043,15 @@ int QwtPlotAbstractGLCanvas::lineWidth() const \param width Midline width of the frame \sa midLineWidth(), setLineWidth() */ -void QwtPlotAbstractGLCanvas::setMidLineWidth( int width ) +void QwtPlotAbstractGLCanvas::setMidLineWidth(int width) { - width = qMax( width, 0 ); - if ( width != m_data->midLineWidth ) - { - m_data->midLineWidth = width; - qwtUpdateContentsRect( frameWidth(), canvasWidget() ); - canvasWidget()->update(); - } + width = qMax(width, 0); + if (width != m_data->midLineWidth) + { + m_data->midLineWidth = width; + qwtUpdateContentsRect(frameWidth(), canvasWidget()); + canvasWidget()->update(); + } } /*! @@ -1075,7 +1060,7 @@ void QwtPlotAbstractGLCanvas::setMidLineWidth( int width ) */ int QwtPlotAbstractGLCanvas::midLineWidth() const { - return m_data->midLineWidth; + return m_data->midLineWidth; } /*! @@ -1083,7 +1068,7 @@ int QwtPlotAbstractGLCanvas::midLineWidth() const */ int QwtPlotAbstractGLCanvas::frameWidth() const { - return ( frameStyle() != QFrame::NoFrame ) ? m_data->lineWidth : 0; + return (frameStyle() != QFrame::NoFrame) ? m_data->lineWidth : 0; } /*! @@ -1092,38 +1077,38 @@ int QwtPlotAbstractGLCanvas::frameWidth() const */ void QwtPlotAbstractGLCanvas::replot() { - invalidateBackingStore(); + invalidateBackingStore(); - QWidget* w = canvasWidget(); - if ( testPaintAttribute( QwtPlotAbstractGLCanvas::ImmediatePaint ) ) - w->repaint( w->contentsRect() ); - else - w->update( w->contentsRect() ); + QWidget *w = canvasWidget(); + if (testPaintAttribute(QwtPlotAbstractGLCanvas::ImmediatePaint)) + w->repaint(w->contentsRect()); + else + w->update(w->contentsRect()); } //! \return The rectangle where the frame is drawn in. QRect QwtPlotAbstractGLCanvas::frameRect() const { - const int fw = frameWidth(); - return canvasWidget()->contentsRect().adjusted( -fw, -fw, fw, fw ); + const int fw = frameWidth(); + return canvasWidget()->contentsRect().adjusted(-fw, -fw, fw, fw); } //! Helper function for the derived plot canvas -void QwtPlotAbstractGLCanvas::draw( QPainter* painter ) +void QwtPlotAbstractGLCanvas::draw(QPainter *painter) { #if FIX_GL_TRANSLATION - if ( painter->paintEngine()->type() == QPaintEngine::OpenGL2 ) - { - // work around a translation bug of QPaintEngine::OpenGL2 - painter->translate( 1, 1 ); - } + if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) + { + // work around a translation bug of QPaintEngine::OpenGL2 + painter->translate(1, 1); + } #endif - if ( canvasWidget()->testAttribute( Qt::WA_StyledBackground ) ) - drawStyled( painter, true ); - else - drawUnstyled( painter ); + if (canvasWidget()->testAttribute(Qt::WA_StyledBackground)) + drawStyled(painter, true); + else + drawUnstyled(painter); - if ( frameWidth() > 0 ) - drawBorder( painter ); + if (frameWidth() > 0) + drawBorder(painter); } diff --git a/libs/qwt/src/qwt_plot_abstract_canvas.h b/libs/qwt/src/qwt_plot_abstract_canvas.h index 58514c4c..fcf09194 100644 --- a/libs/qwt/src/qwt_plot_abstract_canvas.h +++ b/libs/qwt/src/qwt_plot_abstract_canvas.h @@ -20,65 +20,65 @@ class QwtPlot; */ class QWT_EXPORT QwtPlotAbstractCanvas { - public: +public: + /*! + \brief Focus indicator + The default setting is NoFocusIndicator + \sa setFocusIndicator(), focusIndicator(), drawFocusIndicator() + */ + + enum FocusIndicator + { + //! Don't paint a focus indicator + NoFocusIndicator, + /*! - \brief Focus indicator - The default setting is NoFocusIndicator - \sa setFocusIndicator(), focusIndicator(), drawFocusIndicator() + The focus is related to the complete canvas. + Paint the focus indicator using drawFocusIndicator() */ + CanvasFocusIndicator, - enum FocusIndicator - { - //! Don't paint a focus indicator - NoFocusIndicator, + /*! + The focus is related to an item (curve, point, ...) on + the canvas. It is up to the application to display a + focus indication using f.e. highlighting. + */ + ItemFocusIndicator + }; - /*! - The focus is related to the complete canvas. - Paint the focus indicator using drawFocusIndicator() - */ - CanvasFocusIndicator, + explicit QwtPlotAbstractCanvas(QWidget *canvasWidget); + virtual ~QwtPlotAbstractCanvas(); - /*! - The focus is related to an item (curve, point, ...) on - the canvas. It is up to the application to display a - focus indication using f.e. highlighting. - */ - ItemFocusIndicator - }; + QwtPlot *plot(); + const QwtPlot *plot() const; - explicit QwtPlotAbstractCanvas( QWidget* canvasWidget ); - virtual ~QwtPlotAbstractCanvas(); + void setFocusIndicator(FocusIndicator); + FocusIndicator focusIndicator() const; - QwtPlot* plot(); - const QwtPlot* plot() const; + void setBorderRadius(double); + double borderRadius() const; - void setFocusIndicator( FocusIndicator ); - FocusIndicator focusIndicator() const; +protected: + QWidget *canvasWidget(); + const QWidget *canvasWidget() const; - void setBorderRadius( double ); - double borderRadius() const; + virtual void drawFocusIndicator(QPainter *); + virtual void drawBorder(QPainter *); + virtual void drawBackground(QPainter *); - protected: - QWidget* canvasWidget(); - const QWidget* canvasWidget() const; + void fillBackground(QPainter *); + void drawCanvas(QPainter *); + void drawStyled(QPainter *, bool); + void drawUnstyled(QPainter *); - virtual void drawFocusIndicator( QPainter* ); - virtual void drawBorder( QPainter* ); - virtual void drawBackground( QPainter* ); + QPainterPath canvasBorderPath(const QRect &rect) const; + void updateStyleSheetInfo(); - void fillBackground( QPainter* ); - void drawCanvas( QPainter* ); - void drawStyled( QPainter*, bool ); - void drawUnstyled( QPainter* ); +private: + Q_DISABLE_COPY(QwtPlotAbstractCanvas) - QPainterPath canvasBorderPath( const QRect& rect ) const; - void updateStyleSheetInfo(); - - private: - Q_DISABLE_COPY(QwtPlotAbstractCanvas) - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; /*! @@ -86,79 +86,79 @@ class QWT_EXPORT QwtPlotAbstractCanvas */ class QWT_EXPORT QwtPlotAbstractGLCanvas : public QwtPlotAbstractCanvas { - public: +public: + /*! + \brief Paint attributes + + The default setting enables BackingStore and Opaque. + + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { /*! - \brief Paint attributes + \brief Paint double buffered reusing the content + of the pixmap buffer when possible. - The default setting enables BackingStore and Opaque. + Using a backing store might improve the performance + significantly, when working with widget overlays ( like rubber bands ). + Disabling the cache might improve the performance for + incremental paints (using QwtPlotDirectPainter ). - \sa setPaintAttribute(), testPaintAttribute() + \sa backingStore(), invalidateBackingStore() */ - enum PaintAttribute - { - /*! - \brief Paint double buffered reusing the content - of the pixmap buffer when possible. + BackingStore = 1, - Using a backing store might improve the performance - significantly, when working with widget overlays ( like rubber bands ). - Disabling the cache might improve the performance for - incremental paints (using QwtPlotDirectPainter ). + /*! + When ImmediatePaint is set replot() calls repaint() + instead of update(). - \sa backingStore(), invalidateBackingStore() - */ - BackingStore = 1, + \sa replot(), QWidget::repaint(), QWidget::update() + */ + ImmediatePaint = 8, + }; - /*! - When ImmediatePaint is set replot() calls repaint() - instead of update(). + //! Paint attributes + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - \sa replot(), QWidget::repaint(), QWidget::update() - */ - ImmediatePaint = 8, - }; + explicit QwtPlotAbstractGLCanvas(QWidget *canvasWidget); + virtual ~QwtPlotAbstractGLCanvas(); - //! Paint attributes - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - explicit QwtPlotAbstractGLCanvas( QWidget* canvasWidget ); - virtual ~QwtPlotAbstractGLCanvas(); + void setFrameStyle(int style); + int frameStyle() const; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + void setFrameShadow(QFrame::Shadow); + QFrame::Shadow frameShadow() const; - void setFrameStyle( int style ); - int frameStyle() const; + void setFrameShape(QFrame::Shape); + QFrame::Shape frameShape() const; - void setFrameShadow( QFrame::Shadow ); - QFrame::Shadow frameShadow() const; + void setLineWidth(int); + int lineWidth() const; - void setFrameShape( QFrame::Shape ); - QFrame::Shape frameShape() const; + void setMidLineWidth(int); + int midLineWidth() const; - void setLineWidth( int ); - int lineWidth() const; + int frameWidth() const; + QRect frameRect() const; - void setMidLineWidth( int ); - int midLineWidth() const; + //! Invalidate the internal backing store + virtual void invalidateBackingStore() = 0; - int frameWidth() const; - QRect frameRect() const; +protected: + void replot(); + void draw(QPainter *); - //! Invalidate the internal backing store - virtual void invalidateBackingStore() = 0; +private: + virtual void clearBackingStore() = 0; - protected: - void replot(); - void draw( QPainter* ); - - private: - virtual void clearBackingStore() = 0; - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotAbstractGLCanvas::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotAbstractGLCanvas::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_axis.cpp b/libs/qwt/src/qwt_plot_axis.cpp index 470d1893..7ba3789a 100644 --- a/libs/qwt/src/qwt_plot_axis.cpp +++ b/libs/qwt/src/qwt_plot_axis.cpp @@ -16,106 +16,108 @@ namespace QwtPlotAxisPrivate { - class AxisData - { - public: - AxisData() - : isVisible( true ) - , doAutoScale( true ) - , minValue( 0.0 ) - , maxValue( 1000.0 ) - , stepSize( 0.0 ) - , maxMajor( 8 ) - , maxMinor( 5 ) - , isValid( false ) - , scaleEngine( new QwtLinearScaleEngine() ) - , scaleWidget( NULL ) - { - } +class AxisData +{ +public: + AxisData() + : isVisible(true) + , doAutoScale(true) + , minValue(0.0) + , maxValue(1000.0) + , stepSize(0.0) + , maxMajor(8) + , maxMinor(5) + , isValid(false) + , scaleEngine(new QwtLinearScaleEngine()) + , scaleWidget(NULL) + { + } - ~AxisData() - { - delete scaleEngine; - } + ~AxisData() { delete scaleEngine; } - void initWidget( QwtScaleDraw::Alignment align, const QString& name, QwtPlot* plot ) - { - scaleWidget = new QwtScaleWidget( align, plot ); - scaleWidget->setObjectName( name ); + void initWidget(QwtScaleDraw::Alignment align, const QString &name, + QwtPlot *plot) + { + scaleWidget = new QwtScaleWidget(align, plot); + scaleWidget->setObjectName(name); - #if 1 - // better find the font sizes from the application font - const QFont fscl( plot->fontInfo().family(), 10 ); - const QFont fttl( plot->fontInfo().family(), 12, QFont::Bold ); - #endif +#if 1 + // better find the font sizes from the application font + const QFont fscl(plot->fontInfo().family(), 10); + const QFont fttl(plot->fontInfo().family(), 12, QFont::Bold); +#endif - scaleWidget->setTransformation( scaleEngine->transformation() ); + scaleWidget->setTransformation(scaleEngine->transformation()); - scaleWidget->setFont( fscl ); - scaleWidget->setMargin( 2 ); + scaleWidget->setFont(fscl); + scaleWidget->setMargin(2); - QwtText text = scaleWidget->title(); - text.setFont( fttl ); - scaleWidget->setTitle( text ); - } + QwtText text = scaleWidget->title(); + text.setFont(fttl); + scaleWidget->setTitle(text); + } - bool isVisible; - bool doAutoScale; + bool isVisible; + bool doAutoScale; - double minValue; - double maxValue; - double stepSize; + double minValue; + double maxValue; + double stepSize; - int maxMajor; - int maxMinor; + int maxMajor; + int maxMinor; - bool isValid; + bool isValid; - QwtScaleDiv scaleDiv; - QwtScaleEngine* scaleEngine; - QwtScaleWidget* scaleWidget; - }; -} + QwtScaleDiv scaleDiv; + QwtScaleEngine *scaleEngine; + QwtScaleWidget *scaleWidget; +}; +} // namespace QwtPlotAxisPrivate class QwtPlot::ScaleData { - public: - ScaleData( QwtPlot* plot ) - { - using namespace QwtAxis; +public: + ScaleData(QwtPlot *plot) + { + using namespace QwtAxis; - m_axisData[YLeft].initWidget( QwtScaleDraw::LeftScale, "QwtPlotAxisYLeft", plot ); - m_axisData[YRight].initWidget( QwtScaleDraw::RightScale, "QwtPlotAxisYRight", plot ); - m_axisData[XTop].initWidget( QwtScaleDraw::TopScale, "QwtPlotAxisXTop", plot ); - m_axisData[XBottom].initWidget( QwtScaleDraw::BottomScale, "QwtPlotAxisXBottom", plot ); - } + m_axisData[YLeft].initWidget(QwtScaleDraw::LeftScale, "QwtPlotAxisYLeft", + plot); + m_axisData[YRight].initWidget(QwtScaleDraw::RightScale, "QwtPlotAxisYRight", + plot); + m_axisData[XTop].initWidget(QwtScaleDraw::TopScale, "QwtPlotAxisXTop", + plot); + m_axisData[XBottom].initWidget(QwtScaleDraw::BottomScale, + "QwtPlotAxisXBottom", plot); + } - inline QwtPlotAxisPrivate::AxisData& axisData( QwtAxisId axisId ) - { - return m_axisData[ axisId ]; - } + inline QwtPlotAxisPrivate::AxisData &axisData(QwtAxisId axisId) + { + return m_axisData[axisId]; + } - inline const QwtPlotAxisPrivate::AxisData& axisData( QwtAxisId axisId ) const - { - return m_axisData[ axisId ]; - } + inline const QwtPlotAxisPrivate::AxisData &axisData(QwtAxisId axisId) const + { + return m_axisData[axisId]; + } - private: - QwtPlotAxisPrivate::AxisData m_axisData[ QwtAxis::AxisPositions ]; +private: + QwtPlotAxisPrivate::AxisData m_axisData[QwtAxis::AxisPositions]; }; void QwtPlot::initAxesData() { - m_scaleData = new ScaleData( this ); + m_scaleData = new ScaleData(this); - m_scaleData->axisData( QwtAxis::YRight ).isVisible = false; - m_scaleData->axisData( QwtAxis::XTop ).isVisible = false; + m_scaleData->axisData(QwtAxis::YRight).isVisible = false; + m_scaleData->axisData(QwtAxis::XTop).isVisible = false; } void QwtPlot::deleteAxesData() { - delete m_scaleData; - m_scaleData = NULL; + delete m_scaleData; + m_scaleData = NULL; } /*! @@ -124,38 +126,38 @@ void QwtPlot::deleteAxesData() \param axisId axis \return \c true if the specified axis exists, otherwise \c false - \note This method is equivalent to QwtAxis::isValid( axisId ) and simply checks - if axisId is one of the values of QwtAxis::Position. It is a placeholder - for future releases, where it will be possible to have a customizable number - of axes ( multiaxes branch ) at each side. + \note This method is equivalent to QwtAxis::isValid( axisId ) and simply + checks if axisId is one of the values of QwtAxis::Position. It is a + placeholder for future releases, where it will be possible to have a + customizable number of axes ( multiaxes branch ) at each side. */ -bool QwtPlot::isAxisValid( QwtAxisId axisId ) const +bool QwtPlot::isAxisValid(QwtAxisId axisId) const { - return QwtAxis::isValid( axisId ); + return QwtAxis::isValid(axisId); } /*! \return Scale widget of the specified axis, or NULL if axisId is invalid. \param axisId Axis */ -const QwtScaleWidget* QwtPlot::axisWidget( QwtAxisId axisId ) const +const QwtScaleWidget *QwtPlot::axisWidget(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).scaleWidget; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).scaleWidget; - return NULL; + return NULL; } /*! \return Scale widget of the specified axis, or NULL if axisId is invalid. \param axisId Axis */ -QwtScaleWidget* QwtPlot::axisWidget( QwtAxisId axisId ) +QwtScaleWidget *QwtPlot::axisWidget(QwtAxisId axisId) { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).scaleWidget; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).scaleWidget; - return NULL; + return NULL; } /*! @@ -166,81 +168,80 @@ QwtScaleWidget* QwtPlot::axisWidget( QwtAxisId axisId ) \sa axisScaleEngine() */ -void QwtPlot::setAxisScaleEngine( QwtAxisId axisId, QwtScaleEngine* scaleEngine ) +void QwtPlot::setAxisScaleEngine(QwtAxisId axisId, QwtScaleEngine *scaleEngine) { - if ( isAxisValid( axisId ) && scaleEngine != NULL ) - { - QwtPlotAxisPrivate::AxisData& d = m_scaleData->axisData( axisId ); + if (isAxisValid(axisId) && scaleEngine != NULL) + { + QwtPlotAxisPrivate::AxisData &d = m_scaleData->axisData(axisId); - delete d.scaleEngine; - d.scaleEngine = scaleEngine; + delete d.scaleEngine; + d.scaleEngine = scaleEngine; - d.scaleWidget->setTransformation( scaleEngine->transformation() ); + d.scaleWidget->setTransformation(scaleEngine->transformation()); - d.isValid = false; + d.isValid = false; - autoRefresh(); - } + autoRefresh(); + } } /*! \param axisId Axis \return Scale engine for a specific axis */ -QwtScaleEngine* QwtPlot::axisScaleEngine( QwtAxisId axisId ) +QwtScaleEngine *QwtPlot::axisScaleEngine(QwtAxisId axisId) { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).scaleEngine; - else - return NULL; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).scaleEngine; + else + return NULL; } /*! \param axisId Axis \return Scale engine for a specific axis */ -const QwtScaleEngine* QwtPlot::axisScaleEngine( QwtAxisId axisId ) const +const QwtScaleEngine *QwtPlot::axisScaleEngine(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).scaleEngine; - else - return NULL; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).scaleEngine; + else + return NULL; } /*! \return \c True, if autoscaling is enabled \param axisId Axis */ -bool QwtPlot::axisAutoScale( QwtAxisId axisId ) const +bool QwtPlot::axisAutoScale(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).doAutoScale; - else - return false; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).doAutoScale; + else + return false; } /*! \return \c True, if a specified axis is visible \param axisId Axis */ -bool QwtPlot::isAxisVisible( QwtAxisId axisId ) const +bool QwtPlot::isAxisVisible(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).isVisible; - else - return false; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).isVisible; + else + return false; } /*! \return The font of the scale labels for a specified axis \param axisId Axis */ -QFont QwtPlot::axisFont( QwtAxisId axisId ) const +QFont QwtPlot::axisFont(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return axisWidget( axisId )->font(); - else - return QFont(); - + if (isAxisValid(axisId)) + return axisWidget(axisId)->font(); + else + return QFont(); } /*! @@ -248,12 +249,12 @@ QFont QwtPlot::axisFont( QwtAxisId axisId ) const \param axisId Axis \sa setAxisMaxMajor(), QwtScaleEngine::divideScale() */ -int QwtPlot::axisMaxMajor( QwtAxisId axisId ) const +int QwtPlot::axisMaxMajor(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).maxMajor; - else - return 0; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).maxMajor; + else + return 0; } /*! @@ -261,12 +262,12 @@ int QwtPlot::axisMaxMajor( QwtAxisId axisId ) const \param axisId Axis \sa setAxisMaxMinor(), QwtScaleEngine::divideScale() */ -int QwtPlot::axisMaxMinor( QwtAxisId axisId ) const +int QwtPlot::axisMaxMinor(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return m_scaleData->axisData( axisId ).maxMinor; - else - return 0; + if (isAxisValid(axisId)) + return m_scaleData->axisData(axisId).maxMinor; + else + return 0; } /*! @@ -280,9 +281,9 @@ int QwtPlot::axisMaxMinor( QwtAxisId axisId ) const \sa QwtScaleDiv, setAxisScaleDiv(), QwtScaleEngine::divideScale() */ -const QwtScaleDiv& QwtPlot::axisScaleDiv( QwtAxisId axisId ) const +const QwtScaleDiv &QwtPlot::axisScaleDiv(QwtAxisId axisId) const { - return m_scaleData->axisData( axisId ).scaleDiv; + return m_scaleData->axisData(axisId).scaleDiv; } /*! @@ -291,12 +292,12 @@ const QwtScaleDiv& QwtPlot::axisScaleDiv( QwtAxisId axisId ) const \param axisId Axis \return Specified scaleDraw for axis, or NULL if axis is invalid. */ -const QwtScaleDraw* QwtPlot::axisScaleDraw( QwtAxisId axisId ) const +const QwtScaleDraw *QwtPlot::axisScaleDraw(QwtAxisId axisId) const { - if ( !isAxisValid( axisId ) ) - return NULL; + if (!isAxisValid(axisId)) + return NULL; - return axisWidget( axisId )->scaleDraw(); + return axisWidget(axisId)->scaleDraw(); } /*! @@ -305,12 +306,12 @@ const QwtScaleDraw* QwtPlot::axisScaleDraw( QwtAxisId axisId ) const \param axisId Axis \return Specified scaleDraw for axis, or NULL if axis is invalid. */ -QwtScaleDraw* QwtPlot::axisScaleDraw( QwtAxisId axisId ) +QwtScaleDraw *QwtPlot::axisScaleDraw(QwtAxisId axisId) { - if ( !isAxisValid( axisId ) ) - return NULL; + if (!isAxisValid(axisId)) + return NULL; - return axisWidget( axisId )->scaleDraw(); + return axisWidget(axisId)->scaleDraw(); } /*! @@ -323,12 +324,12 @@ QwtScaleDraw* QwtPlot::axisScaleDraw( QwtAxisId axisId ) \sa setAxisScale(), QwtScaleEngine::divideScale() */ -double QwtPlot::axisStepSize( QwtAxisId axisId ) const +double QwtPlot::axisStepSize(QwtAxisId axisId) const { - if ( !isAxisValid( axisId ) ) - return 0; + if (!isAxisValid(axisId)) + return 0; - return m_scaleData->axisData( axisId ).stepSize; + return m_scaleData->axisData(axisId).stepSize; } /*! @@ -341,24 +342,24 @@ double QwtPlot::axisStepSize( QwtAxisId axisId ) const \sa QwtScaleDiv, axisScaleDiv() */ -QwtInterval QwtPlot::axisInterval( QwtAxisId axisId ) const +QwtInterval QwtPlot::axisInterval(QwtAxisId axisId) const { - if ( !isAxisValid( axisId ) ) - return QwtInterval(); + if (!isAxisValid(axisId)) + return QwtInterval(); - return m_scaleData->axisData( axisId ).scaleDiv.interval(); + return m_scaleData->axisData(axisId).scaleDiv.interval(); } /*! \return Title of a specified axis \param axisId Axis */ -QwtText QwtPlot::axisTitle( QwtAxisId axisId ) const +QwtText QwtPlot::axisTitle(QwtAxisId axisId) const { - if ( isAxisValid( axisId ) ) - return axisWidget( axisId )->title(); - else - return QwtText(); + if (isAxisValid(axisId)) + return axisWidget(axisId)->title(); + else + return QwtText(); } /*! @@ -373,13 +374,13 @@ QwtText QwtPlot::axisTitle( QwtAxisId axisId ) const \param axisId Axis \param on \c true (visible) or \c false (hidden) */ -void QwtPlot::setAxisVisible( QwtAxisId axisId, bool on ) +void QwtPlot::setAxisVisible(QwtAxisId axisId, bool on) { - if ( isAxisValid( axisId ) && on != m_scaleData->axisData( axisId ).isVisible ) - { - m_scaleData->axisData( axisId ).isVisible = on; - updateLayout(); - } + if (isAxisValid(axisId) && on != m_scaleData->axisData(axisId).isVisible) + { + m_scaleData->axisData(axisId).isVisible = on; + updateLayout(); + } } /*! @@ -394,15 +395,14 @@ void QwtPlot::setAxisVisible( QwtAxisId axisId, bool on ) \warning The position can be an x or a y coordinate, depending on the specified axis. */ -double QwtPlot::invTransform( QwtAxisId axisId, double pos ) const +double QwtPlot::invTransform(QwtAxisId axisId, double pos) const { - if ( isAxisValid( axisId ) ) - return( canvasMap( axisId ).invTransform( pos ) ); - else - return 0.0; + if (isAxisValid(axisId)) + return (canvasMap(axisId).invTransform(pos)); + else + return 0.0; } - /*! \brief Transform a value into a coordinate in the plotting region @@ -411,12 +411,12 @@ double QwtPlot::invTransform( QwtAxisId axisId, double pos ) const \return X or Y coordinate in the plotting region corresponding to the value. */ -double QwtPlot::transform( QwtAxisId axisId, double value ) const +double QwtPlot::transform(QwtAxisId axisId, double value) const { - if ( isAxisValid( axisId ) ) - return( canvasMap( axisId ).transform( value ) ); - else - return 0.0; + if (isAxisValid(axisId)) + return (canvasMap(axisId).transform(value)); + else + return 0.0; } /*! @@ -427,10 +427,10 @@ double QwtPlot::transform( QwtAxisId axisId, double value ) const \warning This function changes the font of the tick labels, not of the axis title. */ -void QwtPlot::setAxisFont( QwtAxisId axisId, const QFont& font ) +void QwtPlot::setAxisFont(QwtAxisId axisId, const QFont &font) { - if ( isAxisValid( axisId ) ) - axisWidget( axisId )->setFont( font ); + if (isAxisValid(axisId)) + axisWidget(axisId)->setFont(font); } /*! @@ -446,13 +446,13 @@ void QwtPlot::setAxisFont( QwtAxisId axisId, const QFont& font ) \note The autoscaling flag has no effect until updateAxes() is executed ( called by replot() ). */ -void QwtPlot::setAxisAutoScale( QwtAxisId axisId, bool on ) +void QwtPlot::setAxisAutoScale(QwtAxisId axisId, bool on) { - if ( isAxisValid( axisId ) && ( m_scaleData->axisData( axisId ).doAutoScale != on ) ) - { - m_scaleData->axisData( axisId ).doAutoScale = on; - autoRefresh(); - } + if (isAxisValid(axisId) && (m_scaleData->axisData(axisId).doAutoScale != on)) + { + m_scaleData->axisData(axisId).doAutoScale = on; + autoRefresh(); + } } /*! @@ -468,23 +468,25 @@ void QwtPlot::setAxisAutoScale( QwtAxisId axisId, bool on ) \param stepSize Major step size. If step == 0, the step size is calculated automatically using the maxMajor setting. - \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize(), QwtScaleEngine::divideScale() + \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize(), + QwtScaleEngine::divideScale() */ -void QwtPlot::setAxisScale( QwtAxisId axisId, double min, double max, double stepSize ) +void QwtPlot::setAxisScale(QwtAxisId axisId, double min, double max, + double stepSize) { - if ( isAxisValid( axisId ) ) - { - QwtPlotAxisPrivate::AxisData& d = m_scaleData->axisData( axisId ); + if (isAxisValid(axisId)) + { + QwtPlotAxisPrivate::AxisData &d = m_scaleData->axisData(axisId); - d.doAutoScale = false; - d.isValid = false; + d.doAutoScale = false; + d.isValid = false; - d.minValue = min; - d.maxValue = max; - d.stepSize = stepSize; + d.minValue = min; + d.maxValue = max; + d.stepSize = stepSize; - autoRefresh(); - } + autoRefresh(); + } } /*! @@ -499,18 +501,18 @@ void QwtPlot::setAxisScale( QwtAxisId axisId, double min, double max, double ste \sa setAxisScale(), setAxisAutoScale() */ -void QwtPlot::setAxisScaleDiv( QwtAxisId axisId, const QwtScaleDiv& scaleDiv ) +void QwtPlot::setAxisScaleDiv(QwtAxisId axisId, const QwtScaleDiv &scaleDiv) { - if ( isAxisValid( axisId ) ) - { - QwtPlotAxisPrivate::AxisData& d = m_scaleData->axisData( axisId ); + if (isAxisValid(axisId)) + { + QwtPlotAxisPrivate::AxisData &d = m_scaleData->axisData(axisId); - d.doAutoScale = false; - d.scaleDiv = scaleDiv; - d.isValid = true; + d.doAutoScale = false; + d.scaleDiv = scaleDiv; + d.isValid = true; - autoRefresh(); - } + autoRefresh(); + } } /*! @@ -529,13 +531,13 @@ void QwtPlot::setAxisScaleDiv( QwtAxisId axisId, const QwtScaleDiv& scaleDiv ) previous QwtScaleDraw. */ -void QwtPlot::setAxisScaleDraw( QwtAxisId axisId, QwtScaleDraw* scaleDraw ) +void QwtPlot::setAxisScaleDraw(QwtAxisId axisId, QwtScaleDraw *scaleDraw) { - if ( isAxisValid( axisId ) ) - { - axisWidget( axisId )->setScaleDraw( scaleDraw ); - autoRefresh(); - } + if (isAxisValid(axisId)) + { + axisWidget(axisId)->setScaleDraw(scaleDraw); + autoRefresh(); + } } /*! @@ -546,10 +548,10 @@ void QwtPlot::setAxisScaleDraw( QwtAxisId axisId, QwtScaleDraw* scaleDraw ) \sa QwtScaleDraw::setLabelAlignment() */ -void QwtPlot::setAxisLabelAlignment( QwtAxisId axisId, Qt::Alignment alignment ) +void QwtPlot::setAxisLabelAlignment(QwtAxisId axisId, Qt::Alignment alignment) { - if ( isAxisValid( axisId ) ) - axisWidget( axisId )->setLabelAlignment( alignment ); + if (isAxisValid(axisId)) + axisWidget(axisId)->setLabelAlignment(alignment); } /*! @@ -561,10 +563,10 @@ void QwtPlot::setAxisLabelAlignment( QwtAxisId axisId, Qt::Alignment alignment ) \sa QwtScaleDraw::setLabelRotation(), setAxisLabelAlignment() */ -void QwtPlot::setAxisLabelRotation( QwtAxisId axisId, double rotation ) +void QwtPlot::setAxisLabelRotation(QwtAxisId axisId, double rotation) { - if ( isAxisValid( axisId ) ) - axisWidget( axisId )->setLabelRotation( rotation ); + if (isAxisValid(axisId)) + axisWidget(axisId)->setLabelRotation(rotation); } /*! @@ -575,20 +577,20 @@ void QwtPlot::setAxisLabelRotation( QwtAxisId axisId, double rotation ) \sa axisMaxMinor() */ -void QwtPlot::setAxisMaxMinor( QwtAxisId axisId, int maxMinor ) +void QwtPlot::setAxisMaxMinor(QwtAxisId axisId, int maxMinor) { - if ( isAxisValid( axisId ) ) - { - maxMinor = qBound( 0, maxMinor, 100 ); + if (isAxisValid(axisId)) + { + maxMinor = qBound(0, maxMinor, 100); - QwtPlotAxisPrivate::AxisData& d = m_scaleData->axisData( axisId ); - if ( maxMinor != d.maxMinor ) - { - d.maxMinor = maxMinor; - d.isValid = false; - autoRefresh(); - } + QwtPlotAxisPrivate::AxisData &d = m_scaleData->axisData(axisId); + if (maxMinor != d.maxMinor) + { + d.maxMinor = maxMinor; + d.isValid = false; + autoRefresh(); } + } } /*! @@ -599,20 +601,20 @@ void QwtPlot::setAxisMaxMinor( QwtAxisId axisId, int maxMinor ) \sa axisMaxMajor() */ -void QwtPlot::setAxisMaxMajor( QwtAxisId axisId, int maxMajor ) +void QwtPlot::setAxisMaxMajor(QwtAxisId axisId, int maxMajor) { - if ( isAxisValid( axisId ) ) - { - maxMajor = qBound( 1, maxMajor, 10000 ); + if (isAxisValid(axisId)) + { + maxMajor = qBound(1, maxMajor, 10000); - QwtPlotAxisPrivate::AxisData& d = m_scaleData->axisData( axisId ); - if ( maxMajor != d.maxMajor ) - { - d.maxMajor = maxMajor; - d.isValid = false; - autoRefresh(); - } + QwtPlotAxisPrivate::AxisData &d = m_scaleData->axisData(axisId); + if (maxMajor != d.maxMajor) + { + d.maxMajor = maxMajor; + d.isValid = false; + autoRefresh(); } + } } /*! @@ -621,10 +623,10 @@ void QwtPlot::setAxisMaxMajor( QwtAxisId axisId, int maxMajor ) \param axisId Axis \param title axis title */ -void QwtPlot::setAxisTitle( QwtAxisId axisId, const QString& title ) +void QwtPlot::setAxisTitle(QwtAxisId axisId, const QString &title) { - if ( isAxisValid( axisId ) ) - axisWidget( axisId )->setTitle( title ); + if (isAxisValid(axisId)) + axisWidget(axisId)->setTitle(title); } /*! @@ -633,10 +635,10 @@ void QwtPlot::setAxisTitle( QwtAxisId axisId, const QString& title ) \param axisId Axis \param title Axis title */ -void QwtPlot::setAxisTitle( QwtAxisId axisId, const QwtText& title ) +void QwtPlot::setAxisTitle(QwtAxisId axisId, const QwtText &title) { - if ( isAxisValid( axisId ) ) - axisWidget( axisId )->setTitle( title ); + if (isAxisValid(axisId)) + axisWidget(axisId)->setTitle(title); } /*! @@ -665,85 +667,85 @@ void QwtPlot::setAxisTitle( QwtAxisId axisId, const QwtText& title ) */ void QwtPlot::updateAxes() { - // Find bounding interval of the item data - // for all axes, where autoscaling is enabled + // Find bounding interval of the item data + // for all axes, where autoscaling is enabled - QwtInterval boundingIntervals[QwtAxis::AxisPositions]; + QwtInterval boundingIntervals[QwtAxis::AxisPositions]; - const QwtPlotItemList& itmList = itemList(); + const QwtPlotItemList &itmList = itemList(); - QwtPlotItemIterator it; - for ( it = itmList.begin(); it != itmList.end(); ++it ) + QwtPlotItemIterator it; + for (it = itmList.begin(); it != itmList.end(); ++it) + { + const QwtPlotItem *item = *it; + + if (!item->testItemAttribute(QwtPlotItem::AutoScale)) + continue; + + if (!item->isVisible()) + continue; + + if (axisAutoScale(item->xAxis()) || axisAutoScale(item->yAxis())) { - const QwtPlotItem* item = *it; + const QRectF rect = item->boundingRect(); - if ( !item->testItemAttribute( QwtPlotItem::AutoScale ) ) - continue; + if (rect.width() >= 0.0) + boundingIntervals[item->xAxis()] + |= QwtInterval(rect.left(), rect.right()); - if ( !item->isVisible() ) - continue; - - if ( axisAutoScale( item->xAxis() ) || axisAutoScale( item->yAxis() ) ) - { - const QRectF rect = item->boundingRect(); - - if ( rect.width() >= 0.0 ) - boundingIntervals[item->xAxis()] |= QwtInterval( rect.left(), rect.right() ); - - if ( rect.height() >= 0.0 ) - boundingIntervals[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() ); - } + if (rect.height() >= 0.0) + boundingIntervals[item->yAxis()] + |= QwtInterval(rect.top(), rect.bottom()); } + } - // Adjust scales + // Adjust scales - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { - { - const QwtAxisId axisId( axisPos ); + const QwtAxisId axisId(axisPos); - QwtPlotAxisPrivate::AxisData& d = m_scaleData->axisData( axisId ); + QwtPlotAxisPrivate::AxisData &d = m_scaleData->axisData(axisId); - double minValue = d.minValue; - double maxValue = d.maxValue; - double stepSize = d.stepSize; + double minValue = d.minValue; + double maxValue = d.maxValue; + double stepSize = d.stepSize; - const QwtInterval& interval = boundingIntervals[axisId]; + const QwtInterval &interval = boundingIntervals[axisId]; - if ( d.doAutoScale && interval.isValid() ) - { - d.isValid = false; + if (d.doAutoScale && interval.isValid()) + { + d.isValid = false; - minValue = interval.minValue(); - maxValue = interval.maxValue(); + minValue = interval.minValue(); + maxValue = interval.maxValue(); - d.scaleEngine->autoScale( d.maxMajor, - minValue, maxValue, stepSize ); - } - if ( !d.isValid ) - { - d.scaleDiv = d.scaleEngine->divideScale( - minValue, maxValue, d.maxMajor, d.maxMinor, stepSize ); - d.isValid = true; - } + d.scaleEngine->autoScale(d.maxMajor, minValue, maxValue, stepSize); + } + if (!d.isValid) + { + d.scaleDiv = d.scaleEngine->divideScale(minValue, maxValue, d.maxMajor, + d.maxMinor, stepSize); + d.isValid = true; + } - QwtScaleWidget* scaleWidget = axisWidget( axisId ); - scaleWidget->setScaleDiv( d.scaleDiv ); + QwtScaleWidget *scaleWidget = axisWidget(axisId); + scaleWidget->setScaleDiv(d.scaleDiv); - int startDist, endDist; - scaleWidget->getBorderDistHint( startDist, endDist ); - scaleWidget->setBorderDist( startDist, endDist ); - } + int startDist, endDist; + scaleWidget->getBorderDistHint(startDist, endDist); + scaleWidget->setBorderDist(startDist, endDist); } + } - for ( it = itmList.begin(); it != itmList.end(); ++it ) + for (it = itmList.begin(); it != itmList.end(); ++it) + { + QwtPlotItem *item = *it; + if (item->testItemInterest(QwtPlotItem::ScaleInterest)) { - QwtPlotItem* item = *it; - if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) ) - { - item->updateScaleDiv( axisScaleDiv( item->xAxis() ), - axisScaleDiv( item->yAxis() ) ); - } + item->updateScaleDiv(axisScaleDiv(item->xAxis()), + axisScaleDiv(item->yAxis())); } + } } - diff --git a/libs/qwt/src/qwt_plot_barchart.cpp b/libs/qwt/src/qwt_plot_barchart.cpp index f2af17cc..fb334db9 100644 --- a/libs/qwt/src/qwt_plot_barchart.cpp +++ b/libs/qwt/src/qwt_plot_barchart.cpp @@ -18,58 +18,55 @@ class QwtPlotBarChart::PrivateData { - public: - PrivateData() - : symbol( NULL ) - , legendMode( QwtPlotBarChart::LegendChartTitle ) - { - } +public: + PrivateData() + : symbol(NULL) + , legendMode(QwtPlotBarChart::LegendChartTitle) + { + } - ~PrivateData() - { - delete symbol; - } + ~PrivateData() { delete symbol; } - QwtColumnSymbol* symbol; - QwtPlotBarChart::LegendMode legendMode; + QwtColumnSymbol *symbol; + QwtPlotBarChart::LegendMode legendMode; }; /*! Constructor \param title Title of the curve */ -QwtPlotBarChart::QwtPlotBarChart( const QwtText& title ) - : QwtPlotAbstractBarChart( title ) +QwtPlotBarChart::QwtPlotBarChart(const QwtText &title) + : QwtPlotAbstractBarChart(title) { - init(); + init(); } /*! Constructor \param title Title of the curve */ -QwtPlotBarChart::QwtPlotBarChart( const QString& title ) - : QwtPlotAbstractBarChart( QwtText( title ) ) +QwtPlotBarChart::QwtPlotBarChart(const QString &title) + : QwtPlotAbstractBarChart(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotBarChart::~QwtPlotBarChart() { - delete m_data; + delete m_data; } void QwtPlotBarChart::init() { - m_data = new PrivateData; - setData( new QwtPointSeriesData() ); + m_data = new PrivateData; + setData(new QwtPointSeriesData()); } //! \return QwtPlotItem::Rtti_PlotBarChart int QwtPlotBarChart::rtti() const { - return QwtPlotItem::Rtti_PlotBarChart; + return QwtPlotItem::Rtti_PlotBarChart; } /*! @@ -79,10 +76,9 @@ int QwtPlotBarChart::rtti() const \note QVector is implicitly shared \note QPolygonF is derived from QVector */ -void QwtPlotBarChart::setSamples( - const QVector< QPointF >& samples ) +void QwtPlotBarChart::setSamples(const QVector &samples) { - setData( new QwtPointSeriesData( samples ) ); + setData(new QwtPointSeriesData(samples)); } /*! @@ -94,16 +90,15 @@ void QwtPlotBarChart::setSamples( \param samples Vector of y coordinates \note QVector is implicitly shared */ -void QwtPlotBarChart::setSamples( - const QVector< double >& samples ) +void QwtPlotBarChart::setSamples(const QVector &samples) { - QVector< QPointF > points; - points.reserve( samples.size() ); + QVector points; + points.reserve(samples.size()); - for ( int i = 0; i < samples.size(); i++ ) - points += QPointF( i, samples[ i ] ); + for (int i = 0; i < samples.size(); i++) + points += QPointF(i, samples[i]); - setData( new QwtPointSeriesData( points ) ); + setData(new QwtPointSeriesData(points)); } /*! @@ -116,9 +111,9 @@ void QwtPlotBarChart::setSamples( \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotBarChart::setSamples( QwtSeriesData< QPointF >* data ) +void QwtPlotBarChart::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -131,25 +126,25 @@ void QwtPlotBarChart::setSamples( QwtSeriesData< QPointF >* data ) \param symbol Symbol \sa symbol() */ -void QwtPlotBarChart::setSymbol( QwtColumnSymbol* symbol ) +void QwtPlotBarChart::setSymbol(QwtColumnSymbol *symbol) { - if ( symbol != m_data->symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; + if (symbol != m_data->symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Current symbol or NULL, when no symbol has been assigned \sa setSymbol() */ -const QwtColumnSymbol* QwtPlotBarChart::symbol() const +const QwtColumnSymbol *QwtPlotBarChart::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -161,13 +156,13 @@ const QwtColumnSymbol* QwtPlotBarChart::symbol() const \param mode New mode \sa legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute */ -void QwtPlotBarChart::setLegendMode( LegendMode mode ) +void QwtPlotBarChart::setLegendMode(LegendMode mode) { - if ( mode != m_data->legendMode ) - { - m_data->legendMode = mode; - legendChanged(); - } + if (mode != m_data->legendMode) + { + m_data->legendMode = mode; + legendChanged(); + } } /*! @@ -176,7 +171,7 @@ void QwtPlotBarChart::setLegendMode( LegendMode mode ) */ QwtPlotBarChart::LegendMode QwtPlotBarChart::legendMode() const { - return m_data->legendMode; + return m_data->legendMode; } /*! @@ -185,26 +180,26 @@ QwtPlotBarChart::LegendMode QwtPlotBarChart::legendMode() const */ QRectF QwtPlotBarChart::boundingRect() const { - const int numSamples = dataSize(); - if ( numSamples == 0 ) - return QwtPlotSeriesItem::boundingRect(); + const int numSamples = dataSize(); + if (numSamples == 0) + return QwtPlotSeriesItem::boundingRect(); - QRectF rect = QwtPlotSeriesItem::boundingRect(); - if ( rect.height() >= 0 ) - { - const double baseLine = baseline(); + QRectF rect = QwtPlotSeriesItem::boundingRect(); + if (rect.height() >= 0) + { + const double baseLine = baseline(); - if ( rect.bottom() < baseLine ) - rect.setBottom( baseLine ); + if (rect.bottom() < baseLine) + rect.setBottom(baseLine); - if ( rect.top() > baseLine ) - rect.setTop( baseLine ); - } + if (rect.top() > baseLine) + rect.setTop(baseLine); + } - if ( orientation() == Qt::Horizontal ) - rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); + if (orientation() == Qt::Horizontal) + rect.setRect(rect.y(), rect.x(), rect.height(), rect.width()); - return rect; + return rect; } /*! @@ -220,32 +215,31 @@ QRectF QwtPlotBarChart::boundingRect() const \sa drawSymbols() */ -void QwtPlotBarChart::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotBarChart::drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( from > to ) - return; + if (from > to) + return; + const QRectF br = data()->boundingRect(); + const QwtInterval interval(br.left(), br.right()); - const QRectF br = data()->boundingRect(); - const QwtInterval interval( br.left(), br.right() ); + painter->save(); - painter->save(); + for (int i = from; i <= to; i++) + { + drawSample(painter, xMap, yMap, canvasRect, interval, i, sample(i)); + } - for ( int i = from; i <= to; i++ ) - { - drawSample( painter, xMap, yMap, - canvasRect, interval, i, sample( i ) ); - } - - painter->restore(); + painter->restore(); } /*! @@ -259,51 +253,52 @@ void QwtPlotBarChart::drawSeries(QPainter* painter, \return Geometry of the column */ -QwtColumnRect QwtPlotBarChart::columnRect( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - const QPointF& sample ) const +QwtColumnRect QwtPlotBarChart::columnRect(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, + const QwtInterval &boundingInterval, + const QPointF &sample) const { - QwtColumnRect barRect; + QwtColumnRect barRect; - if ( orientation() == Qt::Horizontal ) - { - const double barHeight = sampleWidth( yMap, canvasRect.height(), - boundingInterval.width(), sample.y() ); + if (orientation() == Qt::Horizontal) + { + const double barHeight = sampleWidth(yMap, canvasRect.height(), + boundingInterval.width(), sample.y()); - const double x1 = xMap.transform( baseline() ); - const double x2 = xMap.transform( sample.y() ); + const double x1 = xMap.transform(baseline()); + const double x2 = xMap.transform(sample.y()); - const double y = yMap.transform( sample.x() ); - const double y1 = y - 0.5 * barHeight; - const double y2 = y + 0.5 * barHeight; + const double y = yMap.transform(sample.x()); + const double y1 = y - 0.5 * barHeight; + const double y2 = y + 0.5 * barHeight; - barRect.direction = ( x1 < x2 ) ? - QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft; + barRect.direction + = (x1 < x2) ? QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft; - barRect.hInterval = QwtInterval( x1, x2 ).normalized(); - barRect.vInterval = QwtInterval( y1, y2 ); - } - else - { - const double barWidth = sampleWidth( xMap, canvasRect.width(), - boundingInterval.width(), sample.y() ); + barRect.hInterval = QwtInterval(x1, x2).normalized(); + barRect.vInterval = QwtInterval(y1, y2); + } + else + { + const double barWidth = sampleWidth(xMap, canvasRect.width(), + boundingInterval.width(), sample.y()); - const double x = xMap.transform( sample.x() ); - const double x1 = x - 0.5 * barWidth; - const double x2 = x + 0.5 * barWidth; + const double x = xMap.transform(sample.x()); + const double x1 = x - 0.5 * barWidth; + const double x2 = x + 0.5 * barWidth; - const double y1 = yMap.transform( baseline() ); - const double y2 = yMap.transform( sample.y() ); + const double y1 = yMap.transform(baseline()); + const double y2 = yMap.transform(sample.y()); - barRect.direction = ( y1 < y2 ) ? - QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop; + barRect.direction + = (y1 < y2) ? QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop; - barRect.hInterval = QwtInterval( x1, x2 ); - barRect.vInterval = QwtInterval( y1, y2 ).normalized(); - } + barRect.hInterval = QwtInterval(x1, x2); + barRect.vInterval = QwtInterval(y1, y2).normalized(); + } - return barRect; + return barRect; } /*! @@ -319,15 +314,16 @@ QwtColumnRect QwtPlotBarChart::columnRect( \sa drawSeries() */ -void QwtPlotBarChart::drawSample( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - int index, const QPointF& sample ) const +void QwtPlotBarChart::drawSample(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, + const QwtInterval &boundingInterval, int index, + const QPointF &sample) const { - const QwtColumnRect barRect = columnRect( xMap, yMap, - canvasRect, boundingInterval, sample ); + const QwtColumnRect barRect + = columnRect(xMap, yMap, canvasRect, boundingInterval, sample); - drawBar( painter, index, sample, barRect ); + drawBar(painter, index, sample, barRect); } /*! @@ -338,31 +334,30 @@ void QwtPlotBarChart::drawSample( QPainter* painter, \param sample Value of the sample \param rect Bounding rectangle of the bar */ -void QwtPlotBarChart::drawBar( QPainter* painter, - int sampleIndex, const QPointF& sample, - const QwtColumnRect& rect ) const +void QwtPlotBarChart::drawBar(QPainter *painter, int sampleIndex, + const QPointF &sample, + const QwtColumnRect &rect) const { - const QwtColumnSymbol* specialSym = - specialSymbol( sampleIndex, sample ); + const QwtColumnSymbol *specialSym = specialSymbol(sampleIndex, sample); - const QwtColumnSymbol* sym = specialSym; - if ( sym == NULL ) - sym = m_data->symbol; + const QwtColumnSymbol *sym = specialSym; + if (sym == NULL) + sym = m_data->symbol; - if ( sym ) - { - sym->draw( painter, rect ); - } - else - { - // we build a temporary default symbol - QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box ); - columnSymbol.setLineWidth( 1 ); - columnSymbol.setFrameStyle( QwtColumnSymbol::Plain ); - columnSymbol.draw( painter, rect ); - } + if (sym) + { + sym->draw(painter, rect); + } + else + { + // we build a temporary default symbol + QwtColumnSymbol columnSymbol(QwtColumnSymbol::Box); + columnSymbol.setLineWidth(1); + columnSymbol.setFrameStyle(QwtColumnSymbol::Plain); + columnSymbol.draw(painter, rect); + } - delete specialSym; + delete specialSym; } /*! @@ -374,13 +369,13 @@ void QwtPlotBarChart::drawBar( QPainter* painter, \return NULL, indicating to use the default symbol */ -QwtColumnSymbol* QwtPlotBarChart::specialSymbol( - int sampleIndex, const QPointF& sample ) const +QwtColumnSymbol *QwtPlotBarChart::specialSymbol(int sampleIndex, + const QPointF &sample) const { - Q_UNUSED( sampleIndex ); - Q_UNUSED( sample ); + Q_UNUSED(sampleIndex); + Q_UNUSED(sample); - return NULL; + return NULL; } /*! @@ -396,10 +391,10 @@ QwtColumnSymbol* QwtPlotBarChart::specialSymbol( \return An empty text \sa LegendBarTitles */ -QwtText QwtPlotBarChart::barTitle( int sampleIndex ) const +QwtText QwtPlotBarChart::barTitle(int sampleIndex) const { - Q_UNUSED( sampleIndex ); - return QwtText(); + Q_UNUSED(sampleIndex); + return QwtText(); } /*! @@ -413,37 +408,36 @@ QwtText QwtPlotBarChart::barTitle( int sampleIndex ) const \return Information, that is needed to represent the item on the legend \sa title(), setLegendMode(), barTitle(), QwtLegend, QwtPlotLegendItem */ -QList< QwtLegendData > QwtPlotBarChart::legendData() const +QList QwtPlotBarChart::legendData() const { - QList< QwtLegendData > list; + QList list; - if ( m_data->legendMode == LegendBarTitles ) + if (m_data->legendMode == LegendBarTitles) + { + const int numSamples = dataSize(); + list.reserve(numSamples); + + for (int i = 0; i < numSamples; i++) { - const int numSamples = dataSize(); - list.reserve( numSamples ); + QwtLegendData data; - for ( int i = 0; i < numSamples; i++ ) - { - QwtLegendData data; + data.setValue(QwtLegendData::TitleRole, QVariant::fromValue(barTitle(i))); - data.setValue( QwtLegendData::TitleRole, - QVariant::fromValue( barTitle( i ) ) ); + if (!legendIconSize().isEmpty()) + { + data.setValue(QwtLegendData::IconRole, + QVariant::fromValue(legendIcon(i, legendIconSize()))); + } - if ( !legendIconSize().isEmpty() ) - { - data.setValue( QwtLegendData::IconRole, - QVariant::fromValue( legendIcon( i, legendIconSize() ) ) ); - } - - list += data; - } - } - else - { - return QwtPlotAbstractBarChart::legendData(); + list += data; } + } + else + { + return QwtPlotAbstractBarChart::legendData(); + } - return list; + return list; } /*! @@ -459,26 +453,25 @@ QList< QwtLegendData > QwtPlotBarChart::legendData() const \sa setLegendMode(), drawBar(), QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() */ -QwtGraphic QwtPlotBarChart::legendIcon( - int index, const QSizeF& size ) const +QwtGraphic QwtPlotBarChart::legendIcon(int index, const QSizeF &size) const { - QwtColumnRect column; - column.hInterval = QwtInterval( 0.0, size.width() - 1.0 ); - column.vInterval = QwtInterval( 0.0, size.height() - 1.0 ); + QwtColumnRect column; + column.hInterval = QwtInterval(0.0, size.width() - 1.0); + column.vInterval = QwtInterval(0.0, size.height() - 1.0); - QwtGraphic icon; - icon.setDefaultSize( size ); - icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + QwtGraphic icon; + icon.setDefaultSize(size); + icon.setRenderHint(QwtGraphic::RenderPensUnscaled, true); - QPainter painter( &icon ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); + QPainter painter(&icon); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); - int barIndex = -1; - if ( m_data->legendMode == QwtPlotBarChart::LegendBarTitles ) - barIndex = index; + int barIndex = -1; + if (m_data->legendMode == QwtPlotBarChart::LegendBarTitles) + barIndex = index; - drawBar( &painter, barIndex, QPointF(), column ); + drawBar(&painter, barIndex, QPointF(), column); - return icon; + return icon; } diff --git a/libs/qwt/src/qwt_plot_barchart.h b/libs/qwt/src/qwt_plot_barchart.h index 1ca9a005..4aecafc5 100644 --- a/libs/qwt/src/qwt_plot_barchart.h +++ b/libs/qwt/src/qwt_plot_barchart.h @@ -15,7 +15,8 @@ class QwtColumnRect; class QwtColumnSymbol; -template< typename T > class QwtSeriesData; +template +class QwtSeriesData; /*! \brief QwtPlotBarChart displays a series of a values as bars. @@ -38,87 +39,85 @@ template< typename T > class QwtSeriesData; \sa QwtPlotMultiBarChart, QwtPlotHistogram, QwtPlotCurve::Sticks, QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline() */ -class QWT_EXPORT QwtPlotBarChart - : public QwtPlotAbstractBarChart - , public QwtSeriesStore< QPointF > +class QWT_EXPORT QwtPlotBarChart : public QwtPlotAbstractBarChart, + public QwtSeriesStore { - public: +public: + /*! + \brief Legend modes. + + The default setting is QwtPlotBarChart::LegendChartTitle. + \sa setLegendMode(), legendMode() + */ + enum LegendMode + { /*! - \brief Legend modes. + One entry on the legend showing the default symbol + and the title() of the chart - The default setting is QwtPlotBarChart::LegendChartTitle. - \sa setLegendMode(), legendMode() + \sa QwtPlotItem::title() */ - enum LegendMode - { - /*! - One entry on the legend showing the default symbol - and the title() of the chart + LegendChartTitle, - \sa QwtPlotItem::title() - */ - LegendChartTitle, + /*! + One entry for each value showing the individual symbol + of the corresponding bar and the bar title. - /*! - One entry for each value showing the individual symbol - of the corresponding bar and the bar title. + \sa specialSymbol(), barTitle() + */ + LegendBarTitles + }; - \sa specialSymbol(), barTitle() - */ - LegendBarTitles - }; + explicit QwtPlotBarChart(const QString &title = QString()); + explicit QwtPlotBarChart(const QwtText &title); - explicit QwtPlotBarChart( const QString& title = QString() ); - explicit QwtPlotBarChart( const QwtText& title ); + virtual ~QwtPlotBarChart(); - virtual ~QwtPlotBarChart(); + virtual int rtti() const QWT_OVERRIDE; - virtual int rtti() const QWT_OVERRIDE; + void setSamples(const QVector &); + void setSamples(const QVector &); + void setSamples(QwtSeriesData *); - void setSamples( const QVector< QPointF >& ); - void setSamples( const QVector< double >& ); - void setSamples( QwtSeriesData< QPointF >* ); + void setSymbol(QwtColumnSymbol *); + const QwtColumnSymbol *symbol() const; - void setSymbol( QwtColumnSymbol* ); - const QwtColumnSymbol* symbol() const; + void setLegendMode(LegendMode); + LegendMode legendMode() const; - void setLegendMode( LegendMode ); - LegendMode legendMode() const; + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QwtColumnSymbol *specialSymbol(int sampleIndex, + const QPointF &) const; - virtual QwtColumnSymbol* specialSymbol( - int sampleIndex, const QPointF& ) const; + virtual QwtText barTitle(int sampleIndex) const; - virtual QwtText barTitle( int sampleIndex ) const; +protected: + virtual void drawSample(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + const QwtInterval &boundingInterval, int index, + const QPointF &sample) const; - protected: - virtual void drawSample( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - int index, const QPointF& sample ) const; + virtual void drawBar(QPainter *, int sampleIndex, const QPointF &sample, + const QwtColumnRect &) const; - virtual void drawBar( QPainter*, - int sampleIndex, const QPointF& sample, - const QwtColumnRect& ) const; + QwtColumnRect columnRect(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect, + const QwtInterval &boundingInterval, + const QPointF &sample) const; - QwtColumnRect columnRect( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - const QPointF& sample ) const; + QList legendData() const QWT_OVERRIDE; + QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - QList< QwtLegendData > legendData() const QWT_OVERRIDE; - QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE; +private: + void init(); - private: - void init(); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_canvas.cpp b/libs/qwt/src/qwt_plot_canvas.cpp index 64422bfb..19219779 100644 --- a/libs/qwt/src/qwt_plot_canvas.cpp +++ b/libs/qwt/src/qwt_plot_canvas.cpp @@ -17,19 +17,16 @@ class QwtPlotCanvas::PrivateData { - public: - PrivateData() - : backingStore( NULL ) - { - } +public: + PrivateData() + : backingStore(NULL) + { + } - ~PrivateData() - { - delete backingStore; - } + ~PrivateData() { delete backingStore; } - QwtPlotCanvas::PaintAttributes paintAttributes; - QPixmap* backingStore; + QwtPlotCanvas::PaintAttributes paintAttributes; + QPixmap *backingStore; }; /*! @@ -38,25 +35,25 @@ class QwtPlotCanvas::PrivateData \param plot Parent plot widget \sa QwtPlot::setCanvas() */ -QwtPlotCanvas::QwtPlotCanvas( QwtPlot* plot ) - : QFrame( plot ) - , QwtPlotAbstractCanvas( this ) +QwtPlotCanvas::QwtPlotCanvas(QwtPlot *plot) + : QFrame(plot) + , QwtPlotAbstractCanvas(this) { - m_data = new PrivateData; + m_data = new PrivateData; - setPaintAttribute( QwtPlotCanvas::BackingStore, true ); - setPaintAttribute( QwtPlotCanvas::Opaque, true ); - setPaintAttribute( QwtPlotCanvas::HackStyledBackground, true ); + setPaintAttribute(QwtPlotCanvas::BackingStore, true); + setPaintAttribute(QwtPlotCanvas::Opaque, true); + setPaintAttribute(QwtPlotCanvas::HackStyledBackground, true); - setLineWidth( 2 ); - setFrameShadow( QFrame::Sunken ); - setFrameShape( QFrame::Panel ); + setLineWidth(2); + setFrameShadow(QFrame::Sunken); + setFrameShape(QFrame::Panel); } //! Destructor QwtPlotCanvas::~QwtPlotCanvas() { - delete m_data; + delete m_data; } /*! @@ -67,54 +64,50 @@ QwtPlotCanvas::~QwtPlotCanvas() \sa testPaintAttribute(), backingStore() */ -void QwtPlotCanvas::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPlotCanvas::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( bool( m_data->paintAttributes & attribute ) == on ) - return; + if (bool(m_data->paintAttributes & attribute) == on) + return; - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; - switch ( attribute ) - { - case BackingStore: + switch (attribute) + { + case BackingStore: { + if (on) + { + if (m_data->backingStore == NULL) + m_data->backingStore = new QPixmap(); + + if (isVisible()) { - if ( on ) - { - if ( m_data->backingStore == NULL ) - m_data->backingStore = new QPixmap(); - - if ( isVisible() ) - { #if QT_VERSION >= 0x050000 - *m_data->backingStore = grab( rect() ); + *m_data->backingStore = grab(rect()); #else - *m_data->backingStore = - QPixmap::grabWidget( this, rect() ); + *m_data->backingStore = QPixmap::grabWidget(this, rect()); #endif - } - } - else - { - delete m_data->backingStore; - m_data->backingStore = NULL; - } - break; - } - case Opaque: - { - if ( on ) - setAttribute( Qt::WA_OpaquePaintEvent, true ); - - break; - } - default: - { - break; } + } + else + { + delete m_data->backingStore; + m_data->backingStore = NULL; + } + break; } + case Opaque: { + if (on) + setAttribute(Qt::WA_OpaquePaintEvent, true); + + break; + } + default: { + break; + } + } } /*! @@ -124,22 +117,22 @@ void QwtPlotCanvas::setPaintAttribute( PaintAttribute attribute, bool on ) \return true, when attribute is enabled \sa setPaintAttribute() */ -bool QwtPlotCanvas::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPlotCanvas::testPaintAttribute(PaintAttribute attribute) const { - return m_data->paintAttributes & attribute; + return m_data->paintAttributes & attribute; } //! \return Backing store, might be null -const QPixmap* QwtPlotCanvas::backingStore() const +const QPixmap *QwtPlotCanvas::backingStore() const { - return m_data->backingStore; + return m_data->backingStore; } //! Invalidate the internal backing store void QwtPlotCanvas::invalidateBackingStore() { - if ( m_data->backingStore ) - *m_data->backingStore = QPixmap(); + if (m_data->backingStore) + *m_data->backingStore = QPixmap(); } /*! @@ -148,123 +141,123 @@ void QwtPlotCanvas::invalidateBackingStore() \param event Qt Event \return See QFrame::event() */ -bool QwtPlotCanvas::event( QEvent* event ) +bool QwtPlotCanvas::event(QEvent *event) { - if ( event->type() == QEvent::PolishRequest ) + if (event->type() == QEvent::PolishRequest) + { + if (testPaintAttribute(QwtPlotCanvas::Opaque)) { - if ( testPaintAttribute( QwtPlotCanvas::Opaque ) ) - { - // Setting a style sheet changes the - // Qt::WA_OpaquePaintEvent attribute, but we insist - // on painting the background. + // Setting a style sheet changes the + // Qt::WA_OpaquePaintEvent attribute, but we insist + // on painting the background. - setAttribute( Qt::WA_OpaquePaintEvent, true ); - } + setAttribute(Qt::WA_OpaquePaintEvent, true); } + } - if ( event->type() == QEvent::PolishRequest || - event->type() == QEvent::StyleChange ) - { - updateStyleSheetInfo(); - } + if (event->type() == QEvent::PolishRequest + || event->type() == QEvent::StyleChange) + { + updateStyleSheetInfo(); + } - return QFrame::event( event ); + return QFrame::event(event); } /*! Paint event \param event Paint event */ -void QwtPlotCanvas::paintEvent( QPaintEvent* event ) +void QwtPlotCanvas::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - if ( testPaintAttribute( QwtPlotCanvas::BackingStore ) && - m_data->backingStore != NULL ) + if (testPaintAttribute(QwtPlotCanvas::BackingStore) + && m_data->backingStore != NULL) + { + QPixmap &bs = *m_data->backingStore; + if (bs.size() != size() * QwtPainter::devicePixelRatio(&bs)) { - QPixmap& bs = *m_data->backingStore; - if ( bs.size() != size() * QwtPainter::devicePixelRatio( &bs ) ) + bs = QwtPainter::backingStore(this, size()); + + if (testAttribute(Qt::WA_StyledBackground)) + { + QPainter p(&bs); + drawStyled(&p, testPaintAttribute(HackStyledBackground)); + } + else + { + QPainter p; + if (borderRadius() <= 0.0) { - bs = QwtPainter::backingStore( this, size() ); - - if ( testAttribute(Qt::WA_StyledBackground) ) - { - QPainter p( &bs ); - drawStyled( &p, testPaintAttribute( HackStyledBackground ) ); - } - else - { - QPainter p; - if ( borderRadius() <= 0.0 ) - { - QwtPainter::fillPixmap( this, bs ); - p.begin( &bs ); - drawCanvas( &p ); - } - else - { - p.begin( &bs ); - drawUnstyled( &p ); - } - - if ( frameWidth() > 0 ) - drawBorder( &p ); - } - } - - painter.drawPixmap( 0, 0, *m_data->backingStore ); - } - else - { - if ( testAttribute(Qt::WA_StyledBackground ) ) - { - if ( testAttribute( Qt::WA_OpaquePaintEvent ) ) - { - drawStyled( &painter, testPaintAttribute( HackStyledBackground ) ); - } - else - { - drawCanvas( &painter ); - } + QwtPainter::fillPixmap(this, bs); + p.begin(&bs); + drawCanvas(&p); } else { - if ( testAttribute( Qt::WA_OpaquePaintEvent ) ) - { - if ( autoFillBackground() ) - { - fillBackground( &painter ); - drawBackground( &painter ); - } - } - else - { - if ( borderRadius() > 0.0 ) - { - QPainterPath clipPath; - clipPath.addRect( rect() ); - clipPath = clipPath.subtracted( borderPath( rect() ) ); - - painter.save(); - - painter.setClipPath( clipPath, Qt::IntersectClip ); - fillBackground( &painter ); - drawBackground( &painter ); - - painter.restore(); - } - } - - drawCanvas( &painter ); - - if ( frameWidth() > 0 ) - drawBorder( &painter ); + p.begin(&bs); + drawUnstyled(&p); } + + if (frameWidth() > 0) + drawBorder(&p); + } } - if ( hasFocus() && focusIndicator() == CanvasFocusIndicator ) - drawFocusIndicator( &painter ); + painter.drawPixmap(0, 0, *m_data->backingStore); + } + else + { + if (testAttribute(Qt::WA_StyledBackground)) + { + if (testAttribute(Qt::WA_OpaquePaintEvent)) + { + drawStyled(&painter, testPaintAttribute(HackStyledBackground)); + } + else + { + drawCanvas(&painter); + } + } + else + { + if (testAttribute(Qt::WA_OpaquePaintEvent)) + { + if (autoFillBackground()) + { + fillBackground(&painter); + drawBackground(&painter); + } + } + else + { + if (borderRadius() > 0.0) + { + QPainterPath clipPath; + clipPath.addRect(rect()); + clipPath = clipPath.subtracted(borderPath(rect())); + + painter.save(); + + painter.setClipPath(clipPath, Qt::IntersectClip); + fillBackground(&painter); + drawBackground(&painter); + + painter.restore(); + } + } + + drawCanvas(&painter); + + if (frameWidth() > 0) + drawBorder(&painter); + } + } + + if (hasFocus() && focusIndicator() == CanvasFocusIndicator) + drawFocusIndicator(&painter); } /*! @@ -273,25 +266,25 @@ void QwtPlotCanvas::paintEvent( QPaintEvent* event ) \param painter Painter \sa setBorderRadius() */ -void QwtPlotCanvas::drawBorder( QPainter* painter ) +void QwtPlotCanvas::drawBorder(QPainter *painter) { - if ( borderRadius() <= 0 ) - { - drawFrame( painter ); - return; - } + if (borderRadius() <= 0) + { + drawFrame(painter); + return; + } - QwtPlotAbstractCanvas::drawBorder( painter ); + QwtPlotAbstractCanvas::drawBorder(painter); } /*! Resize event \param event Resize event */ -void QwtPlotCanvas::resizeEvent( QResizeEvent* event ) +void QwtPlotCanvas::resizeEvent(QResizeEvent *event) { - QFrame::resizeEvent( event ); - updateStyleSheetInfo(); + QFrame::resizeEvent(event); + updateStyleSheetInfo(); } /*! @@ -300,12 +293,12 @@ void QwtPlotCanvas::resizeEvent( QResizeEvent* event ) */ void QwtPlotCanvas::replot() { - invalidateBackingStore(); + invalidateBackingStore(); - if ( testPaintAttribute( QwtPlotCanvas::ImmediatePaint ) ) - repaint( contentsRect() ); - else - update( contentsRect() ); + if (testPaintAttribute(QwtPlotCanvas::ImmediatePaint)) + repaint(contentsRect()); + else + update(contentsRect()); } /*! @@ -317,11 +310,11 @@ void QwtPlotCanvas::replot() \param rect Bounding rectangle of the canvas \return Painter path, that can be used for clipping */ -QPainterPath QwtPlotCanvas::borderPath( const QRect& rect ) const +QPainterPath QwtPlotCanvas::borderPath(const QRect &rect) const { - return canvasBorderPath( rect ); + return canvasBorderPath(rect); } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_canvas.cpp" +# include "moc_qwt_plot_canvas.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_canvas.h b/libs/qwt/src/qwt_plot_canvas.h index b13336dc..c586710b 100644 --- a/libs/qwt/src/qwt_plot_canvas.h +++ b/libs/qwt/src/qwt_plot_canvas.h @@ -28,106 +28,105 @@ class QPainterPath; */ class QWT_EXPORT QwtPlotCanvas : public QFrame, public QwtPlotAbstractCanvas { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius ) + Q_PROPERTY(double borderRadius READ borderRadius WRITE setBorderRadius) - public: +public: + /*! + \brief Paint attributes + + The default setting enables BackingStore and Opaque. + + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { + /*! + \brief Paint double buffered reusing the content + of the pixmap buffer when possible. + + Using a backing store might improve the performance + significantly, when working with widget overlays ( like rubber bands ). + Disabling the cache might improve the performance for + incremental paints (using QwtPlotDirectPainter ). + + \sa backingStore(), invalidateBackingStore() + */ + BackingStore = 1, /*! - \brief Paint attributes + \brief Try to fill the complete contents rectangle + of the plot canvas - The default setting enables BackingStore and Opaque. + When using styled backgrounds Qt assumes, that the + canvas doesn't fill its area completely + ( f.e because of rounded borders ) and fills the area + below the canvas. When this is done with gradients it might + result in a serious performance bottleneck - depending on the size. - \sa setPaintAttribute(), testPaintAttribute() + When the Opaque attribute is enabled the canvas tries to + identify the gaps with some heuristics and to fill those only. + + \warning Will not work for semitransparent backgrounds */ - enum PaintAttribute - { - /*! - \brief Paint double buffered reusing the content - of the pixmap buffer when possible. + Opaque = 2, - Using a backing store might improve the performance - significantly, when working with widget overlays ( like rubber bands ). - Disabling the cache might improve the performance for - incremental paints (using QwtPlotDirectPainter ). + /*! + \brief Try to improve painting of styled backgrounds - \sa backingStore(), invalidateBackingStore() - */ - BackingStore = 1, + QwtPlotCanvas supports the box model attributes for + customizing the layout with style sheets. Unfortunately + the design of Qt style sheets has no concept how to + handle backgrounds with rounded corners - beside of padding. - /*! - \brief Try to fill the complete contents rectangle - of the plot canvas + When HackStyledBackground is enabled the plot canvas tries + to separate the background from the background border + by reverse engineering to paint the background before and + the border after the plot items. In this order the border + gets perfectly antialiased and you can avoid some pixel + artifacts in the corners. + */ + HackStyledBackground = 4, - When using styled backgrounds Qt assumes, that the - canvas doesn't fill its area completely - ( f.e because of rounded borders ) and fills the area - below the canvas. When this is done with gradients it might - result in a serious performance bottleneck - depending on the size. + /*! + When ImmediatePaint is set replot() calls repaint() + instead of update(). - When the Opaque attribute is enabled the canvas tries to - identify the gaps with some heuristics and to fill those only. + \sa replot(), QWidget::repaint(), QWidget::update() + */ + ImmediatePaint = 8 + }; - \warning Will not work for semitransparent backgrounds - */ - Opaque = 2, + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - /*! - \brief Try to improve painting of styled backgrounds + explicit QwtPlotCanvas(QwtPlot * = NULL); + virtual ~QwtPlotCanvas(); - QwtPlotCanvas supports the box model attributes for - customizing the layout with style sheets. Unfortunately - the design of Qt style sheets has no concept how to - handle backgrounds with rounded corners - beside of padding. + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - When HackStyledBackground is enabled the plot canvas tries - to separate the background from the background border - by reverse engineering to paint the background before and - the border after the plot items. In this order the border - gets perfectly antialiased and you can avoid some pixel - artifacts in the corners. - */ - HackStyledBackground = 4, + const QPixmap *backingStore() const; + Q_INVOKABLE void invalidateBackingStore(); - /*! - When ImmediatePaint is set replot() calls repaint() - instead of update(). + virtual bool event(QEvent *) QWT_OVERRIDE; - \sa replot(), QWidget::repaint(), QWidget::update() - */ - ImmediatePaint = 8 - }; + Q_INVOKABLE QPainterPath borderPath(const QRect &) const; - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) +public Q_SLOTS: + void replot(); - explicit QwtPlotCanvas( QwtPlot* = NULL ); - virtual ~QwtPlotCanvas(); +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + virtual void drawBorder(QPainter *) QWT_OVERRIDE; - const QPixmap* backingStore() const; - Q_INVOKABLE void invalidateBackingStore(); - - virtual bool event( QEvent* ) QWT_OVERRIDE; - - Q_INVOKABLE QPainterPath borderPath( const QRect& ) const; - - public Q_SLOTS: - void replot(); - - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; - - virtual void drawBorder( QPainter* ) QWT_OVERRIDE; - - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCanvas::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCanvas::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_curve.cpp b/libs/qwt/src/qwt_plot_curve.cpp index 923422bd..770cf15f 100644 --- a/libs/qwt/src/qwt_plot_curve.cpp +++ b/libs/qwt/src/qwt_plot_curve.cpp @@ -23,128 +23,129 @@ #include #include -static inline QRectF qwtIntersectedClipRect( const QRectF& rect, QPainter* painter ) +static inline QRectF qwtIntersectedClipRect(const QRectF &rect, + QPainter *painter) { - QRectF clipRect = rect; - if ( painter->hasClipping() ) - clipRect &= painter->clipBoundingRect(); + QRectF clipRect = rect; + if (painter->hasClipping()) + clipRect &= painter->clipBoundingRect(); - return clipRect; + return clipRect; } -static void qwtUpdateLegendIconSize( QwtPlotCurve* curve ) +static void qwtUpdateLegendIconSize(QwtPlotCurve *curve) { - if ( curve->symbol() && - curve->testLegendAttribute( QwtPlotCurve::LegendShowSymbol ) ) + if (curve->symbol() + && curve->testLegendAttribute(QwtPlotCurve::LegendShowSymbol)) + { + QSize sz = curve->symbol()->boundingRect().size(); + sz += QSize(2, 2); // margin + + if (curve->testLegendAttribute(QwtPlotCurve::LegendShowLine)) { - QSize sz = curve->symbol()->boundingRect().size(); - sz += QSize( 2, 2 ); // margin + // Avoid, that the line is completely covered by the symbol - if ( curve->testLegendAttribute( QwtPlotCurve::LegendShowLine ) ) - { - // Avoid, that the line is completely covered by the symbol + int w = qwtCeil(1.5 * sz.width()); + if (w % 2) + w++; - int w = qwtCeil( 1.5 * sz.width() ); - if ( w % 2 ) - w++; - - sz.setWidth( qMax( 8, w ) ); - } - - curve->setLegendIconSize( sz ); + sz.setWidth(qMax(8, w)); } + + curve->setLegendIconSize(sz); + } } -static int qwtVerifyRange( int size, int& i1, int& i2 ) +static int qwtVerifyRange(int size, int &i1, int &i2) { - if ( size < 1 ) - return 0; + if (size < 1) + return 0; - i1 = qBound( 0, i1, size - 1 ); - i2 = qBound( 0, i2, size - 1 ); + i1 = qBound(0, i1, size - 1); + i2 = qBound(0, i2, size - 1); - if ( i1 > i2 ) - qSwap( i1, i2 ); + if (i1 > i2) + qSwap(i1, i2); - return ( i2 - i1 + 1 ); + return (i2 - i1 + 1); } class QwtPlotCurve::PrivateData { - public: - PrivateData() - : style( QwtPlotCurve::Lines ) - , baseline( 0.0 ) - , symbol( NULL ) - , pen( Qt::black ) - , paintAttributes( QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ) - { - curveFitter = new QwtSplineCurveFitter; - } +public: + PrivateData() + : style(QwtPlotCurve::Lines) + , baseline(0.0) + , symbol(NULL) + , pen(Qt::black) + , paintAttributes(QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints) + { + curveFitter = new QwtSplineCurveFitter; + } - ~PrivateData() - { - delete symbol; - delete curveFitter; - } + ~PrivateData() + { + delete symbol; + delete curveFitter; + } - QwtPlotCurve::CurveStyle style; - double baseline; + QwtPlotCurve::CurveStyle style; + double baseline; - const QwtSymbol* symbol; - QwtCurveFitter* curveFitter; + const QwtSymbol *symbol; + QwtCurveFitter *curveFitter; - QPen pen; - QBrush brush; + QPen pen; + QBrush brush; - QwtPlotCurve::CurveAttributes attributes; - QwtPlotCurve::PaintAttributes paintAttributes; + QwtPlotCurve::CurveAttributes attributes; + QwtPlotCurve::PaintAttributes paintAttributes; - QwtPlotCurve::LegendAttributes legendAttributes; + QwtPlotCurve::LegendAttributes legendAttributes; }; /*! Constructor \param title Title of the curve */ -QwtPlotCurve::QwtPlotCurve( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotCurve::QwtPlotCurve(const QwtText &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } /*! Constructor \param title Title of the curve */ -QwtPlotCurve::QwtPlotCurve( const QString& title ) - : QwtPlotSeriesItem( QwtText( title ) ) +QwtPlotCurve::QwtPlotCurve(const QString &title) + : QwtPlotSeriesItem(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotCurve::~QwtPlotCurve() { - delete m_data; + delete m_data; } //! Initialize internal members void QwtPlotCurve::init() { - setItemAttribute( QwtPlotItem::Legend ); - setItemAttribute( QwtPlotItem::AutoScale ); + setItemAttribute(QwtPlotItem::Legend); + setItemAttribute(QwtPlotItem::AutoScale); - m_data = new PrivateData; - setData( new QwtPointSeriesData() ); + m_data = new PrivateData; + setData(new QwtPointSeriesData()); - setZ( 20.0 ); + setZ(20.0); } //! \return QwtPlotItem::Rtti_PlotCurve int QwtPlotCurve::rtti() const { - return QwtPlotItem::Rtti_PlotCurve; + return QwtPlotItem::Rtti_PlotCurve; } /*! @@ -154,21 +155,21 @@ int QwtPlotCurve::rtti() const \param on On/Off \sa testPaintAttribute() */ -void QwtPlotCurve::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPlotCurve::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! \return True, when attribute is enabled \sa setPaintAttribute() */ -bool QwtPlotCurve::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPlotCurve::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! @@ -178,27 +179,27 @@ bool QwtPlotCurve::testPaintAttribute( PaintAttribute attribute ) const \param on On/Off /sa testLegendAttribute(). legendIcon() */ -void QwtPlotCurve::setLegendAttribute( LegendAttribute attribute, bool on ) +void QwtPlotCurve::setLegendAttribute(LegendAttribute attribute, bool on) { - if ( on != testLegendAttribute( attribute ) ) - { - if ( on ) - m_data->legendAttributes |= attribute; - else - m_data->legendAttributes &= ~attribute; + if (on != testLegendAttribute(attribute)) + { + if (on) + m_data->legendAttributes |= attribute; + else + m_data->legendAttributes &= ~attribute; - qwtUpdateLegendIconSize( this ); - legendChanged(); - } + qwtUpdateLegendIconSize(this); + legendChanged(); + } } /*! \return True, when attribute is enabled \sa setLegendAttribute() */ -bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const +bool QwtPlotCurve::testLegendAttribute(LegendAttribute attribute) const { - return ( m_data->legendAttributes & attribute ); + return (m_data->legendAttributes & attribute); } /*! @@ -207,15 +208,15 @@ bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const \param attributes Attributes /sa setLegendAttribute(). legendIcon() */ -void QwtPlotCurve::setLegendAttributes( LegendAttributes attributes ) +void QwtPlotCurve::setLegendAttributes(LegendAttributes attributes) { - if ( attributes != m_data->legendAttributes ) - { - m_data->legendAttributes = attributes; + if (attributes != m_data->legendAttributes) + { + m_data->legendAttributes = attributes; - qwtUpdateLegendIconSize( this ); - legendChanged(); - } + qwtUpdateLegendIconSize(this); + legendChanged(); + } } /*! @@ -224,7 +225,7 @@ void QwtPlotCurve::setLegendAttributes( LegendAttributes attributes ) */ QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes() const { - return m_data->legendAttributes; + return m_data->legendAttributes; } /*! @@ -233,15 +234,15 @@ QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes() const \param style Curve style \sa style() */ -void QwtPlotCurve::setStyle( CurveStyle style ) +void QwtPlotCurve::setStyle(CurveStyle style) { - if ( style != m_data->style ) - { - m_data->style = style; + if (style != m_data->style) + { + m_data->style = style; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -250,7 +251,7 @@ void QwtPlotCurve::setStyle( CurveStyle style ) */ QwtPlotCurve::CurveStyle QwtPlotCurve::style() const { - return m_data->style; + return m_data->style; } /*! @@ -263,27 +264,27 @@ QwtPlotCurve::CurveStyle QwtPlotCurve::style() const \param symbol Symbol \sa symbol() */ -void QwtPlotCurve::setSymbol( QwtSymbol* symbol ) +void QwtPlotCurve::setSymbol(QwtSymbol *symbol) { - if ( symbol != m_data->symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; + if (symbol != m_data->symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; - qwtUpdateLegendIconSize( this ); + qwtUpdateLegendIconSize(this); - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Current symbol or NULL, when no symbol has been assigned \sa setSymbol() */ -const QwtSymbol* QwtPlotCurve::symbol() const +const QwtSymbol *QwtPlotCurve::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -299,9 +300,9 @@ const QwtSymbol* QwtPlotCurve::symbol() const \sa pen(), brush() */ -void QwtPlotCurve::setPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotCurve::setPen(const QColor &color, qreal width, Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -310,24 +311,24 @@ void QwtPlotCurve::setPen( const QColor& color, qreal width, Qt::PenStyle style \param pen New pen \sa pen(), brush() */ -void QwtPlotCurve::setPen( const QPen& pen ) +void QwtPlotCurve::setPen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; + if (pen != m_data->pen) + { + m_data->pen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Pen used to draw the lines \sa setPen(), brush() */ -const QPen& QwtPlotCurve::pen() const +const QPen &QwtPlotCurve::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -345,24 +346,24 @@ const QPen& QwtPlotCurve::pen() const \param brush New brush \sa brush(), setBaseline(), baseline() */ -void QwtPlotCurve::setBrush( const QBrush& brush ) +void QwtPlotCurve::setBrush(const QBrush &brush) { - if ( brush != m_data->brush ) - { - m_data->brush = brush; + if (brush != m_data->brush) + { + m_data->brush = brush; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Brush used to fill the area between lines and the baseline \sa setBrush(), setBaseline(), baseline() */ -const QBrush& QwtPlotCurve::brush() const +const QBrush &QwtPlotCurve::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -378,41 +379,39 @@ const QBrush& QwtPlotCurve::brush() const \sa drawCurve(), drawSymbols(), */ -void QwtPlotCurve::drawSeries( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const { - const int numSamples = dataSize(); + const int numSamples = dataSize(); - if ( !painter || numSamples <= 0 ) - return; + if (!painter || numSamples <= 0) + return; - if ( to < 0 ) - to = numSamples - 1; + if (to < 0) + to = numSamples - 1; - if ( qwtVerifyRange( numSamples, from, to ) > 0 ) + if (qwtVerifyRange(numSamples, from, to) > 0) + { + painter->save(); + painter->setPen(m_data->pen); + + /* + Qt 4.0.0 is slow when drawing lines, but it's even + slower when the painter has a brush. So we don't + set the brush before we really need it. + */ + + drawCurve(painter, m_data->style, xMap, yMap, canvasRect, from, to); + painter->restore(); + + if (m_data->symbol && (m_data->symbol->style() != QwtSymbol::NoSymbol)) { - painter->save(); - painter->setPen( m_data->pen ); - - /* - Qt 4.0.0 is slow when drawing lines, but it's even - slower when the painter has a brush. So we don't - set the brush before we really need it. - */ - - drawCurve( painter, m_data->style, xMap, yMap, canvasRect, from, to ); - painter->restore(); - - if ( m_data->symbol && - ( m_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - painter->save(); - drawSymbols( painter, *m_data->symbol, - xMap, yMap, canvasRect, from, to ); - painter->restore(); - } + painter->save(); + drawSymbols(painter, *m_data->symbol, xMap, yMap, canvasRect, from, to); + painter->restore(); } + } } /*! @@ -426,35 +425,35 @@ void QwtPlotCurve::drawSeries( QPainter* painter, \param to index of the last point to be painted \sa draw(), drawDots(), drawLines(), drawSteps(), drawSticks() */ -void QwtPlotCurve::drawCurve( QPainter* painter, int style, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawCurve(QPainter *painter, int style, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, int to) const { - switch ( style ) - { - case Lines: - if ( testCurveAttribute( Fitted ) ) - { - // we always need the complete - // curve for fitting - from = 0; - to = dataSize() - 1; - } - drawLines( painter, xMap, yMap, canvasRect, from, to ); - break; - case Sticks: - drawSticks( painter, xMap, yMap, canvasRect, from, to ); - break; - case Steps: - drawSteps( painter, xMap, yMap, canvasRect, from, to ); - break; - case Dots: - drawDots( painter, xMap, yMap, canvasRect, from, to ); - break; - case NoCurve: - default: - break; - } + switch (style) + { + case Lines: + if (testCurveAttribute(Fitted)) + { + // we always need the complete + // curve for fitting + from = 0; + to = dataSize() - 1; + } + drawLines(painter, xMap, yMap, canvasRect, from, to); + break; + case Sticks: + drawSticks(painter, xMap, yMap, canvasRect, from, to); + break; + case Steps: + drawSteps(painter, xMap, yMap, canvasRect, from, to); + break; + case Dots: + drawDots(painter, xMap, yMap, canvasRect, from, to); + break; + case NoCurve: + default: + break; + } } /*! @@ -473,101 +472,101 @@ void QwtPlotCurve::drawCurve( QPainter* painter, int style, \sa setCurveAttribute(), setCurveFitter(), draw(), drawLines(), drawDots(), drawSteps(), drawSticks() */ -void QwtPlotCurve::drawLines( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawLines(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const { - if ( from > to ) - return; + if (from > to) + return; - const bool doFit = ( m_data->attributes & Fitted ) && m_data->curveFitter; - const bool doAlign = !doFit && QwtPainter::roundingAlignment( painter ); - const bool doFill = ( m_data->brush.style() != Qt::NoBrush ) - && ( m_data->brush.color().alpha() > 0 ); + const bool doFit = (m_data->attributes & Fitted) && m_data->curveFitter; + const bool doAlign = !doFit && QwtPainter::roundingAlignment(painter); + const bool doFill = (m_data->brush.style() != Qt::NoBrush) + && (m_data->brush.color().alpha() > 0); - QRectF clipRect; - if ( m_data->paintAttributes & ClipPolygons ) + QRectF clipRect; + if (m_data->paintAttributes & ClipPolygons) + { + clipRect = qwtIntersectedClipRect(canvasRect, painter); + + const qreal pw = QwtPainter::effectivePenWidth(painter->pen()); + clipRect = clipRect.adjusted(-pw, -pw, pw, pw); + } + + QwtPointMapper mapper; + + if (doAlign) + { + mapper.setFlag(QwtPointMapper::RoundPoints, true); + mapper.setFlag(QwtPointMapper::WeedOutIntermediatePoints, + testPaintAttribute(FilterPointsAggressive)); + } + + mapper.setFlag(QwtPointMapper::WeedOutPoints, + testPaintAttribute(FilterPoints) + || testPaintAttribute(FilterPointsAggressive)); + + mapper.setBoundingRect(canvasRect); + + QPolygonF polyline = mapper.toPolygonF(xMap, yMap, data(), from, to); + + if (doFill) + { + if (doFit) { - clipRect = qwtIntersectedClipRect( canvasRect, painter ); + // it might be better to extend and draw the curvePath, but for + // the moment we keep an implementation, where we translate the + // path back to a polyline. - const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); - clipRect = clipRect.adjusted(-pw, -pw, pw, pw); + polyline = m_data->curveFitter->fitCurve(polyline); } - QwtPointMapper mapper; - - if ( doAlign ) + if (painter->pen().style() != Qt::NoPen) { - mapper.setFlag( QwtPointMapper::RoundPoints, true ); - mapper.setFlag( QwtPointMapper::WeedOutIntermediatePoints, - testPaintAttribute( FilterPointsAggressive ) ); - } + // here we are wasting memory for the filled copy, + // do polygon clipping twice etc .. TODO - mapper.setFlag( QwtPointMapper::WeedOutPoints, - testPaintAttribute( FilterPoints ) || - testPaintAttribute( FilterPointsAggressive ) ); + QPolygonF filled = polyline; + fillCurve(painter, xMap, yMap, canvasRect, filled); + filled.clear(); - mapper.setBoundingRect( canvasRect ); + if (m_data->paintAttributes & ClipPolygons) + QwtClipper::clipPolygonF(clipRect, polyline, false); - QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to ); - - if ( doFill ) - { - if ( doFit ) - { - // it might be better to extend and draw the curvePath, but for - // the moment we keep an implementation, where we translate the - // path back to a polyline. - - polyline = m_data->curveFitter->fitCurve( polyline ); - } - - if ( painter->pen().style() != Qt::NoPen ) - { - // here we are wasting memory for the filled copy, - // do polygon clipping twice etc .. TODO - - QPolygonF filled = polyline; - fillCurve( painter, xMap, yMap, canvasRect, filled ); - filled.clear(); - - if ( m_data->paintAttributes & ClipPolygons ) - QwtClipper::clipPolygonF( clipRect, polyline, false ); - - QwtPainter::drawPolyline( painter, polyline ); - } - else - { - fillCurve( painter, xMap, yMap, canvasRect, polyline ); - } + QwtPainter::drawPolyline(painter, polyline); } else { - if ( testPaintAttribute( ClipPolygons ) ) - { - QwtClipper::clipPolygonF( clipRect, polyline, false ); - } - - if ( doFit ) - { - if ( m_data->curveFitter->mode() == QwtCurveFitter::Path ) - { - const QPainterPath curvePath = - m_data->curveFitter->fitCurvePath( polyline ); - - painter->drawPath( curvePath ); - } - else - { - polyline = m_data->curveFitter->fitCurve( polyline ); - QwtPainter::drawPolyline( painter, polyline ); - } - } - else - { - QwtPainter::drawPolyline( painter, polyline ); - } + fillCurve(painter, xMap, yMap, canvasRect, polyline); } + } + else + { + if (testPaintAttribute(ClipPolygons)) + { + QwtClipper::clipPolygonF(clipRect, polyline, false); + } + + if (doFit) + { + if (m_data->curveFitter->mode() == QwtCurveFitter::Path) + { + const QPainterPath curvePath + = m_data->curveFitter->fitCurvePath(polyline); + + painter->drawPath(curvePath); + } + else + { + polyline = m_data->curveFitter->fitCurve(polyline); + QwtPainter::drawPolyline(painter, polyline); + } + } + else + { + QwtPainter::drawPolyline(painter, polyline); + } + } } /*! @@ -582,47 +581,47 @@ void QwtPlotCurve::drawLines( QPainter* painter, \sa draw(), drawCurve(), drawDots(), drawLines(), drawSteps() */ -void QwtPlotCurve::drawSticks( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawSticks(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const { - Q_UNUSED( canvasRect ) + Q_UNUSED(canvasRect) - painter->save(); - painter->setRenderHint( QPainter::Antialiasing, false ); + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, false); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - double x0 = xMap.transform( m_data->baseline ); - double y0 = yMap.transform( m_data->baseline ); - if ( doAlign ) + double x0 = xMap.transform(m_data->baseline); + double y0 = yMap.transform(m_data->baseline); + if (doAlign) + { + x0 = qRound(x0); + y0 = qRound(y0); + } + + const Qt::Orientation o = orientation(); + + const QwtSeriesData *series = data(); + + for (int i = from; i <= to; i++) + { + const QPointF sample = series->sample(i); + double xi = xMap.transform(sample.x()); + double yi = yMap.transform(sample.y()); + if (doAlign) { - x0 = qRound( x0 ); - y0 = qRound( y0 ); + xi = qRound(xi); + yi = qRound(yi); } - const Qt::Orientation o = orientation(); + if (o == Qt::Horizontal) + QwtPainter::drawLine(painter, x0, yi, xi, yi); + else + QwtPainter::drawLine(painter, xi, y0, xi, yi); + } - const QwtSeriesData< QPointF >* series = data(); - - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = series->sample( i ); - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( o == Qt::Horizontal ) - QwtPainter::drawLine( painter, x0, yi, xi, yi ); - else - QwtPainter::drawLine( painter, xi, y0, xi, yi ); - } - - painter->restore(); + painter->restore(); } /*! @@ -637,90 +636,86 @@ void QwtPlotCurve::drawSticks( QPainter* painter, \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps() */ -void QwtPlotCurve::drawDots( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawDots(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const { - const QColor color = painter->pen().color(); + const QColor color = painter->pen().color(); - if ( painter->pen().style() == Qt::NoPen || color.alpha() == 0 ) + if (painter->pen().style() == Qt::NoPen || color.alpha() == 0) + { + return; + } + + const bool doFill = (m_data->brush.style() != Qt::NoBrush) + && (m_data->brush.color().alpha() > 0); + const bool doAlign = QwtPainter::roundingAlignment(painter); + + QwtPointMapper mapper; + mapper.setBoundingRect(canvasRect); + mapper.setFlag(QwtPointMapper::RoundPoints, doAlign); + + if (m_data->paintAttributes & FilterPoints) + { + if ((color.alpha() == 255) + && !(painter->renderHints() & QPainter::Antialiasing)) { - return; + mapper.setFlag(QwtPointMapper::WeedOutPoints, true); } + } - const bool doFill = ( m_data->brush.style() != Qt::NoBrush ) - && ( m_data->brush.color().alpha() > 0 ); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + if (doFill) + { + mapper.setFlag(QwtPointMapper::WeedOutPoints, false); - QwtPointMapper mapper; - mapper.setBoundingRect( canvasRect ); - mapper.setFlag( QwtPointMapper::RoundPoints, doAlign ); + QPolygonF points = mapper.toPolygonF(xMap, yMap, data(), from, to); - if ( m_data->paintAttributes & FilterPoints ) + QwtPainter::drawPoints(painter, points); + fillCurve(painter, xMap, yMap, canvasRect, points); + } + else if (m_data->paintAttributes & ImageBuffer) + { + const QImage image = mapper.toImage( + xMap, yMap, data(), from, to, m_data->pen, + painter->testRenderHint(QPainter::Antialiasing), renderThreadCount()); + + painter->drawImage(canvasRect.toAlignedRect(), image); + } + else if (m_data->paintAttributes & MinimizeMemory) + { + const QwtSeriesData *series = data(); + + for (int i = from; i <= to; i++) { - if ( ( color.alpha() == 255 ) - && !( painter->renderHints() & QPainter::Antialiasing ) ) - { - mapper.setFlag( QwtPointMapper::WeedOutPoints, true ); - } + const QPointF sample = series->sample(i); + + double xi = xMap.transform(sample.x()); + double yi = yMap.transform(sample.y()); + + if (doAlign) + { + xi = qRound(xi); + yi = qRound(yi); + } + + QwtPainter::drawPoint(painter, QPointF(xi, yi)); } - - if ( doFill ) + } + else + { + if (doAlign) { - mapper.setFlag( QwtPointMapper::WeedOutPoints, false ); + const QPolygon points = mapper.toPoints(xMap, yMap, data(), from, to); - QPolygonF points = mapper.toPolygonF( - xMap, yMap, data(), from, to ); - - QwtPainter::drawPoints( painter, points ); - fillCurve( painter, xMap, yMap, canvasRect, points ); - } - else if ( m_data->paintAttributes & ImageBuffer ) - { - const QImage image = mapper.toImage( xMap, yMap, - data(), from, to, m_data->pen, - painter->testRenderHint( QPainter::Antialiasing ), - renderThreadCount() ); - - painter->drawImage( canvasRect.toAlignedRect(), image ); - } - else if ( m_data->paintAttributes & MinimizeMemory ) - { - const QwtSeriesData< QPointF >* series = data(); - - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = series->sample( i ); - - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - QwtPainter::drawPoint( painter, QPointF( xi, yi ) ); - } + QwtPainter::drawPoints(painter, points); } else { - if ( doAlign ) - { - const QPolygon points = mapper.toPoints( - xMap, yMap, data(), from, to ); + const QPolygonF points = mapper.toPointsF(xMap, yMap, data(), from, to); - QwtPainter::drawPoints( painter, points ); - } - else - { - const QPolygonF points = mapper.toPointsF( - xMap, yMap, data(), from, to ); - - QwtPainter::drawPoints( painter, points ); - } + QwtPainter::drawPoints(painter, points); } + } } /*! @@ -738,76 +733,75 @@ void QwtPlotCurve::drawDots( QPainter* painter, \sa CurveAttribute, setCurveAttribute(), draw(), drawCurve(), drawDots(), drawLines(), drawSticks() */ -void QwtPlotCurve::drawSteps( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawSteps(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const { - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - QPolygonF polygon( 2 * ( to - from ) + 1 ); - QPointF* points = polygon.data(); + QPolygonF polygon(2 * (to - from) + 1); + QPointF *points = polygon.data(); - bool inverted = orientation() == Qt::Vertical; - if ( m_data->attributes & Inverted ) - inverted = !inverted; + bool inverted = orientation() == Qt::Vertical; + if (m_data->attributes & Inverted) + inverted = !inverted; - const QwtSeriesData< QPointF >* series = data(); + const QwtSeriesData *series = data(); - int i, ip; - for ( i = from, ip = 0; i <= to; i++, ip += 2 ) + int i, ip; + for (i = from, ip = 0; i <= to; i++, ip += 2) + { + const QPointF sample = series->sample(i); + double xi = xMap.transform(sample.x()); + double yi = yMap.transform(sample.y()); + if (doAlign) { - const QPointF sample = series->sample( i ); - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( ip > 0 ) - { - const QPointF& p0 = points[ip - 2]; - QPointF& p = points[ip - 1]; - - if ( inverted ) - { - p.rx() = p0.x(); - p.ry() = yi; - } - else - { - p.rx() = xi; - p.ry() = p0.y(); - } - } - - points[ip].rx() = xi; - points[ip].ry() = yi; + xi = qRound(xi); + yi = qRound(yi); } - if ( m_data->paintAttributes & ClipPolygons ) + if (ip > 0) { - QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); + const QPointF &p0 = points[ip - 2]; + QPointF &p = points[ip - 1]; - const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); - clipRect = clipRect.adjusted(-pw, -pw, pw, pw); - - const QPolygonF clipped = QwtClipper::clippedPolygonF( - clipRect, polygon, false ); - - QwtPainter::drawPolyline( painter, clipped ); - } - else - { - QwtPainter::drawPolyline( painter, polygon ); + if (inverted) + { + p.rx() = p0.x(); + p.ry() = yi; + } + else + { + p.rx() = xi; + p.ry() = p0.y(); + } } - if ( m_data->brush.style() != Qt::NoBrush ) - fillCurve( painter, xMap, yMap, canvasRect, polygon ); + points[ip].rx() = xi; + points[ip].ry() = yi; + } + + if (m_data->paintAttributes & ClipPolygons) + { + QRectF clipRect = qwtIntersectedClipRect(canvasRect, painter); + + const qreal pw = QwtPainter::effectivePenWidth(painter->pen()); + clipRect = clipRect.adjusted(-pw, -pw, pw, pw); + + const QPolygonF clipped + = QwtClipper::clippedPolygonF(clipRect, polygon, false); + + QwtPainter::drawPolyline(painter, clipped); + } + else + { + QwtPainter::drawPolyline(painter, polygon); + } + + if (m_data->brush.style() != Qt::NoBrush) + fillCurve(painter, xMap, yMap, canvasRect, polygon); } - /*! Specify an attribute for drawing the curve @@ -816,26 +810,26 @@ void QwtPlotCurve::drawSteps( QPainter* painter, /sa testCurveAttribute(), setCurveFitter() */ -void QwtPlotCurve::setCurveAttribute( CurveAttribute attribute, bool on ) +void QwtPlotCurve::setCurveAttribute(CurveAttribute attribute, bool on) { - if ( bool( m_data->attributes & attribute ) == on ) - return; + if (bool(m_data->attributes & attribute) == on) + return; - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; - itemChanged(); + itemChanged(); } /*! \return true, if attribute is enabled \sa setCurveAttribute() */ -bool QwtPlotCurve::testCurveAttribute( CurveAttribute attribute ) const +bool QwtPlotCurve::testCurveAttribute(CurveAttribute attribute) const { - return m_data->attributes & attribute; + return m_data->attributes & attribute; } /*! @@ -855,12 +849,12 @@ bool QwtPlotCurve::testCurveAttribute( CurveAttribute attribute ) const \param curveFitter() Curve fitter \sa Fitted */ -void QwtPlotCurve::setCurveFitter( QwtCurveFitter* curveFitter ) +void QwtPlotCurve::setCurveFitter(QwtCurveFitter *curveFitter) { - delete m_data->curveFitter; - m_data->curveFitter = curveFitter; + delete m_data->curveFitter; + m_data->curveFitter = curveFitter; - itemChanged(); + itemChanged(); } /*! @@ -869,9 +863,9 @@ void QwtPlotCurve::setCurveFitter( QwtCurveFitter* curveFitter ) \return Curve fitter \sa setCurveFitter(), Fitted */ -QwtCurveFitter* QwtPlotCurve::curveFitter() const +QwtCurveFitter *QwtPlotCurve::curveFitter() const { - return m_data->curveFitter; + return m_data->curveFitter; } /*! @@ -886,35 +880,35 @@ QwtCurveFitter* QwtPlotCurve::curveFitter() const \sa setBrush(), setBaseline(), setStyle() */ -void QwtPlotCurve::fillCurve( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, QPolygonF& polygon ) const +void QwtPlotCurve::fillCurve(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + QPolygonF &polygon) const { - if ( m_data->brush.style() == Qt::NoBrush ) - return; + if (m_data->brush.style() == Qt::NoBrush) + return; - closePolyline( painter, xMap, yMap, polygon ); - if ( polygon.count() <= 2 ) // a line can't be filled - return; + closePolyline(painter, xMap, yMap, polygon); + if (polygon.count() <= 2) // a line can't be filled + return; - QBrush brush = m_data->brush; - if ( !brush.color().isValid() ) - brush.setColor( m_data->pen.color() ); + QBrush brush = m_data->brush; + if (!brush.color().isValid()) + brush.setColor(m_data->pen.color()); - if ( m_data->paintAttributes & ClipPolygons ) - { - const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); - QwtClipper::clipPolygonF( clipRect, polygon, true ); - } + if (m_data->paintAttributes & ClipPolygons) + { + const QRectF clipRect = qwtIntersectedClipRect(canvasRect, painter); + QwtClipper::clipPolygonF(clipRect, polygon, true); + } - painter->save(); + painter->save(); - painter->setPen( Qt::NoPen ); - painter->setBrush( brush ); + painter->setPen(Qt::NoPen); + painter->setBrush(brush); - QwtPainter::drawPolygon( painter, polygon ); + QwtPainter::drawPolygon(painter, polygon); - painter->restore(); + painter->restore(); } /*! @@ -926,41 +920,41 @@ void QwtPlotCurve::fillCurve( QPainter* painter, \param yMap Y map \param polygon Polygon to be completed */ -void QwtPlotCurve::closePolyline( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - QPolygonF& polygon ) const +void QwtPlotCurve::closePolyline(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + QPolygonF &polygon) const { - if ( polygon.size() < 2 ) - return; + if (polygon.size() < 2) + return; - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - double baseline = m_data->baseline; + double baseline = m_data->baseline; - if ( orientation() == Qt::Vertical ) - { - if ( yMap.transformation() ) - baseline = yMap.transformation()->bounded( baseline ); + if (orientation() == Qt::Vertical) + { + if (yMap.transformation()) + baseline = yMap.transformation()->bounded(baseline); - double refY = yMap.transform( baseline ); - if ( doAlign ) - refY = qRound( refY ); + double refY = yMap.transform(baseline); + if (doAlign) + refY = qRound(refY); - polygon += QPointF( polygon.last().x(), refY ); - polygon += QPointF( polygon.first().x(), refY ); - } - else - { - if ( xMap.transformation() ) - baseline = xMap.transformation()->bounded( baseline ); + polygon += QPointF(polygon.last().x(), refY); + polygon += QPointF(polygon.first().x(), refY); + } + else + { + if (xMap.transformation()) + baseline = xMap.transformation()->bounded(baseline); - double refX = xMap.transform( baseline ); - if ( doAlign ) - refX = qRound( refX ); + double refX = xMap.transform(baseline); + if (doAlign) + refX = qRound(refX); - polygon += QPointF( refX, polygon.last().y() ); - polygon += QPointF( refX, polygon.first().y() ); - } + polygon += QPointF(refX, polygon.last().y()); + polygon += QPointF(refX, polygon.first().y()); + } } /*! @@ -976,31 +970,30 @@ void QwtPlotCurve::closePolyline( QPainter* painter, \sa setSymbol(), drawSeries(), drawCurve() */ -void QwtPlotCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol &symbol, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, int to) const { - QwtPointMapper mapper; - mapper.setFlag( QwtPointMapper::RoundPoints, - QwtPainter::roundingAlignment( painter ) ); - mapper.setFlag( QwtPointMapper::WeedOutPoints, - testPaintAttribute( QwtPlotCurve::FilterPoints ) ); + QwtPointMapper mapper; + mapper.setFlag(QwtPointMapper::RoundPoints, + QwtPainter::roundingAlignment(painter)); + mapper.setFlag(QwtPointMapper::WeedOutPoints, + testPaintAttribute(QwtPlotCurve::FilterPoints)); - const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); - mapper.setBoundingRect( clipRect ); + const QRectF clipRect = qwtIntersectedClipRect(canvasRect, painter); + mapper.setBoundingRect(clipRect); - const int chunkSize = 500; + const int chunkSize = 500; - for ( int i = from; i <= to; i += chunkSize ) - { - const int n = qMin( chunkSize, to - i + 1 ); + for (int i = from; i <= to; i += chunkSize) + { + const int n = qMin(chunkSize, to - i + 1); - const QPolygonF points = mapper.toPointsF( xMap, yMap, - data(), i, i + n - 1 ); + const QPolygonF points = mapper.toPointsF(xMap, yMap, data(), i, i + n - 1); - if ( points.size() > 0 ) - symbol.drawSymbols( painter, points ); - } + if (points.size() > 0) + symbol.drawSymbols(painter, points); + } } /*! @@ -1017,15 +1010,16 @@ void QwtPlotCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol, The default value is 0.0. \param value Value of the baseline - \sa baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation() + \sa baseline(), setBrush(), setStyle(), + QwtPlotAbstractSeriesItem::orientation() */ -void QwtPlotCurve::setBaseline( double value ) +void QwtPlotCurve::setBaseline(double value) { - if ( m_data->baseline != value ) - { - m_data->baseline = value; - itemChanged(); - } + if (m_data->baseline != value) + { + m_data->baseline = value; + itemChanged(); + } } /*! @@ -1034,7 +1028,7 @@ void QwtPlotCurve::setBaseline( double value ) */ double QwtPlotCurve::baseline() const { - return m_data->baseline; + return m_data->baseline; } /*! @@ -1048,39 +1042,39 @@ double QwtPlotCurve::baseline() const \note closestPoint() implements a dumb algorithm, that iterates over all points */ -int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const +int QwtPlotCurve::closestPoint(const QPointF &pos, double *dist) const { - const int numSamples = dataSize(); + const int numSamples = dataSize(); - if ( plot() == NULL || numSamples <= 0 ) - return -1; + if (plot() == NULL || numSamples <= 0) + return -1; - const QwtSeriesData< QPointF >* series = data(); + const QwtSeriesData *series = data(); - const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot()->canvasMap( yAxis() ); + const QwtScaleMap xMap = plot()->canvasMap(xAxis()); + const QwtScaleMap yMap = plot()->canvasMap(yAxis()); - int index = -1; - double dmin = 1.0e10; + int index = -1; + double dmin = 1.0e10; - for ( int i = 0; i < numSamples; i++ ) + for (int i = 0; i < numSamples; i++) + { + const QPointF sample = series->sample(i); + + const double cx = xMap.transform(sample.x()) - pos.x(); + const double cy = yMap.transform(sample.y()) - pos.y(); + + const double f = qwtSqr(cx) + qwtSqr(cy); + if (f < dmin) { - const QPointF sample = series->sample( i ); - - const double cx = xMap.transform( sample.x() ) - pos.x(); - const double cy = yMap.transform( sample.y() ) - pos.y(); - - const double f = qwtSqr( cx ) + qwtSqr( cy ); - if ( f < dmin ) - { - index = i; - dmin = f; - } + index = i; + dmin = f; } - if ( dist ) - *dist = std::sqrt( dmin ); + } + if (dist) + *dist = std::sqrt(dmin); - return index; + return index; } /*! @@ -1092,71 +1086,70 @@ int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() */ -QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF& size ) const +QwtGraphic QwtPlotCurve::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); + Q_UNUSED(index); - if ( size.isEmpty() ) - return QwtGraphic(); + if (size.isEmpty()) + return QwtGraphic(); - QwtGraphic graphic; - graphic.setDefaultSize( size ); - graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + QwtGraphic graphic; + graphic.setDefaultSize(size); + graphic.setRenderHint(QwtGraphic::RenderPensUnscaled, true); - QPainter painter( &graphic ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); + QPainter painter(&graphic); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); - if ( m_data->legendAttributes == 0 || - m_data->legendAttributes & QwtPlotCurve::LegendShowBrush ) + if (m_data->legendAttributes == 0 + || m_data->legendAttributes & QwtPlotCurve::LegendShowBrush) + { + QBrush brush = m_data->brush; + + if (brush.style() == Qt::NoBrush && m_data->legendAttributes == 0) { - QBrush brush = m_data->brush; - - if ( brush.style() == Qt::NoBrush && - m_data->legendAttributes == 0 ) - { - if ( style() != QwtPlotCurve::NoCurve ) - { - brush = QBrush( pen().color() ); - } - else if ( m_data->symbol && - ( m_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - brush = QBrush( m_data->symbol->pen().color() ); - } - } - - if ( brush.style() != Qt::NoBrush ) - { - QRectF r( 0, 0, size.width(), size.height() ); - painter.fillRect( r, brush ); - } + if (style() != QwtPlotCurve::NoCurve) + { + brush = QBrush(pen().color()); + } + else if (m_data->symbol + && (m_data->symbol->style() != QwtSymbol::NoSymbol)) + { + brush = QBrush(m_data->symbol->pen().color()); + } } - if ( m_data->legendAttributes & QwtPlotCurve::LegendShowLine ) + if (brush.style() != Qt::NoBrush) { - if ( pen() != Qt::NoPen ) - { - QPen pn = pen(); - pn.setCapStyle( Qt::FlatCap ); - - painter.setPen( pn ); - - const double y = 0.5 * size.height(); - QwtPainter::drawLine( &painter, 0.0, y, size.width(), y ); - } + QRectF r(0, 0, size.width(), size.height()); + painter.fillRect(r, brush); } + } - if ( m_data->legendAttributes & QwtPlotCurve::LegendShowSymbol ) + if (m_data->legendAttributes & QwtPlotCurve::LegendShowLine) + { + if (pen() != Qt::NoPen) { - if ( m_data->symbol ) - { - QRectF r( 0, 0, size.width(), size.height() ); - m_data->symbol->drawSymbol( &painter, r ); - } - } + QPen pn = pen(); + pn.setCapStyle(Qt::FlatCap); - return graphic; + painter.setPen(pn); + + const double y = 0.5 * size.height(); + QwtPainter::drawLine(&painter, 0.0, y, size.width(), y); + } + } + + if (m_data->legendAttributes & QwtPlotCurve::LegendShowSymbol) + { + if (m_data->symbol) + { + QRectF r(0, 0, size.width(), size.height()); + m_data->symbol->drawSymbol(&painter, r); + } + } + + return graphic; } /*! @@ -1169,9 +1162,9 @@ QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF& size ) const \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotCurve::setSamples( QwtSeriesData< QPointF >* data ) +void QwtPlotCurve::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -1181,9 +1174,9 @@ void QwtPlotCurve::setSamples( QwtSeriesData< QPointF >* data ) \note QVector is implicitly shared \note QPolygonF is derived from QVector */ -void QwtPlotCurve::setSamples( const QVector< QPointF >& samples ) +void QwtPlotCurve::setSamples(const QVector &samples) { - setData( new QwtPointSeriesData( samples ) ); + setData(new QwtPointSeriesData(samples)); } /*! @@ -1200,10 +1193,10 @@ void QwtPlotCurve::setSamples( const QVector< QPointF >& samples ) \sa QwtCPointerData */ -void QwtPlotCurve::setRawSamples( - const double* xData, const double* yData, int size ) +void QwtPlotCurve::setRawSamples(const double *xData, const double *yData, + int size) { - setData( new QwtCPointerData< double >( xData, yData, size ) ); + setData(new QwtCPointerData(xData, yData, size)); } /*! @@ -1220,10 +1213,10 @@ void QwtPlotCurve::setRawSamples( \sa QwtCPointerData */ -void QwtPlotCurve::setRawSamples( - const float* xData, const float* yData, int size ) +void QwtPlotCurve::setRawSamples(const float *xData, const float *yData, + int size) { - setData( new QwtCPointerData< float >( xData, yData, size ) ); + setData(new QwtCPointerData(xData, yData, size)); } /*! @@ -1242,9 +1235,9 @@ void QwtPlotCurve::setRawSamples( \sa QwtCPointerData */ -void QwtPlotCurve::setRawSamples( const double* yData, int size ) +void QwtPlotCurve::setRawSamples(const double *yData, int size) { - setData( new QwtCPointerValueData< double >( yData, size ) ); + setData(new QwtCPointerValueData(yData, size)); } /*! @@ -1263,9 +1256,9 @@ void QwtPlotCurve::setRawSamples( const double* yData, int size ) \sa QwtCPointerData */ -void QwtPlotCurve::setRawSamples( const float* yData, int size ) +void QwtPlotCurve::setRawSamples(const float *yData, int size) { - setData( new QwtCPointerValueData< float >( yData, size ) ); + setData(new QwtCPointerValueData(yData, size)); } /*! @@ -1279,10 +1272,10 @@ void QwtPlotCurve::setRawSamples( const float* yData, int size ) \sa QwtPointArrayData */ -void QwtPlotCurve::setSamples( - const double* xData, const double* yData, int size ) +void QwtPlotCurve::setSamples(const double *xData, const double *yData, + int size) { - setData( new QwtPointArrayData< double >( xData, yData, size ) ); + setData(new QwtPointArrayData(xData, yData, size)); } /*! @@ -1296,10 +1289,9 @@ void QwtPlotCurve::setSamples( \sa QwtPointArrayData */ -void QwtPlotCurve::setSamples( - const float* xData, const float* yData, int size ) +void QwtPlotCurve::setSamples(const float *xData, const float *yData, int size) { - setData( new QwtPointArrayData< float >( xData, yData, size ) ); + setData(new QwtPointArrayData(xData, yData, size)); } /*! @@ -1310,10 +1302,10 @@ void QwtPlotCurve::setSamples( \sa QwtPointArrayData */ -void QwtPlotCurve::setSamples( const QVector< double >& xData, - const QVector< double >& yData ) +void QwtPlotCurve::setSamples(const QVector &xData, + const QVector &yData) { - setData( new QwtPointArrayData< double >( xData, yData ) ); + setData(new QwtPointArrayData(xData, yData)); } /*! @@ -1324,10 +1316,10 @@ void QwtPlotCurve::setSamples( const QVector< double >& xData, \sa QwtPointArrayData */ -void QwtPlotCurve::setSamples( const QVector< float >& xData, - const QVector< float >& yData ) +void QwtPlotCurve::setSamples(const QVector &xData, + const QVector &yData) { - setData( new QwtPointArrayData< float >( xData, yData ) ); + setData(new QwtPointArrayData(xData, yData)); } /*! @@ -1341,9 +1333,9 @@ void QwtPlotCurve::setSamples( const QVector< float >& xData, \sa QwtValuePointData */ -void QwtPlotCurve::setSamples( const double* yData, int size ) +void QwtPlotCurve::setSamples(const double *yData, int size) { - setData( new QwtValuePointData< double >( yData, size ) ); + setData(new QwtValuePointData(yData, size)); } /*! @@ -1357,9 +1349,9 @@ void QwtPlotCurve::setSamples( const double* yData, int size ) \sa QwtValuePointData */ -void QwtPlotCurve::setSamples( const float* yData, int size ) +void QwtPlotCurve::setSamples(const float *yData, int size) { - setData( new QwtValuePointData< float >( yData, size ) ); + setData(new QwtValuePointData(yData, size)); } /*! @@ -1372,9 +1364,9 @@ void QwtPlotCurve::setSamples( const float* yData, int size ) \sa QwtValuePointData */ -void QwtPlotCurve::setSamples( const QVector< double >& yData ) +void QwtPlotCurve::setSamples(const QVector &yData) { - setData( new QwtValuePointData< double >( yData ) ); + setData(new QwtValuePointData(yData)); } /*! @@ -1387,7 +1379,7 @@ void QwtPlotCurve::setSamples( const QVector< double >& yData ) \sa QwtValuePointData */ -void QwtPlotCurve::setSamples( const QVector< float >& yData ) +void QwtPlotCurve::setSamples(const QVector &yData) { - setData( new QwtValuePointData< float >( yData ) ); + setData(new QwtValuePointData(yData)); } diff --git a/libs/qwt/src/qwt_plot_curve.h b/libs/qwt/src/qwt_plot_curve.h index 953543df..37e03c3b 100644 --- a/libs/qwt/src/qwt_plot_curve.h +++ b/libs/qwt/src/qwt_plot_curve.h @@ -18,7 +18,8 @@ class QwtScaleMap; class QwtSymbol; class QwtCurveFitter; -template< typename T > class QwtSeriesData; +template +class QwtSeriesData; class QwtText; class QPainter; class QPolygonF; @@ -40,8 +41,8 @@ class QPen;

b) Connect/Assign data.
QwtPlotCurve gets its points using a QwtSeriesData object offering a bridge to the real storage of the points ( like QAbstractItemModel ). - There are several convenience classes derived from QwtSeriesData, that also store - the points inside ( like QStandardItemModel ). QwtPlotCurve also offers + There are several convenience classes derived from QwtSeriesData, that also + store the points inside ( like QStandardItemModel ). QwtPlotCurve also offers a couple of variations of setSamples(), that build QwtSeriesData objects from arrays internally.
c) Attach the curve to a plot
@@ -53,324 +54,321 @@ class QPen; \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap */ -class QWT_EXPORT QwtPlotCurve - : public QwtPlotSeriesItem - , public QwtSeriesStore< QPointF > +class QWT_EXPORT QwtPlotCurve : public QwtPlotSeriesItem, + public QwtSeriesStore { - public: +public: + /*! + Curve styles. + \sa setStyle(), style() + */ + enum CurveStyle + { /*! - Curve styles. - \sa setStyle(), style() + Don't draw a curve. Note: This doesn't affect the symbols. */ - enum CurveStyle - { - /*! - Don't draw a curve. Note: This doesn't affect the symbols. - */ - NoCurve = -1, - - /*! - Connect the points with straight lines. The lines might - be interpolated depending on the 'Fitted' attribute. Curve - fitting can be configured using setCurveFitter(). - */ - Lines, - - /*! - Draw vertical or horizontal sticks ( depending on the - orientation() ) from a baseline which is defined by setBaseline(). - */ - Sticks, - - /*! - Connect the points with a step function. The step function - is drawn from the left to the right or vice versa, - depending on the QwtPlotCurve::Inverted attribute. - */ - Steps, - - /*! - Draw dots at the locations of the data points. Note: - This is different from a dotted line (see setPen()), and faster - as a curve in QwtPlotCurve::NoStyle style and a symbol - painting a point. - */ - Dots, - - /*! - Styles >= QwtPlotCurve::UserCurve are reserved for derived - classes of QwtPlotCurve that overload drawCurve() with - additional application specific curve types. - */ - UserCurve = 100 - }; + NoCurve = -1, /*! - Attribute for drawing the curve - \sa setCurveAttribute(), testCurveAttribute(), curveFitter() + Connect the points with straight lines. The lines might + be interpolated depending on the 'Fitted' attribute. Curve + fitting can be configured using setCurveFitter(). */ - enum CurveAttribute - { - /*! - For QwtPlotCurve::Steps only. - Draws a step function from the right to the left. - */ - Inverted = 0x01, - - /*! - Only in combination with QwtPlotCurve::Lines - A QwtCurveFitter tries to - interpolate/smooth the curve, before it is painted. - - \note Curve fitting requires temporary memory - for calculating coefficients and additional points. - If painting in QwtPlotCurve::Fitted mode is slow it might be better - to fit the points, before they are passed to QwtPlotCurve. - */ - Fitted = 0x02 - }; - - Q_DECLARE_FLAGS( CurveAttributes, CurveAttribute ) + Lines, /*! - Attributes how to represent the curve on the legend - - \sa setLegendAttribute(), testLegendAttribute(), - QwtPlotItem::legendData(), legendIcon() + Draw vertical or horizontal sticks ( depending on the + orientation() ) from a baseline which is defined by setBaseline(). */ - - enum LegendAttribute - { - /*! - QwtPlotCurve tries to find a color representing the curve - and paints a rectangle with it. - */ - LegendNoAttribute = 0x00, - - /*! - If the style() is not QwtPlotCurve::NoCurve a line - is painted with the curve pen(). - */ - LegendShowLine = 0x01, - - /*! - If the curve has a valid symbol it is painted. - */ - LegendShowSymbol = 0x02, - - /*! - If the curve has a brush a rectangle filled with the - curve brush() is painted. - */ - LegendShowBrush = 0x04 - }; - - Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute ) + Sticks, /*! - Attributes to modify the drawing algorithm. - The default setting enables ClipPolygons | FilterPoints - - \sa setPaintAttribute(), testPaintAttribute() + Connect the points with a step function. The step function + is drawn from the left to the right or vice versa, + depending on the QwtPlotCurve::Inverted attribute. */ - enum PaintAttribute - { - /*! - Clip polygons before painting them. In situations, where points - are far outside the visible area (f.e when zooming deep) this - might be a substantial improvement for the painting performance - */ - ClipPolygons = 0x01, + Steps, - /*! - Tries to reduce the data that has to be painted, by sorting out - duplicates, or paintings outside the visible area. Might have a - notable impact on curves with many close points. - Only a couple of very basic filtering algorithms are implemented. - */ - FilterPoints = 0x02, + /*! + Draw dots at the locations of the data points. Note: + This is different from a dotted line (see setPen()), and faster + as a curve in QwtPlotCurve::NoStyle style and a symbol + painting a point. + */ + Dots, - /*! - Minimize memory usage that is temporarily needed for the - translated points, before they get painted. - This might slow down the performance of painting - */ - MinimizeMemory = 0x04, + /*! + Styles >= QwtPlotCurve::UserCurve are reserved for derived + classes of QwtPlotCurve that overload drawCurve() with + additional application specific curve types. + */ + UserCurve = 100 + }; - /*! - Render the points to a temporary image and paint the image. - This is a very special optimization for Dots style, when - having a huge amount of points. - With a reasonable number of points QPainter::drawPoints() - will be faster. - */ - ImageBuffer = 0x08, + /*! + Attribute for drawing the curve + \sa setCurveAttribute(), testCurveAttribute(), curveFitter() + */ + enum CurveAttribute + { + /*! + For QwtPlotCurve::Steps only. + Draws a step function from the right to the left. + */ + Inverted = 0x01, - /*! - More aggressive point filtering trying to filter out - intermediate points, accepting minor visual differences. + /*! + Only in combination with QwtPlotCurve::Lines + A QwtCurveFitter tries to + interpolate/smooth the curve, before it is painted. - Has only an effect, when drawing the curve to a paint device - in integer coordinates ( f.e. all widgets on screen ) using the fact, - that consecutive points are often mapped to the same x or y coordinate. - Each chunk of samples mapped to the same coordinate can be reduced to - 4 points ( first, min, max last ). + \note Curve fitting requires temporary memory + for calculating coefficients and additional points. + If painting in QwtPlotCurve::Fitted mode is slow it might be better + to fit the points, before they are passed to QwtPlotCurve. + */ + Fitted = 0x02 + }; - In the worst case the polygon to be rendered will be 4 times the width - of the plot canvas. + Q_DECLARE_FLAGS(CurveAttributes, CurveAttribute) - The algorithm is very fast and effective for huge datasets, and can be used - inside a replot cycle. + /*! + Attributes how to represent the curve on the legend - \note Implemented for QwtPlotCurve::Lines only - \note As this algo replaces many small lines by a long one - a nasty bug of the raster paint engine ( Qt 4.8, Qt 5.1 - 5.3 ) - becomes more dominant. For these versions the bug can be - worked around by enabling the QwtPainter::polylineSplitting() mode. - */ - FilterPointsAggressive = 0x10, - }; + \sa setLegendAttribute(), testLegendAttribute(), + QwtPlotItem::legendData(), legendIcon() + */ - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + enum LegendAttribute + { + /*! + QwtPlotCurve tries to find a color representing the curve + and paints a rectangle with it. + */ + LegendNoAttribute = 0x00, - explicit QwtPlotCurve( const QString& title = QString() ); - explicit QwtPlotCurve( const QwtText& title ); + /*! + If the style() is not QwtPlotCurve::NoCurve a line + is painted with the curve pen(). + */ + LegendShowLine = 0x01, - virtual ~QwtPlotCurve(); + /*! + If the curve has a valid symbol it is painted. + */ + LegendShowSymbol = 0x02, - virtual int rtti() const QWT_OVERRIDE; + /*! + If the curve has a brush a rectangle filled with the + curve brush() is painted. + */ + LegendShowBrush = 0x04 + }; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + Q_DECLARE_FLAGS(LegendAttributes, LegendAttribute) - void setLegendAttribute( LegendAttribute, bool on = true ); - bool testLegendAttribute( LegendAttribute ) const; + /*! + Attributes to modify the drawing algorithm. + The default setting enables ClipPolygons | FilterPoints - void setLegendAttributes( LegendAttributes ); - LegendAttributes legendAttributes() const; + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { + /*! + Clip polygons before painting them. In situations, where points + are far outside the visible area (f.e when zooming deep) this + might be a substantial improvement for the painting performance + */ + ClipPolygons = 0x01, - void setRawSamples( const double* xData, const double* yData, int size ); - void setRawSamples( const float* xData, const float* yData, int size ); + /*! + Tries to reduce the data that has to be painted, by sorting out + duplicates, or paintings outside the visible area. Might have a + notable impact on curves with many close points. + Only a couple of very basic filtering algorithms are implemented. + */ + FilterPoints = 0x02, - void setRawSamples( const double* yData, int size ); - void setRawSamples( const float* yData, int size ); + /*! + Minimize memory usage that is temporarily needed for the + translated points, before they get painted. + This might slow down the performance of painting + */ + MinimizeMemory = 0x04, - void setSamples( const double* xData, const double* yData, int size ); - void setSamples( const float* xData, const float* yData, int size ); + /*! + Render the points to a temporary image and paint the image. + This is a very special optimization for Dots style, when + having a huge amount of points. + With a reasonable number of points QPainter::drawPoints() + will be faster. + */ + ImageBuffer = 0x08, - void setSamples( const double* yData, int size ); - void setSamples( const float* yData, int size ); + /*! + More aggressive point filtering trying to filter out + intermediate points, accepting minor visual differences. - void setSamples( const QVector< double >& yData ); - void setSamples( const QVector< float >& yData ); + Has only an effect, when drawing the curve to a paint device + in integer coordinates ( f.e. all widgets on screen ) using the fact, + that consecutive points are often mapped to the same x or y coordinate. + Each chunk of samples mapped to the same coordinate can be reduced to + 4 points ( first, min, max last ). - void setSamples( const QVector< double >& xData, const QVector< double >& yData ); - void setSamples( const QVector< float >& xData, const QVector< float >& yData ); + In the worst case the polygon to be rendered will be 4 times the width + of the plot canvas. - void setSamples( const QVector< QPointF >& ); - void setSamples( QwtSeriesData< QPointF >* ); + The algorithm is very fast and effective for huge datasets, and can be + used inside a replot cycle. - virtual int closestPoint( const QPointF& pos, double* dist = NULL ) const; + \note Implemented for QwtPlotCurve::Lines only + \note As this algo replaces many small lines by a long one + a nasty bug of the raster paint engine ( Qt 4.8, Qt 5.1 - 5.3 ) + becomes more dominant. For these versions the bug can be + worked around by enabling the QwtPainter::polylineSplitting() mode. + */ + FilterPointsAggressive = 0x10, + }; - double minXValue() const; - double maxXValue() const; - double minYValue() const; - double maxYValue() const; + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - void setCurveAttribute( CurveAttribute, bool on = true ); - bool testCurveAttribute( CurveAttribute ) const; + explicit QwtPlotCurve(const QString &title = QString()); + explicit QwtPlotCurve(const QwtText &title); - void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setPen( const QPen& ); - const QPen& pen() const; + virtual ~QwtPlotCurve(); - void setBrush( const QBrush& ); - const QBrush& brush() const; + virtual int rtti() const QWT_OVERRIDE; - void setBaseline( double ); - double baseline() const; + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - void setStyle( CurveStyle style ); - CurveStyle style() const; + void setLegendAttribute(LegendAttribute, bool on = true); + bool testLegendAttribute(LegendAttribute) const; - void setSymbol( QwtSymbol* ); - const QwtSymbol* symbol() const; + void setLegendAttributes(LegendAttributes); + LegendAttributes legendAttributes() const; - void setCurveFitter( QwtCurveFitter* ); - QwtCurveFitter* curveFitter() const; + void setRawSamples(const double *xData, const double *yData, int size); + void setRawSamples(const float *xData, const float *yData, int size); - virtual void drawSeries(QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + void setRawSamples(const double *yData, int size); + void setRawSamples(const float *yData, int size); - virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE; + void setSamples(const double *xData, const double *yData, int size); + void setSamples(const float *xData, const float *yData, int size); - protected: + void setSamples(const double *yData, int size); + void setSamples(const float *yData, int size); - void init(); + void setSamples(const QVector &yData); + void setSamples(const QVector &yData); - virtual void drawCurve( QPainter*, int style, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + void setSamples(const QVector &xData, const QVector &yData); + void setSamples(const QVector &xData, const QVector &yData); - virtual void drawSymbols( QPainter*, const QwtSymbol&, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + void setSamples(const QVector &); + void setSamples(QwtSeriesData *); - virtual void drawLines( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + virtual int closestPoint(const QPointF &pos, double *dist = NULL) const; - virtual void drawSticks( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + double minXValue() const; + double maxXValue() const; + double minYValue() const; + double maxYValue() const; - virtual void drawDots( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + void setCurveAttribute(CurveAttribute, bool on = true); + bool testCurveAttribute(CurveAttribute) const; - virtual void drawSteps( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); + void setPen(const QPen &); + const QPen &pen() const; - virtual void fillCurve( QPainter*, - const QwtScaleMap&, const QwtScaleMap&, - const QRectF& canvasRect, QPolygonF& ) const; + void setBrush(const QBrush &); + const QBrush &brush() const; - void closePolyline( QPainter*, - const QwtScaleMap&, const QwtScaleMap&, QPolygonF& ) const; + void setBaseline(double); + double baseline() const; - private: - class PrivateData; - PrivateData* m_data; + void setStyle(CurveStyle style); + CurveStyle style() const; + + void setSymbol(QwtSymbol *); + const QwtSymbol *symbol() const; + + void setCurveFitter(QwtCurveFitter *); + QwtCurveFitter *curveFitter() const; + + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; + + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; + +protected: + void init(); + + virtual void drawCurve(QPainter *, int style, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; + + virtual void drawSymbols(QPainter *, const QwtSymbol &, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, int to) const; + + virtual void drawLines(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; + + virtual void drawSticks(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; + + virtual void drawDots(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; + + virtual void drawSteps(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; + + virtual void fillCurve(QPainter *, const QwtScaleMap &, const QwtScaleMap &, + const QRectF &canvasRect, QPolygonF &) const; + + void closePolyline(QPainter *, const QwtScaleMap &, const QwtScaleMap &, + QPolygonF &) const; + +private: + class PrivateData; + PrivateData *m_data; }; //! boundingRect().left() inline double QwtPlotCurve::minXValue() const { - return boundingRect().left(); + return boundingRect().left(); } //! boundingRect().right() inline double QwtPlotCurve::maxXValue() const { - return boundingRect().right(); + return boundingRect().right(); } //! boundingRect().top() inline double QwtPlotCurve::minYValue() const { - return boundingRect().top(); + return boundingRect().top(); } //! boundingRect().bottom() inline double QwtPlotCurve::maxYValue() const { - return boundingRect().bottom(); + return boundingRect().bottom(); } -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::PaintAttributes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::LegendAttributes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotCurve::CurveAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_dict.cpp b/libs/qwt/src/qwt_plot_dict.cpp index a4de2b7a..45d54dd8 100644 --- a/libs/qwt/src/qwt_plot_dict.cpp +++ b/libs/qwt/src/qwt_plot_dict.cpp @@ -12,52 +12,52 @@ class QwtPlotDict::PrivateData { +public: + class ItemList : public QList + { public: - - class ItemList : public QList< QwtPlotItem* > + void insertItem(QwtPlotItem *item) { - public: - void insertItem( QwtPlotItem* item ) - { - if ( item == NULL ) - return; + if (item == NULL) + return; - QList< QwtPlotItem* >::iterator it = - std::upper_bound( begin(), end(), item, LessZThan() ); - insert( it, item ); + QList::iterator it + = std::upper_bound(begin(), end(), item, LessZThan()); + insert(it, item); + } + + void removeItem(QwtPlotItem *item) + { + if (item == NULL) + return; + + QList::iterator it + = std::lower_bound(begin(), end(), item, LessZThan()); + + for (; it != end(); ++it) + { + if (item == *it) + { + erase(it); + break; } + } + } - void removeItem( QwtPlotItem* item ) - { - if ( item == NULL ) - return; - - QList< QwtPlotItem* >::iterator it = - std::lower_bound( begin(), end(), item, LessZThan() ); - - for ( ; it != end(); ++it ) - { - if ( item == *it ) - { - erase( it ); - break; - } - } - } - private: - class LessZThan - { - public: - inline bool operator()( const QwtPlotItem* item1, - const QwtPlotItem* item2 ) const - { - return item1->z() < item2->z(); - } - }; + private: + class LessZThan + { + public: + inline bool operator()(const QwtPlotItem *item1, + const QwtPlotItem *item2) const + { + return item1->z() < item2->z(); + } }; + }; - ItemList itemList; - bool autoDelete; + ItemList itemList; + bool autoDelete; }; /*! @@ -68,8 +68,8 @@ class QwtPlotDict::PrivateData */ QwtPlotDict::QwtPlotDict() { - m_data = new QwtPlotDict::PrivateData; - m_data->autoDelete = true; + m_data = new QwtPlotDict::PrivateData; + m_data->autoDelete = true; } /*! @@ -80,8 +80,8 @@ QwtPlotDict::QwtPlotDict() */ QwtPlotDict::~QwtPlotDict() { - detachItems( QwtPlotItem::Rtti_PlotItem, m_data->autoDelete ); - delete m_data; + detachItems(QwtPlotItem::Rtti_PlotItem, m_data->autoDelete); + delete m_data; } /*! @@ -92,9 +92,9 @@ QwtPlotDict::~QwtPlotDict() \sa autoDelete(), insertItem() */ -void QwtPlotDict::setAutoDelete( bool autoDelete ) +void QwtPlotDict::setAutoDelete(bool autoDelete) { - m_data->autoDelete = autoDelete; + m_data->autoDelete = autoDelete; } /*! @@ -103,7 +103,7 @@ void QwtPlotDict::setAutoDelete( bool autoDelete ) */ bool QwtPlotDict::autoDelete() const { - return m_data->autoDelete; + return m_data->autoDelete; } /*! @@ -112,9 +112,9 @@ bool QwtPlotDict::autoDelete() const \param item PlotItem \sa removeItem() */ -void QwtPlotDict::insertItem( QwtPlotItem* item ) +void QwtPlotDict::insertItem(QwtPlotItem *item) { - m_data->itemList.insertItem( item ); + m_data->itemList.insertItem(item); } /*! @@ -123,9 +123,9 @@ void QwtPlotDict::insertItem( QwtPlotItem* item ) \param item PlotItem \sa insertItem() */ -void QwtPlotDict::removeItem( QwtPlotItem* item ) +void QwtPlotDict::removeItem(QwtPlotItem *item) { - m_data->itemList.removeItem( item ); + m_data->itemList.removeItem(item); } /*! @@ -135,23 +135,23 @@ void QwtPlotDict::removeItem( QwtPlotItem* item ) otherwise only those items of the type rtti. \param autoDelete If true, delete all detached items */ -void QwtPlotDict::detachItems( int rtti, bool autoDelete ) +void QwtPlotDict::detachItems(int rtti, bool autoDelete) { - PrivateData::ItemList list = m_data->itemList; - QwtPlotItemIterator it = list.constBegin(); - while ( it != list.constEnd() ) + PrivateData::ItemList list = m_data->itemList; + QwtPlotItemIterator it = list.constBegin(); + while (it != list.constEnd()) + { + QwtPlotItem *item = *it; + + ++it; // increment before removing item from the list + + if (rtti == QwtPlotItem::Rtti_PlotItem || item->rtti() == rtti) { - QwtPlotItem* item = *it; - - ++it; // increment before removing item from the list - - if ( rtti == QwtPlotItem::Rtti_PlotItem || item->rtti() == rtti ) - { - item->attach( NULL ); - if ( autoDelete ) - delete item; - } + item->attach(NULL); + if (autoDelete) + delete item; } + } } /*! @@ -163,9 +163,9 @@ void QwtPlotDict::detachItems( int rtti, bool autoDelete ) \return List of all attached plot items. */ -const QwtPlotItemList& QwtPlotDict::itemList() const +const QwtPlotItemList &QwtPlotDict::itemList() const { - return m_data->itemList; + return m_data->itemList; } /*! @@ -173,20 +173,20 @@ const QwtPlotItemList& QwtPlotDict::itemList() const \param rtti See QwtPlotItem::RttiValues \sa QwtPlotItem::rtti() */ -QwtPlotItemList QwtPlotDict::itemList( int rtti ) const +QwtPlotItemList QwtPlotDict::itemList(int rtti) const { - if ( rtti == QwtPlotItem::Rtti_PlotItem ) - return m_data->itemList; + if (rtti == QwtPlotItem::Rtti_PlotItem) + return m_data->itemList; - QwtPlotItemList items; + QwtPlotItemList items; - PrivateData::ItemList list = m_data->itemList; - for ( QwtPlotItemIterator it = list.constBegin(); it != list.constEnd(); ++it ) - { - QwtPlotItem* item = *it; - if ( item->rtti() == rtti ) - items += item; - } + PrivateData::ItemList list = m_data->itemList; + for (QwtPlotItemIterator it = list.constBegin(); it != list.constEnd(); ++it) + { + QwtPlotItem *item = *it; + if (item->rtti() == rtti) + items += item; + } - return items; + return items; } diff --git a/libs/qwt/src/qwt_plot_dict.h b/libs/qwt/src/qwt_plot_dict.h index 689903cc..0f5fe4c9 100644 --- a/libs/qwt/src/qwt_plot_dict.h +++ b/libs/qwt/src/qwt_plot_dict.h @@ -15,8 +15,8 @@ #include -typedef QList< QwtPlotItem* > QwtPlotItemList; -typedef QList< QwtPlotItem* >::ConstIterator QwtPlotItemIterator; +typedef QList QwtPlotItemList; +typedef QList::ConstIterator QwtPlotItemIterator; /*! \brief A dictionary for plot items @@ -31,26 +31,26 @@ typedef QList< QwtPlotItem* >::ConstIterator QwtPlotItemIterator; */ class QWT_EXPORT QwtPlotDict { - public: - explicit QwtPlotDict(); - virtual ~QwtPlotDict(); +public: + explicit QwtPlotDict(); + virtual ~QwtPlotDict(); - void setAutoDelete( bool ); - bool autoDelete() const; + void setAutoDelete(bool); + bool autoDelete() const; - const QwtPlotItemList& itemList() const; - QwtPlotItemList itemList( int rtti ) const; + const QwtPlotItemList &itemList() const; + QwtPlotItemList itemList(int rtti) const; - void detachItems( int rtti = QwtPlotItem::Rtti_PlotItem, - bool autoDelete = true ); + void detachItems(int rtti = QwtPlotItem::Rtti_PlotItem, + bool autoDelete = true); - protected: - void insertItem( QwtPlotItem* ); - void removeItem( QwtPlotItem* ); +protected: + void insertItem(QwtPlotItem *); + void removeItem(QwtPlotItem *); - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_directpainter.cpp b/libs/qwt/src/qwt_plot_directpainter.cpp index 6b2c87f4..709f4d99 100644 --- a/libs/qwt/src/qwt_plot_directpainter.cpp +++ b/libs/qwt/src/qwt_plot_directpainter.cpp @@ -17,62 +17,63 @@ #include #include -static inline void qwtRenderItem( - QPainter* painter, const QRect& canvasRect, - QwtPlotSeriesItem* seriesItem, int from, int to ) +static inline void qwtRenderItem(QPainter *painter, const QRect &canvasRect, + QwtPlotSeriesItem *seriesItem, int from, + int to) { - // A minor performance improvement is possible - // with caching the maps. TODO ... + // A minor performance improvement is possible + // with caching the maps. TODO ... - QwtPlot* plot = seriesItem->plot(); - const QwtScaleMap xMap = plot->canvasMap( seriesItem->xAxis() ); - const QwtScaleMap yMap = plot->canvasMap( seriesItem->yAxis() ); + QwtPlot *plot = seriesItem->plot(); + const QwtScaleMap xMap = plot->canvasMap(seriesItem->xAxis()); + const QwtScaleMap yMap = plot->canvasMap(seriesItem->yAxis()); - painter->setRenderHint( QPainter::Antialiasing, - seriesItem->testRenderHint( QwtPlotItem::RenderAntialiased ) ); - seriesItem->drawSeries( painter, xMap, yMap, canvasRect, from, to ); + painter->setRenderHint( + QPainter::Antialiasing, + seriesItem->testRenderHint(QwtPlotItem::RenderAntialiased)); + seriesItem->drawSeries(painter, xMap, yMap, canvasRect, from, to); } -static inline bool qwtHasBackingStore( const QwtPlotCanvas* canvas ) +static inline bool qwtHasBackingStore(const QwtPlotCanvas *canvas) { - return canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) - && canvas->backingStore() && !canvas->backingStore()->isNull(); + return canvas->testPaintAttribute(QwtPlotCanvas::BackingStore) + && canvas->backingStore() && !canvas->backingStore()->isNull(); } class QwtPlotDirectPainter::PrivateData { - public: - PrivateData() - : hasClipping( false ) - , seriesItem( NULL ) - , from( 0 ) - , to( 0 ) - { - } +public: + PrivateData() + : hasClipping(false) + , seriesItem(NULL) + , from(0) + , to(0) + { + } - QwtPlotDirectPainter::Attributes attributes; + QwtPlotDirectPainter::Attributes attributes; - bool hasClipping; - QRegion clipRegion; + bool hasClipping; + QRegion clipRegion; - QPainter painter; + QPainter painter; - QwtPlotSeriesItem* seriesItem; - int from; - int to; + QwtPlotSeriesItem *seriesItem; + int from; + int to; }; //! Constructor -QwtPlotDirectPainter::QwtPlotDirectPainter( QObject* parent ) - : QObject( parent ) +QwtPlotDirectPainter::QwtPlotDirectPainter(QObject *parent) + : QObject(parent) { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtPlotDirectPainter::~QwtPlotDirectPainter() { - delete m_data; + delete m_data; } /*! @@ -83,18 +84,18 @@ QwtPlotDirectPainter::~QwtPlotDirectPainter() \sa Attribute, testAttribute() */ -void QwtPlotDirectPainter::setAttribute( Attribute attribute, bool on ) +void QwtPlotDirectPainter::setAttribute(Attribute attribute, bool on) { - if ( bool( m_data->attributes & attribute ) != on ) - { - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; + if (bool(m_data->attributes & attribute) != on) + { + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; - if ( ( attribute == AtomicPainter ) && on ) - reset(); - } + if ((attribute == AtomicPainter) && on) + reset(); + } } /*! @@ -102,9 +103,9 @@ void QwtPlotDirectPainter::setAttribute( Attribute attribute, bool on ) \param attribute Attribute to be tested \sa Attribute, setAttribute() */ -bool QwtPlotDirectPainter::testAttribute( Attribute attribute ) const +bool QwtPlotDirectPainter::testAttribute(Attribute attribute) const { - return m_data->attributes & attribute; + return m_data->attributes & attribute; } /*! @@ -113,9 +114,9 @@ bool QwtPlotDirectPainter::testAttribute( Attribute attribute ) const \param enable Enables clipping is true, disable it otherwise \sa hasClipping(), clipRegion(), setClipRegion() */ -void QwtPlotDirectPainter::setClipping( bool enable ) +void QwtPlotDirectPainter::setClipping(bool enable) { - m_data->hasClipping = enable; + m_data->hasClipping = enable; } /*! @@ -124,7 +125,7 @@ void QwtPlotDirectPainter::setClipping( bool enable ) */ bool QwtPlotDirectPainter::hasClipping() const { - return m_data->hasClipping; + return m_data->hasClipping; } /*! @@ -138,10 +139,10 @@ bool QwtPlotDirectPainter::hasClipping() const \param region Clip region \sa clipRegion(), hasClipping(), setClipping() */ -void QwtPlotDirectPainter::setClipRegion( const QRegion& region ) +void QwtPlotDirectPainter::setClipRegion(const QRegion ®ion) { - m_data->clipRegion = region; - m_data->hasClipping = true; + m_data->clipRegion = region; + m_data->hasClipping = true; } /*! @@ -150,15 +151,15 @@ void QwtPlotDirectPainter::setClipRegion( const QRegion& region ) */ QRegion QwtPlotDirectPainter::clipRegion() const { - return m_data->clipRegion; + return m_data->clipRegion; } /*! \brief Draw a set of points of a seriesItem. When observing an measurement while it is running, new points have to be - added to an existing seriesItem. drawSeries() can be used to display them avoiding - a complete redraw of the canvas. + added to an existing seriesItem. drawSeries() can be used to display them + avoiding a complete redraw of the canvas. Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); will result in faster painting, if the paint engine of the canvas widget @@ -169,152 +170,150 @@ QRegion QwtPlotDirectPainter::clipRegion() const \param to Index of the last point to be painted. If to < 0 the series will be painted to its last point. */ -void QwtPlotDirectPainter::drawSeries( - QwtPlotSeriesItem* seriesItem, int from, int to ) +void QwtPlotDirectPainter::drawSeries(QwtPlotSeriesItem *seriesItem, int from, + int to) { - if ( seriesItem == NULL || seriesItem->plot() == NULL ) - return; + if (seriesItem == NULL || seriesItem->plot() == NULL) + return; - QWidget* canvas = seriesItem->plot()->canvas(); - const QRect canvasRect = canvas->contentsRect(); + QWidget *canvas = seriesItem->plot()->canvas(); + const QRect canvasRect = canvas->contentsRect(); - QwtPlotCanvas* plotCanvas = qobject_cast< QwtPlotCanvas* >( canvas ); + QwtPlotCanvas *plotCanvas = qobject_cast(canvas); - if ( plotCanvas && qwtHasBackingStore( plotCanvas ) ) + if (plotCanvas && qwtHasBackingStore(plotCanvas)) + { + QPainter painter(const_cast(plotCanvas->backingStore())); + + if (m_data->hasClipping) + painter.setClipRegion(m_data->clipRegion); + + qwtRenderItem(&painter, canvasRect, seriesItem, from, to); + + painter.end(); + + if (testAttribute(QwtPlotDirectPainter::FullRepaint)) { - QPainter painter( const_cast< QPixmap* >( plotCanvas->backingStore() ) ); - - if ( m_data->hasClipping ) - painter.setClipRegion( m_data->clipRegion ); - - qwtRenderItem( &painter, canvasRect, seriesItem, from, to ); - - painter.end(); - - if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) ) - { - plotCanvas->repaint(); - return; - } + plotCanvas->repaint(); + return; } + } - bool immediatePaint = true; - if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) ) - { + bool immediatePaint = true; + if (!canvas->testAttribute(Qt::WA_WState_InPaintEvent)) + { #if QT_VERSION < 0x050000 - if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) ) + if (!canvas->testAttribute(Qt::WA_PaintOutsidePaintEvent)) #endif - immediatePaint = false; + immediatePaint = false; + } + + if (immediatePaint) + { + if (!m_data->painter.isActive()) + { + reset(); + + m_data->painter.begin(canvas); + canvas->installEventFilter(this); } - if ( immediatePaint ) + if (m_data->hasClipping) { - if ( !m_data->painter.isActive() ) - { - reset(); - - m_data->painter.begin( canvas ); - canvas->installEventFilter( this ); - } - - if ( m_data->hasClipping ) - { - m_data->painter.setClipRegion( - QRegion( canvasRect ) & m_data->clipRegion ); - } - else - { - if ( !m_data->painter.hasClipping() ) - m_data->painter.setClipRect( canvasRect ); - } - - qwtRenderItem( &m_data->painter, canvasRect, seriesItem, from, to ); - - if ( m_data->attributes & QwtPlotDirectPainter::AtomicPainter ) - { - reset(); - } - else - { - if ( m_data->hasClipping ) - m_data->painter.setClipping( false ); - } + m_data->painter.setClipRegion(QRegion(canvasRect) & m_data->clipRegion); } else { - reset(); - - m_data->seriesItem = seriesItem; - m_data->from = from; - m_data->to = to; - - QRegion clipRegion = canvasRect; - if ( m_data->hasClipping ) - clipRegion &= m_data->clipRegion; - - canvas->installEventFilter( this ); - canvas->repaint(clipRegion); - canvas->removeEventFilter( this ); - - m_data->seriesItem = NULL; + if (!m_data->painter.hasClipping()) + m_data->painter.setClipRect(canvasRect); } + + qwtRenderItem(&m_data->painter, canvasRect, seriesItem, from, to); + + if (m_data->attributes & QwtPlotDirectPainter::AtomicPainter) + { + reset(); + } + else + { + if (m_data->hasClipping) + m_data->painter.setClipping(false); + } + } + else + { + reset(); + + m_data->seriesItem = seriesItem; + m_data->from = from; + m_data->to = to; + + QRegion clipRegion = canvasRect; + if (m_data->hasClipping) + clipRegion &= m_data->clipRegion; + + canvas->installEventFilter(this); + canvas->repaint(clipRegion); + canvas->removeEventFilter(this); + + m_data->seriesItem = NULL; + } } //! Close the internal QPainter void QwtPlotDirectPainter::reset() { - if ( m_data->painter.isActive() ) - { - QWidget* w = static_cast< QWidget* >( m_data->painter.device() ); - if ( w ) - w->removeEventFilter( this ); + if (m_data->painter.isActive()) + { + QWidget *w = static_cast(m_data->painter.device()); + if (w) + w->removeEventFilter(this); - m_data->painter.end(); - } + m_data->painter.end(); + } } //! Event filter -bool QwtPlotDirectPainter::eventFilter( QObject*, QEvent* event ) +bool QwtPlotDirectPainter::eventFilter(QObject *, QEvent *event) { - if ( event->type() == QEvent::Paint ) + if (event->type() == QEvent::Paint) + { + reset(); + + if (m_data->seriesItem) { - reset(); + const QPaintEvent *pe = static_cast(event); - if ( m_data->seriesItem ) + QWidget *canvas = m_data->seriesItem->plot()->canvas(); + + QPainter painter(canvas); + painter.setClipRegion(pe->region()); + + bool doCopyCache = testAttribute(CopyBackingStore); + + if (doCopyCache) + { + QwtPlotCanvas *plotCanvas = qobject_cast(canvas); + if (plotCanvas) { - const QPaintEvent* pe = static_cast< QPaintEvent* >( event ); - - QWidget* canvas = m_data->seriesItem->plot()->canvas(); - - QPainter painter( canvas ); - painter.setClipRegion( pe->region() ); - - bool doCopyCache = testAttribute( CopyBackingStore ); - - if ( doCopyCache ) - { - QwtPlotCanvas* plotCanvas = - qobject_cast< QwtPlotCanvas* >( canvas ); - if ( plotCanvas ) - { - doCopyCache = qwtHasBackingStore( plotCanvas ); - if ( doCopyCache ) - { - painter.drawPixmap( plotCanvas->rect().topLeft(), - *plotCanvas->backingStore() ); - } - } - } - - if ( !doCopyCache ) - { - qwtRenderItem( &painter, canvas->contentsRect(), - m_data->seriesItem, m_data->from, m_data->to ); - } - - return true; // don't call QwtPlotCanvas::paintEvent() + doCopyCache = qwtHasBackingStore(plotCanvas); + if (doCopyCache) + { + painter.drawPixmap(plotCanvas->rect().topLeft(), + *plotCanvas->backingStore()); + } } - } + } - return false; + if (!doCopyCache) + { + qwtRenderItem(&painter, canvas->contentsRect(), m_data->seriesItem, + m_data->from, m_data->to); + } + + return true; // don't call QwtPlotCanvas::paintEvent() + } + } + + return false; } diff --git a/libs/qwt/src/qwt_plot_directpainter.h b/libs/qwt/src/qwt_plot_directpainter.h index 3746749b..de144653 100644 --- a/libs/qwt/src/qwt_plot_directpainter.h +++ b/libs/qwt/src/qwt_plot_directpainter.h @@ -38,62 +38,62 @@ class QwtPlotSeriesItem; */ class QWT_EXPORT QwtPlotDirectPainter : public QObject { - public: +public: + /*! + \brief Paint attributes + \sa setAttribute(), testAttribute(), drawSeries() + */ + enum Attribute + { /*! - \brief Paint attributes - \sa setAttribute(), testAttribute(), drawSeries() + Initializing a QPainter is an expensive operation. + When AtomicPainter is set each call of drawSeries() opens/closes + a temporary QPainter. Otherwise QwtPlotDirectPainter tries to + use the same QPainter as long as possible. */ - enum Attribute - { - /*! - Initializing a QPainter is an expensive operation. - When AtomicPainter is set each call of drawSeries() opens/closes - a temporary QPainter. Otherwise QwtPlotDirectPainter tries to - use the same QPainter as long as possible. - */ - AtomicPainter = 0x01, + AtomicPainter = 0x01, - /*! - When FullRepaint is set the plot canvas is explicitly repainted - after the samples have been rendered. - */ - FullRepaint = 0x02, + /*! + When FullRepaint is set the plot canvas is explicitly repainted + after the samples have been rendered. + */ + FullRepaint = 0x02, - /*! - When QwtPlotCanvas::BackingStore is enabled the painter - has to paint to the backing store and the widget. In certain - situations/environments it might be faster to paint to - the backing store only and then copy the backing store to the canvas. - This flag can also be useful for settings, where Qt fills the - the clip region with the widget background. - */ - CopyBackingStore = 0x04 - }; + /*! + When QwtPlotCanvas::BackingStore is enabled the painter + has to paint to the backing store and the widget. In certain + situations/environments it might be faster to paint to + the backing store only and then copy the backing store to the canvas. + This flag can also be useful for settings, where Qt fills the + the clip region with the widget background. + */ + CopyBackingStore = 0x04 + }; - Q_DECLARE_FLAGS( Attributes, Attribute ) + Q_DECLARE_FLAGS(Attributes, Attribute) - explicit QwtPlotDirectPainter( QObject* parent = NULL ); - virtual ~QwtPlotDirectPainter(); + explicit QwtPlotDirectPainter(QObject *parent = NULL); + virtual ~QwtPlotDirectPainter(); - void setAttribute( Attribute, bool on ); - bool testAttribute( Attribute ) const; + void setAttribute(Attribute, bool on); + bool testAttribute(Attribute) const; - void setClipping( bool ); - bool hasClipping() const; + void setClipping(bool); + bool hasClipping() const; - void setClipRegion( const QRegion& ); - QRegion clipRegion() const; + void setClipRegion(const QRegion &); + QRegion clipRegion() const; - void drawSeries( QwtPlotSeriesItem*, int from, int to ); - void reset(); + void drawSeries(QwtPlotSeriesItem *, int from, int to); + void reset(); - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotDirectPainter::Attributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotDirectPainter::Attributes) #endif diff --git a/libs/qwt/src/qwt_plot_glcanvas.cpp b/libs/qwt/src/qwt_plot_glcanvas.cpp index 451e634f..227e6c16 100644 --- a/libs/qwt/src/qwt_plot_glcanvas.cpp +++ b/libs/qwt/src/qwt_plot_glcanvas.cpp @@ -18,33 +18,30 @@ namespace { - class QwtPlotGLCanvasFormat : public QGLFormat - { - public: - QwtPlotGLCanvasFormat() - : QGLFormat( QGLFormat::defaultFormat() ) - { - setSampleBuffers( true ); - } - }; -} +class QwtPlotGLCanvasFormat : public QGLFormat +{ +public: + QwtPlotGLCanvasFormat() + : QGLFormat(QGLFormat::defaultFormat()) + { + setSampleBuffers(true); + } +}; +} // namespace class QwtPlotGLCanvas::PrivateData { - public: - PrivateData() - : fboDirty( true ) - , fbo( NULL ) - { - } +public: + PrivateData() + : fboDirty(true) + , fbo(NULL) + { + } - ~PrivateData() - { - delete fbo; - } + ~PrivateData() { delete fbo; } - bool fboDirty; - QGLFramebufferObject* fbo; + bool fboDirty; + QGLFramebufferObject *fbo; }; /*! @@ -53,11 +50,11 @@ class QwtPlotGLCanvas::PrivateData \param plot Parent plot widget \sa QwtPlot::setCanvas() */ -QwtPlotGLCanvas::QwtPlotGLCanvas( QwtPlot* plot ) - : QGLWidget( QwtPlotGLCanvasFormat(), plot ) - , QwtPlotAbstractGLCanvas( this ) +QwtPlotGLCanvas::QwtPlotGLCanvas(QwtPlot *plot) + : QGLWidget(QwtPlotGLCanvasFormat(), plot) + , QwtPlotAbstractGLCanvas(this) { - init(); + init(); } /*! \brief Constructor @@ -66,29 +63,29 @@ QwtPlotGLCanvas::QwtPlotGLCanvas( QwtPlot* plot ) \param plot Parent plot widget \sa QwtPlot::setCanvas() */ -QwtPlotGLCanvas::QwtPlotGLCanvas( const QGLFormat& format, QwtPlot* plot ) - : QGLWidget( format, plot ) - , QwtPlotAbstractGLCanvas( this ) +QwtPlotGLCanvas::QwtPlotGLCanvas(const QGLFormat &format, QwtPlot *plot) + : QGLWidget(format, plot) + , QwtPlotAbstractGLCanvas(this) { - init(); + init(); } //! Destructor QwtPlotGLCanvas::~QwtPlotGLCanvas() { - delete m_data; + delete m_data; } void QwtPlotGLCanvas::init() { - m_data = new PrivateData; + m_data = new PrivateData; #if 1 - setAttribute( Qt::WA_OpaquePaintEvent, true ); + setAttribute(Qt::WA_OpaquePaintEvent, true); #endif - setLineWidth( 2 ); - setFrameShadow( QFrame::Sunken ); - setFrameShape( QFrame::Panel ); + setLineWidth(2); + setFrameShadow(QFrame::Sunken); + setFrameShape(QFrame::Panel); } /*! @@ -97,9 +94,9 @@ void QwtPlotGLCanvas::init() \param event Paint event \sa QwtPlot::drawCanvas() */ -void QwtPlotGLCanvas::paintEvent( QPaintEvent* event ) +void QwtPlotGLCanvas::paintEvent(QPaintEvent *event) { - QGLWidget::paintEvent( event ); + QGLWidget::paintEvent(event); } /*! @@ -107,21 +104,20 @@ void QwtPlotGLCanvas::paintEvent( QPaintEvent* event ) \param event Qt Event \return See QGLWidget::event() */ -bool QwtPlotGLCanvas::event( QEvent* event ) +bool QwtPlotGLCanvas::event(QEvent *event) { - const bool ok = QGLWidget::event( event ); + const bool ok = QGLWidget::event(event); - if ( event->type() == QEvent::PolishRequest || - event->type() == QEvent::StyleChange ) - { - // assuming, that we always have a styled background - // when we have a style sheet + if (event->type() == QEvent::PolishRequest + || event->type() == QEvent::StyleChange) + { + // assuming, that we always have a styled background + // when we have a style sheet - setAttribute( Qt::WA_StyledBackground, - testAttribute( Qt::WA_StyleSheet ) ); - } + setAttribute(Qt::WA_StyledBackground, testAttribute(Qt::WA_StyleSheet)); + } - return ok; + return ok; } /*! @@ -130,19 +126,19 @@ bool QwtPlotGLCanvas::event( QEvent* event ) */ void QwtPlotGLCanvas::replot() { - QwtPlotAbstractGLCanvas::replot(); + QwtPlotAbstractGLCanvas::replot(); } //! Invalidate the internal backing store void QwtPlotGLCanvas::invalidateBackingStore() { - m_data->fboDirty = true; + m_data->fboDirty = true; } void QwtPlotGLCanvas::clearBackingStore() { - delete m_data->fbo; - m_data->fbo = NULL; + delete m_data->fbo; + m_data->fbo = NULL; } /*! @@ -154,87 +150,85 @@ void QwtPlotGLCanvas::clearBackingStore() \param rect Bounding rectangle of the canvas \return Painter path, that can be used for clipping */ -QPainterPath QwtPlotGLCanvas::borderPath( const QRect& rect ) const +QPainterPath QwtPlotGLCanvas::borderPath(const QRect &rect) const { - return canvasBorderPath( rect ); + return canvasBorderPath(rect); } //! No operation - reserved for some potential use in the future -void QwtPlotGLCanvas::initializeGL() -{ -} +void QwtPlotGLCanvas::initializeGL() {} //! Paint the plot void QwtPlotGLCanvas::paintGL() { - const bool hasFocusIndicator = - hasFocus() && focusIndicator() == CanvasFocusIndicator; + const bool hasFocusIndicator + = hasFocus() && focusIndicator() == CanvasFocusIndicator; - QPainter painter; + QPainter painter; - if ( testPaintAttribute( QwtPlotGLCanvas::BackingStore ) ) + if (testPaintAttribute(QwtPlotGLCanvas::BackingStore)) + { + const qreal pixelRatio = QwtPainter::devicePixelRatio(NULL); + const QRect rect(0, 0, width() * pixelRatio, height() * pixelRatio); + + if (hasFocusIndicator) + painter.begin(this); + + if (m_data->fbo) { - const qreal pixelRatio = QwtPainter::devicePixelRatio( NULL ); - const QRect rect( 0, 0, width() * pixelRatio, height() * pixelRatio ); - - if ( hasFocusIndicator ) - painter.begin( this ); - - if ( m_data->fbo ) - { - if ( m_data->fbo->size() != rect.size() ) - { - delete m_data->fbo; - m_data->fbo = NULL; - } - } - - if ( m_data->fbo == NULL ) - { - QGLFramebufferObjectFormat format; - format.setSamples( 4 ); - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - - m_data->fbo = new QGLFramebufferObject( rect.size(), format ); - m_data->fboDirty = true; - } - - if ( m_data->fboDirty ) - { - QPainter fboPainter( m_data->fbo ); - fboPainter.scale( pixelRatio, pixelRatio ); - draw( &fboPainter ); - fboPainter.end(); - - m_data->fboDirty = false; - } - - /* - Why do we have this strange translation - but, anyway - QwtPlotGLCanvas in combination with scaling factor - is not very likely to happen as using QwtPlotOpenGLCanvas - usually makes more sense then. - */ - - QGLFramebufferObject::blitFramebuffer( NULL, - rect.translated( 0, height() - rect.height() ), m_data->fbo, rect ); - } - else - { - painter.begin( this ); - draw( &painter ); + if (m_data->fbo->size() != rect.size()) + { + delete m_data->fbo; + m_data->fbo = NULL; + } } - if ( hasFocusIndicator ) - drawFocusIndicator( &painter ); + if (m_data->fbo == NULL) + { + QGLFramebufferObjectFormat format; + format.setSamples(4); + format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + + m_data->fbo = new QGLFramebufferObject(rect.size(), format); + m_data->fboDirty = true; + } + + if (m_data->fboDirty) + { + QPainter fboPainter(m_data->fbo); + fboPainter.scale(pixelRatio, pixelRatio); + draw(&fboPainter); + fboPainter.end(); + + m_data->fboDirty = false; + } + + /* + Why do we have this strange translation - but, anyway + QwtPlotGLCanvas in combination with scaling factor + is not very likely to happen as using QwtPlotOpenGLCanvas + usually makes more sense then. + */ + + QGLFramebufferObject::blitFramebuffer( + NULL, rect.translated(0, height() - rect.height()), m_data->fbo, rect); + } + else + { + painter.begin(this); + draw(&painter); + } + + if (hasFocusIndicator) + drawFocusIndicator(&painter); } //! No operation - reserved for some potential use in the future -void QwtPlotGLCanvas::resizeGL( int, int ) +void QwtPlotGLCanvas::resizeGL(int, int) { - // nothing to do + // nothing to do } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_glcanvas.cpp" +# include "moc_qwt_plot_glcanvas.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_glcanvas.h b/libs/qwt/src/qwt_plot_glcanvas.h index 8796a508..95ff146d 100644 --- a/libs/qwt/src/qwt_plot_glcanvas.h +++ b/libs/qwt/src/qwt_plot_glcanvas.h @@ -38,49 +38,50 @@ class QwtPlot; geometries. \note Another way for getting hardware accelerated graphics is using - an OpenGL offscreen buffer ( QwtPlotCanvas::OpenGLBuffer ) with QwtPlotCanvas. - Performance is worse, than rendering straight to a QGLWidget, but is usually - better integrated into a desktop application. + an OpenGL offscreen buffer ( QwtPlotCanvas::OpenGLBuffer ) with + QwtPlotCanvas. Performance is worse, than rendering straight to a QGLWidget, + but is usually better integrated into a desktop application. */ -class QWT_EXPORT QwtPlotGLCanvas : public QGLWidget, public QwtPlotAbstractGLCanvas +class QWT_EXPORT QwtPlotGLCanvas : public QGLWidget, + public QwtPlotAbstractGLCanvas { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( QFrame::Shadow frameShadow READ frameShadow WRITE setFrameShadow ) - Q_PROPERTY( QFrame::Shape frameShape READ frameShape WRITE setFrameShape ) - Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth ) - Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth ) - Q_PROPERTY( int frameWidth READ frameWidth ) - Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false ) + Q_PROPERTY(QFrame::Shadow frameShadow READ frameShadow WRITE setFrameShadow) + Q_PROPERTY(QFrame::Shape frameShape READ frameShape WRITE setFrameShape) + Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) + Q_PROPERTY(int midLineWidth READ midLineWidth WRITE setMidLineWidth) + Q_PROPERTY(int frameWidth READ frameWidth) + Q_PROPERTY(QRect frameRect READ frameRect DESIGNABLE false) - Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius ) + Q_PROPERTY(double borderRadius READ borderRadius WRITE setBorderRadius) - public: - explicit QwtPlotGLCanvas( QwtPlot* = NULL ); - explicit QwtPlotGLCanvas( const QGLFormat&, QwtPlot* = NULL ); - virtual ~QwtPlotGLCanvas(); +public: + explicit QwtPlotGLCanvas(QwtPlot * = NULL); + explicit QwtPlotGLCanvas(const QGLFormat &, QwtPlot * = NULL); + virtual ~QwtPlotGLCanvas(); - Q_INVOKABLE virtual void invalidateBackingStore() QWT_OVERRIDE; - Q_INVOKABLE QPainterPath borderPath( const QRect& ) const; + Q_INVOKABLE virtual void invalidateBackingStore() QWT_OVERRIDE; + Q_INVOKABLE QPainterPath borderPath(const QRect &) const; - virtual bool event( QEvent* ) QWT_OVERRIDE; + virtual bool event(QEvent *) QWT_OVERRIDE; - public Q_SLOTS: - void replot(); +public Q_SLOTS: + void replot(); - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; - virtual void initializeGL() QWT_OVERRIDE; - virtual void paintGL() QWT_OVERRIDE; - virtual void resizeGL( int width, int height ) QWT_OVERRIDE; + virtual void initializeGL() QWT_OVERRIDE; + virtual void paintGL() QWT_OVERRIDE; + virtual void resizeGL(int width, int height) QWT_OVERRIDE; - private: - void init(); - virtual void clearBackingStore() QWT_OVERRIDE; +private: + void init(); + virtual void clearBackingStore() QWT_OVERRIDE; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_graphicitem.cpp b/libs/qwt/src/qwt_plot_graphicitem.cpp index 1a310857..3a4e544b 100644 --- a/libs/qwt/src/qwt_plot_graphicitem.cpp +++ b/libs/qwt/src/qwt_plot_graphicitem.cpp @@ -15,9 +15,9 @@ class QwtPlotGraphicItem::PrivateData { - public: - QRectF boundingRect; - QwtGraphic graphic; +public: + QRectF boundingRect; + QwtGraphic graphic; }; /*! @@ -29,10 +29,10 @@ class QwtPlotGraphicItem::PrivateData \param title Title */ -QwtPlotGraphicItem::QwtPlotGraphicItem( const QString& title ) - : QwtPlotItem( QwtText( title ) ) +QwtPlotGraphicItem::QwtPlotGraphicItem(const QString &title) + : QwtPlotItem(QwtText(title)) { - init(); + init(); } /*! @@ -44,33 +44,33 @@ QwtPlotGraphicItem::QwtPlotGraphicItem( const QString& title ) \param title Title */ -QwtPlotGraphicItem::QwtPlotGraphicItem( const QwtText& title ) - : QwtPlotItem( title ) +QwtPlotGraphicItem::QwtPlotGraphicItem(const QwtText &title) + : QwtPlotItem(title) { - init(); + init(); } //! Destructor QwtPlotGraphicItem::~QwtPlotGraphicItem() { - delete m_data; + delete m_data; } void QwtPlotGraphicItem::init() { - m_data = new PrivateData(); - m_data->boundingRect = QwtPlotItem::boundingRect(); + m_data = new PrivateData(); + m_data->boundingRect = QwtPlotItem::boundingRect(); - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Legend, false ); + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Legend, false); - setZ( 8.0 ); + setZ(8.0); } //! \return QwtPlotItem::Rtti_PlotGraphic int QwtPlotGraphicItem::rtti() const { - return QwtPlotItem::Rtti_PlotGraphic; + return QwtPlotItem::Rtti_PlotGraphic; } /*! @@ -79,14 +79,14 @@ int QwtPlotGraphicItem::rtti() const \param rect Rectangle in plot coordinates \param graphic Recorded sequence of painter commands */ -void QwtPlotGraphicItem::setGraphic( - const QRectF& rect, const QwtGraphic& graphic ) +void QwtPlotGraphicItem::setGraphic(const QRectF &rect, + const QwtGraphic &graphic) { - m_data->boundingRect = rect; - m_data->graphic = graphic; + m_data->boundingRect = rect; + m_data->graphic = graphic; - legendChanged(); - itemChanged(); + legendChanged(); + itemChanged(); } /*! @@ -95,13 +95,13 @@ void QwtPlotGraphicItem::setGraphic( */ QwtGraphic QwtPlotGraphicItem::graphic() const { - return m_data->graphic; + return m_data->graphic; } //! Bounding rectangle of the item QRectF QwtPlotGraphicItem::boundingRect() const { - return m_data->boundingRect; + return m_data->boundingRect; } /*! @@ -112,25 +112,25 @@ QRectF QwtPlotGraphicItem::boundingRect() const \param yMap Y-Scale Map \param canvasRect Contents rect of the plot canvas */ -void QwtPlotGraphicItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotGraphicItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - if ( m_data->graphic.isEmpty() ) - return; + if (m_data->graphic.isEmpty()) + return; - QRectF r = QwtScaleMap::transform( xMap, yMap, boundingRect() ); + QRectF r = QwtScaleMap::transform(xMap, yMap, boundingRect()); - if ( !r.intersects( canvasRect ) ) - return; + if (!r.intersects(canvasRect)) + return; - if ( QwtPainter::roundingAlignment( painter ) ) - { - r.setLeft ( qRound( r.left() ) ); - r.setRight ( qRound( r.right() ) ); - r.setTop ( qRound( r.top() ) ); - r.setBottom ( qRound( r.bottom() ) ); - } + if (QwtPainter::roundingAlignment(painter)) + { + r.setLeft(qRound(r.left())); + r.setRight(qRound(r.right())); + r.setTop(qRound(r.top())); + r.setBottom(qRound(r.bottom())); + } - m_data->graphic.render( painter, r ); + m_data->graphic.render(painter, r); } diff --git a/libs/qwt/src/qwt_plot_graphicitem.h b/libs/qwt/src/qwt_plot_graphicitem.h index b8441036..d57ddece 100644 --- a/libs/qwt/src/qwt_plot_graphicitem.h +++ b/libs/qwt/src/qwt_plot_graphicitem.h @@ -28,28 +28,28 @@ class QWT_EXPORT QwtPlotGraphicItem : public QwtPlotItem { - public: - explicit QwtPlotGraphicItem( const QString& title = QString() ); - explicit QwtPlotGraphicItem( const QwtText& title ); +public: + explicit QwtPlotGraphicItem(const QString &title = QString()); + explicit QwtPlotGraphicItem(const QwtText &title); - virtual ~QwtPlotGraphicItem(); + virtual ~QwtPlotGraphicItem(); - void setGraphic( const QRectF& rect, const QwtGraphic& ); - QwtGraphic graphic() const; + void setGraphic(const QRectF &rect, const QwtGraphic &); + QwtGraphic graphic() const; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - private: - void init(); +private: + void init(); - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_grid.cpp b/libs/qwt/src/qwt_plot_grid.cpp index 30b6b7d5..a1e51e5a 100644 --- a/libs/qwt/src/qwt_plot_grid.cpp +++ b/libs/qwt/src/qwt_plot_grid.cpp @@ -16,54 +16,54 @@ #include #include -static inline bool qwtFuzzyGreaterOrEqual( double d1, double d2 ) +static inline bool qwtFuzzyGreaterOrEqual(double d1, double d2) { - return ( d1 >= d2 ) || qFuzzyCompare( d1, d2 ); + return (d1 >= d2) || qFuzzyCompare(d1, d2); } class QwtPlotGrid::PrivateData { - public: - PrivateData() - : xEnabled( true ) - , yEnabled( true ) - , xMinEnabled( false ) - , yMinEnabled( false ) - { - } +public: + PrivateData() + : xEnabled(true) + , yEnabled(true) + , xMinEnabled(false) + , yMinEnabled(false) + { + } - bool xEnabled; - bool yEnabled; - bool xMinEnabled; - bool yMinEnabled; + bool xEnabled; + bool yEnabled; + bool xMinEnabled; + bool yMinEnabled; - QwtScaleDiv xScaleDiv; - QwtScaleDiv yScaleDiv; + QwtScaleDiv xScaleDiv; + QwtScaleDiv yScaleDiv; - QPen majorPen; - QPen minorPen; + QPen majorPen; + QPen minorPen; }; //! Enables major grid, disables minor grid QwtPlotGrid::QwtPlotGrid() - : QwtPlotItem( QwtText( "Grid" ) ) + : QwtPlotItem(QwtText("Grid")) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemInterest( QwtPlotItem::ScaleInterest, true ); - setZ( 10.0 ); + setItemInterest(QwtPlotItem::ScaleInterest, true); + setZ(10.0); } //! Destructor QwtPlotGrid::~QwtPlotGrid() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PlotGrid int QwtPlotGrid::rtti() const { - return QwtPlotItem::Rtti_PlotGrid; + return QwtPlotItem::Rtti_PlotGrid; } /*! @@ -73,15 +73,15 @@ int QwtPlotGrid::rtti() const \sa Minor grid lines can be enabled or disabled with enableXMin() */ -void QwtPlotGrid::enableX( bool on ) +void QwtPlotGrid::enableX(bool on) { - if ( m_data->xEnabled != on ) - { - m_data->xEnabled = on; + if (m_data->xEnabled != on) + { + m_data->xEnabled = on; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -89,15 +89,15 @@ void QwtPlotGrid::enableX( bool on ) \param on Enable (true) or disable \sa Minor grid lines can be enabled or disabled with enableYMin() */ -void QwtPlotGrid::enableY( bool on ) +void QwtPlotGrid::enableY(bool on) { - if ( m_data->yEnabled != on ) - { - m_data->yEnabled = on; + if (m_data->yEnabled != on) + { + m_data->yEnabled = on; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -105,15 +105,15 @@ void QwtPlotGrid::enableY( bool on ) \param on Enable (true) or disable \sa enableX() */ -void QwtPlotGrid::enableXMin( bool on ) +void QwtPlotGrid::enableXMin(bool on) { - if ( m_data->xMinEnabled != on ) - { - m_data->xMinEnabled = on; + if (m_data->xMinEnabled != on) + { + m_data->xMinEnabled = on; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -121,15 +121,15 @@ void QwtPlotGrid::enableXMin( bool on ) \param on Enable (true) or disable \sa enableY() */ -void QwtPlotGrid::enableYMin( bool on ) +void QwtPlotGrid::enableYMin(bool on) { - if ( m_data->yMinEnabled != on ) - { - m_data->yMinEnabled = on; + if (m_data->yMinEnabled != on) + { + m_data->yMinEnabled = on; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -137,13 +137,13 @@ void QwtPlotGrid::enableYMin( bool on ) \param scaleDiv Scale division */ -void QwtPlotGrid::setXDiv( const QwtScaleDiv& scaleDiv ) +void QwtPlotGrid::setXDiv(const QwtScaleDiv &scaleDiv) { - if ( m_data->xScaleDiv != scaleDiv ) - { - m_data->xScaleDiv = scaleDiv; - itemChanged(); - } + if (m_data->xScaleDiv != scaleDiv) + { + m_data->xScaleDiv = scaleDiv; + itemChanged(); + } } /*! @@ -151,13 +151,13 @@ void QwtPlotGrid::setXDiv( const QwtScaleDiv& scaleDiv ) \param scaleDiv Scale division */ -void QwtPlotGrid::setYDiv( const QwtScaleDiv& scaleDiv ) +void QwtPlotGrid::setYDiv(const QwtScaleDiv &scaleDiv) { - if ( m_data->yScaleDiv != scaleDiv ) - { - m_data->yScaleDiv = scaleDiv; - itemChanged(); - } + if (m_data->yScaleDiv != scaleDiv) + { + m_data->yScaleDiv = scaleDiv; + itemChanged(); + } } /*! @@ -173,9 +173,9 @@ void QwtPlotGrid::setYDiv( const QwtScaleDiv& scaleDiv ) \sa pen(), brush() */ -void QwtPlotGrid::setPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotGrid::setPen(const QColor &color, qreal width, Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -184,16 +184,16 @@ void QwtPlotGrid::setPen( const QColor& color, qreal width, Qt::PenStyle style ) \param pen Pen \sa setMajorPen(), setMinorPen() */ -void QwtPlotGrid::setPen( const QPen& pen ) +void QwtPlotGrid::setPen(const QPen &pen) { - if ( m_data->majorPen != pen || m_data->minorPen != pen ) - { - m_data->majorPen = pen; - m_data->minorPen = pen; + if (m_data->majorPen != pen || m_data->minorPen != pen) + { + m_data->majorPen = pen; + m_data->minorPen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -209,9 +209,10 @@ void QwtPlotGrid::setPen( const QPen& pen ) \sa pen(), brush() */ -void QwtPlotGrid::setMajorPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotGrid::setMajorPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setMajorPen( QPen( color, width, style ) ); + setMajorPen(QPen(color, width, style)); } /*! @@ -220,15 +221,15 @@ void QwtPlotGrid::setMajorPen( const QColor& color, qreal width, Qt::PenStyle st \param pen Pen \sa majorPen(), setMinorPen(), setPen() */ -void QwtPlotGrid::setMajorPen( const QPen& pen ) +void QwtPlotGrid::setMajorPen(const QPen &pen) { - if ( m_data->majorPen != pen ) - { - m_data->majorPen = pen; + if (m_data->majorPen != pen) + { + m_data->majorPen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -244,9 +245,10 @@ void QwtPlotGrid::setMajorPen( const QPen& pen ) \sa pen(), brush() */ -void QwtPlotGrid::setMinorPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotGrid::setMinorPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setMinorPen( QPen( color, width, style ) ); + setMinorPen(QPen(color, width, style)); } /*! @@ -255,15 +257,15 @@ void QwtPlotGrid::setMinorPen( const QColor& color, qreal width, Qt::PenStyle st \param pen Pen \sa minorPen(), setMajorPen(), setPen() */ -void QwtPlotGrid::setMinorPen( const QPen& pen ) +void QwtPlotGrid::setMinorPen(const QPen &pen) { - if ( m_data->minorPen != pen ) - { - m_data->minorPen = pen; + if (m_data->minorPen != pen) + { + m_data->minorPen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -279,103 +281,103 @@ void QwtPlotGrid::setMinorPen( const QPen& pen ) \param yMap Y axis \param canvasRect Contents rectangle of the plot canvas */ -void QwtPlotGrid::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotGrid::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect) const { - // draw minor grid lines - QPen minorPen = m_data->minorPen; - minorPen.setCapStyle( Qt::FlatCap ); + // draw minor grid lines + QPen minorPen = m_data->minorPen; + minorPen.setCapStyle(Qt::FlatCap); - painter->setPen( minorPen ); + painter->setPen(minorPen); - if ( m_data->xEnabled && m_data->xMinEnabled ) - { - drawLines( painter, canvasRect, Qt::Vertical, xMap, - m_data->xScaleDiv.ticks( QwtScaleDiv::MinorTick ) ); - drawLines( painter, canvasRect, Qt::Vertical, xMap, - m_data->xScaleDiv.ticks( QwtScaleDiv::MediumTick ) ); - } + if (m_data->xEnabled && m_data->xMinEnabled) + { + drawLines(painter, canvasRect, Qt::Vertical, xMap, + m_data->xScaleDiv.ticks(QwtScaleDiv::MinorTick)); + drawLines(painter, canvasRect, Qt::Vertical, xMap, + m_data->xScaleDiv.ticks(QwtScaleDiv::MediumTick)); + } - if ( m_data->yEnabled && m_data->yMinEnabled ) - { - drawLines( painter, canvasRect, Qt::Horizontal, yMap, - m_data->yScaleDiv.ticks( QwtScaleDiv::MinorTick ) ); - drawLines( painter, canvasRect, Qt::Horizontal, yMap, - m_data->yScaleDiv.ticks( QwtScaleDiv::MediumTick ) ); - } + if (m_data->yEnabled && m_data->yMinEnabled) + { + drawLines(painter, canvasRect, Qt::Horizontal, yMap, + m_data->yScaleDiv.ticks(QwtScaleDiv::MinorTick)); + drawLines(painter, canvasRect, Qt::Horizontal, yMap, + m_data->yScaleDiv.ticks(QwtScaleDiv::MediumTick)); + } - // draw major grid lines - QPen majorPen = m_data->majorPen; - majorPen.setCapStyle( Qt::FlatCap ); + // draw major grid lines + QPen majorPen = m_data->majorPen; + majorPen.setCapStyle(Qt::FlatCap); - painter->setPen( majorPen ); + painter->setPen(majorPen); - if ( m_data->xEnabled ) - { - drawLines( painter, canvasRect, Qt::Vertical, xMap, - m_data->xScaleDiv.ticks( QwtScaleDiv::MajorTick ) ); - } + if (m_data->xEnabled) + { + drawLines(painter, canvasRect, Qt::Vertical, xMap, + m_data->xScaleDiv.ticks(QwtScaleDiv::MajorTick)); + } - if ( m_data->yEnabled ) - { - drawLines( painter, canvasRect, Qt::Horizontal, yMap, - m_data->yScaleDiv.ticks( QwtScaleDiv::MajorTick ) ); - } + if (m_data->yEnabled) + { + drawLines(painter, canvasRect, Qt::Horizontal, yMap, + m_data->yScaleDiv.ticks(QwtScaleDiv::MajorTick)); + } } -void QwtPlotGrid::drawLines( QPainter* painter, const QRectF& canvasRect, - Qt::Orientation orientation, const QwtScaleMap& scaleMap, - const QList< double >& values ) const +void QwtPlotGrid::drawLines(QPainter *painter, const QRectF &canvasRect, + Qt::Orientation orientation, + const QwtScaleMap &scaleMap, + const QList &values) const { - const double x1 = canvasRect.left(); - const double x2 = canvasRect.right() - 1.0; - const double y1 = canvasRect.top(); - const double y2 = canvasRect.bottom() - 1.0; + const double x1 = canvasRect.left(); + const double x2 = canvasRect.right() - 1.0; + const double y1 = canvasRect.top(); + const double y2 = canvasRect.bottom() - 1.0; - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - for ( int i = 0; i < values.count(); i++ ) + for (int i = 0; i < values.count(); i++) + { + double value = scaleMap.transform(values[i]); + if (doAlign) + value = qRound(value); + + if (orientation == Qt::Horizontal) { - double value = scaleMap.transform( values[i] ); - if ( doAlign ) - value = qRound( value ); - - if ( orientation == Qt::Horizontal ) - { - if ( qwtFuzzyGreaterOrEqual( value, y1 ) && - qwtFuzzyGreaterOrEqual( y2, value ) ) - { - QwtPainter::drawLine( painter, x1, value, x2, value ); - } - } - else - { - if ( qwtFuzzyGreaterOrEqual( value, x1 ) && - qwtFuzzyGreaterOrEqual( x2, value ) ) - { - QwtPainter::drawLine( painter, value, y1, value, y2 ); - } - } + if (qwtFuzzyGreaterOrEqual(value, y1) + && qwtFuzzyGreaterOrEqual(y2, value)) + { + QwtPainter::drawLine(painter, x1, value, x2, value); + } } + else + { + if (qwtFuzzyGreaterOrEqual(value, x1) + && qwtFuzzyGreaterOrEqual(x2, value)) + { + QwtPainter::drawLine(painter, value, y1, value, y2); + } + } + } } /*! \return the pen for the major grid lines \sa setMajorPen(), setMinorPen(), setPen() */ -const QPen& QwtPlotGrid::majorPen() const +const QPen &QwtPlotGrid::majorPen() const { - return m_data->majorPen; + return m_data->majorPen; } /*! \return the pen for the minor grid lines \sa setMinorPen(), setMajorPen(), setPen() */ -const QPen& QwtPlotGrid::minorPen() const +const QPen &QwtPlotGrid::minorPen() const { - return m_data->minorPen; + return m_data->minorPen; } /*! @@ -384,7 +386,7 @@ const QPen& QwtPlotGrid::minorPen() const */ bool QwtPlotGrid::xEnabled() const { - return m_data->xEnabled; + return m_data->xEnabled; } /*! @@ -393,7 +395,7 @@ bool QwtPlotGrid::xEnabled() const */ bool QwtPlotGrid::xMinEnabled() const { - return m_data->xMinEnabled; + return m_data->xMinEnabled; } /*! @@ -402,7 +404,7 @@ bool QwtPlotGrid::xMinEnabled() const */ bool QwtPlotGrid::yEnabled() const { - return m_data->yEnabled; + return m_data->yEnabled; } /*! @@ -411,20 +413,19 @@ bool QwtPlotGrid::yEnabled() const */ bool QwtPlotGrid::yMinEnabled() const { - return m_data->yMinEnabled; + return m_data->yMinEnabled; } - /*! \return the scale division of the x axis */ -const QwtScaleDiv& QwtPlotGrid::xScaleDiv() const +const QwtScaleDiv &QwtPlotGrid::xScaleDiv() const { - return m_data->xScaleDiv; + return m_data->xScaleDiv; } /*! \return the scale division of the y axis */ -const QwtScaleDiv& QwtPlotGrid::yScaleDiv() const +const QwtScaleDiv &QwtPlotGrid::yScaleDiv() const { - return m_data->yScaleDiv; + return m_data->yScaleDiv; } /*! @@ -435,9 +436,9 @@ const QwtScaleDiv& QwtPlotGrid::yScaleDiv() const \sa QwtPlot::updateAxes() */ -void QwtPlotGrid::updateScaleDiv( const QwtScaleDiv& xScaleDiv, - const QwtScaleDiv& yScaleDiv ) +void QwtPlotGrid::updateScaleDiv(const QwtScaleDiv &xScaleDiv, + const QwtScaleDiv &yScaleDiv) { - setXDiv( xScaleDiv ); - setYDiv( yScaleDiv ); + setXDiv(xScaleDiv); + setYDiv(yScaleDiv); } diff --git a/libs/qwt/src/qwt_plot_grid.h b/libs/qwt/src/qwt_plot_grid.h index a742fc27..e137ffdc 100644 --- a/libs/qwt/src/qwt_plot_grid.h +++ b/libs/qwt/src/qwt_plot_grid.h @@ -32,59 +32,58 @@ class QwtScaleDiv; class QWT_EXPORT QwtPlotGrid : public QwtPlotItem { - public: - explicit QwtPlotGrid(); - virtual ~QwtPlotGrid(); +public: + explicit QwtPlotGrid(); + virtual ~QwtPlotGrid(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void enableX( bool ); - bool xEnabled() const; + void enableX(bool); + bool xEnabled() const; - void enableY( bool ); - bool yEnabled() const; + void enableY(bool); + bool yEnabled() const; - void enableXMin( bool ); - bool xMinEnabled() const; + void enableXMin(bool); + bool xMinEnabled() const; - void enableYMin( bool ); - bool yMinEnabled() const; + void enableYMin(bool); + bool yMinEnabled() const; - void setXDiv( const QwtScaleDiv& ); - const QwtScaleDiv& xScaleDiv() const; + void setXDiv(const QwtScaleDiv &); + const QwtScaleDiv &xScaleDiv() const; - void setYDiv( const QwtScaleDiv& ); - const QwtScaleDiv& yScaleDiv() const; + void setYDiv(const QwtScaleDiv &); + const QwtScaleDiv &yScaleDiv() const; - void setPen( const QColor&, - qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); - void setPen( const QPen& ); + void setPen(const QPen &); - void setMajorPen( const QColor&, - qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); + void setMajorPen(const QColor &, qreal width = 0.0, + Qt::PenStyle = Qt::SolidLine); - void setMajorPen( const QPen& ); - const QPen& majorPen() const; + void setMajorPen(const QPen &); + const QPen &majorPen() const; - void setMinorPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setMinorPen( const QPen& ); - const QPen& minorPen() const; + void setMinorPen(const QColor &, qreal width = 0.0, + Qt::PenStyle = Qt::SolidLine); + void setMinorPen(const QPen &); + const QPen &minorPen() const; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - virtual void updateScaleDiv( - const QwtScaleDiv& xScaleDiv, const QwtScaleDiv& yScaleDiv ) QWT_OVERRIDE; + virtual void updateScaleDiv(const QwtScaleDiv &xScaleDiv, + const QwtScaleDiv &yScaleDiv) QWT_OVERRIDE; - private: - void drawLines( QPainter*, const QRectF&, - Qt::Orientation, const QwtScaleMap&, - const QList< double >& ) const; +private: + void drawLines(QPainter *, const QRectF &, Qt::Orientation, + const QwtScaleMap &, const QList &) const; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_histogram.cpp b/libs/qwt/src/qwt_plot_histogram.cpp index 1f2a9603..7df2362e 100644 --- a/libs/qwt/src/qwt_plot_histogram.cpp +++ b/libs/qwt/src/qwt_plot_histogram.cpp @@ -16,83 +16,79 @@ #include #include -static inline bool qwtIsCombinable( const QwtInterval& d1, - const QwtInterval& d2 ) +static inline bool qwtIsCombinable(const QwtInterval &d1, const QwtInterval &d2) { - if ( d1.isValid() && d2.isValid() ) + if (d1.isValid() && d2.isValid()) + { + if (d1.maxValue() == d2.minValue()) { - if ( d1.maxValue() == d2.minValue() ) - { - if ( !( d1.borderFlags() & QwtInterval::ExcludeMaximum - && d2.borderFlags() & QwtInterval::ExcludeMinimum ) ) - { - return true; - } - } + if (!(d1.borderFlags() & QwtInterval::ExcludeMaximum + && d2.borderFlags() & QwtInterval::ExcludeMinimum)) + { + return true; + } } + } - return false; + return false; } class QwtPlotHistogram::PrivateData { - public: - PrivateData() - : baseline( 0.0 ) - , style( Columns ) - , symbol( NULL ) - { - } +public: + PrivateData() + : baseline(0.0) + , style(Columns) + , symbol(NULL) + { + } - ~PrivateData() - { - delete symbol; - } + ~PrivateData() { delete symbol; } - double baseline; + double baseline; - QPen pen; - QBrush brush; - QwtPlotHistogram::HistogramStyle style; - const QwtColumnSymbol* symbol; + QPen pen; + QBrush brush; + QwtPlotHistogram::HistogramStyle style; + const QwtColumnSymbol *symbol; }; /*! Constructor \param title Title of the histogram. */ -QwtPlotHistogram::QwtPlotHistogram( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotHistogram::QwtPlotHistogram(const QwtText &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } /*! Constructor \param title Title of the histogram. */ -QwtPlotHistogram::QwtPlotHistogram( const QString& title ) - : QwtPlotSeriesItem( title ) +QwtPlotHistogram::QwtPlotHistogram(const QString &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } //! Destructor QwtPlotHistogram::~QwtPlotHistogram() { - delete m_data; + delete m_data; } //! Initialize data members void QwtPlotHistogram::init() { - m_data = new PrivateData(); - setData( new QwtIntervalSeriesData() ); + m_data = new PrivateData(); + setData(new QwtIntervalSeriesData()); - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Legend, true ); + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Legend, true); - setZ( 20.0 ); + setZ(20.0); } /*! @@ -101,15 +97,15 @@ void QwtPlotHistogram::init() \param style Histogram style \sa HistogramStyle, style() */ -void QwtPlotHistogram::setStyle( HistogramStyle style ) +void QwtPlotHistogram::setStyle(HistogramStyle style) { - if ( style != m_data->style ) - { - m_data->style = style; + if (style != m_data->style) + { + m_data->style = style; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -118,7 +114,7 @@ void QwtPlotHistogram::setStyle( HistogramStyle style ) */ QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style() const { - return m_data->style; + return m_data->style; } /*! @@ -134,9 +130,10 @@ QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style() const \sa pen(), brush() */ -void QwtPlotHistogram::setPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotHistogram::setPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -145,24 +142,24 @@ void QwtPlotHistogram::setPen( const QColor& color, qreal width, Qt::PenStyle st \param pen New pen \sa pen(), brush() */ -void QwtPlotHistogram::setPen( const QPen& pen ) +void QwtPlotHistogram::setPen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; + if (pen != m_data->pen) + { + m_data->pen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Pen used in a style() depending way. \sa setPen(), brush() */ -const QPen& QwtPlotHistogram::pen() const +const QPen &QwtPlotHistogram::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -171,24 +168,24 @@ const QPen& QwtPlotHistogram::pen() const \param brush New brush \sa pen(), brush() */ -void QwtPlotHistogram::setBrush( const QBrush& brush ) +void QwtPlotHistogram::setBrush(const QBrush &brush) { - if ( brush != m_data->brush ) - { - m_data->brush = brush; + if (brush != m_data->brush) + { + m_data->brush = brush; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Brush used in a style() depending way. \sa setPen(), brush() */ -const QBrush& QwtPlotHistogram::brush() const +const QBrush &QwtPlotHistogram::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -202,28 +199,28 @@ const QBrush& QwtPlotHistogram::brush() const \sa style(), symbol(), drawColumn(), pen(), brush() \note In applications, where different intervals need to be displayed - in a different way ( f.e different colors or even using different symbols) - it is recommended to overload drawColumn(). + in a different way ( f.e different colors or even using different + symbols) it is recommended to overload drawColumn(). */ -void QwtPlotHistogram::setSymbol( const QwtColumnSymbol* symbol ) +void QwtPlotHistogram::setSymbol(const QwtColumnSymbol *symbol) { - if ( symbol != m_data->symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; + if (symbol != m_data->symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Current symbol or NULL, when no symbol has been assigned \sa setSymbol() */ -const QwtColumnSymbol* QwtPlotHistogram::symbol() const +const QwtColumnSymbol *QwtPlotHistogram::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -237,13 +234,13 @@ const QwtColumnSymbol* QwtPlotHistogram::symbol() const \param value Value of the baseline \sa baseline() */ -void QwtPlotHistogram::setBaseline( double value ) +void QwtPlotHistogram::setBaseline(double value) { - if ( m_data->baseline != value ) - { - m_data->baseline = value; - itemChanged(); - } + if (m_data->baseline != value) + { + m_data->baseline = value; + itemChanged(); + } } /*! @@ -252,7 +249,7 @@ void QwtPlotHistogram::setBaseline( double value ) */ double QwtPlotHistogram::baseline() const { - return m_data->baseline; + return m_data->baseline; } /*! @@ -261,45 +258,43 @@ double QwtPlotHistogram::baseline() const */ QRectF QwtPlotHistogram::boundingRect() const { - QRectF rect = data()->boundingRect(); - if ( !rect.isValid() ) - return rect; - - if ( orientation() == Qt::Horizontal ) - { - rect = QRectF( rect.y(), rect.x(), - rect.height(), rect.width() ); - - if ( rect.left() > m_data->baseline ) - rect.setLeft( m_data->baseline ); - else if ( rect.right() < m_data->baseline ) - rect.setRight( m_data->baseline ); - } - else - { - if ( rect.bottom() < m_data->baseline ) - rect.setBottom( m_data->baseline ); - else if ( rect.top() > m_data->baseline ) - rect.setTop( m_data->baseline ); - } - + QRectF rect = data()->boundingRect(); + if (!rect.isValid()) return rect; + + if (orientation() == Qt::Horizontal) + { + rect = QRectF(rect.y(), rect.x(), rect.height(), rect.width()); + + if (rect.left() > m_data->baseline) + rect.setLeft(m_data->baseline); + else if (rect.right() < m_data->baseline) + rect.setRight(m_data->baseline); + } + else + { + if (rect.bottom() < m_data->baseline) + rect.setBottom(m_data->baseline); + else if (rect.top() > m_data->baseline) + rect.setTop(m_data->baseline); + } + + return rect; } //! \return QwtPlotItem::Rtti_PlotHistogram int QwtPlotHistogram::rtti() const { - return QwtPlotItem::Rtti_PlotHistogram; + return QwtPlotItem::Rtti_PlotHistogram; } /*! Initialize data with an array of samples. \param samples Vector of points */ -void QwtPlotHistogram::setSamples( - const QVector< QwtIntervalSample >& samples ) +void QwtPlotHistogram::setSamples(const QVector &samples) { - setData( new QwtIntervalSeriesData( samples ) ); + setData(new QwtIntervalSeriesData(samples)); } /*! @@ -312,10 +307,9 @@ void QwtPlotHistogram::setSamples( \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotHistogram::setSamples( - QwtSeriesData< QwtIntervalSample >* data ) +void QwtPlotHistogram::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -331,32 +325,33 @@ void QwtPlotHistogram::setSamples( \sa drawOutline(), drawLines(), drawColumns */ -void QwtPlotHistogram::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotHistogram::drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - Q_UNUSED( canvasRect ) + Q_UNUSED(canvasRect) - if ( !painter || dataSize() <= 0 ) - return; + if (!painter || dataSize() <= 0) + return; - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - switch ( m_data->style ) - { - case Outline: - drawOutline( painter, xMap, yMap, from, to ); - break; - case Lines: - drawLines( painter, xMap, yMap, from, to ); - break; - case Columns: - drawColumns( painter, xMap, yMap, from, to ); - break; - default: - break; - } + switch (m_data->style) + { + case Outline: + drawOutline(painter, xMap, yMap, from, to); + break; + case Lines: + drawLines(painter, xMap, yMap, from, to); + break; + case Columns: + drawColumns(painter, xMap, yMap, from, to); + break; + default: + break; + } } /*! @@ -373,77 +368,77 @@ void QwtPlotHistogram::drawSeries(QPainter* painter, \warning The outline style requires, that the intervals are in increasing order and not overlapping. */ -void QwtPlotHistogram::drawOutline( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - int from, int to ) const +void QwtPlotHistogram::drawOutline(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, int from, + int to) const { - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - double v0 = ( orientation() == Qt::Horizontal ) ? - xMap.transform( baseline() ) : yMap.transform( baseline() ); - if ( doAlign ) - v0 = qRound( v0 ); + double v0 = (orientation() == Qt::Horizontal) ? xMap.transform(baseline()) + : yMap.transform(baseline()); + if (doAlign) + v0 = qRound(v0); - QwtIntervalSample previous; + QwtIntervalSample previous; - QPolygonF polygon; - for ( int i = from; i <= to; i++ ) + QPolygonF polygon; + for (int i = from; i <= to; i++) + { + const QwtIntervalSample sample = this->sample(i); + + if (!sample.interval.isValid()) { - const QwtIntervalSample sample = this->sample( i ); - - if ( !sample.interval.isValid() ) - { - flushPolygon( painter, v0, polygon ); - previous = sample; - continue; - } - - if ( previous.interval.isValid() ) - { - if ( !qwtIsCombinable( previous.interval, sample.interval ) ) - flushPolygon( painter, v0, polygon ); - } - - if ( orientation() == Qt::Vertical ) - { - double x1 = xMap.transform( sample.interval.minValue() ); - double x2 = xMap.transform( sample.interval.maxValue() ); - double y = yMap.transform( sample.value ); - if ( doAlign ) - { - x1 = qRound( x1 ); - x2 = qRound( x2 ); - y = qRound( y ); - } - - if ( polygon.size() == 0 ) - polygon += QPointF( x1, v0 ); - - polygon += QPointF( x1, y ); - polygon += QPointF( x2, y ); - } - else - { - double y1 = yMap.transform( sample.interval.minValue() ); - double y2 = yMap.transform( sample.interval.maxValue() ); - double x = xMap.transform( sample.value ); - if ( doAlign ) - { - y1 = qRound( y1 ); - y2 = qRound( y2 ); - x = qRound( x ); - } - - if ( polygon.size() == 0 ) - polygon += QPointF( v0, y1 ); - - polygon += QPointF( x, y1 ); - polygon += QPointF( x, y2 ); - } - previous = sample; + flushPolygon(painter, v0, polygon); + previous = sample; + continue; } - flushPolygon( painter, v0, polygon ); + if (previous.interval.isValid()) + { + if (!qwtIsCombinable(previous.interval, sample.interval)) + flushPolygon(painter, v0, polygon); + } + + if (orientation() == Qt::Vertical) + { + double x1 = xMap.transform(sample.interval.minValue()); + double x2 = xMap.transform(sample.interval.maxValue()); + double y = yMap.transform(sample.value); + if (doAlign) + { + x1 = qRound(x1); + x2 = qRound(x2); + y = qRound(y); + } + + if (polygon.size() == 0) + polygon += QPointF(x1, v0); + + polygon += QPointF(x1, y); + polygon += QPointF(x2, y); + } + else + { + double y1 = yMap.transform(sample.interval.minValue()); + double y2 = yMap.transform(sample.interval.maxValue()); + double x = xMap.transform(sample.value); + if (doAlign) + { + y1 = qRound(y1); + y2 = qRound(y2); + x = qRound(x); + } + + if (polygon.size() == 0) + polygon += QPointF(v0, y1); + + polygon += QPointF(x, y1); + polygon += QPointF(x, y2); + } + previous = sample; + } + + flushPolygon(painter, v0, polygon); } /*! @@ -458,24 +453,24 @@ void QwtPlotHistogram::drawOutline( QPainter* painter, \sa setStyle(), style(), setSymbol(), drawColumn() */ -void QwtPlotHistogram::drawColumns( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - int from, int to ) const +void QwtPlotHistogram::drawColumns(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, int from, + int to) const { - painter->setPen( m_data->pen ); - painter->setBrush( m_data->brush ); + painter->setPen(m_data->pen); + painter->setBrush(m_data->brush); - const QwtSeriesData< QwtIntervalSample >* series = data(); + const QwtSeriesData *series = data(); - for ( int i = from; i <= to; i++ ) + for (int i = from; i <= to; i++) + { + const QwtIntervalSample sample = series->sample(i); + if (!sample.interval.isNull()) { - const QwtIntervalSample sample = series->sample( i ); - if ( !sample.interval.isNull() ) - { - const QwtColumnRect rect = columnRect( sample, xMap, yMap ); - drawColumn( painter, rect, sample ); - } + const QwtColumnRect rect = columnRect(sample, xMap, yMap); + drawColumn(painter, rect, sample); } + } } /*! @@ -490,104 +485,96 @@ void QwtPlotHistogram::drawColumns( QPainter* painter, \sa setStyle(), style(), setPen() */ -void QwtPlotHistogram::drawLines( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - int from, int to ) const +void QwtPlotHistogram::drawLines(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, int from, + int to) const { - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - painter->setPen( m_data->pen ); - painter->setBrush( Qt::NoBrush ); + painter->setPen(m_data->pen); + painter->setBrush(Qt::NoBrush); - const QwtSeriesData< QwtIntervalSample >* series = data(); + const QwtSeriesData *series = data(); - for ( int i = from; i <= to; i++ ) + for (int i = from; i <= to; i++) + { + const QwtIntervalSample sample = series->sample(i); + if (!sample.interval.isNull()) { - const QwtIntervalSample sample = series->sample( i ); - if ( !sample.interval.isNull() ) - { - const QwtColumnRect rect = columnRect( sample, xMap, yMap ); + const QwtColumnRect rect = columnRect(sample, xMap, yMap); - QRectF r = rect.toRect(); - if ( doAlign ) - { - r.setLeft( qRound( r.left() ) ); - r.setRight( qRound( r.right() ) ); - r.setTop( qRound( r.top() ) ); - r.setBottom( qRound( r.bottom() ) ); - } + QRectF r = rect.toRect(); + if (doAlign) + { + r.setLeft(qRound(r.left())); + r.setRight(qRound(r.right())); + r.setTop(qRound(r.top())); + r.setBottom(qRound(r.bottom())); + } - switch ( rect.direction ) - { - case QwtColumnRect::LeftToRight: - { - QwtPainter::drawLine( painter, - r.topRight(), r.bottomRight() ); - break; - } - case QwtColumnRect::RightToLeft: - { - QwtPainter::drawLine( painter, - r.topLeft(), r.bottomLeft() ); - break; - } - case QwtColumnRect::TopToBottom: - { - QwtPainter::drawLine( painter, - r.bottomRight(), r.bottomLeft() ); - break; - } - case QwtColumnRect::BottomToTop: - { - QwtPainter::drawLine( painter, - r.topRight(), r.topLeft() ); - break; - } - } + switch (rect.direction) + { + case QwtColumnRect::LeftToRight: { + QwtPainter::drawLine(painter, r.topRight(), r.bottomRight()); + break; } + case QwtColumnRect::RightToLeft: { + QwtPainter::drawLine(painter, r.topLeft(), r.bottomLeft()); + break; + } + case QwtColumnRect::TopToBottom: { + QwtPainter::drawLine(painter, r.bottomRight(), r.bottomLeft()); + break; + } + case QwtColumnRect::BottomToTop: { + QwtPainter::drawLine(painter, r.topRight(), r.topLeft()); + break; + } + } } + } } //! Internal, used by the Outline style. -void QwtPlotHistogram::flushPolygon( QPainter* painter, - double baseLine, QPolygonF& polygon ) const +void QwtPlotHistogram::flushPolygon(QPainter *painter, double baseLine, + QPolygonF &polygon) const { - if ( polygon.size() == 0 ) - return; + if (polygon.size() == 0) + return; - if ( orientation() == Qt::Horizontal ) - polygon += QPointF( baseLine, polygon.last().y() ); + if (orientation() == Qt::Horizontal) + polygon += QPointF(baseLine, polygon.last().y()); + else + polygon += QPointF(polygon.last().x(), baseLine); + + if (m_data->brush.style() != Qt::NoBrush) + { + painter->setPen(Qt::NoPen); + painter->setBrush(m_data->brush); + + if (orientation() == Qt::Horizontal) + { + polygon += QPointF(polygon.last().x(), baseLine); + polygon += QPointF(polygon.first().x(), baseLine); + } else - polygon += QPointF( polygon.last().x(), baseLine ); - - if ( m_data->brush.style() != Qt::NoBrush ) { - painter->setPen( Qt::NoPen ); - painter->setBrush( m_data->brush ); - - if ( orientation() == Qt::Horizontal ) - { - polygon += QPointF( polygon.last().x(), baseLine ); - polygon += QPointF( polygon.first().x(), baseLine ); - } - else - { - polygon += QPointF( baseLine, polygon.last().y() ); - polygon += QPointF( baseLine, polygon.first().y() ); - } - - QwtPainter::drawPolygon( painter, polygon ); - - polygon.pop_back(); - polygon.pop_back(); + polygon += QPointF(baseLine, polygon.last().y()); + polygon += QPointF(baseLine, polygon.first().y()); } - if ( m_data->pen.style() != Qt::NoPen ) - { - painter->setBrush( Qt::NoBrush ); - painter->setPen( m_data->pen ); - QwtPainter::drawPolyline( painter, polygon ); - } - polygon.clear(); + + QwtPainter::drawPolygon(painter, polygon); + + polygon.pop_back(); + polygon.pop_back(); + } + if (m_data->pen.style() != Qt::NoPen) + { + painter->setBrush(Qt::NoBrush); + painter->setPen(m_data->pen); + QwtPainter::drawPolyline(painter, polygon); + } + polygon.clear(); } /*! @@ -599,41 +586,42 @@ void QwtPlotHistogram::flushPolygon( QPainter* painter, \return Rectangle, that is covered by a sample */ -QwtColumnRect QwtPlotHistogram::columnRect( const QwtIntervalSample& sample, - const QwtScaleMap& xMap, const QwtScaleMap& yMap ) const +QwtColumnRect QwtPlotHistogram::columnRect(const QwtIntervalSample &sample, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap) const { - QwtColumnRect rect; - - const QwtInterval& iv = sample.interval; - if ( !iv.isValid() ) - return rect; - - if ( orientation() == Qt::Horizontal ) - { - const double x0 = xMap.transform( baseline() ); - const double x = xMap.transform( sample.value ); - const double y1 = yMap.transform( iv.minValue() ); - const double y2 = yMap.transform( iv.maxValue() ); - - rect.hInterval.setInterval( x0, x ); - rect.vInterval.setInterval( y1, y2, iv.borderFlags() ); - rect.direction = ( x < x0 ) ? QwtColumnRect::RightToLeft : - QwtColumnRect::LeftToRight; - } - else - { - const double x1 = xMap.transform( iv.minValue() ); - const double x2 = xMap.transform( iv.maxValue() ); - const double y0 = yMap.transform( baseline() ); - const double y = yMap.transform( sample.value ); - - rect.hInterval.setInterval( x1, x2, iv.borderFlags() ); - rect.vInterval.setInterval( y0, y ); - rect.direction = ( y < y0 ) ? QwtColumnRect::BottomToTop : - QwtColumnRect::TopToBottom; - } + QwtColumnRect rect; + const QwtInterval &iv = sample.interval; + if (!iv.isValid()) return rect; + + if (orientation() == Qt::Horizontal) + { + const double x0 = xMap.transform(baseline()); + const double x = xMap.transform(sample.value); + const double y1 = yMap.transform(iv.minValue()); + const double y2 = yMap.transform(iv.maxValue()); + + rect.hInterval.setInterval(x0, x); + rect.vInterval.setInterval(y1, y2, iv.borderFlags()); + rect.direction + = (x < x0) ? QwtColumnRect::RightToLeft : QwtColumnRect::LeftToRight; + } + else + { + const double x1 = xMap.transform(iv.minValue()); + const double x2 = xMap.transform(iv.maxValue()); + const double y0 = yMap.transform(baseline()); + const double y = yMap.transform(sample.value); + + rect.hInterval.setInterval(x1, x2, iv.borderFlags()); + rect.vInterval.setInterval(y0, y); + rect.direction + = (y < y0) ? QwtColumnRect::BottomToTop : QwtColumnRect::TopToBottom; + } + + return rect; } /*! @@ -647,32 +635,31 @@ QwtColumnRect QwtPlotHistogram::columnRect( const QwtIntervalSample& sample, \param sample Sample to be displayed \note In applications, where different intervals need to be displayed - in a different way ( f.e different colors or even using different symbols) - it is recommended to overload drawColumn(). + in a different way ( f.e different colors or even using different + symbols) it is recommended to overload drawColumn(). */ -void QwtPlotHistogram::drawColumn( QPainter* painter, - const QwtColumnRect& rect, const QwtIntervalSample& sample ) const +void QwtPlotHistogram::drawColumn(QPainter *painter, const QwtColumnRect &rect, + const QwtIntervalSample &sample) const { - Q_UNUSED( sample ); + Q_UNUSED(sample); - if ( m_data->symbol && - ( m_data->symbol->style() != QwtColumnSymbol::NoStyle ) ) + if (m_data->symbol && (m_data->symbol->style() != QwtColumnSymbol::NoStyle)) + { + m_data->symbol->draw(painter, rect); + } + else + { + QRectF r = rect.toRect(); + if (QwtPainter::roundingAlignment(painter)) { - m_data->symbol->draw( painter, rect ); + r.setLeft(qRound(r.left())); + r.setRight(qRound(r.right())); + r.setTop(qRound(r.top())); + r.setBottom(qRound(r.bottom())); } - else - { - QRectF r = rect.toRect(); - if ( QwtPainter::roundingAlignment( painter ) ) - { - r.setLeft( qRound( r.left() ) ); - r.setRight( qRound( r.right() ) ); - r.setTop( qRound( r.top() ) ); - r.setBottom( qRound( r.bottom() ) ); - } - QwtPainter::drawRect( painter, r ); - } + QwtPainter::drawRect(painter, r); + } } /*! @@ -685,8 +672,8 @@ void QwtPlotHistogram::drawColumn( QPainter* painter, \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() */ -QwtGraphic QwtPlotHistogram::legendIcon( int index, const QSizeF& size ) const +QwtGraphic QwtPlotHistogram::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); - return defaultIcon( m_data->brush, size ); + Q_UNUSED(index); + return defaultIcon(m_data->brush, size); } diff --git a/libs/qwt/src/qwt_plot_histogram.h b/libs/qwt/src/qwt_plot_histogram.h index 6fdd3455..23ad593e 100644 --- a/libs/qwt/src/qwt_plot_histogram.h +++ b/libs/qwt/src/qwt_plot_histogram.h @@ -19,7 +19,8 @@ class QColor; class QPolygonF; #if QT_VERSION < 0x060000 -template< typename T > class QVector; +template +class QVector; #endif /*! @@ -38,108 +39,103 @@ template< typename T > class QVector; \sa QwtPlotBarChart, QwtPlotMultiBarChart */ -class QWT_EXPORT QwtPlotHistogram - : public QwtPlotSeriesItem - , public QwtSeriesStore< QwtIntervalSample > +class QWT_EXPORT QwtPlotHistogram : public QwtPlotSeriesItem, + public QwtSeriesStore { - public: +public: + /*! + Histogram styles. + The default style is QwtPlotHistogram::Columns. + + \sa setStyle(), style(), setSymbol(), symbol(), setBaseline() + */ + enum HistogramStyle + { /*! - Histogram styles. - The default style is QwtPlotHistogram::Columns. - - \sa setStyle(), style(), setSymbol(), symbol(), setBaseline() + Draw an outline around the area, that is build by all intervals + using the pen() and fill it with the brush(). The outline style + requires, that the intervals are in increasing order and + not overlapping. */ - enum HistogramStyle - { - /*! - Draw an outline around the area, that is build by all intervals - using the pen() and fill it with the brush(). The outline style - requires, that the intervals are in increasing order and - not overlapping. - */ - Outline, + Outline, - /*! - Draw a column for each interval. When a symbol() has been set - the symbol is used otherwise the column is displayed as - plain rectangle using pen() and brush(). - */ - Columns, + /*! + Draw a column for each interval. When a symbol() has been set + the symbol is used otherwise the column is displayed as + plain rectangle using pen() and brush(). + */ + Columns, - /*! - Draw a simple line using the pen() for each interval. - */ - Lines, + /*! + Draw a simple line using the pen() for each interval. + */ + Lines, - /*! - Styles >= UserStyle are reserved for derived - classes that overload drawSeries() with - additional application specific ways to display a histogram. - */ - UserStyle = 100 - }; + /*! + Styles >= UserStyle are reserved for derived + classes that overload drawSeries() with + additional application specific ways to display a histogram. + */ + UserStyle = 100 + }; - explicit QwtPlotHistogram( const QString& title = QString() ); - explicit QwtPlotHistogram( const QwtText& title ); - virtual ~QwtPlotHistogram(); + explicit QwtPlotHistogram(const QString &title = QString()); + explicit QwtPlotHistogram(const QwtText &title); + virtual ~QwtPlotHistogram(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setPen( const QColor&, - qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); - void setPen( const QPen& ); - const QPen& pen() const; + void setPen(const QPen &); + const QPen &pen() const; - void setBrush( const QBrush& ); - const QBrush& brush() const; + void setBrush(const QBrush &); + const QBrush &brush() const; - void setSamples( const QVector< QwtIntervalSample >& ); - void setSamples( QwtSeriesData< QwtIntervalSample >* ); + void setSamples(const QVector &); + void setSamples(QwtSeriesData *); - void setBaseline( double ); - double baseline() const; + void setBaseline(double); + double baseline() const; - void setStyle( HistogramStyle style ); - HistogramStyle style() const; + void setStyle(HistogramStyle style); + HistogramStyle style() const; - void setSymbol( const QwtColumnSymbol* ); - const QwtColumnSymbol* symbol() const; + void setSymbol(const QwtColumnSymbol *); + const QwtColumnSymbol *symbol() const; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual QwtGraphic legendIcon( - int index, const QSizeF& ) const QWT_OVERRIDE; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - protected: - virtual QwtColumnRect columnRect( const QwtIntervalSample&, - const QwtScaleMap&, const QwtScaleMap& ) const; +protected: + virtual QwtColumnRect columnRect(const QwtIntervalSample &, + const QwtScaleMap &, + const QwtScaleMap &) const; - virtual void drawColumn( QPainter*, const QwtColumnRect&, - const QwtIntervalSample& ) const; + virtual void drawColumn(QPainter *, const QwtColumnRect &, + const QwtIntervalSample &) const; - void drawColumns( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - int from, int to ) const; + void drawColumns(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, + int from, int to) const; - void drawOutline( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - int from, int to ) const; + void drawOutline(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, + int from, int to) const; - void drawLines( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - int from, int to ) const; + void drawLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, + int from, int to) const; - private: - void init(); - void flushPolygon( QPainter*, double baseLine, QPolygonF& ) const; +private: + void init(); + void flushPolygon(QPainter *, double baseLine, QPolygonF &) const; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_intervalcurve.cpp b/libs/qwt/src/qwt_plot_intervalcurve.cpp index ce68ff0e..66b59a46 100644 --- a/libs/qwt/src/qwt_plot_intervalcurve.cpp +++ b/libs/qwt/src/qwt_plot_intervalcurve.cpp @@ -18,103 +18,102 @@ #include #include -static inline bool qwtIsHSampleInside( const QwtIntervalSample& sample, - double xMin, double xMax, double yMin, double yMax ) +static inline bool qwtIsHSampleInside(const QwtIntervalSample &sample, + double xMin, double xMax, double yMin, + double yMax) { - const double y = sample.value; - const double x1 = sample.interval.minValue(); - const double x2 = sample.interval.maxValue(); + const double y = sample.value; + const double x1 = sample.interval.minValue(); + const double x2 = sample.interval.maxValue(); - const bool isOffScreen = ( y < yMin ) || ( y > yMax ) - || ( x1 < xMin && x2 < xMin ) || ( x1 > xMax && x2 > xMax ); + const bool isOffScreen = (y < yMin) || (y > yMax) || (x1 < xMin && x2 < xMin) + || (x1 > xMax && x2 > xMax); - return !isOffScreen; + return !isOffScreen; } -static inline bool qwtIsVSampleInside( const QwtIntervalSample& sample, - double xMin, double xMax, double yMin, double yMax ) +static inline bool qwtIsVSampleInside(const QwtIntervalSample &sample, + double xMin, double xMax, double yMin, + double yMax) { - const double x = sample.value; - const double y1 = sample.interval.minValue(); - const double y2 = sample.interval.maxValue(); + const double x = sample.value; + const double y1 = sample.interval.minValue(); + const double y2 = sample.interval.maxValue(); - const bool isOffScreen = ( x < xMin ) || ( x > xMax ) - || ( y1 < yMin && y2 < yMin ) || ( y1 > yMax && y2 > yMax ); + const bool isOffScreen = (x < xMin) || (x > xMax) || (y1 < yMin && y2 < yMin) + || (y1 > yMax && y2 > yMax); - return !isOffScreen; + return !isOffScreen; } class QwtPlotIntervalCurve::PrivateData { - public: - PrivateData(): - style( QwtPlotIntervalCurve::Tube ), - symbol( NULL ), - pen( Qt::black ), - brush( Qt::white ) - { - paintAttributes = QwtPlotIntervalCurve::ClipPolygons; - paintAttributes |= QwtPlotIntervalCurve::ClipSymbol; +public: + PrivateData() + : style(QwtPlotIntervalCurve::Tube) + , symbol(NULL) + , pen(Qt::black) + , brush(Qt::white) + { + paintAttributes = QwtPlotIntervalCurve::ClipPolygons; + paintAttributes |= QwtPlotIntervalCurve::ClipSymbol; - pen.setCapStyle( Qt::FlatCap ); - } + pen.setCapStyle(Qt::FlatCap); + } - ~PrivateData() - { - delete symbol; - } + ~PrivateData() { delete symbol; } - QwtPlotIntervalCurve::CurveStyle style; - const QwtIntervalSymbol* symbol; + QwtPlotIntervalCurve::CurveStyle style; + const QwtIntervalSymbol *symbol; - QPen pen; - QBrush brush; + QPen pen; + QBrush brush; - QwtPlotIntervalCurve::PaintAttributes paintAttributes; + QwtPlotIntervalCurve::PaintAttributes paintAttributes; }; /*! Constructor \param title Title of the curve */ -QwtPlotIntervalCurve::QwtPlotIntervalCurve( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotIntervalCurve::QwtPlotIntervalCurve(const QwtText &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } /*! Constructor \param title Title of the curve */ -QwtPlotIntervalCurve::QwtPlotIntervalCurve( const QString& title ) - : QwtPlotSeriesItem( QwtText( title ) ) +QwtPlotIntervalCurve::QwtPlotIntervalCurve(const QString &title) + : QwtPlotSeriesItem(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotIntervalCurve::~QwtPlotIntervalCurve() { - delete m_data; + delete m_data; } //! Initialize internal members void QwtPlotIntervalCurve::init() { - setItemAttribute( QwtPlotItem::Legend, true ); - setItemAttribute( QwtPlotItem::AutoScale, true ); + setItemAttribute(QwtPlotItem::Legend, true); + setItemAttribute(QwtPlotItem::AutoScale, true); - m_data = new PrivateData; - setData( new QwtIntervalSeriesData() ); + m_data = new PrivateData; + setData(new QwtIntervalSeriesData()); - setZ( 19.0 ); + setZ(19.0); } //! \return QwtPlotItem::Rtti_PlotIntervalCurve int QwtPlotIntervalCurve::rtti() const { - return QwtPlotIntervalCurve::Rtti_PlotIntervalCurve; + return QwtPlotIntervalCurve::Rtti_PlotIntervalCurve; } /*! @@ -124,33 +123,30 @@ int QwtPlotIntervalCurve::rtti() const \param on On/Off \sa testPaintAttribute() */ -void QwtPlotIntervalCurve::setPaintAttribute( - PaintAttribute attribute, bool on ) +void QwtPlotIntervalCurve::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! \return True, when attribute is enabled \sa PaintAttribute, setPaintAttribute() */ -bool QwtPlotIntervalCurve::testPaintAttribute( - PaintAttribute attribute ) const +bool QwtPlotIntervalCurve::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! Initialize data with an array of samples. \param samples Vector of samples */ -void QwtPlotIntervalCurve::setSamples( - const QVector< QwtIntervalSample >& samples ) +void QwtPlotIntervalCurve::setSamples(const QVector &samples) { - setData( new QwtIntervalSeriesData( samples ) ); + setData(new QwtIntervalSeriesData(samples)); } /*! @@ -163,10 +159,9 @@ void QwtPlotIntervalCurve::setSamples( \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotIntervalCurve::setSamples( - QwtSeriesData< QwtIntervalSample >* data ) +void QwtPlotIntervalCurve::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -175,15 +170,15 @@ void QwtPlotIntervalCurve::setSamples( \param style Curve style \sa CurveStyle, style() */ -void QwtPlotIntervalCurve::setStyle( CurveStyle style ) +void QwtPlotIntervalCurve::setStyle(CurveStyle style) { - if ( style != m_data->style ) - { - m_data->style = style; + if (style != m_data->style) + { + m_data->style = style; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -192,7 +187,7 @@ void QwtPlotIntervalCurve::setStyle( CurveStyle style ) */ QwtPlotIntervalCurve::CurveStyle QwtPlotIntervalCurve::style() const { - return m_data->style; + return m_data->style; } /*! @@ -201,25 +196,25 @@ QwtPlotIntervalCurve::CurveStyle QwtPlotIntervalCurve::style() const \param symbol Symbol \sa symbol() */ -void QwtPlotIntervalCurve::setSymbol( const QwtIntervalSymbol* symbol ) +void QwtPlotIntervalCurve::setSymbol(const QwtIntervalSymbol *symbol) { - if ( symbol != m_data->symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; + if (symbol != m_data->symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Current symbol or NULL, when no symbol has been assigned \sa setSymbol() */ -const QwtIntervalSymbol* QwtPlotIntervalCurve::symbol() const +const QwtIntervalSymbol *QwtPlotIntervalCurve::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -235,9 +230,10 @@ const QwtIntervalSymbol* QwtPlotIntervalCurve::symbol() const \sa pen(), brush() */ -void QwtPlotIntervalCurve::setPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotIntervalCurve::setPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -245,24 +241,24 @@ void QwtPlotIntervalCurve::setPen( const QColor& color, qreal width, Qt::PenStyl \param pen New pen \sa pen(), brush() */ -void QwtPlotIntervalCurve::setPen( const QPen& pen ) +void QwtPlotIntervalCurve::setPen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; + if (pen != m_data->pen) + { + m_data->pen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Pen used to draw the lines \sa setPen(), brush() */ -const QPen& QwtPlotIntervalCurve::pen() const +const QPen &QwtPlotIntervalCurve::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -273,24 +269,24 @@ const QPen& QwtPlotIntervalCurve::pen() const \param brush Brush \sa brush(), pen(), setStyle(), CurveStyle */ -void QwtPlotIntervalCurve::setBrush( const QBrush& brush ) +void QwtPlotIntervalCurve::setBrush(const QBrush &brush) { - if ( brush != m_data->brush ) - { - m_data->brush = brush; + if (brush != m_data->brush) + { + m_data->brush = brush; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Brush used to fill the area in Tube style() \sa setBrush(), setStyle(), CurveStyle */ -const QBrush& QwtPlotIntervalCurve::brush() const +const QBrush &QwtPlotIntervalCurve::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -299,11 +295,11 @@ const QBrush& QwtPlotIntervalCurve::brush() const */ QRectF QwtPlotIntervalCurve::boundingRect() const { - QRectF rect = QwtPlotSeriesItem::boundingRect(); - if ( orientation() == Qt::Vertical ) - rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); + QRectF rect = QwtPlotSeriesItem::boundingRect(); + if (orientation() == Qt::Vertical) + rect.setRect(rect.y(), rect.x(), rect.height(), rect.width()); - return rect; + return rect; } /*! @@ -319,36 +315,37 @@ QRectF QwtPlotIntervalCurve::boundingRect() const \sa drawTube(), drawSymbols() */ -void QwtPlotIntervalCurve::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotIntervalCurve::drawSeries(QPainter *painter, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( from > to ) - return; + if (from > to) + return; - switch ( m_data->style ) - { - case Tube: - drawTube( painter, xMap, yMap, canvasRect, from, to ); - break; + switch (m_data->style) + { + case Tube: + drawTube(painter, xMap, yMap, canvasRect, from, to); + break; - case NoCurve: - default: - break; - } + case NoCurve: + default: + break; + } - if ( m_data->symbol && - ( m_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) ) - { - drawSymbols( painter, *m_data->symbol, - xMap, yMap, canvasRect, from, to ); - } + if (m_data->symbol + && (m_data->symbol->style() != QwtIntervalSymbol::NoSymbol)) + { + drawSymbols(painter, *m_data->symbol, xMap, yMap, canvasRect, from, to); + } } /*! @@ -368,107 +365,108 @@ void QwtPlotIntervalCurve::drawSeries(QPainter* painter, \sa drawSeries(), drawSymbols() */ -void QwtPlotIntervalCurve::drawTube( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotIntervalCurve::drawTube(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - painter->save(); + painter->save(); - const int size = to - from + 1; - QPolygonF polygon( 2 * size ); - QPointF* points = polygon.data(); + const int size = to - from + 1; + QPolygonF polygon(2 * size); + QPointF *points = polygon.data(); - for ( int i = 0; i < size; i++ ) + for (int i = 0; i < size; i++) + { + QPointF &minValue = points[i]; + QPointF &maxValue = points[2 * size - 1 - i]; + + const QwtIntervalSample intervalSample = sample(from + i); + if (orientation() == Qt::Vertical) { - QPointF& minValue = points[i]; - QPointF& maxValue = points[2 * size - 1 - i]; + double x = xMap.transform(intervalSample.value); + double y1 = yMap.transform(intervalSample.interval.minValue()); + double y2 = yMap.transform(intervalSample.interval.maxValue()); + if (doAlign) + { + x = qRound(x); + y1 = qRound(y1); + y2 = qRound(y2); + } - const QwtIntervalSample intervalSample = sample( from + i ); - if ( orientation() == Qt::Vertical ) - { - double x = xMap.transform( intervalSample.value ); - double y1 = yMap.transform( intervalSample.interval.minValue() ); - double y2 = yMap.transform( intervalSample.interval.maxValue() ); - if ( doAlign ) - { - x = qRound( x ); - y1 = qRound( y1 ); - y2 = qRound( y2 ); - } - - minValue.rx() = x; - minValue.ry() = y1; - maxValue.rx() = x; - maxValue.ry() = y2; - } - else - { - double y = yMap.transform( intervalSample.value ); - double x1 = xMap.transform( intervalSample.interval.minValue() ); - double x2 = xMap.transform( intervalSample.interval.maxValue() ); - if ( doAlign ) - { - y = qRound( y ); - x1 = qRound( x1 ); - x2 = qRound( x2 ); - } - - minValue.rx() = x1; - minValue.ry() = y; - maxValue.rx() = x2; - maxValue.ry() = y; - } + minValue.rx() = x; + minValue.ry() = y1; + maxValue.rx() = x; + maxValue.ry() = y2; } - - if ( m_data->brush.style() != Qt::NoBrush ) + else { - painter->setPen( QPen( Qt::NoPen ) ); - painter->setBrush( m_data->brush ); + double y = yMap.transform(intervalSample.value); + double x1 = xMap.transform(intervalSample.interval.minValue()); + double x2 = xMap.transform(intervalSample.interval.maxValue()); + if (doAlign) + { + y = qRound(y); + x1 = qRound(x1); + x2 = qRound(x2); + } - if ( m_data->paintAttributes & ClipPolygons ) - { - const qreal m = 1.0; - const QPolygonF p = QwtClipper::clippedPolygonF( - canvasRect.adjusted( -m, -m, m, m ), polygon, true ); - - QwtPainter::drawPolygon( painter, p ); - } - else - { - QwtPainter::drawPolygon( painter, polygon ); - } + minValue.rx() = x1; + minValue.ry() = y; + maxValue.rx() = x2; + maxValue.ry() = y; } + } - if ( m_data->pen.style() != Qt::NoPen ) + if (m_data->brush.style() != Qt::NoBrush) + { + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(m_data->brush); + + if (m_data->paintAttributes & ClipPolygons) { - painter->setPen( m_data->pen ); - painter->setBrush( Qt::NoBrush ); + const qreal m = 1.0; + const QPolygonF p = QwtClipper::clippedPolygonF( + canvasRect.adjusted(-m, -m, m, m), polygon, true); - if ( m_data->paintAttributes & ClipPolygons ) - { - qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); - const QRectF clipRect = canvasRect.adjusted( -pw, -pw, pw, pw ); - - QPolygonF p( size ); - - std::memcpy( p.data(), points, size * sizeof( QPointF ) ); - QwtPainter::drawPolyline( painter, - QwtClipper::clippedPolygonF( clipRect, p ) ); - - std::memcpy( p.data(), points + size, size * sizeof( QPointF ) ); - QwtPainter::drawPolyline( painter, - QwtClipper::clippedPolygonF( clipRect, p ) ); - } - else - { - QwtPainter::drawPolyline( painter, points, size ); - QwtPainter::drawPolyline( painter, points + size, size ); - } + QwtPainter::drawPolygon(painter, p); } + else + { + QwtPainter::drawPolygon(painter, polygon); + } + } - painter->restore(); + if (m_data->pen.style() != Qt::NoPen) + { + painter->setPen(m_data->pen); + painter->setBrush(Qt::NoBrush); + + if (m_data->paintAttributes & ClipPolygons) + { + qreal pw = QwtPainter::effectivePenWidth(painter->pen()); + const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw); + + QPolygonF p(size); + + std::memcpy(p.data(), points, size * sizeof(QPointF)); + QwtPainter::drawPolyline(painter, + QwtClipper::clippedPolygonF(clipRect, p)); + + std::memcpy(p.data(), points + size, size * sizeof(QPointF)); + QwtPainter::drawPolyline(painter, + QwtClipper::clippedPolygonF(clipRect, p)); + } + else + { + QwtPainter::drawPolyline(painter, points, size); + QwtPainter::drawPolyline(painter, points + size, size); + } + } + + painter->restore(); } /*! @@ -485,65 +483,62 @@ void QwtPlotIntervalCurve::drawTube( QPainter* painter, \sa setSymbol(), drawSeries(), drawTube() */ void QwtPlotIntervalCurve::drawSymbols( - QPainter* painter, const QwtIntervalSymbol& symbol, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const + QPainter *painter, const QwtIntervalSymbol &symbol, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const { - painter->save(); + painter->save(); - QPen pen = symbol.pen(); - pen.setCapStyle( Qt::FlatCap ); + QPen pen = symbol.pen(); + pen.setCapStyle(Qt::FlatCap); - painter->setPen( pen ); - painter->setBrush( symbol.brush() ); + painter->setPen(pen); + painter->setBrush(symbol.brush()); - const QRectF tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect ); + const QRectF tr = QwtScaleMap::invTransform(xMap, yMap, canvasRect); - const double xMin = tr.left(); - const double xMax = tr.right(); - const double yMin = tr.top(); - const double yMax = tr.bottom(); + const double xMin = tr.left(); + const double xMax = tr.right(); + const double yMin = tr.top(); + const double yMax = tr.bottom(); - const bool doClip = m_data->paintAttributes & ClipSymbol; + const bool doClip = m_data->paintAttributes & ClipSymbol; - for ( int i = from; i <= to; i++ ) + for (int i = from; i <= to; i++) + { + const QwtIntervalSample s = sample(i); + + if (orientation() == Qt::Vertical) { - const QwtIntervalSample s = sample( i ); + if (!doClip || qwtIsVSampleInside(s, xMin, xMax, yMin, yMax)) + { + const double x = xMap.transform(s.value); + const double y1 = yMap.transform(s.interval.minValue()); + const double y2 = yMap.transform(s.interval.maxValue()); - if ( orientation() == Qt::Vertical ) - { - if ( !doClip || qwtIsVSampleInside( s, xMin, xMax, yMin, yMax ) ) - { - const double x = xMap.transform( s.value ); - const double y1 = yMap.transform( s.interval.minValue() ); - const double y2 = yMap.transform( s.interval.maxValue() ); - - symbol.draw( painter, orientation(), - QPointF( x, y1 ), QPointF( x, y2 ) ); - } - } - else - { - if ( !doClip || qwtIsHSampleInside( s, xMin, xMax, yMin, yMax ) ) - { - const double y = yMap.transform( s.value ); - const double x1 = xMap.transform( s.interval.minValue() ); - const double x2 = xMap.transform( s.interval.maxValue() ); - - symbol.draw( painter, orientation(), - QPointF( x1, y ), QPointF( x2, y ) ); - } - } + symbol.draw(painter, orientation(), QPointF(x, y1), QPointF(x, y2)); + } } + else + { + if (!doClip || qwtIsHSampleInside(s, xMin, xMax, yMin, yMax)) + { + const double y = yMap.transform(s.value); + const double x1 = xMap.transform(s.interval.minValue()); + const double x2 = xMap.transform(s.interval.maxValue()); - painter->restore(); + symbol.draw(painter, orientation(), QPointF(x1, y), QPointF(x2, y)); + } + } + } + + painter->restore(); } /*! \return Icon for the legend - In case of Tube style() the icon is a plain rectangle filled with the brush(). - If a symbol is assigned it is scaled to size. + In case of Tube style() the icon is a plain rectangle filled with the + brush(). If a symbol is assigned it is scaled to size. \param index Index of the legend entry ( ignored as there is only one ) @@ -551,53 +546,52 @@ void QwtPlotIntervalCurve::drawSymbols( \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() */ -QwtGraphic QwtPlotIntervalCurve::legendIcon( - int index, const QSizeF& size ) const +QwtGraphic QwtPlotIntervalCurve::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); + Q_UNUSED(index); - if ( size.isEmpty() ) - return QwtGraphic(); + if (size.isEmpty()) + return QwtGraphic(); - QwtGraphic icon; - icon.setDefaultSize( size ); - icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + QwtGraphic icon; + icon.setDefaultSize(size); + icon.setRenderHint(QwtGraphic::RenderPensUnscaled, true); - QPainter painter( &icon ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); + QPainter painter(&icon); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); - if ( m_data->style == Tube ) + if (m_data->style == Tube) + { + QRectF r(0, 0, size.width(), size.height()); + painter.fillRect(r, m_data->brush); + } + + if (m_data->symbol + && (m_data->symbol->style() != QwtIntervalSymbol::NoSymbol)) + { + QPen pen = m_data->symbol->pen(); + pen.setWidthF(pen.widthF()); + pen.setCapStyle(Qt::FlatCap); + + painter.setPen(pen); + painter.setBrush(m_data->symbol->brush()); + + if (orientation() == Qt::Vertical) { - QRectF r( 0, 0, size.width(), size.height() ); - painter.fillRect( r, m_data->brush ); - } + const double x = 0.5 * size.width(); - if ( m_data->symbol && - ( m_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) ) + m_data->symbol->draw(&painter, orientation(), QPointF(x, 0), + QPointF(x, size.height() - 1.0)); + } + else { - QPen pen = m_data->symbol->pen(); - pen.setWidthF( pen.widthF() ); - pen.setCapStyle( Qt::FlatCap ); + const double y = 0.5 * size.height(); - painter.setPen( pen ); - painter.setBrush( m_data->symbol->brush() ); - - if ( orientation() == Qt::Vertical ) - { - const double x = 0.5 * size.width(); - - m_data->symbol->draw( &painter, orientation(), - QPointF( x, 0 ), QPointF( x, size.height() - 1.0 ) ); - } - else - { - const double y = 0.5 * size.height(); - - m_data->symbol->draw( &painter, orientation(), - QPointF( 0.0, y ), QPointF( size.width() - 1.0, y ) ); - } + m_data->symbol->draw(&painter, orientation(), QPointF(0.0, y), + QPointF(size.width() - 1.0, y)); } + } - return icon; + return icon; } diff --git a/libs/qwt/src/qwt_plot_intervalcurve.h b/libs/qwt/src/qwt_plot_intervalcurve.h index db3a8450..bd990477 100644 --- a/libs/qwt/src/qwt_plot_intervalcurve.h +++ b/libs/qwt/src/qwt_plot_intervalcurve.h @@ -14,7 +14,8 @@ #include "qwt_plot_seriesitem.h" class QwtIntervalSymbol; -template< typename T > class QwtSeriesData; +template +class QwtSeriesData; /*! \brief QwtPlotIntervalCurve represents a series of samples, where each value @@ -24,112 +25,108 @@ template< typename T > class QwtSeriesData; that is displayed for each interval. QwtPlotIntervalCurve might be used to display error bars or the area between 2 curves. */ -class QWT_EXPORT QwtPlotIntervalCurve - : public QwtPlotSeriesItem - , public QwtSeriesStore< QwtIntervalSample > +class QWT_EXPORT QwtPlotIntervalCurve : public QwtPlotSeriesItem, + public QwtSeriesStore { - public: +public: + /*! + \brief Curve styles. + The default setting is QwtPlotIntervalCurve::Tube. + + \sa setStyle(), style() + */ + enum CurveStyle + { /*! - \brief Curve styles. - The default setting is QwtPlotIntervalCurve::Tube. - - \sa setStyle(), style() + Don't draw a curve. Note: This doesn't affect the symbols. */ - enum CurveStyle - { - /*! - Don't draw a curve. Note: This doesn't affect the symbols. - */ - NoCurve, - - /*! - Build 2 curves from the upper and lower limits of the intervals - and draw them with the pen(). The area between the curves is - filled with the brush(). - */ - Tube, - - /*! - Styles >= QwtPlotIntervalCurve::UserCurve are reserved for derived - classes that overload drawSeries() with - additional application specific curve types. - */ - UserCurve = 100 - }; + NoCurve, /*! - Attributes to modify the drawing algorithm. - \sa setPaintAttribute(), testPaintAttribute() + Build 2 curves from the upper and lower limits of the intervals + and draw them with the pen(). The area between the curves is + filled with the brush(). */ - enum PaintAttribute - { - /*! - Clip polygons before painting them. In situations, where points - are far outside the visible area (f.e when zooming deep) this - might be a substantial improvement for the painting performance. - */ - ClipPolygons = 0x01, + Tube, - //! Check if a symbol is on the plot canvas before painting it. - ClipSymbol = 0x02 - }; + /*! + Styles >= QwtPlotIntervalCurve::UserCurve are reserved for derived + classes that overload drawSeries() with + additional application specific curve types. + */ + UserCurve = 100 + }; - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + /*! + Attributes to modify the drawing algorithm. + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { + /*! + Clip polygons before painting them. In situations, where points + are far outside the visible area (f.e when zooming deep) this + might be a substantial improvement for the painting performance. + */ + ClipPolygons = 0x01, - explicit QwtPlotIntervalCurve( const QString& title = QString() ); - explicit QwtPlotIntervalCurve( const QwtText& title ); + //! Check if a symbol is on the plot canvas before painting it. + ClipSymbol = 0x02 + }; - virtual ~QwtPlotIntervalCurve(); + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - virtual int rtti() const QWT_OVERRIDE; + explicit QwtPlotIntervalCurve(const QString &title = QString()); + explicit QwtPlotIntervalCurve(const QwtText &title); - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + virtual ~QwtPlotIntervalCurve(); - void setSamples( const QVector< QwtIntervalSample >& ); - void setSamples( QwtSeriesData< QwtIntervalSample >* ); + virtual int rtti() const QWT_OVERRIDE; - void setPen( const QColor&, - qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - void setPen( const QPen& ); - const QPen& pen() const; + void setSamples(const QVector &); + void setSamples(QwtSeriesData *); - void setBrush( const QBrush& ); - const QBrush& brush() const; + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); - void setStyle( CurveStyle style ); - CurveStyle style() const; + void setPen(const QPen &); + const QPen &pen() const; - void setSymbol( const QwtIntervalSymbol* ); - const QwtIntervalSymbol* symbol() const; + void setBrush(const QBrush &); + const QBrush &brush() const; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + void setStyle(CurveStyle style); + CurveStyle style() const; - virtual QRectF boundingRect() const QWT_OVERRIDE; + void setSymbol(const QwtIntervalSymbol *); + const QwtIntervalSymbol *symbol() const; - virtual QwtGraphic legendIcon( - int index, const QSizeF& ) const QWT_OVERRIDE; + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - protected: + virtual QRectF boundingRect() const QWT_OVERRIDE; - void init(); + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - virtual void drawTube( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; +protected: + void init(); - virtual void drawSymbols( QPainter*, const QwtIntervalSymbol&, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + virtual void drawTube(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; - private: - class PrivateData; - PrivateData* m_data; + virtual void drawSymbols(QPainter *, const QwtIntervalSymbol &, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, int to) const; + +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotIntervalCurve::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotIntervalCurve::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_item.cpp b/libs/qwt/src/qwt_plot_item.cpp index 5b9e6358..41e691b0 100644 --- a/libs/qwt/src/qwt_plot_item.cpp +++ b/libs/qwt/src/qwt_plot_item.cpp @@ -18,35 +18,35 @@ class QwtPlotItem::PrivateData { - public: - PrivateData() - : plot( NULL ) - , isVisible( true ) - , renderThreadCount( 1 ) - , z( 0.0 ) - , xAxisId( QwtAxis::XBottom ) - , yAxisId( QwtAxis::YLeft ) - , legendIconSize( 8, 8 ) - { - } +public: + PrivateData() + : plot(NULL) + , isVisible(true) + , renderThreadCount(1) + , z(0.0) + , xAxisId(QwtAxis::XBottom) + , yAxisId(QwtAxis::YLeft) + , legendIconSize(8, 8) + { + } - mutable QwtPlot* plot; + mutable QwtPlot *plot; - bool isVisible; + bool isVisible; - QwtPlotItem::ItemAttributes attributes; - QwtPlotItem::ItemInterests interests; + QwtPlotItem::ItemAttributes attributes; + QwtPlotItem::ItemInterests interests; - QwtPlotItem::RenderHints renderHints; - uint renderThreadCount; + QwtPlotItem::RenderHints renderHints; + uint renderThreadCount; - double z; + double z; - QwtAxisId xAxisId; - QwtAxisId yAxisId; + QwtAxisId xAxisId; + QwtAxisId yAxisId; - QwtText title; - QSize legendIconSize; + QwtText title; + QSize legendIconSize; }; /*! @@ -54,34 +54,34 @@ class QwtPlotItem::PrivateData */ QwtPlotItem::QwtPlotItem() { - m_data = new PrivateData; + m_data = new PrivateData; } /*! Constructor \param title Title of the item */ -QwtPlotItem::QwtPlotItem( const QString& title ) +QwtPlotItem::QwtPlotItem(const QString &title) { - m_data = new PrivateData; - m_data->title = title; + m_data = new PrivateData; + m_data->title = title; } /*! Constructor \param title Title of the item */ -QwtPlotItem::QwtPlotItem( const QwtText& title ) +QwtPlotItem::QwtPlotItem(const QwtText &title) { - m_data = new PrivateData; - m_data->title = title; + m_data = new PrivateData; + m_data->title = title; } //! Destroy the QwtPlotItem QwtPlotItem::~QwtPlotItem() { - attach( NULL ); - delete m_data; + attach(NULL); + delete m_data; } /*! @@ -95,18 +95,18 @@ QwtPlotItem::~QwtPlotItem() \param plot Plot widget \sa detach() */ -void QwtPlotItem::attach( QwtPlot* plot ) +void QwtPlotItem::attach(QwtPlot *plot) { - if ( plot == m_data->plot ) - return; + if (plot == m_data->plot) + return; - if ( m_data->plot ) - m_data->plot->attachItem( this, false ); + if (m_data->plot) + m_data->plot->attachItem(this, false); - m_data->plot = plot; + m_data->plot = plot; - if ( m_data->plot ) - m_data->plot->attachItem( this, true ); + if (m_data->plot) + m_data->plot->attachItem(this, true); } /*! @@ -118,7 +118,7 @@ void QwtPlotItem::attach( QwtPlot* plot ) */ void QwtPlotItem::detach() { - attach( NULL ); + attach(NULL); } /*! @@ -135,13 +135,13 @@ void QwtPlotItem::detach() */ int QwtPlotItem::rtti() const { - return Rtti_PlotItem; + return Rtti_PlotItem; } //! Return attached plot -QwtPlot* QwtPlotItem::plot() const +QwtPlot *QwtPlotItem::plot() const { - return m_data->plot; + return m_data->plot; } /*! @@ -151,7 +151,7 @@ QwtPlot* QwtPlotItem::plot() const */ double QwtPlotItem::z() const { - return m_data->z; + return m_data->z; } /*! @@ -162,20 +162,20 @@ double QwtPlotItem::z() const \param z Z-value \sa z(), QwtPlotDict::itemList() */ -void QwtPlotItem::setZ( double z ) +void QwtPlotItem::setZ(double z) { - if ( m_data->z != z ) - { - if ( m_data->plot ) // update the z order - m_data->plot->attachItem( this, false ); + if (m_data->z != z) + { + if (m_data->plot) // update the z order + m_data->plot->attachItem(this, false); - m_data->z = z; + m_data->z = z; - if ( m_data->plot ) - m_data->plot->attachItem( this, true ); + if (m_data->plot) + m_data->plot->attachItem(this, true); - itemChanged(); - } + itemChanged(); + } } /*! @@ -184,9 +184,9 @@ void QwtPlotItem::setZ( double z ) \param title Title \sa title() */ -void QwtPlotItem::setTitle( const QString& title ) +void QwtPlotItem::setTitle(const QString &title) { - setTitle( QwtText( title ) ); + setTitle(QwtText(title)); } /*! @@ -195,26 +195,26 @@ void QwtPlotItem::setTitle( const QString& title ) \param title Title \sa title() */ -void QwtPlotItem::setTitle( const QwtText& title ) +void QwtPlotItem::setTitle(const QwtText &title) { - if ( m_data->title != title ) - { - m_data->title = title; + if (m_data->title != title) + { + m_data->title = title; - legendChanged(); + legendChanged(); #if 0 itemChanged(); #endif - } + } } /*! \return Title of the item \sa setTitle() */ -const QwtText& QwtPlotItem::title() const +const QwtText &QwtPlotItem::title() const { - return m_data->title; + return m_data->title; } /*! @@ -225,35 +225,35 @@ const QwtText& QwtPlotItem::title() const \sa testItemAttribute(), ItemInterest */ -void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on ) +void QwtPlotItem::setItemAttribute(ItemAttribute attribute, bool on) { - if ( m_data->attributes.testFlag( attribute ) != on ) + if (m_data->attributes.testFlag(attribute) != on) + { + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; + + if (attribute == QwtPlotItem::Legend) { - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; - - if ( attribute == QwtPlotItem::Legend ) - { - if ( on ) - { - legendChanged(); - } - else - { - /* - In the special case of taking an item from - the legend we can't use legendChanged() as - it depends on QwtPlotItem::Legend being enabled - */ - if ( m_data->plot ) - m_data->plot->updateLegend( this ); - } - } - - itemChanged(); + if (on) + { + legendChanged(); + } + else + { + /* + In the special case of taking an item from + the legend we can't use legendChanged() as + it depends on QwtPlotItem::Legend being enabled + */ + if (m_data->plot) + m_data->plot->updateLegend(this); + } } + + itemChanged(); + } } /*! @@ -263,9 +263,9 @@ void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on ) \return true/false \sa setItemAttribute(), ItemInterest */ -bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const +bool QwtPlotItem::testItemAttribute(ItemAttribute attribute) const { - return m_data->attributes.testFlag( attribute ); + return m_data->attributes.testFlag(attribute); } /*! @@ -276,17 +276,17 @@ bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const \sa testItemInterest(), ItemAttribute */ -void QwtPlotItem::setItemInterest( ItemInterest interest, bool on ) +void QwtPlotItem::setItemInterest(ItemInterest interest, bool on) { - if ( m_data->interests.testFlag( interest ) != on ) - { - if ( on ) - m_data->interests |= interest; - else - m_data->interests &= ~interest; + if (m_data->interests.testFlag(interest) != on) + { + if (on) + m_data->interests |= interest; + else + m_data->interests &= ~interest; - itemChanged(); - } + itemChanged(); + } } /*! @@ -296,9 +296,9 @@ void QwtPlotItem::setItemInterest( ItemInterest interest, bool on ) \return true/false \sa setItemInterest(), ItemAttribute */ -bool QwtPlotItem::testItemInterest( ItemInterest interest ) const +bool QwtPlotItem::testItemInterest(ItemInterest interest) const { - return m_data->interests.testFlag( interest ); + return m_data->interests.testFlag(interest); } /*! @@ -309,17 +309,17 @@ bool QwtPlotItem::testItemInterest( ItemInterest interest ) const \sa testRenderHint(), RenderHint */ -void QwtPlotItem::setRenderHint( RenderHint hint, bool on ) +void QwtPlotItem::setRenderHint(RenderHint hint, bool on) { - if ( m_data->renderHints.testFlag( hint ) != on ) - { - if ( on ) - m_data->renderHints |= hint; - else - m_data->renderHints &= ~hint; + if (m_data->renderHints.testFlag(hint) != on) + { + if (on) + m_data->renderHints |= hint; + else + m_data->renderHints &= ~hint; - itemChanged(); - } + itemChanged(); + } } /*! @@ -329,9 +329,9 @@ void QwtPlotItem::setRenderHint( RenderHint hint, bool on ) \return true/false \sa setRenderHint(), RenderHint */ -bool QwtPlotItem::testRenderHint( RenderHint hint ) const +bool QwtPlotItem::testRenderHint(RenderHint hint) const { - return m_data->renderHints.testFlag( hint ); + return m_data->renderHints.testFlag(hint); } /*! @@ -347,9 +347,9 @@ bool QwtPlotItem::testRenderHint( RenderHint hint ) const The default thread count is 1 ( = no additional threads ) */ -void QwtPlotItem::setRenderThreadCount( uint numThreads ) +void QwtPlotItem::setRenderThreadCount(uint numThreads) { - m_data->renderThreadCount = numThreads; + m_data->renderThreadCount = numThreads; } /*! @@ -359,7 +359,7 @@ void QwtPlotItem::setRenderThreadCount( uint numThreads ) */ uint QwtPlotItem::renderThreadCount() const { - return m_data->renderThreadCount; + return m_data->renderThreadCount; } /*! @@ -370,13 +370,13 @@ uint QwtPlotItem::renderThreadCount() const \param size Size \sa legendIconSize(), legendIcon() */ -void QwtPlotItem::setLegendIconSize( const QSize& size ) +void QwtPlotItem::setLegendIconSize(const QSize &size) { - if ( m_data->legendIconSize != size ) - { - m_data->legendIconSize = size; - legendChanged(); - } + if (m_data->legendIconSize != size) + { + m_data->legendIconSize = size; + legendChanged(); + } } /*! @@ -385,7 +385,7 @@ void QwtPlotItem::setLegendIconSize( const QSize& size ) */ QSize QwtPlotItem::legendIconSize() const { - return m_data->legendIconSize; + return m_data->legendIconSize; } /*! @@ -399,13 +399,12 @@ QSize QwtPlotItem::legendIconSize() const \sa setLegendIconSize(), legendData() */ -QwtGraphic QwtPlotItem::legendIcon( - int index, const QSizeF& size ) const +QwtGraphic QwtPlotItem::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ) - Q_UNUSED( size ) + Q_UNUSED(index) + Q_UNUSED(size) - return QwtGraphic(); + return QwtGraphic(); } /*! @@ -419,33 +418,33 @@ QwtGraphic QwtPlotItem::legendIcon( \return A filled rectangle */ -QwtGraphic QwtPlotItem::defaultIcon( - const QBrush& brush, const QSizeF& size ) const +QwtGraphic QwtPlotItem::defaultIcon(const QBrush &brush, + const QSizeF &size) const { - QwtGraphic icon; - if ( !size.isEmpty() ) - { - icon.setDefaultSize( size ); + QwtGraphic icon; + if (!size.isEmpty()) + { + icon.setDefaultSize(size); - QRectF r( 0, 0, size.width(), size.height() ); + QRectF r(0, 0, size.width(), size.height()); - QPainter painter( &icon ); - painter.fillRect( r, brush ); - } + QPainter painter(&icon); + painter.fillRect(r, brush); + } - return icon; + return icon; } //! Show the item void QwtPlotItem::show() { - setVisible( true ); + setVisible(true); } //! Hide the item void QwtPlotItem::hide() { - setVisible( false ); + setVisible(false); } /*! @@ -454,13 +453,13 @@ void QwtPlotItem::hide() \param on Show if true, otherwise hide \sa isVisible(), show(), hide() */ -void QwtPlotItem::setVisible( bool on ) +void QwtPlotItem::setVisible(bool on) { - if ( on != m_data->isVisible ) - { - m_data->isVisible = on; - itemChanged(); - } + if (on != m_data->isVisible) + { + m_data->isVisible = on; + itemChanged(); + } } /*! @@ -469,7 +468,7 @@ void QwtPlotItem::setVisible( bool on ) */ bool QwtPlotItem::isVisible() const { - return m_data->isVisible; + return m_data->isVisible; } /*! @@ -480,8 +479,8 @@ bool QwtPlotItem::isVisible() const */ void QwtPlotItem::itemChanged() { - if ( m_data->plot ) - m_data->plot->autoRefresh(); + if (m_data->plot) + m_data->plot->autoRefresh(); } /*! @@ -490,8 +489,8 @@ void QwtPlotItem::itemChanged() */ void QwtPlotItem::legendChanged() { - if ( testItemAttribute( QwtPlotItem::Legend ) && m_data->plot ) - m_data->plot->updateLegend( this ); + if (testItemAttribute(QwtPlotItem::Legend) && m_data->plot) + m_data->plot->updateLegend(this); } /*! @@ -504,15 +503,15 @@ void QwtPlotItem::legendChanged() \sa setXAxis(), setYAxis(), xAxis(), yAxis() */ -void QwtPlotItem::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ) +void QwtPlotItem::setAxes(QwtAxisId xAxisId, QwtAxisId yAxisId) { - if ( QwtAxis::isXAxis( xAxisId ) ) - m_data->xAxisId = xAxisId; + if (QwtAxis::isXAxis(xAxisId)) + m_data->xAxisId = xAxisId; - if ( QwtAxis::isYAxis( yAxisId ) ) - m_data->yAxisId = yAxisId; + if (QwtAxis::isYAxis(yAxisId)) + m_data->yAxisId = yAxisId; - itemChanged(); + itemChanged(); } /*! @@ -523,13 +522,13 @@ void QwtPlotItem::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ) \param axisId X Axis \sa setAxes(), setYAxis(), xAxis() */ -void QwtPlotItem::setXAxis( QwtAxisId axisId ) +void QwtPlotItem::setXAxis(QwtAxisId axisId) { - if ( QwtAxis::isXAxis( axisId ) ) - { - m_data->xAxisId = axisId; - itemChanged(); - } + if (QwtAxis::isXAxis(axisId)) + { + m_data->xAxisId = axisId; + itemChanged(); + } } /*! @@ -540,25 +539,25 @@ void QwtPlotItem::setXAxis( QwtAxisId axisId ) \param axisId Y Axis \sa setAxes(), setXAxis(), yAxis() */ -void QwtPlotItem::setYAxis( QwtAxisId axisId ) +void QwtPlotItem::setYAxis(QwtAxisId axisId) { - if ( QwtAxis::isYAxis( axisId ) ) - { - m_data->yAxisId = axisId; - itemChanged(); - } + if (QwtAxis::isYAxis(axisId)) + { + m_data->yAxisId = axisId; + itemChanged(); + } } //! Return xAxis QwtAxisId QwtPlotItem::xAxis() const { - return m_data->xAxisId; + return m_data->xAxisId; } //! Return yAxis QwtAxisId QwtPlotItem::yAxis() const { - return m_data->yAxisId; + return m_data->yAxisId; } /*! @@ -567,7 +566,7 @@ QwtAxisId QwtPlotItem::yAxis() const */ QRectF QwtPlotItem::boundingRect() const { - return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid + return QRectF(1.0, 1.0, -2.0, -2.0); // invalid } /*! @@ -592,16 +591,18 @@ QRectF QwtPlotItem::boundingRect() const \sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins() */ -void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QRectF& canvasRect, - double& left, double& top, double& right, double& bottom ) const +void QwtPlotItem::getCanvasMarginHint(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, double &left, + double &top, double &right, + double &bottom) const { - Q_UNUSED( xMap ); - Q_UNUSED( yMap ); - Q_UNUSED( canvasRect ); + Q_UNUSED(xMap); + Q_UNUSED(yMap); + Q_UNUSED(canvasRect); - // use QMargins, when we don't need to support Qt < 4.6 anymore - left = top = right = bottom = 0.0; + // use QMargins, when we don't need to support Qt < 4.6 anymore + left = top = right = bottom = 0.0; } /*! @@ -623,27 +624,25 @@ void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap& xMap, \return Data, that is needed to represent the item on the legend \sa title(), legendIcon(), QwtLegend, QwtPlotLegendItem */ -QList< QwtLegendData > QwtPlotItem::legendData() const +QList QwtPlotItem::legendData() const { - QwtLegendData data; + QwtLegendData data; - QwtText label = title(); - label.setRenderFlags( label.renderFlags() & Qt::AlignLeft ); + QwtText label = title(); + label.setRenderFlags(label.renderFlags() & Qt::AlignLeft); - data.setValue( QwtLegendData::TitleRole, - QVariant::fromValue( label ) ); + data.setValue(QwtLegendData::TitleRole, QVariant::fromValue(label)); - const QwtGraphic graphic = legendIcon( 0, legendIconSize() ); - if ( !graphic.isNull() ) - { - data.setValue( QwtLegendData::IconRole, - QVariant::fromValue( graphic ) ); - } + const QwtGraphic graphic = legendIcon(0, legendIconSize()); + if (!graphic.isNull()) + { + data.setValue(QwtLegendData::IconRole, QVariant::fromValue(graphic)); + } - QList< QwtLegendData > list; - list += data; + QList list; + list += data; - return list; + return list; } /*! @@ -662,11 +661,11 @@ QList< QwtLegendData > QwtPlotItem::legendData() const \sa QwtPlot::updateAxes(), ScaleInterest */ -void QwtPlotItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv, - const QwtScaleDiv& yScaleDiv ) +void QwtPlotItem::updateScaleDiv(const QwtScaleDiv &xScaleDiv, + const QwtScaleDiv &yScaleDiv) { - Q_UNUSED( xScaleDiv ); - Q_UNUSED( yScaleDiv ); + Q_UNUSED(xScaleDiv); + Q_UNUSED(yScaleDiv); } /*! @@ -687,11 +686,11 @@ void QwtPlotItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv, need to enable the QwtPlotItem::Legend flag and to implement legendData() and legendIcon() */ -void QwtPlotItem::updateLegend( const QwtPlotItem* item, - const QList< QwtLegendData >& data ) +void QwtPlotItem::updateLegend(const QwtPlotItem *item, + const QList &data) { - Q_UNUSED( item ); - Q_UNUSED( data ); + Q_UNUSED(item); + Q_UNUSED(data); } /*! @@ -702,11 +701,10 @@ void QwtPlotItem::updateLegend( const QwtPlotItem* item, \return Bounding scale rect of the scale maps, not normalized */ -QRectF QwtPlotItem::scaleRect( const QwtScaleMap& xMap, - const QwtScaleMap& yMap ) const +QRectF QwtPlotItem::scaleRect(const QwtScaleMap &xMap, + const QwtScaleMap &yMap) const { - return QRectF( xMap.s1(), yMap.s1(), - xMap.sDist(), yMap.sDist() ); + return QRectF(xMap.s1(), yMap.s1(), xMap.sDist(), yMap.sDist()); } /*! @@ -717,11 +715,10 @@ QRectF QwtPlotItem::scaleRect( const QwtScaleMap& xMap, \return Bounding paint rectangle of the scale maps, not normalized */ -QRectF QwtPlotItem::paintRect( const QwtScaleMap& xMap, - const QwtScaleMap& yMap ) const +QRectF QwtPlotItem::paintRect(const QwtScaleMap &xMap, + const QwtScaleMap &yMap) const { - const QRectF rect( xMap.p1(), yMap.p1(), - xMap.pDist(), yMap.pDist() ); + const QRectF rect(xMap.p1(), yMap.p1(), xMap.pDist(), yMap.pDist()); - return rect; + return rect; } diff --git a/libs/qwt/src/qwt_plot_item.h b/libs/qwt/src/qwt_plot_item.h index baeb5fed..d3fcf335 100644 --- a/libs/qwt/src/qwt_plot_item.h +++ b/libs/qwt/src/qwt_plot_item.h @@ -23,7 +23,8 @@ class QwtLegendData; class QRectF; class QPainter; class QString; -template< typename T > class QList; +template +class QList; /*! \brief Base class for items on the plot canvas @@ -65,246 +66,245 @@ template< typename T > class QList; class QWT_EXPORT QwtPlotItem { - public: - /*! - \brief Runtime type information +public: + /*! + \brief Runtime type information - RttiValues is used to cast plot items, without - having to enable runtime type information of the compiler. - */ - enum RttiValues - { - //! Unspecific value, that can be used, when it doesn't matter - Rtti_PlotItem = 0, + RttiValues is used to cast plot items, without + having to enable runtime type information of the compiler. + */ + enum RttiValues + { + //! Unspecific value, that can be used, when it doesn't matter + Rtti_PlotItem = 0, - //! For QwtPlotGrid - Rtti_PlotGrid, + //! For QwtPlotGrid + Rtti_PlotGrid, - //! For QwtPlotScaleItem - Rtti_PlotScale, + //! For QwtPlotScaleItem + Rtti_PlotScale, - //! For QwtPlotLegendItem - Rtti_PlotLegend, + //! For QwtPlotLegendItem + Rtti_PlotLegend, - //! For QwtPlotMarker - Rtti_PlotMarker, + //! For QwtPlotMarker + Rtti_PlotMarker, - //! For QwtPlotCurve - Rtti_PlotCurve, + //! For QwtPlotCurve + Rtti_PlotCurve, - //! For QwtPlotSpectroCurve - Rtti_PlotSpectroCurve, + //! For QwtPlotSpectroCurve + Rtti_PlotSpectroCurve, - //! For QwtPlotIntervalCurve - Rtti_PlotIntervalCurve, + //! For QwtPlotIntervalCurve + Rtti_PlotIntervalCurve, - //! For QwtPlotHistogram - Rtti_PlotHistogram, + //! For QwtPlotHistogram + Rtti_PlotHistogram, - //! For QwtPlotSpectrogram - Rtti_PlotSpectrogram, + //! For QwtPlotSpectrogram + Rtti_PlotSpectrogram, - //! For QwtPlotGraphicItem, QwtPlotSvgItem - Rtti_PlotGraphic, + //! For QwtPlotGraphicItem, QwtPlotSvgItem + Rtti_PlotGraphic, - //! For QwtPlotTradingCurve - Rtti_PlotTradingCurve, + //! For QwtPlotTradingCurve + Rtti_PlotTradingCurve, - //! For QwtPlotBarChart - Rtti_PlotBarChart, + //! For QwtPlotBarChart + Rtti_PlotBarChart, - //! For QwtPlotMultiBarChart - Rtti_PlotMultiBarChart, + //! For QwtPlotMultiBarChart + Rtti_PlotMultiBarChart, - //! For QwtPlotShapeItem - Rtti_PlotShape, + //! For QwtPlotShapeItem + Rtti_PlotShape, - //! For QwtPlotTextLabel - Rtti_PlotTextLabel, + //! For QwtPlotTextLabel + Rtti_PlotTextLabel, - //! For QwtPlotZoneItem - Rtti_PlotZone, + //! For QwtPlotZoneItem + Rtti_PlotZone, - //! For QwtPlotVectorField - Rtti_PlotVectorField, - - /*! - Values >= Rtti_PlotUserItem are reserved for plot items - not implemented in the Qwt library. - */ - Rtti_PlotUserItem = 1000 - }; + //! For QwtPlotVectorField + Rtti_PlotVectorField, /*! - \brief Plot Item Attributes - - Various aspects of a plot widget depend on the attributes of - the attached plot items. If and how a single plot item - participates in these updates depends on its attributes. - - \sa setItemAttribute(), testItemAttribute(), ItemInterest + Values >= Rtti_PlotUserItem are reserved for plot items + not implemented in the Qwt library. */ - enum ItemAttribute - { - //! The item is represented on the legend. - Legend = 0x01, + Rtti_PlotUserItem = 1000 + }; - /*! - The boundingRect() of the item is included in the - autoscaling calculation as long as its width or height - is >= 0.0. - */ - AutoScale = 0x02, + /*! + \brief Plot Item Attributes - /*! - The item needs extra space to display something outside - its bounding rectangle. - \sa getCanvasMarginHint() - */ - Margins = 0x04 - }; + Various aspects of a plot widget depend on the attributes of + the attached plot items. If and how a single plot item + participates in these updates depends on its attributes. - Q_DECLARE_FLAGS( ItemAttributes, ItemAttribute ) + \sa setItemAttribute(), testItemAttribute(), ItemInterest + */ + enum ItemAttribute + { + //! The item is represented on the legend. + Legend = 0x01, /*! - \brief Plot Item Interests - - Plot items might depend on the situation of the corresponding - plot widget. By enabling an interest the plot item will be - notified, when the corresponding attribute of the plot widgets - has changed. - - \sa setItemAttribute(), testItemAttribute(), ItemInterest + The boundingRect() of the item is included in the + autoscaling calculation as long as its width or height + is >= 0.0. */ - enum ItemInterest - { - /*! - The item is interested in updates of the scales - \sa updateScaleDiv() - */ - ScaleInterest = 0x01, - - /*! - The item is interested in updates of the legend ( of other items ) - This flag is intended for items, that want to implement a legend - for displaying entries of other plot item. - - \note If the plot item wants to be represented on a legend - enable QwtPlotItem::Legend instead. - - \sa updateLegend() - */ - LegendInterest = 0x02 - }; - - Q_DECLARE_FLAGS( ItemInterests, ItemInterest ) - - //! Render hints - enum RenderHint - { - //! Enable antialiasing - RenderAntialiased = 0x1 - }; - - Q_DECLARE_FLAGS( RenderHints, RenderHint ) - - explicit QwtPlotItem(); - explicit QwtPlotItem( const QString& title ); - explicit QwtPlotItem( const QwtText& title ); - - virtual ~QwtPlotItem(); - - void attach( QwtPlot* plot ); - void detach(); - - QwtPlot* plot() const; - - void setTitle( const QString& title ); - void setTitle( const QwtText& title ); - const QwtText& title() const; - - virtual int rtti() const; - - void setItemAttribute( ItemAttribute, bool on = true ); - bool testItemAttribute( ItemAttribute ) const; - - void setItemInterest( ItemInterest, bool on = true ); - bool testItemInterest( ItemInterest ) const; - - void setRenderHint( RenderHint, bool on = true ); - bool testRenderHint( RenderHint ) const; - - void setRenderThreadCount( uint numThreads ); - uint renderThreadCount() const; - - void setLegendIconSize( const QSize& ); - QSize legendIconSize() const; - - double z() const; - void setZ( double z ); - - void show(); - void hide(); - virtual void setVisible( bool ); - bool isVisible () const; - - void setAxes( QwtAxisId xAxis, QwtAxisId yAxis ); - - void setXAxis( QwtAxisId ); - QwtAxisId xAxis() const; - - void setYAxis( QwtAxisId ); - QwtAxisId yAxis() const; - - virtual void itemChanged(); - virtual void legendChanged(); + AutoScale = 0x02, /*! - \brief Draw the item - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas in painter coordinates + The item needs extra space to display something outside + its bounding rectangle. + \sa getCanvasMarginHint() */ - virtual void draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const = 0; + Margins = 0x04 + }; - virtual QRectF boundingRect() const; + Q_DECLARE_FLAGS(ItemAttributes, ItemAttribute) - virtual void getCanvasMarginHint( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, - double& left, double& top, double& right, double& bottom) const; + /*! + \brief Plot Item Interests - virtual void updateScaleDiv( - const QwtScaleDiv&, const QwtScaleDiv& ); + Plot items might depend on the situation of the corresponding + plot widget. By enabling an interest the plot item will be + notified, when the corresponding attribute of the plot widgets + has changed. - virtual void updateLegend( const QwtPlotItem*, - const QList< QwtLegendData >& ); + \sa setItemAttribute(), testItemAttribute(), ItemInterest + */ + enum ItemInterest + { + /*! + The item is interested in updates of the scales + \sa updateScaleDiv() + */ + ScaleInterest = 0x01, - QRectF scaleRect( const QwtScaleMap&, const QwtScaleMap& ) const; - QRectF paintRect( const QwtScaleMap&, const QwtScaleMap& ) const; + /*! + The item is interested in updates of the legend ( of other items ) + This flag is intended for items, that want to implement a legend + for displaying entries of other plot item. - virtual QList< QwtLegendData > legendData() const; + \note If the plot item wants to be represented on a legend + enable QwtPlotItem::Legend instead. - virtual QwtGraphic legendIcon( int index, const QSizeF& ) const; + \sa updateLegend() + */ + LegendInterest = 0x02 + }; - protected: - QwtGraphic defaultIcon( const QBrush&, const QSizeF& ) const; + Q_DECLARE_FLAGS(ItemInterests, ItemInterest) - private: - Q_DISABLE_COPY(QwtPlotItem) + //! Render hints + enum RenderHint + { + //! Enable antialiasing + RenderAntialiased = 0x1 + }; - class PrivateData; - PrivateData* m_data; + Q_DECLARE_FLAGS(RenderHints, RenderHint) + + explicit QwtPlotItem(); + explicit QwtPlotItem(const QString &title); + explicit QwtPlotItem(const QwtText &title); + + virtual ~QwtPlotItem(); + + void attach(QwtPlot *plot); + void detach(); + + QwtPlot *plot() const; + + void setTitle(const QString &title); + void setTitle(const QwtText &title); + const QwtText &title() const; + + virtual int rtti() const; + + void setItemAttribute(ItemAttribute, bool on = true); + bool testItemAttribute(ItemAttribute) const; + + void setItemInterest(ItemInterest, bool on = true); + bool testItemInterest(ItemInterest) const; + + void setRenderHint(RenderHint, bool on = true); + bool testRenderHint(RenderHint) const; + + void setRenderThreadCount(uint numThreads); + uint renderThreadCount() const; + + void setLegendIconSize(const QSize &); + QSize legendIconSize() const; + + double z() const; + void setZ(double z); + + void show(); + void hide(); + virtual void setVisible(bool); + bool isVisible() const; + + void setAxes(QwtAxisId xAxis, QwtAxisId yAxis); + + void setXAxis(QwtAxisId); + QwtAxisId xAxis() const; + + void setYAxis(QwtAxisId); + QwtAxisId yAxis() const; + + virtual void itemChanged(); + virtual void legendChanged(); + + /*! + \brief Draw the item + + \param painter Painter + \param xMap Maps x-values into pixel coordinates. + \param yMap Maps y-values into pixel coordinates. + \param canvasRect Contents rect of the canvas in painter coordinates + */ + virtual void draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect) const + = 0; + + virtual QRectF boundingRect() const; + + virtual void getCanvasMarginHint(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, double &left, + double &top, double &right, + double &bottom) const; + + virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &); + + virtual void updateLegend(const QwtPlotItem *, const QList &); + + QRectF scaleRect(const QwtScaleMap &, const QwtScaleMap &) const; + QRectF paintRect(const QwtScaleMap &, const QwtScaleMap &) const; + + virtual QList legendData() const; + + virtual QwtGraphic legendIcon(int index, const QSizeF &) const; + +protected: + QwtGraphic defaultIcon(const QBrush &, const QSizeF &) const; + +private: + Q_DISABLE_COPY(QwtPlotItem) + + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotItem::ItemAttributes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotItem::ItemInterests) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotItem::RenderHints) -Q_DECLARE_METATYPE( QwtPlotItem* ) +Q_DECLARE_METATYPE(QwtPlotItem *) #endif diff --git a/libs/qwt/src/qwt_plot_layout.cpp b/libs/qwt/src/qwt_plot_layout.cpp index 09ab3818..cd680b63 100644 --- a/libs/qwt/src/qwt_plot_layout.cpp +++ b/libs/qwt/src/qwt_plot_layout.cpp @@ -18,1015 +18,984 @@ namespace { - class LayoutData +class LayoutData +{ +public: + struct LegendData + { + void init(const QwtAbstractLegend *legend) { - public: - struct LegendData - { - void init( const QwtAbstractLegend* legend ) - { - if ( legend ) - { - frameWidth = legend->frameWidth(); - hScrollExtent = legend->scrollExtent( Qt::Horizontal ); - vScrollExtent = legend->scrollExtent( Qt::Vertical ); + if (legend) + { + frameWidth = legend->frameWidth(); + hScrollExtent = legend->scrollExtent(Qt::Horizontal); + vScrollExtent = legend->scrollExtent(Qt::Vertical); - hint = legend->sizeHint(); - } - } - - QSize legendHint( const QwtAbstractLegend* legend, const QRectF& rect ) const - { - const int w = qMin( hint.width(), qwtFloor( rect.width() ) ); - - int h = legend->heightForWidth( w ); - if ( h <= 0 ) - h = hint.height(); - - return QSize( w, h ); - } - - int frameWidth; - int hScrollExtent; - int vScrollExtent; - QSize hint; - }; - - struct LabelData - { - void init( const QwtTextLabel* label ) - { - frameWidth = 0; - text = QwtText(); - - if ( label ) - { - text = label->text(); - if ( !( text.testPaintAttribute( QwtText::PaintUsingTextFont ) ) ) - text.setFont( label->font() ); - - frameWidth = label->frameWidth(); - } - } - - QwtText text; - int frameWidth; - }; - - struct ScaleData - { - void init( const QwtScaleWidget* axisWidget ) - { - isVisible = true; - - scaleWidget = axisWidget; - scaleFont = axisWidget->font(); - - start = axisWidget->startBorderDist(); - end = axisWidget->endBorderDist(); - - baseLineOffset = axisWidget->margin(); - - tickOffset = axisWidget->margin(); - if ( axisWidget->scaleDraw()->hasComponent( QwtAbstractScaleDraw::Ticks ) ) - tickOffset += axisWidget->scaleDraw()->maxTickLength(); - - dimWithoutTitle = axisWidget->dimForLength( QWIDGETSIZE_MAX, scaleFont ); - if ( !axisWidget->title().isEmpty() ) - dimWithoutTitle -= axisWidget->titleHeightForWidth( QWIDGETSIZE_MAX ); - } - - void reset() - { - isVisible = false; - start = 0; - end = 0; - baseLineOffset = 0; - tickOffset = 0.0; - dimWithoutTitle = 0; - } - - bool isVisible; - const QwtScaleWidget* scaleWidget; - QFont scaleFont; - int start; - int end; - int baseLineOffset; - double tickOffset; - int dimWithoutTitle; - }; - - struct CanvasData - { - void init( const QWidget* canvas ) - { - const QMargins m = canvas->contentsMargins(); - - contentsMargins[ QwtAxis::YLeft ] = m.left(); - contentsMargins[ QwtAxis::XTop ] = m.top(); - contentsMargins[ QwtAxis::YRight ] = m.right(); - contentsMargins[ QwtAxis::XBottom ] = m.bottom(); - } - - int contentsMargins[ QwtAxis::AxisPositions ]; - }; - - public: - enum Label - { - Title, - Footer, - - NumLabels - }; - - LayoutData( const QwtPlot* ); - bool hasSymmetricYAxes() const; - - inline ScaleData& axisData( QwtAxisId axisId ) - { - return m_scaleData[ axisId ]; - } - - inline const ScaleData& axisData( QwtAxisId axisId ) const - { - return m_scaleData[ axisId ]; - } - - inline double tickOffset( int axisPos ) const - { - return axisData( axisPos ).tickOffset; - } - - LegendData legendData; - LabelData labelData[ NumLabels ]; - CanvasData canvasData; - - private: - ScaleData m_scaleData[ QwtAxis::AxisPositions ]; - }; - - /* - Extract all layout relevant data from the plot components - */ - LayoutData::LayoutData( const QwtPlot* plot ) - { - legendData.init( plot->legend() ); - labelData[ Title ].init( plot->titleLabel() ); - labelData[ Footer ].init( plot->footerLabel() ); - - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - { - const QwtAxisId axisId( axisPos ); - - ScaleData& scaleData = axisData( axisId ); - - if ( plot->isAxisVisible( axisId ) ) - { - const QwtScaleWidget* scaleWidget = plot->axisWidget( axisId ); - scaleData.init( scaleWidget ); - } - else - { - scaleData.reset(); - } - } - } - - canvasData.init( plot->canvas() ); + hint = legend->sizeHint(); + } } - bool LayoutData::hasSymmetricYAxes() const + QSize legendHint(const QwtAbstractLegend *legend, const QRectF &rect) const { - using namespace QwtAxis; - return m_scaleData[ YLeft ].isVisible == m_scaleData[ YRight ].isVisible; + const int w = qMin(hint.width(), qwtFloor(rect.width())); + + int h = legend->heightForWidth(w); + if (h <= 0) + h = hint.height(); + + return QSize(w, h); } + + int frameWidth; + int hScrollExtent; + int vScrollExtent; + QSize hint; + }; + + struct LabelData + { + void init(const QwtTextLabel *label) + { + frameWidth = 0; + text = QwtText(); + + if (label) + { + text = label->text(); + if (!(text.testPaintAttribute(QwtText::PaintUsingTextFont))) + text.setFont(label->font()); + + frameWidth = label->frameWidth(); + } + } + + QwtText text; + int frameWidth; + }; + + struct ScaleData + { + void init(const QwtScaleWidget *axisWidget) + { + isVisible = true; + + scaleWidget = axisWidget; + scaleFont = axisWidget->font(); + + start = axisWidget->startBorderDist(); + end = axisWidget->endBorderDist(); + + baseLineOffset = axisWidget->margin(); + + tickOffset = axisWidget->margin(); + if (axisWidget->scaleDraw()->hasComponent(QwtAbstractScaleDraw::Ticks)) + tickOffset += axisWidget->scaleDraw()->maxTickLength(); + + dimWithoutTitle = axisWidget->dimForLength(QWIDGETSIZE_MAX, scaleFont); + if (!axisWidget->title().isEmpty()) + dimWithoutTitle -= axisWidget->titleHeightForWidth(QWIDGETSIZE_MAX); + } + + void reset() + { + isVisible = false; + start = 0; + end = 0; + baseLineOffset = 0; + tickOffset = 0.0; + dimWithoutTitle = 0; + } + + bool isVisible; + const QwtScaleWidget *scaleWidget; + QFont scaleFont; + int start; + int end; + int baseLineOffset; + double tickOffset; + int dimWithoutTitle; + }; + + struct CanvasData + { + void init(const QWidget *canvas) + { + const QMargins m = canvas->contentsMargins(); + + contentsMargins[QwtAxis::YLeft] = m.left(); + contentsMargins[QwtAxis::XTop] = m.top(); + contentsMargins[QwtAxis::YRight] = m.right(); + contentsMargins[QwtAxis::XBottom] = m.bottom(); + } + + int contentsMargins[QwtAxis::AxisPositions]; + }; + +public: + enum Label + { + Title, + Footer, + + NumLabels + }; + + LayoutData(const QwtPlot *); + bool hasSymmetricYAxes() const; + + inline ScaleData &axisData(QwtAxisId axisId) { return m_scaleData[axisId]; } + + inline const ScaleData &axisData(QwtAxisId axisId) const + { + return m_scaleData[axisId]; + } + + inline double tickOffset(int axisPos) const + { + return axisData(axisPos).tickOffset; + } + + LegendData legendData; + LabelData labelData[NumLabels]; + CanvasData canvasData; + +private: + ScaleData m_scaleData[QwtAxis::AxisPositions]; +}; + +/* + Extract all layout relevant data from the plot components + */ +LayoutData::LayoutData(const QwtPlot *plot) +{ + legendData.init(plot->legend()); + labelData[Title].init(plot->titleLabel()); + labelData[Footer].init(plot->footerLabel()); + + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { + { + const QwtAxisId axisId(axisPos); + + ScaleData &scaleData = axisData(axisId); + + if (plot->isAxisVisible(axisId)) + { + const QwtScaleWidget *scaleWidget = plot->axisWidget(axisId); + scaleData.init(scaleWidget); + } + else + { + scaleData.reset(); + } + } + } + + canvasData.init(plot->canvas()); } +bool LayoutData::hasSymmetricYAxes() const +{ + using namespace QwtAxis; + return m_scaleData[YLeft].isVisible == m_scaleData[YRight].isVisible; +} +} // namespace + namespace { - class LayoutHintData +class LayoutHintData +{ +public: + LayoutHintData(const QwtPlot *plot); + + int alignedSize(const QwtAxisId) const; + + inline int yAxesWidth() const + { + using namespace QwtAxis; + return axesWidth(YLeft) + axesWidth(YRight); + } + + inline int yAxesHeight() const + { + using namespace QwtAxis; + return qMax(axesHeight(YLeft), axesHeight(YRight)); + } + + inline int xAxesHeight() const + { + using namespace QwtAxis; + return axesHeight(XTop) + axesHeight(XBottom); + } + + inline int xAxesWidth() const + { + using namespace QwtAxis; + return qMax(axesWidth(XTop), axesWidth(XBottom)); + } + +private: + struct ScaleData + { + ScaleData() { w = h = minLeft = minRight = tickOffset = 0; } + + int w; + int h; + int minLeft; + int minRight; + int tickOffset; + }; + + const ScaleData &axisData(QwtAxisId axisId) const + { + return m_scaleData[axisId]; + } + + ScaleData &axisData(QwtAxisId axisId) { return m_scaleData[axisId]; } + + inline int axesWidth(int axisPos) const { return m_scaleData[axisPos].w; } + + inline int axesHeight(int axisPos) const { return m_scaleData[axisPos].h; } + + int m_canvasBorder[QwtAxis::AxisPositions]; + ScaleData m_scaleData[QwtAxis::AxisPositions]; +}; + +LayoutHintData::LayoutHintData(const QwtPlot *plot) +{ + using namespace QwtAxis; + + const QMargins m = plot->canvas()->contentsMargins(); + + int contentsMargins[4]; + contentsMargins[YLeft] = m.left(); + contentsMargins[XTop] = m.top(); + contentsMargins[YRight] = m.right(); + contentsMargins[XBottom] = m.bottom(); + + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + m_canvasBorder[axisPos] = contentsMargins[axisPos] + + plot->plotLayout()->canvasMargin(axisPos) + 1; { - public: - LayoutHintData( const QwtPlot* plot ); + const QwtAxisId axisId(axisPos); - int alignedSize( const QwtAxisId ) const; + if (plot->isAxisVisible(axisId)) + { + const QwtScaleWidget *scl = plot->axisWidget(axisId); + + const QSize hint = scl->minimumSizeHint(); + + ScaleData &sd = axisData(axisId); + sd.w = hint.width(); + sd.h = hint.height(); + scl->getBorderDistHint(sd.minLeft, sd.minRight); - inline int yAxesWidth() const { - using namespace QwtAxis; - return axesWidth( YLeft ) + axesWidth( YRight ); - } - - inline int yAxesHeight() const - { - using namespace QwtAxis; - return qMax( axesHeight( YLeft ), axesHeight( YRight ) ); - } - - inline int xAxesHeight() const - { - using namespace QwtAxis; - return axesHeight( XTop ) + axesHeight( XBottom ); - } - - inline int xAxesWidth() const - { - using namespace QwtAxis; - return qMax( axesWidth( XTop ), axesWidth( XBottom ) ); - } - - private: - - struct ScaleData - { - ScaleData() - { - w = h = minLeft = minRight = tickOffset = 0; - } - - int w; - int h; - int minLeft; - int minRight; - int tickOffset; - - }; - - const ScaleData& axisData( QwtAxisId axisId ) const - { - return m_scaleData[ axisId ]; - } - - ScaleData& axisData( QwtAxisId axisId ) - { - return m_scaleData[ axisId ]; - } - - inline int axesWidth( int axisPos ) const - { - return m_scaleData[axisPos].w; - } - - inline int axesHeight( int axisPos ) const - { - return m_scaleData[axisPos].h; - } - - int m_canvasBorder[QwtAxis::AxisPositions]; - ScaleData m_scaleData[QwtAxis::AxisPositions]; - }; - - LayoutHintData::LayoutHintData( const QwtPlot* plot ) - { - using namespace QwtAxis; - - const QMargins m = plot->canvas()->contentsMargins(); - - int contentsMargins[ 4 ]; - contentsMargins[ YLeft ] = m.left(); - contentsMargins[ XTop ] = m.top(); - contentsMargins[ YRight ] = m.right(); - contentsMargins[ XBottom ] = m.bottom(); - - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) - { - m_canvasBorder[axisPos] = contentsMargins[axisPos] + - plot->plotLayout()->canvasMargin( axisPos ) + 1; - { - const QwtAxisId axisId( axisPos ); - - if ( plot->isAxisVisible( axisId ) ) - { - const QwtScaleWidget* scl = plot->axisWidget( axisId ); - - const QSize hint = scl->minimumSizeHint(); - - ScaleData& sd = axisData( axisId ); - sd.w = hint.width(); - sd.h = hint.height(); - scl->getBorderDistHint( sd.minLeft, sd.minRight ); - - { - sd.tickOffset = scl->margin(); - if ( scl->scaleDraw()->hasComponent( QwtAbstractScaleDraw::Ticks ) ) - sd.tickOffset += qwtCeil( scl->scaleDraw()->maxTickLength() ); - } - } - } - } - - for ( int axis = 0; axis < AxisPositions; axis++ ) - { - const int sz = alignedSize( axis ); - - ScaleData& sd = axisData( axis ); - if ( isXAxis( axis ) ) - sd.w = sz; - else - sd.h = sz; + sd.tickOffset = scl->margin(); + if (scl->scaleDraw()->hasComponent(QwtAbstractScaleDraw::Ticks)) + sd.tickOffset += qwtCeil(scl->scaleDraw()->maxTickLength()); } + } } + } - int LayoutHintData::alignedSize( const QwtAxisId axisId ) const - { - using namespace QwtAxis; + for (int axis = 0; axis < AxisPositions; axis++) + { + const int sz = alignedSize(axis); - const ScaleData& sd = axisData( axisId ); - - if ( sd.w && isXAxis( axisId ) ) - { - int w = sd.w; - - if ( const int leftW = axesWidth( YLeft ) ) - { - const int shiftLeft = sd.minLeft - m_canvasBorder[YLeft]; - if ( shiftLeft > 0 ) - w -= qMin( shiftLeft, leftW ); - } - - if ( const int rightW = axesWidth( YRight ) ) - { - const int shiftRight = sd.minRight - m_canvasBorder[YRight]; - if ( shiftRight > 0 ) - w -= qMin( shiftRight, rightW ); - } - - return w; - } - - if ( sd.h && isYAxis( axisId ) ) - { - int h = sd.h; - - if ( axesHeight( XBottom ) ) - { - const int shiftBottom = sd.minLeft - m_canvasBorder[XBottom]; - if ( shiftBottom > 0 ) - h -= qMin( shiftBottom, axisData( XBottom ).tickOffset ); - } - - if ( axesHeight( XTop ) ) - { - const int shiftTop = sd.minRight - m_canvasBorder[XTop]; - if ( shiftTop > 0 ) - h -= qMin( shiftTop, axisData( XTop ).tickOffset ); - } - - return h; - } - - return 0; - } + ScaleData &sd = axisData(axis); + if (isXAxis(axis)) + sd.w = sz; + else + sd.h = sz; + } } +int LayoutHintData::alignedSize(const QwtAxisId axisId) const +{ + using namespace QwtAxis; + + const ScaleData &sd = axisData(axisId); + + if (sd.w && isXAxis(axisId)) + { + int w = sd.w; + + if (const int leftW = axesWidth(YLeft)) + { + const int shiftLeft = sd.minLeft - m_canvasBorder[YLeft]; + if (shiftLeft > 0) + w -= qMin(shiftLeft, leftW); + } + + if (const int rightW = axesWidth(YRight)) + { + const int shiftRight = sd.minRight - m_canvasBorder[YRight]; + if (shiftRight > 0) + w -= qMin(shiftRight, rightW); + } + + return w; + } + + if (sd.h && isYAxis(axisId)) + { + int h = sd.h; + + if (axesHeight(XBottom)) + { + const int shiftBottom = sd.minLeft - m_canvasBorder[XBottom]; + if (shiftBottom > 0) + h -= qMin(shiftBottom, axisData(XBottom).tickOffset); + } + + if (axesHeight(XTop)) + { + const int shiftTop = sd.minRight - m_canvasBorder[XTop]; + if (shiftTop > 0) + h -= qMin(shiftTop, axisData(XTop).tickOffset); + } + + return h; + } + + return 0; +} +} // namespace + namespace QwtPlotLayoutPrivate { - class LayoutEngine +class LayoutEngine +{ +public: + struct Dimensions + { + Dimensions() { - public: - struct Dimensions - { - Dimensions() - { - dimTitle = dimFooter = 0; - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - m_dimAxes[axisPos] = 0; - } + dimTitle = dimFooter = 0; + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + m_dimAxes[axisPos] = 0; + } - inline int dimAxis( QwtAxisId axisId ) const - { - return m_dimAxes[ axisId ]; - } + inline int dimAxis(QwtAxisId axisId) const { return m_dimAxes[axisId]; } - void setDimAxis( QwtAxisId axisId, int dim ) - { - m_dimAxes[ axisId ] = dim; - } + void setDimAxis(QwtAxisId axisId, int dim) { m_dimAxes[axisId] = dim; } - inline int dimAxes( int axisPos ) const - { - return m_dimAxes[ axisPos ]; - } + inline int dimAxes(int axisPos) const { return m_dimAxes[axisPos]; } - inline int dimYAxes() const - { - return dimAxes( QwtAxis::YLeft ) + dimAxes( QwtAxis::YRight ); - } + inline int dimYAxes() const + { + return dimAxes(QwtAxis::YLeft) + dimAxes(QwtAxis::YRight); + } - inline int dimXAxes() const - { - return dimAxes( QwtAxis::XTop ) + dimAxes( QwtAxis::XBottom ); - } + inline int dimXAxes() const + { + return dimAxes(QwtAxis::XTop) + dimAxes(QwtAxis::XBottom); + } - inline QRectF centered( const QRectF& rect, const QRectF& labelRect ) const - { - QRectF r = labelRect; - r.setX( rect.left() + dimAxes( QwtAxis::YLeft ) ); - r.setWidth( rect.width() - dimYAxes() ); + inline QRectF centered(const QRectF &rect, const QRectF &labelRect) const + { + QRectF r = labelRect; + r.setX(rect.left() + dimAxes(QwtAxis::YLeft)); + r.setWidth(rect.width() - dimYAxes()); - return r; - } + return r; + } - inline QRectF innerRect( const QRectF& rect ) const - { - QRectF r( - rect.x() + dimAxes( QwtAxis::YLeft ), - rect.y() + dimAxes( QwtAxis::XTop ), - rect.width() - dimYAxes(), - rect.height() - dimXAxes() ); + inline QRectF innerRect(const QRectF &rect) const + { + QRectF r(rect.x() + dimAxes(QwtAxis::YLeft), + rect.y() + dimAxes(QwtAxis::XTop), rect.width() - dimYAxes(), + rect.height() - dimXAxes()); - if ( r.width() < 0 ) - { - r.setX( rect.center().x() ); - r.setWidth( 0 ); - } - if ( r.height() < 0 ) - { - r.setY( rect.center().y() ); - r.setHeight( 0 ); - } + if (r.width() < 0) + { + r.setX(rect.center().x()); + r.setWidth(0); + } + if (r.height() < 0) + { + r.setY(rect.center().y()); + r.setHeight(0); + } - return r; - } + return r; + } - int dimTitle; - int dimFooter; + int dimTitle; + int dimFooter; - private: - int m_dimAxes[QwtAxis::AxisPositions]; - }; + private: + int m_dimAxes[QwtAxis::AxisPositions]; + }; - LayoutEngine() - : m_legendPos( QwtPlot::BottomLegend ) - , m_legendRatio( 1.0 ) - , m_spacing( 5 ) - { - } + LayoutEngine() + : m_legendPos(QwtPlot::BottomLegend) + , m_legendRatio(1.0) + , m_spacing(5) + { + } - QRectF layoutLegend( QwtPlotLayout::Options, - const LayoutData::LegendData&, const QRectF&, const QSize& ) const; + QRectF layoutLegend(QwtPlotLayout::Options, const LayoutData::LegendData &, + const QRectF &, const QSize &) const; - QRectF alignLegend( const QSize& legendHint, - const QRectF& canvasRect, const QRectF& legendRect ) const; + QRectF alignLegend(const QSize &legendHint, const QRectF &canvasRect, + const QRectF &legendRect) const; - void alignScales( QwtPlotLayout::Options, - const LayoutData&, QRectF& canvasRect, - QRectF scaleRect[QwtAxis::AxisPositions] ) const; + void alignScales(QwtPlotLayout::Options, const LayoutData &, + QRectF &canvasRect, + QRectF scaleRect[QwtAxis::AxisPositions]) const; - Dimensions layoutDimensions( QwtPlotLayout::Options, - const LayoutData&, const QRectF& ) const; + Dimensions layoutDimensions(QwtPlotLayout::Options, const LayoutData &, + const QRectF &) const; - inline void setSpacing( unsigned int spacing ) { m_spacing = spacing; } - inline unsigned int spacing() const { return m_spacing; } + inline void setSpacing(unsigned int spacing) { m_spacing = spacing; } + inline unsigned int spacing() const { return m_spacing; } - inline void setAlignCanvas( int axisPos, bool on ) { m_alignCanvas[ axisPos ] = on; } - inline bool alignCanvas( int axisPos ) const { return m_alignCanvas[ axisPos ]; } + inline void setAlignCanvas(int axisPos, bool on) + { + m_alignCanvas[axisPos] = on; + } + inline bool alignCanvas(int axisPos) const { return m_alignCanvas[axisPos]; } - inline void setCanvasMargin( int axisPos, int margin ) { m_canvasMargin[ axisPos ] = margin; } - inline int canvasMargin( int axisPos ) const { return m_canvasMargin[ axisPos ]; } + inline void setCanvasMargin(int axisPos, int margin) + { + m_canvasMargin[axisPos] = margin; + } + inline int canvasMargin(int axisPos) const { return m_canvasMargin[axisPos]; } - inline void setLegendPos( QwtPlot::LegendPosition pos ) { m_legendPos = pos; } - inline QwtPlot::LegendPosition legendPos() const { return m_legendPos; } + inline void setLegendPos(QwtPlot::LegendPosition pos) { m_legendPos = pos; } + inline QwtPlot::LegendPosition legendPos() const { return m_legendPos; } - inline void setLegendRatio( double ratio ) { m_legendRatio = ratio; } - inline double legendRatio() const { return m_legendRatio; } + inline void setLegendRatio(double ratio) { m_legendRatio = ratio; } + inline double legendRatio() const { return m_legendRatio; } - private: - int heightForWidth( LayoutData::Label, const LayoutData&, - QwtPlotLayout::Options, double width, int axesWidth ) const; +private: + int heightForWidth(LayoutData::Label, const LayoutData &, + QwtPlotLayout::Options, double width, int axesWidth) const; - QwtPlot::LegendPosition m_legendPos; - double m_legendRatio; + QwtPlot::LegendPosition m_legendPos; + double m_legendRatio; - unsigned int m_canvasMargin[QwtAxis::AxisPositions]; - bool m_alignCanvas[QwtAxis::AxisPositions]; + unsigned int m_canvasMargin[QwtAxis::AxisPositions]; + bool m_alignCanvas[QwtAxis::AxisPositions]; - unsigned int m_spacing; - }; + unsigned int m_spacing; +}; +} // namespace QwtPlotLayoutPrivate + +QRectF QwtPlotLayoutPrivate::LayoutEngine::layoutLegend( + QwtPlotLayout::Options options, const LayoutData::LegendData &legendData, + const QRectF &rect, const QSize &legendHint) const +{ + int dim; + if (m_legendPos == QwtPlot::LeftLegend || m_legendPos == QwtPlot::RightLegend) + { + // We don't allow vertical legends to take more than + // half of the available space. + + dim = qMin(legendHint.width(), int(rect.width() * m_legendRatio)); + + if (!(options & QwtPlotLayout::IgnoreScrollbars)) + { + if (legendHint.height() > rect.height()) + { + // The legend will need additional + // space for the vertical scrollbar. + + dim += legendData.hScrollExtent; + } + } + } + else + { + dim = qMin(legendHint.height(), int(rect.height() * m_legendRatio)); + dim = qMax(dim, legendData.vScrollExtent); + } + + QRectF legendRect = rect; + switch (m_legendPos) + { + case QwtPlot::LeftLegend: { + legendRect.setWidth(dim); + break; + } + case QwtPlot::RightLegend: { + legendRect.setX(rect.right() - dim); + legendRect.setWidth(dim); + break; + } + case QwtPlot::TopLegend: { + legendRect.setHeight(dim); + break; + } + case QwtPlot::BottomLegend: { + legendRect.setY(rect.bottom() - dim); + legendRect.setHeight(dim); + break; + } + } + + return legendRect; } -QRectF QwtPlotLayoutPrivate::LayoutEngine::layoutLegend( QwtPlotLayout::Options options, - const LayoutData::LegendData& legendData, - const QRectF& rect, const QSize& legendHint ) const +QRectF +QwtPlotLayoutPrivate::LayoutEngine::alignLegend(const QSize &legendHint, + const QRectF &canvasRect, + const QRectF &legendRect) const { - int dim; - if ( m_legendPos == QwtPlot::LeftLegend - || m_legendPos == QwtPlot::RightLegend ) + QRectF alignedRect = legendRect; + + if (m_legendPos == QwtPlot::BottomLegend || m_legendPos == QwtPlot::TopLegend) + { + if (legendHint.width() < canvasRect.width()) { - // We don't allow vertical legends to take more than - // half of the available space. - - dim = qMin( legendHint.width(), int( rect.width() * m_legendRatio ) ); - - if ( !( options & QwtPlotLayout::IgnoreScrollbars ) ) - { - if ( legendHint.height() > rect.height() ) - { - // The legend will need additional - // space for the vertical scrollbar. - - dim += legendData.hScrollExtent; - } - } + alignedRect.setX(canvasRect.x()); + alignedRect.setWidth(canvasRect.width()); } - else + } + else + { + if (legendHint.height() < canvasRect.height()) { - dim = qMin( legendHint.height(), int( rect.height() * m_legendRatio ) ); - dim = qMax( dim, legendData.vScrollExtent ); + alignedRect.setY(canvasRect.y()); + alignedRect.setHeight(canvasRect.height()); } + } - QRectF legendRect = rect; - switch ( m_legendPos ) - { - case QwtPlot::LeftLegend: - { - legendRect.setWidth( dim ); - break; - } - case QwtPlot::RightLegend: - { - legendRect.setX( rect.right() - dim ); - legendRect.setWidth( dim ); - break; - } - case QwtPlot::TopLegend: - { - legendRect.setHeight( dim ); - break; - } - case QwtPlot::BottomLegend: - { - legendRect.setY( rect.bottom() - dim ); - legendRect.setHeight( dim ); - break; - } - } - - return legendRect; -} - -QRectF QwtPlotLayoutPrivate::LayoutEngine::alignLegend( const QSize& legendHint, - const QRectF& canvasRect, const QRectF& legendRect ) const -{ - QRectF alignedRect = legendRect; - - if ( m_legendPos == QwtPlot::BottomLegend - || m_legendPos == QwtPlot::TopLegend ) - { - if ( legendHint.width() < canvasRect.width() ) - { - alignedRect.setX( canvasRect.x() ); - alignedRect.setWidth( canvasRect.width() ); - } - } - else - { - if ( legendHint.height() < canvasRect.height() ) - { - alignedRect.setY( canvasRect.y() ); - alignedRect.setHeight( canvasRect.height() ); - } - } - - return alignedRect; + return alignedRect; } int QwtPlotLayoutPrivate::LayoutEngine::heightForWidth( - LayoutData::Label labelType, const LayoutData& layoutData, - QwtPlotLayout::Options options, - double width, int axesWidth ) const + LayoutData::Label labelType, const LayoutData &layoutData, + QwtPlotLayout::Options options, double width, int axesWidth) const { - const LayoutData::LabelData& labelData = layoutData.labelData[ labelType ]; + const LayoutData::LabelData &labelData = layoutData.labelData[labelType]; - if ( labelData.text.isEmpty() ) - return 0; + if (labelData.text.isEmpty()) + return 0; - double w = width; + double w = width; - if ( !layoutData.hasSymmetricYAxes() ) - { - // center to the canvas - w -= axesWidth; - } + if (!layoutData.hasSymmetricYAxes()) + { + // center to the canvas + w -= axesWidth; + } - int d = qwtCeil( labelData.text.heightForWidth( w ) ); - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - d += 2 * labelData.frameWidth; + int d = qwtCeil(labelData.text.heightForWidth(w)); + if (!(options & QwtPlotLayout::IgnoreFrames)) + d += 2 * labelData.frameWidth; - return d; + return d; } -QwtPlotLayoutPrivate::LayoutEngine::Dimensions QwtPlotLayoutPrivate::LayoutEngine::layoutDimensions( QwtPlotLayout::Options options, - const LayoutData& layoutData, const QRectF& rect ) const +QwtPlotLayoutPrivate::LayoutEngine::Dimensions +QwtPlotLayoutPrivate::LayoutEngine::layoutDimensions( + QwtPlotLayout::Options options, const LayoutData &layoutData, + const QRectF &rect) const { - using namespace QwtAxis; + using namespace QwtAxis; - Dimensions dimensions; + Dimensions dimensions; - int backboneOffset[AxisPositions]; - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) + int backboneOffset[AxisPositions]; + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + backboneOffset[axisPos] = 0; + if (!(options & QwtPlotLayout::IgnoreFrames)) + backboneOffset[axisPos] += layoutData.canvasData.contentsMargins[axisPos]; + + if (!m_alignCanvas[axisPos]) + backboneOffset[axisPos] += m_canvasMargin[axisPos]; + } + + bool done = false; + while (!done) + { + done = true; + + // the size for the 4 axis depend on each other. Expanding + // the height of a horizontal axis will shrink the height + // for the vertical axis, shrinking the height of a vertical + // axis will result in a line break what will expand the + // width and results in shrinking the width of a horizontal + // axis what might result in a line break of a horizontal + // axis ... . So we loop as long until no size changes. + + if (!(options & QwtPlotLayout::IgnoreTitle)) { - backboneOffset[axisPos] = 0; - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - backboneOffset[axisPos] += layoutData.canvasData.contentsMargins[axisPos]; + const int d = heightForWidth(LayoutData::Title, layoutData, options, + rect.width(), dimensions.dimYAxes()); - if ( !m_alignCanvas[axisPos] ) - backboneOffset[axisPos] += m_canvasMargin[axisPos]; + if (d > dimensions.dimTitle) + { + dimensions.dimTitle = d; + done = false; + } } - bool done = false; - while ( !done ) + if (!(options & QwtPlotLayout::IgnoreFooter)) { - done = true; + const int d = heightForWidth(LayoutData::Footer, layoutData, options, + rect.width(), dimensions.dimYAxes()); - // the size for the 4 axis depend on each other. Expanding - // the height of a horizontal axis will shrink the height - // for the vertical axis, shrinking the height of a vertical - // axis will result in a line break what will expand the - // width and results in shrinking the width of a horizontal - // axis what might result in a line break of a horizontal - // axis ... . So we loop as long until no size changes. - - if ( !( options & QwtPlotLayout::IgnoreTitle ) ) - { - const int d = heightForWidth( - LayoutData::Title, layoutData, options, - rect.width(), dimensions.dimYAxes() ); - - if ( d > dimensions.dimTitle ) - { - dimensions.dimTitle = d; - done = false; - } - } - - if ( !( options & QwtPlotLayout::IgnoreFooter ) ) - { - const int d = heightForWidth( - LayoutData::Footer, layoutData, options, - rect.width(), dimensions.dimYAxes() ); - - if ( d > dimensions.dimFooter ) - { - dimensions.dimFooter = d; - done = false; - } - } - - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) - { - { - const QwtAxisId axisId( axisPos ); - - const LayoutData::ScaleData& scaleData = layoutData.axisData( axisId ); - - if ( scaleData.isVisible ) - { - double length; - if ( isXAxis( axisPos ) ) - { - length = rect.width() - dimensions.dimYAxes(); - length -= scaleData.start + scaleData.end; - - if ( dimensions.dimAxes( YRight ) > 0 ) - length -= 1; - - length += qMin( dimensions.dimAxes( YLeft ), - scaleData.start - backboneOffset[YLeft] ); - - length += qMin( dimensions.dimAxes( YRight ), - scaleData.end - backboneOffset[YRight] ); - } - else // y axis - { - length = rect.height() - dimensions.dimXAxes(); - length -= scaleData.start + scaleData.end; - length -= 1; - - if ( dimensions.dimAxes( XBottom ) <= 0 ) - length -= 1; - - if ( dimensions.dimAxes( XTop ) <= 0 ) - length -= 1; - - /* - The tick labels of the y axes are always left/right from the - backbone/ticks of the x axes - but we have to take care, - that the labels don't overlap. - */ - if ( dimensions.dimAxes( XBottom ) > 0 ) - { - length += qMin( - layoutData.tickOffset( XBottom ), - double( scaleData.start - backboneOffset[XBottom] ) ); - } - - if ( dimensions.dimAxes( XTop ) > 0 ) - { - length += qMin( - layoutData.tickOffset( XTop ), - double( scaleData.end - backboneOffset[XTop] ) ); - } - - if ( dimensions.dimTitle > 0 ) - length -= dimensions.dimTitle + m_spacing; - } - - int d = scaleData.dimWithoutTitle; - if ( !scaleData.scaleWidget->title().isEmpty() ) - { - d += scaleData.scaleWidget->titleHeightForWidth( qwtFloor( length ) ); - } - - - if ( d > dimensions.dimAxis( axisId ) ) - { - dimensions.setDimAxis( axisId, d ); - done = false; - } - } - } - } + if (d > dimensions.dimFooter) + { + dimensions.dimFooter = d; + done = false; + } } - return dimensions; + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + { + const QwtAxisId axisId(axisPos); + + const LayoutData::ScaleData &scaleData = layoutData.axisData(axisId); + + if (scaleData.isVisible) + { + double length; + if (isXAxis(axisPos)) + { + length = rect.width() - dimensions.dimYAxes(); + length -= scaleData.start + scaleData.end; + + if (dimensions.dimAxes(YRight) > 0) + length -= 1; + + length += qMin(dimensions.dimAxes(YLeft), + scaleData.start - backboneOffset[YLeft]); + + length += qMin(dimensions.dimAxes(YRight), + scaleData.end - backboneOffset[YRight]); + } + else // y axis + { + length = rect.height() - dimensions.dimXAxes(); + length -= scaleData.start + scaleData.end; + length -= 1; + + if (dimensions.dimAxes(XBottom) <= 0) + length -= 1; + + if (dimensions.dimAxes(XTop) <= 0) + length -= 1; + + /* + The tick labels of the y axes are always left/right from the + backbone/ticks of the x axes - but we have to take care, + that the labels don't overlap. + */ + if (dimensions.dimAxes(XBottom) > 0) + { + length += qMin(layoutData.tickOffset(XBottom), + double(scaleData.start - backboneOffset[XBottom])); + } + + if (dimensions.dimAxes(XTop) > 0) + { + length += qMin(layoutData.tickOffset(XTop), + double(scaleData.end - backboneOffset[XTop])); + } + + if (dimensions.dimTitle > 0) + length -= dimensions.dimTitle + m_spacing; + } + + int d = scaleData.dimWithoutTitle; + if (!scaleData.scaleWidget->title().isEmpty()) + { + d += scaleData.scaleWidget->titleHeightForWidth(qwtFloor(length)); + } + + if (d > dimensions.dimAxis(axisId)) + { + dimensions.setDimAxis(axisId, d); + done = false; + } + } + } + } + } + + return dimensions; } -void QwtPlotLayoutPrivate::LayoutEngine::alignScales( QwtPlotLayout::Options options, - const LayoutData& layoutData, QRectF& canvasRect, - QRectF scaleRect[QwtAxis::AxisPositions] ) const +void QwtPlotLayoutPrivate::LayoutEngine::alignScales( + QwtPlotLayout::Options options, const LayoutData &layoutData, + QRectF &canvasRect, QRectF scaleRect[QwtAxis::AxisPositions]) const { - using namespace QwtAxis; + using namespace QwtAxis; - int backboneOffset[AxisPositions]; - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) + int backboneOffset[AxisPositions]; + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + backboneOffset[axisPos] = 0; + + if (!m_alignCanvas[axisPos]) { - backboneOffset[axisPos] = 0; - - if ( !m_alignCanvas[axisPos] ) - { - backboneOffset[axisPos] += m_canvasMargin[axisPos]; - } - - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - { - backboneOffset[axisPos] += - layoutData.canvasData.contentsMargins[axisPos]; - } + backboneOffset[axisPos] += m_canvasMargin[axisPos]; } - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) + if (!(options & QwtPlotLayout::IgnoreFrames)) { - { - QRectF& axisRect = scaleRect[axisPos]; - if ( !axisRect.isValid() ) - continue; - - const QwtAxisId axisId( axisPos ); - - const int startDist = layoutData.axisData( axisId ).start; - const int endDist = layoutData.axisData( axisId ).end; - - if ( isXAxis( axisPos ) ) - { - const QRectF& leftScaleRect = scaleRect[YLeft]; - const int leftOffset = backboneOffset[YLeft] - startDist; - - if ( leftScaleRect.isValid() ) - { - const double dx = leftOffset + leftScaleRect.width(); - if ( m_alignCanvas[YLeft] && dx < 0.0 ) - { - /* - The axis needs more space than the width - of the left scale. - */ - const double cLeft = canvasRect.left(); // qreal -> double - canvasRect.setLeft( qwtMaxF( cLeft, axisRect.left() - dx ) ); - } - else - { - const double minLeft = leftScaleRect.left(); - const double left = axisRect.left() + leftOffset; - axisRect.setLeft( qwtMaxF( left, minLeft ) ); - } - } - else - { - if ( m_alignCanvas[YLeft] && leftOffset < 0 ) - { - canvasRect.setLeft( qwtMaxF( canvasRect.left(), - axisRect.left() - leftOffset ) ); - } - else - { - if ( leftOffset > 0 ) - axisRect.setLeft( axisRect.left() + leftOffset ); - } - } - - const QRectF& rightScaleRect = scaleRect[YRight]; - const int rightOffset = backboneOffset[YRight] - endDist + 1; - - if ( rightScaleRect.isValid() ) - { - const double dx = rightOffset + rightScaleRect.width(); - if ( m_alignCanvas[YRight] && dx < 0 ) - { - /* - The axis needs more space than the width - of the right scale. - */ - const double cRight = canvasRect.right(); // qreal -> double - canvasRect.setRight( qwtMinF( cRight, axisRect.right() + dx ) ); - } - - const double maxRight = rightScaleRect.right(); - const double right = axisRect.right() - rightOffset; - axisRect.setRight( qwtMinF( right, maxRight ) ); - } - else - { - if ( m_alignCanvas[YRight] && rightOffset < 0 ) - { - canvasRect.setRight( qwtMinF( canvasRect.right(), - axisRect.right() + rightOffset ) ); - } - else - { - if ( rightOffset > 0 ) - axisRect.setRight( axisRect.right() - rightOffset ); - } - } - } - else // y axes - { - const QRectF& bottomScaleRect = scaleRect[XBottom]; - const int bottomOffset = backboneOffset[XBottom] - endDist + 1; - - if ( bottomScaleRect.isValid() ) - { - const double dy = bottomOffset + bottomScaleRect.height(); - if ( m_alignCanvas[XBottom] && dy < 0 ) - { - /* - The axis needs more space than the height - of the bottom scale. - */ - const double cBottom = canvasRect.bottom(); // qreal -> double - canvasRect.setBottom( qwtMinF( cBottom, axisRect.bottom() + dy ) ); - } - else - { - const double maxBottom = bottomScaleRect.top() + - layoutData.tickOffset( XBottom ); - const double bottom = axisRect.bottom() - bottomOffset; - axisRect.setBottom( qwtMinF( bottom, maxBottom ) ); - } - } - else - { - if ( m_alignCanvas[XBottom] && bottomOffset < 0 ) - { - canvasRect.setBottom( qwtMinF( canvasRect.bottom(), - axisRect.bottom() + bottomOffset ) ); - } - else - { - if ( bottomOffset > 0 ) - axisRect.setBottom( axisRect.bottom() - bottomOffset ); - } - } - - const QRectF& topScaleRect = scaleRect[XTop]; - const int topOffset = backboneOffset[XTop] - startDist; - - if ( topScaleRect.isValid() ) - { - const double dy = topOffset + topScaleRect.height(); - if ( m_alignCanvas[XTop] && dy < 0 ) - { - /* - The axis needs more space than the height - of the top scale. - */ - const double cTop = canvasRect.top(); // qreal -> double - canvasRect.setTop( qwtMaxF( cTop, axisRect.top() - dy ) ); - } - else - { - const double minTop = topScaleRect.bottom() - - layoutData.tickOffset( XTop ); - - const double top = axisRect.top() + topOffset; - axisRect.setTop( qwtMaxF( top, minTop ) ); - } - } - else - { - if ( m_alignCanvas[XTop] && topOffset < 0 ) - { - canvasRect.setTop( qwtMaxF( canvasRect.top(), - axisRect.top() - topOffset ) ); - } - else - { - if ( topOffset > 0 ) - axisRect.setTop( axisRect.top() + topOffset ); - } - } - } - } + backboneOffset[axisPos] += layoutData.canvasData.contentsMargins[axisPos]; } + } - /* - The canvas has been aligned to the scale with largest - border distances. Now we have to realign the other scale. - */ - - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { { + QRectF &axisRect = scaleRect[axisPos]; + if (!axisRect.isValid()) + continue; + + const QwtAxisId axisId(axisPos); + + const int startDist = layoutData.axisData(axisId).start; + const int endDist = layoutData.axisData(axisId).end; + + if (isXAxis(axisPos)) + { + const QRectF &leftScaleRect = scaleRect[YLeft]; + const int leftOffset = backboneOffset[YLeft] - startDist; + + if (leftScaleRect.isValid()) { - const QwtAxisId axisId( axisPos ); - - QRectF& sRect = scaleRect[axisPos]; - const LayoutData::ScaleData& axisData = layoutData.axisData( axisId ); - - if ( !sRect.isValid() ) - continue; - - if ( isXAxis( axisPos ) ) - { - if ( m_alignCanvas[YLeft] ) - { - double y = canvasRect.left() - axisData.start; - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - y += layoutData.canvasData.contentsMargins[YLeft]; - - sRect.setLeft( y ); - } - - if ( m_alignCanvas[YRight] ) - { - double y = canvasRect.right() - 1 + axisData.end; - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - y -= layoutData.canvasData.contentsMargins[YRight]; - - sRect.setRight( y ); - } - - if ( m_alignCanvas[axisPos] ) - { - if ( axisPos == XTop ) - sRect.setBottom( canvasRect.top() ); - else - sRect.setTop( canvasRect.bottom() ); - } - } - else - { - if ( m_alignCanvas[XTop] ) - { - double x = canvasRect.top() - axisData.start; - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - x += layoutData.canvasData.contentsMargins[XTop]; - - sRect.setTop( x ); - } - - if ( m_alignCanvas[XBottom] ) - { - double x = canvasRect.bottom() - 1 + axisData.end; - if ( !( options & QwtPlotLayout::IgnoreFrames ) ) - x -= layoutData.canvasData.contentsMargins[XBottom]; - - sRect.setBottom( x ); - } - - if ( m_alignCanvas[axisPos] ) - { - if ( axisPos == YLeft ) - sRect.setRight( canvasRect.left() ); - else - sRect.setLeft( canvasRect.right() ); - } - } + const double dx = leftOffset + leftScaleRect.width(); + if (m_alignCanvas[YLeft] && dx < 0.0) + { + /* + The axis needs more space than the width + of the left scale. + */ + const double cLeft = canvasRect.left(); // qreal -> double + canvasRect.setLeft(qwtMaxF(cLeft, axisRect.left() - dx)); + } + else + { + const double minLeft = leftScaleRect.left(); + const double left = axisRect.left() + leftOffset; + axisRect.setLeft(qwtMaxF(left, minLeft)); + } } + else + { + if (m_alignCanvas[YLeft] && leftOffset < 0) + { + canvasRect.setLeft( + qwtMaxF(canvasRect.left(), axisRect.left() - leftOffset)); + } + else + { + if (leftOffset > 0) + axisRect.setLeft(axisRect.left() + leftOffset); + } + } + + const QRectF &rightScaleRect = scaleRect[YRight]; + const int rightOffset = backboneOffset[YRight] - endDist + 1; + + if (rightScaleRect.isValid()) + { + const double dx = rightOffset + rightScaleRect.width(); + if (m_alignCanvas[YRight] && dx < 0) + { + /* + The axis needs more space than the width + of the right scale. + */ + const double cRight = canvasRect.right(); // qreal -> double + canvasRect.setRight(qwtMinF(cRight, axisRect.right() + dx)); + } + + const double maxRight = rightScaleRect.right(); + const double right = axisRect.right() - rightOffset; + axisRect.setRight(qwtMinF(right, maxRight)); + } + else + { + if (m_alignCanvas[YRight] && rightOffset < 0) + { + canvasRect.setRight( + qwtMinF(canvasRect.right(), axisRect.right() + rightOffset)); + } + else + { + if (rightOffset > 0) + axisRect.setRight(axisRect.right() - rightOffset); + } + } + } + else // y axes + { + const QRectF &bottomScaleRect = scaleRect[XBottom]; + const int bottomOffset = backboneOffset[XBottom] - endDist + 1; + + if (bottomScaleRect.isValid()) + { + const double dy = bottomOffset + bottomScaleRect.height(); + if (m_alignCanvas[XBottom] && dy < 0) + { + /* + The axis needs more space than the height + of the bottom scale. + */ + const double cBottom = canvasRect.bottom(); // qreal -> double + canvasRect.setBottom(qwtMinF(cBottom, axisRect.bottom() + dy)); + } + else + { + const double maxBottom + = bottomScaleRect.top() + layoutData.tickOffset(XBottom); + const double bottom = axisRect.bottom() - bottomOffset; + axisRect.setBottom(qwtMinF(bottom, maxBottom)); + } + } + else + { + if (m_alignCanvas[XBottom] && bottomOffset < 0) + { + canvasRect.setBottom( + qwtMinF(canvasRect.bottom(), axisRect.bottom() + bottomOffset)); + } + else + { + if (bottomOffset > 0) + axisRect.setBottom(axisRect.bottom() - bottomOffset); + } + } + + const QRectF &topScaleRect = scaleRect[XTop]; + const int topOffset = backboneOffset[XTop] - startDist; + + if (topScaleRect.isValid()) + { + const double dy = topOffset + topScaleRect.height(); + if (m_alignCanvas[XTop] && dy < 0) + { + /* + The axis needs more space than the height + of the top scale. + */ + const double cTop = canvasRect.top(); // qreal -> double + canvasRect.setTop(qwtMaxF(cTop, axisRect.top() - dy)); + } + else + { + const double minTop + = topScaleRect.bottom() - layoutData.tickOffset(XTop); + + const double top = axisRect.top() + topOffset; + axisRect.setTop(qwtMaxF(top, minTop)); + } + } + else + { + if (m_alignCanvas[XTop] && topOffset < 0) + { + canvasRect.setTop( + qwtMaxF(canvasRect.top(), axisRect.top() - topOffset)); + } + else + { + if (topOffset > 0) + axisRect.setTop(axisRect.top() + topOffset); + } + } + } } + } + + /* + The canvas has been aligned to the scale with largest + border distances. Now we have to realign the other scale. + */ + + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + { + const QwtAxisId axisId(axisPos); + + QRectF &sRect = scaleRect[axisPos]; + const LayoutData::ScaleData &axisData = layoutData.axisData(axisId); + + if (!sRect.isValid()) + continue; + + if (isXAxis(axisPos)) + { + if (m_alignCanvas[YLeft]) + { + double y = canvasRect.left() - axisData.start; + if (!(options & QwtPlotLayout::IgnoreFrames)) + y += layoutData.canvasData.contentsMargins[YLeft]; + + sRect.setLeft(y); + } + + if (m_alignCanvas[YRight]) + { + double y = canvasRect.right() - 1 + axisData.end; + if (!(options & QwtPlotLayout::IgnoreFrames)) + y -= layoutData.canvasData.contentsMargins[YRight]; + + sRect.setRight(y); + } + + if (m_alignCanvas[axisPos]) + { + if (axisPos == XTop) + sRect.setBottom(canvasRect.top()); + else + sRect.setTop(canvasRect.bottom()); + } + } + else + { + if (m_alignCanvas[XTop]) + { + double x = canvasRect.top() - axisData.start; + if (!(options & QwtPlotLayout::IgnoreFrames)) + x += layoutData.canvasData.contentsMargins[XTop]; + + sRect.setTop(x); + } + + if (m_alignCanvas[XBottom]) + { + double x = canvasRect.bottom() - 1 + axisData.end; + if (!(options & QwtPlotLayout::IgnoreFrames)) + x -= layoutData.canvasData.contentsMargins[XBottom]; + + sRect.setBottom(x); + } + + if (m_alignCanvas[axisPos]) + { + if (axisPos == YLeft) + sRect.setRight(canvasRect.left()); + else + sRect.setLeft(canvasRect.right()); + } + } + } + } } class QwtPlotLayout::PrivateData { - public: - QRectF titleRect; - QRectF footerRect; - QRectF legendRect; - QRectF scaleRects[QwtAxis::AxisPositions]; - QRectF canvasRect; +public: + QRectF titleRect; + QRectF footerRect; + QRectF legendRect; + QRectF scaleRects[QwtAxis::AxisPositions]; + QRectF canvasRect; - QwtPlotLayoutPrivate::LayoutEngine engine; + QwtPlotLayoutPrivate::LayoutEngine engine; }; /*! @@ -1035,19 +1004,19 @@ class QwtPlotLayout::PrivateData QwtPlotLayout::QwtPlotLayout() { - m_data = new PrivateData; + m_data = new PrivateData; - setLegendPosition( QwtPlot::BottomLegend ); - setCanvasMargin( 4 ); - setAlignCanvasToScales( false ); + setLegendPosition(QwtPlot::BottomLegend); + setCanvasMargin(4); + setAlignCanvasToScales(false); - invalidate(); + invalidate(); } //! Destructor QwtPlotLayout::~QwtPlotLayout() { - delete m_data; + delete m_data; } /*! @@ -1056,29 +1025,28 @@ QwtPlotLayout::~QwtPlotLayout() be set to -1, excluding the borders of the scales. \param margin New margin - \param axisPos One of QwtAxis::Position. Specifies where the position of the margin. - -1 means margin at all borders. - \sa canvasMargin() + \param axisPos One of QwtAxis::Position. Specifies where the position of the + margin. -1 means margin at all borders. \sa canvasMargin() \warning The margin will have no effect when alignCanvasToScale() is true */ -void QwtPlotLayout::setCanvasMargin( int margin, int axisPos ) +void QwtPlotLayout::setCanvasMargin(int margin, int axisPos) { - if ( margin < -1 ) - margin = -1; + if (margin < -1) + margin = -1; - QwtPlotLayoutPrivate::LayoutEngine& engine = m_data->engine; + QwtPlotLayoutPrivate::LayoutEngine &engine = m_data->engine; - if ( axisPos == -1 ) - { - for ( axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - engine.setCanvasMargin( axisPos, margin ); - } - else if ( QwtAxis::isValid( axisPos ) ) - { - engine.setCanvasMargin( axisPos, margin ); - } + if (axisPos == -1) + { + for (axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + engine.setCanvasMargin(axisPos, margin); + } + else if (QwtAxis::isValid(axisPos)) + { + engine.setCanvasMargin(axisPos, margin); + } } /*! @@ -1086,12 +1054,12 @@ void QwtPlotLayout::setCanvasMargin( int margin, int axisPos ) \return Margin around the scale tick borders \sa setCanvasMargin() */ -int QwtPlotLayout::canvasMargin( int axisPos ) const +int QwtPlotLayout::canvasMargin(int axisPos) const { - if ( !QwtAxis::isValid( axisPos ) ) - return 0; + if (!QwtAxis::isValid(axisPos)) + return 0; - return m_data->engine.canvasMargin( axisPos ); + return m_data->engine.canvasMargin(axisPos); } /*! @@ -1100,10 +1068,10 @@ int QwtPlotLayout::canvasMargin( int axisPos ) const \param on True/False \sa setAlignCanvasToScale(), alignCanvasToScale() */ -void QwtPlotLayout::setAlignCanvasToScales( bool on ) +void QwtPlotLayout::setAlignCanvasToScales(bool on) { - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - m_data->engine.setAlignCanvas( axisPos, on ); + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + m_data->engine.setAlignCanvas(axisPos, on); } /*! @@ -1123,10 +1091,10 @@ void QwtPlotLayout::setAlignCanvasToScales( bool on ) \sa setCanvasMargin(), alignCanvasToScale(), setAlignCanvasToScales() \warning In case of on == true canvasMargin() will have no effect */ -void QwtPlotLayout::setAlignCanvasToScale( int axisPos, bool on ) +void QwtPlotLayout::setAlignCanvasToScale(int axisPos, bool on) { - if ( QwtAxis::isValid( axisPos ) ) - m_data->engine.setAlignCanvas( axisPos, on ); + if (QwtAxis::isValid(axisPos)) + m_data->engine.setAlignCanvas(axisPos, on); } /*! @@ -1138,12 +1106,12 @@ void QwtPlotLayout::setAlignCanvasToScale( int axisPos, bool on ) \return align-canvas-to-axis-scales setting \sa setAlignCanvasToScale(), setAlignCanvasToScale(), setCanvasMargin() */ -bool QwtPlotLayout::alignCanvasToScale( int axisPos ) const +bool QwtPlotLayout::alignCanvasToScale(int axisPos) const { - if ( !QwtAxis::isValid( axisPos ) ) - return false; + if (!QwtAxis::isValid(axisPos)) + return false; - return m_data->engine.alignCanvas( axisPos ); + return m_data->engine.alignCanvas(axisPos); } /*! @@ -1153,9 +1121,9 @@ bool QwtPlotLayout::alignCanvasToScale( int axisPos ) const \param spacing New spacing \sa setCanvasMargin(), spacing() */ -void QwtPlotLayout::setSpacing( int spacing ) +void QwtPlotLayout::setSpacing(int spacing) { - m_data->engine.setSpacing( qMax( 0, spacing ) ); + m_data->engine.setSpacing(qMax(0, spacing)); } /*! @@ -1164,7 +1132,7 @@ void QwtPlotLayout::setSpacing( int spacing ) */ int QwtPlotLayout::spacing() const { - return m_data->engine.spacing(); + return m_data->engine.spacing(); } /*! @@ -1180,40 +1148,38 @@ int QwtPlotLayout::spacing() const \sa QwtPlot::setLegendPosition() */ -void QwtPlotLayout::setLegendPosition( QwtPlot::LegendPosition pos, double ratio ) +void QwtPlotLayout::setLegendPosition(QwtPlot::LegendPosition pos, double ratio) { - if ( ratio > 1.0 ) - ratio = 1.0; + if (ratio > 1.0) + ratio = 1.0; - QwtPlotLayoutPrivate::LayoutEngine& engine = m_data->engine; + QwtPlotLayoutPrivate::LayoutEngine &engine = m_data->engine; - switch ( pos ) - { - case QwtPlot::TopLegend: - case QwtPlot::BottomLegend: - { - if ( ratio <= 0.0 ) - ratio = 0.33; + switch (pos) + { + case QwtPlot::TopLegend: + case QwtPlot::BottomLegend: { + if (ratio <= 0.0) + ratio = 0.33; - engine.setLegendRatio( ratio ); - engine.setLegendPos( pos ); + engine.setLegendRatio(ratio); + engine.setLegendPos(pos); - break; - } - case QwtPlot::LeftLegend: - case QwtPlot::RightLegend: - { - if ( ratio <= 0.0 ) - ratio = 0.5; - - engine.setLegendRatio( ratio ); - engine.setLegendPos( pos ); - - break; - } - default: - break; + break; } + case QwtPlot::LeftLegend: + case QwtPlot::RightLegend: { + if (ratio <= 0.0) + ratio = 0.5; + + engine.setLegendRatio(ratio); + engine.setLegendPos(pos); + + break; + } + default: + break; + } } /*! @@ -1224,9 +1190,9 @@ void QwtPlotLayout::setLegendPosition( QwtPlot::LegendPosition pos, double ratio \sa QwtPlot::setLegendPosition() */ -void QwtPlotLayout::setLegendPosition( QwtPlot::LegendPosition pos ) +void QwtPlotLayout::setLegendPosition(QwtPlot::LegendPosition pos) { - setLegendPosition( pos, 0.0 ); + setLegendPosition(pos, 0.0); } /*! @@ -1236,7 +1202,7 @@ void QwtPlotLayout::setLegendPosition( QwtPlot::LegendPosition pos ) */ QwtPlot::LegendPosition QwtPlotLayout::legendPosition() const { - return m_data->engine.legendPos(); + return m_data->engine.legendPos(); } /*! @@ -1248,9 +1214,9 @@ QwtPlot::LegendPosition QwtPlotLayout::legendPosition() const it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5. */ -void QwtPlotLayout::setLegendRatio( double ratio ) +void QwtPlotLayout::setLegendRatio(double ratio) { - setLegendPosition( legendPosition(), ratio ); + setLegendPosition(legendPosition(), ratio); } /*! @@ -1259,7 +1225,7 @@ void QwtPlotLayout::setLegendRatio( double ratio ) */ double QwtPlotLayout::legendRatio() const { - return m_data->engine.legendRatio(); + return m_data->engine.legendRatio(); } /*! @@ -1270,9 +1236,9 @@ double QwtPlotLayout::legendRatio() const \sa titleRect(), activate() */ -void QwtPlotLayout::setTitleRect( const QRectF& rect ) +void QwtPlotLayout::setTitleRect(const QRectF &rect) { - m_data->titleRect = rect; + m_data->titleRect = rect; } /*! @@ -1281,7 +1247,7 @@ void QwtPlotLayout::setTitleRect( const QRectF& rect ) */ QRectF QwtPlotLayout::titleRect() const { - return m_data->titleRect; + return m_data->titleRect; } /*! @@ -1292,9 +1258,9 @@ QRectF QwtPlotLayout::titleRect() const \sa footerRect(), activate() */ -void QwtPlotLayout::setFooterRect( const QRectF& rect ) +void QwtPlotLayout::setFooterRect(const QRectF &rect) { - m_data->footerRect = rect; + m_data->footerRect = rect; } /*! @@ -1303,7 +1269,7 @@ void QwtPlotLayout::setFooterRect( const QRectF& rect ) */ QRectF QwtPlotLayout::footerRect() const { - return m_data->footerRect; + return m_data->footerRect; } /*! @@ -1316,9 +1282,9 @@ QRectF QwtPlotLayout::footerRect() const \sa legendRect(), activate() */ -void QwtPlotLayout::setLegendRect( const QRectF& rect ) +void QwtPlotLayout::setLegendRect(const QRectF &rect) { - m_data->legendRect = rect; + m_data->legendRect = rect; } /*! @@ -1327,7 +1293,7 @@ void QwtPlotLayout::setLegendRect( const QRectF& rect ) */ QRectF QwtPlotLayout::legendRect() const { - return m_data->legendRect; + return m_data->legendRect; } /*! @@ -1341,10 +1307,10 @@ QRectF QwtPlotLayout::legendRect() const \sa scaleRect(), activate() */ -void QwtPlotLayout::setScaleRect( QwtAxisId axisId, const QRectF& rect ) +void QwtPlotLayout::setScaleRect(QwtAxisId axisId, const QRectF &rect) { - if ( QwtAxis::isValid( axisId ) ) - m_data->scaleRects[axisId] = rect; + if (QwtAxis::isValid(axisId)) + m_data->scaleRects[axisId] = rect; } /*! @@ -1352,12 +1318,12 @@ void QwtPlotLayout::setScaleRect( QwtAxisId axisId, const QRectF& rect ) \return Geometry for the scale \sa activate(), invalidate() */ -QRectF QwtPlotLayout::scaleRect( QwtAxisId axisId ) const +QRectF QwtPlotLayout::scaleRect(QwtAxisId axisId) const { - if ( QwtAxis::isValid( axisId ) ) - return m_data->scaleRects[axisId]; + if (QwtAxis::isValid(axisId)) + return m_data->scaleRects[axisId]; - return QRectF(); + return QRectF(); } /*! @@ -1368,9 +1334,9 @@ QRectF QwtPlotLayout::scaleRect( QwtAxisId axisId ) const \sa canvasRect(), activate() */ -void QwtPlotLayout::setCanvasRect( const QRectF& rect ) +void QwtPlotLayout::setCanvasRect(const QRectF &rect) { - m_data->canvasRect = rect; + m_data->canvasRect = rect; } /*! @@ -1379,7 +1345,7 @@ void QwtPlotLayout::setCanvasRect( const QRectF& rect ) */ QRectF QwtPlotLayout::canvasRect() const { - return m_data->canvasRect; + return m_data->canvasRect; } /*! @@ -1388,11 +1354,11 @@ QRectF QwtPlotLayout::canvasRect() const */ void QwtPlotLayout::invalidate() { - m_data->titleRect = m_data->footerRect = - m_data->legendRect = m_data->canvasRect = QRectF(); + m_data->titleRect = m_data->footerRect = m_data->legendRect + = m_data->canvasRect = QRectF(); - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - m_data->scaleRects[axisPos] = QRect(); + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + m_data->scaleRects[axisPos] = QRect(); } /*! @@ -1401,98 +1367,98 @@ void QwtPlotLayout::invalidate() \sa QwtPlot::minimumSizeHint() */ -QSize QwtPlotLayout::minimumSizeHint( const QwtPlot* plot ) const +QSize QwtPlotLayout::minimumSizeHint(const QwtPlot *plot) const { - LayoutHintData hintData( plot ); + LayoutHintData hintData(plot); - const int xAxesWidth = hintData.xAxesWidth(); - const int yAxesHeight = hintData.yAxesHeight(); + const int xAxesWidth = hintData.xAxesWidth(); + const int yAxesHeight = hintData.yAxesHeight(); - const QWidget* canvas = plot->canvas(); + const QWidget *canvas = plot->canvas(); - const QMargins m = canvas->contentsMargins(); - const QSize minCanvasSize = canvas->minimumSize(); + const QMargins m = canvas->contentsMargins(); + const QSize minCanvasSize = canvas->minimumSize(); - int w = hintData.yAxesWidth(); - int cw = xAxesWidth + m.left() + 1 + m.right() + 1; - w += qMax( cw, minCanvasSize.width() ); + int w = hintData.yAxesWidth(); + int cw = xAxesWidth + m.left() + 1 + m.right() + 1; + w += qMax(cw, minCanvasSize.width()); - int h = hintData.xAxesHeight(); - int ch = yAxesHeight + m.top() + 1 + m.bottom() + 1; - h += qMax( ch, minCanvasSize.height() ); + int h = hintData.xAxesHeight(); + int ch = yAxesHeight + m.top() + 1 + m.bottom() + 1; + h += qMax(ch, minCanvasSize.height()); - const QwtTextLabel* labels[2]; - labels[0] = plot->titleLabel(); - labels[1] = plot->footerLabel(); + const QwtTextLabel *labels[2]; + labels[0] = plot->titleLabel(); + labels[1] = plot->footerLabel(); - for ( int i = 0; i < 2; i++ ) + for (int i = 0; i < 2; i++) + { + const QwtTextLabel *label = labels[i]; + if (label && !label->text().isEmpty()) { - const QwtTextLabel* label = labels[i]; - if ( label && !label->text().isEmpty() ) - { - // we center on the plot canvas. - const bool centerOnCanvas = !( plot->isAxisVisible( QwtAxis::YLeft ) - && plot->isAxisVisible( QwtAxis::YRight ) ); + // we center on the plot canvas. + const bool centerOnCanvas = !(plot->isAxisVisible(QwtAxis::YLeft) + && plot->isAxisVisible(QwtAxis::YRight)); - int labelW = w; - if ( centerOnCanvas ) - { - labelW -= hintData.yAxesWidth(); - } + int labelW = w; + if (centerOnCanvas) + { + labelW -= hintData.yAxesWidth(); + } - int labelH = label->heightForWidth( labelW ); - if ( labelH > labelW ) // Compensate for a long title - { - w = labelW = labelH; - if ( centerOnCanvas ) - w += hintData.yAxesWidth(); + int labelH = label->heightForWidth(labelW); + if (labelH > labelW) // Compensate for a long title + { + w = labelW = labelH; + if (centerOnCanvas) + w += hintData.yAxesWidth(); - labelH = label->heightForWidth( labelW ); - } - h += labelH + spacing(); - } + labelH = label->heightForWidth(labelW); + } + h += labelH + spacing(); } + } - // Compute the legend contribution + // Compute the legend contribution - const QwtAbstractLegend* legend = plot->legend(); - if ( legend && !legend->isEmpty() ) + const QwtAbstractLegend *legend = plot->legend(); + if (legend && !legend->isEmpty()) + { + const QwtPlotLayoutPrivate::LayoutEngine &engine = m_data->engine; + + if (engine.legendPos() == QwtPlot::LeftLegend + || engine.legendPos() == QwtPlot::RightLegend) { - const QwtPlotLayoutPrivate::LayoutEngine& engine = m_data->engine; + int legendW = legend->sizeHint().width(); + int legendH = legend->heightForWidth(legendW); - if ( engine.legendPos() == QwtPlot::LeftLegend - || engine.legendPos() == QwtPlot::RightLegend ) - { - int legendW = legend->sizeHint().width(); - int legendH = legend->heightForWidth( legendW ); + if (legend->frameWidth() > 0) + w += spacing(); - if ( legend->frameWidth() > 0 ) - w += spacing(); + if (legendH > h) + legendW += legend->scrollExtent(Qt::Horizontal); - if ( legendH > h ) - legendW += legend->scrollExtent( Qt::Horizontal ); + if (engine.legendRatio() < 1.0) + legendW = qMin(legendW, int(w / (1.0 - engine.legendRatio()))); - if ( engine.legendRatio() < 1.0 ) - legendW = qMin( legendW, int( w / ( 1.0 - engine.legendRatio() ) ) ); - - w += legendW + spacing(); - } - else - { - int legendW = qMin( legend->sizeHint().width(), w ); - int legendH = legend->heightForWidth( legendW ); - - if ( legend->frameWidth() > 0 ) - h += spacing(); - - if ( engine.legendRatio() < 1.0 ) - legendH = qMin( legendH, int( h / ( 1.0 - engine.legendRatio() ) ) ); - - h += legendH + spacing(); - } + w += legendW + spacing(); } + else + { + int legendW = qMin(legend->sizeHint().width(), w); + int legendH = legend->heightForWidth(legendW); - return QSize( w, h ); + if (legend->frameWidth() > 0) + h += spacing(); + + if (engine.legendRatio() < 1.0) + legendH = qMin(legendH, int(h / (1.0 - engine.legendRatio()))); + + h += legendH + spacing(); + } + } + + return QSize(w, h); } /*! @@ -1505,202 +1471,194 @@ QSize QwtPlotLayout::minimumSizeHint( const QwtPlot* plot ) const \sa invalidate(), titleRect(), footerRect() legendRect(), scaleRect(), canvasRect() */ -void QwtPlotLayout::activate( const QwtPlot* plot, - const QRectF& plotRect, Options options ) +void QwtPlotLayout::activate(const QwtPlot *plot, const QRectF &plotRect, + Options options) { - invalidate(); + invalidate(); - QRectF rect( plotRect ); // undistributed rest of the plot rect + QRectF rect(plotRect); // undistributed rest of the plot rect - // We extract all layout relevant parameters from the widgets, - // and save them to m_data->layoutData. + // We extract all layout relevant parameters from the widgets, + // and save them to m_data->layoutData. - LayoutData layoutData( plot ); + LayoutData layoutData(plot); - QSize legendHint; + QSize legendHint; - if ( !( options & IgnoreLegend ) - && plot->legend() && !plot->legend()->isEmpty() ) + if (!(options & IgnoreLegend) && plot->legend() && !plot->legend()->isEmpty()) + { + legendHint = layoutData.legendData.legendHint(plot->legend(), rect); + + m_data->legendRect = m_data->engine.layoutLegend( + options, layoutData.legendData, rect, legendHint); + + // subtract m_data->legendRect from rect + + const QRegion region(rect.toRect()); + rect = region.subtracted(m_data->legendRect.toRect()).boundingRect(); + + switch (m_data->engine.legendPos()) { - legendHint = layoutData.legendData.legendHint( plot->legend(), rect ); + case QwtPlot::LeftLegend: { + rect.setLeft(rect.left() + spacing()); + break; + } + case QwtPlot::RightLegend: { + rect.setRight(rect.right() - spacing()); + break; + } + case QwtPlot::TopLegend: { + rect.setTop(rect.top() + spacing()); + break; + } + case QwtPlot::BottomLegend: { + rect.setBottom(rect.bottom() - spacing()); + break; + } + } + } - m_data->legendRect = m_data->engine.layoutLegend( - options, layoutData.legendData, rect, legendHint ); + /* + +---+-----------+---+ + | Title | + +---+-----------+---+ + | | Axis | | + +---+-----------+---+ + | A | | A | + | x | Canvas | x | + | i | | i | + | s | | s | + +---+-----------+---+ + | | Axis | | + +---+-----------+---+ + | Footer | + +---+-----------+---+ + */ - // subtract m_data->legendRect from rect + // title, footer and axes include text labels. The height of each + // label depends on its line breaks, that depend on the width + // for the label. A line break in a horizontal text will reduce + // the available width for vertical texts and vice versa. + // layoutDimensions finds the height/width for title, footer and axes + // including all line breaks. - const QRegion region( rect.toRect() ); - rect = region.subtracted( m_data->legendRect.toRect() ).boundingRect(); + using namespace QwtAxis; - switch ( m_data->engine.legendPos() ) + const QwtPlotLayoutPrivate::LayoutEngine::Dimensions dimensions + = m_data->engine.layoutDimensions(options, layoutData, rect); + + if (dimensions.dimTitle > 0) + { + QRectF &labelRect = m_data->titleRect; + + labelRect.setRect(rect.left(), rect.top(), rect.width(), + dimensions.dimTitle); + + rect.setTop(labelRect.bottom() + spacing()); + + if (!layoutData.hasSymmetricYAxes()) + { + // if only one of the y axes is missing we align + // the title centered to the canvas + + labelRect = dimensions.centered(rect, labelRect); + } + } + + if (dimensions.dimFooter > 0) + { + QRectF &labelRect = m_data->footerRect; + + labelRect.setRect(rect.left(), rect.bottom() - dimensions.dimFooter, + rect.width(), dimensions.dimFooter); + + rect.setBottom(labelRect.top() - spacing()); + + if (!layoutData.hasSymmetricYAxes()) + { + // if only one of the y axes is missing we align + // the footer centered to the canvas + + labelRect = dimensions.centered(rect, labelRect); + } + } + + m_data->canvasRect = dimensions.innerRect(rect); + + for (int axisPos = 0; axisPos < AxisPositions; axisPos++) + { + // set the rects for the axes + + const int pos = 0; + { + const QwtAxisId axisId(axisPos); + + if (dimensions.dimAxis(axisId)) + { + const int dim = dimensions.dimAxis(axisId); + + const QRectF &canvasRect = m_data->canvasRect; + + QRectF &scaleRect = m_data->scaleRects[axisId]; + scaleRect = canvasRect; + + switch (axisPos) { - case QwtPlot::LeftLegend: - { - rect.setLeft( rect.left() + spacing() ); - break; - } - case QwtPlot::RightLegend: - { - rect.setRight( rect.right() - spacing() ); - break; - } - case QwtPlot::TopLegend: - { - rect.setTop( rect.top() + spacing() ); - break; - } - case QwtPlot::BottomLegend: - { - rect.setBottom( rect.bottom() - spacing() ); - break; - } + case YLeft: { + scaleRect.setX(canvasRect.left() - pos - dim); + scaleRect.setWidth(dim); + break; + } + case YRight: { + scaleRect.setX(canvasRect.right() + pos); + scaleRect.setWidth(dim); + break; + } + case XBottom: { + scaleRect.setY(canvasRect.bottom() + pos); + scaleRect.setHeight(dim); + break; + } + case XTop: { + scaleRect.setY(canvasRect.top() - pos - dim); + scaleRect.setHeight(dim); + break; + } } + scaleRect = scaleRect.normalized(); + } } + } - /* - +---+-----------+---+ - | Title | - +---+-----------+---+ - | | Axis | | - +---+-----------+---+ - | A | | A | - | x | Canvas | x | - | i | | i | - | s | | s | - +---+-----------+---+ - | | Axis | | - +---+-----------+---+ - | Footer | - +---+-----------+---+ - */ + // +---+-----------+---+ + // | <- Axis -> | + // +-^-+-----------+-^-+ + // | | | | | | + // | | | | + // | A | | A | + // | x | Canvas | x | + // | i | | i | + // | s | | s | + // | | | | + // | | | | | | + // +-V-+-----------+-V-+ + // | <- Axis -> | + // +---+-----------+---+ - // title, footer and axes include text labels. The height of each - // label depends on its line breaks, that depend on the width - // for the label. A line break in a horizontal text will reduce - // the available width for vertical texts and vice versa. - // layoutDimensions finds the height/width for title, footer and axes - // including all line breaks. + // The ticks of the axes - not the labels above - should + // be aligned to the canvas. So we try to use the empty + // corners to extend the axes, so that the label texts + // left/right of the min/max ticks are moved into them. - using namespace QwtAxis; + m_data->engine.alignScales(options, layoutData, m_data->canvasRect, + m_data->scaleRects); - const QwtPlotLayoutPrivate::LayoutEngine::Dimensions dimensions = - m_data->engine.layoutDimensions( options, layoutData, rect ); + if (!m_data->legendRect.isEmpty()) + { + // We prefer to align the legend to the canvas - not to + // the complete plot - if possible. - if ( dimensions.dimTitle > 0 ) - { - QRectF& labelRect = m_data->titleRect; - - labelRect.setRect( rect.left(), rect.top(), rect.width(), dimensions.dimTitle ); - - rect.setTop( labelRect.bottom() + spacing() ); - - if ( !layoutData.hasSymmetricYAxes() ) - { - // if only one of the y axes is missing we align - // the title centered to the canvas - - labelRect = dimensions.centered( rect, labelRect ); - } - } - - if ( dimensions.dimFooter > 0 ) - { - QRectF& labelRect = m_data->footerRect; - - labelRect.setRect( rect.left(), rect.bottom() - dimensions.dimFooter, - rect.width(), dimensions.dimFooter ); - - rect.setBottom( labelRect.top() - spacing() ); - - if ( !layoutData.hasSymmetricYAxes() ) - { - // if only one of the y axes is missing we align - // the footer centered to the canvas - - labelRect = dimensions.centered( rect, labelRect ); - } - } - - m_data->canvasRect = dimensions.innerRect( rect ); - - for ( int axisPos = 0; axisPos < AxisPositions; axisPos++ ) - { - // set the rects for the axes - - const int pos = 0; - { - const QwtAxisId axisId( axisPos ); - - if ( dimensions.dimAxis( axisId ) ) - { - const int dim = dimensions.dimAxis( axisId ); - - const QRectF& canvasRect = m_data->canvasRect; - - QRectF& scaleRect = m_data->scaleRects[axisId]; - scaleRect = canvasRect; - - switch ( axisPos ) - { - case YLeft: - { - scaleRect.setX( canvasRect.left() - pos - dim ); - scaleRect.setWidth( dim ); - break; - } - case YRight: - { - scaleRect.setX( canvasRect.right() + pos ); - scaleRect.setWidth( dim ); - break; - } - case XBottom: - { - scaleRect.setY( canvasRect.bottom() + pos ); - scaleRect.setHeight( dim ); - break; - } - case XTop: - { - scaleRect.setY( canvasRect.top() - pos - dim ); - scaleRect.setHeight( dim ); - break; - } - } - scaleRect = scaleRect.normalized(); - } - } - } - - // +---+-----------+---+ - // | <- Axis -> | - // +-^-+-----------+-^-+ - // | | | | | | - // | | | | - // | A | | A | - // | x | Canvas | x | - // | i | | i | - // | s | | s | - // | | | | - // | | | | | | - // +-V-+-----------+-V-+ - // | <- Axis -> | - // +---+-----------+---+ - - // The ticks of the axes - not the labels above - should - // be aligned to the canvas. So we try to use the empty - // corners to extend the axes, so that the label texts - // left/right of the min/max ticks are moved into them. - - m_data->engine.alignScales( options, layoutData, - m_data->canvasRect, m_data->scaleRects ); - - if ( !m_data->legendRect.isEmpty() ) - { - // We prefer to align the legend to the canvas - not to - // the complete plot - if possible. - - m_data->legendRect = m_data->engine.alignLegend( - legendHint, m_data->canvasRect, m_data->legendRect ); - } + m_data->legendRect = m_data->engine.alignLegend( + legendHint, m_data->canvasRect, m_data->legendRect); + } } diff --git a/libs/qwt/src/qwt_plot_layout.h b/libs/qwt/src/qwt_plot_layout.h index 08902751..c762c358 100644 --- a/libs/qwt/src/qwt_plot_layout.h +++ b/libs/qwt/src/qwt_plot_layout.h @@ -26,86 +26,85 @@ class QWT_EXPORT QwtPlotLayout { - public: +public: + /*! + Options to configure the plot layout engine + \sa activate(), QwtPlotRenderer + */ + enum Option + { + //! Unused + AlignScales = 0x01, + /*! - Options to configure the plot layout engine - \sa activate(), QwtPlotRenderer + Ignore the dimension of the scrollbars. There are no + scrollbars, when the plot is not rendered to widgets. */ - enum Option - { - //! Unused - AlignScales = 0x01, + IgnoreScrollbars = 0x02, - /*! - Ignore the dimension of the scrollbars. There are no - scrollbars, when the plot is not rendered to widgets. - */ - IgnoreScrollbars = 0x02, + //! Ignore all frames. + IgnoreFrames = 0x04, - //! Ignore all frames. - IgnoreFrames = 0x04, + //! Ignore the legend. + IgnoreLegend = 0x08, - //! Ignore the legend. - IgnoreLegend = 0x08, + //! Ignore the title. + IgnoreTitle = 0x10, - //! Ignore the title. - IgnoreTitle = 0x10, + //! Ignore the footer. + IgnoreFooter = 0x20 + }; - //! Ignore the footer. - IgnoreFooter = 0x20 - }; + Q_DECLARE_FLAGS(Options, Option) - Q_DECLARE_FLAGS( Options, Option ) + explicit QwtPlotLayout(); + virtual ~QwtPlotLayout(); - explicit QwtPlotLayout(); - virtual ~QwtPlotLayout(); + void setCanvasMargin(int margin, int axis = -1); + int canvasMargin(int axisId) const; - void setCanvasMargin( int margin, int axis = -1 ); - int canvasMargin( int axisId ) const; + void setAlignCanvasToScales(bool); - void setAlignCanvasToScales( bool ); + void setAlignCanvasToScale(int axisId, bool); + bool alignCanvasToScale(int axisId) const; - void setAlignCanvasToScale( int axisId, bool ); - bool alignCanvasToScale( int axisId ) const; + void setSpacing(int); + int spacing() const; - void setSpacing( int ); - int spacing() const; + void setLegendPosition(QwtPlot::LegendPosition pos, double ratio); + void setLegendPosition(QwtPlot::LegendPosition pos); + QwtPlot::LegendPosition legendPosition() const; - void setLegendPosition( QwtPlot::LegendPosition pos, double ratio ); - void setLegendPosition( QwtPlot::LegendPosition pos ); - QwtPlot::LegendPosition legendPosition() const; + void setLegendRatio(double ratio); + double legendRatio() const; - void setLegendRatio( double ratio ); - double legendRatio() const; + virtual QSize minimumSizeHint(const QwtPlot *) const; - virtual QSize minimumSizeHint( const QwtPlot* ) const; + virtual void activate(const QwtPlot *, const QRectF &plotRect, + Options options = Options()); - virtual void activate( const QwtPlot*, - const QRectF& plotRect, Options options = Options() ); + virtual void invalidate(); - virtual void invalidate(); + QRectF titleRect() const; + QRectF footerRect() const; + QRectF legendRect() const; + QRectF scaleRect(QwtAxisId) const; + QRectF canvasRect() const; - QRectF titleRect() const; - QRectF footerRect() const; - QRectF legendRect() const; - QRectF scaleRect( QwtAxisId ) const; - QRectF canvasRect() const; +protected: + void setTitleRect(const QRectF &); + void setFooterRect(const QRectF &); + void setLegendRect(const QRectF &); + void setScaleRect(QwtAxisId, const QRectF &); + void setCanvasRect(const QRectF &); - protected: +private: + Q_DISABLE_COPY(QwtPlotLayout) - void setTitleRect( const QRectF& ); - void setFooterRect( const QRectF& ); - void setLegendRect( const QRectF& ); - void setScaleRect( QwtAxisId, const QRectF& ); - void setCanvasRect( const QRectF& ); - - private: - Q_DISABLE_COPY(QwtPlotLayout) - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotLayout::Options ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotLayout::Options) #endif diff --git a/libs/qwt/src/qwt_plot_legenditem.cpp b/libs/qwt/src/qwt_plot_legenditem.cpp index 272a7e9d..5e9320b3 100644 --- a/libs/qwt/src/qwt_plot_legenditem.cpp +++ b/libs/qwt/src/qwt_plot_legenditem.cpp @@ -21,177 +21,171 @@ namespace QwtPlotLegendItemPrivate { - class LayoutItem QWT_FINAL : public QLayoutItem - { - public: - LayoutItem( const QwtPlotLegendItem*, const QwtPlotItem* ); - virtual ~LayoutItem(); +class LayoutItem QWT_FINAL : public QLayoutItem +{ +public: + LayoutItem(const QwtPlotLegendItem *, const QwtPlotItem *); + virtual ~LayoutItem(); - const QwtPlotItem* plotItem() const; + const QwtPlotItem *plotItem() const; - void setData( const QwtLegendData& ); - const QwtLegendData& data() const; + void setData(const QwtLegendData &); + const QwtLegendData &data() const; - virtual Qt::Orientations expandingDirections() const QWT_OVERRIDE; - virtual QRect geometry() const QWT_OVERRIDE; - virtual bool hasHeightForWidth() const QWT_OVERRIDE; - virtual int heightForWidth( int ) const QWT_OVERRIDE; - virtual bool isEmpty() const QWT_OVERRIDE; - virtual QSize maximumSize() const QWT_OVERRIDE; - virtual int minimumHeightForWidth( int ) const QWT_OVERRIDE; - virtual QSize minimumSize() const QWT_OVERRIDE; - virtual void setGeometry( const QRect& ) QWT_OVERRIDE; - virtual QSize sizeHint() const QWT_OVERRIDE; + virtual Qt::Orientations expandingDirections() const QWT_OVERRIDE; + virtual QRect geometry() const QWT_OVERRIDE; + virtual bool hasHeightForWidth() const QWT_OVERRIDE; + virtual int heightForWidth(int) const QWT_OVERRIDE; + virtual bool isEmpty() const QWT_OVERRIDE; + virtual QSize maximumSize() const QWT_OVERRIDE; + virtual int minimumHeightForWidth(int) const QWT_OVERRIDE; + virtual QSize minimumSize() const QWT_OVERRIDE; + virtual void setGeometry(const QRect &) QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; - private: +private: + const QwtPlotLegendItem *m_legendItem; + const QwtPlotItem *m_plotItem; + QwtLegendData m_data; - const QwtPlotLegendItem* m_legendItem; - const QwtPlotItem* m_plotItem; - QwtLegendData m_data; + QRect m_rect; +}; - QRect m_rect; - }; - - LayoutItem::LayoutItem( - const QwtPlotLegendItem* legendItem, const QwtPlotItem* plotItem ) - : m_legendItem( legendItem ) - , m_plotItem( plotItem) - { - } - - LayoutItem::~LayoutItem() - { - } - - const QwtPlotItem* LayoutItem::plotItem() const - { - return m_plotItem; - } - - void LayoutItem::setData( const QwtLegendData& data ) - { - m_data = data; - } - - const QwtLegendData& LayoutItem::data() const - { - return m_data; - } - - Qt::Orientations LayoutItem::expandingDirections() const - { - return Qt::Horizontal; - } - - bool LayoutItem::hasHeightForWidth() const - { - return !m_data.title().isEmpty(); - } - - int LayoutItem::minimumHeightForWidth( int w ) const - { - return m_legendItem->heightForWidth( m_data, w ); - } - - int LayoutItem::heightForWidth( int w ) const - { - return m_legendItem->heightForWidth( m_data, w ); - } - - bool LayoutItem::isEmpty() const - { - return false; - } - - QSize LayoutItem::maximumSize() const - { - return QSize( QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX ); - } - - QSize LayoutItem::minimumSize() const - { - return m_legendItem->minimumSize( m_data ); - } - - QSize LayoutItem::sizeHint() const - { - return minimumSize(); - } - - void LayoutItem::setGeometry( const QRect& rect ) - { - m_rect = rect; - } - - QRect LayoutItem::geometry() const - { - return m_rect; - } +LayoutItem::LayoutItem(const QwtPlotLegendItem *legendItem, + const QwtPlotItem *plotItem) + : m_legendItem(legendItem) + , m_plotItem(plotItem) +{ } +LayoutItem::~LayoutItem() {} + +const QwtPlotItem *LayoutItem::plotItem() const +{ + return m_plotItem; +} + +void LayoutItem::setData(const QwtLegendData &data) +{ + m_data = data; +} + +const QwtLegendData &LayoutItem::data() const +{ + return m_data; +} + +Qt::Orientations LayoutItem::expandingDirections() const +{ + return Qt::Horizontal; +} + +bool LayoutItem::hasHeightForWidth() const +{ + return !m_data.title().isEmpty(); +} + +int LayoutItem::minimumHeightForWidth(int w) const +{ + return m_legendItem->heightForWidth(m_data, w); +} + +int LayoutItem::heightForWidth(int w) const +{ + return m_legendItem->heightForWidth(m_data, w); +} + +bool LayoutItem::isEmpty() const +{ + return false; +} + +QSize LayoutItem::maximumSize() const +{ + return QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX); +} + +QSize LayoutItem::minimumSize() const +{ + return m_legendItem->minimumSize(m_data); +} + +QSize LayoutItem::sizeHint() const +{ + return minimumSize(); +} + +void LayoutItem::setGeometry(const QRect &rect) +{ + m_rect = rect; +} + +QRect LayoutItem::geometry() const +{ + return m_rect; +} +} // namespace QwtPlotLegendItemPrivate + class QwtPlotLegendItem::PrivateData { - public: - PrivateData() - : itemMargin( 4 ) - , itemSpacing( 4 ) - , borderRadius( 0.0 ) - , borderPen( Qt::NoPen ) - , backgroundBrush( Qt::NoBrush ) - , backgroundMode( QwtPlotLegendItem::LegendBackground ) - , canvasAlignment( Qt::AlignRight | Qt::AlignBottom ) - { - canvasOffset[ 0 ] = canvasOffset[1] = 10; - layout = new QwtDynGridLayout(); - layout->setMaxColumns( 2 ); +public: + PrivateData() + : itemMargin(4) + , itemSpacing(4) + , borderRadius(0.0) + , borderPen(Qt::NoPen) + , backgroundBrush(Qt::NoBrush) + , backgroundMode(QwtPlotLegendItem::LegendBackground) + , canvasAlignment(Qt::AlignRight | Qt::AlignBottom) + { + canvasOffset[0] = canvasOffset[1] = 10; + layout = new QwtDynGridLayout(); + layout->setMaxColumns(2); - layout->setSpacing( 0 ); - layout->setContentsMargins( 0, 0, 0, 0 ); - } + layout->setSpacing(0); + layout->setContentsMargins(0, 0, 0, 0); + } - ~PrivateData() - { - delete layout; - } + ~PrivateData() { delete layout; } - QFont font; - QPen textPen; - int itemMargin; - int itemSpacing; + QFont font; + QPen textPen; + int itemMargin; + int itemSpacing; - double borderRadius; - QPen borderPen; - QBrush backgroundBrush; - QwtPlotLegendItem::BackgroundMode backgroundMode; + double borderRadius; + QPen borderPen; + QBrush backgroundBrush; + QwtPlotLegendItem::BackgroundMode backgroundMode; - int canvasOffset[2]; - Qt::Alignment canvasAlignment; + int canvasOffset[2]; + Qt::Alignment canvasAlignment; - QMap< const QwtPlotItem*, QList< QwtPlotLegendItemPrivate::LayoutItem* > > map; - QwtDynGridLayout* layout; + QMap> map; + QwtDynGridLayout *layout; }; //! Constructor QwtPlotLegendItem::QwtPlotLegendItem() - : QwtPlotItem( QwtText( "Legend" ) ) + : QwtPlotItem(QwtText("Legend")) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemInterest( QwtPlotItem::LegendInterest, true ); - setZ( 100.0 ); + setItemInterest(QwtPlotItem::LegendInterest, true); + setZ(100.0); } //! Destructor QwtPlotLegendItem::~QwtPlotLegendItem() { - clearLegend(); - delete m_data; + clearLegend(); + delete m_data; } //! \return QwtPlotItem::Rtti_PlotLegend int QwtPlotLegendItem::rtti() const { - return QwtPlotItem::Rtti_PlotLegend; + return QwtPlotItem::Rtti_PlotLegend; } /*! @@ -207,13 +201,13 @@ int QwtPlotLegendItem::rtti() const \note To align a legend with many items horizontally the number of columns need to be limited */ -void QwtPlotLegendItem::setAlignmentInCanvas( Qt::Alignment alignment ) +void QwtPlotLegendItem::setAlignmentInCanvas(Qt::Alignment alignment) { - if ( m_data->canvasAlignment != alignment ) - { - m_data->canvasAlignment = alignment; - itemChanged(); - } + if (m_data->canvasAlignment != alignment) + { + m_data->canvasAlignment = alignment; + itemChanged(); + } } /*! @@ -222,7 +216,7 @@ void QwtPlotLegendItem::setAlignmentInCanvas( Qt::Alignment alignment ) */ Qt::Alignment QwtPlotLegendItem::alignmentInCanvas() const { - return m_data->canvasAlignment; + return m_data->canvasAlignment; } /*! @@ -235,13 +229,13 @@ Qt::Alignment QwtPlotLegendItem::alignmentInCanvas() const \param maxColumns Maximum number of columns. 0 means unlimited. \sa maxColumns(), QwtDynGridLayout::setMaxColumns() */ -void QwtPlotLegendItem::setMaxColumns( uint maxColumns ) +void QwtPlotLegendItem::setMaxColumns(uint maxColumns) { - if ( maxColumns != m_data->layout->maxColumns() ) - { - m_data->layout->setMaxColumns( maxColumns ); - itemChanged(); - } + if (maxColumns != m_data->layout->maxColumns()) + { + m_data->layout->setMaxColumns(maxColumns); + itemChanged(); + } } /*! @@ -250,7 +244,7 @@ void QwtPlotLegendItem::setMaxColumns( uint maxColumns ) */ uint QwtPlotLegendItem::maxColumns() const { - return m_data->layout->maxColumns(); + return m_data->layout->maxColumns(); } /*! @@ -261,16 +255,15 @@ uint QwtPlotLegendItem::maxColumns() const \param margin Margin in pixels \sa margin(), setSpacing(), setItemMargin(), setItemSpacing */ -void QwtPlotLegendItem::setMargin( int margin ) +void QwtPlotLegendItem::setMargin(int margin) { - margin = qMax( margin, 0 ); - if ( margin != this->margin() ) - { - m_data->layout->setContentsMargins( - margin, margin, margin, margin ); + margin = qMax(margin, 0); + if (margin != this->margin()) + { + m_data->layout->setContentsMargins(margin, margin, margin, margin); - itemChanged(); - } + itemChanged(); + } } /*! @@ -279,10 +272,10 @@ void QwtPlotLegendItem::setMargin( int margin ) */ int QwtPlotLegendItem::margin() const { - int left; - m_data->layout->getContentsMargins( &left, NULL, NULL, NULL ); + int left; + m_data->layout->getContentsMargins(&left, NULL, NULL, NULL); - return left; + return left; } /*! @@ -291,14 +284,14 @@ int QwtPlotLegendItem::margin() const \param spacing Spacing in pixels \sa spacing(), setMargin() */ -void QwtPlotLegendItem::setSpacing( int spacing ) +void QwtPlotLegendItem::setSpacing(int spacing) { - spacing = qMax( spacing, 0 ); - if ( spacing != m_data->layout->spacing() ) - { - m_data->layout->setSpacing( spacing ); - itemChanged(); - } + spacing = qMax(spacing, 0); + if (spacing != m_data->layout->spacing()) + { + m_data->layout->setSpacing(spacing); + itemChanged(); + } } /*! @@ -307,7 +300,7 @@ void QwtPlotLegendItem::setSpacing( int spacing ) */ int QwtPlotLegendItem::spacing() const { - return m_data->layout->spacing(); + return m_data->layout->spacing(); } /*! @@ -316,16 +309,16 @@ int QwtPlotLegendItem::spacing() const \param margin Margin \sa itemMargin(), setItemSpacing(), setMargin(), setSpacing() */ -void QwtPlotLegendItem::setItemMargin( int margin ) +void QwtPlotLegendItem::setItemMargin(int margin) { - margin = qMax( margin, 0 ); - if ( margin != m_data->itemMargin ) - { - m_data->itemMargin = margin; + margin = qMax(margin, 0); + if (margin != m_data->itemMargin) + { + m_data->itemMargin = margin; - m_data->layout->invalidate(); - itemChanged(); - } + m_data->layout->invalidate(); + itemChanged(); + } } /*! @@ -334,7 +327,7 @@ void QwtPlotLegendItem::setItemMargin( int margin ) */ int QwtPlotLegendItem::itemMargin() const { - return m_data->itemMargin; + return m_data->itemMargin; } /*! @@ -343,17 +336,16 @@ int QwtPlotLegendItem::itemMargin() const \param spacing Spacing \sa itemSpacing(), setItemMargin(), setMargin(), setSpacing() */ -void QwtPlotLegendItem::setItemSpacing( int spacing ) +void QwtPlotLegendItem::setItemSpacing(int spacing) { - spacing = qMax( spacing, 0 ); - if ( spacing != m_data->itemSpacing ) - { - m_data->itemSpacing = spacing; - - m_data->layout->invalidate(); - itemChanged(); - } + spacing = qMax(spacing, 0); + if (spacing != m_data->itemSpacing) + { + m_data->itemSpacing = spacing; + m_data->layout->invalidate(); + itemChanged(); + } } /*! @@ -362,7 +354,7 @@ void QwtPlotLegendItem::setItemSpacing( int spacing ) */ int QwtPlotLegendItem::itemSpacing() const { - return m_data->itemSpacing; + return m_data->itemSpacing; } /*! @@ -371,15 +363,15 @@ int QwtPlotLegendItem::itemSpacing() const \param font Legend font \sa font() */ -void QwtPlotLegendItem::setFont( const QFont& font ) +void QwtPlotLegendItem::setFont(const QFont &font) { - if ( font != m_data->font ) - { - m_data->font = font; + if (font != m_data->font) + { + m_data->font = font; - m_data->layout->invalidate(); - itemChanged(); - } + m_data->layout->invalidate(); + itemChanged(); + } } /*! @@ -388,7 +380,7 @@ void QwtPlotLegendItem::setFont( const QFont& font ) */ QFont QwtPlotLegendItem::font() const { - return m_data->font; + return m_data->font; } /*! @@ -402,36 +394,36 @@ QFont QwtPlotLegendItem::font() const \param numPixels Distance in pixels \sa setMargin() */ -void QwtPlotLegendItem::setOffsetInCanvas( - Qt::Orientations orientations, int numPixels ) +void QwtPlotLegendItem::setOffsetInCanvas(Qt::Orientations orientations, + int numPixels) { - if ( numPixels < 0 ) - numPixels = -1; + if (numPixels < 0) + numPixels = -1; - bool isChanged = false; + bool isChanged = false; - int* offset = m_data->canvasOffset; + int *offset = m_data->canvasOffset; - if ( orientations & Qt::Horizontal ) + if (orientations & Qt::Horizontal) + { + if (numPixels != offset[0]) { - if ( numPixels != offset[0] ) - { - offset[0] = numPixels; - isChanged = true; - } + offset[0] = numPixels; + isChanged = true; } + } - if ( orientations & Qt::Vertical ) + if (orientations & Qt::Vertical) + { + if (numPixels != offset[1]) { - if ( numPixels != offset[1] ) - { - offset[1] = numPixels; - isChanged = true; - } + offset[1] = numPixels; + isChanged = true; } + } - if ( isChanged ) - itemChanged(); + if (isChanged) + itemChanged(); } /*! @@ -441,11 +433,10 @@ void QwtPlotLegendItem::setOffsetInCanvas( \return Distance between the legend and the canvas border \sa setOffsetInCanvas() */ -int QwtPlotLegendItem::offsetInCanvas( - Qt::Orientation orientation ) const +int QwtPlotLegendItem::offsetInCanvas(Qt::Orientation orientation) const { - const int index = ( orientation == Qt::Vertical ) ? 1 : 0; - return m_data->canvasOffset[index]; + const int index = (orientation == Qt::Vertical) ? 1 : 0; + return m_data->canvasOffset[index]; } /*! @@ -454,15 +445,15 @@ int QwtPlotLegendItem::offsetInCanvas( \param radius A value <= 0 defines a rectangular border \sa borderRadius(), setBorderPen() */ -void QwtPlotLegendItem::setBorderRadius( double radius ) +void QwtPlotLegendItem::setBorderRadius(double radius) { - radius = qwtMaxF( 0.0, radius ); + radius = qwtMaxF(0.0, radius); - if ( radius != m_data->borderRadius ) - { - m_data->borderRadius = radius; - itemChanged(); - } + if (radius != m_data->borderRadius) + { + m_data->borderRadius = radius; + itemChanged(); + } } /*! @@ -471,7 +462,7 @@ void QwtPlotLegendItem::setBorderRadius( double radius ) */ double QwtPlotLegendItem::borderRadius() const { - return m_data->borderRadius; + return m_data->borderRadius; } /*! @@ -480,13 +471,13 @@ double QwtPlotLegendItem::borderRadius() const \param pen Border pen \sa borderPen(), setBackgroundBrush() */ -void QwtPlotLegendItem::setBorderPen( const QPen& pen ) +void QwtPlotLegendItem::setBorderPen(const QPen &pen) { - if ( m_data->borderPen != pen ) - { - m_data->borderPen = pen; - itemChanged(); - } + if (m_data->borderPen != pen) + { + m_data->borderPen = pen; + itemChanged(); + } } /*! @@ -495,7 +486,7 @@ void QwtPlotLegendItem::setBorderPen( const QPen& pen ) */ QPen QwtPlotLegendItem::borderPen() const { - return m_data->borderPen; + return m_data->borderPen; } /*! @@ -506,13 +497,13 @@ QPen QwtPlotLegendItem::borderPen() const \param brush Brush \sa backgroundBrush(), setBackgroundMode(), drawBackground() */ -void QwtPlotLegendItem::setBackgroundBrush( const QBrush& brush ) +void QwtPlotLegendItem::setBackgroundBrush(const QBrush &brush) { - if ( m_data->backgroundBrush != brush ) - { - m_data->backgroundBrush = brush; - itemChanged(); - } + if (m_data->backgroundBrush != brush) + { + m_data->backgroundBrush = brush; + itemChanged(); + } } /*! @@ -521,7 +512,7 @@ void QwtPlotLegendItem::setBackgroundBrush( const QBrush& brush ) */ QBrush QwtPlotLegendItem::backgroundBrush() const { - return m_data->backgroundBrush; + return m_data->backgroundBrush; } /*! @@ -534,13 +525,13 @@ QBrush QwtPlotLegendItem::backgroundBrush() const \sa backgroundMode(), setBackgroundBrush(), drawBackground() */ -void QwtPlotLegendItem::setBackgroundMode( BackgroundMode mode ) +void QwtPlotLegendItem::setBackgroundMode(BackgroundMode mode) { - if ( mode != m_data->backgroundMode ) - { - m_data->backgroundMode = mode; - itemChanged(); - } + if (mode != m_data->backgroundMode) + { + m_data->backgroundMode = mode; + itemChanged(); + } } /*! @@ -549,7 +540,7 @@ void QwtPlotLegendItem::setBackgroundMode( BackgroundMode mode ) */ QwtPlotLegendItem::BackgroundMode QwtPlotLegendItem::backgroundMode() const { - return m_data->backgroundMode; + return m_data->backgroundMode; } /*! @@ -558,13 +549,13 @@ QwtPlotLegendItem::BackgroundMode QwtPlotLegendItem::backgroundMode() const \param pen Text pen \sa textPen(), setFont() */ -void QwtPlotLegendItem::setTextPen( const QPen& pen ) +void QwtPlotLegendItem::setTextPen(const QPen &pen) { - if ( m_data->textPen != pen ) - { - m_data->textPen = pen; - itemChanged(); - } + if (m_data->textPen != pen) + { + m_data->textPen = pen; + itemChanged(); + } } /*! @@ -573,7 +564,7 @@ void QwtPlotLegendItem::setTextPen( const QPen& pen ) */ QPen QwtPlotLegendItem::textPen() const { - return m_data->textPen; + return m_data->textPen; } /*! @@ -584,38 +575,39 @@ QPen QwtPlotLegendItem::textPen() const \param yMap y Scale Map \param canvasRect Contents rectangle of the canvas in painter coordinates */ -void QwtPlotLegendItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotLegendItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - Q_UNUSED( xMap ); - Q_UNUSED( yMap ); + Q_UNUSED(xMap); + Q_UNUSED(yMap); - m_data->layout->setGeometry( geometry( canvasRect ) ); - if ( m_data->layout->geometry().isEmpty() ) - { - // don't draw a legend when having no content - return; - } + m_data->layout->setGeometry(geometry(canvasRect)); + if (m_data->layout->geometry().isEmpty()) + { + // don't draw a legend when having no content + return; + } - if ( m_data->backgroundMode == QwtPlotLegendItem::LegendBackground ) - drawBackground( painter, m_data->layout->geometry() ); + if (m_data->backgroundMode == QwtPlotLegendItem::LegendBackground) + drawBackground(painter, m_data->layout->geometry()); - for ( int i = 0; i < m_data->layout->count(); i++ ) - { - const QwtPlotLegendItemPrivate::LayoutItem* layoutItem = - static_cast< QwtPlotLegendItemPrivate::LayoutItem* >( m_data->layout->itemAt( i ) ); + for (int i = 0; i < m_data->layout->count(); i++) + { + const QwtPlotLegendItemPrivate::LayoutItem *layoutItem + = static_cast( + m_data->layout->itemAt(i)); - if ( m_data->backgroundMode == QwtPlotLegendItem::ItemBackground ) - drawBackground( painter, layoutItem->geometry() ); + if (m_data->backgroundMode == QwtPlotLegendItem::ItemBackground) + drawBackground(painter, layoutItem->geometry()); - painter->save(); + painter->save(); - drawLegendData( painter, layoutItem->plotItem(), - layoutItem->data(), layoutItem->geometry() ); + drawLegendData(painter, layoutItem->plotItem(), layoutItem->data(), + layoutItem->geometry()); - painter->restore(); - } + painter->restore(); + } } /*! @@ -627,18 +619,18 @@ void QwtPlotLegendItem::draw( QPainter* painter, \sa setBorderRadius(), setBorderPen(), setBackgroundBrush(), setBackgroundMode() */ -void QwtPlotLegendItem::drawBackground( - QPainter* painter, const QRectF& rect ) const +void QwtPlotLegendItem::drawBackground(QPainter *painter, + const QRectF &rect) const { - painter->save(); + painter->save(); - painter->setPen( m_data->borderPen ); - painter->setBrush( m_data->backgroundBrush ); + painter->setPen(m_data->borderPen); + painter->setBrush(m_data->backgroundBrush); - const double radius = m_data->borderRadius; - painter->drawRoundedRect( rect, radius, radius ); + const double radius = m_data->borderRadius; + painter->drawRoundedRect(rect, radius, radius); - painter->restore(); + painter->restore(); } /*! @@ -647,44 +639,44 @@ void QwtPlotLegendItem::drawBackground( \param canvasRect Geometry of the canvas \return Geometry of the legend */ -QRect QwtPlotLegendItem::geometry( const QRectF& canvasRect ) const +QRect QwtPlotLegendItem::geometry(const QRectF &canvasRect) const { - QRect rect; - rect.setSize( m_data->layout->sizeHint() ); + QRect rect; + rect.setSize(m_data->layout->sizeHint()); - if ( m_data->canvasAlignment & Qt::AlignHCenter ) - { - int x = qRound( canvasRect.center().x() ); - rect.moveCenter( QPoint( x, rect.center().y() ) ); - } - else if ( m_data->canvasAlignment & Qt::AlignRight ) - { - const int offset = offsetInCanvas( Qt::Horizontal ); - rect.moveRight( qwtFloor( canvasRect.right() - offset ) ); - } - else - { - const int offset = offsetInCanvas( Qt::Horizontal ); - rect.moveLeft( qwtCeil( canvasRect.left() + offset ) ); - } + if (m_data->canvasAlignment & Qt::AlignHCenter) + { + int x = qRound(canvasRect.center().x()); + rect.moveCenter(QPoint(x, rect.center().y())); + } + else if (m_data->canvasAlignment & Qt::AlignRight) + { + const int offset = offsetInCanvas(Qt::Horizontal); + rect.moveRight(qwtFloor(canvasRect.right() - offset)); + } + else + { + const int offset = offsetInCanvas(Qt::Horizontal); + rect.moveLeft(qwtCeil(canvasRect.left() + offset)); + } - if ( m_data->canvasAlignment & Qt::AlignVCenter ) - { - int y = qRound( canvasRect.center().y() ); - rect.moveCenter( QPoint( rect.center().x(), y ) ); - } - else if ( m_data->canvasAlignment & Qt::AlignBottom ) - { - const int offset = offsetInCanvas( Qt::Vertical ); - rect.moveBottom( qwtFloor( canvasRect.bottom() - offset ) ); - } - else - { - const int offset = offsetInCanvas( Qt::Vertical ); - rect.moveTop( qwtCeil( canvasRect.top() + offset ) ); - } + if (m_data->canvasAlignment & Qt::AlignVCenter) + { + int y = qRound(canvasRect.center().y()); + rect.moveCenter(QPoint(rect.center().x(), y)); + } + else if (m_data->canvasAlignment & Qt::AlignBottom) + { + const int offset = offsetInCanvas(Qt::Vertical); + rect.moveBottom(qwtFloor(canvasRect.bottom() - offset)); + } + else + { + const int offset = offsetInCanvas(Qt::Vertical); + rect.moveTop(qwtCeil(canvasRect.top() + offset)); + } - return rect; + return rect; } /*! @@ -694,79 +686,80 @@ QRect QwtPlotLegendItem::geometry( const QRectF& canvasRect ) const \param plotItem Plot item \param data Attributes of the legend entries */ -void QwtPlotLegendItem::updateLegend( const QwtPlotItem* plotItem, - const QList< QwtLegendData >& data ) +void QwtPlotLegendItem::updateLegend(const QwtPlotItem *plotItem, + const QList &data) { - if ( plotItem == NULL ) - return; + if (plotItem == NULL) + return; - QList< QwtPlotLegendItemPrivate::LayoutItem* > layoutItems; + QList layoutItems; - QMap< const QwtPlotItem*, QList< QwtPlotLegendItemPrivate::LayoutItem* > >::const_iterator it = - m_data->map.constFind( plotItem ); - if ( it != m_data->map.constEnd() ) - layoutItems = it.value(); + QMap>::const_iterator it + = m_data->map.constFind(plotItem); + if (it != m_data->map.constEnd()) + layoutItems = it.value(); - bool changed = false; + bool changed = false; - if ( data.size() != layoutItems.size() ) + if (data.size() != layoutItems.size()) + { + changed = true; + + for (int i = 0; i < layoutItems.size(); i++) { - changed = true; - - for ( int i = 0; i < layoutItems.size(); i++ ) - { - m_data->layout->removeItem( layoutItems[i] ); - delete layoutItems[i]; - } - layoutItems.clear(); - - if ( it != m_data->map.constEnd() ) - m_data->map.remove( plotItem ); - - if ( !data.isEmpty() ) - { - layoutItems.reserve( data.size() ); - - for ( int i = 0; i < data.size(); i++ ) - { - QwtPlotLegendItemPrivate::LayoutItem* layoutItem = - new QwtPlotLegendItemPrivate::LayoutItem( this, plotItem ); - m_data->layout->addItem( layoutItem ); - layoutItems += layoutItem; - } - - m_data->map.insert( plotItem, layoutItems ); - } + m_data->layout->removeItem(layoutItems[i]); + delete layoutItems[i]; } + layoutItems.clear(); - for ( int i = 0; i < data.size(); i++ ) + if (it != m_data->map.constEnd()) + m_data->map.remove(plotItem); + + if (!data.isEmpty()) { - if ( layoutItems[i]->data().values() != data[i].values() ) - { - layoutItems[i]->setData( data[i] ); - changed = true; - } - } + layoutItems.reserve(data.size()); - if ( changed ) - { - m_data->layout->invalidate(); - itemChanged(); + for (int i = 0; i < data.size(); i++) + { + QwtPlotLegendItemPrivate::LayoutItem *layoutItem + = new QwtPlotLegendItemPrivate::LayoutItem(this, plotItem); + m_data->layout->addItem(layoutItem); + layoutItems += layoutItem; + } + + m_data->map.insert(plotItem, layoutItems); } + } + + for (int i = 0; i < data.size(); i++) + { + if (layoutItems[i]->data().values() != data[i].values()) + { + layoutItems[i]->setData(data[i]); + changed = true; + } + } + + if (changed) + { + m_data->layout->invalidate(); + itemChanged(); + } } //! Remove all items from the legend void QwtPlotLegendItem::clearLegend() { - if ( !m_data->map.isEmpty() ) - { - m_data->map.clear(); + if (!m_data->map.isEmpty()) + { + m_data->map.clear(); - for ( int i = m_data->layout->count() - 1; i >= 0; i-- ) - delete m_data->layout->takeAt( i ); + for (int i = m_data->layout->count() - 1; i >= 0; i--) + delete m_data->layout->takeAt(i); - itemChanged(); - } + itemChanged(); + } } /*! @@ -777,41 +770,41 @@ void QwtPlotLegendItem::clearLegend() \param data Attributes of the legend entry \param rect Bounding rectangle for the entry */ -void QwtPlotLegendItem::drawLegendData( QPainter* painter, - const QwtPlotItem* plotItem, const QwtLegendData& data, - const QRectF& rect ) const +void QwtPlotLegendItem::drawLegendData(QPainter *painter, + const QwtPlotItem *plotItem, + const QwtLegendData &data, + const QRectF &rect) const { - Q_UNUSED( plotItem ); + Q_UNUSED(plotItem); - const int m = m_data->itemMargin; - const QRectF r = rect.toRect().adjusted( m, m, -m, -m ); + const int m = m_data->itemMargin; + const QRectF r = rect.toRect().adjusted(m, m, -m, -m); - painter->setClipRect( r, Qt::IntersectClip ); + painter->setClipRect(r, Qt::IntersectClip); - int titleOff = 0; + int titleOff = 0; - const QwtGraphic graphic = data.icon(); - if ( !graphic.isEmpty() ) - { - QRectF iconRect( r.topLeft(), graphic.defaultSize() ); + const QwtGraphic graphic = data.icon(); + if (!graphic.isEmpty()) + { + QRectF iconRect(r.topLeft(), graphic.defaultSize()); - iconRect.moveCenter( - QPoint( iconRect.center().x(), rect.center().y() ) ); + iconRect.moveCenter(QPoint(iconRect.center().x(), rect.center().y())); - graphic.render( painter, iconRect, Qt::KeepAspectRatio ); + graphic.render(painter, iconRect, Qt::KeepAspectRatio); - titleOff += iconRect.width() + m_data->itemSpacing; - } + titleOff += iconRect.width() + m_data->itemSpacing; + } - const QwtText text = data.title(); - if ( !text.isEmpty() ) - { - painter->setPen( textPen() ); - painter->setFont( font() ); + const QwtText text = data.title(); + if (!text.isEmpty()) + { + painter->setPen(textPen()); + painter->setFont(font()); - const QRectF textRect = r.adjusted( titleOff, 0, 0, 0 ); - text.draw( painter, textRect ); - } + const QRectF textRect = r.adjusted(titleOff, 0, 0, 0); + text.draw(painter, textRect); + } } /*! @@ -820,38 +813,38 @@ void QwtPlotLegendItem::drawLegendData( QPainter* painter, \param data Attributes of the legend entry \return Minimum size */ -QSize QwtPlotLegendItem::minimumSize( const QwtLegendData& data ) const +QSize QwtPlotLegendItem::minimumSize(const QwtLegendData &data) const { - QSize size( 2 * m_data->itemMargin, 2 * m_data->itemMargin ); + QSize size(2 * m_data->itemMargin, 2 * m_data->itemMargin); - if ( !data.isValid() ) - return size; - - const QwtGraphic graphic = data.icon(); - const QwtText text = data.title(); - - int w = 0; - int h = 0; - - if ( !graphic.isNull() ) - { - w = graphic.width(); - h = graphic.height(); - } - - if ( !text.isEmpty() ) - { - const QSizeF sz = text.textSize( font() ); - - w += qwtCeil( sz.width() ); - h = qMax( h, qwtCeil( sz.height() ) ); - } - - if ( graphic.width() > 0 && !text.isEmpty() ) - w += m_data->itemSpacing; - - size += QSize( w, h ); + if (!data.isValid()) return size; + + const QwtGraphic graphic = data.icon(); + const QwtText text = data.title(); + + int w = 0; + int h = 0; + + if (!graphic.isNull()) + { + w = graphic.width(); + h = graphic.height(); + } + + if (!text.isEmpty()) + { + const QSizeF sz = text.textSize(font()); + + w += qwtCeil(sz.width()); + h = qMax(h, qwtCeil(sz.height())); + } + + if (graphic.width() > 0 && !text.isEmpty()) + w += m_data->itemSpacing; + + size += QSize(w, h); + return size; } /*! @@ -859,54 +852,55 @@ QSize QwtPlotLegendItem::minimumSize( const QwtLegendData& data ) const \param data Attributes of the legend entry \param width Width */ -int QwtPlotLegendItem::heightForWidth( - const QwtLegendData& data, int width ) const +int QwtPlotLegendItem::heightForWidth(const QwtLegendData &data, + int width) const { - width -= 2 * m_data->itemMargin; + width -= 2 * m_data->itemMargin; - const QwtGraphic graphic = data.icon(); - const QwtText text = data.title(); + const QwtGraphic graphic = data.icon(); + const QwtText text = data.title(); - if ( text.isEmpty() ) - return graphic.height(); + if (text.isEmpty()) + return graphic.height(); - if ( graphic.width() > 0 ) - width -= graphic.width() + m_data->itemSpacing; + if (graphic.width() > 0) + width -= graphic.width() + m_data->itemSpacing; - int h = text.heightForWidth( width, font() ); - h += 2 * m_data->itemMargin; + int h = text.heightForWidth(width, font()); + h += 2 * m_data->itemMargin; - return qMax( graphic.height(), h ); + return qMax(graphic.height(), h); } /*! \return All plot items with an entry on the legend \note A plot item might have more than one entry on the legend */ -QList< const QwtPlotItem* > QwtPlotLegendItem::plotItems() const +QList QwtPlotLegendItem::plotItems() const { - return m_data->map.keys(); + return m_data->map.keys(); } /*! \return Geometries of the items of a plot item \note Usually a plot item has only one entry on the legend */ -QList< QRect > QwtPlotLegendItem::legendGeometries( - const QwtPlotItem* plotItem ) const +QList +QwtPlotLegendItem::legendGeometries(const QwtPlotItem *plotItem) const { - QList< QwtPlotLegendItemPrivate::LayoutItem* > layoutItems; + QList layoutItems; - QMap< const QwtPlotItem*, QList< QwtPlotLegendItemPrivate::LayoutItem* > >::const_iterator it = - m_data->map.constFind( plotItem ); - if ( it != m_data->map.constEnd() ) - layoutItems = it.value(); + QMap>::const_iterator it + = m_data->map.constFind(plotItem); + if (it != m_data->map.constEnd()) + layoutItems = it.value(); - QList< QRect > geometries; - geometries.reserve(layoutItems.size() ); + QList geometries; + geometries.reserve(layoutItems.size()); - for ( int i = 0; i < layoutItems.size(); i++ ) - geometries += layoutItems[i]->geometry(); + for (int i = 0; i < layoutItems.size(); i++) + geometries += layoutItems[i]->geometry(); - return geometries; + return geometries; } diff --git a/libs/qwt/src/qwt_plot_legenditem.h b/libs/qwt/src/qwt_plot_legenditem.h index 1be4286e..c799123d 100644 --- a/libs/qwt/src/qwt_plot_legenditem.h +++ b/libs/qwt/src/qwt_plot_legenditem.h @@ -40,96 +40,96 @@ class QFont; class QWT_EXPORT QwtPlotLegendItem : public QwtPlotItem { - public: - /*! - \brief Background mode +public: + /*! + \brief Background mode - Depending on the mode the complete legend or each item - might have an background. + Depending on the mode the complete legend or each item + might have an background. - The default setting is LegendBackground. + The default setting is LegendBackground. - \sa setBackgroundMode(), setBackgroundBrush(), drawBackground() - */ - enum BackgroundMode - { - //! The legend has a background - LegendBackground, + \sa setBackgroundMode(), setBackgroundBrush(), drawBackground() + */ + enum BackgroundMode + { + //! The legend has a background + LegendBackground, - //! Each item has a background - ItemBackground - }; + //! Each item has a background + ItemBackground + }; - explicit QwtPlotLegendItem(); - virtual ~QwtPlotLegendItem(); + explicit QwtPlotLegendItem(); + virtual ~QwtPlotLegendItem(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setAlignmentInCanvas( Qt::Alignment ); - Qt::Alignment alignmentInCanvas() const; + void setAlignmentInCanvas(Qt::Alignment); + Qt::Alignment alignmentInCanvas() const; - void setOffsetInCanvas( Qt::Orientations, int numPixels ); - int offsetInCanvas( Qt::Orientation ) const; + void setOffsetInCanvas(Qt::Orientations, int numPixels); + int offsetInCanvas(Qt::Orientation) const; - void setMaxColumns( uint ); - uint maxColumns() const; + void setMaxColumns(uint); + uint maxColumns() const; - void setMargin( int ); - int margin() const; + void setMargin(int); + int margin() const; - void setSpacing( int ); - int spacing() const; + void setSpacing(int); + int spacing() const; - void setItemMargin( int ); - int itemMargin() const; + void setItemMargin(int); + int itemMargin() const; - void setItemSpacing( int ); - int itemSpacing() const; + void setItemSpacing(int); + int itemSpacing() const; - void setFont( const QFont& ); - QFont font() const; + void setFont(const QFont &); + QFont font() const; - void setBorderRadius( double ); - double borderRadius() const; + void setBorderRadius(double); + double borderRadius() const; - void setBorderPen( const QPen& ); - QPen borderPen() const; + void setBorderPen(const QPen &); + QPen borderPen() const; - void setBackgroundBrush( const QBrush& ); - QBrush backgroundBrush() const; + void setBackgroundBrush(const QBrush &); + QBrush backgroundBrush() const; - void setBackgroundMode( BackgroundMode ); - BackgroundMode backgroundMode() const; + void setBackgroundMode(BackgroundMode); + BackgroundMode backgroundMode() const; - void setTextPen( const QPen& ); - QPen textPen() const; + void setTextPen(const QPen &); + QPen textPen() const; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - void clearLegend(); + void clearLegend(); - virtual void updateLegend( const QwtPlotItem*, - const QList< QwtLegendData >& ) QWT_OVERRIDE; + virtual void updateLegend(const QwtPlotItem *, + const QList &) QWT_OVERRIDE; - virtual QRect geometry( const QRectF& canvasRect ) const; + virtual QRect geometry(const QRectF &canvasRect) const; - virtual QSize minimumSize( const QwtLegendData& ) const; - virtual int heightForWidth( const QwtLegendData&, int width ) const; + virtual QSize minimumSize(const QwtLegendData &) const; + virtual int heightForWidth(const QwtLegendData &, int width) const; - QList< const QwtPlotItem* > plotItems() const; - QList< QRect > legendGeometries( const QwtPlotItem* ) const; + QList plotItems() const; + QList legendGeometries(const QwtPlotItem *) const; - protected: - virtual void drawLegendData( QPainter*, - const QwtPlotItem*, const QwtLegendData&, const QRectF& ) const; +protected: + virtual void drawLegendData(QPainter *, const QwtPlotItem *, + const QwtLegendData &, const QRectF &) const; - virtual void drawBackground( QPainter*, const QRectF& rect ) const; + virtual void drawBackground(QPainter *, const QRectF &rect) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_magnifier.cpp b/libs/qwt/src/qwt_plot_magnifier.cpp index a1f0d278..cbf5ee64 100644 --- a/libs/qwt/src/qwt_plot_magnifier.cpp +++ b/libs/qwt/src/qwt_plot_magnifier.cpp @@ -13,30 +13,30 @@ class QwtPlotMagnifier::PrivateData { - public: - PrivateData() - { - for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ ) - isAxisEnabled[axis] = true; - } +public: + PrivateData() + { + for (int axis = 0; axis < QwtAxis::AxisPositions; axis++) + isAxisEnabled[axis] = true; + } - bool isAxisEnabled[QwtAxis::AxisPositions]; + bool isAxisEnabled[QwtAxis::AxisPositions]; }; /*! Constructor \param canvas Plot canvas to be magnified */ -QwtPlotMagnifier::QwtPlotMagnifier( QWidget* canvas ) - : QwtMagnifier( canvas ) +QwtPlotMagnifier::QwtPlotMagnifier(QWidget *canvas) + : QwtMagnifier(canvas) { - m_data = new PrivateData(); + m_data = new PrivateData(); } //! Destructor QwtPlotMagnifier::~QwtPlotMagnifier() { - delete m_data; + delete m_data; } /*! @@ -50,10 +50,10 @@ QwtPlotMagnifier::~QwtPlotMagnifier() \sa isAxisEnabled() */ -void QwtPlotMagnifier::setAxisEnabled( QwtAxisId axisId, bool on ) +void QwtPlotMagnifier::setAxisEnabled(QwtAxisId axisId, bool on) { - if ( QwtAxis::isValid( axisId ) ) - m_data->isAxisEnabled[axisId] = on; + if (QwtAxis::isValid(axisId)) + m_data->isAxisEnabled[axisId] = on; } /*! @@ -64,109 +64,109 @@ void QwtPlotMagnifier::setAxisEnabled( QwtAxisId axisId, bool on ) \sa setAxisEnabled() */ -bool QwtPlotMagnifier::isAxisEnabled( QwtAxisId axisId ) const +bool QwtPlotMagnifier::isAxisEnabled(QwtAxisId axisId) const { - if ( QwtAxis::isValid( axisId ) ) - return m_data->isAxisEnabled[axisId]; + if (QwtAxis::isValid(axisId)) + return m_data->isAxisEnabled[axisId]; - return true; + return true; } //! Return observed plot canvas -QWidget* QwtPlotMagnifier::canvas() +QWidget *QwtPlotMagnifier::canvas() { - return parentWidget(); + return parentWidget(); } //! Return Observed plot canvas -const QWidget* QwtPlotMagnifier::canvas() const +const QWidget *QwtPlotMagnifier::canvas() const { - return parentWidget(); + return parentWidget(); } //! Return plot widget, containing the observed plot canvas -QwtPlot* QwtPlotMagnifier::plot() +QwtPlot *QwtPlotMagnifier::plot() { - QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< QwtPlot* >( w ); + return qobject_cast(w); } //! Return plot widget, containing the observed plot canvas -const QwtPlot* QwtPlotMagnifier::plot() const +const QwtPlot *QwtPlotMagnifier::plot() const { - const QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + const QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< const QwtPlot* >( w ); + return qobject_cast(w); } /*! Zoom in/out the axes scales \param factor A value < 1.0 zooms in, a value > 1.0 zooms out. */ -void QwtPlotMagnifier::rescale( double factor ) +void QwtPlotMagnifier::rescale(double factor) { - QwtPlot* plt = plot(); - if ( plt == NULL ) - return; + QwtPlot *plt = plot(); + if (plt == NULL) + return; - factor = qAbs( factor ); - if ( factor == 1.0 || factor == 0.0 ) - return; + factor = qAbs(factor); + if (factor == 1.0 || factor == 0.0) + return; - bool doReplot = false; + bool doReplot = false; - const bool autoReplot = plt->autoReplot(); - plt->setAutoReplot( false ); + const bool autoReplot = plt->autoReplot(); + plt->setAutoReplot(false); - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { + const QwtAxisId axisId(axisPos); + + if (isAxisEnabled(axisId)) + { + const QwtScaleMap scaleMap = plt->canvasMap(axisId); + + double v1 = scaleMap.s1(); + double v2 = scaleMap.s2(); + + if (scaleMap.transformation()) { - const QwtAxisId axisId( axisPos ); + // the coordinate system of the paint device is always linear - if ( isAxisEnabled( axisId ) ) - { - const QwtScaleMap scaleMap = plt->canvasMap( axisId ); - - double v1 = scaleMap.s1(); - double v2 = scaleMap.s2(); - - if ( scaleMap.transformation() ) - { - // the coordinate system of the paint device is always linear - - v1 = scaleMap.transform( v1 ); // scaleMap.p1() - v2 = scaleMap.transform( v2 ); // scaleMap.p2() - } - - const double center = 0.5 * ( v1 + v2 ); - const double width_2 = 0.5 * ( v2 - v1 ) * factor; - - v1 = center - width_2; - v2 = center + width_2; - - if ( scaleMap.transformation() ) - { - v1 = scaleMap.invTransform( v1 ); - v2 = scaleMap.invTransform( v2 ); - } - - plt->setAxisScale( axisId, v1, v2 ); - doReplot = true; - } + v1 = scaleMap.transform(v1); // scaleMap.p1() + v2 = scaleMap.transform(v2); // scaleMap.p2() } + + const double center = 0.5 * (v1 + v2); + const double width_2 = 0.5 * (v2 - v1) * factor; + + v1 = center - width_2; + v2 = center + width_2; + + if (scaleMap.transformation()) + { + v1 = scaleMap.invTransform(v1); + v2 = scaleMap.invTransform(v2); + } + + plt->setAxisScale(axisId, v1, v2); + doReplot = true; + } } + } - plt->setAutoReplot( autoReplot ); + plt->setAutoReplot(autoReplot); - if ( doReplot ) - plt->replot(); + if (doReplot) + plt->replot(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_magnifier.cpp" +# include "moc_qwt_plot_magnifier.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_magnifier.h b/libs/qwt/src/qwt_plot_magnifier.h index cd2c1cb1..a0577677 100644 --- a/libs/qwt/src/qwt_plot_magnifier.h +++ b/libs/qwt/src/qwt_plot_magnifier.h @@ -29,27 +29,27 @@ class QwtPlot; */ class QWT_EXPORT QwtPlotMagnifier : public QwtMagnifier { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPlotMagnifier( QWidget* ); - virtual ~QwtPlotMagnifier(); +public: + explicit QwtPlotMagnifier(QWidget *); + virtual ~QwtPlotMagnifier(); - void setAxisEnabled( QwtAxisId, bool on ); - bool isAxisEnabled( QwtAxisId ) const; + void setAxisEnabled(QwtAxisId, bool on); + bool isAxisEnabled(QwtAxisId) const; - QWidget* canvas(); - const QWidget* canvas() const; + QWidget *canvas(); + const QWidget *canvas() const; - QwtPlot* plot(); - const QwtPlot* plot() const; + QwtPlot *plot(); + const QwtPlot *plot() const; - public Q_SLOTS: - virtual void rescale( double factor ) QWT_OVERRIDE; +public Q_SLOTS: + virtual void rescale(double factor) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_marker.cpp b/libs/qwt/src/qwt_plot_marker.cpp index 0f910f0e..23837d67 100644 --- a/libs/qwt/src/qwt_plot_marker.cpp +++ b/libs/qwt/src/qwt_plot_marker.cpp @@ -19,116 +19,113 @@ class QwtPlotMarker::PrivateData { - public: - PrivateData() - : labelAlignment( Qt::AlignCenter ) - , labelOrientation( Qt::Horizontal ) - , spacing( 2 ) - , symbol( NULL ) - , style( QwtPlotMarker::NoLine ) - , xValue( 0.0 ) - , yValue( 0.0 ) - { - } +public: + PrivateData() + : labelAlignment(Qt::AlignCenter) + , labelOrientation(Qt::Horizontal) + , spacing(2) + , symbol(NULL) + , style(QwtPlotMarker::NoLine) + , xValue(0.0) + , yValue(0.0) + { + } - ~PrivateData() - { - delete symbol; - } + ~PrivateData() { delete symbol; } - QwtText label; - Qt::Alignment labelAlignment; - Qt::Orientation labelOrientation; - int spacing; + QwtText label; + Qt::Alignment labelAlignment; + Qt::Orientation labelOrientation; + int spacing; - QPen pen; - const QwtSymbol* symbol; - LineStyle style; + QPen pen; + const QwtSymbol *symbol; + LineStyle style; - double xValue; - double yValue; + double xValue; + double yValue; }; //! Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine QwtPlotMarker::QwtPlotMarker() { - m_data = new PrivateData; - setZ( 30.0 ); + m_data = new PrivateData; + setZ(30.0); } //! Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine -QwtPlotMarker::QwtPlotMarker( const QString& title ) - : QwtPlotItem( QwtText( title ) ) +QwtPlotMarker::QwtPlotMarker(const QString &title) + : QwtPlotItem(QwtText(title)) { - m_data = new PrivateData; - setZ( 30.0 ); + m_data = new PrivateData; + setZ(30.0); } //! Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine -QwtPlotMarker::QwtPlotMarker( const QwtText& title ) - : QwtPlotItem( title ) +QwtPlotMarker::QwtPlotMarker(const QwtText &title) + : QwtPlotItem(title) { - m_data = new PrivateData; - setZ( 30.0 ); + m_data = new PrivateData; + setZ(30.0); } //! Destructor QwtPlotMarker::~QwtPlotMarker() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PlotMarker int QwtPlotMarker::rtti() const { - return QwtPlotItem::Rtti_PlotMarker; + return QwtPlotItem::Rtti_PlotMarker; } //! Return Value QPointF QwtPlotMarker::value() const { - return QPointF( m_data->xValue, m_data->yValue ); + return QPointF(m_data->xValue, m_data->yValue); } //! Return x Value double QwtPlotMarker::xValue() const { - return m_data->xValue; + return m_data->xValue; } //! Return y Value double QwtPlotMarker::yValue() const { - return m_data->yValue; + return m_data->yValue; } //! Set Value -void QwtPlotMarker::setValue( const QPointF& pos ) +void QwtPlotMarker::setValue(const QPointF &pos) { - setValue( pos.x(), pos.y() ); + setValue(pos.x(), pos.y()); } //! Set Value -void QwtPlotMarker::setValue( double x, double y ) +void QwtPlotMarker::setValue(double x, double y) { - if ( x != m_data->xValue || y != m_data->yValue ) - { - m_data->xValue = x; - m_data->yValue = y; - itemChanged(); - } + if (x != m_data->xValue || y != m_data->yValue) + { + m_data->xValue = x; + m_data->yValue = y; + itemChanged(); + } } //! Set X Value -void QwtPlotMarker::setXValue( double x ) +void QwtPlotMarker::setXValue(double x) { - setValue( x, m_data->yValue ); + setValue(x, m_data->yValue); } //! Set Y Value -void QwtPlotMarker::setYValue( double y ) +void QwtPlotMarker::setYValue(double y) { - setValue( m_data->xValue, y ); + setValue(m_data->xValue, y); } /*! @@ -139,16 +136,16 @@ void QwtPlotMarker::setYValue( double y ) \param yMap y Scale Map \param canvasRect Contents rectangle of the canvas in painter coordinates */ -void QwtPlotMarker::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotMarker::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - const QPointF pos( xMap.transform( m_data->xValue ), - yMap.transform( m_data->yValue ) ); + const QPointF pos(xMap.transform(m_data->xValue), + yMap.transform(m_data->yValue)); - drawLines( painter, canvasRect, pos ); - drawSymbol( painter, canvasRect, pos ); - drawLabel( painter, canvasRect, pos ); + drawLines(painter, canvasRect, pos); + drawSymbol(painter, canvasRect, pos); + drawLabel(painter, canvasRect, pos); } /*! @@ -160,35 +157,35 @@ void QwtPlotMarker::draw( QPainter* painter, \sa drawLabel(), drawSymbol() */ -void QwtPlotMarker::drawLines( QPainter* painter, - const QRectF& canvasRect, const QPointF& pos ) const +void QwtPlotMarker::drawLines(QPainter *painter, const QRectF &canvasRect, + const QPointF &pos) const { - if ( m_data->style == NoLine ) - return; + if (m_data->style == NoLine) + return; - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - painter->setPen( m_data->pen ); - if ( m_data->style == QwtPlotMarker::HLine || - m_data->style == QwtPlotMarker::Cross ) - { - double y = pos.y(); - if ( doAlign ) - y = qRound( y ); + painter->setPen(m_data->pen); + if (m_data->style == QwtPlotMarker::HLine + || m_data->style == QwtPlotMarker::Cross) + { + double y = pos.y(); + if (doAlign) + y = qRound(y); - QwtPainter::drawLine( painter, canvasRect.left(), - y, canvasRect.right() - 1.0, y ); - } - if ( m_data->style == QwtPlotMarker::VLine || - m_data->style == QwtPlotMarker::Cross ) - { - double x = pos.x(); - if ( doAlign ) - x = qRound( x ); + QwtPainter::drawLine(painter, canvasRect.left(), y, + canvasRect.right() - 1.0, y); + } + if (m_data->style == QwtPlotMarker::VLine + || m_data->style == QwtPlotMarker::Cross) + { + double x = pos.x(); + if (doAlign) + x = qRound(x); - QwtPainter::drawLine( painter, x, - canvasRect.top(), x, canvasRect.bottom() - 1.0 ); - } + QwtPainter::drawLine(painter, x, canvasRect.top(), x, + canvasRect.bottom() - 1.0); + } } /*! @@ -200,24 +197,24 @@ void QwtPlotMarker::drawLines( QPainter* painter, \sa drawLabel(), QwtSymbol::drawSymbol() */ -void QwtPlotMarker::drawSymbol( QPainter* painter, - const QRectF& canvasRect, const QPointF& pos ) const +void QwtPlotMarker::drawSymbol(QPainter *painter, const QRectF &canvasRect, + const QPointF &pos) const { - if ( m_data->symbol == NULL ) - return; + if (m_data->symbol == NULL) + return; - const QwtSymbol& symbol = *m_data->symbol; + const QwtSymbol &symbol = *m_data->symbol; - if ( symbol.style() != QwtSymbol::NoSymbol ) - { - const QSizeF sz = symbol.size(); + if (symbol.style() != QwtSymbol::NoSymbol) + { + const QSizeF sz = symbol.size(); - const QRectF clipRect = canvasRect.adjusted( - -sz.width(), -sz.height(), sz.width(), sz.height() ); + const QRectF clipRect = canvasRect.adjusted(-sz.width(), -sz.height(), + sz.width(), sz.height()); - if ( clipRect.contains( pos ) ) - symbol.drawSymbol( painter, pos ); - } + if (clipRect.contains(pos)) + symbol.drawSymbol(painter, pos); + } } /*! @@ -229,133 +226,129 @@ void QwtPlotMarker::drawSymbol( QPainter* painter, \sa drawLabel(), drawSymbol() */ -void QwtPlotMarker::drawLabel( QPainter* painter, - const QRectF& canvasRect, const QPointF& pos ) const +void QwtPlotMarker::drawLabel(QPainter *painter, const QRectF &canvasRect, + const QPointF &pos) const { - if ( m_data->label.isEmpty() ) - return; + if (m_data->label.isEmpty()) + return; - Qt::Alignment align = m_data->labelAlignment; - QPointF alignPos = pos; + Qt::Alignment align = m_data->labelAlignment; + QPointF alignPos = pos; - QSizeF symbolOff( 0, 0 ); + QSizeF symbolOff(0, 0); - switch ( m_data->style ) - { - case QwtPlotMarker::VLine: - { - // In VLine-style the y-position is pointless and - // the alignment flags are relative to the canvas + switch (m_data->style) + { + case QwtPlotMarker::VLine: { + // In VLine-style the y-position is pointless and + // the alignment flags are relative to the canvas - if ( m_data->labelAlignment & Qt::AlignTop ) - { - alignPos.setY( canvasRect.top() ); - align &= ~Qt::AlignTop; - align |= Qt::AlignBottom; - } - else if ( m_data->labelAlignment & Qt::AlignBottom ) - { - // In HLine-style the x-position is pointless and - // the alignment flags are relative to the canvas + if (m_data->labelAlignment & Qt::AlignTop) + { + alignPos.setY(canvasRect.top()); + align &= ~Qt::AlignTop; + align |= Qt::AlignBottom; + } + else if (m_data->labelAlignment & Qt::AlignBottom) + { + // In HLine-style the x-position is pointless and + // the alignment flags are relative to the canvas - alignPos.setY( canvasRect.bottom() - 1 ); - align &= ~Qt::AlignBottom; - align |= Qt::AlignTop; - } - else - { - alignPos.setY( canvasRect.center().y() ); - } - break; - } - case QwtPlotMarker::HLine: - { - if ( m_data->labelAlignment & Qt::AlignLeft ) - { - alignPos.setX( canvasRect.left() ); - align &= ~Qt::AlignLeft; - align |= Qt::AlignRight; - } - else if ( m_data->labelAlignment & Qt::AlignRight ) - { - alignPos.setX( canvasRect.right() - 1 ); - align &= ~Qt::AlignRight; - align |= Qt::AlignLeft; - } - else - { - alignPos.setX( canvasRect.center().x() ); - } - break; - } - default: - { - if ( m_data->symbol && - ( m_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - symbolOff = m_data->symbol->size() + QSizeF( 1, 1 ); - symbolOff /= 2; - } - } + alignPos.setY(canvasRect.bottom() - 1); + align &= ~Qt::AlignBottom; + align |= Qt::AlignTop; + } + else + { + alignPos.setY(canvasRect.center().y()); + } + break; } - - qreal pw2 = m_data->pen.widthF() / 2.0; - if ( pw2 == 0.0 ) - pw2 = 0.5; - - const int spacing = m_data->spacing; - - const qreal xOff = qwtMaxF( pw2, symbolOff.width() ); - const qreal yOff = qwtMaxF( pw2, symbolOff.height() ); - - const QSizeF textSize = m_data->label.textSize( painter->font() ); - - if ( align & Qt::AlignLeft ) - { - alignPos.rx() -= xOff + spacing; - if ( m_data->labelOrientation == Qt::Vertical ) - alignPos.rx() -= textSize.height(); - else - alignPos.rx() -= textSize.width(); + case QwtPlotMarker::HLine: { + if (m_data->labelAlignment & Qt::AlignLeft) + { + alignPos.setX(canvasRect.left()); + align &= ~Qt::AlignLeft; + align |= Qt::AlignRight; + } + else if (m_data->labelAlignment & Qt::AlignRight) + { + alignPos.setX(canvasRect.right() - 1); + align &= ~Qt::AlignRight; + align |= Qt::AlignLeft; + } + else + { + alignPos.setX(canvasRect.center().x()); + } + break; } - else if ( align & Qt::AlignRight ) - { - alignPos.rx() += xOff + spacing; + default: { + if (m_data->symbol && (m_data->symbol->style() != QwtSymbol::NoSymbol)) + { + symbolOff = m_data->symbol->size() + QSizeF(1, 1); + symbolOff /= 2; + } } + } + + qreal pw2 = m_data->pen.widthF() / 2.0; + if (pw2 == 0.0) + pw2 = 0.5; + + const int spacing = m_data->spacing; + + const qreal xOff = qwtMaxF(pw2, symbolOff.width()); + const qreal yOff = qwtMaxF(pw2, symbolOff.height()); + + const QSizeF textSize = m_data->label.textSize(painter->font()); + + if (align & Qt::AlignLeft) + { + alignPos.rx() -= xOff + spacing; + if (m_data->labelOrientation == Qt::Vertical) + alignPos.rx() -= textSize.height(); else - { - if ( m_data->labelOrientation == Qt::Vertical ) - alignPos.rx() -= textSize.height() / 2; - else - alignPos.rx() -= textSize.width() / 2; - } - - if ( align & Qt::AlignTop ) - { - alignPos.ry() -= yOff + spacing; - if ( m_data->labelOrientation != Qt::Vertical ) - alignPos.ry() -= textSize.height(); - } - else if ( align & Qt::AlignBottom ) - { - alignPos.ry() += yOff + spacing; - if ( m_data->labelOrientation == Qt::Vertical ) - alignPos.ry() += textSize.width(); - } + alignPos.rx() -= textSize.width(); + } + else if (align & Qt::AlignRight) + { + alignPos.rx() += xOff + spacing; + } + else + { + if (m_data->labelOrientation == Qt::Vertical) + alignPos.rx() -= textSize.height() / 2; else - { - if ( m_data->labelOrientation == Qt::Vertical ) - alignPos.ry() += textSize.width() / 2; - else - alignPos.ry() -= textSize.height() / 2; - } + alignPos.rx() -= textSize.width() / 2; + } - painter->translate( alignPos.x(), alignPos.y() ); - if ( m_data->labelOrientation == Qt::Vertical ) - painter->rotate( -90.0 ); + if (align & Qt::AlignTop) + { + alignPos.ry() -= yOff + spacing; + if (m_data->labelOrientation != Qt::Vertical) + alignPos.ry() -= textSize.height(); + } + else if (align & Qt::AlignBottom) + { + alignPos.ry() += yOff + spacing; + if (m_data->labelOrientation == Qt::Vertical) + alignPos.ry() += textSize.width(); + } + else + { + if (m_data->labelOrientation == Qt::Vertical) + alignPos.ry() += textSize.width() / 2; + else + alignPos.ry() -= textSize.height() / 2; + } - const QRectF textRect( 0, 0, textSize.width(), textSize.height() ); - m_data->label.draw( painter, textRect ); + painter->translate(alignPos.x(), alignPos.y()); + if (m_data->labelOrientation == Qt::Vertical) + painter->rotate(-90.0); + + const QRectF textRect(0, 0, textSize.width(), textSize.height()); + m_data->label.draw(painter, textRect); } /*! @@ -363,15 +356,15 @@ void QwtPlotMarker::drawLabel( QPainter* painter, \param style Line style. \sa lineStyle() */ -void QwtPlotMarker::setLineStyle( LineStyle style ) +void QwtPlotMarker::setLineStyle(LineStyle style) { - if ( style != m_data->style ) - { - m_data->style = style; + if (style != m_data->style) + { + m_data->style = style; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -380,7 +373,7 @@ void QwtPlotMarker::setLineStyle( LineStyle style ) */ QwtPlotMarker::LineStyle QwtPlotMarker::lineStyle() const { - return m_data->style; + return m_data->style; } /*! @@ -388,28 +381,28 @@ QwtPlotMarker::LineStyle QwtPlotMarker::lineStyle() const \param symbol New symbol \sa symbol() */ -void QwtPlotMarker::setSymbol( const QwtSymbol* symbol ) +void QwtPlotMarker::setSymbol(const QwtSymbol *symbol) { - if ( symbol != m_data->symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; + if (symbol != m_data->symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; - if ( symbol ) - setLegendIconSize( symbol->boundingRect().size() ); + if (symbol) + setLegendIconSize(symbol->boundingRect().size()); - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return the symbol \sa setSymbol(), QwtSymbol */ -const QwtSymbol* QwtPlotMarker::symbol() const +const QwtSymbol *QwtPlotMarker::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -417,13 +410,13 @@ const QwtSymbol* QwtPlotMarker::symbol() const \param label Label text \sa label() */ -void QwtPlotMarker::setLabel( const QwtText& label ) +void QwtPlotMarker::setLabel(const QwtText &label) { - if ( label != m_data->label ) - { - m_data->label = label; - itemChanged(); - } + if (label != m_data->label) + { + m_data->label = label; + itemChanged(); + } } /*! @@ -432,7 +425,7 @@ void QwtPlotMarker::setLabel( const QwtText& label ) */ QwtText QwtPlotMarker::label() const { - return m_data->label; + return m_data->label; } /*! @@ -449,13 +442,13 @@ QwtText QwtPlotMarker::label() const \param align Alignment. \sa labelAlignment(), labelOrientation() */ -void QwtPlotMarker::setLabelAlignment( Qt::Alignment align ) +void QwtPlotMarker::setLabelAlignment(Qt::Alignment align) { - if ( align != m_data->labelAlignment ) - { - m_data->labelAlignment = align; - itemChanged(); - } + if (align != m_data->labelAlignment) + { + m_data->labelAlignment = align; + itemChanged(); + } } /*! @@ -464,7 +457,7 @@ void QwtPlotMarker::setLabelAlignment( Qt::Alignment align ) */ Qt::Alignment QwtPlotMarker::labelAlignment() const { - return m_data->labelAlignment; + return m_data->labelAlignment; } /*! @@ -477,13 +470,13 @@ Qt::Alignment QwtPlotMarker::labelAlignment() const \sa labelOrientation(), setLabelAlignment() */ -void QwtPlotMarker::setLabelOrientation( Qt::Orientation orientation ) +void QwtPlotMarker::setLabelOrientation(Qt::Orientation orientation) { - if ( orientation != m_data->labelOrientation ) - { - m_data->labelOrientation = orientation; - itemChanged(); - } + if (orientation != m_data->labelOrientation) + { + m_data->labelOrientation = orientation; + itemChanged(); + } } /*! @@ -492,7 +485,7 @@ void QwtPlotMarker::setLabelOrientation( Qt::Orientation orientation ) */ Qt::Orientation QwtPlotMarker::labelOrientation() const { - return m_data->labelOrientation; + return m_data->labelOrientation; } /*! @@ -504,16 +497,16 @@ Qt::Orientation QwtPlotMarker::labelOrientation() const \param spacing Spacing \sa spacing(), setLabelAlignment() */ -void QwtPlotMarker::setSpacing( int spacing ) +void QwtPlotMarker::setSpacing(int spacing) { - if ( spacing < 0 ) - spacing = 0; + if (spacing < 0) + spacing = 0; - if ( spacing == m_data->spacing ) - return; + if (spacing == m_data->spacing) + return; - m_data->spacing = spacing; - itemChanged(); + m_data->spacing = spacing; + itemChanged(); } /*! @@ -522,7 +515,7 @@ void QwtPlotMarker::setSpacing( int spacing ) */ int QwtPlotMarker::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! @@ -538,9 +531,10 @@ int QwtPlotMarker::spacing() const \sa pen(), brush() */ -void QwtPlotMarker::setLinePen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotMarker::setLinePen(const QColor &color, qreal width, + Qt::PenStyle style) { - setLinePen( QPen( color, width, style ) ); + setLinePen(QPen(color, width, style)); } /*! @@ -549,41 +543,41 @@ void QwtPlotMarker::setLinePen( const QColor& color, qreal width, Qt::PenStyle s \param pen New pen \sa linePen() */ -void QwtPlotMarker::setLinePen( const QPen& pen ) +void QwtPlotMarker::setLinePen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; + if (pen != m_data->pen) + { + m_data->pen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return the line pen \sa setLinePen() */ -const QPen& QwtPlotMarker::linePen() const +const QPen &QwtPlotMarker::linePen() const { - return m_data->pen; + return m_data->pen; } QRectF QwtPlotMarker::boundingRect() const { - // width/height of -1 does not affect the autoscale calculation + // width/height of -1 does not affect the autoscale calculation - switch (m_data->style) - { - case QwtPlotMarker::HLine: - return QRectF( m_data->xValue, m_data->yValue, -1.0, 0.0 ); + switch (m_data->style) + { + case QwtPlotMarker::HLine: + return QRectF(m_data->xValue, m_data->yValue, -1.0, 0.0); - case QwtPlotMarker::VLine: - return QRectF( m_data->xValue, m_data->yValue, 0.0, -1.0 ); + case QwtPlotMarker::VLine: + return QRectF(m_data->xValue, m_data->yValue, 0.0, -1.0); - default: - return QRectF( m_data->xValue, m_data->yValue, 0.0, 0.0 ); - } + default: + return QRectF(m_data->xValue, m_data->yValue, 0.0, 0.0); + } } /*! @@ -595,50 +589,47 @@ QRectF QwtPlotMarker::boundingRect() const \sa setLegendIconSize(), legendData() */ -QwtGraphic QwtPlotMarker::legendIcon( int index, const QSizeF& size ) const +QwtGraphic QwtPlotMarker::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); + Q_UNUSED(index); - if ( size.isEmpty() ) - return QwtGraphic(); + if (size.isEmpty()) + return QwtGraphic(); - QwtGraphic icon; - icon.setDefaultSize( size ); - icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + QwtGraphic icon; + icon.setDefaultSize(size); + icon.setRenderHint(QwtGraphic::RenderPensUnscaled, true); - QPainter painter( &icon ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); + QPainter painter(&icon); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); - if ( m_data->style != QwtPlotMarker::NoLine ) + if (m_data->style != QwtPlotMarker::NoLine) + { + painter.setPen(m_data->pen); + + if (m_data->style == QwtPlotMarker::HLine + || m_data->style == QwtPlotMarker::Cross) { - painter.setPen( m_data->pen ); + const double y = 0.5 * size.height(); - if ( m_data->style == QwtPlotMarker::HLine || - m_data->style == QwtPlotMarker::Cross ) - { - const double y = 0.5 * size.height(); - - QwtPainter::drawLine( &painter, - 0.0, y, size.width(), y ); - } - - if ( m_data->style == QwtPlotMarker::VLine || - m_data->style == QwtPlotMarker::Cross ) - { - const double x = 0.5 * size.width(); - - QwtPainter::drawLine( &painter, - x, 0.0, x, size.height() ); - } + QwtPainter::drawLine(&painter, 0.0, y, size.width(), y); } - if ( m_data->symbol ) + if (m_data->style == QwtPlotMarker::VLine + || m_data->style == QwtPlotMarker::Cross) { - const QRect r( 0.0, 0.0, size.width(), size.height() ); - m_data->symbol->drawSymbol( &painter, r ); - } + const double x = 0.5 * size.width(); - return icon; + QwtPainter::drawLine(&painter, x, 0.0, x, size.height()); + } + } + + if (m_data->symbol) + { + const QRect r(0.0, 0.0, size.width(), size.height()); + m_data->symbol->drawSymbol(&painter, r); + } + + return icon; } - diff --git a/libs/qwt/src/qwt_plot_marker.h b/libs/qwt/src/qwt_plot_marker.h index 809466b3..199b8cce 100644 --- a/libs/qwt/src/qwt_plot_marker.h +++ b/libs/qwt/src/qwt_plot_marker.h @@ -44,89 +44,83 @@ class QwtSymbol; class QWT_EXPORT QwtPlotMarker : public QwtPlotItem { - public: +public: + /*! + Line styles. + \sa setLineStyle(), lineStyle() + */ + enum LineStyle + { + //! No line + NoLine, - /*! - Line styles. - \sa setLineStyle(), lineStyle() - */ - enum LineStyle - { - //! No line - NoLine, + //! A horizontal line + HLine, - //! A horizontal line - HLine, + //! A vertical line + VLine, - //! A vertical line - VLine, + //! A crosshair + Cross + }; - //! A crosshair - Cross - }; + explicit QwtPlotMarker(); + explicit QwtPlotMarker(const QString &title); + explicit QwtPlotMarker(const QwtText &title); - explicit QwtPlotMarker(); - explicit QwtPlotMarker( const QString& title ); - explicit QwtPlotMarker( const QwtText& title ); + virtual ~QwtPlotMarker(); - virtual ~QwtPlotMarker(); + virtual int rtti() const QWT_OVERRIDE; - virtual int rtti() const QWT_OVERRIDE; + double xValue() const; + double yValue() const; + QPointF value() const; - double xValue() const; - double yValue() const; - QPointF value() const; + void setXValue(double); + void setYValue(double); + void setValue(double, double); + void setValue(const QPointF &); - void setXValue( double ); - void setYValue( double ); - void setValue( double, double ); - void setValue( const QPointF& ); + void setLineStyle(LineStyle); + LineStyle lineStyle() const; - void setLineStyle( LineStyle ); - LineStyle lineStyle() const; + void setLinePen(const QColor &, qreal width = 0.0, + Qt::PenStyle = Qt::SolidLine); + void setLinePen(const QPen &); + const QPen &linePen() const; - void setLinePen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setLinePen( const QPen& ); - const QPen& linePen() const; + void setSymbol(const QwtSymbol *); + const QwtSymbol *symbol() const; - void setSymbol( const QwtSymbol* ); - const QwtSymbol* symbol() const; + void setLabel(const QwtText &); + QwtText label() const; - void setLabel( const QwtText& ); - QwtText label() const; + void setLabelAlignment(Qt::Alignment); + Qt::Alignment labelAlignment() const; - void setLabelAlignment( Qt::Alignment ); - Qt::Alignment labelAlignment() const; + void setLabelOrientation(Qt::Orientation); + Qt::Orientation labelOrientation() const; - void setLabelOrientation( Qt::Orientation ); - Qt::Orientation labelOrientation() const; + void setSpacing(int); + int spacing() const; - void setSpacing( int ); - int spacing() const; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &) const QWT_OVERRIDE; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& ) const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - virtual QwtGraphic legendIcon( - int index, const QSizeF& ) const QWT_OVERRIDE; +protected: + virtual void drawLines(QPainter *, const QRectF &, const QPointF &) const; - protected: - virtual void drawLines( QPainter*, - const QRectF&, const QPointF& ) const; + virtual void drawSymbol(QPainter *, const QRectF &, const QPointF &) const; - virtual void drawSymbol( QPainter*, - const QRectF&, const QPointF& ) const; + virtual void drawLabel(QPainter *, const QRectF &, const QPointF &) const; - virtual void drawLabel( QPainter*, - const QRectF&, const QPointF& ) const; - - private: - - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_multi_barchart.cpp b/libs/qwt/src/qwt_plot_multi_barchart.cpp index a9bbad11..07e5dce7 100644 --- a/libs/qwt/src/qwt_plot_multi_barchart.cpp +++ b/libs/qwt/src/qwt_plot_multi_barchart.cpp @@ -17,97 +17,95 @@ #include -inline static bool qwtIsIncreasing( - const QwtScaleMap& map, const QVector< double >& values ) +inline static bool qwtIsIncreasing(const QwtScaleMap &map, + const QVector &values) { - bool isInverting = map.isInverting(); + bool isInverting = map.isInverting(); - for ( int i = 0; i < values.size(); i++ ) - { - const double y = values[ i ]; - if ( y != 0.0 ) - return ( map.isInverting() != ( y > 0.0 ) ); - } + for (int i = 0; i < values.size(); i++) + { + const double y = values[i]; + if (y != 0.0) + return (map.isInverting() != (y > 0.0)); + } - return !isInverting; + return !isInverting; } class QwtPlotMultiBarChart::PrivateData { - public: - PrivateData() - : style( QwtPlotMultiBarChart::Grouped ) - { - } +public: + PrivateData() + : style(QwtPlotMultiBarChart::Grouped) + { + } - QwtPlotMultiBarChart::ChartStyle style; - QList< QwtText > barTitles; - QMap< int, QwtColumnSymbol* > symbolMap; + QwtPlotMultiBarChart::ChartStyle style; + QList barTitles; + QMap symbolMap; }; /*! Constructor \param title Title of the chart */ -QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QwtText& title ) - : QwtPlotAbstractBarChart( title ) +QwtPlotMultiBarChart::QwtPlotMultiBarChart(const QwtText &title) + : QwtPlotAbstractBarChart(title) { - init(); + init(); } /*! Constructor \param title Title of the chart */ -QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QString& title ) - : QwtPlotAbstractBarChart( QwtText( title ) ) +QwtPlotMultiBarChart::QwtPlotMultiBarChart(const QString &title) + : QwtPlotAbstractBarChart(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotMultiBarChart::~QwtPlotMultiBarChart() { - resetSymbolMap(); - delete m_data; + resetSymbolMap(); + delete m_data; } void QwtPlotMultiBarChart::init() { - m_data = new PrivateData; - setData( new QwtSetSeriesData() ); + m_data = new PrivateData; + setData(new QwtSetSeriesData()); } //! \return QwtPlotItem::Rtti_PlotBarChart int QwtPlotMultiBarChart::rtti() const { - return QwtPlotItem::Rtti_PlotMultiBarChart; + return QwtPlotItem::Rtti_PlotMultiBarChart; } /*! Initialize data with an array of samples. \param samples Vector of points */ -void QwtPlotMultiBarChart::setSamples( - const QVector< QwtSetSample >& samples ) +void QwtPlotMultiBarChart::setSamples(const QVector &samples) { - setData( new QwtSetSeriesData( samples ) ); + setData(new QwtSetSeriesData(samples)); } /*! Initialize data with an array of samples. \param samples Vector of points */ -void QwtPlotMultiBarChart::setSamples( - const QVector< QVector< double > >& samples ) +void QwtPlotMultiBarChart::setSamples(const QVector> &samples) { - QVector< QwtSetSample > s; - s.reserve( samples.size() ); + QVector s; + s.reserve(samples.size()); - for ( int i = 0; i < samples.size(); i++ ) - s += QwtSetSample( i, samples[ i ] ); + for (int i = 0; i < samples.size(); i++) + s += QwtSetSample(i, samples[i]); - setData( new QwtSetSeriesData( s ) ); + setData(new QwtSetSeriesData(s)); } /*! @@ -120,10 +118,9 @@ void QwtPlotMultiBarChart::setSamples( \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotMultiBarChart::setSamples( - QwtSeriesData< QwtSetSample >* data ) +void QwtPlotMultiBarChart::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -135,19 +132,19 @@ void QwtPlotMultiBarChart::setSamples( \sa barTitles(), legendData() */ -void QwtPlotMultiBarChart::setBarTitles( const QList< QwtText >& titles ) +void QwtPlotMultiBarChart::setBarTitles(const QList &titles) { - m_data->barTitles = titles; - itemChanged(); + m_data->barTitles = titles; + itemChanged(); } /*! \return Bar titles \sa setBarTitles(), legendData() */ -QList< QwtText > QwtPlotMultiBarChart::barTitles() const +QList QwtPlotMultiBarChart::barTitles() const { - return m_data->barTitles; + return m_data->barTitles; } /*! @@ -161,42 +158,42 @@ QList< QwtText > QwtPlotMultiBarChart::barTitles() const \sa symbol(), resetSymbolMap(), specialSymbol() */ -void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol* symbol ) +void QwtPlotMultiBarChart::setSymbol(int valueIndex, QwtColumnSymbol *symbol) { - if ( valueIndex < 0 ) - return; + if (valueIndex < 0) + return; - QMap< int, QwtColumnSymbol* >::iterator it = - m_data->symbolMap.find(valueIndex); - if ( it == m_data->symbolMap.end() ) + QMap::iterator it + = m_data->symbolMap.find(valueIndex); + if (it == m_data->symbolMap.end()) + { + if (symbol != NULL) { - if ( symbol != NULL ) - { - m_data->symbolMap.insert( valueIndex, symbol ); + m_data->symbolMap.insert(valueIndex, symbol); - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); } - else + } + else + { + if (symbol != it.value()) { - if ( symbol != it.value() ) - { - delete it.value(); + delete it.value(); - if ( symbol == NULL ) - { - m_data->symbolMap.remove( valueIndex ); - } - else - { - it.value() = symbol; - } + if (symbol == NULL) + { + m_data->symbolMap.remove(valueIndex); + } + else + { + it.value() = symbol; + } - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); } + } } /*! @@ -207,12 +204,12 @@ void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol* symbol ) \sa setSymbol(), specialSymbol(), drawBar() */ -const QwtColumnSymbol* QwtPlotMultiBarChart::symbol( int valueIndex ) const +const QwtColumnSymbol *QwtPlotMultiBarChart::symbol(int valueIndex) const { - QMap< int, QwtColumnSymbol* >::const_iterator it = - m_data->symbolMap.constFind( valueIndex ); + QMap::const_iterator it + = m_data->symbolMap.constFind(valueIndex); - return ( it == m_data->symbolMap.constEnd() ) ? NULL : it.value(); + return (it == m_data->symbolMap.constEnd()) ? NULL : it.value(); } /*! @@ -223,12 +220,12 @@ const QwtColumnSymbol* QwtPlotMultiBarChart::symbol( int valueIndex ) const \sa setSymbol(), specialSymbol(), drawBar() */ -QwtColumnSymbol* QwtPlotMultiBarChart::symbol( int valueIndex ) +QwtColumnSymbol *QwtPlotMultiBarChart::symbol(int valueIndex) { - QMap< int, QwtColumnSymbol* >::const_iterator it = - m_data->symbolMap.constFind( valueIndex ); + QMap::const_iterator it + = m_data->symbolMap.constFind(valueIndex); - return ( it == m_data->symbolMap.constEnd() ) ? NULL : it.value(); + return (it == m_data->symbolMap.constEnd()) ? NULL : it.value(); } /*! @@ -236,8 +233,8 @@ QwtColumnSymbol* QwtPlotMultiBarChart::symbol( int valueIndex ) */ void QwtPlotMultiBarChart::resetSymbolMap() { - qDeleteAll( m_data->symbolMap ); - m_data->symbolMap.clear(); + qDeleteAll(m_data->symbolMap); + m_data->symbolMap.clear(); } /*! @@ -260,13 +257,13 @@ void QwtPlotMultiBarChart::resetSymbolMap() \return NULL, meaning that the value is not special */ -QwtColumnSymbol* QwtPlotMultiBarChart::specialSymbol( - int sampleIndex, int valueIndex ) const +QwtColumnSymbol *QwtPlotMultiBarChart::specialSymbol(int sampleIndex, + int valueIndex) const { - Q_UNUSED( sampleIndex ); - Q_UNUSED( valueIndex ); + Q_UNUSED(sampleIndex); + Q_UNUSED(valueIndex); - return NULL; + return NULL; } /*! @@ -275,15 +272,15 @@ QwtColumnSymbol* QwtPlotMultiBarChart::specialSymbol( \param style Chart style \sa style() */ -void QwtPlotMultiBarChart::setStyle( ChartStyle style ) +void QwtPlotMultiBarChart::setStyle(ChartStyle style) { - if ( style != m_data->style ) - { - m_data->style = style; + if (style != m_data->style) + { + m_data->style = style; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -292,7 +289,7 @@ void QwtPlotMultiBarChart::setStyle( ChartStyle style ) */ QwtPlotMultiBarChart::ChartStyle QwtPlotMultiBarChart::style() const { - return m_data->style; + return m_data->style; } /*! @@ -301,61 +298,61 @@ QwtPlotMultiBarChart::ChartStyle QwtPlotMultiBarChart::style() const */ QRectF QwtPlotMultiBarChart::boundingRect() const { - const int numSamples = dataSize(); + const int numSamples = dataSize(); - if ( numSamples == 0 ) - return QwtPlotSeriesItem::boundingRect(); + if (numSamples == 0) + return QwtPlotSeriesItem::boundingRect(); - const double baseLine = baseline(); + const double baseLine = baseline(); - QRectF rect; + QRectF rect; - if ( m_data->style != QwtPlotMultiBarChart::Stacked ) + if (m_data->style != QwtPlotMultiBarChart::Stacked) + { + rect = QwtPlotSeriesItem::boundingRect(); + + if (rect.height() >= 0) { - rect = QwtPlotSeriesItem::boundingRect(); - - if ( rect.height() >= 0 ) - { - if ( rect.bottom() < baseLine ) - rect.setBottom( baseLine ); - if ( rect.top() > baseLine ) - rect.setTop( baseLine ); - } + if (rect.bottom() < baseLine) + rect.setBottom(baseLine); + if (rect.top() > baseLine) + rect.setTop(baseLine); } - else + } + else + { + double xMin, xMax, yMin, yMax; + + xMin = xMax = 0.0; + yMin = yMax = baseLine; + + const QwtSeriesData *series = data(); + + for (int i = 0; i < numSamples; i++) { - double xMin, xMax, yMin, yMax; + const QwtSetSample sample = series->sample(i); + if (i == 0) + { + xMin = xMax = sample.value; + } + else + { + xMin = qwtMinF(xMin, sample.value); + xMax = qwtMaxF(xMax, sample.value); + } - xMin = xMax = 0.0; - yMin = yMax = baseLine; + const double y = baseLine + sample.added(); - const QwtSeriesData< QwtSetSample >* series = data(); - - for ( int i = 0; i < numSamples; i++ ) - { - const QwtSetSample sample = series->sample( i ); - if ( i == 0 ) - { - xMin = xMax = sample.value; - } - else - { - xMin = qwtMinF( xMin, sample.value ); - xMax = qwtMaxF( xMax, sample.value ); - } - - const double y = baseLine + sample.added(); - - yMin = qwtMinF( yMin, y ); - yMax = qwtMaxF( yMax, y ); - } - rect.setRect( xMin, yMin, xMax - xMin, yMax - yMin ); + yMin = qwtMinF(yMin, y); + yMax = qwtMaxF(yMax, y); } + rect.setRect(xMin, yMin, xMax - xMin, yMax - yMin); + } - if ( orientation() == Qt::Horizontal ) - rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); + if (orientation() == Qt::Horizontal) + rect.setRect(rect.y(), rect.x(), rect.height(), rect.width()); - return rect; + return rect; } /*! @@ -371,32 +368,32 @@ QRectF QwtPlotMultiBarChart::boundingRect() const \sa drawSymbols() */ -void QwtPlotMultiBarChart::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotMultiBarChart::drawSeries(QPainter *painter, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( from > to ) - return; + if (from > to) + return; + const QRectF br = data()->boundingRect(); + const QwtInterval interval(br.left(), br.right()); - const QRectF br = data()->boundingRect(); - const QwtInterval interval( br.left(), br.right() ); + painter->save(); - painter->save(); + for (int i = from; i <= to; i++) + { + drawSample(painter, xMap, yMap, canvasRect, interval, i, sample(i)); + } - for ( int i = from; i <= to; i++ ) - { - drawSample( painter, xMap, yMap, - canvasRect, interval, i, sample( i ) ); - } - - painter->restore(); + painter->restore(); } /*! @@ -412,37 +409,35 @@ void QwtPlotMultiBarChart::drawSeries(QPainter* painter, \sa drawSeries() */ -void QwtPlotMultiBarChart::drawSample( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - int index, const QwtSetSample& sample ) const +void QwtPlotMultiBarChart::drawSample( + QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &canvasRect, const QwtInterval &boundingInterval, int index, + const QwtSetSample &sample) const { - if ( sample.set.size() <= 0 ) - return; + if (sample.set.size() <= 0) + return; - double sampleW; + double sampleW; - if ( orientation() == Qt::Horizontal ) - { - sampleW = sampleWidth( yMap, canvasRect.height(), - boundingInterval.width(), sample.value ); - } - else - { - sampleW = sampleWidth( xMap, canvasRect.width(), - boundingInterval.width(), sample.value ); - } + if (orientation() == Qt::Horizontal) + { + sampleW = sampleWidth(yMap, canvasRect.height(), boundingInterval.width(), + sample.value); + } + else + { + sampleW = sampleWidth(xMap, canvasRect.width(), boundingInterval.width(), + sample.value); + } - if ( m_data->style == Stacked ) - { - drawStackedBars( painter, xMap, yMap, - canvasRect, index, sampleW, sample ); - } - else - { - drawGroupedBars( painter, xMap, yMap, - canvasRect, index, sampleW, sample ); - } + if (m_data->style == Stacked) + { + drawStackedBars(painter, xMap, yMap, canvasRect, index, sampleW, sample); + } + else + { + drawGroupedBars(painter, xMap, yMap, canvasRect, index, sampleW, sample); + } } /*! @@ -458,71 +453,73 @@ void QwtPlotMultiBarChart::drawSample( QPainter* painter, \sa drawSeries(), sampleWidth() */ -void QwtPlotMultiBarChart::drawGroupedBars( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int index, double sampleWidth, - const QwtSetSample& sample ) const +void QwtPlotMultiBarChart::drawGroupedBars(QPainter *painter, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int index, + double sampleWidth, + const QwtSetSample &sample) const { - Q_UNUSED( canvasRect ); + Q_UNUSED(canvasRect); - const int numBars = sample.set.size(); - if ( numBars == 0 ) - return; + const int numBars = sample.set.size(); + if (numBars == 0) + return; - if ( orientation() == Qt::Vertical ) + if (orientation() == Qt::Vertical) + { + const double barWidth = sampleWidth / numBars; + + const double y1 = yMap.transform(baseline()); + const double x0 = xMap.transform(sample.value) - 0.5 * sampleWidth; + + for (int i = 0; i < numBars; i++) { - const double barWidth = sampleWidth / numBars; + const double x1 = x0 + i * barWidth; + const double x2 = x1 + barWidth; - const double y1 = yMap.transform( baseline() ); - const double x0 = xMap.transform( sample.value ) - 0.5 * sampleWidth; + const double y2 = yMap.transform(sample.set[i]); - for ( int i = 0; i < numBars; i++ ) - { - const double x1 = x0 + i * barWidth; - const double x2 = x1 + barWidth; + QwtColumnRect barRect; + barRect.direction + = (y1 < y2) ? QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop; - const double y2 = yMap.transform( sample.set[i] ); + barRect.hInterval = QwtInterval(x1, x2).normalized(); + if (i != 0) + barRect.hInterval.setBorderFlags(QwtInterval::ExcludeMinimum); - QwtColumnRect barRect; - barRect.direction = ( y1 < y2 ) ? - QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop; + barRect.vInterval = QwtInterval(y1, y2).normalized(); - barRect.hInterval = QwtInterval( x1, x2 ).normalized(); - if ( i != 0 ) - barRect.hInterval.setBorderFlags( QwtInterval::ExcludeMinimum ); - - barRect.vInterval = QwtInterval( y1, y2 ).normalized(); - - drawBar( painter, index, i, barRect ); - } + drawBar(painter, index, i, barRect); } - else + } + else + { + const double barHeight = sampleWidth / numBars; + + const double x1 = xMap.transform(baseline()); + const double y0 = yMap.transform(sample.value) - 0.5 * sampleWidth; + + for (int i = 0; i < numBars; i++) { - const double barHeight = sampleWidth / numBars; + double y1 = y0 + i * barHeight; + double y2 = y1 + barHeight; - const double x1 = xMap.transform( baseline() ); - const double y0 = yMap.transform( sample.value ) - 0.5 * sampleWidth; + double x2 = xMap.transform(sample.set[i]); - for ( int i = 0; i < numBars; i++ ) - { - double y1 = y0 + i * barHeight; - double y2 = y1 + barHeight; + QwtColumnRect barRect; + barRect.direction + = x1 < x2 ? QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft; - double x2 = xMap.transform( sample.set[i] ); + barRect.hInterval = QwtInterval(x1, x2).normalized(); - QwtColumnRect barRect; - barRect.direction = x1 < x2 ? - QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft; + barRect.vInterval = QwtInterval(y1, y2); + if (i != 0) + barRect.vInterval.setBorderFlags(QwtInterval::ExcludeMinimum); - barRect.hInterval = QwtInterval( x1, x2 ).normalized(); - - barRect.vInterval = QwtInterval( y1, y2 ); - if ( i != 0 ) - barRect.vInterval.setBorderFlags( QwtInterval::ExcludeMinimum ); - - drawBar( painter, index, i, barRect ); - } + drawBar(painter, index, i, barRect); } + } } /*! @@ -538,104 +535,106 @@ void QwtPlotMultiBarChart::drawGroupedBars( QPainter* painter, \sa drawSeries(), sampleWidth() */ -void QwtPlotMultiBarChart::drawStackedBars( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int index, - double sampleWidth, const QwtSetSample& sample ) const +void QwtPlotMultiBarChart::drawStackedBars(QPainter *painter, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int index, + double sampleWidth, + const QwtSetSample &sample) const { - Q_UNUSED( canvasRect ); // clipping the bars ? + Q_UNUSED(canvasRect); // clipping the bars ? - const int numBars = sample.set.size(); - if ( numBars == 0 ) - return; + const int numBars = sample.set.size(); + if (numBars == 0) + return; - QwtInterval::BorderFlag borderFlags = QwtInterval::IncludeBorders; + QwtInterval::BorderFlag borderFlags = QwtInterval::IncludeBorders; - if ( orientation() == Qt::Vertical ) + if (orientation() == Qt::Vertical) + { + const double x1 = xMap.transform(sample.value) - 0.5 * sampleWidth; + const double x2 = x1 + sampleWidth; + + const bool increasing = qwtIsIncreasing(yMap, sample.set); + + QwtColumnRect bar; + bar.direction + = increasing ? QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop; + + bar.hInterval = QwtInterval(x1, x2).normalized(); + + double sum = baseline(); + + for (int i = 0; i < numBars; i++) { - const double x1 = xMap.transform( sample.value ) - 0.5 * sampleWidth; - const double x2 = x1 + sampleWidth; + const double si = sample.set[i]; + if (si == 0.0) + continue; - const bool increasing = qwtIsIncreasing( yMap, sample.set ); + const double y1 = yMap.transform(sum); + const double y2 = yMap.transform(sum + si); - QwtColumnRect bar; - bar.direction = increasing ? - QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop; + if ((y2 > y1) != increasing) + { + // stacked bars need to be in the same direction + continue; + } - bar.hInterval = QwtInterval( x1, x2 ).normalized(); + bar.vInterval = QwtInterval(y1, y2).normalized(); + bar.vInterval.setBorderFlags(borderFlags); - double sum = baseline(); + drawBar(painter, index, i, bar); - for ( int i = 0; i < numBars; i++ ) - { - const double si = sample.set[ i ]; - if ( si == 0.0 ) - continue; + sum += si; - const double y1 = yMap.transform( sum ); - const double y2 = yMap.transform( sum + si ); - - if ( ( y2 > y1 ) != increasing ) - { - // stacked bars need to be in the same direction - continue; - } - - bar.vInterval = QwtInterval( y1, y2 ).normalized(); - bar.vInterval.setBorderFlags( borderFlags ); - - drawBar( painter, index, i, bar ); - - sum += si; - - if ( increasing ) - borderFlags = QwtInterval::ExcludeMinimum; - else - borderFlags = QwtInterval::ExcludeMaximum; - } + if (increasing) + borderFlags = QwtInterval::ExcludeMinimum; + else + borderFlags = QwtInterval::ExcludeMaximum; } - else + } + else + { + const double y1 = yMap.transform(sample.value) - 0.5 * sampleWidth; + const double y2 = y1 + sampleWidth; + + const bool increasing = qwtIsIncreasing(xMap, sample.set); + + QwtColumnRect bar; + bar.direction + = increasing ? QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft; + bar.vInterval = QwtInterval(y1, y2).normalized(); + + double sum = baseline(); + + for (int i = 0; i < sample.set.size(); i++) { - const double y1 = yMap.transform( sample.value ) - 0.5 * sampleWidth; - const double y2 = y1 + sampleWidth; + const double si = sample.set[i]; + if (si == 0.0) + continue; - const bool increasing = qwtIsIncreasing( xMap, sample.set ); + const double x1 = xMap.transform(sum); + const double x2 = xMap.transform(sum + si); - QwtColumnRect bar; - bar.direction = increasing ? - QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft; - bar.vInterval = QwtInterval( y1, y2 ).normalized(); + if ((x2 > x1) != increasing) + { + // stacked bars need to be in the same direction + continue; + } - double sum = baseline(); + bar.hInterval = QwtInterval(x1, x2).normalized(); + bar.hInterval.setBorderFlags(borderFlags); - for ( int i = 0; i < sample.set.size(); i++ ) - { - const double si = sample.set[ i ]; - if ( si == 0.0 ) - continue; + drawBar(painter, index, i, bar); - const double x1 = xMap.transform( sum ); - const double x2 = xMap.transform( sum + si ); + sum += si; - if ( ( x2 > x1 ) != increasing ) - { - // stacked bars need to be in the same direction - continue; - } - - bar.hInterval = QwtInterval( x1, x2 ).normalized(); - bar.hInterval.setBorderFlags( borderFlags ); - - drawBar( painter, index, i, bar ); - - sum += si; - - if ( increasing ) - borderFlags = QwtInterval::ExcludeMinimum; - else - borderFlags = QwtInterval::ExcludeMaximum; - } + if (increasing) + borderFlags = QwtInterval::ExcludeMinimum; + else + borderFlags = QwtInterval::ExcludeMaximum; } + } } /*! @@ -649,31 +648,32 @@ void QwtPlotMultiBarChart::drawStackedBars( QPainter* painter, \sa drawSeries() */ -void QwtPlotMultiBarChart::drawBar( QPainter* painter, - int sampleIndex, int valueIndex, const QwtColumnRect& rect ) const +void QwtPlotMultiBarChart::drawBar(QPainter *painter, int sampleIndex, + int valueIndex, + const QwtColumnRect &rect) const { - const QwtColumnSymbol* specialSym = NULL; - if ( sampleIndex >= 0 ) - specialSym = specialSymbol( sampleIndex, valueIndex ); + const QwtColumnSymbol *specialSym = NULL; + if (sampleIndex >= 0) + specialSym = specialSymbol(sampleIndex, valueIndex); - const QwtColumnSymbol* sym = specialSym; - if ( sym == NULL ) - sym = symbol( valueIndex ); + const QwtColumnSymbol *sym = specialSym; + if (sym == NULL) + sym = symbol(valueIndex); - if ( sym ) - { - sym->draw( painter, rect ); - } - else - { - // we build a temporary default symbol - QwtColumnSymbol columnSymbol( QwtColumnSymbol::Box ); - columnSymbol.setLineWidth( 1 ); - columnSymbol.setFrameStyle( QwtColumnSymbol::Plain ); - columnSymbol.draw( painter, rect ); - } + if (sym) + { + sym->draw(painter, rect); + } + else + { + // we build a temporary default symbol + QwtColumnSymbol columnSymbol(QwtColumnSymbol::Box); + columnSymbol.setLineWidth(1); + columnSymbol.setFrameStyle(QwtColumnSymbol::Plain); + columnSymbol.draw(painter, rect); + } - delete specialSym; + delete specialSym; } /*! @@ -684,28 +684,28 @@ void QwtPlotMultiBarChart::drawBar( QPainter* painter, \sa barTitles(), legendIcon(), legendIconSize() */ -QList< QwtLegendData > QwtPlotMultiBarChart::legendData() const +QList QwtPlotMultiBarChart::legendData() const { - QList< QwtLegendData > list; - list.reserve( m_data->barTitles.size() ); + QList list; + list.reserve(m_data->barTitles.size()); - for ( int i = 0; i < m_data->barTitles.size(); i++ ) + for (int i = 0; i < m_data->barTitles.size(); i++) + { + QwtLegendData data; + + data.setValue(QwtLegendData::TitleRole, + QVariant::fromValue(m_data->barTitles[i])); + + if (!legendIconSize().isEmpty()) { - QwtLegendData data; - - data.setValue( QwtLegendData::TitleRole, - QVariant::fromValue( m_data->barTitles[i] ) ); - - if ( !legendIconSize().isEmpty() ) - { - data.setValue( QwtLegendData::IconRole, - QVariant::fromValue( legendIcon( i, legendIconSize() ) ) ); - } - - list += data; + data.setValue(QwtLegendData::IconRole, + QVariant::fromValue(legendIcon(i, legendIconSize()))); } - return list; + list += data; + } + + return list; } /*! @@ -717,23 +717,21 @@ QList< QwtLegendData > QwtPlotMultiBarChart::legendData() const \return An icon showing a bar \sa drawBar(), legendData() */ -QwtGraphic QwtPlotMultiBarChart::legendIcon( int index, - const QSizeF& size ) const +QwtGraphic QwtPlotMultiBarChart::legendIcon(int index, const QSizeF &size) const { - QwtColumnRect column; - column.hInterval = QwtInterval( 0.0, size.width() - 1.0 ); - column.vInterval = QwtInterval( 0.0, size.height() - 1.0 ); + QwtColumnRect column; + column.hInterval = QwtInterval(0.0, size.width() - 1.0); + column.vInterval = QwtInterval(0.0, size.height() - 1.0); - QwtGraphic icon; - icon.setDefaultSize( size ); - icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + QwtGraphic icon; + icon.setDefaultSize(size); + icon.setRenderHint(QwtGraphic::RenderPensUnscaled, true); - QPainter painter( &icon ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); + QPainter painter(&icon); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); - drawBar( &painter, -1, index, column ); + drawBar(&painter, -1, index, column); - return icon; + return icon; } - diff --git a/libs/qwt/src/qwt_plot_multi_barchart.h b/libs/qwt/src/qwt_plot_multi_barchart.h index 2b382e81..37211b20 100644 --- a/libs/qwt/src/qwt_plot_multi_barchart.h +++ b/libs/qwt/src/qwt_plot_multi_barchart.h @@ -15,7 +15,8 @@ class QwtColumnRect; class QwtColumnSymbol; -template< typename T > class QwtSeriesData; +template +class QwtSeriesData; /*! \brief QwtPlotMultiBarChart displays a series of a samples that consist @@ -24,9 +25,9 @@ template< typename T > class QwtSeriesData; Each value is displayed as a bar, the bars of each set can be organized side by side or accumulated. - Each bar of a set is rendered by a QwtColumnSymbol, that is set by setSymbol(). - The bars of different sets use the same symbols. Exceptions are possible - by overloading specialSymbol() or overloading drawBar(). + Each bar of a set is rendered by a QwtColumnSymbol, that is set by + setSymbol(). The bars of different sets use the same symbols. Exceptions are + possible by overloading specialSymbol() or overloading drawBar(). Depending on its orientation() the bars are displayed horizontally or vertically. The bars cover the interval between the baseline() @@ -38,92 +39,89 @@ template< typename T > class QwtSeriesData; \sa QwtPlotBarChart, QwtPlotHistogram QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline() */ -class QWT_EXPORT QwtPlotMultiBarChart - : public QwtPlotAbstractBarChart - , public QwtSeriesStore< QwtSetSample > +class QWT_EXPORT QwtPlotMultiBarChart : public QwtPlotAbstractBarChart, + public QwtSeriesStore { - public: +public: + /*! + \brief Chart styles. + + The default setting is QwtPlotMultiBarChart::Grouped. + \sa setStyle(), style() + */ + enum ChartStyle + { + //! The bars of a set are displayed side by side + Grouped, + /*! - \brief Chart styles. - - The default setting is QwtPlotMultiBarChart::Grouped. - \sa setStyle(), style() + The bars are displayed on top of each other accumulating + to a single bar. All values of a set need to have the same + sign. */ - enum ChartStyle - { - //! The bars of a set are displayed side by side - Grouped, + Stacked + }; - /*! - The bars are displayed on top of each other accumulating - to a single bar. All values of a set need to have the same - sign. - */ - Stacked - }; + explicit QwtPlotMultiBarChart(const QString &title = QString()); + explicit QwtPlotMultiBarChart(const QwtText &title); - explicit QwtPlotMultiBarChart( const QString& title = QString() ); - explicit QwtPlotMultiBarChart( const QwtText& title ); + virtual ~QwtPlotMultiBarChart(); - virtual ~QwtPlotMultiBarChart(); + virtual int rtti() const QWT_OVERRIDE; - virtual int rtti() const QWT_OVERRIDE; + void setBarTitles(const QList &); + QList barTitles() const; - void setBarTitles( const QList< QwtText >& ); - QList< QwtText > barTitles() const; + void setSamples(const QVector &); + void setSamples(const QVector> &); + void setSamples(QwtSeriesData *); - void setSamples( const QVector< QwtSetSample >& ); - void setSamples( const QVector< QVector< double > >& ); - void setSamples( QwtSeriesData< QwtSetSample >* ); + void setStyle(ChartStyle style); + ChartStyle style() const; - void setStyle( ChartStyle style ); - ChartStyle style() const; + void setSymbol(int valueIndex, QwtColumnSymbol *); + const QwtColumnSymbol *symbol(int valueIndex) const; - void setSymbol( int valueIndex, QwtColumnSymbol* ); - const QwtColumnSymbol* symbol( int valueIndex ) const; + void resetSymbolMap(); - void resetSymbolMap(); + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QList legendData() const QWT_OVERRIDE; - virtual QList< QwtLegendData > legendData() const QWT_OVERRIDE; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - virtual QwtGraphic legendIcon( - int index, const QSizeF& ) const QWT_OVERRIDE; +protected: + QwtColumnSymbol *symbol(int valueIndex); - protected: - QwtColumnSymbol* symbol( int valueIndex ); + virtual QwtColumnSymbol *specialSymbol(int sampleIndex, int valueIndex) const; - virtual QwtColumnSymbol* specialSymbol( - int sampleIndex, int valueIndex ) const; + virtual void drawSample(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + const QwtInterval &boundingInterval, int index, + const QwtSetSample &) const; - virtual void drawSample( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - int index, const QwtSetSample& ) const; + virtual void drawBar(QPainter *, int sampleIndex, int valueIndex, + const QwtColumnRect &) const; - virtual void drawBar( QPainter*, int sampleIndex, - int valueIndex, const QwtColumnRect& ) const; + void drawStackedBars(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int index, double sampleWidth, + const QwtSetSample &) const; - void drawStackedBars( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int index, - double sampleWidth, const QwtSetSample& ) const; + void drawGroupedBars(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int index, double sampleWidth, + const QwtSetSample &) const; - void drawGroupedBars( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int index, - double sampleWidth, const QwtSetSample& ) const; +private: + void init(); - private: - void init(); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_opengl_canvas.cpp b/libs/qwt/src/qwt_plot_opengl_canvas.cpp index c61c18b6..e85493a2 100644 --- a/libs/qwt/src/qwt_plot_opengl_canvas.cpp +++ b/libs/qwt/src/qwt_plot_opengl_canvas.cpp @@ -19,24 +19,21 @@ class QwtPlotOpenGLCanvas::PrivateData { - public: - PrivateData() - : isPolished( false ) - , fboDirty( true ) - , fbo( NULL ) - { - } +public: + PrivateData() + : isPolished(false) + , fboDirty(true) + , fbo(NULL) + { + } - ~PrivateData() - { - delete fbo; - } + ~PrivateData() { delete fbo; } - int numSamples; + int numSamples; - bool isPolished; - bool fboDirty; - QOpenGLFramebufferObject* fbo; + bool isPolished; + bool fboDirty; + QOpenGLFramebufferObject *fbo; }; /*! @@ -45,14 +42,14 @@ class QwtPlotOpenGLCanvas::PrivateData \param plot Parent plot widget \sa QwtPlot::setCanvas() */ -QwtPlotOpenGLCanvas::QwtPlotOpenGLCanvas( QwtPlot* plot ) - : QOpenGLWidget( plot ) - , QwtPlotAbstractGLCanvas( this ) +QwtPlotOpenGLCanvas::QwtPlotOpenGLCanvas(QwtPlot *plot) + : QOpenGLWidget(plot) + , QwtPlotAbstractGLCanvas(this) { - QSurfaceFormat fmt = format(); - fmt.setSamples( 4 ); + QSurfaceFormat fmt = format(); + fmt.setSamples(4); - init( fmt ); + init(fmt); } /*! @@ -62,34 +59,34 @@ QwtPlotOpenGLCanvas::QwtPlotOpenGLCanvas( QwtPlot* plot ) \param plot Parent plot widget \sa QwtPlot::setCanvas() */ -QwtPlotOpenGLCanvas::QwtPlotOpenGLCanvas( - const QSurfaceFormat& format, QwtPlot* plot ) - : QOpenGLWidget( plot ) - , QwtPlotAbstractGLCanvas( this ) +QwtPlotOpenGLCanvas::QwtPlotOpenGLCanvas(const QSurfaceFormat &format, + QwtPlot *plot) + : QOpenGLWidget(plot) + , QwtPlotAbstractGLCanvas(this) { - init( format ); + init(format); } -void QwtPlotOpenGLCanvas::init( const QSurfaceFormat& format ) +void QwtPlotOpenGLCanvas::init(const QSurfaceFormat &format) { - m_data = new PrivateData; - m_data->numSamples = format.samples(); + m_data = new PrivateData; + m_data->numSamples = format.samples(); - setFormat( format ); + setFormat(format); #if 1 - setAttribute( Qt::WA_OpaquePaintEvent, true ); + setAttribute(Qt::WA_OpaquePaintEvent, true); #endif - setLineWidth( 2 ); - setFrameShadow( QFrame::Sunken ); - setFrameShape( QFrame::Panel ); + setLineWidth(2); + setFrameShadow(QFrame::Sunken); + setFrameShape(QFrame::Panel); } //! Destructor QwtPlotOpenGLCanvas::~QwtPlotOpenGLCanvas() { - delete m_data; + delete m_data; } /*! @@ -98,10 +95,10 @@ QwtPlotOpenGLCanvas::~QwtPlotOpenGLCanvas() \param event Paint event \sa QwtPlot::drawCanvas() */ -void QwtPlotOpenGLCanvas::paintEvent( QPaintEvent* event ) +void QwtPlotOpenGLCanvas::paintEvent(QPaintEvent *event) { - if ( m_data->isPolished ) - QOpenGLWidget::paintEvent( event ); + if (m_data->isPolished) + QOpenGLWidget::paintEvent(event); } /*! @@ -109,30 +106,29 @@ void QwtPlotOpenGLCanvas::paintEvent( QPaintEvent* event ) \param event Qt Event \return See QGLWidget::event() */ -bool QwtPlotOpenGLCanvas::event( QEvent* event ) +bool QwtPlotOpenGLCanvas::event(QEvent *event) { - const bool ok = QOpenGLWidget::event( event ); + const bool ok = QOpenGLWidget::event(event); - if ( event->type() == QEvent::PolishRequest ) - { - // In opposite to non OpenGL widgets receive pointless - // early repaints. As we always have a QEvent::PolishRequest - // followed by QEvent::Paint, we can ignore all these repaints. + if (event->type() == QEvent::PolishRequest) + { + // In opposite to non OpenGL widgets receive pointless + // early repaints. As we always have a QEvent::PolishRequest + // followed by QEvent::Paint, we can ignore all these repaints. - m_data->isPolished = true; - } + m_data->isPolished = true; + } - if ( event->type() == QEvent::PolishRequest || - event->type() == QEvent::StyleChange ) - { - // assuming, that we always have a styled background - // when we have a style sheet + if (event->type() == QEvent::PolishRequest + || event->type() == QEvent::StyleChange) + { + // assuming, that we always have a styled background + // when we have a style sheet - setAttribute( Qt::WA_StyledBackground, - testAttribute( Qt::WA_StyleSheet ) ); - } + setAttribute(Qt::WA_StyledBackground, testAttribute(Qt::WA_StyleSheet)); + } - return ok; + return ok; } /*! @@ -141,19 +137,19 @@ bool QwtPlotOpenGLCanvas::event( QEvent* event ) */ void QwtPlotOpenGLCanvas::replot() { - QwtPlotAbstractGLCanvas::replot(); + QwtPlotAbstractGLCanvas::replot(); } //! Invalidate the internal backing store void QwtPlotOpenGLCanvas::invalidateBackingStore() { - m_data->fboDirty = true; + m_data->fboDirty = true; } void QwtPlotOpenGLCanvas::clearBackingStore() { - delete m_data->fbo; - m_data->fbo = NULL; + delete m_data->fbo; + m_data->fbo = NULL; } /*! @@ -165,94 +161,93 @@ void QwtPlotOpenGLCanvas::clearBackingStore() \param rect Bounding rectangle of the canvas \return Painter path, that can be used for clipping */ -QPainterPath QwtPlotOpenGLCanvas::borderPath( const QRect& rect ) const +QPainterPath QwtPlotOpenGLCanvas::borderPath(const QRect &rect) const { - return canvasBorderPath( rect ); + return canvasBorderPath(rect); } //! No operation - reserved for some potential use in the future -void QwtPlotOpenGLCanvas::initializeGL() -{ -} +void QwtPlotOpenGLCanvas::initializeGL() {} //! Paint the plot void QwtPlotOpenGLCanvas::paintGL() { - const bool hasFocusIndicator = - hasFocus() && focusIndicator() == CanvasFocusIndicator; + const bool hasFocusIndicator + = hasFocus() && focusIndicator() == CanvasFocusIndicator; - QPainter painter; + QPainter painter; - if ( testPaintAttribute( QwtPlotOpenGLCanvas::BackingStore ) && - QOpenGLFramebufferObject::hasOpenGLFramebufferBlit() ) + if (testPaintAttribute(QwtPlotOpenGLCanvas::BackingStore) + && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) + { + const qreal pixelRatio = QwtPainter::devicePixelRatio(NULL); + const QSize fboSize = size() * pixelRatio; + + if (hasFocusIndicator) + painter.begin(this); + + /* + QOpenGLWidget has its own internal FBO, that is used to restore + its content without having to repaint. This works fine when f.e + a rubberband is moving on top, but there are still situations, + where we can repaint without an potentially expensive replot: + + - when having the focus the top level window gets + activated/deactivated + - ??? + */ + + if (m_data->fbo) { - const qreal pixelRatio = QwtPainter::devicePixelRatio( NULL ); - const QSize fboSize = size() * pixelRatio; - - if ( hasFocusIndicator ) - painter.begin( this ); - - /* - QOpenGLWidget has its own internal FBO, that is used to restore - its content without having to repaint. This works fine when f.e - a rubberband is moving on top, but there are still situations, - where we can repaint without an potentially expensive replot: - - - when having the focus the top level window gets activated/deactivated - - ??? - */ - - if ( m_data->fbo ) - { - if ( m_data->fbo->size() != fboSize ) - { - delete m_data->fbo; - m_data->fbo = NULL; - } - } - - if ( m_data->fbo == NULL ) - { - QOpenGLFramebufferObjectFormat fboFormat; - fboFormat.setSamples( m_data->numSamples ); - fboFormat.setAttachment( QOpenGLFramebufferObject::CombinedDepthStencil ); - - m_data->fbo = new QOpenGLFramebufferObject( fboSize, fboFormat ); - m_data->fboDirty = true; - } - - if ( m_data->fboDirty ) - { - m_data->fbo->bind(); - - QOpenGLPaintDevice pd( fboSize ); - - QPainter fboPainter( &pd ); - fboPainter.scale( pixelRatio, pixelRatio ); - draw( &fboPainter); - fboPainter.end(); - - m_data->fboDirty = false; - } - - QOpenGLFramebufferObject::blitFramebuffer( NULL, m_data->fbo ); - } - else - { - painter.begin( this ); - draw( &painter ); + if (m_data->fbo->size() != fboSize) + { + delete m_data->fbo; + m_data->fbo = NULL; + } } - if ( hasFocusIndicator ) - drawFocusIndicator( &painter ); + if (m_data->fbo == NULL) + { + QOpenGLFramebufferObjectFormat fboFormat; + fboFormat.setSamples(m_data->numSamples); + fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + + m_data->fbo = new QOpenGLFramebufferObject(fboSize, fboFormat); + m_data->fboDirty = true; + } + + if (m_data->fboDirty) + { + m_data->fbo->bind(); + + QOpenGLPaintDevice pd(fboSize); + + QPainter fboPainter(&pd); + fboPainter.scale(pixelRatio, pixelRatio); + draw(&fboPainter); + fboPainter.end(); + + m_data->fboDirty = false; + } + + QOpenGLFramebufferObject::blitFramebuffer(NULL, m_data->fbo); + } + else + { + painter.begin(this); + draw(&painter); + } + + if (hasFocusIndicator) + drawFocusIndicator(&painter); } //! No operation - reserved for some potential use in the future -void QwtPlotOpenGLCanvas::resizeGL( int, int ) +void QwtPlotOpenGLCanvas::resizeGL(int, int) { - // nothing to do + // nothing to do } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_opengl_canvas.cpp" +# include "moc_qwt_plot_opengl_canvas.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_opengl_canvas.h b/libs/qwt/src/qwt_plot_opengl_canvas.h index a89bbb0d..590b0175 100644 --- a/libs/qwt/src/qwt_plot_opengl_canvas.h +++ b/libs/qwt/src/qwt_plot_opengl_canvas.h @@ -27,49 +27,50 @@ class QwtPlot; \sa QwtPlot::setCanvas(), QwtPlotCanvas, QwtPlotCanvas::OpenGLBuffer \note Another way for getting hardware accelerated graphics is using - an OpenGL offscreen buffer ( QwtPlotCanvas::OpenGLBuffer ) with QwtPlotCanvas. - Performance is worse, than rendering straight to a QOpenGLWidget, but is usually - better integrated into a desktop application. + an OpenGL offscreen buffer ( QwtPlotCanvas::OpenGLBuffer ) with + QwtPlotCanvas. Performance is worse, than rendering straight to a + QOpenGLWidget, but is usually better integrated into a desktop application. */ -class QWT_EXPORT QwtPlotOpenGLCanvas : public QOpenGLWidget, public QwtPlotAbstractGLCanvas +class QWT_EXPORT QwtPlotOpenGLCanvas : public QOpenGLWidget, + public QwtPlotAbstractGLCanvas { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( QFrame::Shadow frameShadow READ frameShadow WRITE setFrameShadow ) - Q_PROPERTY( QFrame::Shape frameShape READ frameShape WRITE setFrameShape ) - Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth ) - Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth ) - Q_PROPERTY( int frameWidth READ frameWidth ) - Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false ) + Q_PROPERTY(QFrame::Shadow frameShadow READ frameShadow WRITE setFrameShadow) + Q_PROPERTY(QFrame::Shape frameShape READ frameShape WRITE setFrameShape) + Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) + Q_PROPERTY(int midLineWidth READ midLineWidth WRITE setMidLineWidth) + Q_PROPERTY(int frameWidth READ frameWidth) + Q_PROPERTY(QRect frameRect READ frameRect DESIGNABLE false) - Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius ) + Q_PROPERTY(double borderRadius READ borderRadius WRITE setBorderRadius) - public: - explicit QwtPlotOpenGLCanvas( QwtPlot* = NULL ); - explicit QwtPlotOpenGLCanvas( const QSurfaceFormat&, QwtPlot* = NULL); - virtual ~QwtPlotOpenGLCanvas(); +public: + explicit QwtPlotOpenGLCanvas(QwtPlot * = NULL); + explicit QwtPlotOpenGLCanvas(const QSurfaceFormat &, QwtPlot * = NULL); + virtual ~QwtPlotOpenGLCanvas(); - Q_INVOKABLE virtual void invalidateBackingStore() QWT_OVERRIDE; - Q_INVOKABLE QPainterPath borderPath( const QRect& ) const; + Q_INVOKABLE virtual void invalidateBackingStore() QWT_OVERRIDE; + Q_INVOKABLE QPainterPath borderPath(const QRect &) const; - virtual bool event( QEvent* ) QWT_OVERRIDE; + virtual bool event(QEvent *) QWT_OVERRIDE; - public Q_SLOTS: - void replot(); +public Q_SLOTS: + void replot(); - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; - virtual void initializeGL() QWT_OVERRIDE; - virtual void paintGL() QWT_OVERRIDE; - virtual void resizeGL( int width, int height ) QWT_OVERRIDE; + virtual void initializeGL() QWT_OVERRIDE; + virtual void paintGL() QWT_OVERRIDE; + virtual void resizeGL(int width, int height) QWT_OVERRIDE; - private: - void init( const QSurfaceFormat& ); - virtual void clearBackingStore() QWT_OVERRIDE; +private: + void init(const QSurfaceFormat &); + virtual void clearBackingStore() QWT_OVERRIDE; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_panner.cpp b/libs/qwt/src/qwt_plot_panner.cpp index 0aa38c85..9c8be100 100644 --- a/libs/qwt/src/qwt_plot_panner.cpp +++ b/libs/qwt/src/qwt_plot_panner.cpp @@ -19,101 +19,101 @@ #include #include -static QBitmap qwtBorderMask( const QWidget* canvas, const QSize& size ) +static QBitmap qwtBorderMask(const QWidget *canvas, const QSize &size) { #if QT_VERSION >= 0x050000 - const qreal pixelRatio = QwtPainter::devicePixelRatio( canvas ); + const qreal pixelRatio = QwtPainter::devicePixelRatio(canvas); #endif - const QRect r( 0, 0, size.width(), size.height() ); + const QRect r(0, 0, size.width(), size.height()); - QPainterPath borderPath; + QPainterPath borderPath; - ( void )QMetaObject::invokeMethod( - const_cast< QWidget* >( canvas ), "borderPath", Qt::DirectConnection, - Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) ); + (void)QMetaObject::invokeMethod( + const_cast(canvas), "borderPath", Qt::DirectConnection, + Q_RETURN_ARG(QPainterPath, borderPath), Q_ARG(QRect, r)); - if ( borderPath.isEmpty() ) - { - if ( canvas->contentsRect() == canvas->rect() ) - return QBitmap(); + if (borderPath.isEmpty()) + { + if (canvas->contentsRect() == canvas->rect()) + return QBitmap(); #if QT_VERSION >= 0x050000 - QBitmap mask( size* pixelRatio ); - mask.setDevicePixelRatio( pixelRatio ); + QBitmap mask(size * pixelRatio); + mask.setDevicePixelRatio(pixelRatio); #else - QBitmap mask( size ); + QBitmap mask(size); #endif - mask.fill( Qt::color0 ); + mask.fill(Qt::color0); - QPainter painter( &mask ); - painter.fillRect( canvas->contentsRect(), Qt::color1 ); + QPainter painter(&mask); + painter.fillRect(canvas->contentsRect(), Qt::color1); - return mask; - } + return mask; + } #if QT_VERSION >= 0x050000 - QImage image( size* pixelRatio, QImage::Format_ARGB32_Premultiplied ); - image.setDevicePixelRatio( pixelRatio ); + QImage image(size * pixelRatio, QImage::Format_ARGB32_Premultiplied); + image.setDevicePixelRatio(pixelRatio); #else - QImage image( size, QImage::Format_ARGB32_Premultiplied ); + QImage image(size, QImage::Format_ARGB32_Premultiplied); #endif - image.fill( Qt::color0 ); + image.fill(Qt::color0); - QPainter painter( &image ); - painter.setClipPath( borderPath ); - painter.fillRect( r, Qt::color1 ); + QPainter painter(&image); + painter.setClipPath(borderPath); + painter.fillRect(r, Qt::color1); - // now erase the frame + // now erase the frame - painter.setCompositionMode( QPainter::CompositionMode_DestinationOut ); + painter.setCompositionMode(QPainter::CompositionMode_DestinationOut); - if ( canvas->testAttribute(Qt::WA_StyledBackground ) ) + if (canvas->testAttribute(Qt::WA_StyledBackground)) + { + QStyleOptionFrame opt; + opt.initFrom(canvas); + opt.rect = r; + canvas->style()->drawPrimitive(QStyle::PE_Frame, &opt, &painter, canvas); + } + else + { + const QVariant borderRadius = canvas->property("borderRadius"); + const QVariant frameWidth = canvas->property("frameWidth"); + + if (borderRadius.canConvert() && frameWidth.canConvert()) { - QStyleOptionFrame opt; - opt.initFrom(canvas); - opt.rect = r; - canvas->style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, canvas ); + const double br = borderRadius.value(); + const int fw = frameWidth.value(); + + if (br > 0.0 && fw > 0) + { + painter.setPen(QPen(Qt::color1, fw)); + painter.setBrush(Qt::NoBrush); + painter.setRenderHint(QPainter::Antialiasing, true); + + painter.drawPath(borderPath); + } } - else - { - const QVariant borderRadius = canvas->property( "borderRadius" ); - const QVariant frameWidth = canvas->property( "frameWidth" ); + } - if ( borderRadius.canConvert< double >() && frameWidth.canConvert< int >() ) - { - const double br = borderRadius.value< double >(); - const int fw = frameWidth.value< int >(); + painter.end(); - if ( br > 0.0 && fw > 0 ) - { - painter.setPen( QPen( Qt::color1, fw ) ); - painter.setBrush( Qt::NoBrush ); - painter.setRenderHint( QPainter::Antialiasing, true ); + const QImage mask + = image.createMaskFromColor(QColor(Qt::color1).rgb(), Qt::MaskOutColor); - painter.drawPath( borderPath ); - } - } - } - - painter.end(); - - const QImage mask = image.createMaskFromColor( - QColor( Qt::color1 ).rgb(), Qt::MaskOutColor ); - - return QBitmap::fromImage( mask ); + return QBitmap::fromImage(mask); } class QwtPlotPanner::PrivateData { - public: - PrivateData() - { - for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ ) - isAxisEnabled[axis] = true; - } +public: + PrivateData() + { + for (int axis = 0; axis < QwtAxis::AxisPositions; axis++) + isAxisEnabled[axis] = true; + } - bool isAxisEnabled[QwtAxis::AxisPositions]; + bool isAxisEnabled[QwtAxis::AxisPositions]; }; /*! @@ -125,19 +125,18 @@ class QwtPlotPanner::PrivateData \sa setAxisEnabled() */ -QwtPlotPanner::QwtPlotPanner( QWidget* canvas ) - : QwtPanner( canvas ) +QwtPlotPanner::QwtPlotPanner(QWidget *canvas) + : QwtPanner(canvas) { - m_data = new PrivateData(); + m_data = new PrivateData(); - connect( this, SIGNAL(panned(int,int)), - SLOT(moveCanvas(int,int)) ); + connect(this, SIGNAL(panned(int, int)), SLOT(moveCanvas(int, int))); } //! Destructor QwtPlotPanner::~QwtPlotPanner() { - delete m_data; + delete m_data; } /*! @@ -151,10 +150,10 @@ QwtPlotPanner::~QwtPlotPanner() \sa isAxisEnabled(), moveCanvas() */ -void QwtPlotPanner::setAxisEnabled( QwtAxisId axisId, bool on ) +void QwtPlotPanner::setAxisEnabled(QwtAxisId axisId, bool on) { - if ( QwtAxis::isValid( axisId ) ) - m_data->isAxisEnabled[axisId] = on; + if (QwtAxis::isValid(axisId)) + m_data->isAxisEnabled[axisId] = on; } /*! @@ -165,44 +164,44 @@ void QwtPlotPanner::setAxisEnabled( QwtAxisId axisId, bool on ) \sa setAxisEnabled(), moveCanvas() */ -bool QwtPlotPanner::isAxisEnabled( QwtAxisId axisId ) const +bool QwtPlotPanner::isAxisEnabled(QwtAxisId axisId) const { - if ( QwtAxis::isValid( axisId ) ) - return m_data->isAxisEnabled[axisId]; + if (QwtAxis::isValid(axisId)) + return m_data->isAxisEnabled[axisId]; - return true; + return true; } //! Return observed plot canvas -QWidget* QwtPlotPanner::canvas() +QWidget *QwtPlotPanner::canvas() { - return parentWidget(); + return parentWidget(); } //! Return Observed plot canvas -const QWidget* QwtPlotPanner::canvas() const +const QWidget *QwtPlotPanner::canvas() const { - return parentWidget(); + return parentWidget(); } //! Return plot widget, containing the observed plot canvas -QwtPlot* QwtPlotPanner::plot() +QwtPlot *QwtPlotPanner::plot() { - QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< QwtPlot* >( w ); + return qobject_cast(w); } //! Return plot widget, containing the observed plot canvas -const QwtPlot* QwtPlotPanner::plot() const +const QwtPlot *QwtPlotPanner::plot() const { - const QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + const QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< const QwtPlot* >( w ); + return qobject_cast(w); } /*! @@ -213,49 +212,49 @@ const QwtPlot* QwtPlotPanner::plot() const \sa QwtPanner::panned() */ -void QwtPlotPanner::moveCanvas( int dx, int dy ) +void QwtPlotPanner::moveCanvas(int dx, int dy) { - if ( dx == 0 && dy == 0 ) - return; + if (dx == 0 && dy == 0) + return; - QwtPlot* plot = this->plot(); - if ( plot == NULL ) - return; + QwtPlot *plot = this->plot(); + if (plot == NULL) + return; - const bool doAutoReplot = plot->autoReplot(); - plot->setAutoReplot( false ); + const bool doAutoReplot = plot->autoReplot(); + plot->setAutoReplot(false); - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { - { - const QwtAxisId axisId( axisPos ); + const QwtAxisId axisId(axisPos); - if ( !m_data->isAxisEnabled[axisId] ) - continue; + if (!m_data->isAxisEnabled[axisId]) + continue; - const QwtScaleMap map = plot->canvasMap( axisId ); + const QwtScaleMap map = plot->canvasMap(axisId); - const double p1 = map.transform( plot->axisScaleDiv( axisId ).lowerBound() ); - const double p2 = map.transform( plot->axisScaleDiv( axisId ).upperBound() ); + const double p1 = map.transform(plot->axisScaleDiv(axisId).lowerBound()); + const double p2 = map.transform(plot->axisScaleDiv(axisId).upperBound()); - double d1, d2; - if ( QwtAxis::isXAxis( axisPos ) ) - { - d1 = map.invTransform( p1 - dx ); - d2 = map.invTransform( p2 - dx ); - } - else - { - d1 = map.invTransform( p1 - dy ); - d2 = map.invTransform( p2 - dy ); - } + double d1, d2; + if (QwtAxis::isXAxis(axisPos)) + { + d1 = map.invTransform(p1 - dx); + d2 = map.invTransform(p2 - dx); + } + else + { + d1 = map.invTransform(p1 - dy); + d2 = map.invTransform(p2 - dy); + } - plot->setAxisScale( axisId, d1, d2 ); - } + plot->setAxisScale(axisId, d1, d2); } + } - plot->setAutoReplot( doAutoReplot ); - plot->replot(); + plot->setAutoReplot(doAutoReplot); + plot->replot(); } /*! @@ -266,10 +265,10 @@ void QwtPlotPanner::moveCanvas( int dx, int dy ) */ QBitmap QwtPlotPanner::contentsMask() const { - if ( canvas() ) - return qwtBorderMask( canvas(), size() ); + if (canvas()) + return qwtBorderMask(canvas(), size()); - return QwtPanner::contentsMask(); + return QwtPanner::contentsMask(); } /*! @@ -277,23 +276,23 @@ QBitmap QwtPlotPanner::contentsMask() const */ QPixmap QwtPlotPanner::grab() const { - const QWidget* cv = canvas(); - if ( cv && cv->inherits( "QGLWidget" ) ) - { - // we can't grab from a QGLWidget + const QWidget *cv = canvas(); + if (cv && cv->inherits("QGLWidget")) + { + // we can't grab from a QGLWidget - QPixmap pm( cv->size() ); - QwtPainter::fillPixmap( cv, pm ); + QPixmap pm(cv->size()); + QwtPainter::fillPixmap(cv, pm); - QPainter painter( &pm ); - const_cast< QwtPlot* >( plot() )->drawCanvas( &painter ); + QPainter painter(&pm); + const_cast(plot())->drawCanvas(&painter); - return pm; - } + return pm; + } - return QwtPanner::grab(); + return QwtPanner::grab(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_panner.cpp" +# include "moc_qwt_plot_panner.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_panner.h b/libs/qwt/src/qwt_plot_panner.h index a13b8ab0..ab89b193 100644 --- a/libs/qwt/src/qwt_plot_panner.h +++ b/libs/qwt/src/qwt_plot_panner.h @@ -31,31 +31,31 @@ class QwtPlot; */ class QWT_EXPORT QwtPlotPanner : public QwtPanner { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPlotPanner( QWidget* ); - virtual ~QwtPlotPanner(); +public: + explicit QwtPlotPanner(QWidget *); + virtual ~QwtPlotPanner(); - QWidget* canvas(); - const QWidget* canvas() const; + QWidget *canvas(); + const QWidget *canvas() const; - QwtPlot* plot(); - const QwtPlot* plot() const; + QwtPlot *plot(); + const QwtPlot *plot() const; - void setAxisEnabled( QwtAxisId axisId, bool on ); - bool isAxisEnabled( QwtAxisId ) const; + void setAxisEnabled(QwtAxisId axisId, bool on); + bool isAxisEnabled(QwtAxisId) const; - public Q_SLOTS: - virtual void moveCanvas( int dx, int dy ); +public Q_SLOTS: + virtual void moveCanvas(int dx, int dy); - protected: - virtual QBitmap contentsMask() const QWT_OVERRIDE; - virtual QPixmap grab() const QWT_OVERRIDE; +protected: + virtual QBitmap contentsMask() const QWT_OVERRIDE; + virtual QPixmap grab() const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_picker.cpp b/libs/qwt/src/qwt_plot_picker.cpp index b1c93032..ffb436fc 100644 --- a/libs/qwt/src/qwt_plot_picker.cpp +++ b/libs/qwt/src/qwt_plot_picker.cpp @@ -16,15 +16,15 @@ class QwtPlotPicker::PrivateData { - public: - PrivateData(): - xAxisId( -1 ), - yAxisId( -1 ) - { - } +public: + PrivateData() + : xAxisId(-1) + , yAxisId(-1) + { + } - QwtAxisId xAxisId; - QwtAxisId yAxisId; + QwtAxisId xAxisId; + QwtAxisId yAxisId; }; /*! @@ -40,28 +40,28 @@ class QwtPlotPicker::PrivateData \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect() */ -QwtPlotPicker::QwtPlotPicker( QWidget* canvas ) - : QwtPicker( canvas ) +QwtPlotPicker::QwtPlotPicker(QWidget *canvas) + : QwtPicker(canvas) { - m_data = new PrivateData; + m_data = new PrivateData; - if ( !canvas ) - return; + if (!canvas) + return; - const QwtPlot* plot = QwtPlotPicker::plot(); - // attach axes + const QwtPlot *plot = QwtPlotPicker::plot(); + // attach axes - using namespace QwtAxis; + using namespace QwtAxis; - int xAxis = XBottom; - if ( !plot->isAxisVisible( XBottom ) && plot->isAxisVisible( XTop ) ) - xAxis = XTop; + int xAxis = XBottom; + if (!plot->isAxisVisible(XBottom) && plot->isAxisVisible(XTop)) + xAxis = XTop; - int yAxis = YLeft; - if ( !plot->isAxisVisible( YLeft ) && plot->isAxisVisible( YRight ) ) - yAxis = YRight; + int yAxis = YLeft; + if (!plot->isAxisVisible(YLeft) && plot->isAxisVisible(YRight)) + yAxis = YRight; - setAxes( xAxis, yAxis ); + setAxes(xAxis, yAxis); } /*! @@ -73,12 +73,13 @@ QwtPlotPicker::QwtPlotPicker( QWidget* canvas ) \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect() */ -QwtPlotPicker::QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget* canvas ) - : QwtPicker( canvas ) +QwtPlotPicker::QwtPlotPicker(QwtAxisId xAxisId, QwtAxisId yAxisId, + QWidget *canvas) + : QwtPicker(canvas) { - m_data = new PrivateData; - m_data->xAxisId = xAxisId; - m_data->yAxisId = yAxisId; + m_data = new PrivateData; + m_data->xAxisId = xAxisId; + m_data->yAxisId = yAxisId; } /*! @@ -95,51 +96,52 @@ QwtPlotPicker::QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget* can \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect() */ -QwtPlotPicker::QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, - RubberBand rubberBand, DisplayMode trackerMode, QWidget* canvas ) - : QwtPicker( rubberBand, trackerMode, canvas ) +QwtPlotPicker::QwtPlotPicker(QwtAxisId xAxisId, QwtAxisId yAxisId, + RubberBand rubberBand, DisplayMode trackerMode, + QWidget *canvas) + : QwtPicker(rubberBand, trackerMode, canvas) { - m_data = new PrivateData; - m_data->xAxisId = xAxisId; - m_data->yAxisId = yAxisId; + m_data = new PrivateData; + m_data->xAxisId = xAxisId; + m_data->yAxisId = yAxisId; } //! Destructor QwtPlotPicker::~QwtPlotPicker() { - delete m_data; + delete m_data; } //! \return Observed plot canvas -QWidget* QwtPlotPicker::canvas() +QWidget *QwtPlotPicker::canvas() { - return parentWidget(); + return parentWidget(); } //! \return Observed plot canvas -const QWidget* QwtPlotPicker::canvas() const +const QWidget *QwtPlotPicker::canvas() const { - return parentWidget(); + return parentWidget(); } //! \return Plot widget, containing the observed plot canvas -QwtPlot* QwtPlotPicker::plot() +QwtPlot *QwtPlotPicker::plot() { - QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< QwtPlot* >( w ); + return qobject_cast(w); } //! \return Plot widget, containing the observed plot canvas -const QwtPlot* QwtPlotPicker::plot() const +const QwtPlot *QwtPlotPicker::plot() const { - const QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + const QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< const QwtPlot* >( w ); + return qobject_cast(w); } /*! @@ -148,19 +150,18 @@ const QwtPlot* QwtPlotPicker::plot() const */ QRectF QwtPlotPicker::scaleRect() const { - QRectF rect; + QRectF rect; - if ( plot() ) - { - const QwtScaleDiv& xs = plot()->axisScaleDiv( xAxis() ); - const QwtScaleDiv& ys = plot()->axisScaleDiv( yAxis() ); + if (plot()) + { + const QwtScaleDiv &xs = plot()->axisScaleDiv(xAxis()); + const QwtScaleDiv &ys = plot()->axisScaleDiv(yAxis()); - rect = QRectF( xs.lowerBound(), ys.lowerBound(), - xs.range(), ys.range() ); - rect = rect.normalized(); - } + rect = QRectF(xs.lowerBound(), ys.lowerBound(), xs.range(), ys.range()); + rect = rect.normalized(); + } - return rect; + return rect; } /*! @@ -169,29 +170,29 @@ QRectF QwtPlotPicker::scaleRect() const \param xAxisId X axis \param yAxisId Y axis */ -void QwtPlotPicker::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ) +void QwtPlotPicker::setAxes(QwtAxisId xAxisId, QwtAxisId yAxisId) { - const QwtPlot* plt = plot(); - if ( !plt ) - return; + const QwtPlot *plt = plot(); + if (!plt) + return; - if ( xAxisId != m_data->xAxisId || yAxisId != m_data->yAxisId ) - { - m_data->xAxisId = xAxisId; - m_data->yAxisId = yAxisId; - } + if (xAxisId != m_data->xAxisId || yAxisId != m_data->yAxisId) + { + m_data->xAxisId = xAxisId; + m_data->yAxisId = yAxisId; + } } //! Return x axis QwtAxisId QwtPlotPicker::xAxis() const { - return m_data->xAxisId; + return m_data->xAxisId; } //! Return y axis QwtAxisId QwtPlotPicker::yAxis() const { - return m_data->yAxisId; + return m_data->yAxisId; } /*! @@ -200,12 +201,12 @@ QwtAxisId QwtPlotPicker::yAxis() const \param pos Position in pixel coordinates \return Position string */ -QwtText QwtPlotPicker::trackerText( const QPoint& pos ) const +QwtText QwtPlotPicker::trackerText(const QPoint &pos) const { - if ( plot() == NULL ) - return QwtText(); + if (plot() == NULL) + return QwtText(); - return trackerTextF( invTransform( pos ) ); + return trackerTextF(invTransform(pos)); } /*! @@ -220,23 +221,23 @@ QwtText QwtPlotPicker::trackerText( const QPoint& pos ) const \param pos Position \return Position string */ -QwtText QwtPlotPicker::trackerTextF( const QPointF& pos ) const +QwtText QwtPlotPicker::trackerTextF(const QPointF &pos) const { - QString text; + QString text; - switch ( rubberBand() ) - { - case HLineRubberBand: - text = QString::number( pos.y(), 'f', 4 ); - break; - case VLineRubberBand: - text = QString::number( pos.x(), 'f', 4 ); - break; - default: - text = QString::number( pos.x(), 'f', 4 ) - + ", " + QString::number( pos.y(), 'f', 4 ); - } - return QwtText( text ); + switch (rubberBand()) + { + case HLineRubberBand: + text = QString::number(pos.y(), 'f', 4); + break; + case VLineRubberBand: + text = QString::number(pos.x(), 'f', 4); + break; + default: + text = QString::number(pos.x(), 'f', 4) + ", " + + QString::number(pos.y(), 'f', 4); + } + return QwtText(text); } /*! @@ -248,10 +249,10 @@ QwtText QwtPlotPicker::trackerTextF( const QPointF& pos ) const \note The appended(const QPoint &), appended(const QDoublePoint &) signals are emitted. */ -void QwtPlotPicker::append( const QPoint& pos ) +void QwtPlotPicker::append(const QPoint &pos) { - QwtPicker::append( pos ); - Q_EMIT appended( invTransform( pos ) ); + QwtPicker::append(pos); + Q_EMIT appended(invTransform(pos)); } /*! @@ -263,10 +264,10 @@ void QwtPlotPicker::append( const QPoint& pos ) \note The moved(const QPoint &), moved(const QDoublePoint &) signals are emitted. */ -void QwtPlotPicker::move( const QPoint& pos ) +void QwtPlotPicker::move(const QPoint &pos) { - QwtPicker::move( pos ); - Q_EMIT moved( invTransform( pos ) ); + QwtPicker::move(pos); + Q_EMIT moved(invTransform(pos)); } /*! @@ -277,59 +278,55 @@ void QwtPlotPicker::move( const QPoint& pos ) \return True if the selection has been accepted, false otherwise */ -bool QwtPlotPicker::end( bool ok ) +bool QwtPlotPicker::end(bool ok) { - ok = QwtPicker::end( ok ); - if ( !ok ) - return false; + ok = QwtPicker::end(ok); + if (!ok) + return false; - QwtPlot* plot = QwtPlotPicker::plot(); - if ( !plot ) - return false; + QwtPlot *plot = QwtPlotPicker::plot(); + if (!plot) + return false; - const QPolygon points = selection(); - if ( points.count() == 0 ) - return false; + const QPolygon points = selection(); + if (points.count() == 0) + return false; - QwtPickerMachine::SelectionType selectionType = - QwtPickerMachine::NoSelection; + QwtPickerMachine::SelectionType selectionType = QwtPickerMachine::NoSelection; - if ( stateMachine() ) - selectionType = stateMachine()->selectionType(); + if (stateMachine()) + selectionType = stateMachine()->selectionType(); - switch ( selectionType ) - { - case QwtPickerMachine::PointSelection: - { - const QPointF pos = invTransform( points.first() ); - Q_EMIT selected( pos ); - break; - } - case QwtPickerMachine::RectSelection: - { - if ( points.count() >= 2 ) - { - const QPoint p1 = points.first(); - const QPoint p2 = points.last(); - - const QRect rect = QRect( p1, p2 ).normalized(); - Q_EMIT selected( invTransform( rect ) ); - } - break; - } - case QwtPickerMachine::PolygonSelection: - { - QVector< QPointF > dpa( points.count() ); - for ( int i = 0; i < points.count(); i++ ) - dpa[i] = invTransform( points[i] ); - - Q_EMIT selected( dpa ); - } - default: - break; + switch (selectionType) + { + case QwtPickerMachine::PointSelection: { + const QPointF pos = invTransform(points.first()); + Q_EMIT selected(pos); + break; } + case QwtPickerMachine::RectSelection: { + if (points.count() >= 2) + { + const QPoint p1 = points.first(); + const QPoint p2 = points.last(); - return true; + const QRect rect = QRect(p1, p2).normalized(); + Q_EMIT selected(invTransform(rect)); + } + break; + } + case QwtPickerMachine::PolygonSelection: { + QVector dpa(points.count()); + for (int i = 0; i < points.count(); i++) + dpa[i] = invTransform(points[i]); + + Q_EMIT selected(dpa); + } + default: + break; + } + + return true; } /*! @@ -338,12 +335,12 @@ bool QwtPlotPicker::end( bool ok ) \return Rectangle in plot coordinates \sa transform() */ -QRectF QwtPlotPicker::invTransform( const QRect& rect ) const +QRectF QwtPlotPicker::invTransform(const QRect &rect) const { - const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot()->canvasMap( yAxis() ); + const QwtScaleMap xMap = plot()->canvasMap(xAxis()); + const QwtScaleMap yMap = plot()->canvasMap(yAxis()); - return QwtScaleMap::invTransform( xMap, yMap, rect ); + return QwtScaleMap::invTransform(xMap, yMap, rect); } /*! @@ -351,12 +348,12 @@ QRectF QwtPlotPicker::invTransform( const QRect& rect ) const \return Rectangle in pixel coordinates \sa invTransform() */ -QRect QwtPlotPicker::transform( const QRectF& rect ) const +QRect QwtPlotPicker::transform(const QRectF &rect) const { - const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot()->canvasMap( yAxis() ); + const QwtScaleMap xMap = plot()->canvasMap(xAxis()); + const QwtScaleMap yMap = plot()->canvasMap(yAxis()); - return QwtScaleMap::transform( xMap, yMap, rect ).toRect(); + return QwtScaleMap::transform(xMap, yMap, rect).toRect(); } /*! @@ -364,15 +361,12 @@ QRect QwtPlotPicker::transform( const QRectF& rect ) const \return Point in plot coordinates \sa transform() */ -QPointF QwtPlotPicker::invTransform( const QPoint& pos ) const +QPointF QwtPlotPicker::invTransform(const QPoint &pos) const { - const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot()->canvasMap( yAxis() ); + const QwtScaleMap xMap = plot()->canvasMap(xAxis()); + const QwtScaleMap yMap = plot()->canvasMap(yAxis()); - return QPointF( - xMap.invTransform( pos.x() ), - yMap.invTransform( pos.y() ) - ); + return QPointF(xMap.invTransform(pos.x()), yMap.invTransform(pos.y())); } /*! @@ -380,16 +374,16 @@ QPointF QwtPlotPicker::invTransform( const QPoint& pos ) const \return Point in pixel coordinates \sa invTransform() */ -QPoint QwtPlotPicker::transform( const QPointF& pos ) const +QPoint QwtPlotPicker::transform(const QPointF &pos) const { - const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot()->canvasMap( yAxis() ); + const QwtScaleMap xMap = plot()->canvasMap(xAxis()); + const QwtScaleMap yMap = plot()->canvasMap(yAxis()); - const QPointF p( xMap.transform( pos.x() ), yMap.transform( pos.y() ) ); + const QPointF p(xMap.transform(pos.x()), yMap.transform(pos.y())); - return p.toPoint(); + return p.toPoint(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_picker.cpp" +# include "moc_qwt_plot_picker.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_picker.h b/libs/qwt/src/qwt_plot_picker.h index f1508b3d..5890e59c 100644 --- a/libs/qwt/src/qwt_plot_picker.h +++ b/libs/qwt/src/qwt_plot_picker.h @@ -19,7 +19,8 @@ class QPointF; class QRectF; #if QT_VERSION < 0x060000 -template< typename T > class QVector; +template +class QVector; #endif /*! @@ -32,86 +33,87 @@ template< typename T > class QVector; class QWT_EXPORT QwtPlotPicker : public QwtPicker { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPlotPicker( QWidget* canvas ); - virtual ~QwtPlotPicker(); +public: + explicit QwtPlotPicker(QWidget *canvas); + virtual ~QwtPlotPicker(); - explicit QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget* ); + explicit QwtPlotPicker(QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget *); - explicit QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, - RubberBand rubberBand, DisplayMode trackerMode, QWidget* ); + explicit QwtPlotPicker(QwtAxisId xAxisId, QwtAxisId yAxisId, + RubberBand rubberBand, DisplayMode trackerMode, + QWidget *); - virtual void setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ); + virtual void setAxes(QwtAxisId xAxisId, QwtAxisId yAxisId); - QwtAxisId xAxis() const; - QwtAxisId yAxis() const; + QwtAxisId xAxis() const; + QwtAxisId yAxis() const; - QwtPlot* plot(); - const QwtPlot* plot() const; + QwtPlot *plot(); + const QwtPlot *plot() const; - QWidget* canvas(); - const QWidget* canvas() const; + QWidget *canvas(); + const QWidget *canvas() const; - Q_SIGNALS: +Q_SIGNALS: - /*! - A signal emitted in case of QwtPickerMachine::PointSelection. - \param pos Selected point - */ - void selected( const QPointF& pos ); + /*! + A signal emitted in case of QwtPickerMachine::PointSelection. + \param pos Selected point + */ + void selected(const QPointF &pos); - /*! - A signal emitted in case of QwtPickerMachine::RectSelection. - \param rect Selected rectangle - */ - void selected( const QRectF& rect ); + /*! + A signal emitted in case of QwtPickerMachine::RectSelection. + \param rect Selected rectangle + */ + void selected(const QRectF &rect); - /*! - A signal emitting the selected points, - at the end of a selection. + /*! + A signal emitting the selected points, + at the end of a selection. - \param pa Selected points - */ - void selected( const QVector< QPointF >& pa ); + \param pa Selected points + */ + void selected(const QVector &pa); - /*! - A signal emitted when a point has been appended to the selection + /*! + A signal emitted when a point has been appended to the selection - \param pos Position of the appended point. - \sa append(). moved() - */ - void appended( const QPointF& pos ); + \param pos Position of the appended point. + \sa append(). moved() + */ + void appended(const QPointF &pos); - /*! - A signal emitted whenever the last appended point of the - selection has been moved. + /*! + A signal emitted whenever the last appended point of the + selection has been moved. - \param pos Position of the moved last point of the selection. - \sa move(), appended() - */ - void moved( const QPointF& pos ); + \param pos Position of the moved last point of the selection. + \sa move(), appended() + */ + void moved(const QPointF &pos); - protected: - QRectF scaleRect() const; +protected: + QRectF scaleRect() const; - QRectF invTransform( const QRect& ) const; - QRect transform( const QRectF& ) const; + QRectF invTransform(const QRect &) const; + QRect transform(const QRectF &) const; - QPointF invTransform( const QPoint& ) const; - QPoint transform( const QPointF& ) const; + QPointF invTransform(const QPoint &) const; + QPoint transform(const QPointF &) const; - virtual QwtText trackerText( const QPoint& ) const QWT_OVERRIDE; - virtual QwtText trackerTextF( const QPointF& ) const; + virtual QwtText trackerText(const QPoint &) const QWT_OVERRIDE; + virtual QwtText trackerTextF(const QPointF &) const; - virtual void move( const QPoint& ) QWT_OVERRIDE; - virtual void append( const QPoint& ) QWT_OVERRIDE; - virtual bool end( bool ok = true ) QWT_OVERRIDE; + virtual void move(const QPoint &) QWT_OVERRIDE; + virtual void append(const QPoint &) QWT_OVERRIDE; + virtual bool end(bool ok = true) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_rasteritem.cpp b/libs/qwt/src/qwt_plot_rasteritem.cpp index 6f48bf14..cc1686f5 100644 --- a/libs/qwt/src/qwt_plot_rasteritem.cpp +++ b/libs/qwt/src/qwt_plot_rasteritem.cpp @@ -24,440 +24,438 @@ class QwtPlotRasterItem::PrivateData { - public: - PrivateData() - : alpha( -1 ) - , paintAttributes( QwtPlotRasterItem::PaintInDeviceResolution ) - { - cache.policy = QwtPlotRasterItem::NoCache; - } +public: + PrivateData() + : alpha(-1) + , paintAttributes(QwtPlotRasterItem::PaintInDeviceResolution) + { + cache.policy = QwtPlotRasterItem::NoCache; + } - int alpha; + int alpha; - QwtPlotRasterItem::PaintAttributes paintAttributes; + QwtPlotRasterItem::PaintAttributes paintAttributes; - struct ImageCache - { - QwtPlotRasterItem::CachePolicy policy; - QRectF area; - QSizeF size; - QImage image; - } cache; + struct ImageCache + { + QwtPlotRasterItem::CachePolicy policy; + QRectF area; + QSizeF size; + QImage image; + } cache; }; - -static QRectF qwtAlignRect(const QRectF& rect) +static QRectF qwtAlignRect(const QRectF &rect) { - QRectF r; - r.setLeft( qRound( rect.left() ) ); - r.setRight( qRound( rect.right() ) ); - r.setTop( qRound( rect.top() ) ); - r.setBottom( qRound( rect.bottom() ) ); + QRectF r; + r.setLeft(qRound(rect.left())); + r.setRight(qRound(rect.right())); + r.setTop(qRound(rect.top())); + r.setBottom(qRound(rect.bottom())); - return r; + return r; } -static QRectF qwtStripRect(const QRectF& rect, const QRectF& area, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtInterval& xInterval, const QwtInterval& yInterval) +static QRectF qwtStripRect(const QRectF &rect, const QRectF &area, + const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtInterval &xInterval, + const QwtInterval &yInterval) { - QRectF r = rect; - if ( xInterval.borderFlags() & QwtInterval::ExcludeMinimum ) + QRectF r = rect; + if (xInterval.borderFlags() & QwtInterval::ExcludeMinimum) + { + if (area.left() <= xInterval.minValue()) { - if ( area.left() <= xInterval.minValue() ) - { - if ( xMap.isInverting() ) - r.adjust(0, 0, -1, 0); - else - r.adjust(1, 0, 0, 0); - } + if (xMap.isInverting()) + r.adjust(0, 0, -1, 0); + else + r.adjust(1, 0, 0, 0); } + } - if ( xInterval.borderFlags() & QwtInterval::ExcludeMaximum ) + if (xInterval.borderFlags() & QwtInterval::ExcludeMaximum) + { + if (area.right() >= xInterval.maxValue()) { - if ( area.right() >= xInterval.maxValue() ) - { - if ( xMap.isInverting() ) - r.adjust(1, 0, 0, 0); - else - r.adjust(0, 0, -1, 0); - } + if (xMap.isInverting()) + r.adjust(1, 0, 0, 0); + else + r.adjust(0, 0, -1, 0); } + } - if ( yInterval.borderFlags() & QwtInterval::ExcludeMinimum ) + if (yInterval.borderFlags() & QwtInterval::ExcludeMinimum) + { + if (area.top() <= yInterval.minValue()) { - if ( area.top() <= yInterval.minValue() ) - { - if ( yMap.isInverting() ) - r.adjust(0, 0, 0, -1); - else - r.adjust(0, 1, 0, 0); - } + if (yMap.isInverting()) + r.adjust(0, 0, 0, -1); + else + r.adjust(0, 1, 0, 0); } + } - if ( yInterval.borderFlags() & QwtInterval::ExcludeMaximum ) + if (yInterval.borderFlags() & QwtInterval::ExcludeMaximum) + { + if (area.bottom() >= yInterval.maxValue()) { - if ( area.bottom() >= yInterval.maxValue() ) - { - if ( yMap.isInverting() ) - r.adjust(0, 1, 0, 0); - else - r.adjust(0, 0, 0, -1); - } + if (yMap.isInverting()) + r.adjust(0, 1, 0, 0); + else + r.adjust(0, 0, 0, -1); } + } - return r; + return r; } -static QImage qwtExpandImage(const QImage& image, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& area, const QRectF& area2, const QRectF& paintRect, - const QwtInterval& xInterval, const QwtInterval& yInterval ) +static QImage qwtExpandImage(const QImage &image, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &area, + const QRectF &area2, const QRectF &paintRect, + const QwtInterval &xInterval, + const QwtInterval &yInterval) { - const QRectF strippedRect = qwtStripRect(paintRect, area2, - xMap, yMap, xInterval, yInterval); - const QSize sz = strippedRect.toRect().size(); + const QRectF strippedRect + = qwtStripRect(paintRect, area2, xMap, yMap, xInterval, yInterval); + const QSize sz = strippedRect.toRect().size(); - const int w = image.width(); - const int h = image.height(); + const int w = image.width(); + const int h = image.height(); - const QRectF r = QwtScaleMap::transform(xMap, yMap, area).normalized(); - const double pw = ( r.width() - 1 ) / w; - const double ph = ( r.height() - 1 ) / h; + const QRectF r = QwtScaleMap::transform(xMap, yMap, area).normalized(); + const double pw = (r.width() - 1) / w; + const double ph = (r.height() - 1) / h; - double px0, py0; - if ( !xMap.isInverting() ) - { - px0 = xMap.transform( area2.left() ); - px0 = qRound( px0 ); - px0 = px0 - xMap.transform( area.left() ); - } - else - { - px0 = xMap.transform( area2.right() ); - px0 = qRound( px0 ); - px0 -= xMap.transform( area.right() ); + double px0, py0; + if (!xMap.isInverting()) + { + px0 = xMap.transform(area2.left()); + px0 = qRound(px0); + px0 = px0 - xMap.transform(area.left()); + } + else + { + px0 = xMap.transform(area2.right()); + px0 = qRound(px0); + px0 -= xMap.transform(area.right()); - px0 -= 1.0; - } - px0 += strippedRect.left() - paintRect.left(); + px0 -= 1.0; + } + px0 += strippedRect.left() - paintRect.left(); - if ( !yMap.isInverting() ) - { - py0 = yMap.transform( area2.top() ); - py0 = qRound( py0 ); - py0 -= yMap.transform( area.top() ); - } - else - { - py0 = yMap.transform( area2.bottom() ); - py0 = qRound( py0 ); - py0 -= yMap.transform( area.bottom() ); + if (!yMap.isInverting()) + { + py0 = yMap.transform(area2.top()); + py0 = qRound(py0); + py0 -= yMap.transform(area.top()); + } + else + { + py0 = yMap.transform(area2.bottom()); + py0 = qRound(py0); + py0 -= yMap.transform(area.bottom()); - py0 -= 1.0; - } - py0 += strippedRect.top() - paintRect.top(); + py0 -= 1.0; + } + py0 += strippedRect.top() - paintRect.top(); - QImage expanded( sz, image.format() ); - if ( image.format() == QImage::Format_Indexed8 ) - expanded.setColorTable( image.colorTable() ); + QImage expanded(sz, image.format()); + if (image.format() == QImage::Format_Indexed8) + expanded.setColorTable(image.colorTable()); - switch( image.depth() ) - { - case 32: + switch (image.depth()) + { + case 32: { + for (int y1 = 0; y1 < h; y1++) + { + int yy1; + if (y1 == 0) { - for ( int y1 = 0; y1 < h; y1++ ) - { - int yy1; - if ( y1 == 0 ) - { - yy1 = 0; - } - else - { - yy1 = qRound( y1 * ph - py0 ); - if ( yy1 < 0 ) - yy1 = 0; - } - - int yy2; - if ( y1 == h - 1 ) - { - yy2 = sz.height(); - } - else - { - yy2 = qRound( ( y1 + 1 ) * ph - py0 ); - if ( yy2 > sz.height() ) - yy2 = sz.height(); - } - - const quint32* line1 = - reinterpret_cast< const quint32* >( image.scanLine( y1 ) ); - - for ( int x1 = 0; x1 < w; x1++ ) - { - int xx1; - if ( x1 == 0 ) - { - xx1 = 0; - } - else - { - xx1 = qRound( x1 * pw - px0 ); - if ( xx1 < 0 ) - xx1 = 0; - } - - int xx2; - if ( x1 == w - 1 ) - { - xx2 = sz.width(); - } - else - { - xx2 = qRound( ( x1 + 1 ) * pw - px0 ); - if ( xx2 > sz.width() ) - xx2 = sz.width(); - } - - const quint32 rgb( line1[x1] ); - for ( int y2 = yy1; y2 < yy2; y2++ ) - { - quint32* line2 = reinterpret_cast< quint32* >( - expanded.scanLine( y2 ) ); - - for ( int x2 = xx1; x2 < xx2; x2++ ) - line2[x2] = rgb; - } - } - } - break; + yy1 = 0; } - case 8: + else { - for ( int y1 = 0; y1 < h; y1++ ) - { - int yy1; - if ( y1 == 0 ) - { - yy1 = 0; - } - else - { - yy1 = qRound( y1 * ph - py0 ); - if ( yy1 < 0 ) - yy1 = 0; - } - - int yy2; - if ( y1 == h - 1 ) - { - yy2 = sz.height(); - } - else - { - yy2 = qRound( ( y1 + 1 ) * ph - py0 ); - if ( yy2 > sz.height() ) - yy2 = sz.height(); - } - - const uchar* line1 = image.scanLine( y1 ); - - for ( int x1 = 0; x1 < w; x1++ ) - { - int xx1; - if ( x1 == 0 ) - { - xx1 = 0; - } - else - { - xx1 = qRound( x1 * pw - px0 ); - if ( xx1 < 0 ) - xx1 = 0; - } - - int xx2; - if ( x1 == w - 1 ) - { - xx2 = sz.width(); - } - else - { - xx2 = qRound( ( x1 + 1 ) * pw - px0 ); - if ( xx2 > sz.width() ) - xx2 = sz.width(); - } - - for ( int y2 = yy1; y2 < yy2; y2++ ) - { - uchar* line2 = expanded.scanLine( y2 ); - memset( line2 + xx1, line1[x1], xx2 - xx1 ); - } - } - } - break; + yy1 = qRound(y1 * ph - py0); + if (yy1 < 0) + yy1 = 0; } - default: - expanded = image; - } - return expanded; -} - -static QRectF qwtExpandToPixels(const QRectF& rect, const QRectF& pixelRect) -{ - const double pw = pixelRect.width(); - const double ph = pixelRect.height(); - - const double dx1 = pixelRect.left() - rect.left(); - const double dx2 = pixelRect.right() - rect.right(); - const double dy1 = pixelRect.top() - rect.top(); - const double dy2 = pixelRect.bottom() - rect.bottom(); - - QRectF r; - r.setLeft( pixelRect.left() - qwtCeil( dx1 / pw ) * pw ); - r.setTop( pixelRect.top() - qwtCeil( dy1 / ph ) * ph ); - r.setRight( pixelRect.right() - qwtFloor( dx2 / pw ) * pw ); - r.setBottom( pixelRect.bottom() - qwtFloor( dy2 / ph ) * ph ); - - return r; -} - -static void qwtTransformMaps( const QTransform& tr, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - QwtScaleMap& xxMap, QwtScaleMap& yyMap ) -{ - const QPointF p1 = tr.map( QPointF( xMap.p1(), yMap.p1() ) ); - const QPointF p2 = tr.map( QPointF( xMap.p2(), yMap.p2() ) ); - - xxMap = xMap; - xxMap.setPaintInterval( p1.x(), p2.x() ); - - yyMap = yMap; - yyMap.setPaintInterval( p1.y(), p2.y() ); -} - -static void qwtAdjustMaps( QwtScaleMap& xMap, QwtScaleMap& yMap, - const QRectF& area, const QRectF& paintRect) -{ - double sx1 = area.left(); - double sx2 = area.right(); - if ( xMap.isInverting() ) - qSwap(sx1, sx2); - - double sy1 = area.top(); - double sy2 = area.bottom(); - - if ( yMap.isInverting() ) - qSwap(sy1, sy2); - - xMap.setPaintInterval(paintRect.left(), paintRect.right() ); - xMap.setScaleInterval(sx1, sx2); - - yMap.setPaintInterval(paintRect.top(), paintRect.bottom() ); - yMap.setScaleInterval(sy1, sy2); -} - -static bool qwtUseCache( QwtPlotRasterItem::CachePolicy policy, - const QPainter* painter ) -{ - bool doCache = false; - - if ( policy == QwtPlotRasterItem::PaintCache ) - { - // Caching doesn't make sense, when the item is - // not painted to screen - - switch ( painter->paintEngine()->type() ) + int yy2; + if (y1 == h - 1) { - case QPaintEngine::SVG: - case QPaintEngine::Pdf: + yy2 = sz.height(); + } + else + { + yy2 = qRound((y1 + 1) * ph - py0); + if (yy2 > sz.height()) + yy2 = sz.height(); + } + + const quint32 *line1 + = reinterpret_cast(image.scanLine(y1)); + + for (int x1 = 0; x1 < w; x1++) + { + int xx1; + if (x1 == 0) + { + xx1 = 0; + } + else + { + xx1 = qRound(x1 * pw - px0); + if (xx1 < 0) + xx1 = 0; + } + + int xx2; + if (x1 == w - 1) + { + xx2 = sz.width(); + } + else + { + xx2 = qRound((x1 + 1) * pw - px0); + if (xx2 > sz.width()) + xx2 = sz.width(); + } + + const quint32 rgb(line1[x1]); + for (int y2 = yy1; y2 < yy2; y2++) + { + quint32 *line2 = reinterpret_cast(expanded.scanLine(y2)); + + for (int x2 = xx1; x2 < xx2; x2++) + line2[x2] = rgb; + } + } + } + break; + } + case 8: { + for (int y1 = 0; y1 < h; y1++) + { + int yy1; + if (y1 == 0) + { + yy1 = 0; + } + else + { + yy1 = qRound(y1 * ph - py0); + if (yy1 < 0) + yy1 = 0; + } + + int yy2; + if (y1 == h - 1) + { + yy2 = sz.height(); + } + else + { + yy2 = qRound((y1 + 1) * ph - py0); + if (yy2 > sz.height()) + yy2 = sz.height(); + } + + const uchar *line1 = image.scanLine(y1); + + for (int x1 = 0; x1 < w; x1++) + { + int xx1; + if (x1 == 0) + { + xx1 = 0; + } + else + { + xx1 = qRound(x1 * pw - px0); + if (xx1 < 0) + xx1 = 0; + } + + int xx2; + if (x1 == w - 1) + { + xx2 = sz.width(); + } + else + { + xx2 = qRound((x1 + 1) * pw - px0); + if (xx2 > sz.width()) + xx2 = sz.width(); + } + + for (int y2 = yy1; y2 < yy2; y2++) + { + uchar *line2 = expanded.scanLine(y2); + memset(line2 + xx1, line1[x1], xx2 - xx1); + } + } + } + break; + } + default: + expanded = image; + } + + return expanded; +} + +static QRectF qwtExpandToPixels(const QRectF &rect, const QRectF &pixelRect) +{ + const double pw = pixelRect.width(); + const double ph = pixelRect.height(); + + const double dx1 = pixelRect.left() - rect.left(); + const double dx2 = pixelRect.right() - rect.right(); + const double dy1 = pixelRect.top() - rect.top(); + const double dy2 = pixelRect.bottom() - rect.bottom(); + + QRectF r; + r.setLeft(pixelRect.left() - qwtCeil(dx1 / pw) * pw); + r.setTop(pixelRect.top() - qwtCeil(dy1 / ph) * ph); + r.setRight(pixelRect.right() - qwtFloor(dx2 / pw) * pw); + r.setBottom(pixelRect.bottom() - qwtFloor(dy2 / ph) * ph); + + return r; +} + +static void qwtTransformMaps(const QTransform &tr, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, QwtScaleMap &xxMap, + QwtScaleMap &yyMap) +{ + const QPointF p1 = tr.map(QPointF(xMap.p1(), yMap.p1())); + const QPointF p2 = tr.map(QPointF(xMap.p2(), yMap.p2())); + + xxMap = xMap; + xxMap.setPaintInterval(p1.x(), p2.x()); + + yyMap = yMap; + yyMap.setPaintInterval(p1.y(), p2.y()); +} + +static void qwtAdjustMaps(QwtScaleMap &xMap, QwtScaleMap &yMap, + const QRectF &area, const QRectF &paintRect) +{ + double sx1 = area.left(); + double sx2 = area.right(); + if (xMap.isInverting()) + qSwap(sx1, sx2); + + double sy1 = area.top(); + double sy2 = area.bottom(); + + if (yMap.isInverting()) + qSwap(sy1, sy2); + + xMap.setPaintInterval(paintRect.left(), paintRect.right()); + xMap.setScaleInterval(sx1, sx2); + + yMap.setPaintInterval(paintRect.top(), paintRect.bottom()); + yMap.setScaleInterval(sy1, sy2); +} + +static bool qwtUseCache(QwtPlotRasterItem::CachePolicy policy, + const QPainter *painter) +{ + bool doCache = false; + + if (policy == QwtPlotRasterItem::PaintCache) + { + // Caching doesn't make sense, when the item is + // not painted to screen + + switch (painter->paintEngine()->type()) + { + case QPaintEngine::SVG: + case QPaintEngine::Pdf: #if QT_VERSION < 0x060000 - case QPaintEngine::PostScript: + case QPaintEngine::PostScript: #endif - case QPaintEngine::MacPrinter: - case QPaintEngine::Picture: - break; - default:; - doCache = true; - } + case QPaintEngine::MacPrinter: + case QPaintEngine::Picture: + break; + default:; + doCache = true; } + } - return doCache; + return doCache; } -static void qwtToRgba( const QImage* from, QImage* to, - const QRect& tile, int alpha ) +static void qwtToRgba(const QImage *from, QImage *to, const QRect &tile, + int alpha) { - const QRgb mask1 = qRgba( 0, 0, 0, alpha ); - const QRgb mask2 = qRgba( 255, 255, 255, 0 ); - const QRgb mask3 = qRgba( 0, 0, 0, 255 ); + const QRgb mask1 = qRgba(0, 0, 0, alpha); + const QRgb mask2 = qRgba(255, 255, 255, 0); + const QRgb mask3 = qRgba(0, 0, 0, 255); - const int y0 = tile.top(); - const int y1 = tile.bottom(); - const int x0 = tile.left(); - const int x1 = tile.right(); + const int y0 = tile.top(); + const int y1 = tile.bottom(); + const int x0 = tile.left(); + const int x1 = tile.right(); - if ( from->depth() == 8 ) + if (from->depth() == 8) + { + for (int y = y0; y <= y1; y++) { - for ( int y = y0; y <= y1; y++ ) - { - QRgb* alphaLine = reinterpret_cast< QRgb* >( to->scanLine( y ) ); - const unsigned char* line = from->scanLine( y ); + QRgb *alphaLine = reinterpret_cast(to->scanLine(y)); + const unsigned char *line = from->scanLine(y); - for ( int x = x0; x <= x1; x++ ) - *alphaLine++ = ( from->color( *line++ ) & mask2 ) | mask1; - } + for (int x = x0; x <= x1; x++) + *alphaLine++ = (from->color(*line++) & mask2) | mask1; } - else if ( from->depth() == 32 ) + } + else if (from->depth() == 32) + { + for (int y = y0; y <= y1; y++) { - for ( int y = y0; y <= y1; y++ ) - { - QRgb* alphaLine = reinterpret_cast< QRgb* >( to->scanLine( y ) ); - const QRgb* line = reinterpret_cast< const QRgb* >( from->scanLine( y ) ); + QRgb *alphaLine = reinterpret_cast(to->scanLine(y)); + const QRgb *line = reinterpret_cast(from->scanLine(y)); - for ( int x = x0; x <= x1; x++ ) - { - const QRgb rgb = *line++; - if ( rgb & mask3 ) // alpha != 0 - *alphaLine++ = ( rgb & mask2 ) | mask1; - else - *alphaLine++ = rgb; - } - } + for (int x = x0; x <= x1; x++) + { + const QRgb rgb = *line++; + if (rgb & mask3) // alpha != 0 + *alphaLine++ = (rgb & mask2) | mask1; + else + *alphaLine++ = rgb; + } } + } } //! Constructor -QwtPlotRasterItem::QwtPlotRasterItem( const QString& title ) - : QwtPlotItem( QwtText( title ) ) +QwtPlotRasterItem::QwtPlotRasterItem(const QString &title) + : QwtPlotItem(QwtText(title)) { - init(); + init(); } //! Constructor -QwtPlotRasterItem::QwtPlotRasterItem( const QwtText& title ) - : QwtPlotItem( title ) +QwtPlotRasterItem::QwtPlotRasterItem(const QwtText &title) + : QwtPlotItem(title) { - init(); + init(); } //! Destructor QwtPlotRasterItem::~QwtPlotRasterItem() { - delete m_data; + delete m_data; } void QwtPlotRasterItem::init() { - m_data = new PrivateData(); + m_data = new PrivateData(); - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Legend, false ); + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Legend, false); - setZ( 8.0 ); + setZ(8.0); } /*! @@ -467,21 +465,21 @@ void QwtPlotRasterItem::init() \param on On/Off /sa PaintAttribute, testPaintAttribute() */ -void QwtPlotRasterItem::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPlotRasterItem::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! \return True, when attribute is enabled \sa PaintAttribute, setPaintAttribute() */ -bool QwtPlotRasterItem::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPlotRasterItem::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! @@ -507,20 +505,20 @@ bool QwtPlotRasterItem::testPaintAttribute( PaintAttribute attribute ) const \sa alpha() */ -void QwtPlotRasterItem::setAlpha( int alpha ) +void QwtPlotRasterItem::setAlpha(int alpha) { - if ( alpha < 0 ) - alpha = -1; + if (alpha < 0) + alpha = -1; - if ( alpha > 255 ) - alpha = 255; + if (alpha > 255) + alpha = 255; - if ( alpha != m_data->alpha ) - { - m_data->alpha = alpha; + if (alpha != m_data->alpha) + { + m_data->alpha = alpha; - itemChanged(); - } + itemChanged(); + } } /*! @@ -529,7 +527,7 @@ void QwtPlotRasterItem::setAlpha( int alpha ) */ int QwtPlotRasterItem::alpha() const { - return m_data->alpha; + return m_data->alpha; } /*! @@ -540,16 +538,15 @@ int QwtPlotRasterItem::alpha() const \param policy Cache policy \sa CachePolicy, cachePolicy() */ -void QwtPlotRasterItem::setCachePolicy( - QwtPlotRasterItem::CachePolicy policy ) +void QwtPlotRasterItem::setCachePolicy(QwtPlotRasterItem::CachePolicy policy) { - if ( m_data->cache.policy != policy ) - { - m_data->cache.policy = policy; + if (m_data->cache.policy != policy) + { + m_data->cache.policy = policy; - invalidateCache(); - itemChanged(); - } + invalidateCache(); + itemChanged(); + } } /*! @@ -558,7 +555,7 @@ void QwtPlotRasterItem::setCachePolicy( */ QwtPlotRasterItem::CachePolicy QwtPlotRasterItem::cachePolicy() const { - return m_data->cache.policy; + return m_data->cache.policy; } /*! @@ -567,9 +564,9 @@ QwtPlotRasterItem::CachePolicy QwtPlotRasterItem::cachePolicy() const */ void QwtPlotRasterItem::invalidateCache() { - m_data->cache.image = QImage(); - m_data->cache.area = QRect(); - m_data->cache.size = QSize(); + m_data->cache.image = QImage(); + m_data->cache.area = QRect(); + m_data->cache.size = QSize(); } /*! @@ -598,10 +595,10 @@ void QwtPlotRasterItem::invalidateCache() \sa render(), renderImage() */ -QRectF QwtPlotRasterItem::pixelHint( const QRectF& area ) const +QRectF QwtPlotRasterItem::pixelHint(const QRectF &area) const { - Q_UNUSED( area ); - return QRectF(); + Q_UNUSED(area); + return QRectF(); } /*! @@ -611,160 +608,157 @@ QRectF QwtPlotRasterItem::pixelHint( const QRectF& area ) const \param yMap Y-Scale Map \param canvasRect Contents rectangle of the plot canvas */ -void QwtPlotRasterItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotRasterItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - if ( canvasRect.isEmpty() || m_data->alpha == 0 ) - return; + if (canvasRect.isEmpty() || m_data->alpha == 0) + return; - const bool doCache = qwtUseCache( m_data->cache.policy, painter ); + const bool doCache = qwtUseCache(m_data->cache.policy, painter); - const QwtInterval xInterval = interval( Qt::XAxis ); - const QwtInterval yInterval = interval( Qt::YAxis ); + const QwtInterval xInterval = interval(Qt::XAxis); + const QwtInterval yInterval = interval(Qt::YAxis); - /* - Scaling an image always results in a loss of - precision/quality. So we always render the image in - paint device resolution. - */ + /* + Scaling an image always results in a loss of + precision/quality. So we always render the image in + paint device resolution. + */ - QwtScaleMap xxMap, yyMap; - qwtTransformMaps( painter->transform(), xMap, yMap, xxMap, yyMap ); + QwtScaleMap xxMap, yyMap; + qwtTransformMaps(painter->transform(), xMap, yMap, xxMap, yyMap); - QRectF paintRect = painter->transform().mapRect( canvasRect ); - QRectF area = QwtScaleMap::invTransform( xxMap, yyMap, paintRect ); + QRectF paintRect = painter->transform().mapRect(canvasRect); + QRectF area = QwtScaleMap::invTransform(xxMap, yyMap, paintRect); - const QRectF br = boundingRect(); - if ( br.isValid() && !br.contains( area ) ) + const QRectF br = boundingRect(); + if (br.isValid() && !br.contains(area)) + { + area &= br; + if (!area.isValid()) + return; + + paintRect = QwtScaleMap::transform(xxMap, yyMap, area); + } + + QRectF imageRect; + QImage image; + + QRectF pixelRect = pixelHint(area); + if (!pixelRect.isEmpty()) + { + // one pixel of the target device in plot coordinates + const double dx = qAbs(xxMap.invTransform(1) - xxMap.invTransform(0)); + const double dy = qAbs(yyMap.invTransform(1) - yyMap.invTransform(0)); + + if (dx > pixelRect.width() && dy > pixelRect.height()) { - area &= br; - if ( !area.isValid() ) - return; - - paintRect = QwtScaleMap::transform( xxMap, yyMap, area ); - } - - QRectF imageRect; - QImage image; - - QRectF pixelRect = pixelHint(area); - if ( !pixelRect.isEmpty() ) - { - // one pixel of the target device in plot coordinates - const double dx = qAbs( xxMap.invTransform( 1 ) - xxMap.invTransform( 0 ) ); - const double dy = qAbs( yyMap.invTransform( 1 ) - yyMap.invTransform( 0 ) ); - - if ( dx > pixelRect.width() && dy > pixelRect.height() ) - { - /* - When the resolution of the data pixels is higher than - the resolution of the target device we render in - target device resolution. - */ - pixelRect = QRectF(); - } - else - { - /* - If only one dimension is of the data pixel is higher - we expand the pixel rect to the resolution of the target device. - */ - - if ( dx > pixelRect.width() ) - pixelRect.setWidth( dx ); - - if ( dy > pixelRect.height() ) - pixelRect.setHeight( dy ); - } - } - - if ( pixelRect.isEmpty() ) - { - if ( QwtPainter::roundingAlignment( painter ) ) - { - // we want to have maps, where the boundaries of - // the aligned paint rectangle exactly match the area - - paintRect = qwtAlignRect(paintRect); - qwtAdjustMaps(xxMap, yyMap, area, paintRect); - } - - // When we have no information about position and size of - // data pixels we render in resolution of the paint device. - - image = compose(xxMap, yyMap, - area, paintRect, paintRect.size().toSize(), doCache); - if ( image.isNull() ) - return; - - // Remove pixels at the boundaries, when explicitly - // excluded in the intervals - - imageRect = qwtStripRect(paintRect, area, - xxMap, yyMap, xInterval, yInterval); - - if ( imageRect != paintRect ) - { - const QRect r( - qRound( imageRect.x() - paintRect.x() ), - qRound( imageRect.y() - paintRect.y() ), - qRound( imageRect.width() ), - qRound( imageRect.height() ) ); - - image = image.copy(r); - } + /* + When the resolution of the data pixels is higher than + the resolution of the target device we render in + target device resolution. + */ + pixelRect = QRectF(); } else { - if ( QwtPainter::roundingAlignment( painter ) ) - paintRect = qwtAlignRect(paintRect); + /* + If only one dimension is of the data pixel is higher + we expand the pixel rect to the resolution of the target device. + */ - // align the area to the data pixels - QRectF imageArea = qwtExpandToPixels(area, pixelRect); + if (dx > pixelRect.width()) + pixelRect.setWidth(dx); - if ( imageArea.right() == xInterval.maxValue() && - !( xInterval.borderFlags() & QwtInterval::ExcludeMaximum ) ) - { - imageArea.adjust(0, 0, pixelRect.width(), 0); - } - if ( imageArea.bottom() == yInterval.maxValue() && - !( yInterval.borderFlags() & QwtInterval::ExcludeMaximum ) ) - { - imageArea.adjust(0, 0, 0, pixelRect.height() ); - } + if (dy > pixelRect.height()) + pixelRect.setHeight(dy); + } + } - QSize imageSize; - imageSize.setWidth( qRound( imageArea.width() / pixelRect.width() ) ); - imageSize.setHeight( qRound( imageArea.height() / pixelRect.height() ) ); + if (pixelRect.isEmpty()) + { + if (QwtPainter::roundingAlignment(painter)) + { + // we want to have maps, where the boundaries of + // the aligned paint rectangle exactly match the area - image = compose(xxMap, yyMap, - imageArea, paintRect, imageSize, doCache ); - - if ( image.isNull() ) - return; - - imageRect = qwtStripRect(paintRect, area, - xxMap, yyMap, xInterval, yInterval); - - if ( ( image.width() > 1 || image.height() > 1 ) && - testPaintAttribute( PaintInDeviceResolution ) ) - { - // Because of rounding errors the pixels - // need to be expanded manually to rectangles of - // different sizes - - image = qwtExpandImage(image, xxMap, yyMap, - imageArea, area, paintRect, xInterval, yInterval ); - } + paintRect = qwtAlignRect(paintRect); + qwtAdjustMaps(xxMap, yyMap, area, paintRect); } - painter->save(); - painter->setWorldTransform( QTransform() ); + // When we have no information about position and size of + // data pixels we render in resolution of the paint device. - QwtPainter::drawImage( painter, imageRect, image ); + image = compose(xxMap, yyMap, area, paintRect, paintRect.size().toSize(), + doCache); + if (image.isNull()) + return; - painter->restore(); + // Remove pixels at the boundaries, when explicitly + // excluded in the intervals + + imageRect + = qwtStripRect(paintRect, area, xxMap, yyMap, xInterval, yInterval); + + if (imageRect != paintRect) + { + const QRect r(qRound(imageRect.x() - paintRect.x()), + qRound(imageRect.y() - paintRect.y()), + qRound(imageRect.width()), qRound(imageRect.height())); + + image = image.copy(r); + } + } + else + { + if (QwtPainter::roundingAlignment(painter)) + paintRect = qwtAlignRect(paintRect); + + // align the area to the data pixels + QRectF imageArea = qwtExpandToPixels(area, pixelRect); + + if (imageArea.right() == xInterval.maxValue() + && !(xInterval.borderFlags() & QwtInterval::ExcludeMaximum)) + { + imageArea.adjust(0, 0, pixelRect.width(), 0); + } + if (imageArea.bottom() == yInterval.maxValue() + && !(yInterval.borderFlags() & QwtInterval::ExcludeMaximum)) + { + imageArea.adjust(0, 0, 0, pixelRect.height()); + } + + QSize imageSize; + imageSize.setWidth(qRound(imageArea.width() / pixelRect.width())); + imageSize.setHeight(qRound(imageArea.height() / pixelRect.height())); + + image = compose(xxMap, yyMap, imageArea, paintRect, imageSize, doCache); + + if (image.isNull()) + return; + + imageRect + = qwtStripRect(paintRect, area, xxMap, yyMap, xInterval, yInterval); + + if ((image.width() > 1 || image.height() > 1) + && testPaintAttribute(PaintInDeviceResolution)) + { + // Because of rounding errors the pixels + // need to be expanded manually to rectangles of + // different sizes + + image = qwtExpandImage(image, xxMap, yyMap, imageArea, area, paintRect, + xInterval, yInterval); + } + } + + painter->save(); + painter->setWorldTransform(QTransform()); + + QwtPainter::drawImage(painter, imageRect, image); + + painter->restore(); } /*! @@ -777,8 +771,8 @@ void QwtPlotRasterItem::draw( QPainter* painter, */ QwtInterval QwtPlotRasterItem::interval(Qt::Axis axis) const { - Q_UNUSED( axis ); - return QwtInterval(); + Q_UNUSED(axis); + return QwtInterval(); } /*! @@ -787,130 +781,130 @@ QwtInterval QwtPlotRasterItem::interval(Qt::Axis axis) const */ QRectF QwtPlotRasterItem::boundingRect() const { - const QwtInterval intervalX = interval( Qt::XAxis ); - const QwtInterval intervalY = interval( Qt::YAxis ); + const QwtInterval intervalX = interval(Qt::XAxis); + const QwtInterval intervalY = interval(Qt::YAxis); - if ( !intervalX.isValid() && !intervalY.isValid() ) - return QRectF(); // no bounding rect + if (!intervalX.isValid() && !intervalY.isValid()) + return QRectF(); // no bounding rect - QRectF r; + QRectF r; - if ( intervalX.isValid() ) - { - r.setLeft( intervalX.minValue() ); - r.setRight( intervalX.maxValue() ); - } - else - { - const qreal max = std::numeric_limits< float >::max(); + if (intervalX.isValid()) + { + r.setLeft(intervalX.minValue()); + r.setRight(intervalX.maxValue()); + } + else + { + const qreal max = std::numeric_limits::max(); - r.setLeft( -0.5 * max ); - r.setWidth( max ); - } + r.setLeft(-0.5 * max); + r.setWidth(max); + } - if ( intervalY.isValid() ) - { - r.setTop( intervalY.minValue() ); - r.setBottom( intervalY.maxValue() ); - } - else - { - const qreal max = std::numeric_limits< float >::max(); + if (intervalY.isValid()) + { + r.setTop(intervalY.minValue()); + r.setBottom(intervalY.maxValue()); + } + else + { + const qreal max = std::numeric_limits::max(); - r.setTop( -0.5 * max ); - r.setHeight( max ); - } + r.setTop(-0.5 * max); + r.setHeight(max); + } - return r.normalized(); + return r.normalized(); } -QImage QwtPlotRasterItem::compose( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& imageArea, const QRectF& paintRect, - const QSize& imageSize, bool doCache) const +QImage QwtPlotRasterItem::compose(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &imageArea, + const QRectF &paintRect, + const QSize &imageSize, bool doCache) const { - QImage image; - if ( imageArea.isEmpty() || paintRect.isEmpty() || imageSize.isEmpty() ) - return image; - - if ( doCache ) - { - if ( !m_data->cache.image.isNull() - && m_data->cache.area == imageArea - && m_data->cache.size == paintRect.size() ) - { - image = m_data->cache.image; - } - } - - if ( image.isNull() ) - { - double dx = 0.0; - if ( paintRect.toRect().width() > imageSize.width() ) - dx = imageArea.width() / imageSize.width(); - - const QwtScaleMap xxMap = - imageMap(Qt::Horizontal, xMap, imageArea, imageSize, dx); - - double dy = 0.0; - if ( paintRect.toRect().height() > imageSize.height() ) - dy = imageArea.height() / imageSize.height(); - - const QwtScaleMap yyMap = - imageMap(Qt::Vertical, yMap, imageArea, imageSize, dy); - - image = renderImage( xxMap, yyMap, imageArea, imageSize ); - - if ( doCache ) - { - m_data->cache.area = imageArea; - m_data->cache.size = paintRect.size(); - m_data->cache.image = image; - } - } - - if ( m_data->alpha >= 0 && m_data->alpha < 255 ) - { - QImage alphaImage( image.size(), QImage::Format_ARGB32 ); - -#if !defined( QT_NO_QFUTURE ) - uint numThreads = renderThreadCount(); - - if ( numThreads <= 0 ) - numThreads = QThread::idealThreadCount(); - - if ( numThreads <= 0 ) - numThreads = 1; - - const int numRows = image.height() / numThreads; - - QVector< QFuture< void > > futures; - futures.reserve( numThreads - 1 ); - - for ( uint i = 0; i < numThreads; i++ ) - { - QRect tile( 0, i * numRows, image.width(), numRows ); - if ( i == numThreads - 1 ) - { - tile.setHeight( image.height() - i * numRows ); - qwtToRgba( &image, &alphaImage, tile, m_data->alpha ); - } - else - { - futures += QtConcurrent::run( - &qwtToRgba, &image, &alphaImage, tile, m_data->alpha ); - } - } - for ( int i = 0; i < futures.size(); i++ ) - futures[i].waitForFinished(); -#else - const QRect tile( 0, 0, image.width(), image.height() ); - qwtToRgba( &image, &alphaImage, tile, m_data->alpha ); -#endif - image = alphaImage; - } - + QImage image; + if (imageArea.isEmpty() || paintRect.isEmpty() || imageSize.isEmpty()) return image; + + if (doCache) + { + if (!m_data->cache.image.isNull() && m_data->cache.area == imageArea + && m_data->cache.size == paintRect.size()) + { + image = m_data->cache.image; + } + } + + if (image.isNull()) + { + double dx = 0.0; + if (paintRect.toRect().width() > imageSize.width()) + dx = imageArea.width() / imageSize.width(); + + const QwtScaleMap xxMap + = imageMap(Qt::Horizontal, xMap, imageArea, imageSize, dx); + + double dy = 0.0; + if (paintRect.toRect().height() > imageSize.height()) + dy = imageArea.height() / imageSize.height(); + + const QwtScaleMap yyMap + = imageMap(Qt::Vertical, yMap, imageArea, imageSize, dy); + + image = renderImage(xxMap, yyMap, imageArea, imageSize); + + if (doCache) + { + m_data->cache.area = imageArea; + m_data->cache.size = paintRect.size(); + m_data->cache.image = image; + } + } + + if (m_data->alpha >= 0 && m_data->alpha < 255) + { + QImage alphaImage(image.size(), QImage::Format_ARGB32); + +#if !defined(QT_NO_QFUTURE) + uint numThreads = renderThreadCount(); + + if (numThreads <= 0) + numThreads = QThread::idealThreadCount(); + + if (numThreads <= 0) + numThreads = 1; + + const int numRows = image.height() / numThreads; + + QVector> futures; + futures.reserve(numThreads - 1); + + for (uint i = 0; i < numThreads; i++) + { + QRect tile(0, i * numRows, image.width(), numRows); + if (i == numThreads - 1) + { + tile.setHeight(image.height() - i * numRows); + qwtToRgba(&image, &alphaImage, tile, m_data->alpha); + } + else + { + futures += QtConcurrent::run(&qwtToRgba, &image, &alphaImage, tile, + m_data->alpha); + } + } + for (int i = 0; i < futures.size(); i++) + futures[i].waitForFinished(); +#else + const QRect tile(0, 0, image.width(), image.height()); + qwtToRgba(&image, &alphaImage, tile, m_data->alpha); +#endif + image = alphaImage; + } + + return image; } /*! @@ -924,48 +918,49 @@ QImage QwtPlotRasterItem::compose( \return Calculated scale map */ -QwtScaleMap QwtPlotRasterItem::imageMap( - Qt::Orientation orientation, - const QwtScaleMap& map, const QRectF& area, - const QSize& imageSize, double pixelSize) const +QwtScaleMap QwtPlotRasterItem::imageMap(Qt::Orientation orientation, + const QwtScaleMap &map, + const QRectF &area, + const QSize &imageSize, + double pixelSize) const { - double p1, p2, s1, s2; + double p1, p2, s1, s2; - if ( orientation == Qt::Horizontal ) - { - p1 = 0.0; - p2 = imageSize.width(); - s1 = area.left(); - s2 = area.right(); - } - else - { - p1 = 0.0; - p2 = imageSize.height(); - s1 = area.top(); - s2 = area.bottom(); - } + if (orientation == Qt::Horizontal) + { + p1 = 0.0; + p2 = imageSize.width(); + s1 = area.left(); + s2 = area.right(); + } + else + { + p1 = 0.0; + p2 = imageSize.height(); + s1 = area.top(); + s2 = area.bottom(); + } - if ( pixelSize > 0.0 || p2 == 1.0 ) - { - double off = 0.5 * pixelSize; - if ( map.isInverting() ) - off = -off; + if (pixelSize > 0.0 || p2 == 1.0) + { + double off = 0.5 * pixelSize; + if (map.isInverting()) + off = -off; - s1 += off; - s2 += off; - } - else - { - p2--; - } + s1 += off; + s2 += off; + } + else + { + p2--; + } - if ( map.isInverting() && ( s1 < s2 ) ) - qSwap( s1, s2 ); + if (map.isInverting() && (s1 < s2)) + qSwap(s1, s2); - QwtScaleMap newMap = map; - newMap.setPaintInterval( p1, p2 ); - newMap.setScaleInterval( s1, s2 ); + QwtScaleMap newMap = map; + newMap.setPaintInterval(p1, p2); + newMap.setScaleInterval(s1, s2); - return newMap; + return newMap; } diff --git a/libs/qwt/src/qwt_plot_rasteritem.h b/libs/qwt/src/qwt_plot_rasteritem.h index 4b66f6e3..25b97c2d 100644 --- a/libs/qwt/src/qwt_plot_rasteritem.h +++ b/libs/qwt/src/qwt_plot_rasteritem.h @@ -36,116 +36,115 @@ class QwtInterval; class QWT_EXPORT QwtPlotRasterItem : public QwtPlotItem { - public: +public: + /*! + \brief Cache policy + The default policy is NoCache + */ + enum CachePolicy + { /*! - \brief Cache policy - The default policy is NoCache + renderImage() is called each time the item has to be repainted */ - enum CachePolicy - { - /*! - renderImage() is called each time the item has to be repainted - */ - NoCache, - - /*! - renderImage() is called, whenever the image cache is not valid, - or the scales, or the size of the canvas has changed. - - This type of cache is useful for improving the performance - of hide/show operations or manipulations of the alpha value. - All other situations are handled by the canvas backing store. - */ - PaintCache - }; + NoCache, /*! - Attributes to modify the drawing algorithm. - \sa setPaintAttribute(), testPaintAttribute() + renderImage() is called, whenever the image cache is not valid, + or the scales, or the size of the canvas has changed. + + This type of cache is useful for improving the performance + of hide/show operations or manipulations of the alpha value. + All other situations are handled by the canvas backing store. */ - enum PaintAttribute - { - /*! - When the image is rendered according to the data pixels - ( QwtRasterData::pixelHint() ) it can be expanded to paint - device resolution before it is passed to QPainter. - The expansion algorithm rounds the pixel borders in the same - way as the axis ticks, what is usually better than the - scaling algorithm implemented in Qt. - Disabling this flag might make sense, to reduce the size of a - document/file. If this is possible for a document format - depends on the implementation of the specific QPaintEngine. - */ + PaintCache + }; - PaintInDeviceResolution = 1 - }; - - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) - - explicit QwtPlotRasterItem( const QString& title = QString() ); - explicit QwtPlotRasterItem( const QwtText& title ); - virtual ~QwtPlotRasterItem(); - - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; - - void setAlpha( int alpha ); - int alpha() const; - - void setCachePolicy( CachePolicy ); - CachePolicy cachePolicy() const; - - void invalidateCache(); - - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; - - virtual QRectF pixelHint( const QRectF& ) const; - - virtual QwtInterval interval(Qt::Axis) const; - virtual QRectF boundingRect() const QWT_OVERRIDE; - - protected: + /*! + Attributes to modify the drawing algorithm. + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { /*! - \brief Render an image - - An implementation of render() might iterate over all - pixels of imageRect. Each pixel has to be translated into - the corresponding position in scale coordinates using the maps. - This position can be used to look up a value in a implementation - specific way and to map it into a color. - - \param xMap X-Scale Map - \param yMap Y-Scale Map - \param area Requested area for the image in scale coordinates - \param imageSize Requested size of the image - - \return Rendered image + When the image is rendered according to the data pixels + ( QwtRasterData::pixelHint() ) it can be expanded to paint + device resolution before it is passed to QPainter. + The expansion algorithm rounds the pixel borders in the same + way as the axis ticks, what is usually better than the + scaling algorithm implemented in Qt. + Disabling this flag might make sense, to reduce the size of a + document/file. If this is possible for a document format + depends on the implementation of the specific QPaintEngine. */ - virtual QImage renderImage( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QRectF& area, - const QSize& imageSize ) const = 0; - virtual QwtScaleMap imageMap( Qt::Orientation, - const QwtScaleMap& map, const QRectF& area, - const QSize& imageSize, double pixelSize) const; + PaintInDeviceResolution = 1 + }; - private: - explicit QwtPlotRasterItem( const QwtPlotRasterItem& ); - QwtPlotRasterItem& operator=( const QwtPlotRasterItem& ); + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - void init(); + explicit QwtPlotRasterItem(const QString &title = QString()); + explicit QwtPlotRasterItem(const QwtText &title); + virtual ~QwtPlotRasterItem(); - QImage compose( const QwtScaleMap&, const QwtScaleMap&, - const QRectF& imageArea, const QRectF& paintRect, - const QSize& imageSize, bool doCache) const; + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; + void setAlpha(int alpha); + int alpha() const; - class PrivateData; - PrivateData* m_data; + void setCachePolicy(CachePolicy); + CachePolicy cachePolicy() const; + + void invalidateCache(); + + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; + + virtual QRectF pixelHint(const QRectF &) const; + + virtual QwtInterval interval(Qt::Axis) const; + virtual QRectF boundingRect() const QWT_OVERRIDE; + +protected: + /*! + \brief Render an image + + An implementation of render() might iterate over all + pixels of imageRect. Each pixel has to be translated into + the corresponding position in scale coordinates using the maps. + This position can be used to look up a value in a implementation + specific way and to map it into a color. + + \param xMap X-Scale Map + \param yMap Y-Scale Map + \param area Requested area for the image in scale coordinates + \param imageSize Requested size of the image + + \return Rendered image + */ + virtual QImage renderImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &area, const QSize &imageSize) const + = 0; + + virtual QwtScaleMap imageMap(Qt::Orientation, const QwtScaleMap &map, + const QRectF &area, const QSize &imageSize, + double pixelSize) const; + +private: + explicit QwtPlotRasterItem(const QwtPlotRasterItem &); + QwtPlotRasterItem &operator=(const QwtPlotRasterItem &); + + void init(); + + QImage compose(const QwtScaleMap &, const QwtScaleMap &, + const QRectF &imageArea, const QRectF &paintRect, + const QSize &imageSize, bool doCache) const; + + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRasterItem::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotRasterItem::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_renderer.cpp b/libs/qwt/src/qwt_plot_renderer.cpp index 058c6d0c..1ae967b4 100644 --- a/libs/qwt/src/qwt_plot_renderer.cpp +++ b/libs/qwt/src/qwt_plot_renderer.cpp @@ -30,13 +30,13 @@ #include #ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB -#define QWT_FORMAT_SVG 1 -#endif +# ifdef QT_SVG_LIB +# define QWT_FORMAT_SVG 1 +# endif #endif #ifndef QT_NO_PRINTER -#define QWT_FORMAT_PDF 1 +# define QWT_FORMAT_PDF 1 #endif #ifndef QT_NO_PDF @@ -45,114 +45,113 @@ // Qt 5.3. Guess it is o.k. to stay with QPrinter for older // versions. -#if QT_VERSION >= 0x050300 +# if QT_VERSION >= 0x050300 -#ifndef QWT_FORMAT_PDF -#define QWT_FORMAT_PDF 1 -#endif +# ifndef QWT_FORMAT_PDF +# define QWT_FORMAT_PDF 1 +# endif -#define QWT_PDF_WRITER 1 +# define QWT_PDF_WRITER 1 -#endif +# endif #endif #ifndef QT_NO_PRINTER // postscript support has been dropped in Qt5 -#if QT_VERSION < 0x050000 -#define QWT_FORMAT_POSTSCRIPT 1 -#endif +# if QT_VERSION < 0x050000 +# define QWT_FORMAT_POSTSCRIPT 1 +# endif #endif #if QWT_FORMAT_SVG -#include +# include #endif #if QWT_PDF_WRITER -#include +# include #endif -static qreal qwtScalePenWidth( const QwtPlot* plot ) +static qreal qwtScalePenWidth(const QwtPlot *plot) { - qreal pw = 0.0; + qreal pw = 0.0; - for ( int axisId = 0; axisId < QwtAxis::AxisPositions; axisId++ ) - { - if ( plot->isAxisVisible( axisId ) ) - pw = qMax( pw, plot->axisScaleDraw( axisId )->penWidthF() ); - } + for (int axisId = 0; axisId < QwtAxis::AxisPositions; axisId++) + { + if (plot->isAxisVisible(axisId)) + pw = qMax(pw, plot->axisScaleDraw(axisId)->penWidthF()); + } - return pw; + return pw; } -static QColor qwtScalePenColor( const QwtPlot* plot ) +static QColor qwtScalePenColor(const QwtPlot *plot) { - const QPalette pal = plot->axisWidget( QwtAxis::YLeft )->palette(); - return pal.color( QPalette::WindowText ); + const QPalette pal = plot->axisWidget(QwtAxis::YLeft)->palette(); + return pal.color(QPalette::WindowText); } -static QPainterPath qwtCanvasClip( - const QWidget* canvas, const QRectF& canvasRect ) +static QPainterPath qwtCanvasClip(const QWidget *canvas, + const QRectF &canvasRect) { - // The clip region is calculated in integers - // To avoid too much rounding errors better - // calculate it in target device resolution + // The clip region is calculated in integers + // To avoid too much rounding errors better + // calculate it in target device resolution - int x1 = qwtCeil( canvasRect.left() ); - int x2 = qwtFloor( canvasRect.right() ); - int y1 = qwtCeil( canvasRect.top() ); - int y2 = qwtFloor( canvasRect.bottom() ); + int x1 = qwtCeil(canvasRect.left()); + int x2 = qwtFloor(canvasRect.right()); + int y1 = qwtCeil(canvasRect.top()); + int y2 = qwtFloor(canvasRect.bottom()); - const QRect r( x1, y1, x2 - x1 - 1, y2 - y1 - 1 ); + const QRect r(x1, y1, x2 - x1 - 1, y2 - y1 - 1); - QPainterPath clipPath; + QPainterPath clipPath; - ( void ) QMetaObject::invokeMethod( - const_cast< QWidget* >( canvas ), "borderPath", - Qt::DirectConnection, - Q_RETURN_ARG( QPainterPath, clipPath ), Q_ARG( QRect, r ) ); + (void)QMetaObject::invokeMethod( + const_cast(canvas), "borderPath", Qt::DirectConnection, + Q_RETURN_ARG(QPainterPath, clipPath), Q_ARG(QRect, r)); - return clipPath; + return clipPath; } -static inline QFont qwtResolvedFont( const QWidget* widget ) +static inline QFont qwtResolvedFont(const QWidget *widget) { - QFont font = widget->font(); + QFont font = widget->font(); #if QT_VERSION >= 0x060000 - font.setResolveMask( QFont::AllPropertiesResolved ); + font.setResolveMask(QFont::AllPropertiesResolved); #else - font.resolve( QFont::AllPropertiesResolved ); + font.resolve(QFont::AllPropertiesResolved); #endif - return font; + return font; } class QwtPlotRenderer::PrivateData { - public: - PrivateData() - : discardFlags( QwtPlotRenderer::DiscardNone ) - , layoutFlags( QwtPlotRenderer::DefaultLayout ) - { - } +public: + PrivateData() + : discardFlags(QwtPlotRenderer::DiscardNone) + , layoutFlags(QwtPlotRenderer::DefaultLayout) + { + } - QwtPlotRenderer::DiscardFlags discardFlags; - QwtPlotRenderer::LayoutFlags layoutFlags; + QwtPlotRenderer::DiscardFlags discardFlags; + QwtPlotRenderer::LayoutFlags layoutFlags; }; /*! Constructor \param parent Parent object */ -QwtPlotRenderer::QwtPlotRenderer( QObject* parent ) - : QObject( parent ) +QwtPlotRenderer::QwtPlotRenderer(QObject *parent) + : QObject(parent) { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtPlotRenderer::~QwtPlotRenderer() { - delete m_data; + delete m_data; } /*! @@ -163,12 +162,12 @@ QwtPlotRenderer::~QwtPlotRenderer() \sa DiscardFlag, testDiscardFlag(), setDiscardFlags(), discardFlags() */ -void QwtPlotRenderer::setDiscardFlag( DiscardFlag flag, bool on ) +void QwtPlotRenderer::setDiscardFlag(DiscardFlag flag, bool on) { - if ( on ) - m_data->discardFlags |= flag; - else - m_data->discardFlags &= ~flag; + if (on) + m_data->discardFlags |= flag; + else + m_data->discardFlags &= ~flag; } /*! @@ -176,9 +175,9 @@ void QwtPlotRenderer::setDiscardFlag( DiscardFlag flag, bool on ) \param flag Flag to be tested \sa DiscardFlag, setDiscardFlag(), setDiscardFlags(), discardFlags() */ -bool QwtPlotRenderer::testDiscardFlag( DiscardFlag flag ) const +bool QwtPlotRenderer::testDiscardFlag(DiscardFlag flag) const { - return m_data->discardFlags & flag; + return m_data->discardFlags & flag; } /*! @@ -187,9 +186,9 @@ bool QwtPlotRenderer::testDiscardFlag( DiscardFlag flag ) const \param flags Flags \sa DiscardFlag, setDiscardFlag(), testDiscardFlag(), discardFlags() */ -void QwtPlotRenderer::setDiscardFlags( DiscardFlags flags ) +void QwtPlotRenderer::setDiscardFlags(DiscardFlags flags) { - m_data->discardFlags = flags; + m_data->discardFlags = flags; } /*! @@ -198,7 +197,7 @@ void QwtPlotRenderer::setDiscardFlags( DiscardFlags flags ) */ QwtPlotRenderer::DiscardFlags QwtPlotRenderer::discardFlags() const { - return m_data->discardFlags; + return m_data->discardFlags; } /*! @@ -209,12 +208,12 @@ QwtPlotRenderer::DiscardFlags QwtPlotRenderer::discardFlags() const \sa LayoutFlag, testLayoutFlag(), setLayoutFlags(), layoutFlags() */ -void QwtPlotRenderer::setLayoutFlag( LayoutFlag flag, bool on ) +void QwtPlotRenderer::setLayoutFlag(LayoutFlag flag, bool on) { - if ( on ) - m_data->layoutFlags |= flag; - else - m_data->layoutFlags &= ~flag; + if (on) + m_data->layoutFlags |= flag; + else + m_data->layoutFlags &= ~flag; } /*! @@ -222,9 +221,9 @@ void QwtPlotRenderer::setLayoutFlag( LayoutFlag flag, bool on ) \param flag Flag to be tested \sa LayoutFlag, setLayoutFlag(), setLayoutFlags(), layoutFlags() */ -bool QwtPlotRenderer::testLayoutFlag( LayoutFlag flag ) const +bool QwtPlotRenderer::testLayoutFlag(LayoutFlag flag) const { - return m_data->layoutFlags & flag; + return m_data->layoutFlags & flag; } /*! @@ -233,9 +232,9 @@ bool QwtPlotRenderer::testLayoutFlag( LayoutFlag flag ) const \param flags Flags \sa LayoutFlag, setLayoutFlag(), testLayoutFlag(), layoutFlags() */ -void QwtPlotRenderer::setLayoutFlags( LayoutFlags flags ) +void QwtPlotRenderer::setLayoutFlags(LayoutFlags flags) { - m_data->layoutFlags = flags; + m_data->layoutFlags = flags; } /*! @@ -244,7 +243,7 @@ void QwtPlotRenderer::setLayoutFlags( LayoutFlags flags ) */ QwtPlotRenderer::LayoutFlags QwtPlotRenderer::layoutFlags() const { - return m_data->layoutFlags; + return m_data->layoutFlags; } /*! @@ -258,11 +257,11 @@ QwtPlotRenderer::LayoutFlags QwtPlotRenderer::layoutFlags() const \param sizeMM Size for the document in millimeters. \param resolution Resolution in dots per Inch (dpi) */ -void QwtPlotRenderer::renderDocument( QwtPlot* plot, - const QString& fileName, const QSizeF& sizeMM, int resolution ) +void QwtPlotRenderer::renderDocument(QwtPlot *plot, const QString &fileName, + const QSizeF &sizeMM, int resolution) { - renderDocument( plot, fileName, - QFileInfo( fileName ).suffix(), sizeMM, resolution ); + renderDocument(plot, fileName, QFileInfo(fileName).suffix(), sizeMM, + resolution); } /*! @@ -290,100 +289,99 @@ void QwtPlotRenderer::renderDocument( QwtPlot* plot, \sa renderTo(), render(), QwtPainter::setRoundingAlignment() */ -void QwtPlotRenderer::renderDocument( QwtPlot* plot, - const QString& fileName, const QString& format, - const QSizeF& sizeMM, int resolution ) +void QwtPlotRenderer::renderDocument(QwtPlot *plot, const QString &fileName, + const QString &format, + const QSizeF &sizeMM, int resolution) { - if ( plot == NULL || sizeMM.isEmpty() || resolution <= 0 ) - return; + if (plot == NULL || sizeMM.isEmpty() || resolution <= 0) + return; - QString title = plot->title().text(); - if ( title.isEmpty() ) - title = "Plot Document"; + QString title = plot->title().text(); + if (title.isEmpty()) + title = "Plot Document"; - const double mmToInch = 1.0 / 25.4; - const QSizeF size = sizeMM * mmToInch * resolution; + const double mmToInch = 1.0 / 25.4; + const QSizeF size = sizeMM * mmToInch * resolution; - const QRectF documentRect( 0.0, 0.0, size.width(), size.height() ); + const QRectF documentRect(0.0, 0.0, size.width(), size.height()); - const QString fmt = format.toLower(); - if ( fmt == QLatin1String( "pdf" ) ) - { + const QString fmt = format.toLower(); + if (fmt == QLatin1String("pdf")) + { #if QWT_FORMAT_PDF -#if QWT_PDF_WRITER - QPdfWriter pdfWriter( fileName ); - pdfWriter.setPageSize( QPageSize( sizeMM, QPageSize::Millimeter ) ); - pdfWriter.setTitle( title ); - pdfWriter.setPageMargins( QMarginsF() ); - pdfWriter.setResolution( resolution ); +# if QWT_PDF_WRITER + QPdfWriter pdfWriter(fileName); + pdfWriter.setPageSize(QPageSize(sizeMM, QPageSize::Millimeter)); + pdfWriter.setTitle(title); + pdfWriter.setPageMargins(QMarginsF()); + pdfWriter.setResolution(resolution); - QPainter painter( &pdfWriter ); - render( plot, &painter, documentRect ); -#else - QPrinter printer; - printer.setOutputFormat( QPrinter::PdfFormat ); - printer.setColorMode( QPrinter::Color ); - printer.setFullPage( true ); - printer.setPaperSize( sizeMM, QPrinter::Millimeter ); - printer.setDocName( title ); - printer.setOutputFileName( fileName ); - printer.setResolution( resolution ); + QPainter painter(&pdfWriter); + render(plot, &painter, documentRect); +# else + QPrinter printer; + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setColorMode(QPrinter::Color); + printer.setFullPage(true); + printer.setPaperSize(sizeMM, QPrinter::Millimeter); + printer.setDocName(title); + printer.setOutputFileName(fileName); + printer.setResolution(resolution); - QPainter painter( &printer ); - render( plot, &painter, documentRect ); + QPainter painter(&printer); + render(plot, &painter, documentRect); +# endif #endif -#endif - } - else if ( fmt == QLatin1String( "ps" ) ) - { + } + else if (fmt == QLatin1String("ps")) + { #if QWT_FORMAT_POSTSCRIPT - QPrinter printer; - printer.setOutputFormat( QPrinter::PostScriptFormat ); - printer.setColorMode( QPrinter::Color ); - printer.setFullPage( true ); - printer.setPaperSize( sizeMM, QPrinter::Millimeter ); - printer.setDocName( title ); - printer.setOutputFileName( fileName ); - printer.setResolution( resolution ); + QPrinter printer; + printer.setOutputFormat(QPrinter::PostScriptFormat); + printer.setColorMode(QPrinter::Color); + printer.setFullPage(true); + printer.setPaperSize(sizeMM, QPrinter::Millimeter); + printer.setDocName(title); + printer.setOutputFileName(fileName); + printer.setResolution(resolution); - QPainter painter( &printer ); - render( plot, &painter, documentRect ); + QPainter painter(&printer); + render(plot, &painter, documentRect); #endif - } - else if ( fmt == QLatin1String( "svg" ) ) - { + } + else if (fmt == QLatin1String("svg")) + { #if QWT_FORMAT_SVG - QSvgGenerator generator; - generator.setTitle( title ); - generator.setFileName( fileName ); - generator.setResolution( resolution ); - generator.setViewBox( documentRect ); + QSvgGenerator generator; + generator.setTitle(title); + generator.setFileName(fileName); + generator.setResolution(resolution); + generator.setViewBox(documentRect); - QPainter painter( &generator ); - render( plot, &painter, documentRect ); + QPainter painter(&generator); + render(plot, &painter, documentRect); #endif - } - else + } + else + { + if (QImageWriter::supportedImageFormats().indexOf(format.toLatin1()) >= 0) { - if ( QImageWriter::supportedImageFormats().indexOf( - format.toLatin1() ) >= 0 ) - { - const QRect imageRect = documentRect.toRect(); - const int dotsPerMeter = qRound( resolution * mmToInch * 1000.0 ); + const QRect imageRect = documentRect.toRect(); + const int dotsPerMeter = qRound(resolution * mmToInch * 1000.0); - QImage image( imageRect.size(), QImage::Format_ARGB32 ); - image.setDotsPerMeterX( dotsPerMeter ); - image.setDotsPerMeterY( dotsPerMeter ); - image.fill( QColor( Qt::white ).rgb() ); + QImage image(imageRect.size(), QImage::Format_ARGB32); + image.setDotsPerMeterX(dotsPerMeter); + image.setDotsPerMeterY(dotsPerMeter); + image.fill(QColor(Qt::white).rgb()); - QPainter painter( &image ); - render( plot, &painter, imageRect ); - painter.end(); + QPainter painter(&image); + render(plot, &painter, imageRect); + painter.end(); - image.save( fileName, format.toLatin1() ); - } + image.save(fileName, format.toLatin1()); } + } } /*! @@ -399,14 +397,13 @@ void QwtPlotRenderer::renderDocument( QwtPlot* plot, \sa renderDocument(), render(), QwtPainter::setRoundingAlignment() */ -void QwtPlotRenderer::renderTo( - QwtPlot* plot, QPaintDevice& paintDevice ) const +void QwtPlotRenderer::renderTo(QwtPlot *plot, QPaintDevice &paintDevice) const { - int w = paintDevice.width(); - int h = paintDevice.height(); + int w = paintDevice.width(); + int h = paintDevice.height(); - QPainter p( &paintDevice ); - render( plot, &p, QRectF( 0, 0, w, h ) ); + QPainter p(&paintDevice); + render(plot, &p, QRectF(0, 0, w, h)); } /*! @@ -424,19 +421,18 @@ void QwtPlotRenderer::renderTo( #ifndef QT_NO_PRINTER -void QwtPlotRenderer::renderTo( - QwtPlot* plot, QPrinter& printer ) const +void QwtPlotRenderer::renderTo(QwtPlot *plot, QPrinter &printer) const { - int w = printer.width(); - int h = printer.height(); + int w = printer.width(); + int h = printer.height(); - QRectF rect( 0, 0, w, h ); - double aspect = rect.width() / rect.height(); - if ( ( aspect < 1.0 ) ) - rect.setHeight( aspect * rect.width() ); + QRectF rect(0, 0, w, h); + double aspect = rect.width() / rect.height(); + if ((aspect < 1.0)) + rect.setHeight(aspect * rect.width()); - QPainter p( &printer ); - render( plot, &p, rect ); + QPainter p(&printer); + render(plot, &p, rect); } #endif @@ -454,18 +450,17 @@ void QwtPlotRenderer::renderTo( \param plot Plot to be rendered \param generator SVG generator */ -void QwtPlotRenderer::renderTo( - QwtPlot* plot, QSvgGenerator& generator ) const +void QwtPlotRenderer::renderTo(QwtPlot *plot, QSvgGenerator &generator) const { - QRectF rect = generator.viewBoxF(); - if ( rect.isEmpty() ) - rect.setRect( 0, 0, generator.width(), generator.height() ); + QRectF rect = generator.viewBoxF(); + if (rect.isEmpty()) + rect.setRect(0, 0, generator.width(), generator.height()); - if ( rect.isEmpty() ) - rect.setRect( 0, 0, 800, 600 ); // something + if (rect.isEmpty()) + rect.setRect(0, 0, 800, 600); // something - QPainter p( &generator ); - render( plot, &p, rect ); + QPainter p(&generator); + render(plot, &p, rect); } #endif @@ -479,188 +474,186 @@ void QwtPlotRenderer::renderTo( \sa renderDocument(), renderTo(), QwtPainter::setRoundingAlignment() */ -void QwtPlotRenderer::render( QwtPlot* plot, - QPainter* painter, const QRectF& plotRect ) const +void QwtPlotRenderer::render(QwtPlot *plot, QPainter *painter, + const QRectF &plotRect) const { - if ( painter == 0 || !painter->isActive() || - !plotRect.isValid() || plot->size().isNull() ) + if (painter == 0 || !painter->isActive() || !plotRect.isValid() + || plot->size().isNull()) + { + return; + } + + if (!(m_data->discardFlags & DiscardBackground)) + QwtPainter::drawBackgound(painter, plotRect, plot); + + /* + The layout engine uses the same methods as they are used + by the Qt layout system. Therefore we need to calculate the + layout in screen coordinates and paint with a scaled painter. + */ + QTransform transform; + transform.scale( + double(painter->device()->logicalDpiX()) / plot->logicalDpiX(), + double(painter->device()->logicalDpiY()) / plot->logicalDpiY()); + + QRectF layoutRect = transform.inverted().mapRect(plotRect); + + if (!(m_data->discardFlags & DiscardBackground)) + { + // subtract the contents margins + + const QMargins m = plot->contentsMargins(); + layoutRect.adjust(m.left(), m.top(), -m.right(), -m.bottom()); + } + + QwtPlotLayout *layout = plot->plotLayout(); + + int baseLineDists[QwtAxis::AxisPositions]; + int canvasMargins[QwtAxis::AxisPositions]; + + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { + canvasMargins[axisPos] = layout->canvasMargin(axisPos); + + if (m_data->layoutFlags & FrameWithScales) { - return; - } + const QwtAxisId axisId(axisPos); - if ( !( m_data->discardFlags & DiscardBackground ) ) - QwtPainter::drawBackgound( painter, plotRect, plot ); + QwtScaleWidget *scaleWidget = plot->axisWidget(axisId); + if (scaleWidget) + { + baseLineDists[axisPos] = scaleWidget->margin(); + scaleWidget->setMargin(0); + } - /* - The layout engine uses the same methods as they are used - by the Qt layout system. Therefore we need to calculate the - layout in screen coordinates and paint with a scaled painter. - */ - QTransform transform; - transform.scale( - double( painter->device()->logicalDpiX() ) / plot->logicalDpiX(), - double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() ); + if (!plot->isAxisVisible(axisId)) + { + // When we have a scale the frame is painted on + // the position of the backbone - otherwise we + // need to introduce a margin around the canvas - QRectF layoutRect = transform.inverted().mapRect( plotRect ); + const qreal fw = qwtScalePenWidth(plot); - if ( !( m_data->discardFlags & DiscardBackground ) ) - { - // subtract the contents margins - - const QMargins m = plot->contentsMargins(); - layoutRect.adjust( m.left(), m.top(), -m.right(), -m.bottom() ); - } - - QwtPlotLayout* layout = plot->plotLayout(); - - int baseLineDists[QwtAxis::AxisPositions]; - int canvasMargins[QwtAxis::AxisPositions]; - - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - canvasMargins[axisPos] = layout->canvasMargin( axisPos ); - - if ( m_data->layoutFlags & FrameWithScales ) + switch (axisPos) { - const QwtAxisId axisId( axisPos ); + case QwtAxis::YLeft: + layoutRect.adjust(fw, 0, 0, 0); + break; - QwtScaleWidget* scaleWidget = plot->axisWidget( axisId ); - if ( scaleWidget ) - { - baseLineDists[axisPos] = scaleWidget->margin(); - scaleWidget->setMargin( 0 ); - } + case QwtAxis::YRight: + layoutRect.adjust(0, 0, -fw, 0); + break; - if ( !plot->isAxisVisible( axisId ) ) - { - // When we have a scale the frame is painted on - // the position of the backbone - otherwise we - // need to introduce a margin around the canvas + case QwtAxis::XTop: + layoutRect.adjust(0, fw, 0, 0); + break; - const qreal fw = qwtScalePenWidth( plot ); + case QwtAxis::XBottom: + layoutRect.adjust(0, 0, 0, -fw); + break; - switch( axisPos ) - { - case QwtAxis::YLeft: - layoutRect.adjust( fw, 0, 0, 0 ); - break; - - case QwtAxis::YRight: - layoutRect.adjust( 0, 0, -fw, 0 ); - break; - - case QwtAxis::XTop: - layoutRect.adjust( 0, fw, 0, 0 ); - break; - - case QwtAxis::XBottom: - layoutRect.adjust( 0, 0, 0, -fw ); - break; - - default: - ; - } - } + default:; } + } } + } - // Calculate the layout for the document. + // Calculate the layout for the document. - QwtPlotLayout::Options layoutOptions = QwtPlotLayout::IgnoreScrollbars; + QwtPlotLayout::Options layoutOptions = QwtPlotLayout::IgnoreScrollbars; - if ( ( m_data->layoutFlags & FrameWithScales ) || - ( m_data->discardFlags & DiscardCanvasFrame ) ) + if ((m_data->layoutFlags & FrameWithScales) + || (m_data->discardFlags & DiscardCanvasFrame)) + { + layoutOptions |= QwtPlotLayout::IgnoreFrames; + } + + if (m_data->discardFlags & DiscardLegend) + layoutOptions |= QwtPlotLayout::IgnoreLegend; + + if (m_data->discardFlags & DiscardTitle) + layoutOptions |= QwtPlotLayout::IgnoreTitle; + + if (m_data->discardFlags & DiscardFooter) + layoutOptions |= QwtPlotLayout::IgnoreFooter; + + layout->activate(plot, layoutRect, layoutOptions); + + // canvas + + QwtScaleMap maps[QwtAxis::AxisPositions]; + buildCanvasMaps(plot, layout->canvasRect(), maps); + if (updateCanvasMargins(plot, layout->canvasRect(), maps)) + { + // recalculate maps and layout, when the margins + // have been changed + + layout->activate(plot, layoutRect, layoutOptions); + buildCanvasMaps(plot, layout->canvasRect(), maps); + } + + // now start painting + + painter->save(); + painter->setWorldTransform(transform, true); + + renderCanvas(plot, painter, layout->canvasRect(), maps); + + if (!(m_data->discardFlags & DiscardTitle) + && (!plot->titleLabel()->text().isEmpty())) + { + renderTitle(plot, painter, layout->titleRect()); + } + + if (!(m_data->discardFlags & DiscardFooter) + && (!plot->footerLabel()->text().isEmpty())) + { + renderFooter(plot, painter, layout->footerRect()); + } + + if (!(m_data->discardFlags & DiscardLegend) && plot->legend() + && !plot->legend()->isEmpty()) + { + renderLegend(plot, painter, layout->legendRect()); + } + + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { - layoutOptions |= QwtPlotLayout::IgnoreFrames; + const QwtAxisId axisId(axisPos); + + QwtScaleWidget *scaleWidget = plot->axisWidget(axisId); + if (scaleWidget) + { + int baseDist = scaleWidget->margin(); + + int startDist, endDist; + scaleWidget->getBorderDistHint(startDist, endDist); + + renderScale(plot, painter, axisId, startDist, endDist, baseDist, + layout->scaleRect(axisId)); + } } + } - if ( m_data->discardFlags & DiscardLegend ) - layoutOptions |= QwtPlotLayout::IgnoreLegend; + painter->restore(); - if ( m_data->discardFlags & DiscardTitle ) - layoutOptions |= QwtPlotLayout::IgnoreTitle; - - if ( m_data->discardFlags & DiscardFooter ) - layoutOptions |= QwtPlotLayout::IgnoreFooter; - - layout->activate( plot, layoutRect, layoutOptions ); - - // canvas - - QwtScaleMap maps[QwtAxis::AxisPositions]; - buildCanvasMaps( plot, layout->canvasRect(), maps ); - if ( updateCanvasMargins( plot, layout->canvasRect(), maps ) ) + // restore all setting to their original attributes. + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { + if (m_data->layoutFlags & FrameWithScales) { - // recalculate maps and layout, when the margins - // have been changed + const QwtAxisId axisId(axisPos); - layout->activate( plot, layoutRect, layoutOptions ); - buildCanvasMaps( plot, layout->canvasRect(), maps ); + QwtScaleWidget *scaleWidget = plot->axisWidget(axisId); + if (scaleWidget) + scaleWidget->setMargin(baseLineDists[axisPos]); } - // now start painting - - painter->save(); - painter->setWorldTransform( transform, true ); - - renderCanvas( plot, painter, layout->canvasRect(), maps ); - - if ( !( m_data->discardFlags & DiscardTitle ) - && ( !plot->titleLabel()->text().isEmpty() ) ) - { - renderTitle( plot, painter, layout->titleRect() ); - } - - if ( !( m_data->discardFlags & DiscardFooter ) - && ( !plot->footerLabel()->text().isEmpty() ) ) - { - renderFooter( plot, painter, layout->footerRect() ); - } - - if ( !( m_data->discardFlags & DiscardLegend ) - && plot->legend() && !plot->legend()->isEmpty() ) - { - renderLegend( plot, painter, layout->legendRect() ); - } - - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - { - const QwtAxisId axisId( axisPos ); - - QwtScaleWidget* scaleWidget = plot->axisWidget( axisId ); - if ( scaleWidget ) - { - int baseDist = scaleWidget->margin(); - - int startDist, endDist; - scaleWidget->getBorderDistHint( startDist, endDist ); - - renderScale( plot, painter, axisId, startDist, endDist, - baseDist, layout->scaleRect( axisId ) ); - } - } - } - - painter->restore(); - - // restore all setting to their original attributes. - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - if ( m_data->layoutFlags & FrameWithScales ) - { - const QwtAxisId axisId( axisPos ); - - QwtScaleWidget* scaleWidget = plot->axisWidget( axisId ); - if ( scaleWidget ) - scaleWidget->setMargin( baseLineDists[axisPos] ); - } - - layout->setCanvasMargin( canvasMargins[axisPos] ); - } - - layout->invalidate(); + layout->setCanvasMargin(canvasMargins[axisPos]); + } + layout->invalidate(); } /*! @@ -670,16 +663,16 @@ void QwtPlotRenderer::render( QwtPlot* plot, \param painter Painter \param titleRect Bounding rectangle for the title */ -void QwtPlotRenderer::renderTitle( const QwtPlot* plot, - QPainter* painter, const QRectF& titleRect ) const +void QwtPlotRenderer::renderTitle(const QwtPlot *plot, QPainter *painter, + const QRectF &titleRect) const { - painter->setFont( qwtResolvedFont( plot->titleLabel() ) ); + painter->setFont(qwtResolvedFont(plot->titleLabel())); - const QColor color = plot->titleLabel()->palette().color( - QPalette::Active, QPalette::Text ); + const QColor color + = plot->titleLabel()->palette().color(QPalette::Active, QPalette::Text); - painter->setPen( color ); - plot->titleLabel()->text().draw( painter, titleRect ); + painter->setPen(color); + plot->titleLabel()->text().draw(painter, titleRect); } /*! @@ -689,16 +682,16 @@ void QwtPlotRenderer::renderTitle( const QwtPlot* plot, \param painter Painter \param footerRect Bounding rectangle for the footer */ -void QwtPlotRenderer::renderFooter( const QwtPlot* plot, - QPainter* painter, const QRectF& footerRect ) const +void QwtPlotRenderer::renderFooter(const QwtPlot *plot, QPainter *painter, + const QRectF &footerRect) const { - painter->setFont( qwtResolvedFont( plot->footerLabel() ) ); + painter->setFont(qwtResolvedFont(plot->footerLabel())); - const QColor color = plot->footerLabel()->palette().color( - QPalette::Active, QPalette::Text ); + const QColor color + = plot->footerLabel()->palette().color(QPalette::Active, QPalette::Text); - painter->setPen( color ); - plot->footerLabel()->text().draw( painter, footerRect ); + painter->setPen(color); + plot->footerLabel()->text().draw(painter, footerRect); } /*! @@ -708,14 +701,14 @@ void QwtPlotRenderer::renderFooter( const QwtPlot* plot, \param painter Painter \param legendRect Bounding rectangle for the legend */ -void QwtPlotRenderer::renderLegend( const QwtPlot* plot, - QPainter* painter, const QRectF& legendRect ) const +void QwtPlotRenderer::renderLegend(const QwtPlot *plot, QPainter *painter, + const QRectF &legendRect) const { - if ( plot->legend() ) - { - bool fillBackground = !( m_data->discardFlags & DiscardBackground ); - plot->legend()->renderLegend( painter, legendRect, fillBackground ); - } + if (plot->legend()) + { + bool fillBackground = !(m_data->discardFlags & DiscardBackground); + plot->legend()->renderLegend(painter, legendRect, fillBackground); + } } /*! @@ -730,94 +723,89 @@ void QwtPlotRenderer::renderLegend( const QwtPlot* plot, \param baseDist Base distance \param scaleRect Bounding rectangle for the scale */ -void QwtPlotRenderer::renderScale( const QwtPlot* plot, QPainter* painter, - QwtAxisId axisId, int startDist, int endDist, int baseDist, - const QRectF& scaleRect ) const +void QwtPlotRenderer::renderScale(const QwtPlot *plot, QPainter *painter, + QwtAxisId axisId, int startDist, int endDist, + int baseDist, const QRectF &scaleRect) const { - if ( !plot->isAxisVisible( axisId ) ) - return; + if (!plot->isAxisVisible(axisId)) + return; - const QwtScaleWidget* scaleWidget = plot->axisWidget( axisId ); - if ( scaleWidget->isColorBarEnabled() - && scaleWidget->colorBarWidth() > 0 ) - { - scaleWidget->drawColorBar( painter, scaleWidget->colorBarRect( scaleRect ) ); - baseDist += scaleWidget->colorBarWidth() + scaleWidget->spacing(); + const QwtScaleWidget *scaleWidget = plot->axisWidget(axisId); + if (scaleWidget->isColorBarEnabled() && scaleWidget->colorBarWidth() > 0) + { + scaleWidget->drawColorBar(painter, scaleWidget->colorBarRect(scaleRect)); + baseDist += scaleWidget->colorBarWidth() + scaleWidget->spacing(); + } + + painter->save(); + + QwtScaleDraw::Alignment align; + double x, y, w; + + qreal off = 0.0; + if (m_data->layoutFlags & FrameWithScales) + off = qwtScalePenWidth(plot); + + switch (axisId) + { + case QwtAxis::YLeft: { + x = scaleRect.right() - 1.0 - baseDist - off; + y = scaleRect.y() + startDist; + w = scaleRect.height() - startDist - endDist; + align = QwtScaleDraw::LeftScale; + break; } - - painter->save(); - - QwtScaleDraw::Alignment align; - double x, y, w; - - qreal off = 0.0; - if ( m_data->layoutFlags & FrameWithScales ) - off = qwtScalePenWidth( plot ); - - switch ( axisId ) - { - case QwtAxis::YLeft: - { - x = scaleRect.right() - 1.0 - baseDist - off; - y = scaleRect.y() + startDist; - w = scaleRect.height() - startDist - endDist; - align = QwtScaleDraw::LeftScale; - break; - } - case QwtAxis::YRight: - { - x = scaleRect.left() + baseDist + off; - y = scaleRect.y() + startDist; - w = scaleRect.height() - startDist - endDist; - align = QwtScaleDraw::RightScale; - break; - } - case QwtAxis::XTop: - { - x = scaleRect.left() + startDist; - y = scaleRect.bottom() - 1.0 - baseDist - off; - w = scaleRect.width() - startDist - endDist; - align = QwtScaleDraw::TopScale; - break; - } - case QwtAxis::XBottom: - { - x = scaleRect.left() + startDist; - y = scaleRect.top() + baseDist + off; - w = scaleRect.width() - startDist - endDist; - align = QwtScaleDraw::BottomScale; - break; - } - default: - return; + case QwtAxis::YRight: { + x = scaleRect.left() + baseDist + off; + y = scaleRect.y() + startDist; + w = scaleRect.height() - startDist - endDist; + align = QwtScaleDraw::RightScale; + break; } + case QwtAxis::XTop: { + x = scaleRect.left() + startDist; + y = scaleRect.bottom() - 1.0 - baseDist - off; + w = scaleRect.width() - startDist - endDist; + align = QwtScaleDraw::TopScale; + break; + } + case QwtAxis::XBottom: { + x = scaleRect.left() + startDist; + y = scaleRect.top() + baseDist + off; + w = scaleRect.width() - startDist - endDist; + align = QwtScaleDraw::BottomScale; + break; + } + default: + return; + } - scaleWidget->drawTitle( painter, align, scaleRect ); + scaleWidget->drawTitle(painter, align, scaleRect); - painter->setFont( qwtResolvedFont( scaleWidget ) ); + painter->setFont(qwtResolvedFont(scaleWidget)); - QwtScaleDraw* sd = const_cast< QwtScaleDraw* >( scaleWidget->scaleDraw() ); - const QPointF sdPos = sd->pos(); - const double sdLength = sd->length(); + QwtScaleDraw *sd = const_cast(scaleWidget->scaleDraw()); + const QPointF sdPos = sd->pos(); + const double sdLength = sd->length(); - const bool hasBackbone = sd->hasComponent( QwtAbstractScaleDraw::Backbone ); + const bool hasBackbone = sd->hasComponent(QwtAbstractScaleDraw::Backbone); - if ( m_data->layoutFlags & FrameWithScales ) - sd->enableComponent( QwtAbstractScaleDraw::Backbone, false ); + if (m_data->layoutFlags & FrameWithScales) + sd->enableComponent(QwtAbstractScaleDraw::Backbone, false); - sd->move( x, y ); - sd->setLength( w ); + sd->move(x, y); + sd->setLength(w); - QPalette palette = scaleWidget->palette(); - palette.setCurrentColorGroup( QPalette::Active ); - sd->draw( painter, palette ); + QPalette palette = scaleWidget->palette(); + palette.setCurrentColorGroup(QPalette::Active); + sd->draw(painter, palette); - // reset previous values - sd->move( sdPos ); - sd->setLength( sdLength ); - sd->enableComponent( QwtAbstractScaleDraw::Backbone, hasBackbone ); + // reset previous values + sd->move(sdPos); + sd->setLength(sdLength); + sd->enableComponent(QwtAbstractScaleDraw::Backbone, hasBackbone); - painter->restore(); + painter->restore(); } /*! @@ -828,135 +816,133 @@ void QwtPlotRenderer::renderScale( const QwtPlot* plot, QPainter* painter, \param maps Maps mapping between plot and paint device coordinates \param canvasRect Canvas rectangle */ -void QwtPlotRenderer::renderCanvas( const QwtPlot* plot, - QPainter* painter, const QRectF& canvasRect, - const QwtScaleMap* maps ) const +void QwtPlotRenderer::renderCanvas(const QwtPlot *plot, QPainter *painter, + const QRectF &canvasRect, + const QwtScaleMap *maps) const { - const QWidget* canvas = plot->canvas(); + const QWidget *canvas = plot->canvas(); - QRectF r = canvasRect.adjusted( 0.0, 0.0, -1.0, -1.0 ); + QRectF r = canvasRect.adjusted(0.0, 0.0, -1.0, -1.0); - if ( m_data->layoutFlags & FrameWithScales ) + if (m_data->layoutFlags & FrameWithScales) + { + painter->save(); + + QPen pen; + pen.setColor(qwtScalePenColor(plot)); + pen.setWidth(qwtScalePenWidth(plot)); + pen.setJoinStyle(Qt::MiterJoin); + + painter->setPen(pen); + + const qreal pw2 = 0.5 * pen.widthF(); + r.adjust(-pw2, -pw2, pw2, pw2); + + if (!(m_data->discardFlags & DiscardCanvasBackground)) { - painter->save(); - - QPen pen; - pen.setColor( qwtScalePenColor( plot ) ); - pen.setWidth( qwtScalePenWidth( plot ) ); - pen.setJoinStyle( Qt::MiterJoin ); - - painter->setPen( pen ); - - const qreal pw2 = 0.5 * pen.widthF(); - r.adjust( -pw2, -pw2, pw2, pw2 ); - - if ( !( m_data->discardFlags & DiscardCanvasBackground ) ) - { - const QBrush bgBrush = - canvas->palette().brush( plot->backgroundRole() ); - painter->setBrush( bgBrush ); - } - - QwtPainter::drawRect( painter, r ); - - painter->restore(); - painter->save(); - - painter->setClipRect( canvasRect ); - plot->drawItems( painter, canvasRect, maps ); - - painter->restore(); + const QBrush bgBrush = canvas->palette().brush(plot->backgroundRole()); + painter->setBrush(bgBrush); } - else if ( canvas->testAttribute( Qt::WA_StyledBackground ) ) + + QwtPainter::drawRect(painter, r); + + painter->restore(); + painter->save(); + + painter->setClipRect(canvasRect); + plot->drawItems(painter, canvasRect, maps); + + painter->restore(); + } + else if (canvas->testAttribute(Qt::WA_StyledBackground)) + { + QPainterPath clipPath; + + painter->save(); + + if (!(m_data->discardFlags & DiscardCanvasBackground)) { - QPainterPath clipPath; + QwtPainter::drawBackgound(painter, r, canvas); + clipPath = qwtCanvasClip(canvas, canvasRect); + } - painter->save(); + painter->restore(); + painter->save(); - if ( !( m_data->discardFlags & DiscardCanvasBackground ) ) - { - QwtPainter::drawBackgound( painter, r, canvas ); - clipPath = qwtCanvasClip( canvas, canvasRect ); - } + if (clipPath.isEmpty()) + painter->setClipRect(canvasRect); + else + painter->setClipPath(clipPath); - painter->restore(); - painter->save(); + plot->drawItems(painter, canvasRect, maps); - if ( clipPath.isEmpty() ) - painter->setClipRect( canvasRect ); - else - painter->setClipPath( clipPath ); + painter->restore(); + } + else + { + QPainterPath clipPath; - plot->drawItems( painter, canvasRect, maps ); + double frameWidth = 0.0; - painter->restore(); + if (!(m_data->discardFlags & DiscardCanvasFrame)) + { + const QVariant fw = canvas->property("frameWidth"); + if (fw.canConvert()) + frameWidth = fw.value(); + + clipPath = qwtCanvasClip(canvas, canvasRect); + } + + QRectF innerRect + = canvasRect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); + + painter->save(); + + if (clipPath.isEmpty()) + { + painter->setClipRect(innerRect); } else { - QPainterPath clipPath; - - double frameWidth = 0.0; - - if ( !( m_data->discardFlags & DiscardCanvasFrame ) ) - { - const QVariant fw = canvas->property( "frameWidth" ); - if ( fw.canConvert< double >() ) - frameWidth = fw.value< double >(); - - clipPath = qwtCanvasClip( canvas, canvasRect ); - } - - QRectF innerRect = canvasRect.adjusted( - frameWidth, frameWidth, -frameWidth, -frameWidth ); - - painter->save(); - - if ( clipPath.isEmpty() ) - { - painter->setClipRect( innerRect ); - } - else - { - painter->setClipPath( clipPath ); - } - - if ( !( m_data->discardFlags & DiscardCanvasBackground ) ) - { - QwtPainter::drawBackgound( painter, innerRect, canvas ); - } - - plot->drawItems( painter, innerRect, maps ); - - painter->restore(); - - if ( frameWidth > 0 ) - { - painter->save(); - - const int frameStyle = - canvas->property( "frameShadow" ).toInt() | - canvas->property( "frameShape" ).toInt(); - - const QVariant borderRadius = canvas->property( "borderRadius" ); - if ( borderRadius.canConvert< double >() - && borderRadius.value< double >() > 0.0 ) - { - const double radius = borderRadius.value< double >(); - - QwtPainter::drawRoundedFrame( painter, canvasRect, - radius, radius, canvas->palette(), frameWidth, frameStyle ); - } - else - { - const int midLineWidth = canvas->property( "midLineWidth" ).toInt(); - - QwtPainter::drawFrame( painter, canvasRect, - canvas->palette(), canvas->foregroundRole(), - frameWidth, midLineWidth, frameStyle ); - } - painter->restore(); - } + painter->setClipPath(clipPath); } + + if (!(m_data->discardFlags & DiscardCanvasBackground)) + { + QwtPainter::drawBackgound(painter, innerRect, canvas); + } + + plot->drawItems(painter, innerRect, maps); + + painter->restore(); + + if (frameWidth > 0) + { + painter->save(); + + const int frameStyle = canvas->property("frameShadow").toInt() + | canvas->property("frameShape").toInt(); + + const QVariant borderRadius = canvas->property("borderRadius"); + if (borderRadius.canConvert() + && borderRadius.value() > 0.0) + { + const double radius = borderRadius.value(); + + QwtPainter::drawRoundedFrame(painter, canvasRect, radius, radius, + canvas->palette(), frameWidth, frameStyle); + } + else + { + const int midLineWidth = canvas->property("midLineWidth").toInt(); + + QwtPainter::drawFrame(painter, canvasRect, canvas->palette(), + canvas->foregroundRole(), frameWidth, + midLineWidth, frameStyle); + } + painter->restore(); + } + } } /*! @@ -966,84 +952,85 @@ void QwtPlotRenderer::renderCanvas( const QwtPlot* plot, \param canvasRect Target rectangle \param maps Scale maps to be calculated */ -void QwtPlotRenderer::buildCanvasMaps( const QwtPlot* plot, - const QRectF& canvasRect, QwtScaleMap maps[] ) const +void QwtPlotRenderer::buildCanvasMaps(const QwtPlot *plot, + const QRectF &canvasRect, + QwtScaleMap maps[]) const { - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { + const QwtAxisId axisId(axisPos); + + QwtScaleMap &scaleMap = maps[axisId]; + + scaleMap.setTransformation( + plot->axisScaleEngine(axisId)->transformation()); + + const QwtScaleDiv &scaleDiv = plot->axisScaleDiv(axisId); + scaleMap.setScaleInterval(scaleDiv.lowerBound(), scaleDiv.upperBound()); + + double from, to; + if (plot->isAxisVisible(axisId)) + { + const int sDist = plot->axisWidget(axisId)->startBorderDist(); + const int eDist = plot->axisWidget(axisId)->endBorderDist(); + const QRectF scaleRect = plot->plotLayout()->scaleRect(axisId); + + if (QwtAxis::isXAxis(axisPos)) { - const QwtAxisId axisId( axisPos ); - - QwtScaleMap& scaleMap = maps[axisId]; - - scaleMap.setTransformation( - plot->axisScaleEngine( axisId )->transformation() ); - - const QwtScaleDiv& scaleDiv = plot->axisScaleDiv( axisId ); - scaleMap.setScaleInterval( - scaleDiv.lowerBound(), scaleDiv.upperBound() ); - - double from, to; - if ( plot->isAxisVisible( axisId ) ) - { - const int sDist = plot->axisWidget( axisId )->startBorderDist(); - const int eDist = plot->axisWidget( axisId )->endBorderDist(); - const QRectF scaleRect = plot->plotLayout()->scaleRect( axisId ); - - if ( QwtAxis::isXAxis( axisPos ) ) - { - from = scaleRect.left() + sDist; - to = scaleRect.right() - eDist; - } - else - { - from = scaleRect.bottom() - eDist; - to = scaleRect.top() + sDist; - } - } - else - { - int margin = 0; - if ( !plot->plotLayout()->alignCanvasToScale( axisPos ) ) - margin = plot->plotLayout()->canvasMargin( axisPos ); - - if ( QwtAxis::isYAxis( axisPos ) ) - { - from = canvasRect.bottom() - margin; - to = canvasRect.top() + margin; - } - else - { - from = canvasRect.left() + margin; - to = canvasRect.right() - margin; - } - } - scaleMap.setPaintInterval( from, to ); + from = scaleRect.left() + sDist; + to = scaleRect.right() - eDist; } + else + { + from = scaleRect.bottom() - eDist; + to = scaleRect.top() + sDist; + } + } + else + { + int margin = 0; + if (!plot->plotLayout()->alignCanvasToScale(axisPos)) + margin = plot->plotLayout()->canvasMargin(axisPos); + + if (QwtAxis::isYAxis(axisPos)) + { + from = canvasRect.bottom() - margin; + to = canvasRect.top() + margin; + } + else + { + from = canvasRect.left() + margin; + to = canvasRect.right() - margin; + } + } + scaleMap.setPaintInterval(from, to); } + } } -bool QwtPlotRenderer::updateCanvasMargins( QwtPlot* plot, - const QRectF& canvasRect, const QwtScaleMap maps[] ) const +bool QwtPlotRenderer::updateCanvasMargins(QwtPlot *plot, + const QRectF &canvasRect, + const QwtScaleMap maps[]) const { - using namespace QwtAxis; + using namespace QwtAxis; - double margins[AxisPositions]; - plot->getCanvasMarginsHint( maps, canvasRect, - margins[YLeft], margins[XTop], margins[YRight], margins[XBottom] ); + double margins[AxisPositions]; + plot->getCanvasMarginsHint(maps, canvasRect, margins[YLeft], margins[XTop], + margins[YRight], margins[XBottom]); - bool marginsChanged = false; - for ( int axisId = 0; axisId < AxisPositions; axisId++ ) + bool marginsChanged = false; + for (int axisId = 0; axisId < AxisPositions; axisId++) + { + if (margins[axisId] >= 0.0) { - if ( margins[axisId] >= 0.0 ) - { - const int m = qwtCeil( margins[axisId] ); - plot->plotLayout()->setCanvasMargin( m, axisId); - marginsChanged = true; - } + const int m = qwtCeil(margins[axisId]); + plot->plotLayout()->setCanvasMargin(m, axisId); + marginsChanged = true; } + } - return marginsChanged; + return marginsChanged; } /*! @@ -1057,59 +1044,58 @@ bool QwtPlotRenderer::updateCanvasMargins( QwtPlot* plot, \return True, when exporting was successful \sa renderDocument() */ -bool QwtPlotRenderer::exportTo( QwtPlot* plot, const QString& documentName, - const QSizeF& sizeMM, int resolution ) +bool QwtPlotRenderer::exportTo(QwtPlot *plot, const QString &documentName, + const QSizeF &sizeMM, int resolution) { - if ( plot == NULL ) - return false; + if (plot == NULL) + return false; - QString fileName = documentName; + QString fileName = documentName; - // What about translation + // What about translation #ifndef QT_NO_FILEDIALOG - const QList< QByteArray > imageFormats = - QImageWriter::supportedImageFormats(); + const QList imageFormats = QImageWriter::supportedImageFormats(); - QStringList filter; -#if QWT_FORMAT_PDF - filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)"; -#endif -#if QWT_FORMAT_SVG - filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)"; -#endif -#if QWT_FORMAT_POSTSCRIPT - filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)"; -#endif + QStringList filter; +# if QWT_FORMAT_PDF + filter += QString("PDF ") + tr("Documents") + " (*.pdf)"; +# endif +# if QWT_FORMAT_SVG + filter += QString("SVG ") + tr("Documents") + " (*.svg)"; +# endif +# if QWT_FORMAT_POSTSCRIPT + filter += QString("Postscript ") + tr("Documents") + " (*.ps)"; +# endif - if ( imageFormats.size() > 0 ) + if (imageFormats.size() > 0) + { + QString imageFilter(tr("Images")); + imageFilter += " ("; + for (int i = 0; i < imageFormats.size(); i++) { - QString imageFilter( tr( "Images" ) ); - imageFilter += " ("; - for ( int i = 0; i < imageFormats.size(); i++ ) - { - if ( i > 0 ) - imageFilter += " "; - imageFilter += "*."; - imageFilter += imageFormats[i]; - } - imageFilter += ")"; - - filter += imageFilter; + if (i > 0) + imageFilter += " "; + imageFilter += "*."; + imageFilter += imageFormats[i]; } + imageFilter += ")"; - fileName = QFileDialog::getSaveFileName( - NULL, tr( "Export File Name" ), fileName, - filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); + filter += imageFilter; + } + + fileName = QFileDialog::getSaveFileName(NULL, tr("Export File Name"), + fileName, filter.join(";;"), NULL, + QFileDialog::DontConfirmOverwrite); #endif - if ( fileName.isEmpty() ) - return false; + if (fileName.isEmpty()) + return false; - renderDocument( plot, fileName, sizeMM, resolution ); + renderDocument(plot, fileName, sizeMM, resolution); - return true; + return true; } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_renderer.cpp" +# include "moc_qwt_plot_renderer.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_renderer.h b/libs/qwt/src/qwt_plot_renderer.h index e009b4db..e60f4393 100644 --- a/libs/qwt/src/qwt_plot_renderer.h +++ b/libs/qwt/src/qwt_plot_renderer.h @@ -27,9 +27,9 @@ class QPrinter; #endif #ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB +# ifdef QT_SVG_LIB class QSvgGenerator; -#endif +# endif #endif /*! @@ -38,131 +38,129 @@ class QSvgGenerator; */ class QWT_EXPORT QwtPlotRenderer : public QObject { - Q_OBJECT + Q_OBJECT - public: - //! Discard flags - enum DiscardFlag - { - //! Render all components of the plot - DiscardNone = 0x00, +public: + //! Discard flags + enum DiscardFlag + { + //! Render all components of the plot + DiscardNone = 0x00, - //! Don't render the background of the plot - DiscardBackground = 0x01, + //! Don't render the background of the plot + DiscardBackground = 0x01, - //! Don't render the title of the plot - DiscardTitle = 0x02, + //! Don't render the title of the plot + DiscardTitle = 0x02, - //! Don't render the legend of the plot - DiscardLegend = 0x04, + //! Don't render the legend of the plot + DiscardLegend = 0x04, - //! Don't render the background of the canvas - DiscardCanvasBackground = 0x08, + //! Don't render the background of the canvas + DiscardCanvasBackground = 0x08, - //! Don't render the footer of the plot - DiscardFooter = 0x10, - - /*! - Don't render the frame of the canvas - - \note This flag has no effect when using - style sheets, where the frame is part - of the background - */ - DiscardCanvasFrame = 0x20 - - }; - - Q_DECLARE_FLAGS( DiscardFlags, DiscardFlag ) + //! Don't render the footer of the plot + DiscardFooter = 0x10, /*! - \brief Layout flags - \sa setLayoutFlag(), testLayoutFlag() + Don't render the frame of the canvas + + \note This flag has no effect when using + style sheets, where the frame is part + of the background */ - enum LayoutFlag - { - //! Use the default layout as on screen - DefaultLayout = 0x00, + DiscardCanvasFrame = 0x20 - /*! - Instead of the scales a box is painted around the plot canvas, - where the scale ticks are aligned to. - */ - FrameWithScales = 0x01 - }; + }; - Q_DECLARE_FLAGS( LayoutFlags, LayoutFlag ) + Q_DECLARE_FLAGS(DiscardFlags, DiscardFlag) - explicit QwtPlotRenderer( QObject* = NULL ); - virtual ~QwtPlotRenderer(); + /*! + \brief Layout flags + \sa setLayoutFlag(), testLayoutFlag() + */ + enum LayoutFlag + { + //! Use the default layout as on screen + DefaultLayout = 0x00, - void setDiscardFlag( DiscardFlag flag, bool on = true ); - bool testDiscardFlag( DiscardFlag flag ) const; + /*! + Instead of the scales a box is painted around the plot canvas, + where the scale ticks are aligned to. + */ + FrameWithScales = 0x01 + }; - void setDiscardFlags( DiscardFlags flags ); - DiscardFlags discardFlags() const; + Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) - void setLayoutFlag( LayoutFlag flag, bool on = true ); - bool testLayoutFlag( LayoutFlag flag ) const; + explicit QwtPlotRenderer(QObject * = NULL); + virtual ~QwtPlotRenderer(); - void setLayoutFlags( LayoutFlags flags ); - LayoutFlags layoutFlags() const; + void setDiscardFlag(DiscardFlag flag, bool on = true); + bool testDiscardFlag(DiscardFlag flag) const; - void renderDocument( QwtPlot*, const QString& fileName, - const QSizeF& sizeMM, int resolution = 85 ); + void setDiscardFlags(DiscardFlags flags); + DiscardFlags discardFlags() const; - void renderDocument( QwtPlot*, - const QString& fileName, const QString& format, - const QSizeF& sizeMM, int resolution = 85 ); + void setLayoutFlag(LayoutFlag flag, bool on = true); + bool testLayoutFlag(LayoutFlag flag) const; + + void setLayoutFlags(LayoutFlags flags); + LayoutFlags layoutFlags() const; + + void renderDocument(QwtPlot *, const QString &fileName, const QSizeF &sizeMM, + int resolution = 85); + + void renderDocument(QwtPlot *, const QString &fileName, const QString &format, + const QSizeF &sizeMM, int resolution = 85); #ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB - void renderTo( QwtPlot*, QSvgGenerator& ) const; -#endif +# ifdef QT_SVG_LIB + void renderTo(QwtPlot *, QSvgGenerator &) const; +# endif #endif #ifndef QT_NO_PRINTER - void renderTo( QwtPlot*, QPrinter& ) const; + void renderTo(QwtPlot *, QPrinter &) const; #endif - void renderTo( QwtPlot*, QPaintDevice& ) const; + void renderTo(QwtPlot *, QPaintDevice &) const; - virtual void render( QwtPlot*, - QPainter*, const QRectF& plotRect ) const; + virtual void render(QwtPlot *, QPainter *, const QRectF &plotRect) const; - virtual void renderTitle( const QwtPlot*, - QPainter*, const QRectF& titleRect ) const; + virtual void renderTitle(const QwtPlot *, QPainter *, + const QRectF &titleRect) const; - virtual void renderFooter( const QwtPlot*, - QPainter*, const QRectF& footerRect ) const; + virtual void renderFooter(const QwtPlot *, QPainter *, + const QRectF &footerRect) const; - virtual void renderScale( const QwtPlot*, QPainter*, - QwtAxisId, int startDist, int endDist, - int baseDist, const QRectF& scaleRect ) const; + virtual void renderScale(const QwtPlot *, QPainter *, QwtAxisId, + int startDist, int endDist, int baseDist, + const QRectF &scaleRect) const; - virtual void renderCanvas( const QwtPlot*, - QPainter*, const QRectF& canvasRect, - const QwtScaleMap* maps ) const; + virtual void renderCanvas(const QwtPlot *, QPainter *, + const QRectF &canvasRect, + const QwtScaleMap *maps) const; - virtual void renderLegend( - const QwtPlot*, QPainter*, const QRectF& legendRect ) const; + virtual void renderLegend(const QwtPlot *, QPainter *, + const QRectF &legendRect) const; - bool exportTo( QwtPlot*, const QString& documentName, - const QSizeF& sizeMM = QSizeF( 300, 200 ), int resolution = 85 ); + bool exportTo(QwtPlot *, const QString &documentName, + const QSizeF &sizeMM = QSizeF(300, 200), int resolution = 85); - private: - void buildCanvasMaps( const QwtPlot*, - const QRectF&, QwtScaleMap maps[] ) const; +private: + void buildCanvasMaps(const QwtPlot *, const QRectF &, + QwtScaleMap maps[]) const; - bool updateCanvasMargins( QwtPlot*, - const QRectF&, const QwtScaleMap maps[] ) const; + bool updateCanvasMargins(QwtPlot *, const QRectF &, + const QwtScaleMap maps[]) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotRenderer::DiscardFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotRenderer::LayoutFlags) #endif diff --git a/libs/qwt/src/qwt_plot_rescaler.cpp b/libs/qwt/src/qwt_plot_rescaler.cpp index 34e7971a..dedf1894 100644 --- a/libs/qwt/src/qwt_plot_rescaler.cpp +++ b/libs/qwt/src/qwt_plot_rescaler.cpp @@ -17,46 +17,46 @@ class QwtPlotRescaler::AxisData { - public: - AxisData() - : aspectRatio( 1.0 ) - , expandingDirection( QwtPlotRescaler::ExpandUp ) - { - } +public: + AxisData() + : aspectRatio(1.0) + , expandingDirection(QwtPlotRescaler::ExpandUp) + { + } - double aspectRatio; - QwtInterval intervalHint; - QwtPlotRescaler::ExpandingDirection expandingDirection; - mutable QwtScaleDiv scaleDiv; + double aspectRatio; + QwtInterval intervalHint; + QwtPlotRescaler::ExpandingDirection expandingDirection; + mutable QwtScaleDiv scaleDiv; }; class QwtPlotRescaler::PrivateData { - public: - PrivateData() - : referenceAxis( QwtAxis::XBottom ) - , rescalePolicy( QwtPlotRescaler::Expanding ) - , isEnabled( false ) - , inReplot( 0 ) - { - } +public: + PrivateData() + : referenceAxis(QwtAxis::XBottom) + , rescalePolicy(QwtPlotRescaler::Expanding) + , isEnabled(false) + , inReplot(0) + { + } - QwtPlotRescaler::AxisData* axisData( QwtAxisId axisId ) - { - if ( !QwtAxis::isValid( axisId ) ) - return NULL; + QwtPlotRescaler::AxisData *axisData(QwtAxisId axisId) + { + if (!QwtAxis::isValid(axisId)) + return NULL; - return &m_axisData[ axisId]; - } + return &m_axisData[axisId]; + } - QwtAxisId referenceAxis; - RescalePolicy rescalePolicy; - bool isEnabled; + QwtAxisId referenceAxis; + RescalePolicy rescalePolicy; + bool isEnabled; - mutable int inReplot; + mutable int inReplot; - private: - QwtPlotRescaler::AxisData m_axisData[QwtAxis::AxisPositions]; +private: + QwtPlotRescaler::AxisData m_axisData[QwtAxis::AxisPositions]; }; /*! @@ -68,21 +68,21 @@ class QwtPlotRescaler::PrivateData \sa setRescalePolicy(), setReferenceAxis() */ -QwtPlotRescaler::QwtPlotRescaler( QWidget* canvas, - QwtAxisId referenceAxis, RescalePolicy policy ) - : QObject( canvas ) +QwtPlotRescaler::QwtPlotRescaler(QWidget *canvas, QwtAxisId referenceAxis, + RescalePolicy policy) + : QObject(canvas) { - m_data = new PrivateData; - m_data->referenceAxis = referenceAxis; - m_data->rescalePolicy = policy; + m_data = new PrivateData; + m_data->referenceAxis = referenceAxis; + m_data->rescalePolicy = policy; - setEnabled( true ); + setEnabled(true); } //! Destructor QwtPlotRescaler::~QwtPlotRescaler() { - delete m_data; + delete m_data; } /*! @@ -94,21 +94,21 @@ QwtPlotRescaler::~QwtPlotRescaler() \param on true or false \sa isEnabled(), eventFilter() */ -void QwtPlotRescaler::setEnabled( bool on ) +void QwtPlotRescaler::setEnabled(bool on) { - if ( m_data->isEnabled != on ) - { - m_data->isEnabled = on; + if (m_data->isEnabled != on) + { + m_data->isEnabled = on; - QWidget* w = canvas(); - if ( w ) - { - if ( m_data->isEnabled ) - w->installEventFilter( this ); - else - w->removeEventFilter( this ); - } + QWidget *w = canvas(); + if (w) + { + if (m_data->isEnabled) + w->installEventFilter(this); + else + w->removeEventFilter(this); } + } } /*! @@ -117,7 +117,7 @@ void QwtPlotRescaler::setEnabled( bool on ) */ bool QwtPlotRescaler::isEnabled() const { - return m_data->isEnabled; + return m_data->isEnabled; } /*! @@ -126,9 +126,9 @@ bool QwtPlotRescaler::isEnabled() const \param policy Rescale policy \sa rescalePolicy() */ -void QwtPlotRescaler::setRescalePolicy( RescalePolicy policy ) +void QwtPlotRescaler::setRescalePolicy(RescalePolicy policy) { - m_data->rescalePolicy = policy; + m_data->rescalePolicy = policy; } /*! @@ -137,7 +137,7 @@ void QwtPlotRescaler::setRescalePolicy( RescalePolicy policy ) */ QwtPlotRescaler::RescalePolicy QwtPlotRescaler::rescalePolicy() const { - return m_data->rescalePolicy; + return m_data->rescalePolicy; } /*! @@ -146,9 +146,9 @@ QwtPlotRescaler::RescalePolicy QwtPlotRescaler::rescalePolicy() const \param axisId Axis \sa referenceAxis() */ -void QwtPlotRescaler::setReferenceAxis( QwtAxisId axisId ) +void QwtPlotRescaler::setReferenceAxis(QwtAxisId axisId) { - m_data->referenceAxis = axisId; + m_data->referenceAxis = axisId; } /*! @@ -157,7 +157,7 @@ void QwtPlotRescaler::setReferenceAxis( QwtAxisId axisId ) */ QwtAxisId QwtPlotRescaler::referenceAxis() const { - return m_data->referenceAxis; + return m_data->referenceAxis; } /*! @@ -166,11 +166,10 @@ QwtAxisId QwtPlotRescaler::referenceAxis() const \param direction Direction \sa expandingDirection() */ -void QwtPlotRescaler::setExpandingDirection( - ExpandingDirection direction ) +void QwtPlotRescaler::setExpandingDirection(ExpandingDirection direction) { - for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ ) - setExpandingDirection( axis, direction ); + for (int axis = 0; axis < QwtAxis::AxisPositions; axis++) + setExpandingDirection(axis, direction); } /*! @@ -180,11 +179,11 @@ void QwtPlotRescaler::setExpandingDirection( \param direction Direction \sa expandingDirection() */ -void QwtPlotRescaler::setExpandingDirection( - QwtAxisId axisId, ExpandingDirection direction ) +void QwtPlotRescaler::setExpandingDirection(QwtAxisId axisId, + ExpandingDirection direction) { - if ( AxisData* axisData = m_data->axisData( axisId ) ) - axisData->expandingDirection = direction; + if (AxisData *axisData = m_data->axisData(axisId)) + axisData->expandingDirection = direction; } /*! @@ -194,12 +193,12 @@ void QwtPlotRescaler::setExpandingDirection( \sa setExpandingDirection() */ QwtPlotRescaler::ExpandingDirection -QwtPlotRescaler::expandingDirection( QwtAxisId axisId ) const +QwtPlotRescaler::expandingDirection(QwtAxisId axisId) const { - if ( const AxisData* axisData = m_data->axisData( axisId ) ) - return axisData->expandingDirection; + if (const AxisData *axisData = m_data->axisData(axisId)) + return axisData->expandingDirection; - return ExpandBoth; + return ExpandBoth; } /*! @@ -209,10 +208,10 @@ QwtPlotRescaler::expandingDirection( QwtAxisId axisId ) const \param ratio Aspect ratio \sa aspectRatio() */ -void QwtPlotRescaler::setAspectRatio( double ratio ) +void QwtPlotRescaler::setAspectRatio(double ratio) { - for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ ) - setAspectRatio( axis, ratio ); + for (int axis = 0; axis < QwtAxis::AxisPositions; axis++) + setAspectRatio(axis, ratio); } /*! @@ -223,15 +222,15 @@ void QwtPlotRescaler::setAspectRatio( double ratio ) \param ratio Aspect ratio \sa aspectRatio() */ -void QwtPlotRescaler::setAspectRatio( QwtAxisId axisId, double ratio ) +void QwtPlotRescaler::setAspectRatio(QwtAxisId axisId, double ratio) { - if ( AxisData* axisData = m_data->axisData( axisId ) ) - { - if ( ratio < 0.0 ) - ratio = 0.0; + if (AxisData *axisData = m_data->axisData(axisId)) + { + if (ratio < 0.0) + ratio = 0.0; - axisData->aspectRatio = ratio; - } + axisData->aspectRatio = ratio; + } } /*! @@ -240,12 +239,12 @@ void QwtPlotRescaler::setAspectRatio( QwtAxisId axisId, double ratio ) \param axisId Axis \sa setAspectRatio() */ -double QwtPlotRescaler::aspectRatio( QwtAxisId axisId ) const +double QwtPlotRescaler::aspectRatio(QwtAxisId axisId) const { - if ( AxisData* axisData = m_data->axisData( axisId ) ) - return axisData->aspectRatio; + if (AxisData *axisData = m_data->axisData(axisId)) + return axisData->aspectRatio; - return 0.0; + return 0.0; } /*! @@ -258,11 +257,11 @@ double QwtPlotRescaler::aspectRatio( QwtAxisId axisId ) const \param interval Axis \sa intervalHint(), RescalePolicy */ -void QwtPlotRescaler::setIntervalHint( QwtAxisId axisId, - const QwtInterval& interval ) +void QwtPlotRescaler::setIntervalHint(QwtAxisId axisId, + const QwtInterval &interval) { - if ( AxisData* axisData = m_data->axisData( axisId ) ) - axisData->intervalHint = interval; + if (AxisData *axisData = m_data->axisData(axisId)) + axisData->intervalHint = interval; } /*! @@ -270,68 +269,66 @@ void QwtPlotRescaler::setIntervalHint( QwtAxisId axisId, \return Interval hint \sa setIntervalHint(), RescalePolicy */ -QwtInterval QwtPlotRescaler::intervalHint( QwtAxisId axisId ) const +QwtInterval QwtPlotRescaler::intervalHint(QwtAxisId axisId) const { - if ( AxisData* axisData = m_data->axisData( axisId ) ) - return axisData->intervalHint; + if (AxisData *axisData = m_data->axisData(axisId)) + return axisData->intervalHint; - return QwtInterval(); + return QwtInterval(); } //! \return plot canvas -QWidget* QwtPlotRescaler::canvas() +QWidget *QwtPlotRescaler::canvas() { - return qobject_cast< QWidget* >( parent() ); + return qobject_cast(parent()); } //! \return plot canvas -const QWidget* QwtPlotRescaler::canvas() const +const QWidget *QwtPlotRescaler::canvas() const { - return qobject_cast< const QWidget* >( parent() ); + return qobject_cast(parent()); } //! \return plot widget -QwtPlot* QwtPlotRescaler::plot() +QwtPlot *QwtPlotRescaler::plot() { - QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< QwtPlot* >( w ); + return qobject_cast(w); } //! \return plot widget -const QwtPlot* QwtPlotRescaler::plot() const +const QwtPlot *QwtPlotRescaler::plot() const { - const QWidget* w = canvas(); - if ( w ) - w = w->parentWidget(); + const QWidget *w = canvas(); + if (w) + w = w->parentWidget(); - return qobject_cast< const QwtPlot* >( w ); + return qobject_cast(w); } //! Event filter for the plot canvas -bool QwtPlotRescaler::eventFilter( QObject* object, QEvent* event ) +bool QwtPlotRescaler::eventFilter(QObject *object, QEvent *event) { - if ( object && object == canvas() ) + if (object && object == canvas()) + { + switch (event->type()) { - switch ( event->type() ) - { - case QEvent::Resize: - { - canvasResizeEvent( static_cast< QResizeEvent* >( event ) ); - break; - } - case QEvent::PolishRequest: - { - rescale(); - break; - } - default:; - } + case QEvent::Resize: { + canvasResizeEvent(static_cast(event)); + break; + } + case QEvent::PolishRequest: { + rescale(); + break; + } + default:; } + } - return false; + return false; } /*! @@ -340,22 +337,22 @@ bool QwtPlotRescaler::eventFilter( QObject* object, QEvent* event ) \param event Resize event \sa rescale() */ -void QwtPlotRescaler::canvasResizeEvent( QResizeEvent* event ) +void QwtPlotRescaler::canvasResizeEvent(QResizeEvent *event) { - const QMargins m = canvas()->contentsMargins(); - const QSize marginSize( m.left() + m.right(), m.top() + m.bottom() ); + const QMargins m = canvas()->contentsMargins(); + const QSize marginSize(m.left() + m.right(), m.top() + m.bottom()); - const QSize newSize = event->size() - marginSize; - const QSize oldSize = event->oldSize() - marginSize; + const QSize newSize = event->size() - marginSize; + const QSize oldSize = event->oldSize() - marginSize; - rescale( oldSize, newSize ); + rescale(oldSize, newSize); } //! Adjust the plot axes scales void QwtPlotRescaler::rescale() const { - const QSize size = canvas()->contentsRect().size(); - rescale( size, size ); + const QSize size = canvas()->contentsRect().size(); + rescale(size, size); } /*! @@ -364,33 +361,31 @@ void QwtPlotRescaler::rescale() const \param oldSize Previous size of the canvas \param newSize New size of the canvas */ -void QwtPlotRescaler::rescale( - const QSize& oldSize, const QSize& newSize ) const +void QwtPlotRescaler::rescale(const QSize &oldSize, const QSize &newSize) const { - if ( newSize.isEmpty() ) - return; + if (newSize.isEmpty()) + return; - QwtInterval intervals[QwtAxis::AxisPositions]; - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) + QwtInterval intervals[QwtAxis::AxisPositions]; + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { + const QwtAxisId axisId(axisPos); + intervals[axisPos] = interval(axisId); + } + + const QwtAxisId refAxis = referenceAxis(); + intervals[refAxis] = expandScale(refAxis, oldSize, newSize); + + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { + const QwtAxisId axisId(axisPos); + if (aspectRatio(axisId) > 0.0 && axisId != refAxis) { - const QwtAxisId axisId( axisPos ); - intervals[axisPos] = interval( axisId ); + intervals[axisPos] = syncScale(axisId, intervals[refAxis], newSize); } + } - const QwtAxisId refAxis = referenceAxis(); - intervals[refAxis] = expandScale( refAxis, oldSize, newSize ); - - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - const QwtAxisId axisId( axisPos ); - if ( aspectRatio( axisId ) > 0.0 && axisId != refAxis ) - { - intervals[axisPos] = syncScale( - axisId, intervals[refAxis], newSize ); - } - } - - updateScales( intervals ); + updateScales(intervals); } /*! @@ -402,59 +397,56 @@ void QwtPlotRescaler::rescale( \return Calculated new interval for the axis */ -QwtInterval QwtPlotRescaler::expandScale( QwtAxisId axisId, - const QSize& oldSize, const QSize& newSize ) const +QwtInterval QwtPlotRescaler::expandScale(QwtAxisId axisId, const QSize &oldSize, + const QSize &newSize) const { - const QwtInterval oldInterval = interval( axisId ); + const QwtInterval oldInterval = interval(axisId); - QwtInterval expanded = oldInterval; - switch ( rescalePolicy() ) - { - case Fixed: - { - break; // do nothing - } - case Expanding: - { - if ( !oldSize.isEmpty() ) - { - double width = oldInterval.width(); - if ( orientation( axisId ) == Qt::Horizontal ) - width *= double( newSize.width() ) / oldSize.width(); - else - width *= double( newSize.height() ) / oldSize.height(); - - expanded = expandInterval( oldInterval, - width, expandingDirection( axisId ) ); - } - break; - } - case Fitting: - { - double dist = 0.0; - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { - const QwtAxisId axisId( axisPos ); - const double d = pixelDist( axisId, newSize ); - if ( d > dist ) - dist = d; - } - if ( dist > 0.0 ) - { - double width; - if ( orientation( axisId ) == Qt::Horizontal ) - width = newSize.width() * dist; - else - width = newSize.height() * dist; - - expanded = expandInterval( intervalHint( axisId ), - width, expandingDirection( axisId ) ); - } - break; - } + QwtInterval expanded = oldInterval; + switch (rescalePolicy()) + { + case Fixed: { + break; // do nothing } + case Expanding: { + if (!oldSize.isEmpty()) + { + double width = oldInterval.width(); + if (orientation(axisId) == Qt::Horizontal) + width *= double(newSize.width()) / oldSize.width(); + else + width *= double(newSize.height()) / oldSize.height(); - return expanded; + expanded + = expandInterval(oldInterval, width, expandingDirection(axisId)); + } + break; + } + case Fitting: { + double dist = 0.0; + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { + const QwtAxisId axisId(axisPos); + const double d = pixelDist(axisId, newSize); + if (d > dist) + dist = d; + } + if (dist > 0.0) + { + double width; + if (orientation(axisId) == Qt::Horizontal) + width = newSize.width() * dist; + else + width = newSize.height() * dist; + + expanded = expandInterval(intervalHint(axisId), width, + expandingDirection(axisId)); + } + break; + } + } + + return expanded; } /*! @@ -466,52 +458,53 @@ QwtInterval QwtPlotRescaler::expandScale( QwtAxisId axisId, \return New interval for axis */ -QwtInterval QwtPlotRescaler::syncScale( QwtAxisId axisId, - const QwtInterval& reference, const QSize& size ) const +QwtInterval QwtPlotRescaler::syncScale(QwtAxisId axisId, + const QwtInterval &reference, + const QSize &size) const { - double dist; - if ( orientation( referenceAxis() ) == Qt::Horizontal ) - dist = reference.width() / size.width(); - else - dist = reference.width() / size.height(); + double dist; + if (orientation(referenceAxis()) == Qt::Horizontal) + dist = reference.width() / size.width(); + else + dist = reference.width() / size.height(); - if ( orientation( axisId ) == Qt::Horizontal ) - dist *= size.width(); - else - dist *= size.height(); + if (orientation(axisId) == Qt::Horizontal) + dist *= size.width(); + else + dist *= size.height(); - dist /= aspectRatio( axisId ); + dist /= aspectRatio(axisId); - QwtInterval intv; - if ( rescalePolicy() == Fitting ) - intv = intervalHint( axisId ); - else - intv = interval( axisId ); + QwtInterval intv; + if (rescalePolicy() == Fitting) + intv = intervalHint(axisId); + else + intv = interval(axisId); - intv = expandInterval( intv, dist, expandingDirection( axisId ) ); + intv = expandInterval(intv, dist, expandingDirection(axisId)); - return intv; + return intv; } /*! \return Orientation of an axis \param axisId Axis */ -Qt::Orientation QwtPlotRescaler::orientation( QwtAxisId axisId ) const +Qt::Orientation QwtPlotRescaler::orientation(QwtAxisId axisId) const { - return QwtAxis::isYAxis( axisId ) ? Qt::Vertical : Qt::Horizontal; + return QwtAxis::isYAxis(axisId) ? Qt::Vertical : Qt::Horizontal; } /*! \param axisId Axis \return Normalized interval of an axis */ -QwtInterval QwtPlotRescaler::interval( QwtAxisId axisId ) const +QwtInterval QwtPlotRescaler::interval(QwtAxisId axisId) const { - if ( !plot()->isAxisValid( axisId ) ) - return QwtInterval(); + if (!plot()->isAxisValid(axisId)) + return QwtInterval(); - return plot()->axisScaleDiv( axisId ).interval().normalized(); + return plot()->axisScaleDiv(axisId).interval().normalized(); } /*! @@ -523,61 +516,61 @@ QwtInterval QwtPlotRescaler::interval( QwtAxisId axisId ) const \return Expanded interval */ -QwtInterval QwtPlotRescaler::expandInterval( - const QwtInterval& interval, double width, - ExpandingDirection direction ) const +QwtInterval QwtPlotRescaler::expandInterval(const QwtInterval &interval, + double width, + ExpandingDirection direction) const { - QwtInterval expanded = interval; + QwtInterval expanded = interval; - switch ( direction ) - { - case ExpandUp: - expanded.setMinValue( interval.minValue() ); - expanded.setMaxValue( interval.minValue() + width ); - break; + switch (direction) + { + case ExpandUp: + expanded.setMinValue(interval.minValue()); + expanded.setMaxValue(interval.minValue() + width); + break; - case ExpandDown: - expanded.setMaxValue( interval.maxValue() ); - expanded.setMinValue( interval.maxValue() - width ); - break; + case ExpandDown: + expanded.setMaxValue(interval.maxValue()); + expanded.setMinValue(interval.maxValue() - width); + break; - case ExpandBoth: - default: - expanded.setMinValue( interval.minValue() + - interval.width() / 2.0 - width / 2.0 ); - expanded.setMaxValue( expanded.minValue() + width ); - } - return expanded; + case ExpandBoth: + default: + expanded.setMinValue(interval.minValue() + interval.width() / 2.0 + - width / 2.0); + expanded.setMaxValue(expanded.minValue() + width); + } + return expanded; } -double QwtPlotRescaler::pixelDist( QwtAxisId axisId, const QSize& size ) const +double QwtPlotRescaler::pixelDist(QwtAxisId axisId, const QSize &size) const { - const QwtInterval intv = intervalHint( axisId ); + const QwtInterval intv = intervalHint(axisId); - double dist = 0.0; - if ( !intv.isNull() ) + double dist = 0.0; + if (!intv.isNull()) + { + if (axisId == referenceAxis()) { - if ( axisId == referenceAxis() ) - { - dist = intv.width(); - } - else - { - const double r = aspectRatio( axisId ); - if ( r > 0.0 ) - dist = intv.width() * r; - } + dist = intv.width(); } - - if ( dist > 0.0 ) + else { - if ( orientation( axisId ) == Qt::Horizontal ) - dist /= size.width(); - else - dist /= size.height(); + const double r = aspectRatio(axisId); + if (r > 0.0) + dist = intv.width() * r; } + } - return dist; + if (dist > 0.0) + { + if (orientation(axisId) == Qt::Horizontal) + dist /= size.width(); + else + dist /= size.height(); + } + + return dist; } /*! @@ -586,71 +579,71 @@ double QwtPlotRescaler::pixelDist( QwtAxisId axisId, const QSize& size ) const \param intervals Scale intervals */ void QwtPlotRescaler::updateScales( - QwtInterval intervals[QwtAxis::AxisPositions] ) const + QwtInterval intervals[QwtAxis::AxisPositions]) const { - if ( m_data->inReplot >= 5 ) + if (m_data->inReplot >= 5) + { + return; + } + + QwtPlot *plt = const_cast(plot()); + + const bool doReplot = plt->autoReplot(); + plt->setAutoReplot(false); + + for (int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++) + { { - return; - } + const QwtAxisId axisId(axisPos); - QwtPlot* plt = const_cast< QwtPlot* >( plot() ); + if (axisId == referenceAxis() || aspectRatio(axisId) > 0.0) + { + double v1 = intervals[axisPos].minValue(); + double v2 = intervals[axisPos].maxValue(); - const bool doReplot = plt->autoReplot(); - plt->setAutoReplot( false ); + if (!plt->axisScaleDiv(axisId).isIncreasing()) + qSwap(v1, v2); - for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) - { + if (m_data->inReplot >= 1) + m_data->axisData(axisId)->scaleDiv = plt->axisScaleDiv(axisId); + + if (m_data->inReplot >= 2) { - const QwtAxisId axisId( axisPos ); + QList ticks[QwtScaleDiv::NTickTypes]; + for (int t = 0; t < QwtScaleDiv::NTickTypes; t++) + ticks[t] = m_data->axisData(axisId)->scaleDiv.ticks(t); - if ( axisId == referenceAxis() || aspectRatio( axisId ) > 0.0 ) - { - double v1 = intervals[axisPos].minValue(); - double v2 = intervals[axisPos].maxValue(); - - if ( !plt->axisScaleDiv( axisId ).isIncreasing() ) - qSwap( v1, v2 ); - - if ( m_data->inReplot >= 1 ) - m_data->axisData( axisId )->scaleDiv = plt->axisScaleDiv( axisId ); - - if ( m_data->inReplot >= 2 ) - { - QList< double > ticks[QwtScaleDiv::NTickTypes]; - for ( int t = 0; t < QwtScaleDiv::NTickTypes; t++ ) - ticks[t] = m_data->axisData( axisId )->scaleDiv.ticks( t ); - - plt->setAxisScaleDiv( axisId, QwtScaleDiv( v1, v2, ticks ) ); - } - else - { - plt->setAxisScale( axisId, v1, v2 ); - } - } + plt->setAxisScaleDiv(axisId, QwtScaleDiv(v1, v2, ticks)); } + else + { + plt->setAxisScale(axisId, v1, v2); + } + } } + } - QwtPlotCanvas* canvas = qobject_cast< QwtPlotCanvas* >( plt->canvas() ); + QwtPlotCanvas *canvas = qobject_cast(plt->canvas()); - bool immediatePaint = false; - if ( canvas ) - { - immediatePaint = canvas->testPaintAttribute( QwtPlotCanvas::ImmediatePaint ); - canvas->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, false ); - } + bool immediatePaint = false; + if (canvas) + { + immediatePaint = canvas->testPaintAttribute(QwtPlotCanvas::ImmediatePaint); + canvas->setPaintAttribute(QwtPlotCanvas::ImmediatePaint, false); + } - plt->setAutoReplot( doReplot ); + plt->setAutoReplot(doReplot); - m_data->inReplot++; - plt->replot(); - m_data->inReplot--; + m_data->inReplot++; + plt->replot(); + m_data->inReplot--; - if ( canvas && immediatePaint ) - { - canvas->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, true ); - } + if (canvas && immediatePaint) + { + canvas->setPaintAttribute(QwtPlotCanvas::ImmediatePaint, true); + } } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_rescaler.cpp" +# include "moc_qwt_plot_rescaler.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_rescaler.h b/libs/qwt/src/qwt_plot_rescaler.h index 5759e2bd..6a2913a8 100644 --- a/libs/qwt/src/qwt_plot_rescaler.h +++ b/libs/qwt/src/qwt_plot_rescaler.h @@ -28,117 +28,117 @@ class QResizeEvent; class QWT_EXPORT QwtPlotRescaler : public QObject { - Q_OBJECT + Q_OBJECT - public: +public: + /*! + The rescale policy defines how to rescale the reference axis and + their depending axes. + + \sa ExpandingDirection, setIntervalHint() + */ + enum RescalePolicy + { /*! - The rescale policy defines how to rescale the reference axis and - their depending axes. - - \sa ExpandingDirection, setIntervalHint() + The interval of the reference axis remains unchanged, when the + geometry of the canvas changes. All other axes + will be adjusted according to their aspect ratio. */ - enum RescalePolicy - { - /*! - The interval of the reference axis remains unchanged, when the - geometry of the canvas changes. All other axes - will be adjusted according to their aspect ratio. - */ - Fixed, - - /*! - The interval of the reference axis will be shrunk/expanded, - when the geometry of the canvas changes. All other axes - will be adjusted according to their aspect ratio. - - The interval, that is represented by one pixel is fixed. - - */ - Expanding, - - /*! - The intervals of the axes are calculated, so that all axes include - their interval hint. - */ - Fitting - }; + Fixed, /*! - When rescalePolicy() is set to Expanding its direction depends - on ExpandingDirection + The interval of the reference axis will be shrunk/expanded, + when the geometry of the canvas changes. All other axes + will be adjusted according to their aspect ratio. + + The interval, that is represented by one pixel is fixed. + */ - enum ExpandingDirection - { - //! The upper limit of the scale is adjusted - ExpandUp, + Expanding, - //! The lower limit of the scale is adjusted - ExpandDown, + /*! + The intervals of the axes are calculated, so that all axes include + their interval hint. + */ + Fitting + }; - //! Both limits of the scale are adjusted - ExpandBoth - }; + /*! + When rescalePolicy() is set to Expanding its direction depends + on ExpandingDirection + */ + enum ExpandingDirection + { + //! The upper limit of the scale is adjusted + ExpandUp, - explicit QwtPlotRescaler( QWidget* canvas, - QwtAxisId referenceAxis = QwtAxis::XBottom, - RescalePolicy = Expanding ); + //! The lower limit of the scale is adjusted + ExpandDown, - virtual ~QwtPlotRescaler(); + //! Both limits of the scale are adjusted + ExpandBoth + }; - void setEnabled( bool ); - bool isEnabled() const; + explicit QwtPlotRescaler(QWidget *canvas, + QwtAxisId referenceAxis = QwtAxis::XBottom, + RescalePolicy = Expanding); - void setRescalePolicy( RescalePolicy ); - RescalePolicy rescalePolicy() const; + virtual ~QwtPlotRescaler(); - void setExpandingDirection( ExpandingDirection ); - void setExpandingDirection( QwtAxisId, ExpandingDirection ); - ExpandingDirection expandingDirection( QwtAxisId ) const; + void setEnabled(bool); + bool isEnabled() const; - void setReferenceAxis( QwtAxisId ); - QwtAxisId referenceAxis() const; + void setRescalePolicy(RescalePolicy); + RescalePolicy rescalePolicy() const; - void setAspectRatio( double ratio ); - void setAspectRatio( QwtAxisId, double ratio ); - double aspectRatio( QwtAxisId ) const; + void setExpandingDirection(ExpandingDirection); + void setExpandingDirection(QwtAxisId, ExpandingDirection); + ExpandingDirection expandingDirection(QwtAxisId) const; - void setIntervalHint( QwtAxisId, const QwtInterval& ); - QwtInterval intervalHint( QwtAxisId ) const; + void setReferenceAxis(QwtAxisId); + QwtAxisId referenceAxis() const; - QWidget* canvas(); - const QWidget* canvas() const; + void setAspectRatio(double ratio); + void setAspectRatio(QwtAxisId, double ratio); + double aspectRatio(QwtAxisId) const; - QwtPlot* plot(); - const QwtPlot* plot() const; + void setIntervalHint(QwtAxisId, const QwtInterval &); + QwtInterval intervalHint(QwtAxisId) const; - virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; + QWidget *canvas(); + const QWidget *canvas() const; - void rescale() const; + QwtPlot *plot(); + const QwtPlot *plot() const; - protected: - virtual void canvasResizeEvent( QResizeEvent* ); + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; - virtual void rescale( const QSize& oldSize, const QSize& newSize ) const; - virtual QwtInterval expandScale( - QwtAxisId, const QSize& oldSize, const QSize& newSize ) const; + void rescale() const; - virtual QwtInterval syncScale( - QwtAxisId, const QwtInterval& reference, const QSize& size ) const; +protected: + virtual void canvasResizeEvent(QResizeEvent *); - virtual void updateScales( - QwtInterval intervals[QwtAxis::AxisPositions] ) const; + virtual void rescale(const QSize &oldSize, const QSize &newSize) const; + virtual QwtInterval expandScale(QwtAxisId, const QSize &oldSize, + const QSize &newSize) const; - Qt::Orientation orientation( QwtAxisId ) const; - QwtInterval interval( QwtAxisId ) const; - QwtInterval expandInterval( const QwtInterval&, - double width, ExpandingDirection ) const; + virtual QwtInterval syncScale(QwtAxisId, const QwtInterval &reference, + const QSize &size) const; - private: - double pixelDist( QwtAxisId, const QSize& ) const; + virtual void + updateScales(QwtInterval intervals[QwtAxis::AxisPositions]) const; - class AxisData; - class PrivateData; - PrivateData* m_data; + Qt::Orientation orientation(QwtAxisId) const; + QwtInterval interval(QwtAxisId) const; + QwtInterval expandInterval(const QwtInterval &, double width, + ExpandingDirection) const; + +private: + double pixelDist(QwtAxisId, const QSize &) const; + + class AxisData; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_scaleitem.cpp b/libs/qwt/src/qwt_plot_scaleitem.cpp index 211298e2..6793652a 100644 --- a/libs/qwt/src/qwt_plot_scaleitem.cpp +++ b/libs/qwt/src/qwt_plot_scaleitem.cpp @@ -18,82 +18,81 @@ class QwtPlotScaleItem::PrivateData { - public: - PrivateData() - : position( 0.0 ) - , borderDistance( -1 ) - , scaleDivFromAxis( true ) - , scaleDraw( new QwtScaleDraw() ) - { - } +public: + PrivateData() + : position(0.0) + , borderDistance(-1) + , scaleDivFromAxis(true) + , scaleDraw(new QwtScaleDraw()) + { + } - ~PrivateData() - { - delete scaleDraw; - } + ~PrivateData() { delete scaleDraw; } - QwtInterval scaleInterval( const QRectF&, - const QwtScaleMap&, const QwtScaleMap& ) const; + QwtInterval scaleInterval(const QRectF &, const QwtScaleMap &, + const QwtScaleMap &) const; - QPalette palette; - QFont font; - double position; - int borderDistance; - bool scaleDivFromAxis; - QwtScaleDraw* scaleDraw; + QPalette palette; + QFont font; + double position; + int borderDistance; + bool scaleDivFromAxis; + QwtScaleDraw *scaleDraw; }; -QwtInterval QwtPlotScaleItem::PrivateData::scaleInterval( const QRectF& canvasRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap ) const +QwtInterval +QwtPlotScaleItem::PrivateData::scaleInterval(const QRectF &canvasRect, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap) const { - QwtInterval interval; - if ( scaleDraw->orientation() == Qt::Horizontal ) - { - interval.setMinValue( xMap.invTransform( canvasRect.left() ) ); - interval.setMaxValue( xMap.invTransform( canvasRect.right() - 1 ) ); - } - else - { - interval.setMinValue( yMap.invTransform( canvasRect.bottom() - 1 ) ); - interval.setMaxValue( yMap.invTransform( canvasRect.top() ) ); - } + QwtInterval interval; + if (scaleDraw->orientation() == Qt::Horizontal) + { + interval.setMinValue(xMap.invTransform(canvasRect.left())); + interval.setMaxValue(xMap.invTransform(canvasRect.right() - 1)); + } + else + { + interval.setMinValue(yMap.invTransform(canvasRect.bottom() - 1)); + interval.setMaxValue(yMap.invTransform(canvasRect.top())); + } - return interval; + return interval; } /*! \brief Constructor for scale item at the position pos. - \param alignment In case of QwtScaleDraw::BottomScale or QwtScaleDraw::TopScale - the scale item is corresponding to the xAxis(), + \param alignment In case of QwtScaleDraw::BottomScale or + QwtScaleDraw::TopScale the scale item is corresponding to the xAxis(), otherwise it corresponds to the yAxis(). \param pos x or y position, depending on the corresponding axis. \sa setPosition(), setAlignment() */ -QwtPlotScaleItem::QwtPlotScaleItem( - QwtScaleDraw::Alignment alignment, const double pos ) - : QwtPlotItem( QwtText( "Scale" ) ) +QwtPlotScaleItem::QwtPlotScaleItem(QwtScaleDraw::Alignment alignment, + const double pos) + : QwtPlotItem(QwtText("Scale")) { - m_data = new PrivateData; - m_data->position = pos; - m_data->scaleDraw->setAlignment( alignment ); + m_data = new PrivateData; + m_data->position = pos; + m_data->scaleDraw->setAlignment(alignment); - setItemInterest( QwtPlotItem::ScaleInterest, true ); - setZ( 11.0 ); + setItemInterest(QwtPlotItem::ScaleInterest, true); + setZ(11.0); } //! Destructor QwtPlotScaleItem::~QwtPlotScaleItem() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PlotScale int QwtPlotScaleItem::rtti() const { - return QwtPlotItem::Rtti_PlotScale; + return QwtPlotItem::Rtti_PlotScale; } /*! @@ -105,16 +104,16 @@ int QwtPlotScaleItem::rtti() const \param scaleDiv Scale division \sa scaleDiv(), setScaleDivFromAxis(), isScaleDivFromAxis() */ -void QwtPlotScaleItem::setScaleDiv( const QwtScaleDiv& scaleDiv ) +void QwtPlotScaleItem::setScaleDiv(const QwtScaleDiv &scaleDiv) { - m_data->scaleDivFromAxis = false; - m_data->scaleDraw->setScaleDiv( scaleDiv ); + m_data->scaleDivFromAxis = false; + m_data->scaleDraw->setScaleDiv(scaleDiv); } //! \return Scale division -const QwtScaleDiv& QwtPlotScaleItem::scaleDiv() const +const QwtScaleDiv &QwtPlotScaleItem::scaleDiv() const { - return m_data->scaleDraw->scaleDiv(); + return m_data->scaleDraw->scaleDiv(); } /*! @@ -124,22 +123,21 @@ const QwtScaleDiv& QwtPlotScaleItem::scaleDiv() const \param on true/false \sa isScaleDivFromAxis() */ -void QwtPlotScaleItem::setScaleDivFromAxis( bool on ) +void QwtPlotScaleItem::setScaleDivFromAxis(bool on) { - if ( on != m_data->scaleDivFromAxis ) + if (on != m_data->scaleDivFromAxis) + { + m_data->scaleDivFromAxis = on; + if (on) { - m_data->scaleDivFromAxis = on; - if ( on ) - { - const QwtPlot* plt = plot(); - if ( plt ) - { - updateScaleDiv( plt->axisScaleDiv( xAxis() ), - plt->axisScaleDiv( yAxis() ) ); - itemChanged(); - } - } + const QwtPlot *plt = plot(); + if (plt) + { + updateScaleDiv(plt->axisScaleDiv(xAxis()), plt->axisScaleDiv(yAxis())); + itemChanged(); + } } + } } /*! @@ -149,22 +147,22 @@ void QwtPlotScaleItem::setScaleDivFromAxis( bool on ) */ bool QwtPlotScaleItem::isScaleDivFromAxis() const { - return m_data->scaleDivFromAxis; + return m_data->scaleDivFromAxis; } /*! Set the palette \sa QwtAbstractScaleDraw::draw(), palette() */ -void QwtPlotScaleItem::setPalette( const QPalette& palette ) +void QwtPlotScaleItem::setPalette(const QPalette &palette) { - if ( palette != m_data->palette ) - { - m_data->palette = palette; + if (palette != m_data->palette) + { + m_data->palette = palette; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -173,20 +171,20 @@ void QwtPlotScaleItem::setPalette( const QPalette& palette ) */ QPalette QwtPlotScaleItem::palette() const { - return m_data->palette; + return m_data->palette; } /*! Change the tick label font \sa font() */ -void QwtPlotScaleItem::setFont( const QFont& font ) +void QwtPlotScaleItem::setFont(const QFont &font) { - if ( font != m_data->font ) - { - m_data->font = font; - itemChanged(); - } + if (font != m_data->font) + { + m_data->font = font; + itemChanged(); + } } /*! @@ -195,7 +193,7 @@ void QwtPlotScaleItem::setFont( const QFont& font ) */ QFont QwtPlotScaleItem::font() const { - return m_data->font; + return m_data->font; } /*! @@ -209,42 +207,41 @@ QFont QwtPlotScaleItem::font() const \sa scaleDraw() */ -void QwtPlotScaleItem::setScaleDraw( QwtScaleDraw* scaleDraw ) +void QwtPlotScaleItem::setScaleDraw(QwtScaleDraw *scaleDraw) { - if ( scaleDraw == NULL ) - return; + if (scaleDraw == NULL) + return; - if ( scaleDraw != m_data->scaleDraw ) - delete m_data->scaleDraw; + if (scaleDraw != m_data->scaleDraw) + delete m_data->scaleDraw; - m_data->scaleDraw = scaleDraw; + m_data->scaleDraw = scaleDraw; - const QwtPlot* plt = plot(); - if ( plt ) - { - updateScaleDiv( plt->axisScaleDiv( xAxis() ), - plt->axisScaleDiv( yAxis() ) ); - } + const QwtPlot *plt = plot(); + if (plt) + { + updateScaleDiv(plt->axisScaleDiv(xAxis()), plt->axisScaleDiv(yAxis())); + } - itemChanged(); + itemChanged(); } /*! \return Scale draw \sa setScaleDraw() */ -const QwtScaleDraw* QwtPlotScaleItem::scaleDraw() const +const QwtScaleDraw *QwtPlotScaleItem::scaleDraw() const { - return m_data->scaleDraw; + return m_data->scaleDraw; } /*! \return Scale draw \sa setScaleDraw() */ -QwtScaleDraw* QwtPlotScaleItem::scaleDraw() +QwtScaleDraw *QwtPlotScaleItem::scaleDraw() { - return m_data->scaleDraw; + return m_data->scaleDraw; } /*! @@ -258,14 +255,14 @@ QwtScaleDraw* QwtPlotScaleItem::scaleDraw() \param pos New position \sa position(), setAlignment() */ -void QwtPlotScaleItem::setPosition( double pos ) +void QwtPlotScaleItem::setPosition(double pos) { - if ( m_data->position != pos ) - { - m_data->position = pos; - m_data->borderDistance = -1; - itemChanged(); - } + if (m_data->position != pos) + { + m_data->position = pos; + m_data->borderDistance = -1; + itemChanged(); + } } /*! @@ -274,7 +271,7 @@ void QwtPlotScaleItem::setPosition( double pos ) */ double QwtPlotScaleItem::position() const { - return m_data->position; + return m_data->position; } /*! @@ -293,16 +290,16 @@ double QwtPlotScaleItem::position() const \sa setPosition(), borderDistance() */ -void QwtPlotScaleItem::setBorderDistance( int distance ) +void QwtPlotScaleItem::setBorderDistance(int distance) { - if ( distance < 0 ) - distance = -1; + if (distance < 0) + distance = -1; - if ( distance != m_data->borderDistance ) - { - m_data->borderDistance = distance; - itemChanged(); - } + if (distance != m_data->borderDistance) + { + m_data->borderDistance = distance; + itemChanged(); + } } /*! @@ -311,7 +308,7 @@ void QwtPlotScaleItem::setBorderDistance( int distance ) */ int QwtPlotScaleItem::borderDistance() const { - return m_data->borderDistance; + return m_data->borderDistance; } /*! @@ -330,104 +327,102 @@ int QwtPlotScaleItem::borderDistance() const \sa scaleDraw(), QwtScaleDraw::alignment(), setPosition() */ -void QwtPlotScaleItem::setAlignment( QwtScaleDraw::Alignment alignment ) +void QwtPlotScaleItem::setAlignment(QwtScaleDraw::Alignment alignment) { - QwtScaleDraw* sd = m_data->scaleDraw; - if ( sd->alignment() != alignment ) - { - sd->setAlignment( alignment ); - itemChanged(); - } + QwtScaleDraw *sd = m_data->scaleDraw; + if (sd->alignment() != alignment) + { + sd->setAlignment(alignment); + itemChanged(); + } } /*! \brief Draw the scale */ -void QwtPlotScaleItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotScaleItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - QwtScaleDraw* sd = m_data->scaleDraw; + QwtScaleDraw *sd = m_data->scaleDraw; - if ( m_data->scaleDivFromAxis ) + if (m_data->scaleDivFromAxis) + { + const QwtInterval interval = m_data->scaleInterval(canvasRect, xMap, yMap); + + if (interval != sd->scaleDiv().interval()) { - const QwtInterval interval = - m_data->scaleInterval( canvasRect, xMap, yMap ); + QwtScaleDiv scaleDiv = sd->scaleDiv(); + scaleDiv.setInterval(interval); + sd->setScaleDiv(scaleDiv); + } + } - if ( interval != sd->scaleDiv().interval() ) - { - QwtScaleDiv scaleDiv = sd->scaleDiv(); - scaleDiv.setInterval( interval ); - sd->setScaleDiv( scaleDiv ); - } + QPen pen = painter->pen(); + pen.setStyle(Qt::SolidLine); + painter->setPen(pen); + + if (sd->orientation() == Qt::Horizontal) + { + double y; + if (m_data->borderDistance >= 0) + { + if (sd->alignment() == QwtScaleDraw::BottomScale) + y = canvasRect.top() + m_data->borderDistance; + else + { + y = canvasRect.bottom() - m_data->borderDistance; + } + } + else + { + y = yMap.transform(m_data->position); } - QPen pen = painter->pen(); - pen.setStyle( Qt::SolidLine ); - painter->setPen( pen ); + if (y < canvasRect.top() || y > canvasRect.bottom()) + return; - if ( sd->orientation() == Qt::Horizontal ) + sd->move(canvasRect.left(), y); + sd->setLength(canvasRect.width() - 1); + + QwtTransform *transform = NULL; + if (xMap.transformation()) + transform = xMap.transformation()->copy(); + + sd->setTransformation(transform); + } + else // == Qt::Vertical + { + double x; + if (m_data->borderDistance >= 0) { - double y; - if ( m_data->borderDistance >= 0 ) - { - if ( sd->alignment() == QwtScaleDraw::BottomScale ) - y = canvasRect.top() + m_data->borderDistance; - else - { - y = canvasRect.bottom() - m_data->borderDistance; - } - - } - else - { - y = yMap.transform( m_data->position ); - } - - if ( y < canvasRect.top() || y > canvasRect.bottom() ) - return; - - sd->move( canvasRect.left(), y ); - sd->setLength( canvasRect.width() - 1 ); - - QwtTransform* transform = NULL; - if ( xMap.transformation() ) - transform = xMap.transformation()->copy(); - - sd->setTransformation( transform ); + if (sd->alignment() == QwtScaleDraw::RightScale) + x = canvasRect.left() + m_data->borderDistance; + else + { + x = canvasRect.right() - m_data->borderDistance; + } } - else // == Qt::Vertical + else { - double x; - if ( m_data->borderDistance >= 0 ) - { - if ( sd->alignment() == QwtScaleDraw::RightScale ) - x = canvasRect.left() + m_data->borderDistance; - else - { - x = canvasRect.right() - m_data->borderDistance; - } - } - else - { - x = xMap.transform( m_data->position ); - } - if ( x < canvasRect.left() || x > canvasRect.right() ) - return; - - sd->move( x, canvasRect.top() ); - sd->setLength( canvasRect.height() - 1 ); - - QwtTransform* transform = NULL; - if ( yMap.transformation() ) - transform = yMap.transformation()->copy(); - - sd->setTransformation( transform ); + x = xMap.transform(m_data->position); } + if (x < canvasRect.left() || x > canvasRect.right()) + return; - painter->setFont( m_data->font ); + sd->move(x, canvasRect.top()); + sd->setLength(canvasRect.height() - 1); - sd->draw( painter, m_data->palette ); + QwtTransform *transform = NULL; + if (yMap.transformation()) + transform = yMap.transformation()->copy(); + + sd->setTransformation(transform); + } + + painter->setFont(m_data->font); + + sd->draw(painter, m_data->palette); } /*! @@ -442,39 +437,39 @@ void QwtPlotScaleItem::draw( QPainter* painter, \sa QwtPlot::updateAxes() */ -void QwtPlotScaleItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv, - const QwtScaleDiv& yScaleDiv ) +void QwtPlotScaleItem::updateScaleDiv(const QwtScaleDiv &xScaleDiv, + const QwtScaleDiv &yScaleDiv) { - QwtScaleDraw* scaleDraw = m_data->scaleDraw; + QwtScaleDraw *scaleDraw = m_data->scaleDraw; - if ( m_data->scaleDivFromAxis && scaleDraw ) + if (m_data->scaleDivFromAxis && scaleDraw) + { + const QwtScaleDiv &scaleDiv + = scaleDraw->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv; + + const QwtPlot *plt = plot(); + if (plt != NULL) { - const QwtScaleDiv& scaleDiv = - scaleDraw->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv; + const QRectF canvasRect = plt->canvas()->contentsRect(); - const QwtPlot* plt = plot(); - if ( plt != NULL ) - { - const QRectF canvasRect = plt->canvas()->contentsRect(); + const QwtInterval interval = m_data->scaleInterval( + canvasRect, plt->canvasMap(xAxis()), plt->canvasMap(yAxis())); - const QwtInterval interval = m_data->scaleInterval( - canvasRect, plt->canvasMap( xAxis() ), plt->canvasMap( yAxis() ) ); + QwtScaleDiv sd = scaleDiv; + sd.setInterval(interval); - QwtScaleDiv sd = scaleDiv; - sd.setInterval( interval ); + if (sd != scaleDraw->scaleDiv()) + { + // the internal label cache of QwtScaleDraw + // is cleared here, so better avoid pointless + // assignments. - if ( sd != scaleDraw->scaleDiv() ) - { - // the internal label cache of QwtScaleDraw - // is cleared here, so better avoid pointless - // assignments. - - scaleDraw->setScaleDiv( sd ); - } - } - else - { - scaleDraw->setScaleDiv( scaleDiv ); - } + scaleDraw->setScaleDiv(sd); + } } + else + { + scaleDraw->setScaleDiv(scaleDiv); + } + } } diff --git a/libs/qwt/src/qwt_plot_scaleitem.h b/libs/qwt/src/qwt_plot_scaleitem.h index 536c6a64..7014df8c 100644 --- a/libs/qwt/src/qwt_plot_scaleitem.h +++ b/libs/qwt/src/qwt_plot_scaleitem.h @@ -35,9 +35,9 @@ class QPalette; The following example shows how to replace the left axis, by a scale item at the x position 0.0. \code - QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem( QwtScaleDraw::RightScale, 0.0 ); - scaleItem->setFont( plot->axisWidget( QwtAxis::YLeft )->font() ); - scaleItem->attach(plot); + QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem( + QwtScaleDraw::RightScale, 0.0 ); scaleItem->setFont( plot->axisWidget( + QwtAxis::YLeft )->font() ); scaleItem->attach(plot); plot->setAxisVisible( QwtAxis::YLeft, false ); \endcode @@ -45,50 +45,49 @@ class QPalette; class QWT_EXPORT QwtPlotScaleItem : public QwtPlotItem { - public: - explicit QwtPlotScaleItem( - QwtScaleDraw::Alignment = QwtScaleDraw::BottomScale, - const double pos = 0.0 ); +public: + explicit QwtPlotScaleItem(QwtScaleDraw::Alignment = QwtScaleDraw::BottomScale, + const double pos = 0.0); - virtual ~QwtPlotScaleItem(); + virtual ~QwtPlotScaleItem(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setScaleDiv( const QwtScaleDiv& ); - const QwtScaleDiv& scaleDiv() const; + void setScaleDiv(const QwtScaleDiv &); + const QwtScaleDiv &scaleDiv() const; - void setScaleDivFromAxis( bool on ); - bool isScaleDivFromAxis() const; + void setScaleDivFromAxis(bool on); + bool isScaleDivFromAxis() const; - void setPalette( const QPalette& ); - QPalette palette() const; + void setPalette(const QPalette &); + QPalette palette() const; - void setFont( const QFont& ); - QFont font() const; + void setFont(const QFont &); + QFont font() const; - void setScaleDraw( QwtScaleDraw* ); + void setScaleDraw(QwtScaleDraw *); - const QwtScaleDraw* scaleDraw() const; - QwtScaleDraw* scaleDraw(); + const QwtScaleDraw *scaleDraw() const; + QwtScaleDraw *scaleDraw(); - void setPosition( double pos ); - double position() const; + void setPosition(double pos); + double position() const; - void setBorderDistance( int ); - int borderDistance() const; + void setBorderDistance(int); + int borderDistance() const; - void setAlignment( QwtScaleDraw::Alignment ); + void setAlignment(QwtScaleDraw::Alignment); - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - virtual void updateScaleDiv( - const QwtScaleDiv&, const QwtScaleDiv& ) QWT_OVERRIDE; + virtual void updateScaleDiv(const QwtScaleDiv &, + const QwtScaleDiv &) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_seriesitem.cpp b/libs/qwt/src/qwt_plot_seriesitem.cpp index d745e016..7d137654 100644 --- a/libs/qwt/src/qwt_plot_seriesitem.cpp +++ b/libs/qwt/src/qwt_plot_seriesitem.cpp @@ -13,41 +13,41 @@ class QwtPlotSeriesItem::PrivateData { - public: - PrivateData() - : orientation( Qt::Vertical ) - { - } +public: + PrivateData() + : orientation(Qt::Vertical) + { + } - Qt::Orientation orientation; + Qt::Orientation orientation; }; /*! Constructor \param title Title of the curve */ -QwtPlotSeriesItem::QwtPlotSeriesItem( const QwtText& title ) - : QwtPlotItem( title ) +QwtPlotSeriesItem::QwtPlotSeriesItem(const QwtText &title) + : QwtPlotItem(title) { - m_data = new PrivateData(); - setItemInterest( QwtPlotItem::ScaleInterest, true ); + m_data = new PrivateData(); + setItemInterest(QwtPlotItem::ScaleInterest, true); } /*! Constructor \param title Title of the curve */ -QwtPlotSeriesItem::QwtPlotSeriesItem( const QString& title ) - : QwtPlotItem( QwtText( title ) ) +QwtPlotSeriesItem::QwtPlotSeriesItem(const QString &title) + : QwtPlotItem(QwtText(title)) { - m_data = new PrivateData(); - setItemInterest( QwtPlotItem::ScaleInterest, true ); + m_data = new PrivateData(); + setItemInterest(QwtPlotItem::ScaleInterest, true); } //! Destructor QwtPlotSeriesItem::~QwtPlotSeriesItem() { - delete m_data; + delete m_data; } /*! @@ -59,15 +59,15 @@ QwtPlotSeriesItem::~QwtPlotSeriesItem() \sa orientation() */ -void QwtPlotSeriesItem::setOrientation( Qt::Orientation orientation ) +void QwtPlotSeriesItem::setOrientation(Qt::Orientation orientation) { - if ( m_data->orientation != orientation ) - { - m_data->orientation = orientation; + if (m_data->orientation != orientation) + { + m_data->orientation = orientation; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -76,7 +76,7 @@ void QwtPlotSeriesItem::setOrientation( Qt::Orientation orientation ) */ Qt::Orientation QwtPlotSeriesItem::orientation() const { - return m_data->orientation; + return m_data->orientation; } /*! @@ -87,29 +87,28 @@ Qt::Orientation QwtPlotSeriesItem::orientation() const \param yMap Maps y-values into pixel coordinates. \param canvasRect Contents rectangle of the canvas */ -void QwtPlotSeriesItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotSeriesItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - drawSeries( painter, xMap, yMap, canvasRect, 0, -1 ); + drawSeries(painter, xMap, yMap, canvasRect, 0, -1); } QRectF QwtPlotSeriesItem::boundingRect() const { - return dataRect(); + return dataRect(); } -void QwtPlotSeriesItem::updateScaleDiv( - const QwtScaleDiv& xScaleDiv, const QwtScaleDiv& yScaleDiv ) +void QwtPlotSeriesItem::updateScaleDiv(const QwtScaleDiv &xScaleDiv, + const QwtScaleDiv &yScaleDiv) { - const QRectF rect = QRectF( - xScaleDiv.lowerBound(), yScaleDiv.lowerBound(), - xScaleDiv.range(), yScaleDiv.range() ); + const QRectF rect = QRectF(xScaleDiv.lowerBound(), yScaleDiv.lowerBound(), + xScaleDiv.range(), yScaleDiv.range()); - setRectOfInterest( rect ); + setRectOfInterest(rect); } void QwtPlotSeriesItem::dataChanged() { - itemChanged(); + itemChanged(); } diff --git a/libs/qwt/src/qwt_plot_seriesitem.h b/libs/qwt/src/qwt_plot_seriesitem.h index b5c134a7..ee551799 100644 --- a/libs/qwt/src/qwt_plot_seriesitem.h +++ b/libs/qwt/src/qwt_plot_seriesitem.h @@ -22,47 +22,48 @@ class QwtScaleDiv; \brief Base class for plot items representing a series of samples */ class QWT_EXPORT QwtPlotSeriesItem : public QwtPlotItem, - public virtual QwtAbstractSeriesStore + public virtual QwtAbstractSeriesStore { - public: - explicit QwtPlotSeriesItem( const QString& title = QString() ); - explicit QwtPlotSeriesItem( const QwtText& title ); +public: + explicit QwtPlotSeriesItem(const QString &title = QString()); + explicit QwtPlotSeriesItem(const QwtText &title); - virtual ~QwtPlotSeriesItem(); + virtual ~QwtPlotSeriesItem(); - void setOrientation( Qt::Orientation ); - Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation); + Qt::Orientation orientation() const; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - /*! - Draw a subset of the samples + /*! + Draw a subset of the samples - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rectangle of the canvas - \param from Index of the first point to be painted - \param to Index of the last point to be painted. If to < 0 the - curve will be painted to its last point. - */ - virtual void drawSeries( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const = 0; + \param painter Painter + \param xMap Maps x-values into pixel coordinates. + \param yMap Maps y-values into pixel coordinates. + \param canvasRect Contents rectangle of the canvas + \param from Index of the first point to be painted + \param to Index of the last point to be painted. If to < 0 the + curve will be painted to its last point. + */ + virtual void drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const + = 0; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual void updateScaleDiv( - const QwtScaleDiv&, const QwtScaleDiv& ) QWT_OVERRIDE; + virtual void updateScaleDiv(const QwtScaleDiv &, + const QwtScaleDiv &) QWT_OVERRIDE; - protected: - virtual void dataChanged() QWT_OVERRIDE; +protected: + virtual void dataChanged() QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_shapeitem.cpp b/libs/qwt/src/qwt_plot_shapeitem.cpp index af7a607b..e7e3c42d 100644 --- a/libs/qwt/src/qwt_plot_shapeitem.cpp +++ b/libs/qwt/src/qwt_plot_shapeitem.cpp @@ -19,85 +19,81 @@ #include #include -static QPainterPath qwtTransformPath( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QPainterPath& path, bool doAlign ) +static QPainterPath qwtTransformPath(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QPainterPath &path, bool doAlign) { - QPainterPath shape; - shape.setFillRule( path.fillRule() ); + QPainterPath shape; + shape.setFillRule(path.fillRule()); - for ( int i = 0; i < path.elementCount(); i++ ) + for (int i = 0; i < path.elementCount(); i++) + { + const QPainterPath::Element element = path.elementAt(i); + + double x = xMap.transform(element.x); + double y = yMap.transform(element.y); + + switch (element.type) { - const QPainterPath::Element element = path.elementAt( i ); - - double x = xMap.transform( element.x ); - double y = yMap.transform( element.y ); - - switch( element.type ) + case QPainterPath::MoveToElement: { + if (doAlign) { - case QPainterPath::MoveToElement: - { - if ( doAlign ) - { - x = qRound( x ); - y = qRound( y ); - } - - shape.moveTo( x, y ); - break; - } - case QPainterPath::LineToElement: - { - if ( doAlign ) - { - x = qRound( x ); - y = qRound( y ); - } - - shape.lineTo( x, y ); - break; - } - case QPainterPath::CurveToElement: - { - const QPainterPath::Element element1 = path.elementAt( ++i ); - const double x1 = xMap.transform( element1.x ); - const double y1 = yMap.transform( element1.y ); - - const QPainterPath::Element element2 = path.elementAt( ++i ); - const double x2 = xMap.transform( element2.x ); - const double y2 = yMap.transform( element2.y ); - - shape.cubicTo( x, y, x1, y1, x2, y2 ); - break; - } - case QPainterPath::CurveToDataElement: - { - break; - } + x = qRound(x); + y = qRound(y); } + + shape.moveTo(x, y); + break; + } + case QPainterPath::LineToElement: { + if (doAlign) + { + x = qRound(x); + y = qRound(y); + } + + shape.lineTo(x, y); + break; + } + case QPainterPath::CurveToElement: { + const QPainterPath::Element element1 = path.elementAt(++i); + const double x1 = xMap.transform(element1.x); + const double y1 = yMap.transform(element1.y); + + const QPainterPath::Element element2 = path.elementAt(++i); + const double x2 = xMap.transform(element2.x); + const double y2 = yMap.transform(element2.y); + + shape.cubicTo(x, y, x1, y1, x2, y2); + break; + } + case QPainterPath::CurveToDataElement: { + break; + } } + } - return shape; + return shape; } - class QwtPlotShapeItem::PrivateData { - public: - PrivateData() - : legendMode( QwtPlotShapeItem::LegendColor ) - , renderTolerance( 0.0 ) - { - } +public: + PrivateData() + : legendMode(QwtPlotShapeItem::LegendColor) + , renderTolerance(0.0) + { + } - QwtPlotShapeItem::PaintAttributes paintAttributes; - QwtPlotShapeItem::LegendMode legendMode; + QwtPlotShapeItem::PaintAttributes paintAttributes; + QwtPlotShapeItem::LegendMode legendMode; - double renderTolerance; - QRectF boundingRect; + double renderTolerance; + QRectF boundingRect; - QPen pen; - QBrush brush; - QPainterPath shape; + QPen pen; + QBrush brush; + QPainterPath shape; }; /*! @@ -109,10 +105,10 @@ class QwtPlotShapeItem::PrivateData \param title Title */ -QwtPlotShapeItem::QwtPlotShapeItem( const QString& title ) - : QwtPlotItem( QwtText( title ) ) +QwtPlotShapeItem::QwtPlotShapeItem(const QString &title) + : QwtPlotItem(QwtText(title)) { - init(); + init(); } /*! @@ -124,33 +120,33 @@ QwtPlotShapeItem::QwtPlotShapeItem( const QString& title ) \param title Title */ -QwtPlotShapeItem::QwtPlotShapeItem( const QwtText& title ) - : QwtPlotItem( title ) +QwtPlotShapeItem::QwtPlotShapeItem(const QwtText &title) + : QwtPlotItem(title) { - init(); + init(); } //! Destructor QwtPlotShapeItem::~QwtPlotShapeItem() { - delete m_data; + delete m_data; } void QwtPlotShapeItem::init() { - m_data = new PrivateData(); - m_data->boundingRect = QwtPlotItem::boundingRect(); + m_data = new PrivateData(); + m_data->boundingRect = QwtPlotItem::boundingRect(); - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Legend, false ); + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Legend, false); - setZ( 8.0 ); + setZ(8.0); } //! \return QwtPlotItem::Rtti_PlotShape int QwtPlotShapeItem::rtti() const { - return QwtPlotItem::Rtti_PlotShape; + return QwtPlotItem::Rtti_PlotShape; } /*! @@ -160,21 +156,21 @@ int QwtPlotShapeItem::rtti() const \param on On/Off \sa testPaintAttribute() */ -void QwtPlotShapeItem::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPlotShapeItem::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! \return True, when attribute is enabled \sa setPaintAttribute() */ -bool QwtPlotShapeItem::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPlotShapeItem::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! @@ -183,13 +179,13 @@ bool QwtPlotShapeItem::testPaintAttribute( PaintAttribute attribute ) const \param mode Mode \sa legendMode() */ -void QwtPlotShapeItem::setLegendMode( LegendMode mode ) +void QwtPlotShapeItem::setLegendMode(LegendMode mode) { - if ( mode != m_data->legendMode ) - { - m_data->legendMode = mode; - legendChanged(); - } + if (mode != m_data->legendMode) + { + m_data->legendMode = mode; + legendChanged(); + } } /*! @@ -198,13 +194,13 @@ void QwtPlotShapeItem::setLegendMode( LegendMode mode ) */ QwtPlotShapeItem::LegendMode QwtPlotShapeItem::legendMode() const { - return m_data->legendMode; + return m_data->legendMode; } //! Bounding rectangle of the shape QRectF QwtPlotShapeItem::boundingRect() const { - return m_data->boundingRect; + return m_data->boundingRect; } /*! @@ -213,12 +209,12 @@ QRectF QwtPlotShapeItem::boundingRect() const \param rect Rectangle \sa setShape(), setPolygon(), shape() */ -void QwtPlotShapeItem::setRect( const QRectF& rect ) +void QwtPlotShapeItem::setRect(const QRectF &rect) { - QPainterPath path; - path.addRect( rect ); + QPainterPath path; + path.addRect(rect); - setShape( path ); + setShape(path); } /*! @@ -227,12 +223,12 @@ void QwtPlotShapeItem::setRect( const QRectF& rect ) \param polygon Polygon \sa setShape(), setRect(), shape() */ -void QwtPlotShapeItem::setPolygon( const QPolygonF& polygon ) +void QwtPlotShapeItem::setPolygon(const QPolygonF &polygon) { - QPainterPath shape; - shape.addPolygon( polygon ); + QPainterPath shape; + shape.addPolygon(polygon); - setShape( shape ); + setShape(shape); } /*! @@ -241,22 +237,22 @@ void QwtPlotShapeItem::setPolygon( const QPolygonF& polygon ) \param shape Shape \sa setShape(), shape() */ -void QwtPlotShapeItem::setShape( const QPainterPath& shape ) +void QwtPlotShapeItem::setShape(const QPainterPath &shape) { - if ( shape != m_data->shape ) + if (shape != m_data->shape) + { + m_data->shape = shape; + if (shape.isEmpty()) { - m_data->shape = shape; - if ( shape.isEmpty() ) - { - m_data->boundingRect = QwtPlotItem::boundingRect(); - } - else - { - m_data->boundingRect = shape.boundingRect(); - } - - itemChanged(); + m_data->boundingRect = QwtPlotItem::boundingRect(); } + else + { + m_data->boundingRect = shape.boundingRect(); + } + + itemChanged(); + } } /*! @@ -265,7 +261,7 @@ void QwtPlotShapeItem::setShape( const QPainterPath& shape ) */ QPainterPath QwtPlotShapeItem::shape() const { - return m_data->shape; + return m_data->shape; } /*! @@ -281,9 +277,10 @@ QPainterPath QwtPlotShapeItem::shape() const \sa pen(), brush() */ -void QwtPlotShapeItem::setPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotShapeItem::setPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -294,13 +291,13 @@ void QwtPlotShapeItem::setPen( const QColor& color, qreal width, Qt::PenStyle st \param pen Pen \sa pen(), brush() */ -void QwtPlotShapeItem::setPen( const QPen& pen ) +void QwtPlotShapeItem::setPen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; - itemChanged(); - } + if (pen != m_data->pen) + { + m_data->pen = pen; + itemChanged(); + } } /*! @@ -309,7 +306,7 @@ void QwtPlotShapeItem::setPen( const QPen& pen ) */ QPen QwtPlotShapeItem::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -320,13 +317,13 @@ QPen QwtPlotShapeItem::pen() const \param brush Brush \sa brush(), pen() */ -void QwtPlotShapeItem::setBrush( const QBrush& brush ) +void QwtPlotShapeItem::setBrush(const QBrush &brush) { - if ( brush != m_data->brush ) - { - m_data->brush = brush; - itemChanged(); - } + if (brush != m_data->brush) + { + m_data->brush = brush; + itemChanged(); + } } /*! @@ -335,7 +332,7 @@ void QwtPlotShapeItem::setBrush( const QBrush& brush ) */ QBrush QwtPlotShapeItem::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -354,15 +351,15 @@ QBrush QwtPlotShapeItem::brush() const \sa renderTolerance(), QwtWeedingCurveFitter */ -void QwtPlotShapeItem::setRenderTolerance( double tolerance ) +void QwtPlotShapeItem::setRenderTolerance(double tolerance) { - tolerance = qwtMaxF( tolerance, 0.0 ); + tolerance = qwtMaxF(tolerance, 0.0); - if ( tolerance != m_data->renderTolerance ) - { - m_data->renderTolerance = tolerance; - itemChanged(); - } + if (tolerance != m_data->renderTolerance) + { + m_data->renderTolerance = tolerance; + itemChanged(); + } } /*! @@ -371,7 +368,7 @@ void QwtPlotShapeItem::setRenderTolerance( double tolerance ) */ double QwtPlotShapeItem::renderTolerance() const { - return m_data->renderTolerance; + return m_data->renderTolerance; } /*! @@ -382,73 +379,69 @@ double QwtPlotShapeItem::renderTolerance() const \param yMap Y-Scale Map \param canvasRect Contents rect of the plot canvas */ -void QwtPlotShapeItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotShapeItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - if ( m_data->shape.isEmpty() ) - return; + if (m_data->shape.isEmpty()) + return; - if ( m_data->pen.style() == Qt::NoPen - && m_data->brush.style() == Qt::NoBrush ) + if (m_data->pen.style() == Qt::NoPen && m_data->brush.style() == Qt::NoBrush) + { + return; + } + + const QRectF cr = QwtScaleMap::invTransform(xMap, yMap, canvasRect.toRect()); + + const QRectF &br = m_data->boundingRect; + + if ((br.left() > cr.right()) || (br.right() < cr.left()) + || (br.top() > cr.bottom()) || (br.bottom() < cr.top())) + { + // outside the visible area + return; + } + + const bool doAlign = QwtPainter::roundingAlignment(painter); + + QPainterPath path = qwtTransformPath(xMap, yMap, m_data->shape, doAlign); + + if (testPaintAttribute(QwtPlotShapeItem::ClipPolygons)) + { + const qreal pw = QwtPainter::effectivePenWidth(painter->pen()); + const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw); + + QPainterPath clippedPath; + clippedPath.setFillRule(path.fillRule()); + + QList polygons = path.toSubpathPolygons(); + for (int i = 0; i < polygons.size(); i++) { - return; + QwtClipper::clipPolygonF(clipRect, polygons[i], true); + clippedPath.addPolygon(polygons[i]); } - const QRectF cr = QwtScaleMap::invTransform( - xMap, yMap, canvasRect.toRect() ); + path = clippedPath; + } - const QRectF& br = m_data->boundingRect; + if (m_data->renderTolerance > 0.0) + { + QwtWeedingCurveFitter fitter(m_data->renderTolerance); - if ( ( br.left() > cr.right() ) || ( br.right() < cr.left() ) - || ( br.top() > cr.bottom() ) || ( br.bottom() < cr.top() ) ) - { - // outside the visible area - return; - } + QPainterPath fittedPath; + fittedPath.setFillRule(path.fillRule()); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const QList polygons = path.toSubpathPolygons(); + for (int i = 0; i < polygons.size(); i++) + fittedPath.addPolygon(fitter.fitCurve(polygons[i])); - QPainterPath path = qwtTransformPath( xMap, yMap, - m_data->shape, doAlign ); + path = fittedPath; + } - if ( testPaintAttribute( QwtPlotShapeItem::ClipPolygons ) ) - { - const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); - const QRectF clipRect = canvasRect.adjusted( -pw, -pw, pw, pw ); + painter->setPen(m_data->pen); + painter->setBrush(m_data->brush); - QPainterPath clippedPath; - clippedPath.setFillRule( path.fillRule() ); - - QList< QPolygonF > polygons = path.toSubpathPolygons(); - for ( int i = 0; i < polygons.size(); i++ ) - { - QwtClipper::clipPolygonF( clipRect, polygons[i], true ); - clippedPath.addPolygon( polygons[i] ); - - } - - path = clippedPath; - } - - if ( m_data->renderTolerance > 0.0 ) - { - QwtWeedingCurveFitter fitter( m_data->renderTolerance ); - - QPainterPath fittedPath; - fittedPath.setFillRule( path.fillRule() ); - - const QList< QPolygonF > polygons = path.toSubpathPolygons(); - for ( int i = 0; i < polygons.size(); i++ ) - fittedPath.addPolygon( fitter.fitCurve( polygons[ i ] ) ); - - path = fittedPath; - } - - painter->setPen( m_data->pen ); - painter->setBrush( m_data->brush ); - - painter->drawPath( path ); + painter->drawPath(path); } /*! @@ -460,42 +453,40 @@ void QwtPlotShapeItem::draw( QPainter* painter, \sa setLegendIconSize(), legendData() */ -QwtGraphic QwtPlotShapeItem::legendIcon( int index, - const QSizeF& size ) const +QwtGraphic QwtPlotShapeItem::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); + Q_UNUSED(index); - QwtGraphic icon; - icon.setDefaultSize( size ); - - if ( size.isEmpty() ) - return icon; - - if ( m_data->legendMode == QwtPlotShapeItem::LegendShape ) - { - const QRectF& br = m_data->boundingRect; - - QPainter painter( &icon ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); - - painter.translate( -br.topLeft() ); - - painter.setPen( m_data->pen ); - painter.setBrush( m_data->brush ); - painter.drawPath( m_data->shape ); - } - else - { - QColor iconColor; - if ( m_data->brush.style() != Qt::NoBrush ) - iconColor = m_data->brush.color(); - else - iconColor = m_data->pen.color(); - - icon = defaultIcon( iconColor, size ); - } + QwtGraphic icon; + icon.setDefaultSize(size); + if (size.isEmpty()) return icon; -} + if (m_data->legendMode == QwtPlotShapeItem::LegendShape) + { + const QRectF &br = m_data->boundingRect; + + QPainter painter(&icon); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); + + painter.translate(-br.topLeft()); + + painter.setPen(m_data->pen); + painter.setBrush(m_data->brush); + painter.drawPath(m_data->shape); + } + else + { + QColor iconColor; + if (m_data->brush.style() != Qt::NoBrush) + iconColor = m_data->brush.color(); + else + iconColor = m_data->pen.color(); + + icon = defaultIcon(iconColor, size); + } + + return icon; +} diff --git a/libs/qwt/src/qwt_plot_shapeitem.h b/libs/qwt/src/qwt_plot_shapeitem.h index e90e2a9a..ab4ea107 100644 --- a/libs/qwt/src/qwt_plot_shapeitem.h +++ b/libs/qwt/src/qwt_plot_shapeitem.h @@ -23,96 +23,95 @@ class QPolygonF; that can be defined by a QPainterPath A QPainterPath is a shape composed from intersecting and uniting - regions, rectangles, ellipses or irregular areas defined by lines, and curves. - QwtPlotShapeItem displays a shape with a pen and brush. + regions, rectangles, ellipses or irregular areas defined by lines, and + curves. QwtPlotShapeItem displays a shape with a pen and brush. QwtPlotShapeItem offers a couple of optimizations like clipping or weeding. These algorithms need to convert the painter path into polygons that might be less performant for paths built from curves and ellipses. - More complex shapes, that can't be expressed by a QPainterPath can be displayed - using QwtPlotGraphicItem. + More complex shapes, that can't be expressed by a QPainterPath can be + displayed using QwtPlotGraphicItem. \sa QwtPlotZone, QwtPlotGraphicItem */ class QWT_EXPORT QwtPlotShapeItem : public QwtPlotItem { - public: +public: + /*! + Attributes to modify the drawing algorithm. + The default disables all attributes + + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { /*! - Attributes to modify the drawing algorithm. - The default disables all attributes + Clip polygons before painting them. In situations, where points + are far outside the visible area (f.e when zooming deep) this + might be a substantial improvement for the painting performance - \sa setPaintAttribute(), testPaintAttribute() + But polygon clipping will convert the painter path into + polygons what might introduce a negative impact on the + performance of paths composed from curves or ellipses. */ - enum PaintAttribute - { - /*! - Clip polygons before painting them. In situations, where points - are far outside the visible area (f.e when zooming deep) this - might be a substantial improvement for the painting performance + ClipPolygons = 0x01, + }; - But polygon clipping will convert the painter path into - polygons what might introduce a negative impact on the - performance of paths composed from curves or ellipses. - */ - ClipPolygons = 0x01, - }; + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + //! Mode how to display the item on the legend + enum LegendMode + { + //! Display a scaled down version of the shape + LegendShape, - //! Mode how to display the item on the legend - enum LegendMode - { - //! Display a scaled down version of the shape - LegendShape, + //! Display a filled rectangle + LegendColor + }; - //! Display a filled rectangle - LegendColor - }; + explicit QwtPlotShapeItem(const QString &title = QString()); + explicit QwtPlotShapeItem(const QwtText &title); - explicit QwtPlotShapeItem( const QString& title = QString() ); - explicit QwtPlotShapeItem( const QwtText& title ); + virtual ~QwtPlotShapeItem(); - virtual ~QwtPlotShapeItem(); + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + void setLegendMode(LegendMode); + LegendMode legendMode() const; - void setLegendMode( LegendMode ); - LegendMode legendMode() const; + void setRect(const QRectF &); + void setPolygon(const QPolygonF &); - void setRect( const QRectF& ); - void setPolygon( const QPolygonF& ); + void setShape(const QPainterPath &); + QPainterPath shape() const; - void setShape( const QPainterPath& ); - QPainterPath shape() const; + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); + void setPen(const QPen &); + QPen pen() const; - void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setPen( const QPen& ); - QPen pen() const; + void setBrush(const QBrush &); + QBrush brush() const; - void setBrush( const QBrush& ); - QBrush brush() const; + void setRenderTolerance(double); + double renderTolerance() const; - void setRenderTolerance( double ); - double renderTolerance() const; + virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - virtual QwtGraphic legendIcon( - int index, const QSizeF& ) const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - virtual int rtti() const QWT_OVERRIDE; +private: + void init(); - private: - void init(); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_spectrocurve.cpp b/libs/qwt/src/qwt_plot_spectrocurve.cpp index abf7af39..1cbe256a 100644 --- a/libs/qwt/src/qwt_plot_spectrocurve.cpp +++ b/libs/qwt/src/qwt_plot_spectrocurve.cpp @@ -17,51 +17,48 @@ class QwtPlotSpectroCurve::PrivateData { - public: - PrivateData() - : colorRange( 0.0, 1000.0 ) - , penWidth( 0.0 ) - , paintAttributes( QwtPlotSpectroCurve::ClipPoints ) - { - colorMap = new QwtLinearColorMap(); - } +public: + PrivateData() + : colorRange(0.0, 1000.0) + , penWidth(0.0) + , paintAttributes(QwtPlotSpectroCurve::ClipPoints) + { + colorMap = new QwtLinearColorMap(); + } - ~PrivateData() - { - delete colorMap; - } + ~PrivateData() { delete colorMap; } - QwtColorMap* colorMap; - QwtInterval colorRange; - QVector< QRgb > colorTable; - double penWidth; - QwtPlotSpectroCurve::PaintAttributes paintAttributes; + QwtColorMap *colorMap; + QwtInterval colorRange; + QVector colorTable; + double penWidth; + QwtPlotSpectroCurve::PaintAttributes paintAttributes; }; /*! Constructor \param title Title of the curve */ -QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotSpectroCurve::QwtPlotSpectroCurve(const QwtText &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } /*! Constructor \param title Title of the curve */ -QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QString& title ) - : QwtPlotSeriesItem( QwtText( title ) ) +QwtPlotSpectroCurve::QwtPlotSpectroCurve(const QString &title) + : QwtPlotSeriesItem(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotSpectroCurve::~QwtPlotSpectroCurve() { - delete m_data; + delete m_data; } /*! @@ -69,19 +66,19 @@ QwtPlotSpectroCurve::~QwtPlotSpectroCurve() */ void QwtPlotSpectroCurve::init() { - setItemAttribute( QwtPlotItem::Legend ); - setItemAttribute( QwtPlotItem::AutoScale ); + setItemAttribute(QwtPlotItem::Legend); + setItemAttribute(QwtPlotItem::AutoScale); - m_data = new PrivateData; - setData( new QwtPoint3DSeriesData() ); + m_data = new PrivateData; + setData(new QwtPoint3DSeriesData()); - setZ( 20.0 ); + setZ(20.0); } //! \return QwtPlotItem::Rtti_PlotSpectroCurve int QwtPlotSpectroCurve::rtti() const { - return QwtPlotItem::Rtti_PlotSpectroCurve; + return QwtPlotItem::Rtti_PlotSpectroCurve; } /*! @@ -91,30 +88,30 @@ int QwtPlotSpectroCurve::rtti() const \param on On/Off /sa PaintAttribute, testPaintAttribute() */ -void QwtPlotSpectroCurve::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPlotSpectroCurve::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! \return True, when attribute is enabled \sa PaintAttribute, setPaintAttribute() */ -bool QwtPlotSpectroCurve::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPlotSpectroCurve::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! Initialize data with an array of samples. \param samples Vector of points */ -void QwtPlotSpectroCurve::setSamples( const QVector< QwtPoint3D >& samples ) +void QwtPlotSpectroCurve::setSamples(const QVector &samples) { - setData( new QwtPoint3DSeriesData( samples ) ); + setData(new QwtPoint3DSeriesData(samples)); } /*! @@ -127,10 +124,9 @@ void QwtPlotSpectroCurve::setSamples( const QVector< QwtPoint3D >& samples ) \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotSpectroCurve::setSamples( - QwtSeriesData< QwtPoint3D >* data ) +void QwtPlotSpectroCurve::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -144,25 +140,25 @@ void QwtPlotSpectroCurve::setSamples( \sa colorMap(), setColorRange(), QwtColorMap::color(), QwtScaleWidget::setColorBarEnabled(), QwtScaleWidget::setColorMap() */ -void QwtPlotSpectroCurve::setColorMap( QwtColorMap* colorMap ) +void QwtPlotSpectroCurve::setColorMap(QwtColorMap *colorMap) { - if ( colorMap != m_data->colorMap ) - { - delete m_data->colorMap; - m_data->colorMap = colorMap; - } + if (colorMap != m_data->colorMap) + { + delete m_data->colorMap; + m_data->colorMap = colorMap; + } - legendChanged(); - itemChanged(); + legendChanged(); + itemChanged(); } /*! \return Color Map used for mapping the intensity values to colors \sa setColorMap(), setColorRange(), QwtColorMap::color() */ -const QwtColorMap* QwtPlotSpectroCurve::colorMap() const +const QwtColorMap *QwtPlotSpectroCurve::colorMap() const { - return m_data->colorMap; + return m_data->colorMap; } /*! @@ -173,24 +169,24 @@ const QwtColorMap* QwtPlotSpectroCurve::colorMap() const \sa colorRange(), setColorMap(), QwtColorMap::color() */ -void QwtPlotSpectroCurve::setColorRange( const QwtInterval& interval ) +void QwtPlotSpectroCurve::setColorRange(const QwtInterval &interval) { - if ( interval != m_data->colorRange ) - { - m_data->colorRange = interval; + if (interval != m_data->colorRange) + { + m_data->colorRange = interval; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! \return Value interval, that corresponds to the color map \sa setColorRange(), setColorMap(), QwtColorMap::color() */ -QwtInterval& QwtPlotSpectroCurve::colorRange() const +QwtInterval &QwtPlotSpectroCurve::colorRange() const { - return m_data->colorRange; + return m_data->colorRange; } /*! @@ -201,16 +197,16 @@ QwtInterval& QwtPlotSpectroCurve::colorRange() const */ void QwtPlotSpectroCurve::setPenWidth(double penWidth) { - if ( penWidth < 0.0 ) - penWidth = 0.0; + if (penWidth < 0.0) + penWidth = 0.0; - if ( m_data->penWidth != penWidth ) - { - m_data->penWidth = penWidth; + if (m_data->penWidth != penWidth) + { + m_data->penWidth = penWidth; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -219,7 +215,7 @@ void QwtPlotSpectroCurve::setPenWidth(double penWidth) */ double QwtPlotSpectroCurve::penWidth() const { - return m_data->penWidth; + return m_data->penWidth; } /*! @@ -235,23 +231,24 @@ double QwtPlotSpectroCurve::penWidth() const \sa drawDots() */ -void QwtPlotSpectroCurve::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotSpectroCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( !painter || dataSize() <= 0 ) - return; + if (!painter || dataSize() <= 0) + return; - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( from > to ) - return; + if (from > to) + return; - drawDots( painter, xMap, yMap, canvasRect, from, to ); + drawDots(painter, xMap, yMap, canvasRect, from, to); } /*! @@ -267,57 +264,57 @@ void QwtPlotSpectroCurve::drawSeries(QPainter* painter, \sa drawSeries() */ -void QwtPlotSpectroCurve::drawDots( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotSpectroCurve::drawDots(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( !m_data->colorRange.isValid() ) - return; + if (!m_data->colorRange.isValid()) + return; - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - const QwtColorMap::Format format = m_data->colorMap->format(); - if ( format == QwtColorMap::Indexed ) - m_data->colorTable = m_data->colorMap->colorTable256(); + const QwtColorMap::Format format = m_data->colorMap->format(); + if (format == QwtColorMap::Indexed) + m_data->colorTable = m_data->colorMap->colorTable256(); - const QwtSeriesData< QwtPoint3D >* series = data(); + const QwtSeriesData *series = data(); - for ( int i = from; i <= to; i++ ) + for (int i = from; i <= to; i++) + { + const QwtPoint3D sample = series->sample(i); + + double xi = xMap.transform(sample.x()); + double yi = yMap.transform(sample.y()); + if (doAlign) { - const QwtPoint3D sample = series->sample( i ); - - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( m_data->paintAttributes & QwtPlotSpectroCurve::ClipPoints ) - { - if ( !canvasRect.contains( xi, yi ) ) - continue; - } - - if ( format == QwtColorMap::RGB ) - { - const QRgb rgb = m_data->colorMap->rgb( - m_data->colorRange, sample.z() ); - - painter->setPen( QPen( QColor::fromRgba( rgb ), m_data->penWidth ) ); - } - else - { - const unsigned char index = m_data->colorMap->colorIndex( - 256, m_data->colorRange, sample.z() ); - - painter->setPen( QPen( QColor::fromRgba( m_data->colorTable[index] ), - m_data->penWidth ) ); - } - - QwtPainter::drawPoint( painter, QPointF( xi, yi ) ); + xi = qRound(xi); + yi = qRound(yi); } - m_data->colorTable.clear(); + if (m_data->paintAttributes & QwtPlotSpectroCurve::ClipPoints) + { + if (!canvasRect.contains(xi, yi)) + continue; + } + + if (format == QwtColorMap::RGB) + { + const QRgb rgb = m_data->colorMap->rgb(m_data->colorRange, sample.z()); + + painter->setPen(QPen(QColor::fromRgba(rgb), m_data->penWidth)); + } + else + { + const unsigned char index + = m_data->colorMap->colorIndex(256, m_data->colorRange, sample.z()); + + painter->setPen( + QPen(QColor::fromRgba(m_data->colorTable[index]), m_data->penWidth)); + } + + QwtPainter::drawPoint(painter, QPointF(xi, yi)); + } + + m_data->colorTable.clear(); } diff --git a/libs/qwt/src/qwt_plot_spectrocurve.h b/libs/qwt/src/qwt_plot_spectrocurve.h index 6dc19dca..c8e3a963 100644 --- a/libs/qwt/src/qwt_plot_spectrocurve.h +++ b/libs/qwt/src/qwt_plot_spectrocurve.h @@ -19,59 +19,57 @@ class QwtColorMap; \brief Curve that displays 3D points as dots, where the z coordinate is mapped to a color. */ -class QWT_EXPORT QwtPlotSpectroCurve - : public QwtPlotSeriesItem - , public QwtSeriesStore< QwtPoint3D > +class QWT_EXPORT QwtPlotSpectroCurve : public QwtPlotSeriesItem, + public QwtSeriesStore { - public: - //! Paint attributes - enum PaintAttribute - { - //! Clip points outside the canvas rectangle - ClipPoints = 1 - }; +public: + //! Paint attributes + enum PaintAttribute + { + //! Clip points outside the canvas rectangle + ClipPoints = 1 + }; - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - explicit QwtPlotSpectroCurve( const QString& title = QString() ); - explicit QwtPlotSpectroCurve( const QwtText& title ); + explicit QwtPlotSpectroCurve(const QString &title = QString()); + explicit QwtPlotSpectroCurve(const QwtText &title); - virtual ~QwtPlotSpectroCurve(); + virtual ~QwtPlotSpectroCurve(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - void setSamples( const QVector< QwtPoint3D >& ); - void setSamples( QwtSeriesData< QwtPoint3D >* ); + void setSamples(const QVector &); + void setSamples(QwtSeriesData *); + void setColorMap(QwtColorMap *); + const QwtColorMap *colorMap() const; - void setColorMap( QwtColorMap* ); - const QwtColorMap* colorMap() const; + void setColorRange(const QwtInterval &); + QwtInterval &colorRange() const; - void setColorRange( const QwtInterval& ); - QwtInterval& colorRange() const; + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + void setPenWidth(double); + double penWidth() const; - void setPenWidth( double ); - double penWidth() const; +protected: + virtual void drawDots(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; - protected: - virtual void drawDots( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; +private: + void init(); - private: - void init(); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectroCurve::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotSpectroCurve::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_spectrogram.cpp b/libs/qwt/src/qwt_plot_spectrogram.cpp index a677ad29..e0e19a12 100644 --- a/libs/qwt/src/qwt_plot_spectrogram.cpp +++ b/libs/qwt/src/qwt_plot_spectrogram.cpp @@ -24,74 +24,74 @@ #define DEBUG_RENDER 0 #if DEBUG_RENDER -#include +# include #endif #include -static inline bool qwtIsNaN( double d ) +static inline bool qwtIsNaN(double d) { - // qt_is_nan is private header and qIsNaN is not inlined - // so we need these code here too + // qt_is_nan is private header and qIsNaN is not inlined + // so we need these code here too - const uchar* ch = (const uchar*)&d; - if ( QSysInfo::ByteOrder == QSysInfo::BigEndian ) - { - return ( ch[0] & 0x7f ) == 0x7f && ch[1] > 0xf0; - } - else - { - return ( ch[7] & 0x7f ) == 0x7f && ch[6] > 0xf0; - } + const uchar *ch = (const uchar *)&d; + if (QSysInfo::ByteOrder == QSysInfo::BigEndian) + { + return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0; + } + else + { + return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0; + } } class QwtPlotSpectrogram::PrivateData { - public: - PrivateData() - : data( NULL ) - , colorTableSize( 0 ) - { - colorMap = new QwtLinearColorMap(); - displayMode = ImageMode; +public: + PrivateData() + : data(NULL) + , colorTableSize(0) + { + colorMap = new QwtLinearColorMap(); + displayMode = ImageMode; - conrecFlags = QwtRasterData::IgnoreAllVerticesOnLevel; + conrecFlags = QwtRasterData::IgnoreAllVerticesOnLevel; #if 0 conrecFlags |= QwtRasterData::IgnoreOutOfRange; #endif - } + } - ~PrivateData() + ~PrivateData() + { + delete data; + delete colorMap; + } + + void updateColorTable() + { + if (colorMap->format() == QwtColorMap::Indexed) { - delete data; - delete colorMap; + colorTable = colorMap->colorTable256(); } - - void updateColorTable() + else { - if ( colorMap->format() == QwtColorMap::Indexed ) - { - colorTable = colorMap->colorTable256(); - } - else - { - if ( colorTableSize == 0 ) - colorTable.clear(); - else - colorTable = colorMap->colorTable( colorTableSize ); - } + if (colorTableSize == 0) + colorTable.clear(); + else + colorTable = colorMap->colorTable(colorTableSize); } + } - QwtRasterData* data; - QwtColorMap* colorMap; - DisplayModes displayMode; + QwtRasterData *data; + QwtColorMap *colorMap; + DisplayModes displayMode; - QList< double > contourLevels; - QPen defaultContourPen; - QwtRasterData::ConrecFlags conrecFlags; + QList contourLevels; + QPen defaultContourPen; + QwtRasterData::ConrecFlags conrecFlags; - int colorTableSize; - QVector< QRgb > colorTable; + int colorTableSize; + QVector colorTable; }; /*! @@ -105,27 +105,27 @@ class QwtPlotSpectrogram::PrivateData \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ() */ -QwtPlotSpectrogram::QwtPlotSpectrogram( const QString& title ) - : QwtPlotRasterItem( title ) +QwtPlotSpectrogram::QwtPlotSpectrogram(const QString &title) + : QwtPlotRasterItem(title) { - m_data = new PrivateData(); + m_data = new PrivateData(); - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Legend, false ); + setItemAttribute(QwtPlotItem::AutoScale, true); + setItemAttribute(QwtPlotItem::Legend, false); - setZ( 8.0 ); + setZ(8.0); } //! Destructor QwtPlotSpectrogram::~QwtPlotSpectrogram() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PlotSpectrogram int QwtPlotSpectrogram::rtti() const { - return QwtPlotItem::Rtti_PlotSpectrogram; + return QwtPlotItem::Rtti_PlotSpectrogram; } /*! @@ -138,18 +138,18 @@ int QwtPlotSpectrogram::rtti() const \sa DisplayMode, displayMode() */ -void QwtPlotSpectrogram::setDisplayMode( DisplayMode mode, bool on ) +void QwtPlotSpectrogram::setDisplayMode(DisplayMode mode, bool on) { - if ( on != bool( mode & m_data->displayMode ) ) - { - if ( on ) - m_data->displayMode |= mode; - else - m_data->displayMode &= ~mode; - } + if (on != bool(mode & m_data->displayMode)) + { + if (on) + m_data->displayMode |= mode; + else + m_data->displayMode &= ~mode; + } - legendChanged(); - itemChanged(); + legendChanged(); + itemChanged(); } /*! @@ -158,9 +158,9 @@ void QwtPlotSpectrogram::setDisplayMode( DisplayMode mode, bool on ) \param mode Display mode \return true if mode is enabled */ -bool QwtPlotSpectrogram::testDisplayMode( DisplayMode mode ) const +bool QwtPlotSpectrogram::testDisplayMode(DisplayMode mode) const { - return ( m_data->displayMode & mode ); + return (m_data->displayMode & mode); } /*! @@ -174,32 +174,32 @@ bool QwtPlotSpectrogram::testDisplayMode( DisplayMode mode ) const \sa colorMap(), QwtScaleWidget::setColorBarEnabled(), QwtScaleWidget::setColorMap() */ -void QwtPlotSpectrogram::setColorMap( QwtColorMap* colorMap ) +void QwtPlotSpectrogram::setColorMap(QwtColorMap *colorMap) { - if ( colorMap == NULL ) - return; + if (colorMap == NULL) + return; - if ( colorMap != m_data->colorMap ) - { - delete m_data->colorMap; - m_data->colorMap = colorMap; - } + if (colorMap != m_data->colorMap) + { + delete m_data->colorMap; + m_data->colorMap = colorMap; + } - m_data->updateColorTable(); + m_data->updateColorTable(); - invalidateCache(); + invalidateCache(); - legendChanged(); - itemChanged(); + legendChanged(); + itemChanged(); } /*! \return Color Map used for mapping the intensity values to colors \sa setColorMap() */ -const QwtColorMap* QwtPlotSpectrogram::colorMap() const +const QwtColorMap *QwtPlotSpectrogram::colorMap() const { - return m_data->colorMap; + return m_data->colorMap; } /*! @@ -221,15 +221,15 @@ const QwtColorMap* QwtPlotSpectrogram::colorMap() const \sa QwtColorMap::colorTable(), colorTableSize() */ -void QwtPlotSpectrogram::setColorTableSize( int numColors ) +void QwtPlotSpectrogram::setColorTableSize(int numColors) { - numColors = qMax( numColors, 0 ); - if ( numColors != m_data->colorTableSize ) - { - m_data->colorTableSize = numColors; - m_data->updateColorTable(); - invalidateCache(); - } + numColors = qMax(numColors, 0); + if (numColors != m_data->colorTableSize) + { + m_data->colorTableSize = numColors; + m_data->updateColorTable(); + invalidateCache(); + } } /*! \return Size of the color table, 0 means not using a color table @@ -237,7 +237,7 @@ void QwtPlotSpectrogram::setColorTableSize( int numColors ) */ int QwtPlotSpectrogram::colorTableSize() const { - return m_data->colorTableSize; + return m_data->colorTableSize; } /*! @@ -253,10 +253,10 @@ int QwtPlotSpectrogram::colorTableSize() const \sa pen(), brush() */ -void QwtPlotSpectrogram::setDefaultContourPen( - const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotSpectrogram::setDefaultContourPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setDefaultContourPen( QPen( color, width, style ) ); + setDefaultContourPen(QPen(color, width, style)); } /*! @@ -269,15 +269,15 @@ void QwtPlotSpectrogram::setDefaultContourPen( \sa defaultContourPen(), contourPen() */ -void QwtPlotSpectrogram::setDefaultContourPen( const QPen& pen ) +void QwtPlotSpectrogram::setDefaultContourPen(const QPen &pen) { - if ( pen != m_data->defaultContourPen ) - { - m_data->defaultContourPen = pen; + if (pen != m_data->defaultContourPen) + { + m_data->defaultContourPen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -286,7 +286,7 @@ void QwtPlotSpectrogram::setDefaultContourPen( const QPen& pen ) */ QPen QwtPlotSpectrogram::defaultContourPen() const { - return m_data->defaultContourPen; + return m_data->defaultContourPen; } /*! @@ -300,15 +300,15 @@ QPen QwtPlotSpectrogram::defaultContourPen() const \sa setDefaultContourPen(), setColorMap(), setContourLevels() */ -QPen QwtPlotSpectrogram::contourPen( double level ) const +QPen QwtPlotSpectrogram::contourPen(double level) const { - if ( m_data->data == NULL || m_data->colorMap == NULL ) - return QPen(); + if (m_data->data == NULL || m_data->colorMap == NULL) + return QPen(); - const QwtInterval intensityRange = m_data->data->interval(Qt::ZAxis); - const QColor c( m_data->colorMap->rgb( intensityRange, level ) ); + const QwtInterval intensityRange = m_data->data->interval(Qt::ZAxis); + const QColor c(m_data->colorMap->rgb(intensityRange, level)); - return QPen( c ); + return QPen(c); } /*! @@ -321,18 +321,17 @@ QPen QwtPlotSpectrogram::contourPen( double level ) const \sa testConrecFlag(), renderContourLines(), QwtRasterData::contourLines() */ -void QwtPlotSpectrogram::setConrecFlag( - QwtRasterData::ConrecFlag flag, bool on ) +void QwtPlotSpectrogram::setConrecFlag(QwtRasterData::ConrecFlag flag, bool on) { - if ( bool( m_data->conrecFlags & flag ) == on ) - return; + if (bool(m_data->conrecFlags & flag) == on) + return; - if ( on ) - m_data->conrecFlags |= flag; - else - m_data->conrecFlags &= ~flag; + if (on) + m_data->conrecFlags |= flag; + else + m_data->conrecFlags &= ~flag; - itemChanged(); + itemChanged(); } /*! @@ -347,10 +346,9 @@ void QwtPlotSpectrogram::setConrecFlag( \sa setConrecClag(), renderContourLines(), QwtRasterData::contourLines() */ -bool QwtPlotSpectrogram::testConrecFlag( - QwtRasterData::ConrecFlag flag ) const +bool QwtPlotSpectrogram::testConrecFlag(QwtRasterData::ConrecFlag flag) const { - return m_data->conrecFlags & flag; + return m_data->conrecFlags & flag; } /*! @@ -362,13 +360,13 @@ bool QwtPlotSpectrogram::testConrecFlag( \note contourLevels returns the same levels but sorted. */ -void QwtPlotSpectrogram::setContourLevels( const QList< double >& levels ) +void QwtPlotSpectrogram::setContourLevels(const QList &levels) { - m_data->contourLevels = levels; - std::sort( m_data->contourLevels.begin(), m_data->contourLevels.end() ); + m_data->contourLevels = levels; + std::sort(m_data->contourLevels.begin(), m_data->contourLevels.end()); - legendChanged(); - itemChanged(); + legendChanged(); + itemChanged(); } /*! @@ -379,9 +377,9 @@ void QwtPlotSpectrogram::setContourLevels( const QList< double >& levels ) \sa contourLevels(), renderContourLines(), QwtRasterData::contourLines() */ -QList< double > QwtPlotSpectrogram::contourLevels() const +QList QwtPlotSpectrogram::contourLevels() const { - return m_data->contourLevels; + return m_data->contourLevels; } /*! @@ -390,34 +388,34 @@ QList< double > QwtPlotSpectrogram::contourLevels() const \param data Spectrogram Data \sa data() */ -void QwtPlotSpectrogram::setData( QwtRasterData* data ) +void QwtPlotSpectrogram::setData(QwtRasterData *data) { - if ( data != m_data->data ) - { - delete m_data->data; - m_data->data = data; + if (data != m_data->data) + { + delete m_data->data; + m_data->data = data; - invalidateCache(); - itemChanged(); - } + invalidateCache(); + itemChanged(); + } } /*! \return Spectrogram data \sa setData() */ -const QwtRasterData* QwtPlotSpectrogram::data() const +const QwtRasterData *QwtPlotSpectrogram::data() const { - return m_data->data; + return m_data->data; } /*! \return Spectrogram data \sa setData() */ -QwtRasterData* QwtPlotSpectrogram::data() +QwtRasterData *QwtPlotSpectrogram::data() { - return m_data->data; + return m_data->data; } /*! @@ -431,10 +429,10 @@ QwtRasterData* QwtPlotSpectrogram::data() */ QwtInterval QwtPlotSpectrogram::interval(Qt::Axis axis) const { - if ( m_data->data == NULL ) - return QwtInterval(); + if (m_data->data == NULL) + return QwtInterval(); - return m_data->data->interval( axis ); + return m_data->data->interval(axis); } /*! @@ -453,12 +451,12 @@ QwtInterval QwtPlotSpectrogram::interval(Qt::Axis axis) const \sa QwtPlotRasterItem::pixelHint(), QwtRasterData::pixelHint(), render(), renderImage() */ -QRectF QwtPlotSpectrogram::pixelHint( const QRectF& area ) const +QRectF QwtPlotSpectrogram::pixelHint(const QRectF &area) const { - if ( m_data->data == NULL ) - return QRectF(); + if (m_data->data == NULL) + return QRectF(); - return m_data->data->pixelHint( area ); + return m_data->data->pixelHint(area); } /*! @@ -477,85 +475,86 @@ QRectF QwtPlotSpectrogram::pixelHint( const QRectF& area ) const \sa QwtRasterData::value(), QwtColorMap::rgb(), QwtColorMap::colorIndex() */ -QImage QwtPlotSpectrogram::renderImage( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& area, const QSize& imageSize ) const +QImage QwtPlotSpectrogram::renderImage(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &area, + const QSize &imageSize) const { - if ( imageSize.isEmpty() || m_data->data == NULL - || m_data->colorMap == NULL ) - { - return QImage(); - } + if (imageSize.isEmpty() || m_data->data == NULL || m_data->colorMap == NULL) + { + return QImage(); + } - const QwtInterval intensityRange = m_data->data->interval( Qt::ZAxis ); - if ( !intensityRange.isValid() ) - return QImage(); + const QwtInterval intensityRange = m_data->data->interval(Qt::ZAxis); + if (!intensityRange.isValid()) + return QImage(); - const QImage::Format format = ( m_data->colorMap->format() == QwtColorMap::RGB ) - ? QImage::Format_ARGB32 : QImage::Format_Indexed8; + const QImage::Format format = (m_data->colorMap->format() == QwtColorMap::RGB) + ? QImage::Format_ARGB32 + : QImage::Format_Indexed8; - QImage image( imageSize, format ); + QImage image(imageSize, format); - if ( m_data->colorMap->format() == QwtColorMap::Indexed ) - image.setColorTable( m_data->colorMap->colorTable256() ); + if (m_data->colorMap->format() == QwtColorMap::Indexed) + image.setColorTable(m_data->colorMap->colorTable256()); - m_data->data->initRaster( area, image.size() ); + m_data->data->initRaster(area, image.size()); #if DEBUG_RENDER - QElapsedTimer time; - time.start(); + QElapsedTimer time; + time.start(); #endif -#if !defined( QT_NO_QFUTURE ) - uint numThreads = renderThreadCount(); +#if !defined(QT_NO_QFUTURE) + uint numThreads = renderThreadCount(); - if ( numThreads <= 0 ) - numThreads = QThread::idealThreadCount(); + if (numThreads <= 0) + numThreads = QThread::idealThreadCount(); - if ( numThreads <= 0 ) - numThreads = 1; + if (numThreads <= 0) + numThreads = 1; - const int numRows = imageSize.height() / numThreads; + const int numRows = imageSize.height() / numThreads; - QVector< QFuture< void > > futures; - futures.reserve( numThreads - 1 ); + QVector> futures; + futures.reserve(numThreads - 1); - for ( uint i = 0; i < numThreads; i++ ) + for (uint i = 0; i < numThreads; i++) + { + QRect tile(0, i * numRows, image.width(), numRows); + if (i == numThreads - 1) { - QRect tile( 0, i * numRows, image.width(), numRows ); - if ( i == numThreads - 1 ) - { - tile.setHeight( image.height() - i * numRows ); - renderTile( xMap, yMap, tile, &image ); - } - else - { - futures += QtConcurrent::run( -#if QT_VERSION >= 0x060000 - &QwtPlotSpectrogram::renderTile, this, -#else - this, &QwtPlotSpectrogram::renderTile, -#endif - xMap, yMap, tile, &image ); - } + tile.setHeight(image.height() - i * numRows); + renderTile(xMap, yMap, tile, &image); } + else + { + futures += QtConcurrent::run( +# if QT_VERSION >= 0x060000 + &QwtPlotSpectrogram::renderTile, this, +# else + this, &QwtPlotSpectrogram::renderTile, +# endif + xMap, yMap, tile, &image); + } + } - for ( int i = 0; i < futures.size(); i++ ) - futures[i].waitForFinished(); + for (int i = 0; i < futures.size(); i++) + futures[i].waitForFinished(); #else - const QRect tile( 0, 0, image.width(), image.height() ); - renderTile( xMap, yMap, tile, &image ); + const QRect tile(0, 0, image.width(), image.height()); + renderTile(xMap, yMap, tile, &image); #endif #if DEBUG_RENDER - const qint64 elapsed = time.elapsed(); - qDebug() << "renderImage" << imageSize << elapsed; + const qint64 elapsed = time.elapsed(); + qDebug() << "renderImage" << imageSize << elapsed; #endif - m_data->data->discardRaster(); + m_data->data->discardRaster(); - return image; + return image; } /*! @@ -569,78 +568,78 @@ QImage QwtPlotSpectrogram::renderImage( \param tile Geometry of the tile in image coordinates \param image Image to be rendered */ -void QwtPlotSpectrogram::renderTile( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRect& tile, QImage* image ) const +void QwtPlotSpectrogram::renderTile(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRect &tile, + QImage *image) const { - const QwtInterval range = m_data->data->interval( Qt::ZAxis ); - if ( range.width() <= 0.0 ) - return; + const QwtInterval range = m_data->data->interval(Qt::ZAxis); + if (range.width() <= 0.0) + return; - const bool hasGaps = !m_data->data->testAttribute( QwtRasterData::WithoutGaps ); + const bool hasGaps = !m_data->data->testAttribute(QwtRasterData::WithoutGaps); - if ( m_data->colorMap->format() == QwtColorMap::RGB ) + if (m_data->colorMap->format() == QwtColorMap::RGB) + { + const int numColors = m_data->colorTable.size(); + const QRgb *rgbTable = m_data->colorTable.constData(); + const QwtColorMap *colorMap = m_data->colorMap; + + for (int y = tile.top(); y <= tile.bottom(); y++) { - const int numColors = m_data->colorTable.size(); - const QRgb* rgbTable = m_data->colorTable.constData(); - const QwtColorMap* colorMap = m_data->colorMap; + const double ty = yMap.invTransform(y); - for ( int y = tile.top(); y <= tile.bottom(); y++ ) + QRgb *line = reinterpret_cast(image->scanLine(y)); + line += tile.left(); + + for (int x = tile.left(); x <= tile.right(); x++) + { + const double tx = xMap.invTransform(x); + + const double value = m_data->data->value(tx, ty); + + if (hasGaps && qwtIsNaN(value)) { - const double ty = yMap.invTransform( y ); - - QRgb* line = reinterpret_cast< QRgb* >( image->scanLine( y ) ); - line += tile.left(); - - for ( int x = tile.left(); x <= tile.right(); x++ ) - { - const double tx = xMap.invTransform( x ); - - const double value = m_data->data->value( tx, ty ); - - if ( hasGaps && qwtIsNaN( value ) ) - { - *line++ = 0u; - } - else if ( numColors == 0 ) - { - *line++ = colorMap->rgb( range, value ); - } - else - { - const uint index = colorMap->colorIndex( numColors, range, value ); - *line++ = rgbTable[index]; - } - } + *line++ = 0u; } + else if (numColors == 0) + { + *line++ = colorMap->rgb(range, value); + } + else + { + const uint index = colorMap->colorIndex(numColors, range, value); + *line++ = rgbTable[index]; + } + } } - else if ( m_data->colorMap->format() == QwtColorMap::Indexed ) + } + else if (m_data->colorMap->format() == QwtColorMap::Indexed) + { + for (int y = tile.top(); y <= tile.bottom(); y++) { - for ( int y = tile.top(); y <= tile.bottom(); y++ ) + const double ty = yMap.invTransform(y); + + unsigned char *line = image->scanLine(y); + line += tile.left(); + + for (int x = tile.left(); x <= tile.right(); x++) + { + const double tx = xMap.invTransform(x); + + const double value = m_data->data->value(tx, ty); + + if (hasGaps && qwtIsNaN(value)) { - const double ty = yMap.invTransform( y ); - - unsigned char* line = image->scanLine( y ); - line += tile.left(); - - for ( int x = tile.left(); x <= tile.right(); x++ ) - { - const double tx = xMap.invTransform( x ); - - const double value = m_data->data->value( tx, ty ); - - if ( hasGaps && qwtIsNaN( value ) ) - { - *line++ = 0; - } - else - { - const uint index = m_data->colorMap->colorIndex( 256, range, value ); - *line++ = static_cast< unsigned char >( index ); - } - } + *line++ = 0; } + else + { + const uint index = m_data->colorMap->colorIndex(256, range, value); + *line++ = static_cast(index); + } + } } + } } /*! @@ -660,20 +659,20 @@ void QwtPlotSpectrogram::renderTile( \sa drawContourLines(), QwtRasterData::contourLines() */ -QSize QwtPlotSpectrogram::contourRasterSize( - const QRectF& area, const QRect& rect ) const +QSize QwtPlotSpectrogram::contourRasterSize(const QRectF &area, + const QRect &rect) const { - QSize raster = rect.size() / 2; + QSize raster = rect.size() / 2; - const QRectF pixelRect = pixelHint( area ); - if ( !pixelRect.isEmpty() ) - { - const QSize res( qwtCeil( rect.width() / pixelRect.width() ), - qwtCeil( rect.height() / pixelRect.height() ) ); - raster = raster.boundedTo( res ); - } + const QRectF pixelRect = pixelHint(area); + if (!pixelRect.isEmpty()) + { + const QSize res(qwtCeil(rect.width() / pixelRect.width()), + qwtCeil(rect.height() / pixelRect.height())); + raster = raster.boundedTo(res); + } - return raster; + return raster; } /*! @@ -686,14 +685,15 @@ QSize QwtPlotSpectrogram::contourRasterSize( \sa contourLevels(), setConrecFlag(), QwtRasterData::contourLines() */ -QwtRasterData::ContourLines QwtPlotSpectrogram::renderContourLines( - const QRectF& rect, const QSize& raster ) const +QwtRasterData::ContourLines +QwtPlotSpectrogram::renderContourLines(const QRectF &rect, + const QSize &raster) const { - if ( m_data->data == NULL ) - return QwtRasterData::ContourLines(); + if (m_data->data == NULL) + return QwtRasterData::ContourLines(); - return m_data->data->contourLines( rect, raster, - m_data->contourLevels, m_data->conrecFlags ); + return m_data->data->contourLines(rect, raster, m_data->contourLevels, + m_data->conrecFlags); } /*! @@ -706,38 +706,38 @@ QwtRasterData::ContourLines QwtPlotSpectrogram::renderContourLines( \sa renderContourLines(), defaultContourPen(), contourPen() */ -void QwtPlotSpectrogram::drawContourLines( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtRasterData::ContourLines& contourLines ) const +void QwtPlotSpectrogram::drawContourLines( + QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtRasterData::ContourLines &contourLines) const { - if ( m_data->data == NULL ) - return; + if (m_data->data == NULL) + return; - const int numLevels = m_data->contourLevels.size(); - for ( int l = 0; l < numLevels; l++ ) + const int numLevels = m_data->contourLevels.size(); + for (int l = 0; l < numLevels; l++) + { + const double level = m_data->contourLevels[l]; + + QPen pen = defaultContourPen(); + if (pen.style() == Qt::NoPen) + pen = contourPen(level); + + if (pen.style() == Qt::NoPen) + continue; + + painter->setPen(pen); + + const QPolygonF &lines = contourLines[level]; + for (int i = 0; i < lines.size(); i += 2) { - const double level = m_data->contourLevels[l]; + const QPointF p1(xMap.transform(lines[i].x()), + yMap.transform(lines[i].y())); + const QPointF p2(xMap.transform(lines[i + 1].x()), + yMap.transform(lines[i + 1].y())); - QPen pen = defaultContourPen(); - if ( pen.style() == Qt::NoPen ) - pen = contourPen( level ); - - if ( pen.style() == Qt::NoPen ) - continue; - - painter->setPen( pen ); - - const QPolygonF& lines = contourLines[level]; - for ( int i = 0; i < lines.size(); i += 2 ) - { - const QPointF p1( xMap.transform( lines[i].x() ), - yMap.transform( lines[i].y() ) ); - const QPointF p2( xMap.transform( lines[i + 1].x() ), - yMap.transform( lines[i + 1].y() ) ); - - QwtPainter::drawLine( painter, p1, p2 ); - } + QwtPainter::drawLine(painter, p1, p2); } + } } /*! @@ -751,40 +751,41 @@ void QwtPlotSpectrogram::drawContourLines( QPainter* painter, \sa setDisplayMode(), renderImage(), QwtPlotRasterItem::draw(), drawContourLines() */ -void QwtPlotSpectrogram::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotSpectrogram::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - if ( m_data->displayMode & ImageMode ) - QwtPlotRasterItem::draw( painter, xMap, yMap, canvasRect ); + if (m_data->displayMode & ImageMode) + QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect); - if ( m_data->displayMode & ContourMode ) + if (m_data->displayMode & ContourMode) + { + // Add some pixels at the borders + const int margin = 2; + QRectF rasterRect(canvasRect.x() - margin, canvasRect.y() - margin, + canvasRect.width() + 2 * margin, + canvasRect.height() + 2 * margin); + + QRectF area = QwtScaleMap::invTransform(xMap, yMap, rasterRect); + + const QRectF br = boundingRect(); + if (br.isValid()) { - // Add some pixels at the borders - const int margin = 2; - QRectF rasterRect( canvasRect.x() - margin, canvasRect.y() - margin, - canvasRect.width() + 2 * margin, canvasRect.height() + 2 * margin ); + area &= br; + if (area.isEmpty()) + return; - QRectF area = QwtScaleMap::invTransform( xMap, yMap, rasterRect ); - - const QRectF br = boundingRect(); - if ( br.isValid() ) - { - area &= br; - if ( area.isEmpty() ) - return; - - rasterRect = QwtScaleMap::transform( xMap, yMap, area ); - } - - QSize raster = contourRasterSize( area, rasterRect.toRect() ); - raster = raster.boundedTo( rasterRect.toRect().size() ); - if ( raster.isValid() ) - { - const QwtRasterData::ContourLines lines = - renderContourLines( area, raster ); - - drawContourLines( painter, xMap, yMap, lines ); - } + rasterRect = QwtScaleMap::transform(xMap, yMap, area); } + + QSize raster = contourRasterSize(area, rasterRect.toRect()); + raster = raster.boundedTo(rasterRect.toRect().size()); + if (raster.isValid()) + { + const QwtRasterData::ContourLines lines + = renderContourLines(area, raster); + + drawContourLines(painter, xMap, yMap, lines); + } + } } diff --git a/libs/qwt/src/qwt_plot_spectrogram.h b/libs/qwt/src/qwt_plot_spectrogram.h index cf07de09..507ec8fd 100644 --- a/libs/qwt/src/qwt_plot_spectrogram.h +++ b/libs/qwt/src/qwt_plot_spectrogram.h @@ -15,7 +15,8 @@ #include "qwt_plot_rasteritem.h" class QwtColorMap; -template< typename T > class QList; +template +class QList; /*! \brief A plot item, which displays a spectrogram @@ -35,84 +36,83 @@ template< typename T > class QList; class QWT_EXPORT QwtPlotSpectrogram : public QwtPlotRasterItem { - public: - /*! - The display mode controls how the raster data will be represented. - \sa setDisplayMode(), testDisplayMode() - */ +public: + /*! + The display mode controls how the raster data will be represented. + \sa setDisplayMode(), testDisplayMode() + */ - enum DisplayMode - { - //! The values are mapped to colors using a color map. - ImageMode = 0x01, + enum DisplayMode + { + //! The values are mapped to colors using a color map. + ImageMode = 0x01, - //! The data is displayed using contour lines - ContourMode = 0x02 - }; + //! The data is displayed using contour lines + ContourMode = 0x02 + }; - Q_DECLARE_FLAGS( DisplayModes, DisplayMode ) + Q_DECLARE_FLAGS(DisplayModes, DisplayMode) - explicit QwtPlotSpectrogram( const QString& title = QString() ); - virtual ~QwtPlotSpectrogram(); + explicit QwtPlotSpectrogram(const QString &title = QString()); + virtual ~QwtPlotSpectrogram(); - void setDisplayMode( DisplayMode, bool on = true ); - bool testDisplayMode( DisplayMode ) const; + void setDisplayMode(DisplayMode, bool on = true); + bool testDisplayMode(DisplayMode) const; - void setData( QwtRasterData* data ); - const QwtRasterData* data() const; - QwtRasterData* data(); + void setData(QwtRasterData *data); + const QwtRasterData *data() const; + QwtRasterData *data(); - void setColorMap( QwtColorMap* ); - const QwtColorMap* colorMap() const; + void setColorMap(QwtColorMap *); + const QwtColorMap *colorMap() const; - void setColorTableSize( int numColors ); - int colorTableSize() const; + void setColorTableSize(int numColors); + int colorTableSize() const; - virtual QwtInterval interval( Qt::Axis ) const QWT_OVERRIDE; - virtual QRectF pixelHint( const QRectF& ) const QWT_OVERRIDE; + virtual QwtInterval interval(Qt::Axis) const QWT_OVERRIDE; + virtual QRectF pixelHint(const QRectF &) const QWT_OVERRIDE; - void setDefaultContourPen( const QColor&, - qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setDefaultContourPen( const QPen& ); - QPen defaultContourPen() const; + void setDefaultContourPen(const QColor &, qreal width = 0.0, + Qt::PenStyle = Qt::SolidLine); + void setDefaultContourPen(const QPen &); + QPen defaultContourPen() const; - virtual QPen contourPen( double level ) const; + virtual QPen contourPen(double level) const; - void setConrecFlag( QwtRasterData::ConrecFlag, bool on ); - bool testConrecFlag( QwtRasterData::ConrecFlag ) const; + void setConrecFlag(QwtRasterData::ConrecFlag, bool on); + bool testConrecFlag(QwtRasterData::ConrecFlag) const; - void setContourLevels( const QList< double >& ); - QList< double > contourLevels() const; + void setContourLevels(const QList &); + QList contourLevels() const; - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - virtual void draw( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const QWT_OVERRIDE; - protected: - virtual QImage renderImage( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& area, const QSize& imageSize ) const QWT_OVERRIDE; +protected: + virtual QImage renderImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &area, + const QSize &imageSize) const QWT_OVERRIDE; - virtual QSize contourRasterSize( - const QRectF&, const QRect& ) const; + virtual QSize contourRasterSize(const QRectF &, const QRect &) const; - virtual QwtRasterData::ContourLines renderContourLines( - const QRectF& rect, const QSize& raster ) const; + virtual QwtRasterData::ContourLines + renderContourLines(const QRectF &rect, const QSize &raster) const; - virtual void drawContourLines( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtRasterData::ContourLines& ) const; + virtual void drawContourLines(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtRasterData::ContourLines &) const; - void renderTile( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRect& tile, QImage* ) const; + void renderTile(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRect &tile, QImage *) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotSpectrogram::DisplayModes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotSpectrogram::DisplayModes) #endif diff --git a/libs/qwt/src/qwt_plot_svgitem.cpp b/libs/qwt/src/qwt_plot_svgitem.cpp index af72547f..67b87bb2 100644 --- a/libs/qwt/src/qwt_plot_svgitem.cpp +++ b/libs/qwt/src/qwt_plot_svgitem.cpp @@ -17,8 +17,8 @@ \brief Constructor \param title Title */ -QwtPlotSvgItem::QwtPlotSvgItem( const QString& title ) - : QwtPlotGraphicItem( QwtText( title ) ) +QwtPlotSvgItem::QwtPlotSvgItem(const QString &title) + : QwtPlotGraphicItem(QwtText(title)) { } @@ -26,15 +26,13 @@ QwtPlotSvgItem::QwtPlotSvgItem( const QString& title ) \brief Constructor \param title Title */ -QwtPlotSvgItem::QwtPlotSvgItem( const QwtText& title ) - : QwtPlotGraphicItem( title ) +QwtPlotSvgItem::QwtPlotSvgItem(const QwtText &title) + : QwtPlotGraphicItem(title) { } //! Destructor -QwtPlotSvgItem::~QwtPlotSvgItem() -{ -} +QwtPlotSvgItem::~QwtPlotSvgItem() {} /*! Load a SVG file @@ -44,23 +42,22 @@ QwtPlotSvgItem::~QwtPlotSvgItem() \return true, if the SVG file could be loaded */ -bool QwtPlotSvgItem::loadFile( const QRectF& rect, - const QString& fileName ) +bool QwtPlotSvgItem::loadFile(const QRectF &rect, const QString &fileName) { - QwtGraphic graphic; + QwtGraphic graphic; - QSvgRenderer renderer; + QSvgRenderer renderer; - const bool ok = renderer.load( fileName ); - if ( ok ) - { - QPainter p( &graphic ); - renderer.render( &p ); - } + const bool ok = renderer.load(fileName); + if (ok) + { + QPainter p(&graphic); + renderer.render(&p); + } - setGraphic( rect, graphic ); + setGraphic(rect, graphic); - return ok; + return ok; } /*! @@ -71,21 +68,20 @@ bool QwtPlotSvgItem::loadFile( const QRectF& rect, \return true, if the SVG data could be loaded */ -bool QwtPlotSvgItem::loadData( const QRectF& rect, - const QByteArray& data ) +bool QwtPlotSvgItem::loadData(const QRectF &rect, const QByteArray &data) { - QwtGraphic graphic; + QwtGraphic graphic; - QSvgRenderer renderer; + QSvgRenderer renderer; - const bool ok = renderer.load( data ); - if ( ok ) - { - QPainter p( &graphic ); - renderer.render( &p ); - } + const bool ok = renderer.load(data); + if (ok) + { + QPainter p(&graphic); + renderer.render(&p); + } - setGraphic( rect, graphic ); + setGraphic(rect, graphic); - return ok; + return ok; } diff --git a/libs/qwt/src/qwt_plot_svgitem.h b/libs/qwt/src/qwt_plot_svgitem.h index 398cc3e6..de5961b8 100644 --- a/libs/qwt/src/qwt_plot_svgitem.h +++ b/libs/qwt/src/qwt_plot_svgitem.h @@ -27,13 +27,13 @@ class QByteArray; class QWT_EXPORT QwtPlotSvgItem : public QwtPlotGraphicItem { - public: - explicit QwtPlotSvgItem( const QString& title = QString() ); - explicit QwtPlotSvgItem( const QwtText& title ); - virtual ~QwtPlotSvgItem(); +public: + explicit QwtPlotSvgItem(const QString &title = QString()); + explicit QwtPlotSvgItem(const QwtText &title); + virtual ~QwtPlotSvgItem(); - bool loadFile( const QRectF&, const QString& fileName ); - bool loadData( const QRectF&, const QByteArray& ); + bool loadFile(const QRectF &, const QString &fileName); + bool loadData(const QRectF &, const QByteArray &); }; #endif diff --git a/libs/qwt/src/qwt_plot_textlabel.cpp b/libs/qwt/src/qwt_plot_textlabel.cpp index f2d93022..c063b758 100644 --- a/libs/qwt/src/qwt_plot_textlabel.cpp +++ b/libs/qwt/src/qwt_plot_textlabel.cpp @@ -16,52 +16,52 @@ #include #include -static QRect qwtItemRect( int renderFlags, - const QRectF& rect, const QSizeF& itemSize ) +static QRect qwtItemRect(int renderFlags, const QRectF &rect, + const QSizeF &itemSize) { - int x; - if ( renderFlags & Qt::AlignLeft ) - { - x = rect.left(); - } - else if ( renderFlags & Qt::AlignRight ) - { - x = rect.right() - itemSize.width(); - } - else - { - x = rect.center().x() - 0.5 * itemSize.width(); - } + int x; + if (renderFlags & Qt::AlignLeft) + { + x = rect.left(); + } + else if (renderFlags & Qt::AlignRight) + { + x = rect.right() - itemSize.width(); + } + else + { + x = rect.center().x() - 0.5 * itemSize.width(); + } - int y; - if ( renderFlags & Qt::AlignTop ) - { - y = rect.top(); - } - else if ( renderFlags & Qt::AlignBottom ) - { - y = rect.bottom() - itemSize.height(); - } - else - { - y = rect.center().y() - 0.5 * itemSize.height(); - } + int y; + if (renderFlags & Qt::AlignTop) + { + y = rect.top(); + } + else if (renderFlags & Qt::AlignBottom) + { + y = rect.bottom() - itemSize.height(); + } + else + { + y = rect.center().y() - 0.5 * itemSize.height(); + } - return QRect( x, y, itemSize.width(), itemSize.height() ); + return QRect(x, y, itemSize.width(), itemSize.height()); } class QwtPlotTextLabel::PrivateData { - public: - PrivateData() - : margin( 5 ) - { - } +public: + PrivateData() + : margin(5) + { + } - QwtText text; - int margin; + QwtText text; + int margin; - QPixmap pixmap; + QPixmap pixmap; }; /*! @@ -80,26 +80,26 @@ class QwtPlotTextLabel::PrivateData */ QwtPlotTextLabel::QwtPlotTextLabel() - : QwtPlotItem( QwtText( "Label" ) ) + : QwtPlotItem(QwtText("Label")) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemAttribute( QwtPlotItem::AutoScale, false ); - setItemAttribute( QwtPlotItem::Legend, false ); + setItemAttribute(QwtPlotItem::AutoScale, false); + setItemAttribute(QwtPlotItem::Legend, false); - setZ( 150 ); + setZ(150); } //! Destructor QwtPlotTextLabel::~QwtPlotTextLabel() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PlotTextLabel int QwtPlotTextLabel::rtti() const { - return QwtPlotItem::Rtti_PlotTextLabel; + return QwtPlotItem::Rtti_PlotTextLabel; } /*! @@ -112,15 +112,15 @@ int QwtPlotTextLabel::rtti() const \sa text(), QwtText::renderFlags() */ -void QwtPlotTextLabel::setText( const QwtText& text ) +void QwtPlotTextLabel::setText(const QwtText &text) { - if ( m_data->text != text ) - { - m_data->text = text; + if (m_data->text != text) + { + m_data->text = text; - invalidateCache(); - itemChanged(); - } + invalidateCache(); + itemChanged(); + } } /*! @@ -129,7 +129,7 @@ void QwtPlotTextLabel::setText( const QwtText& text ) */ QwtText QwtPlotTextLabel::text() const { - return m_data->text; + return m_data->text; } /*! @@ -143,14 +143,14 @@ QwtText QwtPlotTextLabel::text() const \sa margin(), textRect() */ -void QwtPlotTextLabel::setMargin( int margin ) +void QwtPlotTextLabel::setMargin(int margin) { - margin = qMax( margin, 0 ); - if ( m_data->margin != margin ) - { - m_data->margin = margin; - itemChanged(); - } + margin = qMax(margin, 0); + if (m_data->margin != margin) + { + m_data->margin = margin; + itemChanged(); + } } /*! @@ -159,7 +159,7 @@ void QwtPlotTextLabel::setMargin( int margin ) */ int QwtPlotTextLabel::margin() const { - return m_data->margin; + return m_data->margin; } /*! @@ -173,80 +173,79 @@ int QwtPlotTextLabel::margin() const \sa textRect() */ -void QwtPlotTextLabel::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotTextLabel::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - Q_UNUSED( xMap ); - Q_UNUSED( yMap ); + Q_UNUSED(xMap); + Q_UNUSED(yMap); - const int m = m_data->margin; + const int m = m_data->margin; - const QRectF rect = textRect( canvasRect.adjusted( m, m, -m, -m ), - m_data->text.textSize( painter->font() ) ); + const QRectF rect = textRect(canvasRect.adjusted(m, m, -m, -m), + m_data->text.textSize(painter->font())); - bool doCache = QwtPainter::roundingAlignment( painter ); - if ( doCache ) + bool doCache = QwtPainter::roundingAlignment(painter); + if (doCache) + { + switch (painter->paintEngine()->type()) { - switch( painter->paintEngine()->type() ) - { - case QPaintEngine::Picture: - case QPaintEngine::User: // usually QwtGraphic - { - // don't use a cache for record/replay devices - doCache = false; - break; - } - default:; - } + case QPaintEngine::Picture: + case QPaintEngine::User: // usually QwtGraphic + { + // don't use a cache for record/replay devices + doCache = false; + break; + } + default:; } + } - if ( doCache ) - { - // when the paint device is aligning it is not one - // where scalability matters ( PDF, SVG ). - // As rendering a text label is an expensive operation - // we use a cache. + if (doCache) + { + // when the paint device is aligning it is not one + // where scalability matters ( PDF, SVG ). + // As rendering a text label is an expensive operation + // we use a cache. - int pw = 0; - if ( m_data->text.borderPen().style() != Qt::NoPen ) - pw = qMax( m_data->text.borderPen().width(), 1 ); + int pw = 0; + if (m_data->text.borderPen().style() != Qt::NoPen) + pw = qMax(m_data->text.borderPen().width(), 1); - QRect pixmapRect; - pixmapRect.setLeft( qwtFloor( rect.left() ) - pw ); - pixmapRect.setTop( qwtFloor( rect.top() ) - pw ); - pixmapRect.setRight( qwtCeil( rect.right() ) + pw ); - pixmapRect.setBottom( qwtCeil( rect.bottom() ) + pw ); + QRect pixmapRect; + pixmapRect.setLeft(qwtFloor(rect.left()) - pw); + pixmapRect.setTop(qwtFloor(rect.top()) - pw); + pixmapRect.setRight(qwtCeil(rect.right()) + pw); + pixmapRect.setBottom(qwtCeil(rect.bottom()) + pw); #if QT_VERSION >= 0x050000 - const qreal pixelRatio = QwtPainter::devicePixelRatio( painter->device() ); - const QSize scaledSize = pixmapRect.size() * pixelRatio; + const qreal pixelRatio = QwtPainter::devicePixelRatio(painter->device()); + const QSize scaledSize = pixmapRect.size() * pixelRatio; #else - const QSize scaledSize = pixmapRect.size(); + const QSize scaledSize = pixmapRect.size(); #endif - if ( m_data->pixmap.isNull() || - ( scaledSize != m_data->pixmap.size() ) ) - { - m_data->pixmap = QPixmap( scaledSize ); -#if QT_VERSION >= 0x050000 - m_data->pixmap.setDevicePixelRatio( pixelRatio ); -#endif - m_data->pixmap.fill( Qt::transparent ); - - const QRect r( pw, pw, - pixmapRect.width() - 2 * pw, pixmapRect.height() - 2 * pw ); - - QPainter pmPainter( &m_data->pixmap ); - m_data->text.draw( &pmPainter, r ); - } - - painter->drawPixmap( pixmapRect, m_data->pixmap ); - } - else + if (m_data->pixmap.isNull() || (scaledSize != m_data->pixmap.size())) { - m_data->text.draw( painter, rect ); + m_data->pixmap = QPixmap(scaledSize); +#if QT_VERSION >= 0x050000 + m_data->pixmap.setDevicePixelRatio(pixelRatio); +#endif + m_data->pixmap.fill(Qt::transparent); + + const QRect r(pw, pw, pixmapRect.width() - 2 * pw, + pixmapRect.height() - 2 * pw); + + QPainter pmPainter(&m_data->pixmap); + m_data->text.draw(&pmPainter, r); } + + painter->drawPixmap(pixmapRect, m_data->pixmap); + } + else + { + m_data->text.draw(painter, rect); + } } /*! @@ -260,14 +259,14 @@ void QwtPlotTextLabel::draw( QPainter* painter, \sa setMargin(), QwtText::renderFlags(), QwtText::textSize() */ -QRectF QwtPlotTextLabel::textRect( - const QRectF& rect, const QSizeF& textSize ) const +QRectF QwtPlotTextLabel::textRect(const QRectF &rect, + const QSizeF &textSize) const { - return qwtItemRect( m_data->text.renderFlags(), rect, textSize ); + return qwtItemRect(m_data->text.renderFlags(), rect, textSize); } //! Invalidate all internal cache void QwtPlotTextLabel::invalidateCache() { - m_data->pixmap = QPixmap(); + m_data->pixmap = QPixmap(); } diff --git a/libs/qwt/src/qwt_plot_textlabel.h b/libs/qwt/src/qwt_plot_textlabel.h index f5a6f834..50002b2a 100644 --- a/libs/qwt/src/qwt_plot_textlabel.h +++ b/libs/qwt/src/qwt_plot_textlabel.h @@ -46,30 +46,29 @@ class QwtText; class QWT_EXPORT QwtPlotTextLabel : public QwtPlotItem { - public: - QwtPlotTextLabel(); - virtual ~QwtPlotTextLabel(); +public: + QwtPlotTextLabel(); + virtual ~QwtPlotTextLabel(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setText( const QwtText& ); - QwtText text() const; + void setText(const QwtText &); + QwtText text() const; - void setMargin( int margin ); - int margin() const; + void setMargin(int margin); + int margin() const; - virtual QRectF textRect( const QRectF&, const QSizeF& ) const; + virtual QRectF textRect(const QRectF &, const QSizeF &) const; - protected: - virtual void draw( QPainter*, - const QwtScaleMap&, const QwtScaleMap&, - const QRectF&) const QWT_OVERRIDE; +protected: + virtual void draw(QPainter *, const QwtScaleMap &, const QwtScaleMap &, + const QRectF &) const QWT_OVERRIDE; - void invalidateCache(); + void invalidateCache(); - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_tradingcurve.cpp b/libs/qwt/src/qwt_plot_tradingcurve.cpp index 9a1e4bfa..1e1dd01f 100644 --- a/libs/qwt/src/qwt_plot_tradingcurve.cpp +++ b/libs/qwt/src/qwt_plot_tradingcurve.cpp @@ -16,85 +16,86 @@ #include -static inline bool qwtIsSampleInside( const QwtOHLCSample& sample, - double tMin, double tMax, double vMin, double vMax ) +static inline bool qwtIsSampleInside(const QwtOHLCSample &sample, double tMin, + double tMax, double vMin, double vMax) { - const double t = sample.time; - const QwtInterval interval = sample.boundingInterval(); + const double t = sample.time; + const QwtInterval interval = sample.boundingInterval(); - const bool isOffScreen = ( t < tMin ) || ( t > tMax ) - || ( interval.maxValue() < vMin ) || ( interval.minValue() > vMax ); + const bool isOffScreen = (t < tMin) || (t > tMax) + || (interval.maxValue() < vMin) + || (interval.minValue() > vMax); - return !isOffScreen; + return !isOffScreen; } class QwtPlotTradingCurve::PrivateData { - public: - PrivateData() - : symbolStyle( QwtPlotTradingCurve::CandleStick ) - , symbolExtent( 0.6 ) - , minSymbolWidth( 2.0 ) - , maxSymbolWidth( -1.0 ) - , paintAttributes( QwtPlotTradingCurve::ClipSymbols ) - { - symbolBrush[0] = QBrush( Qt::white ); - symbolBrush[1] = QBrush( Qt::black ); - } +public: + PrivateData() + : symbolStyle(QwtPlotTradingCurve::CandleStick) + , symbolExtent(0.6) + , minSymbolWidth(2.0) + , maxSymbolWidth(-1.0) + , paintAttributes(QwtPlotTradingCurve::ClipSymbols) + { + symbolBrush[0] = QBrush(Qt::white); + symbolBrush[1] = QBrush(Qt::black); + } - QwtPlotTradingCurve::SymbolStyle symbolStyle; - double symbolExtent; - double minSymbolWidth; - double maxSymbolWidth; + QwtPlotTradingCurve::SymbolStyle symbolStyle; + double symbolExtent; + double minSymbolWidth; + double maxSymbolWidth; - QPen symbolPen; - QBrush symbolBrush[2]; // Increasing/Decreasing + QPen symbolPen; + QBrush symbolBrush[2]; // Increasing/Decreasing - QwtPlotTradingCurve::PaintAttributes paintAttributes; + QwtPlotTradingCurve::PaintAttributes paintAttributes; }; /*! Constructor \param title Title of the curve */ -QwtPlotTradingCurve::QwtPlotTradingCurve( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotTradingCurve::QwtPlotTradingCurve(const QwtText &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } /*! Constructor \param title Title of the curve */ -QwtPlotTradingCurve::QwtPlotTradingCurve( const QString& title ) - : QwtPlotSeriesItem( QwtText( title ) ) +QwtPlotTradingCurve::QwtPlotTradingCurve(const QString &title) + : QwtPlotSeriesItem(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotTradingCurve::~QwtPlotTradingCurve() { - delete m_data; + delete m_data; } //! Initialize internal members void QwtPlotTradingCurve::init() { - setItemAttribute( QwtPlotItem::Legend, true ); - setItemAttribute( QwtPlotItem::AutoScale, true ); + setItemAttribute(QwtPlotItem::Legend, true); + setItemAttribute(QwtPlotItem::AutoScale, true); - m_data = new PrivateData; - setData( new QwtTradingChartData() ); + m_data = new PrivateData; + setData(new QwtTradingChartData()); - setZ( 19.0 ); + setZ(19.0); } //! \return QwtPlotItem::Rtti_PlotTradingCurve int QwtPlotTradingCurve::rtti() const { - return QwtPlotTradingCurve::Rtti_PlotTradingCurve; + return QwtPlotTradingCurve::Rtti_PlotTradingCurve; } /*! @@ -104,23 +105,21 @@ int QwtPlotTradingCurve::rtti() const \param on On/Off \sa testPaintAttribute() */ -void QwtPlotTradingCurve::setPaintAttribute( - PaintAttribute attribute, bool on ) +void QwtPlotTradingCurve::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! \return True, when attribute is enabled \sa PaintAttribute, setPaintAttribute() */ -bool QwtPlotTradingCurve::testPaintAttribute( - PaintAttribute attribute ) const +bool QwtPlotTradingCurve::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! @@ -129,10 +128,9 @@ bool QwtPlotTradingCurve::testPaintAttribute( \sa QwtPlotSeriesItem::setData() */ -void QwtPlotTradingCurve::setSamples( - const QVector< QwtOHLCSample >& samples ) +void QwtPlotTradingCurve::setSamples(const QVector &samples) { - setData( new QwtTradingChartData( samples ) ); + setData(new QwtTradingChartData(samples)); } /*! @@ -145,10 +143,9 @@ void QwtPlotTradingCurve::setSamples( \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotTradingCurve::setSamples( - QwtSeriesData< QwtOHLCSample >* data ) +void QwtPlotTradingCurve::setSamples(QwtSeriesData *data) { - setData( data ); + setData(data); } /*! @@ -159,15 +156,15 @@ void QwtPlotTradingCurve::setSamples( \sa symbolStyle(), setSymbolExtent(), setSymbolPen(), setSymbolBrush() */ -void QwtPlotTradingCurve::setSymbolStyle( SymbolStyle style ) +void QwtPlotTradingCurve::setSymbolStyle(SymbolStyle style) { - if ( style != m_data->symbolStyle ) - { - m_data->symbolStyle = style; + if (style != m_data->symbolStyle) + { + m_data->symbolStyle = style; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -176,7 +173,7 @@ void QwtPlotTradingCurve::setSymbolStyle( SymbolStyle style ) */ QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle() const { - return m_data->symbolStyle; + return m_data->symbolStyle; } /*! @@ -192,10 +189,10 @@ QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle() const \sa pen(), brush() */ -void QwtPlotTradingCurve::setSymbolPen( - const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotTradingCurve::setSymbolPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setSymbolPen( QPen( color, width, style ) ); + setSymbolPen(QPen(color, width, style)); } /*! @@ -206,15 +203,15 @@ void QwtPlotTradingCurve::setSymbolPen( \sa symbolPen(), setSymbolBrush() */ -void QwtPlotTradingCurve::setSymbolPen( const QPen& pen ) +void QwtPlotTradingCurve::setSymbolPen(const QPen &pen) { - if ( pen != m_data->symbolPen ) - { - m_data->symbolPen = pen; + if (pen != m_data->symbolPen) + { + m_data->symbolPen = pen; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -223,7 +220,7 @@ void QwtPlotTradingCurve::setSymbolPen( const QPen& pen ) */ QPen QwtPlotTradingCurve::symbolPen() const { - return m_data->symbolPen; + return m_data->symbolPen; } /*! @@ -235,21 +232,21 @@ QPen QwtPlotTradingCurve::symbolPen() const \sa symbolBrush(), setSymbolPen() */ -void QwtPlotTradingCurve::setSymbolBrush( - Direction direction, const QBrush& brush ) +void QwtPlotTradingCurve::setSymbolBrush(Direction direction, + const QBrush &brush) { - // silencing -Wtautological-constant-out-of-range-compare - const int index = static_cast< int >( direction ); - if ( index < 0 || index >= 2 ) - return; + // silencing -Wtautological-constant-out-of-range-compare + const int index = static_cast(direction); + if (index < 0 || index >= 2) + return; - if ( brush != m_data->symbolBrush[ index ] ) - { - m_data->symbolBrush[ index ] = brush; + if (brush != m_data->symbolBrush[index]) + { + m_data->symbolBrush[index] = brush; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -259,13 +256,13 @@ void QwtPlotTradingCurve::setSymbolBrush( \sa setSymbolPen(), symbolBrush() */ -QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const +QBrush QwtPlotTradingCurve::symbolBrush(Direction direction) const { - const int index = static_cast< int >( direction ); - if ( index < 0 || index >= 2 ) - return QBrush(); + const int index = static_cast(direction); + if (index < 0 || index >= 2) + return QBrush(); - return m_data->symbolBrush[ index ]; + return m_data->symbolBrush[index]; } /*! @@ -281,16 +278,16 @@ QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const \sa symbolExtent(), scaledSymbolWidth(), setMinSymbolWidth(), setMaxSymbolWidth() */ -void QwtPlotTradingCurve::setSymbolExtent( double extent ) +void QwtPlotTradingCurve::setSymbolExtent(double extent) { - extent = qwtMaxF( 0.0, extent ); - if ( extent != m_data->symbolExtent ) - { - m_data->symbolExtent = extent; + extent = qwtMaxF(0.0, extent); + if (extent != m_data->symbolExtent) + { + m_data->symbolExtent = extent; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -300,7 +297,7 @@ void QwtPlotTradingCurve::setSymbolExtent( double extent ) */ double QwtPlotTradingCurve::symbolExtent() const { - return m_data->symbolExtent; + return m_data->symbolExtent; } /*! @@ -309,16 +306,16 @@ double QwtPlotTradingCurve::symbolExtent() const \param width Width in paint device coordinates \sa minSymbolWidth(), setMaxSymbolWidth(), setSymbolExtent() */ -void QwtPlotTradingCurve::setMinSymbolWidth( double width ) +void QwtPlotTradingCurve::setMinSymbolWidth(double width) { - width = qwtMaxF( width, 0.0 ); - if ( width != m_data->minSymbolWidth ) - { - m_data->minSymbolWidth = width; + width = qwtMaxF(width, 0.0); + if (width != m_data->minSymbolWidth) + { + m_data->minSymbolWidth = width; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -327,7 +324,7 @@ void QwtPlotTradingCurve::setMinSymbolWidth( double width ) */ double QwtPlotTradingCurve::minSymbolWidth() const { - return m_data->minSymbolWidth; + return m_data->minSymbolWidth; } /*! @@ -338,15 +335,15 @@ double QwtPlotTradingCurve::minSymbolWidth() const \param width Width in paint device coordinates \sa maxSymbolWidth(), setMinSymbolWidth(), setSymbolExtent() */ -void QwtPlotTradingCurve::setMaxSymbolWidth( double width ) +void QwtPlotTradingCurve::setMaxSymbolWidth(double width) { - if ( width != m_data->maxSymbolWidth ) - { - m_data->maxSymbolWidth = width; + if (width != m_data->maxSymbolWidth) + { + m_data->maxSymbolWidth = width; - legendChanged(); - itemChanged(); - } + legendChanged(); + itemChanged(); + } } /*! @@ -355,7 +352,7 @@ void QwtPlotTradingCurve::setMaxSymbolWidth( double width ) */ double QwtPlotTradingCurve::maxSymbolWidth() const { - return m_data->maxSymbolWidth; + return m_data->maxSymbolWidth; } /*! @@ -364,11 +361,11 @@ double QwtPlotTradingCurve::maxSymbolWidth() const */ QRectF QwtPlotTradingCurve::boundingRect() const { - QRectF rect = QwtPlotSeriesItem::boundingRect(); - if ( orientation() == Qt::Vertical ) - rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); + QRectF rect = QwtPlotSeriesItem::boundingRect(); + if (orientation() == Qt::Vertical) + rect.setRect(rect.y(), rect.x(), rect.height(), rect.width()); - return rect; + return rect; } /*! @@ -384,25 +381,26 @@ QRectF QwtPlotTradingCurve::boundingRect() const \sa drawSymbols() */ -void QwtPlotTradingCurve::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotTradingCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( from > to ) - return; + if (from > to) + return; - painter->save(); + painter->save(); - if ( m_data->symbolStyle != QwtPlotTradingCurve::NoSymbol ) - drawSymbols( painter, xMap, yMap, canvasRect, from, to ); + if (m_data->symbolStyle != QwtPlotTradingCurve::NoSymbol) + drawSymbols(painter, xMap, yMap, canvasRect, from, to); - painter->restore(); + painter->restore(); } /*! @@ -417,104 +415,101 @@ void QwtPlotTradingCurve::drawSeries(QPainter* painter, \sa drawSeries() */ -void QwtPlotTradingCurve::drawSymbols( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotTradingCurve::drawSymbols(QPainter *painter, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - const QRectF tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect ); + const QRectF tr = QwtScaleMap::invTransform(xMap, yMap, canvasRect); - const QwtScaleMap* timeMap, * valueMap; - double tMin, tMax, vMin, vMax; + const QwtScaleMap *timeMap, *valueMap; + double tMin, tMax, vMin, vMax; - const Qt::Orientation orient = orientation(); - if ( orient == Qt::Vertical ) + const Qt::Orientation orient = orientation(); + if (orient == Qt::Vertical) + { + timeMap = &xMap; + valueMap = &yMap; + + tMin = tr.left(); + tMax = tr.right(); + vMin = tr.top(); + vMax = tr.bottom(); + } + else + { + timeMap = &yMap; + valueMap = &xMap; + + vMin = tr.left(); + vMax = tr.right(); + tMin = tr.top(); + tMax = tr.bottom(); + } + + const bool inverted = timeMap->isInverting(); + const bool doClip = m_data->paintAttributes & ClipSymbols; + const bool doAlign = QwtPainter::roundingAlignment(painter); + + double symbolWidth = scaledSymbolWidth(xMap, yMap, canvasRect); + if (doAlign) + symbolWidth = std::floor(0.5 * symbolWidth) * 2.0; + + QPen pen = m_data->symbolPen; + pen.setCapStyle(Qt::FlatCap); + + painter->setPen(pen); + + for (int i = from; i <= to; i++) + { + const QwtOHLCSample s = sample(i); + + if (!doClip || qwtIsSampleInside(s, tMin, tMax, vMin, vMax)) { - timeMap = &xMap; - valueMap = &yMap; + QwtOHLCSample translatedSample; - tMin = tr.left(); - tMax = tr.right(); - vMin = tr.top(); - vMax = tr.bottom(); - } - else - { - timeMap = &yMap; - valueMap = &xMap; + translatedSample.time = timeMap->transform(s.time); + translatedSample.open = valueMap->transform(s.open); + translatedSample.high = valueMap->transform(s.high); + translatedSample.low = valueMap->transform(s.low); + translatedSample.close = valueMap->transform(s.close); - vMin = tr.left(); - vMax = tr.right(); - tMin = tr.top(); - tMax = tr.bottom(); - } + const int brushIndex = (s.open < s.close) + ? QwtPlotTradingCurve::Increasing + : QwtPlotTradingCurve::Decreasing; - const bool inverted = timeMap->isInverting(); - const bool doClip = m_data->paintAttributes & ClipSymbols; - const bool doAlign = QwtPainter::roundingAlignment( painter ); + if (doAlign) + { + translatedSample.time = qRound(translatedSample.time); + translatedSample.open = qRound(translatedSample.open); + translatedSample.high = qRound(translatedSample.high); + translatedSample.low = qRound(translatedSample.low); + translatedSample.close = qRound(translatedSample.close); + } - double symbolWidth = scaledSymbolWidth( xMap, yMap, canvasRect ); - if ( doAlign ) - symbolWidth = std::floor( 0.5 * symbolWidth ) * 2.0; - - QPen pen = m_data->symbolPen; - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - - for ( int i = from; i <= to; i++ ) - { - const QwtOHLCSample s = sample( i ); - - if ( !doClip || qwtIsSampleInside( s, tMin, tMax, vMin, vMax ) ) - { - QwtOHLCSample translatedSample; - - translatedSample.time = timeMap->transform( s.time ); - translatedSample.open = valueMap->transform( s.open ); - translatedSample.high = valueMap->transform( s.high ); - translatedSample.low = valueMap->transform( s.low ); - translatedSample.close = valueMap->transform( s.close ); - - const int brushIndex = ( s.open < s.close ) - ? QwtPlotTradingCurve::Increasing - : QwtPlotTradingCurve::Decreasing; - - if ( doAlign ) - { - translatedSample.time = qRound( translatedSample.time ); - translatedSample.open = qRound( translatedSample.open ); - translatedSample.high = qRound( translatedSample.high ); - translatedSample.low = qRound( translatedSample.low ); - translatedSample.close = qRound( translatedSample.close ); - } - - switch( m_data->symbolStyle ) - { - case Bar: - { - drawBar( painter, translatedSample, - orient, inverted, symbolWidth ); - break; - } - case CandleStick: - { - painter->setBrush( m_data->symbolBrush[ brushIndex ] ); - drawCandleStick( painter, translatedSample, - orient, symbolWidth ); - break; - } - default: - { - if ( m_data->symbolStyle >= UserSymbol ) - { - painter->setBrush( m_data->symbolBrush[ brushIndex ] ); - drawUserSymbol( painter, m_data->symbolStyle, - translatedSample, orient, inverted, symbolWidth ); - } - } - } + switch (m_data->symbolStyle) + { + case Bar: { + drawBar(painter, translatedSample, orient, inverted, symbolWidth); + break; } + case CandleStick: { + painter->setBrush(m_data->symbolBrush[brushIndex]); + drawCandleStick(painter, translatedSample, orient, symbolWidth); + break; + } + default: { + if (m_data->symbolStyle >= UserSymbol) + { + painter->setBrush(m_data->symbolBrush[brushIndex]); + drawUserSymbol(painter, m_data->symbolStyle, translatedSample, + orient, inverted, symbolWidth); + } + } + } } + } } /*! @@ -531,16 +526,16 @@ void QwtPlotTradingCurve::drawSymbols( QPainter* painter, in the opposite direction as QPainter coordinates. \param symbolWidth Width of the symbol in paint device coordinates */ -void QwtPlotTradingCurve::drawUserSymbol( QPainter* painter, - SymbolStyle symbolStyle, const QwtOHLCSample& sample, - Qt::Orientation orientation, bool inverted, double symbolWidth ) const +void QwtPlotTradingCurve::drawUserSymbol( + QPainter *painter, SymbolStyle symbolStyle, const QwtOHLCSample &sample, + Qt::Orientation orientation, bool inverted, double symbolWidth) const { - Q_UNUSED( painter ) - Q_UNUSED( symbolStyle ) - Q_UNUSED( orientation ) - Q_UNUSED( inverted ) - Q_UNUSED( symbolWidth ) - Q_UNUSED( sample ) + Q_UNUSED(painter) + Q_UNUSED(symbolStyle) + Q_UNUSED(orientation) + Q_UNUSED(inverted) + Q_UNUSED(symbolWidth) + Q_UNUSED(sample) } /*! @@ -559,33 +554,34 @@ void QwtPlotTradingCurve::drawUserSymbol( QPainter* painter, \sa Bar */ -void QwtPlotTradingCurve::drawBar( QPainter* painter, - const QwtOHLCSample& sample, Qt::Orientation orientation, - bool inverted, double width ) const +void QwtPlotTradingCurve::drawBar(QPainter *painter, + const QwtOHLCSample &sample, + Qt::Orientation orientation, bool inverted, + double width) const { - double w2 = 0.5 * width; - if ( inverted ) - w2 *= -1; + double w2 = 0.5 * width; + if (inverted) + w2 *= -1; - if ( orientation == Qt::Vertical ) - { - QwtPainter::drawLine( painter, - sample.time, sample.low, sample.time, sample.high ); + if (orientation == Qt::Vertical) + { + QwtPainter::drawLine(painter, sample.time, sample.low, sample.time, + sample.high); - QwtPainter::drawLine( painter, - sample.time - w2, sample.open, sample.time, sample.open ); - QwtPainter::drawLine( painter, - sample.time + w2, sample.close, sample.time, sample.close ); - } - else - { - QwtPainter::drawLine( painter, sample.low, sample.time, - sample.high, sample.time ); - QwtPainter::drawLine( painter, - sample.open, sample.time - w2, sample.open, sample.time ); - QwtPainter::drawLine( painter, - sample.close, sample.time + w2, sample.close, sample.time ); - } + QwtPainter::drawLine(painter, sample.time - w2, sample.open, sample.time, + sample.open); + QwtPainter::drawLine(painter, sample.time + w2, sample.close, sample.time, + sample.close); + } + else + { + QwtPainter::drawLine(painter, sample.low, sample.time, sample.high, + sample.time); + QwtPainter::drawLine(painter, sample.open, sample.time - w2, sample.open, + sample.time); + QwtPainter::drawLine(painter, sample.close, sample.time + w2, sample.close, + sample.time); + } } /*! @@ -598,36 +594,37 @@ void QwtPlotTradingCurve::drawBar( QPainter* painter, \sa CandleStick */ -void QwtPlotTradingCurve::drawCandleStick( QPainter* painter, - const QwtOHLCSample& sample, Qt::Orientation orientation, - double width ) const +void QwtPlotTradingCurve::drawCandleStick(QPainter *painter, + const QwtOHLCSample &sample, + Qt::Orientation orientation, + double width) const { - const double t = sample.time; - const double v1 = qwtMinF( sample.low, sample.high ); - const double v2 = qwtMinF( sample.open, sample.close ); - const double v3 = qwtMaxF( sample.low, sample.high ); - const double v4 = qwtMaxF( sample.open, sample.close ); + const double t = sample.time; + const double v1 = qwtMinF(sample.low, sample.high); + const double v2 = qwtMinF(sample.open, sample.close); + const double v3 = qwtMaxF(sample.low, sample.high); + const double v4 = qwtMaxF(sample.open, sample.close); - if ( orientation == Qt::Vertical ) - { - QwtPainter::drawLine( painter, t, v1, t, v2 ); - QwtPainter::drawLine( painter, t, v3, t, v4 ); + if (orientation == Qt::Vertical) + { + QwtPainter::drawLine(painter, t, v1, t, v2); + QwtPainter::drawLine(painter, t, v3, t, v4); - QRectF rect( t - 0.5 * width, sample.open, - width, sample.close - sample.open ); + QRectF rect(t - 0.5 * width, sample.open, width, + sample.close - sample.open); - QwtPainter::drawRect( painter, rect ); - } - else - { - QwtPainter::drawLine( painter, v1, t, v2, t ); - QwtPainter::drawLine( painter, v3, t, v4, t ); + QwtPainter::drawRect(painter, rect); + } + else + { + QwtPainter::drawLine(painter, v1, t, v2, t); + QwtPainter::drawLine(painter, v3, t, v4, t); - const QRectF rect( sample.open, t - 0.5 * width, - sample.close - sample.open, width ); + const QRectF rect(sample.open, t - 0.5 * width, sample.close - sample.open, + width); - QwtPainter::drawRect( painter, rect ); - } + QwtPainter::drawRect(painter, rect); + } } /*! @@ -639,11 +636,10 @@ void QwtPlotTradingCurve::drawCandleStick( QPainter* painter, \sa setLegendIconSize(), legendData() */ -QwtGraphic QwtPlotTradingCurve::legendIcon( int index, - const QSizeF& size ) const +QwtGraphic QwtPlotTradingCurve::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); - return defaultIcon( m_data->symbolPen.color(), size ); + Q_UNUSED(index); + return defaultIcon(m_data->symbolPen.color(), size); } /*! @@ -661,28 +657,27 @@ QwtGraphic QwtPlotTradingCurve::legendIcon( int index, \sa symbolExtent(), minSymbolWidth(), maxSymbolWidth() */ -double QwtPlotTradingCurve::scaledSymbolWidth( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +double QwtPlotTradingCurve::scaledSymbolWidth(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - Q_UNUSED( canvasRect ); + Q_UNUSED(canvasRect); - if ( m_data->maxSymbolWidth > 0.0 && - m_data->minSymbolWidth >= m_data->maxSymbolWidth ) - { - return m_data->minSymbolWidth; - } + if (m_data->maxSymbolWidth > 0.0 + && m_data->minSymbolWidth >= m_data->maxSymbolWidth) + { + return m_data->minSymbolWidth; + } - const QwtScaleMap* map = - ( orientation() == Qt::Vertical ) ? &xMap : &yMap; + const QwtScaleMap *map = (orientation() == Qt::Vertical) ? &xMap : &yMap; - const double pos = map->transform( map->s1() + m_data->symbolExtent ); + const double pos = map->transform(map->s1() + m_data->symbolExtent); - double width = qAbs( pos - map->p1() ); + double width = qAbs(pos - map->p1()); - width = qwtMaxF( width, m_data->minSymbolWidth ); - if ( m_data->maxSymbolWidth > 0.0 ) - width = qwtMinF( width, m_data->maxSymbolWidth ); + width = qwtMaxF(width, m_data->minSymbolWidth); + if (m_data->maxSymbolWidth > 0.0) + width = qwtMinF(width, m_data->maxSymbolWidth); - return width; + return width; } diff --git a/libs/qwt/src/qwt_plot_tradingcurve.h b/libs/qwt/src/qwt_plot_tradingcurve.h index 8da366a4..518aed1c 100644 --- a/libs/qwt/src/qwt_plot_tradingcurve.h +++ b/libs/qwt/src/qwt_plot_tradingcurve.h @@ -34,140 +34,138 @@ When setting the minimum and maximum to the same value, the width of the symbol is fixed. */ -class QWT_EXPORT QwtPlotTradingCurve - : public QwtPlotSeriesItem - , public QwtSeriesStore< QwtOHLCSample > +class QWT_EXPORT QwtPlotTradingCurve : public QwtPlotSeriesItem, + public QwtSeriesStore { - public: - /*! - \brief Symbol styles. +public: + /*! + \brief Symbol styles. - The default setting is QwtPlotSeriesItem::CandleStick. - \sa setSymbolStyle(), symbolStyle() - */ - enum SymbolStyle - { - //! Nothing is displayed - NoSymbol = -1, - - /*! - A line on the chart shows the price range (the highest and lowest - prices) over one unit of time, e.g. one day or one hour. - Tick marks project from each side of the line indicating the - opening and closing price. - */ - Bar, - - /*! - The range between opening/closing price are displayed as - a filled box. The fill brush depends on the direction of the - price movement. The box is connected to the highest/lowest - values by lines. - */ - CandleStick, - - /*! - SymbolTypes >= UserSymbol are displayed by drawUserSymbol(), - that needs to be overloaded and implemented in derived - curve classes. - - \sa drawUserSymbol() - */ - UserSymbol = 100 - }; + The default setting is QwtPlotSeriesItem::CandleStick. + \sa setSymbolStyle(), symbolStyle() + */ + enum SymbolStyle + { + //! Nothing is displayed + NoSymbol = -1, /*! - \brief Direction of a price movement + A line on the chart shows the price range (the highest and lowest + prices) over one unit of time, e.g. one day or one hour. + Tick marks project from each side of the line indicating the + opening and closing price. */ - enum Direction - { - //! The closing price is higher than the opening price - Increasing, - - //! The closing price is lower than the opening price - Decreasing - }; + Bar, /*! - Attributes to modify the drawing algorithm. - \sa setPaintAttribute(), testPaintAttribute() + The range between opening/closing price are displayed as + a filled box. The fill brush depends on the direction of the + price movement. The box is connected to the highest/lowest + values by lines. */ - enum PaintAttribute - { - //! Check if a symbol is on the plot canvas before painting it. - ClipSymbols = 0x01 - }; + CandleStick, - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + /*! + SymbolTypes >= UserSymbol are displayed by drawUserSymbol(), + that needs to be overloaded and implemented in derived + curve classes. - explicit QwtPlotTradingCurve( const QString& title = QString() ); - explicit QwtPlotTradingCurve( const QwtText& title ); + \sa drawUserSymbol() + */ + UserSymbol = 100 + }; - virtual ~QwtPlotTradingCurve(); + /*! + \brief Direction of a price movement + */ + enum Direction + { + //! The closing price is higher than the opening price + Increasing, - virtual int rtti() const QWT_OVERRIDE; + //! The closing price is lower than the opening price + Decreasing + }; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + /*! + Attributes to modify the drawing algorithm. + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { + //! Check if a symbol is on the plot canvas before painting it. + ClipSymbols = 0x01 + }; - void setSamples( const QVector< QwtOHLCSample >& ); - void setSamples( QwtSeriesData< QwtOHLCSample >* ); + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - void setSymbolStyle( SymbolStyle style ); - SymbolStyle symbolStyle() const; + explicit QwtPlotTradingCurve(const QString &title = QString()); + explicit QwtPlotTradingCurve(const QwtText &title); - void setSymbolPen( const QColor&, - qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setSymbolPen( const QPen& ); - QPen symbolPen() const; + virtual ~QwtPlotTradingCurve(); - void setSymbolBrush( Direction, const QBrush& ); - QBrush symbolBrush( Direction ) const; + virtual int rtti() const QWT_OVERRIDE; - void setSymbolExtent( double ); - double symbolExtent() const; + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - void setMinSymbolWidth( double ); - double minSymbolWidth() const; + void setSamples(const QVector &); + void setSamples(QwtSeriesData *); - void setMaxSymbolWidth( double ); - double maxSymbolWidth() const; + void setSymbolStyle(SymbolStyle style); + SymbolStyle symbolStyle() const; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + void setSymbolPen(const QColor &, qreal width = 0.0, + Qt::PenStyle = Qt::SolidLine); + void setSymbolPen(const QPen &); + QPen symbolPen() const; - virtual QRectF boundingRect() const QWT_OVERRIDE; + void setSymbolBrush(Direction, const QBrush &); + QBrush symbolBrush(Direction) const; - virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE; + void setSymbolExtent(double); + double symbolExtent() const; - protected: + void setMinSymbolWidth(double); + double minSymbolWidth() const; - void init(); + void setMaxSymbolWidth(double); + double maxSymbolWidth() const; - virtual void drawSymbols( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - virtual void drawUserSymbol( QPainter*, - SymbolStyle, const QwtOHLCSample&, - Qt::Orientation, bool inverted, double symbolWidth ) const; + virtual QRectF boundingRect() const QWT_OVERRIDE; - void drawBar( QPainter*, const QwtOHLCSample&, - Qt::Orientation, bool inverted, double width ) const; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - void drawCandleStick( QPainter*, const QwtOHLCSample&, - Qt::Orientation, double width ) const; +protected: + void init(); - virtual double scaledSymbolWidth( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const; + virtual void drawSymbols(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; - private: - class PrivateData; - PrivateData* m_data; + virtual void drawUserSymbol(QPainter *, SymbolStyle, const QwtOHLCSample &, + Qt::Orientation, bool inverted, + double symbolWidth) const; + + void drawBar(QPainter *, const QwtOHLCSample &, Qt::Orientation, + bool inverted, double width) const; + + void drawCandleStick(QPainter *, const QwtOHLCSample &, Qt::Orientation, + double width) const; + + virtual double scaledSymbolWidth(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const; + +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotTradingCurve::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotTradingCurve::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_plot_vectorfield.cpp b/libs/qwt/src/qwt_plot_vectorfield.cpp index 65bc6ed3..c5982bf8 100644 --- a/libs/qwt/src/qwt_plot_vectorfield.cpp +++ b/libs/qwt/src/qwt_plot_vectorfield.cpp @@ -25,292 +25,280 @@ #define DEBUG_RENDER 0 #if DEBUG_RENDER -#include +# include #endif - -static inline double qwtVector2Radians( double vx, double vy ) +static inline double qwtVector2Radians(double vx, double vy) { - if ( vx == 0.0 ) - return ( vy >= 0 ) ? M_PI_2 : 3 * M_PI_2; + if (vx == 0.0) + return (vy >= 0) ? M_PI_2 : 3 * M_PI_2; - return std::atan2( vy, vx ); + return std::atan2(vy, vx); } -static inline double qwtVector2Magnitude( double vx, double vy ) +static inline double qwtVector2Magnitude(double vx, double vy) { - return sqrt( vx * vx + vy * vy ); + return sqrt(vx * vx + vy * vy); } -static QwtInterval qwtMagnitudeRange( - const QwtSeriesData< QwtVectorFieldSample >* series ) +static QwtInterval +qwtMagnitudeRange(const QwtSeriesData *series) { - if ( series->size() == 0 ) - return QwtInterval( 0, 1 ); + if (series->size() == 0) + return QwtInterval(0, 1); - const QwtVectorFieldSample s0 = series->sample( 0 ); + const QwtVectorFieldSample s0 = series->sample(0); - double min = s0.vx * s0.vx + s0.vy * s0.vy; - double max = min; + double min = s0.vx * s0.vx + s0.vy * s0.vy; + double max = min; - for ( int i = 1; i < series->size(); i++ ) + for (int i = 1; i < series->size(); i++) + { + const QwtVectorFieldSample s = series->sample(i); + const double l = s.vx * s.vx + s.vy * s.vy; + + if (l < min) + min = l; + + if (l > max) + max = l; + } + + min = std::sqrt(min); + max = std::sqrt(max); + + if (max == min) + max += 1.0; + + return QwtInterval(min, max); +} + +static inline QTransform qwtSymbolTransformation(const QTransform &oldTransform, + double x, double y, double vx, + double vy, double magnitude) +{ + QTransform transform = oldTransform; + + if (!transform.isIdentity()) + { + transform.translate(x, y); + + const double radians = qwtVector2Radians(vx, vy); + transform.rotateRadians(radians); + } + else + { + /* + When starting with no transformation ( f.e on screen ) + the matrix can be found without having to use + trigonometric functions + */ + + qreal sin, cos; + if (magnitude == 0.0) { - const QwtVectorFieldSample s = series->sample( i ); - const double l = s.vx * s.vx + s.vy * s.vy; - - if ( l < min ) - min = l; - - if ( l > max ) - max = l; - } - - min = std::sqrt( min ); - max = std::sqrt( max ); - - if ( max == min ) - max += 1.0; - - return QwtInterval( min, max ); -} - -static inline QTransform qwtSymbolTransformation( - const QTransform& oldTransform, double x, double y, - double vx, double vy, double magnitude ) -{ - QTransform transform = oldTransform; - - if ( !transform.isIdentity() ) - { - transform.translate( x, y ); - - const double radians = qwtVector2Radians( vx, vy ); - transform.rotateRadians( radians ); + // something + sin = 1.0; + cos = 0.0; } else { - /* - When starting with no transformation ( f.e on screen ) - the matrix can be found without having to use - trigonometric functions - */ - - qreal sin, cos; - if ( magnitude == 0.0 ) - { - // something - sin = 1.0; - cos = 0.0; - } - else - { - sin = vy / magnitude; - cos = vx / magnitude; - } - - transform.setMatrix( cos, sin, 0.0, -sin, cos, 0.0, x, y, 1.0 ); + sin = vy / magnitude; + cos = vx / magnitude; } - return transform; + transform.setMatrix(cos, sin, 0.0, -sin, cos, 0.0, x, y, 1.0); + } + + return transform; } namespace { - class FilterMatrix +class FilterMatrix +{ +public: + class Entry + { + public: + inline void addSample(double sx, double sy, double svx, double svy) { - public: - class Entry - { - public: - inline void addSample( double sx, double sy, - double svx, double svy ) - { - x += sx; - y += sy; + x += sx; + y += sy; - vx += svx; - vy += svy; + vx += svx; + vy += svy; - count++; - } + count++; + } - quint32 count; + quint32 count; - // screen positions -> float is good enough - float x; - float y; - float vx; - float vy; - }; + // screen positions -> float is good enough + float x; + float y; + float vx; + float vy; + }; - FilterMatrix( const QRectF& dataRect, - const QRectF& canvasRect, const QSizeF& cellSize ) - { - m_dx = cellSize.width(); - m_dy = cellSize.height(); + FilterMatrix(const QRectF &dataRect, const QRectF &canvasRect, + const QSizeF &cellSize) + { + m_dx = cellSize.width(); + m_dy = cellSize.height(); - m_x0 = dataRect.x(); - if ( m_x0 < canvasRect.x() ) - m_x0 += int( ( canvasRect.x() - m_x0 ) / m_dx ) * m_dx; + m_x0 = dataRect.x(); + if (m_x0 < canvasRect.x()) + m_x0 += int((canvasRect.x() - m_x0) / m_dx) * m_dx; - m_y0 = dataRect.y(); - if ( m_y0 < canvasRect.y() ) - m_y0 += int( ( canvasRect.y() - m_y0 ) / m_dy ) * m_dy; + m_y0 = dataRect.y(); + if (m_y0 < canvasRect.y()) + m_y0 += int((canvasRect.y() - m_y0) / m_dy) * m_dy; - m_numColumns = canvasRect.width() / m_dx + 1; - m_numRows = canvasRect.height() / m_dy + 1; + m_numColumns = canvasRect.width() / m_dx + 1; + m_numRows = canvasRect.height() / m_dy + 1; #if 1 - /* - limit column and row count to a maximum of 1000000, - so that memory usage is not an issue - */ - if ( m_numColumns > 1000 ) - { - m_dx = canvasRect.width() / 1000; - m_numColumns = canvasRect.width() / m_dx + 1; - } + /* + limit column and row count to a maximum of 1000000, + so that memory usage is not an issue + */ + if (m_numColumns > 1000) + { + m_dx = canvasRect.width() / 1000; + m_numColumns = canvasRect.width() / m_dx + 1; + } - if ( m_numRows > 1000 ) - { - m_dy = canvasRect.height() / 1000; - m_numRows = canvasRect.height() / m_dx + 1; - } + if (m_numRows > 1000) + { + m_dy = canvasRect.height() / 1000; + m_numRows = canvasRect.height() / m_dx + 1; + } #endif - m_x1 = m_x0 + m_numColumns * m_dx; - m_y1 = m_y0 + m_numRows * m_dy; + m_x1 = m_x0 + m_numColumns * m_dx; + m_y1 = m_y0 + m_numRows * m_dy; - size_t r = static_cast(m_numRows); - size_t c = static_cast(m_numColumns); - m_entries = ( Entry* )::calloc( r * c, sizeof( Entry ) ); - if ( m_entries == NULL ) - { - qWarning() << "QwtPlotVectorField: raster for filtering too fine - running out of memory"; - } - } + size_t r = static_cast(m_numRows); + size_t c = static_cast(m_numColumns); + m_entries = (Entry *)::calloc(r * c, sizeof(Entry)); + if (m_entries == NULL) + { + qWarning() << "QwtPlotVectorField: raster for filtering too fine - " + "running out of memory"; + } + } - ~FilterMatrix() - { - if ( m_entries ) - std::free( m_entries ); - } + ~FilterMatrix() + { + if (m_entries) + std::free(m_entries); + } - inline int numColumns() const - { - return m_numColumns; - } + inline int numColumns() const { return m_numColumns; } - inline int numRows() const - { - return m_numRows; - } + inline int numRows() const { return m_numRows; } - inline void addSample( double x, double y, - double u, double v ) - { - if ( x >= m_x0 && x < m_x1 - && y >= m_y0 && y < m_y1 ) - { - Entry& entry = m_entries[ indexOf( x, y ) ]; - entry.addSample( x, y, u, v ); - } - } + inline void addSample(double x, double y, double u, double v) + { + if (x >= m_x0 && x < m_x1 && y >= m_y0 && y < m_y1) + { + Entry &entry = m_entries[indexOf(x, y)]; + entry.addSample(x, y, u, v); + } + } - const FilterMatrix::Entry* entries() const - { - return m_entries; - } + const FilterMatrix::Entry *entries() const { return m_entries; } - private: - inline int indexOf( qreal x, qreal y ) const - { - const int col = ( x - m_x0 ) / m_dx; - const int row = ( y - m_y0 ) / m_dy; +private: + inline int indexOf(qreal x, qreal y) const + { + const int col = (x - m_x0) / m_dx; + const int row = (y - m_y0) / m_dy; - return row * m_numColumns + col; - } + return row * m_numColumns + col; + } - qreal m_x0, m_x1, m_y0, m_y1, m_dx, m_dy; - int m_numColumns; - int m_numRows; + qreal m_x0, m_x1, m_y0, m_y1, m_dx, m_dy; + int m_numColumns; + int m_numRows; - Entry* m_entries; - }; -} + Entry *m_entries; +}; +} // namespace class QwtPlotVectorField::PrivateData { - public: - PrivateData() - : pen( Qt::black ) - , brush( Qt::black ) - , indicatorOrigin( QwtPlotVectorField::OriginHead ) - , magnitudeScaleFactor( 1.0 ) - , rasterSize( 20, 20 ) - , minArrowLength( 0.0 ) - , maxArrowLength( std::numeric_limits< short >::max() ) - , magnitudeModes( MagnitudeAsLength ) - { - colorMap = NULL; - symbol = new QwtVectorFieldThinArrow(); - } +public: + PrivateData() + : pen(Qt::black) + , brush(Qt::black) + , indicatorOrigin(QwtPlotVectorField::OriginHead) + , magnitudeScaleFactor(1.0) + , rasterSize(20, 20) + , minArrowLength(0.0) + , maxArrowLength(std::numeric_limits::max()) + , magnitudeModes(MagnitudeAsLength) + { + colorMap = NULL; + symbol = new QwtVectorFieldThinArrow(); + } - ~PrivateData() - { - delete colorMap; - delete symbol; - } + ~PrivateData() + { + delete colorMap; + delete symbol; + } - QPen pen; - QBrush brush; + QPen pen; + QBrush brush; - IndicatorOrigin indicatorOrigin; - QwtVectorFieldSymbol* symbol; - QwtColorMap* colorMap; + IndicatorOrigin indicatorOrigin; + QwtVectorFieldSymbol *symbol; + QwtColorMap *colorMap; - /* - Stores the range of magnitudes to be used for the color map. - If invalid (min=max or negative values), the range is determined - from the data samples themselves. - */ - QwtInterval magnitudeRange; - QwtInterval boundingMagnitudeRange; + /* + Stores the range of magnitudes to be used for the color map. + If invalid (min=max or negative values), the range is determined + from the data samples themselves. + */ + QwtInterval magnitudeRange; + QwtInterval boundingMagnitudeRange; - qreal magnitudeScaleFactor; - QSizeF rasterSize; + qreal magnitudeScaleFactor; + QSizeF rasterSize; - double minArrowLength; - double maxArrowLength; + double minArrowLength; + double maxArrowLength; - PaintAttributes paintAttributes; - MagnitudeModes magnitudeModes; + PaintAttributes paintAttributes; + MagnitudeModes magnitudeModes; }; /*! Constructor \param title Title of the curve */ -QwtPlotVectorField::QwtPlotVectorField( const QwtText& title ) - : QwtPlotSeriesItem( title ) +QwtPlotVectorField::QwtPlotVectorField(const QwtText &title) + : QwtPlotSeriesItem(title) { - init(); + init(); } /*! Constructor \param title Title of the curve */ -QwtPlotVectorField::QwtPlotVectorField( const QString& title ) - : QwtPlotSeriesItem( QwtText( title ) ) +QwtPlotVectorField::QwtPlotVectorField(const QString &title) + : QwtPlotSeriesItem(QwtText(title)) { - init(); + init(); } //! Destructor QwtPlotVectorField::~QwtPlotVectorField() { - delete m_data; + delete m_data; } /*! @@ -318,13 +306,13 @@ QwtPlotVectorField::~QwtPlotVectorField() */ void QwtPlotVectorField::init() { - setItemAttribute( QwtPlotItem::Legend ); - setItemAttribute( QwtPlotItem::AutoScale ); + setItemAttribute(QwtPlotItem::Legend); + setItemAttribute(QwtPlotItem::AutoScale); - m_data = new PrivateData; - setData( new QwtVectorFieldData() ); + m_data = new PrivateData; + setData(new QwtVectorFieldData()); - setZ( 20.0 ); + setZ(20.0); } /*! @@ -335,15 +323,15 @@ void QwtPlotVectorField::init() \note the pen is ignored in MagnitudeAsColor mode */ -void QwtPlotVectorField::setPen( const QPen& pen ) +void QwtPlotVectorField::setPen(const QPen &pen) { - if ( m_data->pen != pen ) - { - m_data->pen = pen; + if (m_data->pen != pen) + { + m_data->pen = pen; - itemChanged(); - legendChanged(); - } + itemChanged(); + legendChanged(); + } } /*! @@ -352,7 +340,7 @@ void QwtPlotVectorField::setPen( const QPen& pen ) */ QPen QwtPlotVectorField::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -363,15 +351,15 @@ QPen QwtPlotVectorField::pen() const \note the brush is ignored in MagnitudeAsColor mode */ -void QwtPlotVectorField::setBrush( const QBrush& brush ) +void QwtPlotVectorField::setBrush(const QBrush &brush) { - if ( m_data->brush != brush ) - { - m_data->brush = brush; + if (m_data->brush != brush) + { + m_data->brush = brush; - itemChanged(); - legendChanged(); - } + itemChanged(); + legendChanged(); + } } /*! @@ -380,7 +368,7 @@ void QwtPlotVectorField::setBrush( const QBrush& brush ) */ QBrush QwtPlotVectorField::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -389,20 +377,20 @@ QBrush QwtPlotVectorField::brush() const \param origin Origin \sa indicatorOrigin() */ -void QwtPlotVectorField::setIndicatorOrigin( IndicatorOrigin origin ) +void QwtPlotVectorField::setIndicatorOrigin(IndicatorOrigin origin) { + m_data->indicatorOrigin = origin; + if (m_data->indicatorOrigin != origin) + { m_data->indicatorOrigin = origin; - if ( m_data->indicatorOrigin != origin ) - { - m_data->indicatorOrigin = origin; - itemChanged(); - } + itemChanged(); + } } //! \return origin for the symbols/arrows QwtPlotVectorField::IndicatorOrigin QwtPlotVectorField::indicatorOrigin() const { - return m_data->indicatorOrigin; + return m_data->indicatorOrigin; } /*! @@ -416,13 +404,13 @@ QwtPlotVectorField::IndicatorOrigin QwtPlotVectorField::indicatorOrigin() const \sa magnitudeScaleFactor(), arrowLength() \note Has no effect when QwtPlotVectorField::MagnitudeAsLength is not enabled */ -void QwtPlotVectorField::setMagnitudeScaleFactor( double factor ) +void QwtPlotVectorField::setMagnitudeScaleFactor(double factor) { - if ( factor != m_data->magnitudeScaleFactor ) - { - m_data->magnitudeScaleFactor = factor; - itemChanged(); - } + if (factor != m_data->magnitudeScaleFactor) + { + m_data->magnitudeScaleFactor = factor; + itemChanged(); + } } /*! @@ -431,9 +419,10 @@ void QwtPlotVectorField::setMagnitudeScaleFactor( double factor ) The length of the arrow in screen coordinate units is calculated by scaling the magnitude by the magnitudeScaleFactor. - Default implementation simply scales the vector using the magnitudeScaleFactor - property. Re-implement this function to provide special handling for - zero/non-zero magnitude arrows, or impose minimum/maximum arrow length limits. + Default implementation simply scales the vector using the + magnitudeScaleFactor property. Re-implement this function to provide special + handling for zero/non-zero magnitude arrows, or impose minimum/maximum arrow + length limits. \return Length of arrow to be drawn in dependence of vector magnitude. \sa magnitudeScaleFactor @@ -441,7 +430,7 @@ void QwtPlotVectorField::setMagnitudeScaleFactor( double factor ) */ double QwtPlotVectorField::magnitudeScaleFactor() const { - return m_data->magnitudeScaleFactor; + return m_data->magnitudeScaleFactor; } /*! @@ -449,13 +438,13 @@ double QwtPlotVectorField::magnitudeScaleFactor() const \sa rasterSize(), QwtPlotVectorField::FilterVectors */ -void QwtPlotVectorField::setRasterSize( const QSizeF& size ) +void QwtPlotVectorField::setRasterSize(const QSizeF &size) { - if ( size != m_data->rasterSize ) - { - m_data->rasterSize = size; - itemChanged(); - } + if (size != m_data->rasterSize) + { + m_data->rasterSize = size; + itemChanged(); + } } /*! @@ -464,7 +453,7 @@ void QwtPlotVectorField::setRasterSize( const QSizeF& size ) */ QSizeF QwtPlotVectorField::rasterSize() const { - return m_data->rasterSize; + return m_data->rasterSize; } /*! @@ -474,37 +463,35 @@ QSizeF QwtPlotVectorField::rasterSize() const \param on On/Off \sa testPaintAttribute() */ -void QwtPlotVectorField::setPaintAttribute( - PaintAttribute attribute, bool on ) +void QwtPlotVectorField::setPaintAttribute(PaintAttribute attribute, bool on) { - PaintAttributes attributes = m_data->paintAttributes; + PaintAttributes attributes = m_data->paintAttributes; - if ( on ) - attributes |= attribute; - else - attributes &= ~attribute; + if (on) + attributes |= attribute; + else + attributes &= ~attribute; - if ( m_data->paintAttributes != attributes ) - { - m_data->paintAttributes = attributes; - itemChanged(); - } + if (m_data->paintAttributes != attributes) + { + m_data->paintAttributes = attributes; + itemChanged(); + } } /*! \return True, when attribute is enabled \sa PaintAttribute, setPaintAttribute() */ -bool QwtPlotVectorField::testPaintAttribute( - PaintAttribute attribute ) const +bool QwtPlotVectorField::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } //! \return QwtPlotItem::Rtti_PlotField int QwtPlotVectorField::rtti() const { - return QwtPlotItem::Rtti_PlotVectorField; + return QwtPlotItem::Rtti_PlotVectorField; } /*! @@ -515,34 +502,35 @@ int QwtPlotVectorField::rtti() const \sa symbol(), drawSymbol() \note Ownership is transferred to QwtPlotVectorField. */ -void QwtPlotVectorField::setSymbol( QwtVectorFieldSymbol* symbol ) +void QwtPlotVectorField::setSymbol(QwtVectorFieldSymbol *symbol) { - if ( m_data->symbol == symbol ) - return; + if (m_data->symbol == symbol) + return; - delete m_data->symbol; - m_data->symbol = symbol; + delete m_data->symbol; + m_data->symbol = symbol; - itemChanged(); - legendChanged(); + itemChanged(); + legendChanged(); } /*! \return arrow symbol \sa setSymbol(), drawSymbol() */ -const QwtVectorFieldSymbol* QwtPlotVectorField::symbol() const +const QwtVectorFieldSymbol *QwtPlotVectorField::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! Initialize data with an array of samples. \param samples Vector of points */ -void QwtPlotVectorField::setSamples( const QVector< QwtVectorFieldSample >& samples ) +void QwtPlotVectorField::setSamples( + const QVector &samples) { - setData( new QwtVectorFieldData( samples ) ); + setData(new QwtVectorFieldData(samples)); } /*! @@ -555,9 +543,9 @@ void QwtPlotVectorField::setSamples( const QVector< QwtVectorFieldSample >& samp \warning The item takes ownership of the data object, deleting it when its not used anymore. */ -void QwtPlotVectorField::setSamples( QwtVectorFieldData* data ) +void QwtPlotVectorField::setSamples(QwtVectorFieldData *data) { - setData( data ); + setData(data); } /*! @@ -570,28 +558,28 @@ void QwtPlotVectorField::setSamples( QwtVectorFieldData* data ) \sa colorMap(), magnitudeRange() */ -void QwtPlotVectorField::setColorMap( QwtColorMap* colorMap ) +void QwtPlotVectorField::setColorMap(QwtColorMap *colorMap) { - if ( colorMap == NULL ) - return; + if (colorMap == NULL) + return; - if ( colorMap != m_data->colorMap ) - { - delete m_data->colorMap; - m_data->colorMap = colorMap; - } + if (colorMap != m_data->colorMap) + { + delete m_data->colorMap; + m_data->colorMap = colorMap; + } - legendChanged(); - itemChanged(); + legendChanged(); + itemChanged(); } /*! \return Color Map used for mapping the intensity values to colors \sa setColorMap() */ -const QwtColorMap* QwtPlotVectorField::colorMap() const +const QwtColorMap *QwtPlotVectorField::colorMap() const { - return m_data->colorMap; + return m_data->colorMap; } /*! @@ -601,26 +589,26 @@ const QwtColorMap* QwtPlotVectorField::colorMap() const \param on On/Off \sa testMagnitudeMode() */ -void QwtPlotVectorField::setMagnitudeMode( MagnitudeMode mode, bool on ) +void QwtPlotVectorField::setMagnitudeMode(MagnitudeMode mode, bool on) { - if ( on == testMagnitudeMode( mode ) ) - return; + if (on == testMagnitudeMode(mode)) + return; - if ( on ) - m_data->magnitudeModes |= mode; - else - m_data->magnitudeModes &= ~mode; + if (on) + m_data->magnitudeModes |= mode; + else + m_data->magnitudeModes &= ~mode; - itemChanged(); + itemChanged(); } /*! \return True, when mode is enabled \sa MagnitudeMode, setMagnitudeMode() */ -bool QwtPlotVectorField::testMagnitudeMode( MagnitudeMode mode ) const +bool QwtPlotVectorField::testMagnitudeMode(MagnitudeMode mode) const { - return m_data->magnitudeModes & mode; + return m_data->magnitudeModes & mode; } /*! @@ -631,13 +619,13 @@ bool QwtPlotVectorField::testMagnitudeMode( MagnitudeMode mode ) const \sa magnitudeRange(), colorMap() */ -void QwtPlotVectorField::setMagnitudeRange( const QwtInterval& magnitudeRange ) +void QwtPlotVectorField::setMagnitudeRange(const QwtInterval &magnitudeRange) { - if ( m_data->magnitudeRange != magnitudeRange ) - { - m_data->magnitudeRange = magnitudeRange; - itemChanged(); - } + if (m_data->magnitudeRange != magnitudeRange) + { + m_data->magnitudeRange = magnitudeRange; + itemChanged(); + } } /*! @@ -646,7 +634,7 @@ void QwtPlotVectorField::setMagnitudeRange( const QwtInterval& magnitudeRange ) */ QwtInterval QwtPlotVectorField::magnitudeRange() const { - return m_data->magnitudeRange; + return m_data->magnitudeRange; } /*! @@ -657,15 +645,15 @@ QwtInterval QwtPlotVectorField::magnitudeRange() const \sa minArrowLength(), setMaxArrowLength(), arrowLength() \note Has no effect when QwtPlotVectorField::MagnitudeAsLength is not enabled */ -void QwtPlotVectorField::setMinArrowLength( double length ) +void QwtPlotVectorField::setMinArrowLength(double length) { - length = qMax( length, 0.0 ); + length = qMax(length, 0.0); - if ( m_data->minArrowLength != length ) - { - m_data->minArrowLength = length; - itemChanged(); - } + if (m_data->minArrowLength != length) + { + m_data->minArrowLength = length; + itemChanged(); + } } /*! @@ -676,7 +664,7 @@ void QwtPlotVectorField::setMinArrowLength( double length ) */ double QwtPlotVectorField::minArrowLength() const { - return m_data->minArrowLength; + return m_data->minArrowLength; } /*! @@ -687,15 +675,15 @@ double QwtPlotVectorField::minArrowLength() const \sa maxArrowLength(), setMinArrowLength(), arrowLength() \note Has no effect when QwtPlotVectorField::MagnitudeAsLength is not enabled */ -void QwtPlotVectorField::setMaxArrowLength( double length ) +void QwtPlotVectorField::setMaxArrowLength(double length) { - length = qMax( length, 0.0 ); + length = qMax(length, 0.0); - if ( m_data->maxArrowLength != length ) - { - m_data->maxArrowLength = length; - itemChanged(); - } + if (m_data->maxArrowLength != length) + { + m_data->maxArrowLength = length; + itemChanged(); + } } /*! @@ -706,18 +694,20 @@ void QwtPlotVectorField::setMaxArrowLength( double length ) */ double QwtPlotVectorField::maxArrowLength() const { - return m_data->maxArrowLength; + return m_data->maxArrowLength; } /*! - Computes length of the arrow in screen coordinate units based on its magnitude. + Computes length of the arrow in screen coordinate units based on its + magnitude. - Default implementation simply scales the vector using the magnitudeScaleFactor() - If the result is not null, the length is then bounded into the interval - [ minArrowLength(), maxArrowLength() ]. + Default implementation simply scales the vector using the + magnitudeScaleFactor() If the result is not null, the length is then bounded + into the interval [ minArrowLength(), maxArrowLength() ]. Re-implement this function to provide special handling for - zero/non-zero magnitude arrows, or impose minimum/maximum arrow length limits. + zero/non-zero magnitude arrows, or impose minimum/maximum arrow length + limits. \param magnitude Magnitude \return Length of arrow to be drawn in dependence of vector magnitude. @@ -725,7 +715,7 @@ double QwtPlotVectorField::maxArrowLength() const \sa magnitudeScaleFactor, minArrowLength(), maxArrowLength() \note Has no effect when QwtPlotVectorField::MagnitudeAsLength is not enabled */ -double QwtPlotVectorField::arrowLength( double magnitude ) const +double QwtPlotVectorField::arrowLength(double magnitude) const { #if 0 /* @@ -740,12 +730,12 @@ double QwtPlotVectorField::arrowLength( double magnitude ) const magnitude /= m_data->magnitudeRange.maxValue(); #endif - double length = magnitude * m_data->magnitudeScaleFactor; + double length = magnitude * m_data->magnitudeScaleFactor; - if ( length > 0.0 ) - length = qBound( m_data->minArrowLength, length, m_data->maxArrowLength ); + if (length > 0.0) + length = qBound(m_data->minArrowLength, length, m_data->maxArrowLength); - return length; + return length; } QRectF QwtPlotVectorField::boundingRect() const @@ -758,7 +748,7 @@ QRectF QwtPlotVectorField::boundingRect() const */ #endif - return QwtPlotSeriesItem::boundingRect(); + return QwtPlotSeriesItem::boundingRect(); } /*! @@ -769,30 +759,29 @@ QRectF QwtPlotVectorField::boundingRect() const \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() */ -QwtGraphic QwtPlotVectorField::legendIcon( - int index, const QSizeF& size ) const +QwtGraphic QwtPlotVectorField::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); + Q_UNUSED(index); - QwtGraphic icon; - icon.setDefaultSize( size ); - - if ( size.isEmpty() ) - return icon; - - QPainter painter( &icon ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); - - painter.translate( -size.width(), -0.5 * size.height() ); - - painter.setPen( m_data->pen ); - painter.setBrush( m_data->brush ); - - m_data->symbol->setLength( size.width() - 2 ); - m_data->symbol->paint( &painter ); + QwtGraphic icon; + icon.setDefaultSize(size); + if (size.isEmpty()) return icon; + + QPainter painter(&icon); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPlotItem::RenderAntialiased)); + + painter.translate(-size.width(), -0.5 * size.height()); + + painter.setPen(m_data->pen); + painter.setBrush(m_data->brush); + + m_data->symbol->setLength(size.width() - 2); + m_data->symbol->paint(&painter); + + return icon; } /*! @@ -806,31 +795,32 @@ QwtGraphic QwtPlotVectorField::legendIcon( \param to Index of the last sample to be painted. If to < 0 the series will be painted to its last sample. */ -void QwtPlotVectorField::drawSeries(QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotVectorField::drawSeries(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - if ( !painter || dataSize() <= 0 ) - return; + if (!painter || dataSize() <= 0) + return; - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( from > to ) - return; + if (from > to) + return; #if DEBUG_RENDER - QElapsedTimer timer; - timer.start(); + QElapsedTimer timer; + timer.start(); #endif - drawSymbols( painter, xMap, yMap, canvasRect, from, to ); + drawSymbols(painter, xMap, yMap, canvasRect, from, to); #if DEBUG_RENDER - qDebug() << timer.elapsed(); + qDebug() << timer.elapsed(); #endif } @@ -846,124 +836,126 @@ void QwtPlotVectorField::drawSeries(QPainter* painter, \sa setSymbol(), drawSymbol(), drawSeries() */ -void QwtPlotVectorField::drawSymbols( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const +void QwtPlotVectorField::drawSymbols(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect, int from, + int to) const { - const bool doAlign = QwtPainter::roundingAlignment( painter ); - const bool doClip = false; + const bool doAlign = QwtPainter::roundingAlignment(painter); + const bool doClip = false; - const bool isInvertingX = xMap.isInverting(); - const bool isInvertingY = yMap.isInverting(); + const bool isInvertingX = xMap.isInverting(); + const bool isInvertingY = yMap.isInverting(); - const QwtSeriesData< QwtVectorFieldSample >* series = data(); + const QwtSeriesData *series = data(); - if ( m_data->magnitudeModes & MagnitudeAsColor ) - { - // user input error, can't draw without color map - // TODO: Discuss! Without colormap, silently fall back to uniform colors? - if ( m_data->colorMap == NULL) - return; - } - else - { - painter->setPen( m_data->pen ); - painter->setBrush( m_data->brush ); - } + if (m_data->magnitudeModes & MagnitudeAsColor) + { + // user input error, can't draw without color map + // TODO: Discuss! Without colormap, silently fall back to uniform colors? + if (m_data->colorMap == NULL) + return; + } + else + { + painter->setPen(m_data->pen); + painter->setBrush(m_data->brush); + } - if ( ( m_data->paintAttributes & FilterVectors ) && !m_data->rasterSize.isEmpty() ) - { - const QRectF dataRect = QwtScaleMap::transform( - xMap, yMap, boundingRect() ); + if ((m_data->paintAttributes & FilterVectors) + && !m_data->rasterSize.isEmpty()) + { + const QRectF dataRect = QwtScaleMap::transform(xMap, yMap, boundingRect()); - // TODO: Discuss. How to handle raster size when switching from screen to print size! - // DPI-aware adjustment of rastersize? Or make "rastersize in screen coordinate" - // or "rastersize in plotcoordinetes" a user option? + // TODO: Discuss. How to handle raster size when switching from screen to + // print size! + // DPI-aware adjustment of rastersize? Or make "rastersize in screen + // coordinate" or "rastersize in plotcoordinetes" a user option? #if 1 - // define filter matrix based on screen/print coordinates - FilterMatrix matrix( dataRect, canvasRect, m_data->rasterSize ); + // define filter matrix based on screen/print coordinates + FilterMatrix matrix(dataRect, canvasRect, m_data->rasterSize); #else - // define filter matrix based on real coordinates + // define filter matrix based on real coordinates - // get scale factor from real coordinates to screen coordinates - double xScale = 1; - if (xMap.sDist() != 0) - xScale = xMap.pDist() / xMap.sDist(); + // get scale factor from real coordinates to screen coordinates + double xScale = 1; + if (xMap.sDist() != 0) + xScale = xMap.pDist() / xMap.sDist(); - double yScale = 1; - if (yMap.sDist() != 0) - yScale = yMap.pDist() / yMap.sDist(); + double yScale = 1; + if (yMap.sDist() != 0) + yScale = yMap.pDist() / yMap.sDist(); - QSizeF canvasRasterSize(xScale * m_data->rasterSize.width(), yScale * m_data->rasterSize.height() ); - FilterMatrix matrix( dataRect, canvasRect, canvasRasterSize ); + QSizeF canvasRasterSize(xScale * m_data->rasterSize.width(), + yScale * m_data->rasterSize.height()); + FilterMatrix matrix(dataRect, canvasRect, canvasRasterSize); #endif - for ( int i = from; i <= to; i++ ) - { - const QwtVectorFieldSample sample = series->sample( i ); - if ( !sample.isNull() ) - { - matrix.addSample( xMap.transform( sample.x ), - yMap.transform( sample.y ), sample.vx, sample.vy ); - } - } - - const int numEntries = matrix.numRows() * matrix.numColumns(); - const FilterMatrix::Entry* entries = matrix.entries(); - - for ( int i = 0; i < numEntries; i++ ) - { - const FilterMatrix::Entry& entry = entries[i]; - - if ( entry.count == 0 ) - continue; - - double xi = entry.x / entry.count; - double yi = entry.y / entry.count; - - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - const double vx = entry.vx / entry.count; - const double vy = entry.vy / entry.count; - - drawSymbol( painter, xi, yi, - isInvertingX ? -vx : vx, isInvertingY ? -vy : vy ); - } - } - else + for (int i = from; i <= to; i++) { - for ( int i = from; i <= to; i++ ) - { - const QwtVectorFieldSample sample = series->sample( i ); - - // arrows with zero length are never drawn - if ( sample.isNull() ) - continue; - - double xi = xMap.transform( sample.x ); - double yi = yMap.transform( sample.y ); - - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( doClip ) - { - if ( !canvasRect.contains( xi, yi ) ) - continue; - } - - drawSymbol( painter, xi, yi, - isInvertingX ? -sample.vx : sample.vx, - isInvertingY ? -sample.vy : sample.vy ); - } + const QwtVectorFieldSample sample = series->sample(i); + if (!sample.isNull()) + { + matrix.addSample(xMap.transform(sample.x), yMap.transform(sample.y), + sample.vx, sample.vy); + } } + + const int numEntries = matrix.numRows() * matrix.numColumns(); + const FilterMatrix::Entry *entries = matrix.entries(); + + for (int i = 0; i < numEntries; i++) + { + const FilterMatrix::Entry &entry = entries[i]; + + if (entry.count == 0) + continue; + + double xi = entry.x / entry.count; + double yi = entry.y / entry.count; + + if (doAlign) + { + xi = qRound(xi); + yi = qRound(yi); + } + + const double vx = entry.vx / entry.count; + const double vy = entry.vy / entry.count; + + drawSymbol(painter, xi, yi, isInvertingX ? -vx : vx, + isInvertingY ? -vy : vy); + } + } + else + { + for (int i = from; i <= to; i++) + { + const QwtVectorFieldSample sample = series->sample(i); + + // arrows with zero length are never drawn + if (sample.isNull()) + continue; + + double xi = xMap.transform(sample.x); + double yi = yMap.transform(sample.y); + + if (doAlign) + { + xi = qRound(xi); + yi = qRound(yi); + } + + if (doClip) + { + if (!canvasRect.contains(xi, yi)) + continue; + } + + drawSymbol(painter, xi, yi, isInvertingX ? -sample.vx : sample.vx, + isInvertingY ? -sample.vy : sample.vy); + } + } } /*! @@ -974,67 +966,67 @@ void QwtPlotVectorField::drawSymbols( QPainter* painter, \sa setSymbol(), drawSeries() */ -void QwtPlotVectorField::drawSymbol( QPainter* painter, - double x, double y, double vx, double vy ) const +void QwtPlotVectorField::drawSymbol(QPainter *painter, double x, double y, + double vx, double vy) const { - const double magnitude = qwtVector2Magnitude( vx, vy ); + const double magnitude = qwtVector2Magnitude(vx, vy); - const QTransform oldTransform = painter->transform(); + const QTransform oldTransform = painter->transform(); - QTransform transform = qwtSymbolTransformation( oldTransform, - x, y, vx, vy, magnitude ); + QTransform transform + = qwtSymbolTransformation(oldTransform, x, y, vx, vy, magnitude); - QwtVectorFieldSymbol* symbol = m_data->symbol; + QwtVectorFieldSymbol *symbol = m_data->symbol; - double length = 0.0; + double length = 0.0; - if ( m_data->magnitudeModes & MagnitudeAsLength ) + if (m_data->magnitudeModes & MagnitudeAsLength) + { + length = arrowLength(magnitude); + } + + symbol->setLength(length); + + if (m_data->indicatorOrigin == OriginTail) + { + const qreal dx = symbol->length(); + transform.translate(dx, 0.0); + } + else if (m_data->indicatorOrigin == OriginCenter) + { + const qreal dx = symbol->length(); + transform.translate(0.5 * dx, 0.0); + } + + if (m_data->magnitudeModes & MagnitudeAsColor) + { + // Determine color for arrow if colored by magnitude. + + QwtInterval range = m_data->magnitudeRange; + + if (!range.isValid()) { - length = arrowLength( magnitude ); + if (!m_data->boundingMagnitudeRange.isValid()) + m_data->boundingMagnitudeRange = qwtMagnitudeRange(data()); + + range = m_data->boundingMagnitudeRange; } - symbol->setLength( length ); - - if( m_data->indicatorOrigin == OriginTail ) - { - const qreal dx = symbol->length(); - transform.translate( dx, 0.0 ); - } - else if ( m_data->indicatorOrigin == OriginCenter ) - { - const qreal dx = symbol->length(); - transform.translate( 0.5 * dx, 0.0 ); - } - - if ( m_data->magnitudeModes & MagnitudeAsColor ) - { - // Determine color for arrow if colored by magnitude. - - QwtInterval range = m_data->magnitudeRange; - - if ( !range.isValid() ) - { - if ( !m_data->boundingMagnitudeRange.isValid() ) - m_data->boundingMagnitudeRange = qwtMagnitudeRange( data() ); - - range = m_data->boundingMagnitudeRange; - } - - const QColor c = m_data->colorMap->rgb( range, magnitude ); + const QColor c = m_data->colorMap->rgb(range, magnitude); #if 1 - painter->setBrush( c ); - painter->setPen( c ); + painter->setBrush(c); + painter->setPen(c); #endif - } + } - painter->setWorldTransform( transform, false ); - symbol->paint( painter ); - painter->setWorldTransform( oldTransform, false ); + painter->setWorldTransform(transform, false); + symbol->paint(painter); + painter->setWorldTransform(oldTransform, false); } void QwtPlotVectorField::dataChanged() { - m_data->boundingMagnitudeRange.invalidate(); - QwtPlotSeriesItem::dataChanged(); + m_data->boundingMagnitudeRange.invalidate(); + QwtPlotSeriesItem::dataChanged(); } diff --git a/libs/qwt/src/qwt_plot_vectorfield.h b/libs/qwt/src/qwt_plot_vectorfield.h index a80b63ba..1b1837c6 100644 --- a/libs/qwt/src/qwt_plot_vectorfield.h +++ b/libs/qwt/src/qwt_plot_vectorfield.h @@ -21,149 +21,148 @@ class QBrush; /*! \brief A plot item, that represents a vector field - A vector field is a representation of a points with a given magnitude and direction - as arrows. While the direction affects the direction of the arrow, the magnitude - might be represented as a color or by the length of the arrow. + A vector field is a representation of a points with a given magnitude and + direction as arrows. While the direction affects the direction of the arrow, + the magnitude might be represented as a color or by the length of the arrow. \sa QwtVectorFieldSymbol, QwtVectorFieldSample */ class QWT_EXPORT QwtPlotVectorField - : public QwtPlotSeriesItem - , public QwtSeriesStore< QwtVectorFieldSample > + : public QwtPlotSeriesItem, + public QwtSeriesStore { - public: - /*! - Depending on the origin the indicator symbol ( usually an arrow ) - will be to the position of the corresponding sample. +public: + /*! + Depending on the origin the indicator symbol ( usually an arrow ) + will be to the position of the corresponding sample. + */ + enum IndicatorOrigin + { + //! symbol points to the sample position + OriginHead, + + //! The arrow starts at the sample position + OriginTail, + + //! The arrow is centered at the sample position + OriginCenter + }; + + /*! + Attributes to modify the rendering + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { + /* + FilterVectors calculates an average sample from all samples + that lie in the same cell of a grid that is determined by + setting the rasterSize(). + + \sa setRasterSize() */ - enum IndicatorOrigin - { - //! symbol points to the sample position - OriginHead, + FilterVectors = 0x01 + }; - //! The arrow starts at the sample position - OriginTail, + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - //! The arrow is centered at the sample position - OriginCenter - }; + /*! + Depending on the MagnitudeMode the magnitude component will have + an impact on the attributes of the symbol/arrow. + + \sa setMagnitudeMode() + */ + enum MagnitudeMode + { + /*! + The magnitude will be mapped to a color using a color map + \sa magnitudeRange(), colorMap() + */ + MagnitudeAsColor = 0x01, /*! - Attributes to modify the rendering - \sa setPaintAttribute(), testPaintAttribute() + The magnitude will have an impact on the length of the arrow/symbol + \sa arrowLength(), magnitudeScaleFactor() */ - enum PaintAttribute - { - /* - FilterVectors calculates an average sample from all samples - that lie in the same cell of a grid that is determined by - setting the rasterSize(). + MagnitudeAsLength = 0x02 + }; - \sa setRasterSize() - */ - FilterVectors = 0x01 - }; + Q_DECLARE_FLAGS(MagnitudeModes, MagnitudeMode) - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + explicit QwtPlotVectorField(const QString &title = QString()); + explicit QwtPlotVectorField(const QwtText &title); - /*! - Depending on the MagnitudeMode the magnitude component will have - an impact on the attributes of the symbol/arrow. + virtual ~QwtPlotVectorField(); - \sa setMagnitudeMode() - */ - enum MagnitudeMode - { - /*! - The magnitude will be mapped to a color using a color map - \sa magnitudeRange(), colorMap() - */ - MagnitudeAsColor = 0x01, + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - /*! - The magnitude will have an impact on the length of the arrow/symbol - \sa arrowLength(), magnitudeScaleFactor() - */ - MagnitudeAsLength = 0x02 - }; + void setMagnitudeMode(MagnitudeMode, bool on = true); + bool testMagnitudeMode(MagnitudeMode) const; - Q_DECLARE_FLAGS( MagnitudeModes, MagnitudeMode ) + void setSymbol(QwtVectorFieldSymbol *); + const QwtVectorFieldSymbol *symbol() const; - explicit QwtPlotVectorField( const QString& title = QString() ); - explicit QwtPlotVectorField( const QwtText& title ); + void setPen(const QPen &); + QPen pen() const; - virtual ~QwtPlotVectorField(); + void setBrush(const QBrush &); + QBrush brush() const; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + void setRasterSize(const QSizeF &); + QSizeF rasterSize() const; - void setMagnitudeMode( MagnitudeMode, bool on = true ); - bool testMagnitudeMode( MagnitudeMode ) const; + void setIndicatorOrigin(IndicatorOrigin); + IndicatorOrigin indicatorOrigin() const; - void setSymbol( QwtVectorFieldSymbol* ); - const QwtVectorFieldSymbol* symbol() const; + void setSamples(const QVector &); + void setSamples(QwtVectorFieldData *); - void setPen( const QPen& ); - QPen pen() const; + void setColorMap(QwtColorMap *); + const QwtColorMap *colorMap() const; - void setBrush( const QBrush& ); - QBrush brush() const; + void setMagnitudeRange(const QwtInterval &); + QwtInterval magnitudeRange() const; - void setRasterSize( const QSizeF& ); - QSizeF rasterSize() const; + void setMinArrowLength(double); + double minArrowLength() const; - void setIndicatorOrigin( IndicatorOrigin ); - IndicatorOrigin indicatorOrigin() const; + void setMaxArrowLength(double); + double maxArrowLength() const; - void setSamples( const QVector< QwtVectorFieldSample >& ); - void setSamples( QwtVectorFieldData* ); + virtual double arrowLength(double magnitude) const; - void setColorMap( QwtColorMap* ); - const QwtColorMap* colorMap() const; + virtual QRectF boundingRect() const QWT_OVERRIDE; - void setMagnitudeRange( const QwtInterval& ); - QwtInterval magnitudeRange() const; + virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const QWT_OVERRIDE; - void setMinArrowLength( double ); - double minArrowLength() const; + virtual int rtti() const QWT_OVERRIDE; - void setMaxArrowLength( double ); - double maxArrowLength() const; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - virtual double arrowLength( double magnitude ) const; + void setMagnitudeScaleFactor(double factor); + double magnitudeScaleFactor() const; - virtual QRectF boundingRect() const QWT_OVERRIDE; +protected: + virtual void drawSymbols(QPainter *, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &canvasRect, + int from, int to) const; - virtual void drawSeries( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const QWT_OVERRIDE; + virtual void drawSymbol(QPainter *, double x, double y, double vx, + double vy) const; - virtual int rtti() const QWT_OVERRIDE; + virtual void dataChanged() QWT_OVERRIDE; - virtual QwtGraphic legendIcon( - int index, const QSizeF& ) const QWT_OVERRIDE; +private: + void init(); - void setMagnitudeScaleFactor( double factor ); - double magnitudeScaleFactor() const; - - protected: - virtual void drawSymbols( QPainter*, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int from, int to ) const; - - virtual void drawSymbol( QPainter*, - double x, double y, double vx, double vy ) const; - - virtual void dataChanged() QWT_OVERRIDE; - - private: - void init(); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotVectorField::PaintAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotVectorField::MagnitudeModes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotVectorField::PaintAttributes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotVectorField::MagnitudeModes) #endif diff --git a/libs/qwt/src/qwt_plot_zoneitem.cpp b/libs/qwt/src/qwt_plot_zoneitem.cpp index d596adaa..22966c04 100644 --- a/libs/qwt/src/qwt_plot_zoneitem.cpp +++ b/libs/qwt/src/qwt_plot_zoneitem.cpp @@ -17,20 +17,20 @@ class QwtPlotZoneItem::PrivateData { - public: - PrivateData() - : orientation( Qt::Vertical ) - , pen( Qt::NoPen ) - { - QColor c( Qt::darkGray ); - c.setAlpha( 100 ); - brush = QBrush( c ); - } +public: + PrivateData() + : orientation(Qt::Vertical) + , pen(Qt::NoPen) + { + QColor c(Qt::darkGray); + c.setAlpha(100); + brush = QBrush(c); + } - Qt::Orientation orientation; - QPen pen; - QBrush brush; - QwtInterval interval; + Qt::Orientation orientation; + QPen pen; + QBrush brush; + QwtInterval interval; }; /*! @@ -48,26 +48,26 @@ class QwtPlotZoneItem::PrivateData \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ() */ QwtPlotZoneItem::QwtPlotZoneItem() - : QwtPlotItem( QwtText( "Zone" ) ) + : QwtPlotItem(QwtText("Zone")) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemAttribute( QwtPlotItem::AutoScale, false ); - setItemAttribute( QwtPlotItem::Legend, false ); + setItemAttribute(QwtPlotItem::AutoScale, false); + setItemAttribute(QwtPlotItem::Legend, false); - setZ( 5 ); + setZ(5); } //! Destructor QwtPlotZoneItem::~QwtPlotZoneItem() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PlotZone int QwtPlotZoneItem::rtti() const { - return QwtPlotItem::Rtti_PlotZone; + return QwtPlotItem::Rtti_PlotZone; } /*! @@ -83,9 +83,10 @@ int QwtPlotZoneItem::rtti() const \sa pen(), brush() */ -void QwtPlotZoneItem::setPen( const QColor& color, qreal width, Qt::PenStyle style ) +void QwtPlotZoneItem::setPen(const QColor &color, qreal width, + Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -96,22 +97,22 @@ void QwtPlotZoneItem::setPen( const QColor& color, qreal width, Qt::PenStyle sty \param pen Pen \sa pen(), setBrush() */ -void QwtPlotZoneItem::setPen( const QPen& pen ) +void QwtPlotZoneItem::setPen(const QPen &pen) { - if ( m_data->pen != pen ) - { - m_data->pen = pen; - itemChanged(); - } + if (m_data->pen != pen) + { + m_data->pen = pen; + itemChanged(); + } } /*! \return Pen used to draw the border lines \sa setPen(), brush() */ -const QPen& QwtPlotZoneItem::pen() const +const QPen &QwtPlotZoneItem::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -122,22 +123,22 @@ const QPen& QwtPlotZoneItem::pen() const \param brush Brush \sa pen(), setBrush() */ -void QwtPlotZoneItem::setBrush( const QBrush& brush ) +void QwtPlotZoneItem::setBrush(const QBrush &brush) { - if ( m_data->brush != brush ) - { - m_data->brush = brush; - itemChanged(); - } + if (m_data->brush != brush) + { + m_data->brush = brush; + itemChanged(); + } } /*! \return Brush used to fill the zone \sa setPen(), brush() */ -const QBrush& QwtPlotZoneItem::brush() const +const QBrush &QwtPlotZoneItem::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -149,13 +150,13 @@ const QBrush& QwtPlotZoneItem::brush() const \sa orientation(), QwtPlotItem::setAxes() */ -void QwtPlotZoneItem::setOrientation( Qt::Orientation orientation ) +void QwtPlotZoneItem::setOrientation(Qt::Orientation orientation) { - if ( m_data->orientation != orientation ) - { - m_data->orientation = orientation; - itemChanged(); - } + if (m_data->orientation != orientation) + { + m_data->orientation = orientation; + itemChanged(); + } } /*! @@ -164,7 +165,7 @@ void QwtPlotZoneItem::setOrientation( Qt::Orientation orientation ) */ Qt::Orientation QwtPlotZoneItem::orientation() const { - return m_data->orientation; + return m_data->orientation; } /*! @@ -178,9 +179,9 @@ Qt::Orientation QwtPlotZoneItem::orientation() const \sa interval(), setOrientation() */ -void QwtPlotZoneItem::setInterval( double min, double max ) +void QwtPlotZoneItem::setInterval(double min, double max) { - setInterval( QwtInterval( min, max ) ); + setInterval(QwtInterval(min, max)); } /*! @@ -193,13 +194,13 @@ void QwtPlotZoneItem::setInterval( double min, double max ) \sa interval(), setOrientation() */ -void QwtPlotZoneItem::setInterval( const QwtInterval& interval ) +void QwtPlotZoneItem::setInterval(const QwtInterval &interval) { - if ( m_data->interval != interval ) - { - m_data->interval = interval; - itemChanged(); - } + if (m_data->interval != interval) + { + m_data->interval = interval; + itemChanged(); + } } /*! @@ -208,7 +209,7 @@ void QwtPlotZoneItem::setInterval( const QwtInterval& interval ) */ QwtInterval QwtPlotZoneItem::interval() const { - return m_data->interval; + return m_data->interval; } /*! @@ -220,72 +221,73 @@ QwtInterval QwtPlotZoneItem::interval() const \param canvasRect Contents rectangle of the canvas in painter coordinates */ -void QwtPlotZoneItem::draw( QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect ) const +void QwtPlotZoneItem::draw(QPainter *painter, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QRectF &canvasRect) const { - if ( !m_data->interval.isValid() ) - return; + if (!m_data->interval.isValid()) + return; - QPen pen = m_data->pen; - pen.setCapStyle( Qt::FlatCap ); + QPen pen = m_data->pen; + pen.setCapStyle(Qt::FlatCap); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - if ( m_data->orientation == Qt::Horizontal ) + if (m_data->orientation == Qt::Horizontal) + { + double y1 = yMap.transform(m_data->interval.minValue()); + double y2 = yMap.transform(m_data->interval.maxValue()); + + if (doAlign) { - double y1 = yMap.transform( m_data->interval.minValue() ); - double y2 = yMap.transform( m_data->interval.maxValue() ); - - if ( doAlign ) - { - y1 = qRound( y1 ); - y2 = qRound( y2 ); - } - - QRectF r( canvasRect.left(), y1, canvasRect.width(), y2 - y1 ); - r = r.normalized(); - - if ( ( m_data->brush.style() != Qt::NoBrush ) && ( y1 != y2 ) ) - { - QwtPainter::fillRect( painter, r, m_data->brush ); - } - - if ( m_data->pen.style() != Qt::NoPen ) - { - painter->setPen( m_data->pen ); - - QwtPainter::drawLine( painter, r.left(), r.top(), r.right(), r.top() ); - QwtPainter::drawLine( painter, r.left(), r.bottom(), r.right(), r.bottom() ); - } + y1 = qRound(y1); + y2 = qRound(y2); } - else + + QRectF r(canvasRect.left(), y1, canvasRect.width(), y2 - y1); + r = r.normalized(); + + if ((m_data->brush.style() != Qt::NoBrush) && (y1 != y2)) { - double x1 = xMap.transform( m_data->interval.minValue() ); - double x2 = xMap.transform( m_data->interval.maxValue() ); - - if ( doAlign ) - { - x1 = qRound( x1 ); - x2 = qRound( x2 ); - } - - QRectF r( x1, canvasRect.top(), x2 - x1, canvasRect.height() ); - r = r.normalized(); - - if ( ( m_data->brush.style() != Qt::NoBrush ) && ( x1 != x2 ) ) - { - QwtPainter::fillRect( painter, r, m_data->brush ); - } - - if ( m_data->pen.style() != Qt::NoPen ) - { - painter->setPen( m_data->pen ); - - QwtPainter::drawLine( painter, r.left(), r.top(), r.left(), r.bottom() ); - QwtPainter::drawLine( painter, r.right(), r.top(), r.right(), r.bottom() ); - } + QwtPainter::fillRect(painter, r, m_data->brush); } + + if (m_data->pen.style() != Qt::NoPen) + { + painter->setPen(m_data->pen); + + QwtPainter::drawLine(painter, r.left(), r.top(), r.right(), r.top()); + QwtPainter::drawLine(painter, r.left(), r.bottom(), r.right(), + r.bottom()); + } + } + else + { + double x1 = xMap.transform(m_data->interval.minValue()); + double x2 = xMap.transform(m_data->interval.maxValue()); + + if (doAlign) + { + x1 = qRound(x1); + x2 = qRound(x2); + } + + QRectF r(x1, canvasRect.top(), x2 - x1, canvasRect.height()); + r = r.normalized(); + + if ((m_data->brush.style() != Qt::NoBrush) && (x1 != x2)) + { + QwtPainter::fillRect(painter, r, m_data->brush); + } + + if (m_data->pen.style() != Qt::NoPen) + { + painter->setPen(m_data->pen); + + QwtPainter::drawLine(painter, r.left(), r.top(), r.left(), r.bottom()); + QwtPainter::drawLine(painter, r.right(), r.top(), r.right(), r.bottom()); + } + } } /*! @@ -296,23 +298,23 @@ void QwtPlotZoneItem::draw( QPainter* painter, */ QRectF QwtPlotZoneItem::boundingRect() const { - QRectF br = QwtPlotItem::boundingRect(); + QRectF br = QwtPlotItem::boundingRect(); - const QwtInterval& intv = m_data->interval; + const QwtInterval &intv = m_data->interval; - if ( intv.isValid() ) + if (intv.isValid()) + { + if (m_data->orientation == Qt::Horizontal) { - if ( m_data->orientation == Qt::Horizontal ) - { - br.setTop( intv.minValue() ); - br.setBottom( intv.maxValue() ); - } - else - { - br.setLeft( intv.minValue() ); - br.setRight( intv.maxValue() ); - } + br.setTop(intv.minValue()); + br.setBottom(intv.maxValue()); } + else + { + br.setLeft(intv.minValue()); + br.setRight(intv.maxValue()); + } + } - return br; + return br; } diff --git a/libs/qwt/src/qwt_plot_zoneitem.h b/libs/qwt/src/qwt_plot_zoneitem.h index 5292f3c1..781e4fa6 100644 --- a/libs/qwt/src/qwt_plot_zoneitem.h +++ b/libs/qwt/src/qwt_plot_zoneitem.h @@ -24,44 +24,43 @@ class QBrush; A horizontal zone highlights an interval of the y axis - a vertical zone an interval of the x axis - and is unbounded in the opposite direction. - It is filled with a brush and its border lines are optionally displayed with a pen. + It is filled with a brush and its border lines are optionally displayed with + a pen. \note For displaying an area that is bounded for x and y coordinates use QwtPlotShapeItem */ -class QWT_EXPORT QwtPlotZoneItem : - public QwtPlotItem +class QWT_EXPORT QwtPlotZoneItem : public QwtPlotItem { - public: - explicit QwtPlotZoneItem(); - virtual ~QwtPlotZoneItem(); +public: + explicit QwtPlotZoneItem(); + virtual ~QwtPlotZoneItem(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setOrientation( Qt::Orientation ); - Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation); + Qt::Orientation orientation() const; - void setInterval( double min, double max ); - void setInterval( const QwtInterval& ); - QwtInterval interval() const; + void setInterval(double min, double max); + void setInterval(const QwtInterval &); + QwtInterval interval() const; - void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setPen( const QPen& ); - const QPen& pen() const; + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); + void setPen(const QPen &); + const QPen &pen() const; - void setBrush( const QBrush& ); - const QBrush& brush() const; + void setBrush(const QBrush &); + const QBrush &brush() const; - virtual void draw( QPainter*, - const QwtScaleMap&, const QwtScaleMap&, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QwtScaleMap &, const QwtScaleMap &, + const QRectF &canvasRect) const QWT_OVERRIDE; - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_plot_zoomer.cpp b/libs/qwt/src/qwt_plot_zoomer.cpp index c0d2d4f5..a9037e26 100644 --- a/libs/qwt/src/qwt_plot_zoomer.cpp +++ b/libs/qwt/src/qwt_plot_zoomer.cpp @@ -16,75 +16,77 @@ #include -static QwtInterval qwtExpandedZoomInterval( double v1, double v2, - double minRange, const QwtTransform* transform ) +static QwtInterval qwtExpandedZoomInterval(double v1, double v2, + double minRange, + const QwtTransform *transform) { - double min = v1; - double max = v2; + double min = v1; + double max = v2; - if ( max - min < minRange ) + if (max - min < minRange) + { + min = 0.5 * (min + max - minRange); + max = min + minRange; + + if (transform) { - min = 0.5 * ( min + max - minRange ); - max = min + minRange; + // f.e the logarithmic scale doesn't allow values + // outside [QwtLogTransform::LogMin/QwtLogTransform::LogMax] - if ( transform ) - { - // f.e the logarithmic scale doesn't allow values - // outside [QwtLogTransform::LogMin/QwtLogTransform::LogMax] + double minBounded = transform->bounded(min); + double maxBounded = transform->bounded(max); - double minBounded = transform->bounded( min ); - double maxBounded = transform->bounded( max ); + if (minBounded != min) + { + maxBounded = transform->bounded(minBounded + minRange); + } + else if (maxBounded != max) + { + minBounded = transform->bounded(maxBounded - minRange); + } - if ( minBounded != min ) - { - maxBounded = transform->bounded( minBounded + minRange ); - } - else if ( maxBounded != max ) - { - minBounded = transform->bounded( maxBounded - minRange ); - } - - min = minBounded; - max = maxBounded; - } + min = minBounded; + max = maxBounded; } + } - return QwtInterval( min, max ); + return QwtInterval(min, max); } -static QRectF qwtExpandedZoomRect( const QRectF& zoomRect, const QSizeF& minSize, - const QwtTransform* transformX, const QwtTransform* transformY ) +static QRectF qwtExpandedZoomRect(const QRectF &zoomRect, const QSizeF &minSize, + const QwtTransform *transformX, + const QwtTransform *transformY) { - QRectF r = zoomRect; + QRectF r = zoomRect; - if ( minSize.width() > r.width() ) - { - const QwtInterval intv = qwtExpandedZoomInterval( - r.left(), r.right(), minSize.width(), transformX ); + if (minSize.width() > r.width()) + { + const QwtInterval intv = qwtExpandedZoomInterval( + r.left(), r.right(), minSize.width(), transformX); - r.setLeft( intv.minValue() ); - r.setRight( intv.maxValue() ); - } + r.setLeft(intv.minValue()); + r.setRight(intv.maxValue()); + } - if ( minSize.height() > r.height() ) - { - const QwtInterval intv = qwtExpandedZoomInterval( - zoomRect.top(), zoomRect.bottom(), minSize.height(), transformY ); + if (minSize.height() > r.height()) + { + const QwtInterval intv = qwtExpandedZoomInterval( + zoomRect.top(), zoomRect.bottom(), minSize.height(), transformY); - r.setTop( intv.minValue() ); - r.setBottom( intv.maxValue() ); - } + r.setTop(intv.minValue()); + r.setBottom(intv.maxValue()); + } - return r; + return r; } class QwtPlotZoomer::PrivateData { - public: - uint zoomRectIndex; - QStack< QRectF > zoomStack; +public: + uint zoomRectIndex; + QStack zoomStack; - int maxStackDepth; + int maxStackDepth; }; /*! @@ -100,17 +102,17 @@ class QwtPlotZoomer::PrivateData is set to QwtPicker::RectRubberBand \param canvas Plot canvas to observe, also the parent object - \param doReplot Call QwtPlot::replot() for the attached plot before initializing - the zoomer with its scales. This might be necessary, - when the plot is in a state with pending scale changes. + \param doReplot Call QwtPlot::replot() for the attached plot before + initializing the zoomer with its scales. This might be necessary, when the + plot is in a state with pending scale changes. \sa QwtPlot::autoReplot(), QwtPlot::replot(), setZoomBase() */ -QwtPlotZoomer::QwtPlotZoomer( QWidget* canvas, bool doReplot ) - : QwtPlotPicker( canvas ) +QwtPlotZoomer::QwtPlotZoomer(QWidget *canvas, bool doReplot) + : QwtPlotPicker(canvas) { - if ( canvas ) - init( doReplot ); + if (canvas) + init(doReplot); } /*! @@ -123,41 +125,41 @@ QwtPlotZoomer::QwtPlotZoomer( QWidget* canvas, bool doReplot ) \param xAxisId X axis of the zoomer \param yAxisId Y axis of the zoomer \param canvas Plot canvas to observe, also the parent object - \param doReplot Call QwtPlot::replot() for the attached plot before initializing - the zoomer with its scales. This might be necessary, - when the plot is in a state with pending scale changes. + \param doReplot Call QwtPlot::replot() for the attached plot before + initializing the zoomer with its scales. This might be necessary, when the + plot is in a state with pending scale changes. \sa QwtPlot::autoReplot(), QwtPlot::replot(), setZoomBase() */ -QwtPlotZoomer::QwtPlotZoomer( QwtAxisId xAxisId, QwtAxisId yAxisId, - QWidget* canvas, bool doReplot ) - : QwtPlotPicker( xAxisId, yAxisId, canvas ) +QwtPlotZoomer::QwtPlotZoomer(QwtAxisId xAxisId, QwtAxisId yAxisId, + QWidget *canvas, bool doReplot) + : QwtPlotPicker(xAxisId, yAxisId, canvas) { - if ( canvas ) - init( doReplot ); + if (canvas) + init(doReplot); } //! Init the zoomer, used by the constructors -void QwtPlotZoomer::init( bool doReplot ) +void QwtPlotZoomer::init(bool doReplot) { - m_data = new PrivateData; + m_data = new PrivateData; - m_data->maxStackDepth = -1; + m_data->maxStackDepth = -1; - setTrackerMode( ActiveOnly ); - setRubberBand( RectRubberBand ); - setStateMachine( new QwtPickerDragRectMachine() ); + setTrackerMode(ActiveOnly); + setRubberBand(RectRubberBand); + setStateMachine(new QwtPickerDragRectMachine()); - if ( doReplot && plot() ) - plot()->replot(); + if (doReplot && plot()) + plot()->replot(); - setZoomBase( scaleRect() ); + setZoomBase(scaleRect()); } QwtPlotZoomer::~QwtPlotZoomer() { - delete m_data; + delete m_data; } /*! @@ -171,27 +173,27 @@ QwtPlotZoomer::~QwtPlotZoomer() \note depth doesn't include the zoom base, so zoomStack().count() might be maxStackDepth() + 1. */ -void QwtPlotZoomer::setMaxStackDepth( int depth ) +void QwtPlotZoomer::setMaxStackDepth(int depth) { - m_data->maxStackDepth = depth; + m_data->maxStackDepth = depth; - if ( depth >= 0 ) + if (depth >= 0) + { + // unzoom if the current depth is below m_data->maxStackDepth + + const int zoomOut + = m_data->zoomStack.count() - 1 - depth; // -1 for the zoom base + + if (zoomOut > 0) { - // unzoom if the current depth is below m_data->maxStackDepth - - const int zoomOut = - m_data->zoomStack.count() - 1 - depth; // -1 for the zoom base - - if ( zoomOut > 0 ) - { - zoom( -zoomOut ); - for ( int i = m_data->zoomStack.count() - 1; - i > int( m_data->zoomRectIndex ); i-- ) - { - ( void )m_data->zoomStack.pop(); // remove trailing rects - } - } + zoom(-zoomOut); + for (int i = m_data->zoomStack.count() - 1; + i > int(m_data->zoomRectIndex); i--) + { + (void)m_data->zoomStack.pop(); // remove trailing rects + } } + } } /*! @@ -200,7 +202,7 @@ void QwtPlotZoomer::setMaxStackDepth( int depth ) */ int QwtPlotZoomer::maxStackDepth() const { - return m_data->maxStackDepth; + return m_data->maxStackDepth; } /*! @@ -209,9 +211,9 @@ int QwtPlotZoomer::maxStackDepth() const \sa setZoomStack(), zoomRectIndex() */ -const QStack< QRectF >& QwtPlotZoomer::zoomStack() const +const QStack &QwtPlotZoomer::zoomStack() const { - return m_data->zoomStack; + return m_data->zoomStack; } /*! @@ -220,32 +222,32 @@ const QStack< QRectF >& QwtPlotZoomer::zoomStack() const */ QRectF QwtPlotZoomer::zoomBase() const { - return m_data->zoomStack[0]; + return m_data->zoomStack[0]; } /*! Reinitialized the zoom stack with scaleRect() as base. - \param doReplot Call QwtPlot::replot() for the attached plot before initializing - the zoomer with its scales. This might be necessary, - when the plot is in a state with pending scale changes. + \param doReplot Call QwtPlot::replot() for the attached plot before + initializing the zoomer with its scales. This might be necessary, when the + plot is in a state with pending scale changes. \sa zoomBase(), scaleRect() QwtPlot::autoReplot(), QwtPlot::replot(). */ -void QwtPlotZoomer::setZoomBase( bool doReplot ) +void QwtPlotZoomer::setZoomBase(bool doReplot) { - QwtPlot* plt = plot(); - if ( plt == NULL ) - return; + QwtPlot *plt = plot(); + if (plt == NULL) + return; - if ( doReplot ) - plt->replot(); + if (doReplot) + plt->replot(); - m_data->zoomStack.clear(); - m_data->zoomStack.push( scaleRect() ); - m_data->zoomRectIndex = 0; + m_data->zoomStack.clear(); + m_data->zoomStack.push(scaleRect()); + m_data->zoomRectIndex = 0; - rescale(); + rescale(); } /*! @@ -258,26 +260,26 @@ void QwtPlotZoomer::setZoomBase( bool doReplot ) \sa zoomBase(), scaleRect() */ -void QwtPlotZoomer::setZoomBase( const QRectF& base ) +void QwtPlotZoomer::setZoomBase(const QRectF &base) { - const QwtPlot* plt = plot(); - if ( !plt ) - return; + const QwtPlot *plt = plot(); + if (!plt) + return; - const QRectF sRect = scaleRect(); - const QRectF bRect = base | sRect; + const QRectF sRect = scaleRect(); + const QRectF bRect = base | sRect; - m_data->zoomStack.clear(); - m_data->zoomStack.push( bRect ); - m_data->zoomRectIndex = 0; + m_data->zoomStack.clear(); + m_data->zoomStack.push(bRect); + m_data->zoomRectIndex = 0; - if ( base != sRect ) - { - m_data->zoomStack.push( sRect ); - m_data->zoomRectIndex++; - } + if (base != sRect) + { + m_data->zoomStack.push(sRect); + m_data->zoomRectIndex++; + } - rescale(); + rescale(); } /*! @@ -286,7 +288,7 @@ void QwtPlotZoomer::setZoomBase( const QRectF& base ) */ QRectF QwtPlotZoomer::zoomRect() const { - return m_data->zoomStack[m_data->zoomRectIndex]; + return m_data->zoomStack[m_data->zoomRectIndex]; } /*! @@ -294,7 +296,7 @@ QRectF QwtPlotZoomer::zoomRect() const */ uint QwtPlotZoomer::zoomRectIndex() const { - return m_data->zoomRectIndex; + return m_data->zoomRectIndex; } /*! @@ -307,30 +309,29 @@ uint QwtPlotZoomer::zoomRectIndex() const \note The zoomed signal is emitted. */ -void QwtPlotZoomer::zoom( const QRectF& rect ) +void QwtPlotZoomer::zoom(const QRectF &rect) { - if ( m_data->maxStackDepth >= 0 && - int( m_data->zoomRectIndex ) >= m_data->maxStackDepth ) + if (m_data->maxStackDepth >= 0 + && int(m_data->zoomRectIndex) >= m_data->maxStackDepth) + { + return; + } + + const QRectF zoomRect = rect.normalized(); + if (zoomRect != m_data->zoomStack[m_data->zoomRectIndex]) + { + for (uint i = m_data->zoomStack.count() - 1; i > m_data->zoomRectIndex; i--) { - return; + (void)m_data->zoomStack.pop(); } - const QRectF zoomRect = rect.normalized(); - if ( zoomRect != m_data->zoomStack[m_data->zoomRectIndex] ) - { - for ( uint i = m_data->zoomStack.count() - 1; - i > m_data->zoomRectIndex; i-- ) - { - ( void )m_data->zoomStack.pop(); - } + m_data->zoomStack.push(zoomRect); + m_data->zoomRectIndex++; - m_data->zoomStack.push( zoomRect ); - m_data->zoomRectIndex++; + rescale(); - rescale(); - - Q_EMIT zoomed( zoomRect ); - } + Q_EMIT zoomed(zoomRect); + } } /*! @@ -344,26 +345,26 @@ void QwtPlotZoomer::zoom( const QRectF& rect ) \note The zoomed signal is emitted. \sa zoomRectIndex() */ -void QwtPlotZoomer::zoom( int offset ) +void QwtPlotZoomer::zoom(int offset) { - int newIndex; + int newIndex; - if ( offset == 0 ) - { - newIndex = 0; - } - else - { - newIndex = m_data->zoomRectIndex + offset; - newIndex = qBound( 0, newIndex, m_data->zoomStack.count() - 1 ); - } + if (offset == 0) + { + newIndex = 0; + } + else + { + newIndex = m_data->zoomRectIndex + offset; + newIndex = qBound(0, newIndex, m_data->zoomStack.count() - 1); + } - if ( newIndex != static_cast< int >( m_data->zoomRectIndex ) ) - { - m_data->zoomRectIndex = newIndex; - rescale(); - Q_EMIT zoomed( zoomRect() ); - } + if (newIndex != static_cast(m_data->zoomRectIndex)) + { + m_data->zoomRectIndex = newIndex; + rescale(); + Q_EMIT zoomed(zoomRect()); + } } /*! @@ -380,31 +381,30 @@ void QwtPlotZoomer::zoom( int offset ) \note The zoomed signal might be emitted. \sa zoomStack(), zoomRectIndex() */ -void QwtPlotZoomer::setZoomStack( - const QStack< QRectF >& zoomStack, int zoomRectIndex ) +void QwtPlotZoomer::setZoomStack(const QStack &zoomStack, + int zoomRectIndex) { - if ( zoomStack.isEmpty() ) - return; + if (zoomStack.isEmpty()) + return; - if ( m_data->maxStackDepth >= 0 && - zoomStack.count() > m_data->maxStackDepth ) - { - return; - } + if (m_data->maxStackDepth >= 0 && zoomStack.count() > m_data->maxStackDepth) + { + return; + } - if ( zoomRectIndex < 0 || zoomRectIndex > zoomStack.count() ) - zoomRectIndex = zoomStack.count() - 1; + if (zoomRectIndex < 0 || zoomRectIndex > zoomStack.count()) + zoomRectIndex = zoomStack.count() - 1; - const bool doRescale = zoomStack[zoomRectIndex] != zoomRect(); + const bool doRescale = zoomStack[zoomRectIndex] != zoomRect(); - m_data->zoomStack = zoomStack; - m_data->zoomRectIndex = uint( zoomRectIndex ); + m_data->zoomStack = zoomStack; + m_data->zoomRectIndex = uint(zoomRectIndex); - if ( doRescale ) - { - rescale(); - Q_EMIT zoomed( zoomRect() ); - } + if (doRescale) + { + rescale(); + Q_EMIT zoomed(zoomRect()); + } } /*! @@ -415,34 +415,34 @@ void QwtPlotZoomer::setZoomStack( void QwtPlotZoomer::rescale() { - QwtPlot* plt = plot(); - if ( !plt ) - return; + QwtPlot *plt = plot(); + if (!plt) + return; - const QRectF& rect = m_data->zoomStack[m_data->zoomRectIndex]; - if ( rect != scaleRect() ) - { - const bool doReplot = plt->autoReplot(); - plt->setAutoReplot( false ); + const QRectF &rect = m_data->zoomStack[m_data->zoomRectIndex]; + if (rect != scaleRect()) + { + const bool doReplot = plt->autoReplot(); + plt->setAutoReplot(false); - double x1 = rect.left(); - double x2 = rect.right(); - if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() ) - qSwap( x1, x2 ); + double x1 = rect.left(); + double x2 = rect.right(); + if (!plt->axisScaleDiv(xAxis()).isIncreasing()) + qSwap(x1, x2); - plt->setAxisScale( xAxis(), x1, x2 ); + plt->setAxisScale(xAxis(), x1, x2); - double y1 = rect.top(); - double y2 = rect.bottom(); - if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() ) - qSwap( y1, y2 ); + double y1 = rect.top(); + double y2 = rect.bottom(); + if (!plt->axisScaleDiv(yAxis()).isIncreasing()) + qSwap(y1, y2); - plt->setAxisScale( yAxis(), y1, y2 ); + plt->setAxisScale(yAxis(), y1, y2); - plt->setAutoReplot( doReplot ); + plt->setAutoReplot(doReplot); - plt->replot(); - } + plt->replot(); + } } /*! @@ -452,13 +452,13 @@ void QwtPlotZoomer::rescale() \param yAxisId Y axis */ -void QwtPlotZoomer::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ) +void QwtPlotZoomer::setAxes(QwtAxisId xAxisId, QwtAxisId yAxisId) { - if ( xAxisId != QwtPlotPicker::xAxis() || yAxisId != QwtPlotPicker::yAxis() ) - { - QwtPlotPicker::setAxes( xAxisId, yAxisId ); - setZoomBase( scaleRect() ); - } + if (xAxisId != QwtPlotPicker::xAxis() || yAxisId != QwtPlotPicker::yAxis()) + { + QwtPlotPicker::setAxes(xAxisId, yAxisId); + setZoomBase(scaleRect()); + } } /*! @@ -471,16 +471,16 @@ void QwtPlotZoomer::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ) \note The mouse events can be changed, using QwtEventPattern::setMousePattern: 2, 1 */ -void QwtPlotZoomer::widgetMouseReleaseEvent( QMouseEvent* me ) +void QwtPlotZoomer::widgetMouseReleaseEvent(QMouseEvent *me) { - if ( mouseMatch( MouseSelect2, me ) ) - zoom( 0 ); - else if ( mouseMatch( MouseSelect3, me ) ) - zoom( -1 ); - else if ( mouseMatch( MouseSelect6, me ) ) - zoom( +1 ); - else - QwtPlotPicker::widgetMouseReleaseEvent( me ); + if (mouseMatch(MouseSelect2, me)) + zoom(0); + else if (mouseMatch(MouseSelect3, me)) + zoom(-1); + else if (mouseMatch(MouseSelect6, me)) + zoom(+1); + else + QwtPlotPicker::widgetMouseReleaseEvent(me); } /*! @@ -494,19 +494,19 @@ void QwtPlotZoomer::widgetMouseReleaseEvent( QMouseEvent* me ) QwtEventPattern::setKeyPattern: 3, 4, 5 */ -void QwtPlotZoomer::widgetKeyPressEvent( QKeyEvent* ke ) +void QwtPlotZoomer::widgetKeyPressEvent(QKeyEvent *ke) { - if ( !isActive() ) - { - if ( keyMatch( KeyUndo, ke ) ) - zoom( -1 ); - else if ( keyMatch( KeyRedo, ke ) ) - zoom( +1 ); - else if ( keyMatch( KeyHome, ke ) ) - zoom( 0 ); - } + if (!isActive()) + { + if (keyMatch(KeyUndo, ke)) + zoom(-1); + else if (keyMatch(KeyRedo, ke)) + zoom(+1); + else if (keyMatch(KeyHome, ke)) + zoom(0); + } - QwtPlotPicker::widgetKeyPressEvent( ke ); + QwtPlotPicker::widgetKeyPressEvent(ke); } /*! @@ -517,10 +517,10 @@ void QwtPlotZoomer::widgetKeyPressEvent( QKeyEvent* ke ) \note The changed rectangle is limited by the zoom base */ -void QwtPlotZoomer::moveBy( double dx, double dy ) +void QwtPlotZoomer::moveBy(double dx, double dy) { - const QRectF& rect = m_data->zoomStack[m_data->zoomRectIndex]; - moveTo( QPointF( rect.left() + dx, rect.top() + dy ) ); + const QRectF &rect = m_data->zoomStack[m_data->zoomRectIndex]; + moveTo(QPointF(rect.left() + dx, rect.top() + dy)); } /*! @@ -531,26 +531,26 @@ void QwtPlotZoomer::moveBy( double dx, double dy ) \sa QRectF::moveTo() \note The changed rectangle is limited by the zoom base */ -void QwtPlotZoomer::moveTo( const QPointF& pos ) +void QwtPlotZoomer::moveTo(const QPointF &pos) { - double x = pos.x(); - double y = pos.y(); + double x = pos.x(); + double y = pos.y(); - if ( x < zoomBase().left() ) - x = zoomBase().left(); - if ( x > zoomBase().right() - zoomRect().width() ) - x = zoomBase().right() - zoomRect().width(); + if (x < zoomBase().left()) + x = zoomBase().left(); + if (x > zoomBase().right() - zoomRect().width()) + x = zoomBase().right() - zoomRect().width(); - if ( y < zoomBase().top() ) - y = zoomBase().top(); - if ( y > zoomBase().bottom() - zoomRect().height() ) - y = zoomBase().bottom() - zoomRect().height(); + if (y < zoomBase().top()) + y = zoomBase().top(); + if (y > zoomBase().bottom() - zoomRect().height()) + y = zoomBase().bottom() - zoomRect().height(); - if ( x != zoomRect().left() || y != zoomRect().top() ) - { - m_data->zoomStack[m_data->zoomRectIndex].moveTo( x, y ); - rescale(); - } + if (x != zoomRect().left() || y != zoomRect().top()) + { + m_data->zoomStack[m_data->zoomRectIndex].moveTo(x, y); + rescale(); + } } /*! @@ -564,29 +564,29 @@ void QwtPlotZoomer::moveTo( const QPointF& pos ) to an accepted one. */ -bool QwtPlotZoomer::accept( QPolygon& pa ) const +bool QwtPlotZoomer::accept(QPolygon &pa) const { - if ( pa.count() < 2 ) - return false; + if (pa.count() < 2) + return false; - QRect rect = QRect( pa.first(), pa.last() ); - rect = rect.normalized(); + QRect rect = QRect(pa.first(), pa.last()); + rect = rect.normalized(); - const int minSize = 2; - if ( rect.width() < minSize && rect.height() < minSize ) - return false; + const int minSize = 2; + if (rect.width() < minSize && rect.height() < minSize) + return false; - const int minZoomSize = 11; + const int minZoomSize = 11; - const QPoint center = rect.center(); - rect.setSize( rect.size().expandedTo( QSize( minZoomSize, minZoomSize ) ) ); - rect.moveCenter( center ); + const QPoint center = rect.center(); + rect.setSize(rect.size().expandedTo(QSize(minZoomSize, minZoomSize))); + rect.moveCenter(center); - pa.resize( 2 ); - pa[0] = rect.topLeft(); - pa[1] = rect.bottomRight(); + pa.resize(2); + pa[0] = rect.topLeft(); + pa[1] = rect.bottomRight(); - return true; + return true; } /*! @@ -596,8 +596,8 @@ bool QwtPlotZoomer::accept( QPolygon& pa ) const */ QSizeF QwtPlotZoomer::minZoomSize() const { - return QSizeF( m_data->zoomStack[0].width() / 10e4, - m_data->zoomStack[0].height() / 10e4 ); + return QSizeF(m_data->zoomStack[0].width() / 10e4, + m_data->zoomStack[0].height() / 10e4); } /*! @@ -608,26 +608,24 @@ QSizeF QwtPlotZoomer::minZoomSize() const */ void QwtPlotZoomer::begin() { - if ( m_data->maxStackDepth >= 0 ) + if (m_data->maxStackDepth >= 0) + { + if (m_data->zoomRectIndex >= uint(m_data->maxStackDepth)) + return; + } + + const QSizeF minSize = minZoomSize(); + if (minSize.isValid()) + { + const QSizeF sz = m_data->zoomStack[m_data->zoomRectIndex].size() * 0.9999; + + if (minSize.width() >= sz.width() && minSize.height() >= sz.height()) { - if ( m_data->zoomRectIndex >= uint( m_data->maxStackDepth ) ) - return; + return; } + } - const QSizeF minSize = minZoomSize(); - if ( minSize.isValid() ) - { - const QSizeF sz = - m_data->zoomStack[m_data->zoomRectIndex].size() * 0.9999; - - if ( minSize.width() >= sz.width() && - minSize.height() >= sz.height() ) - { - return; - } - } - - QwtPlotPicker::begin(); + QwtPlotPicker::begin(); } /*! @@ -640,36 +638,36 @@ void QwtPlotZoomer::begin() \sa accept(), minZoomSize() \return True if the selection has been accepted, false otherwise */ -bool QwtPlotZoomer::end( bool ok ) +bool QwtPlotZoomer::end(bool ok) { - ok = QwtPlotPicker::end( ok ); - if ( !ok ) - return false; + ok = QwtPlotPicker::end(ok); + if (!ok) + return false; - QwtPlot* plot = QwtPlotZoomer::plot(); - if ( !plot ) - return false; + QwtPlot *plot = QwtPlotZoomer::plot(); + if (!plot) + return false; - const QPolygon& pa = selection(); - if ( pa.count() < 2 ) - return false; + const QPolygon &pa = selection(); + if (pa.count() < 2) + return false; - QRect rect = QRect( pa.first(), pa.last() ); - rect = rect.normalized(); + QRect rect = QRect(pa.first(), pa.last()); + rect = rect.normalized(); - const QwtScaleMap xMap = plot->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot->canvasMap( yAxis() ); + const QwtScaleMap xMap = plot->canvasMap(xAxis()); + const QwtScaleMap yMap = plot->canvasMap(yAxis()); - QRectF zoomRect = QwtScaleMap::invTransform( xMap, yMap, rect ).normalized(); + QRectF zoomRect = QwtScaleMap::invTransform(xMap, yMap, rect).normalized(); - zoomRect = qwtExpandedZoomRect( zoomRect, minZoomSize(), - xMap.transformation(), yMap.transformation() ); + zoomRect = qwtExpandedZoomRect(zoomRect, minZoomSize(), xMap.transformation(), + yMap.transformation()); - zoom( zoomRect ); + zoom(zoomRect); - return true; + return true; } #if QWT_MOC_INCLUDE -#include "moc_qwt_plot_zoomer.cpp" +# include "moc_qwt_plot_zoomer.cpp" #endif diff --git a/libs/qwt/src/qwt_plot_zoomer.h b/libs/qwt/src/qwt_plot_zoomer.h index eac7ce58..c73ca129 100644 --- a/libs/qwt/src/qwt_plot_zoomer.h +++ b/libs/qwt/src/qwt_plot_zoomer.h @@ -14,7 +14,8 @@ #include "qwt_plot_picker.h" class QSizeF; -template< typename T > class QStack; +template +class QStack; /*! \brief QwtPlotZoomer provides stacked zooming for a plot widget @@ -61,10 +62,10 @@ template< typename T > class QStack; \code zoomer = new QwtPlotZoomer( plot ); - zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier ); - zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier ); - zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home ); - \endcode + zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier + ); zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, + Qt::ShiftModifier ); zoomer->setKeyPattern( QwtEventPattern::KeyHome, + Qt::Key_Home ); \endcode QwtPlotZoomer is tailored for plots with one x and y axis, but it is allowed to attach a second QwtPlotZoomer ( without rubber band and tracker ) @@ -78,65 +79,64 @@ template< typename T > class QStack; class QWT_EXPORT QwtPlotZoomer : public QwtPlotPicker { - Q_OBJECT - public: - explicit QwtPlotZoomer( QWidget*, bool doReplot = true ); - explicit QwtPlotZoomer( QwtAxisId xAxis, QwtAxisId yAxis, - QWidget*, bool doReplot = true ); + Q_OBJECT +public: + explicit QwtPlotZoomer(QWidget *, bool doReplot = true); + explicit QwtPlotZoomer(QwtAxisId xAxis, QwtAxisId yAxis, QWidget *, + bool doReplot = true); - virtual ~QwtPlotZoomer(); + virtual ~QwtPlotZoomer(); - virtual void setZoomBase( bool doReplot = true ); - virtual void setZoomBase( const QRectF& ); + virtual void setZoomBase(bool doReplot = true); + virtual void setZoomBase(const QRectF &); - QRectF zoomBase() const; - QRectF zoomRect() const; + QRectF zoomBase() const; + QRectF zoomRect() const; - virtual void setAxes( QwtAxisId xAxis, QwtAxisId yAxis ) QWT_OVERRIDE; + virtual void setAxes(QwtAxisId xAxis, QwtAxisId yAxis) QWT_OVERRIDE; - void setMaxStackDepth( int ); - int maxStackDepth() const; + void setMaxStackDepth(int); + int maxStackDepth() const; - const QStack< QRectF >& zoomStack() const; - void setZoomStack( const QStack< QRectF >&, - int zoomRectIndex = -1 ); + const QStack &zoomStack() const; + void setZoomStack(const QStack &, int zoomRectIndex = -1); - uint zoomRectIndex() const; + uint zoomRectIndex() const; - public Q_SLOTS: - void moveBy( double dx, double dy ); - virtual void moveTo( const QPointF& ); +public Q_SLOTS: + void moveBy(double dx, double dy); + virtual void moveTo(const QPointF &); - virtual void zoom( const QRectF& ); - virtual void zoom( int offset ); + virtual void zoom(const QRectF &); + virtual void zoom(int offset); - Q_SIGNALS: - /*! - A signal emitting the zoomRect(), when the plot has been - zoomed in or out. +Q_SIGNALS: + /*! + A signal emitting the zoomRect(), when the plot has been + zoomed in or out. - \param rect Current zoom rectangle. - */ + \param rect Current zoom rectangle. + */ - void zoomed( const QRectF& rect ); + void zoomed(const QRectF &rect); - protected: - virtual void rescale(); +protected: + virtual void rescale(); - virtual QSizeF minZoomSize() const; + virtual QSizeF minZoomSize() const; - virtual void widgetMouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void widgetKeyPressEvent( QKeyEvent* ) QWT_OVERRIDE; + virtual void widgetMouseReleaseEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void widgetKeyPressEvent(QKeyEvent *) QWT_OVERRIDE; - virtual void begin() QWT_OVERRIDE; - virtual bool end( bool ok = true ) QWT_OVERRIDE; - virtual bool accept( QPolygon& ) const QWT_OVERRIDE; + virtual void begin() QWT_OVERRIDE; + virtual bool end(bool ok = true) QWT_OVERRIDE; + virtual bool accept(QPolygon &) const QWT_OVERRIDE; - private: - void init( bool doReplot ); +private: + void init(bool doReplot); - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_point_3d.cpp b/libs/qwt/src/qwt_point_3d.cpp index b722d5af..a38681dd 100644 --- a/libs/qwt/src/qwt_point_3d.cpp +++ b/libs/qwt/src/qwt_point_3d.cpp @@ -11,38 +11,37 @@ #if QT_VERSION >= 0x050200 -static QwtPoint3D qwtPointToPoint3D( const QPointF& point ) +static QwtPoint3D qwtPointToPoint3D(const QPointF &point) { - return QwtPoint3D( point ); + return QwtPoint3D(point); } #endif namespace { - static const struct RegisterQwtPoint3D - { - inline RegisterQwtPoint3D() - { - qRegisterMetaType< QwtPoint3D >(); +static const struct RegisterQwtPoint3D +{ + inline RegisterQwtPoint3D() + { + qRegisterMetaType(); #if QT_VERSION >= 0x050200 - QMetaType::registerConverter< QPointF, QwtPoint3D >( qwtPointToPoint3D ); + QMetaType::registerConverter(qwtPointToPoint3D); #endif - } - } qwtRegisterQwtPoint3D; -} + } +} qwtRegisterQwtPoint3D; +} // namespace #ifndef QT_NO_DEBUG_STREAM -#include +# include -QDebug operator<<( QDebug debug, const QwtPoint3D& point ) +QDebug operator<<(QDebug debug, const QwtPoint3D &point) { - debug.nospace() << "QwtPoint3D(" << point.x() - << "," << point.y() << "," << point.z() << ")"; - return debug.space(); + debug.nospace() << "QwtPoint3D(" << point.x() << "," << point.y() << "," + << point.z() << ")"; + return debug.space(); } #endif - diff --git a/libs/qwt/src/qwt_point_3d.h b/libs/qwt/src/qwt_point_3d.h index 4ce57445..1e441bf6 100644 --- a/libs/qwt/src/qwt_point_3d.h +++ b/libs/qwt/src/qwt_point_3d.h @@ -21,41 +21,41 @@ class QWT_EXPORT QwtPoint3D { - public: - QwtPoint3D(); - QwtPoint3D( double x, double y, double z ); - QwtPoint3D( const QPointF& ); +public: + QwtPoint3D(); + QwtPoint3D(double x, double y, double z); + QwtPoint3D(const QPointF &); - bool isNull() const; + bool isNull() const; - double x() const; - double y() const; - double z() const; + double x() const; + double y() const; + double z() const; - double& rx(); - double& ry(); - double& rz(); + double &rx(); + double &ry(); + double &rz(); - void setX( double x ); - void setY( double y ); - void setZ( double y ); + void setX(double x); + void setY(double y); + void setZ(double y); - QPointF toPoint() const; + QPointF toPoint() const; - bool operator==( const QwtPoint3D& ) const; - bool operator!=( const QwtPoint3D& ) const; + bool operator==(const QwtPoint3D &) const; + bool operator!=(const QwtPoint3D &) const; - private: - double m_x; - double m_y; - double m_z; +private: + double m_x; + double m_y; + double m_z; }; -Q_DECLARE_TYPEINFO( QwtPoint3D, Q_MOVABLE_TYPE ); -Q_DECLARE_METATYPE( QwtPoint3D ); +Q_DECLARE_TYPEINFO(QwtPoint3D, Q_MOVABLE_TYPE); +Q_DECLARE_METATYPE(QwtPoint3D); #ifndef QT_NO_DEBUG_STREAM -QWT_EXPORT QDebug operator<<( QDebug, const QwtPoint3D& ); +QWT_EXPORT QDebug operator<<(QDebug, const QwtPoint3D &); #endif /*! @@ -63,17 +63,17 @@ QWT_EXPORT QDebug operator<<( QDebug, const QwtPoint3D& ); \sa isNull() */ inline QwtPoint3D::QwtPoint3D() - : m_x( 0.0 ) - , m_y( 0.0 ) - , m_z( 0.0 ) + : m_x(0.0) + , m_y(0.0) + , m_z(0.0) { } //! Constructs a point with coordinates specified by x, y and z. -inline QwtPoint3D::QwtPoint3D( double x, double y, double z = 0.0 ) - : m_x( x ) - , m_y( y ) - , m_z( z ) +inline QwtPoint3D::QwtPoint3D(double x, double y, double z = 0.0) + : m_x(x) + , m_y(y) + , m_z(z) { } @@ -81,10 +81,10 @@ inline QwtPoint3D::QwtPoint3D( double x, double y, double z = 0.0 ) Constructs a point with x and y coordinates from a 2D point, and a z coordinate of 0. */ -inline QwtPoint3D::QwtPoint3D( const QPointF& other ) - : m_x( other.x() ) - , m_y( other.y() ) - , m_z( 0.0 ) +inline QwtPoint3D::QwtPoint3D(const QPointF &other) + : m_x(other.x()) + , m_y(other.y()) + , m_z(0.0) { } @@ -96,61 +96,61 @@ inline QwtPoint3D::QwtPoint3D( const QPointF& other ) */ inline bool QwtPoint3D::isNull() const { - return m_x == 0.0 && m_y == 0.0 && m_z == 0.0; + return m_x == 0.0 && m_y == 0.0 && m_z == 0.0; } //! \return The x-coordinate of the point. inline double QwtPoint3D::x() const { - return m_x; + return m_x; } //! \return The y-coordinate of the point. inline double QwtPoint3D::y() const { - return m_y; + return m_y; } //! \return The z-coordinate of the point. inline double QwtPoint3D::z() const { - return m_z; + return m_z; } //! \return A reference to the x-coordinate of the point. -inline double& QwtPoint3D::rx() +inline double &QwtPoint3D::rx() { - return m_x; + return m_x; } //! \return A reference to the y-coordinate of the point. -inline double& QwtPoint3D::ry() +inline double &QwtPoint3D::ry() { - return m_y; + return m_y; } //! \return A reference to the z-coordinate of the point. -inline double& QwtPoint3D::rz() +inline double &QwtPoint3D::rz() { - return m_z; + return m_z; } //! Sets the x-coordinate of the point to the value specified by x. -inline void QwtPoint3D::setX( double x ) +inline void QwtPoint3D::setX(double x) { - m_x = x; + m_x = x; } //! Sets the y-coordinate of the point to the value specified by y. -inline void QwtPoint3D::setY( double y ) +inline void QwtPoint3D::setY(double y) { - m_y = y; + m_y = y; } //! Sets the z-coordinate of the point to the value specified by z. -inline void QwtPoint3D::setZ( double z ) +inline void QwtPoint3D::setZ(double z) { - m_z = z; + m_z = z; } /*! @@ -158,19 +158,19 @@ inline void QwtPoint3D::setZ( double z ) */ inline QPointF QwtPoint3D::toPoint() const { - return QPointF( m_x, m_y ); + return QPointF(m_x, m_y); } //! \return True, if this point and other are equal; otherwise returns false. -inline bool QwtPoint3D::operator==( const QwtPoint3D& other ) const +inline bool QwtPoint3D::operator==(const QwtPoint3D &other) const { - return ( m_x == other.m_x ) && ( m_y == other.m_y ) && ( m_z == other.m_z ); + return (m_x == other.m_x) && (m_y == other.m_y) && (m_z == other.m_z); } //! \return True if this rect and other are different; otherwise returns false. -inline bool QwtPoint3D::operator!=( const QwtPoint3D& other ) const +inline bool QwtPoint3D::operator!=(const QwtPoint3D &other) const { - return !operator==( other ); + return !operator==(other); } #endif diff --git a/libs/qwt/src/qwt_point_data.cpp b/libs/qwt/src/qwt_point_data.cpp index ba537e67..21a34477 100644 --- a/libs/qwt/src/qwt_point_data.cpp +++ b/libs/qwt/src/qwt_point_data.cpp @@ -17,10 +17,10 @@ \sa setInterval(), setSize() */ -QwtSyntheticPointData::QwtSyntheticPointData( - int size, const QwtInterval& interval ) - : m_size( size ) - , m_interval( interval ) +QwtSyntheticPointData::QwtSyntheticPointData(int size, + const QwtInterval &interval) + : m_size(size) + , m_interval(interval) { } @@ -30,9 +30,9 @@ QwtSyntheticPointData::QwtSyntheticPointData( \param size Number of points \sa size(), setInterval() */ -void QwtSyntheticPointData::setSize( int size ) +void QwtSyntheticPointData::setSize(int size) { - m_size = size; + m_size = size; } /*! @@ -41,7 +41,7 @@ void QwtSyntheticPointData::setSize( int size ) */ int QwtSyntheticPointData::size() const { - return m_size; + return m_size; } /*! @@ -50,9 +50,9 @@ int QwtSyntheticPointData::size() const \param interval Interval \sa interval(), setSize() */ -void QwtSyntheticPointData::setInterval( const QwtInterval& interval ) +void QwtSyntheticPointData::setInterval(const QwtInterval &interval) { - m_interval = interval.normalized(); + m_interval = interval.normalized(); } /*! @@ -61,7 +61,7 @@ void QwtSyntheticPointData::setInterval( const QwtInterval& interval ) */ QwtInterval QwtSyntheticPointData::interval() const { - return m_interval; + return m_interval; } /*! @@ -75,11 +75,10 @@ QwtInterval QwtSyntheticPointData::interval() const \sa rectOfInterest() */ -void QwtSyntheticPointData::setRectOfInterest( const QRectF& rect ) +void QwtSyntheticPointData::setRectOfInterest(const QRectF &rect) { - m_rectOfInterest = rect; - m_intervalOfInterest = QwtInterval( - rect.left(), rect.right() ).normalized(); + m_rectOfInterest = rect; + m_intervalOfInterest = QwtInterval(rect.left(), rect.right()).normalized(); } /*! @@ -88,7 +87,7 @@ void QwtSyntheticPointData::setRectOfInterest( const QRectF& rect ) */ QRectF QwtSyntheticPointData::rectOfInterest() const { - return m_rectOfInterest; + return m_rectOfInterest; } /*! @@ -104,13 +103,12 @@ QRectF QwtSyntheticPointData::rectOfInterest() const */ QRectF QwtSyntheticPointData::boundingRect() const { - if ( m_size == 0 || - !( m_interval.isValid() || m_intervalOfInterest.isValid() ) ) - { - return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid - } + if (m_size == 0 || !(m_interval.isValid() || m_intervalOfInterest.isValid())) + { + return QRectF(1.0, 1.0, -2.0, -2.0); // something invalid + } - return qwtBoundingRect( *this ); + return qwtBoundingRect(*this); } /*! @@ -122,15 +120,15 @@ QRectF QwtSyntheticPointData::boundingRect() const \warning For invalid indices ( index < 0 || index >= size() ) (0, 0) is returned. */ -QPointF QwtSyntheticPointData::sample( int index ) const +QPointF QwtSyntheticPointData::sample(int index) const { - if ( index >= m_size ) - return QPointF( 0, 0 ); + if (index >= m_size) + return QPointF(0, 0); - const double xValue = x( index ); - const double yValue = y( xValue ); + const double xValue = x(index); + const double yValue = y(xValue); - return QPointF( xValue, yValue ); + return QPointF(xValue, yValue); } /*! @@ -145,17 +143,17 @@ QPointF QwtSyntheticPointData::sample( int index ) const \sa interval(), rectOfInterest(), y() */ -double QwtSyntheticPointData::x( uint index ) const +double QwtSyntheticPointData::x(uint index) const { - const QwtInterval& interval = m_interval.isValid() ? - m_interval : m_intervalOfInterest; + const QwtInterval &interval + = m_interval.isValid() ? m_interval : m_intervalOfInterest; - if ( !interval.isValid() ) - return 0.0; + if (!interval.isValid()) + return 0.0; - if ( m_size <= 1 ) - return interval.minValue(); + if (m_size <= 1) + return interval.minValue(); - const double dx = interval.width() / ( m_size - 1 ); - return interval.minValue() + index * dx; + const double dx = interval.width() / (m_size - 1); + return interval.minValue() + index * dx; } diff --git a/libs/qwt/src/qwt_point_data.h b/libs/qwt/src/qwt_point_data.h index 5e706c99..47a1582d 100644 --- a/libs/qwt/src/qwt_point_data.h +++ b/libs/qwt/src/qwt_point_data.h @@ -18,43 +18,43 @@ /*! \brief Interface for iterating over two QVector objects. */ -template< typename T > +template class QwtPointArrayData : public QwtPointSeriesData { - public: - QwtPointArrayData( const QVector< T >& x, const QVector< T >& y ); - QwtPointArrayData( const T* x, const T* y, int size ); +public: + QwtPointArrayData(const QVector &x, const QVector &y); + QwtPointArrayData(const T *x, const T *y, int size); - virtual int size() const QWT_OVERRIDE; - virtual QPointF sample( int index ) const QWT_OVERRIDE; + virtual int size() const QWT_OVERRIDE; + virtual QPointF sample(int index) const QWT_OVERRIDE; - const QVector< T >& xData() const; - const QVector< T >& yData() const; + const QVector &xData() const; + const QVector &yData() const; - private: - QVector< T > m_x; - QVector< T > m_y; +private: + QVector m_x; + QVector m_y; }; /*! \brief Data class containing two pointers to memory blocks of T. */ -template< typename T > +template class QwtCPointerData : public QwtPointSeriesData { - public: - QwtCPointerData( const T* x, const T* y, int size ); +public: + QwtCPointerData(const T *x, const T *y, int size); - virtual int size() const QWT_OVERRIDE; - virtual QPointF sample( int index ) const QWT_OVERRIDE; + virtual int size() const QWT_OVERRIDE; + virtual QPointF sample(int index) const QWT_OVERRIDE; - const T* xData() const; - const T* yData() const; + const T *xData() const; + const T *yData() const; - private: - const T* m_x; - const T* m_y; - int m_size; +private: + const T *m_x; + const T *m_y; + int m_size; }; /*! @@ -63,20 +63,20 @@ class QwtCPointerData : public QwtPointSeriesData The memory contains the y coordinates, while the index is interpreted as x coordinate. */ -template< typename T > +template class QwtValuePointData : public QwtPointSeriesData { - public: - QwtValuePointData( const QVector< T >& y ); - QwtValuePointData( const T* y, int size ); +public: + QwtValuePointData(const QVector &y); + QwtValuePointData(const T *y, int size); - virtual int size() const QWT_OVERRIDE; - virtual QPointF sample( int index ) const QWT_OVERRIDE; + virtual int size() const QWT_OVERRIDE; + virtual QPointF sample(int index) const QWT_OVERRIDE; - const QVector< T >& yData() const; + const QVector &yData() const; - private: - QVector< T > m_y; +private: + QVector m_y; }; /*! @@ -85,20 +85,20 @@ class QwtValuePointData : public QwtPointSeriesData The memory contains the y coordinates, while the index is interpreted as x coordinate. */ -template< typename T > +template class QwtCPointerValueData : public QwtPointSeriesData { - public: - QwtCPointerValueData( const T* y, int size ); +public: + QwtCPointerValueData(const T *y, int size); - virtual int size() const QWT_OVERRIDE; - virtual QPointF sample( int index ) const QWT_OVERRIDE; + virtual int size() const QWT_OVERRIDE; + virtual QPointF sample(int index) const QWT_OVERRIDE; - const T* yData() const; + const T *yData() const; - private: - const T* m_y; - int m_size; +private: + const T *m_y; + int m_size; }; /*! @@ -156,36 +156,35 @@ class QwtCPointerValueData : public QwtPointSeriesData */ class QWT_EXPORT QwtSyntheticPointData : public QwtPointSeriesData { - public: - QwtSyntheticPointData( int size, - const QwtInterval& = QwtInterval() ); +public: + QwtSyntheticPointData(int size, const QwtInterval & = QwtInterval()); - void setSize( int size ); - virtual int size() const QWT_OVERRIDE; + void setSize(int size); + virtual int size() const QWT_OVERRIDE; - void setInterval( const QwtInterval& ); - QwtInterval interval() const; + void setInterval(const QwtInterval &); + QwtInterval interval() const; - virtual QRectF boundingRect() const QWT_OVERRIDE; - virtual QPointF sample( int index ) const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QPointF sample(int index) const QWT_OVERRIDE; - /*! - Calculate a y value for a x value + /*! + Calculate a y value for a x value - \param x x value - \return Corresponding y value - */ - virtual double y( double x ) const = 0; - virtual double x( uint index ) const; + \param x x value + \return Corresponding y value + */ + virtual double y(double x) const = 0; + virtual double x(uint index) const; - virtual void setRectOfInterest( const QRectF& ) QWT_OVERRIDE; - QRectF rectOfInterest() const; + virtual void setRectOfInterest(const QRectF &) QWT_OVERRIDE; + QRectF rectOfInterest() const; - private: - int m_size; - QwtInterval m_interval; - QRectF m_rectOfInterest; - QwtInterval m_intervalOfInterest; +private: + int m_size; + QwtInterval m_interval; + QRectF m_rectOfInterest; + QwtInterval m_intervalOfInterest; }; /*! @@ -196,11 +195,11 @@ class QWT_EXPORT QwtSyntheticPointData : public QwtPointSeriesData \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples() */ -template< typename T > -QwtPointArrayData< T >::QwtPointArrayData( - const QVector< T >& x, const QVector< T >& y ) - : m_x( x ) - , m_y( y ) +template +QwtPointArrayData::QwtPointArrayData(const QVector &x, + const QVector &y) + : m_x(x) + , m_y(y) { } @@ -212,21 +211,21 @@ QwtPointArrayData< T >::QwtPointArrayData( \param size Size of the x and y arrays \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples() */ -template< typename T > -QwtPointArrayData< T >::QwtPointArrayData( const T* x, const T* y, int size ) +template +QwtPointArrayData::QwtPointArrayData(const T *x, const T *y, int size) { - m_x.resize( size ); - std::memcpy( m_x.data(), x, size * sizeof( T ) ); + m_x.resize(size); + std::memcpy(m_x.data(), x, size * sizeof(T)); - m_y.resize( size ); - std::memcpy( m_y.data(), y, size * sizeof( T ) ); + m_y.resize(size); + std::memcpy(m_y.data(), y, size * sizeof(T)); } //! \return Size of the data set -template< typename T > -int QwtPointArrayData< T >::size() const +template +int QwtPointArrayData::size() const { - return qMin( m_x.size(), m_y.size() ); + return qMin(m_x.size(), m_y.size()); } /*! @@ -235,24 +234,24 @@ int QwtPointArrayData< T >::size() const \param index Index \return Sample at position i */ -template< typename T > -QPointF QwtPointArrayData< T >::sample( int index ) const +template +QPointF QwtPointArrayData::sample(int index) const { - return QPointF( m_x[int( index )], m_y[int( index )] ); + return QPointF(m_x[int(index)], m_y[int(index)]); } //! \return Array of the x-values -template< typename T > -const QVector< T >& QwtPointArrayData< T >::xData() const +template +const QVector &QwtPointArrayData::xData() const { - return m_x; + return m_x; } //! \return Array of the y-values -template< typename T > -const QVector< T >& QwtPointArrayData< T >::yData() const +template +const QVector &QwtPointArrayData::yData() const { - return m_y; + return m_y; } /*! @@ -262,9 +261,9 @@ const QVector< T >& QwtPointArrayData< T >::yData() const \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples() */ -template< typename T > -QwtValuePointData< T >::QwtValuePointData( const QVector< T >& y ) - : m_y( y ) +template +QwtValuePointData::QwtValuePointData(const QVector &y) + : m_y(y) { } @@ -275,18 +274,18 @@ QwtValuePointData< T >::QwtValuePointData( const QVector< T >& y ) \param size Size of the x and y arrays \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples() */ -template< typename T > -QwtValuePointData< T >::QwtValuePointData( const T* y, int size ) +template +QwtValuePointData::QwtValuePointData(const T *y, int size) { - m_y.resize( size ); - std::memcpy( m_y.data(), y, size * sizeof( T ) ); + m_y.resize(size); + std::memcpy(m_y.data(), y, size * sizeof(T)); } //! \return Size of the data set -template< typename T > -int QwtValuePointData< T >::size() const +template +int QwtValuePointData::size() const { - return m_y.size(); + return m_y.size(); } /*! @@ -295,17 +294,17 @@ int QwtValuePointData< T >::size() const \param index Index \return Sample at position i */ -template< typename T > -QPointF QwtValuePointData< T >::sample( int index ) const +template +QPointF QwtValuePointData::sample(int index) const { - return QPointF( index, m_y[int( index )] ); + return QPointF(index, m_y[int(index)]); } //! \return Array of the y-values -template< typename T > -const QVector< T >& QwtValuePointData< T >::yData() const +template +const QVector &QwtValuePointData::yData() const { - return m_y; + return m_y; } /*! @@ -322,19 +321,19 @@ const QVector< T >& QwtValuePointData< T >::yData() const \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples() */ -template< typename T > -QwtCPointerData< T >::QwtCPointerData( const T* x, const T* y, int size ) - : m_x( x ) - , m_y( y ) - , m_size( size ) +template +QwtCPointerData::QwtCPointerData(const T *x, const T *y, int size) + : m_x(x) + , m_y(y) + , m_size(size) { } //! \return Size of the data set -template< typename T > -int QwtCPointerData< T >::size() const +template +int QwtCPointerData::size() const { - return m_size; + return m_size; } /*! @@ -343,24 +342,24 @@ int QwtCPointerData< T >::size() const \param index Index \return Sample at position i */ -template< typename T > -QPointF QwtCPointerData< T >::sample( int index ) const +template +QPointF QwtCPointerData::sample(int index) const { - return QPointF( m_x[int( index )], m_y[int( index )] ); + return QPointF(m_x[int(index)], m_y[int(index)]); } //! \return Array of the x-values -template< typename T > -const T* QwtCPointerData< T >::xData() const +template +const T *QwtCPointerData::xData() const { - return m_x; + return m_x; } //! \return Array of the y-values -template< typename T > -const T* QwtCPointerData< T >::yData() const +template +const T *QwtCPointerData::yData() const { - return m_y; + return m_y; } /*! @@ -376,18 +375,18 @@ const T* QwtCPointerData< T >::yData() const \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples() */ -template< typename T > -QwtCPointerValueData< T >::QwtCPointerValueData( const T* y, int size ) - : m_y( y ) - , m_size( size ) +template +QwtCPointerValueData::QwtCPointerValueData(const T *y, int size) + : m_y(y) + , m_size(size) { } //! \return Size of the data set -template< typename T > -int QwtCPointerValueData< T >::size() const +template +int QwtCPointerValueData::size() const { - return m_size; + return m_size; } /*! @@ -396,17 +395,17 @@ int QwtCPointerValueData< T >::size() const \param index Index \return Sample at position i */ -template< typename T > -QPointF QwtCPointerValueData< T >::sample( int index ) const +template +QPointF QwtCPointerValueData::sample(int index) const { - return QPointF( index, m_y[ int( index ) ] ); + return QPointF(index, m_y[int(index)]); } //! \return Array of the y-values -template< typename T > -const T* QwtCPointerValueData< T >::yData() const +template +const T *QwtCPointerValueData::yData() const { - return m_y; + return m_y; } #endif diff --git a/libs/qwt/src/qwt_point_mapper.cpp b/libs/qwt/src/qwt_point_mapper.cpp index f714f449..38a95054 100644 --- a/libs/qwt/src/qwt_point_mapper.cpp +++ b/libs/qwt/src/qwt_point_mapper.cpp @@ -22,537 +22,522 @@ #include #include -#if !defined( QT_NO_QFUTURE ) -#define QWT_USE_THREADS 1 +#if !defined(QT_NO_QFUTURE) +# define QWT_USE_THREADS 1 #endif -static QRectF qwtInvalidRect( 0.0, 0.0, -1.0, -1.0 ); +static QRectF qwtInvalidRect(0.0, 0.0, -1.0, -1.0); -static inline int qwtRoundValue( double value ) +static inline int qwtRoundValue(double value) { - return qRound( value ); + return qRound(value); } -static inline double qwtRoundValueF( double value ) +static inline double qwtRoundValueF(double value) { #if 1 - // MS Windows and at least IRIX does not have C99's nearbyint() function - return ( value >= 0.0 ) ? std::floor( value + 0.5 ) : std::ceil( value - 0.5 ); + // MS Windows and at least IRIX does not have C99's nearbyint() function + return (value >= 0.0) ? std::floor(value + 0.5) : std::ceil(value - 0.5); #else - return nearbyint( value ); + return nearbyint(value); #endif } -static Qt::Orientation qwtProbeOrientation( - const QwtSeriesData< QPointF >* series, int from, int to ) +static Qt::Orientation qwtProbeOrientation(const QwtSeriesData *series, + int from, int to) { - if ( to - from < 20 ) - { - // not enough points to "have an orientation" - return Qt::Horizontal; - } - - const double x0 = series->sample( from ).x(); - const double xn = series->sample( to ).x(); - - if ( x0 == xn ) - return Qt::Vertical; - - const int step = ( to - from ) / 10; - const bool isIncreasing = xn > x0; - - double x1 = x0; - for ( int i = from + step; i < to; i += step ) - { - const double x2 = series->sample( i ).x(); - if ( x2 != x1 ) - { - if ( ( x2 > x1 ) != isIncreasing ) - return Qt::Vertical; - } - - x1 = x2; - } - + if (to - from < 20) + { + // not enough points to "have an orientation" return Qt::Horizontal; + } + + const double x0 = series->sample(from).x(); + const double xn = series->sample(to).x(); + + if (x0 == xn) + return Qt::Vertical; + + const int step = (to - from) / 10; + const bool isIncreasing = xn > x0; + + double x1 = x0; + for (int i = from + step; i < to; i += step) + { + const double x2 = series->sample(i).x(); + if (x2 != x1) + { + if ((x2 > x1) != isIncreasing) + return Qt::Vertical; + } + + x1 = x2; + } + + return Qt::Horizontal; } namespace { - template< class Polygon, class Point > - class QwtPolygonQuadrupelX +template +class QwtPolygonQuadrupelX +{ +public: + inline void start(int x, int y) + { + x0 = x; + y1 = yMin = yMax = y2 = y; + } + + inline bool append(int x, int y) + { + if (x0 != x) + return false; + + if (y < yMin) + yMin = y; + else if (y > yMax) + yMax = y; + + y2 = y; + + return true; + } + + inline void flush(Polygon &polyline) + { + appendTo(y1, polyline); + + if (y2 > y1) + qSwap(yMin, yMax); + + if (yMax != y1) + appendTo(yMax, polyline); + + if (yMin != yMax) + appendTo(yMin, polyline); + + if (y2 != yMin) + appendTo(y2, polyline); + } + +private: + inline void appendTo(int y, Polygon &polyline) { polyline += Point(x0, y); } + +private: + int x0, y1, yMin, yMax, y2; +}; + +template +class QwtPolygonQuadrupelY +{ +public: + inline void start(int x, int y) + { + y0 = y; + x1 = xMin = xMax = x2 = x; + } + + inline bool append(int x, int y) + { + if (y0 != y) + return false; + + if (x < xMin) + xMin = x; + else if (x > xMax) + xMax = x; + + x2 = x; + + return true; + } + + inline void flush(Polygon &polyline) + { + appendTo(x1, polyline); + + if (x2 > x1) + qSwap(xMin, xMax); + + if (xMax != x1) + appendTo(xMax, polyline); + + if (xMin != xMax) + appendTo(xMin, polyline); + + if (x2 != xMin) + appendTo(x2, polyline); + } + +private: + inline void appendTo(int x, Polygon &polyline) { polyline += Point(x, y0); } + + int y0, x1, xMin, xMax, x2; +}; +} // namespace + +template +static Polygon +qwtMapPointsQuad(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to) +{ + const QPointF sample0 = series->sample(from); + + PolygonQuadrupel q; + q.start(qwtRoundValue(xMap.transform(sample0.x())), + qwtRoundValue(yMap.transform(sample0.y()))); + + Polygon polyline; + for (int i = from; i <= to; i++) + { + const QPointF sample = series->sample(i); + + const int x = qwtRoundValue(xMap.transform(sample.x())); + const int y = qwtRoundValue(yMap.transform(sample.y())); + + if (!q.append(x, y)) { - public: - inline void start( int x, int y ) - { - x0 = x; - y1 = yMin = yMax = y2 = y; - } + q.flush(polyline); + q.start(x, y); + } + } + q.flush(polyline); - inline bool append( int x, int y ) - { - if ( x0 != x ) - return false; - - if ( y < yMin ) - yMin = y; - else if ( y > yMax ) - yMax = y; - - y2 = y; - - return true; - } - - inline void flush( Polygon& polyline ) - { - appendTo( y1, polyline ); - - if ( y2 > y1 ) - qSwap( yMin, yMax ); - - if ( yMax != y1 ) - appendTo( yMax, polyline ); - - if ( yMin != yMax ) - appendTo( yMin, polyline ); - - if ( y2 != yMin ) - appendTo( y2, polyline ); - } - - private: - inline void appendTo( int y, Polygon& polyline ) - { - polyline += Point( x0, y ); - } - - private: - int x0, y1, yMin, yMax, y2; - }; - - template< class Polygon, class Point > - class QwtPolygonQuadrupelY - { - public: - inline void start( int x, int y ) - { - y0 = y; - x1 = xMin = xMax = x2 = x; - } - - inline bool append( int x, int y ) - { - if ( y0 != y ) - return false; - - if ( x < xMin ) - xMin = x; - else if ( x > xMax ) - xMax = x; - - x2 = x; - - return true; - } - - inline void flush( Polygon& polyline ) - { - appendTo( x1, polyline ); - - if ( x2 > x1 ) - qSwap( xMin, xMax ); - - if ( xMax != x1 ) - appendTo( xMax, polyline ); - - if ( xMin != xMax ) - appendTo( xMin, polyline ); - - if ( x2 != xMin ) - appendTo( x2, polyline ); - } - - private: - inline void appendTo( int x, Polygon& polyline ) - { - polyline += Point( x, y0 ); - } - - int y0, x1, xMin, xMax, x2; - }; + return polyline; } -template< class Polygon, class Point, class PolygonQuadrupel > -static Polygon qwtMapPointsQuad( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) +template +static Polygon qwtMapPointsQuad(const Polygon &polyline) { - const QPointF sample0 = series->sample( from ); - - PolygonQuadrupel q; - q.start( qwtRoundValue( xMap.transform( sample0.x() ) ), - qwtRoundValue( yMap.transform( sample0.y() ) ) ); - - Polygon polyline; - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = series->sample( i ); - - const int x = qwtRoundValue( xMap.transform( sample.x() ) ); - const int y = qwtRoundValue( yMap.transform( sample.y() ) ); - - if ( !q.append( x, y ) ) - { - q.flush( polyline ); - q.start( x, y ); - } - } - q.flush( polyline ); + const int numPoints = polyline.size(); + if (numPoints < 3) return polyline; + + const Point *points = polyline.constData(); + + Polygon polylineXY; + + PolygonQuadrupel q; + q.start(points[0].x(), points[0].y()); + + for (int i = 0; i < numPoints; i++) + { + const int x = points[i].x(); + const int y = points[i].y(); + + if (!q.append(x, y)) + { + q.flush(polylineXY); + q.start(x, y); + } + } + q.flush(polylineXY); + + return polylineXY; } -template< class Polygon, class Point, class PolygonQuadrupel > -static Polygon qwtMapPointsQuad( const Polygon& polyline ) +template +static Polygon +qwtMapPointsQuad(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to) { - const int numPoints = polyline.size(); - - if ( numPoints < 3 ) - return polyline; - - const Point* points = polyline.constData(); - - Polygon polylineXY; - - PolygonQuadrupel q; - q.start( points[0].x(), points[0].y() ); - - for ( int i = 0; i < numPoints; i++ ) - { - const int x = points[i].x(); - const int y = points[i].y(); - - if ( !q.append( x, y ) ) - { - q.flush( polylineXY ); - q.start( x, y ); - } - } - q.flush( polylineXY ); - - return polylineXY; -} - - -template< class Polygon, class Point > -static Polygon qwtMapPointsQuad( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) -{ - Polygon polyline; - if ( from > to ) - return polyline; - - /* - probing some values, to decide if it is better - to start with x or y coordinates - */ - const Qt::Orientation orientation = qwtProbeOrientation( series, from, to ); - - if ( orientation == Qt::Horizontal ) - { - polyline = qwtMapPointsQuad< Polygon, Point, - QwtPolygonQuadrupelY< Polygon, Point > >( xMap, yMap, series, from, to ); - - polyline = qwtMapPointsQuad< Polygon, Point, - QwtPolygonQuadrupelX< Polygon, Point > >( polyline ); - } - else - { - polyline = qwtMapPointsQuad< Polygon, Point, - QwtPolygonQuadrupelX< Polygon, Point > >( xMap, yMap, series, from, to ); - - polyline = qwtMapPointsQuad< Polygon, Point, - QwtPolygonQuadrupelY< Polygon, Point > >( polyline ); - } - + Polygon polyline; + if (from > to) return polyline; + + /* + probing some values, to decide if it is better + to start with x or y coordinates + */ + const Qt::Orientation orientation = qwtProbeOrientation(series, from, to); + + if (orientation == Qt::Horizontal) + { + polyline = qwtMapPointsQuad>( + xMap, yMap, series, from, to); + + polyline = qwtMapPointsQuad>(polyline); + } + else + { + polyline = qwtMapPointsQuad>( + xMap, yMap, series, from, to); + + polyline = qwtMapPointsQuad>(polyline); + } + + return polyline; } // Helper class to work around the 5 parameters // limitation of QtConcurrent::run() class QwtDotsCommand { - public: - const QwtSeriesData< QPointF >* series; - int from; - int to; - QRgb rgb; +public: + const QwtSeriesData *series; + int from; + int to; + QRgb rgb; }; -static void qwtRenderDots( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtDotsCommand& command, const QPoint& pos, QImage* image ) +static void qwtRenderDots(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtDotsCommand &command, const QPoint &pos, + QImage *image) { - const QRgb rgb = command.rgb; - QRgb* bits = reinterpret_cast< QRgb* >( image->bits() ); + const QRgb rgb = command.rgb; + QRgb *bits = reinterpret_cast(image->bits()); - const int w = image->width(); - const int h = image->height(); + const int w = image->width(); + const int h = image->height(); - const int x0 = pos.x(); - const int y0 = pos.y(); + const int x0 = pos.x(); + const int y0 = pos.y(); - for ( int i = command.from; i <= command.to; i++ ) - { - const QPointF sample = command.series->sample( i ); + for (int i = command.from; i <= command.to; i++) + { + const QPointF sample = command.series->sample(i); - const int x = static_cast< int >( xMap.transform( sample.x() ) + 0.5 ) - x0; - const int y = static_cast< int >( yMap.transform( sample.y() ) + 0.5 ) - y0; + const int x = static_cast(xMap.transform(sample.x()) + 0.5) - x0; + const int y = static_cast(yMap.transform(sample.y()) + 0.5) - y0; - if ( x >= 0 && x < w && y >= 0 && y < h ) - bits[ y * w + x ] = rgb; - } + if (x >= 0 && x < w && y >= 0 && y < h) + bits[y * w + x] = rgb; + } } // some functors, so that the compile can inline struct QwtRoundI { - inline int operator()( double value ) const - { - return qwtRoundValue( value ); - } + inline int operator()(double value) const { return qwtRoundValue(value); } }; struct QwtRoundF { - inline double operator()( double value ) const - { - return qwtRoundValueF( value ); - } + inline double operator()(double value) const { return qwtRoundValueF(value); } }; struct QwtNoRoundF { - inline double operator()( double value ) const - { - return value; - } + inline double operator()(double value) const { return value; } }; // mapping points without any filtering - beside checking // the bounding rectangle -template< class Polygon, class Point, class Round > -static inline Polygon qwtToPoints( - const QRectF& boundingRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, - int from, int to, Round round ) +template +static inline Polygon +qwtToPoints(const QRectF &boundingRect, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QwtSeriesData *series, + int from, int to, Round round) { - Polygon polyline( to - from + 1 ); - Point* points = polyline.data(); + Polygon polyline(to - from + 1); + Point *points = polyline.data(); - int numPoints = 0; + int numPoints = 0; - if ( boundingRect.isValid() ) + if (boundingRect.isValid()) + { + // iterating over all values + // filtering out all points outside of + // the bounding rectangle + + for (int i = from; i <= to; i++) { - // iterating over all values - // filtering out all points outside of - // the bounding rectangle + const QPointF sample = series->sample(i); - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = series->sample( i ); + const double x = xMap.transform(sample.x()); + const double y = yMap.transform(sample.y()); - const double x = xMap.transform( sample.x() ); - const double y = yMap.transform( sample.y() ); + if (boundingRect.contains(x, y)) + { + points[numPoints].rx() = round(x); + points[numPoints].ry() = round(y); - if ( boundingRect.contains( x, y ) ) - { - points[ numPoints ].rx() = round( x ); - points[ numPoints ].ry() = round( y ); - - numPoints++; - } - } - - polyline.resize( numPoints ); - } - else - { - // simply iterating over all values - // without any filtering - - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = series->sample( i ); - - const double x = xMap.transform( sample.x() ); - const double y = yMap.transform( sample.y() ); - - points[ numPoints ].rx() = round( x ); - points[ numPoints ].ry() = round( y ); - - numPoints++; - } + numPoints++; + } } - return polyline; + polyline.resize(numPoints); + } + else + { + // simply iterating over all values + // without any filtering + + for (int i = from; i <= to; i++) + { + const QPointF sample = series->sample(i); + + const double x = xMap.transform(sample.x()); + const double y = yMap.transform(sample.y()); + + points[numPoints].rx() = round(x); + points[numPoints].ry() = round(y); + + numPoints++; + } + } + + return polyline; } -static inline QPolygon qwtToPointsI( - const QRectF& boundingRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, - int from, int to ) +static inline QPolygon qwtToPointsI(const QRectF &boundingRect, + const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, + int from, int to) { - return qwtToPoints< QPolygon, QPoint >( - boundingRect, xMap, yMap, series, from, to, QwtRoundI() ); + return qwtToPoints(boundingRect, xMap, yMap, series, from, + to, QwtRoundI()); } -template< class Round > -static inline QPolygonF qwtToPointsF( - const QRectF& boundingRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, - int from, int to, Round round ) +template +static inline QPolygonF +qwtToPointsF(const QRectF &boundingRect, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QwtSeriesData *series, + int from, int to, Round round) { - return qwtToPoints< QPolygonF, QPointF >( - boundingRect, xMap, yMap, series, from, to, round ); + return qwtToPoints(boundingRect, xMap, yMap, series, from, + to, round); } // Mapping points with filtering out consecutive // points mapped to the same position -template< class Polygon, class Point, class Round > -static inline Polygon qwtToPolylineFiltered( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, - int from, int to, Round round ) +template +static inline Polygon +qwtToPolylineFiltered(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to, + Round round) { - // in curves with many points consecutive points - // are often mapped to the same position. As this might - // result in empty lines ( or symbols hidden by others ) - // we try to filter them out + // in curves with many points consecutive points + // are often mapped to the same position. As this might + // result in empty lines ( or symbols hidden by others ) + // we try to filter them out - Polygon polyline( to - from + 1 ); - Point* points = polyline.data(); + Polygon polyline(to - from + 1); + Point *points = polyline.data(); - const QPointF sample0 = series->sample( from ); + const QPointF sample0 = series->sample(from); - points[0].rx() = round( xMap.transform( sample0.x() ) ); - points[0].ry() = round( yMap.transform( sample0.y() ) ); + points[0].rx() = round(xMap.transform(sample0.x())); + points[0].ry() = round(yMap.transform(sample0.y())); - int pos = 0; - for ( int i = from + 1; i <= to; i++ ) + int pos = 0; + for (int i = from + 1; i <= to; i++) + { + const QPointF sample = series->sample(i); + + const Point p(round(xMap.transform(sample.x())), + round(yMap.transform(sample.y()))); + + if (points[pos] != p) + points[++pos] = p; + } + + polyline.resize(pos + 1); + return polyline; +} + +static inline QPolygon +qwtToPolylineFilteredI(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to) +{ + return qwtToPolylineFiltered(xMap, yMap, series, from, to, + QwtRoundI()); +} + +template +static inline QPolygonF +qwtToPolylineFilteredF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to, + Round round) +{ + return qwtToPolylineFiltered(xMap, yMap, series, from, to, + round); +} + +template +static inline Polygon +qwtToPointsFiltered(const QRectF &boundingRect, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to) +{ + // F.e. in scatter plots ( no connecting lines ) we + // can sort out all duplicates ( not only consecutive points ) + + Polygon polygon(to - from + 1); + Point *points = polygon.data(); + + QwtPixelMatrix pixelMatrix(boundingRect.toAlignedRect()); + + int numPoints = 0; + for (int i = from; i <= to; i++) + { + const QPointF sample = series->sample(i); + + const int x = qwtRoundValue(xMap.transform(sample.x())); + const int y = qwtRoundValue(yMap.transform(sample.y())); + + if (pixelMatrix.testAndSetPixel(x, y, true) == false) { - const QPointF sample = series->sample( i ); + points[numPoints].rx() = x; + points[numPoints].ry() = y; - const Point p( round( xMap.transform( sample.x() ) ), - round( yMap.transform( sample.y() ) ) ); - - if ( points[pos] != p ) - points[++pos] = p; + numPoints++; } + } - polyline.resize( pos + 1 ); - return polyline; + polygon.resize(numPoints); + return polygon; } -static inline QPolygon qwtToPolylineFilteredI( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, - int from, int to ) +static inline QPolygon +qwtToPointsFilteredI(const QRectF &boundingRect, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to) { - return qwtToPolylineFiltered< QPolygon, QPoint >( - xMap, yMap, series, from, to, QwtRoundI() ); + return qwtToPointsFiltered(boundingRect, xMap, yMap, series, + from, to); } -template< class Round > -static inline QPolygonF qwtToPolylineFilteredF( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, - int from, int to, Round round ) +static inline QPolygonF +qwtToPointsFilteredF(const QRectF &boundingRect, const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to) { - return qwtToPolylineFiltered< QPolygonF, QPointF >( - xMap, yMap, series, from, to, round ); -} - -template< class Polygon, class Point > -static inline Polygon qwtToPointsFiltered( - const QRectF& boundingRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) -{ - // F.e. in scatter plots ( no connecting lines ) we - // can sort out all duplicates ( not only consecutive points ) - - Polygon polygon( to - from + 1 ); - Point* points = polygon.data(); - - QwtPixelMatrix pixelMatrix( boundingRect.toAlignedRect() ); - - int numPoints = 0; - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = series->sample( i ); - - const int x = qwtRoundValue( xMap.transform( sample.x() ) ); - const int y = qwtRoundValue( yMap.transform( sample.y() ) ); - - if ( pixelMatrix.testAndSetPixel( x, y, true ) == false ) - { - points[ numPoints ].rx() = x; - points[ numPoints ].ry() = y; - - numPoints++; - } - } - - polygon.resize( numPoints ); - return polygon; -} - -static inline QPolygon qwtToPointsFilteredI( - const QRectF& boundingRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) -{ - return qwtToPointsFiltered< QPolygon, QPoint >( - boundingRect, xMap, yMap, series, from, to ); -} - -static inline QPolygonF qwtToPointsFilteredF( - const QRectF& boundingRect, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) -{ - return qwtToPointsFiltered< QPolygonF, QPointF >( - boundingRect, xMap, yMap, series, from, to ); + return qwtToPointsFiltered(boundingRect, xMap, yMap, + series, from, to); } class QwtPointMapper::PrivateData { - public: - PrivateData() - : boundingRect( qwtInvalidRect ) - { - } +public: + PrivateData() + : boundingRect(qwtInvalidRect) + { + } - QRectF boundingRect; - QwtPointMapper::TransformationFlags flags; + QRectF boundingRect; + QwtPointMapper::TransformationFlags flags; }; //! Constructor QwtPointMapper::QwtPointMapper() { - m_data = new PrivateData(); + m_data = new PrivateData(); } //! Destructor QwtPointMapper::~QwtPointMapper() { - delete m_data; + delete m_data; } /*! @@ -561,9 +546,9 @@ QwtPointMapper::~QwtPointMapper() \param flags Flags \sa flags(), setFlag() */ -void QwtPointMapper::setFlags( TransformationFlags flags ) +void QwtPointMapper::setFlags(TransformationFlags flags) { - m_data->flags = flags; + m_data->flags = flags; } /*! @@ -572,7 +557,7 @@ void QwtPointMapper::setFlags( TransformationFlags flags ) */ QwtPointMapper::TransformationFlags QwtPointMapper::flags() const { - return m_data->flags; + return m_data->flags; } /*! @@ -583,12 +568,12 @@ QwtPointMapper::TransformationFlags QwtPointMapper::flags() const \sa flag(), setFlags() */ -void QwtPointMapper::setFlag( TransformationFlag flag, bool on ) +void QwtPointMapper::setFlag(TransformationFlag flag, bool on) { - if ( on ) - m_data->flags |= flag; - else - m_data->flags &= ~flag; + if (on) + m_data->flags |= flag; + else + m_data->flags &= ~flag; } /*! @@ -596,9 +581,9 @@ void QwtPointMapper::setFlag( TransformationFlag flag, bool on ) \param flag Flag type \sa setFlag(), setFlags() */ -bool QwtPointMapper::testFlag( TransformationFlag flag ) const +bool QwtPointMapper::testFlag(TransformationFlag flag) const { - return m_data->flags & flag; + return m_data->flags & flag; } /*! @@ -609,9 +594,9 @@ bool QwtPointMapper::testFlag( TransformationFlag flag ) const \param rect Bounding rectangle \sa boundingRect() */ -void QwtPointMapper::setBoundingRect( const QRectF& rect ) +void QwtPointMapper::setBoundingRect(const QRectF &rect) { - m_data->boundingRect = rect; + m_data->boundingRect = rect; } /*! @@ -620,7 +605,7 @@ void QwtPointMapper::setBoundingRect( const QRectF& rect ) */ QRectF QwtPointMapper::boundingRect() const { - return m_data->boundingRect; + return m_data->boundingRect; } /*! @@ -644,45 +629,46 @@ QRectF QwtPointMapper::boundingRect() const \return Translated polygon */ -QPolygonF QwtPointMapper::toPolygonF( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const +QPolygonF QwtPointMapper::toPolygonF(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, + int from, int to) const { - QPolygonF polyline; + QPolygonF polyline; - if ( m_data->flags & RoundPoints ) + if (m_data->flags & RoundPoints) + { + if (m_data->flags & WeedOutIntermediatePoints) { - if ( m_data->flags & WeedOutIntermediatePoints ) - { - polyline = qwtMapPointsQuad< QPolygonF, QPointF >( - xMap, yMap, series, from, to ); - } - else if ( m_data->flags & WeedOutPoints ) - { - polyline = qwtToPolylineFilteredF( - xMap, yMap, series, from, to, QwtRoundF() ); - } - else - { - polyline = qwtToPointsF( qwtInvalidRect, - xMap, yMap, series, from, to, QwtRoundF() ); - } + polyline + = qwtMapPointsQuad(xMap, yMap, series, from, to); + } + else if (m_data->flags & WeedOutPoints) + { + polyline + = qwtToPolylineFilteredF(xMap, yMap, series, from, to, QwtRoundF()); } else { - if ( m_data->flags & WeedOutPoints ) - { - polyline = qwtToPolylineFilteredF( - xMap, yMap, series, from, to, QwtNoRoundF() ); - } - else - { - polyline = qwtToPointsF( qwtInvalidRect, - xMap, yMap, series, from, to, QwtNoRoundF() ); - } + polyline = qwtToPointsF(qwtInvalidRect, xMap, yMap, series, from, to, + QwtRoundF()); } + } + else + { + if (m_data->flags & WeedOutPoints) + { + polyline + = qwtToPolylineFilteredF(xMap, yMap, series, from, to, QwtNoRoundF()); + } + else + { + polyline = qwtToPointsF(qwtInvalidRect, xMap, yMap, series, from, to, + QwtNoRoundF()); + } + } - return polyline; + return polyline; } /*! @@ -699,30 +685,28 @@ QPolygonF QwtPointMapper::toPolygonF( \return Translated polygon */ -QPolygon QwtPointMapper::toPolygon( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const +QPolygon QwtPointMapper::toPolygon(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, + int from, int to) const { - QPolygon polyline; + QPolygon polyline; - if ( m_data->flags & WeedOutIntermediatePoints ) - { - // TODO WeedOutIntermediatePointsY ... - polyline = qwtMapPointsQuad< QPolygon, QPoint >( - xMap, yMap, series, from, to ); - } - else if ( m_data->flags & WeedOutPoints ) - { - polyline = qwtToPolylineFilteredI( - xMap, yMap, series, from, to ); - } - else - { - polyline = qwtToPointsI( - qwtInvalidRect, xMap, yMap, series, from, to ); - } + if (m_data->flags & WeedOutIntermediatePoints) + { + // TODO WeedOutIntermediatePointsY ... + polyline = qwtMapPointsQuad(xMap, yMap, series, from, to); + } + else if (m_data->flags & WeedOutPoints) + { + polyline = qwtToPolylineFilteredI(xMap, yMap, series, from, to); + } + else + { + polyline = qwtToPointsI(qwtInvalidRect, xMap, yMap, series, from, to); + } - return polyline; + return polyline; } /*! @@ -756,55 +740,56 @@ QPolygon QwtPointMapper::toPolygon( \return Translated polygon */ -QPolygonF QwtPointMapper::toPointsF( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const +QPolygonF QwtPointMapper::toPointsF(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, + int from, int to) const { - QPolygonF points; + QPolygonF points; - if ( m_data->flags & WeedOutPoints ) + if (m_data->flags & WeedOutPoints) + { + if (m_data->flags & RoundPoints) { - if ( m_data->flags & RoundPoints ) - { - if ( m_data->boundingRect.isValid() ) - { - points = qwtToPointsFilteredF( m_data->boundingRect, - xMap, yMap, series, from, to ); - } - else - { - // without a bounding rectangle all we can - // do is to filter out duplicates of - // consecutive points + if (m_data->boundingRect.isValid()) + { + points = qwtToPointsFilteredF(m_data->boundingRect, xMap, yMap, series, + from, to); + } + else + { + // without a bounding rectangle all we can + // do is to filter out duplicates of + // consecutive points - points = qwtToPolylineFilteredF( - xMap, yMap, series, from, to, QwtRoundF() ); - } - } - else - { - // when rounding is not allowed we can't use - // qwtToPointsFilteredF - - points = qwtToPolylineFilteredF( - xMap, yMap, series, from, to, QwtNoRoundF() ); - } + points + = qwtToPolylineFilteredF(xMap, yMap, series, from, to, QwtRoundF()); + } } else { - if ( m_data->flags & RoundPoints ) - { - points = qwtToPointsF( m_data->boundingRect, - xMap, yMap, series, from, to, QwtRoundF() ); - } - else - { - points = qwtToPointsF( m_data->boundingRect, - xMap, yMap, series, from, to, QwtNoRoundF() ); - } - } + // when rounding is not allowed we can't use + // qwtToPointsFilteredF - return points; + points + = qwtToPolylineFilteredF(xMap, yMap, series, from, to, QwtNoRoundF()); + } + } + else + { + if (m_data->flags & RoundPoints) + { + points = qwtToPointsF(m_data->boundingRect, xMap, yMap, series, from, to, + QwtRoundF()); + } + else + { + points = qwtToPointsF(m_data->boundingRect, xMap, yMap, series, from, to, + QwtNoRoundF()); + } + } + + return points; } /*! @@ -830,38 +815,36 @@ QPolygonF QwtPointMapper::toPointsF( \return Translated polygon */ -QPolygon QwtPointMapper::toPoints( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const +QPolygon QwtPointMapper::toPoints(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, + const QwtSeriesData *series, + int from, int to) const { - QPolygon points; + QPolygon points; - if ( m_data->flags & WeedOutPoints ) + if (m_data->flags & WeedOutPoints) + { + if (m_data->boundingRect.isValid()) { - if ( m_data->boundingRect.isValid() ) - { - points = qwtToPointsFilteredI( m_data->boundingRect, - xMap, yMap, series, from, to ); - } - else - { - // when we don't have the bounding rectangle all - // we can do is to filter out consecutive duplicates - - points = qwtToPolylineFilteredI( - xMap, yMap, series, from, to ); - } + points = qwtToPointsFilteredI(m_data->boundingRect, xMap, yMap, series, + from, to); } else { - points = qwtToPointsI( - m_data->boundingRect, xMap, yMap, series, from, to ); + // when we don't have the bounding rectangle all + // we can do is to filter out consecutive duplicates + + points = qwtToPolylineFilteredI(xMap, yMap, series, from, to); } + } + else + { + points = qwtToPointsI(m_data->boundingRect, xMap, yMap, series, from, to); + } - return points; + return points; } - /*! \brief Translate a series into a QImage @@ -880,90 +863,89 @@ QPolygon QwtPointMapper::toPoints( \return Image displaying the series */ -QImage QwtPointMapper::toImage( - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to, - const QPen& pen, bool antialiased, uint numThreads ) const +QImage QwtPointMapper::toImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, + int to, const QPen &pen, bool antialiased, + uint numThreads) const { - Q_UNUSED( antialiased ) + Q_UNUSED(antialiased) #if QWT_USE_THREADS - if ( numThreads == 0 ) - numThreads = QThread::idealThreadCount(); + if (numThreads == 0) + numThreads = QThread::idealThreadCount(); - if ( numThreads <= 0 ) - numThreads = 1; + if (numThreads <= 0) + numThreads = 1; #else - Q_UNUSED( numThreads ) + Q_UNUSED(numThreads) #endif - // a very special optimization for scatter plots - // where every sample is mapped to one pixel only. + // a very special optimization for scatter plots + // where every sample is mapped to one pixel only. - const QRect rect = m_data->boundingRect.toAlignedRect(); + const QRect rect = m_data->boundingRect.toAlignedRect(); - QImage image( rect.size(), QImage::Format_ARGB32 ); - image.fill( Qt::transparent ); + QImage image(rect.size(), QImage::Format_ARGB32); + image.fill(Qt::transparent); - if ( pen.width() <= 1 && pen.color().alpha() == 255 ) - { - QwtDotsCommand command; - command.series = series; - command.rgb = pen.color().rgba(); + if (pen.width() <= 1 && pen.color().alpha() == 255) + { + QwtDotsCommand command; + command.series = series; + command.rgb = pen.color().rgba(); #if QWT_USE_THREADS - const int numPoints = ( to - from + 1 ) / numThreads; + const int numPoints = (to - from + 1) / numThreads; - QList< QFuture< void > > futures; - for ( uint i = 0; i < numThreads; i++ ) - { - const QPoint pos = rect.topLeft(); + QList> futures; + for (uint i = 0; i < numThreads; i++) + { + const QPoint pos = rect.topLeft(); - const int index0 = from + i * numPoints; - if ( i == numThreads - 1 ) - { - command.from = index0; - command.to = to; - - qwtRenderDots( xMap, yMap, command, pos, &image ); - } - else - { - command.from = index0; - command.to = index0 + numPoints - 1; - - futures += QtConcurrent::run( &qwtRenderDots, - xMap, yMap, command, pos, &image ); - } - } - for ( int i = 0; i < futures.size(); i++ ) - futures[i].waitForFinished(); -#else - command.from = from; + const int index0 = from + i * numPoints; + if (i == numThreads - 1) + { + command.from = index0; command.to = to; - qwtRenderDots( xMap, yMap, command, rect.topLeft(), &image ); + qwtRenderDots(xMap, yMap, command, pos, &image); + } + else + { + command.from = index0; + command.to = index0 + numPoints - 1; + + futures += QtConcurrent::run(&qwtRenderDots, xMap, yMap, command, pos, + &image); + } + } + for (int i = 0; i < futures.size(); i++) + futures[i].waitForFinished(); +#else + command.from = from; + command.to = to; + + qwtRenderDots(xMap, yMap, command, rect.topLeft(), &image); #endif - } - else + } + else + { + // fallback implementation: to be replaced later by + // setting the pixels of the image like above, TODO ... + + QPainter painter(&image); + painter.setPen(pen); + painter.setRenderHint(QPainter::Antialiasing, antialiased); + + const int chunkSize = 1000; + for (int i = from; i <= to; i += chunkSize) { - // fallback implementation: to be replaced later by - // setting the pixels of the image like above, TODO ... + const int indexTo = qMin(i + chunkSize - 1, to); + const QPolygon points = toPoints(xMap, yMap, series, i, indexTo); - QPainter painter( &image ); - painter.setPen( pen ); - painter.setRenderHint( QPainter::Antialiasing, antialiased ); - - const int chunkSize = 1000; - for ( int i = from; i <= to; i += chunkSize ) - { - const int indexTo = qMin( i + chunkSize - 1, to ); - const QPolygon points = toPoints( - xMap, yMap, series, i, indexTo ); - - painter.drawPoints( points ); - } + painter.drawPoints(points); } + } - return image; + return image; } diff --git a/libs/qwt/src/qwt_point_mapper.h b/libs/qwt/src/qwt_point_mapper.h index 8ce4be7b..41e64e7b 100644 --- a/libs/qwt/src/qwt_point_mapper.h +++ b/libs/qwt/src/qwt_point_mapper.h @@ -13,7 +13,8 @@ #include "qwt_global.h" class QwtScaleMap; -template< typename T > class QwtSeriesData; +template +class QwtSeriesData; class QPolygonF; class QPointF; class QRectF; @@ -31,80 +32,84 @@ class QImage; */ class QWT_EXPORT QwtPointMapper { - public: +public: + /*! + \brief Flags affecting the transformation process + \sa setFlag(), setFlags() + */ + enum TransformationFlag + { + //! Round points to integer values + RoundPoints = 0x01, + /*! - \brief Flags affecting the transformation process - \sa setFlag(), setFlags() + Try to remove points, that are translated to the + same position. */ - enum TransformationFlag - { - //! Round points to integer values - RoundPoints = 0x01, + WeedOutPoints = 0x02, - /*! - Try to remove points, that are translated to the - same position. - */ - WeedOutPoints = 0x02, + /*! + An even more aggressive weeding algorithm, that + can be used in toPolygon(). - /*! - An even more aggressive weeding algorithm, that - can be used in toPolygon(). + A consecutive chunk of points being mapped to the + same x coordinate is reduced to 4 points: - A consecutive chunk of points being mapped to the - same x coordinate is reduced to 4 points: + - first point + - point with the minimum y coordinate + - point with the maximum y coordinate + - last point - - first point - - point with the minimum y coordinate - - point with the maximum y coordinate - - last point + In the worst case ( first and last points are never one of the extremes ) + the number of points will be 4 times the width. - In the worst case ( first and last points are never one of the extremes ) - the number of points will be 4 times the width. + As the algorithm is fast it can be used inside of + a polyline render cycle. + */ + WeedOutIntermediatePoints = 0x04 + }; - As the algorithm is fast it can be used inside of - a polyline render cycle. - */ - WeedOutIntermediatePoints = 0x04 - }; + Q_DECLARE_FLAGS(TransformationFlags, TransformationFlag) - Q_DECLARE_FLAGS( TransformationFlags, TransformationFlag ) + QwtPointMapper(); + ~QwtPointMapper(); - QwtPointMapper(); - ~QwtPointMapper(); + void setFlags(TransformationFlags); + TransformationFlags flags() const; - void setFlags( TransformationFlags ); - TransformationFlags flags() const; + void setFlag(TransformationFlag, bool on = true); + bool testFlag(TransformationFlag) const; - void setFlag( TransformationFlag, bool on = true ); - bool testFlag( TransformationFlag ) const; + void setBoundingRect(const QRectF &); + QRectF boundingRect() const; - void setBoundingRect( const QRectF& ); - QRectF boundingRect() const; + QPolygonF toPolygonF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, + int to) const; - QPolygonF toPolygonF( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const; + QPolygon toPolygon(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, + int to) const; - QPolygon toPolygon( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const; + QPolygon toPoints(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, + int to) const; - QPolygon toPoints( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const; + QPolygonF toPointsF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, + int to) const; - QPolygonF toPointsF( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to ) const; + QImage toImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QwtSeriesData *series, int from, int to, + const QPen &, bool antialiased, uint numThreads) const; - QImage toImage( const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QwtSeriesData< QPointF >* series, int from, int to, - const QPen&, bool antialiased, uint numThreads ) const; +private: + Q_DISABLE_COPY(QwtPointMapper) - private: - Q_DISABLE_COPY(QwtPointMapper) - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPointMapper::TransformationFlags ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPointMapper::TransformationFlags) #endif diff --git a/libs/qwt/src/qwt_point_polar.cpp b/libs/qwt/src/qwt_point_polar.cpp index fdfd7123..7c5c2b05 100644 --- a/libs/qwt/src/qwt_point_polar.cpp +++ b/libs/qwt/src/qwt_point_polar.cpp @@ -11,29 +11,30 @@ #if QT_VERSION >= 0x050200 -static QwtPointPolar qwtPointToPolar( const QPointF& point ) +static QwtPointPolar qwtPointToPolar(const QPointF &point) { - return QwtPointPolar( point ); + return QwtPointPolar(point); } #endif namespace { - static const struct RegisterQwtPointPolar - { - inline RegisterQwtPointPolar() - { - qRegisterMetaType< QwtPointPolar >(); +static const struct RegisterQwtPointPolar +{ + inline RegisterQwtPointPolar() + { + qRegisterMetaType(); #if QT_VERSION >= 0x050200 - QMetaType::registerConverter< QPointF, QwtPointPolar >( qwtPointToPolar ); - QMetaType::registerConverter< QwtPointPolar, QPointF >( &QwtPointPolar::toPoint ); + QMetaType::registerConverter(qwtPointToPolar); + QMetaType::registerConverter( + &QwtPointPolar::toPoint); #endif - } + } - } qwtRegisterQwtPointPolar; -} +} qwtRegisterQwtPointPolar; +} // namespace /*! Convert and assign values from a point in Cartesian coordinates @@ -41,20 +42,20 @@ namespace \param p Point in Cartesian coordinates \sa setPoint(), toPoint() */ -QwtPointPolar::QwtPointPolar( const QPointF& p ) +QwtPointPolar::QwtPointPolar(const QPointF &p) { - m_radius = std::sqrt( qwtSqr( p.x() ) + qwtSqr( p.y() ) ); - m_azimuth = std::atan2( p.y(), p.x() ); + m_radius = std::sqrt(qwtSqr(p.x()) + qwtSqr(p.y())); + m_azimuth = std::atan2(p.y(), p.x()); } /*! Convert and assign values from a point in Cartesian coordinates \param p Point in Cartesian coordinates */ -void QwtPointPolar::setPoint( const QPointF& p ) +void QwtPointPolar::setPoint(const QPointF &p) { - m_radius = std::sqrt( qwtSqr( p.x() ) + qwtSqr( p.y() ) ); - m_azimuth = std::atan2( p.y(), p.x() ); + m_radius = std::sqrt(qwtSqr(p.x()) + qwtSqr(p.y())); + m_azimuth = std::atan2(p.y(), p.x()); } /*! @@ -67,13 +68,13 @@ void QwtPointPolar::setPoint( const QPointF& p ) */ QPointF QwtPointPolar::toPoint() const { - if ( m_radius <= 0.0 ) - return QPointF( 0.0, 0.0 ); + if (m_radius <= 0.0) + return QPointF(0.0, 0.0); - const double x = m_radius * std::cos( m_azimuth ); - const double y = m_radius * std::sin( m_azimuth ); + const double x = m_radius * std::cos(m_azimuth); + const double y = m_radius * std::sin(m_azimuth); - return QPointF( x, y ); + return QPointF(x, y); } /*! @@ -87,9 +88,9 @@ QPointF QwtPointPolar::toPoint() const \sa normalized() */ -bool QwtPointPolar::operator==( const QwtPointPolar& other ) const +bool QwtPointPolar::operator==(const QwtPointPolar &other) const { - return m_radius == other.m_radius && m_azimuth == other.m_azimuth; + return m_radius == other.m_radius && m_azimuth == other.m_azimuth; } /*! @@ -102,9 +103,9 @@ bool QwtPointPolar::operator==( const QwtPointPolar& other ) const \return True if the point is not equal to other; otherwise return false. \sa normalized() */ -bool QwtPointPolar::operator!=( const QwtPointPolar& other ) const +bool QwtPointPolar::operator!=(const QwtPointPolar &other) const { - return m_radius != other.m_radius || m_azimuth != other.m_azimuth; + return m_radius != other.m_radius || m_azimuth != other.m_azimuth; } /*! @@ -117,29 +118,28 @@ bool QwtPointPolar::operator!=( const QwtPointPolar& other ) const */ QwtPointPolar QwtPointPolar::normalized() const { - const double radius = qwtMaxF( m_radius, 0.0 ); + const double radius = qwtMaxF(m_radius, 0.0); - double azimuth = m_azimuth; - if ( azimuth < -2.0 * M_PI || azimuth >= 2 * M_PI ) - azimuth = std::fmod( m_azimuth, 2 * M_PI ); + double azimuth = m_azimuth; + if (azimuth < -2.0 * M_PI || azimuth >= 2 * M_PI) + azimuth = std::fmod(m_azimuth, 2 * M_PI); - if ( azimuth < 0.0 ) - azimuth += 2 * M_PI; + if (azimuth < 0.0) + azimuth += 2 * M_PI; - return QwtPointPolar( azimuth, radius ); + return QwtPointPolar(azimuth, radius); } #ifndef QT_NO_DEBUG_STREAM -#include +# include -QDebug operator<<( QDebug debug, const QwtPointPolar& point ) +QDebug operator<<(QDebug debug, const QwtPointPolar &point) { - debug.nospace() << "QwtPointPolar(" - << point.azimuth() << "," << point.radius() << ")"; + debug.nospace() << "QwtPointPolar(" << point.azimuth() << "," + << point.radius() << ")"; - return debug.space(); + return debug.space(); } #endif - diff --git a/libs/qwt/src/qwt_point_polar.h b/libs/qwt/src/qwt_point_polar.h index 13897a44..907f07a0 100644 --- a/libs/qwt/src/qwt_point_polar.h +++ b/libs/qwt/src/qwt_point_polar.h @@ -27,41 +27,41 @@ class QWT_EXPORT QwtPointPolar { - public: - QwtPointPolar(); - QwtPointPolar( double azimuth, double radius ); - QwtPointPolar( const QPointF& ); +public: + QwtPointPolar(); + QwtPointPolar(double azimuth, double radius); + QwtPointPolar(const QPointF &); - void setPoint( const QPointF& ); - QPointF toPoint() const; + void setPoint(const QPointF &); + QPointF toPoint() const; - bool isValid() const; - bool isNull() const; + bool isValid() const; + bool isNull() const; - double radius() const; - double azimuth() const; + double radius() const; + double azimuth() const; - double& rRadius(); - double& rAzimuth(); + double &rRadius(); + double &rAzimuth(); - void setRadius( double ); - void setAzimuth( double ); + void setRadius(double); + void setAzimuth(double); - bool operator==( const QwtPointPolar& ) const; - bool operator!=( const QwtPointPolar& ) const; + bool operator==(const QwtPointPolar &) const; + bool operator!=(const QwtPointPolar &) const; - QwtPointPolar normalized() const; + QwtPointPolar normalized() const; - private: - double m_azimuth; - double m_radius; +private: + double m_azimuth; + double m_radius; }; -Q_DECLARE_TYPEINFO( QwtPointPolar, Q_MOVABLE_TYPE ); -Q_DECLARE_METATYPE( QwtPointPolar ); +Q_DECLARE_TYPEINFO(QwtPointPolar, Q_MOVABLE_TYPE); +Q_DECLARE_METATYPE(QwtPointPolar); #ifndef QT_NO_DEBUG_STREAM -QWT_EXPORT QDebug operator<<( QDebug, const QwtPointPolar& ); +QWT_EXPORT QDebug operator<<(QDebug, const QwtPointPolar &); #endif /*! @@ -69,8 +69,8 @@ QWT_EXPORT QDebug operator<<( QDebug, const QwtPointPolar& ); \sa QPointF::isNull() */ inline QwtPointPolar::QwtPointPolar() - : m_azimuth( 0.0 ) - , m_radius( 0.0 ) + : m_azimuth(0.0) + , m_radius(0.0) { } @@ -80,109 +80,105 @@ inline QwtPointPolar::QwtPointPolar() \param azimuth Azimuth \param radius Radius */ -inline QwtPointPolar::QwtPointPolar( double azimuth, double radius ) - : m_azimuth( azimuth ) - , m_radius( radius ) +inline QwtPointPolar::QwtPointPolar(double azimuth, double radius) + : m_azimuth(azimuth) + , m_radius(radius) { } //! Returns true if radius() >= 0.0 inline bool QwtPointPolar::isValid() const { - return m_radius >= 0.0; + return m_radius >= 0.0; } //! Returns true if radius() >= 0.0 inline bool QwtPointPolar::isNull() const { - return m_radius == 0.0; + return m_radius == 0.0; } //! Returns the radius. inline double QwtPointPolar::radius() const { - return m_radius; + return m_radius; } //! Returns the azimuth. inline double QwtPointPolar::azimuth() const { - return m_azimuth; + return m_azimuth; } //! Returns the radius. -inline double& QwtPointPolar::rRadius() +inline double &QwtPointPolar::rRadius() { - return m_radius; + return m_radius; } //! Returns the azimuth. -inline double& QwtPointPolar::rAzimuth() +inline double &QwtPointPolar::rAzimuth() { - return m_azimuth; + return m_azimuth; } //! Sets the radius to radius. -inline void QwtPointPolar::setRadius( double radius ) +inline void QwtPointPolar::setRadius(double radius) { - m_radius = radius; + m_radius = radius; } //! Sets the azimuth to azimuth. -inline void QwtPointPolar::setAzimuth( double azimuth ) +inline void QwtPointPolar::setAzimuth(double azimuth) { - m_azimuth = azimuth; + m_azimuth = azimuth; } -inline QPoint qwtPolar2Pos( const QPoint& pole, - double radius, double angle ) +inline QPoint qwtPolar2Pos(const QPoint &pole, double radius, double angle) { - const double x = pole.x() + radius * std::cos( angle ); - const double y = pole.y() - radius * std::sin( angle ); + const double x = pole.x() + radius * std::cos(angle); + const double y = pole.y() - radius * std::sin(angle); - return QPoint( qRound( x ), qRound( y ) ); + return QPoint(qRound(x), qRound(y)); } -inline QPoint qwtDegree2Pos( const QPoint& pole, - double radius, double angle ) +inline QPoint qwtDegree2Pos(const QPoint &pole, double radius, double angle) { - return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI ); + return qwtPolar2Pos(pole, radius, angle / 180.0 * M_PI); } -inline QPointF qwtPolar2Pos( const QPointF& pole, - double radius, double angle ) +inline QPointF qwtPolar2Pos(const QPointF &pole, double radius, double angle) { - const double x = pole.x() + radius * std::cos( angle ); - const double y = pole.y() - radius * std::sin( angle ); + const double x = pole.x() + radius * std::cos(angle); + const double y = pole.y() - radius * std::sin(angle); - return QPointF( x, y); + return QPointF(x, y); } -inline QPointF qwtDegree2Pos( const QPointF& pole, - double radius, double angle ) +inline QPointF qwtDegree2Pos(const QPointF &pole, double radius, double angle) { - return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI ); + return qwtPolar2Pos(pole, radius, angle / 180.0 * M_PI); } -inline QPointF qwtFastPolar2Pos( const QPointF& pole, - double radius, double angle ) +inline QPointF qwtFastPolar2Pos(const QPointF &pole, double radius, + double angle) { - const double x = pole.x() + radius * qFastCos( angle ); - const double y = pole.y() - radius * qFastSin( angle ); + const double x = pole.x() + radius * qFastCos(angle); + const double y = pole.y() - radius * qFastSin(angle); - return QPointF( x, y); + return QPointF(x, y); } -inline QPointF qwtFastDegree2Pos( const QPointF& pole, - double radius, double angle ) +inline QPointF qwtFastDegree2Pos(const QPointF &pole, double radius, + double angle) { - return qwtFastPolar2Pos( pole, radius, angle / 180.0 * M_PI ); + return qwtFastPolar2Pos(pole, radius, angle / 180.0 * M_PI); } -inline QwtPointPolar qwtFastPos2Polar( const QPointF& pos ) +inline QwtPointPolar qwtFastPos2Polar(const QPointF &pos) { - return QwtPointPolar( qwtFastAtan2( pos.y(), pos.x() ), - qSqrt( qwtSqr( pos.x() ) + qwtSqr( pos.y() ) ) ); + return QwtPointPolar(qwtFastAtan2(pos.y(), pos.x()), + qSqrt(qwtSqr(pos.x()) + qwtSqr(pos.y()))); } #endif diff --git a/libs/qwt/src/qwt_polar.h b/libs/qwt/src/qwt_polar.h index 94b41ca4..7a62e3e0 100644 --- a/libs/qwt/src/qwt_polar.h +++ b/libs/qwt/src/qwt_polar.h @@ -11,72 +11,72 @@ namespace QwtPolar { - //! Unit of an angle - enum AngleUnit - { - //! 0.0 -> 2_M_PI - Radians, +//! Unit of an angle +enum AngleUnit +{ + //! 0.0 -> 2_M_PI + Radians, - //! 0.0 -> 360.0 - Degrees, + //! 0.0 -> 360.0 + Degrees, - //! 0.0 - 400.0 - Gradians, + //! 0.0 - 400.0 + Gradians, - //! 0.0 - 1.0 - Turns - }; + //! 0.0 - 1.0 + Turns +}; - //! An enum, that identifies the type of a coordinate - enum Coordinate - { - //! Azimuth - Azimuth, +//! An enum, that identifies the type of a coordinate +enum Coordinate +{ + //! Azimuth + Azimuth, - //! Radius - Radius - }; + //! Radius + Radius +}; - /*! - Indices used to identify an axis. - \sa Scale - */ - enum Axis - { - //! Azimuth axis - AxisAzimuth, +/*! + Indices used to identify an axis. + \sa Scale + */ +enum Axis +{ + //! Azimuth axis + AxisAzimuth, - //! Left axis - AxisLeft, + //! Left axis + AxisLeft, - //! Right axis - AxisRight, + //! Right axis + AxisRight, - //! Top axis - AxisTop, + //! Top axis + AxisTop, - //! Bottom axis - AxisBottom, + //! Bottom axis + AxisBottom, - //! Number of available axis - AxesCount - }; + //! Number of available axis + AxesCount +}; - /*! - Indices used to identify a scale. - \sa Axis - */ - enum Scale - { - //! Azimuth scale - ScaleAzimuth = Azimuth, +/*! + Indices used to identify a scale. + \sa Axis + */ +enum Scale +{ + //! Azimuth scale + ScaleAzimuth = Azimuth, - //! Radial scale - ScaleRadius = Radius, + //! Radial scale + ScaleRadius = Radius, - //! Number of scales - ScaleCount - }; -} + //! Number of scales + ScaleCount +}; +} // namespace QwtPolar #endif diff --git a/libs/qwt/src/qwt_polar_canvas.cpp b/libs/qwt/src/qwt_polar_canvas.cpp index 953d6834..b0620e74 100644 --- a/libs/qwt/src/qwt_polar_canvas.cpp +++ b/libs/qwt/src/qwt_polar_canvas.cpp @@ -16,93 +16,90 @@ #include #include #ifdef Q_WS_X11 -#include +# include #endif -static inline void PolarCanvas_qwtDrawStyledBackground( - QWidget* widget, QPainter* painter ) +static inline void PolarCanvas_qwtDrawStyledBackground(QWidget *widget, + QPainter *painter) { - QStyleOption opt; - opt.initFrom( widget ); - widget->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, widget ); + QStyleOption opt; + opt.initFrom(widget); + widget->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, widget); } -static QWidget* PolarCanvas_qwtBackgroundWidget( QWidget* w ) +static QWidget *PolarCanvas_qwtBackgroundWidget(QWidget *w) { - if ( w->parentWidget() == NULL ) - return w; + if (w->parentWidget() == NULL) + return w; - if ( w->autoFillBackground() ) - { - const QBrush brush = w->palette().brush( w->backgroundRole() ); - if ( brush.color().alpha() > 0 ) - return w; - } + if (w->autoFillBackground()) + { + const QBrush brush = w->palette().brush(w->backgroundRole()); + if (brush.color().alpha() > 0) + return w; + } - if ( w->testAttribute( Qt::WA_StyledBackground ) ) - { - QImage image( 1, 1, QImage::Format_ARGB32 ); - image.fill( Qt::transparent ); + if (w->testAttribute(Qt::WA_StyledBackground)) + { + QImage image(1, 1, QImage::Format_ARGB32); + image.fill(Qt::transparent); - QPainter painter( &image ); - painter.translate( -w->rect().center() ); - PolarCanvas_qwtDrawStyledBackground( w, &painter ); - painter.end(); + QPainter painter(&image); + painter.translate(-w->rect().center()); + PolarCanvas_qwtDrawStyledBackground(w, &painter); + painter.end(); - if ( qAlpha( image.pixel( 0, 0 ) ) != 0 ) - return w; - } + if (qAlpha(image.pixel(0, 0)) != 0) + return w; + } - return PolarCanvas_qwtBackgroundWidget( w->parentWidget() ); + return PolarCanvas_qwtBackgroundWidget(w->parentWidget()); } class QwtPolarCanvas::PrivateData { - public: - PrivateData() - : backingStore( NULL ) - { - } +public: + PrivateData() + : backingStore(NULL) + { + } - ~PrivateData() - { - delete backingStore; - } + ~PrivateData() { delete backingStore; } - QwtPolarCanvas::PaintAttributes paintAttributes; - QPixmap* backingStore; + QwtPolarCanvas::PaintAttributes paintAttributes; + QPixmap *backingStore; }; //! Constructor -QwtPolarCanvas::QwtPolarCanvas( QwtPolarPlot* plot ) - : QFrame( plot ) +QwtPolarCanvas::QwtPolarCanvas(QwtPolarPlot *plot) + : QFrame(plot) { - m_data = new PrivateData; + m_data = new PrivateData; #ifndef QT_NO_CURSOR - setCursor( Qt::CrossCursor ); + setCursor(Qt::CrossCursor); #endif - setFocusPolicy( Qt::WheelFocus ); + setFocusPolicy(Qt::WheelFocus); - setPaintAttribute( BackingStore, true ); + setPaintAttribute(BackingStore, true); } //! Destructor QwtPolarCanvas::~QwtPolarCanvas() { - delete m_data; + delete m_data; } //! \return Parent plot widget -QwtPolarPlot* QwtPolarCanvas::plot() +QwtPolarPlot *QwtPolarCanvas::plot() { - return qobject_cast< QwtPolarPlot* >( parent() ); + return qobject_cast(parent()); } //! \return Parent plot widget -const QwtPolarPlot* QwtPolarCanvas::plot() const +const QwtPolarPlot *QwtPolarCanvas::plot() const { - return qobject_cast< QwtPolarPlot* >( parent() ); + return qobject_cast(parent()); } /*! @@ -115,43 +112,42 @@ const QwtPolarPlot* QwtPolarCanvas::plot() const \sa testPaintAttribute(), paintCache() */ -void QwtPolarCanvas::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPolarCanvas::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( bool( m_data->paintAttributes & attribute ) == on ) - return; + if (bool(m_data->paintAttributes & attribute) == on) + return; - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; - switch( attribute ) - { - case BackingStore: + switch (attribute) + { + case BackingStore: { + if (on) + { + if (m_data->backingStore == NULL) + m_data->backingStore = new QPixmap(); + + if (isVisible()) { - if ( on ) - { - if ( m_data->backingStore == NULL ) - m_data->backingStore = new QPixmap(); - - if ( isVisible() ) - { - const QRect cr = contentsRect(); + const QRect cr = contentsRect(); #if QT_VERSION >= 0x050000 - *m_data->backingStore = grab( cr ); + *m_data->backingStore = grab(cr); #else - *m_data->backingStore = QPixmap::grabWidget( this, cr ); + *m_data->backingStore = QPixmap::grabWidget(this, cr); #endif - } - } - else - { - delete m_data->backingStore; - m_data->backingStore = NULL; - } - break; } + } + else + { + delete m_data->backingStore; + m_data->backingStore = NULL; + } + break; } + } } /*! @@ -161,99 +157,98 @@ void QwtPolarCanvas::setPaintAttribute( PaintAttribute attribute, bool on ) \return true if the attribute is enabled \sa setPaintAttribute() */ -bool QwtPolarCanvas::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPolarCanvas::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ) != 0; + return (m_data->paintAttributes & attribute) != 0; } //! \return Backing store, might be null -const QPixmap* QwtPolarCanvas::backingStore() const +const QPixmap *QwtPolarCanvas::backingStore() const { - return m_data->backingStore; + return m_data->backingStore; } //! Invalidate the internal backing store void QwtPolarCanvas::invalidateBackingStore() { - if ( m_data->backingStore ) - *m_data->backingStore = QPixmap(); + if (m_data->backingStore) + *m_data->backingStore = QPixmap(); } /*! Paint event \param event Paint event */ -void QwtPolarCanvas::paintEvent( QPaintEvent* event ) +void QwtPolarCanvas::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - if ( ( m_data->paintAttributes & BackingStore ) - && m_data->backingStore != NULL ) + if ((m_data->paintAttributes & BackingStore) && m_data->backingStore != NULL) + { + QPixmap &bs = *m_data->backingStore; + if (bs.size() != size()) { - QPixmap& bs = *m_data->backingStore; - if ( bs.size() != size() ) - { - bs = QPixmap( size() ); + bs = QPixmap(size()); #ifdef Q_WS_X11 - if ( bs.x11Info().screen() != x11Info().screen() ) - bs.x11SetScreen( x11Info().screen() ); + if (bs.x11Info().screen() != x11Info().screen()) + bs.x11SetScreen(x11Info().screen()); #endif - QPainter p; + QPainter p; - if ( testAttribute( Qt::WA_StyledBackground ) ) - { - p.begin( &bs ); - PolarCanvas_qwtDrawStyledBackground( this, &p ); - } - else - { - if ( autoFillBackground() ) - { - p.begin( &bs ); - p.fillRect( rect(), palette().brush( backgroundRole() ) ); - } - else - { - QWidget* bgWidget = PolarCanvas_qwtBackgroundWidget( plot() ); - - QwtPainter::fillPixmap( bgWidget, bs, - mapTo( bgWidget, rect().topLeft() ) ); - - p.begin( &bs ); - } - } - - plot()->drawCanvas( &p, contentsRect() ); - - if ( frameWidth() > 0 ) - drawFrame( &p ); + if (testAttribute(Qt::WA_StyledBackground)) + { + p.begin(&bs); + PolarCanvas_qwtDrawStyledBackground(this, &p); + } + else + { + if (autoFillBackground()) + { + p.begin(&bs); + p.fillRect(rect(), palette().brush(backgroundRole())); } + else + { + QWidget *bgWidget = PolarCanvas_qwtBackgroundWidget(plot()); - painter.drawPixmap( 0, 0, *m_data->backingStore ); + QwtPainter::fillPixmap(bgWidget, bs, + mapTo(bgWidget, rect().topLeft())); + + p.begin(&bs); + } + } + + plot()->drawCanvas(&p, contentsRect()); + + if (frameWidth() > 0) + drawFrame(&p); } - else - { - PolarCanvas_qwtDrawStyledBackground( this, &painter ); - plot()->drawCanvas( &painter, contentsRect() ); + painter.drawPixmap(0, 0, *m_data->backingStore); + } + else + { + PolarCanvas_qwtDrawStyledBackground(this, &painter); - if ( frameWidth() > 0 ) - drawFrame( &painter ); - } + plot()->drawCanvas(&painter, contentsRect()); + + if (frameWidth() > 0) + drawFrame(&painter); + } } /*! Resize event \param event Resize event */ -void QwtPolarCanvas::resizeEvent( QResizeEvent* event ) +void QwtPolarCanvas::resizeEvent(QResizeEvent *event) { - QFrame::resizeEvent( event ); + QFrame::resizeEvent(event); - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) - plot()->updateScale( scaleId ); + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + plot()->updateScale(scaleId); } /*! @@ -264,40 +259,40 @@ void QwtPolarCanvas::resizeEvent( QResizeEvent* event ) \sa transform() */ -QwtPointPolar QwtPolarCanvas::invTransform( const QPoint& pos ) const +QwtPointPolar QwtPolarCanvas::invTransform(const QPoint &pos) const { - const QwtPolarPlot* pl = plot(); + const QwtPolarPlot *pl = plot(); - const QwtScaleMap azimuthMap = pl->scaleMap( QwtPolar::Azimuth ); - const QwtScaleMap radialMap = pl->scaleMap( QwtPolar::Radius ); + const QwtScaleMap azimuthMap = pl->scaleMap(QwtPolar::Azimuth); + const QwtScaleMap radialMap = pl->scaleMap(QwtPolar::Radius); - const QPointF center = pl->plotRect().center(); + const QPointF center = pl->plotRect().center(); - double dx = pos.x() - center.x(); - double dy = -( pos.y() - center.y() ); + double dx = pos.x() - center.x(); + double dy = -(pos.y() - center.y()); - const QwtPointPolar polarPos = QwtPointPolar( QPoint( dx, dy ) ).normalized(); + const QwtPointPolar polarPos = QwtPointPolar(QPoint(dx, dy)).normalized(); - double azimuth = azimuthMap.invTransform( polarPos.azimuth() ); + double azimuth = azimuthMap.invTransform(polarPos.azimuth()); - // normalize the azimuth - double min = azimuthMap.s1(); - double max = azimuthMap.s2(); - if ( max < min ) - qSwap( min, max ); + // normalize the azimuth + double min = azimuthMap.s1(); + double max = azimuthMap.s2(); + if (max < min) + qSwap(min, max); - if ( azimuth < min ) - { - azimuth += max - min; - } - else if ( azimuth > max ) - { - azimuth -= max - min; - } + if (azimuth < min) + { + azimuth += max - min; + } + else if (azimuth > max) + { + azimuth -= max - min; + } - const double radius = radialMap.invTransform( polarPos.radius() ); + const double radius = radialMap.invTransform(polarPos.radius()); - return QwtPointPolar( azimuth, radius ); + return QwtPointPolar(azimuth, radius); } /*! @@ -307,22 +302,21 @@ QwtPointPolar QwtPolarCanvas::invTransform( const QPoint& pos ) const \return Point in widget coordinates \sa transform() */ -QPoint QwtPolarCanvas::transform( const QwtPointPolar& polarPos ) const +QPoint QwtPolarCanvas::transform(const QwtPointPolar &polarPos) const { - const QwtPolarPlot* pl = plot(); + const QwtPolarPlot *pl = plot(); - const QwtScaleMap azimuthMap = pl->scaleMap( QwtPolar::Azimuth ); - const QwtScaleMap radialMap = pl->scaleMap( QwtPolar::Radius ); + const QwtScaleMap azimuthMap = pl->scaleMap(QwtPolar::Azimuth); + const QwtScaleMap radialMap = pl->scaleMap(QwtPolar::Radius); - const double radius = radialMap.transform( polarPos.radius() ); - const double azimuth = azimuthMap.transform( polarPos.azimuth() ); + const double radius = radialMap.transform(polarPos.radius()); + const double azimuth = azimuthMap.transform(polarPos.azimuth()); - const QPointF pos = qwtPolar2Pos( - pl->plotRect().center(), radius, azimuth ); + const QPointF pos = qwtPolar2Pos(pl->plotRect().center(), radius, azimuth); - return pos.toPoint(); + return pos.toPoint(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_polar_canvas.cpp" +# include "moc_qwt_polar_canvas.cpp" #endif diff --git a/libs/qwt/src/qwt_polar_canvas.h b/libs/qwt/src/qwt_polar_canvas.h index 97dff309..ff3101fe 100644 --- a/libs/qwt/src/qwt_polar_canvas.h +++ b/libs/qwt/src/qwt_polar_canvas.h @@ -26,53 +26,53 @@ class QwtPolarPlot; */ class QWT_EXPORT QwtPolarCanvas : public QFrame { - Q_OBJECT + Q_OBJECT - public: +public: + /*! + \brief Paint attributes + + The default setting enables BackingStore + + \sa setPaintAttribute(), testPaintAttribute(), backingStore() + */ + + enum PaintAttribute + { /*! - \brief Paint attributes - - The default setting enables BackingStore - - \sa setPaintAttribute(), testPaintAttribute(), backingStore() + Paint double buffered and reuse the content of the pixmap buffer + for some spontaneous repaints that happen when a plot gets unhidden, + deiconified or changes the focus. */ + BackingStore = 0x01 + }; - enum PaintAttribute - { - /*! - Paint double buffered and reuse the content of the pixmap buffer - for some spontaneous repaints that happen when a plot gets unhidden, - deiconified or changes the focus. - */ - BackingStore = 0x01 - }; + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + explicit QwtPolarCanvas(QwtPolarPlot *); + virtual ~QwtPolarCanvas(); - explicit QwtPolarCanvas( QwtPolarPlot* ); - virtual ~QwtPolarCanvas(); + QwtPolarPlot *plot(); + const QwtPolarPlot *plot() const; - QwtPolarPlot* plot(); - const QwtPolarPlot* plot() const; + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + const QPixmap *backingStore() const; + void invalidateBackingStore(); - const QPixmap* backingStore() const; - void invalidateBackingStore(); + QwtPointPolar invTransform(const QPoint &) const; + QPoint transform(const QwtPointPolar &) const; - QwtPointPolar invTransform( const QPoint& ) const; - QPoint transform( const QwtPointPolar& ) const; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; - - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCanvas::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarCanvas::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_polar_curve.cpp b/libs/qwt/src/qwt_polar_curve.cpp index b2164a7b..dc562321 100644 --- a/libs/qwt/src/qwt_polar_curve.cpp +++ b/libs/qwt/src/qwt_polar_curve.cpp @@ -18,101 +18,101 @@ #include -static inline bool qwtInsidePole( const QwtScaleMap& map, double radius ) +static inline bool qwtInsidePole(const QwtScaleMap &map, double radius) { - return map.isInverting() ? ( radius > map.s1() ) : ( radius < map.s1() ); + return map.isInverting() ? (radius > map.s1()) : (radius < map.s1()); } -static int PolarCurve_qwtVerifyRange( int size, int& i1, int& i2 ) +static int PolarCurve_qwtVerifyRange(int size, int &i1, int &i2) { - if ( size < 1 ) - return 0; + if (size < 1) + return 0; - i1 = qBound( 0, i1, size - 1 ); - i2 = qBound( 0, i2, size - 1 ); + i1 = qBound(0, i1, size - 1); + i2 = qBound(0, i2, size - 1); - if ( i1 > i2 ) - qSwap( i1, i2 ); + if (i1 > i2) + qSwap(i1, i2); - return ( i2 - i1 + 1 ); + return (i2 - i1 + 1); } class QwtPolarCurve::PrivateData { - public: - PrivateData() - : style( QwtPolarCurve::Lines ) - , curveFitter( NULL ) - { - symbol = new QwtSymbol(); - pen = QPen( Qt::black ); - } +public: + PrivateData() + : style(QwtPolarCurve::Lines) + , curveFitter(NULL) + { + symbol = new QwtSymbol(); + pen = QPen(Qt::black); + } - ~PrivateData() - { - delete symbol; - delete curveFitter; - } + ~PrivateData() + { + delete symbol; + delete curveFitter; + } - QwtPolarCurve::CurveStyle style; - const QwtSymbol* symbol; - QPen pen; - QwtCurveFitter* curveFitter; + QwtPolarCurve::CurveStyle style; + const QwtSymbol *symbol; + QPen pen; + QwtCurveFitter *curveFitter; - QwtPolarCurve::LegendAttributes legendAttributes; + QwtPolarCurve::LegendAttributes legendAttributes; }; //! Constructor QwtPolarCurve::QwtPolarCurve() - : QwtPolarItem( QwtText() ) + : QwtPolarItem(QwtText()) { - init(); + init(); } /*! Constructor \param title title of the curve */ -QwtPolarCurve::QwtPolarCurve( const QwtText& title ) - : QwtPolarItem( title ) +QwtPolarCurve::QwtPolarCurve(const QwtText &title) + : QwtPolarItem(title) { - init(); + init(); } /*! Constructor \param title title of the curve */ -QwtPolarCurve::QwtPolarCurve( const QString& title ) - : QwtPolarItem( QwtText( title ) ) +QwtPolarCurve::QwtPolarCurve(const QString &title) + : QwtPolarItem(QwtText(title)) { - init(); + init(); } //! Destructor QwtPolarCurve::~QwtPolarCurve() { - delete m_series; - delete m_data; + delete m_series; + delete m_data; } //! Initialize data members void QwtPolarCurve::init() { - m_data = new PrivateData; - m_series = NULL; + m_data = new PrivateData; + m_series = NULL; - setItemAttribute( QwtPolarItem::AutoScale ); - setItemAttribute( QwtPolarItem::Legend ); - setZ( 20.0 ); + setItemAttribute(QwtPolarItem::AutoScale); + setItemAttribute(QwtPolarItem::Legend); + setZ(20.0); - setRenderHint( RenderAntialiased, true ); + setRenderHint(RenderAntialiased, true); } //! \return QwtPolarCurve::Rtti_PolarCurve int QwtPolarCurve::rtti() const { - return QwtPolarItem::Rtti_PolarCurve; + return QwtPolarItem::Rtti_PolarCurve; } /*! @@ -122,12 +122,12 @@ int QwtPolarCurve::rtti() const \param on On/Off /sa LegendAttribute, testLegendAttribute() */ -void QwtPolarCurve::setLegendAttribute( LegendAttribute attribute, bool on ) +void QwtPolarCurve::setLegendAttribute(LegendAttribute attribute, bool on) { - if ( on ) - m_data->legendAttributes |= attribute; - else - m_data->legendAttributes &= ~attribute; + if (on) + m_data->legendAttributes |= attribute; + else + m_data->legendAttributes &= ~attribute; } /*! @@ -138,9 +138,9 @@ void QwtPolarCurve::setLegendAttribute( LegendAttribute attribute, bool on ) \return True if attribute is enabled \sa LegendAttribute, setLegendAttribute() */ -bool QwtPolarCurve::testLegendAttribute( LegendAttribute attribute ) const +bool QwtPolarCurve::testLegendAttribute(LegendAttribute attribute) const { - return ( m_data->legendAttributes & attribute ); + return (m_data->legendAttributes & attribute); } /*! @@ -149,13 +149,13 @@ bool QwtPolarCurve::testLegendAttribute( LegendAttribute attribute ) const \param style Curve style \sa CurveStyle, style() */ -void QwtPolarCurve::setStyle( CurveStyle style ) +void QwtPolarCurve::setStyle(CurveStyle style) { - if ( style != m_data->style ) - { - m_data->style = style; - itemChanged(); - } + if (style != m_data->style) + { + m_data->style = style; + itemChanged(); + } } /*! @@ -164,7 +164,7 @@ void QwtPolarCurve::setStyle( CurveStyle style ) */ QwtPolarCurve::CurveStyle QwtPolarCurve::style() const { - return m_data->style; + return m_data->style; } /*! @@ -172,23 +172,23 @@ QwtPolarCurve::CurveStyle QwtPolarCurve::style() const \param symbol Symbol \sa symbol() */ -void QwtPolarCurve::setSymbol( QwtSymbol* symbol ) +void QwtPolarCurve::setSymbol(QwtSymbol *symbol) { - if ( symbol != m_data->symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; - itemChanged(); - } + if (symbol != m_data->symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; + itemChanged(); + } } /*! \return The current symbol \sa setSymbol() */ -const QwtSymbol* QwtPolarCurve::symbol() const +const QwtSymbol *QwtPolarCurve::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -196,22 +196,22 @@ const QwtSymbol* QwtPolarCurve::symbol() const \param pen New pen \sa pen() */ -void QwtPolarCurve::setPen( const QPen& pen ) +void QwtPolarCurve::setPen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; - itemChanged(); - } + if (pen != m_data->pen) + { + m_data->pen = pen; + itemChanged(); + } } /*! \return Pen used to draw the lines \sa setPen() */ -const QPen& QwtPolarCurve::pen() const +const QPen &QwtPolarCurve::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -222,14 +222,14 @@ const QPen& QwtPolarCurve::pen() const \param data Data */ -void QwtPolarCurve::setData( QwtSeriesData< QwtPointPolar >* data ) +void QwtPolarCurve::setData(QwtSeriesData *data) { - if ( m_series != data ) - { - delete m_series; - m_series = data; - itemChanged(); - } + if (m_series != data) + { + delete m_series; + m_series = data; + itemChanged(); + } } /*! @@ -243,24 +243,24 @@ void QwtPolarCurve::setData( QwtSeriesData< QwtPointPolar >* data ) \sa curveFitter() */ -void QwtPolarCurve::setCurveFitter( QwtCurveFitter* curveFitter ) +void QwtPolarCurve::setCurveFitter(QwtCurveFitter *curveFitter) { - if ( curveFitter != m_data->curveFitter ) - { - delete m_data->curveFitter; - m_data->curveFitter = curveFitter; + if (curveFitter != m_data->curveFitter) + { + delete m_data->curveFitter; + m_data->curveFitter = curveFitter; - itemChanged(); - } + itemChanged(); + } } /*! \return The curve fitter \sa setCurveFitter() */ -QwtCurveFitter* QwtPolarCurve::curveFitter() const +QwtCurveFitter *QwtPolarCurve::curveFitter() const { - return m_data->curveFitter; + return m_data->curveFitter; } /*! @@ -273,15 +273,14 @@ QwtCurveFitter* QwtPolarCurve::curveFitter() const \param radius Radius of the complete plot area in painter coordinates \param canvasRect Contents rect of the canvas in painter coordinates */ -void QwtPolarCurve::draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const +void QwtPolarCurve::draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const { - Q_UNUSED( radius ); - Q_UNUSED( canvasRect ); + Q_UNUSED(radius); + Q_UNUSED(canvasRect); - draw( painter, azimuthMap, radialMap, pole, 0, -1 ); + draw(painter, azimuthMap, radialMap, pole, 0, -1); } /*! @@ -296,34 +295,33 @@ void QwtPolarCurve::draw( QPainter* painter, \sa drawCurve(), drawSymbols(), */ -void QwtPolarCurve::draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const +void QwtPolarCurve::draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + int from, int to) const { - if ( !painter || dataSize() <= 0 ) - return; + if (!painter || dataSize() <= 0) + return; - if ( to < 0 ) - to = dataSize() - 1; + if (to < 0) + to = dataSize() - 1; - if ( PolarCurve_qwtVerifyRange( dataSize(), from, to ) > 0 ) + if (PolarCurve_qwtVerifyRange(dataSize(), from, to) > 0) + { + painter->save(); + painter->setPen(m_data->pen); + + drawCurve(painter, m_data->style, azimuthMap, radialMap, pole, from, to); + + painter->restore(); + + if (m_data->symbol->style() != QwtSymbol::NoSymbol) { - painter->save(); - painter->setPen( m_data->pen ); - - drawCurve( painter, m_data->style, - azimuthMap, radialMap, pole, from, to ); - - painter->restore(); - - if ( m_data->symbol->style() != QwtSymbol::NoSymbol ) - { - painter->save(); - drawSymbols( painter, *m_data->symbol, - azimuthMap, radialMap, pole, from, to ); - painter->restore(); - } + painter->save(); + drawSymbols(painter, *m_data->symbol, azimuthMap, radialMap, pole, from, + to); + painter->restore(); } + } } /*! @@ -338,19 +336,20 @@ void QwtPolarCurve::draw( QPainter* painter, \param to index of the last point to be painted. \sa draw(), drawLines() */ -void QwtPolarCurve::drawCurve( QPainter* painter, int style, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const +void QwtPolarCurve::drawCurve(QPainter *painter, int style, + const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + int from, int to) const { - switch ( style ) - { - case Lines: - drawLines( painter, azimuthMap, radialMap, pole, from, to ); - break; - case NoCurve: - default: - break; - } + switch (style) + { + case Lines: + drawLines(painter, azimuthMap, radialMap, pole, from, to); + break; + case NoCurve: + default: + break; + } } /*! @@ -364,83 +363,83 @@ void QwtPolarCurve::drawCurve( QPainter* painter, int style, \param to index of the last point to be painted. \sa draw(), drawLines(), setCurveFitter() */ -void QwtPolarCurve::drawLines( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const +void QwtPolarCurve::drawLines(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + int from, int to) const { - int size = to - from + 1; - if ( size <= 0 ) - return; + int size = to - from + 1; + if (size <= 0) + return; - QPolygonF polyline; + QPolygonF polyline; - if ( m_data->curveFitter ) + if (m_data->curveFitter) + { + QPolygonF points(size); + for (int j = from; j <= to; j++) { - QPolygonF points( size ); - for ( int j = from; j <= to; j++ ) - { - const QwtPointPolar point = sample( j ); - points[j - from] = QPointF( point.azimuth(), point.radius() ); - } - - points = m_data->curveFitter->fitCurve( points ); - - polyline.resize( points.size() ); - - QPointF* polylineData = polyline.data(); - QPointF* pointsData = points.data(); - - for ( int i = 0; i < points.size(); i++ ) - { - const QwtPointPolar point( pointsData[i].x(), pointsData[i].y() ); - - double r = radialMap.transform( point.radius() ); - const double a = azimuthMap.transform( point.azimuth() ); - - polylineData[i] = qwtPolar2Pos( pole, r, a ); - } - } - else - { - polyline.resize( size ); - QPointF* polylineData = polyline.data(); - - for ( int i = from; i <= to; i++ ) - { - QwtPointPolar point = sample( i ); - if ( !qwtInsidePole( radialMap, point.radius() ) ) - { - double r = radialMap.transform( point.radius() ); - const double a = azimuthMap.transform( point.azimuth() ); - polylineData[i - from] = qwtPolar2Pos( pole, r, a ); - } - else - { - polylineData[i - from] = pole; - } - } + const QwtPointPolar point = sample(j); + points[j - from] = QPointF(point.azimuth(), point.radius()); } - QRectF clipRect; - if ( painter->hasClipping() ) - { - clipRect = painter->clipRegion().boundingRect(); - } - else - { - clipRect = painter->window(); - if ( !clipRect.isEmpty() ) - clipRect = painter->transform().inverted().mapRect( clipRect ); - } + points = m_data->curveFitter->fitCurve(points); - if ( !clipRect.isEmpty() ) - { - double off = qCeil( qMax( qreal( 1.0 ), painter->pen().widthF() ) ); - clipRect = clipRect.toRect().adjusted( -off, -off, off, off ); - QwtClipper::clipPolygonF( clipRect, polyline ); - } + polyline.resize(points.size()); - QwtPainter::drawPolyline( painter, polyline ); + QPointF *polylineData = polyline.data(); + QPointF *pointsData = points.data(); + + for (int i = 0; i < points.size(); i++) + { + const QwtPointPolar point(pointsData[i].x(), pointsData[i].y()); + + double r = radialMap.transform(point.radius()); + const double a = azimuthMap.transform(point.azimuth()); + + polylineData[i] = qwtPolar2Pos(pole, r, a); + } + } + else + { + polyline.resize(size); + QPointF *polylineData = polyline.data(); + + for (int i = from; i <= to; i++) + { + QwtPointPolar point = sample(i); + if (!qwtInsidePole(radialMap, point.radius())) + { + double r = radialMap.transform(point.radius()); + const double a = azimuthMap.transform(point.azimuth()); + polylineData[i - from] = qwtPolar2Pos(pole, r, a); + } + else + { + polylineData[i - from] = pole; + } + } + } + + QRectF clipRect; + if (painter->hasClipping()) + { + clipRect = painter->clipRegion().boundingRect(); + } + else + { + clipRect = painter->window(); + if (!clipRect.isEmpty()) + clipRect = painter->transform().inverted().mapRect(clipRect); + } + + if (!clipRect.isEmpty()) + { + double off = qCeil(qMax(qreal(1.0), painter->pen().widthF())); + clipRect = clipRect.toRect().adjusted(-off, -off, off, off); + QwtClipper::clipPolygonF(clipRect, polyline); + } + + QwtPainter::drawPolyline(painter, polyline); } /*! @@ -456,40 +455,41 @@ void QwtPolarCurve::drawLines( QPainter* painter, \sa setSymbol(), draw(), drawCurve() */ -void QwtPolarCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const +void QwtPolarCurve::drawSymbols(QPainter *painter, const QwtSymbol &symbol, + const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, + const QPointF &pole, int from, int to) const { - painter->setBrush( symbol.brush() ); - painter->setPen( symbol.pen() ); + painter->setBrush(symbol.brush()); + painter->setPen(symbol.pen()); - const int chunkSize = 500; + const int chunkSize = 500; - for ( int i = from; i <= to; i += chunkSize ) + for (int i = from; i <= to; i += chunkSize) + { + const int n = qMin(chunkSize, to - i + 1); + + QPolygonF points; + for (int j = 0; j < n; j++) { - const int n = qMin( chunkSize, to - i + 1 ); + const QwtPointPolar point = sample(i + j); - QPolygonF points; - for ( int j = 0; j < n; j++ ) - { - const QwtPointPolar point = sample( i + j ); + if (!qwtInsidePole(radialMap, point.radius())) + { + const double r = radialMap.transform(point.radius()); + const double a = azimuthMap.transform(point.azimuth()); - if ( !qwtInsidePole( radialMap, point.radius() ) ) - { - const double r = radialMap.transform( point.radius() ); - const double a = azimuthMap.transform( point.azimuth() ); - - points += qwtPolar2Pos( pole, r, a ); - } - else - { - points += pole; - } - } - - if ( points.size() > 0 ) - symbol.drawSymbols( painter, points ); + points += qwtPolar2Pos(pole, r, a); + } + else + { + points += pole; + } } + + if (points.size() > 0) + symbol.drawSymbols(painter, points); + } } /*! @@ -498,7 +498,7 @@ void QwtPolarCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol, */ int QwtPolarCurve::dataSize() const { - return m_series->size(); + return m_series->size(); } /*! @@ -510,67 +510,65 @@ int QwtPolarCurve::dataSize() const \sa QwtPolarItem::setLegendIconSize(), QwtPolarItem::legendData() */ -QwtGraphic QwtPolarCurve::legendIcon( int index, - const QSizeF& size ) const +QwtGraphic QwtPolarCurve::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ); + Q_UNUSED(index); - if ( size.isEmpty() ) - return QwtGraphic(); + if (size.isEmpty()) + return QwtGraphic(); - QwtGraphic graphic; - graphic.setDefaultSize( size ); - graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); + QwtGraphic graphic; + graphic.setDefaultSize(size); + graphic.setRenderHint(QwtGraphic::RenderPensUnscaled, true); - QPainter painter( &graphic ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPolarItem::RenderAntialiased ) ); + QPainter painter(&graphic); + painter.setRenderHint(QPainter::Antialiasing, + testRenderHint(QwtPolarItem::RenderAntialiased)); - if ( m_data->legendAttributes == 0 ) + if (m_data->legendAttributes == 0) + { + QBrush brush; + + if (style() != QwtPolarCurve::NoCurve) { - QBrush brush; - - if ( style() != QwtPolarCurve::NoCurve ) - { - brush = QBrush( pen().color() ); - } - else if ( m_data->symbol && - ( m_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - brush = QBrush( m_data->symbol->pen().color() ); - } - - if ( brush.style() != Qt::NoBrush ) - { - QRectF r( 0, 0, size.width(), size.height() ); - painter.fillRect( r, brush ); - } + brush = QBrush(pen().color()); + } + else if (m_data->symbol && (m_data->symbol->style() != QwtSymbol::NoSymbol)) + { + brush = QBrush(m_data->symbol->pen().color()); } - if ( m_data->legendAttributes & QwtPolarCurve::LegendShowLine ) + if (brush.style() != Qt::NoBrush) { - if ( pen() != Qt::NoPen ) - { - QPen pn = pen(); - pn.setCapStyle( Qt::FlatCap ); - - painter.setPen( pn ); - - const double y = 0.5 * size.height(); - QwtPainter::drawLine( &painter, 0.0, y, size.width(), y ); - } + QRectF r(0, 0, size.width(), size.height()); + painter.fillRect(r, brush); } + } - if ( m_data->legendAttributes & QwtPolarCurve::LegendShowSymbol ) + if (m_data->legendAttributes & QwtPolarCurve::LegendShowLine) + { + if (pen() != Qt::NoPen) { - if ( m_data->symbol ) - { - QRectF r( 0, 0, size.width(), size.height() ); - m_data->symbol->drawSymbol( &painter, r ); - } - } + QPen pn = pen(); + pn.setCapStyle(Qt::FlatCap); - return graphic; + painter.setPen(pn); + + const double y = 0.5 * size.height(); + QwtPainter::drawLine(&painter, 0.0, y, size.width(), y); + } + } + + if (m_data->legendAttributes & QwtPolarCurve::LegendShowSymbol) + { + if (m_data->symbol) + { + QRectF r(0, 0, size.width(), size.height()); + m_data->symbol->drawSymbol(&painter, r); + } + } + + return graphic; } /*! @@ -582,15 +580,15 @@ QwtGraphic QwtPolarCurve::legendIcon( int index, \sa QwtData::boundingRect() */ -QwtInterval QwtPolarCurve::boundingInterval( int scaleId ) const +QwtInterval QwtPolarCurve::boundingInterval(int scaleId) const { - const QRectF boundingRect = m_series->boundingRect(); + const QRectF boundingRect = m_series->boundingRect(); - if ( scaleId == QwtPolar::ScaleAzimuth ) - return QwtInterval( boundingRect.left(), boundingRect.right() ); + if (scaleId == QwtPolar::ScaleAzimuth) + return QwtInterval(boundingRect.left(), boundingRect.right()); - if ( scaleId == QwtPolar::ScaleRadius ) - return QwtInterval( boundingRect.top(), boundingRect.bottom() ); + if (scaleId == QwtPolar::ScaleRadius) + return QwtInterval(boundingRect.top(), boundingRect.bottom()); - return QwtInterval(); + return QwtInterval(); } diff --git a/libs/qwt/src/qwt_polar_curve.h b/libs/qwt/src/qwt_polar_curve.h index de194006..c49bde86 100644 --- a/libs/qwt/src/qwt_polar_curve.h +++ b/libs/qwt/src/qwt_polar_curve.h @@ -29,132 +29,130 @@ class QwtCurveFitter; class QWT_EXPORT QwtPolarCurve : public QwtPolarItem { - public: - /*! - Curve styles. - \sa setStyle(), style() - */ - enum CurveStyle - { - //! Don't draw a curve. Note: This doesn't affect the symbols. - NoCurve, - - /*! - Connect the points with straight lines. The lines might - be interpolated depending on the 'Fitted' attribute. Curve - fitting can be configured using setCurveFitter(). - */ - Lines, - - //! Values > 100 are reserved for user specific curve styles - UserCurve = 100 - }; +public: + /*! + Curve styles. + \sa setStyle(), style() + */ + enum CurveStyle + { + //! Don't draw a curve. Note: This doesn't affect the symbols. + NoCurve, /*! - \brief Attributes how to represent the curve on the legend - - If none of the flags is activated QwtPlotCurve tries to find - a color representing the curve and paints a rectangle with it. - In the default setting all attributes are off. - - \sa setLegendAttribute(), testLegendAttribute() + Connect the points with straight lines. The lines might + be interpolated depending on the 'Fitted' attribute. Curve + fitting can be configured using setCurveFitter(). */ + Lines, - enum LegendAttribute - { - /*! - If the curveStyle() is not NoCurve a line is painted with the - curvePen(). - */ - LegendShowLine = 0x01, + //! Values > 100 are reserved for user specific curve styles + UserCurve = 100 + }; - //! If the curve has a valid symbol it is painted. - LegendShowSymbol = 0x02 - }; + /*! + \brief Attributes how to represent the curve on the legend - Q_DECLARE_FLAGS( LegendAttributes, LegendAttribute ) + If none of the flags is activated QwtPlotCurve tries to find + a color representing the curve and paints a rectangle with it. + In the default setting all attributes are off. + \sa setLegendAttribute(), testLegendAttribute() + */ - explicit QwtPolarCurve(); - explicit QwtPolarCurve( const QwtText& title ); - explicit QwtPolarCurve( const QString& title ); + enum LegendAttribute + { + /*! + If the curveStyle() is not NoCurve a line is painted with the + curvePen(). + */ + LegendShowLine = 0x01, - virtual ~QwtPolarCurve(); + //! If the curve has a valid symbol it is painted. + LegendShowSymbol = 0x02 + }; - virtual int rtti() const QWT_OVERRIDE; + Q_DECLARE_FLAGS(LegendAttributes, LegendAttribute) - void setLegendAttribute( LegendAttribute, bool on = true ); - bool testLegendAttribute( LegendAttribute ) const; + explicit QwtPolarCurve(); + explicit QwtPolarCurve(const QwtText &title); + explicit QwtPolarCurve(const QString &title); - void setData( QwtSeriesData< QwtPointPolar >* data ); - const QwtSeriesData< QwtPointPolar >* data() const; + virtual ~QwtPolarCurve(); - int dataSize() const; - QwtPointPolar sample( int i ) const; + virtual int rtti() const QWT_OVERRIDE; - void setPen( const QPen& ); - const QPen& pen() const; + void setLegendAttribute(LegendAttribute, bool on = true); + bool testLegendAttribute(LegendAttribute) const; - void setStyle( CurveStyle style ); - CurveStyle style() const; + void setData(QwtSeriesData *data); + const QwtSeriesData *data() const; - void setSymbol( QwtSymbol* ); - const QwtSymbol* symbol() const; + int dataSize() const; + QwtPointPolar sample(int i) const; - void setCurveFitter( QwtCurveFitter* ); - QwtCurveFitter* curveFitter() const; + void setPen(const QPen &); + const QPen &pen() const; - virtual void draw( QPainter* p, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const QWT_OVERRIDE; + void setStyle(CurveStyle style); + CurveStyle style() const; - virtual void draw( QPainter* p, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const; + void setSymbol(QwtSymbol *); + const QwtSymbol *symbol() const; - virtual QwtInterval boundingInterval( int scaleId ) const QWT_OVERRIDE; + void setCurveFitter(QwtCurveFitter *); + QwtCurveFitter *curveFitter() const; - virtual QwtGraphic legendIcon( int index, const QSizeF& ) const QWT_OVERRIDE; + virtual void draw(QPainter *p, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const QWT_OVERRIDE; - protected: + virtual void draw(QPainter *p, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, int from, + int to) const; - void init(); + virtual QwtInterval boundingInterval(int scaleId) const QWT_OVERRIDE; - virtual void drawCurve( QPainter*, int style, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE; - virtual void drawSymbols( QPainter*, const QwtSymbol&, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const; +protected: + void init(); - void drawLines( QPainter*, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, int from, int to ) const; + virtual void drawCurve(QPainter *, int style, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + int from, int to) const; - private: - QwtSeriesData< QwtPointPolar >* m_series; + virtual void drawSymbols(QPainter *, const QwtSymbol &, + const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + int from, int to) const; - class PrivateData; - PrivateData* m_data; + void drawLines(QPainter *, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, int from, + int to) const; + +private: + QwtSeriesData *m_series; + + class PrivateData; + PrivateData *m_data; }; //! \return the the curve data -inline const QwtSeriesData< QwtPointPolar >* QwtPolarCurve::data() const +inline const QwtSeriesData *QwtPolarCurve::data() const { - return m_series; + return m_series; } /*! \param i index \return point at position i */ -inline QwtPointPolar QwtPolarCurve::sample( int i ) const +inline QwtPointPolar QwtPolarCurve::sample(int i) const { - return m_series->sample( i ); + return m_series->sample(i); } -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCurve::LegendAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarCurve::LegendAttributes) #endif diff --git a/libs/qwt/src/qwt_polar_fitter.cpp b/libs/qwt/src/qwt_polar_fitter.cpp index ec1cfea0..8523c209 100644 --- a/libs/qwt/src/qwt_polar_fitter.cpp +++ b/libs/qwt/src/qwt_polar_fitter.cpp @@ -12,13 +12,13 @@ class QwtPolarFitter::PrivateData { - public: - PrivateData() - : stepCount( 5 ) - { - } +public: + PrivateData() + : stepCount(5) + { + } - int stepCount; + int stepCount; }; /*! @@ -27,17 +27,17 @@ class QwtPolarFitter::PrivateData \param stepCount Number of points, that will be inserted between 2 points \sa setStepCount() */ -QwtPolarFitter::QwtPolarFitter( int stepCount ) - : QwtCurveFitter( QwtPolarFitter::Polygon ) +QwtPolarFitter::QwtPolarFitter(int stepCount) + : QwtCurveFitter(QwtPolarFitter::Polygon) { - m_data = new PrivateData; - m_data->stepCount = stepCount; + m_data = new PrivateData; + m_data->stepCount = stepCount; } //! Destructor QwtPolarFitter::~QwtPolarFitter() { - delete m_data; + delete m_data; } /*! @@ -48,9 +48,9 @@ QwtPolarFitter::~QwtPolarFitter() \sa stepCount() */ -void QwtPolarFitter::setStepCount( int stepCount ) +void QwtPolarFitter::setStepCount(int stepCount) { - m_data->stepCount = qMax( stepCount, 0 ); + m_data->stepCount = qMax(stepCount, 0); } /*! @@ -59,7 +59,7 @@ void QwtPolarFitter::setStepCount( int stepCount ) */ int QwtPolarFitter::stepCount() const { - return m_data->stepCount; + return m_data->stepCount; } /*! @@ -69,37 +69,37 @@ int QwtPolarFitter::stepCount() const \param points Array of points \return Array of points including the additional points */ -QPolygonF QwtPolarFitter::fitCurve( const QPolygonF& points ) const +QPolygonF QwtPolarFitter::fitCurve(const QPolygonF &points) const { - if ( m_data->stepCount <= 0 || points.size() <= 1 ) - return points; + if (m_data->stepCount <= 0 || points.size() <= 1) + return points; - QPolygonF fittedPoints; + QPolygonF fittedPoints; - int numPoints = points.size() + ( points.size() - 1 ) * m_data->stepCount; + int numPoints = points.size() + (points.size() - 1) * m_data->stepCount; - fittedPoints.resize( numPoints ); + fittedPoints.resize(numPoints); - int index = 0; - fittedPoints[index++] = points[0]; - for ( int i = 1; i < points.size(); i++ ) + int index = 0; + fittedPoints[index++] = points[0]; + for (int i = 1; i < points.size(); i++) + { + const QPointF &p1 = points[i - 1]; + const QPointF &p2 = points[i]; + + const double dx = (p2.x() - p1.x()) / m_data->stepCount; + const double dy = (p2.y() - p1.y()) / m_data->stepCount; + for (int j = 1; j <= m_data->stepCount; j++) { - const QPointF& p1 = points[i - 1]; - const QPointF& p2 = points[i]; + const double x = p1.x() + j * dx; + const double y = p1.y() + j * dy; - const double dx = ( p2.x() - p1.x() ) / m_data->stepCount; - const double dy = ( p2.y() - p1.y() ) / m_data->stepCount; - for ( int j = 1; j <= m_data->stepCount; j++ ) - { - const double x = p1.x() + j * dx; - const double y = p1.y() + j * dy; - - fittedPoints[index++] = QPointF( x, y ); - } + fittedPoints[index++] = QPointF(x, y); } - fittedPoints.resize( index ); + } + fittedPoints.resize(index); - return fittedPoints; + return fittedPoints; } /*! @@ -107,9 +107,9 @@ QPolygonF QwtPolarFitter::fitCurve( const QPolygonF& points ) const \return Curve path \sa fitCurve() */ -QPainterPath QwtPolarFitter::fitCurvePath( const QPolygonF& points ) const +QPainterPath QwtPolarFitter::fitCurvePath(const QPolygonF &points) const { - QPainterPath path; - path.addPolygon( fitCurve( points ) ); - return path; + QPainterPath path; + path.addPolygon(fitCurve(points)); + return path; } diff --git a/libs/qwt/src/qwt_polar_fitter.h b/libs/qwt/src/qwt_polar_fitter.h index ad19b508..d9b3b997 100644 --- a/libs/qwt/src/qwt_polar_fitter.h +++ b/libs/qwt/src/qwt_polar_fitter.h @@ -23,19 +23,19 @@ */ class QWT_EXPORT QwtPolarFitter : public QwtCurveFitter { - public: - QwtPolarFitter( int stepCount = 5 ); - virtual ~QwtPolarFitter(); +public: + QwtPolarFitter(int stepCount = 5); + virtual ~QwtPolarFitter(); - void setStepCount( int size ); - int stepCount() const; + void setStepCount(int size); + int stepCount() const; - virtual QPolygonF fitCurve( const QPolygonF& ) const QWT_OVERRIDE; - virtual QPainterPath fitCurvePath( const QPolygonF& ) const QWT_OVERRIDE; + virtual QPolygonF fitCurve(const QPolygonF &) const QWT_OVERRIDE; + virtual QPainterPath fitCurvePath(const QPolygonF &) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_grid.cpp b/libs/qwt/src/qwt_polar_grid.cpp index b8cea2e4..a4940936 100644 --- a/libs/qwt/src/qwt_polar_grid.cpp +++ b/libs/qwt/src/qwt_polar_grid.cpp @@ -20,58 +20,55 @@ #include #include -static inline bool isClose( double value1, double value2 ) +static inline bool isClose(double value1, double value2) { - return qAbs( value1 - value2 ) < DBL_EPSILON; + return qAbs(value1 - value2) < DBL_EPSILON; } namespace QwtPolarGridPrivate { - class AxisData - { - public: - AxisData() - : isVisible( false ) - , scaleDraw( NULL ) - { - } +class AxisData +{ +public: + AxisData() + : isVisible(false) + , scaleDraw(NULL) + { + } - ~AxisData() - { - delete scaleDraw; - } + ~AxisData() { delete scaleDraw; } - bool isVisible; - mutable QwtAbstractScaleDraw* scaleDraw; - QPen pen; - QFont font; - }; + bool isVisible; + mutable QwtAbstractScaleDraw *scaleDraw; + QPen pen; + QFont font; +}; - class GridData - { - public: - GridData() - : isVisible( true ) - , isMinorVisible( false ) - { - } +class GridData +{ +public: + GridData() + : isVisible(true) + , isMinorVisible(false) + { + } - bool isVisible; - bool isMinorVisible; - QwtScaleDiv scaleDiv; + bool isVisible; + bool isMinorVisible; + QwtScaleDiv scaleDiv; - QPen majorPen; - QPen minorPen; - }; -} + QPen majorPen; + QPen minorPen; +}; +} // namespace QwtPolarGridPrivate class QwtPolarGrid::PrivateData { - public: - QwtPolarGridPrivate::GridData gridData[QwtPolar::ScaleCount]; - QwtPolarGridPrivate::AxisData axisData[QwtPolar::AxesCount]; - QwtPolarGrid::DisplayFlags displayFlags; - QwtPolarGrid::GridAttributes attributes; +public: + QwtPolarGridPrivate::GridData gridData[QwtPolar::ScaleCount]; + QwtPolarGridPrivate::AxisData axisData[QwtPolar::AxesCount]; + QwtPolarGrid::DisplayFlags displayFlags; + QwtPolarGrid::GridAttributes attributes; }; /*! @@ -82,87 +79,82 @@ class QwtPolarGrid::PrivateData are hidden. Autoscaling is enabled. */ QwtPolarGrid::QwtPolarGrid() - : QwtPolarItem( QwtText( "Grid" ) ) + : QwtPolarItem(QwtText("Grid")) { - m_data = new PrivateData; + m_data = new PrivateData; - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) + { + QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + switch (axisId) { - QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; - switch( axisId ) - { - case QwtPolar::AxisAzimuth: - { - axis.scaleDraw = new QwtRoundScaleDraw; - axis.scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 2 ); - axis.scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 2 ); - axis.scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 4 ); - axis.isVisible = true; - break; - } - case QwtPolar::AxisLeft: - { - QwtScaleDraw* scaleDraw = new QwtScaleDraw; - scaleDraw->setAlignment( QwtScaleDraw::BottomScale ); + case QwtPolar::AxisAzimuth: { + axis.scaleDraw = new QwtRoundScaleDraw; + axis.scaleDraw->setTickLength(QwtScaleDiv::MinorTick, 2); + axis.scaleDraw->setTickLength(QwtScaleDiv::MediumTick, 2); + axis.scaleDraw->setTickLength(QwtScaleDiv::MajorTick, 4); + axis.isVisible = true; + break; + } + case QwtPolar::AxisLeft: { + QwtScaleDraw *scaleDraw = new QwtScaleDraw; + scaleDraw->setAlignment(QwtScaleDraw::BottomScale); - axis.scaleDraw = scaleDraw; - axis.isVisible = false; - break; - } - case QwtPolar::AxisRight: - { - QwtScaleDraw* scaleDraw = new QwtScaleDraw; - scaleDraw->setAlignment( QwtScaleDraw::BottomScale ); + axis.scaleDraw = scaleDraw; + axis.isVisible = false; + break; + } + case QwtPolar::AxisRight: { + QwtScaleDraw *scaleDraw = new QwtScaleDraw; + scaleDraw->setAlignment(QwtScaleDraw::BottomScale); - axis.scaleDraw = scaleDraw; - axis.isVisible = true; - break; - } - case QwtPolar::AxisTop: - { - QwtScaleDraw* scaleDraw = new QwtScaleDraw; - scaleDraw->setAlignment( QwtScaleDraw::LeftScale ); + axis.scaleDraw = scaleDraw; + axis.isVisible = true; + break; + } + case QwtPolar::AxisTop: { + QwtScaleDraw *scaleDraw = new QwtScaleDraw; + scaleDraw->setAlignment(QwtScaleDraw::LeftScale); - axis.scaleDraw = scaleDraw; - axis.isVisible = false; - break; - } - case QwtPolar::AxisBottom: - { - QwtScaleDraw* scaleDraw = new QwtScaleDraw; - scaleDraw->setAlignment( QwtScaleDraw::LeftScale ); + axis.scaleDraw = scaleDraw; + axis.isVisible = false; + break; + } + case QwtPolar::AxisBottom: { + QwtScaleDraw *scaleDraw = new QwtScaleDraw; + scaleDraw->setAlignment(QwtScaleDraw::LeftScale); - axis.scaleDraw = scaleDraw; - axis.isVisible = true; - break; - } - default:; - } + axis.scaleDraw = scaleDraw; + axis.isVisible = true; + break; + } + default:; } + } - m_data->attributes = AutoScaling; + m_data->attributes = AutoScaling; - m_data->displayFlags = DisplayFlags(); - m_data->displayFlags |= SmartOriginLabel; - m_data->displayFlags |= HideMaxRadiusLabel; - m_data->displayFlags |= ClipAxisBackground; - m_data->displayFlags |= SmartScaleDraw; - m_data->displayFlags |= ClipGridLines; + m_data->displayFlags = DisplayFlags(); + m_data->displayFlags |= SmartOriginLabel; + m_data->displayFlags |= HideMaxRadiusLabel; + m_data->displayFlags |= ClipAxisBackground; + m_data->displayFlags |= SmartScaleDraw; + m_data->displayFlags |= ClipGridLines; - setZ( 10.0 ); - setRenderHint( RenderAntialiased, true ); + setZ(10.0); + setRenderHint(RenderAntialiased, true); } //! Destructor QwtPolarGrid::~QwtPolarGrid() { - delete m_data; + delete m_data; } //! \return QwtPlotItem::Rtti_PolarGrid int QwtPolarGrid::rtti() const { - return QwtPolarItem::Rtti_PolarGrid; + return QwtPolarItem::Rtti_PolarGrid; } /*! @@ -171,26 +163,26 @@ int QwtPolarGrid::rtti() const \param flag See DisplayFlag \param on true/false */ -void QwtPolarGrid::setDisplayFlag( DisplayFlag flag, bool on ) +void QwtPolarGrid::setDisplayFlag(DisplayFlag flag, bool on) { - if ( ( ( m_data->displayFlags & flag ) != 0 ) != on ) - { - if ( on ) - m_data->displayFlags |= flag; - else - m_data->displayFlags &= ~flag; + if (((m_data->displayFlags & flag) != 0) != on) + { + if (on) + m_data->displayFlags |= flag; + else + m_data->displayFlags &= ~flag; - itemChanged(); - } + itemChanged(); + } } /*! \return true, if flag is enabled \param flag See DisplayFlag */ -bool QwtPolarGrid::testDisplayFlag( DisplayFlag flag ) const +bool QwtPolarGrid::testDisplayFlag(DisplayFlag flag) const { - return ( m_data->displayFlags & flag ); + return (m_data->displayFlags & flag); } /*! @@ -202,26 +194,26 @@ bool QwtPolarGrid::testDisplayFlag( DisplayFlag flag ) const /sa GridAttribute, testGridAttribute(), updateScaleDiv(), QwtPolarPlot::zoom(), QwtPolarPlot::scaleDiv() */ -void QwtPolarGrid::setGridAttribute( GridAttribute attribute, bool on ) +void QwtPolarGrid::setGridAttribute(GridAttribute attribute, bool on) { - if ( bool( m_data->attributes & attribute ) == on ) - return; + if (bool(m_data->attributes & attribute) == on) + return; - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; - itemChanged(); + itemChanged(); } /*! \return true, if attribute is enabled \sa GridAttribute, setGridAttribute() */ -bool QwtPolarGrid::testGridAttribute( GridAttribute attribute ) const +bool QwtPolarGrid::testGridAttribute(GridAttribute attribute) const { - return m_data->attributes & attribute; + return m_data->attributes & attribute; } /*! @@ -232,17 +224,17 @@ bool QwtPolarGrid::testGridAttribute( GridAttribute attribute ) const \sa axisPen() */ -void QwtPolarGrid::setAxisPen( int axisId, const QPen& pen ) +void QwtPolarGrid::setAxisPen(int axisId, const QPen &pen) { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return; + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return; - QwtPolarGridPrivate::AxisData& axisData = m_data->axisData[axisId]; - if ( axisData.pen != pen ) - { - axisData.pen = pen; - itemChanged(); - } + QwtPolarGridPrivate::AxisData &axisData = m_data->axisData[axisId]; + if (axisData.pen != pen) + { + axisData.pen = pen; + itemChanged(); + } } /*! @@ -251,17 +243,17 @@ void QwtPolarGrid::setAxisPen( int axisId, const QPen& pen ) \param scaleId Scale id ( QwtPolar::Scale ) \param show true/false */ -void QwtPolarGrid::showGrid( int scaleId, bool show ) +void QwtPolarGrid::showGrid(int scaleId, bool show) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.isVisible != show ) - { - grid.isVisible = show; - itemChanged(); - } + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.isVisible != show) + { + grid.isVisible = show; + itemChanged(); + } } /*! @@ -269,12 +261,12 @@ void QwtPolarGrid::showGrid( int scaleId, bool show ) \param scaleId Scale id ( QwtPolar::Scale ) \sa QwtPolar::Scale, showGrid() */ -bool QwtPolarGrid::isGridVisible( int scaleId ) const +bool QwtPolarGrid::isGridVisible(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return false; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return false; - return m_data->gridData[scaleId].isVisible; + return m_data->gridData[scaleId].isVisible; } /*! @@ -287,17 +279,17 @@ bool QwtPolarGrid::isGridVisible( int scaleId ) const \sa showGrid */ -void QwtPolarGrid::showMinorGrid( int scaleId, bool show ) +void QwtPolarGrid::showMinorGrid(int scaleId, bool show) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.isMinorVisible != show ) - { - grid.isMinorVisible = show; - itemChanged(); - } + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.isMinorVisible != show) + { + grid.isMinorVisible = show; + itemChanged(); + } } /*! @@ -305,12 +297,12 @@ void QwtPolarGrid::showMinorGrid( int scaleId, bool show ) \param scaleId Scale id ( QwtPolar::Scale ) \sa showMinorGrid() */ -bool QwtPolarGrid::isMinorGridVisible( int scaleId ) const +bool QwtPolarGrid::isMinorGridVisible(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return false; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return false; - return m_data->gridData[scaleId].isMinorVisible; + return m_data->gridData[scaleId].isMinorVisible; } /*! @@ -321,17 +313,17 @@ bool QwtPolarGrid::isMinorGridVisible( int scaleId ) const \sa isAxisVisible() */ -void QwtPolarGrid::showAxis( int axisId, bool show ) +void QwtPolarGrid::showAxis(int axisId, bool show) { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return; + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return; - QwtPolarGridPrivate::AxisData& axisData = m_data->axisData[axisId]; - if ( axisData.isVisible != show ) - { - axisData.isVisible = show; - itemChanged(); - } + QwtPolarGridPrivate::AxisData &axisData = m_data->axisData[axisId]; + if (axisData.isVisible != show) + { + axisData.isVisible = show; + itemChanged(); + } } /*! @@ -340,12 +332,12 @@ void QwtPolarGrid::showAxis( int axisId, bool show ) \sa showAxis() */ -bool QwtPolarGrid::isAxisVisible( int axisId ) const +bool QwtPolarGrid::isAxisVisible(int axisId) const { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return false; + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return false; - return m_data->axisData[axisId].isVisible; + return m_data->axisData[axisId].isVisible; } /*! @@ -354,31 +346,31 @@ bool QwtPolarGrid::isAxisVisible( int axisId ) const \param pen Pen \sa setMajorGridPen(), setMinorGridPen(), setAxisPen() */ -void QwtPolarGrid::setPen( const QPen& pen ) +void QwtPolarGrid::setPen(const QPen &pen) { - bool isChanged = false; + bool isChanged = false; - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + { + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.majorPen != pen || grid.minorPen != pen) { - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.majorPen != pen || grid.minorPen != pen ) - { - grid.majorPen = pen; - grid.minorPen = pen; - isChanged = true; - } + grid.majorPen = pen; + grid.minorPen = pen; + isChanged = true; } - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) + } + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) + { + QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + if (axis.pen != pen) { - QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; - if ( axis.pen != pen ) - { - axis.pen = pen; - isChanged = true; - } + axis.pen = pen; + isChanged = true; } - if ( isChanged ) - itemChanged(); + } + if (isChanged) + itemChanged(); } /*! @@ -387,20 +379,20 @@ void QwtPolarGrid::setPen( const QPen& pen ) \param font Font \sa setAxisFont() */ -void QwtPolarGrid::setFont( const QFont& font ) +void QwtPolarGrid::setFont(const QFont &font) { - bool isChanged = false; - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) + bool isChanged = false; + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) + { + QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + if (axis.font != font) { - QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; - if ( axis.font != font ) - { - axis.font = font; - isChanged = true; - } + axis.font = font; + isChanged = true; } - if ( isChanged ) - itemChanged(); + } + if (isChanged) + itemChanged(); } /*! @@ -409,21 +401,21 @@ void QwtPolarGrid::setFont( const QFont& font ) \param pen Pen \sa setPen(), setMinorGridPen(), majorGridPen */ -void QwtPolarGrid::setMajorGridPen( const QPen& pen ) +void QwtPolarGrid::setMajorGridPen(const QPen &pen) { - bool isChanged = false; + bool isChanged = false; - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + { + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.majorPen != pen) { - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.majorPen != pen ) - { - grid.majorPen = pen; - isChanged = true; - } + grid.majorPen = pen; + isChanged = true; } - if ( isChanged ) - itemChanged(); + } + if (isChanged) + itemChanged(); } /*! @@ -433,17 +425,17 @@ void QwtPolarGrid::setMajorGridPen( const QPen& pen ) \param pen Pen \sa setPen(), setMinorGridPen(), majorGridPen */ -void QwtPolarGrid::setMajorGridPen( int scaleId, const QPen& pen ) +void QwtPolarGrid::setMajorGridPen(int scaleId, const QPen &pen) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.majorPen != pen ) - { - grid.majorPen = pen; - itemChanged(); - } + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.majorPen != pen) + { + grid.majorPen = pen; + itemChanged(); + } } /*! @@ -451,13 +443,13 @@ void QwtPolarGrid::setMajorGridPen( int scaleId, const QPen& pen ) \param scaleId Scale id ( QwtPolar::Scale ) \sa setMajorGridPen(), minorGridPen() */ -QPen QwtPolarGrid::majorGridPen( int scaleId ) const +QPen QwtPolarGrid::majorGridPen(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return QPen(); + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return QPen(); - const QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - return grid.majorPen; + const QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + return grid.majorPen; } /*! @@ -466,21 +458,21 @@ QPen QwtPolarGrid::majorGridPen( int scaleId ) const \param pen Pen \sa setPen(), setMajorGridPen(), minorGridPen() */ -void QwtPolarGrid::setMinorGridPen( const QPen& pen ) +void QwtPolarGrid::setMinorGridPen(const QPen &pen) { - bool isChanged = false; + bool isChanged = false; - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + { + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.minorPen != pen) { - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.minorPen != pen ) - { - grid.minorPen = pen; - isChanged = true; - } + grid.minorPen = pen; + isChanged = true; } - if ( isChanged ) - itemChanged(); + } + if (isChanged) + itemChanged(); } /*! @@ -490,30 +482,30 @@ void QwtPolarGrid::setMinorGridPen( const QPen& pen ) \param pen Pen \sa setPen(), setMajorGridPen(), minorGridPen */ -void QwtPolarGrid::setMinorGridPen( int scaleId, const QPen& pen ) +void QwtPolarGrid::setMinorGridPen(int scaleId, const QPen &pen) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - if ( grid.minorPen != pen ) - { - grid.minorPen = pen; - itemChanged(); - } + QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + if (grid.minorPen != pen) + { + grid.minorPen = pen; + itemChanged(); + } } /*! \return Pen for painting the minor grid lines of a specific scale \param scaleId Scale id ( QwtPolar::Scale ) */ -QPen QwtPolarGrid::minorGridPen( int scaleId ) const +QPen QwtPolarGrid::minorGridPen(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return QPen(); + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return QPen(); - const QwtPolarGridPrivate::GridData& grid = m_data->gridData[scaleId]; - return grid.minorPen; + const QwtPolarGridPrivate::GridData &grid = m_data->gridData[scaleId]; + return grid.minorPen; } /*! @@ -522,12 +514,12 @@ QPen QwtPolarGrid::minorGridPen( int scaleId ) const \param axisId Axis id (QwtPolar::Axis) \sa setAxisPen() */ -QPen QwtPolarGrid::axisPen( int axisId ) const +QPen QwtPolarGrid::axisPen(int axisId) const { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return QPen(); + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return QPen(); - return m_data->axisData[axisId].pen; + return m_data->axisData[axisId].pen; } /*! @@ -536,29 +528,29 @@ QPen QwtPolarGrid::axisPen( int axisId ) const \param axisId Axis id (QwtPolar::Axis) \param font new Font */ -void QwtPolarGrid::setAxisFont( int axisId, const QFont& font ) +void QwtPolarGrid::setAxisFont(int axisId, const QFont &font) { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return; + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return; - QwtPolarGridPrivate::AxisData& axisData = m_data->axisData[axisId]; - if ( axisData.font != font ) - { - axisData.font = font; - itemChanged(); - } + QwtPolarGridPrivate::AxisData &axisData = m_data->axisData[axisId]; + if (axisData.font != font) + { + axisData.font = font; + itemChanged(); + } } /*! \return Font for the tick labels of a specific axis \param axisId Axis id (QwtPolar::Axis) */ -QFont QwtPolarGrid::axisFont( int axisId ) const +QFont QwtPolarGrid::axisFont(int axisId) const { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return QFont(); + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return QFont(); - return m_data->axisData[axisId].font; + return m_data->axisData[axisId].font; } /*! @@ -571,101 +563,100 @@ QFont QwtPolarGrid::axisFont( int axisId ) const \param radius Radius of the complete plot area in painter coordinates \param canvasRect Contents rect of the canvas in painter coordinates */ -void QwtPolarGrid::draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const +void QwtPolarGrid::draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const { - updateScaleDraws( azimuthMap, radialMap, pole, radius ); + updateScaleDraws(azimuthMap, radialMap, pole, radius); - painter->save(); + painter->save(); - if ( testDisplayFlag( ClipAxisBackground ) ) + if (testDisplayFlag(ClipAxisBackground)) + { + QRegion clipRegion(canvasRect.toRect()); + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) { - QRegion clipRegion( canvasRect.toRect() ); - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) + const QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + if (axisId != QwtPolar::AxisAzimuth && axis.isVisible) + { + QwtScaleDraw *scaleDraw = static_cast(axis.scaleDraw); + if (scaleDraw->hasComponent(QwtScaleDraw::Labels)) { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; - if ( axisId != QwtPolar::AxisAzimuth && axis.isVisible ) - { - QwtScaleDraw* scaleDraw = static_cast< QwtScaleDraw* >( axis.scaleDraw ); - if ( scaleDraw->hasComponent( QwtScaleDraw::Labels ) ) - { - const QList< double >& ticks = - scaleDraw->scaleDiv().ticks( QwtScaleDiv::MajorTick ); - for ( int i = 0; i < int( ticks.size() ); i++ ) - { - if ( !scaleDraw->scaleDiv().contains( ticks[i] ) ) - continue; + const QList &ticks + = scaleDraw->scaleDiv().ticks(QwtScaleDiv::MajorTick); + for (int i = 0; i < int(ticks.size()); i++) + { + if (!scaleDraw->scaleDiv().contains(ticks[i])) + continue; - QRect labelRect = - scaleDraw->boundingLabelRect( axis.font, ticks[i] ); + QRect labelRect = scaleDraw->boundingLabelRect(axis.font, ticks[i]); - const int margin = 2; - labelRect.adjust( -margin, -margin, margin, margin ); + const int margin = 2; + labelRect.adjust(-margin, -margin, margin, margin); - if ( labelRect.isValid() ) - clipRegion -= QRegion( labelRect ); - } - } - } + if (labelRect.isValid()) + clipRegion -= QRegion(labelRect); + } } - painter->setClipRegion( clipRegion ); + } } + painter->setClipRegion(clipRegion); + } - // draw radial grid + // draw radial grid - const QwtPolarGridPrivate::GridData& radialGrid = m_data->gridData[QwtPolar::Radius]; - if ( radialGrid.isVisible && radialGrid.isMinorVisible ) + const QwtPolarGridPrivate::GridData &radialGrid + = m_data->gridData[QwtPolar::Radius]; + if (radialGrid.isVisible && radialGrid.isMinorVisible) + { + painter->setPen(radialGrid.minorPen); + + drawCircles(painter, canvasRect, pole, radialMap, + radialGrid.scaleDiv.ticks(QwtScaleDiv::MinorTick)); + drawCircles(painter, canvasRect, pole, radialMap, + radialGrid.scaleDiv.ticks(QwtScaleDiv::MediumTick)); + } + if (radialGrid.isVisible) + { + painter->setPen(radialGrid.majorPen); + + drawCircles(painter, canvasRect, pole, radialMap, + radialGrid.scaleDiv.ticks(QwtScaleDiv::MajorTick)); + } + + // draw azimuth grid + + const QwtPolarGridPrivate::GridData &azimuthGrid + = m_data->gridData[QwtPolar::Azimuth]; + + if (azimuthGrid.isVisible && azimuthGrid.isMinorVisible) + { + painter->setPen(azimuthGrid.minorPen); + + drawRays(painter, canvasRect, pole, radius, azimuthMap, + azimuthGrid.scaleDiv.ticks(QwtScaleDiv::MinorTick)); + drawRays(painter, canvasRect, pole, radius, azimuthMap, + azimuthGrid.scaleDiv.ticks(QwtScaleDiv::MediumTick)); + } + if (azimuthGrid.isVisible) + { + painter->setPen(azimuthGrid.majorPen); + + drawRays(painter, canvasRect, pole, radius, azimuthMap, + azimuthGrid.scaleDiv.ticks(QwtScaleDiv::MajorTick)); + } + painter->restore(); + + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) + { + const QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + if (axis.isVisible) { - painter->setPen( radialGrid.minorPen ); - - drawCircles( painter, canvasRect, pole, radialMap, - radialGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) ); - drawCircles( painter, canvasRect, pole, radialMap, - radialGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) ); - } - if ( radialGrid.isVisible ) - { - painter->setPen( radialGrid.majorPen ); - - drawCircles( painter, canvasRect, pole, radialMap, - radialGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) ); - } - - // draw azimuth grid - - const QwtPolarGridPrivate::GridData& azimuthGrid = - m_data->gridData[QwtPolar::Azimuth]; - - if ( azimuthGrid.isVisible && azimuthGrid.isMinorVisible ) - { - painter->setPen( azimuthGrid.minorPen ); - - drawRays( painter, canvasRect, pole, radius, azimuthMap, - azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) ); - drawRays( painter, canvasRect, pole, radius, azimuthMap, - azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) ); - } - if ( azimuthGrid.isVisible ) - { - painter->setPen( azimuthGrid.majorPen ); - - drawRays( painter, canvasRect, pole, radius, azimuthMap, - azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) ); - } - painter->restore(); - - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) - { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; - if ( axis.isVisible ) - { - painter->save(); - drawAxis( painter, axisId ); - painter->restore(); - } + painter->save(); + drawAxis(painter, axisId); + painter->restore(); } + } } /*! @@ -678,65 +669,69 @@ void QwtPolarGrid::draw( QPainter* painter, \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI \param values Azimuth values, indicating the direction of the lines */ -void QwtPolarGrid::drawRays( - QPainter* painter, const QRectF& canvasRect, - const QPointF& pole, double radius, - const QwtScaleMap& azimuthMap, const QList< double >& values ) const +void QwtPolarGrid::drawRays(QPainter *painter, const QRectF &canvasRect, + const QPointF &pole, double radius, + const QwtScaleMap &azimuthMap, + const QList &values) const { - for ( int i = 0; i < int( values.size() ); i++ ) + for (int i = 0; i < int(values.size()); i++) + { + double azimuth = azimuthMap.transform(values[i]); + azimuth = ::fmod(azimuth, 2 * M_PI); + + bool skipLine = false; + if (testDisplayFlag(SmartScaleDraw)) { - double azimuth = azimuthMap.transform( values[i] ); - azimuth = ::fmod( azimuth, 2 * M_PI ); - - bool skipLine = false; - if ( testDisplayFlag( SmartScaleDraw ) ) - { - const QwtAbstractScaleDraw::ScaleComponent bone = - QwtAbstractScaleDraw::Backbone; - if ( isClose( azimuth, 0.0 ) ) - { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[QwtPolar::AxisRight]; - if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) - skipLine = true; - } - else if ( isClose( azimuth, M_PI / 2 ) ) - { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[QwtPolar::AxisTop]; - if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) - skipLine = true; - } - else if ( isClose( azimuth, M_PI ) ) - { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[QwtPolar::AxisLeft]; - if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) - skipLine = true; - } - else if ( isClose( azimuth, 3 * M_PI / 2.0 ) ) - { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[QwtPolar::AxisBottom]; - if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) ) - skipLine = true; - } - } - if ( !skipLine ) - { - const QPointF pos = qwtPolar2Pos( pole, radius, azimuth ); - - /* - Qt4 is horrible slow, when painting primitives, - with coordinates far outside the visible area. - */ - - QPolygonF polygon( 2 ); - polygon[0] = pole.toPoint(); - polygon[1] = pos.toPoint(); - - if ( testDisplayFlag( ClipGridLines ) ) - QwtClipper::clipPolygonF( canvasRect, polygon ); - - QwtPainter::drawPolyline( painter, polygon ); - } + const QwtAbstractScaleDraw::ScaleComponent bone + = QwtAbstractScaleDraw::Backbone; + if (isClose(azimuth, 0.0)) + { + const QwtPolarGridPrivate::AxisData &axis + = m_data->axisData[QwtPolar::AxisRight]; + if (axis.isVisible && axis.scaleDraw->hasComponent(bone)) + skipLine = true; + } + else if (isClose(azimuth, M_PI / 2)) + { + const QwtPolarGridPrivate::AxisData &axis + = m_data->axisData[QwtPolar::AxisTop]; + if (axis.isVisible && axis.scaleDraw->hasComponent(bone)) + skipLine = true; + } + else if (isClose(azimuth, M_PI)) + { + const QwtPolarGridPrivate::AxisData &axis + = m_data->axisData[QwtPolar::AxisLeft]; + if (axis.isVisible && axis.scaleDraw->hasComponent(bone)) + skipLine = true; + } + else if (isClose(azimuth, 3 * M_PI / 2.0)) + { + const QwtPolarGridPrivate::AxisData &axis + = m_data->axisData[QwtPolar::AxisBottom]; + if (axis.isVisible && axis.scaleDraw->hasComponent(bone)) + skipLine = true; + } } + if (!skipLine) + { + const QPointF pos = qwtPolar2Pos(pole, radius, azimuth); + + /* + Qt4 is horrible slow, when painting primitives, + with coordinates far outside the visible area. + */ + + QPolygonF polygon(2); + polygon[0] = pole.toPoint(); + polygon[1] = pos.toPoint(); + + if (testDisplayFlag(ClipGridLines)) + QwtClipper::clipPolygonF(canvasRect, polygon); + + QwtPainter::drawPolyline(painter, polygon); + } + } } /*! @@ -748,79 +743,79 @@ void QwtPolarGrid::drawRays( \param radialMap Maps radius values into painter coordinates. \param values Radial values, indicating the distances from the pole */ -void QwtPolarGrid::drawCircles( - QPainter* painter, const QRectF& canvasRect, - const QPointF& pole, const QwtScaleMap& radialMap, - const QList< double >& values ) const +void QwtPolarGrid::drawCircles(QPainter *painter, const QRectF &canvasRect, + const QPointF &pole, + const QwtScaleMap &radialMap, + const QList &values) const { - for ( int i = 0; i < int( values.size() ); i++ ) + for (int i = 0; i < int(values.size()); i++) + { + const double val = values[i]; + + const QwtPolarGridPrivate::GridData &gridData + = m_data->gridData[QwtPolar::Radius]; + + bool skipLine = false; + if (testDisplayFlag(SmartScaleDraw)) { - const double val = values[i]; - - const QwtPolarGridPrivate::GridData& gridData = - m_data->gridData[QwtPolar::Radius]; - - bool skipLine = false; - if ( testDisplayFlag( SmartScaleDraw ) ) - { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[QwtPolar::AxisAzimuth]; - if ( axis.isVisible && - axis.scaleDraw->hasComponent( QwtAbstractScaleDraw::Backbone ) ) - { - if ( isClose( val, gridData.scaleDiv.upperBound() ) ) - skipLine = true; - } - } - - if ( isClose( val, gridData.scaleDiv.lowerBound() ) ) - skipLine = true; - - if ( !skipLine ) - { - const double radius = radialMap.transform( val ); - - QRectF outerRect( 0, 0, 2 * radius, 2 * radius ); - outerRect.moveCenter( pole ); - - if ( testDisplayFlag( ClipGridLines ) ) - { - /* - Qt4 is horrible slow, when painting primitives, - with coordinates far outside the visible area. - We need to clip. - */ - - const QVector< QwtInterval > angles = - QwtClipper::clipCircle( canvasRect, pole, radius ); - - for ( int j = 0; j < angles.size(); j++ ) - { - const QwtInterval intv = angles[j]; - - if ( intv.minValue() == 0 && intv.maxValue() == 2 * M_PI ) - { - QwtPainter::drawEllipse( painter, outerRect ); - } - else - { - const double from = qwtDegrees( intv.minValue() ); - const double to = qwtDegrees( intv.maxValue() ); - - double span = to - from; - if ( span < 0.0 ) - span += 360.0; - - painter->drawArc( outerRect, - qRound( from * 16 ), qRound( span * 16 ) ); - } - } - } - else - { - QwtPainter::drawEllipse( painter, outerRect ); - } - } + const QwtPolarGridPrivate::AxisData &axis + = m_data->axisData[QwtPolar::AxisAzimuth]; + if (axis.isVisible + && axis.scaleDraw->hasComponent(QwtAbstractScaleDraw::Backbone)) + { + if (isClose(val, gridData.scaleDiv.upperBound())) + skipLine = true; + } } + + if (isClose(val, gridData.scaleDiv.lowerBound())) + skipLine = true; + + if (!skipLine) + { + const double radius = radialMap.transform(val); + + QRectF outerRect(0, 0, 2 * radius, 2 * radius); + outerRect.moveCenter(pole); + + if (testDisplayFlag(ClipGridLines)) + { + /* + Qt4 is horrible slow, when painting primitives, + with coordinates far outside the visible area. + We need to clip. + */ + + const QVector angles + = QwtClipper::clipCircle(canvasRect, pole, radius); + + for (int j = 0; j < angles.size(); j++) + { + const QwtInterval intv = angles[j]; + + if (intv.minValue() == 0 && intv.maxValue() == 2 * M_PI) + { + QwtPainter::drawEllipse(painter, outerRect); + } + else + { + const double from = qwtDegrees(intv.minValue()); + const double to = qwtDegrees(intv.maxValue()); + + double span = to - from; + if (span < 0.0) + span += 360.0; + + painter->drawArc(outerRect, qRound(from * 16), qRound(span * 16)); + } + } + } + else + { + QwtPainter::drawEllipse(painter, outerRect); + } + } + } } /*! @@ -829,21 +824,21 @@ void QwtPolarGrid::drawCircles( \param painter Painter \param axisId Axis id (QwtPolar::Axis) */ -void QwtPolarGrid::drawAxis( QPainter* painter, int axisId ) const +void QwtPolarGrid::drawAxis(QPainter *painter, int axisId) const { - if ( axisId < 0 || axisId >= QwtPolar::AxesCount ) - return; + if (axisId < 0 || axisId >= QwtPolar::AxesCount) + return; - QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; + QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; - painter->setPen( axis.pen ); - painter->setFont( axis.font ); + painter->setPen(axis.pen); + painter->setFont(axis.font); - QPalette pal; - pal.setColor( QPalette::WindowText, axis.pen.color() ); - pal.setColor( QPalette::Text, axis.pen.color() ); + QPalette pal; + pal.setColor(QPalette::WindowText, axis.pen.color()); + pal.setColor(QPalette::Text, axis.pen.color()); - axis.scaleDraw->draw( painter, pal ); + axis.scaleDraw->draw(painter, pal); } /*! @@ -856,82 +851,77 @@ void QwtPolarGrid::drawAxis( QPainter* painter, int axisId ) const \sa updateScaleDiv() */ -void QwtPolarGrid::updateScaleDraws( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius ) const +void QwtPolarGrid::updateScaleDraws(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, + const QPointF &pole, double radius) const { - const QPoint p = pole.toPoint(); + const QPoint p = pole.toPoint(); - const QwtInterval interval = - m_data->gridData[QwtPolar::ScaleRadius].scaleDiv.interval(); + const QwtInterval interval + = m_data->gridData[QwtPolar::ScaleRadius].scaleDiv.interval(); - const int min = radialMap.transform( interval.minValue() ); - const int max = radialMap.transform( interval.maxValue() ); - const int l = max - min; + const int min = radialMap.transform(interval.minValue()); + const int max = radialMap.transform(interval.maxValue()); + const int l = max - min; - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) + { + QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + + if (axisId == QwtPolar::AxisAzimuth) { - QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; + QwtRoundScaleDraw *scaleDraw + = static_cast(axis.scaleDraw); - if ( axisId == QwtPolar::AxisAzimuth ) - { - QwtRoundScaleDraw* scaleDraw = - static_cast< QwtRoundScaleDraw* >( axis.scaleDraw ); + scaleDraw->setRadius(qRound(radius)); + scaleDraw->moveCenter(p); - scaleDraw->setRadius( qRound( radius ) ); - scaleDraw->moveCenter( p ); + double from = ::fmod(90.0 - qwtDegrees(azimuthMap.p1()), 360.0); + if (from < 0.0) + from += 360.0; - double from = ::fmod( 90.0 - qwtDegrees( azimuthMap.p1() ), 360.0 ); - if ( from < 0.0 ) - from += 360.0; + scaleDraw->setAngleRange(from, from - 360.0); - scaleDraw->setAngleRange( from, from - 360.0 ); - - const QwtTransform* transform = azimuthMap.transformation(); - if ( transform ) - scaleDraw->setTransformation( transform->copy() ); - else - scaleDraw->setTransformation( NULL ); - } - else - { - QwtScaleDraw* scaleDraw = - static_cast< QwtScaleDraw* >( axis.scaleDraw ); - - switch( axisId ) - { - case QwtPolar::AxisLeft: - { - scaleDraw->move( p.x() - min, p.y() ); - scaleDraw->setLength( -l ); - break; - } - case QwtPolar::AxisRight: - { - scaleDraw->move( p.x() + min, p.y() ); - scaleDraw->setLength( l ); - break; - } - case QwtPolar::AxisTop: - { - scaleDraw->move( p.x(), p.y() - max ); - scaleDraw->setLength( l ); - break; - } - case QwtPolar::AxisBottom: - { - scaleDraw->move( p.x(), p.y() + max ); - scaleDraw->setLength( -l ); - break; - } - } - const QwtTransform* transform = radialMap.transformation(); - if ( transform ) - scaleDraw->setTransformation( transform->copy() ); - else - scaleDraw->setTransformation( NULL ); - } + const QwtTransform *transform = azimuthMap.transformation(); + if (transform) + scaleDraw->setTransformation(transform->copy()); + else + scaleDraw->setTransformation(NULL); } + else + { + QwtScaleDraw *scaleDraw = static_cast(axis.scaleDraw); + + switch (axisId) + { + case QwtPolar::AxisLeft: { + scaleDraw->move(p.x() - min, p.y()); + scaleDraw->setLength(-l); + break; + } + case QwtPolar::AxisRight: { + scaleDraw->move(p.x() + min, p.y()); + scaleDraw->setLength(l); + break; + } + case QwtPolar::AxisTop: { + scaleDraw->move(p.x(), p.y() - max); + scaleDraw->setLength(l); + break; + } + case QwtPolar::AxisBottom: { + scaleDraw->move(p.x(), p.y() + max); + scaleDraw->setLength(-l); + break; + } + } + const QwtTransform *transform = radialMap.transformation(); + if (transform) + scaleDraw->setTransformation(transform->copy()); + else + scaleDraw->setTransformation(NULL); + } + } } /*! @@ -949,97 +939,98 @@ void QwtPolarGrid::updateScaleDraws( \sa QwtPolarPlot::setGridAttributes() */ -void QwtPolarGrid::updateScaleDiv( const QwtScaleDiv& azimuthScaleDiv, - const QwtScaleDiv& radialScaleDiv, const QwtInterval& interval ) +void QwtPolarGrid::updateScaleDiv(const QwtScaleDiv &azimuthScaleDiv, + const QwtScaleDiv &radialScaleDiv, + const QwtInterval &interval) { - QwtPolarGridPrivate::GridData& radialGrid = m_data->gridData[QwtPolar::Radius]; + QwtPolarGridPrivate::GridData &radialGrid + = m_data->gridData[QwtPolar::Radius]; - const QwtPolarPlot* plt = plot(); - if ( plt && testGridAttribute( AutoScaling ) ) - { - const QwtScaleEngine* se = plt->scaleEngine( QwtPolar::Radius ); - radialGrid.scaleDiv = se->divideScale( - interval.minValue(), interval.maxValue(), - plt->scaleMaxMajor( QwtPolar::Radius ), - plt->scaleMaxMinor( QwtPolar::Radius ), 0 ); - } - else - { - if ( radialGrid.scaleDiv != radialScaleDiv ) - radialGrid.scaleDiv = radialScaleDiv; - } + const QwtPolarPlot *plt = plot(); + if (plt && testGridAttribute(AutoScaling)) + { + const QwtScaleEngine *se = plt->scaleEngine(QwtPolar::Radius); + radialGrid.scaleDiv + = se->divideScale(interval.minValue(), interval.maxValue(), + plt->scaleMaxMajor(QwtPolar::Radius), + plt->scaleMaxMinor(QwtPolar::Radius), 0); + } + else + { + if (radialGrid.scaleDiv != radialScaleDiv) + radialGrid.scaleDiv = radialScaleDiv; + } - QwtPolarGridPrivate::GridData& azimuthGrid = m_data->gridData[QwtPolar::Azimuth]; - if ( azimuthGrid.scaleDiv != azimuthScaleDiv ) - { - azimuthGrid.scaleDiv = azimuthScaleDiv; - } + QwtPolarGridPrivate::GridData &azimuthGrid + = m_data->gridData[QwtPolar::Azimuth]; + if (azimuthGrid.scaleDiv != azimuthScaleDiv) + { + azimuthGrid.scaleDiv = azimuthScaleDiv; + } - bool hasOrigin = false; - for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ ) + bool hasOrigin = false; + for (int axisId = 0; axisId < QwtPolar::AxesCount; axisId++) + { + QwtPolarGridPrivate::AxisData &axis = m_data->axisData[axisId]; + if (axis.isVisible && axis.scaleDraw) { - QwtPolarGridPrivate::AxisData& axis = m_data->axisData[axisId]; - if ( axis.isVisible && axis.scaleDraw ) + if (axisId == QwtPolar::AxisAzimuth) + { + axis.scaleDraw->setScaleDiv(azimuthGrid.scaleDiv); + if (testDisplayFlag(SmartScaleDraw)) { - if ( axisId == QwtPolar::AxisAzimuth ) + axis.scaleDraw->enableComponent(QwtAbstractScaleDraw::Ticks, + !azimuthGrid.isVisible); + } + } + else + { + QwtScaleDiv sd = radialGrid.scaleDiv; + + QList ticks = sd.ticks(QwtScaleDiv::MajorTick); + + if (testDisplayFlag(SmartOriginLabel)) + { + bool skipOrigin = hasOrigin; + if (!skipOrigin) + { + if (axisId == QwtPolar::AxisLeft || axisId == QwtPolar::AxisRight) { - axis.scaleDraw->setScaleDiv( azimuthGrid.scaleDiv ); - if ( testDisplayFlag( SmartScaleDraw ) ) - { - axis.scaleDraw->enableComponent( - QwtAbstractScaleDraw::Ticks, !azimuthGrid.isVisible ); - } + if (m_data->axisData[QwtPolar::AxisBottom].isVisible) + skipOrigin = true; } else { - QwtScaleDiv sd = radialGrid.scaleDiv; - - QList< double > ticks = sd.ticks( QwtScaleDiv::MajorTick ); - - if ( testDisplayFlag( SmartOriginLabel ) ) - { - bool skipOrigin = hasOrigin; - if ( !skipOrigin ) - { - if ( axisId == QwtPolar::AxisLeft - || axisId == QwtPolar::AxisRight ) - { - if ( m_data->axisData[QwtPolar::AxisBottom].isVisible ) - skipOrigin = true; - } - else - { - if ( m_data->axisData[QwtPolar::AxisLeft].isVisible ) - skipOrigin = true; - } - } - if ( ticks.size() > 0 && ticks.first() == sd.lowerBound() ) - { - if ( skipOrigin ) - ticks.removeFirst(); - else - hasOrigin = true; - } - } - - if ( testDisplayFlag( HideMaxRadiusLabel ) ) - { - if ( ticks.size() > 0 && ticks.last() == sd.upperBound() ) - ticks.removeLast(); - } - - sd.setTicks( QwtScaleDiv::MajorTick, ticks ); - axis.scaleDraw->setScaleDiv( sd ); - - if ( testDisplayFlag( SmartScaleDraw ) ) - { - axis.scaleDraw->enableComponent( - QwtAbstractScaleDraw::Ticks, !radialGrid.isVisible ); - } - + if (m_data->axisData[QwtPolar::AxisLeft].isVisible) + skipOrigin = true; } + } + if (ticks.size() > 0 && ticks.first() == sd.lowerBound()) + { + if (skipOrigin) + ticks.removeFirst(); + else + hasOrigin = true; + } } + + if (testDisplayFlag(HideMaxRadiusLabel)) + { + if (ticks.size() > 0 && ticks.last() == sd.upperBound()) + ticks.removeLast(); + } + + sd.setTicks(QwtScaleDiv::MajorTick, ticks); + axis.scaleDraw->setScaleDiv(sd); + + if (testDisplayFlag(SmartScaleDraw)) + { + axis.scaleDraw->enableComponent(QwtAbstractScaleDraw::Ticks, + !radialGrid.isVisible); + } + } } + } } /*! @@ -1048,86 +1039,87 @@ void QwtPolarGrid::updateScaleDiv( const QwtScaleDiv& azimuthScaleDiv, */ int QwtPolarGrid::marginHint() const { - const QwtPolarGridPrivate::AxisData& axis = m_data->axisData[QwtPolar::AxisAzimuth]; - if ( axis.isVisible ) - { - const int extent = axis.scaleDraw->extent( axis.font ); - return extent; - } + const QwtPolarGridPrivate::AxisData &axis + = m_data->axisData[QwtPolar::AxisAzimuth]; + if (axis.isVisible) + { + const int extent = axis.scaleDraw->extent(axis.font); + return extent; + } - return 0; + return 0; } /*! Returns the scale draw of a specified axis - \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= QwtPolar::AxisBottom) - \return specified scaleDraw for axis, or NULL if axis is invalid. - \sa azimuthScaleDraw() + \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= + QwtPolar::AxisBottom) \return specified scaleDraw for axis, or NULL if axis + is invalid. \sa azimuthScaleDraw() */ -const QwtScaleDraw* QwtPolarGrid::scaleDraw( int axisId ) const +const QwtScaleDraw *QwtPolarGrid::scaleDraw(int axisId) const { - if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom ) - return static_cast< QwtScaleDraw* >( m_data->axisData[axisId].scaleDraw ); + if (axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom) + return static_cast(m_data->axisData[axisId].scaleDraw); - return NULL; + return NULL; } /*! Returns the scale draw of a specified axis - \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= QwtPolar::AxisBottom) - \return specified scaleDraw for axis, or NULL if axis is invalid. - \sa setScaleDraw(), azimuthScaleDraw() + \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= + QwtPolar::AxisBottom) \return specified scaleDraw for axis, or NULL if axis + is invalid. \sa setScaleDraw(), azimuthScaleDraw() */ -QwtScaleDraw* QwtPolarGrid::scaleDraw( int axisId ) +QwtScaleDraw *QwtPolarGrid::scaleDraw(int axisId) { - if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom ) - return static_cast< QwtScaleDraw* >( m_data->axisData[axisId].scaleDraw ); + if (axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom) + return static_cast(m_data->axisData[axisId].scaleDraw); - return NULL; + return NULL; } /*! \brief Set a scale draw - \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= QwtPolar::AxisBottom) - \param scaleDraw object responsible for drawing scales. + \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= + QwtPolar::AxisBottom) \param scaleDraw object responsible for drawing scales. \sa scaleDraw(), setAzimuthScaleDraw() */ -void QwtPolarGrid::setScaleDraw( int axisId, QwtScaleDraw* scaleDraw ) +void QwtPolarGrid::setScaleDraw(int axisId, QwtScaleDraw *scaleDraw) { - if ( axisId < QwtPolar::AxisLeft || axisId > QwtPolar::AxisBottom ) - return; + if (axisId < QwtPolar::AxisLeft || axisId > QwtPolar::AxisBottom) + return; - QwtPolarGridPrivate::AxisData& axisData = m_data->axisData[axisId]; - if ( axisData.scaleDraw != scaleDraw ) - { - delete axisData.scaleDraw; - axisData.scaleDraw = scaleDraw; - itemChanged(); - } + QwtPolarGridPrivate::AxisData &axisData = m_data->axisData[axisId]; + if (axisData.scaleDraw != scaleDraw) + { + delete axisData.scaleDraw; + axisData.scaleDraw = scaleDraw; + itemChanged(); + } } /*! \return Scale draw for the azimuth scale \sa setAzimuthScaleDraw(), scaleDraw() */ -const QwtRoundScaleDraw* QwtPolarGrid::azimuthScaleDraw() const +const QwtRoundScaleDraw *QwtPolarGrid::azimuthScaleDraw() const { - return static_cast< QwtRoundScaleDraw* >( - m_data->axisData[QwtPolar::AxisAzimuth].scaleDraw ); + return static_cast( + m_data->axisData[QwtPolar::AxisAzimuth].scaleDraw); } /*! \return Scale draw for the azimuth scale \sa setAzimuthScaleDraw(), scaleDraw() */ -QwtRoundScaleDraw* QwtPolarGrid::azimuthScaleDraw() +QwtRoundScaleDraw *QwtPolarGrid::azimuthScaleDraw() { - return static_cast< QwtRoundScaleDraw* >( - m_data->axisData[QwtPolar::AxisAzimuth].scaleDraw ); + return static_cast( + m_data->axisData[QwtPolar::AxisAzimuth].scaleDraw); } /*! @@ -1136,13 +1128,14 @@ QwtRoundScaleDraw* QwtPolarGrid::azimuthScaleDraw() \param scaleDraw object responsible for drawing scales. \sa azimuthScaleDraw(), setScaleDraw() */ -void QwtPolarGrid::setAzimuthScaleDraw( QwtRoundScaleDraw* scaleDraw ) +void QwtPolarGrid::setAzimuthScaleDraw(QwtRoundScaleDraw *scaleDraw) { - QwtPolarGridPrivate::AxisData& axisData = m_data->axisData[QwtPolar::AxisAzimuth]; - if ( axisData.scaleDraw != scaleDraw ) - { - delete axisData.scaleDraw; - axisData.scaleDraw = scaleDraw; - itemChanged(); - } + QwtPolarGridPrivate::AxisData &axisData + = m_data->axisData[QwtPolar::AxisAzimuth]; + if (axisData.scaleDraw != scaleDraw) + { + delete axisData.scaleDraw; + axisData.scaleDraw = scaleDraw; + itemChanged(); + } } diff --git a/libs/qwt/src/qwt_polar_grid.h b/libs/qwt/src/qwt_polar_grid.h index 561f9db5..6e04ec78 100644 --- a/libs/qwt/src/qwt_polar_grid.h +++ b/libs/qwt/src/qwt_polar_grid.h @@ -40,144 +40,142 @@ class QwtScaleDraw; class QWT_EXPORT QwtPolarGrid : public QwtPolarItem { - public: +public: + /*! + Mysterious flags trying to avoid conflicts, when painting the + scales and grid lines. + + The default setting enables all flags. + + \sa setDisplayFlag(), testDisplayFlag() + */ + enum DisplayFlag + { /*! - Mysterious flags trying to avoid conflicts, when painting the - scales and grid lines. - - The default setting enables all flags. - - \sa setDisplayFlag(), testDisplayFlag() + Try to avoid situations, where the label of the origin is + painted over another axis. */ - enum DisplayFlag - { - /*! - Try to avoid situations, where the label of the origin is - painted over another axis. - */ - SmartOriginLabel = 1, - - /*! - Often the outermost tick of the radial scale is close to the - canvas border. With HideMaxRadiusLabel enabled it is not painted. - */ - HideMaxRadiusLabel = 2, - - /*! - The tick labels of the radial scales might be hard to read, when - they are painted on top of the radial grid lines ( or on top - of a curve/spectrogram ). When ClipAxisBackground the bounding rect - of each label is added to the clip region. - */ - ClipAxisBackground = 4, - - /*! - Don't paint the backbone of the radial axes, when they are very close - to a line of the azimuth grid. - */ - SmartScaleDraw = 8, - - /*! - All grid lines are clipped against the plot area before being painted. - When the plot is zoomed in this will have an significant impact - on the performance of the painting code. - */ - ClipGridLines = 16 - }; - - Q_DECLARE_FLAGS( DisplayFlags, DisplayFlag ) + SmartOriginLabel = 1, /*! - \brief Grid attributes - \sa setGridAttributes(), testGridAttributes() + Often the outermost tick of the radial scale is close to the + canvas border. With HideMaxRadiusLabel enabled it is not painted. */ - enum GridAttribute - { - /*! - When AutoScaling is enabled, the radial axes will be adjusted - to the interval, that is currently visible on the canvas plot. - */ - AutoScaling = 0x01 - }; + HideMaxRadiusLabel = 2, - Q_DECLARE_FLAGS( GridAttributes, GridAttribute ) + /*! + The tick labels of the radial scales might be hard to read, when + they are painted on top of the radial grid lines ( or on top + of a curve/spectrogram ). When ClipAxisBackground the bounding rect + of each label is added to the clip region. + */ + ClipAxisBackground = 4, - explicit QwtPolarGrid(); - virtual ~QwtPolarGrid(); + /*! + Don't paint the backbone of the radial axes, when they are very close + to a line of the azimuth grid. + */ + SmartScaleDraw = 8, - virtual int rtti() const QWT_OVERRIDE; + /*! + All grid lines are clipped against the plot area before being painted. + When the plot is zoomed in this will have an significant impact + on the performance of the painting code. + */ + ClipGridLines = 16 + }; - void setDisplayFlag( DisplayFlag, bool on = true ); - bool testDisplayFlag( DisplayFlag ) const; + Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag) - void setGridAttribute( GridAttribute, bool on = true ); - bool testGridAttribute( GridAttribute ) const; + /*! + \brief Grid attributes + \sa setGridAttributes(), testGridAttributes() + */ + enum GridAttribute + { + /*! + When AutoScaling is enabled, the radial axes will be adjusted + to the interval, that is currently visible on the canvas plot. + */ + AutoScaling = 0x01 + }; - void showGrid( int scaleId, bool show = true ); - bool isGridVisible( int scaleId ) const; + Q_DECLARE_FLAGS(GridAttributes, GridAttribute) - void showMinorGrid( int scaleId, bool show = true ); - bool isMinorGridVisible( int scaleId ) const; + explicit QwtPolarGrid(); + virtual ~QwtPolarGrid(); - void showAxis( int axisId, bool show = true ); - bool isAxisVisible( int axisId ) const; + virtual int rtti() const QWT_OVERRIDE; - void setPen( const QPen& p ); - void setFont( const QFont& ); + void setDisplayFlag(DisplayFlag, bool on = true); + bool testDisplayFlag(DisplayFlag) const; - void setMajorGridPen( const QPen& p ); - void setMajorGridPen( int scaleId, const QPen& p ); - QPen majorGridPen( int scaleId ) const; + void setGridAttribute(GridAttribute, bool on = true); + bool testGridAttribute(GridAttribute) const; - void setMinorGridPen( const QPen& p ); - void setMinorGridPen( int scaleId, const QPen& p ); - QPen minorGridPen( int scaleId ) const; + void showGrid(int scaleId, bool show = true); + bool isGridVisible(int scaleId) const; - void setAxisPen( int axisId, const QPen& p ); - QPen axisPen( int axisId ) const; + void showMinorGrid(int scaleId, bool show = true); + bool isMinorGridVisible(int scaleId) const; - void setAxisFont( int axisId, const QFont& p ); - QFont axisFont( int axisId ) const; + void showAxis(int axisId, bool show = true); + bool isAxisVisible(int axisId) const; - void setScaleDraw( int axisId, QwtScaleDraw* ); - const QwtScaleDraw* scaleDraw( int axisId ) const; - QwtScaleDraw* scaleDraw( int axisId ); + void setPen(const QPen &p); + void setFont(const QFont &); - void setAzimuthScaleDraw( QwtRoundScaleDraw* ); - const QwtRoundScaleDraw* azimuthScaleDraw() const; - QwtRoundScaleDraw* azimuthScaleDraw(); + void setMajorGridPen(const QPen &p); + void setMajorGridPen(int scaleId, const QPen &p); + QPen majorGridPen(int scaleId) const; - virtual void draw( QPainter* p, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& rect ) const QWT_OVERRIDE; + void setMinorGridPen(const QPen &p); + void setMinorGridPen(int scaleId, const QPen &p); + QPen minorGridPen(int scaleId) const; - virtual void updateScaleDiv( const QwtScaleDiv& azimuthMap, - const QwtScaleDiv& radialMap, const QwtInterval& ) QWT_OVERRIDE; + void setAxisPen(int axisId, const QPen &p); + QPen axisPen(int axisId) const; - virtual int marginHint() const QWT_OVERRIDE; + void setAxisFont(int axisId, const QFont &p); + QFont axisFont(int axisId) const; - protected: - void drawRays( QPainter*, const QRectF&, - const QPointF& pole, double radius, - const QwtScaleMap& azimuthMap, const QList< double >& ) const; - void drawCircles( QPainter*, const QRectF&, - const QPointF& pole, const QwtScaleMap& radialMap, - const QList< double >& ) const; + void setScaleDraw(int axisId, QwtScaleDraw *); + const QwtScaleDraw *scaleDraw(int axisId) const; + QwtScaleDraw *scaleDraw(int axisId); - void drawAxis( QPainter*, int axisId ) const; + void setAzimuthScaleDraw(QwtRoundScaleDraw *); + const QwtRoundScaleDraw *azimuthScaleDraw() const; + QwtRoundScaleDraw *azimuthScaleDraw(); - private: - void updateScaleDraws( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, const double radius ) const; + virtual void draw(QPainter *p, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &rect) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; + virtual void updateScaleDiv(const QwtScaleDiv &azimuthMap, + const QwtScaleDiv &radialMap, + const QwtInterval &) QWT_OVERRIDE; + + virtual int marginHint() const QWT_OVERRIDE; + +protected: + void drawRays(QPainter *, const QRectF &, const QPointF &pole, double radius, + const QwtScaleMap &azimuthMap, const QList &) const; + void drawCircles(QPainter *, const QRectF &, const QPointF &pole, + const QwtScaleMap &radialMap, const QList &) const; + + void drawAxis(QPainter *, int axisId) const; + +private: + void updateScaleDraws(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + const double radius) const; + +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::DisplayFlags ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::GridAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarGrid::DisplayFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarGrid::GridAttributes) #endif diff --git a/libs/qwt/src/qwt_polar_item.cpp b/libs/qwt/src/qwt_polar_item.cpp index 9543de84..85cbd52d 100644 --- a/libs/qwt/src/qwt_polar_item.cpp +++ b/libs/qwt/src/qwt_polar_item.cpp @@ -15,27 +15,27 @@ class QwtPolarItem::PrivateData { - public: - PrivateData() - : plot( NULL ) - , isVisible( true ) - , renderThreadCount( 1 ) - , z( 0.0 ) - , legendIconSize( 8, 8 ) - { - } +public: + PrivateData() + : plot(NULL) + , isVisible(true) + , renderThreadCount(1) + , z(0.0) + , legendIconSize(8, 8) + { + } - mutable QwtPolarPlot* plot; + mutable QwtPolarPlot *plot; - bool isVisible; - QwtPolarItem::ItemAttributes attributes; - QwtPolarItem::RenderHints renderHints; - uint renderThreadCount; + bool isVisible; + QwtPolarItem::ItemAttributes attributes; + QwtPolarItem::RenderHints renderHints; + uint renderThreadCount; - double z; + double z; - QwtText title; - QSize legendIconSize; + QwtText title; + QSize legendIconSize; }; /*! @@ -45,17 +45,17 @@ class QwtPolarItem::PrivateData \sa setTitle() */ -QwtPolarItem::QwtPolarItem( const QwtText& title ) +QwtPolarItem::QwtPolarItem(const QwtText &title) { - m_data = new PrivateData; - m_data->title = title; + m_data = new PrivateData; + m_data->title = title; } //! Destroy the QwtPolarItem QwtPolarItem::~QwtPolarItem() { - attach( NULL ); - delete m_data; + attach(NULL); + delete m_data; } /*! @@ -71,18 +71,18 @@ QwtPolarItem::~QwtPolarItem() \sa QwtPolarItem::detach() */ -void QwtPolarItem::attach( QwtPolarPlot* plot ) +void QwtPolarItem::attach(QwtPolarPlot *plot) { - if ( plot == m_data->plot ) - return; + if (plot == m_data->plot) + return; - if ( m_data->plot ) - m_data->plot->attachItem( this, false ); + if (m_data->plot) + m_data->plot->attachItem(this, false); - m_data->plot = plot; + m_data->plot = plot; - if ( m_data->plot ) - m_data->plot->attachItem( this, true ); + if (m_data->plot) + m_data->plot->attachItem(this, true); } /*! @@ -94,7 +94,7 @@ void QwtPolarItem::attach( QwtPolarPlot* plot ) */ void QwtPolarItem::detach() { - attach( NULL ); + attach(NULL); } /*! @@ -111,13 +111,13 @@ void QwtPolarItem::detach() */ int QwtPolarItem::rtti() const { - return Rtti_PolarItem; + return Rtti_PolarItem; } //! \return Attached plot -QwtPolarPlot* QwtPolarItem::plot() const +QwtPolarPlot *QwtPolarItem::plot() const { - return m_data->plot; + return m_data->plot; } /*! @@ -128,7 +128,7 @@ QwtPolarPlot* QwtPolarItem::plot() const */ double QwtPolarItem::z() const { - return m_data->z; + return m_data->z; } /*! @@ -139,20 +139,20 @@ double QwtPolarItem::z() const \param z Z-value \sa z(), QwtPolarItemDict::itemList() */ -void QwtPolarItem::setZ( double z ) +void QwtPolarItem::setZ(double z) { - if ( m_data->z != z ) - { - if ( m_data->plot ) - m_data->plot->attachItem( this, false ); + if (m_data->z != z) + { + if (m_data->plot) + m_data->plot->attachItem(this, false); - m_data->z = z; + m_data->z = z; - if ( m_data->plot ) - m_data->plot->attachItem( this, true ); + if (m_data->plot) + m_data->plot->attachItem(this, true); - itemChanged(); - } + itemChanged(); + } } /*! @@ -161,9 +161,9 @@ void QwtPolarItem::setZ( double z ) \param title Title \sa title() */ -void QwtPolarItem::setTitle( const QString& title ) +void QwtPolarItem::setTitle(const QString &title) { - setTitle( QwtText( title ) ); + setTitle(QwtText(title)); } /*! @@ -172,22 +172,22 @@ void QwtPolarItem::setTitle( const QString& title ) \param title Title \sa title() */ -void QwtPolarItem::setTitle( const QwtText& title ) +void QwtPolarItem::setTitle(const QwtText &title) { - if ( m_data->title != title ) - { - m_data->title = title; - itemChanged(); - } + if (m_data->title != title) + { + m_data->title = title; + itemChanged(); + } } /*! \return Title of the item \sa setTitle() */ -const QwtText& QwtPolarItem::title() const +const QwtText &QwtPolarItem::title() const { - return m_data->title; + return m_data->title; } /*! @@ -198,17 +198,17 @@ const QwtText& QwtPolarItem::title() const \sa testItemAttribute(), ItemAttribute */ -void QwtPolarItem::setItemAttribute( ItemAttribute attribute, bool on ) +void QwtPolarItem::setItemAttribute(ItemAttribute attribute, bool on) { - if ( bool( m_data->attributes & attribute ) != on ) - { - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; + if (bool(m_data->attributes & attribute) != on) + { + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; - itemChanged(); - } + itemChanged(); + } } /*! @@ -218,9 +218,9 @@ void QwtPolarItem::setItemAttribute( ItemAttribute attribute, bool on ) \return true/false \sa setItemAttribute(), ItemAttribute */ -bool QwtPolarItem::testItemAttribute( ItemAttribute attribute ) const +bool QwtPolarItem::testItemAttribute(ItemAttribute attribute) const { - return m_data->attributes & attribute; + return m_data->attributes & attribute; } /*! @@ -231,17 +231,17 @@ bool QwtPolarItem::testItemAttribute( ItemAttribute attribute ) const \sa testRenderHint(), RenderHint */ -void QwtPolarItem::setRenderHint( RenderHint hint, bool on ) +void QwtPolarItem::setRenderHint(RenderHint hint, bool on) { - if ( ( ( m_data->renderHints & hint ) != 0 ) != on ) - { - if ( on ) - m_data->renderHints |= hint; - else - m_data->renderHints &= ~hint; + if (((m_data->renderHints & hint) != 0) != on) + { + if (on) + m_data->renderHints |= hint; + else + m_data->renderHints &= ~hint; - itemChanged(); - } + itemChanged(); + } } /*! @@ -251,9 +251,9 @@ void QwtPolarItem::setRenderHint( RenderHint hint, bool on ) \return true/false \sa setRenderHint(), RenderHint */ -bool QwtPolarItem::testRenderHint( RenderHint hint ) const +bool QwtPolarItem::testRenderHint(RenderHint hint) const { - return ( m_data->renderHints & hint ); + return (m_data->renderHints & hint); } /*! @@ -269,9 +269,9 @@ bool QwtPolarItem::testRenderHint( RenderHint hint ) const The default thread count is 1 ( = no additional threads ) */ -void QwtPolarItem::setRenderThreadCount( uint numThreads ) +void QwtPolarItem::setRenderThreadCount(uint numThreads) { - m_data->renderThreadCount = numThreads; + m_data->renderThreadCount = numThreads; } /*! @@ -281,7 +281,7 @@ void QwtPolarItem::setRenderThreadCount( uint numThreads ) */ uint QwtPolarItem::renderThreadCount() const { - return m_data->renderThreadCount; + return m_data->renderThreadCount; } /*! @@ -292,13 +292,13 @@ uint QwtPolarItem::renderThreadCount() const \param size Size \sa legendIconSize(), legendIcon() */ -void QwtPolarItem::setLegendIconSize( const QSize& size ) +void QwtPolarItem::setLegendIconSize(const QSize &size) { - if ( m_data->legendIconSize != size ) - { - m_data->legendIconSize = size; - legendChanged(); - } + if (m_data->legendIconSize != size) + { + m_data->legendIconSize = size; + legendChanged(); + } } /*! @@ -307,19 +307,19 @@ void QwtPolarItem::setLegendIconSize( const QSize& size ) */ QSize QwtPolarItem::legendIconSize() const { - return m_data->legendIconSize; + return m_data->legendIconSize; } //! Show the item void QwtPolarItem::show() { - setVisible( true ); + setVisible(true); } //! Hide the item void QwtPolarItem::hide() { - setVisible( false ); + setVisible(false); } /*! @@ -328,13 +328,13 @@ void QwtPolarItem::hide() \param on Show if true, otherwise hide \sa isVisible(), show(), hide() */ -void QwtPolarItem::setVisible( bool on ) +void QwtPolarItem::setVisible(bool on) { - if ( on != m_data->isVisible ) - { - m_data->isVisible = on; - itemChanged(); - } + if (on != m_data->isVisible) + { + m_data->isVisible = on; + itemChanged(); + } } /*! @@ -343,7 +343,7 @@ void QwtPolarItem::setVisible( bool on ) */ bool QwtPolarItem::isVisible() const { - return m_data->isVisible; + return m_data->isVisible; } /*! @@ -354,8 +354,8 @@ bool QwtPolarItem::isVisible() const */ void QwtPolarItem::itemChanged() { - if ( m_data->plot ) - m_data->plot->autoRefresh(); + if (m_data->plot) + m_data->plot->autoRefresh(); } /*! @@ -364,8 +364,8 @@ void QwtPolarItem::itemChanged() */ void QwtPolarItem::legendChanged() { - if ( testItemAttribute( QwtPolarItem::Legend ) && m_data->plot ) - m_data->plot->updateLegend( this ); + if (testItemAttribute(QwtPolarItem::Legend) && m_data->plot) + m_data->plot->updateLegend(this); } /*! @@ -378,11 +378,11 @@ void QwtPolarItem::legendChanged() \param scaleId Scale id ( QwtPolar::Scale ) \return Bounding interval of the plot item for a specific scale */ -QwtInterval QwtPolarItem::boundingInterval( int scaleId ) const +QwtInterval QwtPolarItem::boundingInterval(int scaleId) const { - Q_UNUSED( scaleId ); + Q_UNUSED(scaleId); - return QwtInterval(); // invalid + return QwtInterval(); // invalid } /*! @@ -400,12 +400,13 @@ QwtInterval QwtPolarItem::boundingInterval( int scaleId ) const \sa QwtPolarPlot::updateAxes() */ -void QwtPolarItem::updateScaleDiv( const QwtScaleDiv& azimuthScaleDiv, - const QwtScaleDiv& radialScaleDiv, const QwtInterval& interval ) +void QwtPolarItem::updateScaleDiv(const QwtScaleDiv &azimuthScaleDiv, + const QwtScaleDiv &radialScaleDiv, + const QwtInterval &interval) { - Q_UNUSED( azimuthScaleDiv ); - Q_UNUSED( radialScaleDiv ); - Q_UNUSED( interval ); + Q_UNUSED(azimuthScaleDiv); + Q_UNUSED(radialScaleDiv); + Q_UNUSED(interval); } /*! @@ -425,27 +426,25 @@ void QwtPolarItem::updateScaleDiv( const QwtScaleDiv& azimuthScaleDiv, \sa title(), legendIcon(), QwtLegend */ -QList< QwtLegendData > QwtPolarItem::legendData() const +QList QwtPolarItem::legendData() const { - QwtLegendData data; + QwtLegendData data; - QwtText label = title(); - label.setRenderFlags( label.renderFlags() & Qt::AlignLeft ); + QwtText label = title(); + label.setRenderFlags(label.renderFlags() & Qt::AlignLeft); - data.setValue( QwtLegendData::TitleRole, - QVariant::fromValue( label ) ); + data.setValue(QwtLegendData::TitleRole, QVariant::fromValue(label)); - const QwtGraphic graphic = legendIcon( 0, legendIconSize() ); - if ( !graphic.isNull() ) - { - data.setValue( QwtLegendData::IconRole, - QVariant::fromValue( graphic ) ); - } + const QwtGraphic graphic = legendIcon(0, legendIconSize()); + if (!graphic.isNull()) + { + data.setValue(QwtLegendData::IconRole, QVariant::fromValue(graphic)); + } - QList< QwtLegendData > list; - list += data; + QList list; + list += data; - return list; + return list; } /*! @@ -459,13 +458,12 @@ QList< QwtLegendData > QwtPolarItem::legendData() const \sa setLegendIconSize(), legendData() */ -QwtGraphic QwtPolarItem::legendIcon( - int index, const QSizeF& size ) const +QwtGraphic QwtPolarItem::legendIcon(int index, const QSizeF &size) const { - Q_UNUSED( index ) - Q_UNUSED( size ) + Q_UNUSED(index) + Q_UNUSED(size) - return QwtGraphic(); + return QwtGraphic(); } /*! @@ -477,5 +475,5 @@ QwtGraphic QwtPolarItem::legendIcon( */ int QwtPolarItem::marginHint() const { - return 0; + return 0; } diff --git a/libs/qwt/src/qwt_polar_item.h b/libs/qwt/src/qwt_polar_item.h index d1b931d9..63ef68e2 100644 --- a/libs/qwt/src/qwt_polar_item.h +++ b/libs/qwt/src/qwt_polar_item.h @@ -36,139 +36,139 @@ class QwtScaleDiv; */ class QWT_EXPORT QwtPolarItem { - public: - /*! - \brief Runtime type information +public: + /*! + \brief Runtime type information - RttiValues is used to cast plot items, without - having to enable runtime type information of the compiler. - */ - enum RttiValues - { - //! Unspecific value, that can be used, when it doesn't matter - Rtti_PolarItem = 0, + RttiValues is used to cast plot items, without + having to enable runtime type information of the compiler. + */ + enum RttiValues + { + //! Unspecific value, that can be used, when it doesn't matter + Rtti_PolarItem = 0, - //! For QwtPolarGrid - Rtti_PolarGrid, + //! For QwtPolarGrid + Rtti_PolarGrid, - //! For QwtPolarMarker - Rtti_PolarMarker, + //! For QwtPolarMarker + Rtti_PolarMarker, - //! For QwtPolarCurve - Rtti_PolarCurve, + //! For QwtPolarCurve + Rtti_PolarCurve, - //! For QwtPolarSpectrogram - Rtti_PolarSpectrogram, - - /*! - Values >= Rtti_PolarUserItem are reserved for plot items - not implemented in the QwtPolar library. - */ - Rtti_PolarUserItem = 1000 - }; + //! For QwtPolarSpectrogram + Rtti_PolarSpectrogram, /*! - \brief Plot Item Attributes - \sa setItemAttribute(), testItemAttribute() + Values >= Rtti_PolarUserItem are reserved for plot items + not implemented in the QwtPolar library. */ - enum ItemAttribute - { - //! The item is represented on the legend. - Legend = 0x01, + Rtti_PolarUserItem = 1000 + }; - /*! - The boundingRect() of the item is included in the - autoscaling calculation. - */ - AutoScale = 0x02 - }; - - Q_DECLARE_FLAGS( ItemAttributes, ItemAttribute ) + /*! + \brief Plot Item Attributes + \sa setItemAttribute(), testItemAttribute() + */ + enum ItemAttribute + { + //! The item is represented on the legend. + Legend = 0x01, /*! - \brief Render hints - \sa setRenderHint(), testRenderHint() + The boundingRect() of the item is included in the + autoscaling calculation. */ - enum RenderHint - { - //! Enable antialiasing - RenderAntialiased = 0x01 - }; + AutoScale = 0x02 + }; - Q_DECLARE_FLAGS( RenderHints, RenderHint ) + Q_DECLARE_FLAGS(ItemAttributes, ItemAttribute) - explicit QwtPolarItem( const QwtText& title = QwtText() ); - virtual ~QwtPolarItem(); + /*! + \brief Render hints + \sa setRenderHint(), testRenderHint() + */ + enum RenderHint + { + //! Enable antialiasing + RenderAntialiased = 0x01 + }; - void attach( QwtPolarPlot* plot ); - void detach(); + Q_DECLARE_FLAGS(RenderHints, RenderHint) - QwtPolarPlot* plot() const; + explicit QwtPolarItem(const QwtText &title = QwtText()); + virtual ~QwtPolarItem(); - void setTitle( const QString& title ); - void setTitle( const QwtText& title ); - const QwtText& title() const; + void attach(QwtPolarPlot *plot); + void detach(); - virtual int rtti() const; + QwtPolarPlot *plot() const; - void setItemAttribute( ItemAttribute, bool on = true ); - bool testItemAttribute( ItemAttribute ) const; + void setTitle(const QString &title); + void setTitle(const QwtText &title); + const QwtText &title() const; - void setRenderHint( RenderHint, bool on = true ); - bool testRenderHint( RenderHint ) const; + virtual int rtti() const; - void setRenderThreadCount( uint numThreads ); - uint renderThreadCount() const; + void setItemAttribute(ItemAttribute, bool on = true); + bool testItemAttribute(ItemAttribute) const; - double z() const; - void setZ( double z ); + void setRenderHint(RenderHint, bool on = true); + bool testRenderHint(RenderHint) const; - void show(); - void hide(); - virtual void setVisible( bool ); - bool isVisible () const; + void setRenderThreadCount(uint numThreads); + uint renderThreadCount() const; - virtual void itemChanged(); - virtual void legendChanged(); + double z() const; + void setZ(double z); - /*! - \brief Draw the item + void show(); + void hide(); + virtual void setVisible(bool); + bool isVisible() const; - \param painter Painter - \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI - \param radialMap Maps radius values into painter coordinates. - \param pole Position of the pole in painter coordinates - \param radius Radius of the complete plot area in painter coordinates - \param canvasRect Contents rect of the canvas in painter coordinates - */ - virtual void draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const = 0; + virtual void itemChanged(); + virtual void legendChanged(); - virtual QwtInterval boundingInterval( int scaleId ) const; + /*! + \brief Draw the item - virtual void updateScaleDiv( const QwtScaleDiv&, - const QwtScaleDiv&, const QwtInterval& ); + \param painter Painter + \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI + \param radialMap Maps radius values into painter coordinates. + \param pole Position of the pole in painter coordinates + \param radius Radius of the complete plot area in painter coordinates + \param canvasRect Contents rect of the canvas in painter coordinates + */ + virtual void draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const + = 0; - virtual int marginHint() const; + virtual QwtInterval boundingInterval(int scaleId) const; - void setLegendIconSize( const QSize& ); - QSize legendIconSize() const; + virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &, + const QwtInterval &); - virtual QList< QwtLegendData > legendData() const; - virtual QwtGraphic legendIcon( int index, const QSizeF& ) const; + virtual int marginHint() const; - private: - Q_DISABLE_COPY( QwtPolarItem ) + void setLegendIconSize(const QSize &); + QSize legendIconSize() const; - class PrivateData; - PrivateData* m_data; + virtual QList legendData() const; + virtual QwtGraphic legendIcon(int index, const QSizeF &) const; + +private: + Q_DISABLE_COPY(QwtPolarItem) + + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::ItemAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarItem::ItemAttributes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarItem::RenderHints) -Q_DECLARE_METATYPE( QwtPolarItem* ) +Q_DECLARE_METATYPE(QwtPolarItem *) #endif diff --git a/libs/qwt/src/qwt_polar_itemdict.cpp b/libs/qwt/src/qwt_polar_itemdict.cpp index 6f1e3fc8..18320d9a 100644 --- a/libs/qwt/src/qwt_polar_itemdict.cpp +++ b/libs/qwt/src/qwt_polar_itemdict.cpp @@ -10,56 +10,56 @@ class QwtPolarItemDict::PrivateData { +public: + class ItemList : public QList + { public: - class ItemList : public QList< QwtPolarItem* > + void insertItem(QwtPolarItem *item) { - public: - void insertItem( QwtPolarItem* item ) + if (item == NULL) + return; + + // Unfortunately there is no inSort operation + // for lists in Qt4. The implementation below + // is slow, but there shouldn't be many plot items. + + QList::Iterator it; + for (it = begin(); it != end(); ++it) + { + if (*it == item) + return; + + if ((*it)->z() > item->z()) { - if ( item == NULL ) - return; - - // Unfortunately there is no inSort operation - // for lists in Qt4. The implementation below - // is slow, but there shouldn't be many plot items. - - QList< QwtPolarItem* >::Iterator it; - for ( it = begin(); it != end(); ++it ) - { - if ( *it == item ) - return; - - if ( ( *it )->z() > item->z() ) - { - insert( it, item ); - return; - } - } - append( item ); + insert(it, item); + return; } + } + append(item); + } - void removeItem( QwtPolarItem* item ) + void removeItem(QwtPolarItem *item) + { + if (item == NULL) + return; + + int i = 0; + + QList::Iterator it; + for (it = begin(); it != end(); ++it) + { + if (item == *it) { - if ( item == NULL ) - return; - - int i = 0; - - QList< QwtPolarItem* >::Iterator it; - for ( it = begin(); it != end(); ++it ) - { - if ( item == *it ) - { - removeAt( i ); - return; - } - i++; - } + removeAt(i); + return; } - }; + i++; + } + } + }; - ItemList itemList; - bool autoDelete; + ItemList itemList; + bool autoDelete; }; /*! @@ -70,8 +70,8 @@ class QwtPolarItemDict::PrivateData */ QwtPolarItemDict::QwtPolarItemDict() { - m_data = new QwtPolarItemDict::PrivateData; - m_data->autoDelete = true; + m_data = new QwtPolarItemDict::PrivateData; + m_data->autoDelete = true; } /*! @@ -82,8 +82,8 @@ QwtPolarItemDict::QwtPolarItemDict() */ QwtPolarItemDict::~QwtPolarItemDict() { - detachItems( QwtPolarItem::Rtti_PolarItem, m_data->autoDelete ); - delete m_data; + detachItems(QwtPolarItem::Rtti_PolarItem, m_data->autoDelete); + delete m_data; } /*! @@ -94,9 +94,9 @@ QwtPolarItemDict::~QwtPolarItemDict() \sa autoDelete, attachItem */ -void QwtPolarItemDict::setAutoDelete( bool autoDelete ) +void QwtPolarItemDict::setAutoDelete(bool autoDelete) { - m_data->autoDelete = autoDelete; + m_data->autoDelete = autoDelete; } /*! @@ -105,7 +105,7 @@ void QwtPolarItemDict::setAutoDelete( bool autoDelete ) */ bool QwtPolarItemDict::autoDelete() const { - return m_data->autoDelete; + return m_data->autoDelete; } /*! @@ -114,9 +114,9 @@ bool QwtPolarItemDict::autoDelete() const \param item PlotItem \sa removeItem() */ -void QwtPolarItemDict::insertItem( QwtPolarItem* item ) +void QwtPolarItemDict::insertItem(QwtPolarItem *item) { - m_data->itemList.insertItem( item ); + m_data->itemList.insertItem(item); } /*! @@ -125,9 +125,9 @@ void QwtPolarItemDict::insertItem( QwtPolarItem* item ) \param item PlotItem \sa insertItem() */ -void QwtPolarItemDict::removeItem( QwtPolarItem* item ) +void QwtPolarItemDict::removeItem(QwtPolarItem *item) { - m_data->itemList.removeItem( item ); + m_data->itemList.removeItem(item); } /*! @@ -137,23 +137,23 @@ void QwtPolarItemDict::removeItem( QwtPolarItem* item ) otherwise only those items of the type rtti. \param autoDelete If true, delete all detached items */ -void QwtPolarItemDict::detachItems( int rtti, bool autoDelete ) +void QwtPolarItemDict::detachItems(int rtti, bool autoDelete) { - PrivateData::ItemList list = m_data->itemList; - QwtPolarItemIterator it = list.constBegin(); - while ( it != list.constEnd() ) + PrivateData::ItemList list = m_data->itemList; + QwtPolarItemIterator it = list.constBegin(); + while (it != list.constEnd()) + { + QwtPolarItem *item = *it; + + ++it; // increment before removing item from the list + + if (rtti == QwtPolarItem::Rtti_PolarItem || item->rtti() == rtti) { - QwtPolarItem* item = *it; - - ++it; // increment before removing item from the list - - if ( rtti == QwtPolarItem::Rtti_PolarItem || item->rtti() == rtti ) - { - item->attach( NULL ); - if ( autoDelete ) - delete item; - } + item->attach(NULL); + if (autoDelete) + delete item; } + } } /*! @@ -165,7 +165,7 @@ void QwtPolarItemDict::detachItems( int rtti, bool autoDelete ) Instead you can place pointers to objects to be removed in a removal list, and traverse that list later. */ -const QwtPolarItemList& QwtPolarItemDict::itemList() const +const QwtPolarItemList &QwtPolarItemDict::itemList() const { - return m_data->itemList; + return m_data->itemList; } diff --git a/libs/qwt/src/qwt_polar_itemdict.h b/libs/qwt/src/qwt_polar_itemdict.h index 80c0a54d..3cc8a353 100644 --- a/libs/qwt/src/qwt_polar_itemdict.h +++ b/libs/qwt/src/qwt_polar_itemdict.h @@ -13,8 +13,8 @@ #include "qwt_polar_item.h" #include -typedef QList< QwtPolarItem* >::ConstIterator QwtPolarItemIterator; -typedef QList< QwtPolarItem* > QwtPolarItemList; +typedef QList::ConstIterator QwtPolarItemIterator; +typedef QList QwtPolarItemList; /*! \brief A dictionary for polar plot items @@ -27,25 +27,25 @@ typedef QList< QwtPolarItem* > QwtPolarItemList; */ class QWT_EXPORT QwtPolarItemDict { - public: - explicit QwtPolarItemDict(); - ~QwtPolarItemDict(); +public: + explicit QwtPolarItemDict(); + ~QwtPolarItemDict(); - void setAutoDelete( bool ); - bool autoDelete() const; + void setAutoDelete(bool); + bool autoDelete() const; - const QwtPolarItemList& itemList() const; + const QwtPolarItemList &itemList() const; - void detachItems( int rtti = QwtPolarItem::Rtti_PolarItem, - bool autoDelete = true ); + void detachItems(int rtti = QwtPolarItem::Rtti_PolarItem, + bool autoDelete = true); - protected: - void insertItem( QwtPolarItem* ); - void removeItem( QwtPolarItem* ); +protected: + void insertItem(QwtPolarItem *); + void removeItem(QwtPolarItem *); - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_layout.cpp b/libs/qwt/src/qwt_polar_layout.cpp index 82ec5f63..5697977d 100644 --- a/libs/qwt/src/qwt_polar_layout.cpp +++ b/libs/qwt/src/qwt_polar_layout.cpp @@ -15,96 +15,94 @@ class QwtPolarLayout::LayoutData { - public: - void init( const QwtPolarPlot*, const QRectF& rect ); +public: + void init(const QwtPolarPlot *, const QRectF &rect); - struct t_legendData - { - int frameWidth; - int hScrollExtent; - int vScrollExtent; - QSizeF hint; - } legend; + struct t_legendData + { + int frameWidth; + int hScrollExtent; + int vScrollExtent; + QSizeF hint; + } legend; - struct t_titleData - { - QwtText text; - int frameWidth; - } title; + struct t_titleData + { + QwtText text; + int frameWidth; + } title; - struct t_canvasData - { - int frameWidth; - } canvas; + struct t_canvasData + { + int frameWidth; + } canvas; }; -void QwtPolarLayout::LayoutData::init( - const QwtPolarPlot* plot, const QRectF& rect ) +void QwtPolarLayout::LayoutData::init(const QwtPolarPlot *plot, + const QRectF &rect) { - // legend + // legend - if ( plot->plotLayout()->legendPosition() != QwtPolarPlot::ExternalLegend - && plot->legend() ) - { - legend.frameWidth = plot->legend()->frameWidth(); - legend.hScrollExtent = - plot->legend()->scrollExtent( Qt::Horizontal ); - legend.vScrollExtent = - plot->legend()->scrollExtent( Qt::Vertical ); + if (plot->plotLayout()->legendPosition() != QwtPolarPlot::ExternalLegend + && plot->legend()) + { + legend.frameWidth = plot->legend()->frameWidth(); + legend.hScrollExtent = plot->legend()->scrollExtent(Qt::Horizontal); + legend.vScrollExtent = plot->legend()->scrollExtent(Qt::Vertical); - const QSizeF hint = plot->legend()->sizeHint(); + const QSizeF hint = plot->legend()->sizeHint(); - double w = qMin( hint.width(), rect.width() ); - double h = plot->legend()->heightForWidth( w ); - if ( h == 0.0 ) - h = hint.height(); + double w = qMin(hint.width(), rect.width()); + double h = plot->legend()->heightForWidth(w); + if (h == 0.0) + h = hint.height(); - if ( h > rect.height() ) - w += legend.hScrollExtent; + if (h > rect.height()) + w += legend.hScrollExtent; - legend.hint = QSizeF( w, h ); - } + legend.hint = QSizeF(w, h); + } - // title + // title - title.frameWidth = 0; - title.text = QwtText(); + title.frameWidth = 0; + title.text = QwtText(); - if ( plot->titleLabel() ) - { - const QwtTextLabel* label = plot->titleLabel(); - title.text = label->text(); - if ( !( title.text.testPaintAttribute( QwtText::PaintUsingTextFont ) ) ) - title.text.setFont( label->font() ); + if (plot->titleLabel()) + { + const QwtTextLabel *label = plot->titleLabel(); + title.text = label->text(); + if (!(title.text.testPaintAttribute(QwtText::PaintUsingTextFont))) + title.text.setFont(label->font()); - title.frameWidth = plot->titleLabel()->frameWidth(); - } + title.frameWidth = plot->titleLabel()->frameWidth(); + } - // canvas + // canvas - canvas.frameWidth = plot->canvas()->frameWidth(); + canvas.frameWidth = plot->canvas()->frameWidth(); } class QwtPolarLayout::PrivateData { - public: - PrivateData() - : margin( 0 ) - , spacing( 0 ) - { - } +public: + PrivateData() + : margin(0) + , spacing(0) + { + } - QRectF titleRect; - QRectF legendRect; - QRectF canvasRect; + QRectF titleRect; + QRectF legendRect; + QRectF canvasRect; - QwtPolarLayout::LayoutData layoutData; + QwtPolarLayout::LayoutData layoutData; - QwtPolarPlot::LegendPosition legendPos; - double legendRatio; + QwtPolarPlot::LegendPosition legendPos; + double legendRatio; - unsigned int margin; - unsigned int spacing; + unsigned int margin; + unsigned int spacing; }; /*! @@ -113,16 +111,16 @@ class QwtPolarLayout::PrivateData QwtPolarLayout::QwtPolarLayout() { - m_data = new PrivateData; + m_data = new PrivateData; - setLegendPosition( QwtPolarPlot::BottomLegend ); - invalidate(); + setLegendPosition(QwtPolarPlot::BottomLegend); + invalidate(); } //! Destructor QwtPolarLayout::~QwtPolarLayout() { - delete m_data; + delete m_data; } /*! @@ -138,41 +136,38 @@ QwtPolarLayout::~QwtPolarLayout() \sa QwtPolarPlot::setLegendPosition() */ -void QwtPolarLayout::setLegendPosition( - QwtPolarPlot::LegendPosition pos, double ratio ) +void QwtPolarLayout::setLegendPosition(QwtPolarPlot::LegendPosition pos, + double ratio) { - if ( ratio > 1.0 ) - ratio = 1.0; + if (ratio > 1.0) + ratio = 1.0; - switch( pos ) - { - case QwtPolarPlot::TopLegend: - case QwtPolarPlot::BottomLegend: - { - if ( ratio <= 0.0 ) - ratio = 0.33; - m_data->legendRatio = ratio; - m_data->legendPos = pos; - break; - } - case QwtPolarPlot::LeftLegend: - case QwtPolarPlot::RightLegend: - { - if ( ratio <= 0.0 ) - ratio = 0.5; - m_data->legendRatio = ratio; - m_data->legendPos = pos; - break; - } - case QwtPolarPlot::ExternalLegend: - { - m_data->legendRatio = ratio; // meaningless - m_data->legendPos = pos; - break; - } - default: - break; + switch (pos) + { + case QwtPolarPlot::TopLegend: + case QwtPolarPlot::BottomLegend: { + if (ratio <= 0.0) + ratio = 0.33; + m_data->legendRatio = ratio; + m_data->legendPos = pos; + break; } + case QwtPolarPlot::LeftLegend: + case QwtPolarPlot::RightLegend: { + if (ratio <= 0.0) + ratio = 0.5; + m_data->legendRatio = ratio; + m_data->legendPos = pos; + break; + } + case QwtPolarPlot::ExternalLegend: { + m_data->legendRatio = ratio; // meaningless + m_data->legendPos = pos; + break; + } + default: + break; + } } /*! @@ -183,9 +178,9 @@ void QwtPolarLayout::setLegendPosition( \sa QwtPolarPlot::setLegendPosition() */ -void QwtPolarLayout::setLegendPosition( QwtPolarPlot::LegendPosition pos ) +void QwtPolarLayout::setLegendPosition(QwtPolarPlot::LegendPosition pos) { - setLegendPosition( pos, 0.0 ); + setLegendPosition(pos, 0.0); } /*! @@ -195,7 +190,7 @@ void QwtPolarLayout::setLegendPosition( QwtPolarPlot::LegendPosition pos ) */ QwtPolarPlot::LegendPosition QwtPolarLayout::legendPosition() const { - return m_data->legendPos; + return m_data->legendPos; } /*! @@ -207,9 +202,9 @@ QwtPolarPlot::LegendPosition QwtPolarLayout::legendPosition() const it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5. */ -void QwtPolarLayout::setLegendRatio( double ratio ) +void QwtPolarLayout::setLegendRatio(double ratio) { - setLegendPosition( legendPosition(), ratio ); + setLegendPosition(legendPosition(), ratio); } /*! @@ -218,7 +213,7 @@ void QwtPolarLayout::setLegendRatio( double ratio ) */ double QwtPolarLayout::legendRatio() const { - return m_data->legendRatio; + return m_data->legendRatio; } /*! @@ -226,9 +221,9 @@ double QwtPolarLayout::legendRatio() const \sa activate(), invalidate() */ -const QRectF& QwtPolarLayout::titleRect() const +const QRectF &QwtPolarLayout::titleRect() const { - return m_data->titleRect; + return m_data->titleRect; } /*! @@ -236,18 +231,18 @@ const QRectF& QwtPolarLayout::titleRect() const \sa activate(), invalidate() */ -const QRectF& QwtPolarLayout::legendRect() const +const QRectF &QwtPolarLayout::legendRect() const { - return m_data->legendRect; + return m_data->legendRect; } /*! \return Geometry for the canvas \sa activate(), invalidate() */ -const QRectF& QwtPolarLayout::canvasRect() const +const QRectF &QwtPolarLayout::canvasRect() const { - return m_data->canvasRect; + return m_data->canvasRect; } /*! @@ -256,7 +251,7 @@ const QRectF& QwtPolarLayout::canvasRect() const */ void QwtPolarLayout::invalidate() { - m_data->titleRect = m_data->legendRect = m_data->canvasRect = QRect(); + m_data->titleRect = m_data->legendRect = m_data->canvasRect = QRect(); } /*! @@ -266,70 +261,66 @@ void QwtPolarLayout::invalidate() \return Geometry for the legend */ -QRectF QwtPolarLayout::layoutLegend( Options options, QRectF& rect ) const +QRectF QwtPolarLayout::layoutLegend(Options options, QRectF &rect) const { - const QSizeF hint( m_data->layoutData.legend.hint ); + const QSizeF hint(m_data->layoutData.legend.hint); - int dim; - if ( m_data->legendPos == QwtPolarPlot::LeftLegend - || m_data->legendPos == QwtPolarPlot::RightLegend ) + int dim; + if (m_data->legendPos == QwtPolarPlot::LeftLegend + || m_data->legendPos == QwtPolarPlot::RightLegend) + { + // We don't allow vertical legends to take more than + // half of the available space. + + dim = qMin(double(hint.width()), rect.width() * m_data->legendRatio); + + if (!(options & IgnoreScrollbars)) { - // We don't allow vertical legends to take more than - // half of the available space. + if (hint.height() > rect.height()) + { + // The legend will need additional + // space for the vertical scrollbar. - dim = qMin( double( hint.width() ), rect.width() * m_data->legendRatio ); - - if ( !( options & IgnoreScrollbars ) ) - { - if ( hint.height() > rect.height() ) - { - // The legend will need additional - // space for the vertical scrollbar. - - dim += m_data->layoutData.legend.hScrollExtent; - } - } - } - else - { - dim = qMin( double( hint.height() ), rect.height() * m_data->legendRatio ); - dim = qMax( dim, m_data->layoutData.legend.vScrollExtent ); + dim += m_data->layoutData.legend.hScrollExtent; + } } + } + else + { + dim = qMin(double(hint.height()), rect.height() * m_data->legendRatio); + dim = qMax(dim, m_data->layoutData.legend.vScrollExtent); + } - QRectF legendRect = rect; - switch( m_data->legendPos ) - { - case QwtPolarPlot::LeftLegend: - { - legendRect.setWidth( dim ); - rect.setLeft( legendRect.right() ); - break; - } - case QwtPolarPlot::RightLegend: - { - legendRect.setX( rect.right() - dim + 1 ); - legendRect.setWidth( dim ); - rect.setRight( legendRect.left() ); - break; - } - case QwtPolarPlot::TopLegend: - { - legendRect.setHeight( dim ); - rect.setTop( legendRect.bottom() ); - break; - } - case QwtPolarPlot::BottomLegend: - { - legendRect.setY( rect.bottom() - dim + 1 ); - legendRect.setHeight( dim ); - rect.setBottom( legendRect.top() ); - break; - } - case QwtPolarPlot::ExternalLegend: - break; + QRectF legendRect = rect; + switch (m_data->legendPos) + { + case QwtPolarPlot::LeftLegend: { + legendRect.setWidth(dim); + rect.setLeft(legendRect.right()); + break; } + case QwtPolarPlot::RightLegend: { + legendRect.setX(rect.right() - dim + 1); + legendRect.setWidth(dim); + rect.setRight(legendRect.left()); + break; + } + case QwtPolarPlot::TopLegend: { + legendRect.setHeight(dim); + rect.setTop(legendRect.bottom()); + break; + } + case QwtPolarPlot::BottomLegend: { + legendRect.setY(rect.bottom() - dim + 1); + legendRect.setHeight(dim); + rect.setBottom(legendRect.top()); + break; + } + case QwtPolarPlot::ExternalLegend: + break; + } - return legendRect; + return legendRect; } /*! @@ -341,103 +332,100 @@ QRectF QwtPolarLayout::layoutLegend( Options options, QRectF& rect ) const \sa invalidate(), titleRect(), legendRect(), canvasRect() */ -void QwtPolarLayout::activate( const QwtPolarPlot* plot, - const QRectF& boundingRect, Options options ) +void QwtPolarLayout::activate(const QwtPolarPlot *plot, + const QRectF &boundingRect, Options options) { - invalidate(); + invalidate(); - QRectF rect( boundingRect ); // undistributed rest of the plot rect - rect.adjust( m_data->margin, m_data->margin, - -((int)m_data->margin), -(int)(m_data->margin)); + QRectF rect(boundingRect); // undistributed rest of the plot rect + rect.adjust(m_data->margin, m_data->margin, -((int)m_data->margin), + -(int)(m_data->margin)); - // We extract all layout relevant data from the widgets - // and save them to m_data->layoutData. + // We extract all layout relevant data from the widgets + // and save them to m_data->layoutData. - m_data->layoutData.init( plot, rect ); - if ( !( options & IgnoreLegend ) - && m_data->legendPos != QwtPolarPlot::ExternalLegend - && plot->legend() && !plot->legend()->isEmpty() ) + m_data->layoutData.init(plot, rect); + if (!(options & IgnoreLegend) + && m_data->legendPos != QwtPolarPlot::ExternalLegend && plot->legend() + && !plot->legend()->isEmpty()) + { + m_data->legendRect = layoutLegend(options, rect); + if (m_data->layoutData.legend.frameWidth && !(options & IgnoreFrames)) { - m_data->legendRect = layoutLegend( options, rect ); - if ( m_data->layoutData.legend.frameWidth && - !( options & IgnoreFrames ) ) - { - // In case of a frame we have to insert a spacing. - // Otherwise the leading of the font separates - // legend and scale/canvas + // In case of a frame we have to insert a spacing. + // Otherwise the leading of the font separates + // legend and scale/canvas - switch( m_data->legendPos ) - { - case QwtPolarPlot::LeftLegend: - rect.setLeft( rect.left() + m_data->spacing ); - break; + switch (m_data->legendPos) + { + case QwtPolarPlot::LeftLegend: + rect.setLeft(rect.left() + m_data->spacing); + break; - case QwtPolarPlot::RightLegend: - rect.setRight( rect.right() - m_data->spacing ); - break; + case QwtPolarPlot::RightLegend: + rect.setRight(rect.right() - m_data->spacing); + break; - case QwtPolarPlot::TopLegend: - rect.setTop( rect.top() + m_data->spacing ); - break; + case QwtPolarPlot::TopLegend: + rect.setTop(rect.top() + m_data->spacing); + break; - case QwtPolarPlot::BottomLegend: - rect.setBottom( rect.bottom() - m_data->spacing ); - break; + case QwtPolarPlot::BottomLegend: + rect.setBottom(rect.bottom() - m_data->spacing); + break; - case QwtPolarPlot::ExternalLegend: - break; // suppress compiler warning - } - } + case QwtPolarPlot::ExternalLegend: + break; // suppress compiler warning + } } + } - if ( !( options & IgnoreTitle ) && - !m_data->layoutData.title.text.isEmpty() ) + if (!(options & IgnoreTitle) && !m_data->layoutData.title.text.isEmpty()) + { + int h = m_data->layoutData.title.text.heightForWidth(rect.width()); + if (!(options & IgnoreFrames)) + h += 2 * m_data->layoutData.title.frameWidth; + + m_data->titleRect = QRectF(rect.x(), rect.y(), rect.width(), h); + + // subtract title + rect.setTop(rect.top() + h + m_data->spacing); + } + + if (plot->zoomPos().radius() > 0.0 || plot->zoomFactor() < 1.0) + { + // In zoomed state we have no idea about the geometry that + // is best for the plot. So we use the complete rectangle + // accepting, that there might a lot of space wasted + // around the plot. + + m_data->canvasRect = rect; + } + else + { + // In full state we know, that we want + // to display something circular. + + const int dim = qMin(rect.width(), rect.height()); + + m_data->canvasRect.setX(rect.center().x() - dim / 2); + m_data->canvasRect.setY(rect.y()); + m_data->canvasRect.setSize(QSize(dim, dim)); + } + + if (!m_data->legendRect.isEmpty()) + { + if (m_data->legendPos == QwtPolarPlot::LeftLegend + || m_data->legendPos == QwtPolarPlot::RightLegend) { - int h = m_data->layoutData.title.text.heightForWidth( rect.width() ); - if ( !( options & IgnoreFrames ) ) - h += 2 * m_data->layoutData.title.frameWidth; + // We prefer to align the legend to the canvas - not to + // the complete plot - if possible. - m_data->titleRect = QRectF( rect.x(), rect.y(), rect.width(), h ); - - // subtract title - rect.setTop( rect.top() + h + m_data->spacing ); - } - - if ( plot->zoomPos().radius() > 0.0 || plot->zoomFactor() < 1.0 ) - { - // In zoomed state we have no idea about the geometry that - // is best for the plot. So we use the complete rectangle - // accepting, that there might a lot of space wasted - // around the plot. - - m_data->canvasRect = rect; - } - else - { - // In full state we know, that we want - // to display something circular. - - const int dim = qMin( rect.width(), rect.height() ); - - m_data->canvasRect.setX( rect.center().x() - dim / 2 ); - m_data->canvasRect.setY( rect.y() ); - m_data->canvasRect.setSize( QSize( dim, dim ) ); - } - - if ( !m_data->legendRect.isEmpty() ) - { - if ( m_data->legendPos == QwtPolarPlot::LeftLegend - || m_data->legendPos == QwtPolarPlot::RightLegend ) - { - // We prefer to align the legend to the canvas - not to - // the complete plot - if possible. - - if ( m_data->layoutData.legend.hint.height() - < m_data->canvasRect.height() ) - { - m_data->legendRect.setY( m_data->canvasRect.y() ); - m_data->legendRect.setHeight( m_data->canvasRect.height() ); - } - } + if (m_data->layoutData.legend.hint.height() < m_data->canvasRect.height()) + { + m_data->legendRect.setY(m_data->canvasRect.y()); + m_data->legendRect.setHeight(m_data->canvasRect.height()); + } } + } } diff --git a/libs/qwt/src/qwt_polar_layout.h b/libs/qwt/src/qwt_polar_layout.h index 67fdd0de..6cadc5f1 100644 --- a/libs/qwt/src/qwt_polar_layout.h +++ b/libs/qwt/src/qwt_polar_layout.h @@ -22,55 +22,54 @@ */ class QWT_EXPORT QwtPolarLayout { - public: +public: + //! \brief Options to configure the plot layout engine + enum Option + { + //! Ignore the dimension of the scrollbars. + IgnoreScrollbars = 0x01, - //! \brief Options to configure the plot layout engine - enum Option - { - //! Ignore the dimension of the scrollbars. - IgnoreScrollbars = 0x01, + //! Ignore all frames. + IgnoreFrames = 0x02, - //! Ignore all frames. - IgnoreFrames = 0x02, + //! Ignore the title. + IgnoreTitle = 0x04, - //! Ignore the title. - IgnoreTitle = 0x04, + //! Ignore the legend. + IgnoreLegend = 0x08 + }; - //! Ignore the legend. - IgnoreLegend = 0x08 - }; + Q_DECLARE_FLAGS(Options, Option) - Q_DECLARE_FLAGS( Options, Option ) + explicit QwtPolarLayout(); + virtual ~QwtPolarLayout(); - explicit QwtPolarLayout(); - virtual ~QwtPolarLayout(); + void setLegendPosition(QwtPolarPlot::LegendPosition pos, double ratio); + void setLegendPosition(QwtPolarPlot::LegendPosition pos); + QwtPolarPlot::LegendPosition legendPosition() const; - void setLegendPosition( QwtPolarPlot::LegendPosition pos, double ratio ); - void setLegendPosition( QwtPolarPlot::LegendPosition pos ); - QwtPolarPlot::LegendPosition legendPosition() const; + void setLegendRatio(double ratio); + double legendRatio() const; - void setLegendRatio( double ratio ); - double legendRatio() const; + virtual void activate(const QwtPolarPlot *, const QRectF &rect, + Options options = Options()); - virtual void activate( const QwtPolarPlot*, - const QRectF& rect, Options options = Options() ); + virtual void invalidate(); - virtual void invalidate(); + const QRectF &titleRect() const; + const QRectF &legendRect() const; + const QRectF &canvasRect() const; - const QRectF& titleRect() const; - const QRectF& legendRect() const; - const QRectF& canvasRect() const; + class LayoutData; - class LayoutData; +protected: + QRectF layoutLegend(Options options, QRectF &) const; - protected: - QRectF layoutLegend( Options options, QRectF& ) const; - - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarLayout::Options ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarLayout::Options) #endif diff --git a/libs/qwt/src/qwt_polar_magnifier.cpp b/libs/qwt/src/qwt_polar_magnifier.cpp index 7a692401..ab23dd7f 100644 --- a/libs/qwt/src/qwt_polar_magnifier.cpp +++ b/libs/qwt/src/qwt_polar_magnifier.cpp @@ -16,31 +16,31 @@ class QwtPolarMagnifier::PrivateData { - public: - PrivateData() - : unzoomKey( Qt::Key_Home ) - , unzoomKeyModifiers( Qt::NoModifier ) - { - } +public: + PrivateData() + : unzoomKey(Qt::Key_Home) + , unzoomKeyModifiers(Qt::NoModifier) + { + } - int unzoomKey; - int unzoomKeyModifiers; + int unzoomKey; + int unzoomKeyModifiers; }; /*! Constructor \param canvas Plot canvas to be magnified */ -QwtPolarMagnifier::QwtPolarMagnifier( QwtPolarCanvas* canvas ) - : QwtMagnifier( canvas ) +QwtPolarMagnifier::QwtPolarMagnifier(QwtPolarCanvas *canvas) + : QwtMagnifier(canvas) { - m_data = new PrivateData(); + m_data = new PrivateData(); } //! Destructor QwtPolarMagnifier::~QwtPolarMagnifier() { - delete m_data; + delete m_data; } /*! @@ -51,10 +51,10 @@ QwtPolarMagnifier::~QwtPolarMagnifier() \param modifiers Modifiers \sa getUnzoomKey(), QwtPolarPlot::unzoom() */ -void QwtPolarMagnifier::setUnzoomKey( int key, int modifiers ) +void QwtPolarMagnifier::setUnzoomKey(int key, int modifiers) { - m_data->unzoomKey = key; - m_data->unzoomKeyModifiers = modifiers; + m_data->unzoomKey = key; + m_data->unzoomKeyModifiers = modifiers; } /*! @@ -64,42 +64,42 @@ void QwtPolarMagnifier::setUnzoomKey( int key, int modifiers ) \param modifiers Modifiers \sa setUnzoomKey(), QwtPolarPlot::unzoom() */ -void QwtPolarMagnifier::getUnzoomKey( int& key, int& modifiers ) const +void QwtPolarMagnifier::getUnzoomKey(int &key, int &modifiers) const { - key = m_data->unzoomKey; - modifiers = m_data->unzoomKeyModifiers; + key = m_data->unzoomKey; + modifiers = m_data->unzoomKeyModifiers; } //! \return Observed plot canvas -QwtPolarCanvas* QwtPolarMagnifier::canvas() +QwtPolarCanvas *QwtPolarMagnifier::canvas() { - return qobject_cast< QwtPolarCanvas* >( parent() ); + return qobject_cast(parent()); } //! \return Observed plot canvas -const QwtPolarCanvas* QwtPolarMagnifier::canvas() const +const QwtPolarCanvas *QwtPolarMagnifier::canvas() const { - return qobject_cast< QwtPolarCanvas* >( parent() ); + return qobject_cast(parent()); } //! \return Observed plot -QwtPolarPlot* QwtPolarMagnifier::plot() +QwtPolarPlot *QwtPolarMagnifier::plot() { - QwtPolarCanvas* c = canvas(); - if ( c ) - return c->plot(); + QwtPolarCanvas *c = canvas(); + if (c) + return c->plot(); - return NULL; + return NULL; } //! \return observed plot -const QwtPolarPlot* QwtPolarMagnifier::plot() const +const QwtPolarPlot *QwtPolarMagnifier::plot() const { - const QwtPolarCanvas* c = canvas(); - if ( c ) - return c->plot(); + const QwtPolarCanvas *c = canvas(); + if (c) + return c->plot(); - return NULL; + return NULL; } /*! @@ -107,66 +107,65 @@ const QwtPolarPlot* QwtPolarMagnifier::plot() const \param event Key event */ -void QwtPolarMagnifier::widgetKeyPressEvent( QKeyEvent* event ) +void QwtPolarMagnifier::widgetKeyPressEvent(QKeyEvent *event) { - const int key = event->key(); - const int state = event->modifiers(); + const int key = event->key(); + const int state = event->modifiers(); - if ( key == m_data->unzoomKey && - state == m_data->unzoomKeyModifiers ) - { - unzoom(); - return; - } + if (key == m_data->unzoomKey && state == m_data->unzoomKeyModifiers) + { + unzoom(); + return; + } - QwtMagnifier::widgetKeyPressEvent( event ); + QwtMagnifier::widgetKeyPressEvent(event); } /*! Zoom in/out the zoomed area \param factor A value < 1.0 zooms in, a value > 1.0 zooms out. */ -void QwtPolarMagnifier::rescale( double factor ) +void QwtPolarMagnifier::rescale(double factor) { - factor = qAbs( factor ); - if ( factor == 1.0 || factor == 0.0 ) - return; + factor = qAbs(factor); + if (factor == 1.0 || factor == 0.0) + return; - QwtPolarPlot* plt = plot(); - if ( plt == NULL ) - return; + QwtPolarPlot *plt = plot(); + if (plt == NULL) + return; - QwtPointPolar zoomPos; - double newZoomFactor = plt->zoomFactor() * factor; + QwtPointPolar zoomPos; + double newZoomFactor = plt->zoomFactor() * factor; - if ( newZoomFactor >= 1.0 ) - newZoomFactor = 1.0; - else - zoomPos = plt->zoomPos(); + if (newZoomFactor >= 1.0) + newZoomFactor = 1.0; + else + zoomPos = plt->zoomPos(); - const bool autoReplot = plt->autoReplot(); - plt->setAutoReplot( false ); + const bool autoReplot = plt->autoReplot(); + plt->setAutoReplot(false); - plt->zoom( zoomPos, newZoomFactor ); + plt->zoom(zoomPos, newZoomFactor); - plt->setAutoReplot( autoReplot ); - plt->replot(); + plt->setAutoReplot(autoReplot); + plt->replot(); } //! Unzoom the plot widget void QwtPolarMagnifier::unzoom() { - QwtPolarPlot* plt = plot(); + QwtPolarPlot *plt = plot(); - const bool autoReplot = plt->autoReplot(); - plt->setAutoReplot( false ); + const bool autoReplot = plt->autoReplot(); + plt->setAutoReplot(false); - plt->unzoom(); + plt->unzoom(); - plt->setAutoReplot( autoReplot ); - plt->replot(); + plt->setAutoReplot(autoReplot); + plt->replot(); } #if QWT_MOC_INCLUDE -#include "moc_qwt_polar_magnifier.cpp" +# include "moc_qwt_polar_magnifier.cpp" #endif diff --git a/libs/qwt/src/qwt_polar_magnifier.h b/libs/qwt/src/qwt_polar_magnifier.h index 8e083b74..acf76ee1 100644 --- a/libs/qwt/src/qwt_polar_magnifier.h +++ b/libs/qwt/src/qwt_polar_magnifier.h @@ -29,31 +29,31 @@ class QwtPolarCanvas; class QWT_EXPORT QwtPolarMagnifier : public QwtMagnifier { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPolarMagnifier( QwtPolarCanvas* ); - virtual ~QwtPolarMagnifier(); +public: + explicit QwtPolarMagnifier(QwtPolarCanvas *); + virtual ~QwtPolarMagnifier(); - void setUnzoomKey( int key, int modifiers ); - void getUnzoomKey( int& key, int& modifiers ) const; + void setUnzoomKey(int key, int modifiers); + void getUnzoomKey(int &key, int &modifiers) const; - QwtPolarPlot* plot(); - const QwtPolarPlot* plot() const; + QwtPolarPlot *plot(); + const QwtPolarPlot *plot() const; - QwtPolarCanvas* canvas(); - const QwtPolarCanvas* canvas() const; + QwtPolarCanvas *canvas(); + const QwtPolarCanvas *canvas() const; - public Q_SLOTS: - virtual void rescale( double factor ) QWT_OVERRIDE; - void unzoom(); +public Q_SLOTS: + virtual void rescale(double factor) QWT_OVERRIDE; + void unzoom(); - protected: - virtual void widgetKeyPressEvent( QKeyEvent* ) QWT_OVERRIDE; +protected: + virtual void widgetKeyPressEvent(QKeyEvent *) QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_marker.cpp b/libs/qwt/src/qwt_polar_marker.cpp index bc40b525..f1524e7e 100644 --- a/libs/qwt/src/qwt_polar_marker.cpp +++ b/libs/qwt/src/qwt_polar_marker.cpp @@ -18,62 +18,59 @@ static const int LabelDist = 2; class QwtPolarMarker::PrivateData { - public: - PrivateData() - : align( Qt::AlignCenter ) - { - symbol = new QwtSymbol(); - } +public: + PrivateData() + : align(Qt::AlignCenter) + { + symbol = new QwtSymbol(); + } - ~PrivateData() - { - delete symbol; - } + ~PrivateData() { delete symbol; } - QwtText label; - Qt::Alignment align; - QPen pen; - const QwtSymbol* symbol; + QwtText label; + Qt::Alignment align; + QPen pen; + const QwtSymbol *symbol; - QwtPointPolar pos; + QwtPointPolar pos; }; //! Sets alignment to Qt::AlignCenter, and style to NoLine QwtPolarMarker::QwtPolarMarker() - : QwtPolarItem( QwtText( "Marker" ) ) + : QwtPolarItem(QwtText("Marker")) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemAttribute( QwtPolarItem::AutoScale ); - setZ( 30.0 ); + setItemAttribute(QwtPolarItem::AutoScale); + setZ(30.0); } //! Destructor QwtPolarMarker::~QwtPolarMarker() { - delete m_data; + delete m_data; } //! \return QwtPolarItem::Rtti_PlotMarker int QwtPolarMarker::rtti() const { - return QwtPolarItem::Rtti_PolarMarker; + return QwtPolarItem::Rtti_PolarMarker; } //! \return Position of the marker QwtPointPolar QwtPolarMarker::position() const { - return m_data->pos; + return m_data->pos; } //! Change the position of the marker -void QwtPolarMarker::setPosition( const QwtPointPolar& pos ) +void QwtPolarMarker::setPosition(const QwtPointPolar &pos) { - if ( m_data->pos != pos ) - { - m_data->pos = pos; - itemChanged(); - } + if (m_data->pos != pos) + { + m_data->pos = pos; + itemChanged(); + } } /*! @@ -86,58 +83,56 @@ void QwtPolarMarker::setPosition( const QwtPointPolar& pos ) \param radius Radius of the complete plot area in painter coordinates \param canvasRect Contents rect of the canvas in painter coordinates */ -void QwtPolarMarker::draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const +void QwtPolarMarker::draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const { - Q_UNUSED( radius ); - Q_UNUSED( canvasRect ); + Q_UNUSED(radius); + Q_UNUSED(canvasRect); - const double r = radialMap.transform( m_data->pos.radius() ); - const double a = azimuthMap.transform( m_data->pos.azimuth() ); + const double r = radialMap.transform(m_data->pos.radius()); + const double a = azimuthMap.transform(m_data->pos.azimuth()); - const QPointF pos = qwtPolar2Pos( pole, r, a ); + const QPointF pos = qwtPolar2Pos(pole, r, a); + // draw symbol + QSize sSym(0, 0); + if (m_data->symbol->style() != QwtSymbol::NoSymbol) + { + sSym = m_data->symbol->size(); + m_data->symbol->drawSymbol(painter, pos); + } - // draw symbol - QSize sSym( 0, 0 ); - if ( m_data->symbol->style() != QwtSymbol::NoSymbol ) - { - sSym = m_data->symbol->size(); - m_data->symbol->drawSymbol( painter, pos ); - } + // draw label + if (!m_data->label.isEmpty()) + { + int xlw = qMax(int(m_data->pen.width()), 1); + int ylw = xlw; - // draw label - if ( !m_data->label.isEmpty() ) - { - int xlw = qMax( int( m_data->pen.width() ), 1 ); - int ylw = xlw; + int xlw1 = qMax((xlw + 1) / 2, (sSym.width() + 1) / 2) + LabelDist; + xlw = qMax(xlw / 2, (sSym.width() + 1) / 2) + LabelDist; + int ylw1 = qMax((ylw + 1) / 2, (sSym.height() + 1) / 2) + LabelDist; + ylw = qMax(ylw / 2, (sSym.height() + 1) / 2) + LabelDist; - int xlw1 = qMax( ( xlw + 1 ) / 2, ( sSym.width() + 1 ) / 2 ) + LabelDist; - xlw = qMax( xlw / 2, ( sSym.width() + 1 ) / 2 ) + LabelDist; - int ylw1 = qMax( ( ylw + 1 ) / 2, ( sSym.height() + 1 ) / 2 ) + LabelDist; - ylw = qMax( ylw / 2, ( sSym.height() + 1 ) / 2 ) + LabelDist; + QRect tr(QPoint(0, 0), m_data->label.textSize(painter->font()).toSize()); + tr.moveCenter(QPoint(0, 0)); - QRect tr( QPoint( 0, 0 ), m_data->label.textSize( painter->font() ).toSize() ); - tr.moveCenter( QPoint( 0, 0 ) ); + int dx = pos.x(); + int dy = pos.y(); - int dx = pos.x(); - int dy = pos.y(); + if (m_data->align & Qt::AlignTop) + dy += tr.y() - ylw1; + else if (m_data->align & Qt::AlignBottom) + dy -= tr.y() - ylw1; - if ( m_data->align & Qt::AlignTop ) - dy += tr.y() - ylw1; - else if ( m_data->align & Qt::AlignBottom ) - dy -= tr.y() - ylw1; + if (m_data->align & Qt::AlignLeft) + dx += tr.x() - xlw1; + else if (m_data->align & Qt::AlignRight) + dx -= tr.x() - xlw1; - if ( m_data->align & Qt::AlignLeft ) - dx += tr.x() - xlw1; - else if ( m_data->align & Qt::AlignRight ) - dx -= tr.x() - xlw1; - - tr.translate( dx, dy ); - m_data->label.draw( painter, tr ); - } + tr.translate(dx, dy); + m_data->label.draw(painter, tr); + } } /*! @@ -145,23 +140,23 @@ void QwtPolarMarker::draw( QPainter* painter, \param symbol New symbol \sa symbol() */ -void QwtPolarMarker::setSymbol( const QwtSymbol* symbol ) +void QwtPolarMarker::setSymbol(const QwtSymbol *symbol) { - if ( m_data->symbol != symbol ) - { - delete m_data->symbol; - m_data->symbol = symbol; - itemChanged(); - } + if (m_data->symbol != symbol) + { + delete m_data->symbol; + m_data->symbol = symbol; + itemChanged(); + } } /*! \return the symbol \sa setSymbol(), QwtSymbol */ -const QwtSymbol* QwtPolarMarker::symbol() const +const QwtSymbol *QwtPolarMarker::symbol() const { - return m_data->symbol; + return m_data->symbol; } /*! @@ -169,13 +164,13 @@ const QwtSymbol* QwtPolarMarker::symbol() const \param label label text \sa label() */ -void QwtPolarMarker::setLabel( const QwtText& label ) +void QwtPolarMarker::setLabel(const QwtText &label) { - if ( label != m_data->label ) - { - m_data->label = label; - itemChanged(); - } + if (label != m_data->label) + { + m_data->label = label; + itemChanged(); + } } /*! @@ -184,7 +179,7 @@ void QwtPolarMarker::setLabel( const QwtText& label ) */ QwtText QwtPolarMarker::label() const { - return m_data->label; + return m_data->label; } /*! @@ -198,13 +193,13 @@ QwtText QwtPolarMarker::label() const AlignVCenter. \sa labelAlignment() */ -void QwtPolarMarker::setLabelAlignment( Qt::Alignment align ) +void QwtPolarMarker::setLabelAlignment(Qt::Alignment align) { - if ( align == m_data->align ) - return; + if (align == m_data->align) + return; - m_data->align = align; - itemChanged(); + m_data->align = align; + itemChanged(); } /*! @@ -213,7 +208,7 @@ void QwtPolarMarker::setLabelAlignment( Qt::Alignment align ) */ Qt::Alignment QwtPolarMarker::labelAlignment() const { - return m_data->align; + return m_data->align; } /*! @@ -225,10 +220,10 @@ Qt::Alignment QwtPolarMarker::labelAlignment() const \sa position() */ -QwtInterval QwtPolarMarker::boundingInterval( int scaleId ) const +QwtInterval QwtPolarMarker::boundingInterval(int scaleId) const { - const double v = ( scaleId == QwtPolar::ScaleRadius ) - ? m_data->pos.radius() : m_data->pos.azimuth(); + const double v = (scaleId == QwtPolar::ScaleRadius) ? m_data->pos.radius() + : m_data->pos.azimuth(); - return QwtInterval( v, v ); + return QwtInterval(v, v); } diff --git a/libs/qwt/src/qwt_polar_marker.h b/libs/qwt/src/qwt_polar_marker.h index 9291d683..95cad678 100644 --- a/libs/qwt/src/qwt_polar_marker.h +++ b/libs/qwt/src/qwt_polar_marker.h @@ -35,34 +35,33 @@ class QwtSymbol; */ class QWT_EXPORT QwtPolarMarker : public QwtPolarItem { - public: - explicit QwtPolarMarker(); - virtual ~QwtPolarMarker(); +public: + explicit QwtPolarMarker(); + virtual ~QwtPolarMarker(); - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - void setPosition( const QwtPointPolar& ); - QwtPointPolar position() const; + void setPosition(const QwtPointPolar &); + QwtPointPolar position() const; - void setSymbol( const QwtSymbol* s ); - const QwtSymbol* symbol() const; + void setSymbol(const QwtSymbol *s); + const QwtSymbol *symbol() const; - void setLabel( const QwtText& ); - QwtText label() const; + void setLabel(const QwtText &); + QwtText label() const; - void setLabelAlignment( Qt::Alignment ); - Qt::Alignment labelAlignment() const; + void setLabelAlignment(Qt::Alignment); + Qt::Alignment labelAlignment() const; - virtual void draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const QWT_OVERRIDE; - virtual QwtInterval boundingInterval( int scaleId ) const QWT_OVERRIDE; + virtual QwtInterval boundingInterval(int scaleId) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_panner.cpp b/libs/qwt/src/qwt_polar_panner.cpp index 0e3933f1..8d1e1f16 100644 --- a/libs/qwt/src/qwt_polar_panner.cpp +++ b/libs/qwt/src/qwt_polar_panner.cpp @@ -13,48 +13,45 @@ #include "qwt_point_polar.h" //! Create a plot panner for a polar plot canvas -QwtPolarPanner::QwtPolarPanner( QwtPolarCanvas* canvas ) - : QwtPanner( canvas ) +QwtPolarPanner::QwtPolarPanner(QwtPolarCanvas *canvas) + : QwtPanner(canvas) { - connect( this, SIGNAL(panned(int,int)), - SLOT(movePlot(int,int)) ); + connect(this, SIGNAL(panned(int, int)), SLOT(movePlot(int, int))); } //! Destructor -QwtPolarPanner::~QwtPolarPanner() +QwtPolarPanner::~QwtPolarPanner() {} + +//! \return observed plot canvas +QwtPolarCanvas *QwtPolarPanner::canvas() { + return qobject_cast(parent()); } //! \return observed plot canvas -QwtPolarCanvas* QwtPolarPanner::canvas() +const QwtPolarCanvas *QwtPolarPanner::canvas() const { - return qobject_cast< QwtPolarCanvas* >( parent() ); -} - -//! \return observed plot canvas -const QwtPolarCanvas* QwtPolarPanner::canvas() const -{ - return qobject_cast< const QwtPolarCanvas* >( parent() ); + return qobject_cast(parent()); } //! \return observed plot -QwtPolarPlot* QwtPolarPanner::plot() +QwtPolarPlot *QwtPolarPanner::plot() { - QwtPolarCanvas* c = canvas(); - if ( c ) - return c->plot(); + QwtPolarCanvas *c = canvas(); + if (c) + return c->plot(); - return NULL; + return NULL; } //! \return observed plot -const QwtPolarPlot* QwtPolarPanner::plot() const +const QwtPolarPlot *QwtPolarPanner::plot() const { - const QwtPolarCanvas* c = canvas(); - if ( c ) - return c->plot(); + const QwtPolarCanvas *c = canvas(); + if (c) + return c->plot(); - return NULL; + return NULL; } /*! @@ -65,39 +62,35 @@ const QwtPolarPlot* QwtPolarPanner::plot() const \sa QwtPanner::panned(), QwtPolarPlot::zoom() */ -void QwtPolarPanner::movePlot( int dx, int dy ) +void QwtPolarPanner::movePlot(int dx, int dy) { - QwtPolarPlot* plot = QwtPolarPanner::plot(); - if ( plot == NULL || ( dx == 0 && dy == 0 ) ) - return; + QwtPolarPlot *plot = QwtPolarPanner::plot(); + if (plot == NULL || (dx == 0 && dy == 0)) + return; - const QwtScaleMap map = plot->scaleMap( QwtPolar::Radius ); + const QwtScaleMap map = plot->scaleMap(QwtPolar::Radius); - QwtPointPolar pos = plot->zoomPos(); - if ( map.s1() <= map.s2() ) - { - pos.setRadius( - map.transform( map.s1() + pos.radius() ) - map.p1() ); - pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) ); - pos.setRadius( - map.invTransform( map.p1() + pos.radius() ) - map.s1() ); - } - else - { - pos.setRadius( - map.transform( map.s1() - pos.radius() ) - map.p1() ); - pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) ); - pos.setRadius( - map.s1() - map.invTransform( map.p1() + pos.radius() ) ); - } + QwtPointPolar pos = plot->zoomPos(); + if (map.s1() <= map.s2()) + { + pos.setRadius(map.transform(map.s1() + pos.radius()) - map.p1()); + pos.setPoint(pos.toPoint() - QPointF(dx, -dy)); + pos.setRadius(map.invTransform(map.p1() + pos.radius()) - map.s1()); + } + else + { + pos.setRadius(map.transform(map.s1() - pos.radius()) - map.p1()); + pos.setPoint(pos.toPoint() - QPointF(dx, -dy)); + pos.setRadius(map.s1() - map.invTransform(map.p1() + pos.radius())); + } - const bool doAutoReplot = plot->autoReplot(); - plot->setAutoReplot( false ); + const bool doAutoReplot = plot->autoReplot(); + plot->setAutoReplot(false); - plot->zoom( pos, plot->zoomFactor() ); + plot->zoom(pos, plot->zoomFactor()); - plot->setAutoReplot( doAutoReplot ); - plot->replot(); + plot->setAutoReplot(doAutoReplot); + plot->replot(); } /*! @@ -105,16 +98,16 @@ void QwtPolarPanner::movePlot( int dx, int dy ) \param event Mouse event */ -void QwtPolarPanner::widgetMousePressEvent( QMouseEvent* event ) +void QwtPolarPanner::widgetMousePressEvent(QMouseEvent *event) { - const QwtPolarPlot* plot = QwtPolarPanner::plot(); - if ( plot ) - { - if ( plot->zoomFactor() < 1.0 ) - QwtPanner::widgetMousePressEvent( event ); - } + const QwtPolarPlot *plot = QwtPolarPanner::plot(); + if (plot) + { + if (plot->zoomFactor() < 1.0) + QwtPanner::widgetMousePressEvent(event); + } } #if QWT_MOC_INCLUDE -#include "moc_qwt_polar_panner.cpp" +# include "moc_qwt_polar_panner.cpp" #endif diff --git a/libs/qwt/src/qwt_polar_panner.h b/libs/qwt/src/qwt_polar_panner.h index 7cd4fa46..4a727499 100644 --- a/libs/qwt/src/qwt_polar_panner.h +++ b/libs/qwt/src/qwt_polar_panner.h @@ -29,23 +29,23 @@ class QwtPolarCanvas; */ class QWT_EXPORT QwtPolarPanner : public QwtPanner { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPolarPanner( QwtPolarCanvas* ); - virtual ~QwtPolarPanner(); +public: + explicit QwtPolarPanner(QwtPolarCanvas *); + virtual ~QwtPolarPanner(); - QwtPolarPlot* plot(); - const QwtPolarPlot* plot() const; + QwtPolarPlot *plot(); + const QwtPolarPlot *plot() const; - QwtPolarCanvas* canvas(); - const QwtPolarCanvas* canvas() const; + QwtPolarCanvas *canvas(); + const QwtPolarCanvas *canvas() const; - public Q_SLOTS: - virtual void movePlot( int dx, int dy ); +public Q_SLOTS: + virtual void movePlot(int dx, int dy); - protected: - virtual void widgetMousePressEvent( QMouseEvent* ) QWT_OVERRIDE; +protected: + virtual void widgetMousePressEvent(QMouseEvent *) QWT_OVERRIDE; }; #endif diff --git a/libs/qwt/src/qwt_polar_picker.cpp b/libs/qwt/src/qwt_polar_picker.cpp index d909db44..074f212a 100644 --- a/libs/qwt/src/qwt_polar_picker.cpp +++ b/libs/qwt/src/qwt_polar_picker.cpp @@ -22,11 +22,11 @@ class QwtPolarPicker::PrivateData \param canvas Plot canvas to observe, also the parent object */ -QwtPolarPicker::QwtPolarPicker( QwtPolarCanvas* canvas ) - : QwtPicker( canvas ) - , m_data( nullptr ) +QwtPolarPicker::QwtPolarPicker(QwtPolarCanvas *canvas) + : QwtPicker(canvas) + , m_data(nullptr) { - (void) m_data; + (void)m_data; } /*! @@ -41,48 +41,46 @@ QwtPolarPicker::QwtPolarPicker( QwtPolarCanvas* canvas ) \sa QwtPolarPlot::autoReplot(), QwtPolarPlot::replot(), scaleRect() */ -QwtPolarPicker::QwtPolarPicker( - RubberBand rubberBand, DisplayMode trackerMode, QwtPolarCanvas* canvas ) - : QwtPicker( rubberBand, trackerMode, canvas ) - , m_data( nullptr ) +QwtPolarPicker::QwtPolarPicker(RubberBand rubberBand, DisplayMode trackerMode, + QwtPolarCanvas *canvas) + : QwtPicker(rubberBand, trackerMode, canvas) + , m_data(nullptr) { } //! Destructor -QwtPolarPicker::~QwtPolarPicker() +QwtPolarPicker::~QwtPolarPicker() {} + +//! \return Observed plot canvas +QwtPolarCanvas *QwtPolarPicker::canvas() { + return qobject_cast(parentWidget()); } //! \return Observed plot canvas -QwtPolarCanvas* QwtPolarPicker::canvas() +const QwtPolarCanvas *QwtPolarPicker::canvas() const { - return qobject_cast< QwtPolarCanvas* >( parentWidget() ); -} - -//! \return Observed plot canvas -const QwtPolarCanvas* QwtPolarPicker::canvas() const -{ - return qobject_cast< const QwtPolarCanvas* >( parentWidget() ); + return qobject_cast(parentWidget()); } //! \return Plot widget, containing the observed plot canvas -QwtPolarPlot* QwtPolarPicker::plot() +QwtPolarPlot *QwtPolarPicker::plot() { - QwtPolarCanvas* w = canvas(); - if ( w ) - return w->plot(); + QwtPolarCanvas *w = canvas(); + if (w) + return w->plot(); - return NULL; + return NULL; } //! \return Plot widget, containing the observed plot canvas -const QwtPolarPlot* QwtPolarPicker::plot() const +const QwtPolarPlot *QwtPolarPicker::plot() const { - const QwtPolarCanvas* w = canvas(); - if ( w ) - return w->plot(); + const QwtPolarCanvas *w = canvas(); + if (w) + return w->plot(); - return NULL; + return NULL; } /*! @@ -91,10 +89,10 @@ const QwtPolarPlot* QwtPolarPicker::plot() const \param pos Position in pixel coordinates \return Position string */ -QwtText QwtPolarPicker::trackerText( const QPoint& pos ) const +QwtText QwtPolarPicker::trackerText(const QPoint &pos) const { - const QwtPointPolar polarPoint = invTransform( pos ); - return trackerTextPolar( polarPoint ); + const QwtPointPolar polarPoint = invTransform(pos); + return trackerTextPolar(polarPoint); } /*! @@ -109,12 +107,12 @@ QwtText QwtPolarPicker::trackerText( const QPoint& pos ) const \param pos Position \return Position string */ -QwtText QwtPolarPicker::trackerTextPolar( const QwtPointPolar& pos ) const +QwtText QwtPolarPicker::trackerTextPolar(const QwtPointPolar &pos) const { - const QString text = QString::number( pos.radius(), 'f', 4 ) - + ", " + QString::number( pos.azimuth(), 'f', 4 ); + const QString text = QString::number(pos.radius(), 'f', 4) + ", " + + QString::number(pos.azimuth(), 'f', 4); - return QwtText( text ); + return QwtText(text); } /*! @@ -126,10 +124,10 @@ QwtText QwtPolarPicker::trackerTextPolar( const QwtPointPolar& pos ) const \note The appended(const QPoint &), appended(const QDoublePoint &) signals are emitted. */ -void QwtPolarPicker::append( const QPoint& pos ) +void QwtPolarPicker::append(const QPoint &pos) { - QwtPicker::append( pos ); - Q_EMIT appended( invTransform( pos ) ); + QwtPicker::append(pos); + Q_EMIT appended(invTransform(pos)); } /*! @@ -141,10 +139,10 @@ void QwtPolarPicker::append( const QPoint& pos ) \note The moved(const QPoint &), moved(const QDoublePoint &) signals are emitted. */ -void QwtPolarPicker::move( const QPoint& pos ) +void QwtPolarPicker::move(const QPoint &pos) { - QwtPicker::move( pos ); - Q_EMIT moved( invTransform( pos ) ); + QwtPicker::move(pos); + Q_EMIT moved(invTransform(pos)); } /*! @@ -155,48 +153,45 @@ void QwtPolarPicker::move( const QPoint& pos ) \return true if the selection is accepted, false otherwise */ -bool QwtPolarPicker::end( bool ok ) +bool QwtPolarPicker::end(bool ok) { - ok = QwtPicker::end( ok ); - if ( !ok ) - return false; + ok = QwtPicker::end(ok); + if (!ok) + return false; - QwtPolarPlot* plot = QwtPolarPicker::plot(); - if ( !plot ) - return false; + QwtPolarPlot *plot = QwtPolarPicker::plot(); + if (!plot) + return false; - const QPolygon points = selection(); - if ( points.count() == 0 ) - return false; + const QPolygon points = selection(); + if (points.count() == 0) + return false; - QwtPickerMachine::SelectionType selectionType = - QwtPickerMachine::NoSelection; + QwtPickerMachine::SelectionType selectionType = QwtPickerMachine::NoSelection; - if ( stateMachine() ) - selectionType = stateMachine()->selectionType(); + if (stateMachine()) + selectionType = stateMachine()->selectionType(); - switch ( selectionType ) - { - case QwtPickerMachine::PointSelection: - { - const QwtPointPolar pos = invTransform( points[0] ); - Q_EMIT selected( pos ); - break; - } - case QwtPickerMachine::RectSelection: - case QwtPickerMachine::PolygonSelection: - { - QVector< QwtPointPolar > polarPoints( points.count() ); - for ( int i = 0; i < points.count(); i++ ) - polarPoints[i] = invTransform( points[i] ); - - Q_EMIT selected( polarPoints ); - } - default: - break; + switch (selectionType) + { + case QwtPickerMachine::PointSelection: { + const QwtPointPolar pos = invTransform(points[0]); + Q_EMIT selected(pos); + break; } + case QwtPickerMachine::RectSelection: + case QwtPickerMachine::PolygonSelection: { + QVector polarPoints(points.count()); + for (int i = 0; i < points.count(); i++) + polarPoints[i] = invTransform(points[i]); - return true; + Q_EMIT selected(polarPoints); + } + default: + break; + } + + return true; } /*! @@ -206,13 +201,13 @@ bool QwtPolarPicker::end( bool ok ) \return Point in plot coordinates \sa transform(), canvas() */ -QwtPointPolar QwtPolarPicker::invTransform( const QPoint& pos ) const +QwtPointPolar QwtPolarPicker::invTransform(const QPoint &pos) const { - QwtPointPolar polarPos; - if ( canvas() == NULL ) - return QwtPointPolar(); + QwtPointPolar polarPos; + if (canvas() == NULL) + return QwtPointPolar(); - return canvas()->invTransform( pos ); + return canvas()->invTransform(pos); } /*! @@ -221,25 +216,25 @@ QwtPointPolar QwtPolarPicker::invTransform( const QPoint& pos ) const */ QRect QwtPolarPicker::pickRect() const { - const QRect cr = canvas()->contentsRect(); - const QRect pr = plot()->plotRect( cr ).toRect(); + const QRect cr = canvas()->contentsRect(); + const QRect pr = plot()->plotRect(cr).toRect(); - return cr & pr; + return cr & pr; } QPainterPath QwtPolarPicker::pickArea() const { - const QRect cr = canvas()->contentsRect(); + const QRect cr = canvas()->contentsRect(); - QPainterPath crPath; - crPath.addRect( cr ); + QPainterPath crPath; + crPath.addRect(cr); - QPainterPath prPath; - prPath.addEllipse( plot()->plotRect( cr ) ); + QPainterPath prPath; + prPath.addEllipse(plot()->plotRect(cr)); - return crPath.intersected( prPath ); + return crPath.intersected(prPath); } #if QWT_MOC_INCLUDE -#include "moc_qwt_polar_picker.cpp" +# include "moc_qwt_polar_picker.cpp" #endif diff --git a/libs/qwt/src/qwt_polar_picker.h b/libs/qwt/src/qwt_polar_picker.h index 27c734d1..9c377e3f 100644 --- a/libs/qwt/src/qwt_polar_picker.h +++ b/libs/qwt/src/qwt_polar_picker.h @@ -27,72 +27,71 @@ class QwtPointPolar; */ class QWT_EXPORT QwtPolarPicker : public QwtPicker { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPolarPicker( QwtPolarCanvas* ); - virtual ~QwtPolarPicker(); +public: + explicit QwtPolarPicker(QwtPolarCanvas *); + virtual ~QwtPolarPicker(); - explicit QwtPolarPicker( - RubberBand rubberBand, DisplayMode trackerMode, - QwtPolarCanvas* ); + explicit QwtPolarPicker(RubberBand rubberBand, DisplayMode trackerMode, + QwtPolarCanvas *); - QwtPolarPlot* plot(); - const QwtPolarPlot* plot() const; + QwtPolarPlot *plot(); + const QwtPolarPlot *plot() const; - QwtPolarCanvas* canvas(); - const QwtPolarCanvas* canvas() const; + QwtPolarCanvas *canvas(); + const QwtPolarCanvas *canvas() const; - virtual QRect pickRect() const; + virtual QRect pickRect() const; - Q_SIGNALS: +Q_SIGNALS: - /*! - A signal emitted in case of selectionFlags() & PointSelection. - \param pos Selected point - */ - void selected( const QwtPointPolar& pos ); + /*! + A signal emitted in case of selectionFlags() & PointSelection. + \param pos Selected point + */ + void selected(const QwtPointPolar &pos); - /*! - A signal emitting the selected points, - at the end of a selection. + /*! + A signal emitting the selected points, + at the end of a selection. - \param points Selected points - */ - void selected( const QVector< QwtPointPolar >& points ); + \param points Selected points + */ + void selected(const QVector &points); - /*! - A signal emitted when a point has been appended to the selection + /*! + A signal emitted when a point has been appended to the selection - \param pos Position of the appended point. - \sa append(). moved() - */ - void appended( const QwtPointPolar& pos ); + \param pos Position of the appended point. + \sa append(). moved() + */ + void appended(const QwtPointPolar &pos); - /*! - A signal emitted whenever the last appended point of the - selection has been moved. + /*! + A signal emitted whenever the last appended point of the + selection has been moved. - \param pos Position of the moved last point of the selection. - \sa move(), appended() - */ - void moved( const QwtPointPolar& pos ); + \param pos Position of the moved last point of the selection. + \sa move(), appended() + */ + void moved(const QwtPointPolar &pos); - protected: - QwtPointPolar invTransform( const QPoint& ) const; +protected: + QwtPointPolar invTransform(const QPoint &) const; - virtual QwtText trackerText( const QPoint& ) const QWT_OVERRIDE; - virtual QwtText trackerTextPolar( const QwtPointPolar& ) const; + virtual QwtText trackerText(const QPoint &) const QWT_OVERRIDE; + virtual QwtText trackerTextPolar(const QwtPointPolar &) const; - virtual void move( const QPoint& ) QWT_OVERRIDE; - virtual void append( const QPoint& ) QWT_OVERRIDE; - virtual bool end( bool ok = true ) QWT_OVERRIDE; + virtual void move(const QPoint &) QWT_OVERRIDE; + virtual void append(const QPoint &) QWT_OVERRIDE; + virtual bool end(bool ok = true) QWT_OVERRIDE; - private: - virtual QPainterPath pickArea() const QWT_OVERRIDE; +private: + virtual QPainterPath pickArea() const QWT_OVERRIDE; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_plot.cpp b/libs/qwt/src/qwt_polar_plot.cpp index 41bdf6c2..39a468dc 100644 --- a/libs/qwt/src/qwt_polar_plot.cpp +++ b/libs/qwt/src/qwt_polar_plot.cpp @@ -22,73 +22,69 @@ #include #include -static inline double qwtDistance( - const QPointF& p1, const QPointF& p2 ) +static inline double qwtDistance(const QPointF &p1, const QPointF &p2) { - double dx = p2.x() - p1.x(); - double dy = p2.y() - p1.y(); - return qSqrt( dx * dx + dy * dy ); + double dx = p2.x() - p1.x(); + double dy = p2.y() - p1.y(); + return qSqrt(dx * dx + dy * dy); } namespace QwtPolarPlotPrivate { - class ScaleData - { - public: - ScaleData() - : isValid( false ) - , scaleEngine( NULL ) - { - } +class ScaleData +{ +public: + ScaleData() + : isValid(false) + , scaleEngine(NULL) + { + } - ~ScaleData() - { - delete scaleEngine; - } + ~ScaleData() { delete scaleEngine; } - bool doAutoScale; + bool doAutoScale; - double minValue; - double maxValue; - double stepSize; + double minValue; + double maxValue; + double stepSize; - int maxMajor; - int maxMinor; + int maxMajor; + int maxMinor; - bool isValid; + bool isValid; - QwtScaleDiv scaleDiv; - QwtScaleEngine* scaleEngine; - }; -} + QwtScaleDiv scaleDiv; + QwtScaleEngine *scaleEngine; +}; +} // namespace QwtPolarPlotPrivate class QwtPolarPlot::PrivateData { - public: - QBrush canvasBrush; +public: + QBrush canvasBrush; - bool autoReplot; + bool autoReplot; - QwtPointPolar zoomPos; - double zoomFactor; + QwtPointPolar zoomPos; + double zoomFactor; - QwtPolarPlotPrivate::ScaleData scaleData[QwtPolar::ScaleCount]; - QPointer< QwtTextLabel > titleLabel; - QPointer< QwtPolarCanvas > canvas; - QPointer< QwtAbstractLegend > legend; - double azimuthOrigin; + QwtPolarPlotPrivate::ScaleData scaleData[QwtPolar::ScaleCount]; + QPointer titleLabel; + QPointer canvas; + QPointer legend; + double azimuthOrigin; - QwtPolarLayout* layout; + QwtPolarLayout *layout; }; /*! Constructor \param parent Parent widget */ -QwtPolarPlot::QwtPolarPlot( QWidget* parent ) - : QFrame( parent ) +QwtPolarPlot::QwtPolarPlot(QWidget *parent) + : QFrame(parent) { - initPlot( QwtText() ); + initPlot(QwtText()); } /*! @@ -96,78 +92,78 @@ QwtPolarPlot::QwtPolarPlot( QWidget* parent ) \param title Title text \param parent Parent widget */ -QwtPolarPlot::QwtPolarPlot( const QwtText& title, QWidget* parent ) - : QFrame( parent ) +QwtPolarPlot::QwtPolarPlot(const QwtText &title, QWidget *parent) + : QFrame(parent) { - initPlot( title ); + initPlot(title); } //! Destructor QwtPolarPlot::~QwtPolarPlot() { - detachItems( QwtPolarItem::Rtti_PolarItem, autoDelete() ); + detachItems(QwtPolarItem::Rtti_PolarItem, autoDelete()); - delete m_data->layout; - delete m_data; + delete m_data->layout; + delete m_data; } /*! Change the plot's title \param title New title */ -void QwtPolarPlot::setTitle( const QString& title ) +void QwtPolarPlot::setTitle(const QString &title) { - if ( title != m_data->titleLabel->text().text() ) - { - m_data->titleLabel->setText( title ); - if ( !title.isEmpty() ) - m_data->titleLabel->show(); - else - m_data->titleLabel->hide(); - } + if (title != m_data->titleLabel->text().text()) + { + m_data->titleLabel->setText(title); + if (!title.isEmpty()) + m_data->titleLabel->show(); + else + m_data->titleLabel->hide(); + } } /*! Change the plot's title \param title New title */ -void QwtPolarPlot::setTitle( const QwtText& title ) +void QwtPolarPlot::setTitle(const QwtText &title) { - if ( title != m_data->titleLabel->text() ) - { - m_data->titleLabel->setText( title ); - if ( !title.isEmpty() ) - m_data->titleLabel->show(); - else - m_data->titleLabel->hide(); - } + if (title != m_data->titleLabel->text()) + { + m_data->titleLabel->setText(title); + if (!title.isEmpty()) + m_data->titleLabel->show(); + else + m_data->titleLabel->hide(); + } } //! \return the plot's title QwtText QwtPolarPlot::title() const { - return m_data->titleLabel->text(); + return m_data->titleLabel->text(); } //! \return the plot's title -QwtTextLabel* QwtPolarPlot::titleLabel() +QwtTextLabel *QwtPolarPlot::titleLabel() { - return m_data->titleLabel; + return m_data->titleLabel; } //! \return the plot's title label. -const QwtTextLabel* QwtPolarPlot::titleLabel() const +const QwtTextLabel *QwtPolarPlot::titleLabel() const { - return m_data->titleLabel; + return m_data->titleLabel; } /*! \brief Insert a legend - If the position legend is \c QwtPolarPlot::LeftLegend or \c QwtPolarPlot::RightLegend - the legend will be organized in one column from top to down. - Otherwise the legend items will be placed in a table - with a best fit number of columns from left to right. + If the position legend is \c QwtPolarPlot::LeftLegend or \c + QwtPolarPlot::RightLegend the legend will be organized in one column from top + to down. Otherwise the legend items will be placed in a table with a best fit + number of columns from left to right. If pos != QwtPolarPlot::ExternalLegend the plot widget will become parent of the legend. It will be deleted when the plot is deleted, @@ -188,60 +184,56 @@ const QwtTextLabel* QwtPolarPlot::titleLabel() const \sa legend(), QwtPolarLayout::legendPosition(), QwtPolarLayout::setLegendPosition() */ -void QwtPolarPlot::insertLegend( QwtAbstractLegend* legend, - QwtPolarPlot::LegendPosition pos, double ratio ) +void QwtPolarPlot::insertLegend(QwtAbstractLegend *legend, + QwtPolarPlot::LegendPosition pos, double ratio) { - m_data->layout->setLegendPosition( pos, ratio ); + m_data->layout->setLegendPosition(pos, ratio); - if ( legend != m_data->legend ) + if (legend != m_data->legend) + { + if (m_data->legend && m_data->legend->parent() == this) + delete m_data->legend; + + m_data->legend = legend; + + if (m_data->legend) { - if ( m_data->legend && m_data->legend->parent() == this ) - delete m_data->legend; + connect( + this, + SIGNAL(legendDataChanged(const QVariant &, + const QList &)), + m_data->legend, + SLOT(updateLegend(const QVariant &, const QList &))); - m_data->legend = legend; + if (m_data->legend->parent() != this) + m_data->legend->setParent(this); - if ( m_data->legend ) + updateLegend(); + + QwtLegend *lgd = qobject_cast(legend); + if (lgd) + { + switch (m_data->layout->legendPosition()) { - connect( this, - SIGNAL(legendDataChanged( - const QVariant&,const QList&)), - m_data->legend, - SLOT(updateLegend( - const QVariant&,const QList&)) - ); - - if ( m_data->legend->parent() != this ) - m_data->legend->setParent( this ); - - updateLegend(); - - QwtLegend* lgd = qobject_cast< QwtLegend* >( legend ); - if ( lgd ) - { - switch ( m_data->layout->legendPosition() ) - { - case LeftLegend: - case RightLegend: - { - if ( lgd->maxColumns() == 0 ) - lgd->setMaxColumns( 1 ); // 1 column: align vertical - break; - } - case TopLegend: - case BottomLegend: - { - lgd->setMaxColumns( 0 ); // unlimited - break; - } - default: - break; - } - } - + case LeftLegend: + case RightLegend: { + if (lgd->maxColumns() == 0) + lgd->setMaxColumns(1); // 1 column: align vertical + break; + } + case TopLegend: + case BottomLegend: { + lgd->setMaxColumns(0); // unlimited + break; + } + default: + break; } + } } + } - updateLayout(); + updateLayout(); } /*! @@ -251,12 +243,11 @@ void QwtPolarPlot::insertLegend( QwtAbstractLegend* legend, */ void QwtPolarPlot::updateLegend() { - const QwtPolarItemList& itmList = itemList(); - for ( QwtPolarItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - updateLegend( *it ); - } + const QwtPolarItemList &itmList = itemList(); + for (QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + updateLegend(*it); + } } /*! @@ -265,36 +256,36 @@ void QwtPolarPlot::updateLegend() \param plotItem Plot item \sa QwtPlotItem::legendData(), legendDataChanged() */ -void QwtPolarPlot::updateLegend( const QwtPolarItem* plotItem ) +void QwtPolarPlot::updateLegend(const QwtPolarItem *plotItem) { - if ( plotItem == NULL ) - return; + if (plotItem == NULL) + return; - QList< QwtLegendData > legendData; + QList legendData; - if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) ) - legendData = plotItem->legendData(); + if (plotItem->testItemAttribute(QwtPolarItem::Legend)) + legendData = plotItem->legendData(); - const QVariant itemInfo = itemToInfo( const_cast< QwtPolarItem* >( plotItem ) ); - Q_EMIT legendDataChanged( itemInfo, legendData ); + const QVariant itemInfo = itemToInfo(const_cast(plotItem)); + Q_EMIT legendDataChanged(itemInfo, legendData); } /*! \return the plot's legend \sa insertLegend() */ -QwtAbstractLegend* QwtPolarPlot::legend() +QwtAbstractLegend *QwtPolarPlot::legend() { - return m_data->legend; + return m_data->legend; } /*! \return the plot's legend \sa insertLegend() */ -const QwtAbstractLegend* QwtPolarPlot::legend() const +const QwtAbstractLegend *QwtPolarPlot::legend() const { - return m_data->legend; + return m_data->legend; } /*! @@ -306,22 +297,22 @@ const QwtAbstractLegend* QwtPolarPlot::legend() const \param brush Background Brush \sa plotBackground(), plotArea() */ -void QwtPolarPlot::setPlotBackground( const QBrush& brush ) +void QwtPolarPlot::setPlotBackground(const QBrush &brush) { - if ( brush != m_data->canvasBrush ) - { - m_data->canvasBrush = brush; - autoRefresh(); - } + if (brush != m_data->canvasBrush) + { + m_data->canvasBrush = brush; + autoRefresh(); + } } /*! \return plot background brush \sa plotBackground(), plotArea() */ -const QBrush& QwtPolarPlot::plotBackground() const +const QBrush &QwtPolarPlot::plotBackground() const { - return m_data->canvasBrush; + return m_data->canvasBrush; } /*! @@ -339,15 +330,15 @@ const QBrush& QwtPolarPlot::plotBackground() const \param enable \c true or \c false. Defaults to \c true. \sa replot() */ -void QwtPolarPlot::setAutoReplot( bool enable ) +void QwtPolarPlot::setAutoReplot(bool enable) { - m_data->autoReplot = enable; + m_data->autoReplot = enable; } //! \return true if the autoReplot option is set. bool QwtPolarPlot::autoReplot() const { - return m_data->autoReplot; + return m_data->autoReplot; } /*! @@ -365,17 +356,17 @@ bool QwtPolarPlot::autoReplot() const \sa hasAutoScale(), setScale(), setScaleDiv(), QwtPolarItem::boundingInterval() */ -void QwtPolarPlot::setAutoScale( int scaleId ) +void QwtPolarPlot::setAutoScale(int scaleId) { - if ( scaleId != QwtPolar::ScaleRadius ) - return; + if (scaleId != QwtPolar::ScaleRadius) + return; - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; - if ( !scaleData.doAutoScale ) - { - scaleData.doAutoScale = true; - autoRefresh(); - } + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; + if (!scaleData.doAutoScale) + { + scaleData.doAutoScale = true; + autoRefresh(); + } } /*! @@ -383,12 +374,12 @@ void QwtPolarPlot::setAutoScale( int scaleId ) \param scaleId Scale index \sa setAutoScale() */ -bool QwtPolarPlot::hasAutoScale( int scaleId ) const +bool QwtPolarPlot::hasAutoScale(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return false; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return false; - return m_data->scaleData[scaleId].doAutoScale; + return m_data->scaleData[scaleId].doAutoScale; } /*! @@ -398,21 +389,21 @@ bool QwtPolarPlot::hasAutoScale( int scaleId ) const \param maxMinor maximum number of minor steps \sa scaleMaxMajor() */ -void QwtPolarPlot::setScaleMaxMinor( int scaleId, int maxMinor ) +void QwtPolarPlot::setScaleMaxMinor(int scaleId, int maxMinor) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - maxMinor = qBound( 0, maxMinor, 100 ); + maxMinor = qBound(0, maxMinor, 100); - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; - if ( maxMinor != scaleData.maxMinor ) - { - scaleData.maxMinor = maxMinor; - scaleData.isValid = false; - autoRefresh(); - } + if (maxMinor != scaleData.maxMinor) + { + scaleData.maxMinor = maxMinor; + scaleData.isValid = false; + autoRefresh(); + } } /*! @@ -420,12 +411,12 @@ void QwtPolarPlot::setScaleMaxMinor( int scaleId, int maxMinor ) \param scaleId Scale index \sa setScaleMaxMinor() */ -int QwtPolarPlot::scaleMaxMinor( int scaleId ) const +int QwtPolarPlot::scaleMaxMinor(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return 0; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return 0; - return m_data->scaleData[scaleId].maxMinor; + return m_data->scaleData[scaleId].maxMinor; } /*! @@ -435,20 +426,20 @@ int QwtPolarPlot::scaleMaxMinor( int scaleId ) const \param maxMajor maximum number of major steps \sa scaleMaxMajor() */ -void QwtPolarPlot::setScaleMaxMajor( int scaleId, int maxMajor ) +void QwtPolarPlot::setScaleMaxMajor(int scaleId, int maxMajor) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - maxMajor = qBound( 1, maxMajor, 10000 ); + maxMajor = qBound(1, maxMajor, 10000); - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; - if ( maxMajor != scaleData.maxMinor ) - { - scaleData.maxMajor = maxMajor; - scaleData.isValid = false; - autoRefresh(); - } + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; + if (maxMajor != scaleData.maxMinor) + { + scaleData.maxMajor = maxMajor; + scaleData.isValid = false; + autoRefresh(); + } } /*! @@ -457,12 +448,12 @@ void QwtPolarPlot::setScaleMaxMajor( int scaleId, int maxMajor ) \sa setScaleMaxMajor() */ -int QwtPolarPlot::scaleMaxMajor( int scaleId ) const +int QwtPolarPlot::scaleMaxMajor(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return 0; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return 0; - return m_data->scaleData[scaleId].maxMajor; + return m_data->scaleData[scaleId].maxMajor; } /*! @@ -473,21 +464,21 @@ int QwtPolarPlot::scaleMaxMajor( int scaleId ) const \sa axisScaleEngine() */ -void QwtPolarPlot::setScaleEngine( int scaleId, QwtScaleEngine* scaleEngine ) +void QwtPolarPlot::setScaleEngine(int scaleId, QwtScaleEngine *scaleEngine) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; - if ( scaleEngine == NULL || scaleEngine == scaleData.scaleEngine ) - return; + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; + if (scaleEngine == NULL || scaleEngine == scaleData.scaleEngine) + return; - delete scaleData.scaleEngine; - scaleData.scaleEngine = scaleEngine; + delete scaleData.scaleEngine; + scaleData.scaleEngine = scaleEngine; - scaleData.isValid = false; + scaleData.isValid = false; - autoRefresh(); + autoRefresh(); } /*! @@ -496,12 +487,12 @@ void QwtPolarPlot::setScaleEngine( int scaleId, QwtScaleEngine* scaleEngine ) \param scaleId Scale index \sa setScaleEngine() */ -QwtScaleEngine* QwtPolarPlot::scaleEngine( int scaleId ) +QwtScaleEngine *QwtPolarPlot::scaleEngine(int scaleId) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return NULL; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return NULL; - return m_data->scaleData[scaleId].scaleEngine; + return m_data->scaleData[scaleId].scaleEngine; } /*! @@ -510,12 +501,12 @@ QwtScaleEngine* QwtPolarPlot::scaleEngine( int scaleId ) \param scaleId Scale index \sa setScaleEngine() */ -const QwtScaleEngine* QwtPolarPlot::scaleEngine( int scaleId ) const +const QwtScaleEngine *QwtPolarPlot::scaleEngine(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return NULL; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return NULL; - return m_data->scaleData[scaleId].scaleEngine; + return m_data->scaleData[scaleId].scaleEngine; } /*! @@ -527,22 +518,22 @@ const QwtScaleEngine* QwtPolarPlot::scaleEngine( int scaleId ) const calculated automatically using the maxMajor setting. \sa setScaleMaxMajor(), setAutoScale() */ -void QwtPolarPlot::setScale( int scaleId, - double min, double max, double stepSize ) +void QwtPolarPlot::setScale(int scaleId, double min, double max, + double stepSize) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; - scaleData.isValid = false; + scaleData.isValid = false; - scaleData.minValue = min; - scaleData.maxValue = max; - scaleData.stepSize = stepSize; - scaleData.doAutoScale = false; + scaleData.minValue = min; + scaleData.maxValue = max; + scaleData.stepSize = stepSize; + scaleData.doAutoScale = false; - autoRefresh(); + autoRefresh(); } /*! @@ -551,18 +542,18 @@ void QwtPolarPlot::setScale( int scaleId, \param scaleDiv Scale division \sa setScale(), setAutoScale() */ -void QwtPolarPlot::setScaleDiv( int scaleId, const QwtScaleDiv& scaleDiv ) +void QwtPolarPlot::setScaleDiv(int scaleId, const QwtScaleDiv &scaleDiv) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; - scaleData.scaleDiv = scaleDiv; - scaleData.isValid = true; - scaleData.doAutoScale = false; + scaleData.scaleDiv = scaleDiv; + scaleData.isValid = true; + scaleData.doAutoScale = false; - autoRefresh(); + autoRefresh(); } /*! @@ -576,12 +567,12 @@ void QwtPolarPlot::setScaleDiv( int scaleId, const QwtScaleDiv& scaleDiv ) \sa QwtScaleDiv, setScaleDiv(), setScale() */ -const QwtScaleDiv* QwtPolarPlot::scaleDiv( int scaleId ) const +const QwtScaleDiv *QwtPolarPlot::scaleDiv(int scaleId) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return NULL; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return NULL; - return &m_data->scaleData[scaleId].scaleDiv; + return &m_data->scaleData[scaleId].scaleDiv; } /*! @@ -595,12 +586,12 @@ const QwtScaleDiv* QwtPolarPlot::scaleDiv( int scaleId ) const \sa QwtScaleDiv, setScaleDiv(), setScale() */ -QwtScaleDiv* QwtPolarPlot::scaleDiv( int scaleId ) +QwtScaleDiv *QwtPolarPlot::scaleDiv(int scaleId) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return NULL; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return NULL; - return &m_data->scaleData[scaleId].scaleDiv; + return &m_data->scaleData[scaleId].scaleDiv; } /*! @@ -612,14 +603,14 @@ QwtScaleDiv* QwtPolarPlot::scaleDiv( int scaleId ) \param origin New origin \sa azimuthOrigin() */ -void QwtPolarPlot::setAzimuthOrigin( double origin ) +void QwtPolarPlot::setAzimuthOrigin(double origin) { - origin = ::fmod( origin, 2 * M_PI ); - if ( origin != m_data->azimuthOrigin ) - { - m_data->azimuthOrigin = origin; - autoRefresh(); - } + origin = ::fmod(origin, 2 * M_PI); + if (origin != m_data->azimuthOrigin) + { + m_data->azimuthOrigin = origin; + autoRefresh(); + } } /*! @@ -631,7 +622,7 @@ void QwtPolarPlot::setAzimuthOrigin( double origin ) */ double QwtPolarPlot::azimuthOrigin() const { - return m_data->azimuthOrigin; + return m_data->azimuthOrigin; } /*! @@ -648,17 +639,16 @@ double QwtPolarPlot::azimuthOrigin() const \sa unzoom(), zoomPos(), zoomFactor() */ -void QwtPolarPlot::zoom( const QwtPointPolar& zoomPos, double zoomFactor ) +void QwtPolarPlot::zoom(const QwtPointPolar &zoomPos, double zoomFactor) { - zoomFactor = qAbs( zoomFactor ); - if ( zoomPos != m_data->zoomPos || - zoomFactor != m_data->zoomFactor ) - { - m_data->zoomPos = zoomPos; - m_data->zoomFactor = zoomFactor; - updateLayout(); - autoRefresh(); - } + zoomFactor = qAbs(zoomFactor); + if (zoomPos != m_data->zoomPos || zoomFactor != m_data->zoomFactor) + { + m_data->zoomPos = zoomPos; + m_data->zoomFactor = zoomFactor; + updateLayout(); + autoRefresh(); + } } /*! @@ -667,12 +657,12 @@ void QwtPolarPlot::zoom( const QwtPointPolar& zoomPos, double zoomFactor ) */ void QwtPolarPlot::unzoom() { - if ( m_data->zoomFactor != 1.0 || m_data->zoomPos.isValid() ) - { - m_data->zoomFactor = 1.0; - m_data->zoomPos = QwtPointPolar(); - autoRefresh(); - } + if (m_data->zoomFactor != 1.0 || m_data->zoomPos.isValid()) + { + m_data->zoomFactor = 1.0; + m_data->zoomPos = QwtPointPolar(); + autoRefresh(); + } } /*! @@ -681,7 +671,7 @@ void QwtPolarPlot::unzoom() */ QwtPointPolar QwtPolarPlot::zoomPos() const { - return m_data->zoomPos; + return m_data->zoomPos; } /*! @@ -690,7 +680,7 @@ QwtPointPolar QwtPolarPlot::zoomPos() const */ double QwtPolarPlot::zoomFactor() const { - return m_data->zoomFactor; + return m_data->zoomFactor; } /*! @@ -707,10 +697,10 @@ double QwtPolarPlot::zoomFactor() const \sa QwtScaleMap, transform(), invTransform() */ -QwtScaleMap QwtPolarPlot::scaleMap( int scaleId ) const +QwtScaleMap QwtPolarPlot::scaleMap(int scaleId) const { - const QRectF pr = plotRect(); - return scaleMap( scaleId, pr.width() / 2.0 ); + const QRectF pr = plotRect(); + return scaleMap(scaleId, pr.width() / 2.0); } /*! @@ -727,28 +717,28 @@ QwtScaleMap QwtPolarPlot::scaleMap( int scaleId ) const \sa QwtScaleMap, transform(), invTransform() */ -QwtScaleMap QwtPolarPlot::scaleMap( int scaleId, const double radius ) const +QwtScaleMap QwtPolarPlot::scaleMap(int scaleId, const double radius) const { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return QwtScaleMap(); + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return QwtScaleMap(); - QwtScaleMap map; - map.setTransformation( scaleEngine( scaleId )->transformation() ); + QwtScaleMap map; + map.setTransformation(scaleEngine(scaleId)->transformation()); - const QwtScaleDiv* sd = scaleDiv( scaleId ); - map.setScaleInterval( sd->lowerBound(), sd->upperBound() ); + const QwtScaleDiv *sd = scaleDiv(scaleId); + map.setScaleInterval(sd->lowerBound(), sd->upperBound()); - if ( scaleId == QwtPolar::Azimuth ) - { - map.setPaintInterval( m_data->azimuthOrigin, - m_data->azimuthOrigin + 2 * M_PI ); - } - else - { - map.setPaintInterval( 0.0, radius ); - } + if (scaleId == QwtPolar::Azimuth) + { + map.setPaintInterval(m_data->azimuthOrigin, + m_data->azimuthOrigin + 2 * M_PI); + } + else + { + map.setPaintInterval(0.0, radius); + } - return map; + return map; } /*! @@ -759,131 +749,128 @@ QwtScaleMap QwtPolarPlot::scaleMap( int scaleId, const double radius ) const \param e Qt Event \return True, when the event was processed */ -bool QwtPolarPlot::event( QEvent* e ) +bool QwtPolarPlot::event(QEvent *e) { - bool ok = QWidget::event( e ); - switch( e->type() ) - { - case QEvent::LayoutRequest: - { - updateLayout(); - break; - } - case QEvent::PolishRequest: - { - updateLayout(); - replot(); - break; - } - default:; + bool ok = QWidget::event(e); + switch (e->type()) + { + case QEvent::LayoutRequest: { + updateLayout(); + break; } - return ok; + case QEvent::PolishRequest: { + updateLayout(); + replot(); + break; + } + default:; + } + return ok; } //! Resize and update internal layout -void QwtPolarPlot::resizeEvent( QResizeEvent* e ) +void QwtPolarPlot::resizeEvent(QResizeEvent *e) { - QFrame::resizeEvent( e ); - updateLayout(); + QFrame::resizeEvent(e); + updateLayout(); } -void QwtPolarPlot::initPlot( const QwtText& title ) +void QwtPolarPlot::initPlot(const QwtText &title) { - m_data = new PrivateData; - m_data->layout = new QwtPolarLayout; + m_data = new PrivateData; + m_data->layout = new QwtPolarLayout; - QwtText text( title ); - text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap ); + QwtText text(title); + text.setRenderFlags(Qt::AlignCenter | Qt::TextWordWrap); - m_data->titleLabel = new QwtTextLabel( text, this ); - m_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) ); - if ( !text.isEmpty() ) - m_data->titleLabel->show(); - else - m_data->titleLabel->hide(); + m_data->titleLabel = new QwtTextLabel(text, this); + m_data->titleLabel->setFont(QFont(fontInfo().family(), 14, QFont::Bold)); + if (!text.isEmpty()) + m_data->titleLabel->show(); + else + m_data->titleLabel->hide(); - m_data->canvas = new QwtPolarCanvas( this ); + m_data->canvas = new QwtPolarCanvas(this); - m_data->autoReplot = false; - m_data->canvasBrush = QBrush( Qt::white ); + m_data->autoReplot = false; + m_data->canvasBrush = QBrush(Qt::white); - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + { + QwtPolarPlotPrivate::ScaleData &scaleData = m_data->scaleData[scaleId]; + + if (scaleId == QwtPolar::Azimuth) { - QwtPolarPlotPrivate::ScaleData& scaleData = m_data->scaleData[scaleId]; - - if ( scaleId == QwtPolar::Azimuth ) - { - scaleData.minValue = 0.0; - scaleData.maxValue = 360.0; - scaleData.stepSize = 30.0; - } - else - { - scaleData.minValue = 0.0; - scaleData.maxValue = 1000.0; - scaleData.stepSize = 0.0; - } - - scaleData.doAutoScale = true; - - scaleData.maxMinor = 5; - scaleData.maxMajor = 8; - - scaleData.isValid = false; - - scaleData.scaleEngine = new QwtLinearScaleEngine; + scaleData.minValue = 0.0; + scaleData.maxValue = 360.0; + scaleData.stepSize = 30.0; + } + else + { + scaleData.minValue = 0.0; + scaleData.maxValue = 1000.0; + scaleData.stepSize = 0.0; } - m_data->zoomFactor = 1.0; - m_data->azimuthOrigin = 0.0; - setSizePolicy( QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding ); + scaleData.doAutoScale = true; - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) - updateScale( scaleId ); + scaleData.maxMinor = 5; + scaleData.maxMajor = 8; + + scaleData.isValid = false; + + scaleData.scaleEngine = new QwtLinearScaleEngine; + } + m_data->zoomFactor = 1.0; + m_data->azimuthOrigin = 0.0; + + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + updateScale(scaleId); } //! Replots the plot if QwtPlot::autoReplot() is \c true. void QwtPolarPlot::autoRefresh() { - if ( m_data->autoReplot ) - replot(); + if (m_data->autoReplot) + replot(); } //! Rebuild the layout void QwtPolarPlot::updateLayout() { - m_data->layout->activate( this, contentsRect() ); + m_data->layout->activate(this, contentsRect()); - // resize and show the visible widgets - if ( m_data->titleLabel ) + // resize and show the visible widgets + if (m_data->titleLabel) + { + if (!m_data->titleLabel->text().isEmpty()) { - if ( !m_data->titleLabel->text().isEmpty() ) - { - m_data->titleLabel->setGeometry( m_data->layout->titleRect().toRect() ); - if ( !m_data->titleLabel->isVisible() ) - m_data->titleLabel->show(); - } - else - m_data->titleLabel->hide(); + m_data->titleLabel->setGeometry(m_data->layout->titleRect().toRect()); + if (!m_data->titleLabel->isVisible()) + m_data->titleLabel->show(); } + else + m_data->titleLabel->hide(); + } - if ( m_data->legend ) + if (m_data->legend) + { + if (m_data->legend->isEmpty()) { - if ( m_data->legend->isEmpty() ) - { - m_data->legend->hide(); - } - else - { - const QRectF legendRect = m_data->layout->legendRect(); - m_data->legend->setGeometry( legendRect.toRect() ); - m_data->legend->show(); - } + m_data->legend->hide(); } + else + { + const QRectF legendRect = m_data->layout->legendRect(); + m_data->legend->setGeometry(legendRect.toRect()); + m_data->legend->show(); + } + } - m_data->canvas->setGeometry( m_data->layout->canvasRect().toRect() ); - Q_EMIT layoutChanged(); + m_data->canvas->setGeometry(m_data->layout->canvasRect().toRect()); + Q_EMIT layoutChanged(); } /*! @@ -898,28 +885,28 @@ void QwtPolarPlot::updateLayout() */ void QwtPolarPlot::replot() { - bool doAutoReplot = autoReplot(); - setAutoReplot( false ); + bool doAutoReplot = autoReplot(); + setAutoReplot(false); - for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) - updateScale( scaleId ); + for (int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++) + updateScale(scaleId); - m_data->canvas->invalidateBackingStore(); - m_data->canvas->repaint(); + m_data->canvas->invalidateBackingStore(); + m_data->canvas->repaint(); - setAutoReplot( doAutoReplot ); + setAutoReplot(doAutoReplot); } //! \return the plot's canvas -QwtPolarCanvas* QwtPolarPlot::canvas() +QwtPolarCanvas *QwtPolarPlot::canvas() { - return m_data->canvas; + return m_data->canvas; } //! \return the plot's canvas -const QwtPolarCanvas* QwtPolarPlot::canvas() const +const QwtPolarCanvas *QwtPolarPlot::canvas() const { - return m_data->canvas; + return m_data->canvas; } /*! @@ -927,39 +914,37 @@ const QwtPolarCanvas* QwtPolarPlot::canvas() const \param painter Painter used for drawing \param canvasRect Contents rect of the canvas */ -void QwtPolarPlot::drawCanvas( QPainter* painter, - const QRectF& canvasRect ) const +void QwtPolarPlot::drawCanvas(QPainter *painter, const QRectF &canvasRect) const { - const QRectF cr = canvasRect; - const QRectF pr = plotRect( cr ); + const QRectF cr = canvasRect; + const QRectF pr = plotRect(cr); - const double radius = pr.width() / 2.0; + const double radius = pr.width() / 2.0; - if ( m_data->canvasBrush.style() != Qt::NoBrush ) + if (m_data->canvasBrush.style() != Qt::NoBrush) + { + painter->save(); + painter->setPen(Qt::NoPen); + painter->setBrush(m_data->canvasBrush); + + if (qwtDistance(pr.center(), cr.topLeft()) < radius + && qwtDistance(pr.center(), cr.topRight()) < radius + && qwtDistance(pr.center(), cr.bottomRight()) < radius + && qwtDistance(pr.center(), cr.bottomLeft()) < radius) { - painter->save(); - painter->setPen( Qt::NoPen ); - painter->setBrush( m_data->canvasBrush ); - - if ( qwtDistance( pr.center(), cr.topLeft() ) < radius && - qwtDistance( pr.center(), cr.topRight() ) < radius && - qwtDistance( pr.center(), cr.bottomRight() ) < radius && - qwtDistance( pr.center(), cr.bottomLeft() ) < radius ) - { - QwtPainter::drawRect( painter, cr ); - } - else - { - painter->setRenderHint( QPainter::Antialiasing, true ); - QwtPainter::drawEllipse( painter, pr ); - } - painter->restore(); + QwtPainter::drawRect(painter, cr); } + else + { + painter->setRenderHint(QPainter::Antialiasing, true); + QwtPainter::drawEllipse(painter, pr); + } + painter->restore(); + } - drawItems( painter, - scaleMap( QwtPolar::Azimuth, radius ), - scaleMap( QwtPolar::Radius, radius ), - pr.center(), radius, canvasRect ); + drawItems(painter, scaleMap(QwtPolar::Azimuth, radius), + scaleMap(QwtPolar::Radius, radius), pr.center(), radius, + canvasRect); } /*! @@ -972,64 +957,60 @@ void QwtPolarPlot::drawCanvas( QPainter* painter, \param radius Radius of the complete plot area in painter coordinates \param canvasRect Contents rect of the canvas in painter coordinates */ -void QwtPolarPlot::drawItems( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const +void QwtPolarPlot::drawItems(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const { - const QRectF pr = plotRect( canvasRect ); + const QRectF pr = plotRect(canvasRect); - const QwtPolarItemList& itmList = itemList(); - for ( QwtPolarItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) + const QwtPolarItemList &itmList = itemList(); + for (QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + QwtPolarItem *item = *it; + if (item && item->isVisible()) { - QwtPolarItem* item = *it; - if ( item && item->isVisible() ) + painter->save(); + + // Unfortunately circular clipping slows down + // painting a lot. So we better try to avoid it. + + bool doClipping = false; + if (item->rtti() != QwtPolarItem::Rtti_PolarGrid) + { + const QwtInterval intv = item->boundingInterval(QwtPolar::Radius); + + if (!intv.isValid()) + doClipping = true; + else { - painter->save(); - - // Unfortunately circular clipping slows down - // painting a lot. So we better try to avoid it. - - bool doClipping = false; - if ( item->rtti() != QwtPolarItem::Rtti_PolarGrid ) - { - const QwtInterval intv = - item->boundingInterval( QwtPolar::Radius ); - - if ( !intv.isValid() ) - doClipping = true; - else - { - if ( radialMap.s1() < radialMap.s2() ) - doClipping = intv.maxValue() > radialMap.s2(); - else - doClipping = intv.minValue() < radialMap.s2(); - } - } - - if ( doClipping ) - { - const int margin = item->marginHint(); - - const QRectF clipRect = pr.adjusted( - -margin, -margin, margin, margin ); - if ( !clipRect.contains( canvasRect ) ) - { - QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse ); - painter->setClipRegion( clipRegion, Qt::IntersectClip ); - } - } - - painter->setRenderHint( QPainter::Antialiasing, - item->testRenderHint( QwtPolarItem::RenderAntialiased ) ); - - item->draw( painter, azimuthMap, radialMap, - pole, radius, canvasRect ); - - painter->restore(); + if (radialMap.s1() < radialMap.s2()) + doClipping = intv.maxValue() > radialMap.s2(); + else + doClipping = intv.minValue() < radialMap.s2(); } + } + + if (doClipping) + { + const int margin = item->marginHint(); + + const QRectF clipRect = pr.adjusted(-margin, -margin, margin, margin); + if (!clipRect.contains(canvasRect)) + { + QRegion clipRegion(clipRect.toRect(), QRegion::Ellipse); + painter->setClipRegion(clipRegion, Qt::IntersectClip); + } + } + + painter->setRenderHint( + QPainter::Antialiasing, + item->testRenderHint(QwtPolarItem::RenderAntialiased)); + + item->draw(painter, azimuthMap, radialMap, pole, radius, canvasRect); + + painter->restore(); } + } } /*! @@ -1037,55 +1018,52 @@ void QwtPolarPlot::drawItems( QPainter* painter, \param scaleId Scale index */ -void QwtPolarPlot::updateScale( int scaleId ) +void QwtPolarPlot::updateScale(int scaleId) { - if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount ) - return; + if (scaleId < 0 || scaleId >= QwtPolar::ScaleCount) + return; - QwtPolarPlotPrivate::ScaleData& d = m_data->scaleData[scaleId]; + QwtPolarPlotPrivate::ScaleData &d = m_data->scaleData[scaleId]; - double minValue = d.minValue; - double maxValue = d.maxValue; - double stepSize = d.stepSize; + double minValue = d.minValue; + double maxValue = d.maxValue; + double stepSize = d.stepSize; - if ( scaleId == QwtPolar::ScaleRadius && d.doAutoScale ) + if (scaleId == QwtPolar::ScaleRadius && d.doAutoScale) + { + QwtInterval interval; + + const QwtPolarItemList &itmList = itemList(); + for (QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it) { - QwtInterval interval; - - const QwtPolarItemList& itmList = itemList(); - for ( QwtPolarItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - const QwtPolarItem* item = *it; - if ( item->testItemAttribute( QwtPolarItem::AutoScale ) ) - interval |= item->boundingInterval( scaleId ); - } - - minValue = interval.minValue(); - maxValue = interval.maxValue(); - - d.scaleEngine->autoScale( d.maxMajor, - minValue, maxValue, stepSize ); - d.isValid = false; + const QwtPolarItem *item = *it; + if (item->testItemAttribute(QwtPolarItem::AutoScale)) + interval |= item->boundingInterval(scaleId); } - if ( !d.isValid ) - { - d.scaleDiv = d.scaleEngine->divideScale( - minValue, maxValue, d.maxMajor, d.maxMinor, stepSize ); - d.isValid = true; - } + minValue = interval.minValue(); + maxValue = interval.maxValue(); - const QwtInterval interval = visibleInterval(); + d.scaleEngine->autoScale(d.maxMajor, minValue, maxValue, stepSize); + d.isValid = false; + } - const QwtPolarItemList& itmList = itemList(); - for ( QwtPolarItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - QwtPolarItem* item = *it; - item->updateScaleDiv( *scaleDiv( QwtPolar::Azimuth ), - *scaleDiv( QwtPolar::Radius ), interval ); - } + if (!d.isValid) + { + d.scaleDiv = d.scaleEngine->divideScale(minValue, maxValue, d.maxMajor, + d.maxMinor, stepSize); + d.isValid = true; + } + + const QwtInterval interval = visibleInterval(); + + const QwtPolarItemList &itmList = itemList(); + for (QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + QwtPolarItem *item = *it; + item->updateScaleDiv(*scaleDiv(QwtPolar::Azimuth), + *scaleDiv(QwtPolar::Radius), interval); + } } /*! @@ -1094,20 +1072,19 @@ void QwtPolarPlot::updateScale( int scaleId ) */ int QwtPolarPlot::plotMarginHint() const { - int margin = 0; - const QwtPolarItemList& itmList = itemList(); - for ( QwtPolarItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) + int margin = 0; + const QwtPolarItemList &itmList = itemList(); + for (QwtPolarItemIterator it = itmList.begin(); it != itmList.end(); ++it) + { + QwtPolarItem *item = *it; + if (item && item->isVisible()) { - QwtPolarItem* item = *it; - if ( item && item->isVisible() ) - { - const int hint = item->marginHint(); - if ( hint > margin ) - margin = hint; - } + const int hint = item->marginHint(); + if (hint > margin) + margin = hint; } - return margin; + } + return margin; } /*! @@ -1119,7 +1096,7 @@ int QwtPolarPlot::plotMarginHint() const */ QRectF QwtPolarPlot::plotRect() const { - return plotRect( canvas()->contentsRect() ); + return plotRect(canvas()->contentsRect()); } /*! @@ -1130,37 +1107,36 @@ QRectF QwtPolarPlot::plotRect() const \param canvasRect Rectangle of the canvas \return Rectangle for displaying 100% of the plot */ -QRectF QwtPolarPlot::plotRect( const QRectF& canvasRect ) const +QRectF QwtPolarPlot::plotRect(const QRectF &canvasRect) const { - const QwtScaleDiv* sd = scaleDiv( QwtPolar::Radius ); - const QwtScaleEngine* se = scaleEngine( QwtPolar::Radius ); + const QwtScaleDiv *sd = scaleDiv(QwtPolar::Radius); + const QwtScaleEngine *se = scaleEngine(QwtPolar::Radius); - const int margin = plotMarginHint(); - const QRectF cr = canvasRect; - const int radius = qMin( cr.width(), cr.height() ) / 2 - margin; + const int margin = plotMarginHint(); + const QRectF cr = canvasRect; + const int radius = qMin(cr.width(), cr.height()) / 2 - margin; - QwtScaleMap map; - map.setTransformation( se->transformation() ); - map.setPaintInterval( 0.0, radius / m_data->zoomFactor ); - map.setScaleInterval( sd->lowerBound(), sd->upperBound() ); + QwtScaleMap map; + map.setTransformation(se->transformation()); + map.setPaintInterval(0.0, radius / m_data->zoomFactor); + map.setScaleInterval(sd->lowerBound(), sd->upperBound()); - double v = map.s1(); - if ( map.s1() <= map.s2() ) - v += m_data->zoomPos.radius(); - else - v -= m_data->zoomPos.radius(); - v = map.transform( v ); + double v = map.s1(); + if (map.s1() <= map.s2()) + v += m_data->zoomPos.radius(); + else + v -= m_data->zoomPos.radius(); + v = map.transform(v); - const QPointF off = - QwtPointPolar( m_data->zoomPos.azimuth(), v ).toPoint(); + const QPointF off = QwtPointPolar(m_data->zoomPos.azimuth(), v).toPoint(); - QPointF center( cr.center().x(), cr.top() + margin + radius ); - center -= QPointF( off.x(), -off.y() ); + QPointF center(cr.center().x(), cr.top() + margin + radius); + center -= QPointF(off.x(), -off.y()); - QRectF rect( 0, 0, 2 * map.p2(), 2 * map.p2() ); - rect.moveCenter( center ); + QRectF rect(0, 0, 2 * map.p2(), 2 * map.p2()); + rect.moveCenter(center); - return rect; + return rect; } /*! @@ -1169,119 +1145,119 @@ QRectF QwtPolarPlot::plotRect( const QRectF& canvasRect ) const */ QwtInterval QwtPolarPlot::visibleInterval() const { - const QwtScaleDiv* sd = scaleDiv( QwtPolar::Radius ); + const QwtScaleDiv *sd = scaleDiv(QwtPolar::Radius); - const QRectF cRect = canvas()->contentsRect(); - const QRectF pRect = plotRect( cRect ); - if ( cRect.contains( pRect ) || !cRect.intersects( pRect ) ) + const QRectF cRect = canvas()->contentsRect(); + const QRectF pRect = plotRect(cRect); + if (cRect.contains(pRect) || !cRect.intersects(pRect)) + { + return QwtInterval(sd->lowerBound(), sd->upperBound()); + } + + const QPointF pole = pRect.center(); + const QRectF scaleRect = pRect & cRect; + + const QwtScaleMap map = scaleMap(QwtPolar::Radius); + + double dmin = 0.0; + double dmax = 0.0; + if (scaleRect.contains(pole)) + { + dmin = 0.0; + + QPointF corners[4]; + corners[0] = scaleRect.bottomRight(); + corners[1] = scaleRect.topRight(); + corners[2] = scaleRect.topLeft(); + corners[3] = scaleRect.bottomLeft(); + + dmax = 0.0; + for (int i = 0; i < 4; i++) { - return QwtInterval( sd->lowerBound(), sd->upperBound() ); + const double dist = qwtDistance(pole, corners[i]); + if (dist > dmax) + dmax = dist; } - - const QPointF pole = pRect.center(); - const QRectF scaleRect = pRect & cRect; - - const QwtScaleMap map = scaleMap( QwtPolar::Radius ); - - double dmin = 0.0; - double dmax = 0.0; - if ( scaleRect.contains( pole ) ) + } + else + { + if (pole.x() < scaleRect.left()) { - dmin = 0.0; - - QPointF corners[4]; - corners[0] = scaleRect.bottomRight(); - corners[1] = scaleRect.topRight(); - corners[2] = scaleRect.topLeft(); - corners[3] = scaleRect.bottomLeft(); - - dmax = 0.0; - for ( int i = 0; i < 4; i++ ) - { - const double dist = qwtDistance( pole, corners[i] ); - if ( dist > dmax ) - dmax = dist; - } + if (pole.y() < scaleRect.top()) + { + dmin = qwtDistance(pole, scaleRect.topLeft()); + dmax = qwtDistance(pole, scaleRect.bottomRight()); + } + else if (pole.y() > scaleRect.bottom()) + { + dmin = qwtDistance(pole, scaleRect.bottomLeft()); + dmax = qwtDistance(pole, scaleRect.topRight()); + } + else + { + dmin = scaleRect.left() - pole.x(); + dmax = qMax(qwtDistance(pole, scaleRect.bottomRight()), + qwtDistance(pole, scaleRect.topRight())); + } } - else + else if (pole.x() > scaleRect.right()) { - if ( pole.x() < scaleRect.left() ) - { - if ( pole.y() < scaleRect.top() ) - { - dmin = qwtDistance( pole, scaleRect.topLeft() ); - dmax = qwtDistance( pole, scaleRect.bottomRight() ); - } - else if ( pole.y() > scaleRect.bottom() ) - { - dmin = qwtDistance( pole, scaleRect.bottomLeft() ); - dmax = qwtDistance( pole, scaleRect.topRight() ); - } - else - { - dmin = scaleRect.left() - pole.x(); - dmax = qMax( qwtDistance( pole, scaleRect.bottomRight() ), - qwtDistance( pole, scaleRect.topRight() ) ); - } - } - else if ( pole.x() > scaleRect.right() ) - { - if ( pole.y() < scaleRect.top() ) - { - dmin = qwtDistance( pole, scaleRect.topRight() ); - dmax = qwtDistance( pole, scaleRect.bottomLeft() ); - } - else if ( pole.y() > scaleRect.bottom() ) - { - dmin = qwtDistance( pole, scaleRect.bottomRight() ); - dmax = qwtDistance( pole, scaleRect.topLeft() ); - } - else - { - dmin = pole.x() - scaleRect.right(); - dmax = qMax( qwtDistance( pole, scaleRect.bottomLeft() ), - qwtDistance( pole, scaleRect.topLeft() ) ); - } - } - else if ( pole.y() < scaleRect.top() ) - { - dmin = scaleRect.top() - pole.y(); - dmax = qMax( qwtDistance( pole, scaleRect.bottomLeft() ), - qwtDistance( pole, scaleRect.bottomRight() ) ); - } - else if ( pole.y() > scaleRect.bottom() ) - { - dmin = pole.y() - scaleRect.bottom(); - dmax = qMax( qwtDistance( pole, scaleRect.topLeft() ), - qwtDistance( pole, scaleRect.topRight() ) ); - } + if (pole.y() < scaleRect.top()) + { + dmin = qwtDistance(pole, scaleRect.topRight()); + dmax = qwtDistance(pole, scaleRect.bottomLeft()); + } + else if (pole.y() > scaleRect.bottom()) + { + dmin = qwtDistance(pole, scaleRect.bottomRight()); + dmax = qwtDistance(pole, scaleRect.topLeft()); + } + else + { + dmin = pole.x() - scaleRect.right(); + dmax = qMax(qwtDistance(pole, scaleRect.bottomLeft()), + qwtDistance(pole, scaleRect.topLeft())); + } } + else if (pole.y() < scaleRect.top()) + { + dmin = scaleRect.top() - pole.y(); + dmax = qMax(qwtDistance(pole, scaleRect.bottomLeft()), + qwtDistance(pole, scaleRect.bottomRight())); + } + else if (pole.y() > scaleRect.bottom()) + { + dmin = pole.y() - scaleRect.bottom(); + dmax = qMax(qwtDistance(pole, scaleRect.topLeft()), + qwtDistance(pole, scaleRect.topRight())); + } + } - const double radius = pRect.width() / 2.0; - if ( dmax > radius ) - dmax = radius; + const double radius = pRect.width() / 2.0; + if (dmax > radius) + dmax = radius; - QwtInterval interval; - interval.setMinValue( map.invTransform( dmin ) ); - interval.setMaxValue( map.invTransform( dmax ) ); + QwtInterval interval; + interval.setMinValue(map.invTransform(dmin)); + interval.setMaxValue(map.invTransform(dmax)); - return interval; + return interval; } /*! \return Layout, responsible for the geometry of the plot components */ -QwtPolarLayout* QwtPolarPlot::plotLayout() +QwtPolarLayout *QwtPolarPlot::plotLayout() { - return m_data->layout; + return m_data->layout; } /*! \return Layout, responsible for the geometry of the plot components */ -const QwtPolarLayout* QwtPolarPlot::plotLayout() const +const QwtPolarLayout *QwtPolarPlot::plotLayout() const { - return m_data->layout; + return m_data->layout; } /*! @@ -1290,32 +1266,32 @@ const QwtPolarLayout* QwtPolarPlot::plotLayout() const \param plotItem Plot item \param on When true attach the item, otherwise detach it */ -void QwtPolarPlot::attachItem( QwtPolarItem* plotItem, bool on ) +void QwtPolarPlot::attachItem(QwtPolarItem *plotItem, bool on) { - if ( on ) - insertItem( plotItem ); - else - removeItem( plotItem ); + if (on) + insertItem(plotItem); + else + removeItem(plotItem); - Q_EMIT itemAttached( plotItem, on ); + Q_EMIT itemAttached(plotItem, on); - if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) ) + if (plotItem->testItemAttribute(QwtPolarItem::Legend)) + { + // the item wants to be represented on the legend + + if (on) { - // the item wants to be represented on the legend - - if ( on ) - { - updateLegend( plotItem ); - } - else - { - const QVariant itemInfo = itemToInfo( plotItem ); - Q_EMIT legendDataChanged( itemInfo, QList< QwtLegendData >() ); - } + updateLegend(plotItem); } + else + { + const QVariant itemInfo = itemToInfo(plotItem); + Q_EMIT legendDataChanged(itemInfo, QList()); + } + } - if ( autoReplot() ) - update(); + if (autoReplot()) + update(); } /*! @@ -1334,9 +1310,9 @@ void QwtPolarPlot::attachItem( QwtPolarItem* plotItem, bool on ) \param plotItem Plot item \sa infoToItem() */ -QVariant QwtPolarPlot::itemToInfo( QwtPolarItem* plotItem ) const +QVariant QwtPolarPlot::itemToInfo(QwtPolarItem *plotItem) const { - return QVariant::fromValue( plotItem ); + return QVariant::fromValue(plotItem); } /*! @@ -1354,14 +1330,14 @@ QVariant QwtPolarPlot::itemToInfo( QwtPolarItem* plotItem ) const \return A plot item, when successful, otherwise a NULL pointer. \sa itemToInfo() */ -QwtPolarItem* QwtPolarPlot::infoToItem( const QVariant& itemInfo ) const +QwtPolarItem *QwtPolarPlot::infoToItem(const QVariant &itemInfo) const { - if ( itemInfo.canConvert< QwtPolarItem* >() ) - return qvariant_cast< QwtPolarItem* >( itemInfo ); + if (itemInfo.canConvert()) + return qvariant_cast(itemInfo); - return NULL; + return NULL; } #if QWT_MOC_INCLUDE -#include "moc_qwt_polar_plot.cpp" +# include "moc_qwt_polar_plot.cpp" #endif diff --git a/libs/qwt/src/qwt_polar_plot.h b/libs/qwt/src/qwt_polar_plot.h index 1161641f..e9f049bd 100644 --- a/libs/qwt/src/qwt_polar_plot.h +++ b/libs/qwt/src/qwt_polar_plot.h @@ -45,175 +45,173 @@ class QwtAbstractLegend; */ class QWT_EXPORT QwtPolarPlot : public QFrame, public QwtPolarItemDict { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( QBrush plotBackground READ plotBackground WRITE setPlotBackground ) - Q_PROPERTY( double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin ) + Q_PROPERTY(QBrush plotBackground READ plotBackground WRITE setPlotBackground) + Q_PROPERTY(double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin) +public: + /*! + Position of the legend, relative to the canvas. + \sa insertLegend() + */ + enum LegendPosition + { + //! The legend will be left from the canvas. + LeftLegend, - public: - /*! - Position of the legend, relative to the canvas. - \sa insertLegend() - */ - enum LegendPosition - { - //! The legend will be left from the canvas. - LeftLegend, + //! The legend will be right from the canvas. + RightLegend, - //! The legend will be right from the canvas. - RightLegend, + //! The legend will be below the canvas. + BottomLegend, - //! The legend will be below the canvas. - BottomLegend, - - //! The legend will be between canvas and title. - TopLegend, - - /*! - External means that only the content of the legend - will be handled by QwtPlot, but not its geometry. - This might be interesting if an application wants to - have a legend in an external window ( or on the canvas ). - - \note The legend is not painted by QwtPolarRenderer - */ - ExternalLegend - }; - - explicit QwtPolarPlot( QWidget* parent = NULL ); - QwtPolarPlot( const QwtText& title, QWidget* parent = NULL ); - - virtual ~QwtPolarPlot(); - - void setTitle( const QString& ); - void setTitle( const QwtText& ); - - QwtText title() const; - - QwtTextLabel* titleLabel(); - const QwtTextLabel* titleLabel() const; - - void setAutoReplot( bool tf = true ); - bool autoReplot() const; - - void setAutoScale( int scaleId ); - bool hasAutoScale( int scaleId ) const; - - void setScaleMaxMinor( int scaleId, int maxMinor ); - int scaleMaxMinor( int scaleId ) const; - - int scaleMaxMajor( int scaleId ) const; - void setScaleMaxMajor( int scaleId, int maxMajor ); - - QwtScaleEngine* scaleEngine( int scaleId ); - const QwtScaleEngine* scaleEngine( int scaleId ) const; - void setScaleEngine( int scaleId, QwtScaleEngine* ); - - void setScale( int scaleId, double min, double max, double step = 0 ); - - void setScaleDiv( int scaleId, const QwtScaleDiv& ); - const QwtScaleDiv* scaleDiv( int scaleId ) const; - QwtScaleDiv* scaleDiv( int scaleId ); - - QwtScaleMap scaleMap( int scaleId, double radius ) const; - QwtScaleMap scaleMap( int scaleId ) const; - - void updateScale( int scaleId ); - - double azimuthOrigin() const; - - void zoom( const QwtPointPolar&, double factor ); - void unzoom(); - - QwtPointPolar zoomPos() const; - double zoomFactor() const; - - // Canvas - - QwtPolarCanvas* canvas(); - const QwtPolarCanvas* canvas() const; - - void setPlotBackground ( const QBrush& c ); - const QBrush& plotBackground() const; - - virtual void drawCanvas( QPainter*, const QRectF& ) const; - - // Legend - - void insertLegend( QwtAbstractLegend*, - LegendPosition = RightLegend, double ratio = -1.0 ); - - QwtAbstractLegend* legend(); - const QwtAbstractLegend* legend() const; - - void updateLegend(); - void updateLegend( const QwtPolarItem* ); - - // Layout - QwtPolarLayout* plotLayout(); - const QwtPolarLayout* plotLayout() const; - - QwtInterval visibleInterval() const; - QRectF plotRect() const; - QRectF plotRect( const QRectF& ) const; - - int plotMarginHint() const; - - virtual QVariant itemToInfo( QwtPolarItem* ) const; - virtual QwtPolarItem* infoToItem( const QVariant& ) const; - - Q_SIGNALS: - /*! - A signal indicating, that an item has been attached/detached - - \param plotItem Plot item - \param on Attached/Detached - */ - void itemAttached( QwtPolarItem* plotItem, bool on ); + //! The legend will be between canvas and title. + TopLegend, /*! - A signal with the attributes how to update - the legend entries for a plot item. + External means that only the content of the legend + will be handled by QwtPlot, but not its geometry. + This might be interesting if an application wants to + have a legend in an external window ( or on the canvas ). - \param itemInfo Info about a plot, build from itemToInfo() - \param data Attributes of the entries ( usually <= 1 ) for the plot item. - - \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() + \note The legend is not painted by QwtPolarRenderer */ - void legendDataChanged( const QVariant& itemInfo, - const QList< QwtLegendData >& data ); + ExternalLegend + }; - /*! - A signal that is emitted, whenever the layout of the plot - has been recalculated. - */ - void layoutChanged(); + explicit QwtPolarPlot(QWidget *parent = NULL); + QwtPolarPlot(const QwtText &title, QWidget *parent = NULL); - public Q_SLOTS: - virtual void replot(); - void autoRefresh(); - void setAzimuthOrigin( double ); + virtual ~QwtPolarPlot(); - protected: - virtual bool event( QEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; + void setTitle(const QString &); + void setTitle(const QwtText &); - virtual void updateLayout(); + QwtText title() const; - virtual void drawItems( QPainter* painter, - const QwtScaleMap& radialMap, const QwtScaleMap& azimuthMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const; + QwtTextLabel *titleLabel(); + const QwtTextLabel *titleLabel() const; - private: - friend class QwtPolarItem; - void attachItem( QwtPolarItem*, bool ); + void setAutoReplot(bool tf = true); + bool autoReplot() const; - void initPlot( const QwtText& ); + void setAutoScale(int scaleId); + bool hasAutoScale(int scaleId) const; - class PrivateData; - PrivateData* m_data; + void setScaleMaxMinor(int scaleId, int maxMinor); + int scaleMaxMinor(int scaleId) const; + + int scaleMaxMajor(int scaleId) const; + void setScaleMaxMajor(int scaleId, int maxMajor); + + QwtScaleEngine *scaleEngine(int scaleId); + const QwtScaleEngine *scaleEngine(int scaleId) const; + void setScaleEngine(int scaleId, QwtScaleEngine *); + + void setScale(int scaleId, double min, double max, double step = 0); + + void setScaleDiv(int scaleId, const QwtScaleDiv &); + const QwtScaleDiv *scaleDiv(int scaleId) const; + QwtScaleDiv *scaleDiv(int scaleId); + + QwtScaleMap scaleMap(int scaleId, double radius) const; + QwtScaleMap scaleMap(int scaleId) const; + + void updateScale(int scaleId); + + double azimuthOrigin() const; + + void zoom(const QwtPointPolar &, double factor); + void unzoom(); + + QwtPointPolar zoomPos() const; + double zoomFactor() const; + + // Canvas + + QwtPolarCanvas *canvas(); + const QwtPolarCanvas *canvas() const; + + void setPlotBackground(const QBrush &c); + const QBrush &plotBackground() const; + + virtual void drawCanvas(QPainter *, const QRectF &) const; + + // Legend + + void insertLegend(QwtAbstractLegend *, LegendPosition = RightLegend, + double ratio = -1.0); + + QwtAbstractLegend *legend(); + const QwtAbstractLegend *legend() const; + + void updateLegend(); + void updateLegend(const QwtPolarItem *); + + // Layout + QwtPolarLayout *plotLayout(); + const QwtPolarLayout *plotLayout() const; + + QwtInterval visibleInterval() const; + QRectF plotRect() const; + QRectF plotRect(const QRectF &) const; + + int plotMarginHint() const; + + virtual QVariant itemToInfo(QwtPolarItem *) const; + virtual QwtPolarItem *infoToItem(const QVariant &) const; + +Q_SIGNALS: + /*! + A signal indicating, that an item has been attached/detached + + \param plotItem Plot item + \param on Attached/Detached + */ + void itemAttached(QwtPolarItem *plotItem, bool on); + + /*! + A signal with the attributes how to update + the legend entries for a plot item. + + \param itemInfo Info about a plot, build from itemToInfo() + \param data Attributes of the entries ( usually <= 1 ) for the plot item. + + \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() + */ + void legendDataChanged(const QVariant &itemInfo, + const QList &data); + + /*! + A signal that is emitted, whenever the layout of the plot + has been recalculated. + */ + void layoutChanged(); + +public Q_SLOTS: + virtual void replot(); + void autoRefresh(); + void setAzimuthOrigin(double); + +protected: + virtual bool event(QEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; + + virtual void updateLayout(); + + virtual void drawItems(QPainter *painter, const QwtScaleMap &radialMap, + const QwtScaleMap &azimuthMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const; + +private: + friend class QwtPolarItem; + void attachItem(QwtPolarItem *, bool); + + void initPlot(const QwtText &); + + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_renderer.cpp b/libs/qwt/src/qwt_polar_renderer.cpp index 0e17deb9..0fbd846c 100644 --- a/libs/qwt/src/qwt_polar_renderer.cpp +++ b/libs/qwt/src/qwt_polar_renderer.cpp @@ -23,13 +23,13 @@ #include #ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB -#define QWT_FORMAT_SVG 1 -#endif +# ifdef QT_SVG_LIB +# define QWT_FORMAT_SVG 1 +# endif #endif #ifndef QT_NO_PRINTER -#define QWT_FORMAT_PDF 1 +# define QWT_FORMAT_PDF 1 #endif #ifndef QT_NO_PDF @@ -38,57 +38,57 @@ // Qt 5.3. Guess it is o.k. to stay with QPrinter for older // versions. -#if QT_VERSION >= 0x050300 +# if QT_VERSION >= 0x050300 -#ifndef QWT_FORMAT_PDF -#define QWT_FORMAT_PDF 1 -#endif +# ifndef QWT_FORMAT_PDF +# define QWT_FORMAT_PDF 1 +# endif -#define QWT_PDF_WRITER 1 +# define QWT_PDF_WRITER 1 -#endif +# endif #endif #ifndef QT_NO_PRINTER // postscript support has been dropped in Qt5 -#if QT_VERSION < 0x050000 -#define QWT_FORMAT_POSTSCRIPT 1 -#endif +# if QT_VERSION < 0x050000 +# define QWT_FORMAT_POSTSCRIPT 1 +# endif #endif #if QWT_FORMAT_SVG -#include +# include #endif #if QWT_PDF_WRITER -#include +# include #endif class QwtPolarRenderer::PrivateData { - public: - PrivateData() - : plot( NULL ) - { - } +public: + PrivateData() + : plot(NULL) + { + } - QwtPolarPlot* plot; + QwtPolarPlot *plot; }; /*! Constructor \param parent Parent object */ -QwtPolarRenderer::QwtPolarRenderer( QObject* parent ) - : QObject( parent ) +QwtPolarRenderer::QwtPolarRenderer(QObject *parent) + : QObject(parent) { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtPolarRenderer::~QwtPolarRenderer() { - delete m_data; + delete m_data; } /*! @@ -102,11 +102,12 @@ QwtPolarRenderer::~QwtPolarRenderer() \param sizeMM Size for the document in millimeters. \param resolution Resolution in dots per Inch (dpi) */ -void QwtPolarRenderer::renderDocument( QwtPolarPlot* plot, - const QString& fileName, const QSizeF& sizeMM, int resolution ) +void QwtPolarRenderer::renderDocument(QwtPolarPlot *plot, + const QString &fileName, + const QSizeF &sizeMM, int resolution) { - renderDocument( plot, fileName, - QFileInfo( fileName ).suffix(), sizeMM, resolution ); + renderDocument(plot, fileName, QFileInfo(fileName).suffix(), sizeMM, + resolution); } /*! @@ -117,7 +118,8 @@ void QwtPolarRenderer::renderDocument( QwtPolarPlot* plot, - pdf\n - ps\n - svg\n - - all image formats supported by Qt, see QImageWriter::supportedImageFormats() + - all image formats supported by Qt, see + QImageWriter::supportedImageFormats() \param plot Plot widget \param fileName Path of the file, where the document will be stored @@ -127,100 +129,100 @@ void QwtPolarRenderer::renderDocument( QwtPolarPlot* plot, \sa renderTo(), render(), QwtPainter::setRoundingAlignment() */ -void QwtPolarRenderer::renderDocument( QwtPolarPlot* plot, - const QString& fileName, const QString& format, - const QSizeF& sizeMM, int resolution ) +void QwtPolarRenderer::renderDocument(QwtPolarPlot *plot, + const QString &fileName, + const QString &format, + const QSizeF &sizeMM, int resolution) { - if ( plot == NULL || sizeMM.isEmpty() || resolution <= 0 ) - return; + if (plot == NULL || sizeMM.isEmpty() || resolution <= 0) + return; - QString title = plot->title().text(); - if ( title.isEmpty() ) - title = "Plot Document"; + QString title = plot->title().text(); + if (title.isEmpty()) + title = "Plot Document"; - const double mmToInch = 1.0 / 25.4; - const QSizeF size = sizeMM * mmToInch * resolution; + const double mmToInch = 1.0 / 25.4; + const QSizeF size = sizeMM * mmToInch * resolution; - const QRectF documentRect( 0.0, 0.0, size.width(), size.height() ); + const QRectF documentRect(0.0, 0.0, size.width(), size.height()); - const QString fmt = format.toLower(); - if ( format == "pdf" ) - { + const QString fmt = format.toLower(); + if (format == "pdf") + { #if QWT_FORMAT_PDF -#if QWT_PDF_WRITER - QPdfWriter pdfWriter( fileName ); - pdfWriter.setPageSize( QPageSize( sizeMM, QPageSize::Millimeter ) ); - pdfWriter.setTitle( title ); - pdfWriter.setPageMargins( QMarginsF() ); - pdfWriter.setResolution( resolution ); +# if QWT_PDF_WRITER + QPdfWriter pdfWriter(fileName); + pdfWriter.setPageSize(QPageSize(sizeMM, QPageSize::Millimeter)); + pdfWriter.setTitle(title); + pdfWriter.setPageMargins(QMarginsF()); + pdfWriter.setResolution(resolution); - QPainter painter( &pdfWriter ); - render( plot, &painter, documentRect ); + QPainter painter(&pdfWriter); + render(plot, &painter, documentRect); -#else - QPrinter printer; - printer.setOutputFormat( QPrinter::PdfFormat ); - printer.setColorMode( QPrinter::Color ); - printer.setFullPage( true ); - printer.setPaperSize( sizeMM, QPrinter::Millimeter ); - printer.setDocName( title ); - printer.setOutputFileName( fileName ); - printer.setResolution( resolution ); +# else + QPrinter printer; + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setColorMode(QPrinter::Color); + printer.setFullPage(true); + printer.setPaperSize(sizeMM, QPrinter::Millimeter); + printer.setDocName(title); + printer.setOutputFileName(fileName); + printer.setResolution(resolution); - QPainter painter( &printer ); - render( plot, &painter, documentRect ); + QPainter painter(&printer); + render(plot, &painter, documentRect); +# endif #endif -#endif - } - else if ( format == "ps" ) - { + } + else if (format == "ps") + { #if QWT_FORMAT_POSTSCRIPT - QPrinter printer; - printer.setColorMode( QPrinter::Color ); - printer.setFullPage( true ); - printer.setPaperSize( sizeMM, QPrinter::Millimeter ); - printer.setDocName( title ); - printer.setOutputFileName( fileName ); - printer.setOutputFormat( QPrinter::PostScriptFormat ); - printer.setResolution( resolution ); + QPrinter printer; + printer.setColorMode(QPrinter::Color); + printer.setFullPage(true); + printer.setPaperSize(sizeMM, QPrinter::Millimeter); + printer.setDocName(title); + printer.setOutputFileName(fileName); + printer.setOutputFormat(QPrinter::PostScriptFormat); + printer.setResolution(resolution); - QPainter painter( &printer ); - render( plot, &painter, documentRect ); + QPainter painter(&printer); + render(plot, &painter, documentRect); #endif - } - else if ( format == "svg" ) - { + } + else if (format == "svg") + { #ifdef QWT_FORMAT_SVG - QSvgGenerator generator; - generator.setTitle( title ); - generator.setFileName( fileName ); - generator.setResolution( resolution ); - generator.setViewBox( documentRect ); + QSvgGenerator generator; + generator.setTitle(title); + generator.setFileName(fileName); + generator.setResolution(resolution); + generator.setViewBox(documentRect); - QPainter painter( &generator ); - render( plot, &painter, documentRect ); + QPainter painter(&generator); + render(plot, &painter, documentRect); #endif - } - else + } + else + { + if (QImageWriter::supportedImageFormats().indexOf(format.toLatin1()) >= 0) { - if ( QImageWriter::supportedImageFormats().indexOf( - format.toLatin1() ) >= 0 ) - { - const QRect imageRect = documentRect.toRect(); - const int dotsPerMeter = qRound( resolution * mmToInch * 1000.0 ); + const QRect imageRect = documentRect.toRect(); + const int dotsPerMeter = qRound(resolution * mmToInch * 1000.0); - QImage image( imageRect.size(), QImage::Format_ARGB32 ); - image.setDotsPerMeterX( dotsPerMeter ); - image.setDotsPerMeterY( dotsPerMeter ); - image.fill( QColor( Qt::white ).rgb() ); + QImage image(imageRect.size(), QImage::Format_ARGB32); + image.setDotsPerMeterX(dotsPerMeter); + image.setDotsPerMeterY(dotsPerMeter); + image.fill(QColor(Qt::white).rgb()); - QPainter painter( &image ); - render( plot, &painter, imageRect ); - painter.end(); + QPainter painter(&image); + render(plot, &painter, imageRect); + painter.end(); - image.save( fileName, format.toLatin1() ); - } + image.save(fileName, format.toLatin1()); } + } } /*! @@ -236,17 +238,16 @@ void QwtPolarRenderer::renderDocument( QwtPolarPlot* plot, \sa renderDocument(), render(), QwtPainter::setRoundingAlignment() */ -void QwtPolarRenderer::renderTo( - QwtPolarPlot* plot, QPaintDevice& paintDevice ) const +void QwtPolarRenderer::renderTo(QwtPolarPlot *plot, + QPaintDevice &paintDevice) const { - int w = paintDevice.width(); - int h = paintDevice.height(); + int w = paintDevice.width(); + int h = paintDevice.height(); - QPainter p( &paintDevice ); - render( plot, &p, QRectF( 0, 0, w, h ) ); + QPainter p(&paintDevice); + render(plot, &p, QRectF(0, 0, w, h)); } - /*! \brief Render the plot to a QPrinter @@ -262,19 +263,18 @@ void QwtPolarRenderer::renderTo( #ifndef QT_NO_PRINTER -void QwtPolarRenderer::renderTo( - QwtPolarPlot* plot, QPrinter& printer ) const +void QwtPolarRenderer::renderTo(QwtPolarPlot *plot, QPrinter &printer) const { - int w = printer.width(); - int h = printer.height(); + int w = printer.width(); + int h = printer.height(); - QRectF rect( 0, 0, w, h ); - double aspect = rect.width() / rect.height(); - if ( ( aspect < 1.0 ) ) - rect.setHeight( aspect * rect.width() ); + QRectF rect(0, 0, w, h); + double aspect = rect.width() / rect.height(); + if ((aspect < 1.0)) + rect.setHeight(aspect * rect.width()); - QPainter p( &printer ); - render( plot, &p, rect ); + QPainter p(&printer); + render(plot, &p, rect); } #endif @@ -292,18 +292,18 @@ void QwtPolarRenderer::renderTo( \param plot Plot to be rendered \param generator SVG generator */ -void QwtPolarRenderer::renderTo( - QwtPolarPlot* plot, QSvgGenerator& generator ) const +void QwtPolarRenderer::renderTo(QwtPolarPlot *plot, + QSvgGenerator &generator) const { - QRectF rect = generator.viewBoxF(); - if ( rect.isEmpty() ) - rect.setRect( 0, 0, generator.width(), generator.height() ); + QRectF rect = generator.viewBoxF(); + if (rect.isEmpty()) + rect.setRect(0, 0, generator.width(), generator.height()); - if ( rect.isEmpty() ) - rect.setRect( 0, 0, 800, 600 ); // something + if (rect.isEmpty()) + rect.setRect(0, 0, 800, 600); // something - QPainter p( &generator ); - render( plot, &p, rect ); + QPainter p(&generator); + render(plot, &p, rect); } #endif @@ -315,62 +315,62 @@ void QwtPolarRenderer::renderTo( \param painter Painter \param plotRect Bounding rectangle for the plot */ -void QwtPolarRenderer::render( QwtPolarPlot* plot, - QPainter* painter, const QRectF& plotRect ) const +void QwtPolarRenderer::render(QwtPolarPlot *plot, QPainter *painter, + const QRectF &plotRect) const { - if ( plot == NULL || painter == NULL || !painter->isActive() || - !plotRect.isValid() || plot->size().isNull() ) - { - return; - } + if (plot == NULL || painter == NULL || !painter->isActive() + || !plotRect.isValid() || plot->size().isNull()) + { + return; + } - m_data->plot = plot; + m_data->plot = plot; - /* - The layout engine uses the same methods as they are used - by the Qt layout system. Therefore we need to calculate the - layout in screen coordinates and paint with a scaled painter. - */ - QTransform transform; - transform.scale( - double( painter->device()->logicalDpiX() ) / plot->logicalDpiX(), - double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() ); + /* + The layout engine uses the same methods as they are used + by the Qt layout system. Therefore we need to calculate the + layout in screen coordinates and paint with a scaled painter. + */ + QTransform transform; + transform.scale( + double(painter->device()->logicalDpiX()) / plot->logicalDpiX(), + double(painter->device()->logicalDpiY()) / plot->logicalDpiY()); - const QRectF layoutRect = transform.inverted().mapRect( plotRect ); + const QRectF layoutRect = transform.inverted().mapRect(plotRect); - QwtPolarLayout* layout = plot->plotLayout(); + QwtPolarLayout *layout = plot->plotLayout(); - // All paint operations need to be scaled according to - // the paint device metrics. + // All paint operations need to be scaled according to + // the paint device metrics. - QwtPolarLayout::Options layoutOptions = - QwtPolarLayout::IgnoreScrollbars | QwtPolarLayout::IgnoreFrames; + QwtPolarLayout::Options layoutOptions + = QwtPolarLayout::IgnoreScrollbars | QwtPolarLayout::IgnoreFrames; - layout->activate( plot, layoutRect, layoutOptions ); + layout->activate(plot, layoutRect, layoutOptions); - painter->save(); - painter->setWorldTransform( transform, true ); + painter->save(); + painter->setWorldTransform(transform, true); - painter->save(); - renderTitle( painter, layout->titleRect() ); - painter->restore(); + painter->save(); + renderTitle(painter, layout->titleRect()); + painter->restore(); - painter->save(); - renderLegend( plot, painter, layout->legendRect() ); - painter->restore(); + painter->save(); + renderLegend(plot, painter, layout->legendRect()); + painter->restore(); - const QRectF canvasRect = layout->canvasRect(); + const QRectF canvasRect = layout->canvasRect(); - painter->save(); - painter->setClipRect( canvasRect ); - plot->drawCanvas( painter, canvasRect ); - painter->restore(); + painter->save(); + painter->setClipRect(canvasRect); + plot->drawCanvas(painter, canvasRect); + painter->restore(); - painter->restore(); + painter->restore(); - layout->invalidate(); + layout->invalidate(); - m_data->plot = NULL; + m_data->plot = NULL; } /*! @@ -380,17 +380,16 @@ void QwtPolarRenderer::render( QwtPolarPlot* plot, \param rect Bounding rectangle */ -void QwtPolarRenderer::renderTitle( QPainter* painter, const QRectF& rect ) const +void QwtPolarRenderer::renderTitle(QPainter *painter, const QRectF &rect) const { - QwtTextLabel* title = m_data->plot->titleLabel(); + QwtTextLabel *title = m_data->plot->titleLabel(); - painter->setFont( title->font() ); + painter->setFont(title->font()); - const QColor color = title->palette().color( - QPalette::Active, QPalette::Text ); + const QColor color = title->palette().color(QPalette::Active, QPalette::Text); - painter->setPen( color ); - title->text().draw( painter, rect ); + painter->setPen(color); + title->text().draw(painter, rect); } /*! @@ -400,11 +399,11 @@ void QwtPolarRenderer::renderTitle( QPainter* painter, const QRectF& rect ) cons \param painter Painter \param rect Bounding rectangle */ -void QwtPolarRenderer::renderLegend( const QwtPolarPlot* plot, - QPainter* painter, const QRectF& rect ) const +void QwtPolarRenderer::renderLegend(const QwtPolarPlot *plot, QPainter *painter, + const QRectF &rect) const { - if ( plot->legend() ) - plot->legend()->renderLegend( painter, rect, true ); + if (plot->legend()) + plot->legend()->renderLegend(painter, rect, true); } /*! @@ -419,59 +418,58 @@ void QwtPolarRenderer::renderLegend( const QwtPolarPlot* plot, \sa renderDocument() */ -bool QwtPolarRenderer::exportTo( QwtPolarPlot* plot, - const QString& documentName, const QSizeF& sizeMM, int resolution ) +bool QwtPolarRenderer::exportTo(QwtPolarPlot *plot, const QString &documentName, + const QSizeF &sizeMM, int resolution) { - if ( plot == NULL ) - return false; + if (plot == NULL) + return false; - QString fileName = documentName; + QString fileName = documentName; - // What about translation + // What about translation #ifndef QT_NO_FILEDIALOG - const QList< QByteArray > imageFormats = - QImageWriter::supportedImageFormats(); + const QList imageFormats = QImageWriter::supportedImageFormats(); - QStringList filter; -#ifndef QT_NO_PRINTER - filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)"; -#endif -#ifndef QWT_NO_SVG - filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)"; -#endif -#ifndef QT_NO_PRINTER - filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)"; -#endif + QStringList filter; +# ifndef QT_NO_PRINTER + filter += QString("PDF ") + tr("Documents") + " (*.pdf)"; +# endif +# ifndef QWT_NO_SVG + filter += QString("SVG ") + tr("Documents") + " (*.svg)"; +# endif +# ifndef QT_NO_PRINTER + filter += QString("Postscript ") + tr("Documents") + " (*.ps)"; +# endif - if ( imageFormats.size() > 0 ) + if (imageFormats.size() > 0) + { + QString imageFilter(tr("Images")); + imageFilter += " ("; + for (int i = 0; i < imageFormats.size(); i++) { - QString imageFilter( tr( "Images" ) ); - imageFilter += " ("; - for ( int i = 0; i < imageFormats.size(); i++ ) - { - if ( i > 0 ) - imageFilter += " "; - imageFilter += "*."; - imageFilter += imageFormats[i]; - } - imageFilter += ")"; - - filter += imageFilter; + if (i > 0) + imageFilter += " "; + imageFilter += "*."; + imageFilter += imageFormats[i]; } + imageFilter += ")"; - fileName = QFileDialog::getSaveFileName( - NULL, tr( "Export File Name" ), fileName, - filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); + filter += imageFilter; + } + + fileName = QFileDialog::getSaveFileName(NULL, tr("Export File Name"), + fileName, filter.join(";;"), NULL, + QFileDialog::DontConfirmOverwrite); #endif - if ( fileName.isEmpty() ) - return false; + if (fileName.isEmpty()) + return false; - renderDocument( plot, fileName, sizeMM, resolution ); + renderDocument(plot, fileName, sizeMM, resolution); - return true; + return true; } #if QWT_MOC_INCLUDE -#include "moc_qwt_polar_renderer.cpp" +# include "moc_qwt_polar_renderer.cpp" #endif diff --git a/libs/qwt/src/qwt_polar_renderer.h b/libs/qwt/src/qwt_polar_renderer.h index c877386a..32f27e97 100644 --- a/libs/qwt/src/qwt_polar_renderer.h +++ b/libs/qwt/src/qwt_polar_renderer.h @@ -23,9 +23,9 @@ class QPrinter; #endif #ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB +# ifdef QT_SVG_LIB class QSvgGenerator; -#endif +# endif #endif /*! @@ -34,45 +34,44 @@ class QSvgGenerator; */ class QWT_EXPORT QwtPolarRenderer : public QObject { - Q_OBJECT + Q_OBJECT - public: - explicit QwtPolarRenderer( QObject* parent = NULL ); - virtual ~QwtPolarRenderer(); +public: + explicit QwtPolarRenderer(QObject *parent = NULL); + virtual ~QwtPolarRenderer(); - void renderDocument( QwtPolarPlot*, const QString& format, - const QSizeF& sizeMM, int resolution = 85 ); + void renderDocument(QwtPolarPlot *, const QString &format, + const QSizeF &sizeMM, int resolution = 85); - void renderDocument( QwtPolarPlot*, - const QString& title, const QString& format, - const QSizeF& sizeMM, int resolution = 85 ); + void renderDocument(QwtPolarPlot *, const QString &title, + const QString &format, const QSizeF &sizeMM, + int resolution = 85); #ifndef QWT_NO_SVG -#ifdef QT_SVG_LIB - void renderTo( QwtPolarPlot*, QSvgGenerator& ) const; -#endif +# ifdef QT_SVG_LIB + void renderTo(QwtPolarPlot *, QSvgGenerator &) const; +# endif #endif #ifndef QT_NO_PRINTER - void renderTo( QwtPolarPlot*, QPrinter& ) const; + void renderTo(QwtPolarPlot *, QPrinter &) const; #endif - void renderTo( QwtPolarPlot*, QPaintDevice& ) const; + void renderTo(QwtPolarPlot *, QPaintDevice &) const; - virtual void render( QwtPolarPlot*, - QPainter*, const QRectF& rect ) const; + virtual void render(QwtPolarPlot *, QPainter *, const QRectF &rect) const; - bool exportTo( QwtPolarPlot*, const QString& documentName, - const QSizeF& sizeMM = QSizeF( 200, 200 ), int resolution = 85 ); + bool exportTo(QwtPolarPlot *, const QString &documentName, + const QSizeF &sizeMM = QSizeF(200, 200), int resolution = 85); - virtual void renderTitle( QPainter*, const QRectF& ) const; + virtual void renderTitle(QPainter *, const QRectF &) const; - virtual void renderLegend( - const QwtPolarPlot*, QPainter*, const QRectF& ) const; + virtual void renderLegend(const QwtPolarPlot *, QPainter *, + const QRectF &) const; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_polar_spectrogram.cpp b/libs/qwt/src/qwt_polar_spectrogram.cpp index a5a668f5..053508c6 100644 --- a/libs/qwt/src/qwt_polar_spectrogram.cpp +++ b/libs/qwt/src/qwt_polar_spectrogram.cpp @@ -22,60 +22,60 @@ #include #if QT_VERSION < 0x050000 -#include +# include #endif class QwtPolarSpectrogram::TileInfo { - public: - QPoint imagePos; - QRect rect; - QImage* image; +public: + QPoint imagePos; + QRect rect; + QImage *image; }; class QwtPolarSpectrogram::PrivateData { - public: - PrivateData() - : data( NULL ) - { - colorMap = new QwtLinearColorMap(); - } +public: + PrivateData() + : data(NULL) + { + colorMap = new QwtLinearColorMap(); + } - ~PrivateData() - { - delete data; - delete colorMap; - } + ~PrivateData() + { + delete data; + delete colorMap; + } - QwtRasterData* data; - QwtColorMap* colorMap; + QwtRasterData *data; + QwtColorMap *colorMap; - QwtPolarSpectrogram::PaintAttributes paintAttributes; + QwtPolarSpectrogram::PaintAttributes paintAttributes; }; //! Constructor QwtPolarSpectrogram::QwtPolarSpectrogram() - : QwtPolarItem( QwtText( "Spectrogram" ) ) + : QwtPolarItem(QwtText("Spectrogram")) { - m_data = new PrivateData; + m_data = new PrivateData; - setItemAttribute( QwtPolarItem::AutoScale ); - setItemAttribute( QwtPolarItem::Legend, false ); + setItemAttribute(QwtPolarItem::AutoScale); + setItemAttribute(QwtPolarItem::Legend, false); - setZ( 20.0 ); + setZ(20.0); } //! Destructor QwtPolarSpectrogram::~QwtPolarSpectrogram() { - delete m_data; + delete m_data; } //! \return QwtPolarItem::Rtti_PolarSpectrogram int QwtPolarSpectrogram::rtti() const { - return QwtPolarItem::Rtti_PolarSpectrogram; + return QwtPolarItem::Rtti_PolarSpectrogram; } /*! @@ -88,24 +88,24 @@ int QwtPolarSpectrogram::rtti() const image is rendered, but without any useful parameters. Also QwtRasterData::rasterHint() is not used. */ -void QwtPolarSpectrogram::setData( QwtRasterData* data ) +void QwtPolarSpectrogram::setData(QwtRasterData *data) { - if ( data != m_data->data ) - { - delete m_data->data; - m_data->data = data; + if (data != m_data->data) + { + delete m_data->data; + m_data->data = data; - itemChanged(); - } + itemChanged(); + } } /*! \return Spectrogram data \sa setData() */ -const QwtRasterData* QwtPolarSpectrogram::data() const +const QwtRasterData *QwtPolarSpectrogram::data() const { - return m_data->data; + return m_data->data; } /*! @@ -119,24 +119,24 @@ const QwtRasterData* QwtPolarSpectrogram::data() const \sa colorMap(), QwtScaleWidget::setColorBarEnabled(), QwtScaleWidget::setColorMap() */ -void QwtPolarSpectrogram::setColorMap( QwtColorMap* colorMap ) +void QwtPolarSpectrogram::setColorMap(QwtColorMap *colorMap) { - if ( m_data->colorMap != colorMap ) - { - delete m_data->colorMap; - m_data->colorMap = colorMap; - } + if (m_data->colorMap != colorMap) + { + delete m_data->colorMap; + m_data->colorMap = colorMap; + } - itemChanged(); + itemChanged(); } /*! \return Color Map used for mapping the intensity values to colors \sa setColorMap() */ -const QwtColorMap* QwtPolarSpectrogram::colorMap() const +const QwtColorMap *QwtPolarSpectrogram::colorMap() const { - return m_data->colorMap; + return m_data->colorMap; } /*! @@ -146,12 +146,12 @@ const QwtColorMap* QwtPolarSpectrogram::colorMap() const \param on On/Off \sa testPaintAttribute() */ -void QwtPolarSpectrogram::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtPolarSpectrogram::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! @@ -159,9 +159,9 @@ void QwtPolarSpectrogram::setPaintAttribute( PaintAttribute attribute, bool on ) \return True, when attribute has been set \sa setPaintAttribute() */ -bool QwtPolarSpectrogram::testPaintAttribute( PaintAttribute attribute ) const +bool QwtPolarSpectrogram::testPaintAttribute(PaintAttribute attribute) const { - return ( m_data->paintAttributes & attribute ); + return (m_data->paintAttributes & attribute); } /*! @@ -174,44 +174,44 @@ bool QwtPolarSpectrogram::testPaintAttribute( PaintAttribute attribute ) const \param radius Radius of the complete plot area in painter coordinates \param canvasRect Contents rect of the canvas in painter coordinates */ -void QwtPolarSpectrogram::draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double, - const QRectF& canvasRect ) const +void QwtPolarSpectrogram::draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, + const QPointF &pole, double, + const QRectF &canvasRect) const { - const QRectF plotRect = plot()->plotRect( canvasRect.toRect() ); - QRect imageRect = canvasRect.toRect(); + const QRectF plotRect = plot()->plotRect(canvasRect.toRect()); + QRect imageRect = canvasRect.toRect(); - painter->save(); + painter->save(); - painter->setClipRect( canvasRect ); + painter->setClipRect(canvasRect); - QPainterPath clipPathCanvas; - clipPathCanvas.addEllipse( plotRect ); - painter->setClipPath( clipPathCanvas, Qt::IntersectClip ); + QPainterPath clipPathCanvas; + clipPathCanvas.addEllipse(plotRect); + painter->setClipPath(clipPathCanvas, Qt::IntersectClip); - imageRect &= plotRect.toAlignedRect(); // outer rect + imageRect &= plotRect.toAlignedRect(); // outer rect - const QwtInterval radialInterval = boundingInterval( QwtPolar::ScaleRadius ); - if ( radialInterval.isValid() ) - { - const double radius = radialMap.transform( radialInterval.maxValue() ) - - radialMap.transform( radialInterval.minValue() ); + const QwtInterval radialInterval = boundingInterval(QwtPolar::ScaleRadius); + if (radialInterval.isValid()) + { + const double radius = radialMap.transform(radialInterval.maxValue()) + - radialMap.transform(radialInterval.minValue()); - QRectF clipRect( 0, 0, 2 * radius, 2 * radius ); - clipRect.moveCenter( pole ); + QRectF clipRect(0, 0, 2 * radius, 2 * radius); + clipRect.moveCenter(pole); - imageRect &= clipRect.toRect(); // inner rect, we don't have points outside + imageRect &= clipRect.toRect(); // inner rect, we don't have points outside - QPainterPath clipPathRadial; - clipPathRadial.addEllipse( clipRect ); - painter->setClipPath( clipPathRadial, Qt::IntersectClip ); - } + QPainterPath clipPathRadial; + clipPathRadial.addEllipse(clipRect); + painter->setClipPath(clipPathRadial, Qt::IntersectClip); + } - const QImage image = renderImage( azimuthMap, radialMap, pole, imageRect ); - painter->drawImage( imageRect, image ); + const QImage image = renderImage(azimuthMap, radialMap, pole, imageRect); + painter->drawImage(imageRect, image); - painter->restore(); + painter->restore(); } /*! @@ -232,96 +232,97 @@ void QwtPolarSpectrogram::draw( QPainter* painter, \sa QwtRasterData::intensity(), QwtColorMap::rgb(), QwtColorMap::colorIndex() */ -QImage QwtPolarSpectrogram::renderImage( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, const QRect& rect ) const +QImage QwtPolarSpectrogram::renderImage(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, + const QPointF &pole, + const QRect &rect) const { - if ( m_data->data == NULL || m_data->colorMap == NULL ) - return QImage(); + if (m_data->data == NULL || m_data->colorMap == NULL) + return QImage(); - QImage image( rect.size(), m_data->colorMap->format() == QwtColorMap::RGB - ? QImage::Format_ARGB32 : QImage::Format_Indexed8 ); - - const QwtInterval intensityRange = m_data->data->interval( Qt::ZAxis ); - if ( !intensityRange.isValid() ) - return image; - - if ( m_data->colorMap->format() == QwtColorMap::Indexed ) - image.setColorTable( m_data->colorMap->colorTable256() ); - - /* - For the moment we only announce the composition of the image by - calling initRaster(), but we don't pass any useful parameters. - ( How to map rect into something, that is useful to initialize a matrix - of values in polar coordinates ? ) - */ - m_data->data->initRaster( QRectF(), QSize() ); - - -#if !defined( QT_NO_QFUTURE ) - uint numThreads = renderThreadCount(); - - if ( numThreads <= 0 ) - numThreads = QThread::idealThreadCount(); - - if ( numThreads <= 0 ) - numThreads = 1; - - const int numRows = rect.height() / numThreads; - - - QVector< TileInfo > tileInfos; - for ( uint i = 0; i < numThreads; i++ ) - { - QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows ); - if ( i == numThreads - 1 ) - tile.setHeight( rect.height() - i * numRows ); - - TileInfo tileInfo; - tileInfo.imagePos = rect.topLeft(); - tileInfo.rect = tile; - tileInfo.image = ℑ - - tileInfos += tileInfo; - } - - QVector< QFuture< void > > futures; - for ( int i = 0; i < tileInfos.size(); i++ ) - { - if ( i == tileInfos.size() - 1 ) - { - renderTileInfo( azimuthMap, radialMap, pole, &tileInfos[i] ); - } - else - { - futures += QtConcurrent::run( -#if QT_VERSION >= 0x060000 - &QwtPolarSpectrogram::renderTileInfo, this, -#else - this, &QwtPolarSpectrogram::renderTileInfo, -#endif - azimuthMap, radialMap, pole, &tileInfos[i] ); - } - } - - for ( int i = 0; i < futures.size(); i++ ) - futures[i].waitForFinished(); - -#else - renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image ); -#endif - - m_data->data->discardRaster(); + QImage image(rect.size(), m_data->colorMap->format() == QwtColorMap::RGB + ? QImage::Format_ARGB32 + : QImage::Format_Indexed8); + const QwtInterval intensityRange = m_data->data->interval(Qt::ZAxis); + if (!intensityRange.isValid()) return image; + + if (m_data->colorMap->format() == QwtColorMap::Indexed) + image.setColorTable(m_data->colorMap->colorTable256()); + + /* + For the moment we only announce the composition of the image by + calling initRaster(), but we don't pass any useful parameters. + ( How to map rect into something, that is useful to initialize a matrix + of values in polar coordinates ? ) + */ + m_data->data->initRaster(QRectF(), QSize()); + +#if !defined(QT_NO_QFUTURE) + uint numThreads = renderThreadCount(); + + if (numThreads <= 0) + numThreads = QThread::idealThreadCount(); + + if (numThreads <= 0) + numThreads = 1; + + const int numRows = rect.height() / numThreads; + + QVector tileInfos; + for (uint i = 0; i < numThreads; i++) + { + QRect tile(rect.x(), rect.y() + i * numRows, rect.width(), numRows); + if (i == numThreads - 1) + tile.setHeight(rect.height() - i * numRows); + + TileInfo tileInfo; + tileInfo.imagePos = rect.topLeft(); + tileInfo.rect = tile; + tileInfo.image = ℑ + + tileInfos += tileInfo; + } + + QVector> futures; + for (int i = 0; i < tileInfos.size(); i++) + { + if (i == tileInfos.size() - 1) + { + renderTileInfo(azimuthMap, radialMap, pole, &tileInfos[i]); + } + else + { + futures += QtConcurrent::run( +# if QT_VERSION >= 0x060000 + &QwtPolarSpectrogram::renderTileInfo, this, +# else + this, &QwtPolarSpectrogram::renderTileInfo, +# endif + azimuthMap, radialMap, pole, &tileInfos[i]); + } + } + + for (int i = 0; i < futures.size(); i++) + futures[i].waitForFinished(); + +#else + renderTile(azimuthMap, radialMap, pole, rect.topLeft(), rect, &image); +#endif + + m_data->data->discardRaster(); + + return image; } -void QwtPolarSpectrogram::renderTileInfo( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, TileInfo* tileInfo ) const +void QwtPolarSpectrogram::renderTileInfo(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, + const QPointF &pole, + TileInfo *tileInfo) const { - renderTile( azimuthMap, radialMap, pole, - tileInfo->imagePos, tileInfo->rect, tileInfo->image ); + renderTile(azimuthMap, radialMap, pole, tileInfo->imagePos, tileInfo->rect, + tileInfo->image); } /*! @@ -340,95 +341,97 @@ void QwtPolarSpectrogram::renderTileInfo( \sa setRenderThreadCount() \note renderTile needs to be reentrant */ -void QwtPolarSpectrogram::renderTile( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, const QPoint& imagePos, - const QRect& tile, QImage* image ) const +void QwtPolarSpectrogram::renderTile(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, + const QPointF &pole, + const QPoint &imagePos, const QRect &tile, + QImage *image) const { - const QwtInterval intensityRange = m_data->data->interval( Qt::ZAxis ); - if ( !intensityRange.isValid() ) - return; + const QwtInterval intensityRange = m_data->data->interval(Qt::ZAxis); + if (!intensityRange.isValid()) + return; - const bool doFastAtan = testPaintAttribute( ApproximatedAtan ); + const bool doFastAtan = testPaintAttribute(ApproximatedAtan); - const int y0 = imagePos.y(); - const int y1 = tile.top(); - const int y2 = tile.bottom(); + const int y0 = imagePos.y(); + const int y1 = tile.top(); + const int y2 = tile.bottom(); - const int x0 = imagePos.x(); - const int x1 = tile.left(); - const int x2 = tile.right(); + const int x0 = imagePos.x(); + const int x1 = tile.left(); + const int x2 = tile.right(); - if ( m_data->colorMap->format() == QwtColorMap::RGB ) + if (m_data->colorMap->format() == QwtColorMap::RGB) + { + for (int y = y1; y <= y2; y++) { - for ( int y = y1; y <= y2; y++ ) + const double dy = pole.y() - y; + const double dy2 = qwtSqr(dy); + + QRgb *line = reinterpret_cast(image->scanLine(y - y0)); + line += x1 - x0; + + for (int x = x1; x <= x2; x++) + { + const double dx = x - pole.x(); + + double a = doFastAtan ? qwtFastAtan2(dy, dx) : qAtan2(dy, dx); + + if (a < 0.0) + a += 2 * M_PI; + + if (a < azimuthMap.p1()) + a += 2 * M_PI; + + const double r = qSqrt(qwtSqr(dx) + dy2); + + const double azimuth = azimuthMap.invTransform(a); + const double radius = radialMap.invTransform(r); + + const double value = m_data->data->value(azimuth, radius); + if (qIsNaN(value)) { - const double dy = pole.y() - y; - const double dy2 = qwtSqr( dy ); - - QRgb* line = reinterpret_cast< QRgb* >( image->scanLine( y - y0 ) ); - line += x1 - x0; - - for ( int x = x1; x <= x2; x++ ) - { - const double dx = x - pole.x(); - - double a = doFastAtan ? qwtFastAtan2( dy, dx ) : qAtan2( dy, dx ); - - if ( a < 0.0 ) - a += 2 * M_PI; - - if ( a < azimuthMap.p1() ) - a += 2 * M_PI; - - const double r = qSqrt( qwtSqr( dx ) + dy2 ); - - const double azimuth = azimuthMap.invTransform( a ); - const double radius = radialMap.invTransform( r ); - - const double value = m_data->data->value( azimuth, radius ); - if ( qIsNaN( value ) ) - { - *line++ = 0u; - } - else - { - *line++ = m_data->colorMap->rgb( intensityRange, value ); - } - } + *line++ = 0u; } + else + { + *line++ = m_data->colorMap->rgb(intensityRange, value); + } + } } - else if ( m_data->colorMap->format() == QwtColorMap::Indexed ) + } + else if (m_data->colorMap->format() == QwtColorMap::Indexed) + { + for (int y = y1; y <= y2; y++) { - for ( int y = y1; y <= y2; y++ ) - { - const double dy = pole.y() - y; - const double dy2 = qwtSqr( dy ); + const double dy = pole.y() - y; + const double dy2 = qwtSqr(dy); - unsigned char* line = image->scanLine( y - y0 ); - line += x1 - x0; - for ( int x = x1; x <= x2; x++ ) - { - const double dx = x - pole.x(); + unsigned char *line = image->scanLine(y - y0); + line += x1 - x0; + for (int x = x1; x <= x2; x++) + { + const double dx = x - pole.x(); - double a = doFastAtan ? qwtFastAtan2( dy, dx ) : qAtan2( dy, dx ); - if ( a < 0.0 ) - a += 2 * M_PI; - if ( a < azimuthMap.p1() ) - a += 2 * M_PI; + double a = doFastAtan ? qwtFastAtan2(dy, dx) : qAtan2(dy, dx); + if (a < 0.0) + a += 2 * M_PI; + if (a < azimuthMap.p1()) + a += 2 * M_PI; - const double r = qSqrt( qwtSqr( dx ) + dy2 ); + const double r = qSqrt(qwtSqr(dx) + dy2); - const double azimuth = azimuthMap.invTransform( a ); - const double radius = radialMap.invTransform( r ); + const double azimuth = azimuthMap.invTransform(a); + const double radius = radialMap.invTransform(r); - const double value = m_data->data->value( azimuth, radius ); + const double value = m_data->data->value(azimuth, radius); - const uint index = m_data->colorMap->colorIndex( 256, intensityRange, value ); - *line++ = static_cast< unsigned char >( index ); - } - } + const uint index + = m_data->colorMap->colorIndex(256, intensityRange, value); + *line++ = static_cast(index); + } } + } } /*! @@ -440,10 +443,10 @@ void QwtPolarSpectrogram::renderTile( \sa position() */ -QwtInterval QwtPolarSpectrogram::boundingInterval( int scaleId ) const +QwtInterval QwtPolarSpectrogram::boundingInterval(int scaleId) const { - if ( scaleId == QwtPolar::ScaleRadius ) - return m_data->data->interval( Qt::YAxis ); + if (scaleId == QwtPolar::ScaleRadius) + return m_data->data->interval(Qt::YAxis); - return QwtPolarItem::boundingInterval( scaleId ); + return QwtPolarItem::boundingInterval(scaleId); } diff --git a/libs/qwt/src/qwt_polar_spectrogram.h b/libs/qwt/src/qwt_polar_spectrogram.h index eab3b5a1..61db33fa 100644 --- a/libs/qwt/src/qwt_polar_spectrogram.h +++ b/libs/qwt/src/qwt_polar_spectrogram.h @@ -27,65 +27,64 @@ class QwtColorMap; */ class QWT_EXPORT QwtPolarSpectrogram : public QwtPolarItem { - public: +public: + /*! + Attributes to modify the drawing algorithm. + The default setting disables ApproximatedAtan + + \sa setPaintAttribute(), testPaintAttribute() + */ + enum PaintAttribute + { /*! - Attributes to modify the drawing algorithm. - The default setting disables ApproximatedAtan - - \sa setPaintAttribute(), testPaintAttribute() + Use qwtFastAtan2 instead of atan2 for translating + widget into polar coordinates. */ - enum PaintAttribute - { - /*! - Use qwtFastAtan2 instead of atan2 for translating - widget into polar coordinates. - */ - ApproximatedAtan = 0x01 - }; + ApproximatedAtan = 0x01 + }; - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - explicit QwtPolarSpectrogram(); - virtual ~QwtPolarSpectrogram(); + explicit QwtPolarSpectrogram(); + virtual ~QwtPolarSpectrogram(); - void setData( QwtRasterData* data ); - const QwtRasterData* data() const; + void setData(QwtRasterData *data); + const QwtRasterData *data() const; - void setColorMap( QwtColorMap* ); - const QwtColorMap* colorMap() const; + void setColorMap(QwtColorMap *); + const QwtColorMap *colorMap() const; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - virtual int rtti() const QWT_OVERRIDE; + virtual int rtti() const QWT_OVERRIDE; - virtual void draw( QPainter* painter, - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, double radius, - const QRectF& canvasRect ) const QWT_OVERRIDE; + virtual void draw(QPainter *painter, const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + double radius, const QRectF &canvasRect) const QWT_OVERRIDE; - virtual QwtInterval boundingInterval( int scaleId ) const QWT_OVERRIDE; + virtual QwtInterval boundingInterval(int scaleId) const QWT_OVERRIDE; - protected: - virtual QImage renderImage( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, const QRect& rect ) const; +protected: + virtual QImage renderImage(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + const QRect &rect) const; - virtual void renderTile( - const QwtScaleMap& azimuthMap, const QwtScaleMap& radialMap, - const QPointF& pole, const QPoint& imagePos, - const QRect& tile, QImage* image ) const; + virtual void renderTile(const QwtScaleMap &azimuthMap, + const QwtScaleMap &radialMap, const QPointF &pole, + const QPoint &imagePos, const QRect &tile, + QImage *image) const; - private: - class TileInfo; - void renderTileInfo( const QwtScaleMap&, const QwtScaleMap&, - const QPointF& pole, TileInfo* ) const; +private: + class TileInfo; + void renderTileInfo(const QwtScaleMap &, const QwtScaleMap &, + const QPointF &pole, TileInfo *) const; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarSpectrogram::PaintAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPolarSpectrogram::PaintAttributes) #endif diff --git a/libs/qwt/src/qwt_raster_data.cpp b/libs/qwt/src/qwt_raster_data.cpp index afbf267f..1c34ebef 100644 --- a/libs/qwt/src/qwt_raster_data.cpp +++ b/libs/qwt/src/qwt_raster_data.cpp @@ -19,164 +19,161 @@ class QwtRasterData::ContourPlane { - public: - explicit inline ContourPlane( double z ): - m_z( z ) - { - } +public: + explicit inline ContourPlane(double z) + : m_z(z) + { + } - inline bool intersect( const QwtPoint3D vertex[3], - QPointF line[2], bool ignoreOnPlane ) const; + inline bool intersect(const QwtPoint3D vertex[3], QPointF line[2], + bool ignoreOnPlane) const; - inline double z() const { return m_z; } + inline double z() const { return m_z; } - private: - inline int compare( double z ) const; - inline QPointF intersection( - const QwtPoint3D& p1, const QwtPoint3D& p2 ) const; +private: + inline int compare(double z) const; + inline QPointF intersection(const QwtPoint3D &p1, const QwtPoint3D &p2) const; - double m_z; + double m_z; }; -inline bool QwtRasterData::ContourPlane::intersect( - const QwtPoint3D vertex[3], QPointF line[2], - bool ignoreOnPlane ) const +inline bool QwtRasterData::ContourPlane::intersect(const QwtPoint3D vertex[3], + QPointF line[2], + bool ignoreOnPlane) const { - bool found = true; + bool found = true; - // Are the vertices below (-1), on (0) or above (1) the plan ? - const int eq1 = compare( vertex[0].z() ); - const int eq2 = compare( vertex[1].z() ); - const int eq3 = compare( vertex[2].z() ); + // Are the vertices below (-1), on (0) or above (1) the plan ? + const int eq1 = compare(vertex[0].z()); + const int eq2 = compare(vertex[1].z()); + const int eq3 = compare(vertex[2].z()); - /* - (a) All the vertices lie below the contour level. - (b) Two vertices lie below and one on the contour level. - (c) Two vertices lie below and one above the contour level. - (d) One vertex lies below and two on the contour level. - (e) One vertex lies below, one on and one above the contour level. - (f) One vertex lies below and two above the contour level. - (g) Three vertices lie on the contour level. - (h) Two vertices lie on and one above the contour level. - (i) One vertex lies on and two above the contour level. - (j) All the vertices lie above the contour level. - */ + /* + (a) All the vertices lie below the contour level. + (b) Two vertices lie below and one on the contour level. + (c) Two vertices lie below and one above the contour level. + (d) One vertex lies below and two on the contour level. + (e) One vertex lies below, one on and one above the contour level. + (f) One vertex lies below and two above the contour level. + (g) Three vertices lie on the contour level. + (h) Two vertices lie on and one above the contour level. + (i) One vertex lies on and two above the contour level. + (j) All the vertices lie above the contour level. + */ - static const int tab[3][3][3] = - { - // jump table to avoid nested case statements - { { 0, 0, 8 }, { 0, 2, 5 }, { 7, 6, 9 } }, - { { 0, 3, 4 }, { 1, 10, 1 }, { 4, 3, 0 } }, - { { 9, 6, 7 }, { 5, 2, 0 }, { 8, 0, 0 } } - }; + static const int tab[3][3][3] = {// jump table to avoid nested case statements + {{0, 0, 8}, {0, 2, 5}, {7, 6, 9}}, + {{0, 3, 4}, {1, 10, 1}, {4, 3, 0}}, + {{9, 6, 7}, {5, 2, 0}, {8, 0, 0}}}; - const int edgeType = tab[eq1 + 1][eq2 + 1][eq3 + 1]; - switch ( edgeType ) - { - case 1: - // d(0,0,-1), h(0,0,1) - line[0] = vertex[0].toPoint(); - line[1] = vertex[1].toPoint(); - break; - case 2: - // d(-1,0,0), h(1,0,0) - line[0] = vertex[1].toPoint(); - line[1] = vertex[2].toPoint(); - break; - case 3: - // d(0,-1,0), h(0,1,0) - line[0] = vertex[2].toPoint(); - line[1] = vertex[0].toPoint(); - break; - case 4: - // e(0,-1,1), e(0,1,-1) - line[0] = vertex[0].toPoint(); - line[1] = intersection( vertex[1], vertex[2] ); - break; - case 5: - // e(-1,0,1), e(1,0,-1) - line[0] = vertex[1].toPoint(); - line[1] = intersection( vertex[2], vertex[0] ); - break; - case 6: - // e(-1,1,0), e(1,0,-1) - line[0] = vertex[2].toPoint(); - line[1] = intersection( vertex[0], vertex[1] ); - break; - case 7: - // c(-1,1,-1), f(1,1,-1) - line[0] = intersection( vertex[0], vertex[1] ); - line[1] = intersection( vertex[1], vertex[2] ); - break; - case 8: - // c(-1,-1,1), f(1,1,-1) - line[0] = intersection( vertex[1], vertex[2] ); - line[1] = intersection( vertex[2], vertex[0] ); - break; - case 9: - // f(-1,1,1), c(1,-1,-1) - line[0] = intersection( vertex[2], vertex[0] ); - line[1] = intersection( vertex[0], vertex[1] ); - break; - case 10: - // g(0,0,0) - // The CONREC algorithm has no satisfying solution for - // what to do, when all vertices are on the plane. + const int edgeType = tab[eq1 + 1][eq2 + 1][eq3 + 1]; + switch (edgeType) + { + case 1: + // d(0,0,-1), h(0,0,1) + line[0] = vertex[0].toPoint(); + line[1] = vertex[1].toPoint(); + break; + case 2: + // d(-1,0,0), h(1,0,0) + line[0] = vertex[1].toPoint(); + line[1] = vertex[2].toPoint(); + break; + case 3: + // d(0,-1,0), h(0,1,0) + line[0] = vertex[2].toPoint(); + line[1] = vertex[0].toPoint(); + break; + case 4: + // e(0,-1,1), e(0,1,-1) + line[0] = vertex[0].toPoint(); + line[1] = intersection(vertex[1], vertex[2]); + break; + case 5: + // e(-1,0,1), e(1,0,-1) + line[0] = vertex[1].toPoint(); + line[1] = intersection(vertex[2], vertex[0]); + break; + case 6: + // e(-1,1,0), e(1,0,-1) + line[0] = vertex[2].toPoint(); + line[1] = intersection(vertex[0], vertex[1]); + break; + case 7: + // c(-1,1,-1), f(1,1,-1) + line[0] = intersection(vertex[0], vertex[1]); + line[1] = intersection(vertex[1], vertex[2]); + break; + case 8: + // c(-1,-1,1), f(1,1,-1) + line[0] = intersection(vertex[1], vertex[2]); + line[1] = intersection(vertex[2], vertex[0]); + break; + case 9: + // f(-1,1,1), c(1,-1,-1) + line[0] = intersection(vertex[2], vertex[0]); + line[1] = intersection(vertex[0], vertex[1]); + break; + case 10: + // g(0,0,0) + // The CONREC algorithm has no satisfying solution for + // what to do, when all vertices are on the plane. - if ( ignoreOnPlane ) - found = false; - else - { - line[0] = vertex[2].toPoint(); - line[1] = vertex[0].toPoint(); - } - break; - default: - found = false; - } + if (ignoreOnPlane) + found = false; + else + { + line[0] = vertex[2].toPoint(); + line[1] = vertex[0].toPoint(); + } + break; + default: + found = false; + } - return found; + return found; } -inline int QwtRasterData::ContourPlane::compare( double z ) const +inline int QwtRasterData::ContourPlane::compare(double z) const { - if ( z > m_z ) - return 1; + if (z > m_z) + return 1; - if ( z < m_z ) - return -1; + if (z < m_z) + return -1; - return 0; + return 0; } -inline QPointF QwtRasterData::ContourPlane::intersection( - const QwtPoint3D& p1, const QwtPoint3D& p2 ) const +inline QPointF +QwtRasterData::ContourPlane::intersection(const QwtPoint3D &p1, + const QwtPoint3D &p2) const { - const double h1 = p1.z() - m_z; - const double h2 = p2.z() - m_z; + const double h1 = p1.z() - m_z; + const double h2 = p2.z() - m_z; - const double x = ( h2 * p1.x() - h1 * p2.x() ) / ( h2 - h1 ); - const double y = ( h2 * p1.y() - h1 * p2.y() ) / ( h2 - h1 ); + const double x = (h2 * p1.x() - h1 * p2.x()) / (h2 - h1); + const double y = (h2 * p1.y() - h1 * p2.y()) / (h2 - h1); - return QPointF( x, y ); + return QPointF(x, y); } class QwtRasterData::PrivateData { - public: - QwtRasterData::Attributes attributes; +public: + QwtRasterData::Attributes attributes; }; //! Constructor QwtRasterData::QwtRasterData() { - m_data = new PrivateData(); + m_data = new PrivateData(); } //! Destructor QwtRasterData::~QwtRasterData() { - delete m_data; + delete m_data; } /*! @@ -186,21 +183,21 @@ QwtRasterData::~QwtRasterData() \param on On/Off /sa Attribute, testAttribute() */ -void QwtRasterData::setAttribute( Attribute attribute, bool on ) +void QwtRasterData::setAttribute(Attribute attribute, bool on) { - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; } /*! \return True, when attribute is enabled \sa Attribute, setAttribute() */ -bool QwtRasterData::testAttribute( Attribute attribute ) const +bool QwtRasterData::testAttribute(Attribute attribute) const { - return m_data->attributes & attribute; + return m_data->attributes & attribute; } /*! @@ -218,10 +215,10 @@ bool QwtRasterData::testAttribute( Attribute attribute ) const \sa initRaster(), value() */ -void QwtRasterData::initRaster( const QRectF& area, const QSize& raster ) +void QwtRasterData::initRaster(const QRectF &area, const QSize &raster) { - Q_UNUSED( area ); - Q_UNUSED( raster ); + Q_UNUSED(area); + Q_UNUSED(raster); } /*! @@ -234,9 +231,7 @@ void QwtRasterData::initRaster( const QRectF& area, const QSize& raster ) \sa initRaster(), value() */ -void QwtRasterData::discardRaster() -{ -} +void QwtRasterData::discardRaster() {} /*! \brief Pixel hint @@ -264,10 +259,10 @@ void QwtRasterData::discardRaster() \return Bounding rectangle of a pixel */ -QRectF QwtRasterData::pixelHint( const QRectF& area ) const +QRectF QwtRasterData::pixelHint(const QRectF &area) const { - Q_UNUSED( area ); - return QRectF(); + Q_UNUSED(area); + return QRectF(); } /*! @@ -283,147 +278,137 @@ QRectF QwtRasterData::pixelHint( const QRectF& area ) const An adaption of CONREC, a simple contouring algorithm. http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/ */ -QwtRasterData::ContourLines QwtRasterData::contourLines( - const QRectF& rect, const QSize& raster, - const QList< double >& levels, ConrecFlags flags ) const +QwtRasterData::ContourLines +QwtRasterData::contourLines(const QRectF &rect, const QSize &raster, + const QList &levels, + ConrecFlags flags) const { - ContourLines contourLines; - - if ( levels.size() == 0 || !rect.isValid() || !raster.isValid() ) - return contourLines; - - const double dx = rect.width() / raster.width(); - const double dy = rect.height() / raster.height(); - - const bool ignoreOnPlane = - flags & QwtRasterData::IgnoreAllVerticesOnLevel; - - const QwtInterval range = interval( Qt::ZAxis ); - bool ignoreOutOfRange = false; - if ( range.isValid() ) - ignoreOutOfRange = flags & IgnoreOutOfRange; - - QwtRasterData* that = const_cast< QwtRasterData* >( this ); - that->initRaster( rect, raster ); - - for ( int y = 0; y < raster.height() - 1; y++ ) - { - enum Position - { - Center, - - TopLeft, - TopRight, - BottomRight, - BottomLeft, - - NumPositions - }; - - QwtPoint3D xy[NumPositions]; - - for ( int x = 0; x < raster.width() - 1; x++ ) - { - const QPointF pos( rect.x() + x * dx, rect.y() + y * dy ); - - if ( x == 0 ) - { - xy[TopRight].setX( pos.x() ); - xy[TopRight].setY( pos.y() ); - xy[TopRight].setZ( - value( xy[TopRight].x(), xy[TopRight].y() ) - ); - - xy[BottomRight].setX( pos.x() ); - xy[BottomRight].setY( pos.y() + dy ); - xy[BottomRight].setZ( - value( xy[BottomRight].x(), xy[BottomRight].y() ) - ); - } - - xy[TopLeft] = xy[TopRight]; - xy[BottomLeft] = xy[BottomRight]; - - xy[TopRight].setX( pos.x() + dx ); - xy[TopRight].setY( pos.y() ); - xy[BottomRight].setX( pos.x() + dx ); - xy[BottomRight].setY( pos.y() + dy ); - - xy[TopRight].setZ( - value( xy[TopRight].x(), xy[TopRight].y() ) - ); - xy[BottomRight].setZ( - value( xy[BottomRight].x(), xy[BottomRight].y() ) - ); - - double zMin = xy[TopLeft].z(); - double zMax = zMin; - double zSum = zMin; - - for ( int i = TopRight; i <= BottomLeft; i++ ) - { - const double z = xy[i].z(); - - zSum += z; - if ( z < zMin ) - zMin = z; - if ( z > zMax ) - zMax = z; - } - - if ( qIsNaN( zSum ) ) - { - // one of the points is NaN - continue; - } - - if ( ignoreOutOfRange ) - { - if ( !range.contains( zMin ) || !range.contains( zMax ) ) - continue; - } - - if ( zMax < levels[0] || - zMin > levels[levels.size() - 1] ) - { - continue; - } - - xy[Center].setX( pos.x() + 0.5 * dx ); - xy[Center].setY( pos.y() + 0.5 * dy ); - xy[Center].setZ( 0.25 * zSum ); - - const int numLevels = levels.size(); - for ( int l = 0; l < numLevels; l++ ) - { - const double level = levels[l]; - if ( level < zMin || level > zMax ) - continue; - QPolygonF& lines = contourLines[level]; - const ContourPlane plane( level ); - - QPointF line[2]; - QwtPoint3D vertex[3]; - - for ( int m = TopLeft; m < NumPositions; m++ ) - { - vertex[0] = xy[m]; - vertex[1] = xy[0]; - vertex[2] = xy[m != BottomLeft ? m + 1 : TopLeft]; - - const bool intersects = - plane.intersect( vertex, line, ignoreOnPlane ); - if ( intersects ) - { - lines += line[0]; - lines += line[1]; - } - } - } - } - } - - that->discardRaster(); + ContourLines contourLines; + if (levels.size() == 0 || !rect.isValid() || !raster.isValid()) return contourLines; + + const double dx = rect.width() / raster.width(); + const double dy = rect.height() / raster.height(); + + const bool ignoreOnPlane = flags & QwtRasterData::IgnoreAllVerticesOnLevel; + + const QwtInterval range = interval(Qt::ZAxis); + bool ignoreOutOfRange = false; + if (range.isValid()) + ignoreOutOfRange = flags & IgnoreOutOfRange; + + QwtRasterData *that = const_cast(this); + that->initRaster(rect, raster); + + for (int y = 0; y < raster.height() - 1; y++) + { + enum Position + { + Center, + + TopLeft, + TopRight, + BottomRight, + BottomLeft, + + NumPositions + }; + + QwtPoint3D xy[NumPositions]; + + for (int x = 0; x < raster.width() - 1; x++) + { + const QPointF pos(rect.x() + x * dx, rect.y() + y * dy); + + if (x == 0) + { + xy[TopRight].setX(pos.x()); + xy[TopRight].setY(pos.y()); + xy[TopRight].setZ(value(xy[TopRight].x(), xy[TopRight].y())); + + xy[BottomRight].setX(pos.x()); + xy[BottomRight].setY(pos.y() + dy); + xy[BottomRight].setZ(value(xy[BottomRight].x(), xy[BottomRight].y())); + } + + xy[TopLeft] = xy[TopRight]; + xy[BottomLeft] = xy[BottomRight]; + + xy[TopRight].setX(pos.x() + dx); + xy[TopRight].setY(pos.y()); + xy[BottomRight].setX(pos.x() + dx); + xy[BottomRight].setY(pos.y() + dy); + + xy[TopRight].setZ(value(xy[TopRight].x(), xy[TopRight].y())); + xy[BottomRight].setZ(value(xy[BottomRight].x(), xy[BottomRight].y())); + + double zMin = xy[TopLeft].z(); + double zMax = zMin; + double zSum = zMin; + + for (int i = TopRight; i <= BottomLeft; i++) + { + const double z = xy[i].z(); + + zSum += z; + if (z < zMin) + zMin = z; + if (z > zMax) + zMax = z; + } + + if (qIsNaN(zSum)) + { + // one of the points is NaN + continue; + } + + if (ignoreOutOfRange) + { + if (!range.contains(zMin) || !range.contains(zMax)) + continue; + } + + if (zMax < levels[0] || zMin > levels[levels.size() - 1]) + { + continue; + } + + xy[Center].setX(pos.x() + 0.5 * dx); + xy[Center].setY(pos.y() + 0.5 * dy); + xy[Center].setZ(0.25 * zSum); + + const int numLevels = levels.size(); + for (int l = 0; l < numLevels; l++) + { + const double level = levels[l]; + if (level < zMin || level > zMax) + continue; + QPolygonF &lines = contourLines[level]; + const ContourPlane plane(level); + + QPointF line[2]; + QwtPoint3D vertex[3]; + + for (int m = TopLeft; m < NumPositions; m++) + { + vertex[0] = xy[m]; + vertex[1] = xy[0]; + vertex[2] = xy[m != BottomLeft ? m + 1 : TopLeft]; + + const bool intersects = plane.intersect(vertex, line, ignoreOnPlane); + if (intersects) + { + lines += line[0]; + lines += line[1]; + } + } + } + } + } + + that->discardRaster(); + + return contourLines; } diff --git a/libs/qwt/src/qwt_raster_data.h b/libs/qwt/src/qwt_raster_data.h index 0bbaaa9d..4b03338e 100644 --- a/libs/qwt/src/qwt_raster_data.h +++ b/libs/qwt/src/qwt_raster_data.h @@ -17,8 +17,10 @@ class QwtInterval; class QPolygonF; class QRectF; class QSize; -template< typename T > class QList; -template< class Key, class T > class QMap; +template +class QList; +template +class QMap; /*! \brief QwtRasterData defines an interface to any type of raster data. @@ -41,89 +43,89 @@ template< class Key, class T > class QMap; */ class QWT_EXPORT QwtRasterData { - public: - //! Contour lines - typedef QMap< double, QPolygonF > ContourLines; +public: + //! Contour lines + typedef QMap ContourLines; + /*! + \brief Raster data attributes + + Additional information that is used to improve processing + of the data. + */ + enum Attribute + { /*! - \brief Raster data attributes + The bounding rectangle of the data is spanned by + the interval(Qt::XAxis) and interval(Qt::YAxis). - Additional information that is used to improve processing - of the data. + WithoutGaps indicates, that the data has no gaps + ( unknown values ) in this area and the result of + value() does not need to be checked for NaN values. + + Enabling this flag will have an positive effect on + the performance of rendering a QwtPlotSpectrogram. + + The default setting is false. + + \note NaN values indicate an undefined value */ - enum Attribute - { - /*! - The bounding rectangle of the data is spanned by - the interval(Qt::XAxis) and interval(Qt::YAxis). + WithoutGaps = 0x01 + }; - WithoutGaps indicates, that the data has no gaps - ( unknown values ) in this area and the result of - value() does not need to be checked for NaN values. + Q_DECLARE_FLAGS(Attributes, Attribute) - Enabling this flag will have an positive effect on - the performance of rendering a QwtPlotSpectrogram. + //! Flags to modify the contour algorithm + enum ConrecFlag + { + //! Ignore all vertices on the same level + IgnoreAllVerticesOnLevel = 0x01, - The default setting is false. + //! Ignore all values, that are out of range + IgnoreOutOfRange = 0x02 + }; - \note NaN values indicate an undefined value - */ - WithoutGaps = 0x01 - }; + Q_DECLARE_FLAGS(ConrecFlags, ConrecFlag) - Q_DECLARE_FLAGS( Attributes, Attribute ) + QwtRasterData(); + virtual ~QwtRasterData(); - //! Flags to modify the contour algorithm - enum ConrecFlag - { - //! Ignore all vertices on the same level - IgnoreAllVerticesOnLevel = 0x01, + void setAttribute(Attribute, bool on = true); + bool testAttribute(Attribute) const; - //! Ignore all values, that are out of range - IgnoreOutOfRange = 0x02 - }; + /*! + \return Bounding interval for an axis + \sa setInterval + */ + virtual QwtInterval interval(Qt::Axis) const = 0; - Q_DECLARE_FLAGS( ConrecFlags, ConrecFlag ) + virtual QRectF pixelHint(const QRectF &) const; - QwtRasterData(); - virtual ~QwtRasterData(); + virtual void initRaster(const QRectF &, const QSize &raster); + virtual void discardRaster(); - void setAttribute( Attribute, bool on = true ); - bool testAttribute( Attribute ) const; + /*! + \return the value at a raster position + \param x X value in plot coordinates + \param y Y value in plot coordinates + */ + virtual double value(double x, double y) const = 0; - /*! - \return Bounding interval for an axis - \sa setInterval - */ - virtual QwtInterval interval( Qt::Axis ) const = 0; + virtual ContourLines contourLines(const QRectF &rect, const QSize &raster, + const QList &levels, + ConrecFlags) const; - virtual QRectF pixelHint( const QRectF& ) const; + class Contour3DPoint; + class ContourPlane; - virtual void initRaster( const QRectF&, const QSize& raster ); - virtual void discardRaster(); +private: + Q_DISABLE_COPY(QwtRasterData) - /*! - \return the value at a raster position - \param x X value in plot coordinates - \param y Y value in plot coordinates - */ - virtual double value( double x, double y ) const = 0; - - virtual ContourLines contourLines( const QRectF& rect, - const QSize& raster, const QList< double >& levels, - ConrecFlags ) const; - - class Contour3DPoint; - class ContourPlane; - - private: - Q_DISABLE_COPY(QwtRasterData) - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtRasterData::ConrecFlags ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtRasterData::Attributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtRasterData::ConrecFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtRasterData::Attributes) #endif diff --git a/libs/qwt/src/qwt_round_scale_draw.cpp b/libs/qwt/src/qwt_round_scale_draw.cpp index f048430a..8fa0159e 100644 --- a/libs/qwt/src/qwt_round_scale_draw.cpp +++ b/libs/qwt/src/qwt_round_scale_draw.cpp @@ -18,20 +18,20 @@ class QwtRoundScaleDraw::PrivateData { - public: - PrivateData() - : center( 50.0, 50.0 ) - , radius( 50.0 ) - , startAngle( -135.0 ) - , endAngle( 135.0 ) - { - } +public: + PrivateData() + : center(50.0, 50.0) + , radius(50.0) + , startAngle(-135.0) + , endAngle(135.0) + { + } - QPointF center; - double radius; + QPointF center; + double radius; - double startAngle; - double endAngle; + double startAngle; + double endAngle; }; /*! @@ -43,16 +43,16 @@ class QwtRoundScaleDraw::PrivateData */ QwtRoundScaleDraw::QwtRoundScaleDraw() { - m_data = new QwtRoundScaleDraw::PrivateData; + m_data = new QwtRoundScaleDraw::PrivateData; - setRadius( 50 ); - scaleMap().setPaintInterval( m_data->startAngle, m_data->endAngle ); + setRadius(50); + scaleMap().setPaintInterval(m_data->startAngle, m_data->endAngle); } //! Destructor QwtRoundScaleDraw::~QwtRoundScaleDraw() { - delete m_data; + delete m_data; } /*! @@ -63,9 +63,9 @@ QwtRoundScaleDraw::~QwtRoundScaleDraw() \param radius New Radius \sa moveCenter() */ -void QwtRoundScaleDraw::setRadius( double radius ) +void QwtRoundScaleDraw::setRadius(double radius) { - m_data->radius = radius; + m_data->radius = radius; } /*! @@ -78,7 +78,7 @@ void QwtRoundScaleDraw::setRadius( double radius ) */ double QwtRoundScaleDraw::radius() const { - return m_data->radius; + return m_data->radius; } /*! @@ -87,15 +87,15 @@ double QwtRoundScaleDraw::radius() const \param center New center \sa setRadius() */ -void QwtRoundScaleDraw::moveCenter( const QPointF& center ) +void QwtRoundScaleDraw::moveCenter(const QPointF ¢er) { - m_data->center = center; + m_data->center = center; } //! Get the center of the scale QPointF QwtRoundScaleDraw::center() const { - return m_data->center; + return m_data->center; } /*! @@ -110,28 +110,28 @@ QPointF QwtRoundScaleDraw::center() const \warning
  • The angle range is limited to [-360, 360] degrees. Angles exceeding this range will be clipped. -
  • For angles more or equal than 360 degrees above or below min(angle1, angle2), - scale marks will not be drawn. -
  • If you need a counterclockwise scale, use QwtScaleDiv::setInterval() +
  • For angles more or equal than 360 degrees above or below min(angle1, + angle2), scale marks will not be drawn.
  • If you need a counterclockwise + scale, use QwtScaleDiv::setInterval()
*/ -void QwtRoundScaleDraw::setAngleRange( double angle1, double angle2 ) +void QwtRoundScaleDraw::setAngleRange(double angle1, double angle2) { #if 0 angle1 = qBound( -360.0, angle1, 360.0 ); angle2 = qBound( -360.0, angle2, 360.0 ); #endif - m_data->startAngle = angle1; - m_data->endAngle = angle2; + m_data->startAngle = angle1; + m_data->endAngle = angle2; - if ( m_data->startAngle == m_data->endAngle ) - { - m_data->startAngle -= 1; - m_data->endAngle += 1; - } + if (m_data->startAngle == m_data->endAngle) + { + m_data->startAngle -= 1; + m_data->endAngle += 1; + } - scaleMap().setPaintInterval( m_data->startAngle, m_data->endAngle ); + scaleMap().setPaintInterval(m_data->startAngle, m_data->endAngle); } /*! @@ -142,40 +142,40 @@ void QwtRoundScaleDraw::setAngleRange( double angle1, double angle2 ) \sa drawTick(), drawBackbone() */ -void QwtRoundScaleDraw::drawLabel( QPainter* painter, double value ) const +void QwtRoundScaleDraw::drawLabel(QPainter *painter, double value) const { - const double tval = scaleMap().transform( value ); - if ( ( tval >= m_data->startAngle + 360.0 ) - || ( tval <= m_data->startAngle - 360.0 ) ) - { - return; - } + const double tval = scaleMap().transform(value); + if ((tval >= m_data->startAngle + 360.0) + || (tval <= m_data->startAngle - 360.0)) + { + return; + } - const QwtText label = tickLabel( painter->font(), value ); - if ( label.isEmpty() ) - return; + const QwtText label = tickLabel(painter->font(), value); + if (label.isEmpty()) + return; - double radius = m_data->radius; - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) || - hasComponent( QwtAbstractScaleDraw::Backbone ) ) - { - radius += spacing(); - } + double radius = m_data->radius; + if (hasComponent(QwtAbstractScaleDraw::Ticks) + || hasComponent(QwtAbstractScaleDraw::Backbone)) + { + radius += spacing(); + } - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - radius += tickLength( QwtScaleDiv::MajorTick ); + if (hasComponent(QwtAbstractScaleDraw::Ticks)) + radius += tickLength(QwtScaleDiv::MajorTick); - const QSizeF sz = label.textSize( painter->font() ); - const double arc = qwtRadians( tval ); + const QSizeF sz = label.textSize(painter->font()); + const double arc = qwtRadians(tval); - const double x = m_data->center.x() + - ( radius + sz.width() / 2.0 ) * std::sin( arc ); - const double y = m_data->center.y() - - ( radius + sz.height() / 2.0 ) * std::cos( arc ); + const double x + = m_data->center.x() + (radius + sz.width() / 2.0) * std::sin(arc); + const double y + = m_data->center.y() - (radius + sz.height() / 2.0) * std::cos(arc); - const QRectF r( x - sz.width() / 2, y - sz.height() / 2, - sz.width(), sz.height() ); - label.draw( painter, r ); + const QRectF r(x - sz.width() / 2, y - sz.height() / 2, sz.width(), + sz.height()); + label.draw(painter, r); } /*! @@ -187,32 +187,33 @@ void QwtRoundScaleDraw::drawLabel( QPainter* painter, double value ) const \sa drawBackbone(), drawLabel() */ -void QwtRoundScaleDraw::drawTick( QPainter* painter, double value, double len ) const +void QwtRoundScaleDraw::drawTick(QPainter *painter, double value, + double len) const { - if ( len <= 0 ) - return; + if (len <= 0) + return; - const double tval = scaleMap().transform( value ); + const double tval = scaleMap().transform(value); - const double cx = m_data->center.x(); - const double cy = m_data->center.y(); - const double radius = m_data->radius; + const double cx = m_data->center.x(); + const double cy = m_data->center.y(); + const double radius = m_data->radius; - if ( ( tval < m_data->startAngle + 360.0 ) - && ( tval > m_data->startAngle - 360.0 ) ) - { - const double arc = qwtRadians( tval ); + if ((tval < m_data->startAngle + 360.0) + && (tval > m_data->startAngle - 360.0)) + { + const double arc = qwtRadians(tval); - const double sinArc = std::sin( arc ); - const double cosArc = std::cos( arc ); + const double sinArc = std::sin(arc); + const double cosArc = std::cos(arc); - const double x1 = cx + radius * sinArc; - const double x2 = cx + ( radius + len ) * sinArc; - const double y1 = cy - radius * cosArc; - const double y2 = cy - ( radius + len ) * cosArc; + const double x1 = cx + radius * sinArc; + const double x2 = cx + (radius + len) * sinArc; + const double y1 = cy - radius * cosArc; + const double y2 = cy - (radius + len) * cosArc; - QwtPainter::drawLine( painter, x1, y1, x2, y2 ); - } + QwtPainter::drawLine(painter, x1, y1, x2, y2); + } } /*! @@ -221,20 +222,20 @@ void QwtRoundScaleDraw::drawTick( QPainter* painter, double value, double len ) \sa drawTick(), drawLabel() */ -void QwtRoundScaleDraw::drawBackbone( QPainter* painter ) const +void QwtRoundScaleDraw::drawBackbone(QPainter *painter) const { - const double deg1 = scaleMap().p1(); - const double deg2 = scaleMap().p2(); + const double deg1 = scaleMap().p1(); + const double deg2 = scaleMap().p2(); - const int a1 = qRound( qwtMinF( deg1, deg2 ) - 90 ); - const int a2 = qRound( qwtMaxF( deg1, deg2 ) - 90 ); + const int a1 = qRound(qwtMinF(deg1, deg2) - 90); + const int a2 = qRound(qwtMaxF(deg1, deg2) - 90); - const double radius = m_data->radius; - const double x = m_data->center.x() - radius; - const double y = m_data->center.y() - radius; + const double radius = m_data->radius; + const double x = m_data->center.x() - radius; + const double y = m_data->center.y() - radius; - painter->drawArc( QRectF( x, y, 2 * radius, 2 * radius ), - -a2 * 16, ( a2 - a1 + 1 ) * 16 ); // counterclockwise + painter->drawArc(QRectF(x, y, 2 * radius, 2 * radius), -a2 * 16, + (a2 - a1 + 1) * 16); // counterclockwise } /*! @@ -252,61 +253,61 @@ void QwtRoundScaleDraw::drawBackbone( QPainter* painter ) const calculates only an upper limit, that might be a few pixels too large */ -double QwtRoundScaleDraw::extent( const QFont& font ) const +double QwtRoundScaleDraw::extent(const QFont &font) const { - double d = 0.0; + double d = 0.0; - if ( hasComponent( QwtAbstractScaleDraw::Labels ) ) + if (hasComponent(QwtAbstractScaleDraw::Labels)) + { + const QwtScaleDiv &sd = scaleDiv(); + const QList &ticks = sd.ticks(QwtScaleDiv::MajorTick); + for (int i = 0; i < ticks.count(); i++) { - const QwtScaleDiv& sd = scaleDiv(); - const QList< double >& ticks = sd.ticks( QwtScaleDiv::MajorTick ); - for ( int i = 0; i < ticks.count(); i++ ) - { - const double value = ticks[i]; - if ( !sd.contains( value ) ) - continue; + const double value = ticks[i]; + if (!sd.contains(value)) + continue; - const double tval = scaleMap().transform( value ); - if ( ( tval < m_data->startAngle + 360 ) - && ( tval > m_data->startAngle - 360 ) ) - { - const QwtText label = tickLabel( font, value ); - if ( label.isEmpty() ) - continue; + const double tval = scaleMap().transform(value); + if ((tval < m_data->startAngle + 360) + && (tval > m_data->startAngle - 360)) + { + const QwtText label = tickLabel(font, value); + if (label.isEmpty()) + continue; - const double arc = qwtRadians( tval ); + const double arc = qwtRadians(tval); - const QSizeF sz = label.textSize( font ); - const double off = qMax( sz.width(), sz.height() ); + const QSizeF sz = label.textSize(font); + const double off = qMax(sz.width(), sz.height()); - double x = off * std::sin( arc ); - double y = off * std::cos( arc ); + double x = off * std::sin(arc); + double y = off * std::cos(arc); - const double dist = std::sqrt( x * x + y * y ); - if ( dist > d ) - d = dist; - } - } + const double dist = std::sqrt(x * x + y * y); + if (dist > d) + d = dist; + } } + } - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - { - d += maxTickLength(); - } + if (hasComponent(QwtAbstractScaleDraw::Ticks)) + { + d += maxTickLength(); + } - if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) - { - d += qwtMaxF( penWidthF(), 1.0 ); - } + if (hasComponent(QwtAbstractScaleDraw::Backbone)) + { + d += qwtMaxF(penWidthF(), 1.0); + } - if ( hasComponent( QwtAbstractScaleDraw::Labels ) && - ( hasComponent( QwtAbstractScaleDraw::Ticks ) || - hasComponent( QwtAbstractScaleDraw::Backbone ) ) ) - { - d += spacing(); - } + if (hasComponent(QwtAbstractScaleDraw::Labels) + && (hasComponent(QwtAbstractScaleDraw::Ticks) + || hasComponent(QwtAbstractScaleDraw::Backbone))) + { + d += spacing(); + } - d = qwtMaxF( d, minimumExtent() ); + d = qwtMaxF(d, minimumExtent()); - return d; + return d; } diff --git a/libs/qwt/src/qwt_round_scale_draw.h b/libs/qwt/src/qwt_round_scale_draw.h index 8a52c7be..2d5c3818 100644 --- a/libs/qwt/src/qwt_round_scale_draw.h +++ b/libs/qwt/src/qwt_round_scale_draw.h @@ -30,40 +30,38 @@ class QWT_EXPORT QwtRoundScaleDraw : public QwtAbstractScaleDraw { - public: - QwtRoundScaleDraw(); - virtual ~QwtRoundScaleDraw(); +public: + QwtRoundScaleDraw(); + virtual ~QwtRoundScaleDraw(); - void setRadius( double radius ); - double radius() const; + void setRadius(double radius); + double radius() const; - void moveCenter( double x, double y ); - void moveCenter( const QPointF& ); - QPointF center() const; + void moveCenter(double x, double y); + void moveCenter(const QPointF &); + QPointF center() const; - void setAngleRange( double angle1, double angle2 ); + void setAngleRange(double angle1, double angle2); - virtual double extent( const QFont& ) const QWT_OVERRIDE; + virtual double extent(const QFont &) const QWT_OVERRIDE; - protected: - virtual void drawTick( QPainter*, - double value, double len ) const QWT_OVERRIDE; +protected: + virtual void drawTick(QPainter *, double value, + double len) const QWT_OVERRIDE; - virtual void drawBackbone( - QPainter* ) const QWT_OVERRIDE; + virtual void drawBackbone(QPainter *) const QWT_OVERRIDE; - virtual void drawLabel( - QPainter*, double value ) const QWT_OVERRIDE; + virtual void drawLabel(QPainter *, double value) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; //! Move the center of the scale draw, leaving the radius unchanged -inline void QwtRoundScaleDraw::moveCenter( double x, double y ) +inline void QwtRoundScaleDraw::moveCenter(double x, double y) { - moveCenter( QPointF( x, y ) ); + moveCenter(QPointF(x, y)); } #endif diff --git a/libs/qwt/src/qwt_samples.h b/libs/qwt/src/qwt_samples.h index 424b8269..fa3188b1 100644 --- a/libs/qwt/src/qwt_samples.h +++ b/libs/qwt/src/qwt_samples.h @@ -19,19 +19,19 @@ //! \brief A sample of the types (x1-x2, y) or (x, y1-y2) class QWT_EXPORT QwtIntervalSample { - public: - QwtIntervalSample(); - QwtIntervalSample( double, const QwtInterval& ); - QwtIntervalSample( double value, double min, double max ); +public: + QwtIntervalSample(); + QwtIntervalSample(double, const QwtInterval &); + QwtIntervalSample(double value, double min, double max); - bool operator==( const QwtIntervalSample& ) const; - bool operator!=( const QwtIntervalSample& ) const; + bool operator==(const QwtIntervalSample &) const; + bool operator!=(const QwtIntervalSample &) const; - //! Value - double value; + //! Value + double value; - //! Interval - QwtInterval interval; + //! Interval + QwtInterval interval; }; /*! @@ -39,53 +39,53 @@ class QWT_EXPORT QwtIntervalSample The value is set to 0.0, the interval is invalid */ inline QwtIntervalSample::QwtIntervalSample() - : value( 0.0 ) + : value(0.0) { } //! Constructor -inline QwtIntervalSample::QwtIntervalSample( double v, const QwtInterval& intv ) - : value( v ) - , interval( intv ) +inline QwtIntervalSample::QwtIntervalSample(double v, const QwtInterval &intv) + : value(v) + , interval(intv) { } //! Constructor -inline QwtIntervalSample::QwtIntervalSample( double v, double min, double max ) - : value( v ) - , interval( min, max ) +inline QwtIntervalSample::QwtIntervalSample(double v, double min, double max) + : value(v) + , interval(min, max) { } //! Compare operator -inline bool QwtIntervalSample::operator==( const QwtIntervalSample& other ) const +inline bool QwtIntervalSample::operator==(const QwtIntervalSample &other) const { - return value == other.value && interval == other.interval; + return value == other.value && interval == other.interval; } //! Compare operator -inline bool QwtIntervalSample::operator!=( const QwtIntervalSample& other ) const +inline bool QwtIntervalSample::operator!=(const QwtIntervalSample &other) const { - return !( *this == other ); + return !(*this == other); } //! \brief A sample of the types (x1...xn, y) or (x, y1..yn) class QWT_EXPORT QwtSetSample { - public: - QwtSetSample(); - explicit QwtSetSample( double, const QVector< double >& = QVector< double >( ) ); +public: + QwtSetSample(); + explicit QwtSetSample(double, const QVector & = QVector()); - bool operator==( const QwtSetSample& other ) const; - bool operator!=( const QwtSetSample& other ) const; + bool operator==(const QwtSetSample &other) const; + bool operator!=(const QwtSetSample &other) const; - double added() const; + double added() const; - //! value - double value; + //! value + double value; - //! Vector of values associated to value - QVector< double > set; + //! Vector of values associated to value + QVector set; }; /*! @@ -93,7 +93,7 @@ class QWT_EXPORT QwtSetSample The value is set to 0.0 */ inline QwtSetSample::QwtSetSample() - : value( 0.0 ) + : value(0.0) { } @@ -103,32 +103,32 @@ inline QwtSetSample::QwtSetSample() \param v Value \param s Set of values */ -inline QwtSetSample::QwtSetSample( double v, const QVector< double >& s ) - : value( v ) - , set( s ) +inline QwtSetSample::QwtSetSample(double v, const QVector &s) + : value(v) + , set(s) { } //! Compare operator -inline bool QwtSetSample::operator==( const QwtSetSample& other ) const +inline bool QwtSetSample::operator==(const QwtSetSample &other) const { - return value == other.value && set == other.set; + return value == other.value && set == other.set; } //! Compare operator -inline bool QwtSetSample::operator!=( const QwtSetSample& other ) const +inline bool QwtSetSample::operator!=(const QwtSetSample &other) const { - return !( *this == other ); + return !(*this == other); } //! \return All values of the set added inline double QwtSetSample::added() const { - double y = 0.0; - for ( int i = 0; i < set.size(); i++ ) - y += set[i]; + double y = 0.0; + for (int i = 0; i < set.size(); i++) + y += set[i]; - return y; + return y; } /*! @@ -142,32 +142,31 @@ inline double QwtSetSample::added() const */ class QWT_EXPORT QwtOHLCSample { - public: - QwtOHLCSample( double time = 0.0, - double open = 0.0, double high = 0.0, - double low = 0.0, double close = 0.0 ); +public: + QwtOHLCSample(double time = 0.0, double open = 0.0, double high = 0.0, + double low = 0.0, double close = 0.0); - QwtInterval boundingInterval() const; + QwtInterval boundingInterval() const; - bool isValid() const; + bool isValid() const; - /*! - Time of the sample, usually a number representing - a specific interval - like a day. - */ - double time; + /*! + Time of the sample, usually a number representing + a specific interval - like a day. + */ + double time; - //! Opening price - double open; + //! Opening price + double open; - //! Highest price - double high; + //! Highest price + double high; - //! Lowest price - double low; + //! Lowest price + double low; - //! Closing price - double close; + //! Closing price + double close; }; /*! @@ -179,13 +178,13 @@ class QWT_EXPORT QwtOHLCSample \param l Low value \param c Close value */ -inline QwtOHLCSample::QwtOHLCSample( - double t, double o, double h, double l, double c ) - : time( t ) - , open( o ) - , high( h ) - , low( l ) - , close( c ) +inline QwtOHLCSample::QwtOHLCSample(double t, double o, double h, double l, + double c) + : time(t) + , open(o) + , high(h) + , low(l) + , close(c) { } @@ -202,11 +201,8 @@ inline QwtOHLCSample::QwtOHLCSample( */ inline bool QwtOHLCSample::isValid() const { - return ( low <= high ) - && ( open >= low ) - && ( open <= high ) - && ( close >= low ) - && ( close <= high ); + return (low <= high) && (open >= low) && (open <= high) && (close >= low) + && (close <= high); } /*! @@ -219,17 +215,17 @@ inline bool QwtOHLCSample::isValid() const */ inline QwtInterval QwtOHLCSample::boundingInterval() const { - double minY = open; - minY = qMin( minY, high ); - minY = qMin( minY, low ); - minY = qMin( minY, close ); + double minY = open; + minY = qMin(minY, high); + minY = qMin(minY, low); + minY = qMin(minY, close); - double maxY = open; - maxY = qMax( maxY, high ); - maxY = qMax( maxY, low ); - maxY = qMax( maxY, close ); + double maxY = open; + maxY = qMax(maxY, high); + maxY = qMax(maxY, low); + maxY = qMax(maxY, close); - return QwtInterval( minY, maxY ); + return QwtInterval(minY, maxY); } /*! @@ -242,28 +238,27 @@ inline QwtInterval QwtOHLCSample::boundingInterval() const */ class QWT_EXPORT QwtVectorFieldSample { - public: - QwtVectorFieldSample( double x = 0.0, double y = 0.0, - double vx = 0.0, double vy = 0.0 ); +public: + QwtVectorFieldSample(double x = 0.0, double y = 0.0, double vx = 0.0, + double vy = 0.0); - QwtVectorFieldSample( const QPointF& pos, - double vx = 0.0, double vy = 0.0 ); + QwtVectorFieldSample(const QPointF &pos, double vx = 0.0, double vy = 0.0); - QPointF pos() const; + QPointF pos() const; - bool isNull() const; + bool isNull() const; - //! x coordinate of the position - double x; + //! x coordinate of the position + double x; - //! y coordinate of the position - double y; + //! y coordinate of the position + double y; - //! x coordinate of the vector - double vx; + //! x coordinate of the vector + double vx; - //! y coordinate of the vector - double vy; + //! y coordinate of the vector + double vy; }; /*! @@ -274,12 +269,13 @@ class QWT_EXPORT QwtVectorFieldSample \param vectorX x coordinate of the vector \param vectorY y coordinate of the vector */ -inline QwtVectorFieldSample::QwtVectorFieldSample( - double posX, double posY, double vectorX, double vectorY ) - : x( posX ) - , y( posY ) - , vx( vectorX ) - , vy( vectorY ) +inline QwtVectorFieldSample::QwtVectorFieldSample(double posX, double posY, + double vectorX, + double vectorY) + : x(posX) + , y(posY) + , vx(vectorX) + , vy(vectorY) { } @@ -290,25 +286,26 @@ inline QwtVectorFieldSample::QwtVectorFieldSample( \param vectorX x coordinate of the vector \param vectorY y coordinate of the vector */ -inline QwtVectorFieldSample::QwtVectorFieldSample( - const QPointF& pos, double vectorX, double vectorY ) - : x( pos.x() ) - , y( pos.y() ) - , vx( vectorX ) - , vy( vectorY ) +inline QwtVectorFieldSample::QwtVectorFieldSample(const QPointF &pos, + double vectorX, + double vectorY) + : x(pos.x()) + , y(pos.y()) + , vx(vectorX) + , vy(vectorY) { } //! \return x/y coordinates as QPointF inline QPointF QwtVectorFieldSample::pos() const { - return QPointF( x, y ); + return QPointF(x, y); } //! \return true, if vx and vy are 0 inline bool QwtVectorFieldSample::isNull() const { - return ( vx == 0.0 ) && ( vy == 0.0 ); + return (vx == 0.0) && (vy == 0.0); } #endif diff --git a/libs/qwt/src/qwt_sampling_thread.cpp b/libs/qwt/src/qwt_sampling_thread.cpp index 8230bb7c..19a60b46 100644 --- a/libs/qwt/src/qwt_sampling_thread.cpp +++ b/libs/qwt/src/qwt_sampling_thread.cpp @@ -12,23 +12,23 @@ class QwtSamplingThread::PrivateData { - public: - QElapsedTimer timer; - double msecsInterval; +public: + QElapsedTimer timer; + double msecsInterval; }; //! Constructor -QwtSamplingThread::QwtSamplingThread( QObject* parent ) - : QThread( parent ) +QwtSamplingThread::QwtSamplingThread(QObject *parent) + : QThread(parent) { - m_data = new PrivateData; - m_data->msecsInterval = 1e3; // 1 second + m_data = new PrivateData; + m_data->msecsInterval = 1e3; // 1 second } //! Destructor QwtSamplingThread::~QwtSamplingThread() { - delete m_data; + delete m_data; } /*! @@ -38,12 +38,12 @@ QwtSamplingThread::~QwtSamplingThread() \param msecs Interval \sa interval() */ -void QwtSamplingThread::setInterval( double msecs ) +void QwtSamplingThread::setInterval(double msecs) { - if ( msecs < 0.0 ) - msecs = 0.0; + if (msecs < 0.0) + msecs = 0.0; - m_data->msecsInterval = msecs; + m_data->msecsInterval = msecs; } /*! @@ -52,7 +52,7 @@ void QwtSamplingThread::setInterval( double msecs ) */ double QwtSamplingThread::interval() const { - return m_data->msecsInterval; + return m_data->msecsInterval; } /*! @@ -61,10 +61,10 @@ double QwtSamplingThread::interval() const */ double QwtSamplingThread::elapsed() const { - if ( m_data->timer.isValid() ) - return m_data->timer.nsecsElapsed() / 1e6; + if (m_data->timer.isValid()) + return m_data->timer.nsecsElapsed() / 1e6; - return 0.0; + return 0.0; } /*! @@ -73,7 +73,7 @@ double QwtSamplingThread::elapsed() const */ void QwtSamplingThread::stop() { - m_data->timer.invalidate(); + m_data->timer.invalidate(); } /*! @@ -82,31 +82,31 @@ void QwtSamplingThread::stop() */ void QwtSamplingThread::run() { - m_data->timer.start(); + m_data->timer.start(); - /* - We should have all values in nsecs/qint64, but - this would break existing code. TODO ... - Anyway - for QThread::usleep we even need microseconds( usecs ) - */ - while ( m_data->timer.isValid() ) + /* + We should have all values in nsecs/qint64, but + this would break existing code. TODO ... + Anyway - for QThread::usleep we even need microseconds( usecs ) + */ + while (m_data->timer.isValid()) + { + const qint64 timestamp = m_data->timer.nsecsElapsed(); + sample(timestamp / 1e9); // seconds + + if (m_data->msecsInterval > 0.0) { - const qint64 timestamp = m_data->timer.nsecsElapsed(); - sample( timestamp / 1e9 ); // seconds + const double interval = m_data->msecsInterval * 1e3; + const double elapsed = (m_data->timer.nsecsElapsed() - timestamp) / 1e3; - if ( m_data->msecsInterval > 0.0 ) - { - const double interval = m_data->msecsInterval * 1e3; - const double elapsed = ( m_data->timer.nsecsElapsed() - timestamp ) / 1e3; + const double usecs = interval - elapsed; - const double usecs = interval - elapsed; - - if ( usecs > 0.0 ) - QThread::usleep( qRound( usecs ) ); - } + if (usecs > 0.0) + QThread::usleep(qRound(usecs)); } + } } #if QWT_MOC_INCLUDE -#include "moc_qwt_sampling_thread.cpp" +# include "moc_qwt_sampling_thread.cpp" #endif diff --git a/libs/qwt/src/qwt_sampling_thread.h b/libs/qwt/src/qwt_sampling_thread.h index 1cafbb4f..2562dacc 100644 --- a/libs/qwt/src/qwt_sampling_thread.h +++ b/libs/qwt/src/qwt_sampling_thread.h @@ -27,36 +27,36 @@ */ class QWT_EXPORT QwtSamplingThread : public QThread { - Q_OBJECT + Q_OBJECT - public: - virtual ~QwtSamplingThread(); +public: + virtual ~QwtSamplingThread(); - double interval() const; - double elapsed() const; + double interval() const; + double elapsed() const; - public Q_SLOTS: - void setInterval( double interval ); - void stop(); +public Q_SLOTS: + void setInterval(double interval); + void stop(); - protected: - explicit QwtSamplingThread( QObject* parent = NULL ); +protected: + explicit QwtSamplingThread(QObject *parent = NULL); - virtual void run() QWT_OVERRIDE; + virtual void run() QWT_OVERRIDE; - /*! - Collect a sample + /*! + Collect a sample - \param elapsed Time since the thread was started in seconds - \note Due to a bug in previous version elapsed was passed as - seconds instead of miliseconds. To avoid breaking existing - code we stay with seconds for now. - */ - virtual void sample( double elapsed ) = 0; + \param elapsed Time since the thread was started in seconds + \note Due to a bug in previous version elapsed was passed as + seconds instead of miliseconds. To avoid breaking existing + code we stay with seconds for now. + */ + virtual void sample(double elapsed) = 0; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_scale_div.cpp b/libs/qwt/src/qwt_scale_div.cpp index b9e43ab7..b1fddb2e 100644 --- a/libs/qwt/src/qwt_scale_div.cpp +++ b/libs/qwt/src/qwt_scale_div.cpp @@ -18,9 +18,9 @@ \note lowerBound might be greater than upperBound for inverted scales */ -QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound ) - : m_lowerBound( lowerBound ) - , m_upperBound( upperBound ) +QwtScaleDiv::QwtScaleDiv(double lowerBound, double upperBound) + : m_lowerBound(lowerBound) + , m_upperBound(upperBound) { } @@ -30,13 +30,13 @@ QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound ) \param interval Interval \param ticks List of major, medium and minor ticks */ -QwtScaleDiv::QwtScaleDiv( const QwtInterval& interval, - QList< double > ticks[NTickTypes] ) - : m_lowerBound( interval.minValue() ) - , m_upperBound( interval.maxValue() ) +QwtScaleDiv::QwtScaleDiv(const QwtInterval &interval, + QList ticks[NTickTypes]) + : m_lowerBound(interval.minValue()) + , m_upperBound(interval.maxValue()) { - for ( int i = 0; i < NTickTypes; i++ ) - m_ticks[i] = ticks[i]; + for (int i = 0; i < NTickTypes; i++) + m_ticks[i] = ticks[i]; } /*! @@ -48,13 +48,13 @@ QwtScaleDiv::QwtScaleDiv( const QwtInterval& interval, \note lowerBound might be greater than upperBound for inverted scales */ -QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, - QList< double > ticks[NTickTypes] ) - : m_lowerBound( lowerBound ) - , m_upperBound( upperBound ) +QwtScaleDiv::QwtScaleDiv(double lowerBound, double upperBound, + QList ticks[NTickTypes]) + : m_lowerBound(lowerBound) + , m_upperBound(upperBound) { - for ( int i = 0; i < NTickTypes; i++ ) - m_ticks[i] = ticks[i]; + for (int i = 0; i < NTickTypes; i++) + m_ticks[i] = ticks[i]; } /*! @@ -68,16 +68,16 @@ QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, \note lowerBound might be greater than upperBound for inverted scales */ -QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, - const QList< double >& minorTicks, - const QList< double >& mediumTicks, - const QList< double >& majorTicks ) - : m_lowerBound( lowerBound ) - , m_upperBound( upperBound ) +QwtScaleDiv::QwtScaleDiv(double lowerBound, double upperBound, + const QList &minorTicks, + const QList &mediumTicks, + const QList &majorTicks) + : m_lowerBound(lowerBound) + , m_upperBound(upperBound) { - m_ticks[ MinorTick ] = minorTicks; - m_ticks[ MediumTick ] = mediumTicks; - m_ticks[ MajorTick ] = majorTicks; + m_ticks[MinorTick] = minorTicks; + m_ticks[MediumTick] = mediumTicks; + m_ticks[MajorTick] = majorTicks; } /*! @@ -88,10 +88,10 @@ QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound, \note lowerBound might be greater than upperBound for inverted scales */ -void QwtScaleDiv::setInterval( double lowerBound, double upperBound ) +void QwtScaleDiv::setInterval(double lowerBound, double upperBound) { - m_lowerBound = lowerBound; - m_upperBound = upperBound; + m_lowerBound = lowerBound; + m_upperBound = upperBound; } /*! @@ -99,10 +99,10 @@ void QwtScaleDiv::setInterval( double lowerBound, double upperBound ) \param interval Interval */ -void QwtScaleDiv::setInterval( const QwtInterval& interval ) +void QwtScaleDiv::setInterval(const QwtInterval &interval) { - m_lowerBound = interval.minValue(); - m_upperBound = interval.maxValue(); + m_lowerBound = interval.minValue(); + m_upperBound = interval.maxValue(); } /*! @@ -110,7 +110,7 @@ void QwtScaleDiv::setInterval( const QwtInterval& interval ) */ QwtInterval QwtScaleDiv::interval() const { - return QwtInterval( m_lowerBound, m_upperBound ); + return QwtInterval(m_lowerBound, m_upperBound); } /*! @@ -119,9 +119,9 @@ QwtInterval QwtScaleDiv::interval() const \param lowerBound First boundary \sa lowerBound(), setUpperBound() */ -void QwtScaleDiv::setLowerBound( double lowerBound ) +void QwtScaleDiv::setLowerBound(double lowerBound) { - m_lowerBound = lowerBound; + m_lowerBound = lowerBound; } /*! @@ -130,7 +130,7 @@ void QwtScaleDiv::setLowerBound( double lowerBound ) */ double QwtScaleDiv::lowerBound() const { - return m_lowerBound; + return m_lowerBound; } /*! @@ -139,9 +139,9 @@ double QwtScaleDiv::lowerBound() const \param upperBound Second boundary \sa upperBound(), setLowerBound() */ -void QwtScaleDiv::setUpperBound( double upperBound ) +void QwtScaleDiv::setUpperBound(double upperBound) { - m_upperBound = upperBound; + m_upperBound = upperBound; } /*! @@ -150,7 +150,7 @@ void QwtScaleDiv::setUpperBound( double upperBound ) */ double QwtScaleDiv::upperBound() const { - return m_upperBound; + return m_upperBound; } /*! @@ -158,49 +158,48 @@ double QwtScaleDiv::upperBound() const */ double QwtScaleDiv::range() const { - return m_upperBound - m_lowerBound; + return m_upperBound - m_lowerBound; } /*! \brief Equality operator \return true if this instance is equal to other */ -bool QwtScaleDiv::operator==( const QwtScaleDiv& other ) const +bool QwtScaleDiv::operator==(const QwtScaleDiv &other) const { - if ( m_lowerBound != other.m_lowerBound || - m_upperBound != other.m_upperBound ) - { - return false; - } + if (m_lowerBound != other.m_lowerBound || m_upperBound != other.m_upperBound) + { + return false; + } - for ( int i = 0; i < NTickTypes; i++ ) - { - if ( m_ticks[i] != other.m_ticks[i] ) - return false; - } + for (int i = 0; i < NTickTypes; i++) + { + if (m_ticks[i] != other.m_ticks[i]) + return false; + } - return true; + return true; } /*! \brief Inequality \return true if this instance is not equal to other */ -bool QwtScaleDiv::operator!=( const QwtScaleDiv& other ) const +bool QwtScaleDiv::operator!=(const QwtScaleDiv &other) const { - return ( !( *this == other ) ); + return (!(*this == other)); } //! Check if the scale division is empty( lowerBound() == upperBound() ) bool QwtScaleDiv::isEmpty() const { - return ( m_lowerBound == m_upperBound ); + return (m_lowerBound == m_upperBound); } //! Check if the scale division is increasing( lowerBound() <= upperBound() ) bool QwtScaleDiv::isIncreasing() const { - return m_lowerBound <= m_upperBound; + return m_lowerBound <= m_upperBound; } /*! @@ -209,12 +208,12 @@ bool QwtScaleDiv::isIncreasing() const \param value Value \return true/false */ -bool QwtScaleDiv::contains( double value ) const +bool QwtScaleDiv::contains(double value) const { - const double min = qMin( m_lowerBound, m_upperBound ); - const double max = qMax( m_lowerBound, m_upperBound ); + const double min = qMin(m_lowerBound, m_upperBound); + const double max = qMax(m_lowerBound, m_upperBound); - return value >= min && value <= max; + return value >= min && value <= max; } /*! @@ -223,18 +222,18 @@ bool QwtScaleDiv::contains( double value ) const */ void QwtScaleDiv::invert() { - qSwap( m_lowerBound, m_upperBound ); + qSwap(m_lowerBound, m_upperBound); - for ( int i = 0; i < NTickTypes; i++ ) - { - QList< double >& ticks = m_ticks[i]; + for (int i = 0; i < NTickTypes; i++) + { + QList &ticks = m_ticks[i]; - const int size = ticks.count(); - const int size2 = size / 2; + const int size = ticks.count(); + const int size2 = size / 2; - for ( int j = 0; j < size2; j++ ) - qSwap( ticks[j], ticks[size - 1 - j] ); - } + for (int j = 0; j < size2; j++) + qSwap(ticks[j], ticks[size - 1 - j]); + } } /*! @@ -243,10 +242,10 @@ void QwtScaleDiv::invert() */ QwtScaleDiv QwtScaleDiv::inverted() const { - QwtScaleDiv other = *this; - other.invert(); + QwtScaleDiv other = *this; + other.invert(); - return other; + return other; } /*! @@ -260,32 +259,30 @@ QwtScaleDiv QwtScaleDiv::inverted() const \note lowerBound might be greater than upperBound for inverted scales */ -QwtScaleDiv QwtScaleDiv::bounded( - double lowerBound, double upperBound ) const +QwtScaleDiv QwtScaleDiv::bounded(double lowerBound, double upperBound) const { - const double min = qMin( lowerBound, upperBound ); - const double max = qMax( lowerBound, upperBound ); + const double min = qMin(lowerBound, upperBound); + const double max = qMax(lowerBound, upperBound); - QwtScaleDiv sd; - sd.setInterval( lowerBound, upperBound ); + QwtScaleDiv sd; + sd.setInterval(lowerBound, upperBound); - for ( int tickType = 0; tickType < QwtScaleDiv::NTickTypes; tickType++ ) + for (int tickType = 0; tickType < QwtScaleDiv::NTickTypes; tickType++) + { + const QList &ticks = m_ticks[tickType]; + + QList boundedTicks; + for (int i = 0; i < ticks.size(); i++) { - const QList< double >& ticks = m_ticks[ tickType ]; - - QList< double > boundedTicks; - for ( int i = 0; i < ticks.size(); i++ ) - { - const double tick = ticks[i]; - if ( tick >= min && tick <= max ) - boundedTicks += tick; - } - - sd.setTicks( tickType, boundedTicks ); + const double tick = ticks[i]; + if (tick >= min && tick <= max) + boundedTicks += tick; } - return sd; + sd.setTicks(tickType, boundedTicks); + } + return sd; } /*! @@ -294,10 +291,10 @@ QwtScaleDiv QwtScaleDiv::bounded( \param tickType MinorTick, MediumTick or MajorTick \param ticks Values of the tick positions */ -void QwtScaleDiv::setTicks( int tickType, const QList< double >& ticks ) +void QwtScaleDiv::setTicks(int tickType, const QList &ticks) { - if ( tickType >= 0 && tickType < NTickTypes ) - m_ticks[tickType] = ticks; + if (tickType >= 0 && tickType < NTickTypes) + m_ticks[tickType] = ticks; } /*! @@ -306,27 +303,26 @@ void QwtScaleDiv::setTicks( int tickType, const QList< double >& ticks ) \param tickType MinorTick, MediumTick or MajorTick \return Tick list */ -QList< double > QwtScaleDiv::ticks( int tickType ) const +QList QwtScaleDiv::ticks(int tickType) const { - if ( tickType >= 0 && tickType < NTickTypes ) - return m_ticks[tickType]; + if (tickType >= 0 && tickType < NTickTypes) + return m_ticks[tickType]; - return QList< double >(); + return QList(); } #ifndef QT_NO_DEBUG_STREAM -#include +# include -QDebug operator<<( QDebug debug, const QwtScaleDiv& scaleDiv ) +QDebug operator<<(QDebug debug, const QwtScaleDiv &scaleDiv) { - debug << scaleDiv.lowerBound() << "<->" << scaleDiv.upperBound(); - debug << "Major: " << scaleDiv.ticks( QwtScaleDiv::MajorTick ); - debug << "Medium: " << scaleDiv.ticks( QwtScaleDiv::MediumTick ); - debug << "Minor: " << scaleDiv.ticks( QwtScaleDiv::MinorTick ); + debug << scaleDiv.lowerBound() << "<->" << scaleDiv.upperBound(); + debug << "Major: " << scaleDiv.ticks(QwtScaleDiv::MajorTick); + debug << "Medium: " << scaleDiv.ticks(QwtScaleDiv::MediumTick); + debug << "Minor: " << scaleDiv.ticks(QwtScaleDiv::MinorTick); - return debug; + return debug; } #endif - diff --git a/libs/qwt/src/qwt_scale_div.h b/libs/qwt/src/qwt_scale_div.h index 8b37da5f..da018d28 100644 --- a/libs/qwt/src/qwt_scale_div.h +++ b/libs/qwt/src/qwt_scale_div.h @@ -32,76 +32,76 @@ class QwtInterval; class QWT_EXPORT QwtScaleDiv { - public: - //! Scale tick types - enum TickType - { - //! No ticks - NoTick = -1, +public: + //! Scale tick types + enum TickType + { + //! No ticks + NoTick = -1, - //! Minor ticks - MinorTick, + //! Minor ticks + MinorTick, - //! Medium ticks - MediumTick, + //! Medium ticks + MediumTick, - //! Major ticks - MajorTick, + //! Major ticks + MajorTick, - //! Number of valid tick types - NTickTypes - }; + //! Number of valid tick types + NTickTypes + }; - explicit QwtScaleDiv( double lowerBound = 0.0, - double upperBound = 0.0 ); + explicit QwtScaleDiv(double lowerBound = 0.0, double upperBound = 0.0); - explicit QwtScaleDiv( const QwtInterval&, QList< double >[NTickTypes] ); + explicit QwtScaleDiv(const QwtInterval &, QList[NTickTypes]); - explicit QwtScaleDiv( double lowerBound, double upperBound, - QList< double >[NTickTypes] ); + explicit QwtScaleDiv(double lowerBound, double upperBound, + QList[NTickTypes]); - explicit QwtScaleDiv( double lowerBound, double upperBound, - const QList< double >& minorTicks, const QList< double >& mediumTicks, - const QList< double >& majorTicks ); + explicit QwtScaleDiv(double lowerBound, double upperBound, + const QList &minorTicks, + const QList &mediumTicks, + const QList &majorTicks); - bool operator==( const QwtScaleDiv& ) const; - bool operator!=( const QwtScaleDiv& ) const; + bool operator==(const QwtScaleDiv &) const; + bool operator!=(const QwtScaleDiv &) const; - void setInterval( double lowerBound, double upperBound ); - void setInterval( const QwtInterval& ); - QwtInterval interval() const; + void setInterval(double lowerBound, double upperBound); + void setInterval(const QwtInterval &); + QwtInterval interval() const; - void setLowerBound( double ); - double lowerBound() const; + void setLowerBound(double); + double lowerBound() const; - void setUpperBound( double ); - double upperBound() const; + void setUpperBound(double); + double upperBound() const; - double range() const; + double range() const; - bool contains( double value ) const; + bool contains(double value) const; - void setTicks( int tickType, const QList< double >& ); - QList< double > ticks( int tickType ) const; + void setTicks(int tickType, const QList &); + QList ticks(int tickType) const; - bool isEmpty() const; - bool isIncreasing() const; + bool isEmpty() const; + bool isIncreasing() const; - void invert(); - QwtScaleDiv inverted() const; + void invert(); + QwtScaleDiv inverted() const; - QwtScaleDiv bounded( double lowerBound, double upperBound ) const; + QwtScaleDiv bounded(double lowerBound, double upperBound) const; - private: - double m_lowerBound; - double m_upperBound; - QList< double > m_ticks[NTickTypes]; +private: + double m_lowerBound; + double m_upperBound; + QList m_ticks[NTickTypes]; }; -Q_DECLARE_TYPEINFO( QwtScaleDiv, Q_MOVABLE_TYPE ); +Q_DECLARE_TYPEINFO(QwtScaleDiv, Q_MOVABLE_TYPE); #ifndef QT_NO_DEBUG_STREAM -QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleDiv& ); +QWT_EXPORT QDebug operator<<(QDebug, const QwtScaleDiv &); #endif #endif diff --git a/libs/qwt/src/qwt_scale_draw.cpp b/libs/qwt/src/qwt_scale_draw.cpp index 9267a091..801c9bfa 100644 --- a/libs/qwt/src/qwt_scale_draw.cpp +++ b/libs/qwt/src/qwt_scale_draw.cpp @@ -18,268 +18,250 @@ #include #include -static inline double qwtEffectivePenWidth( const QwtAbstractScaleDraw* scaleDraw ) +static inline double qwtEffectivePenWidth(const QwtAbstractScaleDraw *scaleDraw) { - return qwtMaxF( scaleDraw->penWidthF(), 1.0 ); + return qwtMaxF(scaleDraw->penWidthF(), 1.0); } namespace QwtScaleRendererReal { - inline qreal penWidth( const QPainter* painter, const QwtScaleDraw* scaleDraw ) - { - qreal width = scaleDraw->penWidthF(); +inline qreal penWidth(const QPainter *painter, const QwtScaleDraw *scaleDraw) +{ + qreal width = scaleDraw->penWidthF(); #if 1 - if ( width <= 0.0 ) - width = 1.0; + if (width <= 0.0) + width = 1.0; #endif - if ( painter->pen().isCosmetic() ) - { - const QTransform& transform = painter->transform(); + if (painter->pen().isCosmetic()) + { + const QTransform &transform = painter->transform(); - switch ( scaleDraw->alignment() ) - { - case QwtScaleDraw::LeftScale: - case QwtScaleDraw::RightScale: - { - width /= transform.m11(); - break; - } - case QwtScaleDraw::TopScale: - case QwtScaleDraw::BottomScale: - { - width /= transform.m22(); - break; - } - } - } - - return width; - } - - inline void drawBackbone( QPainter* painter, const QwtScaleDraw* scaleDraw ) + switch (scaleDraw->alignment()) { - const qreal pw2 = 0.5 * penWidth( painter, scaleDraw ); - - const QPointF pos = scaleDraw->pos(); - const qreal length = scaleDraw->length(); - - switch ( scaleDraw->alignment() ) - { - case QwtScaleDraw::LeftScale: - { - const qreal x = pos.x() + 1.0 - pw2; - QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length ); - - break; - } - case QwtScaleDraw::RightScale: - { - const qreal x = pos.x() - 1.0 + pw2; - QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length ); - - break; - } - case QwtScaleDraw::TopScale: - { - const qreal y = pos.y() + 1.0 - pw2; - QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y ); - - break; - } - case QwtScaleDraw::BottomScale: - { - const qreal y = pos.y() - 1.0 + pw2; - QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y ); - - break; - } - } + case QwtScaleDraw::LeftScale: + case QwtScaleDraw::RightScale: { + width /= transform.m11(); + break; + } + case QwtScaleDraw::TopScale: + case QwtScaleDraw::BottomScale: { + width /= transform.m22(); + break; + } } + } - inline void drawTick( QPainter* painter, - const QwtScaleDraw* scaleDraw, qreal tickPos, qreal tickLength ) - { - const QPointF pos = scaleDraw->pos(); - - qreal pw = 0.0; - - if ( scaleDraw->hasComponent( QwtScaleDraw::Backbone ) ) - pw = penWidth( painter, scaleDraw ); - - const qreal length = tickLength + pw; - - /* - Those correction offsets have been found by try and error. - They need to be understood and replaced by a calculation, - that makes sense. TODO ... - */ - const qreal off1 = 1.0; - const qreal off2 = ( scaleDraw->penWidthF() <= 0.0 ) ? 0.5 : 0.0; - - switch ( scaleDraw->alignment() ) - { - case QwtScaleDraw::LeftScale: - { - const qreal x = pos.x() + off1 - off2; - QwtPainter::drawLine( painter, x, tickPos, x - length, tickPos ); - - break; - } - case QwtScaleDraw::RightScale: - { - const qreal x = pos.x() - off1 + off2; - QwtPainter::drawLine( painter, x, tickPos, x + length, tickPos ); - break; - } - case QwtScaleDraw::TopScale: - { - const qreal y = pos.y() + off1 - 2 * off2; - QwtPainter::drawLine( painter, tickPos, y, tickPos, y - length ); - - break; - } - case QwtScaleDraw::BottomScale: - { - const qreal y = pos.y() - off1 + off2; - QwtPainter::drawLine( painter, tickPos, y, tickPos, y + length ); - - break; - } - } - } + return width; } +inline void drawBackbone(QPainter *painter, const QwtScaleDraw *scaleDraw) +{ + const qreal pw2 = 0.5 * penWidth(painter, scaleDraw); + + const QPointF pos = scaleDraw->pos(); + const qreal length = scaleDraw->length(); + + switch (scaleDraw->alignment()) + { + case QwtScaleDraw::LeftScale: { + const qreal x = pos.x() + 1.0 - pw2; + QwtPainter::drawLine(painter, x, pos.y(), x, pos.y() + length); + + break; + } + case QwtScaleDraw::RightScale: { + const qreal x = pos.x() - 1.0 + pw2; + QwtPainter::drawLine(painter, x, pos.y(), x, pos.y() + length); + + break; + } + case QwtScaleDraw::TopScale: { + const qreal y = pos.y() + 1.0 - pw2; + QwtPainter::drawLine(painter, pos.x(), y, pos.x() + length, y); + + break; + } + case QwtScaleDraw::BottomScale: { + const qreal y = pos.y() - 1.0 + pw2; + QwtPainter::drawLine(painter, pos.x(), y, pos.x() + length, y); + + break; + } + } +} + +inline void drawTick(QPainter *painter, const QwtScaleDraw *scaleDraw, + qreal tickPos, qreal tickLength) +{ + const QPointF pos = scaleDraw->pos(); + + qreal pw = 0.0; + + if (scaleDraw->hasComponent(QwtScaleDraw::Backbone)) + pw = penWidth(painter, scaleDraw); + + const qreal length = tickLength + pw; + + /* + Those correction offsets have been found by try and error. + They need to be understood and replaced by a calculation, + that makes sense. TODO ... + */ + const qreal off1 = 1.0; + const qreal off2 = (scaleDraw->penWidthF() <= 0.0) ? 0.5 : 0.0; + + switch (scaleDraw->alignment()) + { + case QwtScaleDraw::LeftScale: { + const qreal x = pos.x() + off1 - off2; + QwtPainter::drawLine(painter, x, tickPos, x - length, tickPos); + + break; + } + case QwtScaleDraw::RightScale: { + const qreal x = pos.x() - off1 + off2; + QwtPainter::drawLine(painter, x, tickPos, x + length, tickPos); + break; + } + case QwtScaleDraw::TopScale: { + const qreal y = pos.y() + off1 - 2 * off2; + QwtPainter::drawLine(painter, tickPos, y, tickPos, y - length); + + break; + } + case QwtScaleDraw::BottomScale: { + const qreal y = pos.y() - off1 + off2; + QwtPainter::drawLine(painter, tickPos, y, tickPos, y + length); + + break; + } + } +} +} // namespace QwtScaleRendererReal + namespace QwtScaleRendererInt { - inline void drawBackbone( QPainter* painter, const QwtScaleDraw* scaleDraw ) - { - const int pw = qMax( qRound( scaleDraw->penWidthF() ), 1 ); +inline void drawBackbone(QPainter *painter, const QwtScaleDraw *scaleDraw) +{ + const int pw = qMax(qRound(scaleDraw->penWidthF()), 1); - const qreal length = scaleDraw->length(); - const QPointF pos = scaleDraw->pos(); + const qreal length = scaleDraw->length(); + const QPointF pos = scaleDraw->pos(); - switch ( scaleDraw->alignment() ) - { - case QwtScaleDraw::LeftScale: - { - const qreal x = qRound( pos.x() - ( pw - 1 ) / 2 ); - QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length ); + switch (scaleDraw->alignment()) + { + case QwtScaleDraw::LeftScale: { + const qreal x = qRound(pos.x() - (pw - 1) / 2); + QwtPainter::drawLine(painter, x, pos.y(), x, pos.y() + length); - break; - } - case QwtScaleDraw::RightScale: - { - const qreal x = qRound( pos.x() + pw / 2 ); - QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length ); - - break; - } - case QwtScaleDraw::TopScale: - { - const qreal y = qRound( pos.y() - ( pw - 1 ) / 2 ); - QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y ); - - break; - } - case QwtScaleDraw::BottomScale: - { - const qreal y = qRound( pos.y() + pw / 2 ); - QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y ); - - break; - } - } + break; } + case QwtScaleDraw::RightScale: { + const qreal x = qRound(pos.x() + pw / 2); + QwtPainter::drawLine(painter, x, pos.y(), x, pos.y() + length); - inline void drawTick( QPainter* painter, - const QwtScaleDraw* scaleDraw, qreal tickPos, qreal tickLength ) - { - const QPointF pos = scaleDraw->pos(); - tickPos = qRound( tickPos ); - - int pw = 0; - if ( scaleDraw->hasComponent( QwtScaleDraw::Backbone ) ) - pw = qMax( qRound( scaleDraw->penWidthF() ), 1 ); - - int len = qMax( qRound( tickLength ), 1 ); - - // the width of ticks at the borders might extent the backbone - len += pw; - - if ( painter->pen().capStyle() == Qt::FlatCap ) - len++; // the end point is not rendered - - qreal off = 0.0; - - if ( painter->paintEngine()->type() == QPaintEngine::X11 ) - { - if ( pw == 1 ) - { - // In opposite to raster, X11 paints the end point - off = 1.0; - } - } - - switch ( scaleDraw->alignment() ) - { - case QwtScaleDraw::LeftScale: - { - const qreal x1 = qRound( pos.x() ) + 1; - const qreal x2 = x1 - len + 1; - - QwtPainter::drawLine( painter, x2, tickPos, x1 - off, tickPos ); - - break; - } - case QwtScaleDraw::RightScale: - { - const qreal x1 = qRound( pos.x() ); - const qreal x2 = x1 + len - 1; - - QwtPainter::drawLine( painter, x1, tickPos, x2 - off, tickPos ); - - break; - } - case QwtScaleDraw::BottomScale: - { - const qreal y1 = qRound( pos.y() ); - const qreal y2 = y1 + len - 1; - - QwtPainter::drawLine( painter, tickPos, y1, tickPos, y2 - off ); - - break; - } - case QwtScaleDraw::TopScale: - { - const qreal y1 = qRound( pos.y() ); - const qreal y2 = y1 - len + 1; - - QwtPainter::drawLine( painter, tickPos, y2 + 1, tickPos, y1 + 1 - off ); - - break; - } - } + break; } + case QwtScaleDraw::TopScale: { + const qreal y = qRound(pos.y() - (pw - 1) / 2); + QwtPainter::drawLine(painter, pos.x(), y, pos.x() + length, y); + + break; + } + case QwtScaleDraw::BottomScale: { + const qreal y = qRound(pos.y() + pw / 2); + QwtPainter::drawLine(painter, pos.x(), y, pos.x() + length, y); + + break; + } + } } +inline void drawTick(QPainter *painter, const QwtScaleDraw *scaleDraw, + qreal tickPos, qreal tickLength) +{ + const QPointF pos = scaleDraw->pos(); + tickPos = qRound(tickPos); + + int pw = 0; + if (scaleDraw->hasComponent(QwtScaleDraw::Backbone)) + pw = qMax(qRound(scaleDraw->penWidthF()), 1); + + int len = qMax(qRound(tickLength), 1); + + // the width of ticks at the borders might extent the backbone + len += pw; + + if (painter->pen().capStyle() == Qt::FlatCap) + len++; // the end point is not rendered + + qreal off = 0.0; + + if (painter->paintEngine()->type() == QPaintEngine::X11) + { + if (pw == 1) + { + // In opposite to raster, X11 paints the end point + off = 1.0; + } + } + + switch (scaleDraw->alignment()) + { + case QwtScaleDraw::LeftScale: { + const qreal x1 = qRound(pos.x()) + 1; + const qreal x2 = x1 - len + 1; + + QwtPainter::drawLine(painter, x2, tickPos, x1 - off, tickPos); + + break; + } + case QwtScaleDraw::RightScale: { + const qreal x1 = qRound(pos.x()); + const qreal x2 = x1 + len - 1; + + QwtPainter::drawLine(painter, x1, tickPos, x2 - off, tickPos); + + break; + } + case QwtScaleDraw::BottomScale: { + const qreal y1 = qRound(pos.y()); + const qreal y2 = y1 + len - 1; + + QwtPainter::drawLine(painter, tickPos, y1, tickPos, y2 - off); + + break; + } + case QwtScaleDraw::TopScale: { + const qreal y1 = qRound(pos.y()); + const qreal y2 = y1 - len + 1; + + QwtPainter::drawLine(painter, tickPos, y2 + 1, tickPos, y1 + 1 - off); + + break; + } + } +} +} // namespace QwtScaleRendererInt + class QwtScaleDraw::PrivateData { - public: - PrivateData() - : len( 0 ) - , alignment( QwtScaleDraw::BottomScale ) - , labelRotation( 0.0 ) - { - } +public: + PrivateData() + : len(0) + , alignment(QwtScaleDraw::BottomScale) + , labelRotation(0.0) + { + } - QPointF pos; - double len; + QPointF pos; + double len; - Alignment alignment; + Alignment alignment; - Qt::Alignment labelAlignment; - double labelRotation; + Qt::Alignment labelAlignment; + double labelRotation; }; /*! @@ -291,14 +273,14 @@ class QwtScaleDraw::PrivateData */ QwtScaleDraw::QwtScaleDraw() { - m_data = new QwtScaleDraw::PrivateData; - setLength( 100 ); + m_data = new QwtScaleDraw::PrivateData; + setLength(100); } //! Destructor QwtScaleDraw::~QwtScaleDraw() { - delete m_data; + delete m_data; } /*! @@ -308,7 +290,7 @@ QwtScaleDraw::~QwtScaleDraw() */ QwtScaleDraw::Alignment QwtScaleDraw::alignment() const { - return m_data->alignment; + return m_data->alignment; } /*! @@ -319,9 +301,9 @@ QwtScaleDraw::Alignment QwtScaleDraw::alignment() const The default alignment is QwtScaleDraw::BottomScale \sa alignment() */ -void QwtScaleDraw::setAlignment( Alignment align ) +void QwtScaleDraw::setAlignment(Alignment align) { - m_data->alignment = align; + m_data->alignment = align; } /*! @@ -336,16 +318,16 @@ void QwtScaleDraw::setAlignment( Alignment align ) */ Qt::Orientation QwtScaleDraw::orientation() const { - switch ( m_data->alignment ) - { - case TopScale: - case BottomScale: - return Qt::Horizontal; - case LeftScale: - case RightScale: - default: - return Qt::Vertical; - } + switch (m_data->alignment) + { + case TopScale: + case BottomScale: + return Qt::Horizontal; + case LeftScale: + case RightScale: + default: + return Qt::Vertical; + } } /*! @@ -358,69 +340,69 @@ Qt::Orientation QwtScaleDraw::orientation() const \param start Start border distance \param end End border distance */ -void QwtScaleDraw::getBorderDistHint( - const QFont& font, int& start, int& end ) const +void QwtScaleDraw::getBorderDistHint(const QFont &font, int &start, + int &end) const { - start = 0; - end = 1.0; + start = 0; + end = 1.0; - if ( !hasComponent( QwtAbstractScaleDraw::Labels ) ) - return; + if (!hasComponent(QwtAbstractScaleDraw::Labels)) + return; - const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick ); - if ( ticks.count() == 0 ) - return; + const QList &ticks = scaleDiv().ticks(QwtScaleDiv::MajorTick); + if (ticks.count() == 0) + return; - // Find the ticks, that are mapped to the borders. - // minTick is the tick, that is mapped to the top/left-most position - // in widget coordinates. + // Find the ticks, that are mapped to the borders. + // minTick is the tick, that is mapped to the top/left-most position + // in widget coordinates. - double minTick = ticks[0]; - double minPos = scaleMap().transform( minTick ); - double maxTick = minTick; - double maxPos = minPos; + double minTick = ticks[0]; + double minPos = scaleMap().transform(minTick); + double maxTick = minTick; + double maxPos = minPos; - for ( int i = 1; i < ticks.count(); i++ ) + for (int i = 1; i < ticks.count(); i++) + { + const double tickPos = scaleMap().transform(ticks[i]); + if (tickPos < minPos) { - const double tickPos = scaleMap().transform( ticks[i] ); - if ( tickPos < minPos ) - { - minTick = ticks[i]; - minPos = tickPos; - } - if ( tickPos > scaleMap().transform( maxTick ) ) - { - maxTick = ticks[i]; - maxPos = tickPos; - } + minTick = ticks[i]; + minPos = tickPos; } - - double e = 0.0; - double s = 0.0; - if ( orientation() == Qt::Vertical ) + if (tickPos > scaleMap().transform(maxTick)) { - s = -labelRect( font, minTick ).top(); - s -= qAbs( minPos - qRound( scaleMap().p2() ) ); - - e = labelRect( font, maxTick ).bottom(); - e -= qAbs( maxPos - scaleMap().p1() ); + maxTick = ticks[i]; + maxPos = tickPos; } - else - { - s = -labelRect( font, minTick ).left(); - s -= qAbs( minPos - scaleMap().p1() ); + } - e = labelRect( font, maxTick ).right(); - e -= qAbs( maxPos - scaleMap().p2() ); - } + double e = 0.0; + double s = 0.0; + if (orientation() == Qt::Vertical) + { + s = -labelRect(font, minTick).top(); + s -= qAbs(minPos - qRound(scaleMap().p2())); - if ( s < 0.0 ) - s = 0.0; - if ( e < 0.0 ) - e = 0.0; + e = labelRect(font, maxTick).bottom(); + e -= qAbs(maxPos - scaleMap().p1()); + } + else + { + s = -labelRect(font, minTick).left(); + s -= qAbs(minPos - scaleMap().p1()); - start = qwtCeil( s ); - end = qwtCeil( e ); + e = labelRect(font, maxTick).right(); + e -= qAbs(maxPos - scaleMap().p2()); + } + + if (s < 0.0) + s = 0.0; + if (e < 0.0) + e = 0.0; + + start = qwtCeil(s); + end = qwtCeil(e); } /*! @@ -433,78 +415,77 @@ void QwtScaleDraw::getBorderDistHint( \sa getBorderDistHint() */ -int QwtScaleDraw::minLabelDist( const QFont& font ) const +int QwtScaleDraw::minLabelDist(const QFont &font) const { - if ( !hasComponent( QwtAbstractScaleDraw::Labels ) ) - return 0; + if (!hasComponent(QwtAbstractScaleDraw::Labels)) + return 0; - const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick ); - if ( ticks.isEmpty() ) - return 0; + const QList &ticks = scaleDiv().ticks(QwtScaleDiv::MajorTick); + if (ticks.isEmpty()) + return 0; - const QFontMetrics fm( font ); + const QFontMetrics fm(font); - const bool vertical = ( orientation() == Qt::Vertical ); + const bool vertical = (orientation() == Qt::Vertical); - QRectF bRect1; - QRectF bRect2 = labelRect( font, ticks[0] ); - if ( vertical ) + QRectF bRect1; + QRectF bRect2 = labelRect(font, ticks[0]); + if (vertical) + { + bRect2.setRect(-bRect2.bottom(), 0.0, bRect2.height(), bRect2.width()); + } + + double maxDist = 0.0; + + for (int i = 1; i < ticks.count(); i++) + { + bRect1 = bRect2; + bRect2 = labelRect(font, ticks[i]); + if (vertical) { - bRect2.setRect( -bRect2.bottom(), 0.0, bRect2.height(), bRect2.width() ); + bRect2.setRect(-bRect2.bottom(), 0.0, bRect2.height(), bRect2.width()); } - double maxDist = 0.0; + double dist = fm.leading(); // space between the labels + if (bRect1.right() > 0) + dist += bRect1.right(); + if (bRect2.left() < 0) + dist += -bRect2.left(); - for ( int i = 1; i < ticks.count(); i++ ) - { - bRect1 = bRect2; - bRect2 = labelRect( font, ticks[i] ); - if ( vertical ) - { - bRect2.setRect( -bRect2.bottom(), 0.0, - bRect2.height(), bRect2.width() ); - } + if (dist > maxDist) + maxDist = dist; + } - double dist = fm.leading(); // space between the labels - if ( bRect1.right() > 0 ) - dist += bRect1.right(); - if ( bRect2.left() < 0 ) - dist += -bRect2.left(); + double angle = qwtRadians(labelRotation()); + if (vertical) + angle += M_PI / 2; - if ( dist > maxDist ) - maxDist = dist; - } + const double sinA = qFastSin(angle); // qreal -> double + if (qFuzzyCompare(sinA + 1.0, 1.0)) + return qCeil(maxDist); - double angle = qwtRadians( labelRotation() ); - if ( vertical ) - angle += M_PI / 2; + const int fmHeight = fm.ascent() - 2; - const double sinA = qFastSin( angle ); // qreal -> double - if ( qFuzzyCompare( sinA + 1.0, 1.0 ) ) - return qCeil( maxDist ); + // The distance we need until there is + // the height of the label font. This height is needed + // for the neighbored label. - const int fmHeight = fm.ascent() - 2; + double labelDist = fmHeight / qFastSin(angle) * qFastCos(angle); + if (labelDist < 0) + labelDist = -labelDist; - // The distance we need until there is - // the height of the label font. This height is needed - // for the neighbored label. + // For text orientations close to the scale orientation - double labelDist = fmHeight / qFastSin( angle ) * qFastCos( angle ); - if ( labelDist < 0 ) - labelDist = -labelDist; + if (labelDist > maxDist) + labelDist = maxDist; - // For text orientations close to the scale orientation + // For text orientations close to the opposite of the + // scale orientation - if ( labelDist > maxDist ) - labelDist = maxDist; + if (labelDist < fmHeight) + labelDist = fmHeight; - // For text orientations close to the opposite of the - // scale orientation - - if ( labelDist < fmHeight ) - labelDist = fmHeight; - - return qCeil( labelDist ); + return qCeil(labelDist); } /*! @@ -520,33 +501,33 @@ int QwtScaleDraw::minLabelDist( const QFont& font ) const \sa minLength() */ -double QwtScaleDraw::extent( const QFont& font ) const +double QwtScaleDraw::extent(const QFont &font) const { - double d = 0; + double d = 0; - if ( hasComponent( QwtAbstractScaleDraw::Labels ) ) - { - if ( orientation() == Qt::Vertical ) - d = maxLabelWidth( font ); - else - d = maxLabelHeight( font ); + if (hasComponent(QwtAbstractScaleDraw::Labels)) + { + if (orientation() == Qt::Vertical) + d = maxLabelWidth(font); + else + d = maxLabelHeight(font); - if ( d > 0 ) - d += spacing(); - } + if (d > 0) + d += spacing(); + } - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - { - d += maxTickLength(); - } + if (hasComponent(QwtAbstractScaleDraw::Ticks)) + { + d += maxTickLength(); + } - if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) - { - d += qwtEffectivePenWidth( this ); - } + if (hasComponent(QwtAbstractScaleDraw::Backbone)) + { + d += qwtEffectivePenWidth(this); + } - d = qwtMaxF( d, minimumExtent() ); - return d; + d = qwtMaxF(d, minimumExtent()); + return d; } /*! @@ -557,31 +538,29 @@ double QwtScaleDraw::extent( const QFont& font ) const \sa extent() */ -int QwtScaleDraw::minLength( const QFont& font ) const +int QwtScaleDraw::minLength(const QFont &font) const { - int startDist, endDist; - getBorderDistHint( font, startDist, endDist ); + int startDist, endDist; + getBorderDistHint(font, startDist, endDist); - const QwtScaleDiv& sd = scaleDiv(); + const QwtScaleDiv &sd = scaleDiv(); - const uint minorCount = - sd.ticks( QwtScaleDiv::MinorTick ).count() + - sd.ticks( QwtScaleDiv::MediumTick ).count(); - const uint majorCount = - sd.ticks( QwtScaleDiv::MajorTick ).count(); + const uint minorCount = sd.ticks(QwtScaleDiv::MinorTick).count() + + sd.ticks(QwtScaleDiv::MediumTick).count(); + const uint majorCount = sd.ticks(QwtScaleDiv::MajorTick).count(); - int lengthForLabels = 0; - if ( hasComponent( QwtAbstractScaleDraw::Labels ) ) - lengthForLabels = minLabelDist( font ) * majorCount; + int lengthForLabels = 0; + if (hasComponent(QwtAbstractScaleDraw::Labels)) + lengthForLabels = minLabelDist(font) * majorCount; - int lengthForTicks = 0; - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - { - const double pw = qwtEffectivePenWidth( this ); - lengthForTicks = qCeil( ( majorCount + minorCount ) * ( pw + 1.0 ) ); - } + int lengthForTicks = 0; + if (hasComponent(QwtAbstractScaleDraw::Ticks)) + { + const double pw = qwtEffectivePenWidth(this); + lengthForTicks = qCeil((majorCount + minorCount) * (pw + 1.0)); + } - return startDist + endDist + qMax( lengthForLabels, lengthForTicks ); + return startDist + endDist + qMax(lengthForLabels, lengthForTicks); } /*! @@ -593,48 +572,44 @@ int QwtScaleDraw::minLength( const QFont& font ) const \param value Value \return Position, where to paint a label */ -QPointF QwtScaleDraw::labelPosition( double value ) const +QPointF QwtScaleDraw::labelPosition(double value) const { - const double tval = scaleMap().transform( value ); - double dist = spacing(); - if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) - dist += qwtEffectivePenWidth( this ); + const double tval = scaleMap().transform(value); + double dist = spacing(); + if (hasComponent(QwtAbstractScaleDraw::Backbone)) + dist += qwtEffectivePenWidth(this); - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - dist += tickLength( QwtScaleDiv::MajorTick ); + if (hasComponent(QwtAbstractScaleDraw::Ticks)) + dist += tickLength(QwtScaleDiv::MajorTick); - double px = 0; - double py = 0; + double px = 0; + double py = 0; - switch ( alignment() ) - { - case RightScale: - { - px = m_data->pos.x() + dist; - py = tval; - break; - } - case LeftScale: - { - px = m_data->pos.x() - dist; - py = tval; - break; - } - case BottomScale: - { - px = tval; - py = m_data->pos.y() + dist; - break; - } - case TopScale: - { - px = tval; - py = m_data->pos.y() - dist; - break; - } + switch (alignment()) + { + case RightScale: { + px = m_data->pos.x() + dist; + py = tval; + break; } + case LeftScale: { + px = m_data->pos.x() - dist; + py = tval; + break; + } + case BottomScale: { + px = tval; + py = m_data->pos.y() + dist; + break; + } + case TopScale: { + px = tval; + py = m_data->pos.y() - dist; + break; + } + } - return QPointF( px, py ); + return QPointF(px, py); } /*! @@ -646,17 +621,17 @@ QPointF QwtScaleDraw::labelPosition( double value ) const \sa drawBackbone(), drawLabel() */ -void QwtScaleDraw::drawTick( QPainter* painter, double value, double len ) const +void QwtScaleDraw::drawTick(QPainter *painter, double value, double len) const { - if ( len <= 0 ) - return; + if (len <= 0) + return; - const double tval = scaleMap().transform( value ); + const double tval = scaleMap().transform(value); - if ( QwtPainter::roundingAlignment( painter ) ) - QwtScaleRendererInt::drawTick( painter, this, tval, len ); - else - QwtScaleRendererReal::drawTick( painter, this, tval, len ); + if (QwtPainter::roundingAlignment(painter)) + QwtScaleRendererInt::drawTick(painter, this, tval, len); + else + QwtScaleRendererReal::drawTick(painter, this, tval, len); } /*! @@ -665,12 +640,12 @@ void QwtScaleDraw::drawTick( QPainter* painter, double value, double len ) const \sa drawTick(), drawLabel() */ -void QwtScaleDraw::drawBackbone( QPainter* painter ) const +void QwtScaleDraw::drawBackbone(QPainter *painter) const { - if ( QwtPainter::roundingAlignment( painter ) ) - QwtScaleRendererInt::drawBackbone( painter, this ); - else - QwtScaleRendererReal::drawBackbone( painter, this ); + if (QwtPainter::roundingAlignment(painter)) + QwtScaleRendererInt::drawBackbone(painter, this); + else + QwtScaleRendererReal::drawBackbone(painter, this); } /*! @@ -704,10 +679,10 @@ void QwtScaleDraw::drawBackbone( QPainter* painter ) const \sa pos(), setLength() */ -void QwtScaleDraw::move( const QPointF& pos ) +void QwtScaleDraw::move(const QPointF &pos) { - m_data->pos = pos; - updateMap(); + m_data->pos = pos; + updateMap(); } /*! @@ -716,7 +691,7 @@ void QwtScaleDraw::move( const QPointF& pos ) */ QPointF QwtScaleDraw::pos() const { - return m_data->pos; + return m_data->pos; } /*! @@ -729,7 +704,7 @@ QPointF QwtScaleDraw::pos() const \sa move(), minLabelDist() */ -void QwtScaleDraw::setLength( double length ) +void QwtScaleDraw::setLength(double length) { #if 0 if ( length >= 0 && length < 10 ) @@ -739,11 +714,11 @@ void QwtScaleDraw::setLength( double length ) if ( length < 0 && length > -10 ) length = -10; #else - length = qwtMaxF( length, 10.0 ); + length = qwtMaxF(length, 10.0); #endif - m_data->len = length; - updateMap(); + m_data->len = length; + updateMap(); } /*! @@ -752,7 +727,7 @@ void QwtScaleDraw::setLength( double length ) */ double QwtScaleDraw::length() const { - return m_data->len; + return m_data->len; } /*! @@ -763,24 +738,24 @@ double QwtScaleDraw::length() const \sa drawTick(), drawBackbone(), boundingLabelRect() */ -void QwtScaleDraw::drawLabel( QPainter* painter, double value ) const +void QwtScaleDraw::drawLabel(QPainter *painter, double value) const { - QwtText lbl = tickLabel( painter->font(), value ); - if ( lbl.isEmpty() ) - return; + QwtText lbl = tickLabel(painter->font(), value); + if (lbl.isEmpty()) + return; - QPointF pos = labelPosition( value ); + QPointF pos = labelPosition(value); - QSizeF labelSize = lbl.textSize( painter->font() ); + QSizeF labelSize = lbl.textSize(painter->font()); - const QTransform transform = labelTransformation( pos, labelSize ); + const QTransform transform = labelTransformation(pos, labelSize); - painter->save(); - painter->setWorldTransform( transform, true ); + painter->save(); + painter->setWorldTransform(transform, true); - lbl.draw ( painter, QRect( QPoint( 0, 0 ), labelSize.toSize() ) ); + lbl.draw(painter, QRect(QPoint(0, 0), labelSize.toSize())); - painter->restore(); + painter->restore(); } /*! @@ -795,17 +770,17 @@ void QwtScaleDraw::drawLabel( QPainter* painter, double value ) const \return Bounding rectangle \sa labelRect() */ -QRect QwtScaleDraw::boundingLabelRect( const QFont& font, double value ) const +QRect QwtScaleDraw::boundingLabelRect(const QFont &font, double value) const { - QwtText lbl = tickLabel( font, value ); - if ( lbl.isEmpty() ) - return QRect(); + QwtText lbl = tickLabel(font, value); + if (lbl.isEmpty()) + return QRect(); - const QPointF pos = labelPosition( value ); - QSizeF labelSize = lbl.textSize( font ); + const QPointF pos = labelPosition(value); + QSizeF labelSize = lbl.textSize(font); - const QTransform transform = labelTransformation( pos, labelSize ); - return transform.mapRect( QRect( QPoint( 0, 0 ), labelSize.toSize() ) ); + const QTransform transform = labelTransformation(pos, labelSize); + return transform.mapRect(QRect(QPoint(0, 0), labelSize.toSize())); } /*! @@ -818,64 +793,60 @@ QRect QwtScaleDraw::boundingLabelRect( const QFont& font, double value ) const \return Transformation matrix \sa setLabelAlignment(), setLabelRotation() */ -QTransform QwtScaleDraw::labelTransformation( - const QPointF& pos, const QSizeF& size ) const +QTransform QwtScaleDraw::labelTransformation(const QPointF &pos, + const QSizeF &size) const { - QTransform transform; - transform.translate( pos.x(), pos.y() ); - transform.rotate( labelRotation() ); + QTransform transform; + transform.translate(pos.x(), pos.y()); + transform.rotate(labelRotation()); - int flags = labelAlignment(); - if ( flags == 0 ) + int flags = labelAlignment(); + if (flags == 0) + { + switch (alignment()) { - switch ( alignment() ) - { - case RightScale: - { - if ( flags == 0 ) - flags = Qt::AlignRight | Qt::AlignVCenter; - break; - } - case LeftScale: - { - if ( flags == 0 ) - flags = Qt::AlignLeft | Qt::AlignVCenter; - break; - } - case BottomScale: - { - if ( flags == 0 ) - flags = Qt::AlignHCenter | Qt::AlignBottom; - break; - } - case TopScale: - { - if ( flags == 0 ) - flags = Qt::AlignHCenter | Qt::AlignTop; - break; - } - } + case RightScale: { + if (flags == 0) + flags = Qt::AlignRight | Qt::AlignVCenter; + break; + } + case LeftScale: { + if (flags == 0) + flags = Qt::AlignLeft | Qt::AlignVCenter; + break; + } + case BottomScale: { + if (flags == 0) + flags = Qt::AlignHCenter | Qt::AlignBottom; + break; + } + case TopScale: { + if (flags == 0) + flags = Qt::AlignHCenter | Qt::AlignTop; + break; + } } + } - double x, y; + double x, y; - if ( flags & Qt::AlignLeft ) - x = -size.width(); - else if ( flags & Qt::AlignRight ) - x = 0.0; - else // Qt::AlignHCenter - x = -( 0.5 * size.width() ); + if (flags & Qt::AlignLeft) + x = -size.width(); + else if (flags & Qt::AlignRight) + x = 0.0; + else // Qt::AlignHCenter + x = -(0.5 * size.width()); - if ( flags & Qt::AlignTop ) - y = -size.height(); - else if ( flags & Qt::AlignBottom ) - y = 0; - else // Qt::AlignVCenter - y = -( 0.5 * size.height() ); + if (flags & Qt::AlignTop) + y = -size.height(); + else if (flags & Qt::AlignBottom) + y = 0; + else // Qt::AlignVCenter + y = -(0.5 * size.height()); - transform.translate( x, y ); + transform.translate(x, y); - return transform; + return transform; } /*! @@ -888,21 +859,21 @@ QTransform QwtScaleDraw::labelTransformation( \return Bounding rectangle that is needed to draw a label */ -QRectF QwtScaleDraw::labelRect( const QFont& font, double value ) const +QRectF QwtScaleDraw::labelRect(const QFont &font, double value) const { - QwtText lbl = tickLabel( font, value ); - if ( lbl.isEmpty() ) - return QRectF( 0.0, 0.0, 0.0, 0.0 ); + QwtText lbl = tickLabel(font, value); + if (lbl.isEmpty()) + return QRectF(0.0, 0.0, 0.0, 0.0); - const QPointF pos = labelPosition( value ); + const QPointF pos = labelPosition(value); - const QSizeF labelSize = lbl.textSize( font ); - const QTransform transform = labelTransformation( pos, labelSize ); + const QSizeF labelSize = lbl.textSize(font); + const QTransform transform = labelTransformation(pos, labelSize); - QRectF br = transform.mapRect( QRectF( QPointF( 0, 0 ), labelSize ) ); - br.translate( -pos.x(), -pos.y() ); + QRectF br = transform.mapRect(QRectF(QPointF(0, 0), labelSize)); + br.translate(-pos.x(), -pos.y()); - return br; + return br; } /*! @@ -913,9 +884,9 @@ QRectF QwtScaleDraw::labelRect( const QFont& font, double value ) const \return Size that is needed to draw a label */ -QSizeF QwtScaleDraw::labelSize( const QFont& font, double value ) const +QSizeF QwtScaleDraw::labelSize(const QFont &font, double value) const { - return labelRect( font, value ).size(); + return labelRect(font, value).size(); } /*! @@ -931,9 +902,9 @@ QSizeF QwtScaleDraw::labelSize( const QFont& font, double value ) const \sa setLabelAlignment(), labelRotation(), labelAlignment(). */ -void QwtScaleDraw::setLabelRotation( double rotation ) +void QwtScaleDraw::setLabelRotation(double rotation) { - m_data->labelRotation = rotation; + m_data->labelRotation = rotation; } /*! @@ -942,7 +913,7 @@ void QwtScaleDraw::setLabelRotation( double rotation ) */ double QwtScaleDraw::labelRotation() const { - return m_data->labelRotation; + return m_data->labelRotation; } /*! @@ -970,9 +941,9 @@ double QwtScaleDraw::labelRotation() const ( QwtText::flags() ) returned from QwtAbstractScaleDraw::label(). */ -void QwtScaleDraw::setLabelAlignment( Qt::Alignment alignment ) +void QwtScaleDraw::setLabelAlignment(Qt::Alignment alignment) { - m_data->labelAlignment = alignment; + m_data->labelAlignment = alignment; } /*! @@ -981,63 +952,63 @@ void QwtScaleDraw::setLabelAlignment( Qt::Alignment alignment ) */ Qt::Alignment QwtScaleDraw::labelAlignment() const { - return m_data->labelAlignment; + return m_data->labelAlignment; } /*! \param font Font \return the maximum width of a label */ -int QwtScaleDraw::maxLabelWidth( const QFont& font ) const +int QwtScaleDraw::maxLabelWidth(const QFont &font) const { - double maxWidth = 0.0; + double maxWidth = 0.0; - const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick ); - for ( int i = 0; i < ticks.count(); i++ ) + const QList &ticks = scaleDiv().ticks(QwtScaleDiv::MajorTick); + for (int i = 0; i < ticks.count(); i++) + { + const double v = ticks[i]; + if (scaleDiv().contains(v)) { - const double v = ticks[i]; - if ( scaleDiv().contains( v ) ) - { - const double w = labelSize( font, ticks[i] ).width(); - if ( w > maxWidth ) - maxWidth = w; - } + const double w = labelSize(font, ticks[i]).width(); + if (w > maxWidth) + maxWidth = w; } + } - return qCeil( maxWidth ); + return qCeil(maxWidth); } /*! \param font Font \return the maximum height of a label */ -int QwtScaleDraw::maxLabelHeight( const QFont& font ) const +int QwtScaleDraw::maxLabelHeight(const QFont &font) const { - double maxHeight = 0.0; + double maxHeight = 0.0; - const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick ); - for ( int i = 0; i < ticks.count(); i++ ) + const QList &ticks = scaleDiv().ticks(QwtScaleDiv::MajorTick); + for (int i = 0; i < ticks.count(); i++) + { + const double v = ticks[i]; + if (scaleDiv().contains(v)) { - const double v = ticks[i]; - if ( scaleDiv().contains( v ) ) - { - const double h = labelSize( font, ticks[i] ).height(); - if ( h > maxHeight ) - maxHeight = h; - } + const double h = labelSize(font, ticks[i]).height(); + if (h > maxHeight) + maxHeight = h; } + } - return qCeil( maxHeight ); + return qCeil(maxHeight); } void QwtScaleDraw::updateMap() { - const QPointF pos = m_data->pos; - double len = m_data->len; + const QPointF pos = m_data->pos; + double len = m_data->len; - QwtScaleMap& sm = scaleMap(); - if ( orientation() == Qt::Vertical ) - sm.setPaintInterval( pos.y() + len, pos.y() ); - else - sm.setPaintInterval( pos.x(), pos.x() + len ); + QwtScaleMap &sm = scaleMap(); + if (orientation() == Qt::Vertical) + sm.setPaintInterval(pos.y() + len, pos.y()); + else + sm.setPaintInterval(pos.x(), pos.x() + len); } diff --git a/libs/qwt/src/qwt_scale_draw.h b/libs/qwt/src/qwt_scale_draw.h index 5bc23ada..5aa63f56 100644 --- a/libs/qwt/src/qwt_scale_draw.h +++ b/libs/qwt/src/qwt_scale_draw.h @@ -34,77 +34,77 @@ class QRect; */ class QWT_EXPORT QwtScaleDraw : public QwtAbstractScaleDraw { - public: - /*! - Alignment of the scale draw - \sa setAlignment(), alignment() - */ - enum Alignment - { - //! The scale is below - BottomScale, +public: + /*! + Alignment of the scale draw + \sa setAlignment(), alignment() + */ + enum Alignment + { + //! The scale is below + BottomScale, - //! The scale is above - TopScale, + //! The scale is above + TopScale, - //! The scale is left - LeftScale, + //! The scale is left + LeftScale, - //! The scale is right - RightScale - }; + //! The scale is right + RightScale + }; - QwtScaleDraw(); - virtual ~QwtScaleDraw(); + QwtScaleDraw(); + virtual ~QwtScaleDraw(); - void getBorderDistHint( const QFont&, int& start, int& end ) const; - int minLabelDist( const QFont& ) const; + void getBorderDistHint(const QFont &, int &start, int &end) const; + int minLabelDist(const QFont &) const; - int minLength( const QFont& ) const; - virtual double extent( const QFont& ) const QWT_OVERRIDE; + int minLength(const QFont &) const; + virtual double extent(const QFont &) const QWT_OVERRIDE; - void move( double x, double y ); - void move( const QPointF& ); - void setLength( double length ); + void move(double x, double y); + void move(const QPointF &); + void setLength(double length); - Alignment alignment() const; - void setAlignment( Alignment ); + Alignment alignment() const; + void setAlignment(Alignment); - Qt::Orientation orientation() const; + Qt::Orientation orientation() const; - QPointF pos() const; - double length() const; + QPointF pos() const; + double length() const; - void setLabelAlignment( Qt::Alignment ); - Qt::Alignment labelAlignment() const; + void setLabelAlignment(Qt::Alignment); + Qt::Alignment labelAlignment() const; - void setLabelRotation( double rotation ); - double labelRotation() const; + void setLabelRotation(double rotation); + double labelRotation() const; - int maxLabelHeight( const QFont& ) const; - int maxLabelWidth( const QFont& ) const; + int maxLabelHeight(const QFont &) const; + int maxLabelWidth(const QFont &) const; - QPointF labelPosition( double value ) const; + QPointF labelPosition(double value) const; - QRectF labelRect( const QFont&, double value ) const; - QSizeF labelSize( const QFont&, double value ) const; + QRectF labelRect(const QFont &, double value) const; + QSizeF labelSize(const QFont &, double value) const; - QRect boundingLabelRect( const QFont&, double value ) const; + QRect boundingLabelRect(const QFont &, double value) const; - protected: - QTransform labelTransformation( const QPointF&, const QSizeF& ) const; +protected: + QTransform labelTransformation(const QPointF &, const QSizeF &) const; - virtual void drawTick( QPainter*, - double value, double len ) const QWT_OVERRIDE; + virtual void drawTick(QPainter *, double value, + double len) const QWT_OVERRIDE; - virtual void drawBackbone( QPainter* ) const QWT_OVERRIDE; - virtual void drawLabel( QPainter*, double value ) const QWT_OVERRIDE; + virtual void drawBackbone(QPainter *) const QWT_OVERRIDE; + virtual void drawLabel(QPainter *, double value) const QWT_OVERRIDE; - private: - void updateMap(); +private: + void updateMap(); - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; /*! @@ -115,9 +115,9 @@ class QWT_EXPORT QwtScaleDraw : public QwtAbstractScaleDraw \sa move(const QPointF &) */ -inline void QwtScaleDraw::move( double x, double y ) +inline void QwtScaleDraw::move(double x, double y) { - move( QPointF( x, y ) ); + move(QPointF(x, y)); } #endif diff --git a/libs/qwt/src/qwt_scale_engine.cpp b/libs/qwt/src/qwt_scale_engine.cpp index 21ede709..181c98dc 100644 --- a/libs/qwt/src/qwt_scale_engine.cpp +++ b/libs/qwt/src/qwt_scale_engine.cpp @@ -16,79 +16,82 @@ #include -static inline double qwtLog( double base, double value ) +static inline double qwtLog(double base, double value) { - return std::log( value ) / std::log( base ); + return std::log(value) / std::log(base); } -static inline QwtInterval qwtLogInterval( double base, const QwtInterval& interval ) +static inline QwtInterval qwtLogInterval(double base, + const QwtInterval &interval) { - return QwtInterval( qwtLog( base, interval.minValue() ), - qwtLog( base, interval.maxValue() ) ); + return QwtInterval(qwtLog(base, interval.minValue()), + qwtLog(base, interval.maxValue())); } -static inline QwtInterval qwtPowInterval( double base, const QwtInterval& interval ) +static inline QwtInterval qwtPowInterval(double base, + const QwtInterval &interval) { - return QwtInterval( std::pow( base, interval.minValue() ), - std::pow( base, interval.maxValue() ) ); + return QwtInterval(std::pow(base, interval.minValue()), + std::pow(base, interval.maxValue())); } #if 1 // this version often doesn't find the best ticks: f.e for 15: 5, 10 -static double qwtStepSize( double intervalSize, int maxSteps, uint base ) +static double qwtStepSize(double intervalSize, int maxSteps, uint base) { - const double minStep = - QwtScaleArithmetic::divideInterval( intervalSize, maxSteps, base ); + const double minStep + = QwtScaleArithmetic::divideInterval(intervalSize, maxSteps, base); - if ( minStep != 0.0 ) + if (minStep != 0.0) + { + // # ticks per interval + const int numTicks = qwtCeil(qAbs(intervalSize / minStep)) - 1; + + // Do the minor steps fit into the interval? + if (qwtFuzzyCompare((numTicks + 1) * qAbs(minStep), qAbs(intervalSize), + intervalSize) + > 0) { - // # ticks per interval - const int numTicks = qwtCeil( qAbs( intervalSize / minStep ) ) - 1; - - // Do the minor steps fit into the interval? - if ( qwtFuzzyCompare( ( numTicks + 1 ) * qAbs( minStep ), - qAbs( intervalSize ), intervalSize ) > 0 ) - { - // The minor steps doesn't fit into the interval - return 0.5 * intervalSize; - } + // The minor steps doesn't fit into the interval + return 0.5 * intervalSize; } + } - return minStep; + return minStep; } #else -static double qwtStepSize( double intervalSize, int maxSteps, uint base ) +static double qwtStepSize(double intervalSize, int maxSteps, uint base) { - if ( maxSteps <= 0 ) - return 0.0; + if (maxSteps <= 0) + return 0.0; - if ( maxSteps > 2 ) + if (maxSteps > 2) + { + for (int numSteps = maxSteps; numSteps > 1; numSteps--) { - for ( int numSteps = maxSteps; numSteps > 1; numSteps-- ) + const double stepSize = intervalSize / numSteps; + + const double p = std::floor(std::log(stepSize) / std::log(base)); + const double fraction = std::pow(base, p); + + for (uint n = base; n > 1; n /= 2) + { + if (qFuzzyCompare(stepSize, n * fraction)) + return stepSize; + + if (n == 3 && (base % 2) == 0) { - const double stepSize = intervalSize / numSteps; - - const double p = std::floor( std::log( stepSize ) / std::log( base ) ); - const double fraction = std::pow( base, p ); - - for ( uint n = base; n > 1; n /= 2 ) - { - if ( qFuzzyCompare( stepSize, n * fraction ) ) - return stepSize; - - if ( n == 3 && ( base % 2 ) == 0 ) - { - if ( qFuzzyCompare( stepSize, 2 * fraction ) ) - return stepSize; - } - } + if (qFuzzyCompare(stepSize, 2 * fraction)) + return stepSize; } + } } + } - return intervalSize * 0.5; + return intervalSize * 0.5; } #endif @@ -105,13 +108,12 @@ static const double _eps = 1.0e-6; \sa floorEps() */ -double QwtScaleArithmetic::ceilEps( double value, - double intervalSize ) +double QwtScaleArithmetic::ceilEps(double value, double intervalSize) { - const double eps = _eps * intervalSize; + const double eps = _eps * intervalSize; - value = ( value - eps ) / intervalSize; - return std::ceil( value ) * intervalSize; + value = (value - eps) / intervalSize; + return std::ceil(value) * intervalSize; } /*! @@ -123,12 +125,12 @@ double QwtScaleArithmetic::ceilEps( double value, \return Rounded value \sa floorEps() */ -double QwtScaleArithmetic::floorEps( double value, double intervalSize ) +double QwtScaleArithmetic::floorEps(double value, double intervalSize) { - const double eps = _eps * intervalSize; + const double eps = _eps * intervalSize; - value = ( value + eps ) / intervalSize; - return std::floor( value ) * intervalSize; + value = (value + eps) / intervalSize; + return std::floor(value) * intervalSize; } /*! @@ -140,12 +142,12 @@ double QwtScaleArithmetic::floorEps( double value, double intervalSize ) \param numSteps Number of steps \return Step size */ -double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps ) +double QwtScaleArithmetic::divideEps(double intervalSize, double numSteps) { - if ( numSteps == 0.0 || intervalSize == 0.0 ) - return 0.0; + if (numSteps == 0.0 || intervalSize == 0.0) + return 0.0; - return ( intervalSize - ( _eps * intervalSize ) ) / numSteps; + return (intervalSize - (_eps * intervalSize)) / numSteps; } /*! @@ -157,60 +159,57 @@ double QwtScaleArithmetic::divideEps( double intervalSize, double numSteps ) \return Calculated step size */ -double QwtScaleArithmetic::divideInterval( - double intervalSize, int numSteps, uint base ) +double QwtScaleArithmetic::divideInterval(double intervalSize, int numSteps, + uint base) { - if ( numSteps <= 0 ) - return 0.0; + if (numSteps <= 0) + return 0.0; - const double v = QwtScaleArithmetic::divideEps( intervalSize, numSteps ); - if ( v == 0.0 ) - return 0.0; + const double v = QwtScaleArithmetic::divideEps(intervalSize, numSteps); + if (v == 0.0) + return 0.0; - const double lx = qwtLog( base, std::fabs( v ) ); - const double p = std::floor( lx ); + const double lx = qwtLog(base, std::fabs(v)); + const double p = std::floor(lx); - const double fraction = std::pow( base, lx - p ); + const double fraction = std::pow(base, lx - p); - uint n = base; - while ( ( n > 1 ) && ( fraction <= n / 2 ) ) - n /= 2; + uint n = base; + while ((n > 1) && (fraction <= n / 2)) + n /= 2; - double stepSize = n * std::pow( base, p ); - if ( v < 0 ) - stepSize = -stepSize; + double stepSize = n * std::pow(base, p); + if (v < 0) + stepSize = -stepSize; - return stepSize; + return stepSize; } class QwtScaleEngine::PrivateData { - public: - PrivateData(): - attributes( QwtScaleEngine::NoAttribute ), - lowerMargin( 0.0 ), - upperMargin( 0.0 ), - referenceValue( 0.0 ), - base( 10 ), - transform( NULL ) - { - } +public: + PrivateData() + : attributes(QwtScaleEngine::NoAttribute) + , lowerMargin(0.0) + , upperMargin(0.0) + , referenceValue(0.0) + , base(10) + , transform(NULL) + { + } - ~PrivateData() - { - delete transform; - } + ~PrivateData() { delete transform; } - QwtScaleEngine::Attributes attributes; + QwtScaleEngine::Attributes attributes; - double lowerMargin; - double upperMargin; + double lowerMargin; + double upperMargin; - double referenceValue; + double referenceValue; - uint base; + uint base; - QwtTransform* transform; + QwtTransform *transform; }; /*! @@ -219,17 +218,16 @@ class QwtScaleEngine::PrivateData \param base Base of the scale engine \sa setBase() */ -QwtScaleEngine::QwtScaleEngine( uint base ) +QwtScaleEngine::QwtScaleEngine(uint base) { - m_data = new PrivateData; - setBase( base ); + m_data = new PrivateData; + setBase(base); } - //! Destructor -QwtScaleEngine::~QwtScaleEngine () +QwtScaleEngine::~QwtScaleEngine() { - delete m_data; + delete m_data; } /*! @@ -245,13 +243,13 @@ QwtScaleEngine::~QwtScaleEngine () \sa QwtTransform::copy(), transformation() */ -void QwtScaleEngine::setTransformation( QwtTransform* transform ) +void QwtScaleEngine::setTransformation(QwtTransform *transform) { - if ( transform != m_data->transform ) - { - delete m_data->transform; - m_data->transform = transform; - } + if (transform != m_data->transform) + { + delete m_data->transform; + m_data->transform = transform; + } } /*! @@ -262,13 +260,13 @@ void QwtScaleEngine::setTransformation( QwtTransform* transform ) \return A clone of the transformation \sa setTransformation() */ -QwtTransform* QwtScaleEngine::transformation() const +QwtTransform *QwtScaleEngine::transformation() const { - QwtTransform* transform = NULL; - if ( m_data->transform ) - transform = m_data->transform->copy(); + QwtTransform *transform = NULL; + if (m_data->transform) + transform = m_data->transform->copy(); - return transform; + return transform; } /*! @@ -279,7 +277,7 @@ QwtTransform* QwtScaleEngine::transformation() const */ double QwtScaleEngine::lowerMargin() const { - return m_data->lowerMargin; + return m_data->lowerMargin; } /*! @@ -290,7 +288,7 @@ double QwtScaleEngine::lowerMargin() const */ double QwtScaleEngine::upperMargin() const { - return m_data->upperMargin; + return m_data->upperMargin; } /*! @@ -309,10 +307,10 @@ double QwtScaleEngine::upperMargin() const \sa upperMargin(), lowerMargin() */ -void QwtScaleEngine::setMargins( double lower, double upper ) +void QwtScaleEngine::setMargins(double lower, double upper) { - m_data->lowerMargin = qwtMaxF( lower, 0.0 ); - m_data->upperMargin = qwtMaxF( upper, 0.0 ); + m_data->lowerMargin = qwtMaxF(lower, 0.0); + m_data->upperMargin = qwtMaxF(upper, 0.0); } /*! @@ -323,11 +321,10 @@ void QwtScaleEngine::setMargins( double lower, double upper ) \return Step size */ -double QwtScaleEngine::divideInterval( - double intervalSize, int numSteps ) const +double QwtScaleEngine::divideInterval(double intervalSize, int numSteps) const { - return QwtScaleArithmetic::divideInterval( - intervalSize, numSteps, m_data->base ); + return QwtScaleArithmetic::divideInterval(intervalSize, numSteps, + m_data->base); } /*! @@ -338,19 +335,18 @@ double QwtScaleEngine::divideInterval( \return True, when the value is inside the interval */ -bool QwtScaleEngine::contains( - const QwtInterval& interval, double value ) const +bool QwtScaleEngine::contains(const QwtInterval &interval, double value) const { - if ( !interval.isValid() ) - return false; + if (!interval.isValid()) + return false; - if ( qwtFuzzyCompare( value, interval.minValue(), interval.width() ) < 0 ) - return false; + if (qwtFuzzyCompare(value, interval.minValue(), interval.width()) < 0) + return false; - if ( qwtFuzzyCompare( value, interval.maxValue(), interval.width() ) > 0 ) - return false; + if (qwtFuzzyCompare(value, interval.maxValue(), interval.width()) > 0) + return false; - return true; + return true; } /*! @@ -361,25 +357,24 @@ bool QwtScaleEngine::contains( \return Stripped tick list */ -QList< double > QwtScaleEngine::strip( const QList< double >& ticks, - const QwtInterval& interval ) const +QList QwtScaleEngine::strip(const QList &ticks, + const QwtInterval &interval) const { - if ( !interval.isValid() || ticks.count() == 0 ) - return QList< double >(); + if (!interval.isValid() || ticks.count() == 0) + return QList(); - if ( contains( interval, ticks.first() ) - && contains( interval, ticks.last() ) ) - { - return ticks; - } + if (contains(interval, ticks.first()) && contains(interval, ticks.last())) + { + return ticks; + } - QList< double > strippedTicks; - for ( int i = 0; i < ticks.count(); i++ ) - { - if ( contains( interval, ticks[i] ) ) - strippedTicks += ticks[i]; - } - return strippedTicks; + QList strippedTicks; + for (int i = 0; i < ticks.count(); i++) + { + if (contains(interval, ticks[i])) + strippedTicks += ticks[i]; + } + return strippedTicks; } /*! @@ -392,18 +387,18 @@ QList< double > QwtScaleEngine::strip( const QList< double >& ticks, \return Calculated interval */ -QwtInterval QwtScaleEngine::buildInterval( double value ) const +QwtInterval QwtScaleEngine::buildInterval(double value) const { - const double delta = ( value == 0.0 ) ? 0.5 : qAbs( 0.5 * value ); - const double max = std::numeric_limits< double >::max(); + const double delta = (value == 0.0) ? 0.5 : qAbs(0.5 * value); + const double max = std::numeric_limits::max(); - if ( max - delta < value ) - return QwtInterval( max - delta, max ); + if (max - delta < value) + return QwtInterval(max - delta, max); - if ( -max + delta > value ) - return QwtInterval( -max, -max + delta ); + if (-max + delta > value) + return QwtInterval(-max, -max + delta); - return QwtInterval( value - delta, value + delta ); + return QwtInterval(value - delta, value + delta); } /*! @@ -414,12 +409,12 @@ QwtInterval QwtScaleEngine::buildInterval( double value ) const \sa Attribute, testAttribute() */ -void QwtScaleEngine::setAttribute( Attribute attribute, bool on ) +void QwtScaleEngine::setAttribute(Attribute attribute, bool on) { - if ( on ) - m_data->attributes |= attribute; - else - m_data->attributes &= ~attribute; + if (on) + m_data->attributes |= attribute; + else + m_data->attributes &= ~attribute; } /*! @@ -428,9 +423,9 @@ void QwtScaleEngine::setAttribute( Attribute attribute, bool on ) \param attribute Attribute to be tested \sa Attribute, setAttribute() */ -bool QwtScaleEngine::testAttribute( Attribute attribute ) const +bool QwtScaleEngine::testAttribute(Attribute attribute) const { - return ( m_data->attributes & attribute ); + return (m_data->attributes & attribute); } /*! @@ -439,9 +434,9 @@ bool QwtScaleEngine::testAttribute( Attribute attribute ) const \param attributes Set scale attributes \sa Attribute, attributes() */ -void QwtScaleEngine::setAttributes( Attributes attributes ) +void QwtScaleEngine::setAttributes(Attributes attributes) { - m_data->attributes = attributes; + m_data->attributes = attributes; } /*! @@ -450,7 +445,7 @@ void QwtScaleEngine::setAttributes( Attributes attributes ) */ QwtScaleEngine::Attributes QwtScaleEngine::attributes() const { - return m_data->attributes; + return m_data->attributes; } /*! @@ -462,9 +457,9 @@ QwtScaleEngine::Attributes QwtScaleEngine::attributes() const \sa Attribute */ -void QwtScaleEngine::setReference( double reference ) +void QwtScaleEngine::setReference(double reference) { - m_data->referenceValue = reference; + m_data->referenceValue = reference; } /*! @@ -473,7 +468,7 @@ void QwtScaleEngine::setReference( double reference ) */ double QwtScaleEngine::reference() const { - return m_data->referenceValue; + return m_data->referenceValue; } /*! @@ -488,9 +483,9 @@ double QwtScaleEngine::reference() const \sa base() */ -void QwtScaleEngine::setBase( uint base ) +void QwtScaleEngine::setBase(uint base) { - m_data->base = qMax( base, 2U ); + m_data->base = qMax(base, 2U); } /*! @@ -499,7 +494,7 @@ void QwtScaleEngine::setBase( uint base ) */ uint QwtScaleEngine::base() const { - return m_data->base; + return m_data->base; } /*! @@ -508,15 +503,13 @@ uint QwtScaleEngine::base() const \param base Base of the scale engine \sa setBase() */ -QwtLinearScaleEngine::QwtLinearScaleEngine( uint base ): - QwtScaleEngine( base ) +QwtLinearScaleEngine::QwtLinearScaleEngine(uint base) + : QwtScaleEngine(base) { } //! Destructor -QwtLinearScaleEngine::~QwtLinearScaleEngine() -{ -} +QwtLinearScaleEngine::~QwtLinearScaleEngine() {} /*! Align and divide an interval @@ -528,38 +521,38 @@ QwtLinearScaleEngine::~QwtLinearScaleEngine() \sa setAttribute() */ -void QwtLinearScaleEngine::autoScale( int maxNumSteps, - double& x1, double& x2, double& stepSize ) const +void QwtLinearScaleEngine::autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const { - QwtInterval interval( x1, x2 ); - interval = interval.normalized(); + QwtInterval interval(x1, x2); + interval = interval.normalized(); - interval.setMinValue( interval.minValue() - lowerMargin() ); - interval.setMaxValue( interval.maxValue() + upperMargin() ); + interval.setMinValue(interval.minValue() - lowerMargin()); + interval.setMaxValue(interval.maxValue() + upperMargin()); - if ( testAttribute( QwtScaleEngine::Symmetric ) ) - interval = interval.symmetrize( reference() ); + if (testAttribute(QwtScaleEngine::Symmetric)) + interval = interval.symmetrize(reference()); - if ( testAttribute( QwtScaleEngine::IncludeReference ) ) - interval = interval.extend( reference() ); + if (testAttribute(QwtScaleEngine::IncludeReference)) + interval = interval.extend(reference()); - if ( interval.width() == 0.0 ) - interval = buildInterval( interval.minValue() ); + if (interval.width() == 0.0) + interval = buildInterval(interval.minValue()); - stepSize = QwtScaleArithmetic::divideInterval( - interval.width(), qMax( maxNumSteps, 1 ), base() ); + stepSize = QwtScaleArithmetic::divideInterval(interval.width(), + qMax(maxNumSteps, 1), base()); - if ( !testAttribute( QwtScaleEngine::Floating ) ) - interval = align( interval, stepSize ); + if (!testAttribute(QwtScaleEngine::Floating)) + interval = align(interval, stepSize); - x1 = interval.minValue(); - x2 = interval.maxValue(); + x1 = interval.minValue(); + x2 = interval.maxValue(); - if ( testAttribute( QwtScaleEngine::Inverted ) ) - { - qSwap( x1, x2 ); - stepSize = -stepSize; - } + if (testAttribute(QwtScaleEngine::Inverted)) + { + qSwap(x1, x2); + stepSize = -stepSize; + } } /*! @@ -574,44 +567,46 @@ void QwtLinearScaleEngine::autoScale( int maxNumSteps, \return Calculated scale division */ -QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2, - int maxMajorSteps, int maxMinorSteps, double stepSize ) const +QwtScaleDiv QwtLinearScaleEngine::divideScale(double x1, double x2, + int maxMajorSteps, + int maxMinorSteps, + double stepSize) const { - QwtInterval interval = QwtInterval( x1, x2 ).normalized(); + QwtInterval interval = QwtInterval(x1, x2).normalized(); - if ( interval.widthL() > std::numeric_limits< double >::max() ) - { - qWarning() << "QwtLinearScaleEngine::divideScale: overflow"; - return QwtScaleDiv(); - } + if (interval.widthL() > std::numeric_limits::max()) + { + qWarning() << "QwtLinearScaleEngine::divideScale: overflow"; + return QwtScaleDiv(); + } - if ( interval.width() <= 0 ) - return QwtScaleDiv(); + if (interval.width() <= 0) + return QwtScaleDiv(); - stepSize = qAbs( stepSize ); - if ( stepSize == 0.0 ) - { - if ( maxMajorSteps < 1 ) - maxMajorSteps = 1; + stepSize = qAbs(stepSize); + if (stepSize == 0.0) + { + if (maxMajorSteps < 1) + maxMajorSteps = 1; - stepSize = QwtScaleArithmetic::divideInterval( - interval.width(), maxMajorSteps, base() ); - } + stepSize = QwtScaleArithmetic::divideInterval(interval.width(), + maxMajorSteps, base()); + } - QwtScaleDiv scaleDiv; + QwtScaleDiv scaleDiv; - if ( stepSize != 0.0 ) - { - QList< double > ticks[QwtScaleDiv::NTickTypes]; - buildTicks( interval, stepSize, maxMinorSteps, ticks ); + if (stepSize != 0.0) + { + QList ticks[QwtScaleDiv::NTickTypes]; + buildTicks(interval, stepSize, maxMinorSteps, ticks); - scaleDiv = QwtScaleDiv( interval, ticks ); - } + scaleDiv = QwtScaleDiv(interval, ticks); + } - if ( x1 > x2 ) - scaleDiv.invert(); + if (x1 > x2) + scaleDiv.invert(); - return scaleDiv; + return scaleDiv; } /*! @@ -625,32 +620,32 @@ QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2, \sa buildMajorTicks(), buildMinorTicks */ void QwtLinearScaleEngine::buildTicks( - const QwtInterval& interval, double stepSize, int maxMinorSteps, - QList< double > ticks[QwtScaleDiv::NTickTypes] ) const + const QwtInterval &interval, double stepSize, int maxMinorSteps, + QList ticks[QwtScaleDiv::NTickTypes]) const { - const QwtInterval boundingInterval = align( interval, stepSize ); + const QwtInterval boundingInterval = align(interval, stepSize); - ticks[QwtScaleDiv::MajorTick] = - buildMajorTicks( boundingInterval, stepSize ); + ticks[QwtScaleDiv::MajorTick] = buildMajorTicks(boundingInterval, stepSize); - if ( maxMinorSteps > 0 ) + if (maxMinorSteps > 0) + { + buildMinorTicks(ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize, + ticks[QwtScaleDiv::MinorTick], + ticks[QwtScaleDiv::MediumTick]); + } + + for (int i = 0; i < QwtScaleDiv::NTickTypes; i++) + { + ticks[i] = strip(ticks[i], interval); + + // ticks very close to 0.0 are explicitly set to 0.0 + + for (int j = 0; j < ticks[i].count(); j++) { - buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize, - ticks[QwtScaleDiv::MinorTick], ticks[QwtScaleDiv::MediumTick] ); - } - - for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) - { - ticks[i] = strip( ticks[i], interval ); - - // ticks very close to 0.0 are explicitly set to 0.0 - - for ( int j = 0; j < ticks[i].count(); j++ ) - { - if ( qwtFuzzyCompare( ticks[i][j], 0.0, stepSize ) == 0 ) - ticks[i][j] = 0.0; - } + if (qwtFuzzyCompare(ticks[i][j], 0.0, stepSize) == 0) + ticks[i][j] = 0.0; } + } } /*! @@ -661,22 +656,22 @@ void QwtLinearScaleEngine::buildTicks( \return Calculated ticks */ -QList< double > QwtLinearScaleEngine::buildMajorTicks( - const QwtInterval& interval, double stepSize ) const +QList QwtLinearScaleEngine::buildMajorTicks(const QwtInterval &interval, + double stepSize) const { - int numTicks = qRound( interval.width() / stepSize ) + 1; - if ( numTicks > 10000 ) - numTicks = 10000; + int numTicks = qRound(interval.width() / stepSize) + 1; + if (numTicks > 10000) + numTicks = 10000; - QList< double > ticks; - ticks.reserve( numTicks ); + QList ticks; + ticks.reserve(numTicks); - ticks += interval.minValue(); - for ( int i = 1; i < numTicks - 1; i++ ) - ticks += interval.minValue() + i * stepSize; - ticks += interval.maxValue(); + ticks += interval.minValue(); + for (int i = 1; i < numTicks - 1; i++) + ticks += interval.minValue() + i * stepSize; + ticks += interval.maxValue(); - return ticks; + return ticks; } /*! @@ -689,42 +684,41 @@ QList< double > QwtLinearScaleEngine::buildMajorTicks( \param mediumTicks Array to be filled with the calculated medium ticks */ -void QwtLinearScaleEngine::buildMinorTicks( - const QList< double >& majorTicks, - int maxMinorSteps, double stepSize, - QList< double >& minorTicks, - QList< double >& mediumTicks ) const +void QwtLinearScaleEngine::buildMinorTicks(const QList &majorTicks, + int maxMinorSteps, double stepSize, + QList &minorTicks, + QList &mediumTicks) const { - double minStep = qwtStepSize( stepSize, maxMinorSteps, base() ); - if ( minStep == 0.0 ) - return; + double minStep = qwtStepSize(stepSize, maxMinorSteps, base()); + if (minStep == 0.0) + return; - // # ticks per interval - const int numTicks = qwtCeil( qAbs( stepSize / minStep ) ) - 1; + // # ticks per interval + const int numTicks = qwtCeil(qAbs(stepSize / minStep)) - 1; - int medIndex = -1; - if ( numTicks % 2 ) - medIndex = numTicks / 2; + int medIndex = -1; + if (numTicks % 2) + medIndex = numTicks / 2; - // calculate minor ticks + // calculate minor ticks - for ( int i = 0; i < majorTicks.count(); i++ ) + for (int i = 0; i < majorTicks.count(); i++) + { + double val = majorTicks[i]; + for (int k = 0; k < numTicks; k++) { - double val = majorTicks[i]; - for ( int k = 0; k < numTicks; k++ ) - { - val += minStep; + val += minStep; - double alignedValue = val; - if ( qwtFuzzyCompare( val, 0.0, stepSize ) == 0 ) - alignedValue = 0.0; + double alignedValue = val; + if (qwtFuzzyCompare(val, 0.0, stepSize) == 0) + alignedValue = 0.0; - if ( k == medIndex ) - mediumTicks += alignedValue; - else - minorTicks += alignedValue; - } + if (k == medIndex) + mediumTicks += alignedValue; + else + minorTicks += alignedValue; } + } } /*! @@ -738,33 +732,33 @@ void QwtLinearScaleEngine::buildMinorTicks( \return Aligned interval */ -QwtInterval QwtLinearScaleEngine::align( - const QwtInterval& interval, double stepSize ) const +QwtInterval QwtLinearScaleEngine::align(const QwtInterval &interval, + double stepSize) const { - double x1 = interval.minValue(); - double x2 = interval.maxValue(); + double x1 = interval.minValue(); + double x2 = interval.maxValue(); - // when there is no rounding beside some effect, when - // calculating with doubles, we keep the original value + // when there is no rounding beside some effect, when + // calculating with doubles, we keep the original value - const double eps = 0.000000000001; // since Qt 4.8: qFuzzyIsNull - const double max = std::numeric_limits< double >::max(); + const double eps = 0.000000000001; // since Qt 4.8: qFuzzyIsNull + const double max = std::numeric_limits::max(); - if ( -max + stepSize <= x1 ) - { - const double x = QwtScaleArithmetic::floorEps( x1, stepSize ); - if ( qAbs(x) <= eps || !qFuzzyCompare( x1, x ) ) - x1 = x; - } + if (-max + stepSize <= x1) + { + const double x = QwtScaleArithmetic::floorEps(x1, stepSize); + if (qAbs(x) <= eps || !qFuzzyCompare(x1, x)) + x1 = x; + } - if ( max - stepSize >= x2 ) - { - const double x = QwtScaleArithmetic::ceilEps( x2, stepSize ); - if ( qAbs(x) <= eps || !qFuzzyCompare( x2, x ) ) - x2 = x; - } + if (max - stepSize >= x2) + { + const double x = QwtScaleArithmetic::ceilEps(x2, stepSize); + if (qAbs(x) <= eps || !qFuzzyCompare(x2, x)) + x2 = x; + } - return QwtInterval( x1, x2 ); + return QwtInterval(x1, x2); } /*! @@ -773,16 +767,14 @@ QwtInterval QwtLinearScaleEngine::align( \param base Base of the scale engine \sa setBase() */ -QwtLogScaleEngine::QwtLogScaleEngine( uint base ): - QwtScaleEngine( base ) +QwtLogScaleEngine::QwtLogScaleEngine(uint base) + : QwtScaleEngine(base) { - setTransformation( new QwtLogTransform() ); + setTransformation(new QwtLogTransform()); } //! Destructor -QwtLogScaleEngine::~QwtLogScaleEngine() -{ -} +QwtLogScaleEngine::~QwtLogScaleEngine() {} /*! Align and divide an interval @@ -794,74 +786,74 @@ QwtLogScaleEngine::~QwtLogScaleEngine() \sa QwtScaleEngine::setAttribute() */ -void QwtLogScaleEngine::autoScale( int maxNumSteps, - double& x1, double& x2, double& stepSize ) const +void QwtLogScaleEngine::autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const { - if ( x1 > x2 ) - qSwap( x1, x2 ); + if (x1 > x2) + qSwap(x1, x2); - const double logBase = base(); + const double logBase = base(); - QwtInterval interval( x1 / std::pow( logBase, lowerMargin() ), - x2 * std::pow( logBase, upperMargin() ) ); + QwtInterval interval(x1 / std::pow(logBase, lowerMargin()), + x2 * std::pow(logBase, upperMargin())); - if ( interval.maxValue() / interval.minValue() < logBase ) + if (interval.maxValue() / interval.minValue() < logBase) + { + // scale width is less than one step -> try to build a linear scale + + QwtLinearScaleEngine linearScaler; + linearScaler.setAttributes(attributes()); + linearScaler.setReference(reference()); + linearScaler.setMargins(lowerMargin(), upperMargin()); + + linearScaler.autoScale(maxNumSteps, x1, x2, stepSize); + + QwtInterval linearInterval = QwtInterval(x1, x2).normalized(); + linearInterval = linearInterval.limited(QwtLogTransform::LogMin, + QwtLogTransform::LogMax); + + if (linearInterval.maxValue() / linearInterval.minValue() < logBase) { - // scale width is less than one step -> try to build a linear scale - - QwtLinearScaleEngine linearScaler; - linearScaler.setAttributes( attributes() ); - linearScaler.setReference( reference() ); - linearScaler.setMargins( lowerMargin(), upperMargin() ); - - linearScaler.autoScale( maxNumSteps, x1, x2, stepSize ); - - QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized(); - linearInterval = linearInterval.limited( - QwtLogTransform::LogMin, QwtLogTransform::LogMax ); - - if ( linearInterval.maxValue() / linearInterval.minValue() < logBase ) - { - stepSize = 0.0; - return; - } + stepSize = 0.0; + return; } + } - double logRef = 1.0; - if ( reference() > QwtLogTransform::LogMin / 2 ) - logRef = qwtMinF( reference(), QwtLogTransform::LogMax / 2 ); + double logRef = 1.0; + if (reference() > QwtLogTransform::LogMin / 2) + logRef = qwtMinF(reference(), QwtLogTransform::LogMax / 2); - if ( testAttribute( QwtScaleEngine::Symmetric ) ) - { - const double delta = qwtMaxF( interval.maxValue() / logRef, - logRef / interval.minValue() ); - interval.setInterval( logRef / delta, logRef * delta ); - } + if (testAttribute(QwtScaleEngine::Symmetric)) + { + const double delta + = qwtMaxF(interval.maxValue() / logRef, logRef / interval.minValue()); + interval.setInterval(logRef / delta, logRef * delta); + } - if ( testAttribute( QwtScaleEngine::IncludeReference ) ) - interval = interval.extend( logRef ); + if (testAttribute(QwtScaleEngine::IncludeReference)) + interval = interval.extend(logRef); - interval = interval.limited( QwtLogTransform::LogMin, QwtLogTransform::LogMax ); + interval = interval.limited(QwtLogTransform::LogMin, QwtLogTransform::LogMax); - if ( interval.width() == 0.0 ) - interval = buildInterval( interval.minValue() ); + if (interval.width() == 0.0) + interval = buildInterval(interval.minValue()); - stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(), - qMax( maxNumSteps, 1 ) ); - if ( stepSize < 1.0 ) - stepSize = 1.0; + stepSize = divideInterval(qwtLogInterval(logBase, interval).width(), + qMax(maxNumSteps, 1)); + if (stepSize < 1.0) + stepSize = 1.0; - if ( !testAttribute( QwtScaleEngine::Floating ) ) - interval = align( interval, stepSize ); + if (!testAttribute(QwtScaleEngine::Floating)) + interval = align(interval, stepSize); - x1 = interval.minValue(); - x2 = interval.maxValue(); + x1 = interval.minValue(); + x2 = interval.maxValue(); - if ( testAttribute( QwtScaleEngine::Inverted ) ) - { - qSwap( x1, x2 ); - stepSize = -stepSize; - } + if (testAttribute(QwtScaleEngine::Inverted)) + { + qSwap(x1, x2); + stepSize = -stepSize; + } } /*! @@ -876,55 +868,55 @@ void QwtLogScaleEngine::autoScale( int maxNumSteps, \return Calculated scale division */ -QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2, - int maxMajorSteps, int maxMinorSteps, double stepSize ) const +QwtScaleDiv QwtLogScaleEngine::divideScale(double x1, double x2, + int maxMajorSteps, int maxMinorSteps, + double stepSize) const { - QwtInterval interval = QwtInterval( x1, x2 ).normalized(); - interval = interval.limited( QwtLogTransform::LogMin, QwtLogTransform::LogMax ); + QwtInterval interval = QwtInterval(x1, x2).normalized(); + interval = interval.limited(QwtLogTransform::LogMin, QwtLogTransform::LogMax); - if ( interval.width() <= 0 ) - return QwtScaleDiv(); + if (interval.width() <= 0) + return QwtScaleDiv(); - const double logBase = base(); + const double logBase = base(); - if ( interval.maxValue() / interval.minValue() < logBase ) - { - // scale width is less than one decade -> build linear scale + if (interval.maxValue() / interval.minValue() < logBase) + { + // scale width is less than one decade -> build linear scale - QwtLinearScaleEngine linearScaler; - linearScaler.setAttributes( attributes() ); - linearScaler.setReference( reference() ); - linearScaler.setMargins( lowerMargin(), upperMargin() ); + QwtLinearScaleEngine linearScaler; + linearScaler.setAttributes(attributes()); + linearScaler.setReference(reference()); + linearScaler.setMargins(lowerMargin(), upperMargin()); - return linearScaler.divideScale( x1, x2, - maxMajorSteps, maxMinorSteps, 0.0 ); - } + return linearScaler.divideScale(x1, x2, maxMajorSteps, maxMinorSteps, 0.0); + } - stepSize = qAbs( stepSize ); - if ( stepSize == 0.0 ) - { - if ( maxMajorSteps < 1 ) - maxMajorSteps = 1; + stepSize = qAbs(stepSize); + if (stepSize == 0.0) + { + if (maxMajorSteps < 1) + maxMajorSteps = 1; - stepSize = divideInterval( - qwtLogInterval( logBase, interval ).width(), maxMajorSteps ); - if ( stepSize < 1.0 ) - stepSize = 1.0; // major step must be >= 1 decade - } + stepSize = divideInterval(qwtLogInterval(logBase, interval).width(), + maxMajorSteps); + if (stepSize < 1.0) + stepSize = 1.0; // major step must be >= 1 decade + } - QwtScaleDiv scaleDiv; - if ( stepSize != 0.0 ) - { - QList< double > ticks[QwtScaleDiv::NTickTypes]; - buildTicks( interval, stepSize, maxMinorSteps, ticks ); + QwtScaleDiv scaleDiv; + if (stepSize != 0.0) + { + QList ticks[QwtScaleDiv::NTickTypes]; + buildTicks(interval, stepSize, maxMinorSteps, ticks); - scaleDiv = QwtScaleDiv( interval, ticks ); - } + scaleDiv = QwtScaleDiv(interval, ticks); + } - if ( x1 > x2 ) - scaleDiv.invert(); + if (x1 > x2) + scaleDiv.invert(); - return scaleDiv; + return scaleDiv; } /*! @@ -938,22 +930,22 @@ QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2, \sa buildMajorTicks(), buildMinorTicks */ void QwtLogScaleEngine::buildTicks( - const QwtInterval& interval, double stepSize, int maxMinorSteps, - QList< double > ticks[QwtScaleDiv::NTickTypes] ) const + const QwtInterval &interval, double stepSize, int maxMinorSteps, + QList ticks[QwtScaleDiv::NTickTypes]) const { - const QwtInterval boundingInterval = align( interval, stepSize ); + const QwtInterval boundingInterval = align(interval, stepSize); - ticks[QwtScaleDiv::MajorTick] = - buildMajorTicks( boundingInterval, stepSize ); + ticks[QwtScaleDiv::MajorTick] = buildMajorTicks(boundingInterval, stepSize); - if ( maxMinorSteps > 0 ) - { - buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize, - ticks[QwtScaleDiv::MinorTick], ticks[QwtScaleDiv::MediumTick] ); - } + if (maxMinorSteps > 0) + { + buildMinorTicks(ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize, + ticks[QwtScaleDiv::MinorTick], + ticks[QwtScaleDiv::MediumTick]); + } - for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) - ticks[i] = strip( ticks[i], interval ); + for (int i = 0; i < QwtScaleDiv::NTickTypes; i++) + ticks[i] = strip(ticks[i], interval); } /*! @@ -964,30 +956,30 @@ void QwtLogScaleEngine::buildTicks( \return Calculated ticks */ -QList< double > QwtLogScaleEngine::buildMajorTicks( - const QwtInterval& interval, double stepSize ) const +QList QwtLogScaleEngine::buildMajorTicks(const QwtInterval &interval, + double stepSize) const { - double width = qwtLogInterval( base(), interval ).width(); + double width = qwtLogInterval(base(), interval).width(); - int numTicks = qRound( width / stepSize ) + 1; - if ( numTicks > 10000 ) - numTicks = 10000; + int numTicks = qRound(width / stepSize) + 1; + if (numTicks > 10000) + numTicks = 10000; - const double lxmin = std::log( interval.minValue() ); - const double lxmax = std::log( interval.maxValue() ); - const double lstep = ( lxmax - lxmin ) / double( numTicks - 1 ); + const double lxmin = std::log(interval.minValue()); + const double lxmax = std::log(interval.maxValue()); + const double lstep = (lxmax - lxmin) / double(numTicks - 1); - QList< double > ticks; - ticks.reserve( numTicks ); + QList ticks; + ticks.reserve(numTicks); - ticks += interval.minValue(); + ticks += interval.minValue(); - for ( int i = 1; i < numTicks - 1; i++ ) - ticks += std::exp( lxmin + double( i ) * lstep ); + for (int i = 1; i < numTicks - 1; i++) + ticks += std::exp(lxmin + double(i) * lstep); - ticks += interval.maxValue(); + ticks += interval.maxValue(); - return ticks; + return ticks; } /*! @@ -999,97 +991,95 @@ QList< double > QwtLogScaleEngine::buildMajorTicks( \param minorTicks Array to be filled with the calculated minor ticks \param mediumTicks Array to be filled with the calculated medium ticks */ -void QwtLogScaleEngine::buildMinorTicks( - const QList< double >& majorTicks, - int maxMinorSteps, double stepSize, - QList< double >& minorTicks, - QList< double >& mediumTicks ) const +void QwtLogScaleEngine::buildMinorTicks(const QList &majorTicks, + int maxMinorSteps, double stepSize, + QList &minorTicks, + QList &mediumTicks) const { - const double logBase = base(); + const double logBase = base(); - if ( stepSize < 1.1 ) // major step width is one base + if (stepSize < 1.1) // major step width is one base + { + double minStep = divideInterval(stepSize, maxMinorSteps + 1); + if (minStep == 0.0) + return; + + const int numSteps = qRound(stepSize / minStep); + + int mediumTickIndex = -1; + if ((numSteps > 2) && (numSteps % 2 == 0)) + mediumTickIndex = numSteps / 2; + + for (int i = 0; i < majorTicks.count() - 1; i++) { - double minStep = divideInterval( stepSize, maxMinorSteps + 1 ); - if ( minStep == 0.0 ) - return; + const double v = majorTicks[i]; + const double s = logBase / numSteps; - const int numSteps = qRound( stepSize / minStep ); + if (s >= 1.0) + { + if (!qFuzzyCompare(s, 1.0)) + minorTicks += v * s; - int mediumTickIndex = -1; - if ( ( numSteps > 2 ) && ( numSteps % 2 == 0 ) ) - mediumTickIndex = numSteps / 2; - - for ( int i = 0; i < majorTicks.count() - 1; i++ ) + for (int j = 2; j < numSteps; j++) { - const double v = majorTicks[i]; - const double s = logBase / numSteps; - - if ( s >= 1.0 ) - { - if ( !qFuzzyCompare( s, 1.0 ) ) - minorTicks += v * s; - - for ( int j = 2; j < numSteps; j++ ) - { - minorTicks += v * j * s; - } - } - else - { - for ( int j = 1; j < numSteps; j++ ) - { - const double tick = v + j * v * ( logBase - 1 ) / numSteps; - if ( j == mediumTickIndex ) - mediumTicks += tick; - else - minorTicks += tick; - } - } + minorTicks += v * j * s; } + } + else + { + for (int j = 1; j < numSteps; j++) + { + const double tick = v + j * v * (logBase - 1) / numSteps; + if (j == mediumTickIndex) + mediumTicks += tick; + else + minorTicks += tick; + } + } } - else + } + else + { + double minStep = divideInterval(stepSize, maxMinorSteps); + if (minStep == 0.0) + return; + + if (minStep < 1.0) + minStep = 1.0; + + // # subticks per interval + int numTicks = qRound(stepSize / minStep) - 1; + + // Do the minor steps fit into the interval? + if (qwtFuzzyCompare((numTicks + 1) * minStep, stepSize, stepSize) > 0) { - double minStep = divideInterval( stepSize, maxMinorSteps ); - if ( minStep == 0.0 ) - return; - - if ( minStep < 1.0 ) - minStep = 1.0; - - // # subticks per interval - int numTicks = qRound( stepSize / minStep ) - 1; - - // Do the minor steps fit into the interval? - if ( qwtFuzzyCompare( ( numTicks + 1 ) * minStep, - stepSize, stepSize ) > 0 ) - { - numTicks = 0; - } - - if ( numTicks < 1 ) - return; - - int mediumTickIndex = -1; - if ( ( numTicks > 2 ) && ( numTicks % 2 ) ) - mediumTickIndex = numTicks / 2; - - // substep factor = base^substeps - const qreal minFactor = qwtMaxF( std::pow( logBase, minStep ), logBase ); - - for ( int i = 0; i < majorTicks.count(); i++ ) - { - double tick = majorTicks[i]; - for ( int j = 0; j < numTicks; j++ ) - { - tick *= minFactor; - - if ( j == mediumTickIndex ) - mediumTicks += tick; - else - minorTicks += tick; - } - } + numTicks = 0; } + + if (numTicks < 1) + return; + + int mediumTickIndex = -1; + if ((numTicks > 2) && (numTicks % 2)) + mediumTickIndex = numTicks / 2; + + // substep factor = base^substeps + const qreal minFactor = qwtMaxF(std::pow(logBase, minStep), logBase); + + for (int i = 0; i < majorTicks.count(); i++) + { + double tick = majorTicks[i]; + for (int j = 0; j < numTicks; j++) + { + tick *= minFactor; + + if (j == mediumTickIndex) + mediumTicks += tick; + else + minorTicks += tick; + } + } + } } /*! @@ -1103,18 +1093,18 @@ void QwtLogScaleEngine::buildMinorTicks( \return Aligned interval */ -QwtInterval QwtLogScaleEngine::align( - const QwtInterval& interval, double stepSize ) const +QwtInterval QwtLogScaleEngine::align(const QwtInterval &interval, + double stepSize) const { - const QwtInterval intv = qwtLogInterval( base(), interval ); + const QwtInterval intv = qwtLogInterval(base(), interval); - double x1 = QwtScaleArithmetic::floorEps( intv.minValue(), stepSize ); - if ( qwtFuzzyCompare( interval.minValue(), x1, stepSize ) == 0 ) - x1 = interval.minValue(); + double x1 = QwtScaleArithmetic::floorEps(intv.minValue(), stepSize); + if (qwtFuzzyCompare(interval.minValue(), x1, stepSize) == 0) + x1 = interval.minValue(); - double x2 = QwtScaleArithmetic::ceilEps( intv.maxValue(), stepSize ); - if ( qwtFuzzyCompare( interval.maxValue(), x2, stepSize ) == 0 ) - x2 = interval.maxValue(); + double x2 = QwtScaleArithmetic::ceilEps(intv.maxValue(), stepSize); + if (qwtFuzzyCompare(interval.maxValue(), x2, stepSize) == 0) + x2 = interval.maxValue(); - return qwtPowInterval( base(), QwtInterval( x1, x2 ) ); + return qwtPowInterval(base(), QwtInterval(x1, x2)); } diff --git a/libs/qwt/src/qwt_scale_engine.h b/libs/qwt/src/qwt_scale_engine.h index 303dab71..53576c47 100644 --- a/libs/qwt/src/qwt_scale_engine.h +++ b/libs/qwt/src/qwt_scale_engine.h @@ -21,14 +21,13 @@ class QwtTransform; */ class QWT_EXPORT QwtScaleArithmetic { - public: - static double ceilEps( double value, double intervalSize ); - static double floorEps( double value, double intervalSize ); +public: + static double ceilEps(double value, double intervalSize); + static double floorEps(double value, double intervalSize); - static double divideEps( double intervalSize, double numSteps ); + static double divideEps(double intervalSize, double numSteps); - static double divideInterval( double intervalSize, - int numSteps, uint base ); + static double divideInterval(double intervalSize, int numSteps, uint base); }; /*! @@ -44,101 +43,103 @@ class QWT_EXPORT QwtScaleArithmetic class QWT_EXPORT QwtScaleEngine { - public: - /*! - Layout attributes - \sa setAttribute(), testAttribute(), reference(), - lowerMargin(), upperMargin() - */ +public: + /*! + Layout attributes + \sa setAttribute(), testAttribute(), reference(), + lowerMargin(), upperMargin() + */ - enum Attribute - { - //! No attributes - NoAttribute = 0x00, + enum Attribute + { + //! No attributes + NoAttribute = 0x00, - //! Build a scale which includes the reference() value. - IncludeReference = 0x01, + //! Build a scale which includes the reference() value. + IncludeReference = 0x01, - //! Build a scale which is symmetric to the reference() value. - Symmetric = 0x02, - - /*! - The endpoints of the scale are supposed to be equal the - outmost included values plus the specified margins - (see setMargins()). - If this attribute is *not* set, the endpoints of the scale will - be integer multiples of the step size. - */ - Floating = 0x04, - - //! Turn the scale upside down. - Inverted = 0x08 - }; - - Q_DECLARE_FLAGS( Attributes, Attribute ) - - explicit QwtScaleEngine( uint base = 10 ); - virtual ~QwtScaleEngine(); - - void setBase( uint base ); - uint base() const; - - void setAttribute( Attribute, bool on = true ); - bool testAttribute( Attribute ) const; - - void setAttributes( Attributes ); - Attributes attributes() const; - - void setReference( double ); - double reference() const; - - void setMargins( double lower, double upper ); - double lowerMargin() const; - double upperMargin() const; + //! Build a scale which is symmetric to the reference() value. + Symmetric = 0x02, /*! - Align and divide an interval - - \param maxNumSteps Max. number of steps - \param x1 First limit of the interval (In/Out) - \param x2 Second limit of the interval (In/Out) - \param stepSize Step size (Return value) + The endpoints of the scale are supposed to be equal the + outmost included values plus the specified margins + (see setMargins()). + If this attribute is *not* set, the endpoints of the scale will + be integer multiples of the step size. */ - virtual void autoScale( int maxNumSteps, - double& x1, double& x2, double& stepSize ) const = 0; + Floating = 0x04, - /*! - \brief Calculate a scale division + //! Turn the scale upside down. + Inverted = 0x08 + }; - \param x1 First interval limit - \param x2 Second interval limit - \param maxMajorSteps Maximum for the number of major steps - \param maxMinorSteps Maximum number of minor steps - \param stepSize Step size. If stepSize == 0.0, the scaleEngine - calculates one. + Q_DECLARE_FLAGS(Attributes, Attribute) - \return Calculated scale division - */ - virtual QwtScaleDiv divideScale( double x1, double x2, - int maxMajorSteps, int maxMinorSteps, - double stepSize = 0.0 ) const = 0; + explicit QwtScaleEngine(uint base = 10); + virtual ~QwtScaleEngine(); - void setTransformation( QwtTransform* ); - QwtTransform* transformation() const; + void setBase(uint base); + uint base() const; - protected: - bool contains( const QwtInterval&, double value ) const; - QList< double > strip( const QList< double >&, const QwtInterval& ) const; + void setAttribute(Attribute, bool on = true); + bool testAttribute(Attribute) const; - double divideInterval( double intervalSize, int numSteps ) const; + void setAttributes(Attributes); + Attributes attributes() const; - QwtInterval buildInterval( double value ) const; + void setReference(double); + double reference() const; - private: - Q_DISABLE_COPY(QwtScaleEngine) + void setMargins(double lower, double upper); + double lowerMargin() const; + double upperMargin() const; - class PrivateData; - PrivateData* m_data; + /*! + Align and divide an interval + + \param maxNumSteps Max. number of steps + \param x1 First limit of the interval (In/Out) + \param x2 Second limit of the interval (In/Out) + \param stepSize Step size (Return value) + */ + virtual void autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const + = 0; + + /*! + \brief Calculate a scale division + + \param x1 First interval limit + \param x2 Second interval limit + \param maxMajorSteps Maximum for the number of major steps + \param maxMinorSteps Maximum number of minor steps + \param stepSize Step size. If stepSize == 0.0, the scaleEngine + calculates one. + + \return Calculated scale division + */ + virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, + int maxMinorSteps, + double stepSize = 0.0) const + = 0; + + void setTransformation(QwtTransform *); + QwtTransform *transformation() const; + +protected: + bool contains(const QwtInterval &, double value) const; + QList strip(const QList &, const QwtInterval &) const; + + double divideInterval(double intervalSize, int numSteps) const; + + QwtInterval buildInterval(double value) const; + +private: + Q_DISABLE_COPY(QwtScaleEngine) + + class PrivateData; + PrivateData *m_data; }; /*! @@ -150,31 +151,29 @@ class QWT_EXPORT QwtScaleEngine class QWT_EXPORT QwtLinearScaleEngine : public QwtScaleEngine { - public: - explicit QwtLinearScaleEngine( uint base = 10 ); - virtual ~QwtLinearScaleEngine(); +public: + explicit QwtLinearScaleEngine(uint base = 10); + virtual ~QwtLinearScaleEngine(); - virtual void autoScale( int maxNumSteps, - double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE; + virtual void autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const QWT_OVERRIDE; - virtual QwtScaleDiv divideScale( double x1, double x2, - int maxMajorSteps, int maxMinorSteps, - double stepSize = 0.0 ) const QWT_OVERRIDE; + virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, + int maxMinorSteps, + double stepSize = 0.0) const QWT_OVERRIDE; +protected: + QwtInterval align(const QwtInterval &, double stepSize) const; - protected: - QwtInterval align( const QwtInterval&, double stepSize ) const; + void buildTicks(const QwtInterval &, double stepSize, int maxMinorSteps, + QList ticks[QwtScaleDiv::NTickTypes]) const; - void buildTicks( - const QwtInterval&, double stepSize, int maxMinorSteps, - QList< double > ticks[QwtScaleDiv::NTickTypes] ) const; + QList buildMajorTicks(const QwtInterval &interval, + double stepSize) const; - QList< double > buildMajorTicks( - const QwtInterval& interval, double stepSize ) const; - - void buildMinorTicks( const QList< double >& majorTicks, - int maxMinorSteps, double stepSize, - QList< double >& minorTicks, QList< double >& mediumTicks ) const; + void buildMinorTicks(const QList &majorTicks, int maxMinorSteps, + double stepSize, QList &minorTicks, + QList &mediumTicks) const; }; /*! @@ -190,32 +189,31 @@ class QWT_EXPORT QwtLinearScaleEngine : public QwtScaleEngine class QWT_EXPORT QwtLogScaleEngine : public QwtScaleEngine { - public: - explicit QwtLogScaleEngine( uint base = 10 ); - virtual ~QwtLogScaleEngine(); +public: + explicit QwtLogScaleEngine(uint base = 10); + virtual ~QwtLogScaleEngine(); - virtual void autoScale( int maxNumSteps, - double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE; + virtual void autoScale(int maxNumSteps, double &x1, double &x2, + double &stepSize) const QWT_OVERRIDE; - virtual QwtScaleDiv divideScale( double x1, double x2, - int maxMajorSteps, int maxMinorSteps, - double stepSize = 0.0 ) const QWT_OVERRIDE; + virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, + int maxMinorSteps, + double stepSize = 0.0) const QWT_OVERRIDE; - protected: - QwtInterval align( const QwtInterval&, double stepSize ) const; +protected: + QwtInterval align(const QwtInterval &, double stepSize) const; - void buildTicks( - const QwtInterval&, double stepSize, int maxMinorSteps, - QList< double > ticks[QwtScaleDiv::NTickTypes] ) const; + void buildTicks(const QwtInterval &, double stepSize, int maxMinorSteps, + QList ticks[QwtScaleDiv::NTickTypes]) const; - QList< double > buildMajorTicks( - const QwtInterval& interval, double stepSize ) const; + QList buildMajorTicks(const QwtInterval &interval, + double stepSize) const; - void buildMinorTicks( const QList< double >& majorTicks, - int maxMinorSteps, double stepSize, - QList< double >& minorTicks, QList< double >& mediumTicks ) const; + void buildMinorTicks(const QList &majorTicks, int maxMinorSteps, + double stepSize, QList &minorTicks, + QList &mediumTicks) const; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtScaleEngine::Attributes) #endif diff --git a/libs/qwt/src/qwt_scale_map.cpp b/libs/qwt/src/qwt_scale_map.cpp index 8be2f6fe..1bb91a07 100644 --- a/libs/qwt/src/qwt_scale_map.cpp +++ b/libs/qwt/src/qwt_scale_map.cpp @@ -19,28 +19,28 @@ The scale and paint device intervals are both set to [0,1]. */ QwtScaleMap::QwtScaleMap() - : m_s1( 0.0 ) - , m_s2( 1.0 ) - , m_p1( 0.0 ) - , m_p2( 1.0 ) - , m_cnv( 1.0 ) - , m_ts1( 0.0 ) - , m_transform( NULL ) + : m_s1(0.0) + , m_s2(1.0) + , m_p1(0.0) + , m_p2(1.0) + , m_cnv(1.0) + , m_ts1(0.0) + , m_transform(NULL) { } //! Copy constructor -QwtScaleMap::QwtScaleMap( const QwtScaleMap& other ) - : m_s1( other.m_s1 ) - , m_s2( other.m_s2 ) - , m_p1( other.m_p1 ) - , m_p2( other.m_p2 ) - , m_cnv( other.m_cnv ) - , m_ts1( other.m_ts1 ) - , m_transform( NULL ) +QwtScaleMap::QwtScaleMap(const QwtScaleMap &other) + : m_s1(other.m_s1) + , m_s2(other.m_s2) + , m_p1(other.m_p1) + , m_p2(other.m_p2) + , m_cnv(other.m_cnv) + , m_ts1(other.m_ts1) + , m_transform(NULL) { - if ( other.m_transform ) - m_transform = other.m_transform->copy(); + if (other.m_transform) + m_transform = other.m_transform->copy(); } /*! @@ -48,46 +48,46 @@ QwtScaleMap::QwtScaleMap( const QwtScaleMap& other ) */ QwtScaleMap::~QwtScaleMap() { - delete m_transform; + delete m_transform; } //! Assignment operator -QwtScaleMap& QwtScaleMap::operator=( const QwtScaleMap& other ) +QwtScaleMap &QwtScaleMap::operator=(const QwtScaleMap &other) { - m_s1 = other.m_s1; - m_s2 = other.m_s2; - m_p1 = other.m_p1; - m_p2 = other.m_p2; - m_cnv = other.m_cnv; - m_ts1 = other.m_ts1; + m_s1 = other.m_s1; + m_s2 = other.m_s2; + m_p1 = other.m_p1; + m_p2 = other.m_p2; + m_cnv = other.m_cnv; + m_ts1 = other.m_ts1; - delete m_transform; - m_transform = NULL; + delete m_transform; + m_transform = NULL; - if ( other.m_transform ) - m_transform = other.m_transform->copy(); + if (other.m_transform) + m_transform = other.m_transform->copy(); - return *this; + return *this; } /*! Initialize the map with a transformation */ -void QwtScaleMap::setTransformation( QwtTransform* transform ) +void QwtScaleMap::setTransformation(QwtTransform *transform) { - if ( transform != m_transform ) - { - delete m_transform; - m_transform = transform; - } + if (transform != m_transform) + { + delete m_transform; + m_transform = transform; + } - setScaleInterval( m_s1, m_s2 ); + setScaleInterval(m_s1, m_s2); } //! Get the transformation -const QwtTransform* QwtScaleMap::transformation() const +const QwtTransform *QwtScaleMap::transformation() const { - return m_transform; + return m_transform; } /*! @@ -97,18 +97,18 @@ const QwtTransform* QwtScaleMap::transformation() const \warning scales might be aligned to transformation depending boundaries */ -void QwtScaleMap::setScaleInterval( double s1, double s2 ) +void QwtScaleMap::setScaleInterval(double s1, double s2) { - m_s1 = s1; - m_s2 = s2; + m_s1 = s1; + m_s2 = s2; - if ( m_transform ) - { - m_s1 = m_transform->bounded( m_s1 ); - m_s2 = m_transform->bounded( m_s2 ); - } + if (m_transform) + { + m_s1 = m_transform->bounded(m_s1); + m_s2 = m_transform->bounded(m_s2); + } - updateFactor(); + updateFactor(); } /*! @@ -116,28 +116,28 @@ void QwtScaleMap::setScaleInterval( double s1, double s2 ) \param p1 first border \param p2 second border */ -void QwtScaleMap::setPaintInterval( double p1, double p2 ) +void QwtScaleMap::setPaintInterval(double p1, double p2) { - m_p1 = p1; - m_p2 = p2; + m_p1 = p1; + m_p2 = p2; - updateFactor(); + updateFactor(); } void QwtScaleMap::updateFactor() { - m_ts1 = m_s1; - double ts2 = m_s2; + m_ts1 = m_s1; + double ts2 = m_s2; - if ( m_transform ) - { - m_ts1 = m_transform->transform( m_ts1 ); - ts2 = m_transform->transform( ts2 ); - } + if (m_transform) + { + m_ts1 = m_transform->transform(m_ts1); + ts2 = m_transform->transform(ts2); + } - m_cnv = 1.0; - if ( m_ts1 != ts2 ) - m_cnv = ( m_p2 - m_p1 ) / ( ts2 - m_ts1 ); + m_cnv = 1.0; + if (m_ts1 != ts2) + m_cnv = (m_p2 - m_p1) / (ts2 - m_ts1); } /*! @@ -150,29 +150,29 @@ void QwtScaleMap::updateFactor() \sa invTransform() */ -QRectF QwtScaleMap::transform( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QRectF& rect ) +QRectF QwtScaleMap::transform(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QRectF &rect) { - double x1 = xMap.transform( rect.left() ); - double x2 = xMap.transform( rect.right() ); - double y1 = yMap.transform( rect.top() ); - double y2 = yMap.transform( rect.bottom() ); + double x1 = xMap.transform(rect.left()); + double x2 = xMap.transform(rect.right()); + double y1 = yMap.transform(rect.top()); + double y2 = yMap.transform(rect.bottom()); - if ( x2 < x1 ) - qSwap( x1, x2 ); - if ( y2 < y1 ) - qSwap( y1, y2 ); + if (x2 < x1) + qSwap(x1, x2); + if (y2 < y1) + qSwap(y1, y2); - if ( qwtFuzzyCompare( x1, 0.0, x2 - x1 ) == 0 ) - x1 = 0.0; - if ( qwtFuzzyCompare( x2, 0.0, x2 - x1 ) == 0 ) - x2 = 0.0; - if ( qwtFuzzyCompare( y1, 0.0, y2 - y1 ) == 0 ) - y1 = 0.0; - if ( qwtFuzzyCompare( y2, 0.0, y2 - y1 ) == 0 ) - y2 = 0.0; + if (qwtFuzzyCompare(x1, 0.0, x2 - x1) == 0) + x1 = 0.0; + if (qwtFuzzyCompare(x2, 0.0, x2 - x1) == 0) + x2 = 0.0; + if (qwtFuzzyCompare(y1, 0.0, y2 - y1) == 0) + y1 = 0.0; + if (qwtFuzzyCompare(y2, 0.0, y2 - y1) == 0) + y2 = 0.0; - return QRectF( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ); + return QRectF(x1, y1, x2 - x1 + 1, y2 - y1 + 1); } /*! @@ -184,13 +184,10 @@ QRectF QwtScaleMap::transform( const QwtScaleMap& xMap, \return Position in scale coordinates \sa transform() */ -QPointF QwtScaleMap::invTransform( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QPointF& pos ) +QPointF QwtScaleMap::invTransform(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QPointF &pos) { - return QPointF( - xMap.invTransform( pos.x() ), - yMap.invTransform( pos.y() ) - ); + return QPointF(xMap.invTransform(pos.x()), yMap.invTransform(pos.y())); } /*! @@ -203,13 +200,10 @@ QPointF QwtScaleMap::invTransform( const QwtScaleMap& xMap, \sa invTransform() */ -QPointF QwtScaleMap::transform( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QPointF& pos ) +QPointF QwtScaleMap::transform(const QwtScaleMap &xMap, const QwtScaleMap &yMap, + const QPointF &pos) { - return QPointF( - xMap.transform( pos.x() ), - yMap.transform( pos.y() ) - ); + return QPointF(xMap.transform(pos.x()), yMap.transform(pos.y())); } /*! @@ -221,29 +215,27 @@ QPointF QwtScaleMap::transform( const QwtScaleMap& xMap, \return Rectangle in scale coordinates \sa transform() */ -QRectF QwtScaleMap::invTransform( const QwtScaleMap& xMap, - const QwtScaleMap& yMap, const QRectF& rect ) +QRectF QwtScaleMap::invTransform(const QwtScaleMap &xMap, + const QwtScaleMap &yMap, const QRectF &rect) { - const double x1 = xMap.invTransform( rect.left() ); - const double x2 = xMap.invTransform( rect.right() - 1 ); - const double y1 = yMap.invTransform( rect.top() ); - const double y2 = yMap.invTransform( rect.bottom() - 1 ); + const double x1 = xMap.invTransform(rect.left()); + const double x2 = xMap.invTransform(rect.right() - 1); + const double y1 = yMap.invTransform(rect.top()); + const double y2 = yMap.invTransform(rect.bottom() - 1); - const QRectF r( x1, y1, x2 - x1, y2 - y1 ); - return r.normalized(); + const QRectF r(x1, y1, x2 - x1, y2 - y1); + return r.normalized(); } #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<( QDebug debug, const QwtScaleMap& map ) +QDebug operator<<(QDebug debug, const QwtScaleMap &map) { - debug.nospace() << "QwtScaleMap(" - << map.transformation() - << ", s:" << map.s1() << "->" << map.s2() - << ", p:" << map.p1() << "->" << map.p2() - << ")"; + debug.nospace() << "QwtScaleMap(" << map.transformation() + << ", s:" << map.s1() << "->" << map.s2() + << ", p:" << map.p1() << "->" << map.p2() << ")"; - return debug.space(); + return debug.space(); } #endif diff --git a/libs/qwt/src/qwt_scale_map.h b/libs/qwt/src/qwt_scale_map.h index 7f9e038a..aa700ddd 100644 --- a/libs/qwt/src/qwt_scale_map.h +++ b/libs/qwt/src/qwt_scale_map.h @@ -25,56 +25,56 @@ class QRectF; */ class QWT_EXPORT QwtScaleMap { - public: - QwtScaleMap(); - QwtScaleMap( const QwtScaleMap& ); +public: + QwtScaleMap(); + QwtScaleMap(const QwtScaleMap &); - ~QwtScaleMap(); + ~QwtScaleMap(); - QwtScaleMap& operator=( const QwtScaleMap& ); + QwtScaleMap &operator=(const QwtScaleMap &); - void setTransformation( QwtTransform* ); - const QwtTransform* transformation() const; + void setTransformation(QwtTransform *); + const QwtTransform *transformation() const; - void setPaintInterval( double p1, double p2 ); - void setScaleInterval( double s1, double s2 ); + void setPaintInterval(double p1, double p2); + void setScaleInterval(double s1, double s2); - double transform( double s ) const; - double invTransform( double p ) const; + double transform(double s) const; + double invTransform(double p) const; - double p1() const; - double p2() const; + double p1() const; + double p2() const; - double s1() const; - double s2() const; + double s1() const; + double s2() const; - double pDist() const; - double sDist() const; + double pDist() const; + double sDist() const; - static QRectF transform( const QwtScaleMap&, - const QwtScaleMap&, const QRectF& ); + static QRectF transform(const QwtScaleMap &, const QwtScaleMap &, + const QRectF &); - static QRectF invTransform( const QwtScaleMap&, - const QwtScaleMap&, const QRectF& ); + static QRectF invTransform(const QwtScaleMap &, const QwtScaleMap &, + const QRectF &); - static QPointF transform( const QwtScaleMap&, - const QwtScaleMap&, const QPointF& ); + static QPointF transform(const QwtScaleMap &, const QwtScaleMap &, + const QPointF &); - static QPointF invTransform( const QwtScaleMap&, - const QwtScaleMap&, const QPointF& ); + static QPointF invTransform(const QwtScaleMap &, const QwtScaleMap &, + const QPointF &); - bool isInverting() const; + bool isInverting() const; - private: - void updateFactor(); +private: + void updateFactor(); - double m_s1, m_s2; // scale interval boundaries - double m_p1, m_p2; // paint device interval boundaries + double m_s1, m_s2; // scale interval boundaries + double m_p1, m_p2; // paint device interval boundaries - double m_cnv; // conversion factor - double m_ts1; + double m_cnv; // conversion factor + double m_ts1; - QwtTransform* m_transform; + QwtTransform *m_transform; }; /*! @@ -82,7 +82,7 @@ class QWT_EXPORT QwtScaleMap */ inline double QwtScaleMap::s1() const { - return m_s1; + return m_s1; } /*! @@ -90,7 +90,7 @@ inline double QwtScaleMap::s1() const */ inline double QwtScaleMap::s2() const { - return m_s2; + return m_s2; } /*! @@ -98,7 +98,7 @@ inline double QwtScaleMap::s2() const */ inline double QwtScaleMap::p1() const { - return m_p1; + return m_p1; } /*! @@ -106,7 +106,7 @@ inline double QwtScaleMap::p1() const */ inline double QwtScaleMap::p2() const { - return m_p2; + return m_p2; } /*! @@ -114,7 +114,7 @@ inline double QwtScaleMap::p2() const */ inline double QwtScaleMap::pDist() const { - return qAbs( m_p2 - m_p1 ); + return qAbs(m_p2 - m_p1); } /*! @@ -122,7 +122,7 @@ inline double QwtScaleMap::pDist() const */ inline double QwtScaleMap::sDist() const { - return qAbs( m_s2 - m_s1 ); + return qAbs(m_s2 - m_s1); } /*! @@ -134,12 +134,12 @@ inline double QwtScaleMap::sDist() const \sa invTransform() */ -inline double QwtScaleMap::transform( double s ) const +inline double QwtScaleMap::transform(double s) const { - if ( m_transform ) - s = m_transform->transform( s ); + if (m_transform) + s = m_transform->transform(s); - return m_p1 + ( s - m_ts1 ) * m_cnv; + return m_p1 + (s - m_ts1) * m_cnv; } /*! @@ -151,23 +151,23 @@ inline double QwtScaleMap::transform( double s ) const \sa transform() */ -inline double QwtScaleMap::invTransform( double p ) const +inline double QwtScaleMap::invTransform(double p) const { - double s = m_ts1 + ( p - m_p1 ) / m_cnv; - if ( m_transform ) - s = m_transform->invTransform( s ); + double s = m_ts1 + (p - m_p1) / m_cnv; + if (m_transform) + s = m_transform->invTransform(s); - return s; + return s; } //! \return True, when ( p1() < p2() ) != ( s1() < s2() ) inline bool QwtScaleMap::isInverting() const { - return ( ( m_p1 < m_p2 ) != ( m_s1 < m_s2 ) ); + return ((m_p1 < m_p2) != (m_s1 < m_s2)); } #ifndef QT_NO_DEBUG_STREAM -QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap& ); +QWT_EXPORT QDebug operator<<(QDebug, const QwtScaleMap &); #endif #endif diff --git a/libs/qwt/src/qwt_scale_widget.cpp b/libs/qwt/src/qwt_scale_widget.cpp index 3ce6e693..0d5882df 100644 --- a/libs/qwt/src/qwt_scale_widget.cpp +++ b/libs/qwt/src/qwt_scale_widget.cpp @@ -26,49 +26,49 @@ class QwtScaleWidget::PrivateData { - public: - PrivateData() - : scaleDraw( NULL ) - { - colorBar.colorMap = NULL; - } +public: + PrivateData() + : scaleDraw(NULL) + { + colorBar.colorMap = NULL; + } - ~PrivateData() - { - delete scaleDraw; - delete colorBar.colorMap; - } + ~PrivateData() + { + delete scaleDraw; + delete colorBar.colorMap; + } - QwtScaleDraw* scaleDraw; + QwtScaleDraw *scaleDraw; - int borderDist[2]; - int minBorderDist[2]; - int scaleLength; - int margin; + int borderDist[2]; + int minBorderDist[2]; + int scaleLength; + int margin; - int titleOffset; - int spacing; - QwtText title; + int titleOffset; + int spacing; + QwtText title; - QwtScaleWidget::LayoutFlags layoutFlags; + QwtScaleWidget::LayoutFlags layoutFlags; - struct t_colorBar - { - bool isEnabled; - int width; - QwtInterval interval; - QwtColorMap* colorMap; - } colorBar; + struct t_colorBar + { + bool isEnabled; + int width; + QwtInterval interval; + QwtColorMap *colorMap; + } colorBar; }; /*! \brief Create a scale with the position QwtScaleWidget::Left \param parent Parent widget */ -QwtScaleWidget::QwtScaleWidget( QWidget* parent ) - : QWidget( parent ) +QwtScaleWidget::QwtScaleWidget(QWidget *parent) + : QWidget(parent) { - initScale( QwtScaleDraw::LeftScale ); + initScale(QwtScaleDraw::LeftScale); } /*! @@ -76,58 +76,56 @@ QwtScaleWidget::QwtScaleWidget( QWidget* parent ) \param align Alignment. \param parent Parent widget */ -QwtScaleWidget::QwtScaleWidget( QwtScaleDraw::Alignment align, QWidget* parent ) - : QWidget( parent ) +QwtScaleWidget::QwtScaleWidget(QwtScaleDraw::Alignment align, QWidget *parent) + : QWidget(parent) { - initScale( align ); + initScale(align); } //! Destructor QwtScaleWidget::~QwtScaleWidget() { - delete m_data; + delete m_data; } //! Initialize the scale -void QwtScaleWidget::initScale( QwtScaleDraw::Alignment align ) +void QwtScaleWidget::initScale(QwtScaleDraw::Alignment align) { - m_data = new PrivateData; + m_data = new PrivateData; - if ( align == QwtScaleDraw::RightScale ) - m_data->layoutFlags |= TitleInverted; + if (align == QwtScaleDraw::RightScale) + m_data->layoutFlags |= TitleInverted; - m_data->borderDist[0] = 0; - m_data->borderDist[1] = 0; - m_data->minBorderDist[0] = 0; - m_data->minBorderDist[1] = 0; - m_data->margin = 4; - m_data->titleOffset = 0; - m_data->spacing = 2; + m_data->borderDist[0] = 0; + m_data->borderDist[1] = 0; + m_data->minBorderDist[0] = 0; + m_data->minBorderDist[1] = 0; + m_data->margin = 4; + m_data->titleOffset = 0; + m_data->spacing = 2; - m_data->scaleDraw = new QwtScaleDraw; - m_data->scaleDraw->setAlignment( align ); - m_data->scaleDraw->setLength( 10 ); + m_data->scaleDraw = new QwtScaleDraw; + m_data->scaleDraw->setAlignment(align); + m_data->scaleDraw->setLength(10); - m_data->scaleDraw->setScaleDiv( - QwtLinearScaleEngine().divideScale( 0.0, 100.0, 10, 5 ) ); + m_data->scaleDraw->setScaleDiv( + QwtLinearScaleEngine().divideScale(0.0, 100.0, 10, 5)); - m_data->colorBar.colorMap = new QwtLinearColorMap(); - m_data->colorBar.isEnabled = false; - m_data->colorBar.width = 10; + m_data->colorBar.colorMap = new QwtLinearColorMap(); + m_data->colorBar.isEnabled = false; + m_data->colorBar.width = 10; - const int flags = Qt::AlignHCenter - | Qt::TextExpandTabs | Qt::TextWordWrap; - m_data->title.setRenderFlags( flags ); - m_data->title.setFont( font() ); + const int flags = Qt::AlignHCenter | Qt::TextExpandTabs | Qt::TextWordWrap; + m_data->title.setRenderFlags(flags); + m_data->title.setFont(font()); - QSizePolicy policy( QSizePolicy::MinimumExpanding, - QSizePolicy::Fixed ); - if ( m_data->scaleDraw->orientation() == Qt::Vertical ) - policy.transpose(); + QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + if (m_data->scaleDraw->orientation() == Qt::Vertical) + policy.transpose(); - setSizePolicy( policy ); + setSizePolicy(policy); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); + setAttribute(Qt::WA_WState_OwnSizePolicy, false); } /*! @@ -138,17 +136,17 @@ void QwtScaleWidget::initScale( QwtScaleDraw::Alignment align ) \sa testLayoutFlag(), LayoutFlag */ -void QwtScaleWidget::setLayoutFlag( LayoutFlag flag, bool on ) +void QwtScaleWidget::setLayoutFlag(LayoutFlag flag, bool on) { - if ( ( ( m_data->layoutFlags & flag ) != 0 ) != on ) - { - if ( on ) - m_data->layoutFlags |= flag; - else - m_data->layoutFlags &= ~flag; + if (((m_data->layoutFlags & flag) != 0) != on) + { + if (on) + m_data->layoutFlags |= flag; + else + m_data->layoutFlags &= ~flag; - update(); - } + update(); + } } /*! @@ -158,9 +156,9 @@ void QwtScaleWidget::setLayoutFlag( LayoutFlag flag, bool on ) \return true/false \sa setLayoutFlag(), LayoutFlag */ -bool QwtScaleWidget::testLayoutFlag( LayoutFlag flag ) const +bool QwtScaleWidget::testLayoutFlag(LayoutFlag flag) const { - return ( m_data->layoutFlags & flag ); + return (m_data->layoutFlags & flag); } /*! @@ -169,13 +167,13 @@ bool QwtScaleWidget::testLayoutFlag( LayoutFlag flag ) const \param title New title \sa title(), setTitle(const QwtText &); */ -void QwtScaleWidget::setTitle( const QString& title ) +void QwtScaleWidget::setTitle(const QString &title) { - if ( m_data->title.text() != title ) - { - m_data->title.setText( title ); - layoutScale(); - } + if (m_data->title.text() != title) + { + m_data->title.setText(title); + layoutScale(); + } } /*! @@ -187,17 +185,17 @@ void QwtScaleWidget::setTitle( const QString& title ) direction of the label, AlignTop, AlignBottom can't be set as the title will always be aligned to the scale. */ -void QwtScaleWidget::setTitle( const QwtText& title ) +void QwtScaleWidget::setTitle(const QwtText &title) { - QwtText t = title; - const int flags = title.renderFlags() & ~( Qt::AlignTop | Qt::AlignBottom ); - t.setRenderFlags( flags ); + QwtText t = title; + const int flags = title.renderFlags() & ~(Qt::AlignTop | Qt::AlignBottom); + t.setRenderFlags(flags); - if ( t != m_data->title ) - { - m_data->title = t; - layoutScale(); - } + if (t != m_data->title) + { + m_data->title = t; + layoutScale(); + } } /*! @@ -206,37 +204,35 @@ void QwtScaleWidget::setTitle( const QwtText& title ) \param alignment New alignment \sa alignment() */ -void QwtScaleWidget::setAlignment( QwtScaleDraw::Alignment alignment ) +void QwtScaleWidget::setAlignment(QwtScaleDraw::Alignment alignment) { - if ( m_data->scaleDraw ) - m_data->scaleDraw->setAlignment( alignment ); + if (m_data->scaleDraw) + m_data->scaleDraw->setAlignment(alignment); - if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) ) - { - QSizePolicy policy( QSizePolicy::MinimumExpanding, - QSizePolicy::Fixed ); - if ( m_data->scaleDraw->orientation() == Qt::Vertical ) - policy.transpose(); + if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) + { + QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + if (m_data->scaleDraw->orientation() == Qt::Vertical) + policy.transpose(); - setSizePolicy( policy ); + setSizePolicy(policy); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); - } + setAttribute(Qt::WA_WState_OwnSizePolicy, false); + } - layoutScale(); + layoutScale(); } - /*! \return position \sa setPosition() */ QwtScaleDraw::Alignment QwtScaleWidget::alignment() const { - if ( !scaleDraw() ) - return QwtScaleDraw::LeftScale; + if (!scaleDraw()) + return QwtScaleDraw::LeftScale; - return scaleDraw()->alignment(); + return scaleDraw()->alignment(); } /*! @@ -247,14 +243,14 @@ QwtScaleDraw::Alignment QwtScaleWidget::alignment() const \param dist2 Right or bottom distance \sa borderDist() */ -void QwtScaleWidget::setBorderDist( int dist1, int dist2 ) +void QwtScaleWidget::setBorderDist(int dist1, int dist2) { - if ( dist1 != m_data->borderDist[0] || dist2 != m_data->borderDist[1] ) - { - m_data->borderDist[0] = dist1; - m_data->borderDist[1] = dist2; - layoutScale(); - } + if (dist1 != m_data->borderDist[0] || dist2 != m_data->borderDist[1]) + { + m_data->borderDist[0] = dist1; + m_data->borderDist[1] = dist2; + layoutScale(); + } } /*! @@ -262,14 +258,14 @@ void QwtScaleWidget::setBorderDist( int dist1, int dist2 ) \param margin Margin \sa margin() */ -void QwtScaleWidget::setMargin( int margin ) +void QwtScaleWidget::setMargin(int margin) { - margin = qMax( 0, margin ); - if ( margin != m_data->margin ) - { - m_data->margin = margin; - layoutScale(); - } + margin = qMax(0, margin); + if (margin != m_data->margin) + { + m_data->margin = margin; + layoutScale(); + } } /*! @@ -277,14 +273,14 @@ void QwtScaleWidget::setMargin( int margin ) \param spacing Spacing \sa spacing() */ -void QwtScaleWidget::setSpacing( int spacing ) +void QwtScaleWidget::setSpacing(int spacing) { - spacing = qMax( 0, spacing ); - if ( spacing != m_data->spacing ) - { - m_data->spacing = spacing; - layoutScale(); - } + spacing = qMax(0, spacing); + if (spacing != m_data->spacing) + { + m_data->spacing = spacing; + layoutScale(); + } } /*! @@ -292,10 +288,10 @@ void QwtScaleWidget::setSpacing( int spacing ) \sa QwtScaleDraw::setLabelAlignment(), setLabelRotation() */ -void QwtScaleWidget::setLabelAlignment( Qt::Alignment alignment ) +void QwtScaleWidget::setLabelAlignment(Qt::Alignment alignment) { - m_data->scaleDraw->setLabelAlignment( alignment ); - layoutScale(); + m_data->scaleDraw->setLabelAlignment(alignment); + layoutScale(); } /*! @@ -305,10 +301,10 @@ void QwtScaleWidget::setLabelAlignment( Qt::Alignment alignment ) \param rotation Rotation \sa QwtScaleDraw::setLabelRotation(), setLabelFlags() */ -void QwtScaleWidget::setLabelRotation( double rotation ) +void QwtScaleWidget::setLabelRotation(double rotation) { - m_data->scaleDraw->setLabelRotation( rotation ); - layoutScale(); + m_data->scaleDraw->setLabelRotation(rotation); + layoutScale(); } /*! @@ -322,46 +318,46 @@ void QwtScaleWidget::setLabelRotation( double rotation ) \param scaleDraw ScaleDraw object \sa scaleDraw() */ -void QwtScaleWidget::setScaleDraw( QwtScaleDraw* scaleDraw ) +void QwtScaleWidget::setScaleDraw(QwtScaleDraw *scaleDraw) { - if ( ( scaleDraw == NULL ) || ( scaleDraw == m_data->scaleDraw ) ) - return; + if ((scaleDraw == NULL) || (scaleDraw == m_data->scaleDraw)) + return; - const QwtScaleDraw* sd = m_data->scaleDraw; - if ( sd ) - { - scaleDraw->setAlignment( sd->alignment() ); - scaleDraw->setScaleDiv( sd->scaleDiv() ); + const QwtScaleDraw *sd = m_data->scaleDraw; + if (sd) + { + scaleDraw->setAlignment(sd->alignment()); + scaleDraw->setScaleDiv(sd->scaleDiv()); - QwtTransform* transform = NULL; - if ( sd->scaleMap().transformation() ) - transform = sd->scaleMap().transformation()->copy(); + QwtTransform *transform = NULL; + if (sd->scaleMap().transformation()) + transform = sd->scaleMap().transformation()->copy(); - scaleDraw->setTransformation( transform ); - } + scaleDraw->setTransformation(transform); + } - delete m_data->scaleDraw; - m_data->scaleDraw = scaleDraw; + delete m_data->scaleDraw; + m_data->scaleDraw = scaleDraw; - layoutScale(); + layoutScale(); } /*! \return scaleDraw of this scale \sa setScaleDraw(), QwtScaleDraw::setScaleDraw() */ -const QwtScaleDraw* QwtScaleWidget::scaleDraw() const +const QwtScaleDraw *QwtScaleWidget::scaleDraw() const { - return m_data->scaleDraw; + return m_data->scaleDraw; } /*! \return scaleDraw of this scale \sa QwtScaleDraw::setScaleDraw() */ -QwtScaleDraw* QwtScaleWidget::scaleDraw() +QwtScaleDraw *QwtScaleWidget::scaleDraw() { - return m_data->scaleDraw; + return m_data->scaleDraw; } /*! @@ -370,7 +366,7 @@ QwtScaleDraw* QwtScaleWidget::scaleDraw() */ QwtText QwtScaleWidget::title() const { - return m_data->title; + return m_data->title; } /*! @@ -379,7 +375,7 @@ QwtText QwtScaleWidget::title() const */ int QwtScaleWidget::startBorderDist() const { - return m_data->borderDist[0]; + return m_data->borderDist[0]; } /*! @@ -388,7 +384,7 @@ int QwtScaleWidget::startBorderDist() const */ int QwtScaleWidget::endBorderDist() const { - return m_data->borderDist[1]; + return m_data->borderDist[1]; } /*! @@ -397,7 +393,7 @@ int QwtScaleWidget::endBorderDist() const */ int QwtScaleWidget::margin() const { - return m_data->margin; + return m_data->margin; } /*! @@ -406,51 +402,51 @@ int QwtScaleWidget::margin() const */ int QwtScaleWidget::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! \brief paintEvent */ -void QwtScaleWidget::paintEvent( QPaintEvent* event ) +void QwtScaleWidget::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - draw( &painter ); + draw(&painter); } /*! \brief draw the scale */ -void QwtScaleWidget::draw( QPainter* painter ) const +void QwtScaleWidget::draw(QPainter *painter) const { - m_data->scaleDraw->draw( painter, palette() ); + m_data->scaleDraw->draw(painter, palette()); - if ( m_data->colorBar.isEnabled && m_data->colorBar.width > 0 && - m_data->colorBar.interval.isValid() ) - { - drawColorBar( painter, colorBarRect( contentsRect() ) ); - } + if (m_data->colorBar.isEnabled && m_data->colorBar.width > 0 + && m_data->colorBar.interval.isValid()) + { + drawColorBar(painter, colorBarRect(contentsRect())); + } - QRect r = contentsRect(); - if ( m_data->scaleDraw->orientation() == Qt::Horizontal ) - { - r.setLeft( r.left() + m_data->borderDist[0] ); - r.setWidth( r.width() - m_data->borderDist[1] ); - } - else - { - r.setTop( r.top() + m_data->borderDist[0] ); - r.setHeight( r.height() - m_data->borderDist[1] ); - } + QRect r = contentsRect(); + if (m_data->scaleDraw->orientation() == Qt::Horizontal) + { + r.setLeft(r.left() + m_data->borderDist[0]); + r.setWidth(r.width() - m_data->borderDist[1]); + } + else + { + r.setTop(r.top() + m_data->borderDist[0]); + r.setHeight(r.height() - m_data->borderDist[1]); + } - if ( !m_data->title.isEmpty() ) - drawTitle( painter, m_data->scaleDraw->alignment(), r ); + if (!m_data->title.isEmpty()) + drawTitle(painter, m_data->scaleDraw->alignment(), r); } /*! @@ -459,55 +455,49 @@ void QwtScaleWidget::draw( QPainter* painter ) const \param rect Bounding rectangle for all components of the scale \return Rectangle for the color bar */ -QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const +QRectF QwtScaleWidget::colorBarRect(const QRectF &rect) const { - QRectF cr = rect; + QRectF cr = rect; - if ( m_data->scaleDraw->orientation() == Qt::Horizontal ) - { - cr.setLeft( cr.left() + m_data->borderDist[0] ); - cr.setWidth( cr.width() - m_data->borderDist[1] + 1 ); - } - else - { - cr.setTop( cr.top() + m_data->borderDist[0] ); - cr.setHeight( cr.height() - m_data->borderDist[1] + 1 ); + if (m_data->scaleDraw->orientation() == Qt::Horizontal) + { + cr.setLeft(cr.left() + m_data->borderDist[0]); + cr.setWidth(cr.width() - m_data->borderDist[1] + 1); + } + else + { + cr.setTop(cr.top() + m_data->borderDist[0]); + cr.setHeight(cr.height() - m_data->borderDist[1] + 1); + } + + switch (m_data->scaleDraw->alignment()) + { + case QwtScaleDraw::LeftScale: { + cr.setLeft(cr.right() - m_data->margin - m_data->colorBar.width); + cr.setWidth(m_data->colorBar.width); + break; } - switch ( m_data->scaleDraw->alignment() ) - { - case QwtScaleDraw::LeftScale: - { - cr.setLeft( cr.right() - m_data->margin - - m_data->colorBar.width ); - cr.setWidth( m_data->colorBar.width ); - break; - } - - case QwtScaleDraw::RightScale: - { - cr.setLeft( cr.left() + m_data->margin ); - cr.setWidth( m_data->colorBar.width ); - break; - } - - case QwtScaleDraw::BottomScale: - { - cr.setTop( cr.top() + m_data->margin ); - cr.setHeight( m_data->colorBar.width ); - break; - } - - case QwtScaleDraw::TopScale: - { - cr.setTop( cr.bottom() - m_data->margin - - m_data->colorBar.width ); - cr.setHeight( m_data->colorBar.width ); - break; - } + case QwtScaleDraw::RightScale: { + cr.setLeft(cr.left() + m_data->margin); + cr.setWidth(m_data->colorBar.width); + break; } - return cr; + case QwtScaleDraw::BottomScale: { + cr.setTop(cr.top() + m_data->margin); + cr.setHeight(m_data->colorBar.width); + break; + } + + case QwtScaleDraw::TopScale: { + cr.setTop(cr.bottom() - m_data->margin - m_data->colorBar.width); + cr.setHeight(m_data->colorBar.width); + break; + } + } + + return cr; } /*! @@ -516,24 +506,24 @@ QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const Invalidates internal caches if necessary */ -void QwtScaleWidget::changeEvent( QEvent* event ) +void QwtScaleWidget::changeEvent(QEvent *event) { - if ( event->type() == QEvent::LocaleChange ) - { - m_data->scaleDraw->invalidateCache(); - } + if (event->type() == QEvent::LocaleChange) + { + m_data->scaleDraw->invalidateCache(); + } - QWidget::changeEvent( event ); + QWidget::changeEvent(event); } /*! Event handler for resize events \param event Resize event */ -void QwtScaleWidget::resizeEvent( QResizeEvent* event ) +void QwtScaleWidget::resizeEvent(QResizeEvent *event) { - Q_UNUSED( event ); - layoutScale( false ); + Q_UNUSED(event); + layoutScale(false); } /*! @@ -544,73 +534,73 @@ void QwtScaleWidget::resizeEvent( QResizeEvent* event ) to redraw the scale */ -void QwtScaleWidget::layoutScale( bool update_geometry ) +void QwtScaleWidget::layoutScale(bool update_geometry) { - int bd0, bd1; - getBorderDistHint( bd0, bd1 ); - if ( m_data->borderDist[0] > bd0 ) - bd0 = m_data->borderDist[0]; - if ( m_data->borderDist[1] > bd1 ) - bd1 = m_data->borderDist[1]; + int bd0, bd1; + getBorderDistHint(bd0, bd1); + if (m_data->borderDist[0] > bd0) + bd0 = m_data->borderDist[0]; + if (m_data->borderDist[1] > bd1) + bd1 = m_data->borderDist[1]; - int colorBarWidth = 0; - if ( m_data->colorBar.isEnabled && m_data->colorBar.interval.isValid() ) - colorBarWidth = m_data->colorBar.width + m_data->spacing; + int colorBarWidth = 0; + if (m_data->colorBar.isEnabled && m_data->colorBar.interval.isValid()) + colorBarWidth = m_data->colorBar.width + m_data->spacing; - const QRectF r = contentsRect(); - double x, y, length; + const QRectF r = contentsRect(); + double x, y, length; - if ( m_data->scaleDraw->orientation() == Qt::Vertical ) - { - y = r.top() + bd0; - length = r.height() - ( bd0 + bd1 ); + if (m_data->scaleDraw->orientation() == Qt::Vertical) + { + y = r.top() + bd0; + length = r.height() - (bd0 + bd1); - if ( m_data->scaleDraw->alignment() == QwtScaleDraw::LeftScale ) - x = r.right() - 1.0 - m_data->margin - colorBarWidth; - else - x = r.left() + m_data->margin + colorBarWidth; - } + if (m_data->scaleDraw->alignment() == QwtScaleDraw::LeftScale) + x = r.right() - 1.0 - m_data->margin - colorBarWidth; else - { - x = r.left() + bd0; - length = r.width() - ( bd0 + bd1 ); + x = r.left() + m_data->margin + colorBarWidth; + } + else + { + x = r.left() + bd0; + length = r.width() - (bd0 + bd1); - if ( m_data->scaleDraw->alignment() == QwtScaleDraw::BottomScale ) - y = r.top() + m_data->margin + colorBarWidth; - else - y = r.bottom() - 1.0 - m_data->margin - colorBarWidth; - } + if (m_data->scaleDraw->alignment() == QwtScaleDraw::BottomScale) + y = r.top() + m_data->margin + colorBarWidth; + else + y = r.bottom() - 1.0 - m_data->margin - colorBarWidth; + } - m_data->scaleDraw->move( x, y ); - m_data->scaleDraw->setLength( length ); + m_data->scaleDraw->move(x, y); + m_data->scaleDraw->setLength(length); - const int extent = qwtCeil( m_data->scaleDraw->extent( font() ) ); + const int extent = qwtCeil(m_data->scaleDraw->extent(font())); - m_data->titleOffset = - m_data->margin + m_data->spacing + colorBarWidth + extent; + m_data->titleOffset + = m_data->margin + m_data->spacing + colorBarWidth + extent; - if ( update_geometry ) - { - updateGeometry(); + if (update_geometry) + { + updateGeometry(); #if 1 - /* - for some reason updateGeometry does not send a LayoutRequest event - when the parent is not visible and has no layout - */ + /* + for some reason updateGeometry does not send a LayoutRequest event + when the parent is not visible and has no layout + */ - if ( QWidget* w = parentWidget() ) - { - if ( !w->isVisible() && w->layout() == NULL ) - { - if ( w->testAttribute( Qt::WA_WState_Polished ) ) - QApplication::postEvent( w, new QEvent( QEvent::LayoutRequest ) ); - } - } + if (QWidget *w = parentWidget()) + { + if (!w->isVisible() && w->layout() == NULL) + { + if (w->testAttribute(Qt::WA_WState_Polished)) + QApplication::postEvent(w, new QEvent(QEvent::LayoutRequest)); + } + } #endif - update(); - } + update(); + } } /*! @@ -621,16 +611,16 @@ void QwtScaleWidget::layoutScale( bool update_geometry ) \sa setColorBarEnabled() */ -void QwtScaleWidget::drawColorBar( QPainter* painter, const QRectF& rect ) const +void QwtScaleWidget::drawColorBar(QPainter *painter, const QRectF &rect) const { - if ( !m_data->colorBar.interval.isValid() ) - return; + if (!m_data->colorBar.interval.isValid()) + return; - const QwtScaleDraw* sd = m_data->scaleDraw; + const QwtScaleDraw *sd = m_data->scaleDraw; - QwtPainter::drawColorBar( painter, *m_data->colorBar.colorMap, - m_data->colorBar.interval.normalized(), sd->scaleMap(), - sd->orientation(), rect ); + QwtPainter::drawColorBar(painter, *m_data->colorBar.colorMap, + m_data->colorBar.interval.normalized(), + sd->scaleMap(), sd->orientation(), rect); } /*! @@ -641,68 +631,66 @@ void QwtScaleWidget::drawColorBar( QPainter* painter, const QRectF& rect ) const \param rect Bounding rectangle */ -void QwtScaleWidget::drawTitle( QPainter* painter, - QwtScaleDraw::Alignment align, const QRectF& rect ) const +void QwtScaleWidget::drawTitle(QPainter *painter, QwtScaleDraw::Alignment align, + const QRectF &rect) const { - QRectF r = rect; - double angle; - int flags = m_data->title.renderFlags() & - ~( Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter ); + QRectF r = rect; + double angle; + int flags = m_data->title.renderFlags() + & ~(Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter); - switch ( align ) + switch (align) + { + case QwtScaleDraw::LeftScale: + angle = -90.0; + flags |= Qt::AlignTop; + r.setRect(r.left(), r.bottom(), r.height(), + r.width() - m_data->titleOffset); + break; + + case QwtScaleDraw::RightScale: + angle = -90.0; + flags |= Qt::AlignTop; + r.setRect(r.left() + m_data->titleOffset, r.bottom(), r.height(), + r.width() - m_data->titleOffset); + break; + + case QwtScaleDraw::BottomScale: + angle = 0.0; + flags |= Qt::AlignBottom; + r.setTop(r.top() + m_data->titleOffset); + break; + + case QwtScaleDraw::TopScale: + default: + angle = 0.0; + flags |= Qt::AlignTop; + r.setBottom(r.bottom() - m_data->titleOffset); + break; + } + + if (m_data->layoutFlags & TitleInverted) + { + if (align == QwtScaleDraw::LeftScale || align == QwtScaleDraw::RightScale) { - case QwtScaleDraw::LeftScale: - angle = -90.0; - flags |= Qt::AlignTop; - r.setRect( r.left(), r.bottom(), - r.height(), r.width() - m_data->titleOffset ); - break; - - case QwtScaleDraw::RightScale: - angle = -90.0; - flags |= Qt::AlignTop; - r.setRect( r.left() + m_data->titleOffset, r.bottom(), - r.height(), r.width() - m_data->titleOffset ); - break; - - case QwtScaleDraw::BottomScale: - angle = 0.0; - flags |= Qt::AlignBottom; - r.setTop( r.top() + m_data->titleOffset ); - break; - - case QwtScaleDraw::TopScale: - default: - angle = 0.0; - flags |= Qt::AlignTop; - r.setBottom( r.bottom() - m_data->titleOffset ); - break; + angle = -angle; + r.setRect(r.x() + r.height(), r.y() - r.width(), r.width(), r.height()); } + } - if ( m_data->layoutFlags & TitleInverted ) - { - if ( align == QwtScaleDraw::LeftScale - || align == QwtScaleDraw::RightScale ) - { - angle = -angle; - r.setRect( r.x() + r.height(), r.y() - r.width(), - r.width(), r.height() ); - } - } + painter->save(); + painter->setFont(font()); + painter->setPen(palette().color(QPalette::Text)); - painter->save(); - painter->setFont( font() ); - painter->setPen( palette().color( QPalette::Text ) ); + painter->translate(r.x(), r.y()); + if (angle != 0.0) + painter->rotate(angle); - painter->translate( r.x(), r.y() ); - if ( angle != 0.0 ) - painter->rotate( angle ); + QwtText title = m_data->title; + title.setRenderFlags(flags); + title.draw(painter, QRectF(0.0, 0.0, r.width(), r.height())); - QwtText title = m_data->title; - title.setRenderFlags( flags ); - title.draw( painter, QRectF( 0.0, 0.0, r.width(), r.height() ) ); - - painter->restore(); + painter->restore(); } /*! @@ -715,7 +703,7 @@ void QwtScaleWidget::drawTitle( QPainter* painter, void QwtScaleWidget::scaleChange() { - layoutScale(); + layoutScale(); } /*! @@ -723,7 +711,7 @@ void QwtScaleWidget::scaleChange() */ QSize QwtScaleWidget::sizeHint() const { - return minimumSizeHint(); + return minimumSizeHint(); } /*! @@ -731,31 +719,31 @@ QSize QwtScaleWidget::sizeHint() const */ QSize QwtScaleWidget::minimumSizeHint() const { - const Qt::Orientation o = m_data->scaleDraw->orientation(); + const Qt::Orientation o = m_data->scaleDraw->orientation(); - // Border Distance cannot be less than the scale borderDistHint - // Note, the borderDistHint is already included in minHeight/minWidth - int length = 0; - int mbd1, mbd2; - getBorderDistHint( mbd1, mbd2 ); - length += qMax( 0, m_data->borderDist[0] - mbd1 ); - length += qMax( 0, m_data->borderDist[1] - mbd2 ); - length += m_data->scaleDraw->minLength( font() ); + // Border Distance cannot be less than the scale borderDistHint + // Note, the borderDistHint is already included in minHeight/minWidth + int length = 0; + int mbd1, mbd2; + getBorderDistHint(mbd1, mbd2); + length += qMax(0, m_data->borderDist[0] - mbd1); + length += qMax(0, m_data->borderDist[1] - mbd2); + length += m_data->scaleDraw->minLength(font()); - int dim = dimForLength( length, font() ); - if ( length < dim ) - { - // compensate for long titles - length = dim; - dim = dimForLength( length, font() ); - } + int dim = dimForLength(length, font()); + if (length < dim) + { + // compensate for long titles + length = dim; + dim = dimForLength(length, font()); + } - QSize size( length + 2, dim ); - if ( o == Qt::Vertical ) - size.transpose(); + QSize size(length + 2, dim); + if (o == Qt::Vertical) + size.transpose(); - const QMargins m = contentsMargins(); - return size + QSize( m.left() + m.right(), m.top() + m.bottom() ); + const QMargins m = contentsMargins(); + return size + QSize(m.left() + m.right(), m.top() + m.bottom()); } /*! @@ -764,9 +752,9 @@ QSize QwtScaleWidget::minimumSizeHint() const \return height Height */ -int QwtScaleWidget::titleHeightForWidth( int width ) const +int QwtScaleWidget::titleHeightForWidth(int width) const { - return qwtCeil( m_data->title.heightForWidth( width, font() ) ); + return qwtCeil(m_data->title.heightForWidth(width, font())); } /*! @@ -778,19 +766,19 @@ int QwtScaleWidget::titleHeightForWidth( int width ) const \return height for horizontal, width for vertical scales */ -int QwtScaleWidget::dimForLength( int length, const QFont& scaleFont ) const +int QwtScaleWidget::dimForLength(int length, const QFont &scaleFont) const { - const int extent = qwtCeil( m_data->scaleDraw->extent( scaleFont ) ); + const int extent = qwtCeil(m_data->scaleDraw->extent(scaleFont)); - int dim = m_data->margin + extent + 1; + int dim = m_data->margin + extent + 1; - if ( !m_data->title.isEmpty() ) - dim += titleHeightForWidth( length ) + m_data->spacing; + if (!m_data->title.isEmpty()) + dim += titleHeightForWidth(length) + m_data->spacing; - if ( m_data->colorBar.isEnabled && m_data->colorBar.interval.isValid() ) - dim += m_data->colorBar.width + m_data->spacing; + if (m_data->colorBar.isEnabled && m_data->colorBar.interval.isValid()) + dim += m_data->colorBar.width + m_data->spacing; - return dim; + return dim; } /*! @@ -811,15 +799,15 @@ int QwtScaleWidget::dimForLength( int length, const QFont& scaleFont ) const
  • The minimum border distance depends on the font.
\sa setMinBorderDist(), getMinBorderDist(), setBorderDist() */ -void QwtScaleWidget::getBorderDistHint( int& start, int& end ) const +void QwtScaleWidget::getBorderDistHint(int &start, int &end) const { - m_data->scaleDraw->getBorderDistHint( font(), start, end ); + m_data->scaleDraw->getBorderDistHint(font(), start, end); - if ( start < m_data->minBorderDist[0] ) - start = m_data->minBorderDist[0]; + if (start < m_data->minBorderDist[0]) + start = m_data->minBorderDist[0]; - if ( end < m_data->minBorderDist[1] ) - end = m_data->minBorderDist[1]; + if (end < m_data->minBorderDist[1]) + end = m_data->minBorderDist[1]; } /*! @@ -832,10 +820,10 @@ void QwtScaleWidget::getBorderDistHint( int& start, int& end ) const \param end Minimum for the end border \sa getMinBorderDist(), getBorderDistHint() */ -void QwtScaleWidget::setMinBorderDist( int start, int end ) +void QwtScaleWidget::setMinBorderDist(int start, int end) { - m_data->minBorderDist[0] = start; - m_data->minBorderDist[1] = end; + m_data->minBorderDist[0] = start; + m_data->minBorderDist[1] = end; } /*! @@ -849,10 +837,10 @@ void QwtScaleWidget::setMinBorderDist( int start, int end ) \sa setMinBorderDist(), getBorderDistHint() */ -void QwtScaleWidget::getMinBorderDist( int& start, int& end ) const +void QwtScaleWidget::getMinBorderDist(int &start, int &end) const { - start = m_data->minBorderDist[0]; - end = m_data->minBorderDist[1]; + start = m_data->minBorderDist[0]; + end = m_data->minBorderDist[1]; } /*! @@ -863,16 +851,16 @@ void QwtScaleWidget::getMinBorderDist( int& start, int& end ) const \param scaleDiv Scale Division \sa For more information about scale divisions, see QwtScaleDiv. */ -void QwtScaleWidget::setScaleDiv( const QwtScaleDiv& scaleDiv ) +void QwtScaleWidget::setScaleDiv(const QwtScaleDiv &scaleDiv) { - QwtScaleDraw* sd = m_data->scaleDraw; - if ( sd->scaleDiv() != scaleDiv ) - { - sd->setScaleDiv( scaleDiv ); - layoutScale(); + QwtScaleDraw *sd = m_data->scaleDraw; + if (sd->scaleDiv() != scaleDiv) + { + sd->setScaleDiv(scaleDiv); + layoutScale(); - Q_EMIT scaleDivChanged(); - } + Q_EMIT scaleDivChanged(); + } } /*! @@ -881,23 +869,23 @@ void QwtScaleWidget::setScaleDiv( const QwtScaleDiv& scaleDiv ) \param transformation Transformation \sa QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap */ -void QwtScaleWidget::setTransformation( QwtTransform* transformation ) +void QwtScaleWidget::setTransformation(QwtTransform *transformation) { - m_data->scaleDraw->setTransformation( transformation ); - layoutScale(); + m_data->scaleDraw->setTransformation(transformation); + layoutScale(); } /*! En/disable a color bar associated to the scale \sa isColorBarEnabled(), setColorBarWidth() */ -void QwtScaleWidget::setColorBarEnabled( bool on ) +void QwtScaleWidget::setColorBarEnabled(bool on) { - if ( on != m_data->colorBar.isEnabled ) - { - m_data->colorBar.isEnabled = on; - layoutScale(); - } + if (on != m_data->colorBar.isEnabled) + { + m_data->colorBar.isEnabled = on; + layoutScale(); + } } /*! @@ -906,7 +894,7 @@ void QwtScaleWidget::setColorBarEnabled( bool on ) */ bool QwtScaleWidget::isColorBarEnabled() const { - return m_data->colorBar.isEnabled; + return m_data->colorBar.isEnabled; } /*! @@ -915,14 +903,14 @@ bool QwtScaleWidget::isColorBarEnabled() const \param width Width \sa colorBarWidth(), setColorBarEnabled() */ -void QwtScaleWidget::setColorBarWidth( int width ) +void QwtScaleWidget::setColorBarWidth(int width) { - if ( width != m_data->colorBar.width ) - { - m_data->colorBar.width = width; - if ( isColorBarEnabled() ) - layoutScale(); - } + if (width != m_data->colorBar.width) + { + m_data->colorBar.width = width; + if (isColorBarEnabled()) + layoutScale(); + } } /*! @@ -931,7 +919,7 @@ void QwtScaleWidget::setColorBarWidth( int width ) */ int QwtScaleWidget::colorBarWidth() const { - return m_data->colorBar.width; + return m_data->colorBar.width; } /*! @@ -940,7 +928,7 @@ int QwtScaleWidget::colorBarWidth() const */ QwtInterval QwtScaleWidget::colorBarInterval() const { - return m_data->colorBar.interval; + return m_data->colorBar.interval; } /*! @@ -952,30 +940,30 @@ QwtInterval QwtScaleWidget::colorBarInterval() const \sa colorMap(), colorBarInterval() */ -void QwtScaleWidget::setColorMap( - const QwtInterval& interval, QwtColorMap* colorMap ) +void QwtScaleWidget::setColorMap(const QwtInterval &interval, + QwtColorMap *colorMap) { - m_data->colorBar.interval = interval; + m_data->colorBar.interval = interval; - if ( colorMap != m_data->colorBar.colorMap ) - { - delete m_data->colorBar.colorMap; - m_data->colorBar.colorMap = colorMap; - } + if (colorMap != m_data->colorBar.colorMap) + { + delete m_data->colorBar.colorMap; + m_data->colorBar.colorMap = colorMap; + } - if ( isColorBarEnabled() ) - layoutScale(); + if (isColorBarEnabled()) + layoutScale(); } /*! \return Color map \sa setColorMap(), colorBarInterval() */ -const QwtColorMap* QwtScaleWidget::colorMap() const +const QwtColorMap *QwtScaleWidget::colorMap() const { - return m_data->colorBar.colorMap; + return m_data->colorBar.colorMap; } #if QWT_MOC_INCLUDE -#include "moc_qwt_scale_widget.cpp" +# include "moc_qwt_scale_widget.cpp" #endif diff --git a/libs/qwt/src/qwt_scale_widget.h b/libs/qwt/src/qwt_scale_widget.h index 02f5e6d4..6cc82312 100644 --- a/libs/qwt/src/qwt_scale_widget.h +++ b/libs/qwt/src/qwt_scale_widget.h @@ -33,105 +33,104 @@ class QwtColorMap; class QWT_EXPORT QwtScaleWidget : public QWidget { - Q_OBJECT + Q_OBJECT - public: - //! Layout flags of the title - enum LayoutFlag - { - /*! - The title of vertical scales is painted from top to bottom. - Otherwise it is painted from bottom to top. - */ - TitleInverted = 1 - }; +public: + //! Layout flags of the title + enum LayoutFlag + { + /*! + The title of vertical scales is painted from top to bottom. + Otherwise it is painted from bottom to top. + */ + TitleInverted = 1 + }; - Q_DECLARE_FLAGS( LayoutFlags, LayoutFlag ) + Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) - explicit QwtScaleWidget( QWidget* parent = NULL ); - explicit QwtScaleWidget( QwtScaleDraw::Alignment, QWidget* parent = NULL ); - virtual ~QwtScaleWidget(); + explicit QwtScaleWidget(QWidget *parent = NULL); + explicit QwtScaleWidget(QwtScaleDraw::Alignment, QWidget *parent = NULL); + virtual ~QwtScaleWidget(); - Q_SIGNALS: - //! Signal emitted, whenever the scale division changes - void scaleDivChanged(); +Q_SIGNALS: + //! Signal emitted, whenever the scale division changes + void scaleDivChanged(); - public: - void setTitle( const QString& title ); - void setTitle( const QwtText& title ); - QwtText title() const; +public: + void setTitle(const QString &title); + void setTitle(const QwtText &title); + QwtText title() const; - void setLayoutFlag( LayoutFlag, bool on ); - bool testLayoutFlag( LayoutFlag ) const; + void setLayoutFlag(LayoutFlag, bool on); + bool testLayoutFlag(LayoutFlag) const; - void setBorderDist( int dist1, int dist2 ); - int startBorderDist() const; - int endBorderDist() const; + void setBorderDist(int dist1, int dist2); + int startBorderDist() const; + int endBorderDist() const; - void getBorderDistHint( int& start, int& end ) const; + void getBorderDistHint(int &start, int &end) const; - void getMinBorderDist( int& start, int& end ) const; - void setMinBorderDist( int start, int end ); + void getMinBorderDist(int &start, int &end) const; + void setMinBorderDist(int start, int end); - void setMargin( int ); - int margin() const; + void setMargin(int); + int margin() const; - void setSpacing( int ); - int spacing() const; + void setSpacing(int); + int spacing() const; - void setScaleDiv( const QwtScaleDiv& ); - void setTransformation( QwtTransform* ); + void setScaleDiv(const QwtScaleDiv &); + void setTransformation(QwtTransform *); - void setScaleDraw( QwtScaleDraw* ); - const QwtScaleDraw* scaleDraw() const; - QwtScaleDraw* scaleDraw(); + void setScaleDraw(QwtScaleDraw *); + const QwtScaleDraw *scaleDraw() const; + QwtScaleDraw *scaleDraw(); - void setLabelAlignment( Qt::Alignment ); - void setLabelRotation( double rotation ); + void setLabelAlignment(Qt::Alignment); + void setLabelRotation(double rotation); - void setColorBarEnabled( bool ); - bool isColorBarEnabled() const; + void setColorBarEnabled(bool); + bool isColorBarEnabled() const; - void setColorBarWidth( int ); - int colorBarWidth() const; + void setColorBarWidth(int); + int colorBarWidth() const; - void setColorMap( const QwtInterval&, QwtColorMap* ); + void setColorMap(const QwtInterval &, QwtColorMap *); - QwtInterval colorBarInterval() const; - const QwtColorMap* colorMap() const; + QwtInterval colorBarInterval() const; + const QwtColorMap *colorMap() const; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - int titleHeightForWidth( int width ) const; - int dimForLength( int length, const QFont& scaleFont ) const; + int titleHeightForWidth(int width) const; + int dimForLength(int length, const QFont &scaleFont) const; - void drawColorBar( QPainter*, const QRectF& ) const; - void drawTitle( QPainter*, QwtScaleDraw::Alignment, - const QRectF& rect ) const; + void drawColorBar(QPainter *, const QRectF &) const; + void drawTitle(QPainter *, QwtScaleDraw::Alignment, const QRectF &rect) const; - void setAlignment( QwtScaleDraw::Alignment ); - QwtScaleDraw::Alignment alignment() const; + void setAlignment(QwtScaleDraw::Alignment); + QwtScaleDraw::Alignment alignment() const; - QRectF colorBarRect( const QRectF& ) const; + QRectF colorBarRect(const QRectF &) const; - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; - virtual void changeEvent( QEvent* ) QWT_OVERRIDE; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; + virtual void changeEvent(QEvent *) QWT_OVERRIDE; - void draw( QPainter* ) const; + void draw(QPainter *) const; - void scaleChange(); - void layoutScale( bool update_geometry = true ); + void scaleChange(); + void layoutScale(bool update_geometry = true); - private: - void initScale( QwtScaleDraw::Alignment ); +private: + void initScale(QwtScaleDraw::Alignment); - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleWidget::LayoutFlags ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtScaleWidget::LayoutFlags) #endif diff --git a/libs/qwt/src/qwt_series_data.cpp b/libs/qwt/src/qwt_series_data.cpp index 3792a823..67d08f71 100644 --- a/libs/qwt/src/qwt_series_data.cpp +++ b/libs/qwt/src/qwt_series_data.cpp @@ -10,63 +10,63 @@ #include "qwt_series_data.h" #include "qwt_point_polar.h" -static inline QRectF qwtBoundingRect( const QPointF& sample ) +static inline QRectF qwtBoundingRect(const QPointF &sample) { - return QRectF( sample.x(), sample.y(), 0.0, 0.0 ); + return QRectF(sample.x(), sample.y(), 0.0, 0.0); } -static inline QRectF qwtBoundingRect( const QwtPoint3D& sample ) +static inline QRectF qwtBoundingRect(const QwtPoint3D &sample) { - return QRectF( sample.x(), sample.y(), 0.0, 0.0 ); + return QRectF(sample.x(), sample.y(), 0.0, 0.0); } -static inline QRectF qwtBoundingRect( const QwtPointPolar& sample ) +static inline QRectF qwtBoundingRect(const QwtPointPolar &sample) { - return QRectF( sample.azimuth(), sample.radius(), 0.0, 0.0 ); + return QRectF(sample.azimuth(), sample.radius(), 0.0, 0.0); } -static inline QRectF qwtBoundingRect( const QwtIntervalSample& sample ) +static inline QRectF qwtBoundingRect(const QwtIntervalSample &sample) { - return QRectF( sample.interval.minValue(), sample.value, - sample.interval.maxValue() - sample.interval.minValue(), 0.0 ); + return QRectF(sample.interval.minValue(), sample.value, + sample.interval.maxValue() - sample.interval.minValue(), 0.0); } -static inline QRectF qwtBoundingRect( const QwtSetSample& sample ) +static inline QRectF qwtBoundingRect(const QwtSetSample &sample) { - if ( sample.set.empty() ) - return QRectF( sample.value, 0.0, 0.0, -1.0 ); + if (sample.set.empty()) + return QRectF(sample.value, 0.0, 0.0, -1.0); - double minY = sample.set[0]; - double maxY = sample.set[0]; + double minY = sample.set[0]; + double maxY = sample.set[0]; - for ( int i = 1; i < sample.set.size(); i++ ) - { - if ( sample.set[i] < minY ) - minY = sample.set[i]; + for (int i = 1; i < sample.set.size(); i++) + { + if (sample.set[i] < minY) + minY = sample.set[i]; - if ( sample.set[i] > maxY ) - maxY = sample.set[i]; - } + if (sample.set[i] > maxY) + maxY = sample.set[i]; + } - return QRectF( sample.value, minY, 0.0, maxY - minY ); + return QRectF(sample.value, minY, 0.0, maxY - minY); } -static inline QRectF qwtBoundingRect( const QwtOHLCSample& sample ) +static inline QRectF qwtBoundingRect(const QwtOHLCSample &sample) { - const QwtInterval interval = sample.boundingInterval(); - return QRectF( interval.minValue(), sample.time, interval.width(), 0.0 ); + const QwtInterval interval = sample.boundingInterval(); + return QRectF(interval.minValue(), sample.time, interval.width(), 0.0); } -static inline QRectF qwtBoundingRect( const QwtVectorFieldSample& sample ) +static inline QRectF qwtBoundingRect(const QwtVectorFieldSample &sample) { - /* - When displaying a sample as an arrow its length will be - proportional to the magnitude - but not the same. - As the factor between length and magnitude is not known - we can't include vx/vy into the bounding rectangle. - */ + /* + When displaying a sample as an arrow its length will be + proportional to the magnitude - but not the same. + As the factor between length and magnitude is not known + we can't include vx/vy into the bounding rectangle. + */ - return QRectF( sample.x, sample.y, 0, 0 ); + return QRectF(sample.x, sample.y, 0, 0); } /*! @@ -81,45 +81,45 @@ static inline QRectF qwtBoundingRect( const QwtVectorFieldSample& sample ) \return Bounding rectangle */ -template< class T > -QRectF qwtBoundingRectT( const QwtSeriesData< T >& series, int from, int to ) +template +QRectF qwtBoundingRectT(const QwtSeriesData &series, int from, int to) { - QRectF boundingRect( 1.0, 1.0, -2.0, -2.0 ); // invalid; + QRectF boundingRect(1.0, 1.0, -2.0, -2.0); // invalid; - if ( from < 0 ) - from = 0; + if (from < 0) + from = 0; - if ( to < 0 ) - to = static_cast(series.size()) - 1; - - if ( to < from ) - return boundingRect; - - int i; - for ( i = from; i <= to; i++ ) - { - const QRectF rect = qwtBoundingRect( series.sample( i ) ); - if ( rect.width() >= 0.0 && rect.height() >= 0.0 ) - { - boundingRect = rect; - i++; - break; - } - } - - for ( ; i <= to; i++ ) - { - const QRectF rect = qwtBoundingRect( series.sample( i ) ); - if ( rect.width() >= 0.0 && rect.height() >= 0.0 ) - { - boundingRect.setLeft( qMin( boundingRect.left(), rect.left() ) ); - boundingRect.setRight( qMax( boundingRect.right(), rect.right() ) ); - boundingRect.setTop( qMin( boundingRect.top(), rect.top() ) ); - boundingRect.setBottom( qMax( boundingRect.bottom(), rect.bottom() ) ); - } - } + if (to < 0) + to = static_cast(series.size()) - 1; + if (to < from) return boundingRect; + + int i; + for (i = from; i <= to; i++) + { + const QRectF rect = qwtBoundingRect(series.sample(i)); + if (rect.width() >= 0.0 && rect.height() >= 0.0) + { + boundingRect = rect; + i++; + break; + } + } + + for (; i <= to; i++) + { + const QRectF rect = qwtBoundingRect(series.sample(i)); + if (rect.width() >= 0.0 && rect.height() >= 0.0) + { + boundingRect.setLeft(qMin(boundingRect.left(), rect.left())); + boundingRect.setRight(qMax(boundingRect.right(), rect.right())); + boundingRect.setTop(qMin(boundingRect.top(), rect.top())); + boundingRect.setBottom(qMax(boundingRect.bottom(), rect.bottom())); + } + } + + return boundingRect; } /*! @@ -133,9 +133,9 @@ QRectF qwtBoundingRectT( const QwtSeriesData< T >& series, int from, int to ) \return Bounding rectangle */ -QRectF qwtBoundingRect( const QwtSeriesData< QPointF >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, int from, int to) { - return qwtBoundingRectT< QPointF >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! @@ -149,10 +149,10 @@ QRectF qwtBoundingRect( const QwtSeriesData< QPointF >& series, int from, int to \return Bounding rectangle */ -QRectF qwtBoundingRect( - const QwtSeriesData< QwtPoint3D >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, int from, + int to) { - return qwtBoundingRectT< QwtPoint3D >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! @@ -169,10 +169,10 @@ QRectF qwtBoundingRect( \return Bounding rectangle */ -QRectF qwtBoundingRect( - const QwtSeriesData< QwtPointPolar >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, int from, + int to) { - return qwtBoundingRectT< QwtPointPolar >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! @@ -186,10 +186,10 @@ QRectF qwtBoundingRect( \return Bounding rectangle */ -QRectF qwtBoundingRect( - const QwtSeriesData< QwtIntervalSample >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, int from, + int to) { - return qwtBoundingRectT< QwtIntervalSample >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! @@ -203,10 +203,10 @@ QRectF qwtBoundingRect( \return Bounding rectangle */ -QRectF qwtBoundingRect( - const QwtSeriesData< QwtOHLCSample >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, int from, + int to) { - return qwtBoundingRectT< QwtOHLCSample >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! @@ -220,10 +220,10 @@ QRectF qwtBoundingRect( \return Bounding rectangle */ -QRectF qwtBoundingRect( - const QwtSeriesData< QwtSetSample >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, int from, + int to) { - return qwtBoundingRectT< QwtSetSample >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! @@ -237,18 +237,18 @@ QRectF qwtBoundingRect( \return Bounding rectangle */ -QRectF qwtBoundingRect( - const QwtSeriesData< QwtVectorFieldSample >& series, int from, int to ) +QRectF qwtBoundingRect(const QwtSeriesData &series, + int from, int to) { - return qwtBoundingRectT< QwtVectorFieldSample >( series, from, to ); + return qwtBoundingRectT(series, from, to); } /*! Constructor \param samples Samples */ -QwtPointSeriesData::QwtPointSeriesData( const QVector< QPointF >& samples ) - : QwtArraySeriesData< QPointF >( samples ) +QwtPointSeriesData::QwtPointSeriesData(const QVector &samples) + : QwtArraySeriesData(samples) { } @@ -262,19 +262,18 @@ QwtPointSeriesData::QwtPointSeriesData( const QVector< QPointF >& samples ) */ QRectF QwtPointSeriesData::boundingRect() const { - if ( cachedBoundingRect.width() < 0.0 ) - cachedBoundingRect = qwtBoundingRect( *this ); + if (cachedBoundingRect.width() < 0.0) + cachedBoundingRect = qwtBoundingRect(*this); - return cachedBoundingRect; + return cachedBoundingRect; } /*! Constructor \param samples Samples */ -QwtPoint3DSeriesData::QwtPoint3DSeriesData( - const QVector< QwtPoint3D >& samples ) - : QwtArraySeriesData< QwtPoint3D >( samples ) +QwtPoint3DSeriesData::QwtPoint3DSeriesData(const QVector &samples) + : QwtArraySeriesData(samples) { } @@ -288,10 +287,10 @@ QwtPoint3DSeriesData::QwtPoint3DSeriesData( */ QRectF QwtPoint3DSeriesData::boundingRect() const { - if ( cachedBoundingRect.width() < 0.0 ) - cachedBoundingRect = qwtBoundingRect( *this ); + if (cachedBoundingRect.width() < 0.0) + cachedBoundingRect = qwtBoundingRect(*this); - return cachedBoundingRect; + return cachedBoundingRect; } /*! @@ -299,8 +298,8 @@ QRectF QwtPoint3DSeriesData::boundingRect() const \param samples Samples */ QwtIntervalSeriesData::QwtIntervalSeriesData( - const QVector< QwtIntervalSample >& samples ) - : QwtArraySeriesData< QwtIntervalSample >( samples ) + const QVector &samples) + : QwtArraySeriesData(samples) { } @@ -314,10 +313,10 @@ QwtIntervalSeriesData::QwtIntervalSeriesData( */ QRectF QwtIntervalSeriesData::boundingRect() const { - if ( cachedBoundingRect.width() < 0.0 ) - cachedBoundingRect = qwtBoundingRect( *this ); + if (cachedBoundingRect.width() < 0.0) + cachedBoundingRect = qwtBoundingRect(*this); - return cachedBoundingRect; + return cachedBoundingRect; } /*! @@ -325,8 +324,8 @@ QRectF QwtIntervalSeriesData::boundingRect() const \param samples Samples */ QwtVectorFieldData::QwtVectorFieldData( - const QVector< QwtVectorFieldSample >& samples ) - : QwtArraySeriesData< QwtVectorFieldSample >( samples ) + const QVector &samples) + : QwtArraySeriesData(samples) { } @@ -340,18 +339,18 @@ QwtVectorFieldData::QwtVectorFieldData( */ QRectF QwtVectorFieldData::boundingRect() const { - if ( cachedBoundingRect.width() < 0.0 ) - cachedBoundingRect = qwtBoundingRect( *this ); + if (cachedBoundingRect.width() < 0.0) + cachedBoundingRect = qwtBoundingRect(*this); - return cachedBoundingRect; + return cachedBoundingRect; } /*! Constructor \param samples Samples */ -QwtSetSeriesData::QwtSetSeriesData( const QVector< QwtSetSample >& samples ) - : QwtArraySeriesData< QwtSetSample >( samples ) +QwtSetSeriesData::QwtSetSeriesData(const QVector &samples) + : QwtArraySeriesData(samples) { } @@ -365,18 +364,18 @@ QwtSetSeriesData::QwtSetSeriesData( const QVector< QwtSetSample >& samples ) */ QRectF QwtSetSeriesData::boundingRect() const { - if ( cachedBoundingRect.width() < 0.0 ) - cachedBoundingRect = qwtBoundingRect( *this ); + if (cachedBoundingRect.width() < 0.0) + cachedBoundingRect = qwtBoundingRect(*this); - return cachedBoundingRect; + return cachedBoundingRect; } /*! Constructor \param samples Samples */ -QwtTradingChartData::QwtTradingChartData( const QVector< QwtOHLCSample >& samples ) - : QwtArraySeriesData< QwtOHLCSample >( samples ) +QwtTradingChartData::QwtTradingChartData(const QVector &samples) + : QwtArraySeriesData(samples) { } @@ -390,8 +389,8 @@ QwtTradingChartData::QwtTradingChartData( const QVector< QwtOHLCSample >& sample */ QRectF QwtTradingChartData::boundingRect() const { - if ( cachedBoundingRect.width() < 0.0 ) - cachedBoundingRect = qwtBoundingRect( *this ); + if (cachedBoundingRect.width() < 0.0) + cachedBoundingRect = qwtBoundingRect(*this); - return cachedBoundingRect; + return cachedBoundingRect; } diff --git a/libs/qwt/src/qwt_series_data.h b/libs/qwt/src/qwt_series_data.h index 027f37d7..5aab3c9b 100644 --- a/libs/qwt/src/qwt_series_data.h +++ b/libs/qwt/src/qwt_series_data.h @@ -42,86 +42,87 @@ class QwtPointPolar; the data. You can use qwtBoundingRect() for an implementation but often it is possible to implement a more efficient algorithm depending on the characteristics of the series. - The member cachedBoundingRect is intended for caching the calculated rectangle. + The member cachedBoundingRect is intended for caching the calculated + rectangle. */ -template< typename T > +template class QwtSeriesData { - public: - //! Constructor - QwtSeriesData(); +public: + //! Constructor + QwtSeriesData(); - //! Destructor - virtual ~QwtSeriesData(); + //! Destructor + virtual ~QwtSeriesData(); #ifndef QWT_PYTHON_WRAPPER - //! \return Number of samples - virtual int size() const = 0; + //! \return Number of samples + virtual int size() const = 0; - /*! - Return a sample - \param i Index - \return Sample at position i - */ - virtual T sample( int i ) const = 0; + /*! + Return a sample + \param i Index + \return Sample at position i + */ + virtual T sample(int i) const = 0; - /*! - Calculate the bounding rect of all samples + /*! + Calculate the bounding rect of all samples - The bounding rect is necessary for autoscaling and can be used - for a couple of painting optimizations. + The bounding rect is necessary for autoscaling and can be used + for a couple of painting optimizations. - qwtBoundingRect(...) offers slow implementations iterating - over the samples. For large sets it is recommended to implement - something faster f.e. by caching the bounding rectangle. + qwtBoundingRect(...) offers slow implementations iterating + over the samples. For large sets it is recommended to implement + something faster f.e. by caching the bounding rectangle. - \return Bounding rectangle - */ - virtual QRectF boundingRect() const = 0; + \return Bounding rectangle + */ + virtual QRectF boundingRect() const = 0; #else - // Needed for generating the python bindings, but not for using them ! - virtual int size() const { return 0; } - virtual T sample( int i ) const { return T(); } - virtual QRectF boundingRect() const { return cachedBoundingRect; } + // Needed for generating the python bindings, but not for using them ! + virtual int size() const { return 0; } + virtual T sample(int i) const { return T(); } + virtual QRectF boundingRect() const { return cachedBoundingRect; } #endif - /*! - Set a the "rect of interest" + /*! + Set a the "rect of interest" - QwtPlotSeriesItem defines the current area of the plot canvas - as "rectangle of interest" ( QwtPlotSeriesItem::updateScaleDiv() ). - It can be used to implement different levels of details. + QwtPlotSeriesItem defines the current area of the plot canvas + as "rectangle of interest" ( QwtPlotSeriesItem::updateScaleDiv() ). + It can be used to implement different levels of details. - The default implementation does nothing. + The default implementation does nothing. - \param rect Rectangle of interest - */ - virtual void setRectOfInterest( const QRectF& rect ); + \param rect Rectangle of interest + */ + virtual void setRectOfInterest(const QRectF &rect); - protected: - //! Can be used to cache a calculated bounding rectangle - mutable QRectF cachedBoundingRect; +protected: + //! Can be used to cache a calculated bounding rectangle + mutable QRectF cachedBoundingRect; - private: - QwtSeriesData< T >& operator=( const QwtSeriesData< T >& ); +private: + QwtSeriesData &operator=(const QwtSeriesData &); }; -template< typename T > -QwtSeriesData< T >::QwtSeriesData() - : cachedBoundingRect( 0.0, 0.0, -1.0, -1.0 ) +template +QwtSeriesData::QwtSeriesData() + : cachedBoundingRect(0.0, 0.0, -1.0, -1.0) { } -template< typename T > -QwtSeriesData< T >::~QwtSeriesData() +template +QwtSeriesData::~QwtSeriesData() { } -template< typename T > -void QwtSeriesData< T >::setRectOfInterest( const QRectF& ) +template +void QwtSeriesData::setRectOfInterest(const QRectF &) { } @@ -131,162 +132,161 @@ void QwtSeriesData< T >::setRectOfInterest( const QRectF& ) QVector uses implicit data sharing and can be passed around as argument efficiently. */ -template< typename T > -class QwtArraySeriesData : public QwtSeriesData< T > +template +class QwtArraySeriesData : public QwtSeriesData { - public: - //! Constructor - QwtArraySeriesData(); +public: + //! Constructor + QwtArraySeriesData(); - /*! - Constructor - \param samples Array of samples - */ - explicit QwtArraySeriesData( const QVector< T >& samples ); + /*! + Constructor + \param samples Array of samples + */ + explicit QwtArraySeriesData(const QVector &samples); - /*! - Assign an array of samples - \param samples Array of samples - */ - void setSamples( const QVector< T >& samples ); + /*! + Assign an array of samples + \param samples Array of samples + */ + void setSamples(const QVector &samples); - //! \return Array of samples - const QVector< T > samples() const; + //! \return Array of samples + const QVector samples() const; - //! \return Number of samples - virtual int size() const QWT_OVERRIDE; + //! \return Number of samples + virtual int size() const QWT_OVERRIDE; - /*! - \return Sample at a specific position + /*! + \return Sample at a specific position - \param index Index - \return Sample at position index - */ - virtual T sample( int index ) const QWT_OVERRIDE; + \param index Index + \return Sample at position index + */ + virtual T sample(int index) const QWT_OVERRIDE; - protected: - //! Vector of samples - QVector< T > m_samples; +protected: + //! Vector of samples + QVector m_samples; }; -template< typename T > -QwtArraySeriesData< T >::QwtArraySeriesData() +template +QwtArraySeriesData::QwtArraySeriesData() { } -template< typename T > -QwtArraySeriesData< T >::QwtArraySeriesData( const QVector< T >& samples ) - : m_samples( samples ) +template +QwtArraySeriesData::QwtArraySeriesData(const QVector &samples) + : m_samples(samples) { } -template< typename T > -void QwtArraySeriesData< T >::setSamples( const QVector< T >& samples ) +template +void QwtArraySeriesData::setSamples(const QVector &samples) { - QwtSeriesData< T >::cachedBoundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 ); - m_samples = samples; + QwtSeriesData::cachedBoundingRect = QRectF(0.0, 0.0, -1.0, -1.0); + m_samples = samples; } -template< typename T > -const QVector< T > QwtArraySeriesData< T >::samples() const +template +const QVector QwtArraySeriesData::samples() const { - return m_samples; + return m_samples; } -template< typename T > -int QwtArraySeriesData< T >::size() const +template +int QwtArraySeriesData::size() const { - return m_samples.size(); + return m_samples.size(); } -template< typename T > -T QwtArraySeriesData< T >::sample( int i ) const +template +T QwtArraySeriesData::sample(int i) const { - return m_samples[ static_cast< int >( i ) ]; + return m_samples[static_cast(i)]; } //! Interface for iterating over an array of points -class QWT_EXPORT QwtPointSeriesData : public QwtArraySeriesData< QPointF > +class QWT_EXPORT QwtPointSeriesData : public QwtArraySeriesData { - public: - QwtPointSeriesData( - const QVector< QPointF >& = QVector< QPointF >( ) ); +public: + QwtPointSeriesData(const QVector & = QVector()); - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; }; //! Interface for iterating over an array of 3D points -class QWT_EXPORT QwtPoint3DSeriesData : public QwtArraySeriesData< QwtPoint3D > +class QWT_EXPORT QwtPoint3DSeriesData : public QwtArraySeriesData { - public: - QwtPoint3DSeriesData( - const QVector< QwtPoint3D >& = QVector< QwtPoint3D >( ) ); +public: + QwtPoint3DSeriesData(const QVector & = QVector()); - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; }; //! Interface for iterating over an array of intervals -class QWT_EXPORT QwtIntervalSeriesData : public QwtArraySeriesData< QwtIntervalSample > +class QWT_EXPORT QwtIntervalSeriesData + : public QwtArraySeriesData { - public: - QwtIntervalSeriesData( - const QVector< QwtIntervalSample >& = QVector< QwtIntervalSample >( ) ); +public: + QwtIntervalSeriesData( + const QVector & = QVector()); - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; }; //! Interface for iterating over an array of samples -class QWT_EXPORT QwtSetSeriesData : public QwtArraySeriesData< QwtSetSample > +class QWT_EXPORT QwtSetSeriesData : public QwtArraySeriesData { - public: - QwtSetSeriesData( - const QVector< QwtSetSample >& = QVector< QwtSetSample >( ) ); +public: + QwtSetSeriesData(const QVector & = QVector()); - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; }; //! Interface for iterating over an array of vector field samples -class QWT_EXPORT QwtVectorFieldData : public QwtArraySeriesData< QwtVectorFieldSample > +class QWT_EXPORT QwtVectorFieldData + : public QwtArraySeriesData { - public: - QwtVectorFieldData( - const QVector< QwtVectorFieldSample >& = QVector< QwtVectorFieldSample >( ) ); +public: + QwtVectorFieldData( + const QVector & = QVector()); - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; }; /*! Interface for iterating over an array of OHLC samples */ -class QWT_EXPORT QwtTradingChartData : public QwtArraySeriesData< QwtOHLCSample > +class QWT_EXPORT QwtTradingChartData : public QwtArraySeriesData { - public: - QwtTradingChartData( - const QVector< QwtOHLCSample >& = QVector< QwtOHLCSample >( ) ); +public: + QwtTradingChartData( + const QVector & = QVector()); - virtual QRectF boundingRect() const QWT_OVERRIDE; + virtual QRectF boundingRect() const QWT_OVERRIDE; }; -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QPointF >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, int from = 0, + int to = -1); -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QwtPoint3D >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, + int from = 0, int to = -1); -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QwtPointPolar >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, + int from = 0, int to = -1); -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QwtIntervalSample >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, + int from = 0, int to = -1); -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QwtSetSample >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, + int from = 0, int to = -1); -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QwtOHLCSample >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, + int from = 0, int to = -1); -QWT_EXPORT QRectF qwtBoundingRect( - const QwtSeriesData< QwtVectorFieldSample >&, int from = 0, int to = -1 ); +QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData &, + int from = 0, int to = -1); /*! Binary search for a sorted series of samples @@ -343,35 +343,35 @@ QWT_EXPORT QRectF qwtBoundingRect( \note The samples must be sorted according to the order specified by the lessThan object */ -template< typename T, typename LessThan > -inline int qwtUpperSampleIndex( const QwtSeriesData< T >& series, - double value, LessThan lessThan ) +template +inline int qwtUpperSampleIndex(const QwtSeriesData &series, double value, + LessThan lessThan) { - const int indexMax = series.size() - 1; + const int indexMax = series.size() - 1; - if ( indexMax < 0 || !lessThan( value, series.sample( indexMax ) ) ) - return -1; + if (indexMax < 0 || !lessThan(value, series.sample(indexMax))) + return -1; - int indexMin = 0; - int n = indexMax; + int indexMin = 0; + int n = indexMax; - while ( n > 0 ) + while (n > 0) + { + const int half = n >> 1; + const int indexMid = indexMin + half; + + if (lessThan(value, series.sample(indexMid))) { - const int half = n >> 1; - const int indexMid = indexMin + half; - - if ( lessThan( value, series.sample( indexMid ) ) ) - { - n = half; - } - else - { - indexMin = indexMid + 1; - n -= half + 1; - } + n = half; } + else + { + indexMin = indexMid + 1; + n -= half + 1; + } + } - return indexMin; + return indexMin; } #endif diff --git a/libs/qwt/src/qwt_series_store.h b/libs/qwt/src/qwt_series_store.h index 5f51149f..bb6ce421 100644 --- a/libs/qwt/src/qwt_series_store.h +++ b/libs/qwt/src/qwt_series_store.h @@ -23,32 +23,32 @@ */ class QwtAbstractSeriesStore { - public: - //! Destructor - virtual ~QwtAbstractSeriesStore() {} +public: + //! Destructor + virtual ~QwtAbstractSeriesStore() {} - protected: +protected: #ifndef QWT_PYTHON_WRAPPER - //! dataChanged() indicates, that the series has been changed. - virtual void dataChanged() = 0; + //! dataChanged() indicates, that the series has been changed. + virtual void dataChanged() = 0; - /*! - Set a the "rectangle of interest" for the stored series - \sa QwtSeriesData::setRectOfInterest() - */ - virtual void setRectOfInterest( const QRectF& ) = 0; + /*! + Set a the "rectangle of interest" for the stored series + \sa QwtSeriesData::setRectOfInterest() + */ + virtual void setRectOfInterest(const QRectF &) = 0; - //! \return Bounding rectangle of the stored series - virtual QRectF dataRect() const = 0; + //! \return Bounding rectangle of the stored series + virtual QRectF dataRect() const = 0; - //! \return Number of samples - virtual int dataSize() const = 0; + //! \return Number of samples + virtual int dataSize() const = 0; #else - // Needed for generating the python bindings, but not for using them ! - virtual void dataChanged() {} - virtual void setRectOfInterest( const QRectF& ) {} - virtual QRectF dataRect() const { return QRectF( 0.0, 0.0, -1.0, -1.0 ); } - virtual int dataSize() const { return 0; } + // Needed for generating the python bindings, but not for using them ! + virtual void dataChanged() {} + virtual void setRectOfInterest(const QRectF &) {} + virtual QRectF dataRect() const { return QRectF(0.0, 0.0, -1.0, -1.0); } + virtual int dataSize() const { return 0; } #endif }; @@ -62,147 +62,147 @@ class QwtAbstractSeriesStore QwtSeriesStore offers the template based part for the plot item API, so that QwtPlotSeriesItem can be derived without any hassle with templates. */ -template< typename T > +template class QwtSeriesStore : public virtual QwtAbstractSeriesStore { - public: - /*! - \brief Constructor - The store contains no series - */ - explicit QwtSeriesStore(); +public: + /*! + \brief Constructor + The store contains no series + */ + explicit QwtSeriesStore(); - //! Destructor - ~QwtSeriesStore(); + //! Destructor + ~QwtSeriesStore(); - /*! - Assign a series of samples + /*! + Assign a series of samples - \param series Data - \warning The item takes ownership of the data object, deleting - it when its not used anymore. - */ - void setData( QwtSeriesData< T >* series ); + \param series Data + \warning The item takes ownership of the data object, deleting + it when its not used anymore. + */ + void setData(QwtSeriesData *series); - //! \return the the series data - QwtSeriesData< T >* data(); + //! \return the the series data + QwtSeriesData *data(); - //! \return the the series data - const QwtSeriesData< T >* data() const; + //! \return the the series data + const QwtSeriesData *data() const; - /*! - \param index Index - \return Sample at position index - */ - T sample( int index ) const; + /*! + \param index Index + \return Sample at position index + */ + T sample(int index) const; - /*! - \return Number of samples of the series - \sa setData(), QwtSeriesData::size() - */ - virtual int dataSize() const QWT_OVERRIDE; + /*! + \return Number of samples of the series + \sa setData(), QwtSeriesData::size() + */ + virtual int dataSize() const QWT_OVERRIDE; - /*! - \return Bounding rectangle of the series - or an invalid rectangle, when no series is stored + /*! + \return Bounding rectangle of the series + or an invalid rectangle, when no series is stored - \sa QwtSeriesData::boundingRect() - */ - virtual QRectF dataRect() const QWT_OVERRIDE; + \sa QwtSeriesData::boundingRect() + */ + virtual QRectF dataRect() const QWT_OVERRIDE; - /*! - Set a the "rect of interest" for the series + /*! + Set a the "rect of interest" for the series - \param rect Rectangle of interest - \sa QwtSeriesData::setRectOfInterest() - */ - virtual void setRectOfInterest( const QRectF& rect ) QWT_OVERRIDE; + \param rect Rectangle of interest + \sa QwtSeriesData::setRectOfInterest() + */ + virtual void setRectOfInterest(const QRectF &rect) QWT_OVERRIDE; - /*! - Replace a series without deleting the previous one + /*! + Replace a series without deleting the previous one - \param series New series - \return Previously assigned series - */ - QwtSeriesData< T >* swapData( QwtSeriesData< T >* series ); + \param series New series + \return Previously assigned series + */ + QwtSeriesData *swapData(QwtSeriesData *series); - private: - QwtSeriesData< T >* m_series; +private: + QwtSeriesData *m_series; }; -template< typename T > -QwtSeriesStore< T >::QwtSeriesStore() - : m_series( NULL ) +template +QwtSeriesStore::QwtSeriesStore() + : m_series(NULL) { } -template< typename T > -QwtSeriesStore< T >::~QwtSeriesStore() +template +QwtSeriesStore::~QwtSeriesStore() { + delete m_series; +} + +template +inline QwtSeriesData *QwtSeriesStore::data() +{ + return m_series; +} + +template +inline const QwtSeriesData *QwtSeriesStore::data() const +{ + return m_series; +} + +template +inline T QwtSeriesStore::sample(int index) const +{ + return m_series ? m_series->sample(index) : T(); +} + +template +void QwtSeriesStore::setData(QwtSeriesData *series) +{ + if (m_series != series) + { delete m_series; -} - -template< typename T > -inline QwtSeriesData< T >* QwtSeriesStore< T >::data() -{ - return m_series; -} - -template< typename T > -inline const QwtSeriesData< T >* QwtSeriesStore< T >::data() const -{ - return m_series; -} - -template< typename T > -inline T QwtSeriesStore< T >::sample( int index ) const -{ - return m_series ? m_series->sample( index ) : T(); -} - -template< typename T > -void QwtSeriesStore< T >::setData( QwtSeriesData< T >* series ) -{ - if ( m_series != series ) - { - delete m_series; - m_series = series; - dataChanged(); - } -} - -template< typename T > -int QwtSeriesStore< T >::dataSize() const -{ - if ( m_series == NULL ) - return 0; - - return m_series->size(); -} - -template< typename T > -QRectF QwtSeriesStore< T >::dataRect() const -{ - if ( m_series == NULL ) - return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid - - return m_series->boundingRect(); -} - -template< typename T > -void QwtSeriesStore< T >::setRectOfInterest( const QRectF& rect ) -{ - if ( m_series ) - m_series->setRectOfInterest( rect ); -} - -template< typename T > -QwtSeriesData< T >* QwtSeriesStore< T >::swapData( QwtSeriesData< T >* series ) -{ - QwtSeriesData< T >* swappedSeries = m_series; m_series = series; + dataChanged(); + } +} - return swappedSeries; +template +int QwtSeriesStore::dataSize() const +{ + if (m_series == NULL) + return 0; + + return m_series->size(); +} + +template +QRectF QwtSeriesStore::dataRect() const +{ + if (m_series == NULL) + return QRectF(1.0, 1.0, -2.0, -2.0); // invalid + + return m_series->boundingRect(); +} + +template +void QwtSeriesStore::setRectOfInterest(const QRectF &rect) +{ + if (m_series) + m_series->setRectOfInterest(rect); +} + +template +QwtSeriesData *QwtSeriesStore::swapData(QwtSeriesData *series) +{ + QwtSeriesData *swappedSeries = m_series; + m_series = series; + + return swappedSeries; } #endif diff --git a/libs/qwt/src/qwt_slider.cpp b/libs/qwt/src/qwt_slider.cpp index 030c2485..fad1b4d2 100644 --- a/libs/qwt/src/qwt_slider.cpp +++ b/libs/qwt/src/qwt_slider.cpp @@ -21,90 +21,91 @@ #include #include -static QSize qwtHandleSize( const QSize& size, - Qt::Orientation orientation, bool hasTrough ) +static QSize qwtHandleSize(const QSize &size, Qt::Orientation orientation, + bool hasTrough) { - QSize handleSize = size; + QSize handleSize = size; - if ( handleSize.isEmpty() ) - { - const int handleThickness = 16; - handleSize.setWidth( 2 * handleThickness ); - handleSize.setHeight( handleThickness ); + if (handleSize.isEmpty()) + { + const int handleThickness = 16; + handleSize.setWidth(2 * handleThickness); + handleSize.setHeight(handleThickness); - if ( !hasTrough ) - handleSize.transpose(); + if (!hasTrough) + handleSize.transpose(); - if ( orientation == Qt::Vertical ) - handleSize.transpose(); - } + if (orientation == Qt::Vertical) + handleSize.transpose(); + } - return handleSize; + return handleSize; } -static QwtScaleDraw::Alignment qwtScaleDrawAlignment( - Qt::Orientation orientation, QwtSlider::ScalePosition scalePos ) +static QwtScaleDraw::Alignment +qwtScaleDrawAlignment(Qt::Orientation orientation, + QwtSlider::ScalePosition scalePos) { - QwtScaleDraw::Alignment align; + QwtScaleDraw::Alignment align; - if ( orientation == Qt::Vertical ) - { - // NoScale lays out like Left - if ( scalePos == QwtSlider::LeadingScale ) - align = QwtScaleDraw::RightScale; - else - align = QwtScaleDraw::LeftScale; - } + if (orientation == Qt::Vertical) + { + // NoScale lays out like Left + if (scalePos == QwtSlider::LeadingScale) + align = QwtScaleDraw::RightScale; else - { - // NoScale lays out like Bottom - if ( scalePos == QwtSlider::TrailingScale ) - align = QwtScaleDraw::TopScale; - else - align = QwtScaleDraw::BottomScale; - } + align = QwtScaleDraw::LeftScale; + } + else + { + // NoScale lays out like Bottom + if (scalePos == QwtSlider::TrailingScale) + align = QwtScaleDraw::TopScale; + else + align = QwtScaleDraw::BottomScale; + } - return align; + return align; } class QwtSlider::PrivateData { - public: - PrivateData() - : repeatTimerId( 0 ) - , updateInterval( 150 ) - , stepsIncrement( 0 ) - , pendingValueChange( false ) - , borderWidth( 2 ) - , spacing( 4 ) - , scalePosition( QwtSlider::TrailingScale ) - , hasTrough( true ) - , hasGroove( false ) - , mouseOffset( 0 ) - { - } +public: + PrivateData() + : repeatTimerId(0) + , updateInterval(150) + , stepsIncrement(0) + , pendingValueChange(false) + , borderWidth(2) + , spacing(4) + , scalePosition(QwtSlider::TrailingScale) + , hasTrough(true) + , hasGroove(false) + , mouseOffset(0) + { + } - int repeatTimerId; - bool timerTick; - int updateInterval; - int stepsIncrement; - bool pendingValueChange; + int repeatTimerId; + bool timerTick; + int updateInterval; + int stepsIncrement; + bool pendingValueChange; - QRect sliderRect; + QRect sliderRect; - QSize handleSize; - int borderWidth; - int spacing; + QSize handleSize; + int borderWidth; + int spacing; - Qt::Orientation orientation; - QwtSlider::ScalePosition scalePosition; + Qt::Orientation orientation; + QwtSlider::ScalePosition scalePosition; - bool hasTrough; - bool hasGroove; + bool hasTrough; + bool hasGroove; - int mouseOffset; + int mouseOffset; - mutable QSize sizeHintCache; + mutable QSize sizeHintCache; }; /*! Construct vertical slider in QwtSlider::Trough style @@ -116,10 +117,10 @@ class QwtSlider::PrivateData \sa setOrientation(), setScalePosition(), setBackgroundStyle() */ -QwtSlider::QwtSlider( QWidget* parent ) - : QwtAbstractSlider( parent ) +QwtSlider::QwtSlider(QWidget *parent) + : QwtAbstractSlider(parent) { - initSlider( Qt::Vertical ); + initSlider(Qt::Vertical); } /*! @@ -133,37 +134,37 @@ QwtSlider::QwtSlider( QWidget* parent ) \param parent Parent widget \param orientation Orientation of the slider. */ -QwtSlider::QwtSlider( Qt::Orientation orientation, QWidget* parent ) - : QwtAbstractSlider( parent ) +QwtSlider::QwtSlider(Qt::Orientation orientation, QWidget *parent) + : QwtAbstractSlider(parent) { - initSlider( orientation ); + initSlider(orientation); } //! Destructor QwtSlider::~QwtSlider() { - delete m_data; + delete m_data; } -void QwtSlider::initSlider( Qt::Orientation orientation ) +void QwtSlider::initSlider(Qt::Orientation orientation) { - if ( orientation == Qt::Vertical ) - setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); - else - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + if (orientation == Qt::Vertical) + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + else + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); + setAttribute(Qt::WA_WState_OwnSizePolicy, false); - m_data = new QwtSlider::PrivateData; + m_data = new QwtSlider::PrivateData; - m_data->orientation = orientation; + m_data->orientation = orientation; - scaleDraw()->setAlignment( - qwtScaleDrawAlignment( orientation, m_data->scalePosition ) ); - scaleDraw()->setLength( 100 ); + scaleDraw()->setAlignment( + qwtScaleDrawAlignment(orientation, m_data->scalePosition)); + scaleDraw()->setLength(100); - setScale( 0.0, 100.0 ); - setValue( 0.0 ); + setScale(0.0, 100.0); + setValue(0.0); } /*! @@ -172,27 +173,27 @@ void QwtSlider::initSlider( Qt::Orientation orientation ) \sa orientation(), scalePosition() */ -void QwtSlider::setOrientation( Qt::Orientation orientation ) +void QwtSlider::setOrientation(Qt::Orientation orientation) { - if ( orientation == m_data->orientation ) - return; + if (orientation == m_data->orientation) + return; - m_data->orientation = orientation; + m_data->orientation = orientation; - scaleDraw()->setAlignment( - qwtScaleDrawAlignment( orientation, m_data->scalePosition ) ); + scaleDraw()->setAlignment( + qwtScaleDrawAlignment(orientation, m_data->scalePosition)); - if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) ) - { - QSizePolicy sp = sizePolicy(); - sp.transpose(); - setSizePolicy( sp ); + if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) + { + QSizePolicy sp = sizePolicy(); + sp.transpose(); + setSizePolicy(sp); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); - } + setAttribute(Qt::WA_WState_OwnSizePolicy, false); + } - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); } /*! @@ -201,7 +202,7 @@ void QwtSlider::setOrientation( Qt::Orientation orientation ) */ Qt::Orientation QwtSlider::orientation() const { - return m_data->orientation; + return m_data->orientation; } /*! @@ -210,17 +211,17 @@ Qt::Orientation QwtSlider::orientation() const \sa ScalePosition, scalePosition() */ -void QwtSlider::setScalePosition( ScalePosition scalePosition ) +void QwtSlider::setScalePosition(ScalePosition scalePosition) { - if ( m_data->scalePosition == scalePosition ) - return; + if (m_data->scalePosition == scalePosition) + return; - m_data->scalePosition = scalePosition; - scaleDraw()->setAlignment( - qwtScaleDrawAlignment( m_data->orientation, scalePosition ) ); + m_data->scalePosition = scalePosition; + scaleDraw()->setAlignment( + qwtScaleDrawAlignment(m_data->orientation, scalePosition)); - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); } /*! @@ -229,7 +230,7 @@ void QwtSlider::setScalePosition( ScalePosition scalePosition ) */ QwtSlider::ScalePosition QwtSlider::scalePosition() const { - return m_data->scalePosition; + return m_data->scalePosition; } /*! @@ -241,18 +242,18 @@ QwtSlider::ScalePosition QwtSlider::scalePosition() const \param width Border width \sa borderWidth() */ -void QwtSlider::setBorderWidth( int width ) +void QwtSlider::setBorderWidth(int width) { - if ( width < 0 ) - width = 0; + if (width < 0) + width = 0; - if ( width != m_data->borderWidth ) - { - m_data->borderWidth = width; + if (width != m_data->borderWidth) + { + m_data->borderWidth = width; - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); - } + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); + } } /*! @@ -261,7 +262,7 @@ void QwtSlider::setBorderWidth( int width ) */ int QwtSlider::borderWidth() const { - return m_data->borderWidth; + return m_data->borderWidth; } /*! @@ -275,18 +276,18 @@ int QwtSlider::borderWidth() const \param spacing Number of pixels \sa spacing(); */ -void QwtSlider::setSpacing( int spacing ) +void QwtSlider::setSpacing(int spacing) { - if ( spacing <= 0 ) - spacing = 0; + if (spacing <= 0) + spacing = 0; - if ( spacing != m_data->spacing ) - { - m_data->spacing = spacing; + if (spacing != m_data->spacing) + { + m_data->spacing = spacing; - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); - } + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); + } } /*! @@ -295,7 +296,7 @@ void QwtSlider::setSpacing( int spacing ) */ int QwtSlider::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! @@ -308,15 +309,15 @@ int QwtSlider::spacing() const \sa handleSize() */ -void QwtSlider::setHandleSize( const QSize& size ) +void QwtSlider::setHandleSize(const QSize &size) { - if ( size != m_data->handleSize ) - { - m_data->handleSize = size; + if (size != m_data->handleSize) + { + m_data->handleSize = size; - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); - } + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); + } } /*! @@ -325,7 +326,7 @@ void QwtSlider::setHandleSize( const QSize& size ) */ QSize QwtSlider::handleSize() const { - return m_data->handleSize; + return m_data->handleSize; } /*! @@ -341,46 +342,46 @@ QSize QwtSlider::handleSize() const \sa scaleDraw() */ -void QwtSlider::setScaleDraw( QwtScaleDraw* scaleDraw ) +void QwtSlider::setScaleDraw(QwtScaleDraw *scaleDraw) { - const QwtScaleDraw* previousScaleDraw = this->scaleDraw(); - if ( scaleDraw == NULL || scaleDraw == previousScaleDraw ) - return; + const QwtScaleDraw *previousScaleDraw = this->scaleDraw(); + if (scaleDraw == NULL || scaleDraw == previousScaleDraw) + return; - if ( previousScaleDraw ) - scaleDraw->setAlignment( previousScaleDraw->alignment() ); + if (previousScaleDraw) + scaleDraw->setAlignment(previousScaleDraw->alignment()); - setAbstractScaleDraw( scaleDraw ); + setAbstractScaleDraw(scaleDraw); - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); } /*! \return the scale draw of the slider \sa setScaleDraw() */ -const QwtScaleDraw* QwtSlider::scaleDraw() const +const QwtScaleDraw *QwtSlider::scaleDraw() const { - return static_cast< const QwtScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } /*! \return the scale draw of the slider \sa setScaleDraw() */ -QwtScaleDraw* QwtSlider::scaleDraw() +QwtScaleDraw *QwtSlider::scaleDraw() { - return static_cast< QwtScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } //! Notify changed scale void QwtSlider::scaleChange() { - QwtAbstractSlider::scaleChange(); + QwtAbstractSlider::scaleChange(); - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); } /*! @@ -392,9 +393,9 @@ void QwtSlider::scaleChange() \sa setUpdateInterval() */ -void QwtSlider::setUpdateInterval( int interval ) +void QwtSlider::setUpdateInterval(int interval) { - m_data->updateInterval = qMax( interval, 50 ); + m_data->updateInterval = qMax(interval, 50); } /*! @@ -403,7 +404,7 @@ void QwtSlider::setUpdateInterval( int interval ) */ int QwtSlider::updateInterval() const { - return m_data->updateInterval; + return m_data->updateInterval; } /*! @@ -412,55 +413,53 @@ int QwtSlider::updateInterval() const \param painter Painter \param sliderRect Bounding rectangle of the slider */ -void QwtSlider::drawSlider( - QPainter* painter, const QRect& sliderRect ) const +void QwtSlider::drawSlider(QPainter *painter, const QRect &sliderRect) const { - QRect innerRect( sliderRect ); + QRect innerRect(sliderRect); - if ( m_data->hasTrough ) + if (m_data->hasTrough) + { + const int bw = m_data->borderWidth; + innerRect = sliderRect.adjusted(bw, bw, -bw, -bw); + + painter->fillRect(innerRect, palette().brush(QPalette::Mid)); + qDrawShadePanel(painter, sliderRect, palette(), true, bw, NULL); + } + + if (m_data->hasGroove) + { + const QSize handleSize = qwtHandleSize( + m_data->handleSize, m_data->orientation, m_data->hasTrough); + + const int slotExtent = 4; + const int slotMargin = 4; + + QRect slotRect; + if (orientation() == Qt::Horizontal) { - const int bw = m_data->borderWidth; - innerRect = sliderRect.adjusted( bw, bw, -bw, -bw ); + int slotOffset = qMax(1, handleSize.width() / 2 - slotMargin); + int slotHeight = slotExtent + (innerRect.height() % 2); - painter->fillRect( innerRect, palette().brush( QPalette::Mid ) ); - qDrawShadePanel( painter, sliderRect, palette(), true, bw, NULL ); + slotRect.setWidth(innerRect.width() - 2 * slotOffset); + slotRect.setHeight(slotHeight); + } + else + { + int slotOffset = qMax(1, handleSize.height() / 2 - slotMargin); + int slotWidth = slotExtent + (innerRect.width() % 2); + + slotRect.setWidth(slotWidth); + slotRect.setHeight(innerRect.height() - 2 * slotOffset); } - if ( m_data->hasGroove ) - { - const QSize handleSize = qwtHandleSize( m_data->handleSize, - m_data->orientation, m_data->hasTrough ); + slotRect.moveCenter(innerRect.center()); - const int slotExtent = 4; - const int slotMargin = 4; + QBrush brush = palette().brush(QPalette::Dark); + qDrawShadePanel(painter, slotRect, palette(), true, 1, &brush); + } - QRect slotRect; - if ( orientation() == Qt::Horizontal ) - { - int slotOffset = qMax( 1, handleSize.width() / 2 - slotMargin ); - int slotHeight = slotExtent + ( innerRect.height() % 2 ); - - slotRect.setWidth( innerRect.width() - 2 * slotOffset ); - slotRect.setHeight( slotHeight ); - } - else - { - int slotOffset = qMax( 1, handleSize.height() / 2 - slotMargin ); - int slotWidth = slotExtent + ( innerRect.width() % 2 ); - - slotRect.setWidth( slotWidth ); - slotRect.setHeight( innerRect.height() - 2 * slotOffset ); - - } - - slotRect.moveCenter( innerRect.center() ); - - QBrush brush = palette().brush( QPalette::Dark ); - qDrawShadePanel( painter, slotRect, palette(), true, 1, &brush ); - } - - if ( isValid() ) - drawHandle( painter, handleRect(), transform( value() ) ); + if (isValid()) + drawHandle(painter, handleRect(), transform(value())); } /*! @@ -470,26 +469,25 @@ void QwtSlider::drawSlider( \param handleRect Bounding rectangle of the handle \param pos Position of the handle marker in widget coordinates */ -void QwtSlider::drawHandle( QPainter* painter, - const QRect& handleRect, int pos ) const +void QwtSlider::drawHandle(QPainter *painter, const QRect &handleRect, + int pos) const { - const int bw = m_data->borderWidth; + const int bw = m_data->borderWidth; - qDrawShadePanel( painter, - handleRect, palette(), false, bw, - &palette().brush( QPalette::Button ) ); + qDrawShadePanel(painter, handleRect, palette(), false, bw, + &palette().brush(QPalette::Button)); - pos++; // shade line points one pixel below - if ( orientation() == Qt::Horizontal ) - { - qDrawShadeLine( painter, pos, handleRect.top() + bw, - pos, handleRect.bottom() - bw, palette(), true, 1 ); - } - else // Vertical - { - qDrawShadeLine( painter, handleRect.left() + bw, pos, - handleRect.right() - bw, pos, palette(), true, 1 ); - } + pos++; // shade line points one pixel below + if (orientation() == Qt::Horizontal) + { + qDrawShadeLine(painter, pos, handleRect.top() + bw, pos, + handleRect.bottom() - bw, palette(), true, 1); + } + else // Vertical + { + qDrawShadeLine(painter, handleRect.left() + bw, pos, + handleRect.right() - bw, pos, palette(), true, 1); + } } /*! @@ -500,18 +498,17 @@ void QwtSlider::drawHandle( QPainter* painter, \retval True, when handleRect() contains pos \sa scrolledTo() */ -bool QwtSlider::isScrollPosition( const QPoint& pos ) const +bool QwtSlider::isScrollPosition(const QPoint &pos) const { - if ( handleRect().contains( pos ) ) - { - const double v = ( orientation() == Qt::Horizontal ) - ? pos.x() : pos.y(); + if (handleRect().contains(pos)) + { + const double v = (orientation() == Qt::Horizontal) ? pos.x() : pos.y(); - m_data->mouseOffset = v - transform( value() ); - return true; - } + m_data->mouseOffset = v - transform(value()); + return true; + } - return false; + return false; } /*! @@ -523,103 +520,102 @@ bool QwtSlider::isScrollPosition( const QPoint& pos ) const \return Value for the mouse position \sa isScrollPosition() */ -double QwtSlider::scrolledTo( const QPoint& pos ) const +double QwtSlider::scrolledTo(const QPoint &pos) const { - int p = ( orientation() == Qt::Horizontal ) - ? pos.x() : pos.y(); + int p = (orientation() == Qt::Horizontal) ? pos.x() : pos.y(); - p -= m_data->mouseOffset; + p -= m_data->mouseOffset; - int min = transform( lowerBound() ); - int max = transform( upperBound() ); - if ( min > max ) - qSwap( min, max ); + int min = transform(lowerBound()); + int max = transform(upperBound()); + if (min > max) + qSwap(min, max); - p = qBound( min, p, max ); + p = qBound(min, p, max); - return scaleMap().invTransform( p ); + return scaleMap().invTransform(p); } /*! Mouse press event handler \param event Mouse event */ -void QwtSlider::mousePressEvent( QMouseEvent* event ) +void QwtSlider::mousePressEvent(QMouseEvent *event) { - if ( isReadOnly() ) + if (isReadOnly()) + { + event->ignore(); + return; + } + + const QPoint pos = event->pos(); + + if (isValid() && m_data->sliderRect.contains(pos)) + { + if (!handleRect().contains(pos)) { - event->ignore(); - return; + const int markerPos = transform(value()); + + m_data->stepsIncrement = pageSteps(); + + if (m_data->orientation == Qt::Horizontal) + { + if (pos.x() < markerPos) + m_data->stepsIncrement = -m_data->stepsIncrement; + } + else + { + if (pos.y() < markerPos) + m_data->stepsIncrement = -m_data->stepsIncrement; + } + + if (isInverted()) + m_data->stepsIncrement = -m_data->stepsIncrement; + + const double v = value(); + incrementValue(m_data->stepsIncrement); + + if (v != value()) + { + if (isTracking()) + Q_EMIT valueChanged(value()); + else + m_data->pendingValueChange = true; + + Q_EMIT sliderMoved(value()); + } + + m_data->timerTick = false; + m_data->repeatTimerId = startTimer(qMax(250, 2 * updateInterval())); + + return; } + } - const QPoint pos = event->pos(); - - if ( isValid() && m_data->sliderRect.contains( pos ) ) - { - if ( !handleRect().contains( pos ) ) - { - const int markerPos = transform( value() ); - - m_data->stepsIncrement = pageSteps(); - - if ( m_data->orientation == Qt::Horizontal ) - { - if ( pos.x() < markerPos ) - m_data->stepsIncrement = -m_data->stepsIncrement; - } - else - { - if ( pos.y() < markerPos ) - m_data->stepsIncrement = -m_data->stepsIncrement; - } - - if ( isInverted() ) - m_data->stepsIncrement = -m_data->stepsIncrement; - - const double v = value(); - incrementValue( m_data->stepsIncrement ); - - if ( v != value() ) - { - if ( isTracking() ) - Q_EMIT valueChanged( value() ); - else - m_data->pendingValueChange = true; - - Q_EMIT sliderMoved( value() ); - } - - m_data->timerTick = false; - m_data->repeatTimerId = startTimer( qMax( 250, 2 * updateInterval() ) ); - - return; - } - } - - QwtAbstractSlider::mousePressEvent( event ); + QwtAbstractSlider::mousePressEvent(event); } /*! Mouse release event handler \param event Mouse event */ -void QwtSlider::mouseReleaseEvent( QMouseEvent* event ) +void QwtSlider::mouseReleaseEvent(QMouseEvent *event) { - if ( m_data->repeatTimerId > 0 ) - { - killTimer( m_data->repeatTimerId ); - m_data->repeatTimerId = 0; - m_data->timerTick = false; - m_data->stepsIncrement = 0; - } + if (m_data->repeatTimerId > 0) + { + killTimer(m_data->repeatTimerId); + m_data->repeatTimerId = 0; + m_data->timerTick = false; + m_data->stepsIncrement = 0; + } - if ( m_data->pendingValueChange ) - { - m_data->pendingValueChange = false; - Q_EMIT valueChanged( value() ); - } + if (m_data->pendingValueChange) + { + m_data->pendingValueChange = false; + Q_EMIT valueChanged(value()); + } - QwtAbstractSlider::mouseReleaseEvent( event ); + QwtAbstractSlider::mouseReleaseEvent(event); } /*! @@ -630,77 +626,77 @@ void QwtSlider::mouseReleaseEvent( QMouseEvent* event ) \param event Mouse event */ -void QwtSlider::timerEvent( QTimerEvent* event ) +void QwtSlider::timerEvent(QTimerEvent *event) { - if ( event->timerId() != m_data->repeatTimerId ) - { - QwtAbstractSlider::timerEvent( event ); - return; - } + if (event->timerId() != m_data->repeatTimerId) + { + QwtAbstractSlider::timerEvent(event); + return; + } - if ( !isValid() ) - { - killTimer( m_data->repeatTimerId ); - m_data->repeatTimerId = 0; - return; - } + if (!isValid()) + { + killTimer(m_data->repeatTimerId); + m_data->repeatTimerId = 0; + return; + } - const double v = value(); - incrementValue( m_data->stepsIncrement ); + const double v = value(); + incrementValue(m_data->stepsIncrement); - if ( v != value() ) - { - if ( isTracking() ) - Q_EMIT valueChanged( value() ); - else - m_data->pendingValueChange = true; + if (v != value()) + { + if (isTracking()) + Q_EMIT valueChanged(value()); + else + m_data->pendingValueChange = true; - Q_EMIT sliderMoved( value() ); - } + Q_EMIT sliderMoved(value()); + } - if ( !m_data->timerTick ) - { - // restart the timer with a shorter interval - killTimer( m_data->repeatTimerId ); - m_data->repeatTimerId = startTimer( updateInterval() ); + if (!m_data->timerTick) + { + // restart the timer with a shorter interval + killTimer(m_data->repeatTimerId); + m_data->repeatTimerId = startTimer(updateInterval()); - m_data->timerTick = true; - } + m_data->timerTick = true; + } } /*! Qt paint event handler \param event Paint event */ -void QwtSlider::paintEvent( QPaintEvent* event ) +void QwtSlider::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - if ( m_data->scalePosition != QwtSlider::NoScale ) - { - if ( !m_data->sliderRect.contains( event->rect() ) ) - scaleDraw()->draw( &painter, palette() ); - } + if (m_data->scalePosition != QwtSlider::NoScale) + { + if (!m_data->sliderRect.contains(event->rect())) + scaleDraw()->draw(&painter, palette()); + } - drawSlider( &painter, m_data->sliderRect ); + drawSlider(&painter, m_data->sliderRect); - if ( hasFocus() ) - QwtPainter::drawFocusRect( &painter, this, m_data->sliderRect ); + if (hasFocus()) + QwtPainter::drawFocusRect(&painter, this, m_data->sliderRect); } /*! Qt resize event handler \param event Resize event */ -void QwtSlider::resizeEvent( QResizeEvent* event ) +void QwtSlider::resizeEvent(QResizeEvent *event) { - layoutSlider( false ); - QwtAbstractSlider::resizeEvent( event ); + layoutSlider(false); + QwtAbstractSlider::resizeEvent(event); } /*! @@ -709,28 +705,28 @@ void QwtSlider::resizeEvent( QResizeEvent* event ) \return true, if event was recognized and processed */ -bool QwtSlider::event( QEvent* event ) +bool QwtSlider::event(QEvent *event) { - if ( event->type() == QEvent::PolishRequest ) - layoutSlider( false ); + if (event->type() == QEvent::PolishRequest) + layoutSlider(false); - return QwtAbstractSlider::event( event ); + return QwtAbstractSlider::event(event); } /*! Handles QEvent::StyleChange and QEvent::FontChange events \param event Change event */ -void QwtSlider::changeEvent( QEvent* event ) +void QwtSlider::changeEvent(QEvent *event) { - if ( event->type() == QEvent::StyleChange || - event->type() == QEvent::FontChange ) - { - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); - } + if (event->type() == QEvent::StyleChange + || event->type() == QEvent::FontChange) + { + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); + } - QwtAbstractSlider::changeEvent( event ); + QwtAbstractSlider::changeEvent(event); } /*! @@ -740,112 +736,112 @@ void QwtSlider::changeEvent( QEvent* event ) \param update_geometry notify the layout system and call update to redraw the scale */ -void QwtSlider::layoutSlider( bool update_geometry ) +void QwtSlider::layoutSlider(bool update_geometry) { - int bw = 0; - if ( m_data->hasTrough ) - bw = m_data->borderWidth; + int bw = 0; + if (m_data->hasTrough) + bw = m_data->borderWidth; - const QSize handleSize = qwtHandleSize( m_data->handleSize, - m_data->orientation, m_data->hasTrough ); + const QSize handleSize = qwtHandleSize( + m_data->handleSize, m_data->orientation, m_data->hasTrough); - QRect sliderRect = contentsRect(); + QRect sliderRect = contentsRect(); - /* - The marker line of the handle needs to be aligned to - the scale. But the marker is in the center - and we need space enough to display the rest of the handle. + /* + The marker line of the handle needs to be aligned to + the scale. But the marker is in the center + and we need space enough to display the rest of the handle. - But the scale itself usually needs margins for displaying - the tick labels, that also might needs space beyond the - backbone. + But the scale itself usually needs margins for displaying + the tick labels, that also might needs space beyond the + backbone. - Now it depends on what needs more margins. If it is the - slider the scale gets shrunk, otherwise the slider. - */ + Now it depends on what needs more margins. If it is the + slider the scale gets shrunk, otherwise the slider. + */ - int scaleMargin = 0; - if ( m_data->scalePosition != QwtSlider::NoScale ) + int scaleMargin = 0; + if (m_data->scalePosition != QwtSlider::NoScale) + { + int d1, d2; + scaleDraw()->getBorderDistHint(font(), d1, d2); + + scaleMargin = qMax(d1, d2) - bw; + } + + int scaleX, scaleY, scaleLength; + + if (m_data->orientation == Qt::Horizontal) + { + const int handleMargin = handleSize.width() / 2 - 1; + if (scaleMargin > handleMargin) { - int d1, d2; - scaleDraw()->getBorderDistHint( font(), d1, d2 ); - - scaleMargin = qMax( d1, d2 ) - bw; + int off = scaleMargin - handleMargin; + sliderRect.adjust(off, 0, -off, 0); } - int scaleX, scaleY, scaleLength; - - if ( m_data->orientation == Qt::Horizontal ) + scaleX = sliderRect.left() + bw + handleSize.width() / 2 - 1; + scaleLength = sliderRect.width() - handleSize.width(); + } + else + { + int handleMargin = handleSize.height() / 2 - 1; + if (scaleMargin > handleMargin) { - const int handleMargin = handleSize.width() / 2 - 1; - if ( scaleMargin > handleMargin ) - { - int off = scaleMargin - handleMargin; - sliderRect.adjust( off, 0, -off, 0 ); - } + int off = scaleMargin - handleMargin; + sliderRect.adjust(0, off, 0, -off); + } - scaleX = sliderRect.left() + bw + handleSize.width() / 2 - 1; - scaleLength = sliderRect.width() - handleSize.width(); + scaleY = sliderRect.top() + bw + handleSize.height() / 2 - 1; + scaleLength = sliderRect.height() - handleSize.height(); + } + + scaleLength -= 2 * bw; + + // now align slider and scale according to the ScalePosition + + if (m_data->orientation == Qt::Horizontal) + { + const int h = handleSize.height() + 2 * bw; + + if (m_data->scalePosition == QwtSlider::TrailingScale) + { + sliderRect.setTop(sliderRect.bottom() + 1 - h); + scaleY = sliderRect.top() - m_data->spacing; } else { - int handleMargin = handleSize.height() / 2 - 1; - if ( scaleMargin > handleMargin ) - { - int off = scaleMargin - handleMargin; - sliderRect.adjust( 0, off, 0, -off ); - } - - scaleY = sliderRect.top() + bw + handleSize.height() / 2 - 1; - scaleLength = sliderRect.height() - handleSize.height(); + sliderRect.setHeight(h); + scaleY = sliderRect.bottom() + 1 + m_data->spacing; } + } + else // Qt::Vertical + { + const int w = handleSize.width() + 2 * bw; - scaleLength -= 2 * bw; - - // now align slider and scale according to the ScalePosition - - if ( m_data->orientation == Qt::Horizontal ) + if (m_data->scalePosition == QwtSlider::LeadingScale) { - const int h = handleSize.height() + 2 * bw; - - if ( m_data->scalePosition == QwtSlider::TrailingScale ) - { - sliderRect.setTop( sliderRect.bottom() + 1 - h ); - scaleY = sliderRect.top() - m_data->spacing; - } - else - { - sliderRect.setHeight( h ); - scaleY = sliderRect.bottom() + 1 + m_data->spacing; - } + sliderRect.setWidth(w); + scaleX = sliderRect.right() + 1 + m_data->spacing; } - else // Qt::Vertical + else { - const int w = handleSize.width() + 2 * bw; - - if ( m_data->scalePosition == QwtSlider::LeadingScale ) - { - sliderRect.setWidth( w ); - scaleX = sliderRect.right() + 1 + m_data->spacing; - } - else - { - sliderRect.setLeft( sliderRect.right() + 1 - w ); - scaleX = sliderRect.left() - m_data->spacing; - } + sliderRect.setLeft(sliderRect.right() + 1 - w); + scaleX = sliderRect.left() - m_data->spacing; } + } - m_data->sliderRect = sliderRect; + m_data->sliderRect = sliderRect; - scaleDraw()->move( scaleX, scaleY ); - scaleDraw()->setLength( scaleLength ); + scaleDraw()->move(scaleX, scaleY); + scaleDraw()->setLength(scaleLength); - if ( update_geometry ) - { - m_data->sizeHintCache = QSize(); // invalidate - updateGeometry(); - update(); - } + if (update_geometry) + { + m_data->sizeHintCache = QSize(); // invalidate + updateGeometry(); + update(); + } } /*! @@ -857,15 +853,15 @@ void QwtSlider::layoutSlider( bool update_geometry ) \param on When true, the groove is visible \sa hasTrough(), setGroove() */ -void QwtSlider::setTrough( bool on ) +void QwtSlider::setTrough(bool on) { - if ( m_data->hasTrough != on ) - { - m_data->hasTrough = on; + if (m_data->hasTrough != on) + { + m_data->hasTrough = on; - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); - } + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); + } } /*! @@ -874,7 +870,7 @@ void QwtSlider::setTrough( bool on ) */ bool QwtSlider::hasTrough() const { - return m_data->hasTrough; + return m_data->hasTrough; } /*! @@ -886,15 +882,15 @@ bool QwtSlider::hasTrough() const \param on When true, the groove is visible \sa hasGroove(), setThrough() */ -void QwtSlider::setGroove( bool on ) +void QwtSlider::setGroove(bool on) { - if ( m_data->hasGroove != on ) - { - m_data->hasGroove = on; + if (m_data->hasGroove != on) + { + m_data->hasGroove = on; - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutSlider( true ); - } + if (testAttribute(Qt::WA_WState_Polished)) + layoutSlider(true); + } } /*! @@ -903,7 +899,7 @@ void QwtSlider::setGroove( bool on ) */ bool QwtSlider::hasGroove() const { - return m_data->hasGroove; + return m_data->hasGroove; } /*! @@ -911,8 +907,8 @@ bool QwtSlider::hasGroove() const */ QSize QwtSlider::sizeHint() const { - const QSize hint = minimumSizeHint(); - return qwtExpandedToGlobalStrut( hint ); + const QSize hint = minimumSizeHint(); + return qwtExpandedToGlobalStrut(hint); } /*! @@ -921,67 +917,67 @@ QSize QwtSlider::sizeHint() const */ QSize QwtSlider::minimumSizeHint() const { - if ( !m_data->sizeHintCache.isEmpty() ) - return m_data->sizeHintCache; - - const QSize handleSize = qwtHandleSize( m_data->handleSize, - m_data->orientation, m_data->hasTrough ); - - int bw = 0; - if ( m_data->hasTrough ) - bw = m_data->borderWidth; - - int sliderLength = 0; - int scaleExtent = 0; - - if ( m_data->scalePosition != QwtSlider::NoScale ) - { - int d1, d2; - scaleDraw()->getBorderDistHint( font(), d1, d2 ); - - const int scaleBorderDist = 2 * ( qMax( d1, d2 ) - bw ); - - int handleBorderDist; - if ( m_data->orientation == Qt::Horizontal ) - handleBorderDist = handleSize.width(); - else - handleBorderDist = handleSize.height(); - - sliderLength = scaleDraw()->minLength( font() ); - if ( handleBorderDist > scaleBorderDist ) - { - // We need additional space for the overlapping handle - sliderLength += handleBorderDist - scaleBorderDist; - } - - scaleExtent += m_data->spacing; - scaleExtent += qwtCeil( scaleDraw()->extent( font() ) ); - } - - sliderLength = qMax( sliderLength, 84 ); // from QSlider - - int w = 0; - int h = 0; - - if ( m_data->orientation == Qt::Horizontal ) - { - w = sliderLength; - h = handleSize.height() + 2 * bw + scaleExtent; - } - else - { - w = handleSize.width() + 2 * bw + scaleExtent; - h = sliderLength; - } - - // finally add margins - const QMargins m = contentsMargins(); - - w += m.left() + m.right(); - h += m.top() + m.bottom(); - - m_data->sizeHintCache = QSize( w, h ); + if (!m_data->sizeHintCache.isEmpty()) return m_data->sizeHintCache; + + const QSize handleSize = qwtHandleSize( + m_data->handleSize, m_data->orientation, m_data->hasTrough); + + int bw = 0; + if (m_data->hasTrough) + bw = m_data->borderWidth; + + int sliderLength = 0; + int scaleExtent = 0; + + if (m_data->scalePosition != QwtSlider::NoScale) + { + int d1, d2; + scaleDraw()->getBorderDistHint(font(), d1, d2); + + const int scaleBorderDist = 2 * (qMax(d1, d2) - bw); + + int handleBorderDist; + if (m_data->orientation == Qt::Horizontal) + handleBorderDist = handleSize.width(); + else + handleBorderDist = handleSize.height(); + + sliderLength = scaleDraw()->minLength(font()); + if (handleBorderDist > scaleBorderDist) + { + // We need additional space for the overlapping handle + sliderLength += handleBorderDist - scaleBorderDist; + } + + scaleExtent += m_data->spacing; + scaleExtent += qwtCeil(scaleDraw()->extent(font())); + } + + sliderLength = qMax(sliderLength, 84); // from QSlider + + int w = 0; + int h = 0; + + if (m_data->orientation == Qt::Horizontal) + { + w = sliderLength; + h = handleSize.height() + 2 * bw + scaleExtent; + } + else + { + w = handleSize.width() + 2 * bw + scaleExtent; + h = sliderLength; + } + + // finally add margins + const QMargins m = contentsMargins(); + + w += m.left() + m.right(); + h += m.top() + m.bottom(); + + m_data->sizeHintCache = QSize(w, h); + return m_data->sizeHintCache; } /*! @@ -989,23 +985,23 @@ QSize QwtSlider::minimumSizeHint() const */ QRect QwtSlider::handleRect() const { - if ( !isValid() ) - return QRect(); + if (!isValid()) + return QRect(); - const int markerPos = transform( value() ); + const int markerPos = transform(value()); - QPoint center = m_data->sliderRect.center(); - if ( m_data->orientation == Qt::Horizontal ) - center.setX( markerPos ); - else - center.setY( markerPos ); + QPoint center = m_data->sliderRect.center(); + if (m_data->orientation == Qt::Horizontal) + center.setX(markerPos); + else + center.setY(markerPos); - QRect rect; - rect.setSize( qwtHandleSize( m_data->handleSize, - m_data->orientation, m_data->hasTrough ) ); - rect.moveCenter( center ); + QRect rect; + rect.setSize(qwtHandleSize(m_data->handleSize, m_data->orientation, + m_data->hasTrough)); + rect.moveCenter(center); - return rect; + return rect; } /*! @@ -1013,9 +1009,9 @@ QRect QwtSlider::handleRect() const */ QRect QwtSlider::sliderRect() const { - return m_data->sliderRect; + return m_data->sliderRect; } #if QWT_MOC_INCLUDE -#include "moc_qwt_slider.cpp" +# include "moc_qwt_slider.cpp" #endif diff --git a/libs/qwt/src/qwt_slider.h b/libs/qwt/src/qwt_slider.h index 1306e010..310f3097 100644 --- a/libs/qwt/src/qwt_slider.h +++ b/libs/qwt/src/qwt_slider.h @@ -29,104 +29,102 @@ class QwtScaleDraw; class QWT_EXPORT QwtSlider : public QwtAbstractSlider { - Q_OBJECT + Q_OBJECT - Q_ENUMS( ScalePosition BackgroundStyle ) + Q_ENUMS(ScalePosition BackgroundStyle) - Q_PROPERTY( Qt::Orientation orientation - READ orientation WRITE setOrientation ) - Q_PROPERTY( ScalePosition scalePosition READ scalePosition - WRITE setScalePosition ) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) + Q_PROPERTY( + ScalePosition scalePosition READ scalePosition WRITE setScalePosition) - Q_PROPERTY( bool trough READ hasTrough WRITE setTrough ) - Q_PROPERTY( bool groove READ hasGroove WRITE setGroove ) + Q_PROPERTY(bool trough READ hasTrough WRITE setTrough) + Q_PROPERTY(bool groove READ hasGroove WRITE setGroove) - Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) - Q_PROPERTY( int spacing READ spacing WRITE setSpacing ) + Q_PROPERTY(QSize handleSize READ handleSize WRITE setHandleSize) + Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) + Q_PROPERTY(int spacing READ spacing WRITE setSpacing) - public: +public: + /*! + Position of the scale + \sa QwtSlider(), setScalePosition(), setOrientation() + */ + enum ScalePosition + { + //! The slider has no scale + NoScale, - /*! - Position of the scale - \sa QwtSlider(), setScalePosition(), setOrientation() - */ - enum ScalePosition - { - //! The slider has no scale - NoScale, + //! The scale is right of a vertical or below a horizontal slider + LeadingScale, - //! The scale is right of a vertical or below a horizontal slider - LeadingScale, + //! The scale is left of a vertical or above a horizontal slider + TrailingScale + }; - //! The scale is left of a vertical or above a horizontal slider - TrailingScale - }; + explicit QwtSlider(QWidget *parent = NULL); + explicit QwtSlider(Qt::Orientation, QWidget *parent = NULL); - explicit QwtSlider( QWidget* parent = NULL ); - explicit QwtSlider( Qt::Orientation, QWidget* parent = NULL ); + virtual ~QwtSlider(); - virtual ~QwtSlider(); + void setOrientation(Qt::Orientation); + Qt::Orientation orientation() const; - void setOrientation( Qt::Orientation ); - Qt::Orientation orientation() const; + void setScalePosition(ScalePosition); + ScalePosition scalePosition() const; - void setScalePosition( ScalePosition ); - ScalePosition scalePosition() const; + void setTrough(bool); + bool hasTrough() const; - void setTrough( bool ); - bool hasTrough() const; + void setGroove(bool); + bool hasGroove() const; - void setGroove( bool ); - bool hasGroove() const; + void setHandleSize(const QSize &); + QSize handleSize() const; - void setHandleSize( const QSize& ); - QSize handleSize() const; + void setBorderWidth(int); + int borderWidth() const; - void setBorderWidth( int ); - int borderWidth() const; + void setSpacing(int); + int spacing() const; - void setSpacing( int ); - int spacing() const; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + void setScaleDraw(QwtScaleDraw *); + const QwtScaleDraw *scaleDraw() const; - void setScaleDraw( QwtScaleDraw* ); - const QwtScaleDraw* scaleDraw() const; + void setUpdateInterval(int); + int updateInterval() const; - void setUpdateInterval( int ); - int updateInterval() const; +protected: + virtual double scrolledTo(const QPoint &) const QWT_OVERRIDE; + virtual bool isScrollPosition(const QPoint &) const QWT_OVERRIDE; - protected: - virtual double scrolledTo( const QPoint& ) const QWT_OVERRIDE; - virtual bool isScrollPosition( const QPoint& ) const QWT_OVERRIDE; + virtual void drawSlider(QPainter *, const QRect &) const; + virtual void drawHandle(QPainter *, const QRect &, int pos) const; - virtual void drawSlider ( QPainter*, const QRect& ) const; - virtual void drawHandle( QPainter*, const QRect&, int pos ) const; + virtual void mousePressEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void changeEvent(QEvent *) QWT_OVERRIDE; + virtual void timerEvent(QTimerEvent *) QWT_OVERRIDE; - virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; - virtual void paintEvent ( QPaintEvent* ) QWT_OVERRIDE; - virtual void changeEvent( QEvent* ) QWT_OVERRIDE; - virtual void timerEvent( QTimerEvent* ) QWT_OVERRIDE; + virtual bool event(QEvent *) QWT_OVERRIDE; - virtual bool event( QEvent* ) QWT_OVERRIDE; + virtual void scaleChange() QWT_OVERRIDE; - virtual void scaleChange() QWT_OVERRIDE; + QRect sliderRect() const; + QRect handleRect() const; - QRect sliderRect() const; - QRect handleRect() const; +private: + QwtScaleDraw *scaleDraw(); - private: - QwtScaleDraw* scaleDraw(); + void layoutSlider(bool); + void initSlider(Qt::Orientation); - void layoutSlider( bool ); - void initSlider( Qt::Orientation ); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_spline.cpp b/libs/qwt/src/qwt_spline.cpp index b2f573c6..64f29bd2 100644 --- a/libs/qwt/src/qwt_spline.cpp +++ b/libs/qwt/src/qwt_spline.cpp @@ -16,453 +16,437 @@ namespace QwtSplineC1P { - struct param - { - param( const QwtSplineParametrization* p ): - parameter( p ) - { - } +struct param +{ + param(const QwtSplineParametrization *p) + : parameter(p) + { + } - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return parameter->valueIncrement( p1, p2 ); - } + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return parameter->valueIncrement(p1, p2); + } - const QwtSplineParametrization* parameter; - }; + const QwtSplineParametrization *parameter; +}; - struct paramY - { - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return QwtSplineParametrization::valueIncrementY( p1, p2 ); - } - }; +struct paramY +{ + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return QwtSplineParametrization::valueIncrementY(p1, p2); + } +}; - struct paramUniform - { - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return QwtSplineParametrization::valueIncrementUniform( p1, p2 ); - } - }; +struct paramUniform +{ + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return QwtSplineParametrization::valueIncrementUniform(p1, p2); + } +}; - struct paramCentripetal - { - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return QwtSplineParametrization::valueIncrementCentripetal( p1, p2 ); - } - }; +struct paramCentripetal +{ + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return QwtSplineParametrization::valueIncrementCentripetal(p1, p2); + } +}; - struct paramChordal - { - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return QwtSplineParametrization::valueIncrementChordal( p1, p2 ); - } - }; +struct paramChordal +{ + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return QwtSplineParametrization::valueIncrementChordal(p1, p2); + } +}; - struct paramManhattan - { - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return QwtSplineParametrization::valueIncrementManhattan( p1, p2 ); - } - }; +struct paramManhattan +{ + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return QwtSplineParametrization::valueIncrementManhattan(p1, p2); + } +}; - class PathStore - { - public: - inline void init( int size ) - { - Q_UNUSED(size); - } +class PathStore +{ +public: + inline void init(int size) { Q_UNUSED(size); } - inline void start( double x1, double y1 ) - { - path.moveTo( x1, y1 ); - } + inline void start(double x1, double y1) { path.moveTo(x1, y1); } - inline void addCubic( double cx1, double cy1, - double cx2, double cy2, double x2, double y2 ) - { - path.cubicTo( cx1, cy1, cx2, cy2, x2, y2 ); - } + inline void addCubic(double cx1, double cy1, double cx2, double cy2, + double x2, double y2) + { + path.cubicTo(cx1, cy1, cx2, cy2, x2, y2); + } - inline void end() - { - path.closeSubpath(); - } + inline void end() { path.closeSubpath(); } - QPainterPath path; - }; + QPainterPath path; +}; - class ControlPointsStore - { - public: - inline ControlPointsStore(): - m_cp( NULL ) - { - } +class ControlPointsStore +{ +public: + inline ControlPointsStore() + : m_cp(NULL) + { + } - inline void init( int size ) - { - controlPoints.resize( size ); - m_cp = controlPoints.data(); - } + inline void init(int size) + { + controlPoints.resize(size); + m_cp = controlPoints.data(); + } - inline void start( double x1, double y1 ) - { - Q_UNUSED( x1 ); - Q_UNUSED( y1 ); - } + inline void start(double x1, double y1) + { + Q_UNUSED(x1); + Q_UNUSED(y1); + } - inline void addCubic( double cx1, double cy1, - double cx2, double cy2, double x2, double y2 ) - { - Q_UNUSED( x2 ); - Q_UNUSED( y2 ); + inline void addCubic(double cx1, double cy1, double cx2, double cy2, + double x2, double y2) + { + Q_UNUSED(x2); + Q_UNUSED(y2); - QLineF& l = *m_cp++; - l.setLine( cx1, cy1, cx2, cy2 ); - } + QLineF &l = *m_cp++; + l.setLine(cx1, cy1, cx2, cy2); + } - inline void end() - { - } + inline void end() {} - QVector< QLineF > controlPoints; + QVector controlPoints; - private: - QLineF* m_cp; - }; +private: + QLineF *m_cp; +}; - double slopeBoundary( int boundaryCondition, double boundaryValue, - const QPointF& p1, const QPointF& p2, double slope1 ) - { - const double dx = p2.x() - p1.x(); - const double dy = p2.y() - p1.y(); +double slopeBoundary(int boundaryCondition, double boundaryValue, + const QPointF &p1, const QPointF &p2, double slope1) +{ + const double dx = p2.x() - p1.x(); + const double dy = p2.y() - p1.y(); - double m = 0.0; + double m = 0.0; - switch( boundaryCondition ) - { - case QwtSpline::Clamped1: - { - m = boundaryValue; - break; - } - case QwtSpline::Clamped2: - { - const double c2 = 0.5 * boundaryValue; - const double c1 = slope1; - - m = 0.5 * ( 3.0 * dy / dx - c1 - c2 * dx ); - break; - } - case QwtSpline::Clamped3: - { - const double c3 = boundaryValue / 6.0; - m = c3 * dx * dx + 2 * dy / dx - slope1; - break; - } - case QwtSpline::LinearRunout: - { - const double s = dy / dx; - const double r = qBound( 0.0, boundaryValue, 1.0 ); - - m = s - r * ( s - slope1 ); - break; - } - default: - { - m = dy / dx; // something - } - } - - return m; + switch (boundaryCondition) + { + case QwtSpline::Clamped1: { + m = boundaryValue; + break; } + case QwtSpline::Clamped2: { + const double c2 = 0.5 * boundaryValue; + const double c1 = slope1; + + m = 0.5 * (3.0 * dy / dx - c1 - c2 * dx); + break; + } + case QwtSpline::Clamped3: { + const double c3 = boundaryValue / 6.0; + m = c3 * dx * dx + 2 * dy / dx - slope1; + break; + } + case QwtSpline::LinearRunout: { + const double s = dy / dx; + const double r = qBound(0.0, boundaryValue, 1.0); + + m = s - r * (s - slope1); + break; + } + default: { + m = dy / dx; // something + } + } + + return m; +} +} // namespace QwtSplineC1P + +template +static inline SplineStore qwtSplineC1PathParamX(const QwtSplineC1 *spline, + const QPolygonF &points) +{ + const int n = points.size(); + + const QVector m = spline->slopes(points); + if (m.size() != n) + return SplineStore(); + + const QPointF *pd = points.constData(); + const double *md = m.constData(); + + SplineStore store; + store.init(m.size() - 1); + store.start(pd[0].x(), pd[0].y()); + + for (int i = 0; i < n - 1; i++) + { + const double dx3 = (pd[i + 1].x() - pd[i].x()) / 3.0; + + store.addCubic(pd[i].x() + dx3, pd[i].y() + md[i] * dx3, + pd[i + 1].x() - dx3, pd[i + 1].y() - md[i + 1] * dx3, + pd[i + 1].x(), pd[i + 1].y()); + } + + return store; } -template< class SplineStore > -static inline SplineStore qwtSplineC1PathParamX( - const QwtSplineC1* spline, const QPolygonF& points ) +template +static inline SplineStore qwtSplineC1PathParamY(const QwtSplineC1 *spline, + const QPolygonF &points) { - const int n = points.size(); + const int n = points.size(); - const QVector< double > m = spline->slopes( points ); - if ( m.size() != n ) - return SplineStore(); + QPolygonF pointsFlipped(n); + for (int i = 0; i < n; i++) + { + pointsFlipped[i].setX(points[i].y()); + pointsFlipped[i].setY(points[i].x()); + } - const QPointF* pd = points.constData(); - const double* md = m.constData(); + const QVector m = spline->slopes(pointsFlipped); + if (m.size() != n) + return SplineStore(); - SplineStore store; - store.init( m.size() - 1 ); - store.start( pd[0].x(), pd[0].y() ); + const QPointF *pd = pointsFlipped.constData(); + const double *md = m.constData(); - for ( int i = 0; i < n - 1; i++ ) - { - const double dx3 = ( pd[i + 1].x() - pd[i].x() ) / 3.0; + SplineStore store; + store.init(m.size() - 1); + store.start(pd[0].y(), pd[0].x()); - store.addCubic( pd[i].x() + dx3, pd[i].y() + md[i] * dx3, - pd[i + 1].x() - dx3, pd[i + 1].y() - md[i + 1] * dx3, - pd[i + 1].x(), pd[i + 1].y() ); - } + QVector lines(n); + for (int i = 0; i < n - 1; i++) + { + const double dx3 = (pd[i + 1].x() - pd[i].x()) / 3.0; - return store; + store.addCubic(pd[i].y() + md[i] * dx3, pd[i].x() + dx3, + pd[i + 1].y() - md[i + 1] * dx3, pd[i + 1].x() - dx3, + pd[i + 1].y(), pd[i + 1].x()); + } + + return store; } -template< class SplineStore > -static inline SplineStore qwtSplineC1PathParamY( - const QwtSplineC1* spline, const QPolygonF& points ) +template +static inline SplineStore qwtSplineC1PathParametric(const QwtSplineC1 *spline, + const QPolygonF &points, + Param param) { - const int n = points.size(); + const bool isClosing = (spline->boundaryType() == QwtSpline::ClosedPolygon); + const int n = points.size(); - QPolygonF pointsFlipped( n ); - for ( int i = 0; i < n; i++ ) + QPolygonF pointsX, pointsY; + pointsX.resize(isClosing ? n + 1 : n); + pointsY.resize(isClosing ? n + 1 : n); + + QPointF *px = pointsX.data(); + QPointF *py = pointsY.data(); + const QPointF *p = points.constData(); + + double t = 0.0; + + px[0].rx() = py[0].rx() = t; + px[0].ry() = p[0].x(); + py[0].ry() = p[0].y(); + + int numParamPoints = 1; + for (int i = 1; i < n; i++) + { + const double td = param(points[i - 1], points[i]); + if (td > 0.0) { - pointsFlipped[i].setX( points[i].y() ); - pointsFlipped[i].setY( points[i].x() ); + t += td; + + px[numParamPoints].rx() = py[numParamPoints].rx() = t; + + px[numParamPoints].ry() = p[i].x(); + py[numParamPoints].ry() = p[i].y(); + + numParamPoints++; + } + } + + if (isClosing) + { + const double td = param(points[n - 1], points[0]); + + if (td > 0.0) + { + t += td; + + px[numParamPoints].rx() = py[numParamPoints].rx() = t; + + px[numParamPoints].ry() = p[0].x(); + py[numParamPoints].ry() = p[0].y(); + + numParamPoints++; + } + } + + if (pointsX.size() != numParamPoints) + { + pointsX.resize(numParamPoints); + pointsY.resize(numParamPoints); + } + + const QVector slopesX = spline->slopes(pointsX); + const QVector slopesY = spline->slopes(pointsY); + + const double *mx = slopesX.constData(); + const double *my = slopesY.constData(); + + // we don't need it anymore + pointsX.clear(); + pointsY.clear(); + + SplineStore store; + store.init(isClosing ? n : n - 1); + store.start(points[0].x(), points[0].y()); + + int j = 0; + + for (int i = 0; i < n - 1; i++) + { + const QPointF &p1 = p[i]; + const QPointF &p2 = p[i + 1]; + + const double td = param(p1, p2); + + if (td != 0.0) + { + const double t3 = td / 3.0; + + const double cx1 = p1.x() + mx[j] * t3; + const double cy1 = p1.y() + my[j] * t3; + + const double cx2 = p2.x() - mx[j + 1] * t3; + const double cy2 = p2.y() - my[j + 1] * t3; + + store.addCubic(cx1, cy1, cx2, cy2, p2.x(), p2.y()); + + j++; + } + else + { + // setting control points to the ends + store.addCubic(p1.x(), p1.y(), p2.x(), p2.y(), p2.x(), p2.y()); + } + } + + if (isClosing) + { + const QPointF &p1 = p[n - 1]; + const QPointF &p2 = p[0]; + + const double td = param(p1, p2); + + if (td != 0.0) + { + const double t3 = td / 3.0; + + const double cx1 = p1.x() + mx[j] * t3; + const double cy1 = p1.y() + my[j] * t3; + + const double cx2 = p2.x() - mx[0] * t3; + const double cy2 = p2.y() - my[0] * t3; + + store.addCubic(cx1, cy1, cx2, cy2, p2.x(), p2.y()); + } + else + { + store.addCubic(p1.x(), p1.y(), p2.x(), p2.y(), p2.x(), p2.y()); } - const QVector< double > m = spline->slopes( pointsFlipped ); - if ( m.size() != n ) - return SplineStore(); + store.end(); + } - const QPointF* pd = pointsFlipped.constData(); - const double* md = m.constData(); - - SplineStore store; - store.init( m.size() - 1 ); - store.start( pd[0].y(), pd[0].x() ); - - QVector< QLineF > lines( n ); - for ( int i = 0; i < n - 1; i++ ) - { - const double dx3 = ( pd[i + 1].x() - pd[i].x() ) / 3.0; - - store.addCubic( pd[i].y() + md[i] * dx3, pd[i].x() + dx3, - pd[i + 1].y() - md[i + 1] * dx3, pd[i + 1].x() - dx3, - pd[i + 1].y(), pd[i + 1].x() ); - } - - return store; + return store; } -template< class SplineStore, class Param > -static inline SplineStore qwtSplineC1PathParametric( - const QwtSplineC1* spline, const QPolygonF& points, Param param ) +template +static QPolygonF qwtPolygonParametric(double distance, const QPolygonF &points, + const QVector &values, + bool withNodes) { - const bool isClosing = ( spline->boundaryType() == QwtSpline::ClosedPolygon ); - const int n = points.size(); + QPolygonF fittedPoints; - QPolygonF pointsX, pointsY; - pointsX.resize( isClosing ? n + 1 : n ); - pointsY.resize( isClosing ? n + 1 : n ); + const QPointF *p = points.constData(); + const double *v = values.constData(); - QPointF* px = pointsX.data(); - QPointF* py = pointsY.data(); - const QPointF* p = points.constData(); + fittedPoints += p[0]; + double t = distance; - double t = 0.0; + const int n = points.size(); - px[0].rx() = py[0].rx() = t; - px[0].ry() = p[0].x(); - py[0].ry() = p[0].y(); + for (int i = 0; i < n - 1; i++) + { + const QPointF &p1 = p[i]; + const QPointF &p2 = p[i + 1]; - int numParamPoints = 1; - for ( int i = 1; i < n; i++ ) + const QwtSplinePolynomial polynomial = toPolynomial(p1, v[i], p2, v[i + 1]); + + const double l = p2.x() - p1.x(); + + while (t < l) { - const double td = param( points[i - 1], points[i] ); - if ( td > 0.0 ) - { - t += td; - - px[numParamPoints].rx() = py[numParamPoints].rx() = t; - - px[numParamPoints].ry() = p[i].x(); - py[numParamPoints].ry() = p[i].y(); - - numParamPoints++; - } + fittedPoints += QPointF(p1.x() + t, p1.y() + polynomial.valueAt(t)); + t += distance; } - if ( isClosing ) + if (withNodes) { - const double td = param( points[n - 1], points[0] ); - - if ( td > 0.0 ) - { - t += td; - - px[numParamPoints].rx() = py[numParamPoints].rx() = t; - - px[numParamPoints].ry() = p[0].x(); - py[numParamPoints].ry() = p[0].y(); - - numParamPoints++; - } + if (qFuzzyCompare(fittedPoints.last().x(), p2.x())) + fittedPoints.last() = p2; + else + fittedPoints += p2; } - - if ( pointsX.size() != numParamPoints ) + else { - pointsX.resize( numParamPoints ); - pointsY.resize( numParamPoints ); + t -= l; } + } - const QVector< double > slopesX = spline->slopes( pointsX ); - const QVector< double > slopesY = spline->slopes( pointsY ); - - const double* mx = slopesX.constData(); - const double* my = slopesY.constData(); - - // we don't need it anymore - pointsX.clear(); - pointsY.clear(); - - SplineStore store; - store.init( isClosing ? n : n - 1 ); - store.start( points[0].x(), points[0].y() ); - - int j = 0; - - for ( int i = 0; i < n - 1; i++ ) - { - const QPointF& p1 = p[i]; - const QPointF& p2 = p[i + 1]; - - const double td = param( p1, p2 ); - - if ( td != 0.0 ) - { - const double t3 = td / 3.0; - - const double cx1 = p1.x() + mx[j] * t3; - const double cy1 = p1.y() + my[j] * t3; - - const double cx2 = p2.x() - mx[j + 1] * t3; - const double cy2 = p2.y() - my[j + 1] * t3; - - store.addCubic( cx1, cy1, cx2, cy2, p2.x(), p2.y() ); - - j++; - } - else - { - // setting control points to the ends - store.addCubic( p1.x(), p1.y(), p2.x(), p2.y(), p2.x(), p2.y() ); - } - } - - if ( isClosing ) - { - const QPointF& p1 = p[n - 1]; - const QPointF& p2 = p[0]; - - const double td = param( p1, p2 ); - - if ( td != 0.0 ) - { - const double t3 = td / 3.0; - - const double cx1 = p1.x() + mx[j] * t3; - const double cy1 = p1.y() + my[j] * t3; - - const double cx2 = p2.x() - mx[0] * t3; - const double cy2 = p2.y() - my[0] * t3; - - store.addCubic( cx1, cy1, cx2, cy2, p2.x(), p2.y() ); - } - else - { - store.addCubic( p1.x(), p1.y(), p2.x(), p2.y(), p2.x(), p2.y() ); - } - - store.end(); - } - - return store; -} - -template< QwtSplinePolynomial toPolynomial( const QPointF&, double, const QPointF&, double ) > -static QPolygonF qwtPolygonParametric( double distance, - const QPolygonF& points, const QVector< double >& values, bool withNodes ) -{ - QPolygonF fittedPoints; - - const QPointF* p = points.constData(); - const double* v = values.constData(); - - fittedPoints += p[0]; - double t = distance; - - const int n = points.size(); - - for ( int i = 0; i < n - 1; i++ ) - { - const QPointF& p1 = p[i]; - const QPointF& p2 = p[i + 1]; - - const QwtSplinePolynomial polynomial = toPolynomial( p1, v[i], p2, v[i + 1] ); - - const double l = p2.x() - p1.x(); - - while ( t < l ) - { - fittedPoints += QPointF( p1.x() + t, p1.y() + polynomial.valueAt( t ) ); - t += distance; - } - - if ( withNodes ) - { - if ( qFuzzyCompare( fittedPoints.last().x(), p2.x() ) ) - fittedPoints.last() = p2; - else - fittedPoints += p2; - } - else - { - t -= l; - } - } - - return fittedPoints; + return fittedPoints; } class QwtSpline::PrivateData { - public: - PrivateData() - : boundaryType( QwtSpline::ConditionalBoundaries ) - { - parametrization = new QwtSplineParametrization( - QwtSplineParametrization::ParameterChordal ); +public: + PrivateData() + : boundaryType(QwtSpline::ConditionalBoundaries) + { + parametrization = new QwtSplineParametrization( + QwtSplineParametrization::ParameterChordal); - // parabolic runout at both ends + // parabolic runout at both ends - boundaryConditions[0].type = QwtSpline::Clamped3; - boundaryConditions[0].value = 0.0; + boundaryConditions[0].type = QwtSpline::Clamped3; + boundaryConditions[0].value = 0.0; - boundaryConditions[1].type = QwtSpline::Clamped3; - boundaryConditions[1].value = 0.0; - } + boundaryConditions[1].type = QwtSpline::Clamped3; + boundaryConditions[1].value = 0.0; + } - ~PrivateData() - { - delete parametrization; - } + ~PrivateData() { delete parametrization; } - QwtSplineParametrization* parametrization; - QwtSpline::BoundaryType boundaryType; + QwtSplineParametrization *parametrization; + QwtSpline::BoundaryType boundaryType; - struct - { - int type; - double value; + struct + { + int type; + double value; - } boundaryConditions[2]; + } boundaryConditions[2]; }; /*! @@ -483,8 +467,8 @@ class QwtSpline::PrivateData Interpolates a polygon piecewise with Bezier curves interpolating them in a 2nd pass by polygons. - The interpolation is based on "Piecewise Linear Approximation of Bézier Curves" - by Roger Willcocks ( http://www.rops.org ) + The interpolation is based on "Piecewise Linear Approximation of Bézier + Curves" by Roger Willcocks ( http://www.rops.org ) \param points Control points \param tolerance Maximum for the accepted error of the approximation @@ -493,41 +477,41 @@ class QwtSpline::PrivateData \sa bezierControlLines(), QwtBezier */ -QPolygonF QwtSpline::polygon( const QPolygonF& points, double tolerance ) const +QPolygonF QwtSpline::polygon(const QPolygonF &points, double tolerance) const { - if ( tolerance <= 0.0 ) - return QPolygonF(); + if (tolerance <= 0.0) + return QPolygonF(); - const QPainterPath path = painterPath( points ); - const int n = path.elementCount(); - if ( n == 0 ) - return QPolygonF(); + const QPainterPath path = painterPath(points); + const int n = path.elementCount(); + if (n == 0) + return QPolygonF(); - const QPainterPath::Element el = path.elementAt( 0 ); - if ( el.type != QPainterPath::MoveToElement ) - return QPolygonF(); + const QPainterPath::Element el = path.elementAt(0); + if (el.type != QPainterPath::MoveToElement) + return QPolygonF(); - QPointF p1( el.x, el.y ); + QPointF p1(el.x, el.y); - QPolygonF polygon; - QwtBezier bezier( tolerance ); + QPolygonF polygon; + QwtBezier bezier(tolerance); - for ( int i = 1; i < n; i += 3 ) - { - const QPainterPath::Element el1 = path.elementAt( i ); - const QPainterPath::Element el2 = path.elementAt( i + 1 ); - const QPainterPath::Element el3 = path.elementAt( i + 2 ); + for (int i = 1; i < n; i += 3) + { + const QPainterPath::Element el1 = path.elementAt(i); + const QPainterPath::Element el2 = path.elementAt(i + 1); + const QPainterPath::Element el3 = path.elementAt(i + 2); - const QPointF cp1( el1.x, el1.y ); - const QPointF cp2( el2.x, el2.y ); - const QPointF p2( el3.x, el3.y ); + const QPointF cp1(el1.x, el1.y); + const QPointF cp2(el2.x, el2.y); + const QPointF p2(el3.x, el3.y); - bezier.appendToPolygon( p1, cp1, cp2, p2, polygon ); + bezier.appendToPolygon(p1, cp1, cp2, p2, polygon); - p1 = p2; - } + p1 = p2; + } - return polygon; + return polygon; } /*! @@ -539,13 +523,13 @@ QPolygonF QwtSpline::polygon( const QPolygonF& points, double tolerance ) const */ QwtSpline::QwtSpline() { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtSpline::~QwtSpline() { - delete m_data; + delete m_data; } /*! @@ -563,23 +547,23 @@ QwtSpline::~QwtSpline() */ uint QwtSpline::locality() const { - return 0; + return 0; } /*! Define the parametrization for a parametric spline approximation The default setting is a chordal parametrization. - \param type Type of parametrization, usually one of QwtSplineParametrization::Type - \sa parametrization() + \param type Type of parametrization, usually one of + QwtSplineParametrization::Type \sa parametrization() */ -void QwtSpline::setParametrization( int type ) +void QwtSpline::setParametrization(int type) { - if ( m_data->parametrization->type() != type ) - { - delete m_data->parametrization; - m_data->parametrization = new QwtSplineParametrization( type ); - } + if (m_data->parametrization->type() != type) + { + delete m_data->parametrization; + m_data->parametrization = new QwtSplineParametrization(type); + } } /*! @@ -589,22 +573,22 @@ void QwtSpline::setParametrization( int type ) \param parametrization Parametrization \sa parametrization() */ -void QwtSpline::setParametrization( QwtSplineParametrization* parametrization ) +void QwtSpline::setParametrization(QwtSplineParametrization *parametrization) { - if ( ( parametrization != NULL ) && ( m_data->parametrization != parametrization ) ) - { - delete m_data->parametrization; - m_data->parametrization = parametrization; - } + if ((parametrization != NULL) && (m_data->parametrization != parametrization)) + { + delete m_data->parametrization; + m_data->parametrization = parametrization; + } } /*! \return parametrization \sa setParametrization() */ -const QwtSplineParametrization* QwtSpline::parametrization() const +const QwtSplineParametrization *QwtSpline::parametrization() const { - return m_data->parametrization; + return m_data->parametrization; } /*! @@ -614,9 +598,9 @@ const QwtSplineParametrization* QwtSpline::parametrization() const \param boundaryType Boundary type \sa boundaryType() */ -void QwtSpline::setBoundaryType( BoundaryType boundaryType ) +void QwtSpline::setBoundaryType(BoundaryType boundaryType) { - m_data->boundaryType = boundaryType; + m_data->boundaryType = boundaryType; } /*! @@ -625,7 +609,7 @@ void QwtSpline::setBoundaryType( BoundaryType boundaryType ) */ QwtSpline::BoundaryType QwtSpline::boundaryType() const { - return m_data->boundaryType; + return m_data->boundaryType; } /*! @@ -636,10 +620,10 @@ QwtSpline::BoundaryType QwtSpline::boundaryType() const \sa BoundaryCondition, QwtSplineC2::BoundaryCondition, boundaryCondition() */ -void QwtSpline::setBoundaryCondition( BoundaryPosition position, int condition ) +void QwtSpline::setBoundaryCondition(BoundaryPosition position, int condition) { - if ( ( position == QwtSpline::AtBeginning ) || ( position == QwtSpline::AtEnd ) ) - m_data->boundaryConditions[position].type = condition; + if ((position == QwtSpline::AtBeginning) || (position == QwtSpline::AtEnd)) + m_data->boundaryConditions[position].type = condition; } /*! @@ -648,12 +632,12 @@ void QwtSpline::setBoundaryCondition( BoundaryPosition position, int condition ) \sa setBoundaryCondition(), boundaryValue(), setBoundaryConditions() */ -int QwtSpline::boundaryCondition( BoundaryPosition position ) const +int QwtSpline::boundaryCondition(BoundaryPosition position) const { - if ( ( position == QwtSpline::AtBeginning ) || ( position == QwtSpline::AtEnd ) ) - return m_data->boundaryConditions[position].type; + if ((position == QwtSpline::AtBeginning) || (position == QwtSpline::AtEnd)) + return m_data->boundaryConditions[position].type; - return m_data->boundaryConditions[0].type; // should never happen + return m_data->boundaryConditions[0].type; // should never happen } /*! @@ -667,10 +651,10 @@ int QwtSpline::boundaryCondition( BoundaryPosition position ) const \sa boundaryValue(), setBoundaryCondition() */ -void QwtSpline::setBoundaryValue( BoundaryPosition position, double value ) +void QwtSpline::setBoundaryValue(BoundaryPosition position, double value) { - if ( ( position == QwtSpline::AtBeginning ) || ( position == QwtSpline::AtEnd ) ) - m_data->boundaryConditions[position].value = value; + if ((position == QwtSpline::AtBeginning) || (position == QwtSpline::AtEnd)) + m_data->boundaryConditions[position].value = value; } /*! @@ -679,12 +663,12 @@ void QwtSpline::setBoundaryValue( BoundaryPosition position, double value ) \sa setBoundaryValue(), boundaryCondition() */ -double QwtSpline::boundaryValue( BoundaryPosition position ) const +double QwtSpline::boundaryValue(BoundaryPosition position) const { - if ( ( position == QwtSpline::AtBeginning ) || ( position == QwtSpline::AtEnd ) ) - return m_data->boundaryConditions[position].value; + if ((position == QwtSpline::AtBeginning) || (position == QwtSpline::AtEnd)) + return m_data->boundaryConditions[position].value; - return m_data->boundaryConditions[0].value; // should never happen + return m_data->boundaryConditions[0].value; // should never happen } /*! @@ -697,25 +681,21 @@ double QwtSpline::boundaryValue( BoundaryPosition position ) const \sa BoundaryCondition, QwtSplineC2::BoundaryCondition, testBoundaryCondition(), setBoundaryValue() */ -void QwtSpline::setBoundaryConditions( - int condition, double valueBegin, double valueEnd ) +void QwtSpline::setBoundaryConditions(int condition, double valueBegin, + double valueEnd) { - setBoundaryCondition( QwtSpline::AtBeginning, condition ); - setBoundaryValue( QwtSpline::AtBeginning, valueBegin ); + setBoundaryCondition(QwtSpline::AtBeginning, condition); + setBoundaryValue(QwtSpline::AtBeginning, valueBegin); - setBoundaryCondition( QwtSpline::AtEnd, condition ); - setBoundaryValue( QwtSpline::AtEnd, valueEnd ); + setBoundaryCondition(QwtSpline::AtEnd, condition); + setBoundaryValue(QwtSpline::AtEnd, valueEnd); } //! \brief Constructor -QwtSplineInterpolating::QwtSplineInterpolating() -{ -} +QwtSplineInterpolating::QwtSplineInterpolating() {} //! Destructor -QwtSplineInterpolating::~QwtSplineInterpolating() -{ -} +QwtSplineInterpolating::~QwtSplineInterpolating() {} /*! \fn QVector QwtSplineInterpolating::bezierControlLines( const QPolygonF &points ) const @@ -745,45 +725,45 @@ QwtSplineInterpolating::~QwtSplineInterpolating() \sa bezierControlLines() */ -QPainterPath QwtSplineInterpolating::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplineInterpolating::painterPath(const QPolygonF &points) const { - const int n = points.size(); - - QPainterPath path; - if ( n == 0 ) - return path; - - if ( n == 1 ) - { - path.moveTo( points[0] ); - return path; - } - - if ( n == 2 ) - { - path.addPolygon( points ); - return path; - } - - const QVector< QLineF > controlLines = bezierControlLines( points ); - if ( controlLines.size() < n - 1 ) - return path; - - const QPointF* p = points.constData(); - const QLineF* l = controlLines.constData(); - - path.moveTo( p[0] ); - for ( int i = 0; i < n - 1; i++ ) - path.cubicTo( l[i].p1(), l[i].p2(), p[i + 1] ); - - if ( ( boundaryType() == QwtSpline::ClosedPolygon ) - && ( controlLines.size() >= n ) ) - { - path.cubicTo( l[n - 1].p1(), l[n - 1].p2(), p[0] ); - path.closeSubpath(); - } + const int n = points.size(); + QPainterPath path; + if (n == 0) return path; + + if (n == 1) + { + path.moveTo(points[0]); + return path; + } + + if (n == 2) + { + path.addPolygon(points); + return path; + } + + const QVector controlLines = bezierControlLines(points); + if (controlLines.size() < n - 1) + return path; + + const QPointF *p = points.constData(); + const QLineF *l = controlLines.constData(); + + path.moveTo(p[0]); + for (int i = 0; i < n - 1; i++) + path.cubicTo(l[i].p1(), l[i].p2(), p[i + 1]); + + if ((boundaryType() == QwtSpline::ClosedPolygon) + && (controlLines.size() >= n)) + { + path.cubicTo(l[n - 1].p1(), l[n - 1].p2(), p[0]); + path.closeSubpath(); + } + + return path; } /*! @@ -792,8 +772,8 @@ QPainterPath QwtSplineInterpolating::painterPath( const QPolygonF& points ) cons Interpolates a polygon piecewise with Bezier curves approximating them by polygons. - The approximation is based on "Piecewise Linear Approximation of Bézier Curves" - by Roger Willcocks ( http://www.rops.org ) + The approximation is based on "Piecewise Linear Approximation of Bézier + Curves" by Roger Willcocks ( http://www.rops.org ) \param points Control points \param tolerance Maximum for the accepted error of the approximation @@ -802,39 +782,39 @@ QPainterPath QwtSplineInterpolating::painterPath( const QPolygonF& points ) cons \sa bezierControlLines(), QwtSplineBezier::toPolygon() */ -QPolygonF QwtSplineInterpolating::polygon( - const QPolygonF& points, double tolerance ) const +QPolygonF QwtSplineInterpolating::polygon(const QPolygonF &points, + double tolerance) const { - if ( tolerance <= 0.0 ) - return QPolygonF(); + if (tolerance <= 0.0) + return QPolygonF(); - const QVector< QLineF > controlLines = bezierControlLines( points ); - if ( controlLines.isEmpty() ) - return QPolygonF(); + const QVector controlLines = bezierControlLines(points); + if (controlLines.isEmpty()) + return QPolygonF(); - const bool isClosed = boundaryType() == QwtSpline::ClosedPolygon; + const bool isClosed = boundaryType() == QwtSpline::ClosedPolygon; - QwtBezier bezier( tolerance ); + QwtBezier bezier(tolerance); - const QPointF* p = points.constData(); - const QLineF* cl = controlLines.constData(); + const QPointF *p = points.constData(); + const QLineF *cl = controlLines.constData(); - const int n = controlLines.size(); + const int n = controlLines.size(); - QPolygonF polygon; + QPolygonF polygon; - for ( int i = 0; i < n - 1; i++ ) - { - const QLineF& l = cl[i]; - bezier.appendToPolygon( p[i], l.p1(), l.p2(), p[i + 1], polygon ); - } + for (int i = 0; i < n - 1; i++) + { + const QLineF &l = cl[i]; + bezier.appendToPolygon(p[i], l.p1(), l.p2(), p[i + 1], polygon); + } - const QPointF& pn = isClosed ? p[0] : p[n]; - const QLineF& l = cl[n - 1]; + const QPointF &pn = isClosed ? p[0] : p[n]; + const QLineF &l = cl[n - 1]; - bezier.appendToPolygon( p[n - 1], l.p1(), l.p2(), pn, polygon ); + bezier.appendToPolygon(p[n - 1], l.p1(), l.p2(), pn, polygon); - return polygon; + return polygon; } /*! @@ -860,95 +840,91 @@ QPolygonF QwtSplineInterpolating::polygon( \sa bezierControlLines() */ -QPolygonF QwtSplineInterpolating::equidistantPolygon( const QPolygonF& points, - double distance, bool withNodes ) const +QPolygonF QwtSplineInterpolating::equidistantPolygon(const QPolygonF &points, + double distance, + bool withNodes) const { - if ( distance <= 0.0 ) - return QPolygonF(); + if (distance <= 0.0) + return QPolygonF(); - const int n = points.size(); - if ( n <= 1 ) - return points; + const int n = points.size(); + if (n <= 1) + return points; - if ( n == 2 ) - { - // TODO - return points; - } + if (n == 2) + { + // TODO + return points; + } - QPolygonF path; + QPolygonF path; - const QVector< QLineF > controlLines = bezierControlLines( points ); - - if ( controlLines.size() < n - 1 ) - return path; - - path += points.first(); - double t = distance; - - const QPointF* p = points.constData(); - const QLineF* cl = controlLines.constData(); - - const QwtSplineParametrization* param = parametrization(); - - for ( int i = 0; i < n - 1; i++ ) - { - const double l = param->valueIncrement( p[i], p[i + 1] ); - - while ( t < l ) - { - path += QwtBezier::pointAt( p[i], cl[i].p1(), - cl[i].p2(), p[i + 1], t / l ); - - t += distance; - } - - if ( withNodes ) - { - if ( qFuzzyCompare( path.last().x(), p[i + 1].x() ) ) - path.last() = p[i + 1]; - else - path += p[i + 1]; - - t = distance; - } - else - { - t -= l; - } - } - - if ( ( boundaryType() == QwtSpline::ClosedPolygon ) - && ( controlLines.size() >= n ) ) - { - const double l = param->valueIncrement( p[n - 1], p[0] ); - - while ( t < l ) - { - path += QwtBezier::pointAt( p[n - 1], cl[n - 1].p1(), - cl[n - 1].p2(), p[0], t / l ); - - t += distance; - } - - if ( qFuzzyCompare( path.last().x(), p[0].x() ) ) - path.last() = p[0]; - else - path += p[0]; - } + const QVector controlLines = bezierControlLines(points); + if (controlLines.size() < n - 1) return path; + + path += points.first(); + double t = distance; + + const QPointF *p = points.constData(); + const QLineF *cl = controlLines.constData(); + + const QwtSplineParametrization *param = parametrization(); + + for (int i = 0; i < n - 1; i++) + { + const double l = param->valueIncrement(p[i], p[i + 1]); + + while (t < l) + { + path += QwtBezier::pointAt(p[i], cl[i].p1(), cl[i].p2(), p[i + 1], t / l); + + t += distance; + } + + if (withNodes) + { + if (qFuzzyCompare(path.last().x(), p[i + 1].x())) + path.last() = p[i + 1]; + else + path += p[i + 1]; + + t = distance; + } + else + { + t -= l; + } + } + + if ((boundaryType() == QwtSpline::ClosedPolygon) + && (controlLines.size() >= n)) + { + const double l = param->valueIncrement(p[n - 1], p[0]); + + while (t < l) + { + path += QwtBezier::pointAt(p[n - 1], cl[n - 1].p1(), cl[n - 1].p2(), p[0], + t / l); + + t += distance; + } + + if (qFuzzyCompare(path.last().x(), p[0].x())) + path.last() = p[0]; + else + path += p[0]; + } + + return path; } //! Constructor -QwtSplineG1::QwtSplineG1() -{ -} +QwtSplineG1::QwtSplineG1() {} //! Destructor -QwtSplineG1::~QwtSplineG1() -{ -} +QwtSplineG1::~QwtSplineG1() {} /*! \brief Constructor @@ -961,13 +937,11 @@ QwtSplineG1::~QwtSplineG1() */ QwtSplineC1::QwtSplineC1() { - setParametrization( QwtSplineParametrization::ParameterX ); + setParametrization(QwtSplineParametrization::ParameterX); } //! Destructor -QwtSplineC1::~QwtSplineC1() -{ -} +QwtSplineC1::~QwtSplineC1() {} /*! \param points Control points @@ -976,43 +950,47 @@ QwtSplineC1::~QwtSplineC1() \return value of the first derivative at the first point \sa slopeAtEnd(), QwtSpline::boundaryCondition(), QwtSpline::boundaryValue() */ -double QwtSplineC1::slopeAtBeginning( const QPolygonF& points, double slopeNext ) const +double QwtSplineC1::slopeAtBeginning(const QPolygonF &points, + double slopeNext) const { - if ( points.size() < 2 ) - return 0.0; + if (points.size() < 2) + return 0.0; - return QwtSplineC1P::slopeBoundary( - boundaryCondition( QwtSpline::AtBeginning ), - boundaryValue( QwtSpline::AtBeginning ), - points[0], points[1], slopeNext ); + return QwtSplineC1P::slopeBoundary(boundaryCondition(QwtSpline::AtBeginning), + boundaryValue(QwtSpline::AtBeginning), + points[0], points[1], slopeNext); } /*! \param points Control points - \param slopeBefore Value of the first derivative at the point before the last one + \param slopeBefore Value of the first derivative at the point before the last + one \return value of the first derivative at the last point - \sa slopeAtBeginning(), QwtSpline::boundaryCondition(), QwtSpline::boundaryValue() + \sa slopeAtBeginning(), QwtSpline::boundaryCondition(), + QwtSpline::boundaryValue() */ -double QwtSplineC1::slopeAtEnd( const QPolygonF& points, double slopeBefore ) const +double QwtSplineC1::slopeAtEnd(const QPolygonF &points, + double slopeBefore) const { - const int n = points.size(); + const int n = points.size(); - const QPointF p1( points[n - 1].x(), -points[n - 1].y() ); - const QPointF p2( points[n - 2].x(), -points[n - 2].y() ); + const QPointF p1(points[n - 1].x(), -points[n - 1].y()); + const QPointF p2(points[n - 2].x(), -points[n - 2].y()); - const int condition = boundaryCondition( QwtSpline::AtEnd ); + const int condition = boundaryCondition(QwtSpline::AtEnd); - double value = boundaryValue( QwtSpline::AtEnd ); - if ( condition != QwtSpline::LinearRunout ) - { - // beside LinearRunout the boundaryValue is a slope or curvature - // and needs to be inverted too - value = -value; - } + double value = boundaryValue(QwtSpline::AtEnd); + if (condition != QwtSpline::LinearRunout) + { + // beside LinearRunout the boundaryValue is a slope or curvature + // and needs to be inverted too + value = -value; + } - const double slope = QwtSplineC1P::slopeBoundary( condition, value, p1, p2, -slopeBefore ); - return -slope; + const double slope + = QwtSplineC1P::slopeBoundary(condition, value, p1, p2, -slopeBefore); + return -slope; } /*! \fn QVector QwtSplineC1::slopes( const QPolygonF &points ) const @@ -1040,53 +1018,47 @@ double QwtSplineC1::slopeAtEnd( const QPolygonF& points, double slopeBefore ) co \note Derived spline classes might overload painterPath() to avoid the extra loops for converting results into a QPainterPath */ -QPainterPath QwtSplineC1::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplineC1::painterPath(const QPolygonF &points) const { - const int n = points.size(); - if ( n <= 2 ) - return QwtSplineInterpolating::painterPath( points ); + const int n = points.size(); + if (n <= 2) + return QwtSplineInterpolating::painterPath(points); - using namespace QwtSplineC1P; + using namespace QwtSplineC1P; - PathStore store; - switch( parametrization()->type() ) - { - case QwtSplineParametrization::ParameterX: - { - store = qwtSplineC1PathParamX< PathStore >( this, points ); - break; - } - case QwtSplineParametrization::ParameterY: - { - store = qwtSplineC1PathParamY< PathStore >( this, points ); - break; - } - case QwtSplineParametrization::ParameterUniform: - { - store = qwtSplineC1PathParametric< PathStore >( - this, points, paramUniform() ); - break; - } - case QwtSplineParametrization::ParameterCentripetal: - { - store = qwtSplineC1PathParametric< PathStore >( - this, points, paramCentripetal() ); - break; - } - case QwtSplineParametrization::ParameterChordal: - { - store = qwtSplineC1PathParametric< PathStore >( - this, points, paramChordal() ); - break; - } - default: - { - store = qwtSplineC1PathParametric< PathStore >( - this, points, param( parametrization() ) ); - } + PathStore store; + switch (parametrization()->type()) + { + case QwtSplineParametrization::ParameterX: { + store = qwtSplineC1PathParamX(this, points); + break; } + case QwtSplineParametrization::ParameterY: { + store = qwtSplineC1PathParamY(this, points); + break; + } + case QwtSplineParametrization::ParameterUniform: { + store + = qwtSplineC1PathParametric(this, points, paramUniform()); + break; + } + case QwtSplineParametrization::ParameterCentripetal: { + store = qwtSplineC1PathParametric(this, points, + paramCentripetal()); + break; + } + case QwtSplineParametrization::ParameterChordal: { + store + = qwtSplineC1PathParametric(this, points, paramChordal()); + break; + } + default: { + store = qwtSplineC1PathParametric(this, points, + param(parametrization())); + } + } - return store.path; + return store.path; } /*! @@ -1098,53 +1070,47 @@ QPainterPath QwtSplineC1::painterPath( const QPolygonF& points ) const \param points Control points \return Control points of the interpolating Bezier curves */ -QVector< QLineF > QwtSplineC1::bezierControlLines( const QPolygonF& points ) const +QVector QwtSplineC1::bezierControlLines(const QPolygonF &points) const { - using namespace QwtSplineC1P; + using namespace QwtSplineC1P; - const int n = points.size(); - if ( n <= 2 ) - return QVector< QLineF >(); + const int n = points.size(); + if (n <= 2) + return QVector(); - ControlPointsStore store; - switch( parametrization()->type() ) - { - case QwtSplineParametrization::ParameterX: - { - store = qwtSplineC1PathParamX< ControlPointsStore >( this, points ); - break; - } - case QwtSplineParametrization::ParameterY: - { - store = qwtSplineC1PathParamY< ControlPointsStore >( this, points ); - break; - } - case QwtSplineParametrization::ParameterUniform: - { - store = qwtSplineC1PathParametric< ControlPointsStore >( - this, points, paramUniform() ); - break; - } - case QwtSplineParametrization::ParameterCentripetal: - { - store = qwtSplineC1PathParametric< ControlPointsStore >( - this, points, paramCentripetal() ); - break; - } - case QwtSplineParametrization::ParameterChordal: - { - store = qwtSplineC1PathParametric< ControlPointsStore >( - this, points, paramChordal() ); - break; - } - default: - { - store = qwtSplineC1PathParametric< ControlPointsStore >( - this, points, param( parametrization() ) ); - } + ControlPointsStore store; + switch (parametrization()->type()) + { + case QwtSplineParametrization::ParameterX: { + store = qwtSplineC1PathParamX(this, points); + break; } + case QwtSplineParametrization::ParameterY: { + store = qwtSplineC1PathParamY(this, points); + break; + } + case QwtSplineParametrization::ParameterUniform: { + store = qwtSplineC1PathParametric(this, points, + paramUniform()); + break; + } + case QwtSplineParametrization::ParameterCentripetal: { + store = qwtSplineC1PathParametric(this, points, + paramCentripetal()); + break; + } + case QwtSplineParametrization::ParameterChordal: { + store = qwtSplineC1PathParametric(this, points, + paramChordal()); + break; + } + default: { + store = qwtSplineC1PathParametric( + this, points, param(parametrization())); + } + } - return store.controlPoints; + return store.controlPoints; } /*! @@ -1164,23 +1130,24 @@ QVector< QLineF > QwtSplineC1::bezierControlLines( const QPolygonF& points ) con \sa QwtSpline::equidistantPolygon() */ -QPolygonF QwtSplineC1::equidistantPolygon( const QPolygonF& points, - double distance, bool withNodes ) const +QPolygonF QwtSplineC1::equidistantPolygon(const QPolygonF &points, + double distance, bool withNodes) const { - if ( parametrization()->type() == QwtSplineParametrization::ParameterX ) + if (parametrization()->type() == QwtSplineParametrization::ParameterX) + { + if (points.size() > 2) { - if ( points.size() > 2 ) - { - const QVector< double > m = slopes( points ); - if ( m.size() != points.size() ) - return QPolygonF(); + const QVector m = slopes(points); + if (m.size() != points.size()) + return QPolygonF(); - return qwtPolygonParametric< QwtSplinePolynomial::fromSlopes >( - distance, points, m, withNodes ); - } + return qwtPolygonParametric( + distance, points, m, withNodes); } + } - return QwtSplineInterpolating::equidistantPolygon( points, distance, withNodes ); + return QwtSplineInterpolating::equidistantPolygon(points, distance, + withNodes); } /*! @@ -1188,7 +1155,8 @@ QPolygonF QwtSplineC1::equidistantPolygon( const QPolygonF& points, C1 spline interpolations are based on finding values for the first derivates at the control points. The interpolating polynomials can - be calculated from the the first derivates using QwtSplinePolynomial::fromSlopes(). + be calculated from the the first derivates using + QwtSplinePolynomial::fromSlopes(). The default implementation is a two pass calculation. In derived classes it might be overloaded by a one pass implementation. @@ -1198,23 +1166,23 @@ QPolygonF QwtSplineC1::equidistantPolygon( const QPolygonF& points, \note The x coordinates need to be increasing or decreasing */ -QVector< QwtSplinePolynomial > QwtSplineC1::polynomials( - const QPolygonF& points ) const +QVector +QwtSplineC1::polynomials(const QPolygonF &points) const { - QVector< QwtSplinePolynomial > polynomials; - - const QVector< double > m = slopes( points ); - if ( m.size() < 2 ) - return polynomials; - - polynomials.reserve( m.size() - 1 ); - for ( int i = 1; i < m.size(); i++ ) - { - polynomials += QwtSplinePolynomial::fromSlopes( - points[i - 1], m[i - 1], points[i], m[i] ); - } + QVector polynomials; + const QVector m = slopes(points); + if (m.size() < 2) return polynomials; + + polynomials.reserve(m.size() - 1); + for (int i = 1; i < m.size(); i++) + { + polynomials += QwtSplinePolynomial::fromSlopes(points[i - 1], m[i - 1], + points[i], m[i]); + } + + return polynomials; } /*! @@ -1225,14 +1193,10 @@ QVector< QwtSplinePolynomial > QwtSplineC1::polynomials( \sa QwtSpline::setParametrization(), QwtSpline::setBoundaryType() */ -QwtSplineC2::QwtSplineC2() -{ -} +QwtSplineC2::QwtSplineC2() {} //! Destructor -QwtSplineC2::~QwtSplineC2() -{ -} +QwtSplineC2::~QwtSplineC2() {} /*! \brief Interpolate a curve with Bezier curves @@ -1246,12 +1210,12 @@ QwtSplineC2::~QwtSplineC2() \note The implementation simply calls QwtSplineC1::painterPath(), but is intended to be replaced by a one pass calculation some day. */ -QPainterPath QwtSplineC2::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplineC2::painterPath(const QPolygonF &points) const { - // could be implemented from curvatures without the extra - // loop for calculating the slopes vector. TODO ... + // could be implemented from curvatures without the extra + // loop for calculating the slopes vector. TODO ... - return QwtSplineC1::painterPath( points ); + return QwtSplineC1::painterPath(points); } /*! @@ -1267,12 +1231,12 @@ QPainterPath QwtSplineC2::painterPath( const QPolygonF& points ) const but is intended to be replaced by a more efficient implementation that builds the polynomials by the curvatures some day. */ -QVector< QLineF > QwtSplineC2::bezierControlLines( const QPolygonF& points ) const +QVector QwtSplineC2::bezierControlLines(const QPolygonF &points) const { - // could be implemented from curvatures without the extra - // loop for calculating the slopes vector. TODO ... + // could be implemented from curvatures without the extra + // loop for calculating the slopes vector. TODO ... - return QwtSplineC1::bezierControlLines( points ); + return QwtSplineC1::bezierControlLines(points); } /*! @@ -1292,23 +1256,24 @@ QVector< QLineF > QwtSplineC2::bezierControlLines( const QPolygonF& points ) con \sa QwtSpline::equidistantPolygon() */ -QPolygonF QwtSplineC2::equidistantPolygon( const QPolygonF& points, - double distance, bool withNodes ) const +QPolygonF QwtSplineC2::equidistantPolygon(const QPolygonF &points, + double distance, bool withNodes) const { - if ( parametrization()->type() == QwtSplineParametrization::ParameterX ) + if (parametrization()->type() == QwtSplineParametrization::ParameterX) + { + if (points.size() > 2) { - if ( points.size() > 2 ) - { - const QVector< double > cv = curvatures( points ); - if ( cv.size() != points.size() ) - return QPolygonF(); + const QVector cv = curvatures(points); + if (cv.size() != points.size()) + return QPolygonF(); - return qwtPolygonParametric< QwtSplinePolynomial::fromCurvatures >( - distance, points, cv, withNodes ); - } + return qwtPolygonParametric( + distance, points, cv, withNodes); } + } - return QwtSplineInterpolating::equidistantPolygon( points, distance, withNodes ); + return QwtSplineInterpolating::equidistantPolygon(points, distance, + withNodes); } /*! \fn QVector QwtSplineC2::curvatures( const QPolygonF &points ) const @@ -1336,31 +1301,32 @@ QPolygonF QwtSplineC2::equidistantPolygon( const QPolygonF& points, \note The x coordinates need to be increasing or decreasing */ -QVector< double > QwtSplineC2::slopes( const QPolygonF& points ) const +QVector QwtSplineC2::slopes(const QPolygonF &points) const { - const QVector< double > curvatures = this->curvatures( points ); - if ( curvatures.size() < 2 ) - return QVector< double >(); + const QVector curvatures = this->curvatures(points); + if (curvatures.size() < 2) + return QVector(); - QVector< double > slopes( curvatures.size() ); + QVector slopes(curvatures.size()); - const double* cv = curvatures.constData(); - double* m = slopes.data(); + const double *cv = curvatures.constData(); + double *m = slopes.data(); - const int n = points.size(); - const QPointF* p = points.constData(); + const int n = points.size(); + const QPointF *p = points.constData(); - QwtSplinePolynomial polynomial; + QwtSplinePolynomial polynomial; - for ( int i = 0; i < n - 1; i++ ) - { - polynomial = QwtSplinePolynomial::fromCurvatures( p[i], cv[i], p[i + 1], cv[i + 1] ); - m[i] = polynomial.c1; - } + for (int i = 0; i < n - 1; i++) + { + polynomial + = QwtSplinePolynomial::fromCurvatures(p[i], cv[i], p[i + 1], cv[i + 1]); + m[i] = polynomial.c1; + } - m[n - 1] = polynomial.slopeAt( p[n - 1].x() - p[n - 2].x() ); + m[n - 1] = polynomial.slopeAt(p[n - 1].x() - p[n - 2].x()); - return slopes; + return slopes; } /*! @@ -1368,7 +1334,8 @@ QVector< double > QwtSplineC2::slopes( const QPolygonF& points ) const C2 spline interpolations are based on finding values for the second derivates of f at the control points. The interpolating polynomials can - be calculated from the the second derivates using QwtSplinePolynomial::fromCurvatures. + be calculated from the the second derivates using + QwtSplinePolynomial::fromCurvatures. The default implementation is a 2 pass calculation. In derived classes it might be overloaded by a one pass implementation. @@ -1378,24 +1345,25 @@ QVector< double > QwtSplineC2::slopes( const QPolygonF& points ) const \note The x coordinates need to be increasing or decreasing */ -QVector< QwtSplinePolynomial > QwtSplineC2::polynomials( const QPolygonF& points ) const +QVector +QwtSplineC2::polynomials(const QPolygonF &points) const { - QVector< QwtSplinePolynomial > polynomials; - - const QVector< double > curvatures = this->curvatures( points ); - if ( curvatures.size() < 2 ) - return polynomials; - - const QPointF* p = points.constData(); - const double* cv = curvatures.constData(); - const int n = curvatures.size(); - polynomials.reserve( n - 1 ); - - for ( int i = 1; i < n; i++ ) - { - polynomials += QwtSplinePolynomial::fromCurvatures( - p[i - 1], cv[i - 1], p[i], cv[i] ); - } + QVector polynomials; + const QVector curvatures = this->curvatures(points); + if (curvatures.size() < 2) return polynomials; + + const QPointF *p = points.constData(); + const double *cv = curvatures.constData(); + const int n = curvatures.size(); + polynomials.reserve(n - 1); + + for (int i = 1; i < n; i++) + { + polynomials += QwtSplinePolynomial::fromCurvatures(p[i - 1], cv[i - 1], + p[i], cv[i]); + } + + return polynomials; } diff --git a/libs/qwt/src/qwt_spline.h b/libs/qwt/src/qwt_spline.h index aaf9b3fe..cd0169ae 100644 --- a/libs/qwt/src/qwt_spline.h +++ b/libs/qwt/src/qwt_spline.h @@ -20,15 +20,17 @@ class QLineF; class QPolygonF; #if QT_VERSION < 0x060000 -template< typename T > class QVector; +template +class QVector; #endif /*! \brief Base class for all splines - A spline is a curve represented by a sequence of polynomials. Spline approximation - is the process of finding polynomials for a given set of points. - When the algorithm preserves the initial points it is called interpolating. + A spline is a curve represented by a sequence of polynomials. Spline + approximation is the process of finding polynomials for a given set of + points. When the algorithm preserves the initial points it is called + interpolating. Splines can be classified according to conditions of the polynomials that are met at the start/endpoints of the pieces: @@ -37,8 +39,8 @@ template< typename T > class QVector; - G0: polynomials are joined - G1: first derivatives are proportional at the join point - The curve tangents thus have the same direction, but not necessarily the - same magnitude. i.e., C1'(1) = (a,b,c) and C2'(0) = (k*a, k*b, k*c). + The curve tangents thus have the same direction, but not necessarily + the same magnitude. i.e., C1'(1) = (a,b,c) and C2'(0) = (k*a, k*b, k*c). - G2: first and second derivatives are proportional at join point - Parametric Continuity @@ -48,140 +50,140 @@ template< typename T > class QVector; - C2: first and second derivatives are equal Geometric continuity requires the geometry to be continuous, while parametric - continuity requires that the underlying parameterization be continuous as well. - Parametric continuity of order n implies geometric continuity of order n, - but not vice-versa. + continuity requires that the underlying parameterization be continuous as + well. Parametric continuity of order n implies geometric continuity of order + n, but not vice-versa. QwtSpline is the base class for spline approximations of any continuity. */ class QWT_EXPORT QwtSpline { - public: +public: + /*! + Boundary type specifying the spline at its endpoints + + \sa setBoundaryType(), boundaryType() + */ + enum BoundaryType + { /*! - Boundary type specifying the spline at its endpoints + The polynomials at the start/endpoint depend on specific conditions - \sa setBoundaryType(), boundaryType() + \sa QwtSpline::BoundaryCondition */ - enum BoundaryType - { - /*! - The polynomials at the start/endpoint depend on specific conditions - - \sa QwtSpline::BoundaryCondition - */ - ConditionalBoundaries, - - /*! - The polynomials at the start/endpoint are found by using - imaginary additional points. Additional points at the end - are found by translating points from the beginning or v.v. - */ - PeriodicPolygon, - - /*! - ClosedPolygon is similar to PeriodicPolygon beside, that - the interpolation includes the connection between the last - and the first control point. - - \note Only works for parametrizations, where the parameter increment - for the the final closing line is positive. - This excludes QwtSplineParametrization::ParameterX and - QwtSplineParametrization::ParameterY - */ - - ClosedPolygon - }; + ConditionalBoundaries, /*! - position of a boundary condition - \sa boundaryCondition(), boundaryValue() + The polynomials at the start/endpoint are found by using + imaginary additional points. Additional points at the end + are found by translating points from the beginning or v.v. */ - enum BoundaryPosition - { - //! the condition is at the beginning of the polynomial - AtBeginning, - - //! the condition is at the end of the polynomial - AtEnd - }; + PeriodicPolygon, /*! - \brief Boundary condition + ClosedPolygon is similar to PeriodicPolygon beside, that + the interpolation includes the connection between the last + and the first control point. - A spline algorithm calculates polynomials by looking - a couple of points back/ahead ( locality() ). At the ends - additional rules are necessary to compensate the missing - points. - - \sa boundaryCondition(), boundaryValue() - \sa QwtSplineC2::BoundaryConditionC2 + \note Only works for parametrizations, where the parameter increment + for the the final closing line is positive. + This excludes QwtSplineParametrization::ParameterX and + QwtSplineParametrization::ParameterY */ - enum BoundaryCondition - { - /*! - The first derivative at the end point is given - \sa boundaryValue() - */ - Clamped1, - /*! - The second derivative at the end point is given + ClosedPolygon + }; - \sa boundaryValue() - \note a condition having a second derivative of 0 - is also called "natural". - */ - Clamped2, + /*! + position of a boundary condition + \sa boundaryCondition(), boundaryValue() + */ + enum BoundaryPosition + { + //! the condition is at the beginning of the polynomial + AtBeginning, - /*! - The third derivative at the end point is given + //! the condition is at the end of the polynomial + AtEnd + }; - \sa boundaryValue() - \note a condition having a third derivative of 0 - is also called "parabolic runout". - */ - Clamped3, + /*! + \brief Boundary condition - /*! - The first derivate at the endpoint is related to the first derivative - at its neighbour by the boundary value. F,e when the boundary - value at the end is 1.0 then the slope at the last 2 points is - the same. + A spline algorithm calculates polynomials by looking + a couple of points back/ahead ( locality() ). At the ends + additional rules are necessary to compensate the missing + points. - \sa boundaryValue(). - */ - LinearRunout - }; + \sa boundaryCondition(), boundaryValue() + \sa QwtSplineC2::BoundaryConditionC2 + */ + enum BoundaryCondition + { + /*! + The first derivative at the end point is given + \sa boundaryValue() + */ + Clamped1, - QwtSpline(); - virtual ~QwtSpline(); + /*! + The second derivative at the end point is given - void setParametrization( int type ); - void setParametrization( QwtSplineParametrization* ); - const QwtSplineParametrization* parametrization() const; + \sa boundaryValue() + \note a condition having a second derivative of 0 + is also called "natural". + */ + Clamped2, - void setBoundaryType( BoundaryType ); - BoundaryType boundaryType() const; + /*! + The third derivative at the end point is given - void setBoundaryValue( BoundaryPosition, double value ); - double boundaryValue( BoundaryPosition ) const; + \sa boundaryValue() + \note a condition having a third derivative of 0 + is also called "parabolic runout". + */ + Clamped3, - void setBoundaryCondition( BoundaryPosition, int condition ); - int boundaryCondition( BoundaryPosition ) const; + /*! + The first derivate at the endpoint is related to the first derivative + at its neighbour by the boundary value. F,e when the boundary + value at the end is 1.0 then the slope at the last 2 points is + the same. - void setBoundaryConditions( int condition, - double valueBegin = 0.0, double valueEnd = 0.0 ); + \sa boundaryValue(). + */ + LinearRunout + }; - virtual QPolygonF polygon( const QPolygonF&, double tolerance ) const; - virtual QPainterPath painterPath( const QPolygonF& ) const = 0; + QwtSpline(); + virtual ~QwtSpline(); - virtual uint locality() const; + void setParametrization(int type); + void setParametrization(QwtSplineParametrization *); + const QwtSplineParametrization *parametrization() const; - private: - Q_DISABLE_COPY(QwtSpline) + void setBoundaryType(BoundaryType); + BoundaryType boundaryType() const; - class PrivateData; - PrivateData* m_data; + void setBoundaryValue(BoundaryPosition, double value); + double boundaryValue(BoundaryPosition) const; + + void setBoundaryCondition(BoundaryPosition, int condition); + int boundaryCondition(BoundaryPosition) const; + + void setBoundaryConditions(int condition, double valueBegin = 0.0, + double valueEnd = 0.0); + + virtual QPolygonF polygon(const QPolygonF &, double tolerance) const; + virtual QPainterPath painterPath(const QPolygonF &) const = 0; + + virtual uint locality() const; + +private: + Q_DISABLE_COPY(QwtSpline) + + class PrivateData; + PrivateData *m_data; }; /*! @@ -192,21 +194,21 @@ class QWT_EXPORT QwtSpline */ class QWT_EXPORT QwtSplineInterpolating : public QwtSpline { - public: - QwtSplineInterpolating(); - virtual ~QwtSplineInterpolating(); +public: + QwtSplineInterpolating(); + virtual ~QwtSplineInterpolating(); - virtual QPolygonF equidistantPolygon( const QPolygonF&, - double distance, bool withNodes ) const; + virtual QPolygonF equidistantPolygon(const QPolygonF &, double distance, + bool withNodes) const; - virtual QPolygonF polygon( - const QPolygonF&, double tolerance ) const QWT_OVERRIDE; + virtual QPolygonF polygon(const QPolygonF &, + double tolerance) const QWT_OVERRIDE; - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< QLineF > bezierControlLines( const QPolygonF& ) const = 0; + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector bezierControlLines(const QPolygonF &) const = 0; - private: - Q_DISABLE_COPY(QwtSplineInterpolating) +private: + Q_DISABLE_COPY(QwtSplineInterpolating) }; /*! @@ -215,9 +217,9 @@ class QWT_EXPORT QwtSplineInterpolating : public QwtSpline */ class QWT_EXPORT QwtSplineG1 : public QwtSplineInterpolating { - public: - QwtSplineG1(); - virtual ~QwtSplineG1(); +public: + QwtSplineG1(); + virtual ~QwtSplineG1(); }; /*! @@ -228,28 +230,30 @@ class QWT_EXPORT QwtSplineG1 : public QwtSplineInterpolating the 1. derivate at some control points. In case of non parametric splines those points are the curve points, while - for parametric splines the calculation is done twice using a parameter value t. + for parametric splines the calculation is done twice using a parameter value + t. \sa QwtSplineParametrization */ class QWT_EXPORT QwtSplineC1 : public QwtSplineG1 { - public: - QwtSplineC1(); - virtual ~QwtSplineC1(); +public: + QwtSplineC1(); + virtual ~QwtSplineC1(); - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< QLineF > bezierControlLines( const QPolygonF& ) const QWT_OVERRIDE; + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector + bezierControlLines(const QPolygonF &) const QWT_OVERRIDE; - virtual QPolygonF equidistantPolygon( const QPolygonF&, - double distance, bool withNodes ) const QWT_OVERRIDE; + virtual QPolygonF equidistantPolygon(const QPolygonF &, double distance, + bool withNodes) const QWT_OVERRIDE; - // these methods are the non parametric part - virtual QVector< QwtSplinePolynomial > polynomials( const QPolygonF& ) const; - virtual QVector< double > slopes( const QPolygonF& ) const = 0; + // these methods are the non parametric part + virtual QVector polynomials(const QPolygonF &) const; + virtual QVector slopes(const QPolygonF &) const = 0; - virtual double slopeAtBeginning( const QPolygonF&, double slopeNext ) const; - virtual double slopeAtEnd( const QPolygonF&, double slopeBefore ) const; + virtual double slopeAtBeginning(const QPolygonF &, double slopeNext) const; + virtual double slopeAtEnd(const QPolygonF &, double slopeBefore) const; }; /*! @@ -260,51 +264,54 @@ class QWT_EXPORT QwtSplineC1 : public QwtSplineG1 the 2. derivate at some control points. In case of non parametric splines those points are the curve points, while - for parametric splines the calculation is done twice using a parameter value t. + for parametric splines the calculation is done twice using a parameter value + t. \sa QwtSplineParametrization */ class QWT_EXPORT QwtSplineC2 : public QwtSplineC1 { - public: +public: + /*! + Boundary condition that requires C2 continuity + + \sa QwtSpline::boundaryCondition, QwtSpline::BoundaryCondition + */ + enum BoundaryConditionC2 + { /*! - Boundary condition that requires C2 continuity + The second derivate at the endpoint is related to the second derivatives + at the 2 neighbours: cv[0] := 2.0 * cv[1] - cv[2]. - \sa QwtSpline::boundaryCondition, QwtSpline::BoundaryCondition + \note boundaryValue() is ignored */ - enum BoundaryConditionC2 - { - /*! - The second derivate at the endpoint is related to the second derivatives - at the 2 neighbours: cv[0] := 2.0 * cv[1] - cv[2]. + CubicRunout = LinearRunout + 1, - \note boundaryValue() is ignored - */ - CubicRunout = LinearRunout + 1, + /*! + The 3rd derivate at the endpoint matches the 3rd derivate at its + neighbours. Or in other words: the first/last curve segment extents the + polynomial of its neighboured polynomial - /*! - The 3rd derivate at the endpoint matches the 3rd derivate at its neighbours. - Or in other words: the first/last curve segment extents the polynomial of its - neighboured polynomial + \note boundaryValue() is ignored + */ + NotAKnot + }; - \note boundaryValue() is ignored - */ - NotAKnot - }; + QwtSplineC2(); + virtual ~QwtSplineC2(); - QwtSplineC2(); - virtual ~QwtSplineC2(); + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector + bezierControlLines(const QPolygonF &) const QWT_OVERRIDE; - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< QLineF > bezierControlLines( const QPolygonF& ) const QWT_OVERRIDE; + virtual QPolygonF equidistantPolygon(const QPolygonF &, double distance, + bool withNodes) const QWT_OVERRIDE; - virtual QPolygonF equidistantPolygon( const QPolygonF&, - double distance, bool withNodes ) const QWT_OVERRIDE; - - // calculating the parametric equations - virtual QVector< QwtSplinePolynomial > polynomials( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< double > slopes( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< double > curvatures( const QPolygonF& ) const = 0; + // calculating the parametric equations + virtual QVector + polynomials(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector slopes(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector curvatures(const QPolygonF &) const = 0; }; #endif diff --git a/libs/qwt/src/qwt_spline_basis.cpp b/libs/qwt/src/qwt_spline_basis.cpp index 2837294b..f39e465c 100644 --- a/libs/qwt/src/qwt_spline_basis.cpp +++ b/libs/qwt/src/qwt_spline_basis.cpp @@ -66,177 +66,175 @@ static inline void qwtSplineBezierControlPoints( const QwtSplineParametrization* } #endif -static QPainterPath qwtSplineBasisPathUniform( const QPolygonF& points, - QwtSpline::BoundaryType boundaryType ) +static QPainterPath +qwtSplineBasisPathUniform(const QPolygonF &points, + QwtSpline::BoundaryType boundaryType) { - const int n = points.size(); - const QPointF* pd = points.constData(); + const int n = points.size(); + const QPointF *pd = points.constData(); - QPainterPath path; + QPainterPath path; - QPointF cp1 = ( 2.0 * pd[0] + pd[1] ) / 3.0;; + QPointF cp1 = (2.0 * pd[0] + pd[1]) / 3.0; + ; - if ( boundaryType == QwtSpline::ConditionalBoundaries ) + if (boundaryType == QwtSpline::ConditionalBoundaries) + { + path.moveTo(pd[0]); + } + else + { + const QPointF cpN = (pd[n - 1] + 2.0 * pd[0]) / 3.0; + path.moveTo(0.5 * (cpN + cp1)); + } + + for (int i = 1; i < n - 1; i++) + { + const QPointF cp2 = (pd[i - 1] + 2.0 * pd[i]) / 3.0; + const QPointF cp3 = (2.0 * pd[i] + pd[i + 1]) / 3.0; + + path.cubicTo(cp1, cp2, 0.5 * (cp2 + cp3)); + + cp1 = cp3; + } + + if (boundaryType == QwtSpline::ConditionalBoundaries) + { + const QPointF cp2 = (pd[n - 2] + 2.0 * pd[n - 1]) / 3.0; + path.cubicTo(cp1, cp2, pd[n - 1]); + } + else + { + const QPointF cp2 = (pd[n - 2] + 2.0 * pd[n - 1]) / 3.0; + const QPointF cp3 = (2.0 * pd[n - 1] + pd[0]) / 3.0; + + path.cubicTo(cp1, cp2, 0.5 * (cp2 + cp3)); + + if (boundaryType == QwtSpline::ClosedPolygon) { - path.moveTo( pd[0] ); - } - else - { - const QPointF cpN = ( pd[n - 1] + 2.0 * pd[0] ) / 3.0; - path.moveTo( 0.5 * ( cpN + cp1 ) ); + const QPointF cp4 = (pd[n - 1] + 2.0 * pd[0]) / 3.0; + const QPointF cp5 = (2.0 * pd[0] + pd[1]) / 3.0; + + path.cubicTo(cp3, cp4, 0.5 * (cp4 + cp5)); } + } - for ( int i = 1; i < n - 1; i++ ) - { - const QPointF cp2 = ( pd[i - 1] + 2.0 * pd[i] ) / 3.0; - const QPointF cp3 = ( 2.0 * pd[i] + pd[i + 1] ) / 3.0; - - path.cubicTo( cp1, cp2, 0.5 * ( cp2 + cp3 ) ); - - cp1 = cp3; - } - - if ( boundaryType == QwtSpline::ConditionalBoundaries ) - { - const QPointF cp2 = ( pd[n - 2] + 2.0 * pd[n - 1] ) / 3.0; - path.cubicTo( cp1, cp2, pd[n - 1] ); - } - else - { - const QPointF cp2 = ( pd[n - 2] + 2.0 * pd[n - 1] ) / 3.0; - const QPointF cp3 = ( 2.0 * pd[n - 1] + pd[0] ) / 3.0; - - path.cubicTo( cp1, cp2, 0.5 * ( cp2 + cp3 ) ); - - if ( boundaryType == QwtSpline::ClosedPolygon ) - { - const QPointF cp4 = ( pd[n - 1] + 2.0 * pd[0] ) / 3.0; - const QPointF cp5 = ( 2.0 * pd[0] + pd[1] ) / 3.0; - - path.cubicTo( cp3, cp4, 0.5 * ( cp4 + cp5 ) ); - } - } - - return path; + return path; } -static QPainterPath qwtSplineBasisPath( const QPolygonF& points, - const QwtSplineParametrization* param, - QwtSpline::BoundaryType boundaryType ) +static QPainterPath qwtSplineBasisPath(const QPolygonF &points, + const QwtSplineParametrization *param, + QwtSpline::BoundaryType boundaryType) { - const int n = points.size(); - const QPointF* pd = points.constData(); + const int n = points.size(); + const QPointF *pd = points.constData(); - QPointF p0; + QPointF p0; - double t1 = param->valueIncrement( pd[0], pd[1] ); - double t2 = param->valueIncrement( pd[1], pd[2] ); + double t1 = param->valueIncrement(pd[0], pd[1]); + double t2 = param->valueIncrement(pd[1], pd[2]); - double t0; - if ( boundaryType == QwtSpline::ConditionalBoundaries ) - t0 = t1; + double t0; + if (boundaryType == QwtSpline::ConditionalBoundaries) + t0 = t1; + else + t0 = param->valueIncrement(pd[n - 1], pd[0]); + + double t012 = t0 + t1 + t2; + QPointF cp1 = ((t1 + t2) * pd[0] + t0 * pd[1]) / t012; + + if (boundaryType == QwtSpline::ConditionalBoundaries) + { + p0 = pd[0]; + } + else + { + const double tN = param->valueIncrement(pd[n - 2], pd[n - 1]); + const QPointF cpN = (t1 * pd[n - 1] + (tN + t0) * pd[0]) / (tN + t0 + t1); + + p0 = (t1 * cpN + t0 * cp1) / (t0 + t1); + } + + QPainterPath path; + path.moveTo(p0); + + for (int i = 1; i < n - 2; i++) + { + const double t3 = param->valueIncrement(pd[i + 1], pd[i + 2]); + const double t123 = t1 + t2 + t3; + + const QPointF cp2 = (t2 * pd[i - 1] + (t0 + t1) * pd[i]) / t012; + const QPointF cp3 = ((t2 + t3) * pd[i] + t1 * pd[i + 1]) / t123; + + const QPointF p2 = (t2 * cp2 + t1 * cp3) / (t1 + t2); + + path.cubicTo(cp1, cp2, p2); + + cp1 = cp3; + + t0 = t1; + t1 = t2; + t2 = t3; + t012 = t123; + } + + { + double t3; + if (boundaryType == QwtSpline::ConditionalBoundaries) + t3 = t2; else - t0 = param->valueIncrement( pd[n - 1], pd[0] ); + t3 = param->valueIncrement(pd[n - 1], pd[0]); - double t012 = t0 + t1 + t2; - QPointF cp1 = ( ( t1 + t2 ) * pd[0] + t0 * pd[1] ) / t012; + const double t123 = t1 + t2 + t3; - if ( boundaryType == QwtSpline::ConditionalBoundaries ) - { - p0 = pd[0]; - } - else - { - const double tN = param->valueIncrement( pd[n - 2], pd[n - 1] ); - const QPointF cpN = ( t1 * pd[n - 1] + ( tN + t0 ) * pd[0] ) / ( tN + t0 + t1 ); + const QPointF cp2 = (t2 * pd[n - 3] + (t0 + t1) * pd[n - 2]) / t012; + const QPointF cp3 = ((t2 + t3) * pd[n - 2] + t1 * pd[n - 1]) / t123; - p0 = ( t1 * cpN + t0 * cp1 ) / ( t0 + t1 ); - } + const QPointF p2 = (t2 * cp2 + t1 * cp3) / (t1 + t2); - QPainterPath path; - path.moveTo( p0 ); + path.cubicTo(cp1, cp2, p2); - for ( int i = 1; i < n - 2; i++ ) - { - const double t3 = param->valueIncrement( pd[i + 1], pd[i + 2] ); - const double t123 = t1 + t2 + t3; + cp1 = cp3; - const QPointF cp2 = ( t2 * pd[i - 1] + ( t0 + t1 ) * pd[i] ) / t012; - const QPointF cp3 = ( ( t2 + t3 ) * pd[i] + t1 * pd[i + 1] ) / t123; + t0 = t1; + t1 = t2; + t2 = t3; + t012 = t123; + } - const QPointF p2 = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 ); + const QPointF cp2 = (t2 * pd[n - 2] + (t0 + t1) * pd[n - 1]) / t012; - path.cubicTo( cp1, cp2, p2 ); + if (boundaryType == QwtSpline::ConditionalBoundaries) + { + path.cubicTo(cp1, cp2, pd[n - 1]); + } + else + { + const double t3 = param->valueIncrement(pd[0], pd[1]); + const double t123 = t1 + t2 + t3; - cp1 = cp3; + const QPointF cp3 = (t2 + t3) / t123 * pd[n - 1] + t1 / t123 * pd[0]; + const QPointF cp4 = (t3 * pd[n - 1] + (t1 + t2) * pd[0]) / t123; - t0 = t1; - t1 = t2; - t2 = t3; - t012 = t123; - } + const QPointF pN = (t2 * cp2 + t1 * cp3) / (t1 + t2); - { - double t3; - if ( boundaryType == QwtSpline::ConditionalBoundaries ) - t3 = t2; - else - t3 = param->valueIncrement( pd[n - 1], pd[0] ); + path.cubicTo(cp1, cp2, pN); + path.cubicTo(cp3, cp4, p0); + } - const double t123 = t1 + t2 + t3; - - const QPointF cp2 = ( t2 * pd[n - 3] + ( t0 + t1 ) * pd[n - 2] ) / t012; - const QPointF cp3 = ( ( t2 + t3 ) * pd[n - 2] + t1 * pd[n - 1] ) / t123; - - const QPointF p2 = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 ); - - path.cubicTo( cp1, cp2, p2 ); - - cp1 = cp3; - - t0 = t1; - t1 = t2; - t2 = t3; - t012 = t123; - } - - const QPointF cp2 = ( t2 * pd[n - 2] + ( t0 + t1 ) * pd[n - 1] ) / t012; - - if ( boundaryType == QwtSpline::ConditionalBoundaries ) - { - path.cubicTo( cp1, cp2, pd[n - 1] ); - } - else - { - const double t3 = param->valueIncrement( pd[0], pd[1] ); - const double t123 = t1 + t2 + t3; - - const QPointF cp3 = ( t2 + t3 ) / t123 * pd[n - 1] + t1 / t123 * pd[0]; - const QPointF cp4 = ( t3 * pd[n - 1] + ( t1 + t2 ) * pd[0] ) / t123; - - const QPointF pN = ( t2 * cp2 + t1 * cp3 ) / ( t1 + t2 ); - - path.cubicTo( cp1, cp2, pN ); - path.cubicTo( cp3, cp4, p0 ); - } - - return path; + return path; } //! Constructor -QwtSplineBasis::QwtSplineBasis() -{ -} +QwtSplineBasis::QwtSplineBasis() {} //! Destructor -QwtSplineBasis::~QwtSplineBasis() -{ -} +QwtSplineBasis::~QwtSplineBasis() {} //! The locality is always 2 uint QwtSplineBasis::locality() const { - return 2; + return 2; } /*! @@ -246,25 +244,23 @@ uint QwtSplineBasis::locality() const \param points Control points \return Painter path, that can be rendered by QPainter */ -QPainterPath QwtSplineBasis::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplineBasis::painterPath(const QPolygonF &points) const { - if ( points.size() < 4 ) - return QPainterPath(); + if (points.size() < 4) + return QPainterPath(); - QPainterPath path; + QPainterPath path; - switch( parametrization()->type() ) - { - case QwtSplineParametrization::ParameterUniform: - { - path = qwtSplineBasisPathUniform( points, boundaryType() ); - break; - } - default: - { - path = qwtSplineBasisPath( points, parametrization(), boundaryType() ); - } + switch (parametrization()->type()) + { + case QwtSplineParametrization::ParameterUniform: { + path = qwtSplineBasisPathUniform(points, boundaryType()); + break; } + default: { + path = qwtSplineBasisPath(points, parametrization(), boundaryType()); + } + } - return path; + return path; } diff --git a/libs/qwt/src/qwt_spline_basis.h b/libs/qwt/src/qwt_spline_basis.h index f95e8c96..4b27b25a 100644 --- a/libs/qwt/src/qwt_spline_basis.h +++ b/libs/qwt/src/qwt_spline_basis.h @@ -16,19 +16,19 @@ /*! \brief An approximation using a basis spline - QwtSplineBasis approximates a set of points by a polynomials with C2 continuity - ( = first and second derivatives are equal ) at the end points. + QwtSplineBasis approximates a set of points by a polynomials with C2 + continuity ( = first and second derivatives are equal ) at the end points. The end points of the spline do not match the original points. */ class QWT_EXPORT QwtSplineBasis : public QwtSpline { - public: - QwtSplineBasis(); - virtual ~QwtSplineBasis(); +public: + QwtSplineBasis(); + virtual ~QwtSplineBasis(); - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual uint locality() const QWT_OVERRIDE; + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual uint locality() const QWT_OVERRIDE; }; #endif diff --git a/libs/qwt/src/qwt_spline_cubic.cpp b/libs/qwt/src/qwt_spline_cubic.cpp index be710705..5417173d 100644 --- a/libs/qwt/src/qwt_spline_cubic.cpp +++ b/libs/qwt/src/qwt_spline_cubic.cpp @@ -18,359 +18,334 @@ namespace QwtSplineCubicP { - class KahanSum - { - public: - inline KahanSum( double value = 0.0 ): - m_sum( value ), - m_carry( 0.0 ) - { - } +class KahanSum +{ +public: + inline KahanSum(double value = 0.0) + : m_sum(value) + , m_carry(0.0) + { + } - inline void reset() - { - m_sum = m_carry = 0.0; - } + inline void reset() { m_sum = m_carry = 0.0; } - inline double value() const - { - return m_sum; - } + inline double value() const { return m_sum; } - inline void add( double value ) - { - const double y = value - m_carry; - const double t = m_sum + y; + inline void add(double value) + { + const double y = value - m_carry; + const double t = m_sum + y; - m_carry = ( t - m_sum ) - y; - m_sum = t; - } + m_carry = (t - m_sum) - y; + m_sum = t; + } - static inline double sum3( double d1, double d2, double d3 ) - { - KahanSum sum( d1 ); - sum.add( d2 ); - sum.add( d3 ); + static inline double sum3(double d1, double d2, double d3) + { + KahanSum sum(d1); + sum.add(d2); + sum.add(d3); - return sum.value(); - } + return sum.value(); + } - static inline double sum4( double d1, double d2, double d3, double d4 ) - { - KahanSum sum( d1 ); - sum.add( d2 ); - sum.add( d3 ); - sum.add( d4 ); + static inline double sum4(double d1, double d2, double d3, double d4) + { + KahanSum sum(d1); + sum.add(d2); + sum.add(d3); + sum.add(d4); - return sum.value(); - } + return sum.value(); + } +private: + double m_sum; + double m_carry; // The carry from the previous operation +}; - private: - double m_sum; - double m_carry; // The carry from the previous operation - }; +class CurvatureStore +{ +public: + inline void setup(int size) + { + m_curvatures.resize(size); + m_cv = m_curvatures.data(); + } - class CurvatureStore - { - public: - inline void setup( int size ) - { - m_curvatures.resize( size ); - m_cv = m_curvatures.data(); - } + inline void storeFirst(double, const QPointF &, const QPointF &, double b1, + double) + { + m_cv[0] = 2.0 * b1; + } - inline void storeFirst( double, - const QPointF&, const QPointF&, double b1, double ) - { - m_cv[0] = 2.0 * b1; - } + inline void storeNext(int index, double, const QPointF &, const QPointF &, + double, double b2) + { + m_cv[index] = 2.0 * b2; + } - inline void storeNext( int index, double, - const QPointF&, const QPointF&, double, double b2 ) - { - m_cv[index] = 2.0 * b2; - } + inline void storeLast(double, const QPointF &, const QPointF &, double, + double b2) + { + m_cv[m_curvatures.size() - 1] = 2.0 * b2; + } - inline void storeLast( double, - const QPointF&, const QPointF&, double, double b2 ) - { - m_cv[m_curvatures.size() - 1] = 2.0 * b2; - } + inline void storePrevious(int index, double, const QPointF &, const QPointF &, + double b1, double) + { + m_cv[index] = 2.0 * b1; + } - inline void storePrevious( int index, double, - const QPointF&, const QPointF&, double b1, double ) - { - m_cv[index] = 2.0 * b1; - } + inline void closeR() { m_cv[0] = m_cv[m_curvatures.size() - 1]; } - inline void closeR() - { - m_cv[0] = m_cv[m_curvatures.size() - 1]; - } + QVector curvatures() const { return m_curvatures; } - QVector< double > curvatures() const { return m_curvatures; } +private: + QVector m_curvatures; + double *m_cv; +}; - private: - QVector< double > m_curvatures; - double* m_cv; - }; +class SlopeStore +{ +public: + inline void setup(int size) + { + m_slopes.resize(size); + m_m = m_slopes.data(); + } - class SlopeStore - { - public: - inline void setup( int size ) - { - m_slopes.resize( size ); - m_m = m_slopes.data(); - } - - inline void storeFirst( double h, - const QPointF& p1, const QPointF& p2, double b1, double b2 ) - { - const double s = ( p2.y() - p1.y() ) / h; - m_m[0] = s - h * ( 2.0 * b1 + b2 ) / 3.0; + inline void storeFirst(double h, const QPointF &p1, const QPointF &p2, + double b1, double b2) + { + const double s = (p2.y() - p1.y()) / h; + m_m[0] = s - h * (2.0 * b1 + b2) / 3.0; #if KAHAN - m_sum.add( m_m[0] ); + m_sum.add(m_m[0]); #endif - } + } - inline void storeNext( int index, double h, - const QPointF& p1, const QPointF& p2, double b1, double b2 ) - { + inline void storeNext(int index, double h, const QPointF &p1, + const QPointF &p2, double b1, double b2) + { #if SLOPES_INCREMENTAL - Q_UNUSED( p1 ) - Q_UNUSED( p2 ) -#if KAHAN - m_sum.add( ( b1 + b2 ) * h ); - m_m[index] = m_sum.value(); + Q_UNUSED(p1) + Q_UNUSED(p2) +# if KAHAN + m_sum.add((b1 + b2) * h); + m_m[index] = m_sum.value(); +# else + m_m[index] = m_m[index - 1] + (b1 + b2) * h; +# endif #else - m_m[index] = m_m[index - 1] + ( b1 + b2 ) * h; + const double s = (p2.y() - p1.y()) / h; + m_m[index] = s + h * (b1 + 2.0 * b2) / 3.0; #endif -#else - const double s = ( p2.y() - p1.y() ) / h; - m_m[index] = s + h * ( b1 + 2.0 * b2 ) / 3.0; -#endif - } + } - inline void storeLast( double h, - const QPointF& p1, const QPointF& p2, double b1, double b2 ) - { - const double s = ( p2.y() - p1.y() ) / h; - m_m[m_slopes.size() - 1] = s + h * ( b1 + 2.0 * b2 ) / 3.0; + inline void storeLast(double h, const QPointF &p1, const QPointF &p2, + double b1, double b2) + { + const double s = (p2.y() - p1.y()) / h; + m_m[m_slopes.size() - 1] = s + h * (b1 + 2.0 * b2) / 3.0; #if KAHAN - m_sum.add( m_m[m_slopes.size() - 1] ); + m_sum.add(m_m[m_slopes.size() - 1]); #endif - } + } - inline void storePrevious( int index, double h, - const QPointF& p1, const QPointF& p2, double b1, double b2 ) - { + inline void storePrevious(int index, double h, const QPointF &p1, + const QPointF &p2, double b1, double b2) + { #if SLOPES_INCREMENTAL - Q_UNUSED( p1 ) - Q_UNUSED( p2 ) -#if KAHAN - m_sum.add( -( b1 + b2 ) * h ); - m_m[index] = m_sum.value(); -#else - m_m[index] = m_m[index + 1] - ( b1 + b2 ) * h; -#endif + Q_UNUSED(p1) + Q_UNUSED(p2) +# if KAHAN + m_sum.add(-(b1 + b2) * h); + m_m[index] = m_sum.value(); +# else + m_m[index] = m_m[index + 1] - (b1 + b2) * h; +# endif #else - const double s = ( p2.y() - p1.y() ) / h; - m_m[index] = s - h * ( 2.0 * b1 + b2 ) / 3.0; + const double s = (p2.y() - p1.y()) / h; + m_m[index] = s - h * (2.0 * b1 + b2) / 3.0; #endif - } + } - inline void closeR() - { - m_m[0] = m_m[m_slopes.size() - 1]; - } + inline void closeR() { m_m[0] = m_m[m_slopes.size() - 1]; } - QVector< double > slopes() const { return m_slopes; } + QVector slopes() const { return m_slopes; } - private: - QVector< double > m_slopes; - double* m_m; +private: + QVector m_slopes; + double *m_m; #if SLOPES_INCREMENTAL - KahanSum m_sum; + KahanSum m_sum; #endif - }; -} +}; +} // namespace QwtSplineCubicP namespace QwtSplineCubicP { - class Equation2 - { - public: - inline Equation2() - { - } +class Equation2 +{ +public: + inline Equation2() {} - inline Equation2( double p0, double q0, double r0 ): - p( p0 ), - q( q0 ), - r( r0 ) - { - } + inline Equation2(double p0, double q0, double r0) + : p(p0) + , q(q0) + , r(r0) + { + } - inline void setup( double p0, double q0, double r0 ) - { - p = p0; - q = q0; - r = r0; - } + inline void setup(double p0, double q0, double r0) + { + p = p0; + q = q0; + r = r0; + } - inline Equation2 normalized() const - { - Equation2 c; - c.p = 1.0; - c.q = q / p; - c.r = r / p; + inline Equation2 normalized() const + { + Equation2 c; + c.p = 1.0; + c.q = q / p; + c.r = r / p; - return c; - } + return c; + } - inline double resolved1( double x2 ) const - { - return ( r - q * x2 ) / p; - } + inline double resolved1(double x2) const { return (r - q * x2) / p; } - inline double resolved2( double x1 ) const - { - return ( r - p * x1 ) / q; - } + inline double resolved2(double x1) const { return (r - p * x1) / q; } - inline double resolved1( const Equation2& eq ) const - { - // find x1 - double k = q / eq.q; - return ( r - k * eq.r ) / ( p - k * eq.p ); - } + inline double resolved1(const Equation2 &eq) const + { + // find x1 + double k = q / eq.q; + return (r - k * eq.r) / (p - k * eq.p); + } - inline double resolved2( const Equation2& eq ) const - { - // find x2 - const double k = p / eq.p; - return ( r - k * eq.r ) / ( q - k * eq.q ); - } + inline double resolved2(const Equation2 &eq) const + { + // find x2 + const double k = p / eq.p; + return (r - k * eq.r) / (q - k * eq.q); + } - // p * x1 + q * x2 = r - double p, q, r; - }; + // p * x1 + q * x2 = r + double p, q, r; +}; - class Equation3 - { - public: - inline Equation3() - { - } +class Equation3 +{ +public: + inline Equation3() {} - inline Equation3( const QPointF& p1, const QPointF& p2, const QPointF& p3 ) - { - const double h1 = p2.x() - p1.x(); - const double s1 = ( p2.y() - p1.y() ) / h1; + inline Equation3(const QPointF &p1, const QPointF &p2, const QPointF &p3) + { + const double h1 = p2.x() - p1.x(); + const double s1 = (p2.y() - p1.y()) / h1; - const double h2 = p3.x() - p2.x(); - const double s2 = ( p3.y() - p2.y() ) / h2; + const double h2 = p3.x() - p2.x(); + const double s2 = (p3.y() - p2.y()) / h2; - p = h1; - q = 2 * ( h1 + h2 ); - u = h2; - r = 3 * ( s2 - s1 ); - } + p = h1; + q = 2 * (h1 + h2); + u = h2; + r = 3 * (s2 - s1); + } - inline Equation3( double cp, double cq, double du, double dr ): - p( cp ), - q( cq ), - u( du ), - r( dr ) - { - } + inline Equation3(double cp, double cq, double du, double dr) + : p(cp) + , q(cq) + , u(du) + , r(dr) + { + } - inline bool operator==( const Equation3& c ) const - { - return ( p == c.p ) && ( q == c.q ) && - ( u == c.u ) && ( r == c.r ); - } + inline bool operator==(const Equation3 &c) const + { + return (p == c.p) && (q == c.q) && (u == c.u) && (r == c.r); + } - inline void setup( double cp, double cq, double du, double dr ) - { - p = cp; - q = cq; - u = du; - r = dr; - } + inline void setup(double cp, double cq, double du, double dr) + { + p = cp; + q = cq; + u = du; + r = dr; + } - inline Equation3 normalized() const - { - Equation3 c; - c.p = 1.0; - c.q = q / p; - c.u = u / p; - c.r = r / p; + inline Equation3 normalized() const + { + Equation3 c; + c.p = 1.0; + c.q = q / p; + c.u = u / p; + c.r = r / p; - return c; - } + return c; + } - inline Equation2 substituted1( const Equation3& eq ) const - { - // eliminate x1 - const double k = p / eq.p; - return Equation2( q - k * eq.q, u - k * eq.u, r - k * eq.r ); - } + inline Equation2 substituted1(const Equation3 &eq) const + { + // eliminate x1 + const double k = p / eq.p; + return Equation2(q - k * eq.q, u - k * eq.u, r - k * eq.r); + } - inline Equation2 substituted2( const Equation3& eq ) const - { - // eliminate x2 + inline Equation2 substituted2(const Equation3 &eq) const + { + // eliminate x2 - const double k = q / eq.q; - return Equation2( p - k * eq.p, u - k * eq.u, r - k * eq.r ); - } + const double k = q / eq.q; + return Equation2(p - k * eq.p, u - k * eq.u, r - k * eq.r); + } - inline Equation2 substituted3( const Equation3& eq ) const - { - // eliminate x3 + inline Equation2 substituted3(const Equation3 &eq) const + { + // eliminate x3 - const double k = u / eq.u; - return Equation2( p - k * eq.p, q - k * eq.q, r - k * eq.r ); - } + const double k = u / eq.u; + return Equation2(p - k * eq.p, q - k * eq.q, r - k * eq.r); + } - inline Equation2 substituted1( const Equation2& eq ) const - { - // eliminate x1 - const double k = p / eq.p; - return Equation2( q - k * eq.q, u, r - k * eq.r ); - } + inline Equation2 substituted1(const Equation2 &eq) const + { + // eliminate x1 + const double k = p / eq.p; + return Equation2(q - k * eq.q, u, r - k * eq.r); + } - inline Equation2 substituted3( const Equation2& eq ) const - { - // eliminate x3 + inline Equation2 substituted3(const Equation2 &eq) const + { + // eliminate x3 - const double k = u / eq.q; - return Equation2( p, q - k * eq.p, r - k * eq.r ); - } + const double k = u / eq.q; + return Equation2(p, q - k * eq.p, r - k * eq.r); + } + inline double resolved1(double x2, double x3) const + { + return (r - q * x2 - u * x3) / p; + } - inline double resolved1( double x2, double x3 ) const - { - return ( r - q * x2 - u * x3 ) / p; - } + inline double resolved2(double x1, double x3) const + { + return (r - u * x3 - p * x1) / q; + } - inline double resolved2( double x1, double x3 ) const - { - return ( r - u * x3 - p * x1 ) / q; - } + inline double resolved3(double x1, double x2) const + { + return (r - p * x1 - q * x2) / u; + } - inline double resolved3( double x1, double x2 ) const - { - return ( r - p * x1 - q * x2 ) / u; - } - - // p * x1 + q * x2 + u * x3 = r - double p, q, u, r; - }; -} + // p * x1 + q * x2 + u * x3 = r + double p, q, u, r; +}; +} // namespace QwtSplineCubicP #if 0 static QDebug operator<<( QDebug debug, const QwtSplineCubicP::Equation2& eq ) @@ -389,570 +364,550 @@ static QDebug operator<<( QDebug debug, const QwtSplineCubicP::Equation3& eq ) namespace QwtSplineCubicP { - template< class T > - class EquationSystem - { - public: - void setStartCondition( double p, double q, double u, double r ) - { - m_conditionsEQ[0].setup( p, q, u, r ); - } - - void setEndCondition( double p, double q, double u, double r ) - { - m_conditionsEQ[1].setup( p, q, u, r ); - } - - const T& store() const - { - return m_store; - } - - void resolve( const QPolygonF& p ) - { - const int n = p.size(); - if ( n < 3 ) - return; - - if ( m_conditionsEQ[0].p == 0.0 || - ( m_conditionsEQ[0].q == 0.0 && m_conditionsEQ[0].u != 0.0 ) ) - { - return; - } - - if ( m_conditionsEQ[1].u == 0.0 || - ( m_conditionsEQ[1].q == 0.0 && m_conditionsEQ[1].p != 0.0 ) ) - { - return; - } - - const double h0 = p[1].x() - p[0].x(); - const double h1 = p[2].x() - p[1].x(); - const double hn = p[n - 1].x() - p[n - 2].x(); - - m_store.setup( n ); - - - if ( n == 3 ) - { - // For certain conditions the first/last point does not - // necessarily meet the spline equation and we would - // have many solutions. In this case we resolve using - // the spline equation - as for all other conditions. - - const Equation3 eqSpline0( p[0], p[1], p[2] ); // ??? - const Equation2 eq0 = m_conditionsEQ[0].substituted1( eqSpline0 ); - - // The equation system can be solved without substitution - // from the start/end conditions and eqSpline0 ( = eqSplineN ). - - double b1; - - if ( m_conditionsEQ[0].normalized() == m_conditionsEQ[1].normalized() ) - { - // When we have 3 points only and start/end conditions - // for 3 points mean the same condition the system - // is under-determined and has many solutions. - // We chose b1 = 0.0 - - b1 = 0.0; - } - else - { - const Equation2 eq = m_conditionsEQ[1].substituted1( eqSpline0 ); - b1 = eq0.resolved1( eq ); - } - - const double b2 = eq0.resolved2( b1 ); - const double b0 = eqSpline0.resolved1( b1, b2 ); - - m_store.storeFirst( h0, p[0], p[1], b0, b1 ); - m_store.storeNext( 1, h0, p[0], p[1], b0, b1 ); - m_store.storeNext( 2, h1, p[1], p[2], b1, b2 ); - - return; - } - - const Equation3 eqSplineN( p[n - 3], p[n - 2], p[n - 1] ); - const Equation2 eqN = m_conditionsEQ[1].substituted3( eqSplineN ); - - Equation2 eq = eqN; - if ( n > 4 ) - { - const Equation3 eqSplineR( p[n - 4], p[n - 3], p[n - 2] ); - eq = eqSplineR.substituted3( eq ); - eq = substituteSpline( p, eq ); - } - - const Equation3 eqSpline0( p[0], p[1], p[2] ); - - double b0, b1; - if ( m_conditionsEQ[0].u == 0.0 ) - { - eq = eqSpline0.substituted3( eq ); - - const Equation3& eq0 = m_conditionsEQ[0]; - b0 = Equation2( eq0.p, eq0.q, eq0.r ).resolved1( eq ); - b1 = eq.resolved2( b0 ); - } - else - { - const Equation2 eqX = m_conditionsEQ[0].substituted3( eq ); - const Equation2 eqY = eqSpline0.substituted3( eq ); - - b0 = eqY.resolved1( eqX ); - b1 = eqY.resolved2( b0 ); - } - - m_store.storeFirst( h0, p[0], p[1], b0, b1 ); - m_store.storeNext( 1, h0, p[0], p[1], b0, b1 ); - - const double bn2 = resolveSpline( p, b1 ); - - const double bn1 = eqN.resolved2( bn2 ); - const double bn0 = m_conditionsEQ[1].resolved3( bn2, bn1 ); - - const double hx = p[n - 2].x() - p[n - 3].x(); - m_store.storeNext( n - 2, hx, p[n - 3], p[n - 2], bn2, bn1 ); - m_store.storeNext( n - 1, hn, p[n - 2], p[n - 1], bn1, bn0 ); - } - - private: - Equation2 substituteSpline( const QPolygonF& points, const Equation2& eq ) - { - const int n = points.size(); - - m_eq.resize( n - 2 ); - m_eq[n - 3] = eq; - - // eq[i].resolved2( b[i-1] ) => b[i] - - double slope2 = ( points[n - 3].y() - points[n - 4].y() ) / eq.p; - - for ( int i = n - 4; i > 1; i-- ) - { - const Equation2& eq2 = m_eq[i + 1]; - Equation2& eq1 = m_eq[i]; - - eq1.p = points[i].x() - points[i - 1].x(); - const double slope1 = ( points[i].y() - points[i - 1].y() ) / eq1.p; - - const double v = eq2.p / eq2.q; - - eq1.q = 2.0 * ( eq1.p + eq2.p ) - v * eq2.p; - eq1.r = 3.0 * ( slope2 - slope1 ) - v * eq2.r; - - slope2 = slope1; - } - - return m_eq[2]; - } - - double resolveSpline( const QPolygonF& points, double b1 ) - { - const int n = points.size(); - const QPointF* p = points.constData(); - - for ( int i = 2; i < n - 2; i++ ) - { - // eq[i].resolved2( b[i-1] ) => b[i] - const double b2 = m_eq[i].resolved2( b1 ); - m_store.storeNext( i, m_eq[i].p, p[i - 1], p[i], b1, b2 ); - - b1 = b2; - } - - return b1; - } - - private: - Equation3 m_conditionsEQ[2]; - QVector< Equation2 > m_eq; - T m_store; - }; - - template< class T > - class EquationSystem2 - { - public: - const T& store() const - { - return m_store; - } - - void resolve( const QPolygonF& p ) - { - const int n = p.size(); - - if ( p[n - 1].y() != p[0].y() ) - { - // TODO ??? - } - - const double h0 = p[1].x() - p[0].x(); - const double s0 = ( p[1].y() - p[0].y() ) / h0; - - if ( n == 3 ) - { - const double h1 = p[2].x() - p[1].x(); - const double s1 = ( p[2].y() - p[1].y() ) / h1; - - const double b = 3.0 * ( s0 - s1 ) / ( h0 + h1 ); - - m_store.setup( 3 ); - m_store.storeLast( h1, p[1], p[2], -b, b ); - m_store.storePrevious( 1, h1, p[1], p[2], -b, b ); - m_store.closeR(); - - return; - } - - const double hn = p[n - 1].x() - p[n - 2].x(); - - Equation2 eqn, eqX; - substitute( p, eqn, eqX ); - - const double b0 = eqn.resolved2( eqX ); - const double bn = eqn.resolved1( b0 ); - - m_store.setup( n ); - m_store.storeLast( hn, p[n - 2], p[n - 1], bn, b0 ); - m_store.storePrevious( n - 2, hn, p[n - 2], p[n - 1], bn, b0 ); - - resolveSpline( p, b0, bn ); - - m_store.closeR(); - } - - private: - - void substitute( const QPolygonF& points, Equation2& eqn, Equation2& eqX ) - { - const int n = points.size(); - - const double hn = points[n - 1].x() - points[n - 2].x(); - - const Equation3 eqSpline0( points[0], points[1], points[2] ); - const Equation3 eqSplineN( - QPointF( points[0].x() - hn, points[n - 2].y() ), points[0], points[1] ); - - m_eq.resize( n - 1 ); - - double dq = 0; - double dr = 0; - - m_eq[1] = eqSpline0; - - double slope1 = ( points[2].y() - points[1].y() ) / m_eq[1].u; - - // a) p1 * b[0] + q1 * b[1] + u1 * b[2] = r1 - // b) p2 * b[n-2] + q2 * b[0] + u2 * b[1] = r2 - // c) pi * b[i-1] + qi * b[i] + ui * b[i+1] = ri - // - // Using c) we can substitute b[i] ( starting from 2 ) by b[i+1] - // until we reach n-1. As we know, that b[0] == b[n-1] we found - // an equation where only 2 coefficients ( for b[n-2], b[0] ) are left unknown. - // Each step we have an equation that depends on b[0], b[i] and b[i+1] - // that can also be used to substitute b[i] in b). Ding so we end up with another - // equation depending on b[n-2], b[0] only. - // Finally 2 equations with 2 coefficients can be solved. - - for ( int i = 2; i < n - 1; i++ ) - { - const Equation3& eq1 = m_eq[i - 1]; - Equation3& eq2 = m_eq[i]; - - dq += eq1.p * eq1.p / eq1.q; - dr += eq1.p * eq1.r / eq1.q; - - eq2.u = points[i + 1].x() - points[i].x(); - const double slope2 = ( points[i + 1].y() - points[i].y() ) / eq2.u; - - const double k = eq1.u / eq1.q; - - eq2.p = -eq1.p * k; - eq2.q = 2.0 * ( eq1.u + eq2.u ) - eq1.u * k; - eq2.r = 3.0 * ( slope2 - slope1 ) - eq1.r * k; - - slope1 = slope2; - } - - - // b[0] * m_p[n-2] + b[n-2] * m_q[n-2] + b[n-1] * pN = m_r[n-2] - eqn.setup( m_eq[n - 2].q, m_eq[n - 2].p + eqSplineN.p, m_eq[n - 2].r ); - - // b[n-2] * pN + b[0] * ( qN - dq ) + b[n-2] * m_p[n-2] = rN - dr - eqX.setup( m_eq[n - 2].p + eqSplineN.p, eqSplineN.q - dq, eqSplineN.r - dr ); - } - - void resolveSpline( const QPolygonF& points, double b0, double bi ) - { - const int n = points.size(); - - for ( int i = n - 3; i >= 1; i-- ) - { - const Equation3& eq = m_eq[i]; - - const double b = eq.resolved2( b0, bi ); - m_store.storePrevious( i, eq.u, points[i], points[i + 1], b, bi ); - - bi = b; - } - } - - void resolveSpline2( const QPolygonF& points, - double b0, double bi, QVector< double >& m ) - { - const int n = points.size(); - - bi = m_eq[0].resolved3( b0, bi ); - - for ( int i = 1; i < n - 2; i++ ) - { - const Equation3& eq = m_eq[i]; - - const double b = eq.resolved3( b0, bi ); - m[i + 1] = m[i] + ( b + bi ) * m_eq[i].u; - - bi = b; - } - } - - void resolveSpline3( const QPolygonF& points, - double b0, double b1, QVector< double >& m ) - { - const int n = points.size(); - - double h0 = ( points[1].x() - points[0].x() ); - double s0 = ( points[1].y() - points[0].y() ) / h0; - - m[1] = m[0] + ( b0 + b1 ) * h0; - - for ( int i = 1; i < n - 1; i++ ) - { - const double h1 = ( points[i + 1].x() - points[i].x() ); - const double s1 = ( points[i + 1].y() - points[i].y() ) / h1; - - const double r = 3.0 * ( s1 - s0 ); - - const double b2 = ( r - h0 * b0 - 2.0 * ( h0 + h1 ) * b1 ) / h1; - m[i + 1] = m[i] + ( b1 + b2 ) * h1; - - h0 = h1; - s0 = s1; - b0 = b1; - b1 = b2; - } - } - - void resolveSpline4( const QPolygonF& points, - double b2, double b1, QVector< double >& m ) - { - const int n = points.size(); - - double h2 = ( points[n - 1].x() - points[n - 2].x() ); - double s2 = ( points[n - 1].y() - points[n - 2].y() ) / h2; - - for ( int i = n - 2; i > 1; i-- ) - { - const double h1 = ( points[i].x() - points[i - 1].x() ); - const double s1 = ( points[i].y() - points[i - 1].y() ) / h1; - - const double r = 3.0 * ( s2 - s1 ); - const double k = 2.0 * ( h1 + h2 ); - - const double b0 = ( r - h2 * b2 - k * b1 ) / h1; - - m[i - 1] = m[i] - ( b0 + b1 ) * h1; - - h2 = h1; - s2 = s1; - b2 = b1; - b1 = b0; - } - } - - public: - QVector< Equation3 > m_eq; - T m_store; - }; -} - -static void qwtSetupEndEquations( - int conditionBegin, double valueBegin, int conditionEnd, double valueEnd, - const QPolygonF& points, QwtSplineCubicP::Equation3 eq[2] ) +template +class EquationSystem { +public: + void setStartCondition(double p, double q, double u, double r) + { + m_conditionsEQ[0].setup(p, q, u, r); + } + + void setEndCondition(double p, double q, double u, double r) + { + m_conditionsEQ[1].setup(p, q, u, r); + } + + const T &store() const { return m_store; } + + void resolve(const QPolygonF &p) + { + const int n = p.size(); + if (n < 3) + return; + + if (m_conditionsEQ[0].p == 0.0 + || (m_conditionsEQ[0].q == 0.0 && m_conditionsEQ[0].u != 0.0)) + { + return; + } + + if (m_conditionsEQ[1].u == 0.0 + || (m_conditionsEQ[1].q == 0.0 && m_conditionsEQ[1].p != 0.0)) + { + return; + } + + const double h0 = p[1].x() - p[0].x(); + const double h1 = p[2].x() - p[1].x(); + const double hn = p[n - 1].x() - p[n - 2].x(); + + m_store.setup(n); + + if (n == 3) + { + // For certain conditions the first/last point does not + // necessarily meet the spline equation and we would + // have many solutions. In this case we resolve using + // the spline equation - as for all other conditions. + + const Equation3 eqSpline0(p[0], p[1], p[2]); // ??? + const Equation2 eq0 = m_conditionsEQ[0].substituted1(eqSpline0); + + // The equation system can be solved without substitution + // from the start/end conditions and eqSpline0 ( = eqSplineN ). + + double b1; + + if (m_conditionsEQ[0].normalized() == m_conditionsEQ[1].normalized()) + { + // When we have 3 points only and start/end conditions + // for 3 points mean the same condition the system + // is under-determined and has many solutions. + // We chose b1 = 0.0 + + b1 = 0.0; + } + else + { + const Equation2 eq = m_conditionsEQ[1].substituted1(eqSpline0); + b1 = eq0.resolved1(eq); + } + + const double b2 = eq0.resolved2(b1); + const double b0 = eqSpline0.resolved1(b1, b2); + + m_store.storeFirst(h0, p[0], p[1], b0, b1); + m_store.storeNext(1, h0, p[0], p[1], b0, b1); + m_store.storeNext(2, h1, p[1], p[2], b1, b2); + + return; + } + + const Equation3 eqSplineN(p[n - 3], p[n - 2], p[n - 1]); + const Equation2 eqN = m_conditionsEQ[1].substituted3(eqSplineN); + + Equation2 eq = eqN; + if (n > 4) + { + const Equation3 eqSplineR(p[n - 4], p[n - 3], p[n - 2]); + eq = eqSplineR.substituted3(eq); + eq = substituteSpline(p, eq); + } + + const Equation3 eqSpline0(p[0], p[1], p[2]); + + double b0, b1; + if (m_conditionsEQ[0].u == 0.0) + { + eq = eqSpline0.substituted3(eq); + + const Equation3 &eq0 = m_conditionsEQ[0]; + b0 = Equation2(eq0.p, eq0.q, eq0.r).resolved1(eq); + b1 = eq.resolved2(b0); + } + else + { + const Equation2 eqX = m_conditionsEQ[0].substituted3(eq); + const Equation2 eqY = eqSpline0.substituted3(eq); + + b0 = eqY.resolved1(eqX); + b1 = eqY.resolved2(b0); + } + + m_store.storeFirst(h0, p[0], p[1], b0, b1); + m_store.storeNext(1, h0, p[0], p[1], b0, b1); + + const double bn2 = resolveSpline(p, b1); + + const double bn1 = eqN.resolved2(bn2); + const double bn0 = m_conditionsEQ[1].resolved3(bn2, bn1); + + const double hx = p[n - 2].x() - p[n - 3].x(); + m_store.storeNext(n - 2, hx, p[n - 3], p[n - 2], bn2, bn1); + m_store.storeNext(n - 1, hn, p[n - 2], p[n - 1], bn1, bn0); + } + +private: + Equation2 substituteSpline(const QPolygonF &points, const Equation2 &eq) + { const int n = points.size(); - const double h0 = points[1].x() - points[0].x(); - const double s0 = ( points[1].y() - points[0].y() ) / h0; + m_eq.resize(n - 2); + m_eq[n - 3] = eq; - const double hn = ( points[n - 1].x() - points[n - 2].x() ); - const double sn = ( points[n - 1].y() - points[n - 2].y() ) / hn; + // eq[i].resolved2( b[i-1] ) => b[i] - switch( conditionBegin ) + double slope2 = (points[n - 3].y() - points[n - 4].y()) / eq.p; + + for (int i = n - 4; i > 1; i--) { - case QwtSpline::Clamped1: - { - // first derivative at end points given + const Equation2 &eq2 = m_eq[i + 1]; + Equation2 &eq1 = m_eq[i]; - // 3 * a1 * h + b1 = b2 - // a1 * h * h + b1 * h + c1 = s + eq1.p = points[i].x() - points[i - 1].x(); + const double slope1 = (points[i].y() - points[i - 1].y()) / eq1.p; - // c1 = slopeBegin - // => b1 * ( 2 * h / 3.0 ) + b2 * ( h / 3.0 ) = s - slopeBegin + const double v = eq2.p / eq2.q; - // c2 = slopeEnd - // => b1 * ( 1.0 / 3.0 ) + b2 * ( 2.0 / 3.0 ) = ( slopeEnd - s ) / h; + eq1.q = 2.0 * (eq1.p + eq2.p) - v * eq2.p; + eq1.r = 3.0 * (slope2 - slope1) - v * eq2.r; - eq[0].setup( 2 * h0 / 3.0, h0 / 3.0, 0.0, s0 - valueBegin ); - break; - } - case QwtSpline::Clamped2: - { - // second derivative at end points given - - // b0 = 0.5 * cvStart - // => b0 * 1.0 + b1 * 0.0 = 0.5 * cvStart - - // b1 = 0.5 * cvEnd - // => b0 * 0.0 + b1 * 1.0 = 0.5 * cvEnd - - eq[0].setup( 1.0, 0.0, 0.0, 0.5 * valueBegin ); - break; - } - case QwtSpline::Clamped3: - { - // third derivative at end point given - - // 3 * a * h0 + b[0] = b[1] - - // a = marg_0 / 6.0 - // => b[0] * 1.0 + b[1] * ( -1.0 ) = -0.5 * v0 * h0 - - // a = marg_n / 6.0 - // => b[n-2] * 1.0 + b[n-1] * ( -1.0 ) = -0.5 * v1 * h5 - - eq[0].setup( 1.0, -1.0, 0.0, -0.5 * valueBegin * h0 ); - - break; - } - case QwtSpline::LinearRunout: - { - const double r0 = qBound( 0.0, valueBegin, 1.0 ); - if ( r0 == 0.0 ) - { - // clamping s0 - eq[0].setup( 2 * h0 / 3.0, h0 / 3.0, 0.0, 0.0 ); - } - else - { - eq[0].setup( 1.0 + 2.0 / r0, 2.0 + 1.0 / r0, 0.0, 0.0 ); - } - break; - } - case QwtSplineC2::NotAKnot: - case QwtSplineC2::CubicRunout: - { - // building one cubic curve from 3 points - - double v0; - - if ( conditionBegin == QwtSplineC2::CubicRunout ) - { - // first/last point are the endpoints of the curve - - // b0 = 2 * b1 - b2 - // => 1.0 * b0 - 2 * b1 + 1.0 * b2 = 0.0 - - v0 = 1.0; - } - else - { - // first/last points are on the curve, - // the imaginary endpoints have the same distance as h0/hn - - v0 = h0 / ( points[2].x() - points[1].x() ); - } - - eq[0].setup( 1.0, -( 1.0 + v0 ), v0, 0.0 ); - break; - } - default: - { - // a natural spline, where the - // second derivative at end points set to 0.0 - eq[0].setup( 1.0, 0.0, 0.0, 0.0 ); - break; - } + slope2 = slope1; } - switch( conditionEnd ) + return m_eq[2]; + } + + double resolveSpline(const QPolygonF &points, double b1) + { + const int n = points.size(); + const QPointF *p = points.constData(); + + for (int i = 2; i < n - 2; i++) { - case QwtSpline::Clamped1: - { - // first derivative at end points given - eq[1].setup( 0.0, 1.0 / 3.0 * hn, 2.0 / 3.0 * hn, valueEnd - sn ); - break; - } - case QwtSpline::Clamped2: - { - // second derivative at end points given - eq[1].setup( 0.0, 0.0, 1.0, 0.5 * valueEnd ); - break; - } - case QwtSpline::Clamped3: - { - // third derivative at end point given - eq[1].setup( 0.0, 1.0, -1.0, -0.5 * valueEnd * hn ); - break; - } - case QwtSpline::LinearRunout: - { - const double rn = qBound( 0.0, valueEnd, 1.0 ); - if ( rn == 0.0 ) - { - // clamping sn - eq[1].setup( 0.0, 1.0 / 3.0 * hn, 2.0 / 3.0 * hn, 0.0 ); - } - else - { - eq[1].setup( 0.0, 2.0 + 1.0 / rn, 1.0 + 2.0 / rn, 0.0 ); - } + // eq[i].resolved2( b[i-1] ) => b[i] + const double b2 = m_eq[i].resolved2(b1); + m_store.storeNext(i, m_eq[i].p, p[i - 1], p[i], b1, b2); - break; - } - case QwtSplineC2::NotAKnot: - case QwtSplineC2::CubicRunout: - { - // building one cubic curve from 3 points - - double vn; - - if ( conditionEnd == QwtSplineC2::CubicRunout ) - { - // last point is the endpoints of the curve - vn = 1.0; - } - else - { - // last points on the curve, - // the imaginary endpoints have the same distance as hn - - vn = hn / ( points[n - 2].x() - points[n - 3].x() ); - } - - eq[1].setup( vn, -( 1.0 + vn ), 1.0, 0.0 ); - break; - } - default: - { - // a natural spline, where the - // second derivative at end points set to 0.0 - eq[1].setup( 0.0, 0.0, 1.0, 0.0 ); - break; - } + b1 = b2; } + + return b1; + } + +private: + Equation3 m_conditionsEQ[2]; + QVector m_eq; + T m_store; +}; + +template +class EquationSystem2 +{ +public: + const T &store() const { return m_store; } + + void resolve(const QPolygonF &p) + { + const int n = p.size(); + + if (p[n - 1].y() != p[0].y()) + { + // TODO ??? + } + + const double h0 = p[1].x() - p[0].x(); + const double s0 = (p[1].y() - p[0].y()) / h0; + + if (n == 3) + { + const double h1 = p[2].x() - p[1].x(); + const double s1 = (p[2].y() - p[1].y()) / h1; + + const double b = 3.0 * (s0 - s1) / (h0 + h1); + + m_store.setup(3); + m_store.storeLast(h1, p[1], p[2], -b, b); + m_store.storePrevious(1, h1, p[1], p[2], -b, b); + m_store.closeR(); + + return; + } + + const double hn = p[n - 1].x() - p[n - 2].x(); + + Equation2 eqn, eqX; + substitute(p, eqn, eqX); + + const double b0 = eqn.resolved2(eqX); + const double bn = eqn.resolved1(b0); + + m_store.setup(n); + m_store.storeLast(hn, p[n - 2], p[n - 1], bn, b0); + m_store.storePrevious(n - 2, hn, p[n - 2], p[n - 1], bn, b0); + + resolveSpline(p, b0, bn); + + m_store.closeR(); + } + +private: + void substitute(const QPolygonF &points, Equation2 &eqn, Equation2 &eqX) + { + const int n = points.size(); + + const double hn = points[n - 1].x() - points[n - 2].x(); + + const Equation3 eqSpline0(points[0], points[1], points[2]); + const Equation3 eqSplineN(QPointF(points[0].x() - hn, points[n - 2].y()), + points[0], points[1]); + + m_eq.resize(n - 1); + + double dq = 0; + double dr = 0; + + m_eq[1] = eqSpline0; + + double slope1 = (points[2].y() - points[1].y()) / m_eq[1].u; + + // a) p1 * b[0] + q1 * b[1] + u1 * b[2] = r1 + // b) p2 * b[n-2] + q2 * b[0] + u2 * b[1] = r2 + // c) pi * b[i-1] + qi * b[i] + ui * b[i+1] = ri + // + // Using c) we can substitute b[i] ( starting from 2 ) by b[i+1] + // until we reach n-1. As we know, that b[0] == b[n-1] we found + // an equation where only 2 coefficients ( for b[n-2], b[0] ) are left + // unknown. Each step we have an equation that depends on b[0], b[i] and + // b[i+1] that can also be used to substitute b[i] in b). Ding so we end up + // with another equation depending on b[n-2], b[0] only. Finally 2 equations + // with 2 coefficients can be solved. + + for (int i = 2; i < n - 1; i++) + { + const Equation3 &eq1 = m_eq[i - 1]; + Equation3 &eq2 = m_eq[i]; + + dq += eq1.p * eq1.p / eq1.q; + dr += eq1.p * eq1.r / eq1.q; + + eq2.u = points[i + 1].x() - points[i].x(); + const double slope2 = (points[i + 1].y() - points[i].y()) / eq2.u; + + const double k = eq1.u / eq1.q; + + eq2.p = -eq1.p * k; + eq2.q = 2.0 * (eq1.u + eq2.u) - eq1.u * k; + eq2.r = 3.0 * (slope2 - slope1) - eq1.r * k; + + slope1 = slope2; + } + + // b[0] * m_p[n-2] + b[n-2] * m_q[n-2] + b[n-1] * pN = m_r[n-2] + eqn.setup(m_eq[n - 2].q, m_eq[n - 2].p + eqSplineN.p, m_eq[n - 2].r); + + // b[n-2] * pN + b[0] * ( qN - dq ) + b[n-2] * m_p[n-2] = rN - dr + eqX.setup(m_eq[n - 2].p + eqSplineN.p, eqSplineN.q - dq, eqSplineN.r - dr); + } + + void resolveSpline(const QPolygonF &points, double b0, double bi) + { + const int n = points.size(); + + for (int i = n - 3; i >= 1; i--) + { + const Equation3 &eq = m_eq[i]; + + const double b = eq.resolved2(b0, bi); + m_store.storePrevious(i, eq.u, points[i], points[i + 1], b, bi); + + bi = b; + } + } + + void resolveSpline2(const QPolygonF &points, double b0, double bi, + QVector &m) + { + const int n = points.size(); + + bi = m_eq[0].resolved3(b0, bi); + + for (int i = 1; i < n - 2; i++) + { + const Equation3 &eq = m_eq[i]; + + const double b = eq.resolved3(b0, bi); + m[i + 1] = m[i] + (b + bi) * m_eq[i].u; + + bi = b; + } + } + + void resolveSpline3(const QPolygonF &points, double b0, double b1, + QVector &m) + { + const int n = points.size(); + + double h0 = (points[1].x() - points[0].x()); + double s0 = (points[1].y() - points[0].y()) / h0; + + m[1] = m[0] + (b0 + b1) * h0; + + for (int i = 1; i < n - 1; i++) + { + const double h1 = (points[i + 1].x() - points[i].x()); + const double s1 = (points[i + 1].y() - points[i].y()) / h1; + + const double r = 3.0 * (s1 - s0); + + const double b2 = (r - h0 * b0 - 2.0 * (h0 + h1) * b1) / h1; + m[i + 1] = m[i] + (b1 + b2) * h1; + + h0 = h1; + s0 = s1; + b0 = b1; + b1 = b2; + } + } + + void resolveSpline4(const QPolygonF &points, double b2, double b1, + QVector &m) + { + const int n = points.size(); + + double h2 = (points[n - 1].x() - points[n - 2].x()); + double s2 = (points[n - 1].y() - points[n - 2].y()) / h2; + + for (int i = n - 2; i > 1; i--) + { + const double h1 = (points[i].x() - points[i - 1].x()); + const double s1 = (points[i].y() - points[i - 1].y()) / h1; + + const double r = 3.0 * (s2 - s1); + const double k = 2.0 * (h1 + h2); + + const double b0 = (r - h2 * b2 - k * b1) / h1; + + m[i - 1] = m[i] - (b0 + b1) * h1; + + h2 = h1; + s2 = s1; + b2 = b1; + b1 = b0; + } + } + +public: + QVector m_eq; + T m_store; +}; +} // namespace QwtSplineCubicP + +static void qwtSetupEndEquations(int conditionBegin, double valueBegin, + int conditionEnd, double valueEnd, + const QPolygonF &points, + QwtSplineCubicP::Equation3 eq[2]) +{ + const int n = points.size(); + + const double h0 = points[1].x() - points[0].x(); + const double s0 = (points[1].y() - points[0].y()) / h0; + + const double hn = (points[n - 1].x() - points[n - 2].x()); + const double sn = (points[n - 1].y() - points[n - 2].y()) / hn; + + switch (conditionBegin) + { + case QwtSpline::Clamped1: { + // first derivative at end points given + + // 3 * a1 * h + b1 = b2 + // a1 * h * h + b1 * h + c1 = s + + // c1 = slopeBegin + // => b1 * ( 2 * h / 3.0 ) + b2 * ( h / 3.0 ) = s - slopeBegin + + // c2 = slopeEnd + // => b1 * ( 1.0 / 3.0 ) + b2 * ( 2.0 / 3.0 ) = ( slopeEnd - s ) / h; + + eq[0].setup(2 * h0 / 3.0, h0 / 3.0, 0.0, s0 - valueBegin); + break; + } + case QwtSpline::Clamped2: { + // second derivative at end points given + + // b0 = 0.5 * cvStart + // => b0 * 1.0 + b1 * 0.0 = 0.5 * cvStart + + // b1 = 0.5 * cvEnd + // => b0 * 0.0 + b1 * 1.0 = 0.5 * cvEnd + + eq[0].setup(1.0, 0.0, 0.0, 0.5 * valueBegin); + break; + } + case QwtSpline::Clamped3: { + // third derivative at end point given + + // 3 * a * h0 + b[0] = b[1] + + // a = marg_0 / 6.0 + // => b[0] * 1.0 + b[1] * ( -1.0 ) = -0.5 * v0 * h0 + + // a = marg_n / 6.0 + // => b[n-2] * 1.0 + b[n-1] * ( -1.0 ) = -0.5 * v1 * h5 + + eq[0].setup(1.0, -1.0, 0.0, -0.5 * valueBegin * h0); + + break; + } + case QwtSpline::LinearRunout: { + const double r0 = qBound(0.0, valueBegin, 1.0); + if (r0 == 0.0) + { + // clamping s0 + eq[0].setup(2 * h0 / 3.0, h0 / 3.0, 0.0, 0.0); + } + else + { + eq[0].setup(1.0 + 2.0 / r0, 2.0 + 1.0 / r0, 0.0, 0.0); + } + break; + } + case QwtSplineC2::NotAKnot: + case QwtSplineC2::CubicRunout: { + // building one cubic curve from 3 points + + double v0; + + if (conditionBegin == QwtSplineC2::CubicRunout) + { + // first/last point are the endpoints of the curve + + // b0 = 2 * b1 - b2 + // => 1.0 * b0 - 2 * b1 + 1.0 * b2 = 0.0 + + v0 = 1.0; + } + else + { + // first/last points are on the curve, + // the imaginary endpoints have the same distance as h0/hn + + v0 = h0 / (points[2].x() - points[1].x()); + } + + eq[0].setup(1.0, -(1.0 + v0), v0, 0.0); + break; + } + default: { + // a natural spline, where the + // second derivative at end points set to 0.0 + eq[0].setup(1.0, 0.0, 0.0, 0.0); + break; + } + } + + switch (conditionEnd) + { + case QwtSpline::Clamped1: { + // first derivative at end points given + eq[1].setup(0.0, 1.0 / 3.0 * hn, 2.0 / 3.0 * hn, valueEnd - sn); + break; + } + case QwtSpline::Clamped2: { + // second derivative at end points given + eq[1].setup(0.0, 0.0, 1.0, 0.5 * valueEnd); + break; + } + case QwtSpline::Clamped3: { + // third derivative at end point given + eq[1].setup(0.0, 1.0, -1.0, -0.5 * valueEnd * hn); + break; + } + case QwtSpline::LinearRunout: { + const double rn = qBound(0.0, valueEnd, 1.0); + if (rn == 0.0) + { + // clamping sn + eq[1].setup(0.0, 1.0 / 3.0 * hn, 2.0 / 3.0 * hn, 0.0); + } + else + { + eq[1].setup(0.0, 2.0 + 1.0 / rn, 1.0 + 2.0 / rn, 0.0); + } + + break; + } + case QwtSplineC2::NotAKnot: + case QwtSplineC2::CubicRunout: { + // building one cubic curve from 3 points + + double vn; + + if (conditionEnd == QwtSplineC2::CubicRunout) + { + // last point is the endpoints of the curve + vn = 1.0; + } + else + { + // last points on the curve, + // the imaginary endpoints have the same distance as hn + + vn = hn / (points[n - 2].x() - points[n - 3].x()); + } + + eq[1].setup(vn, -(1.0 + vn), 1.0, 0.0); + break; + } + default: { + // a natural spline, where the + // second derivative at end points set to 0.0 + eq[1].setup(0.0, 0.0, 1.0, 0.0); + break; + } + } } class QwtSplineCubic::PrivateData @@ -964,22 +919,20 @@ class QwtSplineCubic::PrivateData The default setting is a non closing natural spline with no parametrization. */ QwtSplineCubic::QwtSplineCubic() - : m_data( nullptr ) + : m_data(nullptr) { - (void) m_data; + (void)m_data; - // a natural spline - setBoundaryCondition( QwtSpline::AtBeginning, QwtSpline::Clamped2 ); - setBoundaryValue( QwtSpline::AtBeginning, 0.0 ); + // a natural spline + setBoundaryCondition(QwtSpline::AtBeginning, QwtSpline::Clamped2); + setBoundaryValue(QwtSpline::AtBeginning, 0.0); - setBoundaryCondition( QwtSpline::AtEnd, QwtSpline::Clamped2 ); - setBoundaryValue( QwtSpline::AtEnd, 0.0 ); + setBoundaryCondition(QwtSpline::AtEnd, QwtSpline::Clamped2); + setBoundaryValue(QwtSpline::AtEnd, 0.0); } //! Destructor -QwtSplineCubic::~QwtSplineCubic() -{ -} +QwtSplineCubic::~QwtSplineCubic() {} /*! A cubic spline is non local, where changing one point has em effect on all @@ -989,7 +942,7 @@ QwtSplineCubic::~QwtSplineCubic() */ uint QwtSplineCubic::locality() const { - return 0; + return 0; } /*! @@ -1004,27 +957,27 @@ uint QwtSplineCubic::locality() const \sa curvatures(), QwtSplinePolynomial::fromCurvatures() \note The x coordinates need to be increasing or decreasing */ -QVector< double > QwtSplineCubic::slopes( const QPolygonF& points ) const +QVector QwtSplineCubic::slopes(const QPolygonF &points) const { - using namespace QwtSplineCubicP; + using namespace QwtSplineCubicP; - if ( points.size() <= 2 ) - return QVector< double >(); + if (points.size() <= 2) + return QVector(); - if ( ( boundaryType() == QwtSpline::PeriodicPolygon ) - || ( boundaryType() == QwtSpline::ClosedPolygon ) ) + if ((boundaryType() == QwtSpline::PeriodicPolygon) + || (boundaryType() == QwtSpline::ClosedPolygon)) + { + EquationSystem2 eqs; + eqs.resolve(points); + + return eqs.store().slopes(); + } + + if (points.size() == 3) + { + if (boundaryCondition(QwtSpline::AtBeginning) == QwtSplineCubic::NotAKnot + || boundaryCondition(QwtSpline::AtEnd) == QwtSplineCubic::NotAKnot) { - EquationSystem2< SlopeStore > eqs; - eqs.resolve( points ); - - return eqs.store().slopes(); - } - - if ( points.size() == 3 ) - { - if ( boundaryCondition( QwtSpline::AtBeginning ) == QwtSplineCubic::NotAKnot - || boundaryCondition( QwtSpline::AtEnd ) == QwtSplineCubic::NotAKnot ) - { #if 0 const double h0 = points[1].x() - points[0].x(); const double h1 = points[2].x() - points[1].x(); @@ -1046,25 +999,23 @@ QVector< double > QwtSplineCubic::slopes( const QPolygonF& points ) const return m; #else - return QVector< double >(); + return QVector(); #endif - } } + } - Equation3 eq[2]; - qwtSetupEndEquations( - boundaryCondition( QwtSpline::AtBeginning ), - boundaryValue( QwtSpline::AtBeginning ), - boundaryCondition( QwtSpline::AtEnd ), - boundaryValue( QwtSpline::AtEnd ), - points, eq ); + Equation3 eq[2]; + qwtSetupEndEquations(boundaryCondition(QwtSpline::AtBeginning), + boundaryValue(QwtSpline::AtBeginning), + boundaryCondition(QwtSpline::AtEnd), + boundaryValue(QwtSpline::AtEnd), points, eq); - EquationSystem< SlopeStore > eqs; - eqs.setStartCondition( eq[0].p, eq[0].q, eq[0].u, eq[0].r ); - eqs.setEndCondition( eq[1].p, eq[1].q, eq[1].u, eq[1].r ); - eqs.resolve( points ); + EquationSystem eqs; + eqs.setStartCondition(eq[0].p, eq[0].q, eq[0].u, eq[0].r); + eqs.setEndCondition(eq[1].p, eq[1].q, eq[1].u, eq[1].r); + eqs.resolve(points); - return eqs.store().slopes(); + return eqs.store().slopes(); } /*! @@ -1076,45 +1027,43 @@ QVector< double > QwtSplineCubic::slopes( const QPolygonF& points ) const \sa slopes() \note The x coordinates need to be increasing or decreasing */ -QVector< double > QwtSplineCubic::curvatures( const QPolygonF& points ) const +QVector QwtSplineCubic::curvatures(const QPolygonF &points) const { - using namespace QwtSplineCubicP; + using namespace QwtSplineCubicP; - if ( points.size() <= 2 ) - return QVector< double >(); + if (points.size() <= 2) + return QVector(); - if ( ( boundaryType() == QwtSpline::PeriodicPolygon ) - || ( boundaryType() == QwtSpline::ClosedPolygon ) ) - { - EquationSystem2< CurvatureStore > eqs; - eqs.resolve( points ); - - return eqs.store().curvatures(); - } - - if ( points.size() == 3 ) - { - if ( boundaryCondition( QwtSpline::AtBeginning ) == QwtSplineC2::NotAKnot - || boundaryCondition( QwtSpline::AtEnd ) == QwtSplineC2::NotAKnot ) - { - return QVector< double >(); - } - } - - Equation3 eq[2]; - qwtSetupEndEquations( - boundaryCondition( QwtSpline::AtBeginning ), - boundaryValue( QwtSpline::AtBeginning ), - boundaryCondition( QwtSpline::AtEnd ), - boundaryValue( QwtSpline::AtEnd ), - points, eq ); - - EquationSystem< CurvatureStore > eqs; - eqs.setStartCondition( eq[0].p, eq[0].q, eq[0].u, eq[0].r ); - eqs.setEndCondition( eq[1].p, eq[1].q, eq[1].u, eq[1].r ); - eqs.resolve( points ); + if ((boundaryType() == QwtSpline::PeriodicPolygon) + || (boundaryType() == QwtSpline::ClosedPolygon)) + { + EquationSystem2 eqs; + eqs.resolve(points); return eqs.store().curvatures(); + } + + if (points.size() == 3) + { + if (boundaryCondition(QwtSpline::AtBeginning) == QwtSplineC2::NotAKnot + || boundaryCondition(QwtSpline::AtEnd) == QwtSplineC2::NotAKnot) + { + return QVector(); + } + } + + Equation3 eq[2]; + qwtSetupEndEquations(boundaryCondition(QwtSpline::AtBeginning), + boundaryValue(QwtSpline::AtBeginning), + boundaryCondition(QwtSpline::AtEnd), + boundaryValue(QwtSpline::AtEnd), points, eq); + + EquationSystem eqs; + eqs.setStartCondition(eq[0].p, eq[0].q, eq[0].u, eq[0].r); + eqs.setEndCondition(eq[1].p, eq[1].q, eq[1].u, eq[1].r); + eqs.resolve(points); + + return eqs.store().curvatures(); } /*! @@ -1128,12 +1077,12 @@ QVector< double > QwtSplineCubic::curvatures( const QPolygonF& points ) const \note The implementation simply calls QwtSplineC1::painterPath() */ -QPainterPath QwtSplineCubic::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplineCubic::painterPath(const QPolygonF &points) const { - // as QwtSplineCubic can calculate slopes directly we can - // use the implementation of QwtSplineC1 without any performance loss. + // as QwtSplineCubic can calculate slopes directly we can + // use the implementation of QwtSplineC1 without any performance loss. - return QwtSplineC1::painterPath( points ); + return QwtSplineC1::painterPath(points); } /*! @@ -1147,12 +1096,13 @@ QPainterPath QwtSplineCubic::painterPath( const QPolygonF& points ) const \note The implementation simply calls QwtSplineC1::bezierControlLines() */ -QVector< QLineF > QwtSplineCubic::bezierControlLines( const QPolygonF& points ) const +QVector +QwtSplineCubic::bezierControlLines(const QPolygonF &points) const { - // as QwtSplineCubic can calculate slopes directly we can - // use the implementation of QwtSplineC1 without any performance loss. + // as QwtSplineCubic can calculate slopes directly we can + // use the implementation of QwtSplineC1 without any performance loss. - return QwtSplineC1::bezierControlLines( points ); + return QwtSplineC1::bezierControlLines(points); } /*! @@ -1165,8 +1115,8 @@ QVector< QLineF > QwtSplineCubic::bezierControlLines( const QPolygonF& points ) \note The implementation simply calls QwtSplineC2::polynomials(), but is intended to be replaced by a one pass calculation some day. */ -QVector< QwtSplinePolynomial > QwtSplineCubic::polynomials( const QPolygonF& points ) const +QVector +QwtSplineCubic::polynomials(const QPolygonF &points) const { - return QwtSplineC2::polynomials( points ); + return QwtSplineC2::polynomials(points); } - diff --git a/libs/qwt/src/qwt_spline_cubic.h b/libs/qwt/src/qwt_spline_cubic.h index 5272aa0a..c3a68809 100644 --- a/libs/qwt/src/qwt_spline_cubic.h +++ b/libs/qwt/src/qwt_spline_cubic.h @@ -32,23 +32,25 @@ */ class QWT_EXPORT QwtSplineCubic : public QwtSplineC2 { - public: - QwtSplineCubic(); - virtual ~QwtSplineCubic(); +public: + QwtSplineCubic(); + virtual ~QwtSplineCubic(); - virtual uint locality() const QWT_OVERRIDE; + virtual uint locality() const QWT_OVERRIDE; - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< QLineF > bezierControlLines( const QPolygonF& points ) const QWT_OVERRIDE; + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector + bezierControlLines(const QPolygonF &points) const QWT_OVERRIDE; - // calculating the parametric equations - virtual QVector< QwtSplinePolynomial > polynomials( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< double > slopes( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< double > curvatures( const QPolygonF& ) const QWT_OVERRIDE; + // calculating the parametric equations + virtual QVector + polynomials(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector slopes(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector curvatures(const QPolygonF &) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_spline_curve_fitter.cpp b/libs/qwt/src/qwt_spline_curve_fitter.cpp index f7e34d9b..ba667b69 100644 --- a/libs/qwt/src/qwt_spline_curve_fitter.cpp +++ b/libs/qwt/src/qwt_spline_curve_fitter.cpp @@ -16,16 +16,16 @@ //! Constructor QwtSplineCurveFitter::QwtSplineCurveFitter() - : QwtCurveFitter( QwtCurveFitter::Path ) + : QwtCurveFitter(QwtCurveFitter::Path) { - m_spline = new QwtSplineLocal( QwtSplineLocal::Cardinal ); - m_spline->setParametrization( QwtSplineParametrization::ParameterUniform ); + m_spline = new QwtSplineLocal(QwtSplineLocal::Cardinal); + m_spline->setParametrization(QwtSplineParametrization::ParameterUniform); } //! Destructor QwtSplineCurveFitter::~QwtSplineCurveFitter() { - delete m_spline; + delete m_spline; } /*! @@ -37,31 +37,31 @@ QwtSplineCurveFitter::~QwtSplineCurveFitter() \param spline Spline \sa spline() */ -void QwtSplineCurveFitter::setSpline( QwtSpline* spline ) +void QwtSplineCurveFitter::setSpline(QwtSpline *spline) { - if ( m_spline == spline ) - return; + if (m_spline == spline) + return; - delete m_spline; - m_spline = spline; + delete m_spline; + m_spline = spline; } /*! \return Spline \sa setSpline() */ -const QwtSpline* QwtSplineCurveFitter::spline() const +const QwtSpline *QwtSplineCurveFitter::spline() const { - return m_spline; + return m_spline; } /*! \return Spline \sa setSpline() */ -QwtSpline* QwtSplineCurveFitter::spline() +QwtSpline *QwtSplineCurveFitter::spline() { - return m_spline; + return m_spline; } /*! @@ -72,15 +72,15 @@ QwtSpline* QwtSplineCurveFitter::spline() \sa fitCurvePath() */ -QPolygonF QwtSplineCurveFitter::fitCurve( const QPolygonF& points ) const +QPolygonF QwtSplineCurveFitter::fitCurve(const QPolygonF &points) const { - const QPainterPath path = fitCurvePath( points ); + const QPainterPath path = fitCurvePath(points); - const QList< QPolygonF > subPaths = path.toSubpathPolygons(); - if ( subPaths.size() == 1 ) - subPaths.first(); + const QList subPaths = path.toSubpathPolygons(); + if (subPaths.size() == 1) + subPaths.first(); - return QPolygonF(); + return QPolygonF(); } /*! @@ -91,12 +91,12 @@ QPolygonF QwtSplineCurveFitter::fitCurve( const QPolygonF& points ) const \sa fitCurve() */ -QPainterPath QwtSplineCurveFitter::fitCurvePath( const QPolygonF& points ) const +QPainterPath QwtSplineCurveFitter::fitCurvePath(const QPolygonF &points) const { - QPainterPath path; + QPainterPath path; - if ( m_spline ) - path = m_spline->painterPath( points ); + if (m_spline) + path = m_spline->painterPath(points); - return path; + return path; } diff --git a/libs/qwt/src/qwt_spline_curve_fitter.h b/libs/qwt/src/qwt_spline_curve_fitter.h index 457500a9..0c1ed6d0 100644 --- a/libs/qwt/src/qwt_spline_curve_fitter.h +++ b/libs/qwt/src/qwt_spline_curve_fitter.h @@ -24,20 +24,20 @@ class QwtSpline; */ class QWT_EXPORT QwtSplineCurveFitter : public QwtCurveFitter { - public: - QwtSplineCurveFitter(); - virtual ~QwtSplineCurveFitter(); +public: + QwtSplineCurveFitter(); + virtual ~QwtSplineCurveFitter(); - void setSpline( QwtSpline* ); + void setSpline(QwtSpline *); - const QwtSpline* spline() const; - QwtSpline* spline(); + const QwtSpline *spline() const; + QwtSpline *spline(); - virtual QPolygonF fitCurve( const QPolygonF& ) const QWT_OVERRIDE; - virtual QPainterPath fitCurvePath( const QPolygonF& ) const QWT_OVERRIDE; + virtual QPolygonF fitCurve(const QPolygonF &) const QWT_OVERRIDE; + virtual QPainterPath fitCurvePath(const QPolygonF &) const QWT_OVERRIDE; - private: - QwtSpline* m_spline; +private: + QwtSpline *m_spline; }; #endif diff --git a/libs/qwt/src/qwt_spline_local.cpp b/libs/qwt/src/qwt_spline_local.cpp index 61e1bb99..7f808187 100644 --- a/libs/qwt/src/qwt_spline_local.cpp +++ b/libs/qwt/src/qwt_spline_local.cpp @@ -13,44 +13,45 @@ #include -static inline bool qwtIsStrictlyMonotonic( double dy1, double dy2 ) +static inline bool qwtIsStrictlyMonotonic(double dy1, double dy2) { - if ( dy1 == 0.0 || dy2 == 0.0 ) - return false; + if (dy1 == 0.0 || dy2 == 0.0) + return false; - return ( dy1 > 0.0 ) == ( dy2 > 0.0 ); + return (dy1 > 0.0) == (dy2 > 0.0); } -static inline double qwtSlopeLine( const QPointF& p1, const QPointF& p2 ) +static inline double qwtSlopeLine(const QPointF &p1, const QPointF &p2) { - // ??? - const double dx = p2.x() - p1.x(); - return dx ? ( p2.y() - p1.y() ) / dx : 0.0; + // ??? + const double dx = p2.x() - p1.x(); + return dx ? (p2.y() - p1.y()) / dx : 0.0; } -static inline double qwtSlopeCardinal( - double dx1, double dy1, double s1, double dx2, double dy2, double s2 ) +static inline double qwtSlopeCardinal(double dx1, double dy1, double s1, + double dx2, double dy2, double s2) { - Q_UNUSED(s1) - Q_UNUSED(s2) + Q_UNUSED(s1) + Q_UNUSED(s2) - return ( dy1 + dy2 ) / ( dx1 + dx2 ); + return (dy1 + dy2) / (dx1 + dx2); } -static inline double qwtSlopeParabolicBlending( - double dx1, double dy1, double s1, double dx2, double dy2, double s2 ) +static inline double qwtSlopeParabolicBlending(double dx1, double dy1, + double s1, double dx2, + double dy2, double s2) { - Q_UNUSED( dy1 ) - Q_UNUSED( dy2 ) + Q_UNUSED(dy1) + Q_UNUSED(dy2) - return ( dx2 * s1 + dx1 * s2 ) / ( dx1 + dx2 ); + return (dx2 * s1 + dx1 * s2) / (dx1 + dx2); } -static inline double qwtSlopePChip( - double dx1, double dy1, double s1, double dx2, double dy2, double s2 ) +static inline double qwtSlopePChip(double dx1, double dy1, double s1, + double dx2, double dy2, double s2) { - if ( qwtIsStrictlyMonotonic( dy1, dy2 ) ) - { + if (qwtIsStrictlyMonotonic(dy1, dy2)) + { #if 0 // weighting the slopes by the dx1/dx2 const double w1 = ( 3 * dx1 + 3 * dx2 ) / ( 2 * dx1 + 4 * dx2 ); @@ -62,383 +63,368 @@ static inline double qwtSlopePChip( // harmonic mean ( see https://en.wikipedia.org/wiki/Pythagorean_means ) return 2.0 / ( 1.0 / s1 + 1.0 / s2 ); #endif - // the same as above - but faster + // the same as above - but faster - const double s12 = ( dy1 + dy2 ) / ( dx1 + dx2 ); - return 3.0 * ( s1 * s2 ) / ( s1 + s2 + s12 ); - } + const double s12 = (dy1 + dy2) / (dx1 + dx2); + return 3.0 * (s1 * s2) / (s1 + s2 + s12); + } - return 0.0; + return 0.0; } namespace QwtSplineLocalP { - class PathStore - { - public: - inline void init( const QVector< QPointF >& ) - { - } +class PathStore +{ +public: + inline void init(const QVector &) {} - inline void start( const QPointF& p0, double ) - { - path.moveTo( p0 ); - } + inline void start(const QPointF &p0, double) { path.moveTo(p0); } - inline void addCubic( const QPointF& p1, double m1, - const QPointF& p2, double m2 ) - { - const double dx3 = ( p2.x() - p1.x() ) / 3.0; + inline void addCubic(const QPointF &p1, double m1, const QPointF &p2, + double m2) + { + const double dx3 = (p2.x() - p1.x()) / 3.0; - path.cubicTo( p1.x() + dx3, p1.y() + m1 * dx3, - p2.x() - dx3, p2.y() - m2 * dx3, - p2.x(), p2.y() ); - } + path.cubicTo(p1.x() + dx3, p1.y() + m1 * dx3, p2.x() - dx3, + p2.y() - m2 * dx3, p2.x(), p2.y()); + } - QPainterPath path; - }; + QPainterPath path; +}; - class ControlPointsStore - { - public: - inline void init( const QVector< QPointF >& points ) - { - if ( points.size() > 0 ) - controlPoints.resize( points.size() - 1 ); - m_cp = controlPoints.data(); - } +class ControlPointsStore +{ +public: + inline void init(const QVector &points) + { + if (points.size() > 0) + controlPoints.resize(points.size() - 1); + m_cp = controlPoints.data(); + } - inline void start( const QPointF&, double ) - { - } + inline void start(const QPointF &, double) {} - inline void addCubic( const QPointF& p1, double m1, - const QPointF& p2, double m2 ) - { - const double dx3 = ( p2.x() - p1.x() ) / 3.0; + inline void addCubic(const QPointF &p1, double m1, const QPointF &p2, + double m2) + { + const double dx3 = (p2.x() - p1.x()) / 3.0; - QLineF& l = *m_cp++; - l.setLine( p1.x() + dx3, p1.y() + m1 * dx3, - p2.x() - dx3, p2.y() - m2 * dx3 ); - } + QLineF &l = *m_cp++; + l.setLine(p1.x() + dx3, p1.y() + m1 * dx3, p2.x() - dx3, p2.y() - m2 * dx3); + } - QVector< QLineF > controlPoints; + QVector controlPoints; - private: - QLineF* m_cp; - }; +private: + QLineF *m_cp; +}; - class SlopeStore - { - public: - void init( const QVector< QPointF >& points ) - { - slopes.resize( points.size() ); - m_m = slopes.data(); - } +class SlopeStore +{ +public: + void init(const QVector &points) + { + slopes.resize(points.size()); + m_m = slopes.data(); + } - inline void start( const QPointF&, double m0 ) - { - *m_m++ = m0; - } + inline void start(const QPointF &, double m0) { *m_m++ = m0; } - inline void addCubic( const QPointF&, double, - const QPointF&, double m2 ) - { - *m_m++ = m2; - } + inline void addCubic(const QPointF &, double, const QPointF &, double m2) + { + *m_m++ = m2; + } - QVector< double > slopes; + QVector slopes; - private: - double* m_m; - }; +private: + double *m_m; +}; - struct slopeCardinal - { - static inline double value( double dx1, double dy1, double s1, - double dx2, double dy2, double s2 ) - { - return qwtSlopeCardinal( dx1, dy1, s1, dx2, dy2, s2 ); - } - }; +struct slopeCardinal +{ + static inline double value(double dx1, double dy1, double s1, double dx2, + double dy2, double s2) + { + return qwtSlopeCardinal(dx1, dy1, s1, dx2, dy2, s2); + } +}; - struct slopeParabolicBlending - { - static inline double value( double dx1, double dy1, double s1, - double dx2, double dy2, double s2 ) - { - return qwtSlopeParabolicBlending( dx1, dy1, s1, dx2, dy2, s2 ); - } - }; +struct slopeParabolicBlending +{ + static inline double value(double dx1, double dy1, double s1, double dx2, + double dy2, double s2) + { + return qwtSlopeParabolicBlending(dx1, dy1, s1, dx2, dy2, s2); + } +}; - struct slopePChip - { - static inline double value( double dx1, double dy1, double s1, - double dx2, double dy2, double s2 ) - { - return qwtSlopePChip( dx1, dy1, s1, dx2, dy2, s2 ); - } - }; +struct slopePChip +{ + static inline double value(double dx1, double dy1, double s1, double dx2, + double dy2, double s2) + { + return qwtSlopePChip(dx1, dy1, s1, dx2, dy2, s2); + } +}; +} // namespace QwtSplineLocalP + +template +static inline double qwtSlopeP3(const QPointF &p1, const QPointF &p2, + const QPointF &p3) +{ + const double dx1 = p2.x() - p1.x(); + const double dy1 = p2.y() - p1.y(); + const double dx2 = p3.x() - p2.x(); + const double dy2 = p3.y() - p2.y(); + + return Slope::value(dx1, dy1, dy1 / dx1, dx2, dy2, dy2 / dx2); } -template< class Slope > -static inline double qwtSlopeP3( - const QPointF& p1, const QPointF& p2, const QPointF& p3 ) +static inline double qwtSlopeAkima(double s1, double s2, double s3, double s4) { - const double dx1 = p2.x() - p1.x(); - const double dy1 = p2.y() - p1.y(); - const double dx2 = p3.x() - p2.x(); - const double dy2 = p3.y() - p2.y(); + if ((s1 == s2) && (s3 == s4)) + { + return 0.5 * (s2 + s3); + } - return Slope::value( dx1, dy1, dy1 / dx1, dx2, dy2, dy2 / dx2 ); + const double ds12 = qAbs(s2 - s1); + const double ds34 = qAbs(s4 - s3); + + return (s2 * ds34 + s3 * ds12) / (ds12 + ds34); } -static inline double qwtSlopeAkima( double s1, double s2, double s3, double s4 ) +static inline double qwtSlopeAkima(const QPointF &p1, const QPointF &p2, + const QPointF &p3, const QPointF &p4, + const QPointF &p5) { - if ( ( s1 == s2 ) && ( s3 == s4 ) ) - { - return 0.5 * ( s2 + s3 ); - } + const double s1 = qwtSlopeLine(p1, p2); + const double s2 = qwtSlopeLine(p2, p3); + const double s3 = qwtSlopeLine(p3, p4); + const double s4 = qwtSlopeLine(p4, p5); - const double ds12 = qAbs( s2 - s1 ); - const double ds34 = qAbs( s4 - s3 ); - - return ( s2 * ds34 + s3 * ds12 ) / ( ds12 + ds34 ); + return qwtSlopeAkima(s1, s2, s3, s4); } -static inline double qwtSlopeAkima( const QPointF& p1, const QPointF& p2, - const QPointF& p3, const QPointF& p4, const QPointF& p5 ) +template +static void qwtSplineBoundariesL1(const QwtSplineLocal *spline, + const QVector &points, + double &slopeBegin, double &slopeEnd) { - const double s1 = qwtSlopeLine( p1, p2 ); - const double s2 = qwtSlopeLine( p2, p3 ); - const double s3 = qwtSlopeLine( p3, p4 ); - const double s4 = qwtSlopeLine( p4, p5 ); + const int n = points.size(); + const QPointF *p = points.constData(); - return qwtSlopeAkima( s1, s2, s3, s4 ); + if ((spline->boundaryType() == QwtSpline::PeriodicPolygon) + || (spline->boundaryType() == QwtSpline::ClosedPolygon)) + { + const QPointF pn = p[0] - (p[n - 1] - p[n - 2]); + slopeBegin = slopeEnd = qwtSlopeP3(pn, p[0], p[1]); + } + else + { + const double m2 = qwtSlopeP3(p[0], p[1], p[2]); + slopeBegin = spline->slopeAtBeginning(points, m2); + + const double mn2 = qwtSlopeP3(p[n - 3], p[n - 2], p[n - 1]); + slopeEnd = spline->slopeAtEnd(points, mn2); + } } -template< class Slope > -static void qwtSplineBoundariesL1( - const QwtSplineLocal* spline, const QVector< QPointF >& points, - double& slopeBegin, double& slopeEnd ) +template +static inline SplineStore qwtSplineL1(const QwtSplineLocal *spline, + const QVector &points) { - const int n = points.size(); - const QPointF* p = points.constData(); + const int size = points.size(); + const QPointF *p = points.constData(); - if ( ( spline->boundaryType() == QwtSpline::PeriodicPolygon ) - || ( spline->boundaryType() == QwtSpline::ClosedPolygon ) ) - { - const QPointF pn = p[0] - ( p[n - 1] - p[n - 2] ); - slopeBegin = slopeEnd = qwtSlopeP3< Slope >( pn, p[0], p[1] ); - } - else - { - const double m2 = qwtSlopeP3< Slope >( p[0], p[1], p[2] ); - slopeBegin = spline->slopeAtBeginning( points, m2 ); + double slopeBegin, slopeEnd; + qwtSplineBoundariesL1(spline, points, slopeBegin, slopeEnd); - const double mn2 = qwtSlopeP3< Slope >( p[n - 3], p[n - 2], p[n - 1] ); - slopeEnd = spline->slopeAtEnd( points, mn2 ); - } + double m1 = slopeBegin; + + SplineStore store; + store.init(points); + store.start(p[0], m1); + + double dx1 = p[1].x() - p[0].x(); + double dy1 = p[1].y() - p[0].y(); + double s1 = dy1 / dx1; + + for (int i = 1; i < size - 1; i++) + { + const double dx2 = p[i + 1].x() - p[i].x(); + const double dy2 = p[i + 1].y() - p[i].y(); + + // cardinal spline doesn't need the line slopes, but + // the compiler will eliminate pointless calculations + const double s2 = dy2 / dx2; + + const double m2 = Slope::value(dx1, dy1, s1, dx2, dy2, s2); + + store.addCubic(p[i - 1], m1, p[i], m2); + + dx1 = dx2; + dy1 = dy2; + s1 = s2; + m1 = m2; + } + + store.addCubic(p[size - 2], m1, p[size - 1], slopeEnd); + + return store; } -template< class SplineStore, class Slope > -static inline SplineStore qwtSplineL1( - const QwtSplineLocal* spline, const QVector< QPointF >& points ) +static inline void qwtSplineAkimaBoundaries(const QwtSplineLocal *spline, + const QVector &points, + double &slopeBegin, + double &slopeEnd) { - const int size = points.size(); - const QPointF* p = points.constData(); + const int n = points.size(); + const QPointF *p = points.constData(); - double slopeBegin, slopeEnd; - qwtSplineBoundariesL1< Slope >( spline, points, slopeBegin, slopeEnd ); + if ((spline->boundaryType() == QwtSpline::PeriodicPolygon) + || (spline->boundaryType() == QwtSpline::ClosedPolygon)) + { + const QPointF p2 = p[0] - (p[n - 1] - p[n - 2]); + const QPointF p1 = p2 - (p[n - 2] - p[n - 3]); - double m1 = slopeBegin; + slopeBegin = slopeEnd = qwtSlopeAkima(p1, p2, p[0], p[1], p[2]); - SplineStore store; - store.init( points ); - store.start( p[0], m1 ); + return; + } - double dx1 = p[1].x() - p[0].x(); - double dy1 = p[1].y() - p[0].y(); - double s1 = dy1 / dx1; + if (spline->boundaryCondition(QwtSpline::AtBeginning) == QwtSpline::Clamped1 + && spline->boundaryCondition(QwtSpline::AtEnd) == QwtSpline::Clamped1) + { + slopeBegin = spline->boundaryValue(QwtSpline::AtBeginning); + slopeEnd = spline->boundaryValue(QwtSpline::AtEnd); - for ( int i = 1; i < size - 1; i++ ) - { - const double dx2 = p[i + 1].x() - p[i].x(); - const double dy2 = p[i + 1].y() - p[i].y(); + return; + } - // cardinal spline doesn't need the line slopes, but - // the compiler will eliminate pointless calculations - const double s2 = dy2 / dx2; + if (n == 3) + { + const double s1 = qwtSlopeLine(p[0], p[1]); + const double s2 = qwtSlopeLine(p[1], p[2]); + const double m = qwtSlopeAkima(0.5 * s1, s1, s2, 0.5 * s2); - const double m2 = Slope::value( dx1, dy1, s1, dx2, dy2, s2 ); + slopeBegin = spline->slopeAtBeginning(points, m); + slopeEnd = spline->slopeAtEnd(points, m); + } + else + { + double s[3]; - store.addCubic( p[i - 1], m1, p[i], m2 ); + s[0] = qwtSlopeLine(p[0], p[1]); + s[1] = qwtSlopeLine(p[1], p[2]); + s[2] = qwtSlopeLine(p[2], p[3]); - dx1 = dx2; - dy1 = dy2; - s1 = s2; - m1 = m2; - } + const double m2 = qwtSlopeAkima(0.5 * s[0], s[0], s[1], s[2]); - store.addCubic( p[size - 2], m1, p[size - 1], slopeEnd ); + slopeBegin = spline->slopeAtBeginning(points, m2); + + s[0] = qwtSlopeLine(p[n - 4], p[n - 3]); + s[1] = qwtSlopeLine(p[n - 3], p[n - 2]); + s[2] = qwtSlopeLine(p[n - 2], p[n - 1]); + + const double mn2 = qwtSlopeAkima(s[0], s[1], s[2], 0.5 * s[2]); + + slopeEnd = spline->slopeAtEnd(points, mn2); + } +} + +template +static inline SplineStore qwtSplineAkima(const QwtSplineLocal *spline, + const QVector &points) +{ + const int size = points.size(); + const QPointF *p = points.constData(); + + double slopeBegin, slopeEnd; + qwtSplineAkimaBoundaries(spline, points, slopeBegin, slopeEnd); + + double m1 = slopeBegin; + + SplineStore store; + store.init(points); + store.start(p[0], m1); + + double s2 = qwtSlopeLine(p[0], p[1]); + double s3 = qwtSlopeLine(p[1], p[2]); + double s1 = 0.5 * s2; + + for (int i = 0; i < size - 3; i++) + { + const double s4 = qwtSlopeLine(p[i + 2], p[i + 3]); + + const double m2 = qwtSlopeAkima(s1, s2, s3, s4); + store.addCubic(p[i], m1, p[i + 1], m2); + + s1 = s2; + s2 = s3; + s3 = s4; + + m1 = m2; + } + + const double m2 = qwtSlopeAkima(s1, s2, s3, 0.5 * s3); + + store.addCubic(p[size - 3], m1, p[size - 2], m2); + store.addCubic(p[size - 2], m2, p[size - 1], slopeEnd); + + return store; +} + +template +static inline SplineStore qwtSplineLocal(const QwtSplineLocal *spline, + const QVector &points) +{ + SplineStore store; + + const int size = points.size(); + if (size <= 1) + return store; + + if (size == 2) + { + const double s0 = qwtSlopeLine(points[0], points[1]); + const double m1 = spline->slopeAtBeginning(points, s0); + const double m2 = spline->slopeAtEnd(points, s0); + + store.init(points); + store.start(points[0], m1); + store.addCubic(points[0], m1, points[1], m2); return store; -} + } -static inline void qwtSplineAkimaBoundaries( - const QwtSplineLocal* spline, const QVector< QPointF >& points, - double& slopeBegin, double& slopeEnd ) -{ - const int n = points.size(); - const QPointF* p = points.constData(); - - if ( ( spline->boundaryType() == QwtSpline::PeriodicPolygon ) - || ( spline->boundaryType() == QwtSpline::ClosedPolygon ) ) - { - const QPointF p2 = p[0] - ( p[n - 1] - p[n - 2] ); - const QPointF p1 = p2 - ( p[n - 2] - p[n - 3] ); - - slopeBegin = slopeEnd = qwtSlopeAkima( p1, p2, p[0], p[1], p[2] ); - - return; + switch (spline->type()) + { + case QwtSplineLocal::Cardinal: { + using namespace QwtSplineLocalP; + store = qwtSplineL1(spline, points); + break; } - - if ( spline->boundaryCondition( QwtSpline::AtBeginning ) == QwtSpline::Clamped1 - && spline->boundaryCondition( QwtSpline::AtEnd ) == QwtSpline::Clamped1 ) - { - slopeBegin = spline->boundaryValue( QwtSpline::AtBeginning); - slopeEnd = spline->boundaryValue( QwtSpline::AtEnd ); - - return; + case QwtSplineLocal::ParabolicBlending: { + using namespace QwtSplineLocalP; + store = qwtSplineL1(spline, points); + break; } - - if ( n == 3 ) - { - const double s1 = qwtSlopeLine( p[0], p[1] ); - const double s2 = qwtSlopeLine( p[1], p[2] ); - const double m = qwtSlopeAkima( 0.5 * s1, s1, s2, 0.5 * s2 ); - - slopeBegin = spline->slopeAtBeginning( points, m ); - slopeEnd = spline->slopeAtEnd( points, m ); + case QwtSplineLocal::PChip: { + using namespace QwtSplineLocalP; + store = qwtSplineL1(spline, points); + break; } - else - { - double s[3]; - - s[0] = qwtSlopeLine( p[0], p[1] ); - s[1] = qwtSlopeLine( p[1], p[2] ); - s[2] = qwtSlopeLine( p[2], p[3] ); - - const double m2 = qwtSlopeAkima( 0.5 * s[0], s[0], s[1], s[2] ); - - slopeBegin = spline->slopeAtBeginning( points, m2 ); - - s[0] = qwtSlopeLine( p[n - 4], p[n - 3] ); - s[1] = qwtSlopeLine( p[n - 3], p[n - 2] ); - s[2] = qwtSlopeLine( p[n - 2], p[n - 1] ); - - const double mn2 = qwtSlopeAkima( s[0], s[1], s[2], 0.5 * s[2] ); - - slopeEnd = spline->slopeAtEnd( points, mn2 ); + case QwtSplineLocal::Akima: { + store = qwtSplineAkima(spline, points); + break; } -} + default: + break; + } -template< class SplineStore > -static inline SplineStore qwtSplineAkima( - const QwtSplineLocal* spline, const QVector< QPointF >& points ) -{ - const int size = points.size(); - const QPointF* p = points.constData(); - - double slopeBegin, slopeEnd; - qwtSplineAkimaBoundaries( spline, points, slopeBegin, slopeEnd ); - - double m1 = slopeBegin; - - SplineStore store; - store.init( points ); - store.start( p[0], m1 ); - - double s2 = qwtSlopeLine( p[0], p[1] ); - double s3 = qwtSlopeLine( p[1], p[2] ); - double s1 = 0.5 * s2; - - for ( int i = 0; i < size - 3; i++ ) - { - const double s4 = qwtSlopeLine( p[i + 2], p[i + 3] ); - - const double m2 = qwtSlopeAkima( s1, s2, s3, s4 ); - store.addCubic( p[i], m1, p[i + 1], m2 ); - - s1 = s2; - s2 = s3; - s3 = s4; - - m1 = m2; - } - - const double m2 = qwtSlopeAkima( s1, s2, s3, 0.5 * s3 ); - - store.addCubic( p[size - 3], m1, p[size - 2], m2 ); - store.addCubic( p[size - 2], m2, p[size - 1], slopeEnd ); - - return store; -} - -template< class SplineStore > -static inline SplineStore qwtSplineLocal( - const QwtSplineLocal* spline, const QVector< QPointF >& points ) -{ - SplineStore store; - - const int size = points.size(); - if ( size <= 1 ) - return store; - - if ( size == 2 ) - { - const double s0 = qwtSlopeLine( points[0], points[1] ); - const double m1 = spline->slopeAtBeginning( points, s0 ); - const double m2 = spline->slopeAtEnd( points, s0 ); - - store.init( points ); - store.start( points[0], m1 ); - store.addCubic( points[0], m1, points[1], m2 ); - - return store; - } - - switch( spline->type() ) - { - case QwtSplineLocal::Cardinal: - { - using namespace QwtSplineLocalP; - store = qwtSplineL1< SplineStore, slopeCardinal >( spline, points ); - break; - } - case QwtSplineLocal::ParabolicBlending: - { - using namespace QwtSplineLocalP; - store = qwtSplineL1< SplineStore, slopeParabolicBlending >( spline, points ); - break; - } - case QwtSplineLocal::PChip: - { - using namespace QwtSplineLocalP; - store = qwtSplineL1< SplineStore, slopePChip >( spline, points ); - break; - } - case QwtSplineLocal::Akima: - { - store = qwtSplineAkima< SplineStore >( spline, points ); - break; - } - default: - break; - } - - return store; + return store; } /*! @@ -447,27 +433,25 @@ static inline SplineStore qwtSplineLocal( \param type Spline type, specifying the type of interpolation \sa type() */ -QwtSplineLocal::QwtSplineLocal( Type type ) - : m_type( type ) +QwtSplineLocal::QwtSplineLocal(Type type) + : m_type(type) { - setBoundaryCondition( QwtSpline::AtBeginning, QwtSpline::LinearRunout ); - setBoundaryValue( QwtSpline::AtBeginning, 0.0 ); + setBoundaryCondition(QwtSpline::AtBeginning, QwtSpline::LinearRunout); + setBoundaryValue(QwtSpline::AtBeginning, 0.0); - setBoundaryCondition( QwtSpline::AtEnd, QwtSpline::LinearRunout ); - setBoundaryValue( QwtSpline::AtEnd, 0.0 ); + setBoundaryCondition(QwtSpline::AtEnd, QwtSpline::LinearRunout); + setBoundaryValue(QwtSpline::AtEnd, 0.0); } //! Destructor -QwtSplineLocal::~QwtSplineLocal() -{ -} +QwtSplineLocal::~QwtSplineLocal() {} /*! \return Spline type, specifying the type of interpolation */ QwtSplineLocal::Type QwtSplineLocal::type() const { - return m_type; + return m_type; } /*! @@ -479,15 +463,15 @@ QwtSplineLocal::Type QwtSplineLocal::type() const \param points Control points \return Painter path, that can be rendered by QPainter */ -QPainterPath QwtSplineLocal::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplineLocal::painterPath(const QPolygonF &points) const { - if ( parametrization()->type() == QwtSplineParametrization::ParameterX ) - { - using namespace QwtSplineLocalP; - return qwtSplineLocal< PathStore >( this, points).path; - } + if (parametrization()->type() == QwtSplineParametrization::ParameterX) + { + using namespace QwtSplineLocalP; + return qwtSplineLocal(this, points).path; + } - return QwtSplineC1::painterPath( points ); + return QwtSplineC1::painterPath(points); } /*! @@ -499,15 +483,16 @@ QPainterPath QwtSplineLocal::painterPath( const QPolygonF& points ) const \param points Control points \return Control points of the interpolating Bezier curves */ -QVector< QLineF > QwtSplineLocal::bezierControlLines( const QPolygonF& points ) const +QVector +QwtSplineLocal::bezierControlLines(const QPolygonF &points) const { - if ( parametrization()->type() == QwtSplineParametrization::ParameterX ) - { - using namespace QwtSplineLocalP; - return qwtSplineLocal< ControlPointsStore >( this, points ).controlPoints; - } + if (parametrization()->type() == QwtSplineParametrization::ParameterX) + { + using namespace QwtSplineLocalP; + return qwtSplineLocal(this, points).controlPoints; + } - return QwtSplineC1::bezierControlLines( points ); + return QwtSplineC1::bezierControlLines(points); } /*! @@ -518,10 +503,10 @@ QVector< QLineF > QwtSplineLocal::bezierControlLines( const QPolygonF& points ) \note The x coordinates need to be increasing or decreasing */ -QVector< double > QwtSplineLocal::slopes( const QPolygonF& points ) const +QVector QwtSplineLocal::slopes(const QPolygonF &points) const { - using namespace QwtSplineLocalP; - return qwtSplineLocal< SlopeStore >( this, points ).slopes; + using namespace QwtSplineLocalP; + return qwtSplineLocal(this, points).slopes; } /*! @@ -534,10 +519,11 @@ QVector< double > QwtSplineLocal::slopes( const QPolygonF& points ) const \note The implementation simply calls QwtSplineC1::polynomials(), but is intended to be replaced by a one pass calculation some day. */ -QVector< QwtSplinePolynomial > QwtSplineLocal::polynomials( const QPolygonF& points ) const +QVector +QwtSplineLocal::polynomials(const QPolygonF &points) const { - // Polynomial store -> TODO - return QwtSplineC1::polynomials( points ); + // Polynomial store -> TODO + return QwtSplineC1::polynomials(points); } /*! @@ -551,21 +537,19 @@ QVector< QwtSplinePolynomial > QwtSplineLocal::polynomials( const QPolygonF& poi */ uint QwtSplineLocal::locality() const { - switch ( m_type ) - { - case Akima: - { - // polynomials: 2 left, 2 right - return 2; - } - case Cardinal: - case ParabolicBlending: - case PChip: - { - // polynomials: 1 left, 1 right - return 1; - } + switch (m_type) + { + case Akima: { + // polynomials: 2 left, 2 right + return 2; } + case Cardinal: + case ParabolicBlending: + case PChip: { + // polynomials: 1 left, 1 right + return 1; + } + } - return QwtSplineC1::locality(); + return QwtSplineC1::locality(); } diff --git a/libs/qwt/src/qwt_spline_local.h b/libs/qwt/src/qwt_spline_local.h index d1dd8e0a..7c8f041c 100644 --- a/libs/qwt/src/qwt_spline_local.h +++ b/libs/qwt/src/qwt_spline_local.h @@ -23,61 +23,63 @@ */ class QWT_EXPORT QwtSplineLocal : public QwtSplineC1 { - public: +public: + /*! + \brief Spline interpolation type + + All type of spline interpolations are lightweight algorithms + calculating the slopes at a point by looking 1 or 2 points back + and ahead. + */ + enum Type + { /*! - \brief Spline interpolation type + A cardinal spline - All type of spline interpolations are lightweight algorithms - calculating the slopes at a point by looking 1 or 2 points back - and ahead. + The cardinal spline interpolation is a very cheap calculation with + a locality of 1. */ - enum Type - { - /*! - A cardinal spline + Cardinal, - The cardinal spline interpolation is a very cheap calculation with - a locality of 1. - */ - Cardinal, + /*! + Parabolic blending is a cheap calculation with a locality of 1. Sometimes + it is also called Cubic Bessel interpolation. + */ + ParabolicBlending, - /*! - Parabolic blending is a cheap calculation with a locality of 1. Sometimes - it is also called Cubic Bessel interpolation. - */ - ParabolicBlending, + /*! + The algorithm of H.Akima is a calculation with a locality of 2. + */ + Akima, - /*! - The algorithm of H.Akima is a calculation with a locality of 2. - */ - Akima, + /*! + Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) is an algorithm + that is popular because of being offered by MATLAB. - /*! - Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) is an algorithm - that is popular because of being offered by MATLAB. + It preserves the shape of the data and respects monotonicity. It has a + locality of 1. + */ + PChip + }; - It preserves the shape of the data and respects monotonicity. It has a - locality of 1. - */ - PChip - }; + QwtSplineLocal(Type type); + virtual ~QwtSplineLocal(); - QwtSplineLocal( Type type ); - virtual ~QwtSplineLocal(); + Type type() const; - Type type() const; + virtual uint locality() const QWT_OVERRIDE; - virtual uint locality() const QWT_OVERRIDE; + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector + bezierControlLines(const QPolygonF &) const QWT_OVERRIDE; - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< QLineF > bezierControlLines( const QPolygonF& ) const QWT_OVERRIDE; + // calculating the parametric equations + virtual QVector + polynomials(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector slopes(const QPolygonF &) const QWT_OVERRIDE; - // calculating the parametric equations - virtual QVector< QwtSplinePolynomial > polynomials( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< double > slopes( const QPolygonF& ) const QWT_OVERRIDE; - - private: - const Type m_type; +private: + const Type m_type; }; #endif diff --git a/libs/qwt/src/qwt_spline_parametrization.cpp b/libs/qwt/src/qwt_spline_parametrization.cpp index 6b4dba1e..24e42584 100644 --- a/libs/qwt/src/qwt_spline_parametrization.cpp +++ b/libs/qwt/src/qwt_spline_parametrization.cpp @@ -14,15 +14,13 @@ \param type Parametrization type \sa type() */ -QwtSplineParametrization::QwtSplineParametrization( int type ) - : m_type( type ) +QwtSplineParametrization::QwtSplineParametrization(int type) + : m_type(type) { } //! Destructor -QwtSplineParametrization::~QwtSplineParametrization() -{ -} +QwtSplineParametrization::~QwtSplineParametrization() {} /*! \brief Calculate the parameter value increment for 2 points @@ -32,44 +30,37 @@ QwtSplineParametrization::~QwtSplineParametrization() \return Value increment */ -double QwtSplineParametrization::valueIncrement( - const QPointF& point1, const QPointF& point2 ) const +double QwtSplineParametrization::valueIncrement(const QPointF &point1, + const QPointF &point2) const { - switch( m_type ) - { - case QwtSplineParametrization::ParameterX: - { - return valueIncrementX( point1, point2 ); - } - case QwtSplineParametrization::ParameterY: - { - return valueIncrementY( point1, point2 ); - } - case QwtSplineParametrization::ParameterCentripetal: - { - return valueIncrementCentripetal( point1, point2 ); - } - case QwtSplineParametrization::ParameterChordal: - { - return valueIncrementChordal( point1, point2 ); - } - case QwtSplineParametrization::ParameterManhattan: - { - return valueIncrementManhattan( point1, point2 ); - } - case QwtSplineParametrization::ParameterUniform: - { - return valueIncrementUniform( point1, point2 ); - } - default: - { - return 1; - } + switch (m_type) + { + case QwtSplineParametrization::ParameterX: { + return valueIncrementX(point1, point2); } + case QwtSplineParametrization::ParameterY: { + return valueIncrementY(point1, point2); + } + case QwtSplineParametrization::ParameterCentripetal: { + return valueIncrementCentripetal(point1, point2); + } + case QwtSplineParametrization::ParameterChordal: { + return valueIncrementChordal(point1, point2); + } + case QwtSplineParametrization::ParameterManhattan: { + return valueIncrementManhattan(point1, point2); + } + case QwtSplineParametrization::ParameterUniform: { + return valueIncrementUniform(point1, point2); + } + default: { + return 1; + } + } } //! \return Parametrization type int QwtSplineParametrization::type() const { - return m_type; + return m_type; } diff --git a/libs/qwt/src/qwt_spline_parametrization.h b/libs/qwt/src/qwt_spline_parametrization.h index 37a0859f..a9c87c87 100644 --- a/libs/qwt/src/qwt_spline_parametrization.h +++ b/libs/qwt/src/qwt_spline_parametrization.h @@ -43,84 +43,83 @@ */ class QWT_EXPORT QwtSplineParametrization { - public: - //! Parametrization type - enum Type - { - /*! - No parametrization: t[i] = x[i] - \sa valueIncrementX() - */ - ParameterX, +public: + //! Parametrization type + enum Type + { + /*! + No parametrization: t[i] = x[i] + \sa valueIncrementX() + */ + ParameterX, - /*! - No parametrization: t[i] = y[i] - \sa valueIncrementY() - */ - ParameterY, + /*! + No parametrization: t[i] = y[i] + \sa valueIncrementY() + */ + ParameterY, - /*! - Uniform parametrization: t[i] = i; + /*! + Uniform parametrization: t[i] = i; - A very fast parametrization, with good results, when the geometry - of the control points is somehow "equidistant". F.e. when - recording the position of a body, that is moving with constant - speed every n seconds. + A very fast parametrization, with good results, when the geometry + of the control points is somehow "equidistant". F.e. when + recording the position of a body, that is moving with constant + speed every n seconds. - \sa valueIncrementUniform() - */ - ParameterUniform, + \sa valueIncrementUniform() + */ + ParameterUniform, - /*! - Parametrization using the chordal length between two control points + /*! + Parametrization using the chordal length between two control points - The chordal length is the most commonly used approximation for - the curve length. + The chordal length is the most commonly used approximation for + the curve length. - \sa valueIncrementChordal() - */ - ParameterChordal, + \sa valueIncrementChordal() + */ + ParameterChordal, - /*! - Centripetal parametrization + /*! + Centripetal parametrization - Based on the square root of the chordal length. + Based on the square root of the chordal length. - Its name stems from the physical observations regarding - the centripetal force, of a body moving along the curve. + Its name stems from the physical observations regarding + the centripetal force, of a body moving along the curve. - \sa valueIncrementCentripetal() - */ - ParameterCentripetal, + \sa valueIncrementCentripetal() + */ + ParameterCentripetal, + /*! + Parametrization using the manhattan length between two control points - /*! - Parametrization using the manhattan length between two control points + Approximating the curve length by the manhattan length is faster + than the chordal length, but usually gives worse results. - Approximating the curve length by the manhattan length is faster - than the chordal length, but usually gives worse results. + \sa valueIncrementManhattan() + */ + ParameterManhattan + }; - \sa valueIncrementManhattan() - */ - ParameterManhattan - }; + explicit QwtSplineParametrization(int type); + virtual ~QwtSplineParametrization(); - explicit QwtSplineParametrization( int type ); - virtual ~QwtSplineParametrization(); + int type() const; - int type() const; + virtual double valueIncrement(const QPointF &, const QPointF &) const; - virtual double valueIncrement( const QPointF&, const QPointF& ) const; + static double valueIncrementX(const QPointF &, const QPointF &); + static double valueIncrementY(const QPointF &, const QPointF &); + static double valueIncrementUniform(const QPointF &, const QPointF &); + static double valueIncrementChordal(const QPointF &, const QPointF &); + static double valueIncrementCentripetal(const QPointF &, const QPointF &); + static double valueIncrementManhattan(const QPointF &, const QPointF &); - static double valueIncrementX( const QPointF&, const QPointF& ); - static double valueIncrementY( const QPointF&, const QPointF& ); - static double valueIncrementUniform( const QPointF&, const QPointF& ); - static double valueIncrementChordal( const QPointF&, const QPointF& ); - static double valueIncrementCentripetal( const QPointF&, const QPointF& ); - static double valueIncrementManhattan( const QPointF&, const QPointF& ); - - private: - const int m_type; +private: + const int m_type; }; /*! @@ -131,10 +130,10 @@ class QWT_EXPORT QwtSplineParametrization \return point2.x() - point1.x(); */ -inline double QwtSplineParametrization::valueIncrementX( - const QPointF& point1, const QPointF& point2 ) +inline double QwtSplineParametrization::valueIncrementX(const QPointF &point1, + const QPointF &point2) { - return point2.x() - point1.x(); + return point2.x() - point1.x(); } /*! @@ -145,10 +144,10 @@ inline double QwtSplineParametrization::valueIncrementX( \return point2.y() - point1.y(); */ -inline double QwtSplineParametrization::valueIncrementY( - const QPointF& point1, const QPointF& point2 ) +inline double QwtSplineParametrization::valueIncrementY(const QPointF &point1, + const QPointF &point2) { - return point2.y() - point1.y(); + return point2.y() - point1.y(); } /*! @@ -159,13 +158,14 @@ inline double QwtSplineParametrization::valueIncrementY( \return 1.0 */ -inline double QwtSplineParametrization::valueIncrementUniform( - const QPointF& point1, const QPointF& point2 ) +inline double +QwtSplineParametrization::valueIncrementUniform(const QPointF &point1, + const QPointF &point2) { - Q_UNUSED( point1 ) - Q_UNUSED( point2 ) + Q_UNUSED(point1) + Q_UNUSED(point2) - return 1.0; + return 1.0; } /*! @@ -176,13 +176,14 @@ inline double QwtSplineParametrization::valueIncrementUniform( \return qSqrt( dx * dx + dy * dy ); */ -inline double QwtSplineParametrization::valueIncrementChordal( - const QPointF& point1, const QPointF& point2 ) +inline double +QwtSplineParametrization::valueIncrementChordal(const QPointF &point1, + const QPointF &point2) { - const double dx = point2.x() - point1.x(); - const double dy = point2.y() - point1.y(); + const double dx = point2.x() - point1.x(); + const double dy = point2.y() - point1.y(); - return std::sqrt( dx * dx + dy * dy ); + return std::sqrt(dx * dx + dy * dy); } /*! @@ -193,10 +194,11 @@ inline double QwtSplineParametrization::valueIncrementChordal( \return The square root of a chordal increment */ -inline double QwtSplineParametrization::valueIncrementCentripetal( - const QPointF& point1, const QPointF& point2 ) +inline double +QwtSplineParametrization::valueIncrementCentripetal(const QPointF &point1, + const QPointF &point2) { - return std::sqrt( valueIncrementChordal( point1, point2 ) ); + return std::sqrt(valueIncrementChordal(point1, point2)); } /*! @@ -207,10 +209,11 @@ inline double QwtSplineParametrization::valueIncrementCentripetal( \return | point2.x() - point1.x() | + | point2.y() - point1.y() | */ -inline double QwtSplineParametrization::valueIncrementManhattan( - const QPointF& point1, const QPointF& point2 ) +inline double +QwtSplineParametrization::valueIncrementManhattan(const QPointF &point1, + const QPointF &point2) { - return qAbs( point2.x() - point1.x() ) + qAbs( point2.y() - point1.y() ); + return qAbs(point2.x() - point1.x()) + qAbs(point2.y() - point1.y()); } #endif diff --git a/libs/qwt/src/qwt_spline_pleasing.cpp b/libs/qwt/src/qwt_spline_pleasing.cpp index 7f3fef5e..fffda111 100644 --- a/libs/qwt/src/qwt_spline_pleasing.cpp +++ b/libs/qwt/src/qwt_spline_pleasing.cpp @@ -12,246 +12,245 @@ #include -static inline double qwtChordalLength( const QPointF& point1, const QPointF& point2 ) +static inline double qwtChordalLength(const QPointF &point1, + const QPointF &point2) { - const double dx = point2.x() - point1.x(); - const double dy = point2.y() - point1.y(); + const double dx = point2.x() - point1.x(); + const double dy = point2.y() - point1.y(); - return std::sqrt( dx * dx + dy * dy ); + return std::sqrt(dx * dx + dy * dy); } -template< class Param > -static QPointF qwtVector( Param param, - const QPointF& p1, const QPointF& p2 ) +template +static QPointF qwtVector(Param param, const QPointF &p1, const QPointF &p2) { - return ( p2 - p1 ) / param( p1, p2 ); + return (p2 - p1) / param(p1, p2); } -template< class Param > -static QPointF qwtVectorCardinal( Param param, - const QPointF& p1, const QPointF& p2, const QPointF& p3 ) +template +static QPointF qwtVectorCardinal(Param param, const QPointF &p1, + const QPointF &p2, const QPointF &p3) { - const double t1 = param( p1, p2 ); - const double t2 = param( p2, p3 ); + const double t1 = param(p1, p2); + const double t2 = param(p2, p3); - return t2 * ( p3 - p1 ) / ( t1 + t2 ); + return t2 * (p3 - p1) / (t1 + t2); } namespace QwtSplinePleasingP { - struct Tension +struct Tension +{ + double t1; + double t2; +}; + +struct param +{ + param(const QwtSplineParametrization *p) + : parameter(p) + { + } + + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return parameter->valueIncrement(p1, p2); + } + + const QwtSplineParametrization *parameter; +}; + +struct paramUniform +{ + inline double operator()(const QPointF &p1, const QPointF &p2) const + { + return QwtSplineParametrization::valueIncrementUniform(p1, p2); + } +}; + +class PathStore +{ +public: + inline void init(int) {} + + inline void start(const QPointF &p0) { path.moveTo(p0); } + + inline void addCubic(const QPointF &cp1, const QPointF &cp2, + const QPointF &p2) + { + path.cubicTo(cp1, cp2, p2); + } + + QPainterPath path; +}; + +class ControlPointsStore +{ +public: + inline ControlPointsStore() + : m_cp(NULL) + { + } + + inline void init(int size) + { + controlPoints.resize(size); + m_cp = controlPoints.data(); + } + + inline void start(const QPointF &) {} + + inline void addCubic(const QPointF &cp1, const QPointF &cp2, const QPointF &) + { + QLineF &l = *m_cp++; + l.setPoints(cp1, cp2); + } + + QVector controlPoints; + +private: + QLineF *m_cp; +}; +} // namespace QwtSplinePleasingP + +static inline QwtSplinePleasingP::Tension +qwtTensionPleasing(double d13, double d23, double d24, const QPointF &p1, + const QPointF &p2, const QPointF &p3, const QPointF &p4) +{ + QwtSplinePleasingP::Tension tension; + + const bool b1 = (d13 / 3.0) < d23; + const bool b2 = (d24 / 3.0) < d23; + + if (b1) + { + if (b2) { - double t1; - double t2; - }; - - struct param + tension.t1 = (p1 != p2) ? (1.0 / 3.0) : (2.0 / 3.0); + tension.t2 = (p3 != p4) ? (1.0 / 3.0) : (2.0 / 3.0); + } + else { - param( const QwtSplineParametrization* p ): - parameter( p ) - { - } - - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return parameter->valueIncrement( p1, p2 ); - } - - const QwtSplineParametrization* parameter; - }; - - struct paramUniform + tension.t1 = tension.t2 = d23 / d24; + } + } + else + { + if (b2) { - inline double operator()( const QPointF& p1, const QPointF& p2 ) const - { - return QwtSplineParametrization::valueIncrementUniform( p1, p2 ); - } - }; - - class PathStore + tension.t1 = tension.t2 = d23 / d13; + } + else { - public: - inline void init( int ) - { - } + tension.t1 = d23 / d13; + tension.t2 = d23 / d24; + } + } - inline void start( const QPointF& p0 ) - { - path.moveTo( p0 ); - } - - inline void addCubic( const QPointF& cp1, - const QPointF& cp2, const QPointF& p2 ) - { - path.cubicTo( cp1, cp2, p2 ); - } - - QPainterPath path; - }; - - class ControlPointsStore - { - public: - inline ControlPointsStore(): - m_cp( NULL ) - { - } - - inline void init( int size ) - { - controlPoints.resize( size ); - m_cp = controlPoints.data(); - } - - inline void start( const QPointF& ) - { - } - - inline void addCubic( const QPointF& cp1, - const QPointF& cp2, const QPointF& ) - { - QLineF& l = *m_cp++; - l.setPoints( cp1, cp2 ); - } - - QVector< QLineF > controlPoints; - - private: - QLineF* m_cp; - }; + return tension; } -static inline QwtSplinePleasingP::Tension qwtTensionPleasing( - double d13, double d23, double d24, - const QPointF& p1, const QPointF& p2, - const QPointF& p3, const QPointF& p4 ) +template +static SplineStore qwtSplinePathPleasing(const QPolygonF &points, bool isClosed, + Param param) { - QwtSplinePleasingP::Tension tension; + using namespace QwtSplinePleasingP; - const bool b1 = ( d13 / 3.0 ) < d23; - const bool b2 = ( d24 / 3.0 ) < d23; + const int size = points.size(); - if ( b1 ) - { - if ( b2 ) - { - tension.t1 = ( p1 != p2 ) ? ( 1.0 / 3.0 ) : ( 2.0 / 3.0 ); - tension.t2 = ( p3 != p4 ) ? ( 1.0 / 3.0 ) : ( 2.0 / 3.0 ); - } - else - { - tension.t1 = tension.t2 = d23 / d24; - } - } - else - { - if ( b2 ) - { - tension.t1 = tension.t2 = d23 / d13; - } - else - { - tension.t1 = d23 / d13; - tension.t2 = d23 / d24; - } - } + const QPointF *p = points.constData(); - return tension; -} + SplineStore store; + store.init(isClosed ? size : size - 1); + store.start(p[0]); -template< class SplineStore, class Param > -static SplineStore qwtSplinePathPleasing( const QPolygonF& points, - bool isClosed, Param param ) -{ - using namespace QwtSplinePleasingP; + double d13; + QPointF vec1; - const int size = points.size(); + if (isClosed) + { + d13 = qwtChordalLength(p[0], p[2]); - const QPointF* p = points.constData(); + const Tension t0 = qwtTensionPleasing(qwtChordalLength(p[size - 1], p[1]), + qwtChordalLength(p[0], p[1]), d13, + p[size - 1], p[0], p[1], p[2]); - SplineStore store; - store.init( isClosed ? size : size - 1 ); - store.start( p[0] ); + const QPointF vec0 + = qwtVectorCardinal(param, p[size - 1], p[0], p[1]); + vec1 = qwtVectorCardinal(param, p[0], p[1], p[2]); - double d13; - QPointF vec1; + store.addCubic(p[0] + vec0 * t0.t1, p[1] - vec1 * t0.t2, p[1]); + } + else + { + d13 = qwtChordalLength(p[0], p[2]); - if ( isClosed ) - { - d13 = qwtChordalLength(p[0], p[2]); + const Tension t0 = qwtTensionPleasing(qwtChordalLength(p[0], p[1]), + qwtChordalLength(p[0], p[1]), d13, + p[0], p[0], p[1], p[2]); - const Tension t0 = qwtTensionPleasing( - qwtChordalLength( p[size - 1], p[1]), qwtChordalLength(p[0], p[1]), - d13, p[size - 1], p[0], p[1], p[2] ); + const QPointF vec0 = 0.5 * qwtVector(param, p[0], p[1]); + vec1 = qwtVectorCardinal(param, p[0], p[1], p[2]); - const QPointF vec0 = qwtVectorCardinal< Param >( param, p[size - 1], p[0], p[1] ); - vec1 = qwtVectorCardinal< Param >( param, p[0], p[1], p[2] ); + store.addCubic(p[0] + vec0 * t0.t1, p[1] - vec1 * t0.t2, p[1]); + } - store.addCubic( p[0] + vec0 * t0.t1, p[1] - vec1 * t0.t2, p[1] ); - } - else - { - d13 = qwtChordalLength(p[0], p[2]); + for (int i = 1; i < size - 2; i++) + { + const double d23 = qwtChordalLength(p[i], p[i + 1]); + const double d24 = qwtChordalLength(p[i], p[i + 2]); - const Tension t0 = qwtTensionPleasing( - qwtChordalLength( p[0], p[1]), qwtChordalLength(p[0], p[1]), - d13, p[0], p[0], p[1], p[2] ); + const QPointF vec2 + = qwtVectorCardinal(param, p[i], p[i + 1], p[i + 2]); - const QPointF vec0 = 0.5 * qwtVector< Param >( param, p[0], p[1] ); - vec1 = qwtVectorCardinal< Param >( param, p[0], p[1], p[2] ); + const Tension t + = qwtTensionPleasing(d13, d23, d24, p[i - 1], p[i], p[i + 1], p[i + 2]); - store.addCubic( p[0] + vec0 * t0.t1, p[1] - vec1 * t0.t2, p[1] ); - } + store.addCubic(p[i] + vec1 * t.t1, p[i + 1] - vec2 * t.t2, p[i + 1]); - for ( int i = 1; i < size - 2; i++ ) - { - const double d23 = qwtChordalLength( p[i], p[i + 1] ); - const double d24 = qwtChordalLength( p[i], p[i + 2] ); + d13 = d24; + vec1 = vec2; + } - const QPointF vec2 = qwtVectorCardinal< Param >( param, p[i], p[i + 1], p[i + 2] ); + if (isClosed) + { + const double d24 = qwtChordalLength(p[size - 2], p[0]); - const Tension t = qwtTensionPleasing( - d13, d23, d24, p[i - 1], p[i], p[i + 1], p[i + 2] ); + const Tension tn + = qwtTensionPleasing(d13, qwtChordalLength(p[size - 2], p[size - 1]), + d24, p[size - 3], p[size - 2], p[size - 1], p[0]); - store.addCubic( p[i] + vec1 * t.t1, p[i + 1] - vec2 * t.t2, p[i + 1] ); + const QPointF vec2 + = qwtVectorCardinal(param, p[size - 2], p[size - 1], p[0]); + store.addCubic(p[size - 2] + vec1 * tn.t1, p[size - 1] - vec2 * tn.t2, + p[size - 1]); - d13 = d24; - vec1 = vec2; - } + const double d34 = qwtChordalLength(p[size - 1], p[0]); + const double d35 = qwtChordalLength(p[size - 1], p[1]); - if ( isClosed ) - { - const double d24 = qwtChordalLength( p[size - 2], p[0] ); + const Tension tc = qwtTensionPleasing(d24, d34, d35, p[size - 2], + p[size - 1], p[0], p[1]); - const Tension tn = qwtTensionPleasing( - d13, qwtChordalLength( p[size - 2], p[size - 1] ), d24, - p[size - 3], p[size - 2], p[size - 1], p[0] ); + const QPointF vec3 + = qwtVectorCardinal(param, p[size - 1], p[0], p[1]); - const QPointF vec2 = qwtVectorCardinal< Param >( param, p[size - 2], p[size - 1], p[0] ); - store.addCubic( p[size - 2] + vec1 * tn.t1, p[size - 1] - vec2 * tn.t2, p[size - 1] ); + store.addCubic(p[size - 1] + vec2 * tc.t1, p[0] - vec3 * tc.t2, p[0]); + } + else + { + const double d24 = qwtChordalLength(p[size - 2], p[size - 1]); - const double d34 = qwtChordalLength( p[size - 1], p[0] ); - const double d35 = qwtChordalLength( p[size - 1], p[1] ); + const Tension tn = qwtTensionPleasing( + d13, qwtChordalLength(p[size - 2], p[size - 1]), d24, p[size - 3], + p[size - 2], p[size - 1], p[size - 1]); - const Tension tc = qwtTensionPleasing( d24, d34, d35, p[size - 2], p[size - 1], p[0], p[1] ); + const QPointF vec2 + = 0.5 * qwtVector(param, p[size - 2], p[size - 1]); + store.addCubic(p[size - 2] + vec1 * tn.t1, p[size - 1] - vec2 * tn.t2, + p[size - 1]); + } - const QPointF vec3 = qwtVectorCardinal< Param >( param, p[size - 1], p[0], p[1] ); - - store.addCubic( p[size - 1] + vec2 * tc.t1, p[0] - vec3 * tc.t2, p[0] ); - } - else - { - const double d24 = qwtChordalLength( p[size - 2], p[size - 1] ); - - const Tension tn = qwtTensionPleasing( - d13, qwtChordalLength( p[size - 2], p[size - 1] ), d24, - p[size - 3], p[size - 2], p[size - 1], p[size - 1] ); - - const QPointF vec2 = 0.5 * qwtVector< Param >( param, p[size - 2], p[size - 1] ); - store.addCubic( p[size - 2] + vec1 * tn.t1, p[size - 1] - vec2 * tn.t2, p[size - 1] ); - } - - return store; + return store; } /*! @@ -264,18 +263,16 @@ static SplineStore qwtSplinePathPleasing( const QPolygonF& points, */ QwtSplinePleasing::QwtSplinePleasing() { - setParametrization( QwtSplineParametrization::ParameterUniform ); + setParametrization(QwtSplineParametrization::ParameterUniform); } //! Destructor -QwtSplinePleasing::~QwtSplinePleasing() -{ -} +QwtSplinePleasing::~QwtSplinePleasing() {} //! \return 2 uint QwtSplinePleasing::locality() const { - return 2; + return 2; } /*! @@ -287,32 +284,31 @@ uint QwtSplinePleasing::locality() const \param points Control points \return QPainterPath Painter path, that can be rendered by QPainter */ -QPainterPath QwtSplinePleasing::painterPath( const QPolygonF& points ) const +QPainterPath QwtSplinePleasing::painterPath(const QPolygonF &points) const { - const int size = points.size(); - if ( size <= 2 ) - return QwtSplineG1::painterPath( points ); + const int size = points.size(); + if (size <= 2) + return QwtSplineG1::painterPath(points); - const bool isClosing = ( boundaryType() == QwtSpline::ClosedPolygon ); + const bool isClosing = (boundaryType() == QwtSpline::ClosedPolygon); - using namespace QwtSplinePleasingP; + using namespace QwtSplinePleasingP; - PathStore store; - if ( parametrization()->type() == QwtSplineParametrization::ParameterUniform ) - { - store = qwtSplinePathPleasing< PathStore >( points, - isClosing, paramUniform() ); - } - else - { - store = qwtSplinePathPleasing< PathStore >( points, - isClosing, param( parametrization() ) ); - } + PathStore store; + if (parametrization()->type() == QwtSplineParametrization::ParameterUniform) + { + store = qwtSplinePathPleasing(points, isClosing, paramUniform()); + } + else + { + store = qwtSplinePathPleasing(points, isClosing, + param(parametrization())); + } - if ( isClosing ) - store.path.closeSubpath(); + if (isClosing) + store.path.closeSubpath(); - return store.path; + return store.path; } /*! @@ -324,28 +320,28 @@ QPainterPath QwtSplinePleasing::painterPath( const QPolygonF& points ) const \param points Control points \return Control points of the interpolating Bezier curves */ -QVector< QLineF > QwtSplinePleasing::bezierControlLines( - const QPolygonF& points ) const +QVector +QwtSplinePleasing::bezierControlLines(const QPolygonF &points) const { - const int size = points.size(); - if ( size <= 2 ) - return QVector< QLineF >(); + const int size = points.size(); + if (size <= 2) + return QVector(); - const bool isClosing = ( boundaryType() == QwtSpline::ClosedPolygon ); + const bool isClosing = (boundaryType() == QwtSpline::ClosedPolygon); - using namespace QwtSplinePleasingP; + using namespace QwtSplinePleasingP; - ControlPointsStore store; - if ( parametrization()->type() == QwtSplineParametrization::ParameterUniform ) - { - store = qwtSplinePathPleasing< ControlPointsStore >( points, - isClosing, paramUniform() ); - } - else - { - store = qwtSplinePathPleasing< ControlPointsStore >( points, - isClosing, param( parametrization() ) ); - } + ControlPointsStore store; + if (parametrization()->type() == QwtSplineParametrization::ParameterUniform) + { + store = qwtSplinePathPleasing(points, isClosing, + paramUniform()); + } + else + { + store = qwtSplinePathPleasing(points, isClosing, + param(parametrization())); + } - return store.controlPoints; + return store.controlPoints; } diff --git a/libs/qwt/src/qwt_spline_pleasing.h b/libs/qwt/src/qwt_spline_pleasing.h index 73ec3a3a..56c89870 100644 --- a/libs/qwt/src/qwt_spline_pleasing.h +++ b/libs/qwt/src/qwt_spline_pleasing.h @@ -22,14 +22,15 @@ */ class QWT_EXPORT QwtSplinePleasing : public QwtSplineG1 { - public: - QwtSplinePleasing(); - virtual ~QwtSplinePleasing(); +public: + QwtSplinePleasing(); + virtual ~QwtSplinePleasing(); - virtual uint locality() const QWT_OVERRIDE; + virtual uint locality() const QWT_OVERRIDE; - virtual QPainterPath painterPath( const QPolygonF& ) const QWT_OVERRIDE; - virtual QVector< QLineF > bezierControlLines( const QPolygonF& ) const QWT_OVERRIDE; + virtual QPainterPath painterPath(const QPolygonF &) const QWT_OVERRIDE; + virtual QVector + bezierControlLines(const QPolygonF &) const QWT_OVERRIDE; }; #endif diff --git a/libs/qwt/src/qwt_spline_polynomial.cpp b/libs/qwt/src/qwt_spline_polynomial.cpp index 40695955..6aade427 100644 --- a/libs/qwt/src/qwt_spline_polynomial.cpp +++ b/libs/qwt/src/qwt_spline_polynomial.cpp @@ -11,24 +11,25 @@ namespace { - static const struct RegisterQwtSplinePolynomial - { - inline RegisterQwtSplinePolynomial() - { qRegisterMetaType< QwtSplinePolynomial >(); } +static const struct RegisterQwtSplinePolynomial +{ + inline RegisterQwtSplinePolynomial() + { + qRegisterMetaType(); + } - } qwtRegisterQwtSplinePolynomial; -} +} qwtRegisterQwtSplinePolynomial; +} // namespace #ifndef QT_NO_DEBUG_STREAM -#include +# include -QDebug operator<<( QDebug debug, const QwtSplinePolynomial& polynomial ) +QDebug operator<<(QDebug debug, const QwtSplinePolynomial &polynomial) { - debug.nospace() << "Polynom(" << polynomial.c3 << ", " - << polynomial.c2 << ", " << polynomial.c1 << ")"; - return debug.space(); + debug.nospace() << "Polynom(" << polynomial.c3 << ", " << polynomial.c2 + << ", " << polynomial.c1 << ")"; + return debug.space(); } #endif - diff --git a/libs/qwt/src/qwt_spline_polynomial.h b/libs/qwt/src/qwt_spline_polynomial.h index c0fd5b56..b22958e5 100644 --- a/libs/qwt/src/qwt_spline_polynomial.h +++ b/libs/qwt/src/qwt_spline_polynomial.h @@ -29,43 +29,41 @@ */ class QWT_EXPORT QwtSplinePolynomial { - public: - QwtSplinePolynomial( double c3 = 0.0, double c2 = 0.0, double c1 = 0.0 ); +public: + QwtSplinePolynomial(double c3 = 0.0, double c2 = 0.0, double c1 = 0.0); - bool operator==( const QwtSplinePolynomial& ) const; - bool operator!=( const QwtSplinePolynomial& ) const; + bool operator==(const QwtSplinePolynomial &) const; + bool operator!=(const QwtSplinePolynomial &) const; - double valueAt( double x ) const; - double slopeAt( double x ) const; - double curvatureAt( double x ) const; + double valueAt(double x) const; + double slopeAt(double x) const; + double curvatureAt(double x) const; - static QwtSplinePolynomial fromSlopes( - const QPointF& p1, double m1, - const QPointF& p2, double m2 ); + static QwtSplinePolynomial fromSlopes(const QPointF &p1, double m1, + const QPointF &p2, double m2); - static QwtSplinePolynomial fromSlopes( - double x, double y, double m1, double m2 ); + static QwtSplinePolynomial fromSlopes(double x, double y, double m1, + double m2); - static QwtSplinePolynomial fromCurvatures( - const QPointF& p1, double cv1, - const QPointF& p2, double cv2 ); + static QwtSplinePolynomial fromCurvatures(const QPointF &p1, double cv1, + const QPointF &p2, double cv2); - static QwtSplinePolynomial fromCurvatures( - double dx, double dy, double cv1, double cv2 ); + static QwtSplinePolynomial fromCurvatures(double dx, double dy, double cv1, + double cv2); - public: - //! coefficient of the cubic summand - double c3; +public: + //! coefficient of the cubic summand + double c3; - //! coefficient of the quadratic summand - double c2; + //! coefficient of the quadratic summand + double c2; - //! coefficient of the linear summand - double c1; + //! coefficient of the linear summand + double c1; }; -Q_DECLARE_TYPEINFO( QwtSplinePolynomial, Q_MOVABLE_TYPE ); -Q_DECLARE_METATYPE( QwtSplinePolynomial ) +Q_DECLARE_TYPEINFO(QwtSplinePolynomial, Q_MOVABLE_TYPE); +Q_DECLARE_METATYPE(QwtSplinePolynomial) /*! \brief Constructor @@ -74,10 +72,10 @@ Q_DECLARE_METATYPE( QwtSplinePolynomial ) \param a2 Coefficient of the quadratic summand \param a1 Coefficient of the linear summand */ -inline QwtSplinePolynomial::QwtSplinePolynomial( double a3, double a2, double a1 ) - : c3( a3 ) - , c2( a2 ) - , c1( a1 ) +inline QwtSplinePolynomial::QwtSplinePolynomial(double a3, double a2, double a1) + : c3(a3) + , c2(a2) + , c1(a1) { } @@ -85,18 +83,20 @@ inline QwtSplinePolynomial::QwtSplinePolynomial( double a3, double a2, double a1 \param other Other polynomial \return true, when both polynomials have the same coefficients */ -inline bool QwtSplinePolynomial::operator==( const QwtSplinePolynomial& other ) const +inline bool +QwtSplinePolynomial::operator==(const QwtSplinePolynomial &other) const { - return ( c3 == other.c3 ) && ( c2 == other.c2 ) && ( c1 == other.c1 ); + return (c3 == other.c3) && (c2 == other.c2) && (c1 == other.c1); } /*! \param other Other polynomial \return true, when the polynomials have different coefficients */ -inline bool QwtSplinePolynomial::operator!=( const QwtSplinePolynomial& other ) const +inline bool +QwtSplinePolynomial::operator!=(const QwtSplinePolynomial &other) const { - return ( !( *this == other ) ); + return (!(*this == other)); } /*! @@ -105,9 +105,9 @@ inline bool QwtSplinePolynomial::operator!=( const QwtSplinePolynomial& other ) \param x Parameter \return Value at x */ -inline double QwtSplinePolynomial::valueAt( double x ) const +inline double QwtSplinePolynomial::valueAt(double x) const { - return ( ( ( c3 * x ) + c2 ) * x + c1 ) * x; + return (((c3 * x) + c2) * x + c1) * x; } /*! @@ -116,9 +116,9 @@ inline double QwtSplinePolynomial::valueAt( double x ) const \param x Parameter \return Slope at x */ -inline double QwtSplinePolynomial::slopeAt( double x ) const +inline double QwtSplinePolynomial::slopeAt(double x) const { - return ( 3.0 * c3 * x + 2.0 * c2 ) * x + c1; + return (3.0 * c3 * x + 2.0 * c2) * x + c1; } /*! @@ -127,9 +127,9 @@ inline double QwtSplinePolynomial::slopeAt( double x ) const \param x Parameter \return Curvature at x */ -inline double QwtSplinePolynomial::curvatureAt( double x ) const +inline double QwtSplinePolynomial::curvatureAt(double x) const { - return 6.0 * c3 * x + 2.0 * c2; + return 6.0 * c3 * x + 2.0 * c2; } /*! @@ -144,10 +144,12 @@ inline double QwtSplinePolynomial::curvatureAt( double x ) const \return Coefficients of the polynomials \note The missing constant term of the polynomial is p1.y() */ -inline QwtSplinePolynomial QwtSplinePolynomial::fromSlopes( - const QPointF& p1, double m1, const QPointF& p2, double m2 ) +inline QwtSplinePolynomial QwtSplinePolynomial::fromSlopes(const QPointF &p1, + double m1, + const QPointF &p2, + double m2) { - return fromSlopes( p2.x() - p1.x(), p2.y() - p1.y(), m1, m2 ); + return fromSlopes(p2.x() - p1.x(), p2.y() - p1.y(), m1, m2); } /*! @@ -161,13 +163,13 @@ inline QwtSplinePolynomial QwtSplinePolynomial::fromSlopes( \return Coefficients of the polynomials */ -inline QwtSplinePolynomial QwtSplinePolynomial::fromSlopes( - double dx, double dy, double m1, double m2 ) +inline QwtSplinePolynomial QwtSplinePolynomial::fromSlopes(double dx, double dy, + double m1, double m2) { - const double c2 = ( 3.0 * dy / dx - 2 * m1 - m2 ) / dx; - const double c3 = ( ( m2 - m1 ) / dx - 2.0 * c2 ) / ( 3.0 * dx ); + const double c2 = (3.0 * dy / dx - 2 * m1 - m2) / dx; + const double c3 = ((m2 - m1) / dx - 2.0 * c2) / (3.0 * dx); - return QwtSplinePolynomial( c3, c2, m1 ); + return QwtSplinePolynomial(c3, c2, m1); } /*! @@ -182,10 +184,11 @@ inline QwtSplinePolynomial QwtSplinePolynomial::fromSlopes( \return Coefficients of the polynomials \note The missing constant term of the polynomial is p1.y() */ -inline QwtSplinePolynomial QwtSplinePolynomial::fromCurvatures( - const QPointF& p1, double cv1, const QPointF& p2, double cv2 ) +inline QwtSplinePolynomial +QwtSplinePolynomial::fromCurvatures(const QPointF &p1, double cv1, + const QPointF &p2, double cv2) { - return fromCurvatures( p2.x() - p1.x(), p2.y() - p1.y(), cv1, cv2 ); + return fromCurvatures(p2.x() - p1.x(), p2.y() - p1.y(), cv1, cv2); } /*! @@ -199,20 +202,22 @@ inline QwtSplinePolynomial QwtSplinePolynomial::fromCurvatures( \return Coefficients of the polynomials */ -inline QwtSplinePolynomial QwtSplinePolynomial::fromCurvatures( - double dx, double dy, double cv1, double cv2 ) +inline QwtSplinePolynomial QwtSplinePolynomial::fromCurvatures(double dx, + double dy, + double cv1, + double cv2) { - const double c3 = ( cv2 - cv1 ) / ( 6.0 * dx ); - const double c2 = 0.5 * cv1; - const double c1 = dy / dx - ( c3 * dx + c2 ) * dx; + const double c3 = (cv2 - cv1) / (6.0 * dx); + const double c2 = 0.5 * cv1; + const double c1 = dy / dx - (c3 * dx + c2) * dx; - return QwtSplinePolynomial( c3, c2, c1 ); + return QwtSplinePolynomial(c3, c2, c1); } #ifndef QT_NO_DEBUG_STREAM class QDebug; -QWT_EXPORT QDebug operator<<( QDebug, const QwtSplinePolynomial& ); +QWT_EXPORT QDebug operator<<(QDebug, const QwtSplinePolynomial &); #endif diff --git a/libs/qwt/src/qwt_symbol.cpp b/libs/qwt/src/qwt_symbol.cpp index f1c7ac73..96d45e4a 100644 --- a/libs/qwt/src/qwt_symbol.cpp +++ b/libs/qwt/src/qwt_symbol.cpp @@ -17,820 +17,810 @@ #include #include #ifndef QWT_NO_SVG -#include +# include #endif namespace QwtTriangle { - enum Type - { - Left, - Right, - Up, - Down - }; +enum Type +{ + Left, + Right, + Up, + Down +}; } -static QwtGraphic qwtPathGraphic( const QPainterPath& path, - const QPen& pen, const QBrush& brush ) +static QwtGraphic qwtPathGraphic(const QPainterPath &path, const QPen &pen, + const QBrush &brush) { - QwtGraphic graphic; - graphic.setRenderHint( QwtGraphic::RenderPensUnscaled ); + QwtGraphic graphic; + graphic.setRenderHint(QwtGraphic::RenderPensUnscaled); - QPainter painter( &graphic ); - painter.setPen( pen ); - painter.setBrush( brush ); - painter.drawPath( path ); - painter.end(); + QPainter painter(&graphic); + painter.setPen(pen); + painter.setBrush(brush); + painter.drawPath(path); + painter.end(); - return graphic; + return graphic; } -static inline QRectF qwtScaledBoundingRect( - const QwtGraphic& graphic, const QSizeF size ) +static inline QRectF qwtScaledBoundingRect(const QwtGraphic &graphic, + const QSizeF size) { - QSizeF scaledSize = size; - if ( scaledSize.isEmpty() ) - scaledSize = graphic.defaultSize(); + QSizeF scaledSize = size; + if (scaledSize.isEmpty()) + scaledSize = graphic.defaultSize(); - const QSizeF sz = graphic.controlPointRect().size(); + const QSizeF sz = graphic.controlPointRect().size(); - double sx = 1.0; - if ( sz.width() > 0.0 ) - sx = scaledSize.width() / sz.width(); + double sx = 1.0; + if (sz.width() > 0.0) + sx = scaledSize.width() / sz.width(); - double sy = 1.0; - if ( sz.height() > 0.0 ) - sy = scaledSize.height() / sz.height(); + double sy = 1.0; + if (sz.height() > 0.0) + sy = scaledSize.height() / sz.height(); - return graphic.scaledBoundingRect( sx, sy ); + return graphic.scaledBoundingRect(sx, sy); } -static inline void qwtDrawPixmapSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawPixmapSymbols(QPainter *painter, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - QSize size = symbol.size(); - if ( size.isEmpty() ) - size = symbol.pixmap().size(); + QSize size = symbol.size(); + if (size.isEmpty()) + size = symbol.pixmap().size(); - const QTransform transform = painter->transform(); - if ( transform.isScaling() ) - { - const QRect r( 0, 0, size.width(), size.height() ); - size = transform.mapRect( r ).size(); - } + const QTransform transform = painter->transform(); + if (transform.isScaling()) + { + const QRect r(0, 0, size.width(), size.height()); + size = transform.mapRect(r).size(); + } - QPixmap pm = symbol.pixmap(); - if ( pm.size() != size ) - pm = pm.scaled( size ); + QPixmap pm = symbol.pixmap(); + if (pm.size() != size) + pm = pm.scaled(size); - QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() ); - if ( symbol.isPinPointEnabled() ) - pinPoint = symbol.pinPoint(); + QPointF pinPoint(0.5 * size.width(), 0.5 * size.height()); + if (symbol.isPinPointEnabled()) + pinPoint = symbol.pinPoint(); - painter->resetTransform(); + painter->resetTransform(); - for ( int i = 0; i < numPoints; i++ ) - { - const QPointF pos = transform.map( points[i] ) - pinPoint; + for (int i = 0; i < numPoints; i++) + { + const QPointF pos = transform.map(points[i]) - pinPoint; - QwtPainter::drawPixmap( painter, - QRect( pos.toPoint(), pm.size() ), pm ); - } + QwtPainter::drawPixmap(painter, QRect(pos.toPoint(), pm.size()), pm); + } } #ifndef QWT_NO_SVG -static inline void qwtDrawSvgSymbols( QPainter* painter, - const QPointF* points, int numPoints, - QSvgRenderer* renderer, const QwtSymbol& symbol ) +static inline void qwtDrawSvgSymbols(QPainter *painter, const QPointF *points, + int numPoints, QSvgRenderer *renderer, + const QwtSymbol &symbol) { - if ( renderer == NULL || !renderer->isValid() ) - return; + if (renderer == NULL || !renderer->isValid()) + return; - const QRectF viewBox = renderer->viewBoxF(); - if ( viewBox.isEmpty() ) - return; + const QRectF viewBox = renderer->viewBoxF(); + if (viewBox.isEmpty()) + return; - QSizeF sz = symbol.size(); - if ( !sz.isValid() ) - sz = viewBox.size(); + QSizeF sz = symbol.size(); + if (!sz.isValid()) + sz = viewBox.size(); - const double sx = sz.width() / viewBox.width(); - const double sy = sz.height() / viewBox.height(); + const double sx = sz.width() / viewBox.width(); + const double sy = sz.height() / viewBox.height(); - QPointF pinPoint = viewBox.center(); - if ( symbol.isPinPointEnabled() ) - pinPoint = symbol.pinPoint(); + QPointF pinPoint = viewBox.center(); + if (symbol.isPinPointEnabled()) + pinPoint = symbol.pinPoint(); - const double dx = sx * ( pinPoint.x() - viewBox.left() ); - const double dy = sy * ( pinPoint.y() - viewBox.top() ); + const double dx = sx * (pinPoint.x() - viewBox.left()); + const double dy = sy * (pinPoint.y() - viewBox.top()); - for ( int i = 0; i < numPoints; i++ ) - { - const double x = points[i].x() - dx; - const double y = points[i].y() - dy; + for (int i = 0; i < numPoints; i++) + { + const double x = points[i].x() - dx; + const double y = points[i].y() - dy; - renderer->render( painter, - QRectF( x, y, sz.width(), sz.height() ) ); - } + renderer->render(painter, QRectF(x, y, sz.width(), sz.height())); + } } #endif -static inline void qwtDrawGraphicSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtGraphic& graphic, - const QwtSymbol& symbol ) +static inline void qwtDrawGraphicSymbols(QPainter *painter, + const QPointF *points, int numPoints, + const QwtGraphic &graphic, + const QwtSymbol &symbol) { - const QRectF pointRect = graphic.controlPointRect(); - if ( pointRect.isEmpty() ) - return; + const QRectF pointRect = graphic.controlPointRect(); + if (pointRect.isEmpty()) + return; - double sx = 1.0; - double sy = 1.0; + double sx = 1.0; + double sy = 1.0; - const QSize sz = symbol.size(); - if ( sz.isValid() ) - { - sx = sz.width() / pointRect.width(); - sy = sz.height() / pointRect.height(); - } + const QSize sz = symbol.size(); + if (sz.isValid()) + { + sx = sz.width() / pointRect.width(); + sy = sz.height() / pointRect.height(); + } - QPointF pinPoint = pointRect.center(); - if ( symbol.isPinPointEnabled() ) - pinPoint = symbol.pinPoint(); + QPointF pinPoint = pointRect.center(); + if (symbol.isPinPointEnabled()) + pinPoint = symbol.pinPoint(); - const QTransform transform = painter->transform(); + const QTransform transform = painter->transform(); - for ( int i = 0; i < numPoints; i++ ) - { - QTransform tr = transform; - tr.translate( points[i].x(), points[i].y() ); - tr.scale( sx, sy ); - tr.translate( -pinPoint.x(), -pinPoint.y() ); + for (int i = 0; i < numPoints; i++) + { + QTransform tr = transform; + tr.translate(points[i].x(), points[i].y()); + tr.scale(sx, sy); + tr.translate(-pinPoint.x(), -pinPoint.y()); - painter->setTransform( tr ); + painter->setTransform(tr); - graphic.render( painter ); - } + graphic.render(painter); + } - painter->setTransform( transform ); + painter->setTransform(transform); } -static inline void qwtDrawEllipseSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawEllipseSymbols(QPainter *painter, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - painter->setBrush( symbol.brush() ); - painter->setPen( symbol.pen() ); + painter->setBrush(symbol.brush()); + painter->setPen(symbol.pen()); - const QSize size = symbol.size(); + const QSize size = symbol.size(); - if ( QwtPainter::roundingAlignment( painter ) ) + if (QwtPainter::roundingAlignment(painter)) + { + const int sw = size.width(); + const int sh = size.height(); + const int sw2 = size.width() / 2; + const int sh2 = size.height() / 2; + + for (int i = 0; i < numPoints; i++) { - const int sw = size.width(); - const int sh = size.height(); - const int sw2 = size.width() / 2; - const int sh2 = size.height() / 2; + const int x = qRound(points[i].x()); + const int y = qRound(points[i].y()); - for ( int i = 0; i < numPoints; i++ ) - { - const int x = qRound( points[i].x() ); - const int y = qRound( points[i].y() ); - - const QRectF r( x - sw2, y - sh2, sw, sh ); - QwtPainter::drawEllipse( painter, r ); - } + const QRectF r(x - sw2, y - sh2, sw, sh); + QwtPainter::drawEllipse(painter, r); } - else + } + else + { + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); + + for (int i = 0; i < numPoints; i++) { - const double sw = size.width(); - const double sh = size.height(); - const double sw2 = 0.5 * size.width(); - const double sh2 = 0.5 * size.height(); + const double x = points[i].x(); + const double y = points[i].y(); - for ( int i = 0; i < numPoints; i++ ) - { - const double x = points[i].x(); - const double y = points[i].y(); - - const QRectF r( x - sw2, y - sh2, sw, sh ); - QwtPainter::drawEllipse( painter, r ); - } + const QRectF r(x - sw2, y - sh2, sw, sh); + QwtPainter::drawEllipse(painter, r); } + } } -static inline void qwtDrawRectSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawRectSymbols(QPainter *painter, const QPointF *points, + int numPoints, const QwtSymbol &symbol) { - const QSize size = symbol.size(); + const QSize size = symbol.size(); - QPen pen = symbol.pen(); - pen.setJoinStyle( Qt::MiterJoin ); - painter->setPen( pen ); - painter->setBrush( symbol.brush() ); - painter->setRenderHint( QPainter::Antialiasing, false ); + QPen pen = symbol.pen(); + pen.setJoinStyle(Qt::MiterJoin); + painter->setPen(pen); + painter->setBrush(symbol.brush()); + painter->setRenderHint(QPainter::Antialiasing, false); - if ( QwtPainter::roundingAlignment( painter ) ) + if (QwtPainter::roundingAlignment(painter)) + { + const int sw = size.width(); + const int sh = size.height(); + const int sw2 = size.width() / 2; + const int sh2 = size.height() / 2; + + for (int i = 0; i < numPoints; i++) { - const int sw = size.width(); - const int sh = size.height(); - const int sw2 = size.width() / 2; - const int sh2 = size.height() / 2; + const int x = qRound(points[i].x()); + const int y = qRound(points[i].y()); - for ( int i = 0; i < numPoints; i++ ) - { - const int x = qRound( points[i].x() ); - const int y = qRound( points[i].y() ); - - const QRect r( x - sw2, y - sh2, sw, sh ); - QwtPainter::drawRect( painter, r ); - } + const QRect r(x - sw2, y - sh2, sw, sh); + QwtPainter::drawRect(painter, r); } - else + } + else + { + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); + + for (int i = 0; i < numPoints; i++) { - const double sw = size.width(); - const double sh = size.height(); - const double sw2 = 0.5 * size.width(); - const double sh2 = 0.5 * size.height(); + const double x = points[i].x(); + const double y = points[i].y(); - for ( int i = 0; i < numPoints; i++ ) - { - const double x = points[i].x(); - const double y = points[i].y(); - - const QRectF r( x - sw2, y - sh2, sw, sh ); - QwtPainter::drawRect( painter, r ); - } + const QRectF r(x - sw2, y - sh2, sw, sh); + QwtPainter::drawRect(painter, r); } + } } -static inline void qwtDrawDiamondSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawDiamondSymbols(QPainter *painter, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - const QSize size = symbol.size(); + const QSize size = symbol.size(); - QPen pen = symbol.pen(); - pen.setJoinStyle( Qt::MiterJoin ); - painter->setPen( pen ); - painter->setBrush( symbol.brush() ); + QPen pen = symbol.pen(); + pen.setJoinStyle(Qt::MiterJoin); + painter->setPen(pen); + painter->setBrush(symbol.brush()); - if ( QwtPainter::roundingAlignment( painter ) ) + if (QwtPainter::roundingAlignment(painter)) + { + for (int i = 0; i < numPoints; i++) { - for ( int i = 0; i < numPoints; i++ ) - { - const int x = qRound( points[i].x() ); - const int y = qRound( points[i].y() ); + const int x = qRound(points[i].x()); + const int y = qRound(points[i].y()); - const int x1 = x - size.width() / 2; - const int y1 = y - size.height() / 2; - const int x2 = x1 + size.width(); - const int y2 = y1 + size.height(); + const int x1 = x - size.width() / 2; + const int y1 = y - size.height() / 2; + const int x2 = x1 + size.width(); + const int y2 = y1 + size.height(); - QPolygonF polygon; - polygon += QPointF( x, y1 ); - polygon += QPointF( x1, y ); - polygon += QPointF( x, y2 ); - polygon += QPointF( x2, y ); + QPolygonF polygon; + polygon += QPointF(x, y1); + polygon += QPointF(x1, y); + polygon += QPointF(x, y2); + polygon += QPointF(x2, y); - QwtPainter::drawPolygon( painter, polygon ); - } + QwtPainter::drawPolygon(painter, polygon); } - else + } + else + { + for (int i = 0; i < numPoints; i++) { - for ( int i = 0; i < numPoints; i++ ) - { - const QPointF& pos = points[i]; + const QPointF &pos = points[i]; - const double x1 = pos.x() - 0.5 * size.width(); - const double y1 = pos.y() - 0.5 * size.height(); - const double x2 = x1 + size.width(); - const double y2 = y1 + size.height(); + const double x1 = pos.x() - 0.5 * size.width(); + const double y1 = pos.y() - 0.5 * size.height(); + const double x2 = x1 + size.width(); + const double y2 = y1 + size.height(); - QPolygonF polygon; - polygon += QPointF( pos.x(), y1 ); - polygon += QPointF( x2, pos.y() ); - polygon += QPointF( pos.x(), y2 ); - polygon += QPointF( x1, pos.y() ); + QPolygonF polygon; + polygon += QPointF(pos.x(), y1); + polygon += QPointF(x2, pos.y()); + polygon += QPointF(pos.x(), y2); + polygon += QPointF(x1, pos.y()); - QwtPainter::drawPolygon( painter, polygon ); - } + QwtPainter::drawPolygon(painter, polygon); } + } } -static inline void qwtDrawTriangleSymbols( - QPainter* painter, QwtTriangle::Type type, - const QPointF* points, int numPoints, - const QwtSymbol& symbol ) +static inline void qwtDrawTriangleSymbols(QPainter *painter, + QwtTriangle::Type type, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - const QSize size = symbol.size(); + const QSize size = symbol.size(); - QPen pen = symbol.pen(); - pen.setJoinStyle( Qt::MiterJoin ); - painter->setPen( pen ); + QPen pen = symbol.pen(); + pen.setJoinStyle(Qt::MiterJoin); + painter->setPen(pen); - painter->setBrush( symbol.brush() ); + painter->setBrush(symbol.brush()); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - double sw2 = 0.5 * size.width(); - double sh2 = 0.5 * size.height(); + double sw2 = 0.5 * size.width(); + double sh2 = 0.5 * size.height(); - if ( doAlign ) + if (doAlign) + { + sw2 = std::floor(sw2); + sh2 = std::floor(sh2); + } + + QPolygonF triangle(3); + QPointF *trianglePoints = triangle.data(); + + for (int i = 0; i < numPoints; i++) + { + const QPointF &pos = points[i]; + + double x = pos.x(); + double y = pos.y(); + + if (doAlign) { - sw2 = std::floor( sw2 ); - sh2 = std::floor( sh2 ); + x = qRound(x); + y = qRound(y); } - QPolygonF triangle( 3 ); - QPointF* trianglePoints = triangle.data(); + const double x1 = x - sw2; + const double x2 = x1 + size.width(); + const double y1 = y - sh2; + const double y2 = y1 + size.height(); - for ( int i = 0; i < numPoints; i++ ) + switch (type) { - const QPointF& pos = points[i]; + case QwtTriangle::Left: { + trianglePoints[0].rx() = x2; + trianglePoints[0].ry() = y1; - double x = pos.x(); - double y = pos.y(); + trianglePoints[1].rx() = x1; + trianglePoints[1].ry() = y; - if ( doAlign ) - { - x = qRound( x ); - y = qRound( y ); - } + trianglePoints[2].rx() = x2; + trianglePoints[2].ry() = y2; - const double x1 = x - sw2; - const double x2 = x1 + size.width(); - const double y1 = y - sh2; - const double y2 = y1 + size.height(); + break; + } + case QwtTriangle::Right: { + trianglePoints[0].rx() = x1; + trianglePoints[0].ry() = y1; - switch ( type ) - { - case QwtTriangle::Left: - { - trianglePoints[0].rx() = x2; - trianglePoints[0].ry() = y1; + trianglePoints[1].rx() = x2; + trianglePoints[1].ry() = y; - trianglePoints[1].rx() = x1; - trianglePoints[1].ry() = y; + trianglePoints[2].rx() = x1; + trianglePoints[2].ry() = y2; - trianglePoints[2].rx() = x2; - trianglePoints[2].ry() = y2; + break; + } + case QwtTriangle::Up: { + trianglePoints[0].rx() = x1; + trianglePoints[0].ry() = y2; - break; - } - case QwtTriangle::Right: - { - trianglePoints[0].rx() = x1; - trianglePoints[0].ry() = y1; + trianglePoints[1].rx() = x; + trianglePoints[1].ry() = y1; - trianglePoints[1].rx() = x2; - trianglePoints[1].ry() = y; + trianglePoints[2].rx() = x2; + trianglePoints[2].ry() = y2; - trianglePoints[2].rx() = x1; - trianglePoints[2].ry() = y2; + break; + } + case QwtTriangle::Down: { + trianglePoints[0].rx() = x1; + trianglePoints[0].ry() = y1; - break; - } - case QwtTriangle::Up: - { - trianglePoints[0].rx() = x1; - trianglePoints[0].ry() = y2; + trianglePoints[1].rx() = x; + trianglePoints[1].ry() = y2; - trianglePoints[1].rx() = x; - trianglePoints[1].ry() = y1; + trianglePoints[2].rx() = x2; + trianglePoints[2].ry() = y1; - trianglePoints[2].rx() = x2; - trianglePoints[2].ry() = y2; - - break; - } - case QwtTriangle::Down: - { - trianglePoints[0].rx() = x1; - trianglePoints[0].ry() = y1; - - trianglePoints[1].rx() = x; - trianglePoints[1].ry() = y2; - - trianglePoints[2].rx() = x2; - trianglePoints[2].ry() = y1; - - break; - } - } - QwtPainter::drawPolygon( painter, triangle ); + break; + } } + QwtPainter::drawPolygon(painter, triangle); + } } -static inline void qwtDrawLineSymbols( - QPainter* painter, int orientations, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawLineSymbols(QPainter *painter, int orientations, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - const QSize size = symbol.size(); + const QSize size = symbol.size(); - int off = 0; + int off = 0; - QPen pen = symbol.pen(); - if ( pen.width() > 1 ) + QPen pen = symbol.pen(); + if (pen.width() > 1) + { + pen.setCapStyle(Qt::FlatCap); + off = 1; + } + + painter->setPen(pen); + painter->setRenderHint(QPainter::Antialiasing, false); + + if (QwtPainter::roundingAlignment(painter)) + { + const int sw = qwtFloor(size.width()); + const int sh = qwtFloor(size.height()); + const int sw2 = size.width() / 2; + const int sh2 = size.height() / 2; + + for (int i = 0; i < numPoints; i++) { - pen.setCapStyle( Qt::FlatCap ); - off = 1; + if (orientations & Qt::Horizontal) + { + const int x = qRound(points[i].x()) - sw2; + const int y = qRound(points[i].y()); + + QwtPainter::drawLine(painter, x, y, x + sw + off, y); + } + if (orientations & Qt::Vertical) + { + const int x = qRound(points[i].x()); + const int y = qRound(points[i].y()) - sh2; + + QwtPainter::drawLine(painter, x, y, x, y + sh + off); + } } + } + else + { + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); - painter->setPen( pen ); - painter->setRenderHint( QPainter::Antialiasing, false ); - - if ( QwtPainter::roundingAlignment( painter ) ) + for (int i = 0; i < numPoints; i++) { - const int sw = qwtFloor( size.width() ); - const int sh = qwtFloor( size.height() ); - const int sw2 = size.width() / 2; - const int sh2 = size.height() / 2; + if (orientations & Qt::Horizontal) + { + const double x = points[i].x() - sw2; + const double y = points[i].y(); - for ( int i = 0; i < numPoints; i++ ) - { - if ( orientations & Qt::Horizontal ) - { - const int x = qRound( points[i].x() ) - sw2; - const int y = qRound( points[i].y() ); + QwtPainter::drawLine(painter, x, y, x + sw, y); + } + if (orientations & Qt::Vertical) + { + const double y = points[i].y() - sh2; + const double x = points[i].x(); - QwtPainter::drawLine( painter, x, y, x + sw + off, y ); - } - if ( orientations & Qt::Vertical ) - { - const int x = qRound( points[i].x() ); - const int y = qRound( points[i].y() ) - sh2; - - QwtPainter::drawLine( painter, x, y, x, y + sh + off ); - } - } - } - else - { - const double sw = size.width(); - const double sh = size.height(); - const double sw2 = 0.5 * size.width(); - const double sh2 = 0.5 * size.height(); - - for ( int i = 0; i < numPoints; i++ ) - { - if ( orientations & Qt::Horizontal ) - { - const double x = points[i].x() - sw2; - const double y = points[i].y(); - - QwtPainter::drawLine( painter, x, y, x + sw, y ); - } - if ( orientations & Qt::Vertical ) - { - const double y = points[i].y() - sh2; - const double x = points[i].x(); - - QwtPainter::drawLine( painter, x, y, x, y + sh ); - } - } + QwtPainter::drawLine(painter, x, y, x, y + sh); + } } + } } -static inline void qwtDrawXCrossSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawXCrossSymbols(QPainter *painter, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - const QSize size = symbol.size(); - int off = 0; + const QSize size = symbol.size(); + int off = 0; - QPen pen = symbol.pen(); - if ( pen.width() > 1 ) + QPen pen = symbol.pen(); + if (pen.width() > 1) + { + pen.setCapStyle(Qt::FlatCap); + off = 1; + } + painter->setPen(pen); + + if (QwtPainter::roundingAlignment(painter)) + { + const int sw = size.width(); + const int sh = size.height(); + const int sw2 = size.width() / 2; + const int sh2 = size.height() / 2; + + for (int i = 0; i < numPoints; i++) { - pen.setCapStyle( Qt::FlatCap ); - off = 1; + const QPointF &pos = points[i]; + + const int x = qRound(pos.x()); + const int y = qRound(pos.y()); + + const int x1 = x - sw2; + const int x2 = x1 + sw + off; + const int y1 = y - sh2; + const int y2 = y1 + sh + off; + + QwtPainter::drawLine(painter, x1, y1, x2, y2); + QwtPainter::drawLine(painter, x2, y1, x1, y2); } - painter->setPen( pen ); + } + else + { + const double sw = size.width(); + const double sh = size.height(); + const double sw2 = 0.5 * size.width(); + const double sh2 = 0.5 * size.height(); - - if ( QwtPainter::roundingAlignment( painter ) ) + for (int i = 0; i < numPoints; i++) { - const int sw = size.width(); - const int sh = size.height(); - const int sw2 = size.width() / 2; - const int sh2 = size.height() / 2; + const QPointF &pos = points[i]; - for ( int i = 0; i < numPoints; i++ ) - { - const QPointF& pos = points[i]; + const double x1 = pos.x() - sw2; + const double x2 = x1 + sw; + const double y1 = pos.y() - sh2; + const double y2 = y1 + sh; - const int x = qRound( pos.x() ); - const int y = qRound( pos.y() ); - - const int x1 = x - sw2; - const int x2 = x1 + sw + off; - const int y1 = y - sh2; - const int y2 = y1 + sh + off; - - QwtPainter::drawLine( painter, x1, y1, x2, y2 ); - QwtPainter::drawLine( painter, x2, y1, x1, y2 ); - } - } - else - { - const double sw = size.width(); - const double sh = size.height(); - const double sw2 = 0.5 * size.width(); - const double sh2 = 0.5 * size.height(); - - for ( int i = 0; i < numPoints; i++ ) - { - const QPointF& pos = points[i]; - - const double x1 = pos.x() - sw2; - const double x2 = x1 + sw; - const double y1 = pos.y() - sh2; - const double y2 = y1 + sh; - - QwtPainter::drawLine( painter, x1, y1, x2, y2 ); - QwtPainter::drawLine( painter, x1, y2, x2, y1 ); - } + QwtPainter::drawLine(painter, x1, y1, x2, y2); + QwtPainter::drawLine(painter, x1, y2, x2, y1); } + } } -static inline void qwtDrawStar1Symbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawStar1Symbols(QPainter *painter, const QPointF *points, + int numPoints, const QwtSymbol &symbol) { - const QSize size = symbol.size(); - painter->setPen( symbol.pen() ); + const QSize size = symbol.size(); + painter->setPen(symbol.pen()); - if ( QwtPainter::roundingAlignment( painter ) ) + if (QwtPainter::roundingAlignment(painter)) + { + QRect r(0, 0, size.width(), size.height()); + + for (int i = 0; i < numPoints; i++) { - QRect r( 0, 0, size.width(), size.height() ); + r.moveCenter(points[i].toPoint()); - for ( int i = 0; i < numPoints; i++ ) - { - r.moveCenter( points[i].toPoint() ); + const double sqrt1_2 = 0.70710678118654752440; /* 1/sqrt(2) */ - const double sqrt1_2 = 0.70710678118654752440; /* 1/sqrt(2) */ + const double d1 = r.width() / 2.0 * (1.0 - sqrt1_2); - const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 ); + QwtPainter::drawLine(painter, qRound(r.left() + d1), qRound(r.top() + d1), + qRound(r.right() - d1), qRound(r.bottom() - d1)); + QwtPainter::drawLine(painter, qRound(r.left() + d1), + qRound(r.bottom() - d1), qRound(r.right() - d1), + qRound(r.top() + d1)); - QwtPainter::drawLine( painter, - qRound( r.left() + d1 ), qRound( r.top() + d1 ), - qRound( r.right() - d1 ), qRound( r.bottom() - d1 ) ); - QwtPainter::drawLine( painter, - qRound( r.left() + d1 ), qRound( r.bottom() - d1 ), - qRound( r.right() - d1), qRound( r.top() + d1 ) ); + const QPoint c = r.center(); - const QPoint c = r.center(); - - QwtPainter::drawLine( painter, - c.x(), r.top(), c.x(), r.bottom() ); - QwtPainter::drawLine( painter, - r.left(), c.y(), r.right(), c.y() ); - } + QwtPainter::drawLine(painter, c.x(), r.top(), c.x(), r.bottom()); + QwtPainter::drawLine(painter, r.left(), c.y(), r.right(), c.y()); } - else + } + else + { + QRectF r(0, 0, size.width(), size.height()); + + for (int i = 0; i < numPoints; i++) { - QRectF r( 0, 0, size.width(), size.height() ); + r.moveCenter(points[i]); - for ( int i = 0; i < numPoints; i++ ) - { - r.moveCenter( points[i] ); + const double sqrt1_2 = 0.70710678118654752440; /* 1/sqrt(2) */ - const double sqrt1_2 = 0.70710678118654752440; /* 1/sqrt(2) */ + const QPointF c = r.center(); + const double d1 = r.width() / 2.0 * (1.0 - sqrt1_2); - const QPointF c = r.center(); - const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 ); - - QwtPainter::drawLine( painter, - r.left() + d1, r.top() + d1, - r.right() - d1, r.bottom() - d1 ); - QwtPainter::drawLine( painter, - r.left() + d1, r.bottom() - d1, - r.right() - d1, r.top() + d1 ); - QwtPainter::drawLine( painter, - c.x(), r.top(), - c.x(), r.bottom() ); - QwtPainter::drawLine( painter, - r.left(), c.y(), - r.right(), c.y() ); - } + QwtPainter::drawLine(painter, r.left() + d1, r.top() + d1, r.right() - d1, + r.bottom() - d1); + QwtPainter::drawLine(painter, r.left() + d1, r.bottom() - d1, + r.right() - d1, r.top() + d1); + QwtPainter::drawLine(painter, c.x(), r.top(), c.x(), r.bottom()); + QwtPainter::drawLine(painter, r.left(), c.y(), r.right(), c.y()); } + } } -static inline void qwtDrawStar2Symbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawStar2Symbols(QPainter *painter, const QPointF *points, + int numPoints, const QwtSymbol &symbol) { - QPen pen = symbol.pen(); - if ( pen.width() > 1 ) - pen.setCapStyle( Qt::FlatCap ); - pen.setJoinStyle( Qt::MiterJoin ); - painter->setPen( pen ); + QPen pen = symbol.pen(); + if (pen.width() > 1) + pen.setCapStyle(Qt::FlatCap); + pen.setJoinStyle(Qt::MiterJoin); + painter->setPen(pen); - painter->setBrush( symbol.brush() ); + painter->setBrush(symbol.brush()); - const double cos30 = 0.866025; // cos(30°) + const double cos30 = 0.866025; // cos(30°) - const double dy = 0.25 * symbol.size().height(); - const double dx = 0.5 * symbol.size().width() * cos30 / 3.0; + const double dy = 0.25 * symbol.size().height(); + const double dx = 0.5 * symbol.size().width() * cos30 / 3.0; - QPolygonF star( 12 ); - QPointF* starPoints = star.data(); + QPolygonF star(12); + QPointF *starPoints = star.data(); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - for ( int i = 0; i < numPoints; i++ ) + for (int i = 0; i < numPoints; i++) + { + double x = points[i].x(); + double y = points[i].y(); + if (doAlign) { - double x = points[i].x(); - double y = points[i].y(); - if ( doAlign ) - { - x = qRound( x ); - y = qRound( y ); - } - - double x1 = x - 3 * dx; - double y1 = y - 2 * dy; - if ( doAlign ) - { - x1 = qRound( x - 3 * dx ); - y1 = qRound( y - 2 * dy ); - } - - const double x2 = x1 + 1 * dx; - const double x3 = x1 + 2 * dx; - const double x4 = x1 + 3 * dx; - const double x5 = x1 + 4 * dx; - const double x6 = x1 + 5 * dx; - const double x7 = x1 + 6 * dx; - - const double y2 = y1 + 1 * dy; - const double y3 = y1 + 2 * dy; - const double y4 = y1 + 3 * dy; - const double y5 = y1 + 4 * dy; - - starPoints[0].rx() = x4; - starPoints[0].ry() = y1; - - starPoints[1].rx() = x5; - starPoints[1].ry() = y2; - - starPoints[2].rx() = x7; - starPoints[2].ry() = y2; - - starPoints[3].rx() = x6; - starPoints[3].ry() = y3; - - starPoints[4].rx() = x7; - starPoints[4].ry() = y4; - - starPoints[5].rx() = x5; - starPoints[5].ry() = y4; - - starPoints[6].rx() = x4; - starPoints[6].ry() = y5; - - starPoints[7].rx() = x3; - starPoints[7].ry() = y4; - - starPoints[8].rx() = x1; - starPoints[8].ry() = y4; - - starPoints[9].rx() = x2; - starPoints[9].ry() = y3; - - starPoints[10].rx() = x1; - starPoints[10].ry() = y2; - - starPoints[11].rx() = x3; - starPoints[11].ry() = y2; - - QwtPainter::drawPolygon( painter, star ); + x = qRound(x); + y = qRound(y); } + + double x1 = x - 3 * dx; + double y1 = y - 2 * dy; + if (doAlign) + { + x1 = qRound(x - 3 * dx); + y1 = qRound(y - 2 * dy); + } + + const double x2 = x1 + 1 * dx; + const double x3 = x1 + 2 * dx; + const double x4 = x1 + 3 * dx; + const double x5 = x1 + 4 * dx; + const double x6 = x1 + 5 * dx; + const double x7 = x1 + 6 * dx; + + const double y2 = y1 + 1 * dy; + const double y3 = y1 + 2 * dy; + const double y4 = y1 + 3 * dy; + const double y5 = y1 + 4 * dy; + + starPoints[0].rx() = x4; + starPoints[0].ry() = y1; + + starPoints[1].rx() = x5; + starPoints[1].ry() = y2; + + starPoints[2].rx() = x7; + starPoints[2].ry() = y2; + + starPoints[3].rx() = x6; + starPoints[3].ry() = y3; + + starPoints[4].rx() = x7; + starPoints[4].ry() = y4; + + starPoints[5].rx() = x5; + starPoints[5].ry() = y4; + + starPoints[6].rx() = x4; + starPoints[6].ry() = y5; + + starPoints[7].rx() = x3; + starPoints[7].ry() = y4; + + starPoints[8].rx() = x1; + starPoints[8].ry() = y4; + + starPoints[9].rx() = x2; + starPoints[9].ry() = y3; + + starPoints[10].rx() = x1; + starPoints[10].ry() = y2; + + starPoints[11].rx() = x3; + starPoints[11].ry() = y2; + + QwtPainter::drawPolygon(painter, star); + } } -static inline void qwtDrawHexagonSymbols( QPainter* painter, - const QPointF* points, int numPoints, const QwtSymbol& symbol ) +static inline void qwtDrawHexagonSymbols(QPainter *painter, + const QPointF *points, int numPoints, + const QwtSymbol &symbol) { - painter->setBrush( symbol.brush() ); - painter->setPen( symbol.pen() ); + painter->setBrush(symbol.brush()); + painter->setPen(symbol.pen()); - const double cos30 = 0.866025; // cos(30°) - const double dx = 0.5 * ( symbol.size().width() - cos30 ); + const double cos30 = 0.866025; // cos(30°) + const double dx = 0.5 * (symbol.size().width() - cos30); - const double dy = 0.25 * symbol.size().height(); + const double dy = 0.25 * symbol.size().height(); - QPolygonF hexaPolygon( 6 ); - QPointF* hexaPoints = hexaPolygon.data(); + QPolygonF hexaPolygon(6); + QPointF *hexaPoints = hexaPolygon.data(); - const bool doAlign = QwtPainter::roundingAlignment( painter ); + const bool doAlign = QwtPainter::roundingAlignment(painter); - for ( int i = 0; i < numPoints; i++ ) + for (int i = 0; i < numPoints; i++) + { + double x = points[i].x(); + double y = points[i].y(); + if (doAlign) { - double x = points[i].x(); - double y = points[i].y(); - if ( doAlign ) - { - x = qRound( x ); - y = qRound( y ); - } - - double x1 = x - dx; - double y1 = y - 2 * dy; - if ( doAlign ) - { - x1 = std::ceil( x1 ); - y1 = std::ceil( y1 ); - } - - const double x2 = x1 + 1 * dx; - const double x3 = x1 + 2 * dx; - - const double y2 = y1 + 1 * dy; - const double y3 = y1 + 3 * dy; - const double y4 = y1 + 4 * dy; - - hexaPoints[0].rx() = x2; - hexaPoints[0].ry() = y1; - - hexaPoints[1].rx() = x3; - hexaPoints[1].ry() = y2; - - hexaPoints[2].rx() = x3; - hexaPoints[2].ry() = y3; - - hexaPoints[3].rx() = x2; - hexaPoints[3].ry() = y4; - - hexaPoints[4].rx() = x1; - hexaPoints[4].ry() = y3; - - hexaPoints[5].rx() = x1; - hexaPoints[5].ry() = y2; - - QwtPainter::drawPolygon( painter, hexaPolygon ); + x = qRound(x); + y = qRound(y); } + + double x1 = x - dx; + double y1 = y - 2 * dy; + if (doAlign) + { + x1 = std::ceil(x1); + y1 = std::ceil(y1); + } + + const double x2 = x1 + 1 * dx; + const double x3 = x1 + 2 * dx; + + const double y2 = y1 + 1 * dy; + const double y3 = y1 + 3 * dy; + const double y4 = y1 + 4 * dy; + + hexaPoints[0].rx() = x2; + hexaPoints[0].ry() = y1; + + hexaPoints[1].rx() = x3; + hexaPoints[1].ry() = y2; + + hexaPoints[2].rx() = x3; + hexaPoints[2].ry() = y3; + + hexaPoints[3].rx() = x2; + hexaPoints[3].ry() = y4; + + hexaPoints[4].rx() = x1; + hexaPoints[4].ry() = y3; + + hexaPoints[5].rx() = x1; + hexaPoints[5].ry() = y2; + + QwtPainter::drawPolygon(painter, hexaPolygon); + } } class QwtSymbol::PrivateData { - public: - PrivateData( QwtSymbol::Style st, const QBrush& br, - const QPen& pn, const QSize& sz ) - : style( st ) - , size( sz ) - , brush( br ) - , pen( pn ) - , isPinPointEnabled( false ) - { - cache.policy = QwtSymbol::AutoCache; +public: + PrivateData(QwtSymbol::Style st, const QBrush &br, const QPen &pn, + const QSize &sz) + : style(st) + , size(sz) + , brush(br) + , pen(pn) + , isPinPointEnabled(false) + { + cache.policy = QwtSymbol::AutoCache; #ifndef QWT_NO_SVG - svg.renderer = NULL; + svg.renderer = NULL; #endif - } + } - ~PrivateData() - { + ~PrivateData() + { #ifndef QWT_NO_SVG - delete svg.renderer; + delete svg.renderer; #endif - } + } - Style style; - QSize size; - QBrush brush; - QPen pen; + Style style; + QSize size; + QBrush brush; + QPen pen; - bool isPinPointEnabled; - QPointF pinPoint; + bool isPinPointEnabled; + QPointF pinPoint; - struct Path - { - QPainterPath path; - QwtGraphic graphic; + struct Path + { + QPainterPath path; + QwtGraphic graphic; - } path; + } path; - struct Pixmap - { - QPixmap pixmap; + struct Pixmap + { + QPixmap pixmap; - } pixmap; + } pixmap; - struct Graphic - { - QwtGraphic graphic; + struct Graphic + { + QwtGraphic graphic; - } graphic; + } graphic; #ifndef QWT_NO_SVG - struct SVG - { - QSvgRenderer* renderer; - } svg; + struct SVG + { + QSvgRenderer *renderer; + } svg; #endif - struct PaintCache - { - QwtSymbol::CachePolicy policy; - QPixmap pixmap; + struct PaintCache + { + QwtSymbol::CachePolicy policy; + QPixmap pixmap; - } cache; + } cache; }; /*! @@ -840,10 +830,10 @@ class QwtSymbol::PrivateData The symbol is constructed with gray interior, black outline with zero width, no size and style 'NoSymbol'. */ -QwtSymbol::QwtSymbol( Style style ) +QwtSymbol::QwtSymbol(Style style) { - m_data = new PrivateData( style, QBrush( Qt::gray ), - QPen( Qt::black, 0 ), QSize() ); + m_data + = new PrivateData(style, QBrush(Qt::gray), QPen(Qt::black, 0), QSize()); } /*! @@ -855,10 +845,10 @@ QwtSymbol::QwtSymbol( Style style ) \sa setStyle(), setBrush(), setPen(), setSize() */ -QwtSymbol::QwtSymbol( QwtSymbol::Style style, const QBrush& brush, - const QPen& pen, const QSize& size ) +QwtSymbol::QwtSymbol(QwtSymbol::Style style, const QBrush &brush, + const QPen &pen, const QSize &size) { - m_data = new PrivateData( style, brush, pen, size ); + m_data = new PrivateData(style, brush, pen, size); } /*! @@ -875,17 +865,17 @@ QwtSymbol::QwtSymbol( QwtSymbol::Style style, const QBrush& brush, \sa setPath(), setBrush(), setPen(), setSize() */ -QwtSymbol::QwtSymbol( const QPainterPath& path, - const QBrush& brush, const QPen& pen ) +QwtSymbol::QwtSymbol(const QPainterPath &path, const QBrush &brush, + const QPen &pen) { - m_data = new PrivateData( QwtSymbol::Path, brush, pen, QSize() ); - setPath( path ); + m_data = new PrivateData(QwtSymbol::Path, brush, pen, QSize()); + setPath(path); } //! Destructor QwtSymbol::~QwtSymbol() { - delete m_data; + delete m_data; } /*! @@ -896,14 +886,13 @@ QwtSymbol::~QwtSymbol() \param policy Cache policy \sa CachePolicy, cachePolicy() */ -void QwtSymbol::setCachePolicy( - QwtSymbol::CachePolicy policy ) +void QwtSymbol::setCachePolicy(QwtSymbol::CachePolicy policy) { - if ( m_data->cache.policy != policy ) - { - m_data->cache.policy = policy; - invalidateCache(); - } + if (m_data->cache.policy != policy) + { + m_data->cache.policy = policy; + invalidateCache(); + } } /*! @@ -912,7 +901,7 @@ void QwtSymbol::setCachePolicy( */ QwtSymbol::CachePolicy QwtSymbol::cachePolicy() const { - return m_data->cache.policy; + return m_data->cache.policy; } /*! @@ -963,20 +952,20 @@ QwtSymbol::CachePolicy QwtSymbol::cachePolicy() const \note The style is implicitly set to QwtSymbol::Path. \sa path(), setSize() */ -void QwtSymbol::setPath( const QPainterPath& path ) +void QwtSymbol::setPath(const QPainterPath &path) { - m_data->style = QwtSymbol::Path; - m_data->path.path = path; - m_data->path.graphic.reset(); + m_data->style = QwtSymbol::Path; + m_data->path.path = path; + m_data->path.graphic.reset(); } /*! \return Painter path for displaying the symbol \sa setPath() */ -const QPainterPath& QwtSymbol::path() const +const QPainterPath &QwtSymbol::path() const { - return m_data->path.path; + return m_data->path.path; } /*! @@ -989,19 +978,19 @@ const QPainterPath& QwtSymbol::path() const \note the style() is set to QwtSymbol::Pixmap \note brush() and pen() have no effect */ -void QwtSymbol::setPixmap( const QPixmap& pixmap ) +void QwtSymbol::setPixmap(const QPixmap &pixmap) { - m_data->style = QwtSymbol::Pixmap; - m_data->pixmap.pixmap = pixmap; + m_data->style = QwtSymbol::Pixmap; + m_data->pixmap.pixmap = pixmap; } /*! \return Assigned pixmap \sa setPixmap() */ -const QPixmap& QwtSymbol::pixmap() const +const QPixmap &QwtSymbol::pixmap() const { - return m_data->pixmap.pixmap; + return m_data->pixmap.pixmap; } /*! @@ -1014,19 +1003,19 @@ const QPixmap& QwtSymbol::pixmap() const \note the style() is set to QwtSymbol::Graphic \note brush() and pen() have no effect */ -void QwtSymbol::setGraphic( const QwtGraphic& graphic ) +void QwtSymbol::setGraphic(const QwtGraphic &graphic) { - m_data->style = QwtSymbol::Graphic; - m_data->graphic.graphic = graphic; + m_data->style = QwtSymbol::Graphic; + m_data->graphic.graphic = graphic; } /*! \return Assigned graphic \sa setGraphic() */ -const QwtGraphic& QwtSymbol::graphic() const +const QwtGraphic &QwtSymbol::graphic() const { - return m_data->graphic.graphic; + return m_data->graphic.graphic; } #ifndef QWT_NO_SVG @@ -1041,13 +1030,13 @@ const QwtGraphic& QwtSymbol::graphic() const \note the style() is set to QwtSymbol::SvgDocument \note brush() and pen() have no effect */ -void QwtSymbol::setSvgDocument( const QByteArray& svgDocument ) +void QwtSymbol::setSvgDocument(const QByteArray &svgDocument) { - m_data->style = QwtSymbol::SvgDocument; - if ( m_data->svg.renderer == NULL ) - m_data->svg.renderer = new QSvgRenderer(); + m_data->style = QwtSymbol::SvgDocument; + if (m_data->svg.renderer == NULL) + m_data->svg.renderer = new QSvgRenderer(); - m_data->svg.renderer->load( svgDocument ); + m_data->svg.renderer->load(svgDocument); } #endif @@ -1064,12 +1053,12 @@ void QwtSymbol::setSvgDocument( const QByteArray& svgDocument ) \sa size() */ -void QwtSymbol::setSize( int width, int height ) +void QwtSymbol::setSize(int width, int height) { - if ( ( width >= 0 ) && ( height < 0 ) ) - height = width; + if ((width >= 0) && (height < 0)) + height = width; - setSize( QSize( width, height ) ); + setSize(QSize(width, height)); } /*! @@ -1078,22 +1067,22 @@ void QwtSymbol::setSize( int width, int height ) \sa size() */ -void QwtSymbol::setSize( const QSize& size ) +void QwtSymbol::setSize(const QSize &size) { - if ( size.isValid() && size != m_data->size ) - { - m_data->size = size; - invalidateCache(); - } + if (size.isValid() && size != m_data->size) + { + m_data->size = size; + invalidateCache(); + } } /*! \return Size \sa setSize() */ -const QSize& QwtSymbol::size() const +const QSize &QwtSymbol::size() const { - return m_data->size; + return m_data->size; } /*! @@ -1104,25 +1093,25 @@ const QSize& QwtSymbol::size() const \sa brush() */ -void QwtSymbol::setBrush( const QBrush& brush ) +void QwtSymbol::setBrush(const QBrush &brush) { - if ( brush != m_data->brush ) - { - m_data->brush = brush; - invalidateCache(); + if (brush != m_data->brush) + { + m_data->brush = brush; + invalidateCache(); - if ( m_data->style == QwtSymbol::Path ) - m_data->path.graphic.reset(); - } + if (m_data->style == QwtSymbol::Path) + m_data->path.graphic.reset(); + } } /*! \return Brush \sa setBrush() */ -const QBrush& QwtSymbol::brush() const +const QBrush &QwtSymbol::brush() const { - return m_data->brush; + return m_data->brush; } /*! @@ -1138,10 +1127,9 @@ const QBrush& QwtSymbol::brush() const \sa pen(), brush() */ -void QwtSymbol::setPen( const QColor& color, - qreal width, Qt::PenStyle style ) +void QwtSymbol::setPen(const QColor &color, qreal width, Qt::PenStyle style) { - setPen( QPen( color, width, style ) ); + setPen(QPen(color, width, style)); } /*! @@ -1152,25 +1140,25 @@ void QwtSymbol::setPen( const QColor& color, \param pen Pen \sa pen(), setBrush() */ -void QwtSymbol::setPen( const QPen& pen ) +void QwtSymbol::setPen(const QPen &pen) { - if ( pen != m_data->pen ) - { - m_data->pen = pen; - invalidateCache(); + if (pen != m_data->pen) + { + m_data->pen = pen; + invalidateCache(); - if ( m_data->style == QwtSymbol::Path ) - m_data->path.graphic.reset(); - } + if (m_data->style == QwtSymbol::Path) + m_data->path.graphic.reset(); + } } /*! \return Pen \sa setPen(), brush() */ -const QPen& QwtSymbol::pen() const +const QPen &QwtSymbol::pen() const { - return m_data->pen; + return m_data->pen; } /*! @@ -1183,53 +1171,49 @@ const QPen& QwtSymbol::pen() const \sa setBrush(), setPen(), brush(), pen() */ -void QwtSymbol::setColor( const QColor& color ) +void QwtSymbol::setColor(const QColor &color) { - switch ( m_data->style ) - { - case QwtSymbol::Ellipse: - case QwtSymbol::Rect: - case QwtSymbol::Diamond: - case QwtSymbol::Triangle: - case QwtSymbol::UTriangle: - case QwtSymbol::DTriangle: - case QwtSymbol::RTriangle: - case QwtSymbol::LTriangle: - case QwtSymbol::Star2: - case QwtSymbol::Hexagon: - { - if ( m_data->brush.color() != color ) - { - m_data->brush.setColor( color ); - invalidateCache(); - } - break; - } - case QwtSymbol::Cross: - case QwtSymbol::XCross: - case QwtSymbol::HLine: - case QwtSymbol::VLine: - case QwtSymbol::Star1: - { - if ( m_data->pen.color() != color ) - { - m_data->pen.setColor( color ); - invalidateCache(); - } - break; - } - default: - { - if ( m_data->brush.color() != color || - m_data->pen.color() != color ) - { - invalidateCache(); - } - - m_data->brush.setColor( color ); - m_data->pen.setColor( color ); - } + switch (m_data->style) + { + case QwtSymbol::Ellipse: + case QwtSymbol::Rect: + case QwtSymbol::Diamond: + case QwtSymbol::Triangle: + case QwtSymbol::UTriangle: + case QwtSymbol::DTriangle: + case QwtSymbol::RTriangle: + case QwtSymbol::LTriangle: + case QwtSymbol::Star2: + case QwtSymbol::Hexagon: { + if (m_data->brush.color() != color) + { + m_data->brush.setColor(color); + invalidateCache(); + } + break; } + case QwtSymbol::Cross: + case QwtSymbol::XCross: + case QwtSymbol::HLine: + case QwtSymbol::VLine: + case QwtSymbol::Star1: { + if (m_data->pen.color() != color) + { + m_data->pen.setColor(color); + invalidateCache(); + } + break; + } + default: { + if (m_data->brush.color() != color || m_data->pen.color() != color) + { + invalidateCache(); + } + + m_data->brush.setColor(color); + m_data->pen.setColor(color); + } + } } /*! @@ -1246,18 +1230,18 @@ void QwtSymbol::setColor( const QColor& color ) \sa pinPoint(), setPinPointEnabled() */ -void QwtSymbol::setPinPoint( const QPointF& pos, bool enable ) +void QwtSymbol::setPinPoint(const QPointF &pos, bool enable) { - if ( m_data->pinPoint != pos ) + if (m_data->pinPoint != pos) + { + m_data->pinPoint = pos; + if (m_data->isPinPointEnabled) { - m_data->pinPoint = pos; - if ( m_data->isPinPointEnabled ) - { - invalidateCache(); - } + invalidateCache(); } + } - setPinPointEnabled( enable ); + setPinPointEnabled(enable); } /*! @@ -1266,7 +1250,7 @@ void QwtSymbol::setPinPoint( const QPointF& pos, bool enable ) */ QPointF QwtSymbol::pinPoint() const { - return m_data->pinPoint; + return m_data->pinPoint; } /*! @@ -1275,13 +1259,13 @@ QPointF QwtSymbol::pinPoint() const \param on Enabled, when on is true \sa setPinPoint(), isPinPointEnabled() */ -void QwtSymbol::setPinPointEnabled( bool on ) +void QwtSymbol::setPinPointEnabled(bool on) { - if ( m_data->isPinPointEnabled != on ) - { - m_data->isPinPointEnabled = on; - invalidateCache(); - } + if (m_data->isPinPointEnabled != on) + { + m_data->isPinPointEnabled = on; + invalidateCache(); + } } /*! @@ -1290,7 +1274,7 @@ void QwtSymbol::setPinPointEnabled( bool on ) */ bool QwtSymbol::isPinPointEnabled() const { - return m_data->isPinPointEnabled; + return m_data->isPinPointEnabled; } /*! @@ -1304,119 +1288,113 @@ bool QwtSymbol::isPinPointEnabled() const \param points Array of points \param numPoints Number of points */ -void QwtSymbol::drawSymbols( QPainter* painter, - const QPointF* points, int numPoints ) const +void QwtSymbol::drawSymbols(QPainter *painter, const QPointF *points, + int numPoints) const { - if ( numPoints <= 0 ) - return; + if (numPoints <= 0) + return; - bool useCache = false; + bool useCache = false; - // Don't use the pixmap, when the paint device - // could generate scalable vectors + // Don't use the pixmap, when the paint device + // could generate scalable vectors - if ( QwtPainter::roundingAlignment( painter ) && - !painter->transform().isScaling() ) + if (QwtPainter::roundingAlignment(painter) + && !painter->transform().isScaling()) + { + if (m_data->cache.policy == QwtSymbol::Cache) { - if ( m_data->cache.policy == QwtSymbol::Cache ) - { - useCache = true; + useCache = true; + } + else if (m_data->cache.policy == QwtSymbol::AutoCache) + { + switch (painter->paintEngine()->type()) + { + case QPaintEngine::OpenGL: + case QPaintEngine::OpenGL2: { + // using a FBO as cache ? + useCache = false; + break; } - else if ( m_data->cache.policy == QwtSymbol::AutoCache ) - { - switch( painter->paintEngine()->type() ) - { - case QPaintEngine::OpenGL: - case QPaintEngine::OpenGL2: - { - // using a FBO as cache ? - useCache = false; - break; - } - case QPaintEngine::OpenVG: - case QPaintEngine::SVG: - case QPaintEngine::Pdf: - case QPaintEngine::Picture: - { - // vector graphics - useCache = false; - break; - } - case QPaintEngine::X11: - { - switch( m_data->style ) - { - case QwtSymbol::XCross: - case QwtSymbol::HLine: - case QwtSymbol::VLine: - case QwtSymbol::Cross: - { - // for the very simple shapes using vector graphics is - // usually faster. + case QPaintEngine::OpenVG: + case QPaintEngine::SVG: + case QPaintEngine::Pdf: + case QPaintEngine::Picture: { + // vector graphics + useCache = false; + break; + } + case QPaintEngine::X11: { + switch (m_data->style) + { + case QwtSymbol::XCross: + case QwtSymbol::HLine: + case QwtSymbol::VLine: + case QwtSymbol::Cross: { + // for the very simple shapes using vector graphics is + // usually faster. - useCache = false; - break; - } - - case QwtSymbol::Pixmap: - { - if ( m_data->size.isEmpty() || - m_data->size == m_data->pixmap.pixmap.size() ) - { - // no need to have a pixmap cache for a pixmap - // of the same size - - useCache = false; - } - break; - } - default: - break; - } - break; - } - default: - { - useCache = true; - } + useCache = false; + break; } - } - } - if ( useCache ) + case QwtSymbol::Pixmap: { + if (m_data->size.isEmpty() + || m_data->size == m_data->pixmap.pixmap.size()) + { + // no need to have a pixmap cache for a pixmap + // of the same size + + useCache = false; + } + break; + } + default: + break; + } + break; + } + default: { + useCache = true; + } + } + } + } + + if (useCache) + { + const QRect br = boundingRect(); + + if (m_data->cache.pixmap.isNull()) { - const QRect br = boundingRect(); + m_data->cache.pixmap = QwtPainter::backingStore(NULL, br.size()); + m_data->cache.pixmap.fill(Qt::transparent); - if ( m_data->cache.pixmap.isNull() ) - { - m_data->cache.pixmap = QwtPainter::backingStore( NULL, br.size() ); - m_data->cache.pixmap.fill( Qt::transparent ); + QPainter p(&m_data->cache.pixmap); + p.setRenderHints(painter->renderHints()); + p.translate(-br.topLeft()); - QPainter p( &m_data->cache.pixmap ); - p.setRenderHints( painter->renderHints() ); - p.translate( -br.topLeft() ); - - const QPointF pos( 0.0, 0.0 ); - renderSymbols( &p, &pos, 1 ); - } - - const int dx = br.left(); - const int dy = br.top(); - - for ( int i = 0; i < numPoints; i++ ) - { - const int left = qRound( points[i].x() ) + dx; - const int top = qRound( points[i].y() ) + dy; - - painter->drawPixmap( left, top, m_data->cache.pixmap ); - } + const QPointF pos(0.0, 0.0); + renderSymbols(&p, &pos, 1); } - else + + const int dx = br.left(); + const int dy = br.top(); + + for (int i = 0; i < numPoints; i++) { - painter->save(); - renderSymbols( painter, points, numPoints ); - painter->restore(); + const int left = qRound(points[i].x()) + dx; + const int top = qRound(points[i].y()) + dy; + + painter->drawPixmap(left, top, m_data->cache.pixmap); } + } + else + { + painter->save(); + renderSymbols(painter, points, numPoints); + painter->restore(); + } } /*! @@ -1431,76 +1409,73 @@ void QwtSymbol::drawSymbols( QPainter* painter, \param painter Painter \param rect Target rectangle for the symbol */ -void QwtSymbol::drawSymbol( QPainter* painter, const QRectF& rect ) const +void QwtSymbol::drawSymbol(QPainter *painter, const QRectF &rect) const { - if ( m_data->style == QwtSymbol::NoSymbol ) - return; + if (m_data->style == QwtSymbol::NoSymbol) + return; - if ( m_data->style == QwtSymbol::Graphic ) + if (m_data->style == QwtSymbol::Graphic) + { + m_data->graphic.graphic.render(painter, rect, Qt::KeepAspectRatio); + } + else if (m_data->style == QwtSymbol::Path) + { + if (m_data->path.graphic.isNull()) { - m_data->graphic.graphic.render( - painter, rect, Qt::KeepAspectRatio ); + m_data->path.graphic + = qwtPathGraphic(m_data->path.path, m_data->pen, m_data->brush); } - else if ( m_data->style == QwtSymbol::Path ) - { - if ( m_data->path.graphic.isNull() ) - { - m_data->path.graphic = qwtPathGraphic( - m_data->path.path, m_data->pen, m_data->brush ); - } - m_data->path.graphic.render( - painter, rect, Qt::KeepAspectRatio ); - return; - } - else if ( m_data->style == QwtSymbol::SvgDocument ) - { + m_data->path.graphic.render(painter, rect, Qt::KeepAspectRatio); + return; + } + else if (m_data->style == QwtSymbol::SvgDocument) + { #ifndef QWT_NO_SVG - if ( m_data->svg.renderer ) - { - QRectF scaledRect; - - QSizeF sz = m_data->svg.renderer->viewBoxF().size(); - if ( !sz.isEmpty() ) - { - sz.scale( rect.size(), Qt::KeepAspectRatio ); - scaledRect.setSize( sz ); - scaledRect.moveCenter( rect.center() ); - } - else - { - scaledRect = rect; - } - - m_data->svg.renderer->render( - painter, scaledRect ); - } -#endif - } - else + if (m_data->svg.renderer) { - const QRect br = boundingRect(); + QRectF scaledRect; - // scale the symbol size to fit into rect. + QSizeF sz = m_data->svg.renderer->viewBoxF().size(); + if (!sz.isEmpty()) + { + sz.scale(rect.size(), Qt::KeepAspectRatio); + scaledRect.setSize(sz); + scaledRect.moveCenter(rect.center()); + } + else + { + scaledRect = rect; + } - const double ratio = qMin( rect.width() / br.width(), - rect.height() / br.height() ); - - painter->save(); - - painter->translate( rect.center() ); - painter->scale( ratio, ratio ); - - const bool isPinPointEnabled = m_data->isPinPointEnabled; - m_data->isPinPointEnabled = false; - - const QPointF pos; - renderSymbols( painter, &pos, 1 ); - - m_data->isPinPointEnabled = isPinPointEnabled; - - painter->restore(); + m_data->svg.renderer->render(painter, scaledRect); } +#endif + } + else + { + const QRect br = boundingRect(); + + // scale the symbol size to fit into rect. + + const double ratio + = qMin(rect.width() / br.width(), rect.height() / br.height()); + + painter->save(); + + painter->translate(rect.center()); + painter->scale(ratio, ratio); + + const bool isPinPointEnabled = m_data->isPinPointEnabled; + m_data->isPinPointEnabled = false; + + const QPointF pos; + renderSymbols(painter, &pos, 1); + + m_data->isPinPointEnabled = isPinPointEnabled; + + painter->restore(); + } } /*! @@ -1510,122 +1485,102 @@ void QwtSymbol::drawSymbol( QPainter* painter, const QRectF& rect ) const \param points Positions of the symbols \param numPoints Number of points */ -void QwtSymbol::renderSymbols( QPainter* painter, - const QPointF* points, int numPoints ) const +void QwtSymbol::renderSymbols(QPainter *painter, const QPointF *points, + int numPoints) const { - switch ( m_data->style ) - { - case QwtSymbol::Ellipse: - { - qwtDrawEllipseSymbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Rect: - { - qwtDrawRectSymbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Diamond: - { - qwtDrawDiamondSymbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Cross: - { - qwtDrawLineSymbols( painter, Qt::Horizontal | Qt::Vertical, - points, numPoints, *this ); - break; - } - case QwtSymbol::XCross: - { - qwtDrawXCrossSymbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Triangle: - case QwtSymbol::UTriangle: - { - qwtDrawTriangleSymbols( painter, QwtTriangle::Up, - points, numPoints, *this ); - break; - } - case QwtSymbol::DTriangle: - { - qwtDrawTriangleSymbols( painter, QwtTriangle::Down, - points, numPoints, *this ); - break; - } - case QwtSymbol::RTriangle: - { - qwtDrawTriangleSymbols( painter, QwtTriangle::Right, - points, numPoints, *this ); - break; - } - case QwtSymbol::LTriangle: - { - qwtDrawTriangleSymbols( painter, QwtTriangle::Left, - points, numPoints, *this ); - break; - } - case QwtSymbol::HLine: - { - qwtDrawLineSymbols( painter, Qt::Horizontal, - points, numPoints, *this ); - break; - } - case QwtSymbol::VLine: - { - qwtDrawLineSymbols( painter, Qt::Vertical, - points, numPoints, *this ); - break; - } - case QwtSymbol::Star1: - { - qwtDrawStar1Symbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Star2: - { - qwtDrawStar2Symbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Hexagon: - { - qwtDrawHexagonSymbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Path: - { - if ( m_data->path.graphic.isNull() ) - { - m_data->path.graphic = qwtPathGraphic( m_data->path.path, - m_data->pen, m_data->brush ); - } - - qwtDrawGraphicSymbols( painter, points, numPoints, - m_data->path.graphic, *this ); - break; - } - case QwtSymbol::Pixmap: - { - qwtDrawPixmapSymbols( painter, points, numPoints, *this ); - break; - } - case QwtSymbol::Graphic: - { - qwtDrawGraphicSymbols( painter, points, numPoints, - m_data->graphic.graphic, *this ); - break; - } - case QwtSymbol::SvgDocument: - { -#ifndef QWT_NO_SVG - qwtDrawSvgSymbols( painter, points, numPoints, - m_data->svg.renderer, *this ); -#endif - break; - } - default:; + switch (m_data->style) + { + case QwtSymbol::Ellipse: { + qwtDrawEllipseSymbols(painter, points, numPoints, *this); + break; } + case QwtSymbol::Rect: { + qwtDrawRectSymbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Diamond: { + qwtDrawDiamondSymbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Cross: { + qwtDrawLineSymbols(painter, Qt::Horizontal | Qt::Vertical, points, + numPoints, *this); + break; + } + case QwtSymbol::XCross: { + qwtDrawXCrossSymbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Triangle: + case QwtSymbol::UTriangle: { + qwtDrawTriangleSymbols(painter, QwtTriangle::Up, points, numPoints, + *this); + break; + } + case QwtSymbol::DTriangle: { + qwtDrawTriangleSymbols(painter, QwtTriangle::Down, points, numPoints, + *this); + break; + } + case QwtSymbol::RTriangle: { + qwtDrawTriangleSymbols(painter, QwtTriangle::Right, points, numPoints, + *this); + break; + } + case QwtSymbol::LTriangle: { + qwtDrawTriangleSymbols(painter, QwtTriangle::Left, points, numPoints, + *this); + break; + } + case QwtSymbol::HLine: { + qwtDrawLineSymbols(painter, Qt::Horizontal, points, numPoints, *this); + break; + } + case QwtSymbol::VLine: { + qwtDrawLineSymbols(painter, Qt::Vertical, points, numPoints, *this); + break; + } + case QwtSymbol::Star1: { + qwtDrawStar1Symbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Star2: { + qwtDrawStar2Symbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Hexagon: { + qwtDrawHexagonSymbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Path: { + if (m_data->path.graphic.isNull()) + { + m_data->path.graphic + = qwtPathGraphic(m_data->path.path, m_data->pen, m_data->brush); + } + + qwtDrawGraphicSymbols(painter, points, numPoints, m_data->path.graphic, + *this); + break; + } + case QwtSymbol::Pixmap: { + qwtDrawPixmapSymbols(painter, points, numPoints, *this); + break; + } + case QwtSymbol::Graphic: { + qwtDrawGraphicSymbols(painter, points, numPoints, m_data->graphic.graphic, + *this); + break; + } + case QwtSymbol::SvgDocument: { +#ifndef QWT_NO_SVG + qwtDrawSvgSymbols(painter, points, numPoints, m_data->svg.renderer, + *this); +#endif + break; + } + default:; + } } /*! @@ -1636,124 +1591,115 @@ void QwtSymbol::renderSymbols( QPainter* painter, */ QRect QwtSymbol::boundingRect() const { - QRectF rect; + QRectF rect; - bool pinPointTranslation = false; + bool pinPointTranslation = false; - switch ( m_data->style ) - { - case QwtSymbol::Ellipse: - case QwtSymbol::Rect: - case QwtSymbol::Hexagon: - { - qreal pw = 0.0; - if ( m_data->pen.style() != Qt::NoPen ) - pw = QwtPainter::effectivePenWidth( m_data->pen ); + switch (m_data->style) + { + case QwtSymbol::Ellipse: + case QwtSymbol::Rect: + case QwtSymbol::Hexagon: { + qreal pw = 0.0; + if (m_data->pen.style() != Qt::NoPen) + pw = QwtPainter::effectivePenWidth(m_data->pen); - rect.setSize( m_data->size + QSizeF( pw, pw ) ); - rect.moveCenter( QPointF( 0.0, 0.0 ) ); + rect.setSize(m_data->size + QSizeF(pw, pw)); + rect.moveCenter(QPointF(0.0, 0.0)); - break; - } - case QwtSymbol::XCross: - case QwtSymbol::Diamond: - case QwtSymbol::Triangle: - case QwtSymbol::UTriangle: - case QwtSymbol::DTriangle: - case QwtSymbol::RTriangle: - case QwtSymbol::LTriangle: - case QwtSymbol::Star1: - case QwtSymbol::Star2: - { - qreal pw = 0.0; - if ( m_data->pen.style() != Qt::NoPen ) - pw = QwtPainter::effectivePenWidth( m_data->pen ); + break; + } + case QwtSymbol::XCross: + case QwtSymbol::Diamond: + case QwtSymbol::Triangle: + case QwtSymbol::UTriangle: + case QwtSymbol::DTriangle: + case QwtSymbol::RTriangle: + case QwtSymbol::LTriangle: + case QwtSymbol::Star1: + case QwtSymbol::Star2: { + qreal pw = 0.0; + if (m_data->pen.style() != Qt::NoPen) + pw = QwtPainter::effectivePenWidth(m_data->pen); - rect.setSize( m_data->size + QSizeF( 2 * pw, 2 * pw ) ); - rect.moveCenter( QPointF( 0.0, 0.0 ) ); - break; - } - case QwtSymbol::Path: - { - if ( m_data->path.graphic.isNull() ) - { - m_data->path.graphic = qwtPathGraphic( - m_data->path.path, m_data->pen, m_data->brush ); - } + rect.setSize(m_data->size + QSizeF(2 * pw, 2 * pw)); + rect.moveCenter(QPointF(0.0, 0.0)); + break; + } + case QwtSymbol::Path: { + if (m_data->path.graphic.isNull()) + { + m_data->path.graphic + = qwtPathGraphic(m_data->path.path, m_data->pen, m_data->brush); + } - rect = qwtScaledBoundingRect( - m_data->path.graphic, m_data->size ); - pinPointTranslation = true; + rect = qwtScaledBoundingRect(m_data->path.graphic, m_data->size); + pinPointTranslation = true; - break; - } - case QwtSymbol::Pixmap: - { - if ( m_data->size.isEmpty() ) - rect.setSize( m_data->pixmap.pixmap.size() ); - else - rect.setSize( m_data->size ); + break; + } + case QwtSymbol::Pixmap: { + if (m_data->size.isEmpty()) + rect.setSize(m_data->pixmap.pixmap.size()); + else + rect.setSize(m_data->size); - pinPointTranslation = true; + pinPointTranslation = true; - break; - } - case QwtSymbol::Graphic: - { - rect = qwtScaledBoundingRect( - m_data->graphic.graphic, m_data->size ); - pinPointTranslation = true; + break; + } + case QwtSymbol::Graphic: { + rect = qwtScaledBoundingRect(m_data->graphic.graphic, m_data->size); + pinPointTranslation = true; - break; - } + break; + } #ifndef QWT_NO_SVG - case QwtSymbol::SvgDocument: - { - if ( m_data->svg.renderer ) - rect = m_data->svg.renderer->viewBoxF(); + case QwtSymbol::SvgDocument: { + if (m_data->svg.renderer) + rect = m_data->svg.renderer->viewBoxF(); - if ( m_data->size.isValid() && !rect.isEmpty() ) - { - QSizeF sz = rect.size(); + if (m_data->size.isValid() && !rect.isEmpty()) + { + QSizeF sz = rect.size(); - const double sx = m_data->size.width() / sz.width(); - const double sy = m_data->size.height() / sz.height(); + const double sx = m_data->size.width() / sz.width(); + const double sy = m_data->size.height() / sz.height(); - QTransform transform; - transform.scale( sx, sy ); + QTransform transform; + transform.scale(sx, sy); - rect = transform.mapRect( rect ); - } - pinPointTranslation = true; - break; - } + rect = transform.mapRect(rect); + } + pinPointTranslation = true; + break; + } #endif - default: - { - rect.setSize( m_data->size ); - rect.moveCenter( QPointF( 0.0, 0.0 ) ); - } + default: { + rect.setSize(m_data->size); + rect.moveCenter(QPointF(0.0, 0.0)); } + } - if ( pinPointTranslation ) - { - QPointF pinPoint( 0.0, 0.0 ); - if ( m_data->isPinPointEnabled ) - pinPoint = rect.center() - m_data->pinPoint; + if (pinPointTranslation) + { + QPointF pinPoint(0.0, 0.0); + if (m_data->isPinPointEnabled) + pinPoint = rect.center() - m_data->pinPoint; - rect.moveCenter( pinPoint ); - } + rect.moveCenter(pinPoint); + } - QRect r; - r.setLeft( qwtFloor( rect.left() ) ); - r.setTop( qwtFloor( rect.top() ) ); - r.setRight( qwtCeil( rect.right() ) ); - r.setBottom( qwtCeil( rect.bottom() ) ); + QRect r; + r.setLeft(qwtFloor(rect.left())); + r.setTop(qwtFloor(rect.top())); + r.setRight(qwtCeil(rect.right())); + r.setBottom(qwtCeil(rect.bottom())); - if ( m_data->style != QwtSymbol::Pixmap ) - r.adjust( -1, -1, 1, 1 ); // for antialiasing + if (m_data->style != QwtSymbol::Pixmap) + r.adjust(-1, -1, 1, 1); // for antialiasing - return r; + return r; } /*! @@ -1769,8 +1715,8 @@ QRect QwtSymbol::boundingRect() const */ void QwtSymbol::invalidateCache() { - if ( !m_data->cache.pixmap.isNull() ) - m_data->cache.pixmap = QPixmap(); + if (!m_data->cache.pixmap.isNull()) + m_data->cache.pixmap = QPixmap(); } /*! @@ -1779,13 +1725,13 @@ void QwtSymbol::invalidateCache() \param style Style \sa style() */ -void QwtSymbol::setStyle( QwtSymbol::Style style ) +void QwtSymbol::setStyle(QwtSymbol::Style style) { - if ( m_data->style != style ) - { - m_data->style = style; - invalidateCache(); - } + if (m_data->style != style) + { + m_data->style = style; + invalidateCache(); + } } /*! @@ -1794,5 +1740,5 @@ void QwtSymbol::setStyle( QwtSymbol::Style style ) */ QwtSymbol::Style QwtSymbol::style() const { - return m_data->style; + return m_data->style; } diff --git a/libs/qwt/src/qwt_symbol.h b/libs/qwt/src/qwt_symbol.h index 4999bf61..a2370a48 100644 --- a/libs/qwt/src/qwt_symbol.h +++ b/libs/qwt/src/qwt_symbol.h @@ -30,203 +30,201 @@ class QwtGraphic; //! A class for drawing symbols class QWT_EXPORT QwtSymbol { - public: - /*! - Symbol Style - \sa setStyle(), style() - */ - enum Style - { - //! No Style. The symbol cannot be drawn. - NoSymbol = -1, +public: + /*! + Symbol Style + \sa setStyle(), style() + */ + enum Style + { + //! No Style. The symbol cannot be drawn. + NoSymbol = -1, - //! Ellipse or circle - Ellipse, + //! Ellipse or circle + Ellipse, - //! Rectangle - Rect, + //! Rectangle + Rect, - //! Diamond - Diamond, + //! Diamond + Diamond, - //! Triangle pointing upwards - Triangle, + //! Triangle pointing upwards + Triangle, - //! Triangle pointing downwards - DTriangle, + //! Triangle pointing downwards + DTriangle, - //! Triangle pointing upwards - UTriangle, + //! Triangle pointing upwards + UTriangle, - //! Triangle pointing left - LTriangle, + //! Triangle pointing left + LTriangle, - //! Triangle pointing right - RTriangle, + //! Triangle pointing right + RTriangle, - //! Cross (+) - Cross, + //! Cross (+) + Cross, - //! Diagonal cross (X) - XCross, + //! Diagonal cross (X) + XCross, - //! Horizontal line - HLine, + //! Horizontal line + HLine, - //! Vertical line - VLine, + //! Vertical line + VLine, - //! X combined with + - Star1, + //! X combined with + + Star1, - //! Six-pointed star - Star2, + //! Six-pointed star + Star2, - //! Hexagon - Hexagon, - - /*! - The symbol is represented by a painter path, where the - origin ( 0, 0 ) of the path coordinate system is mapped to - the position of the symbol. - - \sa setPath(), path() - */ - Path, - - /*! - The symbol is represented by a pixmap. The pixmap is centered - or aligned to its pin point. - - \sa setPinPoint() - */ - Pixmap, - - /*! - The symbol is represented by a graphic. The graphic is centered - or aligned to its pin point. - - \sa setPinPoint() - */ - Graphic, - - /*! - The symbol is represented by a SVG graphic. The graphic is centered - or aligned to its pin point. - - \sa setPinPoint() - */ - SvgDocument, - - /*! - Styles >= QwtSymbol::UserSymbol are reserved for derived - classes of QwtSymbol that overload drawSymbols() with - additional application specific symbol types. - */ - UserStyle = 1000 - }; + //! Hexagon + Hexagon, /*! - Depending on the render engine and the complexity of the - symbol shape it might be faster to render the symbol - to a pixmap and to paint this pixmap. + The symbol is represented by a painter path, where the + origin ( 0, 0 ) of the path coordinate system is mapped to + the position of the symbol. - F.e. the raster paint engine is a pure software renderer - where in cache mode a draw operation usually ends in - raster operation with the the backing store, that are usually - faster, than the algorithms for rendering polygons. - But the opposite can be expected for graphic pipelines - that can make use of hardware acceleration. - - The default setting is AutoCache - - \sa setCachePolicy(), cachePolicy() - - \note The policy has no effect, when the symbol is painted - to a vector graphics format ( PDF, SVG ). - \warning Since Qt 4.8 raster is the default backend on X11 + \sa setPath(), path() */ + Path, - enum CachePolicy - { - //! Don't use a pixmap cache - NoCache, + /*! + The symbol is represented by a pixmap. The pixmap is centered + or aligned to its pin point. - //! Always use a pixmap cache - Cache, + \sa setPinPoint() + */ + Pixmap, - /*! - Use a cache when one of the following conditions is true: + /*! + The symbol is represented by a graphic. The graphic is centered + or aligned to its pin point. - - The symbol is rendered with the software - renderer ( QPaintEngine::Raster ) - */ - AutoCache - }; + \sa setPinPoint() + */ + Graphic, - public: - explicit QwtSymbol( Style = NoSymbol ); - QwtSymbol( Style, const QBrush&, const QPen&, const QSize& ); - QwtSymbol( const QPainterPath&, const QBrush&, const QPen& ); + /*! + The symbol is represented by a SVG graphic. The graphic is centered + or aligned to its pin point. - virtual ~QwtSymbol(); + \sa setPinPoint() + */ + SvgDocument, - void setCachePolicy( CachePolicy ); - CachePolicy cachePolicy() const; + /*! + Styles >= QwtSymbol::UserSymbol are reserved for derived + classes of QwtSymbol that overload drawSymbols() with + additional application specific symbol types. + */ + UserStyle = 1000 + }; - void setSize( const QSize& ); - void setSize( int width, int height = -1 ); - const QSize& size() const; + /*! + Depending on the render engine and the complexity of the + symbol shape it might be faster to render the symbol + to a pixmap and to paint this pixmap. - void setPinPoint( const QPointF& pos, bool enable = true ); - QPointF pinPoint() const; + F.e. the raster paint engine is a pure software renderer + where in cache mode a draw operation usually ends in + raster operation with the the backing store, that are usually + faster, than the algorithms for rendering polygons. + But the opposite can be expected for graphic pipelines + that can make use of hardware acceleration. - void setPinPointEnabled( bool ); - bool isPinPointEnabled() const; + The default setting is AutoCache - virtual void setColor( const QColor& ); + \sa setCachePolicy(), cachePolicy() - void setBrush( const QBrush& ); - const QBrush& brush() const; + \note The policy has no effect, when the symbol is painted + to a vector graphics format ( PDF, SVG ). + \warning Since Qt 4.8 raster is the default backend on X11 + */ - void setPen( const QColor&, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); - void setPen( const QPen& ); - const QPen& pen() const; + enum CachePolicy + { + //! Don't use a pixmap cache + NoCache, - void setStyle( Style ); - Style style() const; + //! Always use a pixmap cache + Cache, - void setPath( const QPainterPath& ); - const QPainterPath& path() const; + /*! + Use a cache when one of the following conditions is true: - void setPixmap( const QPixmap& ); - const QPixmap& pixmap() const; + - The symbol is rendered with the software + renderer ( QPaintEngine::Raster ) + */ + AutoCache + }; - void setGraphic( const QwtGraphic& ); - const QwtGraphic& graphic() const; +public: + explicit QwtSymbol(Style = NoSymbol); + QwtSymbol(Style, const QBrush &, const QPen &, const QSize &); + QwtSymbol(const QPainterPath &, const QBrush &, const QPen &); + + virtual ~QwtSymbol(); + + void setCachePolicy(CachePolicy); + CachePolicy cachePolicy() const; + + void setSize(const QSize &); + void setSize(int width, int height = -1); + const QSize &size() const; + + void setPinPoint(const QPointF &pos, bool enable = true); + QPointF pinPoint() const; + + void setPinPointEnabled(bool); + bool isPinPointEnabled() const; + + virtual void setColor(const QColor &); + + void setBrush(const QBrush &); + const QBrush &brush() const; + + void setPen(const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine); + void setPen(const QPen &); + const QPen &pen() const; + + void setStyle(Style); + Style style() const; + + void setPath(const QPainterPath &); + const QPainterPath &path() const; + + void setPixmap(const QPixmap &); + const QPixmap &pixmap() const; + + void setGraphic(const QwtGraphic &); + const QwtGraphic &graphic() const; #ifndef QWT_NO_SVG - void setSvgDocument( const QByteArray& ); + void setSvgDocument(const QByteArray &); #endif - void drawSymbol( QPainter*, const QRectF& ) const; - void drawSymbol( QPainter*, const QPointF& ) const; - void drawSymbols( QPainter*, const QPolygonF& ) const; - void drawSymbols( QPainter*, - const QPointF*, int numPoints ) const; + void drawSymbol(QPainter *, const QRectF &) const; + void drawSymbol(QPainter *, const QPointF &) const; + void drawSymbols(QPainter *, const QPolygonF &) const; + void drawSymbols(QPainter *, const QPointF *, int numPoints) const; - virtual QRect boundingRect() const; - void invalidateCache(); + virtual QRect boundingRect() const; + void invalidateCache(); - protected: - virtual void renderSymbols( QPainter*, - const QPointF*, int numPoints ) const; +protected: + virtual void renderSymbols(QPainter *, const QPointF *, int numPoints) const; - private: - Q_DISABLE_COPY(QwtSymbol) +private: + Q_DISABLE_COPY(QwtSymbol) - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; /*! @@ -235,10 +233,9 @@ class QWT_EXPORT QwtSymbol \param painter Painter \param pos Position of the symbol in screen coordinates */ -inline void QwtSymbol::drawSymbol( - QPainter* painter, const QPointF& pos ) const +inline void QwtSymbol::drawSymbol(QPainter *painter, const QPointF &pos) const { - drawSymbols( painter, &pos, 1 ); + drawSymbols(painter, &pos, 1); } /*! @@ -248,10 +245,10 @@ inline void QwtSymbol::drawSymbol( \param points Positions of the symbols in screen coordinates */ -inline void QwtSymbol::drawSymbols( - QPainter* painter, const QPolygonF& points ) const +inline void QwtSymbol::drawSymbols(QPainter *painter, + const QPolygonF &points) const { - drawSymbols( painter, points.data(), points.size() ); + drawSymbols(painter, points.data(), points.size()); } #endif diff --git a/libs/qwt/src/qwt_system_clock.cpp b/libs/qwt/src/qwt_system_clock.cpp index bfed27c6..22d8e1e0 100644 --- a/libs/qwt/src/qwt_system_clock.cpp +++ b/libs/qwt/src/qwt_system_clock.cpp @@ -13,13 +13,13 @@ //! \return true, if the elapsed timer is valid bool QwtSystemClock::isNull() const { - return m_timer.isValid(); + return m_timer.isValid(); } //! Start the elapsed timer void QwtSystemClock::start() { - m_timer.start(); + m_timer.start(); } /*! @@ -28,13 +28,13 @@ void QwtSystemClock::start() */ double QwtSystemClock::restart() { - const qint64 nsecs = m_timer.restart(); - return nsecs / 1e6; + const qint64 nsecs = m_timer.restart(); + return nsecs / 1e6; } //! \return elapsed time in multiples of milliseconds double QwtSystemClock::elapsed() const { - const qint64 nsecs = m_timer.nsecsElapsed(); - return nsecs / 1e6; + const qint64 nsecs = m_timer.nsecsElapsed(); + return nsecs / 1e6; } diff --git a/libs/qwt/src/qwt_system_clock.h b/libs/qwt/src/qwt_system_clock.h index 58abf097..7111b351 100644 --- a/libs/qwt/src/qwt_system_clock.h +++ b/libs/qwt/src/qwt_system_clock.h @@ -23,15 +23,15 @@ class QWT_EXPORT QwtSystemClock { - public: - bool isNull() const; +public: + bool isNull() const; - void start(); - double restart(); - double elapsed() const; + void start(); + double restart(); + double elapsed() const; - private: - QElapsedTimer m_timer; +private: + QElapsedTimer m_timer; }; #endif diff --git a/libs/qwt/src/qwt_text.cpp b/libs/qwt/src/qwt_text.cpp index 54dcd261..a4f3462a 100644 --- a/libs/qwt/src/qwt_text.cpp +++ b/libs/qwt/src/qwt_text.cpp @@ -21,178 +21,174 @@ #if QT_VERSION >= 0x050200 -static QwtText qwtStringToText( const QString& text ) +static QwtText qwtStringToText(const QString &text) { - return QwtText( text ); + return QwtText(text); } #endif namespace { - static const struct RegisterQwtText - { - inline RegisterQwtText() - { - qRegisterMetaType< QwtText >(); +static const struct RegisterQwtText +{ + inline RegisterQwtText() + { + qRegisterMetaType(); #if QT_VERSION >= 0x050200 - QMetaType::registerConverter< QString, QwtText >( qwtStringToText ); + QMetaType::registerConverter(qwtStringToText); #endif - } + } - } qwtRegisterQwtText; -} +} qwtRegisterQwtText; +} // namespace namespace { - class TextEngineDict - { - public: - static TextEngineDict& dict(); +class TextEngineDict +{ +public: + static TextEngineDict &dict(); - void setTextEngine( QwtText::TextFormat, QwtTextEngine* ); + void setTextEngine(QwtText::TextFormat, QwtTextEngine *); - const QwtTextEngine* textEngine( QwtText::TextFormat ) const; - const QwtTextEngine* textEngine( const QString&, - QwtText::TextFormat ) const; + const QwtTextEngine *textEngine(QwtText::TextFormat) const; + const QwtTextEngine *textEngine(const QString &, QwtText::TextFormat) const; - private: - TextEngineDict(); - ~TextEngineDict(); +private: + TextEngineDict(); + ~TextEngineDict(); - typedef QMap< int, QwtTextEngine* > EngineMap; + typedef QMap EngineMap; - inline const QwtTextEngine* engine( EngineMap::const_iterator& it ) const - { - return it.value(); - } + inline const QwtTextEngine *engine(EngineMap::const_iterator &it) const + { + return it.value(); + } - EngineMap m_map; - }; + EngineMap m_map; +}; - TextEngineDict& TextEngineDict::dict() - { - static TextEngineDict engineDict; - return engineDict; - } - - TextEngineDict::TextEngineDict() - { - m_map.insert( QwtText::PlainText, new QwtPlainTextEngine() ); - #ifndef QT_NO_RICHTEXT - m_map.insert( QwtText::RichText, new QwtRichTextEngine() ); - #endif - } - - TextEngineDict::~TextEngineDict() - { - for ( EngineMap::const_iterator it = m_map.constBegin(); - it != m_map.constEnd(); ++it ) - { - const QwtTextEngine* textEngine = engine( it ); - delete textEngine; - } - } - - const QwtTextEngine* TextEngineDict::textEngine( const QString& text, - QwtText::TextFormat format ) const - { - if ( format == QwtText::AutoText ) - { - for ( EngineMap::const_iterator it = m_map.begin(); - it != m_map.end(); ++it ) - { - if ( it.key() != QwtText::PlainText ) - { - const QwtTextEngine* e = engine( it ); - if ( e && e->mightRender( text ) ) - return e; - } - } - } - - EngineMap::const_iterator it = m_map.find( format ); - if ( it != m_map.end() ) - { - const QwtTextEngine* e = engine( it ); - if ( e ) - return e; - } - - it = m_map.find( QwtText::PlainText ); - return engine( it ); - } - - void TextEngineDict::setTextEngine( QwtText::TextFormat format, - QwtTextEngine* engine ) - { - if ( format == QwtText::AutoText ) - return; - - if ( format == QwtText::PlainText && engine == NULL ) - return; - - EngineMap::const_iterator it = m_map.constFind( format ); - if ( it != m_map.constEnd() ) - { - delete this->engine( it ); - m_map.remove( format ); - } - - if ( engine != NULL ) - m_map.insert( format, engine ); - } - - const QwtTextEngine* TextEngineDict::textEngine( - QwtText::TextFormat format ) const - { - const QwtTextEngine* e = NULL; - - EngineMap::const_iterator it = m_map.find( format ); - if ( it != m_map.end() ) - e = engine( it ); - - return e; - } +TextEngineDict &TextEngineDict::dict() +{ + static TextEngineDict engineDict; + return engineDict; } +TextEngineDict::TextEngineDict() +{ + m_map.insert(QwtText::PlainText, new QwtPlainTextEngine()); +#ifndef QT_NO_RICHTEXT + m_map.insert(QwtText::RichText, new QwtRichTextEngine()); +#endif +} + +TextEngineDict::~TextEngineDict() +{ + for (EngineMap::const_iterator it = m_map.constBegin(); + it != m_map.constEnd(); ++it) + { + const QwtTextEngine *textEngine = engine(it); + delete textEngine; + } +} + +const QwtTextEngine * +TextEngineDict::textEngine(const QString &text, + QwtText::TextFormat format) const +{ + if (format == QwtText::AutoText) + { + for (EngineMap::const_iterator it = m_map.begin(); it != m_map.end(); ++it) + { + if (it.key() != QwtText::PlainText) + { + const QwtTextEngine *e = engine(it); + if (e && e->mightRender(text)) + return e; + } + } + } + + EngineMap::const_iterator it = m_map.find(format); + if (it != m_map.end()) + { + const QwtTextEngine *e = engine(it); + if (e) + return e; + } + + it = m_map.find(QwtText::PlainText); + return engine(it); +} + +void TextEngineDict::setTextEngine(QwtText::TextFormat format, + QwtTextEngine *engine) +{ + if (format == QwtText::AutoText) + return; + + if (format == QwtText::PlainText && engine == NULL) + return; + + EngineMap::const_iterator it = m_map.constFind(format); + if (it != m_map.constEnd()) + { + delete this->engine(it); + m_map.remove(format); + } + + if (engine != NULL) + m_map.insert(format, engine); +} + +const QwtTextEngine * +TextEngineDict::textEngine(QwtText::TextFormat format) const +{ + const QwtTextEngine *e = NULL; + + EngineMap::const_iterator it = m_map.find(format); + if (it != m_map.end()) + e = engine(it); + + return e; +} +} // namespace + class QwtText::PrivateData { - public: - PrivateData(): - renderFlags( Qt::AlignCenter ), - borderRadius( 0 ), - borderPen( Qt::NoPen ), - backgroundBrush( Qt::NoBrush ), - textEngine( NULL ) - { - } +public: + PrivateData() + : renderFlags(Qt::AlignCenter) + , borderRadius(0) + , borderPen(Qt::NoPen) + , backgroundBrush(Qt::NoBrush) + , textEngine(NULL) + { + } - int renderFlags; - QString text; - QFont font; - QColor color; - double borderRadius; - QPen borderPen; - QBrush backgroundBrush; + int renderFlags; + QString text; + QFont font; + QColor color; + double borderRadius; + QPen borderPen; + QBrush backgroundBrush; - QwtText::PaintAttributes paintAttributes; - QwtText::LayoutAttributes layoutAttributes; + QwtText::PaintAttributes paintAttributes; + QwtText::LayoutAttributes layoutAttributes; - const QwtTextEngine* textEngine; + const QwtTextEngine *textEngine; }; class QwtText::LayoutCache { - public: - void invalidate() - { - textSize = QSizeF(); - } +public: + void invalidate() { textSize = QSizeF(); } - QFont font; - QSizeF textSize; + QFont font; + QSizeF textSize; }; /*! @@ -200,10 +196,10 @@ class QwtText::LayoutCache */ QwtText::QwtText() { - m_data = new PrivateData; - m_data->textEngine = textEngine( m_data->text, PlainText ); + m_data = new PrivateData; + m_data->textEngine = textEngine(m_data->text, PlainText); - m_layoutCache = new LayoutCache; + m_layoutCache = new LayoutCache; } /*! @@ -212,58 +208,58 @@ QwtText::QwtText() \param text Text content \param textFormat Text format */ -QwtText::QwtText( const QString& text, QwtText::TextFormat textFormat ) +QwtText::QwtText(const QString &text, QwtText::TextFormat textFormat) { - m_data = new PrivateData; - m_data->text = text; - m_data->textEngine = textEngine( text, textFormat ); + m_data = new PrivateData; + m_data->text = text; + m_data->textEngine = textEngine(text, textFormat); - m_layoutCache = new LayoutCache; + m_layoutCache = new LayoutCache; } //! Copy constructor -QwtText::QwtText( const QwtText& other ) +QwtText::QwtText(const QwtText &other) { - m_data = new PrivateData; - *m_data = *other.m_data; + m_data = new PrivateData; + *m_data = *other.m_data; - m_layoutCache = new LayoutCache; - *m_layoutCache = *other.m_layoutCache; + m_layoutCache = new LayoutCache; + *m_layoutCache = *other.m_layoutCache; } //! Destructor QwtText::~QwtText() { - delete m_data; - delete m_layoutCache; + delete m_data; + delete m_layoutCache; } //! Assignment operator -QwtText& QwtText::operator=( const QwtText& other ) +QwtText &QwtText::operator=(const QwtText &other) { - *m_data = *other.m_data; - *m_layoutCache = *other.m_layoutCache; - return *this; + *m_data = *other.m_data; + *m_layoutCache = *other.m_layoutCache; + return *this; } //! Relational operator -bool QwtText::operator==( const QwtText& other ) const +bool QwtText::operator==(const QwtText &other) const { - return m_data->renderFlags == other.m_data->renderFlags && - m_data->text == other.m_data->text && - m_data->font == other.m_data->font && - m_data->color == other.m_data->color && - m_data->borderRadius == other.m_data->borderRadius && - m_data->borderPen == other.m_data->borderPen && - m_data->backgroundBrush == other.m_data->backgroundBrush && - m_data->paintAttributes == other.m_data->paintAttributes && - m_data->textEngine == other.m_data->textEngine; + return m_data->renderFlags == other.m_data->renderFlags + && m_data->text == other.m_data->text + && m_data->font == other.m_data->font + && m_data->color == other.m_data->color + && m_data->borderRadius == other.m_data->borderRadius + && m_data->borderPen == other.m_data->borderPen + && m_data->backgroundBrush == other.m_data->backgroundBrush + && m_data->paintAttributes == other.m_data->paintAttributes + && m_data->textEngine == other.m_data->textEngine; } //! Relational operator -bool QwtText::operator!=( const QwtText& other ) const // invalidate +bool QwtText::operator!=(const QwtText &other) const // invalidate { - return !( other == *this ); + return !(other == *this); } /*! @@ -274,12 +270,11 @@ bool QwtText::operator!=( const QwtText& other ) const // invalidate \sa text() */ -void QwtText::setText( const QString& text, - QwtText::TextFormat textFormat ) +void QwtText::setText(const QString &text, QwtText::TextFormat textFormat) { - m_data->text = text; - m_data->textEngine = textEngine( text, textFormat ); - m_layoutCache->invalidate(); + m_data->text = text; + m_data->textEngine = textEngine(text, textFormat); + m_layoutCache->invalidate(); } /*! @@ -288,7 +283,7 @@ void QwtText::setText( const QString& text, */ QString QwtText::text() const { - return m_data->text; + return m_data->text; } /*! @@ -301,13 +296,13 @@ QString QwtText::text() const \sa renderFlags(), QwtTextEngine::draw() \note Some renderFlags might have no effect, depending on the text format. */ -void QwtText::setRenderFlags( int renderFlags ) +void QwtText::setRenderFlags(int renderFlags) { - if ( renderFlags != m_data->renderFlags ) - { - m_data->renderFlags = renderFlags; - m_layoutCache->invalidate(); - } + if (renderFlags != m_data->renderFlags) + { + m_data->renderFlags = renderFlags; + m_layoutCache->invalidate(); + } } /*! @@ -316,7 +311,7 @@ void QwtText::setRenderFlags( int renderFlags ) */ int QwtText::renderFlags() const { - return m_data->renderFlags; + return m_data->renderFlags; } /*! @@ -326,16 +321,16 @@ int QwtText::renderFlags() const \note Setting the font might have no effect, when the text contains control sequences for setting fonts. */ -void QwtText::setFont( const QFont& font ) +void QwtText::setFont(const QFont &font) { - m_data->font = font; - setPaintAttribute( PaintUsingTextFont ); + m_data->font = font; + setPaintAttribute(PaintUsingTextFont); } //! Return the font. QFont QwtText::font() const { - return m_data->font; + return m_data->font; } /*! @@ -347,12 +342,12 @@ QFont QwtText::font() const \sa setFont(), font(), PaintAttributes */ -QFont QwtText::usedFont( const QFont& defaultFont ) const +QFont QwtText::usedFont(const QFont &defaultFont) const { - if ( m_data->paintAttributes & PaintUsingTextFont ) - return m_data->font; + if (m_data->paintAttributes & PaintUsingTextFont) + return m_data->font; - return defaultFont; + return defaultFont; } /*! @@ -362,16 +357,16 @@ QFont QwtText::usedFont( const QFont& defaultFont ) const \note Setting the color might have no effect, when the text contains control sequences for setting colors. */ -void QwtText::setColor( const QColor& color ) +void QwtText::setColor(const QColor &color) { - m_data->color = color; - setPaintAttribute( PaintUsingTextColor ); + m_data->color = color; + setPaintAttribute(PaintUsingTextColor); } //! Return the pen color, used for painting the text QColor QwtText::color() const { - return m_data->color; + return m_data->color; } /*! @@ -383,12 +378,12 @@ QColor QwtText::color() const \sa setColor(), color(), PaintAttributes */ -QColor QwtText::usedColor( const QColor& defaultColor ) const +QColor QwtText::usedColor(const QColor &defaultColor) const { - if ( m_data->paintAttributes & PaintUsingTextColor ) - return m_data->color; + if (m_data->paintAttributes & PaintUsingTextColor) + return m_data->color; - return defaultColor; + return defaultColor; } /*! @@ -397,9 +392,9 @@ QColor QwtText::usedColor( const QColor& defaultColor ) const \param radius Radius of a rounded corner \sa borderRadius(), setBorderPen(), setBackgroundBrush() */ -void QwtText::setBorderRadius( double radius ) +void QwtText::setBorderRadius(double radius) { - m_data->borderRadius = qwtMaxF( 0.0, radius ); + m_data->borderRadius = qwtMaxF(0.0, radius); } /*! @@ -408,7 +403,7 @@ void QwtText::setBorderRadius( double radius ) */ double QwtText::borderRadius() const { - return m_data->borderRadius; + return m_data->borderRadius; } /*! @@ -417,10 +412,10 @@ double QwtText::borderRadius() const \param pen Background pen \sa borderPen(), setBackgroundBrush() */ -void QwtText::setBorderPen( const QPen& pen ) +void QwtText::setBorderPen(const QPen &pen) { - m_data->borderPen = pen; - setPaintAttribute( PaintBackground ); + m_data->borderPen = pen; + setPaintAttribute(PaintBackground); } /*! @@ -429,7 +424,7 @@ void QwtText::setBorderPen( const QPen& pen ) */ QPen QwtText::borderPen() const { - return m_data->borderPen; + return m_data->borderPen; } /*! @@ -438,10 +433,10 @@ QPen QwtText::borderPen() const \param brush Background brush \sa backgroundBrush(), setBorderPen() */ -void QwtText::setBackgroundBrush( const QBrush& brush ) +void QwtText::setBackgroundBrush(const QBrush &brush) { - m_data->backgroundBrush = brush; - setPaintAttribute( PaintBackground ); + m_data->backgroundBrush = brush; + setPaintAttribute(PaintBackground); } /*! @@ -450,7 +445,7 @@ void QwtText::setBackgroundBrush( const QBrush& brush ) */ QBrush QwtText::backgroundBrush() const { - return m_data->backgroundBrush; + return m_data->backgroundBrush; } /*! @@ -463,12 +458,12 @@ QBrush QwtText::backgroundBrush() const setBorderPen() and setBackgroundBrush() \sa testPaintAttribute() */ -void QwtText::setPaintAttribute( PaintAttribute attribute, bool on ) +void QwtText::setPaintAttribute(PaintAttribute attribute, bool on) { - if ( on ) - m_data->paintAttributes |= attribute; - else - m_data->paintAttributes &= ~attribute; + if (on) + m_data->paintAttributes |= attribute; + else + m_data->paintAttributes &= ~attribute; } /*! @@ -479,9 +474,9 @@ void QwtText::setPaintAttribute( PaintAttribute attribute, bool on ) \sa setPaintAttribute() */ -bool QwtText::testPaintAttribute( PaintAttribute attribute ) const +bool QwtText::testPaintAttribute(PaintAttribute attribute) const { - return m_data->paintAttributes & attribute; + return m_data->paintAttributes & attribute; } /*! @@ -491,12 +486,12 @@ bool QwtText::testPaintAttribute( PaintAttribute attribute ) const \param on On/Off \sa testLayoutAttribute() */ -void QwtText::setLayoutAttribute( LayoutAttribute attribute, bool on ) +void QwtText::setLayoutAttribute(LayoutAttribute attribute, bool on) { - if ( on ) - m_data->layoutAttributes |= attribute; - else - m_data->layoutAttributes &= ~attribute; + if (on) + m_data->layoutAttributes |= attribute; + else + m_data->layoutAttributes &= ~attribute; } /*! @@ -507,9 +502,9 @@ void QwtText::setLayoutAttribute( LayoutAttribute attribute, bool on ) \sa setLayoutAttribute() */ -bool QwtText::testLayoutAttribute( LayoutAttribute attribute ) const +bool QwtText::testLayoutAttribute(LayoutAttribute attribute) const { - return m_data->layoutAttributes | attribute; + return m_data->layoutAttributes | attribute; } /*! @@ -519,9 +514,9 @@ bool QwtText::testLayoutAttribute( LayoutAttribute attribute ) const \return Calculated height */ -double QwtText::heightForWidth( double width ) const +double QwtText::heightForWidth(double width) const { - return heightForWidth( width, QFont() ); + return heightForWidth(width, QFont()); } /*! @@ -532,34 +527,33 @@ double QwtText::heightForWidth( double width ) const \return Calculated height */ -double QwtText::heightForWidth( double width, const QFont& defaultFont ) const +double QwtText::heightForWidth(double width, const QFont &defaultFont) const { - // We want to calculate in screen metrics. So - // we need a font that uses screen metrics + // We want to calculate in screen metrics. So + // we need a font that uses screen metrics - const QFont font = QwtPainter::scaledFont( usedFont( defaultFont ) ); + const QFont font = QwtPainter::scaledFont(usedFont(defaultFont)); - double h = 0; + double h = 0; - if ( m_data->layoutAttributes & MinimumLayout ) - { - double left, right, top, bottom; - m_data->textEngine->textMargins( font, m_data->text, - left, right, top, bottom ); + if (m_data->layoutAttributes & MinimumLayout) + { + double left, right, top, bottom; + m_data->textEngine->textMargins(font, m_data->text, left, right, top, + bottom); - h = m_data->textEngine->heightForWidth( - font, m_data->renderFlags, m_data->text, - width + left + right ); + h = m_data->textEngine->heightForWidth(font, m_data->renderFlags, + m_data->text, width + left + right); - h -= top + bottom; - } - else - { - h = m_data->textEngine->heightForWidth( - font, m_data->renderFlags, m_data->text, width ); - } + h -= top + bottom; + } + else + { + h = m_data->textEngine->heightForWidth(font, m_data->renderFlags, + m_data->text, width); + } - return h; + return h; } /*! @@ -569,7 +563,7 @@ double QwtText::heightForWidth( double width, const QFont& defaultFont ) const */ QSizeF QwtText::textSize() const { - return textSize( QFont() ); + return textSize(QFont()); } /*! @@ -578,32 +572,31 @@ QSizeF QwtText::textSize() const \param defaultFont Font of the text \return Calculated size */ -QSizeF QwtText::textSize( const QFont& defaultFont ) const +QSizeF QwtText::textSize(const QFont &defaultFont) const { - // We want to calculate in screen metrics. So - // we need a font that uses screen metrics + // We want to calculate in screen metrics. So + // we need a font that uses screen metrics - const QFont font = QwtPainter::scaledFont( usedFont( defaultFont ) ); + const QFont font = QwtPainter::scaledFont(usedFont(defaultFont)); - if ( !m_layoutCache->textSize.isValid() - || m_layoutCache->font != font ) - { - m_layoutCache->textSize = m_data->textEngine->textSize( - font, m_data->renderFlags, m_data->text ); - m_layoutCache->font = font; - } + if (!m_layoutCache->textSize.isValid() || m_layoutCache->font != font) + { + m_layoutCache->textSize + = m_data->textEngine->textSize(font, m_data->renderFlags, m_data->text); + m_layoutCache->font = font; + } - QSizeF sz = m_layoutCache->textSize; + QSizeF sz = m_layoutCache->textSize; - if ( m_data->layoutAttributes & MinimumLayout ) - { - double left, right, top, bottom; - m_data->textEngine->textMargins( font, m_data->text, - left, right, top, bottom ); - sz -= QSizeF( left + right, top + bottom ); - } + if (m_data->layoutAttributes & MinimumLayout) + { + double left, right, top, bottom; + m_data->textEngine->textMargins(font, m_data->text, left, right, top, + bottom); + sz -= QSizeF(left + right, top + bottom); + } - return sz; + return sz; } /*! @@ -612,68 +605,68 @@ QSizeF QwtText::textSize( const QFont& defaultFont ) const \param painter Painter \param rect Rectangle */ -void QwtText::draw( QPainter* painter, const QRectF& rect ) const +void QwtText::draw(QPainter *painter, const QRectF &rect) const { - if ( m_data->paintAttributes & PaintBackground ) + if (m_data->paintAttributes & PaintBackground) + { + if (m_data->borderPen != Qt::NoPen + || m_data->backgroundBrush != Qt::NoBrush) { - if ( m_data->borderPen != Qt::NoPen || - m_data->backgroundBrush != Qt::NoBrush ) - { - painter->save(); + painter->save(); - painter->setPen( m_data->borderPen ); - painter->setBrush( m_data->backgroundBrush ); + painter->setPen(m_data->borderPen); + painter->setBrush(m_data->backgroundBrush); - if ( m_data->borderRadius == 0 ) - { - QwtPainter::drawRect( painter, rect ); - } - else - { - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->drawRoundedRect( rect, - m_data->borderRadius, m_data->borderRadius ); - } + if (m_data->borderRadius == 0) + { + QwtPainter::drawRect(painter, rect); + } + else + { + painter->setRenderHint(QPainter::Antialiasing, true); + painter->drawRoundedRect(rect, m_data->borderRadius, + m_data->borderRadius); + } - painter->restore(); - } + painter->restore(); } + } - painter->save(); + painter->save(); - if ( m_data->paintAttributes & PaintUsingTextFont ) - { - painter->setFont( m_data->font ); - } + if (m_data->paintAttributes & PaintUsingTextFont) + { + painter->setFont(m_data->font); + } - if ( m_data->paintAttributes & PaintUsingTextColor ) - { - if ( m_data->color.isValid() ) - painter->setPen( m_data->color ); - } + if (m_data->paintAttributes & PaintUsingTextColor) + { + if (m_data->color.isValid()) + painter->setPen(m_data->color); + } - QRectF expandedRect = rect; - if ( m_data->layoutAttributes & MinimumLayout ) - { - // We want to calculate in screen metrics. So - // we need a font that uses screen metrics + QRectF expandedRect = rect; + if (m_data->layoutAttributes & MinimumLayout) + { + // We want to calculate in screen metrics. So + // we need a font that uses screen metrics - const QFont font = QwtPainter::scaledFont( painter->font() ); + const QFont font = QwtPainter::scaledFont(painter->font()); - double left, right, top, bottom; - m_data->textEngine->textMargins( - font, m_data->text, left, right, top, bottom ); + double left, right, top, bottom; + m_data->textEngine->textMargins(font, m_data->text, left, right, top, + bottom); - expandedRect.setTop( rect.top() - top ); - expandedRect.setBottom( rect.bottom() + bottom ); - expandedRect.setLeft( rect.left() - left ); - expandedRect.setRight( rect.right() + right ); - } + expandedRect.setTop(rect.top() - top); + expandedRect.setBottom(rect.bottom() + bottom); + expandedRect.setLeft(rect.left() - left); + expandedRect.setRight(rect.right() + right); + } - m_data->textEngine->draw( painter, expandedRect, - m_data->renderFlags, m_data->text ); + m_data->textEngine->draw(painter, expandedRect, m_data->renderFlags, + m_data->text); - painter->restore(); + painter->restore(); } /*! @@ -691,10 +684,10 @@ void QwtText::draw( QPainter* painter, const QRectF& rect ) const \return Corresponding text engine */ -const QwtTextEngine* QwtText::textEngine( const QString& text, - QwtText::TextFormat format ) +const QwtTextEngine *QwtText::textEngine(const QString &text, + QwtText::TextFormat format) { - return TextEngineDict::dict().textEngine( text, format ); + return TextEngineDict::dict().textEngine(text, format); } /*! @@ -710,10 +703,9 @@ const QwtTextEngine* QwtText::textEngine( const QString& text, \warning Using QwtText::AutoText does nothing. */ -void QwtText::setTextEngine( QwtText::TextFormat format, - QwtTextEngine* engine ) +void QwtText::setTextEngine(QwtText::TextFormat format, QwtTextEngine *engine) { - TextEngineDict::dict().setTextEngine( format, engine ); + TextEngineDict::dict().setTextEngine(format, engine); } /*! @@ -724,20 +716,19 @@ void QwtText::setTextEngine( QwtText::TextFormat format, \param format Text format \return The text engine, or NULL if no engine is available. */ -const QwtTextEngine* QwtText::textEngine( QwtText::TextFormat format ) +const QwtTextEngine *QwtText::textEngine(QwtText::TextFormat format) { - return TextEngineDict::dict().textEngine( format ); + return TextEngineDict::dict().textEngine(format); } //! \return text().isNull() bool QwtText::isNull() const { - return m_data->text.isNull(); + return m_data->text.isNull(); } //! \return text().isEmpty() bool QwtText::isEmpty() const { - return m_data->text.isEmpty(); + return m_data->text.isEmpty(); } - diff --git a/libs/qwt/src/qwt_text.h b/libs/qwt/src/qwt_text.h index f9ee74c9..61092f68 100644 --- a/libs/qwt/src/qwt_text.h +++ b/libs/qwt/src/qwt_text.h @@ -50,169 +50,167 @@ class QwtTextEngine; class QWT_EXPORT QwtText { - public: +public: + /*! + \brief Text format + + The text format defines the QwtTextEngine, that is used to render + the text. + + \sa QwtTextEngine, setTextEngine() + */ + + enum TextFormat + { + /*! + The text format is determined using QwtTextEngine::mightRender() for + all available text engines in increasing order > PlainText. + If none of the text engines can render the text is rendered + like QwtText::PlainText. + */ + AutoText = 0, + + //! Draw the text as it is, using a QwtPlainTextEngine. + PlainText, + + //! Use the Scribe framework (Qt Rich Text) to render the text. + RichText, /*! - \brief Text format + Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine + to display the text. In earlier versions of Qwt such an engine + was included - since Qwt 6.2 it can be found here: + https://github.com/uwerat/qwt-mml-dev - The text format defines the QwtTextEngine, that is used to render - the text. + To enable MathML support the following code needs to be added to the + application: - \sa QwtTextEngine, setTextEngine() + \code + QwtText::setTextEngine( QwtText::MathMLText, new QwtMathMLTextEngine() + ); \endcode */ - - enum TextFormat - { - /*! - The text format is determined using QwtTextEngine::mightRender() for - all available text engines in increasing order > PlainText. - If none of the text engines can render the text is rendered - like QwtText::PlainText. - */ - AutoText = 0, - - //! Draw the text as it is, using a QwtPlainTextEngine. - PlainText, - - //! Use the Scribe framework (Qt Rich Text) to render the text. - RichText, - - /*! - Use a MathML (http://en.wikipedia.org/wiki/MathML) render engine - to display the text. In earlier versions of Qwt such an engine - was included - since Qwt 6.2 it can be found here: - https://github.com/uwerat/qwt-mml-dev - - To enable MathML support the following code needs to be added to the - application: - - \code - QwtText::setTextEngine( QwtText::MathMLText, new QwtMathMLTextEngine() ); - \endcode - */ - MathMLText, - - /*! - Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine - to display the text ( not implemented yet ). - */ - TeXText, - - /*! - The number of text formats can be extended using setTextEngine. - Formats >= QwtText::OtherFormat are not used by Qwt. - */ - OtherFormat = 100 - }; + MathMLText, /*! - \brief Paint Attributes - - Font and color and background are optional attributes of a QwtText. - The paint attributes hold the information, if they are set. + Use a TeX (http://en.wikipedia.org/wiki/TeX) render engine + to display the text ( not implemented yet ). */ - enum PaintAttribute - { - //! The text has an individual font. - PaintUsingTextFont = 0x01, - - //! The text has an individual color. - PaintUsingTextColor = 0x02, - - //! The text has an individual background. - PaintBackground = 0x04 - }; - - Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute ) + TeXText, /*! - \brief Layout Attributes - The layout attributes affects some aspects of the layout of the text. + The number of text formats can be extended using setTextEngine. + Formats >= QwtText::OtherFormat are not used by Qwt. */ - enum LayoutAttribute - { - /*! - Layout the text without its margins. This mode is useful if a - text needs to be aligned accurately, like the tick labels of a scale. - If QwtTextEngine::textMargins is not implemented for the format - of the text, MinimumLayout has no effect. - */ - MinimumLayout = 0x01 - }; + OtherFormat = 100 + }; - Q_DECLARE_FLAGS( LayoutAttributes, LayoutAttribute ) + /*! + \brief Paint Attributes - QwtText(); - QwtText( const QString&, TextFormat textFormat = AutoText ); - QwtText( const QwtText& ); + Font and color and background are optional attributes of a QwtText. + The paint attributes hold the information, if they are set. + */ + enum PaintAttribute + { + //! The text has an individual font. + PaintUsingTextFont = 0x01, - ~QwtText(); + //! The text has an individual color. + PaintUsingTextColor = 0x02, - QwtText& operator=( const QwtText& ); + //! The text has an individual background. + PaintBackground = 0x04 + }; - bool operator==( const QwtText& ) const; - bool operator!=( const QwtText& ) const; + Q_DECLARE_FLAGS(PaintAttributes, PaintAttribute) - void setText( const QString&, - QwtText::TextFormat textFormat = AutoText ); - QString text() const; + /*! + \brief Layout Attributes + The layout attributes affects some aspects of the layout of the text. + */ + enum LayoutAttribute + { + /*! + Layout the text without its margins. This mode is useful if a + text needs to be aligned accurately, like the tick labels of a scale. + If QwtTextEngine::textMargins is not implemented for the format + of the text, MinimumLayout has no effect. + */ + MinimumLayout = 0x01 + }; - bool isNull() const; - bool isEmpty() const; + Q_DECLARE_FLAGS(LayoutAttributes, LayoutAttribute) - void setFont( const QFont& ); - QFont font() const; + QwtText(); + QwtText(const QString &, TextFormat textFormat = AutoText); + QwtText(const QwtText &); - QFont usedFont( const QFont& ) const; + ~QwtText(); - void setRenderFlags( int ); - int renderFlags() const; + QwtText &operator=(const QwtText &); - void setColor( const QColor& ); - QColor color() const; + bool operator==(const QwtText &) const; + bool operator!=(const QwtText &) const; - QColor usedColor( const QColor& ) const; + void setText(const QString &, QwtText::TextFormat textFormat = AutoText); + QString text() const; - void setBorderRadius( double ); - double borderRadius() const; + bool isNull() const; + bool isEmpty() const; - void setBorderPen( const QPen& ); - QPen borderPen() const; + void setFont(const QFont &); + QFont font() const; - void setBackgroundBrush( const QBrush& ); - QBrush backgroundBrush() const; + QFont usedFont(const QFont &) const; - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; + void setRenderFlags(int); + int renderFlags() const; - void setLayoutAttribute( LayoutAttribute, bool on = true ); - bool testLayoutAttribute( LayoutAttribute ) const; + void setColor(const QColor &); + QColor color() const; - double heightForWidth( double width ) const; - double heightForWidth( double width, const QFont& ) const; + QColor usedColor(const QColor &) const; - QSizeF textSize() const; - QSizeF textSize( const QFont& ) const; + void setBorderRadius(double); + double borderRadius() const; - void draw( QPainter* painter, const QRectF& rect ) const; + void setBorderPen(const QPen &); + QPen borderPen() const; - static const QwtTextEngine* textEngine( - const QString& text, QwtText::TextFormat = AutoText ); + void setBackgroundBrush(const QBrush &); + QBrush backgroundBrush() const; - static const QwtTextEngine* textEngine( QwtText::TextFormat ); - static void setTextEngine( QwtText::TextFormat, QwtTextEngine* ); + void setPaintAttribute(PaintAttribute, bool on = true); + bool testPaintAttribute(PaintAttribute) const; - private: - class PrivateData; - PrivateData* m_data; + void setLayoutAttribute(LayoutAttribute, bool on = true); + bool testLayoutAttribute(LayoutAttribute) const; - class LayoutCache; - LayoutCache* m_layoutCache; + double heightForWidth(double width) const; + double heightForWidth(double width, const QFont &) const; + + QSizeF textSize() const; + QSizeF textSize(const QFont &) const; + + void draw(QPainter *painter, const QRectF &rect) const; + + static const QwtTextEngine *textEngine(const QString &text, + QwtText::TextFormat = AutoText); + + static const QwtTextEngine *textEngine(QwtText::TextFormat); + static void setTextEngine(QwtText::TextFormat, QwtTextEngine *); + +private: + class PrivateData; + PrivateData *m_data; + + class LayoutCache; + LayoutCache *m_layoutCache; }; -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::PaintAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes ) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::PaintAttributes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QwtText::LayoutAttributes) -Q_DECLARE_METATYPE( QwtText ) +Q_DECLARE_METATYPE(QwtText) #endif diff --git a/libs/qwt/src/qwt_text_engine.cpp b/libs/qwt/src/qwt_text_engine.cpp index 49941588..0e165b89 100644 --- a/libs/qwt/src/qwt_text_engine.cpp +++ b/libs/qwt/src/qwt_text_engine.cpp @@ -19,144 +19,138 @@ #include #include -static QString taggedRichText( const QString& text, int flags ) +static QString taggedRichText(const QString &text, int flags) { - QString richText = text; + QString richText = text; - // By default QSimpleRichText is Qt::AlignLeft - if ( flags & Qt::AlignJustify ) - { - richText.prepend( QLatin1String( "
" ) ); - richText.append( QLatin1String ( "
" ) ); - } - else if ( flags & Qt::AlignRight ) - { - richText.prepend( QLatin1String ( "
" ) ); - richText.append( QLatin1String ( "
" ) ); - } - else if ( flags & Qt::AlignHCenter ) - { - richText.prepend( QLatin1String ( "
" ) ); - richText.append( QLatin1String ( "
" ) ); - } + // By default QSimpleRichText is Qt::AlignLeft + if (flags & Qt::AlignJustify) + { + richText.prepend(QLatin1String("
")); + richText.append(QLatin1String("
")); + } + else if (flags & Qt::AlignRight) + { + richText.prepend(QLatin1String("
")); + richText.append(QLatin1String("
")); + } + else if (flags & Qt::AlignHCenter) + { + richText.prepend(QLatin1String("
")); + richText.append(QLatin1String("
")); + } - return richText; + return richText; } namespace { - class QwtRichTextDocument : public QTextDocument - { - public: - QwtRichTextDocument( const QString& text, int flags, const QFont& font ) - { - setUndoRedoEnabled( false ); - setDefaultFont( font ); - setHtml( text ); +class QwtRichTextDocument : public QTextDocument +{ +public: + QwtRichTextDocument(const QString &text, int flags, const QFont &font) + { + setUndoRedoEnabled(false); + setDefaultFont(font); + setHtml(text); - // make sure we have a document layout - ( void )documentLayout(); + // make sure we have a document layout + (void)documentLayout(); - QTextOption option = defaultTextOption(); - if ( flags & Qt::TextWordWrap ) - option.setWrapMode( QTextOption::WordWrap ); - else - option.setWrapMode( QTextOption::NoWrap ); + QTextOption option = defaultTextOption(); + if (flags & Qt::TextWordWrap) + option.setWrapMode(QTextOption::WordWrap); + else + option.setWrapMode(QTextOption::NoWrap); - option.setAlignment( static_cast< Qt::Alignment >( flags ) ); - setDefaultTextOption( option ); + option.setAlignment(static_cast(flags)); + setDefaultTextOption(option); - QTextFrame* root = rootFrame(); - QTextFrameFormat fm = root->frameFormat(); - fm.setBorder( 0 ); - fm.setMargin( 0 ); - fm.setPadding( 0 ); - fm.setBottomMargin( 0 ); - fm.setLeftMargin( 0 ); - root->setFrameFormat( fm ); + QTextFrame *root = rootFrame(); + QTextFrameFormat fm = root->frameFormat(); + fm.setBorder(0); + fm.setMargin(0); + fm.setPadding(0); + fm.setBottomMargin(0); + fm.setLeftMargin(0); + root->setFrameFormat(fm); - adjustSize(); - } - }; -} + adjustSize(); + } +}; +} // namespace class QwtPlainTextEngine::PrivateData { - public: - int effectiveAscent( const QFont& font ) const +public: + int effectiveAscent(const QFont &font) const + { + const QString fontKey = font.key(); + + QMap::const_iterator it = m_ascentCache.constFind(fontKey); + + if (it != m_ascentCache.constEnd()) + return *it; + + const int ascent = findAscent(font); + m_ascentCache.insert(fontKey, ascent); + + return ascent; + } + +private: + static int findAscent(const QFont &font) + { + static const QString dummy("E"); + static const QColor white(Qt::white); + + const QFontMetrics fm(font); + + QPixmap pm(QwtPainter::horizontalAdvance(fm, dummy), fm.height()); + pm.fill(white); + + QPainter p(&pm); + p.setFont(font); + p.drawText(0, 0, pm.width(), pm.height(), 0, dummy); + p.end(); + + const QImage img = pm.toImage(); + + int row = 0; + for (row = 0; row < img.height(); row++) { - const QString fontKey = font.key(); + const QRgb *line = reinterpret_cast(img.scanLine(row)); - QMap< QString, int >::const_iterator it = - m_ascentCache.constFind( fontKey ); - - if ( it != m_ascentCache.constEnd() ) - return *it; - - const int ascent = findAscent( font ); - m_ascentCache.insert( fontKey, ascent ); - - return ascent; + const int w = pm.width(); + for (int col = 0; col < w; col++) + { + if (line[col] != white.rgb()) + return fm.ascent() - row + 1; + } } - private: - static int findAscent( const QFont& font ) - { - static const QString dummy( "E" ); - static const QColor white( Qt::white ); + return fm.ascent(); + } - const QFontMetrics fm( font ); - - QPixmap pm( QwtPainter::horizontalAdvance( fm, dummy ), fm.height() ); - pm.fill( white ); - - QPainter p( &pm ); - p.setFont( font ); - p.drawText( 0, 0, pm.width(), pm.height(), 0, dummy ); - p.end(); - - const QImage img = pm.toImage(); - - int row = 0; - for ( row = 0; row < img.height(); row++ ) - { - const QRgb* line = reinterpret_cast< const QRgb* >( - img.scanLine( row ) ); - - const int w = pm.width(); - for ( int col = 0; col < w; col++ ) - { - if ( line[col] != white.rgb() ) - return fm.ascent() - row + 1; - } - } - - return fm.ascent(); - } - - mutable QMap< QString, int > m_ascentCache; + mutable QMap m_ascentCache; }; //! Constructor -QwtTextEngine::QwtTextEngine() -{ -} +QwtTextEngine::QwtTextEngine() {} //! Destructor -QwtTextEngine::~QwtTextEngine() -{ -} +QwtTextEngine::~QwtTextEngine() {} //! Constructor QwtPlainTextEngine::QwtPlainTextEngine() { - m_data = new PrivateData; + m_data = new PrivateData; } //! Destructor QwtPlainTextEngine::~QwtPlainTextEngine() { - delete m_data; + delete m_data; } /*! @@ -169,14 +163,15 @@ QwtPlainTextEngine::~QwtPlainTextEngine() \return Calculated height */ -double QwtPlainTextEngine::heightForWidth( const QFont& font, int flags, - const QString& text, double width ) const +double QwtPlainTextEngine::heightForWidth(const QFont &font, int flags, + const QString &text, + double width) const { - const QFontMetricsF fm( font ); - const QRectF rect = fm.boundingRect( - QRectF( 0, 0, width, QWIDGETSIZE_MAX ), flags, text ); + const QFontMetricsF fm(font); + const QRectF rect + = fm.boundingRect(QRectF(0, 0, width, QWIDGETSIZE_MAX), flags, text); - return rect.height(); + return rect.height(); } /*! @@ -188,14 +183,14 @@ double QwtPlainTextEngine::heightForWidth( const QFont& font, int flags, \return Calculated size */ -QSizeF QwtPlainTextEngine::textSize( const QFont& font, - int flags, const QString& text ) const +QSizeF QwtPlainTextEngine::textSize(const QFont &font, int flags, + const QString &text) const { - const QFontMetricsF fm( font ); - const QRectF rect = fm.boundingRect( - QRectF( 0, 0, QWIDGETSIZE_MAX, QWIDGETSIZE_MAX ), flags, text ); + const QFontMetricsF fm(font); + const QRectF rect = fm.boundingRect( + QRectF(0, 0, QWIDGETSIZE_MAX, QWIDGETSIZE_MAX), flags, text); - return rect.size(); + return rect.size(); } /*! @@ -207,14 +202,15 @@ QSizeF QwtPlainTextEngine::textSize( const QFont& font, \param top Return value for the top margin \param bottom Return value for the bottom margin */ -void QwtPlainTextEngine::textMargins( const QFont& font, const QString&, - double& left, double& right, double& top, double& bottom ) const +void QwtPlainTextEngine::textMargins(const QFont &font, const QString &, + double &left, double &right, double &top, + double &bottom) const { - left = right = top = 0; + left = right = top = 0; - const QFontMetricsF fm( font ); - top = fm.ascent() - m_data->effectiveAscent( font ); - bottom = fm.descent(); + const QFontMetricsF fm(font); + top = fm.ascent() - m_data->effectiveAscent(font); + bottom = fm.descent(); } /*! @@ -227,27 +223,25 @@ void QwtPlainTextEngine::textMargins( const QFont& font, const QString&, \param flags Bitwise OR of the flags used like in QPainter::drawText \param text Text to be rendered */ -void QwtPlainTextEngine::draw( QPainter* painter, const QRectF& rect, - int flags, const QString& text ) const +void QwtPlainTextEngine::draw(QPainter *painter, const QRectF &rect, int flags, + const QString &text) const { - QwtPainter::drawText( painter, rect, flags, text ); + QwtPainter::drawText(painter, rect, flags, text); } /*! Test if a string can be rendered by this text engine. \return Always true. All texts can be rendered by QwtPlainTextEngine */ -bool QwtPlainTextEngine::mightRender( const QString& ) const +bool QwtPlainTextEngine::mightRender(const QString &) const { - return true; + return true; } #ifndef QT_NO_RICHTEXT //! Constructor -QwtRichTextEngine::QwtRichTextEngine() -{ -} +QwtRichTextEngine::QwtRichTextEngine() {} /*! Find the height for a given width @@ -259,13 +253,14 @@ QwtRichTextEngine::QwtRichTextEngine() \return Calculated height */ -double QwtRichTextEngine::heightForWidth( const QFont& font, int flags, - const QString& text, double width ) const +double QwtRichTextEngine::heightForWidth(const QFont &font, int flags, + const QString &text, + double width) const { - QwtRichTextDocument doc( text, flags, font ); + QwtRichTextDocument doc(text, flags, font); - doc.setPageSize( QSizeF( width, QWIDGETSIZE_MAX ) ); - return doc.documentLayout()->documentSize().height(); + doc.setPageSize(QSizeF(width, QWIDGETSIZE_MAX)); + return doc.documentLayout()->documentSize().height(); } /*! @@ -278,20 +273,20 @@ double QwtRichTextEngine::heightForWidth( const QFont& font, int flags, \return Calculated size */ -QSizeF QwtRichTextEngine::textSize( const QFont& font, - int flags, const QString& text ) const +QSizeF QwtRichTextEngine::textSize(const QFont &font, int flags, + const QString &text) const { - QwtRichTextDocument doc( text, flags, font ); + QwtRichTextDocument doc(text, flags, font); - QTextOption option = doc.defaultTextOption(); - if ( option.wrapMode() != QTextOption::NoWrap ) - { - option.setWrapMode( QTextOption::NoWrap ); - doc.setDefaultTextOption( option ); - doc.adjustSize(); - } + QTextOption option = doc.defaultTextOption(); + if (option.wrapMode() != QTextOption::NoWrap) + { + option.setWrapMode(QTextOption::NoWrap); + doc.setDefaultTextOption(option); + doc.adjustSize(); + } - return doc.size(); + return doc.size(); } /*! @@ -302,11 +297,11 @@ QSizeF QwtRichTextEngine::textSize( const QFont& font, \param flags Bitwise OR of the flags like in for QPainter::drawText() \param text Text to be rendered */ -void QwtRichTextEngine::draw( QPainter* painter, const QRectF& rect, - int flags, const QString& text ) const +void QwtRichTextEngine::draw(QPainter *painter, const QRectF &rect, int flags, + const QString &text) const { - QwtRichTextDocument doc( text, flags, painter->font() ); - QwtPainter::drawSimpleRichText( painter, rect, flags, doc ); + QwtRichTextDocument doc(text, flags, painter->font()); + QwtPainter::drawSimpleRichText(painter, rect, flags, doc); } /*! @@ -317,9 +312,9 @@ void QwtRichTextEngine::draw( QPainter* painter, const QRectF& rect, \return Tagged text */ -QString QwtRichTextEngine::taggedText( const QString& text, int flags ) const +QString QwtRichTextEngine::taggedText(const QString &text, int flags) const { - return taggedRichText( text, flags ); + return taggedRichText(text, flags); } /*! @@ -328,9 +323,9 @@ QString QwtRichTextEngine::taggedText( const QString& text, int flags ) const \param text Text to be tested \return Qt::mightBeRichText(text); */ -bool QwtRichTextEngine::mightRender( const QString& text ) const +bool QwtRichTextEngine::mightRender(const QString &text) const { - return Qt::mightBeRichText( text ); + return Qt::mightBeRichText(text); } /*! @@ -341,10 +336,11 @@ bool QwtRichTextEngine::mightRender( const QString& text ) const \param top Return 0 \param bottom Return 0 */ -void QwtRichTextEngine::textMargins( const QFont&, const QString&, - double& left, double& right, double& top, double& bottom ) const +void QwtRichTextEngine::textMargins(const QFont &, const QString &, + double &left, double &right, double &top, + double &bottom) const { - left = right = top = bottom = 0; + left = right = top = bottom = 0; } #endif // !QT_NO_RICHTEXT diff --git a/libs/qwt/src/qwt_text_engine.h b/libs/qwt/src/qwt_text_engine.h index 8de9ba70..695a40b0 100644 --- a/libs/qwt/src/qwt_text_engine.h +++ b/libs/qwt/src/qwt_text_engine.h @@ -29,79 +29,82 @@ class QPainter; class QWT_EXPORT QwtTextEngine { - public: - virtual ~QwtTextEngine(); +public: + virtual ~QwtTextEngine(); - /*! - Find the height for a given width + /*! + Find the height for a given width - \param font Font of the text - \param flags Bitwise OR of the flags used like in QPainter::drawText - \param text Text to be rendered - \param width Width + \param font Font of the text + \param flags Bitwise OR of the flags used like in QPainter::drawText + \param text Text to be rendered + \param width Width - \return Calculated height - */ - virtual double heightForWidth( const QFont& font, int flags, - const QString& text, double width ) const = 0; + \return Calculated height + */ + virtual double heightForWidth(const QFont &font, int flags, + const QString &text, double width) const + = 0; - /*! - Returns the size, that is needed to render text + /*! + Returns the size, that is needed to render text - \param font Font of the text - \param flags Bitwise OR of the flags like in for QPainter::drawText - \param text Text to be rendered + \param font Font of the text + \param flags Bitwise OR of the flags like in for QPainter::drawText + \param text Text to be rendered - \return Calculated size - */ - virtual QSizeF textSize( const QFont& font, int flags, - const QString& text ) const = 0; + \return Calculated size + */ + virtual QSizeF textSize(const QFont &font, int flags, + const QString &text) const + = 0; - /*! - Test if a string can be rendered by this text engine + /*! + Test if a string can be rendered by this text engine - \param text Text to be tested - \return true, if it can be rendered - */ - virtual bool mightRender( const QString& text ) const = 0; + \param text Text to be tested + \return true, if it can be rendered + */ + virtual bool mightRender(const QString &text) const = 0; - /*! - Return margins around the texts + /*! + Return margins around the texts - The textSize might include margins around the - text, like QFontMetrics::descent(). In situations - where texts need to be aligned in detail, knowing - these margins might improve the layout calculations. + The textSize might include margins around the + text, like QFontMetrics::descent(). In situations + where texts need to be aligned in detail, knowing + these margins might improve the layout calculations. - \param font Font of the text - \param text Text to be rendered - \param left Return value for the left margin - \param right Return value for the right margin - \param top Return value for the top margin - \param bottom Return value for the bottom margin - */ - virtual void textMargins( const QFont& font, const QString& text, - double& left, double& right, double& top, double& bottom ) const = 0; + \param font Font of the text + \param text Text to be rendered + \param left Return value for the left margin + \param right Return value for the right margin + \param top Return value for the top margin + \param bottom Return value for the bottom margin + */ + virtual void textMargins(const QFont &font, const QString &text, double &left, + double &right, double &top, double &bottom) const + = 0; - /*! - Draw the text in a clipping rectangle + /*! + Draw the text in a clipping rectangle - \param painter Painter - \param rect Clipping rectangle - \param flags Bitwise OR of the flags like in for QPainter::drawText() - \param text Text to be rendered - */ - virtual void draw( QPainter* painter, const QRectF& rect, - int flags, const QString& text ) const = 0; + \param painter Painter + \param rect Clipping rectangle + \param flags Bitwise OR of the flags like in for QPainter::drawText() + \param text Text to be rendered + */ + virtual void draw(QPainter *painter, const QRectF &rect, int flags, + const QString &text) const + = 0; - protected: - QwtTextEngine(); +protected: + QwtTextEngine(); - private: - Q_DISABLE_COPY(QwtTextEngine) +private: + Q_DISABLE_COPY(QwtTextEngine) }; - /*! \brief A text engine for plain texts @@ -110,32 +113,31 @@ class QWT_EXPORT QwtTextEngine */ class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine { - public: - QwtPlainTextEngine(); - virtual ~QwtPlainTextEngine(); +public: + QwtPlainTextEngine(); + virtual ~QwtPlainTextEngine(); - virtual double heightForWidth( const QFont& font, int flags, - const QString& text, double width ) const QWT_OVERRIDE; + virtual double heightForWidth(const QFont &font, int flags, + const QString &text, + double width) const QWT_OVERRIDE; - virtual QSizeF textSize( const QFont& font, int flags, - const QString& text ) const QWT_OVERRIDE; + virtual QSizeF textSize(const QFont &font, int flags, + const QString &text) const QWT_OVERRIDE; - virtual void draw( QPainter*, const QRectF& rect, - int flags, const QString& text ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QRectF &rect, int flags, + const QString &text) const QWT_OVERRIDE; - virtual bool mightRender( const QString& ) const QWT_OVERRIDE; + virtual bool mightRender(const QString &) const QWT_OVERRIDE; - virtual void textMargins( - const QFont&, const QString&, - double& left, double& right, - double& top, double& bottom ) const QWT_OVERRIDE; + virtual void textMargins(const QFont &, const QString &, double &left, + double &right, double &top, + double &bottom) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; - #ifndef QT_NO_RICHTEXT /*! @@ -146,27 +148,27 @@ class QWT_EXPORT QwtPlainTextEngine : public QwtTextEngine */ class QWT_EXPORT QwtRichTextEngine : public QwtTextEngine { - public: - QwtRichTextEngine(); +public: + QwtRichTextEngine(); - virtual double heightForWidth( const QFont& font, int flags, - const QString& text, double width ) const QWT_OVERRIDE; + virtual double heightForWidth(const QFont &font, int flags, + const QString &text, + double width) const QWT_OVERRIDE; - virtual QSizeF textSize( const QFont& font, int flags, - const QString& text ) const QWT_OVERRIDE; + virtual QSizeF textSize(const QFont &font, int flags, + const QString &text) const QWT_OVERRIDE; - virtual void draw( QPainter*, const QRectF& rect, - int flags, const QString& text ) const QWT_OVERRIDE; + virtual void draw(QPainter *, const QRectF &rect, int flags, + const QString &text) const QWT_OVERRIDE; - virtual bool mightRender( const QString& ) const QWT_OVERRIDE; + virtual bool mightRender(const QString &) const QWT_OVERRIDE; - virtual void textMargins( - const QFont&, const QString&, - double& left, double& right, - double& top, double& bottom ) const QWT_OVERRIDE; + virtual void textMargins(const QFont &, const QString &, double &left, + double &right, double &top, + double &bottom) const QWT_OVERRIDE; - private: - QString taggedText( const QString&, int flags ) const; +private: + QString taggedText(const QString &, int flags) const; }; #endif // !QT_NO_RICHTEXT diff --git a/libs/qwt/src/qwt_text_label.cpp b/libs/qwt/src/qwt_text_label.cpp index 5949352b..9e2a1c1b 100644 --- a/libs/qwt/src/qwt_text_label.cpp +++ b/libs/qwt/src/qwt_text_label.cpp @@ -20,26 +20,26 @@ class QwtTextLabel::PrivateData { - public: - PrivateData() - : indent( 4 ) - , margin( 0 ) - { - } +public: + PrivateData() + : indent(4) + , margin(0) + { + } - int indent; - int margin; - QwtText text; + int indent; + int margin; + QwtText text; }; /*! Constructs an empty label. \param parent Parent widget */ -QwtTextLabel::QwtTextLabel( QWidget* parent ) - : QFrame( parent ) +QwtTextLabel::QwtTextLabel(QWidget *parent) + : QFrame(parent) { - init(); + init(); } /*! @@ -47,32 +47,32 @@ QwtTextLabel::QwtTextLabel( QWidget* parent ) \param parent Parent widget \param text Text */ -QwtTextLabel::QwtTextLabel( const QwtText& text, QWidget* parent ) - : QFrame( parent ) +QwtTextLabel::QwtTextLabel(const QwtText &text, QWidget *parent) + : QFrame(parent) { - init(); - m_data->text = text; + init(); + m_data->text = text; } //! Destructor QwtTextLabel::~QwtTextLabel() { - delete m_data; + delete m_data; } void QwtTextLabel::init() { - m_data = new PrivateData(); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + m_data = new PrivateData(); + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); } /*! Interface for the designer plugin - does the same as setText() \sa plainText() */ -void QwtTextLabel::setPlainText( const QString& text ) +void QwtTextLabel::setPlainText(const QString &text) { - setText( QwtText( text ) ); + setText(QwtText(text)); } /*! @@ -83,7 +83,7 @@ void QwtTextLabel::setPlainText( const QString& text ) */ QString QwtTextLabel::plainText() const { - return m_data->text.text(); + return m_data->text.text(); } /*! @@ -93,192 +93,191 @@ QString QwtTextLabel::plainText() const \sa QwtText */ -void QwtTextLabel::setText( const QString& text, - QwtText::TextFormat textFormat ) +void QwtTextLabel::setText(const QString &text, QwtText::TextFormat textFormat) { - m_data->text.setText( text, textFormat ); + m_data->text.setText(text, textFormat); - update(); - updateGeometry(); + update(); + updateGeometry(); } /*! Change the label's text \param text New text */ -void QwtTextLabel::setText( const QwtText& text ) +void QwtTextLabel::setText(const QwtText &text) { - m_data->text = text; + m_data->text = text; - update(); - updateGeometry(); + update(); + updateGeometry(); } //! Return the text -const QwtText& QwtTextLabel::text() const +const QwtText &QwtTextLabel::text() const { - return m_data->text; + return m_data->text; } //! Clear the text and all QwtText attributes void QwtTextLabel::clear() { - m_data->text = QwtText(); + m_data->text = QwtText(); - update(); - updateGeometry(); + update(); + updateGeometry(); } //! Return label's text indent in pixels int QwtTextLabel::indent() const { - return m_data->indent; + return m_data->indent; } /*! Set label's text indent in pixels \param indent Indentation in pixels */ -void QwtTextLabel::setIndent( int indent ) +void QwtTextLabel::setIndent(int indent) { - if ( indent < 0 ) - indent = 0; + if (indent < 0) + indent = 0; - m_data->indent = indent; + m_data->indent = indent; - update(); - updateGeometry(); + update(); + updateGeometry(); } //! Return label's text margin in pixels int QwtTextLabel::margin() const { - return m_data->margin; + return m_data->margin; } /*! Set label's margin in pixels \param margin Margin in pixels */ -void QwtTextLabel::setMargin( int margin ) +void QwtTextLabel::setMargin(int margin) { - m_data->margin = margin; + m_data->margin = margin; - update(); - updateGeometry(); + update(); + updateGeometry(); } //! Return a size hint QSize QwtTextLabel::sizeHint() const { - return minimumSizeHint(); + return minimumSizeHint(); } //! Return a minimum size hint QSize QwtTextLabel::minimumSizeHint() const { - QSizeF sz = m_data->text.textSize( font() ); + QSizeF sz = m_data->text.textSize(font()); - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - int mw = m.left() + m.right() + 2 * m_data->margin; - int mh = m.top() + m.bottom() + 2 * m_data->margin; + int mw = m.left() + m.right() + 2 * m_data->margin; + int mh = m.top() + m.bottom() + 2 * m_data->margin; - int indent = m_data->indent; - if ( indent <= 0 ) - indent = defaultIndent(); + int indent = m_data->indent; + if (indent <= 0) + indent = defaultIndent(); - if ( indent > 0 ) - { - const int align = m_data->text.renderFlags(); - if ( align & Qt::AlignLeft || align & Qt::AlignRight ) - mw += m_data->indent; - else if ( align & Qt::AlignTop || align & Qt::AlignBottom ) - mh += m_data->indent; - } + if (indent > 0) + { + const int align = m_data->text.renderFlags(); + if (align & Qt::AlignLeft || align & Qt::AlignRight) + mw += m_data->indent; + else if (align & Qt::AlignTop || align & Qt::AlignBottom) + mh += m_data->indent; + } - sz += QSizeF( mw, mh ); + sz += QSizeF(mw, mh); - return QSize( qwtCeil( sz.width() ), qwtCeil( sz.height() ) ); + return QSize(qwtCeil(sz.width()), qwtCeil(sz.height())); } /*! \param width Width \return Preferred height for this widget, given the width. */ -int QwtTextLabel::heightForWidth( int width ) const +int QwtTextLabel::heightForWidth(int width) const { - const int renderFlags = m_data->text.renderFlags(); + const int renderFlags = m_data->text.renderFlags(); - int indent = m_data->indent; - if ( indent <= 0 ) - indent = defaultIndent(); + int indent = m_data->indent; + if (indent <= 0) + indent = defaultIndent(); - const QMargins m = contentsMargins(); + const QMargins m = contentsMargins(); - width -= m.left() + m.right() - 2 * m_data->margin; - if ( renderFlags & Qt::AlignLeft || renderFlags & Qt::AlignRight ) - width -= indent; + width -= m.left() + m.right() - 2 * m_data->margin; + if (renderFlags & Qt::AlignLeft || renderFlags & Qt::AlignRight) + width -= indent; - int height = qwtCeil( m_data->text.heightForWidth( width, font() ) ); - if ( ( renderFlags & Qt::AlignTop ) || ( renderFlags & Qt::AlignBottom ) ) - height += indent; + int height = qwtCeil(m_data->text.heightForWidth(width, font())); + if ((renderFlags & Qt::AlignTop) || (renderFlags & Qt::AlignBottom)) + height += indent; - height += m.top() + m.bottom() + 2 * m_data->margin; + height += m.top() + m.bottom() + 2 * m_data->margin; - return height; + return height; } /*! Qt paint event \param event Paint event */ -void QwtTextLabel::paintEvent( QPaintEvent* event ) +void QwtTextLabel::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - if ( !contentsRect().contains( event->rect() ) ) - { - painter.setClipRegion( event->region() & frameRect() ); - drawFrame( &painter ); - } + if (!contentsRect().contains(event->rect())) + { + painter.setClipRegion(event->region() & frameRect()); + drawFrame(&painter); + } - painter.setClipRegion( event->region() & contentsRect() ); + painter.setClipRegion(event->region() & contentsRect()); - drawContents( &painter ); + drawContents(&painter); } //! Redraw the text and focus indicator -void QwtTextLabel::drawContents( QPainter* painter ) +void QwtTextLabel::drawContents(QPainter *painter) { - const QRect r = textRect(); - if ( r.isEmpty() ) - return; + const QRect r = textRect(); + if (r.isEmpty()) + return; - painter->setFont( font() ); - painter->setPen( palette().color( QPalette::Active, QPalette::Text ) ); + painter->setFont(font()); + painter->setPen(palette().color(QPalette::Active, QPalette::Text)); - drawText( painter, QRectF( r ) ); + drawText(painter, QRectF(r)); - if ( hasFocus() ) - { - const int m = 2; + if (hasFocus()) + { + const int m = 2; - QRect focusRect = contentsRect().adjusted( m, m, -m + 1, -m + 1); + QRect focusRect = contentsRect().adjusted(m, m, -m + 1, -m + 1); - QwtPainter::drawFocusRect( painter, this, focusRect ); - } + QwtPainter::drawFocusRect(painter, this, focusRect); + } } //! Redraw the text -void QwtTextLabel::drawText( QPainter* painter, const QRectF& textRect ) +void QwtTextLabel::drawText(QPainter *painter, const QRectF &textRect) { - m_data->text.draw( painter, textRect ); + m_data->text.draw(painter, textRect); } /*! @@ -287,60 +286,60 @@ void QwtTextLabel::drawText( QPainter* painter, const QRectF& textRect ) */ QRect QwtTextLabel::textRect() const { - QRect r = contentsRect(); + QRect r = contentsRect(); - if ( !r.isEmpty() && m_data->margin > 0 ) + if (!r.isEmpty() && m_data->margin > 0) + { + const int m = m_data->margin; + r.adjust(m, m, -m, -m); + } + + if (!r.isEmpty()) + { + int indent = m_data->indent; + if (indent <= 0) + indent = defaultIndent(); + + if (indent > 0) { - const int m = m_data->margin; - r.adjust( m, m, -m, -m ); + const int renderFlags = m_data->text.renderFlags(); + + if (renderFlags & Qt::AlignLeft) + { + r.setX(r.x() + indent); + } + else if (renderFlags & Qt::AlignRight) + { + r.setWidth(r.width() - indent); + } + else if (renderFlags & Qt::AlignTop) + { + r.setY(r.y() + indent); + } + else if (renderFlags & Qt::AlignBottom) + { + r.setHeight(r.height() - indent); + } } + } - if ( !r.isEmpty() ) - { - int indent = m_data->indent; - if ( indent <= 0 ) - indent = defaultIndent(); - - if ( indent > 0 ) - { - const int renderFlags = m_data->text.renderFlags(); - - if ( renderFlags & Qt::AlignLeft ) - { - r.setX( r.x() + indent ); - } - else if ( renderFlags & Qt::AlignRight ) - { - r.setWidth( r.width() - indent ); - } - else if ( renderFlags & Qt::AlignTop ) - { - r.setY( r.y() + indent ); - } - else if ( renderFlags & Qt::AlignBottom ) - { - r.setHeight( r.height() - indent ); - } - } - } - - return r; + return r; } int QwtTextLabel::defaultIndent() const { - if ( frameWidth() <= 0 ) - return 0; + if (frameWidth() <= 0) + return 0; - QFont fnt; - if ( m_data->text.testPaintAttribute( QwtText::PaintUsingTextFont ) ) - fnt = m_data->text.font(); - else - fnt = font(); + QFont fnt; + if (m_data->text.testPaintAttribute(QwtText::PaintUsingTextFont)) + fnt = m_data->text.font(); + else + fnt = font(); - return QwtPainter::horizontalAdvance( QFontMetrics( fnt ), 'x' ) / 2; + return QwtPainter::horizontalAdvance(QFontMetrics(fnt), 'x') / 2; } #if QWT_MOC_INCLUDE -#include "moc_qwt_text_label.cpp" +# include "moc_qwt_text_label.cpp" #endif diff --git a/libs/qwt/src/qwt_text_label.h b/libs/qwt/src/qwt_text_label.h index 44f8c4bc..9c474e9b 100644 --- a/libs/qwt/src/qwt_text_label.h +++ b/libs/qwt/src/qwt_text_label.h @@ -25,54 +25,54 @@ class QPainter; class QWT_EXPORT QwtTextLabel : public QFrame { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( int indent READ indent WRITE setIndent ) - Q_PROPERTY( int margin READ margin WRITE setMargin ) - Q_PROPERTY( QString plainText READ plainText WRITE setPlainText ) + Q_PROPERTY(int indent READ indent WRITE setIndent) + Q_PROPERTY(int margin READ margin WRITE setMargin) + Q_PROPERTY(QString plainText READ plainText WRITE setPlainText) - public: - explicit QwtTextLabel( QWidget* parent = NULL ); - explicit QwtTextLabel( const QwtText&, QWidget* parent = NULL ); - virtual ~QwtTextLabel(); +public: + explicit QwtTextLabel(QWidget *parent = NULL); + explicit QwtTextLabel(const QwtText &, QWidget *parent = NULL); + virtual ~QwtTextLabel(); - void setPlainText( const QString& ); - QString plainText() const; + void setPlainText(const QString &); + QString plainText() const; - public Q_SLOTS: - void setText( const QString&, - QwtText::TextFormat textFormat = QwtText::AutoText ); - virtual void setText( const QwtText& ); +public Q_SLOTS: + void setText(const QString &, + QwtText::TextFormat textFormat = QwtText::AutoText); + virtual void setText(const QwtText &); - void clear(); + void clear(); - public: - const QwtText& text() const; +public: + const QwtText &text() const; - int indent() const; - void setIndent( int ); + int indent() const; + void setIndent(int); - int margin() const; - void setMargin( int ); + int margin() const; + void setMargin(int); - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual int heightForWidth( int ) const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; + virtual int heightForWidth(int) const QWT_OVERRIDE; - QRect textRect() const; + QRect textRect() const; - virtual void drawText( QPainter*, const QRectF& ); + virtual void drawText(QPainter *, const QRectF &); - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void drawContents( QPainter* ); +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void drawContents(QPainter *); - private: - void init(); - int defaultIndent() const; +private: + void init(); + int defaultIndent() const; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_thermo.cpp b/libs/qwt/src/qwt_thermo.cpp index bad18862..dfbf5fc5 100644 --- a/libs/qwt/src/qwt_thermo.cpp +++ b/libs/qwt/src/qwt_thermo.cpp @@ -23,120 +23,117 @@ #include #include -static inline void qwtDrawLine( QPainter* painter, int pos, - const QColor& color, const QRect& pipeRect, const QRect& liquidRect, - Qt::Orientation orientation ) +static inline void qwtDrawLine(QPainter *painter, int pos, const QColor &color, + const QRect &pipeRect, const QRect &liquidRect, + Qt::Orientation orientation) { - painter->setPen( color ); - if ( orientation == Qt::Horizontal ) - { - if ( pos >= liquidRect.left() && pos < liquidRect.right() ) - painter->drawLine( pos, pipeRect.top(), pos, pipeRect.bottom() ); - } - else - { - if ( pos >= liquidRect.top() && pos < liquidRect.bottom() ) - painter->drawLine( pipeRect.left(), pos, pipeRect.right(), pos ); - } + painter->setPen(color); + if (orientation == Qt::Horizontal) + { + if (pos >= liquidRect.left() && pos < liquidRect.right()) + painter->drawLine(pos, pipeRect.top(), pos, pipeRect.bottom()); + } + else + { + if (pos >= liquidRect.top() && pos < liquidRect.bottom()) + painter->drawLine(pipeRect.left(), pos, pipeRect.right(), pos); + } } -static QVector< double > qwtTickList( const QwtScaleDiv& scaleDiv ) +static QVector qwtTickList(const QwtScaleDiv &scaleDiv) { - QVector< double > values; + QVector values; - double lowerLimit = scaleDiv.interval().minValue(); - double upperLimit = scaleDiv.interval().maxValue(); + double lowerLimit = scaleDiv.interval().minValue(); + double upperLimit = scaleDiv.interval().maxValue(); - if ( upperLimit < lowerLimit ) - qSwap( lowerLimit, upperLimit ); + if (upperLimit < lowerLimit) + qSwap(lowerLimit, upperLimit); - values += lowerLimit; + values += lowerLimit; - for ( int tickType = QwtScaleDiv::MinorTick; - tickType < QwtScaleDiv::NTickTypes; tickType++ ) + for (int tickType = QwtScaleDiv::MinorTick; + tickType < QwtScaleDiv::NTickTypes; tickType++) + { + const QList ticks = scaleDiv.ticks(tickType); + + for (int i = 0; i < ticks.count(); i++) { - const QList< double > ticks = scaleDiv.ticks( tickType ); - - for ( int i = 0; i < ticks.count(); i++ ) - { - const double v = ticks[i]; - if ( v > lowerLimit && v < upperLimit ) - values += v; - } + const double v = ticks[i]; + if (v > lowerLimit && v < upperLimit) + values += v; } + } - values += upperLimit; + values += upperLimit; - return values; + return values; } class QwtThermo::PrivateData { - public: - PrivateData() - : orientation( Qt::Vertical ) - , scalePosition( QwtThermo::TrailingScale ) - , spacing( 3 ) - , borderWidth( 2 ) - , pipeWidth( 10 ) - , alarmLevel( 0.0 ) - , alarmEnabled( false ) - , autoFillPipe( true ) - , originMode( QwtThermo::OriginMinimum ) - , origin( 0.0 ) - , colorMap( NULL ) - , value( 0.0 ) - { - rangeFlags = QwtInterval::IncludeBorders; - } +public: + PrivateData() + : orientation(Qt::Vertical) + , scalePosition(QwtThermo::TrailingScale) + , spacing(3) + , borderWidth(2) + , pipeWidth(10) + , alarmLevel(0.0) + , alarmEnabled(false) + , autoFillPipe(true) + , originMode(QwtThermo::OriginMinimum) + , origin(0.0) + , colorMap(NULL) + , value(0.0) + { + rangeFlags = QwtInterval::IncludeBorders; + } - ~PrivateData() - { - delete colorMap; - } + ~PrivateData() { delete colorMap; } - Qt::Orientation orientation; - QwtThermo::ScalePosition scalePosition; + Qt::Orientation orientation; + QwtThermo::ScalePosition scalePosition; - int spacing; - int borderWidth; - int pipeWidth; + int spacing; + int borderWidth; + int pipeWidth; - QwtInterval::BorderFlags rangeFlags; - double alarmLevel; - bool alarmEnabled; - bool autoFillPipe; - QwtThermo::OriginMode originMode; - double origin; + QwtInterval::BorderFlags rangeFlags; + double alarmLevel; + bool alarmEnabled; + bool autoFillPipe; + QwtThermo::OriginMode originMode; + double origin; - QwtColorMap* colorMap; + QwtColorMap *colorMap; - double value; + double value; }; /*! Constructor \param parent Parent widget */ -QwtThermo::QwtThermo( QWidget* parent ) - : QwtAbstractScale( parent ) +QwtThermo::QwtThermo(QWidget *parent) + : QwtAbstractScale(parent) { - m_data = new PrivateData; + m_data = new PrivateData; - QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - if ( m_data->orientation == Qt::Vertical ) - policy.transpose(); + QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + if (m_data->orientation == Qt::Vertical) + policy.transpose(); - setSizePolicy( policy ); + setSizePolicy(policy); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); - layoutThermo( true ); + setAttribute(Qt::WA_WState_OwnSizePolicy, false); + layoutThermo(true); } //! Destructor QwtThermo::~QwtThermo() { - delete m_data; + delete m_data; } /*! @@ -154,13 +151,13 @@ QwtThermo::~QwtThermo() \param flags Range flags \sa rangeFlags() */ -void QwtThermo::setRangeFlags( QwtInterval::BorderFlags flags ) +void QwtThermo::setRangeFlags(QwtInterval::BorderFlags flags) { - if ( m_data->rangeFlags != flags ) - { - m_data->rangeFlags = flags; - update(); - } + if (m_data->rangeFlags != flags) + { + m_data->rangeFlags = flags; + update(); + } } /*! @@ -169,7 +166,7 @@ void QwtThermo::setRangeFlags( QwtInterval::BorderFlags flags ) */ QwtInterval::BorderFlags QwtThermo::rangeFlags() const { - return m_data->rangeFlags; + return m_data->rangeFlags; } /*! @@ -178,19 +175,19 @@ QwtInterval::BorderFlags QwtThermo::rangeFlags() const \param value New Value \sa value() */ -void QwtThermo::setValue( double value ) +void QwtThermo::setValue(double value) { - if ( m_data->value != value ) - { - m_data->value = value; - update(); - } + if (m_data->value != value) + { + m_data->value = value; + update(); + } } //! Return the value. double QwtThermo::value() const { - return m_data->value; + return m_data->value; } /*! @@ -204,89 +201,86 @@ double QwtThermo::value() const new and will be deleted in ~QwtThermo() or the next call of setScaleDraw(). */ -void QwtThermo::setScaleDraw( QwtScaleDraw* scaleDraw ) +void QwtThermo::setScaleDraw(QwtScaleDraw *scaleDraw) { - setAbstractScaleDraw( scaleDraw ); - layoutThermo( true ); + setAbstractScaleDraw(scaleDraw); + layoutThermo(true); } /*! \return the scale draw of the thermo \sa setScaleDraw() */ -const QwtScaleDraw* QwtThermo::scaleDraw() const +const QwtScaleDraw *QwtThermo::scaleDraw() const { - return static_cast< const QwtScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } /*! \return the scale draw of the thermo \sa setScaleDraw() */ -QwtScaleDraw* QwtThermo::scaleDraw() +QwtScaleDraw *QwtThermo::scaleDraw() { - return static_cast< QwtScaleDraw* >( abstractScaleDraw() ); + return static_cast(abstractScaleDraw()); } /*! Paint event handler \param event Paint event */ -void QwtThermo::paintEvent( QPaintEvent* event ) +void QwtThermo::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - const QRect tRect = pipeRect(); + const QRect tRect = pipeRect(); - if ( !tRect.contains( event->rect() ) ) - { - if ( m_data->scalePosition != QwtThermo::NoScale ) - scaleDraw()->draw( &painter, palette() ); - } + if (!tRect.contains(event->rect())) + { + if (m_data->scalePosition != QwtThermo::NoScale) + scaleDraw()->draw(&painter, palette()); + } - const int bw = m_data->borderWidth; + const int bw = m_data->borderWidth; - const QBrush brush = palette().brush( QPalette::Base ); - qDrawShadePanel( &painter, - tRect.adjusted( -bw, -bw, bw, bw ), - palette(), true, bw, - m_data->autoFillPipe ? &brush : NULL ); + const QBrush brush = palette().brush(QPalette::Base); + qDrawShadePanel(&painter, tRect.adjusted(-bw, -bw, bw, bw), palette(), true, + bw, m_data->autoFillPipe ? &brush : NULL); - drawLiquid( &painter, tRect ); + drawLiquid(&painter, tRect); } /*! Resize event handler \param event Resize event */ -void QwtThermo::resizeEvent( QResizeEvent* event ) +void QwtThermo::resizeEvent(QResizeEvent *event) { - Q_UNUSED( event ); - layoutThermo( false ); + Q_UNUSED(event); + layoutThermo(false); } /*! Qt change event handler \param event Event */ -void QwtThermo::changeEvent( QEvent* event ) +void QwtThermo::changeEvent(QEvent *event) { - switch( event->type() ) - { - case QEvent::StyleChange: - case QEvent::FontChange: - { - layoutThermo( true ); - break; - } - default: - break; + switch (event->type()) + { + case QEvent::StyleChange: + case QEvent::FontChange: { + layoutThermo(true); + break; } + default: + break; + } } /*! @@ -296,86 +290,86 @@ void QwtThermo::changeEvent( QEvent* event ) \param update_geometry notify the layout system and call update to redraw the scale */ -void QwtThermo::layoutThermo( bool update_geometry ) +void QwtThermo::layoutThermo(bool update_geometry) { - const QRect tRect = pipeRect(); - const int bw = m_data->borderWidth + m_data->spacing; - const bool inverted = ( upperBound() < lowerBound() ); + const QRect tRect = pipeRect(); + const int bw = m_data->borderWidth + m_data->spacing; + const bool inverted = (upperBound() < lowerBound()); - int from, to; + int from, to; - if ( m_data->orientation == Qt::Horizontal ) + if (m_data->orientation == Qt::Horizontal) + { + from = tRect.left(); + to = tRect.right(); + + if (m_data->rangeFlags & QwtInterval::ExcludeMinimum) { - from = tRect.left(); - to = tRect.right(); - - if ( m_data->rangeFlags & QwtInterval::ExcludeMinimum ) - { - if ( inverted ) - to++; - else - from--; - } - if ( m_data->rangeFlags & QwtInterval::ExcludeMaximum ) - { - if ( inverted ) - from--; - else - to++; - } - - if ( m_data->scalePosition == QwtThermo::TrailingScale ) - { - scaleDraw()->setAlignment( QwtScaleDraw::TopScale ); - scaleDraw()->move( from, tRect.top() - bw ); - } - else - { - scaleDraw()->setAlignment( QwtScaleDraw::BottomScale ); - scaleDraw()->move( from, tRect.bottom() + bw ); - } - - scaleDraw()->setLength( qMax( to - from, 0 ) ); + if (inverted) + to++; + else + from--; } - else // Qt::Vertical + if (m_data->rangeFlags & QwtInterval::ExcludeMaximum) { - from = tRect.top(); - to = tRect.bottom(); - - if ( m_data->rangeFlags & QwtInterval::ExcludeMinimum ) - { - if ( inverted ) - from--; - else - to++; - } - if ( m_data->rangeFlags & QwtInterval::ExcludeMaximum ) - { - if ( inverted ) - to++; - else - from--; - } - - if ( m_data->scalePosition == QwtThermo::LeadingScale ) - { - scaleDraw()->setAlignment( QwtScaleDraw::RightScale ); - scaleDraw()->move( tRect.right() + bw, from ); - } - else - { - scaleDraw()->setAlignment( QwtScaleDraw::LeftScale ); - scaleDraw()->move( tRect.left() - bw, from ); - } - - scaleDraw()->setLength( qMax( to - from, 0 ) ); + if (inverted) + from--; + else + to++; } - if ( update_geometry ) + if (m_data->scalePosition == QwtThermo::TrailingScale) { - updateGeometry(); - update(); + scaleDraw()->setAlignment(QwtScaleDraw::TopScale); + scaleDraw()->move(from, tRect.top() - bw); } + else + { + scaleDraw()->setAlignment(QwtScaleDraw::BottomScale); + scaleDraw()->move(from, tRect.bottom() + bw); + } + + scaleDraw()->setLength(qMax(to - from, 0)); + } + else // Qt::Vertical + { + from = tRect.top(); + to = tRect.bottom(); + + if (m_data->rangeFlags & QwtInterval::ExcludeMinimum) + { + if (inverted) + from--; + else + to++; + } + if (m_data->rangeFlags & QwtInterval::ExcludeMaximum) + { + if (inverted) + to++; + else + from--; + } + + if (m_data->scalePosition == QwtThermo::LeadingScale) + { + scaleDraw()->setAlignment(QwtScaleDraw::RightScale); + scaleDraw()->move(tRect.right() + bw, from); + } + else + { + scaleDraw()->setAlignment(QwtScaleDraw::LeftScale); + scaleDraw()->move(tRect.left() - bw, from); + } + + scaleDraw()->setLength(qMax(to - from, 0)); + } + + if (update_geometry) + { + updateGeometry(); + update(); + } } /*! @@ -384,43 +378,43 @@ void QwtThermo::layoutThermo( bool update_geometry ) */ QRect QwtThermo::pipeRect() const { - int mbd = 0; - if ( m_data->scalePosition != QwtThermo::NoScale ) - { - int d1, d2; - scaleDraw()->getBorderDistHint( font(), d1, d2 ); - mbd = qMax( d1, d2 ); - } - const int bw = m_data->borderWidth; - const int scaleOff = bw + mbd; + int mbd = 0; + if (m_data->scalePosition != QwtThermo::NoScale) + { + int d1, d2; + scaleDraw()->getBorderDistHint(font(), d1, d2); + mbd = qMax(d1, d2); + } + const int bw = m_data->borderWidth; + const int scaleOff = bw + mbd; - const QRect cr = contentsRect(); + const QRect cr = contentsRect(); - QRect pipeRect = cr; - if ( m_data->orientation == Qt::Horizontal ) - { - pipeRect.adjust( scaleOff, 0, -scaleOff, 0 ); + QRect pipeRect = cr; + if (m_data->orientation == Qt::Horizontal) + { + pipeRect.adjust(scaleOff, 0, -scaleOff, 0); - if ( m_data->scalePosition == QwtThermo::TrailingScale ) - pipeRect.setTop( cr.top() + cr.height() - bw - m_data->pipeWidth ); - else - pipeRect.setTop( bw ); + if (m_data->scalePosition == QwtThermo::TrailingScale) + pipeRect.setTop(cr.top() + cr.height() - bw - m_data->pipeWidth); + else + pipeRect.setTop(bw); - pipeRect.setHeight( m_data->pipeWidth ); - } - else // Qt::Vertical - { - pipeRect.adjust( 0, scaleOff, 0, -scaleOff ); + pipeRect.setHeight(m_data->pipeWidth); + } + else // Qt::Vertical + { + pipeRect.adjust(0, scaleOff, 0, -scaleOff); - if ( m_data->scalePosition == QwtThermo::LeadingScale ) - pipeRect.setLeft( bw ); - else - pipeRect.setLeft( cr.left() + cr.width() - bw - m_data->pipeWidth ); + if (m_data->scalePosition == QwtThermo::LeadingScale) + pipeRect.setLeft(bw); + else + pipeRect.setLeft(cr.left() + cr.width() - bw - m_data->pipeWidth); - pipeRect.setWidth( m_data->pipeWidth ); - } + pipeRect.setWidth(m_data->pipeWidth); + } - return pipeRect; + return pipeRect; } /*! @@ -429,23 +423,23 @@ QRect QwtThermo::pipeRect() const \sa orientation(), scalePosition() */ -void QwtThermo::setOrientation( Qt::Orientation orientation ) +void QwtThermo::setOrientation(Qt::Orientation orientation) { - if ( orientation == m_data->orientation ) - return; + if (orientation == m_data->orientation) + return; - m_data->orientation = orientation; + m_data->orientation = orientation; - if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) ) - { - QSizePolicy sp = sizePolicy(); - sp.transpose(); - setSizePolicy( sp ); + if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) + { + QSizePolicy sp = sizePolicy(); + sp.transpose(); + setSizePolicy(sp); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); - } + setAttribute(Qt::WA_WState_OwnSizePolicy, false); + } - layoutThermo( true ); + layoutThermo(true); } /*! @@ -454,20 +448,20 @@ void QwtThermo::setOrientation( Qt::Orientation orientation ) */ Qt::Orientation QwtThermo::orientation() const { - return m_data->orientation; + return m_data->orientation; } /*! \brief Change how the origin is determined. \sa originMode(), serOrigin(), origin() */ -void QwtThermo::setOriginMode( OriginMode m ) +void QwtThermo::setOriginMode(OriginMode m) { - if ( m == m_data->originMode ) - return; + if (m == m_data->originMode) + return; - m_data->originMode = m; - update(); + m_data->originMode = m; + update(); } /*! @@ -476,7 +470,7 @@ void QwtThermo::setOriginMode( OriginMode m ) */ QwtThermo::OriginMode QwtThermo::originMode() const { - return m_data->originMode; + return m_data->originMode; } /*! @@ -488,13 +482,13 @@ QwtThermo::OriginMode QwtThermo::originMode() const \param origin New origin level \sa setOriginMode(), originMode(), origin() */ -void QwtThermo::setOrigin( double origin ) +void QwtThermo::setOrigin(double origin) { - if ( origin == m_data->origin ) - return; + if (origin == m_data->origin) + return; - m_data->origin = origin; - update(); + m_data->origin = origin; + update(); } /*! @@ -503,7 +497,7 @@ void QwtThermo::setOrigin( double origin ) */ double QwtThermo::origin() const { - return m_data->origin; + return m_data->origin; } /*! @@ -512,15 +506,15 @@ double QwtThermo::origin() const \sa ScalePosition, scalePosition() */ -void QwtThermo::setScalePosition( ScalePosition scalePosition ) +void QwtThermo::setScalePosition(ScalePosition scalePosition) { - if ( m_data->scalePosition == scalePosition ) - return; + if (m_data->scalePosition == scalePosition) + return; - m_data->scalePosition = scalePosition; + m_data->scalePosition = scalePosition; - if ( testAttribute( Qt::WA_WState_Polished ) ) - layoutThermo( true ); + if (testAttribute(Qt::WA_WState_Polished)) + layoutThermo(true); } /*! @@ -529,13 +523,13 @@ void QwtThermo::setScalePosition( ScalePosition scalePosition ) */ QwtThermo::ScalePosition QwtThermo::scalePosition() const { - return m_data->scalePosition; + return m_data->scalePosition; } //! Notify a scale change. void QwtThermo::scaleChange() { - layoutThermo( true ); + layoutThermo(true); } /*! @@ -543,76 +537,72 @@ void QwtThermo::scaleChange() \param painter Painter \param pipeRect Bounding rectangle of the pipe without borders */ -void QwtThermo::drawLiquid( - QPainter* painter, const QRect& pipeRect ) const +void QwtThermo::drawLiquid(QPainter *painter, const QRect &pipeRect) const { - painter->save(); - painter->setClipRect( pipeRect, Qt::IntersectClip ); - painter->setPen( Qt::NoPen ); + painter->save(); + painter->setClipRect(pipeRect, Qt::IntersectClip); + painter->setPen(Qt::NoPen); - const QwtScaleMap scaleMap = scaleDraw()->scaleMap(); + const QwtScaleMap scaleMap = scaleDraw()->scaleMap(); - QRect liquidRect = fillRect( pipeRect ); + QRect liquidRect = fillRect(pipeRect); - if ( m_data->colorMap != NULL ) - { - const QwtInterval interval = scaleDiv().interval().normalized(); + if (m_data->colorMap != NULL) + { + const QwtInterval interval = scaleDiv().interval().normalized(); - // Because the positions of the ticks are rounded - // we calculate the colors for the rounded tick values + // Because the positions of the ticks are rounded + // we calculate the colors for the rounded tick values - QVector< double > values = qwtTickList( scaleDraw()->scaleDiv() ); + QVector values = qwtTickList(scaleDraw()->scaleDiv()); - if ( scaleMap.isInverting() ) - std::sort( values.begin(), values.end(), std::greater< double >() ); - else - std::sort( values.begin(), values.end(), std::less< double >() ); - - int from; - if ( !values.isEmpty() ) - { - from = qRound( scaleMap.transform( values[0] ) ); - qwtDrawLine( painter, from, - m_data->colorMap->color( interval, values[0] ), - pipeRect, liquidRect, m_data->orientation ); - } - - for ( int i = 1; i < values.size(); i++ ) - { - const int to = qRound( scaleMap.transform( values[i] ) ); - - for ( int pos = from + 1; pos < to; pos++ ) - { - const double v = scaleMap.invTransform( pos ); - - qwtDrawLine( painter, pos, - m_data->colorMap->color( interval, v ), - pipeRect, liquidRect, m_data->orientation ); - } - - qwtDrawLine( painter, to, - m_data->colorMap->color( interval, values[i] ), - pipeRect, liquidRect, m_data->orientation ); - - from = to; - } - } + if (scaleMap.isInverting()) + std::sort(values.begin(), values.end(), std::greater()); else - { - if ( !liquidRect.isEmpty() && m_data->alarmEnabled ) - { - const QRect r = alarmRect( liquidRect ); - if ( !r.isEmpty() ) - { - painter->fillRect( r, palette().brush( QPalette::Highlight ) ); - liquidRect = QRegion( liquidRect ).subtracted( r ).boundingRect(); - } - } + std::sort(values.begin(), values.end(), std::less()); - painter->fillRect( liquidRect, palette().brush( QPalette::ButtonText ) ); + int from; + if (!values.isEmpty()) + { + from = qRound(scaleMap.transform(values[0])); + qwtDrawLine(painter, from, m_data->colorMap->color(interval, values[0]), + pipeRect, liquidRect, m_data->orientation); } - painter->restore(); + for (int i = 1; i < values.size(); i++) + { + const int to = qRound(scaleMap.transform(values[i])); + + for (int pos = from + 1; pos < to; pos++) + { + const double v = scaleMap.invTransform(pos); + + qwtDrawLine(painter, pos, m_data->colorMap->color(interval, v), + pipeRect, liquidRect, m_data->orientation); + } + + qwtDrawLine(painter, to, m_data->colorMap->color(interval, values[i]), + pipeRect, liquidRect, m_data->orientation); + + from = to; + } + } + else + { + if (!liquidRect.isEmpty() && m_data->alarmEnabled) + { + const QRect r = alarmRect(liquidRect); + if (!r.isEmpty()) + { + painter->fillRect(r, palette().brush(QPalette::Highlight)); + liquidRect = QRegion(liquidRect).subtracted(r).boundingRect(); + } + } + + painter->fillRect(liquidRect, palette().brush(QPalette::ButtonText)); + } + + painter->restore(); } /*! @@ -626,16 +616,16 @@ void QwtThermo::drawLiquid( \param spacing Number of pixels \sa spacing(); */ -void QwtThermo::setSpacing( int spacing ) +void QwtThermo::setSpacing(int spacing) { - if ( spacing <= 0 ) - spacing = 0; + if (spacing <= 0) + spacing = 0; - if ( spacing != m_data->spacing ) - { - m_data->spacing = spacing; - layoutThermo( true ); - } + if (spacing != m_data->spacing) + { + m_data->spacing = spacing; + layoutThermo(true); + } } /*! @@ -644,7 +634,7 @@ void QwtThermo::setSpacing( int spacing ) */ int QwtThermo::spacing() const { - return m_data->spacing; + return m_data->spacing; } /*! @@ -652,16 +642,16 @@ int QwtThermo::spacing() const \param width Border width \sa borderWidth() */ -void QwtThermo::setBorderWidth( int width ) +void QwtThermo::setBorderWidth(int width) { - if ( width <= 0 ) - width = 0; + if (width <= 0) + width = 0; - if ( width != m_data->borderWidth ) - { - m_data->borderWidth = width; - layoutThermo( true ); - } + if (width != m_data->borderWidth) + { + m_data->borderWidth = width; + layoutThermo(true); + } } /*! @@ -670,7 +660,7 @@ void QwtThermo::setBorderWidth( int width ) */ int QwtThermo::borderWidth() const { - return m_data->borderWidth; + return m_data->borderWidth; } /*! @@ -680,13 +670,13 @@ int QwtThermo::borderWidth() const \warning The alarm threshold has no effect, when a color map has been assigned */ -void QwtThermo::setColorMap( QwtColorMap* colorMap ) +void QwtThermo::setColorMap(QwtColorMap *colorMap) { - if ( colorMap != m_data->colorMap ) - { - delete m_data->colorMap; - m_data->colorMap = colorMap; - } + if (colorMap != m_data->colorMap) + { + delete m_data->colorMap; + m_data->colorMap = colorMap; + } } /*! @@ -694,9 +684,9 @@ void QwtThermo::setColorMap( QwtColorMap* colorMap ) \warning The alarm threshold has no effect, when a color map has been assigned */ -QwtColorMap* QwtThermo::colorMap() +QwtColorMap *QwtThermo::colorMap() { - return m_data->colorMap; + return m_data->colorMap; } /*! @@ -704,9 +694,9 @@ QwtColorMap* QwtThermo::colorMap() \warning The alarm threshold has no effect, when a color map has been assigned */ -const QwtColorMap* QwtThermo::colorMap() const +const QwtColorMap *QwtThermo::colorMap() const { - return m_data->colorMap; + return m_data->colorMap; } /*! @@ -717,11 +707,11 @@ const QwtColorMap* QwtThermo::colorMap() const \param brush New brush. \sa fillBrush(), QWidget::setPalette() */ -void QwtThermo::setFillBrush( const QBrush& brush ) +void QwtThermo::setFillBrush(const QBrush &brush) { - QPalette pal = palette(); - pal.setBrush( QPalette::ButtonText, brush ); - setPalette( pal ); + QPalette pal = palette(); + pal.setBrush(QPalette::ButtonText, brush); + setPalette(pal); } /*! @@ -730,7 +720,7 @@ void QwtThermo::setFillBrush( const QBrush& brush ) */ QBrush QwtThermo::fillBrush() const { - return palette().brush( QPalette::ButtonText ); + return palette().brush(QPalette::ButtonText); } /*! @@ -744,11 +734,11 @@ QBrush QwtThermo::fillBrush() const \warning The alarm threshold has no effect, when a color map has been assigned */ -void QwtThermo::setAlarmBrush( const QBrush& brush ) +void QwtThermo::setAlarmBrush(const QBrush &brush) { - QPalette pal = palette(); - pal.setBrush( QPalette::Highlight, brush ); - setPalette( pal ); + QPalette pal = palette(); + pal.setBrush(QPalette::Highlight, brush); + setPalette(pal); } /*! @@ -760,7 +750,7 @@ void QwtThermo::setAlarmBrush( const QBrush& brush ) */ QBrush QwtThermo::alarmBrush() const { - return palette().brush( QPalette::Highlight ); + return palette().brush(QPalette::Highlight); } /*! @@ -772,11 +762,11 @@ QBrush QwtThermo::alarmBrush() const \warning The alarm threshold has no effect, when a color map has been assigned */ -void QwtThermo::setAlarmLevel( double level ) +void QwtThermo::setAlarmLevel(double level) { - m_data->alarmLevel = level; - m_data->alarmEnabled = 1; - update(); + m_data->alarmLevel = level; + m_data->alarmEnabled = 1; + update(); } /*! @@ -788,7 +778,7 @@ void QwtThermo::setAlarmLevel( double level ) */ double QwtThermo::alarmLevel() const { - return m_data->alarmLevel; + return m_data->alarmLevel; } /*! @@ -797,13 +787,13 @@ double QwtThermo::alarmLevel() const \param width Width of the pipe \sa pipeWidth() */ -void QwtThermo::setPipeWidth( int width ) +void QwtThermo::setPipeWidth(int width) { - if ( width > 0 ) - { - m_data->pipeWidth = width; - layoutThermo( true ); - } + if (width > 0) + { + m_data->pipeWidth = width; + layoutThermo(true); + } } /*! @@ -812,7 +802,7 @@ void QwtThermo::setPipeWidth( int width ) */ int QwtThermo::pipeWidth() const { - return m_data->pipeWidth; + return m_data->pipeWidth; } /*! @@ -822,10 +812,10 @@ int QwtThermo::pipeWidth() const \warning The alarm threshold has no effect, when a color map has been assigned */ -void QwtThermo::setAlarmEnabled( bool on ) +void QwtThermo::setAlarmEnabled(bool on) { - m_data->alarmEnabled = on; - update(); + m_data->alarmEnabled = on; + update(); } /*! @@ -836,7 +826,7 @@ void QwtThermo::setAlarmEnabled( bool on ) */ bool QwtThermo::alarmEnabled() const { - return m_data->alarmEnabled; + return m_data->alarmEnabled; } /*! @@ -845,7 +835,7 @@ bool QwtThermo::alarmEnabled() const */ QSize QwtThermo::sizeHint() const { - return minimumSizeHint(); + return minimumSizeHint(); } /*! @@ -855,35 +845,34 @@ QSize QwtThermo::sizeHint() const */ QSize QwtThermo::minimumSizeHint() const { - int w = 0, h = 0; + int w = 0, h = 0; - if ( m_data->scalePosition != NoScale ) - { - const int sdExtent = qwtCeil( scaleDraw()->extent( font() ) ); - const int sdLength = scaleDraw()->minLength( font() ); + if (m_data->scalePosition != NoScale) + { + const int sdExtent = qwtCeil(scaleDraw()->extent(font())); + const int sdLength = scaleDraw()->minLength(font()); - w = sdLength; - h = m_data->pipeWidth + sdExtent + m_data->spacing; + w = sdLength; + h = m_data->pipeWidth + sdExtent + m_data->spacing; + } + else // no scale + { + w = 200; + h = m_data->pipeWidth; + } - } - else // no scale - { - w = 200; - h = m_data->pipeWidth; - } + if (m_data->orientation == Qt::Vertical) + qSwap(w, h); - if ( m_data->orientation == Qt::Vertical ) - qSwap( w, h ); + w += 2 * m_data->borderWidth; + h += 2 * m_data->borderWidth; - w += 2 * m_data->borderWidth; - h += 2 * m_data->borderWidth; + // finally add the margins + const QMargins m = contentsMargins(); + w += m.left() + m.right(); + h += m.top() + m.bottom(); - // finally add the margins - const QMargins m = contentsMargins(); - w += m.left() + m.right(); - h += m.top() + m.bottom(); - - return QSize( w, h ); + return QSize(w, h); } /*! @@ -894,43 +883,43 @@ QSize QwtThermo::minimumSizeHint() const \sa pipeRect(), alarmRect() */ -QRect QwtThermo::fillRect( const QRect& pipeRect ) const +QRect QwtThermo::fillRect(const QRect &pipeRect) const { - double origin; - if ( m_data->originMode == OriginMinimum ) - { - origin = qMin( lowerBound(), upperBound() ); - } - else if ( m_data->originMode == OriginMaximum ) - { - origin = qMax( lowerBound(), upperBound() ); - } - else // OriginCustom - { - origin = m_data->origin; - } + double origin; + if (m_data->originMode == OriginMinimum) + { + origin = qMin(lowerBound(), upperBound()); + } + else if (m_data->originMode == OriginMaximum) + { + origin = qMax(lowerBound(), upperBound()); + } + else // OriginCustom + { + origin = m_data->origin; + } - const QwtScaleMap scaleMap = scaleDraw()->scaleMap(); + const QwtScaleMap scaleMap = scaleDraw()->scaleMap(); - int from = qRound( scaleMap.transform( m_data->value ) ); - int to = qRound( scaleMap.transform( origin ) ); + int from = qRound(scaleMap.transform(m_data->value)); + int to = qRound(scaleMap.transform(origin)); - if ( to < from ) - qSwap( from, to ); + if (to < from) + qSwap(from, to); - QRect fillRect = pipeRect; - if ( m_data->orientation == Qt::Horizontal ) - { - fillRect.setLeft( from ); - fillRect.setRight( to ); - } - else // Qt::Vertical - { - fillRect.setTop( from ); - fillRect.setBottom( to ); - } + QRect fillRect = pipeRect; + if (m_data->orientation == Qt::Horizontal) + { + fillRect.setLeft(from); + fillRect.setRight(to); + } + else // Qt::Vertical + { + fillRect.setTop(from); + fillRect.setBottom(to); + } - return fillRect.normalized(); + return fillRect.normalized(); } /*! @@ -941,72 +930,71 @@ QRect QwtThermo::fillRect( const QRect& pipeRect ) const \sa pipeRect(), fillRect(), alarmLevel(), alarmBrush() */ -QRect QwtThermo::alarmRect( const QRect& fillRect ) const +QRect QwtThermo::alarmRect(const QRect &fillRect) const { - QRect alarmRect( 0, 0, -1, -1); // something invalid - - if ( !m_data->alarmEnabled ) - return alarmRect; - - const bool inverted = ( upperBound() < lowerBound() ); - - bool increasing; - if ( m_data->originMode == OriginCustom ) - { - increasing = m_data->value > m_data->origin; - } - else - { - increasing = m_data->originMode == OriginMinimum; - } - - const QwtScaleMap map = scaleDraw()->scaleMap(); - const int alarmPos = qRound( map.transform( m_data->alarmLevel ) ); - const int valuePos = qRound( map.transform( m_data->value ) ); - - if ( m_data->orientation == Qt::Horizontal ) - { - int v1, v2; - if ( inverted ) - { - v1 = fillRect.left(); - - v2 = alarmPos - 1; - v2 = qMin( v2, increasing ? fillRect.right() : valuePos ); - } - else - { - v1 = alarmPos + 1; - v1 = qMax( v1, increasing ? fillRect.left() : valuePos ); - - v2 = fillRect.right(); - - } - alarmRect.setRect( v1, fillRect.top(), v2 - v1 + 1, fillRect.height() ); - } - else - { - int v1, v2; - if ( inverted ) - { - v1 = alarmPos + 1; - v1 = qMax( v1, increasing ? fillRect.top() : valuePos ); - - v2 = fillRect.bottom(); - } - else - { - v1 = fillRect.top(); - - v2 = alarmPos - 1; - v2 = qMin( v2, increasing ? fillRect.bottom() : valuePos ); - } - alarmRect.setRect( fillRect.left(), v1, fillRect.width(), v2 - v1 + 1 ); - } + QRect alarmRect(0, 0, -1, -1); // something invalid + if (!m_data->alarmEnabled) return alarmRect; + + const bool inverted = (upperBound() < lowerBound()); + + bool increasing; + if (m_data->originMode == OriginCustom) + { + increasing = m_data->value > m_data->origin; + } + else + { + increasing = m_data->originMode == OriginMinimum; + } + + const QwtScaleMap map = scaleDraw()->scaleMap(); + const int alarmPos = qRound(map.transform(m_data->alarmLevel)); + const int valuePos = qRound(map.transform(m_data->value)); + + if (m_data->orientation == Qt::Horizontal) + { + int v1, v2; + if (inverted) + { + v1 = fillRect.left(); + + v2 = alarmPos - 1; + v2 = qMin(v2, increasing ? fillRect.right() : valuePos); + } + else + { + v1 = alarmPos + 1; + v1 = qMax(v1, increasing ? fillRect.left() : valuePos); + + v2 = fillRect.right(); + } + alarmRect.setRect(v1, fillRect.top(), v2 - v1 + 1, fillRect.height()); + } + else + { + int v1, v2; + if (inverted) + { + v1 = alarmPos + 1; + v1 = qMax(v1, increasing ? fillRect.top() : valuePos); + + v2 = fillRect.bottom(); + } + else + { + v1 = fillRect.top(); + + v2 = alarmPos - 1; + v2 = qMin(v2, increasing ? fillRect.bottom() : valuePos); + } + alarmRect.setRect(fillRect.left(), v1, fillRect.width(), v2 - v1 + 1); + } + + return alarmRect; } #if QWT_MOC_INCLUDE -#include "moc_qwt_thermo.cpp" +# include "moc_qwt_thermo.cpp" #endif diff --git a/libs/qwt/src/qwt_thermo.h b/libs/qwt/src/qwt_thermo.h index 89485571..f7dfe762 100644 --- a/libs/qwt/src/qwt_thermo.h +++ b/libs/qwt/src/qwt_thermo.h @@ -45,134 +45,132 @@ class QwtColorMap; */ class QWT_EXPORT QwtThermo : public QwtAbstractScale { - Q_OBJECT + Q_OBJECT - Q_ENUMS( ScalePosition ) - Q_ENUMS( OriginMode ) + Q_ENUMS(ScalePosition) + Q_ENUMS(OriginMode) - Q_PROPERTY( Qt::Orientation orientation - READ orientation WRITE setOrientation ) - Q_PROPERTY( ScalePosition scalePosition - READ scalePosition WRITE setScalePosition ) - Q_PROPERTY( OriginMode originMode READ originMode WRITE setOriginMode ) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) + Q_PROPERTY( + ScalePosition scalePosition READ scalePosition WRITE setScalePosition) + Q_PROPERTY(OriginMode originMode READ originMode WRITE setOriginMode) - Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled ) - Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel ) - Q_PROPERTY( double origin READ origin WRITE setOrigin ) - Q_PROPERTY( int spacing READ spacing WRITE setSpacing ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) - Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth ) - Q_PROPERTY( double value READ value WRITE setValue USER true ) + Q_PROPERTY(bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled) + Q_PROPERTY(double alarmLevel READ alarmLevel WRITE setAlarmLevel) + Q_PROPERTY(double origin READ origin WRITE setOrigin) + Q_PROPERTY(int spacing READ spacing WRITE setSpacing) + Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) + Q_PROPERTY(int pipeWidth READ pipeWidth WRITE setPipeWidth) + Q_PROPERTY(double value READ value WRITE setValue USER true) - public: +public: + /*! + Position of the scale + \sa setScalePosition(), setOrientation() + */ + enum ScalePosition + { + //! The slider has no scale + NoScale, - /*! - Position of the scale - \sa setScalePosition(), setOrientation() - */ - enum ScalePosition - { - //! The slider has no scale - NoScale, + //! The scale is right of a vertical or below of a horizontal slider + LeadingScale, - //! The scale is right of a vertical or below of a horizontal slider - LeadingScale, + //! The scale is left of a vertical or above of a horizontal slider + TrailingScale + }; - //! The scale is left of a vertical or above of a horizontal slider - TrailingScale - }; + /*! + Origin mode. This property specifies where the beginning of the liquid + is placed. - /*! - Origin mode. This property specifies where the beginning of the liquid - is placed. + \sa setOriginMode(), setOrigin() + */ + enum OriginMode + { + //! The origin is the minimum of the scale + OriginMinimum, - \sa setOriginMode(), setOrigin() - */ - enum OriginMode - { - //! The origin is the minimum of the scale - OriginMinimum, + //! The origin is the maximum of the scale + OriginMaximum, - //! The origin is the maximum of the scale - OriginMaximum, + //! The origin is specified using the origin() property + OriginCustom + }; - //! The origin is specified using the origin() property - OriginCustom - }; + explicit QwtThermo(QWidget *parent = NULL); + virtual ~QwtThermo(); - explicit QwtThermo( QWidget* parent = NULL ); - virtual ~QwtThermo(); + void setOrientation(Qt::Orientation); + Qt::Orientation orientation() const; - void setOrientation( Qt::Orientation ); - Qt::Orientation orientation() const; + void setScalePosition(ScalePosition); + ScalePosition scalePosition() const; - void setScalePosition( ScalePosition ); - ScalePosition scalePosition() const; + void setSpacing(int); + int spacing() const; - void setSpacing( int ); - int spacing() const; + void setBorderWidth(int); + int borderWidth() const; - void setBorderWidth( int ); - int borderWidth() const; + void setOriginMode(OriginMode); + OriginMode originMode() const; - void setOriginMode( OriginMode ); - OriginMode originMode() const; + void setOrigin(double); + double origin() const; - void setOrigin( double ); - double origin() const; + void setFillBrush(const QBrush &); + QBrush fillBrush() const; - void setFillBrush( const QBrush& ); - QBrush fillBrush() const; + void setAlarmBrush(const QBrush &); + QBrush alarmBrush() const; - void setAlarmBrush( const QBrush& ); - QBrush alarmBrush() const; + void setAlarmLevel(double); + double alarmLevel() const; - void setAlarmLevel( double ); - double alarmLevel() const; + void setAlarmEnabled(bool); + bool alarmEnabled() const; - void setAlarmEnabled( bool ); - bool alarmEnabled() const; + void setColorMap(QwtColorMap *); + QwtColorMap *colorMap(); + const QwtColorMap *colorMap() const; - void setColorMap( QwtColorMap* ); - QwtColorMap* colorMap(); - const QwtColorMap* colorMap() const; + void setPipeWidth(int); + int pipeWidth() const; - void setPipeWidth( int ); - int pipeWidth() const; + void setRangeFlags(QwtInterval::BorderFlags); + QwtInterval::BorderFlags rangeFlags() const; - void setRangeFlags( QwtInterval::BorderFlags ); - QwtInterval::BorderFlags rangeFlags() const; + double value() const; - double value() const; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + void setScaleDraw(QwtScaleDraw *); + const QwtScaleDraw *scaleDraw() const; - void setScaleDraw( QwtScaleDraw* ); - const QwtScaleDraw* scaleDraw() const; +public Q_SLOTS: + virtual void setValue(double); - public Q_SLOTS: - virtual void setValue( double ); +protected: + virtual void drawLiquid(QPainter *, const QRect &) const; + virtual void scaleChange() QWT_OVERRIDE; - protected: - virtual void drawLiquid( QPainter*, const QRect& ) const; - virtual void scaleChange() QWT_OVERRIDE; + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; + virtual void changeEvent(QEvent *) QWT_OVERRIDE; - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; - virtual void changeEvent( QEvent* ) QWT_OVERRIDE; + QwtScaleDraw *scaleDraw(); - QwtScaleDraw* scaleDraw(); + QRect pipeRect() const; + QRect fillRect(const QRect &) const; + QRect alarmRect(const QRect &) const; - QRect pipeRect() const; - QRect fillRect( const QRect& ) const; - QRect alarmRect( const QRect& ) const; +private: + void layoutThermo(bool); - private: - void layoutThermo( bool ); - - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_transform.cpp b/libs/qwt/src/qwt_transform.cpp index 6d5b51d0..c43bd40f 100644 --- a/libs/qwt/src/qwt_transform.cpp +++ b/libs/qwt/src/qwt_transform.cpp @@ -17,145 +17,134 @@ const double QwtLogTransform::LogMin = 1.0e-150; const double QwtLogTransform::LogMax = 1.0e150; //! Constructor -QwtTransform::QwtTransform() -{ -} +QwtTransform::QwtTransform() {} //! Destructor -QwtTransform::~QwtTransform() -{ -} +QwtTransform::~QwtTransform() {} /*! \param value Value to be bounded \return value unmodified */ -double QwtTransform::bounded( double value ) const +double QwtTransform::bounded(double value) const { - return value; + return value; } //! Constructor -QwtNullTransform::QwtNullTransform(): - QwtTransform() +QwtNullTransform::QwtNullTransform() + : QwtTransform() { } //! Destructor -QwtNullTransform::~QwtNullTransform() +QwtNullTransform::~QwtNullTransform() {} + +/*! + \param value Value to be transformed + \return value unmodified + */ +double QwtNullTransform::transform(double value) const { + return value; } /*! \param value Value to be transformed \return value unmodified */ -double QwtNullTransform::transform( double value ) const +double QwtNullTransform::invTransform(double value) const { - return value; -} - -/*! - \param value Value to be transformed - \return value unmodified - */ -double QwtNullTransform::invTransform( double value ) const -{ - return value; + return value; } //! \return Clone of the transformation -QwtTransform* QwtNullTransform::copy() const +QwtTransform *QwtNullTransform::copy() const { - return new QwtNullTransform(); + return new QwtNullTransform(); } //! Constructor -QwtLogTransform::QwtLogTransform(): - QwtTransform() +QwtLogTransform::QwtLogTransform() + : QwtTransform() { } //! Destructor -QwtLogTransform::~QwtLogTransform() -{ -} +QwtLogTransform::~QwtLogTransform() {} /*! \param value Value to be transformed \return log( value ) */ -double QwtLogTransform::transform( double value ) const +double QwtLogTransform::transform(double value) const { - return std::log( value ); + return std::log(value); } /*! \param value Value to be transformed \return exp( value ) */ -double QwtLogTransform::invTransform( double value ) const +double QwtLogTransform::invTransform(double value) const { - return std::exp( value ); + return std::exp(value); } /*! \param value Value to be bounded \return qBound( LogMin, value, LogMax ) */ -double QwtLogTransform::bounded( double value ) const +double QwtLogTransform::bounded(double value) const { - return qBound( LogMin, value, LogMax ); + return qBound(LogMin, value, LogMax); } //! \return Clone of the transformation -QwtTransform* QwtLogTransform::copy() const +QwtTransform *QwtLogTransform::copy() const { - return new QwtLogTransform(); + return new QwtLogTransform(); } /*! Constructor \param exponent Exponent */ -QwtPowerTransform::QwtPowerTransform( double exponent ): - QwtTransform(), - m_exponent( exponent ) +QwtPowerTransform::QwtPowerTransform(double exponent) + : QwtTransform() + , m_exponent(exponent) { } //! Destructor -QwtPowerTransform::~QwtPowerTransform() -{ -} +QwtPowerTransform::~QwtPowerTransform() {} /*! \param value Value to be transformed \return Exponentiation preserving the sign */ -double QwtPowerTransform::transform( double value ) const +double QwtPowerTransform::transform(double value) const { - if ( value < 0.0 ) - return -std::pow( -value, 1.0 / m_exponent ); - else - return std::pow( value, 1.0 / m_exponent ); - + if (value < 0.0) + return -std::pow(-value, 1.0 / m_exponent); + else + return std::pow(value, 1.0 / m_exponent); } /*! \param value Value to be transformed \return Inverse exponentiation preserving the sign */ -double QwtPowerTransform::invTransform( double value ) const +double QwtPowerTransform::invTransform(double value) const { - if ( value < 0.0 ) - return -std::pow( -value, m_exponent ); - else - return std::pow( value, m_exponent ); + if (value < 0.0) + return -std::pow(-value, m_exponent); + else + return std::pow(value, m_exponent); } //! \return Clone of the transformation -QwtTransform* QwtPowerTransform::copy() const +QwtTransform *QwtPowerTransform::copy() const { - return new QwtPowerTransform( m_exponent ); + return new QwtPowerTransform(m_exponent); } diff --git a/libs/qwt/src/qwt_transform.h b/libs/qwt/src/qwt_transform.h index 60fff020..d0dd9e3d 100644 --- a/libs/qwt/src/qwt_transform.h +++ b/libs/qwt/src/qwt_transform.h @@ -34,41 +34,41 @@ */ class QWT_EXPORT QwtTransform { - public: - QwtTransform(); - virtual ~QwtTransform(); +public: + QwtTransform(); + virtual ~QwtTransform(); - /*! - Modify value to be a valid value for the transformation. - The default implementation does nothing. - */ - virtual double bounded( double value ) const; + /*! + Modify value to be a valid value for the transformation. + The default implementation does nothing. + */ + virtual double bounded(double value) const; - /*! - Transformation function + /*! + Transformation function - \param value Value - \return Modified value + \param value Value + \return Modified value - \sa invTransform() - */ - virtual double transform( double value ) const = 0; + \sa invTransform() + */ + virtual double transform(double value) const = 0; - /*! - Inverse transformation function + /*! + Inverse transformation function - \param value Value - \return Modified value + \param value Value + \return Modified value - \sa transform() - */ - virtual double invTransform( double value ) const = 0; + \sa transform() + */ + virtual double invTransform(double value) const = 0; - //! Virtualized copy operation - virtual QwtTransform* copy() const = 0; + //! Virtualized copy operation + virtual QwtTransform *copy() const = 0; - private: - Q_DISABLE_COPY(QwtTransform) +private: + Q_DISABLE_COPY(QwtTransform) }; /*! @@ -79,14 +79,14 @@ class QWT_EXPORT QwtTransform */ class QWT_EXPORT QwtNullTransform : public QwtTransform { - public: - QwtNullTransform(); - virtual ~QwtNullTransform(); +public: + QwtNullTransform(); + virtual ~QwtNullTransform(); - virtual double transform( double value ) const QWT_OVERRIDE; - virtual double invTransform( double value ) const QWT_OVERRIDE; + virtual double transform(double value) const QWT_OVERRIDE; + virtual double invTransform(double value) const QWT_OVERRIDE; - virtual QwtTransform* copy() const QWT_OVERRIDE; + virtual QwtTransform *copy() const QWT_OVERRIDE; }; /*! \brief Logarithmic transformation @@ -99,19 +99,19 @@ class QWT_EXPORT QwtNullTransform : public QwtTransform */ class QWT_EXPORT QwtLogTransform : public QwtTransform { - public: - QwtLogTransform(); - virtual ~QwtLogTransform(); +public: + QwtLogTransform(); + virtual ~QwtLogTransform(); - virtual double transform( double value ) const QWT_OVERRIDE; - virtual double invTransform( double value ) const QWT_OVERRIDE; + virtual double transform(double value) const QWT_OVERRIDE; + virtual double invTransform(double value) const QWT_OVERRIDE; - virtual double bounded( double value ) const QWT_OVERRIDE; + virtual double bounded(double value) const QWT_OVERRIDE; - virtual QwtTransform* copy() const QWT_OVERRIDE; + virtual QwtTransform *copy() const QWT_OVERRIDE; - static const double LogMin; - static const double LogMax; + static const double LogMin; + static const double LogMax; }; /*! @@ -124,17 +124,17 @@ class QWT_EXPORT QwtLogTransform : public QwtTransform */ class QWT_EXPORT QwtPowerTransform : public QwtTransform { - public: - explicit QwtPowerTransform( double exponent ); - virtual ~QwtPowerTransform(); +public: + explicit QwtPowerTransform(double exponent); + virtual ~QwtPowerTransform(); - virtual double transform( double value ) const QWT_OVERRIDE; - virtual double invTransform( double value ) const QWT_OVERRIDE; + virtual double transform(double value) const QWT_OVERRIDE; + virtual double invTransform(double value) const QWT_OVERRIDE; - virtual QwtTransform* copy() const QWT_OVERRIDE; + virtual QwtTransform *copy() const QWT_OVERRIDE; - private: - const double m_exponent; +private: + const double m_exponent; }; #endif diff --git a/libs/qwt/src/qwt_vectorfield_symbol.cpp b/libs/qwt/src/qwt_vectorfield_symbol.cpp index ddbe3744..b64954fe 100644 --- a/libs/qwt/src/qwt_vectorfield_symbol.cpp +++ b/libs/qwt/src/qwt_vectorfield_symbol.cpp @@ -13,52 +13,47 @@ #include //! Constructor -QwtVectorFieldSymbol::QwtVectorFieldSymbol() -{ -} +QwtVectorFieldSymbol::QwtVectorFieldSymbol() {} //! Destructor -QwtVectorFieldSymbol::~QwtVectorFieldSymbol() -{ -} +QwtVectorFieldSymbol::~QwtVectorFieldSymbol() {} class QwtVectorFieldArrow::PrivateData { - public: - PrivateData( qreal headW, qreal tailW ) - : headWidth( headW ) - , tailWidth( tailW ) - , length( headW + 4.0 ) - { - /* - Arrow is drawn horizontally, pointing into positive x direction - with tip at 0,0. - */ +public: + PrivateData(qreal headW, qreal tailW) + : headWidth(headW) + , tailWidth(tailW) + , length(headW + 4.0) + { + /* + Arrow is drawn horizontally, pointing into positive x direction + with tip at 0,0. + */ - path.lineTo( -headWidth, headWidth ); - path.lineTo( -headWidth, tailWidth ); - path.lineTo( -length, tailWidth ); - path.lineTo( -length, -tailWidth ); - path.lineTo( -headWidth, -tailWidth ); - path.lineTo( -headWidth, -headWidth ); + path.lineTo(-headWidth, headWidth); + path.lineTo(-headWidth, tailWidth); + path.lineTo(-length, tailWidth); + path.lineTo(-length, -tailWidth); + path.lineTo(-headWidth, -tailWidth); + path.lineTo(-headWidth, -headWidth); - path.closeSubpath(); - } + path.closeSubpath(); + } - void setLength( qreal l ) - { - length = qMax( l, headWidth ); + void setLength(qreal l) + { + length = qMax(l, headWidth); - path.setElementPositionAt( 3, -length, tailWidth ); - path.setElementPositionAt( 4, -length, -tailWidth ); - } + path.setElementPositionAt(3, -length, tailWidth); + path.setElementPositionAt(4, -length, -tailWidth); + } - const qreal headWidth; - const qreal tailWidth; - qreal length; - - QPainterPath path; + const qreal headWidth; + const qreal tailWidth; + qreal length; + QPainterPath path; }; /*! @@ -71,50 +66,50 @@ class QwtVectorFieldArrow::PrivateData \sa setLength() */ -QwtVectorFieldArrow::QwtVectorFieldArrow( qreal headWidth, qreal tailWidth ) +QwtVectorFieldArrow::QwtVectorFieldArrow(qreal headWidth, qreal tailWidth) { - m_data = new PrivateData( headWidth, tailWidth ); + m_data = new PrivateData(headWidth, tailWidth); } //! Destructor QwtVectorFieldArrow::~QwtVectorFieldArrow() { - delete m_data; + delete m_data; } -void QwtVectorFieldArrow::setLength( qreal length ) +void QwtVectorFieldArrow::setLength(qreal length) { - m_data->setLength( length ); + m_data->setLength(length); } qreal QwtVectorFieldArrow::length() const { - return m_data->length; + return m_data->length; } -void QwtVectorFieldArrow::paint( QPainter* painter ) const +void QwtVectorFieldArrow::paint(QPainter *painter) const { - painter->drawPath( m_data->path ); + painter->drawPath(m_data->path); } class QwtVectorFieldThinArrow::PrivateData { - public: - PrivateData( qreal headW ) - : headWidth( headW ) - , length( headW + 4.0 ) - { - path.lineTo( -headWidth, headWidth * 0.6 ); - path.moveTo( 0, 0 ); - path.lineTo( -headWidth, -headWidth * 0.6 ); - path.moveTo( 0, 0 ); - path.lineTo( -length, 0 ); - } +public: + PrivateData(qreal headW) + : headWidth(headW) + , length(headW + 4.0) + { + path.lineTo(-headWidth, headWidth * 0.6); + path.moveTo(0, 0); + path.lineTo(-headWidth, -headWidth * 0.6); + path.moveTo(0, 0); + path.lineTo(-length, 0); + } - const qreal headWidth; - qreal length; + const qreal headWidth; + qreal length; - QPainterPath path; + QPainterPath path; }; /*! @@ -125,36 +120,36 @@ class QwtVectorFieldThinArrow::PrivateData \param headWidth Width of the triangular head \sa setLength() */ -QwtVectorFieldThinArrow::QwtVectorFieldThinArrow( qreal headWidth ) +QwtVectorFieldThinArrow::QwtVectorFieldThinArrow(qreal headWidth) { - m_data = new PrivateData( headWidth ); + m_data = new PrivateData(headWidth); } //! \brief Destructor QwtVectorFieldThinArrow::~QwtVectorFieldThinArrow() { - delete m_data; + delete m_data; } -void QwtVectorFieldThinArrow::setLength( qreal length ) +void QwtVectorFieldThinArrow::setLength(qreal length) { - m_data->length = length; + m_data->length = length; - const qreal headWidth = qMin( m_data->headWidth, length / 3.0 ); + const qreal headWidth = qMin(m_data->headWidth, length / 3.0); - QPainterPath& path = m_data->path; + QPainterPath &path = m_data->path; - path.setElementPositionAt( 1, -headWidth, headWidth * 0.6 ); - path.setElementPositionAt( 3, -headWidth, -headWidth * 0.6 ); - path.setElementPositionAt( 5, -length, 0 ); + path.setElementPositionAt(1, -headWidth, headWidth * 0.6); + path.setElementPositionAt(3, -headWidth, -headWidth * 0.6); + path.setElementPositionAt(5, -length, 0); } qreal QwtVectorFieldThinArrow::length() const { - return m_data->length; + return m_data->length; } -void QwtVectorFieldThinArrow::paint(QPainter* p) const +void QwtVectorFieldThinArrow::paint(QPainter *p) const { - p->drawPath( m_data->path ); + p->drawPath(m_data->path); } diff --git a/libs/qwt/src/qwt_vectorfield_symbol.h b/libs/qwt/src/qwt_vectorfield_symbol.h index a28cf6d8..1b3a86f0 100644 --- a/libs/qwt/src/qwt_vectorfield_symbol.h +++ b/libs/qwt/src/qwt_vectorfield_symbol.h @@ -26,32 +26,33 @@ class QPainterPath; the head size and width of the arrow. It is _always_ called before paint(). - A new arrow implementation can be set with QwtPlotVectorField::setArrowSymbol(), whereby - ownership is transferred to the plot field. + A new arrow implementation can be set with + QwtPlotVectorField::setArrowSymbol(), whereby ownership is transferred to the + plot field. */ class QWT_EXPORT QwtVectorFieldSymbol { - public: - QwtVectorFieldSymbol(); - virtual ~QwtVectorFieldSymbol(); +public: + QwtVectorFieldSymbol(); + virtual ~QwtVectorFieldSymbol(); - /*! - Set the length of the symbol/arrow - \sa length() - */ - virtual void setLength( qreal length ) = 0; + /*! + Set the length of the symbol/arrow + \sa length() + */ + virtual void setLength(qreal length) = 0; - /*! - \return length of the symbol/arrow - \sa setLength() - */ - virtual qreal length() const = 0; + /*! + \return length of the symbol/arrow + \sa setLength() + */ + virtual qreal length() const = 0; - //! Draw the symbol/arrow - virtual void paint( QPainter* ) const = 0; + //! Draw the symbol/arrow + virtual void paint(QPainter *) const = 0; - private: - Q_DISABLE_COPY(QwtVectorFieldSymbol) +private: + Q_DISABLE_COPY(QwtVectorFieldSymbol) }; /*! @@ -60,38 +61,38 @@ class QWT_EXPORT QwtVectorFieldSymbol */ class QWT_EXPORT QwtVectorFieldArrow : public QwtVectorFieldSymbol { - public: - QwtVectorFieldArrow( qreal headWidth = 6.0, qreal tailWidth = 1.0 ); - virtual ~QwtVectorFieldArrow() QWT_OVERRIDE; +public: + QwtVectorFieldArrow(qreal headWidth = 6.0, qreal tailWidth = 1.0); + virtual ~QwtVectorFieldArrow() QWT_OVERRIDE; - virtual void setLength( qreal length ) QWT_OVERRIDE; - virtual qreal length() const QWT_OVERRIDE; + virtual void setLength(qreal length) QWT_OVERRIDE; + virtual qreal length() const QWT_OVERRIDE; - virtual void paint( QPainter* ) const QWT_OVERRIDE; + virtual void paint(QPainter *) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; /*! - Arrow implementation that only used lines, with optionally a filled arrow or only - lines. + Arrow implementation that only used lines, with optionally a filled arrow or + only lines. */ class QWT_EXPORT QwtVectorFieldThinArrow : public QwtVectorFieldSymbol { - public: - QwtVectorFieldThinArrow( qreal headWidth = 6.0 ); - virtual ~QwtVectorFieldThinArrow() QWT_OVERRIDE; +public: + QwtVectorFieldThinArrow(qreal headWidth = 6.0); + virtual ~QwtVectorFieldThinArrow() QWT_OVERRIDE; - virtual void setLength( qreal length ) QWT_OVERRIDE; - virtual qreal length() const QWT_OVERRIDE; + virtual void setLength(qreal length) QWT_OVERRIDE; + virtual qreal length() const QWT_OVERRIDE; - virtual void paint( QPainter* ) const QWT_OVERRIDE; + virtual void paint(QPainter *) const QWT_OVERRIDE; - private: - class PrivateData; - PrivateData* m_data; +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_weeding_curve_fitter.cpp b/libs/qwt/src/qwt_weeding_curve_fitter.cpp index aacb99cc..46782215 100644 --- a/libs/qwt/src/qwt_weeding_curve_fitter.cpp +++ b/libs/qwt/src/qwt_weeding_curve_fitter.cpp @@ -17,28 +17,28 @@ class QwtWeedingCurveFitter::PrivateData { - public: - PrivateData() - : tolerance( 1.0 ) - , chunkSize( 0 ) - { - } +public: + PrivateData() + : tolerance(1.0) + , chunkSize(0) + { + } - double tolerance; - uint chunkSize; + double tolerance; + uint chunkSize; }; class QwtWeedingCurveFitter::Line { - public: - Line( int i1 = 0, int i2 = 0 ) - : from( i1 ) - , to( i2 ) - { - } +public: + Line(int i1 = 0, int i2 = 0) + : from(i1) + , to(i2) + { + } - int from; - int to; + int from; + int to; }; /*! @@ -47,17 +47,17 @@ class QwtWeedingCurveFitter::Line \param tolerance Tolerance \sa setTolerance(), tolerance() */ -QwtWeedingCurveFitter::QwtWeedingCurveFitter( double tolerance ) - : QwtCurveFitter( QwtCurveFitter::Polygon ) +QwtWeedingCurveFitter::QwtWeedingCurveFitter(double tolerance) + : QwtCurveFitter(QwtCurveFitter::Polygon) { - m_data = new PrivateData; - setTolerance( tolerance ); + m_data = new PrivateData; + setTolerance(tolerance); } //! Destructor QwtWeedingCurveFitter::~QwtWeedingCurveFitter() { - delete m_data; + delete m_data; } /*! @@ -73,9 +73,9 @@ QwtWeedingCurveFitter::~QwtWeedingCurveFitter() \sa tolerance() */ -void QwtWeedingCurveFitter::setTolerance( double tolerance ) +void QwtWeedingCurveFitter::setTolerance(double tolerance) { - m_data->tolerance = qwtMaxF( tolerance, 0.0 ); + m_data->tolerance = qwtMaxF(tolerance, 0.0); } /*! @@ -84,7 +84,7 @@ void QwtWeedingCurveFitter::setTolerance( double tolerance ) */ double QwtWeedingCurveFitter::tolerance() const { - return m_data->tolerance; + return m_data->tolerance; } /*! @@ -98,12 +98,12 @@ double QwtWeedingCurveFitter::tolerance() const \sa chunkSize() */ -void QwtWeedingCurveFitter::setChunkSize( uint numPoints ) +void QwtWeedingCurveFitter::setChunkSize(uint numPoints) { - if ( numPoints > 0 ) - numPoints = qMax( numPoints, 3U ); + if (numPoints > 0) + numPoints = qMax(numPoints, 3U); - m_data->chunkSize = numPoints; + m_data->chunkSize = numPoints; } /*! @@ -113,7 +113,7 @@ void QwtWeedingCurveFitter::setChunkSize( uint numPoints ) */ uint QwtWeedingCurveFitter::chunkSize() const { - return m_data->chunkSize; + return m_data->chunkSize; } /*! @@ -121,26 +121,26 @@ uint QwtWeedingCurveFitter::chunkSize() const \return Curve points \sa fitCurvePath() */ -QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF& points ) const +QPolygonF QwtWeedingCurveFitter::fitCurve(const QPolygonF &points) const { - if ( points.isEmpty() ) - return points; + if (points.isEmpty()) + return points; - QPolygonF fittedPoints; - if ( m_data->chunkSize == 0 ) + QPolygonF fittedPoints; + if (m_data->chunkSize == 0) + { + fittedPoints = simplify(points); + } + else + { + for (int i = 0; i < points.size(); i += m_data->chunkSize) { - fittedPoints = simplify( points ); - } - else - { - for ( int i = 0; i < points.size(); i += m_data->chunkSize ) - { - const QPolygonF p = points.mid( i, m_data->chunkSize ); - fittedPoints += simplify( p ); - } + const QPolygonF p = points.mid(i, m_data->chunkSize); + fittedPoints += simplify(p); } + } - return fittedPoints; + return fittedPoints; } /*! @@ -148,94 +148,94 @@ QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF& points ) const \return Curve path \sa fitCurve() */ -QPainterPath QwtWeedingCurveFitter::fitCurvePath( const QPolygonF& points ) const +QPainterPath QwtWeedingCurveFitter::fitCurvePath(const QPolygonF &points) const { - QPainterPath path; - path.addPolygon( fitCurve( points ) ); - return path; + QPainterPath path; + path.addPolygon(fitCurve(points)); + return path; } -QPolygonF QwtWeedingCurveFitter::simplify( const QPolygonF& points ) const +QPolygonF QwtWeedingCurveFitter::simplify(const QPolygonF &points) const { - const double toleranceSqr = m_data->tolerance * m_data->tolerance; + const double toleranceSqr = m_data->tolerance * m_data->tolerance; - QStack< Line > stack; - stack.reserve( 500 ); + QStack stack; + stack.reserve(500); - const QPointF* p = points.data(); - const int nPoints = points.size(); + const QPointF *p = points.data(); + const int nPoints = points.size(); - QVector< bool > usePoint( nPoints, false ); + QVector usePoint(nPoints, false); - stack.push( Line( 0, nPoints - 1 ) ); + stack.push(Line(0, nPoints - 1)); - while ( !stack.isEmpty() ) + while (!stack.isEmpty()) + { + const Line r = stack.pop(); + + // initialize line segment + const double vecX = p[r.to].x() - p[r.from].x(); + const double vecY = p[r.to].y() - p[r.from].y(); + + const double vecLength = std::sqrt(vecX * vecX + vecY * vecY); + + const double unitVecX = (vecLength != 0.0) ? vecX / vecLength : 0.0; + const double unitVecY = (vecLength != 0.0) ? vecY / vecLength : 0.0; + + double maxDistSqr = 0.0; + int nVertexIndexMaxDistance = r.from + 1; + for (int i = r.from + 1; i < r.to; i++) { - const Line r = stack.pop(); + // compare to anchor + const double fromVecX = p[i].x() - p[r.from].x(); + const double fromVecY = p[i].y() - p[r.from].y(); - // initialize line segment - const double vecX = p[r.to].x() - p[r.from].x(); - const double vecY = p[r.to].y() - p[r.from].y(); + double distToSegmentSqr; + if (fromVecX * unitVecX + fromVecY * unitVecY < 0.0) + { + distToSegmentSqr = fromVecX * fromVecX + fromVecY * fromVecY; + } + else + { + const double toVecX = p[i].x() - p[r.to].x(); + const double toVecY = p[i].y() - p[r.to].y(); + const double toVecLength = toVecX * toVecX + toVecY * toVecY; - const double vecLength = std::sqrt( vecX * vecX + vecY * vecY ); - - const double unitVecX = ( vecLength != 0.0 ) ? vecX / vecLength : 0.0; - const double unitVecY = ( vecLength != 0.0 ) ? vecY / vecLength : 0.0; - - double maxDistSqr = 0.0; - int nVertexIndexMaxDistance = r.from + 1; - for ( int i = r.from + 1; i < r.to; i++ ) + const double s = toVecX * (-unitVecX) + toVecY * (-unitVecY); + if (s < 0.0) { - //compare to anchor - const double fromVecX = p[i].x() - p[r.from].x(); - const double fromVecY = p[i].y() - p[r.from].y(); - - double distToSegmentSqr; - if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 ) - { - distToSegmentSqr = fromVecX * fromVecX + fromVecY * fromVecY; - } - else - { - const double toVecX = p[i].x() - p[r.to].x(); - const double toVecY = p[i].y() - p[r.to].y(); - const double toVecLength = toVecX * toVecX + toVecY * toVecY; - - const double s = toVecX * ( -unitVecX ) + toVecY * ( -unitVecY ); - if ( s < 0.0 ) - { - distToSegmentSqr = toVecLength; - } - else - { - distToSegmentSqr = std::fabs( toVecLength - s * s ); - } - } - - if ( maxDistSqr < distToSegmentSqr ) - { - maxDistSqr = distToSegmentSqr; - nVertexIndexMaxDistance = i; - } - } - if ( maxDistSqr <= toleranceSqr ) - { - usePoint[r.from] = true; - usePoint[r.to] = true; + distToSegmentSqr = toVecLength; } else { - stack.push( Line( r.from, nVertexIndexMaxDistance ) ); - stack.push( Line( nVertexIndexMaxDistance, r.to ) ); + distToSegmentSqr = std::fabs(toVecLength - s * s); } - } + } - QPolygonF stripped; - for ( int i = 0; i < nPoints; i++ ) + if (maxDistSqr < distToSegmentSqr) + { + maxDistSqr = distToSegmentSqr; + nVertexIndexMaxDistance = i; + } + } + if (maxDistSqr <= toleranceSqr) { - if ( usePoint[i] ) - stripped += p[i]; + usePoint[r.from] = true; + usePoint[r.to] = true; } + else + { + stack.push(Line(r.from, nVertexIndexMaxDistance)); + stack.push(Line(nVertexIndexMaxDistance, r.to)); + } + } - return stripped; + QPolygonF stripped; + for (int i = 0; i < nPoints; i++) + { + if (usePoint[i]) + stripped += p[i]; + } + + return stripped; } diff --git a/libs/qwt/src/qwt_weeding_curve_fitter.h b/libs/qwt/src/qwt_weeding_curve_fitter.h index 9a273ba1..99f156ea 100644 --- a/libs/qwt/src/qwt_weeding_curve_fitter.h +++ b/libs/qwt/src/qwt_weeding_curve_fitter.h @@ -23,9 +23,9 @@ The runtime of the algorithm increases non linear ( worst case O( n*n ) ) and might be very slow for huge polygons. To avoid performance issues - it might be useful to split the polygon ( setChunkSize() ) and to run the algorithm - for these smaller parts. The disadvantage of having no interpolation - at the borders is for most use cases irrelevant. + it might be useful to split the polygon ( setChunkSize() ) and to run the + algorithm for these smaller parts. The disadvantage of having no + interpolation at the borders is for most use cases irrelevant. The smoothed curve consists of a subset of the points that defined the original curve. @@ -37,26 +37,26 @@ */ class QWT_EXPORT QwtWeedingCurveFitter : public QwtCurveFitter { - public: - explicit QwtWeedingCurveFitter( double tolerance = 1.0 ); - virtual ~QwtWeedingCurveFitter(); +public: + explicit QwtWeedingCurveFitter(double tolerance = 1.0); + virtual ~QwtWeedingCurveFitter(); - void setTolerance( double ); - double tolerance() const; + void setTolerance(double); + double tolerance() const; - void setChunkSize( uint ); - uint chunkSize() const; + void setChunkSize(uint); + uint chunkSize() const; - virtual QPolygonF fitCurve( const QPolygonF& ) const QWT_OVERRIDE; - virtual QPainterPath fitCurvePath( const QPolygonF& ) const QWT_OVERRIDE; + virtual QPolygonF fitCurve(const QPolygonF &) const QWT_OVERRIDE; + virtual QPainterPath fitCurvePath(const QPolygonF &) const QWT_OVERRIDE; - private: - virtual QPolygonF simplify( const QPolygonF& ) const; +private: + virtual QPolygonF simplify(const QPolygonF &) const; - class Line; + class Line; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_wheel.cpp b/libs/qwt/src/qwt_wheel.cpp index 86d50cad..22809891 100644 --- a/libs/qwt/src/qwt_wheel.cpp +++ b/libs/qwt/src/qwt_wheel.cpp @@ -22,87 +22,87 @@ class QwtWheel::PrivateData { - public: - PrivateData() - : orientation( Qt::Horizontal ) - , viewAngle( 175.0 ) - , totalAngle( 360.0 ) - , tickCount( 10 ) - , wheelBorderWidth( 2 ) - , borderWidth( 2 ) - , wheelWidth( 20 ) - , mouseOffset( 0.0 ) - , updateInterval( 50 ) - , mass( 0.0 ) - , timerId( 0 ) - , speed( 0.0 ) - , mouseValue( 0.0 ) - , flyingValue( 0.0 ) - , minimum( 0.0 ) - , maximum( 100.0 ) - , singleStep( 1.0 ) - , pageStepCount( 1 ) - , value( 0.0 ) - , isScrolling( false ) - , tracking( true ) - , stepAlignment( true ) - , pendingValueChanged( false ) - , inverted( false ) - , wrapping( false ) - { - } +public: + PrivateData() + : orientation(Qt::Horizontal) + , viewAngle(175.0) + , totalAngle(360.0) + , tickCount(10) + , wheelBorderWidth(2) + , borderWidth(2) + , wheelWidth(20) + , mouseOffset(0.0) + , updateInterval(50) + , mass(0.0) + , timerId(0) + , speed(0.0) + , mouseValue(0.0) + , flyingValue(0.0) + , minimum(0.0) + , maximum(100.0) + , singleStep(1.0) + , pageStepCount(1) + , value(0.0) + , isScrolling(false) + , tracking(true) + , stepAlignment(true) + , pendingValueChanged(false) + , inverted(false) + , wrapping(false) + { + } - Qt::Orientation orientation; - double viewAngle; - double totalAngle; - int tickCount; - int wheelBorderWidth; - int borderWidth; - int wheelWidth; + Qt::Orientation orientation; + double viewAngle; + double totalAngle; + int tickCount; + int wheelBorderWidth; + int borderWidth; + int wheelWidth; - double mouseOffset; + double mouseOffset; - int updateInterval; - double mass; + int updateInterval; + double mass; - // for the flying wheel effect - int timerId; - QElapsedTimer timer; - double speed; - double mouseValue; - double flyingValue; + // for the flying wheel effect + int timerId; + QElapsedTimer timer; + double speed; + double mouseValue; + double flyingValue; - double minimum; - double maximum; + double minimum; + double maximum; - double singleStep; - int pageStepCount; + double singleStep; + int pageStepCount; - double value; + double value; - bool isScrolling; - bool tracking; - bool stepAlignment; - bool pendingValueChanged; // when not tracking - bool inverted; - bool wrapping; + bool isScrolling; + bool tracking; + bool stepAlignment; + bool pendingValueChanged; // when not tracking + bool inverted; + bool wrapping; }; //! Constructor -QwtWheel::QwtWheel( QWidget* parent ): - QWidget( parent ) +QwtWheel::QwtWheel(QWidget *parent) + : QWidget(parent) { - m_data = new PrivateData; + m_data = new PrivateData; - setFocusPolicy( Qt::StrongFocus ); - setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); + setFocusPolicy(Qt::StrongFocus); + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + setAttribute(Qt::WA_WState_OwnSizePolicy, false); } //! Destructor QwtWheel::~QwtWheel() { - delete m_data; + delete m_data; } /*! @@ -117,9 +117,9 @@ QwtWheel::~QwtWheel() \param enable On/Off \sa isTracking() */ -void QwtWheel::setTracking( bool enable ) +void QwtWheel::setTracking(bool enable) { - m_data->tracking = enable; + m_data->tracking = enable; } /*! @@ -128,7 +128,7 @@ void QwtWheel::setTracking( bool enable ) */ bool QwtWheel::isTracking() const { - return m_data->tracking; + return m_data->tracking; } /*! @@ -139,9 +139,9 @@ bool QwtWheel::isTracking() const \param interval Interval in milliseconds \sa updateInterval(), setMass(), setTracking() */ -void QwtWheel::setUpdateInterval( int interval ) +void QwtWheel::setUpdateInterval(int interval) { - m_data->updateInterval = qMax( interval, 50 ); + m_data->updateInterval = qMax(interval, 50); } /*! @@ -150,7 +150,7 @@ void QwtWheel::setUpdateInterval( int interval ) */ int QwtWheel::updateInterval() const { - return m_data->updateInterval; + return m_data->updateInterval; } /*! @@ -160,22 +160,22 @@ int QwtWheel::updateInterval() const \param event Mouse event */ -void QwtWheel::mousePressEvent( QMouseEvent* event ) +void QwtWheel::mousePressEvent(QMouseEvent *event) { - stopFlying(); + stopFlying(); - m_data->isScrolling = wheelRect().contains( event->pos() ); + m_data->isScrolling = wheelRect().contains(event->pos()); - if ( m_data->isScrolling ) - { - m_data->timer.start(); - m_data->speed = 0.0; - m_data->mouseValue = valueAt( event->pos() ); - m_data->mouseOffset = m_data->mouseValue - m_data->value; - m_data->pendingValueChanged = false; + if (m_data->isScrolling) + { + m_data->timer.start(); + m_data->speed = 0.0; + m_data->mouseValue = valueAt(event->pos()); + m_data->mouseOffset = m_data->mouseValue - m_data->value; + m_data->pendingValueChanged = false; - Q_EMIT wheelPressed(); - } + Q_EMIT wheelPressed(); + } } /*! @@ -185,44 +185,44 @@ void QwtWheel::mousePressEvent( QMouseEvent* event ) \param event Mouse event */ -void QwtWheel::mouseMoveEvent( QMouseEvent* event ) +void QwtWheel::mouseMoveEvent(QMouseEvent *event) { - if ( !m_data->isScrolling ) - return; + if (!m_data->isScrolling) + return; - double mouseValue = valueAt( event->pos() ); + double mouseValue = valueAt(event->pos()); - if ( m_data->mass > 0.0 ) - { - double ms = m_data->timer.restart(); + if (m_data->mass > 0.0) + { + double ms = m_data->timer.restart(); - // the interval when mouse move events are posted are somehow - // random. To avoid unrealistic speed values we limit ms + // the interval when mouse move events are posted are somehow + // random. To avoid unrealistic speed values we limit ms - ms = qMax( ms, 5.0 ); + ms = qMax(ms, 5.0); - m_data->speed = ( mouseValue - m_data->mouseValue ) / ms; - } + m_data->speed = (mouseValue - m_data->mouseValue) / ms; + } - m_data->mouseValue = mouseValue; + m_data->mouseValue = mouseValue; - double value = boundedValue( mouseValue - m_data->mouseOffset ); - if ( m_data->stepAlignment ) - value = alignedValue( value ); + double value = boundedValue(mouseValue - m_data->mouseOffset); + if (m_data->stepAlignment) + value = alignedValue(value); - if ( value != m_data->value ) - { - m_data->value = value; + if (value != m_data->value) + { + m_data->value = value; - update(); + update(); - Q_EMIT wheelMoved( m_data->value ); + Q_EMIT wheelMoved(m_data->value); - if ( m_data->tracking ) - Q_EMIT valueChanged( m_data->value ); - else - m_data->pendingValueChanged = true; - } + if (m_data->tracking) + Q_EMIT valueChanged(m_data->value); + else + m_data->pendingValueChanged = true; + } } /*! @@ -234,41 +234,41 @@ void QwtWheel::mouseMoveEvent( QMouseEvent* event ) \param event Mouse event */ -void QwtWheel::mouseReleaseEvent( QMouseEvent* event ) +void QwtWheel::mouseReleaseEvent(QMouseEvent *event) { - Q_UNUSED( event ); + Q_UNUSED(event); - if ( !m_data->isScrolling ) - return; + if (!m_data->isScrolling) + return; - m_data->isScrolling = false; + m_data->isScrolling = false; - bool startFlying = false; + bool startFlying = false; - if ( m_data->mass > 0.0 ) - { - const qint64 ms = m_data->timer.elapsed(); - if ( ( std::fabs( m_data->speed ) > 0.0 ) && ( ms < 50 ) ) - startFlying = true; - } + if (m_data->mass > 0.0) + { + const qint64 ms = m_data->timer.elapsed(); + if ((std::fabs(m_data->speed) > 0.0) && (ms < 50)) + startFlying = true; + } - if ( startFlying ) - { - m_data->flyingValue = - boundedValue( m_data->mouseValue - m_data->mouseOffset ); + if (startFlying) + { + m_data->flyingValue + = boundedValue(m_data->mouseValue - m_data->mouseOffset); - m_data->timerId = startTimer( m_data->updateInterval ); - } - else - { - if ( m_data->pendingValueChanged ) - Q_EMIT valueChanged( m_data->value ); - } + m_data->timerId = startTimer(m_data->updateInterval); + } + else + { + if (m_data->pendingValueChanged) + Q_EMIT valueChanged(m_data->value); + } - m_data->pendingValueChanged = false; - m_data->mouseOffset = 0.0; + m_data->pendingValueChanged = false; + m_data->mouseOffset = 0.0; - Q_EMIT wheelReleased(); + Q_EMIT wheelReleased(); } /*! @@ -280,40 +280,39 @@ void QwtWheel::mouseReleaseEvent( QMouseEvent* event ) \sa updateInterval() */ -void QwtWheel::timerEvent( QTimerEvent* event ) +void QwtWheel::timerEvent(QTimerEvent *event) { - if ( event->timerId() != m_data->timerId ) - { - QWidget::timerEvent( event ); - return; - } + if (event->timerId() != m_data->timerId) + { + QWidget::timerEvent(event); + return; + } - m_data->speed *= std::exp( -m_data->updateInterval * 0.001 / m_data->mass ); + m_data->speed *= std::exp(-m_data->updateInterval * 0.001 / m_data->mass); - m_data->flyingValue += m_data->speed * m_data->updateInterval; - m_data->flyingValue = boundedValue( m_data->flyingValue ); + m_data->flyingValue += m_data->speed * m_data->updateInterval; + m_data->flyingValue = boundedValue(m_data->flyingValue); - double value = m_data->flyingValue; - if ( m_data->stepAlignment ) - value = alignedValue( value ); + double value = m_data->flyingValue; + if (m_data->stepAlignment) + value = alignedValue(value); - if ( std::fabs( m_data->speed ) < 0.001 * m_data->singleStep ) - { - // stop if m_data->speed < one step per second - stopFlying(); - } + if (std::fabs(m_data->speed) < 0.001 * m_data->singleStep) + { + // stop if m_data->speed < one step per second + stopFlying(); + } - if ( value != m_data->value ) - { - m_data->value = value; - update(); + if (value != m_data->value) + { + m_data->value = value; + update(); - if ( m_data->tracking || m_data->timerId == 0 ) - Q_EMIT valueChanged( m_data->value ); - } + if (m_data->tracking || m_data->timerId == 0) + Q_EMIT valueChanged(m_data->value); + } } - /*! \brief Handle wheel events @@ -321,62 +320,62 @@ void QwtWheel::timerEvent( QTimerEvent* event ) \param event Wheel event */ -void QwtWheel::wheelEvent( QWheelEvent* event ) +void QwtWheel::wheelEvent(QWheelEvent *event) { #if QT_VERSION < 0x050e00 - const QPoint wheelPos = event->pos(); - const int wheelDelta = event->delta(); + const QPoint wheelPos = event->pos(); + const int wheelDelta = event->delta(); #else - const QPoint wheelPos = event->position().toPoint(); + const QPoint wheelPos = event->position().toPoint(); - const QPoint delta = event->angleDelta(); - const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) ) - ? delta.x() : delta.y(); + const QPoint delta = event->angleDelta(); + const int wheelDelta + = (qAbs(delta.x()) > qAbs(delta.y())) ? delta.x() : delta.y(); #endif - if ( !wheelRect().contains( wheelPos ) ) - { - event->ignore(); - return; - } + if (!wheelRect().contains(wheelPos)) + { + event->ignore(); + return; + } - if ( m_data->isScrolling ) - return; + if (m_data->isScrolling) + return; - stopFlying(); + stopFlying(); - double increment = 0.0; + double increment = 0.0; - if ( ( event->modifiers() & Qt::ControlModifier ) || - ( event->modifiers() & Qt::ShiftModifier ) ) - { - // one page regardless of delta - increment = m_data->singleStep * m_data->pageStepCount; - if ( wheelDelta < 0 ) - increment = -increment; - } - else - { - const int numSteps = wheelDelta / 120; - increment = m_data->singleStep * numSteps; - } + if ((event->modifiers() & Qt::ControlModifier) + || (event->modifiers() & Qt::ShiftModifier)) + { + // one page regardless of delta + increment = m_data->singleStep * m_data->pageStepCount; + if (wheelDelta < 0) + increment = -increment; + } + else + { + const int numSteps = wheelDelta / 120; + increment = m_data->singleStep * numSteps; + } - if ( m_data->orientation == Qt::Vertical && m_data->inverted ) - increment = -increment; + if (m_data->orientation == Qt::Vertical && m_data->inverted) + increment = -increment; - double value = boundedValue( m_data->value + increment ); + double value = boundedValue(m_data->value + increment); - if ( m_data->stepAlignment ) - value = alignedValue( value ); + if (m_data->stepAlignment) + value = alignedValue(value); - if ( value != m_data->value ) - { - m_data->value = value; - update(); + if (value != m_data->value) + { + m_data->value = value; + update(); - Q_EMIT valueChanged( m_data->value ); - Q_EMIT wheelMoved( m_data->value ); - } + Q_EMIT valueChanged(m_data->value); + Q_EMIT wheelMoved(m_data->value); + } } /*! @@ -406,104 +405,96 @@ void QwtWheel::wheelEvent( QWheelEvent* event ) \param event Key event */ -void QwtWheel::keyPressEvent( QKeyEvent* event ) +void QwtWheel::keyPressEvent(QKeyEvent *event) { - if ( m_data->isScrolling ) - { - // don't interfere mouse scrolling - return; + if (m_data->isScrolling) + { + // don't interfere mouse scrolling + return; + } + + double value = m_data->value; + double increment = 0.0; + + switch (event->key()) + { + case Qt::Key_Down: { + if (m_data->orientation == Qt::Vertical && m_data->inverted) + increment = m_data->singleStep; + else + increment = -m_data->singleStep; + + break; } + case Qt::Key_Up: { + if (m_data->orientation == Qt::Vertical && m_data->inverted) + increment = -m_data->singleStep; + else + increment = m_data->singleStep; - double value = m_data->value; - double increment = 0.0; - - switch ( event->key() ) - { - case Qt::Key_Down: - { - if ( m_data->orientation == Qt::Vertical && m_data->inverted ) - increment = m_data->singleStep; - else - increment = -m_data->singleStep; - - break; - } - case Qt::Key_Up: - { - if ( m_data->orientation == Qt::Vertical && m_data->inverted ) - increment = -m_data->singleStep; - else - increment = m_data->singleStep; - - break; - } - case Qt::Key_Left: - { - if ( m_data->orientation == Qt::Horizontal ) - { - if ( m_data->inverted ) - increment = m_data->singleStep; - else - increment = -m_data->singleStep; - } - break; - } - case Qt::Key_Right: - { - if ( m_data->orientation == Qt::Horizontal ) - { - if ( m_data->inverted ) - increment = -m_data->singleStep; - else - increment = m_data->singleStep; - } - break; - } - case Qt::Key_PageUp: - { - increment = m_data->pageStepCount * m_data->singleStep; - break; - } - case Qt::Key_PageDown: - { - increment = -m_data->pageStepCount * m_data->singleStep; - break; - } - case Qt::Key_Home: - { - value = m_data->minimum; - break; - } - case Qt::Key_End: - { - value = m_data->maximum; - break; - } - default:; - { - event->ignore(); - } + break; } - - if ( event->isAccepted() ) - stopFlying(); - - if ( increment != 0.0 ) - { - value = boundedValue( m_data->value + increment ); - - if ( m_data->stepAlignment ) - value = alignedValue( value ); + case Qt::Key_Left: { + if (m_data->orientation == Qt::Horizontal) + { + if (m_data->inverted) + increment = m_data->singleStep; + else + increment = -m_data->singleStep; + } + break; } - - if ( value != m_data->value ) - { - m_data->value = value; - update(); - - Q_EMIT valueChanged( m_data->value ); - Q_EMIT wheelMoved( m_data->value ); + case Qt::Key_Right: { + if (m_data->orientation == Qt::Horizontal) + { + if (m_data->inverted) + increment = -m_data->singleStep; + else + increment = m_data->singleStep; + } + break; } + case Qt::Key_PageUp: { + increment = m_data->pageStepCount * m_data->singleStep; + break; + } + case Qt::Key_PageDown: { + increment = -m_data->pageStepCount * m_data->singleStep; + break; + } + case Qt::Key_Home: { + value = m_data->minimum; + break; + } + case Qt::Key_End: { + value = m_data->maximum; + break; + } + default:; + { + event->ignore(); + } + } + + if (event->isAccepted()) + stopFlying(); + + if (increment != 0.0) + { + value = boundedValue(m_data->value + increment); + + if (m_data->stepAlignment) + value = alignedValue(value); + } + + if (value != m_data->value) + { + m_data->value = value; + update(); + + Q_EMIT valueChanged(m_data->value); + Q_EMIT wheelMoved(m_data->value); + } } /*! @@ -516,15 +507,15 @@ void QwtWheel::keyPressEvent( QKeyEvent* event ) \param count Number of grooves per 360 degrees \sa tickCount() */ -void QwtWheel::setTickCount( int count ) +void QwtWheel::setTickCount(int count) { - count = qBound( 6, count, 50 ); + count = qBound(6, count, 50); - if ( count != m_data->tickCount ) - { - m_data->tickCount = qBound( 6, count, 50 ); - update(); - } + if (count != m_data->tickCount) + { + m_data->tickCount = qBound(6, count, 50); + update(); + } } /*! @@ -533,7 +524,7 @@ void QwtWheel::setTickCount( int count ) */ int QwtWheel::tickCount() const { - return m_data->tickCount; + return m_data->tickCount; } /*! @@ -548,12 +539,12 @@ int QwtWheel::tickCount() const \param borderWidth Border width \sa internalBorder() */ -void QwtWheel::setWheelBorderWidth( int borderWidth ) +void QwtWheel::setWheelBorderWidth(int borderWidth) { - const int d = qMin( width(), height() ) / 3; - borderWidth = qMin( borderWidth, d ); - m_data->wheelBorderWidth = qMax( borderWidth, 1 ); - update(); + const int d = qMin(width(), height()) / 3; + borderWidth = qMin(borderWidth, d); + m_data->wheelBorderWidth = qMax(borderWidth, 1); + update(); } /*! @@ -562,7 +553,7 @@ void QwtWheel::setWheelBorderWidth( int borderWidth ) */ int QwtWheel::wheelBorderWidth() const { - return m_data->wheelBorderWidth; + return m_data->wheelBorderWidth; } /*! @@ -573,10 +564,10 @@ int QwtWheel::wheelBorderWidth() const \param width Border width \sa borderWidth() */ -void QwtWheel::setBorderWidth( int width ) +void QwtWheel::setBorderWidth(int width) { - m_data->borderWidth = qMax( width, 0 ); - update(); + m_data->borderWidth = qMax(width, 0); + update(); } /*! @@ -585,7 +576,7 @@ void QwtWheel::setBorderWidth( int width ) */ int QwtWheel::borderWidth() const { - return m_data->borderWidth; + return m_data->borderWidth; } /*! @@ -593,8 +584,8 @@ int QwtWheel::borderWidth() const */ QRect QwtWheel::wheelRect() const { - const int bw = m_data->borderWidth; - return contentsRect().adjusted( bw, bw, -bw, -bw ); + const int bw = m_data->borderWidth; + return contentsRect().adjusted(bw, bw, -bw, -bw); } /*! @@ -610,13 +601,13 @@ QRect QwtWheel::wheelRect() const \param angle total angle in degrees \sa totalAngle() */ -void QwtWheel::setTotalAngle( double angle ) +void QwtWheel::setTotalAngle(double angle) { - if ( angle < 0.0 ) - angle = 0.0; + if (angle < 0.0) + angle = 0.0; - m_data->totalAngle = angle; - update(); + m_data->totalAngle = angle; + update(); } /*! @@ -625,7 +616,7 @@ void QwtWheel::setTotalAngle( double angle ) */ double QwtWheel::totalAngle() const { - return m_data->totalAngle; + return m_data->totalAngle; } /*! @@ -636,22 +627,22 @@ double QwtWheel::totalAngle() const \param orientation Qt::Horizontal or Qt::Vertical. \sa orientation() */ -void QwtWheel::setOrientation( Qt::Orientation orientation ) +void QwtWheel::setOrientation(Qt::Orientation orientation) { - if ( m_data->orientation == orientation ) - return; + if (m_data->orientation == orientation) + return; - if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) ) - { - QSizePolicy sp = sizePolicy(); - sp.transpose(); - setSizePolicy( sp ); + if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) + { + QSizePolicy sp = sizePolicy(); + sp.transpose(); + setSizePolicy(sp); - setAttribute( Qt::WA_WState_OwnSizePolicy, false ); - } + setAttribute(Qt::WA_WState_OwnSizePolicy, false); + } - m_data->orientation = orientation; - update(); + m_data->orientation = orientation; + update(); } /*! @@ -660,7 +651,7 @@ void QwtWheel::setOrientation( Qt::Orientation orientation ) */ Qt::Orientation QwtWheel::orientation() const { - return m_data->orientation; + return m_data->orientation; } /*! @@ -673,10 +664,10 @@ Qt::Orientation QwtWheel::orientation() const \param angle Visible angle in degrees \sa viewAngle(), setTotalAngle() */ -void QwtWheel::setViewAngle( double angle ) +void QwtWheel::setViewAngle(double angle) { - m_data->viewAngle = qBound( 10.0, angle, 175.0 ); - update(); + m_data->viewAngle = qBound(10.0, angle, 175.0); + update(); } /*! @@ -685,7 +676,7 @@ void QwtWheel::setViewAngle( double angle ) */ double QwtWheel::viewAngle() const { - return m_data->viewAngle; + return m_data->viewAngle; } /*! @@ -694,62 +685,62 @@ double QwtWheel::viewAngle() const \param pos Position \return Value corresponding to pos */ -double QwtWheel::valueAt( const QPoint& pos ) const +double QwtWheel::valueAt(const QPoint &pos) const { - const QRectF rect = wheelRect(); + const QRectF rect = wheelRect(); - double w, dx; - if ( m_data->orientation == Qt::Vertical ) - { - w = rect.height(); - dx = rect.top() - pos.y(); - } - else - { - w = rect.width(); - dx = pos.x() - rect.left(); - } + double w, dx; + if (m_data->orientation == Qt::Vertical) + { + w = rect.height(); + dx = rect.top() - pos.y(); + } + else + { + w = rect.width(); + dx = pos.x() - rect.left(); + } - if ( w == 0.0 ) - return 0.0; + if (w == 0.0) + return 0.0; - if ( m_data->inverted ) - { - dx = w - dx; - } + if (m_data->inverted) + { + dx = w - dx; + } - // w pixels is an arc of viewAngle degrees, - // so we convert change in pixels to change in angle - const double ang = dx * m_data->viewAngle / w; + // w pixels is an arc of viewAngle degrees, + // so we convert change in pixels to change in angle + const double ang = dx * m_data->viewAngle / w; - // value range maps to totalAngle degrees, - // so convert the change in angle to a change in value - const double val = ang * ( maximum() - minimum() ) / m_data->totalAngle; + // value range maps to totalAngle degrees, + // so convert the change in angle to a change in value + const double val = ang * (maximum() - minimum()) / m_data->totalAngle; - return val; + return val; } /*! \brief Qt Paint Event \param event Paint event */ -void QwtWheel::paintEvent( QPaintEvent* event ) +void QwtWheel::paintEvent(QPaintEvent *event) { - QPainter painter( this ); - painter.setClipRegion( event->region() ); + QPainter painter(this); + painter.setClipRegion(event->region()); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - qDrawShadePanel( &painter, - contentsRect(), palette(), true, m_data->borderWidth ); + qDrawShadePanel(&painter, contentsRect(), palette(), true, + m_data->borderWidth); - drawWheelBackground( &painter, wheelRect() ); - drawTicks( &painter, wheelRect() ); + drawWheelBackground(&painter, wheelRect()); + drawTicks(&painter, wheelRect()); - if ( hasFocus() ) - QwtPainter::drawFocusRect( &painter, this ); + if (hasFocus()) + QwtPainter::drawFocusRect(&painter, this); } /*! @@ -758,54 +749,55 @@ void QwtWheel::paintEvent( QPaintEvent* event ) \param painter Painter \param rect Geometry for the wheel */ -void QwtWheel::drawWheelBackground( - QPainter* painter, const QRectF& rect ) +void QwtWheel::drawWheelBackground(QPainter *painter, const QRectF &rect) { - painter->save(); + painter->save(); - QPalette pal = palette(); + QPalette pal = palette(); - // draw shaded background - QLinearGradient gradient( rect.topLeft(), - ( m_data->orientation == Qt::Horizontal ) ? rect.topRight() : rect.bottomLeft() ); - gradient.setColorAt( 0.0, pal.color( QPalette::Button ) ); - gradient.setColorAt( 0.2, pal.color( QPalette::Midlight ) ); - gradient.setColorAt( 0.7, pal.color( QPalette::Mid ) ); - gradient.setColorAt( 1.0, pal.color( QPalette::Dark ) ); + // draw shaded background + QLinearGradient gradient(rect.topLeft(), + (m_data->orientation == Qt::Horizontal) + ? rect.topRight() + : rect.bottomLeft()); + gradient.setColorAt(0.0, pal.color(QPalette::Button)); + gradient.setColorAt(0.2, pal.color(QPalette::Midlight)); + gradient.setColorAt(0.7, pal.color(QPalette::Mid)); + gradient.setColorAt(1.0, pal.color(QPalette::Dark)); - painter->fillRect( rect, gradient ); + painter->fillRect(rect, gradient); - // draw internal border + // draw internal border - const QPen lightPen( palette().color( QPalette::Light ), - m_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap ); - const QPen darkPen( pal.color( QPalette::Dark ), - m_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap ); + const QPen lightPen(palette().color(QPalette::Light), + m_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap); + const QPen darkPen(pal.color(QPalette::Dark), m_data->wheelBorderWidth, + Qt::SolidLine, Qt::FlatCap); - const double bw2 = 0.5 * m_data->wheelBorderWidth; + const double bw2 = 0.5 * m_data->wheelBorderWidth; - if ( m_data->orientation == Qt::Horizontal ) - { - painter->setPen( lightPen ); - painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ), - QPointF( rect.right(), rect.top() + bw2 ) ); + if (m_data->orientation == Qt::Horizontal) + { + painter->setPen(lightPen); + painter->drawLine(QPointF(rect.left(), rect.top() + bw2), + QPointF(rect.right(), rect.top() + bw2)); - painter->setPen( darkPen ); - painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ), - QPointF( rect.right(), rect.bottom() - bw2 ) ); - } - else // Qt::Vertical - { - painter->setPen( lightPen ); - painter->drawLine( QPointF( rect.left() + bw2, rect.top() ), - QPointF( rect.left() + bw2, rect.bottom() ) ); + painter->setPen(darkPen); + painter->drawLine(QPointF(rect.left(), rect.bottom() - bw2), + QPointF(rect.right(), rect.bottom() - bw2)); + } + else // Qt::Vertical + { + painter->setPen(lightPen); + painter->drawLine(QPointF(rect.left() + bw2, rect.top()), + QPointF(rect.left() + bw2, rect.bottom())); - painter->setPen( darkPen ); - painter->drawLine( QPointF( rect.right() - bw2, rect.top() ), - QPointF( rect.right() - bw2, rect.bottom() ) ); - } + painter->setPen(darkPen); + painter->drawLine(QPointF(rect.right() - bw2, rect.top()), + QPointF(rect.right() - bw2, rect.bottom())); + } - painter->restore(); + painter->restore(); } /*! @@ -814,112 +806,108 @@ void QwtWheel::drawWheelBackground( \param painter Painter \param rect Geometry for the wheel */ -void QwtWheel::drawTicks( QPainter* painter, const QRectF& rect ) +void QwtWheel::drawTicks(QPainter *painter, const QRectF &rect) { - const double range = m_data->maximum - m_data->minimum; + const double range = m_data->maximum - m_data->minimum; - if ( range == 0.0 || m_data->totalAngle == 0.0 ) + if (range == 0.0 || m_data->totalAngle == 0.0) + { + return; + } + + const QPen lightPen(palette().color(QPalette::Light), 0, Qt::SolidLine, + Qt::FlatCap); + const QPen darkPen(palette().color(QPalette::Dark), 0, Qt::SolidLine, + Qt::FlatCap); + + const double cnvFactor = qAbs(m_data->totalAngle / range); + const double halfIntv = 0.5 * m_data->viewAngle / cnvFactor; + const double loValue = value() - halfIntv; + const double hiValue = value() + halfIntv; + const double tickWidth = 360.0 / double(m_data->tickCount) / cnvFactor; + const double sinArc = qFastSin(m_data->viewAngle * M_PI / 360.0); + + if (m_data->orientation == Qt::Horizontal) + { + const double radius = rect.width() * 0.5; + + double l1 = rect.top() + m_data->wheelBorderWidth; + double l2 = rect.bottom() - m_data->wheelBorderWidth - 1; + + // draw one point over the border if border > 1 + if (m_data->wheelBorderWidth > 1) { - return; + l1--; + l2++; } - const QPen lightPen( palette().color( QPalette::Light ), - 0, Qt::SolidLine, Qt::FlatCap ); - const QPen darkPen( palette().color( QPalette::Dark ), - 0, Qt::SolidLine, Qt::FlatCap ); + const double maxpos = rect.right() - 2; + const double minpos = rect.left() + 2; - const double cnvFactor = qAbs( m_data->totalAngle / range ); - const double halfIntv = 0.5 * m_data->viewAngle / cnvFactor; - const double loValue = value() - halfIntv; - const double hiValue = value() + halfIntv; - const double tickWidth = 360.0 / double( m_data->tickCount ) / cnvFactor; - const double sinArc = qFastSin( m_data->viewAngle * M_PI / 360.0 ); - - if ( m_data->orientation == Qt::Horizontal ) + // draw tick marks + for (double tickValue = std::ceil(loValue / tickWidth) * tickWidth; + tickValue < hiValue; tickValue += tickWidth) { - const double radius = rect.width() * 0.5; + const double angle = qwtRadians(tickValue - value()); + const double s = qFastSin(angle * cnvFactor); - double l1 = rect.top() + m_data->wheelBorderWidth; - double l2 = rect.bottom() - m_data->wheelBorderWidth - 1; + const double off = radius * (sinArc + s) / sinArc; - // draw one point over the border if border > 1 - if ( m_data->wheelBorderWidth > 1 ) - { - l1--; - l2++; - } + double tickPos; + if (m_data->inverted) + tickPos = rect.left() + off; + else + tickPos = rect.right() - off; - const double maxpos = rect.right() - 2; - const double minpos = rect.left() + 2; - - // draw tick marks - for ( double tickValue = std::ceil( loValue / tickWidth ) * tickWidth; - tickValue < hiValue; tickValue += tickWidth ) - { - const double angle = qwtRadians( tickValue - value() ); - const double s = qFastSin( angle * cnvFactor ); - - const double off = radius * ( sinArc + s ) / sinArc; - - double tickPos; - if ( m_data->inverted ) - tickPos = rect.left() + off; - else - tickPos = rect.right() - off; - - if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) ) - { - painter->setPen( darkPen ); - painter->drawLine( QPointF( tickPos - 1, l1 ), - QPointF( tickPos - 1, l2 ) ); - painter->setPen( lightPen ); - painter->drawLine( QPointF( tickPos, l1 ), - QPointF( tickPos, l2 ) ); - } - } + if ((tickPos <= maxpos) && (tickPos > minpos)) + { + painter->setPen(darkPen); + painter->drawLine(QPointF(tickPos - 1, l1), QPointF(tickPos - 1, l2)); + painter->setPen(lightPen); + painter->drawLine(QPointF(tickPos, l1), QPointF(tickPos, l2)); + } } - else // Qt::Vertical + } + else // Qt::Vertical + { + const double radius = rect.height() * 0.5; + + double l1 = rect.left() + m_data->wheelBorderWidth; + double l2 = rect.right() - m_data->wheelBorderWidth - 1; + + if (m_data->wheelBorderWidth > 1) { - const double radius = rect.height() * 0.5; - - double l1 = rect.left() + m_data->wheelBorderWidth; - double l2 = rect.right() - m_data->wheelBorderWidth - 1; - - if ( m_data->wheelBorderWidth > 1 ) - { - l1--; - l2++; - } - - const double maxpos = rect.bottom() - 2; - const double minpos = rect.top() + 2; - - for ( double tickValue = std::ceil( loValue / tickWidth ) * tickWidth; - tickValue < hiValue; tickValue += tickWidth ) - { - const double angle = qwtRadians( tickValue - value() ); - const double s = qFastSin( angle * cnvFactor ); - - const double off = radius * ( sinArc + s ) / sinArc; - - double tickPos; - - if ( m_data->inverted ) - tickPos = rect.bottom() - off; - else - tickPos = rect.top() + off; - - if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) ) - { - painter->setPen( darkPen ); - painter->drawLine( QPointF( l1, tickPos - 1 ), - QPointF( l2, tickPos - 1 ) ); - painter->setPen( lightPen ); - painter->drawLine( QPointF( l1, tickPos ), - QPointF( l2, tickPos ) ); - } - } + l1--; + l2++; } + + const double maxpos = rect.bottom() - 2; + const double minpos = rect.top() + 2; + + for (double tickValue = std::ceil(loValue / tickWidth) * tickWidth; + tickValue < hiValue; tickValue += tickWidth) + { + const double angle = qwtRadians(tickValue - value()); + const double s = qFastSin(angle * cnvFactor); + + const double off = radius * (sinArc + s) / sinArc; + + double tickPos; + + if (m_data->inverted) + tickPos = rect.bottom() - off; + else + tickPos = rect.top() + off; + + if ((tickPos <= maxpos) && (tickPos > minpos)) + { + painter->setPen(darkPen); + painter->drawLine(QPointF(l1, tickPos - 1), QPointF(l2, tickPos - 1)); + painter->setPen(lightPen); + painter->drawLine(QPointF(l1, tickPos), QPointF(l2, tickPos)); + } + } + } } /*! @@ -931,10 +919,10 @@ void QwtWheel::drawTicks( QPainter* painter, const QRectF& rect ) \param width the wheel's width \sa wheelWidth() */ -void QwtWheel::setWheelWidth( int width ) +void QwtWheel::setWheelWidth(int width) { - m_data->wheelWidth = width; - update(); + m_data->wheelWidth = width; + update(); } /*! @@ -943,7 +931,7 @@ void QwtWheel::setWheelWidth( int width ) */ int QwtWheel::wheelWidth() const { - return m_data->wheelWidth; + return m_data->wheelWidth; } /*! @@ -951,8 +939,8 @@ int QwtWheel::wheelWidth() const */ QSize QwtWheel::sizeHint() const { - const QSize hint = minimumSizeHint(); - return qwtExpandedToGlobalStrut( hint ); + const QSize hint = minimumSizeHint(); + return qwtExpandedToGlobalStrut(hint); } /*! @@ -961,12 +949,12 @@ QSize QwtWheel::sizeHint() const */ QSize QwtWheel::minimumSizeHint() const { - QSize sz( 3 * m_data->wheelWidth + 2 * m_data->borderWidth, - m_data->wheelWidth + 2 * m_data->borderWidth ); - if ( m_data->orientation != Qt::Horizontal ) - sz.transpose(); + QSize sz(3 * m_data->wheelWidth + 2 * m_data->borderWidth, + m_data->wheelWidth + 2 * m_data->borderWidth); + if (m_data->orientation != Qt::Horizontal) + sz.transpose(); - return sz; + return sz; } /*! @@ -977,9 +965,9 @@ QSize QwtWheel::minimumSizeHint() const \param stepSize Single step size \sa singleStep(), setPageStepCount() */ -void QwtWheel::setSingleStep( double stepSize ) +void QwtWheel::setSingleStep(double stepSize) { - m_data->singleStep = qwtMaxF( stepSize, 0.0 ); + m_data->singleStep = qwtMaxF(stepSize, 0.0); } /*! @@ -988,7 +976,7 @@ void QwtWheel::setSingleStep( double stepSize ) */ double QwtWheel::singleStep() const { - return m_data->singleStep; + return m_data->singleStep; } /*! @@ -1001,12 +989,12 @@ double QwtWheel::singleStep() const \param on On/Off \sa stepAlignment(), setSingleStep() */ -void QwtWheel::setStepAlignment( bool on ) +void QwtWheel::setStepAlignment(bool on) { - if ( on != m_data->stepAlignment ) - { - m_data->stepAlignment = on; - } + if (on != m_data->stepAlignment) + { + m_data->stepAlignment = on; + } } /*! @@ -1015,7 +1003,7 @@ void QwtWheel::setStepAlignment( bool on ) */ bool QwtWheel::stepAlignment() const { - return m_data->stepAlignment; + return m_data->stepAlignment; } /*! @@ -1031,9 +1019,9 @@ bool QwtWheel::stepAlignment() const \param count Multiplicator for the single step size \sa pageStepCount(), setSingleStep() */ -void QwtWheel::setPageStepCount( int count ) +void QwtWheel::setPageStepCount(int count) { - m_data->pageStepCount = qMax( 0, count ); + m_data->pageStepCount = qMax(0, count); } /*! @@ -1042,7 +1030,7 @@ void QwtWheel::setPageStepCount( int count ) */ int QwtWheel::pageStepCount() const { - return m_data->pageStepCount; + return m_data->pageStepCount; } /*! @@ -1056,23 +1044,23 @@ int QwtWheel::pageStepCount() const \sa minimum(), maximum() */ -void QwtWheel::setRange( double min, double max ) +void QwtWheel::setRange(double min, double max) { - max = qwtMaxF( min, max ); + max = qwtMaxF(min, max); - if ( m_data->minimum == min && m_data->maximum == max ) - return; + if (m_data->minimum == min && m_data->maximum == max) + return; - m_data->minimum = min; - m_data->maximum = max; + m_data->minimum = min; + m_data->maximum = max; - if ( m_data->value < min || m_data->value > max ) - { - m_data->value = qBound( min, m_data->value, max ); + if (m_data->value < min || m_data->value > max) + { + m_data->value = qBound(min, m_data->value, max); - update(); - Q_EMIT valueChanged( m_data->value ); - } + update(); + Q_EMIT valueChanged(m_data->value); + } } /*! Set the minimum value of the range @@ -1080,11 +1068,12 @@ void QwtWheel::setRange( double min, double max ) \param value Minimum value \sa setRange(), setMaximum(), minimum() - \note The maximum is adjusted if necessary to ensure that the range remains valid. + \note The maximum is adjusted if necessary to ensure that the range remains + valid. */ -void QwtWheel::setMinimum( double value ) +void QwtWheel::setMinimum(double value) { - setRange( value, maximum() ); + setRange(value, maximum()); } /*! @@ -1093,7 +1082,7 @@ void QwtWheel::setMinimum( double value ) */ double QwtWheel::minimum() const { - return m_data->minimum; + return m_data->minimum; } /*! @@ -1102,9 +1091,9 @@ double QwtWheel::minimum() const \param value Maximum value \sa setRange(), setMinimum(), maximum() */ -void QwtWheel::setMaximum( double value ) +void QwtWheel::setMaximum(double value) { - setRange( minimum(), value ); + setRange(minimum(), value); } /*! @@ -1113,7 +1102,7 @@ void QwtWheel::setMaximum( double value ) */ double QwtWheel::maximum() const { - return m_data->maximum; + return m_data->maximum; } /*! @@ -1124,20 +1113,20 @@ double QwtWheel::maximum() const \sa value(), valueChanged() \warning The value is clipped when it lies outside the range. */ -void QwtWheel::setValue( double value ) +void QwtWheel::setValue(double value) { - stopFlying(); - m_data->isScrolling = false; + stopFlying(); + m_data->isScrolling = false; - value = qBound( m_data->minimum, value, m_data->maximum ); + value = qBound(m_data->minimum, value, m_data->maximum); - if ( m_data->value != value ) - { - m_data->value = value; + if (m_data->value != value) + { + m_data->value = value; - update(); - Q_EMIT valueChanged( m_data->value ); - } + update(); + Q_EMIT valueChanged(m_data->value); + } } /*! @@ -1146,7 +1135,7 @@ void QwtWheel::setValue( double value ) */ double QwtWheel::value() const { - return m_data->value; + return m_data->value; } /*! @@ -1160,13 +1149,13 @@ double QwtWheel::value() const \sa isInverted() */ -void QwtWheel::setInverted( bool on ) +void QwtWheel::setInverted(bool on) { - if ( m_data->inverted != on ) - { - m_data->inverted = on; - update(); - } + if (m_data->inverted != on) + { + m_data->inverted = on; + update(); + } } /*! @@ -1175,7 +1164,7 @@ void QwtWheel::setInverted( bool on ) */ bool QwtWheel::isInverted() const { - return m_data->inverted; + return m_data->inverted; } /*! @@ -1187,9 +1176,9 @@ bool QwtWheel::isInverted() const \param on En/Disable wrapping \sa wrapping() */ -void QwtWheel::setWrapping( bool on ) +void QwtWheel::setWrapping(bool on) { - m_data->wrapping = on; + m_data->wrapping = on; } /*! @@ -1198,7 +1187,7 @@ void QwtWheel::setWrapping( bool on ) */ bool QwtWheel::wrapping() const { - return m_data->wrapping; + return m_data->wrapping; } /*! @@ -1218,19 +1207,19 @@ bool QwtWheel::wrapping() const The maximal mass is limited to 100kg. \sa mass() */ -void QwtWheel::setMass( double mass ) +void QwtWheel::setMass(double mass) { - if ( mass < 0.001 ) - { - m_data->mass = 0.0; - } - else - { - m_data->mass = qwtMinF( 100.0, mass ); - } + if (mass < 0.001) + { + m_data->mass = 0.0; + } + else + { + m_data->mass = qwtMinF(100.0, mass); + } - if ( m_data->mass <= 0.0 ) - stopFlying(); + if (m_data->mass <= 0.0) + stopFlying(); } /*! @@ -1239,70 +1228,70 @@ void QwtWheel::setMass( double mass ) */ double QwtWheel::mass() const { - return m_data->mass; + return m_data->mass; } //! Stop the flying movement of the wheel void QwtWheel::stopFlying() { - if ( m_data->timerId != 0 ) - { - killTimer( m_data->timerId ); - m_data->timerId = 0; - m_data->speed = 0.0; - } + if (m_data->timerId != 0) + { + killTimer(m_data->timerId); + m_data->timerId = 0; + m_data->speed = 0.0; + } } -double QwtWheel::boundedValue( double value ) const +double QwtWheel::boundedValue(double value) const { - const double range = m_data->maximum - m_data->minimum; + const double range = m_data->maximum - m_data->minimum; - if ( m_data->wrapping && range >= 0.0 ) + if (m_data->wrapping && range >= 0.0) + { + if (value < m_data->minimum) { - if ( value < m_data->minimum ) - { - value += std::ceil( ( m_data->minimum - value ) / range ) * range; - } - else if ( value > m_data->maximum ) - { - value -= std::ceil( ( value - m_data->maximum ) / range ) * range; - } + value += std::ceil((m_data->minimum - value) / range) * range; } - else + else if (value > m_data->maximum) { - value = qBound( m_data->minimum, value, m_data->maximum ); + value -= std::ceil((value - m_data->maximum) / range) * range; } + } + else + { + value = qBound(m_data->minimum, value, m_data->maximum); + } - return value; + return value; } -double QwtWheel::alignedValue( double value ) const +double QwtWheel::alignedValue(double value) const { - const double stepSize = m_data->singleStep; + const double stepSize = m_data->singleStep; - if ( stepSize > 0.0 ) + if (stepSize > 0.0) + { + value = m_data->minimum + + qRound((value - m_data->minimum) / stepSize) * stepSize; + + if (stepSize > 1e-12) { - value = m_data->minimum + - qRound( ( value - m_data->minimum ) / stepSize ) * stepSize; - - if ( stepSize > 1e-12 ) - { - if ( qFuzzyCompare( value + 1.0, 1.0 ) ) - { - // correct rounding error if value = 0 - value = 0.0; - } - else if ( qFuzzyCompare( value, m_data->maximum ) ) - { - // correct rounding error at the border - value = m_data->maximum; - } - } + if (qFuzzyCompare(value + 1.0, 1.0)) + { + // correct rounding error if value = 0 + value = 0.0; + } + else if (qFuzzyCompare(value, m_data->maximum)) + { + // correct rounding error at the border + value = m_data->maximum; + } } + } - return value; + return value; } #if QWT_MOC_INCLUDE -#include "moc_qwt_wheel.cpp" +# include "moc_qwt_wheel.cpp" #endif diff --git a/libs/qwt/src/qwt_wheel.h b/libs/qwt/src/qwt_wheel.h index 5dcffe30..3be2d0e1 100644 --- a/libs/qwt/src/qwt_wheel.h +++ b/libs/qwt/src/qwt_wheel.h @@ -26,154 +26,155 @@ */ class QWT_EXPORT QwtWheel : public QWidget { - Q_OBJECT + Q_OBJECT - Q_PROPERTY( Qt::Orientation orientation - READ orientation WRITE setOrientation ) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY( double value READ value WRITE setValue NOTIFY valueChanged USER true ) + Q_PROPERTY( + double value READ value WRITE setValue NOTIFY valueChanged USER true) - Q_PROPERTY( double minimum READ minimum WRITE setMinimum ) - Q_PROPERTY( double maximum READ maximum WRITE setMaximum ) + Q_PROPERTY(double minimum READ minimum WRITE setMinimum) + Q_PROPERTY(double maximum READ maximum WRITE setMaximum) - Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep ) - Q_PROPERTY( int pageStepCount READ pageStepCount WRITE setPageStepCount ) - Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment ) + Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep) + Q_PROPERTY(int pageStepCount READ pageStepCount WRITE setPageStepCount) + Q_PROPERTY(bool stepAlignment READ stepAlignment WRITE setStepAlignment) - Q_PROPERTY( bool tracking READ isTracking WRITE setTracking ) - Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping ) - Q_PROPERTY( bool inverted READ isInverted WRITE setInverted ) + Q_PROPERTY(bool tracking READ isTracking WRITE setTracking) + Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping) + Q_PROPERTY(bool inverted READ isInverted WRITE setInverted) - Q_PROPERTY( double mass READ mass WRITE setMass ) - Q_PROPERTY( int updateInterval READ updateInterval WRITE setUpdateInterval ) + Q_PROPERTY(double mass READ mass WRITE setMass) + Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval) - Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle ) - Q_PROPERTY( double viewAngle READ viewAngle WRITE setViewAngle ) - Q_PROPERTY( int tickCount READ tickCount WRITE setTickCount ) - Q_PROPERTY( int wheelWidth READ wheelWidth WRITE setWheelWidth ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) - Q_PROPERTY( int wheelBorderWidth READ wheelBorderWidth WRITE setWheelBorderWidth ) + Q_PROPERTY(double totalAngle READ totalAngle WRITE setTotalAngle) + Q_PROPERTY(double viewAngle READ viewAngle WRITE setViewAngle) + Q_PROPERTY(int tickCount READ tickCount WRITE setTickCount) + Q_PROPERTY(int wheelWidth READ wheelWidth WRITE setWheelWidth) + Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) + Q_PROPERTY( + int wheelBorderWidth READ wheelBorderWidth WRITE setWheelBorderWidth) - public: - explicit QwtWheel( QWidget* parent = NULL ); - virtual ~QwtWheel(); +public: + explicit QwtWheel(QWidget *parent = NULL); + virtual ~QwtWheel(); - double value() const; + double value() const; - void setOrientation( Qt::Orientation ); - Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation); + Qt::Orientation orientation() const; - double totalAngle() const; - double viewAngle() const; + double totalAngle() const; + double viewAngle() const; - void setTickCount( int ); - int tickCount() const; + void setTickCount(int); + int tickCount() const; - void setWheelWidth( int ); - int wheelWidth() const; + void setWheelWidth(int); + int wheelWidth() const; - void setWheelBorderWidth( int ); - int wheelBorderWidth() const; + void setWheelBorderWidth(int); + int wheelBorderWidth() const; - void setBorderWidth( int ); - int borderWidth() const; + void setBorderWidth(int); + int borderWidth() const; - void setInverted( bool ); - bool isInverted() const; + void setInverted(bool); + bool isInverted() const; - void setWrapping( bool ); - bool wrapping() const; + void setWrapping(bool); + bool wrapping() const; - void setSingleStep( double ); - double singleStep() const; + void setSingleStep(double); + double singleStep() const; - void setPageStepCount( int ); - int pageStepCount() const; + void setPageStepCount(int); + int pageStepCount() const; - void setStepAlignment( bool on ); - bool stepAlignment() const; + void setStepAlignment(bool on); + bool stepAlignment() const; - void setRange( double min, double max ); + void setRange(double min, double max); - void setMinimum( double ); - double minimum() const; + void setMinimum(double); + double minimum() const; - void setMaximum( double ); - double maximum() const; + void setMaximum(double); + double maximum() const; - void setUpdateInterval( int ); - int updateInterval() const; + void setUpdateInterval(int); + int updateInterval() const; - void setTracking( bool ); - bool isTracking() const; + void setTracking(bool); + bool isTracking() const; - double mass() const; + double mass() const; - public Q_SLOTS: - void setValue( double ); - void setTotalAngle ( double ); - void setViewAngle( double ); - void setMass( double ); +public Q_SLOTS: + void setValue(double); + void setTotalAngle(double); + void setViewAngle(double); + void setMass(double); - Q_SIGNALS: +Q_SIGNALS: - /*! - \brief Notify a change of value. + /*! + \brief Notify a change of value. - When tracking is enabled this signal will be emitted every - time the value changes. + When tracking is enabled this signal will be emitted every + time the value changes. - \param value new value - \sa setTracking() - */ - void valueChanged( double value ); + \param value new value + \sa setTracking() + */ + void valueChanged(double value); - /*! - This signal is emitted when the user presses the - the wheel with the mouse - */ - void wheelPressed(); + /*! + This signal is emitted when the user presses the + the wheel with the mouse + */ + void wheelPressed(); - /*! - This signal is emitted when the user releases the mouse - */ - void wheelReleased(); + /*! + This signal is emitted when the user releases the mouse + */ + void wheelReleased(); - /*! - This signal is emitted when the user moves the - wheel with the mouse. + /*! + This signal is emitted when the user moves the + wheel with the mouse. - \param value new value - */ - void wheelMoved( double value ); + \param value new value + */ + void wheelMoved(double value); - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void mousePressEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void mouseReleaseEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void mouseMoveEvent( QMouseEvent* ) QWT_OVERRIDE; - virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE; - virtual void wheelEvent( QWheelEvent* ) QWT_OVERRIDE; - virtual void timerEvent( QTimerEvent* ) QWT_OVERRIDE; +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *) QWT_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *) QWT_OVERRIDE; + virtual void wheelEvent(QWheelEvent *) QWT_OVERRIDE; + virtual void timerEvent(QTimerEvent *) QWT_OVERRIDE; - void stopFlying(); + void stopFlying(); - QRect wheelRect() const; + QRect wheelRect() const; - virtual QSize sizeHint() const QWT_OVERRIDE; - virtual QSize minimumSizeHint() const QWT_OVERRIDE; + virtual QSize sizeHint() const QWT_OVERRIDE; + virtual QSize minimumSizeHint() const QWT_OVERRIDE; - virtual void drawTicks( QPainter*, const QRectF& ); - virtual void drawWheelBackground( QPainter*, const QRectF& ); + virtual void drawTicks(QPainter *, const QRectF &); + virtual void drawWheelBackground(QPainter *, const QRectF &); - virtual double valueAt( const QPoint& ) const; + virtual double valueAt(const QPoint &) const; - private: - double alignedValue( double ) const; - double boundedValue( double ) const; +private: + double alignedValue(double) const; + double boundedValue(double) const; - class PrivateData; - PrivateData* m_data; + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/libs/qwt/src/qwt_widget_overlay.cpp b/libs/qwt/src/qwt_widget_overlay.cpp index 5967fb13..55b95531 100644 --- a/libs/qwt/src/qwt_widget_overlay.cpp +++ b/libs/qwt/src/qwt_widget_overlay.cpp @@ -20,129 +20,124 @@ static QImage::Format qwtMaskImageFormat() { - if ( QwtPainter::isX11GraphicsSystem() ) - return QImage::Format_ARGB32; + if (QwtPainter::isX11GraphicsSystem()) + return QImage::Format_ARGB32; - return QImage::Format_ARGB32_Premultiplied; + return QImage::Format_ARGB32_Premultiplied; } -static QRegion qwtAlphaMask( const QImage& image, const QRegion& region ) +static QRegion qwtAlphaMask(const QImage &image, const QRegion ®ion) { - const int w = image.width(); - const int h = image.height(); + const int w = image.width(); + const int h = image.height(); - QRegion mask; - QRect rect; + QRegion mask; + QRect rect; #if QT_VERSION >= 0x050800 - for ( QRegion::const_iterator it = region.cbegin(); - it != region.cend(); ++it ) - { - const QRect& r = *it; + for (QRegion::const_iterator it = region.cbegin(); it != region.cend(); ++it) + { + const QRect &r = *it; #else - const QVector< QRect > rects = region.rects(); - for ( int i = 0; i < rects.size(); i++ ) - { - const QRect& r = rects[i]; + const QVector rects = region.rects(); + for (int i = 0; i < rects.size(); i++) + { + const QRect &r = rects[i]; #endif - int x1, x2, y1, y2; - r.getCoords( &x1, &y1, &x2, &y2 ); + int x1, x2, y1, y2; + r.getCoords(&x1, &y1, &x2, &y2); - x1 = qMax( x1, 0 ); - x2 = qMin( x2, w - 1 ); - y1 = qMax( y1, 0 ); - y2 = qMin( y2, h - 1 ); + x1 = qMax(x1, 0); + x2 = qMin(x2, w - 1); + y1 = qMax(y1, 0); + y2 = qMin(y2, h - 1); - for ( int y = y1; y <= y2; ++y ) + for (int y = y1; y <= y2; ++y) + { + bool inRect = false; + int rx0 = -1; + + const uint *line = reinterpret_cast(image.scanLine(y)) + x1; + for (int x = x1; x <= x2; x++) + { + const bool on = ((*line++ >> 24) != 0); + if (on != inRect) { - bool inRect = false; - int rx0 = -1; + if (inRect) + { + rect.setCoords(rx0, y, x - 1, y); + mask += rect; + } + else + { + rx0 = x; + } - const uint* line = - reinterpret_cast< const uint* > ( image.scanLine( y ) ) + x1; - for ( int x = x1; x <= x2; x++ ) - { - const bool on = ( ( *line++ >> 24 ) != 0 ); - if ( on != inRect ) - { - if ( inRect ) - { - rect.setCoords( rx0, y, x - 1, y ); - mask += rect; - } - else - { - rx0 = x; - } - - inRect = on; - } - } - - if ( inRect ) - { - rect.setCoords( rx0, y, x2, y ); - mask = mask.united( rect ); - } + inRect = on; } - } + } - return mask; + if (inRect) + { + rect.setCoords(rx0, y, x2, y); + mask = mask.united(rect); + } + } + } + + return mask; } class QwtWidgetOverlay::PrivateData { - public: - PrivateData() - : maskMode( QwtWidgetOverlay::MaskHint ) - , renderMode( QwtWidgetOverlay::AutoRenderMode ) - , rgbaBuffer( NULL ) - { - } +public: + PrivateData() + : maskMode(QwtWidgetOverlay::MaskHint) + , renderMode(QwtWidgetOverlay::AutoRenderMode) + , rgbaBuffer(NULL) + { + } - ~PrivateData() - { - resetRgbaBuffer(); - } + ~PrivateData() { resetRgbaBuffer(); } - void resetRgbaBuffer() + void resetRgbaBuffer() + { + if (rgbaBuffer) { - if ( rgbaBuffer ) - { - std::free( rgbaBuffer ); - rgbaBuffer = NULL; - } + std::free(rgbaBuffer); + rgbaBuffer = NULL; } + } - MaskMode maskMode; - RenderMode renderMode; - uchar* rgbaBuffer; + MaskMode maskMode; + RenderMode renderMode; + uchar *rgbaBuffer; }; /*! \brief Constructor \param widget Parent widget, where the overlay is aligned to */ -QwtWidgetOverlay::QwtWidgetOverlay( QWidget* widget ) - : QWidget( widget ) +QwtWidgetOverlay::QwtWidgetOverlay(QWidget *widget) + : QWidget(widget) { - m_data = new PrivateData; + m_data = new PrivateData; - setAttribute( Qt::WA_TransparentForMouseEvents ); - setAttribute( Qt::WA_NoSystemBackground ); - setFocusPolicy( Qt::NoFocus ); + setAttribute(Qt::WA_TransparentForMouseEvents); + setAttribute(Qt::WA_NoSystemBackground); + setFocusPolicy(Qt::NoFocus); - if ( widget ) - { - resize( widget->size() ); - widget->installEventFilter( this ); - } + if (widget) + { + resize(widget->size()); + widget->installEventFilter(this); + } } //! Destructor QwtWidgetOverlay::~QwtWidgetOverlay() { - delete m_data; + delete m_data; } /*! @@ -151,13 +146,13 @@ QwtWidgetOverlay::~QwtWidgetOverlay() \param mode New mode \sa maskMode() */ -void QwtWidgetOverlay::setMaskMode( MaskMode mode ) +void QwtWidgetOverlay::setMaskMode(MaskMode mode) { - if ( mode != m_data->maskMode ) - { - m_data->maskMode = mode; - m_data->resetRgbaBuffer(); - } + if (mode != m_data->maskMode) + { + m_data->maskMode = mode; + m_data->resetRgbaBuffer(); + } } /*! @@ -166,7 +161,7 @@ void QwtWidgetOverlay::setMaskMode( MaskMode mode ) */ QwtWidgetOverlay::MaskMode QwtWidgetOverlay::maskMode() const { - return m_data->maskMode; + return m_data->maskMode; } /*! @@ -175,9 +170,9 @@ QwtWidgetOverlay::MaskMode QwtWidgetOverlay::maskMode() const \sa RenderMode, renderMode() */ -void QwtWidgetOverlay::setRenderMode( RenderMode mode ) +void QwtWidgetOverlay::setRenderMode(RenderMode mode) { - m_data->renderMode = mode; + m_data->renderMode = mode; } /*! @@ -186,7 +181,7 @@ void QwtWidgetOverlay::setRenderMode( RenderMode mode ) */ QwtWidgetOverlay::RenderMode QwtWidgetOverlay::renderMode() const { - return m_data->renderMode; + return m_data->renderMode; } /*! @@ -194,63 +189,62 @@ QwtWidgetOverlay::RenderMode QwtWidgetOverlay::renderMode() const */ void QwtWidgetOverlay::updateOverlay() { - updateMask(); - update(); + updateMask(); + update(); } void QwtWidgetOverlay::updateMask() { - m_data->resetRgbaBuffer(); + m_data->resetRgbaBuffer(); - QRegion mask; + QRegion mask; - if ( m_data->maskMode == QwtWidgetOverlay::MaskHint ) + if (m_data->maskMode == QwtWidgetOverlay::MaskHint) + { + mask = maskHint(); + } + else if (m_data->maskMode == QwtWidgetOverlay::AlphaMask) + { + // TODO: the image doesn't need to be larger than + // the bounding rectangle of the hint !! + + QRegion hint = maskHint(); + if (hint.isEmpty()) + hint += QRect(0, 0, width(), height()); + + // A fresh buffer from calloc() is usually faster + // than reinitializing an existing one with + // QImage::fill( 0 ) or memset() + size_t w = static_cast(width()); + size_t h = static_cast(width()); + m_data->rgbaBuffer = (uchar *)::calloc(w * h, 4); + + QImage image(m_data->rgbaBuffer, width(), height(), qwtMaskImageFormat()); + + QPainter painter(&image); + draw(&painter); + painter.end(); + + mask = qwtAlphaMask(image, hint); + + if (m_data->renderMode == QwtWidgetOverlay::DrawOverlay) { - mask = maskHint(); + // we don't need the buffer later + m_data->resetRgbaBuffer(); } - else if ( m_data->maskMode == QwtWidgetOverlay::AlphaMask ) - { - // TODO: the image doesn't need to be larger than - // the bounding rectangle of the hint !! + } - QRegion hint = maskHint(); - if ( hint.isEmpty() ) - hint += QRect( 0, 0, width(), height() ); + // A bug in Qt initiates a full repaint of the widget + // when we change the mask, while we are visible ! - // A fresh buffer from calloc() is usually faster - // than reinitializing an existing one with - // QImage::fill( 0 ) or memset() - size_t w = static_cast(width()); - size_t h = static_cast(width()); - m_data->rgbaBuffer = ( uchar* )::calloc( w * h, 4 ); + setVisible(false); - QImage image( m_data->rgbaBuffer, - width(), height(), qwtMaskImageFormat() ); + if (mask.isEmpty()) + clearMask(); + else + setMask(mask); - QPainter painter( &image ); - draw( &painter ); - painter.end(); - - mask = qwtAlphaMask( image, hint ); - - if ( m_data->renderMode == QwtWidgetOverlay::DrawOverlay ) - { - // we don't need the buffer later - m_data->resetRgbaBuffer(); - } - } - - // A bug in Qt initiates a full repaint of the widget - // when we change the mask, while we are visible ! - - setVisible( false ); - - if ( mask.isEmpty() ) - clearMask(); - else - setMask( mask ); - - setVisible( true ); + setVisible(true); } /*! @@ -259,98 +253,98 @@ void QwtWidgetOverlay::updateMask() \sa drawOverlay() */ -void QwtWidgetOverlay::paintEvent( QPaintEvent* event ) +void QwtWidgetOverlay::paintEvent(QPaintEvent *event) { - const QRegion& clipRegion = event->region(); + const QRegion &clipRegion = event->region(); - QPainter painter( this ); + QPainter painter(this); - bool useRgbaBuffer = false; - if ( m_data->renderMode == QwtWidgetOverlay::CopyAlphaMask ) + bool useRgbaBuffer = false; + if (m_data->renderMode == QwtWidgetOverlay::CopyAlphaMask) + { + useRgbaBuffer = true; + } + else if (m_data->renderMode == QwtWidgetOverlay::AutoRenderMode) + { + if (painter.paintEngine()->type() == QPaintEngine::Raster) + useRgbaBuffer = true; + } + + if (m_data->rgbaBuffer && useRgbaBuffer) + { + const QImage image(m_data->rgbaBuffer, width(), height(), + qwtMaskImageFormat()); + + const int rectCount = clipRegion.rectCount(); + + if (rectCount > 2000) { - useRgbaBuffer = true; - } - else if ( m_data->renderMode == QwtWidgetOverlay::AutoRenderMode ) - { - if ( painter.paintEngine()->type() == QPaintEngine::Raster ) - useRgbaBuffer = true; - } + // the region is to complex + painter.setClipRegion(clipRegion); - if ( m_data->rgbaBuffer && useRgbaBuffer ) - { - const QImage image( m_data->rgbaBuffer, - width(), height(), qwtMaskImageFormat() ); - - const int rectCount = clipRegion.rectCount(); - - if ( rectCount > 2000 ) - { - // the region is to complex - painter.setClipRegion( clipRegion ); - - const QRect r = clipRegion.boundingRect(); - painter.drawImage( r.topLeft(), image, r ); - } - else - { -#if QT_VERSION >= 0x050800 - for ( QRegion::const_iterator it = clipRegion.cbegin(); - it != clipRegion.cend(); ++it ) - { - const QRect& r = *it; - painter.drawImage( r.topLeft(), image, r ); - } -#else - const QVector< QRect > rects = clipRegion.rects(); - for ( int i = 0; i < rects.size(); i++ ) - { - const QRect& r = rects[i]; - painter.drawImage( r.topLeft(), image, r ); - } -#endif - } + const QRect r = clipRegion.boundingRect(); + painter.drawImage(r.topLeft(), image, r); } else { - painter.setClipRegion( clipRegion ); - draw( &painter ); +#if QT_VERSION >= 0x050800 + for (QRegion::const_iterator it = clipRegion.cbegin(); + it != clipRegion.cend(); ++it) + { + const QRect &r = *it; + painter.drawImage(r.topLeft(), image, r); + } +#else + const QVector rects = clipRegion.rects(); + for (int i = 0; i < rects.size(); i++) + { + const QRect &r = rects[i]; + painter.drawImage(r.topLeft(), image, r); + } +#endif } + } + else + { + painter.setClipRegion(clipRegion); + draw(&painter); + } } /*! Resize event \param event Resize event */ -void QwtWidgetOverlay::resizeEvent( QResizeEvent* event ) +void QwtWidgetOverlay::resizeEvent(QResizeEvent *event) { - Q_UNUSED( event ); + Q_UNUSED(event); - m_data->resetRgbaBuffer(); + m_data->resetRgbaBuffer(); } -void QwtWidgetOverlay::draw( QPainter* painter ) const +void QwtWidgetOverlay::draw(QPainter *painter) const { - if ( QWidget* widget = parentWidget() ) + if (QWidget *widget = parentWidget()) + { + painter->setClipRect(widget->contentsRect()); + + // something special for the plot canvas + + const int idx = widget->metaObject()->indexOfMethod("borderPath(QRect)"); + if (idx >= 0) { - painter->setClipRect( widget->contentsRect() ); + QPainterPath clipPath; - // something special for the plot canvas + (void)QMetaObject::invokeMethod( + widget, "borderPath", Qt::DirectConnection, + Q_RETURN_ARG(QPainterPath, clipPath), Q_ARG(QRect, rect())); - const int idx = widget->metaObject()->indexOfMethod( "borderPath(QRect)" ); - if ( idx >= 0 ) - { - QPainterPath clipPath; - - ( void )QMetaObject::invokeMethod( - widget, "borderPath", Qt::DirectConnection, - Q_RETURN_ARG( QPainterPath, clipPath ), Q_ARG( QRect, rect() ) ); - - if (!clipPath.isEmpty() ) - painter->setClipPath( clipPath, Qt::IntersectClip ); - } + if (!clipPath.isEmpty()) + painter->setClipPath(clipPath, Qt::IntersectClip); } + } - drawOverlay( painter ); + drawOverlay(painter); } /*! @@ -373,7 +367,7 @@ void QwtWidgetOverlay::draw( QPainter* painter ) const */ QRegion QwtWidgetOverlay::maskHint() const { - return QRegion(); + return QRegion(); } /*! @@ -387,13 +381,13 @@ QRegion QwtWidgetOverlay::maskHint() const \return See QObject::eventFilter() */ -bool QwtWidgetOverlay::eventFilter( QObject* object, QEvent* event ) +bool QwtWidgetOverlay::eventFilter(QObject *object, QEvent *event) { - if ( object == parent() && event->type() == QEvent::Resize ) - { - QResizeEvent* resizeEvent = static_cast< QResizeEvent* >( event ); - resize( resizeEvent->size() ); - } + if (object == parent() && event->type() == QEvent::Resize) + { + QResizeEvent *resizeEvent = static_cast(event); + resize(resizeEvent->size()); + } - return QObject::eventFilter( object, event ); + return QObject::eventFilter(object, event); } diff --git a/libs/qwt/src/qwt_widget_overlay.h b/libs/qwt/src/qwt_widget_overlay.h index e03c946b..50c21b7d 100644 --- a/libs/qwt/src/qwt_widget_overlay.h +++ b/libs/qwt/src/qwt_widget_overlay.h @@ -39,111 +39,111 @@ class QRegion; */ class QWT_EXPORT QwtWidgetOverlay : public QWidget { - public: - /*! - \brief Mask mode +public: + /*! + \brief Mask mode - When using masks the widget below gets paint events for - the masked regions of the overlay only. Otherwise - Qt triggers full repaints. On less powerful hardware - ( f.e embedded systems ) - or when using the raster paint - engine on a remote desktop - bit blitting is a noticeable - operation, that needs to be avoided. + When using masks the widget below gets paint events for + the masked regions of the overlay only. Otherwise + Qt triggers full repaints. On less powerful hardware + ( f.e embedded systems ) - or when using the raster paint + engine on a remote desktop - bit blitting is a noticeable + operation, that needs to be avoided. - If and how to mask depends on how expensive the calculation - of the mask is and how many pixels can be excluded by the mask. + If and how to mask depends on how expensive the calculation + of the mask is and how many pixels can be excluded by the mask. - The default setting is MaskHint. + The default setting is MaskHint. - \sa setMaskMode(), maskMode() - */ - enum MaskMode - { - //! Don't use a mask. - NoMask, - - /*! - \brief Use maskHint() as mask - - For many situations a fast approximation is good enough - and it is not necessary to build a more detailed mask - ( f.e the bounding rectangle of a text ). - */ - MaskHint, - - /*! - \brief Calculate a mask by checking the alpha values - - Sometimes it is not possible to give a fast approximation - and the mask needs to be calculated by drawing the overlay - and testing the result. - - When a valid maskHint() is available - only pixels inside this approximation are checked. - */ - AlphaMask - }; + \sa setMaskMode(), maskMode() + */ + enum MaskMode + { + //! Don't use a mask. + NoMask, /*! - \brief Render mode + \brief Use maskHint() as mask - For calculating the alpha mask the overlay has already - been painted to a temporary QImage. Instead of rendering - the overlay twice this buffer can be copied for drawing - the overlay. - - On graphic systems using the raster paint engine ( QWS, Windows ) - it means usually copying some memory only. On X11 it results in an - expensive operation building a pixmap and for simple overlays - it might not be recommended. - - \note The render mode has no effect, when maskMode() != AlphaMask. + For many situations a fast approximation is good enough + and it is not necessary to build a more detailed mask + ( f.e the bounding rectangle of a text ). */ - enum RenderMode - { - //! Copy the buffer, when using the raster paint engine. - AutoRenderMode, - - //! Always copy the buffer - CopyAlphaMask, - - //! Never copy the buffer - DrawOverlay - }; - - explicit QwtWidgetOverlay( QWidget* ); - virtual ~QwtWidgetOverlay(); - - void setMaskMode( MaskMode ); - MaskMode maskMode() const; - - void setRenderMode( RenderMode ); - RenderMode renderMode() const; - - virtual bool eventFilter( QObject*, QEvent*) QWT_OVERRIDE; - - public Q_SLOTS: - void updateOverlay(); - - protected: - virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE; - virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE; - - virtual QRegion maskHint() const; + MaskHint, /*! - Draw the widget overlay - \param painter Painter + \brief Calculate a mask by checking the alpha values + + Sometimes it is not possible to give a fast approximation + and the mask needs to be calculated by drawing the overlay + and testing the result. + + When a valid maskHint() is available + only pixels inside this approximation are checked. */ - virtual void drawOverlay( QPainter* painter ) const = 0; + AlphaMask + }; - private: - void updateMask(); - void draw( QPainter* ) const; + /*! + \brief Render mode - private: - class PrivateData; - PrivateData* m_data; + For calculating the alpha mask the overlay has already + been painted to a temporary QImage. Instead of rendering + the overlay twice this buffer can be copied for drawing + the overlay. + + On graphic systems using the raster paint engine ( QWS, Windows ) + it means usually copying some memory only. On X11 it results in an + expensive operation building a pixmap and for simple overlays + it might not be recommended. + + \note The render mode has no effect, when maskMode() != AlphaMask. + */ + enum RenderMode + { + //! Copy the buffer, when using the raster paint engine. + AutoRenderMode, + + //! Always copy the buffer + CopyAlphaMask, + + //! Never copy the buffer + DrawOverlay + }; + + explicit QwtWidgetOverlay(QWidget *); + virtual ~QwtWidgetOverlay(); + + void setMaskMode(MaskMode); + MaskMode maskMode() const; + + void setRenderMode(RenderMode); + RenderMode renderMode() const; + + virtual bool eventFilter(QObject *, QEvent *) QWT_OVERRIDE; + +public Q_SLOTS: + void updateOverlay(); + +protected: + virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE; + virtual void resizeEvent(QResizeEvent *) QWT_OVERRIDE; + + virtual QRegion maskHint() const; + + /*! + Draw the widget overlay + \param painter Painter + */ + virtual void drawOverlay(QPainter *painter) const = 0; + +private: + void updateMask(); + void draw(QPainter *) const; + +private: + class PrivateData; + PrivateData *m_data; }; #endif diff --git a/src/AppInfo.h b/src/AppInfo.h index df04dc99..51449557 100644 --- a/src/AppInfo.h +++ b/src/AppInfo.h @@ -23,7 +23,7 @@ #pragma once // clang-format off -#define APP_VERSION "2.0.0" +#define APP_VERSION "2.1.0" #define APP_DEVELOPER "Alex Spataru" #define APP_NAME "Serial Studio" #define APP_SUPPORT_URL "https://github.com/serial-studio" diff --git a/src/CSV/Export.cpp b/src/CSV/Export.cpp index 4c8e9ecf..e4162140 100644 --- a/src/CSV/Export.cpp +++ b/src/CSV/Export.cpp @@ -40,14 +40,14 @@ * dataframes into JSON list. */ CSV::Export::Export() - : m_fieldCount(0) - , m_exportEnabled(true) + : m_fieldCount(0) + , m_exportEnabled(true) { - auto io = &IO::Manager::instance(); - auto te = &Misc::TimerEvents::instance(); - connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile); - connect(io, &IO::Manager::frameReceived, this, &Export::registerFrame); - connect(te, &Misc::TimerEvents::timeout1Hz, this, &Export::writeValues); + auto io = &IO::Manager::instance(); + auto te = &Misc::TimerEvents::instance(); + connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile); + connect(io, &IO::Manager::frameReceived, this, &Export::registerFrame); + connect(te, &Misc::TimerEvents::timeout1Hz, this, &Export::writeValues); } /** @@ -55,7 +55,7 @@ CSV::Export::Export() */ CSV::Export::~Export() { - closeFile(); + closeFile(); } /** @@ -63,8 +63,8 @@ CSV::Export::~Export() */ CSV::Export &CSV::Export::instance() { - static Export singleton; - return singleton; + static Export singleton; + return singleton; } /** @@ -72,7 +72,7 @@ CSV::Export &CSV::Export::instance() */ bool CSV::Export::isOpen() const { - return m_csvFile.isOpen(); + return m_csvFile.isOpen(); } /** @@ -80,7 +80,7 @@ bool CSV::Export::isOpen() const */ bool CSV::Export::exportEnabled() const { - return m_exportEnabled; + return m_exportEnabled; } /** @@ -88,11 +88,11 @@ bool CSV::Export::exportEnabled() const */ void CSV::Export::openCurrentCsv() { - if (isOpen()) - Misc::Utilities::revealFile(m_csvFile.fileName()); - else - Misc::Utilities::showMessageBox(tr("CSV file not open"), - tr("Cannot find CSV export file!")); + if (isOpen()) + Misc::Utilities::revealFile(m_csvFile.fileName()); + else + Misc::Utilities::showMessageBox(tr("CSV file not open"), + tr("Cannot find CSV export file!")); } /** @@ -100,14 +100,14 @@ void CSV::Export::openCurrentCsv() */ void CSV::Export::setExportEnabled(const bool enabled) { - m_exportEnabled = enabled; - Q_EMIT enabledChanged(); + m_exportEnabled = enabled; + Q_EMIT enabledChanged(); - if (!exportEnabled() && isOpen()) - { - m_frames.clear(); - closeFile(); - } + if (!exportEnabled() && isOpen()) + { + m_frames.clear(); + closeFile(); + } } /** @@ -115,17 +115,17 @@ void CSV::Export::setExportEnabled(const bool enabled) */ void CSV::Export::closeFile() { - if (isOpen()) - { - while (!m_frames.isEmpty()) - writeValues(); + if (isOpen()) + { + while (!m_frames.isEmpty()) + writeValues(); - m_fieldCount = 0; - m_csvFile.close(); - m_textStream.setDevice(Q_NULLPTR); + m_fieldCount = 0; + m_csvFile.close(); + m_textStream.setDevice(Q_NULLPTR); - Q_EMIT openChanged(); - } + Q_EMIT openChanged(); + } } /** @@ -134,120 +134,120 @@ void CSV::Export::closeFile() */ void CSV::Export::writeValues() { - // Get separator sequence - auto sep = IO::Manager::instance().separatorSequence(); + // Get separator sequence + auto sep = IO::Manager::instance().separatorSequence(); - // Write each frame - for (auto i = 0; i < m_frames.count(); ++i) + // Write each frame + for (auto i = 0; i < m_frames.count(); ++i) + { + auto frame = m_frames.at(i); + auto fields = QString::fromUtf8(frame.data).split(sep); + + // File not open, create it & add cell titles + if (!isOpen() && exportEnabled()) + createCsvFile(frame); + + // Write RX date/time + m_textStream << frame.rxDateTime.toString("yyyy/MM/dd/ HH:mm:ss::zzz") + << ","; + + // Write frame data + for (auto j = 0; j < fields.count(); ++j) { - auto frame = m_frames.at(i); - auto fields = QString::fromUtf8(frame.data).split(sep); + m_textStream << fields.at(j); + if (j < fields.count() - 1) + m_textStream << ","; - // File not open, create it & add cell titles - if (!isOpen() && exportEnabled()) - createCsvFile(frame); - - // Write RX date/time - m_textStream << frame.rxDateTime.toString("yyyy/MM/dd/ HH:mm:ss::zzz") << ","; - - // Write frame data - for (auto j = 0; j < fields.count(); ++j) + else + { + auto d = m_fieldCount - fields.count(); + if (d > 0) { - m_textStream << fields.at(j); - if (j < fields.count() - 1) - m_textStream << ","; - - else - { - auto d = m_fieldCount - fields.count(); - if (d > 0) - { - for (auto k = 0; k < d - 1; ++k) - m_textStream << ","; - } - - m_textStream << "\n"; - } + for (auto k = 0; k < d - 1; ++k) + m_textStream << ","; } - } - // Clear frames - m_frames.clear(); + m_textStream << "\n"; + } + } + } + + // Clear frames + m_frames.clear(); } /** - * Creates a new CSV file corresponding to the current project title & field count + * Creates a new CSV file corresponding to the current project title & field + * count */ void CSV::Export::createCsvFile(const CSV::RawFrame &frame) { // Get project title - auto projectTitle = UI::Dashboard::instance().title(); + auto projectTitle = UI::Dashboard::instance().title(); - // Get file name - const QString fileName = frame.rxDateTime.toString("HH-mm-ss") + ".csv"; + // Get file name + const QString fileName = frame.rxDateTime.toString("HH-mm-ss") + ".csv"; - // Get path - // clang-format off - const QString format = frame.rxDateTime.toString("yyyy/MMM/dd/"); - const QString path = QString("%1/Documents/%2/CSV/%3/%4").arg(QDir::homePath(), - qApp->applicationName(), - projectTitle, format); - // clang-format on + // Get path + const QString format = frame.rxDateTime.toString("yyyy/MMM/dd/"); + const QString path = QString("%1/Documents/%2/CSV/%3/%4") + .arg(QDir::homePath(), qApp->applicationName(), + projectTitle, format); - // Generate file path if required - QDir dir(path); - if (!dir.exists()) - dir.mkpath("."); + // Generate file path if required + QDir dir(path); + if (!dir.exists()) + dir.mkpath("."); - // Open file - m_csvFile.setFileName(dir.filePath(fileName)); - if (!m_csvFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - Misc::Utilities::showMessageBox(tr("CSV File Error"), - tr("Cannot open CSV file for writing!")); - closeFile(); - return; - } + // Open file + m_csvFile.setFileName(dir.filePath(fileName)); + if (!m_csvFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + Misc::Utilities::showMessageBox(tr("CSV File Error"), + tr("Cannot open CSV file for writing!")); + closeFile(); + return; + } - // Add cell titles & force UTF-8 codec - m_textStream.setDevice(&m_csvFile); - m_textStream.setGenerateByteOrderMark(true); + // Add cell titles & force UTF-8 codec + m_textStream.setDevice(&m_csvFile); + m_textStream.setGenerateByteOrderMark(true); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - m_textStream.setCodec("UTF-8"); + m_textStream.setCodec("UTF-8"); #else - m_textStream.setEncoding(QStringConverter::Utf8); + m_textStream.setEncoding(QStringConverter::Utf8); #endif - // Get number of fields by counting datasets with non-duplicated indexes - QVector fields; - QVector titles; - for (int i = 0; i < Project::Model::instance().groupCount(); ++i) + // Get number of fields by counting datasets with non-duplicated indexes + QVector fields; + QVector titles; + for (int i = 0; i < Project::Model::instance().groupCount(); ++i) + { + for (int j = 0; j < Project::Model::instance().datasetCount(i); ++j) { - for (int j = 0; j < Project::Model::instance().datasetCount(i); ++j) - { - auto dataset = Project::Model::instance().getDataset(i, j); - if (!fields.contains(dataset.index())) - { - fields.append(dataset.index()); - titles.append(dataset.title()); - } - } + auto dataset = Project::Model::instance().getDataset(i, j); + if (!fields.contains(dataset.index())) + { + fields.append(dataset.index()); + titles.append(dataset.title()); + } } + } - // Add table titles - m_fieldCount = fields.count(); - m_textStream << "RX Date/Time,"; - for (auto i = 0; i < m_fieldCount; ++i) - { - m_textStream << titles.at(i) << "(field " << i + 1 << ")"; + // Add table titles + m_fieldCount = fields.count(); + m_textStream << "RX Date/Time,"; + for (auto i = 0; i < m_fieldCount; ++i) + { + m_textStream << titles.at(i) << "(field " << i + 1 << ")"; - if (i < m_fieldCount - 1) - m_textStream << ","; - else - m_textStream << "\n"; - } + if (i < m_fieldCount - 1) + m_textStream << ","; + else + m_textStream << "\n"; + } - // Update UI - Q_EMIT openChanged(); + // Update UI + Q_EMIT openChanged(); } /** @@ -255,26 +255,22 @@ void CSV::Export::createCsvFile(const CSV::RawFrame &frame) */ void CSV::Export::registerFrame(const QByteArray &data) { - // Ignore if device is not connected (we don't want to generate a CSV file when we - // are reading another CSV file don't we?) - if (!IO::Manager::instance().connected()) - return; + // Ignore if device is not connected (we don't want to generate a CSV file + // when we are reading another CSV file don't we?) + if (!IO::Manager::instance().connected()) + return; - // Ignore if current dashboard frame hasn't been loaded yet - if (!UI::Dashboard::instance().currentFrame().isValid()) - return; + // Ignore if current dashboard frame hasn't been loaded yet + if (!UI::Dashboard::instance().currentFrame().isValid()) + return; - // Ignore if CSV export is disabled - if (!exportEnabled()) - return; + // Ignore if CSV export is disabled + if (!exportEnabled()) + return; - // Register raw frame to list - RawFrame frame; - frame.data = data; - frame.rxDateTime = QDateTime::currentDateTime(); - m_frames.append(frame); + // Register raw frame to list + RawFrame frame; + frame.data = data; + frame.rxDateTime = QDateTime::currentDateTime(); + m_frames.append(frame); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Export.cpp" -#endif diff --git a/src/CSV/Export.h b/src/CSV/Export.h index 3859bbd3..9611c9ca 100644 --- a/src/CSV/Export.h +++ b/src/CSV/Export.h @@ -45,13 +45,13 @@ namespace CSV */ typedef struct { - QByteArray data; - QDateTime rxDateTime; + QByteArray data; + QDateTime rxDateTime; } RawFrame; class Export : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(bool isOpen READ isOpen @@ -60,42 +60,42 @@ class Export : public QObject READ exportEnabled WRITE setExportEnabled NOTIFY enabledChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void openChanged(); - void enabledChanged(); + void openChanged(); + void enabledChanged(); private: - explicit Export(); - Export(Export &&) = delete; - Export(const Export &) = delete; - Export &operator=(Export &&) = delete; - Export &operator=(const Export &) = delete; + explicit Export(); + Export(Export &&) = delete; + Export(const Export &) = delete; + Export &operator=(Export &&) = delete; + Export &operator=(const Export &) = delete; - ~Export(); + ~Export(); public: - static Export &instance(); + static Export &instance(); - bool isOpen() const; - bool exportEnabled() const; + bool isOpen() const; + bool exportEnabled() const; public Q_SLOTS: - void closeFile(); - void openCurrentCsv(); - void setExportEnabled(const bool enabled); + void closeFile(); + void openCurrentCsv(); + void setExportEnabled(const bool enabled); private Q_SLOTS: - void writeValues(); - void registerFrame(const QByteArray &data); - void createCsvFile(const CSV::RawFrame &frame); + void writeValues(); + void registerFrame(const QByteArray &data); + void createCsvFile(const CSV::RawFrame &frame); private: - QFile m_csvFile; - int m_fieldCount; - bool m_exportEnabled; - QTextStream m_textStream; - QVector m_frames; + QFile m_csvFile; + int m_fieldCount; + bool m_exportEnabled; + QTextStream m_textStream; + QVector m_frames; }; -} +} // namespace CSV diff --git a/src/CSV/Player.cpp b/src/CSV/Player.cpp index fded43fc..de2b893b 100644 --- a/src/CSV/Player.cpp +++ b/src/CSV/Player.cpp @@ -36,11 +36,11 @@ * Constructor function */ CSV::Player::Player() - : m_framePos(0) - , m_playing(false) - , m_timestamp("") + : m_framePos(0) + , m_playing(false) + , m_timestamp("") { - connect(this, SIGNAL(playerStateChanged()), this, SLOT(updateData())); + connect(this, SIGNAL(playerStateChanged()), this, SLOT(updateData())); } /** @@ -48,8 +48,8 @@ CSV::Player::Player() */ CSV::Player &CSV::Player::instance() { - static Player singleton; - return singleton; + static Player singleton; + return singleton; } /** @@ -57,7 +57,7 @@ CSV::Player &CSV::Player::instance() */ bool CSV::Player::isOpen() const { - return m_csvFile.isOpen(); + return m_csvFile.isOpen(); } /** @@ -65,7 +65,7 @@ bool CSV::Player::isOpen() const */ qreal CSV::Player::progress() const { - return ((qreal)framePosition()) / frameCount(); + return ((qreal)framePosition()) / frameCount(); } /** @@ -74,7 +74,7 @@ qreal CSV::Player::progress() const */ bool CSV::Player::isPlaying() const { - return m_playing; + return m_playing; } /** @@ -82,13 +82,13 @@ bool CSV::Player::isPlaying() const */ QString CSV::Player::filename() const { - if (isOpen()) - { - auto fileInfo = QFileInfo(m_csvFile.fileName()); - return fileInfo.fileName(); - } + if (isOpen()) + { + auto fileInfo = QFileInfo(m_csvFile.fileName()); + return fileInfo.fileName(); + } - return ""; + return ""; } /** @@ -98,7 +98,7 @@ QString CSV::Player::filename() const */ int CSV::Player::frameCount() const { - return m_csvData.count() - 1; + return m_csvData.count() - 1; } /** @@ -107,7 +107,7 @@ int CSV::Player::frameCount() const */ int CSV::Player::framePosition() const { - return m_framePos; + return m_framePos; } /** @@ -115,7 +115,7 @@ int CSV::Player::framePosition() const */ QString CSV::Player::timestamp() const { - return m_timestamp; + return m_timestamp; } /** @@ -123,18 +123,16 @@ QString CSV::Player::timestamp() const */ QString CSV::Player::csvFilesPath() const { - // Get file name and path - // clang-format off - QString path = QString("%1/Documents/%2/CSV/").arg(QDir::homePath(), - qApp->applicationName()); - // clang-format on + // Get file name and path + const auto path = QString("%1/Documents/%2/CSV/") + .arg(QDir::homePath(), qApp->applicationName()); - // Generate file path if required - QDir dir(path); - if (!dir.exists()) - dir.mkpath("."); + // Generate file path if required + QDir dir(path); + if (!dir.exists()) + dir.mkpath("."); - return path; + return path; } /** @@ -143,8 +141,8 @@ QString CSV::Player::csvFilesPath() const */ void CSV::Player::play() { - m_playing = true; - Q_EMIT playerStateChanged(); + m_playing = true; + Q_EMIT playerStateChanged(); } /** @@ -153,8 +151,8 @@ void CSV::Player::play() */ void CSV::Player::pause() { - m_playing = false; - Q_EMIT playerStateChanged(); + m_playing = false; + Q_EMIT playerStateChanged(); } /** @@ -162,8 +160,8 @@ void CSV::Player::pause() */ void CSV::Player::toggle() { - m_playing = !m_playing; - Q_EMIT playerStateChanged(); + m_playing = !m_playing; + Q_EMIT playerStateChanged(); } /** @@ -171,7 +169,7 @@ void CSV::Player::toggle() */ void CSV::Player::openFile() { - // clang-format off + // clang-format off // Get file name auto file = QFileDialog::getOpenFileName( @@ -184,7 +182,7 @@ void CSV::Player::openFile() if (!file.isEmpty()) openFile(file); - // clang-format on + // clang-format on } /** @@ -193,15 +191,15 @@ void CSV::Player::openFile() */ void CSV::Player::closeFile() { - m_framePos = 0; - m_csvFile.close(); - m_csvData.clear(); - m_playing = false; - m_timestamp = "--.--"; + m_framePos = 0; + m_csvFile.close(); + m_csvData.clear(); + m_playing = false; + m_timestamp = "--.--"; - Q_EMIT openChanged(); - Q_EMIT timestampChanged(); - Q_EMIT playerStateChanged(); + Q_EMIT openChanged(); + Q_EMIT timestampChanged(); + Q_EMIT playerStateChanged(); } /** @@ -209,11 +207,11 @@ void CSV::Player::closeFile() */ void CSV::Player::nextFrame() { - if (framePosition() < frameCount()) - { - ++m_framePos; - updateData(); - } + if (framePosition() < frameCount()) + { + ++m_framePos; + updateData(); + } } /** @@ -221,11 +219,11 @@ void CSV::Player::nextFrame() */ void CSV::Player::previousFrame() { - if (framePosition() > 0) - { - --m_framePos; - updateData(); - } + if (framePosition() > 0) + { + --m_framePos; + updateData(); + } } /** @@ -235,64 +233,66 @@ void CSV::Player::previousFrame() */ void CSV::Player::openFile(const QString &filePath) { - // File name empty, abort - if (filePath.isEmpty()) - return; + // File name empty, abort + if (filePath.isEmpty()) + return; - // Close previous file - closeFile(); + // Close previous file + closeFile(); - // Device is connected, warn user & disconnect - if (IO::Manager::instance().connected()) - { - auto response = Misc::Utilities::showMessageBox( - tr("Serial port open, do you want to continue?"), - tr("In order to use this feature, its necessary " - "to disconnect from the serial port"), - qAppName(), QMessageBox::No | QMessageBox::Yes); - if (response == QMessageBox::Yes) - IO::Manager::instance().disconnectDriver(); - else - return; - } + // Device is connected, warn user & disconnect + if (IO::Manager::instance().connected()) + { + auto response = Misc::Utilities::showMessageBox( + tr("Serial port open, do you want to continue?"), + tr("In order to use this feature, its necessary " + "to disconnect from the serial port"), + qAppName(), QMessageBox::No | QMessageBox::Yes); + if (response == QMessageBox::Yes) + IO::Manager::instance().disconnectDriver(); + else + return; + } - // Try to open the current file - m_csvFile.setFileName(filePath); - if (m_csvFile.open(QIODevice::ReadOnly)) - { - // Read CSV file into string matrix + // Try to open the current file + m_csvFile.setFileName(filePath); + if (m_csvFile.open(QIODevice::ReadOnly)) + { + // Read CSV file into string matrix #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QVector row; - auto csv = QtCSV::Reader::readToList(m_csvFile); - for (int i = 0; i < csv.count(); ++i) - { - row.clear(); - for (int j = 0; j < csv.at(i).count(); ++j) - row.append(csv[i][j]); + QVector row; + auto csv = QtCSV::Reader::readToList(m_csvFile); + for (int i = 0; i < csv.count(); ++i) + { + row.clear(); + for (int j = 0; j < csv.at(i).count(); ++j) + row.append(csv[i][j]); - m_csvData.append(row); - } + m_csvData.append(row); + } #else - m_csvData = QtCSV::Reader::readToList(m_csvFile); + m_csvData = QtCSV::Reader::readToList(m_csvFile); #endif - // Read first data & Q_EMIT UI signals - updateData(); - Q_EMIT openChanged(); + // Read first data & Q_EMIT UI signals + updateData(); + Q_EMIT openChanged(); - // Play next frame (to force UI to generate groups, graphs & widgets) - // Note: nextFrame() MUST BE CALLED AFTER emiting the openChanged() signal in - // order for this monstrosity to work - nextFrame(); - } + // Play next frame (to force UI to generate groups, graphs & widgets) + // Note: nextFrame() MUST BE CALLED AFTER emiting the openChanged() signal + // in + // order for this monstrosity to work + nextFrame(); + } - // Open error - else - { - Misc::Utilities::showMessageBox(tr("Cannot read CSV file"), - tr("Please check file permissions & location")); - closeFile(); - } + // Open error + else + { + Misc::Utilities::showMessageBox( + tr("Cannot read CSV file"), + tr("Please check file permissions & location")); + closeFile(); + } } /** @@ -301,26 +301,26 @@ void CSV::Player::openFile(const QString &filePath) */ void CSV::Player::setProgress(const qreal &progress) { - // Ensure that progress value is between 0 and 1 - auto validProgress = progress; - if (validProgress > 1) - validProgress = 1; - else if (validProgress < 0) - validProgress = 0; + // Ensure that progress value is between 0 and 1 + auto validProgress = progress; + if (validProgress > 1) + validProgress = 1; + else if (validProgress < 0) + validProgress = 0; - // Pause player to avoid messing the scheduled timer (if playing) - if (isPlaying()) - pause(); + // Pause player to avoid messing the scheduled timer (if playing) + if (isPlaying()) + pause(); - // Calculate frame position & update data - m_framePos = qCeil(frameCount() * validProgress); - if (validProgress == 0) - m_framePos = 0; - else if (validProgress == 1) - m_framePos = frameCount(); + // Calculate frame position & update data + m_framePos = qCeil(frameCount() * validProgress); + if (validProgress == 0) + m_framePos = 0; + else if (validProgress == 1) + m_framePos = frameCount(); - // Update CSV values - updateData(); + // Update CSV values + updateData(); } /** @@ -333,87 +333,87 @@ void CSV::Player::setProgress(const qreal &progress) */ void CSV::Player::updateData() { - // File not open, abort - if (!isOpen()) - return; + // File not open, abort + if (!isOpen()) + return; - // Update timestamp string - bool error = true; - auto timestamp = getCellValue(framePosition() + 1, 0, error); - if (!error) + // Update timestamp string + bool error = true; + auto timestamp = getCellValue(framePosition() + 1, 0, error); + if (!error) + { + m_timestamp = timestamp; + Q_EMIT timestampChanged(); + } + + // Construct frame from CSV and send it to the IO manager + IO::Manager::instance().processPayload(getFrame(framePosition() + 1)); + + // If the user wants to 'play' the CSV, get time difference between this + // frame and the next frame & schedule an automated update + if (isPlaying()) + { + // Get first frame + if (framePosition() < frameCount()) { - m_timestamp = timestamp; - Q_EMIT timestampChanged(); - } + bool error = true; + auto currTime = getCellValue(framePosition() + 1, 0, error); + auto nextTime = getCellValue(framePosition() + 2, 0, error); - // Construct frame from CSV and send it to the IO manager - IO::Manager::instance().processPayload(getFrame(framePosition() + 1)); + // No error, calculate difference & schedule update + if (!error) + { + auto format = "yyyy/MM/dd/ HH:mm:ss::zzz"; // Same as in Export.cpp + auto currDateTime = QDateTime::fromString(currTime, format); + auto nextDateTime = QDateTime::fromString(nextTime, format); + auto msecsToNextF = currDateTime.msecsTo(nextDateTime); - // If the user wants to 'play' the CSV, get time difference between this - // frame and the next frame & schedule an automated update - if (isPlaying()) - { - // Get first frame - if (framePosition() < frameCount()) - { - bool error = true; - auto currTime = getCellValue(framePosition() + 1, 0, error); - auto nextTime = getCellValue(framePosition() + 2, 0, error); - - // No error, calculate difference & schedule update - if (!error) - { - auto format = "yyyy/MM/dd/ HH:mm:ss::zzz"; // Same as in Export.cpp - auto currDateTime = QDateTime::fromString(currTime, format); - auto nextDateTime = QDateTime::fromString(nextTime, format); - auto msecsToNextF = currDateTime.msecsTo(nextDateTime); - - // clang-format off + // clang-format off QTimer::singleShot(msecsToNextF, Qt::PreciseTimer, this, SLOT(nextFrame())); - // clang-format on - } + // clang-format on + } - // Error - pause playback - else - { - pause(); - qWarning() << "Error getting timestamp difference"; - } - } - - // Pause at end of CSV - else - pause(); + // Error - pause playback + else + { + pause(); + qWarning() << "Error getting timestamp difference"; + } } + + // Pause at end of CSV + else + pause(); + } } /** - * Generates a frame from the data at the given @a row. The first item of each row is - * ignored because it contains the RX date/time, which is used to regulate the interval - * at which the frames are parsed. + * Generates a frame from the data at the given @a row. The first item of each + * row is ignored because it contains the RX date/time, which is used to + * regulate the interval at which the frames are parsed. */ QByteArray CSV::Player::getFrame(const int row) { - QByteArray frame; - auto sep = IO::Manager::instance().separatorSequence(); + QByteArray frame; + auto sep = IO::Manager::instance().separatorSequence(); - if (m_csvData.count() > row) + if (m_csvData.count() > row) + { + auto list = m_csvData.at(row); + for (int i = 1; i < list.count(); ++i) { - auto list = m_csvData.at(row); - for (int i = 1; i < list.count(); ++i) - { - frame.append(list.at(i).toUtf8()); - if (i < list.count() - 1) - frame.append(sep.toUtf8()); - else - frame.append('\n'); - } + frame.append(list.at(i).toUtf8()); + if (i < list.count() - 1) + frame.append(sep.toUtf8()); + else + frame.append('\n'); } + } - return frame; + return frame; } /** @@ -423,20 +423,16 @@ QByteArray CSV::Player::getFrame(const int row) */ QString CSV::Player::getCellValue(const int row, const int column, bool &error) { - if (m_csvData.count() > row) + if (m_csvData.count() > row) + { + auto list = m_csvData.at(row); + if (list.count() > column) { - auto list = m_csvData.at(row); - if (list.count() > column) - { - error = false; - return list.at(column); - } + error = false; + return list.at(column); } + } - error = true; - return ""; + error = true; + return ""; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Player.cpp" -#endif diff --git a/src/CSV/Player.h b/src/CSV/Player.h index 841fe327..a70a7c86 100644 --- a/src/CSV/Player.h +++ b/src/CSV/Player.h @@ -36,69 +36,69 @@ namespace CSV */ class Player : public QObject { - // clang-format off - Q_OBJECT - Q_PROPERTY(bool isOpen - READ isOpen - NOTIFY openChanged) - Q_PROPERTY(qreal progress - READ progress - NOTIFY timestampChanged) - Q_PROPERTY(bool isPlaying - READ isPlaying - NOTIFY playerStateChanged) - Q_PROPERTY(QString timestamp - READ timestamp - NOTIFY timestampChanged) - // clang-format on + // clang-format off + Q_OBJECT + Q_PROPERTY(bool isOpen + READ isOpen + NOTIFY openChanged) + Q_PROPERTY(qreal progress + READ progress + NOTIFY timestampChanged) + Q_PROPERTY(bool isPlaying + READ isPlaying + NOTIFY playerStateChanged) + Q_PROPERTY(QString timestamp + READ timestamp + NOTIFY timestampChanged) + // clang-format on Q_SIGNALS: - void openChanged(); - void timestampChanged(); - void playerStateChanged(); + void openChanged(); + void timestampChanged(); + void playerStateChanged(); private: - explicit Player(); - Player(Player &&) = delete; - Player(const Player &) = delete; - Player &operator=(Player &&) = delete; - Player &operator=(const Player &) = delete; + explicit Player(); + Player(Player &&) = delete; + Player(const Player &) = delete; + Player &operator=(Player &&) = delete; + Player &operator=(const Player &) = delete; public: - static Player &instance(); + static Player &instance(); - bool isOpen() const; - qreal progress() const; - bool isPlaying() const; - int frameCount() const; - QString filename() const; - int framePosition() const; - QString timestamp() const; - QString csvFilesPath() const; + bool isOpen() const; + qreal progress() const; + bool isPlaying() const; + int frameCount() const; + QString filename() const; + int framePosition() const; + QString timestamp() const; + QString csvFilesPath() const; public Q_SLOTS: - void play(); - void pause(); - void toggle(); - void openFile(); - void closeFile(); - void nextFrame(); - void previousFrame(); - void openFile(const QString &filePath); - void setProgress(const qreal &progress); + void play(); + void pause(); + void toggle(); + void openFile(); + void closeFile(); + void nextFrame(); + void previousFrame(); + void openFile(const QString &filePath); + void setProgress(const qreal &progress); private Q_SLOTS: - void updateData(); + void updateData(); private: - QByteArray getFrame(const int row); - QString getCellValue(const int row, const int column, bool &error); + QByteArray getFrame(const int row); + QString getCellValue(const int row, const int column, bool &error); private: - int m_framePos; - bool m_playing; - QFile m_csvFile; - QString m_timestamp; - QVector> m_csvData; + int m_framePos; + bool m_playing; + QFile m_csvFile; + QString m_timestamp; + QVector> m_csvData; }; -} +} // namespace CSV diff --git a/src/DataTypes.h b/src/DataTypes.h index 891a2090..a5231188 100644 --- a/src/DataTypes.h +++ b/src/DataTypes.h @@ -27,10 +27,10 @@ #include #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -# include -# define StringList QStringList +# include +# define StringList QStringList #else -# define StringList QVector +# define StringList QVector #endif #define PlotData QVector diff --git a/src/IO/Checksum.cpp b/src/IO/Checksum.cpp index a80f395f..57f09c11 100644 --- a/src/IO/Checksum.cpp +++ b/src/IO/Checksum.cpp @@ -24,50 +24,51 @@ uint8_t IO::crc8(const char *data, const int length) { - uint8_t crc = 0xff; - for (int i = 0; i < length; i++) + uint8_t crc = 0xff; + for (int i = 0; i < length; i++) + { + crc ^= data[i]; + for (int j = 0; j < 8; j++) { - crc ^= data[i]; - for (int j = 0; j < 8; j++) - { - if ((crc & 0x80) != 0) - crc = (uint8_t)((crc << 1) ^ 0x31); - else - crc <<= 1; - } + if ((crc & 0x80) != 0) + crc = (uint8_t)((crc << 1) ^ 0x31); + else + crc <<= 1; } + } - return crc; + return crc; } uint16_t IO::crc16(const char *data, const int length) { - uint8_t x; - uint16_t crc = 0xFFFF; + uint8_t x; + uint16_t crc = 0xFFFF; - for (int i = 0; i < length; ++i) - { - x = crc >> 8 ^ data[i]; - x ^= x >> 4; - crc = (crc << 8) ^ ((uint16_t)(x << 12)) ^ ((uint16_t)(x << 5)) ^ ((uint16_t)x); - } + for (int i = 0; i < length; ++i) + { + x = crc >> 8 ^ data[i]; + x ^= x >> 4; + crc = (crc << 8) ^ ((uint16_t)(x << 12)) ^ ((uint16_t)(x << 5)) + ^ ((uint16_t)x); + } - return crc; + return crc; } uint32_t IO::crc32(const char *data, const int length) { - uint32_t mask; - uint32_t crc = 0xFFFFFFFF; - for (int i = 0; i < length; ++i) + uint32_t mask; + uint32_t crc = 0xFFFFFFFF; + for (int i = 0; i < length; ++i) + { + crc = crc ^ data[i]; + for (int j = 8; j >= 0; j--) { - crc = crc ^ data[i]; - for (int j = 8; j >= 0; j--) - { - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); } + } - return ~crc; + return ~crc; } diff --git a/src/IO/Checksum.h b/src/IO/Checksum.h index 90aea2cc..7a2b101b 100644 --- a/src/IO/Checksum.h +++ b/src/IO/Checksum.h @@ -30,4 +30,4 @@ namespace IO uint8_t crc8(const char *data, const int length); uint16_t crc16(const char *data, const int length); uint32_t crc32(const char *data, const int length); -} +} // namespace IO diff --git a/src/IO/Console.cpp b/src/IO/Console.cpp index 37c31beb..d54f9bc6 100644 --- a/src/IO/Console.cpp +++ b/src/IO/Console.cpp @@ -37,63 +37,63 @@ */ static QString HexDump(const char *data, const size_t size) { - char str[4096] = ""; - char ascii[17]; + char str[4096] = ""; + char ascii[17]; - size_t i, j; - ascii[16] = '\0'; - for (i = 0; i < size; ++i) + size_t i, j; + ascii[16] = '\0'; + for (i = 0; i < size; ++i) + { + sprintf(str + strlen(str), "%02X ", static_cast(data[i])); + + if (data[i] >= ' ' && data[i] <= '~') + ascii[i % 16] = data[i]; + else + ascii[i % 16] = '.'; + + if ((i + 1) % 8 == 0 || i + 1 == size) { - sprintf(str + strlen(str), "%02X ", static_cast(data[i])); + sprintf(str + strlen(str), " "); + if ((i + 1) % 16 == 0) + sprintf(str + strlen(str), "| %s \n", ascii); - if (data[i] >= ' ' && data[i] <= '~') - ascii[i % 16] = data[i]; - else - ascii[i % 16] = '.'; + else if (i + 1 == size) + { + ascii[(i + 1) % 16] = '\0'; - if ((i + 1) % 8 == 0 || i + 1 == size) - { - sprintf(str + strlen(str), " "); - if ((i + 1) % 16 == 0) - sprintf(str + strlen(str), "| %s \n", ascii); + if ((i + 1) % 16 <= 8) + sprintf(str + strlen(str), " "); + for (j = (i + 1) % 16; j < 16; ++j) + sprintf(str + strlen(str), " "); - else if (i + 1 == size) - { - ascii[(i + 1) % 16] = '\0'; - - if ((i + 1) % 16 <= 8) - sprintf(str + strlen(str), " "); - for (j = (i + 1) % 16; j < 16; ++j) - sprintf(str + strlen(str), " "); - - sprintf(str + strlen(str), "| %s \n", ascii); - } - } + sprintf(str + strlen(str), "| %s \n", ascii); + } } + } - return QString(str); + return QString(str); } /** * Constructor function */ IO::Console::Console() - : m_dataMode(DataMode::DataUTF8) - , m_lineEnding(LineEnding::NoLineEnding) - , m_displayMode(DisplayMode::DisplayPlainText) - , m_historyItem(0) - , m_echo(false) - , m_autoscroll(true) - , m_showTimestamp(false) - , m_isStartingLine(true) + : m_dataMode(DataMode::DataUTF8) + , m_lineEnding(LineEnding::NoLineEnding) + , m_displayMode(DisplayMode::DisplayPlainText) + , m_historyItem(0) + , m_echo(false) + , m_autoscroll(true) + , m_showTimestamp(false) + , m_isStartingLine(true) { - // Clear buffer & reserve memory - clear(); + // Clear buffer & reserve memory + clear(); - // Read received data automatically - auto dm = &Manager::instance(); - connect(dm, &Manager::dataSent, this, &IO::Console::onDataSent); - connect(dm, &Manager::dataReceived, this, &IO::Console::onDataReceived); + // Read received data automatically + auto dm = &Manager::instance(); + connect(dm, &Manager::dataSent, this, &IO::Console::onDataSent); + connect(dm, &Manager::dataReceived, this, &IO::Console::onDataReceived); } /** @@ -101,26 +101,26 @@ IO::Console::Console() */ IO::Console &IO::Console::instance() { - static Console singleton; - return singleton; + static Console singleton; + return singleton; } /** - * Returns @c true if the console shall display the commands that the user has sent - * to the serial/network device. + * Returns @c true if the console shall display the commands that the user has + * sent to the serial/network device. */ bool IO::Console::echo() const { - return m_echo; + return m_echo; } /** - * Returns @c true if the vertical position of the console display shall be automatically - * moved to show latest data. + * Returns @c true if the vertical position of the console display shall be + * automatically moved to show latest data. */ bool IO::Console::autoscroll() const { - return m_autoscroll; + return m_autoscroll; } /** @@ -128,131 +128,137 @@ bool IO::Console::autoscroll() const */ bool IO::Console::saveAvailable() const { - return m_textBuffer.length() > 0; + return m_textBuffer.length() > 0; } /** - * Returns @c true if a timestamp should be shown before each displayed data block. + * Returns @c true if a timestamp should be shown before each displayed data + * block. */ bool IO::Console::showTimestamp() const { - return m_showTimestamp; + return m_showTimestamp; } /** - * Returns the type of data that the user inputs to the console. There are two possible - * values: - * - @c DataMode::DataUTF8 the user is sending data formated in the UTF-8 codec. + * Returns the type of data that the user inputs to the console. There are two + * possible values: + * - @c DataMode::DataUTF8 the user is sending data formated in the UTF-8 + * codec. * - @c DataMode::DataHexadecimal the user is sending binary data represented in - * hexadecimal format, we must do a conversion to obtain - * and send the appropiate binary data to the target - * device. + * hexadecimal format, we must do a conversion to + * obtain and send the appropiate binary data to the target device. */ IO::Console::DataMode IO::Console::dataMode() const { - return m_dataMode; + return m_dataMode; } /** - * Returns the line ending character that is added to each datablock sent by the user. - * Possible values are: + * Returns the line ending character that is added to each datablock sent by the + * user. Possible values are: * - @c LineEnding::NoLineEnding leave data as-it-is - * - @c LineEnding::NewLine, add '\n' to the data sent by the user - * - @c LineEnding::CarriageReturn, add '\r' to the data sent by the user - * - @c LineEnding::BothNewLineAndCarriageReturn add '\r\n' to the data sent by the user + * - @c LineEnding::NewLine, add '\n' to the data sent by + * the user + * - @c LineEnding::CarriageReturn, add '\r' to the data sent by + * the user + * - @c LineEnding::BothNewLineAndCarriageReturn add '\r\n' to the data sent by + * the user */ IO::Console::LineEnding IO::Console::lineEnding() const { - return m_lineEnding; + return m_lineEnding; } /** * Returns the display format of the console. Posible values are: * - @c DisplayMode::DisplayPlainText display incoming data as an UTF-8 stream - * - @c DisplayMode::DisplayHexadecimal display incoming data in hexadecimal format + * - @c DisplayMode::DisplayHexadecimal display incoming data in hexadecimal + * format */ IO::Console::DisplayMode IO::Console::displayMode() const { - return m_displayMode; + return m_displayMode; } /** * Returns the current command history string selected by the user. * - * @note the user can navigate through sent commands using the Up/Down keys on the - * keyboard. This behaviour is managed by the @c historyUp() & @c historyDown() - * functions. + * @note the user can navigate through sent commands using the Up/Down keys on + * the keyboard. This behaviour is managed by the @c historyUp() & @c + * historyDown() functions. */ QString IO::Console::currentHistoryString() const { - if (m_historyItem < m_historyItems.count() && m_historyItem >= 0) - return m_historyItems.at(m_historyItem); + if (m_historyItem < m_historyItems.count() && m_historyItem >= 0) + return m_historyItems.at(m_historyItem); - return ""; + return ""; } /** - * Returns a list with the available data (sending) modes. This list must be synchronized - * with the order of the @c DataMode enums. + * Returns a list with the available data (sending) modes. This list must be + * synchronized with the order of the @c DataMode enums. */ StringList IO::Console::dataModes() const { - StringList list; - list.append(tr("ASCII")); - list.append(tr("HEX")); - return list; + StringList list; + list.append(tr("ASCII")); + list.append(tr("HEX")); + return list; } /** - * Returns a list with the available line endings options. This list must be synchronized - * with the order of the @c LineEnding enums. + * Returns a list with the available line endings options. This list must be + * synchronized with the order of the @c LineEnding enums. */ StringList IO::Console::lineEndings() const { - StringList list; - list.append(tr("No line ending")); - list.append(tr("New line")); - list.append(tr("Carriage return")); - list.append(tr("NL + CR")); - return list; + StringList list; + list.append(tr("No line ending")); + list.append(tr("New line")); + list.append(tr("Carriage return")); + list.append(tr("NL + CR")); + return list; } /** - * Returns a list with the available console display modes. This list must be synchronized - * with the order of the @c DisplayMode enums. + * Returns a list with the available console display modes. This list must be + * synchronized with the order of the @c DisplayMode enums. */ StringList IO::Console::displayModes() const { - StringList list; - list.append(tr("Plain text")); - list.append(tr("Hexadecimal")); - return list; + StringList list; + list.append(tr("Plain text")); + list.append(tr("Hexadecimal")); + return list; } /** - * Validates the given @a text and adds space to display the text in a byte-oriented view + * Validates the given @a text and adds space to display the text in a + * byte-oriented view */ QString IO::Console::formatUserHex(const QString &text) { - // Remove spaces & stuff - auto data = text.simplified(); - data = data.replace(" ", ""); + // Remove spaces & stuff + auto data = text.simplified(); + data = data.replace(" ", ""); - // Convert to hex string with spaces between bytes - QString str; - for (int i = 0; i < data.length(); ++i) - { - str.append(data.at(i)); - if ((i + 1) % 2 == 0 && i > 0) - str.append(" "); - } + // Convert to hex string with spaces between bytes + QString str; + for (int i = 0; i < data.length(); ++i) + { + str.append(data.at(i)); + if ((i + 1) % 2 == 0 && i > 0) + str.append(" "); + } - // Chop last space - while (str.endsWith(" ")) - str.chop(1); + // Chop last space + while (str.endsWith(" ")) + str.chop(1); - // Return string - return str; + // Return string + return str; } /** @@ -260,29 +266,30 @@ QString IO::Console::formatUserHex(const QString &text) */ void IO::Console::save() { - // No data buffer received, abort - if (!saveAvailable()) - return; + // No data buffer received, abort + if (!saveAvailable()) + return; - // Get file name - auto path - = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export console data"), - QDir::homePath(), tr("Text files") + " (*.txt)"); + // Get file name + auto path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Export console data"), + QDir::homePath(), + tr("Text files") + " (*.txt)"); - // Create file - if (!path.isEmpty()) + // Create file + if (!path.isEmpty()) + { + QFile file(path); + if (file.open(QFile::WriteOnly)) { - QFile file(path); - if (file.open(QFile::WriteOnly)) - { - file.write(m_textBuffer.toUtf8()); - file.close(); - Misc::Utilities::revealFile(path); - } - - else - Misc::Utilities::showMessageBox(tr("File save error"), file.errorString()); + file.write(m_textBuffer.toUtf8()); + file.close(); + Misc::Utilities::revealFile(path); } + + else + Misc::Utilities::showMessageBox(tr("File save error"), + file.errorString()); + } } /** @@ -290,96 +297,96 @@ void IO::Console::save() */ void IO::Console::clear() { - m_textBuffer.clear(); - m_textBuffer.reserve(10 * 1000); - m_isStartingLine = true; - Q_EMIT dataReceived(); + m_textBuffer.clear(); + m_textBuffer.reserve(10 * 1000); + m_isStartingLine = true; + Q_EMIT dataReceived(); } /** - * Comamnds sent by the user are stored in a @c StringList, in which the first items - * are the oldest commands. + * Comamnds sent by the user are stored in a @c StringList, in which the first + * items are the oldest commands. * - * The user can navigate the list using the up/down keys. This function allows the user - * to navigate the list from most recent command to oldest command. + * The user can navigate the list using the up/down keys. This function allows + * the user to navigate the list from most recent command to oldest command. */ void IO::Console::historyUp() { - if (m_historyItem > 0) - { - --m_historyItem; - Q_EMIT historyItemChanged(); - } + if (m_historyItem > 0) + { + --m_historyItem; + Q_EMIT historyItemChanged(); + } } /** - * Comamnds sent by the user are stored in a @c StringList, in which the first items - * are the oldest commands. + * Comamnds sent by the user are stored in a @c StringList, in which the first + * items are the oldest commands. * - * The user can navigate the list using the up/down keys. This function allows the user - * to navigate the list from oldst command to most recent command. + * The user can navigate the list using the up/down keys. This function allows + * the user to navigate the list from oldst command to most recent command. */ void IO::Console::historyDown() { - if (m_historyItem < m_historyItems.count() - 1) - { - ++m_historyItem; - Q_EMIT historyItemChanged(); - } + if (m_historyItem < m_historyItems.count() - 1) + { + ++m_historyItem; + Q_EMIT historyItemChanged(); + } } /** - * Sends the given @a data to the currently connected device using the options specified - * by the user with the rest of the functions of this class. + * Sends the given @a data to the currently connected device using the options + * specified by the user with the rest of the functions of this class. * - * @note @c data is added to the history of sent commands, regardless if the data writing - * was successfull or not. + * @note @c data is added to the history of sent commands, regardless if the + * data writing was successfull or not. */ void IO::Console::send(const QString &data) { - // Check conditions - if (data.isEmpty() || !Manager::instance().connected()) - return; + // Check conditions + if (data.isEmpty() || !Manager::instance().connected()) + return; - // Add user command to history - addToHistory(data); + // Add user command to history + addToHistory(data); - // Convert data to byte array - QByteArray bin; - if (dataMode() == DataMode::DataHexadecimal) - bin = hexToBytes(data); - else - bin = data.toUtf8(); + // Convert data to byte array + QByteArray bin; + if (dataMode() == DataMode::DataHexadecimal) + bin = hexToBytes(data); + else + bin = data.toUtf8(); - // Add EOL character - switch (lineEnding()) - { - case LineEnding::NoLineEnding: - break; - case LineEnding::NewLine: - bin.append("\n"); - break; - case LineEnding::CarriageReturn: - bin.append("\r"); - break; - case LineEnding::BothNewLineAndCarriageReturn: - bin.append("\r"); - bin.append("\n"); - break; - } + // Add EOL character + switch (lineEnding()) + { + case LineEnding::NoLineEnding: + break; + case LineEnding::NewLine: + bin.append("\n"); + break; + case LineEnding::CarriageReturn: + bin.append("\r"); + break; + case LineEnding::BothNewLineAndCarriageReturn: + bin.append("\r"); + bin.append("\n"); + break; + } - // Write data to device - Manager::instance().writeData(bin); + // Write data to device + Manager::instance().writeData(bin); } /** - * Enables or disables displaying sent data in the console screen. See @c echo() for more - * information. + * Enables or disables displaying sent data in the console screen. See @c echo() + * for more information. */ void IO::Console::setEcho(const bool enabled) { - m_echo = enabled; - Q_EMIT echoChanged(); + m_echo = enabled; + Q_EMIT echoChanged(); } /** @@ -390,28 +397,28 @@ void IO::Console::setEcho(const bool enabled) */ void IO::Console::print(const QString &fontFamily) { - // Get document font (specified by QML ui) - QFont font; - font.setPointSize(10); - font.setFamily(fontFamily); + // Get document font (specified by QML ui) + QFont font; + font.setPointSize(10); + font.setFamily(fontFamily); - // Create text document - QTextDocument document; - document.setDefaultFont(font); - document.setPlainText(m_textBuffer); + // Create text document + QTextDocument document; + document.setDefaultFont(font); + document.setPlainText(m_textBuffer); - // Create printer object - QPrinter printer(QPrinter::PrinterResolution); - printer.setFullPage(true); - printer.setDocName(qApp->applicationName()); - printer.setPageOrientation(QPageLayout::Portrait); + // Create printer object + QPrinter printer(QPrinter::PrinterResolution); + printer.setFullPage(true); + printer.setDocName(qApp->applicationName()); + printer.setPageOrientation(QPageLayout::Portrait); - // Show print dialog - QPrintDialog printDialog(&printer, Q_NULLPTR); - if (printDialog.exec() == QDialog::Accepted) - { - document.print(&printer); - } + // Show print dialog + QPrintDialog printDialog(&printer, Q_NULLPTR); + if (printDialog.exec() == QDialog::Accepted) + { + document.print(&printer); + } } /** @@ -419,11 +426,11 @@ void IO::Console::print(const QString &fontFamily) */ void IO::Console::setShowTimestamp(const bool enabled) { - if (showTimestamp() != enabled) - { - m_showTimestamp = enabled; - Q_EMIT showTimestampChanged(); - } + if (showTimestamp() != enabled) + { + m_showTimestamp = enabled; + Q_EMIT showTimestampChanged(); + } } /** @@ -431,20 +438,21 @@ void IO::Console::setShowTimestamp(const bool enabled) */ void IO::Console::setAutoscroll(const bool enabled) { - if (autoscroll() != enabled) - { - m_autoscroll = enabled; - Q_EMIT autoscrollChanged(); - } + if (autoscroll() != enabled) + { + m_autoscroll = enabled; + Q_EMIT autoscrollChanged(); + } } /** - * Changes the data mode for user commands. See @c dataMode() for more information. + * Changes the data mode for user commands. See @c dataMode() for more + * information. */ void IO::Console::setDataMode(const IO::Console::DataMode &mode) { - m_dataMode = mode; - Q_EMIT dataModeChanged(); + m_dataMode = mode; + Q_EMIT dataModeChanged(); } /** @@ -453,95 +461,96 @@ void IO::Console::setDataMode(const IO::Console::DataMode &mode) */ void IO::Console::setLineEnding(const IO::Console::LineEnding &mode) { - m_lineEnding = mode; - Q_EMIT lineEndingChanged(); + m_lineEnding = mode; + Q_EMIT lineEndingChanged(); } /** - * Changes the display mode of the console. See @c displayMode() for more information. + * Changes the display mode of the console. See @c displayMode() for more + * information. */ void IO::Console::setDisplayMode(const IO::Console::DisplayMode &mode) { - m_displayMode = mode; - Q_EMIT displayModeChanged(); + m_displayMode = mode; + Q_EMIT displayModeChanged(); } /** - * Inserts the given @a string into the list of lines of the console, if @a addTimestamp - * is set to @c true, an timestamp is added for each line. + * Inserts the given @a string into the list of lines of the console, if @a + * addTimestamp is set to @c true, an timestamp is added for each line. */ void IO::Console::append(const QString &string, const bool addTimestamp) { - // Abort on empty strings - if (string.isEmpty()) - return; + // Abort on empty strings + if (string.isEmpty()) + return; - // Only use \n as line separator - auto data = string; - data = data.replace("\r\n", "\n"); - data = data.replace("\r", "\n"); + // Only use \n as line separator + auto data = string; + data = data.replace("\r\n", "\n"); + data = data.replace("\r", "\n"); - // Get timestamp - QString timestamp; - if (addTimestamp) + // Get timestamp + QString timestamp; + if (addTimestamp) + { + QDateTime dateTime = QDateTime::currentDateTime(); + timestamp = dateTime.toString("HH:mm:ss.zzz -> "); + } + + // Initialize final string + QString processedString; + processedString.reserve(data.length() + timestamp.length()); + + // Create list with lines (keep separators) + StringList tokens; + QString currentToken; + for (int i = 0; i < data.length(); ++i) + { + if (data.at(i) == '\n') { - QDateTime dateTime = QDateTime::currentDateTime(); - timestamp = dateTime.toString("HH:mm:ss.zzz -> "); + tokens.append(currentToken); + tokens.append("\n"); + currentToken.clear(); } - // Initialize final string - QString processedString; - processedString.reserve(data.length() + timestamp.length()); + else + currentToken += data.at(i); + } - // Create list with lines (keep separators) - StringList tokens; - QString currentToken; - for (int i = 0; i < data.length(); ++i) - { - if (data.at(i) == '\n') - { - tokens.append(currentToken); - tokens.append("\n"); - currentToken.clear(); - } + // Add last item to list + if (!currentToken.isEmpty()) + tokens.append(currentToken); - else - currentToken += data.at(i); - } + // Process lines + while (!tokens.isEmpty()) + { + if (m_isStartingLine) + processedString.append(timestamp); - // Add last item to list - if (!currentToken.isEmpty()) - tokens.append(currentToken); + auto token = tokens.first(); + processedString.append(token); + m_isStartingLine = (token == "\n"); + tokens.removeFirst(); + } - // Process lines - while (!tokens.isEmpty()) - { - if (m_isStartingLine) - processedString.append(timestamp); + // Add data to saved text buffer + m_textBuffer.append(processedString); - auto token = tokens.first(); - processedString.append(token); - m_isStartingLine = (token == "\n"); - tokens.removeFirst(); - } - - // Add data to saved text buffer - m_textBuffer.append(processedString); - - // Update UI - Q_EMIT dataReceived(); - Q_EMIT stringReceived(processedString); + // Update UI + Q_EMIT dataReceived(); + Q_EMIT stringReceived(processedString); } /** - * Displays the given @a data in the console. @c QByteArray to ~@c QString conversion is - * done by the @c dataToString() function, which displays incoming data either in UTF-8 - * or in hexadecimal mode. + * Displays the given @a data in the console. @c QByteArray to ~@c QString + * conversion is done by the @c dataToString() function, which displays incoming + * data either in UTF-8 or in hexadecimal mode. */ void IO::Console::onDataSent(const QByteArray &data) { - if (echo()) - append(dataToString(data) + "\n", showTimestamp()); + if (echo()) + append(dataToString(data) + "\n", showTimestamp()); } /** @@ -549,7 +558,7 @@ void IO::Console::onDataSent(const QByteArray &data) */ void IO::Console::onDataReceived(const QByteArray &data) { - append(dataToString(data), showTimestamp()); + append(dataToString(data), showTimestamp()); } /** @@ -557,14 +566,14 @@ void IO::Console::onDataReceived(const QByteArray &data) */ void IO::Console::addToHistory(const QString &command) { - // Remove old commands from history - while (m_historyItems.count() > 100) - m_historyItems.removeFirst(); + // Remove old commands from history + while (m_historyItems.count() > 100) + m_historyItems.removeFirst(); - // Register command - m_historyItems.append(command); - m_historyItem = m_historyItems.count(); - Q_EMIT historyItemChanged(); + // Register command + m_historyItems.append(command); + m_historyItem = m_historyItems.count(); + Q_EMIT historyItemChanged(); } /** @@ -572,39 +581,39 @@ void IO::Console::addToHistory(const QString &command) */ QByteArray IO::Console::hexToBytes(const QString &data) { - QString withoutSpaces = data; - withoutSpaces.replace(" ", ""); + QString withoutSpaces = data; + withoutSpaces.replace(" ", ""); - QByteArray array; - for (int i = 0; i < withoutSpaces.length(); i += 2) - { - auto chr1 = withoutSpaces.at(i); - auto chr2 = withoutSpaces.at(i + 1); - auto byte = QString("%1%2").arg(chr1, chr2).toInt(Q_NULLPTR, 16); - array.append(byte); - } + QByteArray array; + for (int i = 0; i < withoutSpaces.length(); i += 2) + { + auto chr1 = withoutSpaces.at(i); + auto chr2 = withoutSpaces.at(i + 1); + auto byte = QString("%1%2").arg(chr1, chr2).toInt(Q_NULLPTR, 16); + array.append(byte); + } - return array; + return array; } /** - * Converts the given @a data to a string according to the console display mode set by the - * user. + * Converts the given @a data to a string according to the console display mode + * set by the user. */ QString IO::Console::dataToString(const QByteArray &data) { - switch (displayMode()) - { - case DisplayMode::DisplayPlainText: - return plainTextStr(data); - break; - case DisplayMode::DisplayHexadecimal: - return hexadecimalStr(data); - break; - default: - return ""; - break; - } + switch (displayMode()) + { + case DisplayMode::DisplayPlainText: + return plainTextStr(data); + break; + case DisplayMode::DisplayHexadecimal: + return hexadecimalStr(data); + break; + default: + return ""; + break; + } } /** @@ -612,12 +621,12 @@ QString IO::Console::dataToString(const QByteArray &data) */ QString IO::Console::plainTextStr(const QByteArray &data) { - QString str = QString::fromUtf8(data); + QString str = QString::fromUtf8(data); - if (str.toUtf8() != data) - str = QString::fromLatin1(data); + if (str.toUtf8() != data) + str = QString::fromLatin1(data); - return str; + return str; } /** @@ -625,26 +634,22 @@ QString IO::Console::plainTextStr(const QByteArray &data) */ QString IO::Console::hexadecimalStr(const QByteArray &data) { - // Remove line breaks from data - QByteArray copy = data; + // Remove line breaks from data + QByteArray copy = data; - // Convert data to string with dump every ~80 chars - QString str; - const int characters = 80; - for (int i = 0; i < copy.length(); ++i) - { - QByteArray line; - for (int j = 0; j < qMin(characters, copy.length() - i); ++j) - line.append(copy.at(i + j)); + // Convert data to string with dump every ~80 chars + QString str; + const int characters = 80; + for (int i = 0; i < copy.length(); ++i) + { + QByteArray line; + for (int j = 0; j < qMin(characters, copy.length() - i); ++j) + line.append(copy.at(i + j)); - i += characters; - str.append(HexDump(line.data(), line.size())); - } + i += characters; + str.append(HexDump(line.data(), line.size())); + } - // Return string - return str; + // Return string + return str; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Console.cpp" -#endif diff --git a/src/IO/Console.h b/src/IO/Console.h index db83e394..081b9e7a 100644 --- a/src/IO/Console.h +++ b/src/IO/Console.h @@ -39,7 +39,7 @@ namespace IO */ class Console : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(bool echo READ echo @@ -71,110 +71,110 @@ class Console : public QObject Q_PROPERTY(QString currentHistoryString READ currentHistoryString NOTIFY historyItemChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void echoChanged(); - void dataReceived(); - void dataModeChanged(); - void autoscrollChanged(); - void lineEndingChanged(); - void displayModeChanged(); - void historyItemChanged(); - void textDocumentChanged(); - void showTimestampChanged(); - void stringReceived(const QString &text); + void echoChanged(); + void dataReceived(); + void dataModeChanged(); + void autoscrollChanged(); + void lineEndingChanged(); + void displayModeChanged(); + void historyItemChanged(); + void textDocumentChanged(); + void showTimestampChanged(); + void stringReceived(const QString &text); private: - explicit Console(); - Console(Console &&) = delete; - Console(const Console &) = delete; - Console &operator=(Console &&) = delete; - Console &operator=(const Console &) = delete; + explicit Console(); + Console(Console &&) = delete; + Console(const Console &) = delete; + Console &operator=(Console &&) = delete; + Console &operator=(const Console &) = delete; public: - enum class DisplayMode - { - DisplayPlainText, - DisplayHexadecimal - }; - Q_ENUM(DisplayMode) + enum class DisplayMode + { + DisplayPlainText, + DisplayHexadecimal + }; + Q_ENUM(DisplayMode) - enum class DataMode - { - DataUTF8, - DataHexadecimal - }; - Q_ENUM(DataMode) + enum class DataMode + { + DataUTF8, + DataHexadecimal + }; + Q_ENUM(DataMode) - enum class LineEnding - { - NoLineEnding, - NewLine, - CarriageReturn, - BothNewLineAndCarriageReturn - }; - Q_ENUM(LineEnding) + enum class LineEnding + { + NoLineEnding, + NewLine, + CarriageReturn, + BothNewLineAndCarriageReturn + }; + Q_ENUM(LineEnding) - static Console &instance(); + static Console &instance(); - bool echo() const; - bool autoscroll() const; - bool saveAvailable() const; - bool showTimestamp() const; + bool echo() const; + bool autoscroll() const; + bool saveAvailable() const; + bool showTimestamp() const; - DataMode dataMode() const; - LineEnding lineEnding() const; - DisplayMode displayMode() const; - QString currentHistoryString() const; + DataMode dataMode() const; + LineEnding lineEnding() const; + DisplayMode displayMode() const; + QString currentHistoryString() const; - Q_INVOKABLE StringList dataModes() const; - Q_INVOKABLE StringList lineEndings() const; - Q_INVOKABLE StringList displayModes() const; - Q_INVOKABLE QString formatUserHex(const QString &text); + Q_INVOKABLE StringList dataModes() const; + Q_INVOKABLE StringList lineEndings() const; + Q_INVOKABLE StringList displayModes() const; + Q_INVOKABLE QString formatUserHex(const QString &text); public Q_SLOTS: - void save(); - void clear(); - void historyUp(); - void historyDown(); - void send(const QString &data); - void setEcho(const bool enabled); - void print(const QString &fontFamily); - void setAutoscroll(const bool enabled); - void setShowTimestamp(const bool enabled); - void setDataMode(const IO::Console::DataMode &mode); - void setLineEnding(const IO::Console::LineEnding &mode); - void setDisplayMode(const IO::Console::DisplayMode &mode); - void append(const QString &str, const bool addTimestamp = false); + void save(); + void clear(); + void historyUp(); + void historyDown(); + void send(const QString &data); + void setEcho(const bool enabled); + void print(const QString &fontFamily); + void setAutoscroll(const bool enabled); + void setShowTimestamp(const bool enabled); + void setDataMode(const IO::Console::DataMode &mode); + void setLineEnding(const IO::Console::LineEnding &mode); + void setDisplayMode(const IO::Console::DisplayMode &mode); + void append(const QString &str, const bool addTimestamp = false); private Q_SLOTS: - void onDataSent(const QByteArray &data); - void addToHistory(const QString &command); - void onDataReceived(const QByteArray &data); + void onDataSent(const QByteArray &data); + void addToHistory(const QString &command); + void onDataReceived(const QByteArray &data); private: - QByteArray hexToBytes(const QString &data); - QString dataToString(const QByteArray &data); - QString plainTextStr(const QByteArray &data); - QString hexadecimalStr(const QByteArray &data); + QByteArray hexToBytes(const QString &data); + QString dataToString(const QByteArray &data); + QString plainTextStr(const QByteArray &data); + QString hexadecimalStr(const QByteArray &data); private: - DataMode m_dataMode; - LineEnding m_lineEnding; - DisplayMode m_displayMode; + DataMode m_dataMode; + LineEnding m_lineEnding; + DisplayMode m_displayMode; - int m_historyItem; + int m_historyItem; - bool m_echo; - bool m_autoscroll; - bool m_showTimestamp; - bool m_isStartingLine; + bool m_echo; + bool m_autoscroll; + bool m_showTimestamp; + bool m_isStartingLine; - StringList m_lines; - StringList m_historyItems; + StringList m_lines; + StringList m_historyItems; - QString m_printFont; - QString m_textBuffer; + QString m_printFont; + QString m_textBuffer; }; -} +} // namespace IO diff --git a/src/IO/Drivers/BluetoothLE.cpp b/src/IO/Drivers/BluetoothLE.cpp index 7830b8bd..eaf90b51 100644 --- a/src/IO/Drivers/BluetoothLE.cpp +++ b/src/IO/Drivers/BluetoothLE.cpp @@ -33,12 +33,12 @@ * Constructor function, configures the signals/slots of the BLE module */ IO::Drivers::BluetoothLE::BluetoothLE() - : m_deviceIndex(-1) - , m_deviceConnected(false) - , m_service(Q_NULLPTR) - , m_controller(Q_NULLPTR) + : m_deviceIndex(-1) + , m_deviceConnected(false) + , m_service(Q_NULLPTR) + , m_controller(Q_NULLPTR) { - // clang-format off + // clang-format off // Update connect button status when a BLE device is selected by the user connect(this, &IO::Drivers::BluetoothLE::deviceIndexChanged, @@ -66,7 +66,7 @@ IO::Drivers::BluetoothLE::BluetoothLE() this, &IO::Drivers::BluetoothLE::onDiscoveryError); #endif - // clang-format on + // clang-format on } /** @@ -74,8 +74,8 @@ IO::Drivers::BluetoothLE::BluetoothLE() */ IO::Drivers::BluetoothLE &IO::Drivers::BluetoothLE::instance() { - static BluetoothLE singleton; - return singleton; + static BluetoothLE singleton; + return singleton; } //---------------------------------------------------------------------------------------- @@ -84,115 +84,115 @@ IO::Drivers::BluetoothLE &IO::Drivers::BluetoothLE::instance() void IO::Drivers::BluetoothLE::close() { - // Clear services list & reset flags - m_serviceNames.clear(); - m_deviceConnected = false; + // Clear services list & reset flags + m_serviceNames.clear(); + m_deviceConnected = false; - // Delete previous service - if (m_service) - { - disconnect(m_service); - m_service->deleteLater(); - m_service = Q_NULLPTR; - } + // Delete previous service + if (m_service) + { + disconnect(m_service); + m_service->deleteLater(); + m_service = Q_NULLPTR; + } - // Delete previous controller - if (m_controller) - { - disconnect(m_controller); - m_controller->disconnectFromDevice(); - m_controller->deleteLater(); - m_controller = Q_NULLPTR; - } + // Delete previous controller + if (m_controller) + { + disconnect(m_controller); + m_controller->disconnectFromDevice(); + m_controller->deleteLater(); + m_controller = Q_NULLPTR; + } - // Update UI - Q_EMIT servicesChanged(); - Q_EMIT deviceConnectedChanged(); + // Update UI + Q_EMIT servicesChanged(); + Q_EMIT deviceConnectedChanged(); } bool IO::Drivers::BluetoothLE::isOpen() const { - return m_deviceConnected; + return m_deviceConnected; } bool IO::Drivers::BluetoothLE::isReadable() const { - return false; + return false; } bool IO::Drivers::BluetoothLE::isWritable() const { - return false; + return false; } bool IO::Drivers::BluetoothLE::configurationOk() const { - return operatingSystemSupported() && deviceIndex() >= 0; + return operatingSystemSupported() && deviceIndex() >= 0; } quint64 IO::Drivers::BluetoothLE::write(const QByteArray &data) { - // TODO - (void)data; - return -1; + // TODO + (void)data; + return -1; } bool IO::Drivers::BluetoothLE::open(const QIODevice::OpenMode mode) { - // I/O mode not used - (void)mode; + // I/O mode not used + (void)mode; - // Operating system not supported, abort process - if (!operatingSystemSupported()) - return false; + // Operating system not supported, abort process + if (!operatingSystemSupported()) + return false; - // Validar el indice del dispositivo - if (m_deviceIndex < 0 || m_deviceIndex >= m_devices.count()) - return false; + // Validar el indice del dispositivo + if (m_deviceIndex < 0 || m_deviceIndex >= m_devices.count()) + return false; - // Close previous device - close(); + // Close previous device + close(); - // Initialize a BLE controller for the current deveice - auto device = m_devices.at(m_deviceIndex); - m_controller = QLowEnergyController::createCentral(device, this); + // Initialize a BLE controller for the current deveice + auto device = m_devices.at(m_deviceIndex); + m_controller = QLowEnergyController::createCentral(device, this); - // Configure controller signals/slots - connect(m_controller, &QLowEnergyController::discoveryFinished, this, - &IO::Drivers::BluetoothLE::onServiceDiscoveryFinished); + // Configure controller signals/slots + connect(m_controller, &QLowEnergyController::discoveryFinished, this, + &IO::Drivers::BluetoothLE::onServiceDiscoveryFinished); - // React to connection event with BLE device - connect(m_controller, &QLowEnergyController::connected, this, [this]() { - m_deviceConnected = true; - m_controller->discoverServices(); - Q_EMIT deviceConnectedChanged(); - }); + // React to connection event with BLE device + connect(m_controller, &QLowEnergyController::connected, this, [this]() { + m_deviceConnected = true; + m_controller->discoverServices(); + Q_EMIT deviceConnectedChanged(); + }); - // React to disconnection event with BLE device - connect(m_controller, &QLowEnergyController::disconnected, this, [this]() { - if (m_service) - { - disconnect(m_service); - m_service->deleteLater(); - m_service = Q_NULLPTR; - } + // React to disconnection event with BLE device + connect(m_controller, &QLowEnergyController::disconnected, this, [this]() { + if (m_service) + { + disconnect(m_service); + m_service->deleteLater(); + m_service = Q_NULLPTR; + } - if (m_controller) - { - disconnect(m_controller); - m_controller->deleteLater(); - m_controller = Q_NULLPTR; - } + if (m_controller) + { + disconnect(m_controller); + m_controller->deleteLater(); + m_controller = Q_NULLPTR; + } - m_deviceConnected = false; + m_deviceConnected = false; - Q_EMIT deviceConnectedChanged(); - Q_EMIT error(tr("The BLE device has been disconnected")); - }); + Q_EMIT deviceConnectedChanged(); + Q_EMIT error(tr("The BLE device has been disconnected")); + }); - // Pair with the BLE device - m_controller->connectToDevice(); - return true; + // Pair with the BLE device + m_controller->connectToDevice(); + return true; } //---------------------------------------------------------------------------------------- @@ -204,7 +204,7 @@ bool IO::Drivers::BluetoothLE::open(const QIODevice::OpenMode mode) */ int IO::Drivers::BluetoothLE::deviceCount() const { - return m_devices.count(); + return m_devices.count(); } /** @@ -212,7 +212,7 @@ int IO::Drivers::BluetoothLE::deviceCount() const */ int IO::Drivers::BluetoothLE::deviceIndex() const { - return m_deviceIndex; + return m_deviceIndex; } /** @@ -220,10 +220,10 @@ int IO::Drivers::BluetoothLE::deviceIndex() const */ QStringList IO::Drivers::BluetoothLE::deviceNames() const { - QStringList list; - list.append(tr("Select device")); - list.append(m_deviceNames); - return list; + QStringList list; + list.append(tr("Select device")); + list.append(m_deviceNames); + return list; } /** @@ -231,10 +231,10 @@ QStringList IO::Drivers::BluetoothLE::deviceNames() const */ QStringList IO::Drivers::BluetoothLE::serviceNames() const { - QStringList list; - list.append(tr("Select service")); - list.append(m_serviceNames); - return list; + QStringList list; + list.append(tr("Select service")); + list.append(m_serviceNames); + return list; } /** @@ -244,13 +244,13 @@ QStringList IO::Drivers::BluetoothLE::serviceNames() const bool IO::Drivers::BluetoothLE::operatingSystemSupported() const { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -# if defined(Q_OS_MAC) - if (QOperatingSystemVersion::current() > QOperatingSystemVersion::MacOSBigSur) - return false; -# endif +# if defined(Q_OS_MAC) + if (QOperatingSystemVersion::current() > QOperatingSystemVersion::MacOSBigSur) + return false; +# endif #endif - return true; + return true; } /** @@ -258,77 +258,79 @@ bool IO::Drivers::BluetoothLE::operatingSystemSupported() const */ void IO::Drivers::BluetoothLE::startDiscovery() { - // Operating system not supported, abort process - if (!operatingSystemSupported()) - return; + // Operating system not supported, abort process + if (!operatingSystemSupported()) + return; - // Restore initial conditions - m_devices.clear(); - m_deviceIndex = -1; - m_deviceNames.clear(); + // Restore initial conditions + m_devices.clear(); + m_deviceIndex = -1; + m_deviceNames.clear(); - // Close previous device - close(); + // Close previous device + close(); - // Update UI - Q_EMIT devicesChanged(); - Q_EMIT deviceIndexChanged(); + // Update UI + Q_EMIT devicesChanged(); + Q_EMIT deviceIndexChanged(); - // Start device discovery process - m_discoveryAgent.start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); + // Start device discovery process + m_discoveryAgent.start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); } /** * Changes the index of the device selected by the user. * - * @note This function compensates for the added "Select device" element to the list of - * devices in @c deviceNames() so that the index corresponds to the elements of + * @note This function compensates for the added "Select device" element to the + * list of devices in @c deviceNames() so that the index corresponds to the + * elements of * @c m_deviceNames. */ void IO::Drivers::BluetoothLE::selectDevice(const int index) { - // Operating system not supported, abort process - if (!operatingSystemSupported()) - return; + // Operating system not supported, abort process + if (!operatingSystemSupported()) + return; - // Close current device - close(); + // Close current device + close(); - // Set new device index - m_deviceIndex = index - 1; - Q_EMIT deviceIndexChanged(); + // Set new device index + m_deviceIndex = index - 1; + Q_EMIT deviceIndexChanged(); } /** * Changes the index of the service selected by the user. * - * @note This function compensates for the added "Select service" element to the list of - * devices in @c serviceNames() so that the index corresponds to the elements of + * @note This function compensates for the added "Select service" element to the + * list of devices in @c serviceNames() so that the index corresponds to the + * elements of * @c m_serviceNames. */ void IO::Drivers::BluetoothLE::selectService(const int index) { - // Operating system not supported, abort process - if (!operatingSystemSupported()) - return; + // Operating system not supported, abort process + if (!operatingSystemSupported()) + return; - // Delete previous service + // Delete previous service + if (m_service) + { + disconnect(m_service); + m_service->deleteLater(); + m_service = Q_NULLPTR; + } + + // Ensure that index is valid + if (index >= 1 && index <= m_serviceNames.count()) + { + // Generate service handler & connect signals/slots + auto serviceUuid = m_controller->services().at(index - 1); + m_service = m_controller->createServiceObject(serviceUuid, this); if (m_service) { - disconnect(m_service); - m_service->deleteLater(); - m_service = Q_NULLPTR; - } - - // Ensure that index is valid - if (index >= 1 && index <= m_serviceNames.count()) - { - // Generate service handler & connect signals/slots - auto serviceUuid = m_controller->services().at(index - 1); - m_service = m_controller->createServiceObject(serviceUuid, this); - if (m_service) - { - // clang-format off + // clang-format off connect(m_service, &QLowEnergyService::characteristicChanged, this, &IO::Drivers::BluetoothLE::onCharacteristicChanged); connect(m_service, &QLowEnergyService::characteristicRead, this, @@ -337,83 +339,86 @@ void IO::Drivers::BluetoothLE::selectService(const int index) &IO::Drivers::BluetoothLE::onServiceStateChanged); connect(m_service, &QLowEnergyService::errorOccurred, this, &IO::Drivers::BluetoothLE::onServiceError); - // clang-format on + // clang-format on - if (m_service->state() == QLowEnergyService::RemoteService) - m_service->discoverDetails(); - else - configureCharacteristics(); - } - - // Service handler error - if (!m_service) - Q_EMIT error(tr("Error while configuring BLE service")); + if (m_service->state() == QLowEnergyService::RemoteService) + m_service->discoverDetails(); + else + configureCharacteristics(); } + + // Service handler error + if (!m_service) + Q_EMIT error(tr("Error while configuring BLE service")); + } } /** - * Sets the interaction options between each characteristic of the BLE device and the BLE - * module. + * Sets the interaction options between each characteristic of the BLE device + * and the BLE module. */ void IO::Drivers::BluetoothLE::configureCharacteristics() { - // Validate service pointer - if (!m_service) - return; + // Validate service pointer + if (!m_service) + return; - // Test & validate all service characteristics - foreach (QLowEnergyCharacteristic c, m_service->characteristics()) - { - // Validate characteristic - if (!c.isValid()) - continue; + // Test & validate all service characteristics + foreach (QLowEnergyCharacteristic c, m_service->characteristics()) + { + // Validate characteristic + if (!c.isValid()) + continue; - // Set client/descriptor connection properties - auto descriptor = c.clientCharacteristicConfiguration(); - if (descriptor.isValid()) - m_service->writeDescriptor(descriptor, QByteArray::fromHex("0100")); - } + // Set client/descriptor connection properties + auto descriptor = c.clientCharacteristicConfiguration(); + if (descriptor.isValid()) + m_service->writeDescriptor(descriptor, QByteArray::fromHex("0100")); + } } /** - * Generates a list with the UUIDs of the services available for the current BLE device. + * Generates a list with the UUIDs of the services available for the current BLE + * device. */ void IO::Drivers::BluetoothLE::onServiceDiscoveryFinished() { - // Validate BLE controller - if (!m_controller) - return; + // Validate BLE controller + if (!m_controller) + return; - // Generate services list - m_serviceNames.clear(); - for (auto i = 0; i < m_controller->services().count(); ++i) - m_serviceNames.append(m_controller->services().at(i).toString()); + // Generate services list + m_serviceNames.clear(); + for (auto i = 0; i < m_controller->services().count(); ++i) + m_serviceNames.append(m_controller->services().at(i).toString()); - // Update UI - Q_EMIT servicesChanged(); + // Update UI + Q_EMIT servicesChanged(); } /** * Registers the device (@c device) found in the list of BLE devices. */ -void IO::Drivers::BluetoothLE::onDeviceDiscovered(const QBluetoothDeviceInfo &device) +void IO::Drivers::BluetoothLE::onDeviceDiscovered( + const QBluetoothDeviceInfo &device) { - // Only register BLE devices - if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) + // Only register BLE devices + if (device.coreConfigurations() + & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) + { + // Validate device name (we don't want to show hidden devices...) + if (!device.isValid() || device.name().isEmpty()) + return; + + // Add the device to the list of found devices + if (!m_devices.contains(device) && !m_deviceNames.contains(device.name())) { - // Validate device name (we don't want to show hidden devices...) - if (!device.isValid() || device.name().isEmpty()) - return; + m_devices.append(device); + m_deviceNames.append(device.name()); - // Add the device to the list of found devices - if (!m_devices.contains(device) && !m_deviceNames.contains(device.name())) - { - m_devices.append(device); - m_deviceNames.append(device.name()); - - Q_EMIT devicesChanged(); - } + Q_EMIT devicesChanged(); } + } } /** @@ -422,66 +427,69 @@ void IO::Drivers::BluetoothLE::onDeviceDiscovered(const QBluetoothDeviceInfo &de void IO::Drivers::BluetoothLE::onServiceError( QLowEnergyService::ServiceError serviceError) { - switch (serviceError) - { - case QLowEnergyService::OperationError: - Q_EMIT error(tr("Operation error")); - break; - case QLowEnergyService::CharacteristicWriteError: - Q_EMIT error(tr("Characteristic write error")); - break; - case QLowEnergyService::DescriptorWriteError: - Q_EMIT error(tr("Descriptor write error")); - break; - case QLowEnergyService::UnknownError: - Q_EMIT error(tr("Unknown error")); - break; - case QLowEnergyService::CharacteristicReadError: - Q_EMIT error(tr("Characteristic read error")); - break; - case QLowEnergyService::DescriptorReadError: - Q_EMIT error(tr("Descriptor read error")); - break; - default: - break; - } + switch (serviceError) + { + case QLowEnergyService::OperationError: + Q_EMIT error(tr("Operation error")); + break; + case QLowEnergyService::CharacteristicWriteError: + Q_EMIT error(tr("Characteristic write error")); + break; + case QLowEnergyService::DescriptorWriteError: + Q_EMIT error(tr("Descriptor write error")); + break; + case QLowEnergyService::UnknownError: + Q_EMIT error(tr("Unknown error")); + break; + case QLowEnergyService::CharacteristicReadError: + Q_EMIT error(tr("Characteristic read error")); + break; + case QLowEnergyService::DescriptorReadError: + Q_EMIT error(tr("Descriptor read error")); + break; + default: + break; + } } /** - * Notifies the user of any errors detected in the Bluetooth adapter of the computer. + * Notifies the user of any errors detected in the Bluetooth adapter of the + * computer. */ -void IO::Drivers::BluetoothLE::onDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error e) +void IO::Drivers::BluetoothLE::onDiscoveryError( + QBluetoothDeviceDiscoveryAgent::Error e) { - switch (e) - { - case QBluetoothDeviceDiscoveryAgent::PoweredOffError: - Q_EMIT error(tr("Bluetooth adapter is off!")); - break; - case QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError: - Q_EMIT error(tr("Invalid Bluetooth adapter!")); - break; - case QBluetoothDeviceDiscoveryAgent::UnsupportedPlatformError: - Q_EMIT error(tr("Unsuported platform or operating system")); - break; - case QBluetoothDeviceDiscoveryAgent::UnsupportedDiscoveryMethod: - Q_EMIT error(tr("Unsupported discovery method")); - break; - case QBluetoothDeviceDiscoveryAgent::InputOutputError: - Q_EMIT error(tr("General I/O error")); - break; - default: - break; - } + switch (e) + { + case QBluetoothDeviceDiscoveryAgent::PoweredOffError: + Q_EMIT error(tr("Bluetooth adapter is off!")); + break; + case QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError: + Q_EMIT error(tr("Invalid Bluetooth adapter!")); + break; + case QBluetoothDeviceDiscoveryAgent::UnsupportedPlatformError: + Q_EMIT error(tr("Unsuported platform or operating system")); + break; + case QBluetoothDeviceDiscoveryAgent::UnsupportedDiscoveryMethod: + Q_EMIT error(tr("Unsupported discovery method")); + break; + case QBluetoothDeviceDiscoveryAgent::InputOutputError: + Q_EMIT error(tr("General I/O error")); + break; + default: + break; + } } /** - * Configures the characteristics of the services found on the paired BLE device. + * Configures the characteristics of the services found on the paired BLE + * device. */ void IO::Drivers::BluetoothLE::onServiceStateChanged( QLowEnergyService::ServiceState serviceState) { - if (serviceState == QLowEnergyService::RemoteServiceDiscovered) - configureCharacteristics(); + if (serviceState == QLowEnergyService::RemoteServiceDiscovered) + configureCharacteristics(); } /** @@ -490,10 +498,6 @@ void IO::Drivers::BluetoothLE::onServiceStateChanged( void IO::Drivers::BluetoothLE::onCharacteristicChanged( const QLowEnergyCharacteristic &info, const QByteArray &value) { - (void)info; - Q_EMIT dataReceived(value); + (void)info; + Q_EMIT dataReceived(value); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_BluetoothLE.cpp" -#endif diff --git a/src/IO/Drivers/BluetoothLE.h b/src/IO/Drivers/BluetoothLE.h index 968d4394..24744222 100644 --- a/src/IO/Drivers/BluetoothLE.h +++ b/src/IO/Drivers/BluetoothLE.h @@ -40,7 +40,7 @@ namespace Drivers */ class BluetoothLE : public HAL_Driver { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(int deviceCount READ deviceCount @@ -61,68 +61,68 @@ class BluetoothLE : public HAL_Driver Q_PROPERTY(bool operatingSystemSupported READ operatingSystemSupported CONSTANT) - // clang-format on + // clang-format on Q_SIGNALS: - void devicesChanged(); - void servicesChanged(); - void deviceIndexChanged(); - void deviceConnectedChanged(); - void error(const QString &message); + void devicesChanged(); + void servicesChanged(); + void deviceIndexChanged(); + void deviceConnectedChanged(); + void error(const QString &message); private: - explicit BluetoothLE(); - BluetoothLE(BluetoothLE &&) = delete; - BluetoothLE(const BluetoothLE &) = delete; - BluetoothLE &operator=(BluetoothLE &&) = delete; - BluetoothLE &operator=(const BluetoothLE &) = delete; + explicit BluetoothLE(); + BluetoothLE(BluetoothLE &&) = delete; + BluetoothLE(const BluetoothLE &) = delete; + BluetoothLE &operator=(BluetoothLE &&) = delete; + BluetoothLE &operator=(const BluetoothLE &) = delete; public: - static BluetoothLE &instance(); + static BluetoothLE &instance(); - // - // HAL functions - // - void close() override; - bool isOpen() const override; - bool isReadable() const override; - bool isWritable() const override; - bool configurationOk() const override; - quint64 write(const QByteArray &data) override; - bool open(const QIODevice::OpenMode mode) override; + // + // HAL functions + // + void close() override; + bool isOpen() const override; + bool isReadable() const override; + bool isWritable() const override; + bool configurationOk() const override; + quint64 write(const QByteArray &data) override; + bool open(const QIODevice::OpenMode mode) override; - int deviceCount() const; - int deviceIndex() const; - StringList deviceNames() const; - StringList serviceNames() const; - bool operatingSystemSupported() const; + int deviceCount() const; + int deviceIndex() const; + StringList deviceNames() const; + StringList serviceNames() const; + bool operatingSystemSupported() const; public Q_SLOTS: - void startDiscovery(); - void selectDevice(const int index); - void selectService(const int index); + void startDiscovery(); + void selectDevice(const int index); + void selectService(const int index); private Q_SLOTS: - void configureCharacteristics(); - void onServiceDiscoveryFinished(); - void onDeviceDiscovered(const QBluetoothDeviceInfo &device); - void onServiceError(QLowEnergyService::ServiceError serviceError); - void onDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error error); - void onServiceStateChanged(QLowEnergyService::ServiceState serviceState); - void onCharacteristicChanged(const QLowEnergyCharacteristic &info, - const QByteArray &value); + void configureCharacteristics(); + void onServiceDiscoveryFinished(); + void onDeviceDiscovered(const QBluetoothDeviceInfo &device); + void onServiceError(QLowEnergyService::ServiceError serviceError); + void onDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error error); + void onServiceStateChanged(QLowEnergyService::ServiceState serviceState); + void onCharacteristicChanged(const QLowEnergyCharacteristic &info, + const QByteArray &value); private: - int m_deviceIndex; - bool m_deviceConnected; + int m_deviceIndex; + bool m_deviceConnected; - QLowEnergyService *m_service; - QLowEnergyController *m_controller; + QLowEnergyService *m_service; + QLowEnergyController *m_controller; - StringList m_deviceNames; - StringList m_serviceNames; - QList m_devices; - QBluetoothDeviceDiscoveryAgent m_discoveryAgent; + StringList m_deviceNames; + StringList m_serviceNames; + QList m_devices; + QBluetoothDeviceDiscoveryAgent m_discoveryAgent; }; -} -} +} // namespace Drivers +} // namespace IO diff --git a/src/IO/Drivers/Network.cpp b/src/IO/Drivers/Network.cpp index 9eb4fbbd..36b99f0b 100644 --- a/src/IO/Drivers/Network.cpp +++ b/src/IO/Drivers/Network.cpp @@ -33,19 +33,19 @@ * Constructor function */ IO::Drivers::Network::Network() - : m_hostExists(false) - , m_udpMulticast(false) - , m_lookupActive(false) - , m_udpIgnoreFrameSequences(false) + : m_hostExists(false) + , m_udpMulticast(false) + , m_lookupActive(false) + , m_udpIgnoreFrameSequences(false) { - // Set initial configuration - setRemoteAddress(""); - setTcpPort(defaultTcpPort()); - setUdpLocalPort(defaultUdpLocalPort()); - setUdpRemotePort(defaultUdpRemotePort()); - setSocketType(QAbstractSocket::TcpSocket); + // Set initial configuration + setRemoteAddress(""); + setTcpPort(defaultTcpPort()); + setUdpLocalPort(defaultUdpLocalPort()); + setUdpRemotePort(defaultUdpRemotePort()); + setSocketType(QAbstractSocket::TcpSocket); - // clang-format off + // clang-format off // Update connect button status when the configuration is changed connect(this, &IO::Drivers::Network::addressChanged, @@ -68,7 +68,7 @@ IO::Drivers::Network::Network() this, &IO::Drivers::Network::onErrorOccurred); #endif - // clang-format on + // clang-format on } /** @@ -76,8 +76,8 @@ IO::Drivers::Network::Network() */ IO::Drivers::Network &IO::Drivers::Network::instance() { - static Network singleton; - return singleton; + static Network singleton; + return singleton; } //---------------------------------------------------------------------------------------- @@ -85,24 +85,24 @@ IO::Drivers::Network &IO::Drivers::Network::instance() //---------------------------------------------------------------------------------------- /** - * Closes the current network connection and discards signals/slots with the TCP/UDP - * socket in use by the network module. + * Closes the current network connection and discards signals/slots with the + * TCP/UDP socket in use by the network module. */ void IO::Drivers::Network::close() { - // Abort network connections - m_tcpSocket.abort(); - m_udpSocket.abort(); - m_tcpSocket.disconnectFromHost(); - m_udpSocket.disconnectFromHost(); + // Abort network connections + m_tcpSocket.abort(); + m_udpSocket.abort(); + m_tcpSocket.disconnectFromHost(); + m_udpSocket.disconnectFromHost(); - // Disconnect signals/slots - if (socketType() == QAbstractSocket::TcpSocket) - disconnect(&m_tcpSocket, &QTcpSocket::readyRead, this, - &IO::Drivers::Network::onReadyRead); - else if (socketType() == QAbstractSocket::UdpSocket) - disconnect(&m_udpSocket, &QUdpSocket::readyRead, this, - &IO::Drivers::Network::onReadyRead); + // Disconnect signals/slots + if (socketType() == QAbstractSocket::TcpSocket) + disconnect(&m_tcpSocket, &QTcpSocket::readyRead, this, + &IO::Drivers::Network::onReadyRead); + else if (socketType() == QAbstractSocket::UdpSocket) + disconnect(&m_udpSocket, &QUdpSocket::readyRead, this, + &IO::Drivers::Network::onReadyRead); } /** @@ -110,12 +110,12 @@ void IO::Drivers::Network::close() */ bool IO::Drivers::Network::isOpen() const { - if (socketType() == QAbstractSocket::UdpSocket) - return m_udpSocket.isOpen(); - else if (socketType() == QAbstractSocket::TcpSocket) - return m_tcpSocket.isOpen(); + if (socketType() == QAbstractSocket::UdpSocket) + return m_udpSocket.isOpen(); + else if (socketType() == QAbstractSocket::TcpSocket) + return m_tcpSocket.isOpen(); - return false; + return false; } /** @@ -123,12 +123,12 @@ bool IO::Drivers::Network::isOpen() const */ bool IO::Drivers::Network::isReadable() const { - if (socketType() == QAbstractSocket::UdpSocket) - return m_udpSocket.isReadable(); - else if (socketType() == QAbstractSocket::TcpSocket) - return m_tcpSocket.isReadable(); + if (socketType() == QAbstractSocket::UdpSocket) + return m_udpSocket.isReadable(); + else if (socketType() == QAbstractSocket::TcpSocket) + return m_tcpSocket.isReadable(); - return false; + return false; } /** @@ -136,12 +136,12 @@ bool IO::Drivers::Network::isReadable() const */ bool IO::Drivers::Network::isWritable() const { - if (socketType() == QAbstractSocket::UdpSocket) - return m_udpSocket.isWritable(); - else if (socketType() == QAbstractSocket::TcpSocket) - return m_tcpSocket.isWritable(); + if (socketType() == QAbstractSocket::UdpSocket) + return m_udpSocket.isWritable(); + else if (socketType() == QAbstractSocket::TcpSocket) + return m_tcpSocket.isWritable(); - return false; + return false; } /** @@ -149,81 +149,82 @@ bool IO::Drivers::Network::isWritable() const */ bool IO::Drivers::Network::configurationOk() const { - return tcpPort() > 0 && m_hostExists; + return tcpPort() > 0 && m_hostExists; } /** - * Writes the given @a data to the network device and returns the number of bytes written + * Writes the given @a data to the network device and returns the number of + * bytes written */ quint64 IO::Drivers::Network::write(const QByteArray &data) { - if (isWritable()) - { - if (socketType() == QAbstractSocket::UdpSocket) - return m_udpSocket.write(data); - else if (socketType() == QAbstractSocket::TcpSocket) - return m_tcpSocket.write(data); - } + if (isWritable()) + { + if (socketType() == QAbstractSocket::UdpSocket) + return m_udpSocket.write(data); + else if (socketType() == QAbstractSocket::TcpSocket) + return m_tcpSocket.write(data); + } - return -1; + return -1; } /** - * Attempts to make a connection to the given host, port and TCP/UDP socket type. - * Returns @c true on success, @c false on failure + * Attempts to make a connection to the given host, port and TCP/UDP socket + * type. Returns @c true on success, @c false on failure */ bool IO::Drivers::Network::open(const QIODevice::OpenMode mode) { - // Disconnect all sockets - close(); + // Disconnect all sockets + close(); - // Get host & port - auto hostAddr = remoteAddress(); - if (hostAddr.isEmpty()) - hostAddr = defaultAddress(); + // Get host & port + auto hostAddr = remoteAddress(); + if (hostAddr.isEmpty()) + hostAddr = defaultAddress(); - // Init socket pointer - QIODevice *socket = Q_NULLPTR; + // Init socket pointer + QIODevice *socket = Q_NULLPTR; - // TCP connection, assign socket pointer & connect to host - if (socketType() == QAbstractSocket::TcpSocket) - { - socket = static_cast(&m_tcpSocket); - m_tcpSocket.connectToHost(hostAddr, tcpPort()); - } + // TCP connection, assign socket pointer & connect to host + if (socketType() == QAbstractSocket::TcpSocket) + { + socket = static_cast(&m_tcpSocket); + m_tcpSocket.connectToHost(hostAddr, tcpPort()); + } - // UDP connection, assign socket pointer & bind to host - else if (socketType() == QAbstractSocket::UdpSocket) - { - // Bind the UDP socket - // clang-format off + // UDP connection, assign socket pointer & bind to host + else if (socketType() == QAbstractSocket::UdpSocket) + { + // Bind the UDP socket + // clang-format off m_udpSocket.bind(udpLocalPort(), QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint); - // clang-format on + // clang-format on - // Join the multicast group (if required) - if (udpMulticast()) - m_udpSocket.joinMulticastGroup(QHostAddress(m_address)); + // Join the multicast group (if required) + if (udpMulticast()) + m_udpSocket.joinMulticastGroup(QHostAddress(m_address)); - // Set socket pointer - socket = static_cast(&m_udpSocket); - } + // Set socket pointer + socket = static_cast(&m_udpSocket); + } - // Open network socket - if (socket) + // Open network socket + if (socket) + { + if (socket->open(mode)) { - if (socket->open(mode)) - { - connect(socket, &QIODevice::readyRead, this, - &IO::Drivers::Network::onReadyRead); - return true; - } + connect(socket, &QIODevice::readyRead, this, + &IO::Drivers::Network::onReadyRead); + return true; } + } - // Open failure, abort connection - close(); - return false; + // Open failure, abort connection + close(); + return false; } //---------------------------------------------------------------------------------------- @@ -235,7 +236,7 @@ bool IO::Drivers::Network::open(const QIODevice::OpenMode mode) */ QString IO::Drivers::Network::remoteAddress() const { - return m_address; + return m_address; } /** @@ -243,7 +244,7 @@ QString IO::Drivers::Network::remoteAddress() const */ quint16 IO::Drivers::Network::tcpPort() const { - return m_tcpPort; + return m_tcpPort; } /** @@ -251,7 +252,7 @@ quint16 IO::Drivers::Network::tcpPort() const */ quint16 IO::Drivers::Network::udpLocalPort() const { - return m_udpLocalPort; + return m_udpLocalPort; } /** @@ -259,7 +260,7 @@ quint16 IO::Drivers::Network::udpLocalPort() const */ quint16 IO::Drivers::Network::udpRemotePort() const { - return m_udpRemotePort; + return m_udpRemotePort; } /** @@ -268,7 +269,7 @@ quint16 IO::Drivers::Network::udpRemotePort() const */ bool IO::Drivers::Network::udpMulticast() const { - return m_udpMulticast; + return m_udpMulticast; } /** @@ -276,27 +277,27 @@ bool IO::Drivers::Network::udpMulticast() const */ bool IO::Drivers::Network::lookupActive() const { - return m_lookupActive; + return m_lookupActive; } /** - * Returns the current socket type as an index of the list returned by the @c socketType - * function. + * Returns the current socket type as an index of the list returned by the @c + * socketType function. */ int IO::Drivers::Network::socketTypeIndex() const { - switch (socketType()) - { - case QAbstractSocket::TcpSocket: - return 0; - break; - case QAbstractSocket::UdpSocket: - return 1; - break; - default: - return -1; - break; - } + switch (socketType()) + { + case QAbstractSocket::TcpSocket: + return 0; + break; + case QAbstractSocket::UdpSocket: + return 1; + break; + default: + return -1; + break; + } } /** @@ -304,7 +305,7 @@ int IO::Drivers::Network::socketTypeIndex() const */ StringList IO::Drivers::Network::socketTypes() const { - return StringList { "TCP", "UDP" }; + return StringList{"TCP", "UDP"}; } /** @@ -313,7 +314,7 @@ StringList IO::Drivers::Network::socketTypes() const */ bool IO::Drivers::Network::udpIgnoreFrameSequences() const { - return m_udpIgnoreFrameSequences; + return m_udpIgnoreFrameSequences; } /** @@ -326,7 +327,7 @@ bool IO::Drivers::Network::udpIgnoreFrameSequences() const */ QAbstractSocket::SocketType IO::Drivers::Network::socketType() const { - return m_socketType; + return m_socketType; } /** @@ -334,7 +335,7 @@ QAbstractSocket::SocketType IO::Drivers::Network::socketType() const */ void IO::Drivers::Network::setTcpSocket() { - setSocketType(QAbstractSocket::TcpSocket); + setSocketType(QAbstractSocket::TcpSocket); } /** @@ -342,7 +343,7 @@ void IO::Drivers::Network::setTcpSocket() */ void IO::Drivers::Network::setUdpSocket() { - setSocketType(QAbstractSocket::UdpSocket); + setSocketType(QAbstractSocket::UdpSocket); } /** @@ -350,8 +351,8 @@ void IO::Drivers::Network::setUdpSocket() */ void IO::Drivers::Network::setTcpPort(const quint16 port) { - m_tcpPort = port; - Q_EMIT portChanged(); + m_tcpPort = port; + Q_EMIT portChanged(); } /** @@ -359,8 +360,8 @@ void IO::Drivers::Network::setTcpPort(const quint16 port) */ void IO::Drivers::Network::setUdpLocalPort(const quint16 port) { - m_udpLocalPort = port; - Q_EMIT portChanged(); + m_udpLocalPort = port; + Q_EMIT portChanged(); } /** @@ -368,8 +369,8 @@ void IO::Drivers::Network::setUdpLocalPort(const quint16 port) */ void IO::Drivers::Network::setUdpRemotePort(const quint16 port) { - m_udpRemotePort = port; - Q_EMIT portChanged(); + m_udpRemotePort = port; + Q_EMIT portChanged(); } /** @@ -377,20 +378,20 @@ void IO::Drivers::Network::setUdpRemotePort(const quint16 port) */ void IO::Drivers::Network::setRemoteAddress(const QString &address) { - // Check if host name exists - if (QHostAddress(address).isNull()) - { - m_hostExists = false; - lookup(address); - } + // Check if host name exists + if (QHostAddress(address).isNull()) + { + m_hostExists = false; + lookup(address); + } - // Host is an IP address, host should exist - else - m_hostExists = true; + // Host is an IP address, host should exist + else + m_hostExists = true; - // Change host - m_address = address; - Q_EMIT addressChanged(); + // Change host + m_address = address; + Q_EMIT addressChanged(); } /** @@ -402,8 +403,8 @@ void IO::Drivers::Network::setRemoteAddress(const QString &address) */ void IO::Drivers::Network::setUdpIgnoreFrameSequences(const bool ignore) { - m_udpIgnoreFrameSequences = ignore; - Q_EMIT udpIgnoreFrameSequencesChanged(); + m_udpIgnoreFrameSequences = ignore; + Q_EMIT udpIgnoreFrameSequencesChanged(); } /** @@ -411,9 +412,10 @@ void IO::Drivers::Network::setUdpIgnoreFrameSequences(const bool ignore) */ void IO::Drivers::Network::lookup(const QString &host) { - m_lookupActive = true; - Q_EMIT lookupActiveChanged(); - QHostInfo::lookupHost(host.simplified(), this, &IO::Drivers::Network::lookupFinished); + m_lookupActive = true; + Q_EMIT lookupActiveChanged(); + QHostInfo::lookupHost(host.simplified(), this, + &IO::Drivers::Network::lookupFinished); } /** @@ -421,8 +423,8 @@ void IO::Drivers::Network::lookup(const QString &host) */ void IO::Drivers::Network::setUdpMulticast(const bool enabled) { - m_udpMulticast = enabled; - Q_EMIT udpMulticastChanged(); + m_udpMulticast = enabled; + Q_EMIT udpMulticastChanged(); } /** @@ -431,17 +433,17 @@ void IO::Drivers::Network::setUdpMulticast(const bool enabled) */ void IO::Drivers::Network::setSocketTypeIndex(const int index) { - switch (index) - { - case 0: - setTcpSocket(); - break; - case 1: - setUdpSocket(); - break; - default: - break; - } + switch (index) + { + case 0: + setTcpSocket(); + break; + case 1: + setUdpSocket(); + break; + default: + break; + } } /** @@ -453,8 +455,8 @@ void IO::Drivers::Network::setSocketTypeIndex(const int index) */ void IO::Drivers::Network::setSocketType(const QAbstractSocket::SocketType type) { - m_socketType = type; - Q_EMIT socketTypeChanged(); + m_socketType = type; + Q_EMIT socketTypeChanged(); } /** @@ -462,80 +464,79 @@ void IO::Drivers::Network::setSocketType(const QAbstractSocket::SocketType type) */ void IO::Drivers::Network::onReadyRead() { - // Initialize byte array - QByteArray data; + // Initialize byte array + QByteArray data; - // Check if we need to use UDP socket functions - if (socketType() == QAbstractSocket::UdpSocket) + // Check if we need to use UDP socket functions + if (socketType() == QAbstractSocket::UdpSocket) + { + while (udpSocket()->hasPendingDatagrams()) { - while (udpSocket()->hasPendingDatagrams()) - { - // Read datagram data - QByteArray datagram; - datagram.resize(int(udpSocket()->pendingDatagramSize())); - udpSocket()->readDatagram(datagram.data(), datagram.size()); + // Read datagram data + QByteArray datagram; + datagram.resize(int(udpSocket()->pendingDatagramSize())); + udpSocket()->readDatagram(datagram.data(), datagram.size()); - // Add datagram to data buffer - if (!udpIgnoreFrameSequences()) - { - data.append(datagram); - Q_EMIT dataReceived(data); - } - - // Ingore start/end sequences & process frame directly - else - IO::Manager::instance().processPayload(datagram); - } - } - - // We are using the TCP socket... - else if (socketType() == QAbstractSocket::TcpSocket) - { - data = tcpSocket()->readAll(); + // Add datagram to data buffer + if (!udpIgnoreFrameSequences()) + { + data.append(datagram); Q_EMIT dataReceived(data); + } + + // Ingore start/end sequences & process frame directly + else + IO::Manager::instance().processPayload(datagram); } + } + + // We are using the TCP socket... + else if (socketType() == QAbstractSocket::TcpSocket) + { + data = tcpSocket()->readAll(); + Q_EMIT dataReceived(data); + } } /** * Sets the host IP address when the lookup finishes. - * If the lookup fails, the error code/string shall be shown to the user in a messagebox. + * If the lookup fails, the error code/string shall be shown to the user in a + * messagebox. */ void IO::Drivers::Network::lookupFinished(const QHostInfo &info) { - m_lookupActive = false; + m_lookupActive = false; - if (info.error() == QHostInfo::NoError) + if (info.error() == QHostInfo::NoError) + { + auto addresses = info.addresses(); + if (addresses.count() >= 1) { - auto addresses = info.addresses(); - if (addresses.count() >= 1) - { - m_hostExists = true; - Q_EMIT addressChanged(); - return; - } + m_hostExists = true; + Q_EMIT addressChanged(); + return; } + } - Q_EMIT lookupActiveChanged(); + Q_EMIT lookupActiveChanged(); } /** - * This function is called whenever a socket error occurs, it disconnects the socket - * from the host and displays the error in a message box. + * This function is called whenever a socket error occurs, it disconnects the + * socket from the host and displays the error in a message box. */ -void IO::Drivers::Network::onErrorOccurred(const QAbstractSocket::SocketError socketError) +void IO::Drivers::Network::onErrorOccurred( + const QAbstractSocket::SocketError socketError) { - QString error; - if (socketType() == QAbstractSocket::TcpSocket) - error = m_tcpSocket.errorString(); - else if (socketType() == QAbstractSocket::UdpSocket) - error = m_udpSocket.errorString(); - else - error = QString::number(socketError); + QString error; + if (socketType() == QAbstractSocket::TcpSocket) + error = m_tcpSocket.errorString(); + else if (socketType() == QAbstractSocket::UdpSocket) + error = m_udpSocket.errorString(); + else + error = QString::number(socketError); - Manager::instance().disconnectDriver(); - Misc::Utilities::showMessageBox(tr("Network socket error"), error); + Manager::instance().disconnectDriver(); + Misc::Utilities::showMessageBox(tr("Network socket error"), error); } -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Network.cpp" -#endif diff --git a/src/IO/Drivers/Network.h b/src/IO/Drivers/Network.h index f150bd30..d3ac0115 100644 --- a/src/IO/Drivers/Network.h +++ b/src/IO/Drivers/Network.h @@ -43,7 +43,7 @@ namespace Drivers */ class Network : public HAL_Driver { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(QString remoteAddress READ remoteAddress @@ -95,89 +95,89 @@ class Network : public HAL_Driver READ udpIgnoreFrameSequences WRITE setUdpIgnoreFrameSequences NOTIFY udpIgnoreFrameSequencesChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void portChanged(); - void addressChanged(); - void socketTypeChanged(); - void udpMulticastChanged(); - void lookupActiveChanged(); - void udpIgnoreFrameSequencesChanged(); + void portChanged(); + void addressChanged(); + void socketTypeChanged(); + void udpMulticastChanged(); + void lookupActiveChanged(); + void udpIgnoreFrameSequencesChanged(); private: - explicit Network(); - Network(Network &&) = delete; - Network(const Network &) = delete; - Network &operator=(Network &&) = delete; - Network &operator=(const Network &) = delete; + explicit Network(); + Network(Network &&) = delete; + Network(const Network &) = delete; + Network &operator=(Network &&) = delete; + Network &operator=(const Network &) = delete; public: - static Network &instance(); + static Network &instance(); - // - // HAL functions - // - void close() override; - bool isOpen() const override; - bool isReadable() const override; - bool isWritable() const override; - bool configurationOk() const override; - quint64 write(const QByteArray &data) override; - bool open(const QIODevice::OpenMode mode) override; + // + // HAL functions + // + void close() override; + bool isOpen() const override; + bool isReadable() const override; + bool isWritable() const override; + bool configurationOk() const override; + quint64 write(const QByteArray &data) override; + bool open(const QIODevice::OpenMode mode) override; - QString remoteAddress() const; + QString remoteAddress() const; - quint16 tcpPort() const; - quint16 udpLocalPort() const; - quint16 udpRemotePort() const; + quint16 tcpPort() const; + quint16 udpLocalPort() const; + quint16 udpRemotePort() const; - bool udpMulticast() const; - bool lookupActive() const; - int socketTypeIndex() const; - StringList socketTypes() const; - bool udpIgnoreFrameSequences() const; - QAbstractSocket::SocketType socketType() const; + bool udpMulticast() const; + bool lookupActive() const; + int socketTypeIndex() const; + StringList socketTypes() const; + bool udpIgnoreFrameSequences() const; + QAbstractSocket::SocketType socketType() const; - QTcpSocket *tcpSocket() { return &m_tcpSocket; } - QUdpSocket *udpSocket() { return &m_udpSocket; } + QTcpSocket *tcpSocket() { return &m_tcpSocket; } + QUdpSocket *udpSocket() { return &m_udpSocket; } - static QString defaultAddress() { return "127.0.0.1"; } - static quint16 defaultTcpPort() { return 23; } - static quint16 defaultUdpLocalPort() { return 0; } - static quint16 defaultUdpRemotePort() { return 53; } + static QString defaultAddress() { return "127.0.0.1"; } + static quint16 defaultTcpPort() { return 23; } + static quint16 defaultUdpLocalPort() { return 0; } + static quint16 defaultUdpRemotePort() { return 53; } public Q_SLOTS: - void setTcpSocket(); - void setUdpSocket(); - void lookup(const QString &host); - void setTcpPort(const quint16 port); - void setUdpLocalPort(const quint16 port); - void setUdpMulticast(const bool enabled); - void setSocketTypeIndex(const int index); - void setUdpRemotePort(const quint16 port); - void setRemoteAddress(const QString &address); - void setUdpIgnoreFrameSequences(const bool ignore); - void setSocketType(const QAbstractSocket::SocketType type); + void setTcpSocket(); + void setUdpSocket(); + void lookup(const QString &host); + void setTcpPort(const quint16 port); + void setUdpLocalPort(const quint16 port); + void setUdpMulticast(const bool enabled); + void setSocketTypeIndex(const int index); + void setUdpRemotePort(const quint16 port); + void setRemoteAddress(const QString &address); + void setUdpIgnoreFrameSequences(const bool ignore); + void setSocketType(const QAbstractSocket::SocketType type); private Q_SLOTS: - void onReadyRead(); - void lookupFinished(const QHostInfo &info); - void onErrorOccurred(const QAbstractSocket::SocketError socketError); + void onReadyRead(); + void lookupFinished(const QHostInfo &info); + void onErrorOccurred(const QAbstractSocket::SocketError socketError); private: - QString m_address; - quint16 m_tcpPort; - bool m_hostExists; - bool m_udpMulticast; - bool m_lookupActive; - quint16 m_udpLocalPort; - quint16 m_udpRemotePort; - bool m_udpIgnoreFrameSequences; - QAbstractSocket::SocketType m_socketType; + QString m_address; + quint16 m_tcpPort; + bool m_hostExists; + bool m_udpMulticast; + bool m_lookupActive; + quint16 m_udpLocalPort; + quint16 m_udpRemotePort; + bool m_udpIgnoreFrameSequences; + QAbstractSocket::SocketType m_socketType; - QTcpSocket m_tcpSocket; - QUdpSocket m_udpSocket; + QTcpSocket m_tcpSocket; + QUdpSocket m_udpSocket; }; -} -} +} // namespace Drivers +} // namespace IO diff --git a/src/IO/Drivers/Serial.cpp b/src/IO/Drivers/Serial.cpp index e90bd98f..4ce11956 100644 --- a/src/IO/Drivers/Serial.cpp +++ b/src/IO/Drivers/Serial.cpp @@ -34,23 +34,23 @@ * Constructor function */ IO::Drivers::Serial::Serial() - : m_port(Q_NULLPTR) - , m_autoReconnect(false) - , m_lastSerialDeviceIndex(0) - , m_portIndex(0) + : m_port(Q_NULLPTR) + , m_autoReconnect(false) + , m_lastSerialDeviceIndex(0) + , m_portIndex(0) { - // Read settings - readSettings(); + // Read settings + readSettings(); - // Init serial port configuration variables - setBaudRate(9600); - disconnectDevice(); - setDataBits(dataBitsList().indexOf("8")); - setStopBits(stopBitsList().indexOf("1")); - setParity(parityList().indexOf(tr("None"))); - setFlowControl(flowControlList().indexOf(tr("None"))); + // Init serial port configuration variables + setBaudRate(9600); + disconnectDevice(); + setDataBits(dataBitsList().indexOf("8")); + setStopBits(stopBitsList().indexOf("1")); + setParity(parityList().indexOf(tr("None"))); + setFlowControl(flowControlList().indexOf(tr("None"))); - // clang-format off + // clang-format off // Build serial devices list and refresh it every second connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout1Hz, @@ -60,19 +60,19 @@ IO::Drivers::Serial::Serial() connect(this, &IO::Drivers::Serial::portIndexChanged, this, &IO::Drivers::Serial::configurationChanged); - // clang-format on + // clang-format on } /** - * Destructor function, closes the serial port before exiting the application and saves - * the user's baud rate list settings. + * Destructor function, closes the serial port before exiting the application + * and saves the user's baud rate list settings. */ IO::Drivers::Serial::~Serial() { - writeSettings(); + writeSettings(); - if (port()) - disconnectDevice(); + if (port()) + disconnectDevice(); } /** @@ -80,8 +80,8 @@ IO::Drivers::Serial::~Serial() */ IO::Drivers::Serial &IO::Drivers::Serial::instance() { - static Serial singleton; - return singleton; + static Serial singleton; + return singleton; } //---------------------------------------------------------------------------------------- @@ -93,8 +93,8 @@ IO::Drivers::Serial &IO::Drivers::Serial::instance() */ void IO::Drivers::Serial::close() { - if (isOpen()) - port()->close(); + if (isOpen()) + port()->close(); } /** @@ -102,10 +102,10 @@ void IO::Drivers::Serial::close() */ bool IO::Drivers::Serial::isOpen() const { - if (port()) - return port()->isOpen(); + if (port()) + return port()->isOpen(); - return false; + return false; } /** @@ -113,10 +113,10 @@ bool IO::Drivers::Serial::isOpen() const */ bool IO::Drivers::Serial::isReadable() const { - if (isOpen()) - return port()->isReadable(); + if (isOpen()) + return port()->isReadable(); - return false; + return false; } /** @@ -124,74 +124,76 @@ bool IO::Drivers::Serial::isReadable() const */ bool IO::Drivers::Serial::isWritable() const { - if (isOpen()) - return port()->isWritable(); + if (isOpen()) + return port()->isWritable(); - return false; + return false; } /** - * Returns @c true if the user selects the appropiate controls & options to be able - * to connect to a serial device + * Returns @c true if the user selects the appropiate controls & options to be + * able to connect to a serial device */ bool IO::Drivers::Serial::configurationOk() const { - return portIndex() > 0; + return portIndex() > 0; } /** - * Writes the given @a data to the serial device and returns the number of bytes written + * Writes the given @a data to the serial device and returns the number of bytes + * written */ quint64 IO::Drivers::Serial::write(const QByteArray &data) { - if (isWritable()) - return port()->write(data); + if (isWritable()) + return port()->write(data); - return -1; + return -1; } /** - * Connects to the currently selected serial port device, returns @c true on success + * Connects to the currently selected serial port device, returns @c true on + * success */ bool IO::Drivers::Serial::open(const QIODevice::OpenMode mode) { - // Ignore the first item of the list (Select Port) - auto ports = validPorts(); - auto portId = portIndex() - 1; - if (portId >= 0 && portId < validPorts().count()) - { - // Update port index variable & disconnect from current serial port - disconnectDevice(); - m_portIndex = portId + 1; - m_lastSerialDeviceIndex = m_portIndex; - Q_EMIT portIndexChanged(); - - // Create new serial port handler - m_port = new QSerialPort(ports.at(portId)); - - // Configure serial port - port()->setParity(parity()); - port()->setBaudRate(baudRate()); - port()->setDataBits(dataBits()); - port()->setStopBits(stopBits()); - port()->setFlowControl(flowControl()); - - // Connect signals/slots - connect(port(), SIGNAL(errorOccurred(QSerialPort::SerialPortError)), this, - SLOT(handleError(QSerialPort::SerialPortError))); - - // Open device - if (port()->open(mode)) - { - connect(port(), &QIODevice::readyRead, this, - &IO::Drivers::Serial::onReadyRead); - return true; - } - } - - // Disconnect serial port + // Ignore the first item of the list (Select Port) + auto ports = validPorts(); + auto portId = portIndex() - 1; + if (portId >= 0 && portId < validPorts().count()) + { + // Update port index variable & disconnect from current serial port disconnectDevice(); - return false; + m_portIndex = portId + 1; + m_lastSerialDeviceIndex = m_portIndex; + Q_EMIT portIndexChanged(); + + // Create new serial port handler + m_port = new QSerialPort(ports.at(portId)); + + // Configure serial port + port()->setParity(parity()); + port()->setBaudRate(baudRate()); + port()->setDataBits(dataBits()); + port()->setStopBits(stopBits()); + port()->setFlowControl(flowControl()); + + // Connect signals/slots + connect(port(), SIGNAL(errorOccurred(QSerialPort::SerialPortError)), this, + SLOT(handleError(QSerialPort::SerialPortError))); + + // Open device + if (port()->open(mode)) + { + connect(port(), &QIODevice::readyRead, this, + &IO::Drivers::Serial::onReadyRead); + return true; + } + } + + // Disconnect serial port + disconnectDevice(); + return false; } //---------------------------------------------------------------------------------------- @@ -203,10 +205,10 @@ bool IO::Drivers::Serial::open(const QIODevice::OpenMode mode) */ QString IO::Drivers::Serial::portName() const { - if (port()) - return port()->portName(); + if (port()) + return port()->portName(); - return tr("No Device"); + return tr("No Device"); } /** @@ -214,7 +216,7 @@ QString IO::Drivers::Serial::portName() const */ QSerialPort *IO::Drivers::Serial::port() const { - return m_port; + return m_port; } /** @@ -222,7 +224,7 @@ QSerialPort *IO::Drivers::Serial::port() const */ bool IO::Drivers::Serial::autoReconnect() const { - return m_autoReconnect; + return m_autoReconnect; } /** @@ -230,7 +232,7 @@ bool IO::Drivers::Serial::autoReconnect() const */ quint8 IO::Drivers::Serial::portIndex() const { - return m_portIndex; + return m_portIndex; } /** @@ -239,7 +241,7 @@ quint8 IO::Drivers::Serial::portIndex() const */ quint8 IO::Drivers::Serial::parityIndex() const { - return m_parityIndex; + return m_parityIndex; } /** @@ -248,7 +250,7 @@ quint8 IO::Drivers::Serial::parityIndex() const */ quint8 IO::Drivers::Serial::dataBitsIndex() const { - return m_dataBitsIndex; + return m_dataBitsIndex; } /** @@ -257,7 +259,7 @@ quint8 IO::Drivers::Serial::dataBitsIndex() const */ quint8 IO::Drivers::Serial::stopBitsIndex() const { - return m_stopBitsIndex; + return m_stopBitsIndex; } /** @@ -266,7 +268,7 @@ quint8 IO::Drivers::Serial::stopBitsIndex() const */ quint8 IO::Drivers::Serial::flowControlIndex() const { - return m_flowControlIndex; + return m_flowControlIndex; } /** @@ -279,7 +281,7 @@ quint8 IO::Drivers::Serial::flowControlIndex() const */ StringList IO::Drivers::Serial::portList() const { - return m_portList; + return m_portList; } /** @@ -288,13 +290,13 @@ StringList IO::Drivers::Serial::portList() const */ StringList IO::Drivers::Serial::parityList() const { - StringList list; - list.append(tr("None")); - list.append(tr("Even")); - list.append(tr("Odd")); - list.append(tr("Space")); - list.append(tr("Mark")); - return list; + StringList list; + list.append(tr("None")); + list.append(tr("Even")); + list.append(tr("Odd")); + list.append(tr("Space")); + list.append(tr("Mark")); + return list; } /** @@ -303,7 +305,7 @@ StringList IO::Drivers::Serial::parityList() const */ StringList IO::Drivers::Serial::baudRateList() const { - return m_baudRateList; + return m_baudRateList; } /** @@ -312,7 +314,7 @@ StringList IO::Drivers::Serial::baudRateList() const */ StringList IO::Drivers::Serial::dataBitsList() const { - return StringList { "5", "6", "7", "8" }; + return StringList{"5", "6", "7", "8"}; } /** @@ -321,7 +323,7 @@ StringList IO::Drivers::Serial::dataBitsList() const */ StringList IO::Drivers::Serial::stopBitsList() const { - return StringList { "1", "1.5", "2" }; + return StringList{"1", "1.5", "2"}; } /** @@ -330,11 +332,11 @@ StringList IO::Drivers::Serial::stopBitsList() const */ StringList IO::Drivers::Serial::flowControlList() const { - StringList list; - list.append(tr("None")); - list.append("RTS/CTS"); - list.append("XON/XOFF"); - return list; + StringList list; + list.append(tr("None")); + list.append("RTS/CTS"); + list.append("XON/XOFF"); + return list; } /** @@ -343,7 +345,7 @@ StringList IO::Drivers::Serial::flowControlList() const */ QSerialPort::Parity IO::Drivers::Serial::parity() const { - return m_parity; + return m_parity; } /** @@ -352,7 +354,7 @@ QSerialPort::Parity IO::Drivers::Serial::parity() const */ qint32 IO::Drivers::Serial::baudRate() const { - return m_baudRate; + return m_baudRate; } /** @@ -361,7 +363,7 @@ qint32 IO::Drivers::Serial::baudRate() const */ QSerialPort::DataBits IO::Drivers::Serial::dataBits() const { - return m_dataBits; + return m_dataBits; } /** @@ -370,7 +372,7 @@ QSerialPort::DataBits IO::Drivers::Serial::dataBits() const */ QSerialPort::StopBits IO::Drivers::Serial::stopBits() const { - return m_stopBits; + return m_stopBits; } /** @@ -379,7 +381,7 @@ QSerialPort::StopBits IO::Drivers::Serial::stopBits() const */ QSerialPort::FlowControl IO::Drivers::Serial::flowControl() const { - return m_flowControl; + return m_flowControl; } /** @@ -387,22 +389,22 @@ QSerialPort::FlowControl IO::Drivers::Serial::flowControl() const */ void IO::Drivers::Serial::disconnectDevice() { - // Check if serial port pointer is valid - if (port() != Q_NULLPTR) - { - // Disconnect signals/slots - port()->disconnect(this, SLOT(onReadyRead())); - port()->disconnect(this, SLOT(handleError(QSerialPort::SerialPortError))); + // Check if serial port pointer is valid + if (port() != Q_NULLPTR) + { + // Disconnect signals/slots + port()->disconnect(this, SLOT(onReadyRead())); + port()->disconnect(this, SLOT(handleError(QSerialPort::SerialPortError))); - // Close & delete serial port handler - port()->close(); - port()->deleteLater(); - } + // Close & delete serial port handler + port()->close(); + port()->deleteLater(); + } - // Reset pointer - m_port = Q_NULLPTR; - Q_EMIT portChanged(); - Q_EMIT availablePortsChanged(); + // Reset pointer + m_port = Q_NULLPTR; + Q_EMIT portChanged(); + Q_EMIT availablePortsChanged(); } /** @@ -410,33 +412,33 @@ void IO::Drivers::Serial::disconnectDevice() */ void IO::Drivers::Serial::setBaudRate(const qint32 rate) { - // Asserts - Q_ASSERT(rate > 10); + // Asserts + Q_ASSERT(rate > 10); - // Update baud rate - m_baudRate = rate; + // Update baud rate + m_baudRate = rate; - // Update serial port config - if (port()) - port()->setBaudRate(baudRate()); + // Update serial port config + if (port()) + port()->setBaudRate(baudRate()); - // Update user interface - Q_EMIT baudRateChanged(); + // Update user interface + Q_EMIT baudRateChanged(); } /** - * Changes the port index value, this value is later used by the @c openSerialPort() - * function. + * Changes the port index value, this value is later used by the @c + * openSerialPort() function. */ void IO::Drivers::Serial::setPortIndex(const quint8 portIndex) { - auto portId = portIndex - 1; - if (portId >= 0 && portId < validPorts().count()) - m_portIndex = portIndex; - else - m_portIndex = 0; + auto portId = portIndex - 1; + if (portId >= 0 && portId < validPorts().count()) + m_portIndex = portIndex; + else + m_portIndex = 0; - Q_EMIT portIndexChanged(); + Q_EMIT portIndexChanged(); } /** @@ -445,38 +447,38 @@ void IO::Drivers::Serial::setPortIndex(const quint8 portIndex) */ void IO::Drivers::Serial::setParity(const quint8 parityIndex) { - // Argument verification - Q_ASSERT(parityIndex < parityList().count()); + // Argument verification + Q_ASSERT(parityIndex < parityList().count()); - // Update current index - m_parityIndex = parityIndex; + // Update current index + m_parityIndex = parityIndex; - // Set parity based on current index - switch (parityIndex) - { - case 0: - m_parity = QSerialPort::NoParity; - break; - case 1: - m_parity = QSerialPort::EvenParity; - break; - case 2: - m_parity = QSerialPort::OddParity; - break; - case 3: - m_parity = QSerialPort::SpaceParity; - break; - case 4: - m_parity = QSerialPort::MarkParity; - break; - } + // Set parity based on current index + switch (parityIndex) + { + case 0: + m_parity = QSerialPort::NoParity; + break; + case 1: + m_parity = QSerialPort::EvenParity; + break; + case 2: + m_parity = QSerialPort::OddParity; + break; + case 3: + m_parity = QSerialPort::SpaceParity; + break; + case 4: + m_parity = QSerialPort::MarkParity; + break; + } - // Update serial port config. - if (port()) - port()->setParity(parity()); + // Update serial port config. + if (port()) + port()->setParity(parity()); - // Notify user interface - Q_EMIT parityChanged(); + // Notify user interface + Q_EMIT parityChanged(); } /** @@ -484,15 +486,15 @@ void IO::Drivers::Serial::setParity(const quint8 parityIndex) */ void IO::Drivers::Serial::appendBaudRate(const QString &baudRate) { - if (!m_baudRateList.contains(baudRate)) - { - m_baudRateList.append(baudRate); - writeSettings(); - Q_EMIT baudRateListChanged(); - Misc::Utilities::showMessageBox( - tr("Baud rate registered successfully"), - tr("Rate \"%1\" has been added to baud rate list").arg(baudRate)); - } + if (!m_baudRateList.contains(baudRate)) + { + m_baudRateList.append(baudRate); + writeSettings(); + Q_EMIT baudRateListChanged(); + Misc::Utilities::showMessageBox( + tr("Baud rate registered successfully"), + tr("Rate \"%1\" has been added to baud rate list").arg(baudRate)); + } } /** @@ -503,35 +505,35 @@ void IO::Drivers::Serial::appendBaudRate(const QString &baudRate) */ void IO::Drivers::Serial::setDataBits(const quint8 dataBitsIndex) { - // Argument verification - Q_ASSERT(dataBitsIndex < dataBitsList().count()); + // Argument verification + Q_ASSERT(dataBitsIndex < dataBitsList().count()); - // Update current index - m_dataBitsIndex = dataBitsIndex; + // Update current index + m_dataBitsIndex = dataBitsIndex; - // Obtain data bits value from current index - switch (dataBitsIndex) - { - case 0: - m_dataBits = QSerialPort::Data5; - break; - case 1: - m_dataBits = QSerialPort::Data6; - break; - case 2: - m_dataBits = QSerialPort::Data7; - break; - case 3: - m_dataBits = QSerialPort::Data8; - break; - } + // Obtain data bits value from current index + switch (dataBitsIndex) + { + case 0: + m_dataBits = QSerialPort::Data5; + break; + case 1: + m_dataBits = QSerialPort::Data6; + break; + case 2: + m_dataBits = QSerialPort::Data7; + break; + case 3: + m_dataBits = QSerialPort::Data8; + break; + } - // Update serial port configuration - if (port()) - port()->setDataBits(dataBits()); + // Update serial port configuration + if (port()) + port()->setDataBits(dataBits()); - // Update user interface - Q_EMIT dataBitsChanged(); + // Update user interface + Q_EMIT dataBitsChanged(); } /** @@ -542,32 +544,32 @@ void IO::Drivers::Serial::setDataBits(const quint8 dataBitsIndex) */ void IO::Drivers::Serial::setStopBits(const quint8 stopBitsIndex) { - // Argument verification - Q_ASSERT(stopBitsIndex < stopBitsList().count()); + // Argument verification + Q_ASSERT(stopBitsIndex < stopBitsList().count()); - // Update current index - m_stopBitsIndex = stopBitsIndex; + // Update current index + m_stopBitsIndex = stopBitsIndex; - // Obtain stop bits value from current index - switch (stopBitsIndex) - { - case 0: - m_stopBits = QSerialPort::OneStop; - break; - case 1: - m_stopBits = QSerialPort::OneAndHalfStop; - break; - case 2: - m_stopBits = QSerialPort::TwoStop; - break; - } + // Obtain stop bits value from current index + switch (stopBitsIndex) + { + case 0: + m_stopBits = QSerialPort::OneStop; + break; + case 1: + m_stopBits = QSerialPort::OneAndHalfStop; + break; + case 2: + m_stopBits = QSerialPort::TwoStop; + break; + } - // Update serial port configuration - if (port()) - port()->setStopBits(stopBits()); + // Update serial port configuration + if (port()) + port()->setStopBits(stopBits()); - // Update user interface - Q_EMIT stopBitsChanged(); + // Update user interface + Q_EMIT stopBitsChanged(); } /** @@ -575,8 +577,8 @@ void IO::Drivers::Serial::setStopBits(const quint8 stopBitsIndex) */ void IO::Drivers::Serial::setAutoReconnect(const bool autoreconnect) { - m_autoReconnect = autoreconnect; - Q_EMIT autoReconnectChanged(); + m_autoReconnect = autoreconnect; + Q_EMIT autoReconnectChanged(); } /** @@ -587,32 +589,32 @@ void IO::Drivers::Serial::setAutoReconnect(const bool autoreconnect) */ void IO::Drivers::Serial::setFlowControl(const quint8 flowControlIndex) { - // Argument verification - Q_ASSERT(flowControlIndex < flowControlList().count()); + // Argument verification + Q_ASSERT(flowControlIndex < flowControlList().count()); - // Update current index - m_flowControlIndex = flowControlIndex; + // Update current index + m_flowControlIndex = flowControlIndex; - // Obtain flow control value from current index - switch (flowControlIndex) - { - case 0: - m_flowControl = QSerialPort::NoFlowControl; - break; - case 1: - m_flowControl = QSerialPort::HardwareControl; - break; - case 2: - m_flowControl = QSerialPort::SoftwareControl; - break; - } + // Obtain flow control value from current index + switch (flowControlIndex) + { + case 0: + m_flowControl = QSerialPort::NoFlowControl; + break; + case 1: + m_flowControl = QSerialPort::HardwareControl; + break; + case 2: + m_flowControl = QSerialPort::SoftwareControl; + break; + } - // Update serial port configuration - if (port()) - port()->setFlowControl(flowControl()); + // Update serial port configuration + if (port()) + port()->setFlowControl(flowControl()); - // Update user interface - Q_EMIT flowControlChanged(); + // Update user interface + Q_EMIT flowControlChanged(); } /** @@ -621,56 +623,56 @@ void IO::Drivers::Serial::setFlowControl(const quint8 flowControlIndex) */ void IO::Drivers::Serial::refreshSerialDevices() { - // Create device list, starting with dummy header - // (for a more friendly UI when no devices are attached) - StringList ports; - ports.append(tr("Select port")); + // Create device list, starting with dummy header + // (for a more friendly UI when no devices are attached) + StringList ports; + ports.append(tr("Select port")); - // Search for available ports and add them to the lsit - auto validPortList = validPorts(); - Q_FOREACH (QSerialPortInfo info, validPortList) + // Search for available ports and add them to the lsit + auto validPortList = validPorts(); + Q_FOREACH (QSerialPortInfo info, validPortList) + { + if (!info.isNull()) + ports.append(info.portName()); + } + + // Update list only if necessary + if (portList() != ports) + { + // Update list + m_portList = ports; + + // Update current port index + if (port()) { - if (!info.isNull()) - ports.append(info.portName()); + auto name = port()->portName(); + for (int i = 0; i < validPortList.count(); ++i) + { + auto info = validPortList.at(i); + if (info.portName() == name) + { + m_portIndex = i + 1; + break; + } + } } - // Update list only if necessary - if (portList() != ports) + // Auto reconnect + if (Manager::instance().selectedDriver() == Manager::SelectedDriver::Serial) { - // Update list - m_portList = ports; - - // Update current port index - if (port()) + if (autoReconnect() && m_lastSerialDeviceIndex > 0) + { + if (m_lastSerialDeviceIndex < portList().count()) { - auto name = port()->portName(); - for (int i = 0; i < validPortList.count(); ++i) - { - auto info = validPortList.at(i); - if (info.portName() == name) - { - m_portIndex = i + 1; - break; - } - } + setPortIndex(m_lastSerialDeviceIndex); + Manager::instance().connectDevice(); } - - // Auto reconnect - if (Manager::instance().selectedDriver() == Manager::SelectedDriver::Serial) - { - if (autoReconnect() && m_lastSerialDeviceIndex > 0) - { - if (m_lastSerialDeviceIndex < portList().count()) - { - setPortIndex(m_lastSerialDeviceIndex); - Manager::instance().connectDevice(); - } - } - } - - // Update UI - Q_EMIT availablePortsChanged(); + } } + + // Update UI + Q_EMIT availablePortsChanged(); + } } /** @@ -679,17 +681,18 @@ void IO::Drivers::Serial::refreshSerialDevices() */ void IO::Drivers::Serial::handleError(QSerialPort::SerialPortError error) { - if (error != QSerialPort::NoError) - Manager::instance().disconnectDriver(); + if (error != QSerialPort::NoError) + Manager::instance().disconnectDriver(); } /** - * Reads all the data from the serial port & sends it to the @c IO::Manager class + * Reads all the data from the serial port & sends it to the @c IO::Manager + * class */ void IO::Drivers::Serial::onReadyRead() { - if (isOpen()) - Q_EMIT dataReceived(port()->readAll()); + if (isOpen()) + Q_EMIT dataReceived(port()->readAll()); } /** @@ -697,37 +700,38 @@ void IO::Drivers::Serial::onReadyRead() */ void IO::Drivers::Serial::readSettings() { - // Register standard baud rates - QStringList stdBaudRates - = { "300", "1200", "2400", "4800", "9600", "19200", "38400", "57600", - "74880", "115200", "230400", "250000", "500000", "1000000", "2000000" }; + // Register standard baud rates + QStringList stdBaudRates + = {"300", "1200", "2400", "4800", "9600", + "19200", "38400", "57600", "74880", "115200", + "230400", "250000", "500000", "1000000", "2000000"}; - // Get value from settings - QStringList list; - list = m_settings.value("IO_DataSource_Serial__BaudRates", stdBaudRates) - .toStringList(); + // Get value from settings + QStringList list; + list = m_settings.value("IO_DataSource_Serial__BaudRates", stdBaudRates) + .toStringList(); - // Convert QStringList to QVector - m_baudRateList.clear(); - for (int i = 0; i < list.count(); ++i) - m_baudRateList.append(list.at(i)); + // Convert QStringList to QVector + m_baudRateList.clear(); + for (int i = 0; i < list.count(); ++i) + m_baudRateList.append(list.at(i)); - // Sort baud rate list + // Sort baud rate list #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - for (auto i = 0; i < m_baudRateList.count() - 1; ++i) + for (auto i = 0; i < m_baudRateList.count() - 1; ++i) + { + for (auto j = 0; j < m_baudRateList.count() - i - 1; ++j) { - for (auto j = 0; j < m_baudRateList.count() - i - 1; ++j) - { - auto a = m_baudRateList.at(j).toInt(); - auto b = m_baudRateList.at(j + 1).toInt(); - if (a > b) - m_baudRateList.swapItemsAt(j, j + 1); - } + auto a = m_baudRateList.at(j).toInt(); + auto b = m_baudRateList.at(j + 1).toInt(); + if (a > b) + m_baudRateList.swapItemsAt(j, j + 1); } + } #endif - // Notify UI - Q_EMIT baudRateListChanged(); + // Notify UI + Q_EMIT baudRateListChanged(); } /** @@ -735,30 +739,30 @@ void IO::Drivers::Serial::readSettings() */ void IO::Drivers::Serial::writeSettings() { - // Sort baud rate list + // Sort baud rate list #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - for (auto i = 0; i < m_baudRateList.count() - 1; ++i) + for (auto i = 0; i < m_baudRateList.count() - 1; ++i) + { + for (auto j = 0; j < m_baudRateList.count() - i - 1; ++j) { - for (auto j = 0; j < m_baudRateList.count() - i - 1; ++j) - { - auto a = m_baudRateList.at(j).toInt(); - auto b = m_baudRateList.at(j + 1).toInt(); - if (a > b) - { - m_baudRateList.swapItemsAt(j, j + 1); - Q_EMIT baudRateListChanged(); - } - } + auto a = m_baudRateList.at(j).toInt(); + auto b = m_baudRateList.at(j + 1).toInt(); + if (a > b) + { + m_baudRateList.swapItemsAt(j, j + 1); + Q_EMIT baudRateListChanged(); + } } + } #endif - // Convert QVector to QStringList - QStringList list; - for (int i = 0; i < baudRateList().count(); ++i) - list.append(baudRateList().at(i)); + // Convert QVector to QStringList + QStringList list; + for (int i = 0; i < baudRateList().count(); ++i) + list.append(baudRateList().at(i)); - // Save list to memory - m_settings.setValue("IO_DataSource_Serial__BaudRates", list); + // Save list to memory + m_settings.setValue("IO_DataSource_Serial__BaudRates", list); } /** @@ -766,27 +770,23 @@ void IO::Drivers::Serial::writeSettings() */ QVector IO::Drivers::Serial::validPorts() const { - // Search for available ports and add them to the list - QVector ports; - Q_FOREACH (QSerialPortInfo info, QSerialPortInfo::availablePorts()) + // Search for available ports and add them to the list + QVector ports; + Q_FOREACH (QSerialPortInfo info, QSerialPortInfo::availablePorts()) + { + if (!info.isNull()) { - if (!info.isNull()) - { - // Only accept *.cu devices on macOS (remove *.tty) - // https://stackoverflow.com/a/37688347 + // Only accept *.cu devices on macOS (remove *.tty) + // https://stackoverflow.com/a/37688347 #ifdef Q_OS_MACOS - if (info.portName().toLower().startsWith("tty.")) - continue; + if (info.portName().toLower().startsWith("tty.")) + continue; #endif - // Append port to list - ports.append(info); - } + // Append port to list + ports.append(info); } + } - // Return list - return ports; + // Return list + return ports; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Serial.cpp" -#endif diff --git a/src/IO/Drivers/Serial.h b/src/IO/Drivers/Serial.h index 695bc8c8..1aa12814 100644 --- a/src/IO/Drivers/Serial.h +++ b/src/IO/Drivers/Serial.h @@ -43,7 +43,7 @@ namespace Drivers */ class Serial : public HAL_Driver { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(QString portName READ portName @@ -94,111 +94,111 @@ class Serial : public HAL_Driver Q_PROPERTY(StringList flowControlList READ flowControlList CONSTANT) - // clang-format on + // clang-format on Q_SIGNALS: - void portChanged(); - void parityChanged(); - void baudRateChanged(); - void dataBitsChanged(); - void stopBitsChanged(); - void portIndexChanged(); - void flowControlChanged(); - void baudRateListChanged(); - void autoReconnectChanged(); - void baudRateIndexChanged(); - void availablePortsChanged(); - void connectionError(const QString &name); + void portChanged(); + void parityChanged(); + void baudRateChanged(); + void dataBitsChanged(); + void stopBitsChanged(); + void portIndexChanged(); + void flowControlChanged(); + void baudRateListChanged(); + void autoReconnectChanged(); + void baudRateIndexChanged(); + void availablePortsChanged(); + void connectionError(const QString &name); private: - explicit Serial(); - Serial(Serial &&) = delete; - Serial(const Serial &) = delete; - Serial &operator=(Serial &&) = delete; - Serial &operator=(const Serial &) = delete; + explicit Serial(); + Serial(Serial &&) = delete; + Serial(const Serial &) = delete; + Serial &operator=(Serial &&) = delete; + Serial &operator=(const Serial &) = delete; - ~Serial(); + ~Serial(); public: - static Serial &instance(); + static Serial &instance(); - // - // HAL functions - // - void close() override; - bool isOpen() const override; - bool isReadable() const override; - bool isWritable() const override; - bool configurationOk() const override; - quint64 write(const QByteArray &data) override; - bool open(const QIODevice::OpenMode mode) override; + // + // HAL functions + // + void close() override; + bool isOpen() const override; + bool isReadable() const override; + bool isWritable() const override; + bool configurationOk() const override; + quint64 write(const QByteArray &data) override; + bool open(const QIODevice::OpenMode mode) override; - QString portName() const; - QSerialPort *port() const; - bool autoReconnect() const; + QString portName() const; + QSerialPort *port() const; + bool autoReconnect() const; - quint8 portIndex() const; - quint8 parityIndex() const; - quint8 displayMode() const; - quint8 dataBitsIndex() const; - quint8 stopBitsIndex() const; - quint8 flowControlIndex() const; + quint8 portIndex() const; + quint8 parityIndex() const; + quint8 displayMode() const; + quint8 dataBitsIndex() const; + quint8 stopBitsIndex() const; + quint8 flowControlIndex() const; - StringList portList() const; - StringList parityList() const; - StringList baudRateList() const; - StringList dataBitsList() const; - StringList stopBitsList() const; - StringList flowControlList() const; + StringList portList() const; + StringList parityList() const; + StringList baudRateList() const; + StringList dataBitsList() const; + StringList stopBitsList() const; + StringList flowControlList() const; - qint32 baudRate() const; - QSerialPort::Parity parity() const; - QSerialPort::DataBits dataBits() const; - QSerialPort::StopBits stopBits() const; - QSerialPort::FlowControl flowControl() const; + qint32 baudRate() const; + QSerialPort::Parity parity() const; + QSerialPort::DataBits dataBits() const; + QSerialPort::StopBits stopBits() const; + QSerialPort::FlowControl flowControl() const; public Q_SLOTS: - void disconnectDevice(); - void setBaudRate(const qint32 rate); - void setParity(const quint8 parityIndex); - void setPortIndex(const quint8 portIndex); - void appendBaudRate(const QString &baudRate); - void setDataBits(const quint8 dataBitsIndex); - void setStopBits(const quint8 stopBitsIndex); - void setAutoReconnect(const bool autoreconnect); - void setFlowControl(const quint8 flowControlIndex); + void disconnectDevice(); + void setBaudRate(const qint32 rate); + void setParity(const quint8 parityIndex); + void setPortIndex(const quint8 portIndex); + void appendBaudRate(const QString &baudRate); + void setDataBits(const quint8 dataBitsIndex); + void setStopBits(const quint8 stopBitsIndex); + void setAutoReconnect(const bool autoreconnect); + void setFlowControl(const quint8 flowControlIndex); private Q_SLOTS: - void onReadyRead(); - void readSettings(); - void writeSettings(); - void refreshSerialDevices(); - void handleError(QSerialPort::SerialPortError error); + void onReadyRead(); + void readSettings(); + void writeSettings(); + void refreshSerialDevices(); + void handleError(QSerialPort::SerialPortError error); private: - QVector validPorts() const; + QVector validPorts() const; private: - QSerialPort *m_port; + QSerialPort *m_port; - bool m_autoReconnect; - int m_lastSerialDeviceIndex; + bool m_autoReconnect; + int m_lastSerialDeviceIndex; - qint32 m_baudRate; - QSettings m_settings; - QSerialPort::Parity m_parity; - QSerialPort::DataBits m_dataBits; - QSerialPort::StopBits m_stopBits; - QSerialPort::FlowControl m_flowControl; + qint32 m_baudRate; + QSettings m_settings; + QSerialPort::Parity m_parity; + QSerialPort::DataBits m_dataBits; + QSerialPort::StopBits m_stopBits; + QSerialPort::FlowControl m_flowControl; - quint8 m_portIndex; - quint8 m_parityIndex; - quint8 m_dataBitsIndex; - quint8 m_stopBitsIndex; - quint8 m_flowControlIndex; + quint8 m_portIndex; + quint8 m_parityIndex; + quint8 m_dataBitsIndex; + quint8 m_stopBitsIndex; + quint8 m_flowControlIndex; - StringList m_portList; - StringList m_baudRateList; + StringList m_portList; + StringList m_baudRateList; }; -} -} +} // namespace Drivers +} // namespace IO diff --git a/src/IO/HAL_Driver.h b/src/IO/HAL_Driver.h index f7b2a217..d05c4e7f 100644 --- a/src/IO/HAL_Driver.h +++ b/src/IO/HAL_Driver.h @@ -30,28 +30,30 @@ namespace IO /** * @brief The HAL_Driver class * - * Abstract class that defines common I/O and data access functions for different types of - * devices. I/O drivers (e.g. serial port & network) are sub-classes of this class. + * Abstract class that defines common I/O and data access functions for + * different types of devices. I/O drivers (e.g. serial port & network) are + * sub-classes of this class. * - * This allows the rest of the I/O module to interact with a wide range of devices and - * protocols without the need of understanding protocol-specific implementation details. + * This allows the rest of the I/O module to interact with a wide range of + * devices and protocols without the need of understanding protocol-specific + * implementation details. */ class HAL_Driver : public QObject { - Q_OBJECT + Q_OBJECT Q_SIGNALS: - void configurationChanged(); - void dataSent(const QByteArray &data); - void dataReceived(const QByteArray &data); + void configurationChanged(); + void dataSent(const QByteArray &data); + void dataReceived(const QByteArray &data); public: - virtual void close() = 0; - virtual bool isOpen() const = 0; - virtual bool isReadable() const = 0; - virtual bool isWritable() const = 0; - virtual bool configurationOk() const = 0; - virtual quint64 write(const QByteArray &data) = 0; - virtual bool open(const QIODevice::OpenMode mode) = 0; + virtual void close() = 0; + virtual bool isOpen() const = 0; + virtual bool isReadable() const = 0; + virtual bool isWritable() const = 0; + virtual bool configurationOk() const = 0; + virtual quint64 write(const QByteArray &data) = 0; + virtual bool open(const QIODevice::OpenMode mode) = 0; }; -} +} // namespace IO diff --git a/src/IO/Manager.cpp b/src/IO/Manager.cpp index b6339022..cb68017d 100644 --- a/src/IO/Manager.cpp +++ b/src/IO/Manager.cpp @@ -31,49 +31,49 @@ /** * Adds support for C escape sequences to the given @a str. - * When user inputs "\n" in a textbox, Qt automatically converts that string to "\\n". - * For our purposes, we need to convert "\\n" back to "\n", and so on with the rest of - * the escape sequences supported by C. + * When user inputs "\n" in a textbox, Qt automatically converts that string to + * "\\n". For our purposes, we need to convert "\\n" back to "\n", and so on + * with the rest of the escape sequences supported by C. * * TODO: add support for numbers */ static QString ADD_ESCAPE_SEQUENCES(const QString &str) { - auto escapedStr = str; - escapedStr = escapedStr.replace("\\a", "\a"); - escapedStr = escapedStr.replace("\\b", "\b"); - escapedStr = escapedStr.replace("\\f", "\f"); - escapedStr = escapedStr.replace("\\n", "\n"); - escapedStr = escapedStr.replace("\\r", "\r"); - escapedStr = escapedStr.replace("\\t", "\t"); - escapedStr = escapedStr.replace("\\v", "\v"); - return escapedStr; + auto escapedStr = str; + escapedStr = escapedStr.replace("\\a", "\a"); + escapedStr = escapedStr.replace("\\b", "\b"); + escapedStr = escapedStr.replace("\\f", "\f"); + escapedStr = escapedStr.replace("\\n", "\n"); + escapedStr = escapedStr.replace("\\r", "\r"); + escapedStr = escapedStr.replace("\\t", "\t"); + escapedStr = escapedStr.replace("\\v", "\v"); + return escapedStr; } /** * Constructor function */ IO::Manager::Manager() - : m_enableCrc(false) - , m_writeEnabled(true) - , m_maxBufferSize(1024 * 1024) - , m_driver(Q_NULLPTR) - , m_receivedBytes(0) - , m_startSequence("/*") - , m_finishSequence("*/") - , m_separatorSequence(",") + : m_enableCrc(false) + , m_writeEnabled(true) + , m_maxBufferSize(1024 * 1024) + , m_driver(Q_NULLPTR) + , m_receivedBytes(0) + , m_startSequence("/*") + , m_finishSequence("*/") + , m_separatorSequence(",") { - // Set initial settings - setMaxBufferSize(1024 * 1024); - setSelectedDriver(SelectedDriver::Serial); + // Set initial settings + setMaxBufferSize(1024 * 1024); + setSelectedDriver(SelectedDriver::Serial); - // clang-format off + // clang-format off // Update connect button status when device type is changed connect(this, &IO::Manager::selectedDriverChanged, this, &IO::Manager::configurationChanged); - // clang-format on + // clang-format on } /** @@ -81,8 +81,8 @@ IO::Manager::Manager() */ IO::Manager &IO::Manager::instance() { - static Manager singleton; - return singleton; + static Manager singleton; + return singleton; } /** @@ -90,7 +90,7 @@ IO::Manager &IO::Manager::instance() */ bool IO::Manager::readOnly() { - return connected() && !m_writeEnabled; + return connected() && !m_writeEnabled; } /** @@ -98,19 +98,19 @@ bool IO::Manager::readOnly() */ bool IO::Manager::readWrite() { - return connected() && m_writeEnabled; + return connected() && m_writeEnabled; } /** - * Returns @c true if a device is currently selected and opened or if the MQTT client - * is currently connected as a subscriber. + * Returns @c true if a device is currently selected and opened or if the MQTT + * client is currently connected as a subscriber. */ bool IO::Manager::connected() { - if (driver()) - return driver()->isOpen(); + if (driver()) + return driver()->isOpen(); - return MQTT::Client::instance().isSubscribed(); + return MQTT::Client::instance().isSubscribed(); } /** @@ -118,39 +118,40 @@ bool IO::Manager::connected() */ bool IO::Manager::deviceAvailable() { - return driver() != Q_NULLPTR; + return driver() != Q_NULLPTR; } /** - * Returns @c true if we are able to connect to a device/port with the current config. + * Returns @c true if we are able to connect to a device/port with the current + * config. */ bool IO::Manager::configurationOk() { - if (driver()) - return driver()->configurationOk(); + if (driver()) + return driver()->configurationOk(); - return false; + return false; } /** - * Returns the maximum size of the buffer. This is useful to avoid consuming to much - * memory when a large block of invalid data is received (for example, when the user - * selects an invalid baud rate configuration). + * Returns the maximum size of the buffer. This is useful to avoid consuming to + * much memory when a large block of invalid data is received (for example, when + * the user selects an invalid baud rate configuration). */ int IO::Manager::maxBufferSize() const { - return m_maxBufferSize; + return m_maxBufferSize; } /** * Returns a pointer to the currently selected driver. * - * @warning you need to check this pointer before using it, it can have a @c Q_NULLPTR - * value during normal operations. + * @warning you need to check this pointer before using it, it can have a @c + * Q_NULLPTR value during normal operations. */ IO::HAL_Driver *IO::Manager::driver() { - return m_driver; + return m_driver; } /** @@ -160,36 +161,38 @@ IO::HAL_Driver *IO::Manager::driver() */ IO::Manager::SelectedDriver IO::Manager::selectedDriver() const { - return m_selectedDriver; + return m_selectedDriver; } /** - * Returns the start sequence string used by the application to know where to consider - * that a frame begins. If the start sequence is empty, then the application shall ignore - * incoming data. The only thing that wont ignore the incoming data will be the console. + * Returns the start sequence string used by the application to know where to + * consider that a frame begins. If the start sequence is empty, then the + * application shall ignore incoming data. The only thing that wont ignore the + * incoming data will be the console. */ QString IO::Manager::startSequence() const { - return m_startSequence; + return m_startSequence; } /** - * Returns the finish sequence string used by the application to know where to consider - * that a frame ends. If the start sequence is empty, then the application shall ignore - * incoming data. The only thing that wont ignore the incoming data will be the console. + * Returns the finish sequence string used by the application to know where to + * consider that a frame ends. If the start sequence is empty, then the + * application shall ignore incoming data. The only thing that wont ignore the + * incoming data will be the console. */ QString IO::Manager::finishSequence() const { - return m_finishSequence; + return m_finishSequence; } /** - * Returns the separator sequence string used by the application to know where to consider - * that a data item ends. + * Returns the separator sequence string used by the application to know where + * to consider that a data item ends. */ QString IO::Manager::separatorSequence() const { - return m_separatorSequence; + return m_separatorSequence; } /** @@ -197,11 +200,11 @@ QString IO::Manager::separatorSequence() const */ StringList IO::Manager::availableDrivers() const { - StringList list; - list.append(tr("Serial port")); - list.append(tr("Network port")); - list.append(tr("Bluetooth LE device")); - return list; + StringList list; + list.append(tr("Serial port")); + list.append(tr("Network port")); + list.append(tr("Bluetooth LE device")); + return list; } /** @@ -211,69 +214,69 @@ StringList IO::Manager::availableDrivers() const */ qint64 IO::Manager::writeData(const QByteArray &data) { - if (connected()) + if (connected()) + { + // Write data to device + auto bytes = driver()->write(data); + + // Show sent data in console + if (bytes > 0) { - // Write data to device - auto bytes = driver()->write(data); - - // Show sent data in console - if (bytes > 0) - { - auto writtenData = data; - writtenData.chop(data.length() - bytes); - Q_EMIT dataSent(writtenData); - } - - // Return number of bytes written - return bytes; + auto writtenData = data; + writtenData.chop(data.length() - bytes); + Q_EMIT dataSent(writtenData); } - return -1; + // Return number of bytes written + return bytes; + } + + return -1; } /** - * Connects/disconnects the application from the currently selected device. This function - * is used as a convenience for the connect/disconnect button. + * Connects/disconnects the application from the currently selected device. This + * function is used as a convenience for the connect/disconnect button. */ void IO::Manager::toggleConnection() { - if (connected()) - disconnectDriver(); - else - connectDevice(); + if (connected()) + disconnectDriver(); + else + connectDevice(); } /** - * Closes the currently selected device and tries to open & configure a new connection. - * A data source must be selected before calling this function. + * Closes the currently selected device and tries to open & configure a new + * connection. A data source must be selected before calling this function. */ void IO::Manager::connectDevice() { - // Reset driver - setSelectedDriver(selectedDriver()); + // Reset driver + setSelectedDriver(selectedDriver()); - // Configure current device - if (deviceAvailable()) + // Configure current device + if (deviceAvailable()) + { + // Set open flag + QIODevice::OpenMode mode = QIODevice::ReadOnly; + if (m_writeEnabled) + mode = QIODevice::ReadWrite; + + // Open device + if (driver()->open(mode)) { - // Set open flag - QIODevice::OpenMode mode = QIODevice::ReadOnly; - if (m_writeEnabled) - mode = QIODevice::ReadWrite; - - // Open device - if (driver()->open(mode)) - { - connect(driver(), &IO::HAL_Driver::dataReceived, this, - &IO::Manager::onDataReceived); - } - - // Error opening the device - else - disconnectDriver(); - - // Update UI - Q_EMIT connectedChanged(); + connect(driver(), &IO::HAL_Driver::dataReceived, this, + &IO::Manager::onDataReceived); } + + // Error opening the device + else + disconnectDriver(); + + // Update UI + Q_EMIT connectedChanged(); + } } /** @@ -281,30 +284,30 @@ void IO::Manager::connectDevice() */ void IO::Manager::disconnectDriver() { - if (deviceAvailable()) - { - // Disconnect device signals/slots - disconnect(driver(), &IO::HAL_Driver::dataReceived, this, - &IO::Manager::onDataReceived); - disconnect(driver(), &IO::HAL_Driver::configurationChanged, this, - &IO::Manager::configurationChanged); + if (deviceAvailable()) + { + // Disconnect device signals/slots + disconnect(driver(), &IO::HAL_Driver::dataReceived, this, + &IO::Manager::onDataReceived); + disconnect(driver(), &IO::HAL_Driver::configurationChanged, this, + &IO::Manager::configurationChanged); - // Close driver device - driver()->close(); + // Close driver device + driver()->close(); - // Update device pointer - m_driver = Q_NULLPTR; - m_receivedBytes = 0; - m_dataBuffer.clear(); - m_dataBuffer.reserve(maxBufferSize()); + // Update device pointer + m_driver = Q_NULLPTR; + m_receivedBytes = 0; + m_dataBuffer.clear(); + m_dataBuffer.reserve(maxBufferSize()); - // Update UI - Q_EMIT driverChanged(); - Q_EMIT connectedChanged(); - } + // Update UI + Q_EMIT driverChanged(); + Q_EMIT connectedChanged(); + } - // Disable CRC checking - m_enableCrc = false; + // Disable CRC checking + m_enableCrc = false; } /** @@ -312,118 +315,120 @@ void IO::Manager::disconnectDriver() */ void IO::Manager::setWriteEnabled(const bool enabled) { - m_writeEnabled = enabled; - Q_EMIT writeEnabledChanged(); + m_writeEnabled = enabled; + Q_EMIT writeEnabledChanged(); } /** * Reads the given payload and emits it as if it were received from a device. - * This function is for convenience to interact with other application modules & plugins. + * This function is for convenience to interact with other application modules & + * plugins. */ void IO::Manager::processPayload(const QByteArray &payload) { - if (!payload.isEmpty()) - { - // Update received bytes indicator - m_receivedBytes += payload.size(); - if (m_receivedBytes >= UINT64_MAX) - m_receivedBytes = 0; + if (!payload.isEmpty()) + { + // Update received bytes indicator + m_receivedBytes += payload.size(); + if (m_receivedBytes >= UINT64_MAX) + m_receivedBytes = 0; - // Notify user interface & application modules - Q_EMIT dataReceived(payload); - Q_EMIT frameReceived(payload); - Q_EMIT receivedBytesChanged(); - } + // Notify user interface & application modules + Q_EMIT dataReceived(payload); + Q_EMIT frameReceived(payload); + Q_EMIT receivedBytesChanged(); + } } /** - * Changes the maximum permited buffer size. Check the @c maxBufferSize() function for - * more information. + * Changes the maximum permited buffer size. Check the @c maxBufferSize() + * function for more information. */ void IO::Manager::setMaxBufferSize(const int maxBufferSize) { - m_maxBufferSize = maxBufferSize; - Q_EMIT maxBufferSizeChanged(); + m_maxBufferSize = maxBufferSize; + Q_EMIT maxBufferSizeChanged(); - m_dataBuffer.reserve(maxBufferSize); + m_dataBuffer.reserve(maxBufferSize); } /** - * Changes the frame start sequence. Check the @c startSequence() function for more - * information. + * Changes the frame start sequence. Check the @c startSequence() function for + * more information. */ void IO::Manager::setStartSequence(const QString &sequence) { - m_startSequence = ADD_ESCAPE_SEQUENCES(sequence); - if (m_startSequence.isEmpty()) - m_startSequence = "/*"; + m_startSequence = ADD_ESCAPE_SEQUENCES(sequence); + if (m_startSequence.isEmpty()) + m_startSequence = "/*"; - Q_EMIT startSequenceChanged(); + Q_EMIT startSequenceChanged(); } /** - * Changes the frame end sequence. Check the @c finishSequence() function for more - * information. + * Changes the frame end sequence. Check the @c finishSequence() function for + * more information. */ void IO::Manager::setFinishSequence(const QString &sequence) { - m_finishSequence = ADD_ESCAPE_SEQUENCES(sequence); - if (m_finishSequence.isEmpty()) - m_finishSequence = "*/"; + m_finishSequence = ADD_ESCAPE_SEQUENCES(sequence); + if (m_finishSequence.isEmpty()) + m_finishSequence = "*/"; - Q_EMIT finishSequenceChanged(); + Q_EMIT finishSequenceChanged(); } /** - * Changes the frame separator sequence. Check the @c separatorSequence() function for - * more information. + * Changes the frame separator sequence. Check the @c separatorSequence() + * function for more information. */ void IO::Manager::setSeparatorSequence(const QString &sequence) { - m_separatorSequence = ADD_ESCAPE_SEQUENCES(sequence); - if (m_separatorSequence.isEmpty()) - m_separatorSequence = ","; + m_separatorSequence = ADD_ESCAPE_SEQUENCES(sequence); + if (m_separatorSequence.isEmpty()) + m_separatorSequence = ","; - Q_EMIT separatorSequenceChanged(); + Q_EMIT separatorSequenceChanged(); } /** - * Changes the data source type. Check the @c dataSource() funciton for more information. + * Changes the data source type. Check the @c dataSource() funciton for more + * information. */ void IO::Manager::setSelectedDriver(const IO::Manager::SelectedDriver &driver) { - // Disconnect current driver - disconnectDriver(); + // Disconnect current driver + disconnectDriver(); - // Change data source - m_selectedDriver = driver; + // Change data source + m_selectedDriver = driver; - // Disconnect previous device (if any) - disconnectDriver(); + // Disconnect previous device (if any) + disconnectDriver(); - // Try to open a serial port connection - if (selectedDriver() == SelectedDriver::Serial) - setDriver(&(Drivers::Serial::instance())); + // Try to open a serial port connection + if (selectedDriver() == SelectedDriver::Serial) + setDriver(&(Drivers::Serial::instance())); - // Try to open a network connection - else if (selectedDriver() == SelectedDriver::Network) - setDriver(&(Drivers::Network::instance())); + // Try to open a network connection + else if (selectedDriver() == SelectedDriver::Network) + setDriver(&(Drivers::Network::instance())); - // Try to open a BLE connection - else if (selectedDriver() == SelectedDriver::BluetoothLE) - setDriver(&(Drivers::BluetoothLE::instance())); + // Try to open a BLE connection + else if (selectedDriver() == SelectedDriver::BluetoothLE) + setDriver(&(Drivers::BluetoothLE::instance())); - // Invalid driver - else - setDriver(Q_NULLPTR); + // Invalid driver + else + setDriver(Q_NULLPTR); - // Update UI - Q_EMIT selectedDriverChanged(); + // Update UI + Q_EMIT selectedDriverChanged(); } /** - * Read frames from temporary buffer, every frame that contains the appropiate start/end - * sequence is removed from the buffer as soon as its read. + * Read frames from temporary buffer, every frame that contains the appropiate + * start/end sequence is removed from the buffer as soon as its read. * * This function also checks that the buffer size does not exceed specified size * limitations. @@ -432,227 +437,228 @@ void IO::Manager::setSelectedDriver(const IO::Manager::SelectedDriver &driver) */ void IO::Manager::readFrames() { - // No device connected, abort - if (!connected()) - return; + // No device connected, abort + if (!connected()) + return; - // Read until start/finish combinations are not found - auto bytes = 0; - auto prevBytes = 0; - auto cursor = m_dataBuffer; - auto start = startSequence().toUtf8(); - auto finish = finishSequence().toUtf8(); - while (cursor.contains(start) && cursor.contains(finish)) + // Read until start/finish combinations are not found + auto bytes = 0; + auto prevBytes = 0; + auto cursor = m_dataBuffer; + auto start = startSequence().toUtf8(); + auto finish = finishSequence().toUtf8(); + while (cursor.contains(start) && cursor.contains(finish)) + { + // Remove the part of the buffer prior to, and including, the start + // sequence. + auto sIndex = cursor.indexOf(start); + cursor = cursor.mid(sIndex + start.length(), -1); + bytes += sIndex + start.length(); + + // Copy a sub-buffer that goes until the finish sequence + auto fIndex = cursor.indexOf(finish); + auto frame = cursor.left(fIndex); + + // Parse frame + if (!frame.isEmpty()) { - // Remove the part of the buffer prior to, and including, the start sequence. - auto sIndex = cursor.indexOf(start); - cursor = cursor.mid(sIndex + start.length(), -1); - bytes += sIndex + start.length(); + // Checksum verification & Q_EMIT RX frame + int chop = 0; + auto result = integrityChecks(frame, cursor, &chop); + if (result == ValidationStatus::FrameOk) + Q_EMIT frameReceived(frame); - // Copy a sub-buffer that goes until the finish sequence - auto fIndex = cursor.indexOf(finish); - auto frame = cursor.left(fIndex); + // Checksum data incomplete, try next time... + else if (result == ValidationStatus::ChecksumIncomplete) + { + bytes = prevBytes; + break; + } - // Parse frame - if (!frame.isEmpty()) - { - // Checksum verification & Q_EMIT RX frame - int chop = 0; - auto result = integrityChecks(frame, cursor, &chop); - if (result == ValidationStatus::FrameOk) - Q_EMIT frameReceived(frame); + // Remove the data including the finish sequence from the master buffer + cursor = cursor.mid(fIndex + chop, -1); + bytes += fIndex + chop; - // Checksum data incomplete, try next time... - else if (result == ValidationStatus::ChecksumIncomplete) - { - bytes = prevBytes; - break; - } - - // Remove the data including the finish sequence from the master buffer - cursor = cursor.mid(fIndex + chop, -1); - bytes += fIndex + chop; - - // Frame read successfully, save the number of bytes to chop. - // This is used to manage frames with incomplete checksums - prevBytes = bytes; - } - - // Frame empty, wait for more data... - else - bytes = prevBytes; + // Frame read successfully, save the number of bytes to chop. + // This is used to manage frames with incomplete checksums + prevBytes = bytes; } - // Remove parsed data from master buffer - m_dataBuffer.remove(0, bytes); + // Frame empty, wait for more data... + else + bytes = prevBytes; + } - // Clear temp. buffer (e.g. device sends a lot of invalid data) - if (m_dataBuffer.size() > maxBufferSize()) - clearTempBuffer(); + // Remove parsed data from master buffer + m_dataBuffer.remove(0, bytes); + + // Clear temp. buffer (e.g. device sends a lot of invalid data) + if (m_dataBuffer.size() > maxBufferSize()) + clearTempBuffer(); } /** - * Deletes the contents of the temporary buffer. This function is called automatically by - * the class when the temporary buffer size exceeds the limit imposed by the + * Deletes the contents of the temporary buffer. This function is called + * automatically by the class when the temporary buffer size exceeds the limit + * imposed by the * @c maxBufferSize() function. */ void IO::Manager::clearTempBuffer() { - m_dataBuffer.clear(); + m_dataBuffer.clear(); } /** - * Changes the target device pointer. Deletion should be handled by the interface - * implementation, not by this class. + * Changes the target device pointer. Deletion should be handled by the + * interface implementation, not by this class. */ void IO::Manager::setDriver(HAL_Driver *driver) { - if (driver) - connect(driver, &IO::HAL_Driver::configurationChanged, this, - &IO::Manager::configurationChanged); + if (driver) + connect(driver, &IO::HAL_Driver::configurationChanged, this, + &IO::Manager::configurationChanged); - m_driver = driver; + m_driver = driver; - Q_EMIT driverChanged(); - Q_EMIT configurationChanged(); + Q_EMIT driverChanged(); + Q_EMIT configurationChanged(); } /** - * Reads incoming data from the I/O device, updates the console object, registers incoming - * data to temporary buffer & extracts valid data frames from the buffer using the @c - * readFrame() function. + * Reads incoming data from the I/O device, updates the console object, + * registers incoming data to temporary buffer & extracts valid data frames from + * the buffer using the @c readFrame() function. */ void IO::Manager::onDataReceived(const QByteArray &data) { - // Verify that device is still valid - if (!driver()) - disconnectDriver(); + // Verify that device is still valid + if (!driver()) + disconnectDriver(); - // Read data & append it to buffer - auto bytes = data.length(); + // Read data & append it to buffer + auto bytes = data.length(); - // Obtain frames from data buffer - m_dataBuffer.append(data); - readFrames(); + // Obtain frames from data buffer + m_dataBuffer.append(data); + readFrames(); - // Update received bytes indicator - m_receivedBytes += bytes; - if (m_receivedBytes >= UINT64_MAX) - m_receivedBytes = 0; + // Update received bytes indicator + m_receivedBytes += bytes; + if (m_receivedBytes >= UINT64_MAX) + m_receivedBytes = 0; - // Notify user interface - Q_EMIT receivedBytesChanged(); - Q_EMIT dataReceived(data); + // Notify user interface + Q_EMIT receivedBytesChanged(); + Q_EMIT dataReceived(data); } /** * Checks if the @c cursor has a checksum corresponding to the given @a frame. - * If so, the function shall calculate the appropiate checksum to for the @a frame and - * compare it with the received checksum to verify the integrity of received data. + * If so, the function shall calculate the appropiate checksum to for the @a + * frame and compare it with the received checksum to verify the integrity of + * received data. * * @param frame data in which we shall perform integrity checks * @param cursor master buffer, should start with checksum type header - * @param bytes pointer to the number of bytes that we need to chop from the master buffer + * @param bytes pointer to the number of bytes that we need to chop from the + * master buffer */ -IO::Manager::ValidationStatus IO::Manager::integrityChecks(const QByteArray &frame, - const QByteArray &cursor, - int *bytes) +IO::Manager::ValidationStatus +IO::Manager::integrityChecks(const QByteArray &frame, const QByteArray &cursor, + int *bytes) { - // Get finish sequence as byte array - auto finish = finishSequence().toUtf8(); - auto crc8Header = finish + "crc8:"; - auto crc16Header = finish + "crc16:"; - auto crc32Header = finish + "crc32:"; + // Get finish sequence as byte array + auto finish = finishSequence().toUtf8(); + auto crc8Header = finish + "crc8:"; + auto crc16Header = finish + "crc16:"; + auto crc32Header = finish + "crc32:"; - // Check CRC-8 - if (cursor.contains(crc8Header)) + // Check CRC-8 + if (cursor.contains(crc8Header)) + { + // Enable the CRC flag + m_enableCrc = true; + auto offset = cursor.indexOf(crc8Header) + crc8Header.length() - 1; + + // Check if we have enough data in the buffer + if (cursor.length() >= offset + 1) { - // Enable the CRC flag - m_enableCrc = true; - auto offset = cursor.indexOf(crc8Header) + crc8Header.length() - 1; + // Increment the number of bytes to remove from master buffer + *bytes += crc8Header.length() + 1; - // Check if we have enough data in the buffer - if (cursor.length() >= offset + 1) - { - // Increment the number of bytes to remove from master buffer - *bytes += crc8Header.length() + 1; + // Get 8-bit checksum + const quint8 crc = cursor.at(offset + 1); - // Get 8-bit checksum - const quint8 crc = cursor.at(offset + 1); - - // Compare checksums - if (crc8(frame.data(), frame.length()) == crc) - return ValidationStatus::FrameOk; - else - return ValidationStatus::ChecksumError; - } - } - - // Check CRC-16 - else if (cursor.contains(crc16Header)) - { - // Enable the CRC flag - m_enableCrc = true; - auto offset = cursor.indexOf(crc16Header) + crc16Header.length() - 1; - - // Check if we have enough data in the buffer - if (cursor.length() >= offset + 2) - { - // Increment the number of bytes to remove from master buffer - *bytes += crc16Header.length() + 2; - - // Get 16-bit checksum - const quint8 a = cursor.at(offset + 1); - const quint8 b = cursor.at(offset + 2); - const quint16 crc = (a << 8) | (b & 0xff); - - // Compare checksums - if (crc16(frame.data(), frame.length()) == crc) - return ValidationStatus::FrameOk; - else - return ValidationStatus::ChecksumError; - } - } - - // Check CRC-32 - else if (cursor.contains(crc32Header)) - { - // Enable the CRC flag - m_enableCrc = true; - auto offset = cursor.indexOf(crc32Header) + crc32Header.length() - 1; - - // Check if we have enough data in the buffer - if (cursor.length() >= offset + 4) - { - // Increment the number of bytes to remove from master buffer - *bytes += crc32Header.length() + 4; - - // Get 32-bit checksum - const quint8 a = cursor.at(offset + 1); - const quint8 b = cursor.at(offset + 2); - const quint8 c = cursor.at(offset + 3); - const quint8 d = cursor.at(offset + 4); - const quint32 crc = (a << 24) | (b << 16) | (c << 8) | (d & 0xff); - - // Compare checksums - if (crc32(frame.data(), frame.length()) == crc) - return ValidationStatus::FrameOk; - else - return ValidationStatus::ChecksumError; - } - } - - // Buffer does not contain CRC code - else if (!m_enableCrc) - { - *bytes += finish.length(); + // Compare checksums + if (crc8(frame.data(), frame.length()) == crc) return ValidationStatus::FrameOk; + else + return ValidationStatus::ChecksumError; } + } - // Checksum data incomplete - return ValidationStatus::ChecksumIncomplete; + // Check CRC-16 + else if (cursor.contains(crc16Header)) + { + // Enable the CRC flag + m_enableCrc = true; + auto offset = cursor.indexOf(crc16Header) + crc16Header.length() - 1; + + // Check if we have enough data in the buffer + if (cursor.length() >= offset + 2) + { + // Increment the number of bytes to remove from master buffer + *bytes += crc16Header.length() + 2; + + // Get 16-bit checksum + const quint8 a = cursor.at(offset + 1); + const quint8 b = cursor.at(offset + 2); + const quint16 crc = (a << 8) | (b & 0xff); + + // Compare checksums + if (crc16(frame.data(), frame.length()) == crc) + return ValidationStatus::FrameOk; + else + return ValidationStatus::ChecksumError; + } + } + + // Check CRC-32 + else if (cursor.contains(crc32Header)) + { + // Enable the CRC flag + m_enableCrc = true; + auto offset = cursor.indexOf(crc32Header) + crc32Header.length() - 1; + + // Check if we have enough data in the buffer + if (cursor.length() >= offset + 4) + { + // Increment the number of bytes to remove from master buffer + *bytes += crc32Header.length() + 4; + + // Get 32-bit checksum + const quint8 a = cursor.at(offset + 1); + const quint8 b = cursor.at(offset + 2); + const quint8 c = cursor.at(offset + 3); + const quint8 d = cursor.at(offset + 4); + const quint32 crc = (a << 24) | (b << 16) | (c << 8) | (d & 0xff); + + // Compare checksums + if (crc32(frame.data(), frame.length()) == crc) + return ValidationStatus::FrameOk; + else + return ValidationStatus::ChecksumError; + } + } + + // Buffer does not contain CRC code + else if (!m_enableCrc) + { + *bytes += finish.length(); + return ValidationStatus::FrameOk; + } + + // Checksum data incomplete + return ValidationStatus::ChecksumIncomplete; } -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Manager.cpp" -#endif diff --git a/src/IO/Manager.h b/src/IO/Manager.h index c83c2df8..47e6fbcb 100644 --- a/src/IO/Manager.h +++ b/src/IO/Manager.h @@ -57,7 +57,7 @@ namespace IO */ class Manager : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(bool readOnly READ readOnly @@ -90,100 +90,101 @@ class Manager : public QObject Q_PROPERTY(bool configurationOk READ configurationOk NOTIFY configurationChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void driverChanged(); - void connectedChanged(); - void writeEnabledChanged(); - void configurationChanged(); - void receivedBytesChanged(); - void maxBufferSizeChanged(); - void startSequenceChanged(); - void finishSequenceChanged(); - void selectedDriverChanged(); - void separatorSequenceChanged(); - void frameValidationRegexChanged(); - void dataSent(const QByteArray &data); - void dataReceived(const QByteArray &data); - void frameReceived(const QByteArray &frame); + void driverChanged(); + void connectedChanged(); + void writeEnabledChanged(); + void configurationChanged(); + void receivedBytesChanged(); + void maxBufferSizeChanged(); + void startSequenceChanged(); + void finishSequenceChanged(); + void selectedDriverChanged(); + void separatorSequenceChanged(); + void frameValidationRegexChanged(); + void dataSent(const QByteArray &data); + void dataReceived(const QByteArray &data); + void frameReceived(const QByteArray &frame); private: - explicit Manager(); - Manager(Manager &&) = delete; - Manager(const Manager &) = delete; - Manager &operator=(Manager &&) = delete; - Manager &operator=(const Manager &) = delete; + explicit Manager(); + Manager(Manager &&) = delete; + Manager(const Manager &) = delete; + Manager &operator=(Manager &&) = delete; + Manager &operator=(const Manager &) = delete; public: - enum class SelectedDriver - { - Serial, - Network, - BluetoothLE - }; - Q_ENUM(SelectedDriver) + enum class SelectedDriver + { + Serial, + Network, + BluetoothLE + }; + Q_ENUM(SelectedDriver) - enum class ValidationStatus - { - FrameOk, - ChecksumError, - ChecksumIncomplete - }; - Q_ENUM(ValidationStatus) + enum class ValidationStatus + { + FrameOk, + ChecksumError, + ChecksumIncomplete + }; + Q_ENUM(ValidationStatus) - static Manager &instance(); + static Manager &instance(); - bool readOnly(); - bool readWrite(); - bool connected(); - bool deviceAvailable(); - bool configurationOk(); + bool readOnly(); + bool readWrite(); + bool connected(); + bool deviceAvailable(); + bool configurationOk(); - int maxBufferSize() const; + int maxBufferSize() const; - HAL_Driver *driver(); - SelectedDriver selectedDriver() const; + HAL_Driver *driver(); + SelectedDriver selectedDriver() const; - QString startSequence() const; - QString finishSequence() const; - QString separatorSequence() const; + QString startSequence() const; + QString finishSequence() const; + QString separatorSequence() const; - Q_INVOKABLE StringList availableDrivers() const; - Q_INVOKABLE qint64 writeData(const QByteArray &data); + Q_INVOKABLE StringList availableDrivers() const; + Q_INVOKABLE qint64 writeData(const QByteArray &data); public Q_SLOTS: - void connectDevice(); - void toggleConnection(); - void disconnectDriver(); - void setWriteEnabled(const bool enabled); - void processPayload(const QByteArray &payload); - void setMaxBufferSize(const int maxBufferSize); - void setStartSequence(const QString &sequence); - void setFinishSequence(const QString &sequence); - void setSeparatorSequence(const QString &sequence); - void setSelectedDriver(const IO::Manager::SelectedDriver &driver); + void connectDevice(); + void toggleConnection(); + void disconnectDriver(); + void setWriteEnabled(const bool enabled); + void processPayload(const QByteArray &payload); + void setMaxBufferSize(const int maxBufferSize); + void setStartSequence(const QString &sequence); + void setFinishSequence(const QString &sequence); + void setSeparatorSequence(const QString &sequence); + void setSelectedDriver(const IO::Manager::SelectedDriver &driver); private Q_SLOTS: - void readFrames(); - void clearTempBuffer(); - void setDriver(HAL_Driver *driver); - void onDataReceived(const QByteArray &data); + void readFrames(); + void clearTempBuffer(); + void setDriver(HAL_Driver *driver); + void onDataReceived(const QByteArray &data); private: - ValidationStatus integrityChecks(const QByteArray &frame, - const QByteArray &masterBuffer, int *bytesToChop); + ValidationStatus integrityChecks(const QByteArray &frame, + const QByteArray &masterBuffer, + int *bytesToChop); private: - bool m_enableCrc; - bool m_writeEnabled; - int m_maxBufferSize; - HAL_Driver *m_driver; - QByteArray m_dataBuffer; - quint64 m_receivedBytes; - QString m_startSequence; - QString m_finishSequence; - QString m_separatorSequence; - SelectedDriver m_selectedDriver; + bool m_enableCrc; + bool m_writeEnabled; + int m_maxBufferSize; + HAL_Driver *m_driver; + QByteArray m_dataBuffer; + quint64 m_receivedBytes; + QString m_startSequence; + QString m_finishSequence; + QString m_separatorSequence; + SelectedDriver m_selectedDriver; }; -} +} // namespace IO diff --git a/src/JSON/Dataset.cpp b/src/JSON/Dataset.cpp index 4c55f03e..d0ff254d 100644 --- a/src/JSON/Dataset.cpp +++ b/src/JSON/Dataset.cpp @@ -24,19 +24,19 @@ #include JSON::Dataset::Dataset() - : m_fft(false) - , m_led(false) - , m_log(false) - , m_graph(false) - , m_title("") - , m_value("") - , m_units("") - , m_widget("") - , m_index(0) - , m_max(0) - , m_min(0) - , m_alarm(0) - , m_fftSamples(1024) + : m_fft(false) + , m_led(false) + , m_log(false) + , m_graph(false) + , m_title("") + , m_value("") + , m_units("") + , m_widget("") + , m_index(0) + , m_max(0) + , m_min(0) + , m_alarm(0) + , m_fftSamples(1024) { } @@ -45,7 +45,7 @@ JSON::Dataset::Dataset() */ bool JSON::Dataset::fft() const { - return m_fft; + return m_fft; } /** @@ -53,7 +53,7 @@ bool JSON::Dataset::fft() const */ bool JSON::Dataset::led() const { - return m_led; + return m_led; } /** @@ -61,7 +61,7 @@ bool JSON::Dataset::led() const */ bool JSON::Dataset::log() const { - return m_log; + return m_log; } /** @@ -69,7 +69,7 @@ bool JSON::Dataset::log() const */ int JSON::Dataset::index() const { - return m_index; + return m_index; } /** @@ -77,7 +77,7 @@ int JSON::Dataset::index() const */ bool JSON::Dataset::graph() const { - return m_graph; + return m_graph; } /** @@ -85,7 +85,7 @@ bool JSON::Dataset::graph() const */ double JSON::Dataset::min() const { - return m_min; + return m_min; } /** @@ -93,7 +93,7 @@ double JSON::Dataset::min() const */ double JSON::Dataset::max() const { - return m_max; + return m_max; } /** @@ -101,7 +101,7 @@ double JSON::Dataset::max() const */ double JSON::Dataset::alarm() const { - return m_alarm; + return m_alarm; } /** @@ -109,7 +109,7 @@ double JSON::Dataset::alarm() const */ QString JSON::Dataset::title() const { - return m_title; + return m_title; } /** @@ -117,7 +117,7 @@ QString JSON::Dataset::title() const */ QString JSON::Dataset::value() const { - return m_value; + return m_value; } /** @@ -125,7 +125,7 @@ QString JSON::Dataset::value() const */ QString JSON::Dataset::units() const { - return m_units; + return m_units; } /** @@ -133,7 +133,7 @@ QString JSON::Dataset::units() const */ QString JSON::Dataset::widget() const { - return m_widget; + return m_widget; } /** @@ -141,7 +141,7 @@ QString JSON::Dataset::widget() const */ int JSON::Dataset::fftSamples() const { - return qMax(1, m_fftSamples); + return qMax(1, m_fftSamples); } /** @@ -149,38 +149,38 @@ int JSON::Dataset::fftSamples() const */ QJsonObject JSON::Dataset::jsonData() const { - return m_jsonData; + return m_jsonData; } /** - * Reads dataset information from the given @a object and evaluates any JS code in the - * "value" field of the dataset. + * Reads dataset information from the given @a object and evaluates any JS code + * in the "value" field of the dataset. * * @return @c true on read success, @c false on failure */ bool JSON::Dataset::read(const QJsonObject &object) { - if (!object.isEmpty()) - { - m_fft = object.value("fft").toBool(); - m_led = object.value("led").toBool(); - m_log = object.value("log").toBool(); - m_min = object.value("min").toDouble(); - m_max = object.value("max").toDouble(); - m_index = object.value("index").toInt(); - m_alarm = object.value("alarm").toDouble(); - m_graph = object.value("graph").toBool(); - m_title = object.value("title").toString(); - m_value = object.value("value").toString(); - m_units = object.value("units").toString(); - m_widget = object.value("widget").toString(); - m_fftSamples = object.value("fftSamples").toInt(); + if (!object.isEmpty()) + { + m_fft = object.value("fft").toBool(); + m_led = object.value("led").toBool(); + m_log = object.value("log").toBool(); + m_min = object.value("min").toDouble(); + m_max = object.value("max").toDouble(); + m_index = object.value("index").toInt(); + m_alarm = object.value("alarm").toDouble(); + m_graph = object.value("graph").toBool(); + m_title = object.value("title").toString(); + m_value = object.value("value").toString(); + m_units = object.value("units").toString(); + m_widget = object.value("widget").toString(); + m_fftSamples = object.value("fftSamples").toInt(); - if (m_value.isEmpty()) - m_value = "--.--"; + if (m_value.isEmpty()) + m_value = "--.--"; - return true; - } + return true; + } - return false; + return false; } diff --git a/src/JSON/Dataset.h b/src/JSON/Dataset.h index 36608860..b245a301 100644 --- a/src/JSON/Dataset.h +++ b/src/JSON/Dataset.h @@ -70,45 +70,45 @@ namespace JSON class Dataset { public: - Dataset(); + Dataset(); - bool fft() const; - bool led() const; - bool log() const; - int index() const; - bool graph() const; - double min() const; - double max() const; - double alarm() const; - QString title() const; - QString value() const; - QString units() const; - QString widget() const; - int fftSamples() const; - QJsonObject jsonData() const; + bool fft() const; + bool led() const; + bool log() const; + int index() const; + bool graph() const; + double min() const; + double max() const; + double alarm() const; + QString title() const; + QString value() const; + QString units() const; + QString widget() const; + int fftSamples() const; + QJsonObject jsonData() const; - bool read(const QJsonObject &object); - void setTitle(const QString &title) { m_title = title; } + bool read(const QJsonObject &object); + void setTitle(const QString &title) { m_title = title; } private: - bool m_fft; - bool m_led; - bool m_log; - bool m_graph; + bool m_fft; + bool m_led; + bool m_log; + bool m_graph; - QString m_title; - QString m_value; - QString m_units; - QString m_widget; - QJsonObject m_jsonData; + QString m_title; + QString m_value; + QString m_units; + QString m_widget; + QJsonObject m_jsonData; - // Editor-related variables - int m_index; - double m_max; - double m_min; - double m_alarm; - int m_fftSamples; + // Editor-related variables + int m_index; + double m_max; + double m_min; + double m_alarm; + int m_fftSamples; - friend class Project::Model; + friend class Project::Model; }; -} +} // namespace JSON diff --git a/src/JSON/Frame.cpp b/src/JSON/Frame.cpp index adff02ec..7e29a9ba 100644 --- a/src/JSON/Frame.cpp +++ b/src/JSON/Frame.cpp @@ -23,22 +23,22 @@ #include /** - * Destructor function, free memory used by the @c Group objects before destroying an - * instance of this class. + * Destructor function, free memory used by the @c Group objects before + * destroying an instance of this class. */ JSON::Frame::~Frame() { - m_groups.clear(); + m_groups.clear(); } /** - * Resets the frame title and frees the memory used by the @c Group objects associated - * to the instance of the @c Frame object. + * Resets the frame title and frees the memory used by the @c Group objects + * associated to the instance of the @c Frame object. */ void JSON::Frame::clear() { - m_title = ""; - m_groups.clear(); + m_title = ""; + m_groups.clear(); } /** @@ -46,7 +46,7 @@ void JSON::Frame::clear() */ QString JSON::Frame::title() const { - return m_title; + return m_title; } /** @@ -54,53 +54,54 @@ QString JSON::Frame::title() const */ int JSON::Frame::groupCount() const { - return m_groups.count(); + return m_groups.count(); } /** - * Returns a vector of pointers to the @c Group objects associated to this frame. + * Returns a vector of pointers to the @c Group objects associated to this + * frame. */ QVector &JSON::Frame::groups() { - return m_groups; + return m_groups; } /** - * Reads the frame information and all its asociated groups (and datatsets) from the given - * JSON @c object. + * Reads the frame information and all its asociated groups (and datatsets) from + * the given JSON @c object. * * @return @c true on success, @c false on failure */ bool JSON::Frame::read(const QJsonObject &object) { - // Rest frame data - clear(); + // Rest frame data + clear(); - // Get title & groups array - auto title = object.value("title").toString(); - auto groups = object.value("groups").toArray(); + // Get title & groups array + auto title = object.value("title").toString(); + auto groups = object.value("groups").toArray(); - // We need to have a project title and at least one group - if (!title.isEmpty() && !groups.isEmpty()) + // We need to have a project title and at least one group + if (!title.isEmpty() && !groups.isEmpty()) + { + // Update title + m_title = title; + + // Generate groups & datasets from data frame + for (auto i = 0; i < groups.count(); ++i) { - // Update title - m_title = title; - - // Generate groups & datasets from data frame - for (auto i = 0; i < groups.count(); ++i) - { - Group group; - if (group.read(groups.at(i).toObject())) - m_groups.append(group); - } - - // Return status - return groupCount() > 0; + Group group; + if (group.read(groups.at(i).toObject())) + m_groups.append(group); } - // Error - clear(); - return false; + // Return status + return groupCount() > 0; + } + + // Error + clear(); + return false; } /** @@ -108,5 +109,5 @@ bool JSON::Frame::read(const QJsonObject &object) */ const JSON::Group &JSON::Frame::getGroup(const int index) const { - return m_groups.at(index); + return m_groups.at(index); } diff --git a/src/JSON/Frame.h b/src/JSON/Frame.h index 5238524b..d8f6ef8f 100644 --- a/src/JSON/Frame.h +++ b/src/JSON/Frame.h @@ -49,24 +49,25 @@ namespace JSON * 7) UI dashboard feeds JSON data to this class. * 8) This class creates a model of the JSON data with the values of the latest * frame. - * 9) UI dashboard updates the widgets with the C++ model provided by this class. + * 9) UI dashboard updates the widgets with the C++ model provided by this + * class. */ class Frame { public: - ~Frame(); + ~Frame(); - void clear(); - QString title() const; - int groupCount() const; - QVector &groups(); - bool read(const QJsonObject &object); - Q_INVOKABLE const JSON::Group &getGroup(const int index) const; + void clear(); + QString title() const; + int groupCount() const; + QVector &groups(); + bool read(const QJsonObject &object); + Q_INVOKABLE const JSON::Group &getGroup(const int index) const; - inline bool isValid() const { return !title().isEmpty() && groupCount() > 0; } + inline bool isValid() const { return !title().isEmpty() && groupCount() > 0; } private: - QString m_title; - QVector m_groups; + QString m_title; + QVector m_groups; }; -} +} // namespace JSON diff --git a/src/JSON/Generator.cpp b/src/JSON/Generator.cpp index dba58340..b82232aa 100644 --- a/src/JSON/Generator.cpp +++ b/src/JSON/Generator.cpp @@ -38,14 +38,14 @@ * Initializes the JSON Parser class and connects appropiate SIGNALS/SLOTS */ JSON::Generator::Generator() - : m_opMode(kAutomatic) + : m_opMode(kAutomatic) { - // clang-format off + // clang-format off connect(&IO::Manager::instance(), &IO::Manager::frameReceived, this, &JSON::Generator::readData); - // clang-format on + // clang-format on - readSettings(); + readSettings(); } /** @@ -53,8 +53,8 @@ JSON::Generator::Generator() */ JSON::Generator &JSON::Generator::instance() { - static Generator singleton; - return singleton; + static Generator singleton; + return singleton; } /** @@ -62,7 +62,7 @@ JSON::Generator &JSON::Generator::instance() */ QJsonObject &JSON::Generator::json() { - return m_json; + return m_json; } /** @@ -70,13 +70,13 @@ QJsonObject &JSON::Generator::json() */ QString JSON::Generator::jsonMapFilename() const { - if (m_jsonMap.isOpen()) - { - auto fileInfo = QFileInfo(m_jsonMap.fileName()); - return fileInfo.fileName(); - } + if (m_jsonMap.isOpen()) + { + auto fileInfo = QFileInfo(m_jsonMap.fileName()); + return fileInfo.fileName(); + } - return ""; + return ""; } /** @@ -84,13 +84,13 @@ QString JSON::Generator::jsonMapFilename() const */ QString JSON::Generator::jsonMapFilepath() const { - if (m_jsonMap.isOpen()) - { - auto fileInfo = QFileInfo(m_jsonMap.fileName()); - return fileInfo.filePath(); - } + if (m_jsonMap.isOpen()) + { + auto fileInfo = QFileInfo(m_jsonMap.fileName()); + return fileInfo.filePath(); + } - return ""; + return ""; } /** @@ -98,7 +98,7 @@ QString JSON::Generator::jsonMapFilepath() const */ JSON::Generator::OperationMode JSON::Generator::operationMode() const { - return m_opMode; + return m_opMode; } /** @@ -106,15 +106,15 @@ JSON::Generator::OperationMode JSON::Generator::operationMode() const */ void JSON::Generator::loadJsonMap() { - // clang-format off + // clang-format off auto file = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select JSON map file"), Project::Model::instance().jsonProjectsPath(), tr("JSON files") + " (*.json)"); - // clang-format on + // clang-format on - if (!file.isEmpty()) - loadJsonMap(file); + if (!file.isEmpty()) + loadJsonMap(file); } /** @@ -122,59 +122,61 @@ void JSON::Generator::loadJsonMap() */ void JSON::Generator::loadJsonMap(const QString &path) { - // Validate path - if (path.isEmpty()) - return; + // Validate path + if (path.isEmpty()) + return; - // Close previous file (if open) - if (m_jsonMap.isOpen()) + // Close previous file (if open) + if (m_jsonMap.isOpen()) + { + m_jsonMap.close(); + m_json = QJsonObject(); + Q_EMIT jsonFileMapChanged(); + } + + // Try to open the file (read only mode) + m_jsonMap.setFileName(path); + if (m_jsonMap.open(QFile::ReadOnly)) + { + // Read data & validate JSON from file + QJsonParseError error; + auto data = m_jsonMap.readAll(); + auto document = QJsonDocument::fromJson(data, &error); + if (error.error != QJsonParseError::NoError) { - m_jsonMap.close(); - m_json = QJsonObject(); - Q_EMIT jsonFileMapChanged(); + m_jsonMap.close(); + writeSettings(""); + Misc::Utilities::showMessageBox(tr("JSON parse error"), + error.errorString()); } - // Try to open the file (read only mode) - m_jsonMap.setFileName(path); - if (m_jsonMap.open(QFile::ReadOnly)) - { - // Read data & validate JSON from file - QJsonParseError error; - auto data = m_jsonMap.readAll(); - auto document = QJsonDocument::fromJson(data, &error); - if (error.error != QJsonParseError::NoError) - { - m_jsonMap.close(); - writeSettings(""); - Misc::Utilities::showMessageBox(tr("JSON parse error"), error.errorString()); - } - - // JSON contains no errors, load compacted JSON document & save settings - else - { - // Save settings - writeSettings(path); - - // Load compacted JSON document - document.object().remove("frameParser"); - m_json = document.object(); - } - - // Get rid of warnings - Q_UNUSED(document); - } - - // Open error + // JSON contains no errors, load compacted JSON document & save settings else { - writeSettings(""); - Misc::Utilities::showMessageBox(tr("Cannot read JSON file"), - tr("Please check file permissions & location")); - m_jsonMap.close(); + // Save settings + writeSettings(path); + + // Load compacted JSON document + document.object().remove("frameParser"); + m_json = document.object(); } - // Update UI - Q_EMIT jsonFileMapChanged(); + // Get rid of warnings + Q_UNUSED(document); + } + + // Open error + else + { + writeSettings(""); + Misc::Utilities::showMessageBox( + tr("Cannot read JSON file"), + tr("Please check file permissions & location")); + m_jsonMap.close(); + } + + // Update UI + Q_EMIT jsonFileMapChanged(); } /** @@ -190,10 +192,11 @@ void JSON::Generator::loadJsonMap(const QString &path) * @c kAutomatic serial data contains the JSON data frame, good for simple * applications or for prototyping. */ -void JSON::Generator::setOperationMode(const JSON::Generator::OperationMode &mode) +void JSON::Generator::setOperationMode( + const JSON::Generator::OperationMode &mode) { - m_opMode = mode; - Q_EMIT operationModeChanged(); + m_opMode = mode; + Q_EMIT operationModeChanged(); } /** @@ -201,9 +204,9 @@ void JSON::Generator::setOperationMode(const JSON::Generator::OperationMode &mod */ void JSON::Generator::readSettings() { - auto path = m_settings.value("json_map_location", "").toString(); - if (!path.isEmpty()) - loadJsonMap(path); + auto path = m_settings.value("json_map_location", "").toString(); + if (!path.isEmpty()) + loadJsonMap(path); } /** @@ -211,7 +214,7 @@ void JSON::Generator::readSettings() */ void JSON::Generator::writeSettings(const QString &path) { - m_settings.setValue("json_map_location", path); + m_settings.setValue("json_map_location", path); } /** @@ -229,67 +232,63 @@ void JSON::Generator::writeSettings(const QString &path) */ void JSON::Generator::readData(const QByteArray &data) { - // Data empty, abort - if (data.isEmpty()) - return; + // Data empty, abort + if (data.isEmpty()) + return; - // Serial device sends JSON (auto mode) - QJsonObject jsonData; - if (operationMode() == JSON::Generator::kAutomatic) - jsonData = QJsonDocument::fromJson(data).object(); + // Serial device sends JSON (auto mode) + QJsonObject jsonData; + if (operationMode() == JSON::Generator::kAutomatic) + jsonData = QJsonDocument::fromJson(data).object(); - // Data is separated and parsed by Serial Studio (manual mode) - else + // Data is separated and parsed by Serial Studio (manual mode) + else + { + // Copy JSON map + jsonData = m_json; + + // Get fields from frame parser function + auto fields = Project::CodeEditor::instance().parse( + QString::fromUtf8(data), IO::Manager::instance().separatorSequence()); + + // Replace data in JSON map + auto groups = jsonData.value("groups").toArray(); + for (int i = 0; i < groups.count(); ++i) { - // Copy JSON map - jsonData = m_json; + // Get group & list of datasets + auto group = groups.at(i).toObject(); + auto datasets = group.value("datasets").toArray(); - // Get fields from frame parser function - auto fields = Project::CodeEditor::instance().parse( - QString::fromUtf8(data), IO::Manager::instance().separatorSequence()); + // Evaluate each dataset + for (int j = 0; j < datasets.count(); ++j) + { + auto dataset = datasets.at(j).toObject(); + auto index = dataset.value("index").toInt(); - // Replace data in JSON map - auto groups = jsonData.value("groups").toArray(); - for (int i = 0; i < groups.count(); ++i) + if (index <= fields.count() && index >= 1) { - // Get group & list of datasets - auto group = groups.at(i).toObject(); - auto datasets = group.value("datasets").toArray(); - - // Evaluate each dataset - for (int j = 0; j < datasets.count(); ++j) - { - auto dataset = datasets.at(j).toObject(); - auto index = dataset.value("index").toInt(); - - if (index <= fields.count() && index >= 1) - { - dataset.remove("value"); - dataset.insert("value", QJsonValue(fields.at(index - 1))); - datasets.removeAt(j); - datasets.insert(j, dataset); - } - } - - // Update datasets in group - group.remove("datasets"); - group.insert("datasets", datasets); - - // Update group in groups array - groups.removeAt(i); - groups.insert(i, group); - - // Update groups array in JSON frame - jsonData.remove("groups"); - jsonData.insert("groups", groups); + dataset.remove("value"); + dataset.insert("value", QJsonValue(fields.at(index - 1))); + datasets.removeAt(j); + datasets.insert(j, dataset); } + } + + // Update datasets in group + group.remove("datasets"); + group.insert("datasets", datasets); + + // Update group in groups array + groups.removeAt(i); + groups.insert(i, group); + + // Update groups array in JSON frame + jsonData.remove("groups"); + jsonData.insert("groups", groups); } + } - // Update UI - if (!jsonData.isEmpty()) - Q_EMIT jsonChanged(jsonData); + // Update UI + if (!jsonData.isEmpty()) + Q_EMIT jsonChanged(jsonData); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Generator.cpp" -#endif diff --git a/src/JSON/Generator.h b/src/JSON/Generator.h index d326594e..44f4ef9a 100644 --- a/src/JSON/Generator.h +++ b/src/JSON/Generator.h @@ -54,11 +54,12 @@ namespace JSON * 7) UI dashboard feeds JSON data to a @c Frame object. * 8) The @c Frame object creates a model of the JSON data with the values of * the latest received frame. - * 9) UI dashboard updates the widgets with the C++ model provided by this class. + * 9) UI dashboard updates the widgets with the C++ model provided by this + * class. */ class Generator : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(QString jsonMapFilename READ jsonMapFilename @@ -70,52 +71,52 @@ class Generator : public QObject READ operationMode WRITE setOperationMode NOTIFY operationModeChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void jsonFileMapChanged(); - void operationModeChanged(); - void jsonChanged(const QJsonObject &json); + void jsonFileMapChanged(); + void operationModeChanged(); + void jsonChanged(const QJsonObject &json); private: - explicit Generator(); - Generator(Generator &&) = delete; - Generator(const Generator &) = delete; - Generator &operator=(Generator &&) = delete; - Generator &operator=(const Generator &) = delete; + explicit Generator(); + Generator(Generator &&) = delete; + Generator(const Generator &) = delete; + Generator &operator=(Generator &&) = delete; + Generator &operator=(const Generator &) = delete; public: - enum OperationMode - { - kManual = 0x00, - kAutomatic = 0x01 - }; - Q_ENUM(OperationMode) + enum OperationMode + { + kManual = 0x00, + kAutomatic = 0x01 + }; + Q_ENUM(OperationMode) - static Generator &instance(); + static Generator &instance(); - QJsonObject &json(); - QString jsonMapFilename() const; - QString jsonMapFilepath() const; - OperationMode operationMode() const; + QJsonObject &json(); + QString jsonMapFilename() const; + QString jsonMapFilepath() const; + OperationMode operationMode() const; public Q_SLOTS: - void loadJsonMap(); - void loadJsonMap(const QString &path); - void setOperationMode(const JSON::Generator::OperationMode &mode); + void loadJsonMap(); + void loadJsonMap(const QString &path); + void setOperationMode(const JSON::Generator::OperationMode &mode); public Q_SLOTS: - void readSettings(); - void writeSettings(const QString &path); + void readSettings(); + void writeSettings(const QString &path); private Q_SLOTS: - void readData(const QByteArray &data); + void readData(const QByteArray &data); private: - QFile m_jsonMap; - QJsonObject m_json; - QSettings m_settings; - OperationMode m_opMode; - QJsonParseError m_error; + QFile m_jsonMap; + QJsonObject m_json; + QSettings m_settings; + OperationMode m_opMode; + QJsonParseError m_error; }; -} +} // namespace JSON diff --git a/src/JSON/Group.cpp b/src/JSON/Group.cpp index a2ec8b4c..e3a868cd 100644 --- a/src/JSON/Group.cpp +++ b/src/JSON/Group.cpp @@ -30,7 +30,7 @@ static JSON::Dataset EMPTY_DATASET; */ JSON::Group::~Group() { - m_datasets.clear(); + m_datasets.clear(); } /** @@ -38,7 +38,7 @@ JSON::Group::~Group() */ QString JSON::Group::title() const { - return m_title; + return m_title; } /** @@ -46,7 +46,7 @@ QString JSON::Group::title() const */ QString JSON::Group::widget() const { - return m_widget; + return m_widget; } /** @@ -54,7 +54,7 @@ QString JSON::Group::widget() const */ int JSON::Group::datasetCount() const { - return m_datasets.count(); + return m_datasets.count(); } /** @@ -62,18 +62,19 @@ int JSON::Group::datasetCount() const */ QVector &JSON::Group::datasets() { - return m_datasets; + return m_datasets; } /** - * @return The dataset at the given @a index,vreturns @c Q_NULLPTR on invalid index + * @return The dataset at the given @a index,vreturns @c Q_NULLPTR on invalid + * index */ const JSON::Dataset &JSON::Group::getDataset(const int index) const { - if (m_datasets.count() > index) - return m_datasets.at(index); + if (m_datasets.count() > index) + return m_datasets.at(index); - return EMPTY_DATASET; + return EMPTY_DATASET; } /** @@ -84,32 +85,32 @@ const JSON::Dataset &JSON::Group::getDataset(const int index) const */ bool JSON::Group::read(const QJsonObject &object) { - if (!object.isEmpty()) + if (!object.isEmpty()) + { + auto title = object.value("title").toString(); + auto array = object.value("datasets").toArray(); + auto widget = object.value("widget").toString(); + + if (!title.isEmpty() && !array.isEmpty()) { - auto title = object.value("title").toString(); - auto array = object.value("datasets").toArray(); - auto widget = object.value("widget").toString(); + m_title = title; + m_widget = widget; + m_datasets.clear(); - if (!title.isEmpty() && !array.isEmpty()) + for (auto i = 0; i < array.count(); ++i) + { + auto object = array.at(i).toObject(); + if (!object.isEmpty()) { - m_title = title; - m_widget = widget; - m_datasets.clear(); - - for (auto i = 0; i < array.count(); ++i) - { - auto object = array.at(i).toObject(); - if (!object.isEmpty()) - { - Dataset dataset; - if (dataset.read(object)) - m_datasets.append(dataset); - } - } - - return datasetCount() > 0; + Dataset dataset; + if (dataset.read(object)) + m_datasets.append(dataset); } - } + } - return false; + return datasetCount() > 0; + } + } + + return false; } diff --git a/src/JSON/Group.h b/src/JSON/Group.h index 29a17e4b..35aacd69 100644 --- a/src/JSON/Group.h +++ b/src/JSON/Group.h @@ -60,22 +60,22 @@ namespace JSON class Group { public: - ~Group(); + ~Group(); - QString title() const; - QString widget() const; - int datasetCount() const; - QVector &datasets(); - bool read(const QJsonObject &object); + QString title() const; + QString widget() const; + int datasetCount() const; + QVector &datasets(); + bool read(const QJsonObject &object); - Q_INVOKABLE const JSON::Dataset &getDataset(const int index) const; + Q_INVOKABLE const JSON::Dataset &getDataset(const int index) const; private: - QString m_title; - QString m_widget; - QVector m_datasets; + QString m_title; + QString m_widget; + QVector m_datasets; - friend class UI::Dashboard; - friend class Project::Model; + friend class UI::Dashboard; + friend class Project::Model; }; -} +} // namespace JSON diff --git a/src/MQTT/Client.cpp b/src/MQTT/Client.cpp index 7b9ec697..553a3182 100644 --- a/src/MQTT/Client.cpp +++ b/src/MQTT/Client.cpp @@ -32,21 +32,24 @@ * Constructor function */ MQTT::Client::Client() - : m_topic("") - , m_lookupActive(false) - , m_sentMessages(0) - , m_clientMode(MQTTClientMode::ClientPublisher) - , m_client(Q_NULLPTR) + : m_topic("") + , m_lookupActive(false) + , m_sentMessages(0) + , m_clientMode(MQTTClientMode::ClientPublisher) + , m_client(Q_NULLPTR) { - // Configure new client - regenerateClient(); + // Configure new client + regenerateClient(); - // Send data periodically & reset statistics when disconnected/connected to a device - auto io = &IO::Manager::instance(); - auto te = &Misc::TimerEvents::instance(); - connect(te, &Misc::TimerEvents::timeout1Hz, this, &MQTT::Client::sendData); - connect(io, &IO::Manager::frameReceived, this, &MQTT::Client::onFrameReceived); - connect(io, &IO::Manager::connectedChanged, this, &MQTT::Client::resetStatistics); + // Send data periodically & reset statistics when disconnected/connected to a + // device + auto io = &IO::Manager::instance(); + auto te = &Misc::TimerEvents::instance(); + connect(te, &Misc::TimerEvents::timeout1Hz, this, &MQTT::Client::sendData); + connect(io, &IO::Manager::frameReceived, this, + &MQTT::Client::onFrameReceived); + connect(io, &IO::Manager::connectedChanged, this, + &MQTT::Client::resetStatistics); } /** @@ -54,7 +57,7 @@ MQTT::Client::Client() */ MQTT::Client::~Client() { - delete m_client; + delete m_client; } /** @@ -62,8 +65,8 @@ MQTT::Client::~Client() */ MQTT::Client &MQTT::Client::instance() { - static Client singleton; - return singleton; + static Client singleton; + return singleton; } /** @@ -74,8 +77,8 @@ MQTT::Client &MQTT::Client::instance() */ quint8 MQTT::Client::qos() const { - Q_ASSERT(m_client); - return m_client->willQos(); + Q_ASSERT(m_client); + return m_client->willQos(); } /** @@ -83,8 +86,8 @@ quint8 MQTT::Client::qos() const */ bool MQTT::Client::retain() const { - Q_ASSERT(m_client); - return m_client->willRetain(); + Q_ASSERT(m_client); + return m_client->willRetain(); } /** @@ -92,8 +95,8 @@ bool MQTT::Client::retain() const */ quint16 MQTT::Client::port() const { - Q_ASSERT(m_client); - return m_client->port(); + Q_ASSERT(m_client); + return m_client->port(); } /** @@ -101,7 +104,7 @@ quint16 MQTT::Client::port() const */ QString MQTT::Client::topic() const { - return m_topic; + return m_topic; } /** @@ -109,29 +112,30 @@ QString MQTT::Client::topic() const */ int MQTT::Client::sslProtocol() const { - return m_sslProtocol; + return m_sslProtocol; } /** - * Returns the index of the MQTT version, corresponding to the list returned by the + * Returns the index of the MQTT version, corresponding to the list returned by + * the * @c mqttVersions() function. */ int MQTT::Client::mqttVersion() const { - Q_ASSERT(m_client); + Q_ASSERT(m_client); - switch (m_client->version()) - { - case QMQTT::V3_1_0: - return 0; - break; - case QMQTT::V3_1_1: - return 1; - break; - default: - return -1; - break; - } + switch (m_client->version()) + { + case QMQTT::V3_1_0: + return 0; + break; + case QMQTT::V3_1_1: + return 1; + break; + default: + return -1; + break; + } } /** @@ -139,7 +143,7 @@ int MQTT::Client::mqttVersion() const */ bool MQTT::Client::sslEnabled() const { - return m_sslEnabled; + return m_sslEnabled; } /** @@ -149,7 +153,7 @@ bool MQTT::Client::sslEnabled() const */ int MQTT::Client::clientMode() const { - return m_clientMode; + return m_clientMode; } /** @@ -157,8 +161,8 @@ int MQTT::Client::clientMode() const */ QString MQTT::Client::username() const { - Q_ASSERT(m_client); - return m_client->username(); + Q_ASSERT(m_client); + return m_client->username(); } /** @@ -166,8 +170,8 @@ QString MQTT::Client::username() const */ QString MQTT::Client::password() const { - Q_ASSERT(m_client); - return QString::fromUtf8(m_client->password()); + Q_ASSERT(m_client); + return QString::fromUtf8(m_client->password()); } /** @@ -175,8 +179,8 @@ QString MQTT::Client::password() const */ QString MQTT::Client::host() const { - Q_ASSERT(m_client); - return m_client->hostName(); + Q_ASSERT(m_client); + return m_client->hostName(); } /** @@ -184,26 +188,27 @@ QString MQTT::Client::host() const */ quint16 MQTT::Client::keepAlive() const { - Q_ASSERT(m_client); - return m_client->keepAlive(); + Q_ASSERT(m_client); + return m_client->keepAlive(); } /** - * Returns @c true if the MQTT module is currently performing a DNS lookup of the MQTT - * broker/server domain. + * Returns @c true if the MQTT module is currently performing a DNS lookup of + * the MQTT broker/server domain. */ bool MQTT::Client::lookupActive() const { - return m_lookupActive; + return m_lookupActive; } /** - * Returns @c true if the MQTT module is connected to the broker, the topic is not empty - * and the client is configured to act as an MQTT subscriber. + * Returns @c true if the MQTT module is connected to the broker, the topic is + * not empty and the client is configured to act as an MQTT subscriber. */ bool MQTT::Client::isSubscribed() const { - return isConnectedToHost() && !topic().isEmpty() && clientMode() == ClientSubscriber; + return isConnectedToHost() && !topic().isEmpty() + && clientMode() == ClientSubscriber; } /** @@ -211,8 +216,8 @@ bool MQTT::Client::isSubscribed() const */ bool MQTT::Client::isConnectedToHost() const { - Q_ASSERT(m_client); - return m_client->isConnectedToHost(); + Q_ASSERT(m_client); + return m_client->isConnectedToHost(); } /** @@ -220,13 +225,13 @@ bool MQTT::Client::isConnectedToHost() const */ StringList MQTT::Client::qosLevels() const { - // clang-format off + // clang-format off return StringList { tr("0: At most once"), tr("1: At least once"), tr("2: Exactly once") }; - // clang-format on + // clang-format on } /** @@ -234,7 +239,7 @@ StringList MQTT::Client::qosLevels() const */ StringList MQTT::Client::clientModes() const { - return StringList { tr("Publisher"), tr("Subscriber") }; + return StringList{tr("Publisher"), tr("Subscriber")}; } /** @@ -242,7 +247,7 @@ StringList MQTT::Client::clientModes() const */ StringList MQTT::Client::mqttVersions() const { - return StringList { "MQTT 3.1.0", "MQTT 3.1.1" }; + return StringList{"MQTT 3.1.0", "MQTT 3.1.1"}; } /** @@ -251,12 +256,11 @@ StringList MQTT::Client::mqttVersions() const StringList MQTT::Client::sslProtocols() const { #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - return StringList { tr("System default"), "TLS v1.0", "TLS v1.1", "TLS v1.2" }; + return StringList{tr("System default"), "TLS v1.0", "TLS v1.1", "TLS v1.2"}; #else - return StringList { - tr("System default"), "TLS v1.0", "TLS v1.1", "TLS v1.2", - "TLS v1.3 (or later)", "DTLS v1.0", "DTLS v1.2", "DTLS v1.2 (or later)" - }; + return StringList{ + tr("System default"), "TLS v1.0", "TLS v1.1", "TLS v1.2", + "TLS v1.3 (or later)", "DTLS v1.0", "DTLS v1.2", "DTLS v1.2 (or later)"}; #endif } @@ -265,7 +269,7 @@ StringList MQTT::Client::sslProtocols() const */ QString MQTT::Client::caFilePath() const { - return m_caFilePath; + return m_caFilePath; } /** @@ -274,15 +278,15 @@ QString MQTT::Client::caFilePath() const */ void MQTT::Client::loadCaFile() { - // Prompt user to select a CA file - // clang-format off + // Prompt user to select a CA file + // clang-format off auto path = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select CA file"), QDir::homePath()); - // clang-format on + // clang-format on - // Try to load the *.ca file - loadCaFile(path); + // Try to load the *.ca file + loadCaFile(path); } /** @@ -290,20 +294,20 @@ void MQTT::Client::loadCaFile() */ void MQTT::Client::connectToHost() { - Q_ASSERT(m_client); - m_client->connectToHost(); + Q_ASSERT(m_client); + m_client->connectToHost(); } /** - * Connects/disconnects the application from the current MQTT broker. This function is - * used as a convenience for the connect/disconnect button. + * Connects/disconnects the application from the current MQTT broker. This + * function is used as a convenience for the connect/disconnect button. */ void MQTT::Client::toggleConnection() { - if (isConnectedToHost()) - disconnectFromHost(); - else - connectToHost(); + if (isConnectedToHost()) + disconnectFromHost(); + else + connectToHost(); } /** @@ -311,8 +315,8 @@ void MQTT::Client::toggleConnection() */ void MQTT::Client::disconnectFromHost() { - Q_ASSERT(m_client); - m_client->disconnectFromHost(); + Q_ASSERT(m_client); + m_client->disconnectFromHost(); } /** @@ -320,9 +324,9 @@ void MQTT::Client::disconnectFromHost() */ void MQTT::Client::setQos(const quint8 qos) { - Q_ASSERT(m_client); - m_client->setWillQos(qos); - Q_EMIT qosChanged(); + Q_ASSERT(m_client); + m_client->setWillQos(qos); + Q_EMIT qosChanged(); } /** @@ -330,9 +334,9 @@ void MQTT::Client::setQos(const quint8 qos) */ void MQTT::Client::lookup(const QString &host) { - m_lookupActive = true; - Q_EMIT lookupActiveChanged(); - QHostInfo::lookupHost(host.simplified(), this, &MQTT::Client::lookupFinished); + m_lookupActive = true; + Q_EMIT lookupActiveChanged(); + QHostInfo::lookupHost(host.simplified(), this, &MQTT::Client::lookupFinished); } /** @@ -340,9 +344,9 @@ void MQTT::Client::lookup(const QString &host) */ void MQTT::Client::setPort(const quint16 port) { - Q_ASSERT(m_client); - m_client->setPort(port); - Q_EMIT portChanged(); + Q_ASSERT(m_client); + m_client->setPort(port); + Q_EMIT portChanged(); } /** @@ -350,20 +354,21 @@ void MQTT::Client::setPort(const quint16 port) */ void MQTT::Client::setHost(const QString &host) { - Q_ASSERT(m_client); - m_client->setHostName(host); - Q_EMIT hostChanged(); + Q_ASSERT(m_client); + m_client->setHostName(host); + Q_EMIT hostChanged(); } /** - * If set to @c true, the @c retain flag shall be appended to the MQTT message so that - * new clients connecting to the broker will immediately receive the last "good" message. + * If set to @c true, the @c retain flag shall be appended to the MQTT message + * so that new clients connecting to the broker will immediately receive the + * last "good" message. */ void MQTT::Client::setRetain(const bool retain) { - Q_ASSERT(m_client); - m_client->setWillRetain(retain); - Q_EMIT retainChanged(); + Q_ASSERT(m_client); + m_client->setWillRetain(retain); + Q_EMIT retainChanged(); } /** @@ -373,8 +378,8 @@ void MQTT::Client::setRetain(const bool retain) */ void MQTT::Client::setClientMode(const int mode) { - m_clientMode = static_cast(mode); - Q_EMIT clientModeChanged(); + m_clientMode = static_cast(mode); + Q_EMIT clientModeChanged(); } /** @@ -382,8 +387,8 @@ void MQTT::Client::setClientMode(const int mode) */ void MQTT::Client::setTopic(const QString &topic) { - m_topic = topic; - Q_EMIT topicChanged(); + m_topic = topic; + Q_EMIT topicChanged(); } /** @@ -392,34 +397,35 @@ void MQTT::Client::setTopic(const QString &topic) */ void MQTT::Client::loadCaFile(const QString &path) { - // Save *.ca file path - m_caFilePath = path; - Q_EMIT caFilePathChanged(); + // Save *.ca file path + m_caFilePath = path; + Q_EMIT caFilePathChanged(); - // Empty path, abort - if (path.isEmpty()) - return; + // Empty path, abort + if (path.isEmpty()) + return; - // Try to read file contents - QByteArray data; - QFile file(path); - if (file.open(QFile::ReadOnly)) - { - data = file.readAll(); - file.close(); - } + // Try to read file contents + QByteArray data; + QFile file(path); + if (file.open(QFile::ReadOnly)) + { + data = file.readAll(); + file.close(); + } - // Read error, alert user - else - { - Misc::Utilities::showMessageBox(tr("Cannot open CA file!"), file.errorString()); - file.close(); - return; - } + // Read error, alert user + else + { + Misc::Utilities::showMessageBox(tr("Cannot open CA file!"), + file.errorString()); + file.close(); + return; + } - // Load certificate into SSL configuration - m_sslConfiguration.setCaCertificates(QSslCertificate::fromData(data)); - regenerateClient(); + // Load certificate into SSL configuration + m_sslConfiguration.setCaCertificates(QSslCertificate::fromData(data)); + regenerateClient(); } /** @@ -428,57 +434,57 @@ void MQTT::Client::loadCaFile(const QString &path) void MQTT::Client::setSslProtocol(const int index) { #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - switch (index) - { - case 0: - m_sslConfiguration.setProtocol(QSsl::SecureProtocols); - break; - case 1: - m_sslConfiguration.setProtocol(QSsl::TlsV1_0); - break; - case 2: - m_sslConfiguration.setProtocol(QSsl::TlsV1_1); - break; - case 3: - m_sslConfiguration.setProtocol(QSsl::TlsV1_2); - break; - default: - break; - } + switch (index) + { + case 0: + m_sslConfiguration.setProtocol(QSsl::SecureProtocols); + break; + case 1: + m_sslConfiguration.setProtocol(QSsl::TlsV1_0); + break; + case 2: + m_sslConfiguration.setProtocol(QSsl::TlsV1_1); + break; + case 3: + m_sslConfiguration.setProtocol(QSsl::TlsV1_2); + break; + default: + break; + } #else - switch (index) - { - case 0: - m_sslConfiguration.setProtocol(QSsl::SecureProtocols); - break; - case 1: - m_sslConfiguration.setProtocol(QSsl::TlsV1_0); - break; - case 2: - m_sslConfiguration.setProtocol(QSsl::TlsV1_1); - break; - case 3: - m_sslConfiguration.setProtocol(QSsl::TlsV1_2); - break; - case 4: - m_sslConfiguration.setProtocol(QSsl::TlsV1_3OrLater); - break; - case 5: - m_sslConfiguration.setProtocol(QSsl::DtlsV1_0); - break; - case 6: - m_sslConfiguration.setProtocol(QSsl::DtlsV1_2); - break; - case 7: - m_sslConfiguration.setProtocol(QSsl::DtlsV1_2OrLater); - break; - default: - break; - } + switch (index) + { + case 0: + m_sslConfiguration.setProtocol(QSsl::SecureProtocols); + break; + case 1: + m_sslConfiguration.setProtocol(QSsl::TlsV1_0); + break; + case 2: + m_sslConfiguration.setProtocol(QSsl::TlsV1_1); + break; + case 3: + m_sslConfiguration.setProtocol(QSsl::TlsV1_2); + break; + case 4: + m_sslConfiguration.setProtocol(QSsl::TlsV1_3OrLater); + break; + case 5: + m_sslConfiguration.setProtocol(QSsl::DtlsV1_0); + break; + case 6: + m_sslConfiguration.setProtocol(QSsl::DtlsV1_2); + break; + case 7: + m_sslConfiguration.setProtocol(QSsl::DtlsV1_2OrLater); + break; + default: + break; + } #endif - regenerateClient(); - Q_EMIT sslProtocolChanged(); + regenerateClient(); + Q_EMIT sslProtocolChanged(); } /** @@ -486,9 +492,9 @@ void MQTT::Client::setSslProtocol(const int index) */ void MQTT::Client::setSslEnabled(const bool enabled) { - m_sslEnabled = enabled; - regenerateClient(); - Q_EMIT sslEnabledChanged(); + m_sslEnabled = enabled; + regenerateClient(); + Q_EMIT sslEnabledChanged(); } /** @@ -496,9 +502,9 @@ void MQTT::Client::setSslEnabled(const bool enabled) */ void MQTT::Client::setUsername(const QString &username) { - Q_ASSERT(m_client); - m_client->setUsername(username); - Q_EMIT usernameChanged(); + Q_ASSERT(m_client); + m_client->setUsername(username); + Q_EMIT usernameChanged(); } /** @@ -506,21 +512,21 @@ void MQTT::Client::setUsername(const QString &username) */ void MQTT::Client::setPassword(const QString &password) { - Q_ASSERT(m_client); - m_client->setPassword(password.toUtf8()); - Q_EMIT passwordChanged(); + Q_ASSERT(m_client); + m_client->setPassword(password.toUtf8()); + Q_EMIT passwordChanged(); } /** - * Sets the maximum time interval that is permitted to elapse between the point at which - * the Client finishes transmitting one Control Packet and the point it starts sending the - * next packet. + * Sets the maximum time interval that is permitted to elapse between the point + * at which the Client finishes transmitting one Control Packet and the point it + * starts sending the next packet. */ void MQTT::Client::setKeepAlive(const quint16 keepAlive) { - Q_ASSERT(m_client); - m_client->setKeepAlive(keepAlive); - Q_EMIT keepAliveChanged(); + Q_ASSERT(m_client); + m_client->setKeepAlive(keepAlive); + Q_EMIT keepAliveChanged(); } /** @@ -528,21 +534,21 @@ void MQTT::Client::setKeepAlive(const quint16 keepAlive) */ void MQTT::Client::setMqttVersion(const int versionIndex) { - Q_ASSERT(m_client); + Q_ASSERT(m_client); - switch (versionIndex) - { - case 0: - m_client->setVersion(QMQTT::V3_1_0); - break; - case 1: - m_client->setVersion(QMQTT::V3_1_1); - break; - default: - break; - } + switch (versionIndex) + { + case 0: + m_client->setVersion(QMQTT::V3_1_0); + break; + case 1: + m_client->setVersion(QMQTT::V3_1_1); + break; + default: + break; + } - Q_EMIT mqttVersionChanged(); + Q_EMIT mqttVersionChanged(); } /** @@ -550,26 +556,26 @@ void MQTT::Client::setMqttVersion(const int versionIndex) */ void MQTT::Client::sendData() { - Q_ASSERT(m_client); + Q_ASSERT(m_client); - // Create data byte array - QByteArray data; - for (int i = 0; i < m_frames.count(); ++i) - { - data.append(m_frames.at(i)); - data.append("\n"); - } + // Create data byte array + QByteArray data; + for (int i = 0; i < m_frames.count(); ++i) + { + data.append(m_frames.at(i)); + data.append("\n"); + } - // Create & send MQTT message - if (!data.isEmpty()) - { - QMQTT::Message message(m_sentMessages, topic(), data); - m_client->publish(message); - ++m_sentMessages; - } + // Create & send MQTT message + if (!data.isEmpty()) + { + QMQTT::Message message(m_sentMessages, topic(), data); + m_client->publish(message); + ++m_sentMessages; + } - // Clear frame list - m_frames.clear(); + // Clear frame list + m_frames.clear(); } /** @@ -577,43 +583,46 @@ void MQTT::Client::sendData() */ void MQTT::Client::resetStatistics() { - m_sentMessages = 0; - m_frames.clear(); + m_sentMessages = 0; + m_frames.clear(); } /** - * Subscribe/unsubscripe to the set MQTT topic when the connection state is changed. + * Subscribe/unsubscripe to the set MQTT topic when the connection state is + * changed. */ void MQTT::Client::onConnectedChanged() { - Q_ASSERT(m_client); + Q_ASSERT(m_client); - if (isConnectedToHost()) - m_client->subscribe(topic()); - else - m_client->unsubscribe(topic()); + if (isConnectedToHost()) + m_client->subscribe(topic()); + else + m_client->unsubscribe(topic()); } /** * Sets the host IP address when the lookup finishes. - * If the lookup fails, the error code/string shall be shown to the user in a messagebox. + * If the lookup fails, the error code/string shall be shown to the user in a + * messagebox. */ void MQTT::Client::lookupFinished(const QHostInfo &info) { - m_lookupActive = false; - Q_EMIT lookupActiveChanged(); + m_lookupActive = false; + Q_EMIT lookupActiveChanged(); - if (info.error() == QHostInfo::NoError) + if (info.error() == QHostInfo::NoError) + { + auto addresses = info.addresses(); + if (addresses.count() >= 1) { - auto addresses = info.addresses(); - if (addresses.count() >= 1) - { - setHost(addresses.first().toString()); - return; - } + setHost(addresses.first().toString()); + return; } + } - Misc::Utilities::showMessageBox(tr("IP address lookup error"), info.errorString()); + Misc::Utilities::showMessageBox(tr("IP address lookup error"), + info.errorString()); } /** @@ -621,236 +630,237 @@ void MQTT::Client::lookupFinished(const QHostInfo &info) */ void MQTT::Client::onError(const QMQTT::ClientError error) { - QString str; + QString str; - switch (error) - { - case QMQTT::UnknownError: - str = tr("Unknown error"); - break; - case QMQTT::SocketConnectionRefusedError: - str = tr("Connection refused"); - break; - case QMQTT::SocketRemoteHostClosedError: - str = tr("Remote host closed the connection"); - break; - case QMQTT::SocketHostNotFoundError: - str = tr("Host not found"); - break; - case QMQTT::SocketAccessError: - str = tr("Socket access error"); - break; - case QMQTT::SocketResourceError: - str = tr("Socket resource error"); - break; - case QMQTT::SocketTimeoutError: - str = tr("Socket timeout"); - break; - case QMQTT::SocketDatagramTooLargeError: - str = tr("Socket datagram too large"); - break; - case QMQTT::SocketNetworkError: - str = tr("Network error"); - break; - case QMQTT::SocketAddressInUseError: - str = tr("Address in use"); - break; - case QMQTT::SocketAddressNotAvailableError: - str = tr("Address not available"); - break; - case QMQTT::SocketUnsupportedSocketOperationError: - str = tr("Unsupported socket operation"); - break; - case QMQTT::SocketUnfinishedSocketOperationError: - str = tr("Unfinished socket operation"); - break; - case QMQTT::SocketProxyAuthenticationRequiredError: - str = tr("Proxy authentication required"); - break; - case QMQTT::SocketSslHandshakeFailedError: - str = tr("SSL handshake failed"); - break; - case QMQTT::SocketProxyConnectionRefusedError: - str = tr("Proxy connection refused"); - break; - case QMQTT::SocketProxyConnectionClosedError: - str = tr("Proxy connection closed"); - break; - case QMQTT::SocketProxyConnectionTimeoutError: - str = tr("Proxy connection timeout"); - break; - case QMQTT::SocketProxyNotFoundError: - str = tr("Proxy not found"); - break; - case QMQTT::SocketProxyProtocolError: - str = tr("Proxy protocol error"); - break; - case QMQTT::SocketOperationError: - str = tr("Operation error"); - break; - case QMQTT::SocketSslInternalError: - str = tr("SSL internal error"); - break; - case QMQTT::SocketSslInvalidUserDataError: - str = tr("Invalid SSL user data"); - break; - case QMQTT::SocketTemporaryError: - str = tr("Socket temprary error"); - break; - case QMQTT::MqttUnacceptableProtocolVersionError: - str = tr("Unacceptable MQTT protocol"); - break; - case QMQTT::MqttIdentifierRejectedError: - str = tr("MQTT identifier rejected"); - break; - case QMQTT::MqttServerUnavailableError: - str = tr("MQTT server unavailable"); - break; - case QMQTT::MqttBadUserNameOrPasswordError: - str = tr("Bad MQTT username or password"); - break; - case QMQTT::MqttNotAuthorizedError: - str = tr("MQTT authorization error"); - break; - case QMQTT::MqttNoPingResponse: - str = tr("MQTT no ping response"); - break; - default: - str = ""; - break; - } + switch (error) + { + case QMQTT::UnknownError: + str = tr("Unknown error"); + break; + case QMQTT::SocketConnectionRefusedError: + str = tr("Connection refused"); + break; + case QMQTT::SocketRemoteHostClosedError: + str = tr("Remote host closed the connection"); + break; + case QMQTT::SocketHostNotFoundError: + str = tr("Host not found"); + break; + case QMQTT::SocketAccessError: + str = tr("Socket access error"); + break; + case QMQTT::SocketResourceError: + str = tr("Socket resource error"); + break; + case QMQTT::SocketTimeoutError: + str = tr("Socket timeout"); + break; + case QMQTT::SocketDatagramTooLargeError: + str = tr("Socket datagram too large"); + break; + case QMQTT::SocketNetworkError: + str = tr("Network error"); + break; + case QMQTT::SocketAddressInUseError: + str = tr("Address in use"); + break; + case QMQTT::SocketAddressNotAvailableError: + str = tr("Address not available"); + break; + case QMQTT::SocketUnsupportedSocketOperationError: + str = tr("Unsupported socket operation"); + break; + case QMQTT::SocketUnfinishedSocketOperationError: + str = tr("Unfinished socket operation"); + break; + case QMQTT::SocketProxyAuthenticationRequiredError: + str = tr("Proxy authentication required"); + break; + case QMQTT::SocketSslHandshakeFailedError: + str = tr("SSL handshake failed"); + break; + case QMQTT::SocketProxyConnectionRefusedError: + str = tr("Proxy connection refused"); + break; + case QMQTT::SocketProxyConnectionClosedError: + str = tr("Proxy connection closed"); + break; + case QMQTT::SocketProxyConnectionTimeoutError: + str = tr("Proxy connection timeout"); + break; + case QMQTT::SocketProxyNotFoundError: + str = tr("Proxy not found"); + break; + case QMQTT::SocketProxyProtocolError: + str = tr("Proxy protocol error"); + break; + case QMQTT::SocketOperationError: + str = tr("Operation error"); + break; + case QMQTT::SocketSslInternalError: + str = tr("SSL internal error"); + break; + case QMQTT::SocketSslInvalidUserDataError: + str = tr("Invalid SSL user data"); + break; + case QMQTT::SocketTemporaryError: + str = tr("Socket temprary error"); + break; + case QMQTT::MqttUnacceptableProtocolVersionError: + str = tr("Unacceptable MQTT protocol"); + break; + case QMQTT::MqttIdentifierRejectedError: + str = tr("MQTT identifier rejected"); + break; + case QMQTT::MqttServerUnavailableError: + str = tr("MQTT server unavailable"); + break; + case QMQTT::MqttBadUserNameOrPasswordError: + str = tr("Bad MQTT username or password"); + break; + case QMQTT::MqttNotAuthorizedError: + str = tr("MQTT authorization error"); + break; + case QMQTT::MqttNoPingResponse: + str = tr("MQTT no ping response"); + break; + default: + str = ""; + break; + } - if (!str.isEmpty()) - Misc::Utilities::showMessageBox(tr("MQTT client error"), str); + if (!str.isEmpty()) + Misc::Utilities::showMessageBox(tr("MQTT client error"), str); } /** - * Registers the given @a frame data to the list of frames that shall be published - * to the MQTT broker/server + * Registers the given @a frame data to the list of frames that shall be + * published to the MQTT broker/server */ void MQTT::Client::onFrameReceived(const QByteArray &frame) { - // Ignore if device is not connected - if (!IO::Manager::instance().connected()) - return; + // Ignore if device is not connected + if (!IO::Manager::instance().connected()) + return; - // Ignore if mode is not set to publisher - else if (clientMode() != ClientPublisher) - return; + // Ignore if mode is not set to publisher + else if (clientMode() != ClientPublisher) + return; - // Validate frame & append it to frame list - if (!frame.isEmpty()) - m_frames.append(frame); + // Validate frame & append it to frame list + if (!frame.isEmpty()) + m_frames.append(frame); } /** - * Displays the SSL errors that occur and allows the user to decide if he/she wants to - * ignore those errors. + * Displays the SSL errors that occur and allows the user to decide if he/she + * wants to ignore those errors. */ void MQTT::Client::onSslErrors(const QList &errors) { - Q_ASSERT(m_client); + Q_ASSERT(m_client); - Q_FOREACH (auto error, errors) + Q_FOREACH (auto error, errors) + { + auto ret = Misc::Utilities::showMessageBox( + tr("MQTT client SSL/TLS error, ignore?"), error.errorString(), + qApp->applicationName(), QMessageBox::Ignore | QMessageBox::Abort); + + if (ret == QMessageBox::Abort) { - auto ret = Misc::Utilities::showMessageBox( - tr("MQTT client SSL/TLS error, ignore?"), error.errorString(), - qApp->applicationName(), QMessageBox::Ignore | QMessageBox::Abort); - - if (ret == QMessageBox::Abort) - { - disconnectFromHost(); - abort(); - } + disconnectFromHost(); + abort(); } + } - m_client->ignoreSslErrors(); + m_client->ignoreSslErrors(); } /** - * Reads the given MQTT @a message and instructs the @c IO::Manager module to process - * received data directly. + * Reads the given MQTT @a message and instructs the @c IO::Manager module to + * process received data directly. */ void MQTT::Client::onMessageReceived(const QMQTT::Message &message) { - // Ignore if client mode is not set to suscriber - if (clientMode() != ClientSubscriber) - return; + // Ignore if client mode is not set to suscriber + if (clientMode() != ClientSubscriber) + return; - // Get message data - auto mtopic = message.topic(); - auto mpayld = message.payload(); + // Get message data + auto mtopic = message.topic(); + auto mpayld = message.payload(); - // Ignore if topic is not equal to current topic - if (topic() != mtopic) - return; + // Ignore if topic is not equal to current topic + if (topic() != mtopic) + return; - // Add EOL character - if (!mpayld.endsWith('\n')) - mpayld.append('\n'); + // Add EOL character + if (!mpayld.endsWith('\n')) + mpayld.append('\n'); - // Let IO manager process incoming data - IO::Manager::instance().processPayload(mpayld); + // Let IO manager process incoming data + IO::Manager::instance().processPayload(mpayld); } /** - * Creates a new MQTT client instance, this approach is required in order to allow - * the MQTT module to support both non-encrypted and TLS connections. + * Creates a new MQTT client instance, this approach is required in order to + * allow the MQTT module to support both non-encrypted and TLS connections. */ void MQTT::Client::regenerateClient() { - // Init. default MQTT configuration - quint8 qos = 0; - QString user = ""; - bool retain = false; - QString password = ""; - quint16 keepAlive = 60; - quint16 port = defaultPort(); - QString host = defaultHost(); - QMQTT::MQTTVersion version = QMQTT::V3_1_1; + // Init. default MQTT configuration + quint8 qos = 0; + QString user = ""; + bool retain = false; + QString password = ""; + quint16 keepAlive = 60; + quint16 port = defaultPort(); + QString host = defaultHost(); + QMQTT::MQTTVersion version = QMQTT::V3_1_1; - // There is an existing client, copy its configuration and delete it from memory - if (m_client) - { - port = m_client->port(); - qos = m_client->willQos(); - user = m_client->username(); - version = m_client->version(); - retain = m_client->willRetain(); - keepAlive = m_client->keepAlive(); - host = m_client->host().toString(); - password = QString::fromUtf8(m_client->password()); + // There is an existing client, copy its configuration and delete it from + // memory + if (m_client) + { + port = m_client->port(); + qos = m_client->willQos(); + user = m_client->username(); + version = m_client->version(); + retain = m_client->willRetain(); + keepAlive = m_client->keepAlive(); + host = m_client->host().toString(); + password = QString::fromUtf8(m_client->password()); - disconnect(m_client, &QMQTT::Client::error, Q_NULLPTR, 0); - disconnect(m_client, &QMQTT::Client::received, Q_NULLPTR, 0); - disconnect(m_client, &QMQTT::Client::connected, Q_NULLPTR, 0); - disconnect(m_client, &QMQTT::Client::sslErrors, Q_NULLPTR, 0); - disconnect(m_client, &QMQTT::Client::disconnected, Q_NULLPTR, 0); + disconnect(m_client, &QMQTT::Client::error, Q_NULLPTR, 0); + disconnect(m_client, &QMQTT::Client::received, Q_NULLPTR, 0); + disconnect(m_client, &QMQTT::Client::connected, Q_NULLPTR, 0); + disconnect(m_client, &QMQTT::Client::sslErrors, Q_NULLPTR, 0); + disconnect(m_client, &QMQTT::Client::disconnected, Q_NULLPTR, 0); - m_client->disconnectFromHost(); - delete m_client; - } + m_client->disconnectFromHost(); + delete m_client; + } - // Configure MQTT client depending on SSL/TLS configuration - if (sslEnabled()) - m_client = new QMQTT::Client(host, port, m_sslConfiguration); - else - m_client = new QMQTT::Client(QHostAddress(host), port); + // Configure MQTT client depending on SSL/TLS configuration + if (sslEnabled()) + m_client = new QMQTT::Client(host, port, m_sslConfiguration); + else + m_client = new QMQTT::Client(QHostAddress(host), port); - // Set client ID - m_client->setClientId(qApp->applicationName()); + // Set client ID + m_client->setClientId(qApp->applicationName()); - // Set MQTT client options - m_client->setWillQos(qos); - m_client->setUsername(user); - m_client->setVersion(version); - m_client->setWillRetain(retain); - m_client->setWillRetain(retain); - m_client->setKeepAlive(keepAlive); - m_client->setPassword(password.toUtf8()); + // Set MQTT client options + m_client->setWillQos(qos); + m_client->setUsername(user); + m_client->setVersion(version); + m_client->setWillRetain(retain); + m_client->setWillRetain(retain); + m_client->setKeepAlive(keepAlive); + m_client->setPassword(password.toUtf8()); - // Connect signals/slots - // clang-format off + // Connect signals/slots + // clang-format off connect(m_client, &QMQTT::Client::error, this, &MQTT::Client::onError); connect(m_client, &QMQTT::Client::sslErrors, @@ -865,9 +875,5 @@ void MQTT::Client::regenerateClient() this, &MQTT::Client::connectedChanged); connect(m_client, &QMQTT::Client::disconnected, this, &MQTT::Client::onConnectedChanged); - // clang-format on + // clang-format on } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Client.cpp" -#endif diff --git a/src/MQTT/Client.h b/src/MQTT/Client.h index 3b37e3c3..bd650a33 100644 --- a/src/MQTT/Client.h +++ b/src/MQTT/Client.h @@ -40,26 +40,28 @@ namespace MQTT */ enum MQTTClientMode { - ClientPublisher = 0, - ClientSubscriber = 1 + ClientPublisher = 0, + ClientSubscriber = 1 }; /** * @brief The Client class * - * Implements a simple MQTT client, which allows Serial Studio to upload received frames - * to a MQTT broker so that other devices and/or services can make use of that - * information. By acting as a MQTT subscriber, Serial Studio can display & process frames - * from a remote Serial Studio instance that is setup as a MQTT publisher. As you might - * notice, this has a lot of interesting applications. + * Implements a simple MQTT client, which allows Serial Studio to upload + * received frames to a MQTT broker so that other devices and/or services can + * make use of that information. By acting as a MQTT subscriber, Serial Studio + * can display & process frames from a remote Serial Studio instance that is + * setup as a MQTT publisher. As you might notice, this has a lot of interesting + * applications. * - * For example, you can receive frames from a CanSat mission and display them almost in - * real-time in another location, such as the "ground control" centre or by the media team - * which streams the GCS display on the internet as the mission is developing. + * For example, you can receive frames from a CanSat mission and display them + * almost in real-time in another location, such as the "ground control" centre + * or by the media team which streams the GCS display on the internet as the + * mission is developing. */ class Client : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(quint16 port READ port @@ -136,105 +138,105 @@ class Client : public QObject Q_PROPERTY(QString caFilePath READ caFilePath NOTIFY caFilePathChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void qosChanged(); - void portChanged(); - void hostChanged(); - void topicChanged(); - void retainChanged(); - void usernameChanged(); - void passwordChanged(); - void keepAliveChanged(); - void connectedChanged(); - void caFilePathChanged(); - void clientModeChanged(); - void sslEnabledChanged(); - void sslProtocolChanged(); - void mqttVersionChanged(); - void lookupActiveChanged(); + void qosChanged(); + void portChanged(); + void hostChanged(); + void topicChanged(); + void retainChanged(); + void usernameChanged(); + void passwordChanged(); + void keepAliveChanged(); + void connectedChanged(); + void caFilePathChanged(); + void clientModeChanged(); + void sslEnabledChanged(); + void sslProtocolChanged(); + void mqttVersionChanged(); + void lookupActiveChanged(); private: - explicit Client(); - Client(Client &&) = delete; - Client(const Client &) = delete; - Client &operator=(Client &&) = delete; - Client &operator=(const Client &) = delete; + explicit Client(); + Client(Client &&) = delete; + Client(const Client &) = delete; + Client &operator=(Client &&) = delete; + Client &operator=(const Client &) = delete; - ~Client(); + ~Client(); public: - static Client &instance(); + static Client &instance(); - quint8 qos() const; - bool retain() const; - quint16 port() const; - QString host() const; - QString topic() const; - int clientMode() const; - int sslProtocol() const; - int mqttVersion() const; - bool sslEnabled() const; - QString username() const; - QString password() const; - quint16 keepAlive() const; - bool lookupActive() const; - bool isSubscribed() const; - bool isConnectedToHost() const; + quint8 qos() const; + bool retain() const; + quint16 port() const; + QString host() const; + QString topic() const; + int clientMode() const; + int sslProtocol() const; + int mqttVersion() const; + bool sslEnabled() const; + QString username() const; + QString password() const; + quint16 keepAlive() const; + bool lookupActive() const; + bool isSubscribed() const; + bool isConnectedToHost() const; - StringList qosLevels() const; - StringList clientModes() const; - StringList mqttVersions() const; - StringList sslProtocols() const; + StringList qosLevels() const; + StringList clientModes() const; + StringList mqttVersions() const; + StringList sslProtocols() const; - QString caFilePath() const; - quint16 defaultPort() const { return 1883; } - QString defaultHost() const { return "127.0.0.1"; } + QString caFilePath() const; + quint16 defaultPort() const { return 1883; } + QString defaultHost() const { return "127.0.0.1"; } public Q_SLOTS: - void loadCaFile(); - void connectToHost(); - void toggleConnection(); - void disconnectFromHost(); - void setQos(const quint8 qos); - void lookup(const QString &host); - void setPort(const quint16 port); - void setHost(const QString &host); - void setRetain(const bool retain); - void setClientMode(const int mode); - void setTopic(const QString &topic); - void loadCaFile(const QString &path); - void setSslProtocol(const int index); - void setSslEnabled(const bool enabled); - void setUsername(const QString &username); - void setPassword(const QString &password); - void setKeepAlive(const quint16 keepAlive); - void setMqttVersion(const int versionIndex); + void loadCaFile(); + void connectToHost(); + void toggleConnection(); + void disconnectFromHost(); + void setQos(const quint8 qos); + void lookup(const QString &host); + void setPort(const quint16 port); + void setHost(const QString &host); + void setRetain(const bool retain); + void setClientMode(const int mode); + void setTopic(const QString &topic); + void loadCaFile(const QString &path); + void setSslProtocol(const int index); + void setSslEnabled(const bool enabled); + void setUsername(const QString &username); + void setPassword(const QString &password); + void setKeepAlive(const quint16 keepAlive); + void setMqttVersion(const int versionIndex); private Q_SLOTS: - void sendData(); - void resetStatistics(); - void onConnectedChanged(); - void lookupFinished(const QHostInfo &info); - void onError(const QMQTT::ClientError error); - void onFrameReceived(const QByteArray &frame); - void onSslErrors(const QList &errors); - void onMessageReceived(const QMQTT::Message &message); + void sendData(); + void resetStatistics(); + void onConnectedChanged(); + void lookupFinished(const QHostInfo &info); + void onError(const QMQTT::ClientError error); + void onFrameReceived(const QByteArray &frame); + void onSslErrors(const QList &errors); + void onMessageReceived(const QMQTT::Message &message); private: - void regenerateClient(); + void regenerateClient(); private: - QString m_topic; - bool m_sslEnabled; - int m_sslProtocol; - bool m_lookupActive; - QString m_caFilePath; - quint16 m_sentMessages; - MQTTClientMode m_clientMode; - QVector m_frames; - QPointer m_client; - QSslConfiguration m_sslConfiguration; + QString m_topic; + bool m_sslEnabled; + int m_sslProtocol; + bool m_lookupActive; + QString m_caFilePath; + quint16 m_sentMessages; + MQTTClientMode m_clientMode; + QVector m_frames; + QPointer m_client; + QSslConfiguration m_sslConfiguration; }; -} +} // namespace MQTT diff --git a/src/Misc/MacExtras.cpp b/src/Misc/MacExtras.cpp deleted file mode 100644 index 946c69f5..00000000 --- a/src/Misc/MacExtras.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2020-2023 Alex Spataru - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include - -#ifdef Q_OS_MAC -# include -#endif - -Misc::MacExtras::MacExtras() -{ -#ifdef Q_OS_MAC - // Configure action strings - updateButtonText(); - - // Configure action icons - m_setupAction.setIcon(QIcon("://touchbar/setup.png")); - m_consoleAction.setIcon(QIcon("://touchbar/console.png")); - m_dashboardAction.setIcon(QIcon("://touchbar/dashboard.png")); - - // Setup checkable items - m_setupAction.setCheckable(true); - m_consoleAction.setCheckable(true); - m_dashboardAction.setCheckable(true); - - // Set initial button status(es) - m_setupAction.setChecked(true); - m_consoleAction.setChecked(true); - m_dashboardAction.setEnabled(false); - - // Configure signals - connect(&m_setupAction, SIGNAL(triggered()), this, SIGNAL(setupClicked())); - connect(&m_consoleAction, SIGNAL(triggered()), this, SIGNAL(consoleClicked())); - connect(&m_dashboardAction, SIGNAL(triggered()), this, SIGNAL(dashboardClicked())); - - // Create touchbar - KDMacTouchBar *bar = new KDMacTouchBar((QWidget *)Q_NULLPTR); - bar->addAction(&m_setupAction); - bar->addAction(&m_consoleAction); - bar->addAction(&m_dashboardAction); - - // Re-translate buttons when language is changed - connect(&Translator::instance(), SIGNAL(languageChanged()), this, - SLOT(updateButtonText())); -#endif -} - -Misc::MacExtras &Misc::MacExtras::instance() -{ - static MacExtras singleton; - return singleton; -} - -void Misc::MacExtras::setSetupChecked(const bool checked) -{ - m_setupAction.setChecked(checked); -} - -void Misc::MacExtras::setConsoleChecked(const bool checked) -{ - m_consoleAction.setChecked(checked); -} - -void Misc::MacExtras::setDashboardChecked(const bool checked) -{ - m_dashboardAction.setChecked(checked); -} - -void Misc::MacExtras::setDashboardEnabled(const bool enabled) -{ - m_dashboardAction.setEnabled(enabled); -} - -void Misc::MacExtras::updateButtonText() -{ - m_setupAction.setText(tr("Setup")); - m_consoleAction.setText(tr("Console")); - m_dashboardAction.setText(tr("Dashboard")); -} - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_MacExtras.cpp" -#endif diff --git a/src/Misc/MacExtras.h b/src/Misc/MacExtras.h deleted file mode 100644 index a0e019e4..00000000 --- a/src/Misc/MacExtras.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2020-2023 Alex Spataru - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#pragma once - -#include -#include - -namespace Misc -{ -/** - * @brief The MacExtras class - * - * The @c MacExtras class implements specialized functions that are used only in macOS - * targets. For the moment, this class implements the code necessary to interact with the - * touchbar display for some MacBook models. - */ -class MacExtras : public QObject -{ - Q_OBJECT - -Q_SIGNALS: - void setupClicked(); - void connectClicked(); - void consoleClicked(); - void dashboardClicked(); - -private: - explicit MacExtras(); - MacExtras(MacExtras &&) = delete; - MacExtras(const MacExtras &) = delete; - MacExtras &operator=(MacExtras &&) = delete; - MacExtras &operator=(const MacExtras &) = delete; - -public: - static MacExtras &instance(); - -public Q_SLOTS: - void setSetupChecked(const bool checked); - void setConsoleChecked(const bool checked); - void setDashboardChecked(const bool checked); - void setDashboardEnabled(const bool enabled); - -private Q_SLOTS: - void updateButtonText(); - -private: - QAction m_setupAction; - QAction m_consoleAction; - QAction m_dashboardAction; -}; -} diff --git a/src/Misc/ModuleManager.cpp b/src/Misc/ModuleManager.cpp index 831a6c82..d6ed1c83 100644 --- a/src/Misc/ModuleManager.cpp +++ b/src/Misc/ModuleManager.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -57,37 +56,33 @@ #include /** - * Configures the application font and configures application signals/slots to destroy - * singleton classes before the application quits. + * Configures the application font and configures application signals/slots to + * destroy singleton classes before the application quits. */ Misc::ModuleManager::ModuleManager() { - // Init translator - (void)Misc::Translator::instance(); + // Init translator + (void)Misc::Translator::instance(); - // Load Roboto fonts from resources - QFontDatabase::addApplicationFont(":/fonts/Roboto-Bold.ttf"); - QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf"); - QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Bold.ttf"); - QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Regular.ttf"); + // Load Roboto fonts from resources + QFontDatabase::addApplicationFont(":/fonts/Roboto-Bold.ttf"); + QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf"); + QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Bold.ttf"); + QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Regular.ttf"); - // Set Roboto as default app font - QFont font("Roboto"); + // Set Roboto as default app font + QFont font("Roboto"); #if defined(Q_OS_WIN) - font.setPointSize(9); + font.setPointSize(9); #elif defined(Q_OS_MAC) - font.setPointSize(13); + font.setPointSize(13); #elif defined(Q_OS_LINUX) - font.setPointSize(10); + font.setPointSize(10); #endif - qApp->setFont(font); + qApp->setFont(font); - // Enable software rendering - if (softwareRendering()) - QQuickWindow::setGraphicsApi(QSGRendererInterface::Software); - - // Stop modules when application is about to quit - connect(engine(), SIGNAL(quit()), this, SLOT(onQuit())); + // Stop modules when application is about to quit + connect(engine(), SIGNAL(quit()), this, SLOT(onQuit())); } /** @@ -95,7 +90,7 @@ Misc::ModuleManager::ModuleManager() */ QQmlApplicationEngine *Misc::ModuleManager::engine() { - return &m_engine; + return &m_engine; } /** @@ -106,12 +101,12 @@ QQmlApplicationEngine *Misc::ModuleManager::engine() */ void Misc::ModuleManager::configureUpdater() { - if (!autoUpdaterEnabled()) - return; + if (!autoUpdaterEnabled()) + return; - QSimpleUpdater::getInstance()->setNotifyOnUpdate(APP_UPDATER_URL, true); - QSimpleUpdater::getInstance()->setNotifyOnFinish(APP_UPDATER_URL, false); - QSimpleUpdater::getInstance()->setMandatoryUpdate(APP_UPDATER_URL, false); + QSimpleUpdater::getInstance()->setNotifyOnUpdate(APP_UPDATER_URL, true); + QSimpleUpdater::getInstance()->setNotifyOnFinish(APP_UPDATER_URL, false); + QSimpleUpdater::getInstance()->setMandatoryUpdate(APP_UPDATER_URL, false); } /** @@ -122,136 +117,126 @@ void Misc::ModuleManager::configureUpdater() */ void Misc::ModuleManager::registerQmlTypes() { - qmlRegisterType("SerialStudio", 1, 0, "Terminal"); - qmlRegisterType("SerialStudio", 1, 0, "DashboardWidget"); -} - -/** - * Returns @c true if software rendering is enabled. - * By default, software rendering is enabled so that Serial Studio - * works with most computers and virtual machines. - */ -bool Misc::ModuleManager::softwareRendering() -{ - QSettings settings(APP_DEVELOPER, APP_NAME); - return settings.value("SoftwareRendering", true).toBool(); + qmlRegisterType("SerialStudio", 1, 0, "Terminal"); + qmlRegisterType("SerialStudio", 1, 0, "DashboardWidget"); } /** * Enables or disables the auto-updater system (QSimpleUpdater). * - * To disable QSimpleUpdater, you need to add DEFINES += DISABLE_QSU in the qmake project - * file. This option is provided for package managers, users are expected to update the - * application using the same package manager they used for installing it. + * To disable QSimpleUpdater, you need to add DEFINES += DISABLE_QSU in the + * qmake project file. This option is provided for package managers, users are + * expected to update the application using the same package manager they used + * for installing it. */ bool Misc::ModuleManager::autoUpdaterEnabled() { #ifdef DISABLE_QSU - return false; + return false; #else - return true; + return true; #endif } /** - * Initializes all the application modules, registers them with the QML engine and loads - * the "main.qml" file as the root QML file. + * Initializes all the application modules, registers them with the QML engine + * and loads the "main.qml" file as the root QML file. */ void Misc::ModuleManager::initializeQmlInterface() { - // Initialize modules - auto csvExport = &CSV::Export::instance(); - auto csvPlayer = &CSV::Player::instance(); - auto ioManager = &IO::Manager::instance(); - auto ioConsole = &IO::Console::instance(); - auto mqttClient = &MQTT::Client::instance(); - auto uiDashboard = &UI::Dashboard::instance(); - auto projectModel = &Project::Model::instance(); - auto ioSerial = &IO::Drivers::Serial::instance(); - auto jsonGenerator = &JSON::Generator::instance(); - auto pluginsBridge = &Plugins::Server::instance(); - auto miscUtilities = &Misc::Utilities::instance(); - auto miscMacExtras = &Misc::MacExtras::instance(); - auto ioNetwork = &IO::Drivers::Network::instance(); - auto miscTranslator = &Misc::Translator::instance(); - auto miscTimerEvents = &Misc::TimerEvents::instance(); - auto miscThemeManager = &Misc::ThemeManager::instance(); - auto projectCodeEditor = &Project::CodeEditor::instance(); - auto ioBluetoothLE = &IO::Drivers::BluetoothLE::instance(); + // Initialize modules + auto csvExport = &CSV::Export::instance(); + auto csvPlayer = &CSV::Player::instance(); + auto ioManager = &IO::Manager::instance(); + auto ioConsole = &IO::Console::instance(); + auto mqttClient = &MQTT::Client::instance(); + auto uiDashboard = &UI::Dashboard::instance(); + auto projectModel = &Project::Model::instance(); + auto ioSerial = &IO::Drivers::Serial::instance(); + auto jsonGenerator = &JSON::Generator::instance(); + auto pluginsBridge = &Plugins::Server::instance(); + auto miscUtilities = &Misc::Utilities::instance(); + auto ioNetwork = &IO::Drivers::Network::instance(); + auto miscTranslator = &Misc::Translator::instance(); + auto miscTimerEvents = &Misc::TimerEvents::instance(); + auto miscThemeManager = &Misc::ThemeManager::instance(); + auto projectCodeEditor = &Project::CodeEditor::instance(); + auto ioBluetoothLE = &IO::Drivers::BluetoothLE::instance(); - // Initialize third-party modules - auto updater = QSimpleUpdater::getInstance(); + // Initialize third-party modules + auto updater = QSimpleUpdater::getInstance(); - // Operating system flags - bool isWin = false; - bool isMac = false; - bool isNix = false; - QString osName = tr("Unknown OS"); + // Operating system flags + bool isWin = false; + bool isMac = false; + bool isNix = false; + QString osName = tr("Unknown OS"); #if defined(Q_OS_MAC) - isMac = true; - osName = "macOS"; + isMac = true; + osName = "macOS"; #elif defined(Q_OS_WIN) - isWin = true; - osName = "Windows"; + isWin = true; + osName = "Windows"; #elif defined(Q_OS_LINUX) - isNix = true; - osName = "GNU/Linux"; + isNix = true; + osName = "GNU/Linux"; #else - isNix = true; - osName = "UNIX"; + isNix = true; + osName = "UNIX"; #endif - // Qt version QML flag + // Qt version QML flag #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - const bool qt6 = false; + const bool qt6 = false; #else - const bool qt6 = true; + const bool qt6 = true; #endif - // Start common event timers - miscTimerEvents->startTimers(); + // Start common event timers + miscTimerEvents->startTimers(); - // Retranslate the QML interface automagically - connect(miscTranslator, SIGNAL(languageChanged()), engine(), SLOT(retranslate())); + // Retranslate the QML interface automagically + connect(miscTranslator, SIGNAL(languageChanged()), engine(), + SLOT(retranslate())); - // Register C++ modules with QML - auto c = engine()->rootContext(); - c->setContextProperty("Cpp_Qt6", qt6); - c->setContextProperty("Cpp_IsWin", isWin); - c->setContextProperty("Cpp_IsMac", isMac); - c->setContextProperty("Cpp_IsNix", isNix); - c->setContextProperty("Cpp_OSName", osName); - c->setContextProperty("Cpp_Updater", updater); - c->setContextProperty("Cpp_IO_Serial", ioSerial); - c->setContextProperty("Cpp_CSV_Export", csvExport); - c->setContextProperty("Cpp_CSV_Player", csvPlayer); - c->setContextProperty("Cpp_IO_Console", ioConsole); - c->setContextProperty("Cpp_IO_Manager", ioManager); - c->setContextProperty("Cpp_IO_Network", ioNetwork); - c->setContextProperty("Cpp_MQTT_Client", mqttClient); - c->setContextProperty("Cpp_UI_Dashboard", uiDashboard); - c->setContextProperty("Cpp_Project_Model", projectModel); - c->setContextProperty("Cpp_JSON_Generator", jsonGenerator); - c->setContextProperty("Cpp_Plugins_Bridge", pluginsBridge); - c->setContextProperty("Cpp_Misc_MacExtras", miscMacExtras); - c->setContextProperty("Cpp_Misc_Utilities", miscUtilities); - c->setContextProperty("Cpp_IO_Bluetooth_LE", ioBluetoothLE); - c->setContextProperty("Cpp_ThemeManager", miscThemeManager); - c->setContextProperty("Cpp_Misc_Translator", miscTranslator); - c->setContextProperty("Cpp_Misc_TimerEvents", miscTimerEvents); - c->setContextProperty("Cpp_Project_CodeEditor", projectCodeEditor); - c->setContextProperty("Cpp_UpdaterEnabled", autoUpdaterEnabled()); - c->setContextProperty("Cpp_ModuleManager", this); + // Register C++ modules with QML + auto c = engine()->rootContext(); + c->setContextProperty("Cpp_Qt6", qt6); + c->setContextProperty("Cpp_IsWin", isWin); + c->setContextProperty("Cpp_IsMac", isMac); + c->setContextProperty("Cpp_IsNix", isNix); + c->setContextProperty("Cpp_OSName", osName); + c->setContextProperty("Cpp_Updater", updater); + c->setContextProperty("Cpp_IO_Serial", ioSerial); + c->setContextProperty("Cpp_CSV_Export", csvExport); + c->setContextProperty("Cpp_CSV_Player", csvPlayer); + c->setContextProperty("Cpp_IO_Console", ioConsole); + c->setContextProperty("Cpp_IO_Manager", ioManager); + c->setContextProperty("Cpp_IO_Network", ioNetwork); + c->setContextProperty("Cpp_MQTT_Client", mqttClient); + c->setContextProperty("Cpp_UI_Dashboard", uiDashboard); + c->setContextProperty("Cpp_Project_Model", projectModel); + c->setContextProperty("Cpp_JSON_Generator", jsonGenerator); + c->setContextProperty("Cpp_Plugins_Bridge", pluginsBridge); + c->setContextProperty("Cpp_Misc_Utilities", miscUtilities); + c->setContextProperty("Cpp_IO_Bluetooth_LE", ioBluetoothLE); + c->setContextProperty("Cpp_ThemeManager", miscThemeManager); + c->setContextProperty("Cpp_Misc_Translator", miscTranslator); + c->setContextProperty("Cpp_Misc_TimerEvents", miscTimerEvents); + c->setContextProperty("Cpp_Project_CodeEditor", projectCodeEditor); + c->setContextProperty("Cpp_UpdaterEnabled", autoUpdaterEnabled()); + c->setContextProperty("Cpp_ModuleManager", this); - // Register app info with QML - c->setContextProperty("Cpp_AppName", qApp->applicationName()); - c->setContextProperty("Cpp_AppUpdaterUrl", APP_UPDATER_URL); - c->setContextProperty("Cpp_AppVersion", qApp->applicationVersion()); - c->setContextProperty("Cpp_AppOrganization", qApp->organizationName()); - c->setContextProperty("Cpp_AppOrganizationDomain", qApp->organizationDomain()); + // Register app info with QML + c->setContextProperty("Cpp_AppName", qApp->applicationName()); + c->setContextProperty("Cpp_AppUpdaterUrl", APP_UPDATER_URL); + c->setContextProperty("Cpp_AppVersion", qApp->applicationVersion()); + c->setContextProperty("Cpp_AppOrganization", qApp->organizationName()); + c->setContextProperty("Cpp_AppOrganizationDomain", + qApp->organizationDomain()); - // Load main.qml - engine()->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + // Load main.qml + engine()->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); } /** @@ -259,36 +244,9 @@ void Misc::ModuleManager::initializeQmlInterface() */ void Misc::ModuleManager::onQuit() { - CSV::Export::instance().closeFile(); - CSV::Player::instance().closeFile(); - IO::Manager::instance().disconnectDriver(); - Misc::TimerEvents::instance().stopTimers(); - Plugins::Server::instance().removeConnection(); + CSV::Export::instance().closeFile(); + CSV::Player::instance().closeFile(); + IO::Manager::instance().disconnectDriver(); + Misc::TimerEvents::instance().stopTimers(); + Plugins::Server::instance().removeConnection(); } - -/** - * Enables or disables software rendering, which might be useful when - * dealing with virtual machine environments. - */ -void Misc::ModuleManager::setSoftwareRenderingEnabled(const bool enabled) -{ - // Change settings - QSettings settings(APP_DEVELOPER, APP_NAME); - settings.setValue("SoftwareRendering", enabled); - - // Ask user to quit application - // clang-format off - auto ans = Utilities::showMessageBox( - tr("The change will take effect after restart"), - tr("Do you want to restart %1 now?").arg(APP_NAME), APP_NAME, - QMessageBox::Yes | QMessageBox::No); - // clang-format on - - // Restart application - if (ans == QMessageBox::Yes) - Utilities::rebootApplication(); -} - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_ModuleManager.cpp" -#endif diff --git a/src/Misc/ModuleManager.h b/src/Misc/ModuleManager.h index 761b6fcc..be876cc4 100644 --- a/src/Misc/ModuleManager.h +++ b/src/Misc/ModuleManager.h @@ -32,29 +32,26 @@ namespace Misc /** * @brief The ModuleManager class * - * The @c ModuleManager class is in charge of initializing all the C++ modules that are - * part of Serial Studio in the correct order. + * The @c ModuleManager class is in charge of initializing all the C++ modules + * that are part of Serial Studio in the correct order. */ class ModuleManager : public QObject { - Q_OBJECT - Q_PROPERTY(bool softwareRendering READ softwareRendering CONSTANT) - Q_PROPERTY(bool autoUpdaterEnabled READ autoUpdaterEnabled CONSTANT) + Q_OBJECT + Q_PROPERTY(bool autoUpdaterEnabled READ autoUpdaterEnabled CONSTANT) public: - ModuleManager(); - void configureUpdater(); - void registerQmlTypes(); - bool softwareRendering(); - bool autoUpdaterEnabled(); - void initializeQmlInterface(); - QQmlApplicationEngine *engine(); + ModuleManager(); + void configureUpdater(); + void registerQmlTypes(); + bool autoUpdaterEnabled(); + void initializeQmlInterface(); + QQmlApplicationEngine *engine(); public Q_SLOTS: - void onQuit(); - void setSoftwareRenderingEnabled(const bool enabled); + void onQuit(); private: - QQmlApplicationEngine m_engine; + QQmlApplicationEngine m_engine; }; -} +} // namespace Misc diff --git a/src/Misc/ThemeManager.cpp b/src/Misc/ThemeManager.cpp index 5a3f11b8..5afb7111 100644 --- a/src/Misc/ThemeManager.cpp +++ b/src/Misc/ThemeManager.cpp @@ -39,13 +39,13 @@ */ Misc::ThemeManager::ThemeManager() { - populateThemes(); - loadTheme(m_settings.value("themeId", 0).toInt()); + populateThemes(); + loadTheme(m_settings.value("themeId", 0).toInt()); #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - setCustomWindowDecorations(m_settings.value("customWindows", false).toBool()); + setCustomWindowDecorations(m_settings.value("customWindows", false).toBool()); #else - setCustomWindowDecorations(m_settings.value("customWindows", true).toBool()); + setCustomWindowDecorations(m_settings.value("customWindows", true).toBool()); #endif } @@ -54,8 +54,8 @@ Misc::ThemeManager::ThemeManager() */ Misc::ThemeManager &Misc::ThemeManager::instance() { - static ThemeManager singleton; - return singleton; + static ThemeManager singleton; + return singleton; } /** @@ -63,17 +63,17 @@ Misc::ThemeManager &Misc::ThemeManager::instance() */ int Misc::ThemeManager::themeId() const { - return m_themeId; + return m_themeId; } /** - * Returns @c true if the application should draw the window decorations & controls by - * itself. This feature makes it look cooler, but it can lead to some trouble on - * not-so-common desktop environments, such as CDE. + * Returns @c true if the application should draw the window decorations & + * controls by itself. This feature makes it look cooler, but it can lead to + * some trouble on not-so-common desktop environments, such as CDE. */ bool Misc::ThemeManager::customWindowDecorations() const { - return m_customWindowDecorations; + return m_customWindowDecorations; } /** @@ -88,36 +88,36 @@ bool Misc::ThemeManager::customWindowDecorations() const */ void Misc::ThemeManager::setTheme(const int id) { - // Validate theme ID - if (id >= m_availableThemesPaths.count()) - return; + // Validate theme ID + if (id >= m_availableThemesPaths.count()) + return; - // Save settings for next run - m_themeId = id; - m_settings.setValue("themeId", m_themeId); + // Save settings for next run + m_themeId = id; + m_settings.setValue("themeId", m_themeId); - // Ask user to quit application - // clang-format off + // Ask user to quit application + // clang-format off auto ans = Utilities::showMessageBox( tr("The theme change will take effect after restart"), tr("Do you want to restart %1 now?").arg(APP_NAME), APP_NAME, QMessageBox::Yes | QMessageBox::No); - // clang-format on + // clang-format on - // Restart application - if (ans == QMessageBox::Yes) - Utilities::rebootApplication(); + // Restart application + if (ans == QMessageBox::Yes) + Utilities::rebootApplication(); } /** - * Enables/disables the custom window feature. See the @c customWindowDecorations() - * function for more information. + * Enables/disables the custom window feature. See the @c + * customWindowDecorations() function for more information. */ void Misc::ThemeManager::setCustomWindowDecorations(const bool enabled) { - m_customWindowDecorations = enabled; - m_settings.setValue("customWindows", enabled); - Q_EMIT customWindowDecorationsChanged(); + m_customWindowDecorations = enabled; + m_settings.setValue("customWindows", enabled); + Q_EMIT customWindowDecorationsChanged(); } /** @@ -127,106 +127,106 @@ void Misc::ThemeManager::setCustomWindowDecorations(const bool enabled) */ void Misc::ThemeManager::loadTheme(const int id) { - // Validate theme ID - if (id >= m_availableThemesPaths.count()) - return; + // Validate theme ID + if (id >= m_availableThemesPaths.count()) + return; - // Open theme - QFile file(m_availableThemesPaths.at(id)); - if (!file.open(QFile::ReadOnly)) - return; + // Open theme + QFile file(m_availableThemesPaths.at(id)); + if (!file.open(QFile::ReadOnly)) + return; - // Read theme data into JSON - auto document = QJsonDocument::fromJson(file.readAll()); - if (document.isEmpty()) - return; + // Read theme data into JSON + auto document = QJsonDocument::fromJson(file.readAll()); + if (document.isEmpty()) + return; - // Get colors object - auto colors = document.object().value("colors").toObject(); - if (colors.isEmpty()) - return; + // Get colors object + auto colors = document.object().value("colors").toObject(); + if (colors.isEmpty()) + return; - // Read colors from JSON file - // clang-format off - m_titlebarSeparator = document.object().value("titlebarSeparator").toBool(); - m_base = QColor(colors.value("base").toString()); - m_link = QColor(colors.value("link").toString()); - m_button = QColor(colors.value("button").toString()); - m_window = QColor(colors.value("window").toString()); - m_text = QColor(colors.value("text").toString()); - m_border = QColor(colors.value("border").toString()); - m_midlight = QColor(colors.value("midlight").toString()); - m_highlight = QColor(colors.value("highlight").toString()); - m_brightText = QColor(colors.value("brightText").toString()); - m_buttonText = QColor(colors.value("buttonText").toString()); - m_windowText = QColor(colors.value("windowText").toString()); - m_tooltipText = QColor(colors.value("tooltipText").toString()); - m_tooltipBase = QColor(colors.value("tooltipBase").toString()); - m_highlightedText = QColor(colors.value("highlightedText").toString()); - m_highlightedTextAlternative = QColor(colors.value("highlightedTextAlternative").toString()); - m_placeholderText = QColor(colors.value("placeholderText").toString()); - m_toolbarGradient1 = QColor(colors.value("toolbarGradient1").toString()); - m_toolbarGradient2 = QColor(colors.value("toolbarGradient2").toString()); - m_consoleText = QColor(colors.value("consoleText").toString()); - m_consoleBase = QColor(colors.value("consoleBase").toString()); - m_consoleButton = QColor(colors.value("consoleButton").toString()); - m_consoleWindow = QColor(colors.value("consoleWindow").toString()); - m_consoleHighlight = QColor(colors.value("consoleHighlight").toString()); - m_consoleHighlightedText = QColor(colors.value("consoleHighlightedText").toString()); - m_consolePlaceholderText = QColor(colors.value("consolePlaceholderText").toString()); - m_windowBackground = QColor(colors.value("windowBackground").toString()); - m_windowGradient1 = QColor(colors.value("windowGradient1").toString()); - m_windowGradient2 = QColor(colors.value("windowGradient2").toString()); - m_menubarText = QColor(colors.value("menubarText").toString()); - m_dialogBackground = QColor(colors.value("dialogBackground").toString()); - m_alternativeHighlight = QColor(colors.value("alternativeHighlight").toString()); - m_setupPanelBackground = QColor(colors.value("setupPanelBackground").toString()); - m_widgetTextPrimary = QColor(colors.value("widgetTextPrimary").toString()); - m_widgetTextSecondary = QColor(colors.value("widgetTextSecondary").toString()); - m_widgetWindowBackground = QColor(colors.value("widgetWindowBackground").toString()); - m_widgetWindowBorder = QColor(colors.value("widgetWindowBorder").toString()); - m_paneWindowBackground = QColor(colors.value("paneWindowBackground").toString()); - m_ledEnabled = QColor(colors.value("ledEnabled").toString()); - m_ledDisabled = QColor(colors.value("ledDisabled").toString()); - m_csvCheckbox = QColor(colors.value("csvCheckbox").toString()); - m_widgetForegroundPrimary = QColor(colors.value("widgetForegroundPrimary").toString()); - m_widgetForegroundSecondary = QColor(colors.value("widgetForegroundSecondary").toString()); - m_widgetIndicator = QColor(colors.value("widgetIndicator").toString()); - m_widgetControlBackground = QColor(colors.value("widgetControlBackground").toString()); - m_connectButtonChecked = QColor(colors.value("connectButtonChecked").toString()); - m_connectButtonUnchecked = QColor(colors.value("connectButtonUnchecked").toString()); - m_mqttButton = QColor(colors.value("mqttButton").toString()); - // clang-format on + // Read colors from JSON file + // clang-format off + m_titlebarSeparator = document.object().value("titlebarSeparator").toBool(); + m_base = QColor(colors.value("base").toString()); + m_link = QColor(colors.value("link").toString()); + m_button = QColor(colors.value("button").toString()); + m_window = QColor(colors.value("window").toString()); + m_text = QColor(colors.value("text").toString()); + m_border = QColor(colors.value("border").toString()); + m_midlight = QColor(colors.value("midlight").toString()); + m_highlight = QColor(colors.value("highlight").toString()); + m_brightText = QColor(colors.value("brightText").toString()); + m_buttonText = QColor(colors.value("buttonText").toString()); + m_windowText = QColor(colors.value("windowText").toString()); + m_tooltipText = QColor(colors.value("tooltipText").toString()); + m_tooltipBase = QColor(colors.value("tooltipBase").toString()); + m_highlightedText = QColor(colors.value("highlightedText").toString()); + m_highlightedTextAlternative = QColor(colors.value("highlightedTextAlternative").toString()); + m_placeholderText = QColor(colors.value("placeholderText").toString()); + m_toolbarGradient1 = QColor(colors.value("toolbarGradient1").toString()); + m_toolbarGradient2 = QColor(colors.value("toolbarGradient2").toString()); + m_consoleText = QColor(colors.value("consoleText").toString()); + m_consoleBase = QColor(colors.value("consoleBase").toString()); + m_consoleButton = QColor(colors.value("consoleButton").toString()); + m_consoleWindow = QColor(colors.value("consoleWindow").toString()); + m_consoleHighlight = QColor(colors.value("consoleHighlight").toString()); + m_consoleHighlightedText = QColor(colors.value("consoleHighlightedText").toString()); + m_consolePlaceholderText = QColor(colors.value("consolePlaceholderText").toString()); + m_windowBackground = QColor(colors.value("windowBackground").toString()); + m_windowGradient1 = QColor(colors.value("windowGradient1").toString()); + m_windowGradient2 = QColor(colors.value("windowGradient2").toString()); + m_menubarText = QColor(colors.value("menubarText").toString()); + m_dialogBackground = QColor(colors.value("dialogBackground").toString()); + m_alternativeHighlight = QColor(colors.value("alternativeHighlight").toString()); + m_setupPanelBackground = QColor(colors.value("setupPanelBackground").toString()); + m_widgetTextPrimary = QColor(colors.value("widgetTextPrimary").toString()); + m_widgetTextSecondary = QColor(colors.value("widgetTextSecondary").toString()); + m_widgetWindowBackground = QColor(colors.value("widgetWindowBackground").toString()); + m_widgetWindowBorder = QColor(colors.value("widgetWindowBorder").toString()); + m_paneWindowBackground = QColor(colors.value("paneWindowBackground").toString()); + m_ledEnabled = QColor(colors.value("ledEnabled").toString()); + m_ledDisabled = QColor(colors.value("ledDisabled").toString()); + m_csvCheckbox = QColor(colors.value("csvCheckbox").toString()); + m_widgetForegroundPrimary = QColor(colors.value("widgetForegroundPrimary").toString()); + m_widgetForegroundSecondary = QColor(colors.value("widgetForegroundSecondary").toString()); + m_widgetIndicator = QColor(colors.value("widgetIndicator").toString()); + m_widgetControlBackground = QColor(colors.value("widgetControlBackground").toString()); + m_connectButtonChecked = QColor(colors.value("connectButtonChecked").toString()); + m_connectButtonUnchecked = QColor(colors.value("connectButtonUnchecked").toString()); + m_mqttButton = QColor(colors.value("mqttButton").toString()); + // clang-format on - // Read bar widget colors - m_widgetColors.clear(); - auto list = colors.value("widgetColors").toArray(); - for (int i = 0; i < list.count(); ++i) - m_widgetColors.append(list.at(i).toString()); + // Read bar widget colors + m_widgetColors.clear(); + auto list = colors.value("widgetColors").toArray(); + for (int i = 0; i < list.count(); ++i) + m_widgetColors.append(list.at(i).toString()); - // Update application palette - QPalette palette; - palette.setColor(QPalette::Base, base()); - palette.setColor(QPalette::Link, link()); - palette.setColor(QPalette::Text, text()); - palette.setColor(QPalette::Button, button()); - palette.setColor(QPalette::Window, window()); - palette.setColor(QPalette::Midlight, midlight()); - palette.setColor(QPalette::Highlight, highlight()); - palette.setColor(QPalette::BrightText, brightText()); - palette.setColor(QPalette::ButtonText, buttonText()); - palette.setColor(QPalette::WindowText, windowText()); - palette.setColor(QPalette::ToolTipBase, tooltipBase()); - palette.setColor(QPalette::ToolTipText, tooltipText()); - palette.setColor(QPalette::HighlightedText, highlightedText()); + // Update application palette + QPalette palette; + palette.setColor(QPalette::Base, base()); + palette.setColor(QPalette::Link, link()); + palette.setColor(QPalette::Text, text()); + palette.setColor(QPalette::Button, button()); + palette.setColor(QPalette::Window, window()); + palette.setColor(QPalette::Midlight, midlight()); + palette.setColor(QPalette::Highlight, highlight()); + palette.setColor(QPalette::BrightText, brightText()); + palette.setColor(QPalette::ButtonText, buttonText()); + palette.setColor(QPalette::WindowText, windowText()); + palette.setColor(QPalette::ToolTipBase, tooltipBase()); + palette.setColor(QPalette::ToolTipText, tooltipText()); + palette.setColor(QPalette::HighlightedText, highlightedText()); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - palette.setColor(QPalette::PlaceholderText, placeholderText()); + palette.setColor(QPalette::PlaceholderText, placeholderText()); #endif - qApp->setPalette(palette); + qApp->setPalette(palette); - // Update user interface - m_themeId = id; - Q_EMIT themeChanged(); + // Update user interface + m_themeId = id; + Q_EMIT themeChanged(); } /** @@ -236,34 +236,34 @@ void Misc::ThemeManager::loadTheme(const int id) */ void Misc::ThemeManager::populateThemes() { - // Clear available thems - m_availableThemes.clear(); - m_availableThemesPaths.clear(); + // Clear available thems + m_availableThemes.clear(); + m_availableThemesPaths.clear(); - // Scan themes directory & get list of files - auto themeList = QDir(":/themes").entryList(); + // Scan themes directory & get list of files + auto themeList = QDir(":/themes").entryList(); - // Open each JSON file & get theme names - for (int i = 0; i < themeList.count(); ++i) + // Open each JSON file & get theme names + for (int i = 0; i < themeList.count(); ++i) + { + QFile file(QString(":/themes/%1").arg(themeList.at(i))); + if (file.open(QFile::ReadOnly)) { - QFile file(QString(":/themes/%1").arg(themeList.at(i))); - if (file.open(QFile::ReadOnly)) - { - auto data = file.readAll(); - file.close(); + auto data = file.readAll(); + file.close(); - auto document = QJsonDocument::fromJson(data); - auto name = document.object().value("name").toString(); - if (!name.isEmpty()) - { - m_availableThemes.append(name); - m_availableThemesPaths.append(file.fileName()); - } - } + auto document = QJsonDocument::fromJson(data); + auto name = document.object().value("name").toString(); + if (!name.isEmpty()) + { + m_availableThemes.append(name); + m_availableThemesPaths.append(file.fileName()); + } } + } - // Update UI - Q_EMIT availableThemesChanged(); + // Update UI + Q_EMIT availableThemesChanged(); } //---------------------------------------------------------------------------------------- @@ -272,254 +272,250 @@ void Misc::ThemeManager::populateThemes() bool Misc::ThemeManager::titlebarSeparator() const { - return m_titlebarSeparator; + return m_titlebarSeparator; } QColor Misc::ThemeManager::base() const { - return m_base; + return m_base; } QColor Misc::ThemeManager::link() const { - return m_link; + return m_link; } QColor Misc::ThemeManager::button() const { - return m_button; + return m_button; } QColor Misc::ThemeManager::window() const { - return m_window; + return m_window; } QColor Misc::ThemeManager::text() const { - return m_text; + return m_text; } QColor Misc::ThemeManager::border() const { - return m_border; + return m_border; } QColor Misc::ThemeManager::midlight() const { - return m_midlight; + return m_midlight; } QColor Misc::ThemeManager::highlight() const { - return m_highlight; + return m_highlight; } QColor Misc::ThemeManager::brightText() const { - return m_brightText; + return m_brightText; } QColor Misc::ThemeManager::buttonText() const { - return m_buttonText; + return m_buttonText; } QColor Misc::ThemeManager::windowText() const { - return m_windowText; + return m_windowText; } QColor Misc::ThemeManager::tooltipText() const { - return m_tooltipText; + return m_tooltipText; } QColor Misc::ThemeManager::tooltipBase() const { - return m_tooltipBase; + return m_tooltipBase; } QColor Misc::ThemeManager::highlightedText() const { - return m_highlightedText; + return m_highlightedText; } QColor Misc::ThemeManager::highlightedTextAlternative() const { - return m_highlightedTextAlternative; + return m_highlightedTextAlternative; } QColor Misc::ThemeManager::placeholderText() const { - return m_placeholderText; + return m_placeholderText; } QColor Misc::ThemeManager::toolbarGradient1() const { - return m_toolbarGradient1; + return m_toolbarGradient1; } QColor Misc::ThemeManager::toolbarGradient2() const { - return m_toolbarGradient2; + return m_toolbarGradient2; } QColor Misc::ThemeManager::menubarText() const { - return m_menubarText; + return m_menubarText; } QColor Misc::ThemeManager::dialogBackground() const { - return m_dialogBackground; + return m_dialogBackground; } QColor Misc::ThemeManager::consoleText() const { - return m_consoleText; + return m_consoleText; } QColor Misc::ThemeManager::consoleBase() const { - return m_consoleBase; + return m_consoleBase; } QColor Misc::ThemeManager::consoleButton() const { - return m_consoleButton; + return m_consoleButton; } QColor Misc::ThemeManager::consoleWindow() const { - return m_consoleWindow; + return m_consoleWindow; } QColor Misc::ThemeManager::consoleHighlight() const { - return m_consoleHighlight; + return m_consoleHighlight; } QColor Misc::ThemeManager::consoleHighlightedText() const { - return m_consoleHighlightedText; + return m_consoleHighlightedText; } QColor Misc::ThemeManager::consolePlaceholderText() const { - return m_consolePlaceholderText; + return m_consolePlaceholderText; } QColor Misc::ThemeManager::windowBackground() const { - return m_windowBackground; + return m_windowBackground; } QColor Misc::ThemeManager::windowGradient1() const { - return m_windowGradient1; + return m_windowGradient1; } QColor Misc::ThemeManager::windowGradient2() const { - return m_windowGradient2; + return m_windowGradient2; } QColor Misc::ThemeManager::alternativeHighlight() const { - return m_alternativeHighlight; + return m_alternativeHighlight; } QColor Misc::ThemeManager::setupPanelBackground() const { - return m_setupPanelBackground; + return m_setupPanelBackground; } QColor Misc::ThemeManager::widgetTextPrimary() const { - return m_widgetTextPrimary; + return m_widgetTextPrimary; } QColor Misc::ThemeManager::widgetTextSecondary() const { - return m_widgetTextSecondary; + return m_widgetTextSecondary; } QColor Misc::ThemeManager::widgetWindowBackground() const { - return m_widgetWindowBackground; + return m_widgetWindowBackground; } QColor Misc::ThemeManager::widgetWindowBorder() const { - return m_widgetWindowBorder; + return m_widgetWindowBorder; } QColor Misc::ThemeManager::paneWindowBackground() const { - return m_paneWindowBackground; + return m_paneWindowBackground; } QColor Misc::ThemeManager::ledEnabled() const { - return m_ledEnabled; + return m_ledEnabled; } QColor Misc::ThemeManager::ledDisabled() const { - return m_ledDisabled; + return m_ledDisabled; } QColor Misc::ThemeManager::csvCheckbox() const { - return m_csvCheckbox; + return m_csvCheckbox; } QColor Misc::ThemeManager::widgetForegroundPrimary() const { - return m_widgetForegroundPrimary; + return m_widgetForegroundPrimary; } QColor Misc::ThemeManager::widgetForegroundSecondary() const { - return m_widgetForegroundSecondary; + return m_widgetForegroundSecondary; } QColor Misc::ThemeManager::widgetIndicator() const { - return m_widgetIndicator; + return m_widgetIndicator; } QColor Misc::ThemeManager::widgetControlBackground() const { - return m_widgetControlBackground; + return m_widgetControlBackground; } QColor Misc::ThemeManager::connectButtonChecked() const { - return m_connectButtonChecked; + return m_connectButtonChecked; } QColor Misc::ThemeManager::connectButtonUnchecked() const { - return m_connectButtonUnchecked; + return m_connectButtonUnchecked; } QColor Misc::ThemeManager::mqttButton() const { - return m_mqttButton; + return m_mqttButton; } StringList Misc::ThemeManager::widgetColors() const { - return m_widgetColors; + return m_widgetColors; } StringList Misc::ThemeManager::availableThemes() const { - return m_availableThemes; + return m_availableThemes; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_ThemeManager.cpp" -#endif diff --git a/src/Misc/ThemeManager.h b/src/Misc/ThemeManager.h index 2bf84f4f..0c2617d3 100644 --- a/src/Misc/ThemeManager.h +++ b/src/Misc/ThemeManager.h @@ -32,16 +32,17 @@ namespace Misc /** * @brief The ThemeManager class * - * The @c ThemeManager class reads all the colors that are required to build a Serial - * Studio theme and makes them available to the rest of the application. + * The @c ThemeManager class reads all the colors that are required to build a + * Serial Studio theme and makes them available to the rest of the application. * - * Themes are stored as JSON files in the "assets/themes" folder. The class automatically - * builds a model with the available themes. The only requirement to create your own - * themes is to create a JSON theme file and add it to the application resources file. + * Themes are stored as JSON files in the "assets/themes" folder. The class + * automatically builds a model with the available themes. The only requirement + * to create your own themes is to create a JSON theme file and add it to the + * application resources file. */ class ThemeManager : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(int themeId READ themeId @@ -200,158 +201,158 @@ class ThemeManager : public QObject READ customWindowDecorations WRITE setCustomWindowDecorations NOTIFY customWindowDecorationsChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void themeChanged(); - void availableThemesChanged(); - void customWindowDecorationsChanged(); + void themeChanged(); + void availableThemesChanged(); + void customWindowDecorationsChanged(); private: - explicit ThemeManager(); - ThemeManager(ThemeManager &&) = delete; - ThemeManager(const ThemeManager &) = delete; - ThemeManager &operator=(ThemeManager &&) = delete; - ThemeManager &operator=(const ThemeManager &) = delete; + explicit ThemeManager(); + ThemeManager(ThemeManager &&) = delete; + ThemeManager(const ThemeManager &) = delete; + ThemeManager &operator=(ThemeManager &&) = delete; + ThemeManager &operator=(const ThemeManager &) = delete; public: - static ThemeManager &instance(); + static ThemeManager &instance(); - int themeId() const; - bool customWindowDecorations() const; + int themeId() const; + bool customWindowDecorations() const; - bool titlebarSeparator() const; - QColor base() const; - QColor link() const; - QColor button() const; - QColor window() const; - QColor text() const; - QColor border() const; - QColor midlight() const; - QColor highlight() const; - QColor brightText() const; - QColor buttonText() const; - QColor windowText() const; - QColor tooltipText() const; - QColor tooltipBase() const; - QColor highlightedText() const; - QColor highlightedTextAlternative() const; - QColor placeholderText() const; - QColor toolbarGradient1() const; - QColor toolbarGradient2() const; - QColor menubarText() const; - QColor dialogBackground() const; - QColor consoleText() const; - QColor consoleBase() const; - QColor consoleButton() const; - QColor consoleWindow() const; - QColor consoleHighlight() const; - QColor consoleHighlightedText() const; - QColor consolePlaceholderText() const; - QColor windowBackground() const; - QColor windowGradient1() const; - QColor windowGradient2() const; - QColor alternativeHighlight() const; - QColor setupPanelBackground() const; - QColor widgetTextPrimary() const; - QColor widgetTextSecondary() const; - QColor widgetWindowBackground() const; - QColor widgetWindowBorder() const; - QColor paneWindowBackground() const; - QColor ledEnabled() const; - QColor ledDisabled() const; - QColor csvCheckbox() const; - QColor widgetForegroundPrimary() const; - QColor widgetForegroundSecondary() const; - QColor widgetIndicator() const; - QColor widgetControlBackground() const; - QColor connectButtonChecked() const; - QColor connectButtonUnchecked() const; - QColor mqttButton() const; + bool titlebarSeparator() const; + QColor base() const; + QColor link() const; + QColor button() const; + QColor window() const; + QColor text() const; + QColor border() const; + QColor midlight() const; + QColor highlight() const; + QColor brightText() const; + QColor buttonText() const; + QColor windowText() const; + QColor tooltipText() const; + QColor tooltipBase() const; + QColor highlightedText() const; + QColor highlightedTextAlternative() const; + QColor placeholderText() const; + QColor toolbarGradient1() const; + QColor toolbarGradient2() const; + QColor menubarText() const; + QColor dialogBackground() const; + QColor consoleText() const; + QColor consoleBase() const; + QColor consoleButton() const; + QColor consoleWindow() const; + QColor consoleHighlight() const; + QColor consoleHighlightedText() const; + QColor consolePlaceholderText() const; + QColor windowBackground() const; + QColor windowGradient1() const; + QColor windowGradient2() const; + QColor alternativeHighlight() const; + QColor setupPanelBackground() const; + QColor widgetTextPrimary() const; + QColor widgetTextSecondary() const; + QColor widgetWindowBackground() const; + QColor widgetWindowBorder() const; + QColor paneWindowBackground() const; + QColor ledEnabled() const; + QColor ledDisabled() const; + QColor csvCheckbox() const; + QColor widgetForegroundPrimary() const; + QColor widgetForegroundSecondary() const; + QColor widgetIndicator() const; + QColor widgetControlBackground() const; + QColor connectButtonChecked() const; + QColor connectButtonUnchecked() const; + QColor mqttButton() const; - StringList widgetColors() const; - StringList availableThemes() const; + StringList widgetColors() const; + StringList availableThemes() const; public Q_SLOTS: - void setTheme(const int id); - void setCustomWindowDecorations(const bool enabled); + void setTheme(const int id); + void setCustomWindowDecorations(const bool enabled); private Q_SLOTS: - void populateThemes(); - void loadTheme(const int id); + void populateThemes(); + void loadTheme(const int id); private: - int m_themeId; - bool m_customWindowDecorations; + int m_themeId; + bool m_customWindowDecorations; - QSettings m_settings; - bool m_titlebarSeparator; - StringList m_availableThemes; - StringList m_availableThemesPaths; + QSettings m_settings; + bool m_titlebarSeparator; + StringList m_availableThemes; + StringList m_availableThemesPaths; - QColor m_base; - QColor m_link; - QColor m_button; - QColor m_window; - QColor m_text; - QColor m_border; - QColor m_midlight; - QColor m_highlight; - QColor m_brightText; - QColor m_buttonText; - QColor m_windowText; - QColor m_tooltipText; - QColor m_tooltipBase; - QColor m_highlightedText; - QColor m_highlightedTextAlternative; - QColor m_placeholderText; - QColor m_toolbarGradient1; - QColor m_toolbarGradient2; - QColor m_menubarText; - QColor m_dialogBackground; - QColor m_consoleText; - QColor m_consoleBase; - QColor m_consoleButton; - QColor m_consoleWindow; - QColor m_consoleHighlight; - QColor m_consoleHighlightedText; - QColor m_consolePlaceholderText; - QColor m_windowBackground; - QColor m_windowGradient1; - QColor m_windowGradient2; - QColor m_alternativeHighlight; - QColor m_setupPanelBackground; - QColor m_widgetTextPrimary; - QColor m_widgetTextSecondary; - QColor m_widgetWindowBackground; - QColor m_widgetWindowBorder; - QColor m_paneWindowBackground; - QColor m_ledEnabled; - QColor m_ledDisabled; - QColor m_csvCheckbox; - QColor m_widgetForegroundPrimary; - QColor m_widgetForegroundSecondary; - QColor m_widgetIndicator; - QColor m_widgetControlBackground; - QColor m_connectButtonChecked; - QColor m_connectButtonUnchecked; - QColor m_mqttButton; - StringList m_widgetColors; + QColor m_base; + QColor m_link; + QColor m_button; + QColor m_window; + QColor m_text; + QColor m_border; + QColor m_midlight; + QColor m_highlight; + QColor m_brightText; + QColor m_buttonText; + QColor m_windowText; + QColor m_tooltipText; + QColor m_tooltipBase; + QColor m_highlightedText; + QColor m_highlightedTextAlternative; + QColor m_placeholderText; + QColor m_toolbarGradient1; + QColor m_toolbarGradient2; + QColor m_menubarText; + QColor m_dialogBackground; + QColor m_consoleText; + QColor m_consoleBase; + QColor m_consoleButton; + QColor m_consoleWindow; + QColor m_consoleHighlight; + QColor m_consoleHighlightedText; + QColor m_consolePlaceholderText; + QColor m_windowBackground; + QColor m_windowGradient1; + QColor m_windowGradient2; + QColor m_alternativeHighlight; + QColor m_setupPanelBackground; + QColor m_widgetTextPrimary; + QColor m_widgetTextSecondary; + QColor m_widgetWindowBackground; + QColor m_widgetWindowBorder; + QColor m_paneWindowBackground; + QColor m_ledEnabled; + QColor m_ledDisabled; + QColor m_csvCheckbox; + QColor m_widgetForegroundPrimary; + QColor m_widgetForegroundSecondary; + QColor m_widgetIndicator; + QColor m_widgetControlBackground; + QColor m_connectButtonChecked; + QColor m_connectButtonUnchecked; + QColor m_mqttButton; + StringList m_widgetColors; }; -} +} // namespace Misc inline QString QSS(const QString &style, const QColor &color) { - return QString(style).arg(color.name()); + return QString(style).arg(color.name()); } inline QString QSS(const QString &style, const QColor &c1, const QColor &c2) { - return QString(style).arg(c1.name(), c2.name()); + return QString(style).arg(c1.name(), c2.name()); } inline QString QSS(const QString &style, const QColor &c1, const QColor &c2, const QColor &c3) { - return QString(style).arg(c1.name(), c2.name(), c3.name()); + return QString(style).arg(c1.name(), c2.name(), c3.name()); } diff --git a/src/Misc/TimerEvents.cpp b/src/Misc/TimerEvents.cpp index 33846d3b..7aa1e00e 100644 --- a/src/Misc/TimerEvents.cpp +++ b/src/Misc/TimerEvents.cpp @@ -28,8 +28,8 @@ */ Misc::TimerEvents &Misc::TimerEvents::instance() { - static TimerEvents singleton; - return singleton; + static TimerEvents singleton; + return singleton; } /** @@ -37,9 +37,9 @@ Misc::TimerEvents &Misc::TimerEvents::instance() */ void Misc::TimerEvents::stopTimers() { - m_timer1Hz.stop(); - m_timer10Hz.stop(); - m_timer20Hz.stop(); + m_timer1Hz.stop(); + m_timer10Hz.stop(); + m_timer20Hz.stop(); } /** @@ -47,14 +47,14 @@ void Misc::TimerEvents::stopTimers() */ void Misc::TimerEvents::timerEvent(QTimerEvent *event) { - if (event->timerId() == m_timer1Hz.timerId()) - Q_EMIT timeout1Hz(); + if (event->timerId() == m_timer1Hz.timerId()) + Q_EMIT timeout1Hz(); - else if (event->timerId() == m_timer10Hz.timerId()) - Q_EMIT timeout10Hz(); + else if (event->timerId() == m_timer10Hz.timerId()) + Q_EMIT timeout10Hz(); - else if (event->timerId() == m_timer20Hz.timerId()) - Q_EMIT timeout20Hz(); + else if (event->timerId() == m_timer20Hz.timerId()) + Q_EMIT timeout20Hz(); } /** @@ -62,11 +62,7 @@ void Misc::TimerEvents::timerEvent(QTimerEvent *event) */ void Misc::TimerEvents::startTimers() { - m_timer20Hz.start(50, this); - m_timer10Hz.start(100, this); - m_timer1Hz.start(1000, this); + m_timer20Hz.start(50, this); + m_timer10Hz.start(100, this); + m_timer1Hz.start(1000, this); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_TimerEvents.cpp" -#endif diff --git a/src/Misc/TimerEvents.h b/src/Misc/TimerEvents.h index 95163bdb..43832e1f 100644 --- a/src/Misc/TimerEvents.h +++ b/src/Misc/TimerEvents.h @@ -35,35 +35,33 @@ namespace Misc */ class TimerEvents : public QObject { - // clang-format off - Q_OBJECT - // clang-format on + Q_OBJECT Q_SIGNALS: - void timeout1Hz(); - void timeout10Hz(); - void timeout20Hz(); + void timeout1Hz(); + void timeout10Hz(); + void timeout20Hz(); private: - TimerEvents() {}; - TimerEvents(TimerEvents &&) = delete; - TimerEvents(const TimerEvents &) = delete; - TimerEvents &operator=(TimerEvents &&) = delete; - TimerEvents &operator=(const TimerEvents &) = delete; + TimerEvents(){}; + TimerEvents(TimerEvents &&) = delete; + TimerEvents(const TimerEvents &) = delete; + TimerEvents &operator=(TimerEvents &&) = delete; + TimerEvents &operator=(const TimerEvents &) = delete; public: - static TimerEvents &instance(); + static TimerEvents &instance(); protected: - void timerEvent(QTimerEvent *event) override; + void timerEvent(QTimerEvent *event) override; public Q_SLOTS: - void stopTimers(); - void startTimers(); + void stopTimers(); + void startTimers(); private: - QBasicTimer m_timer1Hz; - QBasicTimer m_timer10Hz; - QBasicTimer m_timer20Hz; + QBasicTimer m_timer1Hz; + QBasicTimer m_timer10Hz; + QBasicTimer m_timer20Hz; }; -} +} // namespace Misc diff --git a/src/Misc/Translator.cpp b/src/Misc/Translator.cpp index cb221819..8f6f89e0 100644 --- a/src/Misc/Translator.cpp +++ b/src/Misc/Translator.cpp @@ -27,7 +27,7 @@ */ Misc::Translator::Translator() { - setLanguage(m_settings.value("language", systemLanguage()).toInt()); + setLanguage(m_settings.value("language", systemLanguage()).toInt()); } /** @@ -35,8 +35,8 @@ Misc::Translator::Translator() */ Misc::Translator &Misc::Translator::instance() { - static Translator singleton; - return singleton; + static Translator singleton; + return singleton; } /** @@ -45,7 +45,7 @@ Misc::Translator &Misc::Translator::instance() */ int Misc::Translator::language() const { - return m_language; + return m_language; } /** @@ -54,30 +54,30 @@ int Misc::Translator::language() const */ int Misc::Translator::systemLanguage() const { - int lang; - switch (QLocale::system().language()) - { - case QLocale::English: - lang = 0; - break; - case QLocale::Spanish: - lang = 1; - break; - case QLocale::Chinese: - lang = 2; - break; - case QLocale::German: - lang = 3; - break; - case QLocale::Russian: - lang = 4; - break; - default: - lang = 0; - break; - } + int lang; + switch (QLocale::system().language()) + { + case QLocale::English: + lang = 0; + break; + case QLocale::Spanish: + lang = 1; + break; + case QLocale::Chinese: + lang = 2; + break; + case QLocale::German: + lang = 3; + break; + case QLocale::Russian: + lang = 4; + break; + default: + lang = 0; + break; + } - return lang; + return lang; } /** @@ -85,38 +85,38 @@ int Misc::Translator::systemLanguage() const */ QString Misc::Translator::welcomeConsoleText() const { - QString lang; - switch (language()) - { - case 0: - lang = "EN"; - break; - case 1: - lang = "ES"; - break; - case 2: - lang = "ZH"; - break; - case 3: - lang = "DE"; - break; - case 4: - lang = "RU"; - break; - default: - lang = "EN"; - break; - } + QString lang; + switch (language()) + { + case 0: + lang = "EN"; + break; + case 1: + lang = "ES"; + break; + case 2: + lang = "ZH"; + break; + case 3: + lang = "DE"; + break; + case 4: + lang = "RU"; + break; + default: + lang = "EN"; + break; + } - QString text = QObject::tr("Failed to load welcome text :("); - QFile file(":/messages/Welcome_" + lang + ".txt"); - if (file.open(QFile::ReadOnly)) - { - text = QString::fromUtf8(file.readAll()); - file.close(); - } + QString text = QObject::tr("Failed to load welcome text :("); + QFile file(":/messages/Welcome_" + lang + ".txt"); + if (file.open(QFile::ReadOnly)) + { + text = QString::fromUtf8(file.readAll()); + file.close(); + } - return text; + return text; } /** @@ -124,15 +124,15 @@ QString Misc::Translator::welcomeConsoleText() const */ QString Misc::Translator::acknowledgementsText() const { - QString text = ""; - QFile file(":/messages/Acknowledgements.txt"); - if (file.open(QFile::ReadOnly)) - { - text = QString::fromUtf8(file.readAll()); - file.close(); - } + QString text = ""; + QFile file(":/messages/Acknowledgements.txt"); + if (file.open(QFile::ReadOnly)) + { + text = QString::fromUtf8(file.readAll()); + file.close(); + } - return text; + return text; } /** @@ -140,7 +140,7 @@ QString Misc::Translator::acknowledgementsText() const */ StringList Misc::Translator::availableLanguages() const { - return StringList { "English", "Español", "简体中文", "Deutsch", "Русский" }; + return StringList{"English", "Español", "简体中文", "Deutsch", "Русский"}; } /** @@ -152,40 +152,40 @@ StringList Misc::Translator::availableLanguages() const */ void Misc::Translator::setLanguage(const int language) { - QString langName; - QLocale locale; - switch (language) - { - case 0: - langName = "en"; - locale = QLocale(QLocale::English); - break; - case 1: - langName = "es"; - locale = QLocale(QLocale::Spanish); - break; - case 2: - langName = "zh"; - locale = QLocale(QLocale::Chinese); - break; - case 3: - langName = "de"; - locale = QLocale(QLocale::German); - break; - case 4: - langName = "ru"; - locale = QLocale(QLocale::Russian); - break; - default: - langName = "en"; - locale = QLocale(QLocale::English); - break; - } + QString langName; + QLocale locale; + switch (language) + { + case 0: + langName = "en"; + locale = QLocale(QLocale::English); + break; + case 1: + langName = "es"; + locale = QLocale(QLocale::Spanish); + break; + case 2: + langName = "zh"; + locale = QLocale(QLocale::Chinese); + break; + case 3: + langName = "de"; + locale = QLocale(QLocale::German); + break; + case 4: + langName = "ru"; + locale = QLocale(QLocale::Russian); + break; + default: + langName = "en"; + locale = QLocale(QLocale::English); + break; + } - m_language = language; - m_settings.setValue("language", m_language); + m_language = language; + m_settings.setValue("language", m_language); - setLanguage(locale, langName); + setLanguage(locale, langName); } /** @@ -196,16 +196,13 @@ void Misc::Translator::setLanguage(const int language) * @param language name of the *.qm file to load from the "translations" * directory inside the application's resources */ -void Misc::Translator::setLanguage(const QLocale &locale, const QString &language) +void Misc::Translator::setLanguage(const QLocale &locale, + const QString &language) { - qApp->removeTranslator(&m_translator); - if (m_translator.load(locale, ":/translations/" + language + ".qm")) - { - qApp->installTranslator(&m_translator); - Q_EMIT languageChanged(); - } + qApp->removeTranslator(&m_translator); + if (m_translator.load(locale, ":/translations/" + language + ".qm")) + { + qApp->installTranslator(&m_translator); + Q_EMIT languageChanged(); + } } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Translator.cpp" -#endif diff --git a/src/Misc/Translator.h b/src/Misc/Translator.h index 97cee386..5ebdb0c5 100644 --- a/src/Misc/Translator.h +++ b/src/Misc/Translator.h @@ -28,7 +28,7 @@ #include #ifdef QT_QML_LIB -# include +# include #endif namespace Misc @@ -37,12 +37,12 @@ namespace Misc * @brief The Translator class * * The @c Translator module provides the user interface with a list of available - * translations, and loads the specified translation file during application startup or - * when the user changes the language of the application. + * translations, and loads the specified translation file during application + * startup or when the user changes the language of the application. */ class Translator : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(int language READ language @@ -51,34 +51,34 @@ class Translator : public QObject Q_PROPERTY(StringList availableLanguages READ availableLanguages CONSTANT) - // clang-format on + // clang-format on Q_SIGNALS: - void languageChanged(); + void languageChanged(); private: - explicit Translator(); - Translator(Translator &&) = delete; - Translator(const Translator &) = delete; - Translator &operator=(Translator &&) = delete; - Translator &operator=(const Translator &) = delete; + explicit Translator(); + Translator(Translator &&) = delete; + Translator(const Translator &) = delete; + Translator &operator=(Translator &&) = delete; + Translator &operator=(const Translator &) = delete; public: - static Translator &instance(); + static Translator &instance(); - int language() const; - int systemLanguage() const; - StringList availableLanguages() const; - Q_INVOKABLE QString welcomeConsoleText() const; - Q_INVOKABLE QString acknowledgementsText() const; + int language() const; + int systemLanguage() const; + StringList availableLanguages() const; + Q_INVOKABLE QString welcomeConsoleText() const; + Q_INVOKABLE QString acknowledgementsText() const; public Q_SLOTS: - void setLanguage(const int language); - void setLanguage(const QLocale &locale, const QString &language); + void setLanguage(const int language); + void setLanguage(const QLocale &locale, const QString &language); private: - int m_language; - QSettings m_settings; - QTranslator m_translator; + int m_language; + QSettings m_settings; + QTranslator m_translator; }; -} +} // namespace Misc diff --git a/src/Misc/Utilities.cpp b/src/Misc/Utilities.cpp index 6b87969b..dd945b6d 100644 --- a/src/Misc/Utilities.cpp +++ b/src/Misc/Utilities.cpp @@ -38,8 +38,8 @@ */ Misc::Utilities &Misc::Utilities::instance() { - static Utilities singleton; - return singleton; + static Utilities singleton; + return singleton; } /** @@ -48,95 +48,98 @@ Misc::Utilities &Misc::Utilities::instance() void Misc::Utilities::rebootApplication() { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - qApp->exit(); - QProcess::startDetached(qApp->arguments().first(), qApp->arguments()); + qApp->exit(); + QProcess::startDetached(qApp->arguments().first(), qApp->arguments()); #else -# ifdef Q_OS_MAC - auto bundle = qApp->applicationDirPath() + "/../../"; - QProcess::startDetached("open", { "-n", "-a", bundle }); -# else - QProcess::startDetached(qApp->arguments()[0], qApp->arguments()); -# endif - qApp->exit(); +# ifdef Q_OS_MAC + auto bundle = qApp->applicationDirPath() + "/../../"; + QProcess::startDetached("open", {"-n", "-a", bundle}); +# else + QProcess::startDetached(qApp->arguments()[0], qApp->arguments()); +# endif + qApp->exit(); #endif } /** - * Asks the user if he/she wants the application to check for updates automatically + * Asks the user if he/she wants the application to check for updates + * automatically */ bool Misc::Utilities::askAutomaticUpdates() { - const int result = showMessageBox(tr("Check for updates automatically?"), - tr("Should %1 automatically check for updates? " - "You can always check for updates manually from " - "the \"Help\" menu") - .arg(APP_NAME), - APP_NAME, QMessageBox::Yes | QMessageBox::No); - return result == QMessageBox::Yes; + const int result + = showMessageBox(tr("Check for updates automatically?"), + tr("Should %1 automatically check for updates? " + "You can always check for updates manually from " + "the \"Help\" menu") + .arg(APP_NAME), + APP_NAME, QMessageBox::Yes | QMessageBox::No); + return result == QMessageBox::Yes; } /** * Shows a macOS-like message box with the given properties */ -int Misc::Utilities::showMessageBox(const QString &text, const QString &informativeText, +int Misc::Utilities::showMessageBox(const QString &text, + const QString &informativeText, const QString &windowTitle, const QMessageBox::StandardButtons &bt) { - // Get app icon - QPixmap icon; - if (qApp->devicePixelRatio() >= 2) - icon.load(":/images/icon-small@2x.png"); - else - icon.load(":/images/icon-small@1x.png"); + // Get app icon + QPixmap icon; + if (qApp->devicePixelRatio() >= 2) + icon.load(":/images/icon-small@2x.png"); + else + icon.load(":/images/icon-small@1x.png"); - // Create message box & set options - QMessageBox box; - box.setIconPixmap(icon); - box.setStandardButtons(bt); - box.setWindowTitle(windowTitle); - box.setText("

" + text + "

"); - box.setInformativeText(informativeText); + // Create message box & set options + QMessageBox box; + box.setIconPixmap(icon); + box.setStandardButtons(bt); + box.setWindowTitle(windowTitle); + box.setText("

" + text + "

"); + box.setInformativeText(informativeText); - // Add button translations - if (bt & QMessageBox::Ok) - box.button(QMessageBox::Ok)->setText(tr("Ok")); - if (bt & QMessageBox::Save) - box.button(QMessageBox::Save)->setText(tr("Save")); - if (bt & QMessageBox::SaveAll) - box.button(QMessageBox::SaveAll)->setText(tr("Save all")); - if (bt & QMessageBox::Open) - box.button(QMessageBox::Open)->setText(tr("Open")); - if (bt & QMessageBox::Yes) - box.button(QMessageBox::Yes)->setText(tr("Yes")); - if (bt & QMessageBox::YesToAll) - box.button(QMessageBox::YesToAll)->setText(tr("Yes to all")); - if (bt & QMessageBox::No) - box.button(QMessageBox::No)->setText(tr("No")); - if (bt & QMessageBox::NoToAll) - box.button(QMessageBox::NoToAll)->setText(tr("No to all")); - if (bt & QMessageBox::Abort) - box.button(QMessageBox::Abort)->setText(tr("Abort")); - if (bt & QMessageBox::Retry) - box.button(QMessageBox::Retry)->setText(tr("Retry")); - if (bt & QMessageBox::Ignore) - box.button(QMessageBox::Ignore)->setText(tr("Ignore")); - if (bt & QMessageBox::Close) - box.button(QMessageBox::Close)->setText(tr("Close")); - if (bt & QMessageBox::Cancel) - box.button(QMessageBox::Cancel)->setText(tr("Cancel")); - if (bt & QMessageBox::Discard) - box.button(QMessageBox::Discard)->setText(tr("Discard")); - if (bt & QMessageBox::Help) - box.button(QMessageBox::Help)->setText(tr("Help")); - if (bt & QMessageBox::Apply) - box.button(QMessageBox::Apply)->setText(tr("Apply")); - if (bt & QMessageBox::Reset) - box.button(QMessageBox::Reset)->setText(tr("Reset")); - if (bt & QMessageBox::RestoreDefaults) - box.button(QMessageBox::RestoreDefaults)->setText(tr("Restore defaults")); + // Add button translations + if (bt & QMessageBox::Ok) + box.button(QMessageBox::Ok)->setText(tr("Ok")); + if (bt & QMessageBox::Save) + box.button(QMessageBox::Save)->setText(tr("Save")); + if (bt & QMessageBox::SaveAll) + box.button(QMessageBox::SaveAll)->setText(tr("Save all")); + if (bt & QMessageBox::Open) + box.button(QMessageBox::Open)->setText(tr("Open")); + if (bt & QMessageBox::Yes) + box.button(QMessageBox::Yes)->setText(tr("Yes")); + if (bt & QMessageBox::YesToAll) + box.button(QMessageBox::YesToAll)->setText(tr("Yes to all")); + if (bt & QMessageBox::No) + box.button(QMessageBox::No)->setText(tr("No")); + if (bt & QMessageBox::NoToAll) + box.button(QMessageBox::NoToAll)->setText(tr("No to all")); + if (bt & QMessageBox::Abort) + box.button(QMessageBox::Abort)->setText(tr("Abort")); + if (bt & QMessageBox::Retry) + box.button(QMessageBox::Retry)->setText(tr("Retry")); + if (bt & QMessageBox::Ignore) + box.button(QMessageBox::Ignore)->setText(tr("Ignore")); + if (bt & QMessageBox::Close) + box.button(QMessageBox::Close)->setText(tr("Close")); + if (bt & QMessageBox::Cancel) + box.button(QMessageBox::Cancel)->setText(tr("Cancel")); + if (bt & QMessageBox::Discard) + box.button(QMessageBox::Discard)->setText(tr("Discard")); + if (bt & QMessageBox::Help) + box.button(QMessageBox::Help)->setText(tr("Help")); + if (bt & QMessageBox::Apply) + box.button(QMessageBox::Apply)->setText(tr("Apply")); + if (bt & QMessageBox::Reset) + box.button(QMessageBox::Reset)->setText(tr("Reset")); + if (bt & QMessageBox::RestoreDefaults) + box.button(QMessageBox::RestoreDefaults)->setText(tr("Restore defaults")); - // Show message box & return user decision to caller - return box.exec(); + // Show message box & return user decision to caller + return box.exec(); } /** @@ -144,7 +147,7 @@ int Misc::Utilities::showMessageBox(const QString &text, const QString &informat */ void Misc::Utilities::aboutQt() { - qApp->aboutQt(); + qApp->aboutQt(); } /** @@ -158,28 +161,24 @@ void Misc::Utilities::aboutQt() void Misc::Utilities::revealFile(const QString &pathToReveal) { #if defined(Q_OS_WIN) - QStringList param; - const QFileInfo fileInfo(pathToReveal); - if (!fileInfo.isDir()) - param += QLatin1String("/select,"); - param += QDir::toNativeSeparators(fileInfo.canonicalFilePath()); - QProcess::startDetached("explorer.exe", param); + QStringList param; + const QFileInfo fileInfo(pathToReveal); + if (!fileInfo.isDir()) + param += QLatin1String("/select,"); + param += QDir::toNativeSeparators(fileInfo.canonicalFilePath()); + QProcess::startDetached("explorer.exe", param); #elif defined(Q_OS_MAC) - QStringList scriptArgs; - scriptArgs << QLatin1String("-e") - << QString::fromLatin1( - "tell application \"Finder\" to reveal POSIX file \"%1\"") - .arg(pathToReveal); - QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs); - scriptArgs.clear(); - scriptArgs << QLatin1String("-e") - << QLatin1String("tell application \"Finder\" to activate"); - QProcess::execute("/usr/bin/osascript", scriptArgs); + QStringList scriptArgs; + scriptArgs << QLatin1String("-e") + << QString::fromLatin1( + "tell application \"Finder\" to reveal POSIX file \"%1\"") + .arg(pathToReveal); + QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs); + scriptArgs.clear(); + scriptArgs << QLatin1String("-e") + << QLatin1String("tell application \"Finder\" to activate"); + QProcess::execute("/usr/bin/osascript", scriptArgs); #else - QDesktopServices::openUrl(QUrl::fromLocalFile(pathToReveal)); + QDesktopServices::openUrl(QUrl::fromLocalFile(pathToReveal)); #endif } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Utilities.cpp" -#endif diff --git a/src/Misc/Utilities.h b/src/Misc/Utilities.h index 1f96a516..28cd02ab 100644 --- a/src/Misc/Utilities.h +++ b/src/Misc/Utilities.h @@ -31,16 +31,16 @@ namespace Misc /** * @brief The Utilities class * - * The @c Utilitities module provides commonly used functionality to the rest of the - * application. For example, showing a messagebox with a nice format or revealing files in - * the operating system's preffered file manager. + * The @c Utilitities module provides commonly used functionality to the rest of + * the application. For example, showing a messagebox with a nice format or + * revealing files in the operating system's preffered file manager. */ class Utilities : public QObject { - Q_OBJECT + Q_OBJECT public: - // clang-format off + // clang-format off static Utilities &instance(); static void rebootApplication(); Q_INVOKABLE bool askAutomaticUpdates(); diff --git a/src/Plugins/Server.cpp b/src/Plugins/Server.cpp index 3fb0c371..37d5172b 100644 --- a/src/Plugins/Server.cpp +++ b/src/Plugins/Server.cpp @@ -34,9 +34,9 @@ * Constructor function */ Plugins::Server::Server() - : m_enabled(false) + : m_enabled(false) { - // clang-format off + // clang-format off // Send processed data at 1 Hz connect(&JSON::Generator::instance(), &JSON::Generator::jsonChanged, @@ -52,15 +52,15 @@ Plugins::Server::Server() connect(&m_server, &QTcpServer::newConnection, this, &Plugins::Server::acceptConnection); - // clang-format on + // clang-format on - // Begin listening on TCP port - if (!m_server.listen(QHostAddress::Any, PLUGINS_TCP_PORT)) - { - Misc::Utilities::showMessageBox(tr("Unable to start plugin TCP server"), - m_server.errorString()); - m_server.close(); - } + // Begin listening on TCP port + if (!m_server.listen(QHostAddress::Any, PLUGINS_TCP_PORT)) + { + Misc::Utilities::showMessageBox(tr("Unable to start plugin TCP server"), + m_server.errorString()); + m_server.close(); + } } /** @@ -68,7 +68,7 @@ Plugins::Server::Server() */ Plugins::Server::~Server() { - m_server.close(); + m_server.close(); } /** @@ -76,8 +76,8 @@ Plugins::Server::~Server() */ Plugins::Server &Plugins::Server::instance() { - static Server singleton; - return singleton; + static Server singleton; + return singleton; } /** @@ -85,7 +85,7 @@ Plugins::Server &Plugins::Server::instance() */ bool Plugins::Server::enabled() const { - return m_enabled; + return m_enabled; } /** @@ -93,24 +93,24 @@ bool Plugins::Server::enabled() const */ void Plugins::Server::removeConnection() { - // Get caller socket - auto socket = static_cast(QObject::sender()); + // Get caller socket + auto socket = static_cast(QObject::sender()); - // Remove socket from registered sockets - if (socket) + // Remove socket from registered sockets + if (socket) + { + for (int i = 0; i < m_sockets.count(); ++i) { - for (int i = 0; i < m_sockets.count(); ++i) - { - if (m_sockets.at(i) == socket) - { - m_sockets.removeAt(i); - i = 0; - } - } - - // Delete socket handler - socket->deleteLater(); + if (m_sockets.at(i) == socket) + { + m_sockets.removeAt(i); + i = 0; + } } + + // Delete socket handler + socket->deleteLater(); + } } /** @@ -118,29 +118,29 @@ void Plugins::Server::removeConnection() */ void Plugins::Server::setEnabled(const bool enabled) { - // Change value - m_enabled = enabled; - Q_EMIT enabledChanged(); + // Change value + m_enabled = enabled; + Q_EMIT enabledChanged(); - // If not enabled, remove all connections - if (!enabled) + // If not enabled, remove all connections + if (!enabled) + { + for (int i = 0; i < m_sockets.count(); ++i) { - for (int i = 0; i < m_sockets.count(); ++i) - { - auto socket = m_sockets.at(i); + auto socket = m_sockets.at(i); - if (socket) - { - socket->abort(); - socket->deleteLater(); - } - } - - m_sockets.clear(); + if (socket) + { + socket->abort(); + socket->deleteLater(); + } } - // Clear frames array to avoid memory leaks - m_frames.clear(); + m_sockets.clear(); + } + + // Clear frames array to avoid memory leaks + m_frames.clear(); } /** @@ -148,12 +148,12 @@ void Plugins::Server::setEnabled(const bool enabled) */ void Plugins::Server::onDataReceived() { - // Get caller socket - auto socket = static_cast(QObject::sender()); + // Get caller socket + auto socket = static_cast(QObject::sender()); - // Write incoming data to manager - if (enabled() && socket) - IO::Manager::instance().writeData(socket->readAll()); + // Write incoming data to manager + if (enabled() && socket) + IO::Manager::instance().writeData(socket->readAll()); } /** @@ -161,33 +161,35 @@ void Plugins::Server::onDataReceived() */ void Plugins::Server::acceptConnection() { - // Get & validate socket - auto socket = m_server.nextPendingConnection(); - if (!socket && enabled()) + // Get & validate socket + auto socket = m_server.nextPendingConnection(); + if (!socket && enabled()) + { + Misc::Utilities::showMessageBox(tr("Plugin server"), + tr("Invalid pending connection")); + return; + } + + // Close connection if system is not enabled + if (!enabled()) + { + if (socket) { - Misc::Utilities::showMessageBox(tr("Plugin server"), - tr("Invalid pending connection")); - return; + socket->close(); + socket->deleteLater(); } - // Close connection if system is not enabled - if (!enabled()) - { - if (socket) - { - socket->close(); - socket->deleteLater(); - } + return; + } - return; - } + // Connect socket signals/slots + connect(socket, &QTcpSocket::readyRead, this, + &Plugins::Server::onDataReceived); + connect(socket, &QTcpSocket::disconnected, this, + &Plugins::Server::removeConnection); - // Connect socket signals/slots - connect(socket, &QTcpSocket::readyRead, this, &Plugins::Server::onDataReceived); - connect(socket, &QTcpSocket::disconnected, this, &Plugins::Server::removeConnection); - - // React to socket errors - // clang-format off + // React to socket errors + // clang-format off #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onErrorOccurred(QAbstractSocket::SocketError))); @@ -195,10 +197,10 @@ void Plugins::Server::acceptConnection() connect(socket, &QTcpSocket::errorOccurred, this, &Plugins::Server::onErrorOccurred); #endif - // clang-format on + // clang-format on - // Add socket to sockets list - m_sockets.append(socket); + // Add socket to sockets list + m_sockets.append(socket); } /** @@ -209,111 +211,108 @@ void Plugins::Server::acceptConnection() */ void Plugins::Server::sendProcessedData() { - // Stop if system is not enabled - if (!enabled()) - return; + // Stop if system is not enabled + if (!enabled()) + return; - // Stop if frame list is empty - if (m_frames.count() <= 0) - return; + // Stop if frame list is empty + if (m_frames.count() <= 0) + return; - // Stop if no sockets are available - if (m_sockets.count() < 1) - return; + // Stop if no sockets are available + if (m_sockets.count() < 1) + return; - // Create JSON array with frame data - QJsonArray array; - for (int i = 0; i < m_frames.count(); ++i) - { - QJsonObject object; - auto frame = m_frames.at(i); - object.insert("data", frame); - array.append(object); - } - - // Create JSON document with frame arrays - if (array.count() > 0) - { - // Construct QByteArray with data - QJsonObject object; - object.insert("frames", array); - const QJsonDocument document(object); - auto json = document.toJson(QJsonDocument::Compact) + "\n"; - - // Send data to each plugin - Q_FOREACH (auto socket, m_sockets) - { - if (!socket) - continue; - - if (socket->isWritable()) - socket->write(json); - } - } - - // Clear frame list - m_frames.clear(); -} - -/** - * Encodes the given @a data in Base64 and sends it through the TCP socket connected - * to the localhost. - */ -void Plugins::Server::sendRawData(const QByteArray &data) -{ - // Stop if system is not enabled - if (!enabled()) - return; - - // Stop if no sockets are available - if (m_sockets.count() < 1) - return; - - // Create JSON structure with incoming data encoded in Base-64 + // Create JSON array with frame data + QJsonArray array; + for (int i = 0; i < m_frames.count(); ++i) + { QJsonObject object; - object.insert("data", QString::fromUtf8(data.toBase64())); + auto frame = m_frames.at(i); + object.insert("data", frame); + array.append(object); + } - // Get JSON string in compact format & send it over the TCP socket - QJsonDocument document(object); + // Create JSON document with frame arrays + if (array.count() > 0) + { + // Construct QByteArray with data + QJsonObject object; + object.insert("frames", array); + const QJsonDocument document(object); auto json = document.toJson(QJsonDocument::Compact) + "\n"; // Send data to each plugin Q_FOREACH (auto socket, m_sockets) { - if (!socket) - continue; + if (!socket) + continue; - if (socket->isWritable()) - socket->write(json); + if (socket->isWritable()) + socket->write(json); } + } + + // Clear frame list + m_frames.clear(); } /** - * Obtains the latest JSON dataframe & appends it to the JSON list, which is later read - * and sent by the @c sendProcessedData() function. + * Encodes the given @a data in Base64 and sends it through the TCP socket + * connected to the localhost. + */ +void Plugins::Server::sendRawData(const QByteArray &data) +{ + // Stop if system is not enabled + if (!enabled()) + return; + + // Stop if no sockets are available + if (m_sockets.count() < 1) + return; + + // Create JSON structure with incoming data encoded in Base-64 + QJsonObject object; + object.insert("data", QString::fromUtf8(data.toBase64())); + + // Get JSON string in compact format & send it over the TCP socket + QJsonDocument document(object); + auto json = document.toJson(QJsonDocument::Compact) + "\n"; + + // Send data to each plugin + Q_FOREACH (auto socket, m_sockets) + { + if (!socket) + continue; + + if (socket->isWritable()) + socket->write(json); + } +} + +/** + * Obtains the latest JSON dataframe & appends it to the JSON list, which is + * later read and sent by the @c sendProcessedData() function. */ void Plugins::Server::registerFrame(const QJsonObject &json) { - if (enabled()) - m_frames.append(json); + if (enabled()) + m_frames.append(json); } /** - * This function is called whenever a socket error occurs, it disconnects the socket - * from the host and displays the error in a message box. + * This function is called whenever a socket error occurs, it disconnects the + * socket from the host and displays the error in a message box. */ -void Plugins::Server::onErrorOccurred(const QAbstractSocket::SocketError socketError) +void Plugins::Server::onErrorOccurred( + const QAbstractSocket::SocketError socketError) { - // Get caller socket - auto socket = static_cast(QObject::sender()); + // Get caller socket + auto socket = static_cast(QObject::sender()); - // Print error - if (socket) - qDebug() << socket->errorString(); - else - qDebug() << socketError; + // Print error + if (socket) + qDebug() << socket->errorString(); + else + qDebug() << socketError; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Server.cpp" -#endif diff --git a/src/Plugins/Server.h b/src/Plugins/Server.h index e3c1fdf1..da2d3d2a 100644 --- a/src/Plugins/Server.h +++ b/src/Plugins/Server.h @@ -32,8 +32,8 @@ #include /** - * Default TCP port to use for incoming connections, I choose 7777 because 7 is one of - * my favourite numbers :) + * Default TCP port to use for incoming connections, I choose 7777 because 7 is + * one of my favourite numbers :) */ #define PLUGINS_TCP_PORT 7777 @@ -42,55 +42,55 @@ namespace Plugins /** * @brief The Server class * - * Implements a simple TCP server on port 7777, which allows Serial Studio to interact - * with other applications on the computer or in the LAN. "Plugins" receive incoming - * frames processed by Serial Studio, and can write data to the device by simply writting - * data on the TCP socket. + * Implements a simple TCP server on port 7777, which allows Serial Studio to + * interact with other applications on the computer or in the LAN. "Plugins" + * receive incoming frames processed by Serial Studio, and can write data to the + * device by simply writting data on the TCP socket. * * An example of such application can be found at: * https://github.com/Kaan-Sat/CC2021-Control-Panel * - * A benefit of implementing plugins in this manner is that you can write your Serial - * Studio companion application in any language and framework that you desire, you do not - * have to force yourself to use Qt or C/C++. + * A benefit of implementing plugins in this manner is that you can write your + * Serial Studio companion application in any language and framework that you + * desire, you do not have to force yourself to use Qt or C/C++. */ class Server : public QObject { - Q_OBJECT - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_OBJECT + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_SIGNALS: - void enabledChanged(); + void enabledChanged(); private: - explicit Server(); - Server(Server &&) = delete; - Server(const Server &) = delete; - Server &operator=(Server &&) = delete; - Server &operator=(const Server &) = delete; + explicit Server(); + Server(Server &&) = delete; + Server(const Server &) = delete; + Server &operator=(Server &&) = delete; + Server &operator=(const Server &) = delete; - ~Server(); + ~Server(); public: - static Server &instance(); - bool enabled() const; + static Server &instance(); + bool enabled() const; public Q_SLOTS: - void removeConnection(); - void setEnabled(const bool enabled); + void removeConnection(); + void setEnabled(const bool enabled); private Q_SLOTS: - void onDataReceived(); - void acceptConnection(); - void sendProcessedData(); - void sendRawData(const QByteArray &data); - void registerFrame(const QJsonObject &json); - void onErrorOccurred(const QAbstractSocket::SocketError socketError); + void onDataReceived(); + void acceptConnection(); + void sendProcessedData(); + void sendRawData(const QByteArray &data); + void registerFrame(const QJsonObject &json); + void onErrorOccurred(const QAbstractSocket::SocketError socketError); private: - bool m_enabled; - QTcpServer m_server; - QVector m_frames; - QVector m_sockets; + bool m_enabled; + QTcpServer m_server; + QVector m_frames; + QVector m_sockets; }; -} +} // namespace Plugins diff --git a/src/Project/CodeEditor.cpp b/src/Project/CodeEditor.cpp index f16a733b..e5e2c219 100644 --- a/src/Project/CodeEditor.cpp +++ b/src/Project/CodeEditor.cpp @@ -31,304 +31,313 @@ Project::CodeEditor::CodeEditor() { - // Setup syntax highlighter - m_highlighter = new QSourceHighlite::QSourceHighliter(m_textEdit.document()); - m_highlighter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeJs); + // Setup syntax highlighter + m_highlighter = new QSourceHighlite::QSourceHighliter(m_textEdit.document()); + m_highlighter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeJs); - // Setup text editor - onNewClicked(); - m_textEdit.setFont(QFont("Roboto Mono")); + // Setup text editor + onNewClicked(); + m_textEdit.setFont(QFont("Roboto Mono")); - // Setup toolbar - auto acNew = m_toolbar.addAction(QIcon(":/icons/template.svg"), tr("New")); - auto acOpen = m_toolbar.addAction(QIcon(":/icons/open.svg"), tr("Open")); - auto acSave = m_toolbar.addAction(QIcon(":/icons/save.svg"), tr("Save")); - m_toolbar.addSeparator(); - auto acUndo = m_toolbar.addAction(QIcon(":/icons/undo.svg"), tr("Undo")); - auto acRedo = m_toolbar.addAction(QIcon(":/icons/redo.svg"), tr("Redo")); - m_toolbar.addSeparator(); - auto acCut = m_toolbar.addAction(QIcon(":/icons/cut.svg"), tr("Cut")); - auto acCopy = m_toolbar.addAction(QIcon(":/icons/copy.svg"), tr("Copy")); - auto acPaste = m_toolbar.addAction(QIcon(":/icons/paste.svg"), tr("Paste")); - m_toolbar.addSeparator(); - auto acHelp = m_toolbar.addAction(QIcon(":/icons/help.svg"), tr("Help")); + // Setup toolbar + auto acNew = m_toolbar.addAction(QIcon(":/icons/template.svg"), tr("New")); + auto acOpen = m_toolbar.addAction(QIcon(":/icons/open.svg"), tr("Open")); + auto acSave = m_toolbar.addAction(QIcon(":/icons/save.svg"), tr("Save")); + m_toolbar.addSeparator(); + auto acUndo = m_toolbar.addAction(QIcon(":/icons/undo.svg"), tr("Undo")); + auto acRedo = m_toolbar.addAction(QIcon(":/icons/redo.svg"), tr("Redo")); + m_toolbar.addSeparator(); + auto acCut = m_toolbar.addAction(QIcon(":/icons/cut.svg"), tr("Cut")); + auto acCopy = m_toolbar.addAction(QIcon(":/icons/copy.svg"), tr("Copy")); + auto acPaste = m_toolbar.addAction(QIcon(":/icons/paste.svg"), tr("Paste")); + m_toolbar.addSeparator(); + auto acHelp = m_toolbar.addAction(QIcon(":/icons/help.svg"), tr("Help")); - // Connect action signals/slots - connect(acUndo, &QAction::triggered, &m_textEdit, &QPlainTextEdit::undo); - connect(acRedo, &QAction::triggered, &m_textEdit, &QPlainTextEdit::redo); - connect(acCut, &QAction::triggered, &m_textEdit, &QPlainTextEdit::cut); - connect(acCopy, &QAction::triggered, &m_textEdit, &QPlainTextEdit::copy); - connect(acPaste, &QAction::triggered, &m_textEdit, &QPlainTextEdit::paste); - connect(acNew, &QAction::triggered, this, &Project::CodeEditor::onNewClicked); - connect(acNew, &QAction::triggered, this, &Project::CodeEditor::onNewClicked); - connect(acOpen, &QAction::triggered, this, &Project::CodeEditor::onOpenClicked); - connect(acSave, &QAction::triggered, this, &Project::CodeEditor::onSaveClicked); - connect(acHelp, &QAction::triggered, this, &Project::CodeEditor::onHelpClicked); + // Connect action signals/slots + connect(acUndo, &QAction::triggered, &m_textEdit, &QPlainTextEdit::undo); + connect(acRedo, &QAction::triggered, &m_textEdit, &QPlainTextEdit::redo); + connect(acCut, &QAction::triggered, &m_textEdit, &QPlainTextEdit::cut); + connect(acCopy, &QAction::triggered, &m_textEdit, &QPlainTextEdit::copy); + connect(acPaste, &QAction::triggered, &m_textEdit, &QPlainTextEdit::paste); + connect(acNew, &QAction::triggered, this, &Project::CodeEditor::onNewClicked); + connect(acNew, &QAction::triggered, this, &Project::CodeEditor::onNewClicked); + connect(acOpen, &QAction::triggered, this, + &Project::CodeEditor::onOpenClicked); + connect(acSave, &QAction::triggered, this, + &Project::CodeEditor::onSaveClicked); + connect(acHelp, &QAction::triggered, this, + &Project::CodeEditor::onHelpClicked); - // Set widget palette - QPalette palette; - auto theme = &Misc::ThemeManager::instance(); - palette.setColor(QPalette::Text, theme->consoleText()); - palette.setColor(QPalette::Base, theme->consoleBase()); - palette.setColor(QPalette::Button, theme->consoleButton()); - palette.setColor(QPalette::Window, theme->consoleWindow()); - palette.setColor(QPalette::Highlight, theme->consoleHighlight()); - palette.setColor(QPalette::HighlightedText, theme->consoleHighlightedText()); + // Set widget palette + QPalette palette; + auto theme = &Misc::ThemeManager::instance(); + palette.setColor(QPalette::Text, theme->consoleText()); + palette.setColor(QPalette::Base, theme->consoleBase()); + palette.setColor(QPalette::Button, theme->consoleButton()); + palette.setColor(QPalette::Window, theme->consoleWindow()); + palette.setColor(QPalette::Highlight, theme->consoleHighlight()); + palette.setColor(QPalette::HighlightedText, theme->consoleHighlightedText()); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - palette.setColor(QPalette::PlaceholderText, theme->consolePlaceholderText()); + palette.setColor(QPalette::PlaceholderText, theme->consolePlaceholderText()); #endif - setPalette(palette); + setPalette(palette); - // Setup layout - auto layout = new QVBoxLayout(this); - layout->addWidget(&m_toolbar); - layout->addWidget(&m_textEdit); - layout->setStretch(0, 0); - layout->setStretch(1, 1); - layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); - setLayout(layout); + // Setup layout + auto layout = new QVBoxLayout(this); + layout->addWidget(&m_toolbar); + layout->addWidget(&m_textEdit); + layout->setStretch(0, 0); + layout->setStretch(1, 1); + layout->setSpacing(0); + layout->setContentsMargins(0, 0, 0, 0); + setLayout(layout); - // Setup window - setMinimumSize(QSize(640, 480)); - setWindowTitle(tr("Customize frame parser")); + // Setup window + setMinimumSize(QSize(640, 480)); + setWindowTitle(tr("Customize frame parser")); - // Load code from JSON model automatically - connect(&Project::Model::instance(), &Model::frameParserCodeChanged, this, - &Project::CodeEditor::readCode); + // Load code from JSON model automatically + connect(&Project::Model::instance(), &Model::frameParserCodeChanged, this, + &Project::CodeEditor::readCode); } -Project::CodeEditor::~CodeEditor() { } +Project::CodeEditor::~CodeEditor() {} Project::CodeEditor &Project::CodeEditor::instance() { - static CodeEditor instance; - return instance; + static CodeEditor instance; + return instance; } QString Project::CodeEditor::defaultCode() const { - QString code; - QFile file(":/scripts/frame-parser.js"); - if (file.open(QFile::ReadOnly)) - { - code = QString::fromUtf8(file.readAll()); - file.close(); - } + QString code; + QFile file(":/scripts/frame-parser.js"); + if (file.open(QFile::ReadOnly)) + { + code = QString::fromUtf8(file.readAll()); + file.close(); + } - return code; + return code; } -QStringList Project::CodeEditor::parse(const QString &frame, const QString &separator) +QStringList Project::CodeEditor::parse(const QString &frame, + const QString &separator) { - // Construct function arguments - QJSValueList args; - args << frame << separator; + // Construct function arguments + QJSValueList args; + args << frame << separator; - // Evaluate frame parsing function - auto out = m_parseFunction.call(args).toVariant().toList(); + // Evaluate frame parsing function + auto out = m_parseFunction.call(args).toVariant().toList(); - // Convert output to QStringList - QStringList list; - for (auto i = 0; i < out.count(); ++i) - list.append(out.at(i).toString()); + // Convert output to QStringList + QStringList list; + for (auto i = 0; i < out.count(); ++i) + list.append(out.at(i).toString()); - // Return fields list - return list; + // Return fields list + return list; } void Project::CodeEditor::displayWindow() { - showNormal(); + showNormal(); } void Project::CodeEditor::onNewClicked() { - // Document has been modified, ask user if he/she wants to continue - if (m_textEdit.document()->isModified()) - { - auto ret = Misc::Utilities::showMessageBox( - tr("The document has been modified!"), - tr("Are you sure you want to continue?"), qAppName(), - QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::No) - return; - } + // Document has been modified, ask user if he/she wants to continue + if (m_textEdit.document()->isModified()) + { + auto ret = Misc::Utilities::showMessageBox( + tr("The document has been modified!"), + tr("Are you sure you want to continue?"), qAppName(), + QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::No) + return; + } - // Load default template - m_textEdit.setPlainText(defaultCode()); - save(true); + // Load default template + m_textEdit.setPlainText(defaultCode()); + save(true); } void Project::CodeEditor::onOpenClicked() { - // Document has been modified, ask user if he/she wants to continue - if (m_textEdit.document()->isModified()) - { - auto ret = Misc::Utilities::showMessageBox( - tr("The document has been modified!"), - tr("Are you sure you want to continue?"), qAppName(), - QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::No) - return; - } + // Document has been modified, ask user if he/she wants to continue + if (m_textEdit.document()->isModified()) + { + auto ret = Misc::Utilities::showMessageBox( + tr("The document has been modified!"), + tr("Are you sure you want to continue?"), qAppName(), + QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::No) + return; + } - // Get file from system - auto path = QFileDialog::getOpenFileName( - Q_NULLPTR, tr("Select Javascript file to import"), QDir::homePath(), "*.js"); + // Get file from system + auto path = QFileDialog::getOpenFileName( + Q_NULLPTR, tr("Select Javascript file to import"), QDir::homePath(), + "*.js"); - // Load file into code editor - if (!path.isEmpty()) + // Load file into code editor + if (!path.isEmpty()) + { + QFile file(path); + if (file.open(QFile::ReadOnly)) { - QFile file(path); - if (file.open(QFile::ReadOnly)) - { - auto data = file.readAll(); - m_textEdit.setPlainText(QString::fromUtf8(data)); - save(true); - } + auto data = file.readAll(); + m_textEdit.setPlainText(QString::fromUtf8(data)); + save(true); } + } } void Project::CodeEditor::onSaveClicked() { - if (save(false)) - close(); + if (save(false)) + close(); } -void Project::CodeEditor::onHelpClicked() { } +void Project::CodeEditor::onHelpClicked() {} bool Project::CodeEditor::save(const bool silent) { - // Update text edit - if (loadScript(m_textEdit.toPlainText())) - { - m_textEdit.document()->setModified(false); + // Update text edit + if (loadScript(m_textEdit.toPlainText())) + { + m_textEdit.document()->setModified(false); - // Save code inside JSON project - QTimer::singleShot(500, this, SLOT(writeChanges())); + // Save code inside JSON project + QTimer::singleShot(500, this, SLOT(writeChanges())); - // Show save messagebox - if (!silent) - Misc::Utilities::showMessageBox( - tr("Frame parser code updated successfully!"), - tr("No errors have been detected in the code.")); + // Show save messagebox + if (!silent) + Misc::Utilities::showMessageBox( + tr("Frame parser code updated successfully!"), + tr("No errors have been detected in the code.")); - // Everything good - return true; - } + // Everything good + return true; + } - // Something did not work quite right - return false; + // Something did not work quite right + return false; } bool Project::CodeEditor::loadScript(const QString &script) { - // Check if there are no general JS errors - QStringList errors; - m_engine.evaluate(script, "", 1, &errors); + // Check if there are no general JS errors + QStringList errors; + m_engine.evaluate(script, "", 1, &errors); - // Check if parse() function exists - auto fun = m_engine.globalObject().property("parse"); - if (fun.isNull() || !fun.isCallable()) + // Check if parse() function exists + auto fun = m_engine.globalObject().property("parse"); + if (fun.isNull() || !fun.isCallable()) + { + Misc::Utilities::showMessageBox( + tr("Frame parser error!"), + tr("No parse() function has been declared!")); + return false; + } + + // Try to run parse() function + QJSValueList args = {"", ","}; + auto ret = fun.call(args); + + // Error on engine evaluation + if (!errors.isEmpty()) + { + Misc::Utilities::showMessageBox( + tr("Frame parser syntax error!"), + tr("Error on line %1.").arg(errors.first())); + return false; + } + + // Error on function execution + else if (ret.isError()) + { + QString errorStr; + switch (ret.errorType()) { - Misc::Utilities::showMessageBox(tr("Frame parser error!"), - tr("No parse() function has been declared!")); - return false; + case QJSValue::GenericError: + errorStr = tr("Generic error"); + break; + case QJSValue::EvalError: + errorStr = tr("Evaluation error"); + break; + case QJSValue::RangeError: + errorStr = tr("Range error"); + break; + case QJSValue::ReferenceError: + errorStr = tr("Reference error"); + break; + case QJSValue::SyntaxError: + errorStr = tr("Syntax error"); + break; + case QJSValue::TypeError: + errorStr = tr("Type error"); + break; + case QJSValue::URIError: + errorStr = tr("URI error"); + break; + default: + errorStr = tr("Unknown error"); + break; } - // Try to run parse() function - QJSValueList args = { "", "," }; - auto ret = fun.call(args); + Misc::Utilities::showMessageBox(tr("Frame parser error detected!"), + errorStr); + return false; + } - // Error on engine evaluation - if (!errors.isEmpty()) - { - Misc::Utilities::showMessageBox(tr("Frame parser syntax error!"), - tr("Error on line %1.").arg(errors.first())); - return false; - } - - // Error on function execution - else if (ret.isError()) - { - QString errorStr; - switch (ret.errorType()) - { - case QJSValue::GenericError: - errorStr = tr("Generic error"); - break; - case QJSValue::EvalError: - errorStr = tr("Evaluation error"); - break; - case QJSValue::RangeError: - errorStr = tr("Range error"); - break; - case QJSValue::ReferenceError: - errorStr = tr("Reference error"); - break; - case QJSValue::SyntaxError: - errorStr = tr("Syntax error"); - break; - case QJSValue::TypeError: - errorStr = tr("Type error"); - break; - case QJSValue::URIError: - errorStr = tr("URI error"); - break; - default: - errorStr = tr("Unknown error"); - break; - } - - Misc::Utilities::showMessageBox(tr("Frame parser error detected!"), errorStr); - return false; - } - - // We have reached this point without any errors, set function caller - m_parseFunction = fun; - return true; + // We have reached this point without any errors, set function caller + m_parseFunction = fun; + return true; } void Project::CodeEditor::closeEvent(QCloseEvent *event) { - if (m_textEdit.document()->isModified()) + if (m_textEdit.document()->isModified()) + { + // Ask user if he/she wants to save changes + auto ret = Misc::Utilities::showMessageBox( + tr("The document has been modified!"), + tr("Do you want to save the changes?"), qAppName(), + QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel); + + // User wants to save changes, validate code & apply + if (ret == QMessageBox::Yes) { - // Ask user if he/she wants to save changes - auto ret = Misc::Utilities::showMessageBox( - tr("The document has been modified!"), tr("Do you want to save the changes?"), - qAppName(), QMessageBox::Yes | QMessageBox::Discard | QMessageBox::Cancel); - - // User wants to save changes, validate code & apply - if (ret == QMessageBox::Yes) - { - if (!save(true)) - { - event->ignore(); - return; - } - } - - // User wants to continue editing the code - if (ret == QMessageBox::Cancel) - { - event->ignore(); - return; - } + if (!save(true)) + { + event->ignore(); + return; + } } - // User saved changes (with no errors) or discarded the changes - event->accept(); + // User wants to continue editing the code + if (ret == QMessageBox::Cancel) + { + event->ignore(); + return; + } + } + + // User saved changes (with no errors) or discarded the changes + event->accept(); } void Project::CodeEditor::readCode() { - m_textEdit.setPlainText(Model::instance().frameParserCode()); - m_textEdit.document()->setModified(false); - loadScript(m_textEdit.toPlainText()); + m_textEdit.setPlainText(Model::instance().frameParserCode()); + m_textEdit.document()->setModified(false); + loadScript(m_textEdit.toPlainText()); } void Project::CodeEditor::writeChanges() { - Model::instance().setFrameParserCode(m_textEdit.toPlainText()); + Model::instance().setFrameParserCode(m_textEdit.toPlainText()); } diff --git a/src/Project/CodeEditor.h b/src/Project/CodeEditor.h index 159e5070..97d8371e 100644 --- a/src/Project/CodeEditor.h +++ b/src/Project/CodeEditor.h @@ -39,45 +39,45 @@ namespace Project { class CodeEditor : public QDialog { - Q_OBJECT + Q_OBJECT private: - explicit CodeEditor(); - ~CodeEditor(); - CodeEditor(CodeEditor &&) = delete; - CodeEditor(const CodeEditor &) = delete; - CodeEditor &operator=(CodeEditor &&) = delete; - CodeEditor &operator=(const CodeEditor &) = delete; + explicit CodeEditor(); + ~CodeEditor(); + CodeEditor(CodeEditor &&) = delete; + CodeEditor(const CodeEditor &) = delete; + CodeEditor &operator=(CodeEditor &&) = delete; + CodeEditor &operator=(const CodeEditor &) = delete; public: - static CodeEditor &instance(); - QString defaultCode() const; - QStringList parse(const QString &frame, const QString &separator); + static CodeEditor &instance(); + QString defaultCode() const; + QStringList parse(const QString &frame, const QString &separator); public Q_SLOTS: - void displayWindow(); + void displayWindow(); private Q_SLOTS: - void onNewClicked(); - void onOpenClicked(); - void onSaveClicked(); - void onHelpClicked(); + void onNewClicked(); + void onOpenClicked(); + void onSaveClicked(); + void onHelpClicked(); private: - bool checkModified(); - bool save(const bool silent = false); - bool loadScript(const QString &script); - void closeEvent(QCloseEvent *event) override; + bool checkModified(); + bool save(const bool silent = false); + bool loadScript(const QString &script); + void closeEvent(QCloseEvent *event) override; private slots: - void readCode(); - void writeChanges(); + void readCode(); + void writeChanges(); private: - QJSEngine m_engine; - QToolBar m_toolbar; - QJSValue m_parseFunction; - QPlainTextEdit m_textEdit; - QSourceHighlite::QSourceHighliter *m_highlighter; + QJSEngine m_engine; + QToolBar m_toolbar; + QJSValue m_parseFunction; + QPlainTextEdit m_textEdit; + QSourceHighlite::QSourceHighliter *m_highlighter; }; -} +} // namespace Project diff --git a/src/Project/Model.cpp b/src/Project/Model.cpp index 5d55da7a..c491507b 100644 --- a/src/Project/Model.cpp +++ b/src/Project/Model.cpp @@ -36,8 +36,8 @@ #include // -// For invalid group returns, avoids crashes while creating a new project & the UI -// is in the process of being updated +// For invalid group returns, avoids crashes while creating a new project & the +// UI is in the process of being updated // static JSON::Group EMPTY_GROUP; @@ -46,21 +46,21 @@ static JSON::Group EMPTY_GROUP; //---------------------------------------------------------------------------------------- /** - * Constructor function. Initializes internal members and configures the signals/slots so - * that the editor can know if the user modified the JSON document. Finally, the - * constructor configures signals/slots with the JSON Generator to share the same JSON - * document file. + * Constructor function. Initializes internal members and configures the + * signals/slots so that the editor can know if the user modified the JSON + * document. Finally, the constructor configures signals/slots with the JSON + * Generator to share the same JSON document file. */ Project::Model::Model() - : m_title("") - , m_separator("") - , m_frameParserCode("") - , m_frameEndSequence("") - , m_frameStartSequence("") - , m_modified(false) - , m_filePath("") + : m_title("") + , m_separator("") + , m_frameParserCode("") + , m_frameEndSequence("") + , m_frameStartSequence("") + , m_modified(false) + , m_filePath("") { - // clang-format off + // clang-format off // Connect signals/slots connect(this, &Project::Model::groupChanged, @@ -86,7 +86,7 @@ Project::Model::Model() connect(&JSON::Generator::instance(), &JSON::Generator::jsonFileMapChanged, this, &Project::Model::onJsonLoaded); - // clang-format on + // clang-format on } /** @@ -94,8 +94,8 @@ Project::Model::Model() */ Project::Model &Project::Model::instance() { - static Model singleton; - return singleton; + static Model singleton; + return singleton; } //---------------------------------------------------------------------------------------- @@ -103,23 +103,24 @@ Project::Model &Project::Model::instance() //---------------------------------------------------------------------------------------- /** - * Returns a list with the available group-level widgets. This list is used by the user - * interface to allow the user to build accelerometer, gyro & map widgets directly from - * the UI. + * Returns a list with the available group-level widgets. This list is used by + * the user interface to allow the user to build accelerometer, gyro & map + * widgets directly from the UI. */ StringList Project::Model::availableGroupLevelWidgets() { - return StringList { tr("Dataset widgets"), tr("Accelerometer"), tr("Gyroscope"), - tr("GPS"), tr("Multiple data plot") }; + return StringList{tr("Dataset widgets"), tr("Accelerometer"), tr("Gyroscope"), + tr("GPS"), tr("Multiple data plot")}; } /** - * Returns a list with the available dataset-level widgets. This list is used by the user - * interface to allow the user to build gauge, bar & compass widgets directly from the UI. + * Returns a list with the available dataset-level widgets. This list is used by + * the user interface to allow the user to build gauge, bar & compass widgets + * directly from the UI. */ StringList Project::Model::availableDatasetLevelWidgets() { - return StringList { tr("None"), tr("Gauge"), tr("Bar/level"), tr("Compass") }; + return StringList{tr("None"), tr("Gauge"), tr("Bar/level"), tr("Compass")}; } /** @@ -127,16 +128,16 @@ StringList Project::Model::availableDatasetLevelWidgets() */ QString Project::Model::jsonProjectsPath() const { - // Get file name and path - QString path = QString("%1/Documents/%2/JSON Projects/") - .arg(QDir::homePath(), qApp->applicationName()); + // Get file name and path + QString path = QString("%1/Documents/%2/JSON Projects/") + .arg(QDir::homePath(), qApp->applicationName()); - // Generate file path if required - QDir dir(path); - if (!dir.exists()) - dir.mkpath("."); + // Generate file path if required + QDir dir(path); + if (!dir.exists()) + dir.mkpath("."); - return path; + return path; } /** @@ -144,7 +145,7 @@ QString Project::Model::jsonProjectsPath() const */ QString Project::Model::title() const { - return m_title; + return m_title; } /** @@ -152,7 +153,7 @@ QString Project::Model::title() const */ QString Project::Model::separator() const { - return m_separator; + return m_separator; } /** @@ -160,7 +161,7 @@ QString Project::Model::separator() const */ QString Project::Model::frameEndSequence() const { - return m_frameEndSequence; + return m_frameEndSequence; } /** @@ -168,7 +169,7 @@ QString Project::Model::frameEndSequence() const */ QString Project::Model::frameStartSequence() const { - return m_frameStartSequence; + return m_frameStartSequence; } /** @@ -178,7 +179,7 @@ QString Project::Model::frameStartSequence() const */ bool Project::Model::modified() const { - return m_modified; + return m_modified; } /** @@ -186,7 +187,7 @@ bool Project::Model::modified() const */ int Project::Model::groupCount() const { - return m_groups.count(); + return m_groups.count(); } /** @@ -194,7 +195,7 @@ int Project::Model::groupCount() const */ QString Project::Model::jsonFilePath() const { - return m_filePath; + return m_filePath; } /** @@ -203,13 +204,13 @@ QString Project::Model::jsonFilePath() const */ QString Project::Model::jsonFileName() const { - if (!jsonFilePath().isEmpty()) - { - auto fileInfo = QFileInfo(m_filePath); - return fileInfo.fileName(); - } + if (!jsonFilePath().isEmpty()) + { + auto fileInfo = QFileInfo(m_filePath); + return fileInfo.fileName(); + } - return tr("New Project"); + return tr("New Project"); } /** @@ -218,21 +219,21 @@ QString Project::Model::jsonFileName() const */ bool Project::Model::askSave() { - if (!modified()) - return true; + if (!modified()) + return true; - auto ret = Misc::Utilities::showMessageBox( - tr("Do you want to save your changes?"), - tr("You have unsaved modifications in this project!"), APP_NAME, - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + auto ret = Misc::Utilities::showMessageBox( + tr("Do you want to save your changes?"), + tr("You have unsaved modifications in this project!"), APP_NAME, + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - if (ret == QMessageBox::Cancel) - return false; + if (ret == QMessageBox::Cancel) + return false; - if (ret == QMessageBox::Discard) - return true; + if (ret == QMessageBox::Discard) + return true; - return saveJsonFile(); + return saveJsonFile(); } /** @@ -241,138 +242,138 @@ bool Project::Model::askSave() */ bool Project::Model::saveJsonFile() { - // Validate project title - if (title().isEmpty()) + // Validate project title + if (title().isEmpty()) + { + Misc::Utilities::showMessageBox(tr("Project error"), + tr("Project title cannot be empty!")); + return false; + } + + // Validate group titles + for (int i = 0; i < groupCount(); ++i) + { + if (groupTitle(i).isEmpty()) { - Misc::Utilities::showMessageBox(tr("Project error"), - tr("Project title cannot be empty!")); + Misc::Utilities::showMessageBox(tr("Project error - Group %1").arg(i + 1), + tr("Group title cannot be empty!")); + return false; + } + } + + // Validate dataset titles + for (int i = 0; i < groupCount(); ++i) + { + for (int j = 0; j < datasetCount(i); ++j) + { + if (datasetTitle(i, j).isEmpty()) + { + Misc::Utilities::showMessageBox( + tr("Project error - Group %1, Dataset %2").arg(i + 1).arg(j + 1), + tr("Dataset title cannot be empty!")); return false; + } } + } - // Validate group titles - for (int i = 0; i < groupCount(); ++i) + // Validate dataset indexes + QVector indexes; + for (int i = 0; i < groupCount(); ++i) + { + for (int j = 0; j < datasetCount(i); ++j) { - if (groupTitle(i).isEmpty()) - { - Misc::Utilities::showMessageBox(tr("Project error - Group %1").arg(i + 1), - tr("Group title cannot be empty!")); - return false; - } - } + if (!indexes.contains(datasetIndex(i, j))) + indexes.append(datasetIndex(i, j)); - // Validate dataset titles - for (int i = 0; i < groupCount(); ++i) + else + { + auto ret = Misc::Utilities::showMessageBox( + tr("Warning - Group %1, Dataset %2").arg(i + 1).arg(j + 1), + tr("Dataset contains duplicate frame index position! Continue?"), + APP_NAME, QMessageBox::Yes | QMessageBox::No); + + if (ret == QMessageBox::No) + return false; + } + } + } + + // Get file save path + if (jsonFilePath().isEmpty()) + { + auto path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save JSON project"), + jsonProjectsPath(), "*.json"); + if (path.isEmpty()) + return false; + + m_filePath = path; + } + + // Open file for writing + QFile file(m_filePath); + if (!file.open(QFile::WriteOnly)) + { + Misc::Utilities::showMessageBox(tr("File open error"), file.errorString()); + return false; + } + + // Create JSON document & add properties + QJsonObject json; + json.insert("title", title()); + json.insert("separator", separator()); + json.insert("frameEnd", frameEndSequence()); + json.insert("frameParser", frameParserCode()); + json.insert("frameStart", frameStartSequence()); + + // Create group array + QJsonArray groups; + for (int i = 0; i < groupCount(); ++i) + { + // Create group + QJsonObject group; + group.insert("title", groupTitle(i)); + group.insert("widget", groupWidget(i)); + + // Create dataset array + QJsonArray datasets; + for (int j = 0; j < datasetCount(i); ++j) { - for (int j = 0; j < datasetCount(i); ++j) - { - if (datasetTitle(i, j).isEmpty()) - { - Misc::Utilities::showMessageBox( - tr("Project error - Group %1, Dataset %2").arg(i + 1).arg(j + 1), - tr("Dataset title cannot be empty!")); - return false; - } - } + // Create dataset + QJsonObject dataset; + dataset.insert("led", datasetLED(i, j)); + dataset.insert("fft", datasetFftPlot(i, j)); + dataset.insert("log", datasetLogPlot(i, j)); + dataset.insert("title", datasetTitle(i, j)); + dataset.insert("units", datasetUnits(i, j)); + dataset.insert("graph", datasetGraph(i, j)); + dataset.insert("widget", datasetWidget(i, j)); + dataset.insert("min", datasetWidgetMin(i, j).toDouble()); + dataset.insert("max", datasetWidgetMax(i, j).toDouble()); + dataset.insert("alarm", datasetWidgetAlarm(i, j).toDouble()); + dataset.insert("fftSamples", datasetFFTSamples(i, j).toInt()); + dataset.insert("index", datasetIndex(i, j)); + dataset.insert("value", ""); + + // Add dataset to array + datasets.append(dataset); } - // Validate dataset indexes - QVector indexes; - for (int i = 0; i < groupCount(); ++i) - { - for (int j = 0; j < datasetCount(i); ++j) - { - if (!indexes.contains(datasetIndex(i, j))) - indexes.append(datasetIndex(i, j)); + // Add datasets to group + group.insert("datasets", datasets); + groups.append(group); + } - else - { - auto ret = Misc::Utilities::showMessageBox( - tr("Warning - Group %1, Dataset %2").arg(i + 1).arg(j + 1), - tr("Dataset contains duplicate frame index position! Continue?"), - APP_NAME, QMessageBox::Yes | QMessageBox::No); + // Add groups array to JSON + json.insert("groups", groups); - if (ret == QMessageBox::No) - return false; - } - } - } + // Write JSON data to file + file.write(QJsonDocument(json).toJson(QJsonDocument::Indented)); + file.close(); - // Get file save path - if (jsonFilePath().isEmpty()) - { - auto path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save JSON project"), - jsonProjectsPath(), "*.json"); - if (path.isEmpty()) - return false; - - m_filePath = path; - } - - // Open file for writing - QFile file(m_filePath); - if (!file.open(QFile::WriteOnly)) - { - Misc::Utilities::showMessageBox(tr("File open error"), file.errorString()); - return false; - } - - // Create JSON document & add properties - QJsonObject json; - json.insert("title", title()); - json.insert("separator", separator()); - json.insert("frameEnd", frameEndSequence()); - json.insert("frameParser", frameParserCode()); - json.insert("frameStart", frameStartSequence()); - - // Create group array - QJsonArray groups; - for (int i = 0; i < groupCount(); ++i) - { - // Create group - QJsonObject group; - group.insert("title", groupTitle(i)); - group.insert("widget", groupWidget(i)); - - // Create dataset array - QJsonArray datasets; - for (int j = 0; j < datasetCount(i); ++j) - { - // Create dataset - QJsonObject dataset; - dataset.insert("led", datasetLED(i, j)); - dataset.insert("fft", datasetFftPlot(i, j)); - dataset.insert("log", datasetLogPlot(i, j)); - dataset.insert("title", datasetTitle(i, j)); - dataset.insert("units", datasetUnits(i, j)); - dataset.insert("graph", datasetGraph(i, j)); - dataset.insert("widget", datasetWidget(i, j)); - dataset.insert("min", datasetWidgetMin(i, j).toDouble()); - dataset.insert("max", datasetWidgetMax(i, j).toDouble()); - dataset.insert("alarm", datasetWidgetAlarm(i, j).toDouble()); - dataset.insert("fftSamples", datasetFFTSamples(i, j).toInt()); - dataset.insert("index", datasetIndex(i, j)); - dataset.insert("value", ""); - - // Add dataset to array - datasets.append(dataset); - } - - // Add datasets to group - group.insert("datasets", datasets); - groups.append(group); - } - - // Add groups array to JSON - json.insert("groups", groups); - - // Write JSON data to file - file.write(QJsonDocument(json).toJson(QJsonDocument::Indented)); - file.close(); - - // Load JSON file to Serial Studio - openJsonFile(file.fileName()); - JSON::Generator::instance().loadJsonMap(file.fileName()); - return true; + // Load JSON file to Serial Studio + openJsonFile(file.fileName()); + JSON::Generator::instance().loadJsonMap(file.fileName()); + return true; } /** @@ -380,7 +381,7 @@ bool Project::Model::saveJsonFile() */ int Project::Model::datasetCount(const int group) const { - return getGroup(group).m_datasets.count(); + return getGroup(group).m_datasets.count(); } /** @@ -388,19 +389,20 @@ int Project::Model::datasetCount(const int group) const */ const JSON::Group &Project::Model::getGroup(const int index) const { - if (m_groups.count() > index) - return m_groups.at(index); + if (m_groups.count() > index) + return m_groups.at(index); - return EMPTY_GROUP; + return EMPTY_GROUP; } /** * Returns a pointer to the dataset object contained by the @a group at * the given @a index */ -const JSON::Dataset &Project::Model::getDataset(const int group, const int index) const +const JSON::Dataset &Project::Model::getDataset(const int group, + const int index) const { - return getGroup(group).getDataset(index); + return getGroup(group).getDataset(index); } /** @@ -408,7 +410,7 @@ const JSON::Dataset &Project::Model::getDataset(const int group, const int index */ QString Project::Model::frameParserCode() const { - return m_frameParserCode; + return m_frameParserCode; } /** @@ -416,7 +418,7 @@ QString Project::Model::frameParserCode() const */ QString Project::Model::groupTitle(const int group) const { - return getGroup(group).title(); + return getGroup(group).title(); } /** @@ -424,7 +426,7 @@ QString Project::Model::groupTitle(const int group) const */ QString Project::Model::groupWidget(const int group) const { - return getGroup(group).widget(); + return getGroup(group).widget(); } /** @@ -435,21 +437,21 @@ QString Project::Model::groupWidget(const int group) const */ int Project::Model::groupWidgetIndex(const int group) const { - auto widget = groupWidget(group); + auto widget = groupWidget(group); - if (widget == "accelerometer") - return 1; + if (widget == "accelerometer") + return 1; - if (widget == "gyro") - return 2; + if (widget == "gyro") + return 2; - if (widget == "map") - return 3; + if (widget == "map") + return 3; - if (widget == "multiplot") - return 4; + if (widget == "multiplot") + return 4; - return 0; + return 0; } /** @@ -461,7 +463,7 @@ int Project::Model::groupWidgetIndex(const int group) const */ int Project::Model::datasetIndex(const int group, const int dataset) const { - return getDataset(group, dataset).m_index; + return getDataset(group, dataset).m_index; } /** @@ -473,7 +475,7 @@ int Project::Model::datasetIndex(const int group, const int dataset) const */ bool Project::Model::datasetLED(const int group, const int dataset) const { - return getDataset(group, dataset).led(); + return getDataset(group, dataset).led(); } /** @@ -485,7 +487,7 @@ bool Project::Model::datasetLED(const int group, const int dataset) const */ bool Project::Model::datasetGraph(const int group, const int dataset) const { - return getDataset(group, dataset).graph(); + return getDataset(group, dataset).graph(); } /** @@ -497,7 +499,7 @@ bool Project::Model::datasetGraph(const int group, const int dataset) const */ bool Project::Model::datasetFftPlot(const int group, const int dataset) const { - return getDataset(group, dataset).fft(); + return getDataset(group, dataset).fft(); } /** @@ -510,7 +512,7 @@ bool Project::Model::datasetFftPlot(const int group, const int dataset) const */ bool Project::Model::datasetLogPlot(const int group, const int dataset) const { - return getDataset(group, dataset).log(); + return getDataset(group, dataset).log(); } /** @@ -521,7 +523,7 @@ bool Project::Model::datasetLogPlot(const int group, const int dataset) const */ QString Project::Model::datasetTitle(const int group, const int dataset) const { - return getDataset(group, dataset).title(); + return getDataset(group, dataset).title(); } /** @@ -532,7 +534,7 @@ QString Project::Model::datasetTitle(const int group, const int dataset) const */ QString Project::Model::datasetUnits(const int group, const int dataset) const { - return getDataset(group, dataset).units(); + return getDataset(group, dataset).units(); } /** @@ -543,7 +545,7 @@ QString Project::Model::datasetUnits(const int group, const int dataset) const */ QString Project::Model::datasetWidget(const int group, const int dataset) const { - return getDataset(group, dataset).widget(); + return getDataset(group, dataset).widget(); } /** @@ -556,16 +558,16 @@ QString Project::Model::datasetWidget(const int group, const int dataset) const */ int Project::Model::datasetWidgetIndex(const int group, const int dataset) const { - auto widget = datasetWidget(group, dataset); + auto widget = datasetWidget(group, dataset); - if (widget == "gauge") - return 1; - if (widget == "bar") - return 2; - if (widget == "compass") - return 3; + if (widget == "gauge") + return 1; + if (widget == "bar") + return 2; + if (widget == "compass") + return 3; - return 0; + return 0; } /** @@ -575,9 +577,10 @@ int Project::Model::datasetWidgetIndex(const int group, const int dataset) const * @param group index of the group in which the dataset belongs * @param dataset index of the dataset */ -QString Project::Model::datasetWidgetMin(const int group, const int dataset) const +QString Project::Model::datasetWidgetMin(const int group, + const int dataset) const { - return QString::number(getDataset(group, dataset).min()); + return QString::number(getDataset(group, dataset).min()); } /** @@ -587,9 +590,10 @@ QString Project::Model::datasetWidgetMin(const int group, const int dataset) con * @param group index of the group in which the dataset belongs * @param dataset index of the dataset */ -QString Project::Model::datasetWidgetMax(const int group, const int dataset) const +QString Project::Model::datasetWidgetMax(const int group, + const int dataset) const { - return QString::number(getDataset(group, dataset).max()); + return QString::number(getDataset(group, dataset).max()); } /** @@ -598,9 +602,10 @@ QString Project::Model::datasetWidgetMax(const int group, const int dataset) con * @param group index of the group in which the dataset belongs * @param dataset index of the dataset */ -QString Project::Model::datasetFFTSamples(const int group, const int dataset) const +QString Project::Model::datasetFFTSamples(const int group, + const int dataset) const { - return QString::number(getDataset(group, dataset).fftSamples()); + return QString::number(getDataset(group, dataset).fftSamples()); } /** @@ -610,14 +615,15 @@ QString Project::Model::datasetFFTSamples(const int group, const int dataset) co * @param group index of the group in which the dataset belongs * @param dataset index of the dataset */ -QString Project::Model::datasetWidgetAlarm(const int group, const int dataset) const +QString Project::Model::datasetWidgetAlarm(const int group, + const int dataset) const { - auto set = getDataset(group, dataset); + auto set = getDataset(group, dataset); - if (set.alarm() <= set.min()) - return QString::number(set.max()); + if (set.alarm() <= set.min()) + return QString::number(set.max()); - return QString::number(set.alarm()); + return QString::number(set.alarm()); } //---------------------------------------------------------------------------------------- @@ -629,23 +635,23 @@ QString Project::Model::datasetWidgetAlarm(const int group, const int dataset) c */ void Project::Model::newJsonFile() { - // Clear groups list - m_groups.clear(); + // Clear groups list + m_groups.clear(); - // Reset project properties - setTitle(""); - setSeparator(""); - setFrameParserCode(""); - setFrameEndSequence(""); - setFrameStartSequence(""); + // Reset project properties + setTitle(""); + setSeparator(""); + setFrameParserCode(""); + setFrameEndSequence(""); + setFrameStartSequence(""); - // Update file path - m_filePath = ""; - Q_EMIT jsonFileChanged(); + // Update file path + m_filePath = ""; + Q_EMIT jsonFileChanged(); - // Update UI - Q_EMIT groupCountChanged(); - setModified(false); + // Update UI + Q_EMIT groupCountChanged(); + setModified(false); } /** @@ -654,19 +660,19 @@ void Project::Model::newJsonFile() */ void Project::Model::openJsonFile() { - // clang-format off + // clang-format off auto path = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select JSON file"), jsonProjectsPath(), "*.json"); - // clang-format on + // clang-format on - // Invalid path, abort - if (path.isEmpty()) - return; + // Invalid path, abort + if (path.isEmpty()) + return; - // Open the JSON file - openJsonFile(path); + // Open the JSON file + openJsonFile(path); } /** @@ -675,95 +681,95 @@ void Project::Model::openJsonFile() */ void Project::Model::openJsonFile(const QString &path) { - // Open file - QFile file(path); - QJsonDocument document; - if (file.open(QFile::ReadOnly)) + // Open file + QFile file(path); + QJsonDocument document; + if (file.open(QFile::ReadOnly)) + { + document = QJsonDocument::fromJson(file.readAll()); + file.close(); + } + + // Validate JSON document + if (document.isEmpty()) + return; + + // Let the generator use the given JSON file + if (JSON::Generator::instance().jsonMapFilepath() != path) + JSON::Generator::instance().loadJsonMap(path); + + // Reset C++ model + newJsonFile(); + + // Update current JSON document + m_filePath = path; + Q_EMIT jsonFileChanged(); + + // Read data from JSON document + auto json = document.object(); + setTitle(json.value("title").toString()); + setSeparator(json.value("separator").toString()); + setFrameEndSequence(json.value("frameEnd").toString()); + setFrameParserCode(json.value("frameParser").toString()); + setFrameStartSequence(json.value("frameStart").toString()); + + // Modify IO manager settings + IO::Manager::instance().setSeparatorSequence(separator()); + IO::Manager::instance().setFinishSequence(frameEndSequence()); + IO::Manager::instance().setStartSequence(frameStartSequence()); + + // Set JSON::Generator operation mode to manual + JSON::Generator::instance().setOperationMode(JSON::Generator::kManual); + + // Read groups from JSON document + auto groups = json.value("groups").toArray(); + for (int g = 0; g < groups.count(); ++g) + { + // Get JSON group data + auto group = groups.at(g).toObject(); + + // Register group with C++ model + addGroup(); + setGroupTitle(g, group.value("title").toString()); + setGroupWidgetData(g, group.value("widget").toString()); + + // Get JSON group datasets + auto datasets = group.value("datasets").toArray(); + for (int d = 0; d < datasets.count(); ++d) { - document = QJsonDocument::fromJson(file.readAll()); - file.close(); + // Get dataset JSON data + auto dataset = datasets.at(d).toObject(); + + // Register dataset with C++ model + addDataset(g); + setDatasetLED(g, d, dataset.value("led").toBool()); + setDatasetFftPlot(g, d, dataset.value("fft").toBool()); + setDatasetLogPlot(g, d, dataset.value("log").toBool()); + setDatasetGraph(g, d, dataset.value("graph").toBool()); + setDatasetTitle(g, d, dataset.value("title").toString()); + setDatasetUnits(g, d, dataset.value("units").toString()); + setDatasetWidgetData(g, d, dataset.value("widget").toString()); + + // Get max/min texts + auto min = dataset.value("min").toDouble(); + auto max = dataset.value("max").toDouble(); + auto index = dataset.value("index").toInt(); + auto alarm = dataset.value("alarm").toDouble(); + auto fftSamples = dataset.value("fftSamples").toInt(); + setDatasetIndex(g, d, index); + setDatasetWidgetMin(g, d, QString::number(min)); + setDatasetWidgetMax(g, d, QString::number(max)); + setDatasetWidgetAlarm(g, d, QString::number(alarm)); + ; + setDatasetFFTSamples(g, d, QString::number(fftSamples)); } + } - // Validate JSON document - if (document.isEmpty()) - return; + // Update UI + Q_EMIT groupCountChanged(); - // Let the generator use the given JSON file - if (JSON::Generator::instance().jsonMapFilepath() != path) - JSON::Generator::instance().loadJsonMap(path); - - // Reset C++ model - newJsonFile(); - - // Update current JSON document - m_filePath = path; - Q_EMIT jsonFileChanged(); - - // Read data from JSON document - auto json = document.object(); - setTitle(json.value("title").toString()); - setSeparator(json.value("separator").toString()); - setFrameEndSequence(json.value("frameEnd").toString()); - setFrameParserCode(json.value("frameParser").toString()); - setFrameStartSequence(json.value("frameStart").toString()); - - // Modify IO manager settings - IO::Manager::instance().setSeparatorSequence(separator()); - IO::Manager::instance().setFinishSequence(frameEndSequence()); - IO::Manager::instance().setStartSequence(frameStartSequence()); - - // Set JSON::Generator operation mode to manual - JSON::Generator::instance().setOperationMode(JSON::Generator::kManual); - - // Read groups from JSON document - auto groups = json.value("groups").toArray(); - for (int g = 0; g < groups.count(); ++g) - { - // Get JSON group data - auto group = groups.at(g).toObject(); - - // Register group with C++ model - addGroup(); - setGroupTitle(g, group.value("title").toString()); - setGroupWidgetData(g, group.value("widget").toString()); - - // Get JSON group datasets - auto datasets = group.value("datasets").toArray(); - for (int d = 0; d < datasets.count(); ++d) - { - // Get dataset JSON data - auto dataset = datasets.at(d).toObject(); - - // Register dataset with C++ model - addDataset(g); - setDatasetLED(g, d, dataset.value("led").toBool()); - setDatasetFftPlot(g, d, dataset.value("fft").toBool()); - setDatasetLogPlot(g, d, dataset.value("log").toBool()); - setDatasetGraph(g, d, dataset.value("graph").toBool()); - setDatasetTitle(g, d, dataset.value("title").toString()); - setDatasetUnits(g, d, dataset.value("units").toString()); - setDatasetWidgetData(g, d, dataset.value("widget").toString()); - - // Get max/min texts - auto min = dataset.value("min").toDouble(); - auto max = dataset.value("max").toDouble(); - auto index = dataset.value("index").toInt(); - auto alarm = dataset.value("alarm").toDouble(); - auto fftSamples = dataset.value("fftSamples").toInt(); - setDatasetIndex(g, d, index); - setDatasetWidgetMin(g, d, QString::number(min)); - setDatasetWidgetMax(g, d, QString::number(max)); - setDatasetWidgetAlarm(g, d, QString::number(alarm)); - ; - setDatasetFFTSamples(g, d, QString::number(fftSamples)); - } - } - - // Update UI - Q_EMIT groupCountChanged(); - - // Reset modified flag - setModified(false); + // Reset modified flag + setModified(false); } /** @@ -771,11 +777,11 @@ void Project::Model::openJsonFile(const QString &path) */ void Project::Model::setTitle(const QString &title) { - if (title != m_title) - { - m_title = title; - Q_EMIT titleChanged(); - } + if (title != m_title) + { + m_title = title; + Q_EMIT titleChanged(); + } } /** @@ -783,11 +789,11 @@ void Project::Model::setTitle(const QString &title) */ void Project::Model::setSeparator(const QString &separator) { - if (separator != m_separator) - { - m_separator = separator; - Q_EMIT separatorChanged(); - } + if (separator != m_separator) + { + m_separator = separator; + Q_EMIT separatorChanged(); + } } /** @@ -795,18 +801,18 @@ void Project::Model::setSeparator(const QString &separator) */ void Project::Model::setFrameParserCode(const QString &code) { - if (code != m_frameParserCode) - { - // Update internal model - m_frameParserCode = code; + if (code != m_frameParserCode) + { + // Update internal model + m_frameParserCode = code; - // Load default code if required - if (m_frameParserCode.isEmpty()) - m_frameParserCode = CodeEditor::instance().defaultCode(); + // Load default code if required + if (m_frameParserCode.isEmpty()) + m_frameParserCode = CodeEditor::instance().defaultCode(); - // Update UI - Q_EMIT frameParserCodeChanged(); - } + // Update UI + Q_EMIT frameParserCodeChanged(); + } } /** @@ -814,11 +820,11 @@ void Project::Model::setFrameParserCode(const QString &code) */ void Project::Model::setFrameEndSequence(const QString &sequence) { - if (sequence != m_frameEndSequence) - { - m_frameEndSequence = sequence; - Q_EMIT frameEndSequenceChanged(); - } + if (sequence != m_frameEndSequence) + { + m_frameEndSequence = sequence; + Q_EMIT frameEndSequenceChanged(); + } } /** @@ -826,11 +832,11 @@ void Project::Model::setFrameEndSequence(const QString &sequence) */ void Project::Model::setFrameStartSequence(const QString &sequence) { - if (sequence != m_frameStartSequence) - { - m_frameStartSequence = sequence; - Q_EMIT frameStartSequenceChanged(); - } + if (sequence != m_frameStartSequence) + { + m_frameStartSequence = sequence; + Q_EMIT frameStartSequenceChanged(); + } } /** @@ -838,10 +844,10 @@ void Project::Model::setFrameStartSequence(const QString &sequence) */ void Project::Model::addGroup() { - m_groups.append(JSON::Group()); - setGroupTitle(m_groups.count() - 1, tr("New Group")); + m_groups.append(JSON::Group()); + setGroupTitle(m_groups.count() - 1, tr("New Group")); - Q_EMIT groupCountChanged(); + Q_EMIT groupCountChanged(); } /** @@ -850,16 +856,16 @@ void Project::Model::addGroup() */ void Project::Model::deleteGroup(const int group) { - auto ret = Misc::Utilities::showMessageBox( - tr("Delete group \"%1\"").arg(groupTitle(group)), - tr("Are you sure you want to delete this group?"), APP_NAME, - QMessageBox::Yes | QMessageBox::No); + auto ret = Misc::Utilities::showMessageBox( + tr("Delete group \"%1\"").arg(groupTitle(group)), + tr("Are you sure you want to delete this group?"), APP_NAME, + QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::Yes) - { - m_groups.removeAt(group); - Q_EMIT groupCountChanged(); - } + if (ret == QMessageBox::Yes) + { + m_groups.removeAt(group); + Q_EMIT groupCountChanged(); + } } /** @@ -867,11 +873,11 @@ void Project::Model::deleteGroup(const int group) */ void Project::Model::moveGroupUp(const int group) { - if (group > 0) - { - m_groups.move(group, group - 1); - Q_EMIT groupOrderChanged(); - } + if (group > 0) + { + m_groups.move(group, group - 1); + Q_EMIT groupOrderChanged(); + } } /** @@ -879,11 +885,11 @@ void Project::Model::moveGroupUp(const int group) */ void Project::Model::moveGroupDown(const int group) { - if (group < groupCount() - 1) - { - m_groups.move(group, group + 1); - Q_EMIT groupOrderChanged(); - } + if (group < groupCount() - 1) + { + m_groups.move(group, group + 1); + Q_EMIT groupOrderChanged(); + } } /** @@ -893,139 +899,139 @@ void Project::Model::moveGroupDown(const int group) */ bool Project::Model::setGroupWidget(const int group, const int widgetId) { - auto grp = getGroup(group); + auto grp = getGroup(group); - // Warn user if group contains existing datasets - if (!(grp.m_datasets.isEmpty()) && widgetId != 4) + // Warn user if group contains existing datasets + if (!(grp.m_datasets.isEmpty()) && widgetId != 4) + { + if (widgetId == 0 && grp.widget() == "multiplot") + grp.m_widget = ""; + + else { - if (widgetId == 0 && grp.widget() == "multiplot") - grp.m_widget = ""; - - else - { - auto ret = Misc::Utilities::showMessageBox( - tr("Are you sure you want to change the group-level widget?"), - tr("Existing datasets for this group will be deleted"), APP_NAME, - QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::No) - return false; - else - grp.m_datasets.clear(); - } + auto ret = Misc::Utilities::showMessageBox( + tr("Are you sure you want to change the group-level widget?"), + tr("Existing datasets for this group will be deleted"), APP_NAME, + QMessageBox::Yes | QMessageBox::No); + if (ret == QMessageBox::No) + return false; + else + grp.m_datasets.clear(); } + } - // Accelerometer widget - if (widgetId == 1) - { - // Set widget title - grp.m_widget = "accelerometer"; - grp.m_title = tr("Accelerometer"); + // Accelerometer widget + if (widgetId == 1) + { + // Set widget title + grp.m_widget = "accelerometer"; + grp.m_title = tr("Accelerometer"); - // Create datasets - JSON::Dataset x, y, z; + // Create datasets + JSON::Dataset x, y, z; - // Set dataset indexes - x.m_index = nextDatasetIndex(); - y.m_index = nextDatasetIndex() + 1; - z.m_index = nextDatasetIndex() + 2; + // Set dataset indexes + x.m_index = nextDatasetIndex(); + y.m_index = nextDatasetIndex() + 1; + z.m_index = nextDatasetIndex() + 2; - // Set measurement units - x.m_units = "m/s²"; - y.m_units = "m/s²"; - z.m_units = "m/s²"; + // Set measurement units + x.m_units = "m/s²"; + y.m_units = "m/s²"; + z.m_units = "m/s²"; - // Set dataset properties - x.m_widget = "x"; - y.m_widget = "y"; - z.m_widget = "z"; - x.m_title = tr("Accelerometer %1").arg("X"); - y.m_title = tr("Accelerometer %1").arg("Y"); - z.m_title = tr("Accelerometer %1").arg("Z"); + // Set dataset properties + x.m_widget = "x"; + y.m_widget = "y"; + z.m_widget = "z"; + x.m_title = tr("Accelerometer %1").arg("X"); + y.m_title = tr("Accelerometer %1").arg("Y"); + z.m_title = tr("Accelerometer %1").arg("Z"); - // Add datasets to group - grp.m_datasets.append(x); - grp.m_datasets.append(y); - grp.m_datasets.append(z); - } + // Add datasets to group + grp.m_datasets.append(x); + grp.m_datasets.append(y); + grp.m_datasets.append(z); + } - // Gyroscope widget - else if (widgetId == 2) - { - // Set widget title - grp.m_widget = "gyro"; - grp.m_title = tr("Gyroscope"); + // Gyroscope widget + else if (widgetId == 2) + { + // Set widget title + grp.m_widget = "gyro"; + grp.m_title = tr("Gyroscope"); - // Create datasets - JSON::Dataset x, y, z; + // Create datasets + JSON::Dataset x, y, z; - // Set dataset indexes - x.m_index = nextDatasetIndex(); - y.m_index = nextDatasetIndex() + 1; - z.m_index = nextDatasetIndex() + 2; + // Set dataset indexes + x.m_index = nextDatasetIndex(); + y.m_index = nextDatasetIndex() + 1; + z.m_index = nextDatasetIndex() + 2; - // Set measurement units - x.m_units = "°"; - y.m_units = "°"; - z.m_units = "°"; + // Set measurement units + x.m_units = "°"; + y.m_units = "°"; + z.m_units = "°"; - // Set dataset properties - x.m_widget = "roll"; - y.m_widget = "pitch"; - z.m_widget = "yaw"; - x.m_title = tr("Gyro %1").arg("Roll"); - y.m_title = tr("Gyro %1").arg("Pitch"); - z.m_title = tr("Gyro %1").arg("Yaw"); + // Set dataset properties + x.m_widget = "roll"; + y.m_widget = "pitch"; + z.m_widget = "yaw"; + x.m_title = tr("Gyro %1").arg("Roll"); + y.m_title = tr("Gyro %1").arg("Pitch"); + z.m_title = tr("Gyro %1").arg("Yaw"); - // Add datasets to group - grp.m_datasets.append(x); - grp.m_datasets.append(y); - grp.m_datasets.append(z); - } + // Add datasets to group + grp.m_datasets.append(x); + grp.m_datasets.append(y); + grp.m_datasets.append(z); + } - // Map widget - else if (widgetId == 3) - { - // Set widget title - grp.m_widget = "map"; - grp.m_title = tr("GPS"); + // Map widget + else if (widgetId == 3) + { + // Set widget title + grp.m_widget = "map"; + grp.m_title = tr("GPS"); - // Create datasets - JSON::Dataset lat, lon, alt; + // Create datasets + JSON::Dataset lat, lon, alt; - // Set dataset indexes - lat.m_index = nextDatasetIndex(); - lon.m_index = nextDatasetIndex() + 1; - alt.m_index = nextDatasetIndex() + 2; + // Set dataset indexes + lat.m_index = nextDatasetIndex(); + lon.m_index = nextDatasetIndex() + 1; + alt.m_index = nextDatasetIndex() + 2; - // Set measurement units - lat.m_units = "°"; - lon.m_units = "°"; - alt.m_units = "m"; + // Set measurement units + lat.m_units = "°"; + lon.m_units = "°"; + alt.m_units = "m"; - // Set dataset properties - lat.m_widget = "lat"; - lon.m_widget = "lon"; - alt.m_widget = "alt"; - lat.m_title = tr("Latitude"); - lon.m_title = tr("Longitude"); - alt.m_title = tr("Altitude"); + // Set dataset properties + lat.m_widget = "lat"; + lon.m_widget = "lon"; + alt.m_widget = "alt"; + lat.m_title = tr("Latitude"); + lon.m_title = tr("Longitude"); + alt.m_title = tr("Altitude"); - // Add datasets to group - grp.m_datasets.append(lat); - grp.m_datasets.append(lon); - grp.m_datasets.append(alt); - } + // Add datasets to group + grp.m_datasets.append(lat); + grp.m_datasets.append(lon); + grp.m_datasets.append(alt); + } - // Multi plot widget - else if (widgetId == 4) - grp.m_widget = "multiplot"; + // Multi plot widget + else if (widgetId == 4) + grp.m_widget = "multiplot"; - // Replace previous group with new group - m_groups.replace(group, grp); + // Replace previous group with new group + m_groups.replace(group, grp); - // Update UI - Q_EMIT groupChanged(group); - return true; + // Update UI + Q_EMIT groupChanged(group); + return true; } /** @@ -1033,15 +1039,15 @@ bool Project::Model::setGroupWidget(const int group, const int widgetId) */ void Project::Model::setGroupTitle(const int group, const QString &title) { - // Get group - auto grp = getGroup(group); + // Get group + auto grp = getGroup(group); - // Change group values & update groups vector - grp.m_title = title; - m_groups.replace(group, grp); + // Change group values & update groups vector + grp.m_title = title; + m_groups.replace(group, grp); - // Update UI - Q_EMIT groupChanged(group); + // Update UI + Q_EMIT groupChanged(group); } /** @@ -1049,15 +1055,15 @@ void Project::Model::setGroupTitle(const int group, const QString &title) */ void Project::Model::setGroupWidgetData(const int group, const QString &widget) { - // Get group - auto grp = getGroup(group); + // Get group + auto grp = getGroup(group); - // Change group values & update groups vector - grp.m_widget = widget; - m_groups.replace(group, grp); + // Change group values & update groups vector + grp.m_widget = widget; + m_groups.replace(group, grp); - // Update UI - Q_EMIT groupChanged(group); + // Update UI + Q_EMIT groupChanged(group); } /** @@ -1067,19 +1073,19 @@ void Project::Model::setGroupWidgetData(const int group, const QString &widget) */ void Project::Model::addDataset(const int group) { - // Get group - auto grp = getGroup(group); + // Get group + auto grp = getGroup(group); - // Change group values & update groups vector - grp.m_datasets.append(JSON::Dataset()); - m_groups.replace(group, grp); + // Change group values & update groups vector + grp.m_datasets.append(JSON::Dataset()); + m_groups.replace(group, grp); - // Set dataset title & index - setDatasetIndex(group, grp.m_datasets.count() - 1, nextDatasetIndex()); - setDatasetTitle(group, grp.m_datasets.count() - 1, tr("New dataset")); + // Set dataset title & index + setDatasetIndex(group, grp.m_datasets.count() - 1, nextDatasetIndex()); + setDatasetTitle(group, grp.m_datasets.count() - 1, tr("New dataset")); - // Update UI - Q_EMIT groupChanged(group); + // Update UI + Q_EMIT groupChanged(group); } /** @@ -1090,18 +1096,18 @@ void Project::Model::addDataset(const int group) */ void Project::Model::deleteDataset(const int group, const int dataset) { - auto ret = Misc::Utilities::showMessageBox( - tr("Delete dataset \"%1\"").arg(getDataset(group, dataset).title()), - tr("Are you sure you want to delete this dataset?"), APP_NAME, - QMessageBox::Yes | QMessageBox::No); + auto ret = Misc::Utilities::showMessageBox( + tr("Delete dataset \"%1\"").arg(getDataset(group, dataset).title()), + tr("Are you sure you want to delete this dataset?"), APP_NAME, + QMessageBox::Yes | QMessageBox::No); - if (ret == QMessageBox::Yes) - { - auto grp = getGroup(group); - grp.m_datasets.removeAt(dataset); - m_groups.replace(group, grp); - Q_EMIT groupChanged(group); - } + if (ret == QMessageBox::Yes) + { + auto grp = getGroup(group); + grp.m_datasets.removeAt(dataset); + m_groups.replace(group, grp); + Q_EMIT groupChanged(group); + } } /** @@ -1113,20 +1119,20 @@ void Project::Model::deleteDataset(const int group, const int dataset) void Project::Model::setDatasetTitle(const int group, const int dataset, const QString &title) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_title != title) - { - set.m_title = title; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_title != title) + { + set.m_title = title; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1138,20 +1144,20 @@ void Project::Model::setDatasetTitle(const int group, const int dataset, void Project::Model::setDatasetUnits(const int group, const int dataset, const QString &units) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_units != units) - { - set.m_units = units; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_units != units) + { + set.m_units = units; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1163,20 +1169,20 @@ void Project::Model::setDatasetUnits(const int group, const int dataset, void Project::Model::setDatasetIndex(const int group, const int dataset, const int frameIndex) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_index != frameIndex) - { - set.m_index = frameIndex; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_index != frameIndex) + { + set.m_index = frameIndex; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1188,20 +1194,20 @@ void Project::Model::setDatasetIndex(const int group, const int dataset, void Project::Model::setDatasetLED(const int group, const int dataset, const bool generateLED) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_led != generateLED) - { - set.m_led = generateLED; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_led != generateLED) + { + set.m_led = generateLED; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1213,20 +1219,20 @@ void Project::Model::setDatasetLED(const int group, const int dataset, void Project::Model::setDatasetGraph(const int group, const int dataset, const bool generateGraph) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_graph != generateGraph) - { - set.m_graph = generateGraph; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_graph != generateGraph) + { + set.m_graph = generateGraph; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1238,20 +1244,20 @@ void Project::Model::setDatasetGraph(const int group, const int dataset, void Project::Model::setDatasetFftPlot(const int group, const int dataset, const bool generateFft) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_fft != generateFft) - { - set.m_fft = generateFft; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_fft != generateFft) + { + set.m_fft = generateFft; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1263,25 +1269,26 @@ void Project::Model::setDatasetFftPlot(const int group, const int dataset, void Project::Model::setDatasetLogPlot(const int group, const int dataset, const bool generateLog) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_log != generateLog) - { - set.m_log = generateLog; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_log != generateLog) + { + set.m_log = generateLog; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** - * Updates the @a widgetId of the given @a dataset. The widget ID is dependent on - * the order of the widgets returned by the @c availableDatasetLevelWidgets() function. + * Updates the @a widgetId of the given @a dataset. The widget ID is dependent + * on the order of the widgets returned by the @c availableDatasetLevelWidgets() + * function. * * @param group index of the group in which the dataset belongs * @param dataset index of the dataset @@ -1289,33 +1296,33 @@ void Project::Model::setDatasetLogPlot(const int group, const int dataset, void Project::Model::setDatasetWidget(const int group, const int dataset, const int widgetId) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Get widget string - QString widget; - if (widgetId == 1) - widget = "gauge"; - else if (widgetId == 2) - widget = "bar"; - else if (widgetId == 3) - { - widget = "compass"; - set.m_min = 0; - set.m_max = 360; - } + // Get widget string + QString widget; + if (widgetId == 1) + widget = "gauge"; + else if (widgetId == 2) + widget = "bar"; + else if (widgetId == 3) + { + widget = "compass"; + set.m_min = 0; + set.m_max = 360; + } - // Update dataset & group - if (set.m_widget != widget) - { - set.m_widget = widget; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_widget != widget) + { + set.m_widget = widget; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1329,20 +1336,20 @@ void Project::Model::setDatasetWidget(const int group, const int dataset, void Project::Model::setDatasetWidgetMin(const int group, const int dataset, const QString &minimum) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_min != minimum.toDouble()) - { - set.m_min = minimum.toDouble(); - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_min != minimum.toDouble()) + { + set.m_min = minimum.toDouble(); + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1356,20 +1363,20 @@ void Project::Model::setDatasetWidgetMin(const int group, const int dataset, void Project::Model::setDatasetWidgetMax(const int group, const int dataset, const QString &maximum) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_max != maximum.toDouble()) - { - set.m_max = maximum.toDouble(); - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_max != maximum.toDouble()) + { + set.m_max = maximum.toDouble(); + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1381,20 +1388,20 @@ void Project::Model::setDatasetWidgetMax(const int group, const int dataset, void Project::Model::setDatasetWidgetData(const int group, const int dataset, const QString &widget) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_widget != widget) - { - set.m_widget = widget; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_widget != widget) + { + set.m_widget = widget; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1408,20 +1415,20 @@ void Project::Model::setDatasetWidgetData(const int group, const int dataset, void Project::Model::setDatasetWidgetAlarm(const int group, const int dataset, const QString &alarm) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Update dataset & group - if (set.m_alarm != alarm.toDouble()) - { - set.m_alarm = alarm.toDouble(); - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_alarm != alarm.toDouble()) + { + set.m_alarm = alarm.toDouble(); + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1433,25 +1440,25 @@ void Project::Model::setDatasetWidgetAlarm(const int group, const int dataset, void Project::Model::setDatasetFFTSamples(const int group, const int dataset, const QString &samples) { - // Get dataset & group - auto grp = getGroup(group); - auto set = getDataset(group, dataset); + // Get dataset & group + auto grp = getGroup(group); + auto set = getDataset(group, dataset); - // Validate FFT samples - auto sample = samples.toInt(); - if (sample < 128) - sample = 128; + // Validate FFT samples + auto sample = samples.toInt(); + if (sample < 128) + sample = 128; - // Update dataset & group - if (set.m_fftSamples != sample) - { - set.m_fftSamples = sample; - grp.m_datasets.replace(dataset, set); - m_groups.replace(group, grp); + // Update dataset & group + if (set.m_fftSamples != sample) + { + set.m_fftSamples = sample; + grp.m_datasets.replace(dataset, set); + m_groups.replace(group, grp); - // Update UI - Q_EMIT datasetChanged(group, dataset); - } + // Update UI + Q_EMIT datasetChanged(group, dataset); + } } /** @@ -1461,8 +1468,8 @@ void Project::Model::setDatasetFFTSamples(const int group, const int dataset, */ void Project::Model::setModified(const bool modified) { - m_modified = modified; - Q_EMIT modifiedChanged(); + m_modified = modified; + Q_EMIT modifiedChanged(); } /** @@ -1471,8 +1478,8 @@ void Project::Model::setModified(const bool modified) */ void Project::Model::onJsonLoaded() { - if (jsonFilePath() != JSON::Generator::instance().jsonMapFilepath()) - openJsonFile(JSON::Generator::instance().jsonMapFilepath()); + if (jsonFilePath() != JSON::Generator::instance().jsonMapFilepath()) + openJsonFile(JSON::Generator::instance().jsonMapFilepath()); } /** @@ -1481,7 +1488,7 @@ void Project::Model::onJsonLoaded() */ void Project::Model::onModelChanged() { - setModified(true); + setModified(true); } /** @@ -1490,8 +1497,8 @@ void Project::Model::onModelChanged() */ void Project::Model::onGroupChanged(const int group) { - (void)group; - setModified(true); + (void)group; + setModified(true); } /** @@ -1503,9 +1510,9 @@ void Project::Model::onGroupChanged(const int group) */ void Project::Model::onDatasetChanged(const int group, const int dataset) { - (void)group; - (void)dataset; - setModified(true); + (void)group; + (void)dataset; + setModified(true); } /** @@ -1517,20 +1524,16 @@ void Project::Model::onDatasetChanged(const int group, const int dataset) */ int Project::Model::nextDatasetIndex() { - int maxIndex = 1; - for (int i = 0; i < groupCount(); ++i) + int maxIndex = 1; + for (int i = 0; i < groupCount(); ++i) + { + for (int j = 0; j < datasetCount(i); ++j) { - for (int j = 0; j < datasetCount(i); ++j) - { - auto dataset = getDataset(i, j); - if (dataset.m_index >= maxIndex) - maxIndex = dataset.m_index + 1; - } + auto dataset = getDataset(i, j); + if (dataset.m_index >= maxIndex) + maxIndex = dataset.m_index + 1; } + } - return maxIndex; + return maxIndex; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Model.cpp" -#endif diff --git a/src/Project/Model.h b/src/Project/Model.h index 231139a5..9137c8ce 100644 --- a/src/Project/Model.h +++ b/src/Project/Model.h @@ -40,7 +40,7 @@ namespace Project */ class Model : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(int groupCount READ groupCount @@ -70,127 +70,144 @@ class Model : public QObject Q_PROPERTY(QString jsonFileName READ jsonFileName NOTIFY jsonFileChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void titleChanged(); - void jsonFileChanged(); - void modifiedChanged(); - void separatorChanged(); - void groupCountChanged(); - void groupOrderChanged(); - void frameParserCodeChanged(); - void frameEndSequenceChanged(); - void frameStartSequenceChanged(); - void groupChanged(const int group); - void datasetChanged(const int group, const int dataset); + void titleChanged(); + void jsonFileChanged(); + void modifiedChanged(); + void separatorChanged(); + void groupCountChanged(); + void groupOrderChanged(); + void frameParserCodeChanged(); + void frameEndSequenceChanged(); + void frameStartSequenceChanged(); + void groupChanged(const int group); + void datasetChanged(const int group, const int dataset); private: - explicit Model(); - Model(Model &&) = delete; - Model(const Model &) = delete; - Model &operator=(Model &&) = delete; - Model &operator=(const Model &) = delete; + explicit Model(); + Model(Model &&) = delete; + Model(const Model &) = delete; + Model &operator=(Model &&) = delete; + Model &operator=(const Model &) = delete; public: - static Model &instance(); + static Model &instance(); - Q_INVOKABLE StringList availableGroupLevelWidgets(); - Q_INVOKABLE StringList availableDatasetLevelWidgets(); + Q_INVOKABLE StringList availableGroupLevelWidgets(); + Q_INVOKABLE StringList availableDatasetLevelWidgets(); - QString jsonProjectsPath() const; + QString jsonProjectsPath() const; - QString title() const; - QString separator() const; - QString frameEndSequence() const; - QString frameStartSequence() const; + QString title() const; + QString separator() const; + QString frameEndSequence() const; + QString frameStartSequence() const; - bool modified() const; - int groupCount() const; - QString jsonFilePath() const; - QString jsonFileName() const; + bool modified() const; + int groupCount() const; + QString jsonFilePath() const; + QString jsonFileName() const; - Q_INVOKABLE bool askSave(); - Q_INVOKABLE bool saveJsonFile(); - Q_INVOKABLE int datasetCount(const int group) const; + Q_INVOKABLE bool askSave(); + Q_INVOKABLE bool saveJsonFile(); + Q_INVOKABLE int datasetCount(const int group) const; - Q_INVOKABLE const JSON::Group &getGroup(const int index) const; - Q_INVOKABLE const JSON::Dataset &getDataset(const int group, const int index) const; + Q_INVOKABLE const JSON::Group &getGroup(const int index) const; + Q_INVOKABLE const JSON::Dataset &getDataset(const int group, + const int index) const; - Q_INVOKABLE QString frameParserCode() const; - Q_INVOKABLE QString groupTitle(const int group) const; - Q_INVOKABLE QString groupWidget(const int group) const; - Q_INVOKABLE int groupWidgetIndex(const int group) const; - Q_INVOKABLE int datasetIndex(const int group, const int dataset) const; - Q_INVOKABLE bool datasetLED(const int group, const int dataset) const; - Q_INVOKABLE bool datasetGraph(const int group, const int dataset) const; - Q_INVOKABLE bool datasetFftPlot(const int group, const int dataset) const; - Q_INVOKABLE bool datasetLogPlot(const int group, const int dataset) const; - Q_INVOKABLE QString datasetTitle(const int group, const int dataset) const; - Q_INVOKABLE QString datasetUnits(const int group, const int dataset) const; - Q_INVOKABLE QString datasetWidget(const int group, const int dataset) const; - Q_INVOKABLE int datasetWidgetIndex(const int group, const int dataset) const; - Q_INVOKABLE QString datasetWidgetMin(const int group, const int dataset) const; - Q_INVOKABLE QString datasetWidgetMax(const int group, const int dataset) const; - Q_INVOKABLE QString datasetFFTSamples(const int group, const int dataset) const; - Q_INVOKABLE QString datasetWidgetAlarm(const int group, const int dataset) const; + Q_INVOKABLE QString frameParserCode() const; + Q_INVOKABLE QString groupTitle(const int group) const; + Q_INVOKABLE QString groupWidget(const int group) const; + Q_INVOKABLE int groupWidgetIndex(const int group) const; + Q_INVOKABLE int datasetIndex(const int group, const int dataset) const; + Q_INVOKABLE bool datasetLED(const int group, const int dataset) const; + Q_INVOKABLE bool datasetGraph(const int group, const int dataset) const; + Q_INVOKABLE bool datasetFftPlot(const int group, const int dataset) const; + Q_INVOKABLE bool datasetLogPlot(const int group, const int dataset) const; + Q_INVOKABLE QString datasetTitle(const int group, const int dataset) const; + Q_INVOKABLE QString datasetUnits(const int group, const int dataset) const; + Q_INVOKABLE QString datasetWidget(const int group, const int dataset) const; + Q_INVOKABLE int datasetWidgetIndex(const int group, const int dataset) const; + Q_INVOKABLE QString datasetWidgetMin(const int group, + const int dataset) const; + Q_INVOKABLE QString datasetWidgetMax(const int group, + const int dataset) const; + Q_INVOKABLE QString datasetFFTSamples(const int group, + const int dataset) const; + Q_INVOKABLE QString datasetWidgetAlarm(const int group, + const int dataset) const; - Q_INVOKABLE bool setGroupWidget(const int group, const int widgetId); + Q_INVOKABLE bool setGroupWidget(const int group, const int widgetId); public Q_SLOTS: - void newJsonFile(); - void openJsonFile(); - void openJsonFile(const QString &path); + void newJsonFile(); + void openJsonFile(); + void openJsonFile(const QString &path); - void setTitle(const QString &title); - void setSeparator(const QString &separator); - void setFrameParserCode(const QString &code); - void setFrameEndSequence(const QString &sequence); - void setFrameStartSequence(const QString &sequence); + void setTitle(const QString &title); + void setSeparator(const QString &separator); + void setFrameParserCode(const QString &code); + void setFrameEndSequence(const QString &sequence); + void setFrameStartSequence(const QString &sequence); - void addGroup(); - void deleteGroup(const int group); - void moveGroupUp(const int group); - void moveGroupDown(const int group); - void setGroupTitle(const int group, const QString &title); - void setGroupWidgetData(const int group, const QString &widget); + void addGroup(); + void deleteGroup(const int group); + void moveGroupUp(const int group); + void moveGroupDown(const int group); + void setGroupTitle(const int group, const QString &title); + void setGroupWidgetData(const int group, const QString &widget); - void addDataset(const int group); - void deleteDataset(const int group, const int dataset); - void setDatasetWidget(const int group, const int dataset, const int widgetId); - void setDatasetTitle(const int group, const int dataset, const QString &title); - void setDatasetUnits(const int group, const int dataset, const QString &units); - void setDatasetIndex(const int group, const int dataset, const int frameIndex); - void setDatasetLED(const int group, const int dataset, const bool generateLED); - void setDatasetGraph(const int group, const int dataset, const bool generateGraph); - void setDatasetFftPlot(const int group, const int dataset, const bool generateFft); - void setDatasetLogPlot(const int group, const int dataset, const bool generateLog); - void setDatasetWidgetMin(const int group, const int dataset, const QString &minimum); - void setDatasetWidgetMax(const int group, const int dataset, const QString &maximum); - void setDatasetWidgetData(const int group, const int dataset, const QString &widget); - void setDatasetWidgetAlarm(const int group, const int dataset, const QString &alarm); - void setDatasetFFTSamples(const int group, const int dataset, const QString &samples); + void addDataset(const int group); + void deleteDataset(const int group, const int dataset); + void setDatasetWidget(const int group, const int dataset, const int widgetId); + void setDatasetTitle(const int group, const int dataset, + const QString &title); + void setDatasetUnits(const int group, const int dataset, + const QString &units); + void setDatasetIndex(const int group, const int dataset, + const int frameIndex); + void setDatasetLED(const int group, const int dataset, + const bool generateLED); + void setDatasetGraph(const int group, const int dataset, + const bool generateGraph); + void setDatasetFftPlot(const int group, const int dataset, + const bool generateFft); + void setDatasetLogPlot(const int group, const int dataset, + const bool generateLog); + void setDatasetWidgetMin(const int group, const int dataset, + const QString &minimum); + void setDatasetWidgetMax(const int group, const int dataset, + const QString &maximum); + void setDatasetWidgetData(const int group, const int dataset, + const QString &widget); + void setDatasetWidgetAlarm(const int group, const int dataset, + const QString &alarm); + void setDatasetFFTSamples(const int group, const int dataset, + const QString &samples); private Q_SLOTS: - void onJsonLoaded(); - void onModelChanged(); - void onGroupChanged(const int group); - void setModified(const bool modified); - void onDatasetChanged(const int group, const int dataset); + void onJsonLoaded(); + void onModelChanged(); + void onGroupChanged(const int group); + void setModified(const bool modified); + void onDatasetChanged(const int group, const int dataset); private: - int nextDatasetIndex(); + int nextDatasetIndex(); private: - QString m_title; - QString m_separator; - QString m_frameParserCode; - QString m_frameEndSequence; - QString m_frameStartSequence; + QString m_title; + QString m_separator; + QString m_frameParserCode; + QString m_frameEndSequence; + QString m_frameStartSequence; - bool m_modified; - QString m_filePath; + bool m_modified; + QString m_filePath; - QVector m_groups; + QVector m_groups; }; -} +} // namespace Project diff --git a/src/UI/Dashboard.cpp b/src/UI/Dashboard.cpp index 8236d864..29bd31f8 100644 --- a/src/UI/Dashboard.cpp +++ b/src/UI/Dashboard.cpp @@ -35,10 +35,10 @@ * Constructor of the class. */ UI::Dashboard::Dashboard() - : m_points(100) - , m_precision(2) + : m_points(100) + , m_precision(2) { - // clang-format off + // clang-format off connect(&CSV::Player::instance(), &CSV::Player::openChanged, this, &UI::Dashboard::resetData); connect(&IO::Manager::instance(), &IO::Manager::connectedChanged, @@ -47,7 +47,7 @@ UI::Dashboard::Dashboard() this, &UI::Dashboard::processLatestJSON); connect(&JSON::Generator::instance(), &JSON::Generator::jsonFileMapChanged, this, &UI::Dashboard::resetData); - // clang-format on + // clang-format on } /** @@ -55,8 +55,8 @@ UI::Dashboard::Dashboard() */ UI::Dashboard &UI::Dashboard::instance() { - static Dashboard singleton; - return singleton; + static Dashboard singleton; + return singleton; } //---------------------------------------------------------------------------------------- @@ -65,7 +65,7 @@ UI::Dashboard &UI::Dashboard::instance() QFont UI::Dashboard::monoFont() const { - return QFont("Roboto Mono"); + return QFont("Roboto Mono"); } // clang-format off @@ -91,7 +91,7 @@ const JSON::Group &UI::Dashboard::getAccelerometer(const int index) const { retu */ QString UI::Dashboard::title() { - return m_currentFrame.title(); + return m_currentFrame.title(); } /** @@ -99,7 +99,7 @@ QString UI::Dashboard::title() */ bool UI::Dashboard::available() { - return totalWidgetCount() > 0; + return totalWidgetCount() > 0; } /** @@ -107,7 +107,7 @@ bool UI::Dashboard::available() */ int UI::Dashboard::points() const { - return m_points; + return m_points; } /** @@ -115,16 +115,16 @@ int UI::Dashboard::points() const */ int UI::Dashboard::precision() const { - return m_precision; + return m_precision; } /** - * Returns @c true if the current JSON frame is valid and ready-to-use by the QML - * interface. + * Returns @c true if the current JSON frame is valid and ready-to-use by the + * QML interface. */ bool UI::Dashboard::frameValid() const { - return m_currentFrame.isValid(); + return m_currentFrame.isValid(); } //---------------------------------------------------------------------------------------- @@ -133,17 +133,17 @@ bool UI::Dashboard::frameValid() const /** * Returns the total number of widgets that compose the current JSON frame. - * This function is used as a helper to the functions that use the global-index widget - * system. + * This function is used as a helper to the functions that use the global-index + * widget system. * - * In the case of this function, we do not care about the order of the items that generate - * the summatory count of all widgets. But in the other global-index functions we need to - * be careful to sincronize the order of the widgets in order to allow the global-index - * system to work correctly. + * In the case of this function, we do not care about the order of the items + * that generate the summatory count of all widgets. But in the other + * global-index functions we need to be careful to sincronize the order of the + * widgets in order to allow the global-index system to work correctly. */ int UI::Dashboard::totalWidgetCount() const { - // clang-format off + // clang-format off const int count = gpsCount() + ledCount() + @@ -156,9 +156,9 @@ int UI::Dashboard::totalWidgetCount() const multiPlotCount() + gyroscopeCount() + accelerometerCount(); - // clang-format on + // clang-format on - return count; + return count; } // clang-format off @@ -180,17 +180,18 @@ int UI::Dashboard::accelerometerCount() const { return m_accelerometerWidgets.co //---------------------------------------------------------------------------------------- /** - * Returns a @c list with the titles of all the widgets that compose the current JSON - * frame. + * Returns a @c list with the titles of all the widgets that compose the current + * JSON frame. * - * We need to be careful to sincronize the order of the widgets in order to allow - * the global-index system to work correctly. + * We need to be careful to sincronize the order of the widgets in order to + * allow the global-index system to work correctly. */ StringList UI::Dashboard::widgetTitles() { - // Warning: maintain same order as the view option repeaters in ViewOptions.qml! + // Warning: maintain same order as the view option repeaters in + // ViewOptions.qml! - // clang-format off + // clang-format off return groupTitles() + multiPlotTitles() + ledTitles() + @@ -202,215 +203,217 @@ StringList UI::Dashboard::widgetTitles() gyroscopeTitles() + accelerometerTitles() + gpsTitles(); - // clang-format on + // clang-format on } /** * Returns the widget-specific index for the widget with the specified @a index. * - * To simplify operations and user interface generation in QML, this class represents - * the widgets in two manners: + * To simplify operations and user interface generation in QML, this class + * represents the widgets in two manners: * * - A global list of all widgets * - A widget-specific list for each type of widget * - * The global index allows us to use the @c WidgetLoader class to load any type of - * widget, which reduces the need of implementing QML-specific code for each widget - * that Serial Studio implements. + * The global index allows us to use the @c WidgetLoader class to load any type + * of widget, which reduces the need of implementing QML-specific code for each + * widget that Serial Studio implements. * - * The relative index is used by the visibility switches in the QML user interface. + * The relative index is used by the visibility switches in the QML user + * interface. * - * We need to be careful to sincronize the order of the widgets in order to allow - * the global-index system to work correctly. + * We need to be careful to sincronize the order of the widgets in order to + * allow the global-index system to work correctly. */ int UI::Dashboard::relativeIndex(const int globalIndex) const { - // - // Warning: relative widget index should be calculated using the same order as defined - // by the UI::Dashboard::widgetTitles() function. - // + // + // Warning: relative widget index should be calculated using the same order as + // defined by the UI::Dashboard::widgetTitles() function. + // - // Check if we should return group widget - int index = globalIndex; - if (index < groupCount()) - return index; + // Check if we should return group widget + int index = globalIndex; + if (index < groupCount()) + return index; - // Check if we should return multi-plot widget - index -= groupCount(); - if (index < multiPlotCount()) - return index; + // Check if we should return multi-plot widget + index -= groupCount(); + if (index < multiPlotCount()) + return index; - // Check if we should return LED widget - index -= multiPlotCount(); - if (index < ledCount()) - return index; + // Check if we should return LED widget + index -= multiPlotCount(); + if (index < ledCount()) + return index; - // Check if we should return FFT widget - index -= ledCount(); - if (index < fftCount()) - return index; + // Check if we should return FFT widget + index -= ledCount(); + if (index < fftCount()) + return index; - // Check if we should return plot widget - index -= fftCount(); - if (index < plotCount()) - return index; + // Check if we should return plot widget + index -= fftCount(); + if (index < plotCount()) + return index; - // Check if we should return bar widget - index -= plotCount(); - if (index < barCount()) - return index; + // Check if we should return bar widget + index -= plotCount(); + if (index < barCount()) + return index; - // Check if we should return gauge widget - index -= barCount(); - if (index < gaugeCount()) - return index; + // Check if we should return gauge widget + index -= barCount(); + if (index < gaugeCount()) + return index; - // Check if we should return compass widget - index -= gaugeCount(); - if (index < compassCount()) - return index; + // Check if we should return compass widget + index -= gaugeCount(); + if (index < compassCount()) + return index; - // Check if we should return gyro widget - index -= compassCount(); - if (index < gyroscopeCount()) - return index; + // Check if we should return gyro widget + index -= compassCount(); + if (index < gyroscopeCount()) + return index; - // Check if we should return accelerometer widget - index -= gyroscopeCount(); - if (index < accelerometerCount()) - return index; + // Check if we should return accelerometer widget + index -= gyroscopeCount(); + if (index < accelerometerCount()) + return index; - // Check if we should return map widget - index -= accelerometerCount(); - if (index < gpsCount()) - return index; + // Check if we should return map widget + index -= accelerometerCount(); + if (index < gpsCount()) + return index; - // Return unknown widget - return -1; + // Return unknown widget + return -1; } /** * Returns @c true if the widget with the specifed @a globalIndex should be * displayed in the QML user interface. * - * To simplify operations and user interface generation in QML, this class represents - * the widgets in two manners: + * To simplify operations and user interface generation in QML, this class + * represents the widgets in two manners: * * - A global list of all widgets * - A widget-specific list for each type of widget * - * The global index allows us to use the @c WidgetLoader class to load any type of - * widget, which reduces the need of implementing QML-specific code for each widget - * that Serial Studio implements. + * The global index allows us to use the @c WidgetLoader class to load any type + * of widget, which reduces the need of implementing QML-specific code for each + * widget that Serial Studio implements. * - * We need to be careful to sincronize the order of the widgets in order to allow - * the global-index system to work correctly. + * We need to be careful to sincronize the order of the widgets in order to + * allow the global-index system to work correctly. */ bool UI::Dashboard::widgetVisible(const int globalIndex) const { - bool visible = false; - auto index = relativeIndex(globalIndex); + bool visible = false; + auto index = relativeIndex(globalIndex); - switch (widgetType(globalIndex)) - { - case WidgetType::Group: - visible = groupVisible(index); - break; - case WidgetType::MultiPlot: - visible = multiPlotVisible(index); - break; - case WidgetType::FFT: - visible = fftVisible(index); - break; - case WidgetType::Plot: - visible = plotVisible(index); - break; - case WidgetType::Bar: - visible = barVisible(index); - break; - case WidgetType::Gauge: - visible = gaugeVisible(index); - break; - case WidgetType::Compass: - visible = compassVisible(index); - break; - case WidgetType::Gyroscope: - visible = gyroscopeVisible(index); - break; - case WidgetType::Accelerometer: - visible = accelerometerVisible(index); - break; - case WidgetType::GPS: - visible = gpsVisible(index); - break; - case WidgetType::LED: - visible = ledVisible(index); - break; - default: - visible = false; - break; - } + switch (widgetType(globalIndex)) + { + case WidgetType::Group: + visible = groupVisible(index); + break; + case WidgetType::MultiPlot: + visible = multiPlotVisible(index); + break; + case WidgetType::FFT: + visible = fftVisible(index); + break; + case WidgetType::Plot: + visible = plotVisible(index); + break; + case WidgetType::Bar: + visible = barVisible(index); + break; + case WidgetType::Gauge: + visible = gaugeVisible(index); + break; + case WidgetType::Compass: + visible = compassVisible(index); + break; + case WidgetType::Gyroscope: + visible = gyroscopeVisible(index); + break; + case WidgetType::Accelerometer: + visible = accelerometerVisible(index); + break; + case WidgetType::GPS: + visible = gpsVisible(index); + break; + case WidgetType::LED: + visible = ledVisible(index); + break; + default: + visible = false; + break; + } - return visible; + return visible; } /** - * Returns the appropiate SVG-icon to load for the widget at the specified @a globalIndex. + * Returns the appropiate SVG-icon to load for the widget at the specified @a + * globalIndex. * - * To simplify operations and user interface generation in QML, this class represents - * the widgets in two manners: + * To simplify operations and user interface generation in QML, this class + * represents the widgets in two manners: * * - A global list of all widgets * - A widget-specific list for each type of widget * - * The global index allows us to use the @c WidgetLoader class to load any type of - * widget, which reduces the need of implementing QML-specific code for each widget - * that Serial Studio implements. + * The global index allows us to use the @c WidgetLoader class to load any type + * of widget, which reduces the need of implementing QML-specific code for each + * widget that Serial Studio implements. * - * We need to be careful to sincronize the order of the widgets in order to allow - * the global-index system to work correctly. + * We need to be careful to sincronize the order of the widgets in order to + * allow the global-index system to work correctly. */ QString UI::Dashboard::widgetIcon(const int globalIndex) const { - switch (widgetType(globalIndex)) - { - case WidgetType::Group: - return "qrc:/icons/group.svg"; - break; - case WidgetType::MultiPlot: - return "qrc:/icons/multiplot.svg"; - break; - case WidgetType::FFT: - return "qrc:/icons/fft.svg"; - break; - case WidgetType::Plot: - return "qrc:/icons/plot.svg"; - break; - case WidgetType::Bar: - return "qrc:/icons/bar.svg"; - break; - case WidgetType::Gauge: - return "qrc:/icons/gauge.svg"; - break; - case WidgetType::Compass: - return "qrc:/icons/compass.svg"; - break; - case WidgetType::Gyroscope: - return "qrc:/icons/gyro.svg"; - break; - case WidgetType::Accelerometer: - return "qrc:/icons/accelerometer.svg"; - break; - case WidgetType::GPS: - return "qrc:/icons/gps.svg"; - break; - case WidgetType::LED: - return "qrc:/icons/led.svg"; - break; - default: - return "qrc:/icons/close.svg"; - break; - } + switch (widgetType(globalIndex)) + { + case WidgetType::Group: + return "qrc:/icons/group.svg"; + break; + case WidgetType::MultiPlot: + return "qrc:/icons/multiplot.svg"; + break; + case WidgetType::FFT: + return "qrc:/icons/fft.svg"; + break; + case WidgetType::Plot: + return "qrc:/icons/plot.svg"; + break; + case WidgetType::Bar: + return "qrc:/icons/bar.svg"; + break; + case WidgetType::Gauge: + return "qrc:/icons/gauge.svg"; + break; + case WidgetType::Compass: + return "qrc:/icons/compass.svg"; + break; + case WidgetType::Gyroscope: + return "qrc:/icons/gyro.svg"; + break; + case WidgetType::Accelerometer: + return "qrc:/icons/accelerometer.svg"; + break; + case WidgetType::GPS: + return "qrc:/icons/gps.svg"; + break; + case WidgetType::LED: + return "qrc:/icons/led.svg"; + break; + default: + return "qrc:/icons/close.svg"; + break; + } } /** @@ -430,87 +433,87 @@ QString UI::Dashboard::widgetIcon(const int globalIndex) const * - @c WidgetType::GPS * - @c WidgetType::LED * - * To simplify operations and user interface generation in QML, this class represents - * the widgets in two manners: + * To simplify operations and user interface generation in QML, this class + * represents the widgets in two manners: * * - A global list of all widgets * - A widget-specific list for each type of widget * - * The global index allows us to use the @c WidgetLoader class to load any type of - * widget, which reduces the need of implementing QML-specific code for each widget - * that Serial Studio implements. + * The global index allows us to use the @c WidgetLoader class to load any type + * of widget, which reduces the need of implementing QML-specific code for each + * widget that Serial Studio implements. * - * We need to be careful to sincronize the order of the widgets in order to allow - * the global-index system to work correctly. + * We need to be careful to sincronize the order of the widgets in order to + * allow the global-index system to work correctly. */ UI::Dashboard::WidgetType UI::Dashboard::widgetType(const int globalIndex) const { - // - // Warning: relative widget index should be calculated using the same order as defined - // by the UI::Dashboard::widgetTitles() function. - // + // + // Warning: relative widget index should be calculated using the same order as + // defined by the UI::Dashboard::widgetTitles() function. + // - // Unitialized widget loader class - if (globalIndex < 0) - return WidgetType::Unknown; - - // Check if we should return group widget - int index = globalIndex; - if (index < groupCount()) - return WidgetType::Group; - - // Check if we should return multi-plot widget - index -= groupCount(); - if (index < multiPlotCount()) - return WidgetType::MultiPlot; - - // Check if we should return LED widget - index -= multiPlotCount(); - if (index < ledCount()) - return WidgetType::LED; - - // Check if we should return FFT widget - index -= ledCount(); - if (index < fftCount()) - return WidgetType::FFT; - - // Check if we should return plot widget - index -= fftCount(); - if (index < plotCount()) - return WidgetType::Plot; - - // Check if we should return bar widget - index -= plotCount(); - if (index < barCount()) - return WidgetType::Bar; - - // Check if we should return gauge widget - index -= barCount(); - if (index < gaugeCount()) - return WidgetType::Gauge; - - // Check if we should return compass widget - index -= gaugeCount(); - if (index < compassCount()) - return WidgetType::Compass; - - // Check if we should return gyro widget - index -= compassCount(); - if (index < gyroscopeCount()) - return WidgetType::Gyroscope; - - // Check if we should return accelerometer widget - index -= gyroscopeCount(); - if (index < accelerometerCount()) - return WidgetType::Accelerometer; - - // Check if we should return map widget - index -= accelerometerCount(); - if (index < gpsCount()) - return WidgetType::GPS; - - // Return unknown widget + // Unitialized widget loader class + if (globalIndex < 0) return WidgetType::Unknown; + + // Check if we should return group widget + int index = globalIndex; + if (index < groupCount()) + return WidgetType::Group; + + // Check if we should return multi-plot widget + index -= groupCount(); + if (index < multiPlotCount()) + return WidgetType::MultiPlot; + + // Check if we should return LED widget + index -= multiPlotCount(); + if (index < ledCount()) + return WidgetType::LED; + + // Check if we should return FFT widget + index -= ledCount(); + if (index < fftCount()) + return WidgetType::FFT; + + // Check if we should return plot widget + index -= fftCount(); + if (index < plotCount()) + return WidgetType::Plot; + + // Check if we should return bar widget + index -= plotCount(); + if (index < barCount()) + return WidgetType::Bar; + + // Check if we should return gauge widget + index -= barCount(); + if (index < gaugeCount()) + return WidgetType::Gauge; + + // Check if we should return compass widget + index -= gaugeCount(); + if (index < compassCount()) + return WidgetType::Compass; + + // Check if we should return gyro widget + index -= compassCount(); + if (index < gyroscopeCount()) + return WidgetType::Gyroscope; + + // Check if we should return accelerometer widget + index -= gyroscopeCount(); + if (index < accelerometerCount()) + return WidgetType::Accelerometer; + + // Check if we should return map widget + index -= accelerometerCount(); + if (index < gpsCount()) + return WidgetType::GPS; + + // Return unknown widget + return WidgetType::Unknown; } //---------------------------------------------------------------------------------------- @@ -555,32 +558,32 @@ StringList UI::Dashboard::accelerometerTitles() { return groupTitles(m_accelerom void UI::Dashboard::setPoints(const int points) { - if (m_points != points) - { - // Update number of points - m_points = points; + if (m_points != points) + { + // Update number of points + m_points = points; - // Clear values - m_fftPlotValues.clear(); - m_linearPlotValues.clear(); + // Clear values + m_fftPlotValues.clear(); + m_linearPlotValues.clear(); - // Regenerate x-axis values - m_xData.resize(points); - for (int i = 0; i < points; ++i) - m_xData[i] = i; + // Regenerate x-axis values + m_xData.resize(points); + for (int i = 0; i < points; ++i) + m_xData[i] = i; - // Update plots - Q_EMIT pointsChanged(); - } + // Update plots + Q_EMIT pointsChanged(); + } } void UI::Dashboard::setPrecision(const int precision) { - if (m_precision != precision) - { - m_precision = precision; - Q_EMIT precisionChanged(); - } + if (m_precision != precision) + { + m_precision = precision; + Q_EMIT precisionChanged(); + } } //---------------------------------------------------------------------------------------- @@ -606,50 +609,50 @@ void UI::Dashboard::setAccelerometerVisible(const int i, const bool v) { setVisi //---------------------------------------------------------------------------------------- /** - * Removes all available data from the UI when the device is disconnected or the CSV - * file is closed. + * Removes all available data from the UI when the device is disconnected or the + * CSV file is closed. */ void UI::Dashboard::resetData() { - // Make latest frame invalid - m_currentFrame.read(QJsonObject {}); + // Make latest frame invalid + m_currentFrame.read(QJsonObject{}); - // Clear plot data - m_fftPlotValues.clear(); - m_linearPlotValues.clear(); + // Clear plot data + m_fftPlotValues.clear(); + m_linearPlotValues.clear(); - // Clear widget data - m_barWidgets.clear(); - m_fftWidgets.clear(); - m_gpsWidgets.clear(); - m_ledWidgets.clear(); - m_plotWidgets.clear(); - m_gaugeWidgets.clear(); - m_groupWidgets.clear(); - m_compassWidgets.clear(); - m_gyroscopeWidgets.clear(); - m_multiPlotWidgets.clear(); - m_accelerometerWidgets.clear(); + // Clear widget data + m_barWidgets.clear(); + m_fftWidgets.clear(); + m_gpsWidgets.clear(); + m_ledWidgets.clear(); + m_plotWidgets.clear(); + m_gaugeWidgets.clear(); + m_groupWidgets.clear(); + m_compassWidgets.clear(); + m_gyroscopeWidgets.clear(); + m_multiPlotWidgets.clear(); + m_accelerometerWidgets.clear(); - // Clear widget visibility data - m_barVisibility.clear(); - m_fftVisibility.clear(); - m_gpsVisibility.clear(); - m_ledVisibility.clear(); - m_plotVisibility.clear(); - m_gaugeVisibility.clear(); - m_groupVisibility.clear(); - m_compassVisibility.clear(); - m_gyroscopeVisibility.clear(); - m_multiPlotVisibility.clear(); - m_accelerometerVisibility.clear(); + // Clear widget visibility data + m_barVisibility.clear(); + m_fftVisibility.clear(); + m_gpsVisibility.clear(); + m_ledVisibility.clear(); + m_plotVisibility.clear(); + m_gaugeVisibility.clear(); + m_groupVisibility.clear(); + m_compassVisibility.clear(); + m_gyroscopeVisibility.clear(); + m_multiPlotVisibility.clear(); + m_accelerometerVisibility.clear(); - // Update UI - Q_EMIT updated(); - Q_EMIT dataReset(); - Q_EMIT titleChanged(); - Q_EMIT widgetCountChanged(); - Q_EMIT widgetVisibilityChanged(); + // Update UI + Q_EMIT updated(); + Q_EMIT dataReset(); + Q_EMIT titleChanged(); + Q_EMIT widgetCountChanged(); + Q_EMIT widgetVisibilityChanged(); } /** @@ -657,78 +660,78 @@ void UI::Dashboard::resetData() */ void UI::Dashboard::updatePlots() { - // Initialize arrays that contain pointers to the - // datasets that need to be plotted. - QVector fftDatasets; - QVector linearDatasets; + // Initialize arrays that contain pointers to the + // datasets that need to be plotted. + QVector fftDatasets; + QVector linearDatasets; - // Create list with datasets that need to be graphed - for (int i = 0; i < m_currentFrame.groupCount(); ++i) + // Create list with datasets that need to be graphed + for (int i = 0; i < m_currentFrame.groupCount(); ++i) + { + auto group = m_currentFrame.groups().at(i); + for (int j = 0; j < group.datasetCount(); ++j) { - auto group = m_currentFrame.groups().at(i); - for (int j = 0; j < group.datasetCount(); ++j) - { - auto dataset = group.getDataset(j); - if (dataset.fft()) - fftDatasets.append(dataset); - if (dataset.graph()) - linearDatasets.append(dataset); - } + auto dataset = group.getDataset(j); + if (dataset.fft()) + fftDatasets.append(dataset); + if (dataset.graph()) + linearDatasets.append(dataset); } + } - // Check if we need to update dataset points - if (m_linearPlotValues.count() != linearDatasets.count()) + // Check if we need to update dataset points + if (m_linearPlotValues.count() != linearDatasets.count()) + { + m_linearPlotValues.clear(); + + for (int i = 0; i < linearDatasets.count(); ++i) { - m_linearPlotValues.clear(); + m_linearPlotValues.append(PlotData()); + m_linearPlotValues.last().resize(points()); - for (int i = 0; i < linearDatasets.count(); ++i) - { - m_linearPlotValues.append(PlotData()); - m_linearPlotValues.last().resize(points()); - - // clang-format off + // clang-format off std::fill(m_linearPlotValues.last().begin(), m_linearPlotValues.last().end(), 0.0001); - // clang-format on - } + // clang-format on } + } - // Check if we need to update FFT dataset points - if (m_fftPlotValues.count() != fftDatasets.count()) + // Check if we need to update FFT dataset points + if (m_fftPlotValues.count() != fftDatasets.count()) + { + m_fftPlotValues.clear(); + + for (int i = 0; i < fftDatasets.count(); ++i) { - m_fftPlotValues.clear(); + m_fftPlotValues.append(PlotData()); + m_fftPlotValues.last().resize(fftDatasets[i].fftSamples()); - for (int i = 0; i < fftDatasets.count(); ++i) - { - m_fftPlotValues.append(PlotData()); - m_fftPlotValues.last().resize(fftDatasets[i].fftSamples()); - - // clang-format off + // clang-format off std::fill(m_fftPlotValues.last().begin(), m_fftPlotValues.last().end(), 0); - // clang-format on - } + // clang-format on } + } - // Append latest values to linear plot data - for (int i = 0; i < linearDatasets.count(); ++i) - { - auto data = m_linearPlotValues[i].data(); - auto count = m_linearPlotValues[i].count(); - memmove(data, data + 1, count * sizeof(double)); - m_linearPlotValues[i][count - 1] = linearDatasets[i].value().toDouble(); - } + // Append latest values to linear plot data + for (int i = 0; i < linearDatasets.count(); ++i) + { + auto data = m_linearPlotValues[i].data(); + auto count = m_linearPlotValues[i].count(); + memmove(data, data + 1, count * sizeof(double)); + m_linearPlotValues[i][count - 1] = linearDatasets[i].value().toDouble(); + } - // Append latest values to FFT plot data - for (int i = 0; i < fftDatasets.count(); ++i) - { - auto data = m_fftPlotValues[i].data(); - auto count = m_fftPlotValues[i].count(); - memmove(data, data + 1, count * sizeof(double)); - m_fftPlotValues[i][count - 1] = fftDatasets[i].value().toDouble(); - } + // Append latest values to FFT plot data + for (int i = 0; i < fftDatasets.count(); ++i) + { + auto data = m_fftPlotValues[i].data(); + auto count = m_fftPlotValues[i].count(); + memmove(data, data + 1, count * sizeof(double)); + m_fftPlotValues[i][count - 1] = fftDatasets[i].value().toDouble(); + } } /** @@ -736,100 +739,101 @@ void UI::Dashboard::updatePlots() */ void UI::Dashboard::processLatestJSON(const QJsonObject &json) { - // Save widget count - const int barC = barCount(); - const int fftC = fftCount(); - const int gpsC = gpsCount(); - const int ledC = ledCount(); - const int plotC = plotCount(); - const int groupC = groupCount(); - const int gaugeC = gaugeCount(); - const int compassC = compassCount(); - const int gyroscopeC = gyroscopeCount(); - const int multiPlotC = multiPlotCount(); - const int accelerometerC = accelerometerCount(); + // Save widget count + const int barC = barCount(); + const int fftC = fftCount(); + const int gpsC = gpsCount(); + const int ledC = ledCount(); + const int plotC = plotCount(); + const int groupC = groupCount(); + const int gaugeC = gaugeCount(); + const int compassC = compassCount(); + const int gyroscopeC = gyroscopeCount(); + const int multiPlotC = multiPlotCount(); + const int accelerometerC = accelerometerCount(); - // Save previous title - auto pTitle = title(); + // Save previous title + auto pTitle = title(); - // Try to read latest frame for widget updating - if (!m_currentFrame.read(json)) - return; + // Try to read latest frame for widget updating + if (!m_currentFrame.read(json)) + return; - // Regenerate plot data - updatePlots(); + // Regenerate plot data + updatePlots(); - // Update widget vectors - m_fftWidgets = getFFTWidgets(); - m_ledWidgets = getLEDWidgets(); - m_plotWidgets = getPlotWidgets(); - m_groupWidgets = getWidgetGroups(""); - m_gpsWidgets = getWidgetGroups("map"); - m_barWidgets = getWidgetDatasets("bar"); - m_gaugeWidgets = getWidgetDatasets("gauge"); - m_gyroscopeWidgets = getWidgetGroups("gyro"); - m_compassWidgets = getWidgetDatasets("compass"); - m_multiPlotWidgets = getWidgetGroups("multiplot"); - m_accelerometerWidgets = getWidgetGroups("accelerometer"); + // Update widget vectors + m_fftWidgets = getFFTWidgets(); + m_ledWidgets = getLEDWidgets(); + m_plotWidgets = getPlotWidgets(); + m_groupWidgets = getWidgetGroups(""); + m_gpsWidgets = getWidgetGroups("map"); + m_barWidgets = getWidgetDatasets("bar"); + m_gaugeWidgets = getWidgetDatasets("gauge"); + m_gyroscopeWidgets = getWidgetGroups("gyro"); + m_compassWidgets = getWidgetDatasets("compass"); + m_multiPlotWidgets = getWidgetGroups("multiplot"); + m_accelerometerWidgets = getWidgetGroups("accelerometer"); - // Add accelerometer widgets to multiplot - for (int i = 0; i < m_accelerometerWidgets.count(); ++i) - m_multiPlotWidgets.append(m_accelerometerWidgets.at(i)); + // Add accelerometer widgets to multiplot + for (int i = 0; i < m_accelerometerWidgets.count(); ++i) + m_multiPlotWidgets.append(m_accelerometerWidgets.at(i)); - // Add gyroscope widgets to multiplot - for (int i = 0; i < m_gyroscopeWidgets.count(); ++i) - m_multiPlotWidgets.append(m_gyroscopeWidgets.at(i)); + // Add gyroscope widgets to multiplot + for (int i = 0; i < m_gyroscopeWidgets.count(); ++i) + m_multiPlotWidgets.append(m_gyroscopeWidgets.at(i)); - // Check if we need to update title - if (pTitle != title()) - Q_EMIT titleChanged(); + // Check if we need to update title + if (pTitle != title()) + Q_EMIT titleChanged(); - // Check if we need to regenerate widgets - bool regenerateWidgets = false; - regenerateWidgets |= (barC != barCount()); - regenerateWidgets |= (fftC != fftCount()); - regenerateWidgets |= (gpsC != gpsCount()); - regenerateWidgets |= (ledC != ledCount()); - regenerateWidgets |= (plotC != plotCount()); - regenerateWidgets |= (gaugeC != gaugeCount()); - regenerateWidgets |= (groupC != groupCount()); - regenerateWidgets |= (compassC != compassCount()); - regenerateWidgets |= (gyroscopeC != gyroscopeCount()); - regenerateWidgets |= (multiPlotC != multiPlotCount()); - regenerateWidgets |= (accelerometerC != accelerometerCount()); + // Check if we need to regenerate widgets + bool regenerateWidgets = false; + regenerateWidgets |= (barC != barCount()); + regenerateWidgets |= (fftC != fftCount()); + regenerateWidgets |= (gpsC != gpsCount()); + regenerateWidgets |= (ledC != ledCount()); + regenerateWidgets |= (plotC != plotCount()); + regenerateWidgets |= (gaugeC != gaugeCount()); + regenerateWidgets |= (groupC != groupCount()); + regenerateWidgets |= (compassC != compassCount()); + regenerateWidgets |= (gyroscopeC != gyroscopeCount()); + regenerateWidgets |= (multiPlotC != multiPlotCount()); + regenerateWidgets |= (accelerometerC != accelerometerCount()); - // Regenerate widget visiblity models - if (regenerateWidgets) - { - m_barVisibility.resize(barCount()); - m_fftVisibility.resize(fftCount()); - m_gpsVisibility.resize(gpsCount()); - m_ledVisibility.resize(ledCount()); - m_plotVisibility.resize(plotCount()); - m_gaugeVisibility.resize(gaugeCount()); - m_groupVisibility.resize(groupCount()); - m_compassVisibility.resize(compassCount()); - m_gyroscopeVisibility.resize(gyroscopeCount()); - m_multiPlotVisibility.resize(multiPlotCount()); - m_accelerometerVisibility.resize(accelerometerCount()); - std::fill(m_barVisibility.begin(), m_barVisibility.end(), 1); - std::fill(m_fftVisibility.begin(), m_fftVisibility.end(), 1); - std::fill(m_gpsVisibility.begin(), m_gpsVisibility.end(), 1); - std::fill(m_ledVisibility.begin(), m_ledVisibility.end(), 1); - std::fill(m_plotVisibility.begin(), m_plotVisibility.end(), 1); - std::fill(m_gaugeVisibility.begin(), m_gaugeVisibility.end(), 1); - std::fill(m_groupVisibility.begin(), m_groupVisibility.end(), 1); - std::fill(m_compassVisibility.begin(), m_compassVisibility.end(), 1); - std::fill(m_gyroscopeVisibility.begin(), m_gyroscopeVisibility.end(), 1); - std::fill(m_multiPlotVisibility.begin(), m_multiPlotVisibility.end(), 1); - std::fill(m_accelerometerVisibility.begin(), m_accelerometerVisibility.end(), 1); + // Regenerate widget visiblity models + if (regenerateWidgets) + { + m_barVisibility.resize(barCount()); + m_fftVisibility.resize(fftCount()); + m_gpsVisibility.resize(gpsCount()); + m_ledVisibility.resize(ledCount()); + m_plotVisibility.resize(plotCount()); + m_gaugeVisibility.resize(gaugeCount()); + m_groupVisibility.resize(groupCount()); + m_compassVisibility.resize(compassCount()); + m_gyroscopeVisibility.resize(gyroscopeCount()); + m_multiPlotVisibility.resize(multiPlotCount()); + m_accelerometerVisibility.resize(accelerometerCount()); + std::fill(m_barVisibility.begin(), m_barVisibility.end(), 1); + std::fill(m_fftVisibility.begin(), m_fftVisibility.end(), 1); + std::fill(m_gpsVisibility.begin(), m_gpsVisibility.end(), 1); + std::fill(m_ledVisibility.begin(), m_ledVisibility.end(), 1); + std::fill(m_plotVisibility.begin(), m_plotVisibility.end(), 1); + std::fill(m_gaugeVisibility.begin(), m_gaugeVisibility.end(), 1); + std::fill(m_groupVisibility.begin(), m_groupVisibility.end(), 1); + std::fill(m_compassVisibility.begin(), m_compassVisibility.end(), 1); + std::fill(m_gyroscopeVisibility.begin(), m_gyroscopeVisibility.end(), 1); + std::fill(m_multiPlotVisibility.begin(), m_multiPlotVisibility.end(), 1); + std::fill(m_accelerometerVisibility.begin(), + m_accelerometerVisibility.end(), 1); - Q_EMIT widgetCountChanged(); - Q_EMIT widgetVisibilityChanged(); - } + Q_EMIT widgetCountChanged(); + Q_EMIT widgetVisibilityChanged(); + } - // Update UI; - Q_EMIT updated(); + // Update UI; + Q_EMIT updated(); } //---------------------------------------------------------------------------------------- @@ -837,57 +841,59 @@ void UI::Dashboard::processLatestJSON(const QJsonObject &json) //---------------------------------------------------------------------------------------- /** - * Returns a group with all the datasets that need to be shown in the LED status panel. + * Returns a group with all the datasets that need to be shown in the LED status + * panel. * - * @note We return a vector with a single group item because we want to display a title on - * the window without breaking the current software architecture. + * @note We return a vector with a single group item because we want to display + * a title on the window without breaking the current software architecture. */ QVector UI::Dashboard::getLEDWidgets() { - QVector widgets; - Q_FOREACH (auto group, m_currentFrame.groups()) + QVector widgets; + Q_FOREACH (auto group, m_currentFrame.groups()) + { + Q_FOREACH (auto dataset, group.datasets()) { - Q_FOREACH (auto dataset, group.datasets()) - { - if (dataset.led()) - { - dataset.setTitle(dataset.title() + " (" + group.title() + ")"); - widgets.append(dataset); - } - } + if (dataset.led()) + { + dataset.setTitle(dataset.title() + " (" + group.title() + ")"); + widgets.append(dataset); + } } + } - QVector groups; - if (widgets.count() > 0) - { - JSON::Group group; - group.m_title = tr("Status Panel"); - group.m_datasets = widgets; - groups.append(group); - } + QVector groups; + if (widgets.count() > 0) + { + JSON::Group group; + group.m_title = tr("Status Panel"); + group.m_datasets = widgets; + groups.append(group); + } - return groups; + return groups; } /** - * Returns a vector with all the datasets that need to be shown in the FFT widgets. + * Returns a vector with all the datasets that need to be shown in the FFT + * widgets. */ QVector UI::Dashboard::getFFTWidgets() { - QVector widgets; - Q_FOREACH (auto group, m_currentFrame.groups()) + QVector widgets; + Q_FOREACH (auto group, m_currentFrame.groups()) + { + Q_FOREACH (auto dataset, group.datasets()) { - Q_FOREACH (auto dataset, group.datasets()) - { - if (dataset.fft()) - { - dataset.setTitle(dataset.title() + " (" + group.title() + ")"); - widgets.append(dataset); - } - } + if (dataset.fft()) + { + dataset.setTitle(dataset.title() + " (" + group.title() + ")"); + widgets.append(dataset); + } } + } - return widgets; + return widgets; } /** @@ -895,58 +901,60 @@ QVector UI::Dashboard::getFFTWidgets() */ QVector UI::Dashboard::getPlotWidgets() { - QVector widgets; - Q_FOREACH (auto group, m_currentFrame.groups()) + QVector widgets; + Q_FOREACH (auto group, m_currentFrame.groups()) + { + Q_FOREACH (auto dataset, group.datasets()) { - Q_FOREACH (auto dataset, group.datasets()) - { - if (dataset.graph()) - { - dataset.setTitle(dataset.title() + " (" + group.title() + ")"); - widgets.append(dataset); - } - } + if (dataset.graph()) + { + dataset.setTitle(dataset.title() + " (" + group.title() + ")"); + widgets.append(dataset); + } } + } - return widgets; + return widgets; } /** - * Returns a vector with all the groups that implement the widget with the specied + * Returns a vector with all the groups that implement the widget with the + * specied * @a handle. */ QVector UI::Dashboard::getWidgetGroups(const QString &handle) { - QVector widgets; - Q_FOREACH (auto group, m_currentFrame.groups()) - { - if (group.widget() == handle) - widgets.append(group); - } + QVector widgets; + Q_FOREACH (auto group, m_currentFrame.groups()) + { + if (group.widget() == handle) + widgets.append(group); + } - return widgets; + return widgets; } /** - * Returns a vector with all the datasets that implement a widget with the specified + * Returns a vector with all the datasets that implement a widget with the + * specified * @a handle. */ QVector UI::Dashboard::getWidgetDatasets(const QString &handle) { - QVector widgets; - Q_FOREACH (auto group, m_currentFrame.groups()) + QVector widgets; + Q_FOREACH (auto group, m_currentFrame.groups()) + { + Q_FOREACH (auto dataset, group.datasets()) { - Q_FOREACH (auto dataset, group.datasets()) - { - if (dataset.widget() == handle) - { - dataset.setTitle(dataset.title() + " (" + group.title() + ")"); - widgets.append(dataset); - } - } + if (dataset.widget() == handle) + { + dataset.setTitle(dataset.title() + " (" + group.title() + ")"); + widgets.append(dataset); + } } + } - return widgets; + return widgets; } /** @@ -954,11 +962,11 @@ QVector UI::Dashboard::getWidgetDatasets(const QString &handle) */ StringList UI::Dashboard::datasetTitles(const QVector &vector) { - StringList list; - Q_FOREACH (auto set, vector) - list.append(set.title()); + StringList list; + Q_FOREACH (auto set, vector) + list.append(set.title()); - return list; + return list; } /** @@ -966,34 +974,31 @@ StringList UI::Dashboard::datasetTitles(const QVector &vector) */ StringList UI::Dashboard::groupTitles(const QVector &vector) { - StringList list; - Q_FOREACH (auto group, vector) - list.append(group.title()); + StringList list; + Q_FOREACH (auto group, vector) + list.append(group.title()); - return list; + return list; } /** - * Returns @c true if the widget at the specifed @a index of the @a vector should be - * displayed in the QML user interface. + * Returns @c true if the widget at the specifed @a index of the @a vector + * should be displayed in the QML user interface. */ -bool UI::Dashboard::getVisibility(const QVector &vector, const int index) const +bool UI::Dashboard::getVisibility(const QVector &vector, + const int index) const { - return vector[index]; + return vector[index]; } /** - * Changes the @a visible flag of the widget at the specified @a index of the given @a - * vector. Calling this function with @a visible set to @c false will hide the widget in - * the QML user interface. + * Changes the @a visible flag of the widget at the specified @a index of the + * given @a vector. Calling this function with @a visible set to @c false will + * hide the widget in the QML user interface. */ void UI::Dashboard::setVisibility(QVector &vector, const int index, const bool visible) { - vector[index] = visible; - Q_EMIT widgetVisibilityChanged(); + vector[index] = visible; + Q_EMIT widgetVisibilityChanged(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Dashboard.cpp" -#endif diff --git a/src/UI/Dashboard.h b/src/UI/Dashboard.h index 96b37aa2..f0c5009f 100644 --- a/src/UI/Dashboard.h +++ b/src/UI/Dashboard.h @@ -32,12 +32,13 @@ namespace UI /** * @brief The Dashboard class * - * The @c Dashboard class receives data from the @c JSON::Generator class and builds the - * vector modules used by the QML user interface and the C++ widgets to display the - * current frame. + * The @c Dashboard class receives data from the @c JSON::Generator class and + * builds the vector modules used by the QML user interface and the C++ widgets + * to display the current frame. * - * This class is very large, but its really simple to understand. Most of the code here is - * repeated in order to support all the widgets implemented by Serial Studio. + * This class is very large, but its really simple to understand. Most of the + * code here is repeated in order to support all the widgets implemented by + * Serial Studio. * * The important functions are: * @@ -52,12 +53,12 @@ namespace UI * - @c Dashboard::getWidgetDatasets() * - @c Dashboard::processLatestJSON() * - * The rest of the functions of this class rely on the procedures above in order to - * implement common functionality features for each widget type. + * The rest of the functions of this class rely on the procedures above in order + * to implement common functionality features for each widget type. */ class Dashboard : public QObject { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(QString title READ title @@ -142,177 +143,178 @@ class Dashboard : public QObject Q_PROPERTY(StringList accelerometerTitles READ accelerometerTitles NOTIFY widgetCountChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void updated(); - void dataReset(); - void titleChanged(); - void pointsChanged(); - void precisionChanged(); - void widgetCountChanged(); - void widgetVisibilityChanged(); + void updated(); + void dataReset(); + void titleChanged(); + void pointsChanged(); + void precisionChanged(); + void widgetCountChanged(); + void widgetVisibilityChanged(); private: - explicit Dashboard(); - Dashboard(Dashboard &&) = delete; - Dashboard(const Dashboard &) = delete; - Dashboard &operator=(Dashboard &&) = delete; - Dashboard &operator=(const Dashboard &) = delete; + explicit Dashboard(); + Dashboard(Dashboard &&) = delete; + Dashboard(const Dashboard &) = delete; + Dashboard &operator=(Dashboard &&) = delete; + Dashboard &operator=(const Dashboard &) = delete; public: - enum class WidgetType - { - Group, - MultiPlot, - FFT, - Plot, - Bar, - Gauge, - Compass, - Gyroscope, - Accelerometer, - GPS, - LED, - Unknown - }; - Q_ENUM(WidgetType) + enum class WidgetType + { + Group, + MultiPlot, + FFT, + Plot, + Bar, + Gauge, + Compass, + Gyroscope, + Accelerometer, + GPS, + LED, + Unknown + }; + Q_ENUM(WidgetType) - static Dashboard &instance(); + static Dashboard &instance(); - QFont monoFont() const; - const JSON::Group &getLED(const int index) const; - const JSON::Group &getGPS(const int index) const; - const JSON::Dataset &getFFT(const int index) const; - const JSON::Dataset &getBar(const int index) const; - const JSON::Group &getGroups(const int index) const; - const JSON::Dataset &getPlot(const int index) const; - const JSON::Dataset &getGauge(const int index) const; - const JSON::Group &getGyroscope(const int index) const; - const JSON::Dataset &getCompass(const int index) const; - const JSON::Group &getMultiplot(const int index) const; - const JSON::Group &getAccelerometer(const int index) const; + QFont monoFont() const; + const JSON::Group &getLED(const int index) const; + const JSON::Group &getGPS(const int index) const; + const JSON::Dataset &getFFT(const int index) const; + const JSON::Dataset &getBar(const int index) const; + const JSON::Group &getGroups(const int index) const; + const JSON::Dataset &getPlot(const int index) const; + const JSON::Dataset &getGauge(const int index) const; + const JSON::Group &getGyroscope(const int index) const; + const JSON::Dataset &getCompass(const int index) const; + const JSON::Group &getMultiplot(const int index) const; + const JSON::Group &getAccelerometer(const int index) const; - QString title(); - bool available(); - int points() const; - int precision() const; + QString title(); + bool available(); + int points() const; + int precision() const; - int totalWidgetCount() const; - int gpsCount() const; - int ledCount() const; - int fftCount() const; - int barCount() const; - int plotCount() const; - int groupCount() const; - int gaugeCount() const; - int compassCount() const; - int gyroscopeCount() const; - int multiPlotCount() const; - int accelerometerCount() const; + int totalWidgetCount() const; + int gpsCount() const; + int ledCount() const; + int fftCount() const; + int barCount() const; + int plotCount() const; + int groupCount() const; + int gaugeCount() const; + int compassCount() const; + int gyroscopeCount() const; + int multiPlotCount() const; + int accelerometerCount() const; - Q_INVOKABLE bool frameValid() const; - Q_INVOKABLE StringList widgetTitles(); - Q_INVOKABLE int relativeIndex(const int globalIndex) const; - Q_INVOKABLE bool widgetVisible(const int globalIndex) const; - Q_INVOKABLE QString widgetIcon(const int globalIndex) const; - Q_INVOKABLE UI::Dashboard::WidgetType widgetType(const int globalIndex) const; + Q_INVOKABLE bool frameValid() const; + Q_INVOKABLE StringList widgetTitles(); + Q_INVOKABLE int relativeIndex(const int globalIndex) const; + Q_INVOKABLE bool widgetVisible(const int globalIndex) const; + Q_INVOKABLE QString widgetIcon(const int globalIndex) const; + Q_INVOKABLE UI::Dashboard::WidgetType widgetType(const int globalIndex) const; - Q_INVOKABLE bool barVisible(const int index) const; - Q_INVOKABLE bool fftVisible(const int index) const; - Q_INVOKABLE bool gpsVisible(const int index) const; - Q_INVOKABLE bool ledVisible(const int index) const; - Q_INVOKABLE bool plotVisible(const int index) const; - Q_INVOKABLE bool groupVisible(const int index) const; - Q_INVOKABLE bool gaugeVisible(const int index) const; - Q_INVOKABLE bool compassVisible(const int index) const; - Q_INVOKABLE bool gyroscopeVisible(const int index) const; - Q_INVOKABLE bool multiPlotVisible(const int index) const; - Q_INVOKABLE bool accelerometerVisible(const int index) const; + Q_INVOKABLE bool barVisible(const int index) const; + Q_INVOKABLE bool fftVisible(const int index) const; + Q_INVOKABLE bool gpsVisible(const int index) const; + Q_INVOKABLE bool ledVisible(const int index) const; + Q_INVOKABLE bool plotVisible(const int index) const; + Q_INVOKABLE bool groupVisible(const int index) const; + Q_INVOKABLE bool gaugeVisible(const int index) const; + Q_INVOKABLE bool compassVisible(const int index) const; + Q_INVOKABLE bool gyroscopeVisible(const int index) const; + Q_INVOKABLE bool multiPlotVisible(const int index) const; + Q_INVOKABLE bool accelerometerVisible(const int index) const; - StringList barTitles(); - StringList fftTitles(); - StringList gpsTitles(); - StringList ledTitles(); - StringList plotTitles(); - StringList groupTitles(); - StringList gaugeTitles(); - StringList compassTitles(); - StringList gyroscopeTitles(); - StringList multiPlotTitles(); - StringList accelerometerTitles(); + StringList barTitles(); + StringList fftTitles(); + StringList gpsTitles(); + StringList ledTitles(); + StringList plotTitles(); + StringList groupTitles(); + StringList gaugeTitles(); + StringList compassTitles(); + StringList gyroscopeTitles(); + StringList multiPlotTitles(); + StringList accelerometerTitles(); - const PlotData &xPlotValues() { return m_xData; } - const JSON::Frame ¤tFrame() { return m_currentFrame; } - const QVector &fftPlotValues() { return m_fftPlotValues; } - const QVector &linearPlotValues() { return m_linearPlotValues; } + const PlotData &xPlotValues() { return m_xData; } + const JSON::Frame ¤tFrame() { return m_currentFrame; } + const QVector &fftPlotValues() { return m_fftPlotValues; } + const QVector &linearPlotValues() { return m_linearPlotValues; } public Q_SLOTS: - void setPoints(const int points); - void setPrecision(const int precision); - void setBarVisible(const int index, const bool visible); - void setFFTVisible(const int index, const bool visible); - void setGpsVisible(const int index, const bool visible); - void setLedVisible(const int index, const bool visible); - void setPlotVisible(const int index, const bool visible); - void setGroupVisible(const int index, const bool visible); - void setGaugeVisible(const int index, const bool visible); - void setCompassVisible(const int index, const bool visible); - void setGyroscopeVisible(const int index, const bool visible); - void setMultiplotVisible(const int index, const bool visible); - void setAccelerometerVisible(const int index, const bool visible); + void setPoints(const int points); + void setPrecision(const int precision); + void setBarVisible(const int index, const bool visible); + void setFFTVisible(const int index, const bool visible); + void setGpsVisible(const int index, const bool visible); + void setLedVisible(const int index, const bool visible); + void setPlotVisible(const int index, const bool visible); + void setGroupVisible(const int index, const bool visible); + void setGaugeVisible(const int index, const bool visible); + void setCompassVisible(const int index, const bool visible); + void setGyroscopeVisible(const int index, const bool visible); + void setMultiplotVisible(const int index, const bool visible); + void setAccelerometerVisible(const int index, const bool visible); private Q_SLOTS: - void resetData(); - void updatePlots(); - void processLatestJSON(const QJsonObject &json); + void resetData(); + void updatePlots(); + void processLatestJSON(const QJsonObject &json); private: - QVector getLEDWidgets(); - QVector getFFTWidgets(); - QVector getPlotWidgets(); - QVector getWidgetGroups(const QString &handle); - QVector getWidgetDatasets(const QString &handle); + QVector getLEDWidgets(); + QVector getFFTWidgets(); + QVector getPlotWidgets(); + QVector getWidgetGroups(const QString &handle); + QVector getWidgetDatasets(const QString &handle); - StringList groupTitles(const QVector &vector); - StringList datasetTitles(const QVector &vector); + StringList groupTitles(const QVector &vector); + StringList datasetTitles(const QVector &vector); - bool getVisibility(const QVector &vector, const int index) const; - void setVisibility(QVector &vector, const int index, const bool visible); + bool getVisibility(const QVector &vector, const int index) const; + void setVisibility(QVector &vector, const int index, + const bool visible); private: - int m_points; - int m_precision; - PlotData m_xData; - QVector m_fftPlotValues; - QVector m_linearPlotValues; - QVector> m_multiplotValues; + int m_points; + int m_precision; + PlotData m_xData; + QVector m_fftPlotValues; + QVector m_linearPlotValues; + QVector> m_multiplotValues; - QVector m_barVisibility; - QVector m_fftVisibility; - QVector m_gpsVisibility; - QVector m_ledVisibility; - QVector m_plotVisibility; - QVector m_groupVisibility; - QVector m_gaugeVisibility; - QVector m_compassVisibility; - QVector m_gyroscopeVisibility; - QVector m_multiPlotVisibility; - QVector m_accelerometerVisibility; + QVector m_barVisibility; + QVector m_fftVisibility; + QVector m_gpsVisibility; + QVector m_ledVisibility; + QVector m_plotVisibility; + QVector m_groupVisibility; + QVector m_gaugeVisibility; + QVector m_compassVisibility; + QVector m_gyroscopeVisibility; + QVector m_multiPlotVisibility; + QVector m_accelerometerVisibility; - QVector m_barWidgets; - QVector m_fftWidgets; - QVector m_plotWidgets; - QVector m_gaugeWidgets; - QVector m_compassWidgets; + QVector m_barWidgets; + QVector m_fftWidgets; + QVector m_plotWidgets; + QVector m_gaugeWidgets; + QVector m_compassWidgets; - QVector m_ledWidgets; - QVector m_gpsWidgets; - QVector m_groupWidgets; - QVector m_multiPlotWidgets; - QVector m_gyroscopeWidgets; - QVector m_accelerometerWidgets; + QVector m_ledWidgets; + QVector m_gpsWidgets; + QVector m_groupWidgets; + QVector m_multiPlotWidgets; + QVector m_gyroscopeWidgets; + QVector m_accelerometerWidgets; - JSON::Frame m_currentFrame; + JSON::Frame m_currentFrame; }; -} +} // namespace UI diff --git a/src/UI/DashboardWidget.cpp b/src/UI/DashboardWidget.cpp index aebbdd91..7a981cf5 100644 --- a/src/UI/DashboardWidget.cpp +++ b/src/UI/DashboardWidget.cpp @@ -39,16 +39,16 @@ * Constructor function */ UI::DashboardWidget::DashboardWidget(QQuickItem *parent) - : DeclarativeWidget(parent) - , m_index(-1) - , m_isGpsMap(false) - , m_widgetVisible(false) - , m_isExternalWindow(false) + : DeclarativeWidget(parent) + , m_index(-1) + , m_isGpsMap(false) + , m_widgetVisible(false) + , m_isExternalWindow(false) { - // clang-format off + // clang-format off connect(&UI::Dashboard::instance(), &UI::Dashboard::widgetVisibilityChanged, this, &UI::DashboardWidget::updateWidgetVisible); - // clang-format on + // clang-format on } /** @@ -56,26 +56,26 @@ UI::DashboardWidget::DashboardWidget(QQuickItem *parent) */ UI::DashboardWidget::~DashboardWidget() { - if (m_dbWidget) - m_dbWidget->deleteLater(); + if (m_dbWidget) + m_dbWidget->deleteLater(); } /** - * Returns the global index of the widget (index of the current widget in relation to all - * registered widgets). + * Returns the global index of the widget (index of the current widget in + * relation to all registered widgets). */ int UI::DashboardWidget::widgetIndex() const { - return m_index; + return m_index; } /** - * Returns the relative index of the widget (e.g. index of a bar widget in relation to the - * total number of bar widgets). + * Returns the relative index of the widget (e.g. index of a bar widget in + * relation to the total number of bar widgets). */ int UI::DashboardWidget::relativeIndex() const { - return UI::Dashboard::instance().relativeIndex(widgetIndex()); + return UI::Dashboard::instance().relativeIndex(widgetIndex()); } /** @@ -83,7 +83,7 @@ int UI::DashboardWidget::relativeIndex() const */ bool UI::DashboardWidget::widgetVisible() const { - return m_widgetVisible; + return m_widgetVisible; } /** @@ -91,7 +91,7 @@ bool UI::DashboardWidget::widgetVisible() const */ QString UI::DashboardWidget::widgetIcon() const { - return UI::Dashboard::instance().widgetIcon(widgetIndex()); + return UI::Dashboard::instance().widgetIcon(widgetIndex()); } /** @@ -99,14 +99,14 @@ QString UI::DashboardWidget::widgetIcon() const */ QString UI::DashboardWidget::widgetTitle() const { - if (widgetIndex() >= 0) - { - auto titles = UI::Dashboard::instance().widgetTitles(); - if (widgetIndex() < titles.count()) - return titles.at(widgetIndex()); - } + if (widgetIndex() >= 0) + { + auto titles = UI::Dashboard::instance().widgetTitles(); + if (widgetIndex() < titles.count()) + return titles.at(widgetIndex()); + } - return tr("Invalid"); + return tr("Invalid"); } /** @@ -118,7 +118,7 @@ QString UI::DashboardWidget::widgetTitle() const */ bool UI::DashboardWidget::isExternalWindow() const { - return m_isExternalWindow; + return m_isExternalWindow; } /** @@ -126,7 +126,7 @@ bool UI::DashboardWidget::isExternalWindow() const */ UI::Dashboard::WidgetType UI::DashboardWidget::widgetType() const { - return UI::Dashboard::instance().widgetType(widgetIndex()); + return UI::Dashboard::instance().widgetType(widgetIndex()); } /** @@ -151,7 +151,7 @@ UI::Dashboard::WidgetType UI::DashboardWidget::widgetType() const */ bool UI::DashboardWidget::isGpsMap() const { - return m_isGpsMap; + return m_isGpsMap; } /** @@ -160,10 +160,10 @@ bool UI::DashboardWidget::isGpsMap() const */ qreal UI::DashboardWidget::gpsAltitude() const { - if (isGpsMap() && m_dbWidget) - return static_cast(m_dbWidget)->altitude(); + if (isGpsMap() && m_dbWidget) + return static_cast(m_dbWidget)->altitude(); - return 0; + return 0; } /** @@ -172,10 +172,10 @@ qreal UI::DashboardWidget::gpsAltitude() const */ qreal UI::DashboardWidget::gpsLatitude() const { - if (isGpsMap() && m_dbWidget) - return static_cast(m_dbWidget)->latitude(); + if (isGpsMap() && m_dbWidget) + return static_cast(m_dbWidget)->latitude(); - return 0; + return 0; } /** @@ -184,10 +184,10 @@ qreal UI::DashboardWidget::gpsLatitude() const */ qreal UI::DashboardWidget::gpsLongitude() const { - if (isGpsMap() && m_dbWidget) - return static_cast(m_dbWidget)->longitude(); + if (isGpsMap() && m_dbWidget) + return static_cast(m_dbWidget)->longitude(); - return 0; + return 0; } /** @@ -195,11 +195,11 @@ qreal UI::DashboardWidget::gpsLongitude() const */ void UI::DashboardWidget::setVisible(const bool visible) { - if (m_dbWidget) - { - m_dbWidget->setEnabled(visible); - update(); - } + if (m_dbWidget) + { + m_dbWidget->setEnabled(visible); + update(); + } } /** @@ -207,78 +207,77 @@ void UI::DashboardWidget::setVisible(const bool visible) */ void UI::DashboardWidget::setWidgetIndex(const int index) { - if (index < UI::Dashboard::instance().totalWidgetCount() && index >= 0) + if (index < UI::Dashboard::instance().totalWidgetCount() && index >= 0) + { + // Update widget index + m_index = index; + + // Delete previous widget + if (m_dbWidget) { - // Update widget index - m_index = index; - - // Delete previous widget - if (m_dbWidget) - { - m_dbWidget->deleteLater(); - m_dbWidget = nullptr; - } - - // Initialize the GPS indicator flag to false by default - m_isGpsMap = false; - - // Construct new widget - switch (widgetType()) - { - case UI::Dashboard::WidgetType::Group: - m_dbWidget = new Widgets::DataGroup(relativeIndex()); - break; - case UI::Dashboard::WidgetType::MultiPlot: - m_dbWidget = new Widgets::MultiPlot(relativeIndex()); - break; - case UI::Dashboard::WidgetType::FFT: - m_dbWidget = new Widgets::FFTPlot(relativeIndex()); - break; - case UI::Dashboard::WidgetType::Plot: - m_dbWidget = new Widgets::Plot(relativeIndex()); - break; - case UI::Dashboard::WidgetType::Bar: - m_dbWidget = new Widgets::Bar(relativeIndex()); - break; - case UI::Dashboard::WidgetType::Gauge: - m_dbWidget = new Widgets::Gauge(relativeIndex()); - break; - case UI::Dashboard::WidgetType::Compass: - m_dbWidget = new Widgets::Compass(relativeIndex()); - break; - case UI::Dashboard::WidgetType::Gyroscope: - m_dbWidget = new Widgets::Gyroscope(relativeIndex()); - break; - case UI::Dashboard::WidgetType::Accelerometer: - m_dbWidget = new Widgets::Accelerometer(relativeIndex()); - break; - case UI::Dashboard::WidgetType::GPS: - m_isGpsMap = true; - m_dbWidget = new Widgets::GPS(relativeIndex()); - break; - case UI::Dashboard::WidgetType::LED: - m_dbWidget = new Widgets::LEDPanel(relativeIndex()); - break; - default: - break; - } - - // Configure widget - if (m_dbWidget) - { - setWidget(m_dbWidget); - updateWidgetVisible(); - connect(m_dbWidget, &Widgets::DashboardWidgetBase::updated, this, - [=]() { - if (!isGpsMap()) - update(); - else - Q_EMIT gpsDataChanged(); - }); - - Q_EMIT widgetIndexChanged(); - } + m_dbWidget->deleteLater(); + m_dbWidget = nullptr; } + + // Initialize the GPS indicator flag to false by default + m_isGpsMap = false; + + // Construct new widget + switch (widgetType()) + { + case UI::Dashboard::WidgetType::Group: + m_dbWidget = new Widgets::DataGroup(relativeIndex()); + break; + case UI::Dashboard::WidgetType::MultiPlot: + m_dbWidget = new Widgets::MultiPlot(relativeIndex()); + break; + case UI::Dashboard::WidgetType::FFT: + m_dbWidget = new Widgets::FFTPlot(relativeIndex()); + break; + case UI::Dashboard::WidgetType::Plot: + m_dbWidget = new Widgets::Plot(relativeIndex()); + break; + case UI::Dashboard::WidgetType::Bar: + m_dbWidget = new Widgets::Bar(relativeIndex()); + break; + case UI::Dashboard::WidgetType::Gauge: + m_dbWidget = new Widgets::Gauge(relativeIndex()); + break; + case UI::Dashboard::WidgetType::Compass: + m_dbWidget = new Widgets::Compass(relativeIndex()); + break; + case UI::Dashboard::WidgetType::Gyroscope: + m_dbWidget = new Widgets::Gyroscope(relativeIndex()); + break; + case UI::Dashboard::WidgetType::Accelerometer: + m_dbWidget = new Widgets::Accelerometer(relativeIndex()); + break; + case UI::Dashboard::WidgetType::GPS: + m_isGpsMap = true; + m_dbWidget = new Widgets::GPS(relativeIndex()); + break; + case UI::Dashboard::WidgetType::LED: + m_dbWidget = new Widgets::LEDPanel(relativeIndex()); + break; + default: + break; + } + + // Configure widget + if (m_dbWidget) + { + setWidget(m_dbWidget); + updateWidgetVisible(); + connect(m_dbWidget, &Widgets::DashboardWidgetBase::updated, this, [=]() { + if (!isGpsMap()) + update(); + else + Q_EMIT gpsDataChanged(); + }); + + Q_EMIT widgetIndexChanged(); + } + } } /** @@ -292,8 +291,8 @@ void UI::DashboardWidget::setWidgetIndex(const int index) */ void UI::DashboardWidget::setIsExternalWindow(const bool isWindow) { - m_isExternalWindow = isWindow; - Q_EMIT isExternalWindowChanged(); + m_isExternalWindow = isWindow; + Q_EMIT isExternalWindowChanged(); } /** @@ -302,22 +301,18 @@ void UI::DashboardWidget::setIsExternalWindow(const bool isWindow) */ void UI::DashboardWidget::updateWidgetVisible() { - bool visible = UI::Dashboard::instance().widgetVisible(widgetIndex()); + bool visible = UI::Dashboard::instance().widgetVisible(widgetIndex()); - if (widgetVisible() != visible && !isExternalWindow()) + if (widgetVisible() != visible && !isExternalWindow()) + { + m_widgetVisible = visible; + + if (m_dbWidget) { - m_widgetVisible = visible; - - if (m_dbWidget) - { - m_dbWidget->setEnabled(visible); - update(); - } - - Q_EMIT widgetVisibleChanged(); + m_dbWidget->setEnabled(visible); + update(); } -} -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_DashboardWidget.cpp" -#endif + Q_EMIT widgetVisibleChanged(); + } +} diff --git a/src/UI/DashboardWidget.h b/src/UI/DashboardWidget.h index 542cb110..cc8cf719 100644 --- a/src/UI/DashboardWidget.h +++ b/src/UI/DashboardWidget.h @@ -32,44 +32,45 @@ namespace Widgets * @brief The DashboardWidgetBase class * * A simple QWidget with an additional @c update() signal, which is used by the - * @c UI::DashboardWidget to know when it should trigger a re-paint request to the scene - * render thread. + * @c UI::DashboardWidget to know when it should trigger a re-paint request to + * the scene render thread. * - * The widget also contains a @c requestUpdate() function, which is called by the widgets - * that inherit this class when they finish updating the displayed data. This function - * is used to schedule a re-paint at a controlled frequency, which is limited at 20 Hz. + * The widget also contains a @c requestUpdate() function, which is called by + * the widgets that inherit this class when they finish updating the displayed + * data. This function is used to schedule a re-paint at a controlled frequency, + * which is limited at 20 Hz. */ class DashboardWidgetBase : public QWidget { - Q_OBJECT + Q_OBJECT Q_SIGNALS: - void updated(); + void updated(); public: - DashboardWidgetBase() - { - // clang-format off + DashboardWidgetBase() + { + // clang-format off connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout20Hz, this, &Widgets::DashboardWidgetBase::repaint); - // clang-format on - } + // clang-format on + } - void repaint() + void repaint() + { + if (m_repaint) { - if (m_repaint) - { - m_repaint = false; - Q_EMIT updated(); - } + m_repaint = false; + Q_EMIT updated(); } + } - void requestRepaint() { m_repaint = true; } + void requestRepaint() { m_repaint = true; } private: - bool m_repaint; + bool m_repaint; }; -} +} // namespace Widgets namespace UI { @@ -77,17 +78,19 @@ namespace UI * @brief The DashboardWidget class * * The @c DashboardWidget class acts as a man-in-the-middle between the QML UI - * and the C++ widgets. C++ widgets are loaded and initialized by this class, and all the - * QML/Qt events are re-routed to the widgets using this class. Finally, the C++ widget - * is "painted" on the QML interface in realtime, effectively allowing us to use QWidget - * object directly in the QML user interface. + * and the C++ widgets. C++ widgets are loaded and initialized by this class, + * and all the QML/Qt events are re-routed to the widgets using this class. + * Finally, the C++ widget is "painted" on the QML interface in realtime, + * effectively allowing us to use QWidget object directly in the QML user + * interface. * - * By using this approach, the QML user interface only needs to know the total number of - * widgets and use the "global-index" approach to initialize every widget using a - * Repeater item. + * By using this approach, the QML user interface only needs to know the total + * number of widgets and use the "global-index" approach to initialize every + * widget using a Repeater item. * - * On the other hand, this class figures out which widget should be loaded and displayed - * in the user interface by knowing the "global-index" provider by the QML Repeater. + * On the other hand, this class figures out which widget should be loaded and + * displayed in the user interface by knowing the "global-index" provider by the + * QML Repeater. * * See the following files for more information: * assets/qml/Dashboard/WidgetDelegate.qml @@ -96,7 +99,7 @@ namespace UI */ class DashboardWidget : public DeclarativeWidget { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(int widgetIndex READ widgetIndex @@ -131,44 +134,44 @@ class DashboardWidget : public DeclarativeWidget Q_PROPERTY(qreal gpsLongitude READ gpsLongitude NOTIFY gpsDataChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void gpsDataChanged(); - void widgetIndexChanged(); - void widgetVisibleChanged(); - void isExternalWindowChanged(); + void gpsDataChanged(); + void widgetIndexChanged(); + void widgetVisibleChanged(); + void isExternalWindowChanged(); public: - DashboardWidget(QQuickItem *parent = 0); - ~DashboardWidget(); + DashboardWidget(QQuickItem *parent = 0); + ~DashboardWidget(); - int widgetIndex() const; - int relativeIndex() const; - bool widgetVisible() const; - QString widgetIcon() const; - QString widgetTitle() const; - bool isExternalWindow() const; - UI::Dashboard::WidgetType widgetType() const; + int widgetIndex() const; + int relativeIndex() const; + bool widgetVisible() const; + QString widgetIcon() const; + QString widgetTitle() const; + bool isExternalWindow() const; + UI::Dashboard::WidgetType widgetType() const; - bool isGpsMap() const; - qreal gpsAltitude() const; - qreal gpsLatitude() const; - qreal gpsLongitude() const; + bool isGpsMap() const; + qreal gpsAltitude() const; + qreal gpsLatitude() const; + qreal gpsLongitude() const; public Q_SLOTS: - void setVisible(const bool visible); - void setWidgetIndex(const int index); - void setIsExternalWindow(const bool isWindow); + void setVisible(const bool visible); + void setWidgetIndex(const int index); + void setIsExternalWindow(const bool isWindow); private Q_SLOTS: - void updateWidgetVisible(); + void updateWidgetVisible(); private: - int m_index; - bool m_isGpsMap; - bool m_widgetVisible; - bool m_isExternalWindow; - Widgets::DashboardWidgetBase* m_dbWidget; + int m_index; + bool m_isGpsMap; + bool m_widgetVisible; + bool m_isExternalWindow; + Widgets::DashboardWidgetBase *m_dbWidget; }; -} +} // namespace UI diff --git a/src/UI/DeclarativeWidget.cpp b/src/UI/DeclarativeWidget.cpp index 86c99085..eabc4bf1 100644 --- a/src/UI/DeclarativeWidget.cpp +++ b/src/UI/DeclarativeWidget.cpp @@ -24,45 +24,46 @@ #include /** - * Creates a subclass of @c QWidget that allows us to call the given protected/private + * Creates a subclass of @c QWidget that allows us to call the given + * protected/private * @a function and pass the given @a event as a parameter to the @a function. */ -#define DW_EXEC_EVENT(pointer, function, event) \ - if (!pointer.isNull()) \ - { \ - class PwnedWidget : public QWidget \ - { \ - public: \ - using QWidget::function; \ - }; \ - static_cast(pointer.data())->function(event); \ - update(); \ - } +#define DW_EXEC_EVENT(pointer, function, event) \ + if (!pointer.isNull()) \ + { \ + class PwnedWidget : public QWidget \ + { \ + public: \ + using QWidget::function; \ + }; \ + static_cast(pointer.data())->function(event); \ + update(); \ + } /** - * Configures item flags, sets fill color and connects signals/slots to automatically - * resize the contained widget to the QML item's size. + * Configures item flags, sets fill color and connects signals/slots to + * automatically resize the contained widget to the QML item's size. */ UI::DeclarativeWidget::DeclarativeWidget(QQuickItem *parent) - : QQuickPaintedItem(parent) + : QQuickPaintedItem(parent) { - setMipmap(true); - setAntialiasing(true); - setOpaquePainting(true); - setAcceptTouchEvents(true); - setFlag(ItemHasContents, true); - setFlag(ItemIsFocusScope, true); - setFlag(ItemAcceptsInputMethod, true); - setAcceptedMouseButtons(Qt::AllButtons); - setFillColor(Misc::ThemeManager::instance().base()); + setMipmap(true); + setAntialiasing(true); + setOpaquePainting(true); + setAcceptTouchEvents(true); + setFlag(ItemHasContents, true); + setFlag(ItemIsFocusScope, true); + setFlag(ItemAcceptsInputMethod, true); + setAcceptedMouseButtons(Qt::AllButtons); + setFillColor(Misc::ThemeManager::instance().base()); - // clang-format off + // clang-format off connect(this, &QQuickPaintedItem::widthChanged, this, &UI::DeclarativeWidget::resizeWidget); connect(this, &QQuickPaintedItem::heightChanged, this, &UI::DeclarativeWidget::resizeWidget); connect(this, &UI::DeclarativeWidget::widgetChanged, [=](){update();}); - // clang-format on + // clang-format on } /** @@ -70,7 +71,7 @@ UI::DeclarativeWidget::DeclarativeWidget(QQuickItem *parent) */ QWidget *UI::DeclarativeWidget::widget() { - return m_widget; + return m_widget; } /** @@ -80,11 +81,11 @@ QWidget *UI::DeclarativeWidget::widget() */ void UI::DeclarativeWidget::update(const QRect &rect) { - if (widget()) - { - m_pixmap = m_widget->grab(); - QQuickPaintedItem::update(rect); - } + if (widget()) + { + m_pixmap = m_widget->grab(); + QQuickPaintedItem::update(rect); + } } /** @@ -93,8 +94,8 @@ void UI::DeclarativeWidget::update(const QRect &rect) */ void UI::DeclarativeWidget::paint(QPainter *painter) { - if (painter) - painter->drawPixmap(0, 0, m_pixmap); + if (painter) + painter->drawPixmap(0, 0, m_pixmap); } /** @@ -102,7 +103,7 @@ void UI::DeclarativeWidget::paint(QPainter *painter) */ void UI::DeclarativeWidget::keyPressEvent(QKeyEvent *event) { - DW_EXEC_EVENT(m_widget, keyPressEvent, event); + DW_EXEC_EVENT(m_widget, keyPressEvent, event); } /** @@ -110,7 +111,7 @@ void UI::DeclarativeWidget::keyPressEvent(QKeyEvent *event) */ void UI::DeclarativeWidget::keyReleaseEvent(QKeyEvent *event) { - DW_EXEC_EVENT(m_widget, keyReleaseEvent, event); + DW_EXEC_EVENT(m_widget, keyReleaseEvent, event); } /** @@ -118,7 +119,7 @@ void UI::DeclarativeWidget::keyReleaseEvent(QKeyEvent *event) */ void UI::DeclarativeWidget::inputMethodEvent(QInputMethodEvent *event) { - DW_EXEC_EVENT(m_widget, inputMethodEvent, event); + DW_EXEC_EVENT(m_widget, inputMethodEvent, event); } /** @@ -126,7 +127,7 @@ void UI::DeclarativeWidget::inputMethodEvent(QInputMethodEvent *event) */ void UI::DeclarativeWidget::focusInEvent(QFocusEvent *event) { - DW_EXEC_EVENT(m_widget, focusInEvent, event); + DW_EXEC_EVENT(m_widget, focusInEvent, event); } /** @@ -134,7 +135,7 @@ void UI::DeclarativeWidget::focusInEvent(QFocusEvent *event) */ void UI::DeclarativeWidget::focusOutEvent(QFocusEvent *event) { - DW_EXEC_EVENT(m_widget, focusOutEvent, event); + DW_EXEC_EVENT(m_widget, focusOutEvent, event); } /** @@ -142,7 +143,7 @@ void UI::DeclarativeWidget::focusOutEvent(QFocusEvent *event) */ void UI::DeclarativeWidget::mousePressEvent(QMouseEvent *event) { - DW_EXEC_EVENT(m_widget, mousePressEvent, event); + DW_EXEC_EVENT(m_widget, mousePressEvent, event); } /** @@ -150,7 +151,7 @@ void UI::DeclarativeWidget::mousePressEvent(QMouseEvent *event) */ void UI::DeclarativeWidget::mouseMoveEvent(QMouseEvent *event) { - DW_EXEC_EVENT(m_widget, mouseMoveEvent, event); + DW_EXEC_EVENT(m_widget, mouseMoveEvent, event); } /** @@ -158,7 +159,7 @@ void UI::DeclarativeWidget::mouseMoveEvent(QMouseEvent *event) */ void UI::DeclarativeWidget::mouseReleaseEvent(QMouseEvent *event) { - DW_EXEC_EVENT(m_widget, mouseReleaseEvent, event); + DW_EXEC_EVENT(m_widget, mouseReleaseEvent, event); } /** @@ -166,7 +167,7 @@ void UI::DeclarativeWidget::mouseReleaseEvent(QMouseEvent *event) */ void UI::DeclarativeWidget::mouseDoubleClickEvent(QMouseEvent *event) { - DW_EXEC_EVENT(m_widget, mouseDoubleClickEvent, event); + DW_EXEC_EVENT(m_widget, mouseDoubleClickEvent, event); } /** @@ -174,7 +175,7 @@ void UI::DeclarativeWidget::mouseDoubleClickEvent(QMouseEvent *event) */ void UI::DeclarativeWidget::wheelEvent(QWheelEvent *event) { - DW_EXEC_EVENT(m_widget, wheelEvent, event); + DW_EXEC_EVENT(m_widget, wheelEvent, event); } /** @@ -182,7 +183,7 @@ void UI::DeclarativeWidget::wheelEvent(QWheelEvent *event) */ void UI::DeclarativeWidget::dragEnterEvent(QDragEnterEvent *event) { - DW_EXEC_EVENT(m_widget, dragEnterEvent, event); + DW_EXEC_EVENT(m_widget, dragEnterEvent, event); } /** @@ -190,7 +191,7 @@ void UI::DeclarativeWidget::dragEnterEvent(QDragEnterEvent *event) */ void UI::DeclarativeWidget::dragMoveEvent(QDragMoveEvent *event) { - DW_EXEC_EVENT(m_widget, dragMoveEvent, event); + DW_EXEC_EVENT(m_widget, dragMoveEvent, event); } /** @@ -198,7 +199,7 @@ void UI::DeclarativeWidget::dragMoveEvent(QDragMoveEvent *event) */ void UI::DeclarativeWidget::dragLeaveEvent(QDragLeaveEvent *event) { - DW_EXEC_EVENT(m_widget, dragLeaveEvent, event); + DW_EXEC_EVENT(m_widget, dragLeaveEvent, event); } /** @@ -206,7 +207,7 @@ void UI::DeclarativeWidget::dragLeaveEvent(QDragLeaveEvent *event) */ void UI::DeclarativeWidget::dropEvent(QDropEvent *event) { - DW_EXEC_EVENT(m_widget, dropEvent, event); + DW_EXEC_EVENT(m_widget, dropEvent, event); } /** @@ -214,14 +215,14 @@ void UI::DeclarativeWidget::dropEvent(QDropEvent *event) */ void UI::DeclarativeWidget::resizeWidget() { - if (widget()) + if (widget()) + { + if (width() > 0 && height() > 0) { - if (width() > 0 && height() > 0) - { - widget()->setFixedSize(width(), height()); - update(); - } + widget()->setFixedSize(width(), height()); + update(); } + } } /** @@ -229,16 +230,12 @@ void UI::DeclarativeWidget::resizeWidget() */ void UI::DeclarativeWidget::setWidget(QWidget *widget) { - if (widget) - { - if (m_widget) - delete m_widget; + if (widget) + { + if (m_widget) + delete m_widget; - m_widget = widget; - Q_EMIT widgetChanged(); - } + m_widget = widget; + Q_EMIT widgetChanged(); + } } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_DeclarativeWidget.cpp" -#endif diff --git a/src/UI/DeclarativeWidget.h b/src/UI/DeclarativeWidget.h index 4bb651df..ad51a2f0 100644 --- a/src/UI/DeclarativeWidget.h +++ b/src/UI/DeclarativeWidget.h @@ -31,44 +31,44 @@ namespace UI { class DeclarativeWidget : public QQuickPaintedItem { - Q_OBJECT - Q_PROPERTY(QWidget *widget READ widget WRITE setWidget NOTIFY widgetChanged) + Q_OBJECT + Q_PROPERTY(QWidget *widget READ widget WRITE setWidget NOTIFY widgetChanged) Q_SIGNALS: - void widgetChanged(); + void widgetChanged(); public: - DeclarativeWidget(QQuickItem *parent = 0); + DeclarativeWidget(QQuickItem *parent = 0); - QWidget *widget(); - void update(const QRect &rect = QRect()); + QWidget *widget(); + void update(const QRect &rect = QRect()); - virtual void paint(QPainter *painter) override; + virtual void paint(QPainter *painter) override; - virtual void keyPressEvent(QKeyEvent *event) override; - virtual void keyReleaseEvent(QKeyEvent *event) override; - virtual void inputMethodEvent(QInputMethodEvent *event) override; - virtual void focusInEvent(QFocusEvent *event) override; - virtual void focusOutEvent(QFocusEvent *event) override; - virtual void mousePressEvent(QMouseEvent *event) override; - virtual void mouseMoveEvent(QMouseEvent *event) override; - virtual void mouseReleaseEvent(QMouseEvent *event) override; - virtual void mouseDoubleClickEvent(QMouseEvent *event) override; - virtual void wheelEvent(QWheelEvent *event) override; - virtual void dragEnterEvent(QDragEnterEvent *event) override; - virtual void dragMoveEvent(QDragMoveEvent *event) override; - virtual void dragLeaveEvent(QDragLeaveEvent *event) override; - virtual void dropEvent(QDropEvent *event) override; + virtual void keyPressEvent(QKeyEvent *event) override; + virtual void keyReleaseEvent(QKeyEvent *event) override; + virtual void inputMethodEvent(QInputMethodEvent *event) override; + virtual void focusInEvent(QFocusEvent *event) override; + virtual void focusOutEvent(QFocusEvent *event) override; + virtual void mousePressEvent(QMouseEvent *event) override; + virtual void mouseMoveEvent(QMouseEvent *event) override; + virtual void mouseReleaseEvent(QMouseEvent *event) override; + virtual void mouseDoubleClickEvent(QMouseEvent *event) override; + virtual void wheelEvent(QWheelEvent *event) override; + virtual void dragEnterEvent(QDragEnterEvent *event) override; + virtual void dragMoveEvent(QDragMoveEvent *event) override; + virtual void dragLeaveEvent(QDragLeaveEvent *event) override; + virtual void dropEvent(QDropEvent *event) override; public Q_SLOTS: - void resizeWidget(); - void setWidget(QWidget *widget); + void resizeWidget(); + void setWidget(QWidget *widget); private: - void execEvent(void *function, void *event); + void execEvent(void *function, void *event); private: - QPixmap m_pixmap; - QPointer m_widget; + QPixmap m_pixmap; + QPointer m_widget; }; -} +} // namespace UI diff --git a/src/UI/Widgets/Accelerometer.cpp b/src/UI/Widgets/Accelerometer.cpp index d50f94d6..49254510 100644 --- a/src/UI/Widgets/Accelerometer.cpp +++ b/src/UI/Widgets/Accelerometer.cpp @@ -31,44 +31,45 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::Accelerometer::Accelerometer(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to Serial Studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to Serial Studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->accelerometerCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->accelerometerCount()) + return; - // Get needle & knob color - QString needleColor; - auto colors = theme->widgetColors(); - auto knobColor = theme->widgetControlBackground(); - if (colors.count() > m_index) - needleColor = colors.at(m_index); - else - needleColor = colors.at(colors.count() % m_index); + // Get needle & knob color + QString needleColor; + auto colors = theme->widgetColors(); + auto knobColor = theme->widgetControlBackground(); + if (colors.count() > m_index) + needleColor = colors.at(m_index); + else + needleColor = colors.at(colors.count() % m_index); - // Configure gauge needle - m_gauge.setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, - QColor(needleColor), knobColor)); + // Configure gauge needle + m_gauge.setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, + QColor(needleColor), knobColor)); - // Set gauge scale & display angles - m_gauge.setScale(0, 12); - m_gauge.setScaleArc(90, 360); + // Set gauge scale & display angles + m_gauge.setScale(0, 12); + m_gauge.setScaleArc(90, 360); - // Set gauge palette - QPalette palette; - palette.setColor(QPalette::WindowText, theme->base()); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - m_gauge.setPalette(palette); + // Set gauge palette + QPalette palette; + palette.setColor(QPalette::WindowText, theme->base()); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + m_gauge.setPalette(palette); - // Set widget pointer - setWidget(&m_gauge); + // Set widget pointer + setWidget(&m_gauge); - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -80,54 +81,50 @@ Widgets::Accelerometer::Accelerometer(const int index) */ void Widgets::Accelerometer::updateData() { - // Widget disabled - if (!isEnabled()) - return; + // Widget disabled + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->accelerometerCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->accelerometerCount()) + return; - // Get accelerometer group & validate it - auto accelerometer = dash->getAccelerometer(m_index); - if (accelerometer.datasetCount() != 3) - return; + // Get accelerometer group & validate it + auto accelerometer = dash->getAccelerometer(m_index); + if (accelerometer.datasetCount() != 3) + return; - // Initialize x, y, z - double x = 0; - double y = 0; - double z = 0; + // Initialize x, y, z + double x = 0; + double y = 0; + double z = 0; - // Extract x, y, z from accelerometer group - for (int i = 0; i < 3; ++i) - { - auto dataset = accelerometer.getDataset(i); - if (dataset.widget() == "x") - x = dataset.value().toDouble(); - if (dataset.widget() == "y") - y = dataset.value().toDouble(); - if (dataset.widget() == "z") - z = dataset.value().toDouble(); - } + // Extract x, y, z from accelerometer group + for (int i = 0; i < 3; ++i) + { + auto dataset = accelerometer.getDataset(i); + if (dataset.widget() == "x") + x = dataset.value().toDouble(); + if (dataset.widget() == "y") + y = dataset.value().toDouble(); + if (dataset.widget() == "z") + z = dataset.value().toDouble(); + } - // Divide accelerations by gravitational constant - x /= 9.81; - y /= 9.81; - z /= 9.81; + // Divide accelerations by gravitational constant + x /= 9.81; + y /= 9.81; + z /= 9.81; - // Normalize acceleration vector - const double G = qSqrt(qPow(x, 2) + qPow(y, 2) + qPow(z, 2)); + // Normalize acceleration vector + const double G = qSqrt(qPow(x, 2) + qPow(y, 2) + qPow(z, 2)); - // Update gauge - m_gauge.setValue(G); - setValue(QString("%1 G").arg( - QString::number(G, 'f', UI::Dashboard::instance().precision()))); + // Update gauge + m_gauge.setValue(G); + setValue(QString("%1 G").arg( + QString::number(G, 'f', UI::Dashboard::instance().precision()))); - // Repaint the widget - requestRepaint(); + // Repaint the widget + requestRepaint(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Accelerometer.cpp" -#endif diff --git a/src/UI/Widgets/Accelerometer.h b/src/UI/Widgets/Accelerometer.h index 3d1a7fee..baac426d 100644 --- a/src/UI/Widgets/Accelerometer.h +++ b/src/UI/Widgets/Accelerometer.h @@ -29,16 +29,16 @@ namespace Widgets { class Accelerometer : public BaseWidget { - Q_OBJECT + Q_OBJECT public: - Accelerometer(const int index = -1); + Accelerometer(const int index = -1); private Q_SLOTS: - void updateData(); + void updateData(); private: - int m_index; - AnalogGauge m_gauge; + int m_index; + AnalogGauge m_gauge; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Bar.cpp b/src/UI/Widgets/Bar.cpp index 9486396f..cef3f315 100644 --- a/src/UI/Widgets/Bar.cpp +++ b/src/UI/Widgets/Bar.cpp @@ -30,52 +30,54 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::Bar::Bar(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->barCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->barCount()) + return; - // Set thermo palette - QPalette palette; - palette.setColor(QPalette::Base, theme->base()); - palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - palette.setColor(QPalette::Dark, theme->widgetIndicator()); - palette.setColor(QPalette::Light, theme->widgetIndicator()); - palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); - palette.setColor(QPalette::WindowText, theme->widgetIndicator()); - m_thermo.setPalette(palette); + // Set thermo palette + QPalette palette; + palette.setColor(QPalette::Base, theme->base()); + palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + palette.setColor(QPalette::Dark, theme->widgetIndicator()); + palette.setColor(QPalette::Light, theme->widgetIndicator()); + palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); + palette.setColor(QPalette::WindowText, theme->widgetIndicator()); + m_thermo.setPalette(palette); - // Get thermo color - QString color; - auto colors = theme->widgetColors(); - if (colors.count() > m_index) - color = colors.at(m_index); - else - color = colors.at(colors.count() % m_index); + // Get thermo color + QString color; + auto colors = theme->widgetColors(); + if (colors.count() > m_index) + color = colors.at(m_index); + else + color = colors.at(colors.count() % m_index); - // Configure thermo style - m_thermo.setPipeWidth(64); - m_thermo.setBorderWidth(1); - m_thermo.setFillBrush(QBrush(QColor(color))); + // Configure thermo style + m_thermo.setPipeWidth(64); + m_thermo.setBorderWidth(1); + m_thermo.setFillBrush(QBrush(QColor(color))); - // Get initial properties from dataset - auto dataset = UI::Dashboard::instance().getBar(m_index); - m_thermo.setAlarmLevel(dataset.alarm()); - m_thermo.setAlarmEnabled(m_thermo.alarmLevel() > 0); - m_thermo.setScale(dataset.min(), dataset.max()); + // Get initial properties from dataset + auto dataset = UI::Dashboard::instance().getBar(m_index); + m_thermo.setAlarmLevel(dataset.alarm()); + m_thermo.setAlarmEnabled(m_thermo.alarmLevel() > 0); + m_thermo.setScale(dataset.min(), dataset.max()); - // Set widget pointer & disable auto resize - setWidget(&m_thermo, Qt::AlignHCenter, false); + // Set widget pointer & disable auto resize + setWidget(&m_thermo, Qt::AlignHCenter, false); - // React to dashboard events - connect(this, SIGNAL(resized()), this, SLOT(onResized()), Qt::QueuedConnection); - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to dashboard events + connect(this, SIGNAL(resized()), this, SLOT(onResized()), + Qt::QueuedConnection); + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -87,25 +89,25 @@ Widgets::Bar::Bar(const int index) */ void Widgets::Bar::updateData() { - // Widget not enabled, do nothing - if (!isEnabled()) - return; + // Widget not enabled, do nothing + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->barCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->barCount()) + return; - // Update bar level - auto dataset = dash->getBar(m_index); - auto value = dataset.value().toDouble(); - m_thermo.setValue(value); - setValue(QString("%1 %2").arg( - QString::number(value, 'f', UI::Dashboard::instance().precision()), - dataset.units())); + // Update bar level + auto dataset = dash->getBar(m_index); + auto value = dataset.value().toDouble(); + m_thermo.setValue(value); + setValue(QString("%1 %2").arg( + QString::number(value, 'f', UI::Dashboard::instance().precision()), + dataset.units())); - // Repaint widget - requestRepaint(); + // Repaint widget + requestRepaint(); } /** @@ -113,9 +115,5 @@ void Widgets::Bar::updateData() */ void Widgets::Bar::onResized() { - m_thermo.setPipeWidth(width() * 0.25); + m_thermo.setPipeWidth(width() * 0.25); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Bar.cpp" -#endif diff --git a/src/UI/Widgets/Bar.h b/src/UI/Widgets/Bar.h index 3dded069..e012f424 100644 --- a/src/UI/Widgets/Bar.h +++ b/src/UI/Widgets/Bar.h @@ -29,17 +29,17 @@ namespace Widgets { class Bar : public BaseWidget { - Q_OBJECT + Q_OBJECT public: - Bar(const int index = -1); + Bar(const int index = -1); private Q_SLOTS: - void updateData(); - void onResized(); + void updateData(); + void onResized(); private: - int m_index; - QwtThermo m_thermo; + int m_index; + QwtThermo m_thermo; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Common/AnalogGauge.cpp b/src/UI/Widgets/Common/AnalogGauge.cpp index a78d2147..f819ddb4 100644 --- a/src/UI/Widgets/Common/AnalogGauge.cpp +++ b/src/UI/Widgets/Common/AnalogGauge.cpp @@ -28,15 +28,15 @@ #include Widgets::AnalogGauge::AnalogGauge(QWidget *parent) - : QwtDial(parent) + : QwtDial(parent) { - // Disable controling the gauge with the mouse or keyboard - setReadOnly(true); + // Disable controling the gauge with the mouse or keyboard + setReadOnly(true); - // Do not reset gauge if we reach maximum value - setWrapping(false); + // Do not reset gauge if we reach maximum value + setWrapping(false); - // Set gauge origin & min/max angles - setOrigin(135); - setScaleArc(0, 270); + // Set gauge origin & min/max angles + setOrigin(135); + setScaleArc(0, 270); } diff --git a/src/UI/Widgets/Common/AnalogGauge.h b/src/UI/Widgets/Common/AnalogGauge.h index eef32016..1d50571d 100644 --- a/src/UI/Widgets/Common/AnalogGauge.h +++ b/src/UI/Widgets/Common/AnalogGauge.h @@ -30,6 +30,6 @@ namespace Widgets class AnalogGauge : public QwtDial { public: - AnalogGauge(QWidget *parent = Q_NULLPTR); + AnalogGauge(QWidget *parent = Q_NULLPTR); }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Common/AttitudeIndicator.cpp b/src/UI/Widgets/Common/AttitudeIndicator.cpp index 1e0a8a0e..ea247b65 100644 --- a/src/UI/Widgets/Common/AttitudeIndicator.cpp +++ b/src/UI/Widgets/Common/AttitudeIndicator.cpp @@ -36,121 +36,122 @@ namespace class Needle : public QwtDialNeedle { public: - Needle(const QColor &color) - { - QPalette palette; - palette.setColor(QPalette::Text, color); - setPalette(palette); - } + Needle(const QColor &color) + { + QPalette palette; + palette.setColor(QPalette::Text, color); + setPalette(palette); + } protected: - virtual void drawNeedle(QPainter *painter, double length, - QPalette::ColorGroup colorGroup) const QWT_OVERRIDE - { - double triangleSize = length * 0.1; - double pos = length - 2.0; + virtual void drawNeedle(QPainter *painter, double length, + QPalette::ColorGroup colorGroup) const QWT_OVERRIDE + { + double triangleSize = length * 0.1; + double pos = length - 2.0; - QPainterPath path; - path.moveTo(pos, 0); - path.lineTo(pos - 2 * triangleSize, triangleSize); - path.lineTo(pos - 2 * triangleSize, -triangleSize); - path.closeSubpath(); + QPainterPath path; + path.moveTo(pos, 0); + path.lineTo(pos - 2 * triangleSize, triangleSize); + path.lineTo(pos - 2 * triangleSize, -triangleSize); + path.closeSubpath(); - painter->setBrush(palette().brush(colorGroup, QPalette::Text)); - painter->drawPath(path); + painter->setBrush(palette().brush(colorGroup, QPalette::Text)); + painter->drawPath(path); - double l = length - 2; - painter->setPen(QPen(palette().color(colorGroup, QPalette::Text), 3)); - painter->drawLine(QPointF(0.0, -l), QPointF(0.0, l)); - } + double l = length - 2; + painter->setPen(QPen(palette().color(colorGroup, QPalette::Text), 3)); + painter->drawLine(QPointF(0.0, -l), QPointF(0.0, l)); + } }; -} +} // namespace AttitudeIndicator::AttitudeIndicator(QWidget *parent) - : QwtDial(parent) - , m_gradient(0) + : QwtDial(parent) + , m_gradient(0) { - QwtRoundScaleDraw *scaleDraw = new QwtRoundScaleDraw(); - scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); - scaleDraw->enableComponent(QwtAbstractScaleDraw::Labels, false); - setScaleDraw(scaleDraw); + QwtRoundScaleDraw *scaleDraw = new QwtRoundScaleDraw(); + scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); + scaleDraw->enableComponent(QwtAbstractScaleDraw::Labels, false); + setScaleDraw(scaleDraw); - setMode(RotateScale); - setWrapping(true); + setMode(RotateScale); + setWrapping(true); - setOrigin(270.0); + setOrigin(270.0); - setScaleMaxMinor(0); - setScaleStepSize(30.0); - setScale(0.0, 360.0); + setScaleMaxMinor(0); + setScaleStepSize(30.0); + setScale(0.0, 360.0); - const QColor color = palette().color(QPalette::Text); - setNeedle(new Needle(color)); + const QColor color = palette().color(QPalette::Text); + setNeedle(new Needle(color)); } double AttitudeIndicator::angle() const { - return value(); + return value(); } double AttitudeIndicator::gradient() const { - return m_gradient; + return m_gradient; } void AttitudeIndicator::setAngle(const double &angle) { - setValue(angle); + setValue(angle); } void AttitudeIndicator::setGradient(const double &gradient) { - auto grad = qMin(1.0, qMax(gradient, -1.0)); + auto grad = qMin(1.0, qMax(gradient, -1.0)); - if (m_gradient != grad) - { - m_gradient = grad; - update(); - } + if (m_gradient != grad) + { + m_gradient = grad; + update(); + } } void AttitudeIndicator::drawScale(QPainter *painter, const QPointF ¢er, double radius) const { - const double offset = 4.0; + const double offset = 4.0; - const QPointF p0 = qwtPolar2Pos(center, offset, 1.5 * M_PI); + const QPointF p0 = qwtPolar2Pos(center, offset, 1.5 * M_PI); - const double w = innerRect().width(); + const double w = innerRect().width(); - QPainterPath path; - path.moveTo(qwtPolar2Pos(p0, w, 0.0)); - path.lineTo(qwtPolar2Pos(path.currentPosition(), 2 * w, M_PI)); - path.lineTo(qwtPolar2Pos(path.currentPosition(), w, 0.5 * M_PI)); - path.lineTo(qwtPolar2Pos(path.currentPosition(), w, 0.0)); + QPainterPath path; + path.moveTo(qwtPolar2Pos(p0, w, 0.0)); + path.lineTo(qwtPolar2Pos(path.currentPosition(), 2 * w, M_PI)); + path.lineTo(qwtPolar2Pos(path.currentPosition(), w, 0.5 * M_PI)); + path.lineTo(qwtPolar2Pos(path.currentPosition(), w, 0.0)); - painter->save(); - painter->setClipPath(path); + painter->save(); + painter->setClipPath(path); - QwtDial::drawScale(painter, center, radius); + QwtDial::drawScale(painter, center, radius); - painter->restore(); + painter->restore(); } -void AttitudeIndicator::drawScaleContents(QPainter *painter, const QPointF ¢er, +void AttitudeIndicator::drawScaleContents(QPainter *painter, + const QPointF ¢er, double radius) const { - (void)center; - (void)radius; + (void)center; + (void)radius; - int dir = 360 - qRound(origin() - value()); - int arc = 90 + qRound(gradient() * 90); + int dir = 360 - qRound(origin() - value()); + int arc = 90 + qRound(gradient() * 90); - const QColor skyColor(38, 151, 221); + const QColor skyColor(38, 151, 221); - painter->save(); - painter->setBrush(skyColor); - painter->drawChord(scaleInnerRect(), (dir - arc) * 16, 2 * arc * 16); - painter->restore(); -} + painter->save(); + painter->setBrush(skyColor); + painter->drawChord(scaleInnerRect(), (dir - arc) * 16, 2 * arc * 16); + painter->restore(); } +} // namespace Widgets diff --git a/src/UI/Widgets/Common/AttitudeIndicator.h b/src/UI/Widgets/Common/AttitudeIndicator.h index c3af6b9a..9538c23c 100644 --- a/src/UI/Widgets/Common/AttitudeIndicator.h +++ b/src/UI/Widgets/Common/AttitudeIndicator.h @@ -26,7 +26,8 @@ #include // -// Based on https://github.com/opencor/qwt/blob/master/examples/dials/AttitudeIndicator.h +// Based on +// https://github.com/opencor/qwt/blob/master/examples/dials/AttitudeIndicator.h // namespace Widgets @@ -34,22 +35,22 @@ namespace Widgets class AttitudeIndicator : public QwtDial { public: - AttitudeIndicator(QWidget *parent = Q_NULLPTR); + AttitudeIndicator(QWidget *parent = Q_NULLPTR); - double angle() const; - double gradient() const; + double angle() const; + double gradient() const; public Q_SLOTS: - void setAngle(const double &angle); - void setGradient(const double &gradient); + void setAngle(const double &angle); + void setGradient(const double &gradient); protected: - void drawScale(QPainter *painter, const QPointF ¢er, - double radius) const QWT_OVERRIDE; - void drawScaleContents(QPainter *painter, const QPointF ¢er, - double radius) const QWT_OVERRIDE; + void drawScale(QPainter *painter, const QPointF ¢er, + double radius) const QWT_OVERRIDE; + void drawScaleContents(QPainter *painter, const QPointF ¢er, + double radius) const QWT_OVERRIDE; private: - double m_gradient; + double m_gradient; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Common/BaseWidget.cpp b/src/UI/Widgets/Common/BaseWidget.cpp index 3e7effaa..42bf3874 100644 --- a/src/UI/Widgets/Common/BaseWidget.cpp +++ b/src/UI/Widgets/Common/BaseWidget.cpp @@ -27,86 +27,87 @@ #include Widgets::BaseWidget::BaseWidget() - : m_index(-1) - , m_widget(Q_NULLPTR) - , m_resizeWidget(true) + : m_index(-1) + , m_widget(Q_NULLPTR) + , m_resizeWidget(true) { - // Workaround for unused variables - (void)m_index; + // Workaround for unused variables + (void)m_index; - // Set window palette - QPalette palette; - auto theme = &Misc::ThemeManager::instance(); - palette.setColor(QPalette::Base, theme->widgetWindowBackground()); - palette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(palette); + // Set window palette + QPalette palette; + auto theme = &Misc::ThemeManager::instance(); + palette.setColor(QPalette::Base, theme->widgetWindowBackground()); + palette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(palette); - // Configure label style - m_label.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + // Configure label style + m_label.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - // Set stylesheets - // clang-format off + // Set stylesheets + // clang-format off auto valueQSS = QSS("background-color:%1; color:%2; border:1px solid %3;", theme->base(), theme->widgetForegroundPrimary(), theme->widgetIndicator()); m_label.setStyleSheet(valueQSS); - // clang-format on + // clang-format on } void Widgets::BaseWidget::setValue(const QString &label) { - // Change label text - if (m_label.text() != label) - { - m_label.setText(label); + // Change label text + if (m_label.text() != label) + { + m_label.setText(label); - // Resize label font (so it fits inside the box) - while (QFontMetrics(m_label.font()).horizontalAdvance(label) + 24 - > m_label.width()) - { - QFont font = m_label.font(); - font.setPixelSize(font.pixelSize() - 1); - m_label.setFont(font); - } + // Resize label font (so it fits inside the box) + while (QFontMetrics(m_label.font()).horizontalAdvance(label) + 24 + > m_label.width()) + { + QFont font = m_label.font(); + font.setPixelSize(font.pixelSize() - 1); + m_label.setFont(font); } + } } -void Widgets::BaseWidget::setWidget(QWidget *widget, const Qt::Alignment &alignment, +void Widgets::BaseWidget::setWidget(QWidget *widget, + const Qt::Alignment &alignment, const bool autoresize) { - Q_ASSERT(widget != Q_NULLPTR); + Q_ASSERT(widget != Q_NULLPTR); - if (m_widget == Q_NULLPTR) - { - m_widget = widget; - m_resizeWidget = autoresize; + if (m_widget == Q_NULLPTR) + { + m_widget = widget; + m_resizeWidget = autoresize; - m_layout.setSpacing(24); - m_layout.addWidget(m_widget); - m_layout.addWidget(&m_label); - m_layout.setAlignment(m_widget, alignment); - m_layout.setContentsMargins(24, 24, 24, 24); - setLayout(&m_layout); - } + m_layout.setSpacing(24); + m_layout.addWidget(m_widget); + m_layout.addWidget(&m_label); + m_layout.setAlignment(m_widget, alignment); + m_layout.setContentsMargins(24, 24, 24, 24); + setLayout(&m_layout); + } - requestRepaint(); + requestRepaint(); } void Widgets::BaseWidget::resizeEvent(QResizeEvent *event) { - // Get width & height (exluding layout margins & spacing) - auto width = event->size().width() - 72; - auto height = event->size().height() - 48; + // Get width & height (exluding layout margins & spacing) + auto width = event->size().width() - 72; + auto height = event->size().height() - 48; - // Get fonts & calculate size - auto labelFont = UI::Dashboard::instance().monoFont(); - auto gaugeFont = UI::Dashboard::instance().monoFont(); - labelFont.setPixelSize(qMax(8, width / 18)); - gaugeFont.setPixelSize(qMax(8, width / 24)); + // Get fonts & calculate size + auto labelFont = UI::Dashboard::instance().monoFont(); + auto gaugeFont = UI::Dashboard::instance().monoFont(); + labelFont.setPixelSize(qMax(8, width / 18)); + gaugeFont.setPixelSize(qMax(8, width / 24)); - // Set label font (so it fits inside the box) - // clang-format off + // Set label font (so it fits inside the box) + // clang-format off m_label.setFont(labelFont); while (QFontMetrics(m_label.font()).horizontalAdvance(m_label.text()) + 12 > m_label.width()) { @@ -119,29 +120,25 @@ void Widgets::BaseWidget::resizeEvent(QResizeEvent *event) else break; } - // clang-format on + // clang-format on - // Set widget font - if (m_widget) - m_widget->setFont(gaugeFont); + // Set widget font + if (m_widget) + m_widget->setFont(gaugeFont); - // Set widget sizes - m_label.setMinimumWidth(width * 0.4); - m_label.setMaximumWidth(width * 0.4); - m_label.setMaximumHeight(height * 0.4); + // Set widget sizes + m_label.setMinimumWidth(width * 0.4); + m_label.setMaximumWidth(width * 0.4); + m_label.setMaximumHeight(height * 0.4); - // Set widget size - if (m_resizeWidget && m_widget) - { - m_widget->setMinimumWidth(width * 0.6); - m_widget->setMaximumWidth(width * 0.6); - } + // Set widget size + if (m_resizeWidget && m_widget) + { + m_widget->setMinimumWidth(width * 0.6); + m_widget->setMaximumWidth(width * 0.6); + } - // Accept event - event->accept(); - Q_EMIT resized(); + // Accept event + event->accept(); + Q_EMIT resized(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_BaseWidget.cpp" -#endif diff --git a/src/UI/Widgets/Common/BaseWidget.h b/src/UI/Widgets/Common/BaseWidget.h index febf647e..4f1bd733 100644 --- a/src/UI/Widgets/Common/BaseWidget.h +++ b/src/UI/Widgets/Common/BaseWidget.h @@ -32,26 +32,27 @@ namespace Widgets { class BaseWidget : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT Q_SIGNALS: - void resized(); + void resized(); public: - BaseWidget(); + BaseWidget(); - void setValue(const QString &label); - void setWidget(QWidget *widget, const Qt::Alignment &alignment = Qt::AlignHCenter, - const bool autoresize = true); + void setValue(const QString &label); + void setWidget(QWidget *widget, + const Qt::Alignment &alignment = Qt::AlignHCenter, + const bool autoresize = true); protected: - void resizeEvent(QResizeEvent *event); + void resizeEvent(QResizeEvent *event); private: - int m_index; - QLabel m_label; - QWidget *m_widget; - bool m_resizeWidget; - QHBoxLayout m_layout; + int m_index; + QLabel m_label; + QWidget *m_widget; + bool m_resizeWidget; + QHBoxLayout m_layout; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Common/ElidedLabel.cpp b/src/UI/Widgets/Common/ElidedLabel.cpp index 0e9ccbae..c4287343 100644 --- a/src/UI/Widgets/Common/ElidedLabel.cpp +++ b/src/UI/Widgets/Common/ElidedLabel.cpp @@ -25,55 +25,51 @@ #include Widgets::ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags flags) - : QLabel(parent, flags) - , m_eliding(false) - , m_originalText("") - , m_elideMode(Qt::ElideNone) + : QLabel(parent, flags) + , m_eliding(false) + , m_originalText("") + , m_elideMode(Qt::ElideNone) { } Widgets::ElidedLabel::ElidedLabel(const QString &text, QWidget *parent, Qt::WindowFlags flags) - : QLabel(text, parent, flags) - , m_eliding(false) - , m_originalText("") - , m_elideMode(Qt::ElideNone) + : QLabel(text, parent, flags) + , m_eliding(false) + , m_originalText("") + , m_elideMode(Qt::ElideNone) { - setText(text); + setText(text); } void Widgets::ElidedLabel::setType(const Qt::TextElideMode type) { - m_elideMode = type; - elide(); + m_elideMode = type; + elide(); } void Widgets::ElidedLabel::resizeEvent(QResizeEvent *event) { - Q_UNUSED(event); - QTimer::singleShot(50, this, SLOT(elide())); + Q_UNUSED(event); + QTimer::singleShot(50, this, SLOT(elide())); } void Widgets::ElidedLabel::setText(const QString &text) { - m_originalText = text; - QLabel::setText(text); - elide(); + m_originalText = text; + QLabel::setText(text); + elide(); } void Widgets::ElidedLabel::elide() { - if (m_eliding == false) - { - m_eliding = true; + if (m_eliding == false) + { + m_eliding = true; - QFontMetrics metrics(font()); - QLabel::setText(metrics.elidedText(m_originalText, m_elideMode, width())); + QFontMetrics metrics(font()); + QLabel::setText(metrics.elidedText(m_originalText, m_elideMode, width())); - m_eliding = false; - } + m_eliding = false; + } } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_ElidedLabel.cpp" -#endif diff --git a/src/UI/Widgets/Common/ElidedLabel.h b/src/UI/Widgets/Common/ElidedLabel.h index fd7ed232..b9a0a486 100644 --- a/src/UI/Widgets/Common/ElidedLabel.h +++ b/src/UI/Widgets/Common/ElidedLabel.h @@ -28,25 +28,25 @@ namespace Widgets { class ElidedLabel : public QLabel { - Q_OBJECT + Q_OBJECT public: - explicit ElidedLabel(QWidget *parent = Q_NULLPTR, - Qt::WindowFlags flags = Qt::WindowFlags()); - explicit ElidedLabel(const QString &text, QWidget *parent = Q_NULLPTR, - Qt::WindowFlags flags = Qt::WindowFlags()); - void setType(const Qt::TextElideMode type); + explicit ElidedLabel(QWidget *parent = Q_NULLPTR, + Qt::WindowFlags flags = Qt::WindowFlags()); + explicit ElidedLabel(const QString &text, QWidget *parent = Q_NULLPTR, + Qt::WindowFlags flags = Qt::WindowFlags()); + void setType(const Qt::TextElideMode type); public Q_SLOTS: - void setText(const QString &text); - void elide(); + void setText(const QString &text); + void elide(); protected: - void resizeEvent(QResizeEvent *event); + void resizeEvent(QResizeEvent *event); private: - bool m_eliding; - QString m_originalText; - Qt::TextElideMode m_elideMode; + bool m_eliding; + QString m_originalText; + Qt::TextElideMode m_elideMode; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Common/KLed.cpp b/src/UI/Widgets/Common/KLed.cpp index a72cdaa1..217cfd9e 100644 --- a/src/UI/Widgets/Common/KLed.cpp +++ b/src/UI/Widgets/Common/KLed.cpp @@ -15,263 +15,262 @@ class KLedPrivate { public: - int darkFactor = 300; - QColor color; - KLed::State state = KLed::On; - KLed::Look look = KLed::Raised; - KLed::Shape shape = KLed::Circular; + int darkFactor = 300; + QColor color; + KLed::State state = KLed::On; + KLed::Look look = KLed::Raised; + KLed::Shape shape = KLed::Circular; - QPixmap cachedPixmap[2]; // for both states + QPixmap cachedPixmap[2]; // for both states }; KLed::KLed(QWidget *parent) - : QWidget(parent) - , d(new KLedPrivate) + : QWidget(parent) + , d(new KLedPrivate) { - setColor(Qt::green); - updateAccessibleName(); + setColor(Qt::green); + updateAccessibleName(); } KLed::KLed(const QColor &color, QWidget *parent) - : QWidget(parent) - , d(new KLedPrivate) + : QWidget(parent) + , d(new KLedPrivate) { - setColor(color); - updateAccessibleName(); + setColor(color); + updateAccessibleName(); } -KLed::KLed(const QColor &color, State state, Look look, Shape shape, QWidget *parent) - : QWidget(parent) - , d(new KLedPrivate) +KLed::KLed(const QColor &color, State state, Look look, Shape shape, + QWidget *parent) + : QWidget(parent) + , d(new KLedPrivate) { - d->state = (state == Off ? Off : On); - d->look = look; - d->shape = shape; + d->state = (state == Off ? Off : On); + d->look = look; + d->shape = shape; - setColor(color); - updateAccessibleName(); + setColor(color); + updateAccessibleName(); } KLed::~KLed() = default; KLed::State KLed::state() const { - return d->state; + return d->state; } KLed::Shape KLed::shape() const { - return d->shape; + return d->shape; } QColor KLed::color() const { - return d->color; + return d->color; } KLed::Look KLed::look() const { - return d->look; + return d->look; } void KLed::setState(State state) { - if (d->state == state) - { - return; - } + if (d->state == state) + { + return; + } - d->state = (state == Off ? Off : On); - updateCachedPixmap(); - updateAccessibleName(); + d->state = (state == Off ? Off : On); + updateCachedPixmap(); + updateAccessibleName(); } void KLed::setShape(Shape shape) { - if (d->shape == shape) - { - return; - } + if (d->shape == shape) + { + return; + } - d->shape = shape; - updateCachedPixmap(); + d->shape = shape; + updateCachedPixmap(); } void KLed::setColor(const QColor &color) { - if (d->color == color) - { - return; - } + if (d->color == color) + { + return; + } - d->color = color; - updateCachedPixmap(); + d->color = color; + updateCachedPixmap(); } void KLed::setDarkFactor(int darkFactor) { - if (d->darkFactor == darkFactor) - { - return; - } + if (d->darkFactor == darkFactor) + { + return; + } - d->darkFactor = darkFactor; - updateCachedPixmap(); + d->darkFactor = darkFactor; + updateCachedPixmap(); } int KLed::darkFactor() const { - return d->darkFactor; + return d->darkFactor; } void KLed::setLook(Look look) { - if (d->look == look) - { - return; - } + if (d->look == look) + { + return; + } - d->look = look; - updateCachedPixmap(); + d->look = look; + updateCachedPixmap(); } void KLed::toggle() { - d->state = (d->state == On ? Off : On); - updateCachedPixmap(); - updateAccessibleName(); + d->state = (d->state == On ? Off : On); + updateCachedPixmap(); + updateAccessibleName(); } void KLed::on() { - setState(On); + setState(On); } void KLed::off() { - setState(Off); + setState(Off); } void KLed::resizeEvent(QResizeEvent *) { - updateCachedPixmap(); + updateCachedPixmap(); } QSize KLed::sizeHint() const { - QStyleOption option; - option.initFrom(this); - int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, &option, this); - return QSize(iconSize, iconSize); + QStyleOption option; + option.initFrom(this); + int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, &option, this); + return QSize(iconSize, iconSize); } QSize KLed::minimumSizeHint() const { - return QSize(32, 32); + return QSize(32, 32); } void KLed::updateAccessibleName() { #ifndef QT_NO_ACCESSIBILITY - QString onName = tr("LED on", "Accessible name of a Led whose state is on"); - QString offName = tr("LED off", "Accessible name of a Led whose state is off"); - QString lastName = accessibleName(); + QString onName = tr("LED on", "Accessible name of a Led whose state is on"); + QString offName + = tr("LED off", "Accessible name of a Led whose state is off"); + QString lastName = accessibleName(); - if (lastName.isEmpty() || lastName == onName || lastName == offName) - { - // Accessible name has not been manually set. + if (lastName.isEmpty() || lastName == onName || lastName == offName) + { + // Accessible name has not been manually set. - setAccessibleName(d->state == On ? onName : offName); - } + setAccessibleName(d->state == On ? onName : offName); + } #endif } void KLed::updateCachedPixmap() { - d->cachedPixmap[Off] = QPixmap(); - d->cachedPixmap[On] = QPixmap(); - update(); + d->cachedPixmap[Off] = QPixmap(); + d->cachedPixmap[On] = QPixmap(); + update(); } void KLed::paintEvent(QPaintEvent *) { - if (!d->cachedPixmap[d->state].isNull()) - { - QPainter painter(this); - painter.drawPixmap(1, 1, d->cachedPixmap[d->state]); - return; - } - - QSize size(width() - 2, height() - 2); - if (d->shape == Circular) - { - // Make sure the LED is round - const int dim = qMin(width(), height()) - 2; - size = QSize(dim, dim); - } - QPointF center(size.width() / 2.0, size.height() / 2.0); - const int smallestSize = qMin(size.width(), size.height()); - QPainter painter; - - QImage image(size, QImage::Format_ARGB32_Premultiplied); - image.fill(0); - - QRadialGradient fillGradient(center, smallestSize / 2.0, - QPointF(center.x(), size.height() / 3.0)); - const QColor fillColor = d->state != Off ? d->color : d->color.darker(d->darkFactor); - fillGradient.setColorAt(0.0, fillColor.lighter(250)); - fillGradient.setColorAt(0.5, fillColor.lighter(130)); - fillGradient.setColorAt(1.0, fillColor); - - QConicalGradient borderGradient(center, d->look == Sunken ? 90 : -90); - QColor borderColor = palette().color(QPalette::Dark); - if (d->state == On) - { - QColor glowOverlay = fillColor; - glowOverlay.setAlpha(80); - - // This isn't the fastest way, but should be "fast enough". - // It's also the only safe way to use QPainter::CompositionMode - QImage img(1, 1, QImage::Format_ARGB32_Premultiplied); - QPainter p(&img); - QColor start = borderColor; - start.setAlpha(255); // opaque - p.fillRect(0, 0, 1, 1, start); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - p.fillRect(0, 0, 1, 1, glowOverlay); - p.end(); - - borderColor = img.pixel(0, 0); - } - borderGradient.setColorAt(0.2, borderColor); - borderGradient.setColorAt(0.5, palette().color(QPalette::Light)); - borderGradient.setColorAt(0.8, borderColor); - - painter.begin(&image); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(d->look == Flat ? QBrush(fillColor) : QBrush(fillGradient)); - const QBrush penBrush - = (d->look == Flat) ? QBrush(borderColor) : QBrush(borderGradient); - const qreal penWidth = smallestSize / 8.0; - painter.setPen(QPen(penBrush, penWidth)); - QRectF r(penWidth / 2.0, penWidth / 2.0, size.width() - penWidth, - size.height() - penWidth); - if (d->shape == Rectangular) - { - painter.drawRect(r); - } - else - { - painter.drawEllipse(r); - } - painter.end(); - - d->cachedPixmap[d->state] = QPixmap::fromImage(image); - painter.begin(this); + if (!d->cachedPixmap[d->state].isNull()) + { + QPainter painter(this); painter.drawPixmap(1, 1, d->cachedPixmap[d->state]); - painter.end(); -} + return; + } -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_KLed.cpp" -#endif + QSize size(width() - 2, height() - 2); + if (d->shape == Circular) + { + // Make sure the LED is round + const int dim = qMin(width(), height()) - 2; + size = QSize(dim, dim); + } + QPointF center(size.width() / 2.0, size.height() / 2.0); + const int smallestSize = qMin(size.width(), size.height()); + QPainter painter; + + QImage image(size, QImage::Format_ARGB32_Premultiplied); + image.fill(0); + + QRadialGradient fillGradient(center, smallestSize / 2.0, + QPointF(center.x(), size.height() / 3.0)); + const QColor fillColor + = d->state != Off ? d->color : d->color.darker(d->darkFactor); + fillGradient.setColorAt(0.0, fillColor.lighter(250)); + fillGradient.setColorAt(0.5, fillColor.lighter(130)); + fillGradient.setColorAt(1.0, fillColor); + + QConicalGradient borderGradient(center, d->look == Sunken ? 90 : -90); + QColor borderColor = palette().color(QPalette::Dark); + if (d->state == On) + { + QColor glowOverlay = fillColor; + glowOverlay.setAlpha(80); + + // This isn't the fastest way, but should be "fast enough". + // It's also the only safe way to use QPainter::CompositionMode + QImage img(1, 1, QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + QColor start = borderColor; + start.setAlpha(255); // opaque + p.fillRect(0, 0, 1, 1, start); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + p.fillRect(0, 0, 1, 1, glowOverlay); + p.end(); + + borderColor = img.pixel(0, 0); + } + borderGradient.setColorAt(0.2, borderColor); + borderGradient.setColorAt(0.5, palette().color(QPalette::Light)); + borderGradient.setColorAt(0.8, borderColor); + + painter.begin(&image); + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(d->look == Flat ? QBrush(fillColor) : QBrush(fillGradient)); + const QBrush penBrush + = (d->look == Flat) ? QBrush(borderColor) : QBrush(borderGradient); + const qreal penWidth = smallestSize / 8.0; + painter.setPen(QPen(penBrush, penWidth)); + QRectF r(penWidth / 2.0, penWidth / 2.0, size.width() - penWidth, + size.height() - penWidth); + if (d->shape == Rectangular) + { + painter.drawRect(r); + } + else + { + painter.drawEllipse(r); + } + painter.end(); + + d->cachedPixmap[d->state] = QPixmap::fromImage(image); + painter.begin(this); + painter.drawPixmap(1, 1, d->cachedPixmap[d->state]); + painter.end(); +} diff --git a/src/UI/Widgets/Common/KLed.h b/src/UI/Widgets/Common/KLed.h index d60a1dba..afb9c113 100644 --- a/src/UI/Widgets/Common/KLed.h +++ b/src/UI/Widgets/Common/KLed.h @@ -31,225 +31,225 @@ class QColor; */ class KLed : public QWidget { - Q_OBJECT - Q_PROPERTY(State state READ state WRITE setState) - Q_PROPERTY(Shape shape READ shape WRITE setShape) - Q_PROPERTY(Look look READ look WRITE setLook) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) + Q_OBJECT + Q_PROPERTY(State state READ state WRITE setState) + Q_PROPERTY(Shape shape READ shape WRITE setShape) + Q_PROPERTY(Look look READ look WRITE setLook) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) public: - /** - * Status of the light is on/off. - * @short LED on/off. - */ - enum State - { - Off, - On - }; - Q_ENUM(State) + /** + * Status of the light is on/off. + * @short LED on/off. + */ + enum State + { + Off, + On + }; + Q_ENUM(State) - /** - * Shades of the lamp. - * @short LED shape - */ - enum Shape - { - Rectangular, - Circular - }; - Q_ENUM(Shape) + /** + * Shades of the lamp. + * @short LED shape + */ + enum Shape + { + Rectangular, + Circular + }; + Q_ENUM(Shape) - /** - * Displays a flat, round or sunken LED. - * - * @short LED look. - */ - enum Look - { - Flat, - Raised, - Sunken, - }; - Q_ENUM(Look) + /** + * Displays a flat, round or sunken LED. + * + * @short LED look. + */ + enum Look + { + Flat, + Raised, + Sunken, + }; + Q_ENUM(Look) - /** - * Constructs a green, round LED widget which will initially - * be turned on. - * - * @param parent The parent widget. - */ - explicit KLed(QWidget *parent = Q_NULLPTR); + /** + * Constructs a green, round LED widget which will initially + * be turned on. + * + * @param parent The parent widget. + */ + explicit KLed(QWidget *parent = Q_NULLPTR); - /** - * Constructs a round LED widget with the supplied color which will - * initially be turned on. - * - * @param color Initial color of the LED. - * @param parent The parent widget. - * @short Constructor - */ - explicit KLed(const QColor &color, QWidget *parent = Q_NULLPTR); + /** + * Constructs a round LED widget with the supplied color which will + * initially be turned on. + * + * @param color Initial color of the LED. + * @param parent The parent widget. + * @short Constructor + */ + explicit KLed(const QColor &color, QWidget *parent = Q_NULLPTR); - /** - * Constructor with the color, state and look. - * - * Differs from above only in the parameters, which configure all settings. - * - * @param color Initial color of the LED. - * @param state Sets the State. - * @param look Sets the Look. - * @param shape Sets the Shape (rectangular or circular). - * @param parent The parent widget. - * @short Constructor - */ - KLed(const QColor &color, KLed::State state, KLed::Look look, KLed::Shape shape, - QWidget *parent = Q_NULLPTR); + /** + * Constructor with the color, state and look. + * + * Differs from above only in the parameters, which configure all settings. + * + * @param color Initial color of the LED. + * @param state Sets the State. + * @param look Sets the Look. + * @param shape Sets the Shape (rectangular or circular). + * @param parent The parent widget. + * @short Constructor + */ + KLed(const QColor &color, KLed::State state, KLed::Look look, + KLed::Shape shape, QWidget *parent = Q_NULLPTR); - /** - * Destroys the LED widget. - * @short Destructor - */ - ~KLed() override; + /** + * Destroys the LED widget. + * @short Destructor + */ + ~KLed() override; - /** - * Returns the current color of the widget. - * - * @returns LED color - * @see setColor() - */ - QColor color() const; + /** + * Returns the current color of the widget. + * + * @returns LED color + * @see setColor() + */ + QColor color() const; - /** - * Returns the current state of the widget (on/off). - * @returns LED state - * - * @see State - */ - State state() const; + /** + * Returns the current state of the widget (on/off). + * @returns LED state + * + * @see State + */ + State state() const; - /** - * Returns the current look of the widget. - * @returns LED look - * - * @see Look - */ - Look look() const; + /** + * Returns the current look of the widget. + * @returns LED look + * + * @see Look + */ + Look look() const; - /** - * Returns the current shape of the widget. - * @returns LED shape - * - * @see Shape - */ - Shape shape() const; + /** + * Returns the current shape of the widget. + * @returns LED shape + * + * @see Shape + */ + Shape shape() const; - /** - * Returns the factor to darken the LED. - * @returns dark factor - * - * @see setDarkFactor() - */ - int darkFactor() const; + /** + * Returns the factor to darken the LED. + * @returns dark factor + * + * @see setDarkFactor() + */ + int darkFactor() const; - /** - * Set the color of the widget. - * - * The LED is shown with @p color when in the KLed::On state - * or with the darken color in KLed::Off state. - * - * The widget calls the update() method, so it will - * be updated when entering the main event loop. - * - * @param color New color of the LED. - * - * @see color() darkFactor() - */ - void setColor(const QColor &color); + /** + * Set the color of the widget. + * + * The LED is shown with @p color when in the KLed::On state + * or with the darken color in KLed::Off state. + * + * The widget calls the update() method, so it will + * be updated when entering the main event loop. + * + * @param color New color of the LED. + * + * @see color() darkFactor() + */ + void setColor(const QColor &color); - /** - * Sets the state of the widget to On or Off. - * - * @param state The LED state: on or off. - * - * @see on() off() toggle() - */ - void setState(State state); + /** + * Sets the state of the widget to On or Off. + * + * @param state The LED state: on or off. + * + * @see on() off() toggle() + */ + void setState(State state); - /** - * Sets the look of the widget. - * - * The look may be Flat, Raised or Sunken. - * - * The widget calls the update() method, so it will - * be updated when entering the main event loop. - * - * @param look New look of the LED. - * - * @see Look - */ - void setLook(Look look); + /** + * Sets the look of the widget. + * + * The look may be Flat, Raised or Sunken. + * + * The widget calls the update() method, so it will + * be updated when entering the main event loop. + * + * @param look New look of the LED. + * + * @see Look + */ + void setLook(Look look); - /** - * Set the shape of the LED. - * - * @param shape The LED shape. - * @short Set LED shape. - */ - void setShape(Shape shape); + /** + * Set the shape of the LED. + * + * @param shape The LED shape. + * @short Set LED shape. + */ + void setShape(Shape shape); - /** - * Sets the factor to darken the LED in KLed::Off state. - * - * The @p darkFactor should be greater than 100, otherwise the LED - * becomes lighter in KLed::Off state. - * - * Defaults to 300. - * - * @param darkFactor Sets the factor to darken the LED. - * - * @see setColor - */ - void setDarkFactor(int darkFactor); + /** + * Sets the factor to darken the LED in KLed::Off state. + * + * The @p darkFactor should be greater than 100, otherwise the LED + * becomes lighter in KLed::Off state. + * + * Defaults to 300. + * + * @param darkFactor Sets the factor to darken the LED. + * + * @see setColor + */ + void setDarkFactor(int darkFactor); - QSize sizeHint() const override; - QSize minimumSizeHint() const override; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; public Q_SLOTS: - /** - * Toggles the state of the led from Off to On or vice versa. - */ - void toggle(); + /** + * Toggles the state of the led from Off to On or vice versa. + */ + void toggle(); - /** - * Sets the state of the widget to On. - * - * @see off() toggle() setState() - */ - void on(); + /** + * Sets the state of the widget to On. + * + * @see off() toggle() setState() + */ + void on(); - /** - * Sets the state of the widget to Off. - * - * @see on() toggle() setState() - */ - void off(); + /** + * Sets the state of the widget to Off. + * + * @see on() toggle() setState() + */ + void off(); protected: - void paintEvent(QPaintEvent *) override; - void resizeEvent(QResizeEvent *) override; + void paintEvent(QPaintEvent *) override; + void resizeEvent(QResizeEvent *) override; - /** - * @internal - * invalidates caches after property changes and calls update() - */ - void updateCachedPixmap(); + /** + * @internal + * invalidates caches after property changes and calls update() + */ + void updateCachedPixmap(); private: - void updateAccessibleName(); + void updateAccessibleName(); private: - std::unique_ptr const d; + std::unique_ptr const d; }; diff --git a/src/UI/Widgets/Compass.cpp b/src/UI/Widgets/Compass.cpp index 6a7ad199..b80bafaf 100644 --- a/src/UI/Widgets/Compass.cpp +++ b/src/UI/Widgets/Compass.cpp @@ -32,42 +32,43 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::Compass::Compass(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->compassCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->compassCount()) + return; - // Set compass style - QwtCompassScaleDraw *scaleDraw = new QwtCompassScaleDraw(); - scaleDraw->enableComponent(QwtAbstractScaleDraw::Ticks, true); - scaleDraw->enableComponent(QwtAbstractScaleDraw::Labels, true); - scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); - scaleDraw->setTickLength(QwtScaleDiv::MinorTick, 1); - scaleDraw->setTickLength(QwtScaleDiv::MediumTick, 1); - scaleDraw->setTickLength(QwtScaleDiv::MajorTick, 3); + // Set compass style + QwtCompassScaleDraw *scaleDraw = new QwtCompassScaleDraw(); + scaleDraw->enableComponent(QwtAbstractScaleDraw::Ticks, true); + scaleDraw->enableComponent(QwtAbstractScaleDraw::Labels, true); + scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); + scaleDraw->setTickLength(QwtScaleDiv::MinorTick, 1); + scaleDraw->setTickLength(QwtScaleDiv::MediumTick, 1); + scaleDraw->setTickLength(QwtScaleDiv::MajorTick, 3); - // Configure compass scale & needle - m_compass.setScaleDraw(scaleDraw); - m_compass.setScaleMaxMajor(36); - m_compass.setScaleMaxMinor(5); - m_compass.setNeedle(new QwtCompassMagnetNeedle(QwtCompassMagnetNeedle::ThinStyle)); + // Configure compass scale & needle + m_compass.setScaleDraw(scaleDraw); + m_compass.setScaleMaxMajor(36); + m_compass.setScaleMaxMinor(5); + m_compass.setNeedle( + new QwtCompassMagnetNeedle(QwtCompassMagnetNeedle::ThinStyle)); - // Set compass palette - QPalette palette; - palette.setColor(QPalette::WindowText, theme->base()); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - m_compass.setPalette(palette); + // Set compass palette + QPalette palette; + palette.setColor(QPalette::WindowText, theme->base()); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + m_compass.setPalette(palette); - // Set widget pointer - setWidget(&m_compass); + // Set widget pointer + setWidget(&m_compass); - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(update()), Qt::QueuedConnection); + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(update()), Qt::QueuedConnection); } /** @@ -79,35 +80,31 @@ Widgets::Compass::Compass(const int index) */ void Widgets::Compass::update() { - // Widget disabled - if (!isEnabled()) - return; + // Widget disabled + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->compassCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->compassCount()) + return; - // Get dataset value & set text format - auto dataset = dash->getCompass(m_index); - auto value = dataset.value().toDouble(); - auto text = QString("%1°").arg( - QString::number(value, 'f', UI::Dashboard::instance().precision())); + // Get dataset value & set text format + auto dataset = dash->getCompass(m_index); + auto value = dataset.value().toDouble(); + auto text = QString("%1°").arg( + QString::number(value, 'f', UI::Dashboard::instance().precision())); - // Ensure that angle always has 3 characters - if (text.length() == 2) - text.prepend("00"); - else if (text.length() == 3) - text.prepend("0"); + // Ensure that angle always has 3 characters + if (text.length() == 2) + text.prepend("00"); + else if (text.length() == 3) + text.prepend("0"); - // Update gauge - setValue(text); - m_compass.setValue(value); + // Update gauge + setValue(text); + m_compass.setValue(value); - // Repaint the widget - requestRepaint(); + // Repaint the widget + requestRepaint(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Compass.cpp" -#endif diff --git a/src/UI/Widgets/Compass.h b/src/UI/Widgets/Compass.h index 7ef13871..72213d61 100644 --- a/src/UI/Widgets/Compass.h +++ b/src/UI/Widgets/Compass.h @@ -29,16 +29,16 @@ namespace Widgets { class Compass : public BaseWidget { - Q_OBJECT + Q_OBJECT public: - Compass(const int index = -1); + Compass(const int index = -1); private Q_SLOTS: - void update(); + void update(); private: - int m_index; - QwtCompass m_compass; + int m_index; + QwtCompass m_compass; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/DataGroup.cpp b/src/UI/Widgets/DataGroup.cpp index 6ea5debc..5c7e38ed 100644 --- a/src/UI/Widgets/DataGroup.cpp +++ b/src/UI/Widgets/DataGroup.cpp @@ -27,132 +27,134 @@ #include #include -#define DG_EXEC_EVENT(pointer, function, event) \ - if (pointer) \ - { \ - class PwnedWidget : public QScrollArea \ - { \ - public: \ - using QScrollArea::function; \ - }; \ - static_cast(pointer)->function(event); \ - requestRepaint(); \ - } +#define DG_EXEC_EVENT(pointer, function, event) \ + if (pointer) \ + { \ + class PwnedWidget : public QScrollArea \ + { \ + public: \ + using QScrollArea::function; \ + }; \ + static_cast(pointer)->function(event); \ + requestRepaint(); \ + } /** * Generates the user interface elements & layout */ Widgets::DataGroup::DataGroup(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->groupCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->groupCount()) + return; - // Get group reference - auto group = dash->getGroups(m_index); + // Get group reference + auto group = dash->getGroups(m_index); - // Generate widget stylesheets - auto titleQSS = QSS("color:%1", theme->widgetTextPrimary()); - auto unitsQSS = QSS("color:%1", theme->widgetTextSecondary()); - auto valueQSS = QSS("color:%1", theme->widgetForegroundPrimary()); - auto iconsQSS = QSS("color:%1; font-weight:600;", theme->widgetTextSecondary()); + // Generate widget stylesheets + auto titleQSS = QSS("color:%1", theme->widgetTextPrimary()); + auto unitsQSS = QSS("color:%1", theme->widgetTextSecondary()); + auto valueQSS = QSS("color:%1", theme->widgetForegroundPrimary()); + auto iconsQSS + = QSS("color:%1; font-weight:600;", theme->widgetTextSecondary()); - // Set window palette - QPalette windowPalette; - windowPalette.setColor(QPalette::Base, theme->widgetWindowBackground()); - windowPalette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(windowPalette); + // Set window palette + QPalette windowPalette; + windowPalette.setColor(QPalette::Base, theme->widgetWindowBackground()); + windowPalette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(windowPalette); - // Configure scroll area container - m_dataContainer = new QWidget(this); + // Configure scroll area container + m_dataContainer = new QWidget(this); - // Make the value label larger - auto valueFont = dash->monoFont(); - valueFont.setPixelSize(dash->monoFont().pixelSize() * 1.3); + // Make the value label larger + auto valueFont = dash->monoFont(); + valueFont.setPixelSize(dash->monoFont().pixelSize() * 1.3); - // Configure grid layout - m_units.reserve(group.datasetCount()); - m_icons.reserve(group.datasetCount()); - m_titles.reserve(group.datasetCount()); - m_values.reserve(group.datasetCount()); - m_gridLayout = new QGridLayout(m_dataContainer); - for (int dataset = 0; dataset < group.datasetCount(); ++dataset) - { - // Create labels - m_units.append(new QLabel(m_dataContainer)); - m_icons.append(new QLabel(m_dataContainer)); - m_titles.append(new ElidedLabel(m_dataContainer)); - m_values.append(new ElidedLabel(m_dataContainer)); + // Configure grid layout + m_units.reserve(group.datasetCount()); + m_icons.reserve(group.datasetCount()); + m_titles.reserve(group.datasetCount()); + m_values.reserve(group.datasetCount()); + m_gridLayout = new QGridLayout(m_dataContainer); + for (int dataset = 0; dataset < group.datasetCount(); ++dataset) + { + // Create labels + m_units.append(new QLabel(m_dataContainer)); + m_icons.append(new QLabel(m_dataContainer)); + m_titles.append(new ElidedLabel(m_dataContainer)); + m_values.append(new ElidedLabel(m_dataContainer)); - // Get pointers to labels - auto dicon = m_icons.last(); - auto units = m_units.last(); - auto title = m_titles.last(); - auto value = m_values.last(); + // Get pointers to labels + auto dicon = m_icons.last(); + auto units = m_units.last(); + auto title = m_titles.last(); + auto value = m_values.last(); - // Set elide modes for title & value fields - title->setType(Qt::ElideRight); - value->setType(Qt::ElideRight); + // Set elide modes for title & value fields + title->setType(Qt::ElideRight); + value->setType(Qt::ElideRight); - // Set label alignments - units->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - value->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - title->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - dicon->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + // Set label alignments + units->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + value->setAlignment(Qt::AlignRight | Qt::AlignVCenter); + title->setAlignment(Qt::AlignRight | Qt::AlignVCenter); + dicon->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - // Set label styles & fonts - value->setFont(valueFont); - title->setFont(dash->monoFont()); - units->setFont(dash->monoFont()); - title->setStyleSheet(titleQSS); - value->setStyleSheet(valueQSS); - units->setStyleSheet(unitsQSS); - dicon->setStyleSheet(iconsQSS); + // Set label styles & fonts + value->setFont(valueFont); + title->setFont(dash->monoFont()); + units->setFont(dash->monoFont()); + title->setStyleSheet(titleQSS); + value->setStyleSheet(valueQSS); + units->setStyleSheet(unitsQSS); + dicon->setStyleSheet(iconsQSS); - // Set label initial data - auto set = group.getDataset(dataset); - title->setText(set.title()); - if (!set.units().isEmpty()) - units->setText(QString("[%1]").arg(set.units())); + // Set label initial data + auto set = group.getDataset(dataset); + title->setText(set.title()); + if (!set.units().isEmpty()) + units->setText(QString("[%1]").arg(set.units())); - // Set icon text - dicon->setText("⤑"); + // Set icon text + dicon->setText("⤑"); - // Add labels to grid layout - m_gridLayout->addWidget(title, dataset, 0); - m_gridLayout->addWidget(dicon, dataset, 1); - m_gridLayout->addWidget(value, dataset, 2); - m_gridLayout->addWidget(units, dataset, 3); - } + // Add labels to grid layout + m_gridLayout->addWidget(title, dataset, 0); + m_gridLayout->addWidget(dicon, dataset, 1); + m_gridLayout->addWidget(value, dataset, 2); + m_gridLayout->addWidget(units, dataset, 3); + } - // Load layout into container widget - m_gridLayout->setColumnStretch(0, 2); - m_gridLayout->setColumnStretch(1, 1); - m_gridLayout->setColumnStretch(2, 2); - m_gridLayout->setColumnStretch(3, 0); - m_dataContainer->setLayout(m_gridLayout); + // Load layout into container widget + m_gridLayout->setColumnStretch(0, 2); + m_gridLayout->setColumnStretch(1, 1); + m_gridLayout->setColumnStretch(2, 2); + m_gridLayout->setColumnStretch(3, 0); + m_dataContainer->setLayout(m_gridLayout); - // Configure scroll area - m_scrollArea = new QScrollArea(this); - m_scrollArea->setWidgetResizable(true); - m_scrollArea->setWidget(m_dataContainer); - m_scrollArea->setFrameShape(QFrame::NoFrame); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // Configure scroll area + m_scrollArea = new QScrollArea(this); + m_scrollArea->setWidgetResizable(true); + m_scrollArea->setWidget(m_dataContainer); + m_scrollArea->setFrameShape(QFrame::NoFrame); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // Configure main layout - m_mainLayout = new QVBoxLayout(this); - m_mainLayout->addWidget(m_scrollArea); - m_mainLayout->setContentsMargins(0, 0, 0, 0); - setLayout(m_mainLayout); + // Configure main layout + m_mainLayout = new QVBoxLayout(this); + m_mainLayout->addWidget(m_scrollArea); + m_mainLayout->setContentsMargins(0, 0, 0, 0); + setLayout(m_mainLayout); - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -160,21 +162,21 @@ Widgets::DataGroup::DataGroup(const int index) */ Widgets::DataGroup::~DataGroup() { - Q_FOREACH (auto icon, m_icons) - delete icon; + Q_FOREACH (auto icon, m_icons) + delete icon; - Q_FOREACH (auto title, m_titles) - delete title; + Q_FOREACH (auto title, m_titles) + delete title; - Q_FOREACH (auto value, m_values) - delete value; + Q_FOREACH (auto value, m_values) + delete value; - Q_FOREACH (auto units, m_units) - delete units; + Q_FOREACH (auto units, m_units) + delete units; - delete m_gridLayout; - delete m_scrollArea; - delete m_mainLayout; + delete m_gridLayout; + delete m_scrollArea; + delete m_mainLayout; } /** @@ -186,39 +188,39 @@ Widgets::DataGroup::~DataGroup() */ void Widgets::DataGroup::updateData() { - // Widget not enabled, do nothing - if (!isEnabled()) - return; + // Widget not enabled, do nothing + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->groupCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->groupCount()) + return; - // Get group reference - auto group = dash->getGroups(m_index); + // Get group reference + auto group = dash->getGroups(m_index); - // Regular expresion handler - const QRegularExpression regex("^[+-]?(\\d*\\.)?\\d+$"); + // Regular expresion handler + const QRegularExpression regex("^[+-]?(\\d*\\.)?\\d+$"); - // Update labels - for (int i = 0; i < group.datasetCount(); ++i) - { - // Get dataset value - auto value = group.getDataset(i).value(); + // Update labels + for (int i = 0; i < group.datasetCount(); ++i) + { + // Get dataset value + auto value = group.getDataset(i).value(); - // Check if value is a number, if so make sure that - // we always show a fixed number of decimal places - if (regex.match(value).hasMatch()) - value = QString::number(value.toDouble(), 'f', dash->precision()); + // Check if value is a number, if so make sure that + // we always show a fixed number of decimal places + if (regex.match(value).hasMatch()) + value = QString::number(value.toDouble(), 'f', dash->precision()); - // Update label - if (m_values.count() > i) - m_values.at(i)->setText(value + " "); - } + // Update label + if (m_values.count() > i) + m_values.at(i)->setText(value + " "); + } - // Repaint widget - requestRepaint(); + // Repaint widget + requestRepaint(); } /** @@ -226,50 +228,46 @@ void Widgets::DataGroup::updateData() */ void Widgets::DataGroup::resizeEvent(QResizeEvent *event) { - auto width = event->size().width(); - QFont font = UI::Dashboard::instance().monoFont(); - QFont icon = font; - QFont valueFont = font; - icon.setPixelSize(qMax(8, width / 16)); - font.setPixelSize(qMax(8, width / 24)); - valueFont.setPixelSize(font.pixelSize() * 1.3); + auto width = event->size().width(); + QFont font = UI::Dashboard::instance().monoFont(); + QFont icon = font; + QFont valueFont = font; + icon.setPixelSize(qMax(8, width / 16)); + font.setPixelSize(qMax(8, width / 24)); + valueFont.setPixelSize(font.pixelSize() * 1.3); - for (int i = 0; i < m_titles.count(); ++i) - { - m_units.at(i)->setFont(font); - m_icons.at(i)->setFont(icon); - m_titles.at(i)->setFont(font); - m_values.at(i)->setFont(valueFont); - } + for (int i = 0; i < m_titles.count(); ++i) + { + m_units.at(i)->setFont(font); + m_icons.at(i)->setFont(icon); + m_titles.at(i)->setFont(font); + m_values.at(i)->setFont(valueFont); + } - event->accept(); + event->accept(); } void Widgets::DataGroup::wheelEvent(QWheelEvent *event) { - DG_EXEC_EVENT(m_scrollArea, wheelEvent, event); + DG_EXEC_EVENT(m_scrollArea, wheelEvent, event); } void Widgets::DataGroup::mouseMoveEvent(QMouseEvent *event) { - DG_EXEC_EVENT(m_scrollArea, mouseMoveEvent, event); + DG_EXEC_EVENT(m_scrollArea, mouseMoveEvent, event); } void Widgets::DataGroup::mousePressEvent(QMouseEvent *event) { - DG_EXEC_EVENT(m_scrollArea, mousePressEvent, event); + DG_EXEC_EVENT(m_scrollArea, mousePressEvent, event); } void Widgets::DataGroup::mouseReleaseEvent(QMouseEvent *event) { - DG_EXEC_EVENT(m_scrollArea, mouseReleaseEvent, event); + DG_EXEC_EVENT(m_scrollArea, mouseReleaseEvent, event); } void Widgets::DataGroup::mouseDoubleClickEvent(QMouseEvent *event) { - DG_EXEC_EVENT(m_scrollArea, mouseDoubleClickEvent, event); + DG_EXEC_EVENT(m_scrollArea, mouseDoubleClickEvent, event); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_DataGroup.cpp" -#endif diff --git a/src/UI/Widgets/DataGroup.h b/src/UI/Widgets/DataGroup.h index 31a7eeb5..6c2a161e 100644 --- a/src/UI/Widgets/DataGroup.h +++ b/src/UI/Widgets/DataGroup.h @@ -33,34 +33,34 @@ namespace Widgets { class DataGroup : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT public: - DataGroup(const int index = -1); - ~DataGroup(); + DataGroup(const int index = -1); + ~DataGroup(); private Q_SLOTS: - void updateData(); + void updateData(); protected: - void resizeEvent(QResizeEvent *event); - void wheelEvent(QWheelEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); + void resizeEvent(QResizeEvent *event); + void wheelEvent(QWheelEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); private: - int m_index; + int m_index; - QVector m_icons; - QVector m_units; - QVector m_titles; - QVector m_values; + QVector m_icons; + QVector m_units; + QVector m_titles; + QVector m_values; - QWidget *m_dataContainer; - QVBoxLayout *m_mainLayout; - QGridLayout *m_gridLayout; - QScrollArea *m_scrollArea; + QWidget *m_dataContainer; + QVBoxLayout *m_mainLayout; + QGridLayout *m_gridLayout; + QScrollArea *m_scrollArea; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/FFTPlot.cpp b/src/UI/Widgets/FFTPlot.cpp index 402f937b..adb4fe9d 100644 --- a/src/UI/Widgets/FFTPlot.cpp +++ b/src/UI/Widgets/FFTPlot.cpp @@ -28,103 +28,104 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::FFTPlot::FFTPlot(const int index) - : m_size(0) - , m_index(index) + : m_size(0) + , m_index(index) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Initialize pointers to NULL - m_fft = Q_NULLPTR; - m_samples = Q_NULLPTR; + // Initialize pointers to NULL + m_fft = Q_NULLPTR; + m_samples = Q_NULLPTR; - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->fftCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->fftCount()) + return; - // Set window palette - QPalette palette; - palette.setColor(QPalette::Base, theme->widgetWindowBackground()); - palette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(palette); + // Set window palette + QPalette palette; + palette.setColor(QPalette::Base, theme->widgetWindowBackground()); + palette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(palette); - // Set plot palette - palette.setColor(QPalette::Base, theme->base()); - palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - palette.setColor(QPalette::Dark, theme->widgetIndicator()); - palette.setColor(QPalette::Light, theme->widgetIndicator()); - palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); - palette.setColor(QPalette::WindowText, theme->widgetIndicator()); - m_plot.setPalette(palette); - m_plot.setCanvasBackground(theme->base()); - m_plot.setFrameStyle(QFrame::Plain); + // Set plot palette + palette.setColor(QPalette::Base, theme->base()); + palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + palette.setColor(QPalette::Dark, theme->widgetIndicator()); + palette.setColor(QPalette::Light, theme->widgetIndicator()); + palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); + palette.setColor(QPalette::WindowText, theme->widgetIndicator()); + m_plot.setPalette(palette); + m_plot.setCanvasBackground(theme->base()); + m_plot.setFrameStyle(QFrame::Plain); - // Configure layout - m_layout.addWidget(&m_plot); - m_layout.setContentsMargins(24, 24, 24, 24); - setLayout(&m_layout); + // Configure layout + m_layout.addWidget(&m_plot); + m_layout.setContentsMargins(24, 24, 24, 24); + setLayout(&m_layout); - // Fit data horizontally - auto xAxisEngine = m_plot.axisScaleEngine(QwtPlot::xBottom); - xAxisEngine->setAttribute(QwtScaleEngine::Floating, true); + // Fit data horizontally + auto xAxisEngine = m_plot.axisScaleEngine(QwtPlot::xBottom); + xAxisEngine->setAttribute(QwtScaleEngine::Floating, true); - // Create curve from data - m_curve.attach(&m_plot); - m_plot.replot(); - m_plot.show(); + // Create curve from data + m_curve.attach(&m_plot); + m_plot.replot(); + m_plot.show(); - // Get curve color - QString color; - const StringList colors = theme->widgetColors(); - if (colors.count() > m_index) - color = colors.at(m_index); - else - color = colors.at(colors.count() % m_index); + // Get curve color + QString color; + const StringList colors = theme->widgetColors(); + if (colors.count() > m_index) + color = colors.at(m_index); + else + color = colors.at(colors.count() % m_index); - // Set curve color & plot style - m_curve.setPen(QColor(color), 2, Qt::SolidLine); + // Set curve color & plot style + m_curve.setPen(QColor(color), 2, Qt::SolidLine); - // Get dataset max freq. & calculate fft size - auto dataset = UI::Dashboard::instance().getFFT(m_index); - int size = qMax(8, dataset.fftSamples()); + // Get dataset max freq. & calculate fft size + auto dataset = UI::Dashboard::instance().getFFT(m_index); + int size = qMax(8, dataset.fftSamples()); - // Ensure that FFT size is valid - while (m_transformer.setSize(size) != QFourierTransformer::FixedSize) - --size; + // Ensure that FFT size is valid + while (m_transformer.setSize(size) != QFourierTransformer::FixedSize) + --size; - // Set FFT size - m_size = size; + // Set FFT size + m_size = size; - // Initialize samples & FFT arrays - m_fft = (float *)calloc(m_size, sizeof(float)); - m_samples = (float *)calloc(m_size, sizeof(float)); + // Initialize samples & FFT arrays + m_fft = (float *)calloc(m_size, sizeof(float)); + m_samples = (float *)calloc(m_size, sizeof(float)); - // Clear Y-axis data - PlotData xData; - PlotData yData; - xData.reserve(m_size); - yData.reserve(m_size); - for (int i = 0; i < m_size; ++i) - { - yData.append(0); - xData.append(i); - } + // Clear Y-axis data + PlotData xData; + PlotData yData; + xData.reserve(m_size); + yData.reserve(m_size); + for (int i = 0; i < m_size; ++i) + { + yData.append(0); + xData.append(i); + } - // Set y-scale from -1 to 1 - m_plot.setAxisScale(QwtPlot::yLeft, -1, 1); + // Set y-scale from -1 to 1 + m_plot.setAxisScale(QwtPlot::yLeft, -1, 1); - // Set axis titles - m_plot.setAxisTitle(QwtPlot::xBottom, tr("Samples")); - m_plot.setAxisTitle(QwtPlot::yLeft, tr("FFT of %1").arg(dataset.title())); + // Set axis titles + m_plot.setAxisTitle(QwtPlot::xBottom, tr("Samples")); + m_plot.setAxisTitle(QwtPlot::yLeft, tr("FFT of %1").arg(dataset.title())); - // Set curve data & replot - m_curve.setSamples(xData, yData); - m_plot.replot(); + // Set curve data & replot + m_curve.setSamples(xData, yData); + m_plot.replot(); - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -132,10 +133,10 @@ Widgets::FFTPlot::FFTPlot(const int index) */ Widgets::FFTPlot::~FFTPlot() { - free(m_fft); - free(m_samples); - m_fft = Q_NULLPTR; - m_samples = Q_NULLPTR; + free(m_fft); + free(m_samples); + m_fft = Q_NULLPTR; + m_samples = Q_NULLPTR; } /** @@ -148,30 +149,26 @@ Widgets::FFTPlot::~FFTPlot() */ void Widgets::FFTPlot::updateData() { - // Verify that FFT sample arrays are valid - if (!m_samples || !m_fft) - return; + // Verify that FFT sample arrays are valid + if (!m_samples || !m_fft) + return; - // Replot - auto plotData = UI::Dashboard::instance().fftPlotValues(); - if (plotData.count() > m_index) - { - // Copy data to samples array - auto data = plotData.at(m_index); - for (int i = 0; i < m_size; ++i) - m_samples[i] = static_cast(data[i]); + // Replot + auto plotData = UI::Dashboard::instance().fftPlotValues(); + if (plotData.count() > m_index) + { + // Copy data to samples array + auto data = plotData.at(m_index); + for (int i = 0; i < m_size; ++i) + m_samples[i] = static_cast(data[i]); - // Execute FFT - m_transformer.forwardTransform(m_samples, m_fft); - m_transformer.rescale(m_fft); - m_curve.setSamples(m_fft, m_size); - m_plot.replot(); + // Execute FFT + m_transformer.forwardTransform(m_samples, m_fft); + m_transformer.rescale(m_fft); + m_curve.setSamples(m_fft, m_size); + m_plot.replot(); - // Repaint widget - requestRepaint(); - } + // Repaint widget + requestRepaint(); + } } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_FFTPlot.cpp" -#endif diff --git a/src/UI/Widgets/FFTPlot.h b/src/UI/Widgets/FFTPlot.h index 37b2a8d8..7aa32657 100644 --- a/src/UI/Widgets/FFTPlot.h +++ b/src/UI/Widgets/FFTPlot.h @@ -35,24 +35,24 @@ namespace Widgets { class FFTPlot : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT public: - FFTPlot(const int index = -1); - ~FFTPlot(); + FFTPlot(const int index = -1); + ~FFTPlot(); private Q_SLOTS: - void updateData(); + void updateData(); private: - float *m_fft; - float *m_samples; + float *m_fft; + float *m_samples; - int m_size; - int m_index; - QwtPlot m_plot; - QwtPlotCurve m_curve; - QVBoxLayout m_layout; - QFourierTransformer m_transformer; + int m_size; + int m_index; + QwtPlot m_plot; + QwtPlotCurve m_curve; + QVBoxLayout m_layout; + QFourierTransformer m_transformer; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/GPS.cpp b/src/UI/Widgets/GPS.cpp index 3e80d6a4..2c51b2fd 100644 --- a/src/UI/Widgets/GPS.cpp +++ b/src/UI/Widgets/GPS.cpp @@ -20,7 +20,6 @@ * THE SOFTWARE. */ - #include #include #include @@ -29,27 +28,28 @@ * Generates the user interface elements & layout */ Widgets::GPS::GPS(const int index) - : m_index(index) - , m_altitude(0) - , m_latitude(0) - , m_longitude(0) + : m_index(index) + , m_altitude(0) + , m_latitude(0) + , m_longitude(0) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->gpsCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->gpsCount()) + return; - // Set window palette - QPalette windowPalette; - windowPalette.setColor(QPalette::Base, theme->widgetWindowBackground()); - windowPalette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(windowPalette); + // Set window palette + QPalette windowPalette; + windowPalette.setColor(QPalette::Base, theme->widgetWindowBackground()); + windowPalette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(windowPalette); - // React to Qt signals - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to Qt signals + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -57,7 +57,7 @@ Widgets::GPS::GPS(const int index) */ qreal Widgets::GPS::altitude() const { - return m_altitude; + return m_altitude; } /** @@ -65,7 +65,7 @@ qreal Widgets::GPS::altitude() const */ qreal Widgets::GPS::latitude() const { - return m_latitude; + return m_latitude; } /** @@ -73,7 +73,7 @@ qreal Widgets::GPS::latitude() const */ qreal Widgets::GPS::longitude() const { - return m_longitude; + return m_longitude; } /** @@ -85,37 +85,32 @@ qreal Widgets::GPS::longitude() const */ void Widgets::GPS::updateData() { - // Widget not enabled, do nothing - if (!isEnabled()) - return; + // Widget not enabled, do nothing + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->gpsCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->gpsCount()) + return; - // Get group reference - auto group = dash->getGPS(m_index); + // Get group reference + auto group = dash->getGPS(m_index); - // Get latitiude/longitude from datasets - m_altitude = 0, - m_latitude = 0; - m_longitude = 0; - for (int i = 0; i < group.datasetCount(); ++i) - { - auto dataset = group.getDataset(i); - if (dataset.widget() == "lat") - m_latitude = dataset.value().toDouble(); - else if (dataset.widget() == "lon") - m_longitude = dataset.value().toDouble(); - else if (dataset.widget() == "alt") - m_altitude = dataset.value().toDouble(); - } + // Get latitiude/longitude from datasets + m_altitude = 0, m_latitude = 0; + m_longitude = 0; + for (int i = 0; i < group.datasetCount(); ++i) + { + auto dataset = group.getDataset(i); + if (dataset.widget() == "lat") + m_latitude = dataset.value().toDouble(); + else if (dataset.widget() == "lon") + m_longitude = dataset.value().toDouble(); + else if (dataset.widget() == "alt") + m_altitude = dataset.value().toDouble(); + } - // Update the QML user interface with the new data - Q_EMIT updated(); + // Update the QML user interface with the new data + Q_EMIT updated(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_GPS.cpp" -#endif diff --git a/src/UI/Widgets/GPS.h b/src/UI/Widgets/GPS.h index 658f4d33..21ca698d 100644 --- a/src/UI/Widgets/GPS.h +++ b/src/UI/Widgets/GPS.h @@ -28,22 +28,22 @@ namespace Widgets { class GPS : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT public: - GPS(const int index = -1); + GPS(const int index = -1); - qreal altitude() const; - qreal latitude() const; - qreal longitude() const; + qreal altitude() const; + qreal latitude() const; + qreal longitude() const; private Q_SLOTS: - void updateData(); + void updateData(); private: - int m_index; - qreal m_altitude; - qreal m_latitude; - qreal m_longitude; + int m_index; + qreal m_altitude; + qreal m_latitude; + qreal m_longitude; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Gauge.cpp b/src/UI/Widgets/Gauge.cpp index 24403310..8f8176d6 100644 --- a/src/UI/Widgets/Gauge.cpp +++ b/src/UI/Widgets/Gauge.cpp @@ -28,46 +28,47 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::Gauge::Gauge(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to Serial Studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to Serial Studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->gaugeCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->gaugeCount()) + return; - // Get needle & knob color - QString needleColor; - auto colors = theme->widgetColors(); - auto knobColor = theme->widgetControlBackground(); - if (colors.count() > m_index) - needleColor = colors.at(m_index); - else - needleColor = colors.at(colors.count() % m_index); + // Get needle & knob color + QString needleColor; + auto colors = theme->widgetColors(); + auto knobColor = theme->widgetControlBackground(); + if (colors.count() > m_index) + needleColor = colors.at(m_index); + else + needleColor = colors.at(colors.count() % m_index); - // Configure gauge needle - auto needle = new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, - QColor(needleColor), knobColor); - m_gauge.setNeedle(needle); - m_gauge.setFont(dash->monoFont()); + // Configure gauge needle + auto needle = new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, + QColor(needleColor), knobColor); + m_gauge.setNeedle(needle); + m_gauge.setFont(dash->monoFont()); - // Set gauge scale - auto dataset = dash->getGauge(m_index); - m_gauge.setScale(dataset.min(), dataset.max()); + // Set gauge scale + auto dataset = dash->getGauge(m_index); + m_gauge.setScale(dataset.min(), dataset.max()); - // Set gauge palette - QPalette palette; - palette.setColor(QPalette::WindowText, theme->base()); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - m_gauge.setPalette(palette); + // Set gauge palette + QPalette palette; + palette.setColor(QPalette::WindowText, theme->base()); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + m_gauge.setPalette(palette); - // Set widget pointer - setWidget(&m_gauge); + // Set widget pointer + setWidget(&m_gauge); - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -79,26 +80,22 @@ Widgets::Gauge::Gauge(const int index) */ void Widgets::Gauge::updateData() { - // Widget not enabled, do nothing - if (!isEnabled()) - return; + // Widget not enabled, do nothing + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->gaugeCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->gaugeCount()) + return; - // Update gauge value - auto dataset = dash->getGauge(m_index); - m_gauge.setValue(dataset.value().toDouble()); - setValue(QString("%1 %2").arg( - QString::number(dataset.value().toDouble(), 'f', dash->precision()), - dataset.units())); + // Update gauge value + auto dataset = dash->getGauge(m_index); + m_gauge.setValue(dataset.value().toDouble()); + setValue(QString("%1 %2").arg( + QString::number(dataset.value().toDouble(), 'f', dash->precision()), + dataset.units())); - // Repaint widget - requestRepaint(); + // Repaint widget + requestRepaint(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Gauge.cpp" -#endif diff --git a/src/UI/Widgets/Gauge.h b/src/UI/Widgets/Gauge.h index d83f9922..950cd233 100644 --- a/src/UI/Widgets/Gauge.h +++ b/src/UI/Widgets/Gauge.h @@ -29,16 +29,16 @@ namespace Widgets { class Gauge : public BaseWidget { - Q_OBJECT + Q_OBJECT public: - Gauge(const int index = -1); + Gauge(const int index = -1); private Q_SLOTS: - void updateData(); + void updateData(); private: - int m_index; - AnalogGauge m_gauge; + int m_index; + AnalogGauge m_gauge; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Gyroscope.cpp b/src/UI/Widgets/Gyroscope.cpp index 4f6b70d4..602f177c 100644 --- a/src/UI/Widgets/Gyroscope.cpp +++ b/src/UI/Widgets/Gyroscope.cpp @@ -31,34 +31,35 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::Gyroscope::Gyroscope(const int index) - : m_index(index) - , m_displayNum(0) + : m_index(index) + , m_displayNum(0) { - // Get pointers to Serial Studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to Serial Studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->gyroscopeCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->gyroscopeCount()) + return; - // Set gauge palette - QPalette palette; - palette.setColor(QPalette::WindowText, theme->base()); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - m_gauge.setPalette(palette); + // Set gauge palette + QPalette palette; + palette.setColor(QPalette::WindowText, theme->base()); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + m_gauge.setPalette(palette); - // Set widget pointer - setWidget(&m_gauge); + // Set widget pointer + setWidget(&m_gauge); - // Show different values each second - // clang-format off + // Show different values each second + // clang-format off connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout1Hz, this, &Widgets::Gyroscope::updateLabel); - // clang-format on + // clang-format on - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -70,69 +71,65 @@ Widgets::Gyroscope::Gyroscope(const int index) */ void Widgets::Gyroscope::updateData() { - if (!isEnabled()) - return; + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->gyroscopeCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->gyroscopeCount()) + return; - // Get group reference & validate dataset count - auto group = dash->getGyroscope(m_index); - if (group.datasetCount() != 3) - return; + // Get group reference & validate dataset count + auto group = dash->getGyroscope(m_index); + if (group.datasetCount() != 3) + return; - // Initialize values for pitch, roll & yaw - double p = 0; - double r = 0; - double y = 0; + // Initialize values for pitch, roll & yaw + double p = 0; + double r = 0; + double y = 0; - // Extract pitch, roll & yaw from group datasets - for (int i = 0; i < 3; ++i) - { - auto dataset = group.getDataset(i); - if (dataset.widget() == "pitch") - p = dataset.value().toDouble(); - if (dataset.widget() == "roll") - r = dataset.value().toDouble(); - if (dataset.widget() == "yaw") - y = dataset.value().toDouble(); - } + // Extract pitch, roll & yaw from group datasets + for (int i = 0; i < 3; ++i) + { + auto dataset = group.getDataset(i); + if (dataset.widget() == "pitch") + p = dataset.value().toDouble(); + if (dataset.widget() == "roll") + r = dataset.value().toDouble(); + if (dataset.widget() == "yaw") + y = dataset.value().toDouble(); + } - // Construct strings from pitch, roll & yaw - m_yaw = QString::number(qAbs(y), 'f', dash->precision()); - m_roll = QString::number(qAbs(r), 'f', dash->precision()); - m_pitch = QString::number(qAbs(p), 'f', dash->precision()); + // Construct strings from pitch, roll & yaw + m_yaw = QString::number(qAbs(y), 'f', dash->precision()); + m_roll = QString::number(qAbs(r), 'f', dash->precision()); + m_pitch = QString::number(qAbs(p), 'f', dash->precision()); - // Update gauge - m_gauge.setValue(p); - m_gauge.setGradient(r / 360.0); + // Update gauge + m_gauge.setValue(p); + m_gauge.setGradient(r / 360.0); - // Repaint the widget - requestRepaint(); + // Repaint the widget + requestRepaint(); } void Widgets::Gyroscope::updateLabel() { - switch (m_displayNum) - { - case 0: - setValue(QString("%1° PITCH").arg(m_pitch)); - break; - case 1: - setValue(QString("%1° ROLL").arg(m_roll)); - break; - case 2: - setValue(QString("%1° YAW").arg(m_yaw)); - break; - } + switch (m_displayNum) + { + case 0: + setValue(QString("%1° PITCH").arg(m_pitch)); + break; + case 1: + setValue(QString("%1° ROLL").arg(m_roll)); + break; + case 2: + setValue(QString("%1° YAW").arg(m_yaw)); + break; + } - ++m_displayNum; - if (m_displayNum > 2) - m_displayNum = 0; + ++m_displayNum; + if (m_displayNum > 2) + m_displayNum = 0; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Gyroscope.cpp" -#endif diff --git a/src/UI/Widgets/Gyroscope.h b/src/UI/Widgets/Gyroscope.h index 28b40fa1..4ec95e24 100644 --- a/src/UI/Widgets/Gyroscope.h +++ b/src/UI/Widgets/Gyroscope.h @@ -29,21 +29,21 @@ namespace Widgets { class Gyroscope : public BaseWidget { - Q_OBJECT + Q_OBJECT public: - Gyroscope(const int index = -1); + Gyroscope(const int index = -1); private Q_SLOTS: - void updateData(); - void updateLabel(); + void updateData(); + void updateLabel(); private: - int m_index; - int m_displayNum; - QString m_yaw; - QString m_roll; - QString m_pitch; - AttitudeIndicator m_gauge; + int m_index; + int m_displayNum; + QString m_yaw; + QString m_roll; + QString m_pitch; + AttitudeIndicator m_gauge; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/LEDPanel.cpp b/src/UI/Widgets/LEDPanel.cpp index 5e696024..3abd5569 100644 --- a/src/UI/Widgets/LEDPanel.cpp +++ b/src/UI/Widgets/LEDPanel.cpp @@ -30,97 +30,98 @@ * Generates the user interface elements & layout */ Widgets::LEDPanel::LEDPanel(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->ledCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->ledCount()) + return; - // Get group reference - auto group = dash->getLED(m_index); + // Get group reference + auto group = dash->getLED(m_index); - // Generate widget stylesheets - auto titleQSS = QSS("color:%1", theme->widgetTextPrimary()); + // Generate widget stylesheets + auto titleQSS = QSS("color:%1", theme->widgetTextPrimary()); - // Set window palette - QPalette windowPalette; - windowPalette.setColor(QPalette::Base, theme->widgetWindowBackground()); - windowPalette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(windowPalette); + // Set window palette + QPalette windowPalette; + windowPalette.setColor(QPalette::Base, theme->widgetWindowBackground()); + windowPalette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(windowPalette); - // Configure scroll area container - m_dataContainer = new QWidget(this); + // Configure scroll area container + m_dataContainer = new QWidget(this); - // Make the value label larger - auto valueFont = dash->monoFont(); - valueFont.setPixelSize(dash->monoFont().pixelSize() * 1.3); + // Make the value label larger + auto valueFont = dash->monoFont(); + valueFont.setPixelSize(dash->monoFont().pixelSize() * 1.3); - // Configure grid layout - m_leds.reserve(group.datasetCount()); - m_titles.reserve(group.datasetCount()); - m_gridLayout = new QGridLayout(m_dataContainer); - m_gridLayout->setSpacing(16); - for (int dataset = 0; dataset < group.datasetCount(); ++dataset) + // Configure grid layout + m_leds.reserve(group.datasetCount()); + m_titles.reserve(group.datasetCount()); + m_gridLayout = new QGridLayout(m_dataContainer); + m_gridLayout->setSpacing(16); + for (int dataset = 0; dataset < group.datasetCount(); ++dataset) + { + // Create labels + m_leds.append(new KLed(m_dataContainer)); + m_titles.append(new QLabel(m_dataContainer)); + + // Get pointers to labels + auto led = m_leds.last(); + auto title = m_titles.last(); + + // Set label styles & fonts + title->setStyleSheet(titleQSS); + title->setFont(dash->monoFont()); + title->setText(group.getDataset(dataset).title()); + + // Set LED color & style + led->setLook(KLed::Sunken); + led->setShape(KLed::Circular); + led->setColor(theme->ledEnabled()); + + // Calculate column and row + int column = 0; + int row = dataset; + int count = dataset + 1; + while (count > 3) { - // Create labels - m_leds.append(new KLed(m_dataContainer)); - m_titles.append(new QLabel(m_dataContainer)); - - // Get pointers to labels - auto led = m_leds.last(); - auto title = m_titles.last(); - - // Set label styles & fonts - title->setStyleSheet(titleQSS); - title->setFont(dash->monoFont()); - title->setText(group.getDataset(dataset).title()); - - // Set LED color & style - led->setLook(KLed::Sunken); - led->setShape(KLed::Circular); - led->setColor(theme->ledEnabled()); - - // Calculate column and row - int column = 0; - int row = dataset; - int count = dataset + 1; - while (count > 3) - { - count -= 3; - row -= 3; - column += 2; - } - - // Add label and LED to grid layout - m_gridLayout->addWidget(led, row, column); - m_gridLayout->addWidget(title, row, column + 1); - m_gridLayout->setAlignment(led, Qt::AlignRight | Qt::AlignVCenter); - m_gridLayout->setAlignment(title, Qt::AlignLeft | Qt::AlignVCenter); + count -= 3; + row -= 3; + column += 2; } - // Load layout into container widget - m_dataContainer->setLayout(m_gridLayout); + // Add label and LED to grid layout + m_gridLayout->addWidget(led, row, column); + m_gridLayout->addWidget(title, row, column + 1); + m_gridLayout->setAlignment(led, Qt::AlignRight | Qt::AlignVCenter); + m_gridLayout->setAlignment(title, Qt::AlignLeft | Qt::AlignVCenter); + } - // Configure scroll area - m_scrollArea = new QScrollArea(this); - m_scrollArea->setWidgetResizable(true); - m_scrollArea->setWidget(m_dataContainer); - m_scrollArea->setFrameShape(QFrame::NoFrame); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // Load layout into container widget + m_dataContainer->setLayout(m_gridLayout); - // Configure main layout - m_mainLayout = new QVBoxLayout(this); - m_mainLayout->addWidget(m_scrollArea); - m_mainLayout->setContentsMargins(0, 0, 0, 0); - setLayout(m_mainLayout); + // Configure scroll area + m_scrollArea = new QScrollArea(this); + m_scrollArea->setWidgetResizable(true); + m_scrollArea->setWidget(m_dataContainer); + m_scrollArea->setFrameShape(QFrame::NoFrame); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // React to dashboard events - connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); + // Configure main layout + m_mainLayout = new QVBoxLayout(this); + m_mainLayout->addWidget(m_scrollArea); + m_mainLayout->setContentsMargins(0, 0, 0, 0); + setLayout(m_mainLayout); + + // React to dashboard events + connect(dash, SIGNAL(updated()), this, SLOT(updateData()), + Qt::QueuedConnection); } /** @@ -128,15 +129,15 @@ Widgets::LEDPanel::LEDPanel(const int index) */ Widgets::LEDPanel::~LEDPanel() { - Q_FOREACH (auto led, m_leds) - delete led; + Q_FOREACH (auto led, m_leds) + delete led; - Q_FOREACH (auto title, m_titles) - delete title; + Q_FOREACH (auto title, m_titles) + delete title; - delete m_gridLayout; - delete m_scrollArea; - delete m_mainLayout; + delete m_gridLayout; + delete m_scrollArea; + delete m_mainLayout; } /** @@ -148,35 +149,35 @@ Widgets::LEDPanel::~LEDPanel() */ void Widgets::LEDPanel::updateData() { - // Widget not enabled, do nothing - if (!isEnabled()) - return; + // Widget not enabled, do nothing + if (!isEnabled()) + return; - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->ledCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->ledCount()) + return; - // Get group pointer - auto group = dash->getLED(m_index); + // Get group pointer + auto group = dash->getLED(m_index); - // Update labels - for (int i = 0; i < group.datasetCount(); ++i) - { - // Check vector size - if (m_leds.count() < i) - break; + // Update labels + for (int i = 0; i < group.datasetCount(); ++i) + { + // Check vector size + if (m_leds.count() < i) + break; - // Get dataset value (we compare with 0.1 for low voltages) - auto value = group.getDataset(i).value().toDouble(); - if (qAbs(value) < 0.10) - m_leds.at(i)->off(); - else - m_leds.at(i)->on(); - } + // Get dataset value (we compare with 0.1 for low voltages) + auto value = group.getDataset(i).value().toDouble(); + if (qAbs(value) < 0.10) + m_leds.at(i)->off(); + else + m_leds.at(i)->on(); + } - // Repaint widget - requestRepaint(); + // Repaint widget + requestRepaint(); } /** @@ -184,20 +185,16 @@ void Widgets::LEDPanel::updateData() */ void Widgets::LEDPanel::resizeEvent(QResizeEvent *event) { - auto width = event->size().width(); - QFont font = UI::Dashboard::instance().monoFont(); - font.setPixelSize(qMax(8, width / 24)); - auto fHeight = QFontMetrics(font).height() * 1.5; + auto width = event->size().width(); + QFont font = UI::Dashboard::instance().monoFont(); + font.setPixelSize(qMax(8, width / 24)); + auto fHeight = QFontMetrics(font).height() * 1.5; - for (int i = 0; i < m_titles.count(); ++i) - { - m_titles.at(i)->setFont(font); - m_leds.at(i)->setMinimumSize(fHeight, fHeight); - } + for (int i = 0; i < m_titles.count(); ++i) + { + m_titles.at(i)->setFont(font); + m_leds.at(i)->setMinimumSize(fHeight, fHeight); + } - event->accept(); + event->accept(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_LEDPanel.cpp" -#endif diff --git a/src/UI/Widgets/LEDPanel.h b/src/UI/Widgets/LEDPanel.h index 2be0f167..62c2f81d 100644 --- a/src/UI/Widgets/LEDPanel.h +++ b/src/UI/Widgets/LEDPanel.h @@ -34,27 +34,27 @@ namespace Widgets { class LEDPanel : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT public: - LEDPanel(const int index = -1); - ~LEDPanel(); + LEDPanel(const int index = -1); + ~LEDPanel(); private Q_SLOTS: - void updateData(); + void updateData(); protected: - void resizeEvent(QResizeEvent *event); + void resizeEvent(QResizeEvent *event); private: - int m_index; + int m_index; - QVector m_leds; - QVector m_titles; + QVector m_leds; + QVector m_titles; - QWidget *m_dataContainer; - QVBoxLayout *m_mainLayout; - QGridLayout *m_gridLayout; - QScrollArea *m_scrollArea; + QWidget *m_dataContainer; + QVBoxLayout *m_mainLayout; + QGridLayout *m_gridLayout; + QScrollArea *m_scrollArea; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/MultiPlot.cpp b/src/UI/Widgets/MultiPlot.cpp index 16432649..b9efe152 100644 --- a/src/UI/Widgets/MultiPlot.cpp +++ b/src/UI/Widgets/MultiPlot.cpp @@ -29,98 +29,98 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::MultiPlot::MultiPlot(const int index) - : m_index(index) + : m_index(index) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->multiPlotCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->multiPlotCount()) + return; - // Set window palette - QPalette palette; - palette.setColor(QPalette::Base, theme->widgetWindowBackground()); - palette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(palette); + // Set window palette + QPalette palette; + palette.setColor(QPalette::Base, theme->widgetWindowBackground()); + palette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(palette); - // Set plot palette - palette.setColor(QPalette::Base, theme->base()); - palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - palette.setColor(QPalette::Dark, theme->widgetIndicator()); - palette.setColor(QPalette::Light, theme->widgetIndicator()); - palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); - palette.setColor(QPalette::WindowText, theme->widgetIndicator()); - m_plot.setPalette(palette); - m_plot.setCanvasBackground(theme->base()); - m_plot.setFrameStyle(QFrame::Plain); + // Set plot palette + palette.setColor(QPalette::Base, theme->base()); + palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + palette.setColor(QPalette::Dark, theme->widgetIndicator()); + palette.setColor(QPalette::Light, theme->widgetIndicator()); + palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); + palette.setColor(QPalette::WindowText, theme->widgetIndicator()); + m_plot.setPalette(palette); + m_plot.setCanvasBackground(theme->base()); + m_plot.setFrameStyle(QFrame::Plain); - // Configure layout - m_layout.addWidget(&m_plot); - m_layout.setContentsMargins(24, 24, 24, 24); - setLayout(&m_layout); + // Configure layout + m_layout.addWidget(&m_plot); + m_layout.setContentsMargins(24, 24, 24, 24); + setLayout(&m_layout); - // Fit data horizontally - m_plot.axisScaleEngine(QwtPlot::xBottom) - ->setAttribute(QwtScaleEngine::Floating, true); + // Fit data horizontally + m_plot.axisScaleEngine(QwtPlot::xBottom) + ->setAttribute(QwtScaleEngine::Floating, true); - // Create curves from datasets - bool normalize = true; - auto group = dash->getMultiplot(m_index); - StringList colors = theme->widgetColors(); - m_curves.reserve(group.datasetCount()); - for (int i = 0; i < group.datasetCount(); ++i) - { - // Get dataset title & min/max values - QString title = tr("Unknown"); - auto dataset = group.getDataset(i); - title = dataset.title(); - normalize &= dataset.max() > dataset.min(); + // Create curves from datasets + bool normalize = true; + auto group = dash->getMultiplot(m_index); + StringList colors = theme->widgetColors(); + m_curves.reserve(group.datasetCount()); + for (int i = 0; i < group.datasetCount(); ++i) + { + // Get dataset title & min/max values + QString title = tr("Unknown"); + auto dataset = group.getDataset(i); + title = dataset.title(); + normalize &= dataset.max() > dataset.min(); - // Create curve - auto curve = new QwtPlotCurve(title); + // Create curve + auto curve = new QwtPlotCurve(title); - // Get curve color - QString color; - if (colors.count() > i) - color = colors.at(i); - else if (i > 0) - color = colors.at(colors.count() % i); + // Get curve color + QString color; + if (colors.count() > i) + color = colors.at(i); + else if (i > 0) + color = colors.at(colors.count() % i); - // Configure curve - curve->setPen(QColor(color), 2, Qt::SolidLine); - curve->attach(&m_plot); + // Configure curve + curve->setPen(QColor(color), 2, Qt::SolidLine); + curve->attach(&m_plot); - // Register curve - m_curves.append(curve); - } + // Register curve + m_curves.append(curve); + } - // Add plot legend to display curve names - m_legend.setFrameStyle(QFrame::Plain); - m_plot.setAxisTitle(QwtPlot::yLeft, group.title()); - m_plot.setAxisTitle(QwtPlot::xBottom, tr("Samples")); - m_plot.insertLegend(&m_legend, QwtPlot::BottomLegend); + // Add plot legend to display curve names + m_legend.setFrameStyle(QFrame::Plain); + m_plot.setAxisTitle(QwtPlot::yLeft, group.title()); + m_plot.setAxisTitle(QwtPlot::xBottom, tr("Samples")); + m_plot.insertLegend(&m_legend, QwtPlot::BottomLegend); - // Normalize data curves - if (normalize) - m_plot.setAxisScale(QwtPlot::yLeft, 0, 1); + // Normalize data curves + if (normalize) + m_plot.setAxisScale(QwtPlot::yLeft, 0, 1); - // Show plot - updateRange(); - m_plot.replot(); - m_plot.show(); + // Show plot + updateRange(); + m_plot.replot(); + m_plot.show(); - // React to dashboard events - // clang-format off + // React to dashboard events + // clang-format off connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); connect(dash, SIGNAL(pointsChanged()), this, SLOT(updateRange()), Qt::QueuedConnection); - // clang-format on + // clang-format on } /** @@ -133,56 +133,56 @@ Widgets::MultiPlot::MultiPlot(const int index) */ void Widgets::MultiPlot::updateData() { - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->multiPlotCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->multiPlotCount()) + return; - // Get group - auto group = dash->getMultiplot(m_index); + // Get group + auto group = dash->getMultiplot(m_index); - // Plot each dataset - for (int i = 0; i < group.datasetCount(); ++i) + // Plot each dataset + for (int i = 0; i < group.datasetCount(); ++i) + { + // Check vector size + if (m_yData.count() < i) + break; + + // Get dataset + auto dataset = group.getDataset(i); + + // Add point to plot data + auto data = m_yData[i].data(); + auto count = m_yData[i].count(); + memmove(data, data + 1, count * sizeof(double)); + + // Normalize dataset value + if (dataset.max() > dataset.min()) { - // Check vector size - if (m_yData.count() < i) - break; - - // Get dataset - auto dataset = group.getDataset(i); - - // Add point to plot data - auto data = m_yData[i].data(); - auto count = m_yData[i].count(); - memmove(data, data + 1, count * sizeof(double)); - - // Normalize dataset value - if (dataset.max() > dataset.min()) - { - auto vmin = dataset.min(); - auto vmax = dataset.max(); - auto v = dataset.value().toDouble(); - m_yData[i][count - 1] = (v - vmin) / (vmax - vmin); - } - - // Plot dataset value directly - else - m_yData[i][count - 1] = dataset.value().toDouble(); - - // Widget not enabled, do not redraw - if (!isEnabled()) - continue; - - // Plot new data - m_curves.at(i)->setSamples(m_yData[i]); + auto vmin = dataset.min(); + auto vmax = dataset.max(); + auto v = dataset.value().toDouble(); + m_yData[i][count - 1] = (v - vmin) / (vmax - vmin); } - // Plot widget again - if (isEnabled()) - { - m_plot.replot(); - requestRepaint(); - } + // Plot dataset value directly + else + m_yData[i][count - 1] = dataset.value().toDouble(); + + // Widget not enabled, do not redraw + if (!isEnabled()) + continue; + + // Plot new data + m_curves.at(i)->setSamples(m_yData[i]); + } + + // Plot widget again + if (isEnabled()) + { + m_plot.replot(); + requestRepaint(); + } } /** @@ -190,30 +190,26 @@ void Widgets::MultiPlot::updateData() */ void Widgets::MultiPlot::updateRange() { - // Invalid index, abort update - auto dash = &UI::Dashboard::instance(); - if (m_index < 0 || m_index >= dash->multiPlotCount()) - return; + // Invalid index, abort update + auto dash = &UI::Dashboard::instance(); + if (m_index < 0 || m_index >= dash->multiPlotCount()) + return; - // Set number of points - m_yData.clear(); - auto group = UI::Dashboard::instance().getMultiplot(m_index); - for (int i = 0; i < group.datasetCount(); ++i) - { - m_yData.append(PlotData()); - m_yData.last().resize(dash->points()); - std::fill(m_yData.last().begin(), m_yData.last().end(), 0.0001); - } + // Set number of points + m_yData.clear(); + auto group = UI::Dashboard::instance().getMultiplot(m_index); + for (int i = 0; i < group.datasetCount(); ++i) + { + m_yData.append(PlotData()); + m_yData.last().resize(dash->points()); + std::fill(m_yData.last().begin(), m_yData.last().end(), 0.0001); + } - // Create curve from data - for (int i = 0; i < group.datasetCount(); ++i) - if (m_curves.count() > i) - m_curves.at(i)->setSamples(dash->xPlotValues(), m_yData[i]); + // Create curve from data + for (int i = 0; i < group.datasetCount(); ++i) + if (m_curves.count() > i) + m_curves.at(i)->setSamples(dash->xPlotValues(), m_yData[i]); - // Repaint widget - requestRepaint(); + // Repaint widget + requestRepaint(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_MultiPlot.cpp" -#endif diff --git a/src/UI/Widgets/MultiPlot.h b/src/UI/Widgets/MultiPlot.h index 3de19f9e..20d7b61c 100644 --- a/src/UI/Widgets/MultiPlot.h +++ b/src/UI/Widgets/MultiPlot.h @@ -36,21 +36,21 @@ namespace Widgets { class MultiPlot : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT public: - MultiPlot(const int index = -1); + MultiPlot(const int index = -1); private Q_SLOTS: - void updateData(); - void updateRange(); + void updateData(); + void updateRange(); private: - int m_index; - QwtPlot m_plot; - QwtLegend m_legend; - QVBoxLayout m_layout; - QVector m_curves; - QVector m_yData; + int m_index; + QwtPlot m_plot; + QwtLegend m_legend; + QVBoxLayout m_layout; + QVector m_curves; + QVector m_yData; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Plot.cpp b/src/UI/Widgets/Plot.cpp index e224ea26..92b3dfc0 100644 --- a/src/UI/Widgets/Plot.cpp +++ b/src/UI/Widgets/Plot.cpp @@ -29,101 +29,101 @@ * Constructor function, configures widget style & signal/slot connections. */ Widgets::Plot::Plot(const int index) - : m_index(index) - , m_min(INT_MAX) - , m_max(INT_MIN) - , m_autoscale(true) + : m_index(index) + , m_min(INT_MAX) + , m_max(INT_MIN) + , m_autoscale(true) { - // Get pointers to serial studio modules - auto dash = &UI::Dashboard::instance(); - auto theme = &Misc::ThemeManager::instance(); + // Get pointers to serial studio modules + auto dash = &UI::Dashboard::instance(); + auto theme = &Misc::ThemeManager::instance(); - // Invalid index, abort initialization - if (m_index < 0 || m_index >= dash->plotCount()) - return; + // Invalid index, abort initialization + if (m_index < 0 || m_index >= dash->plotCount()) + return; - // Set window palette - QPalette palette; - palette.setColor(QPalette::Base, theme->widgetWindowBackground()); - palette.setColor(QPalette::Window, theme->widgetWindowBackground()); - setPalette(palette); + // Set window palette + QPalette palette; + palette.setColor(QPalette::Base, theme->widgetWindowBackground()); + palette.setColor(QPalette::Window, theme->widgetWindowBackground()); + setPalette(palette); - // Set plot palette - palette.setColor(QPalette::Base, theme->base()); - palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); - palette.setColor(QPalette::Text, theme->widgetIndicator()); - palette.setColor(QPalette::Dark, theme->widgetIndicator()); - palette.setColor(QPalette::Light, theme->widgetIndicator()); - palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); - palette.setColor(QPalette::WindowText, theme->widgetIndicator()); - m_plot.setPalette(palette); - m_plot.setCanvasBackground(theme->base()); - m_plot.setFrameStyle(QFrame::Plain); + // Set plot palette + palette.setColor(QPalette::Base, theme->base()); + palette.setColor(QPalette::Highlight, QColor(255, 0, 0)); + palette.setColor(QPalette::Text, theme->widgetIndicator()); + palette.setColor(QPalette::Dark, theme->widgetIndicator()); + palette.setColor(QPalette::Light, theme->widgetIndicator()); + palette.setColor(QPalette::ButtonText, theme->widgetIndicator()); + palette.setColor(QPalette::WindowText, theme->widgetIndicator()); + m_plot.setPalette(palette); + m_plot.setCanvasBackground(theme->base()); + m_plot.setFrameStyle(QFrame::Plain); - // Configure layout - m_layout.addWidget(&m_plot); - m_layout.setContentsMargins(24, 24, 24, 24); - setLayout(&m_layout); + // Configure layout + m_layout.addWidget(&m_plot); + m_layout.setContentsMargins(24, 24, 24, 24); + setLayout(&m_layout); - // Fit data horizontally - auto xAxisEngine = m_plot.axisScaleEngine(QwtPlot::xBottom); - xAxisEngine->setAttribute(QwtScaleEngine::Floating, true); + // Fit data horizontally + auto xAxisEngine = m_plot.axisScaleEngine(QwtPlot::xBottom); + xAxisEngine->setAttribute(QwtScaleEngine::Floating, true); - // Create curve from data - updateRange(); - m_curve.attach(&m_plot); - m_plot.replot(); - m_plot.show(); + // Create curve from data + updateRange(); + m_curve.attach(&m_plot); + m_plot.replot(); + m_plot.show(); - // Get curve color - QString color; - StringList colors = theme->widgetColors(); - if (colors.count() > m_index) - color = colors.at(m_index); - else - { - auto index = colors.count() % m_index; - if (index >= colors.count()) - index = colors.count() - 1; + // Get curve color + QString color; + StringList colors = theme->widgetColors(); + if (colors.count() > m_index) + color = colors.at(m_index); + else + { + auto index = colors.count() % m_index; + if (index >= colors.count()) + index = colors.count() - 1; - color = colors.at(index); - } + color = colors.at(index); + } - // Set curve color & plot style - m_curve.setPen(QColor(color), 2, Qt::SolidLine); + // Set curve color & plot style + m_curve.setPen(QColor(color), 2, Qt::SolidLine); - // Update graph scale - auto dataset = UI::Dashboard::instance().getPlot(m_index); - auto max = dataset.max(); - auto min = dataset.min(); - if (max > min) - { - m_max = max; - m_min = min; - m_autoscale = false; - m_plot.setAxisScale(QwtPlot::yLeft, m_min, m_max); - } + // Update graph scale + auto dataset = UI::Dashboard::instance().getPlot(m_index); + auto max = dataset.max(); + auto min = dataset.min(); + if (max > min) + { + m_max = max; + m_min = min; + m_autoscale = false; + m_plot.setAxisScale(QwtPlot::yLeft, m_min, m_max); + } - // Enable logarithmic scale - // clang-format off + // Enable logarithmic scale + // clang-format off if (dataset.log()) m_plot.setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine(10)); - // clang-format on + // clang-format on - // Set axis titles - m_plot.setAxisTitle(QwtPlot::xBottom, tr("Samples")); - m_plot.setAxisTitle(QwtPlot::yLeft, dataset.title()); + // Set axis titles + m_plot.setAxisTitle(QwtPlot::xBottom, tr("Samples")); + m_plot.setAxisTitle(QwtPlot::yLeft, dataset.title()); - // React to dashboard events - // clang-format off + // React to dashboard events + // clang-format off connect(dash, SIGNAL(updated()), this, SLOT(updateData()), Qt::QueuedConnection); connect(dash, SIGNAL(pointsChanged()), this, SLOT(updateRange()), Qt::QueuedConnection); - // clang-format on + // clang-format on } /** @@ -136,78 +136,79 @@ Widgets::Plot::Plot(const int index) */ void Widgets::Plot::updateData() { - // Widget not enabled, do not redraw - if (!isEnabled()) - return; + // Widget not enabled, do not redraw + if (!isEnabled()) + return; - // Get new data - auto plotData = UI::Dashboard::instance().linearPlotValues(); - if (plotData.count() > m_index) + // Get new data + auto plotData = UI::Dashboard::instance().linearPlotValues(); + if (plotData.count() > m_index) + { + // Check if we need to update graph scale + if (m_autoscale) { - // Check if we need to update graph scale - if (m_autoscale) + // Scan new values to see if chart should be updated + bool changed = false; + for (int i = 0; i < plotData.at(m_index).count(); ++i) + { + auto v = plotData.at(m_index).at(i); + if (v > m_max) { - // Scan new values to see if chart should be updated - bool changed = false; - for (int i = 0; i < plotData.at(m_index).count(); ++i) - { - auto v = plotData.at(m_index).at(i); - if (v > m_max) - { - m_max = v + 1; - changed = true; - } - - if (v < m_min) - { - m_min = v - 1; - changed = true; - } - } - - // Update graph scale - if (changed) - { - // Get central value - double median = qMax(1, (m_max + m_min)) / 2; - if (m_max == m_min) - median = m_max; - - // Center graph verticaly - double mostDiff = qMax(qAbs(m_min), qAbs(m_max)); - double min = median * (1 - 0.5) - qAbs(median - mostDiff); - double max = median * (1 + 0.5) + qAbs(median - mostDiff); - if (m_min < 0) - min = max * -1; - - // Fix issues when min & max are equal - if (min == max) - { - max = qAbs(max); - min = max * -1; - } - - // Fix issues on min = max = (0,0) - if (min == 0 && max == 0) - { - max = 1; - min = -1; - } - - // Update axis scale - m_max = max; - m_min = min; - m_plot.setAxisScale(m_plot.yLeft, m_min, m_max); - } + m_max = v + 1; + changed = true; } - // Replot graph - m_curve.setSamples(plotData.at(m_index)); - m_plot.replot(); + if (v < m_min) + { + m_min = v - 1; + changed = true; + } + } - // Repaint widget - requestRepaint(); + // Update graph scale + if (changed) + { + // Get central value + double median = qMax(1, (m_max + m_min)) / 2; + if (m_max == m_min) + median = m_max; + + // Center graph verticaly + double mostDiff + = qMax(qAbs(m_min), qAbs(m_max)); + double min = median * (1 - 0.5) - qAbs(median - mostDiff); + double max = median * (1 + 0.5) + qAbs(median - mostDiff); + if (m_min < 0) + min = max * -1; + + // Fix issues when min & max are equal + if (min == max) + { + max = qAbs(max); + min = max * -1; + } + + // Fix issues on min = max = (0,0) + if (min == 0 && max == 0) + { + max = 1; + min = -1; + } + + // Update axis scale + m_max = max; + m_min = min; + m_plot.setAxisScale(m_plot.yLeft, m_min, m_max); + } } + + // Replot graph + m_curve.setSamples(plotData.at(m_index)); + m_plot.replot(); + + // Repaint widget + requestRepaint(); + } } /** @@ -215,23 +216,19 @@ void Widgets::Plot::updateData() */ void Widgets::Plot::updateRange() { - // Get pointer to dashboard manager - auto dash = &UI::Dashboard::instance(); + // Get pointer to dashboard manager + auto dash = &UI::Dashboard::instance(); - // Clear Y-axis data - PlotData tempYData; - tempYData.reserve(dash->points()); - for (int i = 0; i < dash->points(); ++i) - tempYData.append(0); + // Clear Y-axis data + PlotData tempYData; + tempYData.reserve(dash->points()); + for (int i = 0; i < dash->points(); ++i) + tempYData.append(0); - // Redraw graph - m_curve.setSamples(dash->xPlotValues(), tempYData); - m_plot.replot(); + // Redraw graph + m_curve.setSamples(dash->xPlotValues(), tempYData); + m_plot.replot(); - // Repaint widget - requestRepaint(); + // Repaint widget + requestRepaint(); } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Plot.cpp" -#endif diff --git a/src/UI/Widgets/Plot.h b/src/UI/Widgets/Plot.h index 1ce6a9fd..46e76506 100644 --- a/src/UI/Widgets/Plot.h +++ b/src/UI/Widgets/Plot.h @@ -33,23 +33,23 @@ namespace Widgets { class Plot : public DashboardWidgetBase { - Q_OBJECT + Q_OBJECT public: - Plot(const int index = -1); + Plot(const int index = -1); private Q_SLOTS: - void updateData(); - void updateRange(); + void updateData(); + void updateRange(); private: - int m_index; - double m_min; - double m_max; - bool m_autoscale; + int m_index; + double m_min; + double m_max; + bool m_autoscale; - QwtPlot m_plot; - QwtPlotCurve m_curve; - QVBoxLayout m_layout; + QwtPlot m_plot; + QwtPlotCurve m_curve; + QVBoxLayout m_layout; }; -} +} // namespace Widgets diff --git a/src/UI/Widgets/Terminal.cpp b/src/UI/Widgets/Terminal.cpp index 164a63eb..3a1ac2cf 100644 --- a/src/UI/Widgets/Terminal.cpp +++ b/src/UI/Widgets/Terminal.cpp @@ -36,46 +36,47 @@ * Constructor function */ Widgets::Terminal::Terminal(QQuickItem *parent) - : UI::DeclarativeWidget(parent) - , m_repaint(false) - , m_autoscroll(true) - , m_textChanged(false) - , m_emulateVt100(false) - , m_copyAvailable(false) + : UI::DeclarativeWidget(parent) + , m_repaint(false) + , m_autoscroll(true) + , m_textChanged(false) + , m_emulateVt100(false) + , m_copyAvailable(false) { - // Set widget & configure VT-100 emulator - setWidget(&m_textEdit); - m_escapeCodeHandler.setTextEdit(&m_textEdit); + // Set widget & configure VT-100 emulator + setWidget(&m_textEdit); + m_escapeCodeHandler.setTextEdit(&m_textEdit); - // Setup default options - setScrollbarWidth(14); - m_textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_textEdit.setSizeAdjustPolicy(QPlainTextEdit::AdjustToContents); + // Setup default options + setScrollbarWidth(14); + m_textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_textEdit.setSizeAdjustPolicy(QPlainTextEdit::AdjustToContents); - // Set widget palette - QPalette palette; - auto theme = &Misc::ThemeManager::instance(); - palette.setColor(QPalette::Text, theme->consoleText()); - palette.setColor(QPalette::Base, theme->consoleBase()); - palette.setColor(QPalette::Button, theme->consoleButton()); - palette.setColor(QPalette::Window, theme->consoleWindow()); - palette.setColor(QPalette::Highlight, theme->consoleHighlight()); - palette.setColor(QPalette::HighlightedText, theme->consoleHighlightedText()); + // Set widget palette + QPalette palette; + auto theme = &Misc::ThemeManager::instance(); + palette.setColor(QPalette::Text, theme->consoleText()); + palette.setColor(QPalette::Base, theme->consoleBase()); + palette.setColor(QPalette::Button, theme->consoleButton()); + palette.setColor(QPalette::Window, theme->consoleWindow()); + palette.setColor(QPalette::Highlight, theme->consoleHighlight()); + palette.setColor(QPalette::HighlightedText, theme->consoleHighlightedText()); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - palette.setColor(QPalette::PlaceholderText, theme->consolePlaceholderText()); + palette.setColor(QPalette::PlaceholderText, theme->consolePlaceholderText()); #endif - m_textEdit.setPalette(palette); + m_textEdit.setPalette(palette); - // Connect signals/slots - // clang-format off + // Connect signals/slots + // clang-format off connect(&IO::Console::instance(), &IO::Console::stringReceived, this, &Widgets::Terminal::insertText); connect(&Misc::TimerEvents::instance(), &Misc::TimerEvents::timeout10Hz, this, &Widgets::Terminal::repaint); - // clang-format on + // clang-format on - // React to widget events - connect(&m_textEdit, SIGNAL(copyAvailable(bool)), this, SLOT(setCopyAvailable(bool))); + // React to widget events + connect(&m_textEdit, SIGNAL(copyAvailable(bool)), this, + SLOT(setCopyAvailable(bool))); } /** @@ -83,7 +84,7 @@ Widgets::Terminal::Terminal(QQuickItem *parent) */ QFont Widgets::Terminal::font() const { - return m_textEdit.font(); + return m_textEdit.font(); } /** @@ -91,7 +92,7 @@ QFont Widgets::Terminal::font() const */ QString Widgets::Terminal::text() const { - return m_textEdit.toPlainText(); + return m_textEdit.toPlainText(); } /** @@ -99,7 +100,7 @@ QString Widgets::Terminal::text() const */ bool Widgets::Terminal::empty() const { - return m_textEdit.document()->isEmpty(); + return m_textEdit.document()->isEmpty(); } /** @@ -107,16 +108,16 @@ bool Widgets::Terminal::empty() const */ bool Widgets::Terminal::readOnly() const { - return m_textEdit.isReadOnly(); + return m_textEdit.isReadOnly(); } /** - * Returns @c true if the widget shall scroll automatically to the bottom when new - * text is appended to the widget. + * Returns @c true if the widget shall scroll automatically to the bottom when + * new text is appended to the widget. */ bool Widgets::Terminal::autoscroll() const { - return m_autoscroll; + return m_autoscroll; } /** @@ -124,16 +125,16 @@ bool Widgets::Terminal::autoscroll() const */ QPalette Widgets::Terminal::palette() const { - return m_textEdit.palette(); + return m_textEdit.palette(); } /** - * Returns the wrap mode of the QPlainTextEdit casted to an integer type (so that it - * can be used from the QML interface). + * Returns the wrap mode of the QPlainTextEdit casted to an integer type (so + * that it can be used from the QML interface). */ int Widgets::Terminal::wordWrapMode() const { - return static_cast(m_textEdit.wordWrapMode()); + return static_cast(m_textEdit.wordWrapMode()); } /** @@ -141,16 +142,17 @@ int Widgets::Terminal::wordWrapMode() const */ int Widgets::Terminal::scrollbarWidth() const { - return m_textEdit.verticalScrollBar()->width(); + return m_textEdit.verticalScrollBar()->width(); } /** - * Returns @c true if the user is able to copy any text from the document. This value is - * updated through the copyAvailable() signal sent by the QPlainTextEdit. + * Returns @c true if the user is able to copy any text from the document. This + * value is updated through the copyAvailable() signal sent by the + * QPlainTextEdit. */ bool Widgets::Terminal::copyAvailable() const { - return m_copyAvailable; + return m_copyAvailable; } /** @@ -158,63 +160,64 @@ bool Widgets::Terminal::copyAvailable() const */ bool Widgets::Terminal::widgetEnabled() const { - return m_textEdit.isEnabled(); + return m_textEdit.isEnabled(); } /** - * If set to true, the plain text edit scrolls the document vertically to make the cursor - * visible at the center of the viewport. This also allows the text edit to scroll below - * the end of the document. Otherwise, if set to false, the plain text edit scrolls the - * smallest amount possible to ensure the cursor is visible. + * If set to true, the plain text edit scrolls the document vertically to make + * the cursor visible at the center of the viewport. This also allows the text + * edit to scroll below the end of the document. Otherwise, if set to false, the + * plain text edit scrolls the smallest amount possible to ensure the cursor is + * visible. */ bool Widgets::Terminal::centerOnScroll() const { - return m_textEdit.centerOnScroll(); + return m_textEdit.centerOnScroll(); } /** - * Returns true if the control shall parse basic VT-100 escape secuences. This can be - * useful if you need to interface with a shell/CLI from Serial Studio. + * Returns true if the control shall parse basic VT-100 escape secuences. This + * can be useful if you need to interface with a shell/CLI from Serial Studio. */ bool Widgets::Terminal::vt100emulation() const { - return m_emulateVt100; + return m_emulateVt100; } /** * This property holds whether undo and redo are enabled. - * Users are only able to undo or redo actions if this property is true, and if there is - * an action that can be undone (or redone). + * Users are only able to undo or redo actions if this property is true, and if + * there is an action that can be undone (or redone). */ bool Widgets::Terminal::undoRedoEnabled() const { - return m_textEdit.isUndoRedoEnabled(); + return m_textEdit.isUndoRedoEnabled(); } /** * This property holds the limit for blocks in the document. * - * Specifies the maximum number of blocks the document may have. If there are more blocks - * in the document that specified with this property blocks are removed from the beginning - * of the document. + * Specifies the maximum number of blocks the document may have. If there are + * more blocks in the document that specified with this property blocks are + * removed from the beginning of the document. * - * A negative or zero value specifies that the document may contain an unlimited amount - * of blocks. + * A negative or zero value specifies that the document may contain an unlimited + * amount of blocks. */ int Widgets::Terminal::maximumBlockCount() const { - return m_textEdit.maximumBlockCount(); + return m_textEdit.maximumBlockCount(); } /** * This property holds the editor placeholder text. * - * Setting this property makes the editor display a grayed-out placeholder text as long as - * the document is empty. + * Setting this property makes the editor display a grayed-out placeholder text + * as long as the document is empty. */ QString Widgets::Terminal::placeholderText() const { - return m_textEdit.placeholderText(); + return m_textEdit.placeholderText(); } /** @@ -222,7 +225,7 @@ QString Widgets::Terminal::placeholderText() const */ QTextDocument *Widgets::Terminal::document() const { - return m_textEdit.document(); + return m_textEdit.document(); } /** @@ -230,7 +233,7 @@ QTextDocument *Widgets::Terminal::document() const */ void Widgets::Terminal::copy() { - m_textEdit.copy(); + m_textEdit.copy(); } /** @@ -238,9 +241,9 @@ void Widgets::Terminal::copy() */ void Widgets::Terminal::clear() { - m_textEdit.clear(); - updateScrollbarVisibility(); - requestRepaint(true); + m_textEdit.clear(); + updateScrollbarVisibility(); + requestRepaint(true); } /** @@ -248,8 +251,8 @@ void Widgets::Terminal::clear() */ void Widgets::Terminal::selectAll() { - m_textEdit.selectAll(); - requestRepaint(); + m_textEdit.selectAll(); + requestRepaint(); } /** @@ -257,25 +260,25 @@ void Widgets::Terminal::selectAll() */ void Widgets::Terminal::clearSelection() { - auto cursor = QTextCursor(m_textEdit.document()); - cursor.clearSelection(); - m_textEdit.setTextCursor(cursor); - updateScrollbarVisibility(); - requestRepaint(); + auto cursor = QTextCursor(m_textEdit.document()); + cursor.clearSelection(); + m_textEdit.setTextCursor(cursor); + updateScrollbarVisibility(); + requestRepaint(); } /** * Changes the read-only state of the text edit. * - * In a read-only text edit the user can only navigate through the text and select text; - * modifying the text is not possible. + * In a read-only text edit the user can only navigate through the text and + * select text; modifying the text is not possible. */ void Widgets::Terminal::setReadOnly(const bool ro) { - m_textEdit.setReadOnly(ro); - requestRepaint(); + m_textEdit.setReadOnly(ro); + requestRepaint(); - Q_EMIT readOnlyChanged(); + Q_EMIT readOnlyChanged(); } /** @@ -283,45 +286,45 @@ void Widgets::Terminal::setReadOnly(const bool ro) */ void Widgets::Terminal::setFont(const QFont &font) { - m_textEdit.setFont(font); - updateScrollbarVisibility(); - requestRepaint(); + m_textEdit.setFont(font); + updateScrollbarVisibility(); + requestRepaint(); - Q_EMIT fontChanged(); + Q_EMIT fontChanged(); } /** * Appends a new paragraph with text to the end of the text edit. * - * If @c autoscroll() is enabled, this function shall also update the scrollbar position - * to scroll to the bottom of the text. + * If @c autoscroll() is enabled, this function shall also update the scrollbar + * position to scroll to the bottom of the text. */ void Widgets::Terminal::append(const QString &text) { - m_textEdit.appendPlainText(text); - updateScrollbarVisibility(); + m_textEdit.appendPlainText(text); + updateScrollbarVisibility(); - if (autoscroll()) - scrollToBottom(); + if (autoscroll()) + scrollToBottom(); - requestRepaint(true); + requestRepaint(true); } /** * Replaces the text of the text editor with @c text. * - * If @c autoscroll() is enabled, this function shall also update the scrollbar position - * to scroll to the bottom of the text. + * If @c autoscroll() is enabled, this function shall also update the scrollbar + * position to scroll to the bottom of the text. */ void Widgets::Terminal::setText(const QString &text) { - m_textEdit.setPlainText(text); - updateScrollbarVisibility(); + m_textEdit.setPlainText(text); + updateScrollbarVisibility(); - if (autoscroll()) - scrollToBottom(); + if (autoscroll()) + scrollToBottom(); - requestRepaint(true); + requestRepaint(true); } /** @@ -329,11 +332,11 @@ void Widgets::Terminal::setText(const QString &text) */ void Widgets::Terminal::setScrollbarWidth(const int width) { - auto bar = m_textEdit.verticalScrollBar(); - bar->setFixedWidth(width); - requestRepaint(); + auto bar = m_textEdit.verticalScrollBar(); + bar->setFixedWidth(width); + requestRepaint(); - Q_EMIT scrollbarWidthChanged(); + Q_EMIT scrollbarWidthChanged(); } /** @@ -341,10 +344,10 @@ void Widgets::Terminal::setScrollbarWidth(const int width) */ void Widgets::Terminal::setPalette(const QPalette &palette) { - m_textEdit.setPalette(palette); - requestRepaint(); + m_textEdit.setPalette(palette); + requestRepaint(); - Q_EMIT colorPaletteChanged(); + Q_EMIT colorPaletteChanged(); } /** @@ -352,33 +355,33 @@ void Widgets::Terminal::setPalette(const QPalette &palette) */ void Widgets::Terminal::setWidgetEnabled(const bool enabled) { - m_textEdit.setEnabled(enabled); - requestRepaint(); + m_textEdit.setEnabled(enabled); + requestRepaint(); - Q_EMIT widgetEnabledChanged(); + Q_EMIT widgetEnabledChanged(); } /** - * Enables/disable automatic scrolling. If automatic scrolling is enabled, then the - * vertical scrollbar shall automatically scroll to the end of the document when the - * text of the text editor is changed. + * Enables/disable automatic scrolling. If automatic scrolling is enabled, then + * the vertical scrollbar shall automatically scroll to the end of the document + * when the text of the text editor is changed. */ void Widgets::Terminal::setAutoscroll(const bool enabled) { - // Change internal variables - m_autoscroll = enabled; - updateScrollbarVisibility(); + // Change internal variables + m_autoscroll = enabled; + updateScrollbarVisibility(); - // Scroll to bottom if autoscroll is enabled - if (enabled) - scrollToBottom(true); + // Scroll to bottom if autoscroll is enabled + if (enabled) + scrollToBottom(true); - // Update console configuration - IO::Console::instance().setAutoscroll(enabled); + // Update console configuration + IO::Console::instance().setAutoscroll(enabled); - // Update UI - requestRepaint(); - Q_EMIT autoscrollChanged(); + // Update UI + requestRepaint(); + Q_EMIT autoscrollChanged(); } /** @@ -386,47 +389,49 @@ void Widgets::Terminal::setAutoscroll(const bool enabled) */ void Widgets::Terminal::insertText(const QString &text) { - if (widgetEnabled()) - addText(text, vt100emulation()); + if (widgetEnabled()) + addText(text, vt100emulation()); } /** * Changes the word wrap mode of the text editor. * - * This property holds the mode QPlainTextEdit will use when wrapping text by words. + * This property holds the mode QPlainTextEdit will use when wrapping text by + * words. */ void Widgets::Terminal::setWordWrapMode(const int mode) { - m_textEdit.setWordWrapMode(static_cast(mode)); - updateScrollbarVisibility(); - requestRepaint(); + m_textEdit.setWordWrapMode(static_cast(mode)); + updateScrollbarVisibility(); + requestRepaint(); - Q_EMIT wordWrapModeChanged(); + Q_EMIT wordWrapModeChanged(); } /** - * If set to true, the plain text edit scrolls the document vertically to make the cursor - * visible at the center of the viewport. This also allows the text edit to scroll below - * the end of the document. Otherwise, if set to false, the plain text edit scrolls the - * smallest amount possible to ensure the cursor is visible. + * If set to true, the plain text edit scrolls the document vertically to make + * the cursor visible at the center of the viewport. This also allows the text + * edit to scroll below the end of the document. Otherwise, if set to false, the + * plain text edit scrolls the smallest amount possible to ensure the cursor is + * visible. */ void Widgets::Terminal::setCenterOnScroll(const bool enabled) { - m_textEdit.setCenterOnScroll(enabled); - requestRepaint(); + m_textEdit.setCenterOnScroll(enabled); + requestRepaint(); - Q_EMIT centerOnScrollChanged(); + Q_EMIT centerOnScrollChanged(); } /** - * Enables/disables interpretation of VT-100 escape secuences. This can be useful when - * interfacing through network ports or interfacing with a MCU that implements some - * kind of shell. + * Enables/disables interpretation of VT-100 escape secuences. This can be + * useful when interfacing through network ports or interfacing with a MCU that + * implements some kind of shell. */ void Widgets::Terminal::setVt100Emulation(const bool enabled) { - m_emulateVt100 = enabled; - Q_EMIT vt100EmulationChanged(); + m_emulateVt100 = enabled; + Q_EMIT vt100EmulationChanged(); } /** @@ -434,22 +439,22 @@ void Widgets::Terminal::setVt100Emulation(const bool enabled) */ void Widgets::Terminal::setUndoRedoEnabled(const bool enabled) { - m_textEdit.setUndoRedoEnabled(enabled); - requestRepaint(); + m_textEdit.setUndoRedoEnabled(enabled); + requestRepaint(); - Q_EMIT undoRedoEnabledChanged(); + Q_EMIT undoRedoEnabledChanged(); } /** - * Changes the placeholder text of the text editor. The placeholder text is only displayed - * when the document is empty. + * Changes the placeholder text of the text editor. The placeholder text is only + * displayed when the document is empty. */ void Widgets::Terminal::setPlaceholderText(const QString &text) { - m_textEdit.setPlaceholderText(text); - requestRepaint(); + m_textEdit.setPlaceholderText(text); + requestRepaint(); - Q_EMIT placeholderTextChanged(); + Q_EMIT placeholderTextChanged(); } /** @@ -457,60 +462,60 @@ void Widgets::Terminal::setPlaceholderText(const QString &text) */ void Widgets::Terminal::scrollToBottom(const bool repaint) { - // Get scrollbar pointer, calculate line count & visible text lines - auto *bar = m_textEdit.verticalScrollBar(); - auto lineCount = m_textEdit.document()->blockCount(); - auto visibleLines = qRound(height() / m_textEdit.fontMetrics().height()); + // Get scrollbar pointer, calculate line count & visible text lines + auto *bar = m_textEdit.verticalScrollBar(); + auto lineCount = m_textEdit.document()->blockCount(); + auto visibleLines = qRound(height() / m_textEdit.fontMetrics().height()); - // Abort operation if control is not visible - if (visibleLines <= 0) - return; + // Abort operation if control is not visible + if (visibleLines <= 0) + return; - // Update scrolling range - bar->setMinimum(0); - bar->setMaximum(lineCount); + // Update scrolling range + bar->setMinimum(0); + bar->setMaximum(lineCount); - // Do not scroll to bottom if all text fits in current window - if (lineCount > visibleLines) - bar->setValue(lineCount - visibleLines + 2); - else - bar->setValue(0); + // Do not scroll to bottom if all text fits in current window + if (lineCount > visibleLines) + bar->setValue(lineCount - visibleLines + 2); + else + bar->setValue(0); - // Trigger UI repaint - if (repaint) - requestRepaint(); + // Trigger UI repaint + if (repaint) + requestRepaint(); } /** - * Specifies the maximum number of blocks the document may have. If there are more blocks - * in the document that specified with this property blocks are removed from the beginning - * of the document. + * Specifies the maximum number of blocks the document may have. If there are + * more blocks in the document that specified with this property blocks are + * removed from the beginning of the document. * - * A negative or zero value specifies that the document may contain an unlimited amount of - * blocks. + * A negative or zero value specifies that the document may contain an unlimited + * amount of blocks. */ void Widgets::Terminal::setMaximumBlockCount(const int maxBlockCount) { - m_textEdit.setMaximumBlockCount(maxBlockCount); - requestRepaint(); + m_textEdit.setMaximumBlockCount(maxBlockCount); + requestRepaint(); - Q_EMIT maximumBlockCountChanged(); + Q_EMIT maximumBlockCountChanged(); } /** - * Redraws the widget. This function is called by a timer to reduce the number of paint - * requests (and thus avoid considerable slow-downs). + * Redraws the widget. This function is called by a timer to reduce the number + * of paint requests (and thus avoid considerable slow-downs). */ void Widgets::Terminal::repaint() { - if (m_repaint) - { - m_repaint = false; - update(); + if (m_repaint) + { + m_repaint = false; + update(); - if (m_textChanged) - Q_EMIT textChanged(); - } + if (m_textChanged) + Q_EMIT textChanged(); + } } /** @@ -518,27 +523,27 @@ void Widgets::Terminal::repaint() */ void Widgets::Terminal::updateScrollbarVisibility() { - // Get current line count & visible lines - auto lineCount = m_textEdit.document()->blockCount(); - auto visibleLines = qCeil(height() / m_textEdit.fontMetrics().height()); + // Get current line count & visible lines + auto lineCount = m_textEdit.document()->blockCount(); + auto visibleLines = qCeil(height() / m_textEdit.fontMetrics().height()); - // Autoscroll enabled or text content is less than widget height - if (autoscroll() || visibleLines >= lineCount) - m_textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // Autoscroll enabled or text content is less than widget height + if (autoscroll() || visibleLines >= lineCount) + m_textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // Show the scrollbar if the text content is greater than the widget height - else - m_textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + // Show the scrollbar if the text content is greater than the widget height + else + m_textEdit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } /** - * Updates the value of copy-available. This function is automatically called by the text - * editor widget when the user makes any text selection/deselection. + * Updates the value of copy-available. This function is automatically called by + * the text editor widget when the user makes any text selection/deselection. */ void Widgets::Terminal::setCopyAvailable(const bool yes) { - m_copyAvailable = yes; - Q_EMIT copyAvailableChanged(); + m_copyAvailable = yes; + Q_EMIT copyAvailableChanged(); } /** @@ -546,56 +551,57 @@ void Widgets::Terminal::setCopyAvailable(const bool yes) */ void Widgets::Terminal::addText(const QString &text, const bool enableVt100) { - // Get text to insert - QString textToInsert = text; - if (enableVt100) - textToInsert = vt100Processing(text); + // Get text to insert + QString textToInsert = text; + if (enableVt100) + textToInsert = vt100Processing(text); - // Clear terminal scrollback after 10000 lines - if (m_textEdit.blockCount() >= 10000) - m_textEdit.clear(); + // Clear terminal scrollback after 10000 lines + if (m_textEdit.blockCount() >= 10000) + m_textEdit.clear(); - // Add text at the end of the text document - QTextCursor cursor(m_textEdit.document()); - cursor.beginEditBlock(); - cursor.movePosition(QTextCursor::End); - cursor.insertText(textToInsert); - cursor.endEditBlock(); + // Add text at the end of the text document + QTextCursor cursor(m_textEdit.document()); + cursor.beginEditBlock(); + cursor.movePosition(QTextCursor::End); + cursor.insertText(textToInsert); + cursor.endEditBlock(); - // Autoscroll to bottom (if needed) - updateScrollbarVisibility(); - if (autoscroll()) - scrollToBottom(); + // Autoscroll to bottom (if needed) + updateScrollbarVisibility(); + if (autoscroll()) + scrollToBottom(); - // Repaint the widget - requestRepaint(true); + // Repaint the widget + requestRepaint(true); } /** - * Enables the re-paint flag, which is later used by the @c repaint() function to know - * if the widget shall be repainted. + * Enables the re-paint flag, which is later used by the @c repaint() function + * to know if the widget shall be repainted. */ void Widgets::Terminal::requestRepaint(const bool textChanged) { - m_repaint = true; - m_textChanged = textChanged; + m_repaint = true; + m_textChanged = textChanged; } /** - * Processes the given @a data to remove the escape sequences from the text using code - * from Qt Creator output terminal. Check the next code block for more info. + * Processes the given @a data to remove the escape sequences from the text + * using code from Qt Creator output terminal. Check the next code block for + * more info. */ QString Widgets::Terminal::vt100Processing(const QString &data) { - auto formattedText = m_escapeCodeHandler.parseText(FormattedText(data)); - const QString cleanLine = std::accumulate( - formattedText.begin(), formattedText.end(), QString(), - [](const FormattedText &t1, const FormattedText &t2) -> QString { - return t1.text + t2.text; - }); - m_escapeCodeHandler.endFormatScope(); + auto formattedText = m_escapeCodeHandler.parseText(FormattedText(data)); + const QString cleanLine = std::accumulate( + formattedText.begin(), formattedText.end(), QString(), + [](const FormattedText &t1, const FormattedText &t2) -> QString { + return t1.text + t2.text; + }); + m_escapeCodeHandler.endFormatScope(); - return cleanLine; + return cleanLine; } //-------------------------------------------------------------------------------------------------- @@ -603,347 +609,345 @@ QString Widgets::Terminal::vt100Processing(const QString &data) // https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/ansiescapecodehandler.cpp //---------------------------------------------------------º---------------------------------------- -#define QTC_ASSERT(cond, action) \ - if (Q_LIKELY(cond)) \ - { \ - } \ - else \ - { \ - action; \ - } \ - do \ - { \ - } while (0) +#define QTC_ASSERT(cond, action) \ + if (Q_LIKELY(cond)) \ + { \ + } \ + else \ + { \ + action; \ + } \ + do \ + { \ + } while (0) static QColor ansiColor(uint code) { - QTC_ASSERT(code < 8, return QColor()); + QTC_ASSERT(code < 8, return QColor()); - const int red = code & 1 ? 170 : 0; - const int green = code & 2 ? 170 : 0; - const int blue = code & 4 ? 170 : 0; - return QColor(red, green, blue); + const int red = code & 1 ? 170 : 0; + const int green = code & 2 ? 170 : 0; + const int blue = code & 4 ? 170 : 0; + return QColor(red, green, blue); } QVector Widgets::AnsiEscapeCodeHandler::parseText(const FormattedText &input) { - enum AnsiEscapeCodes + enum AnsiEscapeCodes + { + ResetFormat = 0, + BoldText = 1, + TextColorStart = 30, + TextColorEnd = 37, + RgbTextColor = 38, + DefaultTextColor = 39, + BackgroundColorStart = 40, + BackgroundColorEnd = 47, + RgbBackgroundColor = 48, + DefaultBackgroundColor = 49 + }; + + const QString escape = "\x1b["; + const QChar semicolon = ';'; + const QChar colorTerminator = 'm'; + const QChar eraseToEol = 'K'; + + QVector outputData; + QTextCharFormat charFormat + = m_previousFormatClosed ? input.format : m_previousFormat; + QString strippedText; + if (m_pendingText.isEmpty()) + strippedText = input.text; + + else + { + strippedText = m_pendingText.append(input.text); + m_pendingText.clear(); + } + + while (!strippedText.isEmpty()) + { + QTC_ASSERT(m_pendingText.isEmpty(), break); + if (m_waitingForTerminator) { - ResetFormat = 0, - BoldText = 1, - TextColorStart = 30, - TextColorEnd = 37, - RgbTextColor = 38, - DefaultTextColor = 39, - BackgroundColorStart = 40, - BackgroundColorEnd = 47, - RgbBackgroundColor = 48, - DefaultBackgroundColor = 49 - }; - - const QString escape = "\x1b["; - const QChar semicolon = ';'; - const QChar colorTerminator = 'm'; - const QChar eraseToEol = 'K'; - - QVector outputData; - QTextCharFormat charFormat = m_previousFormatClosed ? input.format : m_previousFormat; - QString strippedText; - if (m_pendingText.isEmpty()) - strippedText = input.text; - - else - { - strippedText = m_pendingText.append(input.text); - m_pendingText.clear(); + // We ignore all escape codes taking string arguments. + QString terminator = "\x1b\\"; + int terminatorPos = strippedText.indexOf(terminator); + if (terminatorPos == -1 && !m_alternateTerminator.isEmpty()) + { + terminator = m_alternateTerminator; + terminatorPos = strippedText.indexOf(terminator); + } + if (terminatorPos == -1) + { + m_pendingText = strippedText; + break; + } + m_waitingForTerminator = false; + m_alternateTerminator.clear(); + strippedText.remove(0, terminatorPos + terminator.length()); + if (strippedText.isEmpty()) + break; } - - while (!strippedText.isEmpty()) + const int escapePos = strippedText.indexOf(escape.at(0)); + if (escapePos < 0) { - QTC_ASSERT(m_pendingText.isEmpty(), break); - if (m_waitingForTerminator) + outputData << FormattedText(strippedText, charFormat); + break; + } + else if (escapePos != 0) + { + outputData << FormattedText(strippedText.left(escapePos), charFormat); + strippedText.remove(0, escapePos); + } + QTC_ASSERT(strippedText.at(0) == escape.at(0), break); + + while (!strippedText.isEmpty() && escape.at(0) == strippedText.at(0)) + { + if (escape.startsWith(strippedText)) + { + // control secquence is not complete + m_pendingText += strippedText; + strippedText.clear(); + break; + } + if (!strippedText.startsWith(escape)) + { + switch (strippedText.at(1).toLatin1()) { - // We ignore all escape codes taking string arguments. - QString terminator = "\x1b\\"; - int terminatorPos = strippedText.indexOf(terminator); - if (terminatorPos == -1 && !m_alternateTerminator.isEmpty()) - { - terminator = m_alternateTerminator; - terminatorPos = strippedText.indexOf(terminator); - } - if (terminatorPos == -1) - { - m_pendingText = strippedText; - break; - } - m_waitingForTerminator = false; - m_alternateTerminator.clear(); - strippedText.remove(0, terminatorPos + terminator.length()); - if (strippedText.isEmpty()) - break; - } - const int escapePos = strippedText.indexOf(escape.at(0)); - if (escapePos < 0) - { - outputData << FormattedText(strippedText, charFormat); + case '\\': // Unexpected terminator sequence. + Q_FALLTHROUGH(); + case 'N': + case 'O': // Ignore unsupported single-character sequences. + strippedText.remove(0, 2); break; - } - else if (escapePos != 0) - { - outputData << FormattedText(strippedText.left(escapePos), charFormat); - strippedText.remove(0, escapePos); - } - QTC_ASSERT(strippedText.at(0) == escape.at(0), break); - - while (!strippedText.isEmpty() && escape.at(0) == strippedText.at(0)) - { - if (escape.startsWith(strippedText)) - { - // control secquence is not complete - m_pendingText += strippedText; - strippedText.clear(); - break; - } - if (!strippedText.startsWith(escape)) - { - switch (strippedText.at(1).toLatin1()) - { - case '\\': // Unexpected terminator sequence. - Q_FALLTHROUGH(); - case 'N': - case 'O': // Ignore unsupported single-character sequences. - strippedText.remove(0, 2); - break; - case ']': - m_alternateTerminator = QChar(7); - Q_FALLTHROUGH(); - case 'P': - case 'X': - case '^': - case '_': - strippedText.remove(0, 2); - m_waitingForTerminator = true; - break; - default: - // not a control sequence - m_pendingText.clear(); - outputData << FormattedText(strippedText.left(1), charFormat); - strippedText.remove(0, 1); - continue; - } - break; - } - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - m_pendingText += strippedText.midRef(0, escape.length()); -#else - m_pendingText - += QStringView { strippedText }.mid(0, escape.length()).toString(); -#endif - - strippedText.remove(0, escape.length()); - - // Get stripped text in uppercase - auto upperCase = strippedText.toUpper(); - - // Clear line - if (upperCase.contains("2K")) - { - textEdit->setFocus(); - auto storedCursor = textEdit->textCursor(); - textEdit->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); - textEdit->moveCursor(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); - textEdit->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); - textEdit->textCursor().removeSelectedText(); - textEdit->textCursor().deletePreviousChar(); - textEdit->setTextCursor(storedCursor); - return outputData; - } - - // Clear screen - if (upperCase.contains("2J")) - { - textEdit->clear(); - return QVector(); - } - - // \e[K is not supported. Just strip it. - if (strippedText.startsWith(eraseToEol)) - { - m_pendingText.clear(); - strippedText.remove(0, 1); - continue; - } - // get the number - QString strNumber; - StringList numbers; - while (!strippedText.isEmpty()) - { - if (strippedText.at(0).isDigit()) - { - strNumber += strippedText.at(0); - } - else - { - if (!strNumber.isEmpty()) - numbers << strNumber; - if (strNumber.isEmpty() || strippedText.at(0) != semicolon) - break; - strNumber.clear(); - } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - m_pendingText += strippedText.midRef(0, 1); -#else - m_pendingText += QStringView { strippedText }.mid(0, 1).toString(); -#endif - strippedText.remove(0, 1); - } - if (strippedText.isEmpty()) - break; - - // remove terminating char - if (!strippedText.startsWith(colorTerminator)) - { - m_pendingText.clear(); - strippedText.remove(0, 1); - break; - } - // got consistent control sequence, ok to clear pending text + case ']': + m_alternateTerminator = QChar(7); + Q_FALLTHROUGH(); + case 'P': + case 'X': + case '^': + case '_': + strippedText.remove(0, 2); + m_waitingForTerminator = true; + break; + default: + // not a control sequence m_pendingText.clear(); + outputData << FormattedText(strippedText.left(1), charFormat); strippedText.remove(0, 1); - - if (numbers.isEmpty()) - { - charFormat = input.format; - endFormatScope(); - } - - for (int i = 0; i < numbers.size(); ++i) - { - const uint code = numbers.at(i).toUInt(); - - if (code >= TextColorStart && code <= TextColorEnd) - { - charFormat.setForeground(ansiColor(code - TextColorStart)); - setFormatScope(charFormat); - } - else if (code >= BackgroundColorStart && code <= BackgroundColorEnd) - { - charFormat.setBackground(ansiColor(code - BackgroundColorStart)); - setFormatScope(charFormat); - } - else - { - switch (code) - { - case ResetFormat: - charFormat = input.format; - endFormatScope(); - break; - case BoldText: - charFormat.setFontWeight(QFont::Bold); - setFormatScope(charFormat); - break; - case DefaultTextColor: - charFormat.setForeground(input.format.foreground()); - setFormatScope(charFormat); - break; - case DefaultBackgroundColor: - charFormat.setBackground(input.format.background()); - setFormatScope(charFormat); - break; - case RgbTextColor: - case RgbBackgroundColor: - // See http://en.wikipedia.org/wiki/ANSI_escape_code#Colors - if (++i >= numbers.size()) - break; - switch (numbers.at(i).toInt()) - { - case 2: - // RGB set with format: 38;2;;; - if ((i + 3) < numbers.size()) - { - (code == RgbTextColor) - ? charFormat.setForeground( - QColor(numbers.at(i + 1).toInt(), - numbers.at(i + 2).toInt(), - numbers.at(i + 3).toInt())) - : charFormat.setBackground( - QColor(numbers.at(i + 1).toInt(), - numbers.at(i + 2).toInt(), - numbers.at(i + 3).toInt())); - setFormatScope(charFormat); - } - i += 3; - break; - case 5: - // 256 color mode with format: 38;5; - uint index = numbers.at(i + 1).toUInt(); - - QColor color; - if (index < 8) - { - // The first 8 colors are standard low-intensity - // ANSI colors. - color = ansiColor(index); - } - else if (index < 16) - { - // The next 8 colors are standard high-intensity - // ANSI colors. - color = ansiColor(index - 8).lighter(150); - } - else if (index < 232) - { - // The next 216 colors are a 6x6x6 RGB cube. - uint o = index - 16; - color = QColor((o / 36) * 51, ((o / 6) % 6) * 51, - (o % 6) * 51); - } - else - { - // The last 24 colors are a greyscale gradient. - int grey = int((index - 232) * 11); - color = QColor(grey, grey, grey); - } - - if (code == RgbTextColor) - charFormat.setForeground(color); - else - charFormat.setBackground(color); - - setFormatScope(charFormat); - ++i; - break; - } - break; - default: - break; - } - } - } + continue; } + break; + } + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + m_pendingText += strippedText.midRef(0, escape.length()); +#else + m_pendingText + += QStringView{strippedText}.mid(0, escape.length()).toString(); +#endif + + strippedText.remove(0, escape.length()); + + // Get stripped text in uppercase + auto upperCase = strippedText.toUpper(); + + // Clear line + if (upperCase.contains("2K")) + { + textEdit->setFocus(); + auto storedCursor = textEdit->textCursor(); + textEdit->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); + textEdit->moveCursor(QTextCursor::StartOfLine, QTextCursor::MoveAnchor); + textEdit->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); + textEdit->textCursor().removeSelectedText(); + textEdit->textCursor().deletePreviousChar(); + textEdit->setTextCursor(storedCursor); + return outputData; + } + + // Clear screen + if (upperCase.contains("2J")) + { + textEdit->clear(); + return QVector(); + } + + // \e[K is not supported. Just strip it. + if (strippedText.startsWith(eraseToEol)) + { + m_pendingText.clear(); + strippedText.remove(0, 1); + continue; + } + // get the number + QString strNumber; + StringList numbers; + while (!strippedText.isEmpty()) + { + if (strippedText.at(0).isDigit()) + { + strNumber += strippedText.at(0); + } + else + { + if (!strNumber.isEmpty()) + numbers << strNumber; + if (strNumber.isEmpty() || strippedText.at(0) != semicolon) + break; + strNumber.clear(); + } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + m_pendingText += strippedText.midRef(0, 1); +#else + m_pendingText += QStringView{strippedText}.mid(0, 1).toString(); +#endif + strippedText.remove(0, 1); + } + if (strippedText.isEmpty()) + break; + + // remove terminating char + if (!strippedText.startsWith(colorTerminator)) + { + m_pendingText.clear(); + strippedText.remove(0, 1); + break; + } + // got consistent control sequence, ok to clear pending text + m_pendingText.clear(); + strippedText.remove(0, 1); + + if (numbers.isEmpty()) + { + charFormat = input.format; + endFormatScope(); + } + + for (int i = 0; i < numbers.size(); ++i) + { + const uint code = numbers.at(i).toUInt(); + + if (code >= TextColorStart && code <= TextColorEnd) + { + charFormat.setForeground(ansiColor(code - TextColorStart)); + setFormatScope(charFormat); + } + else if (code >= BackgroundColorStart && code <= BackgroundColorEnd) + { + charFormat.setBackground(ansiColor(code - BackgroundColorStart)); + setFormatScope(charFormat); + } + else + { + switch (code) + { + case ResetFormat: + charFormat = input.format; + endFormatScope(); + break; + case BoldText: + charFormat.setFontWeight(QFont::Bold); + setFormatScope(charFormat); + break; + case DefaultTextColor: + charFormat.setForeground(input.format.foreground()); + setFormatScope(charFormat); + break; + case DefaultBackgroundColor: + charFormat.setBackground(input.format.background()); + setFormatScope(charFormat); + break; + case RgbTextColor: + case RgbBackgroundColor: + // See http://en.wikipedia.org/wiki/ANSI_escape_code#Colors + if (++i >= numbers.size()) + break; + switch (numbers.at(i).toInt()) + { + case 2: + // RGB set with format: 38;2;;; + if ((i + 3) < numbers.size()) + { + (code == RgbTextColor) + ? charFormat.setForeground( + QColor(numbers.at(i + 1).toInt(), + numbers.at(i + 2).toInt(), + numbers.at(i + 3).toInt())) + : charFormat.setBackground( + QColor(numbers.at(i + 1).toInt(), + numbers.at(i + 2).toInt(), + numbers.at(i + 3).toInt())); + setFormatScope(charFormat); + } + i += 3; + break; + case 5: + // 256 color mode with format: 38;5; + uint index = numbers.at(i + 1).toUInt(); + + QColor color; + if (index < 8) + { + // The first 8 colors are standard low-intensity + // ANSI colors. + color = ansiColor(index); + } + else if (index < 16) + { + // The next 8 colors are standard high-intensity + // ANSI colors. + color = ansiColor(index - 8).lighter(150); + } + else if (index < 232) + { + // The next 216 colors are a 6x6x6 RGB cube. + uint o = index - 16; + color = QColor((o / 36) * 51, ((o / 6) % 6) * 51, + (o % 6) * 51); + } + else + { + // The last 24 colors are a greyscale gradient. + int grey = int((index - 232) * 11); + color = QColor(grey, grey, grey); + } + + if (code == RgbTextColor) + charFormat.setForeground(color); + else + charFormat.setBackground(color); + + setFormatScope(charFormat); + ++i; + break; + } + break; + default: + break; + } + } + } } - return outputData; + } + return outputData; } void Widgets::AnsiEscapeCodeHandler::setTextEdit(QPlainTextEdit *widget) { - textEdit = widget; + textEdit = widget; } void Widgets::AnsiEscapeCodeHandler::endFormatScope() { - m_previousFormatClosed = true; + m_previousFormatClosed = true; } -void Widgets::AnsiEscapeCodeHandler::setFormatScope(const QTextCharFormat &charFormat) +void Widgets::AnsiEscapeCodeHandler::setFormatScope( + const QTextCharFormat &charFormat) { - m_previousFormat = charFormat; - m_previousFormatClosed = false; + m_previousFormat = charFormat; + m_previousFormatClosed = false; } - -#ifdef SERIAL_STUDIO_INCLUDE_MOC -# include "moc_Terminal.cpp" -#endif diff --git a/src/UI/Widgets/Terminal.h b/src/UI/Widgets/Terminal.h index 4cfcbf7e..ddfef735 100644 --- a/src/UI/Widgets/Terminal.h +++ b/src/UI/Widgets/Terminal.h @@ -30,39 +30,40 @@ namespace Widgets class FormattedText { public: - FormattedText() = default; - FormattedText(const FormattedText &other) = default; - FormattedText(const QString &txt, const QTextCharFormat &fmt = QTextCharFormat()) - : text(txt) - , format(fmt) - { - } + FormattedText() = default; + FormattedText(const FormattedText &other) = default; + FormattedText(const QString &txt, + const QTextCharFormat &fmt = QTextCharFormat()) + : text(txt) + , format(fmt) + { + } - QString text; - QTextCharFormat format; + QString text; + QTextCharFormat format; }; class AnsiEscapeCodeHandler { public: - QVector parseText(const FormattedText &input); - void setTextEdit(QPlainTextEdit *widget); - void endFormatScope(); + QVector parseText(const FormattedText &input); + void setTextEdit(QPlainTextEdit *widget); + void endFormatScope(); private: - void setFormatScope(const QTextCharFormat &charFormat); + void setFormatScope(const QTextCharFormat &charFormat); - QString m_pendingText; - QPlainTextEdit *textEdit; - QString m_alternateTerminator; - QTextCharFormat m_previousFormat; - bool m_previousFormatClosed = true; - bool m_waitingForTerminator = false; + QString m_pendingText; + QPlainTextEdit *textEdit; + QString m_alternateTerminator; + QTextCharFormat m_previousFormat; + bool m_previousFormatClosed = true; + bool m_waitingForTerminator = false; }; class Terminal : public UI::DeclarativeWidget { - // clang-format off + // clang-format off Q_OBJECT Q_PROPERTY(QFont font READ font @@ -122,85 +123,85 @@ class Terminal : public UI::DeclarativeWidget READ vt100emulation WRITE setVt100Emulation NOTIFY vt100EmulationChanged) - // clang-format on + // clang-format on Q_SIGNALS: - void textChanged(); - void fontChanged(); - void readOnlyChanged(); - void autoscrollChanged(); - void colorPaletteChanged(); - void wordWrapModeChanged(); - void copyAvailableChanged(); - void widgetEnabledChanged(); - void scrollbarWidthChanged(); - void centerOnScrollChanged(); - void vt100EmulationChanged(); - void placeholderTextChanged(); - void undoRedoEnabledChanged(); - void maximumBlockCountChanged(); + void textChanged(); + void fontChanged(); + void readOnlyChanged(); + void autoscrollChanged(); + void colorPaletteChanged(); + void wordWrapModeChanged(); + void copyAvailableChanged(); + void widgetEnabledChanged(); + void scrollbarWidthChanged(); + void centerOnScrollChanged(); + void vt100EmulationChanged(); + void placeholderTextChanged(); + void undoRedoEnabledChanged(); + void maximumBlockCountChanged(); public: - Terminal(QQuickItem *parent = 0); + Terminal(QQuickItem *parent = 0); - QFont font() const; - QString text() const; + QFont font() const; + QString text() const; - bool empty() const; - bool readOnly() const; - bool autoscroll() const; - QPalette palette() const; - int wordWrapMode() const; - int scrollbarWidth() const; - bool copyAvailable() const; - bool widgetEnabled() const; - bool centerOnScroll() const; - bool vt100emulation() const; - bool undoRedoEnabled() const; - int maximumBlockCount() const; - QString placeholderText() const; - QTextDocument *document() const; + bool empty() const; + bool readOnly() const; + bool autoscroll() const; + QPalette palette() const; + int wordWrapMode() const; + int scrollbarWidth() const; + bool copyAvailable() const; + bool widgetEnabled() const; + bool centerOnScroll() const; + bool vt100emulation() const; + bool undoRedoEnabled() const; + int maximumBlockCount() const; + QString placeholderText() const; + QTextDocument *document() const; public Q_SLOTS: - void copy(); - void clear(); - void selectAll(); - void clearSelection(); - void setReadOnly(const bool ro); - void setFont(const QFont &font); - void append(const QString &text); - void setText(const QString &text); - void insertText(const QString &text); - void setWordWrapMode(const int mode); - void setAutoscroll(const bool enabled); - void setScrollbarWidth(const int width); - void setPalette(const QPalette &palette); - void setWidgetEnabled(const bool enabled); - void setCenterOnScroll(const bool enabled); - void setVt100Emulation(const bool enabled); - void setUndoRedoEnabled(const bool enabled); - void setPlaceholderText(const QString &text); - void scrollToBottom(const bool repaint = false); - void setMaximumBlockCount(const int maxBlockCount); + void copy(); + void clear(); + void selectAll(); + void clearSelection(); + void setReadOnly(const bool ro); + void setFont(const QFont &font); + void append(const QString &text); + void setText(const QString &text); + void insertText(const QString &text); + void setWordWrapMode(const int mode); + void setAutoscroll(const bool enabled); + void setScrollbarWidth(const int width); + void setPalette(const QPalette &palette); + void setWidgetEnabled(const bool enabled); + void setCenterOnScroll(const bool enabled); + void setVt100Emulation(const bool enabled); + void setUndoRedoEnabled(const bool enabled); + void setPlaceholderText(const QString &text); + void scrollToBottom(const bool repaint = false); + void setMaximumBlockCount(const int maxBlockCount); private Q_SLOTS: - void repaint(); - void updateScrollbarVisibility(); - void setCopyAvailable(const bool yes); - void addText(const QString &text, const bool enableVt100); + void repaint(); + void updateScrollbarVisibility(); + void setCopyAvailable(const bool yes); + void addText(const QString &text, const bool enableVt100); private: - QString vt100Processing(const QString &data); - void requestRepaint(const bool textChanged = false); + QString vt100Processing(const QString &data); + void requestRepaint(const bool textChanged = false); private: - bool m_repaint; - bool m_autoscroll; - bool m_textChanged; - bool m_emulateVt100; - bool m_copyAvailable; + bool m_repaint; + bool m_autoscroll; + bool m_textChanged; + bool m_emulateVt100; + bool m_copyAvailable; - QPlainTextEdit m_textEdit; - AnsiEscapeCodeHandler m_escapeCodeHandler; + QPlainTextEdit m_textEdit; + AnsiEscapeCodeHandler m_escapeCodeHandler; }; -} +} // namespace Widgets diff --git a/src/main.cpp b/src/main.cpp index a67f567e..6e3a41c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,7 +32,7 @@ #include #ifdef Q_OS_WIN -# include +# include #endif /** @@ -40,11 +40,8 @@ */ static void cliShowVersion() { - auto appver = QString("%1 version %2").arg(APP_NAME, APP_VERSION); - auto author = QString("Written by Alex Spataru "); - - qDebug() << appver.toStdString().c_str(); - qDebug() << author.toStdString().c_str(); + qDebug() << APP_NAME << "version" << APP_VERSION; + qDebug() << "Written by Alex Spataru "; } /** @@ -52,8 +49,8 @@ static void cliShowVersion() */ static void cliResetSettings() { - QSettings(APP_DEVELOPER, APP_NAME).clear(); - qDebug() << APP_NAME << "settings cleared!"; + QSettings(APP_DEVELOPER, APP_NAME).clear(); + qDebug() << APP_NAME << "settings cleared!"; } /** @@ -66,74 +63,75 @@ static void cliResetSettings() */ int main(int argc, char **argv) { - // Fix console output on Windows (https://stackoverflow.com/a/41701133) - // This code will only execute if the application is started from the comamnd prompt + // Fix console output on Windows (https://stackoverflow.com/a/41701133) + // This code will only execute if the application is started from the comamnd + // prompt #ifdef _WIN32 - if (AttachConsole(ATTACH_PARENT_PROCESS)) - { - // Open the console's active buffer - (void)freopen("CONOUT$", "w", stdout); - (void)freopen("CONOUT$", "w", stderr); + if (AttachConsole(ATTACH_PARENT_PROCESS)) + { + // Open the console's active buffer + (void)freopen("CONOUT$", "w", stdout); + (void)freopen("CONOUT$", "w", stderr); - // Force print new-line (to avoid printing text over user commands) - printf("\n"); - } + // Force print new-line (to avoid printing text over user commands) + printf("\n"); + } #endif - // Set application attributes + // Set application attributes #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - // Avoid 200% scaling on 150% scaling... - auto policy = Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; - QApplication::setHighDpiScaleFactorRoundingPolicy(policy); + // Avoid 200% scaling on 150% scaling... + auto policy = Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; + QApplication::setHighDpiScaleFactorRoundingPolicy(policy); - // Init. application - QApplication app(argc, argv); - app.setApplicationName(APP_NAME); - app.setApplicationVersion(APP_VERSION); - app.setOrganizationName(APP_DEVELOPER); - app.setOrganizationDomain(APP_SUPPORT_URL); + // Init. application + QApplication app(argc, argv); + app.setApplicationName(APP_NAME); + app.setApplicationVersion(APP_VERSION); + app.setOrganizationName(APP_DEVELOPER); + app.setOrganizationDomain(APP_SUPPORT_URL); - // Set application style - app.setStyle(QStyleFactory::create("Fusion")); - QQuickStyle::setStyle("Fusion"); + // Set application style + app.setStyle(QStyleFactory::create("Fusion")); + QQuickStyle::setStyle("Fusion"); - // Read arguments - QString arguments; - if (app.arguments().count() >= 2) - arguments = app.arguments().at(1); + // Read arguments + QString arguments; + if (app.arguments().count() >= 2) + arguments = app.arguments().at(1); - // There are some CLI arguments, read them - if (!arguments.isEmpty() && arguments.startsWith("-")) + // There are some CLI arguments, read them + if (!arguments.isEmpty() && arguments.startsWith("-")) + { + if (arguments == "-v" || arguments == "--version") { - if (arguments == "-v" || arguments == "--version") - { - cliShowVersion(); - return EXIT_SUCCESS; - } - - else if (arguments == "-r" || arguments == "--reset") - { - cliResetSettings(); - return EXIT_SUCCESS; - } + cliShowVersion(); + return EXIT_SUCCESS; } - // Create module manager - Misc::ModuleManager moduleManager; - moduleManager.configureUpdater(); - - // Initialize QML interface - moduleManager.registerQmlTypes(); - moduleManager.initializeQmlInterface(); - if (moduleManager.engine()->rootObjects().isEmpty()) + else if (arguments == "-r" || arguments == "--reset") { - qCritical() << "Critical QML error"; - return EXIT_FAILURE; + cliResetSettings(); + return EXIT_SUCCESS; } + } - // Enter application event loop - return app.exec(); + // Create module manager + Misc::ModuleManager moduleManager; + moduleManager.configureUpdater(); + + // Initialize QML interface + moduleManager.registerQmlTypes(); + moduleManager.initializeQmlInterface(); + if (moduleManager.engine()->rootObjects().isEmpty()) + { + qCritical() << "Critical QML error"; + return EXIT_FAILURE; + } + + // Enter application event loop + return app.exec(); }