mirror of
https://github.com/troglobit/libite.git
synced 2026-10-14 10:19:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67529f2283 | ||
|
|
8e69676943 | ||
|
|
76faae4292 | ||
|
|
e928c30fbd | ||
|
|
3512201a58 | ||
|
|
dc5c4ae36c | ||
|
|
748948b665 | ||
|
|
951050fdd2 | ||
|
|
d5c5996f03 | ||
|
|
f5808e557e | ||
|
|
d4b554ccdc | ||
|
|
098a020843 | ||
|
|
2040569f0a | ||
|
|
733a7062e9 | ||
|
|
7ad11a31df | ||
|
|
8ce46eb439 | ||
|
|
c15e883427 | ||
|
|
63d82da62d | ||
|
|
dd1c67b2b6 | ||
|
|
08d9a90945 | ||
|
|
beba419a0f | ||
|
|
3d695eede5 |
No files matched your search
+5
-5
@@ -25,15 +25,15 @@ addons:
|
||||
name: "troglobit/libite"
|
||||
description: "That missing frog DNA you've been looking for"
|
||||
notification_email: troglobit@gmail.com
|
||||
build_command_prepend: "./autogen.sh && ./configure --prefix=/tmp --disable-silent-rules"
|
||||
build_command_prepend: "./autogen.sh && ./configure --prefix= --disable-silent-rules"
|
||||
build_command: "make clean all"
|
||||
branch_pattern: dev
|
||||
|
||||
script:
|
||||
- ./autogen.sh
|
||||
- ./configure --prefix=/tmp --disable-silent-rules
|
||||
- ./configure --prefix= --disable-silent-rules
|
||||
- make clean
|
||||
- make -j5
|
||||
- make install-strip
|
||||
- ls -lR /tmp
|
||||
- make check
|
||||
- make install-strip DESTDIR=/tmp/foo
|
||||
- ls -lR /tmp/foo
|
||||
- make distcheck
|
||||
+33
-1
@@ -3,6 +3,36 @@ Change Log
|
||||
|
||||
All notable changes to the project are documented in this file.
|
||||
|
||||
|
||||
[v2.4.0][] - 2021-03-27
|
||||
-----------------------
|
||||
|
||||
### Changes
|
||||
|
||||
- Add support for `touchf()`, formatted string support for `touch()`
|
||||
- Add support for `erasef()`, formatted string support for `erase()`
|
||||
- Add support for `strtrim()`, trims leading and trailing white-space
|
||||
from a string
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix `systemf()` improper handling of `system()` return value. Now
|
||||
checks if exited OK, then returning the exit status of the command, or
|
||||
if not exited OK, then checks if the command was signaled, and returns
|
||||
-1 with `errno` set. This also allows for returning 127, like
|
||||
`system()`, if the shell, or the program itself, did not exist
|
||||
|
||||
|
||||
[v2.3.1][] - 2021-02-12
|
||||
-----------------------
|
||||
|
||||
### Changes
|
||||
- Copyright updates, including LICENSE file, year + author last name
|
||||
|
||||
### Fixes
|
||||
- Debian packaging fixes only
|
||||
|
||||
|
||||
[v2.3.0][] - 2021-02-12
|
||||
-----------------------
|
||||
|
||||
@@ -383,7 +413,9 @@ problems this may cause!
|
||||
Initial extraction of frog DNA from [Finit][]. See [README][] for API details.
|
||||
|
||||
|
||||
[UNRELEASED]: https://github.com/troglobit/libite/compare/v2.3.0...HEAD
|
||||
[UNRELEASED]: https://github.com/troglobit/libite/compare/v2.4.0...HEAD
|
||||
[v2.4.0]: https://github.com/troglobit/libite/compare/v2.3.1...v2.4.0
|
||||
[v2.3.1]: https://github.com/troglobit/libite/compare/v2.3.0...v2.3.1
|
||||
[v2.3.0]: https://github.com/troglobit/libite/compare/v2.2.1...v2.3.0
|
||||
[v2.2.1]: https://github.com/troglobit/libite/compare/v2.2.0...v2.2.1
|
||||
[v2.2.0]: https://github.com/troglobit/libite/compare/v2.1.2...v2.2.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
|
||||
Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+6
-6
@@ -24,15 +24,15 @@ release-hook:
|
||||
echo; \
|
||||
fi
|
||||
|
||||
# lintian --profile debian -i -I --show-overrides ../$PKG.changes
|
||||
package build-deb:
|
||||
@dpkg-buildpackage -uc -us -B
|
||||
## Generate .deb package
|
||||
package:
|
||||
@debuild -uc -us -B --lintian-opts --profile debian -i -I --show-overrides
|
||||
|
||||
## Target to run when building a release
|
||||
release: release-hook distcheck package
|
||||
@for file in $(DIST_ARCHIVES); do \
|
||||
md5sum $$file > ../$$file.md5; \
|
||||
sha256sum $$file > ../$$file.sha256; \
|
||||
@for file in $(DIST_ARCHIVES); do \
|
||||
md5sum $$file > ../$$file.md5; \
|
||||
sha256sum $$file > ../$$file.sha256; \
|
||||
done
|
||||
@mv $(DIST_ARCHIVES) ../
|
||||
@echo
|
||||
|
||||
@@ -94,6 +94,10 @@ Helper Macros
|
||||
|
||||
Erase file/directory with `remove()`. Errors on `stderr`
|
||||
|
||||
- `erasef(fmt, ...)`
|
||||
|
||||
Like `erase()` but takes a formatted printf-like string as argument.
|
||||
|
||||
- `makedir(path)`
|
||||
|
||||
Create directory, like `mkdir()`. Errors on `stderr`
|
||||
@@ -110,6 +114,10 @@ Helper Macros
|
||||
|
||||
Create a file, or update mtime. Errors on `stderr`
|
||||
|
||||
- `touchf(fmt, ...)`
|
||||
|
||||
Like `touch()` but takes a formatted printf-like string as argument.
|
||||
|
||||
- `S_ISEXEC(mode_t m)`
|
||||
|
||||
Mysteriously missing from GLIBC
|
||||
@@ -311,6 +319,11 @@ Generic Functions
|
||||
match, or `-1` on error or not found. `strnmatch()` takes an extra arg
|
||||
to compare only `len` number of characters from `str`.
|
||||
|
||||
- `strtrim(str)`
|
||||
|
||||
Trims a string from any leading and trailing white-space, returns the
|
||||
trimmed result in the same buffer.
|
||||
|
||||
- `systemf(fmt, ...)`
|
||||
|
||||
Like `system()`, but takes a formatted string as argument. This
|
||||
@@ -442,12 +455,13 @@ as a light weight utility library, these days NetBSD should also work.
|
||||
to generate a `configure` script. It is a generated file and otherwise
|
||||
only included in released tarballs.
|
||||
|
||||
|
||||
Origin & References
|
||||
-------------------
|
||||
|
||||
Much of the code in libite (-lite) is written by [Claudio Matsuoka][]
|
||||
for [Finit][original finit] and released under the MIT/X11 license.
|
||||
Joachim Nilsson later improved on the [Finit][] code base and included
|
||||
Joachim Wiberg later improved on the [Finit][] code base and included
|
||||
pieces of software released under the ISC and BSD licenses. See each
|
||||
respective file for license details.
|
||||
|
||||
@@ -461,7 +475,7 @@ respective file for license details.
|
||||
[ISC]: https://en.wikipedia.org/wiki/ISC_license
|
||||
[BSD]: https://en.wikipedia.org/wiki/BSD_licenses
|
||||
[Travis]: https://travis-ci.org/troglobit/libite
|
||||
[Travis Status]: https://travis-ci.org/troglobit/libite.png?branch=master
|
||||
[Travis Status]: https://travis-ci.org/troglobit/libite.svg?branch=master
|
||||
[Coverity Scan]: https://scan.coverity.com/projects/20602
|
||||
[Coverity Status]: https://img.shields.io/coverity/scan/20602.svg
|
||||
[Claudio Matsuoka]: https://github.com/cmatsuoka
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
AC_INIT(libite, 2.3.0, https://github.com/troglobit/libite/issues)
|
||||
AC_INIT(libite, 2.4.0, https://github.com/troglobit/libite/issues)
|
||||
AC_CONFIG_AUX_DIR(aux)
|
||||
AM_INIT_AUTOMAKE([1.11 foreign dist-xz])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
Vendored
+21
@@ -1,3 +1,24 @@
|
||||
libite (2.4.0) stable; urgency=medium
|
||||
|
||||
* New functions:
|
||||
- touchf(), formatted string support for touch()
|
||||
- erasef(), formatted string support for erase()
|
||||
- strtrim(), trims leading and trailing white-space from a string
|
||||
* Fix systemf() improper handling of system() return value. Now checks
|
||||
if exited OK, then returning the exit status of the command, or if not
|
||||
exited OK, then checks if the command was signaled, and returns -1 with
|
||||
errno set. This also allows for returning 127, like system(), if the
|
||||
shell, or the program itself, did not exist.
|
||||
|
||||
-- Joachim Wiberg <troglobit@gmail.com> Sat, 27 Mar 2021 09:12:32 +0100
|
||||
|
||||
libite (2.3.1) stable; urgency=medium
|
||||
|
||||
* Minor packaging fixes.
|
||||
* Copyright updates, including LICENSE file, year + author last name
|
||||
|
||||
-- Joachim Wiberg <troglobit@gmail.com> Fri, 12 Feb 2021 15:10:42 +0100
|
||||
|
||||
libite (2.3.0) stable; urgency=medium
|
||||
|
||||
* New functions:
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
Source: libite
|
||||
Priority: optional
|
||||
Maintainer: Joachim Nilsson <troglobit@gmail.com>
|
||||
Maintainer: Joachim Wiberg <troglobit@gmail.com>
|
||||
Build-Depends: debhelper (>= 10), libtool
|
||||
Standards-Version: 4.3.0
|
||||
Section: libs
|
||||
|
||||
Vendored
+44
-12
@@ -4,7 +4,7 @@ Source: https.//github.com/troglobit/libite/
|
||||
Files: *
|
||||
Copyright:
|
||||
2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
|
||||
2008-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: MIT
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,25 +25,49 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Files: chomp.c
|
||||
Copyright: 2014-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2014-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: conio.h
|
||||
Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Files: conio.?
|
||||
Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: dir.c
|
||||
Copyright: 2008-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: fopenf.c fremove.c systemf.c truncatef.c
|
||||
Copyright: 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: fparseln.c
|
||||
Copyright: 1997 Christos Zoulas
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: fsendfile.c
|
||||
Copyright: 2013 Tobias Waldekranz <tobias@waldekranz.com>
|
||||
License: MIT
|
||||
|
||||
Files: lfile.c
|
||||
Copyright: 2015-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2015-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: makepath.c
|
||||
Copyright: 2016-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: pidfile.c
|
||||
Copyright: 1999 The NetBSD Foundation, Inc.
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: pidfilefn.c
|
||||
Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: progress.c
|
||||
Copyright: 2012-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: queue.h
|
||||
Copyright: 1991, 1993 The Regents of the University of California.
|
||||
License: BSD-3-clause
|
||||
@@ -53,7 +77,7 @@ Copyright: 2008 Otto Moerbeek <otto@drijf.net>
|
||||
License: ISC
|
||||
|
||||
Files: rsync.c
|
||||
Copyright: 2011-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2011-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: strdupa.h strndupa.h
|
||||
@@ -64,12 +88,16 @@ Files: strlcat.c strlcpy.c
|
||||
Copyright: 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
License: MIT
|
||||
|
||||
Files: strlite.h
|
||||
Copyright: 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: MIT
|
||||
|
||||
Files: strmatch.c
|
||||
Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: strnlen.c
|
||||
Copyright: 2016-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2016-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: strtonum.c
|
||||
@@ -77,19 +105,23 @@ Copyright: 2004 Ted Unangst and Todd Miller
|
||||
License: ISC
|
||||
|
||||
Files: telnet.c
|
||||
Copyright: 2010-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2010-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: tempfile.c
|
||||
Copyright: 2015-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2015-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: tree.h
|
||||
Copyright: 2002 Niels Provos <provos@citi.umich.edu>
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: which.c
|
||||
Copyright: 2017-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: yorn.c
|
||||
Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
License: ISC
|
||||
|
||||
Files: tests/*.c
|
||||
|
||||
Vendored
+3
@@ -5,6 +5,7 @@ libite.so.5 libite5 #MINVER#
|
||||
chomp@Base 2.0.0
|
||||
copyfile@Base 2.0.0
|
||||
dir@Base 2.0.0
|
||||
erasef@Base 2.4.0
|
||||
fcopyfile@Base 2.0.0
|
||||
fexist@Base 2.0.0
|
||||
fgetint@Base 2.0.0
|
||||
@@ -38,12 +39,14 @@ libite.so.5 libite5 #MINVER#
|
||||
strmatch@Base 2.1.0
|
||||
strnmatch@Base 2.1.0
|
||||
strtonum@Base 2.1.0
|
||||
strtrim@Base 2.4.0
|
||||
systemf@Base 2.2.0
|
||||
telnet_close@Base 2.1.0
|
||||
telnet_expect@Base 2.1.0
|
||||
telnet_open@Base 2.1.0
|
||||
telnet_session@Base 2.1.0
|
||||
tempfile@Base 2.0.0
|
||||
touchf@Base 2.4.0
|
||||
truncatef@Base 2.3.0
|
||||
which@Base 2.0.0
|
||||
whichp@Base 2.0.0
|
||||
|
||||
+5
-5
@@ -2,19 +2,19 @@ lib_LTLIBRARIES = libite.la
|
||||
|
||||
libite_la_CPPFLAGS = -D_GNU_SOURCE
|
||||
libite_la_CFLAGS = -W -Wall -Wextra
|
||||
libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:0:2
|
||||
libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 8:0:3
|
||||
libite_la_SOURCES = chomp.c copyfile.c \
|
||||
conio.c conio.h \
|
||||
dir.c fopenf.c fremove.c \
|
||||
conio.c conio.h dir.c \
|
||||
erasef.c fopenf.c fremove.c \
|
||||
fexist.c fisdir.c \
|
||||
fparseln.c fsendfile.c \
|
||||
ifconfig.c lfile.c \
|
||||
makepath.c progress.c \
|
||||
pidfile.c pidfilefn.c \
|
||||
reallocarray.c rsync.c \
|
||||
reallocarray.c rsync.c strtrim.c \
|
||||
strlcpy.c strlcat.c strtonum.c \
|
||||
strdupa.h strndupa.h strnlen.h \
|
||||
strmatch.c systemf.c \
|
||||
strmatch.c systemf.c touchf.c \
|
||||
telnet.c tempfile.c truncatef.c \
|
||||
yorn.c which.c \
|
||||
lite.h strlite.h \
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Perl inspired chomp() implementation.
|
||||
*
|
||||
* Copyright (c) 2014-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2014-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* A conio.h like implementation for VTANSI displays.
|
||||
*
|
||||
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* A conio.h like implementation for VTANSI displays.
|
||||
*
|
||||
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Functions for operating on files in directories.
|
||||
*
|
||||
* Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Formatted erase()
|
||||
*
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lite.h"
|
||||
|
||||
/**
|
||||
* erasef - Like erase() but with formatted string support
|
||||
* @fmt: Formatted string to be composed into a pathname
|
||||
*
|
||||
* This is a wrapper for the erase() function in lite.h, lessening the
|
||||
* burden of having to compose the filename from parts in a seprate
|
||||
* buffer.
|
||||
*
|
||||
* Returns:
|
||||
* Upon successful completion erasef() returns POSIX OK(0), otherwise,
|
||||
* -1 is returned and errno is set to indicate the error.
|
||||
*/
|
||||
int erasef(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *file;
|
||||
int len;
|
||||
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(NULL, 0, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
file = alloca(len + 1);
|
||||
if (!file) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(file, len + 1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return erase(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Formatted fopen()
|
||||
*
|
||||
* Copyright (c) 2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Formatted fremove()
|
||||
*
|
||||
* Copyright (c) 2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/* Fastinit (finit) ifconfig() implementation.
|
||||
*
|
||||
* Copyright (c) 2008-2010 Claudio Matsuoka <http://helllabs.org/finit/>
|
||||
* Copyright (C) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (C) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Parse UNIX /etc configuration files like /etc/protocols and /etc/services
|
||||
*
|
||||
* Copyright (c) 2015-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2015-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+9
-4
@@ -1,7 +1,7 @@
|
||||
/* Collection of frog DNA
|
||||
*
|
||||
* Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
|
||||
* Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -60,6 +60,9 @@ typedef struct lfile lfile_t;
|
||||
typedef struct sdbuf sdbuf_t;
|
||||
|
||||
char *chomp (char *str);
|
||||
|
||||
int erasef (const char *fmt, ...);
|
||||
|
||||
char *fparseln (FILE *, size_t *, size_t *, const char[3], int);
|
||||
|
||||
int fexist (const char *file);
|
||||
@@ -107,6 +110,8 @@ int telnet_close (sdbuf_t *ctx);
|
||||
int telnet_expect (sdbuf_t *ctx, char *script[], FILE *output);
|
||||
int telnet_session (int addr, short port, char *script[], FILE *output);
|
||||
|
||||
int touchf (const char *fmt, ...);
|
||||
|
||||
int yorn (const char *fmt, ...);
|
||||
|
||||
char *which (const char *cmd);
|
||||
@@ -117,9 +122,9 @@ int whichp (const char *cmd);
|
||||
#include <sys/time.h> /* utimensat() on *BSD */
|
||||
static inline int touch(const char *path)
|
||||
{
|
||||
if (mknod((path), S_IFREG|0644, 0)) {
|
||||
if (errno == EEXIST)
|
||||
return utimensat(AT_FDCWD, path, NULL, 0);
|
||||
if (utimensat(AT_FDCWD, path, NULL, 0)) {
|
||||
if (errno == ENOENT)
|
||||
return mknod((path), S_IFREG|0644, 0);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* mkpath() -- Create all components leading up to a given directory
|
||||
*
|
||||
* Copyright (c) 2013-2016 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2013-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Functions for dealing with PID files (client side)
|
||||
*
|
||||
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Simple termios based progress bar
|
||||
*
|
||||
* Copyright (c) 2012-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2012-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Micro "rsync" implementation.
|
||||
*
|
||||
* Copyright (c) 2011-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2011-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
/* Collection of frog DNA
|
||||
*
|
||||
* Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -67,6 +67,8 @@ size_t strlcat (char *dst, const char *src, size_t siz);
|
||||
long long strtonum (const char *numstr, long long minval, long long maxval, const char **errstrp);
|
||||
#endif
|
||||
|
||||
char *strtrim (char *str);
|
||||
|
||||
/* Convert string to natural number (0-2147483647), returns -1 on error. */
|
||||
static inline int atonum(const char *str)
|
||||
{
|
||||
@@ -107,7 +109,7 @@ static inline int string_compare(const char *a, const char *b)
|
||||
*/
|
||||
static inline int string_case_compare(const char *a, const char *b)
|
||||
{
|
||||
return strlen (a) == strlen (b) && !strcasecmp (a, b);
|
||||
return strlen(a) == strlen(b) && !strcasecmp(a, b);
|
||||
}
|
||||
|
||||
#endif /* LITE_STRING_H_ */
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Simple string matcher function, finds partial matches.
|
||||
*
|
||||
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* strnlen.h - Re-implementation of GLIBC strnlen()
|
||||
*
|
||||
* Copyright (c) 2016-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2016-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/* Trim a string from whitespace
|
||||
*
|
||||
* Copyright (c) 2014 Mattias Walström <lazzer@gmail.com>
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lite.h"
|
||||
|
||||
/**
|
||||
* strtrim - Strip leading and trailing whitespace from a string
|
||||
* @str: The string to trim
|
||||
*
|
||||
* Trims a string from any leading and trailing white-space, returns the
|
||||
* trimmed result in the same buffer.
|
||||
*
|
||||
* Returns:
|
||||
* If @str is a valid, non-NULL, string this function returns the same
|
||||
* string stripped from whitespace. This function only returns %NULL
|
||||
* if @str itself is %NULL.
|
||||
*/
|
||||
char *strtrim(char *str)
|
||||
{
|
||||
char *start, *end;
|
||||
|
||||
if (!str) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
start = str;
|
||||
while (isspace(*start))
|
||||
start++;
|
||||
|
||||
if (*start == 0) {
|
||||
str[0] = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
end = start + strlen(start) - 1;
|
||||
while (end > start && isspace(*end))
|
||||
end--;
|
||||
*(++end) = 0;
|
||||
|
||||
memmove(str, start, end - start + 1);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+12
-19
@@ -1,6 +1,6 @@
|
||||
/* Formatted system() which returns actual return status of command
|
||||
*
|
||||
* Copyright (c) 2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -25,8 +25,8 @@ int systemf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *cmd;
|
||||
int len, status;
|
||||
int rc = -1;
|
||||
int len;
|
||||
int rc;
|
||||
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(NULL, 0, fmt, ap);
|
||||
@@ -42,23 +42,16 @@ int systemf(const char *fmt, ...)
|
||||
vsnprintf(cmd, len, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
status = system(cmd);
|
||||
rc = system(cmd);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
|
||||
rc = WEXITSTATUS(status);
|
||||
if (!WIFEXITED(status)) {
|
||||
if (WIFSIGNALED(status) &&
|
||||
(WTERMSIG(status) == SIGINT ||
|
||||
WTERMSIG(status) == SIGQUIT)) {
|
||||
errno = EINTR;
|
||||
rc = -1;
|
||||
} else if (!rc) {
|
||||
/*
|
||||
* Alert callee that command didn't complete
|
||||
* successfully. Some programs don't change
|
||||
* their exit code when signaled.
|
||||
*/
|
||||
rc = 1;
|
||||
}
|
||||
if (WIFEXITED(rc)) {
|
||||
errno = 0;
|
||||
rc = WEXITSTATUS(rc);
|
||||
} else if (WIFSIGNALED(rc)) {
|
||||
errno = EINTR;
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Poor mans telnet expect in C.
|
||||
*
|
||||
* Copyright (c) 2010-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2010-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* A secure tmpfile() replacement.
|
||||
*
|
||||
* Copyright (c) 2015-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2015-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Formatted touch()
|
||||
*
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lite.h"
|
||||
|
||||
/**
|
||||
* touchf - Like touch() but with formatted string support
|
||||
* @fmt: Formatted string to be composed into a pathname
|
||||
*
|
||||
* This is a wrapper for the touch() function in lite.h, lessening the
|
||||
* burden of having to compose the filename from parts in a seprate
|
||||
* buffer.
|
||||
*
|
||||
* Returns:
|
||||
* Upon successful completion touchf() returns POSIX OK(0), otherwise,
|
||||
* -1 is returned and errno is set to indicate the error.
|
||||
*/
|
||||
int touchf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *file;
|
||||
int len;
|
||||
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(NULL, 0, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
file = alloca(len + 1);
|
||||
if (!file) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(file, len + 1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return touch(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
*/
|
||||
+1
-2
@@ -1,6 +1,6 @@
|
||||
/* Formatted truncate()
|
||||
*
|
||||
* Copyright (c) 2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -30,7 +30,6 @@
|
||||
* of having to compose the filename from parts in a seprate buffer.
|
||||
*
|
||||
* Returns:
|
||||
|
||||
* Upon successful completion truncate() returns POSIX OK(0), otherwise,
|
||||
* -1 is returned and errno is set to indicate the error.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* C implementation of UNIX which(1)
|
||||
*
|
||||
* Copyright (c) 2017-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2017-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Safe yes-or-no with prompt
|
||||
*
|
||||
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
|
||||
* Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
||||
+8
-3
@@ -4,9 +4,10 @@
|
||||
int main(void)
|
||||
{
|
||||
struct { char *cmd; int rc; } list[] = {
|
||||
{ "/app/enoent", 127 },
|
||||
{ "false", 1 },
|
||||
{ "true", 0 },
|
||||
{ "kill -9 $$", 1 },
|
||||
{ "kill -9 $$", -1 },
|
||||
{ "kill -QUIT $$", -1 },
|
||||
{ "kill -INT $$", -1 }
|
||||
};
|
||||
@@ -15,8 +16,12 @@ int main(void)
|
||||
int rc;
|
||||
|
||||
rc = systemf("%s", list[i].cmd);
|
||||
if (rc != list[i].rc)
|
||||
err(rc, "Failed command %s", list[i].cmd);
|
||||
if (rc != list[i].rc) {
|
||||
if (rc == -1)
|
||||
err(rc, "Failed %s", list[i].cmd);
|
||||
else
|
||||
errx(rc, "Failed %s, rc %d vs %d", list[i].cmd, rc, list[i].rc);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+33
-2
@@ -1,3 +1,4 @@
|
||||
/* test of touch(), touchf(), erase(), and erasef() */
|
||||
#include <err.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
@@ -6,6 +7,8 @@
|
||||
|
||||
#include "check.h"
|
||||
|
||||
#define FMT "%s-bar"
|
||||
|
||||
int verbose = 0;
|
||||
|
||||
|
||||
@@ -32,10 +35,38 @@ static int mtime(char *file)
|
||||
ret = timespec_newer(&after.st_mtim, &before.st_mtim);
|
||||
PRINT("Before: %s\n", timespec2str(&before.st_mtim, buf, sizeof(buf)));
|
||||
PRINT("After : %s\n", timespec2str(&after.st_mtim, buf, sizeof(buf)));
|
||||
erase(file);
|
||||
|
||||
return !ret;
|
||||
}
|
||||
|
||||
static int formatted(char *file)
|
||||
{
|
||||
char vrfy[80];
|
||||
|
||||
if (touchf(FMT, file))
|
||||
err(1, "Failed creating " FMT, file);
|
||||
|
||||
PRINT("Created " FMT "\n", file);
|
||||
|
||||
snprintf(vrfy, sizeof(vrfy), FMT, file);
|
||||
if (!fexist(vrfy))
|
||||
errx(1, "touchf() does not detect failure to create file " FMT, file);
|
||||
|
||||
PRINT("File " FMT " really does exist!\n", file);
|
||||
|
||||
erasef(FMT, file);
|
||||
if (fexist(vrfy)) {
|
||||
int saved = errno;
|
||||
|
||||
erase(vrfy);
|
||||
errno = saved;
|
||||
errx(1, "erasef() failed removing the created file " FMT, file);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
@@ -49,13 +80,13 @@ int main(int argc, char *argv[])
|
||||
err(1, "Failed creating tempfile, %s", file);
|
||||
close(fd);
|
||||
|
||||
return mtime(file);
|
||||
return mtime(file) || formatted(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* compile-command: "make pidfile && ./pidfile -v"
|
||||
* compile-command: "make touch && ./touch -v"
|
||||
* End:
|
||||
*/
|
||||
Reference in new issue
Block a user