[MKISOFS]

Import a minimal version of the highly portable mkisofs tool from schily-2016-10-27 (https://sf.net/projects/schilytools) and use it for creating ReactOS ISOs from now on.

mkisofs is the de-facto standard ISO creation tool on most platforms and actively maintained.
Compared to cdmake, its features have matured and it adds ISO9660:1999 support among many other things.
I can import its UDF features as soon as we need them.

mkisofs has been integrated into our buildsystem in the sdk/tools/mkisofs folder with these subfolders:
* "reactos"
  Host-specific include files that are usually generated by the upstream buildsystem. For us, I have handcrafted them to be enough for mkisofs and compatible with Windows, Linux and Mac OS X.
  Follow the original layout of the generated files whenever you have to edit these.
* "schilytools"
  Contains the actual mkisofs code and dependencies while maintaining the original directory layout.
  Only synchronize with newer versions, but never modify. Submit patches upstream instead :)

ISOs are now being built with a single ISO9660:1999 filesystem instead of classic ISO9660 + Joliet.
For the moment, you can switch back to cdmake using -DUSE_MKISOFS:BOOL=0 on the CMake commandline. cdmake will be completely removed in about a month if no problems occur.

CORE-11988

svn path=/trunk/; revision=73051
This commit is contained in:
Colin Finck
2016-10-27 22:51:59 +00:00
parent f642128e8f
commit 96877abf85
120 changed files with 36797 additions and 27 deletions
+6 -2
View File
@@ -37,6 +37,10 @@ set(CMAKE_COLOR_MAKEFILE OFF)
#set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
set(CMAKE_SKIP_INSTALL_RULES ON)
if(NOT DEFINED USE_MKISOFS)
set(USE_MKISOFS TRUE)
endif()
if(NOT DEFINED NEW_STYLE_BUILD)
set(NEW_STYLE_BUILD TRUE)
endif()
@@ -106,9 +110,9 @@ if(NOT CMAKE_CROSSCOMPILING)
if(NOT NEW_STYLE_BUILD)
if(NOT MSVC)
export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
else()
export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
endif()
endif()
+64 -24
View File
@@ -24,47 +24,87 @@ add_custom_target(efisys
#clear it out
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst "")
add_custom_target(bootcd
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst REACTOS ${REACTOS_BINARY_DIR}/bootcd.iso
DEPENDS native-cdmake efisys
VERBATIM)
if(USE_MKISOFS)
add_custom_target(bootcd
COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/bootcd.iso -iso-level 4 -volid "ReactOS" -path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst -graft-points -no-cache-inodes -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -hide boot.catalog -publisher "ReactOS Foundation" -preparer "ReactOS Foundation"
DEPENDS native-mkisofs
VERBATIM)
else()
add_custom_target(bootcd
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/bootcd.lst REACTOS ${REACTOS_BINARY_DIR}/bootcd.iso
DEPENDS native-cdmake efisys
VERBATIM)
endif()
##bootcdregtest
#clear it out
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst "")
add_custom_target(bootcdregtest
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isobtrt.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst REACTOS ${REACTOS_BINARY_DIR}/bootcdregtest.iso
DEPENDS native-cdmake efisys
VERBATIM)
if(USE_MKISOFS)
add_custom_target(bootcdregtest
COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/bootcdregtest.iso -iso-level 4 -volid "ReactOS" -path-list ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst -graft-points -no-cache-inodes -eltorito-boot loader/isobtrt.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -hide boot.catalog -publisher "ReactOS Foundation" -preparer "ReactOS Foundation"
DEPENDS native-mkisofs
VERBATIM)
else()
add_custom_target(bootcdregtest
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isobtrt.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.lst REACTOS ${REACTOS_BINARY_DIR}/bootcdregtest.iso
DEPENDS native-cdmake efisys
VERBATIM)
endif()
##livecd
#clear it out
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "")
#create the empty Desktop, Favorites, and Start Menu folders
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Desktop\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Favorites\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Start Menu/Programs\n")
if(USE_MKISOFS)
#create the empty Desktop, Favorites, and Start Menu folders
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Desktop=${REACTOS_SOURCE_DIR}/boot/bootdata/empty\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Favorites=${REACTOS_SOURCE_DIR}/boot/bootdata/empty\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Start Menu/Programs=${REACTOS_SOURCE_DIR}/boot/bootdata/empty\n")
add_custom_target(livecd
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/livecd.lst REACTOS ${REACTOS_BINARY_DIR}/livecd.iso
DEPENDS native-cdmake efisys
VERBATIM)
add_custom_target(livecd
COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/livecd.iso -iso-level 4 -volid "ReactOS" -path-list ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst -graft-points -no-cache-inodes -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -hide boot.catalog -publisher "ReactOS Foundation" -preparer "ReactOS Foundation"
DEPENDS native-mkisofs
VERBATIM)
else()
#create the empty Desktop, Favorites, and Start Menu folders
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Desktop\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Favorites\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/livecd.lst "Profiles/Default User/Start Menu/Programs\n")
add_custom_target(livecd
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/livecd.lst REACTOS ${REACTOS_BINARY_DIR}/livecd.iso
DEPENDS native-cdmake efisys
VERBATIM)
endif()
##hybridcd
#clear it out
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "")
#create the empty Desktop, Favorites, and Start Menu folders
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Desktop\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Favorites\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Start Menu/Programs\n")
if(USE_MKISOFS)
#create the empty Desktop, Favorites, and Start Menu folders
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Desktop=${REACTOS_SOURCE_DIR}/boot/bootdata/empty\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Favorites=${REACTOS_SOURCE_DIR}/boot/bootdata/empty\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Start Menu/Programs=${REACTOS_SOURCE_DIR}/boot/bootdata/empty\n")
add_custom_target(hybridcd
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst REACTOS ${REACTOS_BINARY_DIR}/hybridcd.iso
DEPENDS native-cdmake efisys bootcd livecd
VERBATIM)
add_custom_target(hybridcd
COMMAND native-mkisofs -o ${REACTOS_BINARY_DIR}/hybridcd.iso -iso-level 4 -volid "ReactOS" -path-list ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst -graft-points -no-cache-inodes -eltorito-boot loader/isoboot.bin -no-emul-boot -boot-load-size 4 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot loader/efisys.bin -hide boot.catalog -publisher "ReactOS Foundation" -preparer "ReactOS Foundation"
DEPENDS native-mkisofs bootcd livecd
VERBATIM)
add_cd_file(TARGET efisys FILE ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin DESTINATION loader NO_CAB FOR bootcd regtest livecd hybridcd)
else()
#create the empty Desktop, Favorites, and Start Menu folders
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Desktop\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Favorites\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst "livecd/Profiles/Default User/Start Menu/Programs\n")
add_custom_target(hybridcd
COMMAND native-cdmake -j -m -bootdata:2\#p0,e,b${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin\#pEF,e,b${CMAKE_CURRENT_BINARY_DIR}/efisys.bin @${CMAKE_CURRENT_BINARY_DIR}/hybridcd.lst REACTOS ${REACTOS_BINARY_DIR}/hybridcd.iso
DEPENDS native-cdmake efisys bootcd livecd
VERBATIM)
endif()
add_subdirectory(freeldr)
add_subdirectory(bootdata)
+1 -1
View File
@@ -6,7 +6,7 @@ endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
# List of host tools
list(APPEND host_tools_list bin2c hpp widl gendib cabman cdmake fatten mkhive obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
list(APPEND host_tools_list bin2c hpp widl gendib cabman cdmake fatten mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
if(NOT MSVC)
list(APPEND host_tools_list rsym)
endif()
+1
View File
@@ -30,6 +30,7 @@ add_subdirectory(hhpcomp)
add_subdirectory(hpp)
add_subdirectory(kbdtool)
add_subdirectory(mkhive)
add_subdirectory(mkisofs)
add_subdirectory(unicode)
add_subdirectory(widl)
add_subdirectory(wpp)
+87
View File
@@ -0,0 +1,87 @@
add_definitions(
-DINS_BASE="\\".\\""
-DSCHILY_BUILD
-DSORTING)
include_directories(
schilytools/include
reactos
${REACTOS_BINARY_DIR}/sdk/include)
# libschily and libsiconv are licensed under CDDL whereas mkisofs is licensed under GPL.
# As such, we cannot mix the library sources with mkisofs sources and have to build them seperately.
# Later on, they may still be linked together though.
#
# Reference: http://opensource.stackexchange.com/questions/2094
add_library(libschily
schilytools/libschily/stdio/cvmod.c
schilytools/libschily/stdio/dat.c
schilytools/libschily/stdio/fcons.c
schilytools/libschily/stdio/ffileread.c
schilytools/libschily/stdio/fgetline.c
schilytools/libschily/stdio/fileopen.c
schilytools/libschily/stdio/filewrite.c
schilytools/libschily/stdio/flag.c
schilytools/libschily/stdio/niwrite.c
schilytools/libschily/astoll.c
schilytools/libschily/checkerr.c
schilytools/libschily/comerr.c
schilytools/libschily/dirent.c
schilytools/libschily/eaccess.c
schilytools/libschily/error.c
schilytools/libschily/fconv.c
schilytools/libschily/fillbytes.c
schilytools/libschily/fnmatch.c
schilytools/libschily/format.c
schilytools/libschily/getargs.c
schilytools/libschily/geterrno.c
schilytools/libschily/getexecpath.c
schilytools/libschily/gettimeofday.c
schilytools/libschily/gid.c
schilytools/libschily/jsprintf.c
schilytools/libschily/jssnprintf.c
schilytools/libschily/match.c
schilytools/libschily/mem.c
schilytools/libschily/movebytes.c
schilytools/libschily/raisecond.c
schilytools/libschily/saveargs.c
schilytools/libschily/searchinpath.c
schilytools/libschily/seterrno.c
schilytools/libschily/streql.c
schilytools/libschily/strlcat.c
schilytools/libschily/strlcpy.c
schilytools/libschily/uid.c
schilytools/libschily/zerobytes.c)
add_library(libsiconv
schilytools/libsiconv/sic_nls.c)
target_link_libraries(libsiconv libschily)
add_host_tool(mkisofs
schilytools/mkisofs/boot.c
schilytools/mkisofs/eltorito.c
schilytools/mkisofs/hash.c
schilytools/mkisofs/inode.c
schilytools/mkisofs/isonum.c
schilytools/mkisofs/joliet.c
schilytools/mkisofs/match.c
schilytools/mkisofs/mkisofs.c
schilytools/mkisofs/multi.c
schilytools/mkisofs/name.c
schilytools/mkisofs/rock.c
schilytools/mkisofs/stream.c
schilytools/mkisofs/tree.c
schilytools/mkisofs/write.c)
target_link_libraries(mkisofs libschily libsiconv)
if(MSVC)
# mkisofs uses K&R-style function definitions to support very old compilers.
# MSVC complains about the resulting foo() vs. foo(void) mismatches.
add_target_compile_flags(mkisofs "/wd4113")
else()
# libschily implements an own printf function with support for the %r formatter.
# Silence compilers checking for invalid formatting sequences.
add_target_compile_flags(libschily "-Wno-format")
endif()
+22
View File
@@ -0,0 +1,22 @@
/*
* PROJECT: MKISOFS for the ReactOS Build System
* LICENSE: GNU GPLv2 as published by the Free Software Foundation
* AUTHORS: Colin Finck <[email protected]>
*/
#ifndef __ALIGN_H
#define __ALIGN_H
#ifdef __LP64__
#define ALIGN_LMASK 7
#else
#define ALIGN_LMASK 3
#endif
#define xaligned(a, s) ((((UIntptr_t)(a)) & (s)) == 0)
#define x2aligned(a, b, s) (((((UIntptr_t)(a)) | ((UIntptr_t)(b))) & (s)) == 0)
#define laligned(a) xaligned(a, ALIGN_LMASK)
#define l2aligned(a, b) x2aligned(a, b, ALIGN_LMASK)
#endif
@@ -0,0 +1,2 @@
/* This file is intentionally left blank.
* libschily depends on a buildsystem-generated avoffset.h, but its content isn't relevant for mkisofs. */
+207
View File
@@ -0,0 +1,207 @@
/*
* PROJECT: MKISOFS for the ReactOS Build System
* LICENSE: GNU GPLv2 as published by the Free Software Foundation
* AUTHORS: Colin Finck <[email protected]>
*/
/*
* When mkisofs is part of Schily tools, this file is generated by the Schily Build System
* and checks the existence of hundreds of headers and functions.
* For the ReactOS Build System, we provide a written version of this file with sufficient
* information to build mkisofs and universal among our supported build platforms.
*/
#ifndef __XCONFIG_H
#define __XCONFIG_H
/*
* Header Files
*/
#define PROTOTYPES 1
#define HAVE_STDARG_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STRING_H 1
#define STDC_HEADERS 1
#ifndef WIN32
#define HAVE_UNISTD_H 1
#endif
#define HAVE_LIMITS_H 1
#define HAVE_FCNTL_H 1
#ifdef WIN32
#define HAVE_IO_H 1
#endif
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#ifndef WIN32
#define HAVE_DIRENT_H 1
#define HAVE_SYS_TIME_H 1
#define TIME_WITH_SYS_TIME 1
#endif
#define HAVE_SYS_TYPES_H 1
#define HAVE_MATH_H 1
#define HAVE_ERRNO_DEF 1
#ifdef WIN32
#define HAVE_WINDOWS_H 1
#define WBOOL WINBOOL
#endif
#define HAVE_LOCALE_H 1
#define HAVE_CTYPE_H 1
#define HAVE_WCTYPE_H 1
#define HAVE_WCHAR_H 1
/*
* Convert to SCHILY name
*/
#define HAVE_STDC_HEADERS
/*
* Library Functions
*/
#define HAVE_STRERROR 1
#define HAVE_MEMCHR 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMSET 1
#ifndef WIN32
#define HAVE_GETTIMEOFDAY 1
#endif
#define HAVE_TIME 1
#define HAVE_VA_COPY 1
#define HAVE_ECVT 1
#define HAVE_FCVT 1
#define HAVE_GCVT 1
#define HAVE_C99_ISINF 1
#define HAVE_C99_ISNAN 1
#define HAVE_SNPRINTF 1
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#define HAVE_STRCAT 1
#define HAVE_STRNCAT 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRCPY 1
#ifdef __APPLE__
#define HAVE_STRLCAT 1
#define HAVE_STRLCPY 1
#endif
#define HAVE_STRNCPY 1
#define HAVE_STRDUP 1
#define HAVE_STRLEN 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#ifndef WIN32
#define HAVE_USLEEP 1
#endif
#define HAVE_WCSCAT 1
#define HAVE_WCSNCAT 1
#define HAVE_WCSCMP 1
#define HAVE_WCSNCMP 1
#define HAVE_WCSCPY 1
#ifdef __APPLE__
#define HAVE_WCSLCAT 1
#define HAVE_WCSLCPY 1
#endif
#define HAVE_WCSNCPY 1
#define HAVE_WCSDUP 1
#define HAVE_WCSNDUP 1
#define HAVE_WCSLEN 1
#define HAVE_WCSNLEN 1
#define HAVE_WCSCHR 1
#define HAVE_WCSRCHR 1
#define HAVE_WCSSTR 1
#ifndef WIN32
#define HAVE_WCWIDTH 1
#endif
#define HAVE_SETVBUF 1
#define HAVE_ISWPRINT 1
#define HAVE_MBSINIT 1
#define HAVE_MBTOWC 1
#define HAVE_WCTOMB 1
#define HAVE_MBRTOWC 1
#define HAVE_WCRTOMB 1
#if !defined(WIN32) && !defined(__APPLE__)
#define HAVE_RAW_FEXECVE 1
#endif
/*
* Misc OS stuff
*/
#ifndef WIN32
#define HAVE__DEV_NULL 1
#endif
/*
* Structures
*/
#ifndef WIN32
#define HAVE_STRUCT_TIMEVAL 1
#endif
#define HAVE_STRUCT_TIMEZONE 1
#define HAVE_STRUCT_TIMESPEC 1
/*
* Types/Keywords
*/
#define HAVE_LONGLONG 1
#ifndef WIN32
#define VA_LIST_IS_ARRAY 1
#endif
#ifdef WIN32
#define uid_t int
#define gid_t int
#define nlink_t unsigned long
#ifdef _MSC_VER
#define mode_t int
#endif
#endif
#define HAVE_TYPE_INTMAX_T 1
#define HAVE_TYPE_UINTMAX_T 1
/*
* ReactOS additions
*/
#ifdef _MSC_VER
#define ssize_t int
#endif
/* Would need additional fprformat.c, less portable */
#define NO_FPRFORMAT
/* For a nice "mkisofs -version" :) */
#include <reactos/buildno.h>
#define HOST_CPU "ReactOS"
#define HOST_VENDOR KERNEL_VERSION_BUILD_STR
#define HOST_OS REACTOS_COMPILER_NAME "-" REACTOS_COMPILER_VERSION
#endif
@@ -0,0 +1,376 @@
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0
1. Definitions.
1.1. "Contributor" means each individual or entity that creates
or contributes to the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Software, prior Modifications used by a Contributor (if any),
and the Modifications made by that particular Contributor.
1.3. "Covered Software" means (a) the Original Software, or (b)
Modifications, or (c) the combination of files containing
Original Software with files containing Modifications, in
each case including portions thereof.
1.4. "Executable" means the Covered Software in any form other
than Source Code.
1.5. "Initial Developer" means the individual or entity that first
makes Original Software available under this License.
1.6. "Larger Work" means a work which combines Covered Software or
portions thereof with code not governed by the terms of this
License.
1.7. "License" means this document.
1.8. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed
herein.
1.9. "Modifications" means the Source Code and Executable form of
any of the following:
A. Any file that results from an addition to, deletion from or
modification of the contents of a file containing Original
Software or previous Modifications;
B. Any new file that contains any part of the Original
Software or previous Modifications; or
C. Any new file that is contributed or otherwise made
available under the terms of this License.
1.10. "Original Software" means the Source Code and Executable
form of computer software code that is originally released
under this License.
1.11. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method,
process, and apparatus claims, in any patent Licensable by
grantor.
1.12. "Source Code" means (a) the common form of computer software
code in which modifications are made and (b) associated
documentation included in or with such code.
1.13. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms
of, this License. For legal entities, "You" includes any
entity which controls, is controlled by, or is under common
control with You. For purposes of this definition,
"control" means (a) the power, direct or indirect, to cause
the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty
percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants.
2.1. The Initial Developer Grant.
Conditioned upon Your compliance with Section 3.1 below and
subject to third party intellectual property claims, the Initial
Developer hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer, to use,
reproduce, modify, display, perform, sublicense and
distribute the Original Software (or portions thereof),
with or without Modifications, and/or as part of a Larger
Work; and
(b) under Patent Claims infringed by the making, using or
selling of Original Software, to make, have made, use,
practice, sell, and offer for sale, and/or otherwise
dispose of the Original Software (or portions thereof).
(c) The licenses granted in Sections 2.1(a) and (b) are
effective on the date Initial Developer first distributes
or otherwise makes the Original Software available to a
third party under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: (1) for code that You delete from the Original
Software, or (2) for infringements caused by: (i) the
modification of the Original Software, or (ii) the
combination of the Original Software with other software
or devices.
2.2. Contributor Grant.
Conditioned upon Your compliance with Section 3.1 below and
subject to third party intellectual property claims, each
Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor to use, reproduce,
modify, display, perform, sublicense and distribute the
Modifications created by such Contributor (or portions
thereof), either on an unmodified basis, with other
Modifications, as Covered Software and/or as part of a
Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either
alone and/or in combination with its Contributor Version
(or portions of such combination), to make, use, sell,
offer for sale, have made, and/or otherwise dispose of:
(1) Modifications made by that Contributor (or portions
thereof); and (2) the combination of Modifications made by
that Contributor with its Contributor Version (or portions
of such combination).
(c) The licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first distributes or
otherwise makes the Modifications available to a third
party.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: (1) for any code that Contributor has deleted
from the Contributor Version; (2) for infringements caused
by: (i) third party modifications of Contributor Version,
or (ii) the combination of Modifications made by that
Contributor with other software (except as part of the
Contributor Version) or other devices; or (3) under Patent
Claims infringed by Covered Software in the absence of
Modifications made by that Contributor.
3. Distribution Obligations.
3.1. Availability of Source Code.
Any Covered Software that You distribute or otherwise make
available in Executable form must also be made available in Source
Code form and that Source Code form must be distributed only under
the terms of this License. You must include a copy of this
License with every copy of the Source Code form of the Covered
Software You distribute or otherwise make available. You must
inform recipients of any such Covered Software in Executable form
as to how they can obtain such Covered Software in Source Code
form in a reasonable manner on or through a medium customarily
used for software exchange.
3.2. Modifications.
The Modifications that You create or to which You contribute are
governed by the terms of this License. You represent that You
believe Your Modifications are Your original creation(s) and/or
You have sufficient rights to grant the rights conveyed by this
License.
3.3. Required Notices.
You must include a notice in each of Your Modifications that
identifies You as the Contributor of the Modification. You may
not remove or alter any copyright, patent or trademark notices
contained within the Covered Software, or any notices of licensing
or any descriptive text giving attribution to any Contributor or
the Initial Developer.
3.4. Application of Additional Terms.
You may not offer or impose any terms on any Covered Software in
Source Code form that alters or restricts the applicable version
of this License or the recipients' rights hereunder. You may
choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of
Covered Software. However, you may do so only on Your own behalf,
and not on behalf of the Initial Developer or any Contributor.
You must make it absolutely clear that any such warranty, support,
indemnity or liability obligation is offered by You alone, and You
hereby agree to indemnify the Initial Developer and every
Contributor for any liability incurred by the Initial Developer or
such Contributor as a result of warranty, support, indemnity or
liability terms You offer.
3.5. Distribution of Executable Versions.
You may distribute the Executable form of the Covered Software
under the terms of this License or under the terms of a license of
Your choice, which may contain terms different from this License,
provided that You are in compliance with the terms of this License
and that the license for the Executable form does not attempt to
limit or alter the recipient's rights in the Source Code form from
the rights set forth in this License. If You distribute the
Covered Software in Executable form under a different license, You
must make it absolutely clear that any terms which differ from
this License are offered by You alone, not by the Initial
Developer or Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred
by the Initial Developer or such Contributor as a result of any
such terms You offer.
3.6. Larger Works.
You may create a Larger Work by combining Covered Software with
other code not governed by the terms of this License and
distribute the Larger Work as a single product. In such a case,
You must make sure the requirements of this License are fulfilled
for the Covered Software.
4. Versions of the License.
4.1. New Versions.
Sun Microsystems, Inc. is the initial license steward and may
publish revised and/or new versions of this License from time to
time. Each version will be given a distinguishing version number.
Except as provided in Section 4.3, no one other than the license
steward has the right to modify this License.
4.2. Effect of New Versions.
You may always continue to use, distribute or otherwise make the
Covered Software available under the terms of the version of the
License under which You originally received the Covered Software.
If the Initial Developer includes a notice in the Original
Software prohibiting it from being distributed or otherwise made
available under any subsequent version of the License, You must
distribute and make the Covered Software available under the terms
of the version of the License under which You originally received
the Covered Software. Otherwise, You may also choose to use,
distribute or otherwise make the Covered Software available under
the terms of any subsequent version of the License published by
the license steward.
4.3. Modified Versions.
When You are an Initial Developer and You want to create a new
license for Your Original Software, You may create and use a
modified version of this License if You: (a) rename the license
and remove any references to the name of the license steward
(except to note that the license differs from this License); and
(b) otherwise make it clear that the license contains terms which
differ from this License.
5. DISCLAIMER OF WARRANTY.
COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
DISCLAIMER.
6. TERMINATION.
6.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to
cure such breach within 30 days of becoming aware of the breach.
Provisions which, by their nature, must remain in effect beyond
the termination of this License shall survive.
6.2. If You assert a patent infringement claim (excluding
declaratory judgment actions) against Initial Developer or a
Contributor (the Initial Developer or Contributor against whom You
assert such claim is referred to as "Participant") alleging that
the Participant Software (meaning the Contributor Version where
the Participant is a Contributor or the Original Software where
the Participant is the Initial Developer) directly or indirectly
infringes any patent, then any and all rights granted directly or
indirectly to You by such Participant, the Initial Developer (if
the Initial Developer is not the Participant) and all Contributors
under Sections 2.1 and/or 2.2 of this License shall, upon 60 days
notice from Participant terminate prospectively and automatically
at the expiration of such 60 day notice period, unless if within
such 60 day period You withdraw Your claim with respect to the
Participant Software against such Participant either unilaterally
or pursuant to a written agreement with Participant.
6.3. In the event of termination under Sections 6.1 or 6.2 above,
all end user licenses that have been validly granted by You or any
distributor hereunder prior to termination (excluding licenses
granted to You by any distributor) shall survive termination.
7. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
APPLY TO YOU.
8. U.S. GOVERNMENT END USERS.
The Covered Software is a "commercial item," as that term is
defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
computer software" (as that term is defined at 48
C.F.R. 252.227-7014(a)(1)) and "commercial computer software
documentation" as such terms are used in 48 C.F.R. 12.212
(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48
C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all
U.S. Government End Users acquire Covered Software with only those
rights set forth herein. This U.S. Government Rights clause is in
lieu of, and supersedes, any other FAR, DFAR, or other clause or
provision that addresses Government rights in computer software
under this License.
9. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed
by the law of the jurisdiction specified in a notice contained
within the Original Software (except to the extent applicable law,
if any, provides otherwise), excluding such jurisdiction's
conflict-of-law provisions. Any litigation relating to this
License shall be subject to the jurisdiction of the courts located
in the jurisdiction and venue specified in a notice contained
within the Original Software, with the losing party responsible
for costs, including, without limitation, court costs and
reasonable attorneys' fees and expenses. The application of the
United Nations Convention on Contracts for the International Sale
of Goods is expressly excluded. Any law or regulation which
provides that the language of a contract shall be construed
against the drafter shall not apply to this License. You agree
that You alone are responsible for compliance with the United
States export administration regulations (and the export control
laws and regulation of any other countries) when You use,
distribute or otherwise make available any Covered Software.
10. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or
indirectly, out of its utilization of rights under this License
and You agree to work with Initial Developer and Contributors to
distribute such responsibility on an equitable basis. Nothing
herein is intended or shall be deemed to constitute any admission
of liability.
--------------------------------------------------------------------
NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
DISTRIBUTION LICENSE (CDDL)
For Covered Software in this distribution, this License shall
be governed by the laws of Germany (excluding conflict-of-law
provisions).
Any litigation relating to this License shall be subject to the
jurisdiction and the courts of Berlin Germany, with venue lying
in Berlin Germany.
@@ -0,0 +1,6 @@
/* @(#)version.h 1.92 16/01/26 Copyright 2007-2016 J. Schilling */
/*
* The version for cdrtools programs
*/
#define VERSION "3.02a06"
@@ -0,0 +1,173 @@
/* @(#)align.h 1.11 13/07/23 Copyright 1995-2013 J. Schilling */
/*
* Platform dependent definitions for aligning data.
*
* Copyright (c) 1995-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
/*
* The automatically created included file defines the following macros:
*
* saligned(a) One parameter aligned for a "short int"
* s2aligned(a, b) Both parameters aligned for a "short int"
* ialigned(a) One parameter aligned for a "int"
* i2aligned(a, b) Both parameters aligned for a "int"
* laligned(a) One parameter aligned for a "long"
* l2aligned(a, b) Both parameters aligned for a "long"
* llaligned(a) One parameter aligned for a "long long"
* ll2aligned(a, b) Both parameters aligned for a "long long"
* faligned(a) One parameter aligned for a "float"
* f2aligned(a, b) Both parameters aligned for a "float"
* daligned(a) One parameter aligned for a "double"
* d2aligned(a, b) Both parameters aligned for a "double"
* paligned(a) One parameter aligned for a "pointer"
* p2aligned(a, b) Both parameters aligned for a "pointe"
*
* salign(x) Align for a "short int"
* ialign(x) Align for a "int"
* lalign(x) Align for a "long"
* llalign(x) Align for a "long long"
* falign(x) Align for a "float"
* dalign(x) Align for a "double"
* palign(x) Align for a "pointer"
*/
#ifndef _SCHILY_ALIGN_H
#define _SCHILY_ALIGN_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h>
#endif
#ifdef SCHILY_BUILD /* #defined by Schily makefile system */
/*
* Include $(SRCROOT)/incs/$(OARCH)/align.h via
* -I$(SRCROOT)/incs/$(OARCH)/
*/
# include <align.h>
#else /* !SCHILY_BUILD */
/*
* The stuff for static compilation. Include files from a previous
* dynamic autoconfiguration.
*/
#ifdef __SUNOS5_SPARC_CC32
#include <schily/sparc-sunos5-cc/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_SPARC_CC64
#include <schily/sparc-sunos5-cc64/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_SPARC_GCC32
#include <schily/sparc-sunos5-gcc/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_SPARC_GCC64
#include <schily/sparc-sunos5-gcc64/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_X86_CC32
#include <schily/i386-sunos5-cc/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_X86_CC64
#include <schily/i386-sunos5-cc64/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_X86_GCC32
#include <schily/i386-sunos5-gcc/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __SUNOS5_X86_GCC64
#include <schily/i386-sunos5-gcc64/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __HPUX_HPPA_CC32
#include <schily/hppa-hp-ux-cc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_CC64
#include <schily/hppa-hp-ux-cc64/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_GCC32
#include <schily/hppa-hp-ux-gcc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_GCC64
#include <schily/hppa-hp-ux-gcc64/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV6L_GCC32
#include <schily/armv6l-linux-gcc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV5L_GCC32
#include <schily/armv6l-linux-gcc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV5TEJL_GCC32
#include <schily/armv5tejl-linux-gcc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_I386_GCC32
#include <schily/i686-linux-gcc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_amd64_GCC64
#include <schily/x86_64-linux-gcc/align.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __MSWIN_X86_CL32
#include <schily/i686-cygwin32_nt-cl/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifdef __CYGWIN_X86_GCC
#include <schily/i686-cygwin32_nt-gcc/align.h>
#define __JS_ARCH_ALIGN_INCL
#endif
#ifndef __JS_ARCH_ALIGN_INCL
/*
* #error will not work for all compilers (e.g. sunos4)
* The following line will abort compilation on all compilers
* if none of the above is defined. And that's what we want.
*/
Error unconfigured architecture
#include <schily/err_arch.h> /* Avoid "unknown directive" with K&R */
#endif
#endif /* SCHILY_BUILD */
#ifdef __cplusplus
extern "C" {
#endif
/*
* Fake in order to keep the silly hdrchk(1) quiet.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_ALIGN_H */
@@ -0,0 +1,288 @@
/* @(#)archdefs.h 1.14 13/07/23 Copyright 2006-2013 J. Schilling */
/*
* Processor, instruction set and OS architecture specific defines.
* The information is fetched from compiler predefinitions only.
*
* Copyright (c) 2006-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_ARCHDEFS_H
#define _SCHILY_ARCHDEFS_H
/*
* The code in this file only depends on compiler predefined macros.
* For this reason, it does not need to include schily/mconfig.h
*/
#if defined(sun) || defined(__sun) || defined(__sun__)
#ifndef __sun
#define __sun
#endif
#endif
#if defined(sun2)
#ifndef __mc68010
#define __mc68010
#endif
#endif
#if defined(mc68020) || defined(__mc68020) || defined(sun3)
#ifndef __mc68020
#define __mc68020
#endif
#endif
#if defined(__mc68010) || defined(__mc68020)
#ifndef __mc68000
#define __mc68000
#endif
#endif
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
#ifndef __i386
#define __i386
#endif
#endif
#if defined(__amd64) || defined(__amd64__) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64)
#ifndef __amd64
#define __amd64
#endif
#endif
#if defined(__i386) || defined(__amd64)
#ifndef __x86
#define __x86
#endif
#endif
#if defined(sparc) || defined(__sparc) || defined(__sparc__)
#ifndef __sparc
#define __sparc
#endif
#endif
#if defined(__sparcv9) || defined(__sparcv9__)
#ifndef __sparc
#define __sparc
#endif
#ifndef __sparcv9
#define __sparcv9
#endif
#endif
#if defined(__sparc) && defined(__arch64__)
#ifndef __sparcv9
#define __sparcv9
#endif
#endif
#if defined(SOL2) || defined(SOL2) || \
defined(S5R4) || defined(__S5R4) || defined(SVR4)
# ifndef __SVR4
# define __SVR4
# endif
#endif
#if defined(sun2) || defined(sun3) || defined(__sun)
#ifndef __sun
#define __sun
#endif
#ifndef __GNUC__
#ifndef __SUNPRO_C
#ifdef __SVR4
#define __SUNPRO_C
#else
#define __SUN_C
#endif /* __SVR4 */
#endif /* !__SUNPRO_C */
#endif /* !__GNUC__ */
#endif /* __sun */
/*
* SunOS 4 specific defines
*/
#if defined(__sun) && !defined(__SVR4)
#define __SUNOS4
#if defined(__mc68000)
#define __SUNOS4_MC68000
#ifdef __GNUC__
#define __SUNOS4_MC68000_GCC32
#define __JS_ARCH_DEFINED
#endif
#ifdef __SUN_C
#define __SUNOS4_MC68000_CC32
#define __JS_ARCH_DEFINED
#endif
#endif /* __mc68000 */
#if defined(__sparc)
#define __SUNOS4_SPARC
#ifdef __GNUC__
#define __SUNOS4_SPARC_GCC32
#define __JS_ARCH_DEFINED
#endif
#if defined(__SUN_C) || defined(__SUNPRO_C)
#define __SUNOS4_SPARC_CC32
#define __JS_ARCH_DEFINED
#endif
#endif /* __sparc */
#endif /* SunOS 4 */
/*
* SunOS 5 specific defines
*/
#if defined(__sun) && defined(__SVR4)
#define __SUNOS5
#if defined(__sparc)
#ifdef __GNUC__
#ifdef __sparcv9
#define __SUNOS5_SPARC_GCC64
#else
#define __SUNOS5_SPARC_GCC32
#endif
#define __JS_ARCH_DEFINED
#endif
#if defined(__SUNPRO_C)
#ifdef __sparcv9
#define __SUNOS5_SPARC_CC64
#else
#define __SUNOS5_SPARC_CC32
#endif
#define __JS_ARCH_DEFINED
#endif
#endif /* __sparc */
#if defined(__x86)
#ifdef __GNUC__
#ifdef __amd64
#define __SUNOS5_X86_GCC64
#else
#define __SUNOS5_X86_GCC32
#endif
#define __JS_ARCH_DEFINED
#endif
#if defined(__SUNPRO_C)
#ifdef __amd64
#define __SUNOS5_X86_CC64
#else
#define __SUNOS5_X86_CC32
#endif
#define __JS_ARCH_DEFINED
#endif
#endif /* __x86 */
#endif /* SunOS 5 */
/*
* HP-UX specific defines
*/
#if defined(__hpux)
#if defined(__hppa)
#ifdef __GNUC__
#ifdef __LP64__ /* This may be wrong! */
#define __HPUX_HPPA_GCC64
#else
#define __HPUX_HPPA_GCC32
#endif
#define __JS_ARCH_DEFINED
#endif
#if !defined(__GNUC__)
#ifdef __LP64__
#define __HPUX_HPPA_CC64
#else
#define __HPUX_HPPA_CC32
#endif
#define __JS_ARCH_DEFINED
#endif
#endif /* __hppa */
#endif /* HP-UX */
/*
* Linux specific defines
*/
#if defined(__linux)
#if defined(__arm__)
#ifdef __GNUC__
#ifdef __ARM_ARCH_5TE__
#define __LINUX_ARMV5TEJL_GCC32
#define __JS_ARCH_DEFINED
#endif
#ifndef __JS_ARCH_DEFINED
#ifdef __ARM_ARCH_6__
#define __LINUX_ARMV6L_GCC32
#define __JS_ARCH_DEFINED
#endif
#endif
#ifndef __JS_ARCH_DEFINED
#ifdef __ARM_ARCH_5__
#define __LINUX_ARMV5L_GCC32
#define __JS_ARCH_DEFINED
#endif
#endif
#endif /* __GNUC__ */
#endif /* __arm__ */
#if defined(__i386__) || defined(i386)
#ifdef __GNUC__
#define __LINUX_I386_GCC32
#define __JS_ARCH_DEFINED
#endif
#endif /* __i386__ */
#if defined(__amd64__) || defined(__amd64)
#ifdef __GNUC__
#define __LINUX_amd64_GCC64
#define __JS_ARCH_DEFINED
#endif
#endif /* __amd64__ */
#endif /* Linux */
/*
* MS-WIN specific defines
*
* cl defines one of:
* _M_ALPHA
* _M_IX86
* _M_AMD64
* _M_M68K
* _M_PPC PPC in general
* _M_MPPC Power Macintosh
* _M_MRX000 Mips
* _M_IA64 Itanium
*/
#if defined(_MSC_VER) && (defined(_X86_) || defined(_M_IX86))
#define __MSWIN_X86_CL32
#define __JS_ARCH_DEFINED
#endif
#if defined(__CYGWIN32__) || defined(__CYGWIN__)
#define __CYGWIN_X86_GCC
#define __JS_ARCH_DEFINED
#endif
#endif /* _SCHILY_ARCHDEFS_H */
@@ -0,0 +1,164 @@
/* @(#)avoffset.h 1.13 13/08/26 Copyright 1995-2013 J. Schilling */
/*
* Platform dependent definitions for stack scanning.
*
* Copyright (c) 1995-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
/*
* This file includes definitions for STACK_DIRECTION,
* AV_OFFSET and FP_INDIR.
*
* STACK_DIRECTION:
* +1 -> stack grows to larger addresses
* -1 -> stack "groes" to lower addresses
*
* FP_INDIR: the number of fp chain elements above 'main'.
*
* AV_OFFSET: the offset of &av[0] relative to the frame pointer
* in 'main'.
*
* If getav0() does not work on a specific architecture
* the program which generated this automaticly generated include file
* may dump core. In this case, the generated include file does not include
* definitions for AV_OFFSET and FP_INDIR but ends after the
* STACK_DIRECTION definition.
* If AV_OFFSET or FP_INDIR are missing in the file, all code
* that use the definitions are automatically disabled.
*/
#ifndef _SCHILY_AVOFFSET_H
#define _SCHILY_AVOFFSET_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef SCHILY_BUILD /* #defined by Schily makefile system */
/*
* Include $(SRCROOT)/incs/$(OARCH)/avoffset.h via
* -I$(SRCROOT)/incs/$(OARCH)/
*/
# include <avoffset.h>
#else /* !SCHILY_BUILD */
/*
* The stuff for static compilation. Include files from a previous
* dynamic autoconfiguration.
*/
#ifdef __SUNOS5_SPARC_CC32
#include <schily/sparc-sunos5-cc/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_SPARC_CC64
#include <schily/sparc-sunos5-cc64/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_SPARC_GCC32
#include <schily/sparc-sunos5-gcc/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_SPARC_GCC64
#include <schily/sparc-sunos5-gcc64/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_X86_CC32
#include <schily/i386-sunos5-cc/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_X86_CC64
#include <schily/i386-sunos5-cc64/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_X86_GCC32
#include <schily/i386-sunos5-gcc/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __SUNOS5_X86_GCC64
#include <schily/i386-sunos5-gcc64/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __HPUX_HPPA_CC32
#include <schily/hppa-hp-ux-cc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_CC64
#include <schily/hppa-hp-ux-cc64/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_GCC32
#include <schily/hppa-hp-ux-gcc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_GCC64
#include <schily/hppa-hp-ux-gcc64/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV6L_GCC32
#include <schily/armv6l-linux-gcc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV5L_GCC32
#include <schily/armv6l-linux-gcc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV5TEJL_GCC32
#include <schily/armv5tejl-linux-gcc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_I386_GCC32
#include <schily/i686-linux-gcc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_amd64_GCC64
#include <schily/x86_64-linux-gcc/avoffset.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __MSWIN_X86_CL32
#include <schily/i686-cygwin32_nt-cl/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifdef __CYGWIN_X86_GCC
#include <schily/i686-cygwin32_nt-gcc/avoffset.h>
#define __JS_ARCH_AVOFFSET_INCL
#endif
#ifndef __JS_ARCH_AVOFFSET_INCL
/*
* #error will not work for all compilers (e.g. sunos4)
* The following line will abort compilation on all compilers
* if none of the above is defined. And that's what we want.
*/
Error unconfigured architecture
#include <schily/err_arch.h> /* Avoid "unknown directive" with K&R */
#endif
#endif /* SCHILY_BUILD */
#ifdef __cplusplus
extern "C" {
#endif
/*
* Fake in order to keep the silly hdrchk(1) quiet.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_AVOFFSET_H */
@@ -0,0 +1,124 @@
/* @(#)btorder.h 1.22 12/12/03 Copyright 1996-2012 J. Schilling */
/*
* Definitions for Bit and Byte ordering
*
* Copyright (c) 1996-2012 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_BTORDER_H
#define _SCHILY_BTORDER_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h> /* load bit/byte-oder from xmconfig.h */
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h> /* try to load isa_defs.h on Solaris */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Convert bit-order definitions from xconfig.h into our values
* and verify them.
*/
#if defined(HAVE_C_BITFIELDS) && \
defined(BITFIELDS_LTOH)
#define _BIT_FIELDS_LTOH
#endif
#if defined(HAVE_C_BITFIELDS) && \
defined(BITFIELDS_HTOL)
#define _BIT_FIELDS_HTOL
#endif
#if defined(HAVE_C_BITFIELDS) && \
!defined(BITFIELDS_HTOL)
#define BITFIELDS_LTOH
#define _BIT_FIELDS_LTOH
#endif
#if defined(_BIT_FIELDS_LTOH) && defined(_BIT_FIELDS_HTOL)
/*
* #error will not work for all compilers (e.g. sunos4)
* The following line will abort compilation on all compilers
* if none of the above is defined. And that's what we want.
*/
error Only one of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL may be defined
#include <schily/err_bit.h> /* Avoid "unknown directive" with K&R */
#endif
/*
* Convert byte-order definitions from xconfig.h into our values
* and verify them.
* Note that we cannot use the definitions _LITTLE_ENDIAN and _BIG_ENDIAN
* because they are used on IRIX-6.5 with different meaning.
*/
#if defined(HAVE_C_BIGENDIAN) && \
!defined(WORDS_BIGENDIAN)
#define WORDS_LITTLEENDIAN
/* #define _LITTLE_ENDIAN */
#endif
#if defined(HAVE_C_BIGENDIAN) && \
defined(WORDS_BIGENDIAN)
#undef WORDS_LITTLEENDIAN
/* #define _BIG_ENDIAN */
#endif
#if defined(_BIT_FIELDS_LTOH) || defined(_BIT_FIELDS_HTOL)
/*
* Bitorder is already known.
*/
#else
/*
* Bitorder not yet known.
*/
# if defined(sun3) || defined(mc68000) || \
defined(sun4) || defined(__sparc) || defined(sparc) || \
defined(__hppa) || defined(_ARCH_PPC) || defined(_IBMR2)
# define _BIT_FIELDS_HTOL
# endif
# if defined(__sgi) && defined(__mips)
# define _BIT_FIELDS_HTOL
# endif
# if defined(__i386__) || defined(__i386) || defined(i386) || \
defined(__alpha__) || defined(__alpha) || defined(alpha) || \
defined(__arm__) || defined(__arm) || defined(arm)
# define _BIT_FIELDS_LTOH
# endif
# if defined(__ppc__) || defined(ppc) || defined(__ppc) || \
defined(__PPC) || defined(powerpc) || defined(__powerpc__)
# if defined(__BIG_ENDIAN__)
# define _BIT_FIELDS_HTOL
# else
# define _BIT_FIELDS_LTOH
# endif
# endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_BTORDER_H */
@@ -0,0 +1,90 @@
/* @(#)ccomdefs.h 1.12 11/07/21 Copyright 2000-2011 J. Schilling */
/*
* Various compiler dependant macros.
*
* Copyright (c) 2000-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_CCOMDEFS_H
#define _SCHILY_CCOMDEFS_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Compiler-dependent macros to declare that functions take printf-like
* or scanf-like arguments. They are defined to nothing for versions of gcc
* that are not known to support the features properly (old versions of gcc-2
* didn't permit keeping the keywords out of the application namespace).
*/
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
defined(NO_PRINTFLIKE)
#define __printflike__(fmtarg, firstvararg)
#define __printf0like__(fmtarg, firstvararg)
#define __scanflike__(fmtarg, firstvararg)
#else /* We found GCC that supports __attribute__ */
#define __printflike__(fmtarg, firstvararg) \
__attribute__((__format__(__printf__, fmtarg, firstvararg)))
#define __printf0like__(fmtarg, firstvararg) \
__attribute__((__format__(__printf0__, fmtarg, firstvararg)))
/*
* FreeBSD GCC implements printf0 that allows the format string to
* be a NULL pointer.
*/
#if __FreeBSD_cc_version < 300001
#undef __printf0like__
#define __printf0like__ __printflike__
#endif
#define __scanflike__(fmtarg, firstvararg) \
__attribute__((__format__(__scanf__, fmtarg, firstvararg)))
#endif /* GNUC */
#if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 2
/* GCC-3.3 or more */
/* CSTYLED */
#define UConst __attribute__ ((__used__)) const
#else /* less than GNUC 3.3 */
#define UConst const
#endif /* less than GNUC 3.3 */
#ifdef __PCC__
/*
* Hack until pcc supports __attribute__ ((__used__))
*/
#ifdef UConst
#undef UConst
#define UConst const
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_CCOMDEFS_H */
@@ -0,0 +1,95 @@
/* @(#)checkerr.h 1.14 12/11/13 Copyright 2003-2012 J. Schilling */
/*
* Generic error control for programs that do file i/o.
* The error control is usually used by archiving programs.
*
* The current version does not provide a stable interface.
* It does not support multi-threaded programs and it may call
* comerr() from the parser. If you use the code before there is
* an official stable and "library-compliant" interface, be careful
* and watch for changes.
*
* Copyright (c) 2003-2012 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_CHECKERR_H
#define _SCHILY_CHECKERR_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_STANDARD_H
#include <schily/standard.h>
#endif
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Error conditions handled by error control.
*/
#define E_STAT 0x0001 /* Could not stat(2) file */
#define E_GETACL 0x0002 /* Could not retrieve ACL info */
#define E_OPEN 0x0004 /* Could not open file */
#define E_READ 0x0008 /* Could not read file */
#define E_WRITE 0x0010 /* Could not write file */
#define E_GROW 0x0020 /* File did grow during backup */
#define E_SHRINK 0x0040 /* File did shrink during backup */
#define E_MISSLINK 0x0080 /* Missing hard link(s) for file */
#define E_NAMETOOLONG 0x0100 /* File name too long for archive */
#define E_FILETOOBIG 0x0200 /* File too big for archive */
#define E_SPECIALFILE 0x0400 /* Improper file type for archive */
#define E_READLINK 0x0800 /* Could not read symbolic link */
#define E_GETXATTR 0x1000 /* Could not get xattr */
#define E_CHDIR 0x2000 /* Could not chdir() */
/*
* Currently unused: 0x4000 .. 0x8000
*/
#define E_SETTIME 0x10000 /* Could not set file times */
#define E_SETMODE 0x20000 /* Could not set access modes */
#define E_SECURITY 0x40000 /* Skipped for security reasons */
#define E_LSECURITY 0x80000 /* Link skipped for security */
#define E_SAMEFILE 0x100000 /* Skipped from/to identical */
#define E_BADACL 0x200000 /* ACL string conversion error */
#define E_SETACL 0x400000 /* Could not set ACL for file */
#define E_SETXATTR 0x800000 /* Could not set xattr */
/*
* Currently unused: 0x1000000 .. 0x8000000
*/
#define E_DIFF 0x10000000 /* Diffs encountered */
#define E_WARN 0x20000000 /* Print this error but do exit(0) */
#define E_ABORT 0x40000000 /* Abort on this error */
#define E_EXT 0x80000000 /* Extended (TBD later) */
#define E_ALL (~(UInt32_t)(E_DIFF|E_ABORT))
extern int errconfig __PR((char *name));
extern BOOL errhidden __PR((int etype, const char *fname));
extern BOOL errwarnonly __PR((int etype, const char *fname));
extern BOOL errabort __PR((int etype, const char *fname,
BOOL doexit));
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_CHECKERR_H */
@@ -0,0 +1,40 @@
/* @(#)ctype.h 1.2 16/06/19 Copyright 2009-2016 J. Schilling */
/*
* Ctype abstraction
*
* Copyright (c) 2009-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_CTYPE_H
#define _SCHILY_CTYPE_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
#ifdef HAVE_CTYPE_H
#ifndef _INCL_CTYPE_H
#include <ctype.h>
#define _INCL_CTYPE_H
#endif
#else
#endif /* ! HAVE_CTYPE_H */
#endif /* _SCHILY_CTYPE_H */
@@ -0,0 +1,153 @@
/* @(#)device.h 1.19 09/11/16 Copyright 1995-2007 J. Schilling */
/*
* Generic header for users of major(), minor() and makedev()
*
* Copyright (c) 1995-2007 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_DEVICE_H
#define _SCHILY_DEVICE_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
/*
* On generic SVR4, major is a function (defined in sys/mkdev.h).
* On Solaris it is defined ...
* As we cannot just test if major is #define'd, we have to
* define _FOUND_MAJOR_ instead.
*
* WARNING: Do never include <sys/sysmacros.h> in SVR4, it contains
* an old definition for major()/minor() defining 8 minorbits.
* Use <sys/mkdev.h> instead.
*/
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
/*
* Some systems define major in <sys/types.h>.
* We are ready...
*/
#ifdef major
# define _FOUND_MAJOR_
#endif
#ifdef MAJOR_IN_MKDEV
# ifndef _INCL_SYS_MKDEV_H
# include <sys/mkdev.h>
# define _INCL_SYS_MKDEV_H
# endif
/*
* Interix doesn't use makedev(); it uses mkdev()
*/
# if !defined(makedev) && defined(mkdev)
# define makedev(a, b) mkdev((a), (b))
# endif
# define _FOUND_MAJOR_
#endif
#ifndef _FOUND_MAJOR_
# ifdef MAJOR_IN_SYSMACROS
# ifndef _INCL_SYS_SYSMACROS_H
# include <sys/sysmacros.h>
# define _INCL_SYS_SYSMACROS_H
# endif
# define _FOUND_MAJOR_
# endif
#endif
/*
* If we are on HP/UX before HP/UX 8,
* major/minor are not in <sys/sysmacros.h>.
*/
#ifndef _FOUND_MAJOR_
# if defined(hpux) || defined(__hpux__) || defined(__hpux)
# ifndef _INCL_SYS_MKOD_H
# include <sys/mknod.h>
# define _INCL_SYS_MKOD_H
# endif
# define _FOUND_MAJOR_
# endif
#endif
#ifndef _FOUND_MAJOR_
# ifdef VMS
# define major(dev) (((((long)dev) >> 8) & 0xFF))
# define minor(dev) ((((long)dev) & 0xFF))
# define makedev(majo, mino) (((majo) << 8) | (mino))
# define _FOUND_MAJOR_
# endif /* VMS */
#endif /* _FOUND_MAJOR_ */
#ifdef __cplusplus
extern "C" {
#endif
/*
* For all other systems define major()/minor() here.
* XXX Check if this definition will be usefull for ms dos too.
*/
#ifndef _FOUND_MAJOR_
# define major(dev) (((dev) >> 8) & 0xFF)
# define minor(dev) ((dev) & 0xFF)
# define makedev(majo, mino) (((majo) << 8) | (mino))
#endif
/*
* Don't pollute namespace...
*/
#undef _FOUND_MAJOR_
#ifdef __XDEV__
/*
* The following defines are currently only needed for 'star'.
* We make it conditional code to avoid to pollute the namespace.
*/
#define XDEV_T unsigned long
extern int minorbits;
extern XDEV_T minormask;
extern XDEV_T _dev_mask[];
#define dev_major(dev) (((XDEV_T)(dev)) >> minorbits)
#define _dev_major(mbits, dev) (((XDEV_T)(dev)) >> (mbits))
#define dev_minor(dev) (((XDEV_T)(dev)) & minormask)
#define _dev_minor(mbits, dev) (((XDEV_T)(dev)) & _dev_mask[(mbits)])
#define dev_make(majo, mino) ((((XDEV_T)(majo)) << minorbits) | \
((XDEV_T)(mino)))
#define _dev_make(mbits, majo, mino) ((((XDEV_T)(majo)) << (mbits) | \
((XDEV_T)(mino)))
extern void dev_init __PR((BOOL debug));
#ifndef dev_major
extern XDEV_T dev_major __PR((XDEV_T dev));
extern XDEV_T _dev_major __PR((int mbits, XDEV_T dev));
extern XDEV_T dev_minor __PR((XDEV_T dev));
extern XDEV_T _dev_minor __PR((int mbits, XDEV_T dev));
extern XDEV_T dev_make __PR((XDEV_T majo, XDEV_T mino));
extern XDEV_T _dev_make __PR((int mbits, XDEV_T majo, XDEV_T mino));
#endif
#endif /* __XDEV__ */
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_DEVICE_H */
@@ -0,0 +1,225 @@
/* @(#)dirent.h 1.29 11/08/04 Copyright 1987, 1998, 2000-2011 J. Schilling */
/*
* Copyright (c) 1987, 1998, 2000-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_DIRENT_H
#define _SCHILY_DIRENT_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef JOS
# ifdef HAVE_SYS_STYPES_H
# ifndef _INCL_SYS_STYPES_H
# include <sys/stypes.h>
# define _INCL_SYS_STYPES_H
# endif
# endif
# ifdef HAVE_SYS_FILEDESC_H
# ifndef _INCL_SYS_FILEDESC_H
# include <sys/filedesc.h>
# define _INCL_SYS_FILEDESC_H
# endif
# endif
# define NEED_READDIR
# define dirent _direct
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# define DIRSIZE 30
# define FOUND_DIRSIZE
typedef struct _dirent {
char name[DIRSIZE];
short ino;
} dirent;
#else /* !JOS */
# ifndef _SCHILY_TYPES_H
# include <schily/types.h>
# endif
# ifndef _SCHILY_STAT_H
# include <schily/stat.h>
# endif
# ifndef _SCHILY_LIMITS_H
# include <schily/limits.h>
# endif
# ifndef _SCHILY_PARAM_H
# include <schily/param.h>
# endif
# ifndef _SCHILY_STDLIB_H
# include <schily/stdlib.h> /* MSVC: get _MAX_DIR */
# endif
# ifdef HAVE_DIRENT_H /* This a POSIX compliant system */
# ifndef _INCL_DIRENT_H
# include <dirent.h>
# define _INCL_DIRENT_H
# endif
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# define _FOUND_DIR_
# else /* This is a Pre POSIX system */
# define dirent direct
# define DIR_NAMELEN(dirent) (dirent)->d_namlen
# if defined(HAVE_SYS_DIR_H)
# ifndef _INCL_SYS_DIR_H
# include <sys/dir.h>
# define _INCL_SYS_DIR_H
# endif
# define _FOUND_DIR_
# endif
# if defined(HAVE_NDIR_H) && !defined(_FOUND_DIR_)
# ifndef _INCL_NDIR_H
# include <ndir.h>
# define _INCL_NDIR_H
# endif
# define _FOUND_DIR_
# endif
# if defined(HAVE_SYS_NDIR_H) && !defined(_FOUND_DIR_)
# ifndef _INCL_SYS_NDIR_H
# include <sys/ndir.h>
# define _INCL_SYS_NDIR_H
# endif
# define _FOUND_DIR_
# endif
# endif /* HAVE_DIRENT_H */
# if defined(_FOUND_DIR_)
/*
* Don't use defaults here to allow recognition of problems.
*/
# if !defined(FOUND_DIRSIZE) && defined(MAXNAMELEN)
# define DIRSIZE MAXNAMELEN /* From sys/param.h */
# define FOUND_DIRSIZE
# endif
# if !defined(FOUND_DIRSIZE) && defined(MAXNAMLEN)
# define DIRSIZE MAXNAMLEN /* From dirent.h */
# define FOUND_DIRSIZE
# endif
# ifdef __never__
/*
* DIRSIZ(dp) is a parameterized macro, we cannot use it here.
*/
# if !defined(FOUND_DIRSIZE) && defined(DIRSIZ)
# define DIRSIZE DIRSIZ /* From sys/dir.h */
# define FOUND_DIRSIZE
# endif
# endif /* __never__ */
# if !defined(FOUND_DIRSIZE) && defined(NAME_MAX)
# define DIRSIZE NAME_MAX /* From limits.h */
# define FOUND_DIRSIZE
# endif
# else /* !_FOUND_DIR_ */
# if !defined(FOUND_DIRSIZE) && defined(_MAX_DIR)
# if defined(__MINGW32__) || defined(_MSC_VER)
# define DIRSIZE _MAX_DIR /* From stdlib.h */
# define FOUND_DIRSIZE
# define NEED_READDIR
# undef dirent
# define dirent _direct
# undef DIR_NAMELEN
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# endif
# endif
# ifndef NEED_READDIR
# define NEED_DIRENT
# define NEED_READDIR
# undef dirent
# define dirent _direct
# undef DIR_NAMELEN
# define DIR_NAMELEN(dirent) strlen((dirent)->d_name)
# endif /* !NEED_READDIR */
# endif /* _FOUND_DIR_ */
#ifdef NEED_DIRENT
#ifndef FOUND_DIRSIZE
#define DIRSIZE 14 /* The old UNIX standard value */
#define FOUND_DIRSIZE
#endif
typedef struct _dirent {
short ino;
char name[DIRSIZE];
} dirent;
#endif /* NEED_DIRENT */
#endif /* !JOS */
#ifdef NEED_READDIR
#ifndef _SCHILY_STDIO_H
#include <schily/stdio.h>
#endif
#if defined(__MINGW32__) || defined(_MSC_VER)
#ifndef _SCHILY_IO_H
#include <schily/io.h> /* for _findfirst() */
#endif
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h>
#endif
#endif
struct _direct {
unsigned long d_ino;
unsigned short d_reclen;
unsigned short d_namlen;
char d_name[DIRSIZE +1];
};
#define HAVE_DIRENT_D_INO
typedef struct __dirdesc {
FILE *dd_fd;
#if defined(__MINGW32__) || defined(_MSC_VER)
struct _direct dd_dir; /* dirent for this dir */
struct _finddata_t dd_data; /* _findnext() results */
intptr_t dd_handle; /* _findnext() handle */
int dd_state; /* Current Dir state */
char dd_dirname[1]; /* Dir to open */
#endif
} DIR;
extern DIR *opendir __PR((const char *));
extern int closedir __PR((DIR *));
extern struct dirent *readdir __PR((DIR *));
#endif /* NEED_READDIR */
#if !defined(HAVE_DIRFD) && defined(HAVE_DIR_DD_FD)
# define dirfd(dirp) ((dirp)->dd_fd)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_DIRENT_H */
@@ -0,0 +1,110 @@
/* @(#)dlfcn.h 1.4 15/07/13 Copyright 2015 J. Schilling */
/*
* Abstraction from dlfcn.h
*
* Copyright (c) 2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_DLFCN_H
#define _SCHILY_DLFCN_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_DLFCN_H
#ifndef _INCL_DLFCN_H
#include <dlfcn.h> /* POSIX */
#define _INCL_DLFCN_H
#define FOUND_DLFCN_H
#endif
#endif
#ifdef HAVE_DL_H
#ifndef FOUND_DLFCN_H
#ifndef _INCL_DL_H
#include <dl.h> /* HP-UX */
#define _INCL_DL_H
#define FOUND_DLFCN_H
#endif
#endif
#endif
#if defined(HAVE_DLOPEN) && defined(HAVE_DLCLOSE) /* POSIX */
#define HAVE_LOADABLE_LIBS
#endif
#if !defined(HAVE_LOADABLE_LIBS) && defined(HAVE_SHL_LOAD) /* HP-UX */
#define HAVE_LOADABLE_LIBS
#endif
#if !defined(HAVE_LOADABLE_LIBS) && defined(HAVE_LOADLIBRARY) /* Win-DOS */
#define HAVE_LOADABLE_LIBS
#endif
/*
* dlopen() modes
*/
#ifndef RTLD_LAZY /* The only mode in SunOS-4.0 */
#define RTLD_LAZY 0x00001
#define RTLD_NOW 0x00002
#define RTLD_GLOBAL 0x00100
#define RTLD_LOCAL 0x00000
#endif
#ifdef __never_
/*
* dlsym() speudo handles
* These handles are not valid on SunOS-4.0
*/
#ifndef RTLD_NEXT
#define RTLD_NEXT (void *)-1
#define RTLD_DEFAULT (void *)-2
#define RTLD_SELF (void *)-3
#endif
#endif
/*
* dlsym() speudo handle for SunOS-4.0
*/
#if defined(HAVE_DLSYM) && !defined(RTLD_SELF)
#define RTLD_SELF (void *)0
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_DLOPEN
extern void *dlopen __PR((const char *__pathname, int mode));
#endif
#ifndef HAVE_DLCLOSE
extern int dlclose __PR((void *__handle));
#endif
#ifndef HAVE_DLSYM
extern void *dlsym __PR((void *__handle, const char *name));
#endif
#ifndef HAVE_DLERROR
extern const char *dlerror __PR((void));
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_DLFCN_H */
@@ -0,0 +1,62 @@
/* @(#)errno.h 1.7 10/08/24 Copyright 2006-2010 J. Schilling */
/*
* Error number related definitions
*
* Copyright (c) 2006-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_ERRNO_H
#define _SCHILY_ERRNO_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef JOS
#include <error.h>
#define ENOEXEC EBADHEADER
#define EACCES EACCESS
#define ENOENT ENOFILE
#define EEXIST EEXISTS
#else
#include <errno.h>
#define EMISSDIR ENOENT
#define ENDOFFILE EFBIG
#endif
#ifndef HAVE_ERRNO_DEF
extern int errno;
#endif
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
extern int sys_nerr;
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef seterrno
extern int seterrno __PR((int));
#endif
extern int geterrno __PR((void));
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_ERRNO_H */
@@ -0,0 +1,134 @@
/* @(#)fcntl.h 1.19 11/10/19 Copyright 1996-2011 J. Schilling */
/*
* Generic header for users of open(), creat() and chmod()
*
* Copyright (c) 1996-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_FCNTL_H
#define _SCHILY_FCNTL_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h> /* Needed for fcntl.h */
#endif
#ifndef _SCHILY_STAT_H
#include <schily/stat.h> /* For 3rd arg of open() and chmod() */
#endif
#ifdef HAVE_SYS_FILE_H
/*
* Historical systems with flock() only need sys/file.h
*/
# ifndef _INCL_SYS_FILE_H
# include <sys/file.h>
# define _INCL_SYS_FILE_H
# endif
#endif
#ifdef HAVE_FCNTL_H
# ifndef _INCL_FCNTL_H
# include <fcntl.h>
# define _INCL_FCNTL_H
#endif
#endif
/*
* Do not define more than O_RDONLY / O_WRONLY / O_RDWR / O_BINARY
* The values may differ.
*
* O_BINARY is defined here to allow all applications to compile on a non DOS
* environment without repeating this definition.
* O_SEARCH, O_DIRECTORY and NOFOLLOW are defined here to allow to compile on
* older platforms.
* open(name, O_SEARCH) is like UNOS open(name, "") (open neither for read nor
* for write). This allows to call fstat() and to get an fd for openat(fd, ...)
*/
#ifndef O_RDONLY
# define O_RDONLY 0
#endif
#ifndef O_WRONLY
# define O_WRONLY 1
#endif
#ifndef O_RDWR
# define O_RDWR 2
#endif
#ifndef O_BINARY /* Only present on DOS or similar */
# define O_BINARY 0
#endif
#ifndef O_NDELAY /* This is undefined on BeOS :-( */
# define O_NDELAY 0
#endif
#ifndef O_EXEC /* Open for exec only (non-directory) */
# define O_EXEC O_RDONLY
#endif
#ifndef O_SEARCH /* Open for search only. */
# define O_SEARCH O_RDONLY
#endif
#ifndef O_DIRECTORY /* Fail if not a directory */
# define O_DIRECTORY 0
#endif
#ifndef O_NOFOLLOW /* Fail if a symlink */
# define O_NOFOLLOW 0
#endif
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR|O_EXEC|O_SEARCH)
#endif
#ifdef O_NOATIME /* Allow #ifdef O_NOATIME */
#define _O_NOATIME O_NOATIME
#else
#define _O_NOATIME 0
#endif
#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1 /* close on exec flag */
#endif
/*
* The following definitions are used for emulating the *at() functions.
* We use higher numbers for our definitions, to allow to add emulations
* for missing functions without causing a clash with system definitions.
*/
#ifndef HAVE_OPENAT
#ifndef AT_FDCWD
#define AT_FDCWD 0xffd19553 /* *at() to working dir */
#endif
#endif
#ifndef HAVE_FSTATAT
#ifndef AT_SYMLINK_NOFOLLOW
#define AT_SYMLINK_NOFOLLOW 0x10000 /* emulate lstat() */
#endif
#endif
#ifndef HAVE_UNLINKAT
#ifndef AT_REMOVEDIR
#define AT_REMOVEDIR 0x20000 /* emulate rmdir() */
#endif
#endif
#ifndef HAVE_FACCESSAT
#ifndef AT_EACCESS
#define AT_EACCESS 0x40000 /* EUID access() */
#endif
#endif
#ifndef HAVE_LINKAT
#ifndef AT_SYMLINK_FOLLOW
#define AT_SYMLINK_FOLLOW 0x80000 /* follow symlinks before link() */
#endif
#endif
#endif /* _SCHILY_FCNTL_H */
@@ -0,0 +1,56 @@
/* @(#)float.h 1.1 09/08/08 Copyright 2009 J. Schilling */
/*
* Abstraction code for float.h
*
* Copyright (c) 2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_FLOAT_H
#define _SCHILY_FLOAT_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_FLOAT_H
#ifndef _INCL_FLOAT_H
#define _INCL_FLOAT_H
#include <float.h>
#endif
#endif
#ifdef HAVE_VALUES_H
#ifndef _INCL_VALUES_H
#define _INCL_VALUES_H
#include <values.h>
#endif
#ifndef FLT_MAX
#define FLT_MAX MAXFLOAT
#endif
#ifndef FLT_MIN
#define FLT_MIN MINFLOAT
#endif
#ifndef DBL_MAX
#define DBL_MAX MAXDOUBLE
#endif
#ifndef DBL_MIN
#define DBL_MIN MINDOUBLE
#endif
#endif
#endif /* _SCHILY_FLOAT_H */
@@ -0,0 +1,103 @@
/* @(#)fnmatch.h 8.13 10/10/09 Copyright 2006-2010 J. Schilling from 8.1 (Berkeley) */
#ifndef _SCHILY_FNMATCH_H
#define _SCHILY_FNMATCH_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#else /* !HAVE_FNMATCH_H */
#ifdef __cplusplus
extern "C" {
#endif
extern int fnmatch __PR((const char *, const char *, int));
#ifdef __cplusplus
}
#endif
#endif /* !HAVE_FNMATCH */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fnmatch.h 8.13 (Berkeley) 10/09/10
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FNM_NOMATCH
#define FNM_NOMATCH 1 /* Match failed. */
#endif
#ifndef FNM_ERROR
#define FNM_ERROR 2 /* An error occured */
#endif
#ifndef FNM_NOSYS
#define FNM_NOSYS 3 /* Function (XPG4) not supported */
#endif
#ifndef FNM_NOESCAPE
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
#endif
#ifndef FNM_PATHNAME
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
#endif
#ifndef FNM_PERIOD
#define FNM_PERIOD 0x04 /* Period must be matched by period. */
#endif
#if !defined(FNM_IGNORECASE) && !defined(FNM_CASEFOLD)
#define FNM_IGNORECASE 0x10 /* Ignore case when making comparisons */
#endif
#if !defined(FNM_IGNORECASE) && defined(FNM_CASEFOLD)
#define FNM_IGNORECASE FNM_CASEFOLD
#endif
#ifndef FNM_CASEFOLD
#define FNM_CASEFOLD FNM_IGNORECASE
#endif
#ifndef FNM_LEADING_DIR
#define FNM_LEADING_DIR 0x20 /* Ignore /<tail> after Imatch. */
#endif
extern int js_fnmatch __PR((const char *, const char *, int));
#if !defined(HAVE_FNMATCH_IGNORECASE)
#define fnmatch js_fnmatch
#endif
#ifdef __cplusplus
}
#endif
#endif /* !_SCHILY_FNMATCH_H */
@@ -0,0 +1,171 @@
/* @(#)getargs.h 1.22 16/10/23 Copyright 1985-2016 J. Schilling */
/*
* Definitions for getargs()/getallargs()/getfiles()
*
* Copyright (c) 1985-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_GETARGS_H
#define _SCHILY_GETARGS_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Return values for get*args()/get*files()
*
* This package calls options "flags", they are returned from get*args().
*
* Note that NOTAFILE is not returned by the interface functions.
* NOTAFILE is however used as return code from the user's callback functions
* to signal that the current arg may be an option the callback function does
* not know and definitely is no file type argument.
*
* General rules for the return code of the interface functions
* get*args()/get*files():
*
* > 0 A file type argument was found
* 0 All arguments have been parsed
* < 0 An error occured
*
* Flag and file arg processing should be terminated after getting a return
* code <= 0.
*/
#define FLAGDELIM 2 /* "--" stopped flag processing */
#define NOTAFLAG 1 /* Not a flag type argument */
#define NOARGS 0 /* No more args */
#define BADFLAG (-1) /* Not a valid flag argument */
#define BADFMT (-2) /* Error in format string */
#define NOTAFILE (-3) /* Seems to be a flag type */
/*
* The callback functions are called with the following parameters:
*
* arg The option argument
* valp A pointer to the related value argument from a get*arg*() call
* pac A pointer to the current argument counter
* pav A pointer to the current argument vector
* opt The option that caused the call
*
* The return value of the callback function may be:
*
* FLAGDELIM Pretend "--" stopped flag processing
* FLAGPARSED A valid flag was found, getallargs() will continue scanning
* ------------ the following codes will interrupt getallargs() processing:
* NOARGS Pretend all arguments have been examined
* BADFLAG Not a valid flag argument
* BADFMT General Error
* NOTAFILE Continue to check the format string for matches with option arg
*/
#define FLAGPARSED 1 /* Flag was sucessfully parsed */
typedef int (*getargfun) __PR((const char *__arg, void *__valp));
typedef int (*getpargfun) __PR((const char *__arg, void *__valp,
int *__pac, char *const **__pav,
const char *__opt));
#define NO_ARGFUN (getargpfun)0
struct ga_flags {
const char *ga_format; /* Comma separated list for one flag */
void *ga_arg; /* Ptr. to variable to fill for flag */
getpargfun ga_funcp; /* Ptr. for function to call (&/~) */
};
struct ga_props {
UInt32_t ga_flags; /* Flags to define behavior */
UInt32_t ga_oflags; /* State flags */
size_t ga_size; /* Size of this struct gs_props */
};
/*
* This may be used instead of a struct ga_props * parameter:
*/
#define GA_NO_PROPS (struct ga_props *)0 /* Default behavior */
#define GA_POSIX_PROPS (struct ga_props *)-1 /* POSIX behavior */
/*
* Definitions for ga_flags
*/
#define GAF_DEFAULT 0x00 /* The default behavior */
#define GAF_NO_PLUS 0x01 /* Options may not start with '+' */
#define GAF_NO_EQUAL 0x02 /* Disallow '=' between opt and val */
#define GAF_NEED_DASH 0x04 /* Need dash before (-name=val), */
/* name=val is not allowed */
#define GAF_DELIM_DASHDASH 0x08 /* "--" stops even get?allargs() */
#define GAF_POSIX 0x1000 /* Will be expanded as shown below */
/*
* POSIX does not allow options in the form "+option", "-option=value" or
* "option=value". get*files() needs to know what may be a valid option.
*
* If ga_flags == GAF_POSIX, ga_flags is replaced with the value
* of the current definition for GAF_POSIX_DEFAULT.
*
* GAF_NO_PLUS do not allow options to start with a '+'
* GAF_NO_EQUAL do not allow options to contain '=' between name & val
*
* Warning: future versions may need different flags for POSIX, better use the
* GA_POSIX_PROPS "struct" or the GAF_POSIX flag.
*/
#define GAF_POSIX_DEFAULT (GAF_NO_PLUS | GAF_NO_EQUAL)
/*
* Keep in sync with schily.h
*/
extern int getallargs __PR((int *, char * const**, const char *, ...));
extern int getargs __PR((int *, char * const**, const char *, ...));
extern int getfiles __PR((int *, char * const**, const char *));
extern char *getargerror __PR((int));
/*
* The new list versions of the functions need struct ga_props and thus need
* getargs.h
*/
extern int getlallargs __PR((int *, char * const**, struct ga_props *,
const char *, ...));
extern int getlargs __PR((int *, char * const**, struct ga_props *,
const char *, ...));
extern int getlfiles __PR((int *, char * const**, struct ga_props *,
const char *));
extern int _getarginit __PR((struct ga_props *, size_t, UInt32_t));
#define getarginit(p, f) _getarginit(p, sizeof (struct ga_props), f)
/*
* The vector versions of the functions need struct ga_flags and thus need
* getargs.h
*/
extern int getvallargs __PR((int *, char * const**, struct ga_props *,
struct ga_flags *));
extern int getvargs __PR((int *, char * const**, struct ga_props *,
struct ga_flags *));
extern int getvfiles __PR((int *, char * const**, struct ga_props *,
struct ga_flags *));
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_GETARGS_H */
@@ -0,0 +1,72 @@
/* @(#)iconv.h 1.4 08/01/02 Copyright 2007 J. Schilling */
/*
* Abstraction from iconv.h
*
* Copyright (c) 2007 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_ICONV_H
#define _SCHILY_ICONV_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_ICONV_H
#ifndef _INCL_ICONV_H
#include <iconv.h>
#define _INCL_ICONV_H
#endif
#else
#undef USE_ICONV
#endif
/*
* Libiconv on Cygwin is not autoconf-friendly.
* iconv.h #defined iconv to libiconv
* We would need a AC_CHECK_FUNC() macro that allows to specify includefiles.
*/
#if defined(HAVE_LIBICONV) && defined(HAVE_LIBICONV_OPEN) && \
defined(HAVE_LIBICONV_CLOSE) && \
defined(iconv) && defined(iconv_open) && defined(iconv_close)
# ifndef HAVE_ICONV
# define HAVE_ICONV
# endif
# ifndef HAVE_ICONV_OPEN
# define HAVE_ICONV_OPEN
# endif
# ifndef HAVE_ICONV_CLOSE
# define HAVE_ICONV_CLOSE
# endif
#endif
#if !defined(HAVE_ICONV_OPEN) || !defined(HAVE_ICONV_CLOSE)
# undef HAVE_ICONV
#endif
#ifndef HAVE_ICONV
#undef USE_ICONV
#endif
#ifdef NO_ICONV
#undef USE_ICONV
#endif
#ifndef USE_ICONV
#undef iconv_t
#define iconv_t char *
#endif
#endif /* _SCHILY_ICONV_H */
@@ -0,0 +1,114 @@
/* @(#)intcvt.h 1.8 13/10/26 Copyright 1986-2013 J. Schilling */
/*
* Definitions for conversion to/from integer data types of various size.
*
* Copyright (c) 1986-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_INTCVT_H
#define _SCHILY_INTCVT_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h>
#endif
#define i_to_2_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 8) & 0xFF,\
((Uchar *)(a))[1] = (i) & 0xFF)
#define i_to_3_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 16)& 0xFF,\
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
((Uchar *)(a))[2] = (i) & 0xFF)
#define i_to_4_byte(a, i) (((Uchar *)(a))[0] = ((i) >> 24)& 0xFF,\
((Uchar *)(a))[1] = ((i) >> 16)& 0xFF,\
((Uchar *)(a))[2] = ((i) >> 8) & 0xFF,\
((Uchar *)(a))[3] = (i) & 0xFF)
#define a_to_byte(a) (((Int8_t *)a)[0])
#define a_to_u_byte(a) ((UInt8_t) \
(((Uchar *)a)[0] & 0xFF))
#define a_to_u_2_byte(a) ((UInt16_t) \
((((Uchar *)a)[1] & 0xFF) | \
(((Uchar *)a)[0] << 8 & 0xFF00)))
#define a_to_2_byte(a) (int)(Int16_t)a_to_u_2_byte(a)
#define a_to_u_3_byte(a) ((Ulong) \
((((Uchar *)a)[2] & 0xFF) | \
(((Uchar *)a)[1] << 8 & 0xFF00) | \
(((Uchar *)a)[0] << 16 & 0xFF0000)))
#define a_to_3_byte(a) a_to_u_3_byte(a) /* XXX signed version? */
#ifdef __STDC__
# define __TOP_4BYTE 0xFF000000UL
#else
# define __TOP_4BYTE 0xFF000000
#endif
#define a_to_u_4_byte(a) ((Ulong) \
((((Uchar*)a)[3] & 0xFF) | \
(((Uchar*)a)[2] << 8 & 0xFF00) | \
(((Uchar*)a)[1] << 16 & 0xFF0000) | \
(((Uchar*)a)[0] << 24 & __TOP_4BYTE)))
#define a_to_4_byte(a) (long)(Int32_t)a_to_u_4_byte(a)
/*
* Little Endian versions of above macros
*/
#define li_to_2_byte(a, i) (((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
((Uchar *)(a))[0] = (i) & 0xFF)
#define li_to_3_byte(a, i) (((Uchar *)(a))[2] = ((i) >> 16)& 0xFF,\
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
((Uchar *)(a))[0] = (i) & 0xFF)
#define li_to_4_byte(a, i) (((Uchar *)(a))[3] = ((i) >> 24)& 0xFF,\
((Uchar *)(a))[2] = ((i) >> 16)& 0xFF,\
((Uchar *)(a))[1] = ((i) >> 8) & 0xFF,\
((Uchar *)(a))[0] = (i) & 0xFF)
#define la_to_u_2_byte(a) ((UInt16_t) \
((((Uchar*)a)[0] & 0xFF) | \
(((Uchar*)a)[1] << 8 & 0xFF00)))
#define la_to_2_byte(a) (int)(Int16_t)la_to_u_2_byte(a)
#define la_to_u_3_byte(a) ((Ulong) \
((((Uchar*)a)[0] & 0xFF) | \
(((Uchar*)a)[1] << 8 & 0xFF00) | \
(((Uchar*)a)[2] << 16 & 0xFF0000)))
#define la_to_3_byte(a) la_to_u_3_byte(a) /* XXX signed version? */
#define la_to_u_4_byte(a) ((Ulong) \
((((Uchar*)a)[0] & 0xFF) | \
(((Uchar*)a)[1] << 8 & 0xFF00) | \
(((Uchar*)a)[2] << 16 & 0xFF0000) | \
(((Uchar*)a)[3] << 24 & __TOP_4BYTE)))
#define la_to_4_byte(a) (long)(Int32_t)la_to_u_4_byte(a)
#endif /* _SCHILY_INTCVT_H */
@@ -0,0 +1,38 @@
/* @(#)inttypes.h 1.35 12/01/22 Copyright 1997-2012 J. Schilling */
/*
* Abstraction from inttypes.h
*
* Copyright (c) 1997-2012 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_INTTYPES_H
#define _SCHILY_INTTYPES_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
/*
* inttypes.h is based on stdint.h
*/
#ifndef _SCHILY_STDINT_H
#include <schily/stdint.h>
#endif
/*
* inttypes.h inaddition to stdint.h defines printf() format strings.
* As we have a portable printf() in libschily, we do not need these #defines.
*/
#endif /* _SCHILY_INTTYPES_H */
@@ -0,0 +1,46 @@
/* @(#)io.h 1.1 09/07/13 Copyright 2009 J. Schilling */
/*
* DOS io.h abstraction
*
* Copyright (c) 2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_IO_H
#define _SCHILY_IO_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_FCNTL_H
#include <schily/fcntl.h>
#endif
#ifndef NEED_O_BINARY
#if O_BINARY != 0
#define NEED_O_BINARY
#endif
#endif
#if defined(HAVE_IO_H) && defined(NEED_O_BINARY)
#ifndef _INCL_IO_H
#include <io.h>
#define _INCL_IO_H
#endif
#else /* ! defined(HAVE_IO_H) && defined(NEED_O_BINARY) */
#define setmode(f, m)
#endif
#endif /* _SCHILY_IO_H */
@@ -0,0 +1,416 @@
/* @(#)libport.h 1.44 15/05/09 Copyright 1995-2015 J. Schilling */
/*
* Prototypes for POSIX standard functions that may be missing on the
* local platform and thus are implemented inside libschily.
*
* Copyright (c) 1995-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_LIBPORT_H
#define _SCHILY_LIBPORT_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
#ifndef _SCHILY_UNISTD_H
#include <schily/unistd.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(size_t)
# ifndef FOUND_SIZE_T
# define FOUND_SIZE_T
# endif
#endif
#if defined(_MSC_VER) && !defined(_SIZE_T_DEFINED)
# undef FOUND_SIZE_T
#endif
#ifdef OPENSERVER
/*
* Don't use the usleep() from libc on SCO's OPENSERVER.
* It will kill our processes with SIGALRM.
*/
/*
* Don't #undef HAVE_USLEEP in this file, SCO has a
* usleep() prototype in unistd.h
*/
/* #undef HAVE_USLEEP */
#endif
#ifdef FOUND_SIZE_T
/*
* We currently cannot define this here because there IRIX has a definition
* than violates the standard.
*/
#ifndef HAVE_SNPRINTF
/*PRINTFLIKE3*/
extern int snprintf __PR((char *, size_t, const char *, ...))
__printflike__(3, 4);
#endif
#endif
#ifdef EOF /* stdio.h has been included */
#ifdef FOUND_SIZE_T
#ifndef HAVE_GETDELIM
extern ssize_t getdelim __PR((char **, size_t *, int, FILE *));
#endif
#endif
#endif
#ifndef HAVE_GETHOSTID
extern long gethostid __PR((void));
#endif
#ifndef HAVE_GETPAGESIZE
extern int getpagesize __PR((void));
#endif
#ifndef HAVE_USLEEP
extern int usleep __PR((int usec));
#endif
#ifndef HAVE_STRCASECMP
extern int strcasecmp __PR((const char *, const char *));
#endif
#ifdef FOUND_SIZE_T
#ifndef HAVE_STRNCASECMP
extern int strncasecmp __PR((const char *, const char *,
size_t));
#endif
#endif
#ifndef HAVE_STRCAT
extern char *strcat __PR((char *s1, const char *s2));
#endif
#ifndef HAVE_STRCHR
extern char *strchr __PR((const char *s1, int c));
#endif
#ifndef HAVE_STRCMP
extern int strcmp __PR((const char *s1, const char *s2));
#endif
#ifndef HAVE_STRCPY
extern char *strcpy __PR((char *s1, const char *s2));
#endif
#if !defined(HAVE_STRDUP) || defined(__SVR4)
extern char *strdup __PR((const char *s));
#endif
#ifdef FOUND_SIZE_T
#ifndef HAVE_STRNDUP
extern char *strndup __PR((const char *s, size_t len));
#endif
#ifndef HAVE_STRLEN
extern size_t strlen __PR((const char *s));
#endif
#ifndef HAVE_STRNLEN
extern size_t strnlen __PR((const char *s, size_t len));
#endif
#ifndef HAVE_STRLCAT
extern size_t strlcat __PR((char *s1, const char *s2,
size_t len));
#endif
#ifndef HAVE_STRLCPY
extern size_t strlcpy __PR((char *s1, const char *s2,
size_t len));
#endif
#ifndef HAVE_STRNCAT
extern char *strncat __PR((char *s1, const char *s2,
size_t len));
#endif
#ifndef HAVE_STRNCMP
extern int strncmp __PR((const char *s1, const char *s2,
size_t len));
#endif
#ifndef HAVE_STRNCPY
extern char *strncpy __PR((char *s1, const char *s2,
size_t len));
#endif
#endif /* FOUND_SIZE_T */
#ifndef HAVE_STRRCHR
extern char *strrchr __PR((const char *s1, int c));
#endif
#ifndef HAVE_STRSTR
extern char *strstr __PR((const char *s1, const char *s2));
#endif
#ifdef _SCHILY_WCHAR_H
#ifndef HAVE_WCSCAT
extern wchar_t *wcscat __PR((wchar_t *s1, const wchar_t *s2));
#endif
#ifndef HAVE_WCSCHR
extern wchar_t *wcschr __PR((const wchar_t *s1, wchar_t c));
#endif
#ifndef HAVE_WCSCMP
extern int wcscmp __PR((const wchar_t *s1,
const wchar_t *s2));
#endif
#ifndef HAVE_WCSCPY
extern wchar_t *wcscpy __PR((wchar_t *s1, const wchar_t *s2));
#endif
#ifndef HAVE_WCSDUP
extern wchar_t *wcsdup __PR((const wchar_t *s));
#endif
#ifdef FOUND_SIZE_T
#ifndef HAVE_WCSNDUP
extern wchar_t *wcsndup __PR((const wchar_t *s, size_t len));
#endif
#ifndef HAVE_WCSLEN
extern size_t wcslen __PR((const wchar_t *s));
#endif
#ifndef HAVE_WCSNLEN
extern size_t wcsnlen __PR((const wchar_t *s, size_t len));
#endif
#ifndef HAVE_WCSLCAT
extern size_t wcslcat __PR((wchar_t *s1, const wchar_t *s2,
size_t len));
#endif
#ifndef HAVE_WCSLCPY
extern size_t wcslcpy __PR((wchar_t *s1, const wchar_t *s2,
size_t len));
#endif
#ifndef HAVE_WCSNCAT
extern wchar_t *wcsncat __PR((wchar_t *s1, const wchar_t *s2,
size_t len));
#endif
#ifndef HAVE_WCSNCMP
extern int wcsncmp __PR((const wchar_t *s1,
const wchar_t *s2,
size_t len));
#endif
#ifndef HAVE_WCSNCPY
extern wchar_t *wcsncpy __PR((wchar_t *s1, const wchar_t *s2,
size_t len));
#endif
#endif /* FOUND_SIZE_T */
#ifndef HAVE_WCSRCHR
extern wchar_t *wcsrchr __PR((const wchar_t *s1, wchar_t c));
#endif
#ifndef HAVE_WCSSTR
extern wchar_t *wcsstr __PR((const wchar_t *s1,
const wchar_t *s2));
#endif
#endif /* _SCHILY_WCHAR_H */
#ifndef HAVE_RENAME
extern int rename __PR((const char *old,
const char *new));
#endif
/*
* XXX Note: libgen.h / -lgen on Solaris contain eaccess()
*/
#ifndef HAVE_EACCESS
extern int eaccess __PR((const char *name, int mode));
#endif
/*
* See also libgen.h
*/
#ifndef HAVE_BASENAME
extern char *basename __PR((char *name));
#endif
#ifndef HAVE_DIRNAME
extern char *dirname __PR((char *name));
#endif
#ifndef HAVE_TIMEGM
#if defined(_SCHILY_TIME_H)
extern time_t timegm __PR((struct tm *));
#endif
#endif
#ifndef HAVE_GETUID
extern uid_t getuid __PR((void));
#endif
#ifndef HAVE_GETEUID
extern uid_t geteuid __PR((void));
#endif
#ifndef HAVE_SETUID
extern int setuid __PR((uid_t uid));
#endif
#ifndef HAVE_SETEUID
extern int seteuid __PR((uid_t uid));
#endif
#ifndef HAVE_GETGID
extern gid_t getgid __PR((void));
#endif
#ifndef HAVE_GETEGID
extern gid_t getegid __PR((void));
#endif
#ifndef HAVE_SETGID
extern int setgid __PR((gid_t gid));
#endif
#ifndef HAVE_SETEGID
extern int setegid __PR((gid_t gid));
#endif
#ifndef HAVE_GETPWNAM
extern struct passwd *getpwnam __PR((const char *name));
#endif
#ifndef HAVE_GETPWENT
extern struct passwd *getpwent __PR((void));
#endif
#ifndef HAVE_GETPWUID
extern struct passwd *getpwuid __PR((uid_t uid));
#endif
#ifndef HAVE_SETPWENT
extern void setpwent __PR((void));
#endif
#ifndef HAVE_ENDPWENT
extern void endpwent __PR((void));
#endif
#ifndef HAVE_GETGRNAM
extern struct group *getgrnam __PR((const char *name));
#endif
#ifndef HAVE_GETGRENT
extern struct group *getgrent __PR((void));
#endif
#ifndef HAVE_GETGRGID
extern struct group *getgrgid __PR((gid_t gid));
#endif
#ifndef HAVE_SETGRENT
extern void setgrent __PR((void));
#endif
#ifndef HAVE_ENDGRENT
extern void endgrent __PR((void));
#endif
#ifndef HAVE_FCHDIR
extern int fchdir __PR((int fd));
#endif
#ifndef HAVE_OPENAT
extern int openat __PR((int fd, const char *name, int oflag, ...));
#endif
#ifndef HAVE_GETTIMEOFDAY
#ifdef _SCHILY_TIME_H
extern int gettimeofday __PR((struct timeval *__tp, void *__tzp));
#endif
#endif
#ifndef HAVE_FACCESSAT
extern int faccessat __PR((int fd, const char *name,
int amode, int flag));
#endif
#ifndef HAVE_FCHMODAT
extern int fchmodat __PR((int fd, const char *name,
mode_t mode, int flag));
#endif
#ifndef HAVE_LCHMOD
extern int lchmod __PR((const char *name, mode_t mode));
#endif
#ifndef HAVE_FCHOWNAT
extern int fchownat __PR((int fd, const char *name,
uid_t owner, gid_t group, int flag));
#endif
#ifndef HAVE_FDOPENDIR
#ifdef _SCHILY_DIRENT_H
extern DIR *fdopendir __PR((int fd));
#endif
#endif
#ifdef _SCHILY_STAT_H
#ifndef HAVE_FSTATAT
extern int fstatat __PR((int fd, const char *name,
struct stat *sbuf, int flag));
#endif
#endif /* _SCHILY_STAT_H */
#ifdef _SCHILY_TIME_H
#ifndef HAVE_FUTIMENS
extern int futimens __PR((int fd,
const struct timespec __times[2]));
#endif
#ifndef HAVE_FUTIMESAT
extern int futimesat __PR((int fd, const char *name,
const struct timeval __times[2]));
#endif
#ifndef HAVE_LUTIMENS
extern int lutimens __PR((const char *name,
const struct timespec __times[2]));
#endif
#endif /* _SCHILY_TIME_H */
#ifndef HAVE_LINKAT
extern int linkat __PR((int fd1, const char *name1,
int fd2, const char *name2, int flag));
#endif
#ifndef HAVE_MKDIRAT
extern int mkdirat __PR((int fd, const char *name, mode_t mode));
#endif
#ifndef HAVE_MKFIFO
extern int mkfifo __PR((const char *name, mode_t mode));
#endif
#ifndef HAVE_MKFIFOAT
extern int mkfifoat __PR((int fd, const char *name, mode_t mode));
#endif
#ifndef HAVE_MKNODAT
extern int mknodat __PR((int fd, const char *name,
mode_t mode, dev_t dev));
#endif
#ifndef HAVE_READLINKAT
extern ssize_t readlinkat __PR((int fd, const char *name,
char *lbuf, size_t lbufsize));
#endif
#ifndef HAVE_RENAMEAT
extern int renameat __PR((int oldfd, const char *old,
int newfd, const char *new));
#endif
#ifndef HAVE_SYMLINKAT
extern int symlinkat __PR((const char *content,
int fd, const char *name));
#endif
#ifndef HAVE_UNLINKAT
extern int unlinkat __PR((int fd, const char *name, int flag));
#endif
#ifdef _SCHILY_TIME_H
#ifndef HAVE_UTIMENS
extern int utimens __PR((const char *name,
const struct timespec __times[2]));
#endif
#ifndef HAVE_UTIMENSAT
extern int utimensat __PR((int fd, const char *name,
const struct timespec __times[2],
int flag));
#endif
#endif /* _SCHILY_TIME_H */
#ifdef __SUNOS4
/*
* Define prototypes for POSIX standard functions that are missing on SunOS-4.x
* to make compilation smooth.
*/
#include <schily/sunos4_proto.h>
#endif /* __SUNOS4 */
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_LIBPORT_H */
@@ -0,0 +1,54 @@
/* @(#)limits.h 1.7 11/08/13 Copyright 2011 J. Schilling */
/*
* Copyright (c) 2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_LIMITS_H
#define _SCHILY_LIMITS_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_LIMITS_H
#ifndef _INCL_LIMITS_H
#include <limits.h>
#define _INCL_LIMITS_H
#endif
#endif
#ifndef COLL_WEIGHTS_MAX
#define COLL_WEIGHTS_MAX 2
#endif
#ifndef _POSIX2_LINE_MAX
#define _POSIX2_LINE_MAX 2048
#endif
/*
* Include sys/param.h for PIPE_BUF
*/
#ifndef _SCHILY_PARAM_H
#include <schily/param.h>
#endif
#ifndef PIPE_BUF
#if defined(__MINGW32__) || defined(_MSC_VER)
#define PIPE_BUF 5120
#else
#define PIPE_BUF 512
#endif
#endif /* PIPE_BUF */
#endif /* _SCHILY_LIMITS_H */
@@ -0,0 +1,50 @@
/* @(#)locale.h 1.2 09/05/24 Copyright 2009 J. Schilling */
/*
* Copyright (c) 2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_LOCALE_H
#define _SCHILY_LOCALE_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_LOCALE_H
#ifndef _INCL_LOCALE_H
#include <locale.h> /* LC_* definitions */
#define _INCL_LOCALE_H
#endif
#ifndef USE_LOCALE
#define USE_LOCALE
#endif
#else
#undef USE_LOCALE
#endif
#ifndef HAVE_SETLOCALE
#undef USE_LOCALE
#endif
#ifdef NO_LOCALE
#undef USE_LOCALE
#endif
#ifndef USE_LOCALE
#undef setlocale
#define setlocale(n, s) ((void *)0)
#endif
#endif /* _SCHILY_LOCALE_H */
@@ -0,0 +1,34 @@
/* @(#)math.h 1.1 09/08/26 Copyright 2009 J. Schilling */
/*
* Abstraction from math.h
*
* Copyright (c) 2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_MATH_H
#define _SCHILY_MATH_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_MATH_H
#ifndef _INCL_MATH_H
#define _INCL_MATH_H
#include <math.h>
#endif
#endif
#endif /* _SCHILY_MATH_H */
@@ -0,0 +1,113 @@
/* @(#)maxpath.h 1.12 10/08/27 Copyright 1985, 1995, 1998, 2001-2010 J. Schilling */
/*
* Definitions for dealing with statically limitations on pathnames
*
* Copyright (c) 1985, 1995, 1998, 2001-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_MAXPATH_H
#define _SCHILY_MAXPATH_H
#ifndef _SCHILY_DIRENT_H
#include <schily/dirent.h> /* Includes mconfig.h if needed */
#endif
#ifdef JOS
#ifndef _SCHILY_JOS_MAXP_H
# include <schily/jos_maxp.h>
#endif
# ifndef FOUND_MAXPATHNAME
# define FOUND_MAXPATHNAME
# endif
# ifndef FOUND_MAXFILENAME
# define FOUND_MAXFILENAME
# endif
#endif /* JOS */
#if !defined(FOUND_MAXPATHNAME) && defined(MAXPATHLEN)
# define MAXPATHNAME MAXPATHLEN /* From sys/param.h */
# define FOUND_MAXPATHNAME
#endif
#if !defined(FOUND_MAXPATHNAME) && defined(PATH_MAX)
# define MAXPATHNAME PATH_MAX /* From limits.h */
# define FOUND_MAXPATHNAME
#endif
#if !defined(FOUND_MAXPATHNAME)
#include <schily/stdlib.h>
#endif
#if !defined(FOUND_MAXPATHNAME) && defined(_MAX_PATH)
# define MAXPATHNAME _MAX_PATH /* From MS stdlib.h */
# define FOUND_MAXPATHNAME
#endif
#if !defined(FOUND_MAXPATHNAME)
# define MAXPATHNAME 256 /* Is there a limit? */
#endif
#ifndef PATH_MAX
#define PATH_MAX MAXPATHNAME
#endif
/*
* Don't use defaults here to allow recognition of problems.
*/
#if !defined(FOUND_MAXFILENAME) && defined(MAXNAMELEN)
# define MAXFILENAME MAXNAMELEN /* From sys/param.h */
# define FOUND_MAXFILENAME
#endif
#if !defined(FOUND_MAXFILENAME) && defined(MAXNAMLEN)
# define MAXFILENAME MAXNAMLEN /* From dirent.h */
# define FOUND_MAXFILENAME
#endif
#ifdef __never__
/*
* DIRSIZ(dp) is a parameterized macro, we cannot use it here.
*/
#if !defined(FOUND_MAXFILENAME) && defined(DIRSIZ)
# define MAXFILENAME DIRSIZ /* From sys/dir.h */
# define FOUND_MAXFILENAME
#endif
#endif /* __never__ */
#if !defined(FOUND_MAXFILENAME) && defined(NAME_MAX)
# define MAXFILENAME NAME_MAX /* From limits.h */
# define FOUND_MAXFILENAME
#endif
#if !defined(FOUND_MAXFILENAME) && defined(FOUND_DIRSIZE)
# define MAXFILENAME DIRSIZE /* From schily/dirent.h */
# define FOUND_MAXFILENAME
#endif
#if !defined(FOUND_MAXPATHNAME)
#include <schily/stdlib.h>
#endif
#if !defined(FOUND_MAXFILENAME) && defined(_MAX_FNAME)
# define MAXFILENAME _MAX_FNAME /* From MS stdlib.h */
# define FOUND_MAXFILENAME
#endif
#ifndef NAME_MAX
#define NAME_MAX MAXFILENAME
#endif
#ifndef MAXNAMLEN
#define MAXNAMLEN MAXFILENAME
#endif
#endif /* _SCHILY_MAXPATH_H */
@@ -0,0 +1,559 @@
/* @(#)mconfig.h 1.71 15/08/14 Copyright 1995-2015 J. Schilling */
/*
* definitions for machine configuration
*
* Copyright (c) 1995-2015 J. Schilling
*
* This file must be included before any other file.
* If this file is not included before stdio.h you will not be
* able to get LARGEFILE support
*
* Use only cpp instructions.
*
* NOTE: SING: (Schily Is Not Gnu)
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_MCONFIG_H
#define _SCHILY_MCONFIG_H
/*
* Tell our users that this is a Schily SING compile environment.
*/
#define IS_SCHILY
/*
* We need to do this before we include xconfig.h
*/
#ifdef NO_LARGEFILES
#undef USE_LARGEFILES
#endif
#ifdef NO_ACL
#undef USE_ACL
#endif
/*
* Inside <schily/archdefs.h> we get architecture specific Processor defines
* fetched from compiler predefinitions only.
*/
#include <schily/archdefs.h>
/*
* Inside <schily/xconfig.h> we decide whether to use static or dynamic
* autoconf stuff.
*/
#include <schily/xconfig.h>
/*
* Make sure that neither HAVE_LARGEFILES nor USE_LARGEFILES is defined
* if the platform does not support large files.
*/
#ifndef HAVE_LARGEFILES
#undef USE_LARGEFILES
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* The NetBSD people want to bother us.
* They removed the definition for 'unix' and are bleating for every test
* for #if defined(unix). So we need to check for NetBSD early.
*/
#ifndef IS_UNIX
# if defined(__NetBSD__)
# define IS_UNIX
# endif
#endif
#ifndef IS_UNIX
# if (defined(unix) || defined(__unix) || defined(__unix__)) && \
!defined(__DJGPP__)
# define IS_UNIX
# endif
#endif
#ifdef __MSDOS__
# define IS_MSDOS
#endif
#if defined(tos) || defined(__tos)
# define IS_TOS
#endif
#ifdef THINK_C
# define IS_MAC
#endif
#if defined(sun) || defined(__sun) || defined(__sun__)
# define IS_SUN
#endif
#if defined(__CYGWIN32__) || defined(__CYGWIN__)
# define IS_GCC_WIN32
# define IS_CYGWIN
#if defined(unix) || defined(_X86)
# define IS_CYGWIN_1
#endif
#endif
/* ------------------------------------------------------------------------- */
/*
* Some magic that cannot (yet) be figured out with autoconf.
*/
#if defined(sun3) || defined(mc68000) || defined(mc68020)
# ifndef HAVE_SCANSTACK
# define HAVE_SCANSTACK
# endif
#endif
#ifdef sparc
# ifndef HAVE_LDSTUB
# define HAVE_LDSTUB
# endif
# ifndef HAVE_SCANSTACK
# define HAVE_SCANSTACK
# endif
#endif
#if defined(__i386_) || defined(i386)
# ifndef HAVE_XCHG
# define HAVE_XCHG
# endif
# ifndef HAVE_SCANSTACK
# define HAVE_SCANSTACK
# endif
#endif
/*
* Use of SCANSTACK is disabled by default
*/
#ifndef USE_SCANSTACK
# undef HAVE_SCANSTACK
#else
/*
* But ....
* The tests are much better now, so always give it a chance.
*/
#ifndef HAVE_SCANSTACK
# define HAVE_SCANSTACK
#endif
#endif
/*
* Allow to overwrite the defines in the makefiles by calling
*
* make COPTX=-DFORCE_SCANSTACK
*/
#ifdef FORCE_SCANSTACK
# undef NO_SCANSTACK
#ifndef HAVE_SCANSTACK
# define HAVE_SCANSTACK
#endif
#ifndef USE_SCANSTACK
# define USE_SCANSTACK
#endif
#endif
/*
* This is the global switch to deactivate stack scanning
*/
#ifdef NO_SCANSTACK
# ifdef HAVE_SCANSTACK
# undef HAVE_SCANSTACK
# endif
#endif
/*
* This is the global switch to deactivate using #pragma weak
*/
#ifdef NO_PRAGMA_WEAK
# ifdef HAVE_PRAGMA_WEAK
# undef HAVE_PRAGMA_WEAK
# endif
#endif
#ifdef NO_FORK
# ifdef HAVE_FORK
# undef HAVE_FORK
# endif
# ifdef HAVE_VFORK
# undef HAVE_VFORK
# endif
#endif
#ifdef NO_VFORK
# ifdef HAVE_VFORK
# undef HAVE_VFORK
# endif
#endif
#if defined(SOL2) || defined(SOL2) || \
defined(S5R4) || defined(__S5R4) || defined(SVR4)
# ifndef __SVR4
# define __SVR4
# endif
#endif
#ifdef __SVR4
# ifndef SVR4
# define SVR4
# endif
#endif
/*
* SunOS 4.x / SunOS 5.x
*/
#if defined(IS_SUN)
# define HAVE_GETAV0
#endif
/*
* AIX
*/
#if defined(_IBMR2) || defined(_AIX)
# ifndef IS_UNIX
# define IS_UNIX /* ??? really ??? */
# endif
#endif
/*
* QNX
*/
#if defined(__QNX__)
# ifndef IS_UNIX
# define IS_UNIX
# endif
#endif
/*
* Silicon Graphics (must be before SVR4)
*/
#if defined(sgi) || defined(__sgi)
# define __NOT_SVR4__ /* Not a real SVR4 implementation */
#endif
/*
* Data General
*/
#if defined(__DGUX__)
#ifdef XXXXXXX
# undef HAVE_MTGET_DSREG
# undef HAVE_MTGET_RESID
# undef HAVE_MTGET_FILENO
# undef HAVE_MTGET_BLKNO
#endif
# define mt_type mt_model
# define mt_dsreg mt_status1
# define mt_erreg mt_status2
/*
* DGUX hides its flock as dg_flock.
*/
# define HAVE_FLOCK
# define flock dg_flock
/*
* Use the BSD style wait on DGUX to get the resource usages of child
* processes.
*/
# define _BSD_WAIT_FLAVOR
#endif
/*
* Apple Rhapsody (This is the name for Mac OS X beta)
*/
#if defined(__NeXT__) && defined(__TARGET_OSNAME) && __TARGET_OSNAME == rhapsody
# define HAVE_OSDEF /* prevent later definitions to overwrite current */
# ifndef IS_UNIX
# define IS_UNIX
# endif
#endif
/*
* NextStep
*/
#if defined(__NeXT__) && !defined(HAVE_OSDEF)
#define NO_PRINT_OVR
#undef HAVE_USG_STDIO
/*
* NeXT Step 3.x uses
* __flsbuf(unsigned char, FILE *)
* instead of __flsbuf(int, FILE *)
*/
# ifndef IS_UNIX
# define IS_UNIX
# endif
#endif
/*
* Mac OS X
*/
#if defined(__APPLE__) && defined(__MACH__)
# ifndef IS_UNIX
# define IS_UNIX
# endif
# define IS_MACOS_X
#endif
/*
* NextStep 3.x has a broken linker that does not allow us to override
* these functions.
*/
#ifndef __OPRINTF__
#ifdef NO_PRINT_OVR
# define printf Xprintf
# define fprintf Xfprintf
# define sprintf Xsprintf
#endif
#endif /* __OPRINTF__ */
/* ------------------------------------------------------------------------- */
#ifndef _SCHILY_PROTOTYP_H
#include <schily/prototyp.h>
#endif
/*
* We use HAVE_LONGLONG as generalized test on whether "long long", "__in64" or
* something similar exist.
*
* In case that HAVE_LONGLONG is defined here, this is an indication that
* "long long" works. We define HAVE_LONG_LONG to keep this knowledge.
*/
#ifdef HAVE_LONGLONG
# define HAVE_LONG_LONG
#endif
/*
* Microsoft C defines _MSC_VER
* use __int64 instead of long long and use 0i64 for a signed long long const
* and 0ui64 for an unsigned long long const.
*
* #if defined(HAVE___INT64)
* use __int64
* #elif defined(HAVE_LONGLONG)
* use long long
* #endif
*
* Be very careful here as older MSVC versions do not implement long long but
* rather __int64 and once someone makes 'long long' 128 bits on a 64 bit
* machine, we may need to check for a MSVC __int128 type.
*/
#ifndef HAVE_LONGLONG
# if defined(HAVE___INT64)
# define HAVE_LONGLONG
# endif
#endif
/*
* gcc 2.x generally implements the "long long" type.
*/
#ifdef __GNUC__
# if __GNUC__ > 1
# ifndef HAVE_LONGLONG
# define HAVE_LONGLONG
# endif
# ifndef HAVE_LONG_LONG
# define HAVE_LONG_LONG
# endif
# endif
#endif
#ifdef __CHAR_UNSIGNED__ /* GNU GCC define (dynamic) */
#ifndef CHAR_IS_UNSIGNED
#define CHAR_IS_UNSIGNED /* Sing Schily define (static) */
#endif
#endif
/*
* Convert to GNU name
*/
#ifdef HAVE_STDC_HEADERS
# ifndef STDC_HEADERS
# define STDC_HEADERS
# endif
#endif
/*
* Convert to SCHILY name
*/
#ifdef STDC_HEADERS
# ifndef HAVE_STDC_HEADERS
# define HAVE_STDC_HEADERS
# endif
#endif
#ifdef IS_UNIX
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ':'
# define PATH_ENV_DELIM_STR ":"
# define far
# define near
#endif
/*
* Win32 with Gygwin
*/
#ifdef IS_GCC_WIN32
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ':'
# define PATH_ENV_DELIM_STR ":"
# define HAVE_DOS_DRIVELETTER
# define far
# define near
# define NEED_O_BINARY
#endif
/*
* Win32 with Mingw32
*/
#ifdef __MINGW32__
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ';'
# define PATH_ENV_DELIM_STR ";"
# define HAVE_DOS_DRIVELETTER
# define far
# define near
# define NEED_O_BINARY
#endif
/*
* OS/2 EMX
*/
#ifdef __EMX__ /* We don't want to call it UNIX */
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ';'
# define PATH_ENV_DELIM_STR ";"
# define HAVE_DOS_DRIVELETTER
# define far
# define near
# define NEED_O_BINARY
#endif
#ifdef __BEOS__ /* We don't want to call it UNIX */
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ':'
# define PATH_ENV_DELIM_STR ":"
# define far
# define near
#endif
/*
* DOS with DJGPP
*/
#ifdef __DJGPP__ /* We don't want to call it UNIX */
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ';'
# define PATH_ENV_DELIM_STR ";"
# define HAVE_DOS_DRIVELETTER
# define NEED_O_BINARY
#endif
/*
* Vanilla DOS
*/
#if defined(IS_MSDOS) && !defined(__DJGPP__)
# define HAVE_PATH_DELIM
# define PATH_DELIM '\\'
# define PATH_DELIM_STR "\\"
# define PATH_ENV_DELIM ';'
# define PATH_ENV_DELIM_STR ";"
# define HAVE_DOS_DRIVELETTER
# define NEED_O_BINARY
#endif
/*
* ATARI TOS
*/
#ifdef IS_TOS
# define HAVE_PATH_DELIM
# define PATH_DELIM '\\'
# define PATH_DELIM_STR "\\"
# define PATH_ENV_DELIM ','
# define PATH_ENV_DELIM_STR ","
# define HAVE_DOS_DRIVELETTER
# define far
# define near
#endif
/*
* Mac OS 9
*/
#ifdef IS_MAC
# define HAVE_PATH_DELIM
# define PATH_DELIM ':'
# define PATH_DELIM_STR ":"
# define PATH_ENV_DELIM ';' /* ??? */
# define PATH_ENV_DELIM_STR ";" /* ??? */
# define far
# define near
#endif
/*
* I hope this will make compilation on unknown OS easier.
*/
#ifndef HAVE_PATH_DELIM /* Default to POSIX rules */
# define HAVE_PATH_DELIM
# define PATH_DELIM '/'
# define PATH_DELIM_STR "/"
# define PATH_ENV_DELIM ':'
# define PATH_ENV_DELIM_STR ":"
# define far
# define near
#endif
/*
* Is there a solution for /dev/tty and similar?
*/
#ifdef HAVE__DEV_NULL
# define DEV_NULL "/dev/null"
#else
#if defined(_MSC_VER) || defined(__MINGW32__)
# define DEV_NULL "NUL"
#else
/*
* What to do here?
*/
#endif
#endif
#ifdef DBG_MALLOC
/*
* We need to include this here already in order to make sure that
* every program that is based on mconfig.h will include schily/dbgmalloc.h
* in case that we specify -DDBG_MALLOC
*/
#include <schily/dbgmalloc.h>
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_MCONFIG_H */
@@ -0,0 +1,103 @@
/* @(#)nlsdefs.h 1.5 10/12/19 Copyright 2004-2010 J. Schilling */
/*
* Native language support
*
* Copyright (c) 2004-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_NLSDEFS_H
#define _SCHILY_NLSDEFS_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef NO_NLS
#ifndef USE_NLS
#define USE_NLS /* Make nls the default */
#endif
#endif
#ifdef HAVE_LIBINTL_H
#ifndef _INCL_LIBINTL_H
#include <libintl.h> /* gettext() */
#define _INCL_LIBINTL_H
#endif
#else
#undef USE_NLS
#endif
#ifndef _SCHILY_LOCALE_H
#include <schily/locale.h> /* LC_* definitions */
#endif
#ifndef _INCL_LOCALE_H
#undef USE_NLS
#endif
#ifdef HAVE_LANGINFO_H
#ifndef _INCL_LAGINFO_H
#include <langinfo.h> /* YESSTR amnd similar */
#define _INCL_LANGINFO_H
#endif
#else
#undef USE_NLS
#endif
#ifndef HAVE_GETTEXT
#undef USE_NLS
#endif
#ifdef NO_NLS
#undef USE_NLS
#endif
#ifdef NO_TEXT_DOMAIN
#undef TEXT_DOMAIN
#endif
#ifndef USE_NLS
#undef gettext
#define gettext(s) s
#undef dgettext
#define dgettext(d, s) s
#undef dcgettext
#define dcgettext(d, s, c) s
#undef textdomain
#define textdomain(a) ((char *)0)
#undef bindtextdomain
#define bindtextdomain(d, dir) ((char *)0)
#undef bind_textdomain_codeset
#define bind_textdomain_codeset(d, c) ((char *)0)
#endif
#ifdef lint
/*
* Allow lint to check printf() format strings.
*/
#define _(s) s
#else /* lint */
#ifdef USE_DGETTEXT /* e.g. in a library */
#define _(s) dgettext(TEXT_DOMAIN, s)
#else
#define _(s) gettext(s)
#endif
#endif /* lint */
/*
* Allow to mark strings for xgettext(1)
*/
#define __(s) s
#endif /* _SCHILY_NLSDEFS_H */
@@ -0,0 +1,76 @@
/* @(#)param.h 1.7 12/01/22 Copyright 2006-2011 J. Schilling */
/*
* Abstraction from sys/param.h
*
* Copyright (c) 2006-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_PARAM_H
#define _SCHILY_PARAM_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
/*
* Let us include system defined types first.
*/
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#ifndef _INCL_SYS_PARAM_H
#include <sys/param.h> /* Must be before limits.h */
#define _INCL_SYS_PARAM_H
#endif
#endif
#ifndef _SCHILY_LIMITS_H
#include <schily/limits.h> /* For _SC_CLK_TCK */
#endif
#ifndef _SCHILY_UNISTD_H
#include <schily/unistd.h> /* For _SC_CLK_TCK */
#endif
#ifndef NBBY
#define NBBY 8 /* Number of bits per byte */
#endif
#ifndef DEV_BSIZE
#define DEV_BSIZE 512 /* UNIX Device Block size */
#endif
/*
* NODEV may be in sys/param.h keep this definition past the include.
*/
#ifndef NODEV
#define NODEV ((dev_t)-1L)
#endif
#ifndef HZ
#if defined(_SC_CLK_TCK)
#define HZ ((clock_t)sysconf(_SC_CLK_TCK))
#else
#define HZ 100
#endif
#endif
/*
* Do we need to define _XOPEN_SOURCE to get NZERO?
* On Linux, it is needed but on Linux NZERO is 20.
*/
#ifndef NZERO /* for nice(2) */
#define NZERO 20
#endif
#endif /* _SCHILY_PARAM_H */
@@ -0,0 +1,130 @@
/* @(#)patmatch.h 1.15 10/08/27 Copyright 1985,1993-2010 J. Schilling */
#ifndef _SCHILY_PATMATCH_H
#define _SCHILY_PATMATCH_H
/*
* Definitions for the pattern matching functions.
*
* Copyright (c) 1985,1993-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
/*
* The pattern matching functions are based on the algorithm
* presented by Martin Richards in:
*
* "A Compact Function for Regular Expression Pattern Matching",
* Software-Practice and Experience, Vol. 9, 527-534 (1979)
*
* Several changes have been made to the original source which has been
* written in BCPL:
*
* '/' is replaced by '!' (to allow UNIX filenames)
* '(',')' are replaced by '{', '}'
* '\'' is replaced by '\\' (UNIX compatible quote)
*
* Character classes have been added to allow "[<character list>]"
* to be used.
* Start of line '^' and end of line '$' have been added.
*
* Any number in the following comment is zero or more occurrencies
*/
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define ALT '!' /* Alternation in match i.e. this!that!the_other */
#define REP '#' /* Any number of occurrences of the following expr */
#define NIL '%' /* Empty string (exactly nothing) */
#define STAR '*' /* Any number of any character (equivalent of #?) */
#define ANY '?' /* Any one character */
#define QUOTE '\\' /* Quotes the next character */
#define LBRACK '{' /* Begin of precedence grouping */
#define RBRACK '}' /* End of precedence grouping */
#define LCLASS '[' /* Begin of character set */
#define RCLASS ']' /* End of character set */
#define NOT '^' /* If first in set: invert set content */
#define RANGE '-' /* Range notation in sets */
#define START '^' /* Begin of a line */
#define END '$' /* End of a line */
/*
* A list of case statements that may be used for a issimple() or ispattern()
* funtion that checks whether a string conrtains characters that need the
* pattern matcher.
*
* Note that this list does not contain NOT or RANGE because you need
* LCLASS and RCLASS in addition.
*/
#define casePAT case ALT: case REP: case NIL: case STAR: case ANY: \
case QUOTE: case LBRACK: case RBRACK: \
case LCLASS: case RCLASS: case START: case END:
#define MAXPAT 128 /* Max length of pattern for opatmatch()/opatlmatch() */
extern int patcompile __PR((const unsigned char *__pat, int __patlen,
int *__aux));
extern unsigned char *opatmatch __PR((const unsigned char *__pat,
const int *__aux,
const unsigned char *__str,
int __soff, int __slen,
int __alt));
extern unsigned char *opatlmatch __PR((const unsigned char *__pat,
const int *__aux,
const unsigned char *__str,
int __soff, int __slen,
int __alt));
extern unsigned char *patmatch __PR((const unsigned char *__pat,
const int *__aux,
const unsigned char *__str,
int __soff, int __slen,
int __alt, int __state[]));
extern unsigned char *patlmatch __PR((const unsigned char *__pat,
const int *__aux,
const unsigned char *__str,
int __soff, int __slen,
int __alt, int __state[]));
#ifdef __cplusplus
}
#endif
#ifdef _SCHILY_WCHAR_H
#ifdef __cplusplus
extern "C" {
#endif
extern int patwcompile __PR((const wchar_t *__pat, int __patlen,
int *__aux));
extern wchar_t *patwmatch __PR((const wchar_t *__pat, const int *__aux,
const wchar_t *__str,
int __soff, int __slen,
int __alt, int __state[]));
extern wchar_t *patwlmatch __PR((const wchar_t *__pat, const int *__aux,
const wchar_t *__str,
int __soff, int __slen,
int __alt, int __state[]));
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_WCHAR_H */
#endif /* _SCHILY_PATMATCH_H */
@@ -0,0 +1,132 @@
/* @(#)prototyp.h 1.17 15/12/26 Copyright 1995-2015 J. Schilling */
/*
* Definitions for dealing with ANSI / KR C-Compilers
*
* Copyright (c) 1995-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
/*
* <schily/mconfig.h> includes <schily/prototyp.h>
* To be correct, we need to include <schily/mconfig.h> before we test
* for _SCHILY_PROTOTYP_H
*
* In order to keep the silly Solaris hdrchk(1) quiet, we are forced to
* have the _SCHILY_PROTOTYP_H first in <schily/prototyp.h>.
* To keep hdrchk(1) quiet and be correct, we need to introduce a second
* guard _SCHILY_PROTOTYP_X_H.
*/
#ifndef _SCHILY_PROTOTYP_H
#define _SCHILY_PROTOTYP_H
#ifndef _SCHILY_MCONFIG_H
#undef _SCHILY_PROTOTYP_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_PROTOTYP_X_H
#define _SCHILY_PROTOTYP_X_H
#include <schily/ccomdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef PROTOTYPES
/*
* If this has already been defined,
* someone else knows better than us...
*/
# ifdef __STDC__
# if __STDC__ /* ANSI C */
# define PROTOTYPES
# endif
# if defined(sun) && __STDC__ - 0 == 0 /* Sun C */
# define PROTOTYPES
# endif
# endif
#endif /* PROTOTYPES */
#if !defined(PROTOTYPES) && (defined(__cplusplus) || defined(_MSC_VER))
/*
* C++ always supports prototypes.
* Define PROTOTYPES so we are not forced to make
* a separtate autoconf run for C++
*
* Microsoft C has prototypes but does not define __STDC__
*/
# define PROTOTYPES
#endif
/*
* If we have prototypes, we should have stdlib.h string.h stdarg.h
*/
#ifdef PROTOTYPES
#if !(defined(SABER) && defined(sun))
# ifndef HAVE_STDARG_H
# define HAVE_STDARG_H
# endif
#endif
#ifndef JOS
# ifndef HAVE_STDLIB_H
# define HAVE_STDLIB_H
# endif
# ifndef HAVE_STRING_H
# define HAVE_STRING_H
# endif
# ifndef HAVE_STDC_HEADERS
# define HAVE_STDC_HEADERS
# endif
# ifndef STDC_HEADERS
# define STDC_HEADERS /* GNU name */
# endif
#endif
#endif
#ifdef NO_PROTOTYPES /* Force not to use prototypes */
# undef PROTOTYPES
#endif
#ifdef PROTOTYPES
# define __PR(a) a
#else
# define __PR(a) ()
#endif
#if !defined(PROTOTYPES) && !defined(NO_CONST_DEFINE)
# ifndef const
# define const
# endif
# ifndef signed
# define signed
# endif
# ifndef volatile
# define volatile
# endif
#endif
#ifdef PROTOTYPES
#define ALERT '\a'
#else
#define ALERT '\07'
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_PROTOTYP_X_H */
#endif /* _SCHILY_PROTOTYP_H */
@@ -0,0 +1,658 @@
/* @(#)schily.h 1.120 16/09/28 Copyright 1985-2016 J. Schilling */
/*
* Definitions for libschily
*
* This file should be included past:
*
* schily/mconfig.h / config.h
* schily/standard.h
* stdio.h
* stdlib.h (better use schily/stdlib.h)
* unistd.h (better use schily/unistd.h) needed f. LARGEFILE support
* schily/string.h
* sys/types.h
*
* If you need stdio.h, you must include it before schily/schily.h
*
* NOTE: If you need ctype.h and did not include stdio.h you need to
* include ctype.h past schily/schily.h as OpenBSD does not follow POSIX
* and defines EOF in ctype.h
*
* Copyright (c) 1985-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_SCHILY_H
#define _SCHILY_SCHILY_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_STANDARD_H
#include <schily/standard.h>
#endif
#ifndef _SCHILY_CCOMDEFS_H
#include <schily/ccomdefs.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(off_t)
# ifndef FOUND_OFF_T
# define FOUND_OFF_T
# endif
#endif
#if defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(size_t)
# ifndef FOUND_SIZE_T
# define FOUND_SIZE_T
# endif
#endif
#if defined(_MSC_VER) && !defined(_SIZE_T_DEFINED)
# undef FOUND_SIZE_T
#endif
#ifdef __never_def__
/*
* It turns out that we cannot use the folloginw definition because there are
* some platforms that do not behave application friendly. These are mainly
* BSD-4.4 based systems (which #undef a definition when size_t is available.
* We actually removed this code because of a problem with QNX Neutrino.
* For this reason, it is important not to include <sys/types.h> directly but
* via the Schily SING include files so we know whether it has been included
* before we come here.
*/
#if defined(_SIZE_T) || defined(_T_SIZE_) || defined(_T_SIZE) || \
defined(__SIZE_T) || defined(_SIZE_T_) || \
defined(_GCC_SIZE_T) || defined(_SIZET_) || \
defined(__sys_stdtypes_h) || defined(___int_size_t_h) || defined(size_t)
#ifndef FOUND_SIZE_T
# define FOUND_SIZE_T /* We already included a size_t definition */
#endif
#endif
#endif /* __never_def__ */
#if defined(HAVE_LARGEFILES)
# define _fcons _fcons64
# define fdup fdup64
# define fileluopen fileluopen64
# define fileopen fileopen64
# define filemopen filemopen64
# define filepos filepos64
# define filereopen filereopen64
# define fileseek fileseek64
# define filesize filesize64
# define filestat filestat64
# define _openfd _openfd64
#endif
/*
* The official POSIX rule is not to define "new" interfaces that
* are in conflict with older interfaces of the same name.
* Our interfaces fexec*() have been defined and published in 1982.
* The new POSIX interfaces define a different interface and the
* new POSIX interfaces even use names that are not compatible with
* POSIX rules. The new POSIX interfaces in question should be called
* fdexec*() to follow the rules of other similar POSIX functions.
* Simiar problems exist with getline()/fgetline().
*/
#if defined(HAVE_RAW_FEXECL) || defined(HAVE_RAW_FEXECLE) || \
defined(HAVE_RAW_FEXECV) || defined(HAVE_RAW_FEXECVE)
#define RENAME_FEXEC
#endif
#if defined(HAVE_RAW_FSPAWNV) || defined(HAVE_RAW_FSPAWNL) || \
defined(HAVE_RAW_FSPAWNV_NOWAIT)
#define RENAME_FSPAWN
#endif
#if defined(HAVE_RAW_GETLINE) || defined(HAVE_RAW_FGETLINE)
#define RENAME_GETLINE
#endif
#ifdef __needed__
#define RENAME_FEXEC
#define RENAME_FSPAWN
#define RENAME_GETLINE
#endif
#if defined(RENAME_FEXEC) || defined(RENAME_FSPAWN)
#ifndef _SCHILY_UNISTD_H
#include <schily/unistd.h> /* Need to incl. before fexec*() protoypes */
#endif
#endif
#if defined(RENAME_GETLINE)
#ifndef _SCHILY_STDIO_H
#include <schily/stdio.h> /* Need to incl. before *getline() protoypes */
#endif
#endif
#ifdef EOF /* stdio.h has been included */
extern int _cvmod __PR((const char *, int *, int *));
extern FILE *_fcons __PR((FILE *, int, int));
extern FILE *fdup __PR((FILE *));
#if !defined(fdown) || defined(PROTOTYPES)
/*
* We cannot declare fdown() with K&R in case that fdown() has been #define'd
*/
extern int fdown __PR((FILE *));
#endif
extern int js_fexecl __PR((const char *, FILE *, FILE *, FILE *,
const char *, ...));
extern int js_fexecle __PR((const char *, FILE *, FILE *, FILE *,
const char *, ...));
/* 6th arg not const, fexecv forces av[ac] = NULL */
extern int js_fexecv __PR((const char *, FILE *, FILE *, FILE *, int,
char **));
extern int js_fexecve __PR((const char *, FILE *, FILE *, FILE *,
char * const *, char * const *));
extern int js_fspawnv __PR((FILE *, FILE *, FILE *, int, char * const *));
extern int js_fspawnl __PR((FILE *, FILE *, FILE *, const char *, ...));
extern int js_fspawnv_nowait __PR((FILE *, FILE *, FILE *,
const char *, int, char *const*));
extern int js_fgetline __PR((FILE *, char *, int));
#ifdef FOUND_SIZE_T
extern ssize_t fgetaline __PR((FILE *, char **, size_t *));
extern ssize_t getaline __PR((char **, size_t *));
#endif
extern int fgetstr __PR((FILE *, char *, int));
extern int file_getraise __PR((FILE *));
extern void file_raise __PR((FILE *, int));
extern int fileclose __PR((FILE *));
extern FILE *fileluopen __PR((int, const char *));
extern FILE *fileopen __PR((const char *, const char *));
#ifdef _SCHILY_TYPES_H
extern FILE *filemopen __PR((const char *, const char *, mode_t));
#endif
#ifdef FOUND_OFF_T
extern off_t filepos __PR((FILE *));
#endif
#ifdef FOUND_SIZE_T
extern ssize_t fileread __PR((FILE *, void *, size_t));
extern ssize_t ffileread __PR((FILE *, void *, size_t));
#endif
extern FILE *filereopen __PR((const char *, const char *, FILE *));
#ifdef FOUND_OFF_T
extern int fileseek __PR((FILE *, off_t));
extern off_t filesize __PR((FILE *));
#endif
#ifdef S_IFMT
extern int filestat __PR((FILE *, struct stat *));
#endif
#ifdef FOUND_SIZE_T
extern ssize_t filewrite __PR((FILE *, void *, size_t));
extern ssize_t ffilewrite __PR((FILE *, void *, size_t));
#endif
extern int flush __PR((void));
extern int fpipe __PR((FILE **));
#ifdef __never__
extern int fprintf __PR((FILE *, const char *, ...)) __printflike__(2, 3);
#endif
extern int getbroken __PR((FILE *, char *, char, char **, int));
extern int ofindline __PR((FILE *, char, const char *, int,
char **, int));
extern int peekc __PR((FILE *));
#ifdef __never_def__
/*
* We cannot define this or we may get into problems with DOS based systems.
*/
extern int spawnv __PR((FILE *, FILE *, FILE *, int, char * const *));
extern int spawnl __PR((FILE *, FILE *, FILE *, const char *, ...));
extern int spawnv_nowait __PR((FILE *, FILE *, FILE *,
const char *, int, char *const*));
#endif /* __never_def__ */
#endif /* EOF */
/*
* Flags for absfpath() and resolvefpath():
*/
#define RSPF_EXIST 0x01 /* All path components must exist */
#define RSPF_NOFOLLOW_LAST 0x02 /* Don't follow link in last pathcomp */
#ifdef FOUND_SIZE_T
extern char *abspath __PR((const char *relp, char *absp, size_t asize));
extern char *absnpath __PR((const char *relp, char *absp, size_t asize));
extern char *absfpath __PR((const char *relp, char *absp, size_t asize,
int __flags));
#ifndef HAVE_RESOLVEPATH
extern int resolvepath __PR((const char *__path,
char *__buf, size_t __bufsiz));
#endif
extern int resolvenpath __PR((const char *__path,
char *__buf, size_t __bufsiz));
extern int resolvefpath __PR((const char *__path,
char *__buf, size_t __bufsiz, int __flags));
#endif
#ifdef _SCHILY_TYPES_H
extern int mkdirs __PR((char *, mode_t));
extern int makedirs __PR((char *, mode_t, int __striplast));
#endif
extern int lxchdir __PR((char *));
#ifdef HAVE_FCHDIR
#define fdsetname(fd, name) (0)
#define fdclosename(fd) (0)
#else
extern int fdsetname __PR((int fd, const char *name));
extern int fdclosename __PR((int fd));
#endif
extern int diropen __PR((const char *));
extern int dirrdopen __PR((const char *));
extern int dirclose __PR((int));
struct save_wd {
int fd;
char *name;
};
extern int savewd __PR((struct save_wd *sp));
extern void closewd __PR((struct save_wd *sp));
extern int restorewd __PR((struct save_wd *sp));
#ifdef _SCHILY_UTYPES_H
typedef struct gnmult {
char key;
Llong mult;
} gnmult_t;
extern int getllnum __PR((char *arg, Llong *lvalp));
extern int getxnum __PR((char *arg, long *valp, gnmult_t *mult));
extern int getllxnum __PR((char *arg, Llong *lvalp, gnmult_t *mult));
extern int getlltnum __PR((char *arg, Llong *lvalp));
extern int getxtnum __PR((char *arg, time_t *valp, gnmult_t *mult));
extern int getllxtnum __PR((char *arg, Llong *lvalp, gnmult_t *mult));
#endif
extern int getnum __PR((char *arg, long *valp));
#ifdef _SCHILY_TIME_H
extern int gettnum __PR((char *arg, time_t *valp));
#endif
#ifdef _SCHILY_TIME_H
extern int getnstimeofday __PR((struct timespec *__tp));
extern int setnstimeofday __PR((struct timespec *__tp));
#ifdef _SCHILY_UTYPES_H
extern Llong mklgmtime __PR((struct tm *));
#endif
extern time_t mkgmtime __PR((struct tm *));
#endif
#ifdef EOF /* stdio.h has been included */
#ifdef _SCHILY_TYPES_H
/*
* getperm() flags:
*/
#define GP_NOX 0 /* This is not a dir and 'X' is not valid */
#define GP_DOX 1 /* 'X' perm character is valid */
#define GP_XERR 2 /* 'X' perm characters are invalid */
#define GP_FPERM 4 /* TRUE if we implement find -perm */
#define GP_UMASK 8 /* TRUE if we implement umask */
extern int getperm __PR((FILE *f, char *perm, char *opname, \
mode_t *modep, int smode, int flag));
extern void permtostr __PR((mode_t mode, char *));
#endif
#endif
#ifdef FOUND_SIZE_T
extern ssize_t _niread __PR((int, void *, size_t));
extern ssize_t _niwrite __PR((int, void *, size_t));
extern ssize_t _nixread __PR((int, void *, size_t));
extern ssize_t _nixwrite __PR((int, void *, size_t));
#endif
extern int _openfd __PR((const char *, int));
extern int on_comerr __PR((void (*fun)(int, void *), void *arg));
/*PRINTFLIKE1*/
extern void comerr __PR((const char *, ...)) __printflike__(1, 2);
/*PRINTFLIKE2*/
extern void xcomerr __PR((int, const char *, ...)) __printflike__(2, 3);
/*PRINTFLIKE2*/
extern void comerrno __PR((int, const char *, ...)) __printflike__(2, 3);
/*PRINTFLIKE3*/
extern void xcomerrno __PR((int, int, const char *, ...)) __printflike__(3, 4);
/*PRINTFLIKE1*/
extern int errmsg __PR((const char *, ...)) __printflike__(1, 2);
/*PRINTFLIKE2*/
extern int errmsgno __PR((int, const char *, ...)) __printflike__(2, 3);
#ifdef FOUND_SIZE_T
/*PRINTFLIKE3*/
extern int serrmsg __PR((char *, size_t, const char *, ...))
__printflike__(3, 4);
/*PRINTFLIKE4*/
extern int serrmsgno __PR((int, char *, size_t, const char *, ...))
__printflike__(4, 5);
#endif
extern void comexit __PR((int));
extern char *errmsgstr __PR((int));
#ifdef EOF /* stdio.h has been included */
/*PRINTFLIKE2*/
extern void fcomerr __PR((FILE *, const char *, ...))
__printflike__(2, 3);
/*PRINTFLIKE3*/
extern void fxcomerr __PR((FILE *, int, const char *, ...))
__printflike__(3, 4);
/*PRINTFLIKE3*/
extern void fcomerrno __PR((FILE *, int, const char *, ...))
__printflike__(3, 4);
/*PRINTFLIKE4*/
extern void fxcomerrno __PR((FILE *, int, int, const char *, ...))
__printflike__(4, 5);
/*PRINTFLIKE2*/
extern int ferrmsg __PR((FILE *, const char *, ...))
__printflike__(2, 3);
/*PRINTFLIKE3*/
extern int ferrmsgno __PR((FILE *, int, const char *, ...))
__printflike__(3, 4);
#ifdef _SCHILY_VARARGS_H
#define COMERR_RETURN 0
#define COMERR_EXIT 1
#define COMERR_EXCODE 2
/*PRINTFLIKE5*/
extern int _comerr __PR((FILE *, int, int, int,
const char *, va_list));
#endif
#endif
/*PRINTFLIKE1*/
extern int error __PR((const char *, ...)) __printflike__(1, 2);
#ifdef FOUND_SIZE_T
extern char *fillbytes __PR((void *, ssize_t, char));
extern char *zerobytes __PR((void *, ssize_t));
extern char *findbytes __PR((const void *, ssize_t, char));
#endif
extern char *findinpath __PR((char *__name, int __mode,
BOOL __plain_file, char *__path));
extern int findline __PR((const char *, char, const char *,
int, char **, int));
extern int js_getline __PR((char *, int));
extern int getstr __PR((char *, int));
extern int breakline __PR((char *, char, char **, int));
extern int getallargs __PR((int *, char * const**, const char *, ...));
extern int getargs __PR((int *, char * const**, const char *, ...));
extern int getfiles __PR((int *, char * const**, const char *));
extern char *astoi __PR((const char *, int *));
extern char *astol __PR((const char *, long *));
extern char *astolb __PR((const char *, long *, int base));
#ifdef _SCHILY_UTYPES_H
extern char *astoll __PR((const char *, Llong *));
extern char *astollb __PR((const char *, Llong *, int));
extern char *astoull __PR((const char *, Ullong *));
extern char *astoullb __PR((const char *, Ullong *, int));
#endif
extern int patcompile __PR((const unsigned char *, int, int *));
extern unsigned char *patmatch __PR((const unsigned char *, const int *,
const unsigned char *,
int, int, int, int[]));
extern unsigned char *patlmatch __PR((const unsigned char *, const int *,
const unsigned char *,
int, int, int, int[]));
#ifdef __never__
extern int printf __PR((const char *, ...)) __printflike__(1, 2);
#endif
#ifdef FOUND_SIZE_T
extern char *movebytes __PR((const void *, void *, ssize_t));
#endif
extern void save_args __PR((int, char **));
extern int saved_ac __PR((void));
extern char **saved_av __PR((void));
extern char *saved_av0 __PR((void));
extern char *searchfileinpath __PR((char *__name, int __mode,
int __file_mode, char *__path));
#define SIP_ANY_FILE 0x00 /* Search for any file type */
#define SIP_PLAIN_FILE 0x01 /* Search for plain files - not dirs */
#define SIP_NO_PATH 0x10 /* Do not do PATH search */
#define SIP_ONLY_PATH 0x20 /* Do only PATH search */
#define SIP_NO_STRIPBIN 0x40 /* Do not strip "/bin" from PATH elem. */
#define SIP_TYPE_MASK 0x0F /* Mask file type related bits */
#ifndef seterrno
extern int seterrno __PR((int));
#endif
extern void set_progname __PR((const char *));
extern char *get_progname __PR((void));
extern char *get_progpath __PR((void));
extern char *getexecpath __PR((void));
extern void setfp __PR((void * const *));
extern int wait_chld __PR((int)); /* for fspawnv_nowait() */
extern int geterrno __PR((void));
extern void raisecond __PR((const char *, long));
#ifdef __never__
/*
* sprintf() may be declared incorrectly somewhere else
* e.g. in old BSD include files
*/
extern int sprintf __PR((char *, const char *, ...));
#endif
extern char *strcatl __PR((char *, ...));
#ifdef FOUND_SIZE_T
extern size_t strlcatl __PR((char *, size_t, ...));
#endif
extern int streql __PR((const char *, const char *));
#ifdef _SCHILY_WCHAR_H
extern wchar_t *wcscatl __PR((wchar_t *, ...));
#ifdef FOUND_SIZE_T
extern size_t wcslcatl __PR((wchar_t *, size_t, ...));
#endif
extern int wcseql __PR((const wchar_t *, const wchar_t *));
#endif
#ifdef va_arg
extern int format __PR((void (*)(char, long), long, const char *,
va_list));
extern int fprformat __PR((long, const char *, va_list));
#else
extern int format __PR((void (*)(char, long), long, const char *, void *));
extern int fprformat __PR((long, const char *, void *));
#endif
extern int ftoes __PR((char *, double, int, int));
extern int ftofs __PR((char *, double, int, int));
#ifdef HAVE_LONGDOUBLE
extern int qftoes __PR((char *, long double, int, int));
extern int qftofs __PR((char *, long double, int, int));
#endif
/*PRINTFLIKE1*/
extern int js_error __PR((const char *, ...)) __printflike__(1, 2);
/*PRINTFLIKE2*/
extern int js_dprintf __PR((int, const char *, ...))
__printflike__(2, 3);
#ifdef EOF /* stdio.h has been included */
/*PRINTFLIKE2*/
extern int js_fprintf __PR((FILE *, const char *, ...))
__printflike__(2, 3);
#endif /* EOF */
/*PRINTFLIKE1*/
extern int js_printf __PR((const char *, ...)) __printflike__(1, 2);
#ifdef FOUND_SIZE_T
/*PRINTFLIKE3*/
extern int js_snprintf __PR((char *, size_t, const char *, ...))
__printflike__(3, 4);
#endif
/*PRINTFLIKE2*/
extern int js_sprintf __PR((char *, const char *, ...))
__printflike__(2, 3);
#ifdef FOUND_SIZE_T
extern void swabbytes __PR((void *, ssize_t));
#endif
extern char **getmainfp __PR((void));
extern char **getavp __PR((void));
extern char *getav0 __PR((void));
extern void **getfp __PR((void));
extern int flush_reg_windows __PR((int));
#ifdef FOUND_SIZE_T
extern ssize_t cmpbytes __PR((const void *, const void *, ssize_t));
extern int cmpmbytes __PR((const void *, const void *, ssize_t));
extern ssize_t cmpnullbytes __PR((const void *, ssize_t));
#endif
#ifdef nonono
#if defined(HAVE_LARGEFILES)
/*
* To allow this, we need to figure out how to do autoconfiguration for off64_t
*/
extern FILE *_fcons64 __PR((FILE *, int, int));
extern FILE *fdup64 __PR((FILE *));
extern FILE *fileluopen64 __PR((int, const char *));
extern FILE *fileopen64 __PR((const char *, const char *));
#ifdef FOUND_OFF_T
extern off64_t filepos64 __PR((FILE *));
#endif
extern FILE *filereopen64 __PR((const char *, const char *, FILE *));
#ifdef FOUND_OFF_T
extern int fileseek64 __PR((FILE *, off64_t));
extern off64_t filesize64 __PR((FILE *));
#endif
#ifdef S_IFMT
extern int filestat64 __PR((FILE *, struct stat *));
#endif
extern int _openfd64 __PR((const char *, int));
#endif
#endif
#ifndef NO_SCHILY_PRINT /* Define to disable *printf() redirects */
#ifdef SCHILY_PRINT
#ifdef __never__
#undef error
#define error js_error
#endif
#undef dprintf
#define dprintf js_dprintf
#undef fprintf
#define fprintf js_fprintf
#undef printf
#define printf js_printf
#undef snprintf
#define snprintf js_snprintf
#undef sprintf
#define sprintf js_sprintf
#else
#ifndef HAVE_SNPRINTF
#undef snprintf
#define snprintf js_snprintf
#endif
#endif
#endif
#ifndef NO_SCHILY_GETLINE /* Define to disable *getline() redirect */
#undef getline
#define getline js_getline
#undef fgetline
#define fgetline js_fgetline
#endif
#ifndef NO_SCHILY_FEXEC /* Define to disable fexec*() redirect */
#undef fexecl
#define fexecl js_fexecl
#undef fexecle
#define fexecle js_fexecle
#undef fexecv
#define fexecv js_fexecv
#undef fexecve
#define fexecve js_fexecve
#endif
#ifndef NO_SCHILY_FSPAWN /* Define to disable fspawn*() redirect */
#undef fspawnv
#define fspawnv js_fspawnv
#undef fspawnv_nowait
#define fspawnv_nowait js_fspawnv_nowait
#undef fspawnl
#define fspawnl js_fspawnl
#endif
extern int js_mexval __PR((int exval));
#ifdef FOUND_SIZE_T
extern void *js_malloc __PR((size_t size, char *msg));
extern void *js_realloc __PR((void *ptr, size_t size, char *msg));
#endif
extern char *js_savestr __PR((const char *s));
#ifdef _SCHILY_JMPDEFS_H
/*
* Special values for the "jmp" parameter.
*
* Control how the siglongjmp() should be handled:
*/
#define JM_EXIT ((sigjmps_t *)-1) /* Call comexit(errno) instead */
#define JM_RETURN ((sigjmps_t *)0) /* Return instead */
extern int js_jmexval __PR((int exval));
#ifdef FOUND_SIZE_T
extern void *js_jmalloc __PR((size_t size, char *msg, sigjmps_t *jmp));
extern void *js_jrealloc __PR((void *ptr, size_t size, char *msg,
sigjmps_t *jmp));
#endif
extern char *js_jsavestr __PR((const char *s, sigjmps_t *jmp));
extern int js_fjmexval __PR((int exval));
#ifdef EOF /* stdio.h has been included */
#ifdef FOUND_SIZE_T
extern void *js_fjmalloc __PR((FILE *f, size_t size, char *msg,
sigjmps_t *jmp));
extern void *js_fjrealloc __PR((FILE *f, void *ptr, size_t size,
char *msg, sigjmps_t *jmp));
#endif
extern char *js_fjsavestr __PR((FILE *f, const char *s, sigjmps_t *jmp));
#endif /* EOF */
#endif /* _SCHILY_JMPDEFS_H */
#define ___mexval js_mexval
#define ___malloc js_malloc
#define ___realloc js_realloc
#define ___savestr js_savestr
#define __jmexval js_jmexval
#define __jmalloc js_jmalloc
#define __jrealloc js_jrealloc
#define __jsavestr js_jsavestr
#define __fjmalloc js_fjmalloc
#define __fjmexval js_fjmexval
#define __fjrealloc js_fjrealloc
#define __fjsavestr js_fjsavestr
#ifdef __cplusplus
}
#endif
#if defined(_JOS) || defined(JOS)
# ifndef _SCHILY_JOS_IO_H
# include <schily/jos_io.h>
# endif
#endif
#if !defined(_SCHILY_LIBPORT_H) && !defined(NO_LIBPORT_H)
#include <schily/libport.h>
#endif
#if !defined(_SCHILY_HOSTNAME_H) && defined(USE_HOSTNAME_H)
#include <schily/hostname.h>
#endif
#endif /* _SCHILY_SCHILY_H */
@@ -0,0 +1,63 @@
/* @(#)siconv.h 1.5 10/12/20 Copyright 2007-2010 J. Schilling */
/*
* Definitions fur users of libsiconv
*
* Copyright (c) 2007-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_SICONV_H
#define _SCHILY_SICONV_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h>
#endif
#ifndef _SCHILY_ICONV_H
#include <schily/iconv.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct siconv_table siconvt_t;
struct siconv_table {
char *sic_name; /* SICONV charset name */
UInt16_t *sic_cs2uni; /* Charset -> Unicode */
UInt8_t **sic_uni2cs; /* Unicode -> Charset */
iconv_t sic_cd2uni; /* iconv Charset -> Unicode */
iconv_t sic_uni2cd; /* iconv Unicode -> Charset */
siconvt_t *sic_alt; /* alternate iconv tab */
siconvt_t *sic_next; /* Next table */
int sic_refcnt; /* Reference count */
};
#define use_iconv(t) ((t)->sic_cd2uni != NULL)
#define sic_c2uni(t, c) ((t)->sic_cs2uni[c])
#define sic_uni2c(t, c) ((t)->sic_uni2cs[((c) >> 8) & 0xFF][(c) & 0xFF])
extern int sic_list __PR((FILE *));
extern siconvt_t *sic_open __PR((char *));
extern const char *sic_base __PR((void));
extern int sic_close __PR((siconvt_t *));
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_SICONV_H */
@@ -0,0 +1,62 @@
/* @(#)sigblk.h 1.12 08/12/24 Copyright 1985, 1995-2008 J. Schilling */
/*
* software signal block definition
*
* Copyright (c) 1985, 1995-2008 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_SIGBLK_H
#define _SCHILY_SIGBLK_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct sigblk {
long **sb_savfp; /* Real saved framepointer */
struct sigblk *sb_signext; /* Next sw signal blk for this func */
short sb_siglen; /* Strlen for sb_signame */
const char *sb_signame; /* Name of software signal */
/* sb_sigfun: function to call */
int (*sb_sigfun) __PR((const char *, long, long));
long sb_sigarg; /* Second arg for sb_sigfun */
} SIGBLK;
/*
* The handler function is called with three arguments:
*
* 1) The name of the software signal
* 2) The argument from the handlecond() call
* 3) The argument from the raisecond() call
*/
typedef int (*handlefunc_t) __PR((const char *, long, long));
extern void handlecond __PR((const char *, SIGBLK *,
int(*)(const char *, long, long),
long));
extern void raisecond __PR((const char *, long));
extern void starthandlecond __PR((SIGBLK *));
extern void unhandlecond __PR((SIGBLK *));
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_SIGBLK_H */
@@ -0,0 +1,159 @@
/* @(#)standard.h 1.40 13/05/01 Copyright 1985-2013 J. Schilling */
/*
* standard definitions
*
* This file should be included past:
*
* mconfig.h / config.h
* stdio.h
* stdlib.h (better use schily/stdlib.h)
* unistd.h (better use schily/unistd.h) needed f. LARGEFILE support
*
* If you need stdio.h, you must include it before standard.h
*
* Copyright (c) 1985-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_STANDARD_H
#define _SCHILY_STANDARD_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef M68000
# ifndef tos
# define JOS 1
# endif
#endif
/*
* fundamental constants
*/
#ifndef NULL
# define NULL 0
#endif
#ifndef TRUE
# define TRUE 1
# define FALSE 0
#endif
/*
* Program exit codes used with comerr(), comexit() and similar.
*
* Exit codes between -2 and -63 are currently available to flag
* program specific error conditions.
*/
#define EX_BAD (-1) /* Default error exit code */
#define EX_CLASH (-64) /* Exit code used with exit clashes */
/*
* standard storage class definitions
*/
#define GLOBAL extern
#define IMPORT extern
#define EXPORT
#define INTERN static
#define LOCAL static
#define FAST register
#ifndef PROTOTYPES
# ifndef const
# define const
# endif
# ifndef signed
# define signed
# endif
# ifndef volatile
# define volatile
# endif
#endif /* PROTOTYPES */
/*
* standard type definitions
*
* The hidden Schily BOOL definition is used in case we need to deal
* with other BOOL defines on systems we like to port to.
*/
typedef int __SBOOL;
typedef int BOOL;
#ifdef JOS
# ifndef __GNUC__
# define NO_VOID
# endif
#endif
#ifdef NO_VOID
# ifndef lint
typedef int void;
# endif
#endif
#if defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(off_t)
# ifndef FOUND_OFF_T
# define FOUND_OFF_T
# endif
#endif
#if defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(size_t)
# ifndef FOUND_SIZE_T
# define FOUND_SIZE_T
# endif
#endif
#if defined(_MSC_VER) && !defined(_SIZE_T_DEFINED)
# undef FOUND_SIZE_T
#endif
#ifdef __never_def__
/*
* It turns out that we cannot use the folloginw definition because there are
* some platforms that do not behave application friendly. These are mainly
* BSD-4.4 based systems (which #undef a definition when size_t is available.
* We actually removed this code because of a problem with QNX Neutrino.
* For this reason, it is important not to include <sys/types.h> directly but
* via the Schily SING include files so we know whether it has been included
* before we come here.
*/
#if defined(_SIZE_T) || defined(_T_SIZE_) || defined(_T_SIZE) || \
defined(__SIZE_T) || defined(_SIZE_T_) || \
defined(_GCC_SIZE_T) || defined(_SIZET_) || \
defined(__sys_stdtypes_h) || defined(___int_size_t_h) || defined(size_t)
#ifndef FOUND_SIZE_T
# define FOUND_SIZE_T /* We already included a size_t definition */
#endif
#endif
#endif /* __never_def__ */
#ifdef __cplusplus
}
#endif
#if defined(_JOS) || defined(JOS)
# ifndef _SCHILY_SCHILY_H
# include <schily/schily.h>
# endif
# ifndef _SCHILY_JOS_DEFS_H
# include <schily/jos_defs.h>
# endif
# ifndef _SCHILY_JOS_IO_H
# include <schily/jos_io.h>
# endif
#endif
#endif /* _SCHILY_STANDARD_H */
@@ -0,0 +1,402 @@
/* @(#)stat.h 1.20 15/08/23 Copyright 1998-2015 J. Schilling */
/*
* Definitions for stat() file mode
*
* Copyright (c) 1998-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_STAT_H
#define _SCHILY_STAT_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h> /* Needed for sys/stat.h */
#endif
#ifndef _INCL_SYS_STAT_H
#include <sys/stat.h> /* For S_IS* and S_IF* */
#define _INCL_SYS_STAT_H
#endif
#if !defined(HAVE_LSTAT) || !defined(S_IFLNK)
#define lstat stat
#endif
/*
* Apollo Domain/OS has a broken sys/stat.h that defines
* S_IFIFO == S_IFSOCK and creates trouble if the constants
* are used as case labels.
*/
#if S_IFIFO == S_IFSOCK
# undef S_IFSOCK
#endif
#ifdef STAT_MACROS_BROKEN
#undef S_ISFIFO /* Named pipe */
#undef S_ISCHR /* Character special */
#undef S_ISMPC /* UNUSED multiplexed c */
#undef S_ISDIR /* Directory */
#undef S_ISNAM /* Named file (XENIX) */
#undef S_ISBLK /* Block special */
#undef S_ISMPB /* UNUSED multiplexed b */
#undef S_ISREG /* Regular file */
#undef S_ISCTG /* Contiguous file */
#undef S_ISLNK /* Symbolic link */
#undef S_ISSHAD /* Solaris shadow inode */
#undef S_ISSOCK /* UNIX domain socket */
#undef S_ISDOOR /* Solaris DOOR */
#undef S_ISPORT /* Solaris event port */
#undef S_ISWHT /* BSD whiteout */
#undef S_ISEVC /* UNOS eventcount */
#endif
#ifndef S_ISFIFO /* 1 Named pipe */
# ifdef S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# else
# define S_ISFIFO(m) (0)
# endif
#endif
#ifndef S_ISCHR /* 2 Character special */
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) (0)
# endif
#endif
#ifndef S_ISMPC /* 3 UNUSED multiplexed char */
# ifdef S_IFMPC
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
# else
# define S_ISMPC(m) (0)
# endif
#endif
#ifndef S_ISDIR /* 4 Directory */
# ifdef S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# else
# define S_ISDIR(m) (0)
# endif
#endif
#ifndef S_ISNAM /* 5 Named file (XENIX) */
# ifdef S_IFNAM
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
# else
# define S_ISNAM(m) (0)
# endif
#endif
#ifndef S_ISBLK /* 6 Block special */
# ifdef S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# else
# define S_ISBLK(m) (0)
# endif
#endif
#ifndef S_ISMPB /* 7 UNUSED multiplexed block */
# ifdef S_IFMPB
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# else
# define S_ISMPB(m) (0)
# endif
#endif
#ifndef S_ISREG /* 8 Regular file */
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# else
# define S_ISREG(m) (0)
# endif
#endif
#ifndef S_ISCTG /* 9 Contiguous file */
# ifdef S_IFCTG
# define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
# else
# define S_ISCTG(m) (0)
# endif
#endif
#ifndef S_ISLNK /* 10 Symbolic link */
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) (0)
# endif
#endif
#ifndef S_ISSHAD /* 11 Solaris shadow inode */
# ifdef S_IFSHAD
# define S_ISSHAD(m) (((m) & S_IFMT) == S_IFSHAD)
# else
# define S_ISSHAD(m) (0)
# endif
#endif
#ifndef S_ISSOCK /* 12 UNIX domain socket */
# ifdef S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) (0)
# endif
#endif
#ifndef S_ISDOOR /* 13 Solaris DOOR */
# ifdef S_IFDOOR
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
# else
# define S_ISDOOR(m) (0)
# endif
#endif
#ifndef S_ISPORT /* 14 Solaris event port */
# ifdef S_IFPORT
# define S_ISPORT(m) (((m) & S_IFMT) == S_IFPORT)
# else
# define S_ISPORT(m) (0)
# endif
#endif
#ifndef S_ISWHT /* 14 BSD whiteout */
# ifdef S_IFWHT
# define S_ISWHT(m) (((m) & S_IFMT) == S_ISWHT)
# else
# define S_ISWHT(m) (0)
# endif
#endif
#ifndef S_IFEVC /* 15 UNOS eventcount */
# ifdef S_IFEVC
# define S_ISEVC(m) (((m) & S_IFMT) == S_IFEVC)
# else
# define S_ISEVC(m) (0)
# endif
#endif
#ifndef S_TYPEISMQ
/*
* XXX ??? where is a definition of a message queue ???
*/
# define S_TYPEISMQ(_stbuf) (0)
#endif
#ifndef S_TYPEISSEM
# ifdef S_INSEM
# define S_TYPEISSEM(_stbuf) (S_ISNAM((_stbuf)->st_mode) && \
(_stbuf)->st_rdev == S_INSEM)
# else
# define S_TYPEISSEM(_stbuf) (0)
# endif
#endif
#ifndef S_TYPEISSHM
# ifdef S_INSHD
# define S_TYPEISSHM(_stbuf) (S_ISNAM((_stbuf)->st_mode) && \
(_stbuf)->st_rdev == S_INSHD)
# else
# define S_TYPEISSHM(_stbuf) (0)
# endif
#endif
/*
* Mode permission bits.
* UNIX V.7 has only S_ISUID/S_ISGID/S_ISVTX and S_IREAD/S_IWRITE/S_IEXEC
*
* S_ISUID/S_ISGID/S_ISVTX is available on UNIX V.7 and POSIX
*/
#ifndef S_ISUID /* Set-user-ID on execution */
#define S_ISUID 0 /* If it is not defined, it is not supported */
#endif
#ifndef S_ISGID /* Set-group-ID on execution */
#define S_ISGID 0 /* If it is not defined, it is not supported */
#endif
#ifndef S_ISVTX /* On directories, restricted deletion flag */
#define S_ISVTX 0 /* If it is not defined, it is not supported */
#endif
/*
* S_IREAD/S_IWRITE/S_IEXEC is only available on UNIX V.7 but not on POSIX
* Emulate these definitions to support compilation of programs like
* SCCS and the Bourne Shell and to make the other definitions simpler.
*/
#ifndef S_IREAD
#ifdef S_IRUSR
#define S_IREAD S_IRUSR /* Use POSIX name */
#else
#define S_IREAD 0400 /* Very old UNIX, use own definition */
#endif
#endif
#ifndef S_IWRITE
#ifdef S_IWUSR
#define S_IWRITE S_IWUSR /* Use POSIX name */
#else
#define S_IWRITE 0200 /* Very old UNIX, use own definition */
#endif
#endif
#ifndef S_IEXEC
#ifdef S_IXUSR
#define S_IEXEC S_IXUSR /* Use POSIX name */
#else
#define S_IEXEC 0100 /* Very old UNIX, use own definition */
#endif
#endif
#ifndef S_IRUSR /* Read permission, owner */
#define S_IRUSR S_IREAD /* Needed on old UNIX systems */
#endif
#ifndef S_IWUSR /* Write permission, owner */
#define S_IWUSR S_IWRITE /* Needed on old UNIX systems */
#endif
#ifndef S_IXUSR /* Execute/search permission, owner */
#define S_IXUSR S_IEXEC /* Needed on old UNIX systems */
#endif
#ifndef S_IRGRP /* Read permission, group */
#define S_IRGRP (S_IREAD >> 3) /* Needed on old UNIX systems */
#endif
#ifndef S_IWGRP /* Write permission, group */
#define S_IWGRP (S_IWRITE >> 3) /* Needed on old UNIX systems */
#endif
#ifndef S_IXGRP /* Execute/search permission, group */
#define S_IXGRP (S_IEXEC >> 3) /* Needed on old UNIX systems */
#endif
#ifndef S_IROTH /* Read permission, others */
#define S_IROTH (S_IREAD >> 6) /* Needed on old UNIX systems */
#endif
#ifndef S_IWOTH /* Write permission, others */
#define S_IWOTH (S_IWRITE >> 6) /* Needed on old UNIX systems */
#endif
#ifndef S_IXOTH /* Execute/search permission, others */
#define S_IXOTH (S_IEXEC >> 6) /* Needed on old UNIX systems */
#endif
#ifndef S_IRWXU /* Read, write, execute/search by owner */
#define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
#endif
#ifndef S_IRWXG /* Read, write, execute/search by group */
#define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
#endif
#ifndef S_IRWXO /* Read, write, execute/search by others */
#define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
#endif
/*
* SCO UnixWare has st_atim.st__tim.tv_nsec but the st_atim.tv_nsec tests also
* succeeds. If we use st_atim.tv_nsec on UnixWare, we get a warning about
* illegal structure usage. For this reason, our code needs to have
* #ifdef HAVE_ST__TIM before #ifdef HAVE_ST_NSEC.
*/
#if defined(HAVE_ST_ATIMENSEC)
/*
* Found e.g. on NetBSD and OpenBSD.
*/
#define stat_ansecs(s) ((s)->st_atimensec)
#define stat_mnsecs(s) ((s)->st_mtimensec)
#define stat_cnsecs(s) ((s)->st_ctimensec)
#define stat_set_ansecs(s, n) ((s)->st_atimensec = n)
#define stat_set_mnsecs(s, n) ((s)->st_mtimensec = n)
#define stat_set_cnsecs(s, n) ((s)->st_ctimensec = n)
#define _FOUND_STAT_NSECS_
#endif
#if defined(HAVE_ST_ATIME_N)
/*
* Found e.g. on AIX.
*/
#define stat_ansecs(s) ((s)->st_atime_n)
#define stat_mnsecs(s) ((s)->st_mtime_n)
#define stat_cnsecs(s) ((s)->st_ctime_n)
#define stat_set_ansecs(s, n) ((s)->st_atime_n = n)
#define stat_set_mnsecs(s, n) ((s)->st_mtime_n = n)
#define stat_set_cnsecs(s, n) ((s)->st_ctime_n = n)
#define _FOUND_STAT_NSECS_
#endif
#if defined(HAVE_ST__TIM) && !defined(_FOUND_STAT_NSECS_)
/*
* Found e.g. on UnixWare.
*/
#define stat_ansecs(s) ((s)->st_atim.st__tim.tv_nsec)
#define stat_mnsecs(s) ((s)->st_mtim.st__tim.tv_nsec)
#define stat_cnsecs(s) ((s)->st_ctim.st__tim.tv_nsec)
#define stat_set_ansecs(s, n) ((s)->st_atim.st__tim.tv_nsec = n)
#define stat_set_mnsecs(s, n) ((s)->st_mtim.st__tim.tv_nsec = n)
#define stat_set_cnsecs(s, n) ((s)->st_ctim.st__tim.tv_nsec = n)
#define _FOUND_STAT_NSECS_
#endif
#if defined(HAVE_ST_NSEC) && !defined(_FOUND_STAT_NSECS_)
/*
* Found e.g. on SunOS-5.x and IRIX.
*/
#define stat_ansecs(s) ((s)->st_atim.tv_nsec)
#define stat_mnsecs(s) ((s)->st_mtim.tv_nsec)
#define stat_cnsecs(s) ((s)->st_ctim.tv_nsec)
#define stat_set_ansecs(s, n) ((s)->st_atim.tv_nsec = n)
#define stat_set_mnsecs(s, n) ((s)->st_mtim.tv_nsec = n)
#define stat_set_cnsecs(s, n) ((s)->st_ctim.tv_nsec = n)
#define _FOUND_STAT_NSECS_
#endif
#if defined(HAVE_ST_ATIMESPEC) && !defined(_FOUND_STAT_NSECS_)
/*
* Found e.g. on FreeBSD and Mac OS X.
*/
#define stat_ansecs(s) ((s)->st_atimespec.tv_nsec)
#define stat_mnsecs(s) ((s)->st_mtimespec.tv_nsec)
#define stat_cnsecs(s) ((s)->st_ctimespec.tv_nsec)
#define stat_set_ansecs(s, n) ((s)->st_atimespec.tv_nsec = n)
#define stat_set_mnsecs(s, n) ((s)->st_mtimespec.tv_nsec = n)
#define stat_set_cnsecs(s, n) ((s)->st_ctimespec.tv_nsec = n)
#define _FOUND_STAT_NSECS_
#endif
/*
* st_spare1 is last as some implementations keep backwards
* compatibility although there is one of the nsec implementations.
*/
#if defined(HAVE_ST_SPARE1) && !defined(_FOUND_STAT_NSECS_)
/*
* Found e.g. on SunOS-4.x and HP-UX.
*/
#define stat_ansecs(s) ((s)->st_spare1 * 1000)
#define stat_mnsecs(s) ((s)->st_spare2 * 1000)
#define stat_cnsecs(s) ((s)->st_spare3 * 1000)
#define stat_set_ansecs(s, n) ((s)->st_spare1 = n / 1000)
#define stat_set_mnsecs(s, n) ((s)->st_spare2 = n / 1000)
#define stat_set_cnsecs(s, n) ((s)->st_spare3 = n / 1000)
#define _FOUND_STAT_USECS_
#define _FOUND_STAT_NSECS_
#endif
#if !defined(_FOUND_STAT_NSECS_)
#define stat_ansecs(s) (0)
#define stat_mnsecs(s) (0)
#define stat_cnsecs(s) (0)
#define stat_set_ansecs(s, n) (0)
#define stat_set_mnsecs(s, n) (0)
#define stat_set_cnsecs(s, n) (0)
#endif
#endif /* _SCHILY_STAT_H */
@@ -0,0 +1,488 @@
/* @(#)stdint.h 1.37 15/12/10 Copyright 1997-2015 J. Schilling */
/*
* Abstraction from stdint.h
*
* Copyright (c) 1997-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_STDINT_H
#define _SCHILY_STDINT_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
/*
* Let us include system defined types too.
*/
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
/*
* Include sys/param.h for NBBY - needed in case that CHAR_BIT is missing
*/
#ifndef _SCHILY_PARAM_H
#include <schily/param.h> /* Must be before limits.h */
#endif
/*
* Include limits.h for CHAR_BIT - needed by TYPE_MINVAL(t) and TYPE_MAXVAL(t)
*/
#ifndef _SCHILY_LIMITS_H
#include <schily/limits.h>
#endif
#ifndef CHAR_BIT
#ifdef NBBY
#define CHAR_BIT NBBY
#endif
#endif
/*
* Last resort: define CHAR_BIT by hand
*/
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
/*
* These macros may not work on all platforms but as we depend
* on two's complement in many places, they do not reduce portability.
* The macros below work with 2s complement and ones complement machines.
* Verify with this table...
*
* Bits 1's c. 2's complement.
* 100 -3 -4
* 101 -2 -3
* 110 -1 -2
* 111 -0 -1
* 000 +0 0
* 001 +1 +1
* 010 +2 +2
* 011 +3 +3
*
* Computing -TYPE_MINVAL(type) will not work on 2's complement machines
* if 'type' is int or more. Use:
* ((unsigned type)(-1 * (TYPE_MINVAL(type)+1))) + 1;
* it works for both 1's complement and 2's complement machines.
*/
#define TYPE_ISSIGNED(t) (((t)-1) < ((t)0))
#define TYPE_ISUNSIGNED(t) (!TYPE_ISSIGNED(t))
#define TYPE_MSBVAL(t) ((t)(~((t)0) << (sizeof (t)*CHAR_BIT - 1)))
#define TYPE_MINVAL(t) (TYPE_ISSIGNED(t) \
? TYPE_MSBVAL(t) \
: ((t)0))
#define TYPE_MAXVAL(t) ((t)(~((t)0) - TYPE_MINVAL(t)))
/*
* MSVC has size_t in stddef.h
*/
#ifdef HAVE_STDDEF_H
#ifndef _INCL_STDDEF_H
#include <stddef.h>
#define _INCL_STDDEF_H
#endif
#endif
/*
* CHAR_IS_UNSIGNED is needed to define int8_t
*/
#ifdef __CHAR_UNSIGNED__ /* GNU GCC define (dynamic) */
#ifndef CHAR_IS_UNSIGNED
#define CHAR_IS_UNSIGNED /* Sing Schily define (static) */
#endif
#endif
/*
* This is a definition for a compiler dependant 64 bit type.
* There is currently a silently fallback to a long if the compiler does not
* support it. Check if this is the right way.
*
* Be very careful here as MSVC does not implement long long but rather __int64
* and once someone makes 'long long' 128 bits on a 64 bit machine, we need to
* check for a MSVC __int128 type.
*/
#ifndef NO_LONGLONG
# if !defined(USE_LONGLONG) && defined(HAVE_LONGLONG)
# define USE_LONGLONG
# endif
# if !defined(USE_LONGLONG) && defined(HAVE___INT64)
# define USE_LONGLONG
# endif
#endif
#ifdef USE_LONGLONG
# if defined(HAVE___INT64)
typedef __int64 Llong;
typedef unsigned __int64 Ullong; /* We should avoid this */
typedef unsigned __int64 ULlong;
#define SIZEOF_LLONG SIZEOF___INT64
#define SIZEOF_ULLONG SIZEOF_UNSIGNED___INT64
# else /* We must have HAVE_LONG_LONG */
typedef long long Llong;
typedef unsigned long long Ullong; /* We should avoid this */
typedef unsigned long long ULlong;
#define SIZEOF_LLONG SIZEOF_LONG_LONG
#define SIZEOF_ULLONG SIZEOF_UNSIGNED_LONG_LONG
# endif /* HAVE___INT64 / HAVE_LONG_LONG */
#else /* !USE_LONGLONG */
typedef long Llong;
typedef unsigned long Ullong; /* We should avoid this */
typedef unsigned long ULlong;
#define SIZEOF_LLONG SIZEOF_LONG
#define SIZEOF_ULLONG SIZEOF_UNSIGNED_LONG
#endif /* USE_LONGLONG */
#ifndef LLONG_MIN
#define LLONG_MIN TYPE_MINVAL(Llong)
#endif
#ifndef LLONG_MAX
#define LLONG_MAX TYPE_MAXVAL(Llong)
#endif
#ifndef ULLONG_MAX
#define ULLONG_MAX TYPE_MAXVAL(Ullong)
#endif
/*
* Start inttypes.h emulation.
*
* Thanks to Solaris 2.4 and even recent 1999 Linux versions, we
* cannot use the official UNIX-98 names here. Old Solaris versions
* define parts of the types in some exotic include files.
* Linux even defines incompatible types in <sys/types.h>.
*/
#if defined(HAVE_INTTYPES_H) || defined(HAVE_STDINT_H)
#if defined(HAVE_INTTYPES_H)
# ifndef _INCL_INTTYPES_H
# include <inttypes.h>
# define _INCL_INTTYPES_H
# endif
#else
#if defined(HAVE_STDINT_H)
# ifndef _INCL_STDINT_H
# include <stdint.h>
# define _INCL_STDINT_H
# endif
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* On VMS on VAX, these types are present but non-scalar.
* Thus we may not be able to use them
*/
#ifdef HAVE_LONGLONG
# define HAVE_INT64_T
# define HAVE_UINT64_T
#endif
#define Int8_t int8_t
#define Int16_t int16_t
#define Int32_t int32_t
#ifdef HAVE_LONGLONG
#define Int64_t int64_t
#endif
#define Intmax_t intmax_t
#define UInt8_t uint8_t
#define UInt16_t uint16_t
#define UInt32_t uint32_t
#ifdef HAVE_LONGLONG
#define UInt64_t uint64_t
#endif
#define UIntmax_t uintmax_t
#define Intptr_t intptr_t
#define UIntptr_t uintptr_t
/*
* If we only have a UNIX-98 inttypes.h but no SUSv3
*
* Beware not to use int64_t / uint64_t as VMS on a VAX defines
* them as non-scalar (structure) based types.
*/
#ifndef HAVE_TYPE_INTMAX_T
#define intmax_t Llong
#endif
#ifndef HAVE_TYPE_UINTMAX_T
#define uintmax_t ULlong
#endif
#ifdef __cplusplus
}
#endif
#else /* !HAVE_INTTYPES_H */
#ifdef __cplusplus
extern "C" {
#endif
#if SIZEOF_CHAR != 1 || SIZEOF_UNSIGNED_CHAR != 1
/*
* #error will not work for all compilers (e.g. sunos4)
* The following line will abort compilation on all compilers
* if the above is true. And that's what we want.
*/
error Sizeof char is not equal 1
#include <schily/err_char.h> /* Avoid "unknown directive" with K&R */
#endif
#if defined(__STDC__) || defined(CHAR_IS_UNSIGNED)
typedef signed char Int8_t;
#else
typedef char Int8_t;
#endif
#if SIZEOF_SHORT_INT == 2
typedef short Int16_t;
#else
error No int16_t found
#include <schily/err_type.h> /* Avoid "unknown directive" with K&R */
#endif
#if SIZEOF_INT == 4
#if defined(_MSC_VER) && SIZEOF_LONG_INT == 4
typedef long Int32_t;
#else
typedef int Int32_t;
#endif
#else
error No int32_t found
#include <schily/err_type.h> /* Avoid "unknown directive" with K&R */
#endif
#if SIZEOF_LONG_INT == 8
typedef long Int64_t;
# define HAVE_INT64_T
#else
#if SIZEOF_LONG_LONG == 8
typedef long long Int64_t;
# define HAVE_INT64_T
#else
#if SIZEOF___INT64 == 8
typedef __int64 Int64_t;
# define HAVE_INT64_T
#else
/*
* Tolerate platforms without 64-Bit support.
*/
/* error No int64_t found */
#endif
#endif
#endif
#if SIZEOF_CHAR_P == SIZEOF_INT
typedef int Intptr_t;
#else
#if SIZEOF_CHAR_P == SIZEOF_LONG_INT
typedef long Intptr_t;
#else
#if SIZEOF_CHAR_P == SIZEOF_LLONG
typedef Llong Intptr_t;
#else
error No intptr_t found
#include <schily/err_type.h> /* Avoid "unknown directive" with K&R */
#endif
#endif
#endif
typedef unsigned char UInt8_t;
#if SIZEOF_UNSIGNED_SHORT_INT == 2
typedef unsigned short UInt16_t;
#else
error No uint16_t found
#include <schily/err_type.h> /* Avoid "unknown directive" with K&R */
#endif
#if SIZEOF_UNSIGNED_INT == 4
#if defined(_MSC_VER) && SIZEOF_UNSIGNED_LONG_INT == 4
typedef unsigned long UInt32_t;
#else
typedef unsigned int UInt32_t;
#endif
#else
error No int32_t found
#include <schily/err_type.h> /* Avoid "unknown directive" with K&R */
#endif
#if SIZEOF_UNSIGNED_LONG_INT == 8
typedef unsigned long UInt64_t;
# define HAVE_UINT64_T
#else
#if SIZEOF_UNSIGNED_LONG_LONG == 8
typedef unsigned long long UInt64_t;
# define HAVE_UINT64_T
#else
#if SIZEOF_UNSIGNED___INT64 == 8
typedef unsigned __int64 UInt64_t;
# define HAVE_UINT64_T
#else
/*
* Tolerate platforms without 64-Bit support.
*/
/* error No uint64_t found */
#endif
#endif
#endif
#define Intmax_t Llong
#define UIntmax_t Ullong
#if SIZEOF_CHAR_P == SIZEOF_UNSIGNED_INT
typedef unsigned int UIntptr_t;
#else
#if SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG_INT
typedef unsigned long UIntptr_t;
#else
#if SIZEOF_CHAR_P == SIZEOF_ULLONG
typedef ULlong UIntptr_t;
#else
error No uintptr_t found
#include <schily/err_type.h> /* Avoid "unknown directive" with K&R */
#endif
#endif
#endif
#ifdef _MSC_VER
/*
* All recent platforms define the POSIX/C-99 compliant types from inttypes.h
* except Microsoft. With these #defines, we may also use official types on a
* Microsoft environment.
*
* Warning: Linux-2.2 and before do not have inttypes.h and define some of the
* types in an incmpatible way.
*/
#undef int8_t
#define int8_t Int8_t
#undef int16_t
#define int16_t Int16_t
#undef int32_t
#define int32_t Int32_t
#undef int64_t
#define int64_t Int64_t
#undef intmax_t
#define intmax_t Intmax_t
#undef uint8_t
#define uint8_t UInt8_t
#undef uint16_t
#define uint16_t UInt16_t
#undef uint32_t
#define uint32_t UInt32_t
#undef uint64_t
#define uint64_t UInt64_t
#undef uintmax_t
#define uintmax_t UIntmax_t
#undef intptr_t
#define intptr_t Intptr_t
#undef uintptr_t
#define uintptr_t UIntptr_t
#endif /* _MSC_VER */
#ifdef __cplusplus
}
#endif
#endif /* HAVE_INTTYPES_H */
#ifndef INT8_MIN
#define INT8_MIN TYPE_MINVAL(Int8_t)
#endif
#ifndef INT8_MAX
#define INT8_MAX TYPE_MAXVAL(Int8_t)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX TYPE_MAXVAL(UInt8_t)
#endif
#ifndef INT16_MIN
#define INT16_MIN TYPE_MINVAL(Int16_t)
#endif
#ifndef INT16_MAX
#define INT16_MAX TYPE_MAXVAL(Int16_t)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX TYPE_MAXVAL(UInt16_t)
#endif
#ifndef INT32_MIN
#define INT32_MIN TYPE_MINVAL(Int32_t)
#endif
#ifndef INT32_MAX
#define INT32_MAX TYPE_MAXVAL(Int32_t)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX TYPE_MAXVAL(UInt32_t)
#endif
#ifdef HAVE_INT64_T
#ifndef INT64_MIN
#define INT64_MIN TYPE_MINVAL(Int64_t)
#endif
#ifndef INT64_MAX
#define INT64_MAX TYPE_MAXVAL(Int64_t)
#endif
#endif
#ifdef HAVE_UINT64_T
#ifndef UINT64_MAX
#define UINT64_MAX TYPE_MAXVAL(UInt64_t)
#endif
#endif
#ifndef INTMAX_MIN
#define INTMAX_MIN TYPE_MINVAL(Intmax_t)
#endif
#ifndef INTMAX_MAX
#define INTMAX_MAX TYPE_MAXVAL(Intmax_t)
#endif
#ifndef UINTMAX_MAX
#define UINTMAX_MAX TYPE_MAXVAL(UIntmax_t)
#endif
#define SIZE_T_MIN TYPE_MINVAL(size_t)
#ifdef SIZE_T_MAX
#undef SIZE_T_MAX /* FreeBSD has a similar #define */
#endif
#define SIZE_T_MAX TYPE_MAXVAL(size_t)
#define SSIZE_T_MIN TYPE_MINVAL(ssize_t)
#define SSIZE_T_MAX TYPE_MAXVAL(ssize_t)
#endif /* _SCHILY_STDINT_H */
@@ -0,0 +1,124 @@
/* @(#)stdio.h 1.12 16/09/11 Copyright 2009-2016 J. Schilling */
/*
* Abstraction from stdio.h
*
* Copyright (c) 2009-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_STDIO_H
#define _SCHILY_STDIO_H
#ifndef NO_SCHILY_STDIO_H /* We #undef _SCHILY_STDIO_H later because */
/* of the ill designed "hdrchk" program */
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef INCL_MYSTDIO
#ifndef _INCL_MYSTDIO_H
#include <mystdio.h>
#define _INCL_MYSTDIO_H
#endif
#else /* INCL_MYSTDIO */
#ifndef _INCL_STDIO_H
#include <stdio.h>
#define _INCL_STDIO_H
#endif
#endif /* INCL_MYSTDIO */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_LARGEFILES
/*
* If HAVE_LARGEFILES is defined, it is guaranteed that fseeko()/ftello()
* both are available.
*/
#define fseek fseeko
#define ftell ftello
#else /* !HAVE_LARGEFILES */
/*
* If HAVE_LARGEFILES is not defined, we depend on specific tests for
* fseeko()/ftello() which must have been done before the tests for
* Large File support have been done.
* Note that this only works if the tests used below are really done before
* the Large File autoconf test is run. This is because autoconf does no
* clean testing but instead cumulatively modifes the envivonment used for
* testing.
*/
#ifdef HAVE_FSEEKO
# define fseek fseeko
#endif
#ifdef HAVE_FTELLO
# define ftell ftello
#endif
#endif
#if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
#define popen(c, m) _popen((c), (m))
#endif
#if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
#define pclose(fp) _pclose(fp)
#endif
#ifdef FAST_GETC_PUTC
/*
* The following code partially allows libschily to access FILE * as fast as
* from inside libc on Solaris.
* This makes it possible to implement js_printf() from libschily aprox.
* 33% faster than printf() from libc on Solaris. To do this, we
* partially unhide the FILE structure in a 64 bit environment on Solaris
* to allow to run putc_unlocked() as a marcro.
*
* If you believe you can do this on onther platforms, send a note.
*/
#if defined(__SVR4) && defined(__sun) && defined(_LP64)
/*
* This is how the 64 bit FILE * begins on Solaris.
*/
struct SCHILY__FILE_TAG {
unsigned char *_ptr; /* next character from/to here in buffer */
unsigned char *_base; /* the buffer */
unsigned char *_end; /* the end of the buffer */
ssize_t _cnt; /* number of available characters in buffer */
};
#define __putc_unlocked(x, p) (--(p)->_cnt < 0 \
? __flsbuf((x), (FILE *)(p)) \
: (int)(*(p)->_ptr++ = \
(unsigned char) (x)))
#define putc_unlocked(x, p) __putc_unlocked(x, (struct SCHILY__FILE_TAG *)p)
extern int __flsbuf __PR((int, FILE *));
#endif /* defined(__SVR4) && defined(__sun) && defined(_LP64) */
#endif /* FAST_GETC_PUTC */
#ifdef __cplusplus
}
#endif
#else /* !NO_SCHILY_STDIO_H */
#undef _SCHILY_STDIO_H /* #undef here to pass "hdrchk" */
#endif /* NO_SCHILY_STDIO_H */
#endif /* _SCHILY_STDIO_H */
@@ -0,0 +1,72 @@
/* @(#)stdlib.h 1.11 15/11/28 Copyright 1996-2015 J. Schilling */
/*
* Definitions for stdlib
*
* Copyright (c) 1996-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_STDLIB_H
#define _SCHILY_STDLIB_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_STDLIB_H
#ifndef _INCL_STDLIB_H
#include <stdlib.h>
#define _INCL_STDLIB_H
#endif
#endif /* HAVE_STDLIB_H */
#ifdef HAVE_POSIX_MALLOC_H /* Haiku */
#ifndef _INCL_POSIX_MALLOC_H
#include <posix/malloc.h>
#define _INCL_POSIX_MALLOC_H
#endif
#endif /* HAVE_POSIX_MALLOC_H */
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(_INCL_STDLIB_H) && !defined(_INCL_POSIX_MALLOC_H)
extern char *malloc();
extern char *realloc();
#endif
#ifndef _INCL_STDLIB_H
extern double atof();
#endif
#ifdef __cplusplus
}
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef RAND_MAX
#define RAND_MAX 32767
#endif
#endif /* _SCHILY_STDLIB_H */
@@ -0,0 +1,108 @@
/* @(#)string.h 1.12 11/11/24 Copyright 1996-2011 J. Schilling */
/*
* Definitions for strings
*
* Copyright (c) 1996-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_STRING_H
#define _SCHILY_STRING_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h> /* Try to get size_t */
#endif
/*
* It may be that IBM's AIX has problems when doing
* #include <string.h>
* #include <strings.h>
* So I moved the #include <strings.h> to the top. As the file strings.h
* defines strcasecmp() we may need it...
*
* Note that the only real problem appears if we use rubbish FSF based code that
* #defines _NO_PROTO
*/
#ifdef HAVE_STRINGS_H
#ifndef _INCL_STRINGS_H
#include <strings.h>
#define _INCL_STRINGS_H
#endif
#endif /* HAVE_STRINGS_H */
#ifdef HAVE_STRING_H
#ifndef _INCL_STRING_H
#include <string.h>
#define _INCL_STRING_H
#endif
#else /* HAVE_STRING_H */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
#define NULL 0
#endif
extern void *memcpy __PR((void *, const void *, int));
extern void *memmove __PR((void *, const void *, int));
extern char *strcpy __PR((char *, const char *));
extern char *strncpy __PR((char *, const char *, int));
extern char *strcat __PR((char *, const char *));
extern char *strncat __PR((char *, const char *, int));
extern int memcmp __PR((const void *, const void *, int));
extern int strcmp __PR((const char *, const char *));
extern int strcoll __PR((const char *, const char *));
extern int strncmp __PR((const char *, const char *, int));
extern int strxfrm __PR((char *, const char *, int));
extern void *memchr __PR((const void *, int, int));
extern char *strchr __PR((const char *, int));
extern int strcspn __PR((const char *, const char *));
/* #pragma int_to_unsigned strcspn */
extern char *strpbrk __PR((const char *, const char *));
extern char *strrchr __PR((const char *, int));
extern int strspn __PR((const char *, const char *));
/* #pragma int_to_unsigned strspn */
extern char *strstr __PR((const char *, const char *));
extern char *strtok __PR((char *, const char *));
extern void *memset __PR((void *, int, int));
extern char *strerror __PR((int));
extern int strlen __PR((const char *));
/* #pragma int_to_unsigned strlen */
extern void *memccpy __PR((void *, const void *, int, int));
extern int strcasecmp __PR((const char *, const char *));
extern int strncasecmp __PR((const char *, const char *, size_t));
#ifdef __cplusplus
}
#endif
#endif /* HAVE_STRING_H */
#endif /* _SCHILY_STRING_H */
@@ -0,0 +1,164 @@
/* @(#)time.h 1.20 13/10/01 Copyright 1996-2013 J. Schilling */
/*
* Generic header for users of time(), gettimeofday() ...
*
* It includes definitions for time_t, struct timeval, ...
*
* Copyright (c) 1996-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_TIME_H
#define _SCHILY_TIME_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h> /* Needed for time_t */
#endif
#ifdef TIME_WITH_SYS_TIME
# ifndef _INCL_SYS_TIME_H
# include <sys/time.h>
# define _INCL_SYS_TIME_H
# endif
# ifndef _INCL_TIME_H
# include <time.h>
# define _INCL_TIME_H
# endif
#else
#ifdef HAVE_SYS_TIME_H
# ifndef _INCL_SYS_TIME_H
# include <sys/time.h>
# define _INCL_SYS_TIME_H
# endif
#else
# ifndef _INCL_TIME_H
# include <time.h>
# define _INCL_TIME_H
# endif
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef timerclear
/*
* With MSVC timerclear / struct timeval present in case that
* winsock2.h has been included before.
*/
#undef HAVE_STRUCT_TIMEVAL
#define HAVE_STRUCT_TIMEVAL 1
#endif
#ifndef HAVE_STRUCT_TIMEVAL
struct timeval {
long tv_sec;
long tv_usec;
};
#endif
#ifndef HAVE_STRUCT_TIMEZONE
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#endif
#ifndef HAVE_STRUCT_TIMESPEC
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif
#undef timerclear
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
#undef timerfix
#define timerfix1(tvp) while ((tvp)->tv_usec < 0) { \
(tvp)->tv_sec--; \
(tvp)->tv_usec += 1000000; \
}
#define timerfix2(tvp) while ((tvp)->tv_usec > 1000000) { \
(tvp)->tv_sec++; \
(tvp)->tv_usec -= 1000000; \
}
#define timerfix(tvp) do { timerfix1(tvp); timerfix2(tvp); } while (0)
/*
* timersub() and timeradd() are defined on FreeBSD with a different
* interface (3 parameters).
*/
#undef timersub
#define timersub(tvp1, tvp2) do { \
(tvp1)->tv_sec -= (tvp2)->tv_sec; \
(tvp1)->tv_usec -= (tvp2)->tv_usec; \
timerfix1(tvp1); timerfix2(tvp1); \
} while (0)
#undef timeradd
#define timeradd(tvp1, tvp2) do { \
(tvp1)->tv_sec += (tvp2)->tv_sec; \
(tvp1)->tv_usec += (tvp2)->tv_usec; \
timerfix1(tvp1); timerfix2(tvp1); \
} while (0)
#undef timespecclear
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
#undef timespecfix
#define timespecfix1(tsp) while ((tsp)->tv_nsec < 0) { \
(tsp)->tv_sec--; \
(tsp)->tv_nsec += 1000000000; \
}
#define timespecfix2(tsp) while ((tsp)->tv_nsec > 1000000000) { \
(tsp)->tv_sec++; \
(tsp)->tv_nsec -= 1000000000; \
}
#define timespecfix(tsp) do { timespecfix1(tsp); timespecfix2(tsp); } while (0)
#undef timespecsub
#define timespecsub(tsp1, tsp2) do { \
(tsp1)->tv_sec -= (tsp2)->tv_sec; \
(tsp1)->tv_nsec -= (tsp2)->tv_nsec; \
timespecfix1(tsp1); timespecfix2(tsp1); \
} while (0)
#undef timespecadd
#define timespecadd(tsp1, tsp2) do { \
(tsp1)->tv_sec += (tsp2)->tv_sec; \
(tsp1)->tv_nsec += (tsp2)->tv_nsec; \
timespecfix1(tsp1); timespecfix2(tsp1); \
} while (0)
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_TIME_H */
@@ -0,0 +1,47 @@
/* @(#)types.h 1.5 09/10/22 Copyright 2006-2009 J. Schilling */
/*
* Abstraction from sys/types.h
*
* Copyright (c) 2006-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_TYPES_H
#define _SCHILY_TYPES_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#ifndef _INCL_SYS_TYPES_H
#include <sys/types.h>
#define _INCL_SYS_TYPES_H
#endif
#else
#ifdef HAVE_TYPES_H
#ifndef _INCL_TYPES_H
#include <types.h>
#define _INCL_TYPES_H
#endif
#endif
#endif
#ifdef HAVE_STDDEF_H
#ifndef _INCL_STDDEF_H
#include <stddef.h> /* For offsetof(), ptrdiff_t, wchar_t, size_t */
#define _INCL_STDDEF_H
#endif
#endif
#endif /* _SCHILY_TYPES_H */
@@ -0,0 +1,183 @@
/* @(#)unistd.h 1.27 14/06/19 Copyright 1996-2014 J. Schilling */
/*
* Definitions for unix system interface
*
* Copyright (c) 1996-2014 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_UNISTD_H
#define _SCHILY_UNISTD_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
/*
* unistd.h grants things like off_t to be typedef'd.
*/
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
/*
* inttypes.h grants things like Intptr_t to be typedef'd.
*/
#ifndef _SCHILY_INTTYPES_H
#include <schily/inttypes.h>
#endif
#ifdef HAVE_UNISTD_H
#ifndef _INCL_UNISTD_H
#include <unistd.h>
#define _INCL_UNISTD_H
#endif
#ifndef _SC_PAGESIZE
#ifdef _SC_PAGE_SIZE /* HP/UX & OSF */
#define _SC_PAGESIZE _SC_PAGE_SIZE
#endif
#endif
#else /* !HAVE_UNISTD_H */
#ifndef _SCHILY_STDLIB_H
#include <schily/stdlib.h> /* MSVC: no unistd.h environ is in stdlib.h */
#endif
#endif /* !HAVE_UNISTD_H */
/*
* MSVC has getcwd()/chdir()/mkdir()/rmdir() in direct.h
*/
#if defined(_MSC_VER) && defined(HAVE_DIRECT_H)
#ifndef _INCL_DIRECT_H
#include <direct.h>
#define _INCL_DIRECT_H
#endif
#endif
/*
* MSVC has size_t in stddef.h
*/
#ifdef HAVE_STDDEF_H
#ifndef _INCL_STDDEF_H
#include <stddef.h>
#define _INCL_STDDEF_H
#endif
#endif
#ifndef STDIN_FILENO
# ifdef JOS
# ifndef _SCHILY_JOS_IO_H
# include <schily/jos_io.h>
# endif
# else
# define STDIN_FILENO 0
# define STDOUT_FILENO 1
# define STDERR_FILENO 2
# endif
#endif
#ifndef R_OK
/* Symbolic constants for the "access" routine: */
#define R_OK 4 /* Test for Read permission */
#define W_OK 2 /* Test for Write permission */
#define X_OK 1 /* Test for eXecute permission */
#define F_OK 0 /* Test for existence of File */
#endif
#ifndef E_OK
#ifdef HAVE_ACCESS_E_OK
#ifdef EFF_ONLY_OK
#define E_OK EFF_ONLY_OK /* Irix */
#else
#ifdef EUID_OK
#define E_OK EUID_OK /* UNICOS (0400) */
#else
#define E_OK 010 /* Test effective uids */
#endif /* EUID_OK */
#endif /* EFF_ONLY_OK */
#else
#define E_OK 0
#endif /* HAVE_ACCESS_E_OK */
#endif /* !E_OK */
/* Symbolic constants for the "lseek" routine: */
#ifndef SEEK_SET
#define SEEK_SET 0 /* Set file pointer to "offset" */
#endif
#ifndef SEEK_CUR
#define SEEK_CUR 1 /* Set file pointer to current plus "offset" */
#endif
#ifndef SEEK_END
#define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef HAVE_ENVIRON_DEF
extern char **environ;
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(HAVE_UNISTD_H) || !defined(_POSIX_VERSION)
/*
* Maybe we need a lot more definitions here...
* It is not clear whether we should have prototyped definitions.
*/
#if !defined(_MSC_VER) && !defined(__MINGW32__)
/*
* MS C comes with broken prototypes in wrong header files (in our case, the
* wrong prototype is in io.h). Avoid to redefine the broken MS stuff with
* correct prototypes.
*/
extern int access __PR((const char *, int));
extern int close __PR((int));
extern int dup __PR((int));
extern int dup2 __PR((int, int));
extern int link __PR((const char *, const char *));
extern int read __PR((int, void *, size_t));
extern int unlink __PR((const char *));
extern int write __PR((int, const void *, size_t));
#endif
#if !defined(_MSC_VER) && !defined(__MINGW32__)
/*
* MS C comes with broken prototypes in wrong header files (in our case, the
* wrong prototype is in stdlib.h). Avoid to redefine the broken MS stuff with
* correct prototypes.
*/
extern void _exit __PR((int));
#endif
#endif
#if !defined(HAVE_PIPE) && defined(HAVE__PIPE) && defined(HAVE_IO_H)
#ifndef _SCHILY_LIMITS_H
#include <schily/limits.h> /* for PIPE_BUF */
#endif
#ifndef _SCHILY_FCNTL_H
#include <schily/fcntl.h> /* for O_BINARY */
#endif
#ifndef _SCHILY_IO_H
#include <schily/io.h> /* for _pipe() */
#endif
#define pipe(pp) _pipe(pp, PIPE_BUF, O_BINARY)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_UNISTD_H */
@@ -0,0 +1,158 @@
/* @(#)utypes.h 1.36 13/09/14 Copyright 1997-2013 J. Schilling */
/*
* Definitions for some user defined types
*
* Copyright (c) 1997-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_UTYPES_H
#define _SCHILY_UTYPES_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
/*
* uypes.h is based on inttypes.h
*/
#ifndef _SCHILY_INTTYPES_H
#include <schily/inttypes.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Several unsigned cardinal types
*/
typedef unsigned long Ulong;
typedef unsigned int Uint;
typedef unsigned short Ushort;
typedef unsigned char Uchar;
/*
* The IBM AIX C-compiler seems to be the only compiler on the world
* which does not allow to use unsigned char bit fields as a hint
* for packed bit fields. Define a pesical type to avoid warnings.
* The packed attribute is honored wit unsigned int in this case too.
*/
#if defined(_AIX) && !defined(__GNUC__)
typedef unsigned int Ucbit;
#else
typedef unsigned char Ucbit;
#endif
#ifndef CHAR_MIN
#define CHAR_MIN TYPE_MINVAL(char)
#endif
#ifndef CHAR_MAX
#define CHAR_MAX TYPE_MAXVAL(char)
#endif
#ifndef UCHAR_MAX
#define UCHAR_MAX TYPE_MAXVAL(unsigned char)
#endif
#ifndef SHRT_MIN
#define SHRT_MIN TYPE_MINVAL(short)
#endif
#ifndef SHRT_MAX
#define SHRT_MAX TYPE_MAXVAL(short)
#endif
#ifndef USHRT_MAX
#define USHRT_MAX TYPE_MAXVAL(unsigned short)
#endif
#ifndef INT_MIN
#define INT_MIN TYPE_MINVAL(int)
#endif
#ifndef INT_MAX
#define INT_MAX TYPE_MAXVAL(int)
#endif
#ifndef UINT_MAX
#define UINT_MAX TYPE_MAXVAL(unsigned int)
#endif
#ifndef LONG_MIN
#define LONG_MIN TYPE_MINVAL(long)
#endif
#ifndef LONG_MAX
#define LONG_MAX TYPE_MAXVAL(long)
#endif
#ifndef ULONG_MAX
#define ULONG_MAX TYPE_MAXVAL(unsigned long)
#endif
#define OFF_T_MIN TYPE_MINVAL(off_t)
#define OFF_T_MAX TYPE_MAXVAL(off_t)
#define UID_T_MIN TYPE_MINVAL(uid_t)
#define UID_T_MAX TYPE_MAXVAL(uid_t)
#define GID_T_MIN TYPE_MINVAL(gid_t)
#define GID_T_MAX TYPE_MAXVAL(gid_t)
#define PID_T_MIN TYPE_MINVAL(pid_t)
#define PID_T_MAX TYPE_MAXVAL(pid_t)
#define MODE_T_MIN TYPE_MINVAL(mode_t)
#define MODE_T_MAX TYPE_MAXVAL(mode_t)
#define TIME_T_MIN TYPE_MINVAL(time_t)
#define TIME_T_MAX TYPE_MAXVAL(time_t)
#define CADDR_T_MIN TYPE_MINVAL(caddr_t)
#define CADDR_T_MAX TYPE_MAXVAL(caddr_t)
#define DADDR_T_MIN TYPE_MINVAL(daddr_t)
#define DADDR_T_MAX TYPE_MAXVAL(daddr_t)
#define DEV_T_MIN TYPE_MINVAL(dev_t)
#define DEV_T_MAX TYPE_MAXVAL(dev_t)
#define MAJOR_T_MIN TYPE_MINVAL(major_t)
#define MAJOR_T_MAX TYPE_MAXVAL(major_t)
#define MINOR_T_MIN TYPE_MINVAL(minor_t)
#define MINOR_T_MAX TYPE_MAXVAL(minor_t)
#define INO_T_MIN TYPE_MINVAL(ino_t)
#define INO_T_MAX TYPE_MAXVAL(ino_t)
#define NLINK_T_MIN TYPE_MINVAL(nlink_t)
#define NLINK_T_MAX TYPE_MAXVAL(nlink_t)
#define BLKSIZE_T_MIN TYPE_MINVAL(blksize_t)
#define BLKSIZE_T_MAX TYPE_MAXVAL(blksize_t)
#define BLKCNT_T_MIN TYPE_MINVAL(blkcnt_t)
#define BLKCNT_T_MAX TYPE_MAXVAL(blkcnt_t)
#define CLOCK_T_MIN TYPE_MINVAL(clock_t)
#define CLOCK_T_MAX TYPE_MAXVAL(clock_t)
#define SOCKLEN_T_MIN TYPE_MINVAL(socklen_t)
#define SOCKLEN_T_MAX TYPE_MAXVAL(socklen_t)
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_UTYPES_H */
@@ -0,0 +1,140 @@
/* @(#)varargs.h 1.8 14/01/06 Copyright 1998-2014 J. Schilling */
/*
* Generic header for users of var args ...
*
* Includes a default definition for va_copy()
* and some magic know how about the SVr4 Power PC var args ABI
* to create a __va_arg_list() macro.
*
* The __va_arg_list() macro is needed to fetch a va_list type argument
* from a va_list. This is needed to implement a recursive "%r" printf.
*
* Copyright (c) 1998-2014 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_VARARGS_H
#define _SCHILY_VARARGS_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef PROTOTYPES
/*
* For ANSI C-compilers prefer stdarg.h
*/
# ifdef HAVE_STDARG_H
# ifndef _INCL_STDARG_H
# include <stdarg.h>
# define _INCL_STDARG_H
# endif
# else
# ifndef _INCL_VARARGS_H
# include <varargs.h>
# define _INCL_VARARGS_H
# endif
# endif
#else
/*
* For K&R C-compilers prefer varargs.h
*/
# ifdef HAVE_VARARGS_H
# ifndef _INCL_VARARGS_H
# include <varargs.h>
# define _INCL_VARARGS_H
# endif
# else
# ifndef _INCL_STDARG_H
# include <stdarg.h>
# define _INCL_STDARG_H
# endif
# endif
#endif
#if (defined(__linux__) || defined(__linux) || defined(sun)) && \
(defined(__ppc) || defined(__PPC) || \
defined(powerpc) || defined(__powerpc__))
# ifndef VA_LIST_IS_ARRAY
# define VA_LIST_IS_ARRAY
# endif
#endif
/*
* __va_copy() is used by GCC 2.8 or newer until va_copy() becomes
* a final ISO standard.
*/
#if !defined(va_copy) && !defined(HAVE_VA_COPY)
# if defined(__va_copy)
# define va_copy(to, from) __va_copy(to, from)
# endif
#endif
/*
* va_copy() is a Solaris extension to provide a portable way to perform a
* variable argument list "bookmarking" function.
* If it is not available via stdarg.h, use a simple assignement for backward
* compatibility.
*/
#if !defined(va_copy) && !defined(HAVE_VA_COPY)
#ifdef VA_LIST_IS_ARRAY
# define va_copy(to, from) ((to)[0] = (from)[0])
#else
# define va_copy(to, from) ((to) = (from))
#endif
#endif
/*
* I don't know any portable way to get an arbitrary
* C object from a var arg list so I use a
* system-specific routine __va_arg_list() that knows
* if 'va_list' is an array. You will not be able to
* assign the value of __va_arg_list() but it works
* to be used as an argument of a function.
* It is a requirement for recursive printf to be able
* to use this function argument. If your system
* defines va_list to be an array you need to know this
* via autoconf or another mechanism.
* It would be nice to have something like
* __va_arg_list() in stdarg.h
*/
#ifdef VA_LIST_IS_ARRAY
# define __va_arg_list(list) va_arg(list, void *)
#else
# define __va_arg_list(list) va_arg(list, va_list)
#endif
/*
* This structure allows to work around the C limitation that a variable of
* type array cannot appear at the left side of an assignement operator.
* By putting va_list inside a struture, the assignement will work even in case
* that va_list is an array2.
*/
typedef struct {
va_list ap;
} va_lists_t;
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_VARARGS_H */
@@ -0,0 +1,180 @@
/* @(#)wchar.h 1.21 11/07/19 Copyright 2007-2011 J. Schilling */
/*
* Abstraction from wchar.h
*
* Copyright (c) 2007-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_WCHAR_H
#define _SCHILY_WCHAR_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_STDLIB_H
#include <schily/stdlib.h> /* for MB_CUR_MAX, mbtowc()/wctomb() */
#endif
#ifndef _SCHILY_TYPES_H
#include <schily/types.h>
#endif
#ifdef HAVE_STDDEF_H
#ifndef _INCL_STDDEF_H
#include <stddef.h> /* Needed for e.g. size_t (POSIX) */
#define _INCL_STDDEF_H
#endif
#endif
#ifndef _SCHILY_STDIO_H
#include <schily/stdio.h> /* Needed for e.g. FILE (POSIX) */
#endif
#ifndef _SCHILY_VARARGS_H
#include <schily/varargs.h> /* Needed for e.g. va_list (POSIX) */
#endif
#if !defined(HAVE_MBTOWC) || !defined(HAVE_WCTOMB)
#if defined(HAVE_MBRTOWC) && defined(HAVE_WCRTOMB)
# define mbtowc(wp, cp, len) mbrtowc(wp, cp, len, (mbstate_t *)0)
# define wctomb(cp, wc) wcrtomb(cp, wc, (mbstate_t *)0)
#else
# define NO_WCHAR
#endif
#endif
#ifdef HAVE_WCHAR_H
#ifndef _INCL_WCHAR_H
#include <wchar.h>
#define _INCL_WCHAR_H
#endif
#ifndef HAVE_MBSINIT
#define mbsinit(sp) ((int)((sp) == 0))
#endif
#ifndef HAVE_MBRTOWC
#define mbrtowc(wp, cp, len, sp) mbtowc(wp, cp, len)
#endif
#ifndef HAVE_WCRTOMB
#define wcrtomb(cp, wc, sp) wctomb(cp, wc)
#endif
#ifndef USE_WCHAR
#define USE_WCHAR
#endif
#else /* HAVE_WCHAR_H */
#undef USE_WCHAR
#endif /* !HAVE_WCHAR_H */
#if !defined(HAVE_WCTYPE_H) && !defined(HAVE_ISWPRINT)
#undef USE_WCHAR
#undef USE_WCTYPE
#endif
#ifdef NO_WCTYPE
#undef USE_WCHAR
#undef USE_WCTYPE
#endif
#ifdef NO_WCHAR
#undef USE_WCHAR
#undef USE_WCTYPE
#endif
#ifndef USE_WCHAR
/*
* We either don't have wide chars or we don't use them...
*/
#undef wchar_t
#define wchar_t char
#undef wint_t
#define wint_t int
/*
* We cannot define wctype_t here because of a bug in Linux (missing xctype_t
* definition in wchar.h
*/
#ifdef __never__
#undef wctype_t
#define wctype_t int
#endif
#undef WEOF
#define WEOF ((wint_t)-1)
#ifndef _SCHILY_UTYPES_H
#include <schily/utypes.h> /* For TYPE_MAXVAL() */
#endif
#undef WCHAR_MAX
#define WCHAR_MAX TYPE_MAXVAL(wchar_t)
#undef WCHAR_MIN
#define WCHAR_MIN TYPE_MINVAL(wchar_t)
#undef WINT_MAX
#define WINT_MAX TYPE_MAXVAL(wint_t)
#undef WINT_MIN
#define WINT_MIN TYPE_MINVAL(wint_t)
#undef WCTYPE_MAX
#define WCTYPE_MAX TYPE_MAXVAL(wctype_t)
#undef WCTYPE_MIN
#define WCTYPE_MIN TYPE_MINVAL(wctype_t)
#undef SIZEOF_WCHAR_T
#define SIZEOF_WCHAR_T SIZEOF_CHAR
#undef MB_CUR_MAX
#define MB_CUR_MAX 1
#undef MB_LEN_MAX
#define MB_LEN_MAX 1
/*
* The mbtowc() for the non-multibyte case could be as simple as
*
* #define mbtowc(wp, cp, len) (*(wp) = *(cp), 1)
*
* but Mac OS X forces us to do many mbtowc(NULL, NULL, 0) calls in order
* to reset the internal state. On other platforms that do not support
* wide chars, NULL may be defined as (void *)0, so we need to check
* for "wp" != NULL and to cast "wp" and "cp" to their expected types.
*/
#undef mbtowc
#define mbtowc(wp, cp, len) ((void)((wp) ? \
*(wchar_t *)(wp) = *(char *)(cp) : 1), 1)
#undef mbrtowc
#define mbrtowc(wp, cp, len, sp) ((void)((wp) ? \
*(wchar_t *)(wp) = *(char *)(cp) : 1), 1)
#undef wctomb
#define wctomb(cp, wc) (*(cp) = wc, 1)
#undef wcrtomb
#define wcrtomb(cp, wc, sp) (*(cp) = wc, 1)
#undef mbsinit
#define mbsinit(sp) ((int)((sp) == 0))
#undef wcwidth
#define wcwidth(wc) (1)
#else /* USE_WCHAR */
#ifndef HAVE_WCWIDTH
#undef wcwidth
#define wcwidth(wc) (1)
#endif
#endif /* USE_WCHAR */
#endif /* _SCHILY_WCHAR_H */
@@ -0,0 +1,99 @@
/* @(#)wctype.h 1.8 13/07/08 Copyright 2009-2013 J. Schilling */
/*
* Abstraction from wctype.h
*
* Copyright (c) 2009-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_WCTYPE_H
#define _SCHILY_WCTYPE_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifndef _SCHILY_WCHAR_H
#include <schily/wchar.h>
#endif
#ifdef HAVE_WCTYPE_H
/*
* Include wctype.h if wchars have been enabled in schily/wchar.h
*/
#ifdef USE_WCHAR
#ifndef _INCL_WCTYPE_H
#include <wctype.h>
#define _INCL_WCTYPE_H
#endif
#ifndef USE_WCTYPE
#define USE_WCTYPE
#endif
#endif /* USE_WCHAR */
#endif /* HAVE_WCTYPE_H */
#if defined(HAVE_ISWPRINT) && defined(USE_WCHAR)
#ifndef USE_WCTYPE
#undef USE_WCTYPE
#endif
#endif
#if !defined(HAVE_WCTYPE_H) && !defined(HAVE_ISWPRINT)
#undef USE_WCTYPE
#endif
#ifdef NO_WCTYPE
#undef USE_WCTYPE
#endif
#ifndef USE_WCTYPE
#ifndef _SCHILY_CTYPE_H
#include <schily/ctype.h>
#endif
#undef iswalnum
#define iswalnum(c) isalnum(c)
#undef iswalpha
#define iswalpha(c) isalpha(c)
#undef iswcntrl
#define iswcntrl(c) iscntrl(c)
#undef iswcntrl
#define iswcntrl(c) iscntrl(c)
#undef iswdigit
#define iswdigit(c) isdigit(c)
#undef iswgraph
#define iswgraph(c) isgraph(c)
#undef iswlower
#define iswlower(c) islower(c)
#undef iswprint
#define iswprint(c) isprint(c)
#undef iswpunct
#define iswpunct(c) ispunct(c)
#undef iswspace
#define iswspace(c) isspace(c)
#undef iswupper
#define iswupper(c) isupper(c)
#undef iswxdigit
#define iswxdigit(c) isxdigit(c)
#undef towlower
#define towlower(c) tolower(c)
#undef towupper
#define towupper(c) toupper(c)
#endif /* !USE_WCTYPE */
#endif /* _SCHILY_WCTYPE_H */
@@ -0,0 +1,88 @@
/* @(#)windows.h 1.4 13/10/26 Copyright 2011-2013 J. Schilling */
/*
* Definitions for windows.h
*
* Copyright (c) 2011-2013 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_WINDOWS_H
#define _SCHILY_WINDOWS_H
#ifndef _SCHILY_MCONFIG_H
#include <schily/mconfig.h>
#endif
#ifdef HAVE_WINDOWS_H
#ifndef _INCL_WINDOWS_H
/*
* configure believes they are missing and #define's them:
*/
#if defined(_MSC_VER) || defined(__MINGW32__)
/* BEGIN CSTYLED */
#undef u_char
#undef u_short
#undef u_int
#undef u_long
/* END CSTYLED */
#endif
#if defined(__CYGWIN32__) || defined(__CYGWIN__)
/*
* Cygwin-1.7.17 (Autumn 2012) makes life hard as it prevents to rename
* the Cygwin BOOL definition. Note that we have our own BOOL definition
* in schily/standard.h that exists since 1982 which happened before Microsoft
* introduced their BOOL.
*
* Previous Cygwin versions have been compatible to the original MS include
* files and allowed to rename the BOOL from windows.h (windef.h) by just using
* #define BOOL WBOOL before #include <windows.h>.
*
* Recent Cygwin version are unfriendly to us and prevent this.
* We now need a two level #define to redirect the BOOL from windows.h to the
* Cygwin specific WINBOOL typedef.
*
* If we do not include schily/standard.h with newer Cygwin, we cannot get
* working typedefs for "PBOOL" and "LPBOOL".
*/
#include <schily/standard.h> /* Get our BOOL typedef */
#define _NO_BOOL_TYPEDEF /* Avoid 2nd BOOL typedef on Cygwin-1.7.17 */
#define WBOOL WINBOOL /* Cygwin-1.7.17 prevents to avoid BOOL */
#endif /* defined(__CYGWIN32__) || defined(__CYGWIN__) */
#define BOOL WBOOL /* This is the Win BOOL */
#define format __ms_format /* Avoid format parameter hides global ... */
#ifdef timerclear /* struct timeval has already been declared */
#define timeval __ms_timeval
#endif
#include <windows.h>
#undef BOOL /* MS Code uses WBOOL or #define BOOL WBOOL */
#undef format /* Return to previous definition */
#undef timeval
#define _INCL_WINDOWS_H
#endif
#endif /* HAVE_WINDOWS_H */
#endif /* _SCHILY_WINDOWS_H */
@@ -0,0 +1,180 @@
/* @(#)xconfig.h 1.13 13/07/23 Copyright 1995-2013 J. Schilling */
/*
* This file either includes the dynamic or manual autoconf stuff.
*
* Copyright (c) 1995-2013 J. Schilling
*
* This file is included from <schily/mconfig.h> and usually
* includes $(SRCROOT)/incs/$(OARCH)/xconfig.h via
* -I$(SRCROOT)/incs/$(OARCH)/
*
* Use only cpp instructions.
*
* NOTE: SING: (Schily Is Not Gnu)
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _SCHILY_XCONFIG_H
#define _SCHILY_XCONFIG_H
/*
* This hack that is needed as long as VMS has no POSIX shell.
* It will go away soon. VMS users: in future you need to specify:
* cc -DUSE_STATIC_CONF
*/
#ifdef VMS
# define USE_STATIC_CONF
#endif
#ifdef NO_STATIC_CONF
#undef USE_STATIC_CONF
#endif
#ifdef USE_STATIC_CONF
# include <schily/xmconfig.h> /* The static autoconf stuff */
#else /* USE_STATIC_CONF */
#ifdef SCHILY_BUILD /* #defined by Schily makefile system */
/*
* Include $(SRCROOT)/incs/$(OARCH)/xconfig.h via
* -I$(SRCROOT)/incs/$(OARCH)/
*/
# include <xconfig.h> /* The current dynamic autoconf stuff */
#else /* !SCHILY_BUILD */
/*
* The stuff for static compilation. Include files from a previous
* dynamic autoconfiguration.
*/
#ifdef __SUNOS5_SPARC_CC32
#include <schily/sparc-sunos5-cc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_SPARC_CC64
#include <schily/sparc-sunos5-cc64/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_SPARC_GCC32
#include <schily/sparc-sunos5-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_SPARC_GCC64
#include <schily/sparc-sunos5-gcc64/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_X86_CC32
#include <schily/i386-sunos5-cc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_X86_CC64
#include <schily/i386-sunos5-cc64/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_X86_GCC32
#include <schily/i386-sunos5-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS5_X86_GCC64
#include <schily/i386-sunos5-gcc64/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __SUNOS4_MC68000_CC32
#ifdef __mc68020
#include <schily/mc68020-sunos4-cc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#endif
#ifdef __SUNOS4_MC68000_GCC32
#ifdef __mc68020
#include <schily/mc68020-sunos4-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#endif
#ifdef __HPUX_HPPA_CC32
#include <schily/hppa-hp-ux-cc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_CC64
#include <schily/hppa-hp-ux-cc64/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_GCC32
#include <schily/hppa-hp-ux-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __HPUX_HPPA_GCC64
#include <schily/hppa-hp-ux-gcc64/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV6L_GCC32
#include <schily/armv6l-linux-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV5L_GCC32
#include <schily/armv6l-linux-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_ARMV5TEJL_GCC32
#include <schily/armv5tejl-linux-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_I386_GCC32
#include <schily/i686-linux-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __LINUX_amd64_GCC64
#include <schily/x86_64-linux-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __MSWIN_X86_CL32
#include <schily/i686-cygwin32_nt-cl/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifdef __CYGWIN_X86_GCC
#include <schily/i686-cygwin32_nt-gcc/xconfig.h>
#define __JS_ARCH_CONF_INCL
#endif
#ifndef __JS_ARCH_CONF_INCL
/*
* #error will not work for all compilers (e.g. sunos4)
* The following line will abort compilation on all compilers
* if none of the above is defined. And that's what we want.
*/
Error unconfigured architecture
#include <schily/err_arch.h> /* Avoid "unknown directive" with K&R */
#endif
#endif /* SCHILY_BUILD */
#endif /* USE_STATIC_CONF */
#ifdef __cplusplus
extern "C" {
#endif
/*
* Fake in order to keep the silly hdrchk(1) quiet.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SCHILY_XCONFIG_H */
@@ -0,0 +1,164 @@
/* @(#)astoll.c 1.5 15/12/10 Copyright 1985, 2000-2015 J. Schilling */
/*
* astoll() converts a string to long long
*
* Leading tabs and spaces are ignored.
* Both return pointer to the first char that has not been used.
* Caller must check if this means a bad conversion.
*
* leading "+" is ignored
* leading "0" makes conversion octal (base 8)
* leading "0x" makes conversion hex (base 16)
*
* Llong is silently reverted to long if the compiler does not
* support long long.
*
* Copyright (c) 1985, 2000-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/standard.h>
#include <schily/utypes.h>
#include <schily/schily.h>
#include <schily/errno.h>
#define is_space(c) ((c) == ' ' || (c) == '\t')
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_hex(c) (\
((c) >= 'a' && (c) <= 'f') || \
((c) >= 'A' && (c) <= 'F'))
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define to_lower(c) (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A'+'a' : (c))
#if ('i' + 1) < 'j'
#define BASE_MAX ('i' - 'a' + 10 + 1) /* This is EBCDIC */
#else
#define BASE_MAX ('z' - 'a' + 10 + 1) /* This is ASCII */
#endif
char *
astoll(s, l)
register const char *s;
Llong *l;
{
return (astollb(s, l, 0));
}
char *
astollb(s, l, base)
register const char *s;
Llong *l;
register int base;
{
int neg = 0;
register ULlong ret = (ULlong)0;
ULlong maxmult;
ULlong maxval;
register int digit;
register char c;
if (base > BASE_MAX || base == 1 || base < 0) {
seterrno(EINVAL);
return ((char *)s);
}
while (is_space(*s))
s++;
if (*s == '+') {
s++;
} else if (*s == '-') {
s++;
neg++;
}
if (base == 0) {
if (*s == '0') {
base = 8;
s++;
if (*s == 'x' || *s == 'X') {
s++;
base = 16;
}
} else {
base = 10;
}
}
if (neg) {
/*
* Portable way to compute the positive value of "min-Llong"
* as -TYPE_MINVAL(Llong) does not work.
*/
maxval = ((ULlong)(-1 * (TYPE_MINVAL(Llong)+1))) + 1;
} else {
maxval = TYPE_MAXVAL(Llong);
}
maxmult = maxval / base;
for (; (c = *s) != 0; s++) {
if (is_digit(c)) {
digit = c - '0';
} else if (is_lower(c)) {
digit = c - 'a' + 10;
} else if (is_upper(c)) {
digit = c - 'A' + 10;
} else {
break;
}
if (digit < base) {
if (ret > maxmult)
goto overflow;
ret *= base;
if (maxval - ret < digit)
goto overflow;
ret += digit;
} else {
break;
}
}
if (neg) {
*l = (Llong)-1 * ret;
} else {
*l = (Llong)ret;
}
return ((char *)s);
overflow:
for (; (c = *s) != 0; s++) {
if (is_digit(c)) {
digit = c - '0';
} else if (is_lower(c)) {
digit = c - 'a' + 10;
} else if (is_upper(c)) {
digit = c - 'A' + 10;
} else {
break;
}
if (digit >= base)
break;
}
if (neg) {
*l = TYPE_MINVAL(Llong);
} else {
*l = TYPE_MAXVAL(Llong);
}
seterrno(ERANGE);
return ((char *)s);
}
@@ -0,0 +1,323 @@
/* @(#)checkerr.c 1.24 09/07/08 Copyright 2003-2009 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)checkerr.c 1.24 09/07/08 Copyright 2003-2009 J. Schilling";
#endif
/*
* Generic error control for programs that do file i/o.
* The error control is usually used by archiving programs.
*
* The current version does not provide a stable interface.
* It does not support multi-threaded programs and it may call
* comerr() from the parser. If you use the code before there is
* an official stable and "library-compliant" interface, be careful
* and watch for changes.
*
* Copyright (c) 2003-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/stdio.h>
#include <schily/standard.h>
#include <schily/patmatch.h>
#include <schily/string.h>
#include <schily/utypes.h>
#include <schily/schily.h>
#include <schily/checkerr.h>
typedef struct errconf {
struct errconf *ec_next; /* Next in list */
const Uchar *ec_pat; /* File name pattern */
int *ec_aux; /* Aux array from pattern compiler */
int ec_alt; /* Alt return from pattern compiler */
int ec_plen; /* String length of pattern */
UInt32_t ec_flags; /* Error condition flags */
} ec_t;
LOCAL int *ec_state; /* State array for pattern compiler */
LOCAL ec_t *ec_root; /* Root node of error config list */
LOCAL ec_t **ec_last = &ec_root; /* Last pointer in root node list */
LOCAL int maxplen;
LOCAL BOOL _errflag = TRUE; /* Abort on all errors */
EXPORT int errconfig __PR((char *name));
LOCAL char *_endword __PR((char *p));
LOCAL void parse_errctl __PR((char *line));
LOCAL UInt32_t errflags __PR((char *eflag, BOOL doexit));
LOCAL ec_t *_errptr __PR((int etype, const char *fname));
EXPORT BOOL errhidden __PR((int etype, const char *fname));
EXPORT BOOL errwarnonly __PR((int etype, const char *fname));
EXPORT BOOL errabort __PR((int etype, const char *fname, BOOL doexit));
/*
* Read and parse error configuration file
*/
EXPORT int
errconfig(name)
char *name;
{
char line[8192];
FILE *f;
int omaxplen = maxplen;
if ((f = fileopen(name, "r")) == NULL) {
if (errflags(name, FALSE) != 0)
parse_errctl(name);
else
comerr("Cannot open '%s'.\n", name);
} else {
while (fgetline(f, line, sizeof (line)) >= 0) {
parse_errctl(line);
}
fclose(f);
}
if (maxplen > omaxplen) {
ec_state = ___realloc(ec_state, (maxplen+1)*sizeof (int),
"pattern state");
}
return (1);
}
LOCAL char *
_endword(p)
char *p;
{
/*
* Find end of word.
*/
for (; *p != '\0' &&
*p != '\t' &&
*p != ' ';
p++) {
;
/* LINTED */
}
return (p);
}
LOCAL void
parse_errctl(line)
char *line;
{
int plen;
char *pattern;
ec_t *ep;
/*
* Find end of word.
*/
pattern = _endword(line);
if (pattern == line || *pattern == '\0') {
comerrno(EX_BAD,
"Bad error configuration line '%s'.\n", line);
}
/*
* Find end of white space after word.
*/
for (pattern++; *pattern != '\0' &&
(*pattern == '\t' || *pattern == ' ');
pattern++) {
;
/* LINTED */
}
ep = ___malloc(sizeof (ec_t), "errcheck node");
ep->ec_flags = errflags(line, TRUE);
ep->ec_plen = plen = strlen(pattern);
if (ep->ec_plen > maxplen)
maxplen = ep->ec_plen;
ep->ec_pat = (const Uchar *)___savestr(pattern);
ep->ec_aux = ___malloc(plen*sizeof (int), "compiled pattern");
if ((ep->ec_alt = patcompile((const Uchar *)pattern,
plen, ep->ec_aux)) == 0)
comerrno(EX_BAD, "Bad errctl pattern: '%s'.\n", pattern);
ep->ec_next = NULL;
*ec_last = ep;
ec_last = &ep->ec_next;
}
LOCAL struct eflags {
char *fname;
UInt32_t fval;
} eflags[] = {
{ "STAT", E_STAT },
{ "GETACL", E_GETACL },
{ "OPEN", E_OPEN },
{ "READ", E_READ },
{ "WRITE", E_WRITE },
{ "GROW", E_GROW },
{ "SHRINK", E_SHRINK },
{ "MISSLINK", E_MISSLINK },
{ "NAMETOOLONG", E_NAMETOOLONG },
{ "FILETOOBIG", E_FILETOOBIG },
{ "SPECIALFILE", E_SPECIALFILE },
{ "READLINK", E_READLINK },
{ "GETXATTR", E_GETXATTR },
{ "CHDIR", E_CHDIR },
{ "SETTIME", E_SETTIME },
{ "SETMODE", E_SETMODE },
{ "SECURITY", E_SECURITY },
{ "LSECURITY", E_LSECURITY },
{ "SAMEFILE", E_SAMEFILE },
{ "BADACL", E_BADACL },
{ "SETACL", E_SETACL },
{ "SETXATTR", E_SETXATTR },
{ "ALL", E_ALL },
{ "DIFF", E_DIFF },
{ "WARN", E_WARN },
{ "ABORT", E_ABORT },
{ NULL, 0 }
};
/*
* Convert error condition string into flag word
*/
LOCAL UInt32_t
errflags(eflag, doexit)
char *eflag;
BOOL doexit;
{
register char *p = eflag;
char *ef = _endword(eflag);
register struct eflags *ep;
register int slen;
register UInt32_t nflags = 0;
do {
for (ep = eflags; ep->fname; ep++) {
slen = strlen(ep->fname);
if ((strncmp(ep->fname, p, slen) == 0) &&
(p[slen] == '|' || p[slen] == ' ' ||
p[slen] == '\0')) {
nflags |= ep->fval;
break;
}
}
if (ep->fname == NULL) {
if (doexit)
comerrno(EX_BAD, "Bad flag '%s'\n", p);
return (0);
}
p = strchr(p, '|');
} while (p < ef && p && *p++ == '|');
if ((nflags & ~(UInt32_t)(E_ABORT|E_WARN)) == 0) {
if (doexit)
comerrno(EX_BAD, "Bad error condition '%s'.\n", eflag);
return (0);
}
return (nflags);
}
LOCAL ec_t *
_errptr(etype, fname)
int etype;
const char *fname;
{
ec_t *ep = ec_root;
char *ret;
const Uchar *name = (const Uchar *)fname;
int nlen;
if (fname == NULL) {
errmsgno(EX_BAD,
"Implementation botch for errhidden(0x%X, NULL)\n",
etype);
errmsgno(EX_BAD, "Please report this bug!\n");
errmsgno(EX_BAD, "Error cannot be ignored.\n");
return ((ec_t *)NULL);
}
nlen = strlen(fname);
while (ep) {
if ((ep->ec_flags & etype) != 0) {
ret = (char *)patmatch(ep->ec_pat, ep->ec_aux,
name, 0,
nlen, ep->ec_alt, ec_state);
if (ret != NULL && *ret == '\0')
return (ep);
}
ep = ep->ec_next;
}
return ((ec_t *)NULL);
}
/*
* Check whether error condition should be ignored for file name.
*/
EXPORT BOOL
errhidden(etype, fname)
int etype;
const char *fname;
{
ec_t *ep;
if ((ep = _errptr(etype, fname)) != NULL) {
if ((ep->ec_flags & (E_ABORT|E_WARN)) != 0)
return (FALSE);
return (TRUE);
}
return (FALSE);
}
/*
* Check whether error condition should not affect exit code for file name.
*/
EXPORT BOOL
errwarnonly(etype, fname)
int etype;
const char *fname;
{
ec_t *ep;
if ((ep = _errptr(etype, fname)) != NULL) {
if ((ep->ec_flags & E_WARN) != 0)
return (TRUE);
return (FALSE);
}
return (FALSE);
}
/*
* Check whether error condition should be fatal for file name.
*/
EXPORT BOOL
errabort(etype, fname, doexit)
int etype;
const char *fname;
BOOL doexit;
{
ec_t *ep;
if ((ep = _errptr(etype, fname)) == NULL) {
if (!_errflag)
return (FALSE);
} else if ((ep->ec_flags & E_ABORT) == 0)
return (FALSE);
if (doexit) {
errmsgno(EX_BAD, "Error is considered fatal, aborting.\n");
#ifdef CALL_OTHER_FUNCTION
if (other_func != NULL)
(*other_func)();
else
#endif
comexit(-3);
}
return (TRUE);
}
@@ -0,0 +1,373 @@
/* @(#)comerr.c 1.43 15/07/01 Copyright 1985-1989, 1995-2015 J. Schilling */
/*
* Routines for printing command errors
*
* Copyright (c) 1985-1989, 1995-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/unistd.h> /* include <sys/types.h> try to get size_t */
#include <schily/stdio.h> /* Try again for size_t */
#include <schily/stdlib.h> /* Try again for size_t */
#include <schily/standard.h>
#include <schily/varargs.h>
#include <schily/string.h>
#include <schily/schily.h>
#include <schily/errno.h>
EXPORT int on_comerr __PR((void (*fun)(int, void *), void *arg));
EXPORT void comerr __PR((const char *, ...));
EXPORT void xcomerr __PR((int, const char *, ...));
EXPORT void comerrno __PR((int, const char *, ...));
EXPORT void xcomerrno __PR((int, int, const char *, ...));
EXPORT int errmsg __PR((const char *, ...));
EXPORT int errmsgno __PR((int, const char *, ...));
EXPORT int _comerr __PR((FILE *, int, int, int,
const char *, va_list));
LOCAL int _ex_clash __PR((int));
EXPORT void comexit __PR((int));
EXPORT char *errmsgstr __PR((int));
typedef struct ex {
struct ex *next;
void (*func) __PR((int, void *));
void *arg;
} ex_t;
LOCAL ex_t *exfuncs;
/*
* Set list of callback functions to call with *comerr() and comexit().
* The function set up last with on_comerr() is called first on exit;
* in other words: call order is the reverse order of registration.
*/
EXPORT int
on_comerr(func, arg)
void (*func) __PR((int, void *));
void *arg;
{
ex_t *fp;
fp = malloc(sizeof (*fp));
if (fp == NULL)
return (-1);
fp->func = func;
fp->arg = arg;
fp->next = exfuncs;
exfuncs = fp;
return (0);
}
/*
* Fetch current errno, print a related message and exit(errno).
*/
/* VARARGS1 */
#ifdef PROTOTYPES
EXPORT void
comerr(const char *msg, ...)
#else
EXPORT void
comerr(msg, va_alist)
char *msg;
va_dcl
#endif
{
va_list args;
#ifdef PROTOTYPES
va_start(args, msg);
#else
va_start(args);
#endif
(void) _comerr(stderr, COMERR_EXIT, 0, geterrno(), msg, args);
/* NOTREACHED */
va_end(args);
}
/*
* Fetch current errno, print a related message and exit(exc).
*/
/* VARARGS2 */
#ifdef PROTOTYPES
EXPORT void
xcomerr(int exc, const char *msg, ...)
#else
EXPORT void
xcomerr(exc, msg, va_alist)
int exc;
char *msg;
va_dcl
#endif
{
va_list args;
#ifdef PROTOTYPES
va_start(args, msg);
#else
va_start(args);
#endif
(void) _comerr(stderr, COMERR_EXCODE, exc, geterrno(), msg, args);
/* NOTREACHED */
va_end(args);
}
/*
* Print a message related to err and exit(err).
*/
/* VARARGS2 */
#ifdef PROTOTYPES
EXPORT void
comerrno(int err, const char *msg, ...)
#else
EXPORT void
comerrno(err, msg, va_alist)
int err;
char *msg;
va_dcl
#endif
{
va_list args;
#ifdef PROTOTYPES
va_start(args, msg);
#else
va_start(args);
#endif
(void) _comerr(stderr, COMERR_EXIT, 0, err, msg, args);
/* NOTREACHED */
va_end(args);
}
/*
* Print a message related to err and exit(exc).
*/
/* VARARGS3 */
#ifdef PROTOTYPES
EXPORT void
xcomerrno(int exc, int err, const char *msg, ...)
#else
EXPORT void
xcomerrno(exc, err, msg, va_alist)
int exc;
int err;
char *msg;
va_dcl
#endif
{
va_list args;
#ifdef PROTOTYPES
va_start(args, msg);
#else
va_start(args);
#endif
(void) _comerr(stderr, COMERR_EXCODE, exc, err, msg, args);
/* NOTREACHED */
va_end(args);
}
/*
* Fetch current errno, print a related message and return(errno).
*/
/* VARARGS1 */
#ifdef PROTOTYPES
EXPORT int
errmsg(const char *msg, ...)
#else
EXPORT int
errmsg(msg, va_alist)
char *msg;
va_dcl
#endif
{
va_list args;
int ret;
#ifdef PROTOTYPES
va_start(args, msg);
#else
va_start(args);
#endif
ret = _comerr(stderr, COMERR_RETURN, 0, geterrno(), msg, args);
va_end(args);
return (ret);
}
/*
* Print a message related to err and return(err).
*/
/* VARARGS2 */
#ifdef PROTOTYPES
EXPORT int
errmsgno(int err, const char *msg, ...)
#else
EXPORT int
errmsgno(err, msg, va_alist)
int err;
char *msg;
va_dcl
#endif
{
va_list args;
int ret;
#ifdef PROTOTYPES
va_start(args, msg);
#else
va_start(args);
#endif
ret = _comerr(stderr, COMERR_RETURN, 0, err, msg, args);
va_end(args);
return (ret);
}
#if defined(__BEOS__) || defined(__HAIKU__)
/*
* On BeOS errno is a big negative number (0x80000000 + small number).
* We assume that small negative numbers are safe to be used as special
* values that prevent printing the errno text.
*
* We tried to use #if EIO < 0 but this does not work because EIO is
* defined to a enum. ENODEV may work as ENODEV is defined to a number
* directly.
*/
#define silent_error(e) ((e) < 0 && (e) >= -1024)
#else
/*
* On UNIX errno is a small non-negative number, so we assume that
* negative values cannot be a valid errno and don't print the error
* string in this case. However the value may still be used as exit()
* code if 'exflg' is set.
*/
#define silent_error(e) ((e) < 0)
#endif
EXPORT int
_comerr(f, exflg, exc, err, msg, args)
FILE *f; /* FILE * to print to */
int exflg; /* COMERR_RETURN, COMERR_EXIT, COMERR_EXCODE */
int exc; /* Use for exit() if exflg & COMERR_EXCODE */
int err; /* Errno for text, exit(err) if !COMERR_EXIT*/
const char *msg; /* printf() format */
va_list args; /* printf() args for format */
{
char errbuf[20];
char *errnam;
char *prognam = get_progname();
if (silent_error(err)) {
js_fprintf(f, "%s: %r", prognam, msg, args);
} else {
errnam = errmsgstr(err);
if (errnam == NULL) {
(void) js_snprintf(errbuf, sizeof (errbuf),
"Error %d", err);
errnam = errbuf;
}
js_fprintf(f, "%s: %s. %r", prognam, errnam, msg, args);
}
if (exflg) {
if (exflg & COMERR_EXCODE)
err = exc;
else
err = _ex_clash(err);
comexit(err);
/* NOTREACHED */
}
return (err);
}
LOCAL int
_ex_clash(exc)
int exc;
{
int exmod = exc % 256;
/*
* On a recent POSIX System that supports waitid(), siginfo.si_status
* holds the exit(2) value as an int. So if waitid() is used to wait
* for the process, we do not have problems from folded exit codes.
* All other wait*() functions fold the exit code by masking it
* with 0377.
*
* Exit codes used with comerr*()/comexit() are frequently errno values
* that have been in the range 0..31 with UNIX.V5 in the mid 1970s and
* that now are in the range 0..151 on Solaris. These values do not
* cause problems from folding to 8 bits, but "sysexits.h" contains
* definitions in the range 64..79 that cause (even unfolded) clashes
* with errno values.
*
* To avoid clashes with errno values, "schily/standard.h" defines
* EX_BAD (-1) as default error exit code and
* EX_CLASH (-64) as marker for clashes.
* Exit codes in the range -2..-63 (254..193 seen as unsigned two's
* complement) are available as software specific exit codes.
* We map all other negative exit codes to EX_CLASH if they would fold
* to -2..-63.
*/
if (exc != exmod && exmod <= 0 && exmod >= EX_CLASH)
exc = EX_CLASH;
return (exc);
}
/*
* Do a program exit() with previously calling functions registered via
* on_comerr().
*/
EXPORT void
comexit(err)
int err;
{
while (exfuncs) {
(*exfuncs->func)(err, exfuncs->arg);
exfuncs = exfuncs->next;
}
exit(err);
/* NOTREACHED */
}
/*
* Wrapper around the strange POSIX strerror().
* If there is a problem with retrieving the correct error text,
* return NULL.
*/
EXPORT char *
errmsgstr(err)
int err;
{
#ifdef HAVE_STRERROR
/*
* POSIX compliance may look strange...
*/
int errsav = geterrno();
char *ret;
seterrno(0);
ret = strerror(err);
err = geterrno();
seterrno(errsav);
if (ret == NULL || err)
return (NULL);
return (ret);
#else
if (err < 0 || err >= sys_nerr) {
return (NULL);
} else {
return (sys_errlist[err]);
}
#endif
}
@@ -0,0 +1,157 @@
/* @(#)dirent.c 1.3 12/03/20 Copyright 2011 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)dirent.c 1.3 12/03/20 Copyright 2011 J. Schilling";
#endif
/*
* Copyright (c) 2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/dirent.h>
#include <schily/maxpath.h>
#include <schily/string.h>
#include <schily/errno.h>
#ifdef NEED_READDIR
#if defined(__MINGW32__) || defined(_MSC_VER)
#include <schily/windows.h>
#include <schily/utypes.h>
#include <schily/schily.h>
EXPORT DIR *opendir __PR((const char *));
EXPORT int closedir __PR((DIR *));
EXPORT struct dirent *readdir __PR((DIR *));
EXPORT DIR *
opendir(dname)
const char *dname;
{
char path[PATH_MAX];
size_t len;
uint32_t attr;
DIR *dp;
if (dname == NULL) {
seterrno(EFAULT);
return ((DIR *)0);
}
len = strlen(dname);
if (len > PATH_MAX) {
seterrno(ENAMETOOLONG);
return ((DIR *)0);
}
if (len == 0) {
seterrno(ENOENT);
return ((DIR *)0);
}
attr = GetFileAttributes(dname);
if (attr == INVALID_FILE_ATTRIBUTES ||
(attr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
seterrno(ENOTDIR);
return ((DIR *)0);
}
path[0] = '\0';
_fullpath(path, dname, PATH_MAX);
len = strlen(path);
if (len == 0) {
seterrno(ENOENT);
return ((DIR *)0);
}
dp = malloc(sizeof (*dp) + len + 2); /* Add 2 for "/ *" */
if (dp == NULL) {
seterrno(ENOMEM);
return ((DIR *)0);
}
strcpy(dp->dd_dirname, path);
if (dp->dd_dirname[len-1] != '/' &&
dp->dd_dirname[len-1] != '\\') {
dp->dd_dirname[len] = '\\';
len++;
}
dp->dd_dirname[len] = '*';
dp->dd_handle = -1;
dp->dd_state = 0;
dp->dd_dir.d_ino = 0;
dp->dd_dir.d_reclen = 0;
dp->dd_dir.d_namlen = 0;
zerobytes(dp->dd_dir.d_name, sizeof (dp->dd_dir.d_name));
return (dp);
}
EXPORT int
closedir(dp)
DIR *dp;
{
int ret = 0;
if (dp == NULL) {
seterrno(EFAULT);
return (-1);
}
if (dp->dd_handle != -1) {
ret = _findclose(dp->dd_handle);
}
free(dp);
return (ret);
}
EXPORT struct dirent *
readdir(dp)
DIR *dp;
{
if (dp == NULL) {
seterrno(EFAULT);
return ((struct dirent *)0);
}
if (dp->dd_state == (char)-1) {
return ((struct dirent *)0);
} else if (dp->dd_state == (char)0) {
dp->dd_handle = _findfirst(dp->dd_dirname, &(dp->dd_data));
if (dp->dd_handle != -1)
dp->dd_state = 1;
else
dp->dd_state = -1;
} else {
if (_findnext(dp->dd_handle, &(dp->dd_data))) {
uint32_t werrno = GetLastError();
if (werrno == ERROR_NO_MORE_FILES)
seterrno(0);
_findclose(dp->dd_handle);
dp->dd_handle = -1;
dp->dd_state = -1;
} else {
dp->dd_state = 1; /* state++ to support seekdir */
}
}
if (dp->dd_state > 0) {
strlcpy(dp->dd_dir.d_name, dp->dd_data.name,
sizeof (dp->dd_dir.d_name));
return (&dp->dd_dir);
}
return ((struct dirent *)0);
}
#endif /* defined(__MINGW32__) || defined(_MSC_VER) */
#endif /* NEED_READDIR */
@@ -0,0 +1,56 @@
/* @(#)eaccess.c 1.6 14/05/15 Copyright 2004-2014 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)eaccess.c 1.6 14/05/15 Copyright 2004-2014 J. Schilling";
#endif
/*
* Implement the best possible emulation for eaccess()
*
* Copyright 2004-2014 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/unistd.h>
#include <schily/standard.h>
#include <schily/errno.h>
#include <schily/schily.h>
#ifndef HAVE_EACCESS
EXPORT int eaccess __PR((const char *name, int mode));
EXPORT int
eaccess(name, mode)
const char *name;
int mode;
{
#ifdef HAVE_EUIDACCESS
return (euidaccess(name, mode));
#else
#ifdef HAVE_ACCESS_E_OK
return (access(name, E_OK|mode));
#else
if (getuid() == geteuid() && getgid() == getegid())
return (access(name, mode));
#ifdef EOPNOTSUPP
seterrno(EOPNOTSUPP);
#else
seterrno(EINVAL);
#endif
return (-1);
#endif
#endif
}
#endif
@@ -0,0 +1,88 @@
/* @(#)error.c 1.18 15/08/01 Copyright 1985, 1989, 1995-2015 J. Schilling */
/*
* fprintf() on standard error stdio stream
*
* Copyright (c) 1985, 1989, 1995-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/stdio.h>
#include <schily/standard.h>
#include <schily/varargs.h>
#include <schily/schily.h>
#undef error
#ifndef NO_WEAK_SYMBOLS
/*
* The Cygwin compile environment incorrectly implements #pragma weak.
* The weak symbols are only defined as local symbols making it impossible
* to use them from outside the scope of this source file.
* A platform that allows linking with global symbols has HAVE_LINK_WEAK
* defined.
*/
#if defined(HAVE_PRAGMA_WEAK) && defined(HAVE_LINK_WEAK)
#pragma weak error = js_error
#else
/* VARARGS1 */
#ifdef PROTOTYPES
EXPORT int
error(const char *fmt, ...)
#else
EXPORT int
error(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list args;
int ret;
#ifdef PROTOTYPES
va_start(args, fmt);
#else
va_start(args);
#endif
ret = js_fprintf(stderr, "%r", fmt, args);
va_end(args);
return (ret);
}
#endif
#endif /* NO_WEAK_SYMBOLS */
/* VARARGS1 */
#ifdef PROTOTYPES
EXPORT int
js_error(const char *fmt, ...)
#else
EXPORT int
js_error(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list args;
int ret;
#ifdef PROTOTYPES
va_start(args, fmt);
#else
va_start(args);
#endif
ret = js_fprintf(stderr, "%r", fmt, args);
va_end(args);
return (ret);
}
@@ -0,0 +1,416 @@
/* @(#)fconv.c 1.45 10/11/06 Copyright 1985, 1995-2010 J. Schilling */
/*
* Convert floating point numbers to strings for format.c
* Should rather use the MT-safe routines [efg]convert()
*
* Copyright (c) 1985, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h> /* <- may define NO_FLOATINGPOINT */
#ifndef NO_FLOATINGPOINT
#ifndef __DO_LONG_DOUBLE__
#include <schily/stdlib.h>
#include <schily/standard.h>
#include <schily/string.h>
#include <schily/schily.h>
#include <schily/math.h> /* The default place for isinf()/isnan() */
#include <schily/nlsdefs.h>
#if !defined(HAVE_STDLIB_H) || defined(HAVE_DTOA)
extern char *ecvt __PR((double, int, int *, int *));
extern char *fcvt __PR((double, int, int *, int *));
#endif
#if defined(HAVE_ISNAN) && defined(HAVE_ISINF)
/*
* *BSD alike libc
*/
#define FOUND_ISNAN
#define FOUND_ISINF
#define FOUND_ISXX
#endif
#if defined(HAVE_C99_ISNAN) && defined(HAVE_C99_ISINF)
#ifndef FOUND_ISXX
#define FOUND_ISXX
#endif
#define FOUND_C99_ISNAN
#define FOUND_C99_ISINF
#define FOUND_C99_ISXX
#endif
#if defined(HAVE_FP_H) && !defined(FOUND_ISXX)
/*
* WAS:
* #if defined(__osf__) || defined(_IBMR2) || defined(_AIX)
*/
/*
* Moved before HAVE_IEEEFP_H for True64 due to a hint
* from Bert De Knuydt <[email protected]>
*
* True64 has both fp.h & ieeefp.h but the functions
* isnand() & finite() seem to be erreneously not implemented
* as a macro and the function lives in libm.
* Let's hope that we will not get problems with the new order.
*/
#include <fp.h>
#if !defined(isnan) && defined(IS_NAN)
#define isnan IS_NAN
#define FOUND_ISNAN
#endif
#if !defined(isinf) && defined(FINITE)
#define isinf !FINITE
#define FOUND_ISINF
#endif
#if defined(FOUND_ISNAN) && defined(FOUND_ISINF)
#define FOUND_ISXX
#endif
#endif
#if defined(HAVE_IEEEFP_H) && !defined(FOUND_ISXX) && \
!defined(FOUND_C99_ISXX)
/*
* SVR4
*/
#include <ieeefp.h>
#ifdef HAVE_ISNAND
#ifndef isnan
#define isnan isnand
#define FOUND_ISNAN
#endif
#endif
#ifdef HAVE_FINITE
#ifndef isinf
#define isinf !finite
#define FOUND_ISINF
#endif
#endif
#if defined(FOUND_ISNAN) && defined(FOUND_ISINF)
#define FOUND_ISXX
#endif
#endif
/*
* WAS:
* #if defined(__hpux) || defined(VMS) || defined(_SCO_DS) || defined(__QNX__)
*/
#ifdef __nneded__
#if defined(__hpux) || defined(__QNX__) || defined(__DJGPP__)
#ifndef FOUND_C99_ISXX
#undef isnan
#undef isinf
#endif
#endif
#endif /* __needed__ */
/*
* As we no longer check for defined(isnan)/defined(isinf), the next block
* should also handle the problems with DJGPP, HP-UX, QNX and VMS.
*/
#if !defined(FOUND_ISNAN) && !defined(HAVE_C99_ISNAN)
#undef isnan
#define isnan(val) (0)
#define NO_ISNAN
#endif
#if !defined(FOUND_ISINF) && !defined(HAVE_C99_ISINF)
#undef isinf
#define isinf(val) (0)
#define NO_ISINF
#endif
#if defined(NO_ISNAN) || defined(NO_ISINF)
#include <schily/float.h> /* For values.h */
#if (_IEEE - 0) > 0 /* We know that there is IEEE FP */
/*
* Note that older HP-UX versions have different #defines for MAXINT in
* values.h and sys/param.h
*/
#include <schily/utypes.h>
#include <schily/btorder.h>
#ifdef WORDS_BIGENDIAN
#define fpw_high(x) ((UInt32_t *)&x)[0]
#define fpw_low(x) ((UInt32_t *)&x)[1]
#else
#define fpw_high(x) ((UInt32_t *)&x)[1]
#define fpw_low(x) ((UInt32_t *)&x)[0]
#endif
#define FP_EXP 0x7FF00000
#define fp_exp(x) (fpw_high(x) & FP_EXP)
#define fp_exc(x) (fp_exp(x) == FP_EXP)
#ifdef NO_ISNAN
#undef isnan
#define isnan(val) (fp_exc(val) && \
(fpw_low(val) != 0 || (fpw_high(val) & 0xFFFFF) != 0))
#endif
#ifdef NO_ISINF
#undef isinf
#define isinf(val) (fp_exc(val) && \
fpw_low(val) == 0 && (fpw_high(val) & 0xFFFFF) == 0)
#endif
#endif /* We know that there is IEEE FP */
#endif /* defined(NO_ISNAN) || defined(NO_ISINF) */
#if !defined(HAVE_ECVT) || !defined(HAVE_FCVT) || !defined(HAVE_GCVT)
#ifdef NO_USER_XCVT
/*
* We cannot define our own ecvt()/fcvt()/gcvt() so we need to use
* local names instead.
*/
#ifndef HAVE_ECVT
#define ecvt js_ecvt
#endif
#ifndef HAVE_FCVT
#define fcvt js_fcvt
#endif
#ifndef HAVE_GCVT
#define gcvt js_gcvt
#endif
#endif
#include "cvt.c"
#endif
static char _js_nan[] = "(NaN)";
static char _js_inf[] = "(Infinity)";
static int _ferr __PR((char *, double));
#endif /* __DO_LONG_DOUBLE__ */
#ifdef __DO_LONG_DOUBLE__
#undef MDOUBLE
#define MDOUBLE long double
#else
#undef MDOUBLE
#define MDOUBLE double
#endif
#ifdef abs
#undef abs
#endif
#define abs(i) ((i) < 0 ? -(i) : (i))
EXPORT int
ftoes(s, val, fieldwidth, ndigits)
register char *s;
MDOUBLE val;
register int fieldwidth;
register int ndigits;
{
register char *b;
register char *rs;
register int len;
register int rdecpt;
int decpt;
int sign;
#ifndef __DO_LONG_DOUBLE__
if ((len = _ferr(s, val)) > 0)
return (len);
#endif
rs = s;
#ifdef V7_FLOATSTYLE
b = ecvt(val, ndigits, &decpt, &sign);
rdecpt = decpt;
#else
b = ecvt(val, ndigits+1, &decpt, &sign);
rdecpt = decpt-1;
#endif
#ifdef __DO_LONG_DOUBLE__
len = *b;
if (len < '0' || len > '9') { /* Inf/NaN */
strcpy(s, b);
return (strlen(b));
}
#endif
len = ndigits + 6; /* Punkt e +/- nnn */
if (sign)
len++;
if (fieldwidth > len)
while (fieldwidth-- > len)
*rs++ = ' ';
if (sign)
*rs++ = '-';
#ifndef V7_FLOATSTYLE
if (*b)
*rs++ = *b++;
#endif
#if defined(HAVE_LOCALECONV) && defined(USE_LOCALE)
*rs++ = *(localeconv()->decimal_point);
#else
*rs++ = '.';
#endif
while (*b && ndigits-- > 0)
*rs++ = *b++;
*rs++ = 'e';
*rs++ = rdecpt >= 0 ? '+' : '-';
rdecpt = abs(rdecpt);
#ifdef __DO_LONG_DOUBLE__
if (rdecpt >= 1000) { /* Max-Exp is > 4000 */
*rs++ = rdecpt / 1000 + '0';
rdecpt %= 1000;
}
#endif
#ifndef V7_FLOATSTYLE
if (rdecpt >= 100)
#endif
{
*rs++ = rdecpt / 100 + '0';
rdecpt %= 100;
}
*rs++ = rdecpt / 10 + '0';
*rs++ = rdecpt % 10 + '0';
*rs = '\0';
return (rs - s);
}
/*
* fcvt() from Cygwin32 is buggy.
*/
#if !defined(HAVE_FCVT) && defined(HAVE_ECVT)
#define USE_ECVT
#endif
EXPORT int
ftofs(s, val, fieldwidth, ndigits)
register char *s;
MDOUBLE val;
register int fieldwidth;
register int ndigits;
{
register char *b;
register char *rs;
register int len;
register int rdecpt;
int decpt;
int sign;
#ifndef __DO_LONG_DOUBLE__
if ((len = _ferr(s, val)) > 0)
return (len);
#endif
rs = s;
#ifdef USE_ECVT
/*
* Needed on systems with broken fcvt() implementation
* (e.g. Cygwin32)
*/
b = ecvt(val, ndigits, &decpt, &sign);
/*
* The next call is needed to force higher precision.
*/
if (decpt > 0)
b = ecvt(val, ndigits+decpt, &decpt, &sign);
#else
b = fcvt(val, ndigits, &decpt, &sign);
#endif
#ifdef __DO_LONG_DOUBLE__
len = *b;
if (len < '0' || len > '9') { /* Inf/NaN */
strcpy(s, b);
return (strlen(b));
}
#endif
rdecpt = decpt;
len = rdecpt + ndigits + 1;
if (rdecpt < 0)
len -= rdecpt;
if (sign)
len++;
if (fieldwidth > len)
while (fieldwidth-- > len)
*rs++ = ' ';
if (sign)
*rs++ = '-';
if (rdecpt > 0) {
len = rdecpt;
while (*b && len-- > 0)
*rs++ = *b++;
#ifdef USE_ECVT
while (len-- > 0)
*rs++ = '0';
#endif
}
#ifndef V7_FLOATSTYLE
else {
*rs++ = '0';
}
#endif
#if defined(HAVE_LOCALECONV) && defined(USE_LOCALE)
*rs++ = *(localeconv()->decimal_point);
#else
*rs++ = '.';
#endif
if (rdecpt < 0) {
len = rdecpt;
while (len++ < 0 && ndigits-- > 0)
*rs++ = '0';
}
while (*b && ndigits-- > 0)
*rs++ = *b++;
#ifdef USE_ECVT
while (ndigits-- > 0)
*rs++ = '0';
#endif
*rs = '\0';
return (rs - s);
}
#ifndef __DO_LONG_DOUBLE__
#ifdef HAVE_LONGDOUBLE
#ifdef HAVE__LDECVT
#define qecvt(ld, n, dp, sp) _ldecvt(*(long_double *)&ld, n, dp, sp)
#endif
#ifdef HAVE__LDFCVT
#define qfcvt(ld, n, dp, sp) _ldfcvt(*(long_double *)&ld, n, dp, sp)
#endif
#if (defined(HAVE_QECVT) || defined(HAVE__LDECVT)) && \
(defined(HAVE_QFCVT) || defined(HAVE__LDFCVT))
#define __DO_LONG_DOUBLE__
#define ftoes qftoes
#define ftofs qftofs
#define ecvt qecvt
#define fcvt qfcvt
#include "fconv.c"
#undef __DO_LONG_DOUBLE__
#endif
#endif /* HAVE_LONGDOUBLE */
LOCAL int
_ferr(s, val)
char *s;
double val;
{
if (isnan(val)) {
strcpy(s, _js_nan);
return (sizeof (_js_nan) - 1);
}
/*
* Check first for NaN because finite() will return 1 on Nan too.
*/
if (isinf(val)) {
strcpy(s, _js_inf);
return (sizeof (_js_inf) - 1);
}
return (0);
}
#endif /* __DO_LONG_DOUBLE__ */
#endif /* NO_FLOATINGPOINT */
@@ -0,0 +1,99 @@
/* @(#)fillbytes.c 1.18 10/08/21 Copyright 1987, 1995-2010 J. Schilling */
/*
* fill memory with data
*
* Copyright (c) 1987, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/standard.h>
#include <schily/align.h>
#include <schily/types.h>
#include <schily/schily.h>
#define DO8(a) a; a; a; a; a; a; a; a;
#define cval ((char)lval)
/*
* fillbytes(to, cnt, val) is the same as memset(to, val, cnt)
*/
#ifdef PROTOTYPES
EXPORT char *
fillbytes(void *tov, ssize_t cnt, char val)
#else
EXPORT char *
fillbytes(tov, cnt, val)
void *tov;
ssize_t cnt;
char val;
#endif
{
register char *to = (char *)tov;
register ssize_t n;
register long lval;
/*
* If we change cnt to be unsigned, check for == instead of <=
*/
if ((n = cnt) <= 0)
return (to);
lval = val & 0xFF;
/*
* Assign byte-wise until properly aligned for a long pointer.
*/
while (--n >= 0 && !laligned(to)) {
*to++ = cval;
}
n++;
if (n >= (ssize_t)(8 * sizeof (long))) {
register ssize_t rem = n % (8 * sizeof (long));
lval |= (lval<<8);
lval |= (lval<<16);
#if SIZE_LONG > SIZE_INT
lval |= (lval<<32);
#endif
n /= (8 * sizeof (long));
{
register long *tol = (long *)to;
do {
DO8 (*tol++ = lval);
} while (--n > 0);
to = (char *)tol;
}
n = rem;
if (n >= 8) {
n -= 8;
do {
DO8 (*to++ = cval);
} while ((n -= 8) >= 0);
n += 8;
}
if (n > 0) do {
*to++ = cval;
} while (--n > 0);
return (to);
}
if (n > 0) do {
*to++ = cval;
} while (--n > 0);
return (to);
}
@@ -0,0 +1,341 @@
/* @(#)fnmatch.c 8.20 15/07/06 2005-2015 J. Schilling from 8.2 (Berkeley) */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)fnmatch.c 8.20 15/07/06 2005-2015 J. Schilling from 8.2 (Berkeley)";
#endif
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Guido van Rossum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static UConst char sccsid[] = "@(#)fnmatch.c 8.20 (Berkeley) 07/06/15";
#endif /* LIBC_SCCS and not lint */
/* "FBSD src/lib/libc/gen/fnmatch.c,v 1.19 2010/04/16 22:29:24 jilles Exp $" */
/*
* Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
* Compares a filename or pathname to a pattern.
*/
/*
* Some notes on multibyte character support:
* 1. Patterns with illegal byte sequences match nothing.
* 2. Illegal byte sequences in the "string" argument are handled by treating
* them as single-byte characters with a value of the first byte of the
* sequence cast to wchar_t.
* 3. Multibyte conversion state objects (mbstate_t) are passed around and
* used for most, but not all, conversions. Further work will be required
* to support state-dependent encodings.
*/
#include <schily/mconfig.h>
#include <schily/fnmatch.h>
#include <schily/limits.h>
#include <schily/string.h>
#include <schily/wchar.h>
#include <schily/wctype.h>
#include <schily/libport.h> /* Define missing prototypes */
#define EOS '\0'
#define RANGE_MATCH 1
#define RANGE_NOMATCH 0
#define RANGE_ERROR (-1)
static int rangematch __PR((const char *, wchar_t, int, char **, mbstate_t *));
static int fnmatch1 __PR((const char *, const char *, const char *, int,
mbstate_t, mbstate_t));
#ifndef HAVE_FNMATCH
#undef fnmatch
/*
* The Cygwin compile environment incorrectly implements #pragma weak.
* The weak symbols are only defined as local symbols making it impossible
* to use them from outside the scope of this source file.
* A platform that allows linking with global symbols has HAVE_LINK_WEAK
* defined.
*/
#if defined(HAVE_PRAGMA_WEAK) && defined(HAVE_LINK_WEAK)
#pragma weak fnmatch = js_fnmatch
#else
int
fnmatch(pattern, string, flags)
const char *pattern;
const char *string;
int flags;
{
return (js_fnmatch(pattern, string, flags));
}
#endif
#endif
int
js_fnmatch(pattern, string, flags)
const char *pattern;
const char *string;
int flags;
{
/*
* SunPro C gives a warning if we do not initialize an object:
* static const mbstate_t initial;
* GCC gives a warning if we try to initialize it.
* As the POSIX standard forbids mbstate_t from being an array,
* we do not need "const", the var is always copied when used as
* a parapemeter for fnmatch1();
*/
static mbstate_t initial;
return (fnmatch1(pattern, string, string, flags, initial, initial));
}
static int
fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs)
const char *pattern;
const char *string;
const char *stringstart;
int flags;
mbstate_t patmbs;
mbstate_t strmbs;
{
char *newp;
char c;
wchar_t pc, sc;
size_t pclen, sclen;
for (;;) {
pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
pattern += pclen;
sclen = mbrtowc(&sc, string, MB_LEN_MAX, &strmbs);
if (sclen == (size_t)-1 || sclen == (size_t)-2) {
sc = (unsigned char)*string;
sclen = 1;
memset(&strmbs, 0, sizeof (strmbs));
}
switch (pc) {
case EOS:
if ((flags & FNM_LEADING_DIR) && sc == '/')
return (0);
return (sc == EOS ? 0 : FNM_NOMATCH);
case '?':
if (sc == EOS)
return (FNM_NOMATCH);
if (sc == '/' && (flags & FNM_PATHNAME))
return (FNM_NOMATCH);
if (sc == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
return (FNM_NOMATCH);
string += sclen;
break;
case '*':
c = *pattern;
/* Collapse multiple stars. */
while (c == '*')
c = *++pattern;
if (sc == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
return (FNM_NOMATCH);
/* Optimize for pattern with * at end or before /. */
if (c == EOS) {
if (flags & FNM_PATHNAME)
return ((flags & FNM_LEADING_DIR) ||
strchr(string, '/') == NULL ?
0 : FNM_NOMATCH);
else
return (0);
} else if (c == '/' && flags & FNM_PATHNAME) {
if ((string = strchr(string, '/')) == NULL)
return (FNM_NOMATCH);
break;
}
/* General case, use recursion. */
while (sc != EOS) {
if (!fnmatch1(pattern, string, stringstart,
flags, patmbs, strmbs))
return (0);
sclen = mbrtowc(&sc, string, MB_LEN_MAX,
&strmbs);
if (sclen == (size_t)-1 ||
sclen == (size_t)-2) {
sc = (unsigned char)*string;
sclen = 1;
memset(&strmbs, 0, sizeof (strmbs));
}
if (sc == '/' && (flags & FNM_PATHNAME))
break;
string += sclen;
}
return (FNM_NOMATCH);
case '[':
if (sc == EOS)
return (FNM_NOMATCH);
if (sc == '/' && (flags & FNM_PATHNAME))
return (FNM_NOMATCH);
if (sc == '.' && (flags & FNM_PERIOD) &&
(string == stringstart ||
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
return (FNM_NOMATCH);
switch (rangematch(pattern, sc, flags, &newp,
&patmbs)) {
case RANGE_ERROR:
goto norm;
case RANGE_MATCH:
pattern = newp;
break;
case RANGE_NOMATCH:
return (FNM_NOMATCH);
}
string += sclen;
break;
case '\\':
if (!(flags & FNM_NOESCAPE)) {
pclen = mbrtowc(&pc, pattern, MB_LEN_MAX,
&patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
if (pclen == 0)
pc = '\\';
pattern += pclen;
}
/* FALLTHROUGH */
default:
norm:
if (pc == sc)
;
else if ((flags & FNM_CASEFOLD) &&
(towlower(pc) == towlower(sc)))
;
else
return (FNM_NOMATCH);
string += sclen;
break;
}
}
/* NOTREACHED */
}
#ifdef PROTOTYPES
static int
rangematch(const char *pattern, wchar_t test, int flags, char **newp, mbstate_t *patmbs)
#else
static int
rangematch(pattern, test, flags, newp, patmbs)
const char *pattern;
wchar_t test;
int flags;
char **newp;
mbstate_t *patmbs;
#endif
{
int negate, ok;
wchar_t c, c2;
size_t pclen;
const char *origpat;
/*
* A bracket expression starting with an unquoted circumflex
* character produces unspecified results (IEEE 1003.2-1992,
* 3.13.2). This implementation treats it like '!', for
* consistency with the regular expression syntax.
* J.T. Conklin ([email protected])
*/
if ((negate = (*pattern == '!' || *pattern == '^')))
++pattern;
if (flags & FNM_CASEFOLD)
test = towlower(test);
/*
* A right bracket shall lose its special meaning and represent
* itself in a bracket expression if it occurs first in the list.
* -- POSIX.2 2.8.3.2
*/
ok = 0;
origpat = pattern;
for (;;) {
if (*pattern == ']' && pattern > origpat) {
pattern++;
break;
} else if (*pattern == '\0') {
return (RANGE_ERROR);
} else if (*pattern == '/' && (flags & FNM_PATHNAME)) {
return (RANGE_NOMATCH);
} else if (*pattern == '\\' && !(flags & FNM_NOESCAPE))
pattern++;
pclen = mbrtowc(&c, pattern, MB_LEN_MAX, patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (RANGE_NOMATCH);
pattern += pclen;
if (flags & FNM_CASEFOLD)
c = towlower(c);
if (*pattern == '-' && *(pattern + 1) != EOS &&
*(pattern + 1) != ']') {
if (*++pattern == '\\' && !(flags & FNM_NOESCAPE))
if (*pattern != EOS)
pattern++;
pclen = mbrtowc(&c2, pattern, MB_LEN_MAX, patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (RANGE_NOMATCH);
pattern += pclen;
if (c2 == EOS)
return (RANGE_ERROR);
if (flags & FNM_CASEFOLD)
c2 = towlower(c2);
#ifdef XXX_COLLATE
if (__collate_load_error ?
c <= test && test <= c2 :
__collate_range_cmp(c, test) <= 0 &&
__collate_range_cmp(test, c2) <= 0)
ok = 1;
#else
if (c <= test && test <= c2)
ok = 1;
#endif
} else if (c == test)
ok = 1;
}
*newp = (char *)pattern;
return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,38 @@
/* @(#)geterrno.c 1.14 10/08/23 Copyright 1985, 1995-2010 J. Schilling */
/*
* Get error number
*
* Copyright (c) 1985, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _TS_ERRNO
#define _TS_ERRNO /* Solaris: get thread safe errno value */
#endif
#ifndef _LIBC_REENTRANT
#define _LIBC_REENTRANT /* Linux: get thread safe errno value */
#endif
#include <schily/errno.h>
#include <schily/standard.h>
#include <schily/schily.h>
#ifdef geterrno
#undef geterrno
#endif
EXPORT int
geterrno()
{
return (errno);
}
@@ -0,0 +1,80 @@
/* @(#)getexecpath.c 1.1 10/11/18 Copyright 2006-2010 J. Schilling */
/*
* Copyright (c) 2006.2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/types.h>
#include <schily/unistd.h>
#include <schily/string.h>
#include <schily/standard.h>
#include <schily/schily.h>
#if (defined(sun) || defined(__sun) || defined(__sun__)) && defined(__SVR4)
#define PATH_IMPL
#define METHOD_SYMLINK
#define SYMLINK_PATH "/proc/self/path/a.out" /* Solaris 10 -> ... */
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define PATH_IMPL
#define METHOD_SYMLINK
#define SYMLINK_PATH "/proc/curproc/file" /* /proc may nor be mounted */
#endif
#if defined(__linux__) || defined(__linux)|| defined(linux)
#define PATH_IMPL
#define METHOD_SYMLINK
#define SYMLINK_PATH "/proc/self/exe"
#endif
#if defined(HAVE_PROC_PIDPATH) /* Mac OS X */
#ifdef HAVE_LIBPROC_H
#include <libproc.h>
#endif
#define PATH_IMPL
#endif
/*
* TODO: AIX: /proc/$$/object/a.out -> plain file, match via st_dev/st_ino
*/
EXPORT char *
getexecpath()
{
#ifdef PATH_IMPL
#ifdef METHOD_SYMLINK
char buf[1024];
ssize_t len;
len = readlink(SYMLINK_PATH, buf, sizeof (buf)-1);
if (len == -1)
return (NULL);
buf[len] = '\0';
return (strdup(buf));
#endif
#ifdef HAVE_PROC_PIDPATH /* Mac OS X */
char buf[1024];
int len;
len = proc_pidpath(getpid(), buf, sizeof (buf));
if (len == -1)
return (NULL);
return (strdup(buf));
#endif
#else
return (NULL);
#endif
}
@@ -0,0 +1,89 @@
/* @(#)gettimeofday.c 1.9 12/11/29 Copyright 2007-2012 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)gettimeofday.c 1.9 12/11/29 Copyright 2007-2012 J. Schilling";
#endif
/*
* Emulate gettimeofday where it does not exist
*
* Copyright (c) 2007-2012 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#if !defined(HAVE_GETTIMEOFDAY)
#if (defined(_MSC_VER) || defined(__MINGW32__))
#include <schily/windows.h>
#include <schily/time.h>
#include <schily/utypes.h>
#include <schily/standard.h>
#ifdef _MSC_VER
const __int64 MS_FTIME_ADD = 0x2b6109100i64;
const __int64 MS_FTIME_SECS = 10000000i64;
#else
const Int64_t MS_FTIME_ADD = 0x2b6109100LL;
const Int64_t MS_FTIME_SECS = 10000000LL;
#endif
EXPORT int
gettimeofday(tp, dummy)
struct timeval *tp;
void *dummy; /* tzp is unspecified by POSIX */
{
FILETIME ft;
Int64_t T;
if (tp == 0)
return (0);
GetSystemTimeAsFileTime(&ft); /* 100ns time since 1601 */
T = ft.dwHighDateTime;
T <<= 32;
T += ft.dwLowDateTime;
/*
* Cast to avoid a loss of data warning
* MSVC uses long instead of time_t for tv_sec
*/
tp->tv_sec = (long) (T / MS_FTIME_SECS - MS_FTIME_ADD);
tp->tv_usec = (long) (T % MS_FTIME_SECS) / 10;
return (0);
}
#else /* (defined(_MSC_VER) || defined(__MINGW32__)) */
#ifdef HAVE_TIME
#include <schily/time.h>
#include <schily/standard.h>
EXPORT int
gettimeofday(tp, dummy)
struct timeval *tp;
void *dummy; /* tzp is unspecified by POSIX */
{
time_t t;
if (tp == 0)
return (0);
(void) time(&t);
tp->tv_sec = t;
tp->tv_usec = 0;
return (0);
}
#endif
#endif /* (defined(_MSC_VER) || defined(__MINGW32__)) */
#endif /* !defined(HAVE_GETTIMEOFDAY) */
@@ -0,0 +1,64 @@
/* @(#)gid.c 1.1 11/07/11 Copyright 2011 J. Schilling */
/*
* Dummy functions for gid handling, used e.g. on MINGW
*
* Copyright (c) 2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/types.h>
#include <schily/unistd.h>
#include <schily/standard.h>
#include <schily/schily.h>
#ifndef HAVE_GETGID
EXPORT gid_t
getgid()
{
return (0);
}
#endif
#ifndef HAVE_GETEGID
EXPORT gid_t
getegid()
{
return (0);
}
#endif
#ifndef HAVE_SETGID
EXPORT int
setgid(gid)
gid_t gid;
{
return (0);
}
#endif
#ifndef HAVE_SETEGID
EXPORT int
setegid(gid)
gid_t gid;
{
return (0);
}
#endif
@@ -0,0 +1,198 @@
/* @(#)jsprintf.c 1.19 16/01/21 Copyright 1985, 1995-2016 J. Schilling */
/*
* Copyright (c) 1985, 1995-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/stdio.h>
#include <schily/types.h>
#include <schily/varargs.h>
#include <schily/standard.h>
#include <schily/schily.h>
#ifdef NO_FPRFORMAT
#undef USE_FPRFORMAT
#else
#define USE_FPRFORMAT
#endif
#ifdef USE_FPRFORMAT
/*
* This is the speed-optimized version that currently only has been tested
* on Solaris.
* It is based on fprformat() instead of format() and is faster than the
* the format() based standard implementation, in case that putc() or
* putc_unlocked() is a macro.
*/
/* VARARGS1 */
#ifdef PROTOTYPES
EXPORT int
js_printf(const char *form, ...)
#else
EXPORT int
js_printf(form, va_alist)
char *form;
va_dcl
#endif
{
va_list args;
int ret;
#ifdef PROTOTYPES
va_start(args, form);
#else
va_start(args);
#endif
ret = fprformat((long)stdout, form, args);
va_end(args);
return (ret);
}
/* VARARGS2 */
#ifdef PROTOTYPES
EXPORT int
js_fprintf(FILE *file, const char *form, ...)
#else
EXPORT int
js_fprintf(file, form, va_alist)
FILE *file;
char *form;
va_dcl
#endif
{
va_list args;
int ret;
#ifdef PROTOTYPES
va_start(args, form);
#else
va_start(args);
#endif
ret = fprformat((long)file, form, args);
va_end(args);
return (ret);
}
#else /* !USE_FPRFORMAT */
/*
* This is the portable standard implementation that works anywhere.
*/
#define BFSIZ 256
typedef struct {
short cnt;
char *ptr;
char buf[BFSIZ];
int count;
FILE *f;
} *BUF, _BUF;
LOCAL void _bflush __PR((BUF));
LOCAL void _bput __PR((char, long));
EXPORT int js_fprintf __PR((FILE *, const char *, ...));
EXPORT int js_printf __PR((const char *, ...));
LOCAL void
_bflush(bp)
register BUF bp;
{
bp->count += bp->ptr - bp->buf;
if (filewrite(bp->f, bp->buf, bp->ptr - bp->buf) < 0)
bp->count = EOF;
bp->ptr = bp->buf;
bp->cnt = BFSIZ;
}
#ifdef PROTOTYPES
LOCAL void
_bput(char c, long l)
#else
LOCAL void
_bput(c, l)
char c;
long l;
#endif
{
register BUF bp = (BUF)l;
*bp->ptr++ = c;
if (--bp->cnt <= 0)
_bflush(bp);
}
/* VARARGS1 */
#ifdef PROTOTYPES
EXPORT int
js_printf(const char *form, ...)
#else
EXPORT int
js_printf(form, va_alist)
char *form;
va_dcl
#endif
{
va_list args;
_BUF bb;
bb.ptr = bb.buf;
bb.cnt = BFSIZ;
bb.count = 0;
bb.f = stdout;
#ifdef PROTOTYPES
va_start(args, form);
#else
va_start(args);
#endif
format(_bput, (long)&bb, form, args);
va_end(args);
if (bb.cnt < BFSIZ)
_bflush(&bb);
return (bb.count);
}
/* VARARGS2 */
#ifdef PROTOTYPES
EXPORT int
js_fprintf(FILE *file, const char *form, ...)
#else
EXPORT int
js_fprintf(file, form, va_alist)
FILE *file;
char *form;
va_dcl
#endif
{
va_list args;
_BUF bb;
bb.ptr = bb.buf;
bb.cnt = BFSIZ;
bb.count = 0;
bb.f = file;
#ifdef PROTOTYPES
va_start(args, form);
#else
va_start(args);
#endif
format(_bput, (long)&bb, form, args);
va_end(args);
if (bb.cnt < BFSIZ)
_bflush(&bb);
return (bb.count);
}
#endif
@@ -0,0 +1,89 @@
/* @(#)jssnprintf.c 1.13 16/08/10 Copyright 1985, 1995-2016 J. Schilling */
/*
* Copyright (c) 1985, 1995-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/unistd.h> /* include <sys/types.h> try to get size_t */
#include <schily/stdio.h> /* Try again for size_t */
#include <schily/stdlib.h> /* Try again for size_t */
#include <schily/varargs.h>
#include <schily/standard.h>
#include <schily/schily.h>
EXPORT int js_snprintf __PR((char *, size_t maxcnt, const char *, ...));
typedef struct {
char *ptr;
int count;
} *BUF, _BUF;
#ifdef PROTOTYPES
static void
_cput(char c, long l)
#else
static void
_cput(c, l)
char c;
long l;
#endif
{
register BUF bp = (BUF)l;
if (--bp->count > 0) {
*bp->ptr++ = c;
} else {
/*
* Make sure that there will never be a negative overflow.
*/
bp->count++;
}
}
/* VARARGS2 */
#ifdef PROTOTYPES
EXPORT int
js_snprintf(char *buf, size_t maxcnt, const char *form, ...)
#else
EXPORT int
js_snprintf(buf, maxcnt, form, va_alist)
char *buf;
unsigned maxcnt;
char *form;
va_dcl
#endif
{
va_list args;
int cnt;
_BUF bb;
bb.ptr = buf;
bb.count = maxcnt;
#ifdef PROTOTYPES
va_start(args, form);
#else
va_start(args);
#endif
cnt = format(_cput, (long)&bb, form, args);
va_end(args);
if (maxcnt > 0)
*(bb.ptr) = '\0';
if (bb.count < 0)
return (-1);
return (cnt);
}
@@ -0,0 +1,470 @@
/* @(#)match.c 1.24 10/08/21 Copyright 1985, 1995-2010 J. Schilling */
#include <schily/standard.h>
#include <schily/patmatch.h>
/*
* Pattern matching functions
*
* Copyright (c) 1985, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
/*
* The pattern matching functions below are based on the algorithm
* presented by Martin Richards in:
*
* "A Compact Function for Regular Expression Pattern Matching",
* Software-Practice and Experience, Vol. 9, 527-534 (1979)
*
* Several changes have been made to the original source which has been
* written in BCPL:
*
* '/' is replaced by '!' (to allow UNIX filenames)
* '(',')' are replaced by '{', '}'
* '\'' is replaced by '\\' (UNIX compatible quote)
*
* Character classes have been added to allow "[<character list>]"
* to be used.
* Start of line '^' and end of line '$' have been added.
*/
#undef CHAR
#ifdef __LINE_MATCH
#ifdef __WIDE_CHAR
#define patmatch patwlmatch
#else
#define opatmatch opatlmatch
#define patmatch patlmatch
#endif
#endif
#ifdef __WIDE_CHAR
#ifndef __LINE_MATCH
#define patcompile patwcompile
#define patmatch patwmatch
#endif
#define CHAR wchar_t
#endif
#ifndef CHAR
typedef unsigned char Uchar;
#define CHAR Uchar
#endif
#define ENDSTATE (-1)
/*
* The Interpreter
*/
/*
* put adds a new state to the active list
*/
#define put(ret, state, sp, n) { \
register int *lstate = state; \
register int *lsp = sp; \
register int ln = n; \
\
while (lstate < lsp) { \
if (*lstate++ == ln) { \
ret = lsp; \
lsp = 0; \
break; \
} \
} \
if (lsp) { \
*lstate++ = ln; \
ret = lstate; \
} \
}
/*
* match a character in class
*/
#define in_class(found, pat, c) { \
register const CHAR *lpat = pat; \
register int lc = c; \
int lo_bound; \
int hi_bound; \
\
found = FALSE; \
\
if (*lpat == NOT) { \
lpat++; \
found = TRUE; \
} \
while (*lpat != RCLASS) { \
if (*lpat == QUOTE) \
lpat++; \
lo_bound = *lpat++; \
if (*lpat == RANGE) { \
lpat++; \
if (*lpat == QUOTE) \
lpat++; \
hi_bound = *lpat++; \
} else { \
hi_bound = lo_bound; \
} \
if (lo_bound <= lc && lc <= hi_bound) { \
found = !found; \
break; \
} \
} \
}
/*
* opatmatch - the old external interpreter interface.
*
* Trys to match a string beginning at offset
* against the compiled pattern.
*/
#ifndef __WIDE_CHAR
EXPORT CHAR
*opatmatch(pat, aux, str, soff, slen, alt)
const CHAR *pat;
const int *aux;
const CHAR *str;
int soff;
int slen;
int alt;
{
int state[MAXPAT];
return (patmatch(pat, aux, str, soff, slen, alt, state));
}
#endif
/*
* patmatch - the external interpreter interface.
*
* Trys to match a string beginning at offset
* against the compiled pattern.
*/
EXPORT CHAR *
patmatch(pat, aux, str, soff, slen, alt, state)
const CHAR *pat;
const int *aux;
const CHAR *str;
int soff;
int slen;
int alt;
int state[];
{
register int *sp;
register int *n;
register int *i;
register int p;
register int q, s, k;
int c;
const CHAR *lastp = (CHAR *)NULL;
#ifdef __LINE_MATCH
for (; soff <= slen; soff++) {
#endif
sp = state;
put(sp, state, state, 0);
if (alt != ENDSTATE)
put(sp, state, sp, alt);
for (s = soff; ; s++) {
/*
* next char from input string
*/
if (s >= slen)
c = 0;
else
c = str[s];
/*
* first complete the closure
*/
for (n = state; n < sp; ) {
p = *n++; /* next state number */
if (p == ENDSTATE)
continue;
q = aux[p]; /* get next state for pat */
k = pat[p]; /* get next char from pat */
switch (k) {
case REP:
put(sp, state, sp, p+1);
/* FALLTHRU */
case NIL: /* NIL matches always */
case STAR:
put(sp, state, sp, q);
break;
case LBRACK: /* alternations */
case ALT:
put(sp, state, sp, p+1);
if (q != ENDSTATE)
put(sp, state, sp, q);
break;
case START:
if (s == 0)
put(sp, state, sp, q);
break;
case END:
if (c == '\0')
put(sp, state, sp, q);
break;
}
}
for (i = state; i < sp; ) {
if (*i++ == ENDSTATE) {
lastp = &str[s];
break;
}
}
if (c == 0)
return ((CHAR *)lastp);
/*
* now try to match next character
*/
n = sp;
sp = state;
for (i = sp; i < n; ) {
p = *i++; /* next active state number */
if (p == ENDSTATE)
continue;
k = pat[p];
switch (k) {
case ALT:
case REP:
case NIL:
case LBRACK:
case START:
case END:
continue;
case LCLASS:
in_class(q, &pat[p+1], c);
if (!q)
continue;
break;
case STAR:
put(sp, state, sp, p);
continue;
case QUOTE:
k = pat[p+1];
default:
if (k != c)
continue;
/* FALLTHRU */
case ANY:
break;
}
put(sp, state, sp, aux[p]);
}
if (sp == state) { /* if no new states return */
#ifdef __LINE_MATCH
if (lastp || (soff == slen - 1))
return ((CHAR *)lastp);
else
break;
#else
return ((CHAR *)lastp);
#endif
}
}
#ifdef __LINE_MATCH
}
return ((CHAR *)lastp);
#endif
}
#ifndef __LINE_MATCH
/*
* The Compiler
*/
typedef struct args {
const CHAR *pattern;
int *aux;
int patp;
int length;
CHAR Ch;
} arg_t;
LOCAL void nextitem __PR((arg_t *));
LOCAL int prim __PR((arg_t *));
LOCAL int expr __PR((arg_t *, int *));
LOCAL void setexits __PR((int *, int, int));
LOCAL int join __PR((int *, int, int));
/*
* 'read' the next character from pattern
*/
#define rch(ap) \
{ \
if (++(ap)->patp >= (ap)->length) \
(ap)->Ch = 0; \
else \
(ap)->Ch = (ap)->pattern[(ap)->patp]; \
}
/*
* get the next item from pattern
*/
LOCAL void
nextitem(ap)
arg_t *ap;
{
if (ap->Ch == QUOTE)
rch(ap);
rch(ap);
}
/*
* parse a primary
*/
LOCAL int
prim(ap)
arg_t *ap;
{
int a = ap->patp;
int op = ap->Ch;
int t;
nextitem(ap);
switch (op) {
case '\0':
case ALT:
case RBRACK:
return (ENDSTATE);
case LCLASS:
while (ap->Ch != RCLASS && ap->Ch != '\0')
nextitem(ap);
if (ap->Ch == '\0')
return (ENDSTATE);
nextitem(ap);
break;
case REP:
t = prim(ap);
if (t == ENDSTATE)
return (ENDSTATE);
setexits(ap->aux, t, a);
break;
case LBRACK:
a = expr(ap, &ap->aux[a]);
if (a == ENDSTATE || ap->Ch != RBRACK)
return (ENDSTATE);
nextitem(ap);
break;
}
return (a);
}
/*
* parse an expression (a sequence of primaries)
*/
LOCAL int
expr(ap, altp)
arg_t *ap;
int *altp;
{
int exits = ENDSTATE;
int a;
int *aux = ap->aux;
CHAR Ch;
for (;;) {
a = prim(ap);
Ch = ap->Ch;
if (Ch == ALT || Ch == RBRACK || Ch == '\0') {
exits = join(aux, exits, a);
if (Ch != ALT)
return (exits);
*altp = ap->patp;
altp = &aux[ap->patp];
nextitem(ap);
} else
setexits(aux, a, ap->patp);
}
}
/*
* set all exits in a list to a specified value
*/
LOCAL void
setexits(aux, list, val)
int *aux;
int list;
int val;
{
int a;
while (list != ENDSTATE) {
a = aux[list];
aux[list] = val;
list = a;
}
}
/*
* concatenate two lists
*/
LOCAL int
join(aux, a, b)
int *aux;
int a;
int b;
{
int t;
if (a == ENDSTATE)
return (b);
t = a;
while (aux[t] != ENDSTATE)
t = aux[t];
aux[t] = b;
return (a);
}
/*
* patcompile - the external compiler interface.
*
* The pattern is compiled into the aux array.
* Return value on success, is the outermost alternate which is != 0.
* Error is indicated by return of 0.
*/
EXPORT int
patcompile(pat, len, aux)
const CHAR *pat;
int len;
int *aux;
{
arg_t a;
int alt = ENDSTATE;
int i;
a.pattern = pat;
a.length = len;
a.aux = aux;
a.patp = -1;
for (i = 0; i < len; i++)
aux[i] = ENDSTATE;
rch(&a);
i = expr(&a, &alt);
if (i == ENDSTATE)
return (0);
setexits(aux, i, ENDSTATE);
return (alt);
}
#endif /* LMATCH */
@@ -0,0 +1,104 @@
/* @(#)mem.c 1.11 15/05/10 Copyright 1998-2015 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)mem.c 1.11 15/05/10 Copyright 1998-2015 J. Schilling";
#endif
/*
* Memory handling with error checking
*
* Copyright (c) 1998-2015 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/stdio.h>
#include <schily/stdlib.h>
#include <schily/unistd.h>
#include <schily/string.h>
#include <schily/standard.h>
#include <schily/schily.h>
#include <schily/nlsdefs.h>
EXPORT int ___mexval __PR((int exval));
EXPORT void *___malloc __PR((size_t size, char *msg));
EXPORT void *___realloc __PR((void *ptr, size_t size, char *msg));
EXPORT char *___savestr __PR((const char *s));
LOCAL int mexval;
EXPORT int
___mexval(exval)
int exval;
{
int ret = mexval;
mexval = exval;
return (ret);
}
EXPORT void *
___malloc(size, msg)
size_t size;
char *msg;
{
void *ret;
ret = malloc(size);
if (ret == NULL) {
int err = geterrno();
errmsg(gettext("Cannot allocate memory for %s.\n"), msg);
if (mexval)
err = mexval;
comexit(err);
/* NOTREACHED */
}
return (ret);
}
EXPORT void *
___realloc(ptr, size, msg)
void *ptr;
size_t size;
char *msg;
{
void *ret;
if (ptr == NULL)
ret = malloc(size);
else
ret = realloc(ptr, size);
if (ret == NULL) {
int err = geterrno();
errmsg(gettext("Cannot realloc memory for %s.\n"), msg);
if (mexval)
err = mexval;
comexit(err);
/* NOTREACHED */
}
return (ret);
}
EXPORT char *
___savestr(s)
const char *s;
{
char *ret = ___malloc(strlen(s)+1, "saved string");
strcpy(ret, s);
return (ret);
}
@@ -0,0 +1,125 @@
/* @(#)movebytes.c 1.18 09/10/17 Copyright 1985, 1989, 1995-2009 J. Schilling */
/*
* move data
*
* Copyright (c) 1985, 1989, 1995-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/standard.h>
#include <schily/align.h>
#include <schily/types.h>
#include <schily/schily.h>
#define DO8(a) a; a; a; a; a; a; a; a;
/*
* movebytes(from, to, cnt) is the same as memmove(to, from, cnt)
*/
EXPORT char *
movebytes(fromv, tov, cnt)
const void *fromv;
void *tov;
ssize_t cnt;
{
register const char *from = fromv;
register char *to = tov;
register ssize_t n;
/*
* If we change cnt to be unsigned, check for == instead of <=
*/
if ((n = cnt) <= 0)
return (to);
if (from >= to) {
/*
* source is on higher addresses than destination:
* move bytes forwards
*/
if (n >= (ssize_t)(8 * sizeof (long))) {
if (l2aligned(from, to)) {
register const long *froml = (const long *)from;
register long *tol = (long *)to;
register ssize_t rem = n % (8 * sizeof (long));
n /= (8 * sizeof (long));
do {
DO8 (*tol++ = *froml++);
} while (--n > 0);
from = (const char *)froml;
to = (char *)tol;
n = rem;
}
if (n >= 8) {
n -= 8;
do {
DO8 (*to++ = *from++);
} while ((n -= 8) >= 0);
n += 8;
}
if (n > 0) do {
*to++ = *from++;
} while (--n > 0);
return (to);
}
if (n > 0) do {
*to++ = *from++;
} while (--n > 0);
return (to);
} else {
char *ep;
/*
* source is on lower addresses than destination:
* move bytes backwards
*/
to += n;
from += n;
ep = to;
if (n >= (ssize_t)(8 * sizeof (long))) {
if (l2aligned(from, to)) {
register const long *froml = (const long *)from;
register long *tol = (long *)to;
register ssize_t rem = n % (8 * sizeof (long));
n /= (8 * sizeof (long));
do {
DO8 (*--tol = *--froml);
} while (--n > 0);
from = (const char *)froml;
to = (char *)tol;
n = rem;
}
if (n >= 8) {
n -= 8;
do {
DO8 (*--to = *--from);
} while ((n -= 8) >= 0);
n += 8;
}
if (n > 0) do {
*--to = *--from;
} while (--n > 0);
return (ep);
}
if (n > 0) do {
*--to = *--from;
} while (--n > 0);
return (ep);
}
}
@@ -0,0 +1,172 @@
/* @(#)raisecond.c 1.22 09/07/10 Copyright 1985, 1989, 1995-2004 J. Schilling */
/*
* raise a condition (software signal)
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
/*
* Check for installed condition handlers.
* If a handler is found, the function is called with the appropriate args.
* If no handler is found or no handler signals success,
* the program will be aborted.
*
* Copyright (c) 1985, 1989, 1995-2004 J. Schilling
*/
#include <schily/mconfig.h>
#include <schily/stdio.h>
#include <schily/standard.h>
#include <schily/sigblk.h>
#include <schily/unistd.h>
#include <schily/stdlib.h>
#include <schily/string.h>
#include <schily/avoffset.h>
#include <schily/schily.h>
#if !defined(AV_OFFSET) || !defined(FP_INDIR)
# ifdef HAVE_SCANSTACK
# undef HAVE_SCANSTACK
# endif
#endif
/*
* Macros to print to stderr without stdio, to avoid screwing up.
*/
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
#define eprints(a) (void)write(STDERR_FILENO, (a), sizeof (a)-1)
#define eprintl(a) (void)write(STDERR_FILENO, (a), strlen(a))
#define is_even(p) ((((long)(p)) & 1) == 0)
#define even(p) (((long)(p)) & ~1L)
#ifdef __future__
#define even(p) (((long)(p)) - 1) /* will this work with 64 bit ?? */
#endif
LOCAL void raiseabort __PR((const char *));
#ifdef HAVE_SCANSTACK
#include <schily/stkframe.h>
#define next_frame(vp) do { \
if (((struct frame *)(vp))->fr_savfp == 0) { \
vp = (void *)0; \
break; \
} \
if (((struct frame *)(vp))->fr_savpc == 0) { \
vp = (void *)0; \
break; \
} \
vp = \
(void *)((struct frame *)(vp))->fr_savfp; \
} while (vp != NULL && is_even(vp)); \
vp = (struct frame *)even(vp);
#else
#if defined(IS_MACOS_X)
/*
* The MAC OS X linker does not grok "common" varaibles.
* Make __roothandle a "data" variable.
*/
EXPORT SIGBLK *__roothandle = 0;
#else
EXPORT SIGBLK *__roothandle;
#endif
#define next_frame(vp) vp = (((SIGBLK *)(vp))->sb_savfp);
#endif
LOCAL BOOL framehandle __PR((SIGBLK *, const char *, const char *, long));
/*
* Loop through the chain of procedure frames on the stack.
*
* Frame pointers normally have even values.
* Frame pointers of procedures with an installed handler are marked odd.
* The even base value, in this case actually points to a SIGBLK which
* holds the saved "real" frame pointer.
* The SIGBLK mentioned above may me the start of a chain of SIGBLK's,
* containing different handlers.
*/
EXPORT void
raisecond(signame, arg2)
const char *signame;
long arg2;
{
register void *vp = NULL;
#ifdef HAVE_SCANSTACK
/*
* As the SCO OpenServer C-Compiler has a bug that may cause
* the first function call to getfp() been done before the
* new stack frame is created, we call getfp() twice.
*/
(void) getfp();
vp = getfp();
next_frame(vp);
#else
vp = __roothandle;
#endif
while (vp) {
if (framehandle((SIGBLK *)vp, signame, signame, arg2))
return;
else if (framehandle((SIGBLK *)vp, "any_other", signame, arg2))
return;
#ifdef HAVE_SCANSTACK
vp = (struct frame *)((SIGBLK *)vp)->sb_savfp;
#endif
next_frame(vp);
}
/*
* No matching handler that signals success found.
* Print error message and abort.
*/
raiseabort(signame);
/* NOTREACHED */
}
/*
* Loop through the handler chain for a procedure frame.
*
* If no handler with matching name is found, return FALSE,
* otherwise the first handler with matching name is called.
* The return value in the latter case depends on the called function.
*/
LOCAL BOOL
framehandle(sp, handlename, signame, arg2)
register SIGBLK *sp;
const char *handlename;
const char *signame;
long arg2;
{
for (; sp; sp = sp->sb_signext) {
if (sp->sb_signame != NULL &&
streql(sp->sb_signame, handlename)) {
if (sp->sb_sigfun == NULL) { /* deactivated */
return (FALSE);
} else {
return (*sp->sb_sigfun)(signame,
sp->sb_sigarg, arg2);
}
}
}
return (FALSE);
}
LOCAL void
raiseabort(signame)
const char *signame;
{
eprints("Condition not caught: "); eprintl(signame); eprints(".\n");
abort();
/* NOTREACHED */
}
@@ -0,0 +1,221 @@
/* @(#)saveargs.c 1.16 10/11/18 Copyright 1995-2010 J. Schilling */
/*
* save argc, argv for command error printing routines
*
* Copyright (c) 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/standard.h>
#include <schily/string.h>
#include <schily/stdlib.h>
#include <schily/avoffset.h>
#include <schily/schily.h>
#include <schily/dlfcn.h>
#if !defined(AV_OFFSET) || !defined(FP_INDIR)
# ifdef HAVE_SCANSTACK
# undef HAVE_SCANSTACK
# endif
#endif
#ifdef HAVE_VAR___PROGNAME
extern char *__progname;
#ifdef HAVE_VAR___PROGNAME_FULL
extern char *__progname_full;
#else
#define __progname_full __progname
#endif
#endif
static int ac_saved;
static char **av_saved;
static char *av0_saved;
static char *av0_name_saved;
static char *progpath_saved;
static char *progname_saved;
static char av0_sp[32]; /* av0 space, avoid malloc() in most cases */
static char prn_sp[32]; /* name space, avoid malloc() in most cases */
static char dfl_str[] = "?";
LOCAL void save_av0 __PR((char *av0));
LOCAL void init_progname __PR((void));
LOCAL void init_arginfo __PR((void));
EXPORT void
save_args(ac, av)
int ac;
char *av[];
{
ac_saved = ac;
av_saved = av;
save_av0(av[0]);
}
LOCAL void
save_av0(av0)
char *av0;
{
int slen;
char *p;
if (av0_saved && av0_saved != av0_sp)
free(av0_saved);
slen = strlen(av0) + 1;
if (slen <= (int)sizeof (av0_sp))
av0_saved = av0_sp;
else
av0_saved = malloc(slen);
if (av0_saved) {
strcpy(av0_saved, av0);
av0 = av0_saved;
}
if ((p = strrchr(av0, '/')) == NULL)
av0_name_saved = av0;
else
av0_name_saved = ++p;
}
EXPORT int
saved_ac()
{
if (av_saved == NULL)
init_arginfo();
return (ac_saved);
}
EXPORT char **
saved_av()
{
if (av_saved == NULL)
init_arginfo();
return (av_saved);
}
EXPORT char *
saved_av0()
{
if (av0_saved == NULL)
init_arginfo();
return (av0_saved);
}
EXPORT void
set_progname(name)
const char *name;
{
int slen;
char *p;
if (progpath_saved && progpath_saved != prn_sp)
free(progpath_saved);
slen = strlen(name) + 1;
if (slen <= sizeof (prn_sp))
progpath_saved = prn_sp;
else
progpath_saved = malloc(slen);
if (progpath_saved) {
strcpy(progpath_saved, name);
name = progpath_saved;
}
if ((p = strrchr(name, '/')) == NULL)
progname_saved = (char *)name;
else
progname_saved = ++p;
}
EXPORT char *
get_progname()
{
if (progname_saved)
return (progname_saved);
if (av0_name_saved == NULL)
init_progname();
if (av0_name_saved)
return (av0_name_saved);
return (dfl_str);
}
EXPORT char *
get_progpath()
{
if (progpath_saved)
return (progpath_saved);
if (av0_saved == NULL)
init_progname();
if (av0_saved)
return (av0_saved);
return (dfl_str);
}
LOCAL void
init_progname()
{
#if defined(HAVE_SCANSTACK) || defined(HAVE_GETPROGNAME)
char *progname;
#endif
if (av0_name_saved == NULL)
init_arginfo();
if (av0_name_saved)
return;
#ifdef HAVE_GETPROGNAME
progname = (char *)getprogname();
if (progname) {
save_av0(progname);
return;
}
#endif
#ifdef HAVE_VAR___PROGNAME
if (__progname_full) {
save_av0(__progname_full);
return;
}
#endif
#ifdef HAVE_SCANSTACK
progname = getav0(); /* scan stack to get argv[0] */
if (progname) {
save_av0(progname);
return;
}
#endif
}
LOCAL void
init_arginfo()
{
#if defined(HAVE_DLINFO) && defined(HAVE_DLOPEN_IN_LIBC) && defined(RTLD_DI_ARGSINFO)
Dl_argsinfo args;
if (dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &args) < 0 ||
args.dla_argc <= 0 ||
args.dla_argv[0] == NULL)
return;
if (av_saved == NULL)
save_args(args.dla_argc, args.dla_argv);
#endif
}
@@ -0,0 +1,245 @@
/* @(#)searchinpath.c 1.5 16/08/01 Copyright 1999-2016 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)searchinpath.c 1.5 16/08/01 Copyright 1999-2016 J. Schilling";
#endif
/*
* Search a file name in the PATH of the current exeecutable.
* Return the path to the file name in allocated space.
*
* Copyright (c) 1999-2016 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/mconfig.h>
#include <schily/string.h>
#include <schily/unistd.h>
#include <schily/stdlib.h> /* getexecname() */
#include <schily/stat.h>
#include <schily/standard.h>
#include <schily/schily.h>
#include <schily/errno.h>
#define NAMEMAX 4096
EXPORT char *searchfileinpath __PR((char *name, int mode,
int file_mode,
char *path));
LOCAL char *searchonefile __PR((char *name, int mode,
BOOL plain_file,
char *xn,
char *nbuf,
char *np, char *ep));
#if defined(__DJGPP__)
LOCAL char *strbs2s __PR((char *s));
#endif
#ifdef JOS
#define enofile(t) ((t) == EMISSDIR || \
(t) == ENOFILE || \
(t) == EISADIR || \
(t) == EIOERR)
#else
#define enofile(t) ((t) == ENOENT || \
(t) == ENOTDIR || \
(t) == EISDIR || \
(t) == EIO)
#endif
/*
* Search for the "name" file in the PATH of the user.
* Assume that the file is ... bin/../name.
*/
EXPORT char *
searchfileinpath(name, mode, file_mode, path)
char *name; /* Find <execname>/../name in PATH */
int mode; /* Mode for access() e.g. X_OK */
int file_mode; /* How to check files */
char *path; /* PATH to use if not NULL */
{
char pbuf[NAMEMAX];
char *nbuf = pbuf;
char *np;
char *ep;
char *xn;
int nlen = strlen(name);
int oerrno = geterrno();
int err = 0;
#ifdef HAVE_GETEXECNAME
char *pn = (char *)getexecname(); /* pn is on the stack */
#else
char *pn = getexecpath(); /* pn is from strdup() */
char ebuf[NAMEMAX];
if (pn) {
strlcpy(ebuf, pn, sizeof (ebuf));
free(pn);
pn = ebuf;
}
#endif
if (pn == NULL)
xn = get_progname();
else
xn = pn;
if ((np = strrchr(xn, '/')) != NULL)
xn = ++np;
/*
* getexecname() is the best choice for our seach. getexecname()
* returns either "foo" (if called from the current directory) or
* an absolute path after symlinks have been resolved.
* If getexecname() returns a path with slashes, try to search
* first relatively to the known location of the current binary.
*/
if ((file_mode & SIP_ONLY_PATH) == 0 &&
pn != NULL && strchr(pn, '/') != NULL) {
strlcpy(nbuf, pn, sizeof (pbuf));
np = nbuf + strlen(nbuf);
while (np > nbuf && np[-1] != '/')
*--np = '\0';
pn = &nbuf[sizeof (pbuf) - 1];
if ((np = searchonefile(name, mode,
file_mode & (SIP_PLAIN_FILE|SIP_NO_STRIPBIN),
xn,
nbuf, np, pn)) != NULL) {
seterrno(oerrno);
return (np);
}
}
if (file_mode & SIP_NO_PATH)
return (NULL);
if (path == NULL)
path = getenv("PATH");
if (path == NULL)
return (NULL);
#ifdef __DJGPP__
path = strdup(path);
if (path == NULL)
return (NULL);
strbs2s(path); /* PATH under DJGPP can contain both slashes */
#endif
/*
* A PATH name search should lead us to the path under which we
* called the binary, but not necessarily to the install path as
* we may have been called thorugh a symlink or hardlink. In case
* of a symlink, we can follow the link. In case of a hardlink, we
* are lost.
*/
ep = &nbuf[sizeof (pbuf) - 1];
for (;;) {
np = nbuf;
while (*path != PATH_ENV_DELIM && *path != '\0' &&
np < &nbuf[sizeof (pbuf) - nlen])
*np++ = *path++;
*np = '\0';
if ((np = searchonefile(name, mode,
file_mode & (SIP_PLAIN_FILE|SIP_NO_STRIPBIN),
xn,
nbuf, np, ep)) != NULL) {
#ifdef __DJGPP__
free(path);
#endif
seterrno(oerrno);
return (np);
}
if (err == 0) {
err = geterrno();
if (enofile(err))
err = 0;
}
if (*path == '\0')
break;
path++;
}
#ifdef __DJGPP__
free(path);
#endif
if (err)
seterrno(err);
else
seterrno(oerrno);
return (NULL);
}
LOCAL char *
searchonefile(name, mode, plain_file, xn, nbuf, np, ep)
register char *name; /* Find <execname>/../name in PATH */
int mode; /* Mode for access() e.g. X_OK */
BOOL plain_file; /* Whether to check only plain files */
char *xn; /* The basename of the executable */
register char *nbuf; /* Name buffer base */
register char *np; /* Where to append name to path */
register char *ep; /* Point to last valid char in nbuf */
{
struct stat sb;
while (np > nbuf && np[-1] == '/')
*--np = '\0';
if (xn) {
*np++ = '/';
strlcpy(np, xn, ep - np);
if (stat(nbuf, &sb) < 0)
return (NULL);
if (!S_ISREG(sb.st_mode))
return (NULL);
*--np = '\0';
}
if ((plain_file & SIP_NO_STRIPBIN) == 0) {
if (np >= &nbuf[4] && streql(&np[-4], "/bin"))
np = &np[-4];
}
plain_file &= SIP_PLAIN_FILE;
*np++ = '/';
*np = '\0';
strlcpy(np, name, ep - np);
seterrno(0);
if (stat(nbuf, &sb) >= 0) {
if ((!plain_file || S_ISREG(sb.st_mode)) &&
(eaccess(nbuf, mode) >= 0)) {
return (strdup(nbuf));
}
if (geterrno() == 0)
seterrno(EACCES);
}
return (NULL);
}
#ifdef __DJGPP__
LOCAL char *
strbs2s(s)
char *s;
{
char *tmp = s;
if (tmp) {
while (*tmp) {
if (*tmp == '\\')
*tmp = '/';
tmp++;
}
}
return (s);
}
#endif
@@ -0,0 +1,41 @@
/* @(#)seterrno.c 1.13 10/08/23 Copyright 1985, 1995-2010 J. Schilling */
/*
* Set error number
*
* Copyright (c) 1985, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _TS_ERRNO
#define _TS_ERRNO /* Solaris: get thread safe errno value */
#endif
#ifndef _LIBC_REENTRANT
#define _LIBC_REENTRANT /* Linux: get thread safe errno value */
#endif
#include <schily/standard.h>
#include <schily/errno.h>
#include <schily/schily.h>
#ifdef seterrno
#undef seterrno
#endif
EXPORT int
seterrno(err)
int err;
{
int old = errno;
errno = err;
return (old);
}
@@ -0,0 +1,59 @@
/* @(#)cvmod.c 2.9 04/08/08 Copyright 1986, 1995-2003 J. Schilling */
/*
* Copyright (c) 1986, 1995-2003 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
EXPORT int
_cvmod(mode, omode, flag)
const char *mode;
int *omode;
int *flag;
{
while (*mode) {
switch (*mode) {
case 'r': *omode |= O_RDONLY; *flag |= FI_READ; break;
case 'w': *omode |= O_WRONLY; *flag |= FI_WRITE; break;
case 'e': *omode |= O_EXCL; break;
case 'c': *omode |= O_CREAT; *flag |= FI_CREATE; break;
case 't': *omode |= O_TRUNC; *flag |= FI_TRUNC; break;
case 'a': *omode |= O_APPEND; *flag |= FI_APPEND; break;
case 'u': *flag |= FI_UNBUF; break;
/* dummy on UNIX */
case 'b': *omode |= O_BINARY; *flag |= FI_BINARY; break;
/*
* XXX do we need this ?
* XXX May this be a problem?
*/
case 'l': *omode |= O_LARGEFILE; break;
default: raisecond(_badmode, 0L);
return (0);
}
mode++;
}
if (*flag & FI_READ && *flag & FI_WRITE) {
*omode &= ~(O_RDONLY|O_WRONLY);
*omode |= O_RDWR;
}
return (1);
}
@@ -0,0 +1,19 @@
/* @(#)dat.c 1.3 03/06/15 Copyright 1986, 1996-2003 J. Schilling */
/*
* Copyright (c) 1986, 1996-2003 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
char _badfile[] = "bad_file";
char _badmode[] = "bad_file_mode";
char _badop[] = "bad_file_op";
@@ -0,0 +1,79 @@
/* @(#)fcons.c 2.20 10/11/06 Copyright 1986, 1995-2010 J. Schilling */
/*
* Copyright (c) 1986, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
/*
* Note that because of a definition in schilyio.h we are using
* fseeko()/ftello() instead of fseek()/ftell() if available.
*/
LOCAL char *fmtab[] = {
"", /* 0 FI_NONE */
"r", /* 1 FI_READ */
"w", /* 2 FI_WRITE **1) */
"r+", /* 3 FI_READ | FI_WRITE */
"b", /* 4 FI_NONE | FI_BINARY */
"rb", /* 5 FI_READ | FI_BINARY */
"wb", /* 6 FI_WRITE | FI_BINARY **1) */
"r+b", /* 7 FI_READ | FI_WRITE | FI_BINARY */
/* + FI_APPEND */ "", /* 0 FI_NONE */
/* ... */ "r", /* 1 FI_READ */
"a", /* 2 FI_WRITE **1) */
"a+", /* 3 FI_READ | FI_WRITE */
"b", /* 4 FI_NONE | FI_BINARY */
"rb", /* 5 FI_READ | FI_BINARY */
"ab", /* 6 FI_WRITE | FI_BINARY **1) */
"a+b", /* 7 FI_READ | FI_WRITE | FI_BINARY */
};
/*
* NOTES:
* 1) fdopen() guarantees not to create/trunc files in this case
*
* "w" will create/trunc files with fopen()
* "a" will create files with fopen()
*/
EXPORT FILE *
_fcons(fd, f, flag)
register FILE *fd;
int f;
int flag;
{
int my_gflag = _io_glflag;
if (fd == (FILE *)NULL)
fd = fdopen(f,
fmtab[flag&(FI_READ|FI_WRITE|FI_BINARY | FI_APPEND)]);
if (fd != (FILE *)NULL) {
if (flag & FI_APPEND) {
(void) fseek(fd, (off_t)0, SEEK_END);
}
if (flag & FI_UNBUF) {
setbuf(fd, NULL);
my_gflag |= _JS_IOUNBUF;
}
set_my_flag(fd, my_gflag); /* must clear it if fd is reused */
return (fd);
}
if (flag & FI_CLOSE)
close(f);
return ((FILE *)NULL);
}
@@ -0,0 +1,40 @@
/* @(#)ffileread.c 1.13 09/06/30 Copyright 1986, 1996-2009 J. Schilling */
/*
* Copyright (c) 1986, 1996-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
EXPORT ssize_t
ffileread(f, buf, len)
register FILE *f;
void *buf;
size_t len;
{
register int fd;
register ssize_t ret;
int oerrno = geterrno();
down2(f, _IOREAD, _IORW);
fd = fileno(f);
while ((ret = read(fd, buf, len)) < 0 && geterrno() == EINTR) {
/*
* Set back old 'errno' so we don't change the errno visible
* to the outside if we did not fail.
*/
seterrno(oerrno);
}
return (ret);
}
@@ -0,0 +1,138 @@
/* @(#)fgetline.c 1.13 14/03/27 Copyright 1986, 1996-2014 J. Schilling */
/*
* Copyright (c) 1986, 1996-2014 J. Schilling
*
* This is an interface that exists in the public since 1982.
* The POSIX.1-2008 standard did ignore POSIX rules not to
* redefine existing public interfaces and redefined the interfaces
* forcing us to add a js_*() prefix to the original functions.
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#define fgetline __no__fgetline__
#define getline __no__getline__
#include "schilyio.h"
#ifndef NO_GETLINE_COMPAT /* Define to disable backward compatibility */
#undef fgetline
#undef getline
#ifdef HAVE_PRAGMA_WEAK
#pragma weak fgetline = js_fgetline
#pragma weak getline = js_getline
#else
EXPORT int fgetline __PR((FILE *, char *, int));
EXPORT int getline __PR((char *, int));
EXPORT int
fgetline(f, buf, len)
FILE *f;
char *buf;
int len;
{
return (js_fgetline(f, buf, len));
}
EXPORT int
getline(buf, len)
char *buf;
int len;
{
return (js_fgetline(stdin, buf, len));
}
#endif
#endif
/*
* XXX should we check if HAVE_USG_STDIO is defined and
* XXX use something line memccpy to speed things up ???
* XXX On Solaris 64 bits, we may use #define FAST_GETC_PUTC
* XXX and getc_unlocked()
*/
#if !defined(getc) && defined(USE_FGETS_FOR_FGETLINE)
#include <schily/string.h>
EXPORT int
js_fgetline(f, buf, len)
register FILE *f;
char *buf;
register int len;
{
char *bp = fgets(buf, len, f);
if (bp) {
len = strlen(bp);
if (len > 0) {
if (bp[len-1] == '\n')
bp[--len] = '\0';
}
return (len);
}
buf[0] = '\0';
return (-1);
}
#else
EXPORT int
js_fgetline(f, buf, len)
register FILE *f;
char *buf;
register int len;
{
register int c = '\0';
register char *bp = buf;
register int nl = '\n';
down2(f, _IOREAD, _IORW);
for (;;) {
if ((c = getc(f)) < 0)
break;
if (c == nl)
break;
if (--len > 0) {
*bp++ = (char)c;
} else {
#ifdef __never__
/*
* Read up to end of line
*/
while ((c = getc(f)) >= 0 && c != nl)
/* LINTED */
;
#endif
break;
}
}
*bp = '\0';
/*
* If buffer is empty and we hit EOF, return EOF
*/
if (c < 0 && bp == buf)
return (c);
return (bp - buf);
}
#endif
EXPORT int
js_getline(buf, len)
char *buf;
int len;
{
return (js_fgetline(stdin, buf, len));
}
@@ -0,0 +1,35 @@
/* @(#)fileopen.c 1.12 10/08/21 Copyright 1986, 1995-2010 J. Schilling */
/*
* Copyright (c) 1986, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
EXPORT FILE *
fileopen(name, mode)
const char *name;
const char *mode;
{
int ret;
int omode = 0;
int flag = 0;
if (!_cvmod(mode, &omode, &flag))
return ((FILE *)NULL);
if ((ret = _openfd(name, omode)) < 0)
return ((FILE *)NULL);
return (_fcons((FILE *)0, ret, flag | FI_CLOSE));
}
@@ -0,0 +1,92 @@
/* @(#)filewrite.c 1.18 12/02/26 Copyright 1986, 1995-2012 J. Schilling */
/*
* Copyright (c) 1986, 1995-2012 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
static char _writeerr[] = "file_write_err";
#ifdef HAVE_USG_STDIO
EXPORT ssize_t
filewrite(f, vbuf, len)
register FILE *f;
void *vbuf;
size_t len;
{
register int n;
ssize_t cnt;
char *buf = vbuf;
down2(f, _IOWRT, _IORW);
if (f->_flag & _IONBF) {
cnt = _niwrite(fileno(f), buf, len);
if (cnt < 0) {
f->_flag |= _IOERR;
if (!(my_flag(f) & _JS_IONORAISE))
raisecond(_writeerr, 0L);
}
return (cnt);
}
cnt = 0;
while (len > 0) {
if (f->_cnt <= 0) {
if (usg_flsbuf((unsigned char) *buf++, f) == EOF)
break;
cnt++;
if (--len == 0)
break;
}
if ((n = f->_cnt >= len ? len : f->_cnt) > 0) {
f->_ptr = (unsigned char *)movebytes(buf, f->_ptr, n);
buf += n;
f->_cnt -= n;
cnt += n;
len -= n;
}
}
if (!ferror(f))
return (cnt);
if (!(my_flag(f) & _JS_IONORAISE) && !(_io_glflag & _JS_IONORAISE))
raisecond(_writeerr, 0L);
return (-1);
}
#else
EXPORT ssize_t
filewrite(f, vbuf, len)
register FILE *f;
void *vbuf;
size_t len;
{
ssize_t cnt;
char *buf = vbuf;
down2(f, _IOWRT, _IORW);
if (my_flag(f) & _JS_IOUNBUF)
return (_niwrite(fileno(f), buf, len));
cnt = fwrite(buf, 1, len, f);
if (!ferror(f))
return (cnt);
if (!(my_flag(f) & _JS_IONORAISE) && !(_io_glflag & _JS_IONORAISE))
raisecond(_writeerr, 0L);
return (-1);
}
#endif /* HAVE_USG_STDIO */
@@ -0,0 +1,135 @@
/* @(#)flag.c 2.14 10/11/06 Copyright 1986-2010 J. Schilling */
/*
* Copyright (c) 1986-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
#include <schily/stdlib.h>
#ifdef DO_MYFLAG
#define FL_INIT 10
#if defined(IS_MACOS_X)
/*
* The MAC OS X linker does not grok "common" varaibles.
* Make _io_glflag a "data" variable.
*/
EXPORT int _io_glflag = 0; /* global default flag */
#else
EXPORT int _io_glflag; /* global default flag */
#endif
LOCAL int _fl_inc = 10; /* increment to expand flag struct */
EXPORT int _fl_max = FL_INIT; /* max fd currently in _io_myfl */
LOCAL _io_fl _io_smyfl[FL_INIT]; /* initial static space */
EXPORT _io_fl *_io_myfl = _io_smyfl; /* init to static space */
LOCAL int _more_flags __PR((FILE *));
LOCAL int
_more_flags(fp)
FILE *fp;
{
register int f = fileno(fp);
register int n = _fl_max;
register _io_fl *np;
while (n <= f)
n += _fl_inc;
if (_io_myfl == _io_smyfl) {
np = (_io_fl *) malloc(n * sizeof (*np));
fillbytes(np, n * sizeof (*np), '\0');
movebytes(_io_smyfl, np, sizeof (_io_smyfl)/sizeof (*np));
} else {
np = (_io_fl *) realloc(_io_myfl, n * sizeof (*np));
if (np)
fillbytes(&np[_fl_max], (n-_fl_max)*sizeof (*np), '\0');
}
if (np) {
_io_myfl = np;
_fl_max = n;
return (_io_get_my_flag(fp));
} else {
return (_JS_IONORAISE);
}
}
EXPORT int
_io_get_my_flag(fp)
register FILE *fp;
{
register int f = fileno(fp);
register _io_fl *fl;
if (f >= _fl_max)
return (_more_flags(fp));
fl = &_io_myfl[f];
if (fl->fl_io == 0 || fl->fl_io == fp)
return (fl->fl_flags);
while (fl && fl->fl_io != fp)
fl = fl->fl_next;
if (fl == 0)
return (0);
return (fl->fl_flags);
}
EXPORT void
_io_set_my_flag(fp, flag)
FILE *fp;
int flag;
{
register int f = fileno(fp);
register _io_fl *fl;
register _io_fl *fl2;
if (f >= _fl_max)
(void) _more_flags(fp);
fl = &_io_myfl[f];
if (fl->fl_io != (FILE *)0) {
fl2 = fl;
while (fl && fl->fl_io != fp)
fl = fl->fl_next;
if (fl == 0) {
if ((fl = (_io_fl *) malloc(sizeof (*fl))) == 0)
return;
fl->fl_next = fl2->fl_next;
fl2->fl_next = fl;
}
}
fl->fl_io = fp;
fl->fl_flags = flag;
}
EXPORT void
_io_add_my_flag(fp, flag)
FILE *fp;
int flag;
{
int oflag = _io_get_my_flag(fp);
oflag |= flag;
_io_set_my_flag(fp, oflag);
}
#endif /* DO_MYFLAG */
@@ -0,0 +1,42 @@
/* @(#)niwrite.c 1.7 09/06/30 Copyright 1986, 2001-2009 J. Schilling */
/*
* Non interruptable write
*
* Copyright (c) 1986, 2001-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include "schilyio.h"
EXPORT ssize_t
_niwrite(f, buf, count)
int f;
void *buf;
size_t count;
{
ssize_t ret;
int oerrno = geterrno();
if ((ret = (ssize_t)count) < 0) {
seterrno(EINVAL);
return ((ssize_t)-1);
}
while ((ret = write(f, buf, count)) < 0 && geterrno() == EINTR) {
/*
* Set back old 'errno' so we don't change the errno visible
* to the outside if we did not fail.
*/
seterrno(oerrno);
}
return (ret);
}
@@ -0,0 +1,233 @@
/* @(#)schilyio.h 2.28 10/08/23 Copyright 1986, 1995-2010 J. Schilling */
/*
* Copyright (c) 1986, 1995-2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#ifndef _STDIO_SCHILYIO_H
#define _STDIO_SCHILYIO_H
#include <schily/mconfig.h>
#include <schily/stdio.h>
#include <schily/standard.h>
#include <schily/types.h>
#include <schily/unistd.h>
#include <schily/fcntl.h>
#include <schily/schily.h>
#include <schily/errno.h>
#ifdef NO_USG_STDIO
# ifdef HAVE_USG_STDIO
# undef HAVE_USG_STDIO
# endif
#endif
#ifdef HAVE_LARGEFILES
/*
* XXX We may need to put this code to a more global place to allow all
* XXX users of fseek()/ftell() to automaticaly use fseeko()/ftello()
* XXX if the latter are available.
*
* If HAVE_LARGEFILES is defined, it is guaranteed that fseeko()/ftello()
* both are available.
*/
# define fseek fseeko
# define ftell ftello
#else /* !HAVE_LARGEFILES */
/*
* If HAVE_LARGEFILES is not defined, we depend on specific tests for
* fseeko()/ftello() which must have been done before the tests for
* Large File support have been done.
* Note that this only works if the tests used below are really done before
* the Large File autoconf test is run. This is because autoconf does no
* clean testing but instead cumulatively modifes the envivonment used for
* testing.
*/
#ifdef HAVE_FSEEKO
# define fseek fseeko
#endif
#ifdef HAVE_FTELLO
# define ftell ftello
#endif
#endif
/*
* speed things up...
*/
#ifndef _OPENFD_SRC
#ifdef _openfd
#undef _openfd
#endif
#define _openfd(name, omode) (open(name, omode, (mode_t)0666))
#endif
#define DO_MYFLAG /* use local flags */
/*
* Flags used during fileopen(), ... by _fcons()/ _cvmod()
*/
#define FI_NONE 0x0000 /* no flags defined */
#define FI_READ 0x0001 /* open for reading */
#define FI_WRITE 0x0002 /* open for writing */
#define FI_BINARY 0x0004 /* open in binary mode */
#define FI_APPEND 0x0008 /* append on each write */
#define FI_CREATE 0x0010 /* create if nessecary */
#define FI_TRUNC 0x0020 /* truncate file on open */
#define FI_UNBUF 0x0080 /* dont't buffer io */
#define FI_CLOSE 0x1000 /* close file on error */
/*
* Additional Schily FILE * flags that are not present with the
* standard stdio implementation.
*/
#define _JS_IONORAISE 01 /* do no raisecond() on errors */
#define _JS_IOUNBUF 02 /* do unbuffered i/o */
#ifdef DO_MYFLAG
struct _io_flags {
FILE *fl_io; /* file pointer */
struct _io_flags /* pointer to next struct */
*fl_next; /* if more file pointer to same fd */
int fl_flags; /* my flags */
};
typedef struct _io_flags _io_fl;
extern int _io_glflag; /* global default flag */
extern _io_fl *_io_myfl; /* array of structs to hold my flags */
extern int _fl_max; /* max fd currently in _io_myfl */
/*
* if fileno > max
* expand
* else if map[fileno].pointer == 0
* return 0
* else if map[fileno].pointer == p
* return map[fileno].flags
* else
* search list
*/
#define flp(p) (&_io_myfl[fileno(p)])
#ifdef MY_FLAG_IS_MACRO
#define my_flag(p) ((int)fileno(p) >= _fl_max ? \
_io_get_my_flag(p) : \
((flp(p)->fl_io == 0 || flp(p)->fl_io == p) ? \
flp(p)->fl_flags : \
_io_get_my_flag(p)))
#else
#define my_flag(p) _io_get_my_flag(p)
#endif
#define set_my_flag(p, v) _io_set_my_flag(p, v)
#define add_my_flag(p, v) _io_add_my_flag(p, v)
extern int _io_get_my_flag __PR((FILE *));
extern void _io_set_my_flag __PR((FILE *, int));
extern void _io_add_my_flag __PR((FILE *, int));
#else /* DO_MYFLAG */
#define my_flag(p) _JS_IONORAISE /* Always noraise */
#define set_my_flag(p, v) /* Ignore */
#define add_my_flag(p, v) /* Ignore */
#endif /* DO_MYFLAG */
#ifdef HAVE_USG_STDIO
/*
* Use the right filbuf()/flsbuf() function.
*/
#ifdef HAVE___FILBUF
# define usg_filbuf(fp) __filbuf(fp)
# define usg_flsbuf(c, fp) __flsbuf(c, fp)
/*
* Define prototypes to verify if our interface is right
*/
extern int __filbuf __PR((FILE *));
#else
# ifdef HAVE__FILBUF
# define usg_filbuf(fp) _filbuf(fp)
# define usg_flsbuf(c, fp) _flsbuf(c, fp)
/*
* Define prototypes to verify if our interface is right
*/
extern int _filbuf __PR((FILE *));
# else
/*
* no filbuf() but this will not happen on USG_STDIO systems.
*/
# endif
#endif
/*
* Do not check this because flsbuf()'s 1st parameter may be
* int SunOS
* unsigned int Apollo
* unsigned char HP-UX-11
*
* Note that the interface is now checked by autoconf.
*/
#else
/*
* If we are on a non USG system we cannot down file pointers
*/
#undef DO_DOWN
#endif
#ifndef DO_DOWN
/*
* No stream checking
*/
#define down(f)
#define down1(f, fl1)
#define down2(f, fl1, fl2)
#else
/*
* Do stream checking (works only on USG stdio)
*
* New version of USG stdio.
* _iob[] holds only a small amount of pointers.
* Aditional space is allocated.
* We may check only if the file pointer is != NULL
* and if iop->_flag refers to a stream with appropriate modes.
* If _iob[] gets expanded by malloc() we cannot check upper bound.
*/
#define down(f) ((f) == 0 || (f)->_flag == 0 ? \
(raisecond(_badfile, 0L), (FILE *)0) : (f))
#define down1(f, fl1) ((f) == 0 || (f)->_flag == 0 ? \
(raisecond(_badfile, 0L), (FILE *)0) : \
(((f)->_flag & fl1) != fl1 ? \
(raisecond(_badop, 0L), (FILE *)0) : \
(f)))
#define down2(f, fl1, fl2) ((f) == 0 || (f)->_flag == 0 ? \
(raisecond(_badfile, 0L), (FILE *)0) : \
(((f)->_flag & fl1) != fl1 && \
((f)->_flag & fl2) != fl2 ? \
(raisecond(_badop, 0L), (FILE *)0) : \
(f)))
#endif /* DO_DOWN */
extern char _badfile[];
extern char _badmode[];
extern char _badop[];
#endif /* _STDIO_SCHILYIO_H */
@@ -0,0 +1,41 @@
/* @(#)streql.c 1.10 09/06/07 Copyright 1985, 1995-2009 J. Schilling */
/*
* Check if two strings are equal
*
* Copyright (c) 1985, 1995-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/standard.h>
#include <schily/schily.h>
EXPORT int
streql(a, b)
const char *a;
const char *b;
{
register const char *s1 = a;
register const char *s2 = b;
if (s1 == NULL || s2 == NULL)
return (FALSE);
if (s1 == s2)
return (TRUE);
while (*s1 == *s2++)
if (*s1++ == '\0')
return (TRUE);
return (FALSE);
}
@@ -0,0 +1,59 @@
/* @(#)strlcat.c 1.1 10/04/26 Copyright 2010 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)strlcat.c 1.1 10/04/26 Copyright 2010 J. Schilling";
#endif
/*
* strlcat() to be used if missing in libc
*
* Copyright (c) 2010 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/standard.h>
#include <schily/unistd.h>
#include <schily/string.h>
#include <schily/libport.h>
#ifndef HAVE_STRLCAT
EXPORT size_t
strlcat(s1, s2, len)
register char *s1;
register const char *s2;
register size_t len;
{
const char *os1 = s1;
size_t olen = len;
if (len > 0) {
while (--len > 0 && *s1++ != '\0')
;
if (len == 0)
return (olen + strlen(s2));
s1--;
len++;
while (--len > 0 && (*s1++ = *s2++) != '\0')
;
if (len == 0) {
*s1 = '\0';
return (s1 - os1 + strlen(s2));
}
return (--s1 - os1);
}
return (strlen(s2));
}
#endif /* HAVE_STRLCAT */
@@ -0,0 +1,52 @@
/* @(#)strlcpy.c 1.4 09/07/08 Copyright 2006-2009 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)strlcpy.c 1.4 09/07/08 Copyright 2006-2009 J. Schilling";
#endif
/*
* strlcpy() to be used if missing in libc
*
* Copyright (c) 2006-2009 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/standard.h>
#include <schily/unistd.h>
#include <schily/libport.h>
#ifndef HAVE_STRLCPY
EXPORT size_t
strlcpy(s1, s2, len)
register char *s1;
register const char *s2;
register size_t len;
{
const char *os2 = s2;
if (len > 0) {
while (--len > 0 && (*s1++ = *s2++) != '\0')
;
if (len == 0) {
*s1 = '\0';
while (*s2++ != '\0')
;
}
} else {
while (*s2++ != '\0')
;
}
return (--s2 - os2);
}
#endif /* HAVE_STRLCPY */
@@ -0,0 +1,64 @@
/* @(#)uid.c 1.1 11/07/11 Copyright 2011 J. Schilling */
/*
* Dummy functions for uid handling, used e.g. on MINGW
*
* Copyright (c) 2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/types.h>
#include <schily/unistd.h>
#include <schily/standard.h>
#include <schily/schily.h>
#ifndef HAVE_GETUID
EXPORT uid_t
getuid()
{
return (0);
}
#endif
#ifndef HAVE_GETEUID
EXPORT uid_t
geteuid()
{
return (0);
}
#endif
#ifndef HAVE_SETUID
EXPORT int
setuid(uid)
uid_t uid;
{
return (0);
}
#endif
#ifndef HAVE_SETEUID
EXPORT int
seteuid(uid)
uid_t uid;
{
return (0);
}
#endif
@@ -0,0 +1,90 @@
/* @(#)zerobytes.c 1.2 11/07/30 Copyright Copyright 1987, 1995-2011 J. Schilling */
/*
* fill memory with null bytes
*
* Copyright (c) 1987, 1995-2011 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/standard.h>
#include <schily/align.h>
#include <schily/types.h>
#include <schily/schily.h>
#define DO8(a) a; a; a; a; a; a; a; a;
/*
* zero(to, cnt)
*/
EXPORT char *
zerobytes(tov, cnt)
void *tov;
ssize_t cnt;
{
register char *to = (char *)tov;
register ssize_t n;
register long lval = 0L;
/*
* If we change cnt to be unsigned, check for == instead of <=
*/
if ((n = cnt) <= 0)
return (to);
if (n < 8 * sizeof (long)) { /* Simple may be faster... */
do { /* n is always > 0 */
*to++ = '\0';
} while (--n > 0);
return (to);
}
/*
* Assign byte-wise until properly aligned for a long pointer.
*/
while (--n >= 0 && !laligned(to)) {
*to++ = '\0';
}
n++;
if (n >= (ssize_t)(8 * sizeof (long))) {
register ssize_t rem = n % (8 * sizeof (long));
n /= (8 * sizeof (long));
{
register long *tol = (long *)to;
do {
DO8 (*tol++ = lval);
} while (--n > 0);
to = (char *)tol;
}
n = rem;
if (n >= 8) {
n -= 8;
do {
DO8 (*to++ = '\0');
} while ((n -= 8) >= 0);
n += 8;
}
if (n > 0) do {
*to++ = '\0';
} while (--n > 0);
return (to);
}
if (n > 0) do {
*to++ = '\0';
} while (--n > 0);
return (to);
}
@@ -0,0 +1,551 @@
/* @(#)sic_nls.c 1.18 14/01/15 Copyright 2007-2014 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)sic_nls.c 1.18 14/01/15 Copyright 2007-2014 J. Schilling";
#endif
/*
* This code reads translation files in the format used by
* the Unicode Organization (www.unicode.org).
*
* The current implementation is only useful to create translations
* from single byte character sets to unicode.
* We use this code on systems that do not provide the iconv() function.
*
* Copyright 2007-2014 J. Schilling
*/
/*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* See the file CDDL.Schily.txt in this distribution for details.
* A copy of the CDDL is also available via the Internet at
* http://www.opensource.org/licenses/cddl1.txt
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file CDDL.Schily.txt from this distribution.
*/
#include <schily/stdio.h>
#include <schily/stdlib.h>
#include <schily/string.h>
#include <schily/libport.h> /* For strdup() */
#include <schily/unistd.h> /* For R_OK */
#include <schily/schily.h>
#include <schily/dirent.h>
#include <schily/siconv.h>
#define TAB_SIZE (UINT8_MAX+1)
#define __CAN_TAB_SIZE__
#ifndef PROTOTYPES
#undef __CAN_TAB_SIZE__
#endif
#if (!defined(__STDC__) || __STDC__ < 1) && \
!defined(__SUNPRO_C) /* Sun Compilers are OK even with __STDC__ 0 */
/*
* C-preprocessors from K&R compilers cannot do the computation for TAB_SIZE
* in the next line We need to disable this test in case of a K&R compiler.
*/
#undef __CAN_TAB_SIZE__
#endif
#ifdef __GNUC__
#if __GNUC__ < 2
#undef __CAN_TAB_SIZE__
#endif
#if __GNUC__ < 3 && __GNUC_MINOR__ < 95
#undef __CAN_TAB_SIZE__
#endif
#endif
#if defined(VMS) && !defined(__GNUC__)
#undef __CAN_TAB_SIZE__
#endif
#ifdef __CAN_TAB_SIZE__
#if TAB_SIZE < 256
Error Table size too small
#endif
#endif
LOCAL UInt8_t nullpage[TAB_SIZE] = { 0 };
LOCAL char *ins_base;
LOCAL siconvt_t *insert_sic __PR((siconvt_t *sip));
LOCAL int remove_sic __PR((siconvt_t *sip));
EXPORT siconvt_t *sic_open __PR((char *name));
EXPORT const char *sic_base __PR((void));
EXPORT int sic_close __PR((siconvt_t *sip));
EXPORT int sic_list __PR((FILE *f));
LOCAL void freetbl __PR((UInt8_t **uni2cs));
LOCAL FILE *pfopen __PR((char *name));
LOCAL siconvt_t *create_sic __PR((char *name));
#ifdef USE_ICONV
LOCAL siconvt_t *create_iconv_sic __PR((char *name));
LOCAL siconvt_t *dup_iconv_sic __PR((siconvt_t *sip));
#endif
/*
* Global list for translation tables
*/
LOCAL siconvt_t *glist = (siconvt_t *) NULL;
/*
* Insert a table into the global list and allow to reuse it
*/
LOCAL siconvt_t *
insert_sic(sip)
siconvt_t *sip;
{
siconvt_t **sp = &glist;
if (sip == (siconvt_t *)NULL) /* No table arg */
return ((siconvt_t *)NULL);
if (sip->sic_next) /* Already in list */
return (sip);
while (*sp) {
if (sip == *sp) { /* Already in list */
return (sip);
}
sp = &(*sp)->sic_next;
}
sip->sic_next = glist;
glist = sip;
return (sip);
}
/*
* Remove a table from the global list
*/
LOCAL int
remove_sic(sip)
siconvt_t *sip;
{
siconvt_t **sp = &glist;
while (*sp) {
#ifdef USE_ICONV
if (strcmp(sip->sic_name, (*sp)->sic_name) == 0) {
siconvt_t *sap = *sp;
if (sip == *sp) {
*sp = sip->sic_next;
return (0);
}
while (sap->sic_alt != NULL) {
if (sap->sic_alt == sip) {
sap->sic_alt = sip->sic_alt;
sip->sic_name = NULL; /* No free() */
return (0);
}
sap = sap->sic_alt;
}
}
#endif
if (sip == *sp) {
*sp = sip->sic_next;
return (0);
}
sp = &(*sp)->sic_next;
}
return (-1);
}
/*
* Open a new translation
*/
EXPORT siconvt_t *
sic_open(charset)
char *charset;
{
siconvt_t *sip = glist;
if (charset == NULL || *charset == '\0')
return ((siconvt_t *)NULL);
while (sip) {
if (strcmp(sip->sic_name, charset) == 0) {
#ifdef USE_ICONV
if (sip->sic_cd2uni != 0)
return (dup_iconv_sic(sip));
#endif
sip->sic_refcnt++;
return (sip);
}
sip = sip->sic_next;
}
return (create_sic(charset));
}
/*
* Open a new translation
*/
EXPORT const char *
sic_base()
{
if (ins_base == NULL) {
ins_base = searchfileinpath("lib/siconv/iso8859-1", R_OK,
SIP_PLAIN_FILE, NULL);
if (ins_base != NULL) {
int len = strlen(ins_base);
ins_base[len - 9] = '\0';
}
}
return (ins_base);
}
/*
* Close a translation
*/
EXPORT int
sic_close(sip)
siconvt_t *sip;
{
if (remove_sic(sip) < 0)
return (-1);
if (--sip->sic_refcnt > 0)
return (0);
if (sip->sic_name)
free(sip->sic_name);
if (sip->sic_uni2cs)
freetbl(sip->sic_uni2cs);
if (sip->sic_cs2uni)
free(sip->sic_cs2uni);
#ifdef USE_ICONV
if (sip->sic_cd2uni)
iconv_close(sip->sic_cd2uni);
if (sip->sic_uni2cd)
iconv_close(sip->sic_uni2cd);
#endif
return (0);
}
/*
* List all possible translation files in the install directory.
*/
EXPORT int
sic_list(f)
FILE *f;
{
char path[1024];
DIR *d;
struct dirent *dp;
int i = 0;
if (ins_base == NULL)
(void) sic_base();
if (ins_base != NULL)
snprintf(path, sizeof (path), "%s", ins_base);
else
snprintf(path, sizeof (path), "%s/lib/siconv/", INS_BASE);
if ((d = opendir(path)) == NULL)
return (-1);
while ((dp = readdir(d)) != NULL) {
if (dp->d_name[0] == '.') {
if (dp->d_name[1] == '\0')
continue;
if (dp->d_name[1] == '.' && dp->d_name[2] == '\0')
continue;
}
fprintf(f, "%s\n", dp->d_name);
i++;
}
return (i);
}
/*
* Free a reverse (uncode -> char) translation table
*/
LOCAL void
freetbl(uni2cs)
UInt8_t **uni2cs;
{
int i;
for (i = 0; i < TAB_SIZE; i++) {
if (uni2cs[i] != nullpage) {
free(uni2cs[i]);
}
}
free(uni2cs);
}
/*
* Search a tranlation table, first in the current directory and then
* in the install directory.
*/
LOCAL FILE *
pfopen(name)
char *name;
{
char path[1024];
char *p;
if (strchr(name, '/'))
return (fopen(name, "r"));
if (ins_base == NULL)
(void) sic_base();
p = ins_base;
if (p != NULL) {
snprintf(path, sizeof (path), "%s%s", p, name);
return (fopen(path, "r"));
}
snprintf(path, sizeof (path), "%s/lib/siconv/%s", INS_BASE, name);
return (fopen(path, "r"));
}
/*
* Create a new translation either from a file or from iconv_open()
*/
LOCAL siconvt_t *
create_sic(name)
char *name;
{
UInt16_t *cs2uni = NULL;
UInt8_t **uni2cs = NULL;
siconvt_t *sip;
char line[1024];
FILE *f;
unsigned ch;
unsigned uni;
int i;
int numtrans = 0;
if (name == NULL || *name == '\0')
return ((siconvt_t *)NULL);
#ifdef USE_ICONV
/*
* Explicitly search for an iconv based translation
*/
if (strncmp("iconv:", name, 6) == 0) {
return (create_iconv_sic(name));
}
#else
if (strncmp("iconv:", name, 6) == 0) {
return ((siconvt_t *)NULL);
}
#endif
if ((f = pfopen(name)) == (FILE *)NULL) {
if (strcmp(name, "default") == 0) {
if ((cs2uni = (UInt16_t *)
malloc(sizeof (UInt16_t) * TAB_SIZE)) == NULL) {
return ((siconvt_t *)NULL);
}
/*
* Set up a 1:1 translation table like ISO-8859-1
*/
for (i = 0; i < TAB_SIZE; i++)
cs2uni[i] = i;
goto do_reverse;
}
#ifdef USE_ICONV
return (create_iconv_sic(name));
#else
return ((siconvt_t *)NULL);
#endif
}
if ((cs2uni = (UInt16_t *)
malloc(sizeof (UInt16_t) * TAB_SIZE)) == NULL) {
fclose(f);
return ((siconvt_t *)NULL);
}
/*
* Set up mapping base.
* Always map the control characters 0x00 .. 0x1F
*/
for (i = 0; i < 32; i++)
cs2uni[i] = i;
for (i = 32; i < TAB_SIZE; i++)
cs2uni[i] = '\0'; /* nul marks an illegal character */
cs2uni[0x7f] = 0x7F; /* Always map DELETE character 0x7F */
while (fgets(line, sizeof (line), f) != NULL) {
char *p;
if ((p = strchr(line, '#')) != NULL)
*p = '\0';
if (sscanf(line, "%x%x", &ch, &uni) == 2) {
/*
* Only accept exactly two values in the right range.
*/
if (ch > 0xFF || uni > 0xFFFF)
continue;
cs2uni[ch] = uni; /* Set up unicode translation */
numtrans++;
}
}
fclose(f);
if (numtrans == 0) { /* No valid translations found */
free(cs2uni);
return ((siconvt_t *)NULL);
}
do_reverse:
if ((uni2cs = (UInt8_t **)
malloc(sizeof (unsigned char *) * TAB_SIZE)) == NULL) {
free(cs2uni);
return ((siconvt_t *)NULL);
}
for (i = 0; i < TAB_SIZE; i++) /* Map all pages to the nullpage */
uni2cs[i] = nullpage;
/*
* Create a reversed table from the forward table read from the file.
*/
for (i = 0; i < TAB_SIZE; i++) {
UInt8_t high;
UInt8_t low;
UInt8_t *page;
uni = cs2uni[i];
high = (uni >> 8) & 0xFF;
low = uni & 0xFF;
page = uni2cs[high];
if (page == nullpage) {
int j;
/*
* Do not write to the nullpage but replace it by
* new and specific memory.
*/
if ((page = (UInt8_t *) malloc(TAB_SIZE)) == NULL) {
free(cs2uni);
freetbl(uni2cs);
return ((siconvt_t *)NULL);
}
for (j = 0; j < TAB_SIZE; j++)
page[j] = '\0';
uni2cs[high] = page;
}
page[low] = i; /* Set up the reverse translation */
}
if ((sip = (siconvt_t *)malloc(sizeof (siconvt_t))) == NULL) {
free(cs2uni);
freetbl(uni2cs);
return ((siconvt_t *)NULL);
}
sip->sic_name = strdup(name);
sip->sic_uni2cs = uni2cs;
sip->sic_cs2uni = cs2uni;
sip->sic_cd2uni = NULL;
sip->sic_uni2cd = NULL;
sip->sic_alt = NULL;
sip->sic_next = NULL;
sip->sic_refcnt = 1;
return (insert_sic(sip));
}
#ifdef USE_ICONV
/*
* Create a new translation from iconv_open()
*/
LOCAL siconvt_t *
create_iconv_sic(name)
char *name;
{
siconvt_t *sip;
iconv_t to;
iconv_t from;
char *nm;
/*cerror("init_unls_iconv(%s)\n", name);*/
if (name == NULL || *name == '\0')
return ((siconvt_t *)NULL);
nm = name;
if (strncmp("iconv:", name, 6) == 0)
nm = &name[6];
if ((sip = (siconvt_t *)malloc(sizeof (siconvt_t)))
== NULL) {
return ((siconvt_t *)NULL);
}
if ((from = iconv_open("UCS-2BE", nm)) == (iconv_t)-1) {
free(sip);
return ((siconvt_t *)NULL);
}
if ((to = iconv_open(nm, "UCS-2BE")) == (iconv_t)-1) {
free(sip);
iconv_close(from);
return ((siconvt_t *)NULL);
}
sip->sic_name = strdup(name);
sip->sic_uni2cs = NULL;
sip->sic_cs2uni = NULL;
sip->sic_cd2uni = from;
sip->sic_uni2cd = to;
sip->sic_alt = NULL;
sip->sic_next = NULL;
sip->sic_refcnt = 1;
return (insert_sic(sip));
}
/*
* As the iconv conversion is stateful, we need to create a new translation
* if we like to get the same translation again.
*/
LOCAL siconvt_t *
dup_iconv_sic(sip)
siconvt_t *sip;
{
siconvt_t *sp;
iconv_t to;
iconv_t from;
char *nm;
if ((sp = (siconvt_t *)malloc(sizeof (siconvt_t)))
== NULL) {
return ((siconvt_t *)NULL);
}
nm = sip->sic_name;
if (strncmp("iconv:", nm, 6) == 0)
nm = &nm[6];
if ((from = iconv_open("UCS-2BE", nm)) == (iconv_t)-1) {
free(sp);
return ((siconvt_t *)NULL);
}
if ((to = iconv_open(nm, "UCS-2BE")) == (iconv_t)-1) {
free(sp);
iconv_close(from);
return ((siconvt_t *)NULL);
}
sp->sic_name = sip->sic_name; /* Allow to compare name pointers */
sp->sic_uni2cs = NULL;
sp->sic_cs2uni = NULL;
sp->sic_cd2uni = from;
sp->sic_uni2cd = to;
sp->sic_alt = NULL;
sp->sic_next = NULL;
sp->sic_refcnt = 1;
sip->sic_alt = sp;
return (sp);
}
#endif /* USE_UNLS */
@@ -0,0 +1,542 @@
/* @(#)boot.c 1.28 16/10/23 Copyright 1999-2016 J. Schilling */
#include <schily/mconfig.h>
#ifndef lint
static UConst char sccsid[] =
"@(#)boot.c 1.28 16/10/23 Copyright 1999-2016 J. Schilling";
#endif
/*
* Support for generic boot (sector 0..16)
* and to boot Sun sparc and Sun x86 systems.
*
* Copyright (c) 1999-2016 J. Schilling
*/
/*@@C@@*/
#include "mkisofs.h"
#include <schily/fcntl.h>
#include <schily/utypes.h>
#include <schily/intcvt.h>
#include <schily/schily.h>
#include "sunlabel.h"
extern int use_sunx86boot;
LOCAL struct sun_label cd_label;
LOCAL struct x86_label sx86_label;
LOCAL struct pc_part fdisk_part;
LOCAL char *boot_files[NDKMAP]; /* Change this for > 8 x86 parts */
LOCAL void init_sparc_label __PR((void));
LOCAL void init_sunx86_label __PR((void));
EXPORT int sparc_boot_label __PR((char *label));
EXPORT int sunx86_boot_label __PR((char *label));
EXPORT int scan_sparc_boot __PR((char *files));
EXPORT int scan_sunx86_boot __PR((char *files));
EXPORT int make_sun_label __PR((void));
EXPORT int make_sunx86_label __PR((void));
LOCAL void dup_sun_label __PR((int part));
LOCAL int sunboot_write __PR((FILE *outfile));
LOCAL int sunlabel_size __PR((UInt32_t starting_extent));
LOCAL int sunlabel_write __PR((FILE *outfile));
LOCAL int genboot_size __PR((UInt32_t starting_extent));
LOCAL int genboot_write __PR((FILE *outfile));
/*
* Set the virtual geometry in the disk label.
* If we like to make the geometry variable, we may change
* dkl_ncyl and dkl_pcyl later.
*/
LOCAL void
init_sparc_label()
{
i_to_4_byte(cd_label.dkl_vtoc.v_version, V_VERSION);
i_to_2_byte(cd_label.dkl_vtoc.v_nparts, NDKMAP);
i_to_4_byte(cd_label.dkl_vtoc.v_sanity, VTOC_SANE);
i_to_2_byte(cd_label.dkl_rpm, CD_RPM);
i_to_2_byte(cd_label.dkl_pcyl, CD_PCYL);
i_to_2_byte(cd_label.dkl_apc, CD_APC);
i_to_2_byte(cd_label.dkl_intrlv, CD_INTRLV);
i_to_2_byte(cd_label.dkl_ncyl, CD_NCYL);
i_to_2_byte(cd_label.dkl_acyl, CD_ACYL);
i_to_2_byte(cd_label.dkl_nhead, CD_NHEAD);
i_to_2_byte(cd_label.dkl_nsect, CD_NSECT);
cd_label.dkl_magic[0] = DKL_MAGIC_0;
cd_label.dkl_magic[1] = DKL_MAGIC_1;
}
LOCAL void
init_sunx86_label()
{
li_to_4_byte(sx86_label.dkl_vtoc.v_sanity, VTOC_SANE);
li_to_4_byte(sx86_label.dkl_vtoc.v_version, V_VERSION);
li_to_2_byte(sx86_label.dkl_vtoc.v_sectorsz, 512);
li_to_2_byte(sx86_label.dkl_vtoc.v_nparts, NX86MAP);
li_to_4_byte(sx86_label.dkl_pcyl, CD_PCYL);
li_to_4_byte(sx86_label.dkl_ncyl, CD_NCYL);
li_to_2_byte(sx86_label.dkl_acyl, CD_ACYL);
li_to_2_byte(sx86_label.dkl_bcyl, 0);
li_to_4_byte(sx86_label.dkl_nhead, CD_NHEAD);
li_to_4_byte(sx86_label.dkl_nsect, CD_NSECT);
li_to_2_byte(sx86_label.dkl_intrlv, CD_INTRLV);
li_to_2_byte(sx86_label.dkl_skew, 0);
li_to_2_byte(sx86_label.dkl_apc, CD_APC);
li_to_2_byte(sx86_label.dkl_rpm, CD_RPM);
li_to_2_byte(sx86_label.dkl_write_reinstruct, 0);
li_to_2_byte(sx86_label.dkl_read_reinstruct, 0);
li_to_2_byte(sx86_label.dkl_magic, DKL_MAGIC);
}
/*
* For command line parser: set ASCII label.
*/
EXPORT int
sparc_boot_label(label)
char *label;
{
strncpy(cd_label.dkl_ascilabel, label, 127);
cd_label.dkl_ascilabel[127] = '\0';
return (1);
}
EXPORT int
sunx86_boot_label(label)
char *label;
{
strncpy(sx86_label.dkl_vtoc.v_asciilabel, label, 127);
sx86_label.dkl_vtoc.v_asciilabel[127] = '\0';
return (1);
}
/*
* Parse the command line argument for boot images.
*/
EXPORT int
scan_sparc_boot(files)
char *files;
{
char *p;
int i = 1;
struct stat statbuf;
int status;
extern int use_sparcboot;
extern int use_sunx86boot;
if (use_sunx86boot)
comerrno(EX_BAD,
_("-sparc-boot and -sunx86-boot are mutual exclusive.\n"));
use_sparcboot++;
init_sparc_label();
do {
if (i >= NDKMAP)
comerrno(EX_BAD, _("Too many boot partitions.\n"));
boot_files[i++] = files;
if ((p = strchr(files, ',')) != NULL)
*p++ = '\0';
files = p;
} while (p);
i_to_2_byte(cd_label.dkl_vtoc.v_part[0].p_tag, V_USR);
i_to_2_byte(cd_label.dkl_vtoc.v_part[0].p_flag, V_RONLY);
for (i = 0; i < NDKMAP; i++) {
p = boot_files[i];
if (p == NULL || *p == '\0')
continue;
if (strcmp(p, "...") == '\0')
break;
status = stat_filter(p, &statbuf);
if (status < 0 || access(p, R_OK) < 0)
comerr(_("Cannot access '%s'.\n"), p);
i_to_4_byte(cd_label.dkl_map[i].dkl_nblk,
roundup(statbuf.st_size, CD_CYLSIZE)/512);
i_to_2_byte(cd_label.dkl_vtoc.v_part[i].p_tag, V_ROOT);
i_to_2_byte(cd_label.dkl_vtoc.v_part[i].p_flag, V_RONLY);
}
return (1);
}
EXPORT int
scan_sunx86_boot(files)
char *files;
{
char *p;
int i = 0;
struct stat statbuf;
int status;
extern int use_sparcboot;
extern int use_sunx86boot;
if (use_sparcboot)
comerrno(EX_BAD,
_("-sparc-boot and -sunx86-boot are mutual exclusive.\n"));
use_sunx86boot++;
init_sunx86_label();
do {
if (i >= NDKMAP)
comerrno(EX_BAD, _("Too many boot partitions.\n"));
boot_files[i++] = files;
if ((p = strchr(files, ',')) != NULL)
*p++ = '\0';
files = p;
} while (p);
li_to_2_byte(sx86_label.dkl_vtoc.v_part[0].p_tag, V_ROOT); /* UFS */
li_to_2_byte(sx86_label.dkl_vtoc.v_part[0].p_flag, V_RONLY);
li_to_2_byte(sx86_label.dkl_vtoc.v_part[1].p_tag, V_USR); /* ISO */
li_to_2_byte(sx86_label.dkl_vtoc.v_part[1].p_flag, V_RONLY);
li_to_2_byte(sx86_label.dkl_vtoc.v_part[2].p_tag, 0); /* ALL */
li_to_2_byte(sx86_label.dkl_vtoc.v_part[2].p_flag, 0);
for (i = 0; i < NDKMAP; i++) {
p = boot_files[i];
if (p == NULL || *p == '\0')
continue;
if (i == 1 || i == 2) {
comerrno(EX_BAD,
_("Partition %d may not have a filename.\n"), i);
}
status = stat_filter(p, &statbuf);
if (status < 0 || access(p, R_OK) < 0)
comerr(_("Cannot access '%s'.\n"), p);
li_to_4_byte(sx86_label.dkl_vtoc.v_part[i].p_size,
roundup(statbuf.st_size, CD_CYLSIZE)/512);
if (i > 2) {
li_to_2_byte(sx86_label.dkl_vtoc.v_part[i].p_tag, V_USR);
li_to_2_byte(sx86_label.dkl_vtoc.v_part[i].p_flag, V_RONLY);
}
}
return (1);
}
/*
* Finish the Sun disk label and compute the size of the additional data.
*/
EXPORT int
make_sun_label()
{
int last;
int cyl = 0;
int nblk;
int bsize;
int i;
char *p;
/*
* Compute the size of the padding for the iso9660 image
* to allow the next partition to start on a cylinder boundary.
*/
last = roundup(last_extent, (CD_CYLSIZE/SECTOR_SIZE));
i_to_4_byte(cd_label.dkl_map[0].dkl_nblk, last*4);
bsize = 0;
for (i = 0; i < NDKMAP; i++) {
p = boot_files[i];
if (p != NULL && strcmp(p, "...") == '\0') {
dup_sun_label(i);
break;
}
if ((nblk = a_to_4_byte(cd_label.dkl_map[i].dkl_nblk)) == 0)
continue;
i_to_4_byte(cd_label.dkl_map[i].dkl_cylno, cyl);
cyl += nblk / (CD_CYLSIZE/512);
if (i > 0)
bsize += nblk;
}
bsize /= 4;
return (last-last_extent+bsize);
}
/*
* A typical Solaris boot/install CD from a Sun CD set looks
* this way:
*
* UFS Part 0 tag 2 flag 10 start 3839 size 1314560
* ISO Part 1 tag 4 flag 10 start 0 size 3839
* ALL Part 2 tag 0 flag 0 start 0 size 1318400
*/
EXPORT int
make_sunx86_label()
{
int last;
int cyl = 0;
int nblk;
int bsize;
int i;
int partoff = 1; /* The offset of the Solaris 0x82 partition */
/*
* Compute the size of the padding for the iso9660 image
* to allow the next partition to start on a cylinder boundary.
*/
last = roundup(last_extent, (CD_CYLSIZE/SECTOR_SIZE));
li_to_4_byte(sx86_label.dkl_vtoc.v_part[1].p_size, last*4);
/*
* Note that the Solaris fdisk partition with fdisk signature 0x82
* is created at fixed offset 1 sector == 512 Bytes by this
* implementation.
* We need subtract this partition offset from all absolute
* partition offsets in order to get offsets relative to the
* Solaris primary partition.
*/
bsize = 0;
for (i = 0; i < NDKMAP; i++) {
if (i == 2) /* Never include the whole disk in */
continue; /* size/offset computations */
if ((nblk = la_to_4_byte(sx86_label.dkl_vtoc.v_part[i].p_size)) == 0)
continue;
li_to_4_byte(sx86_label.dkl_vtoc.v_part[i].p_start,
cyl*(CD_CYLSIZE/512)-partoff);
cyl += nblk / (CD_CYLSIZE/512);
if (i == 0 || i > 2)
bsize += nblk;
}
li_to_4_byte(sx86_label.dkl_vtoc.v_part[0].p_start, last*4-partoff);
li_to_4_byte(sx86_label.dkl_vtoc.v_part[1].p_start, 0);
li_to_4_byte(sx86_label.dkl_vtoc.v_part[1].p_size, last*4-partoff);
li_to_4_byte(sx86_label.dkl_vtoc.v_part[2].p_start, 0);
li_to_4_byte(sx86_label.dkl_vtoc.v_part[2].p_size, last*4+bsize);
fdisk_part.part[0].pr_status = STATUS_ACTIVE;
fdisk_part.part[0].pr_type = TYPE_SOLARIS;
li_to_4_byte(fdisk_part.part[0].pr_partoff, partoff);
li_to_4_byte(fdisk_part.part[0].pr_nsect, last*4+bsize-partoff);
fdisk_part.magic[0] = 0x55;
fdisk_part.magic[1] = 0xAA;
bsize /= 4;
return (last-last_extent+bsize);
}
/*
* Duplicate a partition of the Sun disk label until all partitions are filled up.
*/
LOCAL void
dup_sun_label(part)
int part;
{
int cyl;
int nblk;
int i;
if (part < 1 || part >= NDKMAP)
part = 1;
cyl = a_to_4_byte(cd_label.dkl_map[part-1].dkl_cylno);
nblk = a_to_4_byte(cd_label.dkl_map[part-1].dkl_nblk);
for (i = part; i < NDKMAP; i++) {
i_to_4_byte(cd_label.dkl_map[i].dkl_cylno, cyl);
i_to_4_byte(cd_label.dkl_map[i].dkl_nblk, nblk);
i_to_2_byte(cd_label.dkl_vtoc.v_part[i].p_tag, V_ROOT);
i_to_2_byte(cd_label.dkl_vtoc.v_part[i].p_flag, V_RONLY);
}
}
/*
* Write out Sun boot partitions.
*/
LOCAL int
sunboot_write(outfile)
FILE *outfile;
{
char buffer[SECTOR_SIZE];
int i;
int n;
int nblk;
int amt;
int f;
char *p;
memset(buffer, 0, sizeof (buffer));
/*
* Write padding to the iso9660 image to allow the
* boot partitions to start on a cylinder boundary.
*/
amt = roundup(last_extent_written, (CD_CYLSIZE/SECTOR_SIZE)) - last_extent_written;
for (n = 0; n < amt; n++) {
xfwrite(buffer, SECTOR_SIZE, 1, outfile, 0, FALSE);
last_extent_written++;
}
if (use_sunx86boot)
i = 0;
else
i = 1;
for (; i < NDKMAP; i++) {
if (use_sunx86boot && (i == 1 || i == 2))
continue;
p = boot_files[i];
if (p == NULL || *p == '\0')
continue;
if (p != NULL && strcmp(p, "...") == '\0')
break;
if (use_sunx86boot) {
if ((nblk = la_to_4_byte(sx86_label.dkl_vtoc.v_part[i].p_size)) == 0)
continue;
} else {
if ((nblk = a_to_4_byte(cd_label.dkl_map[i].dkl_nblk)) == 0)
continue;
}
if ((f = open(boot_files[i], O_RDONLY| O_BINARY)) < 0)
comerr(_("Cannot open '%s'.\n"), boot_files[i]);
amt = nblk / 4;
for (n = 0; n < amt; n++) {
memset(buffer, 0, sizeof (buffer));
if (read(f, buffer, SECTOR_SIZE) < 0)
comerr(_("Read error on '%s'.\n"), boot_files[i]);
xfwrite(buffer, SECTOR_SIZE, 1, outfile, 0, FALSE);
last_extent_written++;
}
close(f);
}
fprintf(stderr, _("Total extents including %s boot = %u\n"),
use_sunx86boot ? "Solaris x86":"sparc",
last_extent_written - session_start);
return (0);
}
/*
* Do size management for the Sun disk label that is located in the first
* sector of a disk.
*/
LOCAL int
sunlabel_size(starting_extent)
UInt32_t starting_extent;
{
if (last_extent != session_start)
comerrno(EX_BAD, _("Cannot create sparc boot on offset != 0.\n"));
last_extent++;
return (0);
}
/*
* Compute the checksum and write a Sun disk label to the first sector
* of the disk.
* If the -generic-boot option has been specified too, overlay the
* Sun disk label on the first 512 bytes of the generic boot code.
*/
LOCAL int
sunlabel_write(outfile)
FILE *outfile;
{
char buffer[SECTOR_SIZE];
register char *p;
register short count = (512/2) - 1;
int f;
memset(buffer, 0, sizeof (buffer));
if (genboot_image) {
if ((f = open(genboot_image, O_RDONLY| O_BINARY)) < 0)
comerr(_("Cannot open '%s'.\n"), genboot_image);
if (read(f, buffer, SECTOR_SIZE) < 0)
comerr(_("Read error on '%s'.\n"), genboot_image);
close(f);
}
if (use_sunx86boot) {
if (sx86_label.dkl_vtoc.v_asciilabel[0] == '\0')
strcpy(sx86_label.dkl_vtoc.v_asciilabel, CD_X86LABEL);
p = (char *)&sx86_label;
sx86_label.dkl_cksum[0] = 0;
sx86_label.dkl_cksum[1] = 0;
while (count-- > 0) {
sx86_label.dkl_cksum[0] ^= *p++;
sx86_label.dkl_cksum[1] ^= *p++;
}
memcpy(&buffer[0x1BE], fdisk_part.part, sizeof (fdisk_part.part));
p = &buffer[510];
*p++ = 0x55;
*p = 0xAA;
memcpy(&buffer[1024], &sx86_label, 512);
} else {
/*
* If we don't already have a Sun disk label text
* set up the default.
*/
if (cd_label.dkl_ascilabel[0] == '\0')
strcpy(cd_label.dkl_ascilabel, CD_DEFLABEL);
p = (char *)&cd_label;
cd_label.dkl_cksum[0] = 0;
cd_label.dkl_cksum[1] = 0;
while (count--) {
cd_label.dkl_cksum[0] ^= *p++;
cd_label.dkl_cksum[1] ^= *p++;
}
memcpy(buffer, &cd_label, 512);
}
xfwrite(buffer, SECTOR_SIZE, 1, outfile, 0, FALSE);
last_extent_written++;
return (0);
}
/*
* Do size management for the generic boot code on sectors 0..16.
*/
LOCAL int
genboot_size(starting_extent)
UInt32_t starting_extent;
{
if (last_extent > (session_start + 1))
comerrno(EX_BAD, _("Cannot create generic boot on offset != 0.\n"));
last_extent = session_start + 16;
return (0);
}
/*
* Write the generic boot code to sectors 0..16.
* If there is a Sun disk label, start writing at sector 1.
*/
LOCAL int
genboot_write(outfile)
FILE *outfile;
{
char buffer[SECTOR_SIZE];
int i;
int f;
if ((f = open(genboot_image, O_RDONLY| O_BINARY)) < 0)
comerr(_("Cannot open '%s'.\n"), genboot_image);
for (i = 0; i < 16; i++) {
memset(buffer, 0, sizeof (buffer));
if (read(f, buffer, SECTOR_SIZE) < 0)
comerr(_("Read error on '%s'.\n"), genboot_image);
if (i != 0 || last_extent_written == session_start) {
xfwrite(buffer, SECTOR_SIZE, 1, outfile, 0, FALSE);
last_extent_written++;
}
}
close(f);
return (0);
}
struct output_fragment sunboot_desc = {NULL, NULL, NULL, sunboot_write, "Sun Boot" };
struct output_fragment sunlabel_desc = {NULL, sunlabel_size, NULL, sunlabel_write, "Sun Disk Label" };
struct output_fragment genboot_desc = {NULL, genboot_size, NULL, genboot_write, "Generic Boot" };
@@ -0,0 +1,34 @@
/* @(#)bootinfo.h 1.3 04/03/02 Copyright 1999, 2004 J. Schilling */
/*
* Header file bootinfo.h - mkisofs-defined boot information table
* useful for an El Torito-loaded disk image.
*
* Copyright (c) 1999, 2004 J. Schilling
*/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; see the file COPYING. If not, write to the Free Software
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _BOOTINFO_H
#define _BOOTINFO_H
struct mkisofs_boot_info {
char bi_pvd [ISODCL(1, 4)]; /* LBA of PVD */
char bi_file [ISODCL(5, 8)]; /* LBA of boot image */
char bi_length [ISODCL(9, 12)]; /* Length of boot image */
char bi_csum [ISODCL(13, 16)]; /* Checksum of boot image */
char bi_reserved [ISODCL(17, 56)]; /* Reserved */
};
#endif /* _BOOTINFO_H */
@@ -0,0 +1,150 @@
/* @(#)defaults.h 1.25 13/02/14 joerg */
/*
* Header file defaults.h - assorted default values for character strings in
* the volume descriptor.
*
* Copyright (c) 1999-2013 J. Schilling
*/
#define PREPARER_DEFAULT NULL
#define PUBLISHER_DEFAULT NULL
#ifndef APPID_DEFAULT
#ifdef APPLE_HYB
#define APPID_DEFAULT "MKISOFS ISO9660/HFS/UDF FILESYSTEM BUILDER (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING"
#else
#define APPID_DEFAULT "MKISOFS ISO9660/UDF FILESYSTEM BUILDER (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING"
#endif /* APPLE_HYB */
#endif
#define COPYRIGHT_DEFAULT NULL
#define BIBLIO_DEFAULT NULL
#define ABSTRACT_DEFAULT NULL
#define VOLSET_ID_DEFAULT NULL
#define VOLUME_ID_DEFAULT "CDROM"
#define BOOT_CATALOG_DEFAULT "boot.catalog"
#define BOOT_IMAGE_DEFAULT NULL
#ifdef APPLE_HYB
#define APPLE_TYPE_DEFAULT "TEXT"
#define APPLE_CREATOR_DEFAULT "unix"
#endif /* APPLE_HYB */
#ifdef __QNX__
#define SYSTEM_ID_DEFAULT "QNX"
#endif
#ifdef __osf__
#define SYSTEM_ID_DEFAULT "OSF"
#endif
#ifdef __sun
#ifdef __SVR4
#define SYSTEM_ID_DEFAULT "Solaris"
#else
#define SYSTEM_ID_DEFAULT "SunOS"
#endif
#endif
#ifdef __hpux
#define SYSTEM_ID_DEFAULT "HP-UX"
#endif
#ifdef __sgi
#define SYSTEM_ID_DEFAULT "SGI"
#endif
#if defined(_IBMR2) || defined(_AIX)
#define SYSTEM_ID_DEFAULT "AIX"
#endif
#if defined(_WIN) || defined(__CYGWIN32__) || defined(__CYGWIN__)
#define SYSTEM_ID_DEFAULT "Win32"
#endif /* _WIN */
#if !defined(SYSTEM_ID_DEFAULT) && defined(__MINGW32__)
#define SYSTEM_ID_DEFAULT "Win32/MinGW"
#endif /* __MINGW32__ */
#ifdef __EMX__
#define SYSTEM_ID_DEFAULT "OS/2"
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define SYSTEM_ID_DEFAULT "FreeBSD"
#endif
#ifdef __DragonFly__
#define SYSTEM_ID_DEFAULT "DragonFly"
#endif
#ifdef __NetBSD__
#define SYSTEM_ID_DEFAULT "NetBSD"
#endif
#ifdef __OpenBSD__
#define SYSTEM_ID_DEFAULT "OpenBSD"
#endif
#ifdef __bsdi__
#define SYSTEM_ID_DEFAULT "BSD/OS"
#endif
#ifdef __NeXT__
#define SYSTEM_ID_DEFAULT "NeXT"
#endif
#if defined(__NeXT__) && defined(__TARGET_OSNAME) && __TARGET_OSNAME == rhapsody
#undef SYSTEM_ID_DEFAULT
#define SYSTEM_ID_DEFAULT "Rhapsody"
#endif
#if defined(__APPLE__) && defined(__MACH__)
#undef SYSTEM_ID_DEFAULT
#define SYSTEM_ID_DEFAULT "Mac OS X"
#endif
#ifdef __BEOS__
#define SYSTEM_ID_DEFAULT "BeOS"
#endif
#ifdef __HAIKU__
#define SYSTEM_ID_DEFAULT "Haiku"
#endif
#ifdef __OS2
#define SYSTEM_ID_DEFAULT "OS/2"
#endif
#ifdef VMS
#define SYSTEM_ID_DEFAULT "VMS"
#endif
#ifdef OPENSERVER
#define SYSTEM_ID_DEFAULT "SCO-OPENSERVER"
#endif
#ifdef UNIXWARE
#define SYSTEM_ID_DEFAULT "SCO-UNIXWARE"
#endif
#ifdef linux
#define SYSTEM_ID_DEFAULT "LINUX"
#endif
#ifdef __DJGPP__
#define SYSTEM_ID_DEFAULT "DOS"
#endif
#ifdef __MINT__
#define SYSTEM_ID_DEFAULT "ATARI-MiNT"
#endif
#ifdef __SYLLABLE__
#define SYSTEM_ID_DEFAULT "Syllable"
#endif
#ifdef AMIGA
#define SYSTEM_ID_DEFAULT "AMIGA"
#endif
#ifndef SYSTEM_ID_DEFAULT
#define SYSTEM_ID_DEFAULT "UNIX"
#endif

Some files were not shown because too many files have changed in this diff Show More