├── .github └── workflows │ └── winlibs_tools.yml ├── .gitignore ├── Changelog.txt ├── LICENSE ├── Makefile ├── README.md ├── build ├── winlibs.workspace ├── wl-build.cbp ├── wl-build.depend ├── wl-checknewreleases.cbp ├── wl-checknewreleases.depend ├── wl-download.cbp ├── wl-download.depend ├── wl-find.cbp ├── wl-find.depend ├── wl-info.cbp ├── wl-info.depend ├── wl-install.cbp ├── wl-install.cscope_file_list ├── wl-install.depend ├── wl-listall.cbp ├── wl-listall.depend ├── wl-makepackage.cbp ├── wl-makepackage.depend ├── wl-query.cbp ├── wl-query.cfg ├── wl-query.depend ├── wl-showdeps.cbp ├── wl-showdeps.depend ├── wl-showstatus.cbp ├── wl-showstatus.depend ├── wl-uninstall.cbp ├── wl-uninstall.depend ├── wl-wait4deps.cbp └── wl-wait4deps.depend └── src ├── build-order.c ├── build-order.h ├── build-package.c ├── build-package.h ├── common_output.c ├── common_output.h ├── download_cache.c ├── download_cache.h ├── downloader.c ├── downloader.h ├── exclusive_lock_file.c ├── exclusive_lock_file.h ├── filesystem.c ├── filesystem.h ├── fstab.c ├── fstab.h ├── gui-wizard.cpp ├── gui-wizard.h ├── handle_interrupts.h ├── memory_buffer.c ├── memory_buffer.h ├── obsolete ├── install_db.c ├── install_db.h ├── package_info.c └── package_info.h ├── pkg.c ├── pkg.h ├── pkgdb.c ├── pkgdb.h ├── pkgfile.c ├── pkgfile.h ├── sorted_item_queue.c ├── sorted_item_queue.h ├── sorted_unique_list.c ├── sorted_unique_list.h ├── version_check_db.c ├── version_check_db.h ├── winlibs-setup-GUI.cpp ├── winlibs-setup-GUI.h ├── winlibs-setup.c ├── winlibs_common.h ├── wl-build.c ├── wl-checknewreleases.c ├── wl-download.c ├── wl-find.c ├── wl-info.c ├── wl-install.c ├── wl-listall.c ├── wl-makepackage.c ├── wl-query.c ├── wl-showdeps.c ├── wl-showstatus.c ├── wl-uninstall.c └── wl-wait4deps.c /.gitignore: -------------------------------------------------------------------------------- 1 | .svn/ 2 | _deps/ 3 | _research/ 4 | _TEST_/ 5 | tests/ 6 | build/obj/ 7 | build/bin/ 8 | build/inst*/ 9 | build/_inst*/ 10 | build/_packages/ 11 | build/test_build_script/ 12 | build/*.layout 13 | build/logs/ 14 | _.sh 15 | sql.txt 16 | TO_DO.txt 17 | version 18 | *.sq3 19 | *.URL 20 | *.7z 21 | *.zip 22 | *.xz 23 | build/test_fstab.cbp 24 | build/test_install_db.cbp 25 | build/test_package_info.cbp 26 | build/winlibs-setup-GUI.cbp 27 | build/winlibs-setup-GUI.depend 28 | build/winlibs-setup.cbp 29 | build/winlibs-setup.depend 30 | -------------------------------------------------------------------------------- /Changelog.txt: -------------------------------------------------------------------------------- 1 | 1.0.17 2 | 3 | 2025-02-08 Brecht Sanders https://github.com/brechtsanders/ 4 | 5 | * changed wl-checknewreleases to detect recipe line starting with "wl-showstatus --package-version" as position to insert next version 6 | * changed GitHub Actions to use actions/upload-artifact@v4 (instead of actions/upload-artifact@v1) 7 | 8 | 1.0.16 9 | 10 | 2024-02-03 Brecht Sanders https://github.com/brechtsanders/ 11 | 12 | * changes needed for miniargv 1.2.0 13 | 14 | 1.0.15 15 | 16 | 2024-01-17 Brecht Sanders https://github.com/brechtsanders/ 17 | 18 | * add --version command option to display version information 19 | * use scalednum library to represent human readable download sizes in wl-download 20 | 21 | 1.0.14 22 | 23 | 2023-06-23 Brecht Sanders https://github.com/brechtsanders/ 24 | 25 | * define __USE_MINGW_ANSI_STDIO=0 for faster output 26 | 27 | 1.0.13 28 | 29 | 2023-04-02 Brecht Sanders https://github.com/brechtsanders/ 30 | 31 | * changes needed for miniargv 1.0.0 32 | 33 | 1.0.12 34 | 35 | 2022-12-30 Brecht Sanders https://github.com/brechtsanders/ 36 | 37 | * avoid libarchive issue with backslashes in wl-makepackage 38 | 39 | 1.0.11 40 | 41 | 2022-12-28 Brecht Sanders https://github.com/brechtsanders/ 42 | 43 | * added initial support for OPTIONALBUILDDEPENDENCIES 44 | * fixed issue with miniargv 45 | 46 | 1.0.10 47 | 48 | 2022-03-27 Brecht Sanders https://github.com/brechtsanders/ 49 | 50 | * fix issue with cyclic dependency rebuild decision in wl-build 51 | 52 | 1.0.9 53 | 54 | 2022-03-12 Brecht Sanders https://github.com/brechtsanders/ 55 | 56 | * allow multiple paths for -s/--source-path/BUILDSCRIPTS 57 | 58 | 2022-03-05 Brecht Sanders https://github.com/brechtsanders/ 59 | 60 | * separate non-sqlite3 stuff from pkg.h/pkg.c from pkgdb.h/pkgdb.c 61 | * rewrite package_info.h/package_info.c as pkgfile.h/pkgfile.c 62 | 63 | 1.0.8 64 | 65 | 2022-01-13 Brecht Sanders https://github.com/brechtsanders/ 66 | 67 | * added Github Actions 68 | 69 | 2022-01-09 Brecht Sanders https://github.com/brechtsanders/ 70 | 71 | * wl-makepackage: 72 | * use ${pcfiledir} in pkg-config .pc files as relative base 73 | * use ${CMAKE_CURRENT_LIST_DIR} in CMake .cmake files as relative base 74 | 75 | 2021-12-29 Brecht Sanders https://github.com/brechtsanders/ 76 | 77 | * wl-build: use sqlite3 database to check for installed packages 78 | 79 | 2021-12-27 Brecht Sanders https://github.com/brechtsanders/ 80 | 81 | * accept path list via -s / BUILDSCRIPTS (previously only single path) 82 | semicolon-separated on Windows, colon-separated on other platforms 83 | 84 | 2021-12-26 Brecht Sanders https://github.com/brechtsanders/ 85 | 86 | * wl-build: accept comma-separated package lists 87 | 88 | 2021-12-20 Brecht Sanders https://github.com/brechtsanders/ 89 | 90 | * wl-download: flush output after showing progress updates 91 | * wl-checknewreleases: flush log and report output after updating 92 | 93 | 1.0.7 94 | 95 | 2021-12-09 Brecht Sanders https://github.com/brechtsanders/ 96 | 97 | * wl-find: added -l and -d flags and don't highlight in file/folder listing 98 | 99 | 1.0.6 100 | 101 | 2021-12-06 Brecht Sanders https://github.com/brechtsanders/ 102 | 103 | * initial public release under GPL-2.0 license 104 | 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # winlibs build tools 2 | Tools for building [winlibs](https://winlibs.com/) packages from source using the MinGW-w64 GCC compiler for Windows. 3 | 4 | These tools are needed to natively build winlibs packages from source on Windows. 5 | 6 | ## Goal 7 | 8 | In order to build binary packages from source certain build and package management tools are needed. 9 | 10 | The primary goal of [winlibs.com](https://winlibs.com/) is to build C/C++ source code on native Windows 32-bit and 64-bit platforms using [MinGW-w64](https://www.mingw-w64.org/) [GCC](https://gcc.gnu.org/). 11 | 12 | The [MinGW-w64](https://www.mingw-w64.org/) [GCC (GNU Compiler Collection)](https://gcc.gnu.org/) itself and all of its dependencies built with these tools can be downloaded from [winlibs.com](https://winlibs.com/). 13 | 14 | But these tools can be used to build thousands of other software packages for Windows. 15 | 16 | This allows C/C++ developers to use existing software libraries with [MinGW-w64](https://www.mingw-w64.org/) [GCC (GNU Compiler Collection)](https://gcc.gnu.org/), which improves portability to/from other platforms, making it easier to use the same code for multiple platforms (e.g. Windows, Linux, macOS). 17 | 18 | These tools are intended to run on Windows, but the development of these tools was kept as platform independent as possible, in case there is also a future case for using them on other platforms. 19 | 20 | ## Provided Tools 21 | 22 | * `wl-showstatus`: show status (used during build process) 23 | * `wl-download`: download file (used to download source code archives) 24 | * `wl-wait4deps`: wait for package dependencies 25 | * `wl-listall`: list available package recipes 26 | * `wl-info`: display package recipe information 27 | * `wl-showdeps`: display package dependency tree 28 | * `wl-checknewreleases`: check source code website(s) for new versions 29 | * `wl-makepackage`: create package file from isolated package install folder 30 | * `wl-install`: install package file 31 | * `wl-uninstall`: uninstall package(s) 32 | * `wl-build`: build package from source 33 | * `wl-find`: search in installed winlibs packages 34 | 35 | ## Recipe Format 36 | 37 | A `.winlib` build recipe is written as a series of shell commands that can be run manually in the [MSYS2](https://www.msys2.org/) shell. 38 | At the same time they contain fixed commands that allow the build tools to extract information and run them in an automated and unattended way. 39 | 40 | ## Package Format 41 | 42 | Binary packages are compressed into `.7z` archives, so they can also be opened with [7-Zip](https://7-zip.org/). 43 | 44 | A binary package file will have a name that consists of the package name, the version number and the architecture, followed by the `.7z` extension (`--.7z`, e.g.: `libbz2-1.0.8.x86_64.7z`). 45 | 46 | In the archive there will be a `.packageinfo.xml` file containing package metadata and a folder `.license` containing license file(s). 47 | 48 | ## Dependencies 49 | 50 | * [miniargv](https://github.com/brechtsanders/miniargv/) 51 | * [portcolcon](https://github.com/brechtsanders/portcolcon/) 52 | * [versioncmp](https://github.com/brechtsanders/versioncmp/) 53 | * [libdirtrav](https://github.com/brechtsanders/libdirtrav/) 54 | * [crossrun](https://github.com/brechtsanders/crossrun/) 55 | * [pedeps](https://github.com/brechtsanders/pedeps/) 56 | * [pcre2_finder](https://github.com/brechtsanders/pcre2_finder/) 57 | * [avl](https://packages.debian.org/search?keywords=libavl-dev) 58 | * [libcurl](http://curl.haxx.se/libcurl/) 59 | * [gumbo-parser](https://github.com/google/gumbo-parser/) 60 | * [pcre2](http://www.pcre.org/) 61 | * [sqlite3](http://www.sqlite.org/) 62 | * [expat](http://www.libexpat.org/) 63 | * [libarchive](http://www.libarchive.org/) 64 | 65 | ## License 66 | 67 | This software is distributed under the GPL-2.0 license. 68 | -------------------------------------------------------------------------------- /build/winlibs.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /build/wl-build.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 137 | 138 | -------------------------------------------------------------------------------- /build/wl-checknewreleases.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 147 | 148 | -------------------------------------------------------------------------------- /build/wl-download.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 108 | 109 | -------------------------------------------------------------------------------- /build/wl-download.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1636657860 source:z:\winlibs\src\exclusive_lock_file.c 3 | "exclusive_lock_file.h" 4 | "winlibs_common.h" 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 1636657598 z:\winlibs\src\exclusive_lock_file.h 15 | 16 | 1638696901 source:z:\winlibs\src\wl-download.c 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | "exclusive_lock_file.h" 33 | "handle_interrupts.h" 34 | "winlibs_common.h" 35 | 36 | 1638720072 z:\winlibs\src\winlibs_common.h 37 | 38 | 1629915790 z:\winlibs\src\handle_interrupts.h 39 | 40 | 41 | 42 | 1687509705 source:z:\winlibs_tools\src\exclusive_lock_file.c 43 | "winlibs_common.h" 44 | "exclusive_lock_file.h" 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 1636657598 z:\winlibs_tools\src\exclusive_lock_file.h 55 | 56 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 57 | 58 | 1706999439 source:z:\winlibs_tools\src\wl-download.c 59 | "winlibs_common.h" 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | "exclusive_lock_file.h" 76 | "handle_interrupts.h" 77 | 78 | 79 | 1667930335 z:\winlibs_tools\src\handle_interrupts.h 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /build/wl-find.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 122 | 123 | -------------------------------------------------------------------------------- /build/wl-find.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1619372395 source:z:\winlibs\src\filesystem.c 3 | "filesystem.h" 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1619372395 z:\winlibs\src\filesystem.h 14 | 15 | 16 | 1637764573 source:z:\winlibs\src\memory_buffer.c 17 | "memory_buffer.h" 18 | 19 | 20 | 21 | 1637740219 z:\winlibs\src\memory_buffer.h 22 | 23 | 24 | 25 | 1637763547 source:z:\winlibs\src\pkgdb.c 26 | "pkgdb.h" 27 | "filesystem.h" 28 | "memory_buffer.h" 29 | "winlibs_common.h" 30 | 31 | 32 | 33 | 34 | 35 | 36 | 1637763504 z:\winlibs\src\pkgdb.h 37 | "sorted_unique_list.h" 38 | 39 | 40 | 41 | 42 | 1618569018 z:\winlibs\src\sorted_unique_list.h 43 | 44 | 45 | 1638781790 z:\winlibs\src\winlibs_common.h 46 | 47 | 1616684639 source:z:\winlibs\src\sorted_unique_list.c 48 | "sorted_unique_list.h" 49 | 50 | 51 | 52 | 53 | 54 | 1638571434 source:z:\winlibs\src\wl-find.c 55 | 56 | 57 | 58 | 59 | 60 | 61 | "pkgdb.h" 62 | "winlibs_common.h" 63 | "memory_buffer.h" 64 | 65 | 1637570739 source:z:\miniargv\lib\miniargv.c 66 | "miniargv.h" 67 | 68 | 69 | 70 | 71 | 72 | 1650269513 source:z:\winlibs_tools\src\filesystem.c 73 | "filesystem.h" 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 1650269513 z:\winlibs_tools\src\filesystem.h 84 | 85 | 86 | 1637764573 source:z:\winlibs_tools\src\memory_buffer.c 87 | "memory_buffer.h" 88 | 89 | 90 | 91 | 1637740219 z:\winlibs_tools\src\memory_buffer.h 92 | 93 | 94 | 95 | 1687509688 source:z:\winlibs_tools\src\pkgdb.c 96 | "winlibs_common.h" 97 | "pkgdb.h" 98 | "filesystem.h" 99 | "memory_buffer.h" 100 | 101 | 102 | 103 | 104 | 105 | 106 | 1647007962 z:\winlibs_tools\src\pkgdb.h 107 | "pkg.h" 108 | 109 | 110 | 111 | 112 | 1646511479 z:\winlibs_tools\src\sorted_unique_list.h 113 | 114 | 115 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 116 | 117 | 1646511489 source:z:\winlibs_tools\src\sorted_unique_list.c 118 | "sorted_unique_list.h" 119 | 120 | 121 | 122 | 123 | 124 | 1687508846 source:z:\winlibs_tools\src\wl-find.c 125 | "winlibs_common.h" 126 | 127 | 128 | 129 | 130 | 131 | 132 | "pkgdb.h" 133 | "memory_buffer.h" 134 | 135 | 1672234194 source:z:\winlibs_tools\src\pkg.c 136 | "pkg.h" 137 | 138 | 139 | 140 | 1672234197 z:\winlibs_tools\src\pkg.h 141 | "sorted_unique_list.h" 142 | 143 | 144 | 145 | 146 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 147 | "filesystem.h" 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 158 | 159 | 160 | 1637768173 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.c 161 | "memory_buffer.h" 162 | 163 | 164 | 165 | 1637743819 \\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.h 166 | 167 | 168 | 169 | 1646513039 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.c 170 | "pkg.h" 171 | 172 | 173 | 174 | 1646513039 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.h 175 | "sorted_unique_list.h" 176 | 177 | 178 | 179 | 180 | 1646515079 \\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.h 181 | 182 | 183 | 1647011594 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkgdb.c 184 | "pkgdb.h" 185 | "filesystem.h" 186 | "memory_buffer.h" 187 | "winlibs_common.h" 188 | 189 | 190 | 191 | 192 | 193 | 194 | 1647011562 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkgdb.h 195 | "pkg.h" 196 | 197 | 198 | 199 | 200 | 1648382871 \\server\users\brecht\sources\cpp\winlibs_tools\src\winlibs_common.h 201 | 202 | 1646515089 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.c 203 | "sorted_unique_list.h" 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /build/wl-info.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 118 | 119 | -------------------------------------------------------------------------------- /build/wl-info.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1637010986 source:z:\winlibs\src\package_info.c 3 | "package_info.h" 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1620240584 z:\winlibs\src\package_info.h 14 | 15 | 16 | 17 | 1616688239 source:z:\winlibs\src\sorted_unique_list.c 18 | "sorted_unique_list.h" 19 | 20 | 21 | 22 | 23 | 24 | 1618569018 z:\winlibs\src\sorted_unique_list.h 25 | 26 | 27 | 1638727135 source:z:\winlibs\src\wl-info.c 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | "winlibs_common.h" 37 | "package_info.h" 38 | "sorted_unique_list.h" 39 | 40 | 1638720072 z:\winlibs\src\winlibs_common.h 41 | 42 | 1637010986 source:\\server\users\brecht\sources\cpp\winlibs\src\package_info.c 43 | "package_info.h" 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 1620240584 \\server\users\brecht\sources\cpp\winlibs\src\package_info.h 54 | 55 | 56 | 57 | 1640808178 source:z:\winlibs_tools\src\package_info.c 58 | "package_info.h" 59 | "filesystem.h" 60 | "winlibs_common.h" 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 1640808178 z:\winlibs_tools\src\package_info.h 71 | 72 | 73 | 74 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 75 | 76 | 1650269513 z:\winlibs_tools\src\filesystem.h 77 | 78 | 79 | 1650269513 source:z:\winlibs_tools\src\filesystem.c 80 | "filesystem.h" 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 1706999504 source:z:\winlibs_tools\src\wl-info.c 91 | "winlibs_common.h" 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | "pkgfile.h" 101 | "sorted_unique_list.h" 102 | "filesystem.h" 103 | 104 | 1646511479 z:\winlibs_tools\src\sorted_unique_list.h 105 | 106 | 107 | 1672234194 source:z:\winlibs_tools\src\pkg.c 108 | "pkg.h" 109 | 110 | 111 | 112 | 1672234197 z:\winlibs_tools\src\pkg.h 113 | "sorted_unique_list.h" 114 | 115 | 116 | 117 | 118 | 1687509694 source:z:\winlibs_tools\src\pkgfile.c 119 | "winlibs_common.h" 120 | "pkgfile.h" 121 | "filesystem.h" 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 1646511489 z:\winlibs_tools\src\pkgfile.h 132 | "pkg.h" 133 | 134 | 135 | 1646511489 source:z:\winlibs_tools\src\sorted_unique_list.c 136 | "sorted_unique_list.h" 137 | 138 | 139 | 140 | 141 | 142 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 143 | "filesystem.h" 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 154 | 155 | 156 | 1646513039 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.c 157 | "pkg.h" 158 | 159 | 160 | 161 | 1646513039 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.h 162 | "sorted_unique_list.h" 163 | 164 | 165 | 166 | 167 | 1646515079 \\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.h 168 | 169 | 170 | 1647011562 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkgfile.c 171 | "pkgfile.h" 172 | "filesystem.h" 173 | "winlibs_common.h" 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 1646515089 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkgfile.h 184 | "pkg.h" 185 | 186 | 187 | 1648382871 \\server\users\brecht\sources\cpp\winlibs_tools\src\winlibs_common.h 188 | 189 | 1646515089 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.c 190 | "sorted_unique_list.h" 191 | 192 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /build/wl-install.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 119 | 120 | -------------------------------------------------------------------------------- /build/wl-install.cscope_file_list: -------------------------------------------------------------------------------- 1 | "Z:\winlibs\src\sorted_unique_list.c" 2 | "Z:\winlibs\src\winlibs_common.h" 3 | "Z:\winlibs\src\db_common.h" 4 | "Z:\winlibs\src\filesystem.c" 5 | "Z:\winlibs\src\memory_buffer.c" 6 | "Z:\winlibs\src\wl-install.c" 7 | "Z:\winlibs\src\db_write.c" 8 | "Z:\winlibs\src\db_common.c" 9 | "Z:\winlibs\src\sorted_unique_list.h" 10 | "Z:\winlibs\src\filesystem.h" 11 | "Z:\winlibs\src\memory_buffer.h" 12 | "Z:\winlibs\src\db_write.h" 13 | -------------------------------------------------------------------------------- /build/wl-install.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1637764573 source:z:\winlibs\src\memory_buffer.c 3 | "memory_buffer.h" 4 | 5 | 6 | 7 | 1637740219 z:\winlibs\src\memory_buffer.h 8 | 9 | 10 | 11 | 1616684639 source:z:\winlibs\src\sorted_unique_list.c 12 | "sorted_unique_list.h" 13 | 14 | 15 | 16 | 17 | 18 | 1618569018 z:\winlibs\src\sorted_unique_list.h 19 | 20 | 21 | 1638651801 source:z:\winlibs\src\wl-install.c 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | "winlibs_common.h" 34 | "filesystem.h" 35 | "memory_buffer.h" 36 | "sorted_unique_list.h" 37 | "pkgdb.h" 38 | 39 | 40 | 1619372395 source:z:\winlibs\src\filesystem.c 41 | "filesystem.h" 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 1619372395 z:\winlibs\src\filesystem.h 52 | 53 | 54 | 1638720072 z:\winlibs\src\winlibs_common.h 55 | 56 | 1637003015 source:z:\winlibs\src\db_write.c 57 | "db_write.h" 58 | "filesystem.h" 59 | "memory_buffer.h" 60 | "winlibs_common.h" 61 | 62 | 63 | 64 | 65 | 66 | 67 | 1636724530 z:\winlibs\src\db_write.h 68 | "db_common.h" 69 | 70 | 71 | 1636725814 source:z:\winlibs\src\db_common.c 72 | "db_common.h" 73 | 74 | 75 | 76 | 1636725809 z:\winlibs\src\db_common.h 77 | "sorted_unique_list.h" 78 | 79 | 80 | 1637763547 source:z:\winlibs\src\pkgdb.c 81 | "pkgdb.h" 82 | "filesystem.h" 83 | "memory_buffer.h" 84 | "winlibs_common.h" 85 | 86 | 87 | 88 | 89 | 90 | 91 | 1637763504 z:\winlibs\src\pkgdb.h 92 | "sorted_unique_list.h" 93 | 94 | 95 | 96 | 97 | 1619372395 source:\\server\users\brecht\sources\cpp\winlibs\src\filesystem.c 98 | "filesystem.h" 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 1619372395 \\server\users\brecht\sources\cpp\winlibs\src\filesystem.h 109 | 110 | 111 | 1634131102 source:\\server\users\brecht\sources\cpp\winlibs\src\memory_buffer.c 112 | "memory_buffer.h" 113 | 114 | 115 | 116 | 1618568947 \\server\users\brecht\sources\cpp\winlibs\src\memory_buffer.h 117 | 118 | 119 | 120 | 1616684639 source:\\server\users\brecht\sources\cpp\winlibs\src\sorted_unique_list.c 121 | "sorted_unique_list.h" 122 | 123 | 124 | 125 | 126 | 127 | 1618569018 \\server\users\brecht\sources\cpp\winlibs\src\sorted_unique_list.h 128 | 129 | 130 | 1650269513 source:z:\winlibs_tools\src\filesystem.c 131 | "filesystem.h" 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 1650269513 z:\winlibs_tools\src\filesystem.h 142 | 143 | 144 | 1637764573 source:z:\winlibs_tools\src\memory_buffer.c 145 | "memory_buffer.h" 146 | 147 | 148 | 149 | 1637740219 z:\winlibs_tools\src\memory_buffer.h 150 | 151 | 152 | 153 | 1646511489 source:z:\winlibs_tools\src\sorted_unique_list.c 154 | "sorted_unique_list.h" 155 | 156 | 157 | 158 | 159 | 160 | 1646511479 z:\winlibs_tools\src\sorted_unique_list.h 161 | 162 | 163 | 1687509688 source:z:\winlibs_tools\src\pkgdb.c 164 | "winlibs_common.h" 165 | "pkgdb.h" 166 | "filesystem.h" 167 | "memory_buffer.h" 168 | 169 | 170 | 171 | 172 | 173 | 174 | 1647007962 z:\winlibs_tools\src\pkgdb.h 175 | "pkg.h" 176 | 177 | 178 | 179 | 180 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 181 | 182 | 1706999547 source:z:\winlibs_tools\src\wl-install.c 183 | "winlibs_common.h" 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | "filesystem.h" 196 | "memory_buffer.h" 197 | "sorted_unique_list.h" 198 | "pkgdb.h" 199 | 200 | 201 | 1672234194 source:z:\winlibs_tools\src\pkg.c 202 | "pkg.h" 203 | 204 | 205 | 206 | 1672234197 z:\winlibs_tools\src\pkg.h 207 | "sorted_unique_list.h" 208 | 209 | 210 | 211 | 212 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 213 | "filesystem.h" 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 224 | 225 | 226 | 1637768173 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.c 227 | "memory_buffer.h" 228 | 229 | 230 | 231 | 1637743819 \\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.h 232 | 233 | 234 | 235 | 1646513039 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.c 236 | "pkg.h" 237 | 238 | 239 | 240 | 1646513039 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.h 241 | "sorted_unique_list.h" 242 | 243 | 244 | 245 | 246 | 1646515079 \\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.h 247 | 248 | 249 | 1646515089 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.c 250 | "sorted_unique_list.h" 251 | 252 | 253 | 254 | 255 | 256 | -------------------------------------------------------------------------------- /build/wl-listall.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 117 | 118 | -------------------------------------------------------------------------------- /build/wl-listall.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1637010986 source:z:\winlibs\src\package_info.c 3 | "package_info.h" 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1620240584 z:\winlibs\src\package_info.h 14 | 15 | 16 | 17 | 1616684639 source:z:\winlibs\src\sorted_unique_list.c 18 | "sorted_unique_list.h" 19 | 20 | 21 | 22 | 23 | 24 | 1618569018 z:\winlibs\src\sorted_unique_list.h 25 | 26 | 27 | 1638702738 source:z:\winlibs\src\wl-listall.c 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | "winlibs_common.h" 36 | "sorted_unique_list.h" 37 | "package_info.h" 38 | 39 | 1638720072 z:\winlibs\src\winlibs_common.h 40 | 41 | 1640808178 source:z:\winlibs_tools\src\package_info.c 42 | "package_info.h" 43 | "filesystem.h" 44 | "winlibs_common.h" 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 1640808178 z:\winlibs_tools\src\package_info.h 55 | 56 | 57 | 58 | 1650273113 z:\winlibs_tools\src\filesystem.h 59 | 60 | 61 | 1707003380 z:\winlibs_tools\src\winlibs_common.h 62 | 63 | 1646515089 source:z:\winlibs_tools\src\sorted_unique_list.c 64 | "sorted_unique_list.h" 65 | 66 | 67 | 68 | 69 | 70 | 1646515079 z:\winlibs_tools\src\sorted_unique_list.h 71 | 72 | 73 | 1705523775 source:z:\winlibs_tools\src\wl-listall.c 74 | "winlibs_common.h" 75 | 76 | 77 | 78 | 79 | 80 | "sorted_unique_list.h" 81 | "filesystem.h" 82 | "pkgfile.h" 83 | 84 | 1672237794 source:z:\winlibs_tools\src\pkg.c 85 | "pkg.h" 86 | 87 | 88 | 89 | 1672237797 z:\winlibs_tools\src\pkg.h 90 | "sorted_unique_list.h" 91 | 92 | 93 | 94 | 95 | 1687513294 source:z:\winlibs_tools\src\pkgfile.c 96 | "winlibs_common.h" 97 | "pkgfile.h" 98 | "filesystem.h" 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 1646515089 z:\winlibs_tools\src\pkgfile.h 109 | "pkg.h" 110 | 111 | 112 | 1650273113 source:z:\winlibs_tools\src\filesystem.c 113 | "filesystem.h" 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 124 | "filesystem.h" 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 135 | 136 | 137 | -------------------------------------------------------------------------------- /build/wl-makepackage.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 122 | 123 | -------------------------------------------------------------------------------- /build/wl-makepackage.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1637764573 source:z:\winlibs\src\memory_buffer.c 3 | "memory_buffer.h" 4 | 5 | 6 | 7 | 1637740219 z:\winlibs\src\memory_buffer.h 8 | 9 | 10 | 11 | 1619252436 source:z:\winlibs\src\fstab.c 12 | "fstab.h" 13 | "filesystem.h" 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 1618568917 z:\winlibs\src\fstab.h 22 | 23 | 24 | 1638652146 source:z:\winlibs\src\wl-makepackage.c 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | "winlibs_common.h" 41 | "fstab.h" 42 | "memory_buffer.h" 43 | "sorted_unique_list.h" 44 | 45 | "text_list.h" 46 | 47 | 1619372395 source:z:\winlibs\src\filesystem.c 48 | "filesystem.h" 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 1619372395 z:\winlibs\src\filesystem.h 59 | 60 | 61 | 1638720072 z:\winlibs\src\winlibs_common.h 62 | 63 | 1616684639 source:z:\winlibs\src\sorted_unique_list.c 64 | "sorted_unique_list.h" 65 | 66 | 67 | 68 | 69 | 70 | 1618569018 z:\winlibs\src\sorted_unique_list.h 71 | 72 | 73 | 1619372395 source:\\server\users\brecht\sources\cpp\winlibs\src\filesystem.c 74 | "filesystem.h" 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 1619372395 \\server\users\brecht\sources\cpp\winlibs\src\filesystem.h 85 | 86 | 87 | 1634131102 source:\\server\users\brecht\sources\cpp\winlibs\src\memory_buffer.c 88 | "memory_buffer.h" 89 | 90 | 91 | 92 | 1618568947 \\server\users\brecht\sources\cpp\winlibs\src\memory_buffer.h 93 | 94 | 95 | 96 | 1616684639 source:\\server\users\brecht\sources\cpp\winlibs\src\sorted_unique_list.c 97 | "sorted_unique_list.h" 98 | 99 | 100 | 101 | 102 | 103 | 1618569018 \\server\users\brecht\sources\cpp\winlibs\src\sorted_unique_list.h 104 | 105 | 106 | 1650269513 source:z:\winlibs_tools\src\filesystem.c 107 | "filesystem.h" 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 1650269513 z:\winlibs_tools\src\filesystem.h 118 | 119 | 120 | 1637764573 source:z:\winlibs_tools\src\memory_buffer.c 121 | "memory_buffer.h" 122 | 123 | 124 | 125 | 1637740219 z:\winlibs_tools\src\memory_buffer.h 126 | 127 | 128 | 129 | 1646511489 source:z:\winlibs_tools\src\sorted_unique_list.c 130 | "sorted_unique_list.h" 131 | 132 | 133 | 134 | 135 | 136 | 1646511479 z:\winlibs_tools\src\sorted_unique_list.h 137 | 138 | 139 | 1650269699 source:z:\winlibs_tools\src\fstab.c 140 | "fstab.h" 141 | "filesystem.h" 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 1618568917 z:\winlibs_tools\src\fstab.h 150 | 151 | 152 | 1705520175 source:z:\winlibs_tools\src\wl-makepackage.c 153 | "winlibs_common.h" 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | "fstab.h" 170 | "memory_buffer.h" 171 | "sorted_unique_list.h" 172 | 173 | "text_list.h" 174 | 175 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 176 | 177 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 178 | "filesystem.h" 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 189 | 190 | 191 | 1637768173 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.c 192 | "memory_buffer.h" 193 | 194 | 195 | 196 | 1637743819 \\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.h 197 | 198 | 199 | 200 | 1646515089 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.c 201 | "sorted_unique_list.h" 202 | 203 | 204 | 205 | 206 | 207 | 1646515079 \\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.h 208 | 209 | 210 | -------------------------------------------------------------------------------- /build/wl-query.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 122 | 123 | -------------------------------------------------------------------------------- /build/wl-query.cfg: -------------------------------------------------------------------------------- 1 | installpath = D:\Prog\winlibs64-13.1.0msvcrt\custombuilt 2 | -------------------------------------------------------------------------------- /build/wl-query.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1619372395 source:z:\winlibs\src\filesystem.c 3 | "filesystem.h" 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1619372395 z:\winlibs\src\filesystem.h 14 | 15 | 16 | 1637764573 source:z:\winlibs\src\memory_buffer.c 17 | "memory_buffer.h" 18 | 19 | 20 | 21 | 1637740219 z:\winlibs\src\memory_buffer.h 22 | 23 | 24 | 25 | 1637763547 source:z:\winlibs\src\pkgdb.c 26 | "pkgdb.h" 27 | "filesystem.h" 28 | "memory_buffer.h" 29 | "winlibs_common.h" 30 | 31 | 32 | 33 | 34 | 35 | 36 | 1637763504 z:\winlibs\src\pkgdb.h 37 | "sorted_unique_list.h" 38 | 39 | 40 | 41 | 42 | 1618569018 z:\winlibs\src\sorted_unique_list.h 43 | 44 | 45 | 1638781790 z:\winlibs\src\winlibs_common.h 46 | 47 | 1616684639 source:z:\winlibs\src\sorted_unique_list.c 48 | "sorted_unique_list.h" 49 | 50 | 51 | 52 | 53 | 54 | 1638571434 source:z:\winlibs\src\wl-find.c 55 | 56 | 57 | 58 | 59 | 60 | 61 | "pkgdb.h" 62 | "winlibs_common.h" 63 | "memory_buffer.h" 64 | 65 | 1637570739 source:z:\miniargv\lib\miniargv.c 66 | "miniargv.h" 67 | 68 | 69 | 70 | 71 | 72 | 1650273113 source:z:\winlibs_tools\src\filesystem.c 73 | "filesystem.h" 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 1650273113 z:\winlibs_tools\src\filesystem.h 84 | 85 | 86 | 1637768173 source:z:\winlibs_tools\src\memory_buffer.c 87 | "memory_buffer.h" 88 | 89 | 90 | 91 | 1637743819 z:\winlibs_tools\src\memory_buffer.h 92 | 93 | 94 | 95 | 1687513288 source:z:\winlibs_tools\src\pkgdb.c 96 | "winlibs_common.h" 97 | "pkgdb.h" 98 | "filesystem.h" 99 | "memory_buffer.h" 100 | 101 | 102 | 103 | 104 | 105 | 106 | 1647011562 z:\winlibs_tools\src\pkgdb.h 107 | "pkg.h" 108 | 109 | 110 | 111 | 112 | 1646515079 z:\winlibs_tools\src\sorted_unique_list.h 113 | 114 | 115 | 1688463735 z:\winlibs_tools\src\winlibs_common.h 116 | 117 | 1646515089 source:z:\winlibs_tools\src\sorted_unique_list.c 118 | "sorted_unique_list.h" 119 | 120 | 121 | 122 | 123 | 124 | 1639082782 source:z:\winlibs_tools\src\wl-find.c 125 | 126 | 127 | 128 | 129 | 130 | 131 | "pkgdb.h" 132 | "winlibs_common.h" 133 | "memory_buffer.h" 134 | 135 | 1672237794 source:z:\winlibs_tools\src\pkg.c 136 | "pkg.h" 137 | 138 | 139 | 140 | 1672237797 z:\winlibs_tools\src\pkg.h 141 | "sorted_unique_list.h" 142 | 143 | 144 | 145 | 146 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 147 | "filesystem.h" 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 158 | 159 | 160 | 1637768173 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.c 161 | "memory_buffer.h" 162 | 163 | 164 | 165 | 1637743819 \\server\users\brecht\sources\cpp\winlibs_tools\src\memory_buffer.h 166 | 167 | 168 | 169 | 1646513039 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.c 170 | "pkg.h" 171 | 172 | 173 | 174 | 1646513039 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.h 175 | "sorted_unique_list.h" 176 | 177 | 178 | 179 | 180 | 1646515079 \\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.h 181 | 182 | 183 | 1647011594 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkgdb.c 184 | "pkgdb.h" 185 | "filesystem.h" 186 | "memory_buffer.h" 187 | "winlibs_common.h" 188 | 189 | 190 | 191 | 192 | 193 | 194 | 1647011562 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkgdb.h 195 | "pkg.h" 196 | 197 | 198 | 199 | 200 | 1648382871 \\server\users\brecht\sources\cpp\winlibs_tools\src\winlibs_common.h 201 | 202 | 1646515089 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.c 203 | "sorted_unique_list.h" 204 | 205 | 206 | 207 | 208 | 209 | 1688470554 source:z:\winlibs_tools\src\wl-query.c 210 | "winlibs_common.h" 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | "pkgdb.h" 220 | "memory_buffer.h" 221 | 222 | 223 | 224 | 1646515089 z:\winlibs_tools\src\pkgfile.h 225 | "pkg.h" 226 | 227 | 228 | -------------------------------------------------------------------------------- /build/wl-showdeps.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 113 | 114 | -------------------------------------------------------------------------------- /build/wl-showdeps.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1637010986 source:z:\winlibs\src\package_info.c 3 | "package_info.h" 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1620240584 z:\winlibs\src\package_info.h 14 | 15 | 16 | 17 | 1638702161 source:z:\winlibs\src\wl-showdeps.c 18 | 19 | 20 | 21 | 22 | 23 | "package_info.h" 24 | "filesystem.h" 25 | "winlibs_common.h" 26 | 27 | 1638720072 z:\winlibs\src\winlibs_common.h 28 | 29 | 1619372395 source:z:\winlibs\src\filesystem.c 30 | "filesystem.h" 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 1619372395 z:\winlibs\src\filesystem.h 41 | 42 | 43 | 1619372395 source:\\server\users\brecht\sources\cpp\winlibs\src\filesystem.c 44 | "filesystem.h" 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 1619372395 \\server\users\brecht\sources\cpp\winlibs\src\filesystem.h 55 | 56 | 57 | 1637010986 source:\\server\users\brecht\sources\cpp\winlibs\src\package_info.c 58 | "package_info.h" 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 1620240584 \\server\users\brecht\sources\cpp\winlibs\src\package_info.h 69 | 70 | 71 | 72 | 1650269513 source:z:\winlibs_tools\src\filesystem.c 73 | "filesystem.h" 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 1650269513 z:\winlibs_tools\src\filesystem.h 84 | 85 | 86 | 1640808178 source:z:\winlibs_tools\src\package_info.c 87 | "package_info.h" 88 | "filesystem.h" 89 | "winlibs_common.h" 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 1640808178 z:\winlibs_tools\src\package_info.h 100 | 101 | 102 | 103 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 104 | 105 | 1706999514 source:z:\winlibs_tools\src\wl-showdeps.c 106 | "winlibs_common.h" 107 | 108 | 109 | 110 | 111 | "pkgfile.h" 112 | "sorted_unique_list.h" 113 | "filesystem.h" 114 | 115 | 1672234194 source:z:\winlibs_tools\src\pkg.c 116 | "pkg.h" 117 | 118 | 119 | 120 | 1672234197 z:\winlibs_tools\src\pkg.h 121 | "sorted_unique_list.h" 122 | 123 | 124 | 125 | 126 | 1646511479 z:\winlibs_tools\src\sorted_unique_list.h 127 | 128 | 129 | 1687509694 source:z:\winlibs_tools\src\pkgfile.c 130 | "winlibs_common.h" 131 | "pkgfile.h" 132 | "filesystem.h" 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 1646511489 z:\winlibs_tools\src\pkgfile.h 143 | "pkg.h" 144 | 145 | 146 | 1646511489 source:z:\winlibs_tools\src\sorted_unique_list.c 147 | "sorted_unique_list.h" 148 | 149 | 150 | 151 | 152 | 153 | 1650273113 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.c 154 | "filesystem.h" 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 1650273113 \\server\users\brecht\sources\cpp\winlibs_tools\src\filesystem.h 165 | 166 | 167 | 1646513039 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.c 168 | "pkg.h" 169 | 170 | 171 | 172 | 1646513039 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkg.h 173 | "sorted_unique_list.h" 174 | 175 | 176 | 177 | 178 | 1646515079 \\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.h 179 | 180 | 181 | 1647011562 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\pkgfile.c 182 | "pkgfile.h" 183 | "filesystem.h" 184 | "winlibs_common.h" 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 1646515089 \\server\users\brecht\sources\cpp\winlibs_tools\src\pkgfile.h 195 | "pkg.h" 196 | 197 | 198 | 1648382871 \\server\users\brecht\sources\cpp\winlibs_tools\src\winlibs_common.h 199 | 200 | 1646515089 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\sorted_unique_list.c 201 | "sorted_unique_list.h" 202 | 203 | 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /build/wl-showstatus.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 97 | 98 | -------------------------------------------------------------------------------- /build/wl-showstatus.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1638529164 source:z:\winlibs\src\wl-showstatus.c 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | "winlibs_common.h" 13 | 14 | 1638720072 z:\winlibs\src\winlibs_common.h 15 | 16 | 1637183767 source:\\server\users\brecht\sources\cpp\winlibs\src\wl-showstatus.c 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | "winlibs_common.h" 27 | 28 | 1636806968 \\server\users\brecht\sources\cpp\winlibs\src\winlibs_common.h 29 | 30 | 1705520175 source:z:\winlibs_tools\src\wl-showstatus.c 31 | "winlibs_common.h" 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 42 | 43 | 1687508802 source:\\server\users\brecht\sources\cpp\winlibs_tools\src\wl-showstatus.c 44 | "winlibs_common.h" 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 1705518485 \\server\users\brecht\sources\cpp\winlibs_tools\src\winlibs_common.h 55 | 56 | -------------------------------------------------------------------------------- /build/wl-uninstall.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 118 | 119 | -------------------------------------------------------------------------------- /build/wl-wait4deps.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 101 | 102 | -------------------------------------------------------------------------------- /build/wl-wait4deps.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1638529742 source:z:\winlibs\src\wl-wait4deps.c 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | "filesystem.h" 14 | "handle_interrupts.h" 15 | "winlibs_common.h" 16 | 17 | 1638720072 z:\winlibs\src\winlibs_common.h 18 | 19 | 1619372395 source:z:\winlibs\src\filesystem.c 20 | "filesystem.h" 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 1619372395 z:\winlibs\src\filesystem.h 31 | 32 | 33 | 1629915790 z:\winlibs\src\handle_interrupts.h 34 | 35 | 36 | 37 | 1650269513 source:z:\winlibs_tools\src\filesystem.c 38 | "filesystem.h" 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 1650269513 z:\winlibs_tools\src\filesystem.h 49 | 50 | 51 | 1705520175 source:z:\winlibs_tools\src\wl-wait4deps.c 52 | "winlibs_common.h" 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | "filesystem.h" 63 | "handle_interrupts.h" 64 | 65 | 1667930335 z:\winlibs_tools\src\handle_interrupts.h 66 | 67 | 68 | 69 | 1705518485 z:\winlibs_tools\src\winlibs_common.h 70 | 71 | -------------------------------------------------------------------------------- /src/build-order.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for package build order functions 3 | */ 4 | 5 | #ifndef INCLUDED_BUILD_ORDER_H 6 | #define INCLUDED_BUILD_ORDER_H 7 | 8 | #include "pkgfile.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | enum package_filter_type_enum { 15 | filter_type_all, 16 | filter_type_changed 17 | }; 18 | 19 | struct add_package_and_dependencies_to_list_struct { 20 | sorted_unique_list* packagenamelist; 21 | const char* packageinfopath; 22 | enum package_filter_type_enum filtertype; 23 | }; 24 | 25 | struct package_info_extradata_struct { 26 | enum package_filter_type_enum filtertype; 27 | unsigned char visited; 28 | unsigned char checkingcyclic; 29 | struct package_metadata_struct* cyclic_start_pkginfo; 30 | struct package_metadata_struct* cyclic_next_pkginfo; 31 | size_t cyclic_size; 32 | }; 33 | 34 | //!macro for accessing extradata member of struct add_package_and_dependencies_to_list_struct 35 | #define PKG_XTRA(pkginfo) ((struct package_info_extradata_struct*)(pkginfo)->extradata) 36 | 37 | //!compare function for package information 38 | /*! 39 | \param data1 first package information to compare 40 | \param data2 second package information to compare 41 | \return zero if the base name of both packages is equal, negative if it's smaller for data1, otherwise positive 42 | */ 43 | int packageinfo_cmp_basename (const char* data1, const char* data2); 44 | 45 | //!add package and its dependencies to list 46 | /*! 47 | \param basename name of package to add to list 48 | \param data list to add package to 49 | \return zero on success 50 | */ 51 | int add_package_and_dependencies_to_list (const char* basename, struct add_package_and_dependencies_to_list_struct* data); 52 | 53 | //!sort list of packages in the right order to build them based on their dependencies 54 | /*! 55 | \param sortedpackagelist list of packages 56 | \return shell exit code (non-zero usually means an error occurred in the last command executed) 57 | */ 58 | struct package_info_list_struct* generate_build_list (sorted_unique_list* sortedpackagelist); 59 | 60 | #if 0 61 | //!get number of dependency packages specified that are currently not installed for a specific package 62 | /*! 63 | \param dstdir installation path 64 | \param pkginfo package information from build recipe 65 | \return number of dependencies specified in build information that are not currently installed 66 | */ 67 | size_t dependencies_listed_but_not_depended_on (const char* dstdir, struct package_metadata_struct* pkginfo); 68 | #else 69 | //!get number of dependency packages specified that are currently not installed for a specific package 70 | /*! 71 | \param pkginfo package information from build recipe 72 | \param dbpkginfo package information from database for same package as pkginfo 73 | \return number of dependencies specified in build information that are not currently installed 74 | */ 75 | size_t dependencies_listed_but_not_depended_on (struct package_metadata_struct* pkginfo, struct package_metadata_struct* dbpkginfo); 76 | #endif 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif //INCLUDED_BUILD_ORDER_H 83 | -------------------------------------------------------------------------------- /src/build-package.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for package build functions 3 | */ 4 | 5 | #ifndef INCLUDED_BUILD_PACKAGE_H 6 | #define INCLUDED_BUILD_PACKAGE_H 7 | 8 | extern unsigned int interrupted; //variable set by signal handler 9 | 10 | //!build package from source 11 | /*! 12 | \param infopath full path(s) of directory containing build information files 13 | \param basename name of package 14 | \param shell full shell script path (and optional arguments) 15 | \param logfile path of log file to write to (NULL for no logging) 16 | \param buildpath path where temporary build folder will be created (NULL build in shell's current path) 17 | \return shell exit code (non-zero usually means an error occurred in the last command executed) 18 | */ 19 | unsigned long build_package (const char* infopath, const char* basename, const char* shell, const char* logfile, const char* buildpath); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif //INCLUDED_BUILD_PACKAGE_H 26 | -------------------------------------------------------------------------------- /src/common_output.c: -------------------------------------------------------------------------------- 1 | #include "common_output.h" 2 | #include 3 | #include 4 | #include 5 | 6 | //#define PTHREAD_USE_MUTEX_AS_LOCK 7 | 8 | struct commonoutput_stuct { 9 | FILE* logfile; 10 | int verbose; 11 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 12 | pthread_rwlock_t lock; 13 | #else 14 | pthread_mutex_t lock; 15 | #endif 16 | }; 17 | 18 | struct commonoutput_stuct* commonoutput_create (const char* filename, int verbose) 19 | { 20 | struct commonoutput_stuct* handle; 21 | FILE* dst; 22 | //try to open output file (or use standard output if NULL or empty) 23 | if (!filename || !*filename) 24 | dst = stdout; 25 | else if ((dst = fopen(filename, "a")) == NULL) 26 | return NULL; 27 | //initialize handle 28 | if ((handle = (struct commonoutput_stuct*)malloc(sizeof(struct commonoutput_stuct))) == NULL) 29 | return NULL; 30 | handle->logfile = dst; 31 | handle->verbose = verbose; 32 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 33 | if (pthread_rwlock_init(&handle->lock, NULL/*PTHREAD_MUTEX_ERRORCHECK*/) != 0) { 34 | #else 35 | if (pthread_mutex_init(&handle->lock, NULL) != 0) { 36 | #endif 37 | fprintf(stderr, "Error initializing mutex\n"); 38 | if (handle->logfile != stdout) 39 | fclose(handle->logfile); 40 | free(handle); 41 | return NULL; 42 | } 43 | return handle; 44 | } 45 | 46 | void commonoutput_free (struct commonoutput_stuct* handle) 47 | { 48 | if (!handle) 49 | return; 50 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 51 | pthread_rwlock_wrlock(&handle->lock); 52 | #else 53 | pthread_mutex_lock(&handle->lock); 54 | #endif 55 | if (handle->logfile != stdout) 56 | fclose(handle->logfile); 57 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 58 | pthread_rwlock_unlock(&handle->lock); 59 | pthread_rwlock_destroy(&handle->lock); 60 | #else 61 | pthread_mutex_unlock(&handle->lock); 62 | pthread_mutex_destroy(&handle->lock); 63 | #endif 64 | free(handle); 65 | } 66 | 67 | void commonoutput_put (struct commonoutput_stuct* handle, int verbose, const char* data) 68 | { 69 | if (!handle || !handle->logfile || verbose > handle->verbose || !data || !*data) 70 | return; 71 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 72 | pthread_rwlock_wrlock(&handle->lock); 73 | #else 74 | pthread_mutex_lock(&handle->lock); 75 | #endif 76 | fputs(data, handle->logfile); 77 | fflush(handle->logfile); 78 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 79 | pthread_rwlock_unlock(&handle->lock); 80 | #else 81 | pthread_mutex_unlock(&handle->lock); 82 | #endif 83 | } 84 | 85 | void commonoutput_putbuf (struct commonoutput_stuct* handle, int verbose, const char* data, size_t datalen) 86 | { 87 | if (!handle || !handle->logfile || verbose > handle->verbose || !data || !*data) 88 | return; 89 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 90 | pthread_rwlock_wrlock(&handle->lock); 91 | #else 92 | pthread_mutex_lock(&handle->lock); 93 | #endif 94 | fwrite(data, 1, datalen, handle->logfile); 95 | fflush(handle->logfile); 96 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 97 | pthread_rwlock_unlock(&handle->lock); 98 | #else 99 | pthread_mutex_unlock(&handle->lock); 100 | #endif 101 | } 102 | 103 | int commonoutput_vprintf (struct commonoutput_stuct* handle, int verbose, const char* format, va_list args) 104 | { 105 | int result; 106 | if (!handle || !handle->logfile) 107 | return -1; 108 | if (verbose > handle->verbose) 109 | return 0; 110 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 111 | pthread_rwlock_wrlock(&handle->lock); 112 | #else 113 | pthread_mutex_lock(&handle->lock); 114 | #endif 115 | result = vfprintf(handle->logfile, format, args); 116 | fflush(handle->logfile); 117 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 118 | pthread_rwlock_unlock(&handle->lock); 119 | #else 120 | pthread_mutex_unlock(&handle->lock); 121 | #endif 122 | return result; 123 | } 124 | 125 | int commonoutput_printf (struct commonoutput_stuct* handle, int verbose, const char* format, ...) 126 | { 127 | int result; 128 | va_list args; 129 | va_start(args, format); 130 | result = commonoutput_vprintf(handle, verbose, format, args); 131 | va_end(args); 132 | return result; 133 | } 134 | 135 | int commonoutput_flush (struct commonoutput_stuct* handle) 136 | { 137 | if (!handle || !handle->logfile) 138 | return -1; 139 | return fflush(handle->logfile); 140 | } 141 | 142 | -------------------------------------------------------------------------------- /src/common_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for common output functions (with locking to avoid simultaneous output) 3 | */ 4 | 5 | #ifndef INCLUDED_COMMON_OUTPUT_H 6 | #define INCLUDED_COMMON_OUTPUT_H 7 | 8 | #include 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | //!data structure for common output 16 | struct commonoutput_stuct; 17 | 18 | //!create common output 19 | /*! 20 | \param filename path of file to append to (standard output if NULL) 21 | \param verbose verbosity level 22 | \return common output handle 23 | */ 24 | struct commonoutput_stuct* commonoutput_create (const char* filename, int verbose); 25 | 26 | //!clean up common output 27 | /*! 28 | \param handle common output handle 29 | */ 30 | void commonoutput_free (struct commonoutput_stuct* handle); 31 | 32 | //!print data to common output 33 | /*! 34 | \param handle common output handle 35 | \param verbose verbosity level 36 | \param data data to print 37 | \return number of characters printed 38 | */ 39 | void commonoutput_put (struct commonoutput_stuct* handle, int verbose, const char* data); 40 | 41 | //!print buffer to common output 42 | /*! 43 | \param handle common output handle 44 | \param verbose verbosity level 45 | \param data data to print 46 | \param datalen length of data to print 47 | \return number of characters printed 48 | */ 49 | void commonoutput_putbuf (struct commonoutput_stuct* handle, int verbose, const char* data, size_t datalen); 50 | 51 | //!print to common output 52 | /*! 53 | \param handle common output handle 54 | \param verbose verbosity level 55 | \param format format as used by printf() 56 | \param args arguments as used by vprintf() 57 | \return number of characters printed 58 | */ 59 | int commonoutput_vprintf (struct commonoutput_stuct* handle, int verbose, const char* format, va_list args); 60 | 61 | //!print to common output 62 | /*! 63 | \param handle common output handle 64 | \param verbose verbosity level 65 | \param format format as used by printf() 66 | \return number of characters printed 67 | */ 68 | int commonoutput_printf (struct commonoutput_stuct* handle, int verbose, const char* format, ...); 69 | 70 | //!flush buffers for common output 71 | /*! 72 | \param handle common output handle 73 | \return zero on success, non-zero on error 74 | */ 75 | int commonoutput_flush (struct commonoutput_stuct* handle); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif //INCLUDED_COMMON_OUTPUT_H 82 | -------------------------------------------------------------------------------- /src/download_cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for download caching functions 3 | */ 4 | 5 | #ifndef INCLUDED_DOWNLOAD_CACHE_H 6 | #define INCLUDED_DOWNLOAD_CACHE_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | //!data structure for receiving download information 13 | struct download_info_struct { 14 | int cached; //!< cached (non-zero if content was cached, otherwise zero) 15 | long responsecode; //!< HTTP response code 16 | char** status; //!< pointer that will (if not NULL) receive status information or error message 17 | char** actualurl; //!< pointer that will (if not NULL) receive the actual URL (can be different, e.g. because of redirections) 18 | char** mimetype; //!< pointer that will (if not NULL) receive the MIME type 19 | }; 20 | 21 | 22 | 23 | //!data structure for download cache database handle 24 | struct downloadcachedb; 25 | 26 | //!create download cache database handle 27 | /*! 28 | \param filename cache database path or set to NULL for temporary database 29 | \param expiration number of seconds after which cache entries expire 30 | \return download cache database handle 31 | */ 32 | struct downloadcachedb* downloadcachedb_create (const char* filename, unsigned long expiration); 33 | 34 | //!clean up download cache database handle 35 | /*! 36 | \param handle download cache handle 37 | */ 38 | void downloadcachedb_free (struct downloadcachedb* handle); 39 | 40 | //!check if cache database was newly created 41 | /*! 42 | \param handle download cache handle 43 | \return non-zero if cache database was newly created, otherwise zero 44 | */ 45 | int downloadcachedb_is_new (struct downloadcachedb* handle); 46 | 47 | //!purge cache (remove all expired entries) 48 | /*! 49 | \param handle download cache handle 50 | \return number of entries deleted or negative on error 51 | */ 52 | int downloadcachedb_purge (struct downloadcachedb* handle); 53 | 54 | 55 | 56 | //!data structure for download cache handle 57 | struct downloadcache; 58 | 59 | //!create download cache handle 60 | /*! 61 | \param filename cache database path or set to NULL for temporary database 62 | \param expiration number of seconds after which cache entries expire 63 | \return download cache handle 64 | */ 65 | struct downloadcache* downloadcache_create (struct downloadcachedb* masterdb); 66 | 67 | //!clean up download cache handle 68 | /*! 69 | \param handle download cache handle 70 | */ 71 | void downloadcache_free (struct downloadcache* handle); 72 | 73 | //!create cache entry 74 | /*! 75 | \param handle download cache handle 76 | \param url URL used to fetch the data 77 | \param data web page data 78 | \param info structure with status information about the downloaded file 79 | \param responsecode HTTP responce code 80 | \param status status information or error message 81 | \param actualurl actual URL reported by page (can be different, e.g. because of redirections) 82 | \param mimetype MIME type 83 | \return zero on success or non-zero on error 84 | */ 85 | int downloadcache_add (struct downloadcache* handle, const char* url, const char* data, struct download_info_struct* info); 86 | 87 | //!get cache entry 88 | /*! 89 | \param handle download cache handle 90 | \param url URL 91 | \param info structure that will receive status information about the downloaded file 92 | \return web page data or NULL if unable to get page 93 | */ 94 | char* downloadcache_get (struct downloadcache* handle, const char* url, struct download_info_struct* info); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif //INCLUDED_DOWNLOAD_CACHE_H 101 | -------------------------------------------------------------------------------- /src/downloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for download functions 3 | */ 4 | 5 | #ifndef INCLUDED_DOWNLOADER_H 6 | #define INCLUDED_DOWNLOADER_H 7 | 8 | #include "download_cache.h" 9 | #include "common_output.h" 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | //!data structure for downloader handle 17 | struct downloader; 18 | 19 | //!global initialization, call once in the application before using any other downloader functions 20 | void downloader_global_init (); 21 | 22 | //!global cleanup, call once in the application, don't use any other downloader functions after this 23 | void downloader_global_cleanup (); 24 | 25 | //!create downloader handle 26 | /*! 27 | \param useragent user agent for web client (or NULL to set to default) 28 | \param cachedb cache database (or NULL to not use caching) 29 | \param output output to send status information to 30 | \return downloader handle 31 | */ 32 | struct downloader* downloader_create (const char* useragent, struct downloadcachedb* cachedb, struct commonoutput_stuct* output); 33 | 34 | //!clean up downloader handle 35 | /*! 36 | \param handle downloader handle 37 | */ 38 | void downloader_free (struct downloader* handle); 39 | 40 | //!custom MIME type used for FTP listings 41 | extern const char* custom_mimetype_ftp_listing; 42 | 43 | //!download file contents to memory 44 | /*! 45 | \param handle downloader handle 46 | \param url URL 47 | \param info structure that will receive status information about the downloaded file 48 | \return contents of HTML page or NULL on error 49 | */ 50 | char* downloader_get_file (struct downloader* handle, const char* url, struct download_info_struct* info); 51 | 52 | //!download file 53 | /*! 54 | \param handle downloader handle 55 | \param url URL 56 | \param outputfile file where to save the downloaded data 57 | \return HTTP status code 58 | */ 59 | long downloader_save_file (struct downloader* handle, const char* url, const char* outputfile); 60 | 61 | 62 | 63 | //!decode URL encoded string 64 | /*! 65 | \param data data to URL decode 66 | \param datalen length data to URL decode 67 | \return newly allocated string with URL decoded data (caller must call free() on the result) or NULL on error 68 | */ 69 | char* url_decode (const char* data, size_t datalen); 70 | 71 | //!return a pointer to the character right after "://" or NULL if not found 72 | /*! 73 | \param url URL 74 | \return pointer after "://" in the URL or NULL on error 75 | */ 76 | const char* url_skip_scheme (const char* url); 77 | 78 | //!resolve URL (absolute URLs are returned without change, relative URLs will be resolved) 79 | /*! 80 | \param base_url base URL 81 | \param url URL to resolve 82 | \return newly allocated string with resolved URL (caller must call free() on the result) or NULL on error 83 | */ 84 | char* resolve_url (const char* base_url, const char* url); 85 | 86 | //!returns filename part of a URL, or name of deepest folder if URL ends with a slash 87 | /*! 88 | \param url URL to get filename part from 89 | \param filelen pointer to variable that will receive length of filename (may be NULL) 90 | \return pointer to filename part of URL or NULL on error 91 | */ 92 | const char* get_url_file_part (const char* url, size_t* filelen); 93 | 94 | //!returns download filename part of a URL 95 | /*! 96 | \param url URL to get download filename part from 97 | \param filelen pointer to variable that will receive length of download filename (may be NULL) 98 | \return pointer to download filename part of URL or NULL on error 99 | */ 100 | const char* get_url_download_file_part (const char* url, size_t* filelen); 101 | 102 | 103 | 104 | //!compare full mime type string with base mime type 105 | /*! 106 | \param fullmimetype full mime type to check 107 | \param basemimetype base mime type to compare with 108 | \return zero on match, otherwise non-zero 109 | */ 110 | int mimetype_cmp (const char* fullmimetype, const char* basemimetype); 111 | 112 | //!check if mime type specifies HTML 113 | /*! 114 | \param fullmimetype full mime type to check 115 | \return zero if HTML, otherwise non-zero 116 | */ 117 | int mimetype_is_html (const char* fullmimetype); 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif //INCLUDED_DOWNLOADER_H 124 | -------------------------------------------------------------------------------- /src/exclusive_lock_file.c: -------------------------------------------------------------------------------- 1 | #include "winlibs_common.h" 2 | #include "exclusive_lock_file.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #ifdef _WIN32 10 | #include 11 | #else 12 | #include 13 | #endif 14 | 15 | #define LOCK_EXTENSION ".lock" 16 | #define LOCK_RETRIES 59 //number if retries (not including first attempt) 17 | #define LOCK_RETRYWAIT 1 //time between retries (in seconds) 18 | 19 | struct exclusive_lock_file_struct { 20 | char* path; 21 | int filehandle; 22 | }; 23 | 24 | static int is_directory (const char* path) 25 | { 26 | struct stat statbuf; 27 | if (stat(path, &statbuf) < 0) 28 | return 0; 29 | return S_ISDIR(statbuf.st_mode); 30 | } 31 | 32 | exclusive_lock_file exclusive_lock_file_create (const char* directory, const char* basename, const char** errmsg, exclusive_lock_file_create_progress_callback_fn callback, void* callbackdata) 33 | { 34 | struct exclusive_lock_file_struct* handle; 35 | size_t directorylen; 36 | size_t basenamelen; 37 | int retriesleft = LOCK_RETRIES; 38 | if (errmsg) 39 | *errmsg = NULL; 40 | if (!basename || !*basename) { 41 | if (errmsg) 42 | *errmsg = "Lock file base name missing"; 43 | return NULL; 44 | } 45 | if (!directory || !*directory) { 46 | directory = "."; 47 | } else if (!is_directory(directory)) { 48 | if (errmsg) 49 | *errmsg = "Lock file destination is not a directory"; 50 | return NULL; 51 | } 52 | //allocate structure 53 | if ((handle = (struct exclusive_lock_file_struct*)malloc(sizeof(struct exclusive_lock_file_struct))) == NULL) { 54 | if (errmsg) 55 | *errmsg = "Memory allocation error"; 56 | return NULL; 57 | } 58 | //determine lock file name 59 | directorylen = strlen(directory); 60 | basenamelen = strlen(basename); 61 | if ((handle->path = (char*)malloc(directorylen + basenamelen + strlen(LOCK_EXTENSION) + 2)) == NULL) { 62 | if (errmsg) 63 | *errmsg = "Memory allocation error"; 64 | free(handle); 65 | return NULL; 66 | } 67 | memcpy(handle->path, directory, directorylen); 68 | handle->path[directorylen] = PATH_SEPARATOR; 69 | memcpy(handle->path + directorylen + 1, basename, basenamelen); 70 | strcpy(handle->path + directorylen + 1 + basenamelen, LOCK_EXTENSION); 71 | //create lock file (retry multiple times if needed) 72 | do { 73 | if ((handle->filehandle = open(handle->path, O_WRONLY | O_CREAT | O_EXCL, S_IWUSR | S_IWGRP | S_IWOTH)) < 0) { 74 | if (errno != EEXIST) { 75 | if (errmsg) 76 | *errmsg = "Unable to create lock file"; 77 | } else { 78 | /////TO DO: check if process that created lock file still exists 79 | if (errmsg) 80 | *errmsg = "Lock file already exists"; 81 | } 82 | if (callback) { 83 | if ((*callback)(handle, callbackdata) != 0) { 84 | if (errmsg) 85 | *errmsg = "Unable to get lock and retry aborted"; 86 | break; 87 | } 88 | } 89 | #ifdef _WIN32 90 | Sleep(LOCK_RETRYWAIT * 1000); 91 | #else 92 | sleep(LOCK_RETRYWAIT); 93 | #endif 94 | } else { 95 | if (errmsg) 96 | *errmsg = NULL; 97 | } 98 | } while (handle->filehandle < 0 && retriesleft-- > 0); 99 | if (handle->filehandle < 0) { 100 | free(handle->path); 101 | free(handle); 102 | return NULL; 103 | } 104 | 105 | //write hostname to lock file 106 | #ifdef _WIN32 107 | char hostname[MAX_COMPUTERNAME_LENGTH + 1]; 108 | DWORD hostnamelen = sizeof(hostname); 109 | if (!GetComputerNameA(hostname, &hostnamelen)) 110 | hostname[0] = 0; 111 | #else 112 | #ifndef HOST_NAME_MAX 113 | #define HOST_NAME_MAX 255 114 | #endif 115 | char hostname[HOST_NAME_MAX + 1]; 116 | hostname[0] = 0; 117 | gethostname(hostname, sizeof(hostname)); 118 | #endif 119 | write(handle->filehandle, hostname, strlen(hostname)); 120 | write(handle->filehandle, "\n", 1); 121 | 122 | //write process id to lock file 123 | char buf[32]; 124 | #ifdef _WIN32 125 | DWORD pid = GetCurrentProcessId(); 126 | lltoa((long long)pid, buf, 10); 127 | #else 128 | pid_t pid = getpid(); 129 | snprintf(buf, sizeof(buf), "%lli", (long long)pid); 130 | #endif 131 | write(handle->filehandle, buf, strlen(buf)); 132 | write(handle->filehandle, "\n", 1); 133 | 134 | return handle; 135 | } 136 | 137 | void exclusive_lock_file_destroy (exclusive_lock_file handle) 138 | { 139 | if (handle) { 140 | close(handle->filehandle); 141 | if (unlink(handle->path) != 0) { 142 | //fprintf(stderr, "Error %i deleting lock file: %s\n", errno, handle->path); 143 | } 144 | free(handle->path); 145 | free(handle); 146 | } 147 | } 148 | 149 | const char* exclusive_lock_file_get_path (exclusive_lock_file handle) 150 | { 151 | if (!handle) 152 | return NULL; 153 | return handle->path; 154 | } 155 | -------------------------------------------------------------------------------- /src/exclusive_lock_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for exclusive lock file functions 3 | */ 4 | 5 | #ifndef INCLUDED_EXCLUSIVELOCKFILE_H 6 | #define INCLUDED_EXCLUSIVELOCKFILE_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | //!data structure for exclusive lock file 13 | typedef struct exclusive_lock_file_struct* exclusive_lock_file; 14 | 15 | //!callback function used while waiting for another process to release the lock on the lock file 16 | /*! 17 | \param handle database handle 18 | \param callbackdata user data 19 | \return zero to continue or non-zero to abort 20 | */ 21 | typedef int (*exclusive_lock_file_create_progress_callback_fn)(exclusive_lock_file handle, void* callbackdata); 22 | 23 | //!create exclusive lock file handle 24 | /*! 25 | \param directory path to directory where exclusive lock file will be created 26 | \param basename base name to use for lock file (an extension will be added) 27 | \param errmsg pointer to where error message will be stored (or NULL if not needed) 28 | \param callback user function to call while trying to get the lock (not called if lock succeeds right away, called multiple times if multiple attempts are made) 29 | \param callbackdata user data to pass to user function 30 | \return exclusive lock file handle or NULL on error 31 | */ 32 | exclusive_lock_file exclusive_lock_file_create (const char* directory, const char* basename, const char** errmsg, exclusive_lock_file_create_progress_callback_fn callback, void* callbackdata); 33 | 34 | //!clean up file handle 35 | /*! 36 | \param handle exclusive lock file handle 37 | */ 38 | void exclusive_lock_file_destroy (exclusive_lock_file handle); 39 | 40 | //!get full path of lock file 41 | /*! 42 | \param handle exclusive lock file handle 43 | \return full path to lock file or NULL on error (if handle is NULL) 44 | */ 45 | const char* exclusive_lock_file_get_path (exclusive_lock_file handle); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif //INCLUDED_EXCLUSIVELOCKFILE_H 52 | -------------------------------------------------------------------------------- /src/filesystem.c: -------------------------------------------------------------------------------- 1 | #include "filesystem.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #ifdef _WIN32 8 | #include 9 | #define OS_MKDIR(path) _mkdir(path) 10 | #else 11 | #include 12 | #define OS_MKDIR(path) mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) 13 | #endif 14 | #include 15 | 16 | int file_exists (const char* path) 17 | { 18 | struct stat statbuf; 19 | if (stat(path, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) 20 | return 1; 21 | return 0; 22 | } 23 | 24 | int folder_exists (const char* path) 25 | { 26 | struct stat statbuf; 27 | if (stat(path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)) 28 | return 1; 29 | return 0; 30 | } 31 | 32 | //returns 0 on success, 1 if the directory already exists or -1 on error 33 | int recursive_mkdir (const char* path) 34 | { 35 | char* p; 36 | char* q; 37 | //try to create deepest level directory 38 | if (OS_MKDIR(path) == 0) 39 | return 0; 40 | if (errno == EEXIST) 41 | return 1; 42 | //find last separator 43 | p = strrchr(path, '/'); 44 | #ifdef _WIN32 45 | q = strrchr(path, '\\'); 46 | if (q && (!p || q > p)) 47 | p = q; 48 | #endif 49 | //skip additional separators (if any) 50 | while (p && *p && p > path && (*(p - 1) == '/' 51 | #ifdef _WIN32 52 | || *(p - 1) == '\\' 53 | #endif 54 | )) 55 | p--; 56 | //recurse to create missing upper level(s) 57 | if (p && *p) { 58 | int result; 59 | size_t len = p - path; 60 | if ((q = (char*)malloc(len + 1)) == NULL) 61 | return -1; 62 | memcpy(q, path, len); 63 | q[len] = 0; 64 | result = recursive_mkdir(q); 65 | free(q); 66 | if (result >= 0) { 67 | if (OS_MKDIR(path) != 0) { 68 | if (errno == EEXIST) 69 | return 1; 70 | return -1; 71 | } 72 | return 0; 73 | } 74 | } 75 | return -1; 76 | } 77 | 78 | int delete_file (const char* path) 79 | { 80 | if (!file_exists(path)) 81 | return 1; 82 | if (unlink(path) != 0) 83 | return -1; 84 | return 0; 85 | } 86 | 87 | char* readline_from_file (FILE* f) 88 | { 89 | int datalen; 90 | char data[128]; 91 | int resultlen = 0; 92 | char* result = NULL; 93 | while (fgets(data, sizeof(data), f)) { 94 | datalen = strlen(data); 95 | result = (char*)realloc(result, resultlen + datalen + 1); 96 | memcpy(result + resultlen, data, datalen + 1); 97 | resultlen += datalen; 98 | if (resultlen > 0 && result[resultlen - 1] == '\n') { 99 | result[--resultlen] = 0; 100 | if (resultlen > 0 && result[resultlen - 1] == '\r') 101 | result[--resultlen] = 0; 102 | break; 103 | } 104 | } 105 | return result; 106 | } 107 | 108 | int write_to_file (const char* path, const char* data) 109 | { 110 | FILE* dst; 111 | if (!path || !*path) 112 | return 1; 113 | if ((dst = fopen(path, "wb")) == NULL) 114 | return -1; 115 | if (data) 116 | fprintf(dst, "%s\n", data); 117 | fclose(dst); 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /src/filesystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for package information functions 3 | */ 4 | 5 | #ifndef INCLUDED_FILESYSTEM_H 6 | #define INCLUDED_FILESYSTEM_H 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | //!check if a file exists 15 | /*! 16 | \param path path of file to check 17 | \return 1 if path exists and is a regular file, otherwise 0 18 | */ 19 | int file_exists (const char* path); 20 | 21 | //!check if a folder exists 22 | /*! 23 | \param path path of folder to check 24 | \return 1 if path exists and is a folder, otherwise 0 25 | */ 26 | int folder_exists (const char* path); 27 | 28 | //!create directory and if needed also create missing parent directories 29 | /*! 30 | \param path path of directory to create 31 | \return 0 on success, 1 if the directory already exists or -1 on error 32 | */ 33 | int recursive_mkdir (const char* path); 34 | 35 | //!delete file 36 | /*! 37 | \param path path of file to delete 38 | \return 0 on success, 1 if file didn't exist or -1 on error 39 | */ 40 | int delete_file (const char* path); 41 | 42 | //!read line from file 43 | /*! 44 | \param f open file handle to read line from 45 | \return line read from file or NULL on end of file or error, caller must free() the result 46 | */ 47 | char* readline_from_file (FILE* f); 48 | 49 | //!write data to file 50 | /*! 51 | \param path path of file to write to 52 | \param data data to write to file 53 | \return 0 on success 54 | */ 55 | int write_to_file (const char* path, const char* data); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif //INCLUDED_FILESYSTEM_H 62 | -------------------------------------------------------------------------------- /src/fstab.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for functions related to fstab mount points (implemented by MSYS on Windows) 3 | */ 4 | 5 | #ifndef INCLUDED_FSTAB_H 6 | #define INCLUDED_FSTAB_H 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | //!get path of fstab file, caller must free() the result, NULL on error 15 | /*! 16 | on non-Windows this will be "/etc/fstab" 17 | on windows detection is done by looking for looking for ../etc/fstab or ../../etc/fstab relative to each entry in the PATH environment variable 18 | \return path to fstab file (or NULL on error), result must be cleaned up with free() 19 | */ 20 | char* get_fstab_path (); 21 | 22 | //!data structure used to store fstab data, see also: read_fstab_data() 23 | struct fstab_data_struct { 24 | char* fullpath; 25 | size_t fullpathlen; 26 | char* mountpath; 27 | size_t mountpathlen; 28 | struct fstab_data_struct* next; 29 | }; 30 | 31 | //!clean up data structure 32 | /*! 33 | \param fstabdata pointer to data structure 34 | */ 35 | void cleanup_fstab_data (struct fstab_data_struct* fstabdata); 36 | 37 | //!populate data structure by reading the fstab file 38 | /*! 39 | \param fstabpath location of ftsab file 40 | \return pointer to data structure (or NULL on error), result must be cleaned up with cleanup_fstab_data() 41 | */ 42 | struct fstab_data_struct* read_fstab_data (const char* fstabpath); 43 | 44 | //!convert a full path to a mounted path, caller must free() the result, NULL on error or when not a mounted path 45 | /*! 46 | \param fstabdata pointer to data structure 47 | \param fullpath full path 48 | \return mounted path (or NULL on error), result must be cleaned up with free() 49 | */ 50 | char* fstabpath_from_fullpath (const struct fstab_data_struct* fstabdata, const char* fullpath); 51 | 52 | //!convert a mounted path to a full path, caller must free() the result, NULL on error or when not a mounted path 53 | /*! 54 | \param fstabdata pointer to data structure 55 | \param mountpath mounted path 56 | \return full path (or NULL on error), result must be cleaned up with free() 57 | */ 58 | char* fstabpath_to_fullpath (const struct fstab_data_struct* fstabdata, const char* mountpath); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif //INCLUDED_FSTAB_H 65 | -------------------------------------------------------------------------------- /src/gui-wizard.h: -------------------------------------------------------------------------------- 1 | #ifndef __INCLUDED_SIGNATURE2TEMPLATEGUI_H 2 | #define __INCLUDED_SIGNATURE2TEMPLATEGUI_H 3 | 4 | //#define wxUSE_UNICODE 0 5 | //#undef _UNICODE 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class wxWizardPageStaticText : public wxWizardPageSimple 14 | { 15 | private: 16 | DECLARE_EVENT_TABLE() 17 | protected: 18 | wxBoxSizer* sizer; 19 | wxStaticText* statictext; 20 | wxString txt; 21 | public: 22 | wxWizardPageStaticText (wxWizard* parent, wxString text); 23 | void SetText (wxString& text) { txt = text; } 24 | void AppendText (wxString text) { txt += text; } 25 | protected: 26 | virtual void OnSize (wxSizeEvent& event); 27 | virtual void OnWizardPageChanging (wxWizardEvent& event); 28 | }; 29 | 30 | class wxWizardPageSelect : public wxWizardPageStaticText 31 | { 32 | protected: 33 | static const long ID_LISTBOX; 34 | private: 35 | DECLARE_EVENT_TABLE() 36 | protected: 37 | wxListBox* listbox; 38 | public: 39 | wxWizardPageSelect (wxWizard* parent, wxString text); 40 | void HideSelectBox () { listbox->Hide(); } 41 | void Clear () { listbox->Clear(); } 42 | void AddItem (const char* itemtext) { listbox->Append(itemtext); } 43 | void SetValue (int value) { listbox->SetSelection(value); } 44 | int GetValue () { return listbox->GetSelection(); } 45 | wxString GetValueString () { int i = listbox->GetSelection(); return (i == wxNOT_FOUND ? wxT("") : listbox->GetString(i)); } 46 | protected: 47 | virtual void OnListboxDoubleClick (wxCommandEvent& event); 48 | virtual void OnWizardPageChanging (wxWizardEvent& event); 49 | }; 50 | 51 | class wxWizardPageSelectDirectory : public wxWizardPageStaticText 52 | { 53 | protected: 54 | static const long ID_BUTTON_BROWSE; 55 | protected: 56 | wxTextCtrl* directory; 57 | wxString dialogprompt; 58 | bool askcreate; 59 | bool allowempty; 60 | public: 61 | wxWizardPageSelectDirectory (wxWizard* parent, wxString text, wxString prompt = wxT("")); 62 | void AskCreate (bool ask_create = true) { askcreate = ask_create; } 63 | void AllowEmpty (bool allow_empty = true) { allowempty = allow_empty; } 64 | void SetValue (wxString value); 65 | wxString GetValue (); 66 | private: 67 | void OnListBoxSelect (wxCommandEvent& event); 68 | void OnClickBrowse (wxCommandEvent& event); 69 | protected: 70 | virtual void OnWizardPageChanging (wxWizardEvent& event); 71 | }; 72 | 73 | class wxWizardRadioBox : public wxWizardPageStaticText 74 | { 75 | protected: 76 | static const long ID_RADIOBOX; 77 | protected: 78 | wxRadioBox* radiobox; 79 | public: 80 | wxWizardRadioBox (wxWizard* parent, wxString text, wxString choice1, wxString choice2); 81 | void SetValue (int value) { radiobox->SetSelection(value); } 82 | int GetValue () { return radiobox->GetSelection(); } 83 | }; 84 | 85 | class WinLibsWizardGUI : public wxWizard 86 | { 87 | private: 88 | wxWizardPageStaticText* page_begin; 89 | wxWizardPageSelectDirectory* page_msyspath; 90 | /* 91 | wxWizardPageSelectDirectory* page_dstdir; 92 | wxWizardRadioBox* page_searchtype; 93 | */ 94 | wxWizardPageStaticText* page_done; 95 | wxTextCtrl* status; 96 | public: 97 | WinLibsWizardGUI (wxWindow* parent); 98 | virtual void OnProcessStatus (std::string msg, bool iserror); 99 | virtual bool Run (); 100 | }; 101 | 102 | #endif //__INCLUDED_SIGNATURE2TEMPLATEGUI_H 103 | -------------------------------------------------------------------------------- /src/handle_interrupts.h: -------------------------------------------------------------------------------- 1 | /* 2 | handle Ctrl-C/break/interrupt/close signals 3 | */ 4 | 5 | #ifndef INCLUDED_HANDLE_INTERRUPTS_H 6 | #define INCLUDED_HANDLE_INTERRUPTS_H 7 | 8 | #ifdef _WIN32 9 | # include 10 | #else 11 | # include 12 | #endif 13 | 14 | //!start definition of function to handle interrupt signals 15 | /*! 16 | \param function_name name of function to handle interrupt signals 17 | */ 18 | #ifdef _WIN32 19 | # define DEFINE_INTERRUPT_HANDLER_BEGIN(function_name) \ 20 | BOOL WINAPI function_name (DWORD interrupt_signal) { \ 21 | if (interrupt_signal == CTRL_C_EVENT || \ 22 | interrupt_signal == CTRL_BREAK_EVENT || \ 23 | interrupt_signal == CTRL_CLOSE_EVENT || \ 24 | interrupt_signal == CTRL_LOGOFF_EVENT || \ 25 | interrupt_signal == CTRL_SHUTDOWN_EVENT) { 26 | #else 27 | # define DEFINE_INTERRUPT_HANDLER_BEGIN(function_name) \ 28 | void function_name (int interrupt_signal) { 29 | #endif 30 | 31 | //!finish definition of function to handle interrupt signals 32 | /*! 33 | \param function_name name of function to handle interrupt signals 34 | */ 35 | #ifdef _WIN32 36 | # define DEFINE_INTERRUPT_HANDLER_END(function_name) } else { return FALSE; } return TRUE; } 37 | #else 38 | # define DEFINE_INTERRUPT_HANDLER_END(function_name) signal(interrupt_signal, function_name); } 39 | #endif 40 | 41 | //!macros to check which signal was triggered 42 | /*! 43 | * \name INTERRUPT_HANDLER_SIGNAL_IS_* 44 | * \{ 45 | */ 46 | #ifdef _WIN32 47 | # define INTERRUPT_HANDLER_SIGNAL_IS_CTRL_C ((interrupt_signal) == CTRL_C_EVENT) 48 | # define INTERRUPT_HANDLER_SIGNAL_IS_BREAK ((interrupt_signal) == CTRL_BREAK_EVENT) 49 | # define INTERRUPT_HANDLER_SIGNAL_IS_CLOSE ((interrupt_signal) == CTRL_CLOSE_EVENT || (interrupt_signal) == CTRL_LOGOFF_EVENT || (interrupt_signal) == CTRL_SHUTDOWN_EVENT) 50 | #else 51 | # define INTERRUPT_HANDLER_SIGNAL_IS_CTRL_C ((interrupt_signal) == SIGINT) 52 | # if defined(SIGBREAK) 53 | # define INTERRUPT_HANDLER_SIGNAL_IS_BREAK ((interrupt_signal) == SIGBREAK) 54 | # elif defined(SIGBRK) 55 | # define INTERRUPT_HANDLER_SIGNAL_IS_BREAK ((interrupt_signal) == SIGBRK) 56 | # else 57 | # define INTERRUPT_HANDLER_SIGNAL_IS_BREAK 0 58 | # endif 59 | # define INTERRUPT_HANDLER_SIGNAL_IS_CLOSE ((interrupt_signal) == SIGTERM) 60 | #endif 61 | /*! @} */ 62 | 63 | //!install function to handle interrupt signals 64 | /*! 65 | \param function_name name of function to handle interrupt signals 66 | */ 67 | #ifdef _WIN32 68 | # define INSTALL_INTERRUPT_HANDLER(function_name) { SetConsoleCtrlHandler(NULL, FALSE); SetConsoleCtrlHandler(function_name, TRUE); } 69 | #else 70 | # if defined(SIGBREAK) 71 | # define INSTALL_INTERRUPT_HANDLER(function_name) { signal(SIGINT, function_name); signal(SIGBREAK, function_name); signal(SIGTERM, function_name); } 72 | # elif defined(SIGBRK) 73 | # define INSTALL_INTERRUPT_HANDLER(function_name) { signal(SIGINT, function_name); signal(SIGBRK, function_name); signal(SIGTERM, function_name); } 74 | # else 75 | # define INSTALL_INTERRUPT_HANDLER(function_name) { signal(SIGINT, function_name); signal(SIGTERM, function_name); } 76 | # endif 77 | #endif 78 | 79 | #endif //INCLUDED_HANDLE_INTERRUPTS_H 80 | -------------------------------------------------------------------------------- /src/memory_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for memory buffer functions 3 | */ 4 | 5 | #ifndef INCLUDED_MEMORY_BUFFER_H 6 | #define INCLUDED_MEMORY_BUFFER_H 7 | 8 | #include 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | //!data structure for memory buffer 16 | struct memory_buffer { 17 | size_t datalen; 18 | char* data; 19 | }; 20 | 21 | //!create memory buffer 22 | /*! 23 | \return memory buffer 24 | */ 25 | struct memory_buffer* memory_buffer_create (); 26 | 27 | //!create memory buffer from string 28 | /*! 29 | \param data string to add to memory buffer 30 | \return memory buffer 31 | */ 32 | struct memory_buffer* memory_buffer_create_from_string (const char* data); 33 | 34 | //!create memory buffer from allocated string, the caller must not free() it 35 | /*! 36 | \param data string to add to memory buffer 37 | \return memory buffer 38 | */ 39 | struct memory_buffer* memory_buffer_create_from_allocated_string (char* data); 40 | 41 | //!clean up memory buffer 42 | /*! 43 | \param membuf memory buffer 44 | */ 45 | void memory_buffer_free (struct memory_buffer* membuf); 46 | 47 | //!clean up memory buffer and return allocated string with the contents 48 | /*! 49 | \param membuf memory buffer 50 | \return null-terminated contents (or NULL if nothing was added), the caller must call free() 51 | */ 52 | char* memory_buffer_free_to_allocated_string (struct memory_buffer* membuf); 53 | 54 | //!get memory buffer contents 55 | /*! 56 | \param membuf memory buffer 57 | \return null-terminated contents (or NULL if empty) 58 | */ 59 | const char* memory_buffer_get (struct memory_buffer* membuf); 60 | 61 | //!get size of memory buffer 62 | /*! 63 | \param membuf memory buffer 64 | \return size of memory buffer 65 | */ 66 | size_t memory_buffer_length (struct memory_buffer* membuf); 67 | 68 | //!set memory buffer to string 69 | /*! 70 | \param membuf memory buffer 71 | \param data string to set memory buffer to 72 | \return memory buffer 73 | */ 74 | struct memory_buffer* memory_buffer_set (struct memory_buffer* membuf, const char* data); 75 | 76 | //!set memory buffer to an allocated string, the caller must not free() it 77 | /*! 78 | \param membuf memory buffer 79 | \param data string to set memory buffer to 80 | \return memory buffer 81 | */ 82 | struct memory_buffer* memory_buffer_set_allocated (struct memory_buffer* membuf, char* data); 83 | 84 | //!grow memory buffer (contents of the additional data will be undefined, this will not shrink if the buffer if newsize is smaller than the current size) 85 | /*! 86 | \param membuf memory buffer 87 | \param newsize string to add to memory buffer 88 | \return new size of memory buffer (or 0 on error) 89 | */ 90 | size_t memory_buffer_grow (struct memory_buffer* membuf, size_t newsize); 91 | 92 | //!append string to memory buffer 93 | /*! 94 | \param membuf memory buffer 95 | \param data string to add to memory buffer 96 | \return number of bytes added 97 | */ 98 | int memory_buffer_append (struct memory_buffer* membuf, const char* data); 99 | 100 | //!append data to memory buffer 101 | /*! 102 | \param membuf memory buffer 103 | \param data data to add to memory buffer 104 | \param datalen size (in bytes) of data to add to memory buffer 105 | \return number of bytes added 106 | */ 107 | int memory_buffer_append_buf (struct memory_buffer* membuf, const char* data, size_t datalen); 108 | 109 | //!set memory buffer using printf formatting 110 | /*! 111 | \param membuf memory buffer 112 | \param format format as used by printf() 113 | \return memory buffer or NULL on error 114 | */ 115 | struct memory_buffer* memory_buffer_set_printf (struct memory_buffer* membuf, const char* format, ...); 116 | 117 | //!append data to memory buffer using printf formatting 118 | /*! 119 | \param membuf memory buffer 120 | \param format format as used by printf() 121 | \return number of bytes added 122 | */ 123 | int memory_buffer_append_printf (struct memory_buffer* membuf, const char* format, ...); 124 | 125 | //!replace part of memory buffer 126 | /*! 127 | \param membuf memory buffer 128 | \param pos starting position of part to replace 129 | \param len length of part to replace 130 | \param replacement new data to replace with 131 | \return memory buffer 132 | */ 133 | struct memory_buffer* memory_buffer_replace (struct memory_buffer* membuf, size_t pos, size_t len, const char* replacement); 134 | 135 | //!replace part of memory buffer 136 | /*! 137 | \param membuf memory buffer 138 | \param pos starting position of part to replace 139 | \param len length of part to replace 140 | \param replacement new data to replace with 141 | \param replacementlen size of new data to replace with 142 | \return memory buffer 143 | */ 144 | struct memory_buffer* memory_buffer_replace_data (struct memory_buffer* membuf, size_t pos, size_t len,const char* replacement, size_t replacementlen); 145 | 146 | //!replace text in memory buffer 147 | /*! 148 | \param membuf memory buffer 149 | \param s1 text to search 150 | \param s2 text to replace with 151 | \return memory buffer 152 | */ 153 | struct memory_buffer* memory_buffer_find_replace_data (struct memory_buffer* membuf, const char* s1, const char* s2); 154 | 155 | //!fix memory buffer for use as XML data 156 | /*! 157 | \param membuf memory buffer 158 | \return memory buffer 159 | */ 160 | struct memory_buffer* memory_buffer_xml_special_chars (struct memory_buffer* membuf); 161 | 162 | //!fix memory buffer for use in a URL 163 | /*! 164 | \param membuf memory buffer 165 | \return memory buffer 166 | */ 167 | struct memory_buffer* url_encode (struct memory_buffer* membuf); 168 | 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | 173 | #endif //INCLUDED_MEMORY_BUFFER_H 174 | -------------------------------------------------------------------------------- /src/obsolete/install_db.c: -------------------------------------------------------------------------------- 1 | #include "install_db.h" 2 | #include "memory_buffer.h" 3 | #include "filesystem.h" 4 | #include "winlibs_common.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int install_db_check_install_path (const char* installpath) 11 | { 12 | return (folder_exists(installpath) ? 0 : -1); 13 | } 14 | 15 | struct install_db_get_package_info_struct* install_db_get_package_info (const char* installpath, const char* packagename) 16 | { 17 | FILE* src; 18 | struct memory_buffer* pkginfopath = memory_buffer_create(); 19 | struct memory_buffer* filepath = memory_buffer_create(); 20 | struct install_db_get_package_info_struct* packageinfo; 21 | //allocate structure for result 22 | if ((packageinfo = (struct install_db_get_package_info_struct*)malloc(sizeof(struct install_db_get_package_info_struct))) == NULL) 23 | return NULL; 24 | packageinfo->installpath = strdup(installpath); 25 | packageinfo->packagename = strdup(packagename); 26 | packageinfo->version = NULL; 27 | //determine package information path 28 | memory_buffer_set_printf(pkginfopath, "%s%s%c%s%c", installpath, PACKAGE_INFO_PATH, PATH_SEPARATOR, packagename, PATH_SEPARATOR); 29 | //load version installed package 30 | if ((src = fopen(memory_buffer_get(memory_buffer_set_printf(filepath, "%s%s", memory_buffer_get(pkginfopath), PACKAGE_INFO_VERSION_FILE)), "rb")) != NULL) { 31 | packageinfo->version = readline_from_file(src); 32 | fclose(src); 33 | } 34 | //clean up 35 | memory_buffer_free(pkginfopath); 36 | memory_buffer_free(filepath); 37 | //abort if version information was not found 38 | if (!packageinfo->version) { 39 | free(packageinfo); 40 | return NULL; 41 | } 42 | return packageinfo; 43 | } 44 | 45 | int install_db_get_package_info_folders (struct install_db_get_package_info_struct* packageinfo, install_db_get_package_info_callback_fn foldercallback, void* foldercallbackdata) 46 | { 47 | FILE* src; 48 | char* line; 49 | int abort; 50 | struct memory_buffer* pkginfopath; 51 | struct memory_buffer* filepath; 52 | if (!packageinfo || !packageinfo->installpath) 53 | return -1; 54 | //iterate folders 55 | abort = 0; 56 | if (foldercallback) { 57 | pkginfopath = memory_buffer_create(); 58 | filepath = memory_buffer_create(); 59 | //determine package information path 60 | memory_buffer_set_printf(pkginfopath, "%s%s%c%s%c", packageinfo->installpath, PACKAGE_INFO_PATH, PATH_SEPARATOR, packageinfo->packagename, PATH_SEPARATOR); 61 | //read and process list of folders 62 | if ((src = fopen(memory_buffer_get(memory_buffer_set_printf(filepath, "%s%s", memory_buffer_get(pkginfopath), PACKAGE_INFO_FOLDERS_FILE)), "rb")) != NULL) { 63 | while (!abort && (line = readline_from_file(src)) != NULL) 64 | abort = (*foldercallback)(packageinfo, line, foldercallbackdata); 65 | fclose(src); 66 | } 67 | //clean up 68 | memory_buffer_free(pkginfopath); 69 | memory_buffer_free(filepath); 70 | } 71 | return abort; 72 | } 73 | 74 | int install_db_get_package_info_files (struct install_db_get_package_info_struct* packageinfo, install_db_get_package_info_callback_fn filecallback, void* filecallbackdata) 75 | { 76 | FILE* src; 77 | char* line; 78 | int abort; 79 | struct memory_buffer* pkginfopath; 80 | struct memory_buffer* filepath; 81 | if (!packageinfo || !packageinfo->installpath) 82 | return -1; 83 | //iterate files 84 | abort = 0; 85 | if (filecallback) { 86 | pkginfopath = memory_buffer_create(); 87 | filepath = memory_buffer_create(); 88 | //determine package information path 89 | memory_buffer_set_printf(pkginfopath, "%s%s%c%s%c", packageinfo->installpath, PACKAGE_INFO_PATH, PATH_SEPARATOR, packageinfo->packagename, PATH_SEPARATOR); 90 | //read and process list of files 91 | if ((src = fopen(memory_buffer_get(memory_buffer_set_printf(filepath, "%s%s", memory_buffer_get(pkginfopath), PACKAGE_INFO_CONTENT_FILE)), "rb")) != NULL) { 92 | while (!abort && (line = readline_from_file(src)) != NULL) 93 | abort = (*filecallback)(packageinfo, line, filecallbackdata); 94 | fclose(src); 95 | } 96 | //clean up 97 | memory_buffer_free(pkginfopath); 98 | memory_buffer_free(filepath); 99 | } 100 | return abort; 101 | } 102 | 103 | void install_db_get_package_info_free (struct install_db_get_package_info_struct* packageinfo) 104 | { 105 | if (!packageinfo) 106 | return; 107 | free(packageinfo->packagename); 108 | free(packageinfo->version); 109 | free(packageinfo); 110 | } 111 | -------------------------------------------------------------------------------- /src/obsolete/install_db.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for functions related to the database of installed packages 3 | */ 4 | 5 | #ifndef INCLUDED_INSTALL_DB_H 6 | #define INCLUDED_INSTALL_DB_H 7 | 8 | #include 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | //!check if installation path exists 16 | /*! 17 | \param installpath installation path 18 | \return zero on success or non-zero on error 19 | */ 20 | int install_db_check_install_path (const char* installpath); 21 | 22 | //!structure used for returning package information 23 | struct install_db_get_package_info_struct { 24 | char* installpath; 25 | char* packagename; 26 | char* version; 27 | }; 28 | 29 | //!callback function used to iterate folders or files of an installed package 30 | /*! 31 | \param packageinfo package information 32 | \param path path of folder or file 33 | \param callbackdata user data 34 | \return zero to continue or non-zero to abort the current listing 35 | */ 36 | typedef int (*install_db_get_package_info_callback_fn)(struct install_db_get_package_info_struct* packageinfo, const char* path, void* callbackdata); 37 | 38 | //!get information about installed package 39 | /*! 40 | \param installpath installation path 41 | \param packagename package name 42 | \param foldercallback callback function to call for each folder in the installed package 43 | \param foldercallbackdata user data to pass to the folder callback function 44 | \param filecallback callback function to call for each file in the installed package 45 | \param filecallbackdata user data to pass to the file callback function 46 | \return installed version or NULL if package was not found 47 | */ 48 | struct install_db_get_package_info_struct* install_db_get_package_info (const char* installpath, const char* packagename); 49 | 50 | //!iterate through all folders in installed package 51 | /*! 52 | \param packageinfo package information 53 | \param foldercallback callback function to call for each folder in the installed package 54 | \param foldercallbackdata user data to pass to the folder callback function 55 | \return 0 if all folders were iterated, -1 on error or exit code of callback function 56 | */ 57 | int install_db_get_package_info_folders (struct install_db_get_package_info_struct* packageinfo, install_db_get_package_info_callback_fn foldercallback, void* foldercallbackdata); 58 | 59 | //!iterate through all files in installed package 60 | /*! 61 | \param packageinfo package information 62 | \param filecallback callback function to call for each file in the installed package 63 | \param filecallbackdata user data to pass to the file callback function 64 | \return 0 if all files were iterated, -1 on error or exit code of callback function 65 | */ 66 | int install_db_get_package_info_files (struct install_db_get_package_info_struct* packageinfo, install_db_get_package_info_callback_fn filecallback, void* filecallbackdata); 67 | 68 | //!clean up structure used for returning package information 69 | /*! 70 | \param packageinfo package information 71 | */ 72 | void install_db_get_package_info_free (struct install_db_get_package_info_struct* packageinfo); 73 | 74 | 75 | 76 | /* 77 | struct install_db_install_package_struct {}; 78 | struct install_db_install_package_struct* install_db_install_package (const char* installpath, const char* packagename); 79 | void install_db_install_package_close (struct install_db_install_package_struct* packageinfo); 80 | int install_db_install_package_folder (struct install_db_install_package_struct* packageinfo, const char* path); 81 | FILE* install_db_install_package_file_create (struct install_db_install_package_struct* packageinfo, const char* path); 82 | int install_db_install_package_file_close (struct install_db_install_package_struct* packageinfo, FILE* filehandle); 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif //INCLUDED_INSTALL_DB_H 90 | -------------------------------------------------------------------------------- /src/pkg.c: -------------------------------------------------------------------------------- 1 | #include "pkg.h" 2 | #include 3 | #include 4 | 5 | const char* package_metadata_field_name[] = { 6 | "Name", 7 | "Version", 8 | "Title", 9 | "Description", 10 | "Website URL", 11 | "Downloads URL", 12 | "Source code URL", 13 | "Category", 14 | "Type", 15 | "Version date", 16 | "License file", 17 | "License type", 18 | "Status", 19 | NULL 20 | }; 21 | 22 | struct package_metadata_struct* package_metadata_create () 23 | { 24 | int i; 25 | struct package_metadata_struct* pkginfo; 26 | if ((pkginfo = (struct package_metadata_struct*)malloc(sizeof(struct package_metadata_struct))) == NULL) 27 | return NULL; 28 | for (i = 0; i < PACKAGE_METADATA_TOTAL_FIELDS; i++) 29 | pkginfo->datafield[i] = NULL; 30 | pkginfo->fileexclusions = sorted_unique_list_create(strcmp, free); 31 | pkginfo->folderexclusions = sorted_unique_list_create(strcmp, free); 32 | pkginfo->filelist = sorted_unique_list_create(strcmp, free); 33 | pkginfo->folderlist = sorted_unique_list_create(strcmp, free); 34 | pkginfo->dependencies = sorted_unique_list_create(strcmp, free); 35 | pkginfo->optionaldependencies = sorted_unique_list_create(strcmp, free); 36 | pkginfo->builddependencies = sorted_unique_list_create(strcmp, free); 37 | pkginfo->optionalbuilddependencies = sorted_unique_list_create(strcmp, free); 38 | pkginfo->totalsize = 0; 39 | pkginfo->version_linenumber = 0; 40 | pkginfo->nextversion_linenumber = 0; 41 | pkginfo->buildok = 0; 42 | pkginfo->lastchanged = 0; 43 | pkginfo->extradata = NULL; 44 | pkginfo->extradata_free_fn = NULL; 45 | return pkginfo; 46 | } 47 | 48 | void package_metadata_free (struct package_metadata_struct* pkginfo) 49 | { 50 | int i; 51 | if (!pkginfo) 52 | return; 53 | for (i = 0; i < PACKAGE_METADATA_TOTAL_FIELDS; i++) 54 | if (pkginfo->datafield[i]) 55 | free(pkginfo->datafield[i]); 56 | sorted_unique_list_free(pkginfo->fileexclusions); 57 | sorted_unique_list_free(pkginfo->folderexclusions); 58 | sorted_unique_list_free(pkginfo->filelist); 59 | sorted_unique_list_free(pkginfo->folderlist); 60 | sorted_unique_list_free(pkginfo->dependencies); 61 | sorted_unique_list_free(pkginfo->optionaldependencies); 62 | sorted_unique_list_free(pkginfo->builddependencies); 63 | sorted_unique_list_free(pkginfo->optionalbuilddependencies); 64 | if (pkginfo->extradata && pkginfo->extradata_free_fn) 65 | (*(pkginfo->extradata_free_fn))(pkginfo->extradata); 66 | free(pkginfo); 67 | } 68 | -------------------------------------------------------------------------------- /src/pkg.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for the package information data structure 3 | */ 4 | 5 | #ifndef INCLUDED_PKG_H 6 | #define INCLUDED_PKG_H 7 | 8 | #include "sorted_unique_list.h" 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | //!macros specifying package data field index 18 | /*! 19 | * \name PACKAGE_METADATA_INDEX_* 20 | * \{ 21 | */ 22 | #define PACKAGE_METADATA_INDEX_BASENAME 0 23 | #define PACKAGE_METADATA_INDEX_VERSION 1 24 | #define PACKAGE_METADATA_INDEX_NAME 2 25 | #define PACKAGE_METADATA_INDEX_DESCRIPTION 3 26 | #define PACKAGE_METADATA_INDEX_URL 4 27 | #define PACKAGE_METADATA_INDEX_DOWNLOADURL 5 28 | #define PACKAGE_METADATA_INDEX_DOWNLOADSOURCEURL 6 29 | #define PACKAGE_METADATA_INDEX_CATEGORY 7 30 | #define PACKAGE_METADATA_INDEX_TYPE 8 31 | #define PACKAGE_METADATA_INDEX_VERSIONDATE 9 32 | #define PACKAGE_METADATA_INDEX_LICENSEFILE 10 33 | #define PACKAGE_METADATA_INDEX_LICENSETYPE 11 34 | #define PACKAGE_METADATA_INDEX_STATUS 12 35 | #define PACKAGE_METADATA_TOTAL_FIELDS 13 36 | /*! @} */ 37 | 38 | //!names of package data fields 39 | /*! 40 | * \sa PACKAGE_METADATA_INDEX_* 41 | */ 42 | extern const char* package_metadata_field_name[]; 43 | 44 | //!data structure for package information 45 | struct package_metadata_struct { 46 | char* datafield[PACKAGE_METADATA_TOTAL_FIELDS]; 47 | sorted_unique_list* fileexclusions; 48 | sorted_unique_list* folderexclusions; 49 | sorted_unique_list* filelist; 50 | sorted_unique_list* folderlist; 51 | sorted_unique_list* dependencies; 52 | sorted_unique_list* optionaldependencies; 53 | sorted_unique_list* builddependencies; 54 | sorted_unique_list* optionalbuilddependencies; 55 | uint64_t totalsize; 56 | size_t version_linenumber; 57 | size_t nextversion_linenumber; 58 | int buildok; 59 | time_t lastchanged; 60 | void* extradata; 61 | void (*extradata_free_fn)(void*); 62 | }; 63 | 64 | //!create and initialize data structure for package information 65 | struct package_metadata_struct* package_metadata_create (); 66 | 67 | //!clean up data structure for package information 68 | void package_metadata_free (struct package_metadata_struct* metadata); 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif //INCLUDED_PKG_H 75 | -------------------------------------------------------------------------------- /src/pkgdb.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for functions related to writing to the database of installed packages 3 | */ 4 | 5 | #ifndef INCLUDED_PKGDB_H 6 | #define INCLUDED_PKGDB_H 7 | 8 | #include "pkg.h" 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | //!handle type used for writing to package database 18 | typedef struct pkgdb_handle_struct* pkgdb_handle; 19 | 20 | //!open handle for writing to package database 21 | /*! 22 | \param rootpath package install location 23 | \return a handle on success or NULL on error 24 | */ 25 | pkgdb_handle pkgdb_open (const char* rootpath); 26 | 27 | //!close handle for writing to package database 28 | /*! 29 | \param handle database handle 30 | */ 31 | void pkgdb_close (pkgdb_handle handle); 32 | 33 | //!get installation root path for package database 34 | /*! 35 | \param handle database handle 36 | \return root path or NULL on error (if handle is NULL) 37 | */ 38 | const char* pkgdb_get_rootpath (pkgdb_handle handle); 39 | 40 | //!add package information to package database 41 | /*! 42 | \param handle database handle 43 | \param pkginfo package information 44 | \return 0 on success 45 | */ 46 | int pkgdb_install_package (pkgdb_handle handle, const struct package_metadata_struct* pkginfo); 47 | 48 | //!remove package from package database 49 | /*! 50 | \param handle database handle 51 | \param package package name 52 | \return 0 on success 53 | */ 54 | int pkgdb_uninstall_package (pkgdb_handle handle, const char* package); 55 | 56 | //!read package information from package database 57 | /*! 58 | \param handle database handle 59 | \param package package name 60 | \param pkginfo place where package information will be stored 61 | \return package information or NULL on error, the caller must free the result with package_metadata_free() 62 | */ 63 | struct package_metadata_struct* pkgdb_read_package (pkgdb_handle handle, const char* package); 64 | 65 | //!callback function used to iterate folders or files of an installed package 66 | /*! 67 | \param handle database handle 68 | \param path path of folder or file (relative to install path) 69 | \param callbackdata user data 70 | \return zero to continue or non-zero to abort the current listing 71 | */ 72 | typedef int (*pkgdb_file_folder_callback_fn)(pkgdb_handle handle, const char* path, void* callbackdata); 73 | 74 | //!iterate through all files in installed package 75 | /*! 76 | \param handle database handle 77 | \param package package name 78 | \param callback callback function to call for each file in the installed package 79 | \param callbackdata user data to pass to the file callback function 80 | \return 0 if all files were iterated, -1 on error or exit code of callback function 81 | */ 82 | int pkgdb_interate_package_files (pkgdb_handle handle, const char* package, pkgdb_file_folder_callback_fn callback, void* callbackdata); 83 | 84 | //!iterate through all folders in installed package 85 | /*! 86 | \param handle database handle 87 | \param package package name 88 | \param callback callback function to call for each folder in the installed package 89 | \param callbackdata user data to pass to the file callback function 90 | \return 0 if all files were iterated, -1 on error or exit code of callback function 91 | */ 92 | int pkgdb_interate_package_folders (pkgdb_handle handle, const char* package, pkgdb_file_folder_callback_fn callback, void* callbackdata); 93 | 94 | #if 0 95 | //!callback function used to iterate packages 96 | /*! 97 | \param handle database handle 98 | \param pkginfo package information (only \a datafield values are set) 99 | \param callbackdata user data 100 | \return zero to continue or non-zero to abort the current listing 101 | */ 102 | typedef int (*pkgdb_package_callback_fn)(pkgdb_handle handle, const struct package_metadata_struct* pkginfo, void* callbackdata); 103 | #endif 104 | 105 | //!check if packages are installed 106 | /*! 107 | \param handle database handle 108 | \param packagelist comma separated list of package names 109 | \return non-zero if all packages are installed, zero if at least package is missing 110 | */ 111 | size_t pkgdb_packages_are_installed (pkgdb_handle handle, const char* packagelist); 112 | 113 | 114 | //!get sqlite3 handleSQL query with 1 string parameter 115 | /*! 116 | \param handle database handle 117 | \return sqlite3 handle or NULL on error 118 | */ 119 | sqlite3* pkgdb_get_sqlite3_handle (pkgdb_handle handle); 120 | 121 | //!open an sqlite3 SQL query with 1 string parameter 122 | /*! 123 | \param handle database handle 124 | \param sql SQL query 125 | \param status pointer that will receive sqlite3 status code 126 | \param param1 parameter 127 | \return sqlite3 prepared statement object or NULL on error 128 | */ 129 | sqlite3_stmt* pkgdb_sql_query_param_str (pkgdb_handle handle, const char* sql, int* status, const char* param1); 130 | 131 | //!get next rowopen an sqlite3 SQL query with 1 string parameter 132 | /*! 133 | \param sqlresult sqlite3 prepared statement object 134 | \return sqlite3 status code 135 | */ 136 | int pkgdb_sql_query_next_row (sqlite3_stmt* sqlresult); 137 | 138 | 139 | 140 | //!callback function used by iterate_items_in_list() 141 | /*! 142 | \param item item data 143 | \param callbackdata callback data passed to read_packageinfolist 144 | \return zero to continue processing, non-zero to abort 145 | */ 146 | typedef size_t (*iterate_items_in_list_callback_fn)(const char* item, void* callbackdata); 147 | 148 | //!iterate through list of items 149 | /*! 150 | \param itemlist list of package names 151 | \param separator separator 152 | \param callback callback function to be called for each package name 153 | \param callbackdata callback data passed to be passed to callback function 154 | \return last result from callback (should be zero if all entries were processed) 155 | */ 156 | size_t iterate_items_in_list (const char* itemlist, char separator, iterate_items_in_list_callback_fn callback, void* callbackdata); 157 | 158 | 159 | 160 | #ifdef __cplusplus 161 | } 162 | #endif 163 | 164 | #endif //INCLUDED_PKGDB_H 165 | -------------------------------------------------------------------------------- /src/pkgfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for functions related to writing to the database of installed packages 3 | */ 4 | 5 | #ifndef INCLUDED_PKGFILE_H 6 | #define INCLUDED_PKGFILE_H 7 | 8 | #include "pkg.h" 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct packageinfo_file_struct* packageinfo_file; 16 | packageinfo_file open_packageinfo_file (const char* infopath, const char* basename); 17 | void close_packageinfo_file (packageinfo_file pkgfile); 18 | char* packageinfo_file_readline (packageinfo_file pkgfile); 19 | 20 | //!check path(s) of build package information files 21 | /*! 22 | \param infopath full path(s) of directory containing build information files 23 | \return 0 if no valid paths were found, < 0 on success, > 0 specifying the number of invalid folders in the list 24 | */ 25 | int check_packageinfo_paths (const char* infopath); 26 | 27 | //!get build package information from file 28 | /*! 29 | \param infopath full path(s) of directory containing build information files 30 | \param basename name of package 31 | \return package information (or NULL on error), the caller must clean up with free_packageinfo() 32 | */ 33 | struct package_metadata_struct* read_packageinfo (const char* infopath, const char* basename); 34 | 35 | //!get download information from package information 36 | /*! 37 | \param packageinfo package information 38 | \param url pointer that will receive the URL where the package sources can be downloaded 39 | \param filematchprefix pointer that will receive the source file matching prefix (or NULL if none specified) 40 | \param filematchsuffix pointer that will receive the source file matching suffix (or NULL if none specified) 41 | */ 42 | void get_package_downloadurl_info (struct package_metadata_struct* packageinfo, char** url, char** filematchprefix, char** filematchsuffix); 43 | 44 | //!callback function used by read_packageinfolist (can be used to show progress) 45 | /*! 46 | \param basename name of package 47 | \param callbackdata callback data passed to read_packageinfolist 48 | \return zero to continue processing, non-zero to abort 49 | */ 50 | typedef int (*package_callback_fn)(const char* basename, void* callbackdata); 51 | 52 | //!iterate through build package information 53 | /*! 54 | \param infopath full path(s) of directory containing build information files 55 | \param callback callback function to be called for each package 56 | \param callbackdata callback data passed to be passed to callback function 57 | \return number of packages processed 58 | */ 59 | size_t iterate_packages (const char* infopath, package_callback_fn callback, void* callbackdata); 60 | 61 | //!iterate through build package information 62 | /*! 63 | \param list list of package names 64 | \param callback callback function to be called for each package name 65 | \param callbackdata callback data passed to be passed to callback function 66 | \return last result from callback (should be zero if all entries were processed) 67 | */ 68 | int iterate_packages_in_list (const sorted_unique_list* sortuniqlist, package_callback_fn callback, void* callbackdata); 69 | 70 | //!data structure for package information list 71 | struct package_info_list_struct { 72 | struct package_metadata_struct* info; 73 | struct package_info_list_struct* next; 74 | }; 75 | 76 | #if 0 77 | //!get list of build package information 78 | /*! 79 | \param infopath full path(s) of directory containing build information files 80 | \param callback callback function to be called for each package 81 | \param callbackdata callback data passed to be passed to callback function 82 | \return package information list (or NULL on error or if list is empty) 83 | */ 84 | struct package_info_list_struct* read_packageinfolist (const char* infopath, package_callback_fn callback, void* callbackdata); 85 | #endif 86 | 87 | //!free package information list 88 | /*! 89 | \param packagelist package information list 90 | \param basename name of package 91 | */ 92 | void free_packageinfolist (struct package_info_list_struct* packagelist); 93 | 94 | //!search package in package information list 95 | /*! 96 | \param packagelist package information list 97 | \param basename name of package 98 | \return pointer to package information or NULL if not found 99 | */ 100 | struct package_info_list_struct* search_packageinfolist_by_basename (struct package_info_list_struct* packagelist, const char* basename); 101 | 102 | //!add package and its dependencies to package information list 103 | /*! 104 | \param packagelist package information list 105 | \param infopath full path(s) of directory containing build information files 106 | \param basename name of package 107 | \return zero on success or non-zero when the package was not added 108 | */ 109 | int insert_package_by_dependency (struct package_info_list_struct** packagelist, const char* infopath, const char* basename); 110 | 111 | //!check if package is installed 112 | /*! 113 | \param installpath path where packages are installed 114 | \param basename name of package 115 | \return non-zero if package is installed 116 | */ 117 | int package_is_installed (const char* installpath, const char* basename); 118 | 119 | //!check if packages are installed 120 | /*! 121 | \param installpath path where packages are installed 122 | \param packagelist comma separated list of package names 123 | \return non-zero if all packages are installed 124 | */ 125 | /* 126 | int packages_are_installed (const char* installpath, const char* packagelist); 127 | */ 128 | 129 | //!check which version of package is installed 130 | /*! 131 | \param installpath path where packages are installed 132 | \param basename name of package 133 | \return version (caller must free() the result) or NULL if not installed 134 | */ 135 | /* 136 | char* installed_package_version (const char* installpath, const char* basename); 137 | */ 138 | 139 | //!check when the package was installed 140 | /*! 141 | \param installpath path where packages are installed 142 | \param basename name of package 143 | \return timestamp of last installation or update or 0 if not installed 144 | */ 145 | time_t installed_package_lastchanged (const char* installpath, const char* basename); 146 | 147 | //!remove missing packages from comma separated list 148 | /*! 149 | \param installpath path where packages are installed 150 | \param packagelist comma separated list of package names (will be modified) 151 | \return number of entries removed from list 152 | */ 153 | int packages_remove_missing_from_list (const char* installpath, char* packagelist); 154 | 155 | #ifdef __cplusplus 156 | } 157 | #endif 158 | 159 | #endif //INCLUDED_PKGFILE_H 160 | -------------------------------------------------------------------------------- /src/sorted_item_queue.c: -------------------------------------------------------------------------------- 1 | #include "sorted_item_queue.h" 2 | #include 3 | 4 | //#define PTHREAD_USE_MUTEX_AS_LOCK 5 | 6 | struct sorted_item_queue_struct { 7 | sorted_unique_list* list; 8 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 9 | pthread_rwlock_t lock; 10 | #else 11 | pthread_mutex_t lock; 12 | #endif 13 | }; 14 | 15 | struct sorted_item_queue_struct* sorted_item_queue_create (sorted_unique_compare_fn comparefunction) 16 | { 17 | struct sorted_item_queue_struct* handle; 18 | if ((handle = (struct sorted_item_queue_struct*)malloc(sizeof(struct sorted_item_queue_struct))) == NULL) 19 | return NULL; 20 | if ((handle->list = sorted_unique_list_create(comparefunction, free)) == NULL) { 21 | free(handle); 22 | return NULL; 23 | } 24 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 25 | if (pthread_rwlock_init(&handle->lock, NULL/*PTHREAD_MUTEX_ERRORCHECK*/) != 0) { 26 | #else 27 | if (pthread_mutex_init(&handle->lock, NULL) != 0) { 28 | #endif 29 | free(handle); 30 | return NULL; 31 | } 32 | return handle; 33 | }; 34 | 35 | void sorted_item_queue_free (struct sorted_item_queue_struct* handle) 36 | { 37 | if (!handle) 38 | return; 39 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 40 | pthread_rwlock_wrlock(&handle->lock); 41 | #else 42 | pthread_mutex_lock(&handle->lock); 43 | #endif 44 | sorted_unique_list_free(handle->list); 45 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 46 | pthread_rwlock_unlock(&handle->lock); 47 | pthread_rwlock_destroy(&handle->lock); 48 | #else 49 | pthread_mutex_unlock(&handle->lock); 50 | pthread_mutex_destroy(&handle->lock); 51 | #endif 52 | free(handle); 53 | } 54 | 55 | size_t sorted_item_queue_size (struct sorted_item_queue_struct* handle) 56 | { 57 | size_t result; 58 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 59 | pthread_rwlock_rdlock(&handle->lock); 60 | #else 61 | pthread_mutex_lock(&handle->lock); 62 | #endif 63 | result = sorted_unique_list_size(handle->list); 64 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 65 | pthread_rwlock_unlock(&handle->lock); 66 | #else 67 | pthread_mutex_unlock(&handle->lock); 68 | #endif 69 | return result; 70 | } 71 | 72 | int sorted_item_queue_add (struct sorted_item_queue_struct* handle, const char* value) 73 | { 74 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 75 | pthread_rwlock_wrlock(&handle->lock); 76 | #else 77 | pthread_mutex_lock(&handle->lock); 78 | #endif 79 | sorted_unique_list_add(handle->list, value); 80 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 81 | pthread_rwlock_unlock(&handle->lock); 82 | #else 83 | pthread_mutex_unlock(&handle->lock); 84 | #endif 85 | return 0; 86 | } 87 | 88 | int sorted_item_queue_add_callback (const char* value, void* handle) 89 | { 90 | return sorted_item_queue_add((struct sorted_item_queue_struct*)handle, value); 91 | } 92 | 93 | int sorted_item_queue_add_allocated (struct sorted_item_queue_struct* handle, char* value) 94 | { 95 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 96 | pthread_rwlock_wrlock(&handle->lock); 97 | #else 98 | pthread_mutex_lock(&handle->lock); 99 | #endif 100 | sorted_unique_list_add_allocated(handle->list, value); 101 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 102 | pthread_rwlock_unlock(&handle->lock); 103 | #else 104 | pthread_mutex_unlock(&handle->lock); 105 | #endif 106 | return 0; 107 | } 108 | 109 | char* sorted_item_queue_take_next (struct sorted_item_queue_struct* handle, size_t* remaining) 110 | { 111 | char* result; 112 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 113 | pthread_rwlock_wrlock(&handle->lock); 114 | #else 115 | pthread_mutex_lock(&handle->lock); 116 | #endif 117 | result = sorted_unique_list_get_and_remove_first(handle->list); 118 | if (remaining) 119 | *remaining = sorted_unique_list_size(handle->list); 120 | #ifndef PTHREAD_USE_MUTEX_AS_LOCK 121 | pthread_rwlock_unlock(&handle->lock); 122 | #else 123 | pthread_mutex_unlock(&handle->lock); 124 | #endif 125 | return result; 126 | } 127 | -------------------------------------------------------------------------------- /src/sorted_item_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for sorted item queue functions 3 | */ 4 | 5 | #ifndef INCLUDED_SORTED_ITEM_QUEUE_H 6 | #define INCLUDED_SORTED_ITEM_QUEUE_H 7 | 8 | #include "sorted_unique_list.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* thread-safe sorted item queue */ 15 | 16 | //!data structure for sorted item queue 17 | struct sorted_item_queue_struct; 18 | 19 | //!create new sorted item queue 20 | /*! 21 | \param comparefunction comparison function used for sorting 22 | \return new sorted item queue or NULL on error (memory allocation error) 23 | */ 24 | struct sorted_item_queue_struct* sorted_item_queue_create (sorted_unique_compare_fn comparefunction); 25 | 26 | //!clean up sorted item queue 27 | /*! 28 | \param handle sorted item queue 29 | */ 30 | void sorted_item_queue_free (struct sorted_item_queue_struct* handle); 31 | 32 | //!get number of entries in sorted item queue 33 | /*! 34 | \param handle sorted item queue 35 | \return number of entries in sorted item queue 36 | */ 37 | size_t sorted_item_queue_size (struct sorted_item_queue_struct* handle); 38 | 39 | //!add value to sorted item queue 40 | /*! 41 | \param handle sorted item queue 42 | \param value value to add to queue 43 | \return number of entries in sorted item queue 44 | */ 45 | int sorted_item_queue_add (struct sorted_item_queue_struct* handle, const char* value); 46 | 47 | //!add value to sorted item queue (for use as callback function) 48 | /*! 49 | \param handle sorted item queue 50 | \param value value to add to queue 51 | \return number of entries in sorted item queue 52 | */ 53 | int sorted_item_queue_add_callback (const char* value, void* handle); 54 | 55 | //!add allocated value to sorted item queue 56 | /*! 57 | \param handle sorted item queue 58 | \param value allocated value to add to queue (caller must no longer free() it) 59 | \return number of entries in sorted item queue 60 | */ 61 | int sorted_item_queue_add_allocated (struct sorted_item_queue_struct* handle, char* value); 62 | 63 | //!get first entry from sorted item queue and remove it 64 | /*! 65 | \param handle sorted item queue 66 | \param value value to add to queue 67 | \return number of entries in sorted item queue 68 | */ 69 | char* sorted_item_queue_take_next (struct sorted_item_queue_struct* handle, size_t* remaining); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif //INCLUDED_SORTED_ITEM_QUEUE_H 76 | -------------------------------------------------------------------------------- /src/version_check_db.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file for functions for the database used to check for new source releases 3 | */ 4 | 5 | #ifndef INCLUDED_VERSION_CHECK_DB_H 6 | #define INCLUDED_VERSION_CHECK_DB_H 7 | 8 | #include 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | //!data structure for version check master database handle 16 | struct versioncheckmasterdb; 17 | 18 | //!open version check database (only use in main thread) 19 | /*! 20 | \return version check master database handle or NULL on error 21 | */ 22 | struct versioncheckmasterdb* versioncheckmasterdb_open (const char* dbpath); 23 | 24 | //!close version check master database (only use in main thread) 25 | /*! 26 | \param handle version check database handle 27 | */ 28 | void versioncheckmasterdb_close (struct versioncheckmasterdb* handle); 29 | 30 | 31 | 32 | //!data structure for version check database handle 33 | struct versioncheckdb; 34 | 35 | //!open version check database 36 | /*! 37 | \return version check database handle or NULL on error 38 | */ 39 | struct versioncheckdb* versioncheckdb_open (struct versioncheckmasterdb* masterdb); 40 | 41 | //!close version check database 42 | /*! 43 | \param handle version check database handle 44 | */ 45 | void versioncheckdb_close (struct versioncheckdb* handle); 46 | 47 | //!update package information in version check database 48 | /*! 49 | \param handle version check database handle 50 | \param packagename name of package 51 | \param status information about current status (set to NULL for no issues) 52 | \param currentversion current version 53 | \param downloadurl URL of page with available versions 54 | \return zero on success or non-zero on error 55 | */ 56 | int versioncheckdb_update_package (struct versioncheckdb* handle, const char* packagename, long responsecode, const char* status, const char* currentversion, const char* downloadurl); 57 | 58 | #if 0 59 | //!update package information from version check database 60 | /*! 61 | \param handle version check database handle 62 | \param packagename name of package 63 | \param updated pointer that will receive latest timestamp (if not set to NULL) 64 | \return zero if not found, positive on success, negative on error 65 | */ 66 | int versioncheckdb_get_package (struct versioncheckdb* handle, const char* packagename, time_t* updated); 67 | #endif 68 | 69 | //!update package version information in version check database 70 | /*! 71 | \param handle version check database handle 72 | \param packagename name of package 73 | \param version version 74 | \return zero on success or non-zero on error 75 | */ 76 | int versioncheckdb_update_package_version (struct versioncheckdb* handle, const char* packagename, const char* version); 77 | 78 | //!group the next database actions together in one transaction 79 | /*! 80 | \param handle version check database handle 81 | */ 82 | void versioncheckdb_group_start (struct versioncheckdb* handle); 83 | 84 | //!end transaction group 85 | /*! 86 | \param handle version check database handle 87 | */ 88 | int versioncheckdb_group_end (struct versioncheckdb* handle); 89 | 90 | //!callback function used by versioncheckdb_list_new_package_versions (can be used to show progress) 91 | /*! 92 | \param version version 93 | \param callbackdata callback data passed to versioncheckdb_list_new_package_versions 94 | \return zero to continue processing, non-zero to abort 95 | */ 96 | typedef int (*versioncheckdb_list_new_package_versions_callback_fn)(const char* version, void* callbackdata); 97 | 98 | //!list new package versions 99 | /*! 100 | \param handle version check database handle 101 | \param packagename name of package 102 | \param since time stamp since when 103 | */ 104 | void versioncheckdb_list_new_package_versions (struct versioncheckdb* handle, const char* packagename, time_t since, versioncheckdb_list_new_package_versions_callback_fn callback, void* callbackdata); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif //INCLUDED_VERSION_CHECK_DB_H 111 | -------------------------------------------------------------------------------- /src/winlibs-setup-GUI.cpp: -------------------------------------------------------------------------------- 1 | #include "winlibs-setup-GUI.h" 2 | #include "gui-wizard.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | //#define LOGERROR(s) { wxMessageBox((s), wxT(PROGRAM_NAME " error"), wxOK | wxICON_ERROR); } 8 | 9 | IMPLEMENT_APP(wxWinlibsSetupGUIApp); 10 | 11 | bool wxWinlibsSetupGUIApp::OnInit() 12 | { 13 | WinLibsWizardGUI* wizard = new WinLibsWizardGUI(NULL); 14 | //wizard->SetIcon(wxICON(aaaa)); 15 | wizard->Run(); 16 | return false; 17 | } 18 | -------------------------------------------------------------------------------- /src/winlibs-setup-GUI.h: -------------------------------------------------------------------------------- 1 | #ifndef __INCLUDED_WINLIBS_SETUP_GUI_H 2 | #define __INCLUDED_WINLIBS_SETUP_GUI_H 3 | 4 | #include 5 | #include 6 | 7 | class wxWinlibsSetupGUIApp : public wxApp 8 | { 9 | public: 10 | virtual bool OnInit(); 11 | }; 12 | 13 | #endif //__INCLUDED_WINLIBS_SETUP_GUI_H 14 | -------------------------------------------------------------------------------- /src/winlibs_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | header file with common definitions for winlibs tools 3 | */ 4 | 5 | #ifndef INCLUDED_WINLIBS_COMMON_H 6 | #define INCLUDED_WINLIBS_COMMON_H 7 | 8 | /*! \brief version number constants 9 | * \name WINLIBS_VERSION_* 10 | * \{ 11 | */ 12 | /*! \brief major version number */ 13 | #define WINLIBS_VERSION_MAJOR 1 14 | /*! \brief minor version number */ 15 | #define WINLIBS_VERSION_MINOR 0 16 | /*! \brief micro version number */ 17 | #define WINLIBS_VERSION_MICRO 17 18 | /*! @} */ 19 | 20 | /*! \brief packed version number */ 21 | #define WINLIBS_VERSION (WINLIBS_VERSION_MAJOR * 0x01000000 + WINLIBS_VERSION_MINOR * 0x00010000 + WINLIBS_VERSION_MICRO * 0x00000100) 22 | 23 | /*! \cond PRIVATE */ 24 | #define WINLIBS_VERSION_STRINGIZE_(major, minor, micro) #major"."#minor"."#micro 25 | #define WINLIBS_VERSION_STRINGIZE(major, minor, micro) WINLIBS_VERSION_STRINGIZE_(major, minor, micro) 26 | /*! \endcond */ 27 | 28 | /*! \brief string with dotted version number \hideinitializer */ 29 | #define WINLIBS_VERSION_STRING WINLIBS_VERSION_STRINGIZE(WINLIBS_VERSION_MAJOR, WINLIBS_VERSION_MINOR, WINLIBS_VERSION_MICRO) 30 | 31 | /*! \brief project license type \hideinitializer */ 32 | #define WINLIBS_LICENSE "GPL" 33 | 34 | /*! \brief project credits \hideinitializer */ 35 | #define WINLIBS_CREDITS "Brecht Sanders (2020-2024)" 36 | 37 | /*! \cond PRIVATE */ 38 | #if defined(_WIN32) && !defined(NOWINDOWSCONSOLE) 39 | #define WINLIBS_HELP_COLOR_WIN "the output is a Windows console then its features will be used. If not and\n" 40 | #else 41 | #define WINLIBS_HELP_COLOR_WIN 42 | #endif 43 | /*! \endcond */ 44 | 45 | /*! \brief help text for color output */ 46 | #define WINLIBS_HELP_COLOR \ 47 | "Color will be used and the terminal window title will be set if possible.\n" \ 48 | "If " WINLIBS_HELP_COLOR_WIN "the TERM environment variable is set ANSI/VT color codes will be used.\n" \ 49 | "Otherwise no color will be used and the terminal window title will not be set.\n" \ 50 | "Set environment variable NO_COLOR to explicitly force plain output.\n" 51 | 52 | /*! \brief name of file in package containing metadata */ 53 | #define PACKAGE_INFO_METADATA_FILE ".packageinfo.xml" 54 | 55 | /*! \brief name of folder in package containing license files */ 56 | #define PACKAGE_INFO_LICENSE_FOLDER ".license" 57 | 58 | /*! \brief name of file containing version number */ 59 | #define PACKAGE_INFO_VERSION_FILE "version" 60 | 61 | /*! \brief name of file containing file list */ 62 | #define PACKAGE_INFO_CONTENT_FILE "files" 63 | 64 | /*! \brief name of file containing folder list */ 65 | #define PACKAGE_INFO_FOLDERS_FILE "folders" 66 | 67 | /*! \brief name of file containing dependencies */ 68 | #define PACKAGE_INFO_DEPENDENCIES_FILE "deps" 69 | #define PACKAGE_INFO_OPTIONALDEPENDENCIES_FILE "deps_optional" 70 | #define PACKAGE_INFO_BUILDDEPENDENCIES_FILE "deps_build" 71 | 72 | 73 | /*! \brief path separator character */ 74 | #ifdef _WIN32 75 | #define PATH_SEPARATOR '\\' 76 | #else 77 | #define PATH_SEPARATOR '/' 78 | #endif 79 | 80 | /*! \brief path list separator character */ 81 | #ifdef _WIN32 82 | #define PATHLIST_SEPARATOR ';' 83 | #else 84 | #define PATHLIST_SEPARATOR ':' 85 | #endif 86 | 87 | /*! \cond PRIVATE */ 88 | #define WINLIBS_CHR2STR_(c) #c 89 | #define WINLIBS_CHR2STR(c) WINLIBS_CHR2STR_(c) 90 | /*! \endcond */ 91 | 92 | /*! \brief path where information about installed packages is stored */ 93 | #ifdef _WIN32 94 | #define PACKAGE_INFO_PATH "\\var\\lib\\packages" 95 | #else 96 | #define PACKAGE_INFO_PATH "/var/lib/packages" 97 | #endif 98 | 99 | /*! \brief path where package information database is stored */ 100 | #ifdef _WIN32 101 | #define PACKAGE_DATABASE_PATH "\\var\\lib\\winlibs" 102 | #else 103 | #define PACKAGE_DATABASE_PATH "/var/lib/winlibs" 104 | #endif 105 | 106 | /*! \brief package information database filename */ 107 | #define PACKAGE_DATABASE_FILE "wl-pkg.db" 108 | 109 | /*! \brief extension for package recipe files */ 110 | #define PACKAGE_RECIPE_EXTENSION ".winlib" 111 | 112 | /*! \brief base name for lock file used for downloads */ 113 | #define SOURCE_DOWNLOAD_LOCK_FILE_BASE ".winlibsdownload" 114 | 115 | /*! \brief sleep for specified number of seconds */ 116 | #ifdef _WIN32 117 | #define SLEEP_SECONDS(s) Sleep(s * 1000); 118 | #else 119 | #define SLEEP_SECONDS(s) sleep(s); 120 | #endif 121 | 122 | ///*! \cond PRIVATE */ 123 | //#if defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) 124 | //#define __USE_MINGW_ANSI_STDIO 0 /* use Windows' printf functions as they are faster */ 125 | //#endif 126 | ///*! \endcond */ 127 | 128 | #endif //INCLUDED_WINLIBS_COMMON_H 129 | -------------------------------------------------------------------------------- /src/wl-info.c: -------------------------------------------------------------------------------- 1 | #include "winlibs_common.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "pkgfile.h" 11 | #include "sorted_unique_list.h" 12 | #include "filesystem.h" 13 | 14 | #define PROGRAM_NAME "wl-info" 15 | #define PROGRAM_DESC "Command line utility to display package recipe information" 16 | 17 | int packageinfo_show (const char* basename, void* callbackdata) 18 | { 19 | struct package_metadata_struct* pkginfo; 20 | const char* packageinfopath = (const char*)callbackdata; 21 | if ((pkginfo = read_packageinfo(packageinfopath, basename)) == NULL) { 22 | fprintf(stderr, "Error reading package information for: %s\n", basename); 23 | } else { 24 | printf("[%s]\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME]); 25 | if (!pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME] || strcmp(basename, pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME]) != 0) { 26 | fprintf(stderr, "Name mismatch for package %s (name in file: %s)\n", basename, (pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME] ? pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME] : "NULL")); 27 | } 28 | printf("basename=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME]); 29 | printf("version=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_VERSION]); 30 | printf("versiondate=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_VERSION]); 31 | printf("name=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_NAME]); 32 | printf("description=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_DESCRIPTION]); 33 | printf("url=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_URL]); 34 | printf("category=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_CATEGORY]); 35 | printf("type=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_CATEGORY]); 36 | printf("builds=%s\n", (pkginfo->buildok ? "yes" : "no")); 37 | printf("status=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_STATUS]); 38 | printf("dependencies="); 39 | sorted_unique_list_print(pkginfo->dependencies, ","); 40 | printf("\n"); 41 | printf("optionaldependencies="); 42 | sorted_unique_list_print(pkginfo->optionaldependencies, ","); 43 | printf("\n"); 44 | printf("builddependencies="); 45 | sorted_unique_list_print(pkginfo->builddependencies, ","); 46 | printf("\n"); 47 | printf("licensefile=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_LICENSEFILE]); 48 | printf("licensetype=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_LICENSETYPE]); 49 | printf("downloadurldata=%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_DOWNLOADURL]); 50 | //printf("downloadsourceurl=%s\n", pkginfo->downloadsourceurl); 51 | //pkginfo->time_t lastchanged; 52 | printf("\n"); 53 | package_metadata_free(pkginfo); 54 | } 55 | return 0; 56 | } 57 | 58 | int main (int argc, char *argv[], char *envp[]) 59 | { 60 | int i; 61 | int showversion = 0; 62 | int showhelp = 0; 63 | int verbose = 0; 64 | const char* packageinfopath = NULL; 65 | //definition of command line arguments 66 | const miniargv_definition argdef[] = { 67 | {'h', "help", NULL, miniargv_cb_increment_int, &showhelp, "show command line help", NULL}, 68 | {0, "version", NULL, miniargv_cb_increment_int, &showversion, "show version information", NULL}, 69 | {'s', "source-path", "PATH", miniargv_cb_set_const_str, &packageinfopath, "path containing build recipes\noverrides environment variable BUILDSCRIPTS\ncan be multiple paths separated by \"" WINLIBS_CHR2STR(PATHLIST_SEPARATOR) "\"", NULL}, 70 | {'v', "verbose", NULL, miniargv_cb_increment_int, &verbose, "verbose mode", NULL}, 71 | //{0, NULL, "PACKAGE", process_arg_param, NULL, "package(s) to build (or \"all\" to list all packages)", NULL}, 72 | {0, NULL, "PACKAGE", miniargv_cb_error, NULL, "package(s) to build (or \"all\" to list all packages)", NULL}, 73 | MINIARGV_DEFINITION_END 74 | }; 75 | //definition of environment variables 76 | const miniargv_definition envdef[] = { 77 | {0, "BUILDSCRIPTS", NULL, miniargv_cb_set_const_str, &packageinfopath, "path where to look for build recipes", NULL}, 78 | //{0, "MINGWPKGINFODIR", NULL, miniargv_cb_set_const_str, &packageinfopath, "path where to look for build recipes", NULL}, 79 | MINIARGV_DEFINITION_END 80 | }; 81 | //parse environment and command line flags 82 | if (miniargv_process_env(envp, envdef, NULL, NULL) != 0) 83 | return 1; 84 | if (miniargv_process_arg_flags(argv, argdef, NULL, NULL) != 0) 85 | return 1; 86 | //show help if requested or if no command line arguments were given 87 | if (showhelp || argc <= 1) { 88 | printf( 89 | PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n" 90 | PROGRAM_DESC "\n" 91 | "Usage: " PROGRAM_NAME " " 92 | ); 93 | miniargv_arg_list(argdef, 1); 94 | printf("\n"); 95 | miniargv_help(argdef, envdef, 24, 0); 96 | #ifdef PORTCOLCON_VERSION 97 | printf(WINLIBS_HELP_COLOR); 98 | #endif 99 | return 0; 100 | } 101 | //show version information if requested 102 | if (showversion) { 103 | printf(PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n"); 104 | return 0; 105 | } 106 | //check parameters 107 | if (miniargv_get_next_arg_param(0, argv, argdef, NULL) <= 0) { 108 | fprintf(stderr, "No packages specified\n"); 109 | return 2; 110 | } 111 | if (!packageinfopath || !*packageinfopath) { 112 | fprintf(stderr, "Missing -s parameter or BUILDSCRIPTS environment variable\n"); 113 | return 2; 114 | } 115 | if (!check_packageinfo_paths(packageinfopath)) { 116 | fprintf(stderr, "Invalid path(s) specified with -s parameter or BUILDSCRIPTS environment variable: %s\n", packageinfopath); 117 | return 3; 118 | } 119 | //process command line argument values 120 | i = 0; 121 | while ((i = miniargv_get_next_arg_param(i, argv, argdef, NULL)) > 0) { 122 | if (strcasecmp(argv[i], "all") == 0) { 123 | iterate_packages(packageinfopath, (package_callback_fn)packageinfo_show, (void*)packageinfopath); 124 | } else { 125 | packageinfo_show(argv[i], (void*)packageinfopath); 126 | } 127 | } 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /src/wl-listall.c: -------------------------------------------------------------------------------- 1 | #include "winlibs_common.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "sorted_unique_list.h" 8 | #include "filesystem.h" 9 | #include "pkgfile.h" 10 | 11 | #define PROGRAM_NAME "wl-listall" 12 | #define PROGRAM_DESC "Command line utility to list available package recipes" 13 | 14 | int packageinfo_callback (const char* basename, void* callbackdata) 15 | { 16 | sorted_unique_list_add((sorted_unique_list*)callbackdata, basename); 17 | return 0; 18 | } 19 | 20 | int main (int argc, char *argv[], char *envp[]) 21 | { 22 | size_t i; 23 | size_t n; 24 | sorted_unique_list* packagelist; 25 | struct package_metadata_struct* pkginfo; 26 | const char* basename; 27 | size_t totalbuilding = 0; 28 | size_t totalproblems = 0; 29 | int showversion = 0; 30 | int showhelp = 0; 31 | int verbose = 1; 32 | const char* packageinfopath = NULL; 33 | //definition of command line arguments 34 | const miniargv_definition argdef[] = { 35 | {'h', "help", NULL, miniargv_cb_increment_int, &showhelp, "show command line help", NULL}, 36 | {0, "version", NULL, miniargv_cb_increment_int, &showversion, "show version information", NULL}, 37 | {'s', "source-path", "PATH", miniargv_cb_set_const_str, &packageinfopath, "build recipe path\noverrides environment variable BUILDSCRIPTS\ncan be multiple paths separated by \"" WINLIBS_CHR2STR(PATHLIST_SEPARATOR) "\"", NULL}, 38 | //{'v', "verbose", NULL, miniargv_cb_increment_int, &verbose, "verbose mode", NULL}, 39 | {'q', "quiet", NULL, miniargv_cb_set_int_to_zero, &verbose, "quiet mode", NULL}, 40 | MINIARGV_DEFINITION_END 41 | }; 42 | //definition of environment variables 43 | const miniargv_definition envdef[] = { 44 | {0, "BUILDSCRIPTS", NULL, miniargv_cb_set_const_str, &packageinfopath, "build recipe path", NULL}, 45 | MINIARGV_DEFINITION_END 46 | }; 47 | //parse environment and command line flags 48 | if (miniargv_process(argv, envp, argdef, envdef, NULL, NULL) != 0) 49 | return 1; 50 | //show help if requested 51 | if (showhelp) { 52 | printf( 53 | PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n" 54 | PROGRAM_DESC "\n" 55 | "Usage: " PROGRAM_NAME " " 56 | ); 57 | miniargv_arg_list(argdef, 1); 58 | printf("\n"); 59 | miniargv_help(argdef, envdef, 24, 0); 60 | #ifdef PORTCOLCON_VERSION 61 | printf(WINLIBS_HELP_COLOR); 62 | #endif 63 | return 0; 64 | } 65 | //show version information if requested 66 | if (showversion) { 67 | printf(PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n"); 68 | return 0; 69 | } 70 | //check parameters 71 | if (!packageinfopath || !*packageinfopath) { 72 | fprintf(stderr, "Missing -s parameter or BUILDSCRIPTS environment variable\n"); 73 | return 2; 74 | } 75 | if (!check_packageinfo_paths(packageinfopath)) { 76 | fprintf(stderr, "Invalid path(s) specified with -s parameter or BUILDSCRIPTS environment variable: %s\n", packageinfopath); 77 | return 3; 78 | } 79 | //read all package info 80 | if ((packagelist = sorted_unique_list_create(versioncmp, free)) == NULL) { 81 | fprintf(stderr, "Memory allocation error in sorted_unique_list_create()\n"); 82 | return 1; 83 | } 84 | iterate_packages(packageinfopath, packageinfo_callback, packagelist); 85 | //show all package info 86 | n = sorted_unique_list_size(packagelist); 87 | for (i = 0; i < n; i++) { 88 | basename = sorted_unique_list_get(packagelist, i); 89 | if ((pkginfo = read_packageinfo(packageinfopath, basename)) == NULL) { 90 | fprintf(stderr, "Error reading package information for: %s\n", basename); 91 | totalproblems++; 92 | } else { 93 | if (!pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME] || strcmp(basename, pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME]) != 0) { 94 | fprintf(stderr, "Name mismatch for package %s (name in file: %s)\n", basename, (pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME] ? pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME] : "NULL")); 95 | totalproblems++; 96 | } 97 | if (verbose) 98 | printf("%s %s%s\n", pkginfo->datafield[PACKAGE_METADATA_INDEX_BASENAME], pkginfo->datafield[PACKAGE_METADATA_INDEX_VERSION], (pkginfo->buildok ? "" : " (not building)")); 99 | if (pkginfo->buildok) 100 | totalbuilding++; 101 | package_metadata_free(pkginfo); 102 | } 103 | } 104 | //show summary 105 | printf("Total packages: %lu\n", (unsigned long)n); 106 | printf("Total packages than can be built: %lu\n", (unsigned long)totalbuilding); 107 | printf("Total packages with package information problems: %lu\n", (unsigned long)totalproblems); 108 | //clean up 109 | sorted_unique_list_free(packagelist); 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /src/wl-showdeps.c: -------------------------------------------------------------------------------- 1 | #include "winlibs_common.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "pkgfile.h" 7 | #include "sorted_unique_list.h" 8 | #include "filesystem.h" 9 | 10 | #define PROGRAM_NAME "wl-showdeps" 11 | #define PROGRAM_DESC "Command line utility to display package dependency tree" 12 | #define DEPENDANCY_BULLET_MANDATORY '+' 13 | #define DEPENDANCY_BULLET_OPTIONAL '-' 14 | #define DEPENDANCY_BULLET_BUILD '*' 15 | 16 | void show_package_item (const char* packagename, int level, char bullet) 17 | { 18 | printf("%*s%c %s\n", level * 2, "", bullet, packagename); 19 | } 20 | 21 | struct package_list_struct { 22 | const char* packagename; 23 | struct package_list_struct* next; 24 | }; 25 | 26 | void show_package_dependencies (const char* packagename, const char* basepath, const char* packageinfopath, int recursive, int level, char bullet, struct package_list_struct* parent) 27 | { 28 | struct package_metadata_struct* pkginfo; 29 | struct package_list_struct* listitem; 30 | //show information 31 | show_package_item(packagename, level, bullet); 32 | //check for circular dependency 33 | listitem = parent; 34 | while (listitem) { 35 | if (strcmp(packagename, listitem->packagename) == 0) { 36 | printf("%*s^ (circular dependency)\n", (level + 1) * 2, ""); 37 | return; 38 | } 39 | listitem = listitem->next; 40 | } 41 | //get package details and show details 42 | if ((pkginfo = read_packageinfo(packageinfopath, packagename)) == NULL) { 43 | fprintf(stderr, "Error reading package information for: %s\n", packagename); 44 | } else { 45 | unsigned int i; 46 | unsigned int n; 47 | struct package_list_struct current = {packagename, parent}; 48 | //process depenancies 49 | n = sorted_unique_list_size(pkginfo->dependencies); 50 | for (i = 0; i < n; i++) { 51 | if (!recursive) { 52 | show_package_item(sorted_unique_list_get(pkginfo->dependencies, i), level + 1, DEPENDANCY_BULLET_MANDATORY); 53 | } else { 54 | show_package_dependencies(sorted_unique_list_get(pkginfo->dependencies, i), basepath, packageinfopath, recursive, level + 1, DEPENDANCY_BULLET_MANDATORY, ¤t); 55 | } 56 | } 57 | //process optional depenancies 58 | n = sorted_unique_list_size(pkginfo->optionaldependencies); 59 | for (i = 0; i < n; i++) { 60 | if (!recursive) { 61 | show_package_item(sorted_unique_list_get(pkginfo->optionaldependencies, i), level + 1, DEPENDANCY_BULLET_OPTIONAL); 62 | } else { 63 | show_package_dependencies(sorted_unique_list_get(pkginfo->optionaldependencies, i), basepath, packageinfopath, recursive, level + 1, DEPENDANCY_BULLET_OPTIONAL, ¤t); 64 | } 65 | } 66 | //process build depenancies 67 | n = sorted_unique_list_size(pkginfo->builddependencies); 68 | for (i = 0; i < n; i++) { 69 | if (!recursive) { 70 | show_package_item(sorted_unique_list_get(pkginfo->builddependencies, i), level + 1, DEPENDANCY_BULLET_BUILD); 71 | } else { 72 | show_package_dependencies(sorted_unique_list_get(pkginfo->builddependencies, i), basepath, packageinfopath, recursive, level + 1, DEPENDANCY_BULLET_BUILD, ¤t); 73 | } 74 | } 75 | //clean up 76 | package_metadata_free(pkginfo); 77 | } 78 | } 79 | 80 | int main (int argc, char *argv[], char *envp[]) 81 | { 82 | int i; 83 | int showversion = 0; 84 | int showhelp = 0; 85 | const char* basepath = NULL; 86 | const char* packageinfopath = NULL; 87 | int recursive = 0; 88 | //definition of command line arguments 89 | const miniargv_definition argdef[] = { 90 | {'h', "help", NULL, miniargv_cb_increment_int, &showhelp, "show command line help", NULL}, 91 | {0, "version", NULL, miniargv_cb_increment_int, &showversion, "show version information", NULL}, 92 | //{'m', "install-path", "PATH", miniargv_cb_set_const_str, &basepath, "path where to look for already installed packages\noverrides environment variable MINGWPREFIX", NULL}, 93 | {'i', "install-path", "PATH", miniargv_cb_set_const_str, &basepath, "path where packages are installed\noverrides environment variable MINGWPREFIX", NULL}, 94 | {'s', "source-path", "PATH", miniargv_cb_set_const_str, &packageinfopath, "path containing build recipes\noverrides environment variable BUILDSCRIPTS\ncan be multiple paths separated by \"" WINLIBS_CHR2STR(PATHLIST_SEPARATOR) "\"", NULL}, 95 | {'r', "recursive", NULL, miniargv_cb_increment_int, &recursive, "recursive (list dependencies of dependences and so on)", NULL}, 96 | {0, NULL, "PACKAGE", miniargv_cb_error, NULL, "name(s) of package(s) to list dependencies for", NULL}, 97 | MINIARGV_DEFINITION_END 98 | }; 99 | //definition of environment variables 100 | const miniargv_definition envdef[] = { 101 | {0, "MINGWPREFIX", NULL, miniargv_cb_set_const_str, &basepath, "path where packages are installed", NULL}, 102 | {0, "BUILDSCRIPTS", NULL, miniargv_cb_set_const_str, &packageinfopath, "path where to look for build recipes", NULL}, 103 | MINIARGV_DEFINITION_END 104 | }; 105 | //parse environment and command line flags 106 | if (miniargv_process_env(envp, envdef, NULL, NULL) != 0) 107 | return 1; 108 | if (miniargv_process_arg_flags(argv, argdef, NULL, NULL) != 0) 109 | return 1; 110 | //show help if requested or if no command line arguments were given 111 | if (showhelp) { 112 | printf( 113 | PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n" 114 | PROGRAM_DESC "\n" 115 | "Usage: " PROGRAM_NAME " " 116 | ); 117 | miniargv_arg_list(argdef, 1); 118 | printf("\n"); 119 | miniargv_help(argdef, envdef, 24, 0); 120 | #ifdef PORTCOLCON_VERSION 121 | printf(WINLIBS_HELP_COLOR); 122 | #endif 123 | return 0; 124 | } 125 | //show version information if requested 126 | if (showversion) { 127 | printf(PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n"); 128 | return 0; 129 | } 130 | //check parameters 131 | if (!packageinfopath || !*packageinfopath) { 132 | fprintf(stderr, "Missing -s parameter or BUILDSCRIPTS environment variable\n"); 133 | return 2; 134 | } 135 | if (!check_packageinfo_paths(packageinfopath)) { 136 | fprintf(stderr, "Invalid path(s) specified with -s parameter or BUILDSCRIPTS environment variable: %s\n", packageinfopath); 137 | return 3; 138 | } 139 | //process command line argument values 140 | i = 0; 141 | while ((i = miniargv_get_next_arg_param(i, argv, argdef, NULL)) > 0) { 142 | show_package_dependencies(argv[i], basepath, packageinfopath, recursive, 0, DEPENDANCY_BULLET_MANDATORY, NULL); 143 | } 144 | return 0; 145 | } 146 | -------------------------------------------------------------------------------- /src/wl-showstatus.c: -------------------------------------------------------------------------------- 1 | #include "winlibs_common.h" 2 | #include 3 | #include 4 | #include 5 | #ifdef _WIN32 6 | #include 7 | #else 8 | #include 9 | #include 10 | #endif 11 | #include 12 | #include 13 | 14 | #define PROGRAM_NAME "wl-showstatus" 15 | #define PROGRAM_DESC "Command line utility to show status of the winlibs package build process" 16 | 17 | void allocstr_append (char** data, char separator, const char* text) 18 | { 19 | size_t datalen; 20 | char* p; 21 | int dataisnull = (*data == NULL); 22 | if (!text) 23 | return; 24 | datalen = (dataisnull ? 0 : strlen(*data)); 25 | if ((*data = (char*)realloc(*data, datalen + (!dataisnull && separator ? 1 : 0) + strlen(text) + 1)) == NULL) 26 | return; 27 | p = *data + datalen; 28 | if (!dataisnull && separator) 29 | *(p++) = separator; 30 | strcpy(p, text); 31 | } 32 | 33 | int process_arg_append_str (const miniargv_definition* argdef, const char* value, void* callbackdata) 34 | { 35 | allocstr_append((char**)argdef->userdata, ' ', value); 36 | return 0; 37 | } 38 | 39 | int main (int argc, char *argv[], char *envp[]) 40 | { 41 | char* s; 42 | int showversion = 0; 43 | int showhelp = 0; 44 | int showpackageversion = 0; 45 | const char* basename = NULL; 46 | const char* version = NULL; 47 | char* title = NULL; 48 | char* message = NULL; 49 | //definition of command line arguments 50 | const miniargv_definition argdef[] = { 51 | {'h', "help", NULL, miniargv_cb_increment_int, &showhelp, "show command line help", NULL}, 52 | {0, "version", NULL, miniargv_cb_increment_int, &showversion, "show version information", NULL}, 53 | {'v', "package-version", NULL, miniargv_cb_increment_int, &showpackageversion, "show package name and version (from environment variables)", NULL}, 54 | {0, NULL, "TEXT", process_arg_append_str, &message, "text to display", NULL}, 55 | MINIARGV_DEFINITION_END 56 | }; 57 | //definition of environment variables 58 | const miniargv_definition envdef[] = { 59 | {0, "BASENAME", NULL, miniargv_cb_set_const_str, &basename, "package name\nif present will be displayed as part of the window title", NULL}, 60 | {0, "VERSION", NULL, miniargv_cb_set_const_str, &version, "package version\nif present will be displayed as part of the window title", NULL}, 61 | MINIARGV_DEFINITION_END 62 | }; 63 | //parse environment and command line flags 64 | if (miniargv_process(argv, envp, argdef, envdef, NULL, NULL) != 0) 65 | return 1; 66 | //show help if requested or if no command line arguments were given 67 | if (showhelp || argc <= 1) { 68 | printf( 69 | PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n" 70 | PROGRAM_DESC "\n" 71 | "Usage: " PROGRAM_NAME " " 72 | ); 73 | miniargv_arg_list(argdef, 1); 74 | printf("\n"); 75 | miniargv_help(argdef, envdef, 20, 0); 76 | #ifdef PORTCOLCON_VERSION 77 | printf(WINLIBS_HELP_COLOR); 78 | #endif 79 | return 0; 80 | } 81 | //show version information if requested 82 | if (showversion) { 83 | printf(PROGRAM_NAME " - version " WINLIBS_VERSION_STRING " - " WINLIBS_LICENSE " - " WINLIBS_CREDITS "\n"); 84 | return 0; 85 | } 86 | //determine which text to show 87 | if (showpackageversion) { 88 | //show package name and version number 89 | if (message) { 90 | fprintf(stderr, "No other command line parameters allowed when showing package version.\n"); 91 | return 2; 92 | } 93 | if (basename) 94 | allocstr_append(&message, ' ', basename); 95 | if (version) 96 | allocstr_append(&message, ' ', version); 97 | //use message as basis for window title 98 | if (message) 99 | title = strdup(message); 100 | } else { 101 | //use message as basis for window title 102 | if (message) 103 | title = strdup(message); 104 | //add package name and version to window title 105 | if (basename) 106 | allocstr_append(&title, ' ', basename); 107 | if (version) 108 | allocstr_append(&title, ' ', version); 109 | } 110 | //add current path to window title 111 | if ((s = portcolcon_getcurdir()) != NULL) { 112 | allocstr_append(&title, ' ', s); 113 | portcolcon_free_string(s); 114 | } 115 | //output 116 | portcolconhandle con = portcolcon_initialize(); 117 | portcolcon_write_in_color(con, "-=[", PORTCOLCON_COLOR_DARK_GRAY, PORTCOLCON_COLOR_BLACK); 118 | portcolcon_printf_in_color(con, PORTCOLCON_COLOR_YELLOW, PORTCOLCON_COLOR_BLACK, " %s ", (message ? message : "")); 119 | portcolcon_write_in_color(con, "]=-", PORTCOLCON_COLOR_DARK_GRAY, PORTCOLCON_COLOR_BLACK); 120 | portcolcon_write(con, "\n"); 121 | portcolcon_set_title(con, (title ? title : "")); 122 | portcolcon_cleanup(con); 123 | //clean up 124 | free(message); 125 | free(title); 126 | return 0; 127 | } 128 | 129 | --------------------------------------------------------------------------------