libnih is a light-weight "standard library" of C functions to ease the development of other libraries and applications. Its goals are: * despite its name, to _not_ reimplement anything found in the standard C library or any library normally found in /lib; * use standard C types and conventions where appropriate; * have a simple and consistent programming interface; * be useful to library developers without needing to be exposed in the library's API; * not hide implementation details or structure contents, we're all adults after all. Dependencies ------------ The D-Bus messaging system is required to build the libnih-dbus library and nih-dbus-tool utility. In order to query the availability of the external library, the pkg-config tool is used; and in order to parse D-Bus introspection data, the expat XML parsing library will be used. The recommended versions are: * pkg-config 0.22 * D-Bus 1.2.16 * expat 2.0.0 These should all be available from the current release of any modern Linux distribution. For detailed compilation and installation instructions see the INSTALL file. If you've checked libnih out from revision control, or want to hack on libnih, see the HACKING file. Cross-compiling --------------- libnih uses the nih-dbus-tool utility it builds during its own build process to generate further sources to be built. When cross-compiling this will fail because the built nih-dbus-tool will most likely not be able to run on the build architecture. This can be solved by building and installing nih-dbus-tool for the build architecture first, then when performing the cross-compile, the installed copy will be used instead. If installed into a common system directory, this is automatic; if not, you can pass the path of the nih-dbus-tool binary to the configure script, e.g.: ./configure --build=i486-linux-gnu --host=gnueabi-linux-arm \ NIH_DBUS_TOOL=/cross/bin/nih-dbus-tool
NIH Utility Library
libnih is a light-weight "standard library" of C functions to ease the development of other libraries and applications. Its goals are: * despite its name, to _not_ reimplement anything found in the standard C library or any library noCategory: C/C++ / Miscellaneous |
Watchers: 15 |
Star: 80 |
Fork: 31 |
Last update: Aug 3, 2022 |
I'm not sure if it's deliberate or not, but can license be changed to LGPL-2.1+ or GPL-2.0+? Instead of current GPL-2.0-only ?
Upstart when in user-session mode, needs to pass lists over dbus connection which may be empty.
This drops the != NULL check for NULL terminated arrays and moves the iteration loop inside an 'if' statement.
I just can't find examples nor a manual... could you... ?
better late than never
Fixes running libnih & upstart on XFS filesystem (and others that don't implement dirent.d_type)
Bug-Debian: http://bugs.debian.org/695604 Bug-Ubuntu: https://bugs.launchpad.net/bugs/672643
automake 2.0 will enable subdir-objects by default. 1.14 now issues warnings when sources are used from subdirectories, yet subdir-objects option is not used. libnih compiles with and without this option. with this option enabled, no warnings are displayed for each test_foo_SOURCES = tests/test_foo.c and the test_foo.o is placed in tests/test_foo.o instead of ./test_foo.o
$ make org.freedesktop.systemd1.h
GEN org.freedesktop.systemd1.h
nih-dbus-tool:marshal.c:172: Not reached assertion failed in marshal
/bin/bash: line 4: 12193 Aborted (core dumped) /usr/bin/nih-dbus-tool --package=upstart -- mode=proxy --prefix=systemd --default-interface=org.freedesktop.systemd1.Manager --output=org.freedesktop.systemd1.h org.freedesktop.systemd1.xml
that seems to explode upon seeing DBUS_TYPE_VARIANT, looking at the code, indeed there is no support to generate that. Not a blocker for me, for now.
Hi Scott,
We're using NIH for https://github.com/cgmanager/cgmanager. However, we need to use SCM_CRED/SCM_CREDENTIALS which is not supported by dbus on Linux.
We were therefore wondering about the possibility of adding a new D-Bus annotation to nih-dbus-tool say "client must send SCM creds with this method". FWICS, annotations only affect the tools that generate bindings code but are also some sort of loose contract between the D-Bus client and the server.
The D-Bus spec only seems to touch on the precise meaning of annotations very lightly unless I'm missing something. The D-Bus tutorial does cover them in a little more detail, but it seems unreasonable to consider the tutorial part of the official spec to me.
What the spec does refer to is "well-known" annotations which implies that other annotations may be possible? Indeed, I notice that although NIH supports async methods it does so using "com.netsplit.Nih.Method.Async" rather than the semi-well-known "org.freedesktop.DBus.GLib.Async" (semi since it's not in the spec, but is in the tutorial!)
Can you offer any advice or insight into this?
Cheers,
James.
Add integration with free CI service http://travis-ci.org to execute unit-tests on each push/branch/merge-proposal. At the moment nih_watch_reader tests hang indefinitely on travis-ci infrastructure which have been disabled for now.
I will investigate further why it fails in their environment. To further gather environment details I've executed procenv in that environment (expand context to see line 450 onwards at https://travis-ci.org/xnox/libnih/builds/14676025 ) which indicates an Ubuntu 12.04 OpenVZ container.
This add gtkdoc generated API docs for nih/*.h Also fixes up a few markup errors.
published at http://libnih.la
This branch changes output:
Testing nih_main_write_pidfile()
...with successful write
...with overwrite of existing pid
...with failure to write to temporary file
To:
ok 21 - nih_main_write_pidfile()
ok 22 - nih_main_write_pidfile() with successful write
ok 23 - nih_main_write_pidfile() with overwrite of existing pid
ok 24 - nih_main_write_pidfile() with failure to write to temporary file
Which is in TAP format (Test Anything Protocol).
This results in automake build logs change from:
...
PASS: test_command
PASS: test_config
PASS: test_logging
PASS: test_error
...
============================================================================
Testsuite summary for libnih 1.0.4
============================================================================
# TOTAL: 17
# PASS: 17
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
To:
PASS: test_error 1 - nih_error_raise()
PASS: test_error 2 - nih_error_raise_printf()
PASS: test_error 3 - nih_error_raise_system()
PASS: test_error 4 - nih_error_raise_no_memory()
PASS: test_error 5 - nih_error_raise_error()
PASS: test_error 6 - nih_error_raise_error() with no current error
PASS: test_error 7 - nih_error_raise_error() with unhandled error
PASS: test_error 8 - nih_return_error()
PASS: test_error 9 - nih_return_system_error()
PASS: test_error 10 - nih_return_no_memory_error()
PASS: test_error 11 - nih_error_steal()
PASS: test_error 12 - nih_error_steal() with same context
PASS: test_error 13 - nih_error_steal() with different contexts
PASS: test_error 14 - nih_error_push_context()
PASS: test_error 15 - nih_error_pop_context()
PASS: test_error 16 - nih_error_pop_context() with unhandled error in context
PASS: test_error 17 - nih_error_pop_context() with unhandled error beneath context
make[3]: Entering directory `/home/xnox/canonical/libnih/libnih/nih'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/xnox/canonical/libnih/libnih/nih'
============================================================================
Testsuite summary for libnih 1.0.4
============================================================================
# TOTAL: 839
# PASS: 839
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
Which is a more accurate and useful build-log output. Furthermore it will enable: skipping tests, marking them expected fail, marking them TODO (unimplemented features), whilst accurately reporting each one of them.
There is no break in testing API and this implementation works across all libnih tests. There is no dependency on executing the test-suite under the TAP runner.
There is one change of behaviour: instead of aborting (bailing) on test failure, a FAIL is reported and the individual test binary will "keep going". I believe this is acceptable as the overall build will fail and is accurately reported. I added a define "TEST_TAP_BAIL_ON_FAIL" which will report a TAP "bail" command and abort as it was done previously. In case one wants previous behaviour.