├── .codecov.yml ├── .github └── workflows │ ├── build.yml │ ├── build_freebsd.yml │ └── build_shared.yml ├── .gitignore ├── AUTHORS ├── COPYING ├── COPYING.LESSER ├── ChangeLog ├── Makefile.am ├── NEWS ├── README ├── acinclude.m4 ├── appveyor.yml ├── autogen.ps1 ├── autogen.sh ├── build.ps1 ├── common ├── Makefile.am ├── byte_stream.h ├── common.h ├── config_borlandc.h ├── config_msc.h ├── config_winapi.h ├── file_stream.h ├── memory.h ├── narrow_string.h ├── system_string.h ├── types.h.in └── wide_string.h ├── configure.ac ├── documentation └── OLE definitions.asciidoc ├── dpkg ├── changelog.in ├── compat ├── control ├── copyright ├── libfole-dev.install ├── libfole.install ├── rules └── source │ └── format ├── include ├── Makefile.am ├── libfole.h.in └── libfole │ ├── definitions.h.in │ ├── error.h │ ├── extern.h │ ├── features.h.in │ └── types.h.in ├── libfole.ini ├── libfole.pc.in ├── libfole.spec.in ├── libfole ├── Makefile.am ├── libfole.c ├── libfole.rc.in ├── libfole_definitions.h.in ├── libfole_error.c ├── libfole_error.h ├── libfole_extern.h ├── libfole_libcerror.h ├── libfole_support.c ├── libfole_support.h ├── libfole_types.h ├── libfole_unused.h ├── libfole_value_type.c └── libfole_value_type.h ├── m4 ├── common.m4 ├── libcerror.m4 ├── tests.m4 └── types.m4 ├── manuals ├── Makefile.am └── libfole.3 ├── msvscpp ├── Makefile.am ├── fole_test_error │ └── fole_test_error.vcproj ├── fole_test_support │ └── fole_test_support.vcproj ├── fole_test_value_type │ └── fole_test_value_type.vcproj ├── libcerror │ └── libcerror.vcproj ├── libfole.sln └── libfole │ └── libfole.vcproj ├── po ├── ChangeLog ├── Makevars.in └── POTFILES.in ├── runtests.ps1 ├── runtests.sh ├── synclibs.ps1 ├── synclibs.sh └── tests ├── Makefile.am ├── build.sh ├── fole_test_error.c ├── fole_test_libcerror.h ├── fole_test_libfole.h ├── fole_test_macros.h ├── fole_test_memory.c ├── fole_test_memory.h ├── fole_test_support.c ├── fole_test_unused.h ├── fole_test_value_type.c ├── lsan.suppressions ├── pkgbuild.sh ├── runtests.sh ├── syncsharedlibs.sh ├── test_library.ps1 ├── test_library.sh ├── test_manpage.sh └── test_runner.sh /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: down 4 | range: 70...100 5 | status: 6 | project: true 7 | patch: true 8 | changes: false 9 | ignore: 10 | - "libcerror/*" 11 | - "tests/*" 12 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Build from source. 2 | name: build 3 | on: [push, pull_request] 4 | permissions: read-all 5 | jobs: 6 | build_ubuntu: 7 | runs-on: ubuntu-22.04 8 | strategy: 9 | matrix: 10 | include: 11 | - architecture: 'x86' 12 | compiler: 'clang' 13 | configure_options: '' 14 | - architecture: 'x64' 15 | compiler: 'clang' 16 | configure_options: '' 17 | - architecture: 'x86' 18 | compiler: 'gcc' 19 | configure_options: '' 20 | - architecture: 'x64' 21 | compiler: 'gcc' 22 | configure_options: '' 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Install build dependencies 26 | run: | 27 | sudo apt-get -y install autoconf automake autopoint build-essential git libtool pkg-config 28 | - name: Download test data 29 | run: | 30 | if test -x "synctestdata.sh"; then ./synctestdata.sh; fi 31 | - name: Building from source 32 | env: 33 | CC: ${{ matrix.compiler }} 34 | run: | 35 | tests/build.sh ${{ matrix.configure_options }} 36 | - name: Run tests 37 | run: | 38 | tests/runtests.sh 39 | build_dist: 40 | runs-on: ubuntu-22.04 41 | strategy: 42 | matrix: 43 | include: 44 | - architecture: 'x64' 45 | compiler: 'gcc' 46 | configure_options: '' 47 | steps: 48 | - uses: actions/checkout@v4 49 | - name: Install build dependencies 50 | run: | 51 | sudo apt-get -y install autoconf automake autopoint build-essential git libtool pkg-config 52 | - name: Download test data 53 | run: | 54 | if test -x "synctestdata.sh"; then ./synctestdata.sh; fi 55 | - name: Building from source 56 | env: 57 | CC: ${{ matrix.compiler }} 58 | run: | 59 | tests/build.sh ${{ matrix.configure_options }} 60 | - name: Run tests 61 | run: | 62 | make distcheck 63 | coverage_ubuntu: 64 | runs-on: ubuntu-22.04 65 | strategy: 66 | matrix: 67 | include: 68 | - architecture: 'x86' 69 | compiler: 'gcc' 70 | configure_options: '' 71 | - architecture: 'x64' 72 | compiler: 'gcc' 73 | configure_options: '' 74 | steps: 75 | - uses: actions/checkout@v4 76 | - name: Install build dependencies 77 | run: | 78 | sudo apt-get -y install autoconf automake autopoint build-essential git libtool pkg-config 79 | - name: Download test data 80 | run: | 81 | if test -x "synctestdata.sh"; then ./synctestdata.sh; fi 82 | - name: Building from source 83 | env: 84 | CC: ${{ matrix.compiler }} 85 | run: | 86 | tests/build.sh ${{ matrix.configure_options }} --enable-shared=no CFLAGS="--coverage -O0" CPPFLAGS="-DOPTIMIZATION_DISABLED" LDFLAGS="--coverage" 87 | - name: Run tests 88 | run: | 89 | make check CHECK_WITH_STDERR=1 SKIP_TOOLS_END_TO_END_TESTS=1 90 | - name: Generate coverage data 91 | run: | 92 | for DIRECTORY in `find . -maxdepth 1 -type d`; do \ 93 | (cd ${DIRECTORY} && find . -maxdepth 1 -name \*.gcno -type f -exec gcov -pb {} \;) \ 94 | done 95 | - name: Upload coverage report to Codecov 96 | uses: codecov/codecov-action@v4 97 | with: 98 | name: linux-${{ matrix.architecture }}-gcc-no-optimization 99 | token: ${{ secrets.CODECOV_TOKEN }} 100 | -------------------------------------------------------------------------------- /.github/workflows/build_freebsd.yml: -------------------------------------------------------------------------------- 1 | # Build from source on FreeBSD. 2 | name: build_freebsd 3 | on: [push] 4 | permissions: read-all 5 | jobs: 6 | build_freebsd: 7 | runs-on: ubuntu-22.04 8 | steps: 9 | - uses: actions/checkout@v4 10 | - name: Building from source 11 | id: build_freebsd 12 | uses: vmactions/freebsd-vm@v1 13 | with: 14 | usesh: true 15 | mem: 4096 16 | # Note that the test scripts require bash 17 | prepare: | 18 | pkg install -y autoconf automake bash gettext git libtool pkgconf 19 | run: | 20 | tests/build.sh 21 | tests/runtests.sh 22 | -------------------------------------------------------------------------------- /.github/workflows/build_shared.yml: -------------------------------------------------------------------------------- 1 | # Build from source with libyal dependencies as shared libraries. 2 | name: build_shared 3 | on: 4 | push: 5 | branches: [main] 6 | permissions: read-all 7 | jobs: 8 | build_shared_ubuntu: 9 | runs-on: ubuntu-22.04 10 | strategy: 11 | matrix: 12 | include: 13 | - architecture: 'x64' 14 | compiler: 'gcc' 15 | configure_options: '' 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Install build dependencies 19 | run: | 20 | sudo apt-get -y install autoconf automake autopoint build-essential git libtool pkg-config 21 | - name: Download test data 22 | run: | 23 | if test -x "synctestdata.sh"; then ./synctestdata.sh; fi 24 | - name: Prepare shared libraries 25 | run: | 26 | tests/syncsharedlibs.sh --use-head 27 | - name: Building from source 28 | env: 29 | CC: ${{ matrix.compiler }} 30 | run: | 31 | tests/build.sh ${{ matrix.configure_options }} 32 | - name: Run tests 33 | run: | 34 | tests/runtests.sh 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files to ignore by git 2 | # 3 | # Version: 20231119 4 | 5 | # Generic auto-generated build files 6 | *~ 7 | *.a 8 | *.gcda 9 | *.gcno 10 | *.gcov 11 | *.la 12 | *.lai 13 | *.lib 14 | *.lineno 15 | *.lo 16 | *.log 17 | *.loT 18 | *.o 19 | *.obj 20 | *.Plo 21 | *.Po 22 | *.so 23 | *.so.[0-9][0-9]* 24 | *.so.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]* 25 | *.swp 26 | *.Tpo 27 | *.trs 28 | *.whl 29 | /*.egg-info/ 30 | __pycache__ 31 | .deps 32 | .dirstamp 33 | .libs 34 | .tox 35 | INSTALL 36 | Makefile 37 | Makefile.bcc 38 | Makefile.in 39 | stamp-h[1-9] 40 | 41 | # Specific auto-generated build files 42 | /ABOUT-NLS 43 | /aclocal.m4 44 | /autom4te.cache/ 45 | /build 46 | /compile 47 | /confdefs.h 48 | /config.cache 49 | /config.guess 50 | /config.log 51 | /config.rpath 52 | /config.status 53 | /config.sub 54 | /configure 55 | /conftest.c 56 | /depcomp 57 | /dist 58 | /install-sh 59 | /libtool 60 | /ltmain.sh 61 | /m4/codeset.m4 62 | /m4/extern-inline.m4 63 | /m4/fcntl-o.m4 64 | /m4/gettext.m4 65 | /m4/glibc21.m4 66 | /m4/glibc2.m4 67 | /m4/host-cpu-c-abi.m4 68 | /m4/iconv.m4 69 | /m4/intdiv0.m4 70 | /m4/intldir.m4 71 | /m4/intl.m4 72 | /m4/intlmacosx.m4 73 | /m4/intmax.m4 74 | /m4/inttypes_h.m4 75 | /m4/inttypes-pri.m4 76 | /m4/lcmessage.m4 77 | /m4/lib-ld.m4 78 | /m4/lib-link.m4 79 | /m4/lib-prefix.m4 80 | /m4/libtool.m4 81 | /m4/lock.m4 82 | /m4/longlong.m4 83 | /m4/lt~obsolete.m4 84 | /m4/ltoptions.m4 85 | /m4/ltsugar.m4 86 | /m4/ltversion.m4 87 | /m4/nls.m4 88 | /m4/pkg.m4 89 | /m4/po.m4 90 | /m4/printf-posix.m4 91 | /m4/progtest.m4 92 | /m4/size_max.m4 93 | /m4/stdint_h.m4 94 | /m4/threadlib.m4 95 | /m4/uintmax_t.m4 96 | /m4/visibility.m4 97 | /m4/wchar_t.m4 98 | /m4/wint_t.m4 99 | /m4/xsize.m4 100 | /MANIFEST 101 | /missing 102 | /po/boldquot.sed 103 | /po/en@boldquot.header 104 | /po/en@quot.header 105 | /po/insert-header.sin 106 | /po/Makefile.in.in 107 | /po/Makevars 108 | /po/Makevars.template 109 | /po/POTFILES 110 | /po/quot.sed 111 | /po/remove-potcdate.sed 112 | /po/remove-potcdate.sin 113 | /po/Rules-quot 114 | /test-driver 115 | /ylwrap 116 | 117 | # Project specific files 118 | /common/config.h 119 | /common/config.h.in 120 | /common/types.h 121 | /dpkg/changelog 122 | /include/libfole.h 123 | /include/libfole/definitions.h 124 | /include/libfole/features.h 125 | /include/libfole/types.h 126 | /libfole.pc 127 | /libfole.spec 128 | /libfole/libfole.rc 129 | /libfole/libfole_definitions.h 130 | /tests/*.exe 131 | /tests/fole_test_error 132 | /tests/fole_test_support 133 | /tests/fole_test_value_type 134 | /tests/tmp* 135 | 136 | # Local library dependencies specific files 137 | /libcerror 138 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Acknowledgements: libfole 2 | 3 | Copyright (C) 2008-2024, Joachim Metz 4 | 5 | -------------------------------------------------------------------------------- /COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | TODO 2 | * add description for vector types 3 | 4 | 20140920 5 | * see `git log' for more recent change log 6 | * changes for project site move 7 | 8 | 20140808 9 | * Created stand-alone version of version used in libolecf 10 | 11 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | SUBDIRS = \ 4 | include \ 5 | common \ 6 | libcerror \ 7 | libfole \ 8 | po \ 9 | manuals \ 10 | tests \ 11 | msvscpp 12 | 13 | DPKG_FILES = \ 14 | dpkg/changelog \ 15 | dpkg/changelog.in \ 16 | dpkg/compat \ 17 | dpkg/control \ 18 | dpkg/copyright \ 19 | dpkg/rules \ 20 | dpkg/libfole-dev.install \ 21 | dpkg/libfole.install \ 22 | dpkg/source/format 23 | 24 | GETTEXT_FILES = \ 25 | config.rpath \ 26 | po/Makevars.in 27 | 28 | PKGCONFIG_FILES = \ 29 | libfole.pc.in 30 | 31 | SPEC_FILES = \ 32 | libfole.spec \ 33 | libfole.spec.in 34 | 35 | EXTRA_DIST = \ 36 | $(DPKG_FILES) \ 37 | $(GETTEXT_FILES) \ 38 | $(PKGCONFIG_FILES) \ 39 | $(SPEC_FILES) 40 | 41 | DISTCLEANFILES = \ 42 | config.status \ 43 | config.cache \ 44 | config.log \ 45 | libfole.pc \ 46 | libfole.spec \ 47 | Makefile \ 48 | Makefile.in \ 49 | po/Makevars 50 | 51 | pkgconfigdir = $(libdir)/pkgconfig 52 | 53 | pkgconfig_DATA = \ 54 | libfole.pc 55 | 56 | libtool: @LIBTOOL_DEPS@ 57 | cd $(srcdir) && $(SHELL) ./config.status --recheck 58 | 59 | lib: library 60 | 61 | library: 62 | (cd $(srcdir)/common && $(MAKE) $(AM_MAKEFLAGS)) 63 | (cd $(srcdir)/libcerror && $(MAKE) $(AM_MAKEFLAGS)) 64 | (cd $(srcdir)/libfole && $(MAKE) $(AM_MAKEFLAGS)) 65 | (cd $(srcdir)/po && $(MAKE) $(AM_MAKEFLAGS)) 66 | 67 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libyal/libfole/c6dbb26a2f2a531cd4d1101bbffa88cd110e3f90/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | libfole is a library for Object Linking and Embedding (OLE) data types. 2 | 3 | Project information: 4 | 5 | * Status: alpha 6 | * Licence: LGPLv3+ 7 | 8 | For more information see: 9 | 10 | * Project documentation: https://github.com/libyal/libfole/wiki/Home 11 | * How to build from source: https://github.com/libyal/libfole/wiki/Building 12 | 13 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for required headers and functions 2 | dnl 3 | dnl Version: 20240413 4 | 5 | dnl Function to detect if libfole dependencies are available 6 | AC_DEFUN([AX_LIBFOLE_CHECK_LOCAL], 7 | [dnl No additional checks. 8 | ]) 9 | 10 | dnl Function to check if DLL support is needed 11 | AC_DEFUN([AX_LIBFOLE_CHECK_DLL_SUPPORT], 12 | [AS_IF( 13 | [test "x$enable_shared" = xyes], 14 | [AS_CASE( 15 | [$host], 16 | [*cygwin* | *mingw* | *msys*], 17 | [AC_DEFINE( 18 | [HAVE_DLLMAIN], 19 | [1], 20 | [Define to 1 to enable the DllMain function.]) 21 | AC_SUBST( 22 | [HAVE_DLLMAIN], 23 | [1]) 24 | 25 | AC_SUBST( 26 | [LIBFOLE_DLL_EXPORT], 27 | ["-DLIBFOLE_DLL_EXPORT"]) 28 | 29 | AC_SUBST( 30 | [LIBFOLE_DLL_IMPORT], 31 | ["-DLIBFOLE_DLL_IMPORT"]) 32 | ]) 33 | ]) 34 | ]) 35 | 36 | -------------------------------------------------------------------------------- /autogen.ps1: -------------------------------------------------------------------------------- 1 | # Script to generate the necessary files for a msvscpp build 2 | # 3 | # Version: 20240306 4 | 5 | $WinFlex = "..\win_flex_bison\win_flex.exe" 6 | $WinBison = "..\win_flex_bison\win_bison.exe" 7 | 8 | $Library = Get-Content -Path configure.ac | select -skip 3 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } 9 | $Version = Get-Content -Path configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } 10 | $Prefix = ${Library}.Substring(3) 11 | 12 | Get-Content -Path "include\${Library}.h.in" | Out-File -Encoding ascii "include\${Library}.h" 13 | Get-Content -Path "include\${Library}\definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "include\${Library}\definitions.h" 14 | Get-Content -Path "include\${Library}\features.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\features.h" 15 | Get-Content -Path "include\${Library}\types.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\types.h" 16 | Get-Content -Path "common\types.h.in" | % { $_ -Replace "@PACKAGE@","${Library}" } | Out-File -Encoding ascii "common\types.h" 17 | Get-Content -Path "${Library}\${Library}_definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}_definitions.h" 18 | Get-Content -Path "${Library}\${Library}.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}.rc" 19 | 20 | If (Test-Path "setup.cfg.in") 21 | { 22 | Get-Content -Path "setup.cfg.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "setup.cfg" 23 | } 24 | 25 | If (Test-Path "${Prefix}.net") 26 | { 27 | Get-Content -Path "${Prefix}.net\${Prefix}.net.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Prefix}.net\${Prefix}.net.rc" 28 | } 29 | 30 | $NamePrefix = "" 31 | 32 | ForEach (${Library} in Get-ChildItem -Directory -Path "lib*") 33 | { 34 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.l") 35 | { 36 | $OutputFile = ${DirectoryElement} -Replace ".l$",".c" 37 | 38 | $NamePrefix = Split-Path -path ${DirectoryElement} -leaf 39 | $NamePrefix = ${NamePrefix} -Replace ".l$","_" 40 | 41 | Write-Host "Running: ${WinFlex} -Cf ${DirectoryElement}" 42 | 43 | # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr 44 | # therefore 2>&1 is added and the output is stored in a variable. 45 | $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" 46 | Write-Host ${Output} 47 | 48 | # Moving manually since `win_flex -o filename' does not provide the expected behavior. 49 | Move-Item "lex.yy.c" ${OutputFile} -force 50 | } 51 | 52 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.y") 53 | { 54 | $OutputFile = ${DirectoryElement} -Replace ".y$",".c" 55 | 56 | Write-Host "Running: ${WinBison} -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement}" 57 | 58 | # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr 59 | # therefore 2>&1 is added and the output is stored in a variable. 60 | $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" 61 | Write-Host ${Output} 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to generate ./configure using the autotools 3 | # 4 | # Version: 20230405 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | 9 | BINDIR="/usr/bin"; 10 | 11 | if ! test -x "${BINDIR}/aclocal"; 12 | then 13 | BINDIR="/usr/local/bin"; 14 | fi 15 | if ! test -x "${BINDIR}/aclocal"; 16 | then 17 | BINDIR="/usr/local/bin"; 18 | fi 19 | if ! test -x "${BINDIR}/aclocal"; 20 | then 21 | # Default location of MacPorts installed binaries. 22 | BINDIR="/opt/local/bin"; 23 | fi 24 | if ! test -x "${BINDIR}/aclocal"; 25 | then 26 | # Default location of 32-bit MSYS2-MinGW installed binaries. 27 | BINDIR="/mingw32/bin"; 28 | fi 29 | if ! test -x "${BINDIR}/aclocal"; 30 | then 31 | # Default location of 64-bit MSYS2-MinGW installed binaries. 32 | BINDIR="/mingw64/bin"; 33 | fi 34 | 35 | if ! test -x "${BINDIR}/aclocal"; 36 | then 37 | echo "Unable to find autotools"; 38 | 39 | exit ${EXIT_FAILURE}; 40 | fi 41 | 42 | ACLOCAL="${BINDIR}/aclocal"; 43 | AUTOCONF="${BINDIR}/autoconf"; 44 | AUTOHEADER="${BINDIR}/autoheader"; 45 | AUTOMAKE="${BINDIR}/automake"; 46 | AUTOPOINT="${BINDIR}/autopoint"; 47 | AUTORECONF="${BINDIR}/autoreconf"; 48 | LIBTOOLIZE="${BINDIR}/libtoolize"; 49 | PKGCONFIG="${BINDIR}/pkg-config"; 50 | 51 | if test "${OSTYPE}" = "msys"; 52 | then 53 | # Work-around for autopoint failing to detect gettext version 54 | # using func_trace (which is not available) on MSYS by writing 55 | # the gettext version to intl/VERSION. 56 | if ! test -d intl; 57 | then 58 | mkdir intl; 59 | fi 60 | GETTEXT_VERSION=`gettext --version | head -n1 | sed 's/^.* //'`; 61 | 62 | echo "gettext-${GETTEXT_VERSION}" > intl/VERSION; 63 | 64 | elif ! test -x "${PKGCONFIG}"; 65 | then 66 | if test "${BINDIR}" != "/usr/bin"; 67 | then 68 | # On OpenBSD most of the autotools are located in 69 | # /usr/local/bin while pkg-config is located in /usr/bin 70 | PKGCONFIG="/usr/bin/pkg-config"; 71 | fi 72 | if ! test -x "${PKGCONFIG}"; 73 | then 74 | echo "Unable to find: pkg-config"; 75 | 76 | exit ${EXIT_FAILURE}; 77 | fi 78 | fi 79 | 80 | if test -x "${AUTORECONF}"; 81 | then 82 | ${AUTORECONF} --force --install 83 | if test $? -ne 0; 84 | then 85 | exit $?; 86 | fi 87 | else 88 | if ! test -x "${ACLOCAL}"; 89 | then 90 | echo "Unable to find: aclocal"; 91 | 92 | exit ${EXIT_FAILURE}; 93 | fi 94 | 95 | if ! test -x "${AUTOCONF}"; 96 | then 97 | echo "Unable to find: autoconf"; 98 | 99 | exit ${EXIT_FAILURE}; 100 | fi 101 | 102 | if ! test -x "${AUTOHEADER}"; 103 | then 104 | echo "Unable to find: autoheader"; 105 | 106 | exit ${EXIT_FAILURE}; 107 | fi 108 | 109 | if ! test -x "${AUTOMAKE}"; 110 | then 111 | echo "Unable to find: automake"; 112 | 113 | exit ${EXIT_FAILURE}; 114 | fi 115 | 116 | if ! test -x "${AUTOPOINT}"; 117 | then 118 | echo "Unable to find: autopoint"; 119 | 120 | exit ${EXIT_FAILURE}; 121 | fi 122 | 123 | if ! test -x "${LIBTOOLIZE}"; 124 | then 125 | echo "Unable to find: libtoolize"; 126 | 127 | exit ${EXIT_FAILURE}; 128 | fi 129 | 130 | ${AUTOPOINT} --force; 131 | if test $? -ne 0; 132 | then 133 | exit $?; 134 | fi 135 | 136 | ${ACLOCAL} --force --install -I m4; 137 | if test $? -ne 0; 138 | then 139 | exit $?; 140 | fi 141 | 142 | ${LIBTOOLIZE} --force; 143 | if test $? -ne 0; 144 | then 145 | exit $?; 146 | fi 147 | 148 | ${AUTOHEADER} --force; 149 | if test $? -ne 0; 150 | then 151 | exit $?; 152 | fi 153 | 154 | ${AUTOCONF} --force; 155 | if test $? -ne 0; 156 | then 157 | exit $?; 158 | fi 159 | 160 | ${AUTOMAKE} --force --add-missing; 161 | if test $? -ne 0; 162 | then 163 | exit $?; 164 | fi 165 | 166 | fi 167 | 168 | exit ${EXIT_SUCCESS}; 169 | 170 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | # Script that builds libfole 2 | # 3 | # Version: 20230411 4 | 5 | Param ( 6 | [string]$Configuration = ${Env:Configuration}, 7 | [string]$Platform = ${Env:Platform}, 8 | [string]$PlatformToolset = "", 9 | [string]$PythonPath = "C:\Python311", 10 | [string]$VisualStudioVersion = "", 11 | [string]$VSToolsOptions = "--extend-with-x64", 12 | [string]$VSToolsPath = "..\vstools" 13 | ) 14 | 15 | $ExitSuccess = 0 16 | $ExitFailure = 1 17 | 18 | $Python = "${PythonPath}\python.exe" 19 | 20 | $Git = "git" 21 | $GitUrl = "https://github.com/libyal/vstools.git" 22 | 23 | $MSVSCppConvert = "${VSToolsPath}\scripts\msvscpp-convert.py" 24 | 25 | If (-Not (Test-Path $Python)) 26 | { 27 | Write-Host "Missing Python: ${Python}" -foreground Red 28 | 29 | Exit ${ExitFailure} 30 | } 31 | If (-Not (Test-Path ${VSToolsPath})) 32 | { 33 | # PowerShell will raise NativeCommandError if git writes to stdout or stderr 34 | # therefore 2>&1 is added and the output is stored in a variable. 35 | $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${VSToolsPath} 2>&1" | %{ "$_" } 36 | } 37 | Else 38 | { 39 | Push-Location "${VSToolsPath}" 40 | 41 | Try 42 | { 43 | # Make sure vstools are up to date. 44 | $Output = Invoke-Expression -Command "${Git} pull 2>&1" | %{ "$_" } 45 | } 46 | Finally 47 | { 48 | Pop-Location 49 | } 50 | } 51 | If (-Not (Test-Path ${MSVSCppConvert})) 52 | { 53 | Write-Host "Missing msvscpp-convert.py: ${MSVSCppConvert}" -foreground Red 54 | 55 | Exit ${ExitFailure} 56 | } 57 | If (-Not ${VisualStudioVersion}) 58 | { 59 | $VisualStudioVersion = "2022" 60 | 61 | Write-Host "Visual Studio version not set defauting to: ${VisualStudioVersion}" -foreground Red 62 | } 63 | If ((${VisualStudioVersion} -ne "2008") -And (${VisualStudioVersion} -ne "2010") -And (${VisualStudioVersion} -ne "2012") -And (${VisualStudioVersion} -ne "2013") -And (${VisualStudioVersion} -ne "2015") -And (${VisualStudioVersion} -ne "2017") -And (${VisualStudioVersion} -ne "2019") -And (${VisualStudioVersion} -ne "2022")) 64 | { 65 | Write-Host "Unsupported Visual Studio version: ${VisualStudioVersion}" -foreground Red 66 | 67 | Exit ${ExitFailure} 68 | } 69 | $MSBuild = "" 70 | 71 | If (${VisualStudioVersion} -eq "2008") 72 | { 73 | $MSBuild = "C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" 74 | } 75 | ElseIf ((${VisualStudioVersion} -eq "2010") -Or (${VisualStudioVersion} -eq "2012")) 76 | { 77 | $MSBuild = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" 78 | } 79 | ElseIf (${VisualStudioVersion} -eq "2013") 80 | { 81 | $MSBuild = "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" 82 | } 83 | ElseIf (${VisualStudioVersion} -eq "2015") 84 | { 85 | $MSBuild = "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" 86 | } 87 | ElseIf (${VisualStudioVersion} -eq "2017") 88 | { 89 | $Results = Get-ChildItem -Path "C:\Program Files\Microsoft Visual Studio\${VisualStudioVersion}\*\MSBuild\15.0\Bin\MSBuild.exe" -Recurse -ErrorAction SilentlyContinue -Force 90 | 91 | If ($Results.Count -eq 0) 92 | { 93 | $Results = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Visual Studio\${VisualStudioVersion}\*\MSBuild\15.0\Bin\MSBuild.exe" -Recurse -ErrorAction SilentlyContinue -Force 94 | } 95 | If ($Results.Count -gt 0) 96 | { 97 | $MSBuild = $Results[0].FullName 98 | } 99 | } 100 | ElseIf (${VisualStudioVersion} -eq "2019" -Or ${VisualStudioVersion} -eq "2022") 101 | { 102 | $Results = Get-ChildItem -Path "C:\Program Files\Microsoft Visual Studio\${VisualStudioVersion}\*\MSBuild\Current\Bin\MSBuild.exe" -Recurse -ErrorAction SilentlyContinue -Force 103 | 104 | If ($Results.Count -eq 0) 105 | { 106 | $Results = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Visual Studio\${VisualStudioVersion}\*\MSBuild\Current\Bin\MSBuild.exe" -Recurse -ErrorAction SilentlyContinue -Force 107 | } 108 | If ($Results.Count -gt 0) 109 | { 110 | $MSBuild = $Results[0].FullName 111 | } 112 | } 113 | If (-Not ${MSBuild}) 114 | { 115 | Write-Host "Unable to determine path to msbuild.exe" -foreground Red 116 | 117 | Exit ${ExitFailure} 118 | } 119 | ElseIf (-Not (Test-Path ${MSBuild})) 120 | { 121 | Write-Host "Missing msbuild.exe: ${MSBuild}" -foreground Red 122 | 123 | Exit ${ExitFailure} 124 | } 125 | 126 | If (${VisualStudioVersion} -eq "2008") 127 | { 128 | $VSSolutionPath = "msvscpp" 129 | } 130 | Else 131 | { 132 | $VSSolutionPath = "vs${VisualStudioVersion}" 133 | 134 | If (-Not (Test-Path "${VSSolutionPath}")) 135 | { 136 | ${Env:PYTHONPATH} = ${VSToolsPath} 137 | 138 | Invoke-Expression -Command "& '${Python}' ${MSVSCppConvert} --output-format ${VisualStudioVersion} ${VSToolsOptions} msvscpp\libfole.sln 2>&1" | %{ "$_" } 139 | } 140 | } 141 | $VSSolutionFile = "${VSSolutionPath}\libfole.sln" 142 | 143 | If (-Not (Test-Path "${VSSolutionFile}")) 144 | { 145 | Write-Host "Missing Visual Studio ${VisualStudioVersion} solution file: ${VSSolutionFile}" -foreground Red 146 | 147 | Exit ${ExitFailure} 148 | } 149 | If (-Not ${Configuration}) 150 | { 151 | $Configuration = "Release" 152 | 153 | Write-Host "Configuration not set defauting to: ${Configuration}" 154 | } 155 | If (-Not ${Platform}) 156 | { 157 | $Platform = "Win32" 158 | 159 | Write-Host "Platform not set defauting to: ${Platform}" 160 | } 161 | $PlatformToolset = "" 162 | 163 | If (-Not ${PlatformToolset}) 164 | { 165 | If (${VisualStudioVersion} -eq "2015") 166 | { 167 | $PlatformToolset = "v140" 168 | } 169 | ElseIf (${VisualStudioVersion} -eq "2017") 170 | { 171 | $PlatformToolset = "v141" 172 | } 173 | ElseIf (${VisualStudioVersion} -eq "2019") 174 | { 175 | $PlatformToolset = "v142" 176 | } 177 | ElseIf (${VisualStudioVersion} -eq "2022") 178 | { 179 | $PlatformToolset = "v143" 180 | } 181 | Write-Host "PlatformToolset not set defauting to: ${PlatformToolset}" 182 | } 183 | $MSBuildOptions = "/verbosity:quiet /target:Build /property:Configuration=${Configuration},Platform=${Platform}" 184 | 185 | If (${PlatformToolset}) 186 | { 187 | $MSBuildOptions = "${MSBuildOptions} /property:PlatformToolset=${PlatformToolset}" 188 | } 189 | If (${Env:APPVEYOR} -eq "True") 190 | { 191 | Invoke-Expression -Command "& '${MSBuild}' ${MSBuildOptions} ${VSSolutionFile} /logger:'C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll' 2>&1" | %{ "$_" } 192 | } 193 | Else 194 | { 195 | Invoke-Expression -Command "& '${MSBuild}' ${MSBuildOptions} ${VSSolutionFile} 2>&1" | %{ "$_" } 196 | } 197 | 198 | Exit ${ExitSuccess} 199 | -------------------------------------------------------------------------------- /common/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -I../include -I$(top_srcdir)/include 3 | 4 | EXTRA_DIST = \ 5 | byte_stream.h \ 6 | common.h \ 7 | config.h \ 8 | config_borlandc.h \ 9 | config_msc.h \ 10 | config_winapi.h \ 11 | file_stream.h \ 12 | memory.h \ 13 | narrow_string.h \ 14 | system_string.h \ 15 | types.h \ 16 | types.h.in \ 17 | wide_string.h 18 | 19 | DISTCLEANFILES = \ 20 | config.h \ 21 | types.h \ 22 | Makefile \ 23 | Makefile.in 24 | 25 | -------------------------------------------------------------------------------- /common/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Common include file 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _COMMON_H ) 23 | #define _COMMON_H 24 | 25 | #if defined( HAVE_CONFIG_H ) 26 | #include "config.h" 27 | #endif 28 | 29 | /* Include the Borland/CodeGear C++ Builder compiler specific configuration 30 | */ 31 | #if defined( __BORLANDC__ ) 32 | #include "config_borlandc.h" 33 | 34 | /* Include the Microsoft Visual Studio C++ compiler specific configuration 35 | */ 36 | #elif defined( _MSC_VER ) 37 | #include "config_msc.h" 38 | #endif 39 | 40 | #include "config_winapi.h" 41 | 42 | #endif /* !defined( _COMMON_H ) */ 43 | 44 | -------------------------------------------------------------------------------- /common/config_borlandc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration for the Borland/CodeGear C++ Builder compiler 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _CONFIG_BORLANDC_H ) 23 | #define _CONFIG_BORLANDC_H 24 | 25 | #endif /* !defined( _CONFIG_BORLANDC_H ) */ 26 | 27 | -------------------------------------------------------------------------------- /common/config_msc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration for the Microsoft Visual Studio C++ compiler 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _CONFIG_MSC_H ) 23 | #define _CONFIG_MSC_H 24 | 25 | /* Disable warning C4127: conditional expression is constant 26 | */ 27 | #pragma warning( disable : 4127 ) 28 | 29 | /* Disable warning C4201: nonstandard extension used : nameless struct/union 30 | */ 31 | #pragma warning( disable : 4201 ) 32 | 33 | #endif /* !defined( _CONFIG_MSC_H ) */ 34 | 35 | -------------------------------------------------------------------------------- /common/config_winapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration file for WINAPI 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _CONFIG_WINAPI_H ) 23 | #define _CONFIG_WINAPI_H 24 | 25 | /* Define the earliest supported WINAPI version 26 | #define WINVER 0x0501 27 | */ 28 | 29 | /* If necessary make sure WINAPI is defined 30 | */ 31 | #if defined( HAVE_WINDOWS_H ) || defined( __BORLANDC__ ) || defined( _MSC_VER ) 32 | #include 33 | #endif 34 | 35 | #if defined( WINAPI ) 36 | 37 | /* Define to the address where bug reports for this package should be sent. 38 | */ 39 | #define PACKAGE_BUGREPORT "joachim.metz@gmail.com" 40 | 41 | /* Define the size of the integer for WINAPI 42 | */ 43 | #if !defined( SIZEOF_INT ) 44 | #define SIZEOF_INT 4 45 | #endif 46 | 47 | /* Define the size of size_t for WINAPI 48 | * Do not define when pyconfig.h has been included via python.h 49 | */ 50 | #if !defined( HAVE_PYCONFIG_H ) 51 | 52 | #if !defined( SIZEOF_SIZE_T ) 53 | #if __WORDSIZE == 64 54 | #define SIZEOF_SIZE_T 8 55 | #else 56 | #define SIZEOF_SIZE_T 4 57 | #endif 58 | #endif 59 | 60 | #endif /* !defined( HAVE_PYCONFIG_H ) */ 61 | 62 | /* Define the size of the wide character for WINAPI 63 | */ 64 | #if !defined( SIZEOF_WCHAR_T ) 65 | #define SIZEOF_WCHAR_T 2 66 | #endif 67 | 68 | /* Enable the DllMain function 69 | */ 70 | #define HAVE_DLLMAIN 1 71 | 72 | /* Enable verbose output 73 | #define HAVE_VERBOSE_OUTPUT 1 74 | */ 75 | 76 | /* Enable debug output 77 | #define HAVE_DEBUG_OUTPUT 1 78 | */ 79 | 80 | /* Enable both the narrow and wide character functions 81 | */ 82 | #if !defined( HAVE_WIDE_CHARACTER_TYPE ) 83 | #define HAVE_WIDE_CHARACTER_TYPE 1 84 | #endif 85 | 86 | /* If not controlled by config.h enable multi-thread support 87 | */ 88 | #if !defined( HAVE_CONFIG_H ) && !defined( HAVE_MULTI_THREAD_SUPPORT ) 89 | #define HAVE_MULTI_THREAD_SUPPORT 1 90 | #endif 91 | 92 | #endif /* defined( WINAPI ) */ 93 | 94 | #endif /* !defined( _CONFIG_WINAPI_H ) */ 95 | 96 | -------------------------------------------------------------------------------- /common/file_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILE stream functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _FILE_STREAM_H ) 23 | #define _FILE_STREAM_H 24 | 25 | #include "common.h" 26 | 27 | #if defined( HAVE_GLIB_H ) 28 | #include 29 | #include 30 | #endif 31 | 32 | #include 33 | 34 | #if defined( __cplusplus ) 35 | extern "C" { 36 | #endif 37 | 38 | #define FILE_STREAM_OPEN_APPEND "a" 39 | #define FILE_STREAM_OPEN_READ "r" 40 | #define FILE_STREAM_OPEN_WRITE "w" 41 | 42 | #if defined( WINAPI ) 43 | #define FILE_STREAM_BINARY_OPEN_APPEND "ab" 44 | #define FILE_STREAM_BINARY_OPEN_READ "rb" 45 | #define FILE_STREAM_BINARY_OPEN_WRITE "wb" 46 | 47 | #else 48 | #define FILE_STREAM_BINARY_OPEN_APPEND "a" 49 | #define FILE_STREAM_BINARY_OPEN_READ "r" 50 | #define FILE_STREAM_BINARY_OPEN_WRITE "w" 51 | 52 | #endif 53 | 54 | /* narrow character FILE stream open 55 | */ 56 | #if defined( HAVE_GLIB_H ) 57 | #define file_stream_open( filename, mode ) \ 58 | g_fopen( filename, mode ) 59 | 60 | #elif defined( HAVE_FOPEN ) || defined( WINAPI ) 61 | #define file_stream_open( filename, mode ) \ 62 | fopen( filename, mode ) 63 | #endif 64 | 65 | /* wide character FILE stream open 66 | */ 67 | #if defined( WINAPI ) 68 | #define file_stream_open_wide( filename, mode ) \ 69 | _wfopen( filename, mode ) 70 | #endif 71 | 72 | /* FILE stream close 73 | */ 74 | #if defined( HAVE_FCLOSE ) || defined( WINAPI ) 75 | #define file_stream_close( stream ) \ 76 | fclose( stream ) 77 | #endif 78 | 79 | /* FILE stream read 80 | */ 81 | #if defined( HAVE_FREAD ) || defined( WINAPI ) 82 | #define file_stream_read( stream, data, size ) \ 83 | fread( data, 1, size, stream ) 84 | #endif 85 | 86 | /* FILE stream write 87 | */ 88 | #if defined( HAVE_FWRITE ) || defined( WINAPI ) 89 | #define file_stream_write( stream, data, size ) \ 90 | fwrite( data, 1, size, stream ) 91 | #endif 92 | 93 | /* FILE stream seek 94 | */ 95 | #if defined( WINAPI ) 96 | #define file_stream_seek_offset( stream, offset, whence ) \ 97 | fseek( stream, offset, whence ) 98 | 99 | #elif defined( HAVE_FSEEKO ) 100 | #define file_stream_seek_offset( stream, offset, whence ) \ 101 | fseeko( stream, offset, whence ) 102 | 103 | #elif defined( HAVE_FSEEKO64 ) 104 | #define file_stream_seek_offset( stream, offset, whence ) \ 105 | fseeko64( stream, offset, whence ) 106 | #endif 107 | 108 | /* End of FILE stream 109 | */ 110 | #if defined( HAVE_FEOF ) || defined( WINAPI ) 111 | #define file_stream_at_end( stream ) \ 112 | feof( stream ) 113 | #endif 114 | 115 | /* Get narrow character string from FILE stream 116 | */ 117 | #if defined( HAVE_FGETS ) || defined( WINAPI ) 118 | #define file_stream_get_string( stream, string, size ) \ 119 | fgets( string, size, stream ) 120 | #endif 121 | 122 | /* Get wide characters string from FILE stream 123 | */ 124 | #if defined( HAVE_FGETWS ) || defined( WINAPI ) 125 | #define file_stream_get_string_wide( stream, string, size ) \ 126 | fgetws( string, size, stream ) 127 | #endif 128 | 129 | /* Variable arguments formatted print to stream function 130 | */ 131 | #if defined( HAVE_GLIB_H ) 132 | #define file_stream_vfprintf( stream, format, ... ) \ 133 | g_vfprintf( stream, format, __VA_ARGS__ ) 134 | 135 | /* Borland BCC previous to version 5.6.0 cannot handle the macro form: MACRO( ... ) 136 | */ 137 | #elif defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 138 | #define file_stream_vfprintf \ 139 | vfprintf 140 | 141 | #elif defined( HAVE_VFPRINTF ) || defined( WINAPI ) 142 | #define file_stream_vfprintf( stream, format, ... ) \ 143 | vfprintf( stream, format, __VA_ARGS__ ) 144 | #endif 145 | 146 | #if defined( __cplusplus ) 147 | } 148 | #endif 149 | 150 | #endif /* !defined( _FILE_STREAM_H ) */ 151 | 152 | -------------------------------------------------------------------------------- /common/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _MEMORY_H ) 23 | #define _MEMORY_H 24 | 25 | #include "common.h" 26 | 27 | #if defined( HAVE_GLIB_H ) 28 | #include 29 | #endif 30 | 31 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 32 | #include 33 | #endif 34 | 35 | #if defined( HAVE_STRING_H ) || defined( WINAPI ) 36 | #include 37 | #endif 38 | 39 | #if defined( __cplusplus ) 40 | extern "C" { 41 | #endif 42 | 43 | /* Note that 128 MiB is an arbitrary selected upper limit here 44 | */ 45 | #define MEMORY_MAXIMUM_ALLOCATION_SIZE \ 46 | ( 128 * 1024 * 1024 ) 47 | 48 | /* Memory allocation 49 | */ 50 | #if defined( HAVE_GLIB_H ) 51 | #define memory_allocate( size ) \ 52 | g_malloc( (gsize) size ) 53 | 54 | #elif defined( WINAPI ) 55 | #define memory_allocate( size ) \ 56 | HeapAlloc( GetProcessHeap(), 0, (SIZE_T) size ) 57 | 58 | #elif defined( HAVE_MALLOC ) 59 | #define memory_allocate( size ) \ 60 | malloc( size ) 61 | #endif 62 | 63 | #define memory_allocate_structure( type ) \ 64 | (type *) memory_allocate( sizeof( type ) ) 65 | 66 | #define memory_allocate_structure_as_value( type ) \ 67 | (intptr_t *) memory_allocate( sizeof( type ) ) 68 | 69 | /* Memory reallocation 70 | */ 71 | #if defined( HAVE_GLIB_H ) 72 | #define memory_reallocate( buffer, size ) \ 73 | g_realloc( (gpointer) buffer, (gsize) size ) 74 | 75 | #elif defined( WINAPI ) 76 | /* HeapReAlloc does not allocate empty (NULL) buffers as realloc does 77 | */ 78 | #define memory_reallocate( buffer, size ) \ 79 | ( buffer == NULL ) ? \ 80 | HeapAlloc( GetProcessHeap(), 0, (SIZE_T) size ) : \ 81 | HeapReAlloc( GetProcessHeap(), 0, (LPVOID) buffer, (SIZE_T) size ) 82 | 83 | #elif defined( HAVE_REALLOC ) 84 | #define memory_reallocate( buffer, size ) \ 85 | realloc( (void *) buffer, size ) 86 | #endif 87 | 88 | /* Memory free 89 | */ 90 | #if defined( HAVE_GLIB_H ) 91 | #define memory_free( buffer ) \ 92 | g_free( (gpointer) buffer ) 93 | 94 | #elif defined( WINAPI ) 95 | #define memory_free( buffer ) \ 96 | ( buffer == NULL ) ? TRUE : HeapFree( GetProcessHeap(), 0, (LPVOID) buffer ) 97 | 98 | #elif defined( HAVE_FREE ) 99 | #define memory_free( buffer ) \ 100 | free( (void *) buffer ) 101 | #endif 102 | 103 | /* Memory compare 104 | */ 105 | #if defined( HAVE_MEMCMP ) || defined( WINAPI ) 106 | #define memory_compare( buffer1, buffer2, size ) \ 107 | memcmp( (const void *) buffer1, (const void *) buffer2, size ) 108 | #endif 109 | 110 | /* Memory copy 111 | */ 112 | #if defined( HAVE_MEMCPY ) || defined( WINAPI ) 113 | #define memory_copy( destination, source, count ) \ 114 | memcpy( (void *) destination, (void *) source, count ) 115 | #endif 116 | 117 | /* Memory set 118 | */ 119 | #if defined( HAVE_MEMSET ) || defined( WINAPI ) 120 | #define memory_set( buffer, value, count ) \ 121 | memset( (void *) buffer, (int) value, count ) 122 | #endif 123 | 124 | #if defined( __cplusplus ) 125 | } 126 | #endif 127 | 128 | #endif /* !defined( _MEMORY_H ) */ 129 | 130 | -------------------------------------------------------------------------------- /common/narrow_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Narrow character string functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _NARROW_STRING_H ) 23 | #define _NARROW_STRING_H 24 | 25 | #include "common.h" 26 | #include "memory.h" 27 | #include "types.h" 28 | 29 | #if defined( HAVE_GLIB_H ) 30 | #include 31 | #endif 32 | 33 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 34 | #include 35 | #endif 36 | 37 | #if defined( HAVE_STRING_H ) || defined( WINAPI ) 38 | #include 39 | #endif 40 | 41 | #if defined( __cplusplus ) 42 | extern "C" { 43 | #endif 44 | 45 | /* String allocation 46 | */ 47 | #define narrow_string_allocate( size ) \ 48 | (char *) memory_allocate( sizeof( char ) * ( size ) ) 49 | 50 | /* String reallocation 51 | */ 52 | #define narrow_string_reallocate( string, size ) \ 53 | (char *) memory_reallocate( string, ( sizeof( char ) * ( size ) ) ) 54 | 55 | /* String length 56 | */ 57 | #if defined( HAVE_STRLEN ) || defined( WINAPI ) 58 | #define narrow_string_length( string ) \ 59 | strlen( string ) 60 | #endif 61 | 62 | /* String compare 63 | */ 64 | #if defined( HAVE_MEMCMP ) || defined( WINAPI ) 65 | #define narrow_string_compare( string1, string2, size ) \ 66 | memcmp( (void *) string1, (void *) string2, size ) 67 | 68 | #elif defined( HAVE_STRNCMP ) 69 | #define narrow_string_compare( string1, string2, size ) \ 70 | strncmp( string1, string2, size ) 71 | #endif 72 | 73 | /* Caseless string compare 74 | */ 75 | #if defined( HAVE_GLIB_H ) 76 | #define narrow_string_compare_no_case( string1, string2, size ) \ 77 | g_ascii_strncasecmp( string1, string2, size ) 78 | 79 | #elif defined( _MSC_VER ) 80 | #define narrow_string_compare_no_case( string1, string2, size ) \ 81 | _strnicmp( string1, string2, size ) 82 | 83 | #elif ( defined( WINAPI ) && !defined( __CYGWIN__ ) ) || defined( HAVE_STRNICMP ) 84 | #define narrow_string_compare_no_case( string1, string2, size ) \ 85 | strnicmp( string1, string2, size ) 86 | 87 | #elif defined( HAVE_STRNCASECMP ) 88 | #define narrow_string_compare_no_case( string1, string2, size ) \ 89 | strncasecmp( string1, string2, size ) 90 | 91 | #elif defined( HAVE_STRCASECMP ) 92 | #define narrow_string_compare_no_case( string1, string2, size ) \ 93 | strcasecmp( string1, string2 ) 94 | #endif 95 | 96 | /* String copy 97 | */ 98 | #if defined( HAVE_MEMCPY ) || defined( WINAPI ) 99 | #define narrow_string_copy( destination, source, size ) \ 100 | (char *) memcpy( (void *) destination, (void *) source, size ) 101 | 102 | #elif defined( HAVE_STRNCPY ) 103 | #define narrow_string_copy( destination, source, size ) \ 104 | strncpy( destination, source, size ) 105 | #endif 106 | 107 | /* String character search 108 | */ 109 | #if defined( HAVE_MEMCHR ) || defined( WINAPI ) 110 | #define narrow_string_search_character( string, character, size ) \ 111 | (char *) memchr( (void *) string, (int) character, size ) 112 | 113 | #elif defined( HAVE_STRCHR ) 114 | #define narrow_string_search_character( string, character, size ) \ 115 | strchr( string, (int) character ) 116 | #endif 117 | 118 | /* String reverse character search 119 | */ 120 | #if defined( HAVE_MEMRCHR ) && ( HAVE_DECL_MEMRCHR == 1 ) 121 | #define narrow_string_search_character_reverse( string, character, size ) \ 122 | (char *) memrchr( (void *) string, (int) character, size ) 123 | 124 | #elif defined( HAVE_STRRCHR ) || defined( WINAPI ) 125 | /* (void)(size) is used to suppress unused variable warnings */ 126 | #define narrow_string_search_character_reverse( string, character, size ) \ 127 | strrchr( string, (int) character ); (void)(size) 128 | #endif 129 | 130 | /* String sub-string search 131 | */ 132 | #if defined( HAVE_STRSTR ) || defined( WINAPI ) 133 | #define narrow_string_search_string( string, substring, size ) \ 134 | strstr( string, substring ) 135 | #endif 136 | 137 | /* String formatted print (snprintf) 138 | */ 139 | #if defined( HAVE_GLIB_H ) 140 | #define narrow_string_snprintf( target, size, ... ) \ 141 | g_snprintf( target, size, __VA_ARGS__ ) 142 | 143 | #elif defined( _MSC_VER ) 144 | #define narrow_string_snprintf( target, size, ... ) \ 145 | sprintf_s( target, size, __VA_ARGS__ ) 146 | 147 | #elif defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 148 | #define narrow_string_snprintf \ 149 | snprintf 150 | 151 | #elif defined( HAVE_SNPRINTF ) || defined( WINAPI ) 152 | #define narrow_string_snprintf( target, size, ... ) \ 153 | snprintf( target, size, __VA_ARGS__ ) 154 | #endif 155 | 156 | /* String input conversion (sscanf) 157 | */ 158 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 159 | #define narrow_string_sscanf \ 160 | sscanf 161 | 162 | #elif defined( HAVE_SSCANF ) || defined( WINAPI ) 163 | #define narrow_string_sscanf( string, format, ... ) \ 164 | sscanf( string, format, __VA_ARGS__ ) 165 | #endif 166 | 167 | /* Variable arguments formatted print to string function (vsnprintf) 168 | */ 169 | #if defined( HAVE_GLIB_H ) 170 | #define narrow_string_vsnprintf( string, size, format, ... ) \ 171 | g_vsnprintf( string, size, format, __VA_ARGS__ ) 172 | 173 | #elif defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 174 | #define narrow_string_vsnprintf \ 175 | vsnprintf 176 | 177 | #elif defined( HAVE_VSNPRINTF ) || defined( WINAPI ) 178 | #define narrow_string_vsnprintf( string, size, format, ... ) \ 179 | vsnprintf( string, size, format, __VA_ARGS__ ) 180 | #endif 181 | 182 | #if defined( __cplusplus ) 183 | } 184 | #endif 185 | 186 | #endif /* !defined( _NARROW_STRING_H ) */ 187 | 188 | -------------------------------------------------------------------------------- /common/system_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * System character string functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _SYSTEM_STRING_H ) 23 | #define _SYSTEM_STRING_H 24 | 25 | #include "common.h" 26 | #include "narrow_string.h" 27 | #include "types.h" 28 | #include "wide_string.h" 29 | 30 | #if defined( _cplusplus ) 31 | extern "C" { 32 | #endif 33 | 34 | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) 35 | 36 | #if SIZEOF_WCHAR_T != 2 37 | #error Unsupported wide system character size 38 | #endif 39 | 40 | /* Intermediate version of the macro required 41 | * for correct evaluation predefined string 42 | */ 43 | #define _SYSTEM_STRING_INTERMEDIATE( string ) \ 44 | L ## string 45 | 46 | #define _SYSTEM_STRING( string ) \ 47 | _SYSTEM_STRING_INTERMEDIATE( string ) 48 | 49 | #define system_string_allocate( size ) \ 50 | wide_string_allocate( size ) 51 | 52 | #define system_string_reallocate( string, size ) \ 53 | wide_string_reallocate( string, size ) 54 | 55 | #define system_string_compare( destination, source, size ) \ 56 | wide_string_compare( destination, source, size ) 57 | 58 | #define system_string_compare_no_case( destination, source, size ) \ 59 | wide_string_compare_no_case( destination, source, size ) 60 | 61 | #define system_string_copy( destination, source, size ) \ 62 | wide_string_copy( destination, source, size ) 63 | 64 | #define system_string_length( string ) \ 65 | wide_string_length( string ) 66 | 67 | #define system_string_search_character( string, character, size ) \ 68 | wide_string_search_character( string, character, size ) 69 | 70 | #define system_string_search_character_reverse( string, character, size ) \ 71 | wide_string_search_character_reverse( string, character, size ) 72 | 73 | #define system_string_search_string( string, substring, size ) \ 74 | wide_string_search_string( string, substring, size ) 75 | 76 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 77 | #define system_string_sprintf \ 78 | wide_string_snwprintf 79 | 80 | #else 81 | #define system_string_sprintf( string, size, format, ... ) \ 82 | wide_string_snwprintf( string, size, format, __VA_ARGS__ ) 83 | #endif 84 | 85 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 86 | #define system_string_vsnprintf \ 87 | wide_string_vsnwprintf 88 | 89 | #else 90 | #define system_string_vsnprintf( string, size, format, ... ) \ 91 | wide_string_vsnwprintf( string, size, format, __VA_ARGS__ ) 92 | #endif 93 | 94 | #else 95 | 96 | #define _SYSTEM_STRING( string ) \ 97 | string 98 | 99 | #define system_string_allocate( size ) \ 100 | narrow_string_allocate( size ) 101 | 102 | #define system_string_reallocate( string, size ) \ 103 | narrow_string_reallocate( string, size ) 104 | 105 | #define system_string_compare( destination, source, size ) \ 106 | narrow_string_compare( destination, source, size ) 107 | 108 | #define system_string_compare_no_case( destination, source, size ) \ 109 | narrow_string_compare_no_case( destination, source, size ) 110 | 111 | #define system_string_copy( destination, source, size ) \ 112 | narrow_string_copy( destination, source, size ) 113 | 114 | #define system_string_length( string ) \ 115 | narrow_string_length( string ) 116 | 117 | #define system_string_search_character( string, character, size ) \ 118 | narrow_string_search_character( string, character, size ) 119 | 120 | #define system_string_search_character_reverse( string, character, size ) \ 121 | narrow_string_search_character_reverse( string, character, size ) 122 | 123 | #define system_string_search_string( string, substring, size ) \ 124 | narrow_string_search_string( string, substring, size ) 125 | 126 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 127 | #define system_string_sprintf \ 128 | narrow_string_snprintf 129 | 130 | #else 131 | #define system_string_sprintf( string, size, format, ... ) \ 132 | narrow_string_snprintf( string, size, format, __VA_ARGS__ ) 133 | #endif 134 | 135 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 136 | #define system_string_vsnprintf \ 137 | narrow_string_vsnprintf 138 | 139 | #else 140 | #define system_string_vsnprintf( string, size, format, ... ) \ 141 | narrow_string_vsnprintf( string, size, format, __VA_ARGS__ ) 142 | #endif 143 | 144 | #endif /* defined( HAVE_WIDE_SYSTEM_CHARACTER ) */ 145 | 146 | /* For backwards compatibility */ 147 | #define system_string_vsprintf system_string_vsnprintf 148 | 149 | #if defined( _cplusplus ) 150 | } 151 | #endif 152 | 153 | #endif /* !defined( _SYSTEM_STRING_H ) */ 154 | 155 | -------------------------------------------------------------------------------- /common/wide_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Wide character string functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _WIDE_STRING_H ) 23 | #define _WIDE_STRING_H 24 | 25 | #include "common.h" 26 | #include "memory.h" 27 | #include "types.h" 28 | 29 | #if defined( HAVE_WCHAR_H ) || defined( WINAPI ) 30 | #include 31 | #endif 32 | 33 | #if defined( __cplusplus ) 34 | extern "C" { 35 | #endif 36 | 37 | /* Intermediate version of the macro required 38 | * for correct evaluation predefined string 39 | */ 40 | #define _WIDE_STRING_INTERMEDIATE( string ) \ 41 | L ## string 42 | 43 | #define _WIDE_STRING( string ) \ 44 | _WIDE_STRING_INTERMEDIATE( string ) 45 | 46 | /* String allocation 47 | */ 48 | #define wide_string_allocate( size ) \ 49 | (wchar_t *) memory_allocate( sizeof( wchar_t ) * ( size ) ) 50 | 51 | /* String reallocation 52 | */ 53 | #define wide_string_reallocate( string, size ) \ 54 | (wchar_t *) memory_reallocate( string, ( sizeof( wchar_t ) * ( size ) ) ) 55 | 56 | /* String length 57 | */ 58 | #if defined( HAVE_WCSLEN ) || defined( WINAPI ) 59 | #define wide_string_length( string ) \ 60 | wcslen( string ) 61 | #endif 62 | 63 | /* String compare 64 | */ 65 | #if defined( HAVE_WMEMCMP ) 66 | #define wide_string_compare( string1, string2, size ) \ 67 | wmemcmp( (void *) string1, (void *) string2, size ) 68 | 69 | #elif defined( HAVE_WCSNCMP ) || defined( WINAPI ) 70 | #define wide_string_compare( string1, string2, size ) \ 71 | wcsncmp( string1, string2, size ) 72 | #endif 73 | 74 | /* Caseless string compare 75 | */ 76 | #if defined( _MSC_VER ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ >= 0x0551 ) ) 77 | #define wide_string_compare_no_case( string1, string2, size ) \ 78 | _wcsnicmp( string1, string2, size ) 79 | 80 | #elif ( defined( WINAPI ) && !defined( __CYGWIN__ ) ) || defined( HAVE_WCSNICMP ) 81 | #define wide_string_compare_no_case( string1, string2, size ) \ 82 | wcsnicmp( string1, string2, size ) 83 | 84 | #elif defined( HAVE_WCSNCASECMP ) 85 | #define wide_string_compare_no_case( string1, string2, size ) \ 86 | wcsncasecmp( string1, string2, size ) 87 | 88 | #elif defined( HAVE_WCSCASECMP ) 89 | #define wide_string_compare_no_case( string1, string2, size ) \ 90 | wcscasecmp( string1, string2 ) 91 | #endif 92 | 93 | /* String copy 94 | */ 95 | #if defined( HAVE_WMEMCPY ) 96 | #define wide_string_copy( destination, source, size ) \ 97 | (wchar_t *) wmemcpy( (void *) destination, (void *) source, size ) 98 | 99 | #elif defined( HAVE_WCSNCPY ) || defined( WINAPI ) 100 | #define wide_string_copy( destination, source, size ) \ 101 | wcsncpy( destination, source, size ) 102 | #endif 103 | 104 | /* String character search 105 | */ 106 | #if defined( HAVE_WMEMCHR ) 107 | #define wide_string_search_character( string, character, size ) \ 108 | (wchar_t *) wmemchr( (void *) string, (wchar_t) character, size ) 109 | 110 | #elif defined( HAVE_WCSCHR ) || defined( WINAPI ) 111 | #define wide_string_search_character( string, character, size ) \ 112 | wcschr( string, (wchar_t) character ) 113 | 114 | #endif 115 | 116 | /* String reverse character search 117 | */ 118 | #if defined( HAVE_WMEMRCHR ) 119 | #define wide_string_search_character_reverse( string, character, size ) \ 120 | (wchar_t *) wmemrchr( (void *) string, (wchar_t) character, size ) 121 | 122 | #elif defined( HAVE_WCSRCHR ) || defined( WINAPI ) 123 | /* (void)(size) is used to suppress unused variable warnings */ 124 | #define wide_string_search_character_reverse( string, character, size ) \ 125 | wcsrchr( string, (wchar_t) character ); (void)(size) 126 | #endif 127 | 128 | /* String sub-string search 129 | */ 130 | #if defined( HAVE_WCSSTR ) || defined( WINAPI ) 131 | #define wide_string_search_string( string, substring, size ) \ 132 | wcsstr( string, substring ) 133 | 134 | #endif 135 | 136 | /* String formatted print (snwprintf) 137 | */ 138 | #if defined( _MSC_VER ) 139 | #define wide_string_snwprintf( target, size, ... ) \ 140 | swprintf_s( target, size, __VA_ARGS__ ) 141 | 142 | #elif defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 143 | #define wide_string_snwprintf \ 144 | snwprintf 145 | 146 | #elif defined( WINAPI ) 147 | #define wide_string_snwprintf( target, size, ... ) \ 148 | snwprintf( target, size, __VA_ARGS__ ) 149 | 150 | #elif defined( HAVE_SWPRINTF ) 151 | #define wide_string_snwprintf( target, size, ... ) \ 152 | swprintf( target, size, __VA_ARGS__ ) 153 | #endif 154 | 155 | /* Variable arguments formatted print to string function (vsnwprintf) 156 | */ 157 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 158 | #define wide_string_vsnwprintf \ 159 | _vsnwprintf 160 | 161 | #elif defined( WINAPI ) 162 | #define wide_string_vsnwprintf( string, size, format, ... ) \ 163 | _vsnwprintf( string, size, format, __VA_ARGS__ ) 164 | 165 | #elif defined( HAVE_VSWPRINTF ) 166 | #define wide_string_vsnwprintf( string, size, format, ... ) \ 167 | vswprintf( string, size, format, __VA_ARGS__ ) 168 | #endif 169 | 170 | #if defined( __cplusplus ) 171 | } 172 | #endif 173 | 174 | #endif /* !defined( _WIDE_STRING_H ) */ 175 | 176 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.71]) 2 | 3 | AC_INIT( 4 | [libfole], 5 | [20240521], 6 | [joachim.metz@gmail.com]) 7 | 8 | AC_CONFIG_SRCDIR( 9 | [include/libfole.h.in]) 10 | 11 | AM_INIT_AUTOMAKE([gnu 1.6 tar-ustar]) 12 | AM_EXTRA_RECURSIVE_TARGETS([sources splint]) 13 | 14 | AC_CONFIG_MACRO_DIR([m4]) 15 | 16 | dnl Check for host type 17 | AC_CANONICAL_HOST 18 | 19 | dnl Check for libtool DLL support 20 | LT_INIT([win32-dll]) 21 | 22 | dnl Checks for programs 23 | AC_PROG_CC 24 | AC_PROG_GCC_TRADITIONAL 25 | AC_PROG_MAKE_SET 26 | AC_PROG_INSTALL 27 | 28 | dnl Check for libtool 29 | AC_SUBST(LIBTOOL_DEPS) 30 | 31 | dnl Check for pkg-config 32 | AC_PATH_PROG(PKGCONFIG,[pkg-config]) 33 | 34 | dnl Support of internationalization (i18n) 35 | AM_GNU_GETTEXT([external]) 36 | AM_GNU_GETTEXT_VERSION([0.21]) 37 | 38 | dnl Check for compiler language support 39 | AC_C_CONST 40 | AC_C_VOLATILE 41 | 42 | dnl Check for large file support 43 | AC_SYS_LARGEFILE 44 | 45 | dnl Check if shared library support should be disabled 46 | AX_COMMON_CHECK_DISABLE_SHARED_LIBS 47 | 48 | dnl Check if WINAPI support should be enabled 49 | AX_COMMON_CHECK_ENABLE_WINAPI 50 | 51 | dnl Check if verbose output should be enabled 52 | AX_COMMON_CHECK_ENABLE_VERBOSE_OUTPUT 53 | 54 | dnl Check if debug output should be enabled 55 | AX_COMMON_CHECK_ENABLE_DEBUG_OUTPUT 56 | 57 | dnl Check for type definitions 58 | AX_TYPES_CHECK_LOCAL 59 | 60 | dnl Check if common required headers and functions are available 61 | AX_COMMON_CHECK_LOCAL 62 | 63 | dnl Check if libcerror or required headers and functions are available 64 | AX_LIBCERROR_CHECK_ENABLE 65 | 66 | dnl Check if libfole required headers and functions are available 67 | AX_LIBFOLE_CHECK_LOCAL 68 | 69 | dnl Check if DLL support is needed 70 | AX_LIBFOLE_CHECK_DLL_SUPPORT 71 | 72 | dnl Check if tests required headers and functions are available 73 | AX_TESTS_CHECK_LOCAL 74 | 75 | dnl Set additional compiler flags 76 | CFLAGS="$CFLAGS -Wall"; 77 | 78 | dnl Check if requires and build requires should be set in spec file 79 | AS_IF( 80 | [test "x$ac_cv_libcerror" = xyes], 81 | [AC_SUBST( 82 | [libfole_spec_requires], 83 | [Requires:]) 84 | ]) 85 | 86 | dnl Set the date for the dpkg files 87 | AC_SUBST( 88 | [DPKG_DATE], 89 | [`date -R 2> /dev/null`]) 90 | 91 | dnl Set the date for the spec file 92 | AC_SUBST( 93 | [SPEC_DATE], 94 | [`date +"%a %b %e %Y" 2> /dev/null`]) 95 | 96 | dnl Generate Makefiles 97 | AC_CONFIG_FILES([Makefile]) 98 | AC_CONFIG_FILES([include/Makefile]) 99 | AC_CONFIG_FILES([common/Makefile]) 100 | AC_CONFIG_FILES([libcerror/Makefile]) 101 | AC_CONFIG_FILES([libfole/Makefile]) 102 | AC_CONFIG_FILES([po/Makefile.in]) 103 | AC_CONFIG_FILES([po/Makevars]) 104 | AC_CONFIG_FILES([manuals/Makefile]) 105 | AC_CONFIG_FILES([tests/Makefile]) 106 | AC_CONFIG_FILES([msvscpp/Makefile]) 107 | dnl Generate header files 108 | AC_CONFIG_FILES([include/libfole.h]) 109 | AC_CONFIG_FILES([include/libfole/definitions.h]) 110 | AC_CONFIG_FILES([include/libfole/features.h]) 111 | AC_CONFIG_FILES([include/libfole/types.h]) 112 | AC_CONFIG_FILES([libfole/libfole_definitions.h]) 113 | dnl Generate distribution specific files 114 | AC_CONFIG_FILES([common/types.h]) 115 | AC_CONFIG_FILES([dpkg/changelog]) 116 | AC_CONFIG_FILES([libfole/libfole.rc]) 117 | AC_CONFIG_FILES([libfole.pc]) 118 | AC_CONFIG_FILES([libfole.spec]) 119 | dnl Generate a source configuration file 120 | AC_CONFIG_HEADERS([common/config.h]) 121 | 122 | AC_OUTPUT 123 | 124 | dnl Print a summary 125 | AC_MSG_NOTICE([ 126 | Building: 127 | libcerror support: $ac_cv_libcerror 128 | 129 | Features: 130 | Verbose output: $ac_cv_enable_verbose_output 131 | Debug output: $ac_cv_enable_debug_output 132 | ]); 133 | 134 | -------------------------------------------------------------------------------- /dpkg/changelog.in: -------------------------------------------------------------------------------- 1 | libfole (@VERSION@-1) unstable; urgency=low 2 | 3 | * Auto-generated 4 | 5 | -- Joachim Metz @DPKG_DATE@ 6 | -------------------------------------------------------------------------------- /dpkg/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /dpkg/control: -------------------------------------------------------------------------------- 1 | Source: libfole 2 | Priority: extra 3 | Maintainer: Joachim Metz 4 | Build-Depends: debhelper (>= 9), dh-autoreconf, pkg-config 5 | Standards-Version: 4.1.4 6 | Section: libs 7 | Homepage: https://github.com/libyal/libfole 8 | Vcs-Git: https://github.com/libyal/libfole.git 9 | 10 | Package: libfole 11 | Architecture: any 12 | Depends: ${shlibs:Depends}, ${misc:Depends} 13 | Conflicts: libfole1 14 | Replaces: libfole1 15 | Suggests: libfole-dbg 16 | Description: Library to support the Object Linking and Embedding (OLE) data types 17 | libfole is a library to support the Object Linking and Embedding (OLE) data types. 18 | 19 | Package: libfole-dbg 20 | Architecture: any 21 | Section: debug 22 | Depends: libfole (= ${binary:Version}), ${misc:Depends} 23 | Description: Debugging symbols for libfole 24 | Debugging symbols for libfole. 25 | 26 | Package: libfole-dev 27 | Section: libdevel 28 | Architecture: any 29 | Depends: libfole (= ${binary:Version}), ${misc:Depends} 30 | Description: Header files and libraries for developing applications for libfole 31 | Header files and libraries for developing applications for libfole. 32 | 33 | -------------------------------------------------------------------------------- /dpkg/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: libfole 3 | Source: https://github.com/libyal/libfole 4 | 5 | Files: * 6 | Copyright: 2008-2024, Joachim Metz 7 | License: LGPL-3.0+ 8 | 9 | License: LGPL-3.0+ 10 | This package is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 3 of the License, or (at your option) any later version. 14 | . 15 | This package is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | . 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | . 23 | On Debian systems, the complete text of the GNU Lesser General 24 | Public License can be found in "/usr/share/common-licenses/LGPL-3". 25 | 26 | -------------------------------------------------------------------------------- /dpkg/libfole-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/*-*/lib*.a 3 | usr/lib/*-*/lib*.so 4 | usr/lib/*-*/pkgconfig/* 5 | usr/share/man/man3 6 | -------------------------------------------------------------------------------- /dpkg/libfole.install: -------------------------------------------------------------------------------- 1 | usr/lib/*-*/lib*.so.* 2 | -------------------------------------------------------------------------------- /dpkg/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment for debhelper verbose output. 5 | # export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ --buildsystem=autoconf --with=autoreconf 9 | 10 | .PHONY: override_dh_auto_configure 11 | override_dh_auto_configure: 12 | dh_auto_configure -- CFLAGS="-g" 13 | 14 | .PHONY: override_dh_install 15 | override_dh_install: 16 | dh_install --fail-missing -X.la 17 | 18 | .PHONY: override_dh_strip 19 | override_dh_strip: 20 | ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS))) 21 | dh_strip -plibfole --dbg-package=libfole-dbg 22 | endif 23 | 24 | -------------------------------------------------------------------------------- /dpkg/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | include_HEADERS = \ 2 | libfole.h 3 | 4 | pkginclude_HEADERS = \ 5 | libfole/definitions.h \ 6 | libfole/error.h \ 7 | libfole/extern.h \ 8 | libfole/features.h \ 9 | libfole/types.h 10 | 11 | EXTRA_DIST = \ 12 | libfole.h.in \ 13 | libfole/definitions.h.in \ 14 | libfole/features.h.in \ 15 | libfole/types.h.in 16 | 17 | DISTCLEANFILES = \ 18 | libfole.h \ 19 | libfole/definitions.h \ 20 | libfole/features.h \ 21 | libfole/types.h \ 22 | Makefile \ 23 | Makefile.in 24 | 25 | -------------------------------------------------------------------------------- /include/libfole.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Library to support the Object Linking and Embedding (OLE) data types 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_H ) 23 | #define _LIBFOLE_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #if defined( __cplusplus ) 34 | extern "C" { 35 | #endif 36 | 37 | /* ------------------------------------------------------------------------- 38 | * Support functions 39 | * ------------------------------------------------------------------------- */ 40 | 41 | /* Returns the library version 42 | */ 43 | LIBFOLE_EXTERN \ 44 | const char *libfole_get_version( 45 | void ); 46 | 47 | /* ------------------------------------------------------------------------- 48 | * Error functions 49 | * ------------------------------------------------------------------------- */ 50 | 51 | /* Frees an error 52 | */ 53 | LIBFOLE_EXTERN \ 54 | void libfole_error_free( 55 | libfole_error_t **error ); 56 | 57 | /* Prints a descriptive string of the error to the stream 58 | * Returns the amount of printed characters if successful or -1 on error 59 | */ 60 | LIBFOLE_EXTERN \ 61 | int libfole_error_fprint( 62 | libfole_error_t *error, 63 | FILE *stream ); 64 | 65 | /* Prints a descriptive string of the error to the string 66 | * The end-of-string character is not included in the return value 67 | * Returns the amount of printed characters if successful or -1 on error 68 | */ 69 | LIBFOLE_EXTERN \ 70 | int libfole_error_sprint( 71 | libfole_error_t *error, 72 | char *string, 73 | size_t size ); 74 | 75 | /* Prints a backtrace of the error to the stream 76 | * Returns the amount of printed characters if successful or -1 on error 77 | */ 78 | LIBFOLE_EXTERN \ 79 | int libfole_error_backtrace_fprint( 80 | libfole_error_t *error, 81 | FILE *stream ); 82 | 83 | /* Prints a backtrace of the error to the string 84 | * The end-of-string character is not included in the return value 85 | * Returns the amount of printed characters if successful or -1 on error 86 | */ 87 | LIBFOLE_EXTERN \ 88 | int libfole_error_backtrace_sprint( 89 | libfole_error_t *error, 90 | char *string, 91 | size_t size ); 92 | 93 | /* ------------------------------------------------------------------------- 94 | * Value type functions 95 | * ------------------------------------------------------------------------- */ 96 | 97 | /* Retrieves a string containing the value type identifier 98 | */ 99 | LIBFOLE_EXTERN \ 100 | const char *libfole_value_type_get_identifier( 101 | uint32_t value_type ); 102 | 103 | /* Retrieves a string containing the value type description 104 | */ 105 | LIBFOLE_EXTERN \ 106 | const char *libfole_value_type_get_description( 107 | uint32_t value_type ); 108 | 109 | #if defined( __cplusplus ) 110 | } 111 | #endif 112 | 113 | #endif /* !defined( _LIBFOLE_H ) */ 114 | 115 | -------------------------------------------------------------------------------- /include/libfole/definitions.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions for libfole 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_DEFINITIONS_H ) 23 | #define _LIBFOLE_DEFINITIONS_H 24 | 25 | #include 26 | 27 | #define LIBFOLE_VERSION @VERSION@ 28 | 29 | /* The version string 30 | */ 31 | #define LIBFOLE_VERSION_STRING "@VERSION@" 32 | 33 | /* The byte order definitions 34 | */ 35 | enum LIBFOLE_ENDIAN 36 | { 37 | LIBFOLE_ENDIAN_BIG = (int) 'b', 38 | LIBFOLE_ENDIAN_LITTLE = (int) 'l' 39 | }; 40 | 41 | #endif /* !defined( _LIBFOLE_DEFINITIONS_H ) */ 42 | 43 | -------------------------------------------------------------------------------- /include/libfole/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The error code definitions for libfole 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_ERROR_H ) 23 | #define _LIBFOLE_ERROR_H 24 | 25 | #include 26 | 27 | /* External error type definition hides internal structure 28 | */ 29 | typedef intptr_t libfole_error_t; 30 | 31 | /* The error domains 32 | */ 33 | enum LIBFOLE_ERROR_DOMAINS 34 | { 35 | LIBFOLE_ERROR_DOMAIN_ARGUMENTS = (int) 'a', 36 | LIBFOLE_ERROR_DOMAIN_CONVERSION = (int) 'c', 37 | LIBFOLE_ERROR_DOMAIN_COMPRESSION = (int) 'C', 38 | LIBFOLE_ERROR_DOMAIN_IO = (int) 'I', 39 | LIBFOLE_ERROR_DOMAIN_INPUT = (int) 'i', 40 | LIBFOLE_ERROR_DOMAIN_MEMORY = (int) 'm', 41 | LIBFOLE_ERROR_DOMAIN_OUTPUT = (int) 'o', 42 | LIBFOLE_ERROR_DOMAIN_RUNTIME = (int) 'r' 43 | }; 44 | 45 | /* The argument error codes 46 | * to signify errors regarding arguments passed to a function 47 | */ 48 | enum LIBFOLE_ARGUMENT_ERROR 49 | { 50 | LIBFOLE_ARGUMENT_ERROR_GENERIC = 0, 51 | 52 | /* The argument contains an invalid value 53 | */ 54 | LIBFOLE_ARGUMENT_ERROR_INVALID_VALUE = 1, 55 | 56 | /* The argument contains a value less than zero 57 | */ 58 | LIBFOLE_ARGUMENT_ERROR_VALUE_LESS_THAN_ZERO = 2, 59 | 60 | /* The argument contains a value zero or less 61 | */ 62 | LIBFOLE_ARGUMENT_ERROR_VALUE_ZERO_OR_LESS = 3, 63 | 64 | /* The argument contains a value that exceeds the maximum 65 | * for the specific type 66 | */ 67 | LIBFOLE_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM = 4, 68 | 69 | /* The argument contains a value that is too small 70 | */ 71 | LIBFOLE_ARGUMENT_ERROR_VALUE_TOO_SMALL = 5, 72 | 73 | /* The argument contains a value that is too large 74 | */ 75 | LIBFOLE_ARGUMENT_ERROR_VALUE_TOO_LARGE = 6, 76 | 77 | /* The argument contains a value that is out of bounds 78 | */ 79 | LIBFOLE_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS = 7, 80 | 81 | /* The argument contains a value that is not supported 82 | */ 83 | LIBFOLE_ARGUMENT_ERROR_UNSUPPORTED_VALUE = 8, 84 | 85 | /* The argument contains a value that conficts with another argument 86 | */ 87 | LIBFOLE_ARGUMENT_ERROR_CONFLICTING_VALUE = 9 88 | }; 89 | 90 | /* The conversion error codes 91 | * to signify errors regarding conversions 92 | */ 93 | enum LIBFOLE_CONVERSION_ERROR 94 | { 95 | LIBFOLE_CONVERSION_ERROR_GENERIC = 0, 96 | 97 | /* The conversion failed on the input 98 | */ 99 | LIBFOLE_CONVERSION_ERROR_INPUT_FAILED = 1, 100 | 101 | /* The conversion failed on the output 102 | */ 103 | LIBFOLE_CONVERSION_ERROR_OUTPUT_FAILED = 2 104 | }; 105 | 106 | /* The compression error codes 107 | * to signify errors regarding compression 108 | */ 109 | enum LIBFOLE_COMPRESSION_ERROR 110 | { 111 | LIBFOLE_COMPRESSION_ERROR_GENERIC = 0, 112 | 113 | /* The compression failed 114 | */ 115 | LIBFOLE_COMPRESSION_ERROR_COMPRESS_FAILED = 1, 116 | 117 | /* The decompression failed 118 | */ 119 | LIBFOLE_COMPRESSION_ERROR_DECOMPRESS_FAILED = 2 120 | }; 121 | 122 | /* The input/output error codes 123 | * to signify errors regarding input/output 124 | */ 125 | enum LIBFOLE_IO_ERROR 126 | { 127 | LIBFOLE_IO_ERROR_GENERIC = 0, 128 | 129 | /* The open failed 130 | */ 131 | LIBFOLE_IO_ERROR_OPEN_FAILED = 1, 132 | 133 | /* The close failed 134 | */ 135 | LIBFOLE_IO_ERROR_CLOSE_FAILED = 2, 136 | 137 | /* The seek failed 138 | */ 139 | LIBFOLE_IO_ERROR_SEEK_FAILED = 3, 140 | 141 | /* The read failed 142 | */ 143 | LIBFOLE_IO_ERROR_READ_FAILED = 4, 144 | 145 | /* The write failed 146 | */ 147 | LIBFOLE_IO_ERROR_WRITE_FAILED = 5, 148 | 149 | /* Access denied 150 | */ 151 | LIBFOLE_IO_ERROR_ACCESS_DENIED = 6, 152 | 153 | /* The resource is invalid i.e. a missing file 154 | */ 155 | LIBFOLE_IO_ERROR_INVALID_RESOURCE = 7, 156 | 157 | /* The ioctl failed 158 | */ 159 | LIBFOLE_IO_ERROR_IOCTL_FAILED = 8, 160 | 161 | /* The unlink failed 162 | */ 163 | LIBFOLE_IO_ERROR_UNLINK_FAILED = 9 164 | }; 165 | 166 | /* The input error codes 167 | * to signify errors regarding handing input data 168 | */ 169 | enum LIBFOLE_INPUT_ERROR 170 | { 171 | LIBFOLE_INPUT_ERROR_GENERIC = 0, 172 | 173 | /* The input contains invalid data 174 | */ 175 | LIBFOLE_INPUT_ERROR_INVALID_DATA = 1, 176 | 177 | /* The input contains an unsupported signature 178 | */ 179 | LIBFOLE_INPUT_ERROR_SIGNATURE_MISMATCH = 2, 180 | 181 | /* A checksum in the input did not match 182 | */ 183 | LIBFOLE_INPUT_ERROR_CHECKSUM_MISMATCH = 3, 184 | 185 | /* A value in the input did not match a previously 186 | * read value or calculated value 187 | */ 188 | LIBFOLE_INPUT_ERROR_VALUE_MISMATCH = 4 189 | }; 190 | 191 | /* The memory error codes 192 | * to signify errors regarding memory 193 | */ 194 | enum LIBFOLE_MEMORY_ERROR 195 | { 196 | LIBFOLE_MEMORY_ERROR_GENERIC = 0, 197 | 198 | /* There is insufficient memory available 199 | */ 200 | LIBFOLE_MEMORY_ERROR_INSUFFICIENT = 1, 201 | 202 | /* The memory failed to be copied 203 | */ 204 | LIBFOLE_MEMORY_ERROR_COPY_FAILED = 2, 205 | 206 | /* The memory failed to be set 207 | */ 208 | LIBFOLE_MEMORY_ERROR_SET_FAILED = 3 209 | }; 210 | 211 | /* The output error codes 212 | */ 213 | enum LIBFOLE_OUTPUT_ERROR 214 | { 215 | LIBFOLE_OUTPUT_ERROR_GENERIC = 0, 216 | 217 | /* There is insuficient space to write the output 218 | */ 219 | LIBFOLE_OUTPUT_ERROR_INSUFFICIENT_SPACE = 1 220 | }; 221 | 222 | /* The runtime error codes 223 | * to signify errors regarding runtime processing 224 | */ 225 | enum LIBFOLE_RUNTIME_ERROR 226 | { 227 | LIBFOLE_RUNTIME_ERROR_GENERIC = 0, 228 | 229 | /* The value is missing 230 | */ 231 | LIBFOLE_RUNTIME_ERROR_VALUE_MISSING = 1, 232 | 233 | /* The value was already set 234 | */ 235 | LIBFOLE_RUNTIME_ERROR_VALUE_ALREADY_SET = 2, 236 | 237 | /* The creation and/or initialization of an internal structure failed 238 | */ 239 | LIBFOLE_RUNTIME_ERROR_INITIALIZE_FAILED = 3, 240 | 241 | /* The resize of an internal structure failed 242 | */ 243 | LIBFOLE_RUNTIME_ERROR_RESIZE_FAILED = 4, 244 | 245 | /* The free and/or finalization of an internal structure failed 246 | */ 247 | LIBFOLE_RUNTIME_ERROR_FINALIZE_FAILED = 5, 248 | 249 | /* The value could not be determined 250 | */ 251 | LIBFOLE_RUNTIME_ERROR_GET_FAILED = 6, 252 | 253 | /* The value could not be set 254 | */ 255 | LIBFOLE_RUNTIME_ERROR_SET_FAILED = 7, 256 | 257 | /* The value could not be appended/prepended 258 | */ 259 | LIBFOLE_RUNTIME_ERROR_APPEND_FAILED = 8, 260 | 261 | /* The value could not be copied 262 | */ 263 | LIBFOLE_RUNTIME_ERROR_COPY_FAILED = 9, 264 | 265 | /* The value could not be removed 266 | */ 267 | LIBFOLE_RUNTIME_ERROR_REMOVE_FAILED = 10, 268 | 269 | /* The value could not be printed 270 | */ 271 | LIBFOLE_RUNTIME_ERROR_PRINT_FAILED = 11, 272 | 273 | /* The value was out of bounds 274 | */ 275 | LIBFOLE_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS = 12, 276 | 277 | /* The value exceeds the maximum for its specific type 278 | */ 279 | LIBFOLE_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM = 13, 280 | 281 | /* The value is unsupported 282 | */ 283 | LIBFOLE_RUNTIME_ERROR_UNSUPPORTED_VALUE = 14, 284 | 285 | /* An abort was requested 286 | */ 287 | LIBFOLE_RUNTIME_ERROR_ABORT_REQUESTED = 15 288 | }; 289 | 290 | #endif /* !defined( _LIBFOLE_ERROR_H ) */ 291 | 292 | -------------------------------------------------------------------------------- /include/libfole/extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The extern definition 3 | * 4 | * This header should be included in header files that export or import 5 | * library functions 6 | * 7 | * Copyright (C) 2008-2024, Joachim Metz 8 | * 9 | * Refer to AUTHORS for acknowledgements. 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Lesser General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #if !defined( _LIBFOLE_EXTERN_H ) 26 | #define _LIBFOLE_EXTERN_H 27 | 28 | /* To export functions from the libfole DLL define LIBFOLE_DLL_EXPORT 29 | * To import functions from the libfole DLL define LIBFOLE_DLL_IMPORT 30 | * Otherwise use default extern statement 31 | */ 32 | #if defined( LIBFOLE_DLL_EXPORT ) 33 | #define LIBFOLE_EXTERN __declspec(dllexport) 34 | 35 | #elif defined( LIBFOLE_DLL_IMPORT ) 36 | #define LIBFOLE_EXTERN extern __declspec(dllimport) 37 | 38 | #else 39 | #define LIBFOLE_EXTERN extern 40 | 41 | #endif 42 | 43 | #endif /* !defined( _LIBFOLE_EXTERN_H ) */ 44 | 45 | -------------------------------------------------------------------------------- /include/libfole/features.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Features of libfole 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_FEATURES_H ) 23 | #define _LIBFOLE_FEATURES_H 24 | 25 | /* The libfole type support features 26 | */ 27 | #if !defined( LIBFOLE_DEPRECATED ) 28 | #if defined( __GNUC__ ) && __GNUC__ >= 3 29 | #define LIBFOLE_DEPRECATED __attribute__ ((__deprecated__)) 30 | #elif defined( _MSC_VER ) 31 | #define LIBFOLE_DEPRECATED __declspec(deprecated) 32 | #else 33 | #define LIBFOLE_DEPRECATED 34 | #endif 35 | #endif 36 | 37 | #endif /* !defined( _LIBFOLE_FEATURES_H ) */ 38 | 39 | -------------------------------------------------------------------------------- /include/libfole/types.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Type definitions for libfole 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_TYPES_H ) 23 | #define _LIBFOLE_TYPES_H 24 | 25 | #include 26 | 27 | /* Integer type definitions 28 | */ 29 | #if ( defined( _MSC_VER ) && ( _MSC_VER < 1600 ) ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) ) 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* Microsoft Visual Studio C++ before Visual Studio 2010 or earlier versions of the Borland C++ Builder 36 | * do not support the (u)int#_t type definitions but have __int# definitions instead 37 | */ 38 | #if !defined( HAVE_INT8_T ) 39 | #define HAVE_INT8_T 40 | typedef __int8 int8_t; 41 | #endif 42 | 43 | #if !defined( HAVE_UINT8_T ) 44 | #define HAVE_UINT8_T 45 | typedef unsigned __int8 uint8_t; 46 | #endif 47 | 48 | #if !defined( HAVE_INT16_T ) 49 | #define HAVE_INT16_T 50 | typedef __int16 int16_t; 51 | #endif 52 | 53 | #if !defined( HAVE_UINT16_T ) 54 | #define HAVE_UINT16_T 55 | typedef unsigned __int16 uint16_t; 56 | #endif 57 | 58 | #if !defined( HAVE_INT32_T ) 59 | #define HAVE_INT32_T 60 | typedef __int32 int32_t; 61 | #endif 62 | 63 | #if !defined( HAVE_UINT32_T ) 64 | #define HAVE_UINT32_T 65 | typedef unsigned __int32 uint32_t; 66 | #endif 67 | 68 | #if !defined( HAVE_INT64_T ) 69 | #define HAVE_INT64_T 70 | typedef __int64 int64_t; 71 | #endif 72 | 73 | #if !defined( HAVE_UINT64_T ) 74 | #define HAVE_UINT64_T 75 | typedef unsigned __int64 uint64_t; 76 | #endif 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #elif defined( _MSC_VER ) || defined( __BORLANDC__ ) 83 | 84 | /* Later versions of Microsoft Visual Studio C++ and Borland C/C++ define the types in 85 | */ 86 | #include 87 | 88 | #else 89 | 90 | #if @HAVE_SYS_TYPES_H@ || defined( HAVE_SYS_TYPES_H ) 91 | #include 92 | 93 | #else 94 | #error Missing system type definitions (sys/types.h) 95 | #endif 96 | 97 | /* Type definitions for compilers that have access to 98 | * or 99 | */ 100 | #if @HAVE_INTTYPES_H@ || defined( HAVE_INTTYPES_H ) 101 | #include 102 | 103 | #elif @HAVE_STDINT_H@ || defined( HAVE_STDINT_H ) 104 | #include 105 | 106 | #else 107 | #error Missing integer type definitions (inttypes.h, stdint.h) 108 | #endif 109 | 110 | #endif 111 | 112 | #ifdef __cplusplus 113 | extern "C" { 114 | #endif 115 | 116 | #if defined( _MSC_VER ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) ) 117 | 118 | /* Microsoft Visual Studio C++ or earlier versions of the Borland C++ Builder 119 | * do not support the ssize_t type definition 120 | */ 121 | #if !defined( HAVE_SSIZE_T ) 122 | #define HAVE_SSIZE_T 123 | 124 | #if defined( _WIN64 ) 125 | typedef __int64 ssize_t; 126 | #else 127 | typedef __int32 ssize_t; 128 | #endif 129 | 130 | #endif /* !defined( HAVE_SSIZE_T ) */ 131 | 132 | #endif /* defined( _MSC_VER ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) ) */ 133 | 134 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) 135 | 136 | /* Earlier versions of Borland C++ Builder do not support the intptr_t type definition 137 | */ 138 | #if !defined( HAVE_INTPTR_T ) 139 | #define HAVE_INTPTR_T 140 | 141 | #if defined( _WIN64 ) 142 | typedef __int64 intptr_t; 143 | #else 144 | typedef __int32 intptr_t; 145 | #endif 146 | 147 | #endif /* !defined( HAVE_INTPTR_T ) */ 148 | 149 | #endif /* defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) */ 150 | 151 | #if ( !defined( HAVE_SIZE32_T ) && ! @HAVE_SIZE32_T@ ) || HAVE_SIZE32_T == 0 152 | #define HAVE_SIZE32_T 1 153 | typedef uint32_t size32_t; 154 | #endif 155 | 156 | #if ( !defined( HAVE_SSIZE32_T ) && ! @HAVE_SSIZE32_T@ ) || HAVE_SSIZE32_T == 0 157 | #define HAVE_SSIZE32_T 1 158 | typedef int32_t ssize32_t; 159 | #endif 160 | 161 | #if ( !defined( HAVE_SIZE64_T ) && ! @HAVE_SIZE64_T@ ) || HAVE_SIZE64_T == 0 162 | #define HAVE_SIZE64_T 1 163 | typedef uint64_t size64_t; 164 | #endif 165 | 166 | #if ( !defined( HAVE_SSIZE64_T ) && ! @HAVE_SSIZE64_T@ ) || HAVE_SSIZE64_T == 0 167 | #define HAVE_SSIZE64_T 1 168 | typedef int64_t ssize64_t; 169 | #endif 170 | 171 | #if ( !defined( HAVE_OFF64_T ) && ! @HAVE_OFF64_T@ ) || HAVE_OFF64_T == 0 172 | #define HAVE_OFF64_T 1 173 | typedef int64_t off64_t; 174 | #endif 175 | 176 | /* Wide character definition 177 | */ 178 | #if defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0520 ) 179 | #include 180 | 181 | #elif defined( WINAPI ) 182 | #include 183 | 184 | #elif @HAVE_WCHAR_H@ || defined( HAVE_WCHAR_H ) 185 | 186 | /* __USE_UNIX98 is required to add swprintf definition 187 | */ 188 | #if !defined( __USE_UNIX98 ) 189 | #define __USE_UNIX98 190 | #define LIBFOLE_DEFINITION_UNIX98 191 | #endif 192 | 193 | #include 194 | 195 | #if defined( LIBFOLE_DEFINITION_UNIX98 ) 196 | #undef __USE_UNIX98 197 | #undef LIBFOLE_DEFINITION_UNIX98 198 | #endif 199 | 200 | #endif 201 | 202 | #ifdef __cplusplus 203 | } 204 | #endif 205 | 206 | #endif /* !defined( _LIBFOLE_TYPES_H ) */ 207 | 208 | -------------------------------------------------------------------------------- /libfole.ini: -------------------------------------------------------------------------------- 1 | [project] 2 | description: "libfole is a library for Object Linking and Embedding (OLE) data types." 3 | name: "libfole" 4 | status: "alpha" 5 | year_of_creation: "2008" 6 | features: ["debug_output"] 7 | 8 | [library] 9 | description: "Library to support the Object Linking and Embedding (OLE) data types" 10 | 11 | -------------------------------------------------------------------------------- /libfole.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libfole 7 | Description: Library to support the Object Linking and Embedding (OLE) data types 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lfole 10 | Libs.private: @ax_libcerror_pc_libs_private@ 11 | Cflags: -I${includedir} 12 | 13 | -------------------------------------------------------------------------------- /libfole.spec.in: -------------------------------------------------------------------------------- 1 | Name: libfole 2 | Version: @VERSION@ 3 | Release: 1 4 | Summary: Library to support the Object Linking and Embedding (OLE) data types 5 | Group: System Environment/Libraries 6 | License: LGPL-3.0-or-later 7 | Source: %{name}-%{version}.tar.gz 8 | URL: https://github.com/libyal/libfole 9 | @libfole_spec_requires@ @ax_libcerror_spec_requires@ 10 | BuildRequires: gcc @ax_libcerror_spec_build_requires@ 11 | 12 | %description -n libfole 13 | Library to support the Object Linking and Embedding (OLE) data types 14 | 15 | %package -n libfole-static 16 | Summary: Library to support the Object Linking and Embedding (OLE) data types 17 | Group: Development/Libraries 18 | Requires: libfole = %{version}-%{release} 19 | 20 | %description -n libfole-static 21 | Static library version of libfole. 22 | 23 | %package -n libfole-devel 24 | Summary: Header files and libraries for developing applications for libfole 25 | Group: Development/Libraries 26 | Requires: libfole = %{version}-%{release} 27 | 28 | %description -n libfole-devel 29 | Header files and libraries for developing applications for libfole. 30 | 31 | %prep 32 | %setup -q 33 | 34 | %build 35 | %configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_mandir} 36 | make %{?_smp_mflags} 37 | 38 | %install 39 | rm -rf %{buildroot} 40 | %make_install 41 | 42 | %clean 43 | rm -rf %{buildroot} 44 | 45 | %post -p /sbin/ldconfig 46 | 47 | %postun -p /sbin/ldconfig 48 | 49 | %files -n libfole 50 | %license COPYING COPYING.LESSER 51 | %doc AUTHORS README 52 | %{_libdir}/*.so.* 53 | 54 | %files -n libfole-static 55 | %license COPYING COPYING.LESSER 56 | %doc AUTHORS README 57 | %{_libdir}/*.a 58 | 59 | %files -n libfole-devel 60 | %license COPYING COPYING.LESSER 61 | %doc AUTHORS README 62 | %{_libdir}/*.so 63 | %{_libdir}/pkgconfig/libfole.pc 64 | %{_includedir}/* 65 | %{_mandir}/man3/* 66 | 67 | %changelog 68 | * @SPEC_DATE@ Joachim Metz @VERSION@-1 69 | - Auto-generated 70 | 71 | -------------------------------------------------------------------------------- /libfole/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -I../include -I$(top_srcdir)/include \ 3 | -I../common -I$(top_srcdir)/common \ 4 | @LIBCERROR_CPPFLAGS@ \ 5 | @LIBFOLE_DLL_EXPORT@ 6 | 7 | lib_LTLIBRARIES = libfole.la 8 | 9 | libfole_la_SOURCES = \ 10 | libfole.c \ 11 | libfole_definitions.h \ 12 | libfole_extern.h \ 13 | libfole_error.c libfole_error.h \ 14 | libfole_libcerror.h \ 15 | libfole_support.c libfole_support.h \ 16 | libfole_types.h \ 17 | libfole_unused.h \ 18 | libfole_value_type.c libfole_value_type.h 19 | 20 | libfole_la_LIBADD = \ 21 | @LIBCERROR_LIBADD@ 22 | 23 | libfole_la_LDFLAGS = -no-undefined -version-info 1:0:0 24 | 25 | EXTRA_DIST = \ 26 | libfole_definitions.h.in \ 27 | libfole.rc \ 28 | libfole.rc.in 29 | 30 | DISTCLEANFILES = \ 31 | libfole_definitions.h \ 32 | libfole.rc \ 33 | Makefile \ 34 | Makefile.in 35 | 36 | sources-local: $(BUILT_SOURCES) 37 | 38 | splint-local: 39 | @echo "Running splint on libfole ..." 40 | -splint -preproc -redef $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(libfole_la_SOURCES) 41 | 42 | -------------------------------------------------------------------------------- /libfole/libfole.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library to support the Object Linking and Embedding (OLE) data types 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | 24 | #if defined( WINAPI ) 25 | #include 26 | #endif 27 | 28 | #include "libfole_unused.h" 29 | 30 | /* Define HAVE_LOCAL_LIBFOLE for local use of libfole 31 | */ 32 | #if !defined( HAVE_LOCAL_LIBFOLE ) 33 | 34 | #if defined( WINAPI ) && defined( HAVE_DLLMAIN ) 35 | 36 | #if defined( _MANAGED ) 37 | #pragma managed( push, off ) 38 | #endif 39 | 40 | /* Defines the entry point for the DLL 41 | */ 42 | BOOL WINAPI DllMain( 43 | HINSTANCE hinstDLL, 44 | DWORD fdwReason, 45 | LPVOID lpvReserved ) 46 | { 47 | LIBFOLE_UNREFERENCED_PARAMETER( lpvReserved ) 48 | 49 | switch( fdwReason ) 50 | { 51 | case DLL_PROCESS_ATTACH: 52 | DisableThreadLibraryCalls( 53 | hinstDLL ); 54 | break; 55 | 56 | case DLL_THREAD_ATTACH: 57 | break; 58 | 59 | case DLL_THREAD_DETACH: 60 | break; 61 | 62 | case DLL_PROCESS_DETACH: 63 | break; 64 | } 65 | return( TRUE ); 66 | } 67 | 68 | /* Function that indicates the library is a DLL 69 | * Returns 1 70 | */ 71 | int libfole_is_dll( 72 | void ) 73 | { 74 | return( 1 ); 75 | } 76 | 77 | #endif /* defined( WINAPI ) && defined( HAVE_DLLMAIN ) */ 78 | 79 | #endif /* !defined( HAVE_LOCAL_LIBFOLE ) */ 80 | 81 | -------------------------------------------------------------------------------- /libfole/libfole.rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef GCC_WINDRES 4 | VS_VERSION_INFO VERSIONINFO 5 | #else 6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 7 | #endif 8 | FILEVERSION 1,0,0,0 9 | PRODUCTVERSION 1,0,0,0 10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 11 | #ifdef _DEBUG 12 | FILEFLAGS 0x1L 13 | #else 14 | FILEFLAGS 0x0L 15 | #endif 16 | FILEOS VOS__WINDOWS32 17 | FILETYPE VFT_DLL 18 | FILESUBTYPE 0x0L 19 | BEGIN 20 | BLOCK "StringFileInfo" 21 | BEGIN 22 | BLOCK "040904E4" 23 | BEGIN 24 | VALUE "FileDescription", "Library to support the Object Linking and Embedding (OLE) data types\0" 25 | VALUE "FileVersion", "@VERSION@" "\0" 26 | VALUE "InternalName", "libfole.dll\0" 27 | VALUE "LegalCopyright", "(C) 2008-2024, Joachim Metz \0" 28 | VALUE "OriginalFilename", "libfole.dll\0" 29 | VALUE "ProductName", "libfole\0" 30 | VALUE "ProductVersion", "@VERSION@" "\0" 31 | VALUE "Comments", "For more information visit https://github.com/libyal/libfole/\0" 32 | END 33 | END 34 | BLOCK "VarFileInfo" 35 | BEGIN 36 | VALUE "Translation", 0x0409, 1200 37 | END 38 | END 39 | -------------------------------------------------------------------------------- /libfole/libfole_definitions.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * The internal definitions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( LIBFOLE_INTERNAL_DEFINITIONS_H ) 23 | #define LIBFOLE_INTERNAL_DEFINITIONS_H 24 | 25 | #include 26 | #include 27 | 28 | /* Define HAVE_LOCAL_LIBFOLE for local use of libfole 29 | */ 30 | #if !defined( HAVE_LOCAL_LIBFOLE ) 31 | #include 32 | 33 | /* The definitions in are copied here 34 | * for local use of libfole 35 | */ 36 | #else 37 | #include 38 | 39 | #define LIBFOLE_VERSION @VERSION@ 40 | 41 | /* The version string 42 | */ 43 | #define LIBFOLE_VERSION_STRING "@VERSION@" 44 | 45 | /* The byte order definitions 46 | */ 47 | #define LIBFOLE_ENDIAN_BIG _BYTE_STREAM_ENDIAN_BIG 48 | #define LIBFOLE_ENDIAN_LITTLE _BYTE_STREAM_ENDIAN_LITTLE 49 | 50 | #endif /* !defined( HAVE_LOCAL_LIBFOLE ) */ 51 | 52 | #endif /* !defined( LIBFOLE_INTERNAL_DEFINITIONS_H ) */ 53 | 54 | -------------------------------------------------------------------------------- /libfole/libfole_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Error functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "libfole_error.h" 27 | #include "libfole_libcerror.h" 28 | 29 | #if !defined( HAVE_LOCAL_LIBFOLE ) 30 | 31 | /* Free an error and its elements 32 | */ 33 | void libfole_error_free( 34 | libfole_error_t **error ) 35 | { 36 | libcerror_error_free( 37 | (libcerror_error_t **) error ); 38 | } 39 | 40 | /* Prints a descriptive string of the error to the stream 41 | * Returns the number of printed characters if successful or -1 on error 42 | */ 43 | int libfole_error_fprint( 44 | libfole_error_t *error, 45 | FILE *stream ) 46 | { 47 | int print_count = 0; 48 | 49 | print_count = libcerror_error_fprint( 50 | (libcerror_error_t *) error, 51 | stream ); 52 | 53 | return( print_count ); 54 | } 55 | 56 | /* Prints a descriptive string of the error to the string 57 | * The end-of-string character is not included in the return value 58 | * Returns the number of printed characters if successful or -1 on error 59 | */ 60 | int libfole_error_sprint( 61 | libfole_error_t *error, 62 | char *string, 63 | size_t size ) 64 | { 65 | int print_count = 0; 66 | 67 | print_count = libcerror_error_sprint( 68 | (libcerror_error_t *) error, 69 | string, 70 | size ); 71 | 72 | return( print_count ); 73 | } 74 | 75 | /* Prints a backtrace of the error to the stream 76 | * Returns the number of printed characters if successful or -1 on error 77 | */ 78 | int libfole_error_backtrace_fprint( 79 | libfole_error_t *error, 80 | FILE *stream ) 81 | { 82 | int print_count = 0; 83 | 84 | print_count = libcerror_error_backtrace_fprint( 85 | (libcerror_error_t *) error, 86 | stream ); 87 | 88 | return( print_count ); 89 | } 90 | 91 | /* Prints a backtrace of the error to the string 92 | * The end-of-string character is not included in the return value 93 | * Returns the number of printed characters if successful or -1 on error 94 | */ 95 | int libfole_error_backtrace_sprint( 96 | libfole_error_t *error, 97 | char *string, 98 | size_t size ) 99 | { 100 | int print_count = 0; 101 | 102 | print_count = libcerror_error_backtrace_sprint( 103 | (libcerror_error_t *) error, 104 | string, 105 | size ); 106 | 107 | return( print_count ); 108 | } 109 | 110 | #endif /* !defined( HAVE_LOCAL_LIBFOLE ) */ 111 | 112 | -------------------------------------------------------------------------------- /libfole/libfole_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Error functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_INTERNAL_ERROR_H ) 23 | #define _LIBFOLE_INTERNAL_ERROR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #if !defined( HAVE_LOCAL_LIBFOLE ) 30 | #include 31 | #endif 32 | 33 | #include "libfole_extern.h" 34 | 35 | #if defined( __cplusplus ) 36 | extern "C" { 37 | #endif 38 | 39 | #if !defined( HAVE_LOCAL_LIBFOLE ) 40 | 41 | LIBFOLE_EXTERN \ 42 | void libfole_error_free( 43 | libfole_error_t **error ); 44 | 45 | LIBFOLE_EXTERN \ 46 | int libfole_error_fprint( 47 | libfole_error_t *error, 48 | FILE *stream ); 49 | 50 | LIBFOLE_EXTERN \ 51 | int libfole_error_sprint( 52 | libfole_error_t *error, 53 | char *string, 54 | size_t size ); 55 | 56 | LIBFOLE_EXTERN \ 57 | int libfole_error_backtrace_fprint( 58 | libfole_error_t *error, 59 | FILE *stream ); 60 | 61 | LIBFOLE_EXTERN \ 62 | int libfole_error_backtrace_sprint( 63 | libfole_error_t *error, 64 | char *string, 65 | size_t size ); 66 | 67 | #endif /* !defined( HAVE_LOCAL_LIBFOLE ) */ 68 | 69 | #if defined( __cplusplus ) 70 | } 71 | #endif 72 | 73 | #endif /* !defined( _LIBFOLE_INTERNAL_ERROR_H ) */ 74 | 75 | -------------------------------------------------------------------------------- /libfole/libfole_extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The internal extern definition 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_INTERNAL_EXTERN_H ) 23 | #define _LIBFOLE_INTERNAL_EXTERN_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBFOLE for local use of libfole 28 | */ 29 | #if !defined( HAVE_LOCAL_LIBFOLE ) 30 | 31 | #include 32 | 33 | #if defined( __CYGWIN__ ) || defined( __MINGW32__ ) 34 | #define LIBFOLE_EXTERN_VARIABLE extern 35 | #else 36 | #define LIBFOLE_EXTERN_VARIABLE LIBFOLE_EXTERN 37 | #endif 38 | 39 | #else 40 | #define LIBFOLE_EXTERN /* extern */ 41 | #define LIBFOLE_EXTERN_VARIABLE extern 42 | 43 | #endif /* !defined( HAVE_LOCAL_LIBFOLE ) */ 44 | 45 | #endif /* !defined( _LIBFOLE_INTERNAL_EXTERN_H ) */ 46 | 47 | -------------------------------------------------------------------------------- /libfole/libfole_libcerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcerror header wrapper 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_LIBCERROR_H ) 23 | #define _LIBFOLE_LIBCERROR_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCERROR for local use of libcerror 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCERROR ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCERROR_DLL_IMPORT 39 | * before including libcerror.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCERROR_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCERROR ) */ 48 | 49 | #endif /* !defined( _LIBFOLE_LIBCERROR_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /libfole/libfole_support.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Support functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "libfole_definitions.h" 28 | #include "libfole_support.h" 29 | 30 | #if !defined( HAVE_LOCAL_LIBFOLE ) 31 | 32 | /* Returns the library version as a string 33 | */ 34 | const char *libfole_get_version( 35 | void ) 36 | { 37 | return( (const char *) LIBFOLE_VERSION_STRING ); 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /libfole/libfole_support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Support functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_SUPPORT_H ) 23 | #define _LIBFOLE_SUPPORT_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libfole_extern.h" 29 | 30 | #if defined( __cplusplus ) 31 | extern "C" { 32 | #endif 33 | 34 | #if !defined( HAVE_LOCAL_LIBFOLE ) 35 | 36 | LIBFOLE_EXTERN \ 37 | const char *libfole_get_version( 38 | void ); 39 | 40 | #endif 41 | 42 | #if defined( __cplusplus ) 43 | } 44 | #endif 45 | 46 | #endif /* !defined( _LIBFOLE_SUPPORT_H ) */ 47 | 48 | -------------------------------------------------------------------------------- /libfole/libfole_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The internal type definitions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_INTERNAL_TYPES_H ) 23 | #define _LIBFOLE_INTERNAL_TYPES_H 24 | 25 | #include 26 | #include 27 | 28 | /* Define HAVE_LOCAL_LIBFOLE for local use of libfole 29 | * The definitions in are copied here 30 | * for local use of libfole 31 | */ 32 | #if defined( HAVE_LOCAL_LIBFOLE ) 33 | 34 | /* The following type definitions hide internal data structures 35 | */ 36 | #if defined( HAVE_DEBUG_OUTPUT ) && !defined( WINAPI ) 37 | 38 | 39 | #else 40 | 41 | 42 | #endif /* defined( HAVE_DEBUG_OUTPUT ) && !defined( WINAPI ) */ 43 | 44 | #endif /* defined( HAVE_LOCAL_LIBFOLE ) */ 45 | 46 | #endif /* !defined( _LIBFOLE_INTERNAL_TYPES_H ) */ 47 | 48 | -------------------------------------------------------------------------------- /libfole/libfole_unused.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to silence compiler warnings about unused function attributes/parameters. 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_UNUSED_H ) 23 | #define _LIBFOLE_UNUSED_H 24 | 25 | #include 26 | 27 | #if !defined( LIBFOLE_ATTRIBUTE_UNUSED ) 28 | #if defined( __GNUC__ ) && __GNUC__ >= 3 29 | #define LIBFOLE_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 30 | #else 31 | #define LIBFOLE_ATTRIBUTE_UNUSED 32 | #endif 33 | #endif 34 | 35 | #if defined( _MSC_VER ) 36 | #define LIBFOLE_UNREFERENCED_PARAMETER( parameter ) \ 37 | UNREFERENCED_PARAMETER( parameter ); 38 | #else 39 | #define LIBFOLE_UNREFERENCED_PARAMETER( parameter ) \ 40 | /* parameter */ 41 | #endif 42 | 43 | #endif /* !defined( _LIBFOLE_UNUSED_H ) */ 44 | 45 | -------------------------------------------------------------------------------- /libfole/libfole_value_type.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Value type functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "libfole_value_type.h" 26 | 27 | libfole_value_type_t libfole_value_types[ ] = { 28 | { 0x0000, "VT_EMPTY", "Empty" }, 29 | { 0x0001, "VT_NULL", "NULL" }, 30 | { 0x0002, "VT_I2", "Integer 16-bit signed" }, 31 | { 0x0003, "VT_I4", "Integer 32-bit signed" }, 32 | { 0x0004, "VT_R4", "Floating point single precision (32-bit)" }, 33 | { 0x0005, "VT_R8", "Floating point double precision (64-bit)" }, 34 | { 0x0006, "VT_CY", "Currency (64-bit)" }, 35 | { 0x0007, "VT_DATE", "Application time (64-bit)" }, 36 | { 0x0008, "VT_BSTR", "OLE automation string" }, 37 | { 0x0009, "VT_DISPATCH", "IDispatch reference" }, 38 | { 0x000a, "VT_ERROR", "Error value (32-bit)" }, 39 | { 0x000b, "VT_BOOLEAN", "Boolean" }, 40 | { 0x000c, "VT_VARIANT", "VARIANT reference" }, 41 | { 0x000d, "VT_UNKNOWN", "IUnknown reference" }, 42 | 43 | { 0x0010, "VT_I1", "Integer 8-bit signed" }, 44 | { 0x0011, "VT_UI1", "Integer 8-bit unsigned" }, 45 | { 0x0012, "VT_UI2", "Integer 16-bit unsigned" }, 46 | { 0x0013, "VT_UI4", "Integer 32-bit unsigned" }, 47 | { 0x0014, "VT_I8", "Integer 64-bit signed" }, 48 | { 0x0015, "VT_UI8", "Integer 64-bit unsigned" }, 49 | { 0x0016, "VT_INT", "Integer signed" }, 50 | { 0x0017, "VT_UINT", "Integer unsigned" }, 51 | { 0x0018, "VT_VOID", "Void reference" }, 52 | { 0x0019, "VT_HRESULT", "HRESULT reference" }, 53 | { 0x001a, "VT_PTR", "pointer reference" }, 54 | { 0x001b, "VT_SAFEARRAY", "safe array" }, 55 | { 0x001c, "VT_CARRAY", "C-type array" }, 56 | { 0x001d, "VT_USERDEFINED", "user defined" }, 57 | { 0x001e, "VT_LPSTR", "Extended ASCII string" }, 58 | { 0x001f, "VT_LPWSTR", "UTF-16 Unicode string" }, 59 | 60 | { 0x0040, "VT_FILETIME", "Windows Filetime (64-bit)" }, 61 | { 0x0041, "VT_BLOB", "Binary large object" }, 62 | { 0x0042, "VT_STREAM", "OLE stream" }, 63 | { 0x0043, "VT_STORAGE", "OLE storage" }, 64 | { 0x0044, "VT_STREAMED_OBJECT", "OLE streamed object" }, 65 | { 0x0045, "VT_STORED_OBJECT", "OLE stored object" }, 66 | { 0x0046, "VT_BLOB_OBJECT", "Binary large object" }, 67 | { 0x0047, "VT_CF", "Clipboard format" }, 68 | 69 | { 0x0048, "VT_CLSID", "GUID (128-bit)" }, 70 | { 0x0049, "VT_VERSIONED_STREAM", "OLE versioned stream" }, 71 | 72 | { (uint32_t) -1, "_UNKNOWN_", "Unknown" } }; 73 | 74 | /* Retrieves a string containing the value type identifier 75 | */ 76 | const char *libfole_value_type_get_identifier( 77 | uint32_t value_type ) 78 | { 79 | int iterator = 0; 80 | 81 | while( ( libfole_value_types[ iterator ] ).value_type != (uint32_t) -1 ) 82 | { 83 | if( ( libfole_value_types[ iterator ] ).value_type == value_type ) 84 | { 85 | break; 86 | } 87 | iterator++; 88 | } 89 | return( 90 | ( libfole_value_types[ iterator ] ).identifier ); 91 | } 92 | 93 | /* Retrieves a string containing the value type description 94 | */ 95 | const char *libfole_value_type_get_description( 96 | uint32_t value_type ) 97 | { 98 | int iterator = 0; 99 | 100 | while( ( libfole_value_types[ iterator ] ).value_type != (uint32_t) -1 ) 101 | { 102 | if( ( libfole_value_types[ iterator ] ).value_type == value_type ) 103 | { 104 | break; 105 | } 106 | iterator++; 107 | } 108 | return( 109 | ( libfole_value_types[ iterator ] ).description ); 110 | } 111 | 112 | -------------------------------------------------------------------------------- /libfole/libfole_value_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Value type functions 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBFOLE_VALUE_TYPE_H ) 23 | #define _LIBFOLE_VALUE_TYPE_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libfole_extern.h" 29 | 30 | #if defined( __cplusplus ) 31 | extern "C" { 32 | #endif 33 | 34 | typedef struct libfole_value_type libfole_value_type_t; 35 | 36 | struct libfole_value_type 37 | { 38 | /* The value type 39 | */ 40 | uint32_t value_type; 41 | 42 | /* The identifier 43 | */ 44 | const char *identifier; 45 | 46 | /* The description 47 | */ 48 | const char *description; 49 | }; 50 | 51 | LIBFOLE_EXTERN \ 52 | const char *libfole_value_type_get_identifier( 53 | uint32_t value_type ); 54 | 55 | LIBFOLE_EXTERN \ 56 | const char *libfole_value_type_get_description( 57 | uint32_t value_type ); 58 | 59 | #if defined( __cplusplus ) 60 | } 61 | #endif 62 | 63 | #endif /* !defined( _LIBFOLE_VALUE_TYPE_H ) */ 64 | 65 | -------------------------------------------------------------------------------- /m4/libcerror.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for libcerror required headers and functions 2 | dnl 3 | dnl Version: 20240513 4 | 5 | dnl Function to detect if libcerror is available 6 | dnl ac_libcerror_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l arguments 7 | AC_DEFUN([AX_LIBCERROR_CHECK_LIB], 8 | [AS_IF( 9 | [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libcerror" = xno], 10 | [ac_cv_libcerror=no], 11 | [ac_cv_libcerror=check 12 | dnl Check if the directory provided as parameter exists 13 | dnl For both --with-libcerror which returns "yes" and --with-libcerror= which returns "" 14 | dnl treat them as auto-detection. 15 | AS_IF( 16 | [test "x$ac_cv_with_libcerror" != x && test "x$ac_cv_with_libcerror" != xauto-detect && test "x$ac_cv_with_libcerror" != xyes], 17 | [AX_CHECK_LIB_DIRECTORY_EXISTS([libcerror])], 18 | [dnl Check for a pkg-config file 19 | AS_IF( 20 | [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], 21 | [PKG_CHECK_MODULES( 22 | [libcerror], 23 | [libcerror >= 20120425], 24 | [ac_cv_libcerror=yes], 25 | [ac_cv_libcerror=check]) 26 | ]) 27 | AS_IF( 28 | [test "x$ac_cv_libcerror" = xyes], 29 | [ac_cv_libcerror_CPPFLAGS="$pkg_cv_libcerror_CFLAGS" 30 | ac_cv_libcerror_LIBADD="$pkg_cv_libcerror_LIBS"]) 31 | ]) 32 | 33 | AS_IF( 34 | [test "x$ac_cv_libcerror" = xcheck], 35 | [dnl Check for headers 36 | AC_CHECK_HEADERS([libcerror.h]) 37 | 38 | AS_IF( 39 | [test "x$ac_cv_header_libcerror_h" = xno], 40 | [ac_cv_libcerror=no], 41 | [ac_cv_libcerror=yes 42 | 43 | AX_CHECK_LIB_FUNCTIONS( 44 | [libcerror], 45 | [cerror], 46 | [[libcerror_get_version], 47 | [libcerror_error_free], 48 | [libcerror_error_set], 49 | [libcerror_error_matches], 50 | [libcerror_error_fprint], 51 | [libcerror_error_sprint], 52 | [libcerror_error_backtrace_fprint], 53 | [libcerror_error_backtrace_sprint], 54 | [libcerror_system_set_error]]) 55 | 56 | ac_cv_libcerror_LIBADD="-lcerror"]) 57 | ]) 58 | 59 | AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libcerror]) 60 | ]) 61 | 62 | AS_IF( 63 | [test "x$ac_cv_libcerror" = xyes], 64 | [AC_DEFINE( 65 | [HAVE_LIBCERROR], 66 | [1], 67 | [Define to 1 if you have the `cerror' library (-lcerror).]) 68 | ]) 69 | 70 | AS_IF( 71 | [test "x$ac_cv_libcerror" = xyes], 72 | [AC_SUBST( 73 | [HAVE_LIBCERROR], 74 | [1]) ], 75 | [AC_SUBST( 76 | [HAVE_LIBCERROR], 77 | [0]) 78 | ]) 79 | ]) 80 | 81 | dnl Function to detect if libcerror dependencies are available 82 | AC_DEFUN([AX_LIBCERROR_CHECK_LOCAL], 83 | [dnl Headers included in libcerror/libcerror_error.c 84 | AC_CHECK_HEADERS([stdarg.h varargs.h]) 85 | 86 | AS_IF( 87 | [test "x$ac_cv_header_stdarg_h" != xyes && test "x$ac_cv_header_varargs_h" != xyes], 88 | [AC_MSG_FAILURE( 89 | [Missing headers: stdarg.h and varargs.h], 90 | [1]) 91 | ]) 92 | 93 | dnl Wide character string functions used in libcerror/libcerror_error.c 94 | AS_IF( 95 | [test "x$ac_cv_enable_wide_character_type" != xno], 96 | [AC_CHECK_FUNCS([wcstombs]) 97 | 98 | AS_IF( 99 | [test "x$ac_cv_func_wcstombs" != xyes], 100 | [AC_MSG_FAILURE( 101 | [Missing function: wcstombs], 102 | [1]) 103 | ]) 104 | ]) 105 | 106 | dnl Check for error string functions used in libcerror/libcerror_system.c 107 | AC_FUNC_STRERROR_R() 108 | 109 | AS_IF( 110 | [test "x$ac_cv_have_decl_strerror_r" != xyes], 111 | [AC_CHECK_FUNCS([strerror]) 112 | 113 | AS_IF( 114 | [test "x$ac_cv_func_strerror" != xyes], 115 | [AC_MSG_FAILURE( 116 | [Missing functions: strerror_r and strerror], 117 | [1]) 118 | ]) 119 | ]) 120 | 121 | ac_cv_libcerror_CPPFLAGS="-I../libcerror -I\$(top_srcdir)/libcerror"; 122 | ac_cv_libcerror_LIBADD="../libcerror/libcerror.la"; 123 | 124 | ac_cv_libcerror=local 125 | ]) 126 | 127 | dnl Function to detect how to enable libcerror 128 | AC_DEFUN([AX_LIBCERROR_CHECK_ENABLE], 129 | [AX_COMMON_ARG_WITH( 130 | [libcerror], 131 | [libcerror], 132 | [search for libcerror in includedir and libdir or in the specified DIR, or no if to use local version], 133 | [auto-detect], 134 | [DIR]) 135 | 136 | dnl Check for a shared library version 137 | AX_LIBCERROR_CHECK_LIB 138 | 139 | dnl Check if the dependencies for the local library version 140 | AS_IF( 141 | [test "x$ac_cv_libcerror" != xyes], 142 | [AX_LIBCERROR_CHECK_LOCAL 143 | 144 | AC_DEFINE( 145 | [HAVE_LOCAL_LIBCERROR], 146 | [1], 147 | [Define to 1 if the local version of libcerror is used.]) 148 | AC_SUBST( 149 | [HAVE_LOCAL_LIBCERROR], 150 | [1]) 151 | ]) 152 | 153 | AM_CONDITIONAL( 154 | [HAVE_LOCAL_LIBCERROR], 155 | [test "x$ac_cv_libcerror" = xlocal]) 156 | AS_IF( 157 | [test "x$ac_cv_libcerror_CPPFLAGS" != "x"], 158 | [AC_SUBST( 159 | [LIBCERROR_CPPFLAGS], 160 | [$ac_cv_libcerror_CPPFLAGS]) 161 | ]) 162 | AS_IF( 163 | [test "x$ac_cv_libcerror_LIBADD" != "x"], 164 | [AC_SUBST( 165 | [LIBCERROR_LIBADD], 166 | [$ac_cv_libcerror_LIBADD]) 167 | ]) 168 | 169 | AS_IF( 170 | [test "x$ac_cv_libcerror" = xyes], 171 | [AC_SUBST( 172 | [ax_libcerror_pc_libs_private], 173 | [-lcerror]) 174 | ]) 175 | 176 | AS_IF( 177 | [test "x$ac_cv_libcerror" = xyes], 178 | [AC_SUBST( 179 | [ax_libcerror_spec_requires], 180 | [libcerror]) 181 | AC_SUBST( 182 | [ax_libcerror_spec_build_requires], 183 | [libcerror-devel]) 184 | ]) 185 | ]) 186 | 187 | -------------------------------------------------------------------------------- /m4/tests.m4: -------------------------------------------------------------------------------- 1 | dnl Functions for testing 2 | dnl 3 | dnl Version: 20200712 4 | 5 | dnl Function to detect if tests dependencies are available 6 | AC_DEFUN([AX_TESTS_CHECK_LOCAL], 7 | [AC_CHECK_HEADERS([dlfcn.h]) 8 | 9 | AC_CHECK_FUNCS([fmemopen getopt mkstemp setenv tzset unlink]) 10 | 11 | AC_CHECK_LIB( 12 | dl, 13 | dlsym) 14 | 15 | AS_IF( 16 | [test "x$lt_cv_prog_gnu_ld" = xyes && test "x$ac_cv_lib_dl_dlsym" = xyes], 17 | [AC_DEFINE( 18 | [HAVE_GNU_DL_DLSYM], 19 | [1], 20 | [Define to 1 if dlsym function is available in GNU dl.]) 21 | ]) 22 | ]) 23 | 24 | dnl Function to detect if OSS-Fuzz build environment is available 25 | AC_DEFUN([AX_TESTS_CHECK_OSSFUZZ], 26 | [AM_CONDITIONAL( 27 | HAVE_LIB_FUZZING_ENGINE, 28 | [test "x${LIB_FUZZING_ENGINE}" != x]) 29 | AC_SUBST( 30 | [LIB_FUZZING_ENGINE], 31 | ["${LIB_FUZZING_ENGINE}"]) 32 | ]) 33 | 34 | -------------------------------------------------------------------------------- /m4/types.m4: -------------------------------------------------------------------------------- 1 | dnl Functions for type definitions 2 | dnl 3 | dnl Version: 20180727 4 | 5 | dnl Function to detect if type definitions are available 6 | AC_DEFUN([AX_TYPES_CHECK_LOCAL], 7 | [AS_IF( 8 | [test "x$ac_cv_enable_winapi" = xyes], 9 | [ac_cv_enable_wide_character_type=yes]) 10 | 11 | AS_IF( 12 | [test "x$ac_cv_enable_wide_character_type" = xyes], 13 | [AC_DEFINE( 14 | [HAVE_WIDE_CHARACTER_TYPE], 15 | [1], 16 | [Define to 1 if wide character type should be used.]) 17 | AC_SUBST( 18 | [HAVE_WIDE_CHARACTER_TYPE], 19 | [1]) ], 20 | [AC_SUBST( 21 | [HAVE_WIDE_CHARACTER_TYPE], 22 | [0]) 23 | ]) 24 | 25 | AC_CHECK_HEADERS([sys/types.h inttypes.h stdint.h wchar.h]) 26 | 27 | AS_IF( 28 | [test "x$ac_cv_header_sys_types_h" = xyes], 29 | [AC_SUBST( 30 | [HAVE_SYS_TYPES_H], 31 | [1])], 32 | [AC_SUBST( 33 | [HAVE_SYS_TYPES_H], 34 | [0]) 35 | ]) 36 | 37 | AS_IF( 38 | [test "x$ac_cv_header_inttypes_h" = xyes], 39 | [AC_SUBST( 40 | [HAVE_INTTYPES_H], 41 | [1])], 42 | [AC_SUBST( 43 | [HAVE_INTTYPES_H], 44 | [0]) 45 | ]) 46 | 47 | AS_IF( 48 | [test "x$ac_cv_header_stdint_h" = xyes], 49 | [AC_SUBST( 50 | [HAVE_STDINT_H], 51 | [1])], 52 | [AC_SUBST( 53 | [HAVE_STDINT_H], 54 | [0]) 55 | ]) 56 | 57 | AS_IF( 58 | [test "x$ac_cv_header_wchar_h" = xyes], 59 | [AC_SUBST( 60 | [HAVE_WCHAR_H], 61 | [1]) ], 62 | [AC_SUBST( 63 | [HAVE_WCHAR_H], 64 | [0]) 65 | ]) 66 | 67 | AC_TYPE_MODE_T 68 | AC_TYPE_OFF_T 69 | AC_TYPE_SIZE_T 70 | 71 | AC_CHECK_TYPE( 72 | [size32_t], 73 | [AC_SUBST( 74 | [HAVE_SIZE32_T], 75 | [1])], 76 | [AC_SUBST( 77 | [HAVE_SIZE32_T], 78 | [0]) 79 | ]) 80 | 81 | AC_CHECK_TYPE( 82 | [ssize32_t], 83 | [AC_SUBST( 84 | [HAVE_SSIZE32_T], 85 | [1])], 86 | [AC_SUBST( 87 | [HAVE_SSIZE32_T], 88 | [0]) 89 | ]) 90 | 91 | AC_CHECK_TYPE( 92 | [size64_t], 93 | [AC_SUBST( 94 | [HAVE_SIZE64_T], 95 | [1])], 96 | [AC_SUBST( 97 | [HAVE_SIZE64_T], 98 | [0]) 99 | ]) 100 | 101 | AC_CHECK_TYPE( 102 | [ssize64_t], 103 | [AC_SUBST( 104 | [HAVE_SSIZE64_T], 105 | [1])], 106 | [AC_SUBST( 107 | [HAVE_SSIZE64_T], 108 | [0]) 109 | ]) 110 | 111 | AC_CHECK_TYPE( 112 | [off64_t], 113 | [AC_SUBST( 114 | [HAVE_OFF64_T], 115 | [1])], 116 | [AC_SUBST( 117 | [HAVE_OFF64_T], 118 | [0]) 119 | ]) 120 | 121 | AC_CHECK_TYPE([ssize_t]) 122 | AC_CHECK_TYPE([u64]) 123 | 124 | AC_CHECK_SIZEOF([int]) 125 | AC_CHECK_SIZEOF([long]) 126 | AC_CHECK_SIZEOF([off_t]) 127 | AC_CHECK_SIZEOF([size_t]) 128 | 129 | AS_IF( 130 | [test "x$ac_cv_header_wchar_h" = xyes], 131 | [AC_CHECK_SIZEOF([wchar_t])]) 132 | ]) 133 | 134 | -------------------------------------------------------------------------------- /manuals/Makefile.am: -------------------------------------------------------------------------------- 1 | man_MANS = \ 2 | libfole.3 3 | 4 | EXTRA_DIST = \ 5 | libfole.3 6 | 7 | DISTCLEANFILES = \ 8 | Makefile \ 9 | Makefile.in 10 | 11 | -------------------------------------------------------------------------------- /manuals/libfole.3: -------------------------------------------------------------------------------- 1 | .Dd March 27, 2019 2 | .Dt libfole 3 3 | .Os libfole 4 | .Sh NAME 5 | .Nm libfole.h 6 | .Nd Library to support the Object Linking and Embedding (OLE) data types 7 | .Sh SYNOPSIS 8 | .In libfole.h 9 | .Pp 10 | Support functions 11 | .Ft const char * 12 | .Fn libfole_get_version "void" 13 | .Pp 14 | Error functions 15 | .Ft void 16 | .Fn libfole_error_free "libfole_error_t **error" 17 | .Ft int 18 | .Fn libfole_error_fprint "libfole_error_t *error" "FILE *stream" 19 | .Ft int 20 | .Fn libfole_error_sprint "libfole_error_t *error" "char *string" "size_t size" 21 | .Ft int 22 | .Fn libfole_error_backtrace_fprint "libfole_error_t *error" "FILE *stream" 23 | .Ft int 24 | .Fn libfole_error_backtrace_sprint "libfole_error_t *error" "char *string" "size_t size" 25 | .Pp 26 | Value type functions 27 | .Ft const char * 28 | .Fn libfole_value_type_get_identifier "uint32_t value_type" 29 | .Ft const char * 30 | .Fn libfole_value_type_get_description "uint32_t value_type" 31 | .Sh DESCRIPTION 32 | The 33 | .Fn libfole_get_version 34 | function is used to retrieve the library version. 35 | .Sh RETURN VALUES 36 | Most of the functions return NULL or \-1 on error, dependent on the return type. 37 | For the actual return values see "libfole.h". 38 | .Sh ENVIRONMENT 39 | None 40 | .Sh FILES 41 | None 42 | .Sh BUGS 43 | Please report bugs of any kind on the project issue tracker: https://github.com/libyal/libfole/issues 44 | .Sh AUTHOR 45 | These man pages are generated from "libfole.h". 46 | .Sh COPYRIGHT 47 | Copyright (C) 2008-2024, Joachim Metz . 48 | .sp 49 | This is free software; see the source for copying conditions. 50 | There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 51 | .Sh SEE ALSO 52 | the libfole.h include file 53 | -------------------------------------------------------------------------------- /msvscpp/Makefile.am: -------------------------------------------------------------------------------- 1 | MSVSCPP_FILES = \ 2 | fole_test_error/fole_test_error.vcproj \ 3 | fole_test_support/fole_test_support.vcproj \ 4 | fole_test_value_type/fole_test_value_type.vcproj \ 5 | libcerror/libcerror.vcproj \ 6 | libfole/libfole.vcproj \ 7 | libfole.sln 8 | 9 | EXTRA_DIST = \ 10 | $(MSVSCPP_FILES) 11 | 12 | DISTCLEANFILES = \ 13 | Makefile \ 14 | Makefile.in 15 | 16 | -------------------------------------------------------------------------------- /msvscpp/fole_test_error/fole_test_error.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 27 | 30 | 33 | 36 | 39 | 42 | 50 | 53 | 56 | 59 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 92 | 99 | 102 | 105 | 108 | 111 | 114 | 126 | 129 | 132 | 135 | 147 | 150 | 153 | 156 | 159 | 162 | 165 | 168 | 169 | 170 | 171 | 172 | 173 | 178 | 181 | 182 | 183 | 188 | 191 | 192 | 195 | 196 | 199 | 200 | 203 | 204 | 205 | 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /msvscpp/fole_test_support/fole_test_support.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 27 | 30 | 33 | 36 | 39 | 42 | 50 | 53 | 56 | 59 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 92 | 99 | 102 | 105 | 108 | 111 | 114 | 126 | 129 | 132 | 135 | 147 | 150 | 153 | 156 | 159 | 162 | 165 | 168 | 169 | 170 | 171 | 172 | 173 | 178 | 181 | 182 | 183 | 188 | 191 | 192 | 195 | 196 | 199 | 200 | 201 | 206 | 207 | 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /msvscpp/fole_test_value_type/fole_test_value_type.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 27 | 30 | 33 | 36 | 39 | 42 | 50 | 53 | 56 | 59 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 91 | 92 | 99 | 102 | 105 | 108 | 111 | 114 | 126 | 129 | 132 | 135 | 147 | 150 | 153 | 156 | 159 | 162 | 165 | 168 | 169 | 170 | 171 | 172 | 173 | 178 | 181 | 182 | 185 | 186 | 187 | 192 | 195 | 196 | 199 | 200 | 203 | 204 | 207 | 208 | 211 | 212 | 213 | 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /msvscpp/libcerror/libcerror.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 48 | 51 | 54 | 57 | 63 | 66 | 69 | 72 | 75 | 78 | 79 | 86 | 89 | 92 | 95 | 98 | 101 | 113 | 116 | 119 | 122 | 128 | 131 | 134 | 137 | 140 | 143 | 144 | 145 | 146 | 147 | 148 | 153 | 156 | 157 | 160 | 161 | 164 | 165 | 166 | 171 | 174 | 175 | 178 | 179 | 182 | 183 | 186 | 187 | 190 | 191 | 194 | 195 | 198 | 199 | 200 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /msvscpp/libfole.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfole", "libfole\libfole.vcproj", "{10F855CA-4F78-4C5F-9F73-2FA03C035121}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {145E2FC0-0580-484A-B20A-B38682325816} = {145E2FC0-0580-484A-B20A-B38682325816} 7 | EndProjectSection 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fole_test_error", "fole_test_error\fole_test_error.vcproj", "{0CC4E65F-6263-4D95-9B08-FD8FD0F84651}" 10 | ProjectSection(ProjectDependencies) = postProject 11 | {10F855CA-4F78-4C5F-9F73-2FA03C035121} = {10F855CA-4F78-4C5F-9F73-2FA03C035121} 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fole_test_support", "fole_test_support\fole_test_support.vcproj", "{4B7E6AB8-915C-44EA-9043-EAC99486F935}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | {10F855CA-4F78-4C5F-9F73-2FA03C035121} = {10F855CA-4F78-4C5F-9F73-2FA03C035121} 17 | EndProjectSection 18 | EndProject 19 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fole_test_value_type", "fole_test_value_type\fole_test_value_type.vcproj", "{5488DD58-5C7B-4614-93C0-9985367C296A}" 20 | ProjectSection(ProjectDependencies) = postProject 21 | {10F855CA-4F78-4C5F-9F73-2FA03C035121} = {10F855CA-4F78-4C5F-9F73-2FA03C035121} 22 | EndProjectSection 23 | EndProject 24 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcerror", "libcerror\libcerror.vcproj", "{145E2FC0-0580-484A-B20A-B38682325816}" 25 | EndProject 26 | Global 27 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 28 | Release|Win32 = Release|Win32 29 | VSDebug|Win32 = VSDebug|Win32 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {10F855CA-4F78-4C5F-9F73-2FA03C035121}.Release|Win32.ActiveCfg = Release|Win32 33 | {10F855CA-4F78-4C5F-9F73-2FA03C035121}.Release|Win32.Build.0 = Release|Win32 34 | {10F855CA-4F78-4C5F-9F73-2FA03C035121}.VSDebug|Win32.ActiveCfg = VSDebug|Win32 35 | {10F855CA-4F78-4C5F-9F73-2FA03C035121}.VSDebug|Win32.Build.0 = VSDebug|Win32 36 | {0CC4E65F-6263-4D95-9B08-FD8FD0F84651}.Release|Win32.ActiveCfg = Release|Win32 37 | {0CC4E65F-6263-4D95-9B08-FD8FD0F84651}.Release|Win32.Build.0 = Release|Win32 38 | {0CC4E65F-6263-4D95-9B08-FD8FD0F84651}.VSDebug|Win32.ActiveCfg = VSDebug|Win32 39 | {0CC4E65F-6263-4D95-9B08-FD8FD0F84651}.VSDebug|Win32.Build.0 = VSDebug|Win32 40 | {4B7E6AB8-915C-44EA-9043-EAC99486F935}.Release|Win32.ActiveCfg = Release|Win32 41 | {4B7E6AB8-915C-44EA-9043-EAC99486F935}.Release|Win32.Build.0 = Release|Win32 42 | {4B7E6AB8-915C-44EA-9043-EAC99486F935}.VSDebug|Win32.ActiveCfg = VSDebug|Win32 43 | {4B7E6AB8-915C-44EA-9043-EAC99486F935}.VSDebug|Win32.Build.0 = VSDebug|Win32 44 | {5488DD58-5C7B-4614-93C0-9985367C296A}.Release|Win32.ActiveCfg = Release|Win32 45 | {5488DD58-5C7B-4614-93C0-9985367C296A}.Release|Win32.Build.0 = Release|Win32 46 | {5488DD58-5C7B-4614-93C0-9985367C296A}.VSDebug|Win32.ActiveCfg = VSDebug|Win32 47 | {5488DD58-5C7B-4614-93C0-9985367C296A}.VSDebug|Win32.Build.0 = VSDebug|Win32 48 | {145E2FC0-0580-484A-B20A-B38682325816}.Release|Win32.ActiveCfg = Release|Win32 49 | {145E2FC0-0580-484A-B20A-B38682325816}.Release|Win32.Build.0 = Release|Win32 50 | {145E2FC0-0580-484A-B20A-B38682325816}.VSDebug|Win32.ActiveCfg = VSDebug|Win32 51 | {145E2FC0-0580-484A-B20A-B38682325816}.VSDebug|Win32.Build.0 = VSDebug|Win32 52 | EndGlobalSection 53 | GlobalSection(SolutionProperties) = preSolution 54 | HideSolutionNode = FALSE 55 | EndGlobalSection 56 | EndGlobal 57 | -------------------------------------------------------------------------------- /msvscpp/libfole/libfole.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 48 | 51 | 54 | 57 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 95 | 98 | 101 | 104 | 107 | 110 | 122 | 125 | 128 | 131 | 141 | 144 | 147 | 150 | 153 | 156 | 159 | 162 | 163 | 164 | 165 | 166 | 167 | 172 | 175 | 176 | 179 | 180 | 183 | 184 | 187 | 188 | 189 | 194 | 197 | 198 | 201 | 202 | 205 | 206 | 209 | 210 | 213 | 214 | 217 | 218 | 221 | 222 | 225 | 226 | 227 | 232 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2016-11-04 gettextize 2 | -------------------------------------------------------------------------------- /po/Makevars.in: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = @PACKAGE@ 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Joachim Metz 22 | 23 | # This is the email address or URL to which the translators shall report 24 | # bugs in the untranslated strings: 25 | # - Strings which are not entire sentences, see the maintainer guidelines 26 | # in the GNU gettext documentation, section 'Preparing Strings'. 27 | # - Strings which use unclear terms or require additional context to be 28 | # understood. 29 | # - Strings which make invalid assumptions about notation of date, time or 30 | # money. 31 | # - Pluralisation problems. 32 | # - Incorrect English spelling. 33 | # - Incorrect formatting. 34 | # It can be your email address, or a mailing list address where translators 35 | # can write to without being subscribed, or the URL of a web page through 36 | # which the translators can contact you. 37 | MSGID_BUGS_ADDRESS = @PACKAGE_BUGREPORT@ 38 | 39 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 40 | # message catalogs shall be used. It is usually empty. 41 | EXTRA_LOCALE_CATEGORIES = 42 | 43 | # Additional make targets. 44 | sources splint: 45 | 46 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files which contain translatable strings. 2 | -------------------------------------------------------------------------------- /runtests.ps1: -------------------------------------------------------------------------------- 1 | # Script that runs the tests 2 | # 3 | # Version: 20220103 4 | 5 | $ExitSuccess = 0 6 | $ExitFailure = 1 7 | $ExitIgnore = 77 8 | 9 | Set-Location -Path "tests" 10 | 11 | $Result = ${ExitSuccess} 12 | 13 | $Lines = Get-Content "Makefile.am" 14 | $InTests = $FALSE 15 | 16 | Foreach (${Line} in ${Lines}) 17 | { 18 | If (${InTests}) 19 | { 20 | If (-Not ${Line}) 21 | { 22 | ${InTests} = $FALSE 23 | 24 | Continue 25 | } 26 | ${Line} = ${Line}.TrimStart() 27 | 28 | If (${Line}.EndsWith(" \")) 29 | { 30 | ${Line} = ${Line}.Substring(0, ${Line}.Length - 2) 31 | } 32 | If (-Not (${Line}.EndsWith(".sh"))) 33 | { 34 | Continue 35 | } 36 | ${Line} = ${Line}.Substring(0, ${Line}.Length - 3) 37 | ${Line} = ".\${Line}.ps1" 38 | 39 | Try 40 | { 41 | Invoke-Expression ${Line} 42 | } 43 | Catch 44 | { 45 | $LastExitCode = ${ExitIgnore} 46 | } 47 | If (${LastExitCode} -eq ${ExitFailure}) 48 | { 49 | $Result = ${ExitFailure} 50 | Write-Host "FAIL" -foreground Red -nonewline 51 | } 52 | ElseIf (${LastExitCode} -eq ${ExitIgnore}) 53 | { 54 | Write-Host "SKIP" -foreground Cyan -nonewline 55 | } 56 | Else 57 | { 58 | Write-Host "PASS" -foreground Green -nonewline 59 | } 60 | Write-Host ": ${Line}" 61 | } 62 | ElseIf (${Line}.StartsWith("TESTS = ")) 63 | { 64 | ${InTests} = $TRUE 65 | } 66 | } 67 | 68 | Set-Location -Path ".." 69 | 70 | Exit ${Result} 71 | -------------------------------------------------------------------------------- /synclibs.ps1: -------------------------------------------------------------------------------- 1 | # Script that synchronizes the local library dependencies 2 | # 3 | # Version: 20180125 4 | 5 | Param ( 6 | [switch]$UseHead = $false 7 | ) 8 | 9 | $GitUrlPrefix = "https://github.com/libyal" 10 | $LocalLibs = "libcerror" 11 | $LocalLibs = ${LocalLibs} -split " " 12 | 13 | $Git = "git" 14 | $WinFlex = "..\win_flex_bison\win_flex.exe" 15 | $WinBison = "..\win_flex_bison\win_bison.exe" 16 | 17 | ForEach (${LocalLib} in ${LocalLibs}) 18 | { 19 | # Split will return an array of a single empty string when LocalLibs is empty. 20 | If (-Not (${LocalLib})) 21 | { 22 | Continue 23 | } 24 | $GitUrl = "${GitUrlPrefix}/${LocalLib}.git" 25 | 26 | # PowerShell will raise NativeCommandError if git writes to stdout or stderr 27 | # therefore 2>&1 is added and the output is stored in a variable. 28 | $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${LocalLib}-${pid} 2>&1" 29 | 30 | Push-Location "${LocalLib}-${pid}" 31 | 32 | Try 33 | { 34 | $Output = Invoke-Expression -Command "${Git} fetch --quiet --all --tags --prune 2>&1" 35 | 36 | $LatestTag = Invoke-Expression -Command "${Git} describe --tags --abbrev=0 2>&1" 37 | 38 | If (${LatestTag} -and -not ${UseHead}) 39 | { 40 | Write-Host "Synchronizing: ${LocalLib} from ${GitUrl} tag ${LatestTag}" 41 | 42 | $Output = Invoke-Expression -Command "${Git} checkout --quiet tags/${LatestTag} 2>&1" 43 | } 44 | Else 45 | { 46 | Write-Host "Synchronizing: ${LocalLib} from ${GitUrl} HEAD" 47 | } 48 | } 49 | Finally 50 | { 51 | Pop-Location 52 | } 53 | If (Test-Path ${LocalLib}-${pid}) 54 | { 55 | $LocalLibVersion = Get-Content -Path ${LocalLib}-${pid}\configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } 56 | 57 | If (Test-Path ${LocalLib}) 58 | { 59 | Remove-Item -Path ${LocalLib} -Force -Recurse 60 | } 61 | New-Item -ItemType directory -Path ${LocalLib} -Force | Out-Null 62 | 63 | If (Test-Path ${LocalLib}) 64 | { 65 | Copy-Item -Path ${LocalLib}-${pid}\${LocalLib}\*.[chly] -Destination ${LocalLib}\ 66 | Get-Content -Path ${LocalLib}-${pid}\${LocalLib}\${LocalLib}_definitions.h.in | % { $_ -Replace "@VERSION@",${LocalLibVersion} } > ${LocalLib}\${LocalLib}_definitions.h 67 | } 68 | Remove-Item -Path ${LocalLib}-${pid} -Force -Recurse 69 | 70 | $NamePrefix = "" 71 | 72 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.l") 73 | { 74 | $OutputFile = ${DirectoryElement} -Replace ".l$",".c" 75 | 76 | $NamePrefix = Split-Path -path ${DirectoryElement} -leaf 77 | $NamePrefix = ${NamePrefix} -Replace "^${LocalLib}_","" 78 | $NamePrefix = ${NamePrefix} -Replace ".l$","_" 79 | 80 | # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr 81 | # therefore 2>&1 is added and the output is stored in a variable. 82 | $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" 83 | Write-Host ${Output} 84 | 85 | # Moving manually sicne win_flex -o does not provide the expected behavior. 86 | Move-Item "lex.yy.c" ${OutputFile} -force 87 | } 88 | 89 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.y") 90 | { 91 | $OutputFile = ${DirectoryElement} -Replace ".y$",".c" 92 | 93 | # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr 94 | # therefore 2>&1 is added and the output is stored in a variable. 95 | $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" 96 | Write-Host ${Output} 97 | } 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /synclibs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script that synchronizes the local library dependencies 3 | # 4 | # Version: 20240414 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | 9 | GIT_URL_PREFIX="https://github.com/libyal"; 10 | LOCAL_LIBS="libcerror"; 11 | 12 | OLDIFS=$IFS; 13 | IFS=" "; 14 | 15 | for LOCAL_LIB in ${LOCAL_LIBS}; 16 | do 17 | GIT_URL="${GIT_URL_PREFIX}/${LOCAL_LIB}.git"; 18 | 19 | git clone --quiet ${GIT_URL} ${LOCAL_LIB}-$$; 20 | 21 | if ! test -d ${LOCAL_LIB}-$$; 22 | then 23 | echo "Unable to git clone: ${GIT_URL}"; 24 | 25 | IFS=$OLDIFS; 26 | 27 | exit ${EXIT_FAILURE}; 28 | fi 29 | (cd ${LOCAL_LIB}-$$ && git fetch --quiet --all --tags --prune) 30 | 31 | LATEST_TAG=`cd ${LOCAL_LIB}-$$ && git describe --tags --abbrev=0`; 32 | 33 | if test -n ${LATEST_TAG} && test "$1" != "--use-head"; 34 | then 35 | echo "Synchronizing: ${LOCAL_LIB} from ${GIT_URL} tag ${LATEST_TAG}"; 36 | 37 | (cd ${LOCAL_LIB}-$$ && git checkout --quiet tags/${LATEST_TAG}); 38 | else 39 | echo "Synchronizing: ${LOCAL_LIB} from ${GIT_URL} HEAD"; 40 | fi 41 | 42 | rm -rf ${LOCAL_LIB}; 43 | mkdir ${LOCAL_LIB}; 44 | 45 | if ! test -d ${LOCAL_LIB}; 46 | then 47 | echo "Missing directory: ${LOCAL_LIB}"; 48 | 49 | IFS=$OLDIFS; 50 | 51 | exit ${EXIT_FAILURE}; 52 | fi 53 | 54 | LOCAL_LIB_UPPER=`echo "${LOCAL_LIB}" | tr "[a-z]" "[A-Z]"`; 55 | # Note that sed on FreeBSD does not support \s hence that we use [[:space:]] instead. 56 | LOCAL_LIB_VERSION=`grep -A 2 AC_INIT ${LOCAL_LIB}-$$/configure.ac | tail -n 1 | sed 's/^[[:space:]]*\[\([0-9]*\)\],[[:space:]]*$/\1/'`; 57 | LOCAL_LIB_MAKEFILE_AM="${LOCAL_LIB}/Makefile.am"; 58 | 59 | cp ${LOCAL_LIB}-$$/${LOCAL_LIB}/*.[chly] ${LOCAL_LIB}; 60 | cp ${LOCAL_LIB}-$$/${LOCAL_LIB_MAKEFILE_AM} ${LOCAL_LIB_MAKEFILE_AM}; 61 | 62 | # Make the necessary changes to libyal/Makefile.am 63 | 64 | SED_SCRIPT="/AM_CPPFLAGS = / { 65 | i\\ 66 | if HAVE_LOCAL_${LOCAL_LIB_UPPER} 67 | } 68 | 69 | /lib_LTLIBRARIES = / { 70 | s/lib_LTLIBRARIES/noinst_LTLIBRARIES/ 71 | } 72 | 73 | /${LOCAL_LIB}\.c/ { 74 | d 75 | } 76 | 77 | /${LOCAL_LIB}_la_LIBADD/ { 78 | :loop1 79 | /${LOCAL_LIB}_la_LDFLAGS/ { 80 | N 81 | i\\ 82 | endif 83 | d 84 | } 85 | /${LOCAL_LIB}_la_LDFLAGS/ !{ 86 | N 87 | b loop1 88 | } 89 | } 90 | 91 | /${LOCAL_LIB}_la_LDFLAGS/ { 92 | N 93 | i\\ 94 | endif 95 | d 96 | } 97 | 98 | /DISTCLEANFILES = / { 99 | n 100 | /${LOCAL_LIB}_definitions.h/ { 101 | d 102 | } 103 | }"; 104 | echo "${SED_SCRIPT}" >> ${LOCAL_LIB}-$$.sed; 105 | sed -i'~' -f ${LOCAL_LIB}-$$.sed ${LOCAL_LIB_MAKEFILE_AM}; 106 | rm -f ${LOCAL_LIB}-$$.sed; 107 | 108 | sed -i'~' "/AM_CPPFLAGS = /,/noinst_LTLIBRARIES = / { N; s/\\\\\\n.@${LOCAL_LIB_UPPER}_DLL_EXPORT@//; P; D; }" ${LOCAL_LIB_MAKEFILE_AM}; 109 | sed -i'~' "/${LOCAL_LIB}_definitions.h.in/d" ${LOCAL_LIB_MAKEFILE_AM}; 110 | sed -i'~' "/${LOCAL_LIB}\\.rc/d" ${LOCAL_LIB_MAKEFILE_AM}; 111 | 112 | if test ${LOCAL_LIB} = "libfplist"; 113 | then 114 | # TODO: make this more generic to strip the last \\ 115 | sed -i'~' '/EXTRA_DIST = /,/^$/s/libfplist_xml_scanner.c \\/libfplist_xml_scanner.c/' ${LOCAL_LIB_MAKEFILE_AM}; 116 | 117 | elif test ${LOCAL_LIB} = "libodraw"; 118 | then 119 | # TODO: make this more generic to strip the last \\ 120 | sed -i'~' '/EXTRA_DIST = /,/^$/s/libodraw_cue_scanner.c \\/libodraw_cue_scanner.c/' ${LOCAL_LIB_MAKEFILE_AM}; 121 | 122 | else 123 | sed -i'~' '/EXTRA_DIST = /,/^$/d' ${LOCAL_LIB_MAKEFILE_AM}; 124 | fi 125 | 126 | SED_SCRIPT="/^$/ { 127 | x 128 | N 129 | /endif$/ { 130 | a\\ 131 | 132 | D 133 | } 134 | }"; 135 | echo "${SED_SCRIPT}" >> ${LOCAL_LIB}-$$.sed; 136 | sed -i'~' -f ${LOCAL_LIB}-$$.sed ${LOCAL_LIB_MAKEFILE_AM}; 137 | rm -f ${LOCAL_LIB}-$$.sed; 138 | 139 | # Make the necessary changes to libcfile/Makefile.am 140 | if test ${LOCAL_LIB} = "libcfile"; 141 | then 142 | if ! test -f "m4/libuna.m4"; 143 | then 144 | sed -i'~' 's?@LIBUNA_CPPFLAGS@?-I../libuna -I$(top_srcdir)/libuna?' ${LOCAL_LIB_MAKEFILE_AM}; 145 | fi 146 | fi 147 | 148 | # Make the necessary changes to libfplist/Makefile.am 149 | if test ${LOCAL_LIB} = "libfplist"; 150 | then 151 | if test -f "m4/libfdatetime.m4"; 152 | then 153 | sed -i'~' '/@LIBFGUID_CPPFLAGS@/{h; s/FGUID/FDATETIME/; p; g;}' ${LOCAL_LIB_MAKEFILE_AM}; 154 | fi 155 | fi 156 | 157 | # Make the necessary changes to libfvalue/Makefile.am 158 | if test ${LOCAL_LIB} = "libfvalue"; 159 | then 160 | if ! test -f "m4/libfdatetime.m4"; 161 | then 162 | sed -i'~' '/@LIBFDATETIME_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM}; 163 | fi 164 | if ! test -f "m4/libfguid.m4"; 165 | then 166 | sed -i'~' '/@LIBFGUID_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM}; 167 | fi 168 | if ! test -f "m4/libfwnt.m4"; 169 | then 170 | sed -i'~' '/@LIBFWNT_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM}; 171 | fi 172 | if ! test -f "m4/libuna.m4"; 173 | then 174 | sed -i'~' '/@LIBUNA_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM}; 175 | fi 176 | fi 177 | 178 | # Make the necessary changes to libsmraw/Makefile.am 179 | if test ${LOCAL_LIB} = "libsmraw"; 180 | then 181 | if test -f "m4/libfdatetime.m4"; 182 | then 183 | sed -i'~' '/@LIBFVALUE_CPPFLAGS@/{h; s/FVALUE/FDATETIME/; p; g;}' ${LOCAL_LIB_MAKEFILE_AM}; 184 | fi 185 | if test -f "m4/libfguid.m4"; 186 | then 187 | sed -i'~' '/@LIBFVALUE_CPPFLAGS@/{h; s/FVALUE/FGUID/; p; g;}' ${LOCAL_LIB_MAKEFILE_AM}; 188 | fi 189 | fi 190 | 191 | # Remove libyal/libyal.c 192 | rm -f ${LOCAL_LIB}/${LOCAL_LIB}.c; 193 | 194 | # Make the necessary changes to libyal/libyal_defitions.h 195 | cp ${LOCAL_LIB}-$$/${LOCAL_LIB}/${LOCAL_LIB}_definitions.h.in ${LOCAL_LIB}/${LOCAL_LIB}_definitions.h; 196 | sed -i'~' "s/@VERSION@/${LOCAL_LIB_VERSION}/" ${LOCAL_LIB}/${LOCAL_LIB}_definitions.h; 197 | 198 | rm -rf ${LOCAL_LIB}-$$; 199 | done 200 | 201 | IFS=$OLDIFS; 202 | 203 | exit ${EXIT_SUCCESS}; 204 | 205 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -I../include -I$(top_srcdir)/include \ 3 | -I../common -I$(top_srcdir)/common \ 4 | @LIBCERROR_CPPFLAGS@ \ 5 | @LIBFOLE_DLL_IMPORT@ 6 | 7 | TESTS = \ 8 | test_library.sh 9 | 10 | check_SCRIPTS = \ 11 | test_library.sh \ 12 | test_manpage.sh \ 13 | test_runner.sh 14 | 15 | EXTRA_DIST = \ 16 | $(check_SCRIPTS) 17 | 18 | check_PROGRAMS = \ 19 | fole_test_error \ 20 | fole_test_support \ 21 | fole_test_value_type 22 | 23 | fole_test_error_SOURCES = \ 24 | fole_test_error.c \ 25 | fole_test_libcerror.h \ 26 | fole_test_libfole.h \ 27 | fole_test_macros.h \ 28 | fole_test_unused.h 29 | 30 | fole_test_error_LDADD = \ 31 | ../libfole/libfole.la 32 | 33 | fole_test_support_SOURCES = \ 34 | fole_test_libfole.h \ 35 | fole_test_macros.h \ 36 | fole_test_support.c \ 37 | fole_test_unused.h 38 | 39 | fole_test_support_LDADD = \ 40 | ../libfole/libfole.la 41 | 42 | fole_test_value_type_SOURCES = \ 43 | fole_test_libcerror.h \ 44 | fole_test_libfole.h \ 45 | fole_test_macros.h \ 46 | fole_test_memory.c fole_test_memory.h \ 47 | fole_test_unused.h \ 48 | fole_test_value_type.c 49 | 50 | fole_test_value_type_LDADD = \ 51 | ../libfole/libfole.la 52 | 53 | DISTCLEANFILES = \ 54 | Makefile \ 55 | Makefile.in 56 | 57 | -------------------------------------------------------------------------------- /tests/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to build from source 3 | # 4 | # Version: 20201121 5 | 6 | set -e 7 | 8 | ./synclibs.sh --use-head 9 | ./autogen.sh 10 | ./configure "$@" 11 | make > /dev/null 12 | 13 | -------------------------------------------------------------------------------- /tests/fole_test_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library error functions test program 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 27 | #include 28 | #endif 29 | 30 | #include "fole_test_libfole.h" 31 | #include "fole_test_macros.h" 32 | #include "fole_test_unused.h" 33 | 34 | /* Tests the libfole_error_free function 35 | * Returns 1 if successful or 0 if not 36 | */ 37 | int fole_test_error_free( 38 | void ) 39 | { 40 | /* Test invocation of function only 41 | */ 42 | libfole_error_free( 43 | NULL ); 44 | 45 | return( 1 ); 46 | } 47 | 48 | /* Tests the libfole_error_fprint function 49 | * Returns 1 if successful or 0 if not 50 | */ 51 | int fole_test_error_fprint( 52 | void ) 53 | { 54 | /* Test invocation of function only 55 | */ 56 | libfole_error_fprint( 57 | NULL, 58 | NULL ); 59 | 60 | return( 1 ); 61 | } 62 | 63 | /* Tests the libfole_error_sprint function 64 | * Returns 1 if successful or 0 if not 65 | */ 66 | int fole_test_error_sprint( 67 | void ) 68 | { 69 | /* Test invocation of function only 70 | */ 71 | libfole_error_sprint( 72 | NULL, 73 | NULL, 74 | 0 ); 75 | 76 | return( 1 ); 77 | } 78 | 79 | /* Tests the libfole_error_backtrace_fprint function 80 | * Returns 1 if successful or 0 if not 81 | */ 82 | int fole_test_error_backtrace_fprint( 83 | void ) 84 | { 85 | /* Test invocation of function only 86 | */ 87 | libfole_error_backtrace_fprint( 88 | NULL, 89 | NULL ); 90 | 91 | return( 1 ); 92 | } 93 | 94 | /* Tests the libfole_error_backtrace_sprint function 95 | * Returns 1 if successful or 0 if not 96 | */ 97 | int fole_test_error_backtrace_sprint( 98 | void ) 99 | { 100 | /* Test invocation of function only 101 | */ 102 | libfole_error_backtrace_sprint( 103 | NULL, 104 | NULL, 105 | 0 ); 106 | 107 | return( 1 ); 108 | } 109 | 110 | /* The main program 111 | */ 112 | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) 113 | int wmain( 114 | int argc FOLE_TEST_ATTRIBUTE_UNUSED, 115 | wchar_t * const argv[] FOLE_TEST_ATTRIBUTE_UNUSED ) 116 | #else 117 | int main( 118 | int argc FOLE_TEST_ATTRIBUTE_UNUSED, 119 | char * const argv[] FOLE_TEST_ATTRIBUTE_UNUSED ) 120 | #endif 121 | { 122 | FOLE_TEST_UNREFERENCED_PARAMETER( argc ) 123 | FOLE_TEST_UNREFERENCED_PARAMETER( argv ) 124 | 125 | FOLE_TEST_RUN( 126 | "libfole_error_free", 127 | fole_test_error_free ); 128 | 129 | FOLE_TEST_RUN( 130 | "libfole_error_fprint", 131 | fole_test_error_fprint ); 132 | 133 | FOLE_TEST_RUN( 134 | "libfole_error_sprint", 135 | fole_test_error_sprint ); 136 | 137 | FOLE_TEST_RUN( 138 | "libfole_error_backtrace_fprint", 139 | fole_test_error_backtrace_fprint ); 140 | 141 | FOLE_TEST_RUN( 142 | "libfole_error_backtrace_sprint", 143 | fole_test_error_backtrace_sprint ); 144 | 145 | return( EXIT_SUCCESS ); 146 | 147 | on_error: 148 | return( EXIT_FAILURE ); 149 | } 150 | 151 | -------------------------------------------------------------------------------- /tests/fole_test_libcerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcerror header wrapper 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _FOLE_TEST_LIBCERROR_H ) 23 | #define _FOLE_TEST_LIBCERROR_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCERROR for local use of libcerror 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCERROR ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCERROR_DLL_IMPORT 39 | * before including libcerror.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCERROR_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCERROR ) */ 48 | 49 | #endif /* !defined( _FOLE_TEST_LIBCERROR_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /tests/fole_test_libfole.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libfole header wrapper 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _FOLE_TEST_LIBFOLE_H ) 23 | #define _FOLE_TEST_LIBFOLE_H 24 | 25 | #include 26 | 27 | #include 28 | 29 | #endif /* !defined( _FOLE_TEST_LIBFOLE_H ) */ 30 | 31 | -------------------------------------------------------------------------------- /tests/fole_test_memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory allocation functions for testing 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | 24 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 25 | #include 26 | #endif 27 | 28 | #if defined( HAVE_GNU_DL_DLSYM ) && defined( __GNUC__ ) 29 | #define __USE_GNU 30 | #include 31 | #undef __USE_GNU 32 | #endif 33 | 34 | #include "fole_test_memory.h" 35 | 36 | #if defined( HAVE_FOLE_TEST_MEMORY ) 37 | 38 | static void *(*fole_test_real_malloc)(size_t) = NULL; 39 | static void *(*fole_test_real_memcpy)(void *, const void *, size_t) = NULL; 40 | static void *(*fole_test_real_memset)(void *, int, size_t) = NULL; 41 | static void *(*fole_test_real_realloc)(void *, size_t) = NULL; 42 | 43 | int fole_test_malloc_attempts_before_fail = -1; 44 | int fole_test_memcpy_attempts_before_fail = -1; 45 | int fole_test_memset_attempts_before_fail = -1; 46 | int fole_test_realloc_attempts_before_fail = -1; 47 | 48 | /* Custom malloc for testing memory error cases 49 | * Note this function might fail if compiled with optimation 50 | * Returns a pointer to newly allocated data or NULL 51 | */ 52 | void *malloc( 53 | size_t size ) 54 | { 55 | void *ptr = NULL; 56 | 57 | if( fole_test_real_malloc == NULL ) 58 | { 59 | fole_test_real_malloc = dlsym( 60 | RTLD_NEXT, 61 | "malloc" ); 62 | } 63 | if( fole_test_malloc_attempts_before_fail == 0 ) 64 | { 65 | fole_test_malloc_attempts_before_fail = -1; 66 | 67 | return( NULL ); 68 | } 69 | else if( fole_test_malloc_attempts_before_fail > 0 ) 70 | { 71 | fole_test_malloc_attempts_before_fail--; 72 | } 73 | ptr = fole_test_real_malloc( 74 | size ); 75 | 76 | return( ptr ); 77 | } 78 | 79 | /* Custom memcpy for testing memory error cases 80 | * Note this function might fail if compiled with optimation and as a shared libary 81 | * Returns a pointer to newly allocated data or NULL 82 | */ 83 | void *memcpy( 84 | void *destination, 85 | const void *source, 86 | size_t size ) 87 | { 88 | if( fole_test_real_memcpy == NULL ) 89 | { 90 | fole_test_real_memcpy = dlsym( 91 | RTLD_NEXT, 92 | "memcpy" ); 93 | } 94 | if( fole_test_memcpy_attempts_before_fail == 0 ) 95 | { 96 | fole_test_memcpy_attempts_before_fail = -1; 97 | 98 | return( NULL ); 99 | } 100 | else if( fole_test_memcpy_attempts_before_fail > 0 ) 101 | { 102 | fole_test_memcpy_attempts_before_fail--; 103 | } 104 | destination = fole_test_real_memcpy( 105 | destination, 106 | source, 107 | size ); 108 | 109 | return( destination ); 110 | } 111 | 112 | /* Custom memset for testing memory error cases 113 | * Note this function might fail if compiled with optimation and as a shared libary 114 | * Returns a pointer to newly allocated data or NULL 115 | */ 116 | void *memset( 117 | void *ptr, 118 | int constant, 119 | size_t size ) 120 | { 121 | if( fole_test_real_memset == NULL ) 122 | { 123 | fole_test_real_memset = dlsym( 124 | RTLD_NEXT, 125 | "memset" ); 126 | } 127 | if( fole_test_memset_attempts_before_fail == 0 ) 128 | { 129 | fole_test_memset_attempts_before_fail = -1; 130 | 131 | return( NULL ); 132 | } 133 | else if( fole_test_memset_attempts_before_fail > 0 ) 134 | { 135 | fole_test_memset_attempts_before_fail--; 136 | } 137 | ptr = fole_test_real_memset( 138 | ptr, 139 | constant, 140 | size ); 141 | 142 | return( ptr ); 143 | } 144 | 145 | /* Custom realloc for testing memory error cases 146 | * Note this function might fail if compiled with optimation 147 | * Returns a pointer to reallocated data or NULL 148 | */ 149 | void *realloc( 150 | void *ptr, 151 | size_t size ) 152 | { 153 | if( fole_test_real_realloc == NULL ) 154 | { 155 | fole_test_real_realloc = dlsym( 156 | RTLD_NEXT, 157 | "realloc" ); 158 | } 159 | if( fole_test_realloc_attempts_before_fail == 0 ) 160 | { 161 | fole_test_realloc_attempts_before_fail = -1; 162 | 163 | return( NULL ); 164 | } 165 | else if( fole_test_realloc_attempts_before_fail > 0 ) 166 | { 167 | fole_test_realloc_attempts_before_fail--; 168 | } 169 | ptr = fole_test_real_realloc( 170 | ptr, 171 | size ); 172 | 173 | return( ptr ); 174 | } 175 | 176 | #endif /* defined( HAVE_FOLE_TEST_MEMORY ) */ 177 | 178 | -------------------------------------------------------------------------------- /tests/fole_test_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory allocation functions for testing 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _FOLE_TEST_MEMORY_H ) 23 | #define _FOLE_TEST_MEMORY_H 24 | 25 | #include 26 | 27 | #if defined( __cplusplus ) 28 | extern "C" { 29 | #endif 30 | 31 | #if defined( HAVE_GNU_DL_DLSYM ) && defined( __GNUC__ ) && !defined( LIBFOLE_DLL_IMPORT ) && !defined( __arm__ ) && !defined( __clang__ ) && !defined( __CYGWIN__ ) && !defined( __hppa__ ) && !defined( __loongarch__ ) && !defined( __mips__ ) && !defined( __riscv ) && !defined( __sparc__ ) && !defined( HAVE_ASAN ) 32 | #define HAVE_FOLE_TEST_MEMORY 1 33 | #endif 34 | 35 | #if defined( HAVE_FOLE_TEST_MEMORY ) 36 | 37 | extern int fole_test_malloc_attempts_before_fail; 38 | 39 | extern int fole_test_memcpy_attempts_before_fail; 40 | 41 | extern int fole_test_memset_attempts_before_fail; 42 | 43 | extern int fole_test_realloc_attempts_before_fail; 44 | 45 | #endif /* defined( HAVE_FOLE_TEST_MEMORY ) */ 46 | 47 | #if defined( __cplusplus ) 48 | } 49 | #endif 50 | 51 | #endif /* !defined( _FOLE_TEST_MEMORY_H ) */ 52 | 53 | -------------------------------------------------------------------------------- /tests/fole_test_support.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library support functions test program 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 28 | #include 29 | #endif 30 | 31 | #include "fole_test_libfole.h" 32 | #include "fole_test_macros.h" 33 | #include "fole_test_unused.h" 34 | 35 | /* Tests the libfole_get_version function 36 | * Returns 1 if successful or 0 if not 37 | */ 38 | int fole_test_get_version( 39 | void ) 40 | { 41 | const char *version_string = NULL; 42 | int result = 0; 43 | 44 | version_string = libfole_get_version(); 45 | 46 | result = narrow_string_compare( 47 | version_string, 48 | LIBFOLE_VERSION_STRING, 49 | 9 ); 50 | 51 | FOLE_TEST_ASSERT_EQUAL_INT( 52 | "result", 53 | result, 54 | 0 ); 55 | 56 | return( 1 ); 57 | 58 | on_error: 59 | return( 0 ); 60 | } 61 | 62 | /* The main program 63 | */ 64 | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) 65 | int wmain( 66 | int argc FOLE_TEST_ATTRIBUTE_UNUSED, 67 | wchar_t * const argv[] FOLE_TEST_ATTRIBUTE_UNUSED ) 68 | #else 69 | int main( 70 | int argc FOLE_TEST_ATTRIBUTE_UNUSED, 71 | char * const argv[] FOLE_TEST_ATTRIBUTE_UNUSED ) 72 | #endif 73 | { 74 | FOLE_TEST_UNREFERENCED_PARAMETER( argc ) 75 | FOLE_TEST_UNREFERENCED_PARAMETER( argv ) 76 | 77 | FOLE_TEST_RUN( 78 | "libfole_get_version", 79 | fole_test_get_version ); 80 | 81 | return( EXIT_SUCCESS ); 82 | 83 | on_error: 84 | return( EXIT_FAILURE ); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /tests/fole_test_unused.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to silence compiler warnings about unused function attributes/parameters. 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _FOLE_TEST_UNUSED_H ) 23 | #define _FOLE_TEST_UNUSED_H 24 | 25 | #include 26 | 27 | #if !defined( FOLE_TEST_ATTRIBUTE_UNUSED ) 28 | 29 | #if defined( __GNUC__ ) && __GNUC__ >= 3 30 | #define FOLE_TEST_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 31 | 32 | #else 33 | #define FOLE_TEST_ATTRIBUTE_UNUSED 34 | 35 | #endif /* defined( __GNUC__ ) && __GNUC__ >= 3 */ 36 | 37 | #endif /* !defined( FOLE_TEST_ATTRIBUTE_UNUSED ) */ 38 | 39 | #if defined( _MSC_VER ) 40 | #define FOLE_TEST_UNREFERENCED_PARAMETER( parameter ) \ 41 | UNREFERENCED_PARAMETER( parameter ); 42 | 43 | #else 44 | #define FOLE_TEST_UNREFERENCED_PARAMETER( parameter ) \ 45 | /* parameter */ 46 | 47 | #endif /* defined( _MSC_VER ) */ 48 | 49 | #endif /* !defined( _FOLE_TEST_UNUSED_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /tests/fole_test_value_type.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library value_type type test program 3 | * 4 | * Copyright (C) 2008-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 27 | #include 28 | #endif 29 | 30 | #include "fole_test_libcerror.h" 31 | #include "fole_test_libfole.h" 32 | #include "fole_test_macros.h" 33 | #include "fole_test_memory.h" 34 | #include "fole_test_unused.h" 35 | 36 | /* Tests the libfole_value_type_get_identifier function 37 | * Returns 1 if successful or 0 if not 38 | */ 39 | int fole_test_value_type_get_identifier( 40 | void ) 41 | { 42 | /* Test invocation of function only 43 | */ 44 | libfole_value_type_get_identifier( 45 | 0x0001 ); 46 | 47 | return( 1 ); 48 | } 49 | 50 | /* Tests the libfole_value_type_get_description function 51 | * Returns 1 if successful or 0 if not 52 | */ 53 | int fole_test_value_type_get_description( 54 | void ) 55 | { 56 | /* Test invocation of function only 57 | */ 58 | libfole_value_type_get_description( 59 | 0x0001 ); 60 | 61 | return( 1 ); 62 | } 63 | 64 | /* The main program 65 | */ 66 | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) 67 | int wmain( 68 | int argc FOLE_TEST_ATTRIBUTE_UNUSED, 69 | wchar_t * const argv[] FOLE_TEST_ATTRIBUTE_UNUSED ) 70 | #else 71 | int main( 72 | int argc FOLE_TEST_ATTRIBUTE_UNUSED, 73 | char * const argv[] FOLE_TEST_ATTRIBUTE_UNUSED ) 74 | #endif 75 | { 76 | FOLE_TEST_UNREFERENCED_PARAMETER( argc ) 77 | FOLE_TEST_UNREFERENCED_PARAMETER( argv ) 78 | 79 | FOLE_TEST_RUN( 80 | "libfole_value_type_get_identifier", 81 | fole_test_value_type_get_identifier ); 82 | 83 | FOLE_TEST_RUN( 84 | "libfole_value_type_get_description", 85 | fole_test_value_type_get_description ); 86 | 87 | return( EXIT_SUCCESS ); 88 | 89 | on_error: 90 | return( EXIT_FAILURE ); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /tests/lsan.suppressions: -------------------------------------------------------------------------------- 1 | leak:/lib*/libpython* 2 | -------------------------------------------------------------------------------- /tests/pkgbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to build a MacOS pkg 3 | # 4 | # Version: 20201121 5 | 6 | set -e 7 | 8 | make install DESTDIR=${PWD}/osx-pkg 9 | mkdir -p ${PWD}/osx-pkg/usr/share/doc/libfole 10 | cp AUTHORS COPYING COPYING.LESSER NEWS README ${PWD}/osx-pkg/usr/share/doc/libfole 11 | 12 | VERSION=`sed '5!d; s/^ \[//;s/\],$//' configure.ac` 13 | pkgbuild --root osx-pkg --identifier com.github.libyal.libfole --version ${VERSION} --ownership recommended ../libfole-${VERSION}.pkg 14 | 15 | -------------------------------------------------------------------------------- /tests/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to run tests 3 | # 4 | # Version: 20201121 5 | 6 | if test -f ${PWD}/libfole/.libs/libfole.1.dylib && test -f ./pyfole/.libs/pyfole.so; 7 | then 8 | install_name_tool -change /usr/local/lib/libfole.1.dylib ${PWD}/libfole/.libs/libfole.1.dylib ./pyfole/.libs/pyfole.so; 9 | fi 10 | 11 | make check CHECK_WITH_STDERR=1; 12 | RESULT=$?; 13 | 14 | if test ${RESULT} -ne 0 && test -f tests/test-suite.log; 15 | then 16 | cat tests/test-suite.log; 17 | fi 18 | exit ${RESULT}; 19 | 20 | -------------------------------------------------------------------------------- /tests/syncsharedlibs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script that synchronizes the shared library dependencies 3 | # 4 | # Version: 20201121 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | 9 | GIT_URL_PREFIX="https://github.com/libyal"; 10 | SHARED_LIBS="libcerror"; 11 | 12 | USE_HEAD=""; 13 | 14 | if test "$1" = "--use-head"; 15 | then 16 | USE_HEAD="--use-head"; 17 | fi 18 | 19 | OLDIFS=$IFS; 20 | IFS=" "; 21 | 22 | for SHARED_LIB in ${SHARED_LIBS}; 23 | do 24 | GIT_URL="${GIT_URL_PREFIX}/${SHARED_LIB}.git"; 25 | 26 | git clone --quiet ${GIT_URL} ${SHARED_LIB}-$$; 27 | 28 | if ! test -d ${SHARED_LIB}-$$; 29 | then 30 | echo "Unable to git clone: ${GIT_URL}"; 31 | 32 | IFS=$OLDIFS; 33 | 34 | exit ${EXIT_FAILURE}; 35 | fi 36 | (cd ${SHARED_LIB}-$$ && git fetch --quiet --all --tags --prune) 37 | 38 | LATEST_TAG=`cd ${SHARED_LIB}-$$ && git describe --tags --abbrev=0`; 39 | 40 | if test -n ${LATEST_TAG} && test -z ${USE_HEAD}; 41 | then 42 | echo "Synchronizing: ${SHARED_LIB} from ${GIT_URL} tag ${LATEST_TAG}"; 43 | 44 | (cd ${SHARED_LIB}-$$ && git checkout --quiet tags/${LATEST_TAG}); 45 | else 46 | echo "Synchronizing: ${SHARED_LIB} from ${GIT_URL} HEAD"; 47 | fi 48 | 49 | (cd ${SHARED_LIB}-$$ && ./synclibs.sh ${USE_HEAD} && ./autogen.sh); 50 | 51 | CONFIGURE_OPTIONS=""; 52 | 53 | (cd ${SHARED_LIB}-$$ && ./configure --help | grep -- '--enable-wide-character-type' > /dev/null); 54 | 55 | if test $? -eq 0; 56 | then 57 | CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} --enable-wide-character-type"; 58 | fi 59 | 60 | (cd ${SHARED_LIB}-$$ && ./configure --prefix=/usr ${CONFIGURE_OPTIONS} && make && sudo make install); 61 | 62 | rm -rf ${SHARED_LIB}-$$; 63 | done 64 | 65 | IFS=$OLDIFS; 66 | 67 | exit ${EXIT_SUCCESS}; 68 | 69 | -------------------------------------------------------------------------------- /tests/test_library.ps1: -------------------------------------------------------------------------------- 1 | # Tests library functions and types. 2 | # 3 | # Version: 20230410 4 | 5 | $ExitSuccess = 0 6 | $ExitFailure = 1 7 | $ExitIgnore = 77 8 | 9 | $LibraryTests = "error support value_type" 10 | $LibraryTestsWithInput = "" 11 | $OptionSets = "" 12 | 13 | $InputGlob = "*" 14 | 15 | Function GetTestExecutablesDirectory 16 | { 17 | $TestExecutablesDirectory = "" 18 | 19 | ForEach (${VSDirectory} in ("msvscpp", "vs2008", "vs2010", "vs2012", "vs2013", "vs2015", "vs2017", "vs2019", "vs2022")) 20 | { 21 | ForEach (${VSConfiguration} in ("Release", "VSDebug")) 22 | { 23 | ForEach (${VSPlatform} in ("Win32", "x64")) 24 | { 25 | $TestExecutablesDirectory = "..\${VSDirectory}\${VSConfiguration}\${VSPlatform}" 26 | 27 | If (Test-Path ${TestExecutablesDirectory}) 28 | { 29 | Return ${TestExecutablesDirectory} 30 | } 31 | } 32 | $TestExecutablesDirectory = "..\${VSDirectory}\${VSConfiguration}" 33 | 34 | If (Test-Path ${TestExecutablesDirectory}) 35 | { 36 | Return ${TestExecutablesDirectory} 37 | } 38 | } 39 | } 40 | Return ${TestExecutablesDirectory} 41 | } 42 | 43 | Function ReadIgnoreList 44 | { 45 | param( [string]$TestProfileDirectory ) 46 | 47 | $IgnoreFile = "${TestProfileDirectory}\ignore" 48 | $IgnoreList = "" 49 | 50 | If (Test-Path -Path ${IgnoreFile} -PathType "Leaf") 51 | { 52 | $IgnoreList = Get-Content -Path ${IgnoreFile} | Where {$_ -notmatch '^#.*'} 53 | } 54 | Return $IgnoreList 55 | } 56 | 57 | Function RunTest 58 | { 59 | param( [string]$TestType ) 60 | 61 | $TestDescription = "Testing: ${TestName}" 62 | $TestExecutable = "${TestExecutablesDirectory}\fole_test_${TestName}.exe" 63 | 64 | If (-Not (Test-Path -Path ${TestExecutable} -PathType "Leaf")) 65 | { 66 | Write-Host "${TestDescription} (" -nonewline 67 | Write-Host "SKIP" -foreground Cyan -nonewline 68 | Write-Host ")" 69 | 70 | Return ${ExitIgnore} 71 | } 72 | $Output = Invoke-Expression ${TestExecutable} 73 | $Result = ${LastExitCode} 74 | 75 | If (${Result} -ne ${ExitSuccess}) 76 | { 77 | Write-Host ${Output} -foreground Red 78 | } 79 | Write-Host "${TestDescription} (" -nonewline 80 | 81 | If (${Result} -ne ${ExitSuccess}) 82 | { 83 | Write-Host "FAIL" -foreground Red -nonewline 84 | } 85 | Else 86 | { 87 | Write-Host "PASS" -foreground Green -nonewline 88 | } 89 | Write-Host ")" 90 | 91 | Return ${Result} 92 | } 93 | 94 | Function RunTestWithInput 95 | { 96 | param( [string]$TestType ) 97 | 98 | $TestDescription = "Testing: ${TestName}" 99 | $TestExecutable = "${TestExecutablesDirectory}\fole_test_${TestName}.exe" 100 | 101 | If (-Not (Test-Path -Path ${TestExecutable} -PathType "Leaf")) 102 | { 103 | Write-Host "${TestDescription} (" -nonewline 104 | Write-Host "SKIP" -foreground Cyan -nonewline 105 | Write-Host ")" 106 | 107 | Return ${ExitIgnore} 108 | } 109 | $TestProfileDirectory = "input\.libfole" 110 | 111 | If (-Not (Test-Path -Path ${TestProfileDirectory} -PathType "Container")) 112 | { 113 | New-Item -ItemType "directory" -Path ${TestProfileDirectory} 114 | } 115 | $IgnoreList = ReadIgnoreList ${TestProfileDirectory} 116 | 117 | $Result = ${ExitSuccess} 118 | 119 | ForEach ($TestSetInputDirectory in Get-ChildItem -Path "input" -Exclude ".*") 120 | { 121 | If (-Not (Test-Path -Path ${TestSetInputDirectory} -PathType "Container")) 122 | { 123 | Continue 124 | } 125 | If (${TestSetInputDirectory} -Contains ${IgnoreList}) 126 | { 127 | Continue 128 | } 129 | $TestSetName = ${TestSetInputDirectory}.Name 130 | 131 | If (Test-Path -Path "${TestProfileDirectory}\${TestSetName}\files" -PathType "Leaf") 132 | { 133 | $InputFiles = Get-Content -Path "${TestProfileDirectory}\${TestSetName}\files" | Where {$_ -ne ""} 134 | } 135 | Else 136 | { 137 | $InputFiles = Get-ChildItem -Path ${TestSetInputDirectory} -Include ${InputGlob} 138 | } 139 | ForEach ($InputFile in ${InputFiles}) 140 | { 141 | $TestedWithOptions = $False 142 | 143 | ForEach ($OptionSet in ${OptionSets} -split " ") 144 | { 145 | $InputFileName = ${InputFile}.Name 146 | $TestDataOptionFile = "${TestProfileDirectory}\${TestSetName}\${InputFileName}.${OptionSet}" 147 | 148 | If (-Not (Test-Path -Path "${TestDataOptionFile}" -PathType "Leaf")) 149 | { 150 | Continue 151 | } 152 | $InputOptions = Get-content -Path "${TestDataOptionFile}" -First 1 153 | 154 | $Output = Invoke-Expression "${TestExecutable} ${InputOptions} ${InputFile}" 155 | $Result = $LastExitCode 156 | 157 | If (${Result} -ne ${ExitSuccess}) 158 | { 159 | Break 160 | } 161 | $TestedWithOptions = $True 162 | } 163 | If ((${Result} -eq ${ExitSuccess}) -And (-Not (${TestedWithOptions}))) 164 | { 165 | $Output = Invoke-Expression "${TestExecutable} ${InputFile}" 166 | $Result = ${LastExitCode} 167 | } 168 | If (${Result} -ne ${ExitSuccess}) 169 | { 170 | Break 171 | } 172 | } 173 | If (${Result} -ne ${ExitSuccess}) 174 | { 175 | Break 176 | } 177 | } 178 | If (${Result} -ne ${ExitSuccess}) 179 | { 180 | Write-Host ${Output} -foreground Red 181 | } 182 | Write-Host "${TestDescription} (" -nonewline 183 | 184 | If (${Result} -ne ${ExitSuccess}) 185 | { 186 | Write-Host "FAIL" -foreground Red -nonewline 187 | } 188 | Else 189 | { 190 | Write-Host "PASS" -foreground Green -nonewline 191 | } 192 | Write-Host ")" 193 | 194 | Return ${Result} 195 | } 196 | 197 | $TestExecutablesDirectory = GetTestExecutablesDirectory 198 | 199 | If (-Not (Test-Path ${TestExecutablesDirectory})) 200 | { 201 | Write-Host "Missing test executables directory." -foreground Red 202 | 203 | Exit ${ExitFailure} 204 | } 205 | 206 | $Result = ${ExitIgnore} 207 | 208 | Foreach (${TestName} in ${LibraryTests} -split " ") 209 | { 210 | # Split will return an array of a single empty string when LibraryTests is empty. 211 | If (-Not (${TestName})) 212 | { 213 | Continue 214 | } 215 | $Result = RunTest ${TestName} 216 | 217 | If ((${Result} -ne ${ExitSuccess}) -And (${Result} -ne ${ExitIgnore})) 218 | { 219 | Break 220 | } 221 | } 222 | 223 | Foreach (${TestName} in ${LibraryTestsWithInput} -split " ") 224 | { 225 | # Split will return an array of a single empty string when LibraryTestsWithInput is empty. 226 | If (-Not (${TestName})) 227 | { 228 | Continue 229 | } 230 | If (Test-Path -Path "input" -PathType "Container") 231 | { 232 | $Result = RunTestWithInput ${TestName} 233 | } 234 | Else 235 | { 236 | $Result = RunTest ${TestName} 237 | } 238 | If ((${Result} -ne ${ExitSuccess}) -And (${Result} -ne ${ExitIgnore})) 239 | { 240 | Break 241 | } 242 | } 243 | 244 | Exit ${Result} 245 | 246 | -------------------------------------------------------------------------------- /tests/test_library.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Tests library functions and types. 3 | # 4 | # Version: 20240413 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | EXIT_IGNORE=77; 9 | 10 | LIBRARY_TESTS="error support value_type"; 11 | LIBRARY_TESTS_WITH_INPUT=""; 12 | OPTION_SETS=(); 13 | 14 | INPUT_GLOB="*"; 15 | 16 | run_test() 17 | { 18 | local TEST_NAME=$1; 19 | 20 | local TEST_DESCRIPTION="Testing: ${TEST_NAME}"; 21 | local TEST_EXECUTABLE="./fole_test_${TEST_NAME}"; 22 | 23 | if ! test -x "${TEST_EXECUTABLE}"; 24 | then 25 | TEST_EXECUTABLE="${TEST_EXECUTABLE}.exe"; 26 | fi 27 | 28 | # TODO: add support for TEST_PROFILE and OPTION_SETS? 29 | run_test_with_arguments "${TEST_DESCRIPTION}" "${TEST_EXECUTABLE}"; 30 | local RESULT=$?; 31 | 32 | return ${RESULT}; 33 | } 34 | 35 | run_test_with_input() 36 | { 37 | local TEST_NAME=$1; 38 | 39 | local TEST_DESCRIPTION="Testing: ${TEST_NAME}"; 40 | local TEST_EXECUTABLE="./fole_test_${TEST_NAME}"; 41 | 42 | if ! test -x "${TEST_EXECUTABLE}"; 43 | then 44 | TEST_EXECUTABLE="${TEST_EXECUTABLE}.exe"; 45 | fi 46 | 47 | if ! test -d "input"; 48 | then 49 | echo "Test input directory not found."; 50 | 51 | return ${EXIT_IGNORE}; 52 | fi 53 | local RESULT=`ls input/* | tr ' ' '\n' | wc -l`; 54 | 55 | if test ${RESULT} -eq ${EXIT_SUCCESS}; 56 | then 57 | echo "No files or directories found in the test input directory"; 58 | 59 | return ${EXIT_IGNORE}; 60 | fi 61 | 62 | local TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "libfole"); 63 | 64 | local IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); 65 | 66 | RESULT=${EXIT_SUCCESS}; 67 | 68 | for TEST_SET_INPUT_DIRECTORY in input/*; 69 | do 70 | if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; 71 | then 72 | continue; 73 | fi 74 | if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; 75 | then 76 | continue; 77 | fi 78 | 79 | local TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); 80 | 81 | if test -f "${TEST_SET_DIRECTORY}/files"; 82 | then 83 | IFS="" read -a INPUT_FILES <<< $(cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"); 84 | else 85 | IFS="" read -a INPUT_FILES <<< $(ls -1d ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}); 86 | fi 87 | for INPUT_FILE in "${INPUT_FILES[@]}"; 88 | do 89 | OPTION_INPUT_FILE="${INPUT_FILE}"; 90 | 91 | if test "${OSTYPE}" = "msys"; 92 | then 93 | # A test executable built with MinGW expects a Windows path. 94 | INPUT_FILE=`echo ${INPUT_FILE} | sed 's?/?\\\\?g'`; 95 | fi 96 | local TESTED_WITH_OPTIONS=0; 97 | 98 | for OPTION_SET in ${OPTION_SETS[@]}; 99 | do 100 | local TEST_DATA_OPTION_FILE=$(get_test_data_option_file "${TEST_SET_DIRECTORY}" "${OPTION_INPUT_FILE}" "${OPTION_SET}"); 101 | 102 | if test -f ${TEST_DATA_OPTION_FILE}; 103 | then 104 | TESTED_WITH_OPTIONS=1; 105 | 106 | IFS=" " read -a OPTIONS <<< $(read_test_data_option_file "${TEST_SET_DIRECTORY}" "${INPUT_FILE}" "${OPTION_SET}"); 107 | 108 | run_test_on_input_file "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "default" "${OPTION_SET}" "${TEST_EXECUTABLE}" "${INPUT_FILE}" "${OPTIONS[@]}"; 109 | RESULT=$?; 110 | 111 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 112 | then 113 | break; 114 | fi 115 | fi 116 | done 117 | 118 | if test ${TESTED_WITH_OPTIONS} -eq 0; 119 | then 120 | run_test_on_input_file "${TEST_SET_DIRECTORY}" "${TEST_DESCRIPTION}" "default" "" "${TEST_EXECUTABLE}" "${INPUT_FILE}"; 121 | RESULT=$?; 122 | fi 123 | 124 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 125 | then 126 | break; 127 | fi 128 | done 129 | 130 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 131 | then 132 | break; 133 | fi 134 | done 135 | 136 | return ${RESULT}; 137 | } 138 | 139 | if test -n "${SKIP_LIBRARY_TESTS}"; 140 | then 141 | exit ${EXIT_IGNORE}; 142 | fi 143 | 144 | TEST_DIRECTORY=`dirname $0`; 145 | 146 | TEST_RUNNER="${TEST_DIRECTORY}/test_runner.sh"; 147 | 148 | if ! test -f "${TEST_RUNNER}"; 149 | then 150 | echo "Missing test runner: ${TEST_RUNNER}"; 151 | 152 | exit ${EXIT_FAILURE}; 153 | fi 154 | 155 | source ${TEST_RUNNER}; 156 | 157 | RESULT=${EXIT_IGNORE}; 158 | 159 | for TEST_NAME in ${LIBRARY_TESTS}; 160 | do 161 | run_test "${TEST_NAME}"; 162 | RESULT=$?; 163 | 164 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 165 | then 166 | break; 167 | fi 168 | done 169 | 170 | if test ${RESULT} -ne ${EXIT_SUCCESS} && test ${RESULT} -ne ${EXIT_IGNORE}; 171 | then 172 | exit ${RESULT}; 173 | fi 174 | 175 | for TEST_NAME in ${LIBRARY_TESTS_WITH_INPUT}; 176 | do 177 | if test -d "input"; 178 | then 179 | run_test_with_input "${TEST_NAME}"; 180 | RESULT=$?; 181 | else 182 | run_test "${TEST_NAME}"; 183 | RESULT=$?; 184 | fi 185 | 186 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 187 | then 188 | break; 189 | fi 190 | done 191 | 192 | exit ${RESULT}; 193 | 194 | -------------------------------------------------------------------------------- /tests/test_manpage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Tests man pages. 3 | # 4 | # Version: 20240413 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | EXIT_IGNORE=77; 9 | 10 | run_test() 11 | { 12 | local INPUT_FILE=$1; 13 | local RESULT=0 14 | 15 | TEST_NAME=`basename ${INPUT_FILE}`; 16 | echo -n "Testing man with input: ${TEST_NAME}"; 17 | 18 | LC_ALL=en_US.UTF-8 MANROFFSEQ='' MANWIDTH=80 man --warnings -E UTF-8 -l -Tutf8 -Z ${INPUT_FILE} > /dev/null 2> ${TMPDIR}/${TEST_NAME}.warnings; 19 | RESULT=$?; 20 | 21 | # For now line break warnings are ignored. 22 | if test -f ${TMPDIR}/${TEST_NAME}.warnings; 23 | then 24 | sed "/can't break line/ d" -i ${TMPDIR}/${TEST_NAME}.warnings; 25 | fi 26 | if test -s ${TMPDIR}/${TEST_NAME}.warnings; 27 | then 28 | RESULT=${EXIT_FAILURE}; 29 | fi 30 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 31 | then 32 | echo " (FAIL)"; 33 | else 34 | echo " (PASS)"; 35 | fi 36 | if test -s ${TMPDIR}/${TEST_NAME}.warnings; 37 | then 38 | cat ${TMPDIR}/${TEST_NAME}.warnings; 39 | fi 40 | return ${RESULT}; 41 | } 42 | 43 | if test "${OSTYPE}" = "msys"; 44 | then 45 | exit ${EXIT_IGNORE}; 46 | fi 47 | 48 | TEST_DIRECTORY=`dirname $0`; 49 | 50 | TEST_RUNNER="${TEST_DIRECTORY}/test_runner.sh"; 51 | 52 | if ! test -f "${TEST_RUNNER}"; 53 | then 54 | echo "Missing test runner: ${TEST_RUNNER}"; 55 | 56 | exit ${EXIT_FAILURE}; 57 | fi 58 | 59 | source ${TEST_RUNNER}; 60 | 61 | assert_availability_binary man; 62 | 63 | RESULT=${EXIT_IGNORE}; 64 | 65 | TMPDIR="tmp$$"; 66 | 67 | rm -rf ${TMPDIR}; 68 | mkdir ${TMPDIR}; 69 | 70 | MANUALS_PATH="../manuals"; 71 | 72 | if ! test -d ${MANUALS_PATH}; 73 | then 74 | MANUALS_PATH="manuals"; 75 | fi 76 | 77 | if ! test -d ${MANUALS_PATH}; 78 | then 79 | echo "Manuals directory not found."; 80 | 81 | exit ${EXIT_IGNORE}; 82 | fi 83 | 84 | for INPUT_FILE in ${MANUALS_PATH}/*.[13]; 85 | do 86 | run_test "${INPUT_FILE}"; 87 | RESULT=$?; 88 | 89 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 90 | then 91 | break; 92 | fi 93 | done 94 | 95 | rm -rf ${TMPDIR}; 96 | 97 | exit ${RESULT}; 98 | 99 | --------------------------------------------------------------------------------