libstrl: BSD/GNU String Compat

A reinvention of some commonly disputed wheels which vary in availability between GNU and BSD systems of various types and versions for the purpose of the prevention of further wheel reinvention.

libstrl is an attempt to address the strlcpy() problem. BSD systems ship with strlcpy(), strlcat(), wcslcpy(), and wcslcat(); GNU systems ship with strnlen(), wcsnlen(), getline(), and getdelim(). Both the strl* and strn* families of functions have valid uses, though the intent of this page is not to explore the stigma around either of these functions. This library is meant to discourage developers from bundling their own versions of the respective functions for portability's sake.

If your program uses the strlcpy() function, for example, and the developer is willing to create a dependency on libstrl, the hassle of bundling an implementation of strlcpy() can be replaced with the following code:

configure.ac:
PKG_CHECK_MODULES([LIBSTRL], [libstrl])
Makefile.am:
AM_LDFLAGS = $(LIBSTRL_LIBS)
AM_CPPFAGS = $(LIBSTRL_CFLAGS)
myfile.c:
#include <strl.h>

There are instructions for building libstrl below.

Documentation

Please see the HTML documentation on libstrl.h.

Download

Grab a tarball.

Development

If you are interested in improving libstrl, please consult binki first. Clone the libstrl mercurial repository:


 $ hg clone https://ohnopub.net/hg/libstrl

Submit patches or the output of hg export to libstrl's bug tracker.

During development, be sure to build libstrl with --enable-force-build and --with-check. If you are fixing something in the testsuite itself, please test that portion of the test suite against libstrl's own code (using --enable-force-build) and against an OS's version (by finding a system that provides that function and using --disable-force-build).

Build

Various ./configure options.

Dependencies

General

Et Cetera

I had Gentoo bug 351941 opened for this and dev-libs/libstrl is now in portage (and maintained by me).

See Also


Nathan Phillip Brink (binki) <ohnobinki at oh no publishing dot net> a.k.a. apostrophe
Last-Modified: 2011-12-23T20:42:47-05:00