├── .git-commit-template ├── .gitattributes ├── .github └── workflows │ ├── ci-python.yml │ ├── ci.yml │ └── release-python.yml ├── .gitignore ├── .tito ├── packages │ └── .readme └── tito.props ├── COPYING ├── MANIFEST.in ├── README.md ├── build_prep.cmake ├── chcommits ├── libcomps.pc.in ├── libcomps.spec ├── libcomps ├── .gitattributes ├── CMakeLists.txt ├── docs │ ├── CMakeLists.txt │ ├── Doxyfile.user │ ├── Doxyfile.user.in │ └── mainpage.dox ├── src │ ├── CMakeLists.txt │ ├── comps_bradix.c │ ├── comps_bradix.h │ ├── comps_default.c │ ├── comps_default.h │ ├── comps_dict.c │ ├── comps_dict.h │ ├── comps_doc.c │ ├── comps_doc.h │ ├── comps_doccategory.c │ ├── comps_doccategory.h │ ├── comps_docenv.c │ ├── comps_docenv.h │ ├── comps_docgroup.c │ ├── comps_docgroup.h │ ├── comps_docgroupid.c │ ├── comps_docgroupid.h │ ├── comps_docpackage.c │ ├── comps_docpackage.h │ ├── comps_elem.c │ ├── comps_elem.h │ ├── comps_hslist.c │ ├── comps_hslist.h │ ├── comps_log.c │ ├── comps_log.h │ ├── comps_log_codes.c │ ├── comps_log_codes.h │ ├── comps_mm.c │ ├── comps_mm.h │ ├── comps_mradix.c │ ├── comps_mradix.h │ ├── comps_obj.c │ ├── comps_obj.h │ ├── comps_objdict.c │ ├── comps_objdict.h │ ├── comps_objlist.c │ ├── comps_objlist.h │ ├── comps_objmradix.c │ ├── comps_objmradix.h │ ├── comps_objradix.c │ ├── comps_objradix.h │ ├── comps_parse.c │ ├── comps_parse.h │ ├── comps_radix.c │ ├── comps_radix.h │ ├── comps_set.c │ ├── comps_set.h │ ├── comps_types.c │ ├── comps_types.h │ ├── comps_utils.c │ ├── comps_utils.h │ ├── comps_validate.c │ ├── comps_validate.h │ ├── libcomps_config.h.in │ └── python │ │ ├── CMakeLists.txt │ │ ├── docs │ │ ├── CMakeLists.txt │ │ ├── Doxyfile.user.in │ │ ├── cmake │ │ │ └── FindSphinx.cmake │ │ └── doc-sources │ │ │ ├── comps.rst │ │ │ ├── conf.py.in │ │ │ ├── index.rst │ │ │ └── unioning.rst │ │ ├── examples │ │ └── libcomps_example.py │ │ ├── pycopy.cmake │ │ ├── src │ │ ├── CMakeLists.txt │ │ ├── crc32.c │ │ ├── crc32.h │ │ ├── libcomps │ │ │ └── __init__.py │ │ ├── pycomps.c │ │ ├── pycomps.h │ │ ├── pycomps_categories.c │ │ ├── pycomps_categories.h │ │ ├── pycomps_dict.c │ │ ├── pycomps_dict.h │ │ ├── pycomps_envs.c │ │ ├── pycomps_envs.h │ │ ├── pycomps_exc.c │ │ ├── pycomps_exc.h │ │ ├── pycomps_gids.c │ │ ├── pycomps_gids.h │ │ ├── pycomps_groups.c │ │ ├── pycomps_groups.h │ │ ├── pycomps_hash.c │ │ ├── pycomps_hash.h │ │ ├── pycomps_ids.c │ │ ├── pycomps_ids.h │ │ ├── pycomps_lang._c │ │ ├── pycomps_lang._h │ │ ├── pycomps_lbw.c │ │ ├── pycomps_lbw.h │ │ ├── pycomps_macros.h │ │ ├── pycomps_mdict.c │ │ ├── pycomps_mdict.h │ │ ├── pycomps_sequence.c │ │ ├── pycomps_sequence.h │ │ ├── pycomps_types.h │ │ ├── pycomps_utils.c │ │ └── pycomps_utils.h │ │ └── tests │ │ ├── __test.py │ │ ├── comps │ │ ├── biarchonly.xml │ │ ├── comps-f21.xml │ │ ├── comps-f21.xml.in │ │ ├── comps-rawhide.xml │ │ ├── comps_empty_by_lang_tags.xml │ │ ├── comps_part1.xml │ │ ├── comps_part2.xml │ │ ├── f21-rawhide-comps.xml │ │ ├── fedora_comps.xml │ │ ├── main_arches.xml │ │ ├── main_comps.xml │ │ ├── main_comps2.xml │ │ ├── main_def.xml │ │ ├── merged_comps_1_2.xml │ │ ├── merged_comps_2_1.xml │ │ ├── sample_comps.xml │ │ ├── sample_comps2.xml │ │ └── sample_comps2.xml.gz │ │ ├── run_tests.sh.in │ │ ├── test_libcomps.py │ │ ├── test_merge_comps.py │ │ ├── tests.cmake │ │ └── utest.py ├── tests │ ├── CMakeLists.txt │ ├── check_brtree.c │ ├── check_comps.c │ ├── check_list.c │ ├── check_mrtree.c │ ├── check_objrtree.c │ ├── check_parse.c │ ├── check_rtree.c │ ├── check_utils.c │ ├── check_utils.h │ ├── check_validate.c │ ├── comps.dtd │ ├── dict-test.txt │ ├── dict-test2.txt │ ├── f21-rawhide-comps.xml │ ├── fedora_comps.xml │ ├── main_arches.xml │ ├── main_comps2.xml │ ├── sample-bad-elem.xml │ ├── sample-comps-back.xml │ ├── sample-comps-dtd.xml │ ├── sample-comps-lang.xml │ ├── sample-comps.xml │ ├── sample-elem-error.xml │ ├── sample-good.xml │ ├── sample-wrong-dtd.xml │ ├── sample-wrong-param.xml │ ├── sample_comps.xml │ ├── sample_comps_bad1.xml │ ├── sample_comps_bad2.xml │ └── sample_comps_bad3.xml ├── version.cmake └── version.cmake.in ├── pyproject.toml ├── rel-bump.py ├── setup.py ├── setup_for_python_metadata.py ├── ver-bump.py ├── version.cmake ├── version.cmake.in └── version.json /.git-commit-template: -------------------------------------------------------------------------------- 1 | 2 | 3 | # In addition to regular commit message, you can uncomment and fill in the 4 | # following to include this change in the released RPM package changelog: 5 | 6 | # = changelog = 7 | # msg: 8 | # type: 9 | # resolves: 10 | # related: 11 | 12 | # msg = message to be included in the changelog 13 | # type = one of: bugfix/enhancement/security 14 | # resolves = URLs to bugs or issues resolved by this commit 15 | # related = URLs to any related bugs or issues 16 | 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | licomps/version.cmake merge=ours 2 | -------------------------------------------------------------------------------- /.github/workflows/ci-python.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Python CI 3 | on: pull_request 4 | 5 | jobs: 6 | python-build: 7 | name: Python Build 8 | runs-on: ubuntu-latest 9 | container: fedora:latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - name: Install dependencies 14 | run: | 15 | sudo dnf -y install dnf-plugins-core python3-pip 16 | sudo dnf -y builddep libcomps.spec 17 | pip install --upgrade pip 18 | pip install pytest 19 | 20 | - name: Compile and Install 21 | run: pip install --user . 22 | 23 | - name: Test 24 | run: | 25 | pushd libcomps/src/python/tests/ 26 | pytest --verbose --color=yes ./ 27 | popd 28 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: DNF CI 3 | on: pull_request_target 4 | 5 | jobs: 6 | copr-build: 7 | name: Copr Build 8 | runs-on: ubuntu-latest 9 | container: 10 | image: ghcr.io/rpm-software-management/dnf-ci-host 11 | outputs: 12 | package-urls: ${{steps.copr-build.outputs.package-urls}} 13 | steps: 14 | - name: Check out ci-dnf-stack 15 | uses: actions/checkout@v2 16 | with: 17 | repository: rpm-software-management/ci-dnf-stack 18 | ref: dnf-4-stack 19 | 20 | - name: Setup CI 21 | id: setup-ci 22 | uses: ./.github/actions/setup-ci 23 | with: 24 | copr-user: ${{secrets.COPR_USER}} 25 | copr-api-token: ${{secrets.COPR_API_TOKEN}} 26 | 27 | - name: Check out sources 28 | uses: actions/checkout@v2 29 | with: 30 | path: gits/${{github.event.repository.name}} 31 | ref: ${{github.event.pull_request.head.sha}} # check out the PR HEAD 32 | fetch-depth: 0 33 | 34 | - name: Run Copr Build 35 | id: copr-build 36 | uses: ./.github/actions/copr-build 37 | with: 38 | copr-user: ${{steps.setup-ci.outputs.copr-user}} 39 | 40 | integration-tests: 41 | name: DNF Integration Tests 42 | needs: copr-build 43 | runs-on: ubuntu-latest 44 | container: 45 | image: ghcr.io/rpm-software-management/dnf-ci-host 46 | options: --privileged 47 | steps: 48 | - name: Check out ci-dnf-stack 49 | uses: actions/checkout@v2 50 | with: 51 | repository: rpm-software-management/ci-dnf-stack 52 | ref: dnf-4-stack 53 | 54 | - name: Run Integration Tests 55 | uses: ./.github/actions/integration-tests 56 | with: 57 | package-urls: ${{needs.copr-build.outputs.package-urls}} 58 | 59 | ansible-tests: 60 | name: Ansible Tests 61 | needs: copr-build 62 | runs-on: ubuntu-latest 63 | container: 64 | image: ghcr.io/rpm-software-management/dnf-ci-host 65 | options: --privileged 66 | steps: 67 | - name: Check out ci-dnf-stack 68 | uses: actions/checkout@v2 69 | with: 70 | repository: rpm-software-management/ci-dnf-stack 71 | ref: dnf-4-stack 72 | 73 | - name: Run Ansible Tests 74 | uses: ./.github/actions/ansible-tests 75 | with: 76 | package-urls: ${{needs.copr-build.outputs.package-urls}} 77 | -------------------------------------------------------------------------------- /.github/workflows/release-python.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Release to PyPI 3 | 4 | on: 5 | release: 6 | types: [created] 7 | 8 | jobs: 9 | build_sdist: 10 | name: Build source package 11 | runs-on: ubuntu-latest 12 | container: fedora:latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Install / upgrade dependencies 17 | run: | 18 | sudo dnf -y install dnf-plugins-core python3-pip 19 | sudo dnf -y builddep libcomps.spec 20 | python3 -m pip install --upgrade pip scikit-build 21 | 22 | - name: Build and install Python source package 23 | run: | 24 | python3 setup.py sdist 25 | python3 -m pip install dist/*.tar.gz 26 | 27 | - name: Run tests 28 | run: | 29 | python3 -m pip install pytest 30 | pushd libcomps/src/python/tests/ 31 | pytest --verbose --color=yes ./ 32 | popd 33 | 34 | - uses: actions/upload-artifact@v4 35 | with: 36 | path: dist/*.tar.gz 37 | 38 | 39 | build_bdist: 40 | name: Build binary wheels 41 | runs-on: ubuntu-latest 42 | strategy: 43 | matrix: 44 | include: 45 | - arch: auto64 # native 64-bit 46 | skip: "pp* *-musllinux_* cp36* cp37* cp38*" # no PyPy or musl builds, no older Python versions 47 | - arch: aarch64 48 | skip: "pp* *-musllinux_* cp36* cp37* cp38* cp310* cp312*" # qemu builds are incredibly slow, so only do 3.9 and 3.11 49 | # TODO: when github actions gets native aarch64 runners, we can ditch qemu and not worry about the emulation performance 50 | 51 | steps: 52 | - uses: actions/checkout@v4 53 | 54 | # setup Python for cibuildwheel 55 | - name: Set up Python 56 | uses: actions/setup-python@v4 57 | with: 58 | python-version: '3.x' 59 | 60 | - name: Set up QEMU 61 | if: runner.os == 'Linux' && ${{ matrix.arch }} == "aarch64" 62 | uses: docker/setup-qemu-action@v3 63 | with: 64 | platforms: arm64 65 | 66 | - name: Build wheels for CPython 67 | uses: pypa/cibuildwheel@v2.21.3 68 | env: 69 | CIBW_ARCHS: ${{ matrix.arch }} 70 | CIBW_SKIP: ${{ matrix.skip }} 71 | CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 # alma 8 72 | CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 73 | CIBW_BEFORE_ALL_LINUX: dnf -y install epel-release && yes | dnf -y builddep libcomps.spec 74 | CIBW_BEFORE_BUILD: python -m pip install scikit-build 75 | CIBW_TEST_REQUIRES: pytest 76 | CIBW_TEST_COMMAND: | 77 | pushd {project}/libcomps/src/python/tests/ 78 | pytest --verbose --color=yes ./ 79 | popd 80 | 81 | - uses: actions/upload-artifact@v4 82 | with: 83 | path: ./wheelhouse/*.whl 84 | 85 | 86 | upload_pypi: 87 | name: Publish packages to PyPI 88 | # only publish packages once everything is successful 89 | needs: [build_bdist, build_sdist] 90 | runs-on: ubuntu-latest 91 | steps: 92 | - uses: actions/download-artifact@v4 93 | with: 94 | name: artifact 95 | path: dist 96 | 97 | - uses: pypa/gh-action-pypi-publish@v1.12.3 98 | with: 99 | user: __token__ 100 | password: ${{secrets.PYPI_API_TOKEN}} 101 | # To test: repository_url: https://test.pypi.org/legacy/ 102 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib 19 | lib64 20 | 21 | # Compilation artifacts 22 | _skbuild/ 23 | 24 | # Python distribution stuff 25 | dist/ 26 | MANIFEST 27 | *.egg-info/ 28 | 29 | # Installer logs 30 | pip-log.txt 31 | 32 | # Unit test / coverage reports 33 | .coverage 34 | .tox 35 | nosetests.xml 36 | 37 | # Translations 38 | *.mo 39 | 40 | # Mr Developer 41 | .mr.developer.cfg 42 | .project 43 | .pydevproject 44 | -------------------------------------------------------------------------------- /.tito/packages/.readme: -------------------------------------------------------------------------------- 1 | the .tito/packages directory contains metadata files 2 | named after their packages. Each file has the latest tagged 3 | version and the project's relative directory. 4 | -------------------------------------------------------------------------------- /.tito/tito.props: -------------------------------------------------------------------------------- 1 | [buildconfig] 2 | builder = tito.builder.Builder 3 | tagger = tito.tagger.VersionTagger 4 | changelog_do_not_remove_cherrypick = 0 5 | changelog_format = %s (%ae) 6 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | graft libcomps* 2 | include version.cmake 3 | include version.json 4 | include pyproject.toml 5 | include setup.py 6 | include COPYING 7 | include README.md 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libcomps 2 | ======== 3 | 4 | Libcomps is alternative for yum.comps library. It's written in pure C as library 5 | with Python bindings. 6 | 7 | Building 8 | -------- 9 | 10 | ### Requirements 11 | 12 | for automatic build system: 13 | 14 | * cmake ( >= 2.6) http://www.cmake.org/ 15 | * make http://ftp.gnu.org/gnu/make/ 16 | 17 | for libcomps library: 18 | 19 | * zlib http://www.zlib.net/ 20 | * libxml2 http://www.xmlsoft.org/ 21 | * expat http://expat.sourceforge.net/ 22 | * gcc http://gcc.gnu.org/ 23 | 24 | for python bindings: 25 | 26 | * python http://python.org/ 27 | 28 | for C library tests: 29 | 30 | * check http://check.sourceforge.net/ 31 | 32 | for documentation build: 33 | 34 | * doxygen http://www.stack.nl/~dimitri/doxygen/ 35 | 36 | for rpm building: 37 | 38 | * tito https://github.com/dgoodwin/tito 39 | 40 | 41 | ### Building 42 | 1. clone this repository 43 | git clone https://github.com/rpm-software-management/libcomps.git 44 | 2. from the checkout dir: 45 | 46 | mkdir build 47 | cd build/ 48 | cmake ../libcomps 49 | make 50 | 3. building the documentation: 51 | 52 | make docs 53 | make pydocs 54 | 55 | ### Building rpm package 56 | You can use tito for building rpm package. From checkout dir: 57 | 58 | tito build --rpm --test 59 | 60 | ## Building Python package 61 | To create a binary "wheel" distribution, use: 62 | 63 | python setup.py bdist_wheel 64 | 65 | To create a source distribution, use: 66 | 67 | python setup.py sdist 68 | 69 | Installing source distributions require the installer of the package to have all of the build dependencies installed on their system, since they compile the code during installation. Binary distributions are pre-compiled, but they are likely not portable between substantially different systems, e.g. Fedora and Ubuntu. 70 | 71 | Note: if you are building a bdist or installing the sdist on a system with an older version of Pip, you may need to install the ```scikit-build``` Python package first. 72 | 73 | To install either of these packages, use: 74 | 75 | pip install dist/{{ package name }} 76 | 77 | To create an "editable" install of libcomps, use: 78 | 79 | python setup.py develop 80 | 81 | Note: To recompile the libraries and binaries, you muse re-run this command. 82 | 83 | ### Installing 84 | * After successful build run: 85 | make install 86 | * Or install rpm package 87 | 88 | ### Testing 89 | After build, you can find test for C library in __tests directory__, starting with 90 | `test_` prefix. Binding tests are at (for now) same directory as python binding 91 | library. You can run `python __test.py` or `python3 __test.py` (even without 92 | installing library) for tests bindings. Also this unittest serves as python 93 | bindings documentation 94 | (for now). 95 | 96 | ### Documentation 97 | After build, documentation is in __docs directory__. Documentation is built 98 | in html xml and latex format. Only uncomplete documentation for C library 99 | is available at the moment. Look at bindings unittest `__test.py__` for python 100 | bindings usage. 101 | 102 | Contribution 103 | ------------ 104 | 105 | Here's the most direct way to get your work merged into the project. 106 | 107 | 1. Fork the project 108 | 1. Clone down your fork 109 | 1. Implement your feature or bug fix and commit changes 110 | 1. If the change fixes a bug at [Red Hat bugzilla](https://bugzilla.redhat.com/), or if it is important to the end user, add the following block to the commit message: 111 | 112 | = changelog = 113 | msg: message to be included in the changelog 114 | type: one of: bugfix/enhancement/security (this field is required when message is present) 115 | resolves: URLs to bugs or issues resolved by this commit (can be specified multiple times) 116 | related: URLs to any related bugs or issues (can be specified multiple times) 117 | 118 | * For example:: 119 | 120 | = changelog = 121 | msg: Do not skip type=mandatory in xml output 122 | type: bugfix 123 | resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1771224 124 | 125 | * For your convenience, you can also use git commit template by running the following command in the top-level directory of this project: 126 | 127 | git config commit.template ./.git-commit-template 128 | 129 | 1. Push the branch to your fork 130 | 1. Send a pull request for your branch 131 | 132 | -------------------------------------------------------------------------------- /chcommits: -------------------------------------------------------------------------------- 1 | 946584c5a01d83bf9ec4c26d3f9d73e37bfb5456 2 | 76764059f1085abbd0eeaeab64f45ec48a58ba4d 3 | 4e16e2a76d3ea6f3fd4d162b177fd8e45a641bf9 4 | 9a3e8428587ecb787d0febcf11d299f4c62488ed 5 | 5500d1275ce9288a763c957a23525aae25f283fb 6 | e401de99222bac95e61b10836b230367a92f5e4f 7 | f243b574c801244447b873c8e77b82b3318c09d4 8 | 5500d1275ce9288a763c957a23525aae25f283fb 9 | 997835ec69b72ded9acbd785502c5f3bbf888be8 10 | 8108808bbcdfacbb2732536ddcc05cd44318dd9c 11 | 08008e492804c488a4a97712785ed99880343d69 12 | 36fd42e21c7a4aaf605d8bd9407ae9023c1b95e3 13 | 706260866c0d2d5f48992d2140b96bf9f2b2a988 14 | bba023bbfe75c628296cca40ffd96b2307a3c969 15 | 9c5895fd7e79884fe4e1e9d4aa7baa7d7207669d 16 | e712e7584701de6ef05a160fc4e13d5cbff14192 17 | 06da994e7cfee729475e0bb134b1687fee45da5b 18 | 0a15705507075e32e929941b290ee8f2efeeb1f0 19 | 941627d53245ec695533520835ed1d2d3cc325d0 20 | 15c445abbed24beca686682d30dcff3d7b368478 21 | c8faed2c202b6f1e788a1b4ba819487a4006537d 22 | faca63e2a823f297852154d82ee45cb4393c72aa 23 | 49448ec0c6efa7b98a6d243423edb493fa5e6c2b 24 | c4c1090fcf765236f3a04b006489d2a255c6f015 25 | f231093292e29edb7d92fee134f44379229310b6 26 | 68c7e69ca86db7100eb771929599564969c64c1e 27 | 15c445abbed24beca686682d30dcff3d7b368478 28 | 6347bdd4822b8681f5909fa281e8686f464d85ef 29 | c8faed2c202b6f1e788a1b4ba819487a4006537d 30 | 7de484f5749d2efb29f0f7049012ef6aa04b629c 31 | 3c9d603fc9be986454b919f8e16992dd4e7762f2 32 | 1460656e3c609c8c05a8edeffe8bd8ce3916a7e9 33 | 07d9a32fdb7029947ab08dc9c79772c1af3136e7 34 | a71aa7b6dfb7da3fec6fd9239453ce682d802374 35 | 013195eae09bd9971e16279c31ba545138dc7263 36 | 6fcfd3472cfccf0407546bad55ecc8551afb2564 37 | 376695823d6dcbe0db1655978f3e942073709a9e 38 | 1c222cbdeb5365187ae79abd3d0ce4a927ef1c05 39 | a756363ce4a0dc7cb9395d2f57315428c22a4efb 40 | fcc1951f5cc09d1b0f5dbd9d6e2585419e201031 41 | c57510dda1b9db6143da38656c7e518586ca59cc 42 | 645e2857e19d7791876836794e31604bd444ccc4 43 | 63b6727cca3732adc3d2a00c38512809b4e2d24d 44 | 9788d83e7db2e60a24df27fa149960c34ecfcfb8 45 | a756363ce4a0dc7cb9395d2f57315428c22a4efb 46 | -------------------------------------------------------------------------------- /libcomps.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 4 | 5 | Name: libcomps 6 | Description: alternative for yum.libcomps written in C 7 | Version: @VERSION@ 8 | URL: https://github.com/rpm-software-management/libcomps 9 | CFlags: -I${includedir} 10 | Libs: -L${libdir} -lcomps 11 | Requires: libxml-2.0 expat 12 | -------------------------------------------------------------------------------- /libcomps.spec: -------------------------------------------------------------------------------- 1 | %define __cmake_in_source_build 1 2 | 3 | Name: libcomps 4 | Version: 0.1.21 5 | Release: 1%{?dist} 6 | Summary: Comps XML file manipulation library 7 | 8 | License: GPL-2.0-or-later 9 | URL: https://github.com/rpm-software-management/libcomps 10 | Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz 11 | 12 | BuildRequires: gcc-c++ 13 | BuildRequires: cmake 14 | BuildRequires: gcc 15 | BuildRequires: libxml2-devel 16 | BuildRequires: check-devel 17 | BuildRequires: expat-devel 18 | BuildRequires: zlib-devel 19 | 20 | %description 21 | Libcomps is library for structure-like manipulation with content of 22 | comps XML files. Supports read/write XML file, structure(s) modification. 23 | 24 | %package devel 25 | Summary: Development files for libcomps library 26 | Requires: %{name}%{?_isa} = %{version}-%{release} 27 | 28 | %description devel 29 | Development files for libcomps library. 30 | 31 | %package doc 32 | Summary: Documentation files for libcomps library 33 | Requires: %{name} = %{version}-%{release} 34 | BuildArch: noarch 35 | BuildRequires: doxygen 36 | 37 | %description doc 38 | Documentation files for libcomps library. 39 | 40 | %package -n python-%{name}-doc 41 | Summary: Documentation files for python bindings libcomps library 42 | Requires: %{name} = %{version}-%{release} 43 | BuildArch: noarch 44 | BuildRequires: python3-sphinx 45 | 46 | 47 | %description -n python-%{name}-doc 48 | Documentation files for python bindings libcomps library. 49 | 50 | %package -n python3-%{name} 51 | Summary: Python 3 bindings for libcomps library 52 | BuildRequires: python3-devel 53 | BuildRequires: python3-setuptools 54 | BuildRequires: make 55 | %{?python_provide:%python_provide python3-%{name}} 56 | Requires: %{name}%{?_isa} = %{version}-%{release} 57 | Obsoletes: platform-python-%{name} < %{version}-%{release} 58 | 59 | %description -n python3-%{name} 60 | Python3 bindings for libcomps library. 61 | 62 | %prep 63 | %autosetup -n %{name}-%{version} 64 | 65 | mkdir build-py3 66 | mkdir build-doc 67 | 68 | %build 69 | pushd build-py3 70 | %cmake ../libcomps/ 71 | %make_build 72 | popd 73 | 74 | pushd build-doc 75 | %cmake ../libcomps/ 76 | make %{?_smp_mflags} docs 77 | make %{?_smp_mflags} pydocs 78 | popd 79 | 80 | %install 81 | pushd build-py3 82 | %make_install 83 | popd 84 | 85 | %check 86 | pushd build-py3 87 | make test 88 | make pytest 89 | popd 90 | 91 | %if %{undefined ldconfig_scriptlets} 92 | %post -p /sbin/ldconfig 93 | %postun -p /sbin/ldconfig 94 | %else 95 | %ldconfig_scriptlets 96 | %endif 97 | 98 | %files 99 | %license COPYING 100 | %doc README.md 101 | %{_libdir}/%{name}.so.* 102 | 103 | %files devel 104 | %{_libdir}/%{name}.so 105 | %{_libdir}/pkgconfig/%{name}.pc 106 | %{_includedir}/%{name}/ 107 | 108 | %files doc 109 | %doc build-doc/docs/libcomps-doc/html 110 | 111 | %files -n python-%{name}-doc 112 | %doc build-doc/src/python/docs/html 113 | 114 | %files -n python3-%{name} 115 | %{python3_sitearch}/%{name}/ 116 | %{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info 117 | 118 | %changelog 119 | -------------------------------------------------------------------------------- /libcomps/.gitattributes: -------------------------------------------------------------------------------- 1 | version.cmake merge=ours 2 | -------------------------------------------------------------------------------- /libcomps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libcomps C) 2 | cmake_minimum_required (VERSION 2.8.10) 3 | 4 | include (GNUInstallDirs) 5 | include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) 6 | include (${CMAKE_SOURCE_DIR}/version.cmake) 7 | #set (CMAKE_CXX_COMPILER g++) 8 | 9 | OPTION (ENABLE_TESTS "Build test?" ON) 10 | OPTION (ENABLE_DOCS "Build docs?" ON) 11 | 12 | set(LIBCOMPS_OUT "${CMAKE_CURRENT_BINARY_DIR}/src") 13 | 14 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --pedantic -std=c99 -Wall -Wextra -g -Wno-missing-field-initializers -O2 -fno-strict-aliasing -g") 15 | set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -ggdb -O0 -Wall -Wextra") 16 | 17 | set (VERSION "${libcomps_VERSION_MAJOR}.${libcomps_VERSION_MINOR}.${libcomps_VERSION_PATCH}") 18 | #set (libcomps_SOURCE comps_list.c) 19 | #set (libcomps_HEADERS comps_list.h) 20 | 21 | option(BUILD_LIBCOMPS_SHARED "Build libcomps as a shared library?" ON) 22 | if(NOT BUILD_LIBCOMPS_SHARED) 23 | set(CMAKE_POSITION_INDEPENDENT_CODE 1) 24 | endif() 25 | 26 | option(ENABLE_DEVELOPMENT "Install development files?" ON) 27 | option(ENABLE_DOCS "Build docs?" ON) 28 | option(ENABLE_TESTS "Build test?" ON) 29 | 30 | include_directories("${PROJECT_BINARY_DIR}") 31 | include_directories("${PROJECT_SOURCE_DIR}/src") 32 | #include_directories("${PROJECT_SOURCE_DIR}/src/libcomps") 33 | 34 | if (ENABLE_TESTS) 35 | find_library(CHECK_LIBRARY NAMES check) 36 | endif() 37 | find_library(EXPAT_LIBRARY NAMES expat) 38 | 39 | find_package(ZLIB REQUIRED) 40 | find_package(LibXml2 REQUIRED) 41 | find_package(EXPAT REQUIRED) 42 | 43 | include_directories(${CHECK_INCLUDE_DIR}) 44 | include_directories(${EXPAT_INCLUDE_DIR}) 45 | include_directories(${LIBXML2_INCLUDE_DIR}) 46 | include_directories(${ZLIB_INCLUDE_DIRS}) 47 | 48 | #add_custom_target(pytest DEPENDS pytest_run) 49 | #add_custom_target(ctest DEPENDS test_comps_run test_parse_run) 50 | #add_custom_target(test DEPENDS ctest pytest) 51 | #add_custom_command(TARGET test POST_BUILD COMMAND ./run_tests.sh 52 | # WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libcomps/ 53 | # COMMENT "Running python binding tests") 54 | 55 | if (ENABLE_TESTS) 56 | add_custom_target(pytest) 57 | add_custom_target(ctest) 58 | add_custom_target(test) 59 | add_dependencies(test ctest) 60 | add_dependencies(test pytest) 61 | endif () 62 | 63 | add_subdirectory (src) 64 | 65 | if (ENABLE_TESTS) 66 | add_subdirectory (tests) 67 | endif () 68 | 69 | if (ENABLE_DOCS) 70 | add_subdirectory (docs EXCLUDE_FROM_ALL) 71 | endif (ENABLE_DOCS) 72 | -------------------------------------------------------------------------------- /libcomps/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | if(DOXYGEN_FOUND) 3 | configure_file(Doxyfile.user.in 4 | ${PROJECT_BINARY_DIR}/docs/Doxyfile.user) 5 | add_custom_target (docs COMMAND ${DOXYGEN_EXECUTABLE} 6 | ${PROJECT_BINARY_DIR}/docs/Doxyfile.user 7 | SOURCES ${PROJECT_BINARY_DIR}/docs/Doxyfile.user) 8 | endif(DOXYGEN_FOUND) 9 | #message("dir ",${PROJECT_BINARY_DIR}}) 10 | file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/docs/libcomps-py-doc") 11 | 12 | #add_custom_target(Docs-sphinx ALL 13 | # COMMAND sphinx-build -b html . sphinx/build/html 14 | # WORKING_DIRECTORY . 15 | # DEPENDS Docs 16 | # COMMENT "sphinx docs" 17 | #) 18 | -------------------------------------------------------------------------------- /libcomps/docs/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \mainpage Libcomps documentation 3 | 4 | Libcomps is library for comps.xml files manipulation. Supporting reading 5 | comps.xml files, modifiing content as class-like structure, generating xml 6 | output and creating whole new class-like structure comps representation. 7 | This documentation meet only for C part of library. 8 | 9 | To explore libcomps capabilities and features covering comps files continue 10 | reading @link libcomps_objs 11 | this 12 | @endlink 13 | 14 | To understatning libcomps object management(creating, destroying, copying and 15 | binding to python objects) read @link comps_obj 16 | this 17 | @endlink 18 | 19 | */ 20 | 21 | 22 | -------------------------------------------------------------------------------- /libcomps/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (libcomps_SOURCES comps_doc.c comps_docgroup.c comps_doccategory.c 2 | comps_docenv.c comps_docpackage.c comps_docgroupid.c 3 | comps_obj.c comps_mm.c 4 | #comps_list.c 5 | comps_hslist.c comps_dict.c 6 | comps_objradix.c comps_objmradix.c comps_objdict.c comps_objlist.c 7 | comps_elem.c comps_radix.c comps_mradix.c comps_bradix.c comps_set.c 8 | comps_parse.c comps_log.c comps_default.c 9 | comps_utils.c comps_validate.c 10 | comps_log_codes.c 11 | comps_types.c 12 | ) 13 | set (libcomps_HEADERS comps_doc.h comps_docgroup.h comps_doccategory.h 14 | comps_docenv.h comps_docpackage.h comps_docgroupid.h 15 | comps_obj.h comps_mm.h 16 | #comps_list.h 17 | comps_hslist.h comps_dict.h 18 | comps_objradix.h comps_objmradix.h comps_objdict.h comps_objlist.h 19 | comps_elem.h comps_radix.h comps_mradix.h comps_bradix.h comps_set.h 20 | comps_parse.h comps_log.h comps_default.h 21 | comps_utils.h comps_validate.h 22 | comps_log_codes.h 23 | ) 24 | add_custom_target(src-copy) 25 | 26 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 27 | 28 | configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/libcomps_config.h.in" 29 | "${PROJECT_SOURCE_DIR}/src/libcomps/libcomps_config.h") 30 | 31 | include_directories(${LIBXML2_INCLUDE_DIR}) 32 | file(GLOB files "${PROJECT_SOURCE_DIR}/src/*.h") 33 | file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/src/libcomps") 34 | 35 | foreach(file ${files}) 36 | add_custom_command(TARGET src-copy PRE_BUILD COMMAND ${CMAKE_COMMAND} -E 37 | copy ${file} "${PROJECT_SOURCE_DIR}/src/libcomps/") 38 | #file(COPY ${file} DESTINATION "${PROJECT_SOURCE_DIR}/src/libcomps/") 39 | endforeach() 40 | 41 | 42 | if (BUILD_LIBCOMPS_SHARED) 43 | set (libcomps_library_type SHARED) 44 | else () 45 | set (libcomps_library_type STATIC) 46 | endif () 47 | add_library(libcomps ${libcomps_library_type} ${libcomps_SOURCES}) 48 | target_link_libraries(libcomps ${EXPAT_LIBRARY}) 49 | target_link_libraries(libcomps ${LIBXML2_LIBRARIES}) 50 | target_link_libraries(libcomps ${ZLIB_LIBRARIES}) 51 | target_link_libraries(libcomps m) 52 | set_target_properties(libcomps PROPERTIES OUTPUT_NAME "comps") 53 | set_target_properties(libcomps PROPERTIES SOVERSION ${libcomps_VERSION_MAJOR}) 54 | 55 | add_dependencies(libcomps src-copy) 56 | 57 | if (ENABLE_DEVELOPMENT OR "${libcomps_library_type}" STREQUAL "SHARED") 58 | install ( 59 | TARGETS libcomps 60 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries 61 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries 62 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development 63 | ) 64 | endif () 65 | 66 | if (ENABLE_DEVELOPMENT) 67 | configure_file("${PROJECT_SOURCE_DIR}/../libcomps.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libcomps.pc" @ONLY) 68 | 69 | install (FILES ${libcomps_HEADERS} DESTINATION include/libcomps) 70 | install (TARGETS libcomps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 71 | install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcomps.pc" 72 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") 73 | endif () 74 | 75 | add_subdirectory(python) 76 | 77 | -------------------------------------------------------------------------------- /libcomps/src/comps_bradix.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_BRADIX_H 21 | #define COMPS_BRADIX_H 22 | 23 | #include 24 | #include 25 | #include "comps_hslist.h" 26 | 27 | typedef struct { 28 | void *key; 29 | unsigned is_leaf; 30 | COMPS_HSList *subnodes; 31 | void *data; 32 | void (*key_destroy)(void *key); 33 | void (*data_destructor)(void*); 34 | } COMPS_BRTreeData; 35 | 36 | typedef struct { 37 | COMPS_HSList *subnodes; 38 | void* (*data_constructor)(void*); 39 | void* (*data_cloner)(void*); 40 | void (*data_destructor)(void*); 41 | 42 | void* (*key_clone)(void *key, unsigned int len); 43 | void (*key_destroy)(void *key); 44 | unsigned int (*key_cmp)(void *key1, void *key2, 45 | unsigned int offset1, 46 | unsigned int offset2, 47 | unsigned int len, 48 | char *ended); 49 | void* (*subkey)(void *key, unsigned int offset, unsigned int len); 50 | unsigned int (*key_len)(void *key); 51 | void* (*key_concat)(void*, void*); 52 | } COMPS_BRTree; 53 | 54 | typedef struct { 55 | void *key; 56 | void *data; 57 | void (*key_destroy)(void *key); 58 | } COMPS_BRTreePair; 59 | 60 | COMPS_BRTreeData * __comps_brtree_data_create(COMPS_BRTree *rt, void *key, 61 | unsigned int keylen, 62 | void *data); 63 | COMPS_HSList* __comps_brtree_all(COMPS_BRTree * rt, char pairorkey); 64 | 65 | void comps_brtree_data_destroy(COMPS_BRTreeData * rtd); 66 | void comps_brtree_data_destroy_v(void * rtd); 67 | 68 | COMPS_BRTreeData * comps_brtree_data_create(COMPS_BRTree *rt, void *key, 69 | void *data); 70 | COMPS_BRTreeData * comps_brtree_data_create_n(COMPS_BRTree *rt, void *key, 71 | unsigned int len, 72 | void *data); 73 | 74 | COMPS_BRTree * comps_brtree_create(void* (*data_constructor)(void*), 75 | void* (*data_cloner)(void*), 76 | void (*data_destructor)(void*), 77 | void* (*key_clone)(void*, unsigned int), 78 | void (*key_destroy)(void*), 79 | unsigned int (*key_cmp)(void*, void*, 80 | unsigned int, 81 | unsigned int, 82 | unsigned int, char*), 83 | unsigned int (*key_len)(void*), 84 | void* (*subkey)(void*, 85 | unsigned int, 86 | unsigned int), 87 | void* (*key_concat)(void*, void*)); 88 | 89 | void comps_brtree_destroy(COMPS_BRTree * rt); 90 | 91 | void comps_brtree_set(COMPS_BRTree *rt, void *key, void *data); 92 | void comps_brtree_set_n(COMPS_BRTree *rt, void *key, unsigned int len, 93 | void *data); 94 | 95 | void* comps_brtree_get(COMPS_BRTree * rt, void * key); 96 | void** comps_brtree_getp(COMPS_BRTree *brt, void *key); 97 | void comps_brtree_unset(COMPS_BRTree * rt, void * key); 98 | void comps_brtree_clear(COMPS_BRTree * rt); 99 | 100 | void comps_brtree_values_walk(COMPS_BRTree *rt, void* udata, 101 | void (*walk_f)(void*, void*)); 102 | COMPS_HSList * comps_brtree_values(COMPS_BRTree *rt); 103 | COMPS_HSList* comps_brtree_keys(COMPS_BRTree * rt); 104 | COMPS_HSList* comps_brtree_pairs(COMPS_BRTree * rt); 105 | COMPS_BRTree * comps_brtree_clone(COMPS_BRTree * rt); 106 | 107 | COMPS_BRTreePair * comps_brtree_pair_create(char * key, void * data, 108 | void (*data_destructor(void*))); 109 | void comps_brtree_pair_destroy(COMPS_BRTreePair * pair); 110 | void comps_brtree_pair_destroy_v(void * pair); 111 | 112 | COMPS_HSList* __comps_brtree_all(COMPS_BRTree * rt, char pairorkey); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /libcomps/src/comps_default.c: -------------------------------------------------------------------------------- 1 | #include "comps_default.h" 2 | #include "comps_docpackage.h" 3 | 4 | COMPS_DefaultsOptions COMPS_DDefaultsOptions = { 5 | .default_biarchonly = false, 6 | .default_uservisible = true, 7 | .default_default = false, 8 | .default_pkgtype = COMPS_PACKAGE_MANDATORY 9 | }; 10 | 11 | char* comps_default_doctype_name = "comps"; 12 | char* comps_default_doctype_sysid = "comps.dtd"; 13 | char* comps_default_doctype_pubid = "-//Red Hat, Inc.//DTD Comps info//EN"; 14 | 15 | -------------------------------------------------------------------------------- /libcomps/src/comps_default.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPS_DEFAULT_H 2 | #define COMPS_DEFAULT_H 3 | 4 | #include 5 | 6 | #include "comps_obj.h" 7 | 8 | typedef struct COMPS_DefaultsOptions { 9 | bool default_uservisible; 10 | bool default_biarchonly; 11 | bool default_default; 12 | int default_pkgtype; 13 | } COMPS_DefaultsOptions; 14 | 15 | extern COMPS_DefaultsOptions COMPS_DDefaultsOptions; 16 | extern char* comps_default_doctype_name; 17 | extern char* comps_default_doctype_pubid; 18 | extern char* comps_default_doctype_sysid; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libcomps/src/comps_dict.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "comps_dict.h" 21 | 22 | inline COMPS_Dict* comps_dict_create(void* (*data_constructor)(void*), 23 | void* (*data_cloner)(void*), 24 | void (*data_destructor)(void*)) { 25 | return (COMPS_RTree*) comps_rtree_create(data_constructor, 26 | data_cloner, data_destructor); 27 | } 28 | 29 | inline void comps_dict_destroy(COMPS_Dict *rt) { 30 | comps_rtree_destroy((COMPS_RTree*)rt); 31 | } 32 | inline void comps_dict_destroy_v(void *rt) { 33 | comps_rtree_destroy((COMPS_RTree*)rt); 34 | } 35 | inline void comps_dict_set(COMPS_Dict *rt, char *key, void *data) { 36 | comps_rtree_set((COMPS_RTree*) rt, key, data); 37 | } 38 | inline void comps_dict_set_n(COMPS_Dict *rt, char *key, unsigned int len, 39 | void *data) { 40 | comps_rtree_set_n((COMPS_RTree*) rt, key, len, data); 41 | } 42 | 43 | inline void* comps_dict_get(COMPS_Dict *rt, const char *key) { 44 | return comps_rtree_get((COMPS_RTree*) rt, key); 45 | } 46 | inline void comps_dict_unset(COMPS_Dict * rt, const char * key) { 47 | comps_rtree_unset((COMPS_RTree*) rt, key); 48 | } 49 | inline void comps_dict_clear(COMPS_Dict * rt) { 50 | comps_rtree_clear((COMPS_RTree*) rt); 51 | } 52 | inline COMPS_HSList * comps_dict_values(COMPS_Dict * rt) { 53 | return comps_rtree_values((COMPS_RTree*)rt); 54 | } 55 | inline void comps_dict_values_walk(COMPS_RTree * rt, void* udata, 56 | void (*walk_f)(void*, void*)) { 57 | comps_rtree_values_walk((COMPS_RTree*)rt, udata, walk_f); 58 | } 59 | inline COMPS_Dict * comps_dict_clone(COMPS_Dict * rt) { 60 | return (COMPS_RTree*) comps_rtree_clone((COMPS_RTree*)rt); 61 | } 62 | inline void * comps_dict_clone_v(void * rt) { 63 | return (COMPS_RTree*) comps_rtree_clone((COMPS_RTree*)rt); 64 | } 65 | inline COMPS_HSList* comps_dict_keys(COMPS_Dict * rt) { 66 | return comps_rtree_keys((COMPS_RTree*)rt); 67 | } 68 | inline COMPS_HSList* comps_dict_pairs(COMPS_Dict *rt) { 69 | return comps_rtree_pairs((COMPS_RTree*)rt); 70 | } 71 | inline COMPS_Dict* comps_dict_union(COMPS_Dict *d1, COMPS_Dict *d2) { 72 | return comps_rtree_union((COMPS_RTree*)d1, (COMPS_RTree*)d2); 73 | } 74 | 75 | 76 | inline COMPS_MDict* comps_mdict_create(void* (*data_constructor)(void*), 77 | void* (*data_cloner)(void*), 78 | void (*data_destructor)(void*)) { 79 | return (COMPS_MRTree*) comps_mrtree_create(data_constructor, 80 | data_cloner, data_destructor); 81 | } 82 | 83 | inline void comps_mdict_destroy(COMPS_MDict *rt) { 84 | comps_mrtree_destroy((COMPS_MRTree*)rt); 85 | } 86 | inline void comps_mdict_destroy_v(void *rt) { 87 | comps_mrtree_destroy((COMPS_MRTree*)rt); 88 | } 89 | 90 | inline void comps_mdict_set(COMPS_MDict *rt, char *key, void *data) { 91 | comps_mrtree_set((COMPS_MRTree*) rt, key, data); 92 | } 93 | 94 | inline void comps_mdict_set_n(COMPS_MDict *rt, char *key, unsigned int len, 95 | void *data) { 96 | comps_mrtree_set_n((COMPS_MRTree*) rt, key, len, data); 97 | } 98 | 99 | inline COMPS_HSList* comps_mdict_get(COMPS_MDict *rt, const char *key) { 100 | return comps_mrtree_get((COMPS_MRTree*) rt, key); 101 | } 102 | inline COMPS_HSList** comps_mdict_getp(COMPS_MDict *rt, const char *key) { 103 | return comps_mrtree_getp((COMPS_MRTree*) rt, key); 104 | } 105 | inline void comps_mdict_unset(COMPS_MDict * rt, const char * key) { 106 | comps_mrtree_unset((COMPS_MRTree*) rt, key); 107 | } 108 | inline void comps_mdict_clear(COMPS_MDict * rt) { 109 | comps_mrtree_clear((COMPS_MRTree*) rt); 110 | } 111 | inline void comps_mdict_values_walk(COMPS_MDict * rt, void* udata, 112 | void (*walk_f)(void*, void*)) { 113 | comps_mrtree_values_walk((COMPS_MRTree*)rt, udata, walk_f); 114 | } 115 | 116 | inline COMPS_MDict* comps_mdict_clone(COMPS_MDict * rt) { 117 | return (COMPS_MRTree*) comps_mrtree_clone((COMPS_MRTree*)rt); 118 | } 119 | inline void* comps_mdict_clone_v(void *rt) { 120 | return (COMPS_MRTree*) comps_mrtree_clone((COMPS_MRTree*)rt); 121 | } 122 | inline COMPS_HSList* comps_mdict_keys(COMPS_MDict * rt) { 123 | return comps_mrtree_keys((COMPS_MRTree*)rt); 124 | } 125 | inline void comps_mdict_unite(COMPS_MDict * d1, COMPS_MDict *d2) { 126 | comps_mrtree_unite((COMPS_MRTree*)d1, (COMPS_MRTree*)d2); 127 | } 128 | -------------------------------------------------------------------------------- /libcomps/src/comps_dict.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_DICT_H 21 | #define COMPS_DICT_H 22 | 23 | #include "comps_radix.h" 24 | #include "comps_mradix.h" 25 | 26 | typedef COMPS_RTree COMPS_Dict; 27 | typedef COMPS_MRTree COMPS_MDict; 28 | 29 | COMPS_Dict* comps_dict_create(void* (*data_constructor)(void*), 30 | void* (*data_cloner)(void*), 31 | void (*data_destructor)(void*)); 32 | COMPS_MDict* comps_mdict_create(void* (*data_constructor)(void*), 33 | void* (*data_cloner)(void*), 34 | void (*data_destructor)(void*)); 35 | 36 | void comps_dict_destroy(COMPS_Dict *rt); 37 | void comps_dict_destroy_v(void *rt); 38 | void comps_mdict_destroy(COMPS_MDict *rt); 39 | void comps_mdict_destroy_v(void *rt); 40 | 41 | void comps_dict_set(COMPS_Dict *rt, char *key, void *data); 42 | void comps_dict_set_n(COMPS_Dict *rt, char *key, unsigned int len, void *data); 43 | void comps_mdict_set(COMPS_MDict *rt, char *key, void *data); 44 | void comps_mdict_set_n(COMPS_MDict *rt, char *key, unsigned int len, 45 | void *data); 46 | 47 | void* comps_dict_get(COMPS_Dict *rt, const char *key); 48 | COMPS_HSList * comps_mdict_get(COMPS_MDict *rt, const char *key); 49 | COMPS_HSList ** comps_mdict_getp(COMPS_MDict *rt, const char * key); 50 | 51 | void comps_dict_unset(COMPS_Dict * rt, const char * key); 52 | void comps_mdict_unset(COMPS_MDict * rt, const char * key); 53 | 54 | void comps_dict_clear(COMPS_Dict * rt); 55 | void comps_mdict_clear(COMPS_MDict * rt); 56 | 57 | COMPS_HSList * comps_dict_values(COMPS_Dict * rt); 58 | 59 | void comps_dict_values_walk(COMPS_RTree *rt, void *udata, 60 | void (*walk_f)(void*, void*)); 61 | void comps_mdict_values_walk(COMPS_MDict *rt, void *udata, 62 | void (*walk_f)(void*, void*)); 63 | 64 | COMPS_Dict* comps_dict_clone(COMPS_Dict *rt); 65 | void * comps_dict_clone_v(void * rt); 66 | 67 | COMPS_MDict* comps_mdict_clone(COMPS_MDict *rt); 68 | void* comps_mdict_clone_v(void *rt); 69 | 70 | COMPS_HSList* comps_mdict_keys(COMPS_MDict *rt); 71 | COMPS_HSList* comps_dict_keys(COMPS_Dict *rt); 72 | COMPS_HSList* comps_dict_pairs(COMPS_Dict *rt); 73 | void comps_mdict_unite(COMPS_MDict *d1, COMPS_MDict *d2); 74 | COMPS_Dict* comps_dict_union(COMPS_Dict *d1, COMPS_Dict *d2); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /libcomps/src/comps_docgroupid.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | /** \file comps_docgroupid.h 21 | * \brief COMPS_DocGroupId header file 22 | */ 23 | 24 | #ifndef COMPS_DOCGROUPID_H 25 | #define COMPS_DOCGROUPID_H 26 | 27 | #include 28 | 29 | #include "comps_utils.h" 30 | #include "comps_log.h" 31 | #include "comps_validate.h" 32 | #include "comps_default.h" 33 | #include "comps_obj.h" 34 | 35 | /** COMPS_Object derivate representing group_id element in comps.xml file */ 36 | typedef struct { 37 | COMPS_Object_HEAD; 38 | COMPS_Str *name; 39 | /**< name of GroupId */ 40 | bool def; 41 | /**< GroupId default attribute */ 42 | COMPS_ObjList *arches; 43 | } COMPS_DocGroupId; 44 | COMPS_Object_TAIL(COMPS_DocGroupId); 45 | 46 | //HEAD_COMPS_CREATE_u(docgroupid, COMPS_DocGroupId) /*comps_utils.h macro*/ 47 | //HEAD_COMPS_COPY_u(docgroupid, COMPS_DocGroupId) /*comps_utils.h macro*/ 48 | //HEAD_COMPS_DESTROY_u(docgroupid, COMPS_DocGroupId) /*comps_utils.h macro*/ 49 | 50 | char __comps_docgroupid_cmp_set(void *gid1, void *gid2); 51 | 52 | /** COMPS_DocGroupId name getter 53 | * @param gid COMPS_DocGroupId object 54 | * @return COMPS_Str object representing GroupId name with incremented 55 | * reference counter 56 | */ 57 | COMPS_Object* comps_docgroupid_get_name(COMPS_DocGroupId *gid); 58 | 59 | /** COMPS_DocGroupId name setter 60 | * @param gid COMPS_DocGroupId object 61 | * @param name new name of COMPS_DocGroupId object. Old name object's reference 62 | * @param copy deprecated parameter 63 | * counter will be decremented 64 | */ 65 | void comps_docgroupid_set_name(COMPS_DocGroupId *gid, char *name, char copy); 66 | 67 | /** COMPS_DocGroupId default getter 68 | * @param gid COMPS_DocGroupId object 69 | * @return COMPS_Num object representing GroupId default with incremented 70 | * reference counter 71 | */ 72 | COMPS_Object* comps_docgroupid_get_default(COMPS_DocGroupId *gid); 73 | 74 | /** COMPS_DocGroupId name setter 75 | * @param gid COMPS_DocGroupId object 76 | * @param def COMPS_DocGroupId default value. 77 | * 78 | * Old defaut objects reference counter will be decremented 79 | */ 80 | void comps_docgroupid_set_default(COMPS_DocGroupId *gid, int def); 81 | 82 | COMPS_ObjList* comps_docgroupid_arches(COMPS_DocGroupId *gid); 83 | void comps_docgroupid_set_arches(COMPS_DocGroupId *gid, 84 | COMPS_ObjList *arches); 85 | 86 | signed char comps_docgroupid_xml(COMPS_DocGroupId *groupid, 87 | xmlTextWriterPtr writer, 88 | COMPS_Log *log, COMPS_XMLOptions *options, 89 | COMPS_DefaultsOptions *def_options); 90 | 91 | extern COMPS_ValRuleGeneric* COMPS_DocGroupId_ValidateRules[]; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /libcomps/src/comps_hslist.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | 21 | #ifndef COMPS_HSLIST_H 22 | #define COMPS_HSLIST_H 23 | 24 | 25 | struct _COMPS_HSListItem { 26 | struct _COMPS_HSListItem * next; 27 | void * data; 28 | }; 29 | 30 | typedef struct _COMPS_HSListItem COMPS_HSListItem; 31 | 32 | typedef struct { 33 | COMPS_HSListItem * first; 34 | COMPS_HSListItem * last; 35 | void(*data_destructor)(void*); 36 | void*(*data_cloner)(void*); 37 | void*(*data_constructor)(void*); 38 | } COMPS_HSList; 39 | 40 | COMPS_HSList * comps_hslist_create(); 41 | void comps_hslist_destroy(COMPS_HSList ** hlist); 42 | void comps_hslist_destroy_v(void ** hlist); 43 | 44 | void comps_hslist_init(COMPS_HSList * hlist, 45 | void*(*data_constructor)(void* data), 46 | void*(*data_cloner)(void* data), 47 | void(*data_destructor)(void* data)); 48 | void comps_hslist_append(COMPS_HSList * hlist, void * data, 49 | unsigned construct); 50 | void comps_hslist_remove(COMPS_HSList * hlist, COMPS_HSListItem * it); 51 | void* comps_hslist_data_at(COMPS_HSList * hlist, unsigned int index); 52 | void comps_hslist_insert_after(COMPS_HSList * hslist, COMPS_HSListItem *item, 53 | void *data, unsigned construct); 54 | int comps_hslist_insert_at(COMPS_HSList * hslist, int pos, 55 | void *data, unsigned construct); 56 | void comps_hslist_prepend(COMPS_HSList * hslist, void *data, unsigned construct); 57 | void* comps_hslist_shift(COMPS_HSList * hslist); 58 | void* comps_hslist_pop(COMPS_HSList * hslist); 59 | 60 | COMPS_HSList* comps_hslist_clone(COMPS_HSList * hslist); 61 | void comps_hslist_clear(COMPS_HSList * hslist); 62 | unsigned comps_hslist_values_equal(COMPS_HSList *hlist1, COMPS_HSList *hlist2, 63 | char (*cmpf)(void*, void*)); 64 | void comps_hslist_unique(COMPS_HSList *hslist1, char (*cmpf)(void*, void*)); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libcomps/src/comps_log.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPS_LOG_H 2 | #define COMPS_LOG_H 3 | 4 | #include 5 | 6 | #include "comps_log_codes.h" 7 | #include "comps_hslist.h" 8 | #include "comps_types.h" 9 | 10 | struct COMPS_LogEntry { 11 | COMPS_Object **args; 12 | int arg_count; 13 | int code; 14 | int type; 15 | }; 16 | 17 | struct COMPS_Log { 18 | COMPS_Object_HEAD; 19 | COMPS_HSList *entries; 20 | char std_out; 21 | }; 22 | COMPS_Object_TAIL(COMPS_Log); 23 | 24 | void comps_log_create(COMPS_Log *log, COMPS_Object **args); 25 | void comps_log_create_u(COMPS_Object *log, COMPS_Object **args); 26 | 27 | void comps_log_destroy(COMPS_Log *log); 28 | void comps_log_destroy_u(COMPS_Object *log); 29 | 30 | COMPS_LogEntry *comps_log_entry_create(); 31 | void comps_log_entry_destroy(); 32 | char* comps_log_entry_str(COMPS_LogEntry *log_entry); 33 | 34 | 35 | void comps_log_error(COMPS_Log *log, int code, int n, ...); 36 | void comps_log_error_x(COMPS_Log *log, int code, int n, ...); 37 | void comps_log_warning(COMPS_Log *log, int code, int n, ...); 38 | void comps_log_warning_x(COMPS_Log *log, int code, int n, ...); 39 | void comps_log_print(COMPS_Log *log); 40 | 41 | extern const char * COMPS_LogCodeFormat[]; 42 | //extern COMPS_ObjectInfo COMPS_Log_ObjInfo; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /libcomps/src/comps_log_codes.c: -------------------------------------------------------------------------------- 1 | #include "comps_log_codes.h" 2 | 3 | void __expand(char *str, const char *fmt, char out, ...) { 4 | va_list list; 5 | (void) str; 6 | va_start(list, out); 7 | if (out) 8 | vprintf(fmt, list); 9 | else 10 | vsprintf(str, fmt, list); 11 | va_end(list); 12 | } 13 | 14 | void expand0(char *str, const char *fmt, char **args, char out) { 15 | (void)args; 16 | __expand(str, fmt, out); 17 | } 18 | 19 | void expand1(char *str, const char *fmt, char **args, char out) { 20 | __expand(str, fmt, out, args[0]); 21 | } 22 | 23 | void expand2(char *str, const char *fmt, char **args, char out) { 24 | __expand(str, fmt, out, args[0], 25 | args[1]); 26 | } 27 | 28 | void expand3(char *str, const char *fmt, char **args, char out) { 29 | __expand(str, fmt, out, args[0], 30 | args[1], 31 | args[2]); 32 | } 33 | 34 | void expand4(char *str, const char *fmt, char **args, char out) { 35 | __expand(str, fmt, out, args[0], 36 | args[1], 37 | args[2], 38 | args[3]); 39 | } 40 | 41 | void expand5(char *str, const char *fmt, char **args, char out) { 42 | __expand(str, fmt, out, args[0], 43 | args[1], 44 | args[2], 45 | args[3], 46 | args[4]); 47 | } 48 | 49 | void expand(char *str, const char *fmt, char **args, int len, int out) { 50 | switch(len) { 51 | case 0: 52 | expand0(str, fmt, args, out); 53 | break; 54 | case 1: 55 | expand1(str, fmt, args, out); 56 | break; 57 | case 2: 58 | expand2(str, fmt, args, out); 59 | break; 60 | case 3: 61 | expand3(str, fmt, args, out); 62 | break; 63 | case 4: 64 | expand4(str, fmt, args, out); 65 | break; 66 | case 5: 67 | expand5(str, fmt, args, out); 68 | break; 69 | default: 70 | break; 71 | } 72 | } 73 | 74 | void expand_out(const char *fmt, char **args, int len) { 75 | expand(NULL, fmt, args, len, 1); 76 | } 77 | 78 | void expand_s(char *str, const char *fmt, char **args, int len) { 79 | expand(str, fmt, args, len, 0); 80 | } 81 | -------------------------------------------------------------------------------- /libcomps/src/comps_log_codes.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPS_LOG_CODES_H 2 | #define COMPS_LOG_CODES_H 3 | 4 | #include 5 | #include 6 | 7 | #include "comps_obj.h" 8 | #include "comps_utils.h" 9 | #define COMPS_LOG_ENTRY_ERR 0 10 | #define COMPS_LOG_ENTRY_WAR 1 11 | 12 | #define COMPS_ERR_NO_ERR 1 13 | #define COMPS_ERR_ELEM_UNKNOWN 2 14 | #define COMPS_ERR_ELEM_ALREADYSET 3 15 | #define COMPS_ERR_PARSER 4 16 | #define COMPS_ERR_DEFAULT_PARAM 5 17 | #define COMPS_ERR_USERVISIBLE_PARAM 6 18 | #define COMPS_ERR_PACKAGE_UNKNOWN 7 19 | #define COMPS_ERR_DEFAULT_MISSING 8 20 | #define COMPS_ERR_USERVISIBLE_MISSING 9 21 | #define COMPS_ERR_NAME_MISSING 10 22 | #define COMPS_ERR_ID_MISSING 11 23 | #define COMPS_ERR_DESC_MISSING 12 24 | #define COMPS_ERR_GROUPLIST_NOTSET 13 25 | #define COMPS_ERR_OPTIONLIST_NOTSET 14 26 | #define COMPS_ERR_GROUPIDS_EMPTY 15 27 | #define COMPS_ERR_NOPARENT 16 28 | #define COMPS_ERR_MALLOC 17 29 | #define COMPS_ERR_READFD 18 30 | #define COMPS_ERR_WRITEF 19 31 | #define COMPS_ERR_XMLGEN 20 32 | #define COMPS_ERR_ELEM_REQUIRED 21 33 | #define COMPS_ERR_LIST_EMPTY 22 34 | #define COMPS_ERR_TEXT_BETWEEN 23 35 | #define COMPS_ERR_NOCONTENT 24 36 | #define COMPS_ERR_PKGLIST_EMPTY 25 37 | #define COMPS_ERR_IDS_EMPTY 26 38 | #define COMPS_ERR_ATTR_UNKNOWN 27 39 | 40 | #define LOG_TEST_CODE1 1001 41 | #define LOG_TEST_CODE2 1002 42 | #define LOG_TEST_CODE3 1003 43 | #define LOG_TEST_CODE4 1004 44 | #define LOG_TEST_CODE5 1005 45 | #define LOG_TEST_CODE6 1006 46 | 47 | 48 | 49 | void __expand(char *str, const char *fmt, char out, ...); 50 | 51 | void expand0(char *str, const char *fmt, char **args, char out); 52 | void expand1(char *str, const char *fmt, char **args, char out); 53 | void expand2(char *str, const char *fmt, char **args, char out); 54 | void expand3(char *str, const char *fmt, char **args, char out); 55 | void expand4(char *str, const char *fmt, char **args, char out); 56 | void expand5(char *str, const char *fmt, char **args, char out); 57 | 58 | void expand(char *str, const char *fmt, char **args, int len, int out); 59 | 60 | void expand_out(const char *fmt, char **args, int len); 61 | void expand_s(char *str, const char *fmt, char **args, int len); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libcomps/src/comps_mm.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "comps_mm.h" 21 | COMPS_RefC* comps_refc_create(void *obj, void (*destructor)(void*)) { 22 | COMPS_RefC *refc; 23 | refc = malloc(sizeof(*refc)); 24 | if (!refc) { 25 | raise(SIGABRT); 26 | return NULL; 27 | } 28 | refc->ref_count = 0; 29 | refc->obj = obj; 30 | refc->destructor = destructor; 31 | return refc; 32 | } 33 | 34 | void comps_refc_destroy(COMPS_RefC *refc) { 35 | if (!refc->ref_count) { 36 | if (refc->destructor) refc->destructor(refc->obj); 37 | free(refc); 38 | } else { 39 | refc->ref_count--; 40 | } 41 | } 42 | 43 | inline void comps_refc_destroy_v(void *refc) { 44 | comps_refc_destroy((COMPS_RefC*)refc); 45 | } 46 | 47 | inline void comps_refc_decref(COMPS_RefC *refc) { 48 | comps_refc_destroy(refc); 49 | } 50 | 51 | inline void comps_refc_incref(COMPS_RefC *refc) { 52 | //COMPS_Check_NULL(refc, ) 53 | refc->ref_count++; 54 | } 55 | -------------------------------------------------------------------------------- /libcomps/src/comps_mm.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_MM_H 21 | #define COMPS_MM_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /*! \file comps_mm.h 28 | * \brief COMPS memory management(reference counter) file 29 | * 30 | * Details. 31 | * */ 32 | 33 | /** 34 | Reference counter structure 35 | */ 36 | typedef struct { 37 | size_t ref_count; /**< actual reference count for object */ 38 | void (*destructor)(void*); /**< callback destructor, called when reference 39 | count fall bellow 1*/ 40 | void *obj; /**< pointer to counted object itself */ 41 | } COMPS_RefC; 42 | 43 | /** reference counter constructor */ 44 | COMPS_RefC* comps_refc_create(void *obj, void (*destructor)(void*)); 45 | 46 | /** if ref counter equals zero destroy holded object 47 | * and ref counter object itself, otherwise decrement counter 48 | * @see comps_refc_decref 49 | * */ 50 | void comps_refc_destroy(COMPS_RefC *refc); 51 | 52 | /** alias with void argument 53 | * @see comps_refc_destroy 54 | * */ 55 | void comps_refc_destroy_v(void *refc); 56 | 57 | /** alias for comps_refc_destroy 58 | * @see comps_refc_destroy 59 | * */ 60 | void comps_refc_decref(COMPS_RefC *refc); 61 | 62 | /** increment reference counter by 1 63 | */ 64 | void comps_refc_incref(COMPS_RefC *refc); 65 | 66 | #endif //COMPS_MM_H 67 | -------------------------------------------------------------------------------- /libcomps/src/comps_mradix.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_MRADIX_H 21 | #define COMPS_MRADIX_H 22 | 23 | #include 24 | #include 25 | #include "comps_hslist.h" 26 | 27 | typedef struct { 28 | char * key; 29 | unsigned is_leaf; 30 | COMPS_HSList * subnodes; 31 | COMPS_HSList * data; 32 | } COMPS_MRTreeData; 33 | 34 | typedef struct { 35 | COMPS_HSList * subnodes; 36 | void* (*data_constructor)(void*); 37 | void* (*data_cloner)(void*); 38 | void (*data_destructor)(void*); 39 | } COMPS_MRTree; 40 | 41 | void comps_mrtree_data_destroy(COMPS_MRTreeData * rtd); 42 | void comps_mrtree_data_destroy_v(void * rtd); 43 | COMPS_MRTreeData * comps_mrtree_data_create(COMPS_MRTree* tree, 44 | char * key, void * data); 45 | COMPS_MRTreeData * comps_mrtree_data_create_n(COMPS_MRTree * tree, char * key, 46 | size_t keylen, void * data); 47 | 48 | COMPS_MRTree * comps_mrtree_create(void* (*data_constructor)(void*), 49 | void* (*data_cloner)(void*), 50 | void (*data_destructor)(void*)); 51 | void comps_mrtree_destroy(COMPS_MRTree *rt); 52 | 53 | void comps_mrtree_set(COMPS_MRTree *rt, char *key, void *data); 54 | void comps_mrtree_set_n(COMPS_MRTree * rt, char * key, size_t len, void * data); 55 | 56 | COMPS_HSList* comps_mrtree_get(COMPS_MRTree *rt, const char *key); 57 | COMPS_HSList** comps_mrtree_getp(COMPS_MRTree *rt, const char *key); 58 | 59 | void comps_mrtree_unset(COMPS_MRTree *rt, const char *key); 60 | void comps_mrtree_clear(COMPS_MRTree *rt); 61 | 62 | void comps_mrtree_values_walk(COMPS_MRTree *rt, void *udata, 63 | void (*walk_f)(void*, void*)); 64 | COMPS_MRTree * comps_mrtree_clone(COMPS_MRTree *rt); 65 | COMPS_HSList* comps_mrtree_keys(COMPS_MRTree *rt); 66 | void comps_mrtree_unite(COMPS_MRTree *rt1, COMPS_MRTree *rt2); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /libcomps/src/comps_objmradix.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_OBJMRADIX_H 21 | #define COMPS_OBJMRADIX_H 22 | 23 | #include 24 | #include 25 | 26 | #include "comps_obj.h" 27 | #include "comps_utils.h" 28 | #include "comps_hslist.h" 29 | #include "comps_objlist.h" 30 | 31 | typedef struct { 32 | char * key; 33 | unsigned is_leaf; 34 | COMPS_HSList * subnodes; 35 | COMPS_ObjList * data; 36 | } COMPS_ObjMRTreeData; 37 | 38 | typedef struct { 39 | COMPS_Object_HEAD; 40 | COMPS_HSList * subnodes; 41 | unsigned int len; 42 | } COMPS_ObjMRTree; 43 | 44 | typedef struct { 45 | char *key; 46 | COMPS_ObjList *data; 47 | } COMPS_ObjMRTreePair; 48 | 49 | void comps_objmrtree_data_destroy_v(void * rtd); 50 | void comps_objmrtree_pair_destroy_v(void * pair); 51 | 52 | void comps_objmrtree_data_destroy(COMPS_ObjMRTreeData * rtd); 53 | void comps_objmrtree_data_destroy_v(void * rtd); 54 | COMPS_ObjMRTreeData * comps_objmrtree_data_create(char *key, COMPS_Object *data); 55 | 56 | void comps_objmrtree_create_u(COMPS_Object *mrtree, COMPS_Object **args); 57 | void comps_objmrtree_destroy_u(COMPS_Object * rt); 58 | void comps_objmrtree_copy_shallow(COMPS_ObjMRTree *ret, COMPS_ObjMRTree *rt); 59 | void comps_objmrtree_copy_u(COMPS_Object *rt1, COMPS_Object *rt2); 60 | signed char comps_objmrtree_cmp_u(COMPS_Object *ort1, COMPS_Object *ort2); 61 | 62 | void __comps_objmrtree_set(COMPS_ObjMRTree *rt, char *key, 63 | size_t len, COMPS_Object *ndata); 64 | void comps_objmrtree_set(COMPS_ObjMRTree * rt, char * key, COMPS_Object * ndata); 65 | void comps_objmrtree_set_x(COMPS_ObjMRTree *rt, char *key, COMPS_Object *data); 66 | void comps_objmrtree_set_n(COMPS_ObjMRTree *rt, char *key, size_t len, 67 | void *ndata); 68 | 69 | COMPS_ObjList * comps_objmrtree_get(COMPS_ObjMRTree * rt, const char * key); 70 | 71 | void comps_objmrtree_unset(COMPS_ObjMRTree *rt, const char *key); 72 | void comps_objmrtree_clear(COMPS_ObjMRTree *rt); 73 | 74 | COMPS_HSList * comps_objmrtree_values(COMPS_ObjMRTree * rt); 75 | void comps_objmrtree_values_walk(COMPS_ObjMRTree *rt, void *udata, 76 | void (*walk_f)(void*, void*)); 77 | COMPS_ObjMRTree * comps_objmrtree_clone(COMPS_ObjMRTree *rt); 78 | COMPS_HSList* comps_objmrtree_keys(COMPS_ObjMRTree *rt); 79 | void comps_objmrtree_unite(COMPS_ObjMRTree *rt1, COMPS_ObjMRTree *rt2); 80 | 81 | COMPS_HSList* comps_objmrtree_pairs(COMPS_ObjMRTree * rt); 82 | 83 | extern COMPS_ObjectInfo COMPS_ObjMRTree_ObjInfo; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /libcomps/src/comps_objradix.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_OBJRADIX_H 21 | #define COMPS_OBJRADIX_H 22 | 23 | #include 24 | #include 25 | 26 | #include "comps_hslist.h" 27 | #include "comps_obj.h" 28 | #include "comps_utils.h" 29 | #include "comps_objlist.h" 30 | 31 | typedef struct { 32 | char *key; 33 | unsigned is_leaf; 34 | COMPS_HSList *subnodes; 35 | COMPS_Object *data; 36 | } COMPS_ObjRTreeData; 37 | 38 | typedef struct { 39 | COMPS_Object_HEAD; 40 | COMPS_HSList *subnodes; 41 | unsigned int len; 42 | } COMPS_ObjRTree; 43 | 44 | typedef struct { 45 | char *key; 46 | COMPS_Object *data; 47 | } COMPS_ObjRTreePair; 48 | 49 | COMPS_ObjRTreeData * __comps_objrtree_data_create(char *key, 50 | size_t keylen, 51 | COMPS_Object *data); 52 | COMPS_HSList* __comps_objrtree_all(COMPS_ObjRTree *rt, char pairorkey); 53 | 54 | void comps_objrtree_data_destroy(COMPS_ObjRTreeData *rtd); 55 | void comps_objrtree_data_destroy_v(void *rtd); 56 | 57 | COMPS_ObjRTreeData * comps_objrtree_data_create(char *key, COMPS_Object *data); 58 | COMPS_ObjRTreeData * comps_objrtree_data_create_n(char *key, size_t keylen, 59 | COMPS_Object *data); 60 | 61 | 62 | void comps_objrtree_copy_u(COMPS_Object *rt1, COMPS_Object *rt2); 63 | void comps_objrtree_copy_shallow(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2); 64 | signed char comps_objrtree_cmp_u(COMPS_Object *ort1, COMPS_Object *ort2); 65 | void comps_objrtree_create_u(COMPS_Object *rtree, COMPS_Object **args); 66 | void comps_objrtree_destroy_u(COMPS_Object * rt); 67 | 68 | void comps_objrtree_set(COMPS_ObjRTree *rt, char *key, COMPS_Object *data); 69 | void comps_objrtree_set_x(COMPS_ObjRTree *rt, char *key, COMPS_Object *data); 70 | void comps_objrtree_set_n(COMPS_ObjRTree *rt, char *key, size_t len, 71 | COMPS_Object *data); 72 | void comps_objrtree_set_nx(COMPS_ObjRTree *rt, char *key, size_t len, 73 | COMPS_Object *data); 74 | 75 | COMPS_Object* comps_objrtree_get(COMPS_ObjRTree * rt, const char * key); 76 | COMPS_Object* comps_objrtree_get_x(COMPS_ObjRTree * rt, const char * key); 77 | void comps_objrtree_unset(COMPS_ObjRTree *rt, const char *key); 78 | void comps_objrtree_clear(COMPS_ObjRTree *rt); 79 | 80 | char comps_objrtree_paircmp(void *obj1, void *obj2); 81 | void comps_objrtree_values_walk(COMPS_ObjRTree * rt, void* udata, 82 | void (*walk_f)(void*, COMPS_Object*)); 83 | COMPS_HSList * comps_objrtree_values(COMPS_ObjRTree * rt); 84 | COMPS_HSList* comps_objrtree_keys(COMPS_ObjRTree *rt); 85 | COMPS_HSList* comps_objrtree_pairs(COMPS_ObjRTree * rt); 86 | COMPS_ObjRTree* comps_objrtree_clone(COMPS_ObjRTree *rt); 87 | COMPS_ObjRTree* comps_objrtree_union(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2); 88 | void comps_objrtree_unite(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2); 89 | COMPS_ObjRTree* comps_objrtree_union(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2); 90 | 91 | COMPS_ObjRTreePair* comps_objrtree_pair_create(char *key, void *data, 92 | void (*data_destructor(void*))); 93 | void comps_objrtree_pair_destroy(COMPS_ObjRTreePair *pair); 94 | void comps_objrtree_pair_destroy_v(void *pair); 95 | 96 | extern COMPS_ObjectInfo COMPS_ObjRTree_ObjInfo; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /libcomps/src/comps_parse.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_PARSE_H 21 | #define COMPS_PARSE_H 22 | #include 23 | #include 24 | 25 | #include "comps_hslist.h" 26 | #include "comps_obj.h" 27 | #include "comps_doc.h" 28 | #include "comps_types.h" 29 | #include "comps_log.h" 30 | #include "comps_default.h" 31 | 32 | #include 33 | #include 34 | 35 | typedef struct COMPS_Parsed { 36 | COMPS_HSList *elem_stack; 37 | COMPS_Doc *comps_doc; 38 | COMPS_HSList *text_buffer; 39 | unsigned int text_buffer_len; 40 | char **text_buffer_pt; 41 | char *tmp_buffer; 42 | COMPS_Log *log; 43 | char fatal_error; 44 | XML_Parser parser; 45 | const char *enc; 46 | COMPS_DefaultsOptions *def_options; 47 | 48 | COMPS_Str *doctype_name; 49 | COMPS_Str *doctype_sysid; 50 | COMPS_Str *doctype_pubid; 51 | } COMPS_Parsed; 52 | 53 | COMPS_Parsed* comps_parse_parsed_create(); 54 | void comps_parse_parsed_reinit(COMPS_Parsed *parsed); 55 | void comps_parse_parsed_destroy(COMPS_Parsed *parsed); 56 | unsigned comps_parse_parsed_init(COMPS_Parsed * parsed, const char * encoding, 57 | char log_stdout); 58 | 59 | unsigned __comps_is_whitespace_only(const char * s, int len); 60 | 61 | void comps_parse_end_elem_handler(void *userData, const XML_Char *s); 62 | void comps_parse_def_handler(void *userData, const XML_Char *s, int len); 63 | void comps_parse_start_elem_handler(void *userData, 64 | const XML_Char *s, 65 | const XML_Char **attrs); 66 | void comps_parse_char_data_handler(void *userData, 67 | const XML_Char *s, 68 | int len); 69 | void comps_parse_start_doctype(void *userData, 70 | const XML_Char *doctypeName, 71 | const XML_Char *sysid, 72 | const XML_Char *pubid, 73 | int standalone); 74 | 75 | signed char comps_parse_file(COMPS_Parsed *parsed, FILE *f, 76 | COMPS_DefaultsOptions *options); 77 | signed char comps_parse_str(COMPS_Parsed *parsed, char *str, 78 | COMPS_DefaultsOptions *options); 79 | 80 | unsigned comps_parse_init_parser(XML_Parser *p); 81 | void comps_parse_parsed_destroy(COMPS_Parsed *parsed); 82 | int comps_parse_validate_dtd(char *filename, char *dtd_file); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /libcomps/src/comps_radix.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_RADIX_H 21 | #define COMPS_RADIX_H 22 | 23 | #include 24 | #include 25 | #include "comps_hslist.h" 26 | 27 | typedef struct { 28 | char * key; 29 | unsigned is_leaf; 30 | COMPS_HSList * subnodes; 31 | void * data; 32 | void (**data_destructor)(void*); 33 | } COMPS_RTreeData; 34 | 35 | typedef struct { 36 | COMPS_HSList * subnodes; 37 | void* (*data_constructor)(void*); 38 | void* (*data_cloner)(void*); 39 | void (*data_destructor)(void*); 40 | } COMPS_RTree; 41 | 42 | typedef struct { 43 | char * key; 44 | void * data; 45 | } COMPS_RTreePair; 46 | 47 | COMPS_RTreeData * __comps_rtree_data_create(COMPS_RTree *rt, char *key, 48 | unsigned int keylen, 49 | void *data); 50 | COMPS_HSList* __comps_rtree_all(COMPS_RTree * rt, char pairorkey); 51 | 52 | void comps_rtree_data_destroy(COMPS_RTreeData * rtd); 53 | void comps_rtree_data_destroy_v(void * rtd); 54 | 55 | COMPS_RTreeData * comps_rtree_data_create(COMPS_RTree *rt, char * key, 56 | void * data); 57 | COMPS_RTreeData * comps_rtree_data_create_n(COMPS_RTree *rt, char * key, 58 | size_t keylen, void * data); 59 | 60 | COMPS_RTree * comps_rtree_create(void* (*data_constructor)(void*), 61 | void* (*data_cloner)(void*), 62 | void (*data_destructor)(void*)); 63 | void comps_rtree_destroy(COMPS_RTree * rt); 64 | 65 | void comps_rtree_set(COMPS_RTree *rt, char *key, void *data); 66 | void comps_rtree_set_n(COMPS_RTree * rt, char * key, 67 | size_t keylen, void * data); 68 | 69 | void* comps_rtree_get(COMPS_RTree * rt, const char * key); 70 | void comps_rtree_unset(COMPS_RTree * rt, const char * key); 71 | void comps_rtree_clear(COMPS_RTree * rt); 72 | 73 | void comps_rtree_values_walk(COMPS_RTree *rt, void* udata, 74 | void (*walk_f)(void*, void*)); 75 | COMPS_HSList * comps_rtree_values(COMPS_RTree *rt); 76 | COMPS_HSList* comps_rtree_keys(COMPS_RTree * rt); 77 | COMPS_HSList* comps_rtree_pairs(COMPS_RTree * rt); 78 | COMPS_RTree * comps_rtree_clone(COMPS_RTree * rt); 79 | COMPS_RTree* comps_rtree_union(COMPS_RTree *rt1, COMPS_RTree *rt2); 80 | void comps_rtree_unite(COMPS_RTree *rt1, COMPS_RTree *rt2); 81 | COMPS_RTree* comps_rtree_union(COMPS_RTree *rt1, COMPS_RTree *rt2); 82 | 83 | COMPS_RTreePair * comps_rtree_pair_create(char * key, void * data, 84 | void (*data_destructor(void*))); 85 | void comps_rtree_pair_destroy(COMPS_RTreePair * pair); 86 | void comps_rtree_pair_destroy_v(void * pair); 87 | 88 | void comps_rtree_print(COMPS_HSList * hl, unsigned deep); 89 | #endif 90 | -------------------------------------------------------------------------------- /libcomps/src/comps_set.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_Set_H 21 | #define COMPS_Set_H 22 | 23 | #include "comps_hslist.h" 24 | 25 | typedef struct { 26 | char (*eqf)(void*, void*); 27 | void (*data_destructor)(void*); 28 | void* (*data_cloner)(void*); 29 | void* (*data_constructor)(void*); 30 | COMPS_HSList *data; 31 | } COMPS_Set; 32 | 33 | void* comps_set_index_clone(void *item); 34 | COMPS_Set * comps_set_create(); 35 | void comps_set_destroy(COMPS_Set **set); 36 | void comps_set_destroy_v(void *set); 37 | void comps_set_init(COMPS_Set *set, void* (*data_constructor)(void*), 38 | void* (*data_cloner)(void*), 39 | void (*data_destructor)(void*), 40 | char (*eqf)(void*, void*)); 41 | 42 | char comps_set_in(COMPS_Set *set, void *item); 43 | char comps_set_add(COMPS_Set *set, void *item); 44 | void* comps_set_remove(COMPS_Set *set, void *item); 45 | char comps_set_is_empty(COMPS_Set *set); 46 | char comps_set_cmp(COMPS_Set *set1, COMPS_Set *set2); 47 | int comps_set_at(COMPS_Set *set, void *item); 48 | void* comps_set_data_at(COMPS_Set * set, void * item); 49 | void comps_set_clear(COMPS_Set *set); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libcomps/src/comps_types.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "comps_types.h" 21 | 22 | COMPS_XMLOptions COMPS_XMLDefaultOptions = { 23 | .empty_groups = false, 24 | .empty_categories = false, 25 | .empty_environments = false, 26 | .empty_langpacks = false, 27 | .empty_blacklist = false, 28 | .empty_whiteout = false, 29 | .empty_packages = false, 30 | .empty_grouplist = false, 31 | .empty_optionlist = false, 32 | .uservisible_explicit = false, 33 | .biarchonly_explicit = false, 34 | .default_explicit = false, 35 | .gid_default_explicit = false, 36 | .bao_explicit = false, 37 | .arch_output = false 38 | }; 39 | 40 | 41 | -------------------------------------------------------------------------------- /libcomps/src/comps_types.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef COMPS_TYPES_H 21 | #define COMPS_TYPES_H 22 | 23 | #include 24 | 25 | typedef struct COMPS_Log COMPS_Log; 26 | typedef struct COMPS_LogEntry COMPS_LogEntry; 27 | 28 | typedef struct COMPS_XMLOptions { 29 | bool empty_groups; 30 | bool empty_categories; 31 | bool empty_environments; 32 | bool empty_langpacks; 33 | bool empty_blacklist; 34 | bool empty_whiteout; 35 | bool empty_packages; 36 | bool empty_grouplist; 37 | bool empty_optionlist; 38 | bool biarchonly_explicit; 39 | bool uservisible_explicit; 40 | bool default_explicit; 41 | bool gid_default_explicit; 42 | bool bao_explicit; 43 | bool arch_output; 44 | } COMPS_XMLOptions; 45 | 46 | extern COMPS_XMLOptions COMPS_XMLDefaultOptions; 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /libcomps/src/comps_utils.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "comps_utils.h" 21 | #include "comps_log.h" 22 | 23 | void* __comps_str_clone(void *str) { 24 | char *ret; 25 | if (str == NULL) 26 | return NULL; 27 | ret = malloc(sizeof(char) * (strlen((char*)str)+1)); 28 | if (ret==NULL) return NULL; 29 | memcpy(ret, str, sizeof(char) * (strlen((char*)str)+1)); 30 | return ret; 31 | } 32 | 33 | inline char __comps_strcmp(void *s1, void *s2) { 34 | if (s1 == NULL && s2 == NULL) return 1; 35 | else if ((s1 == NULL && s2 != NULL) || (s1 != NULL && s2 == NULL)) return 0; 36 | return (strcmp((const char*)s1, (const char*)s2) == 0); 37 | } 38 | 39 | inline int __comps_xml_prop(char *key, char *val, 40 | xmlTextWriterPtr writer) { 41 | int retc; 42 | retc = xmlTextWriterStartElement(writer, BAD_CAST key) >= 0 ? 1 : 0; 43 | retc &= xmlTextWriterWriteString(writer, BAD_CAST val) >= 0 ? 1 : 0; 44 | retc &= xmlTextWriterEndElement(writer) >= 0 ? 1 : 0; 45 | return retc; 46 | } 47 | 48 | char* __comps_num2boolstr(COMPS_Object* obj) { 49 | char *ret; 50 | char *_bool; 51 | if (((COMPS_Num*)obj)->val) { 52 | _bool = "true"; 53 | } else { 54 | _bool = "false"; 55 | } 56 | ret = malloc(sizeof(char) * (strlen(_bool)+1)); 57 | ret[0] = 0; 58 | strcat(ret, _bool); 59 | return ret; 60 | } 61 | 62 | unsigned int digits_count(unsigned int x) { 63 | //unsigned int ret = 1; 64 | if (x >= 100000000) return 9; 65 | if (x >= 10000000) return 8; 66 | if (x >= 1000000) return 7; 67 | if (x >= 100000) return 6; 68 | if (x >= 10000) return 5; 69 | if (x >= 1000) return 4; 70 | if (x >= 100) return 3; 71 | if (x >= 10) return 2; 72 | return 1; 73 | } 74 | 75 | 76 | bool __comps_objlist_intersected(COMPS_ObjList *list1, COMPS_ObjList *list2) { 77 | for (COMPS_ObjListIt *it = list1->first; it != NULL; it = it->next) { 78 | for (COMPS_ObjListIt *it2 = list2->first; it2 != NULL; it2 = it2->next){ 79 | if (comps_object_cmp(it->comps_obj, it2->comps_obj)) 80 | return true; 81 | } 82 | } 83 | return false; 84 | } 85 | 86 | char* __comps_xml_arch_str(COMPS_Object *archlist) { 87 | size_t x, total_len = 0; 88 | COMPS_ObjListIt *it; 89 | char *arches_str; 90 | 91 | if (!archlist || !((COMPS_ObjList*)archlist)->len) { 92 | arches_str = malloc(sizeof(char)); 93 | arches_str[0] = 0; 94 | return arches_str; 95 | } 96 | 97 | char *arches[((COMPS_ObjList*)archlist)->len]; 98 | for (x=0, it = ((COMPS_ObjList*)archlist)->first; it != NULL; it = it->next, x++) { 99 | arches[x] = comps_object_tostr(it->comps_obj); 100 | total_len += strlen(arches[x])+1; 101 | } 102 | arches_str = malloc(sizeof(char) * (total_len)); 103 | arches_str[0]=0; 104 | 105 | x = 0; 106 | for (; x < (size_t)(((COMPS_ObjList*)archlist)->len-1); x++) { 107 | strcat(arches_str, arches[x]); 108 | free(arches[x]); 109 | strcat(arches_str, " "); 110 | } 111 | strcat(arches_str, arches[x]); 112 | free(arches[x]); 113 | return arches_str; 114 | } 115 | 116 | int __comps_xml_arch(COMPS_Object *archlist, xmlTextWriterPtr writer) { 117 | if (archlist && ((COMPS_ObjList*)archlist)->len != 0) { 118 | char * str = __comps_xml_arch_str(archlist); 119 | int ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "arch", 120 | BAD_CAST str); 121 | free(str); 122 | return ret; 123 | } else return 0; 124 | } 125 | 126 | 127 | char* __comps_strcpy(char *str) { 128 | char *ret; 129 | ret = malloc(sizeof(char)*(strlen(str)+1)); 130 | return memcpy(ret, str, sizeof(char)*(strlen(str)+1)); 131 | } 132 | 133 | char* __comps_strcat(char *str1, char *str2) { 134 | char *ret; 135 | ret = malloc(sizeof(char)*(strlen(str1)+strlen(str2)+1)); 136 | memcpy(ret, str1, sizeof(char)*(strlen(str1)+1)); 137 | strcat(ret, str2); 138 | return ret; 139 | } 140 | 141 | inline int __comps_check_xml_get(int retcode, COMPS_Object * log) { 142 | if (retcode<0) { 143 | comps_log_error((COMPS_Log*)log, COMPS_ERR_XMLGEN, 0); 144 | return -1; 145 | } return 0; 146 | } 147 | -------------------------------------------------------------------------------- /libcomps/src/comps_validate.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPS_VALIDATE_H 2 | #define COMPS_VALIDATE_H 3 | 4 | #include "comps_obj.h" 5 | #include "comps_utils.h" 6 | 7 | #define H_COMPS_VAL_RULE_GENERIC\ 8 | COMPS_ValGenResult* (*rule_check)(COMPS_ValRuleGeneric*, COMPS_Object*);\ 9 | char *verbose_msg 10 | 11 | #define H_COMPS_VAL_RESULT COMPS_Object_HEAD 12 | 13 | #define COMPS_VAL_RULE_PROP .rule_check = &comps_validate_rule_prop_check 14 | #define COMPS_VAL_RULE_LIST .rule_check = &comps_validate_rule_list_check 15 | #define COMPS_VAL_RULE_LIST2 .rule_check = &comps_validate_rule_list_check2 16 | #define COMPS_VAL_GETF COMPS_Object*(*)(COMPS_Object*) 17 | 18 | typedef struct COMPS_ValRuleGeneric COMPS_ValRuleGeneric; 19 | typedef struct COMPS_ValGenResult COMPS_ValGenResult; 20 | 21 | struct COMPS_ValRuleGeneric { 22 | H_COMPS_VAL_RULE_GENERIC; 23 | }; 24 | 25 | typedef struct COMPS_ValRuleProp { 26 | H_COMPS_VAL_RULE_GENERIC; 27 | COMPS_Object* (*get_f)(COMPS_Object*); 28 | COMPS_ValGenResult* (*check_f)(COMPS_Object*, COMPS_Object*); 29 | } COMPS_ValRuleProp; 30 | 31 | typedef struct COMPS_ValRuleList { 32 | H_COMPS_VAL_RULE_GENERIC; 33 | size_t offset; 34 | COMPS_ValGenResult* (*check_f)(COMPS_Object*, COMPS_Object*); 35 | } COMPS_ValRuleList; 36 | 37 | typedef struct COMPS_ValRuleList2 { 38 | H_COMPS_VAL_RULE_GENERIC; 39 | COMPS_Object* (*get_f)(COMPS_Object*); 40 | COMPS_ValGenResult* (*check_f)(COMPS_Object*, COMPS_Object*); 41 | } COMPS_ValRuleList2; 42 | 43 | struct COMPS_ValGenResult { 44 | H_COMPS_VAL_RESULT; 45 | }; 46 | COMPS_Object_TAIL(COMPS_ValGenResult); 47 | 48 | typedef struct COMPS_ValOkResult { 49 | H_COMPS_VAL_RESULT; 50 | } COMPS_ValOkResult; 51 | COMPS_Object_TAIL(COMPS_ValOkResult); 52 | 53 | typedef struct COMPS_ValErrResult { 54 | H_COMPS_VAL_RESULT; 55 | COMPS_ObjList *err_list; 56 | } COMPS_ValErrResult; 57 | COMPS_Object_TAIL(COMPS_ValErrResult); 58 | 59 | typedef struct COMPS_ValErr { 60 | COMPS_Object_HEAD; 61 | COMPS_Object *err_object; 62 | char *err_msg; 63 | } COMPS_ValErr; 64 | COMPS_Object_TAIL(COMPS_ValErr); 65 | 66 | 67 | COMPS_ValGenResult* comps_validate_rule_prop_check(COMPS_ValRuleGeneric *rule, 68 | COMPS_Object *obj); 69 | COMPS_ValGenResult* comps_validate_rule_list_check(COMPS_ValRuleGeneric *rule, 70 | COMPS_Object *obj); 71 | COMPS_ValGenResult* comps_validate_rule_list_check2(COMPS_ValRuleGeneric *rule, 72 | COMPS_Object *obj); 73 | COMPS_ValGenResult* comps_validate_execute(COMPS_Object *obj, 74 | COMPS_ValRuleGeneric *rules[]); 75 | 76 | COMPS_ValGenResult* comps_empty_check(COMPS_Object *obj, COMPS_Object *prop); 77 | COMPS_ValGenResult* comps_objlist_unique_check(COMPS_Object *object, 78 | COMPS_Object *objlist); 79 | void comps_valgenres_print(COMPS_ValGenResult *res, FILE *stream); 80 | void comps_valgenres_concat(COMPS_ValGenResult **res1, 81 | COMPS_ValGenResult *res2); 82 | void comps_valgenres_prefix(COMPS_ValGenResult *res, const char *prefix); 83 | 84 | //extern COMPS_ObjectInfo COMPS_ValGenResult_ObjInfo; 85 | //extern COMPS_ObjectInfo COMPS_ValOkResult_ObjInfo; 86 | //extern COMPS_ObjectInfo COMPS_ValErrResult_ObjInfo; 87 | //extern COMPS_ObjectInfo COMPS_ValErr_ObjInfo; 88 | #endif 89 | -------------------------------------------------------------------------------- /libcomps/src/libcomps_config.h.in: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #define libcomps_VERSION_MAJOR @libcomps_MAJOR@ 21 | #define libcomps_VERSION_MINOR @libcomps_MINOR@ 22 | -------------------------------------------------------------------------------- /libcomps/src/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (ENABLE_TESTS) 2 | include(tests/tests.cmake) 3 | endif () 4 | 5 | #include(pycopy.cmake) 6 | set(pycopy "py3-copy") 7 | 8 | set (pycomps_TESTSDIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/") 9 | 10 | 11 | set(PYCOMPS_LIB_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/") 12 | 13 | add_subdirectory(src) 14 | 15 | if (ENABLE_DOCS) 16 | add_subdirectory (docs) 17 | endif () 18 | -------------------------------------------------------------------------------- /libcomps/src/python/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc-sources/conf.py.in" 2 | "${CMAKE_CURRENT_SOURCE_DIR}/doc-sources/conf.py") 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} 5 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") 6 | 7 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 8 | 9 | 10 | #include(../pycopy.cmake) 11 | 12 | #find_package(Doxygen) 13 | #if(DOXYGEN_FOUND) 14 | # configure_file(Doxyfile.user.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.user) 15 | # add_custom_target (pydocs COMMAND ${DOXYGEN_EXECUTABLE} 16 | # ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.user 17 | # SOURCES ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.user) 18 | #endif(DOXYGEN_FOUND) 19 | 20 | find_package(Sphinx) 21 | 22 | set(pycopy pydocs) 23 | add_custom_target(pydocs) 24 | add_dependencies(pydocs pycomps) 25 | 26 | include(../pycopy.cmake) 27 | add_custom_command(TARGET pydocs PRE_BUILD COMMAND set -E $ENV{LD_LIBRARY_PATH} "${LIBCOMPS_OUT}:$ENV{LD_LIBRARY_PATH}") 28 | 29 | add_custom_command(TARGET pydocs COMMAND ${PYTHON_EXECUTABLE} ${SPHINX_EXECUTABLE} -E -b html 30 | "${CMAKE_CURRENT_SOURCE_DIR}/doc-sources/" 31 | "${CMAKE_CURRENT_BINARY_DIR}/html/" 32 | COMMENT "LDLP $ENV{LD_LIBRARY_PATH}") 33 | -------------------------------------------------------------------------------- /libcomps/src/python/docs/cmake/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | find_program(SPHINX_EXECUTABLE NAMES sphinx-build 2 | HINTS 3 | $ENV{SPHINX_DIR} 4 | PATH_SUFFIXES bin 5 | DOC "Sphinx documentation generator" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | 10 | find_package_handle_standard_args(Sphinx DEFAULT_MSG 11 | SPHINX_EXECUTABLE 12 | ) 13 | 14 | mark_as_advanced(SPHINX_EXECUTABLE) 15 | 16 | -------------------------------------------------------------------------------- /libcomps/src/python/docs/doc-sources/index.rst: -------------------------------------------------------------------------------- 1 | .. x documentation primary file, created by 2 | sphinx-quickstart on Mon Dec 9 16:34:26 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Libcomps documentation! 7 | ================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | comps 15 | unioning 16 | 17 | Indices and tables 18 | ================== 19 | 20 | * :ref:`genindex` 21 | * :ref:`modindex` 22 | * :ref:`search` 23 | 24 | -------------------------------------------------------------------------------- /libcomps/src/python/docs/doc-sources/unioning.rst: -------------------------------------------------------------------------------- 1 | Libcomps unioning policy 2 | ======================== 3 | 4 | Object Unioning 5 | --------------- 6 | 7 | Complex Object unioning policy 8 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 | 10 | * Two libcomps.Comps object can be unioned into one by __add__ operator 11 | like `o = o1 + o2`. This operator can be applicated on `libcomps.Category` 12 | `libcomps.Group`, `libcomps.Environment` 13 | 14 | * New object have all properties of first operand (o1). If there's some 15 | properties in second operand(o2) overlaying first operand properties, 16 | theese properties will be overwritten in result (o) by second operand 17 | properties (o2). 18 | 19 | * Inner list and dict objects are unioned by rules bellow 20 | 21 | List Object unioning policy 22 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 | * libcomps list objects are unioned by Append-Replace-Append policy. That 24 | means: 25 | 26 | - all items from first list is appended to result list 27 | - if there's some item in second list which is equal some item in 28 | result list, item in result list will be overwritten by item from 29 | second list(position of item in result list remans same!). 30 | - rest of items in second list is appeneded in second list order 31 | to result list 32 | * List items are compared by id attribute (group, category, evinronment) or 33 | by name attribute (package, groupid) 34 | 35 | Dict Object unioning policy 36 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 37 | * Unioning two libcomps dict objects means that result will have all 38 | (key,value) pair from first dict, overlaied pair with second dict is 39 | overwritten and rest of pairs from second dist is set to result dict. 40 | (All libcomps dict have inner alphabetical order!) 41 | 42 | Examples 43 | -------- 44 | 45 | .. code-block:: python 46 | 47 | c1 = libcomps.Category() 48 | c1.id = "c1" 49 | c1.desc = "category 1" 50 | c1.group_list.append("groupid1") 51 | c2.group_list.append("groupid3") 52 | c2 = libcomps.Category() 53 | c2.id = "c2" 54 | c2.group_list.append("groupid2") 55 | c2.group_list.append("groupid3") 56 | 57 | c = c1 + c2 58 | print c.id 59 | >>> c2 60 | print c.description 61 | >>> category 1 62 | print c.group_list 63 | >>> , 64 | , 65 | ] 66 | 67 | cl1 = libcomps.CategoryList() 68 | cl2 = libcomps.CategoryList() 69 | 70 | 71 | c1 = libcomps.Category(id="c1") 72 | c1.group_ids.append("gid1 1") 73 | c1.group_ids.append("gid1 2") 74 | 75 | c3 = libcomps.Category(id="c3") 76 | c3.group_ids.append("gid3 1") 77 | c3.group_ids.append("gid3 2") 78 | 79 | c4 = libcomps.Category(id="c4") 80 | 81 | c2 = libcomps.Category(id="c2") 82 | c2.group_ids.append("gid2 1") 83 | c2.group_ids.append("gid2 2") 84 | cl1.append(c1) 85 | cl1.append(c2) 86 | cl1.append(c3) 87 | cl1.append(c4) 88 | 89 | c5 = libcomps.Category(id="c5") 90 | 91 | c3 = libcomps.Category(id="c3") 92 | c3.group_ids.append("gid3 1") 93 | c3.group_ids[0].default = True 94 | 95 | c6 = libcomps.Category(id="c6") 96 | 97 | c2 = libcomps.Category(id="c4") 98 | c2.group_ids.append("gid2 1") 99 | c2.group_ids.append("gid2 3") 100 | 101 | cl2.append(c2) 102 | cl2.append(c3) 103 | cl2.append(c5) 104 | cl2.append(c6) 105 | 106 | 107 | cl = cl1 + cl2 108 | ids = [x.id for x in cl] 109 | print ids 110 | >>> [u'c1', u'c2', u'c3', u'c4', u'c5', u'c6'] 111 | print cl["c2"].name 112 | >>> c2_2 113 | print cl["c2"].group_ids 114 | >>> [, 115 | ] 116 | print cl["c3"].name 117 | >>> c3_2 118 | print cl["c3"].group_ids 119 | >>> [, 120 | ] 121 | 122 | -------------------------------------------------------------------------------- /libcomps/src/python/examples/libcomps_example.py: -------------------------------------------------------------------------------- 1 | import libcomps 2 | 3 | if __name__ == "__main__": 4 | comps = libcomps.Comps() 5 | categories_ids = ["cat1", "cat2", "cat3"] 6 | categories_names = ["category1", "category2", "category3"] 7 | categories_descriptions = ["category description1", "category_description2", 8 | "category description3"] 9 | categories_group_ids = [["g1", "g2"], ["g1"], ["g2","g3"]] 10 | for x in range(0,3): 11 | c = libcomps.Category(categories_ids[x], categories_names[x], 12 | categories_descriptions[x]) 13 | for y in categories_group_ids[x]: 14 | c.group_ids.append(y) 15 | comps.categories.append(c) 16 | print (comps.xml_str()) 17 | -------------------------------------------------------------------------------- /libcomps/src/python/pycopy.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(${PROJECT_SOURCE_DIR}/src/python/tests/tests.cmake) 3 | 4 | list(LENGTH TESTS_FILES len) 5 | math (EXPR len "${len} - 1") 6 | 7 | #set(pycopy "py${pversion}-copy") 8 | 9 | #if (NOT TARGET ${pycopy}) 10 | 11 | #add_custom_target(${pycopy} DEPENDS pycomps) 12 | set (pycomps_SRCDIR "${PROJECT_SOURCE_DIR}/src/python/src/") 13 | set (pycomps_TESTDIR "${PROJECT_SOURCE_DIR}/src/python/tests/") 14 | set (pycomps_LIBPATH ${PYCOMPS_LIB_PATH})#"${PROJECT_BINARY_DIR}/src/python/src/python${pversion}") 15 | 16 | #add_custom_command(TARGET pycopy PRE_BUILD COMMAND ${CMAKE_COMMAND} -E 17 | # make_directory "${CP_DST}") 18 | 19 | add_custom_command(TARGET ${pycopy} COMMAND ${CMAKE_COMMAND} -E 20 | make_directory ${pycomps_LIBPATH}/libcomps/comps/) 21 | 22 | foreach(x RANGE 0 ${len}) 23 | list(GET TESTS_FILES ${x} val) 24 | add_custom_command(TARGET ${pycopy} POST_BUILD COMMAND ${CMAKE_COMMAND} -E 25 | copy ${pycomps_TESTSDIR}${val} 26 | ${pycomps_LIBPATH}/libcomps/ 27 | COMMENT "copy ${pycomps_TESTSDIR}/${val} to ${pycomps_LIBPATH}/libcomps/") 28 | endforeach() 29 | 30 | list(LENGTH COMPS_FILES len) 31 | math (EXPR len "${len} - 1") 32 | foreach(x RANGE 0 ${len}) 33 | list(GET COMPS_FILES ${x} val) 34 | add_custom_command(TARGET ${pycopy} POST_BUILD COMMAND ${CMAKE_COMMAND} -E 35 | copy ${pycomps_TESTSDIR}/comps/${val} 36 | ${pycomps_LIBPATH}/libcomps/comps/ 37 | COMMENT "${pycomps_TESTSDIR}/comps/${val} to ${pycomps_LIBPATH}/libcomps/comps/") 38 | #file(COPY ${pycomps_TESTSDIR}/comps/${val} DESTINATION ./libcomps/comps/) 39 | endforeach() 40 | add_custom_command(TARGET ${pycopy} POST_BUILD COMMAND ${CMAKE_COMMAND} -E 41 | copy ${pycomps_SRCDIR}/libcomps/__init__.py ${pycomps_LIBPATH}/libcomps/ 42 | COMMENT "copy ${pycomps_SRCDIR}/libcomps/__init__.py to ${pycomps_LIBPATH}/libcomps/") 43 | 44 | configure_file(${pycomps_TESTSDIR}run_tests.sh.in ${pycomps_LIBPATH}/libcomps/run_tests.sh) 45 | #endif (NOT TARGET ${pycopy}) 46 | -------------------------------------------------------------------------------- /libcomps/src/python/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | macro(LIST_REPLACE _LIST INDEX VALUE) 2 | list(INSERT ${_LIST} ${INDEX} ${VALUE}) 3 | MATH(EXPR __INDEX "${INDEX} + 1") 4 | list (REMOVE_AT ${_LIST} ${__INDEX}) 5 | endmacro(LIST_REPLACE) 6 | 7 | set (pycomps_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}) 8 | 9 | set (pycomps_SRC pycomps.c pycomps_sequence.c 10 | pycomps_envs.c pycomps_categories.c pycomps_groups.c 11 | pycomps_gids.c pycomps_utils.c pycomps_dict.c pycomps_mdict.c 12 | pycomps_hash.c pycomps_exc.c pycomps_lbw.c) 13 | 14 | set (pycomps_HEADERS pycomps_macros.h pycomps_sequence.h 15 | pycomps_envs.h pycomps_categories.h pycomps_groups.h 16 | pycomps_gids.h pycomps_utils.h pycomps_dict.h pycomps_mdict.h 17 | pycomps_hash.h pycomps_exc.h pycomps_lbw.h 18 | pycomps_types.h) 19 | 20 | #set(TEST_FILES ../__init__.py __test.py test_merge_comps.py test_libcomps.py 21 | # utest.py) 22 | # 23 | #set(TEST_COMPS fedora_comps.xml sample_comps.xml 24 | # sample_comps2.xml sample_comps2.xml.gz main_comps.xml 25 | # main_comps2.xml main_arches.xml f21-rawhide-comps.xml 26 | # comps-f21.xml.in 27 | # comps/comps_part1.xml comps/comps_part2.xml 28 | # comps/merged_comps_1_2.xml comps/merged_comps_2_1.xml 29 | # comps/comps-f21.xml) 30 | 31 | list (LENGTH pycomps_SRC pycomps_SRCLEN) 32 | math (EXPR pycomps_SRCLEN "${pycomps_SRCLEN} - 1") 33 | foreach(i RANGE 0 ${pycomps_SRCLEN}) 34 | list (GET pycomps_SRC ${i} val) 35 | LIST_REPLACE(pycomps_SRC ${i} "${CMAKE_CURRENT_SOURCE_DIR}/${val}") 36 | endforeach(i) 37 | 38 | list (LENGTH pycomps_HEADERS pycomps_SRCLEN) 39 | math (EXPR pycomps_SRCLEN "${pycomps_SRCLEN} - 1") 40 | foreach(i RANGE 0 ${pycomps_SRCLEN}) 41 | list (GET pycomps_HEADERS ${i} val) 42 | LIST_REPLACE(pycomps_HEADERS ${i} "${CMAKE_CURRENT_SOURCE_DIR}/${val}") 43 | endforeach(i) 44 | 45 | if (NOT SKBUILD) 46 | find_package (PythonInterp 3 EXACT REQUIRED) 47 | find_package (PythonLibs 3 EXACT) 48 | endif(NOT SKBUILD) 49 | 50 | include_directories(${PYTHON_INCLUDE_DIR}) 51 | include_directories(${LIBCOMPS_INCLUDE_PATH}) 52 | 53 | if (ENABLE_TESTS) 54 | configure_file(${pycomps_TESTSDIR}/run_tests.sh.in ./libcomps/run_tests.sh) 55 | endif () 56 | 57 | include(../pycopy.cmake) 58 | 59 | add_library(pycomps SHARED ${pycomps_SRC}) 60 | set_target_properties(pycomps PROPERTIES LIBRARY_OUTPUT_DIRECTORY "./libcomps") 61 | set_target_properties(pycomps PROPERTIES PREFIX "") 62 | set_target_properties(pycomps PROPERTIES LIBRARY_OUTPUT_NAME "_libpycomps") 63 | add_dependencies(pycomps src-copy) 64 | 65 | target_link_libraries(pycomps libcomps) 66 | target_link_libraries(pycomps ${EXPAT_LIBRARIES}) 67 | target_link_libraries(pycomps ${LIBXML2_LIBRARIES}) 68 | 69 | if (NOT SKBUILD) 70 | # manylinux links statically, no libpythonX.so available 71 | # https://github.com/pypa/manylinux/issues/255#issuecomment-450761634 72 | target_link_libraries(pycomps ${PYTHON_LIBRARIES}) 73 | endif (NOT SKBUILD) 74 | 75 | if (ENABLE_TESTS) 76 | set(pycopy pytest_run) 77 | 78 | add_custom_target(pytest_run COMMAND ./run_tests.sh 79 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libcomps/ 80 | COMMENT "Running python binding tests") 81 | add_dependencies(pytest_run pycomps py3-copy) 82 | endif () 83 | 84 | IF (SKBUILD) 85 | INSTALL(FILES libcomps/__init__.py DESTINATION libcomps/src/python/src/libcomps) 86 | INSTALL(TARGETS pycomps LIBRARY DESTINATION libcomps/src/python/src/libcomps) 87 | ELSE () 88 | EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from sysconfig import get_path; stdout.write(get_path('platlib'))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR) 89 | 90 | INSTALL(FILES ${pycomps_SRCDIR}/libcomps/__init__.py DESTINATION ${PYTHON_INSTALL_DIR}/libcomps) 91 | #INSTALL(FILES ${pycomps_SRCDIR}/tests/__test.py DESTINATION 92 | # ${PYTHON_INSTALL_DIR}/libcomps/) 93 | #INSTALL(FILES ${pycomps_SRCDIR}/tests/fedora_comps.xml DESTINATION 94 | # ${PYTHON_INSTALL_DIR}/libcomps/) 95 | #INSTALL(FILES ${pycomps_SRCDIR}/tests/sample_comps.xml DESTINATION 96 | # ${PYTHON_INSTALL_DIR}/libcomps/) 97 | #INSTALL(FILES ${pycomps_SRCDIR}/tests/main_comps.xml DESTINATION 98 | # ${PYTHON_INSTALL_DIR}/libcomps/) 99 | #INSTALL(FILES ${pycomps_SRCDIR}/tests/main_comps2.xml DESTINATION 100 | # ${PYTHON_INSTALL_DIR}/libcomps/) 101 | INSTALL (TARGETS pycomps LIBRARY DESTINATION ${PYTHON_INSTALL_DIR}/libcomps) 102 | # Version has to be passed as last argument. 103 | INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../setup_for_python_metadata.py install_egg_info --install-dir \$ENV{DESTDIR}/${PYTHON_INSTALL_DIR}/ ${VERSION})") 104 | ENDIF (SKBUILD) 105 | -------------------------------------------------------------------------------- /libcomps/src/python/src/crc32.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or 3 | * code or tables extracted from it, as desired without restriction. 4 | * 5 | * First, the polynomial itself and its table of feedback terms. The 6 | * polynomial is 7 | * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 8 | * 9 | * Note that we take it "backwards" and put the highest-order term in 10 | * the lowest-order bit. The X^32 term is "implied"; the LSB is the 11 | * X^31 term, etc. The X^0 term (usually shown as "+1") results in 12 | * the MSB being 1 13 | * 14 | * Note that the usual hardware shift register implementation, which 15 | * is what we're using (we're merely optimizing it by doing eight-bit 16 | * chunks at a time) shifts bits into the lowest-order term. In our 17 | * implementation, that means shifting towards the right. Why do we 18 | * do it this way? Because the calculated CRC must be transmitted in 19 | * order from highest-order term to lowest-order term. UARTs transmit 20 | * characters in order from LSB to MSB. By storing the CRC this way 21 | * we hand it to the UART in the order low-byte to high-byte; the UART 22 | * sends each low-bit to hight-bit; and the result is transmission bit 23 | * by bit from highest- to lowest-order term without requiring any bit 24 | * shuffling on our part. Reception works similarly 25 | * 26 | * The feedback terms table consists of 256, 32-bit entries. Notes 27 | * 28 | * The table can be generated at runtime if desired; code to do so 29 | * is shown later. It might not be obvious, but the feedback 30 | * terms simply represent the results of eight shift/xor opera 31 | * tions for all combinations of data and CRC register values 32 | * 33 | * The values must be right-shifted by eight bits by the "updcrc 34 | * logic; the shift must be unsigned (bring in zeroes). On some 35 | * hardware you could probably optimize the shift in assembler by 36 | * using byte-swap instructions 37 | * polynomial $edb88320 38 | * 39 | * 40 | * CRC32 code derived from work by Gary S. Brown. 41 | */ 42 | 43 | #ifndef CRC32_H 44 | #define CRC32_H 45 | uint32_t crc32(uint32_t crc, const void *buf, size_t size); 46 | #endif 47 | -------------------------------------------------------------------------------- /libcomps/src/python/src/libcomps/__init__.py: -------------------------------------------------------------------------------- 1 | from ._libpycomps import * 2 | 3 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_H 21 | #define PYCOMPS_H 22 | 23 | #include 24 | #include 25 | 26 | #include "libcomps/comps_doc.h" 27 | #include "libcomps/comps_parse.h" 28 | #include "libcomps/comps_dict.h" 29 | #include "libcomps/comps_log.h" 30 | 31 | #include "pycomps_macros.h" 32 | 33 | #include "pycomps_categories.h" 34 | #include "pycomps_groups.h" 35 | #include "pycomps_envs.h" 36 | #include "pycomps_utils.h" 37 | #include "pycomps_dict.h" 38 | #include "pycomps_mdict.h" 39 | #include "pycomps_gids.h" 40 | #include "pycomps_exc.h" 41 | #include "pycomps_lbw.h" 42 | 43 | 44 | typedef struct { 45 | PyTypeObject * type; 46 | size_t pobj_offset; 47 | COMPS_ObjList *(*get_f)(COMPS_Doc*); 48 | void (*set_f)(COMPS_Doc*, COMPS_ObjList*); 49 | } PyCOMPS_GetSetClosure; 50 | 51 | typedef struct { 52 | PyTypeObject * type; 53 | size_t pobj_offset; 54 | COMPS_ObjDict *(*get_f)(COMPS_Doc*); 55 | void (*set_f)(COMPS_Doc*, COMPS_ObjDict*); 56 | } PyCOMPS_DGetSetClosure; 57 | 58 | typedef struct { 59 | PyTypeObject * type; 60 | size_t pobj_offset; 61 | COMPS_ObjMDict *(*get_f)(COMPS_Doc*); 62 | void (*set_f)(COMPS_Doc*, COMPS_ObjMDict*); 63 | } PyCOMPS_MDGetSetClosure; 64 | 65 | typedef struct { 66 | PyObject_HEAD 67 | COMPS_Doc * comps_doc; 68 | PyObject *p_groups; 69 | PyObject *p_categories; 70 | PyObject *p_environments; 71 | PyObject *p_langpacks; 72 | PyObject *p_blacklist; 73 | PyObject *p_whiteout; 74 | } PyCOMPS; 75 | 76 | PyCOMPS_GetSetClosure * get_closure(void * closure); 77 | 78 | extern PyTypeObject PyCOMPS_Type; 79 | 80 | const char PYCOMPS_DOCU[] = "Comps class is representating comps.xml file" 81 | " represented in structure form."; 82 | 83 | 84 | static PyObject* PyCOMPS_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 85 | static int PyCOMPS_init(PyCOMPS *self, PyObject *args, PyObject *kwds); 86 | #endif 87 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_categories.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_CATEGORIES_H 21 | #define PYCOMPS_CATEGORIES_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | #include "libcomps/comps_doc.h" 26 | //#include "libcomps/comps_list.h" 27 | 28 | #include "pycomps_sequence.h" 29 | #include "pycomps_dict.h" 30 | #include "pycomps_gids.h" 31 | #include "pycomps_utils.h" 32 | 33 | typedef struct { 34 | PyObject_HEAD 35 | COMPS_DocCategory *c_obj; 36 | PyObject *p_group_ids; 37 | PyObject *p_name_by_lang; 38 | PyObject *p_desc_by_lang; 39 | } PyCOMPS_Category; 40 | 41 | __H_COMPS_STRPROP_GETSET_CLOSURE(COMPS_DocCategory) /*pycomps_utils.h macro*/ 42 | __H_COMPS_NUMPROP_GETSET_CLOSURE(COMPS_DocCategory) /*pycomps_utils.h macro*/ 43 | __H_COMPS_LIST_GETSET_CLOSURE(COMPS_DocCategory) /*pycomps_utils.h macro*/ 44 | __H_COMPS_DICT_GETSET_CLOSURE(COMPS_DocCategory) /*pycomps_utils.h macro*/ 45 | 46 | COMPS_ObjList* comps_cats_union(COMPS_ObjList *cats1, COMPS_ObjList *cats2); 47 | 48 | PyObject* PyCOMPSCat_convert(void *c); 49 | 50 | void PyCOMPSCat_dealloc(PyObject *self); 51 | PyObject * PyCOMPSCat_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 52 | int PyCOMPSCat_init(PyCOMPS_Category *self, PyObject *args, PyObject *kwds); 53 | 54 | PyObject* PyCOMPSCats_append(PyObject * self, PyObject *item); 55 | 56 | void PyCOMPSCats_dealloc(PyCOMPS_Sequence* self); 57 | int PyCOMPSCats_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 58 | 59 | PyObject* PyCOMPSCat_get_name_by_lang(PyObject *self, void *closure); 60 | int PyCOMPSCat_set_name_by_lang(PyObject *self, PyObject *value, void *closure); 61 | PyObject* PyCOMPSCat_get_desc_by_lang(PyObject *self, void *closure); 62 | int PyCOMPSCat_set_desc_by_lang(PyObject *self, PyObject *value, void *closure); 63 | 64 | 65 | extern PyTypeObject PyCOMPS_CatsType; 66 | extern PyTypeObject PyCOMPS_CatType; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_dict.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_DICT_H 21 | #define PYCOMPS_DICT_H 22 | 23 | #include "libcomps/comps_doc.h" 24 | #include "libcomps/comps_objdict.h" 25 | 26 | //#include "pycomps_types.h" 27 | #include "pycomps_utils.h" 28 | 29 | #include "pyport.h" 30 | #include 31 | #include "structmember.h" 32 | 33 | 34 | void PyCOMPSDict_dealloc(PyCOMPS_Dict *self); 35 | PyObject* PyCOMPSDict_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 36 | int PyCOMPSDict_init(PyCOMPS_Dict *self, PyObject *args, PyObject *kwds); 37 | PyObject* PyCOMPSDict_str(PyObject *self); 38 | PyObject* PyCOMPSSeq_cmp(PyObject *self, PyObject *other, int op); 39 | PyObject* PyCOMPSDict_getiteritems(PyObject *self); 40 | 41 | PyObject* PyCOMPSDictIter_new(PyTypeObject *type, PyObject *args, 42 | PyObject *kwds); 43 | int PyCOMPSDictIter_init(PyCOMPS_DictIter *self, PyObject *args, PyObject *kwds); 44 | void PyCOMPSDictIter_dealloc(PyCOMPS_DictIter *self); 45 | PyObject* PyCOMPSDict_iternext(PyObject *iter_o); 46 | 47 | COMPS_Object* __pycomps_unicode_in(PyObject *obj); 48 | COMPS_Object* __pycomps_bytes_in(PyObject *pobj); 49 | PyObject* __pycomps_str_out(COMPS_Object *obj); 50 | 51 | extern PyTypeObject PyCOMPS_StrDictType; 52 | extern PyCOMPS_ItemInfo PyCOMPS_StrDictInfo; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_envs.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_ENVS_H 21 | #define PYCOMPS_ENVS_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | #include "libcomps/comps_doc.h" 26 | //#include "libcomps/comps_list.h" 27 | 28 | #include "pycomps_sequence.h" 29 | #include "pycomps_gids.h" 30 | #include "pycomps_utils.h" 31 | #include "pycomps_macros.h" 32 | #include "pycomps_dict.h" 33 | #include "pycomps_sequence.h" 34 | 35 | /*typedef struct { 36 | PyObject_HEAD 37 | COMPS_List *list; 38 | } PyCOMPS_Envs; 39 | */ 40 | 41 | typedef struct { 42 | PyObject_HEAD 43 | COMPS_DocEnv *c_obj; 44 | PyObject *p_group_list; 45 | PyObject *p_option_list; 46 | PyObject *p_name_by_lang; 47 | PyObject *p_desc_by_lang; 48 | } PyCOMPS_Env; 49 | 50 | __H_COMPS_STRPROP_GETSET_CLOSURE(COMPS_DocEnv) /*pycomps_utils.h macro*/ 51 | __H_COMPS_NUMPROP_GETSET_CLOSURE(COMPS_DocEnv) /*pycomps_utils.h macro*/ 52 | __H_COMPS_LIST_GETSET_CLOSURE(COMPS_DocEnv) /*pycomps_utils.h macro*/ 53 | __H_COMPS_DICT_GETSET_CLOSURE(COMPS_DocEnv) /*pycomps_utils.h macro*/ 54 | 55 | COMPS_ObjList* comps_envs_union(COMPS_ObjList *envs1, COMPS_ObjList *envs2); 56 | 57 | PyObject* PyCOMPSEnv_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 58 | int PyCOMPSEnvs_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 59 | 60 | int PyCOMPSEnv_init(PyCOMPS_Env *self, PyObject *args, PyObject *kwds); 61 | 62 | PyObject* PyCOMPSEnv_get_name_by_lang(PyObject *self, void *closure); 63 | int PyCOMPSEnv_set_name_by_lang(PyObject *self, PyObject *value, void *closure); 64 | PyObject* PyCOMPSEnv_get_desc_by_lang(PyObject *self, void *closure); 65 | int PyCOMPSEnv_set_desc_by_lang(PyObject *self, PyObject *value, void *closure); 66 | 67 | PyObject* PyCOMPSEnvs_append(PyObject * self, PyObject *item); 68 | 69 | extern PyTypeObject PyCOMPS_EnvType; 70 | extern PyTypeObject PyCOMPS_EnvsType; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_exc.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "pycomps_exc.h" 21 | PyObject * PyCOMPSExc_XMLGenError = NULL; 22 | PyObject * PyCOMPSExc_ParserError = NULL; 23 | 24 | void init_exceptions() { 25 | PyCOMPSExc_XMLGenError = PyErr_NewException("_libpycomps.XMLGenError", 26 | NULL, NULL); 27 | PyCOMPSExc_ParserError = PyErr_NewException("_libpycomps.ParserError", 28 | NULL, NULL); 29 | } 30 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_exc.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_EXC_H 21 | #define PYCOMPS_EXC_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | extern PyObject * PyCOMPSExc_ParserError; 26 | extern PyObject * PyCOMPSExc_XMLGenError; 27 | 28 | void init_exceptions(); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_gids.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_GIDS_H 21 | #define PYCOMPS_GIDS_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | #include "libcomps/comps_doc.h" 26 | //#include "libcomps/comps_list.h" 27 | #include "libcomps/comps_docgroupid.h" 28 | 29 | #include "pycomps_types.h" 30 | #include "pycomps_utils.h" 31 | #include "pycomps_macros.h" 32 | #include "pycomps_sequence.h" 33 | 34 | typedef struct { 35 | PyObject_HEAD 36 | COMPS_DocGroupId *c_obj; 37 | } PyCOMPS_GID; 38 | 39 | __H_COMPS_STRPROP_GETSET_CLOSURE(COMPS_DocGroupId) /*pycomps_utils.h macro*/ 40 | 41 | COMPS_DocGroupId* pycomps_gid_get(PyObject *pygid); 42 | PyObject* PyCOMPSGID_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 43 | int PyCOMPSGID_init(PyCOMPS_GID *self, PyObject *args, PyObject *kwds); 44 | PyObject* PyCOMPSGID_convert(void *gid); 45 | 46 | int PyCOMPSGIDs_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_groups.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_GROUPS_H 21 | #define PYCOMPS_GROUPS_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | #include "libcomps/comps_doc.h" 26 | //#include "libcomps/comps_list.h" 27 | 28 | #include "pycomps_sequence.h" 29 | #include "pycomps_utils.h" 30 | #include "pycomps_ids.h" 31 | #include "pycomps_dict.h" 32 | #include "pycomps_macros.h" 33 | 34 | typedef struct { 35 | PyObject_HEAD 36 | COMPS_DocGroup *c_obj; 37 | PyObject *p_packages; 38 | PyObject *p_name_by_lang; 39 | PyObject *p_desc_by_lang; 40 | } PyCOMPS_Group; 41 | 42 | typedef struct { 43 | PyObject_HEAD 44 | COMPS_DocGroupPackage * c_obj; 45 | } PyCOMPS_Package; 46 | 47 | __H_COMPS_STRPROP_GETSET_CLOSURE(COMPS_DocGroup) /*pycomps_utils.h macro*/ 48 | __H_COMPS_NUMPROP_GETSET_CLOSURE(COMPS_DocGroup) /*pycomps_utils.h macro*/ 49 | __H_COMPS_LIST_GETSET_CLOSURE(COMPS_DocGroup) /*pycomps_utils.h macro*/ 50 | __H_COMPS_DICT_GETSET_CLOSURE(COMPS_DocGroup) /*pycomps_utils.h macro*/ 51 | 52 | __H_COMPS_STRPROP_GETSET_CLOSURE(COMPS_DocGroupPackage) /*pycomps_utils.h macro*/ 53 | __H_COMPS_NUMPROP_GETSET_CLOSURE(COMPS_DocGroupPackage) /*pycomps_utils.h macro*/ 54 | 55 | COMPS_ObjList* comps_groups_union(COMPS_ObjList *groups1, 56 | COMPS_ObjList *groups2); 57 | 58 | 59 | void PyCOMPSGroup_dealloc(PyObject *self); 60 | PyObject * PyCOMPSGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 61 | int PyCOMPSGroup_init(PyCOMPS_Group *self, PyObject *args, PyObject *kwds); 62 | PyObject* PyCOMPSGroup_get_name_by_lang(PyCOMPS_Group *self, void *closure); 63 | int PyCOMPSGroup_set_name_by_lang(PyCOMPS_Group *self, PyObject *value, 64 | void *closure); 65 | PyObject* PyCOMPSGroup_get_desc_by_lang(PyCOMPS_Group *self, void *closure); 66 | int PyCOMPSGroup_set_desc_by_lang(PyCOMPS_Group *self, PyObject *value, 67 | void *closure); 68 | PyObject* PyCOMPSGroup_packages_match(PyObject *self, PyObject *args, 69 | PyObject *kwds); 70 | 71 | PyObject * PyCOMPSGroups_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 72 | int PyCOMPSGroups_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 73 | 74 | void pycomps_pkg_decref(void * pkg); 75 | void pycomps_pkg_incref(void * pkg); 76 | void pycomps_pkg_destroy(void * pkg); 77 | void comps_pkg_print(FILE *f, void *p); 78 | 79 | COMPS_DocGroupPackage* pycomps_pkg_get(PyObject *pypkg); 80 | PyObject* PyCOMPSPack_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 81 | int PyCOMPSPack_init(PyCOMPS_Package *self, PyObject *args, PyObject *kwds); 82 | PyObject* PyCOMPSPack_convert(void *p); 83 | 84 | int PyCOMPSPacks_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 85 | 86 | extern PyTypeObject PyCOMPS_GroupsType; 87 | extern PyTypeObject PyCOMPS_GroupType; 88 | extern PyTypeObject PyCOMPS_PacksType; 89 | extern PyTypeObject PyCOMPS_PackType; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_hash.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "pycomps_hash.h" 21 | #include "pycomps_utils.h" 22 | 23 | Py_hash_t PyCOMPS_hash(PyObject *self) { 24 | char *cstr = NULL; 25 | Py_hash_t crc; 26 | 27 | cstr = comps_object_tostr(((PyCompsObject*)self)->c_obj); 28 | crc = crc32(0, cstr, strlen(cstr)); 29 | free(cstr); 30 | return crc; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_hash.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_HASH_H 21 | #define PYCOMPS_HASH_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | #include "crc32.h" 26 | #include "pycomps_utils.h" 27 | 28 | 29 | Py_hash_t PyCOMPS_hash(PyObject *self); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_ids.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "pycomps_ids.h" 21 | 22 | void* str_from_PyObj_convert(PyObject *obj) { 23 | char *str; 24 | if (__pycomps_arg_to_char(obj, &str)) { 25 | return NULL; 26 | } 27 | return str; 28 | } 29 | 30 | char pycomps_ids_cmp(void *id1, void *id2) { 31 | return !strcmp((char*)id1,(char*)id2); 32 | } 33 | 34 | int PyCOMPSIDs_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds) 35 | { 36 | (void)args; 37 | (void)kwds; 38 | comps_list_init(get_list((PyObject*)self)); 39 | 40 | self->itemtypes = malloc(sizeof(PyTypeObject*)*2); 41 | self->in_convert_funcs = malloc(sizeof(PyCOMPSSeq_in_itemconvert)*2); 42 | self->itemtypes[0] = &PyUnicode_Type; 43 | self->in_convert_funcs[0] = str_from_PyObj_convert; 44 | self->itemtypes[1] = &PyBytes_Type; 45 | self->in_convert_funcs[1] = str_from_PyObj_convert; 46 | self->item_types_len = 2; 47 | 48 | self->out_convert_func = &str_to_unicode; 49 | self->item_cmp_func = &pycomps_ids_cmp; 50 | return 0; 51 | } 52 | 53 | PyMemberDef PyCOMPSIDs_members[] = { 54 | {NULL}}; 55 | 56 | PyMethodDef PyCOMPSIDs_methods[] = { 57 | //{"append", (PyCFunction)PyCOMPSIDs_append, METH_O, 58 | // "Append item to new of the list"}, 59 | {NULL} /* Sentinel */ 60 | }; 61 | 62 | PyTypeObject PyCOMPS_IDsType = { 63 | PyVarObject_HEAD_INIT(NULL, 0) 64 | "libcomps.IdList", /*tp_name*/ 65 | sizeof(PyCOMPS_Sequence), /*tp_basicsize*/ 66 | sizeof(PyObject), /*tp_itemsize*/ 67 | (destructor)PyCOMPSSeq_dealloc, /*tp_dealloc*/ 68 | 0, /*tp_print*/ 69 | 0, /*tp_getattr*/ 70 | 0, /*tp_setattr*/ 71 | 0, /*tp_compare*/ 72 | 0, /*tp_repr*/ 73 | 0, /*tp_as_number*/ 74 | 0,//&PyCOMPSID_sequence, /*tp_as_sequence*/ 75 | 0, /*tp_as_mapping*/ 76 | 0, /*tp_hash */ 77 | 0, /*tp_call*/ 78 | PyCOMPSSeq_str, /*tp_str*/ 79 | 0, /*tp_getattro*/ 80 | 0, /*tp_setattro*/ 81 | 0, /*tp_as_buffer*/ 82 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_TYPE_SUBCLASS, /*tp_flags*/ 83 | "Comps Id list", /* tp_doc */ 84 | 0, /* tp_traverse */ 85 | 0, /* tp_clear */ 86 | &PyCOMPSSeq_cmp, /* tp_richcompare */ 87 | 0, /* tp_weaklistoffset */ 88 | 0, /* tp_iter */ 89 | 0, /* tp_iternext */ 90 | PyCOMPSIDs_methods, /* tp_methods */ 91 | PyCOMPSIDs_members, /* tp_members */ 92 | 0, /* tp_getset */ 93 | &PyCOMPS_SeqType, /* tp_base */ 94 | 0, /* tp_dict */ 95 | 0, /* tp_descr_get */ 96 | 0, /* tp_descr_set */ 97 | 0, /* tp_dictoffset */ 98 | (initproc)PyCOMPSIDs_init, /* tp_init */ 99 | 0, /* tp_alloc */ 100 | PyCOMPSSeq_new, /* tp_new */}; 101 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_ids.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_IDS_H 21 | #define PYCOMPS_IDS_H 22 | 23 | #include 24 | #include "libcomps/comps_doc.h" 25 | //#include "libcomps/comps_list.h" 26 | #include "structmember.h" 27 | #include "pycomps_sequence.h" 28 | #include "pycomps_utils.h" 29 | 30 | int PyCOMPSIDs_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 31 | 32 | //PyObject* ids_getitem(PyObject *self, Py_ssize_t index); 33 | //int ids_setitem(PyObject *self, Py_ssize_t index, PyObject *value); 34 | //int ids_setslice(PyObject *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *value); 35 | //PyObject* ids_getslice(PyObject *self, Py_ssize_t ilow, Py_ssize_t ihigh); 36 | //PyObject* ids_concat(PyObject *self, PyObject *other); 37 | //PyObject* ids_repeat(PyObject *self, Py_ssize_t count); 38 | //PyObject* PyCOMPSIDs_append(PyObject * self, PyObject *item); 39 | 40 | extern PyTypeObject PyCOMPS_IDsType; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_lang._c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "pycomps_lang.h" 21 | 22 | PyObject* pycomps_lang_get_dict(PyCOMPS_CtoPy_CItem *citem, 23 | PyObject **pobj) { 24 | } 25 | int pycomps_lang_set_dict(PyCOMPS_CtoPy_CItem **citem, 26 | PyObject **pobj, 27 | PyObject *value, 28 | void **data) { 29 | } 30 | 31 | PyObject* comps_lang_str(COMPS_Dict * lang) { 32 | } 33 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_lang._h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_LANG_H 21 | #define PYCOMPS_LANG_H 22 | 23 | #include "pycomps_dict.h" 24 | #include "pycomps_ctopy.h" 25 | 26 | PyObject* pycomps_lang_get_dict(PyCOMPS_CtoPy_CItem *citem, 27 | PyObject **pobj); 28 | int pycomps_lang_set_dict(PyCOMPS_CtoPy_CItem **citem, 29 | PyObject **pobj, 30 | PyObject *value, 31 | void **data); 32 | 33 | PyObject* comps_lang_str(COMPS_Dict * lang); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_lbw.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_LBW_H 21 | #define PYCOMPS_LBW_H 22 | 23 | #include "pycomps_mdict.h" 24 | #include "pycomps_utils.h" 25 | 26 | 27 | #include 28 | #include "structmember.h" 29 | 30 | extern PyTypeObject PyCOMPS_LangPacksType; 31 | extern PyTypeObject PyCOMPS_BlacklistType; 32 | extern PyTypeObject PyCOMPS_WhiteoutType; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_macros.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_MACROS_H 21 | #define PYCOMPS_MACROS_H 22 | #include 23 | 24 | #include 25 | #include "structmember.h" 26 | 27 | 28 | #define CMP_OP_EQ_NE_CHECK(OP) \ 29 | if ((OP) != Py_EQ && (OP) != Py_NE) { \ 30 | PyErr_Format(PyExc_NotImplementedError, "Unsuported operator"); \ 31 | return NULL; \ 32 | } 33 | 34 | #define CMP_NONE_CHECK(OP, SELF, OTHER) \ 35 | if ((OTHER) == Py_None && (SELF) == Py_None) \ 36 | return ((OP) == Py_EQ)?(Py_INCREF(Py_True),Py_True): \ 37 | (Py_INCREF(Py_False),Py_False); \ 38 | else if (((OTHER) == Py_None && (SELF) != Py_None) || \ 39 | ((OTHER) != Py_None && (SELF) == Py_None)) \ 40 | return ((OP) == Py_EQ)?(Py_INCREF(Py_False),Py_False): \ 41 | (Py_INCREF(Py_True),Py_True); \ 42 | 43 | #define SET_TO(STRUCT, OFFSET, P) *((size_t*)(((char*)STRUCT)+OFFSET)) = (size_t)P; 44 | #define GET_FROM(STRUCT, OFFSET) *((char**)(((char*)STRUCT)+OFFSET)) 45 | 46 | #endif /*PYCOMPS_MACROS_H*/ 47 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_mdict.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_MDICT_H 21 | #define PYCOMPS_MDICT_H 22 | 23 | #include "libcomps/comps_doc.h" 24 | #include "libcomps/comps_objdict.h" 25 | 26 | #include "pycomps_sequence.h" 27 | #include "pycomps_utils.h" 28 | 29 | #include 30 | #include "structmember.h" 31 | 32 | 33 | void PyCOMPSMDict_dealloc(PyCOMPS_MDict *self); 34 | PyObject* PyCOMPSMDict_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 35 | int PyCOMPSMDict_init(PyCOMPS_MDict *self, PyObject *args, PyObject *kwds); 36 | PyObject* PyCOMPSMDict_str(PyObject *self); 37 | PyObject* PyCOMPSSeq_cmp(PyObject *self, PyObject *other, int op); 38 | PyObject* PyCOMPSMDict_getiteritems(PyObject *self); 39 | 40 | PyObject* PyCOMPSMDictIter_new(PyTypeObject *type, PyObject *args, 41 | PyObject *kwds); 42 | int PyCOMPSMDictIter_init(PyCOMPS_MDictIter *self, PyObject *args, PyObject *kwds); 43 | void PyCOMPSMDictIter_dealloc(PyCOMPS_MDictIter *self); 44 | PyObject* PyCOMPSMDict_iternext(PyObject *iter_o); 45 | 46 | COMPS_Object* __pycomps_unicode_in(PyObject *obj); 47 | COMPS_Object* __pycomps_bytes_in(PyObject *pobj); 48 | PyObject* __pycomps_str_out(COMPS_Object *obj); 49 | 50 | int PyCOMPSStrSeq_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 51 | 52 | extern PyTypeObject PyCOMPS_StrSeqType; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_sequence.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_SEQ_H 21 | #define PYCOMPS_SEQ_H 22 | 23 | #include "pycomps_macros.h" 24 | 25 | #include "pycomps_hash.h" 26 | #include "pycomps_types.h" 27 | 28 | #include "libcomps/comps_objlist.h" 29 | #include "libcomps/comps_utils.h" 30 | 31 | 32 | Py_ssize_t list_len(PyObject *self); 33 | PyObject *list_getitem(PyObject *self, Py_ssize_t index); 34 | PyObject* list_getitem_byid(PyObject *self, PyObject *id); 35 | PyObject* list_get_slice(PyObject *self, PyObject *key); 36 | 37 | int list_setitem_id_unique(PyObject *self, Py_ssize_t index, PyObject *item); 38 | int list_setitem(PyObject *self, Py_ssize_t index, PyObject *value); 39 | int PyCOMPSSeq_set_unique(PyObject *self, PyObject *key, PyObject *val); 40 | PyObject* list_concat(PyObject *self, PyObject *other); 41 | PyObject *PyCOMPSSeq_get(PyObject *self, PyObject *key); 42 | PyObject* PyCOMPSSeq_id_get(PyObject *self, PyObject *key); 43 | int PyCOMPSSeq_set(PyObject *self, PyObject *key, PyObject *val); 44 | 45 | PyObject* list_repeat(PyObject *self, Py_ssize_t count); 46 | PyObject* PyCOMPSSeq_clear(PyObject *self); 47 | 48 | void PyCOMPSSeq_dealloc(PyCOMPS_Sequence *self); 49 | PyObject* PyCOMPSSeq_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 50 | int PyCOMPSSeq_init(PyCOMPS_Sequence *self, PyObject *args, PyObject *kwds); 51 | PyObject* PyCOMPSSeq_append(PyObject * self, PyObject *item); 52 | PyObject* PyCOMPSSeq_append_unique(PyObject * self, PyObject *item); 53 | PyObject* PyCOMPSSeq_str(PyObject *self); 54 | PyObject* PyCOMPSSeq_cmp(PyObject *self, PyObject *other, int op); 55 | 56 | void py_xdecref(void* obj); 57 | 58 | PyObject *list_getitem_X(PyObject *self, PyObject *key); 59 | 60 | PyObject* PyCOMPSSeqIter_new(PyTypeObject *type, PyObject *args, PyObject *kwds); 61 | int PyCOMPSSeqIter_init(PyCOMPS_SeqIter *self, PyObject *args, PyObject *kwds); 62 | 63 | extern PyMappingMethods PyCOMPSSeq_mapping_extra; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_types.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_TYPES_H 21 | #define PYCOMPS_TYPES_H 22 | 23 | #include "libcomps/comps_objlist.h" 24 | #include "libcomps/comps_objdict.h" 25 | 26 | typedef COMPS_Object* (*PyCOMPS_in_itemconvert)(PyObject*); 27 | typedef PyObject* (*PyCOMPS_out_itemconvert)(COMPS_Object*); 28 | 29 | typedef struct PyCOMPS_ItemInfo { 30 | PyTypeObject ** itemtypes; 31 | PyCOMPS_in_itemconvert *in_convert_funcs; 32 | PyCOMPS_out_itemconvert out_convert_func; 33 | int (*pre_checker)(COMPS_Object*); 34 | unsigned item_types_len; 35 | size_t props_offset; 36 | } PyCOMPS_ItemInfo; 37 | 38 | typedef struct PyCOMPS_Sequence { 39 | PyObject_HEAD 40 | COMPS_ObjList *list; 41 | PyCOMPS_ItemInfo *it_info; 42 | } PyCOMPS_Sequence; 43 | 44 | typedef struct PyCOMPS_SeqIter{ 45 | PyObject_HEAD 46 | COMPS_ObjListIt *it; 47 | PyCOMPS_Sequence *seq; 48 | } PyCOMPS_SeqIter; 49 | 50 | typedef struct PyCOMPS_Dict { 51 | PyObject_HEAD 52 | COMPS_ObjDict *dict; 53 | PyCOMPS_ItemInfo *it_info; 54 | } PyCOMPS_Dict; 55 | 56 | typedef struct PyCOMPS_MDict { 57 | PyObject_HEAD 58 | COMPS_ObjMDict *dict; 59 | PyCOMPS_ItemInfo *it_info; 60 | } PyCOMPS_MDict; 61 | 62 | typedef struct PyCOMPS_DictIter{ 63 | PyObject_HEAD 64 | COMPS_ObjListIt *it; 65 | COMPS_HSListItem *hsit; 66 | COMPS_ObjList *objlist; 67 | COMPS_HSList *hslist; 68 | PyObject* (*out_func)(COMPS_HSListItem *hsit); 69 | } PyCOMPS_DictIter; 70 | 71 | typedef struct PyCOMPS_MDictIter{ 72 | PyObject_HEAD 73 | COMPS_ObjListIt *it; 74 | COMPS_HSListItem *hsit; 75 | COMPS_ObjList *objlist; 76 | COMPS_HSList *hslist; 77 | PyObject* (*out_func)(COMPS_HSListItem *hsit); 78 | } PyCOMPS_MDictIter; 79 | 80 | extern PyTypeObject PyCOMPS_GIDsType; 81 | extern PyTypeObject PyCOMPS_GIDType; 82 | 83 | extern PyTypeObject PyCOMPS_SeqType; 84 | extern PyTypeObject PyCOMPS_SeqIterType; 85 | 86 | extern PyTypeObject PyCOMPS_DictType; 87 | extern PyTypeObject PyCOMPS_DictIterType; 88 | 89 | extern PyTypeObject PyCOMPS_MDictType; 90 | extern PyTypeObject PyCOMPS_MDictIterType; 91 | #endif 92 | -------------------------------------------------------------------------------- /libcomps/src/python/src/pycomps_utils.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef PYCOMPS_UTILS_H 21 | #define PYCOMPS_UTILS_H 22 | 23 | #include 24 | #include "structmember.h" 25 | 26 | #include "pycomps_types.h" 27 | #include "pycomps_macros.h" 28 | #include "pycomps_dict.h" 29 | 30 | #include "libcomps/comps_objdict.h" 31 | #include "libcomps/comps_objlist.h" 32 | #include "libcomps/comps_utils.h" 33 | 34 | typedef struct PyCompsObject { 35 | PyObject_HEAD 36 | COMPS_Object *c_obj; 37 | } PyCompsObject; 38 | 39 | typedef struct { 40 | COMPS_Object* (*get_f)(COMPS_Object*); 41 | void (*set_f)(COMPS_Object*, int, bool); 42 | char deleteable; 43 | } __PyCOMPS_NumPropGetSetClosure; 44 | 45 | typedef struct { 46 | COMPS_Object* (*get_f)(COMPS_Object*); 47 | void (*set_f)(COMPS_Object*, char*, char); 48 | char deleteable; 49 | } __PyCOMPS_StrPropGetSetClosure; 50 | 51 | typedef struct { 52 | COMPS_ObjList* (*get_f)(COMPS_Object*); 53 | PyTypeObject *type; 54 | void (*set_f)(COMPS_Object*, COMPS_ObjList*); 55 | size_t p_offset; 56 | } __PyCOMPS_ListGetSetClosure; 57 | 58 | typedef struct { 59 | size_t p_offset; 60 | size_t dict_offset; 61 | PyCOMPS_ItemInfo *dict_info; 62 | PyTypeObject *dict_type; 63 | } __PyCOMPS_DictGetSetClosure; 64 | 65 | #define __H_COMPS_NUMPROP_GETSET_CLOSURE(C_TYPE)\ 66 | typedef struct {\ 67 | COMPS_Object* (*get_f)(C_TYPE*);\ 68 | void (*set_f)(C_TYPE*, int, bool);\ 69 | char deleteable;\ 70 | } CONCAT(CONCAT(PyCOMPS_, C_TYPE), _NumPropGetSetClosure); 71 | 72 | #define __COMPS_NUMPROP_GETSET_CLOSURE(C_TYPE)\ 73 | CONCAT(CONCAT(PyCOMPS_, C_TYPE), _NumPropGetSetClosure) 74 | 75 | #define __H_COMPS_STRPROP_GETSET_CLOSURE(C_TYPE)\ 76 | typedef struct {\ 77 | COMPS_Object* (*get_f)(C_TYPE*);\ 78 | void (*set_f)(C_TYPE*, char*, char);\ 79 | char deleteable;\ 80 | } CONCAT(CONCAT(PyCOMPS_, C_TYPE), _StrPropGetSetClosure); 81 | 82 | #define __COMPS_STRPROP_GETSET_CLOSURE(C_TYPE)\ 83 | CONCAT(CONCAT(PyCOMPS_, C_TYPE), _StrPropGetSetClosure) 84 | 85 | #define __H_COMPS_LIST_GETSET_CLOSURE(C_TYPE)\ 86 | typedef struct {\ 87 | COMPS_ObjList *(*get_f)(C_TYPE*);\ 88 | PyTypeObject *type;\ 89 | void (*set_f)(C_TYPE*, COMPS_ObjList*);\ 90 | size_t p_offset;\ 91 | } CONCAT(CONCAT(PyCOMPS_, C_TYPE), _ListGetSetClosure); 92 | 93 | #define __COMPS_LIST_GETSET_CLOSURE(C_TYPE)\ 94 | CONCAT(CONCAT(PyCOMPS_, C_TYPE), _ListGetSetClosure) 95 | 96 | #define __H_COMPS_DICT_GETSET_CLOSURE(C_TYPE)\ 97 | typedef struct {\ 98 | size_t p_offset;\ 99 | size_t dict_offset;\ 100 | PyCOMPS_ItemInfo *dict_info;\ 101 | PyTypeObject *dict_type;\ 102 | } CONCAT(CONCAT(PyCOMPS_, C_TYPE), _DictGetSetClosure); 103 | 104 | #define __COMPS_DICT_GETSET_CLOSURE(C_TYPE)\ 105 | CONCAT(CONCAT(PyCOMPS_, C_TYPE), _DictGetSetClosure) 106 | 107 | 108 | PyObject* __PyCOMPS_get_ids(PyObject *self, void *closure); 109 | int __PyCOMPS_set_ids(PyObject *self, PyObject *value, void *closure); 110 | 111 | PyObject* __PyCOMPS_get_dict(PyObject *self, void *closure); 112 | int __PyCOMPS_set_dict(PyObject *self, PyObject *value, void *closure); 113 | 114 | PyObject* __PyCOMPS_get_strattr(PyObject *self, void *closure); 115 | int __PyCOMPS_set_strattr(PyObject *self, PyObject *val, void *closure); 116 | PyObject* __PyCOMPS_get_numattr(PyObject *self, void *closure); 117 | int __PyCOMPS_set_numattr(PyObject *self, PyObject *val, void *closure); 118 | PyObject* __PyCOMPS_get_boolattr(PyObject *self, void *closure); 119 | int __PyCOMPS_set_boolattr(PyObject *self, PyObject *val, void *closure); 120 | 121 | int __pycomps_validate_process(COMPS_ValGenResult *result); 122 | 123 | PyObject* __pycomps_str_getter(char * prop); 124 | char __pycomps_strcmp(const char *s1, const char *s2); 125 | char __pycomps_strcmp_v(void *c1, void *c2); 126 | char __pycomps_set_nodel_check(PyObject * value); 127 | PyObject* __pycomps_arg_to_unicode(PyObject *o); 128 | PyObject* __pycomps_arg_to_unicode2(PyObject *o); 129 | signed char __pycomps_arg_to_char(PyObject *value, char ** ret); 130 | signed char __pycomps_stringable_to_char(PyObject *value, char ** ret); 131 | signed char __pycomps_PyUnicode_AsString(PyObject *val, char **ret); 132 | void* __pycomps_strcloner(void *str); 133 | PyObject* __pycomps_lang_decode(char * lang); 134 | PyObject* __pycomps_dict_key_out(COMPS_HSListItem *hsit); 135 | COMPS_Object* __pycomps_unicode_in(PyObject *obj); 136 | COMPS_Object* __pycomps_bytes_in(PyObject *pobj); 137 | PyObject* __pycomps_str_out(COMPS_Object *obj); 138 | PyObject *str_to_unicode(void* str); 139 | 140 | Py_hash_t PyCOMPS_hash(PyObject *self); 141 | 142 | PyObject* PyCOMPSSeq_extra_get(PyObject *self, PyObject *key); 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/biarchonly.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ISO8859-2-support 6 | ISO8859-2 Support 7 | false 8 | false 9 | false 10 | 11 | fonts-ISO8859-2 12 | fonts-ISO8859-2-100dpi 13 | fonts-ISO8859-2-75dpi 14 | 15 | 16 | 17 | ISO8859-9-support 18 | ISO8859-9 Support 19 | false 20 | false 21 | true 22 | 23 | fonts-ISO8859-2-75dpi 24 | fonts-xorg-ISO8859-9-100dpi 25 | fonts-xorg-ISO8859-9-75dpi 26 | 27 | 28 | 29 | ISO8859-15-support 30 | ISO8859-15 Support 31 | false 32 | false 33 | 34 | fonts-ISO8859-15-75dpi 35 | fonts-xorg-ISO8859-15-100dpi 36 | fonts-xorg-ISO8859-15-75dpi 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/comps_empty_by_lang_tags.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | birds 6 | 7 | 8 | 9 | all 10 | all 11 | 12 | 13 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/comps_part1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | core 9 | Core 10 | Smallest possible installation 11 | true 12 | false 13 | 14 | bash 15 | 16 | 17 | 18 | 19 | base-x 20 | base-x 21 | base-x 22 | base-x 23 | Local X.org display server 24 | Lokaler X.org-Displayserver 25 | Místní X.org displej server 26 | false 27 | false 28 | 29 | xorg-x11-server-Xorg 30 | mesa-dri-drivers 31 | 32 | 33 | 34 | 35 | 36 | 37 | minimal-environment 38 | Minimal install 39 | Basic functionality. 40 | 99 41 | 42 | core 43 | 44 | 45 | standard 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/comps_part2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | standard 9 | Standard 10 | Common set of utilities that extend the minimal installation. 11 | false 12 | true 13 | 14 | acl 15 | 16 | 17 | 18 | 19 | base-x 20 | base-x 21 | base-x (2) 22 | base-x 23 | Local X.org display server 24 | Místní X.org displej server (2) 25 | Servidor X.org local 26 | false 27 | false 28 | 29 | xorg-x11-server-Xorg 30 | mesa-dri-drivers 31 | 32 | 33 | 34 | 35 | 36 | 37 | minimal-environment 38 | Minimal install (2) 39 | Basic functionality. (2) 40 | 10 41 | 42 | standard 43 | 44 | 45 | core 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/main_arches.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | group1 6 | group1 7 | 8 | pkg1 9 | pkg2 10 | pkg3 11 | pkg4 12 | pkg5 13 | pkg6 14 | pkg7 15 | 16 | 17 | 18 | group2 19 | group2 20 | 21 | pkg7 22 | 23 | 24 | 25 | group3 26 | group3 27 | 28 | pkg7 29 | 30 | 31 | 32 | group4 33 | group4 34 | 35 | pkg1 36 | 37 | 38 | 39 | cat1 40 | cat1 41 | 42 | g1 43 | g2 44 | g3 45 | g4 46 | g5 47 | g6 48 | g7 49 | 50 | 51 | 52 | cat2 53 | cat2 54 | 55 | g1 56 | 57 | 58 | 59 | cat3 60 | cat3 61 | 62 | g1 63 | 64 | 65 | 66 | cat4 67 | cat4 68 | 69 | g1 70 | 71 | 72 | 73 | env1 74 | env1 75 | 76 | g1 77 | g2 78 | g3 79 | g4 80 | g5 81 | g6 82 | 83 | 84 | o1 85 | o2 86 | o3 87 | o4 88 | o5 89 | o6 90 | 91 | 92 | 93 | env2 94 | env2 95 | 96 | g1 97 | 98 | 99 | o5 100 | 101 | 102 | 103 | env3 104 | env3 105 | 106 | g1 107 | 108 | 109 | o5 110 | 111 | 112 | 113 | env4 114 | env4 115 | 116 | g1 117 | 118 | 119 | o5 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/main_comps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | base 6 | true 7 | true 8 | 1024 9 | Base 10 | This group includes a minimal set of packages. Useful for creating small router/firewall boxes, for example. 11 | Tato skupina zahrnuje nejmenší možnou množinu balíčků. Je vhodná například na instalace malých routerů nebo firewallů. 12 | Diese Gruppe enthält eine minimale Paketauswahl. Dies ist zum Beispiel nützlich zum Aufbau kleiner Router-/Firewall-Rechner. 13 | 14 | pepper 15 | tour 16 | 17 | 18 | 19 | somerset 20 | true 21 | true 22 | 1024 23 | Solid Ground 24 | -- 25 | 26 | pepper 27 | trampoline 28 | 29 | 30 | 31 | base-system 32 | 99 33 | Base System 34 | Základ systému 35 | Basissystem 36 | Various core pieces of the system. 37 | Různé základní části systému. 38 | Verschiedene Kernstücke des Systems. 39 | 40 | base 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/main_comps2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | base 6 | true 7 | true 8 | 1024 9 | Base 10 | This group includes a minimal set of packages. Useful for creating small router/firewall boxes, for example. 11 | Tato skupina zahrnuje nejmenší možnou množinu balíčků. Je vhodná například na instalace malých routerů nebo firewallů. 12 | Diese Gruppe enthält eine minimale Paketauswahl. Dies ist zum Beispiel nützlich zum Aufbau kleiner Router-/Firewall-Rechner. 13 | 14 | pepper 15 | 16 | 17 | 18 | 19 | omerset 20 | 21 | true 22 | 1024 23 | Solid Ground 24 | -- 25 | 26 | pepper 27 | trampoline 28 | 29 | 30 | 31 | base-system 32 | 99 33 | Base System 34 | Základ systému 35 | Basissystem 36 | Various core pieces of the system. 37 | Různé základní části systému. 38 | Verschiedene Kernstücke des Systems. 39 | 40 | base 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/main_def.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | base 6 | 1024 7 | Base 8 | This group includes a minimal set of packages. Useful for creating small router/firewall boxes, for example. 9 | Tato skupina zahrnuje nejmenší možnou množinu balíčků. Je vhodná například na instalace malých routerů nebo firewallů. 10 | Diese Gruppe enthält eine minimale Paketauswahl. Dies ist zum Beispiel nützlich zum Aufbau kleiner Router-/Firewall-Rechner. 11 | 12 | pepper 13 | tour 14 | 15 | 16 | 17 | somerset 18 | 1024 19 | Solid Ground 20 | -- 21 | 22 | pepper 23 | trampoline 24 | 25 | 26 | 27 | base-system 28 | 99 29 | Base System 30 | Základ systému 31 | Basissystem 32 | Various core pieces of the system. 33 | Různé základní části systému. 34 | Verschiedene Kernstücke des Systems. 35 | 36 | base 37 | X11 38 | KDE 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/merged_comps_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | core 6 | Core 7 | Smallest possible installation 8 | true 9 | false 10 | 11 | bash 12 | 13 | 14 | 15 | standard 16 | Standard 17 | Common set of utilities that extend the minimal installation. 18 | false 19 | true 20 | 21 | acl 22 | 23 | 24 | 25 | base-x 26 | base-x 27 | base-x (2) 28 | base-x 29 | base-x 30 | Local X.org display server 31 | Místní X.org displej server (2) 32 | Lokaler X.org-Displayserver 33 | Servidor X.org local 34 | false 35 | false 36 | 37 | xorg-x11-server-Xorg 38 | mesa-dri-drivers 39 | 40 | 41 | 42 | minimal-environment 43 | Minimal install (2) 44 | Basic functionality. (2) 45 | 10 46 | 47 | core 48 | standard 49 | 50 | 51 | standard 52 | core 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/merged_comps_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | standard 6 | Standard 7 | Common set of utilities that extend the minimal installation. 8 | false 9 | true 10 | 11 | acl 12 | 13 | 14 | 15 | core 16 | Core 17 | Smallest possible installation 18 | true 19 | false 20 | 21 | bash 22 | 23 | 24 | 25 | base-x 26 | base-x 27 | base-x 28 | base-x 29 | base-x 30 | Local X.org display server 31 | Místní X.org displej server 32 | Lokaler X.org-Displayserver 33 | Servidor X.org local 34 | false 35 | false 36 | 37 | xorg-x11-server-Xorg 38 | mesa-dri-drivers 39 | 40 | 41 | 42 | minimal-environment 43 | Minimal install 44 | Basic functionality. 45 | 99 46 | 47 | standard 48 | core 49 | 50 | 51 | core 52 | standard 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/comps/sample_comps2.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpm-software-management/libcomps/c37f570dc25704525f0ca85e9b7edd681464888a/libcomps/src/python/tests/comps/sample_comps2.xml.gz -------------------------------------------------------------------------------- /libcomps/src/python/tests/run_tests.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export LD_LIBRARY_PATH="@LIBCOMPS_OUT@/:$LD_LIBRARY_PATH" 3 | @PYTHON_EXECUTABLE@ __test.py 4 | @PYTHON_EXECUTABLE@ test_libcomps.py 5 | @PYTHON_EXECUTABLE@ test_merge_comps.py 6 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/test_merge_comps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | import unittest 6 | import utest 7 | 8 | try: 9 | import _libpycomps as libcomps 10 | print("local tests") 11 | except ImportError: 12 | import libcomps 13 | print("global tests") 14 | 15 | 16 | class TestMergeComps(unittest.TestCase): 17 | 18 | def setUp(self): 19 | self.maxDiff = None 20 | self.comps = libcomps.Comps() 21 | 22 | def test_merge_1_1(self): 23 | # first identity test 24 | c1 = libcomps.Comps() 25 | c1.fromxml_f("comps/comps_part1.xml") 26 | 27 | self.comps += c1 28 | self.comps += c1 29 | 30 | self.assertEqual(self.comps, c1) 31 | self.assertEqual(self.comps.xml_str(), c1.xml_str()) 32 | 33 | def test_merge_2_2(self): 34 | # second identity test 35 | c2 = libcomps.Comps() 36 | c2.fromxml_f("comps/comps_part2.xml") 37 | 38 | self.comps += c2 39 | self.comps += c2 40 | 41 | self.assertEqual(self.comps, c2) 42 | self.assertEqual(self.comps.xml_str(), c2.xml_str()) 43 | 44 | def test_merge_1_2(self): 45 | # c2 overrides c1 46 | c1 = libcomps.Comps() 47 | c1.fromxml_f("comps/comps_part1.xml") 48 | 49 | c2 = libcomps.Comps() 50 | c2.fromxml_f("comps/comps_part2.xml") 51 | 52 | self.comps += c1 53 | self.comps += c2 54 | 55 | merged_comps = libcomps.Comps() 56 | merged_comps.fromxml_f("comps/merged_comps_1_2.xml") 57 | self.assertEqual(self.comps.xml_str(), merged_comps.xml_str()) 58 | self.assertTrue(self.comps == merged_comps) 59 | 60 | def test_merge_2_1(self): 61 | # c1 overrides c2 62 | c1 = libcomps.Comps() 63 | c1.fromxml_f("comps/comps_part1.xml") 64 | 65 | c2 = libcomps.Comps() 66 | c2.fromxml_f("comps/comps_part2.xml") 67 | 68 | self.comps += c2 69 | self.comps += c1 70 | 71 | merged_comps = libcomps.Comps() 72 | merged_comps.fromxml_f("comps/merged_comps_2_1.xml") 73 | self.assertEqual(self.comps.xml_str(), merged_comps.xml_str()) 74 | self.assertTrue(self.comps == merged_comps) 75 | 76 | 77 | if __name__ == "__main__": 78 | unittest.main(testRunner = utest.MyRunner) 79 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/tests.cmake: -------------------------------------------------------------------------------- 1 | 2 | message (${CMAKE_CURRENT_SOURCE_DIR}) 3 | #FILE(GLOB TESTS_FILES "*.py") 4 | set(TESTS_DIR "${PROJECT_SOURCE_DIR}/src/python/tests/") 5 | FILE(GLOB TESTS_FILES RELATIVE "${TESTS_DIR}" "${TESTS_DIR}*.py") 6 | FILE(GLOB COMPS_FILES RELATIVE "${TESTS_DIR}comps/" 7 | "${TESTS_DIR}/comps/*.xml*") 8 | 9 | list(LENGTH COMPS_FILES len) 10 | math (EXPR len "${len} - 1") 11 | 12 | foreach(x RANGE 0 ${len}) 13 | list(GET COMPS_FILES ${x} val) 14 | endforeach() 15 | 16 | #foreach(x ${TEST_FILES}) 17 | # message("tests:" ${x}) 18 | #endforeach() 19 | -------------------------------------------------------------------------------- /libcomps/src/python/tests/utest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | 3 | # libcomps - C alternative to yum.comps library 4 | # Copyright (C) 2013 Jindrich Luza 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, but 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19 | # USA 20 | 21 | import unittest 22 | import traceback 23 | def assertSequenceEqual(seq1, seq2): 24 | if len(seq1) != len(seq2): 25 | raise (AssertionError, "%s != %s" % (seq1, seq2)) 26 | for x,y in zip(seq1,seq2): 27 | if x != y: 28 | raise (AssertionError, "%s != %s" % (seq1, seq2)) 29 | 30 | 31 | class MyResult(unittest.TestResult): 32 | WHITEBOLD = {"1":(1,), "2":(0,)} 33 | WHITE = {"1": (38, 5, 15), "2": (38, 5, 7)} 34 | DRKRED = {"1": (48, 5, 9), "2": (48, 5, 0)} 35 | RED = {"1": (38, 5, 1), "2":(38, 5, 7)} 36 | GREEN = {"1": (38, 5, 10), "2":(38, 5, 7)} 37 | YELLOW = {"1": (38, 5, 11), "2":(38, 5, 7)} 38 | separator1 = "-" * 70 39 | separator2 = "-" * 70 40 | 41 | def colored(self, color, string): 42 | return '\x1b[%sm%s\x1b[m' % (";".join(map(str, color["1"])), string) 43 | 44 | def __init__(self, stream, descriptions, verbosity): 45 | self.stream = stream 46 | try: 47 | super(MyResult, self).__init__(stream, descriptions, verbosity) 48 | except TypeError: 49 | super(MyResult, self).__init__() 50 | self.last_cls = None 51 | self.fail = False 52 | 53 | def startTest(self, test): 54 | if self.last_cls != test.__class__: 55 | self.stream.write( 56 | self.colored(self.WHITEBOLD, 57 | "[ Starting %s ]\n"%str(test.__class__.__name__))) 58 | self.last_cls = test.__class__ 59 | 60 | self.stream.write(str(test)) 61 | self.stream.write(" ... ") 62 | 63 | def startTestRun(self): 64 | pass 65 | 66 | def stopTest(self, test): 67 | #print "done test:", test 68 | pass 69 | 70 | def addSuccess(self, test): 71 | self.stream.write(self.colored(self.GREEN,"[OK]\n")) 72 | self.testsRun += 1 73 | 74 | def addFailure(self, test, error): 75 | self.stream.write(self.colored(self.RED,"[FAIL]\n")) 76 | (_type, value, _traceback) = error 77 | tb = traceback.format_list([traceback.extract_tb(_traceback, 78 | limit=2)[-1]]) 79 | excp = traceback.format_exception_only(_type, value) 80 | self.stream.write("-"*79) 81 | self.stream.write("\n") 82 | self.stream.write("%s"%tb[0]) 83 | self.stream.write("%s\n"%excp[0]) 84 | self.stream.write("."*79) 85 | self.stream.write("\n") 86 | #traceback.print_exception(_type, value, tb, limit=2, file=self.stream) 87 | #self.stream.write(str(error)) 88 | self.testsRun += 1 89 | self.failures += [(test, "".join([tb[0], excp[0]]))] 90 | self.fail = True 91 | 92 | def addError(self, test, error): 93 | self.stream.write(self.colored(self.DRKRED,"[ERROR]\n")) 94 | (_type, value, _traceback) = error 95 | tb = traceback.format_list([traceback.extract_tb(_traceback, 96 | limit=2)[-1]]) 97 | excp = traceback.format_exception_only(_type, value) 98 | self.stream.write("-"*79) 99 | self.stream.write("\n") 100 | self.stream.write("%s"%tb[0]) 101 | self.stream.write("%s\n"%excp[0]) 102 | self.stream.write("."*79) 103 | self.stream.write("\n") 104 | #traceback.print_exception(_type, value, tb, limit=2, file=self.stream) 105 | #self.stream.write(str(error)) 106 | self.testsRun += 1 107 | self.errors += [(test, "".join([tb[0], excp[0]]))] 108 | self.fail = True 109 | 110 | def addSkip(self, test, reason): 111 | self.stream.write(self.colored(self.YELLOW,"[SKIPED]\n")) 112 | self.stream.write(self.colored(self.YELLOW,"reason: %s\n"%reason)) 113 | self.errors += [(test, reason)] 114 | 115 | def wasSuccessful(self): 116 | return not self.fail 117 | def printErrors(self): 118 | pass 119 | 120 | class MyRunner(unittest.TextTestRunner): 121 | def _makeResult(self): 122 | return MyResult(self.stream, self.descriptions, self.verbosity) 123 | -------------------------------------------------------------------------------- /libcomps/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #set (testlist_SOURCE check_list.c check_utils.c) 2 | #set (testlist_HEADERS check_list.h check_utils.h) 3 | add_custom_target(test-copy) 4 | 5 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 6 | 7 | set (testobjrtree_SOURCE check_objrtree.c check_utils.c) 8 | set (testobjrtree_HEADERS check_objrtree.h check_utils.h) 9 | 10 | set (testrtree_SOURCE check_rtree.c check_utils.c) 11 | set (testrtree_HEADERS check_rtree.h check_utils.h) 12 | 13 | set (testbrtree_SOURCE check_brtree.c check_utils.c) 14 | set (testbrtree_HEADERS check_brtree.h check_utils.h) 15 | 16 | set (testparse_SOURCE check_parse.c check_utils.c) 17 | set (testparse_HEADERS check_utils.h) 18 | 19 | set (testcomps_SOURCE check_comps.c) 20 | 21 | set (testvalidate_SOURCE check_validate.c) 22 | 23 | #add_executable(test_list ${testlist_SOURCE}) 24 | add_executable(test_rtree ${testrtree_SOURCE}) 25 | add_executable(test_objrtree ${testobjrtree_SOURCE}) 26 | add_executable(test_brtree ${testbrtree_SOURCE}) 27 | #add_executable(test_mrtree ${testmrtree_SOURCE}) 28 | add_executable(test_parse ${testparse_SOURCE}) 29 | add_executable(test_comps ${testcomps_SOURCE}) 30 | add_executable(test_validate ${testvalidate_SOURCE}) 31 | 32 | #target_link_libraries(test_list libcomps) 33 | #target_link_libraries(test_list ${CHECK_LIBRARY}) 34 | 35 | target_link_libraries(test_brtree libcomps) 36 | target_link_libraries(test_brtree ${CHECK_LIBRARY}) 37 | 38 | target_link_libraries(test_rtree libcomps) 39 | target_link_libraries(test_rtree ${CHECK_LIBRARY}) 40 | 41 | target_link_libraries(test_objrtree libcomps) 42 | target_link_libraries(test_objrtree ${CHECK_LIBRARY}) 43 | 44 | target_link_libraries(test_validate libcomps) 45 | target_link_libraries(test_validate ${CHECK_LIBRARY}) 46 | 47 | #target_link_libraries(test_rtree2 libcomps) 48 | #target_link_libraries(test_rtree2 ${CHECK_LIBRARY}) 49 | 50 | #target_link_libraries(test_mrtree libcomps) 51 | #target_link_libraries(test_mrtree ${CHECK_LIBRARY}) 52 | 53 | target_link_libraries(test_parse libcomps) 54 | target_link_libraries(test_parse expat) 55 | target_link_libraries(test_parse ${CHECK_LIBRARY}) 56 | 57 | target_link_libraries(test_comps expat) 58 | target_link_libraries(test_comps ${CHECK_LIBRARY}) 59 | target_link_libraries(test_comps libcomps) 60 | set_target_properties(test_comps PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -g") 61 | 62 | add_dependencies(test_comps test-copy) 63 | add_dependencies(test_parse test-copy) 64 | add_dependencies(test_validate test-copy) 65 | 66 | 67 | set(TEST_FILES fedora_comps.xml sample-comps.xml sample_comps.xml 68 | sample_comps_bad1.xml sample_comps_bad2.xml sample_comps_bad3.xml 69 | sample-bad-elem.xml comps.dtd dict-test.txt main_comps2.xml 70 | main_arches.xml f21-rawhide-comps.xml) 71 | foreach(file ${TEST_FILES}) 72 | add_custom_command(TARGET test-copy PRE_BUILD COMMAND ${CMAKE_COMMAND} -E 73 | copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} ./) 74 | #file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${file} DESTINATION ./) 75 | endforeach() 76 | 77 | add_custom_target(test_comps_run 78 | COMMAND export LD_LIBRARY_PATH="${LIBCOMPS_OUT}/:$LD_LIBRARY_PATH" 79 | && ./test_comps 80 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 81 | DEPENDS test_comps 82 | COMMENT "Running comps test") 83 | 84 | add_custom_target(test_parse_run 85 | COMMAND export LD_LIBRARY_PATH="${LIBCOMPS_OUT}/:$LD_LIBRARY_PATH" 86 | && ./test_parse 87 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 88 | DEPENDS test_parse 89 | COMMENT "Running comps_parse test") 90 | target_link_libraries(test_parse_run libcomps) 91 | target_link_libraries(test_comps_run libcomps) 92 | 93 | add_dependencies(ctest test_comps_run test_parse_run) 94 | -------------------------------------------------------------------------------- /libcomps/tests/check_utils.c: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #include "check_utils.h" 21 | 22 | const char * pkg_type2str(COMPS_PackageType type) { 23 | switch(type) { 24 | case COMPS_PACKAGE_DEFAULT: 25 | return "default"; 26 | case COMPS_PACKAGE_OPTIONAL: 27 | return "optional"; 28 | case COMPS_PACKAGE_MANDATORY: 29 | return "mandatory"; 30 | case COMPS_PACKAGE_CONDITIONAL: 31 | return "conditional"; 32 | case COMPS_PACKAGE_UNKNOWN: 33 | return "unknown"; 34 | break; 35 | } 36 | return NULL; 37 | } 38 | 39 | /*void print_list_item(COMPS_ListItem * it, unsigned int num, void * user_data) 40 | { 41 | (void) user_data; 42 | printf("%d. %d\n", num, *((int*)it->data)); 43 | }*/ 44 | 45 | void print_package(COMPS_Object *obj) { 46 | char *str; 47 | str = comps_object_tostr((COMPS_Object*) 48 | ((COMPS_DocGroupPackage*)obj)->name); 49 | printf("%s type=", str); 50 | free(str); 51 | printf("%s\n", pkg_type2str(((COMPS_DocGroupPackage*)obj)->type)); 52 | } 53 | 54 | void print_gid(COMPS_Object *obj) { 55 | char *str; 56 | str = comps_object_tostr((COMPS_Object*) 57 | ((COMPS_DocGroupId*)obj)->name); 58 | printf("%s default=", str); 59 | free(str); 60 | printf("%s\n",(((COMPS_DocGroupId*)obj)->def)?"true":"false"); 61 | } 62 | 63 | void print_group(COMPS_Object *obj) { 64 | char *id, *name, *desc; 65 | int disp_ord, def, uservis; 66 | COMPS_Object *prop; 67 | 68 | prop = comps_docgroup_get_id((COMPS_DocGroup*)obj); 69 | id = (prop)?comps_object_tostr(prop):"NULL"; 70 | prop = comps_docgroup_get_name((COMPS_DocGroup*)obj); 71 | name = (prop)?comps_object_tostr(prop):"NULL"; 72 | prop = comps_docgroup_get_desc((COMPS_DocGroup*)obj); 73 | desc = (prop)?comps_object_tostr(prop):"NULL"; 74 | prop = comps_docgroup_get_display_order((COMPS_DocGroup*)obj); 75 | disp_ord = (prop)?((COMPS_Num*)prop)->val:0; 76 | prop = comps_docgroup_get_uservisible((COMPS_DocGroup*)obj); 77 | uservis = (prop)?((COMPS_Num*)prop)->val:0; 78 | prop = comps_docgroup_get_def((COMPS_DocGroup*)obj); 79 | def = (prop)?((COMPS_Num*)prop)->val:0; 80 | 81 | printf("id: %s\n", id); 82 | printf("name: %s\n", name); 83 | printf("desc: %s\n", desc); 84 | printf("default: %d\n", def); 85 | printf("uservisible: %d\n", uservis); 86 | printf("display_order: %d\n", disp_ord); 87 | COMPS_ObjListIt *it = ((COMPS_DocGroup*)obj)->packages->first; 88 | while (comps_objlist_walk(&it, &prop)) { 89 | print_package(prop); 90 | } 91 | } 92 | 93 | void print_category(COMPS_Object *obj) { 94 | char *id, *name, *desc; 95 | int disp_ord; 96 | COMPS_Object *prop; 97 | 98 | prop = comps_doccategory_get_id((COMPS_DocCategory*)obj); 99 | id = (prop)?comps_object_tostr(prop):NULL; 100 | COMPS_OBJECT_DESTROY(prop); 101 | prop = comps_doccategory_get_name((COMPS_DocCategory*)obj); 102 | name = (prop)?comps_object_tostr(prop):NULL; 103 | COMPS_OBJECT_DESTROY(prop); 104 | prop = comps_doccategory_get_desc((COMPS_DocCategory*)obj); 105 | desc = (prop)?comps_object_tostr(prop):NULL; 106 | COMPS_OBJECT_DESTROY(prop); 107 | prop = comps_doccategory_get_display_order((COMPS_DocCategory*)obj); 108 | disp_ord = (prop)?((COMPS_Num*)prop)->val:0; 109 | COMPS_OBJECT_DESTROY(prop); 110 | 111 | printf("id: %s\n", id ? id : "(null)"); 112 | printf("name: %s\n", name ? name : "(null)"); 113 | printf("desc: %s\n", desc ? desc : "(null)"); 114 | printf("display_order: %d\n", disp_ord); 115 | free(id); 116 | free(name); 117 | free(desc); 118 | COMPS_ObjListIt * it = ((COMPS_DocCategory*)obj)->group_ids->first; 119 | while (comps_objlist_walk(&it, &prop)) { 120 | print_gid(prop); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /libcomps/tests/check_utils.h: -------------------------------------------------------------------------------- 1 | /* libcomps - C alternative to yum.comps library 2 | * Copyright (C) 2013 Jindrich Luza 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 | * USA 18 | */ 19 | 20 | #ifndef CHECK_UTILS_H 21 | #define CHECK_UTILS_H 22 | 23 | #include 24 | #include "../src/comps_doc.h" 25 | 26 | const char * pkg_type2str(COMPS_PackageType type); 27 | void print_package(COMPS_Object *obj); 28 | void print_gid(COMPS_Object *obj); 29 | void print_group(COMPS_Object *obj); 30 | void print_category(COMPS_Object *obj); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libcomps/tests/comps.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /libcomps/tests/main_arches.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | group1 6 | group1 7 | 8 | pkg1 9 | pkg2 10 | pkg3 11 | pkg4 12 | pkg5 13 | pkg6 14 | pkg7 15 | 16 | 17 | 18 | group2 19 | group2 20 | 21 | pkg7 22 | 23 | 24 | 25 | group3 26 | group3 27 | 28 | pkg7 29 | 30 | 31 | 32 | group4 33 | group4 34 | 35 | pkg1 36 | 37 | 38 | 39 | cat1 40 | cat1 41 | 42 | g1 43 | g2 44 | g3 45 | g4 46 | g5 47 | g6 48 | g7 49 | 50 | 51 | 52 | cat2 53 | cat2 54 | 55 | g1 56 | 57 | 58 | 59 | cat3 60 | cat3 61 | 62 | g1 63 | 64 | 65 | 66 | cat4 67 | cat4 68 | 69 | g1 70 | 71 | 72 | 73 | env1 74 | env1 75 | 76 | g1 77 | g2 78 | g3 79 | g4 80 | g5 81 | g6 82 | 83 | 84 | o1 85 | o2 86 | o3 87 | o4 88 | o5 89 | o6 90 | 91 | 92 | 93 | env2 94 | env2 95 | 96 | g1 97 | 98 | 99 | o5 100 | 101 | 102 | 103 | env3 104 | env3 105 | 106 | g1 107 | 108 | 109 | o5 110 | 111 | 112 | 113 | env4 114 | env4 115 | 116 | g1 117 | 118 | 119 | o5 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /libcomps/tests/main_comps2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | base 6 | true 7 | true 8 | 1024 9 | Base 10 | This group includes a minimal set of packages. Useful for creating small router/firewall boxes, for example. 11 | Tato skupina zahrnuje nejmenší možnou množinu balíčků. Je vhodná například na instalace malých routerů nebo firewallů. 12 | Diese Gruppe enthält eine minimale Paketauswahl. Dies ist zum Beispiel nützlich zum Aufbau kleiner Router-/Firewall-Rechner. 13 | 14 | pepper 15 | 16 | 17 | 18 | 19 | omerset 20 | 21 | true 22 | 1024 23 | Solid Ground 24 | -- 25 | 26 | pepper 27 | trampoline 28 | 29 | 30 | 31 | base-system 32 | 99 33 | Base System 34 | Základ systému 35 | Basissystem 36 | Various core pieces of the system. 37 | Různé základní části systému. 38 | Verschiedene Kernstücke des Systems. 39 | 40 | base 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /libcomps/tests/sample-bad-elem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | additional-devel 6 | Additional Development 7 | Additional development headers and libraries for developing applications 8 | false 9 | false 10 | 11 | alsa-lib-devel 12 | audit-libs-devel 13 | binutils-devel 14 | boost-devel 15 | package FOO 16 | bzip2-devel 17 | cyrus-sasl-devel 18 | xorg-x11-proto-devel 19 | xz-devel 20 | 21 | 22 | 23 | backup-client 24 | Backup Client 25 | Client tools for connecting to a backup server and doing backups. 26 | true 27 | true 28 | 29 | amanda-client 30 | bacula-client 31 | 32 | 33 | 34 | backup-server 35 | Backup Server 36 | Software to centralize your infrastructure's backups. 37 | false 38 | true 39 | 40 | amanda-server 41 | mt-st 42 | mtx 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /libcomps/tests/sample-comps-dtd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | additional-devel 6 | Additional Development 7 | Additional development headers and libraries for developing applications 8 | false 9 | false 10 | 11 | alsa-lib-devel 12 | audit-libs-devel 13 | binutils-devel 14 | boost-devel 15 | bzip2-devel 16 | cyrus-sasl-devel 17 | dbus-glib-devel 18 | unixODBC-devel 19 | xorg-x11-proto-devel 20 | xz-devel 21 | 22 | 23 | 24 | backup-client 25 | Backup Client 26 | Client tools for connecting to a backup server and doing backups. 27 | true 28 | true 29 | 30 | amanda-client 31 | bacula-client 32 | 33 | 34 | 35 | backup-server 36 | Backup Server 37 | Software to centralize your infrastructure's backups. 38 | false 39 | true 40 | 41 | amanda-server 42 | mt-st 43 | mtx 44 | 45 | 46 | 47 | cat 1 48 | category 1 49 | cat 1 description 50 | 51 | 1 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /libcomps/tests/sample-wrong-dtd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Additional Development 6 | additional-devel 7 | Additional development headers and libraries for developing applications 8 | false 9 | false 10 | 11 | alsa-lib-devel 12 | here 13 | 14 | audit-libs-devel 15 | binutils-devel 16 | boost-devel 17 | bzip2-devel 18 | cyrus-sasl-devel 19 | xorg-x11-proto-devel 20 | xz-devel 21 | 22 | 23 | 24 | backup-client 25 | Backup Client 26 | Client tools for connecting to a backup server and doing backups. 27 | true 28 | true 29 | 30 | amanda-client 31 | bacula-client 32 | 33 | 34 | 35 | backup-server 36 | Backup Server 37 | Software to centralize your infrastructure's backups. 38 | false 39 | true 40 | 41 | amanda-server 42 | mt-st 43 | mtx 44 | 45 | 46 | 47 | cat1 48 | category1 49 | This is category 1 description 50 | 51 | 1 52 | 2 53 | 3 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /libcomps/tests/sample-wrong-param.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | additional-devel 6 | Additional Development 7 | Additional development headers and libraries for developing applications 8 | falXse 9 | Xfalse 10 | 11 | alsa-lib-devel 12 | audit-libs-devel 13 | binutils-devel 14 | boost-devel 15 | bzip2-devel 16 | cyrus-sasl-devel 17 | startup-notification-devel 18 | xz-devel 19 | 20 | 21 | 22 | backup-client 23 | Backup Client 24 | Client tools for connecting to a backup server and doing backups. 25 | true 26 | true 27 | 28 | amanda-client 29 | bacula-client 30 | 31 | 32 | 33 | backup-server 34 | Backup Server 35 | Software to centralize your infrastructure's backups. 36 | false 37 | true 38 | 39 | amanda-server 40 | mt-st 41 | mtx 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /libcomps/version.cmake: -------------------------------------------------------------------------------- 1 | set (libcomps_VERSION_MAJOR 0) 2 | set (libcomps_VERSION_MINOR 1) 3 | set (libcomps_VERSION_PATCH 21) 4 | set (libcomps_RELEASE 1) 5 | 6 | -------------------------------------------------------------------------------- /libcomps/version.cmake.in: -------------------------------------------------------------------------------- 1 | set (libcomps_VERSION_MAJOR ${libcomps_VERSION_MAJOR}) 2 | set (libcomps_VERSION_MINOR ${libcomps_VERSION_MINOR}) 3 | set (libcomps_VERSION_PATCH ${libcomps_VERSION_PATCH}) 4 | set (libcomps_RELEASE ${libcomps_RELEASE}) 5 | 6 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel", "scikit-build"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /rel-bump.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | import json 3 | import sys 4 | import string 5 | 6 | if __name__ == "__main__": 7 | f = open("version.json", "r") 8 | version = json.load(f) 9 | f.close() 10 | version["libcomps_RELEASE"] += 1 11 | 12 | f = open("version.json", "w") 13 | json.dump(version, f, indent=4) 14 | f.close() 15 | 16 | f = open("libcomps/version.cmake.in", "r") 17 | version_in = f.read() 18 | f.close() 19 | 20 | version_out = string.Template(version_in).substitute(version) 21 | f = open("libcomps/version.cmake", "w") 22 | f.write(version_out) 23 | f.close() 24 | 25 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from skbuild import setup 4 | 5 | 6 | with open('version.json', 'r+') as version_file: 7 | version_dict = json.loads(version_file.read()) 8 | # build version string 9 | version = '{major}.{minor}.{patch}-{release}'.format( 10 | major=version_dict['libcomps_VERSION_MAJOR'], 11 | minor=version_dict['libcomps_VERSION_MINOR'], 12 | patch=version_dict['libcomps_VERSION_PATCH'], 13 | release=version_dict['libcomps_RELEASE'] 14 | ) 15 | 16 | with open('README.md') as readme: 17 | README = readme.read() 18 | 19 | setup( 20 | name='libcomps', 21 | description='Comps XML file manipulation library', 22 | long_description_content_type='text/markdown', 23 | long_description=README, 24 | version=version, 25 | license='GPLv2+', 26 | author='RPM Software Management', 27 | author_email='rpm-ecosystem@lists.rpm.org', 28 | url='https://github.com/rpm-software-management', 29 | classifiers=[ 30 | 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', 31 | 'Operating System :: POSIX :: Linux', 32 | 'Programming Language :: C', 33 | 'Topic :: System :: Software Distribution', 34 | 'Topic :: System :: Systems Administration', 35 | 'Programming Language :: Python :: 3', 36 | 'Programming Language :: Python :: 3.9', 37 | 'Programming Language :: Python :: 3.10', 38 | 'Programming Language :: Python :: 3.11', 39 | 'Programming Language :: Python :: 3.12', 40 | ], 41 | packages=['libcomps'], 42 | package_dir={ 43 | 'libcomps': 'libcomps/src/python/src/libcomps/' 44 | }, 45 | cmake_args=[ 46 | '-DBIN_INSTALL_DIR:PATH=libcomps/src/python/src/libcomps/data/bin', 47 | '-DBUILD_LIBCOMPS_SHARED:BOOL=OFF', 48 | '-DENABLE_DEVELOPMENT:BOOL=OFF', 49 | '-DENABLE_DOCS:BOOL=OFF', 50 | '-DENABLE_TESTS:BOOL=OFF' 51 | ], 52 | cmake_languages=['C'], 53 | cmake_source_dir="libcomps", 54 | ) 55 | -------------------------------------------------------------------------------- /setup_for_python_metadata.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | import sys 3 | 4 | # This is a simple and fragile way of creating python metadata for non 5 | # setuptools-guided installs (RPM builds). It's duplicate because of the 6 | # scikit-build dependency in normal setup.py. 7 | # 8 | # This script has to have the version always specified as last argument. 9 | version = sys.argv.pop() 10 | 11 | setup( 12 | name='libcomps', 13 | description='Comps XML file manipulation library', 14 | version=version, 15 | license='GPLv2+', 16 | author='RPM Software Management', 17 | author_email='rpm-ecosystem@lists.rpm.org', 18 | url='https://github.com/rpm-software-management', 19 | classifiers=[ 20 | 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', 21 | 'Operating System :: POSIX :: Linux', 22 | 'Programming Language :: C', 23 | 'Topic :: System :: Software Distribution', 24 | 'Topic :: System :: Systems Administration', 25 | 'Programming Language :: Python :: 3', 26 | 'Programming Language :: Python :: 3.9', 27 | 'Programming Language :: Python :: 3.10', 28 | 'Programming Language :: Python :: 3.11', 29 | 'Programming Language :: Python :: 3.12', 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /ver-bump.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python3 2 | import json 3 | import sys 4 | import string 5 | 6 | if __name__ == "__main__": 7 | f = open("version.json", "r") 8 | version = json.load(f) 9 | f.close() 10 | try: 11 | if sys.argv[1] == "major": 12 | version["libcomps_VERSION_MAJOR"] += 1 13 | version["libcomps_VERSION_MINOR"] = 1 14 | version["libcomps_VERSION_PATCH"] = 1 15 | version["libcomps_RELEASE"] = 1 16 | elif sys.argv[1] == "minor": 17 | version["libcomps_VERSION_MINOR"] += 1 18 | version["libcomps_VERSION_PATCH"] = 1 19 | version["libcomps_RELEASE"] = 1 20 | elif sys.argv[1] == "patch": 21 | version["libcomps_VERSION_PATCH"] += 1 22 | version["libcomps_RELEASE"] = 1 23 | except IndexError: 24 | version["libcomps_VERSION_PATCH"] += 1 25 | version["libcomps_RELEASE"] = 1 26 | 27 | f = open("version.json", "w") 28 | json.dump(version, f, indent=4) 29 | f.close() 30 | 31 | f = open("libcomps/version.cmake.in", "r") 32 | version_in = f.read() 33 | f.close() 34 | 35 | version_out = string.Template(version_in).substitute(version) 36 | f = open("libcomps/version.cmake", "w") 37 | f.write(version_out) 38 | f.close() 39 | 40 | -------------------------------------------------------------------------------- /version.cmake: -------------------------------------------------------------------------------- 1 | set (libcomps_VERSION_MAJOR 0) 2 | set (libcomps_VERSION_MINOR 1) 3 | set (libcomps_VERSION_PATCH 21) 4 | set (libcomps_RELEASE 1) 5 | 6 | -------------------------------------------------------------------------------- /version.cmake.in: -------------------------------------------------------------------------------- 1 | set (libcomps_VERSION_MAJOR ${libcomps_VERSION_MAJOR}) 2 | set (libcomps_VERSION_MINOR ${libcomps_VERSION_MINOR}) 3 | set (libcomps_VERSION_PATCH ${libcomps_VERSION_PATCH}) 4 | set (libcomps_RELEASE ${libcomps_RELEASE}) 5 | 6 | -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "libcomps_VERSION_MAJOR": 0, 3 | "libcomps_RELEASE": 1, 4 | "libcomps_VERSION_MINOR": 1, 5 | "libcomps_VERSION_PATCH": 21 6 | } 7 | --------------------------------------------------------------------------------