├── .gitattributes ├── .gitignore ├── .vscode └── settings.json ├── AUTHORS.txt ├── CHANGES.txt ├── CMakeLists.txt ├── FAQ.txt ├── HISTORY.txt ├── INSTALL.txt ├── KNOWN_ISSUES.txt ├── LICENSE ├── LICENSE.txt ├── NEWS.txt ├── README.md ├── README.txt ├── TODO.md ├── build ├── gcc295 │ └── makefile ├── gcc32 │ └── makefile ├── gcc33 │ └── makefile ├── gcc34 │ └── makefile ├── gcc49 │ └── makefile ├── gcc81 │ └── makefile ├── ow15 │ └── makefile ├── ow16 │ └── makefile ├── ow17 │ └── makefile ├── vc10.x64 │ └── makefile ├── vc10 │ └── makefile ├── vc11.x64 │ └── makefile ├── vc11 │ └── makefile ├── vc12.x64 │ └── makefile ├── vc12 │ └── makefile ├── vc14.x64 │ └── makefile ├── vc14 │ └── makefile ├── vc15.x64 │ └── makefile ├── vc15 │ └── makefile ├── vc16.x64 │ └── makefile ├── vc16 │ └── makefile ├── vc6 │ └── makefile ├── vc7 │ ├── makefile │ └── unixem.vcproj ├── vc8.x64 │ └── makefile ├── vc9.x64 │ └── makefile └── vecc │ └── makefile ├── build_cmake.sh ├── clean_cmake.sh ├── cmake ├── BuildType.cmake ├── LanguageFullVersion.cmake ├── TargetMacros.cmake └── unixem-config.cmake.in ├── examples └── CMakeLists.txt ├── include ├── arpa │ └── inet.h ├── asm │ └── atomic.h ├── dirent.h ├── dlfcn.h ├── glob.h ├── netinet │ └── in.h ├── sys │ ├── mman.h │ ├── resource.h │ ├── socket.h │ ├── time.h │ └── uio.h ├── unistd.h └── unixem │ ├── arpa │ └── inet.h │ ├── asm │ └── atomic.h │ ├── dirent.h │ ├── dlfcn.h │ ├── glob.h │ ├── implicit_link.h │ ├── internal │ ├── safestr.h │ ├── stdint.h │ ├── util.h │ └── winsock.h │ ├── netinet │ └── in.h │ ├── setenv.h │ ├── sys │ ├── mman.h │ ├── resource.h │ ├── socket.h │ ├── time.h │ └── uio.h │ ├── time.h │ ├── unistd.h │ ├── unixem.h │ └── util │ ├── fs.h │ └── str.h ├── prepare_cmake.sh ├── projects ├── core │ ├── vc10 │ │ ├── unixem.core.vcxproj │ │ └── unixem.core.vcxproj.filters │ └── vc6 │ │ └── unixem.core.dsp └── vcprops │ └── unixem.common.props ├── remove_cmake_artefacts.sh ├── run_all_examples.sh ├── run_all_scratch_tests.sh ├── run_all_unit_tests.sh ├── src ├── CMakeLists.txt ├── atomic.c ├── dirent.c ├── dlfcn.c ├── glob.c ├── hostname.c ├── internal │ └── util.c ├── mktemp.c ├── mmap.c ├── resource.c ├── setenv.c ├── time.c ├── uio.c ├── unistd.c ├── util_fs.c └── util_str.c ├── test ├── CMakeLists.txt ├── component │ ├── CMakeLists.txt │ ├── test.component.dirent │ │ ├── CMakeLists.txt │ │ └── entry.cpp │ ├── test.component.glob │ │ ├── CMakeLists.txt │ │ ├── entry.cpp │ │ ├── implicit_link.cpp │ │ └── vc6 │ │ │ └── test.component.glob.dsp │ ├── test.component.unistd.mkdtemp │ │ ├── CMakeLists.txt │ │ ├── entry.c │ │ ├── implicit_link.c │ │ └── vc6 │ │ │ └── test.component.unistd.mkdtemp.dsp │ ├── test.component.unistd.mkstemp │ │ ├── CMakeLists.txt │ │ ├── entry.c │ │ ├── implicit_link.c │ │ └── vc6 │ │ │ └── test.component.unistd.mkstemp.dsp │ └── test.component.unistd.usleep │ │ ├── CMakeLists.txt │ │ └── entry.cpp ├── scratch │ ├── CMakeLists.txt │ ├── test.scratch.dlfcn │ │ ├── CMakeLists.txt │ │ ├── test.scratch.dlfcn.c │ │ └── vc6 │ │ │ └── test.scratch.dlfcn.dsp │ ├── test.scratch.fnmatch │ │ ├── CMakeLists.txt │ │ ├── test.scratch.fnmatch.c │ │ └── vc6 │ │ │ └── test.scratch.fnmatch.dsp │ ├── test.scratch.getrusage │ │ ├── CMakeLists.txt │ │ ├── test.scratch.getrusage.c │ │ └── vc6 │ │ │ └── test.scratch.getrusage.dsp │ ├── test.scratch.link │ │ ├── CMakeLists.txt │ │ ├── test.scratch.link.c │ │ └── vc6 │ │ │ └── test.scratch.link.dsp │ ├── test.scratch.mmap │ │ ├── CMakeLists.txt │ │ ├── test.scratch.mmap.c │ │ └── vc6 │ │ │ └── test.scratch.mmap.dsp │ ├── test.scratch.setenv │ │ ├── CMakeLists.txt │ │ ├── test.scratch.setenv.c │ │ ├── vc10 │ │ │ ├── test.scratch.setenv.vcxproj │ │ │ └── test.scratch.setenv.vcxproj.filters │ │ └── vc6 │ │ │ └── test.scratch.setenv.dsp │ ├── test.scratch.syslog │ │ ├── CMakeLists.txt │ │ ├── test.scratch.syslog.c │ │ └── vc6 │ │ │ └── test.scratch.syslog.dsp │ └── test.scratch.uio │ │ ├── CMakeLists.txt │ │ ├── test.scratch.uio.c │ │ └── vc6 │ │ └── test.scratch.uio.dsp └── unit │ ├── CMakeLists.txt │ ├── test.unit.unistd.gethostname │ ├── CMakeLists.txt │ ├── entry.c │ ├── implicit_link.c │ └── vc6 │ │ └── test.unit.unistd.gethostname.dsp │ ├── test.unit.unistd.getpid │ ├── CMakeLists.txt │ ├── entry.c │ └── vc10 │ │ ├── test.unit.unistd.getpid.vcxproj │ │ └── test.unit.unistd.getpid.vcxproj.filters │ ├── test.unit.unistd.pathconf │ ├── CMakeLists.txt │ └── entry.c │ ├── test.unit.util.fs │ ├── CMakeLists.txt │ └── entry.cpp │ └── test.unit.util.str │ ├── CMakeLists.txt │ └── entry.c ├── unixem.vc10.sln └── unixem.vc6.dsw /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c linguist-language=C 2 | *.h linguist-language=C 3 | *.cpp linguist-language=C++ 4 | *.hpp linguist-language=C++ 5 | *.html linguist-detectable=false 6 | *.sh linguist-detectable=false 7 | makefile linguist-detectable=false 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # directories (by name) 3 | 4 | /_build/ 5 | 6 | include/b64/ 7 | include/shwild/ 8 | include/xcontract/ 9 | include/xcover/ 10 | include/xtests/ 11 | 12 | src/b64/ 13 | src/shwild/ 14 | src/xcontract/ 15 | src/xcover/ 16 | src/xtests/ 17 | 18 | vc71/ 19 | vc8/ 20 | vc9/ 21 | 22 | ideas/ 23 | 24 | bin/ 25 | 26 | lib/ 27 | 28 | ipch/ 29 | 30 | Win32/ 31 | x64/ 32 | 33 | Debug/ 34 | Debug Multithreaded/ 35 | Debug Multithreaded DLL/ 36 | Unicode Debug/ 37 | Unicode Debug Multithreaded/ 38 | Unicode Debug Multithreaded DLL/ 39 | Release/ 40 | Release Multithreaded/ 41 | Release Multithreaded DLL/ 42 | Unicode Release/ 43 | Unicode Release Multithreaded/ 44 | Unicode Release Multithreaded DLL/ 45 | 46 | DebugMTUnix/ 47 | DebugUnix/ 48 | ReleaseMTUnix/ 49 | ReleaseUnix/ 50 | 51 | 52 | # directories (by pattern) 53 | 54 | 55 | # files (by name) 56 | 57 | list_changes.cmd 58 | 59 | build/makefile.tmpl 60 | build/makefile.tools.xml 61 | 62 | include/fastformat/internal/dos2unix.has.been.performed 63 | 64 | test/tests-plan.txt 65 | 66 | 67 | # files (by pattern) 68 | 69 | *~ 70 | *.a 71 | *.app 72 | *.dll 73 | *.dylib 74 | *.exe 75 | *.gch 76 | *.ilk 77 | *.lib 78 | *.ncb 79 | *.o 80 | *.obj 81 | *.opensdf 82 | *.opt 83 | *.org 84 | *.out 85 | *.pch 86 | *.pdb 87 | *.sdf 88 | *.sbr 89 | *.scc 90 | *.so 91 | *.suo 92 | *.swp 93 | *.vcproj*.user 94 | *.vcxproj*.user 95 | 96 | *.vc71.sln 97 | *.vc8.sln 98 | *.vc9.sln 99 | 100 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[bat]": { 3 | "editor.insertSpaces": true, 4 | "editor.rulers": [ 60, 76 ], 5 | "editor.tabSize": 4, 6 | }, 7 | "[c]": { 8 | "editor.insertSpaces": true, 9 | "editor.rulers": [ 60, 76 ], 10 | "editor.tabSize": 4, 11 | }, 12 | "[cpp]": { 13 | "editor.insertSpaces": true, 14 | "editor.rulers": [ 60, 64, 68, 76 ], 15 | "editor.tabSize": 4, 16 | }, 17 | "[cmake]": { 18 | "editor.insertSpaces": false, 19 | "editor.tabSize": 4, 20 | }, 21 | "[json]": { 22 | "editor.insertSpaces": true, 23 | "editor.tabSize": 2, 24 | }, 25 | "[markdown]": { 26 | "editor.insertSpaces": true, 27 | "editor.tabSize": 2, 28 | }, 29 | "[ruby]": { 30 | "editor.insertSpaces": true, 31 | "editor.tabSize": 2, 32 | }, 33 | "[shellscript]": { 34 | "editor.insertSpaces": true, 35 | "editor.rulers": [ 60, 76 ], 36 | "editor.tabSize": 2, 37 | }, 38 | "cmake.configureOnOpen": false, 39 | "editor.detectIndentation": false, 40 | "editor.insertSpaces": false, 41 | "editor.renderWhitespace" : "all", 42 | "editor.rulers": [ 76 ], 43 | "editor.tabSize": 2, 44 | "files.associations": { 45 | "__bit_reference": "cpp", 46 | "__bits": "cpp", 47 | "__config": "cpp", 48 | "__debug": "cpp", 49 | "__errc": "cpp", 50 | "__functional_03": "cpp", 51 | "__functional_base": "cpp", 52 | "__hash_table": "cpp", 53 | "__locale": "cpp", 54 | "__memory": "cpp", 55 | "__mutex_base": "cpp", 56 | "__node_handle": "cpp", 57 | "__nullptr": "cpp", 58 | "__split_buffer": "cpp", 59 | "__string": "cpp", 60 | "__threading_support": "cpp", 61 | "__tree": "cpp", 62 | "__tuple": "cpp", 63 | "__verbose_abort": "cpp", 64 | "algorithm": "cpp", 65 | "array": "cpp", 66 | "atomic": "cpp", 67 | "bit": "cpp", 68 | "bitset": "cpp", 69 | "cctype": "cpp", 70 | "charconv": "cpp", 71 | "chrono": "cpp", 72 | "clocale": "cpp", 73 | "cmath": "cpp", 74 | "compare": "cpp", 75 | "complex": "cpp", 76 | "concepts": "cpp", 77 | "corecrt.h": "c", 78 | "crtdefs.h": "c", 79 | "cstdarg": "cpp", 80 | "cstddef": "cpp", 81 | "cstdint": "cpp", 82 | "cstdio": "cpp", 83 | "cstdlib": "cpp", 84 | "cstring": "cpp", 85 | "ctime": "cpp", 86 | "cwchar": "cpp", 87 | "cwctype": "cpp", 88 | "deque": "cpp", 89 | "exception": "cpp", 90 | "execution": "cpp", 91 | "fcntl.h": "c", 92 | "format": "cpp", 93 | "functional": "cpp", 94 | "implicit_link.h": "c", 95 | "initializer_list": "cpp", 96 | "io.h": "c", 97 | "iomanip": "cpp", 98 | "ios": "cpp", 99 | "iosfwd": "cpp", 100 | "iostream": "cpp", 101 | "istream": "cpp", 102 | "iterator": "cpp", 103 | "limits": "cpp", 104 | "list": "cpp", 105 | "locale": "cpp", 106 | "map": "cpp", 107 | "memory": "cpp", 108 | "memory_resource": "cpp", 109 | "mutex": "cpp", 110 | "new": "cpp", 111 | "numeric": "cpp", 112 | "optional": "cpp", 113 | "ostream": "cpp", 114 | "queue": "cpp", 115 | "ratio": "cpp", 116 | "set": "cpp", 117 | "setenv.h": "c", 118 | "sstream": "cpp", 119 | "stack": "cpp", 120 | "stdexcept": "cpp", 121 | "streambuf": "cpp", 122 | "string": "cpp", 123 | "string_view": "cpp", 124 | "system_error": "cpp", 125 | "thread": "cpp", 126 | "tuple": "cpp", 127 | "type_traits": "cpp", 128 | "typeinfo": "cpp", 129 | "uio.h": "c", 130 | "unixem.h": "c", 131 | "unordered_map": "cpp", 132 | "util.h": "c", 133 | "utility": "cpp", 134 | "variant": "cpp", 135 | "vector": "cpp", 136 | "xfacet": "cpp", 137 | "xiosbase": "cpp", 138 | "xlocale": "cpp", 139 | "xlocbuf": "cpp", 140 | "xlocinfo": "cpp", 141 | "xlocmes": "cpp", 142 | "xlocmon": "cpp", 143 | "xlocnum": "cpp", 144 | "xloctime": "cpp", 145 | "xmemory": "cpp", 146 | "xstring": "cpp", 147 | "xtr1common": "cpp", 148 | "xtree": "cpp", 149 | "xutility": "cpp", 150 | }, 151 | "files.insertFinalNewline": true, 152 | "files.trimTrailingWhitespace": true, 153 | } 154 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | UNIXem - Authors 2 | ================ 3 | 4 | Updated: 19th May 2025 5 | 6 | 7 | Authors: 8 | 9 | Matthew Wilson 10 | 11 | 12 | Bug reports, fixes, questions, requests and suggestions (for which we are 13 | very grateful): 14 | 15 | chen1088 - merge request assistance 16 | Marc Treib - gettimeofday() return type 17 | Mikko Koivunalho - CMake support 18 | Paulo Custodio - fixing syntax errors in header(s) 19 | zydxhs - project documentation 20 | 21 | 22 | Contributions are welcomed. 23 | 24 | =============================== end of file ================================ 25 | 26 | -------------------------------------------------------------------------------- /FAQ.txt: -------------------------------------------------------------------------------- 1 | UNIXem - FAQ 2 | ============ 3 | 4 | Updated: 14th October 2019 5 | 6 | 7 | 8 | The FAQ list is under (constant) development. If you post a question on the 9 | STLSoft newsgroup (http://www.digitalmars.com/webnews/newsgroups.php?search_txt=&group=c%2B%2B.stlsoft) 10 | it will be used to create one. 11 | 12 | FAQs: 13 | ===== 14 | 15 | Q1: "What happens if the I ask a question on the forum?" [20th February 2008] 16 | 17 | A1: 18 | It'll be added to the FAQ. 19 | 20 | =============================== end of file ================================ 21 | 22 | -------------------------------------------------------------------------------- /INSTALL.txt: -------------------------------------------------------------------------------- 1 | UNIXem - Install 2 | ================ 3 | 4 | Updated: 17th December 2020 5 | 6 | 7 | 8 | UNIXem requires manual installation, by copying files after building, 9 | as described in the accompanying doc/html/1.12.6/index.html file. 10 | 11 | =============================== end of file ================================ 12 | 13 | -------------------------------------------------------------------------------- /KNOWN_ISSUES.txt: -------------------------------------------------------------------------------- 1 | UNIXem - Known Issues 2 | ===================== 3 | 4 | Updated: 14th October 2019 5 | 6 | 7 | 8 | UNIXem 1.12 Known Issues: 9 | ------------------------- 10 | 11 | 12 | 13 | 14 | UNIXem 1.12 Suspected Issues: 15 | ----------------------------- 16 | 17 | 18 | 19 | =============================== end of file ================================ 20 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2015, Matthew Wilson and Synesis Software 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name(s) of UNIXem, Matthew Wilson, Synesis Software nor the 13 | names of any contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | UNIXem - License 2 | ================ 3 | 4 | Updated: 17th December 2020 5 | 6 | 7 | 8 | UNIXem uses the BSD-form license, as described in the accompanying 9 | doc/html/1.12.6/index.html file. 10 | 11 | =============================== end of file ================================ 12 | 13 | -------------------------------------------------------------------------------- /NEWS.txt: -------------------------------------------------------------------------------- 1 | UNIXem - News 2 | ============= 3 | 4 | Updated: 1st May 2025 5 | 6 | 7 | 8 | News: 9 | 10 | 19th May 2025 - UNIXem 1.12.8 released 11 | 12 | 1st May 2025 - UNIXem 1.12.7 released 13 | 14 | 17th Dec 2020 - UNIXem 1.12.6 released 15 | 16 | 19th Jul 2020 - UNIXem 1.12.5 released 17 | 18 | 19th Jul 2020 - UNIXem 1.12.4 released 19 | 20 | 14th Oct 2019 - UNIXem 1.12.3 released 21 | 22 | 14th Oct 2019 - UNIXem 1.12.2 released 23 | 24 | 9th Oct 2019 - UNIXem 1.11.4 released 25 | 26 | 2nd Jan 2017 - UNIXem 1.11.2 released 27 | 28 | 7th Oct 2015 - UNIXem 1.11.1 released 29 | 30 | 25th Sep 2015 - UNIXem 1.10.2 released 31 | 32 | 30th Jul 2015 - UNIXem 1.10.1 released 33 | 34 | 16th Jun 2012 - UNIXem 1.9.3 released 35 | 36 | 4th Feb 2011 - UNIXem 1.9.2 released 37 | 38 | 13th Aug 2010 - UNIXem 1.9.1 released 39 | 40 | 13th Aug 2010 - UNIXem 1.8.5 released 41 | 42 | 4th Apr 2010 - UNIXem 1.8.4 released 43 | 44 | 6th Feb 2010 - UNIXem 1.8.3 released 45 | 46 | 13th May 2008 - UNIXem 1.8.2 released 47 | 48 | 22nd Apr 2008 - UNIXem 1.8.1 released 49 | 50 | 20th Apr 2008 - UNIXem 1.7.5 released 51 | 52 | 24th Feb 2008 - UNIXem 1.7.4 released 53 | 54 | 12th Mar 2007 - UNIXem 1.7.3 released 55 | 56 | 12th Sep 2006 - UNIXem 1.7.2 released 57 | 58 | 3rd Sep 2006 - UNIXem 1.7.1 released 59 | 60 | 12th Aug 2006 - UNIXem 1.5.2 released 61 | 62 | 21st Sep 2005 - UNIXem 1.5.1 released 63 | 64 | 19th Jun 2005 - UNIXem 1.5.3 released 65 | 66 | 23rd May 2005 - UNIXem 1.5.2 released 67 | 68 | 17th Feb 2005 - UNIXem 1.5.1 released 69 | 70 | 29th Jun 2004 - UNIXem 1.4 released 71 | 72 | 16th Jun 2004 - UNIXem 1.3 released 73 | 74 | 3rd Jan 2004 - UNIXem 1.2 released 75 | 76 | 2nd Nov 2003 - UNIXem 1.1 released 77 | 78 | 2nd Feb 2003 - UNIXem 1.0 released 79 | 80 | =============================== end of file ================================ 81 | 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UNIXem 2 | **Unix**-**em**ulation, for Windows 3 | 4 | ## Table of Contents 5 | 6 | 1. [Introduction](#introduction) 7 | 2. [Installation](#installation) 8 | 3. [Components](#components) 9 | 4. [Examples](#examples) 10 | 5. [Project Information](#project-information) 11 | 12 | ## Introduction 13 | 14 | **UNIXem** is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code. 15 | 16 | ## Installation 17 | 18 | T.B.C. 19 | 20 | ## Components 21 | 22 | API functions include: 23 | 24 | - ``opendir()``, ``readdir()``, ``rewinddir()``, ``closedir()``; 25 | - ``glob()``, ``globfree()``; 26 | - ``readv()``, ``writev()``; 27 | - ``pathconf()``; 28 | - ``realpath()``; 29 | - ``mmap()``, ``munmap()``, ``msync()``; 30 | - ``dlopen()``, ``dlclose()``, ``dlsym()``, ``dlerror()``; 31 | - ``gettimeofday()``; 32 | - ``getpagesize()``; 33 | - ``mkdtemp()``, ``mkstemp()``; 34 | - ``mkdir()``, ``rmdir()``; 35 | - ``getcwd()``; 36 | - ``getpid()``; 37 | - ``gethostname()``; 38 | - ``usleep()``; 39 | - ``getrusage()``; 40 | - ``setenv()``, ``unsetenv()``; 41 | - ``link()``, ``unlink()``; 42 | - ``timegm()``; 43 | 44 | ## Examples 45 | 46 | T.B.C. 47 | 48 | ## Project Information 49 | 50 | ### Where to get help 51 | 52 | [GitHub Page](https://github.com/synesissoftware/UNIXem "GitHub Page") 53 | 54 | ### Contribution guidelines 55 | 56 | Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/UNIXem. 57 | 58 | ### Related projects 59 | 60 | **UNIXem** is used by a number of C/C++ libraries for compilation/linking/testing on Windows, including: 61 | 62 | * [**FastFormat**](https://github.com/synesissoftware/FastFormat/) 63 | * [**Pantheios**](https://github.com/synesissoftware/Pantheios/) 64 | * [**recls**](https://github.com/synesissoftware/recls/) 65 | 66 | ### License 67 | 68 | **UNIXem** is released under the 3-clause BSD license. See LICENSE for details. 69 | 70 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | UNIXem - README 2 | =============== 3 | 4 | Updated: 17th December 2020 5 | 6 | 7 | 8 | See the introduction in the accompanying doc/html/1.12.6/index.html file. 9 | 10 | =============================== end of file ================================ 11 | 12 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # UNIXem - TODO 2 | 3 | Updated: 12th May 2025 4 | 5 | 6 | ## UNIXem 1.12 TODOs: 7 | 8 | * [x] CMake 9 | * [ ] Refactor file-system utilities into separate API functions; 10 | * [ ] Greater unit-testing coverage; 11 | * [ ] Ensure unit-tests (and scratch-tests) do memory checking; 12 | * [ ] Remove Visual Studio project/solution files; 13 | * [ ] Component test(s) for link; 14 | * [ ] Standardise project boilerplate files (to .md); 15 | * [ ] CMake optional dependencies all marked OFF in CMakeListst.txt; 16 | 17 | 18 | ## UNIXem 1.13 TODOs: 19 | 20 | * [ ] `stpcpy()`, etc.; 21 | * [ ] `glob()` - expand functionality and flags coverage: 22 | * [ ] Proper handling of `errfunc` + `GLOB_ERR`; 23 | * [ ] Support `GLOB_APPEND`; 24 | * [ ] Unit-test `GLOB_MARK`; 25 | * [x] Cause order to be random when `GLOB_NOSORT`; 26 | * [ ] Reimplement in terms of `stpcpy()` (etc.); 27 | * [ ] Verify `GLOB_DOOFFS` handled correctly (esp. wrt `gl_matchc` and `gl_pathc`); 28 | * [ ] Implement escaping (and `UNIXEM_GLOB_NOESCAPE`); 29 | * [ ] Consider full implementation of tilde (i.e. other users' home directories); 30 | * [ ] ; 31 | * ; 32 | 33 | 34 | ## UNIXem 1.14 TODOs: 35 | 36 | * [ ] All Windows System calls use wide-string form, and translate to UTF-8 internally; 37 | * ; 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /build/vc7/unixem.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 20 | 37 | 39 | 43 | 45 | 47 | 49 | 51 | 55 | 57 | 58 | 65 | 81 | 83 | 87 | 89 | 91 | 93 | 95 | 99 | 101 | 102 | 103 | 104 | 107 | 109 | 110 | 112 | 113 | 115 | 116 | 118 | 119 | 120 | 123 | 125 | 126 | 128 | 129 | 131 | 132 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /build/vecc/makefile: -------------------------------------------------------------------------------- 1 | 2 | # Updated: 15th August 2004 3 | 4 | CC = vectorc86 5 | CPPC = vectorc86 6 | AR = lib 7 | 8 | UNIXEM_INC_DIR = ..\..\include 9 | UNIXEM_LIB_DIR = ..\..\lib 10 | UNIXEM_OBJ_DIR = . 11 | UNIXEM_SRC_DIR = ..\..\src 12 | CMP_ID = vecc 13 | 14 | CC_ARGS = -nologo 15 | 16 | CPPC_ARGS = -nologo 17 | 18 | UNIXEM_LIB = $(UNIXEM_LIB_DIR)\unixem.$(CMP_ID).lib 19 | 20 | 21 | OBJS_DEBUG = \ 22 | $(UNIXEM_OBJ_DIR)\atomic.obj \ 23 | $(UNIXEM_OBJ_DIR)\dirent.obj \ 24 | $(UNIXEM_OBJ_DIR)\dlfcn.obj \ 25 | $(UNIXEM_OBJ_DIR)\glob.obj \ 26 | $(UNIXEM_OBJ_DIR)\mmap.obj \ 27 | $(UNIXEM_OBJ_DIR)\time.obj \ 28 | $(UNIXEM_OBJ_DIR)\unistd.obj \ 29 | \ 30 | 31 | 32 | OBJS_RELEASE = \ 33 | 34 | 35 | # rules 36 | 37 | {$(UNIXEM_SRC_DIR)}.cpp{$(UNIXEM_OBJ_DIR)}.obj: 38 | $(CPPC) $(CPPC_ARGS) -include $(UNIXEM_INC_DIR) -outfile $@ $< 39 | 40 | {$(UNIXEM_SRC_DIR)}.c{$(UNIXEM_OBJ_DIR)}.obj: 41 | $(CC) $(CC_ARGS) -include $(UNIXEM_INC_DIR) -outfile $@ $< 42 | 43 | # targets 44 | 45 | target: \ 46 | $(UNIXEM_LIB) \ 47 | \ 48 | 49 | 50 | clean: 51 | @-if exist $(UNIXEM_OBJ_DIR)\*.obj del $(UNIXEM_OBJ_DIR)\*.obj 52 | @-if exist $(UNIXEM_LIB) del $(UNIXEM_LIB) 53 | 54 | 55 | $(UNIXEM_LIB): $(OBJS_DEBUG) 56 | $(AR) -out:$@ -nologo $(OBJS_DEBUG) 57 | -------------------------------------------------------------------------------- /build_cmake.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ScriptPath=$0 4 | Dir=$(cd $(dirname "$ScriptPath"); pwd) 5 | Basename=$(basename "$ScriptPath") 6 | CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build} 7 | MakeCmd=${SIS_CMAKE_COMMAND:-make} 8 | 9 | IgnoreRemainingFlagsAndOptions=0 10 | Targets=() 11 | 12 | 13 | # ########################################################## 14 | # functions 15 | 16 | function join_by { local IFS="$1"; shift; echo "$*"; } 17 | 18 | 19 | # ########################################################## 20 | # command-line handling 21 | 22 | while [[ $# -gt 0 ]]; do 23 | 24 | if [ $IgnoreRemainingFlagsAndOptions -ne 0 ]; then 25 | 26 | Targets+=($1) 27 | 28 | shift 29 | 30 | continue 31 | else 32 | 33 | if [ ! ${1:0:1} = '-' ]; then 34 | 35 | Targets+=($1) 36 | 37 | shift 38 | 39 | continue 40 | fi 41 | fi 42 | 43 | case $1 in 44 | --) 45 | 46 | IgnoreRemainingFlagsAndOptions=1 47 | ;; 48 | --help) 49 | 50 | cat << EOF 51 | UNIXem is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code 52 | Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 53 | Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 54 | Executes CMake-generated artefacts to (re)build project 55 | 56 | $ScriptPath [ ... flags/options ... ] 57 | 58 | Flags/options: 59 | 60 | behaviour: 61 | 62 | 63 | standard flags: 64 | 65 | --help 66 | displays this help and terminates 67 | 68 | EOF 69 | 70 | exit 0 71 | ;; 72 | *) 73 | 74 | >&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage" 75 | 76 | exit 1 77 | ;; 78 | esac 79 | 80 | shift 81 | done 82 | 83 | 84 | # ########################################################## 85 | # main() 86 | 87 | if [ ! -d "$CMakeDir" ]; then 88 | 89 | >&2 echo "$ScriptPath: CMake build directory '$CMakeDir' not found so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts" 90 | 91 | exit 1 92 | else 93 | 94 | cd $CMakeDir 95 | 96 | if [ ! -f "$CMakeDir/Makefile" ]; then 97 | 98 | >&2 echo "$ScriptPath: CMake build directory '$CMakeDir' does not contain expected file 'Makefile', so a clean cannot be performed. It is recommended that you remove all CMake artefacts using script 'remove_cmake_artefacts.sh' followed by regeneration via 'prepare_cmake.sh'" 99 | 100 | cd ->/dev/null 101 | 102 | exit 1 103 | else 104 | 105 | if [ -z "$Targets" ]; then 106 | 107 | echo "Executing build (via command \`$MakeCmd\`)" 108 | else 109 | 110 | echo "Executing build (via command \`$MakeCmd\`) with specific target(s) $(join_by , "${Targets[@]}")" 111 | fi 112 | 113 | $MakeCmd ${Targets[*]} 114 | status=$? 115 | 116 | cd ->/dev/null 117 | 118 | exit $status 119 | fi 120 | fi 121 | 122 | 123 | # ############################## end of file ############################# # 124 | 125 | -------------------------------------------------------------------------------- /clean_cmake.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ScriptPath=$0 4 | Dir=$(cd $(dirname "$ScriptPath"); pwd) 5 | Basename=$(basename "$ScriptPath") 6 | CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build} 7 | MakeCmd=${SIS_CMAKE_COMMAND:-make} 8 | 9 | 10 | # ########################################################## 11 | # command-line handling 12 | 13 | while [[ $# -gt 0 ]]; do 14 | 15 | case $1 in 16 | --help) 17 | 18 | cat << EOF 19 | UNIXem is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code 20 | Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 21 | Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 22 | Executes CMake-generated artefacts to clean project 23 | 24 | $ScriptPath [ ... flags/options ... ] 25 | 26 | Flags/options: 27 | 28 | behaviour: 29 | 30 | 31 | standard flags: 32 | 33 | --help 34 | displays this help and terminates 35 | 36 | EOF 37 | 38 | exit 0 39 | ;; 40 | *) 41 | 42 | >&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage" 43 | 44 | exit 1 45 | ;; 46 | esac 47 | 48 | shift 49 | done 50 | 51 | 52 | # ########################################################## 53 | # main() 54 | 55 | if [ ! -d "$CMakeDir" ]; then 56 | 57 | >&2 echo "$ScriptPath: CMake build directory '$CMakeDir' not found so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts" 58 | 59 | exit 1 60 | else 61 | 62 | cd $CMakeDir 63 | 64 | if [ ! -f "$CMakeDir/Makefile" ]; then 65 | 66 | >&2 echo "$ScriptPath: CMake build directory '$CMakeDir' does not contain expected file 'Makefile', so a clean cannot be performed. It is recommended that you remove all CMake artefacts using script 'remove_cmake_artefacts.sh' followed by regeneration via 'prepare_cmake.sh'" 67 | 68 | cd ->/dev/null 69 | 70 | exit 1 71 | else 72 | 73 | echo "Cleaning build (via command \`$MakeCmd clean\`)" 74 | 75 | $MakeCmd clean 76 | status=$? 77 | 78 | cd ->/dev/null 79 | 80 | exit $status 81 | fi 82 | fi 83 | 84 | 85 | # ############################## end of file ############################# # 86 | 87 | -------------------------------------------------------------------------------- /cmake/BuildType.cmake: -------------------------------------------------------------------------------- 1 | 2 | # ######################################################################## # 3 | # File: /cmake/BuildType.cmake 4 | # 5 | # Purpose: CMake module file (for BuildType) 6 | # 7 | # Created: 16th October 2019 8 | # Updated: 21st January 2024 9 | # 10 | # ######################################################################## # 11 | 12 | 13 | # Including this module sets the `CMAKE_BUILD_TYPE` value as follows: 14 | # 15 | # 1. If user specifies on the command line, then `CMAKE_BUILD_TYPE` already 16 | # has a valid, so this is accepted; 17 | # 2. If the top-level .git directory is specified, then "Debug" is used; 18 | # otherwise 19 | # 3. "Release" is used. 20 | # 21 | # Note: 22 | # - `CMAKE_BUILD_TYPE` is the build (configuration) type; 23 | # - `CMAKE_CONFIGURATION_TYPES` is, if specified, a list of valid 24 | # configurations (see 25 | # https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIGURATION_TYPES.html); 26 | # 27 | # Example usage: 28 | # 29 | #[========[ 30 | 31 | # CMakeLists.txt 32 | 33 | include(BuildType) 34 | 35 | ]========] 36 | 37 | 38 | if(EXISTS "${CMAKE_SOURCE_DIR}/.git") 39 | set(default_build_type "Debug") 40 | else() 41 | set(default_build_type "Release") 42 | endif() 43 | 44 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 45 | 46 | message(STATUS "Setting build type to '${default_build_type}' as none was specified.") 47 | 48 | set(CACHE CMAKE_BUILD_TYPE "${default_build_type}" 49 | STRING "Choose the type of build." FORCE 50 | ) 51 | 52 | # Set the possible values of build type for cmake-gui 53 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 54 | "Debug" "Release" "MinSizeRel" "RelWithDebInfo" 55 | ) 56 | endif() 57 | 58 | # ############################## end of file ############################# # 59 | 60 | -------------------------------------------------------------------------------- /cmake/LanguageFullVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | # ################################################ 3 | # X_CMAKE_CXX_FULLSTANDARD 4 | 5 | set(X_CMAKE_CXX_FULLSTANDARD 0) 6 | 7 | if(FALSE) 8 | elseif(CMAKE_CXX_STANDARD EQUAL 98) 9 | 10 | set(X_CMAKE_CXX_FULLSTANDARD 1998) 11 | elseif(CMAKE_CXX_STANDARD GREATER_EQUAL 26) 12 | 13 | set(X_CMAKE_CXX_FULLSTANDARD 2026) 14 | elseif(CMAKE_CXX_STANDARD GREATER_EQUAL 23) 15 | 16 | set(X_CMAKE_CXX_FULLSTANDARD 2023) 17 | elseif(CMAKE_CXX_STANDARD GREATER_EQUAL 20) 18 | 19 | set(X_CMAKE_CXX_FULLSTANDARD 2020) 20 | elseif(CMAKE_CXX_STANDARD GREATER_EQUAL 17) 21 | 22 | set(X_CMAKE_CXX_FULLSTANDARD 2017) 23 | elseif(CMAKE_CXX_STANDARD GREATER_EQUAL 14) 24 | 25 | set(X_CMAKE_CXX_FULLSTANDARD 2014) 26 | elseif(CMAKE_CXX_STANDARD GREATER_EQUAL 11) 27 | 28 | set(X_CMAKE_CXX_FULLSTANDARD 2011) 29 | else() 30 | 31 | message(FATAL_ERROR "mechanism for discriminating X_CMAKE_CXX_FULLSTANDARD has failed") 32 | endif() 33 | 34 | 35 | # ############################## end of file ############################# # 36 | 37 | -------------------------------------------------------------------------------- /cmake/TargetMacros.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | function(define_automated_test_program program_name entry_point_source_name) 4 | 5 | add_executable(${program_name} 6 | ${entry_point_source_name} 7 | ) 8 | 9 | target_link_libraries(${program_name} 10 | PRIVATE 11 | $<$:shwild::core> 12 | $<$:STLSoft::STLSoft> 13 | UNIXem 14 | xTests::core 15 | ) 16 | 17 | set(X_GCC_CUSTOM_WARNINGS_ "") 18 | 19 | if(X_GCC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED) 20 | foreach(warning ${X_GCC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED}) 21 | 22 | list(APPEND X_GCC_CUSTOM_WARNINGS_ "-Wno-${warning}") 23 | endforeach() 24 | endif() 25 | 26 | set(X_MSVC_CUSTOM_WARNINGS_ "") 27 | 28 | if(X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED) 29 | 30 | foreach(warning ${X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED}) 31 | 32 | list(APPEND X_MSVC_CUSTOM_WARNINGS_ "/wd${warning}") 33 | endforeach() 34 | endif() 35 | 36 | target_compile_options(${program_name} PRIVATE 37 | $<$,$,$>: 38 | -Werror -Wall -Wextra -pedantic 39 | 40 | ${GCC_WARN_NO_cxx11_long_long} 41 | ${X_GCC_CUSTOM_WARNINGS_} 42 | > 43 | $<$,$>: 44 | -Wno-unused-lambda-capture 45 | > 46 | $<$: 47 | /WX /W4 48 | 49 | ${X_MSVC_CUSTOM_WARNINGS_} 50 | > 51 | ) 52 | endfunction(define_automated_test_program) 53 | 54 | function(define_example_program program_name entry_point_source_name) 55 | 56 | add_executable(${program_name} 57 | ${entry_point_source_name} 58 | ) 59 | 60 | target_link_libraries(${program_name} 61 | PRIVATE 62 | $<$:shwild::core> 63 | $<$:STLSoft::STLSoft> 64 | UNIXem 65 | ) 66 | 67 | set(X_GCC_CUSTOM_WARNINGS_ "") 68 | 69 | if(X_GCC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED) 70 | 71 | foreach(warning ${X_GCC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED}) 72 | 73 | list(APPEND X_GCC_CUSTOM_WARNINGS_ "-Wno-${warning}") 74 | endforeach() 75 | endif() 76 | 77 | set(X_MSVC_CUSTOM_WARNINGS_ "") 78 | 79 | if(X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED) 80 | 81 | foreach(warning ${X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED}) 82 | 83 | list(APPEND X_MSVC_CUSTOM_WARNINGS_ "/wd${warning}") 84 | endforeach() 85 | endif() 86 | 87 | target_compile_options(${program_name} PRIVATE 88 | $<$,$,$>: 89 | -Werror -Wall -Wextra -pedantic 90 | 91 | ${GCC_WARN_NO_cxx11_long_long} 92 | ${X_GCC_CUSTOM_WARNINGS_} 93 | > 94 | $<$,$>: 95 | -Wno-unused-lambda-capture 96 | > 97 | $<$: 98 | /WX /W4 99 | 100 | ${X_MSVC_CUSTOM_WARNINGS_} 101 | > 102 | ) 103 | endfunction(define_example_program) 104 | 105 | 106 | 107 | # ############################## end of file ############################# # 108 | 109 | -------------------------------------------------------------------------------- /cmake/unixem-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@-targets.cmake") 3 | 4 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/examples/CMakeLists.txt -------------------------------------------------------------------------------- /include/arpa/inet.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/include/arpa/inet.h -------------------------------------------------------------------------------- /include/asm/atomic.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: asm/atomic.h 3 | * 4 | * Purpose: Declaration of Linux like atomic functions for the 5 | * Windows platform. 6 | * 7 | * Created: 21st November 2003 8 | * Updated: 1st May 2025 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2003-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, this 20 | * list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * - Neither the names of Matthew Wilson and Synesis Software nor the names of 25 | * any contributors may be used to endorse or promote products derived from 26 | * this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | #ifndef SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC 44 | #define SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC 45 | 46 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 47 | # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_MAJOR 3 48 | # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_MINOR 0 49 | # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_REVISION 1 50 | # define SYNSOFT_UNIXEM_VER_SYS_H_ATOMIC_EDIT 23 51 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 52 | 53 | 54 | /* ///////////////////////////////////////////////////////////////////////// 55 | * includes 56 | */ 57 | 58 | #include 59 | 60 | 61 | /* ///////////////////////////////////////////////////////////////////////// 62 | * compatibility 63 | */ 64 | 65 | #ifndef _WIN32 66 | # error This file is only currently defined for compilation on Windows systems 67 | #endif /* _WIN32 */ 68 | 69 | 70 | /* ///////////////////////////////////////////////////////////////////////// 71 | * typedefs 72 | */ 73 | 74 | typedef unixem_atomic_t atomic_t; 75 | 76 | 77 | /* ///////////////////////////////////////////////////////////////////////// 78 | * API functions 79 | */ 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif /* __cplusplus */ 84 | 85 | #define ATOMIC_INIT(i) UNIXEM_ATOMIC_INIT(i) 86 | 87 | #define atomic_set unixem_atomic_set 88 | #define atomic_write unixem_atomic_write 89 | #define atomic_read unixem_atomic_read 90 | #define atomic_add unixem_atomic_add 91 | #define atomic_sub unixem_atomic_sub 92 | #define atomic_inc unixem_atomic_inc 93 | #define atomic_dec unixem_atomic_dec 94 | /** Returns the previous value */ 95 | #define atomic_inc_and_test unixem_atomic_inc_and_test 96 | /** Returns the previous value */ 97 | #define atomic_dec_and_test unixem_atomic_dec_and_test 98 | /** Returns the previous value */ 99 | #define atomic_add_and_test unixem_atomic_add_and_test 100 | /** Returns the previous value */ 101 | #define atomic_sub_and_test unixem_atomic_sub_and_test 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif /* __cplusplus */ 106 | 107 | 108 | /* ////////////////////////////////////////////////////////////////////// */ 109 | 110 | #endif /* SYNSOFT_UNIXEM_INCL_SYS_H_ATOMIC */ 111 | 112 | /* ///////////////////////////// end of file //////////////////////////// */ 113 | -------------------------------------------------------------------------------- /include/netinet/in.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/include/netinet/in.h -------------------------------------------------------------------------------- /include/sys/resource.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: sys/resource.h 3 | * 4 | * Purpose: Declaration of the getrusage() API function and supporting 5 | * types for the Windows platform. 6 | * 7 | * Created: 9th June 2006 8 | * Updated: 28th November 2024 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2006-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, this 20 | * list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * - Neither the names of Matthew Wilson and Synesis Software nor the names of 25 | * any contributors may be used to endorse or promote products derived from 26 | * this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | /** \file sys/resource.h 44 | * 45 | * Contains usage functions and types. 46 | */ 47 | 48 | #ifndef SYNSOFT_UNIXEM_INCL_SYS_H_RESOURCE 49 | #define SYNSOFT_UNIXEM_INCL_SYS_H_RESOURCE 50 | 51 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 52 | # define SYNSOFT_UNIXEM_VER_SYS_H_RESOURCE_MAJOR 2 53 | # define SYNSOFT_UNIXEM_VER_SYS_H_RESOURCE_MINOR 0 54 | # define SYNSOFT_UNIXEM_VER_SYS_H_RESOURCE_REVISION 1 55 | # define SYNSOFT_UNIXEM_VER_SYS_H_RESOURCE_EDIT 12 56 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 57 | 58 | 59 | /* ///////////////////////////////////////////////////////////////////////// 60 | * includes 61 | */ 62 | 63 | #include 64 | 65 | /* ////////////////////////////////////////////////////////////////////// */ 66 | 67 | /** \weakgroup unixem Synesis Software UNIX Emulation for Windows 68 | * \brief The UNIX emulation library 69 | */ 70 | 71 | /** \weakgroup unixem_resource Resource Usage API 72 | * \ingroup UNIXem unixem 73 | * \brief Resource usage functions and types 74 | * @{ 75 | */ 76 | 77 | /* ////////////////////////////////////////////////////////////////////// */ 78 | 79 | #ifdef __cplusplus 80 | extern "C" 81 | { 82 | #endif /* __cplusplus */ 83 | 84 | /** \def RUSAGE_SELF 85 | * 86 | * Requests that rusage() provide information about the calling process. 87 | */ 88 | #define RUSAGE_SELF (UNIXEM_RUSAGE_SELF) 89 | /** \def RUSAGE_CHILDREN 90 | * 91 | * Requests that rusage() provide information about child processes 92 | * of the calling process. 93 | * 94 | * \note This flag is not supported 95 | */ 96 | #define RUSAGE_CHILDREN (UNIXEM_RUSAGE_CHILDREN) 97 | 98 | /** \def rusage 99 | * 100 | * Results structure for getrusage() 101 | * 102 | * \see unixem_getrusage 103 | */ 104 | #define rusage unixem_rusage 105 | 106 | /** Provide resource usage information. 107 | * 108 | * Retrieves resource usage information about the given process(es). 109 | * 110 | * \param who The process(es) about which the usage information is to be 111 | * retrieved. One of RUSAGE_SELF or RUSAGE_CHILDREN. 112 | * \param r_usage Pointer to an rusage structure to receive the rusage 113 | * information. 114 | * 115 | * \note This implementation only supports the RUSAGE_SELF flag for the 116 | * who parameter. 117 | * 118 | * \note This is a macro, which resolves to unixem_getrusage() 119 | */ 120 | #ifdef UNIXEM_DOCUMENTATION_SKIP_SECTION 121 | int getrusage( 122 | int who 123 | , struct rusage* r_usage 124 | ); 125 | #else /* ? UNIXEM_DOCUMENTATION_SKIP_SECTION */ 126 | # define getrusage unixem_getrusage 127 | #endif /* UNIXEM_DOCUMENTATION_SKIP_SECTION */ 128 | 129 | #ifdef __cplusplus 130 | } /* extern "C" */ 131 | #endif /* __cplusplus */ 132 | 133 | 134 | /* ////////////////////////////////////////////////////////////////////// */ 135 | 136 | /** @} // end of group unixem_resource */ 137 | 138 | /* ////////////////////////////////////////////////////////////////////// */ 139 | 140 | #endif /* SYNSOFT_UNIXEM_INCL_SYS_H_RESOURCE */ 141 | 142 | /* ///////////////////////////// end of file //////////////////////////// */ 143 | -------------------------------------------------------------------------------- /include/sys/socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/include/sys/socket.h -------------------------------------------------------------------------------- /include/sys/time.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: sys/time.h 3 | * 4 | * Purpose: Declaration of the gettimeofday() API function and supporting 5 | * types for the Windows platform. 6 | * 7 | * Created: 8th December 2002 8 | * Updated: 18th May 2025 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, this 20 | * list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright notice, 22 | * this list of conditions and the following disclaimer in the documentation 23 | * and/or other materials provided with the distribution. 24 | * - Neither the names of Matthew Wilson and Synesis Software nor the names of 25 | * any contributors may be used to endorse or promote products derived from 26 | * this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | /** \file sys/time.h 44 | * 45 | * Contains time functions and types. 46 | */ 47 | 48 | #ifndef SYNSOFT_UNIXEM_INCL_SYS_H_TIME 49 | #define SYNSOFT_UNIXEM_INCL_SYS_H_TIME 50 | 51 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 52 | # define SYNSOFT_UNIXEM_VER_SYS_H_TIME_MAJOR 3 53 | # define SYNSOFT_UNIXEM_VER_SYS_H_TIME_MINOR 0 54 | # define SYNSOFT_UNIXEM_VER_SYS_H_TIME_REVISION 1 55 | # define SYNSOFT_UNIXEM_VER_SYS_H_TIME_EDIT 30 56 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 57 | 58 | 59 | /* ///////////////////////////////////////////////////////////////////////// 60 | * includes 61 | */ 62 | 63 | #include 64 | 65 | #ifdef _WIN32 66 | # include 67 | #endif /* _WIN32 */ 68 | 69 | /* ////////////////////////////////////////////////////////////////////// */ 70 | 71 | /** \weakgroup unixem Synesis Software UNIX Emulation for Windows 72 | * \brief The UNIX emulation library 73 | */ 74 | 75 | /** \weakgroup unixem_time time() API 76 | * \ingroup UNIXem unixem 77 | * \brief Time functions and types 78 | * @{ 79 | */ 80 | 81 | /* ////////////////////////////////////////////////////////////////////// */ 82 | 83 | #ifdef __cplusplus 84 | extern "C" 85 | { 86 | #endif /* __cplusplus */ 87 | 88 | #ifndef UNIXEM_WINSOCK_IS_INCLUDED 89 | 90 | /** \def timeval 91 | * 92 | * A representation of current time, used by gettimeofday(). 93 | * 94 | * This structure represents the time, in seconds and microseconds, since Jan. 95 | * 1, 1970, in UTC. Returned by the gettimeofday() function. 96 | */ 97 | #define timeval unixem_timeval 98 | 99 | # ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 100 | # if !defined(_TIMEVAL_DEFINED) 101 | # define _TIMEVAL_DEFINED 102 | # endif /* !_TIMEVAL_DEFINED */ 103 | # endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 104 | 105 | #endif /* UNIXEM_WINSOCK_IS_INCLUDED */ 106 | 107 | /** Accesses the current UTC time 108 | * 109 | * Retrieves the current time and timezone information, relative to Greenwich Mean Time 110 | * 111 | * \param tv Pointer to a timeval structure to receive the time information 112 | * \param dummy This parameter is not used 113 | * 114 | * \return Always returns 0. 115 | * 116 | * \note This is a macro, which resolves to unixem_gettimeofday() 117 | */ 118 | #ifdef UNIXEM_DOCUMENTATION_SKIP_SECTION 119 | int gettimeofday( 120 | struct timeval* tv 121 | , void* dummy 122 | ); 123 | #else /* ? UNIXEM_DOCUMENTATION_SKIP_SECTION */ 124 | # define gettimeofday unixem_gettimeofday 125 | #endif /* UNIXEM_DOCUMENTATION_SKIP_SECTION */ 126 | 127 | #ifdef __cplusplus 128 | } /* extern "C" */ 129 | #endif /* __cplusplus */ 130 | 131 | 132 | /* ////////////////////////////////////////////////////////////////////// */ 133 | 134 | /** @} // end of group unixem_time */ 135 | 136 | /* ////////////////////////////////////////////////////////////////////// */ 137 | 138 | #endif /* SYNSOFT_UNIXEM_INCL_SYS_H_TIME */ 139 | 140 | /* ///////////////////////////// end of file //////////////////////////// */ 141 | -------------------------------------------------------------------------------- /include/unixem/arpa/inet.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/include/unixem/arpa/inet.h -------------------------------------------------------------------------------- /include/unixem/asm/atomic.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/asm/atomic.h 3 | * 4 | * Purpose: Declaration of Linux like atomic functions for the 5 | * Windows platform. 6 | * 7 | * Created: 21st November 2003 8 | * Updated: 29th November 2024 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2003-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are 18 | * met: 19 | * 20 | * - Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * - Redistributions in binary form must reproduce the above copyright 23 | * notice, this list of conditions and the following disclaimer in the 24 | * documentation and/or other materials provided with the distribution. 25 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 26 | * names of any contributors may be used to endorse or promote products 27 | * derived from this software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 30 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 34 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 35 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * ////////////////////////////////////////////////////////////////////// */ 42 | 43 | 44 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_ASM_H_ATOMIC 45 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_ASM_H_ATOMIC 46 | 47 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 48 | # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_MAJOR 3 49 | # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_MINOR 0 50 | # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_REVISION 1 51 | # define SYNSOFT_UNIXEM_VER_UNIXEM_ASM_H_ATOMIC_EDIT 22 52 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 53 | 54 | 55 | /* ////////////////////////////////////////////////////////////////////// */ 56 | 57 | #ifndef _WIN32 58 | # error This file is only currently defined for compilation on Windows systems 59 | #endif /* _WIN32 */ 60 | 61 | 62 | /* ///////////////////////////////////////////////////////////////////////// 63 | * constants and definitions 64 | */ 65 | 66 | #include 67 | 68 | 69 | /* ///////////////////////////////////////////////////////////////////////// 70 | * typedefs 71 | */ 72 | 73 | typedef signed long unixem_atomic_t; 74 | 75 | 76 | /* ///////////////////////////////////////////////////////////////////////// 77 | * API functions 78 | */ 79 | 80 | #ifdef __cplusplus 81 | extern "C" { 82 | #endif /* __cplusplus */ 83 | 84 | #define UNIXEM_ATOMIC_INIT(i) (i) 85 | 86 | void unixem_atomic_set(unixem_atomic_t volatile* v, int i); 87 | int unixem_atomic_write(unixem_atomic_t volatile* v, int i); 88 | int unixem_atomic_read(unixem_atomic_t volatile* v); 89 | 90 | void unixem_atomic_add(int i, unixem_atomic_t volatile* v); 91 | void unixem_atomic_sub(int i, unixem_atomic_t volatile* v); 92 | 93 | void unixem_atomic_inc(unixem_atomic_t volatile* v); 94 | void unixem_atomic_dec(unixem_atomic_t volatile* v); 95 | 96 | /** Returns the previous value */ 97 | int unixem_atomic_inc_and_test(unixem_atomic_t volatile* v); 98 | /** Returns the previous value */ 99 | int unixem_atomic_dec_and_test(unixem_atomic_t volatile* v); 100 | 101 | /** Returns the previous value */ 102 | int unixem_atomic_add_and_test(int i, unixem_atomic_t volatile* v); 103 | /** Returns the previous value */ 104 | int unixem_atomic_sub_and_test(int i, unixem_atomic_t volatile* v); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif /* __cplusplus */ 109 | 110 | 111 | /* ////////////////////////////////////////////////////////////////////// */ 112 | 113 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_ASM_H_ATOMIC */ 114 | 115 | /* ///////////////////////////// end of file //////////////////////////// */ 116 | -------------------------------------------------------------------------------- /include/unixem/internal/safestr.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/internal/safestr.h 3 | * 4 | * Purpose: Internal utility header for the UNIXem API. 5 | * 6 | * Created: 28th December 2007 7 | * Updated: 29th November 2024 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 12 | * Copyright (c) 2007-2019, Matthew Wilson and Synesis Software 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are 17 | * met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 25 | * names of any contributors may be used to endorse or promote products 26 | * derived from this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 29 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 32 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 36 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | /** \file unixem/internal/safestr.h Internal utility header for the UNIXem API 44 | */ 45 | 46 | #ifndef UNIXEM_INCL_UNIXEM_INTERNAL_H_SAFESTR 47 | #define UNIXEM_INCL_UNIXEM_INTERNAL_H_SAFESTR 48 | 49 | 50 | /* ///////////////////////////////////////////////////////////////////////// 51 | * version 52 | */ 53 | 54 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 55 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_SAFESTR_MAJOR 1 56 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_SAFESTR_MINOR 0 57 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_SAFESTR_REVISION 1 58 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_SAFESTR_EDIT 8 59 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 60 | 61 | 62 | /* ///////////////////////////////////////////////////////////////////////// 63 | * includes 64 | */ 65 | 66 | #include 67 | 68 | #ifdef UNIXEM_SAFE_STR_USE_crtdefs_h_ 69 | # undef UNIXEM_SAFE_STR_USE_crtdefs_h_ 70 | #endif /* UNIXEM_SAFE_STR_USE_crtdefs_h_ */ 71 | 72 | #if 0 73 | #elif defined(__BORLANDC__) 74 | #elif defined(__DMC__) 75 | #elif defined(__GNUC__) 76 | #elif defined(__INTEL_COMPILER) 77 | # if defined(_MSC_VER) && \ 78 | _MSC_VER >= 1400 79 | # define UNIXEM_SAFE_STR_USE_crtdefs_h_ 80 | # endif /* _MSC_VER >= 1400 */ 81 | #elif defined(__MWERKS__) 82 | #elif defined(__WATCOMC__) 83 | #elif defined(_MSC_VER) 84 | # if _MSC_VER >= 1400 85 | # define UNIXEM_SAFE_STR_USE_crtdefs_h_ 86 | # endif /* _MSC_VER >= 1400 */ 87 | #elif defined(__COMO__) 88 | #else 89 | #endif /* compiler */ 90 | 91 | #ifdef UNIXEM_SAFE_STR_USE_crtdefs_h_ 92 | # include 93 | #endif /* UNIXEM_SAFE_STR_USE_crtdefs_h_ */ 94 | 95 | 96 | /* ///////////////////////////////////////////////////////////////////////// 97 | * feature detection 98 | */ 99 | 100 | #ifdef __STDC_SECURE_LIB__ 101 | # if defined(__STDC_WANT_SECURE_LIB__) && \ 102 | __STDC_WANT_SECURE_LIB__ == 1 103 | # define UNIXEM_USING_SAFE_STR_FUNCTIONS 104 | # endif /* __STDC_WANT_SECURE_LIB__ == 1 */ 105 | #endif /* __STDC_SECURE_LIB__ */ 106 | 107 | 108 | /* ////////////////////////////////////////////////////////////////////// */ 109 | 110 | #endif /* UNIXEM_INCL_UNIXEM_INTERNAL_H_SAFESTR */ 111 | 112 | /* ///////////////////////////// end of file //////////////////////////// */ 113 | -------------------------------------------------------------------------------- /include/unixem/internal/stdint.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/internal/stdint.h 3 | * 4 | * Purpose: Discrimination of integers. 5 | * 6 | * Created: 29th November 2024 7 | * Updated: 29th November 2024 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2024, Matthew Wilson and Synesis Information Systems 12 | * All rights reserved. 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are 16 | * met: 17 | * 18 | * - Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * - Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 24 | * names of any contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 28 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 32 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 33 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 34 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | * ////////////////////////////////////////////////////////////////////// */ 40 | 41 | 42 | /** \file unixem/internal/stdint.h Discrimination of integers 43 | */ 44 | 45 | #ifndef UNIXEM_INCL_UNIXEM_internal_h_stdint 46 | #define UNIXEM_INCL_UNIXEM_internal_h_stdint 47 | 48 | 49 | /* ///////////////////////////////////////////////////////////////////////// 50 | * version 51 | */ 52 | 53 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 54 | # define UNIXEM_VER_UNIXEM_internal_h_stdint_MAJOR 1 55 | # define UNIXEM_VER_UNIXEM_internal_h_stdint_MINOR 0 56 | # define UNIXEM_VER_UNIXEM_internal_h_stdint_REVISION 0 57 | # define UNIXEM_VER_UNIXEM_internal_h_stdint_EDIT 1 58 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 59 | 60 | 61 | /* ///////////////////////////////////////////////////////////////////////// 62 | * includes - 1 63 | */ 64 | 65 | #include 66 | 67 | #include 68 | 69 | 70 | /* ///////////////////////////////////////////////////////////////////////// 71 | * compatibility 72 | */ 73 | 74 | #if 0 75 | #elif __STDC_VERSION__ >= 199901L 76 | 77 | # define UNIXEM_HAS_h_stdint_ 78 | #elif 0 ||\ 79 | ( defined(_MSC_VER) &&\ 80 | _MSC_VER >= 1310) ||\ 81 | 0 82 | 83 | # define UNIXEM_HAS_h_stdint_ 84 | #else 85 | 86 | #endif 87 | 88 | 89 | /* ///////////////////////////////////////////////////////////////////////// 90 | * includes - 2 91 | */ 92 | 93 | #ifdef UNIXEM_HAS_h_stdint_ 94 | # include 95 | #endif 96 | 97 | 98 | /* ///////////////////////////////////////////////////////////////////////// 99 | * macros 100 | */ 101 | 102 | 103 | 104 | /* ///////////////////////////////////////////////////////////////////////// 105 | * integer types 106 | */ 107 | 108 | #if 0 109 | #elif defined(UNIXEM_HAS_h_stdint_) 110 | 111 | typedef intptr_t unixem_ssize_t; 112 | #elif defined(_WIN64) 113 | 114 | # if 0 115 | # elif defined(__LP64__) 116 | 117 | typedef signed long unixem_ssize_t; 118 | # elif defined(__LLP64__) 119 | 120 | typedef signed long long unixem_ssize_t; 121 | # else 122 | 123 | typedef signed __int64 unixem_ssize_t; 124 | # endif 125 | #else 126 | 127 | typedef signed long unixem_ssize_t; 128 | #endif 129 | 130 | 131 | /* ///////////////////////////////////////////////////////////////////////// 132 | * function declarations 133 | */ 134 | 135 | 136 | /* ////////////////////////////////////////////////////////////////////// */ 137 | 138 | #endif /* UNIXEM_INCL_UNIXEM_internal_h_stdint */ 139 | 140 | /* ///////////////////////////// end of file //////////////////////////// */ 141 | -------------------------------------------------------------------------------- /include/unixem/internal/winsock.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/internal/winsock.h 3 | * 4 | * Purpose: Internal utility header for introducing WinSock (in order to 5 | * support timeval and gethostname()). 6 | * 7 | * Created: 28th December 2007 8 | * Updated: 10th July 2024 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2007-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are 18 | * met: 19 | * 20 | * - Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * - Redistributions in binary form must reproduce the above copyright 23 | * notice, this list of conditions and the following disclaimer in the 24 | * documentation and/or other materials provided with the distribution. 25 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 26 | * names of any contributors may be used to endorse or promote products 27 | * derived from this software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 30 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 34 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 35 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * ////////////////////////////////////////////////////////////////////// */ 42 | 43 | 44 | /** \file unixem/internal/winsock.h Internal utility header for introducing 45 | * WinSock 46 | */ 47 | 48 | #ifndef UNIXEM_INCL_UNIXEM_INTERNAL_H_WINSOCK 49 | #define UNIXEM_INCL_UNIXEM_INTERNAL_H_WINSOCK 50 | 51 | 52 | /* ///////////////////////////////////////////////////////////////////////// 53 | * version 54 | */ 55 | 56 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 57 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_WINSOCK_MAJOR 1 58 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_WINSOCK_MINOR 0 59 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_WINSOCK_REVISION 3 60 | # define UNIXEM_VER_UNIXEM_INTERNAL_H_WINSOCK_EDIT 8 61 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 62 | 63 | 64 | /* ///////////////////////////////////////////////////////////////////////// 65 | * includes 66 | */ 67 | 68 | #include 69 | 70 | #ifdef UNIXEM_internal_WIN32_is_defined_ 71 | # undef UNIXEM_internal_WIN32_is_defined_ 72 | #endif /* UNIXEM_internal_WIN32_is_defined_ */ 73 | 74 | #ifdef WIN32 75 | # define UNIXEM_internal_WIN32_is_defined_ 76 | #endif /* WIN32 */ 77 | 78 | #if !defined(WIN32_LEAN_AND_MEAN) 79 | # if defined(_WINSOCKAPI_) || \ 80 | defined(_WINSOCK_H) 81 | # define UNIXEM_WINSOCK_IS_INCLUDED 82 | # endif /* winsock.h */ 83 | # if defined(_WINSOCK2API_) || \ 84 | defined(_WINSOCK2_H) 85 | # define UNIXEM_WINSOCK2_IS_INCLUDED 86 | # endif /* winsock2.h */ 87 | 88 | # if !defined(UNIXEM_WINSOCK_IS_INCLUDED) && \ 89 | !defined(UNIXEM_WINSOCK2_IS_INCLUDED) 90 | # if _WIN32_WINNT >= 0x0400 91 | # include 92 | # define UNIXEM_WINSOCK_IS_INCLUDED 93 | # define UNIXEM_WINSOCK2_IS_INCLUDED 94 | # else /* _WIN32_WINNT */ 95 | 96 | # include 97 | # define UNIXEM_WINSOCK_IS_INCLUDED 98 | # endif /* _WIN32_WINNT >= 0x0400 */ 99 | # endif /* winsock ? */ 100 | #endif /* !WIN32_LEAN_AND_MEAN */ 101 | 102 | #ifdef WIN32 103 | # ifndef UNIXEM_internal_WIN32_is_defined_ 104 | # undef WIN32 105 | # endif /* !UNIXEM_internal_WIN32_is_defined_ */ 106 | #endif /* WIN32 */ 107 | 108 | 109 | /* ////////////////////////////////////////////////////////////////////// */ 110 | 111 | #endif /* UNIXEM_INCL_UNIXEM_INTERNAL_H_WINSOCK */ 112 | 113 | /* ///////////////////////////// end of file //////////////////////////// */ 114 | -------------------------------------------------------------------------------- /include/unixem/netinet/in.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/include/unixem/netinet/in.h -------------------------------------------------------------------------------- /include/unixem/setenv.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/setenv.h 3 | * 4 | * Purpose: Definition of the setenv() and unsetenv() functions. 5 | * 6 | * Created: 9th December 2005 7 | * Updated: 28th November 2024 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 12 | * Copyright (c) 2005-2019, Matthew Wilson and Synesis Software 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are 17 | * met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 25 | * names of any contributors may be used to endorse or promote products 26 | * derived from this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 29 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 32 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 36 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | /** \file unixem/setenv.h Definition of the setenv() and unsetenv() functions 44 | */ 45 | 46 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_H_SETENV 47 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_H_SETENV 48 | 49 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 50 | # define UNIXEM_VER_UNIXEM_H_SETENV_MAJOR 2 51 | # define UNIXEM_VER_UNIXEM_H_SETENV_MINOR 0 52 | # define UNIXEM_VER_UNIXEM_H_SETENV_REVISION 1 53 | # define UNIXEM_VER_UNIXEM_H_SETENV_EDIT 11 54 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 55 | 56 | 57 | /* ///////////////////////////////////////////////////////////////////////// 58 | * includes 59 | */ 60 | 61 | #include 62 | 63 | #include /* for size_t */ 64 | #include /* for mode_t */ 65 | 66 | #if defined(__WATCOMC__) 67 | # error The Watcom RTL provides setenv() 68 | #endif /* compiler */ 69 | 70 | /* ////////////////////////////////////////////////////////////////////// */ 71 | 72 | /** \weakgroup unixem Synesis Software UNIX Emulation for Windows 73 | * \brief The UNIX emulation library 74 | */ 75 | 76 | /** \weakgroup unixem_setenv setenv.h 77 | * \ingroup UNIXem unixem 78 | * \brief setenv() and unsetenv() functions 79 | * @{ 80 | */ 81 | 82 | 83 | /* ///////////////////////////////////////////////////////////////////////// 84 | * API functions 85 | */ 86 | 87 | # ifdef __cplusplus 88 | extern "C" { 89 | # endif /* __cplusplus */ 90 | 91 | /** Inserts or resets the value of an environment variable. 92 | * 93 | * This function creates a link from \c originalFile to \c linkName. 94 | * 95 | * \param name The name of the environment variable to add / set 96 | * \param value The value of the environment variable 97 | * \param bOverwrite Determines whether to overwrite the variable, if it exists, 98 | * or to leave its current value intact 99 | * 100 | * \return O on success, or -1 if there is an error 101 | */ 102 | int unixem_setenv( 103 | char const* name 104 | , char const* value 105 | , int bOverwrite 106 | ); 107 | 108 | 109 | /** Deletes the named environment variable, if it exists. 110 | * 111 | * \param name The name of the environment to delete 112 | */ 113 | void unixem_unsetenv(char const* name); 114 | 115 | # ifdef __cplusplus 116 | } /* extern "C" */ 117 | # endif /* __cplusplus */ 118 | 119 | 120 | /* ////////////////////////////////////////////////////////////////////// */ 121 | 122 | /** @} // end of group unixem_setenv */ 123 | 124 | /* ////////////////////////////////////////////////////////////////////// */ 125 | 126 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_H_SETENV */ 127 | 128 | /* ///////////////////////////// end of file //////////////////////////// */ 129 | 130 | -------------------------------------------------------------------------------- /include/unixem/sys/socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synesissoftware/UNIXem/39c125f5ac718fd6f3cc2eaa985a764dcfe948f5/include/unixem/sys/socket.h -------------------------------------------------------------------------------- /include/unixem/sys/time.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/sys/time.h 3 | * 4 | * Purpose: Declaration of the gettimeofday() API function and supporting 5 | * types for the Windows platform. 6 | * 7 | * Created: 8th December 2002 8 | * Updated: 28th November 2024 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are 18 | * met: 19 | * 20 | * - Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * - Redistributions in binary form must reproduce the above copyright 23 | * notice, this list of conditions and the following disclaimer in the 24 | * documentation and/or other materials provided with the distribution. 25 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 26 | * names of any contributors may be used to endorse or promote products 27 | * derived from this software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 30 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 34 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 35 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * ////////////////////////////////////////////////////////////////////// */ 42 | 43 | 44 | /** \file unixem/sys/time.h 45 | * 46 | * Contains time functions and types. 47 | */ 48 | 49 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_SYS_H_TIME 50 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_SYS_H_TIME 51 | 52 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 53 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_TIME_MAJOR 3 54 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_TIME_MINOR 0 55 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_TIME_REVISION 2 56 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_TIME_EDIT 29 57 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 58 | 59 | 60 | /* ///////////////////////////////////////////////////////////////////////// 61 | * includes 62 | */ 63 | 64 | #include 65 | 66 | #ifdef _WIN32 67 | # include 68 | #endif /* _WIN32 */ 69 | 70 | /* ////////////////////////////////////////////////////////////////////// */ 71 | 72 | /** \weakgroup unixem Synesis Software UNIX Emulation for Windows 73 | * \brief The UNIX emulation library 74 | */ 75 | 76 | /** \weakgroup unixem_time time() API 77 | * \ingroup UNIXem unixem 78 | * \brief Time functions and types 79 | * @{ 80 | */ 81 | 82 | /* ////////////////////////////////////////////////////////////////////// */ 83 | 84 | #ifdef __cplusplus 85 | extern "C" 86 | { 87 | #endif /* __cplusplus */ 88 | 89 | #ifndef UNIXEM_WINSOCK_IS_INCLUDED 90 | 91 | /** A representation of current time, used by gettimeofday(). 92 | * 93 | * This structure represents the time, in seconds and microseconds, since Jan. 94 | * 1, 1970, in UTC. Returned by the gettimeofday() function. 95 | */ 96 | 97 | struct unixem_timeval 98 | { 99 | long tv_sec; /*!< The number of seconds, since Jan. 1, 1970, in the time value. */ 100 | long tv_usec; /*!< The number of microseconds in the time value. */ 101 | }; 102 | 103 | #else /* ? !UNIXEM_WINSOCK_IS_INCLUDED */ 104 | 105 | # define unixem_timeval timeval 106 | 107 | #endif /* !UNIXEM_WINSOCK_IS_INCLUDED */ 108 | 109 | /** Accesses the current UTC time 110 | * 111 | * Retrieves the current time and timezone information, relative to Greenwich Mean Time 112 | * 113 | * \param tv Pointer to a timeval structure to receive the time information 114 | * \param dummy This parameter is not used 115 | * 116 | * \return Always returns 0. 117 | */ 118 | extern int unixem_gettimeofday( 119 | struct unixem_timeval* tv 120 | , void* dummy 121 | ); 122 | 123 | #ifdef __cplusplus 124 | } /* extern "C" */ 125 | #endif /* __cplusplus */ 126 | 127 | 128 | /* ////////////////////////////////////////////////////////////////////// */ 129 | 130 | /** @} // end of group unixem_time */ 131 | 132 | /* ////////////////////////////////////////////////////////////////////// */ 133 | 134 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_SYS_H_TIME */ 135 | 136 | /* ///////////////////////////// end of file //////////////////////////// */ 137 | -------------------------------------------------------------------------------- /include/unixem/sys/uio.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/sys/uio.h 3 | * 4 | * Purpose: Vector file read/write. 5 | * 6 | * Created: 19th September 2005 7 | * Updated: 29th November 2024 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 12 | * Copyright (c) 2005-2019, Matthew Wilson and Synesis Software 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are 17 | * met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 25 | * names of any contributors may be used to endorse or promote products 26 | * derived from this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 29 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 32 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 36 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | /** \file unixem/sys/uio.h 44 | * 45 | * Vector file read/write. 46 | */ 47 | 48 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_SYS_H_UIO 49 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_SYS_H_UIO 50 | 51 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 52 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_UIO_MAJOR 2 53 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_UIO_MINOR 0 54 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_UIO_REVISION 2 55 | # define SYNSOFT_UNIXEM_VER_UNIXEM_SYS_H_UIO_EDIT 16 56 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 57 | 58 | 59 | /* ///////////////////////////////////////////////////////////////////////// 60 | * includes 61 | */ 62 | 63 | #include 64 | 65 | #include 66 | 67 | 68 | /* ///////////////////////////////////////////////////////////////////////// 69 | * compatibility 70 | */ 71 | 72 | 73 | /* ////////////////////////////////////////////////////////////////////// */ 74 | 75 | /** \weakgroup unixem Synesis Software UNIX Emulation for Windows 76 | * \brief The UNIX emulation library 77 | */ 78 | 79 | /** \weakgroup unixem_uio uio() API 80 | * \ingroup UNIXem unixem 81 | * \brief UIO functions and types 82 | * @{ 83 | */ 84 | 85 | /* ////////////////////////////////////////////////////////////////////// */ 86 | 87 | #ifdef __cplusplus 88 | extern "C" 89 | { 90 | #endif /* __cplusplus */ 91 | 92 | 93 | /* ///////////////////////////////////////////////////////////////////////// 94 | * typedefs 95 | */ 96 | 97 | /** Defines a memory vector */ 98 | struct unixem_iovec 99 | { 100 | void* iov_base; /*!< Base address */ 101 | size_t iov_len; /*!< Number of bytes referenced */ 102 | }; 103 | 104 | 105 | /* ///////////////////////////////////////////////////////////////////////// 106 | * functions 107 | */ 108 | 109 | /** Reads from a file into a set of memory blocks 110 | * 111 | * \param fd The file from which to read 112 | * \param vector pointer to the first element in the vector 113 | * \param count the number of elements in the vector 114 | */ 115 | unixem_ssize_t 116 | unixem_readv( 117 | int fd 118 | , struct unixem_iovec const* vector 119 | , int count 120 | ); 121 | 122 | /** Writes to a file from a set of memory blocks 123 | * 124 | * \param fd The file to which to write 125 | * \param vector pointer to the first element in the vector 126 | * \param count the number of elements in the vector 127 | */ 128 | unixem_ssize_t 129 | unixem_writev( 130 | int fd 131 | , struct unixem_iovec const* vector 132 | , int count 133 | ); 134 | 135 | #ifdef __cplusplus 136 | } /* extern "C" */ 137 | #endif /* __cplusplus */ 138 | 139 | 140 | /* ////////////////////////////////////////////////////////////////////// */ 141 | 142 | /** @} // end of group unixem_time */ 143 | 144 | /* ////////////////////////////////////////////////////////////////////// */ 145 | 146 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_SYS_H_UIO */ 147 | 148 | /* ///////////////////////////// end of file //////////////////////////// */ 149 | -------------------------------------------------------------------------------- /include/unixem/time.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/time.h 3 | * 4 | * Purpose: Time functions and types for the Windows platform. 5 | * 6 | * Created: 5th May 2014 7 | * Updated: 1st May 2025 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems 12 | * Copyright (c) 2014-2019, Matthew Wilson and Synesis Software 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are 17 | * met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 25 | * names of any contributors may be used to endorse or promote products 26 | * derived from this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 29 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 32 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 36 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | /** \file unixem/time.h 44 | * 45 | * Time functions and types for the Windows platform. 46 | */ 47 | 48 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_H_TIME 49 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_H_TIME 50 | 51 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 52 | # define SYNSOFT_UNIXEM_VER_UNIXEM_H_UNIXEM_TIME_MAJOR 1 53 | # define SYNSOFT_UNIXEM_VER_UNIXEM_H_UNIXEM_TIME_MINOR 0 54 | # define SYNSOFT_UNIXEM_VER_UNIXEM_H_UNIXEM_TIME_REVISION 1 55 | # define SYNSOFT_UNIXEM_VER_UNIXEM_H_UNIXEM_TIME_EDIT 5 56 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 57 | 58 | 59 | /* ///////////////////////////////////////////////////////////////////////// 60 | * includes 61 | */ 62 | 63 | #include 64 | 65 | #include 66 | 67 | #include 68 | 69 | 70 | /* ////////////////////////////////////////////////////////////////////// */ 71 | 72 | /** \weakgroup unixem Synesis Software UNIX Emulation for Windows 73 | * \brief The UNIX emulation library 74 | */ 75 | 76 | /** \weakgroup unixem_time time() API 77 | * \ingroup UNIXem unixem 78 | * \brief Time functions and types 79 | * @{ 80 | */ 81 | 82 | /* ////////////////////////////////////////////////////////////////////// */ 83 | 84 | #ifdef __cplusplus 85 | extern "C" 86 | { 87 | #endif /* __cplusplus */ 88 | 89 | /** Converts a struct tm value into a time_t value. 90 | * 91 | * \param tm Pointer to a tm structure to receive the time information 92 | * 93 | * \return The converted value. 94 | */ 95 | time_t 96 | unixem_timegm( 97 | struct tm* tm 98 | ); 99 | 100 | 101 | /** Converts a struct tm value into a time_t value. 102 | * 103 | * \param tm Pointer to a tm structure to receive the time information 104 | * 105 | * \return The converted value. 106 | * 107 | * \note This is a macro, which resolves to unixem_timegm() 108 | */ 109 | #ifdef UNIXEM_DOCUMENTATION_SKIP_SECTION 110 | time_t 111 | timegm( 112 | struct tm* tm 113 | ); 114 | #else /* ? UNIXEM_DOCUMENTATION_SKIP_SECTION */ 115 | # ifndef timegm 116 | # define timegm unixem_timegm 117 | # endif /* !timegm */ 118 | #endif /* UNIXEM_DOCUMENTATION_SKIP_SECTION */ 119 | 120 | #ifdef __cplusplus 121 | } /* extern "C" */ 122 | #endif /* __cplusplus */ 123 | 124 | 125 | /* ////////////////////////////////////////////////////////////////////// */ 126 | 127 | /** @} // end of group unixem_time */ 128 | 129 | /* ////////////////////////////////////////////////////////////////////// */ 130 | 131 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_H_TIME */ 132 | 133 | /* ///////////////////////////// end of file //////////////////////////// */ 134 | -------------------------------------------------------------------------------- /include/unixem/unixem.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/unixem.h 3 | * 4 | * Purpose: Version header for the UNIXem API. 5 | * 6 | * Created: 29th August 2005 7 | * Updated: 19th May 2025 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems 12 | * Copyright (c) 2005-2019, Matthew Wilson and Synesis Software 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are 17 | * met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * - Neither the name(s) of Matthew Wilson and Synesis Information Systems 25 | * nor the names of any contributors may be used to endorse or promote 26 | * products derived from this software without specific prior written 27 | * permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 30 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 34 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 35 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * ////////////////////////////////////////////////////////////////////// */ 42 | 43 | 44 | /** \file unixem/unixem.h Version header for the UNIXem API 45 | */ 46 | 47 | #ifndef UNIXEM_INCL_UNIXEM_H_UNIXEM 48 | #define UNIXEM_INCL_UNIXEM_H_UNIXEM 49 | 50 | 51 | /* ///////////////////////////////////////////////////////////////////////// 52 | * version 53 | */ 54 | 55 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 56 | # define UNIXEM_VER_UNIXEM_H_UNIXEM_MAJOR 1 57 | # define UNIXEM_VER_UNIXEM_H_UNIXEM_MINOR 7 58 | # define UNIXEM_VER_UNIXEM_H_UNIXEM_REVISION 7 59 | # define UNIXEM_VER_UNIXEM_H_UNIXEM_EDIT 31 60 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 61 | 62 | /** \def UNIXEM_VER_MAJOR 63 | * The major version number of UNIXem 64 | */ 65 | 66 | /** \def UNIXEM_VER_MINOR 67 | * The minor version number of UNIXem 68 | */ 69 | 70 | /** \def UNIXEM_VER_PATCH 71 | * The patch (aka revision) version number of UNIXem 72 | */ 73 | 74 | /** \def UNIXEM_VER 75 | * The current composite version number of UNIXem 76 | */ 77 | 78 | #define UNIXEM_VER_MAJOR 1 79 | #define UNIXEM_VER_MINOR 12 80 | #define UNIXEM_VER_PATCH 8 81 | #define UNIXEM_VER_ALPHABETA 0x42 82 | 83 | #define UNIXEM_VER \ 84 | (0\ 85 | | ( UNIXEM_VER_MAJOR << 24 ) \ 86 | | ( UNIXEM_VER_MINOR << 16 ) \ 87 | | ( UNIXEM_VER_PATCH << 8 ) \ 88 | | ( UNIXEM_VER_ALPHABETA << 0 ) \ 89 | ) 90 | 91 | #define UNIXEM_VER_REVISION UNIXEM_VER_PATCH 92 | 93 | 94 | /* ////////////////////////////////////////////////////////////////////// */ 95 | 96 | #endif /* UNIXEM_INCL_UNIXEM_H_UNIXEM */ 97 | 98 | /* ///////////////////////////// end of file //////////////////////////// */ 99 | 100 | -------------------------------------------------------------------------------- /include/unixem/util/fs.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/util/fs.h 3 | * 4 | * Purpose: UNIXem.Util.FS header. 5 | * 6 | * Created: 11th May 2025 7 | * Updated: 12th May 2025 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2025, Matthew Wilson and Synesis Information Systems 12 | * All rights reserved. 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are 16 | * met: 17 | * 18 | * - Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * - Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 24 | * names of any contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 28 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 32 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 33 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 34 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | * ////////////////////////////////////////////////////////////////////// */ 40 | 41 | 42 | /** \file unixem/util/fs.h 43 | * 44 | * UNIXem.Util.FS header. 45 | */ 46 | 47 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_UTIL_H_FS 48 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_UTIL_H_FS 49 | 50 | /* ///////////////////////////////////////////////////////////////////////// 51 | * includes 52 | */ 53 | 54 | #include 55 | 56 | 57 | /* ///////////////////////////////////////////////////////////////////////// 58 | * API functions 59 | */ 60 | 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif /* __cplusplus */ 64 | 65 | 66 | 67 | /** Indicates whether the given character is a path separator (i.e. `'/'` or 68 | * `'\'`) 69 | * 70 | * \retval 0 The character is not a separator; 71 | * \retval 1 The character is a separator; 72 | */ 73 | int 74 | unixem_util_fs_char_is_path_sep(char ch); 75 | 76 | /** Indicates whether the given path refers to an existing file-system entry 77 | * that is a directory. 78 | * 79 | * \retval 0 `path` does not name a directory, or names a file-sytem entry 80 | * that is not a directory; 81 | * \retval 1 `path` names an existing directory; 82 | */ 83 | int 84 | unixem_util_fs_directory_exists(char const* path); 85 | 86 | /** Attempts to obtain the home directory. 87 | * 88 | * \param ar Pointer to an array of `char` of size 260 (=== _MAX_PATH); 89 | * \param pnumWritten Optional pointer to a variable to receive the number 90 | * of characters written (excluding the NUL terminator); 91 | * 92 | * \retval 0 The character is not a separator; 93 | * \retval 1 The character is a separator; 94 | */ 95 | int 96 | unixem_util_fs_get_home_directory( 97 | char (*ar)[260] 98 | , size_t* pnumWritten 99 | ); 100 | 101 | 102 | /* ////////////////////////////////////////////////////////////////////// */ 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif /* __cplusplus */ 107 | 108 | 109 | /* ////////////////////////////////////////////////////////////////////// */ 110 | 111 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_UTIL_H_FS */ 112 | 113 | /* ///////////////////////////// end of file //////////////////////////// */ 114 | 115 | -------------------------------------------------------------------------------- /include/unixem/util/str.h: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: unixem/util/str.h 3 | * 4 | * Purpose: UNIXem.Util.Str header. 5 | * 6 | * Created: 18th May 2025 7 | * Updated: 18th May 2025 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2025, Matthew Wilson and Synesis Information Systems 12 | * All rights reserved. 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions are 16 | * met: 17 | * 18 | * - Redistributions of source code must retain the above copyright notice, 19 | * this list of conditions and the following disclaimer. 20 | * - Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 24 | * names of any contributors may be used to endorse or promote products 25 | * derived from this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 28 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 32 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 33 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 34 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | * ////////////////////////////////////////////////////////////////////// */ 40 | 41 | 42 | /** \file unixem/util/str.h 43 | * 44 | * UNIXem.Util.Str header. 45 | */ 46 | 47 | #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_UTIL_H_STR 48 | #define SYNSOFT_UNIXEM_INCL_UNIXEM_UTIL_H_STR 49 | 50 | /* ///////////////////////////////////////////////////////////////////////// 51 | * includes 52 | */ 53 | 54 | 55 | /* ///////////////////////////////////////////////////////////////////////// 56 | * API functions 57 | */ 58 | 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif /* __cplusplus */ 62 | 63 | 64 | int 65 | unixem_util_str_begins_with( 66 | char const* s 67 | , char const* prefix 68 | ); 69 | 70 | int 71 | unixem_util_str_ends_with( 72 | char const* s 73 | , char const* suffix 74 | ); 75 | 76 | 77 | /* ////////////////////////////////////////////////////////////////////// */ 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif /* __cplusplus */ 82 | 83 | 84 | /* ////////////////////////////////////////////////////////////////////// */ 85 | 86 | #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_UTIL_H_STR */ 87 | 88 | /* ///////////////////////////// end of file //////////////////////////// */ 89 | 90 | -------------------------------------------------------------------------------- /remove_cmake_artefacts.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ScriptPath=$0 4 | Dir=$(cd $(dirname "$ScriptPath"); pwd) 5 | Basename=$(basename "$ScriptPath") 6 | CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build} 7 | 8 | Directories=( 9 | CMakeFiles 10 | Testing 11 | cmake 12 | examples 13 | projects 14 | src 15 | test 16 | ) 17 | Files=( 18 | CMakeCache.txt 19 | CTestTestfile.cmake 20 | DartConfiguration.tcl 21 | Makefile 22 | cmake_install.cmake 23 | install_manifest.txt 24 | ) 25 | 26 | 27 | # ########################################################## 28 | # operating environment detection 29 | 30 | OsName="$(uname -s)" 31 | case "${OsName}" in 32 | CYGWIN*|MINGW*|MSYS_NT*) 33 | 34 | Directories+=( 35 | ARM64 36 | Win32 37 | x64 38 | ) 39 | Files+=( 40 | "*.filters" 41 | "*.sln" 42 | "*.vcxproj" 43 | ) 44 | ;; 45 | *) 46 | 47 | ;; 48 | esac 49 | 50 | 51 | # ########################################################## 52 | # command-line handling 53 | 54 | while [[ $# -gt 0 ]]; do 55 | 56 | case $1 in 57 | --help) 58 | 59 | cat << EOF 60 | UNIXem is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code 61 | Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 62 | Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 63 | Removes all known CMake artefacts 64 | 65 | $ScriptPath [ ... flags/options ... ] 66 | 67 | Flags/options: 68 | 69 | behaviour: 70 | 71 | 72 | standard flags: 73 | 74 | --help 75 | displays this help and terminates 76 | 77 | EOF 78 | 79 | exit 0 80 | ;; 81 | *) 82 | 83 | >&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage" 84 | 85 | exit 1 86 | ;; 87 | esac 88 | 89 | shift 90 | done 91 | 92 | 93 | # ########################################################## 94 | # main() 95 | 96 | if [ ! -d "$CMakeDir" ]; then 97 | 98 | echo "$ScriptPath: CMake build directory '$CMakeDir' not found so nothing to do; use script 'prepare_cmake.sh' if you wish to prepare CMake artefacts" 99 | 100 | exit 0 101 | else 102 | 103 | echo "Removing all cmake artefacts in '$CMakeDir'" 104 | 105 | num_dirs_removed=0 106 | num_files_removed=0 107 | 108 | for d in ${Directories[@]} 109 | do 110 | 111 | fq_dir_path="$CMakeDir/$d" 112 | 113 | [ -d "$fq_dir_path" ] || continue 114 | 115 | echo "removing directory '$d'" 116 | 117 | rm -dfr "$fq_dir_path" 118 | 119 | num_dirs_removed=$((num_dirs_removed+1)) 120 | done 121 | 122 | cd "$CMakeDir" 123 | 124 | for f in ${Files[@]} 125 | do 126 | 127 | for fq_file_path in $f 128 | do 129 | 130 | [ -f "$fq_file_path" ] || continue 131 | 132 | echo "removing file '$fq_file_path'" 133 | 134 | rm -f "$fq_file_path" 135 | 136 | num_files_removed=$((num_files_removed+1)) 137 | done 138 | done 139 | 140 | cd ->/dev/null 141 | 142 | if [ 0 -eq $num_dirs_removed ] && [ 0 -eq $num_files_removed ]; then 143 | 144 | echo "nothing to do" 145 | else 146 | 147 | echo "removed $num_dirs_removed directories and $num_files_removed files" 148 | fi 149 | fi 150 | 151 | 152 | # ############################## end of file ############################# # 153 | 154 | -------------------------------------------------------------------------------- /run_all_examples.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ScriptPath=$0 4 | Dir=$(cd $(dirname "$ScriptPath"); pwd) 5 | Basename=$(basename "$ScriptPath") 6 | CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build} 7 | MakeCmd=${SIS_CMAKE_COMMAND:-make} 8 | 9 | ListOnly=0 10 | RunMake=1 11 | 12 | 13 | # ########################################################## 14 | # command-line handling 15 | 16 | while [[ $# -gt 0 ]]; do 17 | 18 | case $1 in 19 | -l|--list-only) 20 | 21 | ListOnly=1 22 | ;; 23 | -M|--no-make) 24 | 25 | RunMake=0 26 | ;; 27 | --help) 28 | 29 | cat << EOF 30 | UNIXem is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code 31 | Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 32 | Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 33 | Runs all example programs 34 | 35 | $ScriptPath [ ... flags/options ... ] 36 | 37 | Flags/options: 38 | 39 | behaviour: 40 | 41 | -l 42 | --list-only 43 | lists the target programs but does not execute them 44 | 45 | -M 46 | --no-make 47 | does not execute CMake and make before running tests 48 | 49 | 50 | standard flags: 51 | 52 | --help 53 | displays this help and terminates 54 | 55 | EOF 56 | 57 | exit 0 58 | ;; 59 | *) 60 | 61 | >&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage" 62 | 63 | exit 1 64 | ;; 65 | esac 66 | 67 | shift 68 | done 69 | 70 | 71 | # ########################################################## 72 | # main() 73 | 74 | status=0 75 | 76 | if [ $RunMake -ne 0 ]; then 77 | 78 | if [ $ListOnly -eq 0 ]; then 79 | 80 | echo "Executing build (via command \`$MakeCmd\`) and then running all example programs" 81 | 82 | mkdir -p $CMakeDir || exit 1 83 | 84 | cd $CMakeDir 85 | 86 | $MakeCmd 87 | status=$? 88 | 89 | cd ->/dev/null 90 | fi 91 | else 92 | 93 | if [ ! -d "$CMakeDir" ] || [ ! -f "$CMakeDir/CMakeCache.txt" ] || [ ! -d "$CMakeDir/CMakeFiles" ]; then 94 | 95 | >&2 echo "$ScriptPath: cannot run in '--no-make' mode without a previous successful build step" 96 | fi 97 | fi 98 | 99 | if [ $status -eq 0 ]; then 100 | 101 | if [ $ListOnly -ne 0 ]; then 102 | 103 | echo "Listing all example programs" 104 | else 105 | 106 | echo "Running all example programs" 107 | fi 108 | 109 | for f in $(find $CMakeDir -type f '(' -name 'example.c.*' -o -name 'example.cpp.*' ')' -exec test -x {} \; -print) 110 | do 111 | 112 | if [ $ListOnly -ne 0 ]; then 113 | 114 | echo "would execute $f:" 115 | 116 | continue 117 | fi 118 | 119 | echo 120 | echo "executing $f:" 121 | 122 | # NOTE: we do not break on fail, because, this being a unit-testing library, the scratch-tests actually fail 123 | $f 124 | done 125 | fi 126 | 127 | exit $status 128 | 129 | 130 | # ############################## end of file ############################# # 131 | 132 | -------------------------------------------------------------------------------- /run_all_scratch_tests.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ScriptPath=$0 4 | Dir=$(cd $(dirname "$ScriptPath"); pwd) 5 | Basename=$(basename "$ScriptPath") 6 | CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build} 7 | MakeCmd=${SIS_CMAKE_COMMAND:-make} 8 | 9 | ListOnly=0 10 | RunMake=1 11 | 12 | 13 | # ########################################################## 14 | # command-line handling 15 | 16 | while [[ $# -gt 0 ]]; do 17 | 18 | case $1 in 19 | -l|--list-only) 20 | 21 | ListOnly=1 22 | ;; 23 | -M|--no-make) 24 | 25 | RunMake=0 26 | ;; 27 | --help) 28 | 29 | cat << EOF 30 | UNIXem is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code 31 | Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 32 | Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 33 | Runs all (matching) scratch-test programs 34 | 35 | $ScriptPath [ ... flags/options ... ] 36 | 37 | Flags/options: 38 | 39 | behaviour: 40 | 41 | -l 42 | --list-only 43 | lists the target programs but does not execute them 44 | 45 | -M 46 | --no-make 47 | does not execute CMake and make before running tests 48 | 49 | 50 | standard flags: 51 | 52 | --help 53 | displays this help and terminates 54 | 55 | EOF 56 | 57 | exit 0 58 | ;; 59 | *) 60 | 61 | >&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage" 62 | 63 | exit 1 64 | ;; 65 | esac 66 | 67 | shift 68 | done 69 | 70 | 71 | # ########################################################## 72 | # main() 73 | 74 | status=0 75 | 76 | if [ $RunMake -ne 0 ]; then 77 | 78 | if [ $ListOnly -eq 0 ]; then 79 | 80 | echo "Executing build (via command \`$MakeCmd\`) and then running all scratch test programs" 81 | 82 | mkdir -p $CMakeDir || exit 1 83 | 84 | cd $CMakeDir 85 | 86 | $MakeCmd 87 | status=$? 88 | 89 | cd ->/dev/null 90 | fi 91 | else 92 | 93 | if [ ! -d "$CMakeDir" ] || [ ! -f "$CMakeDir/CMakeCache.txt" ] || [ ! -d "$CMakeDir/CMakeFiles" ]; then 94 | 95 | >&2 echo "$ScriptPath: cannot run in '--no-make' mode without a previous successful build step" 96 | fi 97 | fi 98 | 99 | if [ $status -eq 0 ]; then 100 | 101 | if [ $ListOnly -ne 0 ]; then 102 | 103 | echo "Listing all scratch test programs" 104 | else 105 | 106 | echo "Running all scratch test programs" 107 | fi 108 | 109 | for f in $(find $CMakeDir -type f '(' -name 'test_scratch*' -o -name 'test.scratch.*' ')' -exec test -x {} \; -print) 110 | do 111 | 112 | if [ $ListOnly -ne 0 ]; then 113 | 114 | echo "would execute $f:" 115 | 116 | continue 117 | fi 118 | 119 | echo 120 | echo "executing $f:" 121 | 122 | if $f; then 123 | 124 | : 125 | else 126 | 127 | status=$? 128 | fi 129 | done 130 | fi 131 | 132 | exit $status 133 | 134 | 135 | # ############################## end of file ############################# # 136 | 137 | -------------------------------------------------------------------------------- /run_all_unit_tests.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ScriptPath=$0 4 | Dir=$(cd $(dirname "$ScriptPath"); pwd) 5 | Basename=$(basename "$ScriptPath") 6 | CMakeDir=${SIS_CMAKE_BUILD_DIR:-$Dir/_build} 7 | MakeCmd=${SIS_CMAKE_COMMAND:-make} 8 | 9 | ListOnly=0 10 | RunMake=1 11 | Verbosity=3 12 | 13 | 14 | # ########################################################## 15 | # command-line handling 16 | 17 | while [[ $# -gt 0 ]]; do 18 | 19 | case $1 in 20 | -l|--list-only) 21 | 22 | ListOnly=1 23 | ;; 24 | -M|--no-make) 25 | 26 | RunMake=0 27 | ;; 28 | --verbosity) 29 | 30 | shift 31 | Verbosity=$1 32 | ;; 33 | --help) 34 | 35 | cat << EOF 36 | UNIXem is a small and simple library that provides emulation of several popular Unix API functions on the Windows platform. Its primary purpose is to assist Windows programmers who are porting to Unix or are writing multi-platform code 37 | Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 38 | Copyright (c) 2002-2019, Matthew Wilson and Synesis Software 39 | Runs all (matching) unit-test programs 40 | 41 | $ScriptPath [ ... flags/options ... ] 42 | 43 | Flags/options: 44 | 45 | behaviour: 46 | 47 | -l 48 | --list-only 49 | lists the target programs but does not execute them 50 | 51 | -M 52 | --no-make 53 | does not execute CMake and make before running tests 54 | 55 | --verbosity 56 | specifies an explicit verbosity for the unit-test(s) 57 | 58 | 59 | standard flags: 60 | 61 | --help 62 | displays this help and terminates 63 | 64 | EOF 65 | 66 | exit 0 67 | ;; 68 | *) 69 | 70 | >&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage" 71 | 72 | exit 1 73 | ;; 74 | esac 75 | 76 | shift 77 | done 78 | 79 | 80 | # ########################################################## 81 | # main() 82 | 83 | status=0 84 | 85 | if [ $RunMake -ne 0 ]; then 86 | 87 | if [ $ListOnly -eq 0 ]; then 88 | 89 | echo "Executing build (via command \`$MakeCmd\`) and then running all component and unit test programs" 90 | 91 | mkdir -p $CMakeDir || exit 1 92 | 93 | cd $CMakeDir 94 | 95 | $MakeCmd 96 | status=$? 97 | 98 | cd ->/dev/null 99 | fi 100 | else 101 | 102 | if [ ! -d "$CMakeDir" ] || [ ! -f "$CMakeDir/CMakeCache.txt" ] || [ ! -d "$CMakeDir/CMakeFiles" ]; then 103 | 104 | >&2 echo "$ScriptPath: cannot run in '--no-make' mode without a previous successful build step" 105 | fi 106 | fi 107 | 108 | if [ $status -eq 0 ]; then 109 | 110 | if [ $ListOnly -ne 0 ]; then 111 | 112 | echo "Listing all component and unit test programs" 113 | else 114 | 115 | echo "Running all component and unit test programs" 116 | fi 117 | 118 | for f in $(find $CMakeDir -type f '(' -name 'test_unit*' -o -name 'test.unit.*' -o -name 'test_component*' -o -name 'test.component.*' ')' -exec test -x {} \; -print) 119 | do 120 | 121 | if [ $ListOnly -ne 0 ]; then 122 | 123 | echo "would execute $f:" 124 | 125 | continue 126 | fi 127 | 128 | if [ $Verbosity -ge 3 ]; then 129 | 130 | echo 131 | fi 132 | if [ $Verbosity -ge 2 ]; then 133 | 134 | echo "executing $f:" 135 | fi 136 | 137 | if $f --verbosity=$Verbosity; then 138 | 139 | : 140 | else 141 | 142 | status=$? 143 | 144 | break 1 145 | fi 146 | done 147 | fi 148 | 149 | exit $status 150 | 151 | 152 | # ############################## end of file ############################# # 153 | 154 | -------------------------------------------------------------------------------- /src/atomic.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: atomic.c 3 | * 4 | * Purpose: Implementation of Linux like atomic functions for the 5 | * Windows platform. 6 | * 7 | * Created: 21st November 2003 8 | * Updated: 1st May 2025 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2003-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are 18 | * met: 19 | * 20 | * - Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * - Redistributions in binary form must reproduce the above copyright 23 | * notice, this list of conditions and the following disclaimer in the 24 | * documentation and/or other materials provided with the distribution. 25 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 26 | * names of any contributors may be used to endorse or promote products 27 | * derived from this software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 30 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 34 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 35 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * ////////////////////////////////////////////////////////////////////// */ 42 | 43 | 44 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 45 | # define _SYNSOFT_VER_C_ATOMIC_MAJOR 3 46 | # define _SYNSOFT_VER_C_ATOMIC_MINOR 0 47 | # define _SYNSOFT_VER_C_ATOMIC_REVISION 1 48 | # define _SYNSOFT_VER_C_ATOMIC_EDIT 21 49 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 50 | 51 | 52 | /* ///////////////////////////////////////////////////////////////////////// 53 | * includes 54 | */ 55 | 56 | #include 57 | 58 | #include 59 | 60 | #include 61 | #include 62 | 63 | 64 | /* ///////////////////////////////////////////////////////////////////////// 65 | * compatibility 66 | */ 67 | 68 | #ifndef WIN32 69 | # error This file is only currently defined for Windows compilation units 70 | #endif /* WIN32 */ 71 | 72 | 73 | /* ///////////////////////////////////////////////////////////////////////// 74 | * constants and definitions 75 | */ 76 | 77 | 78 | /* ///////////////////////////////////////////////////////////////////////// 79 | * API functions 80 | */ 81 | 82 | void unixem_atomic_set(unixem_atomic_t volatile* v, int i) 83 | { 84 | (void)InterlockedExchange((LPLONG)v, i); 85 | } 86 | 87 | int unixem_atomic_read(unixem_atomic_t volatile* v) 88 | { 89 | return *v; 90 | } 91 | 92 | void unixem_atomic_add(int i, unixem_atomic_t volatile* v) 93 | { 94 | (void)InterlockedExchangeAdd((LPLONG)v, i); 95 | } 96 | 97 | void unixem_atomic_sub(int i, unixem_atomic_t volatile* v) 98 | { 99 | (void)InterlockedExchangeAdd((LPLONG)v, -i); 100 | } 101 | 102 | void unixem_atomic_inc(unixem_atomic_t volatile* v) 103 | { 104 | (void)InterlockedIncrement((LPLONG)v); 105 | } 106 | 107 | void unixem_atomic_dec(unixem_atomic_t volatile* v) 108 | { 109 | (void)InterlockedDecrement((LPLONG)v); 110 | } 111 | 112 | int unixem_atomic_inc_and_test(unixem_atomic_t volatile* v) 113 | { 114 | return -1 + InterlockedIncrement((LPLONG)v); 115 | } 116 | 117 | int unixem_atomic_dec_and_test(unixem_atomic_t volatile* v) 118 | { 119 | return 1 + InterlockedDecrement((LPLONG)v); 120 | } 121 | 122 | int unixem_atomic_add_and_test(int i, unixem_atomic_t volatile* v); 123 | 124 | int unixem_atomic_sub_and_test(int i, unixem_atomic_t volatile* v); 125 | 126 | 127 | /* ///////////////////////////// end of file //////////////////////////// */ 128 | 129 | -------------------------------------------------------------------------------- /src/hostname.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: hostname.c 3 | * 4 | * Purpose: Implementation of the gethostname() function. 5 | * 6 | * Created: 20th April 2008 7 | * Updated: 10th July 2024 8 | * 9 | * Home: https://github.com/synesissoftware/UNIXem 10 | * 11 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 12 | * Copyright (c) 2008-2019, Matthew Wilson and Synesis Software 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are 17 | * met: 18 | * 19 | * - Redistributions of source code must retain the above copyright notice, 20 | * this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 25 | * names of any contributors may be used to endorse or promote products 26 | * derived from this software without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 29 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 30 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 32 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 33 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 34 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 36 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ////////////////////////////////////////////////////////////////////// */ 41 | 42 | 43 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 44 | # define _SYNSOFT_VER_C_HOSTNAME_MAJOR 2 45 | # define _SYNSOFT_VER_C_HOSTNAME_MINOR 0 46 | # define _SYNSOFT_VER_C_HOSTNAME_REVISION 1 47 | # define _SYNSOFT_VER_C_HOSTNAME_EDIT 9 48 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 49 | 50 | 51 | /* ///////////////////////////////////////////////////////////////////////// 52 | * includes 53 | */ 54 | 55 | #include 56 | 57 | #include 58 | #include 59 | #include 60 | 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | 67 | /* ///////////////////////////////////////////////////////////////////////// 68 | * API functions 69 | */ 70 | 71 | int __stdcall unixem_gethostname( 72 | char* name 73 | , size_t cchName 74 | ) 75 | { 76 | DWORD cchName_; 77 | 78 | assert(0 == cchName || NULL != name); 79 | 80 | cchName_ = (DWORD)cchName; 81 | 82 | if (!GetComputerNameA(name, &cchName_)) 83 | { 84 | if (ERROR_BUFFER_OVERFLOW != GetLastError()) 85 | { 86 | errno = unixem_internal_errno_from_Win32(GetLastError()); 87 | 88 | return -1; 89 | } 90 | else 91 | { 92 | errno = ENAMETOOLONG; 93 | } 94 | } 95 | #if 0 96 | else 97 | { 98 | errno = 0; 99 | } 100 | #endif /* 0 */ 101 | 102 | return 0; 103 | } 104 | 105 | 106 | /* ///////////////////////////// end of file //////////////////////////// */ 107 | 108 | -------------------------------------------------------------------------------- /src/resource.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: resource.c 3 | * 4 | * Purpose: Implementation of the getrusage() API function for the Windows 5 | * platform. 6 | * 7 | * Created: 9th June 2006 8 | * Updated: 28th November 2024 9 | * 10 | * Home: https://github.com/synesissoftware/UNIXem 11 | * 12 | * Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems 13 | * Copyright (c) 2006-2019, Matthew Wilson and Synesis Software 14 | * All rights reserved. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions are 18 | * met: 19 | * 20 | * - Redistributions of source code must retain the above copyright notice, 21 | * this list of conditions and the following disclaimer. 22 | * - Redistributions in binary form must reproduce the above copyright 23 | * notice, this list of conditions and the following disclaimer in the 24 | * documentation and/or other materials provided with the distribution. 25 | * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 26 | * names of any contributors may be used to endorse or promote products 27 | * derived from this software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 30 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 32 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 33 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 34 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 35 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | * ////////////////////////////////////////////////////////////////////// */ 42 | 43 | 44 | #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 45 | # define SYNSOFT_UNIXEM_VER_SYS_C_USAGE_MAJOR 2 46 | # define SYNSOFT_UNIXEM_VER_SYS_C_USAGE_MINOR 0 47 | # define SYNSOFT_UNIXEM_VER_SYS_C_USAGE_REVISION 1 48 | # define SYNSOFT_UNIXEM_VER_SYS_C_USAGE_EDIT 10 49 | #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 50 | 51 | 52 | /* ///////////////////////////////////////////////////////////////////////// 53 | * includes 54 | */ 55 | 56 | /* If we're going to include 'windows.h', then it has to be included first, 57 | * so as to put off the defintion of timeval in sys/time.h. Regrettably, the 58 | * WinSock header defines it without any conception of sys/time.h. Thanks MS! 59 | */ 60 | #ifndef __MWERKS__ 61 | # include 62 | #endif /* !__MWERKS__ */ 63 | 64 | #include 65 | 66 | #include 67 | #include 68 | 69 | #include 70 | #include 71 | #include 72 | 73 | 74 | /* ///////////////////////////////////////////////////////////////////////// 75 | * helper functions 76 | */ 77 | 78 | 79 | /* ///////////////////////////////////////////////////////////////////////// 80 | * API functions 81 | */ 82 | 83 | int unixem_getrusage( 84 | int who 85 | , struct unixem_rusage* r_usage 86 | ) 87 | { 88 | assert(NULL != r_usage); 89 | 90 | if (UNIXEM_RUSAGE_SELF != who) 91 | { 92 | errno = EINVAL; 93 | 94 | return -1; 95 | } 96 | else 97 | { 98 | ULARGE_INTEGER kernelTime; 99 | ULARGE_INTEGER userTime; 100 | FILETIME dummy; 101 | 102 | if (!GetProcessTimes(GetCurrentProcess(), &dummy, &dummy, (LPFILETIME)&kernelTime, (LPFILETIME)&userTime)) 103 | { 104 | errno = unixem_internal_errno_from_Win32(GetLastError()); 105 | 106 | return -1; 107 | } 108 | else 109 | { 110 | r_usage->ru_stime.tv_sec = (long)(0x7fffffff & (unsigned long)kernelTime.QuadPart / 10000000); 111 | r_usage->ru_utime.tv_sec = (long)(0x7fffffff & (unsigned long)userTime.QuadPart / 10000000); 112 | 113 | r_usage->ru_stime.tv_usec = (long)(0x7fffffff & (unsigned long)((kernelTime.QuadPart % 10000000) / 10)); 114 | r_usage->ru_utime.tv_usec = (long)(0x7fffffff & (unsigned long)((userTime.QuadPart % 10000000) / 10)); 115 | 116 | return 0; 117 | } 118 | } 119 | } 120 | 121 | 122 | /* ///////////////////////////// end of file //////////////////////////// */ 123 | 124 | -------------------------------------------------------------------------------- /src/util_fs.c: -------------------------------------------------------------------------------- 1 | 2 | /* ///////////////////////////////////////////////////////////////////////// 3 | * includes 4 | */ 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | 14 | /* ///////////////////////////////////////////////////////////////////////// 15 | * API functions 16 | */ 17 | 18 | int 19 | unixem_util_fs_char_is_path_sep(char ch) 20 | { 21 | switch (ch) 22 | { 23 | case '/': 24 | case '\\': 25 | 26 | return 1; 27 | default: 28 | 29 | return 0; 30 | } 31 | } 32 | 33 | int 34 | unixem_util_fs_directory_exists(char const* path) 35 | { 36 | DWORD const fa = GetFileAttributesA(path); 37 | 38 | if (INVALID_FILE_ATTRIBUTES == fa) 39 | { 40 | /* no such entry */ 41 | 42 | return 0; 43 | } 44 | else 45 | { 46 | if (0 != (FILE_ATTRIBUTE_DIRECTORY & fa)) 47 | { 48 | return 1; 49 | } 50 | else 51 | { 52 | return 0; 53 | } 54 | } 55 | } 56 | 57 | int 58 | unixem_util_fs_get_home_directory( 59 | char (*ar)[_MAX_PATH] 60 | , size_t* pnumWritten 61 | ) 62 | { 63 | size_t dummy; 64 | 65 | if (NULL == pnumWritten) 66 | { 67 | pnumWritten = &dummy; 68 | } 69 | 70 | (*ar)[0] = '\0'; 71 | *pnumWritten = 0; 72 | 73 | /* First, try "%USERPROFILE%" */ 74 | DWORD const dw_up = GetEnvironmentVariableA("USERPROFILE", &(*ar)[0], _MAX_PATH); 75 | 76 | if (0 == dw_up) 77 | { 78 | // DWORD const le_up = GetLastError(); 79 | 80 | SetLastError(0); 81 | 82 | /* Second, try "%HOMEDRIVE%%HOMEPATH%" 83 | * 84 | * Because `ExpandEnvironmentStringsA()` requires 1 extra byte for a 85 | * terminating NUL we try into the given _MAX_PATH-length buffer and 86 | * take the (very slight) "risk" of having to repeat into a buffer 87 | * of length (1+_MAX_PATH) and then copying back in. 88 | */ 89 | 90 | DWORD const dw_ees = ExpandEnvironmentStringsA("%HOMEDRIVE%%HOMEPATH%", &(*ar)[0], _MAX_PATH); 91 | 92 | if (0 == dw_ees) 93 | { 94 | env_var_not_found: 95 | 96 | { 97 | DWORD const le = ERROR_ENVVAR_NOT_FOUND; 98 | 99 | SetLastError(le); 100 | 101 | errno = unixem_internal_errno_from_Win32(le); 102 | 103 | return 0; 104 | } 105 | } 106 | else 107 | { 108 | if (dw_ees > _MAX_PATH + 1) 109 | { 110 | insufficient_buffer: 111 | 112 | { 113 | DWORD const le = ERROR_INSUFFICIENT_BUFFER; 114 | 115 | SetLastError(le); 116 | 117 | errno = unixem_internal_errno_from_Win32(le); 118 | 119 | return 0; 120 | } 121 | } 122 | else 123 | if (dw_ees == _MAX_PATH + 1) 124 | { 125 | /* NODE: `ExpandEnvironmentStringsA()` requires buffer of len + 1 + 1 */ 126 | 127 | char ar2[_MAX_PATH + 1]; 128 | DWORD const dw_ees2 = ExpandEnvironmentStringsA("%HOMEDRIVE%%HOMEPATH%", &ar2[0], _MAX_PATH + 1); 129 | 130 | if (0 == dw_ees2) 131 | { 132 | goto env_var_not_found; 133 | } 134 | else if (dw_ees2 > _MAX_PATH) 135 | { 136 | goto insufficient_buffer; 137 | } 138 | if (0 != unixem_util_str_begins_with(&ar2[0], "%HOMEDRIVE%") || 139 | 0 != unixem_util_str_ends_with(&ar2[0], "%HOMEPATH%")) 140 | { 141 | goto env_var_not_found; 142 | } 143 | else 144 | { 145 | CopyMemory(&(*ar)[0], &ar2[0], _MAX_PATH * sizeof(ar2[0])); 146 | 147 | *pnumWritten = dw_ees2 - 1; 148 | } 149 | } 150 | else 151 | if (0 != unixem_util_str_begins_with(&(*ar)[0], "%HOMEDRIVE%") || 152 | 0 != unixem_util_str_ends_with(&(*ar)[0], "%HOMEPATH%")) 153 | { 154 | goto env_var_not_found; 155 | } 156 | else 157 | { 158 | *pnumWritten = dw_ees - 1; 159 | } 160 | 161 | // if (ERROR_ENVVAR_NOT_FOUND == GetLastError() && 162 | // ERROR_ENVVAR_NOT_FOUND == le_up) 163 | // { 164 | // SetLastError(0); 165 | // } 166 | 167 | } 168 | } 169 | else 170 | { 171 | if (dw_up >= _MAX_PATH) 172 | { 173 | SetLastError(ERROR_INSUFFICIENT_BUFFER); 174 | } 175 | else 176 | { 177 | *pnumWritten = dw_up; 178 | } 179 | } 180 | 181 | return 1; 182 | } 183 | 184 | 185 | /* ///////////////////////////// end of file //////////////////////////// */ 186 | 187 | -------------------------------------------------------------------------------- /src/util_str.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | 8 | int 9 | unixem_util_str_begins_with( 10 | char const* s 11 | , char const* prefix 12 | ) 13 | { 14 | assert(NULL != s); 15 | assert(NULL != prefix); 16 | 17 | { 18 | size_t const len_prefix = strlen(prefix); 19 | 20 | return 0 == strncmp(s, prefix, len_prefix); 21 | } 22 | } 23 | 24 | int 25 | unixem_util_str_ends_with( 26 | char const* s 27 | , char const* suffix 28 | ) 29 | { 30 | assert(NULL != s); 31 | assert(NULL != suffix); 32 | 33 | { 34 | size_t const len_s = strlen(s); 35 | size_t const len_suffix = strlen(suffix); 36 | 37 | if (len_s < len_suffix) 38 | { 39 | return 0; 40 | } 41 | else 42 | { 43 | return 0 == strcmp(s + (len_s - len_suffix), suffix); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(${CMAKE_SOURCE_DIR}/include) 3 | 4 | if(WIN32) 5 | 6 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 7 | 8 | message(STATUS "Compiling for 64-bit Windows") 9 | 10 | add_definitions(-DWIN64) 11 | else() 12 | 13 | message(STATUS "Compiling for 32-bit Windows") 14 | 15 | add_definitions(-DWIN32) 16 | endif() 17 | 18 | # suppress implicit-link file 19 | add_definitions(-DUNIXEM_INCL_UNIXEM_H_IMPLICIT_LINK) 20 | endif(WIN32) 21 | 22 | 23 | add_subdirectory(component) 24 | add_subdirectory(scratch) 25 | add_subdirectory(unit) 26 | 27 | 28 | # ############################## end of file ############################# # 29 | 30 | -------------------------------------------------------------------------------- /test/component/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_subdirectory(test.component.dirent) 3 | add_subdirectory(test.component.glob) 4 | add_subdirectory(test.component.unistd.mkdtemp) 5 | add_subdirectory(test.component.unistd.mkstemp) 6 | add_subdirectory(test.component.unistd.usleep) 7 | -------------------------------------------------------------------------------- /test/component/test.component.dirent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.component.dirent entry.cpp) 3 | -------------------------------------------------------------------------------- /test/component/test.component.glob/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.component.glob entry.cpp) 3 | -------------------------------------------------------------------------------- /test/component/test.component.glob/implicit_link.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* UNIXem header files */ 3 | #include 4 | 5 | /* xTests header files */ 6 | #include 7 | 8 | 9 | /* ///////////////////////////// end of file //////////////////////////// */ 10 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.mkdtemp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.component.unistd.mkdtemp entry.c) 3 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.mkdtemp/entry.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Created: ... 4 | * Updated: 18th May 2025 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | 16 | int main(int argc, char** argv) 17 | { 18 | int retCode = EXIT_SUCCESS; 19 | int verbosity = 2; 20 | 21 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 22 | 23 | if (XTESTS_START_RUNNER("test.component.unistd.mkdtemp", verbosity)) 24 | { 25 | /* Test-1 */ 26 | if (XTESTS_CASE_BEGIN("Test-1", "testing mkdtemp in local directory")) 27 | { 28 | char template_path[] = "abc.XXX"; 29 | char const* r = mkdtemp(template_path); 30 | 31 | if (NULL == r) 32 | { 33 | int const e = errno; 34 | 35 | fprintf(stderr, "mkdtemp() failed to create '%s': %s (%d)\n", template_path, strerror(e), e); 36 | } 37 | else 38 | { 39 | size_t const len = strlen(template_path); 40 | 41 | rmdir(template_path); 42 | 43 | XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(7u, len)); 44 | XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N("abc.", template_path, 4u); 45 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 3])); 46 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 2])); 47 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 1])); 48 | } 49 | 50 | XTESTS_CASE_END("Test-1"); 51 | } 52 | 53 | /* Test-2 */ 54 | if (XTESTS_CASE_BEGIN("Test-2", "testing mkdtemp in specific directory")) 55 | { 56 | if (unixem_util_fs_directory_exists("C:\\temp")) 57 | { 58 | char template_path[] = "C:\\temp\\abc.XXXX"; 59 | char const* r = mkdtemp(template_path); 60 | 61 | if (NULL == r) 62 | { 63 | int const e = errno; 64 | 65 | fprintf(stderr, "mkdtemp() failed to create '%s': %s (%d)\n", template_path, strerror(e), e); 66 | } 67 | else 68 | { 69 | size_t const len = strlen(template_path); 70 | 71 | rmdir(template_path); 72 | 73 | XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(16u, len)); 74 | XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N("C:\\temp\\abc.", template_path, 12u); 75 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 4])); 76 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 3])); 77 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 2])); 78 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 1])); 79 | } 80 | } 81 | 82 | XTESTS_CASE_END("Test-2"); 83 | } 84 | 85 | XTESTS_PRINT_RESULTS(); 86 | 87 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 88 | } 89 | 90 | return retCode; 91 | } 92 | 93 | 94 | /* ///////////////////////////// end of file //////////////////////////// */ 95 | 96 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.mkdtemp/implicit_link.c: -------------------------------------------------------------------------------- 1 | 2 | /* UNIXem header files */ 3 | #include 4 | 5 | /* xTests header files */ 6 | #include 7 | 8 | 9 | /* ///////////////////////////// end of file //////////////////////////// */ 10 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.mkstemp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.component.unistd.mkstemp entry.c) 3 | 4 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.mkstemp/entry.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Created: ... 4 | * Updated: 18th May 2025 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | 16 | int main(int argc, char** argv) 17 | { 18 | int retCode = EXIT_SUCCESS; 19 | int verbosity = 2; 20 | 21 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 22 | 23 | if (XTESTS_START_RUNNER("test.component.unistd.mkstemp", verbosity)) 24 | { 25 | /* Test-1 */ 26 | if (XTESTS_CASE_BEGIN("Test-1", "testing mkstemp in local directory")) 27 | { 28 | char template_path[] = "abc.XXX"; 29 | int const r = mkstemp(template_path); 30 | 31 | if (-1 == r) 32 | { 33 | int const e = errno; 34 | 35 | fprintf(stderr, "mkstemp() failed to create '%s': %s (%d)\n", template_path, strerror(e), e); 36 | } 37 | else 38 | { 39 | size_t const len = strlen(template_path); 40 | 41 | unixem_close(r); 42 | unlink(template_path); 43 | 44 | XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(7u, len)); 45 | XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N("abc.", template_path, 4u); 46 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 3])); 47 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 2])); 48 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 1])); 49 | } 50 | 51 | XTESTS_CASE_END("Test-1"); 52 | } 53 | 54 | /* Test-2 */ 55 | if (XTESTS_CASE_BEGIN("Test-2", "testing mkstemp in specific directory")) 56 | { 57 | if (unixem_util_fs_directory_exists("C:\\temp")) 58 | { 59 | char template_path[] = "C:\\temp\\abc.XXXX"; 60 | int const r = mkstemp(template_path); 61 | 62 | if (-1 == r) 63 | { 64 | int const e = errno; 65 | 66 | fprintf(stderr, "mkstemp() failed to create '%s': %s (%d)\n", template_path, strerror(e), e); 67 | } 68 | else 69 | { 70 | size_t const len = strlen(template_path); 71 | 72 | unixem_close(r); 73 | unlink(template_path); 74 | 75 | XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(16u, len)); 76 | XTESTS_TEST_MULTIBYTE_STRING_EQUAL_N("C:\\temp\\abc.", template_path, 12u); 77 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 4])); 78 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 3])); 79 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 2])); 80 | XTESTS_TEST_BOOLEAN_TRUE(isdigit(template_path[len - 1])); 81 | } 82 | } 83 | 84 | 85 | XTESTS_CASE_END("Test-2"); 86 | } 87 | 88 | XTESTS_PRINT_RESULTS(); 89 | 90 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 91 | } 92 | 93 | return retCode; 94 | } 95 | 96 | 97 | /* ///////////////////////////// end of file //////////////////////////// */ 98 | 99 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.mkstemp/implicit_link.c: -------------------------------------------------------------------------------- 1 | 2 | /* UNIXem header files */ 3 | #include 4 | 5 | /* xTests header files */ 6 | #include 7 | 8 | 9 | /* ///////////////////////////// end of file //////////////////////////// */ 10 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.usleep/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.component.unistd.usleep entry.cpp) 3 | -------------------------------------------------------------------------------- /test/component/test.component.unistd.usleep/entry.cpp: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.component.unistd.usleep/entry.cpp 3 | * 4 | * Purpose: Unit-test of `usleep()`. 5 | * 6 | * Created: 29th November 2024 7 | * Updated: 29th November 2024 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* ///////////////////////////////////////////////////////////////////////// 13 | * includes 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | /* ///////////////////////////////////////////////////////////////////////// 26 | * forward declarations 27 | */ 28 | 29 | namespace 30 | { 31 | 32 | void TEST_TIME_ZERO(); 33 | void TEST_S_1(); 34 | void TEST_MS_100(); 35 | } // anonymous namespace 36 | 37 | 38 | /* ///////////////////////////////////////////////////////////////////////// 39 | * main() 40 | */ 41 | 42 | int main(int argc, char **argv) 43 | { 44 | int retCode = EXIT_SUCCESS; 45 | int verbosity = 2; 46 | 47 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 48 | 49 | if (XTESTS_START_RUNNER("test.component.unistd.usleep", verbosity)) 50 | { 51 | XTESTS_RUN_CASE(TEST_TIME_ZERO); 52 | XTESTS_RUN_CASE(TEST_S_1); 53 | XTESTS_RUN_CASE(TEST_MS_100); 54 | 55 | XTESTS_PRINT_RESULTS(); 56 | 57 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 58 | } 59 | 60 | return retCode; 61 | } 62 | 63 | 64 | /* ///////////////////////////////////////////////////////////////////////// 65 | * test function implementations 66 | */ 67 | 68 | namespace 69 | { 70 | 71 | void TEST_TIME_ZERO() 72 | { 73 | platformstl::stopwatch sw; 74 | stlsoft::doomgram gram; 75 | 76 | { 77 | stlsoft::gram_scope< 78 | stlsoft::doomgram 79 | , platformstl::stopwatch 80 | > scope(gram, sw); 81 | 82 | usleep(0); 83 | } 84 | 85 | platformstl::stopwatch::interval_type const total_time_ns = gram.total_event_time_ns_raw(); 86 | 87 | XTESTS_TEST_INTEGER_GREATER_OR_EQUAL(0, total_time_ns); 88 | XTESTS_TEST_INTEGER_LESS_OR_EQUAL(100000, total_time_ns); 89 | } 90 | 91 | void TEST_S_1() 92 | { 93 | platformstl::stopwatch sw; 94 | stlsoft::doomgram gram; 95 | 96 | { 97 | stlsoft::gram_scope< 98 | stlsoft::doomgram 99 | , platformstl::stopwatch 100 | > scope(gram, sw); 101 | 102 | usleep(1000000); 103 | } 104 | 105 | platformstl::stopwatch::interval_type const total_time_ns = gram.total_event_time_ns_raw(); 106 | 107 | XTESTS_TEST_INTEGER_GREATER_OR_EQUAL(1000000000, total_time_ns); 108 | XTESTS_TEST_INTEGER_LESS_OR_EQUAL(1100000000, total_time_ns); 109 | } 110 | 111 | void TEST_MS_100() 112 | { 113 | platformstl::stopwatch sw; 114 | stlsoft::doomgram gram; 115 | 116 | { 117 | stlsoft::gram_scope< 118 | stlsoft::doomgram 119 | , platformstl::stopwatch 120 | > scope(gram, sw); 121 | 122 | usleep(100000); 123 | } 124 | 125 | platformstl::stopwatch::interval_type const total_time_ns = gram.total_event_time_ns_raw(); 126 | 127 | XTESTS_TEST_INTEGER_GREATER_OR_EQUAL(100000000, total_time_ns); 128 | XTESTS_TEST_INTEGER_LESS_OR_EQUAL(150000000, total_time_ns); 129 | } 130 | } // anonymous namespace 131 | 132 | 133 | /* ///////////////////////////// end of file //////////////////////////// */ 134 | 135 | -------------------------------------------------------------------------------- /test/scratch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_subdirectory(test.scratch.dlfcn) 3 | #[====[ 4 | add_subdirectory(test.scratch.fnmatch) 5 | ]====] 6 | add_subdirectory(test.scratch.getrusage) 7 | add_subdirectory(test.scratch.link) 8 | #[====[ 9 | add_subdirectory(test.scratch.mmap) 10 | ]====] 11 | add_subdirectory(test.scratch.setenv) 12 | add_subdirectory(test.scratch.syslog) 13 | add_subdirectory(test.scratch.uio) 14 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.dlfcn/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_example_program(test.scratch.dlfcn test.scratch.dlfcn.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.dlfcn/test.scratch.dlfcn.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.dlfcn.c 3 | * 4 | * Purpose: Unit-test of `dlopen()`, `dlsym()`, `dlclose()`. 5 | * 6 | * Created: 1st January 2004 7 | * Updated: 16th October 2024 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* ///////////////////////////////////////////////////////////////////////// 13 | * includes 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | 24 | /* ///////////////////////////////////////////////////////////////////////// 25 | * main() 26 | */ 27 | 28 | int main(int argc, char *argv[]) 29 | { 30 | char const* const program_name = platformstl_C_get_executable_name_from_path(argv[0]).ptr; 31 | 32 | { int i; for (i = 1; i != argc; ++i) 33 | { 34 | if (0 == strcmp("--help", argv[i])) 35 | { 36 | printf("USAGE: %s \n", program_name); 37 | 38 | return EXIT_SUCCESS; 39 | } 40 | }} 41 | 42 | switch (argc) 43 | { 44 | case 1: 45 | case 2: 46 | 47 | fprintf(stderr, "%s: missing arguments; use --help for usage\n", program_name); 48 | 49 | return EXIT_FAILURE; 50 | case 3: 51 | 52 | break; 53 | default: 54 | 55 | fprintf(stderr, "%s: too many arguments; use --help for usage\n", program_name); 56 | 57 | return EXIT_FAILURE; 58 | } 59 | 60 | { 61 | char const* const module_name = argv[1]; 62 | char const* const symbol_name = argv[2]; 63 | 64 | void* const module = dlopen(module_name, RTLD_NOW); 65 | 66 | if (NULL == module) 67 | { 68 | fprintf(stderr 69 | , "%s: failed to open module '%s': %s\n" 70 | , program_name 71 | , module_name 72 | , dlerror() 73 | ); 74 | 75 | return EXIT_FAILURE; 76 | } 77 | else 78 | { 79 | void* const symbol = dlsym(module, symbol_name); 80 | int r = EXIT_SUCCESS; 81 | 82 | if (NULL == symbol) 83 | { 84 | fprintf(stderr 85 | , "%s: failed to retrieve symbol '%s' in '%s': %s\n" 86 | , program_name 87 | , symbol_name 88 | , module_name 89 | , dlerror() 90 | ); 91 | 92 | r = EXIT_FAILURE; 93 | } 94 | else 95 | { 96 | printf("found symbol '%s' at address %p in '%s'\n" 97 | , symbol_name 98 | , symbol 99 | , module_name 100 | ); 101 | } 102 | 103 | dlclose(module); 104 | 105 | return r; 106 | } 107 | } 108 | } 109 | 110 | 111 | /* ///////////////////////////// end of file //////////////////////////// */ 112 | 113 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.dlfcn/vc6/test.scratch.dlfcn.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.dlfcn" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.dlfcn - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.dlfcn.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.dlfcn.mak" CFG="test.scratch.dlfcn - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.dlfcn - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.dlfcn - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.dlfcn - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "$(UNIXEM)/include" /D "WIN32" /D "NDEBUG" /D "STRICT" /D "_CONSOLE" /YX /FD /c 46 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 47 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 48 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 49 | # ADD RSC /l 0xc09 /d "NDEBUG" 50 | BSC32=bscmake.exe 51 | # ADD BASE BSC32 /nologo 52 | # ADD BSC32 /nologo 53 | LINK32=link.exe 54 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 55 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /machine:I386 /libpath:"$(UNIXEM)\lib" 56 | 57 | !ELSEIF "$(CFG)" == "test.scratch.dlfcn - Win32 Debug" 58 | 59 | # PROP BASE Use_MFC 1 60 | # PROP BASE Use_Debug_Libraries 1 61 | # PROP BASE Output_Dir "Debug" 62 | # PROP BASE Intermediate_Dir "Debug" 63 | # PROP BASE Target_Dir "" 64 | # PROP Use_MFC 0 65 | # PROP Use_Debug_Libraries 1 66 | # PROP Output_Dir "Debug" 67 | # PROP Intermediate_Dir "Debug" 68 | # PROP Ignore_Export_Lib 0 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 71 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /D "WIN32" /D "_DEBUG" /D "STRICT" /D "_CONSOLE" /FR /YX /FD /c 72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 74 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 75 | # ADD RSC /l 0xc09 /d "_DEBUG" 76 | BSC32=bscmake.exe 77 | # ADD BASE BSC32 /nologo 78 | # ADD BSC32 /nologo 79 | LINK32=link.exe 80 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 81 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"$(UNIXEM)\lib" 82 | 83 | !ENDIF 84 | 85 | # Begin Target 86 | 87 | # Name "test.scratch.dlfcn - Win32 Release" 88 | # Name "test.scratch.dlfcn - Win32 Debug" 89 | # Begin Group "Source Files" 90 | 91 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 92 | # Begin Source File 93 | 94 | SOURCE=..\test.scratch.dlfcn.c 95 | # End Source File 96 | # End Group 97 | # Begin Group "Header Files" 98 | 99 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 100 | # End Group 101 | # Begin Group "Resource Files" 102 | 103 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" 104 | # End Group 105 | # End Target 106 | # End Project 107 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.fnmatch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_example_program(test.scratch.fnmatch test.scratch.fnmatch.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.fnmatch/test.scratch.fnmatch.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.fnmatch.c 3 | * 4 | * Purpose: Unit-test of `fnmatch()`. 5 | * 6 | * Created: 24th April 2006 7 | * Updated: 1st May 2025 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* UNIXem header files */ 13 | #include 14 | 15 | /* Standard C header files */ 16 | #include 17 | #include 18 | 19 | 20 | /* ///////////////////////////////////////////////////////////////////////// 21 | * globals 22 | */ 23 | 24 | 25 | 26 | /* ///////////////////////////////////////////////////////////////////////// 27 | * typedefs 28 | */ 29 | 30 | 31 | /* ///////////////////////////////////////////////////////////////////////// 32 | * forward declarations 33 | */ 34 | 35 | static void test_1(void); 36 | static void test_2(void); 37 | static void test_3(void); 38 | 39 | 40 | /* ///////////////////////////////////////////////////////////////////////// 41 | * main() 42 | */ 43 | 44 | int main(int argc, char *argv[]) 45 | { 46 | #if 0 47 | { size_t i; for (i = 0; i < 0xffffffff; ++i){} } 48 | #endif /* 0 */ 49 | 50 | ((void)argc); 51 | ((void)argv); 52 | /* . */ 53 | 54 | test_1(); 55 | 56 | return EXIT_SUCCESS; 57 | } 58 | 59 | 60 | /* ///////////////////////////////////////////////////////////////////////// 61 | * test function implementations 62 | */ 63 | 64 | static void test_1(void) 65 | { 66 | if (0 != fnmatch("a", "a", 0)) 67 | { 68 | fprintf(stderr, "test failed!\n"); 69 | } 70 | if (0 == fnmatch("a", "b", 0)) 71 | { 72 | fprintf(stderr, "test failed!\n"); 73 | } 74 | 75 | if (0 != fnmatch("[a-d]", "a", 0)) 76 | { 77 | fprintf(stderr, "test failed!\n"); 78 | } 79 | 80 | if (0 == fnmatch("[^A-Zb-z0-9]", "a", 0)) 81 | { 82 | fprintf(stderr, "test failed!\n"); 83 | } 84 | } 85 | 86 | static void test_2(void) 87 | { 88 | #if 0 89 | 90 | int fnmatch(char const *pattern, char const *string, int flags); 91 | #endif 92 | } 93 | 94 | static void test_3(void) 95 | { 96 | #if 0 97 | 98 | int fnmatch(char const *pattern, char const *string, int flags); 99 | #endif 100 | } 101 | 102 | 103 | /* ///////////////////////////// end of file //////////////////////////// */ 104 | 105 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.fnmatch/vc6/test.scratch.fnmatch.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.fnmatch" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.fnmatch - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.fnmatch.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.fnmatch.mak" CFG="test.scratch.fnmatch - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.fnmatch - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.fnmatch - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.fnmatch - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 46 | # ADD CPP /nologo /W3 /GX /O2 /I "$(STLSOFT)/include" /D "WIN32" /D "NDEBUG" /D "STLSOFT_FORCE_C_COMPILATION_IN_BETA" /D "_STLSOFT_FORCE_ANY_COMPILER" /D "STRICT" /D "_CONSOLE" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 50 | # ADD RSC /l 0xc09 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 56 | # ADD LINK32 shwild.1.vc6.lib cstring.3.vc6.lib kernel32.lib /nologo /version:1.0 /subsystem:console /map /machine:I386 /out:"Release/Fnmatch_test.debug.exe" /libpath:"$(SHWILD_ROOT)/lib" /libpath:"$(CSTRING_ROOT)/lib" 57 | # SUBTRACT LINK32 /pdb:none 58 | 59 | !ELSEIF "$(CFG)" == "test.scratch.fnmatch - Win32 Debug" 60 | 61 | # PROP BASE Use_MFC 1 62 | # PROP BASE Use_Debug_Libraries 1 63 | # PROP BASE Output_Dir "Debug" 64 | # PROP BASE Intermediate_Dir "Debug" 65 | # PROP BASE Target_Dir "" 66 | # PROP Use_MFC 0 67 | # PROP Use_Debug_Libraries 1 68 | # PROP Output_Dir "Debug" 69 | # PROP Intermediate_Dir "Debug" 70 | # PROP Ignore_Export_Lib 0 71 | # PROP Target_Dir "" 72 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c 73 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /I "$(STLSOFT)/include" /D "WIN32" /D "_DEBUG" /D "STLSOFT_FORCE_C_COMPILATION_IN_BETA" /D "_STLSOFT_FORCE_ANY_COMPILER" /D "STRICT" /D "_CONSOLE" /YX /FD /GZ /c 74 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 77 | # ADD RSC /l 0xc09 /d "_DEBUG" 78 | BSC32=bscmake.exe 79 | # ADD BASE BSC32 /nologo 80 | # ADD BSC32 /nologo 81 | LINK32=link.exe 82 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 83 | # ADD LINK32 shwild.1.vc6.debug.lib cstring.3.vc6.debug.lib kernel32.lib /nologo /version:1.0 /subsystem:console /map /debug /machine:I386 /out:"Debug/Fnmatch_test.debug.exe" /pdbtype:sept /libpath:"$(SHWILD_ROOT)/lib" /libpath:"$(CSTRING_ROOT)/lib" 84 | # SUBTRACT LINK32 /pdb:none 85 | 86 | !ENDIF 87 | 88 | # Begin Target 89 | 90 | # Name "test.scratch.fnmatch - Win32 Release" 91 | # Name "test.scratch.fnmatch - Win32 Debug" 92 | # Begin Group "Source Files" 93 | 94 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 95 | # Begin Source File 96 | 97 | SOURCE=..\test.scratch.fnmatch.c 98 | # End Source File 99 | # End Group 100 | # Begin Group "Header Files" 101 | 102 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 103 | # Begin Source File 104 | 105 | SOURCE="$(UNIXEM)\include\fnmatch.h" 106 | # End Source File 107 | # End Group 108 | # Begin Group "Resource Files" 109 | 110 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 111 | # End Group 112 | # End Target 113 | # End Project 114 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.getrusage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.scratch.getrusage test.scratch.getrusage.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.getrusage/test.scratch.getrusage.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.getrusage.c 3 | * 4 | * Purpose: Unit-test of `getrusage()`. 5 | * 6 | * Created: 9th June 2006 7 | * Updated: 29th November 2024 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* ///////////////////////////////////////////////////////////////////////// 13 | * includes 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | 22 | /* ///////////////////////////////////////////////////////////////////////// 23 | * main() 24 | */ 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | ((void)argc); 29 | ((void)argv); 30 | 31 | { 32 | struct rusage usage; 33 | 34 | { size_t i; for (i = 0; i < 0xfffffff; ++i){} } 35 | 36 | { size_t i; for (i = 0; i < 100; ++i) 37 | { 38 | FILE* f = fopen("abc", "w"); 39 | 40 | if (NULL != f) 41 | { 42 | char buf[100] = ""; 43 | int j; 44 | 45 | for (j = 0; j < 100; ++j) 46 | { 47 | fwrite(&buf[0], 100, 1, f); 48 | } 49 | 50 | fclose(f); 51 | 52 | unlink("abc"); 53 | } 54 | }} 55 | 56 | getrusage(0, &usage); 57 | 58 | printf("system: %ld - %ld\n", usage.ru_stime.tv_sec, usage.ru_stime.tv_usec); 59 | printf("user: %ld - %ld\n", usage.ru_utime.tv_sec, usage.ru_utime.tv_usec); 60 | } 61 | 62 | return EXIT_SUCCESS; 63 | } 64 | 65 | 66 | /* ///////////////////////////// end of file //////////////////////////// */ 67 | 68 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.getrusage/vc6/test.scratch.getrusage.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.getrusage" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.getrusage - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.getrusage.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.getrusage.mak" CFG="test.scratch.getrusage - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.getrusage - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.getrusage - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.getrusage - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 46 | # ADD CPP /nologo /W3 /GX /O2 /I "$(UNIXEM)/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "STRICT" /D "_CONSOLE" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 50 | # ADD RSC /l 0xc09 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 56 | # ADD LINK32 kernel32.lib /nologo /version:1.0 /subsystem:console /map /machine:I386 /out:"Release/Getrusage_test.debug.exe" /libpath:"$(UNIXEM)/lib" 57 | # SUBTRACT LINK32 /pdb:none 58 | 59 | !ELSEIF "$(CFG)" == "test.scratch.getrusage - Win32 Debug" 60 | 61 | # PROP BASE Use_MFC 1 62 | # PROP BASE Use_Debug_Libraries 1 63 | # PROP BASE Output_Dir "Debug" 64 | # PROP BASE Intermediate_Dir "Debug" 65 | # PROP BASE Target_Dir "" 66 | # PROP Use_MFC 0 67 | # PROP Use_Debug_Libraries 1 68 | # PROP Output_Dir "Debug" 69 | # PROP Intermediate_Dir "Debug" 70 | # PROP Ignore_Export_Lib 0 71 | # PROP Target_Dir "" 72 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c 73 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "STRICT" /D "_CONSOLE" /FR /YX /FD /GZ /c 74 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 77 | # ADD RSC /l 0xc09 /d "_DEBUG" 78 | BSC32=bscmake.exe 79 | # ADD BASE BSC32 /nologo 80 | # ADD BSC32 /nologo 81 | LINK32=link.exe 82 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 83 | # ADD LINK32 kernel32.lib /nologo /version:1.0 /subsystem:console /map /debug /machine:I386 /out:"Debug/Getrusage_test.debug.exe" /pdbtype:sept /libpath:"$(UNIXEM)/lib" 84 | # SUBTRACT LINK32 /pdb:none 85 | 86 | !ENDIF 87 | 88 | # Begin Target 89 | 90 | # Name "test.scratch.getrusage - Win32 Release" 91 | # Name "test.scratch.getrusage - Win32 Debug" 92 | # Begin Group "Source Files" 93 | 94 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 95 | # Begin Source File 96 | 97 | SOURCE=..\test.scratch.getrusage.c 98 | # End Source File 99 | # End Group 100 | # Begin Group "Header Files" 101 | 102 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 103 | # Begin Source File 104 | 105 | SOURCE=..\..\..\include\sys\resource.h 106 | # End Source File 107 | # End Group 108 | # Begin Group "Resource Files" 109 | 110 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 111 | # End Group 112 | # End Target 113 | # End Project 114 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.link/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.scratch.link test.scratch.link.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.link/test.scratch.link.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.link.c 3 | * 4 | * Purpose: Unit-test of `link()`. 5 | * 6 | * Created: 2nd September 2005 7 | * Updated: 28th November 2024 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* ///////////////////////////////////////////////////////////////////////// 13 | * includes 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | /* ///////////////////////////////////////////////////////////////////////// 26 | * forward declarations 27 | */ 28 | 29 | 30 | /* ///////////////////////////////////////////////////////////////////////// 31 | * main() 32 | */ 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | char const* const program_name = platformstl_C_get_executable_name_from_path(argv[0]).ptr; 37 | char const* module_name; 38 | char const* symbol_name; 39 | 40 | { int i; for (i = 1; i != argc; ++i) 41 | { 42 | if (0 == strcmp("--help", argv[i])) 43 | { 44 | printf("USAGE: %s \n", program_name); 45 | 46 | return EXIT_SUCCESS; 47 | } 48 | }} 49 | 50 | switch (argc) 51 | { 52 | case 1: 53 | case 2: 54 | 55 | fprintf(stderr, "%s: missing arguments; use --help for usage\n", program_name); 56 | 57 | return EXIT_FAILURE; 58 | case 3: 59 | 60 | module_name = argv[1]; 61 | symbol_name = argv[2]; 62 | break; 63 | default: 64 | 65 | fprintf(stderr, "%s: too many arguments; use --help for usage\n", program_name); 66 | 67 | return EXIT_FAILURE; 68 | } 69 | 70 | if (argc < 3) 71 | { 72 | fprintf(stderr, "USAGE: test.scratch.link \n"); 73 | 74 | return EXIT_FAILURE; 75 | } 76 | else 77 | { 78 | int const res = link(module_name, symbol_name); 79 | 80 | if (0 == res) 81 | { 82 | fprintf(stdout, "\"%s\" => \"%s\"\n", module_name, symbol_name); 83 | 84 | return EXIT_SUCCESS; 85 | } 86 | else 87 | { 88 | fprintf(stderr, "link() failed: %d (%s)\n", errno, strerror(errno)); 89 | 90 | return EXIT_FAILURE; 91 | } 92 | } 93 | } 94 | 95 | 96 | /* ///////////////////////////// end of file //////////////////////////// */ 97 | 98 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.link/vc6/test.scratch.link.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.link" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.link - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.link.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.link.mak" CFG="test.scratch.link - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.link - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.link - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.link - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 46 | # ADD CPP /nologo /W3 /GX /O2 /I "$(UNIXEM)/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "STRICT" /D "_CONSOLE" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 50 | # ADD RSC /l 0xc09 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /map /machine:I386 /out:"Release/Link_test.debug.exe" /libpath:"$(UNIXEM)\lib" 57 | # SUBTRACT LINK32 /pdb:none 58 | 59 | !ELSEIF "$(CFG)" == "test.scratch.link - Win32 Debug" 60 | 61 | # PROP BASE Use_MFC 1 62 | # PROP BASE Use_Debug_Libraries 1 63 | # PROP BASE Output_Dir "Debug" 64 | # PROP BASE Intermediate_Dir "Debug" 65 | # PROP BASE Target_Dir "" 66 | # PROP Use_MFC 0 67 | # PROP Use_Debug_Libraries 1 68 | # PROP Output_Dir "Debug" 69 | # PROP Intermediate_Dir "Debug" 70 | # PROP Ignore_Export_Lib 0 71 | # PROP Target_Dir "" 72 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c 73 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "STRICT" /D "_CONSOLE" /FR /YX /FD /GZ /c 74 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 77 | # ADD RSC /l 0xc09 /d "_DEBUG" 78 | BSC32=bscmake.exe 79 | # ADD BASE BSC32 /nologo 80 | # ADD BSC32 /nologo 81 | LINK32=link.exe 82 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 83 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /map /debug /machine:I386 /out:"Debug/Link_test.debug.exe" /pdbtype:sept /libpath:"$(UNIXEM)\lib" 84 | # SUBTRACT LINK32 /pdb:none 85 | 86 | !ENDIF 87 | 88 | # Begin Target 89 | 90 | # Name "test.scratch.link - Win32 Release" 91 | # Name "test.scratch.link - Win32 Debug" 92 | # Begin Group "Source Files" 93 | 94 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 95 | # Begin Source File 96 | 97 | SOURCE=..\test.scratch.link.c 98 | # End Source File 99 | # End Group 100 | # Begin Group "Header Files" 101 | 102 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 103 | # End Group 104 | # Begin Group "Resource Files" 105 | 106 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 107 | # End Group 108 | # End Target 109 | # End Project 110 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.mmap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.scratch.mmap test.scratch.mmap.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.mmap/test.scratch.mmap.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.mmap.cpp 3 | * 4 | * Purpose: Unit-test of `mmap()`, `munmap()`. 5 | * 6 | * Created: 18th December 2003 7 | * Updated: 1st May 2025 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* ///////////////////////////////////////////////////////////////////////// 13 | * includes 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | /* ///////////////////////////////////////////////////////////////////////// 29 | * function declarations 30 | */ 31 | 32 | /** \brief Maps a file 33 | * 34 | * This function supports three modes: 35 | * 36 | * 1. Read-only. 37 | * 38 | * fileName must refer to an existing file 39 | * len can be 0, for all the file contents, or any size up to the length 40 | * of the file. It is an error if the length exceeds the length of 41 | * the file 42 | * prot is PROT_READ 43 | * flags is ignored in the current implementation 44 | * 45 | * 2. Read-write 46 | * 47 | * fileName must refer to an existing file 48 | * len can be 0, for all the file contents, or any size up to the length 49 | * of the file. If it is longer than the current size of the file, the 50 | * file is extended. 51 | * prot contains PROT_WRITE, and is then assumed to be 52 | * (PROT_READ | PROT_WRITE). All other flags are ignored 53 | * flags is ignored in the current implementation 54 | * 55 | * 3. System-page file 56 | * 57 | * fileName must be NULL 58 | * len must be > 0. It is rounded up to the page-size internally 59 | * prot is ignored, It is always assumed to be PROT_READ | PROT_WRITE 60 | * flags is ignored in the current implementation 61 | */ 62 | 63 | #ifdef __cplusplus 64 | extern "C" 65 | #endif 66 | void* 67 | mmap_file( 68 | char const* fileName /* = NULL */ 69 | , size_t len 70 | , size_t offset 71 | , int prot 72 | , int flags 73 | , size_t* plen 74 | ); 75 | 76 | 77 | /* ///////////////////////////////////////////////////////////////////////// 78 | * main() 79 | */ 80 | 81 | int main(int argc, char *argv[]) 82 | { 83 | /* . */ 84 | #if defined(TEST_READONLY) 85 | char const* fileName = "h:\\dev\\bin\\mmcmnbas.dll"; 86 | void* pv = mmap_file(fileName, 0, 1000, PROT_READ, 0, NULL); 87 | #elif defined(TEST_READWRITE) 88 | char const* fileName = "test-file.txt"; 89 | void* pv = mmap_file(fileName, 1000, 0, PROT_WRITE, 0, NULL); 90 | #elif defined(TEST_PAGING) 91 | char const* fileName = ""; 92 | void* pv = mmap_file(NULL, 1000, 0, 0, 0, NULL); 93 | #else 94 | # error Must define one only of TEST_READONLY, TEST_READWRITE or TEST_PAGING 95 | #endif 96 | 97 | ((void)&argc); 98 | ((void)&argv); 99 | 100 | if (MAP_FAILED == pv) 101 | { 102 | fprintf(stderr, "Failed to load \"%s\": %s\n", fileName, strerror(errno)); 103 | } 104 | else 105 | { 106 | fprintf(stderr, "Loaded \"%s\"", fileName); 107 | 108 | #if defined(TEST_READWRITE) || \ 109 | defined(TEST_PAGING) 110 | memset(pv, 99, 2); 111 | 112 | msync(pv, 0, 0); 113 | #endif /* TEST_READWRITE || TEST_PAGING */ 114 | 115 | munmap(pv, 0); 116 | } 117 | 118 | return 0; 119 | } 120 | 121 | 122 | /* ///////////////////////////// end of file //////////////////////////// */ 123 | 124 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.mmap/vc6/test.scratch.mmap.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.mmap" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.mmap - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.mmap.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.mmap.mak" CFG="test.scratch.mmap - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.mmap - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.mmap - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.mmap - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 46 | # ADD CPP /nologo /W3 /GX /O2 /I "$(UNIXEM)/include" /D "WIN32" /D "NDEBUG" /D "STRICT" /D "_CONSOLE" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 50 | # ADD RSC /l 0xc09 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /machine:I386 /out:"..\..\..\bin/test.scratch.mmap.exe" 57 | 58 | !ELSEIF "$(CFG)" == "test.scratch.mmap - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 1 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Ignore_Export_Lib 0 70 | # PROP Target_Dir "" 71 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 72 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /D "WIN32" /D "_DEBUG" /D "STRICT" /D "_CONSOLE" /D "TEST_PAGING" /FR /YX /FD /c 73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 75 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 76 | # ADD RSC /l 0xc09 /d "_DEBUG" 77 | BSC32=bscmake.exe 78 | # ADD BASE BSC32 /nologo 79 | # ADD BSC32 /nologo 80 | LINK32=link.exe 81 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 82 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /debug /machine:I386 /out:"..\..\..\bin/test.scratch.mmapD.exe" /pdbtype:sept 83 | 84 | !ENDIF 85 | 86 | # Begin Target 87 | 88 | # Name "test.scratch.mmap - Win32 Release" 89 | # Name "test.scratch.mmap - Win32 Debug" 90 | # Begin Group "Source Files" 91 | 92 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 93 | # Begin Source File 94 | 95 | SOURCE=..\..\..\ex\mmap_ex.c 96 | # End Source File 97 | # Begin Source File 98 | 99 | SOURCE=..\test.scratch.mmap.cpp 100 | # End Source File 101 | # End Group 102 | # Begin Group "Header Files" 103 | 104 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 105 | # Begin Source File 106 | 107 | SOURCE=..\..\..\include\sys\mman.h 108 | # End Source File 109 | # Begin Source File 110 | 111 | SOURCE=..\..\..\include\unistd.h 112 | # End Source File 113 | # End Group 114 | # Begin Group "Resource Files" 115 | 116 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" 117 | # End Group 118 | # End Target 119 | # End Project 120 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.setenv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.scratch.setenv test.scratch.setenv.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.setenv/test.scratch.setenv.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.setenv.c 3 | * 4 | * Purpose: Unit-test of `setenv()`. 5 | * 6 | * Created: 9th December 2005 7 | * Updated: 29th November 2024 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | #include 13 | 14 | /* STLSoft header files */ 15 | #include 16 | 17 | 18 | /* Standard C header files */ 19 | #include 20 | #include 21 | 22 | 23 | /* ///////////////////////////////////////////////////////////////////////// 24 | * compatibility 25 | */ 26 | 27 | #define setenv unixem_setenv 28 | #define unsetenv unixem_unsetenv 29 | 30 | 31 | /* ///////////////////////////////////////////////////////////////////////// 32 | * typedefs 33 | */ 34 | 35 | 36 | /* ///////////////////////////////////////////////////////////////////////// 37 | * forward declarations 38 | */ 39 | 40 | 41 | /* ///////////////////////////////////////////////////////////////////////// 42 | * main() 43 | */ 44 | 45 | int main(int argc, char *argv[]) 46 | { 47 | ((void)&argc); 48 | ((void)&argv); 49 | 50 | setenv("SOMETHING_VERY_UNLIKELY_2_B_SET", "bat", 0); 51 | 52 | printf("SOMETHING_VERY_UNLIKELY_2_B_SET=%s\n", getenv("SOMETHING_VERY_UNLIKELY_2_B_SET")); 53 | 54 | setenv("SOMETHING_VERY_UNLIKELY_2_B_SET", "out", 0); 55 | 56 | printf("SOMETHING_VERY_UNLIKELY_2_B_SET=%s\n", getenv("SOMETHING_VERY_UNLIKELY_2_B_SET")); 57 | 58 | setenv("SOMETHING_VERY_UNLIKELY_2_B_SET", "of", 1); 59 | 60 | printf("SOMETHING_VERY_UNLIKELY_2_B_SET=%s\n", getenv("SOMETHING_VERY_UNLIKELY_2_B_SET")); 61 | 62 | setenv("SOMETHING_VERY_UNLIKELY_2_B_SET", "hell", 0); 63 | 64 | printf("SOMETHING_VERY_UNLIKELY_2_B_SET=%s\n", getenv("SOMETHING_VERY_UNLIKELY_2_B_SET")); 65 | 66 | unsetenv("SOMETHING_VERY_UNLIKELY_2_B_SET"); 67 | 68 | setenv("SOMETHING_VERY_UNLIKELY_2_B_SET", "deadringer", 0); 69 | 70 | printf("SOMETHING_VERY_UNLIKELY_2_B_SET=%s\n", getenv("SOMETHING_VERY_UNLIKELY_2_B_SET")); 71 | 72 | return EXIT_SUCCESS; 73 | } 74 | 75 | 76 | /* ///////////////////////////// end of file //////////////////////////// */ 77 | 78 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.setenv/vc10/test.scratch.setenv.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.setenv/vc6/test.scratch.setenv.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.setenv" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.setenv - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.setenv.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.setenv.mak" CFG="test.scratch.setenv - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.setenv - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.setenv - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.setenv - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "$(UNIXEM)/include" /I "$(STLSOFT)/include" /D "WIN32" /D "NDEBUG" /D "STLSOFT_FORCE_C_COMPILATION_IN_BETA" /D "STRICT" /D "_CONSOLE" /YX /FD /c 46 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 47 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 49 | # ADD RSC /l 0xc09 /d "NDEBUG" 50 | BSC32=bscmake.exe 51 | # ADD BASE BSC32 /nologo 52 | # ADD BSC32 /nologo 53 | LINK32=link.exe 54 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 55 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /map /machine:I386 /out:"Release/Setenv_test.debug.exe" 56 | # SUBTRACT LINK32 /pdb:none 57 | 58 | !ELSEIF "$(CFG)" == "test.scratch.setenv - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 1 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c 71 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /I "$(STLSOFT)/include" /D "WIN32" /D "_DEBUG" /D "STLSOFT_FORCE_C_COMPILATION_IN_BETA" /D "STRICT" /D "_CONSOLE" /YX /FD /GZ /c 72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 75 | # ADD RSC /l 0xc09 /d "_DEBUG" 76 | BSC32=bscmake.exe 77 | # ADD BASE BSC32 /nologo 78 | # ADD BSC32 /nologo 79 | LINK32=link.exe 80 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 81 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /map /debug /machine:I386 /out:"Debug/Setenv_test.debug.exe" /pdbtype:sept 82 | # SUBTRACT LINK32 /pdb:none 83 | 84 | !ENDIF 85 | 86 | # Begin Target 87 | 88 | # Name "test.scratch.setenv - Win32 Release" 89 | # Name "test.scratch.setenv - Win32 Debug" 90 | # Begin Group "Source Files" 91 | 92 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 93 | # Begin Source File 94 | 95 | SOURCE=..\test.scratch.setenv.c 96 | # End Source File 97 | # End Group 98 | # Begin Group "Header Files" 99 | 100 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 101 | # Begin Source File 102 | 103 | SOURCE=..\..\..\include\unixem\setenv.h 104 | # End Source File 105 | # End Group 106 | # Begin Group "Resource Files" 107 | 108 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 109 | # End Group 110 | # End Target 111 | # End Project 112 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.syslog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #[====[ 2 | list(APPEND X_GCC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED unused-variable) 3 | #]====] 4 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 5 | define_example_program(test.scratch.syslog test.scratch.syslog.c) 6 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.syslog/test.scratch.syslog.c: -------------------------------------------------------------------------------- 1 | /* ////////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.syslog.c 3 | * 4 | * Purpose: Unit-test of `syslog()`. 5 | * 6 | * Created: 1st October 2006 7 | * Updated: 29th November 2024 8 | * 9 | * /////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | /* ///////////////////////////////////////////////////////////////////////// 13 | * includes 14 | */ 15 | 16 | /* STLSoft header files */ 17 | #include 18 | 19 | /* PlatformSTL header files */ 20 | #include 21 | 22 | 23 | /* UNIXem header files */ 24 | #include 25 | 26 | /* Standard C header files */ 27 | #include 28 | #include 29 | 30 | 31 | /* ///////////////////////////////////////////////////////////////////////// 32 | * macros and definitions 33 | */ 34 | 35 | 36 | /* ///////////////////////////////////////////////////////////////////////// 37 | * globals 38 | */ 39 | 40 | 41 | /* ///////////////////////////////////////////////////////////////////////// 42 | * typedefs 43 | */ 44 | 45 | 46 | /* ///////////////////////////////////////////////////////////////////////// 47 | * forward declarations 48 | */ 49 | 50 | 51 | /* ///////////////////////////////////////////////////////////////////////// 52 | * main() 53 | */ 54 | 55 | int main(int argc, char *argv[]) 56 | { 57 | ((void)argc); 58 | ((void)argv); 59 | 60 | return EXIT_SUCCESS; 61 | } 62 | 63 | 64 | /* ///////////////////////////// end of file //////////////////////////// */ 65 | 66 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.syslog/vc6/test.scratch.syslog.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.syslog" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.syslog - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.syslog.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.syslog.mak" CFG="test.scratch.syslog - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.syslog - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.syslog - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.syslog - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 1 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 45 | # ADD CPP /nologo /MT /W3 /GX /O2 /I "$(STLSOFT)/include" /I "$(UNIXEM)/include" /D "WIN32" /D "NDEBUG" /D "STLSOFT_FORCE_C_COMPILATION_IN_BETA" /D "STRICT" /D "_CONSOLE" /YX /FD /c 46 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 47 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 49 | # ADD RSC /l 0xc09 /d "NDEBUG" 50 | BSC32=bscmake.exe 51 | # ADD BASE BSC32 /nologo 52 | # ADD BSC32 /nologo 53 | LINK32=link.exe 54 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 55 | # ADD LINK32 kernel32.lib advapi32.lib /nologo /version:1.0 /subsystem:console /map /machine:I386 /out:"Release/Syslog_test.debug.exe" /libpath:"$(UNIXEM)/lib" 56 | # SUBTRACT LINK32 /pdb:none 57 | 58 | !ELSEIF "$(CFG)" == "test.scratch.syslog - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 1 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 1 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c 71 | # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "$(STLSOFT)/include" /I "$(UNIXEM)/include" /D "WIN32" /D "_DEBUG" /D "STLSOFT_FORCE_C_COMPILATION_IN_BETA" /D "STRICT" /D "_CONSOLE" /YX /FD /GZ /c 72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 75 | # ADD RSC /l 0xc09 /d "_DEBUG" 76 | BSC32=bscmake.exe 77 | # ADD BASE BSC32 /nologo 78 | # ADD BSC32 /nologo 79 | LINK32=link.exe 80 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 81 | # ADD LINK32 kernel32.lib advapi32.lib /nologo /version:1.0 /subsystem:console /map /debug /machine:I386 /out:"Debug/Syslog_test.debug.exe" /pdbtype:sept /libpath:"$(UNIXEM)/lib" 82 | # SUBTRACT LINK32 /pdb:none 83 | 84 | !ENDIF 85 | 86 | # Begin Target 87 | 88 | # Name "test.scratch.syslog - Win32 Release" 89 | # Name "test.scratch.syslog - Win32 Debug" 90 | # Begin Group "Source Files" 91 | 92 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 93 | # Begin Source File 94 | 95 | SOURCE=..\test.scratch.syslog.c 96 | # End Source File 97 | # End Group 98 | # Begin Group "Header Files" 99 | 100 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 101 | # End Group 102 | # Begin Group "Resource Files" 103 | 104 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 105 | # End Group 106 | # End Target 107 | # End Project 108 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.uio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_example_program(test.scratch.uio test.scratch.uio.c) 3 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.uio/test.scratch.uio.c: -------------------------------------------------------------------------------- 1 | /* ///////////////////////////////////////////////////////////////////////// 2 | * File: test.scratch.uio.c 3 | * 4 | * Purpose: Unit-test of `uio()`. 5 | * 6 | * Created: 19th September 2005 7 | * Updated: 29th November 2024 8 | * 9 | * ////////////////////////////////////////////////////////////////////// */ 10 | 11 | 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | /* ///////////////////////////////////////////////////////////////////////// 24 | * main() 25 | */ 26 | 27 | static int main_(int argc, char **argv) 28 | { 29 | char const* const program_name = platformstl_C_get_executable_name_from_path(argv[0]).ptr; 30 | 31 | { int i; for (i = 1; i != argc; ++i) 32 | { 33 | if (0 == strcmp("--help", argv[i])) 34 | { 35 | printf("USAGE: %s \n", program_name); 36 | 37 | return EXIT_SUCCESS; 38 | } 39 | }} 40 | 41 | switch (argc) 42 | { 43 | case 1: 44 | 45 | fprintf(stderr, "%s: missing argument; use --help for usage\n", program_name); 46 | 47 | return EXIT_FAILURE; 48 | case 2: 49 | 50 | break; 51 | default: 52 | 53 | fprintf(stderr, "%s: too many arguments; use --help for usage\n", program_name); 54 | 55 | return EXIT_FAILURE; 56 | } 57 | 58 | { 59 | char const* fileName = argv[1]; 60 | int fd = _open(fileName, _O_RDONLY); 61 | struct iovec vectors[3]; 62 | char sz1[10]; 63 | char sz2[2]; 64 | char sz3[21]; 65 | unixem_ssize_t n; 66 | 67 | vectors[0].iov_base = &sz1[0]; 68 | vectors[0].iov_len = sizeof(sz1); 69 | vectors[1].iov_base = &sz2[0]; 70 | vectors[1].iov_len = sizeof(sz2); 71 | vectors[2].iov_base = &sz3[0]; 72 | vectors[2].iov_len = sizeof(sz3); 73 | 74 | n = readv(fd, &vectors[0], 3); 75 | 76 | if (n < 0) 77 | { 78 | fprintf(stderr, "%s: failed to invoke `readv()` on '%s': %ld\n", program_name, fileName, (long)n); 79 | } 80 | else 81 | { 82 | printf("read following block sizes by `readv()` from '%s': %llu, %llu, %llu; total-read=%ld\n", fileName, vectors[0].iov_len, vectors[1].iov_len, vectors[2].iov_len, (long)n); 83 | 84 | close(fd); 85 | } 86 | } 87 | 88 | return 0; 89 | } 90 | 91 | int main(int argc, char *argv[]) 92 | { 93 | return main_(argc, argv); 94 | } 95 | 96 | 97 | /* ///////////////////////////// end of file //////////////////////////// */ 98 | 99 | -------------------------------------------------------------------------------- /test/scratch/test.scratch.uio/vc6/test.scratch.uio.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="test.scratch.uio" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=test.scratch.uio - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "test.scratch.uio.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "test.scratch.uio.mak" CFG="test.scratch.uio - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "test.scratch.uio - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "test.scratch.uio - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "test.scratch.uio - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 1 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "$(UNIXEM)/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "STRICT" /D "_CONSOLE" /YX /FD /c 46 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 47 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD BASE RSC /l 0xc09 /d "NDEBUG" 49 | # ADD RSC /l 0xc09 /d "NDEBUG" 50 | BSC32=bscmake.exe 51 | # ADD BASE BSC32 /nologo 52 | # ADD BSC32 /nologo 53 | LINK32=link.exe 54 | # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 55 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /map /machine:I386 /out:"Release/Uio_test.debug.exe" /libpath:"$(UNIXEM)/lib" 56 | # SUBTRACT LINK32 /pdb:none 57 | 58 | !ELSEIF "$(CFG)" == "test.scratch.uio - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 1 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c 71 | # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "$(UNIXEM)/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "STRICT" /D "_CONSOLE" /FR /YX /FD /GZ /c 72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD BASE RSC /l 0xc09 /d "_DEBUG" 75 | # ADD RSC /l 0xc09 /d "_DEBUG" 76 | BSC32=bscmake.exe 77 | # ADD BASE BSC32 /nologo 78 | # ADD BSC32 /nologo 79 | LINK32=link.exe 80 | # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 81 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:1.0 /subsystem:console /map /debug /machine:I386 /out:"Debug/Uio_test.debug.exe" /pdbtype:sept /libpath:"$(UNIXEM)/lib" 82 | # SUBTRACT LINK32 /pdb:none 83 | 84 | !ENDIF 85 | 86 | # Begin Target 87 | 88 | # Name "test.scratch.uio - Win32 Release" 89 | # Name "test.scratch.uio - Win32 Debug" 90 | # Begin Group "Source Files" 91 | 92 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 93 | # Begin Source File 94 | 95 | SOURCE=..\test.scratch.uio.c 96 | # End Source File 97 | # End Group 98 | # Begin Group "Header Files" 99 | 100 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 101 | # Begin Source File 102 | 103 | SOURCE=..\..\..\..\include\sys\uio.h 104 | # End Source File 105 | # Begin Source File 106 | 107 | SOURCE=..\..\..\..\include\unixem\sys\uio.h 108 | # End Source File 109 | # Begin Source File 110 | 111 | SOURCE=..\..\..\..\include\unistd.h 112 | # End Source File 113 | # Begin Source File 114 | 115 | SOURCE=..\..\..\..\include\unixem\unistd.h 116 | # End Source File 117 | # Begin Source File 118 | 119 | SOURCE=..\..\..\..\include\unixem\unixem.h 120 | # End Source File 121 | # End Group 122 | # Begin Group "Resource Files" 123 | 124 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 125 | # End Group 126 | # End Target 127 | # End Project 128 | -------------------------------------------------------------------------------- /test/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten 2 | add_subdirectory(test.unit.unistd.gethostname) 3 | add_subdirectory(test.unit.unistd.getpid) 4 | add_subdirectory(test.unit.unistd.pathconf) 5 | add_subdirectory(test.unit.util.fs) 6 | add_subdirectory(test.unit.util.str) 7 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.gethostname/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.unit.unistd.gethostname entry.c) 3 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.gethostname/entry.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | 10 | int main(int argc, char** argv) 11 | { 12 | int retCode = EXIT_SUCCESS; 13 | int verbosity = 2; 14 | 15 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 16 | 17 | if (XTESTS_START_RUNNER("test.unit.unistd.gethostname", verbosity)) 18 | { 19 | /* Test-1 */ 20 | if (XTESTS_CASE_BEGIN("Test-1", "testing gethostname")) 21 | { 22 | char hostName[100]; 23 | 24 | XTESTS_TEST_INTEGER_EQUAL((pid_t)GetCurrentProcessId(), getpid()); 25 | 26 | gethostname(&hostName[0], STLSOFT_NUM_ELEMENTS(hostName)); 27 | 28 | XTESTS_CASE_END("Test-1"); 29 | } 30 | 31 | XTESTS_PRINT_RESULTS(); 32 | 33 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 34 | } 35 | 36 | return retCode; 37 | } 38 | 39 | 40 | /* ///////////////////////////// end of file //////////////////////////// */ 41 | 42 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.gethostname/implicit_link.c: -------------------------------------------------------------------------------- 1 | 2 | /* UNIXem header files */ 3 | #include 4 | 5 | /* xTests header files */ 6 | #include 7 | 8 | 9 | /* ///////////////////////////// end of file //////////////////////////// */ 10 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.getpid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.unit.unistd.getpid entry.c) 3 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.getpid/entry.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | 10 | int main(int argc, char** argv) 11 | { 12 | int retCode = EXIT_SUCCESS; 13 | int verbosity = 2; 14 | 15 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 16 | 17 | if (XTESTS_START_RUNNER("test.unit.unistd.getpid", verbosity)) 18 | { 19 | /* Test-1 */ 20 | if (XTESTS_CASE_BEGIN("Test-1", "testing getpid")) 21 | { 22 | XTESTS_TEST_INTEGER_EQUAL((pid_t)GetCurrentProcessId(), getpid()); 23 | 24 | XTESTS_CASE_END("Test-1"); 25 | } 26 | 27 | XTESTS_PRINT_RESULTS(); 28 | 29 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 30 | } 31 | 32 | return retCode; 33 | } 34 | 35 | 36 | /* ///////////////////////////// end of file //////////////////////////// */ 37 | 38 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.getpid/vc10/test.unit.unistd.getpid.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.pathconf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.unit.unistd.pathconf entry.c) 3 | -------------------------------------------------------------------------------- /test/unit/test.unit.unistd.pathconf/entry.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | int main(int argc, char** argv) 12 | { 13 | int retCode = EXIT_SUCCESS; 14 | int verbosity = 2; 15 | 16 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 17 | 18 | if (XTESTS_START_RUNNER("test.unit.unistd.pathconf", verbosity)) 19 | { 20 | /* Test-1 */ 21 | if (XTESTS_CASE_BEGIN("Test-1", "testing pathconf")) 22 | { 23 | XTESTS_TEST_INTEGER_EQUAL(LONG_MAX, pathconf("", _PC_LINK_MAX)); 24 | XTESTS_TEST_INTEGER_EQUAL(LONG_MAX, pathconf("", _PC_MAX_CANON)); 25 | XTESTS_TEST_INTEGER_EQUAL(LONG_MAX, pathconf("", _PC_MAX_INPUT)); 26 | XTESTS_TEST_INTEGER_EQUAL(_MAX_FNAME - 1, pathconf("/", _PC_NAME_MAX)); 27 | XTESTS_TEST_INTEGER_EQUAL(_MAX_FNAME - 9, pathconf("/01234567", _PC_NAME_MAX)); 28 | XTESTS_TEST_INTEGER_EQUAL(_MAX_PATH - 1, pathconf("/", _PC_PATH_MAX)); 29 | XTESTS_TEST_INTEGER_EQUAL(_MAX_PATH - 9, pathconf("/01234567", _PC_PATH_MAX)); 30 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_PIPE_BUF)); 31 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_CHOWN_RESTRICTED)); 32 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_NO_TRUNC)); 33 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_VDISABLE)); 34 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_AIX_DISK_PARTITION)); 35 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_AIX_DISK_SIZE)); 36 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_FILESIZEBITS)); 37 | XTESTS_TEST_INTEGER_EQUAL(-1, pathconf("", _PC_SYNC_IO)); 38 | 39 | XTESTS_CASE_END("Test-1"); 40 | } 41 | 42 | XTESTS_PRINT_RESULTS(); 43 | 44 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 45 | } 46 | 47 | return retCode; 48 | } 49 | 50 | 51 | /* ///////////////////////////// end of file //////////////////////////// */ 52 | 53 | -------------------------------------------------------------------------------- /test/unit/test.unit.util.fs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | list(APPEND X_MSVC_CUSTOM_WARNINGS_TO_BE_SUPPRESSED 4996) 2 | define_automated_test_program(test.unit.util.fs entry.cpp) 3 | -------------------------------------------------------------------------------- /test/unit/test.unit.util.str/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SIS:AUTO_GENERATED: Do not edit! 2 | define_automated_test_program(test.unit.util.str entry.c) 3 | -------------------------------------------------------------------------------- /test/unit/test.unit.util.str/entry.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | 6 | 7 | static void TEST_begins_with(void); 8 | static void TEST_ends_with(void); 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | int retCode = EXIT_SUCCESS; 13 | int verbosity = 2; 14 | 15 | XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); 16 | 17 | if (XTESTS_START_RUNNER("test.unit.util.fs", verbosity)) 18 | { 19 | XTESTS_RUN_CASE(TEST_begins_with); 20 | XTESTS_RUN_CASE(TEST_ends_with); 21 | 22 | XTESTS_PRINT_RESULTS(); 23 | 24 | XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); 25 | } 26 | 27 | return retCode; 28 | } 29 | 30 | static void TEST_begins_with(void) 31 | { 32 | { 33 | TEST_INT_EQ(1, unixem_util_str_begins_with("", "")); 34 | TEST_INT_EQ(0, unixem_util_str_begins_with("", "abc")); 35 | TEST_INT_EQ(1, unixem_util_str_begins_with("abc", "")); 36 | } 37 | 38 | { 39 | TEST_INT_EQ(1, unixem_util_str_begins_with("abc", "abc")); 40 | TEST_INT_EQ(1, unixem_util_str_begins_with("abc", "ab")); 41 | TEST_INT_EQ(1, unixem_util_str_begins_with("abc", "a")); 42 | TEST_INT_EQ(0, unixem_util_str_begins_with("abc", "abd")); 43 | TEST_INT_EQ(0, unixem_util_str_begins_with("abc", "ad")); 44 | } 45 | 46 | { 47 | TEST_INT_EQ(1, unixem_util_str_begins_with("abcdefghijklmnopqrstuvwxyz", "abc")); 48 | TEST_INT_EQ(1, unixem_util_str_begins_with("abcdefghijklmnopqrstuvwxyz", "ab")); 49 | TEST_INT_EQ(1, unixem_util_str_begins_with("abcdefghijklmnopqrstuvwxyz", "a")); 50 | TEST_INT_EQ(0, unixem_util_str_begins_with("abcdefghijklmnopqrstuvwxyz", "abd")); 51 | TEST_INT_EQ(0, unixem_util_str_begins_with("abcdefghijklmnopqrstuvwxyz", "ad")); 52 | } 53 | } 54 | 55 | static void TEST_ends_with(void) 56 | { 57 | { 58 | TEST_INT_EQ(1, unixem_util_str_ends_with("", "")); 59 | TEST_INT_EQ(0, unixem_util_str_ends_with("", "abc")); 60 | TEST_INT_EQ(1, unixem_util_str_ends_with("abc", "")); 61 | } 62 | 63 | { 64 | TEST_INT_EQ(1, unixem_util_str_ends_with("abc", "abc")); 65 | TEST_INT_EQ(1, unixem_util_str_ends_with("abc", "bc")); 66 | TEST_INT_EQ(1, unixem_util_str_ends_with("abc", "c")); 67 | TEST_INT_EQ(0, unixem_util_str_ends_with("abc", "bbc")); 68 | TEST_INT_EQ(0, unixem_util_str_ends_with("abc", "ac")); 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /unixem.vc6.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "test.component.unistd.mkdtemp"=.\test\component\test.component.unistd.mkdtemp\vc6\test.component.unistd.mkdtemp.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | Begin Project Dependency 15 | Project_Dep_Name unixem.core 16 | End Project Dependency 17 | }}} 18 | 19 | ############################################################################### 20 | 21 | Project: "test.component.unistd.mkstemp"=.\test\component\test.component.unistd.mkstemp\vc6\test.component.unistd.mkstemp.dsp - Package Owner=<4> 22 | 23 | Package=<5> 24 | {{{ 25 | }}} 26 | 27 | Package=<4> 28 | {{{ 29 | Begin Project Dependency 30 | Project_Dep_Name unixem.core 31 | End Project Dependency 32 | }}} 33 | 34 | ############################################################################### 35 | 36 | Project: "test.scratch.dlfcn"=.\test\scratch\test.scratch.dlfcn\vc6\test.scratch.dlfcn.dsp - Package Owner=<4> 37 | 38 | Package=<5> 39 | {{{ 40 | }}} 41 | 42 | Package=<4> 43 | {{{ 44 | Begin Project Dependency 45 | Project_Dep_Name unixem.core 46 | End Project Dependency 47 | }}} 48 | 49 | ############################################################################### 50 | 51 | Project: "test.scratch.getrusage"=.\test\scratch\test.scratch.getrusage\vc6\test.scratch.getrusage.dsp - Package Owner=<4> 52 | 53 | Package=<5> 54 | {{{ 55 | }}} 56 | 57 | Package=<4> 58 | {{{ 59 | Begin Project Dependency 60 | Project_Dep_Name unixem.core 61 | End Project Dependency 62 | }}} 63 | 64 | ############################################################################### 65 | 66 | Project: "test.scratch.link"=.\test\scratch\test.scratch.link\vc6\test.scratch.link.dsp - Package Owner=<4> 67 | 68 | Package=<5> 69 | {{{ 70 | }}} 71 | 72 | Package=<4> 73 | {{{ 74 | Begin Project Dependency 75 | Project_Dep_Name unixem.core 76 | End Project Dependency 77 | }}} 78 | 79 | ############################################################################### 80 | 81 | Project: "test.scratch.setenv"=.\test\scratch\test.scratch.setenv\vc6\test.scratch.setenv.dsp - Package Owner=<4> 82 | 83 | Package=<5> 84 | {{{ 85 | }}} 86 | 87 | Package=<4> 88 | {{{ 89 | Begin Project Dependency 90 | Project_Dep_Name unixem.core 91 | End Project Dependency 92 | }}} 93 | 94 | ############################################################################### 95 | 96 | Project: "test.scratch.syslog"=.\test\scratch\test.scratch.syslog\vc6\test.scratch.syslog.dsp - Package Owner=<4> 97 | 98 | Package=<5> 99 | {{{ 100 | }}} 101 | 102 | Package=<4> 103 | {{{ 104 | Begin Project Dependency 105 | Project_Dep_Name unixem.core 106 | End Project Dependency 107 | }}} 108 | 109 | ############################################################################### 110 | 111 | Project: "test.scratch.uio"=.\test\scratch\test.scratch.uio\vc6\test.scratch.uio.dsp - Package Owner=<4> 112 | 113 | Package=<5> 114 | {{{ 115 | }}} 116 | 117 | Package=<4> 118 | {{{ 119 | Begin Project Dependency 120 | Project_Dep_Name unixem.core 121 | End Project Dependency 122 | }}} 123 | 124 | ############################################################################### 125 | 126 | Project: "test.unit.unistd.gethostname"=.\test\unit\test.unit.unistd.gethostname\vc6\test.unit.unistd.gethostname.dsp - Package Owner=<4> 127 | 128 | Package=<5> 129 | {{{ 130 | }}} 131 | 132 | Package=<4> 133 | {{{ 134 | Begin Project Dependency 135 | Project_Dep_Name unixem.core 136 | End Project Dependency 137 | }}} 138 | 139 | ############################################################################### 140 | 141 | Project: "unixem.core"=.\projects\core\vc6\unixem.core.dsp - Package Owner=<4> 142 | 143 | Package=<5> 144 | {{{ 145 | }}} 146 | 147 | Package=<4> 148 | {{{ 149 | }}} 150 | 151 | ############################################################################### 152 | 153 | Global: 154 | 155 | Package=<5> 156 | {{{ 157 | }}} 158 | 159 | Package=<3> 160 | {{{ 161 | }}} 162 | 163 | ############################################################################### 164 | 165 | --------------------------------------------------------------------------------