├── .copr └── Makefile ├── .github └── workflows │ └── c-cpp.yml ├── .gitignore ├── .mailmap ├── AUTHORS.md ├── COPYRIGHT ├── DIFFERENCES ├── GNUmakefile ├── LICENSE ├── README.md ├── TODO ├── TRADEOFFS ├── bsdutils.spec.in ├── compat ├── expand_number.c ├── getbsize.c ├── heapsort.c ├── humanize_number.c ├── merge.c ├── meson.build ├── setmode.c ├── signames.c ├── strlcat.c ├── strlcpy.c ├── strmode.c └── vis.c ├── include ├── compat.h ├── sys │ └── cdefs.h └── vis.h ├── meson.build ├── meson_options.txt ├── src ├── basename │ ├── basename.1 │ ├── basename.c │ └── meson.build ├── bc │ ├── bc.1 │ ├── bc.library │ ├── bc.y │ ├── extern.h │ ├── meson.build │ ├── pathnames.h │ ├── scan.l │ └── tty.c ├── cat │ ├── cat.1 │ ├── cat.c │ └── meson.build ├── chmod │ ├── chmod.1 │ ├── chmod.c │ └── meson.build ├── chown │ ├── chgrp.1 │ ├── chown.8 │ ├── chown.c │ └── meson.build ├── chroot │ ├── .#chroot. │ ├── chroot.8 │ ├── chroot.c │ └── meson.build ├── cksum │ ├── cksum.1 │ ├── cksum.c │ ├── crc.c │ ├── crc32.c │ ├── extern.h │ ├── meson.build │ ├── print.c │ ├── sum.1 │ ├── sum1.c │ └── sum2.c ├── comm │ ├── comm.1 │ ├── comm.c │ └── meson.build ├── cp │ ├── cp.1 │ ├── cp.c │ ├── extern.h │ ├── meson.build │ └── utils.c ├── csplit │ ├── csplit.1 │ ├── csplit.c │ └── meson.build ├── cut │ ├── cut.1 │ ├── cut.c │ └── meson.build ├── date │ ├── date.1 │ ├── date.c │ ├── meson.build │ ├── vary.c │ └── vary.h ├── dc │ ├── bcode.c │ ├── bcode.h │ ├── dc.1 │ ├── dc.c │ ├── extern.h │ ├── inout.c │ ├── mem.c │ ├── meson.build │ └── stack.c ├── dd │ ├── args.c │ ├── conv.c │ ├── conv_tab.c │ ├── dd.1 │ ├── dd.c │ ├── dd.h │ ├── extern.h │ ├── gen.c │ ├── meson.build │ ├── misc.c │ ├── position.c │ ├── ref.ascii │ ├── ref.ebcdic │ ├── ref.ibm │ ├── ref.lcase │ ├── ref.obs_zeroes │ ├── ref.oldascii │ ├── ref.oldebcdic │ ├── ref.oldibm │ ├── ref.pareven │ ├── ref.parnone │ ├── ref.parodd │ ├── ref.parset │ ├── ref.swab │ └── ref.ucase ├── df │ ├── df.1 │ ├── df.c │ ├── meson.build │ └── vfslist.c ├── dirname │ ├── dirname.c │ └── meson.build ├── du │ ├── du.1 │ ├── du.c │ └── meson.build ├── echo │ ├── echo.1 │ ├── echo.c │ └── meson.build ├── env │ ├── env.1 │ ├── env.c │ ├── envopts.c │ ├── envopts.h │ └── meson.build ├── expand │ ├── expand.1 │ ├── expand.c │ └── meson.build ├── expr │ ├── expr.1 │ ├── expr.y │ └── meson.build ├── factor │ ├── factor.6 │ ├── factor.c │ ├── meson.build │ ├── pr_tbl.c │ └── primes.h ├── false │ ├── false.1 │ ├── false.c │ └── meson.build ├── find │ ├── extern.h │ ├── find.1 │ ├── find.c │ ├── find.h │ ├── function.c │ ├── getdate.y │ ├── ls.c │ ├── main.c │ ├── meson.build │ ├── misc.c │ ├── operator.c │ └── option.c ├── fmt │ ├── fmt.1 │ ├── fmt.c │ └── meson.build ├── fold │ ├── fold.1 │ ├── fold.c │ └── meson.build ├── head │ ├── head.1 │ ├── head.c │ └── meson.build ├── hexdump │ ├── conv.c │ ├── display.c │ ├── hexdump.1 │ ├── hexdump.c │ ├── hexdump.h │ ├── hexsyntax.c │ ├── meson.build │ ├── od.1 │ ├── odsyntax.c │ └── parse.c ├── hostname │ ├── hostname.1 │ ├── hostname.c │ └── meson.build ├── id │ ├── groups.1 │ ├── id.1 │ ├── id.c │ ├── meson.build │ └── whoami.1 ├── join │ ├── join.1 │ ├── join.c │ └── meson.build ├── kill │ ├── kill.1 │ ├── kill.c │ └── meson.build ├── ln │ ├── ln.1 │ ├── ln.c │ ├── meson.build │ └── symlink.7 ├── logname │ ├── logname.1 │ ├── logname.c │ └── meson.build ├── ls │ ├── cmp.c │ ├── extern.h │ ├── ls.1 │ ├── ls.c │ ├── ls.h │ ├── meson.build │ ├── print.c │ └── util.c ├── meson.build ├── mkdir │ ├── meson.build │ ├── mkdir.1 │ └── mkdir.c ├── mkfifo │ ├── meson.build │ ├── mkfifo.1 │ └── mkfifo.c ├── mknod │ ├── meson.build │ ├── mknod.8 │ └── mknod.c ├── mktemp │ ├── meson.build │ ├── mktemp.1 │ └── mktemp.c ├── mv │ ├── meson.build │ ├── mv.1 │ └── mv.c ├── nice │ ├── meson.build │ ├── nice.1 │ └── nice.c ├── nl │ ├── meson.build │ ├── nl.1 │ └── nl.c ├── nohup │ ├── meson.build │ ├── nohup.1 │ └── nohup.c ├── paste │ ├── meson.build │ ├── paste.1 │ └── paste.c ├── pathchk │ ├── meson.build │ ├── pathchk.1 │ └── pathchk.c ├── pr │ ├── egetopt.c │ ├── extern.h │ ├── meson.build │ ├── pr.1 │ ├── pr.c │ └── pr.h ├── printenv │ ├── meson.build │ ├── printenv.1 │ └── printenv.c ├── printf │ ├── meson.build │ ├── printf.1 │ └── printf.c ├── pwd │ ├── meson.build │ ├── pwd.1 │ └── pwd.c ├── realpath │ ├── meson.build │ ├── realpath.1 │ └── realpath.c ├── rm │ ├── meson.build │ ├── rm.1 │ └── rm.c ├── rmdir │ ├── meson.build │ ├── rmdir.1 │ └── rmdir.c ├── sed │ ├── POSIX │ ├── compile.c │ ├── defs.h │ ├── extern.h │ ├── main.c │ ├── meson.build │ ├── misc.c │ ├── process.c │ └── sed.1 ├── seq │ ├── meson.build │ ├── seq.1 │ └── seq.c ├── sleep │ ├── meson.build │ ├── sleep.1 │ └── sleep.c ├── sort │ ├── bwstring.c │ ├── bwstring.h │ ├── coll.c │ ├── coll.h │ ├── file.c │ ├── file.h │ ├── mem.c │ ├── mem.h │ ├── meson.build │ ├── radixsort.c │ ├── radixsort.h │ ├── sort.1 │ ├── sort.c │ ├── sort.h │ ├── vsort.c │ └── vsort.h ├── split │ ├── meson.build │ ├── split.1 │ └── split.c ├── stat │ ├── meson.build │ ├── stat.1 │ └── stat.c ├── stdbuf │ ├── meson.build │ ├── stdbuf.1 │ └── stdbuf.c ├── stty │ ├── cchar.c │ ├── extern.h │ ├── gfmt.c │ ├── key.c │ ├── meson.build │ ├── modes.c │ ├── print.c │ ├── stty.1 │ ├── stty.c │ ├── stty.h │ └── util.c ├── sync │ ├── meson.build │ ├── sync.8 │ └── sync.c ├── tail │ ├── extern.h │ ├── forward.c │ ├── meson.build │ ├── misc.c │ ├── read.c │ ├── reverse.c │ ├── tail.1 │ └── tail.c ├── tee │ ├── meson.build │ ├── tee.1 │ └── tee.c ├── test │ ├── install.sh │ ├── meson.build │ ├── test.1 │ └── test.c ├── timeout │ ├── meson.build │ ├── timeout.1 │ └── timeout.c ├── touch │ ├── meson.build │ ├── touch.1 │ └── touch.c ├── tr │ ├── cmap.c │ ├── cmap.h │ ├── cset.c │ ├── cset.h │ ├── extern.h │ ├── meson.build │ ├── str.c │ ├── tr.1 │ └── tr.c ├── true │ ├── meson.build │ ├── true.1 │ └── true.c ├── truncate │ ├── meson.build │ ├── truncate.1 │ └── truncate.c ├── tsort │ ├── meson.build │ ├── tsort.1 │ └── tsort.c ├── tty │ ├── meson.build │ ├── tty.1 │ └── tty.c ├── uname │ ├── meson.build │ ├── uname.1 │ └── uname.c ├── unexpand │ ├── meson.build │ ├── unexpand.1 │ └── unexpand.c ├── uniq │ ├── meson.build │ ├── uniq.1 │ └── uniq.c ├── users │ ├── meson.build │ ├── users.1 │ └── users.cc ├── wc │ ├── meson.build │ ├── wc.1 │ └── wc.c ├── which │ ├── meson.build │ ├── which.1 │ └── which.c ├── who │ ├── meson.build │ ├── who.1 │ └── who.c ├── xargs │ ├── meson.build │ ├── pathnames.h │ ├── strnsubst.c │ ├── xargs.1 │ └── xargs.c ├── xinstall │ ├── install.1 │ ├── install.sh │ ├── meson.build │ └── xinstall.c └── yes │ ├── meson.build │ ├── yes.1 │ └── yes.c ├── upstream.conf └── utils ├── find-ninja.sh ├── import-src.sh └── install-link.sh /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | paths: 7 | - 'meson.build' 8 | - 'compat/**' 9 | - 'include/**' 10 | - 'src/**' 11 | - '.github/workflows/**' 12 | 13 | pull_request: 14 | branches: [ master ] 15 | paths: 16 | - 'meson.build' 17 | - 'compat/**' 18 | - 'include/**' 19 | - 'src/**' 20 | - '.github/workflows/**' 21 | 22 | jobs: 23 | glibc: 24 | runs-on: ubuntu-latest 25 | 26 | container: 27 | image: "fedora:latest" 28 | 29 | steps: 30 | - name: dependencies 31 | run: | 32 | sudo dnf install -y gcc gcc-c++ flex bison meson ninja-build make libedit-devel libcurl-devel libxo-devel openssl-devel 33 | 34 | - uses: actions/checkout@v2 35 | 36 | - name: build and check 37 | run: | 38 | meson setup build -Db_buildtype=debug 39 | ninja -C build -v 40 | meson test -C build -v 41 | 42 | musl: 43 | runs-on: ubuntu-latest 44 | 45 | container: 46 | image: "alpine:latest" 47 | 48 | steps: 49 | - name: dependencies 50 | run: | 51 | apk add curl git libtool autoconf automake make patch gcc musl-dev linux-headers g++ meson flex bison libedit-dev openssl-dev musl-fts-dev acl-dev 52 | 53 | - name: libxo 54 | run: | 55 | # installed separately 56 | apk add bsd-compat-headers 57 | VER="$(git ls-remote --tag https://github.com/Juniper/libxo | grep -E "\/[0-9\.]+$" | rev | cut -d '/' -f 1 | rev | sort -n | tail -n 1)" 58 | curl -k -f -L -O https://github.com/Juniper/libxo/releases/download/${VER}/libxo-${VER}.tar.gz 59 | tar -xf libxo-${VER}.tar.gz 60 | cd libxo-${VER} 61 | 62 | # remove this once it's merged and a new release includes it 63 | curl -k -f -L -O https://github.com/Juniper/libxo/pull/82.patch 64 | [ -f 82.patch ] && patch -p1 < 82.patch 65 | 66 | ./configure --prefix=/usr/local 67 | make V=1 68 | make V=1 install 69 | 70 | # make sure it does not interfere with bsdutils 71 | apk del bsd-compat-headers 72 | 73 | - name: rpmatch for musl 74 | run: | 75 | git clone https://github.com/pullmoll/musl-rpmatch 76 | cd musl-rpmatch 77 | ./bootstrap.sh 78 | ./configure --prefix=/usr/local 79 | make 80 | make install 81 | 82 | - uses: actions/checkout@v2 83 | 84 | - name: build and check 85 | run: | 86 | meson setup build --werror -Db_buildtype=debug -Drpmatch_path=/usr/local/lib 87 | ninja -C build -v 88 | meson test -C build -v 89 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.orig 2 | build 3 | Makefile.bsd 4 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | David Cantrell David Cantrell 2 | David Cantrell David Cantrell 3 | Daniel Kolesa q66 4 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | - Daniel Kolesa 2 | 3 | - David Cantrell 4 | 5 | - James Bair 6 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | MESON_BUILD_DIR = build 2 | topdir := $(shell realpath $(dir $(lastword $(MAKEFILE_LIST)))) 3 | 4 | # Project information (may be an easier way to get this from meson) 5 | PROJECT_NAME = $(shell grep ^project $(topdir)/meson.build | cut -d "'" -f 2) 6 | PROJECT_VERSION = $(shell grep version $(topdir)/meson.build | grep -E ',$$' | cut -d "'" -f 2) 7 | 8 | # ninja may be called something else 9 | NINJA := $(shell $(topdir)/utils/find-ninja.sh) 10 | ifeq ($(NINJA),) 11 | NINJA = $(error "*** unable to find a suitable `ninja' command") 12 | endif 13 | 14 | all: setup 15 | $(NINJA) -C $(MESON_BUILD_DIR) -v 16 | 17 | setup: 18 | meson setup $(MESON_BUILD_DIR) 19 | 20 | check: setup 21 | meson test -C $(MESON_BUILD_DIR) -v 22 | 23 | clean: 24 | -rm -rf $(MESON_BUILD_DIR) 25 | 26 | authors: 27 | git log --pretty="%an <%ae>" | sort -u | sed -e 's|^|- |g' | sed G > AUTHORS.md 28 | head -n $$(($$(wc -l < AUTHORS.md) - 1)) AUTHORS.md > AUTHORS.md.new 29 | mv AUTHORS.md.new AUTHORS.md 30 | 31 | import: 32 | $(topdir)/utils/import-src.sh $(topdir)/upstream.conf 33 | 34 | # Quiet errors about target arguments not being targets 35 | %: 36 | @true 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This code originates from FreeBSD but has been modified for building 2 | on Linux. Please see the COPYRIGHT file for the original license and 3 | copyright terms of the FreeBSD code. 4 | 5 | Unless otherwise noted in the source file, the following license and 6 | copyright statement applies to the code created as part of this 7 | porting effort. All existing licenses and copyrights apply. 8 | 9 | This is the BSD-3-Clause license as defined on spdx.org. Individual 10 | authors will replace NAME with their name and EMAIL with their email 11 | address. The year may change as well depending on when their 12 | contribution originated. 13 | 14 | For the purposes of code originating in this port, it is under a 15 | BSD-3-Clause license from a number of different authors. 16 | 17 | /* 18 | * Copyright 2021 NAME 19 | * 20 | * Redistribution and use in source and binary forms, with or without 21 | * modification, are permitted provided that the following conditions 22 | * are met: 23 | * 24 | * 1. Redistributions of source code must retain the above copyright 25 | * notice, this list of conditions and the following disclaimer. 26 | * 27 | * 2. Redistributions in binary form must reproduce the above 28 | * copyright notice, this list of conditions and the following 29 | * disclaimer in the documentation and/or other materials provided 30 | * with the distribution. 31 | * 32 | * 3. Neither the name of the copyright holder nor the names of its 33 | * contributors may be used to endorse or promote products derived 34 | * from this software without specific prior written permission. 35 | * 36 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 37 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 38 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 39 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 40 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 41 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 42 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 43 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. 48 | */ 49 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - The following programs in coreutils are not found in the FreeBSD source tree: 2 | 3 | b2sum 4 | base32 5 | base64 6 | chcon 7 | link 8 | md5sum 9 | numfmt 10 | ptx 11 | runcon 12 | sha1sum 13 | sha224sum 14 | sha256sum 15 | sha384sum 16 | sha512sum 17 | shred 18 | shuf 19 | sum 20 | unlink 21 | 22 | - Maybe incorporate diffutils in to the tree (diff, diff3, sdiff). 23 | 24 | - awk? 25 | 26 | - patch? 27 | 28 | - Use libacl to implement the preserve ACL stuff in cp & mv and other 29 | programs that have ACL support on FreeBSD 30 | -------------------------------------------------------------------------------- /TRADEOFFS: -------------------------------------------------------------------------------- 1 | Using bsdutils in place of GNU coreutils does come with some 2 | tradeoffs. The list below highlights some of these that you should 3 | consider before making the switch: 4 | 5 | 6 | Some commands do not exist 7 | -------------------------- 8 | 9 | The following commands are specific to GNU coreutils and are not part 10 | of a BSD base system but have alternatives: 11 | 12 | COMMAND DESCRIPTION ALTERNATIVE 13 | dir list directory contents ls 14 | dircolors color setup for ls ls supports color (-G) 15 | vdir vertical 'dir' command ls 16 | hostid print numeric host identifier none - dropped in 4.4BSD 17 | 18 | The following commands are specific to GNU coreutils and have no 19 | alternative provided by a BSD system: 20 | 21 | COMMAND DESCRIPTION 22 | nproc print number of processing units available 23 | pinky lightweight finger 24 | 25 | 26 | Lack of long options 27 | -------------------- 28 | 29 | This is a usability thing, but if you have a lot of scripts that use 30 | the long options for GNU coreutils commands, you will have to change 31 | those to short options with bsdutils. Keep in mind the short options 32 | often vary between GNU and BSD commands. See each command's man page 33 | for more details. 34 | 35 | 36 | No support for SELinux 37 | ---------------------- 38 | 39 | The ls(1) command from GNU coreutils can display SELinux information 40 | in file listings. Since this is Linux-specific, the bsdutils do not 41 | have support for it. If you don't need this or don't care about 42 | SELinux, then the bsdutils should be functionally equivalent for you. 43 | 44 | Some commands have FreeBSD mac.h functionality which is sort of like 45 | SELinux on Linux. Those commands have had the mac.h functionality 46 | removed, but they would be an ideal starting point for flipping that 47 | over to SELinux on Linux systems. 48 | 49 | 50 | No translations 51 | --------------- 52 | 53 | The bsdutils commands come with very simple untranslated help output 54 | and an English language man page. There may be translated man pages 55 | in the FreeBSD source tree (we should look for those), but the 56 | commands themselves don't output text in other languages. However, 57 | text manipulation commands and things like ls(1) do work with UTF-8 58 | encodings and wide characters. 59 | -------------------------------------------------------------------------------- /bsdutils.spec.in: -------------------------------------------------------------------------------- 1 | # Historically, commerical Unix systems derived from AT&T System V 2 | # would provide software that originated at the University of 3 | # California Berkeley in the /usr/ucb directory. Some systems used 4 | # /usr/bsd. This package uses the /usr/ucb directory as the bindir as 5 | # that's how older Unix systems did it. 6 | %define _bindir %{_prefix}/ucb 7 | %define _sbindir %{_bindir} 8 | 9 | Name: bsdutils 10 | Version: %%VERSION%% 11 | Release: 1%{?dist} 12 | Summary: Userspace commands from FreeBSD 13 | Group: Development/Tools 14 | License: BSD-2-Clause AND BSD-3-Clause 15 | URL: https://github.com/dcantrell/bsdutils 16 | Source0: https://github.com/dcantrell/bsdutils/releases/download/v%{version}/%{name}-%{version}.tar.xz 17 | Source1: https://github.com/dcantrell/bsdutils/releases/download/v%{version}/%{name}-%{version}.tar.xz.asc 18 | Source2: %%GPGKEYRING%% 19 | 20 | BuildRequires: meson 21 | BuildRequires: ninja-build 22 | BuildRequires: gcc 23 | BuildRequires: gcc-c++ 24 | BuildRequires: flex 25 | BuildRequires: bison 26 | BuildRequires: ncurses-devel 27 | BuildRequires: libedit-devel 28 | BuildRequires: openssl-devel 29 | BuildRequires: libxo-devel 30 | BuildRequires: gnupg2 31 | 32 | 33 | %description 34 | Build deviation and compliance tool. This program runs a number of tests 35 | against one or two builds of source RPM files. The built artifacts are 36 | inspected and compared to report changes and validate policy compliance 37 | against the defined parameters. 38 | 39 | 40 | %prep 41 | %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' 42 | %autosetup 43 | 44 | 45 | %build 46 | %meson 47 | %meson_build 48 | 49 | 50 | %install 51 | %meson_install 52 | 53 | # Put all man pages in *b sections 54 | cd %{buildroot}%{_mandir} 55 | for section in 1 6 7 8 ; do 56 | cd man"${section}" 57 | for page in *."${section}" ; do 58 | if [ -L "${page}" ]; then 59 | target="$(readlink "${page}")" 60 | ln -sf "${target}"b "${page}"b 61 | rm "${page}" 62 | else 63 | mv "${page}" "${page}"b 64 | sed -i -e '/^\.Dt/ s/$/B/' "${page}"b 65 | fi 66 | done 67 | cd .. 68 | done 69 | cd .. 70 | 71 | 72 | %files 73 | %doc AUTHORS.md DIFFERENCES README.md TODO TRADEOFFS 74 | %license COPYRIGHT LICENSE 75 | %{_bindir}/* 76 | %{_mandir}/man1/*.1b* 77 | %{_mandir}/man6/*.6b* 78 | %{_mandir}/man7/*.7b* 79 | %{_mandir}/man8/*.8b* 80 | %{_datadir}/misc/bc.library 81 | 82 | 83 | %changelog 84 | -------------------------------------------------------------------------------- /compat/expand_number.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (c) 2007 Eric Anderson 5 | * Copyright (c) 2007 Pawel Jakub Dawidek 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | __FBSDID("$FreeBSD$"); 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | int 40 | expand_number(const char *buf, uint64_t *num) 41 | { 42 | char *endptr; 43 | uintmax_t umaxval; 44 | uint64_t number; 45 | unsigned shift; 46 | int serrno; 47 | 48 | serrno = errno; 49 | errno = 0; 50 | umaxval = strtoumax(buf, &endptr, 0); 51 | if (umaxval > UINT64_MAX) 52 | errno = ERANGE; 53 | if (errno != 0) 54 | return (-1); 55 | errno = serrno; 56 | number = umaxval; 57 | 58 | switch (tolower((unsigned char)*endptr)) { 59 | case 'e': 60 | shift = 60; 61 | break; 62 | case 'p': 63 | shift = 50; 64 | break; 65 | case 't': 66 | shift = 40; 67 | break; 68 | case 'g': 69 | shift = 30; 70 | break; 71 | case 'm': 72 | shift = 20; 73 | break; 74 | case 'k': 75 | shift = 10; 76 | break; 77 | case 'b': 78 | case '\0': /* No unit. */ 79 | *num = number; 80 | return (0); 81 | default: 82 | /* Unrecognized unit. */ 83 | errno = EINVAL; 84 | return (-1); 85 | } 86 | 87 | if ((number << shift) >> shift != number) { 88 | /* Overflow */ 89 | errno = ERANGE; 90 | return (-1); 91 | } 92 | *num = number << shift; 93 | return (0); 94 | } 95 | -------------------------------------------------------------------------------- /compat/meson.build: -------------------------------------------------------------------------------- 1 | libcompat_sources = [ 2 | 'getbsize.c', 3 | 'heapsort.c', 4 | 'humanize_number.c', 5 | 'merge.c', 6 | 'setmode.c', 7 | 'strmode.c', 8 | 'expand_number.c', 9 | 'vis.c', 10 | 'signames.c', 11 | 'strlcpy.c', 12 | 'strlcat.c', 13 | ] 14 | 15 | libcompat = static_library( 16 | 'compat', 17 | libcompat_sources, 18 | include_directories : inc, 19 | ) 20 | -------------------------------------------------------------------------------- /compat/strlcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcat.c,v 1.15 2015/03/02 21:41:08 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998, 2015 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | __FBSDID("$FreeBSD$"); 21 | 22 | #include 23 | #include 24 | 25 | /* 26 | * Appends src to string dst of size dsize (unlike strncat, dsize is the 27 | * full size of dst, not space left). At most dsize-1 characters 28 | * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). 29 | * Returns strlen(src) + MIN(dsize, strlen(initial dst)). 30 | * If retval >= dsize, truncation occurred. 31 | */ 32 | size_t 33 | strlcat(char * __restrict dst, const char * __restrict src, size_t dsize) 34 | { 35 | const char *odst = dst; 36 | const char *osrc = src; 37 | size_t n = dsize; 38 | size_t dlen; 39 | 40 | /* Find the end of dst and adjust bytes left but don't go past end. */ 41 | while (n-- != 0 && *dst != '\0') 42 | dst++; 43 | dlen = dst - odst; 44 | n = dsize - dlen; 45 | 46 | if (n-- == 0) 47 | return(dlen + strlen(src)); 48 | while (*src != '\0') { 49 | if (n != 0) { 50 | *dst++ = *src; 51 | n--; 52 | } 53 | src++; 54 | } 55 | *dst = '\0'; 56 | 57 | return(dlen + (src - osrc)); /* count does not include NUL */ 58 | } 59 | -------------------------------------------------------------------------------- /compat/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998, 2015 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | __FBSDID("$FreeBSD$"); 21 | 22 | #include 23 | #include 24 | 25 | /* 26 | * Copy string src to buffer dst of size dsize. At most dsize-1 27 | * chars will be copied. Always NUL terminates (unless dsize == 0). 28 | * Returns strlen(src); if retval >= dsize, truncation occurred. 29 | */ 30 | size_t 31 | strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize) 32 | { 33 | const char *osrc = src; 34 | size_t nleft = dsize; 35 | 36 | /* Copy as many bytes as will fit. */ 37 | if (nleft != 0) { 38 | while (--nleft != 0) { 39 | if ((*dst++ = *src++) == '\0') 40 | break; 41 | } 42 | } 43 | 44 | /* Not enough room in dst, add NUL and traverse rest of src. */ 45 | if (nleft == 0) { 46 | if (dsize != 0) 47 | *dst = '\0'; /* NUL-terminate dst */ 48 | while (*src++) 49 | ; 50 | } 51 | 52 | return(src - osrc - 1); /* count does not include NUL */ 53 | } 54 | -------------------------------------------------------------------------------- /include/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 2021 Daniel Kolesa 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the University nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef CDEFS_H 32 | #define CDEFS_H 33 | 34 | #include 35 | 36 | #ifdef __GLIBC__ 37 | # include_next 38 | #else 39 | # ifdef __cplusplus 40 | # define __BEGIN_DECLS extern "C" { 41 | # define __END_DECLS } 42 | # else 43 | # define __BEGIN_DECLS 44 | # define __END_DECLS 45 | # endif 46 | #endif 47 | 48 | #define __FBSDID(x) 49 | #define __SCCSID(x) 50 | 51 | #define __dead2 52 | #define __printf0like(x, y) 53 | #define __printflike(x, y) __attribute__((format(printf, x, y))) 54 | #define __DECONST(a, v) ((a)(v)) 55 | #define __unreachable() ((void)0) 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('static_fts', 2 | type: 'boolean', value: false, 3 | description: 'Prefer static libfts' 4 | ) 5 | 6 | option('static_rpmatch', 7 | type: 'boolean', value: false, 8 | description: 'Prefer static librpmatch' 9 | ) 10 | 11 | option('fts_path', 12 | type: 'string', value: '', 13 | description: 'Extra search path for libfts' 14 | ) 15 | 16 | option('rpmatch_path', 17 | type: 'string', value: '', 18 | description: 'Extra search path for librpmatch' 19 | ) 20 | 21 | option('color_ls', 22 | type: 'boolean', value: true, 23 | description: 'Enable color ls(1) (needs terminfo)' 24 | ) 25 | 26 | option('libcrypto', 27 | type: 'feature', value: 'enabled', 28 | description: 'Use libcrypto (for dc(1) and minor features elsewhere)' 29 | ) 30 | 31 | option('libedit', 32 | type: 'feature', value: 'enabled', 33 | description: 'Use libedit (needed by bc(1))' 34 | ) 35 | -------------------------------------------------------------------------------- /src/basename/meson.build: -------------------------------------------------------------------------------- 1 | basename_prog = executable( 2 | 'basename', 3 | [ 'basename.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('basename.1') 9 | -------------------------------------------------------------------------------- /src/bc/extern.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | /* $OpenBSD: extern.h,v 1.12 2014/04/17 19:07:14 otto Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 2003, Otto Moerbeek 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | struct lvalue { 24 | ssize_t load; 25 | ssize_t store; 26 | }; 27 | 28 | int yylex(void); 29 | void yyerror(const char *); 30 | void fatal(const char *); 31 | void abort_line(int); 32 | struct termios; 33 | int gettty(struct termios *); 34 | void tstpcont(int); 35 | unsigned char bc_eof(EditLine *, int); 36 | 37 | extern int lineno; 38 | extern int fileindex; 39 | extern int sargc; 40 | extern const char **sargv; 41 | extern const char *filename; 42 | extern bool interactive; 43 | extern EditLine *el; 44 | extern History *hist; 45 | extern HistEvent he; 46 | extern char *cmdexpr; 47 | extern struct termios ttysaved; 48 | -------------------------------------------------------------------------------- /src/bc/meson.build: -------------------------------------------------------------------------------- 1 | bc_prog = executable( 2 | 'bc', 3 | [ yacc.process('bc.y'), 4 | lex.process('scan.l'), 5 | 'tty.c', 6 | ], 7 | include_directories : inc, 8 | link_with : [ libcompat ], 9 | dependencies : [ libedit ], 10 | install : true, 11 | ) 12 | 13 | install_man('bc.1') 14 | install_data('bc.library', 15 | install_dir : get_option('datadir') / 'misc') 16 | -------------------------------------------------------------------------------- /src/bc/pathnames.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | /* $OpenBSD: pathnames.h,v 1.1 2003/09/25 19:32:44 otto Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 2003, Otto Moerbeek 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #define _PATH_LIBB "/usr/share/misc/bc.library" 21 | #define _PATH_DC "/usr/bin/dc" 22 | -------------------------------------------------------------------------------- /src/bc/tty.c: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | /* $OpenBSD: tty.c,v 1.3 2015/09/05 09:49:24 jsg Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 2013, Otto Moerbeek 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "extern.h" 25 | 26 | struct termios ttysaved, ttyedit; 27 | 28 | static int 29 | settty(struct termios *t) 30 | { 31 | int ret; 32 | 33 | while ((ret = tcsetattr(0, TCSADRAIN, t)) == -1 && errno == EINTR) 34 | continue; 35 | return ret; 36 | } 37 | 38 | int 39 | gettty(struct termios *t) 40 | { 41 | int ret; 42 | 43 | while ((ret = tcgetattr(0, t)) == -1 && errno == EINTR) 44 | continue; 45 | return ret; 46 | } 47 | 48 | /* ARGSUSED */ 49 | void 50 | tstpcont(int sig) 51 | { 52 | int save_errno = errno; 53 | 54 | if (sig == SIGTSTP) { 55 | signal(SIGCONT, tstpcont); 56 | gettty(&ttyedit); 57 | settty(&ttysaved); 58 | } else { 59 | signal(SIGTSTP, tstpcont); 60 | settty(&ttyedit); 61 | } 62 | signal(sig, SIG_DFL); 63 | kill(0, sig); 64 | errno = save_errno; 65 | } 66 | -------------------------------------------------------------------------------- /src/cat/meson.build: -------------------------------------------------------------------------------- 1 | cat_prog = executable( 2 | 'cat', 3 | [ 'cat.c' ], 4 | include_directories : inc, 5 | c_args : '-DNO_UDOM_SUPPORT', 6 | install : true, 7 | ) 8 | 9 | install_man('cat.1') 10 | -------------------------------------------------------------------------------- /src/chmod/meson.build: -------------------------------------------------------------------------------- 1 | chmod_prog = executable( 2 | 'chmod', 3 | [ 'chmod.c' ], 4 | include_directories : inc, 5 | dependencies : [ libfts, ], 6 | link_with : [ libcompat ], 7 | install : true, 8 | ) 9 | 10 | install_man('chmod.1') 11 | -------------------------------------------------------------------------------- /src/chown/meson.build: -------------------------------------------------------------------------------- 1 | chown_prog = executable( 2 | 'chown', 3 | [ 'chown.c' ], 4 | c_args : [ '-DUID_MAX=INT_MAX', '-DGID_MAX=INT_MAX' ], 5 | include_directories : inc, 6 | dependencies : [ libfts, ], 7 | install : true, 8 | install_dir : get_option('sbindir'), 9 | ) 10 | 11 | meson.add_install_script(install_link, 'chown', 'chgrp', get_option('bindir')) 12 | 13 | install_man('chown.8') 14 | install_man('chgrp.1') 15 | -------------------------------------------------------------------------------- /src/chroot/.#chroot.: -------------------------------------------------------------------------------- 1 | dcantrell@bnsf.7081:1619483536 -------------------------------------------------------------------------------- /src/chroot/meson.build: -------------------------------------------------------------------------------- 1 | chroot_prog = executable( 2 | 'chroot', 3 | [ 'chroot.c' ], 4 | include_directories : inc, 5 | install : true, 6 | install_dir : get_option('sbindir'), 7 | ) 8 | 9 | install_man('chroot.8') 10 | -------------------------------------------------------------------------------- /src/cksum/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 32 | * $FreeBSD$ 33 | */ 34 | 35 | #include 36 | 37 | extern uint32_t crc_total; 38 | extern uint32_t crc32_total; 39 | 40 | __BEGIN_DECLS 41 | int crc(int, uint32_t *, off_t *); 42 | void pcrc(char *, uint32_t, off_t); 43 | void psum1(char *, uint32_t, off_t); 44 | void psum2(char *, uint32_t, off_t); 45 | int csum1(int, uint32_t *, off_t *); 46 | int csum2(int, uint32_t *, off_t *); 47 | int crc32(int, uint32_t *, off_t *); 48 | __END_DECLS 49 | -------------------------------------------------------------------------------- /src/cksum/meson.build: -------------------------------------------------------------------------------- 1 | srcs = [ 'cksum.c', 'crc.c', 'print.c', 'sum1.c', 'sum2.c', 'crc32.c' ] 2 | 3 | cksum_prog = executable( 4 | 'cksum', 5 | srcs, 6 | c_args : [ '-Duint32_t=u_int32_t' ], 7 | include_directories : inc, 8 | install : true, 9 | ) 10 | 11 | meson.add_install_script(install_link, 'cksum', 'sum', get_option('bindir')) 12 | 13 | install_man('cksum.1') 14 | install_man('sum.1') 15 | -------------------------------------------------------------------------------- /src/cksum/print.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/6/93"; 35 | #endif 36 | #endif /* not lint */ 37 | 38 | #include 39 | __FBSDID("$FreeBSD$"); 40 | 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | #include "extern.h" 47 | 48 | void 49 | pcrc(char *fn, uint32_t val, off_t len) 50 | { 51 | (void)printf("%lu %jd", (u_long)val, (intmax_t)len); 52 | if (fn != NULL) 53 | (void)printf(" %s", fn); 54 | (void)printf("\n"); 55 | } 56 | 57 | void 58 | psum1(char *fn, uint32_t val, off_t len) 59 | { 60 | (void)printf("%lu %jd", (u_long)val, (intmax_t)(len + 1023) / 1024); 61 | if (fn != NULL) 62 | (void)printf(" %s", fn); 63 | (void)printf("\n"); 64 | } 65 | 66 | void 67 | psum2(char *fn, uint32_t val, off_t len) 68 | { 69 | (void)printf("%lu %jd", (u_long)val, (intmax_t)(len + 511) / 512); 70 | if (fn != NULL) 71 | (void)printf(" %s", fn); 72 | (void)printf("\n"); 73 | } 74 | -------------------------------------------------------------------------------- /src/cksum/sum.1: -------------------------------------------------------------------------------- 1 | .so man1/cksum.1 2 | -------------------------------------------------------------------------------- /src/cksum/sum1.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)sum1.c 8.1 (Berkeley) 6/6/93"; 35 | #endif 36 | #endif /* not lint */ 37 | 38 | #include 39 | __FBSDID("$FreeBSD$"); 40 | 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | #include "extern.h" 47 | 48 | int 49 | csum1(int fd, uint32_t *cval, off_t *clen) 50 | { 51 | int nr; 52 | u_int lcrc; 53 | off_t total; 54 | u_char *p; 55 | u_char buf[8192]; 56 | 57 | /* 58 | * 16-bit checksum, rotating right before each addition; 59 | * overflow is discarded. 60 | */ 61 | lcrc = total = 0; 62 | while ((nr = read(fd, buf, sizeof(buf))) > 0) 63 | for (total += nr, p = buf; nr--; ++p) { 64 | if (lcrc & 1) 65 | lcrc |= 0x10000; 66 | lcrc = ((lcrc >> 1) + *p) & 0xffff; 67 | } 68 | if (nr < 0) 69 | return (1); 70 | 71 | *cval = lcrc; 72 | *clen = total; 73 | return (0); 74 | } 75 | -------------------------------------------------------------------------------- /src/cksum/sum2.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)sum2.c 8.1 (Berkeley) 6/6/93"; 35 | #endif 36 | #endif /* not lint */ 37 | #include 38 | __FBSDID("$FreeBSD$"); 39 | 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | #include "extern.h" 46 | 47 | int 48 | csum2(int fd, uint32_t *cval, off_t *clen) 49 | { 50 | uint32_t lcrc; 51 | int nr; 52 | off_t total; 53 | u_char *p; 54 | u_char buf[8192]; 55 | 56 | /* 57 | * Draft 8 POSIX 1003.2: 58 | * 59 | * s = sum of all bytes 60 | * r = s % 2^16 + (s % 2^32) / 2^16 61 | * lcrc = (r % 2^16) + r / 2^16 62 | */ 63 | lcrc = total = 0; 64 | while ((nr = read(fd, buf, sizeof(buf))) > 0) 65 | for (total += nr, p = buf; nr--; ++p) 66 | lcrc += *p; 67 | if (nr < 0) 68 | return (1); 69 | 70 | lcrc = (lcrc & 0xffff) + (lcrc >> 16); 71 | lcrc = (lcrc & 0xffff) + (lcrc >> 16); 72 | 73 | *cval = lcrc; 74 | *clen = total; 75 | return (0); 76 | } 77 | -------------------------------------------------------------------------------- /src/comm/meson.build: -------------------------------------------------------------------------------- 1 | comm_prog = executable( 2 | 'comm', 3 | [ 'comm.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('comm.1') 9 | -------------------------------------------------------------------------------- /src/cp/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993, 1994 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)extern.h 8.2 (Berkeley) 4/1/94 32 | * $FreeBSD$ 33 | */ 34 | 35 | typedef struct { 36 | char *p_end; /* pointer to NULL at end of path */ 37 | char *target_end; /* pointer to end of target base */ 38 | char p_path[PATH_MAX]; /* pointer to the start of a path */ 39 | } PATH_T; 40 | 41 | extern PATH_T to; 42 | extern int fflag, iflag, lflag, nflag, pflag, sflag, vflag; 43 | extern volatile sig_atomic_t info; 44 | 45 | __BEGIN_DECLS 46 | int copy_fifo(struct stat *, int); 47 | int copy_file(const FTSENT *, int); 48 | int copy_link(const FTSENT *, int); 49 | int copy_special(struct stat *, int); 50 | int setfile(struct stat *, int); 51 | int preserve_dir_acls(struct stat *, char *, char *); 52 | int preserve_fd_acls(int, int); 53 | void usage(void); 54 | __END_DECLS 55 | -------------------------------------------------------------------------------- /src/cp/meson.build: -------------------------------------------------------------------------------- 1 | cp_prog = executable( 2 | 'cp', 3 | [ 'cp.c', 4 | 'utils.c', 5 | ], 6 | dependencies : [ libfts, ], 7 | include_directories : inc, 8 | link_with : [ libcompat ], 9 | install : true, 10 | ) 11 | 12 | install_man('cp.1') 13 | -------------------------------------------------------------------------------- /src/csplit/meson.build: -------------------------------------------------------------------------------- 1 | csplit_prog = executable( 2 | 'csplit', 3 | [ 'csplit.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('csplit.1') 9 | -------------------------------------------------------------------------------- /src/cut/meson.build: -------------------------------------------------------------------------------- 1 | cut_prog = executable( 2 | 'cut', 3 | [ 'cut.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('cut.1') 9 | -------------------------------------------------------------------------------- /src/date/meson.build: -------------------------------------------------------------------------------- 1 | date_prog = executable( 2 | 'date', 3 | [ 'date.c', 4 | 'vary.c', 5 | ], 6 | include_directories : inc, 7 | link_with : [ libcompat ], 8 | install : true, 9 | ) 10 | 11 | install_man('date.1') 12 | -------------------------------------------------------------------------------- /src/date/vary.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1997 Brian Somers 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD$ 27 | */ 28 | 29 | struct vary { 30 | char *arg; 31 | struct vary *next; 32 | }; 33 | 34 | extern struct vary *vary_append(struct vary *v, char *arg); 35 | extern const struct vary *vary_apply(const struct vary *v, struct tm *t); 36 | extern void vary_destroy(struct vary *v); 37 | -------------------------------------------------------------------------------- /src/dc/bcode.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | /* $OpenBSD: bcode.h,v 1.7 2012/11/07 11:06:14 otto Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 2003, Otto Moerbeek 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | struct number { 24 | BIGNUM *number; 25 | u_int scale; 26 | }; 27 | 28 | enum stacktype { 29 | BCODE_NONE, 30 | BCODE_NUMBER, 31 | BCODE_STRING 32 | }; 33 | 34 | enum bcode_compare { 35 | BCODE_EQUAL, 36 | BCODE_NOT_EQUAL, 37 | BCODE_LESS, 38 | BCODE_NOT_LESS, 39 | BCODE_GREATER, 40 | BCODE_NOT_GREATER 41 | }; 42 | 43 | struct array; 44 | 45 | struct value { 46 | union { 47 | struct number *num; 48 | char *string; 49 | } u; 50 | struct array *array; 51 | enum stacktype type; 52 | }; 53 | 54 | struct array { 55 | struct value *data; 56 | size_t size; 57 | }; 58 | 59 | struct stack { 60 | struct value *stack; 61 | ssize_t size; 62 | ssize_t sp; 63 | }; 64 | 65 | struct source; 66 | 67 | struct vtable { 68 | int (*readchar)(struct source *); 69 | void (*unreadchar)(struct source *); 70 | char *(*readline)(struct source *); 71 | void (*free)(struct source *); 72 | }; 73 | 74 | struct source { 75 | union { 76 | struct { 77 | u_char *buf; 78 | size_t pos; 79 | } string; 80 | FILE *stream; 81 | } u; 82 | struct vtable *vtable; 83 | int lastchar; 84 | }; 85 | 86 | void init_bmachine(bool); 87 | void reset_bmachine(struct source *); 88 | u_int bmachine_scale(void); 89 | void scale_number(BIGNUM *, int); 90 | void normalize(struct number *, u_int); 91 | void eval(void); 92 | void pn(const char *, const struct number *); 93 | void pbn(const char *, const BIGNUM *); 94 | void negate(struct number *); 95 | void split_number(const struct number *, BIGNUM *, BIGNUM *); 96 | void bmul_number(struct number *, struct number *, 97 | struct number *, u_int scale); 98 | 99 | static __inline u_int 100 | max(u_int a, u_int b) 101 | { 102 | 103 | return (a > b ? a : b); 104 | } 105 | -------------------------------------------------------------------------------- /src/dc/extern.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | /* $OpenBSD: extern.h,v 1.4 2014/12/01 13:13:00 deraadt Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 2003, Otto Moerbeek 6 | * 7 | * Permission to use, copy, modify, and distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include "bcode.h" 22 | 23 | 24 | /* inout.c */ 25 | void src_setstream(struct source *, FILE *); 26 | void src_setstring(struct source *, char *); 27 | struct number *readnumber(struct source *, u_int, u_int); 28 | void printnumber(FILE *, const struct number *, u_int); 29 | char *read_string(struct source *); 30 | void print_value(FILE *, const struct value *, const char *, u_int); 31 | void print_ascii(FILE *, const struct number *); 32 | 33 | /* mem.c */ 34 | struct number *new_number(void); 35 | void free_number(struct number *); 36 | struct number *div_number(struct number *, struct number *, u_int scale); 37 | struct number *dup_number(const struct number *); 38 | void *bmalloc(size_t); 39 | void *breallocarray(void *, size_t, size_t); 40 | char *bstrdup(const char *p); 41 | void bn_check(int); 42 | void bn_checkp(const void *); 43 | 44 | /* stack.c */ 45 | void stack_init(struct stack *); 46 | void stack_free_value(struct value *); 47 | struct value *stack_dup_value(const struct value *, struct value *); 48 | void stack_swap(struct stack *); 49 | size_t stack_size(const struct stack *); 50 | void stack_dup(struct stack *); 51 | void stack_pushnumber(struct stack *, struct number *); 52 | void stack_pushstring(struct stack *stack, char *); 53 | void stack_push(struct stack *, struct value *); 54 | void stack_set_tos(struct stack *, struct value *); 55 | struct value *stack_tos(const struct stack *); 56 | struct value *stack_pop(struct stack *); 57 | struct number *stack_popnumber(struct stack *); 58 | char *stack_popstring(struct stack *); 59 | void stack_clear(struct stack *); 60 | void stack_print(FILE *, const struct stack *, const char *, 61 | u_int base); 62 | void frame_assign(struct stack *, size_t, const struct value *); 63 | struct value *frame_retrieve(const struct stack *, size_t); 64 | /* void frame_free(struct stack *); */ 65 | -------------------------------------------------------------------------------- /src/dc/meson.build: -------------------------------------------------------------------------------- 1 | dc_prog = executable( 2 | 'dc', 3 | [ 'dc.c', 4 | 'bcode.c', 5 | 'inout.c', 6 | 'mem.c', 7 | 'stack.c', 8 | ], 9 | include_directories : inc, 10 | link_with : [ libcompat ], 11 | dependencies : [ libcrypto, ], 12 | install : true, 13 | ) 14 | 15 | install_man('dc.1') 16 | -------------------------------------------------------------------------------- /src/dd/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993, 1994 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * This code is derived from software contributed to Berkeley by 8 | * Keith Muller of the University of California, San Diego and Lance 9 | * Visser of Convex Computer Corporation. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * @(#)extern.h 8.3 (Berkeley) 4/2/94 36 | * $FreeBSD$ 37 | */ 38 | 39 | #include 40 | 41 | void block(void); 42 | void block_close(void); 43 | void dd_out(int); 44 | void def(void); 45 | void def_close(void); 46 | void jcl(char **); 47 | void pos_in(void); 48 | void pos_out(void); 49 | double secs_elapsed(void); 50 | void progress(void); 51 | void summary(void); 52 | void sigalarm_handler(int); 53 | void siginfo_handler(int); 54 | void terminate(int); 55 | void unblock(void); 56 | void unblock_close(void); 57 | 58 | extern IO in, out; 59 | extern STAT st; 60 | extern void (*cfunc)(void); 61 | extern uintmax_t cpy_cnt; 62 | extern size_t cbsz; 63 | extern uint64_t ddflags; 64 | extern size_t speed; 65 | extern uintmax_t files_cnt; 66 | extern const u_char *ctab; 67 | extern const u_char a2e_32V[], a2e_POSIX[]; 68 | extern const u_char e2a_32V[], e2a_POSIX[]; 69 | extern const u_char a2ibm_32V[], a2ibm_POSIX[]; 70 | extern u_char casetab[]; 71 | extern char fill_char; 72 | extern volatile sig_atomic_t need_summary; 73 | extern volatile sig_atomic_t need_progress; 74 | -------------------------------------------------------------------------------- /src/dd/gen.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * This program is in the public domain 3 | * 4 | * $FreeBSD$ 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | int 11 | main(int argc, char **argv) 12 | { 13 | int i; 14 | 15 | if (argc > 1 && !strcmp(argv[1], "189284")) { 16 | fputs("ABCDEFGH", stdout); 17 | for (i = 0; i < 8; i++) 18 | putchar(0); 19 | } else { 20 | for (i = 0; i < 256; i++) 21 | putchar(i); 22 | } 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /src/dd/meson.build: -------------------------------------------------------------------------------- 1 | dd_prog = executable( 2 | 'dd', 3 | [ 'args.c', 4 | 'conv.c', 5 | 'conv_tab.c', 6 | 'dd.c', 7 | 'misc.c', 8 | 'position.c', 9 | ], 10 | include_directories : inc, 11 | link_with : [ libcompat ], 12 | install : true, 13 | ) 14 | 15 | install_man('dd.1') 16 | -------------------------------------------------------------------------------- /src/dd/ref.ascii: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 9c 09 86 7f 97 8d 8e 0b 0c 0d 0e 0f |................| 3 | 00000010 10 11 12 13 9d 85 08 87 18 19 92 8f 1c 1d 1e 1f |................| 4 | 00000020 80 81 82 83 84 0a 17 1b 88 89 8a 8b 8c 05 06 07 |................| 5 | 00000030 90 91 16 93 94 95 96 04 98 99 9a 9b 14 15 9e 1a |................| 6 | 00000040 20 a0 a1 a2 a3 a4 a5 a6 a7 a8 d5 2e 3c 28 2b 7c | ...........<(+|| 7 | 00000050 26 a9 aa ab ac ad ae af b0 b1 21 24 2a 29 3b 7e |&.........!$*);~| 8 | 00000060 2d 2f b2 b3 b4 b5 b6 b7 b8 b9 cb 2c 25 5f 3e 3f |-/.........,%_>?| 9 | 00000070 ba bb bc bd be bf c0 c1 c2 60 3a 23 40 27 3d 22 |.........`:#@'="| 10 | 00000080 c3 61 62 63 64 65 66 67 68 69 c4 c5 c6 c7 c8 c9 |.abcdefghi......| 11 | 00000090 ca 6a 6b 6c 6d 6e 6f 70 71 72 5e cc cd ce cf d0 |.jklmnopqr^.....| 12 | 000000a0 d1 e5 73 74 75 76 77 78 79 7a d2 d3 d4 5b d6 d7 |..stuvwxyz...[..| 13 | 000000b0 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 5d e6 e7 |.............]..| 14 | 000000c0 7b 41 42 43 44 45 46 47 48 49 e8 e9 ea eb ec ed |{ABCDEFGHI......| 15 | 000000d0 7d 4a 4b 4c 4d 4e 4f 50 51 52 ee ef f0 f1 f2 f3 |}JKLMNOPQR......| 16 | 000000e0 5c 9f 53 54 55 56 57 58 59 5a f4 f5 f6 f7 f8 f9 |\.STUVWXYZ......| 17 | 000000f0 30 31 32 33 34 35 36 37 38 39 fa fb fc fd fe ff |0123456789......| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.ebcdic: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....| 3 | 00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....| 4 | 00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka| 5 | 00000030 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 7a 5e 4c 7e 6e 6f |..........z^L~no| 6 | 00000040 7c c1 c2 c3 c4 c5 c6 c7 c8 c9 d1 d2 d3 d4 d5 d6 ||...............| 7 | 00000050 d7 d8 d9 e2 e3 e4 e5 e6 e7 e8 e9 ad e0 bd 9a 6d |...............m| 8 | 00000060 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 |y...............| 9 | 00000070 97 98 99 a2 a3 a4 a5 a6 a7 a8 a9 c0 4f d0 5f 07 |............O._.| 10 | 00000080 20 21 22 23 24 15 06 17 28 29 2a 2b 2c 09 0a 1b | !"#$...()*+,...| 11 | 00000090 30 31 1a 33 34 35 36 08 38 39 3a 3b 04 14 3e e1 |01.3456.89:;..>.| 12 | 000000a0 41 42 43 44 45 46 47 48 49 51 52 53 54 55 56 57 |ABCDEFGHIQRSTUVW| 13 | 000000b0 58 59 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |XYbcdefghipqrstu| 14 | 000000c0 76 77 78 80 8a 8b 8c 8d 8e 8f 90 6a 9b 9c 9d 9e |vwx........j....| 15 | 000000d0 9f a0 aa ab ac 4a ae af b0 b1 b2 b3 b4 b5 b6 b7 |.....J..........| 16 | 000000e0 b8 b9 ba bb bc a1 be bf ca cb cc cd ce cf da db |................| 17 | 000000f0 dc dd de df ea eb ec ed ee ef fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.ibm: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....| 3 | 00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....| 4 | 00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka| 5 | 00000030 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 7a 5e 4c 7e 6e 6f |..........z^L~no| 6 | 00000040 7c c1 c2 c3 c4 c5 c6 c7 c8 c9 d1 d2 d3 d4 d5 d6 ||...............| 7 | 00000050 d7 d8 d9 e2 e3 e4 e5 e6 e7 e8 e9 ad e0 bd 5f 6d |.............._m| 8 | 00000060 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 |y...............| 9 | 00000070 97 98 99 a2 a3 a4 a5 a6 a7 a8 a9 c0 4f d0 a1 07 |............O...| 10 | 00000080 20 21 22 23 24 15 06 17 28 29 2a 2b 2c 09 0a 1b | !"#$...()*+,...| 11 | 00000090 30 31 1a 33 34 35 36 08 38 39 3a 3b 04 14 3e e1 |01.3456.89:;..>.| 12 | 000000a0 41 42 43 44 45 46 47 48 49 51 52 53 54 55 56 57 |ABCDEFGHIQRSTUVW| 13 | 000000b0 58 59 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |XYbcdefghipqrstu| 14 | 000000c0 76 77 78 80 8a 8b 8c 8d 8e 8f 90 9a 9b 9c 9d 9e |vwx.............| 15 | 000000d0 9f a0 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 |................| 16 | 000000e0 b8 b9 ba bb bc bd be bf ca cb cc cd ce cf da db |................| 17 | 000000f0 dc dd de df ea eb ec ed ee ef fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.lcase: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................| 3 | 00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................| 4 | 00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./| 5 | 00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?| 6 | 00000040 40 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |@abcdefghijklmno| 7 | 00000050 70 71 72 73 74 75 76 77 78 79 7a 5b 5c 5d 5e 5f |pqrstuvwxyz[\]^_| 8 | 00000060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |`abcdefghijklmno| 9 | 00000070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f |pqrstuvwxyz{|}~.| 10 | 00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................| 11 | 00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................| 12 | 000000a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................| 13 | 000000b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |................| 14 | 000000c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |................| 15 | 000000d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |................| 16 | 000000e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |................| 17 | 000000f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.obs_zeroes: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 41 42 43 44 45 46 47 48 00 00 00 00 00 00 00 00 |ABCDEFGH........| 3 | 00000010 4 | -------------------------------------------------------------------------------- /src/dd/ref.oldascii: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 9c 09 86 7f 97 8d 8e 0b 0c 0d 0e 0f |................| 3 | 00000010 10 11 12 13 9d 85 08 87 18 19 92 8f 1c 1d 1e 1f |................| 4 | 00000020 80 81 82 83 84 0a 17 1b 88 89 8a 8b 8c 05 06 07 |................| 5 | 00000030 90 91 16 93 94 95 96 04 98 99 9a 9b 14 15 9e 1a |................| 6 | 00000040 20 a0 a1 a2 a3 a4 a5 a6 a7 a8 5b 2e 3c 28 2b 21 | .........[.<(+!| 7 | 00000050 26 a9 aa ab ac ad ae af b0 b1 5d 24 2a 29 3b 5e |&.........]$*);^| 8 | 00000060 2d 2f b2 b3 b4 b5 b6 b7 b8 b9 7c 2c 25 5f 3e 3f |-/........|,%_>?| 9 | 00000070 ba bb bc bd be bf c0 c1 c2 60 3a 23 40 27 3d 22 |.........`:#@'="| 10 | 00000080 c3 61 62 63 64 65 66 67 68 69 c4 c5 c6 c7 c8 c9 |.abcdefghi......| 11 | 00000090 ca 6a 6b 6c 6d 6e 6f 70 71 72 cb cc cd ce cf d0 |.jklmnopqr......| 12 | 000000a0 d1 7e 73 74 75 76 77 78 79 7a d2 d3 d4 d5 d6 d7 |.~stuvwxyz......| 13 | 000000b0 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 |................| 14 | 000000c0 7b 41 42 43 44 45 46 47 48 49 e8 e9 ea eb ec ed |{ABCDEFGHI......| 15 | 000000d0 7d 4a 4b 4c 4d 4e 4f 50 51 52 ee ef f0 f1 f2 f3 |}JKLMNOPQR......| 16 | 000000e0 5c 9f 53 54 55 56 57 58 59 5a f4 f5 f6 f7 f8 f9 |\.STUVWXYZ......| 17 | 000000f0 30 31 32 33 34 35 36 37 38 39 fa fb fc fd fe ff |0123456789......| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.oldebcdic: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....| 3 | 00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....| 4 | 00000020 40 4f 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@O.{[lP}M]\Nk`Ka| 5 | 00000030 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 7a 5e 4c 7e 6e 6f |..........z^L~no| 6 | 00000040 7c c1 c2 c3 c4 c5 c6 c7 c8 c9 d1 d2 d3 d4 d5 d6 ||...............| 7 | 00000050 d7 d8 d9 e2 e3 e4 e5 e6 e7 e8 e9 4a e0 5a 5f 6d |...........J.Z_m| 8 | 00000060 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 |y...............| 9 | 00000070 97 98 99 a2 a3 a4 a5 a6 a7 a8 a9 c0 6a d0 a1 07 |............j...| 10 | 00000080 20 21 22 23 24 15 06 17 28 29 2a 2b 2c 09 0a 1b | !"#$...()*+,...| 11 | 00000090 30 31 1a 33 34 35 36 08 38 39 3a 3b 04 14 3e e1 |01.3456.89:;..>.| 12 | 000000a0 41 42 43 44 45 46 47 48 49 51 52 53 54 55 56 57 |ABCDEFGHIQRSTUVW| 13 | 000000b0 58 59 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |XYbcdefghipqrstu| 14 | 000000c0 76 77 78 80 8a 8b 8c 8d 8e 8f 90 9a 9b 9c 9d 9e |vwx.............| 15 | 000000d0 9f a0 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 |................| 16 | 000000e0 b8 b9 ba bb bc bd be bf ca cb cc cd ce cf da db |................| 17 | 000000f0 dc dd de df ea eb ec ed ee ef fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.oldibm: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 37 2d 2e 2f 16 05 25 0b 0c 0d 0e 0f |....7-./..%.....| 3 | 00000010 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f |....<=2&..?'....| 4 | 00000020 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 |@Z.{[lP}M]\Nk`Ka| 5 | 00000030 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 7a 5e 4c 7e 6e 6f |..........z^L~no| 6 | 00000040 7c c1 c2 c3 c4 c5 c6 c7 c8 c9 d1 d2 d3 d4 d5 d6 ||...............| 7 | 00000050 d7 d8 d9 e2 e3 e4 e5 e6 e7 e8 e9 ad e0 bd 5f 6d |.............._m| 8 | 00000060 79 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 |y...............| 9 | 00000070 97 98 99 a2 a3 a4 a5 a6 a7 a8 a9 c0 4f d0 a1 07 |............O...| 10 | 00000080 20 21 22 23 24 15 06 17 28 29 2a 2b 2c 09 0a 1b | !"#$...()*+,...| 11 | 00000090 30 31 1a 33 34 35 36 08 38 39 3a 3b 04 14 3e e1 |01.3456.89:;..>.| 12 | 000000a0 41 42 43 44 45 46 47 48 49 51 52 53 54 55 56 57 |ABCDEFGHIQRSTUVW| 13 | 000000b0 58 59 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |XYbcdefghipqrstu| 14 | 000000c0 76 77 78 80 8a 8b 8c 8d 8e 8f 90 9a 9b 9c 9d 9e |vwx.............| 15 | 000000d0 9f a0 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 |................| 16 | 000000e0 b8 b9 ba bb bc bd be bf ca cb cc cd ce cf da db |................| 17 | 000000f0 dc dd de df ea eb ec ed ee ef fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.pareven: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 81 82 03 84 05 06 87 88 09 0a 8b 0c 8d 8e 0f |................| 3 | 00000010 90 11 12 93 14 95 96 17 18 99 9a 1b 9c 1d 1e 9f |................| 4 | 00000020 a0 21 22 a3 24 a5 a6 27 28 a9 aa 2b ac 2d 2e af |.!".$..'(..+.-..| 5 | 00000030 30 b1 b2 33 b4 35 36 b7 b8 39 3a bb 3c bd be 3f |0..3.56..9:.<..?| 6 | 00000040 c0 41 42 c3 44 c5 c6 47 48 c9 ca 4b cc 4d 4e cf |.AB.D..GH..K.MN.| 7 | 00000050 50 d1 d2 53 d4 55 56 d7 d8 59 5a db 5c dd de 5f |P..S.UV..YZ.\.._| 8 | 00000060 60 e1 e2 63 e4 65 66 e7 e8 69 6a eb 6c ed ee 6f |`..c.ef..ij.l..o| 9 | 00000070 f0 71 72 f3 74 f5 f6 77 78 f9 fa 7b fc 7d 7e ff |.qr.t..wx..{.}~.| 10 | 00000080 00 81 82 03 84 05 06 87 88 09 0a 8b 0c 8d 8e 0f |................| 11 | 00000090 90 11 12 93 14 95 96 17 18 99 9a 1b 9c 1d 1e 9f |................| 12 | 000000a0 a0 21 22 a3 24 a5 a6 27 28 a9 aa 2b ac 2d 2e af |.!".$..'(..+.-..| 13 | 000000b0 30 b1 b2 33 b4 35 36 b7 b8 39 3a bb 3c bd be 3f |0..3.56..9:.<..?| 14 | 000000c0 c0 41 42 c3 44 c5 c6 47 48 c9 ca 4b cc 4d 4e cf |.AB.D..GH..K.MN.| 15 | 000000d0 50 d1 d2 53 d4 55 56 d7 d8 59 5a db 5c dd de 5f |P..S.UV..YZ.\.._| 16 | 000000e0 60 e1 e2 63 e4 65 66 e7 e8 69 6a eb 6c ed ee 6f |`..c.ef..ij.l..o| 17 | 000000f0 f0 71 72 f3 74 f5 f6 77 78 f9 fa 7b fc 7d 7e ff |.qr.t..wx..{.}~.| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.parnone: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................| 3 | 00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................| 4 | 00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./| 5 | 00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?| 6 | 00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO| 7 | 00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[\]^_| 8 | 00000060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |`abcdefghijklmno| 9 | 00000070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f |pqrstuvwxyz{|}~.| 10 | 00000080 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................| 11 | 00000090 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................| 12 | 000000a0 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./| 13 | 000000b0 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?| 14 | 000000c0 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO| 15 | 000000d0 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[\]^_| 16 | 000000e0 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f |`abcdefghijklmno| 17 | 000000f0 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f |pqrstuvwxyz{|}~.| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.parodd: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 80 01 02 83 04 85 86 07 08 89 8a 0b 8c 0d 0e 8f |................| 3 | 00000010 10 91 92 13 94 15 16 97 98 19 1a 9b 1c 9d 9e 1f |................| 4 | 00000020 20 a1 a2 23 a4 25 26 a7 a8 29 2a ab 2c ad ae 2f | ..#.%&..)*.,../| 5 | 00000030 b0 31 32 b3 34 b5 b6 37 38 b9 ba 3b bc 3d 3e bf |.12.4..78..;.=>.| 6 | 00000040 40 c1 c2 43 c4 45 46 c7 c8 49 4a cb 4c cd ce 4f |@..C.EF..IJ.L..O| 7 | 00000050 d0 51 52 d3 54 d5 d6 57 58 d9 da 5b dc 5d 5e df |.QR.T..WX..[.]^.| 8 | 00000060 e0 61 62 e3 64 e5 e6 67 68 e9 ea 6b ec 6d 6e ef |.ab.d..gh..k.mn.| 9 | 00000070 70 f1 f2 73 f4 75 76 f7 f8 79 7a fb 7c fd fe 7f |p..s.uv..yz.|...| 10 | 00000080 80 01 02 83 04 85 86 07 08 89 8a 0b 8c 0d 0e 8f |................| 11 | 00000090 10 91 92 13 94 15 16 97 98 19 1a 9b 1c 9d 9e 1f |................| 12 | 000000a0 20 a1 a2 23 a4 25 26 a7 a8 29 2a ab 2c ad ae 2f | ..#.%&..)*.,../| 13 | 000000b0 b0 31 32 b3 34 b5 b6 37 38 b9 ba 3b bc 3d 3e bf |.12.4..78..;.=>.| 14 | 000000c0 40 c1 c2 43 c4 45 46 c7 c8 49 4a cb 4c cd ce 4f |@..C.EF..IJ.L..O| 15 | 000000d0 d0 51 52 d3 54 d5 d6 57 58 d9 da 5b dc 5d 5e df |.QR.T..WX..[.]^.| 16 | 000000e0 e0 61 62 e3 64 e5 e6 67 68 e9 ea 6b ec 6d 6e ef |.ab.d..gh..k.mn.| 17 | 000000f0 70 f1 f2 73 f4 75 76 f7 f8 79 7a fb 7c fd fe 7f |p..s.uv..yz.|...| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.parset: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................| 3 | 00000010 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................| 4 | 00000020 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................| 5 | 00000030 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |................| 6 | 00000040 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |................| 7 | 00000050 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |................| 8 | 00000060 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |................| 9 | 00000070 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |................| 10 | 00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................| 11 | 00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................| 12 | 000000a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................| 13 | 000000b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |................| 14 | 000000c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |................| 15 | 000000d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |................| 16 | 000000e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |................| 17 | 000000f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.swab: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 01 00 03 02 05 04 07 06 09 08 0b 0a 0d 0c 0f 0e |................| 3 | 00000010 11 10 13 12 15 14 17 16 19 18 1b 1a 1d 1c 1f 1e |................| 4 | 00000020 21 20 23 22 25 24 27 26 29 28 2b 2a 2d 2c 2f 2e |! #"%$'&)(+*-,/.| 5 | 00000030 31 30 33 32 35 34 37 36 39 38 3b 3a 3d 3c 3f 3e |1032547698;:=| 6 | 00000040 41 40 43 42 45 44 47 46 49 48 4b 4a 4d 4c 4f 4e |A@CBEDGFIHKJMLON| 7 | 00000050 51 50 53 52 55 54 57 56 59 58 5b 5a 5d 5c 5f 5e |QPSRUTWVYX[Z]\_^| 8 | 00000060 61 60 63 62 65 64 67 66 69 68 6b 6a 6d 6c 6f 6e |a`cbedgfihkjmlon| 9 | 00000070 71 70 73 72 75 74 77 76 79 78 7b 7a 7d 7c 7f 7e |qpsrutwvyx{z}|.~| 10 | 00000080 81 80 83 82 85 84 87 86 89 88 8b 8a 8d 8c 8f 8e |................| 11 | 00000090 91 90 93 92 95 94 97 96 99 98 9b 9a 9d 9c 9f 9e |................| 12 | 000000a0 a1 a0 a3 a2 a5 a4 a7 a6 a9 a8 ab aa ad ac af ae |................| 13 | 000000b0 b1 b0 b3 b2 b5 b4 b7 b6 b9 b8 bb ba bd bc bf be |................| 14 | 000000c0 c1 c0 c3 c2 c5 c4 c7 c6 c9 c8 cb ca cd cc cf ce |................| 15 | 000000d0 d1 d0 d3 d2 d5 d4 d7 d6 d9 d8 db da dd dc df de |................| 16 | 000000e0 e1 e0 e3 e2 e5 e4 e7 e6 e9 e8 eb ea ed ec ef ee |................| 17 | 000000f0 f1 f0 f3 f2 f5 f4 f7 f6 f9 f8 fb fa fd fc ff fe |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/dd/ref.ucase: -------------------------------------------------------------------------------- 1 | $FreeBSD$ 2 | 00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................| 3 | 00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................| 4 | 00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./| 5 | 00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?| 6 | 00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO| 7 | 00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[\]^_| 8 | 00000060 60 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |`ABCDEFGHIJKLMNO| 9 | 00000070 50 51 52 53 54 55 56 57 58 59 5a 7b 7c 7d 7e 7f |PQRSTUVWXYZ{|}~.| 10 | 00000080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |................| 11 | 00000090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f |................| 12 | 000000a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af |................| 13 | 000000b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf |................| 14 | 000000c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf |................| 15 | 000000d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df |................| 16 | 000000e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef |................| 17 | 000000f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |................| 18 | 00000100 19 | -------------------------------------------------------------------------------- /src/df/meson.build: -------------------------------------------------------------------------------- 1 | df_prog = executable( 2 | 'df', 3 | [ 'df.c' ], 4 | include_directories : inc, 5 | dependencies : [ libxo ], 6 | link_with : [ libcompat ], 7 | install : true, 8 | ) 9 | 10 | install_man('df.1') 11 | -------------------------------------------------------------------------------- /src/df/vfslist.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1995 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | #if 0 34 | static char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95"; 35 | #endif 36 | #endif /* not lint */ 37 | #include 38 | __FBSDID("$FreeBSD$"); 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | #include "extern.h" 45 | 46 | static int skipvfs; 47 | 48 | int 49 | checkvfsname(const char *vfsname, const char **vfslist) 50 | { 51 | 52 | if (vfslist == NULL) 53 | return (0); 54 | while (*vfslist != NULL) { 55 | if (strcmp(vfsname, *vfslist) == 0) 56 | return (skipvfs); 57 | ++vfslist; 58 | } 59 | return (!skipvfs); 60 | } 61 | 62 | const char ** 63 | makevfslist(char *fslist) 64 | { 65 | const char **av; 66 | int i; 67 | char *nextcp; 68 | 69 | if (fslist == NULL) 70 | return (NULL); 71 | if (fslist[0] == 'n' && fslist[1] == 'o') { 72 | fslist += 2; 73 | skipvfs = 1; 74 | } 75 | for (i = 0, nextcp = fslist; *nextcp; nextcp++) 76 | if (*nextcp == ',') 77 | i++; 78 | if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { 79 | warnx("malloc failed"); 80 | return (NULL); 81 | } 82 | nextcp = fslist; 83 | i = 0; 84 | av[i++] = nextcp; 85 | while ((nextcp = strchr(nextcp, ',')) != NULL) { 86 | *nextcp++ = '\0'; 87 | av[i++] = nextcp; 88 | } 89 | av[i++] = NULL; 90 | return (av); 91 | } 92 | -------------------------------------------------------------------------------- /src/dirname/dirname.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993, 1994 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1991, 1993, 1994\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #ifndef lint 39 | static const char sccsid[] = "@(#)dirname.c 8.4 (Berkeley) 5/4/95"; 40 | #endif /* not lint */ 41 | #include 42 | __FBSDID("$FreeBSD$"); 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | void usage(void); 51 | 52 | int 53 | main(int argc, char **argv) 54 | { 55 | char *p; 56 | int ch; 57 | 58 | while ((ch = getopt(argc, argv, "")) != -1) 59 | switch(ch) { 60 | case '?': 61 | default: 62 | usage(); 63 | } 64 | argc -= optind; 65 | argv += optind; 66 | 67 | if (argc < 1) 68 | usage(); 69 | 70 | while (argc--) { 71 | if ((p = dirname(*argv)) == NULL) 72 | err(1, "%s", *argv); 73 | argv++; 74 | (void)printf("%s\n", p); 75 | } 76 | exit(0); 77 | } 78 | 79 | void 80 | usage(void) 81 | { 82 | 83 | (void)fprintf(stderr, "usage: dirname string [...]\n"); 84 | exit(1); 85 | } 86 | -------------------------------------------------------------------------------- /src/dirname/meson.build: -------------------------------------------------------------------------------- 1 | dirname_prog = executable( 2 | 'dirname', 3 | [ 'dirname.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | -------------------------------------------------------------------------------- /src/du/meson.build: -------------------------------------------------------------------------------- 1 | du_prog = executable( 2 | 'du', 3 | [ 'du.c' ], 4 | include_directories : [ inc, ], 5 | dependencies : [ libfts, ], 6 | link_with : [ libcompat, ], 7 | install : true, 8 | ) 9 | 10 | install_man('du.1') 11 | -------------------------------------------------------------------------------- /src/echo/meson.build: -------------------------------------------------------------------------------- 1 | echo_prog = executable( 2 | 'echo', 3 | [ 'echo.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('echo.1') 9 | -------------------------------------------------------------------------------- /src/env/envopts.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (c) 2005 - Garance Alistair Drosehn . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * The views and conclusions contained in the software and documentation 29 | * are those of the authors and should not be interpreted as representing 30 | * official policies, either expressed or implied, of the FreeBSD Project. 31 | * 32 | * $FreeBSD$ 33 | */ 34 | 35 | void search_paths(char *path, char **argv); 36 | void split_spaces(const char *str, int *origind, int *origc, 37 | char ***origv); 38 | 39 | extern int env_verbosity; 40 | -------------------------------------------------------------------------------- /src/env/meson.build: -------------------------------------------------------------------------------- 1 | env_prog = executable( 2 | 'env', 3 | [ 'env.c', 4 | 'envopts.c', 5 | ], 6 | include_directories : inc, 7 | link_with : [ libcompat ], 8 | install : true, 9 | ) 10 | 11 | install_man('env.1') 12 | -------------------------------------------------------------------------------- /src/expand/meson.build: -------------------------------------------------------------------------------- 1 | expand_prog = executable( 2 | 'expand', 3 | [ 'expand.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('expand.1') 9 | -------------------------------------------------------------------------------- /src/expr/meson.build: -------------------------------------------------------------------------------- 1 | # expr relies on signed integer wrapping 2 | extra_args = [ '-fwrapv' ] 3 | 4 | expr_prog = executable( 5 | 'expr', 6 | [ yacc.process('expr.y'), ], 7 | include_directories : inc, 8 | c_args : extra_args, 9 | install : true, 10 | ) 11 | 12 | install_man('expr.1') 13 | -------------------------------------------------------------------------------- /src/factor/meson.build: -------------------------------------------------------------------------------- 1 | factor_prog = executable( 2 | 'factor', 3 | [ 'factor.c', 4 | 'pr_tbl.c', 5 | ], 6 | install : true, 7 | ) 8 | 9 | install_man('factor.6') 10 | -------------------------------------------------------------------------------- /src/factor/primes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1989, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * This code is derived from software contributed to Berkeley by 6 | * Landon Curt Noll. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. Neither the name of the University nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | * 32 | * @(#)primes.h 8.2 (Berkeley) 3/1/94 33 | * $FreeBSD$ 34 | */ 35 | 36 | /* 37 | * primes - generate a table of primes between two values 38 | * 39 | * By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo 40 | * 41 | * chongo /\oo/\ 42 | */ 43 | 44 | #include 45 | 46 | /* ubig is the type that holds a large unsigned value */ 47 | typedef uint64_t ubig; /* must be >=32 bit unsigned value */ 48 | #define BIG ULONG_MAX /* largest value will sieve */ 49 | 50 | /* bytes in sieve table (must be > 3*5*7*11) */ 51 | #define TABSIZE 256*1024 52 | 53 | /* 54 | * prime[i] is the (i-1)th prime. 55 | * 56 | * We are able to sieve 2^32-1 because this byte table yields all primes 57 | * up to 65537 and 65537^2 > 2^32-1. 58 | */ 59 | extern const ubig prime[]; 60 | extern const ubig *const pr_limit; /* largest prime in the prime array */ 61 | 62 | /* Maximum size sieving alone can handle. */ 63 | #define SIEVEMAX 4295098368ULL 64 | 65 | /* 66 | * To avoid excessive sieves for small factors, we use the table below to 67 | * setup our sieve blocks. Each element represents an odd number starting 68 | * with 1. All non-zero elements are factors of 3, 5, 7, 11 and 13. 69 | */ 70 | extern const char pattern[]; 71 | extern const size_t pattern_size; /* length of pattern array */ 72 | 73 | /* Test for primality using strong pseudoprime tests. */ 74 | int isprime(ubig); 75 | -------------------------------------------------------------------------------- /src/false/false.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1983, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" This code is derived from software contributed to Berkeley by 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. 6 | .\" 7 | .\" Redistribution and use in source and binary forms, with or without 8 | .\" modification, are permitted provided that the following conditions 9 | .\" are met: 10 | .\" 1. Redistributions of source code must retain the above copyright 11 | .\" notice, this list of conditions and the following disclaimer. 12 | .\" 2. Redistributions in binary form must reproduce the above copyright 13 | .\" notice, this list of conditions and the following disclaimer in the 14 | .\" documentation and/or other materials provided with the distribution. 15 | .\" 3. Neither the name of the University nor the names of its contributors 16 | .\" may be used to endorse or promote products derived from this software 17 | .\" without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | .\" SUCH DAMAGE. 30 | .\" 31 | .\" @(#)false.1 8.1 (Berkeley) 6/6/93 32 | .\" $FreeBSD$ 33 | .\" 34 | .Dd June 6, 1993 35 | .Dt FALSE 1 36 | .Os 37 | .Sh NAME 38 | .Nm false 39 | .Nd return false value 40 | .Sh SYNOPSIS 41 | .Nm 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | utility always returns with a non-zero exit code. 46 | .Pp 47 | Some shells may provide a builtin 48 | .Nm 49 | command which is identical to this utility. 50 | Consult the 51 | .Xr builtin 1 52 | manual page. 53 | .Sh SEE ALSO 54 | .Xr builtin 1 , 55 | .Xr csh 1 , 56 | .Xr sh 1 , 57 | .Xr true 1 58 | .Sh STANDARDS 59 | The 60 | .Nm 61 | utility is expected to be 62 | .St -p1003.2 63 | compatible. 64 | -------------------------------------------------------------------------------- /src/false/false.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1988, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1988, 1993\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #ifndef lint 39 | static const char sccsid[] = "@(#)false.c 8.1 (Berkeley) 6/6/93"; 40 | #endif /* not lint */ 41 | #include 42 | __FBSDID("$FreeBSD$"); 43 | 44 | int 45 | main(void) 46 | { 47 | return 1; 48 | } 49 | -------------------------------------------------------------------------------- /src/false/meson.build: -------------------------------------------------------------------------------- 1 | false_prog = executable( 2 | 'false', 3 | [ 'false.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('false.1') 9 | -------------------------------------------------------------------------------- /src/find/meson.build: -------------------------------------------------------------------------------- 1 | find_prog = executable( 2 | 'find', 3 | [ 'find.c', 4 | 'function.c', 5 | yacc.process('getdate.y'), 6 | 'ls.c', 7 | 'main.c', 8 | 'misc.c', 9 | 'operator.c', 10 | 'option.c', 11 | ], 12 | c_args : [ '-DQUAD_MAX=LONG_MAX', 13 | '-DMAXLOGNAME=LOGIN_NAME_MAX', ], 14 | include_directories : inc, 15 | dependencies : [ libfts, librpmatch, ], 16 | link_with : [ libcompat ], 17 | install : true, 18 | ) 19 | 20 | install_man('find.1') 21 | -------------------------------------------------------------------------------- /src/fmt/meson.build: -------------------------------------------------------------------------------- 1 | fmt_prog = executable( 2 | 'fmt', 3 | [ 'fmt.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('fmt.1') 9 | -------------------------------------------------------------------------------- /src/fold/meson.build: -------------------------------------------------------------------------------- 1 | fold_prog = executable( 2 | 'fold', 3 | [ 'fold.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('fold.1') 9 | -------------------------------------------------------------------------------- /src/head/head.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1980, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)head.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd April 10, 2018 32 | .Dt HEAD 1 33 | .Os 34 | .Sh NAME 35 | .Nm head 36 | .Nd display first lines of a file 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Op Fl n Ar count | Fl c Ar bytes 40 | .Op Ar 41 | .Sh DESCRIPTION 42 | This filter displays the first 43 | .Ar count 44 | lines or 45 | .Ar bytes 46 | of each of the specified files, or of the standard input if no 47 | files are specified. 48 | If 49 | .Ar count 50 | is omitted it defaults to 10. 51 | .Pp 52 | The following options are available: 53 | .Bl -tag -width indent 54 | .It Fl c Ar bytes , Fl -bytes Ns = Ns Ar bytes 55 | Print 56 | .Ar bytes 57 | of each of the specified files. 58 | .It Fl n Ar count , Fl -lines Ns = Ns Ar count 59 | Print 60 | .Ar count 61 | lines of each of the specified files. 62 | .El 63 | .Pp 64 | If more than a single file is specified, each file is preceded by a 65 | header consisting of the string 66 | .Dq ==> XXX <== 67 | where 68 | .Dq XXX 69 | is the name of the file. 70 | .Sh EXIT STATUS 71 | .Ex -std 72 | .Sh EXAMPLES 73 | To display the first 500 lines of the file 74 | .Ar foo : 75 | .Pp 76 | .Dl $ head -n 500 foo 77 | .Pp 78 | .Nm 79 | can be used in conjunction with 80 | .Xr tail 1 81 | in the following way to, for example, display only line 500 from the file 82 | .Ar foo : 83 | .Pp 84 | .Dl $ head -n 500 foo | tail -n 1 85 | .Sh SEE ALSO 86 | .Xr tail 1 87 | .Sh HISTORY 88 | The 89 | .Nm 90 | command appeared in PWB UNIX. 91 | -------------------------------------------------------------------------------- /src/head/meson.build: -------------------------------------------------------------------------------- 1 | head_prog = executable( 2 | 'head', 3 | [ 'head.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('head.1') 9 | -------------------------------------------------------------------------------- /src/hexdump/hexdump.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1989, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1989, 1993\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #ifndef lint 39 | #if 0 40 | static char sccsid[] = "@(#)hexdump.c 8.1 (Berkeley) 6/6/93"; 41 | #endif 42 | #endif /* not lint */ 43 | #include 44 | __FBSDID("$FreeBSD$"); 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include "hexdump.h" 53 | 54 | FS *fshead; /* head of format strings */ 55 | int blocksize; /* data block size */ 56 | int exitval; /* final exit value */ 57 | int length = -1; /* max bytes to read */ 58 | 59 | int 60 | main(int argc, char *argv[]) 61 | { 62 | FS *tfs; 63 | char *p; 64 | 65 | (void)setlocale(LC_ALL, ""); 66 | 67 | if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od")) 68 | newsyntax(argc, &argv); 69 | else 70 | oldsyntax(argc, &argv); 71 | 72 | /* figure out the data block size */ 73 | for (blocksize = 0, tfs = fshead; tfs; tfs = tfs->nextfs) { 74 | tfs->bcnt = size(tfs); 75 | if (blocksize < tfs->bcnt) 76 | blocksize = tfs->bcnt; 77 | } 78 | /* rewrite the rules, do syntax checking */ 79 | for (tfs = fshead; tfs; tfs = tfs->nextfs) 80 | rewrite(tfs); 81 | 82 | (void)next(argv); 83 | display(); 84 | exit(exitval); 85 | } 86 | -------------------------------------------------------------------------------- /src/hexdump/meson.build: -------------------------------------------------------------------------------- 1 | hexdump_prog = executable( 2 | 'hexdump', 3 | [ 'conv.c', 4 | 'display.c', 5 | 'hexdump.c', 6 | 'hexsyntax.c', 7 | 'odsyntax.c', 8 | 'parse.c', 9 | ], 10 | include_directories : [ inc, ], 11 | link_with : [ libcompat ], 12 | install : true, 13 | ) 14 | 15 | install_man('od.1') 16 | install_man('hexdump.1') 17 | 18 | meson.add_install_script(install_link, 'hexdump', 'od', get_option('bindir')) 19 | meson.add_install_script(install_link, 'hexdump', 'hd', get_option('bindir')) 20 | meson.add_install_script( 21 | install_link, 'hexdump.1', 'hd.1', join_paths(get_option('mandir'), 'man1') 22 | ) 23 | -------------------------------------------------------------------------------- /src/hostname/hostname.1: -------------------------------------------------------------------------------- 1 | .\"- 2 | .\" Copyright (c) 1983, 1988, 1990, 1993 3 | .\" The Regents of the University of California. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. Neither the name of the University nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | .\" SUCH DAMAGE. 28 | .\" 29 | .\" @(#)hostname.1 8.2 (Berkeley) 4/28/95 30 | .\" $FreeBSD$ 31 | .\" 32 | .Dd October 5, 2020 33 | .Dt HOSTNAME 1 34 | .Os 35 | .Sh NAME 36 | .Nm hostname 37 | .Nd set or print name of current host system 38 | .Sh SYNOPSIS 39 | .Nm 40 | .Op Fl f 41 | .Op Fl s | d 42 | .Op Ar name-of-host 43 | .Sh DESCRIPTION 44 | The 45 | .Nm 46 | utility prints the name of the current host. 47 | The super-user can 48 | set the hostname by supplying an argument; this is usually done in the 49 | initialization script 50 | .Pa /etc/rc.d/hostname , 51 | normally run at boot 52 | time. 53 | This script uses the 54 | .Va hostname 55 | variable in 56 | .Pa /etc/rc.conf . 57 | .Pp 58 | Options: 59 | .Bl -tag -width flag 60 | .It Fl f 61 | Include domain information in the printed name. 62 | This is the default behavior. 63 | .It Fl s 64 | Trim off any domain information from the printed 65 | name. 66 | .It Fl d 67 | Only print domain information. 68 | .El 69 | .Sh EXAMPLES 70 | Set the host name of the machine and check the result: 71 | .Bd -literal -offset indent 72 | $ hostname beastie.localdomain.org 73 | $ hostname 74 | beastie.localdomain.org 75 | .Ed 76 | .Pp 77 | Do not show domain information: 78 | .Bd -literal -offset indent 79 | $ hostname -s 80 | beastie 81 | .Ed 82 | .Pp 83 | Show only domain information: 84 | .Bd -literal -offset indent 85 | $ hostname -d 86 | localdomain.org 87 | .Ed 88 | .Sh SEE ALSO 89 | .Xr gethostname 3 , 90 | .Xr rc.conf 5 91 | .Sh HISTORY 92 | The 93 | .Nm 94 | command appeared in 95 | .Bx 4.2 . 96 | -------------------------------------------------------------------------------- /src/hostname/meson.build: -------------------------------------------------------------------------------- 1 | hostname_prog = executable( 2 | 'hostname', 3 | [ 'hostname.c' ], 4 | include_directories : [ inc, ], 5 | install : true, 6 | ) 7 | 8 | install_man('hostname.1') 9 | -------------------------------------------------------------------------------- /src/id/groups.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)groups.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd June 6, 1993 32 | .Dt GROUPS 1 33 | .Os 34 | .Sh NAME 35 | .Nm groups 36 | .Nd show group memberships 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Op Ar user 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | utility has been obsoleted by the 44 | .Xr id 1 45 | utility, and is equivalent to 46 | .Dq Nm id Fl Gn Op Ar user . 47 | The command 48 | .Dq Nm id Fl p 49 | is suggested for normal interactive use. 50 | .Pp 51 | The 52 | .Nm 53 | utility displays the groups to which you (or the optionally specified 54 | .Ar user ) 55 | belong. 56 | .Sh EXIT STATUS 57 | .Ex -std 58 | .Sh EXAMPLES 59 | Show groups the root user belongs to: 60 | .Bd -literal -offset indent 61 | $ groups root 62 | wheel operator 63 | .Ed 64 | .Sh SEE ALSO 65 | .Xr id 1 66 | -------------------------------------------------------------------------------- /src/id/meson.build: -------------------------------------------------------------------------------- 1 | id_prog = executable( 2 | 'id', 3 | [ 'id.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | meson.add_install_script(install_link, 'id', 'groups', get_option('bindir')) 9 | meson.add_install_script(install_link, 'id', 'whoami', get_option('bindir')) 10 | 11 | install_man('id.1') 12 | install_man('groups.1') 13 | install_man('whoami.1') 14 | -------------------------------------------------------------------------------- /src/id/whoami.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)whoami.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd June 6, 1993 32 | .Dt WHOAMI 1 33 | .Os 34 | .Sh NAME 35 | .Nm whoami 36 | .Nd display effective user id 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | utility has been obsoleted by the 43 | .Xr id 1 44 | utility, and is equivalent to 45 | .Dq Nm id Fl un . 46 | The command 47 | .Dq Nm id Fl p 48 | is suggested for normal interactive use. 49 | .Pp 50 | The 51 | .Nm 52 | utility displays your effective user ID as a name. 53 | .Sh EXIT STATUS 54 | .Ex -std 55 | .Sh SEE ALSO 56 | .Xr id 1 57 | -------------------------------------------------------------------------------- /src/join/meson.build: -------------------------------------------------------------------------------- 1 | join_prog = executable( 2 | 'join', 3 | [ 'join.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('join.1') 9 | -------------------------------------------------------------------------------- /src/kill/meson.build: -------------------------------------------------------------------------------- 1 | kill_prog = executable( 2 | 'kill', 3 | [ 'kill.c' ], 4 | include_directories : [ inc, ], 5 | link_with : [ libcompat, ], 6 | install : true, 7 | ) 8 | 9 | install_man('kill.1') 10 | -------------------------------------------------------------------------------- /src/ln/meson.build: -------------------------------------------------------------------------------- 1 | ln_prog = executable( 2 | 'ln', 3 | [ 'ln.c' ], 4 | include_directories : inc, 5 | link_with : [ libcompat ], 6 | install : true, 7 | ) 8 | 9 | install_man('ln.1') 10 | install_man('symlink.7') 11 | 12 | meson.add_install_script(install_link, 'ln', 'link', get_option('bindir')) 13 | meson.add_install_script( 14 | install_link, 'ln.1', 'link.1', join_paths(get_option('mandir'), 'man1') 15 | ) 16 | -------------------------------------------------------------------------------- /src/logname/logname.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" This code is derived from software contributed to Berkeley by 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. 6 | .\" 7 | .\" Redistribution and use in source and binary forms, with or without 8 | .\" modification, are permitted provided that the following conditions 9 | .\" are met: 10 | .\" 1. Redistributions of source code must retain the above copyright 11 | .\" notice, this list of conditions and the following disclaimer. 12 | .\" 2. Redistributions in binary form must reproduce the above copyright 13 | .\" notice, this list of conditions and the following disclaimer in the 14 | .\" documentation and/or other materials provided with the distribution. 15 | .\" 3. Neither the name of the University nor the names of its contributors 16 | .\" may be used to endorse or promote products derived from this software 17 | .\" without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | .\" SUCH DAMAGE. 30 | .\" 31 | .\" @(#)logname.1 8.1 (Berkeley) 6/9/93 32 | .\" $FreeBSD$ 33 | .\" 34 | .Dd June 9, 1993 35 | .Dt LOGNAME 1 36 | .Os 37 | .Sh NAME 38 | .Nm logname 39 | .Nd display user's login name 40 | .Sh SYNOPSIS 41 | .Nm 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | utility writes the user's login name to standard output followed by 46 | a newline. 47 | .Pp 48 | The 49 | .Nm 50 | utility explicitly ignores the 51 | .Ev LOGNAME 52 | and 53 | .Ev USER 54 | environment variables 55 | because the environment cannot be trusted. 56 | .Sh EXIT STATUS 57 | .Ex -std 58 | .Sh SEE ALSO 59 | .Xr who 1 , 60 | .Xr whoami 1 , 61 | .Xr getlogin 2 62 | .Sh STANDARDS 63 | The 64 | .Nm 65 | utility is expected to conform to 66 | .St -p1003.2 . 67 | .Sh HISTORY 68 | The 69 | .Nm 70 | command appeared in 71 | .Bx 4.4 . 72 | -------------------------------------------------------------------------------- /src/logname/logname.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993, 1994 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1991, 1993, 1994\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #ifndef lint 39 | static const char sccsid[] = "@(#)logname.c 8.2 (Berkeley) 4/3/94"; 40 | #endif /* not lint */ 41 | #include 42 | __FBSDID("$FreeBSD$"); 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | void usage(void); 50 | 51 | int 52 | main(int argc, char *argv[] __attribute__((unused))) 53 | { 54 | char *p; 55 | 56 | if (argc != 1) 57 | usage(); 58 | if ((p = getlogin()) == NULL) 59 | err(1, NULL); 60 | (void)printf("%s\n", p); 61 | exit(0); 62 | } 63 | 64 | void 65 | usage(void) 66 | { 67 | (void)fprintf(stderr, "usage: logname\n"); 68 | exit(1); 69 | } 70 | -------------------------------------------------------------------------------- /src/logname/meson.build: -------------------------------------------------------------------------------- 1 | logname_prog = executable( 2 | 'logname', 3 | [ 'logname.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('logname.1') 9 | -------------------------------------------------------------------------------- /src/ls/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * from: @(#)extern.h 8.1 (Berkeley) 5/31/93 32 | * $FreeBSD$ 33 | */ 34 | 35 | #include 36 | 37 | int acccmp(const FTSENT *, const FTSENT *); 38 | int revacccmp(const FTSENT *, const FTSENT *); 39 | int modcmp(const FTSENT *, const FTSENT *); 40 | int revmodcmp(const FTSENT *, const FTSENT *); 41 | int namecmp(const FTSENT *, const FTSENT *); 42 | int revnamecmp(const FTSENT *, const FTSENT *); 43 | int verscmp(const FTSENT *, const FTSENT *); 44 | int revverscmp(const FTSENT *, const FTSENT *); 45 | int statcmp(const FTSENT *, const FTSENT *); 46 | int revstatcmp(const FTSENT *, const FTSENT *); 47 | int sizecmp(const FTSENT *, const FTSENT *); 48 | int revsizecmp(const FTSENT *, const FTSENT *); 49 | 50 | void printcol(const DISPLAY *); 51 | void printlong(const DISPLAY *); 52 | int printname(const char *); 53 | void printscol(const DISPLAY *); 54 | void printstream(const DISPLAY *); 55 | void usage(void); 56 | int prn_normal(const char *); 57 | size_t len_octal(const char *, int); 58 | int prn_octal(const char *); 59 | int prn_printable(const char *); 60 | #ifdef COLORLS 61 | void parsecolors(const char *cs); 62 | void colorquit(int); 63 | 64 | extern char *ansi_fgcol; 65 | extern char *ansi_bgcol; 66 | extern char *ansi_coloff; 67 | extern char *attrs_off; 68 | extern char *enter_bold; 69 | extern char *enter_underline; 70 | 71 | extern int colorflag; 72 | extern bool explicitansi; 73 | 74 | #define COLORFLAG_NEVER 0 75 | #define COLORFLAG_AUTO 1 76 | #define COLORFLAG_ALWAYS 2 77 | #endif 78 | extern int termwidth; 79 | -------------------------------------------------------------------------------- /src/ls/meson.build: -------------------------------------------------------------------------------- 1 | ls_cargs = [] 2 | ls_deps = [ libfts, ] 3 | 4 | if get_option('color_ls') 5 | ls_cargs += [ '-DCOLORLS' ] 6 | ls_deps += [ libtinfo ] 7 | endif 8 | 9 | ls_prog = executable( 10 | 'ls', 11 | [ 'cmp.c', 12 | 'ls.c', 13 | 'print.c', 14 | 'util.c', 15 | ], 16 | c_args : ls_cargs, 17 | include_directories : inc, 18 | link_with : [ libcompat ], 19 | dependencies : ls_deps, 20 | install : true, 21 | ) 22 | 23 | install_man('ls.1') 24 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | subdir('basename') 2 | subdir('cat') 3 | subdir('chmod') 4 | subdir('chown') 5 | subdir('chroot') 6 | subdir('cksum') 7 | subdir('comm') 8 | subdir('cp') 9 | subdir('csplit') 10 | subdir('cut') 11 | subdir('date') 12 | subdir('dd') 13 | subdir('df') 14 | subdir('dirname') 15 | subdir('du') 16 | subdir('echo') 17 | subdir('env') 18 | subdir('expand') 19 | subdir('expr') 20 | subdir('factor') 21 | subdir('false') 22 | subdir('find') 23 | subdir('fmt') 24 | subdir('fold') 25 | subdir('head') 26 | subdir('hexdump') 27 | subdir('hostname') 28 | subdir('id') 29 | subdir('join') 30 | subdir('kill') 31 | subdir('ln') 32 | subdir('logname') 33 | subdir('ls') 34 | subdir('mkdir') 35 | subdir('mkfifo') 36 | subdir('mknod') 37 | subdir('mktemp') 38 | subdir('mv') 39 | subdir('nice') 40 | subdir('nl') 41 | subdir('nohup') 42 | subdir('paste') 43 | subdir('pathchk') 44 | subdir('pr') 45 | subdir('printenv') 46 | subdir('printf') 47 | subdir('pwd') 48 | subdir('realpath') 49 | subdir('rm') 50 | subdir('rmdir') 51 | subdir('sed') 52 | subdir('seq') 53 | subdir('sleep') 54 | subdir('sort') 55 | subdir('split') 56 | subdir('stat') 57 | subdir('stdbuf') 58 | subdir('stty') 59 | subdir('sync') 60 | subdir('tail') 61 | subdir('tee') 62 | subdir('test') 63 | subdir('timeout') 64 | subdir('touch') 65 | subdir('tr') 66 | subdir('true') 67 | subdir('truncate') 68 | subdir('tsort') 69 | subdir('tty') 70 | subdir('uname') 71 | subdir('unexpand') 72 | subdir('uniq') 73 | subdir('users') 74 | subdir('wc') 75 | subdir('which') 76 | subdir('who') 77 | subdir('xargs') 78 | subdir('yes') 79 | 80 | if libedit.found() 81 | subdir('bc') 82 | endif 83 | 84 | if libcrypto.found() 85 | subdir('dc') 86 | subdir('xinstall') 87 | endif 88 | -------------------------------------------------------------------------------- /src/mkdir/meson.build: -------------------------------------------------------------------------------- 1 | mkdir_prog = executable( 2 | 'mkdir', 3 | [ 'mkdir.c' ], 4 | include_directories : inc, 5 | link_with : [ libcompat ], 6 | install : true, 7 | ) 8 | 9 | install_man('mkdir.1') 10 | -------------------------------------------------------------------------------- /src/mkfifo/meson.build: -------------------------------------------------------------------------------- 1 | mkfifo_prog = executable( 2 | 'mkfifo', 3 | [ 'mkfifo.c' ], 4 | include_directories : [ inc, ], 5 | link_with : [ libcompat, ], 6 | install : true, 7 | install_dir : get_option('bindir'), 8 | ) 9 | 10 | install_man('mkfifo.1') 11 | -------------------------------------------------------------------------------- /src/mknod/meson.build: -------------------------------------------------------------------------------- 1 | mknod_prog = executable( 2 | 'mknod', 3 | [ 'mknod.c' ], 4 | install : true, 5 | install_dir : get_option('sbindir'), 6 | ) 7 | 8 | install_man('mknod.8') 9 | -------------------------------------------------------------------------------- /src/mktemp/meson.build: -------------------------------------------------------------------------------- 1 | mktemp_prog = executable( 2 | 'mktemp', 3 | [ 'mktemp.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('mktemp.1') 8 | -------------------------------------------------------------------------------- /src/mv/meson.build: -------------------------------------------------------------------------------- 1 | mv_prog = executable( 2 | 'mv', 3 | [ 'mv.c' ], 4 | c_args : [ '-D_PATH_CP="/bin/cp"', 5 | '-D_PATH_RM="/bin/rm"', ], 6 | include_directories : inc, 7 | link_with : [ libcompat ], 8 | install : true, 9 | ) 10 | 11 | install_man('mv.1') 12 | -------------------------------------------------------------------------------- /src/nice/meson.build: -------------------------------------------------------------------------------- 1 | nice_prog = executable( 2 | 'nice', 3 | [ 'nice.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('nice.1') 9 | -------------------------------------------------------------------------------- /src/nl/meson.build: -------------------------------------------------------------------------------- 1 | nl_prog = executable( 2 | 'nl', 3 | [ 'nl.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('nl.1') 9 | -------------------------------------------------------------------------------- /src/nohup/meson.build: -------------------------------------------------------------------------------- 1 | nohup_prog = executable( 2 | 'nohup', 3 | [ 'nohup.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('nohup.1') 9 | -------------------------------------------------------------------------------- /src/paste/meson.build: -------------------------------------------------------------------------------- 1 | paste_prog = executable( 2 | 'paste', 3 | [ 'paste.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('paste.1') 9 | -------------------------------------------------------------------------------- /src/pathchk/meson.build: -------------------------------------------------------------------------------- 1 | pathchk_prog = executable( 2 | 'pathchk', 3 | [ 'pathchk.c' ], 4 | include_directories : [ inc, ], 5 | install : true, 6 | ) 7 | 8 | install_man('pathchk.1') 9 | -------------------------------------------------------------------------------- /src/pr/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-4-Clause 3 | * 4 | * Copyright (c) 1991 Keith Muller. 5 | * Copyright (c) 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Keith Muller of the University of California, San Diego. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. All advertising materials mentioning features or use of this software 20 | * must display the following acknowledgement: 21 | * This product includes software developed by the University of 22 | * California, Berkeley and its contributors. 23 | * 4. Neither the name of the University nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 | * SUCH DAMAGE. 38 | * 39 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 40 | * $FreeBSD$ 41 | */ 42 | 43 | extern int eopterr; 44 | extern int eoptind; 45 | extern int eoptopt; 46 | extern char *eoptarg; 47 | 48 | void addnum(char *, int, int); 49 | int egetopt(int, char * const *, const char *); 50 | void flsh_errs(void); 51 | int horzcol(int, char **); 52 | int inln(FILE *, char *, int, int *, int, int *); 53 | int inskip(FILE *, int, int); 54 | void mfail(void); 55 | int mulfile(int, char **); 56 | FILE *nxtfile(int, char **, const char **, char *, int); 57 | int onecol(int, char **); 58 | int otln(char *, int, int *, int *, int); 59 | void pfail(void); 60 | int prhead(char *, const char *, int); 61 | int prtail(int, int); 62 | int setup(int, char **); 63 | void terminate(int); 64 | void usage(void); 65 | int vertcol(int, char **); 66 | -------------------------------------------------------------------------------- /src/pr/meson.build: -------------------------------------------------------------------------------- 1 | pr_prog = executable( 2 | 'pr', 3 | [ 'egetopt.c', 4 | 'pr.c' 5 | ], 6 | include_directories : inc, 7 | install : true, 8 | ) 9 | 10 | install_man('pr.1') 11 | -------------------------------------------------------------------------------- /src/pr/pr.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-4-Clause 3 | * 4 | * Copyright (c) 1991 Keith Muller. 5 | * Copyright (c) 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Keith Muller of the University of California, San Diego. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. All advertising materials mentioning features or use of this software 20 | * must display the following acknowledgement: 21 | * This product includes software developed by the University of 22 | * California, Berkeley and its contributors. 23 | * 4. Neither the name of the University nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 | * SUCH DAMAGE. 38 | * 39 | * @(#)pr.h 8.1 (Berkeley) 6/6/93 40 | * $FreeBSD$ 41 | */ 42 | 43 | /* 44 | * parameter defaults 45 | */ 46 | #define CLCNT 1 47 | #define INCHAR '\t' 48 | #define INGAP 8 49 | #define OCHAR '\t' 50 | #define OGAP 8 51 | #define LINES 66 52 | #define NMWD 5 53 | #define NMCHAR '\t' 54 | #define SCHAR '\t' 55 | #define PGWD 72 56 | #define SPGWD 512 57 | 58 | /* 59 | * misc default values 60 | */ 61 | #define HDFMT "%s %s Page %d\n\n\n" 62 | #define HEADLEN 5 63 | #define TAILLEN 5 64 | #define TIMEFMTD "%e %b %H:%M %Y" 65 | #define TIMEFMTM "%b %e %H:%M %Y" 66 | #define FNAME "" 67 | #define LBUF 8192 68 | #define HDBUF 512 69 | 70 | /* 71 | * structure for vertical columns. Used to balance cols on last page 72 | */ 73 | struct vcol { 74 | char *pt; /* ptr to col */ 75 | int cnt; /* char count */ 76 | }; 77 | -------------------------------------------------------------------------------- /src/printenv/meson.build: -------------------------------------------------------------------------------- 1 | printenv_prog = executable( 2 | 'printenv', 3 | [ 'printenv.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('printenv.1') 9 | -------------------------------------------------------------------------------- /src/printenv/printenv.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1980, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" This code is derived from software contributed to Berkeley by 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that the following conditions 8 | .\" are met: 9 | .\" 1. Redistributions of source code must retain the above copyright 10 | .\" notice, this list of conditions and the following disclaimer. 11 | .\" 2. Redistributions in binary form must reproduce the above copyright 12 | .\" notice, this list of conditions and the following disclaimer in the 13 | .\" documentation and/or other materials provided with the distribution. 14 | .\" 3. Neither the name of the University nor the names of its contributors 15 | .\" may be used to endorse or promote products derived from this software 16 | .\" without specific prior written permission. 17 | .\" 18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | .\" SUCH DAMAGE. 29 | .\" 30 | .\" @(#)printenv.1 8.1 (Berkeley) 6/6/93 31 | .\" $FreeBSD$ 32 | .\" 33 | .Dd May 12, 2003 34 | .Dt PRINTENV 1 35 | .Os 36 | .Sh NAME 37 | .Nm printenv 38 | .Nd print out the environment 39 | .Sh SYNOPSIS 40 | .Nm 41 | .Op Ar name 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | utility prints out the names and values of the variables in the environment, 46 | with one name/value pair per line. 47 | If 48 | .Ar name 49 | is specified, only 50 | its value is printed. 51 | .Pp 52 | Some shells may provide a builtin 53 | .Nm 54 | command which is similar or identical to this utility. 55 | Consult the 56 | .Xr builtin 1 57 | manual page. 58 | .Sh EXIT STATUS 59 | .Ex -std 60 | .Sh SEE ALSO 61 | .Xr csh 1 , 62 | .Xr env 1 , 63 | .Xr sh 1 , 64 | .Xr environ 7 65 | .Sh STANDARDS 66 | The 67 | .Nm 68 | utility is provided for compatibility with earlier 69 | .Bx 70 | and 71 | .Fx 72 | releases and is not specified by any standards. 73 | The functionality of 74 | .Nm 75 | can be duplicated with the 76 | .Xr echo 1 77 | and 78 | .Xr env 1 79 | utilities. 80 | .Sh HISTORY 81 | The 82 | .Nm 83 | command appeared in 84 | .Bx 3.0 . 85 | -------------------------------------------------------------------------------- /src/printenv/printenv.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1987, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1987, 1993\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #if 0 39 | #ifndef lint 40 | static char sccsid[] = "@(#)printenv.c 8.2 (Berkeley) 5/4/95"; 41 | #endif /* not lint */ 42 | #endif 43 | 44 | #include 45 | __FBSDID("$FreeBSD$"); 46 | 47 | #include 48 | 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | void usage(void); 56 | extern char **environ; 57 | 58 | /* 59 | * printenv 60 | * 61 | * Bill Joy, UCB 62 | * February, 1979 63 | */ 64 | int 65 | main(int argc, char *argv[]) 66 | { 67 | char *cp, **ep; 68 | size_t len; 69 | int ch; 70 | 71 | while ((ch = getopt(argc, argv, "")) != -1) 72 | switch(ch) { 73 | case '?': 74 | default: 75 | usage(); 76 | } 77 | argc -= optind; 78 | argv += optind; 79 | 80 | if (argc == 0) { 81 | for (ep = environ; *ep; ep++) 82 | (void)printf("%s\n", *ep); 83 | exit(0); 84 | } 85 | len = strlen(*argv); 86 | for (ep = environ; *ep; ep++) 87 | if (!memcmp(*ep, *argv, len)) { 88 | cp = *ep + len; 89 | if (*cp == '=') { 90 | (void)printf("%s\n", cp + 1); 91 | exit(0); 92 | } 93 | } 94 | exit(1); 95 | } 96 | 97 | void 98 | usage(void) 99 | { 100 | (void)fprintf(stderr, "usage: printenv [name]\n"); 101 | exit(1); 102 | } 103 | -------------------------------------------------------------------------------- /src/printf/meson.build: -------------------------------------------------------------------------------- 1 | printf_prog = executable( 2 | 'printf', 3 | [ 'printf.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('printf.1') 8 | -------------------------------------------------------------------------------- /src/pwd/meson.build: -------------------------------------------------------------------------------- 1 | pwd_prog = executable( 2 | 'pwd', 3 | [ 'pwd.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('pwd.1') 9 | -------------------------------------------------------------------------------- /src/realpath/meson.build: -------------------------------------------------------------------------------- 1 | realpath_prog = executable( 2 | 'realpath', 3 | [ 'realpath.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('realpath.1') 9 | -------------------------------------------------------------------------------- /src/realpath/realpath.1: -------------------------------------------------------------------------------- 1 | .\"- 2 | .\" Copyright (c) 1990, 1993 3 | .\" The Regents of the University of California. All rights reserved. 4 | .\" 5 | .\" This code is derived from software contributed to Berkeley by 6 | .\" the Institute of Electrical and Electronics Engineers, Inc. 7 | .\" 8 | .\" Redistribution and use in source and binary forms, with or without 9 | .\" modification, are permitted provided that the following conditions 10 | .\" are met: 11 | .\" 1. Redistributions of source code must retain the above copyright 12 | .\" notice, this list of conditions and the following disclaimer. 13 | .\" 2. Redistributions in binary form must reproduce the above copyright 14 | .\" notice, this list of conditions and the following disclaimer in the 15 | .\" documentation and/or other materials provided with the distribution. 16 | .\" 3. Neither the name of the University nor the names of its contributors 17 | .\" may be used to endorse or promote products derived from this software 18 | .\" without specific prior written permission. 19 | .\" 20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | .\" SUCH DAMAGE. 31 | .\" 32 | .\" @(#)pwd.1 8.2 (Berkeley) 4/28/95 33 | .\" From: src/bin/pwd/pwd.1,v 1.11 2000/11/20 11:39:39 ru Exp 34 | .\" $FreeBSD$ 35 | .\" 36 | .Dd June 21, 2011 37 | .Dt REALPATH 1 38 | .Os 39 | .Sh NAME 40 | .Nm realpath 41 | .Nd return resolved physical path 42 | .Sh SYNOPSIS 43 | .Nm 44 | .Op Fl q 45 | .Op Ar path ... 46 | .Sh DESCRIPTION 47 | The 48 | .Nm 49 | utility uses the 50 | .Xr realpath 3 51 | function to resolve all symbolic links, extra 52 | .Ql / 53 | characters and references to 54 | .Pa /./ 55 | and 56 | .Pa /../ 57 | in 58 | .Ar path . 59 | If 60 | .Ar path 61 | is absent, the current working directory 62 | .Pq Sq Pa .\& 63 | is assumed. 64 | .Pp 65 | If 66 | .Fl q 67 | is specified, warnings will not be printed when 68 | .Xr realpath 3 69 | fails. 70 | .Sh EXIT STATUS 71 | .Ex -std 72 | .Sh EXAMPLES 73 | Show the physical path of the 74 | .Pa /dev/log 75 | directory silencing warnings if any: 76 | .Bd -literal -offset indent 77 | $ realpath -q /dev/log 78 | /var/run/log 79 | .Ed 80 | .Sh SEE ALSO 81 | .Xr realpath 3 82 | .Sh HISTORY 83 | The 84 | .Nm 85 | utility first appeared in 86 | .Fx 4.3 . 87 | -------------------------------------------------------------------------------- /src/realpath/realpath.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993, 1994 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | __FBSDID("$FreeBSD$"); 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | static void usage(void) __dead2; 43 | 44 | int 45 | main(int argc, char *argv[]) 46 | { 47 | char buf[PATH_MAX]; 48 | char *p; 49 | const char *path; 50 | int ch, qflag, rval; 51 | 52 | qflag = 0; 53 | while ((ch = getopt(argc, argv, "q")) != -1) { 54 | switch (ch) { 55 | case 'q': 56 | qflag = 1; 57 | break; 58 | case '?': 59 | default: 60 | usage(); 61 | } 62 | } 63 | argc -= optind; 64 | argv += optind; 65 | path = *argv != NULL ? *argv++ : "."; 66 | rval = 0; 67 | do { 68 | if ((p = realpath(path, buf)) == NULL) { 69 | if (!qflag) 70 | warn("%s", path); 71 | rval = 1; 72 | } else 73 | (void)printf("%s\n", p); 74 | } while ((path = *argv++) != NULL); 75 | exit(rval); 76 | } 77 | 78 | static void 79 | usage(void) 80 | { 81 | 82 | (void)fprintf(stderr, "usage: realpath [-q] [path ...]\n"); 83 | exit(1); 84 | } 85 | -------------------------------------------------------------------------------- /src/rm/meson.build: -------------------------------------------------------------------------------- 1 | rm_prog = executable( 2 | 'rm', 3 | [ 'rm.c' ], 4 | include_directories : [ inc, ], 5 | dependencies : [ libfts, ], 6 | link_with : [ libcompat, ], 7 | install : true, 8 | ) 9 | 10 | install_man('rm.1') 11 | 12 | meson.add_install_script(install_link, 'rm', 'unlink', get_option('bindir')) 13 | meson.add_install_script( 14 | install_link, 'rm.1', 'unlink.1', join_paths(get_option('mandir'), 'man1') 15 | ) 16 | -------------------------------------------------------------------------------- /src/rmdir/meson.build: -------------------------------------------------------------------------------- 1 | rmdir_prog = executable( 2 | 'rmdir', 3 | [ 'rmdir.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('rmdir.1') 9 | -------------------------------------------------------------------------------- /src/sed/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1992 Diomidis Spinellis. 5 | * Copyright (c) 1992, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Diomidis Spinellis of Imperial College, University of London. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 36 | * $FreeBSD$ 37 | */ 38 | 39 | extern struct s_command *prog; 40 | extern struct s_appends *appends; 41 | extern regmatch_t *match; 42 | extern size_t maxnsub; 43 | extern u_long linenum; 44 | extern unsigned int appendnum; 45 | extern int aflag, eflag, nflag; 46 | extern const char *fname, *outfname; 47 | extern FILE *infile, *outfile; 48 | extern int rflags; /* regex flags to use */ 49 | extern const char *inplace; 50 | extern int quit; 51 | 52 | void cfclose(struct s_command *, struct s_command *); 53 | void compile(void); 54 | void cspace(SPACE *, const char *, size_t, enum e_spflag); 55 | char *cu_fgets(char *, int, int *); 56 | int mf_fgets(SPACE *, enum e_spflag); 57 | int lastline(void); 58 | void process(void); 59 | void resetstate(void); 60 | char *strregerror(int, regex_t *); 61 | -------------------------------------------------------------------------------- /src/sed/meson.build: -------------------------------------------------------------------------------- 1 | sed_prog = executable( 2 | 'sed', 3 | [ 'compile.c', 4 | 'main.c', 5 | 'misc.c', 6 | 'process.c', 7 | ], 8 | include_directories : [ inc, ], 9 | link_with : [ libcompat, ], 10 | install : true, 11 | ) 12 | 13 | install_man('sed.1') 14 | -------------------------------------------------------------------------------- /src/sed/misc.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1992 Diomidis Spinellis. 5 | * Copyright (c) 1992, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Diomidis Spinellis of Imperial College, University of London. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | #include 37 | __FBSDID("$FreeBSD$"); 38 | 39 | #ifndef lint 40 | static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/6/93"; 41 | #endif 42 | 43 | #include 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #include "defs.h" 53 | #include "extern.h" 54 | 55 | /* 56 | * Return a string for a regular expression error passed. This is overkill, 57 | * because of the silly semantics of regerror (we can never know the size of 58 | * the buffer). 59 | */ 60 | char * 61 | strregerror(int errcode, regex_t *preg) 62 | { 63 | static char *oe; 64 | size_t s; 65 | 66 | if (oe != NULL) 67 | free(oe); 68 | s = regerror(errcode, preg, NULL, 0); 69 | if ((oe = malloc(s)) == NULL) 70 | err(1, "malloc"); 71 | (void)regerror(errcode, preg, oe, s); 72 | return (oe); 73 | } 74 | -------------------------------------------------------------------------------- /src/seq/meson.build: -------------------------------------------------------------------------------- 1 | seq_prog = executable( 2 | 'seq', 3 | [ 'seq.c' ], 4 | dependencies : [ libm, ], 5 | include_directories : inc, 6 | install : true, 7 | ) 8 | 9 | install_man('seq.1') 10 | -------------------------------------------------------------------------------- /src/sleep/meson.build: -------------------------------------------------------------------------------- 1 | sleep_prog = executable( 2 | 'sleep', 3 | [ 'sleep.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('sleep.1') 9 | -------------------------------------------------------------------------------- /src/sort/mem.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (C) 2009 Gabor Kovesdan 5 | * Copyright (C) 2012 Oleg Moskalenko 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | __FBSDID("$FreeBSD$"); 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "mem.h" 38 | 39 | void* 40 | sort_calloc(size_t nb, size_t size) 41 | { 42 | void *ptr; 43 | 44 | if ((ptr = calloc(nb, size)) == NULL) 45 | err(2, NULL); 46 | return (ptr); 47 | } 48 | 49 | /* 50 | * malloc() wrapper. 51 | */ 52 | void * 53 | sort_malloc(size_t size) 54 | { 55 | void *ptr; 56 | 57 | if ((ptr = malloc(size)) == NULL) 58 | err(2, NULL); 59 | return (ptr); 60 | } 61 | 62 | /* 63 | * free() wrapper. 64 | */ 65 | void 66 | sort_free(const void *ptr) 67 | { 68 | 69 | if (ptr) 70 | free(__DECONST(void *, ptr)); 71 | } 72 | 73 | /* 74 | * realloc() wrapper. 75 | */ 76 | void * 77 | sort_realloc(void *ptr, size_t size) 78 | { 79 | 80 | if ((ptr = realloc(ptr, size)) == NULL) 81 | err(2, NULL); 82 | return (ptr); 83 | } 84 | 85 | char * 86 | sort_strdup(const char *str) 87 | { 88 | char *dup; 89 | 90 | if ((dup = strdup(str)) == NULL) 91 | err(2, NULL); 92 | return (dup); 93 | } 94 | -------------------------------------------------------------------------------- /src/sort/mem.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | 3 | /*- 4 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 5 | * 6 | * Copyright (C) 2009 Gabor Kovesdan 7 | * Copyright (C) 2012 Oleg Moskalenko 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #if !defined(__SORT_MEM_H__) 33 | #define __SORT_MEM_H__ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | /* 40 | * mem.c 41 | */ 42 | void *sort_calloc(size_t, size_t); 43 | void *sort_malloc(size_t); 44 | void sort_free(const void *ptr); 45 | void *sort_realloc(void *, size_t); 46 | char *sort_strdup(const char *); 47 | 48 | #endif /* __SORT_MEM_H__ */ 49 | -------------------------------------------------------------------------------- /src/sort/meson.build: -------------------------------------------------------------------------------- 1 | sort_cargs = [ '-DWITHOUT_NLS', '-DSORT_THREADS', ] 2 | 3 | if not libcrypto.found() 4 | sort_cargs += [ '-DWITHOUT_LIBCRYPTO' ] 5 | endif 6 | 7 | sort_prog = executable( 8 | 'sort', 9 | [ 10 | 'bwstring.c', 'coll.c', 'file.c', 'mem.c', 11 | 'radixsort.c', 'sort.c', 'vsort.c', 12 | ], 13 | include_directories : [ inc, ], 14 | dependencies : [ libcrypto, libpthread, ], 15 | link_with : [ libcompat, ], 16 | c_args : sort_cargs, 17 | install : true, 18 | ) 19 | 20 | install_man('sort.1') 21 | -------------------------------------------------------------------------------- /src/sort/radixsort.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | 3 | /*- 4 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 5 | * 6 | * Copyright (C) 2012 Oleg Moskalenko 7 | * Copyright (C) 2012 Gabor Kovesdan 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #if !defined(__SORT_RADIX_H__) 33 | #define __SORT_RADIX_H__ 34 | 35 | #include "coll.h" 36 | #include "sort.h" 37 | 38 | void rxsort(struct sort_list_item **base, size_t nmemb); 39 | 40 | #endif /* __SORT_RADIX_H__ */ 41 | -------------------------------------------------------------------------------- /src/sort/vsort.h: -------------------------------------------------------------------------------- 1 | /* $FreeBSD$ */ 2 | 3 | /*- 4 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 5 | * 6 | * Copyright (C) 2012 Oleg Moskalenko 7 | * Copyright (C) 2012 Gabor Kovesdan 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _VSORT_H_ 33 | #define _VSORT_H_ 34 | 35 | #include "bwstring.h" 36 | 37 | int vcmp(struct bwstring *s1, struct bwstring *s2); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/split/meson.build: -------------------------------------------------------------------------------- 1 | split_prog = executable( 2 | 'split', 3 | [ 'split.c' ], 4 | include_directories : inc, 5 | link_with : [ libcompat, ], 6 | install : true, 7 | ) 8 | 9 | install_man('split.1') 10 | -------------------------------------------------------------------------------- /src/stat/meson.build: -------------------------------------------------------------------------------- 1 | stat_prog = executable( 2 | 'stat', 3 | [ 'stat.c' ], 4 | include_directories : [ inc, ], 5 | link_with : [ libcompat, ], 6 | install : true, 7 | ) 8 | 9 | install_man('stat.1') 10 | 11 | meson.add_install_script(install_link, 'stat', 'readlink', get_option('bindir')) 12 | meson.add_install_script( 13 | install_link, 'stat.1', 'readlink.1', 14 | join_paths(get_option('mandir'), 'man1') 15 | ) 16 | -------------------------------------------------------------------------------- /src/stdbuf/meson.build: -------------------------------------------------------------------------------- 1 | stdbuf_prog = executable( 2 | 'stdbuf', 3 | [ 'stdbuf.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('stdbuf.1') 8 | -------------------------------------------------------------------------------- /src/stty/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)extern.h 8.1 (Berkeley) 5/31/93 30 | * $FreeBSD$ 31 | */ 32 | 33 | int c_cchars(const void *, const void *); 34 | int c_modes(const void *, const void *); 35 | int csearch(char ***, struct info *); 36 | void checkredirect(void); 37 | void gprint(struct termios *, struct winsize *, int); 38 | void gread(struct termios *, char *); 39 | int ksearch(char ***, struct info *); 40 | int msearch(char ***, struct info *); 41 | void optlist(void); 42 | void print(struct termios *, struct winsize *, int, enum FMT); 43 | void usage(void) __dead2; 44 | 45 | int get_baud(speed_t s); 46 | speed_t get_speed(unsigned long b); 47 | 48 | extern struct cchar cchars1[], cchars2[]; 49 | -------------------------------------------------------------------------------- /src/stty/meson.build: -------------------------------------------------------------------------------- 1 | stty_prog = executable( 2 | 'stty', 3 | [ 'cchar.c', 4 | 'gfmt.c', 5 | 'key.c', 6 | 'modes.c', 7 | 'print.c', 8 | 'stty.c', 9 | 'util.c', 10 | ], 11 | include_directories : inc, 12 | install : true, 13 | ) 14 | 15 | install_man('stty.1') 16 | -------------------------------------------------------------------------------- /src/stty/stty.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1991, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)stty.h 8.1 (Berkeley) 5/31/93 30 | * $FreeBSD$ 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | struct info { 37 | int fd; /* file descriptor */ 38 | int ldisc; /* line discipline */ 39 | int off; /* turn off */ 40 | int set; /* need set */ 41 | int wset; /* need window set */ 42 | const char *arg; /* argument */ 43 | struct termios t; /* terminal info */ 44 | struct winsize win; /* window info */ 45 | }; 46 | 47 | struct cchar { 48 | const char *name; 49 | int sub; 50 | u_char def; 51 | }; 52 | 53 | enum FMT { NOTSET, GFLAG, BSD, POSIX }; 54 | 55 | #define LINELENGTH 72 56 | -------------------------------------------------------------------------------- /src/sync/meson.build: -------------------------------------------------------------------------------- 1 | sync_prog = executable( 2 | 'sync', 3 | [ 'sync.c' ], 4 | include_directories : inc, 5 | install : true, 6 | install_dir : get_option('sbindir'), 7 | ) 8 | 9 | install_man('sync.8') 10 | -------------------------------------------------------------------------------- /src/sync/sync.8: -------------------------------------------------------------------------------- 1 | .\"- 2 | .\" Copyright (c) 1980, 1991, 1993 3 | .\" The Regents of the University of California. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. Neither the name of the University nor the names of its contributors 14 | .\" may be used to endorse or promote products derived from this software 15 | .\" without specific prior written permission. 16 | .\" 17 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | .\" SUCH DAMAGE. 28 | .\" 29 | .\" @(#)sync.8 8.1 (Berkeley) 5/31/93 30 | .\" $FreeBSD$ 31 | .\" 32 | .Dd May 31, 1993 33 | .Dt SYNC 8 34 | .Os 35 | .Sh NAME 36 | .Nm sync 37 | .Nd force completion of pending disk writes (flush cache) 38 | .Sh SYNOPSIS 39 | .Nm 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | utility 44 | can be called to ensure that all disk writes have been completed before the 45 | processor is halted in a way not suitably done by 46 | .Xr reboot 8 47 | or 48 | .Xr halt 8 . 49 | Generally, it is preferable to use 50 | .Xr reboot 8 51 | or 52 | .Xr halt 8 53 | to shut down the system, 54 | as they may perform additional actions 55 | such as resynchronizing the hardware clock 56 | and flushing internal caches before performing a final 57 | .Nm . 58 | .Pp 59 | The 60 | .Nm 61 | utility utilizes the 62 | .Xr sync 2 63 | function call. 64 | .Sh SEE ALSO 65 | .Xr fsync 2 , 66 | .Xr sync 2 , 67 | .Xr syncer 4 , 68 | .Xr halt 8 , 69 | .Xr reboot 8 70 | .Sh HISTORY 71 | A 72 | .Nm 73 | utility appeared in 74 | .At v4 . 75 | -------------------------------------------------------------------------------- /src/sync/sync.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1987, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #if 0 31 | #ifndef lint 32 | static char const copyright[] = 33 | "@(#) Copyright (c) 1987, 1993\n\ 34 | The Regents of the University of California. All rights reserved.\n"; 35 | #endif /* not lint */ 36 | 37 | #ifndef lint 38 | static char sccsid[] = "@(#)sync.c 8.1 (Berkeley) 5/31/93"; 39 | #endif /* not lint */ 40 | #endif 41 | #include 42 | __FBSDID("$FreeBSD$"); 43 | 44 | #include 45 | #include 46 | 47 | int 48 | main(int argc __attribute__((unused)), char *argv[] __attribute__((unused))) 49 | { 50 | sync(); 51 | exit(0); 52 | } 53 | -------------------------------------------------------------------------------- /src/tail/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 32 | * 33 | * $FreeBSD$ 34 | */ 35 | 36 | #define WR(p, size) do { \ 37 | ssize_t res; \ 38 | res = write(STDOUT_FILENO, p, size); \ 39 | if (res != (ssize_t)size) { \ 40 | if (res == -1) \ 41 | oerr(); \ 42 | else \ 43 | errx(1, "stdout"); \ 44 | } \ 45 | } while (0) 46 | 47 | #define TAILMAPLEN (4<<20) 48 | 49 | struct mapinfo { 50 | off_t mapoff; 51 | off_t maxoff; 52 | size_t maplen; 53 | char *start; 54 | int fd; 55 | }; 56 | 57 | struct file_info { 58 | FILE *fp; 59 | const char *file_name; 60 | struct stat st; 61 | }; 62 | 63 | typedef struct file_info file_info_t; 64 | 65 | enum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE }; 66 | 67 | void follow(file_info_t *, enum STYLE, off_t); 68 | void forward(FILE *, const char *, enum STYLE, off_t, struct stat *); 69 | void reverse(FILE *, const char *, enum STYLE, off_t, struct stat *); 70 | 71 | int bytes(FILE *, const char *, off_t); 72 | int lines(FILE *, const char *, off_t); 73 | 74 | void ierr(const char *); 75 | void oerr(void); 76 | int mapprint(struct mapinfo *, off_t, off_t); 77 | int maparound(struct mapinfo *, off_t); 78 | void printfn(const char *, int); 79 | 80 | extern int Fflag, fflag, qflag, rflag, rval, no_files; 81 | -------------------------------------------------------------------------------- /src/tail/meson.build: -------------------------------------------------------------------------------- 1 | tail_prog = executable( 2 | 'tail', 3 | [ 'forward.c', 4 | 'misc.c', 5 | 'read.c', 6 | 'reverse.c', 7 | 'tail.c', 8 | ], 9 | include_directories : [ inc, ], 10 | install : true, 11 | ) 12 | 13 | install_man('tail.1') 14 | -------------------------------------------------------------------------------- /src/tee/meson.build: -------------------------------------------------------------------------------- 1 | tee_prog = executable( 2 | 'tee', 3 | [ 'tee.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('tee.1') 8 | -------------------------------------------------------------------------------- /src/tee/tee.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" This code is derived from software contributed to Berkeley by 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. 6 | .\" 7 | .\" Redistribution and use in source and binary forms, with or without 8 | .\" modification, are permitted provided that the following conditions 9 | .\" are met: 10 | .\" 1. Redistributions of source code must retain the above copyright 11 | .\" notice, this list of conditions and the following disclaimer. 12 | .\" 2. Redistributions in binary form must reproduce the above copyright 13 | .\" notice, this list of conditions and the following disclaimer in the 14 | .\" documentation and/or other materials provided with the distribution. 15 | .\" 3. Neither the name of the University nor the names of its contributors 16 | .\" may be used to endorse or promote products derived from this software 17 | .\" without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | .\" SUCH DAMAGE. 30 | .\" 31 | .\" @(#)tee.1 8.1 (Berkeley) 6/6/93 32 | .\" $FreeBSD$ 33 | .\" 34 | .Dd October 30, 2022 35 | .Dt TEE 1 36 | .Os 37 | .Sh NAME 38 | .Nm tee 39 | .Nd duplicate standard input 40 | .Sh SYNOPSIS 41 | .Nm 42 | .Op Fl ai 43 | .Op Ar 44 | .Sh DESCRIPTION 45 | The 46 | .Nm 47 | utility copies standard input to standard output, 48 | making a copy in zero or more files. 49 | The output is unbuffered. 50 | .Pp 51 | The following options are available: 52 | .Bl -tag -width indent 53 | .It Fl a 54 | Append the output to the files rather than 55 | overwriting them. 56 | .It Fl i 57 | Ignore the 58 | .Dv SIGINT 59 | signal. 60 | .El 61 | .Pp 62 | The following operands are available: 63 | .Bl -tag -width indent 64 | .It Ar file 65 | A pathname of an output 66 | .Ar file . 67 | .El 68 | .Pp 69 | The 70 | .Nm 71 | utility takes the default action for all signals, 72 | except in the event of the 73 | .Fl i 74 | option. 75 | .Sh EXIT STATUS 76 | .Ex -std 77 | .Sh EXAMPLES 78 | Send the echoed message both to stdout and to the 79 | .Pa greetings.txt 80 | file: 81 | .Bd -literal -offset indent 82 | $ echo "Hello" | tee greetings.txt 83 | Hello 84 | .Ed 85 | .Sh STANDARDS 86 | The 87 | .Nm 88 | utility is expected to be 89 | .St -p1003.2 90 | compatible. 91 | .Sh HISTORY 92 | The 93 | .Nm 94 | command first appeared in 95 | .At v7 . 96 | -------------------------------------------------------------------------------- /src/test/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BINDIR="${1}" 4 | 5 | mkdir -p "${DESTDIR}"/"${MESON_INSTALL_PREFIX}"/"${BINDIR}" 6 | install -d "${DESTDIR}"/"${MESON_INSTALL_PREFIX}"/"${BINDIR}" 7 | install -m 0755 "${MESON_BUILD_ROOT}"/src/test/xtest "${DESTDIR}"/"${MESON_INSTALL_PREFIX}"/"${BINDIR}"/test 8 | -------------------------------------------------------------------------------- /src/test/meson.build: -------------------------------------------------------------------------------- 1 | test_prog = executable( 2 | 'xtest', 3 | [ 'test.c' ], 4 | include_directories : inc, 5 | ) 6 | 7 | meson.add_install_script('install.sh', get_option('bindir')) 8 | 9 | install_man('test.1') 10 | 11 | meson.add_install_script(install_link, 'test', '[', get_option('bindir')) 12 | meson.add_install_script( 13 | install_link, 'test.1', '[.1', join_paths(get_option('mandir'), 'man1') 14 | ) 15 | -------------------------------------------------------------------------------- /src/timeout/meson.build: -------------------------------------------------------------------------------- 1 | timeout_prog = executable( 2 | 'timeout', 3 | [ 'timeout.c' ], 4 | include_directories : inc, 5 | link_with : [ libcompat, ], 6 | install : true, 7 | ) 8 | 9 | install_man('timeout.1') 10 | -------------------------------------------------------------------------------- /src/touch/meson.build: -------------------------------------------------------------------------------- 1 | touch_prog = executable( 2 | 'touch', 3 | [ 'touch.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('touch.1') 9 | -------------------------------------------------------------------------------- /src/tr/cmap.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (c) 2004 Tim J. Robbins. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * $FreeBSD$ 29 | */ 30 | 31 | #ifndef CMAP_H 32 | #define CMAP_H 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | struct cmapnode { 39 | wint_t cmn_from; 40 | wint_t cmn_to; 41 | struct cmapnode *cmn_left; 42 | struct cmapnode *cmn_right; 43 | }; 44 | 45 | struct cmap { 46 | #define CM_CACHE_SIZE 128 47 | wint_t cm_cache[CM_CACHE_SIZE]; 48 | bool cm_havecache; 49 | struct cmapnode *cm_root; 50 | #define CM_DEF_SELF (wint_t)(-2) 51 | wint_t cm_def; 52 | wint_t cm_min; 53 | wint_t cm_max; 54 | }; 55 | 56 | struct cmap * cmap_alloc(void); 57 | bool cmap_add(struct cmap *, wint_t, wint_t); 58 | wint_t cmap_lookup_hard(struct cmap *, wint_t); 59 | void cmap_cache(struct cmap *); 60 | wint_t cmap_default(struct cmap *, wint_t); 61 | 62 | static __inline wint_t 63 | cmap_lookup(struct cmap *cm, wint_t from) 64 | { 65 | 66 | if (from < CM_CACHE_SIZE && cm->cm_havecache) 67 | return (cm->cm_cache[from]); 68 | return (cmap_lookup_hard(cm, from)); 69 | } 70 | 71 | static __inline wint_t 72 | cmap_min(struct cmap *cm) 73 | { 74 | 75 | return (cm->cm_min); 76 | } 77 | 78 | static __inline wint_t 79 | cmap_max(struct cmap *cm) 80 | { 81 | 82 | return (cm->cm_max); 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/tr/cset.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (c) 2004 Tim J. Robbins. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | * $FreeBSD$ 29 | */ 30 | 31 | #ifndef CSET_H 32 | #define CSET_H 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | struct csnode { 39 | wchar_t csn_min; 40 | wchar_t csn_max; 41 | struct csnode *csn_left; 42 | struct csnode *csn_right; 43 | }; 44 | 45 | struct csclass { 46 | wctype_t csc_type; 47 | bool csc_invert; 48 | struct csclass *csc_next; 49 | }; 50 | 51 | struct cset { 52 | #define CS_CACHE_SIZE 256 53 | bool cs_cache[CS_CACHE_SIZE]; 54 | bool cs_havecache; 55 | struct csclass *cs_classes; 56 | struct csnode *cs_root; 57 | bool cs_invert; 58 | }; 59 | 60 | bool cset_addclass(struct cset *, wctype_t, bool); 61 | struct cset * cset_alloc(void); 62 | bool cset_add(struct cset *, wchar_t); 63 | void cset_invert(struct cset *); 64 | bool cset_in_hard(struct cset *, wchar_t); 65 | void cset_cache(struct cset *); 66 | 67 | static __inline bool 68 | cset_in(struct cset *cs, wchar_t ch) 69 | { 70 | 71 | if (ch < CS_CACHE_SIZE && cs->cs_havecache) 72 | return (cs->cs_cache[ch]); 73 | return (cset_in_hard(cs, ch)); 74 | } 75 | 76 | #endif /* CSET_H */ 77 | -------------------------------------------------------------------------------- /src/tr/extern.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * @(#)extern.h 8.1 (Berkeley) 6/6/93 32 | * $FreeBSD$ 33 | */ 34 | 35 | #include 36 | 37 | #define NCHARS_SB (UCHAR_MAX + 1) /* Number of single-byte characters. */ 38 | #define OOBCH (wint_t)(-1) /* Out of band character value. */ 39 | 40 | typedef struct { 41 | enum { STRING1, STRING2 } which; 42 | enum { EOS, INFINITE, NORMAL, RANGE, SEQUENCE, 43 | CCLASS, CCLASS_UPPER, CCLASS_LOWER, SET } state; 44 | int cnt; /* character count */ 45 | wint_t lastch; /* last character */ 46 | wctype_t cclass; /* character class from wctype() */ 47 | wint_t equiv[NCHARS_SB]; /* equivalence set */ 48 | wint_t *set; /* set of characters */ 49 | char *str; /* user's string */ 50 | } STR; 51 | 52 | wint_t next(STR *); 53 | int charcoll(const void *, const void *); 54 | 55 | #define iswrune(v) (iswprint(v) || iswcntrl(v)) 56 | -------------------------------------------------------------------------------- /src/tr/meson.build: -------------------------------------------------------------------------------- 1 | tr_prog = executable( 2 | 'tr', 3 | [ 'tr.c', 'cmap.c', 'cset.c', 'str.c' ], 4 | include_directories : [ inc, ], 5 | link_with : [ libcompat, ], 6 | install : true, 7 | ) 8 | 9 | install_man('tr.1') 10 | -------------------------------------------------------------------------------- /src/true/meson.build: -------------------------------------------------------------------------------- 1 | true_prog = executable( 2 | 'true', 3 | [ 'true.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('true.1') 8 | -------------------------------------------------------------------------------- /src/true/true.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1983, 1985, 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" This code is derived from software contributed to Berkeley by 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. 6 | .\" 7 | .\" Redistribution and use in source and binary forms, with or without 8 | .\" modification, are permitted provided that the following conditions 9 | .\" are met: 10 | .\" 1. Redistributions of source code must retain the above copyright 11 | .\" notice, this list of conditions and the following disclaimer. 12 | .\" 2. Redistributions in binary form must reproduce the above copyright 13 | .\" notice, this list of conditions and the following disclaimer in the 14 | .\" documentation and/or other materials provided with the distribution. 15 | .\" 3. Neither the name of the University nor the names of its contributors 16 | .\" may be used to endorse or promote products derived from this software 17 | .\" without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | .\" SUCH DAMAGE. 30 | .\" 31 | .\" @(#)true.1 8.1 (Berkeley) 6/9/93 32 | .\" $FreeBSD$ 33 | .\" 34 | .Dd June 9, 1993 35 | .Dt TRUE 1 36 | .Os 37 | .Sh NAME 38 | .Nm true 39 | .Nd return true value 40 | .Sh SYNOPSIS 41 | .Nm 42 | .Sh DESCRIPTION 43 | The 44 | .Nm 45 | utility always returns with an exit code of zero. 46 | .Pp 47 | Some shells may provide a builtin 48 | .Nm 49 | command which is identical to this utility. 50 | Consult the 51 | .Xr builtin 1 52 | manual page. 53 | .Sh SEE ALSO 54 | .Xr builtin 1 , 55 | .Xr csh 1 , 56 | .Xr false 1 , 57 | .Xr sh 1 58 | .Sh STANDARDS 59 | The 60 | .Nm 61 | utility is expected to be 62 | .St -p1003.2 63 | compatible. 64 | -------------------------------------------------------------------------------- /src/true/true.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1988, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * $FreeBSD$ 32 | */ 33 | 34 | #ifndef lint 35 | static const char copyright[] = 36 | "@(#) Copyright (c) 1988, 1993\n\ 37 | The Regents of the University of California. All rights reserved.\n"; 38 | #endif /* not lint */ 39 | 40 | #ifndef lint 41 | static const char sccsid[] = "@(#)true.c 8.1 (Berkeley) 6/9/93"; 42 | #endif /* not lint */ 43 | 44 | int 45 | main(void) 46 | { 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /src/truncate/meson.build: -------------------------------------------------------------------------------- 1 | truncate_prog = executable( 2 | 'truncate', 3 | [ 'truncate.c' ], 4 | include_directories : inc, 5 | link_with : [ libcompat ], 6 | install : true, 7 | ) 8 | 9 | install_man('truncate.1') 10 | -------------------------------------------------------------------------------- /src/tsort/meson.build: -------------------------------------------------------------------------------- 1 | tsort_prog = executable( 2 | 'tsort', 3 | [ 'tsort.c' ], 4 | include_directories : [ inc, ], 5 | install : true, 6 | ) 7 | 8 | install_man('tsort.1') 9 | -------------------------------------------------------------------------------- /src/tty/meson.build: -------------------------------------------------------------------------------- 1 | tty_prog = executable( 2 | 'tty', 3 | [ 'tty.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('tty.1') 9 | -------------------------------------------------------------------------------- /src/tty/tty.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1990, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" This code is derived from software contributed to Berkeley by 5 | .\" the Institute of Electrical and Electronics Engineers, Inc. 6 | .\" 7 | .\" Redistribution and use in source and binary forms, with or without 8 | .\" modification, are permitted provided that the following conditions 9 | .\" are met: 10 | .\" 1. Redistributions of source code must retain the above copyright 11 | .\" notice, this list of conditions and the following disclaimer. 12 | .\" 2. Redistributions in binary form must reproduce the above copyright 13 | .\" notice, this list of conditions and the following disclaimer in the 14 | .\" documentation and/or other materials provided with the distribution. 15 | .\" 3. Neither the name of the University nor the names of its contributors 16 | .\" may be used to endorse or promote products derived from this software 17 | .\" without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | .\" SUCH DAMAGE. 30 | .\" 31 | .\" @(#)tty.1 8.1 (Berkeley) 6/6/93 32 | .\" $FreeBSD$ 33 | .\" 34 | .Dd June 6, 1993 35 | .Dt TTY 1 36 | .Os 37 | .Sh NAME 38 | .Nm tty 39 | .Nd return user's terminal name 40 | .Sh SYNOPSIS 41 | .Nm 42 | .Op Fl s 43 | .Sh DESCRIPTION 44 | The 45 | .Nm 46 | utility writes the name of the terminal attached to standard input 47 | to standard output. 48 | The name that is written is the string returned by 49 | .Xr ttyname 3 . 50 | If the standard input is not a terminal, the message 51 | .Dq Li "not a tty" 52 | is written. 53 | The options are as follows: 54 | .Bl -tag -width indent 55 | .It Fl s 56 | Do not write the terminal name; only the exit status is affected 57 | when this option is specified. 58 | The 59 | .Fl s 60 | option is deprecated in favor of the 61 | .Dq Li "test -t 0" 62 | command. 63 | .El 64 | .Sh EXIT STATUS 65 | The 66 | .Nm 67 | utility 68 | exits 0 if the standard input is a terminal, 1 if the standard input is 69 | not a terminal, and >1 if an error occurs. 70 | .Sh SEE ALSO 71 | .Xr test 1 , 72 | .Xr ttyname 3 73 | .Sh STANDARDS 74 | The 75 | .Nm 76 | utility is expected to be 77 | .St -p1003.2 78 | compatible. 79 | .Sh HISTORY 80 | A 81 | .Nm 82 | command appeared in 83 | .At v1 . 84 | -------------------------------------------------------------------------------- /src/tty/tty.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1988, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1988, 1993\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #ifndef lint 39 | #if 0 40 | static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/6/93"; 41 | #endif 42 | #endif /* not lint */ 43 | 44 | #include 45 | __FBSDID("$FreeBSD$"); 46 | 47 | #include 48 | #include 49 | #include 50 | 51 | extern char *__progname; 52 | 53 | static void usage(void); 54 | 55 | int 56 | main(int argc, char *argv[]) 57 | { 58 | int ch, sflag; 59 | char *t; 60 | 61 | sflag = 0; 62 | while ((ch = getopt(argc, argv, "s")) != -1) 63 | switch (ch) { 64 | case 's': 65 | sflag = 1; 66 | break; 67 | case '?': 68 | default: 69 | usage(); 70 | /* NOTREACHED */ 71 | } 72 | 73 | t = ttyname(STDIN_FILENO); 74 | if (!sflag) 75 | puts(t ? t : "not a tty"); 76 | exit(t ? EXIT_SUCCESS : EXIT_FAILURE); 77 | } 78 | 79 | static void 80 | usage(void) 81 | { 82 | fprintf(stderr, "usage: %s [-s]\n", __progname); 83 | exit(2); 84 | } 85 | -------------------------------------------------------------------------------- /src/uname/meson.build: -------------------------------------------------------------------------------- 1 | uname_prog = executable( 2 | 'uname', 3 | [ 'uname.c' ], 4 | include_directories : [ inc, ], 5 | install : true, 6 | ) 7 | 8 | install_man('uname.1') 9 | -------------------------------------------------------------------------------- /src/unexpand/meson.build: -------------------------------------------------------------------------------- 1 | unexpand_prog = executable( 2 | 'unexpand', 3 | [ 'unexpand.c' ], 4 | include_directories : inc, 5 | install : true, 6 | ) 7 | 8 | install_man('unexpand.1') 9 | -------------------------------------------------------------------------------- /src/unexpand/unexpand.1: -------------------------------------------------------------------------------- 1 | .so man1/expand.1 2 | -------------------------------------------------------------------------------- /src/uniq/meson.build: -------------------------------------------------------------------------------- 1 | uniq_prog = executable( 2 | 'uniq', 3 | [ 'uniq.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('uniq.1') 8 | -------------------------------------------------------------------------------- /src/users/meson.build: -------------------------------------------------------------------------------- 1 | extra_args = [ '-fno-rtti' ] 2 | 3 | users_prog = executable( 4 | 'users', 5 | [ 'users.cc' ], 6 | include_directories : inc, 7 | cpp_args : extra_args, 8 | install : true, 9 | ) 10 | 11 | install_man('users.1') 12 | -------------------------------------------------------------------------------- /src/users/users.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1980, 1990, 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)users.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd January 21, 2010 32 | .Dt USERS 1 33 | .Os 34 | .Sh NAME 35 | .Nm users 36 | .Nd list current users 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Sh DESCRIPTION 40 | The 41 | .Nm 42 | utility lists the login names of the users currently on the system, 43 | in sorted order, space separated, on a single line. 44 | .Sh FILES 45 | .Bl -tag -width /var/run/utx.active 46 | .It Pa /var/run/utx.active 47 | .El 48 | .Sh SEE ALSO 49 | .Xr finger 1 , 50 | .Xr last 1 , 51 | .Xr who 1 , 52 | .Xr getutxent 3 53 | .Sh HISTORY 54 | The 55 | .Nm 56 | command appeared in 57 | .Bx 3.0 . 58 | -------------------------------------------------------------------------------- /src/users/users.cc: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Pietro Cerutti 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | __FBSDID("$FreeBSD$"); 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | using namespace std; 43 | 44 | int 45 | main(int argc, char **) 46 | { 47 | struct utmpx *ut; 48 | set names; 49 | 50 | if (argc > 1) { 51 | cerr << "usage: users" << endl; 52 | return (1); 53 | } 54 | 55 | setutxent(); 56 | 57 | while ((ut = getutxent()) != NULL) 58 | if (ut->ut_type == USER_PROCESS) 59 | names.insert(ut->ut_user); 60 | endutxent(); 61 | 62 | if (!names.empty()) { 63 | set::iterator last = names.end(); 64 | --last; 65 | copy(names.begin(), last, ostream_iterator(cout, " ")); 66 | cout << *last << endl; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/wc/meson.build: -------------------------------------------------------------------------------- 1 | wc_prog = executable( 2 | 'wc', 3 | [ 'wc.c' ], 4 | include_directories : [ inc, ], 5 | dependencies : [ libxo ], 6 | install : true, 7 | ) 8 | 9 | install_man('wc.1') 10 | -------------------------------------------------------------------------------- /src/which/meson.build: -------------------------------------------------------------------------------- 1 | which_prog = executable( 2 | 'which', 3 | [ 'which.c' ], 4 | include_directories : [ inc, ], 5 | install : true, 6 | install_dir : get_option('bindir'), 7 | ) 8 | 9 | install_man('which.1') 10 | -------------------------------------------------------------------------------- /src/who/meson.build: -------------------------------------------------------------------------------- 1 | who_prog = executable( 2 | 'who', 3 | [ 'who.c' ], 4 | include_directories : [ inc, ], 5 | link_with : [ libcompat ], 6 | install : true, 7 | ) 8 | 9 | install_man('who.1') 10 | -------------------------------------------------------------------------------- /src/xargs/meson.build: -------------------------------------------------------------------------------- 1 | xargs_prog = executable( 2 | 'xargs', 3 | [ 'strnsubst.c', 4 | 'xargs.c', 5 | ], 6 | include_directories : [ inc, ], 7 | link_with : [ libcompat ], 8 | install : true, 9 | ) 10 | 11 | install_man('xargs.1') 12 | -------------------------------------------------------------------------------- /src/xargs/pathnames.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1990, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * $FreeBSD$ 32 | * 33 | * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 34 | */ 35 | 36 | #define _PATH_ECHO "/bin/echo" 37 | -------------------------------------------------------------------------------- /src/xinstall/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BINDIR="${1}" 4 | 5 | mkdir -p "${DESTDIR}/${MESON_INSTALL_PREFIX}/${BINDIR}" 6 | install -d "${DESTDIR}/${MESON_INSTALL_PREFIX}/${BINDIR}" 7 | install -m 0755 ${MESON_BUILD_ROOT}/src/xinstall/xinstall "${DESTDIR}/${MESON_INSTALL_PREFIX}/${BINDIR}"/install 8 | -------------------------------------------------------------------------------- /src/xinstall/meson.build: -------------------------------------------------------------------------------- 1 | xinstall_prog = executable( 2 | 'xinstall', 3 | [ 'xinstall.c', ], 4 | include_directories : [ inc, ], 5 | link_with : [ libcompat, ], 6 | dependencies : [ libcrypto, ], 7 | ) 8 | 9 | meson.add_install_script('install.sh', get_option('bindir')) 10 | install_man('install.1') 11 | -------------------------------------------------------------------------------- /src/yes/meson.build: -------------------------------------------------------------------------------- 1 | yes_prog = executable( 2 | 'yes', 3 | [ 'yes.c' ], 4 | install : true, 5 | ) 6 | 7 | install_man('yes.1') 8 | -------------------------------------------------------------------------------- /src/yes/yes.1: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 1980, 1991, 1993 2 | .\" The Regents of the University of California. All rights reserved. 3 | .\" 4 | .\" Redistribution and use in source and binary forms, with or without 5 | .\" modification, are permitted provided that the following conditions 6 | .\" are met: 7 | .\" 1. Redistributions of source code must retain the above copyright 8 | .\" notice, this list of conditions and the following disclaimer. 9 | .\" 2. Redistributions in binary form must reproduce the above copyright 10 | .\" notice, this list of conditions and the following disclaimer in the 11 | .\" documentation and/or other materials provided with the distribution. 12 | .\" 3. Neither the name of the University nor the names of its contributors 13 | .\" may be used to endorse or promote products derived from this software 14 | .\" without specific prior written permission. 15 | .\" 16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | .\" SUCH DAMAGE. 27 | .\" 28 | .\" @(#)yes.1 8.1 (Berkeley) 6/6/93 29 | .\" $FreeBSD$ 30 | .\" 31 | .Dd June 4, 2014 32 | .Dt YES 1 33 | .Os 34 | .Sh NAME 35 | .Nm yes 36 | .Nd be repetitively affirmative 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Op Ar expletive 40 | .Sh DESCRIPTION 41 | The 42 | .Nm 43 | utility outputs 44 | .Ar expletive , 45 | or, by default, 46 | .Dq y , 47 | forever. 48 | .Sh SEE ALSO 49 | .Xr jot 1 , 50 | .Xr seq 1 51 | .Sh HISTORY 52 | The 53 | .Nm 54 | command appeared in 55 | .At v7 . 56 | -------------------------------------------------------------------------------- /src/yes/yes.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * 4 | * Copyright (c) 1987, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef lint 33 | static const char copyright[] = 34 | "@(#) Copyright (c) 1987, 1993\n\ 35 | The Regents of the University of California. All rights reserved.\n"; 36 | #endif /* not lint */ 37 | 38 | #ifndef lint 39 | #if 0 40 | static char sccsid[] = "@(#)yes.c 8.1 (Berkeley) 6/6/93"; 41 | #else 42 | static const char rcsid[] = "$FreeBSD$"; 43 | #endif 44 | #endif /* not lint */ 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | int 52 | main(int argc, char **argv) 53 | { 54 | char buf[8192]; 55 | char y[2] = { 'y', '\n' }; 56 | char * exp = y; 57 | size_t buflen = 0; 58 | size_t explen = sizeof(y); 59 | size_t more; 60 | ssize_t ret; 61 | 62 | if (argc > 1) { 63 | exp = argv[1]; 64 | explen = strlen(exp) + 1; 65 | exp[explen - 1] = '\n'; 66 | } 67 | 68 | if (explen <= sizeof(buf)) { 69 | while (buflen < sizeof(buf) - explen) { 70 | memcpy(buf + buflen, exp, explen); 71 | buflen += explen; 72 | } 73 | exp = buf; 74 | explen = buflen; 75 | } 76 | 77 | more = explen; 78 | while ((ret = write(STDOUT_FILENO, exp + (explen - more), more)) > 0) 79 | if ((more -= ret) == 0) 80 | more = explen; 81 | 82 | err(1, "stdout"); 83 | /*NOTREACHED*/ 84 | } 85 | -------------------------------------------------------------------------------- /upstream.conf: -------------------------------------------------------------------------------- 1 | # The upstream version of FreeBSD we are pulling from. 2 | VER=13.2-RELEASE 3 | 4 | # The download URL for the source code. 5 | SRC="http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/${VER}/src.txz" 6 | -------------------------------------------------------------------------------- /utils/find-ninja.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Find the ninja command to use. 4 | # 5 | 6 | if ! ninja --help >/dev/null 2>&1 ; then 7 | echo "ninja" 8 | exit 0 9 | fi 10 | 11 | if ! ninja-build --help >/dev/null 2>&1 ; then 12 | echo "ninja-build" 13 | exit 0 14 | fi 15 | 16 | exit 1 17 | -------------------------------------------------------------------------------- /utils/install-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ORIGIN="${1}" 4 | TARGET="${2}" 5 | TARGET_DIR="${3}" 6 | 7 | mkdir -p "${DESTDIR}/${MESON_INSTALL_PREFIX}/${TARGET_DIR}" 8 | ln -sf "${ORIGIN}" "${DESTDIR}/${MESON_INSTALL_PREFIX}/${TARGET_DIR}/${TARGET}" 9 | --------------------------------------------------------------------------------