whio

Not logged in

libwhio

Welcome to the Fossil source code repository for libwhio, the WanderingHorse.net I/O library for C. whio is a C library encapsulating an i/o device and stream API. It originally developed as parts of two other libraries, but was found to be generic enough to fork out into its own library.

Author: Stephan Beal (http://wanderinghorse.net/home/stephan/)

License: Public Domain

Code status: Works for me! whio is a core component of libwhefs, is developed in close conjunction with that library, and seems to work well. It is also the basis for a set of JavaScript I/O classes based on the Google v8 JavaScript engine, and (unsurprisingly) has caused no Grief there, either.

Download: downloads page

What is whio?

The API provides an object oriented interface, called whio_dev, for interacting with random-access data stores. On top of this interface, concrete implementations are provided for FILE and in-memory data stores (via dynamic memory or a client-supplied memory range). All implementations have the same, fairly small, public interface.

It can essentially be used to wrap any random-access data stream, and adding wrappers for custom stream types is easy to do. For example libwhefs, an embedded filesystem library, uses a custom whio_dev implementation to provide access to "virtual" files (inside an embedded filesystem) using the same API as one can use for FILE and memory buffer access.

The API also provides another object oriented interface, whio_stream, for interacting with sequential streams. Implementations exist for FILE handles and whio_dev objects, which allows streams to act on any i/o source/destination supported by whio_dev. This is a more lightweight API than whio_dev, but is suitable when one only needs sequential access. This was originally developed as part of libc11n, a data serialization framework, but was forked out for inclusion into the more generic whio library.

Features:

Misfeatures

Requirements

The code is ANSI C, using some C99 features. The file-based i/o handlers, as opposed to the memory-based handlers, require some functions defined in POSIX-1.2001. All (or most) Unix systems will have the few POSIX functions the API requires.

It has been shown to compile using gcc 4.2.x on Linux x86/32, gcc 4.1 on Linux x86/64, tcc on Linux/x86, and gcc 3.4 on Solaris/Sparc, but older gcc versions explicitly require using the -std=c99 flag to enable the C99 features which whio uses.

There are some optional features which use zlib to provide gzip compression to/from whio_stream objects, and these features require zlib (which is installed by default on nearly every system on the planet). See whio_zlib.h for the routines and the macro which needs to be set to enable these functions.

Potential uses

See also...

News

13 Dec 2009:

8 June 2009:

9 March 2009:

30 Dec 2008: