Compare commits

..
32 Commits
Author SHA1 Message Date
Joachim Nilsson ef04307b4a debian: Update symbols file, new APIs introduced in v2.2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:41:44 +01:00
Joachim Nilsson 5d035d955e debian: Add missing libtool to Build-Depends
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:38:25 +01:00
Joachim Nilsson b65175782d Bump ABI version, new APIs added
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:38:25 +01:00
Joachim Nilsson c27a8e7ec6 Update changelogs and bump version for v2.2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 16:01:46 +01:00
Joachim Nilsson d231c1e1eb Revert "Travis-CI: Disable clang temporarily for Coverity Scan run"
This reverts commit 2a6adeebcd.
2020-03-16 10:41:27 +01:00
Joachim Nilsson 247fb67274 Add Coverity Scan badge
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:37:21 +01:00
Joachim Nilsson c716cc5835 copyfile(): Check return value of fstat(), prevent faulty futimens()
Found by Coverity Scan

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:50 +01:00
Joachim Nilsson e81ce85867 rsync(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:50 +01:00
Joachim Nilsson 549f325c21 rsync(): Fix variable shadowing, found by clang-tidy
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:46 +01:00
Joachim Nilsson 2a6adeebcd Travis-CI: Disable clang temporarily for Coverity Scan run
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:56:23 +01:00
Joachim Nilsson cb2beacf2c Travis-CI: Add support for Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:55:27 +01:00
Joachim Nilsson 256b6ba038 Add origin section to README, better place for history or project
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:48:55 +01:00
Joachim Nilsson 61d9b5fac7 Update Changelog for upcoming v2.2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:43:48 +01:00
Joachim Nilsson 38ad841389 Bump version for v2.2.0 release cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:39:17 +01:00
Joachim Nilsson f1a1a21569 Add support for systemf(), formatted system() replacement
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:32:52 +01:00
Joachim Nilsson 7f3f4df9e9 Add support for fmkpath(), formatted string mkpath()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-11 20:03:03 +01:00
Joachim Nilsson 02a42a1cad Add support for fopenf(), formatted string fopen()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-10 09:07:56 +01:00
Joachim Nilsson 28c11f010a Check for existence of AM_PROG_AR macro
This patch facilitates building newer versions of libite on systems with
older versions of autoconf and automake.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 15:47:28 +01:00
Joachim Nilsson 20d8d40285 Update changelogs and bump version for v2.1.2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 15:06:28 +01:00
Joachim Nilsson 4dc24f37e3 debian: Fix breakage when upgrading libite -> libite5
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 15:05:56 +01:00
Joachim Nilsson 11f8846f63 Update changelogs and bump version for v2.1.1 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson 41778fb3ce debian: Add missing symbols file, pointed out by lintian
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson 59d1f0d60c Update .gitignore files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson afc4289326 debian: Fix lintian warning for package short description
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson 67267659f7 configure: Put auxilliary files in aux and check for install
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson 188509d811 debian: Update changelog for 2.1.1 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson c10cd67266 Update release hook and fix formatting in release target
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 13:57:39 +01:00
Joachim Nilsson 82db75cac6 debian: Update to Standards-Version 4.3.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 12:46:14 +01:00
Joachim Nilsson 51970ff86e Update copyright years
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 11:32:43 +01:00
Joachim Nilsson d6fa3cde96 Update ChangeLog for v2.1.1 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 11:17:14 +01:00
Joachim Nilsson 9d50de3ec7 tests: Add example of how to use printhdr()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 11:14:27 +01:00
Joachim Nilsson 2aed5a6b3f chomp: Check for beginning of string while removing \n's
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-09-25 08:51:56 +02:00
41 changed files with 557 additions and 111 deletions

No files matched your search

+2 -10
View File
@@ -1,16 +1,8 @@
*~ *~
*.d
*.o
*.so
*.so.*
*.a
.deps
.libs
ID ID
GPATH GPATH
GRTAGS GRTAGS
GTAGS GTAGS
tmp/
compile compile
config.* config.*
configure configure
@@ -25,5 +17,5 @@ Makefile.in
aclocal.m4 aclocal.m4
ar-lib ar-lib
autom4te.cache autom4te.cache
libite* test-driver
test-driver libite.pc
+19
View File
@@ -10,6 +10,25 @@ compiler:
- gcc - gcc
- clang - clang
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "EcWeDUONZnl7IHBWD2rc92LwTWGIlqBZ7wQrLfe3mFXOnB+IZjJIBnDsJDnHDWwA8fGF9NaJbRz4BThroafueUwkDXNyvph1Mdaxm6mdMPyjNJ4H1AFkd9Fz0LYdLNXCPl43tm6s1BR6OWts17lWF6sMnMmIu8gUgXJVg2qsDBl3O9eCoRvQ/h4elLfXZ03fHi4XzzzQvZVyDCg8MCzXIgHJzdkv4llpiCLWQExFbIAVy39euDnx+UuWYB7WDdUbOc7HkkUwf0/vX9PhKVQFKOkXn1ddN0iCsWRH3ti5KXWrBeRO3RPu6Z5YtR8l1WK7iqCYOLuMBW23tXsBQsIW09f1+fFgJ8Ig5hHRRbDinbTUb+mHUJZmNv9ZTc3hPYH4Fyev/ljk42VVDdIBy9AqO42jj8VGmDmiIq47aqNJZUGYZgQlGXGqk9MtavJrqEVcFSgyfEtI+c4n4fzvMRpcEwjnbp482s1xNzHQZ1GQI77Td5UUXXWyNSCoQoE/VpkAesYJAw8KwXOXveDr3Qu0HhuQu1oyLmWHlZHYDu+TInjY81gpGw9Cm7/SdFoA0Ag49PlAXdPRymbP01B50MqrCTxtXEHtdXxhrkDvaoUp7heSuvO0fS+mI5F7eQ4Ji2JdyRSt1KpXVNAyL1FrO/yznM3EwcXPmWmrc+QjFtC9vY4="
before_install:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
addons:
coverity_scan:
project:
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: "make clean all"
branch_pattern: dev
script: script:
- ./autogen.sh - ./autogen.sh
- ./configure --prefix=/tmp --disable-silent-rules - ./configure --prefix=/tmp --disable-silent-rules
+37 -1
View File
@@ -3,6 +3,39 @@ Change Log
All notable changes to the project are documented in this file. All notable changes to the project are documented in this file.
[v2.2.0][] - 2020-03-16
-----------------------
### Changes
- Add support for `systemf()`, formatted string `system()` replacement
- Add support for `fmkpath()`, formatted string `mkpath()`
- Add support for `fopenf()`, formatted string `fopen()` replacement
### Fixes
- Fix possible memory leak in `rsync()`, found by Coverity Scan
- Check return value of `fstat()` to prevent bogus destination file
times when using `copyfile()`, found by Coverity Scan
[v2.1.2][] - 2020-02-22
-----------------------
### Fixes
- Fix Debian package upgrade from libite -> libite5
[v2.1.1][] - 2020-02-22
-----------------------
### Changes
- Add test/example for `printhdr()`
- Update copyright years
### Fixes
- chomp: Check for beginning of string while removing \n's
[v2.1.0][] - 2019-08-26 [v2.1.0][] - 2019-08-26
----------------------- -----------------------
@@ -339,7 +372,10 @@ problems this may cause!
Initial extraction of frog DNA from [Finit][]. See [README][] for API details. Initial extraction of frog DNA from [Finit][]. See [README][] for API details.
[UNRELEASED]: https://github.com/troglobit/libite/compare/v2.1.0...HEAD [UNRELEASED]: https://github.com/troglobit/libite/compare/v2.2.0...HEAD
[v2.2.0]: https://github.com/troglobit/libite/compare/v2.1.2...v2.2.0
[v2.1.2]: https://github.com/troglobit/libite/compare/v2.1.1...v2.1.2
[v2.1.1]: https://github.com/troglobit/libite/compare/v2.1.0...v2.1.1
[v2.1.0]: https://github.com/troglobit/libite/compare/v2.0.2...v2.1.0 [v2.1.0]: https://github.com/troglobit/libite/compare/v2.0.2...v2.1.0
[v2.0.2]: https://github.com/troglobit/libite/compare/v2.0.1...v2.0.2 [v2.0.2]: https://github.com/troglobit/libite/compare/v2.0.1...v2.0.2
[v2.0.1]: https://github.com/troglobit/libite/compare/v2.0.0...v2.0.1 [v2.0.1]: https://github.com/troglobit/libite/compare/v2.0.0...v2.0.1
+1 -6
View File
@@ -1,10 +1,5 @@
Much of the code in libite (-lite) is written by Claudio Matsuoka for Finit
and released under the MIT/X11 license. Joachim Nilsson 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.
Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
Copyright (c) 2008-2016 Joachim Nilsson <troglobit@gmail.com> Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+31 -25
View File
@@ -6,39 +6,45 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libite.pc pkgconfig_DATA = libite.pc
SUBDIRS = src tests SUBDIRS = src tests
## Generate .deb package
package:
@dpkg-buildpackage -uc -us -B
## Generate MD5 checksum file ## Generate MD5 checksum file
MD5 = md5sum MD5 = md5sum
md5-dist: md5-dist:
@for file in $(DIST_ARCHIVES); do \ @for file in $(DIST_ARCHIVES); do \
$(MD5) $$file > $$file.md5; \ $(MD5) $$file > ../$$file.md5; \
done done
## Check if tagged in git ## Check if tagged in git
release-hook: release-hook:
if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \ @if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \
echo; \ echo; \
printf "\033[1m\033[41mCannot find release tag $(PACKAGE_VERSION)\033[0m\n"; \ printf "\e[1m\e[41mCannot find release tag $(PACKAGE_VERSION)\e[0m\n"; \
printf "\033[1m\033[5mDo release anyway?\033[0m "; read yorn; \ printf "\e[1m\e[5mDo release anyway?\e[0m "; read yorn; \
if [ "$$yorn" != "y" -a "$$yorn" != "Y" ]; then \ if [ "$$yorn" != "y" -a "$$yorn" != "Y" ]; then \
printf "OK, aborting release.\n"; \ printf "OK, aborting release.\n"; \
exit 1; \ exit 1; \
fi; \ fi; \
echo; \ echo; \
else \ else \
echo; \ echo; \
printf "\033[1m\033[42mFound GIT release tag $(PACKAGE_VERSION)\033[0m\n"; \ printf "\e[1m\e[42mFound GIT release tag $(PACKAGE_VERSION)\e[0m\n"; \
printf "\033[1m\033[44m>>Remember to push tags!\033[0m\n"; \ printf "\e[1m\e[44m>>Remember to push tags!\e[0m\n"; \
echo; \ echo; \
fi fi
# lintian --profile debian -i -I --show-overrides ../$PKG.changes
package build-deb:
@dpkg-buildpackage -uc -us -B
## Target to run when building a release ## Target to run when building a release
release: distcheck release-hook md5-dist release: release-hook distcheck package md5-dist
@for file in $(DIST_ARCHIVES); do \ @mv $(DIST_ARCHIVES) ../
printf "$$file \tDistribution tarball\n"; \ @echo
printf "$$file.md5\t"; cat $$file.md5 | cut -f1 -d' '; \ @echo "Resulting release files:"
mv $$file* ../; \ @echo "================================================================="
@for file in $(DIST_ARCHIVES); do \
printf "%-32s Distribution tarball\n" $$file; \
printf "%-32s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \
done
@for file in `cd ..; ls $(PACKAGE)*_$(VERSION)*`; do \
printf "%-32s Debian/Ubuntu package\n" $$file; \
done done
+36 -3
View File
@@ -1,7 +1,6 @@
-lite | Frog DNA, basically -lite | Frog DNA, basically
=========================== ===========================
[![Travis Status][]][Travis] [![Travis Status][]][Travis] [![Coverity Status]][Coverity Scan]
Table of Contents Table of Contents
----------------- -----------------
@@ -12,7 +11,7 @@ Table of Contents
* [Generic Functions](#generic-functions) * [Generic Functions](#generic-functions)
* [OpenBSD Functions](#openbsd-functions) * [OpenBSD Functions](#openbsd-functions)
* [Build & Install](#origin--references) * [Build & Install](#origin--references)
* [TODO](#todo) * [Origin & References](#origin--references)
> **NOTE:** Incompatible changes in v2.0 compared to v1.x! > **NOTE:** Incompatible changes in v2.0 compared to v1.x!
@@ -181,6 +180,15 @@ Generic Functions
Check for the existence of a directory, returns True(1) or False(0). Check for the existence of a directory, returns True(1) or False(0).
- `fopenf(mode, fmt, ...)`
Like `fopen()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
filename from parts into a dynamic buffer before actually opening
the file.
> **Notice:** the swapped order of `pathname` and `mode`!
- `fsendfile(src, dst, len)` - `fsendfile(src, dst, len)`
Copy data between file streams, very similar to `fcopyfile()`, but Copy data between file streams, very similar to `fcopyfile()`, but
@@ -223,6 +231,12 @@ Generic Functions
Like `makepath()`, but also takes a `mode_t` permission mode argument. Like `makepath()`, but also takes a `mode_t` permission mode argument.
- `fmkpath(mode, fmt, ...)`
Like `mkpath()`, but takes a formatted string as argument.
> **Notice:** the swapped order of `pathname` and `mode`!
- `movefile(src, dst)` - `movefile(src, dst)`
Like `copyfile()`, but renames `src` to `dst`, or recreates symlink Like `copyfile()`, but renames `src` to `dst`, or recreates symlink
@@ -289,6 +303,12 @@ Generic Functions
Find matching string in an array of strings. Returns index in array Find matching string in an array of strings. Returns index in array
on match, or `-1` on error or not found. on match, or `-1` on error or not found.
`systemf(fmt, ...)`
Like `system()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
command from parts into a dynamic buffer before calling it.
- `telnet_open(), telnet_close(), telnet_expect()` - `telnet_open(), telnet_close(), telnet_expect()`
Poor mans telnet expect in C. Opens connection to a Telnet service; Poor mans telnet expect in C. Opens connection to a Telnet service;
@@ -407,6 +427,14 @@ as a light weight utility library, these days NetBSD should also work.
to generate a `configure` script. It is a generated file and otherwise to generate a `configure` script. It is a generated file and otherwise
only included in released tarballs. 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
pieces of software released under the ISC and BSD licenses. See each
respective file for license details.
[1]: https://github.com/troglobit/finit [1]: https://github.com/troglobit/finit
[2]: http://www.openbsd.org/ [2]: http://www.openbsd.org/
@@ -419,3 +447,8 @@ only included in released tarballs.
[BSD]: https://en.wikipedia.org/wiki/BSD_licenses [BSD]: https://en.wikipedia.org/wiki/BSD_licenses
[Travis]: https://travis-ci.org/troglobit/libite [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.png?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
[original finit]: http://helllabs.org/finit/
[Finit]: https://github.com/troglobit/finit
+4 -2
View File
@@ -1,4 +1,5 @@
AC_INIT(libite, 2.1.0, https://github.com/troglobit/libite/issues) AC_INIT(libite, 2.2.0, https://github.com/troglobit/libite/issues)
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz]) AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
@@ -8,7 +9,8 @@ AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile libite.pc])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC AC_PROG_CC
AM_PROG_AR AC_PROG_INSTALL
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT LT_INIT
AC_OUTPUT AC_OUTPUT
+5 -2
View File
@@ -1,6 +1,9 @@
*.log
*.substvars
.debhelper/*
tmp/* tmp/*
libuev/* libite5/*
libuev* libite-dev/*
autoreconf* autoreconf*
debhelper* debhelper*
files files
+30
View File
@@ -1,3 +1,33 @@
libite (2.2.0) unstable; urgency=medium
* New functions:
- systemf(), formatted string system() replacement
- fmkpath(), formatted string mkpath() replacement
- fopenf(), formatted string fopen() replacement
* Fixes
- possible memory leak in rsync()
- Check return value of fstat() to prevent bogus destination file
times when using copyfile()
-- Joachim Nilsson <troglobit@gmail.com> Mon, 16 Mar 2020 15:42:02 +0100
libite (2.1.2) stable; urgency=high
* Fix upgrade of base package, new library name to match SONAME
breaks upgrade from libite_2.0.x.deb to libite5_2.1.x.deb
-- Joachim Nilsson <troglobit@gmail.com> Sat, 22 Feb 2020 15:04:27 +0100
libite (2.1.1) stable; urgency=medium
* Fix to chomp(), ensure stopping before beginning of string
* Added example of printhdr()
* Update copyright years
* Add missing libite5.symbols file, found by lintian
* Fix package short description, found by linitian
-- Joachim Nilsson <troglobit@gmail.com> Sat, 22 Feb 2020 13:52:24 +0100
libite (2.1.0) unstable; urgency=medium libite (2.1.0) unstable; urgency=medium
* New functions; strmatch(), strnmatch(), yorn(), telnet expect APIs * New functions; strmatch(), strnmatch(), yorn(), telnet expect APIs
+11 -8
View File
@@ -1,8 +1,8 @@
Source: libite Source: libite
Priority: optional Priority: optional
Maintainer: Joachim Nilsson <troglobit@gmail.com> Maintainer: Joachim Nilsson <troglobit@gmail.com>
Build-Depends: dpkg-dev (>= 1.14.9), debhelper (>= 10) Build-Depends: debhelper (>= 10), libtool
Standards-Version: 4.1.0 Standards-Version: 4.3.0
Section: libs Section: libs
Homepage: https://github.com/troglobit/libite/ Homepage: https://github.com/troglobit/libite/
Vcs-Git: https://github.com/troglobit/libite.git Vcs-Git: https://github.com/troglobit/libite.git
@@ -16,14 +16,14 @@ Depends: ${misc:Depends}, libite5 (= ${binary:Version})
Description: static library, header files, and docs for libite Description: static library, header files, and docs for libite
Static library, header files, and documentation for libite. Static library, header files, and documentation for libite.
. .
Libite is a lightweight library of frog DNA. It can be used to fill the Libite is a lightweight library of frog DNA. It can be used to fill
gaps in any dinosaur project. It holds useful functions and macros the gaps in any dinosaur project. It holds useful functions and macros
developed by both Finit and the OpenBSD project. Most notably the developed by both Finit and the OpenBSD project. Most notably the
string functions: strlcpy(3), strlcat(3) and the highly useful *BSD string functions: strlcpy(3), strlcat(3) and the highly useful *BSD
sys/queue.h and sys/tree.h API's. sys/queue.h and sys/tree.h API's.
. .
Libite is the frog DNA missing in GNU libc. However, -lite does not aim Libite is the frog DNA missing in GNU libc. However, -lite does not
to become another GLIB! One noticeable gap in GLIBC is the missing aim to become another GLIB! One noticeable gap in GLIBC is the missing
_SAFE macros in the BSD sys/queue.h API — highly recommended when _SAFE macros in the BSD sys/queue.h API — highly recommended when
traversing lists to delete/free nodes. traversing lists to delete/free nodes.
. .
@@ -32,9 +32,12 @@ Description: static library, header files, and docs for libite
liberal and can be used freely in proprietary software if needed. liberal and can be used freely in proprietary software if needed.
Package: libite5 Package: libite5
Replaces: libite
Conflicts: libite
Provides: libite
Architecture: any Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends} Depends: ${misc:Depends}, ${shlibs:Depends}
Description: That missing frog DNA you've been looking for. Description: That missing frog DNA you've been looking for
Libite, or -lite, is a lightweight library of frog DNA. It can be used Libite, or -lite, is a lightweight library of frog DNA. It can be used
to fill the gaps in any dinosaur project. It holds useful functions to fill the gaps in any dinosaur project. It holds useful functions
and macros developed by both Finit and the OpenBSD project. Most and macros developed by both Finit and the OpenBSD project. Most
+14 -14
View File
@@ -4,7 +4,7 @@ Source: https.//github.com/troglobit/libite/
Files: * Files: *
Copyright: Copyright:
2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
2008-2016 Joachim Nilsson <troglobit@gmail.com> 2008-2020 Joachim Nilsson <troglobit@gmail.com>
License: MIT License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -25,19 +25,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
Files: chomp.c Files: chomp.c
Copyright: 2014-2015 Joachim Nilsson <troglobit@gmail.com> Copyright: 2014-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: conio.h Files: conio.h
Copyright: 2009-2013 Joachim Nilsson <troglobit@gmail.com> Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: dir.c Files: dir.c
Copyright: 2008-2016 Joachim Nilsson <troglobit@gmail.com> Copyright: 2008-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: lfile.c Files: lfile.c
Copyright: 2015-2016 Joachim Nilsson <troglobit@gmail.com> Copyright: 2015-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: pidfile.c Files: pidfile.c
@@ -53,7 +53,7 @@ Copyright: 2008 Otto Moerbeek <otto@drijf.net>
License: ISC License: ISC
Files: rsync.c Files: rsync.c
Copyright: 2011, 2012 Joachim Nilsson <troglobit@gmail.com> Copyright: 2011-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: strdupa.h strndupa.h Files: strdupa.h strndupa.h
@@ -65,11 +65,11 @@ Copyright: 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
License: MIT License: MIT
Files: strmatch.c Files: strmatch.c
Copyright: 2009-2018 Joachim Nilsson <troglobit@gmail.com> Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: strnlen.c Files: strnlen.c
Copyright: 2016 Joachim Nilsson <troglobit@gmail.com> Copyright: 2016-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: strtonum.c Files: strtonum.c
@@ -77,19 +77,19 @@ Copyright: 2004 Ted Unangst and Todd Miller
License: ISC License: ISC
Files: telnet.c Files: telnet.c
Copyright: 2010, 2013, 2019 Joachim Nilsson <troglobit@gmail.com> Copyright: 2010-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: tempfile.c Files: tempfile.c
Copyright: 2015-2016 Joachim Nilsson <troglobit@gmail.com> Copyright: 2015-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: tree.c Files: tree.h
Copyright: 2015 Joachim Nilsson <troglobit@gmail.com> Copyright: 2002 Niels Provos <provos@citi.umich.edu>
License: ISC License: BSD-2-clause
Files: yorn.c Files: yorn.c
Copyright: 2009 Joachim Nilsson <troglobit@gmail.com> Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com>
License: ISC License: ISC
Files: tests/*.c Files: tests/*.c
+48
View File
@@ -0,0 +1,48 @@
libite.so.5 libite5 #MINVER#
* Build-Depends-Package: libite-dev
__pidfile_name@Base 2.0.0
__pidfile_path@Base 2.0.0
chomp@Base 2.0.0
copyfile@Base 2.0.0
dir@Base 2.0.0
fcopyfile@Base 2.0.0
fexist@Base 2.0.0
fgetint@Base 2.0.0
fisdir@Base 2.0.0
fmkpath@Base 2.2.0
fopenf@Base 2.2.0
fparseln@Base 2.0.0
fsendfile@Base 2.0.0
ifconfig@Base 2.0.0
initscr@Base 2.0.0
lfclose@Base 2.0.0
lfgetint@Base 2.0.0
lfgetkey@Base 2.0.0
lfopen@Base 2.0.0
lftok@Base 2.0.0
makepath@Base 2.0.0
mkpath@Base 2.0.0
movefile@Base 2.0.0
pidfile@Base 2.0.0
pidfile_poll@Base 2.0.0
pidfile_read@Base 2.0.0
pidfile_signal@Base 2.1.0
progress@Base 2.0.0
progress_simple@Base 2.0.0
reallocarray@Base 2.0.0
rsync@Base 2.0.0
sdbuf@Base 2.0.0
strlcat@Base 2.0.0
strlcpy@Base 2.0.0
strmatch@Base 2.1.0
strnmatch@Base 2.1.0
strtonum@Base 2.1.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
which@Base 2.0.0
whichp@Base 2.0.0
yorn@Base 2.1.0
+3
View File
@@ -0,0 +1,3 @@
*.la
.libs/*
libite_la*
+4 -3
View File
@@ -2,10 +2,10 @@ lib_LTLIBRARIES = libite.la
libite_la_CPPFLAGS = -D_GNU_SOURCE libite_la_CPPFLAGS = -D_GNU_SOURCE
libite_la_CFLAGS = -W -Wall -Wextra libite_la_CFLAGS = -W -Wall -Wextra
libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 5:1:0 libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 6:0:1
libite_la_SOURCES = chomp.c copyfile.c \ libite_la_SOURCES = chomp.c copyfile.c \
conio.c conio.h \ conio.c conio.h \
dir.c \ dir.c fopenf.c \
fexist.c fisdir.c \ fexist.c fisdir.c \
fparseln.c fsendfile.c \ fparseln.c fsendfile.c \
ifconfig.c lfile.c \ ifconfig.c lfile.c \
@@ -14,7 +14,8 @@ libite_la_SOURCES = chomp.c copyfile.c \
reallocarray.c rsync.c \ reallocarray.c rsync.c \
strlcpy.c strlcat.c strtonum.c \ strlcpy.c strlcat.c strtonum.c \
strdupa.h strndupa.h strnlen.h \ strdupa.h strndupa.h strnlen.h \
strmatch.c telnet.c tempfile.c \ strmatch.c systemf.c \
telnet.c tempfile.c \
yorn.c which.c \ yorn.c which.c \
lite.h strlite.h \ lite.h strlite.h \
queue.h tree.h queue.h tree.h
+3 -3
View File
@@ -1,6 +1,6 @@
/* Perl inspired chomp() implementation. /* Perl inspired chomp() implementation.
* *
* Copyright (c) 2014-2015 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2014-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -23,7 +23,7 @@
* @str: String to chomp * @str: String to chomp
* *
* This function is like Perl chomp, but it's set to chop of all * This function is like Perl chomp, but it's set to chop of all
* trailing newlines. * trailing newlines. Useful in combination with fgets().
* *
* Returns: * Returns:
* If @str is a valid pointer this function returns @str, otherwise * If @str is a valid pointer this function returns @str, otherwise
@@ -39,7 +39,7 @@ char *chomp(char *str)
} }
p = str + strlen(str) - 1; p = str + strlen(str) - 1;
while (*p == '\n') while (p >= str && *p == '\n')
*p-- = 0; *p-- = 0;
return str; return str;
+1 -1
View File
@@ -1,6 +1,6 @@
/* A conio.h like implementation for VTANSI displays. /* A conio.h like implementation for VTANSI displays.
* *
* Copyright (c) 2009-2017 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* A conio.h like implementation for VTANSI displays. /* A conio.h like implementation for VTANSI displays.
* *
* Copyright (c) 2009-2017 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+3 -1
View File
@@ -85,7 +85,9 @@ static void set_mtime(int in, int out)
struct stat st; struct stat st;
struct timespec tv[2]; struct timespec tv[2];
fstat(in, &st); if (fstat(in, &st))
return;
tv[0] = st.st_atim; tv[0] = st.st_atim;
tv[1] = st.st_mtim; tv[1] = st.st_mtim;
futimens(out, tv); futimens(out, tv);
+1 -1
View File
@@ -1,6 +1,6 @@
/* Functions for operating on files in directories. /* Functions for operating on files in directories.
* *
* Copyright (c) 2008-2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+61
View File
@@ -0,0 +1,61 @@
/* Formatted fopen()
*
* Copyright (c) 2020 Joachim Nilsson <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 <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
/**
* fopenf - Open a file based on the formatted string and optional arguments
* @mode: Last argument in optional list, if omitted EINVAL
* @fmt: Formatted string to be composed into a pathname
*
* This function is an extension to the fopen() family, lessening the burden
* of first having to compose the filename from parts in a seprate buffer.
*
* Returns:
* Upon successful completion fopenf() a FILE pointer. Otherwise, NULL
* is returned and errno is set to indicate the error.
*/
FILE *fopenf(const char *mode, const char *fmt, ...)
{
va_list ap;
FILE *fp = NULL;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
va_start(ap, fmt);
file = alloca(len + 1);
if (file) {
vsnprintf(file, len + 1, fmt, ap);
fp = fopen(file, mode);
}
va_end(ap);
return fp;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+2 -2
View File
@@ -1,7 +1,7 @@
/* Fastinit (finit) ifconfig() implementation. /* Fastinit (finit) ifconfig() implementation.
* *
* Copyright (c) 2008 Claudio Matsuoka <http://helllabs.org/finit/> * Copyright (c) 2008-2010 Claudio Matsuoka <http://helllabs.org/finit/>
* Copyright (C) 2009-2014 Joachim Nilsson <joachim.nilsson@westermo.se> * Copyright (C) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,6 +1,6 @@
/* Parse UNIX /etc configuration files like /etc/protocols and /etc/services /* Parse UNIX /etc configuration files like /etc/protocols and /etc/services
* *
* Copyright (c) 2015-2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2015-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+5 -1
View File
@@ -1,7 +1,7 @@
/* Collection of frog DNA /* Collection of frog DNA
* *
* Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> * Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
* Copyright (c) 2008-2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -65,6 +65,7 @@ char *fparseln (FILE *, size_t *, size_t *, const char[3], int);
int fexist (const char *file); int fexist (const char *file);
int fisdir (const char *path); int fisdir (const char *path);
FILE *fopenf (const char *mode, const char *fmt, ...);
FILE *tempfile (void); FILE *tempfile (void);
ssize_t copyfile (const char *src, const char *dst, int len, int opt); ssize_t copyfile (const char *src, const char *dst, int len, int opt);
int movefile (const char *src, const char *dst); int movefile (const char *src, const char *dst);
@@ -80,6 +81,7 @@ char *lfgetkey (lfile_t *lf, const char *key);
int lfgetint (lfile_t *lf, const char *key); int lfgetint (lfile_t *lf, const char *key);
int fgetint (const char *file, const char *sep, const char *key); int fgetint (const char *file, const char *sep, const char *key);
int fmkpath (mode_t mode, const char *fmt, ...);
int mkpath (const char *dir, mode_t mode); int mkpath (const char *dir, mode_t mode);
int makepath (const char *dir); int makepath (const char *dir);
@@ -96,6 +98,8 @@ void *reallocarray(void *optr, size_t nmemb, size_t size);
void progress (int percent, int max_width); void progress (int percent, int max_width);
void progress_simple(int percent); void progress_simple(int percent);
int systemf (const char *fmt, ...);
sdbuf_t*telnet_open (int addr, short port); sdbuf_t*telnet_open (int addr, short port);
int telnet_close (sdbuf_t *ctx); int telnet_close (sdbuf_t *ctx);
int telnet_expect (sdbuf_t *ctx, char *script[], FILE *output); int telnet_expect (sdbuf_t *ctx, char *script[], FILE *output);
+34
View File
@@ -17,6 +17,8 @@
#include <errno.h> #include <errno.h>
#include <libgen.h> #include <libgen.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include "lite.h" #include "lite.h"
@@ -46,6 +48,38 @@ int mkpath(const char *dir, mode_t mode)
return mkdir(dir, mode); return mkdir(dir, mode);
} }
/**
* fmkpath - Formatted version of mkpath()
* @mode: A &mode_t mode to create directories with
* @fmt: Formatted string to be composed into a pathname
*
* Note:
* Notice the swapped arguments, compared to mkpath()!
*
* Returns:
* POSIX OK(0) on success, otherwise -1 with @errno set.
*/
int fmkpath(mode_t mode, const char *fmt, ...)
{
va_list ap;
char *path;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
path = alloca(len + 1);
if (!path)
return -1;
va_start(ap, fmt);
len = vsnprintf(path, len + 1, fmt, ap);
va_end(ap);
return mkpath(path, mode);
}
/** /**
* makepath - Create all components of the specified directory. * makepath - Create all components of the specified directory.
* @dir: Directory to create. * @dir: Directory to create.
+1 -1
View File
@@ -1,6 +1,6 @@
/* Functions for dealing with PID files (client side) /* Functions for dealing with PID files (client side)
* *
* Copyright (c) 2009-2015 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* Simple termios based progress bar /* Simple termios based progress bar
* *
* Copyright (c) 2012-2015 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2012-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+8 -6
View File
@@ -1,6 +1,6 @@
/* Micro "rsync" implementation. /* Micro "rsync" implementation.
* *
* Copyright (c) 2011, 2012 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2011-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -107,20 +107,22 @@ int rsync(char *src, char *dst, int opt, int (*filter)(const char *file))
snprintf(source, sizeof(source), "%s%s%s", src, fisslashdir(src) ? "" : "/", files[i]); snprintf(source, sizeof(source), "%s%s%s", src, fisslashdir(src) ? "" : "/", files[i]);
if (fisdir(source)) { if (fisdir(source)) {
char dst2[256]; char dst2[256];
struct stat st; struct stat sb;
strcat(source, "/"); strcat(source, "/");
if (stat(source, &st)) if (stat(source, &sb)) {
return 1; result++;
continue;
}
if (mdir(dst2, sizeof(dst2), dst, files[i], &st)) { if (mdir(dst2, sizeof(dst2), dst, files[i], &sb)) {
result++; result++;
continue; continue;
} }
rsync(source, dst2, opt, filter); rsync(source, dst2, opt, filter);
if (keep_mtim) if (keep_mtim)
set_mtime(dst2, &st); set_mtime(dst2, &sb);
continue; /* Next file/dir in @src to copy... */ continue; /* Next file/dir in @src to copy... */
} }
+1 -1
View File
@@ -1,6 +1,6 @@
/* Collection of frog DNA /* Collection of frog DNA
* *
* Copyright (c) 2008-2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,6 +1,6 @@
/* Simple string matcher function, finds partial matches. /* Simple string matcher function, finds partial matches.
* *
* Copyright (c) 2009-2018 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* strnlen.h - Re-implementation of GLIBC strnlen() /* strnlen.h - Re-implementation of GLIBC strnlen()
* *
* Copyright (c) 2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2016-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+73
View File
@@ -0,0 +1,73 @@
/* Formatted system() which returns actual return status of command
*
* Copyright (c) 2020 Joachim Nilsson <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 <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
int systemf(const char *fmt, ...)
{
va_list ap;
char *cmd;
int len, status;
int rc = -1;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
va_start(ap, fmt);
cmd = alloca(++len);
if (!cmd) {
va_end(ap);
errno = ENOMEM;
return -1;
}
vsnprintf(cmd, len, fmt, ap);
va_end(ap);
status = system(cmd);
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;
}
}
return rc;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+1 -1
View File
@@ -1,6 +1,6 @@
/* Poor mans telnet expect in C. /* Poor mans telnet expect in C.
* *
* Copyright (c) 2010, 2013, 2019 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2010-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* A secure tmpfile() replacement. /* A secure tmpfile() replacement.
* *
* Copyright (c) 2015-2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2015-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* C implementation of UNIX which(1) /* C implementation of UNIX which(1)
* *
* Copyright (c) 2017 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2017-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* Safe yes-or-no with prompt /* Safe yes-or-no with prompt
* *
* Copyright (c) 2009 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+5
View File
@@ -1,18 +1,23 @@
*.o
*.log *.log
*.trs *.trs
.deps/
chomp chomp
copyfile copyfile
dir dir
fexist fexist
fisdir fisdir
fopenf
fsendfile fsendfile
lfile lfile
makepath makepath
pidfile pidfile
printhdr
progress progress
rsync rsync
str str
strmatch strmatch
systemf
tempfile tempfile
touch touch
tree tree
+3
View File
@@ -7,14 +7,17 @@ TESTS += copyfile
TESTS += dir TESTS += dir
TESTS += fexist TESTS += fexist
TESTS += fisdir TESTS += fisdir
TESTS += fopenf
TESTS += fsendfile TESTS += fsendfile
TESTS += lfile TESTS += lfile
TESTS += makepath TESTS += makepath
TESTS += pidfile TESTS += pidfile
TESTS += printhdr
TESTS += progress TESTS += progress
TESTS += rsync TESTS += rsync
TESTS += str TESTS += str
TESTS += strmatch TESTS += strmatch
TESTS += systemf
TESTS += touch TESTS += touch
TESTS += tempfile TESTS += tempfile
TESTS += which TESTS += which
+18
View File
@@ -0,0 +1,18 @@
#include "check.h"
int main(void)
{
FILE *fp;
char *dir = "/tmp";
char *file = "__foo__";
fp = fopenf("w", "%s/%s", dir, file);
if (fp) {
fputs("foo", fp);
fclose(fp);
}
fail_unless(fexist("/tmp/__foo__"));
return 0;
}
+33 -11
View File
@@ -4,6 +4,8 @@
#include <stdlib.h> #include <stdlib.h>
#include "check.h" #include "check.h"
#define BASEDIR "/tmp/libite-test"
int checkpath(const char *dir) int checkpath(const char *dir)
{ {
char tmp[256]; char tmp[256];
@@ -32,28 +34,48 @@ int test_makepath(const char *dir)
return ret; return ret;
} }
int test_fmkpath(const char *subdir)
{
int ret;
ret = fmkpath(0755, "%s/%s", BASEDIR, subdir);
if (!ret) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s/%s", BASEDIR, subdir);
ret = checkpath(tmp);
} else
perror("Failed");
return ret;
}
int main(void) int main(void)
{ {
int i, ret = 0; int i, ret = 0;
char *list[] = { char *list[] = {
"/tmp/libite-test/tok/", BASEDIR "/tok/",
"/tmp/libite-test/tok2", BASEDIR "/tok2",
"/tmp/libite-test/ab", BASEDIR "/ab",
"/tmp/libite-test/b", BASEDIR "/b",
"/tmp/libite-test/a/", BASEDIR "/a/",
"/tmp/libite-test/a/b", BASEDIR "/a/b",
"/tmp/libite-test/a/c/", BASEDIR "/a/c/",
NULL NULL
}; };
printf("Testing makepath() ...\n"); mkdir(BASEDIR, 0755);
mkdir("/tmp/libite-test", 0755);
printf("PASS 1/2: makepath() ======================================\n");
for (i = 0; list[i] && !ret; i++) for (i = 0; list[i] && !ret; i++)
ret |= test_makepath(list[i]); ret |= test_makepath(list[i]);
printf("\nCleaning up ...\n"); printf("PASS 2/2: fmkpath() =======================================\n");
system("rm -rf /tmp/libite-test"); for (i = 0; list[i] && !ret; i++)
ret |= test_fmkpath(list[i] + strlen(BASEDIR) + 1);
printf("DONE: Cleaning up =========================================\n");
system("rm -rf " BASEDIR);
return ret; return ret;
} }
+20
View File
@@ -0,0 +1,20 @@
#include <stdlib.h> /* atexit() */
#include <unistd.h> /* usleep() */
#include "check.h"
#define SCREEN_WIDTH 80
int main(void)
{
FILE *fp = stderr;
char buf[SCREEN_WIDTH];
printhdr(fp, "", 0, UNDERSCORE);
printhdr(fp, "Neighbor Table", 0, 0);
snprintf(buf, sizeof(buf), "%-15s %-15s %7s %-5s%10s %6s",
"Neighbor", "Interface", "Version", "Flags", "Uptime", "Expire");
printhdr(fp, buf, 0, REVERSE);
return 0;
}
+31
View File
@@ -0,0 +1,31 @@
#include <err.h>
#include "check.h"
int main(void)
{
struct { char *cmd; int rc; } list[] = {
{ "false", 1 },
{ "true", 0 },
{ "kill -9 $$", 1 },
{ "kill -QUIT $$", -1 },
{ "kill -INT $$", -1 }
};
for (size_t i = 0; i < NELEMS(list); i++) {
int rc;
rc = systemf("%s", list[i].cmd);
if (rc != list[i].rc)
err(rc, "Failed command %s", list[i].cmd);
}
return 0;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/