description
libnostd is a collection of both cross-platform compatibility macros and routines, and common macros and routines used in general-purpose C programming.
For example, one compatibility issue addressed are the <sys/time.h> timer macros and gettimeofday(2) routine, some or all of which are not available in a WIN32 environment but provided in this library. Similarly, the popular strlcpy(3) and strlcat(3) routines are provided.
As a general rule, libnostd only contains interfaces which have a long history in the generally available body of C code. A de jure or de facto standard counts strongly (e.g. WinSock or ISO C99 routines).
Most interfaces--setproctitle() the exception--are
provided in headers files using macros and static
inline function definitions. No extra compilation
steps are required to make use of the library;
simply add the appropriate include paths. In
general, compatability is provided transparently.
For instance, for strlcpy() simply #include
<string.h>
, as-if on any modern BSD
environment.
Some of the interfaces provided:
setproctitle()
arc4random()
arc4random_buf()
strlcpy()
strlcat()
err.h
sys/param.h
sys/queue.h
sys/tree.h
sys/time.h
stdatomic.h
strdupa()
strndupa()
strnlen()
todo
Test new pidfile API addition. Perhaps don't even unlink the file when O_EXLOCK is provided; maybe those useless inode checks in the FreeBSD implemention were because O_EXLOCK isn't atomic with the open afterall.
news
2012-03-16
Apply setproctitle patch from Eric Wong to silence -Wstrict-prototypes and -Wredundant-decls warnings.
Import svn repository to git.
2010-02-24
Implement setproctitle() for Linux and Darwin/OS X. It doesn't [yet] seem possible to implement this inline as it needs to initialize a global state from the original
argv
andenviron
using__attribute__((constructor))
.It is thus currently presumed that if setproctitle is used the application will build the included setproctitle.c.
2009-03-08
Stumbled across FreeBSD pidfile libutil API, eerily similar in most respects to my own in my personal toolbox. Took a crack at implementing the FreeBSD interface in a more portable way; for example, don't unlink the pid file when O_EXLOCK is not supported (e.g. Linux), otherwise there are races. Not portable yet to Win32; likely never. Though probably technically feasible, Win32 and Unix have different conceptions of the role of both files and processes.
2008-10-31
Add arc4random_buf() implementation to sychronize with OpenBSD 4.4.
2008-09-13
Refactor code [mostly] into header files with inline static definitions. This greatly simplifies use; most compilers implement dead-code elimination. Add Linux and Win32 compatible arc4random(). Add re-written versions of strlcat() and strcpy(), better tailored to common glibc optimizations.
2007-04-12
Renamed the project from libcom to libnostd.
2007-03-18
New include layout. Mirrors the layout from standard definitions (e.g. <sys/time/gettimeofday.h>).
2006-11-12
Created.
license
Copyright (c) 2006-2010 William Ahern
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
source
git clone http://25thandClement.com/~william/projects/libnostd.git