Index: vendor/Juniper/libxo/dist/bin/Zaliases =================================================================== --- vendor/Juniper/libxo/dist/bin/Zaliases (revision 296964) +++ vendor/Juniper/libxo/dist/bin/Zaliases (nonexistent) @@ -1,29 +0,0 @@ -set top_src=`pwd` -alias Zautoreconf "(cd $top_src ; autoreconf)" - -set opts=' \ ---with-libslax-prefix=/Users/phil/work/root \ ---enable-debug \ ---enable-warnings \ ---enable-printflike \ ---with-gettext=/opt/local \ ---prefix ${HOME}/work/root \ -' -set opts=`echo $opts` - -setenv CONFIGURE_OPTS "$opts" -setenv ADB_PATH $top_src/build/libxo/.libs - -alias Zconfigure "(cd $top_src/build; ../configure $opts)" -alias Zbuild "(cd $top_src/build; make \!* )" -alias mi "(cd $top_src/build; make && make install); ." - -mkdir -p build -cd build - - -alias xx 'cc -I.. -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Werror -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wformat -Wimplicit -Wmissing-declarations -Wnested-externs -Wparentheses -Wreturn-type -Wshadow -Wswitch -Wtrigraphs -Wuninitialized -Wunused -Wwrite-strings -fno-inline-functions-called-once -g -O2 -o xtest -DUNIT_TEST libxo.c' - -alias mm "make CFLAGS='-O0 -g'" - -alias mmi 'mm && mi' Index: vendor/Juniper/libxo/dist/bin/setup.sh =================================================================== --- vendor/Juniper/libxo/dist/bin/setup.sh (revision 296964) +++ vendor/Juniper/libxo/dist/bin/setup.sh (nonexistent) @@ -1,33 +0,0 @@ -# -# Copyright 2013, Juniper Networks, Inc. -# All rights reserved. -# This SOFTWARE is licensed under the LICENSE provided in the -# ../Copyright file. By downloading, installing, copying, or otherwise -# using the SOFTWARE, you agree to be bound by the terms of that -# LICENSE. - - -if [ ! -f configure ]; then - vers=`autoreconf --version | head -1` - echo "Using" $vers - - mkdir -p m4 - - autoreconf --install - - if [ ! -f configure ]; then - echo "Failed to create configure script" - exit 1 - fi -fi - -echo "Creating build directory ..." -mkdir build - -echo "Setup is complete. To build libslax:" - -echo " 1) Type 'cd build ; ../configure' to configure libslax" -echo " 2) Type 'make' to build libslax" -echo " 3) Type 'make install' to install libslax" - -exit 0 Property changes on: vendor/Juniper/libxo/dist/bin/setup.sh ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/Juniper/libxo/dist/bin/Makefile.am =================================================================== --- vendor/Juniper/libxo/dist/bin/Makefile.am (revision 296964) +++ vendor/Juniper/libxo/dist/bin/Makefile.am (nonexistent) @@ -1,29 +0,0 @@ -# -# Copyright 2013, Juniper Networks, Inc. -# All rights reserved. -# This SOFTWARE is licensed under the LICENSE provided in the -# ../Copyright file. By downloading, installing, copying, or otherwise -# using the SOFTWARE, you agree to be bound by the terms of that -# LICENSE. - -ACLOCAL_AMFLAGS = -I m4 - -EXTRA_DIST = gt setup.sh - -GT_INSTALL_DIR = ${prefix}/bin -GT_INSTALL_FILES = gt - -install-data-hook: - @echo "Installing gt ... " - @-mkdir -p ${GT_INSTALL_DIR} - @for file in ${GT_INSTALL_FILES} ; do \ - if [ -f $$file ]; then \ - rfile=$$file ; \ - else \ - rfile=${srcdir}/$$file ; \ - fi ; \ - mdir=${GT_INSTALL_DIR}/ ; \ - mkdir -p $$mdir ; \ - cp $$rfile $$mdir/ ; \ - done - @${CHMOD} a+x ${GT_INSTALL_DIR}/gt Property changes on: vendor/Juniper/libxo/dist/bin/Makefile.am ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/Juniper/libxo/dist/build/.create =================================================================== Index: vendor/Juniper/libxo/dist/install-sh =================================================================== --- vendor/Juniper/libxo/dist/install-sh (revision 296964) +++ vendor/Juniper/libxo/dist/install-sh (revision 296965) @@ -1,527 +1,501 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-11-20.07; # UTC +scriptversion=2013-12-25.23; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) no_target_directory=true;; + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue + test X"$d" = X && continue - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: Index: vendor/Juniper/libxo/dist/libxo/xo_config.h =================================================================== --- vendor/Juniper/libxo/dist/libxo/xo_config.h (revision 296964) +++ vendor/Juniper/libxo/dist/libxo/xo_config.h (nonexistent) @@ -1,247 +0,0 @@ -/* libxo/xo_config.h. Generated from xo_config.h.in by configure. */ -/* libxo/xo_config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -/* #undef HAVE_ALLOCA_H */ - -/* Define to 1 if you have the `asprintf' function. */ -#define HAVE_ASPRINTF 1 - -/* Define to 1 if you have the `bzero' function. */ -#define HAVE_BZERO 1 - -/* Define to 1 if you have the `ctime' function. */ -#define HAVE_CTIME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define to 1 if you have the declaration of `__isthreaded', and to 0 if you - don't. */ -#define HAVE_DECL___ISTHREADED 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `dlfunc' function. */ -#define HAVE_DLFUNC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the `fdopen' function. */ -#define HAVE_FDOPEN 1 - -/* Define to 1 if you have the `flock' function. */ -#define HAVE_FLOCK 1 - -/* Define to 1 if you have the `getpass' function. */ -#define HAVE_GETPASS 1 - -/* Define to 1 if you have the `getprogname' function. */ -#define HAVE_GETPROGNAME 1 - -/* Define to 1 if you have the `getrusage' function. */ -#define HAVE_GETRUSAGE 1 - -/* gettext(3) */ -/* #undef HAVE_GETTEXT */ - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* humanize_number(3) */ -#define HAVE_HUMANIZE_NUMBER 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `crypto' library (-lcrypto). */ -#define HAVE_LIBCRYPTO 1 - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIBUTIL_H 1 - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Support printflike */ -/* #undef HAVE_PRINTFLIKE */ - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#define HAVE_REALLOC 1 - -/* Define to 1 if you have the `srand' function. */ -#define HAVE_SRAND 1 - -/* Define to 1 if you have the `sranddev' function. */ -#define HAVE_SRANDDEV 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STDIO_EXT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STDTIME_TZFILE_H */ - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strcspn' function. */ -#define HAVE_STRCSPN 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strlcpy' function. */ -#define HAVE_STRLCPY 1 - -/* Define to 1 if you have the `strspn' function. */ -#define HAVE_STRSPN 1 - -/* Have struct sockaddr_un.sun_len */ -#define HAVE_SUN_LEN 1 - -/* Define to 1 if you have the `sysctlbyname' function. */ -#define HAVE_SYSCTLBYNAME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SYSCTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_THREADS_H 1 - -/* thread-local setting */ -#define HAVE_THREAD_LOCAL THREAD_LOCAL_before - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_TZFILE_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `__flbf' function. */ -/* #undef HAVE___FLBF */ - -/* Enable debugging */ -/* #undef LIBXO_DEBUG */ - -/* Enable text-only rendering */ -/* #undef LIBXO_TEXT_ONLY */ - -/* Version number as dotted value */ -#define LIBXO_VERSION "0.4.3" - -/* Version number extra information */ -#define LIBXO_VERSION_EXTRA "" - -/* Version number as a number */ -#define LIBXO_VERSION_NUMBER 4003 - -/* Version number as string */ -#define LIBXO_VERSION_STRING "4003" - -/* Enable local wcwidth implementation */ -#define LIBXO_WCWIDTH 1 - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libxo" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "phil@juniper.net" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "libxo" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libxo 0.4.3" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libxo" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.4.3" - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at runtime. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.4.3" - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to rpl_malloc if the replacement function should be used. */ -/* #undef malloc */ - -/* Define to rpl_realloc if the replacement function should be used. */ -/* #undef realloc */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ Property changes on: vendor/Juniper/libxo/dist/libxo/xo_config.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/Juniper/libxo/dist/libxo/xo_config.h.in =================================================================== --- vendor/Juniper/libxo/dist/libxo/xo_config.h.in (nonexistent) +++ vendor/Juniper/libxo/dist/libxo/xo_config.h.in (revision 296965) @@ -0,0 +1,246 @@ +/* libxo/xo_config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the `asprintf' function. */ +#undef HAVE_ASPRINTF + +/* Define to 1 if you have the `bzero' function. */ +#undef HAVE_BZERO + +/* Define to 1 if you have the `ctime' function. */ +#undef HAVE_CTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_CTYPE_H + +/* Define to 1 if you have the declaration of `__isthreaded', and to 0 if you + don't. */ +#undef HAVE_DECL___ISTHREADED + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the `dlfunc' function. */ +#undef HAVE_DLFUNC + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the `fdopen' function. */ +#undef HAVE_FDOPEN + +/* Define to 1 if you have the `flock' function. */ +#undef HAVE_FLOCK + +/* Define to 1 if you have the `getpass' function. */ +#undef HAVE_GETPASS + +/* Define to 1 if you have the `getprogname' function. */ +#undef HAVE_GETPROGNAME + +/* Define to 1 if you have the `getrusage' function. */ +#undef HAVE_GETRUSAGE + +/* gettext(3) */ +#undef HAVE_GETTEXT + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* humanize_number(3) */ +#undef HAVE_HUMANIZE_NUMBER + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#undef HAVE_LIBCRYPTO + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBUTIL_H + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Support printflike */ +#undef HAVE_PRINTFLIKE + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the `srand' function. */ +#undef HAVE_SRAND + +/* Define to 1 if you have the `sranddev' function. */ +#undef HAVE_SRANDDEV + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_EXT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDTIME_TZFILE_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strcspn' function. */ +#undef HAVE_STRCSPN + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + +/* Define to 1 if you have the `strspn' function. */ +#undef HAVE_STRSPN + +/* Have struct sockaddr_un.sun_len */ +#undef HAVE_SUN_LEN + +/* Define to 1 if you have the `sysctlbyname' function. */ +#undef HAVE_SYSCTLBYNAME + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SYSCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_THREADS_H + +/* thread-local setting */ +#undef HAVE_THREAD_LOCAL + +/* Define to 1 if you have the header file. */ +#undef HAVE_TZFILE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `__flbf' function. */ +#undef HAVE___FLBF + +/* Enable debugging */ +#undef LIBXO_DEBUG + +/* Enable text-only rendering */ +#undef LIBXO_TEXT_ONLY + +/* Version number as dotted value */ +#undef LIBXO_VERSION + +/* Version number extra information */ +#undef LIBXO_VERSION_EXTRA + +/* Version number as a number */ +#undef LIBXO_VERSION_NUMBER + +/* Version number as string */ +#undef LIBXO_VERSION_STRING + +/* Enable local wcwidth implementation */ +#undef LIBXO_WCWIDTH + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to rpl_realloc if the replacement function should be used. */ +#undef realloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t Property changes on: vendor/Juniper/libxo/dist/libxo/xo_config.h.in ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/Juniper/libxo/dist/libxo/xo_format.5 =================================================================== --- vendor/Juniper/libxo/dist/libxo/xo_format.5 (revision 296964) +++ vendor/Juniper/libxo/dist/libxo/xo_format.5 (revision 296965) @@ -1,943 +1,943 @@ .\" # .\" # Copyright (c) 2014, Juniper Networks, Inc. .\" # All rights reserved. .\" # This SOFTWARE is licensed under the LICENSE provided in the .\" # ../Copyright file. By downloading, installing, copying, or .\" # using the SOFTWARE, you agree to be bound by the terms of that .\" # LICENSE. .\" # Phil Shafer, July 2014 .\" -.Dd November 6, 2015 +.Dd December 4, 2014 .Dt LIBXO 3 .Os .Sh NAME .Nm xo_format .Nd content of format descriptors for xo_emit .Sh DESCRIPTION .Pp .Nm libxo uses format strings to control the rendering of data into various output styles, including .Em text , .Em XML , .Em JSON , and .Em HTML . Each format string contains a set of zero or more .Dq "field descriptions" , which describe independent data fields. Each field description contains a set of .Dq modifiers , a .Dq "content string" , and zero, one, or two .Dq "format descriptors" . The modifiers tell .Nm libxo what the field is and how to treat it, while the format descriptors are formatting instructions using .Xr printf 3 Ns -style format strings, telling .Nm libxo how to format the field. The field description is placed inside a set of braces, with a colon .Ql ( \&: ) after the modifiers and a slash .Ql ( \&/ ) before each format descriptors. Text may be intermixed with field descriptions within the format string. .Pp The field description is given as follows: .Bd -literal -offset indent '{' [ role | modifier ]* [',' long-names ]* ':' [ content ] [ '/' field-format [ '/' encoding-format ]] '}' .Ed .Pp The role describes the function of the field, while the modifiers enable optional behaviors. The contents, field-format, and encoding-format are used in varying ways, based on the role. These are described in the following sections. .Pp Braces can be escaped by using double braces, similar to "%%" in .Xr printf 3 . The format string "{{braces}}" would emit "{braces}". .Pp In the following example, three field descriptors appear. The first is a padding field containing three spaces of padding, the second is a label ("In stock"), and the third is a value field ("in-stock"). The in-stock field has a "%u" format that will parse the next argument passed to the .Xr xo_emit 3 , function as an unsigned integer. .Bd -literal -offset indent xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\\n", 65); .Ed .Pp This single line of code can generate text ("In stock: 65\\n"), XML ("65"), JSON ('"in-stock": 65'), or HTML (too lengthy to be listed here). .Pp While roles and modifiers typically use single character for brevity, there are alternative names for each which allow more verbose formatting strings. These names must be preceded by a comma, and may follow any single-character values: .Bd -literal -offset indent xo_emit("{L,white,colon:In stock}{,key:in-stock/%u}\n", 65); .Ed .Ss "Field Roles" Field roles are optional, and indicate the role and formatting of the content. The roles are listed below; only one role is permitted: .Bl -column "M" "Name12341234" .It Sy "M" "Name " "Description" .It C "color " "Field is a color or effect" .It D "decoration " "Field is non-text (e.g. colon, comma)" .It E "error " "Field is an error message" .It L "label " "Field is text that prefixes a value" .It N "note " "Field is text that follows a value" .It P "padding " "Field is spaces needed for vertical alignment" .It T "title " "Field is a title value for headings" .It U "units " "Field is the units for the previous value field" .It V "value " "Field is the name of field (the default)" .It W "warning " "Field is a warning message" .It \&[ "start-anchor" "Begin a section of anchored variable-width text" .It \&] "stop-anchor " "End a section of anchored variable-width text" .El .Bd -literal -offset indent EXAMPLE: xo_emit("{L:Free}{D::}{P: }{:free/%u} {U:Blocks}\n", free_blocks); .Ed .Pp When a role is not provided, the "value" role is used as the default. .Pp Roles and modifiers can also use more verbose names, when preceeded by a comma: .Bd -literal -offset indent EXAMPLE: xo_emit("{,label:Free}{,decoration::}{,padding: }" "{,value:free/%u} {,units:Blocks}\n", free_blocks); .Ed .Ss "The Color Role ({C:})" Colors and effects control how text values are displayed; they are used for display styles (TEXT and HTML). .Bd -literal -offset indent xo_emit("{C:bold}{:value}{C:no-bold}\n", value); .Ed .Pp Colors and effects remain in effect until modified by other "C"-role fields. .Bd -literal -offset indent xo_emit("{C:bold}{C:inverse}both{C:no-bold}only inverse\n"); .Ed .Pp If the content is empty, the "reset" action is performed. .Bd -literal -offset indent xo_emit("{C:both,underline}{:value}{C:}\n", value); .Ed .Pp The content should be a comma-separated list of zero or more colors or display effects. .Bd -literal -offset indent xo_emit("{C:bold,underline,inverse}All three{C:no-bold,no-inverse}\n"); .Ed .Pp The color content can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"): .Bd -literal -offset indent xo_emit("{C:/%s%s}{:value}{C:}", need_bold ? "bold" : "", need_underline ? "underline" : "", value); .Ed .Pp Color names are prefixed with either "fg-" or "bg-" to change the foreground and background colors, respectively. .Bd -literal -offset indent xo_emit("{C:/fg-%s,bg-%s}{Lwc:Cost}{:cost/%u}{C:reset}\n", fg_color, bg_color, cost); .Ed .Pp The following table lists the supported effects: .Bl -column "no-underline" .It Sy "Name " "Description" .It "bg\-xxxxx " "Change background color" .It "bold " "Start bold text effect" .It "fg\-xxxxx " "Change foreground color" .It "inverse " "Start inverse (aka reverse) text effect" .It "no\-bold " "Stop bold text effect" .It "no\-inverse " "Stop inverse (aka reverse) text effect" .It "no\-underline " "Stop underline text effect" .It "normal " "Reset effects (only)" .It "reset " "Reset colors and effects (restore defaults)" .It "underline " "Start underline text effect" .El .Pp The following color names are supported: .Bl -column "no-underline" .It Sy "Name" .It black .It blue .It cyan .It default .It green .It magenta .It red .It white .It yellow .El .Ss "The Decoration Role ({D:})" Decorations are typically punctuation marks such as colons, semi-colons, and commas used to decorate the text and make it simpler for human readers. By marking these distinctly, HTML usage scenarios can use CSS to direct their display parameters. .Bd -literal -offset indent xo_emit("{D:((}{:name}{D:))}\\n", name); .Ed .Ss "The Gettext Role ({G:})" .Nm libxo supports internationalization (i18n) through its use of .Xr gettext 3 . Use the "{G:}" role to request that the remaining part of the format string, following the "{G:}" field, be handled using .Fn gettext . Since .Fn gettext uses the string as the key into the message catalog, .Nm libxo uses a simplified version of the format string that removes unimportant field formatting and modifiers, stopping minor formatting changes from impacting the expensive translation process. A developer change such as changing "/%06d" to "/%08d" should not force hand inspection of all .po files. .Pp The simplified version can be generated for a single message using the "xopo -s " command, or an entire .pot can be translated using the "xopo -f -o " command. .Bd -literal -offset indent xo_emit("{G:}Invalid token\n"); .Ed The {G:} role allows a domain name to be set. .Fn gettext calls will continue to use that domain name until the current format string processing is complete, enabling a library function to emit strings using it's own catalog. The domain name can be either static as the content of the field, or a format can be used to get the domain name from the arguments. .Bd -literal -offset indent xo_emit("{G:libc}Service unavailable in restricted mode\n"); .Ed .Ss "The Label Role ({L:})" Labels are text that appears before a value. .Bd -literal -offset indent xo_emit("{Lwc:Cost}{:cost/%u}\\n", cost); .Ed .Ss "The Note Role ({N:})" Notes are text that appears after a value. .Bd -literal -offset indent xo_emit("{:cost/%u} {N:per year}\\n", cost); .Ed .Ss "The Padding Role ({P:})" Padding represents whitespace used before and between fields. The padding content can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"): .Bd -literal -offset indent xo_emit("{P: }{Lwc:Cost}{:cost/%u}\\n", cost); xo_emit("{P:/30s}{Lwc:Cost}{:cost/%u}\\n", "", cost); .Ed .Ss "The Title Role ({T:})" Titles are heading or column headers that are meant to be displayed to the user. The title can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"): .Bd -literal -offset indent xo_emit("{T:Interface Statistics}\\n"); xo_emit("{T:/%20.20s}{T:/%6.6s}\\n", "Item Name", "Cost"); .Ed .Ss "The Units Role ({U:})" Units are the dimension by which values are measured, such as degrees, miles, bytes, and decibels. The units field carries this information for the previous value field. .Bd -literal -offset indent xo_emit("{Lwc:Distance}{:distance/%u}{Uw:miles}\\n", miles); .Ed .Pp Note that the sense of the 'w' modifier is reversed for units; a blank is added before the contents, rather than after it. .Pp When the .Dv XOF_UNITS flag is set, units are rendered in XML as the .Dq units attribute: .Bd -literal -offset indent 50 .Ed .Pp Units can also be rendered in HTML as the "data-units" attribute: .Bd -literal -offset indent
50
.Ed .Ss "The Value Role ({V:} and {:})" The value role is used to represent the a data value that is interesting for the non-display output styles (XML and JSON). Value is the default role; if no other role designation is given, the field is a value. The field name must appear within the field descriptor, followed by one or two format descriptors. The first format descriptor is used for display styles (TEXT and HTML), while the second one is used for encoding styles (XML and JSON). If no second format is given, the encoding format defaults to the first format, with any minimum width removed. If no first format is given, both format descriptors default to "%s". .Bd -literal -offset indent xo_emit("{:length/%02u}x{:width/%02u}x{:height/%02u}\\n", length, width, height); xo_emit("{:author} wrote \"{:poem}\" in {:year/%4d}\\n, author, poem, year); .Ed .Ss "The Anchor Roles ({[:} and {]:})" The anchor roles allow a set of strings by be padded as a group, but still be visible to .Xr xo_emit 3 as distinct fields. Either the start or stop anchor can give a field width and it can be either directly in the descriptor or passed as an argument. Any fields between the start and stop anchor are padded to meet the minimum width given. .Pp To give a width directly, encode it as the content of the anchor tag: .Bd -literal -offset indent xo_emit("({[:10}{:min/%d}/{:max/%d}{]:})\\n", min, max); .Ed .Pp To pass a width as an argument, use "%d" as the format, which must appear after the "/". Note that only "%d" is supported for widths. Using any other value could ruin your day. .Bd -literal -offset indent xo_emit("({[:/%d}{:min/%d}/{:max/%d}{]:})\\n", width, min, max); .Ed .Pp If the width is negative, padding will be added on the right, suitable for left justification. Otherwise the padding will be added to the left of the fields between the start and stop anchors, suitable for right justification. If the width is zero, nothing happens. If the number of columns of output between the start and stop anchors is less than the absolute value of the given width, nothing happens. .Pp Widths over 8k are considered probable errors and not supported. If .Dv XOF_WARN is set, a warning will be generated. .Ss "Field Modifiers" Field modifiers are flags which modify the way content emitted for particular output styles: .Bl -column M "Name123456789" .It Sy M "Name " "Description" .It c "colon " "A colon ("":"") is appended after the label" .It d "display " "Only emit field for display styles (text/HTML)" .It e "encoding " "Only emit for encoding styles (XML/JSON)" .It h "humanize (hn) " "Format large numbers in human-readable style" .It " " "hn-space " "Humanize: Place space between numeric and unit" .It " " "hn-decimal " "Humanize: Add a decimal digit, if number < 10" .It " " "hn-1000 " "Humanize: Use 1000 as divisor instead of 1024" .It k "key " "Field is a key, suitable for XPath predicates" .It l "leaf-list " "Field is a leaf-list, a list of leaf values" .It n "no-quotes " "Do not quote the field when using JSON style" .It q "quotes " "Quote the field when using JSON style" -.It t "trim " "Trim leading and trailing whitespace" +.It q "trim " "Trim leading and trailing whitespace" .It w "white space " "A blank ("" "") is appended after the label" .El .Pp For example, the modifier string "Lwc" means the field has a label role (text that describes the next field) and should be followed by a colon ('c') and a space ('w'). The modifier string "Vkq" means the field has a value role, that it is a key for the current instance, and that the value should be quoted when encoded for JSON. .Pp Roles and modifiers can also use more verbose names, when preceeded by a comma. For example, the modifier string "Lwc" (or "L,white,colon") means the field has a label role (text that describes the next field) and should be followed by a colon ('c') and a space ('w'). The modifier string "Vkq" (or ":key,quote") means the field has a value role (the default role), that it is a key for the current instance, and that the value should be quoted when encoded for JSON. .Ss "The Colon Modifier ({c:})" The colon modifier appends a single colon to the data value: .Bd -literal -offset indent EXAMPLE: xo_emit("{Lc:Name}{:name}\\n", "phil"); TEXT: Name:phil .Ed .Pp The colon modifier is only used for the TEXT and HTML output styles. It is commonly combined with the space modifier ('{w:}'). It is purely a convenience feature. .Ss "The Display Modifier ({d:})" The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML. .Bd -literal -offset indent EXAMPLE: xo_emit("{Lcw:Name}{d:name} {:id/%d}\\n", "phil", 1); TEXT: Name: phil 1 XML: 1 .Ed .Pp The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data. .Ss "The Encoding Modifier ({e:})" The encoding modifier indicated the field should only be generated for the encoding output styles, such as JSON and XML. .Bd -literal -offset indent EXAMPLE: xo_emit("{Lcw:Name}{:name} {e:id/%d}\\n", "phil", 1); TEXT: Name: phil XML: phil1 .Ed .Pp The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data. .Ss "The Humanize Modifier ({h:})" The humanize modifier is used to render large numbers as in a human-readable format. While numbers like "44470272" are completely readable to computers and savants, humans will generally find "44M" more meaningful. .Pp "hn" can be used as an alias for "humanize". .Pp The humanize modifier only affects display styles (TEXT and HMTL). The "no-humanize" option will block the function of the humanize modifier. .Pp There are a number of modifiers that affect details of humanization. These are only available in as full names, not single characters. The "hn-space" modifier places a space between the number and any multiplier symbol, such as "M" or "K" (ex: "44 K"). The "hn-decimal" modifier will add a decimal point and a single tenths digit when the number is less than 10 (ex: "4.4K"). The "hn-1000" modifier will use 1000 as divisor instead of 1024, following the JEDEC-standard instead of the more natural binary powers-of-two tradition. .Bd -literal -offset indent EXAMPLE: xo_emit("{h:input/%u}, {h,hn-space:output/%u}, " "{h,hn-decimal:errors/%u}, {h,hn-1000:capacity/%u}, " "{h,hn-decimal:remaining/%u}\n", input, output, errors, capacity, remaining); TEXT: 21, 57 K, 96M, 44M, 1.2G .Ed .Pp In the HTML style, the original numeric value is rendered in the "data-number" attribute on the
element: .Bd -literal -offset indent
96M
.Ed .Ss "The Gettext Modifier ({g:})" The gettext modifier is used to translate individual fields using the gettext domain (typically set using the "{G:}" role) and current language settings. Once libxo renders the field value, it is passed to .Xr gettext 3 , where it is used as a key to find the native language translation. .Pp In the following example, the strings "State" and "full" are passed to .Fn gettext to find locale-based translated strings. .Bd -literal -offset indent xo_emit("{Lgwc:State}{g:state}\n", "full"); .Ed .Ss "The Key Modifier ({k:})" The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data. .Bd -literal -offset indent EXAMPLE: xo_open_list("user"); for (i = 0; i < num_users; i++) { xo_open_instance("user"); xo_emit("User {k:name} has {:count} tickets\\n", user[i].u_name, user[i].u_tickets); xo_close_instance("user"); } xo_close_list("user"); .Ed .Pp Currently the key modifier is only used when generating XPath values for the HTML output style when .Dv XOF_XPATH is set, but other uses are likely in the near future. .Ss "The Leaf-List Modifier ({l:})" The leaf-list modifier is used to distinguish lists where each instance consists of only a single value. In XML, these are rendered as single elements, where JSON renders them as arrays. .Bd -literal -offset indent EXAMPLE: xo_open_list("user"); for (i = 0; i < num_users; i++) { xo_emit("Member {l:name}\n", user[i].u_name); } xo_close_list("user"); XML: phil pallavi JSON: "user": [ "phil", "pallavi" ] .Ed .Ss "The No-Quotes Modifier ({n:})" The no-quotes modifier (and its twin, the 'quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string values, but no quotes for numeric, boolean, and null data. .Xr xo_emit 3 applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller. .Bd -literal -offset indent EXAMPLE: const char *bool = is_true ? "true" : "false"; xo_emit("{n:fancy/%s}", bool); JSON: "fancy": true .Ed .Ss "The Plural Modifier ({p:})" The plural modifier selects the appropriate plural form of an expression based on the most recent number emitted and the current language settings. The contents of the field should be the singular and plural English values, separated by a comma: .Bd -literal -offset indent xo_emit("{:bytes} {Ngp:byte,bytes}\n", bytes); .Ed The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. .Pp When used without the gettext modifier or when the message does not appear in the message catalog, the first token is chosen when the last numeric value is equal to 1; otherwise the second value is used, mimicking the simple pluralization rules of English. .Pp When used with the gettext modifier, the .Xr ngettext 3 function is called to handle the heavy lifting, using the message catalog to convert the singular and plural forms into the native language. .Ss "The Quotes Modifier ({q:})" The quotes modifier (and its twin, the 'no-quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string values, but no quotes for numeric, boolean, and null data. .Xr xo_emit 3 applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller. .Bd -literal -offset indent EXAMPLE: xo_emit("{q:time/%d}", 2014); JSON: "year": "2014" .Ed .Ss "The White Space Modifier ({w:})" The white space modifier appends a single space to the data value: .Bd -literal -offset indent EXAMPLE: xo_emit("{Lw:Name}{:name}\\n", "phil"); TEXT: Name phil .Ed .Pp The white space modifier is only used for the TEXT and HTML output styles. It is commonly combined with the colon modifier ('{c:}'). It is purely a convenience feature. .Pp Note that the sense of the 'w' modifier is reversed for the units role ({Uw:}); a blank is added before the contents, rather than after it. .Ss "Field Formatting" The field format is similar to the format string for .Xr printf 3 . Its use varies based on the role of the field, but generally is used to format the field's contents. .Pp If the format string is not provided for a value field, it defaults to "%s". .Pp Note a field definition can contain zero or more printf-style .Dq directives , which are sequences that start with a '%' and end with one of following characters: "diouxXDOUeEfFgGaAcCsSp". Each directive is matched by one of more arguments to the .Xr xo_emit 3 function. .Pp The format string has the form: .Bd -literal -offset indent '%' format-modifier * format-character .Ed .Pp The format- modifier can be: .Bl -bullet .It a '#' character, indicating the output value should be prefixed with "0x", typically to indicate a base 16 (hex) value. .It a minus sign ('-'), indicating the output value should be padded on the right instead of the left. .It a leading zero ('0') indicating the output value should be padded on the left with zeroes instead of spaces (' '). .It one or more digits ('0' - '9') indicating the minimum width of the argument. If the width in columns of the output value is less than the minimum width, the value will be padded to reach the minimum. .It a period followed by one or more digits indicating the maximum number of bytes which will be examined for a string argument, or the maximum width for a non-string argument. When handling ASCII strings this functions as the field width but for multi-byte characters, a single character may be composed of multiple bytes. .Xr xo_emit 3 will never dereference memory beyond the given number of bytes. .It a second period followed by one or more digits indicating the maximum width for a string argument. This modifier cannot be given for non-string arguments. .It one or more 'h' characters, indicating shorter input data. .It one or more 'l' characters, indicating longer input data. .It a 'z' character, indicating a 'size_t' argument. .It a 't' character, indicating a 'ptrdiff_t' argument. .It a ' ' character, indicating a space should be emitted before positive numbers. .It a '+' character, indicating sign should emitted before any number. .El .Pp Note that 'q', 'D', 'O', and 'U' are considered deprecated and will be removed eventually. .Pp The format character is described in the following table: .Bl -column C "Argument Type12" .It Sy "C" "Argument Type " "Format" .It d "int " "base 10 (decimal)" .It i "int " "base 10 (decimal)" .It o "int " "base 8 (octal)" .It u "unsigned " "base 10 (decimal)" .It x "unsigned " "base 16 (hex)" .It X "unsigned long " "base 16 (hex)" .It D "long " "base 10 (decimal)" .It O "unsigned long " "base 8 (octal)" .It U "unsigned long " "base 10 (decimal)" .It e "double " "[-]d.ddde+-dd" .It E "double " "[-]d.dddE+-dd" .It f "double " "[-]ddd.ddd" .It F "double " "[-]ddd.ddd" .It g "double " "as 'e' or 'f'" .It G "double " "as 'E' or 'F'" .It a "double " "[-]0xh.hhhp[+-]d" .It A "double " "[-]0Xh.hhhp[+-]d" .It c "unsigned char " "a character" .It C "wint_t " "a character" .It s "char * " "a UTF-8 string" .It S "wchar_t * " "a unicode/WCS string" .It p "void * " "'%#lx'" .El .Pp The 'h' and 'l' modifiers affect the size and treatment of the argument: .Bl -column "Mod" "d, i " "o, u, x, X " .It Sy "Mod" "d, i " "o, u, x, X" .It "hh " "signed char " "unsigned char" .It "h " "short " "unsigned short" .It "l " "long " "unsigned long" .It "ll " "long long " "unsigned long long" .It "j " "intmax_t " "uintmax_t" .It "t " "ptrdiff_t " "ptrdiff_t" .It "z " "size_t " "size_t" .It "q " "quad_t " "u_quad_t" .El .Ss "UTF-8 and Locale Strings" All strings for .Nm libxo must be UTF-8. .Nm libxo will handle turning them into locale-based strings for display to the user. .Pp For strings, the 'h' and 'l' modifiers affect the interpretation of the bytes pointed to argument. The default '%s' string is a 'char *' pointer to a string encoded as UTF-8. Since UTF-8 is compatible with .Em ASCII data, a normal 7-bit .Em ASCII string can be used. "%ls" expects a "wchar_t *" pointer to a wide-character string, encoded as 32-bit Unicode values. "%hs" expects a "char *" pointer to a multi-byte string encoded with the current locale, as given by the .Ev LC_CTYPE , .Ev LANG , or .Ev LC_ALL environment variables. The first of this list of variables is used and if none of the variables are set, the locale defaults to .Em UTF-8 . .Pp .Nm libxo will convert these arguments as needed to either UTF-8 (for XML, JSON, and HTML styles) or locale-based strings for display in text style. .Bd -literal -offset indent xo_emit("All strings are utf-8 content {:tag/%ls}", L"except for wide strings"); .Ed .Pp "%S" is equivalent to "%ls". .Pp For example, a function is passed a locale-base name, a hat size, and a time value. The hat size is formatted in a UTF-8 (ASCII) string, and the time value is formatted into a wchar_t string. .Bd -literal -offset indent void print_order (const char *name, int size, struct tm *timep) { char buf[32]; const char *size_val = "unknown"; if (size > 0) snprintf(buf, sizeof(buf), "%d", size); size_val = buf; } wchar_t when[32]; wcsftime(when, sizeof(when), L"%d%b%y", timep); xo_emit("The hat for {:name/%hs} is {:size/%s}.\\n", name, size_val); xo_emit("It was ordered on {:order-time/%ls}.\\n", when); } .Ed .Pp It is important to note that .Xr xo_emit 3 will perform the conversion required to make appropriate output. Text style output uses the current locale (as described above), while XML, JSON, and HTML use UTF-8. .Pp UTF-8 and locale-encoded strings can use multiple bytes to encode one column of data. The traditional "precision'" (aka "max-width") value for "%s" printf formatting becomes overloaded since it specifies both the number of bytes that can be safely referenced and the maximum number of columns to emit. .Xr xo_emit 3 uses the precision as the former, and adds a third value for specifying the maximum number of columns. .Pp In this example, the name field is printed with a minimum of 3 columns and a maximum of 6. Up to ten bytes are in used in filling those columns. .Bd -literal -offset indent xo_emit("{:name/%3.10.6s}", name); .Ed .Ss "Characters Outside of Field Definitions" Characters in the format string that are not part of a field definition are copied to the output for the TEXT style, and are ignored for the JSON and XML styles. For HTML, these characters are placed in a
with class "text". .Bd -literal -offset indent EXAMPLE: xo_emit("The hat is {:size/%s}.\\n", size_val); TEXT: The hat is extra small. XML: extra small JSON: "size": "extra small" HTML:
The hat is
extra small
.
.Ed .Ss "'%n' is Not Supported" .Nm libxo does not support the '%n' directive. It is a bad idea and we just do not do it. .Ss "The Encoding Format (eformat)" The "eformat" string is the format string used when encoding the field for JSON and XML. If not provided, it defaults to the primary format with any minimum width removed. If the primary is not given, both default to "%s". .Sh EXAMPLE In this example, the value for the number of items in stock is emitted: .Bd -literal -offset indent xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\\n", instock); .Ed .Pp This call will generate the following output: .Bd -literal -offset indent TEXT: In stock: 144 XML: 144 JSON: "in-stock": 144, HTML:
In stock
:
144
.Ed .Pp Clearly HTML wins the verbosity award, and this output does not include .Dv XOF_XPATH or .Dv XOF_INFO data, which would expand the penultimate line to: .Bd -literal -offset indent
144
.Ed .Sh WHAT MAKES A GOOD FIELD NAME? To make useful, consistent field names, follow these guidelines: .Ss "Use lower case, even for TLAs" Lower case is more civilized. Even TLAs should be lower case to avoid scenarios where the differences between "XPath" and "Xpath" drive your users crazy. Using "xpath" is simpler and better. .Ss "Use hyphens, not underscores" Use of hyphens is traditional in XML, and the .Dv XOF_UNDERSCORES flag can be used to generate underscores in JSON, if desired. But the raw field name should use hyphens. .Ss "Use full words" Do not abbreviate especially when the abbreviation is not obvious or not widely used. Use "data-size", not "dsz" or "dsize". Use "interface" instead of "ifname", "if-name", "iface", "if", or "intf". .Ss "Use -" Using the form - or -- helps in making consistent, useful names, avoiding the situation where one app uses "sent-packet" and another "packets-sent" and another "packets-we-have-sent". The can be dropped when it is obvious, as can obvious words in the classification. Use "receive-after-window-packets" instead of "received-packets-of-data-after-window". .Ss "Reuse existing field names" Nothing is worse than writing expressions like: .Bd -literal -offset indent if ($src1/process[pid == $pid]/name == $src2/proc-table/proc/p[process-id == $pid]/proc-name) { ... } .Ed .Pp Find someone else who is expressing similar data and follow their fields and hierarchy. Remember the quote is not .Dq "Consistency is the hobgoblin of little minds" but .Dq "A foolish consistency is the hobgoblin of little minds" . .Ss "Think about your users" Have empathy for your users, choosing clear and useful fields that contain clear and useful data. You may need to augment the display content with .Xr xo_attr 3 calls or "{e:}" fields to make the data useful. .Ss "Do not use an arbitrary number postfix" What does "errors2" mean? No one will know. "errors-after-restart" would be a better choice. Think of your users, and think of the future. If you make "errors2", the next guy will happily make "errors3" and before you know it, someone will be asking what is the difference between errors37 and errors63. .Ss "Be consistent, uniform, unsurprising, and predictable" Think of your field vocabulary as an API. You want it useful, expressive, meaningful, direct, and obvious. You want the client application's programmer to move between without the need to understand a variety of opinions on how fields are named. They should see the system as a single cohesive whole, not a sack of cats. .Pp Field names constitute the means by which client programmers interact with our system. By choosing wise names now, you are making their lives better. .Pp After using .Xr xolint 1 to find errors in your field descriptors, use .Dq "xolint -V" to spell check your field names and to detect different names for the same data. .Dq dropped-short and .Dq dropped-too-short are both reasonable names, but using them both will lead users to ask the difference between the two fields. If there is no difference, use only one of the field names. If there is a difference, change the names to make that difference more obvious. .Sh SEE ALSO .Xr libxo 3 , .Xr xolint 1 , .Xr xo_emit 3 Index: vendor/Juniper/libxo/dist/libxo/xo_open_container.3 =================================================================== --- vendor/Juniper/libxo/dist/libxo/xo_open_container.3 (revision 296964) +++ vendor/Juniper/libxo/dist/libxo/xo_open_container.3 (revision 296965) @@ -1,188 +1,188 @@ .\" # .\" # Copyright (c) 2014, Juniper Networks, Inc. .\" # All rights reserved. .\" # This SOFTWARE is licensed under the LICENSE provided in the .\" # ../Copyright file. By downloading, installing, copying, or .\" # using the SOFTWARE, you agree to be bound by the terms of that .\" # LICENSE. .\" # Phil Shafer, July 2014 .\" .Dd December 4, 2014 .Dt LIBXO 3 .Os .Sh NAME .Nm xo_open_container , xo_open_container_h , xo_open_container_hd , xo_open_container_d .Nm xo_close_container , xo_close_container_h , xo_close_container_hd , xo_close_container_d .Nd open (and close) container constructs .Sh LIBRARY .Lb libxo .Sh SYNOPSIS .In libxo/xo.h .Ft int .Fn xo_open_container "const char *name" .Ft int .Fn xo_open_container_h "xo_handle_t *handle" "const char *name" .Ft int .Fn xo_open_container_hd "xo_handle_t *handle" "const char *name" .Ft int .Fn xo_open_container_d "const char *name" .Ft int .Fn xo_close_container "const char *name" .Ft int .Fn xo_close_container_h "xo_handle_t *handle" "const char *name" .Ft int .Fn xo_close_container_hd "xo_handle_t *handle" .Ft int .Fn xo_close_container_d "void" .Sh DESCRIPTION .Nm libxo represents two types of hierarchy: .Dq containers and .Dq lists . A container appears once under a given parent where a list contains instances that can appear multiple times. A container is used to hold related fields and to give the data organization and scope. The container has no value, but serves to contain other nodes. .Pp To open a container, call .Fn xo_open_container or .Fn xo_open_container_h . The former uses the default handle and the latter accepts a specific handle. .Pp To close a level, use the .Fn xo_close_container or .Fn xo_close_container_h functions. .Pp Each open call should have a matching close call. If the .Dv XOF_WARN flag is set and the name given does not match the name of the currently open container, a warning will be generated. .Bd -literal -offset indent -compact Example: xo_open_container("top"); xo_open_container("system"); xo_emit("{:host-name/%s%s%s", hostname, domainname ? "." : "", domainname ?: ""); xo_close_container("system"); xo_close_container("top"); Sample Output: Text: my-host.example.org XML: my-host.example.org JSON: "top" : { "system" : { "host-name": "my-host.example.org" } } HTML:
my-host.example.org
.Ed .Sh EMITTING HIERARCHY To create a container, use the .Fn xo_open_container and .Fn xo_close_container set of functions. The .Fa handle parameter contains a handle such as returned by .Xr xo_create 3 or .Dv NULL to use the default handle. The .Fa name parameter gives the name of the container, encoded in .Em UTF-8 . Since .Em ASCII is a proper subset of .Em UTF-8 , traditional C strings can be used directly. .Pp The close functions with the .Dq _d suffix are used in -.Dq \&Do The Right Thing +.Dq Do The Right Thing mode, where the name of the open containers, lists, and instances are maintained internally by .Nm libxo to allow the caller to avoid keeping track of the open container name. .Pp Use the .Dv XOF_WARN flag to generate a warning if the name given on the close does not match the current open container. .Pp For TEXT and HTML output, containers are not rendered into output text, though for HTML they are used when the .Dv XOF_XPATH flag is set. .Pp .Bd -literal -offset indent -compact EXAMPLE: xo_open_container("system"); xo_emit("The host name is {:host-name}\n", hn); xo_close_container("system"); XML: foo .Ed .Sh DTRT MODE Some users may find tracking the names of open containers, lists, and instances inconvenient. .Nm libxo offers a -.Dq \&Do The Right Thing +.Dq Do The Right Thing mode, where .Nm libxo will track the names of open containers, lists, and instances so the close function can be called without a name. To enable .Em DTRT mode, turn on the .Dv XOF_DTRT flag prior to making any other .Nm libxo output. .Bd -literal -offset indent -compact xo_set_flags(NULL, XOF_DTRT); .Ed Each open and close function has a version with the suffix .Dq _d , which will close the open container, list, or instance: .Bd -literal -offset indent -compact xo_open_container("top"); ... xo_close_container_d(); .Ed Note that the .Dv XOF_WARN flag will also cause .Nm libxo to track open containers, lists, and instances. A warning is generated when the name given to the close function and the name recorded do not match. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 Index: vendor/Juniper/libxo/dist/libxo/xo_syslog.c =================================================================== --- vendor/Juniper/libxo/dist/libxo/xo_syslog.c (revision 296964) +++ vendor/Juniper/libxo/dist/libxo/xo_syslog.c (revision 296965) @@ -1,706 +1,706 @@ /* * Copyright (c) 2015, Juniper Networks, Inc. * All rights reserved. * This SOFTWARE is licensed under the LICENSE provided in the * ../Copyright file. By downloading, installing, copying, or otherwise * using the SOFTWARE, you agree to be bound by the terms of that * LICENSE. * Phil Shafer, June 2015 */ /* * Portions of this file are: * Copyright (c) 1983, 1988, 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. * 4. 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. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "xo_config.h" #include "xo.h" #include "xo_encoder.h" /* For xo_realloc */ #include "xo_buf.h" /* * SYSLOG (RFC 5424) requires an enterprise identifier. This turns * out to be a fickle little issue. For a single-vendor box, the * system should have a single EID that all software can use. When * VendorX turns FreeBSD into a product, all software (kernel and * utilities) should report VendorX's EID. But when software is * installed on top of an external operating system, the application * should report it's own EID, distinct from the base OS. * * To make this happen, the kernel should support a sysctl to assign a * custom enterprise-id ("kern.syslog.enterprise_id"). libxo then * allows an application to set a custom EID to override that system * wide value, if needed. * * We try to set the stock IANA assigned Enterprise ID value for the * vendors we know about (FreeBSD, macosx), but fallback to the * "example" EID defined by IANA. See: * https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers */ #define XO_SYSLOG_ENTERPRISE_ID "kern.syslog.enterprise_id" #if defined(__FreeBSD__) #define XO_DEFAULT_EID 2238 #elif defined(__macosx__) #define XO_DEFAULT_EID 63 #else -#define XO_DEFAULT_EID 32473 /* Bail; use "example" number */ +#define XO_DEFAULT_EID 32473 /* Fallback to the "example" number */ #endif #ifdef _SC_HOST_NAME_MAX #define HOST_NAME_MAX _SC_HOST_NAME_MAX #else #define HOST_NAME_MAX 255 #endif /* _SC_HOST_NAME_MAX */ #ifndef UNUSED #define UNUSED __attribute__ ((__unused__)) #endif /* UNUSED */ static int xo_logfile = -1; /* fd for log */ static int xo_status; /* connection xo_status */ static int xo_opened; /* have done openlog() */ static int xo_logstat = 0; /* xo_status bits, set by openlog() */ static const char *xo_logtag = NULL; /* string to tag the entry with */ static int xo_logfacility = LOG_USER; /* default facility code */ static int xo_logmask = 0xff; /* mask of priorities to be logged */ static pthread_mutex_t xo_syslog_mutex UNUSED = PTHREAD_MUTEX_INITIALIZER; static int xo_unit_test; /* Fake data for unit test */ #define REAL_VOID(_x) \ do { int really_ignored = _x; if (really_ignored) { }} while (0) #if !defined(HAVE_DECL___ISTHREADED) || !HAVE_DECL___ISTHREADED #define __isthreaded 1 #endif #define THREAD_LOCK() \ do { \ if (__isthreaded) pthread_mutex_lock(&xo_syslog_mutex); \ } while(0) #define THREAD_UNLOCK() \ do { \ if (__isthreaded) pthread_mutex_unlock(&xo_syslog_mutex); \ } while(0) static void xo_disconnect_log(void); /* disconnect from syslogd */ static void xo_connect_log(void); /* (re)connect to syslogd */ static void xo_open_log_unlocked(const char *, int, int); enum { NOCONN = 0, CONNDEF, CONNPRIV, }; static xo_syslog_open_t xo_syslog_open; static xo_syslog_send_t xo_syslog_send; static xo_syslog_close_t xo_syslog_close; static char xo_syslog_enterprise_id[12]; /* * Record an enterprise ID, which functions as a namespace for syslog * messages. The value is pre-formatted into a string. This allows * applications to customize their syslog message set, when needed. */ void xo_set_syslog_enterprise_id (unsigned short eid) { snprintf(xo_syslog_enterprise_id, sizeof(xo_syslog_enterprise_id), "%u", eid); } /* * Handle the work of transmitting the syslog message */ static void xo_send_syslog (char *full_msg, char *v0_hdr, char *text_only) { if (xo_syslog_send) { xo_syslog_send(full_msg, v0_hdr, text_only); return; } int fd; int full_len = strlen(full_msg); /* Output to stderr if requested. */ if (xo_logstat & LOG_PERROR) { struct iovec iov[3]; struct iovec *v = iov; char newline[] = "\n"; v->iov_base = v0_hdr; v->iov_len = strlen(v0_hdr); v += 1; v->iov_base = text_only; v->iov_len = strlen(text_only); v += 1; v->iov_base = newline; v->iov_len = 1; v += 1; REAL_VOID(writev(STDERR_FILENO, iov, 3)); } /* Get connected, output the message to the local logger. */ if (!xo_opened) xo_open_log_unlocked(xo_logtag, xo_logstat | LOG_NDELAY, 0); xo_connect_log(); /* * If the send() fails, there are two likely scenarios: * 1) syslogd was restarted * 2) /var/run/log is out of socket buffer space, which * in most cases means local DoS. * If the error does not indicate a full buffer, we address * case #1 by attempting to reconnect to /var/run/log[priv] * and resending the message once. * * If we are working with a privileged socket, the retry * attempts end there, because we don't want to freeze a * critical application like su(1) or sshd(8). * * Otherwise, we address case #2 by repeatedly retrying the * send() to give syslogd a chance to empty its socket buffer. */ if (send(xo_logfile, full_msg, full_len, 0) < 0) { if (errno != ENOBUFS) { /* * Scenario 1: syslogd was restarted * reconnect and resend once */ xo_disconnect_log(); xo_connect_log(); if (send(xo_logfile, full_msg, full_len, 0) >= 0) { return; } /* * if the resend failed, fall through to * possible scenario 2 */ } while (errno == ENOBUFS) { /* * Scenario 2: out of socket buffer space * possible DoS, fail fast on a privileged * socket */ if (xo_status == CONNPRIV) break; usleep(1); if (send(xo_logfile, full_msg, full_len, 0) >= 0) { return; } } } else { return; } /* * Output the message to the console; try not to block * as a blocking console should not stop other processes. * Make sure the error reported is the one from the syslogd failure. */ int flags = O_WRONLY | O_NONBLOCK; #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif /* O_CLOEXEC */ if (xo_logstat & LOG_CONS && (fd = open(_PATH_CONSOLE, flags, 0)) >= 0) { struct iovec iov[2]; struct iovec *v = iov; char crnl[] = "\r\n"; char *p; p = strchr(full_msg, '>') + 1; v->iov_base = p; v->iov_len = full_len - (p - full_msg); ++v; v->iov_base = crnl; v->iov_len = 2; REAL_VOID(writev(fd, iov, 2)); (void) close(fd); } } /* Should be called with mutex acquired */ static void xo_disconnect_log (void) { if (xo_syslog_close) { xo_syslog_close(); return; } /* * If the user closed the FD and opened another in the same slot, * that's their problem. They should close it before calling on * system services. */ if (xo_logfile != -1) { close(xo_logfile); xo_logfile = -1; } xo_status = NOCONN; /* retry connect */ } /* Should be called with mutex acquired */ static void xo_connect_log (void) { if (xo_syslog_open) { xo_syslog_open(); return; } struct sockaddr_un saddr; /* AF_UNIX address of local logger */ if (xo_logfile == -1) { int flags = SOCK_DGRAM; #ifdef SOCK_CLOEXEC flags |= SOCK_CLOEXEC; #endif /* SOCK_CLOEXEC */ if ((xo_logfile = socket(AF_UNIX, flags, 0)) == -1) return; } if (xo_logfile != -1 && xo_status == NOCONN) { #ifdef HAVE_SUN_LEN saddr.sun_len = sizeof(saddr); #endif /* HAVE_SUN_LEN */ saddr.sun_family = AF_UNIX; /* * First try privileged socket. If no success, * then try default socket. */ #ifdef _PATH_LOG_PRIV (void) strncpy(saddr.sun_path, _PATH_LOG_PRIV, sizeof saddr.sun_path); if (connect(xo_logfile, (struct sockaddr *) &saddr, sizeof(saddr)) != -1) xo_status = CONNPRIV; #endif /* _PATH_LOG_PRIV */ #ifdef _PATH_LOG if (xo_status == NOCONN) { (void) strncpy(saddr.sun_path, _PATH_LOG, sizeof saddr.sun_path); if (connect(xo_logfile, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) xo_status = CONNDEF; } #endif /* _PATH_LOG */ #ifdef _PATH_OLDLOG if (xo_status == NOCONN) { /* * Try the old "/dev/log" path, for backward * compatibility. */ (void) strncpy(saddr.sun_path, _PATH_OLDLOG, sizeof saddr.sun_path); if (connect(xo_logfile, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) xo_status = CONNDEF; } #endif /* _PATH_OLDLOG */ if (xo_status == NOCONN) { (void) close(xo_logfile); xo_logfile = -1; } } } static void xo_open_log_unlocked (const char *ident, int logstat, int logfac) { if (ident != NULL) xo_logtag = ident; xo_logstat = logstat; if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) xo_logfacility = logfac; if (xo_logstat & LOG_NDELAY) /* open immediately */ xo_connect_log(); xo_opened = 1; /* ident and facility has been set */ } void xo_open_log (const char *ident, int logstat, int logfac) { THREAD_LOCK(); xo_open_log_unlocked(ident, logstat, logfac); THREAD_UNLOCK(); } void xo_close_log (void) { THREAD_LOCK(); if (xo_logfile != -1) { (void) close(xo_logfile); xo_logfile = -1; } xo_logtag = NULL; xo_status = NOCONN; THREAD_UNLOCK(); } /* xo_set_logmask -- set the log mask level */ int xo_set_logmask (int pmask) { int omask; THREAD_LOCK(); omask = xo_logmask; if (pmask != 0) xo_logmask = pmask; THREAD_UNLOCK(); return (omask); } void xo_set_syslog_handler (xo_syslog_open_t open_func, xo_syslog_send_t send_func, xo_syslog_close_t close_func) { xo_syslog_open = open_func; xo_syslog_send = send_func; xo_syslog_close = close_func; } static size_t xo_snprintf (char *out, size_t outsize, const char *fmt, ...) { int status; size_t retval = 0; va_list ap; if (out && outsize) { va_start(ap, fmt); status = vsnprintf(out, outsize, fmt, ap); if (status < 0) { /* this should never happen, */ *out = 0; /* handle it in the safest way possible if it does */ retval = 0; } else { retval = status; retval = retval > outsize ? outsize : retval; } va_end(ap); } return retval; } static int xo_syslog_handle_write (void *opaque, const char *data) { xo_buffer_t *xbp = opaque; int len = strlen(data); int left = xo_buf_left(xbp); if (len > left - 1) len = left - 1; memcpy(xbp->xb_curp, data, len); xbp->xb_curp += len; *xbp->xb_curp = '\0'; return len; } static void xo_syslog_handle_close (void *opaque UNUSED) { } static int xo_syslog_handle_flush (void *opaque UNUSED) { return 0; } void xo_set_unit_test_mode (int value) { xo_unit_test = value; } void xo_vsyslog (int pri, const char *name, const char *fmt, va_list vap) { int saved_errno = errno; char tbuf[2048]; char *tp = NULL, *ep = NULL; unsigned start_of_msg = 0; char *v0_hdr = NULL; xo_buffer_t xb; static pid_t my_pid; unsigned log_offset; if (my_pid == 0) my_pid = xo_unit_test ? 222 : getpid(); /* Check for invalid bits */ if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) { xo_syslog(LOG_ERR | LOG_CONS | LOG_PERROR | LOG_PID, "syslog-unknown-priority", "syslog: unknown facility/priority: %#x", pri); pri &= LOG_PRIMASK|LOG_FACMASK; } THREAD_LOCK(); /* Check priority against setlogmask values. */ if (!(LOG_MASK(LOG_PRI(pri)) & xo_logmask)) { THREAD_UNLOCK(); return; } /* Set default facility if none specified. */ if ((pri & LOG_FACMASK) == 0) pri |= xo_logfacility; /* Create the primary stdio hook */ xb.xb_bufp = tbuf; xb.xb_curp = tbuf; xb.xb_size = sizeof(tbuf); xo_handle_t *xop = xo_create(XO_STYLE_SDPARAMS, 0); if (xop == NULL) { THREAD_UNLOCK(); return; } #ifdef HAVE_GETPROGNAME if (xo_logtag == NULL) xo_logtag = getprogname(); #endif /* HAVE_GETPROGNAME */ xo_set_writer(xop, &xb, xo_syslog_handle_write, xo_syslog_handle_close, xo_syslog_handle_flush); /* Build the message; start by getting the time */ struct tm tm; struct timeval tv; /* Unit test hack: fake a fixed time */ if (xo_unit_test) { tv.tv_sec = 1435085229; tv.tv_usec = 123456; } else gettimeofday(&tv, NULL); (void) localtime_r(&tv.tv_sec, &tm); if (xo_logstat & LOG_PERROR) { /* * For backwards compatibility, we need to make the old-style * message. This message can be emitted to the console/tty. */ v0_hdr = alloca(2048); tp = v0_hdr; ep = v0_hdr + 2048; if (xo_logtag != NULL) tp += xo_snprintf(tp, ep - tp, "%s", xo_logtag); if (xo_logstat & LOG_PID) tp += xo_snprintf(tp, ep - tp, "[%d]", my_pid); if (xo_logtag) tp += xo_snprintf(tp, ep - tp, ": "); } log_offset = xb.xb_curp - xb.xb_bufp; /* Add PRI, PRIVAL, and VERSION */ xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "<%d>1 ", pri); /* Add TIMESTAMP with milliseconds and TZOFFSET */ xb.xb_curp += strftime(xb.xb_curp, xo_buf_left(&xb), "%FT%T", &tm); xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), ".%03.3u", tv.tv_usec / 1000); xb.xb_curp += strftime(xb.xb_curp, xo_buf_left(&xb), "%z ", &tm); /* * Add HOSTNAME; we rely on gethostname and don't fluff with * ip addresses. Might need to revisit..... */ char hostname[HOST_NAME_MAX]; hostname[0] = '\0'; if (xo_unit_test) strcpy(hostname, "worker-host"); else (void) gethostname(hostname, sizeof(hostname)); xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "%s ", hostname[0] ? hostname : "-"); /* Add APP-NAME */ xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "%s ", xo_logtag ?: "-"); /* Add PROCID */ xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "%d ", my_pid); /* * Add MSGID. The user should provide us with a name, which we * prefix with the current enterprise ID, as learned from the kernel. * If the kernel won't tell us, we use the stock/builtin number. */ char *buf UNUSED = NULL; const char *eid = xo_syslog_enterprise_id; const char *at_sign = "@"; if (name == NULL) { name = "-"; eid = at_sign = ""; } else if (*name == '@') { /* Our convention is to prefix IANA-defined names with an "@" */ name += 1; eid = at_sign = ""; } else if (eid[0] == '\0') { #ifdef HAVE_SYSCTLBYNAME /* * See if the kernel knows the sysctl for the enterprise ID */ size_t size = 0; if (sysctlbyname(XO_SYSLOG_ENTERPRISE_ID, NULL, &size, NULL, 0) == 0 && size > 0) { buf = alloca(size); if (sysctlbyname(XO_SYSLOG_ENTERPRISE_ID, buf, &size, NULL, 0) == 0 && size > 0) eid = buf; } #endif /* HAVE_SYSCTLBYNAME */ if (eid[0] == '\0') { /* Fallback to our base default */ xo_set_syslog_enterprise_id(XO_DEFAULT_EID); eid = xo_syslog_enterprise_id; } } xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "%s [%s%s%s ", name, name, at_sign, eid); /* * Now for the real content. We make two distinct passes thru the * xo_emit engine, first for the SD-PARAMS and then for the text * message. */ va_list ap; va_copy(ap, vap); errno = saved_errno; /* Restore saved error value */ xo_emit_hv(xop, fmt, ap); xo_flush_h(xop); va_end(ap); /* Trim trailing space */ if (xb.xb_curp[-1] == ' ') xb.xb_curp -= 1; /* Close the structured data (SD-ELEMENT) */ xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "] "); /* * Since our MSG is known to be UTF-8, we MUST prefix it with * that most-annoying-of-all-UTF-8 features, the BOM (0xEF.BB.BF). */ xb.xb_curp += xo_snprintf(xb.xb_curp, xo_buf_left(&xb), "%c%c%c", 0xEF, 0xBB, 0xBF); /* Save the start of the message */ if (xo_logstat & LOG_PERROR) start_of_msg = xb.xb_curp - xb.xb_bufp; xo_set_style(xop, XO_STYLE_TEXT); xo_set_flags(xop, XOF_UTF8); errno = saved_errno; /* Restore saved error value */ xo_emit_hv(xop, fmt, ap); xo_flush_h(xop); /* Remove a trailing newline */ if (xb.xb_curp[-1] == '\n') *--xb.xb_curp = '\0'; if (xo_get_flags(xop) & XOF_LOG_SYSLOG) fprintf(stderr, "xo: syslog: %s\n", xb.xb_bufp + log_offset); xo_send_syslog(xb.xb_bufp, v0_hdr, xb.xb_bufp + start_of_msg); xo_destroy(xop); THREAD_UNLOCK(); } /* * syslog - print message on log file; output is intended for syslogd(8). */ void xo_syslog (int pri, const char *name, const char *fmt, ...) { va_list ap; va_start(ap, fmt); xo_vsyslog(pri, name, fmt, ap); va_end(ap); }