diff options
31 files changed, 346 insertions, 163 deletions
diff --git a/COPYING.SOFORT b/COPYING.SOFORT index 4880eec..1c8a6c1 100644 --- a/COPYING.SOFORT +++ b/COPYING.SOFORT @@ -2,7 +2,7 @@ /* */ /* sofort: portable software project skeleton */ /* */ -/* Copyright (C) 2015--2021 Z. Gilboa */ +/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */ /* */ /* sofort provides a build system that can be incorporated into Works */ /* which may or may not be covered by a copyleft license. THE FOLLOWING */ diff --git a/COPYING.TPAX b/COPYING.TPAX index 3521193..d145097 100644 --- a/COPYING.TPAX +++ b/COPYING.TPAX @@ -2,7 +2,7 @@ /* */ /* tpax: a topological pax implementation */ /* */ -/* Copyright (C) 2020 Z. Gilboa */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ /* */ /* This program is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ diff --git a/Makefile.in b/Makefile.in index 4e0f9e9..5ad6ff0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -84,7 +84,6 @@ CFLAGS_DEBUG += @cflags_debug@ CFLAGS_CMDLINE += @cflags_cmdline@ CFLAGS_CONFIG += @cflags_config@ CFLAGS_SYSROOT += @cflags_sysroot@ -CFLAGS_OS += @cflags_os@ CFLAGS_SITE += @cflags_site@ CFLAGS_PATH += @cflags_path@ CFLAGS_STRICT += @cflags_strict@ diff --git a/config.project b/config.project index bef65ae..50fa4c2 100644 --- a/config.project +++ b/config.project @@ -42,7 +42,7 @@ mb_hosted= mb_freestanding= # switches -mb_default_cflags_common="\$(_CFLAGS_std_c99) -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D__BSD_VISIBLE" +mb_default_cflags_common="\$(_CFLAGS_std_c99) -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE" mb_default_cflags_common="$mb_default_cflags_common -I\$(SOURCE_DIR)/src/internal" mb_default_cflags_common="$mb_default_cflags_common -I\$(SOURCE_DIR)/include" mb_default_cflags_common="$mb_default_cflags_common -Ibuild" diff --git a/config.usage b/config.usage index 33d1e58..41fe629 100644 --- a/config.usage +++ b/config.usage @@ -143,7 +143,7 @@ supported variables: TOOLCHAIN SYSROOT CROSS_COMPILE - SHELL + CONFIG_SHELL PKGCONF PKGCONFIG @@ -33,7 +33,12 @@ usage() " ___________________________________________" \ "__________________________________" - cat "$mb_project_dir"/project/config/cfgdefs.usage + if [ -f "$mb_project_dir"/project/config/cfgdefs.usage ]; then + cat "$mb_project_dir"/project/config/cfgdefs.usage + else + printf '%s\n\n' \ + "[ info: this project does not provide a project-specific cfgdefs.usage file. ]" + fi fi exit 0 @@ -275,7 +280,7 @@ init_vars() mb_toolchain=$TOOLCHAIN mb_sysroot=$SYSROOT mb_cross_compile=$CROSS_COMPILE - mb_shell=$SHELL + mb_shell=$CONFIG_SHELL # pkgconf mb_pkgconf=$PKGCONF @@ -713,7 +718,7 @@ config_flags() # ccstrict if [ _$mb_ccstrict = _yes ]; then - mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef)' + mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef) $(_CFLAGS_Wpedantic)' fi # ldstrict @@ -842,26 +847,9 @@ config_ccenv() error_msg "${mb_pretty} forcing native mode when cross-building is strictly prohibited." fi - # add the include and library directories to the compiler and linker search path - if [ "$mb_cchost" = "$mb_native_cchost" ]; then - mb_cflags_last="$mb_cflags_last -I$mb_includedir" - mb_ldflags_last="$mb_ldflags_last -L$mb_libdir" - else - case "$mb_libdir" in - /*) - mb_cflags_last="$mb_cflags_last -I$mb_sysroot/.$mb_includedir" - mb_ldflags_last="$mb_ldflags_last -L$mb_sysroot/.$mb_libdir" - ;; - *) - mb_cflags_last="$mb_cflags_last -I$mb_includedir" - mb_ldflags_last="$mb_ldflags_last -L$mb_libdir" - esac - fi - # re-generate Makefile.tmp output_section_break config_copy - } config_custom_cfgdefs() @@ -944,7 +932,7 @@ config_host() mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding" mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib" else - printf 'int main(void){return 0;}' \ + printf 'int main(void){return 0;}\n' \ > "$mb_cfghost_tmpname" fi diff --git a/sofort/ccenv/ccenv.in b/sofort/ccenv/ccenv.in index 441f8ab..0daff84 100644 --- a/sofort/ccenv/ccenv.in +++ b/sofort/ccenv/ccenv.in @@ -84,8 +84,13 @@ PKGCONF = @ccenv_pkgconf@ AS = @ccenv_as@ LD = @ccenv_ld@ +# @ccenv_cfgtype@ visibility attributes +CFLAGS_ATTR_VISIBILITY_DEFAULT = -D_ATTR_VISIBILITY_DEFAULT=@ccenv_attr_visibility_default@ +CFLAGS_ATTR_VISIBILITY_HIDDEN = -D_ATTR_VISIBILITY_HIDDEN=@ccenv_attr_visibility_hidden@ +CFLAGS_ATTR_VISIBILITY_INTERNAL = -D_ATTR_VISIBILITY_INTERNAL=@ccenv_attr_visibility_internal@ +CFLAGS_ATTR_VISIBILITY_PROTECTED = -D_ATTR_VISIBILITY_PROTECTED=@ccenv_attr_visibility_protected@ + # @ccenv_cfgtype@ cflags CFLAGS_OS += -DOS_LIB_SUFFIX=\"@ccenv_os_lib_suffix@\" CFLAGS_OS += @ccenv_cflags_os@ CFLAGS_PIC += @ccenv_cflags_pic@ - diff --git a/sofort/ccenv/ccenv.sh b/sofort/ccenv/ccenv.sh index a13aa07..d975c6b 100644 --- a/sofort/ccenv/ccenv.sh +++ b/sofort/ccenv/ccenv.sh @@ -1118,14 +1118,20 @@ ccenv_set_os() fi case "$ccenv_cchost" in - *-*-*-* ) - ccenv_tip=${ccenv_cchost%-*} - ccenv_os=${ccenv_tip#*-*-} - ;; *-*-musl | *-*-gnu ) ccenv_tip=${ccenv_cchost%-*} ccenv_os=${ccenv_tip#*-} ;; + *-*-solaris* ) + ccenv_os='solaris' + ;; + *-*-*bsd* | *-*-dragonfly* ) + ccenv_os='bsd' + ;; + *-*-*-* ) + ccenv_tip=${ccenv_cchost%-*} + ccenv_os=${ccenv_tip#*-*-} + ;; *-*-* ) ccenv_os=${ccenv_cchost#*-*-} ;; @@ -1412,6 +1418,42 @@ ccenv_set_os_pe_switches() ;; esac fi + + if [ "$ccenv_cc_binfmt" = 'PE' ]; then + if ! cfgtest_macro_definition '__PE__'; then + ccenv_cflags_os="${ccenv_cflags_os} -D__PE__" + fi + + if ! cfgtest_macro_definition '__dllexport'; then + ccenv_cflags_os="${ccenv_cflags_os} -D__dllexport=__attribute__\(\(__dllexport__\)\)" + fi + + if ! cfgtest_macro_definition '__dllimport'; then + ccenv_cflags_os="${ccenv_cflags_os} -D__dllimport=__attribute__\(\(__dllimport__\)\)" + fi + fi +} + +ccenv_set_os_gate_switches() +{ + if [ "$ccenv_os" = 'solaris' ]; then + if ! cfgtest_macro_definition 'AT_FDCWD'; then + ccenv_cflags_os="${ccenv_cflags_os} -D__EXTENSIONS__" + fi + fi +} + +ccenv_set_os_bsd_switches() +{ + if [ "$ccenv_os" = 'bsd' ]; then + mb_cfgtest_headers='sys/mman.h' + + if ! cfgtest_macro_definition 'MAP_ANON'; then + ccenv_cflags_os="${ccenv_cflags_os} -D__BSD_VISIBLE" + fi + + mb_cfgtest_headers= + fi } ccenv_output_defs() @@ -1654,6 +1696,25 @@ ccenv_set_cc_linker_switch_vars() done } +ccenv_set_cc_attr_visibility_vars() +{ + if cfgtest_attr_visibility 'default'; then + ccenv_attr_visibility_default="$mb_cfgtest_attr" + fi + + if cfgtest_attr_visibility 'hidden'; then + ccenv_attr_visibility_hidden="$mb_cfgtest_attr" + fi + + if cfgtest_attr_visibility 'internal'; then + ccenv_attr_visibility_internal="$mb_cfgtest_attr" + fi + + if cfgtest_attr_visibility 'protected'; then + ccenv_attr_visibility_protected="$mb_cfgtest_attr" + fi +} + ccenv_dso_verify() { ccenv_str='int foo(int x){return ++x;}' @@ -1760,6 +1821,9 @@ ccenv_set_toolchain_variables() ccenv_set_os_dso_linkage ccenv_set_os_dso_patterns ccenv_set_os_pe_switches + ccenv_set_os_gate_switches + ccenv_set_os_bsd_switches + ccenv_set_cc_attr_visibility_vars ccenv_output_defs ccenv_clean_up diff --git a/sofort/ccenv/ccenv.vars b/sofort/ccenv/ccenv.vars index 41eb327..054b638 100644 --- a/sofort/ccenv/ccenv.vars +++ b/sofort/ccenv/ccenv.vars @@ -82,6 +82,12 @@ ccenv_windrc= ccenv_pkgconf= +# visibility attributes +ccenv_attr_visibility_default= +ccenv_attr_visibility_hidden= +ccenv_attr_visibility_internal= +ccenv_attr_visibility_protected= + # cflags ccenv_cflags_os= ccenv_cflags_pic= diff --git a/sofort/ccenv/ccswitch.strs b/sofort/ccenv/ccswitch.strs index 0a76f03..277e02e 100644 --- a/sofort/ccenv/ccswitch.strs +++ b/sofort/ccenv/ccswitch.strs @@ -34,6 +34,7 @@ -Werror -Wextra -Wundef +-Wpedantic # debugging -g diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh index debdb8c..7bb27a0 100644 --- a/sofort/cfgtest/cfgtest.sh +++ b/sofort/cfgtest/cfgtest.sh @@ -15,6 +15,7 @@ # mb_cfgtest_cfgtype: the type of the current test (host/native) # mb_cfgtest_makevar: the make variable affected by the current test # mb_cfgtest_headers: headers for ad-hoc inclusion with the current test +# mb_cfgtest_attr: if supported, the compiler-specific attribute definition cfgtest_newline() @@ -131,6 +132,15 @@ cfgtest_epilog() return 1 fi + if [ "${1}" = 'attr' ] && [ "${2}" = '(error)' ]; then + printf '\n\ncfgtest: the %s compiler %s %s_ attribute.\n' \ + "$mb_cfgtest_cfgtype" \ + 'does not appear to support the _' \ + "${3}" >&3 + printf '%s\n' '------------------------' >&3 + return 1 + fi + if [ "${2}" = '-----' ] || [ "${2}" = '(missing)' ]; then printf '\n\ncfgtest: %s %s is missing or cannot be found.\n' "${1}" "${3}" >&3 printf '%s\n' '------------------------' >&3 @@ -246,6 +256,8 @@ cfgtest_common_init() fi elif [ "$cfgtest_type" = 'asm' ]; then cfgtest_fmt='%s -c -xc - -o a.out' + elif [ "$cfgtest_type" = 'attr' ]; then + cfgtest_fmt='%s -c -xc - -o a.out -Werror' elif [ "$cfgtest_type" = 'lib' ]; then cfgtest_fmt='%s -xc - -o a.out' elif [ "$cfgtest_type" = 'ldflag' ]; then @@ -330,11 +342,16 @@ cfgtest_header_presence() cfgtest_prolog 'header' "${1}" cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}") + cfgtest_code_onedecl='int fn(void){return 0;}' + + cfgtest_code_snippet=$(printf '%s\n%s\n' \ + "$cfgtest_code_snippet" \ + "$cfgtest_code_onedecl") cfgtest_common_init # execute - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'header' '-----' "<${1}>" \ @@ -365,11 +382,16 @@ cfgtest_header_absence() cfgtest_prolog 'header absence' "${1}" cfgtest_code_snippet=$(printf '#include <%s>\n' "${1}") + cfgtest_code_onedecl='int fn(void){return 0;}' + + cfgtest_code_snippet=$(printf '%s\n%s\n' \ + "$cfgtest_code_snippet" \ + "$cfgtest_code_onedecl") cfgtest_common_init # execute - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ && printf 'cfgtest: %s header <%s>: no error.' \ @@ -401,12 +423,12 @@ cfgtest_interface_presence() # init cfgtest_prolog 'interface' "${1}" - cfgtest_code_snippet=$(printf 'void * addr = &%s;\n' "${1}") + cfgtest_code_snippet=$(printf 'void (*addr)() = (void (*)())&%s;\n' "${1}") cfgtest_common_init # execute - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'interface' '(error)' "${1}" \ @@ -443,7 +465,7 @@ cfgtest_decl_presence() cfgtest_common_init # execute - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'decl' '(error)' "${1}" \ @@ -496,7 +518,7 @@ cfgtest_type_size() cfgtest_common_init - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ && mb_internal_size=$mb_internal_guess @@ -534,6 +556,39 @@ cfgtest_type_size() } +cfgtest_attr_visibility() +{ + # init + cfgtest_prolog 'compiler visibility attr' "${1}" + + cfgtest_attr_syntax='__attribute__((__visibility__("'"${1}"'")))' + cfgtest_code_snippet="$cfgtest_attr_syntax"' int f_'"${1}"'(void);' + + cfgtest_common_init 'attr' + + # execute + cfgtest_ret=1 + + printf '%s\n' "$cfgtest_src" \ + | eval $(printf '%s' "$cfgtest_cmd") \ + > /dev/null 2>&3 \ + || cfgtest_epilog 'attr' '(error)' "${1}" \ + || return + + # result + mb_cfgtest_attr=$(printf '__attribute__\\(\\(__visibility__\\(\\"%s\\"\\)\\)\\)' "${1}") + + cfgtest_ret=0 + + printf 'cfgtest: %s compiler: above attribute is supported; see also ccenv/%s.mk.\n\n' \ + "$mb_cfgtest_cfgtype" "$mb_cfgtest_cfgtype" >&3 + + cfgtest_epilog 'attr' '(ok)' + + return 0 +} + + cfgtest_code_snippet_asm() { # init @@ -546,7 +601,7 @@ cfgtest_code_snippet_asm() # execute cfgtest_ret=1 - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'snippet' '(error)' \ @@ -579,7 +634,7 @@ cfgtest_macro_definition() # execute cfgtest_ret=1 - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'macro' '(error)' "${1}" \ @@ -627,7 +682,7 @@ cfgtest_library_presence() cfgtest_common_init 'lib' # execute - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'library' '-----' "$@" \ @@ -805,20 +860,20 @@ cfgtest_compiler_switch() ;; *) - cfgtest_code_snippet= + cfgtest_code_snippet='int fn(void){return 0;}' cfgtest_common_init 'switch' ;; esac # execute - printf '%s' "$cfgtest_src" \ + printf '%s\n' "$cfgtest_src" \ | eval $(printf '%s' "$cfgtest_cmd") \ > /dev/null 2>&3 \ || cfgtest_epilog 'switch' '(error)' "$@" \ || return 1 # result - printf 'cfgtest: the switch `%s was accepted by the compier.\n' \ + printf 'cfgtest: the switch `%s was accepted by the compiler.\n' \ "$cfgtest_switches'" >&3 printf '%s\n' '------------------------' >&3 diff --git a/sofort/config/config.vars b/sofort/config/config.vars index 0c01a29..38d5616 100644 --- a/sofort/config/config.vars +++ b/sofort/config/config.vars @@ -54,6 +54,7 @@ zealous sysroot freestanding cross_compile +config_shell shell pkgconf diff --git a/src/driver/tpax_amain.c b/src/driver/tpax_amain.c index 3d138ce..b11dd68 100644 --- a/src/driver/tpax_amain.c +++ b/src/driver/tpax_amain.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <fcntl.h> #include <stdio.h> diff --git a/src/driver/tpax_driver_ctx.c b/src/driver/tpax_driver_ctx.c index 30f3ce5..0a92537 100644 --- a/src/driver/tpax_driver_ctx.c +++ b/src/driver/tpax_driver_ctx.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #define _DEFAULT_SOURCE 1 diff --git a/src/driver/tpax_unit_ctx.c b/src/driver/tpax_unit_ctx.c index f034b17..b272257 100644 --- a/src/driver/tpax_unit_ctx.c +++ b/src/driver/tpax_unit_ctx.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stddef.h> diff --git a/src/helper/tpax_path_copy.c b/src/helper/tpax_path_copy.c index 0df6c17..454b6ea 100644 --- a/src/helper/tpax_path_copy.c +++ b/src/helper/tpax_path_copy.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stdlib.h> diff --git a/src/helper/tpax_stat_compare.c b/src/helper/tpax_stat_compare.c index afbe2f4..c9ab660 100644 --- a/src/helper/tpax_stat_compare.c +++ b/src/helper/tpax_stat_compare.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stdlib.h> diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index 510463f..d66440c 100644 --- a/src/internal/argv/argv.h +++ b/src/internal/argv/argv.h @@ -1,6 +1,6 @@ /****************************************************************************/ /* argv.h: a thread-safe argument vector parser and usage screen generator */ -/* Copyright (C) 2015--2018 Z. Gilboa */ +/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */ /* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ /****************************************************************************/ @@ -83,6 +83,7 @@ enum argv_error { ARGV_ERROR_INTERNAL, ARGV_ERROR_SHORT_OPTION, ARGV_ERROR_LONG_OPTION, + ARGV_ERROR_VENDOR_OPTION, ARGV_ERROR_OPTARG_NONE, ARGV_ERROR_OPTARG_REQUIRED, ARGV_ERROR_OPTARG_PARADIGM, @@ -398,7 +399,11 @@ static void argv_scan( fval = ch; } } else { - ferr = ARGV_ERROR_SHORT_OPTION; + if ((ch == &parg[0][1]) && (ch[0] == 'W') && ch[1]) { + ferr = ARGV_ERROR_VENDOR_OPTION; + } else { + ferr = ARGV_ERROR_SHORT_OPTION; + } } } else if (!fnoscan && (fhybrid || is_long_option(ch))) { @@ -413,49 +418,72 @@ static void argv_scan( ch = *parg; } - if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH)) + /* now verify the proper setting of option values */ + if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH)) { ferr = ARGV_ERROR_HYBRID_NONE; - else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY)) + + } else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY)) { ferr = ARGV_ERROR_HYBRID_ONLY; - else if (option->optarg == ARGV_OPTARG_NONE) { + + } else if (option->optarg == ARGV_OPTARG_NONE) { if (val[0]) { ferr = ARGV_ERROR_OPTARG_NONE; ctx->errch = val + 1; - } else + } else { fval = false; + } + } else if (val[0] && (option->flags & ARGV_OPTION_HYBRID_JOINED)) { fval = true; ch = val; - } else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE)) - ferr = ARGV_ERROR_HYBRID_SPACE; - else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL)) + + } else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE)) { + if (option->optarg == ARGV_OPTARG_OPTIONAL) { + fval = false; + + } else { + ferr = ARGV_ERROR_HYBRID_SPACE; + } + + } else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL)) { ferr = ARGV_ERROR_HYBRID_EQUAL; - else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA)) + + } else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA)) { ferr = ARGV_ERROR_HYBRID_COMMA; - else if (!fhybrid && (val[0]==',')) + + } else if (!fhybrid && (val[0]==',')) { ferr = ARGV_ERROR_HYBRID_COMMA; - else if (val[0] && !val[1]) + + } else if (val[0] && !val[1]) { ferr = ARGV_ERROR_OPTARG_REQUIRED; - else if (val[0] && val[1]) { + + } else if (val[0] && val[1]) { fval = true; ch = ++val; + } else if (option->optarg == ARGV_OPTARG_REQUIRED) { - if (!val[0] && !*parg) + if (!val[0] && !*parg) { ferr = ARGV_ERROR_OPTARG_REQUIRED; - else if (*parg && is_short_option(*parg)) + + } else if (*parg && is_short_option(*parg)) { ferr = ARGV_ERROR_OPTARG_REQUIRED; - else if (*parg && is_long_option(*parg)) + + } else if (*parg && is_long_option(*parg)) { ferr = ARGV_ERROR_OPTARG_REQUIRED; - else if (*parg && is_last_option(*parg)) + + } else if (*parg && is_last_option(*parg)) { ferr = ARGV_ERROR_OPTARG_REQUIRED; - else + + } else { fval = true; + } } else { /* ARGV_OPTARG_OPTIONAL */ fval = val[0]; } - } else + } else { ferr = ARGV_ERROR_LONG_OPTION; + } } if (ferr == ARGV_ERROR_OK) @@ -531,7 +559,11 @@ static const char * argv_program_name(const char * program_path) static void argv_show_error(int fd, struct argv_ctx * ctx) { - char opt_short_name[2] = {0,0}; + const char * src; + char * dst; + char * cap; + char opt_vendor_buf[256]; + char opt_short_name[2] = {0,0}; if (ctx->erropt && ctx->erropt->short_name) opt_short_name[0] = ctx->erropt->short_name; @@ -547,6 +579,27 @@ static void argv_show_error(int fd, struct argv_ctx * ctx) argv_dprintf(fd,"'--%s' is not a valid long option\n",ctx->errch); break; + case ARGV_ERROR_VENDOR_OPTION: + src = ctx->errch; + dst = opt_vendor_buf; + cap = &opt_vendor_buf[sizeof(opt_vendor_buf)]; + + for (; src && *src && dst<cap; ) { + if ((*src == '=') || (*src == ',') || (*src == ':')) { + src = 0; + } else { + *dst++ = *src++; + } + } + + if (dst == cap) + dst--; + + *dst = '\0'; + + argv_dprintf(fd,"'-%s' is not a valid vendor option\n",opt_vendor_buf); + break; + case ARGV_ERROR_OPTARG_NONE: argv_dprintf(fd,"'%s' is not a valid option value for [%s%s%s%s%s] " "(option values may not be specified)\n", @@ -563,7 +616,9 @@ static void argv_show_error(int fd, struct argv_ctx * ctx) opt_short_name[0] ? "-" : "", opt_short_name, opt_short_name[0] ? "," : "", - ctx->erropt->long_name ? "--" : "", + ctx->erropt->long_name + ? (ctx->erropt->flags & ARGV_OPTION_HYBRID_ONLY) ? "-" : "--" + : "", ctx->erropt->long_name, ctx->erropt->paradigm ? "one of the following values:" : "a value", ctx->erropt->paradigm ? "{" : "", diff --git a/src/internal/tpax_dprintf_impl.c b/src/internal/tpax_dprintf_impl.c index 5d2f5f8..b8d2b0b 100644 --- a/src/internal/tpax_dprintf_impl.c +++ b/src/internal/tpax_dprintf_impl.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdio.h> #include <stdarg.h> diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h index 9396d19..5fabb0a 100644 --- a/src/internal/tpax_driver_impl.h +++ b/src/internal/tpax_driver_impl.h @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #ifndef TPAX_DRIVER_IMPL_H #define TPAX_DRIVER_IMPL_H @@ -84,10 +84,7 @@ struct tpax_unit_ctx_impl { off_t dpos; const char * link; char linkbuf[1024]; - union { - struct tpax_ustar_header uhdr; - struct tpax_cpio_header chdr; - } hdrbufs; + size_t hdrbuf[]; }; diff --git a/src/internal/tpax_errinfo_impl.c b/src/internal/tpax_errinfo_impl.c index b610869..5fd2247 100644 --- a/src/internal/tpax_errinfo_impl.c +++ b/src/internal/tpax_errinfo_impl.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <tpax/tpax.h> #include "tpax_driver_impl.h" diff --git a/src/internal/tpax_errinfo_impl.h b/src/internal/tpax_errinfo_impl.h index d85d159..99b416b 100644 --- a/src/internal/tpax_errinfo_impl.h +++ b/src/internal/tpax_errinfo_impl.h @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <errno.h> #include <tpax/tpax.h> diff --git a/src/internal/tpax_getdents_impl.h b/src/internal/tpax_getdents_impl.h index e4d0e2f..42b9da0 100644 --- a/src/internal/tpax_getdents_impl.h +++ b/src/internal/tpax_getdents_impl.h @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020--2021 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #ifndef TPAX_GETDENTS_IMPL_H #define TPAX_GETDENTS_IMPL_H diff --git a/src/internal/tpax_readlink_impl.h b/src/internal/tpax_readlink_impl.h index 7fdffc4..d6c5580 100644 --- a/src/internal/tpax_readlink_impl.h +++ b/src/internal/tpax_readlink_impl.h @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #ifndef TPAX_READLINK_IMPL_H #define TPAX_READLINK_IMPL_H diff --git a/src/internal/tpax_tmpfile_impl.c b/src/internal/tpax_tmpfile_impl.c index a8e0c10..9dd9d40 100644 --- a/src/internal/tpax_tmpfile_impl.c +++ b/src/internal/tpax_tmpfile_impl.c @@ -1,16 +1,20 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #define _GNU_SOURCE +#include <time.h> #include <fcntl.h> #include <limits.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> +#include <inttypes.h> + +#define PPRIX64 "%"PRIx64 /* mkostemp might be guarded by non-standard macros */ /* unless HAVE_NO_MKOSTEMP, assume it is available */ @@ -54,8 +58,8 @@ static int tpax_mkostemp(char * tmplate) int tpax_tmpfile(void) { int fd; - unsigned seed; - char tmplate[64]; + void * addr; + char tmplate[128]; /* try with __fs_tmpfile() */ if ((fd = tpax_tmpfile_by_framework()) >= 0) @@ -66,10 +70,18 @@ int tpax_tmpfile(void) return fd; /* fallback to mk{o}stemp */ - seed = getpid(); + addr = tmplate; memset(tmplate,0,sizeof(tmplate)); - snprintf(tmplate,sizeof(tmplate),"/tmp/tpax_%d_%d_%d_XXXXXXXXXXXX", - getppid(),getpid(),rand_r(&seed)); + snprintf(tmplate,sizeof(tmplate), + "/tmp/" + ".tpax.tmpfile" + ".time."PPRIX64 + ".salt.%p" + ".pid.%d" + ".XXXXXXXXXXXX", + time(0), + addr, + getpid()); return tpax_mkostemp(tmplate); } diff --git a/src/logic/tpax_archive_append.c b/src/logic/tpax_archive_append.c index ef011fd..76ac436 100644 --- a/src/logic/tpax_archive_append.c +++ b/src/logic/tpax_archive_append.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stdlib.h> diff --git a/src/logic/tpax_file_create_memory_snapshot.c b/src/logic/tpax_file_create_memory_snapshot.c index bbcd1df..7c1f90e 100644 --- a/src/logic/tpax_file_create_memory_snapshot.c +++ b/src/logic/tpax_file_create_memory_snapshot.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stdlib.h> diff --git a/src/logic/tpax_file_create_tmpfs_snapshot.c b/src/logic/tpax_file_create_tmpfs_snapshot.c index 9a731c0..5620238 100644 --- a/src/logic/tpax_file_create_tmpfs_snapshot.c +++ b/src/logic/tpax_file_create_tmpfs_snapshot.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stdlib.h> diff --git a/src/logic/tpax_init_ustar_header.c b/src/logic/tpax_init_ustar_header.c index 44b74ad..fb83ba4 100644 --- a/src/logic/tpax_init_ustar_header.c +++ b/src/logic/tpax_init_ustar_header.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdint.h> #include <stdlib.h> diff --git a/src/output/tpax_output_error.c b/src/output/tpax_output_error.c index de09f21..6ecc7ce 100644 --- a/src/output/tpax_output_error.c +++ b/src/output/tpax_output_error.c @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <stdio.h> #include <string.h> @@ -1,8 +1,8 @@ -/******************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020 Z. Gilboa */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/******************************************************/ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ #include <tpax/tpax.h> |